From ee6e2cf3c45d0e49a9a7d16081c4958413190ef5 Mon Sep 17 00:00:00 2001 From: "action@github.com" Date: Wed, 5 Jun 2024 20:44:58 +0000 Subject: [PATCH] Updates --- assets/index-1c16127b.css | 1 - assets/index-6614c9bf.js | 1867 -------------- assets/index-84a3106f.js | 2270 +++++++++++++++++ assets/index-c064dc85.css | 1 + ...ex.es-eac68d26.js => index.es-93d23083.js} | 2 +- ...n-b9cca550.js => jspdf.es.min-fee19fbe.js} | 4 +- index.html | 4 +- 7 files changed, 2276 insertions(+), 1873 deletions(-) delete mode 100644 assets/index-1c16127b.css delete mode 100644 assets/index-6614c9bf.js create mode 100644 assets/index-84a3106f.js create mode 100644 assets/index-c064dc85.css rename assets/{index.es-eac68d26.js => index.es-93d23083.js} (99%) rename assets/{jspdf.es.min-b9cca550.js => jspdf.es.min-fee19fbe.js} (99%) diff --git a/assets/index-1c16127b.css b/assets/index-1c16127b.css deleted file mode 100644 index 92abc46..0000000 --- a/assets/index-1c16127b.css +++ /dev/null @@ -1 +0,0 @@ -._context-menu_18ock_1{position:fixed;background-color:#fffffff2;border:1px solid rgba(0,0,0,.1);border-radius:3px;font-size:12px;cursor:default;padding:3px;box-shadow:0 0 3px #0000001a,0 1px 5px #0000000d}._context-menu-dark_18ock_12{color:#ccc;background-color:#444444f7}._context-menu-icon_18ock_17{display:inline-block;margin-right:3px;vertical-align:middle}._context-menu-icon_18ock_17>svg{width:30px;height:20px}._context-menu-item_18ock_27{padding:2px;white-space:nowrap;border-radius:2px;transition:background .15s cubic-bezier(.25,.1,.25,1),color .15s cubic-bezier(.25,.1,.25,1)}._context-menu-item_18ock_27:hover{background:#337ab7;color:#fff}._context-menu-hr_18ock_38{margin-top:5px;margin-bottom:5px;border:0;border-top:1px solid rgba(0,0,0,.1)}._play-icon_18ock_45{width:12px;height:12px;position:absolute;right:5px}._context-menu-span_18ock_52{margin-right:20px;vertical-align:middle;display:inline-block;line-height:normal;white-space:nowrap}._context-menu-thumbnail_18ock_60{margin-right:10px;border:1px solid #888888}._context-menu-thumbnail-inline_18ock_65{display:inline-block;margin-right:10px;vertical-align:middle}._multitrack-header_1yz7l_1,._multitrack-header-focus_1yz7l_2,._multitrack-header-squeazed_1yz7l_3{position:relative;display:flex;justify-content:space-between;height:24px;margin-top:4px;margin-bottom:4px;color:#999;font-size:12px;line-height:24px;vertical-align:middle;border:0;border-radius:3px;background:#e5e5e5;transition:height .15s cubic-bezier(.25,.1,.25,1),margin .15s cubic-bezier(.25,.1,.25,1)}._multitrack-header-dark_1yz7l_20{background:#222}._multitrack-header-focus_1yz7l_2{height:32px;margin-top:0;margin-bottom:0}._multitrack-header-id_1yz7l_30{padding-left:3px}._multitrack-header-id_1yz7l_30:before{content:"ID:";font-weight:700;padding-right:5px}._multitrack-header-left_1yz7l_39{display:flex;flex-grow:1}._multitrack-header-grabber_1yz7l_44,._multitrack-header-grabber-squeazed_1yz7l_45{display:flex;align-items:center;justify-content:center;width:24px;height:100%;cursor:move;border-radius:3px 0 0 3px;transition:background .15s cubic-bezier(.25,.1,.25,1)}._multitrack-header-grabber_1yz7l_44:hover,._multitrack-header-grabber-squeazed_1yz7l_45:hover{background:#999}._multitrack-header-grabber_1yz7l_44:hover div,._multitrack-header-grabber-squeazed_1yz7l_45:hover div{background:#fff}._multitrack-header-grabber_1yz7l_44 div,._multitrack-header-grabber-squeazed_1yz7l_45 div{width:1px;height:50%;margin:1px;background:#999;transition:background .15s cubic-bezier(.25,.1,.25,1)}._multitrack-header-dark_1yz7l_20 ._multitrack-header-grabber_1yz7l_44 div{background:#666}._multitrack-header-grabber-squeazed_1yz7l_45{width:19.2px}._multitrack-header-search_1yz7l_80{position:relative;flex-grow:1;height:100%;margin-right:12px}._multitrack-header-search_1yz7l_80:after{position:absolute;top:3px;bottom:3px;right:-12px;display:block;content:"";width:1px;margin:0 6px;background:#cccccc}._multitrack-header-dark_1yz7l_20 ._multitrack-header-search_1yz7l_80:after{background:#666}._multitrack-header-nav-list_1yz7l_102,._multitrack-header_1yz7l_1>nav{display:flex}._multitrack-header-icon_1yz7l_107,._multitrack-header-icon-squeazed_1yz7l_108{width:24px;height:100%;padding:6px;transition:background .15s cubic-bezier(.25,.1,.25,1),color .15s cubic-bezier(.25,.1,.25,1)}._multitrack-header-icon_1yz7l_107 g,._multitrack-header-icon-squeazed_1yz7l_108 g{stroke:#999}._multitrack-header-icon_1yz7l_107:hover,._multitrack-header-icon_1yz7l_107:active,._multitrack-header-icon_1yz7l_107:focus,._multitrack-header-icon-squeazed_1yz7l_108:hover,._multitrack-header-icon-squeazed_1yz7l_108:active,._multitrack-header-icon-squeazed_1yz7l_108:focus{color:#fff;background:#337ab7}._multitrack-header-icon_1yz7l_107:hover g,._multitrack-header-icon_1yz7l_107:active g,._multitrack-header-icon_1yz7l_107:focus g,._multitrack-header-icon-squeazed_1yz7l_108:hover g,._multitrack-header-icon-squeazed_1yz7l_108:active g,._multitrack-header-icon-squeazed_1yz7l_108:focus g{stroke:#fff}._multitrack-header-icon_1yz7l_107:last-child,._multitrack-header-icon-squeazed_1yz7l_108:last-child{border-radius:0 3px 3px 0}._mouse-tool-selection_1yz7l_136{color:#fff;border-radius:3px 0 0 3px;background:#337ab7}._multitrack-header-icon-squeazed_1yz7l_108{width:20px 5;padding-left:3px;padding-right:3px}._track-control_w7hx2_1,._track-control-vertical_w7hx2_2{position:absolute;z-index:1;display:flex;background:rgba(255,255,255,.75);right:2px;top:2px;border-radius:2.5px;box-shadow:0 0 0 1px #0000000d,0 0 3px #0000001a;opacity:0;transition:opacity .15s cubic-bezier(.25,.1,.25,1),background .15s cubic-bezier(.25,.1,.25,1),box-shadow .15s cubic-bezier(.25,.1,.25,1)}._track-control-dark_w7hx2_15,._track-control-dark_w7hx2_15 ._track-control-active_w7hx2_16{background:rgba(40,40,40,.85)}._track-control-vertical_w7hx2_2{flex-direction:column-reverse}._track-control-left_w7hx2_24{left:2px;right:auto}._track-control-active_w7hx2_16,._track-control-vertical-active_w7hx2_30{opacity:1;z-index:1}._track-control-active_w7hx2_16:hover,._track-control-vertical-active_w7hx2_30:hover{background:rgb(255,255,255);box-shadow:0 0 0 1px #0000001a,0 0 3px #0003}._track-control-dark_w7hx2_15._track-control-active_w7hx2_16:hover{background:rgba(34,34,34,.95)}._track-control-padding-right_w7hx2_48{right:80px}._track-control-button_w7hx2_52{width:20px;height:20px;padding:4px;cursor:pointer;opacity:.66;transition:background .15s cubic-bezier(.25,.1,.25,1),color .15s cubic-bezier(.25,.1,.25,1),opacity .15s cubic-bezier(.25,.1,.25,1)}._track-control-button_w7hx2_52:hover{color:#fff;background:#337ab7;opacity:1}._track-control-button_w7hx2_52:first-child{border-radius:2.5px 0 0 2.5px}._track-control-button_w7hx2_52:last-child{border-radius:0 2.5px 2.5px 0}._track-control-dark_w7hx2_15 ._track-control-button_w7hx2_52{color:#ccc}._track-control-dark_w7hx2_15 ._track-control-button_w7hx2_52:hover{color:#fff;background:#337ab7;opacity:1}._track-control-button-vertical_w7hx2_81:first-child{border-radius:0 0 2.5px 2.5px}._track-control-button-vertical_w7hx2_81:last-child{border-radius:2.5px 2.5px 0 0}._center-track_fiu64_1{position:relative;background:transparent}._center-track-container_fiu64_6{position:absolute;z-index:1}._track-range-selection_5bcsr_1{position:absolute;z-index:-1;opacity:0;transition:opacity .15s cubic-bezier(.25,.1,.25,1)}._track-range-selection-active_5bcsr_8{z-index:1;opacity:1}._track-range-selection-group-inactive_5bcsr_22{display:none}._track-range-selection-group-brush-selection_5bcsr_26{outline:2px solid rgba(0,0,0,.33);fill:#000;fill-opacity:.1}._drag-listening-div-active_19gkt_1{z-index:10;box-shadow:inset 0 0 3px red}._gallery-tracks_fbxxi_1{position:relative;top:0;left:0;width:100%;height:100%}._gallery-track_fbxxi_1{position:absolute;box-sizing:border-box;inset:0}._gallery-sub-track_fbxxi_18,._gallery-invisible-track_fbxxi_19{position:absolute}._tiled-plot_1y7td_1{position:relative;flex:1;overflow:hidden}._horizontalList_1y7td_7{display:flex;width:600px;height:300px;white-space:nowrap}._list_1y7td_14{width:400px;height:600px;overflow:hidden;-webkit-overflow-scrolling:touch}._stylizedList_1y7td_21{position:relative;z-index:0;background-color:#f3f3f3;outline:none}._stylizedItem_1y7td_28{position:relative;display:flex;align-items:center;width:100%;background-color:transparent;user-select:none;color:#333;font-weight:400}._stylizedHelper_1y7td_39{box-shadow:0 5px 5px -5px #0003,0 -5px 5px -5px #0003;background-color:#fffc;cursor:row-resize}._stylizedHelper_1y7td_39._horizontalItem_1y7td_44{cursor:col-resize}._horizontalItem_1y7td_44{display:flex;flex-shrink:0;align-items:center;justify-content:center}._resizable-track_1y7td_55{width:100%;height:100%}path._domain_1y7td_60{stroke-width:0px}._top-right-handle_cizw2_1,._bottom-right-handle_cizw2_2{border-right:black solid;border-top:black solid}._top-left-handle_cizw2_7,._bottom-left-handle_cizw2_8{border-left:black solid;border-top:black solid}._top-draggable-handle_cizw2_13,._bottom-draggable-handle_cizw2_14,._left-draggable-handle_cizw2_15,._right-draggable-handle_cizw2_16{position:absolute;opacity:0;transition:transform .15s cubic-bezier(.25,.1,.25,1),opacity .15s cubic-bezier(.25,.1,.25,1)}._draggable-div_cizw2_22{background-color:transparent;box-sizing:border-box}._top-draggable-handle-grabber_cizw2_27,._bottom-draggable-handle-grabber_cizw2_28{width:10px;height:4px;border-top:1px solid black;border-bottom:1px solid black}._top-draggable-handle-grabber_cizw2_27,._bottom-draggable-handle-grabber_cizw2_28{margin:4px 7px}._left-draggable-handle-grabber_cizw2_43,._right-draggable-handle-grabber_cizw2_44{width:4px;height:10px;border-left:1px solid black;border-right:1px solid black}._left-draggable-handle-grabber_cizw2_43,._right-draggable-handle-grabber_cizw2_44{margin:7px 4px}._draggable-div_cizw2_22:hover ._top-draggable-handle_cizw2_13,._draggable-div_cizw2_22:hover ._bottom-draggable-handle_cizw2_14,._draggable-div_cizw2_22:hover ._left-draggable-handle_cizw2_15,._draggable-div_cizw2_22:hover ._right-draggable-handle_cizw2_16{opacity:.5;background:rgba(255,255,255,.75);box-shadow:0 0 3px 1px #ffffffbf;border-radius:3px}._top-draggable-handle_cizw2_13:hover,._top-draggable-handle_cizw2_13:active,._bottom-draggable-handle_cizw2_14:hover,._bottom-draggable-handle_cizw2_14:active,._left-draggable-handle_cizw2_15:hover,._left-draggable-handle_cizw2_15:active,._right-draggable-handle_cizw2_16:hover,._right-draggable-handle_cizw2_16:active{opacity:1!important;transform:scale(2)}._top-draggable-handle_cizw2_13:hover ._top-draggable-handle-grabber_cizw2_27,._top-draggable-handle_cizw2_13:hover ._bottom-draggable-handle-grabber_cizw2_28,._top-draggable-handle_cizw2_13:hover ._left-draggable-handle-grabber_cizw2_43,._top-draggable-handle_cizw2_13:hover ._right-draggable-handle-grabber_cizw2_44,._top-draggable-handle_cizw2_13:active ._top-draggable-handle-grabber_cizw2_27,._top-draggable-handle_cizw2_13:active ._bottom-draggable-handle-grabber_cizw2_28,._top-draggable-handle_cizw2_13:active ._left-draggable-handle-grabber_cizw2_43,._top-draggable-handle_cizw2_13:active ._right-draggable-handle-grabber_cizw2_44,._bottom-draggable-handle_cizw2_14:hover ._top-draggable-handle-grabber_cizw2_27,._bottom-draggable-handle_cizw2_14:hover ._bottom-draggable-handle-grabber_cizw2_28,._bottom-draggable-handle_cizw2_14:hover ._left-draggable-handle-grabber_cizw2_43,._bottom-draggable-handle_cizw2_14:hover ._right-draggable-handle-grabber_cizw2_44,._bottom-draggable-handle_cizw2_14:active ._top-draggable-handle-grabber_cizw2_27,._bottom-draggable-handle_cizw2_14:active ._bottom-draggable-handle-grabber_cizw2_28,._bottom-draggable-handle_cizw2_14:active ._left-draggable-handle-grabber_cizw2_43,._bottom-draggable-handle_cizw2_14:active ._right-draggable-handle-grabber_cizw2_44,._left-draggable-handle_cizw2_15:hover ._top-draggable-handle-grabber_cizw2_27,._left-draggable-handle_cizw2_15:hover ._bottom-draggable-handle-grabber_cizw2_28,._left-draggable-handle_cizw2_15:hover ._left-draggable-handle-grabber_cizw2_43,._left-draggable-handle_cizw2_15:hover ._right-draggable-handle-grabber_cizw2_44,._left-draggable-handle_cizw2_15:active ._top-draggable-handle-grabber_cizw2_27,._left-draggable-handle_cizw2_15:active ._bottom-draggable-handle-grabber_cizw2_28,._left-draggable-handle_cizw2_15:active ._left-draggable-handle-grabber_cizw2_43,._left-draggable-handle_cizw2_15:active ._right-draggable-handle-grabber_cizw2_44,._right-draggable-handle_cizw2_16:hover ._top-draggable-handle-grabber_cizw2_27,._right-draggable-handle_cizw2_16:hover ._bottom-draggable-handle-grabber_cizw2_28,._right-draggable-handle_cizw2_16:hover ._left-draggable-handle-grabber_cizw2_43,._right-draggable-handle_cizw2_16:hover ._right-draggable-handle-grabber_cizw2_44,._right-draggable-handle_cizw2_16:active ._top-draggable-handle-grabber_cizw2_27,._right-draggable-handle_cizw2_16:active ._bottom-draggable-handle-grabber_cizw2_28,._right-draggable-handle_cizw2_16:active ._left-draggable-handle-grabber_cizw2_43,._right-draggable-handle_cizw2_16:active ._right-draggable-handle-grabber_cizw2_44{box-shadow:0 0 3px 1px #0089ff;background:#0089ff}._top-draggable-handle_cizw2_13,._bottom-draggable-handle_cizw2_14{height:12px;cursor:row-resize}._left-draggable-handle_cizw2_15,._right-draggable-handle_cizw2_16{width:12px;cursor:col-resize}._horizontal-tiled-plot_1bqkg_1,._track-renderer_11dwb_1{position:relative}._track-renderer-element_11dwb_5,._track-renderer-events_11dwb_6{position:absolute;inset:0;z-index:-1}._track-renderer-events_11dwb_6{z-index:1}._button_1wnjn_1{display:flex;align-items:center;box-sizing:border-box;padding:.5em;color:#000;font-size:1em;line-height:1em;border:0;border-radius:2.5px;background:#fff;box-shadow:0 0 0 1px #ccc;transition:transform .15s cubic-bezier(.25,.1,.25,1),box-shadow .15s cubic-bezier(.25,.1,.25,1),background .15s cubic-bezier(.25,.1,.25,1);-webkit-appearance:none}._button_1wnjn_1:hover{background:#f2f2f2;box-shadow:0 0 0 1px #ccc}._button_1wnjn_1:focus{box-shadow:0 0 0 2px #0089ff}._button_1wnjn_1:active{transform:scale(.9)}._button_1wnjn_1:hover,._button_1wnjn_1:focus,._button_1wnjn_1:active{cursor:pointer;outline:none}._button-shortcut_1wnjn_35{padding:.1em 5px;color:#999;font-size:.8em;transition:color .15s cubic-bezier(.25,.1,.25,1)}._cross_2ke8w_1{position:relative;width:1em;height:1em}._cross_2ke8w_1:before,._cross_2ke8w_1:after{content:"";display:block;position:absolute;top:50%;left:0;width:1em;height:1px;background:black;transform-origin:center}._cross_2ke8w_1:before{-webkit-transform:translate(0,-50%) rotate(45deg);-moz-transform:translate(0,-50%) rotate(45deg);transform:translateY(-50%) rotate(45deg)}._cross_2ke8w_1:after{-webkit-transform:translate(0,-50%) rotate(-45deg);-moz-transform:translate(0,-50%) rotate(-45deg);transform:translateY(-50%) rotate(-45deg)}._modal-background_zzhoe_1{position:absolute;z-index:1000;inset:0;background:rgba(0,0,0,.666);animation:_fade-in_zzhoe_1 .2s cubic-bezier(.25,.1,.25,1) 1;transition:opacity .2s cubic-bezier(.25,.1,.25,1)}._modal-hide_zzhoe_13{opacity:0}._modal-wrap_zzhoe_17{position:absolute;inset:20px}._modal-window_zzhoe_25{position:relative;width:100%;max-width:640px;max-height:100%;margin-left:auto;margin-right:auto;color:#000;border-radius:5px;background:#fff;animation:_fade-scale-in_zzhoe_1 .2s cubic-bezier(.25,.1,.25,1) 1}._modal-window-max-height_zzhoe_38{height:100%}._modal-content_zzhoe_42{padding:10px}@keyframes _fade-in_zzhoe_1{0%{opacity:0}to{opacity:1}}@keyframes _fade-scale-in_zzhoe_1{0%{opacity:0;transform:scale(.5)}to{opacity:1;transform:scale(1)}}._dialog-header_wp50s_1{position:relative;z-index:2;display:flex;justify-content:space-between;margin:0 -10px 10px;padding:0 10px 10px;border-bottom:1px solid #cccccc}._dialog-header_wp50s_1 h3{margin:0;padding:0;font-size:20px;line-height:1em}._dialog-header_wp50s_1 button{font-size:10px}._dialog-main-max-height_wp50s_20{position:absolute;z-index:1;inset:40px 0 50px;padding:10px;overflow:auto}._dialog-footer_wp50s_31,._dialog-footer-max-height_wp50s_31{display:flex;justify-content:space-between;margin:10px -10px 0;padding:10px 10px 0;border-top:1px solid #cccccc}._dialog-footer_wp50s_31 button,._dialog-footer-max-height_wp50s_31 button{font-size:14px}._dialog-footer-max-height_wp50s_31{position:absolute;z-index:2;left:10px;right:10px;bottom:10px}.tileset-finder-label{font-weight:700}.tileset-finder-search-box{margin-left:10px}.tileset-finder-search-bar{display:flex;margin-left:5px;justify-content:space-between;align-items:center}.tileset-finder-checkbox-tree{margin:5px;padding:3px;border:1px solid #aaaaaa;border-radius:5px}.react-checkbox-tree{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:reverse;-ms-flex-direction:row-reverse;flex-direction:row-reverse;font-size:16px}.react-checkbox-tree>ol{-webkit-box-flex:1;-ms-flex:1 1 auto;flex:1 1 auto}.react-checkbox-tree ol{margin:0;padding-left:0;list-style-type:none}.react-checkbox-tree ol ol{padding-left:24px}.react-checkbox-tree button{line-height:normal;color:inherit}.react-checkbox-tree button:disabled{cursor:not-allowed}.react-checkbox-tree .rct-bare-label{cursor:default}.react-checkbox-tree label{margin-bottom:0;cursor:pointer}.react-checkbox-tree label:hover{background:rgba(51,51,204,.1)}.react-checkbox-tree label:active,.react-checkbox-tree label:focus{background:rgba(51,51,204,.15)}.react-checkbox-tree:not(.rct-native-display) input{display:none}.react-checkbox-tree.rct-native-display input{margin:0 5px}.react-checkbox-tree .rct-icon{display:inline-block;text-align:center;text-rendering:auto;font-family:"Font Awesome 5 Free",FontAwesome,sans-serif;font-weight:400;font-variant:normal;font-style:normal}.rct-disabled>.rct-text>label{opacity:.75;cursor:not-allowed}.rct-disabled>.rct-text>label:hover{background:transparent}.rct-disabled>.rct-text>label:active{background:transparent}.rct-text{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.rct-options{-webkit-box-flex:0;-ms-flex:0 0 auto;flex:0 0 auto;margin-left:.5rem;text-align:right}.rct-option{opacity:.75;border:0;background:none;cursor:pointer;padding:0 4px;font-size:18px}.rct-option:hover{opacity:1}.rct-option+.rct-option{margin-left:2px}.rct-collapse,.rct-checkbox,.rct-node-icon{padding:0 5px}.rct-collapse *,.rct-checkbox *,.rct-node-icon *{display:inline-block;margin:0;width:14px}.rct-collapse{-ms-flex-item-align:stretch;align-self:stretch;border:0;background:none;line-height:normal;color:inherit;font-size:12px}.rct-collapse.rct-collapse-btn{cursor:pointer}.rct-collapse>.rct-icon-expand-close{opacity:.5}.rct-collapse>.rct-icon-expand-close:hover{opacity:1}.rct-native-display .rct-checkbox{display:none}.rct-node-clickable{cursor:pointer}.rct-node-clickable:hover{background:rgba(51,51,204,.1)}.rct-node-clickable:focus{outline:0;background:rgba(51,51,204,.2)}.rct-node-icon{color:#33c}.rct-title{padding:0 5px}.rct-icons-fa4 .rct-icon-expand-close:before{content:""}.rct-icons-fa4 .rct-icon-expand-open:before{content:""}.rct-icons-fa4 .rct-icon-uncheck:before{content:""}.rct-icons-fa4 .rct-icon-check:before{content:""}.rct-icons-fa4 .rct-icon-half-check:before{opacity:.5;content:""}.rct-icons-fa4 .rct-icon-leaf:before{content:""}.rct-icons-fa4 .rct-icon-parent-open:before{content:""}.rct-icons-fa4 .rct-icon-parent-close:before{content:""}.rct-icons-fa4 .rct-icon-expand-all:before{content:""}.rct-icons-fa4 .rct-icon-collapse-all:before{content:""}.rct-icons-fa5 .rct-icon-expand-close:before{font-weight:900;content:""}.rct-icons-fa5 .rct-icon-expand-open:before{font-weight:900;content:""}.rct-icons-fa5 .rct-icon-uncheck:before{content:""}.rct-icons-fa5 .rct-icon-check:before{content:""}.rct-icons-fa5 .rct-icon-half-check:before{opacity:.5;content:""}.rct-icons-fa5 .rct-icon-leaf:before{content:""}.rct-icons-fa5 .rct-icon-parent-open:before{content:""}.rct-icons-fa5 .rct-icon-parent-close:before{content:""}.rct-icons-fa5 .rct-icon-expand-all:before{content:""}.rct-icons-fa5 .rct-icon-collapse-all:before{content:""}.rct-direction-rtl{direction:rtl}.rct-direction-rtl ol ol{padding-right:24px;padding-left:0}.rct-direction-rtl.rct-icons-fa4 .rct-icon-expand-close:before{content:""}.rct-direction-rtl.rct-icons-fa5 .rct-icon-expand-close:before{content:""}.plot-type-selected{background-color:#0000ff4d}.plot-type-container{overflow-y:scroll;margin:5px;padding:3px;border:1px solid #aaaaaa;border-radius:5px;max-height:15vh}.plot-type-container-empty{margin:5px;padding:3px 8px;border:1px solid #aaaaaa;background-color:#e8e8e8;border-radius:5px}.plot-type-item{cursor:pointer}.plot-type-item:not(.plot-type-selected):hover{background-color:#3333cc1a}.track-thumbnail{width:30px;height:20px;display:inline-block;margin-right:10;vertical-align:middle}.track-thumbnail>svg{width:20px;height:20px}._collapse-toggle-icon_ub7s6_1:before{font-family:Glyphicons Halflings;content:"";float:left;padding-right:3px}._collapse-toggle-icon_ub7s6_1._collapsed_ub7s6_9:before{content:""}._modal-title_ub7s6_14{font-family:Roboto;font-weight:700}._modal-container_ub7s6_19{position:relative}._modal-container_ub7s6_19 ._modal_ub7s6_14,._modal-container_ub7s6_19 ._modal-backdrop_ub7s6_23{position:absolute}._modal-dialog_ub7s6_27{position:relative;display:table;overflow-y:auto;overflow-x:auto;width:600px;min-width:300px;margin:auto}table.table-track-options{border-collapse:collapse;margin-left:auto;margin-right:auto}td.td-track-options{border:1px solid #fff;outline:none;padding:3px;position:relative;font-family:Roboto,sans-serif;font-size:14px;color:#666}.cell-label{position:absolute;left:0;top:0;margin-left:5px;color:#777}.modal-dialog{position:relative;display:table;overflow-y:auto;overflow-x:auto;width:auto;min-width:300px;margin:auto}._vertical-tiled-plot_f3ho8_1{position:relative}._genome-position-search_1l2sx_1,._genome-position-search-focus_1l2sx_2{position:relative;display:flex;align-items:stretch;height:100%;margin-bottom:0;font-size:13.7142857143px;transition:box-shadow .15s cubic-bezier(.25,.1,.25,1),font-size .15s cubic-bezier(.25,.1,.25,1)}._genome-position-search-focus_1l2sx_2{box-shadow:0 0 0 1px #337ab7,0 0 3px 1px #337ab7}._genome-position-search-bar_1l2sx_16{position:relative;box-sizing:border-box;width:100%;height:100%;padding:3px;color:#666;font-size:inherit;line-height:24px;border:0;border-radius:3px 0 0 3px;background:transparent}._genome-position-search-bar_1l2sx_16:focus{outline:none;color:#000}._genome-position-search-dark_1l2sx_34 ._genome-position-search-bar_1l2sx_16:focus{color:#e5e5e5}._genome-position-search-bar-button_1l2sx_38,._genome-position-search-bar-button-focus_1l2sx_39{display:block;height:100%;padding:0 8px!important;color:#999;border:0!important;border-radius:0!important;background:transparent;transition:background .15s cubic-bezier(.25,.1,.25,1),color .15s cubic-bezier(.25,.1,.25,1)}._genome-position-search-bar-button_1l2sx_38:active,._genome-position-search-bar-button_1l2sx_38:focus,._genome-position-search-bar-button_1l2sx_38:hover,._genome-position-search-bar-button-focus_1l2sx_39:active,._genome-position-search-bar-button-focus_1l2sx_39:focus,._genome-position-search-bar-button-focus_1l2sx_39:hover{color:#fff;background:#337ab7}._genome-position-search-bar-button-focus_1l2sx_39{color:#fff;background:#337ab7}._genome-position-search-bar-icon_1l2sx_62,._genome-position-search-bar-icon-focus_1l2sx_63{display:flex;align-items:center;transition:color .15s cubic-bezier(.25,.1,.25,1)}._genome-position-search-bar-icon_1l2sx_62:first-child,._genome-position-search-bar-icon-focus_1l2sx_63:first-child{margin-left:6px;margin-right:2px}._genome-position-search-bar-icon_1l2sx_62 span,._genome-position-search-bar-icon-focus_1l2sx_63 span{display:block;margin-top:-2px}._genome-position-search-bar-icon-focus_1l2sx_63{color:#337ab7}._genome-position-search-bar-suggestions_1l2sx_83{position:fixed;border-radius:3px;box-shadow:0 0 3px #0000001a,0 1px 5px #0000000d;background-color:#fffffff2;border:1px solid rgba(0,0,0,.1);padding:2px 0;font-size:90%;overflow:auto;max-height:50%}._btn_1l2sx_95{display:inline-block;margin-bottom:0;font-size:13.7142857143px;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;-ms-touch-action:manipulation;touch-action:manipulation;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:none;border:1px solid transparent;border-radius:4px}._btn-sm_1l2sx_116{font-size:12px;line-height:1.5;border-radius:3px}._btn-default_1l2sx_122{color:#666;background-color:#fff;border-color:#ccc}._btn-default_1l2sx_122:hover{color:#000;background:#ccc}._btn-default_1l2sx_122:active,._btn-default_1l2sx_122:focus{color:#fff;border-color:#000;background:#000}._genome-position-search_1l2sx_1 ._btn_1l2sx_95{border-radius:0 3px 3px 0}._export-link-dialog-wrapper_p9gxw_1{display:flex}._export-link-dialog-wrapper_p9gxw_1 input{flex-grow:1}._add-track-position-table_wdy5w_1{border-collapse:collapse;margin:5px;color:#666}._add-track-position-table-dark_wdy5w_7{color:#ccc}._add-track-position-other_wdy5w_11{outline:none}._add-track-position-top-center_wdy5w_15{min-width:80px;min-height:20px;text-align:center;outline:none;border-top:1px solid #999;border-left:1px solid #999;border-right:1px solid #999;border-radius:2px 2px 0 0}._add-track-position-top-center_wdy5w_15:hover{color:#fff;background-color:#337ab7}._add-track-position-middle-left_wdy5w_30{min-width:40px;text-align:center;outline:none;border-top:1px solid #999;border-left:1px solid #999;border-bottom:1px solid #999;border-radius:2px 0 0 2px}._add-track-position-middle-left_wdy5w_30:hover{background-color:#337ab7;color:#fff}._add-track-position-middle-right_wdy5w_45{min-width:40px;text-align:center;outline:none;border-top:1px solid #999;border-right:1px solid #999;border-bottom:1px solid #999;border-radius:0 2px 2px 0}._add-track-position-middle-right_wdy5w_45:hover{background-color:#337ab7;color:#fff}._add-track-position-middle-middle_wdy5w_60{text-align:center;outline:none;border:1px solid #999}._add-track-position-middle-middle_wdy5w_60:hover{background-color:#337ab7;color:#fff}._add-track-position-bottom-middle_wdy5w_71{min-height:20px;text-align:center;outline:none;border-left:1px solid #999;border-right:1px solid #999;border-bottom:1px solid #999;border-radius:0 0 2px 2px}._add-track-position-bottom-middle_wdy5w_71:hover{background-color:#337ab7;color:#fff}._add-track-position-span_wdy5w_86{margin:5px}._view-config-editor-header_1hlm6_1{margin:-10px -10px 0;padding:10px;display:flex;justify-content:space-between;background:#f2f2f2}._view-config-editor-header_1hlm6_1 button{display:flex;align-items:center;font-size:14px;background:#f2f2f2}._view-config-editor-header_1hlm6_1 button:hover{background:#e5e5e5}._view-config-editor-header_1hlm6_1 button:hover span{color:#666}._view-config-editor_1hlm6_1{position:absolute;inset:50px 0 0;margin:1px 0 0;padding:0;overflow:auto;font-size:12.5px;height:calc(100% - 80px)}._view-config-log_1hlm6_34{position:absolute;right:0;bottom:0;left:0;margin:1px 0 0;padding:0;min-height:30px;background:#f2f2f2;transition:height .15s cubic-bezier(.25,.1,.25,1)}._view-config-log-header_1hlm6_46{background:#f2f2f2;border-top:1px solid #cccccc;border-bottom:1px solid #cccccc;padding-left:10px;height:30px;display:flex;align-items:center;cursor:pointer;position:sticky;position:-webkit-sticky;top:0}._view-config-log-msg_1hlm6_60{background:#f2f2f2;overflow:auto;height:calc(100% - 30px)}._view-config-log-msg_1hlm6_60 tr,._view-config-log-msg_1hlm6_60 td{outline:none;vertical-align:top}._view-config-log-msg_1hlm6_60 ._title_1hlm6_70{font-weight:700;padding-left:8px;padding-top:8px;width:100px}._view-config-log-msg_1hlm6_60 ._Warning_1hlm6_76{color:orange}._view-config-log-msg_1hlm6_60 ._Success_1hlm6_79{color:green}._view-config-log-msg_1hlm6_60 ._Error_1hlm6_82{color:red}._view-config-log-msg_1hlm6_60 pre{background:white;white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word}._higlass_1uoq8_1{position:relative}._higlass-dark-theme_1uoq8_5{background:black}._higlass-container-overflow_1uoq8_9,._higlass-scroll-container-overflow_1uoq8_10,._higlass-scroll-container-scroll_1uoq8_11{position:absolute;inset:0}._higlass-scroll-container-overflow_1uoq8_10{overflow:hidden}._higlass-scroll-container-scroll_1uoq8_11{overflow-x:hidden;overflow-y:auto}._higlass-canvas_1uoq8_28{position:absolute;width:100%;height:100%}._higlass-drawing-surface_1uoq8_34{position:relative}._higlass-svg_1uoq8_38{position:absolute;width:100%;height:100%;left:0;top:0;pointer-events:none}._tiled-area_1uoq8_47{display:flex;flex-direction:column}._track-mouseover-menu_1uoq8_52{position:fixed;z-index:1;margin:17px 0 0 9px;padding:0 .25rem;max-width:50vw;word-wrap:break-word;font-size:.8em;pointer-events:none;background:white;border-radius:.25rem;box-shadow:0 0 0 1px #0000001a,0 0 3px #00000013,0 0 7px #0000000d}.react-grid-layout{position:relative;transition:height .2s ease}.react-grid-item{transition:all .2s ease;transition-property:left,top}.react-grid-item.cssTransforms{transition-property:transform}.react-grid-item.resizing{z-index:1;will-change:width,height}.react-grid-item.react-draggable-dragging{transition:none;z-index:3;will-change:transform}.react-grid-item.react-grid-placeholder{background:red;opacity:.2;transition-duration:.1s;z-index:2;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.react-grid-item>.react-resizable-handle{position:absolute;width:20px;height:20px;bottom:0;right:0;cursor:se-resize}.react-grid-item>.react-resizable-handle:after{content:"";position:absolute;right:3px;bottom:3px;width:5px;height:5px;border-right:2px solid rgba(0,0,0,.4);border-bottom:2px solid rgba(0,0,0,.4)}.react-resizable{position:relative}.react-resizable-handle{position:absolute;width:20px;height:20px;background-repeat:no-repeat;background-origin:content-box;box-sizing:border-box;background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2IDYiIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNmZmZmZmYwMCIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iNnB4Ij48ZyBvcGFjaXR5PSIwLjMwMiI+PHBhdGggZD0iTSA2IDYgTCAwIDYgTCAwIDQuMiBMIDQgNC4yIEwgNC4yIDQuMiBMIDQuMiAwIEwgNiAwIEwgNiA2IEwgNiA2IFoiIGZpbGw9IiMwMDAwMDAiLz48L2c+PC9zdmc+);background-position:bottom right;padding:0 3px 3px 0}.react-resizable-handle-sw{bottom:0;left:0;cursor:sw-resize;transform:rotate(90deg)}.react-resizable-handle-se{bottom:0;right:0;cursor:se-resize}.react-resizable-handle-nw{top:0;left:0;cursor:nw-resize;transform:rotate(180deg)}.react-resizable-handle-ne{top:0;right:0;cursor:ne-resize;transform:rotate(270deg)}.react-resizable-handle-w,.react-resizable-handle-e{top:50%;margin-top:-10px;cursor:ew-resize}.react-resizable-handle-w{left:0;transform:rotate(135deg)}.react-resizable-handle-e{right:0;transform:rotate(315deg)}.react-resizable-handle-n,.react-resizable-handle-s{left:50%;margin-left:-10px;cursor:ns-resize}.react-resizable-handle-n{top:0;transform:rotate(225deg)}.react-resizable-handle-s{bottom:0;transform:rotate(45deg)}code[class*=language-],pre[class*=language-]{color:#393a34;font-family:Consolas,Bitstream Vera Sans Mono,Courier New,Courier,monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;font-size:.95em;line-height:1.2em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]::-moz-selection,pre[class*=language-] ::-moz-selection,code[class*=language-]::-moz-selection,code[class*=language-] ::-moz-selection{background:#b3d4fc}pre[class*=language-]::selection,pre[class*=language-] ::selection,code[class*=language-]::selection,code[class*=language-] ::selection{background:#b3d4fc}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto;border:1px solid #dddddd;background-color:#fff}:not(pre)>code[class*=language-]{padding:1px .2em;background:#f8f8f8;border:1px solid #dddddd}.token.comment,.token.prolog,.token.doctype,.token.cdata{color:#998;font-style:italic}.token.namespace{opacity:.7}.token.string,.token.attr-value{color:#e3116c}.token.punctuation,.token.operator{color:#393a34}.token.entity,.token.url,.token.symbol,.token.number,.token.boolean,.token.variable,.token.constant,.token.property,.token.regex,.token.inserted{color:#36acaa}.token.atrule,.token.keyword,.token.attr-name,.language-autohotkey .token.selector{color:#00a4db}.token.function,.token.deleted,.language-autohotkey .token.tag{color:#9a050f}.token.tag,.token.selector,.language-autohotkey .token.keyword{color:#00009f}.token.important,.token.function,.token.bold{font-weight:700}.token.italic{font-style:italic}.higlass *{box-sizing:border-box}.higlass .react-resizable-handle{z-index:1}html,body,#root{height:100%;width:100%}body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale} diff --git a/assets/index-6614c9bf.js b/assets/index-6614c9bf.js deleted file mode 100644 index 58fd355..0000000 --- a/assets/index-6614c9bf.js +++ /dev/null @@ -1,1867 +0,0 @@ -(function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function n(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(o){if(o.ep)return;o.ep=!0;const l=n(o);fetch(o.href,l)}})();var Qg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Al(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function r3e(e){if(e.__esModule)return e;var i=e.default;if(typeof i=="function"){var n=function r(){if(this instanceof r){var o=[null];o.push.apply(o,arguments);var l=Function.bind.apply(i,o);return new l}return i.apply(this,arguments)};n.prototype=i.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}),n}var g3e={exports:{}},$n={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var uW=Symbol.for("react.element"),Q_t=Symbol.for("react.portal"),j_t=Symbol.for("react.fragment"),$_t=Symbol.for("react.strict_mode"),q_t=Symbol.for("react.profiler"),ePt=Symbol.for("react.provider"),tPt=Symbol.for("react.context"),iPt=Symbol.for("react.forward_ref"),nPt=Symbol.for("react.suspense"),rPt=Symbol.for("react.memo"),gPt=Symbol.for("react.lazy"),bHe=Symbol.iterator;function oPt(e){return e===null||typeof e!="object"?null:(e=bHe&&e[bHe]||e["@@iterator"],typeof e=="function"?e:null)}var o3e={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},a3e=Object.assign,s3e={};function yw(e,i,n){this.props=e,this.context=i,this.refs=s3e,this.updater=n||o3e}yw.prototype.isReactComponent={};yw.prototype.setState=function(e,i){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,i,"setState")};yw.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function I3e(){}I3e.prototype=yw.prototype;function Vae(e,i,n){this.props=e,this.context=i,this.refs=s3e,this.updater=n||o3e}var Eae=Vae.prototype=new I3e;Eae.constructor=Vae;a3e(Eae,yw.prototype);Eae.isPureReactComponent=!0;var yHe=Array.isArray,l3e=Object.prototype.hasOwnProperty,Hae={current:null},C3e={key:!0,ref:!0,__self:!0,__source:!0};function c3e(e,i,n){var r,o={},l=null,c=null;if(i!=null)for(r in i.ref!==void 0&&(c=i.ref),i.key!==void 0&&(l=""+i.key),i)l3e.call(i,r)&&!C3e.hasOwnProperty(r)&&(o[r]=i[r]);var u=arguments.length-2;if(u===1)o.children=n;else if(1>>1,Ue=me[Je];if(0>>1;Jeo(ke,Ee))zeo(je,ke)?(me[Je]=je,me[ze]=Ee,Je=ze):(me[Je]=ke,me[rt]=Ee,Je=rt);else if(zeo(je,Ee))me[Je]=je,me[ze]=Ee,Je=ze;else break e}}return be}function o(me,be){var Ee=me.sortIndex-be.sortIndex;return Ee!==0?Ee:me.id-be.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var f=[],m=[],p=1,v=null,B=3,G=!1,T=!1,V=!1,E=typeof setTimeout=="function"?setTimeout:null,W=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function k(me){for(var be=n(m);be!==null;){if(be.callback===null)r(m);else if(be.startTime<=me)r(m),be.sortIndex=be.expirationTime,i(f,be);else break;be=n(m)}}function F(me){if(V=!1,k(me),!T)if(n(f)!==null)T=!0,de(Y);else{var be=n(m);be!==null&&Ze(F,be.startTime-me)}}function Y(me,be){T=!1,V&&(V=!1,W(Q),Q=-1),G=!0;var Ee=B;try{for(k(be),v=n(f);v!==null&&(!(v.expirationTime>be)||me&&!ee());){var Je=v.callback;if(typeof Je=="function"){v.callback=null,B=v.priorityLevel;var Ue=Je(v.expirationTime<=be);be=e.unstable_now(),typeof Ue=="function"?v.callback=Ue:v===n(f)&&r(f),k(be)}else r(f);v=n(f)}if(v!==null)var dt=!0;else{var rt=n(m);rt!==null&&Ze(F,rt.startTime-be),dt=!1}return dt}finally{v=null,B=Ee,G=!1}}var L=!1,O=null,Q=-1,X=5,$=-1;function ee(){return!(e.unstable_now()-$me||125Je?(me.sortIndex=Ee,i(m,me),n(f)===null&&me===n(m)&&(V?(W(Q),Q=-1):V=!0,Ze(F,Ee-Je))):(me.sortIndex=Ue,i(f,me),T||G||(T=!0,de(Y))),me},e.unstable_shouldYield=ee,e.unstable_wrapCallback=function(me){var be=B;return function(){var Ee=B;B=be;try{return me.apply(this,arguments)}finally{B=Ee}}}})(d3e);u3e.exports=d3e;var CPt=u3e.exports;/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var h3e=Ot,Pl=CPt;function oi(e){for(var i="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),fie=Object.prototype.hasOwnProperty,cPt=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,ZHe={},BHe={};function APt(e){return fie.call(BHe,e)?!0:fie.call(ZHe,e)?!1:cPt.test(e)?BHe[e]=!0:(ZHe[e]=!0,!1)}function uPt(e,i,n,r){if(n!==null&&n.type===0)return!1;switch(typeof i){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function dPt(e,i,n,r){if(i===null||typeof i>"u"||uPt(e,i,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!i;case 4:return i===!1;case 5:return isNaN(i);case 6:return isNaN(i)||1>i}return!1}function bI(e,i,n,r,o,l,c){this.acceptsBooleans=i===2||i===3||i===4,this.attributeName=r,this.attributeNamespace=o,this.mustUseProperty=n,this.propertyName=e,this.type=i,this.sanitizeURL=l,this.removeEmptyString=c}var Ma={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Ma[e]=new bI(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var i=e[0];Ma[i]=new bI(i,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Ma[e]=new bI(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Ma[e]=new bI(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Ma[e]=new bI(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Ma[e]=new bI(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Ma[e]=new bI(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Ma[e]=new bI(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Ma[e]=new bI(e,5,!1,e.toLowerCase(),null,!1,!1)});var Nae=/[\-:]([a-z])/g;function kae(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var i=e.replace(Nae,kae);Ma[i]=new bI(i,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var i=e.replace(Nae,kae);Ma[i]=new bI(i,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var i=e.replace(Nae,kae);Ma[i]=new bI(i,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Ma[e]=new bI(e,1,!1,e.toLowerCase(),null,!1,!1)});Ma.xlinkHref=new bI("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Ma[e]=new bI(e,1,!1,e.toLowerCase(),null,!0,!0)});function Xae(e,i,n,r){var o=Ma.hasOwnProperty(i)?Ma[i]:null;(o!==null?o.type!==0:r||!(2u||o[c]!==l[u]){var f=` -`+o[c].replace(" at new "," at ");return e.displayName&&f.includes("")&&(f=f.replace("",e.displayName)),f}while(1<=c&&0<=u);break}}}finally{M$=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?G9(e):""}function hPt(e){switch(e.tag){case 5:return G9(e.type);case 16:return G9("Lazy");case 13:return G9("Suspense");case 19:return G9("SuspenseList");case 0:case 2:case 15:return e=F$(e.type,!1),e;case 11:return e=F$(e.type.render,!1),e;case 1:return e=F$(e.type,!0),e;default:return""}}function yie(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case EG:return"Fragment";case VG:return"Portal";case mie:return"Profiler";case xae:return"StrictMode";case pie:return"Suspense";case bie:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case p3e:return(e.displayName||"Context")+".Consumer";case m3e:return(e._context.displayName||"Context")+".Provider";case Dae:var i=e.render;return e=e.displayName,e||(e=i.displayName||i.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Mae:return i=e.displayName||null,i!==null?i:yie(e.type)||"Memo";case Ym:i=e._payload,e=e._init;try{return yie(e(i))}catch{}}return null}function fPt(e){var i=e.type;switch(e.tag){case 24:return"Cache";case 9:return(i.displayName||"Context")+".Consumer";case 10:return(i._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=i.render,e=e.displayName||e.name||"",i.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return i;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return yie(i);case 8:return i===xae?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i}return null}function Wp(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function y3e(e){var i=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function mPt(e){var i=y3e(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,i),r=""+e[i];if(!e.hasOwnProperty(i)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var o=n.get,l=n.set;return Object.defineProperty(e,i,{configurable:!0,get:function(){return o.call(this)},set:function(c){r=""+c,l.call(this,c)}}),Object.defineProperty(e,i,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(c){r=""+c},stopTracking:function(){e._valueTracker=null,delete e[i]}}}}function oM(e){e._valueTracker||(e._valueTracker=mPt(e))}function v3e(e){if(!e)return!1;var i=e._valueTracker;if(!i)return!0;var n=i.getValue(),r="";return e&&(r=y3e(e)?e.checked?"true":"false":e.value),e=r,e!==n?(i.setValue(e),!0):!1}function QY(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function vie(e,i){var n=i.checked;return qg({},i,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function SHe(e,i){var n=i.defaultValue==null?"":i.defaultValue,r=i.checked!=null?i.checked:i.defaultChecked;n=Wp(i.value!=null?i.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:i.type==="checkbox"||i.type==="radio"?i.checked!=null:i.value!=null}}function Z3e(e,i){i=i.checked,i!=null&&Xae(e,"checked",i,!1)}function Zie(e,i){Z3e(e,i);var n=Wp(i.value),r=i.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}i.hasOwnProperty("value")?Bie(e,i.type,n):i.hasOwnProperty("defaultValue")&&Bie(e,i.type,Wp(i.defaultValue)),i.checked==null&&i.defaultChecked!=null&&(e.defaultChecked=!!i.defaultChecked)}function wHe(e,i,n){if(i.hasOwnProperty("value")||i.hasOwnProperty("defaultValue")){var r=i.type;if(!(r!=="submit"&&r!=="reset"||i.value!==void 0&&i.value!==null))return;i=""+e._wrapperState.initialValue,n||i===e.value||(e.value=i),e.defaultValue=i}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Bie(e,i,n){(i!=="number"||QY(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var S9=Array.isArray;function $G(e,i,n,r){if(e=e.options,i){i={};for(var o=0;o"+i.valueOf().toString()+"",i=aM.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;i.firstChild;)e.appendChild(i.firstChild)}});function DE(e,i){if(i){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=i;return}}e.textContent=i}var aE={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},pPt=["Webkit","ms","Moz","O"];Object.keys(aE).forEach(function(e){pPt.forEach(function(i){i=i+e.charAt(0).toUpperCase()+e.substring(1),aE[i]=aE[e]})});function w3e(e,i,n){return i==null||typeof i=="boolean"||i===""?"":n||typeof i!="number"||i===0||aE.hasOwnProperty(e)&&aE[e]?(""+i).trim():i+"px"}function T3e(e,i){e=e.style;for(var n in i)if(i.hasOwnProperty(n)){var r=n.indexOf("--")===0,o=w3e(n,i[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,o):e[n]=o}}var bPt=qg({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function wie(e,i){if(i){if(bPt[e]&&(i.children!=null||i.dangerouslySetInnerHTML!=null))throw Error(oi(137,e));if(i.dangerouslySetInnerHTML!=null){if(i.children!=null)throw Error(oi(60));if(typeof i.dangerouslySetInnerHTML!="object"||!("__html"in i.dangerouslySetInnerHTML))throw Error(oi(61))}if(i.style!=null&&typeof i.style!="object")throw Error(oi(62))}}function Tie(e,i){if(e.indexOf("-")===-1)return typeof i.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Rie=null;function Fae(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Vie=null,qG=null,eS=null;function VHe(e){if(e=fW(e)){if(typeof Vie!="function")throw Error(oi(280));var i=e.stateNode;i&&(i=U_(i),Vie(e.stateNode,e.type,i))}}function R3e(e){qG?eS?eS.push(e):eS=[e]:qG=e}function V3e(){if(qG){var e=qG,i=eS;if(eS=qG=null,VHe(e),i)for(e=0;e>>=0,e===0?32:31-(EPt(e)/HPt|0)|0}var sM=64,IM=4194304;function w9(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function eK(e,i){var n=e.pendingLanes;if(n===0)return 0;var r=0,o=e.suspendedLanes,l=e.pingedLanes,c=n&268435455;if(c!==0){var u=c&~o;u!==0?r=w9(u):(l&=c,l!==0&&(r=w9(l)))}else c=n&~o,c!==0?r=w9(c):l!==0&&(r=w9(l));if(r===0)return 0;if(i!==0&&i!==r&&!(i&o)&&(o=r&-r,l=i&-i,o>=l||o===16&&(l&4194240)!==0))return i;if(r&4&&(r|=n&16),i=e.entangledLanes,i!==0)for(e=e.entanglements,i&=r;0n;n++)i.push(e);return i}function dW(e,i,n){e.pendingLanes|=i,i!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,i=31-AA(i),e[i]=n}function XPt(e,i){var n=e.pendingLanes&~i;e.pendingLanes=i,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=i,e.mutableReadLanes&=i,e.entangledLanes&=i,i=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=IE),MHe=String.fromCharCode(32),FHe=!1;function Q3e(e,i){switch(e){case"keyup":return lzt.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function j3e(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var HG=!1;function czt(e,i){switch(e){case"compositionend":return j3e(i);case"keypress":return i.which!==32?null:(FHe=!0,MHe);case"textInput":return e=i.data,e===MHe&&FHe?null:e;default:return null}}function Azt(e,i){if(HG)return e==="compositionend"||!Jae&&Q3e(e,i)?(e=J3e(),gY=zae=$m=null,HG=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1=i)return{node:n,offset:i-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=PHe(n)}}function t_e(e,i){return e&&i?e===i?!0:e&&e.nodeType===3?!1:i&&i.nodeType===3?t_e(e,i.parentNode):"contains"in e?e.contains(i):e.compareDocumentPosition?!!(e.compareDocumentPosition(i)&16):!1:!1}function i_e(){for(var e=window,i=QY();i instanceof e.HTMLIFrameElement;){try{var n=typeof i.contentWindow.location.href=="string"}catch{n=!1}if(n)e=i.contentWindow;else break;i=QY(e.document)}return i}function Uae(e){var i=e&&e.nodeName&&e.nodeName.toLowerCase();return i&&(i==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||i==="textarea"||e.contentEditable==="true")}function vzt(e){var i=i_e(),n=e.focusedElem,r=e.selectionRange;if(i!==n&&n&&n.ownerDocument&&t_e(n.ownerDocument.documentElement,n)){if(r!==null&&Uae(n)){if(i=r.start,e=r.end,e===void 0&&(e=i),"selectionStart"in n)n.selectionStart=i,n.selectionEnd=Math.min(e,n.value.length);else if(e=(i=n.ownerDocument||document)&&i.defaultView||window,e.getSelection){e=e.getSelection();var o=n.textContent.length,l=Math.min(r.start,o);r=r.end===void 0?l:Math.min(r.end,o),!e.extend&&l>r&&(o=r,r=l,l=o),o=zHe(n,l);var c=zHe(n,r);o&&c&&(e.rangeCount!==1||e.anchorNode!==o.node||e.anchorOffset!==o.offset||e.focusNode!==c.node||e.focusOffset!==c.offset)&&(i=i.createRange(),i.setStart(o.node,o.offset),e.removeAllRanges(),l>r?(e.addRange(i),e.extend(c.node,c.offset)):(i.setEnd(c.node,c.offset),e.addRange(i)))}}for(i=[],e=n;e=e.parentNode;)e.nodeType===1&&i.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,WG=null,Xie=null,CE=null,xie=!1;function OHe(e,i,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;xie||WG==null||WG!==QY(r)||(r=WG,"selectionStart"in r&&Uae(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),CE&&PE(CE,r)||(CE=r,r=nK(Xie,"onSelect"),0XG||(e.current=_ie[XG],_ie[XG]=null,XG--)}function Ag(e,i){XG++,_ie[XG]=e.current,e.current=i}var Np={},Es=t0(Np),qI=t0(!1),tv=Np;function ZS(e,i){var n=e.type.contextTypes;if(!n)return Np;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===i)return r.__reactInternalMemoizedMaskedChildContext;var o={},l;for(l in n)o[l]=i[l];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=o),o}function el(e){return e=e.childContextTypes,e!=null}function gK(){wg(qI),wg(Es)}function qHe(e,i,n){if(Es.current!==Np)throw Error(oi(168));Ag(Es,i),Ag(qI,n)}function C_e(e,i,n){var r=e.stateNode;if(i=i.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var o in r)if(!(o in i))throw Error(oi(108,fPt(e)||"Unknown",o));return qg({},n,r)}function oK(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Np,tv=Es.current,Ag(Es,e),Ag(qI,qI.current),!0}function eWe(e,i,n){var r=e.stateNode;if(!r)throw Error(oi(169));n?(e=C_e(e,i,tv),r.__reactInternalMemoizedMergedChildContext=e,wg(qI),wg(Es),Ag(Es,e)):wg(qI),Ag(qI,n)}var Bh=null,Q_=!1,tq=!1;function c_e(e){Bh===null?Bh=[e]:Bh.push(e)}function Nzt(e){Q_=!0,c_e(e)}function i0(){if(!tq&&Bh!==null){tq=!0;var e=0,i=Kr;try{var n=Bh;for(Kr=1;e>=c,o-=c,Hh=1<<32-AA(i)+o|n<Q?(X=O,O=null):X=O.sibling;var $=B(W,O,k[Q],F);if($===null){O===null&&(O=X);break}e&&O&&$.alternate===null&&i(W,O),x=l($,x,Q),L===null?Y=$:L.sibling=$,L=$,O=X}if(Q===k.length)return n(W,O),Dg&&oy(W,Q),Y;if(O===null){for(;QQ?(X=O,O=null):X=O.sibling;var ee=B(W,O,$.value,F);if(ee===null){O===null&&(O=X);break}e&&O&&ee.alternate===null&&i(W,O),x=l(ee,x,Q),L===null?Y=ee:L.sibling=ee,L=ee,O=X}if($.done)return n(W,O),Dg&&oy(W,Q),Y;if(O===null){for(;!$.done;Q++,$=k.next())$=v(W,$.value,F),$!==null&&(x=l($,x,Q),L===null?Y=$:L.sibling=$,L=$);return Dg&&oy(W,Q),Y}for(O=r(W,O);!$.done;Q++,$=k.next())$=G(O,W,Q,$.value,F),$!==null&&(e&&$.alternate!==null&&O.delete($.key===null?Q:$.key),x=l($,x,Q),L===null?Y=$:L.sibling=$,L=$);return e&&O.forEach(function(ne){return i(W,ne)}),Dg&&oy(W,Q),Y}function E(W,x,k,F){if(typeof k=="object"&&k!==null&&k.type===EG&&k.key===null&&(k=k.props.children),typeof k=="object"&&k!==null){switch(k.$$typeof){case gM:e:{for(var Y=k.key,L=x;L!==null;){if(L.key===Y){if(Y=k.type,Y===EG){if(L.tag===7){n(W,L.sibling),x=o(L,k.props.children),x.return=W,W=x;break e}}else if(L.elementType===Y||typeof Y=="object"&&Y!==null&&Y.$$typeof===Ym&&aWe(Y)===L.type){n(W,L.sibling),x=o(L,k.props),x.ref=VV(W,L,k),x.return=W,W=x;break e}n(W,L);break}else i(W,L);L=L.sibling}k.type===EG?(x=xy(k.props.children,W.mode,F,k.key),x.return=W,W=x):(F=AY(k.type,k.key,k.props,null,W.mode,F),F.ref=VV(W,x,k),F.return=W,W=F)}return c(W);case VG:e:{for(L=k.key;x!==null;){if(x.key===L)if(x.tag===4&&x.stateNode.containerInfo===k.containerInfo&&x.stateNode.implementation===k.implementation){n(W,x.sibling),x=o(x,k.children||[]),x.return=W,W=x;break e}else{n(W,x);break}else i(W,x);x=x.sibling}x=Iq(k,W.mode,F),x.return=W,W=x}return c(W);case Ym:return L=k._init,E(W,x,L(k._payload),F)}if(S9(k))return T(W,x,k,F);if(GV(k))return V(W,x,k,F);hM(W,k)}return typeof k=="string"&&k!==""||typeof k=="number"?(k=""+k,x!==null&&x.tag===6?(n(W,x.sibling),x=o(x,k),x.return=W,W=x):(n(W,x),x=sq(k,W.mode,F),x.return=W,W=x),c(W)):n(W,x)}return E}var GS=b_e(!0),y_e=b_e(!1),mW={},zu=t0(mW),JE=t0(mW),UE=t0(mW);function Gy(e){if(e===mW)throw Error(oi(174));return e}function rse(e,i){switch(Ag(UE,i),Ag(JE,e),Ag(zu,mW),e=i.nodeType,e){case 9:case 11:i=(i=i.documentElement)?i.namespaceURI:Sie(null,"");break;default:e=e===8?i.parentNode:i,i=e.namespaceURI||null,e=e.tagName,i=Sie(i,e)}wg(zu),Ag(zu,i)}function SS(){wg(zu),wg(JE),wg(UE)}function v_e(e){Gy(UE.current);var i=Gy(zu.current),n=Sie(i,e.type);i!==n&&(Ag(JE,e),Ag(zu,n))}function gse(e){JE.current===e&&(wg(zu),wg(JE))}var Jg=t0(0);function cK(e){for(var i=e;i!==null;){if(i.tag===13){var n=i.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return i}else if(i.tag===19&&i.memoizedProps.revealOrder!==void 0){if(i.flags&128)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===e)break;for(;i.sibling===null;){if(i.return===null||i.return===e)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var iq=[];function ose(){for(var e=0;en?n:4,e(!0);var r=nq.transition;nq.transition={};try{e(!1),i()}finally{Kr=n,nq.transition=r}}function D_e(){return PC().memoizedState}function Dzt(e,i,n){var r=bp(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},M_e(e))F_e(i,n);else if(n=h_e(e,i,n,r),n!==null){var o=AI();uA(n,e,r,o),Y_e(n,i,r)}}function Mzt(e,i,n){var r=bp(e),o={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(M_e(e))F_e(i,o);else{var l=e.alternate;if(e.lanes===0&&(l===null||l.lanes===0)&&(l=i.lastRenderedReducer,l!==null))try{var c=i.lastRenderedState,u=l(c,n);if(o.hasEagerState=!0,o.eagerState=u,yA(u,c)){var f=i.interleaved;f===null?(o.next=o,ise(i)):(o.next=f.next,f.next=o),i.interleaved=o;return}}catch{}finally{}n=h_e(e,i,o,r),n!==null&&(o=AI(),uA(n,e,r,o),Y_e(n,i,r))}}function M_e(e){var i=e.alternate;return e===jg||i!==null&&i===jg}function F_e(e,i){cE=AK=!0;var n=e.pending;n===null?i.next=i:(i.next=n.next,n.next=i),e.pending=i}function Y_e(e,i,n){if(n&4194240){var r=i.lanes;r&=e.pendingLanes,n|=r,i.lanes=n,Kae(e,n)}}var uK={readContext:_C,useCallback:Is,useContext:Is,useEffect:Is,useImperativeHandle:Is,useInsertionEffect:Is,useLayoutEffect:Is,useMemo:Is,useReducer:Is,useRef:Is,useState:Is,useDebugValue:Is,useDeferredValue:Is,useTransition:Is,useMutableSource:Is,useSyncExternalStore:Is,useId:Is,unstable_isNewReconciler:!1},Fzt={readContext:_C,useCallback:function(e,i){return Ru().memoizedState=[e,i===void 0?null:i],e},useContext:_C,useEffect:IWe,useImperativeHandle:function(e,i,n){return n=n!=null?n.concat([e]):null,IY(4194308,4,W_e.bind(null,i,e),n)},useLayoutEffect:function(e,i){return IY(4194308,4,e,i)},useInsertionEffect:function(e,i){return IY(4,2,e,i)},useMemo:function(e,i){var n=Ru();return i=i===void 0?null:i,e=e(),n.memoizedState=[e,i],e},useReducer:function(e,i,n){var r=Ru();return i=n!==void 0?n(i):i,r.memoizedState=r.baseState=i,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Dzt.bind(null,jg,e),[r.memoizedState,e]},useRef:function(e){var i=Ru();return e={current:e},i.memoizedState=e},useState:sWe,useDebugValue:Cse,useDeferredValue:function(e){return Ru().memoizedState=e},useTransition:function(){var e=sWe(!1),i=e[0];return e=xzt.bind(null,e[1]),Ru().memoizedState=e,[i,e]},useMutableSource:function(){},useSyncExternalStore:function(e,i,n){var r=jg,o=Ru();if(Dg){if(n===void 0)throw Error(oi(407));n=n()}else{if(n=i(),ua===null)throw Error(oi(349));nv&30||G_e(r,i,n)}o.memoizedState=n;var l={value:n,getSnapshot:i};return o.queue=l,IWe(w_e.bind(null,r,l,e),[e]),r.flags|=2048,$E(9,S_e.bind(null,r,l,n,i),void 0,null),n},useId:function(){var e=Ru(),i=ua.identifierPrefix;if(Dg){var n=Wh,r=Hh;n=(r&~(1<<32-AA(r)-1)).toString(32)+n,i=":"+i+"R"+n,n=QE++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=c.createElement(n,{is:r.is}):(e=c.createElement(n),n==="select"&&(c=e,r.multiple?c.multiple=!0:r.size&&(c.size=r.size))):e=c.createElementNS(e,n),e[Nu]=i,e[LE]=r,Q_e(e,i,!1,!1),i.stateNode=e;e:{switch(c=Tie(n,r),n){case"dialog":yg("cancel",e),yg("close",e),o=r;break;case"iframe":case"object":case"embed":yg("load",e),o=r;break;case"video":case"audio":for(o=0;oTS&&(i.flags|=128,r=!0,EV(l,!1),i.lanes=4194304)}else{if(!r)if(e=cK(c),e!==null){if(i.flags|=128,r=!0,n=e.updateQueue,n!==null&&(i.updateQueue=n,i.flags|=4),EV(l,!0),l.tail===null&&l.tailMode==="hidden"&&!c.alternate&&!Dg)return ls(i),null}else 2*yo()-l.renderingStartTime>TS&&n!==1073741824&&(i.flags|=128,r=!0,EV(l,!1),i.lanes=4194304);l.isBackwards?(c.sibling=i.child,i.child=c):(n=l.last,n!==null?n.sibling=c:i.child=c,l.last=c)}return l.tail!==null?(i=l.tail,l.rendering=i,l.tail=i.sibling,l.renderingStartTime=yo(),i.sibling=null,n=Jg.current,Ag(Jg,r?n&1|2:n&1),i):(ls(i),null);case 22:case 23:return fse(),r=i.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(i.flags|=8192),r&&i.mode&1?kl&1073741824&&(ls(i),i.subtreeFlags&6&&(i.flags|=8192)):ls(i),null;case 24:return null;case 25:return null}throw Error(oi(156,i.tag))}function Jzt(e,i){switch(jae(i),i.tag){case 1:return el(i.type)&&gK(),e=i.flags,e&65536?(i.flags=e&-65537|128,i):null;case 3:return SS(),wg(qI),wg(Es),ose(),e=i.flags,e&65536&&!(e&128)?(i.flags=e&-65537|128,i):null;case 5:return gse(i),null;case 13:if(wg(Jg),e=i.memoizedState,e!==null&&e.dehydrated!==null){if(i.alternate===null)throw Error(oi(340));BS()}return e=i.flags,e&65536?(i.flags=e&-65537|128,i):null;case 19:return wg(Jg),null;case 4:return SS(),null;case 10:return tse(i.type._context),null;case 22:case 23:return fse(),null;case 24:return null;default:return null}}var mM=!1,ys=!1,Uzt=typeof WeakSet=="function"?WeakSet:Set,Vi=null;function FG(e,i){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){so(e,i,r)}else n.current=null}function tne(e,i,n){try{n()}catch(r){so(e,i,r)}}var mWe=!1;function Qzt(e,i){if(Die=tK,e=i_e(),Uae(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var o=r.anchorOffset,l=r.focusNode;r=r.focusOffset;try{n.nodeType,l.nodeType}catch{n=null;break e}var c=0,u=-1,f=-1,m=0,p=0,v=e,B=null;t:for(;;){for(var G;v!==n||o!==0&&v.nodeType!==3||(u=c+o),v!==l||r!==0&&v.nodeType!==3||(f=c+r),v.nodeType===3&&(c+=v.nodeValue.length),(G=v.firstChild)!==null;)B=v,v=G;for(;;){if(v===e)break t;if(B===n&&++m===o&&(u=c),B===l&&++p===r&&(f=c),(G=v.nextSibling)!==null)break;v=B,B=v.parentNode}v=G}n=u===-1||f===-1?null:{start:u,end:f}}else n=null}n=n||{start:0,end:0}}else n=null;for(Mie={focusedElem:e,selectionRange:n},tK=!1,Vi=i;Vi!==null;)if(i=Vi,e=i.child,(i.subtreeFlags&1028)!==0&&e!==null)e.return=i,Vi=e;else for(;Vi!==null;){i=Vi;try{var T=i.alternate;if(i.flags&1024)switch(i.tag){case 0:case 11:case 15:break;case 1:if(T!==null){var V=T.memoizedProps,E=T.memoizedState,W=i.stateNode,x=W.getSnapshotBeforeUpdate(i.elementType===i.type?V:Jc(i.type,V),E);W.__reactInternalSnapshotBeforeUpdate=x}break;case 3:var k=i.stateNode.containerInfo;k.nodeType===1?k.textContent="":k.nodeType===9&&k.documentElement&&k.removeChild(k.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(oi(163))}}catch(F){so(i,i.return,F)}if(e=i.sibling,e!==null){e.return=i.return,Vi=e;break}Vi=i.return}return T=mWe,mWe=!1,T}function AE(e,i,n){var r=i.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var o=r=r.next;do{if((o.tag&e)===e){var l=o.destroy;o.destroy=void 0,l!==void 0&&tne(i,n,l)}o=o.next}while(o!==r)}}function q_(e,i){if(i=i.updateQueue,i=i!==null?i.lastEffect:null,i!==null){var n=i=i.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==i)}}function ine(e){var i=e.ref;if(i!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof i=="function"?i(e):i.current=e}}function q_e(e){var i=e.alternate;i!==null&&(e.alternate=null,q_e(i)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(i=e.stateNode,i!==null&&(delete i[Nu],delete i[LE],delete i[Kie],delete i[Hzt],delete i[Wzt])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function ePe(e){return e.tag===5||e.tag===3||e.tag===4}function pWe(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ePe(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function nne(e,i,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,i?n.nodeType===8?n.parentNode.insertBefore(e,i):n.insertBefore(e,i):(n.nodeType===8?(i=n.parentNode,i.insertBefore(e,n)):(i=n,i.appendChild(e)),n=n._reactRootContainer,n!=null||i.onclick!==null||(i.onclick=rK));else if(r!==4&&(e=e.child,e!==null))for(nne(e,i,n),e=e.sibling;e!==null;)nne(e,i,n),e=e.sibling}function rne(e,i,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,i?n.insertBefore(e,i):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(rne(e,i,n),e=e.sibling;e!==null;)rne(e,i,n),e=e.sibling}var Ea=null,Qc=!1;function Vm(e,i,n){for(n=n.child;n!==null;)tPe(e,i,n),n=n.sibling}function tPe(e,i,n){if(Pu&&typeof Pu.onCommitFiberUnmount=="function")try{Pu.onCommitFiberUnmount(z_,n)}catch{}switch(n.tag){case 5:ys||FG(n,i);case 6:var r=Ea,o=Qc;Ea=null,Vm(e,i,n),Ea=r,Qc=o,Ea!==null&&(Qc?(e=Ea,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ea.removeChild(n.stateNode));break;case 18:Ea!==null&&(Qc?(e=Ea,n=n.stateNode,e.nodeType===8?eq(e.parentNode,n):e.nodeType===1&&eq(e,n),KE(e)):eq(Ea,n.stateNode));break;case 4:r=Ea,o=Qc,Ea=n.stateNode.containerInfo,Qc=!0,Vm(e,i,n),Ea=r,Qc=o;break;case 0:case 11:case 14:case 15:if(!ys&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){o=r=r.next;do{var l=o,c=l.destroy;l=l.tag,c!==void 0&&(l&2||l&4)&&tne(n,i,c),o=o.next}while(o!==r)}Vm(e,i,n);break;case 1:if(!ys&&(FG(n,i),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(u){so(n,i,u)}Vm(e,i,n);break;case 21:Vm(e,i,n);break;case 22:n.mode&1?(ys=(r=ys)||n.memoizedState!==null,Vm(e,i,n),ys=r):Vm(e,i,n);break;default:Vm(e,i,n)}}function bWe(e){var i=e.updateQueue;if(i!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Uzt),i.forEach(function(r){var o=gOt.bind(null,e,r);n.has(r)||(n.add(r),r.then(o,o))})}}function Sc(e,i){var n=i.deletions;if(n!==null)for(var r=0;ro&&(o=c),r&=~l}if(r=o,r=yo()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*$zt(r/1960))-r,10e?16:e,qm===null)var r=!1;else{if(e=qm,qm=null,fK=0,Ar&6)throw Error(oi(331));var o=Ar;for(Ar|=4,Vi=e.current;Vi!==null;){var l=Vi,c=l.child;if(Vi.flags&16){var u=l.deletions;if(u!==null){for(var f=0;fyo()-dse?Xy(e,0):use|=n),tl(e,i)}function IPe(e,i){i===0&&(e.mode&1?(i=IM,IM<<=1,!(IM&130023424)&&(IM=4194304)):i=1);var n=AI();e=nf(e,i),e!==null&&(dW(e,i,n),tl(e,n))}function rOt(e){var i=e.memoizedState,n=0;i!==null&&(n=i.retryLane),IPe(e,n)}function gOt(e,i){var n=0;switch(e.tag){case 13:var r=e.stateNode,o=e.memoizedState;o!==null&&(n=o.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(oi(314))}r!==null&&r.delete(i),IPe(e,n)}var lPe;lPe=function(e,i,n){if(e!==null)if(e.memoizedProps!==i.pendingProps||qI.current)QI=!0;else{if(!(e.lanes&n)&&!(i.flags&128))return QI=!1,Ozt(e,i,n);QI=!!(e.flags&131072)}else QI=!1,Dg&&i.flags&1048576&&A_e(i,sK,i.index);switch(i.lanes=0,i.tag){case 2:var r=i.type;lY(e,i),e=i.pendingProps;var o=ZS(i,Es.current);iS(i,n),o=sse(null,i,r,e,o,n);var l=Ise();return i.flags|=1,typeof o=="object"&&o!==null&&typeof o.render=="function"&&o.$$typeof===void 0?(i.tag=1,i.memoizedState=null,i.updateQueue=null,el(r)?(l=!0,oK(i)):l=!1,i.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,nse(i),o.updater=j_,i.stateNode=o,o._reactInternals=i,Jie(i,r,e,n),i=jie(null,i,r,!0,l,n)):(i.tag=0,Dg&&l&&Qae(i),rI(null,i,o,n),i=i.child),i;case 16:r=i.elementType;e:{switch(lY(e,i),e=i.pendingProps,o=r._init,r=o(r._payload),i.type=r,o=i.tag=aOt(r),e=Jc(r,e),o){case 0:i=Qie(null,i,r,e,n);break e;case 1:i=dWe(null,i,r,e,n);break e;case 11:i=AWe(null,i,r,e,n);break e;case 14:i=uWe(null,i,r,Jc(r.type,e),n);break e}throw Error(oi(306,r,""))}return i;case 0:return r=i.type,o=i.pendingProps,o=i.elementType===r?o:Jc(r,o),Qie(e,i,r,o,n);case 1:return r=i.type,o=i.pendingProps,o=i.elementType===r?o:Jc(r,o),dWe(e,i,r,o,n);case 3:e:{if(L_e(i),e===null)throw Error(oi(387));r=i.pendingProps,l=i.memoizedState,o=l.element,f_e(e,i),CK(i,r,null,n);var c=i.memoizedState;if(r=c.element,l.isDehydrated)if(l={element:r,isDehydrated:!1,cache:c.cache,pendingSuspenseBoundaries:c.pendingSuspenseBoundaries,transitions:c.transitions},i.updateQueue.baseState=l,i.memoizedState=l,i.flags&256){o=wS(Error(oi(423)),i),i=hWe(e,i,r,n,o);break e}else if(r!==o){o=wS(Error(oi(424)),i),i=hWe(e,i,r,n,o);break e}else for(Ml=fp(i.stateNode.containerInfo.firstChild),Kl=i,Dg=!0,$c=null,n=y_e(i,null,r,n),i.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(BS(),r===o){i=rf(e,i,n);break e}rI(e,i,r,n)}i=i.child}return i;case 5:return v_e(i),e===null&&zie(i),r=i.type,o=i.pendingProps,l=e!==null?e.memoizedProps:null,c=o.children,Fie(r,o)?c=null:l!==null&&Fie(r,l)&&(i.flags|=32),O_e(e,i),rI(e,i,c,n),i.child;case 6:return e===null&&zie(i),null;case 13:return J_e(e,i,n);case 4:return rse(i,i.stateNode.containerInfo),r=i.pendingProps,e===null?i.child=GS(i,null,r,n):rI(e,i,r,n),i.child;case 11:return r=i.type,o=i.pendingProps,o=i.elementType===r?o:Jc(r,o),AWe(e,i,r,o,n);case 7:return rI(e,i,i.pendingProps,n),i.child;case 8:return rI(e,i,i.pendingProps.children,n),i.child;case 12:return rI(e,i,i.pendingProps.children,n),i.child;case 10:e:{if(r=i.type._context,o=i.pendingProps,l=i.memoizedProps,c=o.value,Ag(IK,r._currentValue),r._currentValue=c,l!==null)if(yA(l.value,c)){if(l.children===o.children&&!qI.current){i=rf(e,i,n);break e}}else for(l=i.child,l!==null&&(l.return=i);l!==null;){var u=l.dependencies;if(u!==null){c=l.child;for(var f=u.firstContext;f!==null;){if(f.context===r){if(l.tag===1){f=_h(-1,n&-n),f.tag=2;var m=l.updateQueue;if(m!==null){m=m.shared;var p=m.pending;p===null?f.next=f:(f.next=p.next,p.next=f),m.pending=f}}l.lanes|=n,f=l.alternate,f!==null&&(f.lanes|=n),Oie(l.return,n,i),u.lanes|=n;break}f=f.next}}else if(l.tag===10)c=l.type===i.type?null:l.child;else if(l.tag===18){if(c=l.return,c===null)throw Error(oi(341));c.lanes|=n,u=c.alternate,u!==null&&(u.lanes|=n),Oie(c,n,i),c=l.sibling}else c=l.child;if(c!==null)c.return=l;else for(c=l;c!==null;){if(c===i){c=null;break}if(l=c.sibling,l!==null){l.return=c.return,c=l;break}c=c.return}l=c}rI(e,i,o.children,n),i=i.child}return i;case 9:return o=i.type,r=i.pendingProps.children,iS(i,n),o=_C(o),r=r(o),i.flags|=1,rI(e,i,r,n),i.child;case 14:return r=i.type,o=Jc(r,i.pendingProps),o=Jc(r.type,o),uWe(e,i,r,o,n);case 15:return P_e(e,i,i.type,i.pendingProps,n);case 17:return r=i.type,o=i.pendingProps,o=i.elementType===r?o:Jc(r,o),lY(e,i),i.tag=1,el(r)?(e=!0,oK(i)):e=!1,iS(i,n),p_e(i,r,o),Jie(i,r,o,n),jie(null,i,r,!0,e,n);case 19:return U_e(e,i,n);case 22:return z_e(e,i,n)}throw Error(oi(156,i.tag))};function CPe(e,i){return x3e(e,i)}function oOt(e,i,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function VC(e,i,n,r){return new oOt(e,i,n,r)}function pse(e){return e=e.prototype,!(!e||!e.isReactComponent)}function aOt(e){if(typeof e=="function")return pse(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Dae)return 11;if(e===Mae)return 14}return 2}function yp(e,i){var n=e.alternate;return n===null?(n=VC(e.tag,i,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=i,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,i=e.dependencies,n.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function AY(e,i,n,r,o,l){var c=2;if(r=e,typeof e=="function")pse(e)&&(c=1);else if(typeof e=="string")c=5;else e:switch(e){case EG:return xy(n.children,o,l,i);case xae:c=8,o|=8;break;case mie:return e=VC(12,n,i,o|2),e.elementType=mie,e.lanes=l,e;case pie:return e=VC(13,n,i,o),e.elementType=pie,e.lanes=l,e;case bie:return e=VC(19,n,i,o),e.elementType=bie,e.lanes=l,e;case b3e:return tP(n,o,l,i);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case m3e:c=10;break e;case p3e:c=9;break e;case Dae:c=11;break e;case Mae:c=14;break e;case Ym:c=16,r=null;break e}throw Error(oi(130,e==null?e:typeof e,""))}return i=VC(c,n,i,o),i.elementType=e,i.type=r,i.lanes=l,i}function xy(e,i,n,r){return e=VC(7,e,r,i),e.lanes=n,e}function tP(e,i,n,r){return e=VC(22,e,r,i),e.elementType=b3e,e.lanes=n,e.stateNode={isHidden:!1},e}function sq(e,i,n){return e=VC(6,e,null,i),e.lanes=n,e}function Iq(e,i,n){return i=VC(4,e.children!==null?e.children:[],e.key,i),i.lanes=n,i.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},i}function sOt(e,i,n,r,o){this.tag=i,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=K$(0),this.expirationTimes=K$(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=K$(0),this.identifierPrefix=r,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function bse(e,i,n,r,o,l,c,u,f){return e=new sOt(e,i,n,u,f),i===1?(i=1,l===!0&&(i|=8)):i=0,l=VC(3,null,null,i),e.current=l,l.stateNode=e,l.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},nse(l),e}function IOt(e,i,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(dPe)}catch(e){console.error(e)}}dPe(),A3e.exports=Ql;var Bse=A3e.exports;const uOt=Al(Bse);var TWe=Bse;hie.createRoot=TWe.createRoot,hie.hydrateRoot=TWe.hydrateRoot;/** - * @remix-run/router v1.6.1 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */function eH(){return eH=Object.assign?Object.assign.bind():function(e){for(var i=1;i"u")throw new Error(i)}function oP(e,i){if(!e){typeof console<"u"&&console.warn(i);try{throw new Error(i)}catch{}}}function hOt(){return Math.random().toString(36).substr(2,8)}function VWe(e,i){return{usr:e.state,key:e.key,idx:i}}function Ine(e,i,n,r){return n===void 0&&(n=null),eH({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof i=="string"?Ov(i):i,{state:n,key:i&&i.key||r||hOt()})}function bK(e){let{pathname:i="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(i+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(i+=r.charAt(0)==="#"?r:"#"+r),i}function Ov(e){let i={};if(e){let n=e.indexOf("#");n>=0&&(i.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(i.search=e.substr(r),e=e.substr(0,r)),e&&(i.pathname=e)}return i}function fOt(e,i,n,r){r===void 0&&(r={});let{window:o=document.defaultView,v5Compat:l=!1}=r,c=o.history,u=ep.Pop,f=null,m=p();m==null&&(m=0,c.replaceState(eH({},c.state,{idx:m}),""));function p(){return(c.state||{idx:null}).idx}function v(){u=ep.Pop;let E=p(),W=E==null?null:E-m;m=E,f&&f({action:u,location:V.location,delta:W})}function B(E,W){u=ep.Push;let x=Ine(V.location,E,W);n&&n(x,E),m=p()+1;let k=VWe(x,m),F=V.createHref(x);try{c.pushState(k,"",F)}catch{o.location.assign(F)}l&&f&&f({action:u,location:V.location,delta:1})}function G(E,W){u=ep.Replace;let x=Ine(V.location,E,W);n&&n(x,E),m=p();let k=VWe(x,m),F=V.createHref(x);c.replaceState(k,"",F),l&&f&&f({action:u,location:V.location,delta:0})}function T(E){let W=o.location.origin!=="null"?o.location.origin:o.location.href,x=typeof E=="string"?E:bK(E);return Vo(W,"No window.location.(origin|href) available to create URL for href: "+x),new URL(x,W)}let V={get action(){return u},get location(){return e(o,c)},listen(E){if(f)throw new Error("A history only accepts one active listener");return o.addEventListener(RWe,v),f=E,()=>{o.removeEventListener(RWe,v),f=null}},createHref(E){return i(o,E)},createURL:T,encodeLocation(E){let W=T(E);return{pathname:W.pathname,search:W.search,hash:W.hash}},push:B,replace:G,go(E){return c.go(E)}};return V}var EWe;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(EWe||(EWe={}));function mOt(e,i,n){n===void 0&&(n="/");let r=typeof i=="string"?Ov(i):i,o=Gse(r.pathname||"/",n);if(o==null)return null;let l=hPe(e);pOt(l);let c=null;for(let u=0;c==null&&u{let f={relativePath:u===void 0?l.path||"":u,caseSensitive:l.caseSensitive===!0,childrenIndex:c,route:l};f.relativePath.startsWith("/")&&(Vo(f.relativePath.startsWith(r),'Absolute route path "'+f.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),f.relativePath=f.relativePath.slice(r.length));let m=vp([r,f.relativePath]),p=n.concat(f);l.children&&l.children.length>0&&(Vo(l.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+m+'".')),hPe(l.children,i,p,m)),!(l.path==null&&!l.index)&&i.push({path:m,score:SOt(m,l.index),routesMeta:p})};return e.forEach((l,c)=>{var u;if(l.path===""||!((u=l.path)!=null&&u.includes("?")))o(l,c);else for(let f of fPe(l.path))o(l,c,f)}),i}function fPe(e){let i=e.split("/");if(i.length===0)return[];let[n,...r]=i,o=n.endsWith("?"),l=n.replace(/\?$/,"");if(r.length===0)return o?[l,""]:[l];let c=fPe(r.join("/")),u=[];return u.push(...c.map(f=>f===""?l:[l,f].join("/"))),o&&u.push(...c),u.map(f=>e.startsWith("/")&&f===""?"/":f)}function pOt(e){e.sort((i,n)=>i.score!==n.score?n.score-i.score:wOt(i.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const bOt=/^:\w+$/,yOt=3,vOt=2,ZOt=1,BOt=10,GOt=-2,HWe=e=>e==="*";function SOt(e,i){let n=e.split("/"),r=n.length;return n.some(HWe)&&(r+=GOt),i&&(r+=vOt),n.filter(o=>!HWe(o)).reduce((o,l)=>o+(bOt.test(l)?yOt:l===""?ZOt:BOt),r)}function wOt(e,i){return e.length===i.length&&e.slice(0,-1).every((r,o)=>r===i[o])?e[e.length-1]-i[i.length-1]:0}function TOt(e,i){let{routesMeta:n}=e,r={},o="/",l=[];for(let c=0;c{if(p==="*"){let B=u[v]||"";c=l.slice(0,l.length-B.length).replace(/(.)\/+$/,"$1")}return m[p]=HOt(u[v]||"",p),m},{}),pathname:l,pathnameBase:c,pattern:e}}function VOt(e,i,n){i===void 0&&(i=!1),n===void 0&&(n=!0),oP(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^$?{}|()[\]]/g,"\\$&").replace(/\/:(\w+)/g,(c,u)=>(r.push(u),"/([^\\/]+)"));return e.endsWith("*")?(r.push("*"),o+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?o+="\\/*$":e!==""&&e!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,i?void 0:"i"),r]}function EOt(e){try{return decodeURI(e)}catch(i){return oP(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+i+").")),e}}function HOt(e,i){try{return decodeURIComponent(e)}catch(n){return oP(!1,'The value for the URL param "'+i+'" will not be decoded because'+(' the string "'+e+'" is a malformed URL segment. This is probably')+(" due to a bad percent encoding ("+n+").")),e}}function Gse(e,i){if(i==="/")return e;if(!e.toLowerCase().startsWith(i.toLowerCase()))return null;let n=i.endsWith("/")?i.length-1:i.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}function WOt(e,i){i===void 0&&(i="/");let{pathname:n,search:r="",hash:o=""}=typeof e=="string"?Ov(e):e;return{pathname:n?n.startsWith("/")?n:NOt(n,i):i,search:XOt(r),hash:xOt(o)}}function NOt(e,i){let n=i.replace(/\/+$/,"").split("/");return e.split("/").forEach(o=>{o===".."?n.length>1&&n.pop():o!=="."&&n.push(o)}),n.length>1?n.join("/"):"/"}function lq(e,i,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+i+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function mPe(e){return e.filter((i,n)=>n===0||i.route.path&&i.route.path.length>0)}function pPe(e,i,n,r){r===void 0&&(r=!1);let o;typeof e=="string"?o=Ov(e):(o=eH({},e),Vo(!o.pathname||!o.pathname.includes("?"),lq("?","pathname","search",o)),Vo(!o.pathname||!o.pathname.includes("#"),lq("#","pathname","hash",o)),Vo(!o.search||!o.search.includes("#"),lq("#","search","hash",o)));let l=e===""||o.pathname==="",c=l?"/":o.pathname,u;if(r||c==null)u=n;else{let v=i.length-1;if(c.startsWith("..")){let B=c.split("/");for(;B[0]==="..";)B.shift(),v-=1;o.pathname=B.join("/")}u=v>=0?i[v]:"/"}let f=WOt(o,u),m=c&&c!=="/"&&c.endsWith("/"),p=(l||c===".")&&n.endsWith("/");return!f.pathname.endsWith("/")&&(m||p)&&(f.pathname+="/"),f}const vp=e=>e.join("/").replace(/\/\/+/g,"/"),kOt=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),XOt=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,xOt=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function DOt(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const bPe=["post","put","patch","delete"];new Set(bPe);const MOt=["get",...bPe];new Set(MOt);/** - * React Router v6.11.1 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */function yK(){return yK=Object.assign?Object.assign.bind():function(e){for(var i=1;iu.pathnameBase)),l=Ot.useRef(!1);return ZPe(()=>{l.current=!0}),Ot.useCallback(function(u,f){if(f===void 0&&(f={}),!l.current)return;if(typeof u=="number"){i.go(u);return}let m=pPe(u,JSON.parse(o),r,f.relative==="path");e!=="/"&&(m.pathname=m.pathname==="/"?e:vp([e,m.pathname])),(f.replace?i.replace:i.push)(m,f.state,f)},[e,i,o,r])}function BPe(e,i){let{relative:n}=i===void 0?{}:i,{matches:r}=Ot.useContext(Lv),{pathname:o}=sP(),l=JSON.stringify(mPe(r).map(c=>c.pathnameBase));return Ot.useMemo(()=>pPe(e,JSON.parse(l),o,n==="path"),[e,l,o,n])}function POt(e,i){return zOt(e,i)}function zOt(e,i,n){pW()||Vo(!1);let{navigator:r}=Ot.useContext(Bw),{matches:o}=Ot.useContext(Lv),l=o[o.length-1],c=l?l.params:{};l&&l.pathname;let u=l?l.pathnameBase:"/";l&&l.route;let f=sP(),m;if(i){var p;let V=typeof i=="string"?Ov(i):i;u==="/"||(p=V.pathname)!=null&&p.startsWith(u)||Vo(!1),m=V}else m=f;let v=m.pathname||"/",B=u==="/"?v:v.slice(u.length)||"/",G=mOt(e,{pathname:B}),T=QOt(G&&G.map(V=>Object.assign({},V,{params:Object.assign({},c,V.params),pathname:vp([u,r.encodeLocation?r.encodeLocation(V.pathname).pathname:V.pathname]),pathnameBase:V.pathnameBase==="/"?u:vp([u,r.encodeLocation?r.encodeLocation(V.pathnameBase).pathname:V.pathnameBase])})),o,n);return i&&T?Ot.createElement(aP.Provider,{value:{location:yK({pathname:"/",search:"",hash:"",state:null,key:"default"},m),navigationType:ep.Pop}},T):T}function OOt(){let e=eLt(),i=DOt(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,o={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"},l=null;return Ot.createElement(Ot.Fragment,null,Ot.createElement("h2",null,"Unexpected Application Error!"),Ot.createElement("h3",{style:{fontStyle:"italic"}},i),n?Ot.createElement("pre",{style:o},n):null,l)}const LOt=Ot.createElement(OOt,null);class JOt extends Ot.Component{constructor(i){super(i),this.state={location:i.location,revalidation:i.revalidation,error:i.error}}static getDerivedStateFromError(i){return{error:i}}static getDerivedStateFromProps(i,n){return n.location!==i.location||n.revalidation!=="idle"&&i.revalidation==="idle"?{error:i.error,location:i.location,revalidation:i.revalidation}:{error:i.error||n.error,location:n.location,revalidation:i.revalidation||n.revalidation}}componentDidCatch(i,n){console.error("React Router caught the following error during render",i,n)}render(){return this.state.error?Ot.createElement(Lv.Provider,{value:this.props.routeContext},Ot.createElement(vPe.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function UOt(e){let{routeContext:i,match:n,children:r}=e,o=Ot.useContext(yPe);return o&&o.static&&o.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=n.route.id),Ot.createElement(Lv.Provider,{value:i},r)}function QOt(e,i,n){var r;if(i===void 0&&(i=[]),n===void 0&&(n=null),e==null){var o;if((o=n)!=null&&o.errors)e=n.matches;else return null}let l=e,c=(r=n)==null?void 0:r.errors;if(c!=null){let u=l.findIndex(f=>f.route.id&&c?.[f.route.id]);u>=0||Vo(!1),l=l.slice(0,Math.min(l.length,u+1))}return l.reduceRight((u,f,m)=>{let p=f.route.id?c?.[f.route.id]:null,v=null;n&&(v=f.route.errorElement||LOt);let B=i.concat(l.slice(0,m+1)),G=()=>{let T;return p?T=v:f.route.Component?T=Ot.createElement(f.route.Component,null):f.route.element?T=f.route.element:T=u,Ot.createElement(UOt,{match:f,routeContext:{outlet:u,matches:B,isDataRoute:n!=null},children:T})};return n&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?Ot.createElement(JOt,{location:n.location,revalidation:n.revalidation,component:v,error:p,children:G(),routeContext:{outlet:null,matches:B,isDataRoute:!0}}):G()},null)}var lne;(function(e){e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate"})(lne||(lne={}));var tH;(function(e){e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId"})(tH||(tH={}));function jOt(e){let i=Ot.useContext(yPe);return i||Vo(!1),i}function $Ot(e){let i=Ot.useContext(FOt);return i||Vo(!1),i}function qOt(e){let i=Ot.useContext(Lv);return i||Vo(!1),i}function GPe(e){let i=qOt(),n=i.matches[i.matches.length-1];return n.route.id||Vo(!1),n.route.id}function eLt(){var e;let i=Ot.useContext(vPe),n=$Ot(tH.UseRouteError),r=GPe(tH.UseRouteError);return i||((e=n.errors)==null?void 0:e[r])}function tLt(){let{router:e}=jOt(lne.UseNavigateStable),i=GPe(tH.UseNavigateStable),n=Ot.useRef(!1);return ZPe(()=>{n.current=!0}),Ot.useCallback(function(o,l){l===void 0&&(l={}),n.current&&(typeof o=="number"?e.navigate(o):e.navigate(o,yK({fromRouteId:i},l)))},[e,i])}function Cne(e){Vo(!1)}function iLt(e){let{basename:i="/",children:n=null,location:r,navigationType:o=ep.Pop,navigator:l,static:c=!1}=e;pW()&&Vo(!1);let u=i.replace(/^\/*/,"/"),f=Ot.useMemo(()=>({basename:u,navigator:l,static:c}),[u,l,c]);typeof r=="string"&&(r=Ov(r));let{pathname:m="/",search:p="",hash:v="",state:B=null,key:G="default"}=r,T=Ot.useMemo(()=>{let V=Gse(m,u);return V==null?null:{location:{pathname:V,search:p,hash:v,state:B,key:G},navigationType:o}},[u,m,p,v,B,G,o]);return T==null?null:Ot.createElement(Bw.Provider,{value:f},Ot.createElement(aP.Provider,{children:n,value:T}))}function nLt(e){let{children:i,location:n}=e;return POt(cne(i),n)}var WWe;(function(e){e[e.pending=0]="pending",e[e.success=1]="success",e[e.error=2]="error"})(WWe||(WWe={}));new Promise(()=>{});function cne(e,i){i===void 0&&(i=[]);let n=[];return Ot.Children.forEach(e,(r,o)=>{if(!Ot.isValidElement(r))return;let l=[...i,o];if(r.type===Ot.Fragment){n.push.apply(n,cne(r.props.children,l));return}r.type!==Cne&&Vo(!1),!r.props.index||!r.props.children||Vo(!1);let c={id:r.props.id||l.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(c.children=cne(r.props.children,l)),n.push(c)}),n}/** - * React Router DOM v6.11.1 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */function Ane(){return Ane=Object.assign?Object.assign.bind():function(e){for(var i=1;i=0)&&(n[o]=e[o]);return n}function gLt(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function oLt(e,i){return e.button===0&&(!i||i==="_self")&&!gLt(e)}const aLt=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset"];function sLt(e){let{basename:i,children:n,window:r}=e,o=Ot.useRef();o.current==null&&(o.current=dOt({window:r,v5Compat:!0}));let l=o.current,[c,u]=Ot.useState({action:l.action,location:l.location});return Ot.useLayoutEffect(()=>l.listen(u),[l]),Ot.createElement(iLt,{basename:i,children:n,location:c.location,navigationType:c.action,navigator:l})}const ILt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",lLt=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,CLt=Ot.forwardRef(function(i,n){let{onClick:r,relative:o,reloadDocument:l,replace:c,state:u,target:f,to:m,preventScrollReset:p}=i,v=rLt(i,aLt),{basename:B}=Ot.useContext(Bw),G,T=!1;if(typeof m=="string"&&lLt.test(m)&&(G=m,ILt))try{let x=new URL(window.location.href),k=m.startsWith("//")?new URL(x.protocol+m):new URL(m),F=Gse(k.pathname,B);k.origin===x.origin&&F!=null?m=F+k.search+k.hash:T=!0}catch{}let V=YOt(m,{relative:o}),E=cLt(m,{replace:c,state:u,target:f,preventScrollReset:p,relative:o});function W(x){r&&r(x),x.defaultPrevented||E(x)}return Ot.createElement("a",Ane({},v,{href:G||V,onClick:T||l?r:W,ref:n,target:f}))});var NWe;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmitImpl="useSubmitImpl",e.UseFetcher="useFetcher"})(NWe||(NWe={}));var kWe;(function(e){e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(kWe||(kWe={}));function cLt(e,i){let{target:n,replace:r,state:o,preventScrollReset:l,relative:c}=i===void 0?{}:i,u=KOt(),f=sP(),m=BPe(e,{relative:c});return Ot.useCallback(p=>{if(oLt(p,n)){p.preventDefault();let v=r!==void 0?r:bK(f)===bK(m);u(e,{replace:v,state:o,preventScrollReset:l,relative:c})}},[f,u,m,r,o,n,e,l,c])}const ALt="modulepreload",uLt=function(e){return"/"+e},XWe={},dLt=function(i,n,r){if(!n||n.length===0)return i();const o=document.getElementsByTagName("link");return Promise.all(n.map(l=>{if(l=uLt(l),l in XWe)return;XWe[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(!!r)for(let p=o.length-1;p>=0;p--){const v=o[p];if(v.href===l&&(!c||v.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${u}`))return;const m=document.createElement("link");if(m.rel=c?"stylesheet":ALt,c||(m.as="script",m.crossOrigin=""),m.href=l,document.head.appendChild(m),c)return new Promise((p,v)=>{m.addEventListener("load",p),m.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${l}`)))})})).then(()=>i())};function hLt(e){var i=this.constructor;return this.then(function(n){return i.resolve(e()).then(function(){return n})},function(n){return i.resolve(e()).then(function(){return i.reject(n)})})}function fLt(e){var i=this;return new i(function(n,r){if(!(e&&typeof e.length<"u"))return r(new TypeError(typeof e+" "+e+" is not iterable(cannot read property Symbol(Symbol.iterator))"));var o=Array.prototype.slice.call(e);if(o.length===0)return n([]);var l=o.length;function c(f,m){if(m&&(typeof m=="object"||typeof m=="function")){var p=m.then;if(typeof p=="function"){p.call(m,function(v){c(f,v)},function(v){o[f]={status:"rejected",reason:v},--l===0&&n(o)});return}}o[f]={status:"fulfilled",value:m},--l===0&&n(o)}for(var u=0;u0?1:-1});Number.isInteger||(Number.isInteger=function(i){return typeof i=="number"&&isFinite(i)&&Math.floor(i)===i});self.ArrayBuffer||(self.ArrayBuffer=Array);self.Float32Array||(self.Float32Array=Array);self.Uint32Array||(self.Uint32Array=Array);self.Uint16Array||(self.Uint16Array=Array);self.Uint8Array||(self.Uint8Array=Array);self.Int32Array||(self.Int32Array=Array);var uq=/iPhone/i,MWe=/iPod/i,FWe=/iPad/i,YWe=/\biOS-universal(?:.+)Mac\b/i,dq=/\bAndroid(?:.+)Mobile\b/i,KWe=/Android/i,eG=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,yM=/Silk/i,uh=/Windows Phone/i,_We=/\bWindows(?:.+)ARM\b/i,PWe=/BlackBerry/i,zWe=/BB10/i,OWe=/Opera Mini/i,LWe=/\b(CriOS|Chrome)(?:.+)Mobile/i,JWe=/Mobile(?:.+)Firefox\b/i,UWe=function(e){return typeof e<"u"&&e.platform==="MacIntel"&&typeof e.maxTouchPoints=="number"&&e.maxTouchPoints>1&&typeof MSStream>"u"};function ELt(e){return function(i){return i.test(e)}}function HLt(e){var i={userAgent:"",platform:"",maxTouchPoints:0};!e&&typeof navigator<"u"?i={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof e=="string"?i.userAgent=e:e&&e.userAgent&&(i={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0});var n=i.userAgent,r=n.split("[FBAN");typeof r[1]<"u"&&(n=r[0]),r=n.split("Twitter"),typeof r[1]<"u"&&(n=r[0]);var o=ELt(n),l={apple:{phone:o(uq)&&!o(uh),ipod:o(MWe),tablet:!o(uq)&&(o(FWe)||UWe(i))&&!o(uh),universal:o(YWe),device:(o(uq)||o(MWe)||o(FWe)||o(YWe)||UWe(i))&&!o(uh)},amazon:{phone:o(eG),tablet:!o(eG)&&o(yM),device:o(eG)||o(yM)},android:{phone:!o(uh)&&o(eG)||!o(uh)&&o(dq),tablet:!o(uh)&&!o(eG)&&!o(dq)&&(o(yM)||o(KWe)),device:!o(uh)&&(o(eG)||o(yM)||o(dq)||o(KWe))||o(/\bokhttp\b/i)},windows:{phone:o(uh),tablet:o(_We),device:o(uh)||o(_We)},other:{blackberry:o(PWe),blackberry10:o(zWe),opera:o(OWe),firefox:o(JWe),chrome:o(LWe),device:o(PWe)||o(zWe)||o(OWe)||o(JWe)||o(LWe)},any:!1,phone:!1,tablet:!1};return l.any=l.apple.device||l.android.device||l.windows.device||l.other.device,l.phone=l.apple.phone||l.android.phone||l.windows.phone,l.tablet=l.apple.tablet||l.android.tablet||l.windows.tablet,l}/*! - * @pixi/settings - v6.0.4 - * Compiled Tue, 11 May 2021 18:00:23 UTC - * - * @pixi/settings is licensed under the MIT License. - * http://www.opensource.org/licenses/mit-license - */var EC=HLt(self.navigator);function WLt(e){var i=!0;if(EC.tablet||EC.phone){if(EC.apple.device){var n=navigator.userAgent.match(/OS (\d+)_(\d+)?/);if(n){var r=parseInt(n[1],10);r<11&&(i=!1)}}if(EC.android.device){var n=navigator.userAgent.match(/Android\s([0-9.]*)/);if(n){var r=parseInt(n[1],10);r<7&&(i=!1)}}}return i?e:4}function NLt(){return!EC.apple.device}var QWe;(function(e){e[e.WEBGL_LEGACY=0]="WEBGL_LEGACY",e[e.WEBGL=1]="WEBGL",e[e.WEBGL2=2]="WEBGL2"})(QWe||(QWe={}));var jWe;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.WEBGL=1]="WEBGL",e[e.CANVAS=2]="CANVAS"})(jWe||(jWe={}));var $We;(function(e){e[e.COLOR=16384]="COLOR",e[e.DEPTH=256]="DEPTH",e[e.STENCIL=1024]="STENCIL"})($We||($We={}));var qWe;(function(e){e[e.NORMAL=0]="NORMAL",e[e.ADD=1]="ADD",e[e.MULTIPLY=2]="MULTIPLY",e[e.SCREEN=3]="SCREEN",e[e.OVERLAY=4]="OVERLAY",e[e.DARKEN=5]="DARKEN",e[e.LIGHTEN=6]="LIGHTEN",e[e.COLOR_DODGE=7]="COLOR_DODGE",e[e.COLOR_BURN=8]="COLOR_BURN",e[e.HARD_LIGHT=9]="HARD_LIGHT",e[e.SOFT_LIGHT=10]="SOFT_LIGHT",e[e.DIFFERENCE=11]="DIFFERENCE",e[e.EXCLUSION=12]="EXCLUSION",e[e.HUE=13]="HUE",e[e.SATURATION=14]="SATURATION",e[e.COLOR=15]="COLOR",e[e.LUMINOSITY=16]="LUMINOSITY",e[e.NORMAL_NPM=17]="NORMAL_NPM",e[e.ADD_NPM=18]="ADD_NPM",e[e.SCREEN_NPM=19]="SCREEN_NPM",e[e.NONE=20]="NONE",e[e.SRC_OVER=0]="SRC_OVER",e[e.SRC_IN=21]="SRC_IN",e[e.SRC_OUT=22]="SRC_OUT",e[e.SRC_ATOP=23]="SRC_ATOP",e[e.DST_OVER=24]="DST_OVER",e[e.DST_IN=25]="DST_IN",e[e.DST_OUT=26]="DST_OUT",e[e.DST_ATOP=27]="DST_ATOP",e[e.ERASE=26]="ERASE",e[e.SUBTRACT=28]="SUBTRACT",e[e.XOR=29]="XOR"})(qWe||(qWe={}));var eNe;(function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN"})(eNe||(eNe={}));var tNe;(function(e){e[e.RGBA=6408]="RGBA",e[e.RGB=6407]="RGB",e[e.ALPHA=6406]="ALPHA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL"})(tNe||(tNe={}));var iNe;(function(e){e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z"})(iNe||(iNe={}));var nNe;(function(e){e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.FLOAT=5126]="FLOAT",e[e.HALF_FLOAT=36193]="HALF_FLOAT"})(nNe||(nNe={}));var rNe;(function(e){e[e.FLOAT=0]="FLOAT",e[e.INT=1]="INT",e[e.UINT=2]="UINT"})(rNe||(rNe={}));var hne;(function(e){e[e.NEAREST=0]="NEAREST",e[e.LINEAR=1]="LINEAR"})(hne||(hne={}));var fne;(function(e){e[e.CLAMP=33071]="CLAMP",e[e.REPEAT=10497]="REPEAT",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"})(fne||(fne={}));var mne;(function(e){e[e.OFF=0]="OFF",e[e.POW2=1]="POW2",e[e.ON=2]="ON",e[e.ON_MANUAL=3]="ON_MANUAL"})(mne||(mne={}));var gNe;(function(e){e[e.NPM=0]="NPM",e[e.UNPACK=1]="UNPACK",e[e.PMA=2]="PMA",e[e.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",e[e.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",e[e.PREMULTIPLY_ALPHA=2]="PREMULTIPLY_ALPHA"})(gNe||(gNe={}));var oNe;(function(e){e[e.NO=0]="NO",e[e.YES=1]="YES",e[e.AUTO=2]="AUTO",e[e.BLEND=0]="BLEND",e[e.CLEAR=1]="CLEAR",e[e.BLIT=2]="BLIT"})(oNe||(oNe={}));var pne;(function(e){e[e.AUTO=0]="AUTO",e[e.MANUAL=1]="MANUAL"})(pne||(pne={}));var hE;(function(e){e.LOW="lowp",e.MEDIUM="mediump",e.HIGH="highp"})(hE||(hE={}));var aNe;(function(e){e[e.NONE=0]="NONE",e[e.SCISSOR=1]="SCISSOR",e[e.STENCIL=2]="STENCIL",e[e.SPRITE=3]="SPRITE"})(aNe||(aNe={}));var sNe;(function(e){e[e.NONE=0]="NONE",e[e.LOW=2]="LOW",e[e.MEDIUM=4]="MEDIUM",e[e.HIGH=8]="HIGH"})(sNe||(sNe={}));var tn={MIPMAP_TEXTURES:mne.POW2,ANISOTROPIC_LEVEL:0,RESOLUTION:1,FILTER_RESOLUTION:1,SPRITE_MAX_TEXTURES:WLt(32),SPRITE_BATCH_SIZE:4096,RENDER_OPTIONS:{view:null,antialias:!1,autoDensity:!1,backgroundColor:0,backgroundAlpha:1,useContextAlpha:!0,clearBeforeRender:!0,preserveDrawingBuffer:!1,width:800,height:600,legacy:!1},GC_MODE:pne.AUTO,GC_MAX_IDLE:60*60,GC_MAX_CHECK_COUNT:60*10,WRAP_MODE:fne.CLAMP,SCALE_MODE:hne.LINEAR,PRECISION_VERTEX:hE.HIGH,PRECISION_FRAGMENT:EC.apple.device?hE.HIGH:hE.MEDIUM,CAN_UPLOAD_SAME_BUFFER:NLt(),CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1},VPe={exports:{}};(function(e){var i=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function o(f,m,p){this.fn=f,this.context=m,this.once=p||!1}function l(f,m,p,v,B){if(typeof p!="function")throw new TypeError("The listener must be a function");var G=new o(p,v||f,B),T=n?n+m:m;return f._events[T]?f._events[T].fn?f._events[T]=[f._events[T],G]:f._events[T].push(G):(f._events[T]=G,f._eventsCount++),f}function c(f,m){--f._eventsCount===0?f._events=new r:delete f._events[m]}function u(){this._events=new r,this._eventsCount=0}u.prototype.eventNames=function(){var m=[],p,v;if(this._eventsCount===0)return m;for(v in p=this._events)i.call(p,v)&&m.push(n?v.slice(1):v);return Object.getOwnPropertySymbols?m.concat(Object.getOwnPropertySymbols(p)):m},u.prototype.listeners=function(m){var p=n?n+m:m,v=this._events[p];if(!v)return[];if(v.fn)return[v.fn];for(var B=0,G=v.length,T=new Array(G);B80*n){u=m=e[0],f=p=e[1];for(var T=n;Tm&&(m=v),B>p&&(p=B);G=Math.max(m-u,p-f),G=G!==0?32767/G:0}return nH(l,c,n,u,f,G,0),c}function EPe(e,i,n,r,o){var l,c;if(o===vne(e,i,n,r)>0)for(l=i;l=i;l-=r)c=INe(l,e[l],e[l+1],c);return c&&lP(c,c.next)&&(gH(c),c=c.next),c}function ov(e,i){if(!e)return e;i||(i=e);var n=e,r;do if(r=!1,!n.steiner&&(lP(n,n.next)||Ug(n.prev,n,n.next)===0)){if(gH(n),n=i=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==i);return i}function nH(e,i,n,r,o,l,c){if(e){!c&&l&&zLt(e,r,o,l);for(var u=e,f,m;e.prev!==e.next;){if(f=e.prev,m=e.next,l?xLt(e,r,o,l):XLt(e)){i.push(f.i/n|0),i.push(e.i/n|0),i.push(m.i/n|0),gH(e),e=m.next,u=m.next;continue}if(e=m,e===u){c?c===1?(e=DLt(ov(e),i,n),nH(e,i,n,r,o,l,2)):c===2&&MLt(e,i,n,r,o,l):nH(ov(e),i,n,r,o,l,1);break}}}}function XLt(e){var i=e.prev,n=e,r=e.next;if(Ug(i,n,r)>=0)return!1;for(var o=i.x,l=n.x,c=r.x,u=i.y,f=n.y,m=r.y,p=ol?o>c?o:c:l>c?l:c,G=u>f?u>m?u:m:f>m?f:m,T=r.next;T!==i;){if(T.x>=p&&T.x<=B&&T.y>=v&&T.y<=G&&KG(o,u,l,f,c,m,T.x,T.y)&&Ug(T.prev,T,T.next)>=0)return!1;T=T.next}return!0}function xLt(e,i,n,r){var o=e.prev,l=e,c=e.next;if(Ug(o,l,c)>=0)return!1;for(var u=o.x,f=l.x,m=c.x,p=o.y,v=l.y,B=c.y,G=uf?u>m?u:m:f>m?f:m,E=p>v?p>B?p:B:v>B?v:B,W=bne(G,T,i,n,r),x=bne(V,E,i,n,r),k=e.prevZ,F=e.nextZ;k&&k.z>=W&&F&&F.z<=x;){if(k.x>=G&&k.x<=V&&k.y>=T&&k.y<=E&&k!==o&&k!==c&&KG(u,p,f,v,m,B,k.x,k.y)&&Ug(k.prev,k,k.next)>=0||(k=k.prevZ,F.x>=G&&F.x<=V&&F.y>=T&&F.y<=E&&F!==o&&F!==c&&KG(u,p,f,v,m,B,F.x,F.y)&&Ug(F.prev,F,F.next)>=0))return!1;F=F.nextZ}for(;k&&k.z>=W;){if(k.x>=G&&k.x<=V&&k.y>=T&&k.y<=E&&k!==o&&k!==c&&KG(u,p,f,v,m,B,k.x,k.y)&&Ug(k.prev,k,k.next)>=0)return!1;k=k.prevZ}for(;F&&F.z<=x;){if(F.x>=G&&F.x<=V&&F.y>=T&&F.y<=E&&F!==o&&F!==c&&KG(u,p,f,v,m,B,F.x,F.y)&&Ug(F.prev,F,F.next)>=0)return!1;F=F.nextZ}return!0}function DLt(e,i,n){var r=e;do{var o=r.prev,l=r.next.next;!lP(o,l)&&HPe(o,r,r.next,l)&&rH(o,l)&&rH(l,o)&&(i.push(o.i/n|0),i.push(r.i/n|0),i.push(l.i/n|0),gH(r),gH(r.next),r=e=l),r=r.next}while(r!==e);return ov(r)}function MLt(e,i,n,r,o,l){var c=e;do{for(var u=c.next.next;u!==c.prev;){if(c.i!==u.i&&JLt(c,u)){var f=WPe(c,u);c=ov(c,c.next),f=ov(f,f.next),nH(c,i,n,r,o,l,0),nH(f,i,n,r,o,l,0);return}u=u.next}c=c.next}while(c!==e)}function FLt(e,i,n,r){var o=[],l,c,u,f,m;for(l=0,c=i.length;l=n.next.y&&n.next.y!==n.y){var u=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(u<=r&&u>l&&(l=u,c=n.x=n.x&&n.x>=m&&r!==n.x&&KG(oc.x||n.x===c.x&&PLt(c,n)))&&(c=n,v=B)),n=n.next;while(n!==f);return c}function PLt(e,i){return Ug(e.prev,e,i.prev)<0&&Ug(i.next,e,e.next)<0}function zLt(e,i,n,r){var o=e;do o.z===0&&(o.z=bne(o.x,o.y,i,n,r)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next;while(o!==e);o.prevZ.nextZ=null,o.prevZ=null,OLt(o)}function OLt(e){var i,n,r,o,l,c,u,f,m=1;do{for(n=e,e=null,l=null,c=0;n;){for(c++,r=n,u=0,i=0;i0||f>0&&r;)u!==0&&(f===0||!r||n.z<=r.z)?(o=n,n=n.nextZ,u--):(o=r,r=r.nextZ,f--),l?l.nextZ=o:e=o,o.prevZ=l,l=o;n=r}l.nextZ=null,m*=2}while(c>1);return e}function bne(e,i,n,r,o){return e=(e-n)*o|0,i=(i-r)*o|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e|i<<1}function LLt(e){var i=e,n=e;do(i.x=(e-c)*(l-u)&&(e-c)*(r-u)>=(n-c)*(i-u)&&(n-c)*(l-u)>=(o-c)*(r-u)}function JLt(e,i){return e.next.i!==i.i&&e.prev.i!==i.i&&!ULt(e,i)&&(rH(e,i)&&rH(i,e)&&QLt(e,i)&&(Ug(e.prev,e,i.prev)||Ug(e,i.prev,i))||lP(e,i)&&Ug(e.prev,e,e.next)>0&&Ug(i.prev,i,i.next)>0)}function Ug(e,i,n){return(i.y-e.y)*(n.x-i.x)-(i.x-e.x)*(n.y-i.y)}function lP(e,i){return e.x===i.x&&e.y===i.y}function HPe(e,i,n,r){var o=ZM(Ug(e,i,n)),l=ZM(Ug(e,i,r)),c=ZM(Ug(n,r,e)),u=ZM(Ug(n,r,i));return!!(o!==l&&c!==u||o===0&&vM(e,n,i)||l===0&&vM(e,r,i)||c===0&&vM(n,e,r)||u===0&&vM(n,i,r))}function vM(e,i,n){return i.x<=Math.max(e.x,n.x)&&i.x>=Math.min(e.x,n.x)&&i.y<=Math.max(e.y,n.y)&&i.y>=Math.min(e.y,n.y)}function ZM(e){return e>0?1:e<0?-1:0}function ULt(e,i){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==i.i&&n.next.i!==i.i&&HPe(n,n.next,e,i))return!0;n=n.next}while(n!==e);return!1}function rH(e,i){return Ug(e.prev,e,e.next)<0?Ug(e,i,e.next)>=0&&Ug(e,e.prev,i)>=0:Ug(e,i,e.prev)<0||Ug(e,e.next,i)<0}function QLt(e,i){var n=e,r=!1,o=(e.x+i.x)/2,l=(e.y+i.y)/2;do n.y>l!=n.next.y>l&&n.next.y!==n.y&&o<(n.next.x-n.x)*(l-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function WPe(e,i){var n=new yne(e.i,e.x,e.y),r=new yne(i.i,i.x,i.y),o=e.next,l=i.prev;return e.next=i,i.prev=e,n.next=o,o.prev=n,r.next=n,n.prev=r,l.next=r,r.prev=l,r}function INe(e,i,n,r){var o=new yne(e,i,n);return r?(o.next=r.next,o.prev=r,r.next.prev=o,r.next=o):(o.prev=o,o.next=o),o}function gH(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function yne(e,i,n){this.i=e,this.x=i,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}IP.deviation=function(e,i,n,r){var o=i&&i.length,l=o?i[0]*n:e.length,c=Math.abs(vne(e,0,l,n));if(o)for(var u=0,f=i.length;u0&&(r+=e[o-1].length,n.holes.push(r))}return n};var jLt=Sse.exports;const wse=Al(jLt);var vK={exports:{}};/*! https://mths.be/punycode v1.3.2 by @mathias */vK.exports;(function(e,i){(function(n){var r=i&&!i.nodeType&&i,o=e&&!e.nodeType&&e,l=typeof Qg=="object"&&Qg;(l.global===l||l.window===l||l.self===l)&&(n=l);var c,u=2147483647,f=36,m=1,p=26,v=38,B=700,G=72,T=128,V="-",E=/^xn--/,W=/[^\x20-\x7E]/,x=/[\x2E\u3002\uFF0E\uFF61]/g,k={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},F=f-m,Y=Math.floor,L=String.fromCharCode,O;function Q(Ee){throw RangeError(k[Ee])}function X(Ee,Je){for(var Ue=Ee.length,dt=[];Ue--;)dt[Ue]=Je(Ee[Ue]);return dt}function $(Ee,Je){var Ue=Ee.split("@"),dt="";Ue.length>1&&(dt=Ue[0]+"@",Ee=Ue[1]),Ee=Ee.replace(x,".");var rt=Ee.split("."),ke=X(rt,Je).join(".");return dt+ke}function ee(Ee){for(var Je=[],Ue=0,dt=Ee.length,rt,ke;Ue=55296&&rt<=56319&&Ue65535&&(Je-=65536,Ue+=L(Je>>>10&1023|55296),Je=56320|Je&1023),Ue+=L(Je),Ue}).join("")}function ge(Ee){return Ee-48<10?Ee-22:Ee-65<26?Ee-65:Ee-97<26?Ee-97:f}function Ae(Ee,Je){return Ee+22+75*(Ee<26)-((Je!=0)<<5)}function _(Ee,Je,Ue){var dt=0;for(Ee=Ue?Y(Ee/B):Ee>>1,Ee+=Y(Ee/Je);Ee>F*p>>1;dt+=f)Ee=Y(Ee/F);return Y(dt+(F+1)*Ee/(Ee+v))}function de(Ee){var Je=[],Ue=Ee.length,dt,rt=0,ke=T,ze=G,je,lt,xe,it,Ct,It,Et,Zt,zt;for(je=Ee.lastIndexOf(V),je<0&&(je=0),lt=0;lt=128&&Q("not-basic"),Je.push(Ee.charCodeAt(lt));for(xe=je>0?je+1:0;xe=Ue&&Q("invalid-input"),Et=ge(Ee.charCodeAt(xe++)),(Et>=f||Et>Y((u-rt)/Ct))&&Q("overflow"),rt+=Et*Ct,Zt=It<=ze?m:It>=ze+p?p:It-ze,!(EtY(u/zt)&&Q("overflow"),Ct*=zt;dt=Je.length+1,ze=_(rt-it,dt,it==0),Y(rt/dt)>u-ke&&Q("overflow"),ke+=Y(rt/dt),rt%=dt,Je.splice(rt++,0,ke)}return ne(Je)}function Ze(Ee){var Je,Ue,dt,rt,ke,ze,je,lt,xe,it,Ct,It=[],Et,Zt,zt,Kt;for(Ee=ee(Ee),Et=Ee.length,Je=T,Ue=0,ke=G,ze=0;ze=Je&&CtY((u-Ue)/Zt)&&Q("overflow"),Ue+=(je-Je)*Zt,Je=je,ze=0;zeu&&Q("overflow"),Ct==Je){for(lt=Ue,xe=f;it=xe<=ke?m:xe>=ke+p?p:xe-ke,!(lt0&&u>c&&(u=c);for(var f=0;f=0?(v=m.substr(0,p),B=m.substr(p+1)):(v=m,B=""),G=decodeURIComponent(v),T=decodeURIComponent(B),eJt(o,G)?Array.isArray(o[G])?o[G].push(T):o[G]=[o[G],T]:o[G]=T}return o},WV=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},iJt=function(e,i,n,r){return i=i||"&",n=n||"=",e===null&&(e=void 0),typeof e=="object"?Object.keys(e).map(function(o){var l=encodeURIComponent(WV(o))+n;return Array.isArray(e[o])?e[o].map(function(c){return l+encodeURIComponent(WV(c))}).join(i):l+encodeURIComponent(WV(e[o]))}).join(i):r?encodeURIComponent(WV(r))+n+encodeURIComponent(WV(e)):""};oH.decode=oH.parse=tJt;oH.encode=oH.stringify=iJt;var nJt=$Lt,Hu=qLt,rJt=CP,gJt=hJt,oJt=dJt;function dA(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var aJt=/^([a-z0-9.+-]+:)/i,sJt=/:[0-9]*$/,IJt=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,lJt=["<",">",'"',"`"," ","\r",` -`," "],CJt=["{","}","|","\\","^","`"].concat(lJt),Zne=["'"].concat(CJt),lNe=["%","/","?",";","#"].concat(Zne),CNe=["/","?","#"],cJt=255,cNe=/^[+a-z0-9A-Z_-]{0,63}$/,AJt=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,uJt={javascript:!0,"javascript:":!0},Bne={javascript:!0,"javascript:":!0},rS={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},Gne=oH;function CP(e,i,n){if(e&&Hu.isObject(e)&&e instanceof dA)return e;var r=new dA;return r.parse(e,i,n),r}dA.prototype.parse=function(e,i,n){if(!Hu.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var r=e.indexOf("?"),o=r!==-1&&r127?Y+="x":Y+=F[L];if(!Y.match(cNe)){var Q=x.slice(0,G),X=x.slice(G+1),$=F.match(AJt);$&&(Q.push($[1]),X.unshift($[2])),X.length&&(u="/"+X.join(".")+u),this.hostname=Q.join(".");break}}}this.hostname.length>cJt?this.hostname="":this.hostname=this.hostname.toLowerCase(),W||(this.hostname=nJt.toASCII(this.hostname));var ee=this.port?":"+this.port:"",ne=this.hostname||"";this.host=ne+ee,this.href+=this.host,W&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),u[0]!=="/"&&(u="/"+u))}if(!uJt[p])for(var G=0,k=Zne.length;G0?n.host.split("@"):!1;Y&&(n.auth=Y.shift(),n.host=n.hostname=Y.shift())}return n.search=e.search,n.query=e.query,(!Hu.isNull(n.pathname)||!Hu.isNull(n.search))&&(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!x.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var L=x.slice(-1)[0],O=(n.host||e.host||x.length>1)&&(L==="."||L==="..")||L==="",Q=0,X=x.length;X>=0;X--)L=x[X],L==="."?x.splice(X,1):L===".."?(x.splice(X,1),Q++):Q&&(x.splice(X,1),Q--);if(!E&&!W)for(;Q--;Q)x.unshift("..");E&&x[0]!==""&&(!x[0]||x[0].charAt(0)!=="/")&&x.unshift(""),O&&x.join("/").substr(-1)!=="/"&&x.push("");var $=x[0]===""||x[0]&&x[0].charAt(0)==="/";if(F){n.hostname=n.host=$?"":x.length?x.shift():"";var Y=n.host&&n.host.indexOf("@")>0?n.host.split("@"):!1;Y&&(n.auth=Y.shift(),n.host=n.hostname=Y.shift())}return E=E||n.host&&x.length,E&&!$&&x.unshift(""),x.length?n.pathname=x.join("/"):(n.pathname=null,n.path=null),(!Hu.isNull(n.pathname)||!Hu.isNull(n.search))&&(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n};dA.prototype.parseHost=function(){var e=this.host,i=sJt.exec(e);i&&(i=i[0],i!==":"&&(this.port=i.substr(1)),e=e.substr(0,e.length-i.length)),e&&(this.hostname=e)};/*! - * @pixi/constants - v6.0.4 - * Compiled Tue, 11 May 2021 18:00:23 UTC - * - * @pixi/constants is licensed under the MIT License. - * http://www.opensource.org/licenses/mit-license - */var gd;(function(e){e[e.WEBGL_LEGACY=0]="WEBGL_LEGACY",e[e.WEBGL=1]="WEBGL",e[e.WEBGL2=2]="WEBGL2"})(gd||(gd={}));var RS;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.WEBGL=1]="WEBGL",e[e.CANVAS=2]="CANVAS"})(RS||(RS={}));var aH;(function(e){e[e.COLOR=16384]="COLOR",e[e.DEPTH=256]="DEPTH",e[e.STENCIL=1024]="STENCIL"})(aH||(aH={}));var gn;(function(e){e[e.NORMAL=0]="NORMAL",e[e.ADD=1]="ADD",e[e.MULTIPLY=2]="MULTIPLY",e[e.SCREEN=3]="SCREEN",e[e.OVERLAY=4]="OVERLAY",e[e.DARKEN=5]="DARKEN",e[e.LIGHTEN=6]="LIGHTEN",e[e.COLOR_DODGE=7]="COLOR_DODGE",e[e.COLOR_BURN=8]="COLOR_BURN",e[e.HARD_LIGHT=9]="HARD_LIGHT",e[e.SOFT_LIGHT=10]="SOFT_LIGHT",e[e.DIFFERENCE=11]="DIFFERENCE",e[e.EXCLUSION=12]="EXCLUSION",e[e.HUE=13]="HUE",e[e.SATURATION=14]="SATURATION",e[e.COLOR=15]="COLOR",e[e.LUMINOSITY=16]="LUMINOSITY",e[e.NORMAL_NPM=17]="NORMAL_NPM",e[e.ADD_NPM=18]="ADD_NPM",e[e.SCREEN_NPM=19]="SCREEN_NPM",e[e.NONE=20]="NONE",e[e.SRC_OVER=0]="SRC_OVER",e[e.SRC_IN=21]="SRC_IN",e[e.SRC_OUT=22]="SRC_OUT",e[e.SRC_ATOP=23]="SRC_ATOP",e[e.DST_OVER=24]="DST_OVER",e[e.DST_IN=25]="DST_IN",e[e.DST_OUT=26]="DST_OUT",e[e.DST_ATOP=27]="DST_ATOP",e[e.ERASE=26]="ERASE",e[e.SUBTRACT=28]="SUBTRACT",e[e.XOR=29]="XOR"})(gn||(gn={}));var HC;(function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN"})(HC||(HC={}));var tA;(function(e){e[e.RGBA=6408]="RGBA",e[e.RGB=6407]="RGB",e[e.ALPHA=6406]="ALPHA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL"})(tA||(tA={}));var Zp;(function(e){e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z"})(Zp||(Zp={}));var Ur;(function(e){e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.FLOAT=5126]="FLOAT",e[e.HALF_FLOAT=36193]="HALF_FLOAT"})(Ur||(Ur={}));var sH;(function(e){e[e.FLOAT=0]="FLOAT",e[e.INT=1]="INT",e[e.UINT=2]="UINT"})(sH||(sH={}));var Yu;(function(e){e[e.NEAREST=0]="NEAREST",e[e.LINEAR=1]="LINEAR"})(Yu||(Yu={}));var Ou;(function(e){e[e.CLAMP=33071]="CLAMP",e[e.REPEAT=10497]="REPEAT",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"})(Ou||(Ou={}));var gf;(function(e){e[e.OFF=0]="OFF",e[e.POW2=1]="POW2",e[e.ON=2]="ON",e[e.ON_MANUAL=3]="ON_MANUAL"})(gf||(gf={}));var od;(function(e){e[e.NPM=0]="NPM",e[e.UNPACK=1]="UNPACK",e[e.PMA=2]="PMA",e[e.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",e[e.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",e[e.PREMULTIPLY_ALPHA=2]="PREMULTIPLY_ALPHA"})(od||(od={}));var Gh;(function(e){e[e.NO=0]="NO",e[e.YES=1]="YES",e[e.AUTO=2]="AUTO",e[e.BLEND=0]="BLEND",e[e.CLEAR=1]="CLEAR",e[e.BLIT=2]="BLIT"})(Gh||(Gh={}));var ZK;(function(e){e[e.AUTO=0]="AUTO",e[e.MANUAL=1]="MANUAL"})(ZK||(ZK={}));var sA;(function(e){e.LOW="lowp",e.MEDIUM="mediump",e.HIGH="highp"})(sA||(sA={}));var YI;(function(e){e[e.NONE=0]="NONE",e[e.SCISSOR=1]="SCISSOR",e[e.STENCIL=2]="STENCIL",e[e.SPRITE=3]="SPRITE"})(YI||(YI={}));var av;(function(e){e[e.NONE=0]="NONE",e[e.LOW=2]="LOW",e[e.MEDIUM=4]="MEDIUM",e[e.HIGH=8]="HIGH"})(av||(av={}));/*! - * @pixi/utils - v6.0.4 - * Compiled Tue, 11 May 2021 18:00:23 UTC - * - * @pixi/utils is licensed under the MIT License. - * http://www.opensource.org/licenses/mit-license - */var Sy={parse:rJt,format:oJt,resolve:gJt};tn.RETINA_PREFIX=/@([0-9\.]+)x/;tn.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Sne=!1,ANe="6.0.4";function fJt(){Sne=!0}function NPe(e){var i;if(!Sne){if(navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var n=[` - %c %c %c PixiJS `+ANe+" - ✰ "+e+` ✰ %c %c http://www.pixijs.com/ %c %c ♥%c♥%c♥ - -`,"background: #ff66a5; padding:5px 0;","background: #ff66a5; padding:5px 0;","color: #ff66a5; background: #030307; padding:5px 0;","background: #ff66a5; padding:5px 0;","background: #ffc3dc; padding:5px 0;","background: #ff66a5; padding:5px 0;","color: #ff2424; background: #fff; padding:5px 0;","color: #ff2424; background: #fff; padding:5px 0;","color: #ff2424; background: #fff; padding:5px 0;"];(i=self.console).log.apply(i,n)}else self.console&&self.console.log("PixiJS "+ANe+" - "+e+" - http://www.pixijs.com/");Sne=!0}}var hq;function kPe(){return typeof hq>"u"&&(hq=function(){var i={stencil:!0,failIfMajorPerformanceCaveat:tn.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!self.WebGLRenderingContext)return!1;var n=document.createElement("canvas"),r=n.getContext("webgl",i)||n.getContext("experimental-webgl",i),o=!!(r&&r.getContextAttributes().stencil);if(r){var l=r.getExtension("WEBGL_lose_context");l&&l.loseContext()}return r=null,o}catch{return!1}}()),hq}var mJt="#f0f8ff",pJt="#faebd7",bJt="#00ffff",yJt="#7fffd4",vJt="#f0ffff",ZJt="#f5f5dc",BJt="#ffe4c4",GJt="#000000",SJt="#ffebcd",wJt="#0000ff",TJt="#8a2be2",RJt="#a52a2a",VJt="#deb887",EJt="#5f9ea0",HJt="#7fff00",WJt="#d2691e",NJt="#ff7f50",kJt="#6495ed",XJt="#fff8dc",xJt="#dc143c",DJt="#00ffff",MJt="#00008b",FJt="#008b8b",YJt="#b8860b",KJt="#a9a9a9",_Jt="#006400",PJt="#a9a9a9",zJt="#bdb76b",OJt="#8b008b",LJt="#556b2f",JJt="#ff8c00",UJt="#9932cc",QJt="#8b0000",jJt="#e9967a",$Jt="#8fbc8f",qJt="#483d8b",eUt="#2f4f4f",tUt="#2f4f4f",iUt="#00ced1",nUt="#9400d3",rUt="#ff1493",gUt="#00bfff",oUt="#696969",aUt="#696969",sUt="#1e90ff",IUt="#b22222",lUt="#fffaf0",CUt="#228b22",cUt="#ff00ff",AUt="#dcdcdc",uUt="#f8f8ff",dUt="#daa520",hUt="#ffd700",fUt="#808080",mUt="#008000",pUt="#adff2f",bUt="#808080",yUt="#f0fff0",vUt="#ff69b4",ZUt="#cd5c5c",BUt="#4b0082",GUt="#fffff0",SUt="#f0e68c",wUt="#fff0f5",TUt="#e6e6fa",RUt="#7cfc00",VUt="#fffacd",EUt="#add8e6",HUt="#f08080",WUt="#e0ffff",NUt="#fafad2",kUt="#d3d3d3",XUt="#90ee90",xUt="#d3d3d3",DUt="#ffb6c1",MUt="#ffa07a",FUt="#20b2aa",YUt="#87cefa",KUt="#778899",_Ut="#778899",PUt="#b0c4de",zUt="#ffffe0",OUt="#00ff00",LUt="#32cd32",JUt="#faf0e6",UUt="#ff00ff",QUt="#800000",jUt="#66cdaa",$Ut="#0000cd",qUt="#ba55d3",e7t="#9370db",t7t="#3cb371",i7t="#7b68ee",n7t="#00fa9a",r7t="#48d1cc",g7t="#c71585",o7t="#191970",a7t="#f5fffa",s7t="#ffe4e1",I7t="#ffe4b5",l7t="#ffdead",C7t="#000080",c7t="#fdf5e6",A7t="#808000",u7t="#6b8e23",d7t="#ffa500",h7t="#ff4500",f7t="#da70d6",m7t="#eee8aa",p7t="#98fb98",b7t="#afeeee",y7t="#db7093",v7t="#ffefd5",Z7t="#ffdab9",B7t="#cd853f",G7t="#ffc0cb",S7t="#dda0dd",w7t="#b0e0e6",T7t="#800080",R7t="#663399",V7t="#ff0000",E7t="#bc8f8f",H7t="#4169e1",W7t="#8b4513",N7t="#fa8072",k7t="#f4a460",X7t="#2e8b57",x7t="#fff5ee",D7t="#a0522d",M7t="#c0c0c0",F7t="#87ceeb",Y7t="#6a5acd",K7t="#708090",_7t="#708090",P7t="#fffafa",z7t="#00ff7f",O7t="#4682b4",L7t="#d2b48c",J7t="#008080",U7t="#d8bfd8",Q7t="#ff6347",j7t="#40e0d0",$7t="#ee82ee",q7t="#f5deb3",e4t="#ffffff",t4t="#f5f5f5",i4t="#ffff00",n4t="#9acd32",r4t={aliceblue:mJt,antiquewhite:pJt,aqua:bJt,aquamarine:yJt,azure:vJt,beige:ZJt,bisque:BJt,black:GJt,blanchedalmond:SJt,blue:wJt,blueviolet:TJt,brown:RJt,burlywood:VJt,cadetblue:EJt,chartreuse:HJt,chocolate:WJt,coral:NJt,cornflowerblue:kJt,cornsilk:XJt,crimson:xJt,cyan:DJt,darkblue:MJt,darkcyan:FJt,darkgoldenrod:YJt,darkgray:KJt,darkgreen:_Jt,darkgrey:PJt,darkkhaki:zJt,darkmagenta:OJt,darkolivegreen:LJt,darkorange:JJt,darkorchid:UJt,darkred:QJt,darksalmon:jJt,darkseagreen:$Jt,darkslateblue:qJt,darkslategray:eUt,darkslategrey:tUt,darkturquoise:iUt,darkviolet:nUt,deeppink:rUt,deepskyblue:gUt,dimgray:oUt,dimgrey:aUt,dodgerblue:sUt,firebrick:IUt,floralwhite:lUt,forestgreen:CUt,fuchsia:cUt,gainsboro:AUt,ghostwhite:uUt,goldenrod:dUt,gold:hUt,gray:fUt,green:mUt,greenyellow:pUt,grey:bUt,honeydew:yUt,hotpink:vUt,indianred:ZUt,indigo:BUt,ivory:GUt,khaki:SUt,lavenderblush:wUt,lavender:TUt,lawngreen:RUt,lemonchiffon:VUt,lightblue:EUt,lightcoral:HUt,lightcyan:WUt,lightgoldenrodyellow:NUt,lightgray:kUt,lightgreen:XUt,lightgrey:xUt,lightpink:DUt,lightsalmon:MUt,lightseagreen:FUt,lightskyblue:YUt,lightslategray:KUt,lightslategrey:_Ut,lightsteelblue:PUt,lightyellow:zUt,lime:OUt,limegreen:LUt,linen:JUt,magenta:UUt,maroon:QUt,mediumaquamarine:jUt,mediumblue:$Ut,mediumorchid:qUt,mediumpurple:e7t,mediumseagreen:t7t,mediumslateblue:i7t,mediumspringgreen:n7t,mediumturquoise:r7t,mediumvioletred:g7t,midnightblue:o7t,mintcream:a7t,mistyrose:s7t,moccasin:I7t,navajowhite:l7t,navy:C7t,oldlace:c7t,olive:A7t,olivedrab:u7t,orange:d7t,orangered:h7t,orchid:f7t,palegoldenrod:m7t,palegreen:p7t,paleturquoise:b7t,palevioletred:y7t,papayawhip:v7t,peachpuff:Z7t,peru:B7t,pink:G7t,plum:S7t,powderblue:w7t,purple:T7t,rebeccapurple:R7t,red:V7t,rosybrown:E7t,royalblue:H7t,saddlebrown:W7t,salmon:N7t,sandybrown:k7t,seagreen:X7t,seashell:x7t,sienna:D7t,silver:M7t,skyblue:F7t,slateblue:Y7t,slategray:K7t,slategrey:_7t,snow:P7t,springgreen:z7t,steelblue:O7t,tan:L7t,teal:J7t,thistle:U7t,tomato:Q7t,turquoise:j7t,violet:$7t,wheat:q7t,white:e4t,whitesmoke:t4t,yellow:i4t,yellowgreen:n4t};function sv(e,i){return i===void 0&&(i=[]),i[0]=(e>>16&255)/255,i[1]=(e>>8&255)/255,i[2]=(e&255)/255,i}function Tse(e){var i=e.toString(16);return i="000000".substr(0,6-i.length)+i,"#"+i}function Rse(e){return typeof e=="string"&&(e=r4t[e.toLowerCase()]||e,e[0]==="#"&&(e=e.substr(1))),parseInt(e,16)}function XPe(e){return(e[0]*255<<16)+(e[1]*255<<8)+(e[2]*255|0)}function g4t(){for(var e=[],i=[],n=0;n<32;n++)e[n]=n,i[n]=n;e[gn.NORMAL_NPM]=gn.NORMAL,e[gn.ADD_NPM]=gn.ADD,e[gn.SCREEN_NPM]=gn.SCREEN,i[gn.NORMAL]=gn.NORMAL_NPM,i[gn.ADD]=gn.ADD_NPM,i[gn.SCREEN]=gn.SCREEN_NPM;var r=[];return r.push(i),r.push(e),r}var Vse=g4t();function Ese(e,i){return Vse[i?1:0][e]}function xPe(e,i,n,r){return n=n||new Float32Array(4),r||r===void 0?(n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i):(n[0]=e[0],n[1]=e[1],n[2]=e[2]),n[3]=i,n}function cP(e,i){if(i===1)return(i*255<<24)+e;if(i===0)return 0;var n=e>>16&255,r=e>>8&255,o=e&255;return n=n*i+.5|0,r=r*i+.5|0,o=o*i+.5|0,(i*255<<24)+(n<<16)+(r<<8)+o}function Hse(e,i,n,r){return n=n||new Float32Array(4),n[0]=(e>>16&255)/255,n[1]=(e>>8&255)/255,n[2]=(e&255)/255,(r||r===void 0)&&(n[0]*=i,n[1]*=i,n[2]*=i),n[3]=i,n}function DPe(e,i){i===void 0&&(i=null);var n=e*6;if(i=i||new Uint16Array(n),i.length!==n)throw new Error("Out buffer length is incorrect, got "+i.length+" and expected "+n);for(var r=0,o=0;r>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e+1}function wne(e){return!(e&e-1)&&!!e}function Tne(e){var i=(e>65535?1:0)<<4;e>>>=i;var n=(e>255?1:0)<<3;return e>>>=n,i|=n,n=(e>15?1:0)<<2,e>>>=n,i|=n,n=(e>3?1:0)<<1,e>>>=n,i|=n,i|e>>1}function Dy(e,i,n){var r=e.length,o;if(!(i>=r||n===0)){n=i+n>r?r-i:n;var l=r-n;for(o=i;o"u"?console.warn("PixiJS Deprecation Warning: ",i+` -Deprecated since v`+e):(r=r.split(` -`).splice(n).join(` -`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",i+` -Deprecated since v`+e),console.warn(r),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",i+` -Deprecated since v`+e),console.warn(r))),uNe[i]=!0}}var Rne={},KI=Object.create(null),SC=Object.create(null);function I4t(){var e;for(e in KI)KI[e].destroy();for(e in SC)SC[e].destroy()}function l4t(){var e;for(e in KI)delete KI[e];for(e in SC)delete SC[e]}var Vne=function(){function e(i,n,r){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.resolution=r||tn.RESOLUTION,this.resize(i,n)}return e.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height)},e.prototype.resize=function(i,n){this.canvas.width=i*this.resolution,this.canvas.height=n*this.resolution},e.prototype.destroy=function(){this.context=null,this.canvas=null},Object.defineProperty(e.prototype,"width",{get:function(){return this.canvas.width},set:function(i){this.canvas.width=i},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this.canvas.height},set:function(i){this.canvas.height=i},enumerable:!1,configurable:!0}),e}();function FPe(e){var i=e.width,n=e.height,r=e.getContext("2d"),o=r.getImageData(0,0,i,n),l=o.data,c=l.length,u={top:null,left:null,right:null,bottom:null},f=null,m,p,v;for(m=0;m=this.x&&i=this.y&&nn!=p>n&&i<(m-u)*((n-f)/(p-f))+u;v&&(r=!r)}return r},e.prototype.toString=function(){return"[@pixi/math:Polygon"+("closeStroke="+this.closeStroke)+("points="+this.points.reduce(function(i,n){return i+", "+n},"")+"]")},e}(),LPe=function(){function e(i,n,r,o,l){i===void 0&&(i=0),n===void 0&&(n=0),r===void 0&&(r=0),o===void 0&&(o=0),l===void 0&&(l=20),this.x=i,this.y=n,this.width=r,this.height=o,this.radius=l,this.type=Io.RREC}return e.prototype.clone=function(){return new e(this.x,this.y,this.width,this.height,this.radius)},e.prototype.contains=function(i,n){if(this.width<=0||this.height<=0)return!1;if(i>=this.x&&i<=this.x+this.width&&n>=this.y&&n<=this.y+this.height){if(n>=this.y+this.radius&&n<=this.y+this.height-this.radius||i>=this.x+this.radius&&i<=this.x+this.width-this.radius)return!0;var r=i-(this.x+this.radius),o=n-(this.y+this.radius),l=this.radius*this.radius;if(r*r+o*o<=l||(r=i-(this.x+this.width-this.radius),r*r+o*o<=l)||(o=n-(this.y+this.height-this.radius),r*r+o*o<=l)||(r=i-(this.x+this.radius),r*r+o*o<=l))return!0}return!1},e.prototype.toString=function(){return"[@pixi/math:RoundedRectangle x="+this.x+" y="+this.y+("width="+this.width+" height="+this.height+" radius="+this.radius+"]")},e}(),Co=function(){function e(i,n){i===void 0&&(i=0),n===void 0&&(n=0),this.x=0,this.y=0,this.x=i,this.y=n}return e.prototype.clone=function(){return new e(this.x,this.y)},e.prototype.copyFrom=function(i){return this.set(i.x,i.y),this},e.prototype.copyTo=function(i){return i.set(this.x,this.y),i},e.prototype.equals=function(i){return i.x===this.x&&i.y===this.y},e.prototype.set=function(i,n){return i===void 0&&(i=0),n===void 0&&(n=i),this.x=i,this.y=n,this},e.prototype.toString=function(){return"[@pixi/math:Point x="+this.x+" y="+this.y+"]"},e}(),Ty=function(){function e(i,n,r,o){r===void 0&&(r=0),o===void 0&&(o=0),this._x=r,this._y=o,this.cb=i,this.scope=n}return e.prototype.clone=function(i,n){return i===void 0&&(i=this.cb),n===void 0&&(n=this.scope),new e(i,n,this._x,this._y)},e.prototype.set=function(i,n){return i===void 0&&(i=0),n===void 0&&(n=i),(this._x!==i||this._y!==n)&&(this._x=i,this._y=n,this.cb.call(this.scope)),this},e.prototype.copyFrom=function(i){return(this._x!==i.x||this._y!==i.y)&&(this._x=i.x,this._y=i.y,this.cb.call(this.scope)),this},e.prototype.copyTo=function(i){return i.set(this._x,this._y),i},e.prototype.equals=function(i){return i.x===this._x&&i.y===this._y},e.prototype.toString=function(){return"[@pixi/math:ObservablePoint x=0 y=0 scope="+this.scope+"]"},Object.defineProperty(e.prototype,"x",{get:function(){return this._x},set:function(i){this._x!==i&&(this._x=i,this.cb.call(this.scope))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},set:function(i){this._y!==i&&(this._y=i,this.cb.call(this.scope))},enumerable:!1,configurable:!0}),e}(),Zo=function(){function e(i,n,r,o,l,c){i===void 0&&(i=1),n===void 0&&(n=0),r===void 0&&(r=0),o===void 0&&(o=1),l===void 0&&(l=0),c===void 0&&(c=0),this.array=null,this.a=i,this.b=n,this.c=r,this.d=o,this.tx=l,this.ty=c}return e.prototype.fromArray=function(i){this.a=i[0],this.b=i[1],this.c=i[3],this.d=i[4],this.tx=i[2],this.ty=i[5]},e.prototype.set=function(i,n,r,o,l,c){return this.a=i,this.b=n,this.c=r,this.d=o,this.tx=l,this.ty=c,this},e.prototype.toArray=function(i,n){this.array||(this.array=new Float32Array(9));var r=n||this.array;return i?(r[0]=this.a,r[1]=this.b,r[2]=0,r[3]=this.c,r[4]=this.d,r[5]=0,r[6]=this.tx,r[7]=this.ty,r[8]=1):(r[0]=this.a,r[1]=this.c,r[2]=this.tx,r[3]=this.b,r[4]=this.d,r[5]=this.ty,r[6]=0,r[7]=0,r[8]=1),r},e.prototype.apply=function(i,n){n=n||new Co;var r=i.x,o=i.y;return n.x=this.a*r+this.c*o+this.tx,n.y=this.b*r+this.d*o+this.ty,n},e.prototype.applyInverse=function(i,n){n=n||new Co;var r=1/(this.a*this.d+this.c*-this.b),o=i.x,l=i.y;return n.x=this.d*r*o+-this.c*r*l+(this.ty*this.c-this.tx*this.d)*r,n.y=this.a*r*l+-this.b*r*o+(-this.ty*this.a+this.tx*this.b)*r,n},e.prototype.translate=function(i,n){return this.tx+=i,this.ty+=n,this},e.prototype.scale=function(i,n){return this.a*=i,this.d*=n,this.c*=i,this.b*=n,this.tx*=i,this.ty*=n,this},e.prototype.rotate=function(i){var n=Math.cos(i),r=Math.sin(i),o=this.a,l=this.c,c=this.tx;return this.a=o*n-this.b*r,this.b=o*r+this.b*n,this.c=l*n-this.d*r,this.d=l*r+this.d*n,this.tx=c*n-this.ty*r,this.ty=c*r+this.ty*n,this},e.prototype.append=function(i){var n=this.a,r=this.b,o=this.c,l=this.d;return this.a=i.a*n+i.b*o,this.b=i.a*r+i.b*l,this.c=i.c*n+i.d*o,this.d=i.c*r+i.d*l,this.tx=i.tx*n+i.ty*o+this.tx,this.ty=i.tx*r+i.ty*l+this.ty,this},e.prototype.setTransform=function(i,n,r,o,l,c,u,f,m){return this.a=Math.cos(u+m)*l,this.b=Math.sin(u+m)*l,this.c=-Math.sin(u-f)*c,this.d=Math.cos(u-f)*c,this.tx=i-(r*this.a+o*this.c),this.ty=n-(r*this.b+o*this.d),this},e.prototype.prepend=function(i){var n=this.tx;if(i.a!==1||i.b!==0||i.c!==0||i.d!==1){var r=this.a,o=this.c;this.a=r*i.a+this.b*i.c,this.b=r*i.b+this.b*i.d,this.c=o*i.a+this.d*i.c,this.d=o*i.b+this.d*i.d}return this.tx=n*i.a+this.ty*i.c+i.tx,this.ty=n*i.b+this.ty*i.d+i.ty,this},e.prototype.decompose=function(i){var n=this.a,r=this.b,o=this.c,l=this.d,c=i.pivot,u=-Math.atan2(-o,l),f=Math.atan2(r,n),m=Math.abs(u+f);return m<1e-5||Math.abs(CH-m)<1e-5?(i.rotation=f,i.skew.x=i.skew.y=0):(i.rotation=0,i.skew.x=u,i.skew.y=f),i.scale.x=Math.sqrt(n*n+r*r),i.scale.y=Math.sqrt(o*o+l*l),i.position.x=this.tx+(c.x*n+c.y*o),i.position.y=this.ty+(c.x*r+c.y*l),i},e.prototype.invert=function(){var i=this.a,n=this.b,r=this.c,o=this.d,l=this.tx,c=i*o-n*r;return this.a=o/c,this.b=-n/c,this.c=-r/c,this.d=i/c,this.tx=(r*this.ty-o*l)/c,this.ty=-(i*this.ty-n*l)/c,this},e.prototype.identity=function(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this},e.prototype.clone=function(){var i=new e;return i.a=this.a,i.b=this.b,i.c=this.c,i.d=this.d,i.tx=this.tx,i.ty=this.ty,i},e.prototype.copyTo=function(i){return i.a=this.a,i.b=this.b,i.c=this.c,i.d=this.d,i.tx=this.tx,i.ty=this.ty,i},e.prototype.copyFrom=function(i){return this.a=i.a,this.b=i.b,this.c=i.c,this.d=i.d,this.tx=i.tx,this.ty=i.ty,this},e.prototype.toString=function(){return"[@pixi/math:Matrix a="+this.a+" b="+this.b+" c="+this.c+" d="+this.d+" tx="+this.tx+" ty="+this.ty+"]"},Object.defineProperty(e,"IDENTITY",{get:function(){return new e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"TEMP_MATRIX",{get:function(){return new e},enumerable:!1,configurable:!0}),e}(),sy=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Iy=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],ly=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Cy=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Ene=[],JPe=[],GM=Math.sign;function A4t(){for(var e=0;e<16;e++){var i=[];Ene.push(i);for(var n=0;n<16;n++)for(var r=GM(sy[e]*sy[n]+ly[e]*Iy[n]),o=GM(Iy[e]*sy[n]+Cy[e]*Iy[n]),l=GM(sy[e]*ly[n]+ly[e]*Cy[n]),c=GM(Iy[e]*ly[n]+Cy[e]*Cy[n]),u=0;u<16;u++)if(sy[u]===r&&Iy[u]===o&&ly[u]===l&&Cy[u]===c){i.push(u);break}}for(var e=0;e<16;e++){var f=new Zo;f.set(sy[e],Iy[e],ly[e],Cy[e],0,0),JPe.push(f)}}A4t();var xg={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:function(e){return sy[e]},uY:function(e){return Iy[e]},vX:function(e){return ly[e]},vY:function(e){return Cy[e]},inv:function(e){return e&8?e&15:-e&7},add:function(e,i){return Ene[e][i]},sub:function(e,i){return Ene[e][xg.inv(i)]},rotate180:function(e){return e^4},isVertical:function(e){return(e&3)===2},byDirection:function(e,i){return Math.abs(e)*2<=Math.abs(i)?i>=0?xg.S:xg.N:Math.abs(i)*2<=Math.abs(e)?e>0?xg.E:xg.W:i>0?e>0?xg.SE:xg.SW:e>0?xg.NE:xg.NW},matrixAppendRotationInv:function(e,i,n,r){n===void 0&&(n=0),r===void 0&&(r=0);var o=JPe[xg.inv(i)];o.tx=n,o.ty=r,e.append(o)}},Wse=function(){function e(){this.worldTransform=new Zo,this.localTransform=new Zo,this.position=new Ty(this.onChange,this,0,0),this.scale=new Ty(this.onChange,this,1,1),this.pivot=new Ty(this.onChange,this,0,0),this.skew=new Ty(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}return e.prototype.onChange=function(){this._localID++},e.prototype.updateSkew=function(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++},e.prototype.toString=function(){return"[@pixi/math:Transform "+("position=("+this.position.x+", "+this.position.y+") ")+("rotation="+this.rotation+" ")+("scale=("+this.scale.x+", "+this.scale.y+") ")+("skew=("+this.skew.x+", "+this.skew.y+") ")+"]"},e.prototype.updateLocalTransform=function(){var i=this.localTransform;this._localID!==this._currentLocalID&&(i.a=this._cx*this.scale.x,i.b=this._sx*this.scale.x,i.c=this._cy*this.scale.y,i.d=this._sy*this.scale.y,i.tx=this.position.x-(this.pivot.x*i.a+this.pivot.y*i.c),i.ty=this.position.y-(this.pivot.x*i.b+this.pivot.y*i.d),this._currentLocalID=this._localID,this._parentID=-1)},e.prototype.updateTransform=function(i){var n=this.localTransform;if(this._localID!==this._currentLocalID&&(n.a=this._cx*this.scale.x,n.b=this._sx*this.scale.x,n.c=this._cy*this.scale.y,n.d=this._sy*this.scale.y,n.tx=this.position.x-(this.pivot.x*n.a+this.pivot.y*n.c),n.ty=this.position.y-(this.pivot.x*n.b+this.pivot.y*n.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==i._worldID){var r=i.worldTransform,o=this.worldTransform;o.a=n.a*r.a+n.b*r.c,o.b=n.a*r.b+n.b*r.d,o.c=n.c*r.a+n.d*r.c,o.d=n.c*r.b+n.d*r.d,o.tx=n.tx*r.a+n.ty*r.c+r.tx,o.ty=n.tx*r.b+n.ty*r.d+r.ty,this._parentID=i._worldID,this._worldID++}},e.prototype.setFromMatrix=function(i){i.decompose(this),this._localID++},Object.defineProperty(e.prototype,"rotation",{get:function(){return this._rotation},set:function(i){this._rotation!==i&&(this._rotation=i,this.updateSkew())},enumerable:!1,configurable:!0}),e.IDENTITY=new e,e}();/*! - * @pixi/display - v6.0.4 - * Compiled Tue, 11 May 2021 18:00:23 UTC - * - * @pixi/display is licensed under the MIT License. - * http://www.opensource.org/licenses/mit-license - */tn.SORTABLE_CHILDREN=!1;var cH=function(){function e(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}return e.prototype.isEmpty=function(){return this.minX>this.maxX||this.minY>this.maxY},e.prototype.clear=function(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0},e.prototype.getRectangle=function(i){return this.minX>this.maxX||this.minY>this.maxY?cr.EMPTY:(i=i||new cr(0,0,1,1),i.x=this.minX,i.y=this.minY,i.width=this.maxX-this.minX,i.height=this.maxY-this.minY,i)},e.prototype.addPoint=function(i){this.minX=Math.min(this.minX,i.x),this.maxX=Math.max(this.maxX,i.x),this.minY=Math.min(this.minY,i.y),this.maxY=Math.max(this.maxY,i.y)},e.prototype.addPointMatrix=function(i,n){var r=i.a,o=i.b,l=i.c,c=i.d,u=i.tx,f=i.ty,m=r*n.x+l*n.y+u,p=o*n.x+c*n.y+f;this.minX=Math.min(this.minX,m),this.maxX=Math.max(this.maxX,m),this.minY=Math.min(this.minY,p),this.maxY=Math.max(this.maxY,p)},e.prototype.addQuad=function(i){var n=this.minX,r=this.minY,o=this.maxX,l=this.maxY,c=i[0],u=i[1];n=co?c:o,l=u>l?u:l,c=i[2],u=i[3],n=co?c:o,l=u>l?u:l,c=i[4],u=i[5],n=co?c:o,l=u>l?u:l,c=i[6],u=i[7],n=co?c:o,l=u>l?u:l,this.minX=n,this.minY=r,this.maxX=o,this.maxY=l},e.prototype.addFrame=function(i,n,r,o,l){this.addFrameMatrix(i.worldTransform,n,r,o,l)},e.prototype.addFrameMatrix=function(i,n,r,o,l){var c=i.a,u=i.b,f=i.c,m=i.d,p=i.tx,v=i.ty,B=this.minX,G=this.minY,T=this.maxX,V=this.maxY,E=c*n+f*r+p,W=u*n+m*r+v;B=ET?E:T,V=W>V?W:V,E=c*o+f*r+p,W=u*o+m*r+v,B=ET?E:T,V=W>V?W:V,E=c*n+f*l+p,W=u*n+m*l+v,B=ET?E:T,V=W>V?W:V,E=c*o+f*l+p,W=u*o+m*l+v,B=ET?E:T,V=W>V?W:V,this.minX=B,this.minY=G,this.maxX=T,this.maxY=V},e.prototype.addVertexData=function(i,n,r){for(var o=this.minX,l=this.minY,c=this.maxX,u=this.maxY,f=n;fc?m:c,u=p>u?p:u}this.minX=o,this.minY=l,this.maxX=c,this.maxY=u},e.prototype.addVertices=function(i,n,r,o){this.addVerticesMatrix(i.worldTransform,n,r,o)},e.prototype.addVerticesMatrix=function(i,n,r,o,l,c){l===void 0&&(l=0),c===void 0&&(c=l);for(var u=i.a,f=i.b,m=i.c,p=i.d,v=i.tx,B=i.ty,G=this.minX,T=this.minY,V=this.maxX,E=this.maxY,W=r;Wo?i.maxX:o,this.maxY=i.maxY>l?i.maxY:l},e.prototype.addBoundsMask=function(i,n){var r=i.minX>n.minX?i.minX:n.minX,o=i.minY>n.minY?i.minY:n.minY,l=i.maxXm?l:m,this.maxY=c>p?c:p}},e.prototype.addBoundsMatrix=function(i,n){this.addFrameMatrix(n,i.minX,i.minY,i.maxX,i.maxY)},e.prototype.addBoundsArea=function(i,n){var r=i.minX>n.x?i.minX:n.x,o=i.minY>n.y?i.minY:n.y,l=i.maxXm?l:m,this.maxY=c>p?c:p}},e.prototype.pad=function(i,n){i===void 0&&(i=0),n===void 0&&(n=i),this.isEmpty()||(this.minX-=i,this.maxX+=i,this.minY-=n,this.maxY+=n)},e.prototype.addFramePad=function(i,n,r,o,l,c){i-=l,n-=c,r+=l,o+=c,this.minX=this.minXr?this.maxX:r,this.minY=this.minYo?this.maxY:o},e}();/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */var Hne=function(e,i){return Hne=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)r.hasOwnProperty(o)&&(n[o]=r[o])},Hne(e,i)};function Nse(e,i){Hne(e,i);function n(){this.constructor=e}e.prototype=i===null?Object.create(i):(n.prototype=i.prototype,new n)}var Bo=function(e){Nse(i,e);function i(){var n=e.call(this)||this;return n.tempDisplayObjectParent=null,n.transform=new Wse,n.alpha=1,n.visible=!0,n.renderable=!0,n.parent=null,n.worldAlpha=1,n._lastSortedIndex=0,n._zIndex=0,n.filterArea=null,n.filters=null,n._enabledFilters=null,n._bounds=new cH,n._localBounds=null,n._boundsID=0,n._boundsRect=null,n._localBoundsRect=null,n._mask=null,n._destroyed=!1,n.isSprite=!1,n.isMask=!1,n}return i.mixin=function(n){for(var r=Object.keys(n),o=0;o1)for(var l=0;lthis.children.length)throw new Error(n+"addChildAt: The index "+r+" supplied is out of bounds "+this.children.length);return n.parent&&n.parent.removeChild(n),n.parent=this,this.sortDirty=!0,n.transform._parentID=-1,this.children.splice(r,0,n),this._boundsID++,this.onChildrenChange(r),n.emit("added",this),this.emit("childAdded",n,this,r),n},i.prototype.swapChildren=function(n,r){if(n!==r){var o=this.getChildIndex(n),l=this.getChildIndex(r);this.children[o]=r,this.children[l]=n,this.onChildrenChange(o=this.children.length)throw new Error("The index "+r+" supplied is out of bounds "+this.children.length);var o=this.getChildIndex(n);Dy(this.children,o,1),this.children.splice(r,0,n),this.onChildrenChange(r)},i.prototype.getChildAt=function(n){if(n<0||n>=this.children.length)throw new Error("getChildAt: Index ("+n+") does not exist.");return this.children[n]},i.prototype.removeChild=function(){for(var n=arguments,r=[],o=0;o1)for(var l=0;l0&&c<=l){u=this.children.splice(o,c);for(var f=0;f1&&this.children.sort(u4t),this.sortDirty=!1},i.prototype.updateTransform=function(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(var n=0,r=this.children.length;n title : "+i.title+"
tabIndex: "+i.tabIndex},e.prototype.capHitArea=function(i){i.x<0&&(i.width+=i.x,i.x=0),i.y<0&&(i.height+=i.y,i.y=0);var n=this.renderer,r=n.width,o=n.height;i.x+i.width>r&&(i.width=r-i.x),i.y+i.height>o&&(i.height=o-i.y)},e.prototype.addChild=function(i){var n=this.pool.pop();n||(n=document.createElement("button"),n.style.width=SM+"px",n.style.height=SM+"px",n.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",n.style.position="absolute",n.style.zIndex=dNe.toString(),n.style.borderStyle="none",navigator.userAgent.toLowerCase().indexOf("chrome")>-1?n.setAttribute("aria-live","off"):n.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?n.setAttribute("aria-relevant","additions"):n.setAttribute("aria-relevant","text"),n.addEventListener("click",this._onClick.bind(this)),n.addEventListener("focus",this._onFocus.bind(this)),n.addEventListener("focusout",this._onFocusOut.bind(this))),n.style.pointerEvents=i.accessiblePointerEvents,n.type=i.accessibleType,i.accessibleTitle&&i.accessibleTitle!==null?n.title=i.accessibleTitle:(!i.accessibleHint||i.accessibleHint===null)&&(n.title="displayObject "+i.tabIndex),i.accessibleHint&&i.accessibleHint!==null&&n.setAttribute("aria-label",i.accessibleHint),this.debug&&this.updateDebugHTML(n),i._accessibleActive=!0,i._accessibleDiv=n,n.displayObject=i,this.children.push(i),this.div.appendChild(i._accessibleDiv),i._accessibleDiv.tabIndex=i.tabIndex},e.prototype._onClick=function(i){var n=this.renderer.plugins.interaction,r=i.target.displayObject,o=n.eventData;n.dispatchEvent(r,"click",o),n.dispatchEvent(r,"pointertap",o),n.dispatchEvent(r,"tap",o)},e.prototype._onFocus=function(i){i.target.getAttribute("aria-live")||i.target.setAttribute("aria-live","assertive");var n=this.renderer.plugins.interaction,r=i.target.displayObject,o=n.eventData;n.dispatchEvent(r,"mouseover",o)},e.prototype._onFocusOut=function(i){i.target.getAttribute("aria-live")||i.target.setAttribute("aria-live","polite");var n=this.renderer.plugins.interaction,r=i.target.displayObject,o=n.eventData;n.dispatchEvent(r,"mouseout",o)},e.prototype._onKeyDown=function(i){i.keyCode===d4t&&this.activate()},e.prototype._onMouseMove=function(i){i.movementX===0&&i.movementY===0||this.deactivate()},e.prototype.destroy=function(){this.destroyTouchHook(),this.div=null,self.document.removeEventListener("mousemove",this._onMouseMove,!0),self.removeEventListener("keydown",this._onKeyDown),this.pool=null,this.children=null,this.renderer=null},e}();/*! - * @pixi/ticker - v6.0.4 - * Compiled Tue, 11 May 2021 18:00:23 UTC - * - * @pixi/ticker is licensed under the MIT License. - * http://www.opensource.org/licenses/mit-license - */tn.TARGET_FPMS=.06;var ad;(function(e){e[e.INTERACTION=50]="INTERACTION",e[e.HIGH=25]="HIGH",e[e.NORMAL=0]="NORMAL",e[e.LOW=-25]="LOW",e[e.UTILITY=-50]="UTILITY"})(ad||(ad={}));var fq=function(){function e(i,n,r,o){n===void 0&&(n=null),r===void 0&&(r=0),o===void 0&&(o=!1),this.next=null,this.previous=null,this._destroyed=!1,this.fn=i,this.context=n,this.priority=r,this.once=o}return e.prototype.match=function(i,n){return n===void 0&&(n=null),this.fn===i&&this.context===n},e.prototype.emit=function(i){this.fn&&(this.context?this.fn.call(this.context,i):this.fn(i));var n=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),n},e.prototype.connect=function(i){this.previous=i,i.next&&(i.next.previous=this),this.next=i.next,i.next=this},e.prototype.destroy=function(i){i===void 0&&(i=!1),this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);var n=this.next;return this.next=i?null:n,this.previous=null,n},e}(),aa=function(){function e(){var i=this;this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new fq(null,null,1/0),this.deltaMS=1/tn.TARGET_FPMS,this.elapsedMS=1/tn.TARGET_FPMS,this._tick=function(n){i._requestId=null,i.started&&(i.update(n),i.started&&i._requestId===null&&i._head.next&&(i._requestId=requestAnimationFrame(i._tick)))}}return e.prototype._requestIfNeeded=function(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))},e.prototype._cancelIfNeeded=function(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)},e.prototype._startIfPossible=function(){this.started?this._requestIfNeeded():this.autoStart&&this.start()},e.prototype.add=function(i,n,r){return r===void 0&&(r=ad.NORMAL),this._addListener(new fq(i,n,r))},e.prototype.addOnce=function(i,n,r){return r===void 0&&(r=ad.NORMAL),this._addListener(new fq(i,n,r,!0))},e.prototype._addListener=function(i){var n=this._head.next,r=this._head;if(!n)i.connect(r);else{for(;n;){if(i.priority>n.priority){i.connect(r);break}r=n,n=n.next}i.previous||i.connect(r)}return this._startIfPossible(),this},e.prototype.remove=function(i,n){for(var r=this._head.next;r;)r.match(i,n)?r=r.destroy():r=r.next;return this._head.next||this._cancelIfNeeded(),this},Object.defineProperty(e.prototype,"count",{get:function(){if(!this._head)return 0;for(var i=0,n=this._head;n=n.next;)i++;return i},enumerable:!1,configurable:!0}),e.prototype.start=function(){this.started||(this.started=!0,this._requestIfNeeded())},e.prototype.stop=function(){this.started&&(this.started=!1,this._cancelIfNeeded())},e.prototype.destroy=function(){if(!this._protected){this.stop();for(var i=this._head.next;i;)i=i.destroy(!0);this._head.destroy(),this._head=null}},e.prototype.update=function(i){i===void 0&&(i=performance.now());var n;if(i>this.lastTime){if(n=this.elapsedMS=i-this.lastTime,n>this._maxElapsedMS&&(n=this._maxElapsedMS),n*=this.speed,this._minElapsedMS){var r=i-this._lastFrame|0;if(r=0;v--){var B=p[v],G=this.recursiveFindHit(i,B,r,o,f);if(G){if(!B.parent)continue;f=!1,G&&(i.target&&(o=!1),u=!0)}}return l&&(o&&!i.target&&!n.hitArea&&n.containsPoint&&n.containsPoint(c)&&(u=!0),n.interactive&&(u&&!i.target&&(i.target=n),r&&r(i,n,!!u))),u},e.prototype.findHit=function(i,n,r,o){this.recursiveFindHit(i,n,r,o,!1)},e}(),qPe={interactive:!1,interactiveChildren:!0,hitArea:null,get buttonMode(){return this.cursor==="pointer"},set buttonMode(e){e?this.cursor="pointer":this.cursor==="pointer"&&(this.cursor=null)},cursor:null,get trackedPointers(){return this._trackedPointers===void 0&&(this._trackedPointers={}),this._trackedPointers},_trackedPointers:void 0};Bo.mixin(qPe);var wM=1,TM={target:null,data:{global:null}},eze=function(e){y4t(i,e);function i(n,r){var o=e.call(this)||this;return r=r||{},o.renderer=n,o.autoPreventDefault=r.autoPreventDefault!==void 0?r.autoPreventDefault:!0,o.interactionFrequency=r.interactionFrequency||10,o.mouse=new Wne,o.mouse.identifier=wM,o.mouse.global.set(-999999),o.activeInteractionData={},o.activeInteractionData[wM]=o.mouse,o.interactionDataPool=[],o.eventData=new $Pe,o.interactionDOMElement=null,o.moveWhenInside=!1,o.eventsAdded=!1,o.tickerAdded=!1,o.mouseOverRenderer=!("PointerEvent"in self),o.supportsTouchEvents="ontouchstart"in self,o.supportsPointerEvents=!!self.PointerEvent,o.onPointerUp=o.onPointerUp.bind(o),o.processPointerUp=o.processPointerUp.bind(o),o.onPointerCancel=o.onPointerCancel.bind(o),o.processPointerCancel=o.processPointerCancel.bind(o),o.onPointerDown=o.onPointerDown.bind(o),o.processPointerDown=o.processPointerDown.bind(o),o.onPointerMove=o.onPointerMove.bind(o),o.processPointerMove=o.processPointerMove.bind(o),o.onPointerOut=o.onPointerOut.bind(o),o.processPointerOverOut=o.processPointerOverOut.bind(o),o.onPointerOver=o.onPointerOver.bind(o),o.cursorStyles={default:"inherit",pointer:"pointer"},o.currentCursorMode=null,o.cursor=null,o.resolution=1,o.delayedEvents=[],o.search=new v4t,o._tempDisplayObject=new kse,o._useSystemTicker=r.useSystemTicker!==void 0?r.useSystemTicker:!0,o.setTargetElement(o.renderer.view,o.renderer.resolution),o}return Object.defineProperty(i.prototype,"useSystemTicker",{get:function(){return this._useSystemTicker},set:function(n){this._useSystemTicker=n,n?this.addTickerListener():this.removeTickerListener()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"lastObjectRendered",{get:function(){return this.renderer._lastObjectRendered||this._tempDisplayObject},enumerable:!1,configurable:!0}),i.prototype.hitTest=function(n,r){return TM.target=null,TM.data.global=n,r||(r=this.lastObjectRendered),this.processInteractive(TM,r,null,!0),TM.target},i.prototype.setTargetElement=function(n,r){r===void 0&&(r=1),this.removeTickerListener(),this.removeEvents(),this.interactionDOMElement=n,this.resolution=r,this.addEvents(),this.addTickerListener()},i.prototype.addTickerListener=function(){this.tickerAdded||!this.interactionDOMElement||!this._useSystemTicker||(aa.system.add(this.tickerUpdate,this,ad.INTERACTION),this.tickerAdded=!0)},i.prototype.removeTickerListener=function(){this.tickerAdded&&(aa.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)},i.prototype.addEvents=function(){if(!(this.eventsAdded||!this.interactionDOMElement)){var n=this.interactionDOMElement.style;self.navigator.msPointerEnabled?(n.msContentZooming="none",n.msTouchAction="none"):this.supportsPointerEvents&&(n.touchAction="none"),this.supportsPointerEvents?(self.document.addEventListener("pointermove",this.onPointerMove,!0),this.interactionDOMElement.addEventListener("pointerdown",this.onPointerDown,!0),this.interactionDOMElement.addEventListener("pointerleave",this.onPointerOut,!0),this.interactionDOMElement.addEventListener("pointerover",this.onPointerOver,!0),self.addEventListener("pointercancel",this.onPointerCancel,!0),self.addEventListener("pointerup",this.onPointerUp,!0)):(self.document.addEventListener("mousemove",this.onPointerMove,!0),this.interactionDOMElement.addEventListener("mousedown",this.onPointerDown,!0),this.interactionDOMElement.addEventListener("mouseout",this.onPointerOut,!0),this.interactionDOMElement.addEventListener("mouseover",this.onPointerOver,!0),self.addEventListener("mouseup",this.onPointerUp,!0)),this.supportsTouchEvents&&(this.interactionDOMElement.addEventListener("touchstart",this.onPointerDown,!0),this.interactionDOMElement.addEventListener("touchcancel",this.onPointerCancel,!0),this.interactionDOMElement.addEventListener("touchend",this.onPointerUp,!0),this.interactionDOMElement.addEventListener("touchmove",this.onPointerMove,!0)),this.eventsAdded=!0}},i.prototype.removeEvents=function(){if(!(!this.eventsAdded||!this.interactionDOMElement)){var n=this.interactionDOMElement.style;self.navigator.msPointerEnabled?(n.msContentZooming="",n.msTouchAction=""):this.supportsPointerEvents&&(n.touchAction=""),this.supportsPointerEvents?(self.document.removeEventListener("pointermove",this.onPointerMove,!0),this.interactionDOMElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.interactionDOMElement.removeEventListener("pointerleave",this.onPointerOut,!0),this.interactionDOMElement.removeEventListener("pointerover",this.onPointerOver,!0),self.removeEventListener("pointercancel",this.onPointerCancel,!0),self.removeEventListener("pointerup",this.onPointerUp,!0)):(self.document.removeEventListener("mousemove",this.onPointerMove,!0),this.interactionDOMElement.removeEventListener("mousedown",this.onPointerDown,!0),this.interactionDOMElement.removeEventListener("mouseout",this.onPointerOut,!0),this.interactionDOMElement.removeEventListener("mouseover",this.onPointerOver,!0),self.removeEventListener("mouseup",this.onPointerUp,!0)),this.supportsTouchEvents&&(this.interactionDOMElement.removeEventListener("touchstart",this.onPointerDown,!0),this.interactionDOMElement.removeEventListener("touchcancel",this.onPointerCancel,!0),this.interactionDOMElement.removeEventListener("touchend",this.onPointerUp,!0),this.interactionDOMElement.removeEventListener("touchmove",this.onPointerMove,!0)),this.interactionDOMElement=null,this.eventsAdded=!1}},i.prototype.tickerUpdate=function(n){this._deltaTime+=n,!(this._deltaTime"u"&&(c.button=n.touches.length?1:0),typeof c.buttons>"u"&&(c.buttons=n.touches.length?1:0),typeof c.isPrimary>"u"&&(c.isPrimary=n.touches.length===1&&n.type==="touchstart"),typeof c.width>"u"&&(c.width=c.radiusX||1),typeof c.height>"u"&&(c.height=c.radiusY||1),typeof c.tiltX>"u"&&(c.tiltX=0),typeof c.tiltY>"u"&&(c.tiltY=0),typeof c.pointerType>"u"&&(c.pointerType="touch"),typeof c.pointerId>"u"&&(c.pointerId=c.identifier||0),typeof c.pressure>"u"&&(c.pressure=c.force||.5),typeof c.twist>"u"&&(c.twist=0),typeof c.tangentialPressure>"u"&&(c.tangentialPressure=0),typeof c.layerX>"u"&&(c.layerX=c.offsetX=c.clientX),typeof c.layerY>"u"&&(c.layerY=c.offsetY=c.clientY),c.isNormalized=!0,r.push(c)}else if(!self.MouseEvent||n instanceof MouseEvent&&(!this.supportsPointerEvents||!(n instanceof self.PointerEvent))){var u=n;typeof u.isPrimary>"u"&&(u.isPrimary=!0),typeof u.width>"u"&&(u.width=1),typeof u.height>"u"&&(u.height=1),typeof u.tiltX>"u"&&(u.tiltX=0),typeof u.tiltY>"u"&&(u.tiltY=0),typeof u.pointerType>"u"&&(u.pointerType="mouse"),typeof u.pointerId>"u"&&(u.pointerId=wM),typeof u.pressure>"u"&&(u.pressure=.5),typeof u.twist>"u"&&(u.twist=0),typeof u.tangentialPressure>"u"&&(u.tangentialPressure=0),u.isNormalized=!0,r.push(u)}else r.push(n);return r},i.prototype.destroy=function(){this.removeEvents(),this.removeTickerListener(),this.removeAllListeners(),this.renderer=null,this.mouse=null,this.eventData=null,this.interactionDOMElement=null,this.onPointerDown=null,this.processPointerDown=null,this.onPointerUp=null,this.processPointerUp=null,this.onPointerCancel=null,this.processPointerCancel=null,this.onPointerMove=null,this.processPointerMove=null,this.onPointerOut=null,this.processPointerOverOut=null,this.onPointerOver=null,this.search=null},i}(Gw);/*! - * @pixi/runner - v6.0.4 - * Compiled Tue, 11 May 2021 18:00:23 UTC - * - * @pixi/runner is licensed under the MIT License. - * http://www.opensource.org/licenses/mit-license - */var Wa=function(){function e(i){this.items=[],this._name=i,this._aliasCount=0}return e.prototype.emit=function(i,n,r,o,l,c,u,f){if(arguments.length>8)throw new Error("max arguments reached");var m=this,p=m.name,v=m.items;this._aliasCount++;for(var B=0,G=v.length;B0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))},e.prototype.add=function(i){return i[this._name]&&(this.ensureNonAliasedItems(),this.remove(i),this.items.push(i)),this},e.prototype.remove=function(i){var n=this.items.indexOf(i);return n!==-1&&(this.ensureNonAliasedItems(),this.items.splice(n,1)),this},e.prototype.contains=function(i){return this.items.indexOf(i)!==-1},e.prototype.removeAll=function(){return this.ensureNonAliasedItems(),this.items.length=0,this},e.prototype.destroy=function(){this.removeAll(),this.items=null,this._name=null},Object.defineProperty(e.prototype,"empty",{get:function(){return this.items.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),e}();Object.defineProperties(Wa.prototype,{dispatch:{value:Wa.prototype.emit},run:{value:Wa.prototype.emit}});/*! - * @pixi/core - v6.0.4 - * Compiled Tue, 11 May 2021 18:00:23 UTC - * - * @pixi/core is licensed under the MIT License. - * http://www.opensource.org/licenses/mit-license - */tn.PREFER_ENV=EC.any?gd.WEBGL:gd.WEBGL2;tn.STRICT_TEXTURE_CACHE=!1;var AH=[];function AP(e,i){if(!e)return null;var n="";if(typeof e=="string"){var r=/\.(\w{3,4})(?:$|\?|#)/i.exec(e);r&&(n=r[1].toLowerCase())}for(var o=AH.length-1;o>=0;--o){var l=AH[o];if(l.test&&l.test(e,n))return new l(e,i)}throw new Error("Unrecognized source type to auto-detect Resource")}/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */var kne=function(e,i){return kne=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)r.hasOwnProperty(o)&&(n[o]=r[o])},kne(e,i)};function Dn(e,i){kne(e,i);function n(){this.constructor=e}e.prototype=i===null?Object.create(i):(n.prototype=i.prototype,new n)}var Cv=function(){function e(i,n){i===void 0&&(i=0),n===void 0&&(n=0),this._width=i,this._height=n,this.destroyed=!1,this.internal=!1,this.onResize=new Wa("setRealSize"),this.onUpdate=new Wa("update"),this.onError=new Wa("onError")}return e.prototype.bind=function(i){this.onResize.add(i),this.onUpdate.add(i),this.onError.add(i),(this._width||this._height)&&this.onResize.emit(this._width,this._height)},e.prototype.unbind=function(i){this.onResize.remove(i),this.onUpdate.remove(i),this.onError.remove(i)},e.prototype.resize=function(i,n){(i!==this._width||n!==this._height)&&(this._width=i,this._height=n,this.onResize.emit(i,n))},Object.defineProperty(e.prototype,"valid",{get:function(){return!!this._width&&!!this._height},enumerable:!1,configurable:!0}),e.prototype.update=function(){this.destroyed||this.onUpdate.emit()},e.prototype.load=function(){return Promise.resolve(this)},Object.defineProperty(e.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),e.prototype.style=function(i,n,r){return!1},e.prototype.dispose=function(){},e.prototype.destroy=function(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)},e.test=function(i,n){return!1},e}(),Sw=function(e){Dn(i,e);function i(n,r){var o=this,l=r||{},c=l.width,u=l.height;if(!c||!u)throw new Error("BufferResource width or height invalid");return o=e.call(this,c,u)||this,o.data=n,o}return i.prototype.upload=function(n,r,o){var l=n.gl;l.pixelStorei(l.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.alphaMode===od.UNPACK);var c=r.realWidth,u=r.realHeight;return o.width===c&&o.height===u?l.texSubImage2D(r.target,0,0,0,c,u,r.format,r.type,this.data):(o.width=c,o.height=u,l.texImage2D(r.target,0,o.internalFormat,c,u,0,r.format,o.type,this.data)),!0},i.prototype.dispose=function(){this.data=null},i.test=function(n){return n instanceof Float32Array||n instanceof Uint8Array||n instanceof Uint32Array},i}(Cv),Z4t={scaleMode:Yu.NEAREST,format:tA.RGBA,alphaMode:od.NPM},Lr=function(e){Dn(i,e);function i(n,r){n===void 0&&(n=null),r===void 0&&(r=null);var o=e.call(this)||this;r=r||{};var l=r.alphaMode,c=r.mipmap,u=r.anisotropicLevel,f=r.scaleMode,m=r.width,p=r.height,v=r.wrapMode,B=r.format,G=r.type,T=r.target,V=r.resolution,E=r.resourceOptions;return n&&!(n instanceof Cv)&&(n=AP(n,E),n.internal=!0),o.width=m||0,o.height=p||0,o.resolution=V||tn.RESOLUTION,o.mipmap=c!==void 0?c:tn.MIPMAP_TEXTURES,o.anisotropicLevel=u!==void 0?u:tn.ANISOTROPIC_LEVEL,o.wrapMode=v||tn.WRAP_MODE,o.scaleMode=f!==void 0?f:tn.SCALE_MODE,o.format=B||tA.RGBA,o.type=G||Ur.UNSIGNED_BYTE,o.target=T||Zp.TEXTURE_2D,o.alphaMode=l!==void 0?l:od.UNPACK,o.uid=Iv(),o.touched=0,o.isPowerOfTwo=!1,o._refreshPOT(),o._glTextures={},o.dirtyId=0,o.dirtyStyleId=0,o.cacheId=null,o.valid=m>0&&p>0,o.textureCacheIds=[],o.destroyed=!1,o.resource=null,o._batchEnabled=0,o._batchLocation=0,o.parentTextureArray=null,o.setResource(n),o}return Object.defineProperty(i.prototype,"realWidth",{get:function(){return Math.ceil(this.width*this.resolution-1e-4)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"realHeight",{get:function(){return Math.ceil(this.height*this.resolution-1e-4)},enumerable:!1,configurable:!0}),i.prototype.setStyle=function(n,r){var o;return n!==void 0&&n!==this.scaleMode&&(this.scaleMode=n,o=!0),r!==void 0&&r!==this.mipmap&&(this.mipmap=r,o=!0),o&&this.dirtyStyleId++,this},i.prototype.setSize=function(n,r,o){return this.resolution=o||this.resolution,this.width=n,this.height=r,this._refreshPOT(),this.update(),this},i.prototype.setRealSize=function(n,r,o){return this.resolution=o||this.resolution,this.width=n/this.resolution,this.height=r/this.resolution,this._refreshPOT(),this.update(),this},i.prototype._refreshPOT=function(){this.isPowerOfTwo=wne(this.realWidth)&&wne(this.realHeight)},i.prototype.setResolution=function(n){var r=this.resolution;return r===n?this:(this.resolution=n,this.valid&&(this.width=this.width*r/n,this.height=this.height*r/n,this.emit("update",this)),this._refreshPOT(),this)},i.prototype.setResource=function(n){if(this.resource===n)return this;if(this.resource)throw new Error("Resource can be set only once");return n.bind(this),this.resource=n,this},i.prototype.update=function(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))},i.prototype.onError=function(n){this.emit("error",this,n)},i.prototype.destroy=function(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete SC[this.cacheId],delete KI[this.cacheId],this.cacheId=null),this.dispose(),i.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0},i.prototype.dispose=function(){this.emit("dispose",this)},i.prototype.castToBaseTexture=function(){return this},i.from=function(n,r,o){o===void 0&&(o=tn.STRICT_TEXTURE_CACHE);var l=typeof n=="string",c=null;if(l)c=n;else{if(!n._pixiId){var u=r&&r.pixiIdPrefix||"pixiid";n._pixiId=u+"_"+Iv()}c=n._pixiId}var f=SC[c];if(l&&o&&!f)throw new Error('The cacheId "'+c+'" does not exist in BaseTextureCache.');return f||(f=new i(n,r),f.cacheId=c,i.addToCache(f,c)),f},i.fromBuffer=function(n,r,o,l){n=n||new Float32Array(r*o*4);var c=new Sw(n,{width:r,height:o}),u=n instanceof Float32Array?Ur.FLOAT:Ur.UNSIGNED_BYTE;return new i(c,Object.assign(Z4t,l||{width:r,height:o,type:u}))},i.addToCache=function(n,r){r&&(n.textureCacheIds.indexOf(r)===-1&&n.textureCacheIds.push(r),SC[r]&&console.warn("BaseTexture added to the cache with an id ["+r+"] that already had an entry"),SC[r]=n)},i.removeFromCache=function(n){if(typeof n=="string"){var r=SC[n];if(r){var o=r.textureCacheIds.indexOf(n);return o>-1&&r.textureCacheIds.splice(o,1),delete SC[n],r}}else if(n&&n.textureCacheIds){for(var l=0;l0)if(n.resource)this.addResourceAt(n.resource,r);else throw new Error("CubeResource does not support copying of renderTexture.");else n.target=Zp.TEXTURE_CUBE_MAP_POSITIVE_X+r,n.parentTextureArray=this.baseTexture,this.items[r]=n;return n.valid&&!this.valid&&this.resize(n.realWidth,n.realHeight),this.items[r]=n,this},i.prototype.upload=function(n,r,o){for(var l=this.itemDirtyIds,c=0;c]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i,i}(sd),Mse=function(e){Dn(i,e);function i(n,r){var o=this;if(r=r||{},!(n instanceof HTMLVideoElement)){var l=document.createElement("video");l.setAttribute("preload","auto"),l.setAttribute("webkit-playsinline",""),l.setAttribute("playsinline",""),typeof n=="string"&&(n=[n]);var c=n[0].src||n[0];sd.crossOrigin(l,c,r.crossorigin);for(var u=0;u0&&n.paused===!1&&n.ended===!1&&n.readyState>2},i.prototype._isSourceReady=function(){var n=this.source;return n.readyState===3||n.readyState===4},i.prototype._onPlayStart=function(){this.valid||this._onCanPlay(),this.autoUpdate&&!this._isConnectedToTicker&&(aa.shared.add(this.update,this),this._isConnectedToTicker=!0)},i.prototype._onPlayStop=function(){this._isConnectedToTicker&&(aa.shared.remove(this.update,this),this._isConnectedToTicker=!1)},i.prototype._onCanPlay=function(){var n=this.source;n.removeEventListener("canplay",this._onCanPlay),n.removeEventListener("canplaythrough",this._onCanPlay);var r=this.valid;this.resize(n.videoWidth,n.videoHeight),!r&&this._resolve&&(this._resolve(this),this._resolve=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&n.play()},i.prototype.dispose=function(){this._isConnectedToTicker&&aa.shared.remove(this.update,this);var n=this.source;n&&(n.removeEventListener("error",this._onError,!0),n.pause(),n.src="",n.load()),e.prototype.dispose.call(this)},Object.defineProperty(i.prototype,"autoUpdate",{get:function(){return this._autoUpdate},set:function(n){n!==this._autoUpdate&&(this._autoUpdate=n,!this._autoUpdate&&this._isConnectedToTicker?(aa.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._isSourcePlaying()&&(aa.shared.add(this.update,this),this._isConnectedToTicker=!0))},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"updateFPS",{get:function(){return this._updateFPS},set:function(n){n!==this._updateFPS&&(this._updateFPS=n)},enumerable:!1,configurable:!0}),i.test=function(n,r){return self.HTMLVideoElement&&n instanceof HTMLVideoElement||i.TYPES.indexOf(r)>-1},i.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],i.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"},i}(sd),Fse=function(e){Dn(i,e);function i(n){return e.call(this,n)||this}return i.test=function(n){return!!self.createImageBitmap&&n instanceof ImageBitmap},i}(sd);AH.push(hP,Fse,dP,Mse,Dse,Sw,xse,Xse);var tze={__proto__:null,Resource:Cv,BaseImageResource:sd,INSTALLED:AH,autoDetectResource:AP,AbstractMultiResource:uP,ArrayResource:Xse,BufferResource:Sw,CanvasResource:dP,CubeResource:xse,ImageResource:hP,SVGResource:Dse,VideoResource:Mse,ImageBitmapResource:Fse},ul=function(){function e(i){this.renderer=i}return e.prototype.destroy=function(){this.renderer=null},e}(),B4t=function(e){Dn(i,e);function i(){return e!==null&&e.apply(this,arguments)||this}return i.prototype.upload=function(n,r,o){var l=n.gl;l.pixelStorei(l.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.alphaMode===od.UNPACK);var c=r.realWidth,u=r.realHeight;return o.width===c&&o.height===u?l.texSubImage2D(r.target,0,0,0,c,u,r.format,r.type,this.data):(o.width=c,o.height=u,l.texImage2D(r.target,0,n.context.webGLVersion===1?l.DEPTH_COMPONENT:l.DEPTH_COMPONENT16,c,u,0,r.format,r.type,this.data)),!0},i}(Sw),BK=function(){function e(i,n){this.width=Math.ceil(i||100),this.height=Math.ceil(n||100),this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new Wa("disposeFramebuffer"),this.multisample=av.NONE}return Object.defineProperty(e.prototype,"colorTexture",{get:function(){return this.colorTextures[0]},enumerable:!1,configurable:!0}),e.prototype.addColorTexture=function(i,n){return i===void 0&&(i=0),this.colorTextures[i]=n||new Lr(null,{scaleMode:Yu.NEAREST,resolution:1,mipmap:gf.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this},e.prototype.addDepthTexture=function(i){return this.depthTexture=i||new Lr(new B4t(null,{width:this.width,height:this.height}),{scaleMode:Yu.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:gf.OFF,format:tA.DEPTH_COMPONENT,type:Ur.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this},e.prototype.enableDepth=function(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this},e.prototype.enableStencil=function(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this},e.prototype.resize=function(i,n){if(i=Math.ceil(i),n=Math.ceil(n),!(i===this.width&&n===this.height)){this.width=i,this.height=n,this.dirtyId++,this.dirtySize++;for(var r=0;r-1&&r.textureCacheIds.splice(o,1),delete KI[n],r}}else if(n&&n.textureCacheIds){for(var l=0;lthis.baseTexture.width,f=o+c>this.baseTexture.height;if(u||f){var m=u&&f?"and":"or",p="X: "+r+" + "+l+" = "+(r+l)+" > "+this.baseTexture.width,v="Y: "+o+" + "+c+" = "+(o+c)+" > "+this.baseTexture.height;throw new Error("Texture Error: frame does not fit inside the base Texture dimensions: "+(p+" "+m+" "+v))}this.valid=l&&c&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=n),this.valid&&this.updateUvs()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"rotate",{get:function(){return this._rotate},set:function(n){this._rotate=n,this.valid&&this.updateUvs()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"width",{get:function(){return this.orig.width},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this.orig.height},enumerable:!1,configurable:!0}),i.prototype.castToBaseTexture=function(){return this.baseTexture},i}(Gw);function G4t(){var e=document.createElement("canvas");e.width=16,e.height=16;var i=e.getContext("2d");return i.fillStyle="white",i.fillRect(0,0,16,16),new hn(new Lr(new dP(e)))}function fP(e){e.destroy=function(){},e.on=function(){},e.once=function(){},e.emit=function(){}}hn.EMPTY=new hn(new Lr);fP(hn.EMPTY);fP(hn.EMPTY.baseTexture);hn.WHITE=G4t();fP(hn.WHITE);fP(hn.WHITE.baseTexture);var of=function(e){Dn(i,e);function i(n,r){var o=e.call(this,n,r)||this;return o.valid=!0,o.filterFrame=null,o.filterPoolKey=null,o.updateUvs(),o}return Object.defineProperty(i.prototype,"framebuffer",{get:function(){return this.baseTexture.framebuffer},enumerable:!1,configurable:!0}),i.prototype.resize=function(n,r,o){o===void 0&&(o=!0),n=Math.ceil(n),r=Math.ceil(r),this.valid=n>0&&r>0,this._frame.width=this.orig.width=n,this._frame.height=this.orig.height=r,o&&this.baseTexture.resize(n,r),this.updateUvs()},i.prototype.setResolution=function(n){var r=this.baseTexture;r.resolution!==n&&(r.setResolution(n),this.resize(r.width,r.height,!1))},i.create=function(n){for(var r=arguments,o=[],l=1;l0&&i.height>0,r)for(var o=0;o1){for(var p=0;p1&&this.renderer.framebuffer.blit(),o.length===1)o[0].apply(this,r.renderTexture,p.renderTexture,Gh.BLEND,r),this.returnFilterTexture(r.renderTexture);else{var v=r.renderTexture,B=this.getOptimalFilterTexture(v.width,v.height,r.resolution);B.filterFrame=v.filterFrame;var G=0;for(G=0;G=0;--l)n[l]=o[l]||null,n[l]&&(n[l]._batchLocation=l)},i.prototype.boundArray=function(n,r,o,l){for(var c=n.elements,u=n.ids,f=n.count,m=0,p=0;p=0&&B=gd.WEBGL2&&(o=n.getContext("webgl2",r)),o)this.webGLVersion=2;else if(this.webGLVersion=1,o=n.getContext("webgl",r)||n.getContext("experimental-webgl",r),!o)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=o,this.getExtensions(),this.gl},i.prototype.getExtensions=function(){var n=this.gl,r={anisotropicFiltering:n.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:n.getExtension("OES_texture_float_linear"),s3tc:n.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:n.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:n.getExtension("WEBGL_compressed_texture_etc"),etc1:n.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:n.getExtension("WEBGL_compressed_texture_atc"),astc:n.getExtension("WEBGL_compressed_texture_astc")};this.webGLVersion===1?Object.assign(this.extensions,r,{drawBuffers:n.getExtension("WEBGL_draw_buffers"),depthTexture:n.getExtension("WEBGL_depth_texture"),loseContext:n.getExtension("WEBGL_lose_context"),vertexArrayObject:n.getExtension("OES_vertex_array_object")||n.getExtension("MOZ_OES_vertex_array_object")||n.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:n.getExtension("OES_element_index_uint"),floatTexture:n.getExtension("OES_texture_float"),floatTextureLinear:n.getExtension("OES_texture_float_linear"),textureHalfFloat:n.getExtension("OES_texture_half_float"),textureHalfFloatLinear:n.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,r,{colorBufferFloat:n.getExtension("EXT_color_buffer_float")})},i.prototype.handleContextLost=function(n){n.preventDefault()},i.prototype.handleContextRestored=function(){this.renderer.runners.contextChange.emit(this.gl)},i.prototype.destroy=function(){var n=this.renderer.view;n.removeEventListener("webglcontextlost",this.handleContextLost),n.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()},i.prototype.postrender=function(){this.renderer.renderingToScreen&&this.gl.flush()},i.prototype.validateContext=function(n){var r=n.getContextAttributes(),o="WebGL2RenderingContext"in self&&n instanceof self.WebGL2RenderingContext;o&&(this.webGLVersion=2),r.stencil||console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");var l=o||!!n.getExtension("OES_element_index_uint");this.supports.uint32Indices=l,l||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")},i}(ul),oze=function(){function e(i){this.framebuffer=i,this.stencil=null,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.multisample=av.NONE,this.msaaBuffer=null,this.blitFramebuffer=null}return e}(),H4t=new cr,Lse=function(e){Dn(i,e);function i(n){var r=e.call(this,n)||this;return r.managedFramebuffers=[],r.unknownFramebuffer=new BK(10,10),r.msaaSamples=null,r}return i.prototype.contextChange=function(){var n=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new cr,this.hasMRT=!0,this.writeDepthTexture=!0,this.disposeAll(!0),this.renderer.context.webGLVersion===1){var r=this.renderer.context.extensions.drawBuffers,o=this.renderer.context.extensions.depthTexture;tn.PREFER_ENV===gd.WEBGL_LEGACY&&(r=null,o=null),r?n.drawBuffers=function(l){return r.drawBuffersWEBGL(l)}:(this.hasMRT=!1,n.drawBuffers=function(){}),o||(this.writeDepthTexture=!1)}else this.msaaSamples=n.getInternalformatParameter(n.RENDERBUFFER,n.RGBA8,n.SAMPLES)},i.prototype.bind=function(n,r){var o=this.gl;if(n){var l=n.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(n);this.current!==n&&(this.current=n,o.bindFramebuffer(o.FRAMEBUFFER,l.framebuffer)),l.dirtyId!==n.dirtyId&&(l.dirtyId=n.dirtyId,l.dirtyFormat!==n.dirtyFormat?(l.dirtyFormat=n.dirtyFormat,this.updateFramebuffer(n)):l.dirtySize!==n.dirtySize&&(l.dirtySize=n.dirtySize,this.resizeFramebuffer(n)));for(var c=0;c1&&(o.msaaBuffer=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,o.msaaBuffer),r.renderbufferStorageMultisample(r.RENDERBUFFER,o.multisample,r.RGBA8,n.width,n.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,o.msaaBuffer));for(var u=[],f=0;f1)){var m=n.colorTextures[f],p=m.parentTextureArray||m;this.renderer.texture.bind(p,0),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+f,m.target,p._glTextures[this.CONTEXT_UID].texture,0),u.push(r.COLOR_ATTACHMENT0+f)}if(u.length>1&&r.drawBuffers(u),n.depthTexture){var v=this.writeDepthTexture;if(v){var B=n.depthTexture;this.renderer.texture.bind(B,0),r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,B._glTextures[this.CONTEXT_UID].texture,0)}}!o.stencil&&(n.stencil||n.depth)&&(o.stencil=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,o.stencil),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,n.width,n.height),n.depthTexture||r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,o.stencil))},i.prototype.detectSamples=function(n){var r=this.msaaSamples,o=av.NONE;if(n<=1||r===null)return o;for(var l=0;l=0&&this.managedFramebuffers.splice(c,1),n.disposeRunner.remove(this),r||(l.deleteFramebuffer(o.framebuffer),o.stencil&&l.deleteRenderbuffer(o.stencil))}},i.prototype.disposeAll=function(n){var r=this.managedFramebuffers;this.managedFramebuffers=[];for(var o=0;o=l.data.byteLength)r.bufferSubData(u,0,l.data);else{var f=l.static?r.STATIC_DRAW:r.DYNAMIC_DRAW;c.byteLength=l.data.byteLength,r.bufferData(u,l.data,f)}}}},i.prototype.checkCompatibility=function(n,r){var o=n.attributes,l=r.attributeData;for(var c in l)if(!o[c])throw new Error('shader and geometry incompatible, geometry missing the "'+c+'" attribute')},i.prototype.getSignature=function(n,r){var o=n.attributes,l=r.attributeData,c=["g",n.id];for(var u in o)l[u]&&c.push(u);return c.join("-")},i.prototype.initGeometryVao=function(n,r,o){o===void 0&&(o=!0),this.checkCompatibility(n,r);var l=this.gl,c=this.CONTEXT_UID,u=this.getSignature(n,r),f=n.glVertexArrayObjects[this.CONTEXT_UID],m=f[u];if(m)return f[r.id]=m,m;var p=n.buffers,v=n.attributes,B={},G={};for(var T in p)B[T]=0,G[T]=0;for(var T in v)!v[T].size&&r.attributeData[T]?v[T].size=r.attributeData[T].size:v[T].size||console.warn("PIXI Geometry attribute '"+T+"' size cannot be determined (likely the bound shader does not have the attribute)"),B[v[T].buffer]+=v[T].size*pq[v[T].type];for(var T in v){var V=v[T],E=V.size;V.stride===void 0&&(B[V.buffer]===E*pq[V.type]?V.stride=0:V.stride=B[V.buffer]),V.start===void 0&&(V.start=G[V.buffer],G[V.buffer]+=E*pq[V.type])}m=l.createVertexArray(),l.bindVertexArray(m);for(var W=0;W=gd.WEBGL2&&(i=e.getContext("webgl2",{})),i||(i=e.getContext("webgl",{})||e.getContext("experimental-webgl",{}),i?i.getExtension("WEBGL_draw_buffers"):i=null),NV=i}return NV}var VM;function N4t(){if(!VM){VM=sA.MEDIUM;var e=Cze();if(e&&e.getShaderPrecisionFormat){var i=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT);VM=i.precision?sA.HIGH:sA.MEDIUM}}return VM}function yNe(e,i,n){if(e.substring(0,9)!=="precision"){var r=i;return i===sA.HIGH&&n!==sA.HIGH&&(r=sA.MEDIUM),"precision "+r+` float; -`+e}else if(n!==sA.HIGH&&e.substring(0,15)==="precision highp")return e.replace("precision highp","precision mediump");return e}var k4t={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function X4t(e){return k4t[e]}var EM=null,vNe={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"};function ZNe(e,i){if(!EM){var n=Object.keys(vNe);EM={};for(var r=0;r0&&(i+=` -else `),nv.name?1:-1});for(var c=0;c"u"?.5:n,this.isSimple=!1}return Object.defineProperty(e.prototype,"texture",{get:function(){return this._texture},set:function(i){this._texture=i,this._textureID=-1},enumerable:!1,configurable:!0}),e.prototype.multiplyUvs=function(i,n){n===void 0&&(n=i);for(var r=this.mapCoord,o=0;o0?this._useCurrent():n.disable(n.SCISSOR_TEST)},i.prototype._useCurrent=function(){var n=this.maskStack[this.maskStack.length-1]._scissorRect,r=this.renderer.renderTexture.current,o=this.renderer.projection,l=o.transform,c=o.sourceFrame,u=o.destinationFrame,f=r?r.resolution:this.renderer.resolution,m=u.width/c.width,p=u.height/c.height,v=((n.x-c.x)*m+u.x)*f,B=((n.y-c.y)*p+u.y)*f,G=n.width*m*f,T=n.height*p*f;l&&(v+=l.tx*f,B+=l.ty*f),r||(B=this.renderer.height-T-B),this.renderer.gl.scissor(v,B,G,T)},i}(uze),jse=function(e){Dn(i,e);function i(n){var r=e.call(this,n)||this;return r.glConst=WebGLRenderingContext.STENCIL_TEST,r}return i.prototype.getStackLength=function(){var n=this.maskStack[this.maskStack.length-1];return n?n._stencilCounter:0},i.prototype.push=function(n){var r=n.maskObject,o=this.renderer.gl,l=n._stencilCounter;l===0&&(this.renderer.framebuffer.forceStencil(),o.enable(o.STENCIL_TEST)),n._stencilCounter++,o.colorMask(!1,!1,!1,!1),o.stencilFunc(o.EQUAL,l,this._getBitwiseMask()),o.stencilOp(o.KEEP,o.KEEP,o.INCR),r.renderable=!0,r.render(this.renderer),this.renderer.batch.flush(),this.renderer.framebuffer.blit(),r.renderable=!1,this._useCurrent()},i.prototype.pop=function(n){var r=this.renderer.gl;this.getStackLength()===0?(r.disable(r.STENCIL_TEST),r.clear(r.STENCIL_BUFFER_BIT),r.clearStencil(0)):(r.colorMask(!1,!1,!1,!1),r.stencilOp(r.KEEP,r.KEEP,r.DECR),n.renderable=!0,n.render(this.renderer),this.renderer.batch.flush(),n.renderable=!1,this._useCurrent())},i.prototype._useCurrent=function(){var n=this.renderer.gl;n.colorMask(!0,!0,!0,!0),n.stencilFunc(n.EQUAL,this.getStackLength(),this._getBitwiseMask()),n.stencilOp(n.KEEP,n.KEEP,n.KEEP)},i.prototype._getBitwiseMask=function(){return(1<>1,o++;this.stateId=n.data}for(var o=0;othis.checkCountMax&&(this.checkCount=0,this.run())))},i.prototype.run=function(){for(var n=this.renderer.texture,r=n.managedTextures,o=!1,l=0;lthis.maxIdle&&(n.destroyTexture(c,!0),r[l]=null,o=!0)}if(o){for(var u=0,l=0;l=0;l--)this.unload(n.children[l])},i}(ul),hY=function(){function e(i){this.texture=i,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=6408,this.internalFormat=5121,this.samplerType=0}return e}(),nIe=function(e){Dn(i,e);function i(n){var r=e.call(this,n)||this;return r.boundTextures=[],r.currentLocation=-1,r.managedTextures=[],r._unknownBoundTextures=!1,r.unknownTexture=new Lr,r.hasIntegerTextures=!1,r}return i.prototype.contextChange=function(){var n=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion;var r=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=r;for(var o=0;o=0;--u){var f=o[u];if(f){var m=f._glTextures[c];m.samplerType!==sH.FLOAT&&this.renderer.texture.unbind(f)}}},i.prototype.initTexture=function(n){var r=new hY(this.gl.createTexture());return r.dirtyId=-1,n._glTextures[this.CONTEXT_UID]=r,this.managedTextures.push(n),n.on("dispose",this.destroyTexture,this),r},i.prototype.initTextureType=function(n,r){if(r.internalFormat=n.format,r.type=n.type,this.webGLVersion===2){var o=this.renderer.gl;n.type===o.FLOAT&&n.format===o.RGBA&&(r.internalFormat=o.RGBA32F),n.type===Ur.HALF_FLOAT&&(r.type=o.HALF_FLOAT),r.type===o.HALF_FLOAT&&n.format===o.RGBA&&(r.internalFormat=o.RGBA16F)}},i.prototype.updateTexture=function(n){var r=n._glTextures[this.CONTEXT_UID];if(r){var o=this.renderer;if(this.initTextureType(n,r),n.resource&&n.resource.upload(o,n,r))r.samplerType!==sH.FLOAT&&(this.hasIntegerTextures=!0);else{var l=n.realWidth,c=n.realHeight,u=o.gl;(r.width!==l||r.height!==c||r.dirtyId<0)&&(r.width=l,r.height=c,u.texImage2D(n.target,0,r.internalFormat,l,c,0,n.format,r.type,null))}n.dirtyStyleId!==r.dirtyStyleId&&this.updateTextureStyle(n),r.dirtyId=n.dirtyId}},i.prototype.destroyTexture=function(n,r){var o=this.gl;if(n=n.castToBaseTexture(),n._glTextures[this.CONTEXT_UID]&&(this.unbind(n),o.deleteTexture(n._glTextures[this.CONTEXT_UID].texture),n.off("dispose",this.destroyTexture,this),delete n._glTextures[this.CONTEXT_UID],!r)){var l=this.managedTextures.indexOf(n);l!==-1&&Dy(this.managedTextures,l,1)}},i.prototype.updateTextureStyle=function(n){var r=n._glTextures[this.CONTEXT_UID];r&&((n.mipmap===gf.POW2||this.webGLVersion!==2)&&!n.isPowerOfTwo?r.mipmap=!1:r.mipmap=n.mipmap>=1,this.webGLVersion!==2&&!n.isPowerOfTwo?r.wrapMode=Ou.CLAMP:r.wrapMode=n.wrapMode,n.resource&&n.resource.style(this.renderer,n,r)||this.setStyle(n,r),r.dirtyStyleId=n.dirtyStyleId)},i.prototype.setStyle=function(n,r){var o=this.gl;if(r.mipmap&&n.mipmap!==gf.ON_MANUAL&&o.generateMipmap(n.target),o.texParameteri(n.target,o.TEXTURE_WRAP_S,r.wrapMode),o.texParameteri(n.target,o.TEXTURE_WRAP_T,r.wrapMode),r.mipmap){o.texParameteri(n.target,o.TEXTURE_MIN_FILTER,n.scaleMode===Yu.LINEAR?o.LINEAR_MIPMAP_LINEAR:o.NEAREST_MIPMAP_NEAREST);var l=this.renderer.context.extensions.anisotropicFiltering;if(l&&n.anisotropicLevel>0&&n.scaleMode===Yu.LINEAR){var c=Math.min(n.anisotropicLevel,o.getParameter(l.MAX_TEXTURE_MAX_ANISOTROPY_EXT));o.texParameterf(n.target,l.TEXTURE_MAX_ANISOTROPY_EXT,c)}}else o.texParameteri(n.target,o.TEXTURE_MIN_FILTER,n.scaleMode===Yu.LINEAR?o.LINEAR:o.NEAREST);o.texParameteri(n.target,o.TEXTURE_MAG_FILTER,n.scaleMode===Yu.LINEAR?o.LINEAR:o.NEAREST)},i}(ul),hze={__proto__:null,FilterSystem:Pse,BatchSystem:zse,ContextSystem:Ose,FramebufferSystem:Lse,GeometrySystem:Jse,MaskSystem:Use,ScissorSystem:Qse,StencilSystem:jse,ProjectionSystem:$se,RenderTextureSystem:qse,ShaderSystem:eIe,StateSystem:tIe,TextureGCSystem:iIe,TextureSystem:nIe},wq=new Zo,fze=function(e){Dn(i,e);function i(n,r){n===void 0&&(n=RS.UNKNOWN);var o=e.call(this)||this;return r=Object.assign({},tn.RENDER_OPTIONS,r),o.options=r,o.type=n,o.screen=new cr(0,0,r.width,r.height),o.view=r.view||document.createElement("canvas"),o.resolution=r.resolution||tn.RESOLUTION,o.useContextAlpha=r.useContextAlpha,o.autoDensity=!!r.autoDensity,o.preserveDrawingBuffer=r.preserveDrawingBuffer,o.clearBeforeRender=r.clearBeforeRender,o._backgroundColor=0,o._backgroundColorRgba=[0,0,0,1],o._backgroundColorString="#000000",o.backgroundColor=r.backgroundColor||o._backgroundColor,o.backgroundAlpha=r.backgroundAlpha,r.transparent!==void 0&&(lv("6.0.0","Option transparent is deprecated, please use backgroundAlpha instead."),o.useContextAlpha=r.transparent,o.backgroundAlpha=r.transparent?0:1),o._lastObjectRendered=null,o.plugins={},o}return i.prototype.initPlugins=function(n){for(var r in n)this.plugins[r]=new n[r](this)},Object.defineProperty(i.prototype,"width",{get:function(){return this.view.width},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this.view.height},enumerable:!1,configurable:!0}),i.prototype.resize=function(n,r){this.screen.width=n,this.screen.height=r,this.view.width=n*this.resolution,this.view.height=r*this.resolution,this.autoDensity&&(this.view.style.width=n+"px",this.view.style.height=r+"px"),this.emit("resize",n,r)},i.prototype.generateTexture=function(n,r,o,l){l=l||n.getLocalBounds(null,!0),l.width===0&&(l.width=1),l.height===0&&(l.height=1);var c=of.create({width:l.width|0,height:l.height|0,scaleMode:r,resolution:o});return wq.tx=-l.x,wq.ty=-l.y,this.render(n,{renderTexture:c,clear:!1,transform:wq,skipUpdateTransform:!!n.parent}),c},i.prototype.destroy=function(n){for(var r in this.plugins)this.plugins[r].destroy(),this.plugins[r]=null;n&&this.view.parentNode&&this.view.parentNode.removeChild(this.view);var o=this;o.plugins=null,o.type=RS.UNKNOWN,o.view=null,o.screen=null,o._tempDisplayObjectParent=null,o.options=null,this._backgroundColorRgba=null,this._backgroundColorString=null,this._lastObjectRendered=null},Object.defineProperty(i.prototype,"backgroundColor",{get:function(){return this._backgroundColor},set:function(n){this._backgroundColor=n,this._backgroundColorString=Tse(n),sv(n,this._backgroundColorRgba)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"backgroundAlpha",{get:function(){return this._backgroundColorRgba[3]},set:function(n){this._backgroundColorRgba[3]=n},enumerable:!1,configurable:!0}),i}(Gw),hf=function(e){Dn(i,e);function i(n){var r=e.call(this,RS.WEBGL,n)||this;return n=r.options,r.gl=null,r.CONTEXT_UID=0,r.runners={destroy:new Wa("destroy"),contextChange:new Wa("contextChange"),reset:new Wa("reset"),update:new Wa("update"),postrender:new Wa("postrender"),prerender:new Wa("prerender"),resize:new Wa("resize")},r.globalUniforms=new Bp({projectionMatrix:new Zo},!0),r.addSystem(Use,"mask").addSystem(Ose,"context").addSystem(tIe,"state").addSystem(eIe,"shader").addSystem(nIe,"texture").addSystem(Jse,"geometry").addSystem(Lse,"framebuffer").addSystem(Qse,"scissor").addSystem(jse,"stencil").addSystem($se,"projection").addSystem(iIe,"textureGC").addSystem(Pse,"filter").addSystem(qse,"renderTexture").addSystem(zse,"batch"),r.initPlugins(i.__plugins),n.context?r.context.initFromContext(n.context):r.context.initFromOptions({alpha:!!r.useContextAlpha,antialias:n.antialias,premultipliedAlpha:r.useContextAlpha&&r.useContextAlpha!=="notMultiplied",stencil:!0,preserveDrawingBuffer:n.preserveDrawingBuffer,powerPreference:r.options.powerPreference}),r.renderingToScreen=!0,NPe(r.context.webGLVersion===2?"WebGL 2":"WebGL 1"),r.resize(r.options.width,r.options.height),r}return i.create=function(n){if(kPe())return new i(n);throw new Error('WebGL unsupported in this browser, use "pixi.js-legacy" for fallback canvas2d support.')},i.prototype.addSystem=function(n,r){r||(r=n.name);var o=new n(this);if(this[r])throw new Error('Whoops! The name "'+r+'" is already in use');this[r]=o;for(var l in this.runners)this.runners[l].add(o);return this},i.prototype.render=function(n,r){var o,l,c,u;if(r&&(r instanceof of?(lv("6.0.0","Renderer#render arguments changed, use options instead."),o=r,l=arguments[2],c=arguments[3],u=arguments[4]):(o=r.renderTexture,l=r.clear,c=r.transform,u=r.skipUpdateTransform)),this.renderingToScreen=!o,this.runners.prerender.emit(),this.emit("prerender"),this.projection.transform=c,!this.context.isLost){if(o||(this._lastObjectRendered=n),!u){var f=n.enableTempParent();n.updateTransform(),n.disableTempParent(f)}this.renderTexture.bind(o),this.batch.currentRenderer.start(),(l!==void 0?l:this.clearBeforeRender)&&this.renderTexture.clear(),n.render(this),this.batch.currentRenderer.flush(),o&&o.baseTexture.update(),this.runners.postrender.emit(),this.projection.transform=null,this.emit("postrender")}},i.prototype.resize=function(n,r){e.prototype.resize.call(this,n,r),this.runners.resize.emit(n,r)},i.prototype.reset=function(){return this.runners.reset.emit(),this},i.prototype.clear=function(){this.renderTexture.bind(),this.renderTexture.clear()},i.prototype.destroy=function(n){this.runners.destroy.emit();for(var r in this.runners)this.runners[r].destroy();e.prototype.destroy.call(this,n),this.gl=null},Object.defineProperty(i.prototype,"extract",{get:function(){return lv("6.0.0","Renderer#extract has been deprecated, please use Renderer#plugins.extract instead."),this.plugins.extract},enumerable:!1,configurable:!0}),i.registerPlugin=function(n,r){i.__plugins=i.__plugins||{},i.__plugins[n]=r},i}(fze);function mze(e){return hf.create(e)}var gQt=`attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - vTextureCoord = aTextureCoord; -}`,oQt=`attribute vec2 aVertexPosition; - -uniform mat3 projectionMatrix; - -varying vec2 vTextureCoord; - -uniform vec4 inputSize; -uniform vec4 outputFrame; - -vec4 filterVertexPosition( void ) -{ - vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; - - return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); -} - -vec2 filterTextureCoord( void ) -{ - return aVertexPosition * (outputFrame.zw * inputSize.zw); -} - -void main(void) -{ - gl_Position = filterVertexPosition(); - vTextureCoord = filterTextureCoord(); -} -`,pze=gQt,rIe=oQt,GK=function(){function e(){this.texArray=null,this.blend=0,this.type=HC.TRIANGLES,this.start=0,this.size=0,this.data=null}return e}(),SK=function(){function e(){this.elements=[],this.ids=[],this.count=0}return e.prototype.clear=function(){for(var i=0;ithis.size&&this.flush(),this._vertexCount+=n.vertexData.length/2,this._indexCount+=n.indices.length,this._bufferedTextures[this._bufferSize]=n._texture.baseTexture,this._bufferedElements[this._bufferSize++]=n)},i.prototype.buildTexturesAndDrawCalls=function(){var n=this,r=n._bufferedTextures,o=n.MAX_TEXTURES,l=i._textureArrayPool,c=this.renderer.batch,u=this._tempBoundTextures,f=this.renderer.textureGC.count,m=++Lr._globalBatch,p=0,v=l[0],B=0;c.copyBoundTextures(u,o);for(var G=0;G=o&&(c.boundArray(v,u,m,o),this.buildDrawCalls(v,B,G),B=G,v=l[++p],++m),T._batchEnabled=m,T.touched=f,v.elements[v.count++]=T)}v.count>0&&(c.boundArray(v,u,m,o),this.buildDrawCalls(v,B,this._bufferSize),++p,++m);for(var G=0;G0&&(n+=` -else `),r{if(!e)return;const n={key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:/?#]*)(?::(\d*))?))?((((?:[^?#/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@/]*@)([^:/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#/]*\.[^?#/.]+(?:[?#]|$)))*\/?)?([^?#/]*))(?:\?([^#]*))?(?:#(.*))?)/}},r=n.parser[i.strictMode?"strict":"loose"].exec(e),o={};let l=14;for(;l--;)o[n.key[l]]=r[l]||"";return o[n.q.name]={},o[n.key[12]].replace(n.q.parser,function(c,u,f){u&&(o[n.q.name][u]=f)}),o};const wze=Al(lQt);class WM{constructor(i,n=!1,r){this._fn=i,this._once=n,this._thisArg=r,this._next=this._prev=this._owner=null}detach(){return this._owner===null?!1:(this._owner.detach(this),!0)}}function VNe(e,i){return e._head?(e._tail._next=i,i._prev=e._tail,e._tail=i):(e._head=i,e._tail=i),i._owner=e,i}class Vh{constructor(){this._head=this._tail=void 0}handlers(i=!1){let n=this._head;if(i)return!!n;const r=[];for(;n;)r.push(n),n=n._next;return r}has(i){if(!(i instanceof WM))throw new Error("MiniSignal#has(): First arg must be a MiniSignalBinding object.");return i._owner===this}dispatch(){let i=this._head;if(!i)return!1;for(;i;)i._once&&this.detach(i),i._fn.apply(i._thisArg,arguments),i=i._next;return!0}add(i,n=null){if(typeof i!="function")throw new Error("MiniSignal#add(): First arg must be a Function.");return VNe(this,new WM(i,!1,n))}once(i,n=null){if(typeof i!="function")throw new Error("MiniSignal#once(): First arg must be a Function.");return VNe(this,new WM(i,!0,n))}detach(i){if(!(i instanceof WM))throw new Error("MiniSignal#detach(): First arg must be a MiniSignalBinding object.");return i._owner!==this?this:(i._prev&&(i._prev._next=i._next),i._next&&(i._next._prev=i._prev),i===this._head?(this._head=i._next,i._next===null&&(this._tail=null)):i===this._tail&&(this._tail=i._prev,this._tail._next=null),i._owner=null,this)}detachAll(){let i=this._head;if(!i)return this;for(this._head=this._tail=null;i;)i._owner=null,i=i._next;return this}}/*! - * resource-loader - v3.0.1 - * https://github.com/pixijs/pixi-sound - * Compiled Tue, 02 Jul 2019 14:06:18 UTC - * - * resource-loader is licensed under the MIT license. - * http://www.opensource.org/licenses/mit-license - */function _b(){}function ENe(e,i,n,r){var o=0,l=e.length;(function c(u){if(u||o===l){n&&n(u);return}r?setTimeout(function(){i(e[o++],c)},1):i(e[o++],c)})()}function CQt(e){return function(){if(e===null)throw new Error("Callback was already called.");var n=e;e=null,n.apply(this,arguments)}}function cQt(e,i){if(i==null)i=1;else if(i===0)throw new Error("Concurrency must not be zero");var n=0,r={_tasks:[],concurrency:i,saturated:_b,unsaturated:_b,buffer:i/4,empty:_b,drain:_b,error:_b,started:!1,paused:!1,push:function(u,f){o(u,!1,f)},kill:function(){n=0,r.drain=_b,r.started=!1,r._tasks=[]},unshift:function(u,f){o(u,!0,f)},process:function(){for(;!r.paused&&n"u"?WNe:r.status;(r.responseType===""||r.responseType==="text"||typeof r.responseType>"u")&&(o=r.responseText),l===dQt&&(o.length>0||r.responseType===e.XHR_RESPONSE_TYPE.BUFFER)?l=WNe:l===fQt&&(l=hQt);var c=l/100|0;if(c===mQt)if(this.xhrType===e.XHR_RESPONSE_TYPE.TEXT)this.data=o,this.type=e.TYPE.TEXT;else if(this.xhrType===e.XHR_RESPONSE_TYPE.JSON)try{this.data=JSON.parse(o),this.type=e.TYPE.JSON}catch(m){this.abort("Error trying to parse loaded json: "+m);return}else if(this.xhrType===e.XHR_RESPONSE_TYPE.DOCUMENT)try{if(window.DOMParser){var u=new DOMParser;this.data=u.parseFromString(o,"text/xml")}else{var f=document.createElement("div");f.innerHTML=o,this.data=f}this.type=e.TYPE.XML}catch(m){this.abort("Error trying to parse loaded xml: "+m);return}else this.data=r.response||o;else{this.abort("["+r.status+"] "+r.statusText+": "+r.responseURL);return}this.complete()},i._determineCrossOrigin=function(r,o){if(r.indexOf("data:")===0)return"";if(window.origin!==window.location.origin)return"anonymous";o=o||window.location,NM||(NM=document.createElement("a")),NM.href=r,r=wze(NM.href,{strictMode:!0});var l=!r.port&&o.port===""||r.port===o.port,c=r.protocol?r.protocol+":":"";return r.host!==o.hostname||!l||c!==o.protocol?"anonymous":""},i._determineXhrType=function(){return e._xhrTypeMap[this.extension]||e.XHR_RESPONSE_TYPE.TEXT},i._determineLoadType=function(){return e._loadTypeMap[this.extension]||e.LOAD_TYPE.XHR},i._getExtension=function(){var r=this.url,o="";if(this.isDataUrl){var l=r.indexOf("/");o=r.substring(l+1,r.indexOf(";",l))}else{var c=r.indexOf("?"),u=r.indexOf("#"),f=Math.min(c>-1?c:r.length,u>-1?u:r.length);r=r.substring(0,f),o=r.substring(r.lastIndexOf(".")+1)}return o.toLowerCase()},i._getMimeFromXhrType=function(r){switch(r){case e.XHR_RESPONSE_TYPE.BUFFER:return"application/octet-binary";case e.XHR_RESPONSE_TYPE.BLOB:return"application/blob";case e.XHR_RESPONSE_TYPE.DOCUMENT:return"application/xml";case e.XHR_RESPONSE_TYPE.JSON:return"application/json";case e.XHR_RESPONSE_TYPE.DEFAULT:case e.XHR_RESPONSE_TYPE.TEXT:default:return"text/plain"}},Tze(e,[{key:"isDataUrl",get:function(){return this._hasFlag(e.STATUS_FLAGS.DATA_URL)}},{key:"isComplete",get:function(){return this._hasFlag(e.STATUS_FLAGS.COMPLETE)}},{key:"isLoading",get:function(){return this._hasFlag(e.STATUS_FLAGS.LOADING)}}]),e}();Ui.STATUS_FLAGS={NONE:0,DATA_URL:1<<0,COMPLETE:1<<1,LOADING:1<<2};Ui.TYPE={UNKNOWN:0,JSON:1,XML:2,IMAGE:3,AUDIO:4,VIDEO:5,TEXT:6};Ui.LOAD_TYPE={XHR:1,IMAGE:2,AUDIO:3,VIDEO:4};Ui.XHR_RESPONSE_TYPE={DEFAULT:"text",BUFFER:"arraybuffer",BLOB:"blob",DOCUMENT:"document",JSON:"json",TEXT:"text"};Ui._loadTypeMap={gif:Ui.LOAD_TYPE.IMAGE,png:Ui.LOAD_TYPE.IMAGE,bmp:Ui.LOAD_TYPE.IMAGE,jpg:Ui.LOAD_TYPE.IMAGE,jpeg:Ui.LOAD_TYPE.IMAGE,tif:Ui.LOAD_TYPE.IMAGE,tiff:Ui.LOAD_TYPE.IMAGE,webp:Ui.LOAD_TYPE.IMAGE,tga:Ui.LOAD_TYPE.IMAGE,svg:Ui.LOAD_TYPE.IMAGE,"svg+xml":Ui.LOAD_TYPE.IMAGE,mp3:Ui.LOAD_TYPE.AUDIO,ogg:Ui.LOAD_TYPE.AUDIO,wav:Ui.LOAD_TYPE.AUDIO,mp4:Ui.LOAD_TYPE.VIDEO,webm:Ui.LOAD_TYPE.VIDEO};Ui._xhrTypeMap={xhtml:Ui.XHR_RESPONSE_TYPE.DOCUMENT,html:Ui.XHR_RESPONSE_TYPE.DOCUMENT,htm:Ui.XHR_RESPONSE_TYPE.DOCUMENT,xml:Ui.XHR_RESPONSE_TYPE.DOCUMENT,tmx:Ui.XHR_RESPONSE_TYPE.DOCUMENT,svg:Ui.XHR_RESPONSE_TYPE.DOCUMENT,tsx:Ui.XHR_RESPONSE_TYPE.DOCUMENT,gif:Ui.XHR_RESPONSE_TYPE.BLOB,png:Ui.XHR_RESPONSE_TYPE.BLOB,bmp:Ui.XHR_RESPONSE_TYPE.BLOB,jpg:Ui.XHR_RESPONSE_TYPE.BLOB,jpeg:Ui.XHR_RESPONSE_TYPE.BLOB,tif:Ui.XHR_RESPONSE_TYPE.BLOB,tiff:Ui.XHR_RESPONSE_TYPE.BLOB,webp:Ui.XHR_RESPONSE_TYPE.BLOB,tga:Ui.XHR_RESPONSE_TYPE.BLOB,json:Ui.XHR_RESPONSE_TYPE.JSON,text:Ui.XHR_RESPONSE_TYPE.TEXT,txt:Ui.XHR_RESPONSE_TYPE.TEXT,ttf:Ui.XHR_RESPONSE_TYPE.BUFFER,otf:Ui.XHR_RESPONSE_TYPE.BUFFER};Ui.EMPTY_GIF="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==";function NNe(e,i,n){i&&i.indexOf(".")===0&&(i=i.substring(1)),i&&(e[i]=n)}function Rq(e){return e.toString().replace("object ","")}var bQt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function yQt(e){for(var i="",n=0;n>2,o[1]=(r[0]&3)<<4|r[1]>>4,o[2]=(r[1]&15)<<2|r[2]>>6,o[3]=r[2]&63;var c=n-(e.length-1);switch(c){case 2:o[3]=64,o[2]=64;break;case 1:o[3]=64;break}for(var u=0;u0&&l[l.length-1])&&(m[0]===6||m[0]===2)){n=0;continue}if(m[0]===3&&(!l||m[1]>l[0]&&m[1]=33776&&n<=33779)return"s3tc";if(n>=37488&&n<=37497)return"etc";if(n>=35840&&n<=35843)return"pvrtc";if(n>=36196)return"etc1";if(n>=35986&&n<=34798)return"atc";throw new Error("Invalid (compressed) texture format given!")},i._createLevelBuffers=function(n,r,o,l,c,u,f){for(var m=new Array(o),p=n.byteOffset,v=u,B=f,G=v+l-1&~(l-1),T=B+c-1&~(c-1),V=G*T*uH[r],E=0;E1?v:G,levelHeight:o>1?B:T,levelBuffer:new Uint8Array(n.buffer,p,V)},p+=V,v=v>>1||1,B=B>>1||1,G=v+l-1&~(l-1),T=B+c-1&~(c-1),V=G*T*uH[r];return m},i}(Hze),Wze=function(){function e(){}return e.use=function(i,n){var r=i.data,o=this;if(i.type===MC.TYPE.JSON&&r&&r.cacheID&&r.textures){for(var l=r.textures,c=void 0,u=void 0,f=0,m=l.length;f>>1,ee=ee>>>1}for(var de=O,ne=0;ne1?Q:$,levelHeight:G>1?X:ee,levelBuffer:new Uint8Array(n,_,O)},_+=O}ne+=Ae+4,ne=ne%4!==0?ne+4-ne%4:ne,Q=Q>>1||1,X=X>>1||1,$=Q+V-1&~(V-1),ee=X+E-1&~(E-1),O=$*ee*Y}if(l!==0)throw new Error("TODO: Uncompressed");return k.map(function(me){return new TK(null,{format:u,width:f,height:m,levels:G,levelBuffers:me})})},e.validate=function(i,n){for(var r=0;ru&&(o=u),c._properties=[!1,!0,!1,!1,!1],c._maxSize=n,c._batchSize=o,c._buffers=null,c._bufferUpdateIDs=[],c._updateID=0,c.interactiveChildren=!1,c.blendMode=gn.NORMAL,c.autoResize=l,c.roundPixels=!0,c.baseTexture=null,c.setProperties(r),c._tint=0,c.tintRgb=new Float32Array(4),c.tint=16777215,c}return i.prototype.setProperties=function(n){n&&(this._properties[0]="vertices"in n||"scale"in n?!!n.vertices||!!n.scale:this._properties[0],this._properties[1]="position"in n?!!n.position:this._properties[1],this._properties[2]="rotation"in n?!!n.rotation:this._properties[2],this._properties[3]="uvs"in n?!!n.uvs:this._properties[3],this._properties[4]="tint"in n||"alpha"in n?!!n.tint||!!n.alpha:this._properties[4])},i.prototype.updateTransform=function(){this.displayObjectUpdateTransform()},Object.defineProperty(i.prototype,"tint",{get:function(){return this._tint},set:function(n){this._tint=n,sv(n,this.tintRgb)},enumerable:!1,configurable:!0}),i.prototype.render=function(n){var r=this;!this.visible||this.worldAlpha<=0||!this.children.length||!this.renderable||(this.baseTexture||(this.baseTexture=this.children[0]._texture.baseTexture,this.baseTexture.valid||this.baseTexture.once("update",function(){return r.onChildrenChange(0)})),n.batch.setObjectRenderer(n.plugins.particle),n.plugins.particle.render(this))},i.prototype.onChildrenChange=function(n){for(var r=Math.floor(n/this._batchSize);this._bufferUpdateIDs.lengtho&&!n.autoResize&&(u=o);var f=n._buffers;f||(f=n._buffers=this.generateBuffers(n));var m=r[0]._texture.baseTexture;this.state.blendMode=Ese(n.blendMode,m.alphaMode),c.state.set(this.state);var p=c.gl,v=n.worldTransform.copyTo(this.tempMatrix);v.prepend(c.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=v.toArray(!0),this.shader.uniforms.uColor=xPe(n.tintRgb,n.worldAlpha,this.shader.uniforms.uColor,m.alphaMode),this.shader.uniforms.uSampler=m,this.renderer.shader.bind(this.shader);for(var B=!1,G=0,T=0;Gl&&(V=l),T>=f.length&&f.push(this._generateOneMoreBuffer(n));var E=f[T];E.uploadDynamic(r,G,V);var W=n._bufferUpdateIDs[T]||0;B=B||E._updateID0,v=m.alpha,B=v<1&&p?cP(m._tintRGB,v):m._tintRGB+(v*255<<24);l[u]=B,l[u+c]=B,l[u+c*2]=B,l[u+c*3]=B,u+=c*4}},i.prototype.destroy=function(){e.prototype.destroy.call(this),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null},i}(bW);/*! - * @pixi/graphics - v6.0.4 - * Compiled Tue, 11 May 2021 18:00:23 UTC - * - * @pixi/graphics is licensed under the MIT License. - * http://www.opensource.org/licenses/mit-license - */var Nh;(function(e){e.MITER="miter",e.BEVEL="bevel",e.ROUND="round"})(Nh||(Nh={}));var kh;(function(e){e.BUTT="butt",e.ROUND="round",e.SQUARE="square"})(kh||(kh={}));var VS={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount:function(e,i){if(i===void 0&&(i=20),!this.adaptive||!e||isNaN(e))return i;var n=Math.ceil(e/this.maxLength);return nthis.maxSegments&&(n=this.maxSegments),n}},aIe=function(){function e(){this.color=16777215,this.alpha=1,this.texture=hn.WHITE,this.matrix=null,this.visible=!1,this.reset()}return e.prototype.clone=function(){var i=new e;return i.color=this.color,i.alpha=this.alpha,i.texture=this.texture,i.matrix=this.matrix,i.visible=this.visible,i},e.prototype.reset=function(){this.color=16777215,this.alpha=1,this.texture=hn.WHITE,this.matrix=null,this.visible=!1},e.prototype.destroy=function(){this.texture=null,this.matrix=null},e}();/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */var Kne=function(e,i){return Kne=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)r.hasOwnProperty(o)&&(n[o]=r[o])},Kne(e,i)};function sIe(e,i){Kne(e,i);function n(){this.constructor=e}e.prototype=i===null?Object.create(i):(n.prototype=i.prototype,new n)}var IIe={build:function(e){e.points=e.shape.points.slice()},triangulate:function(e,i){var n=e.points,r=e.holes,o=i.points,l=i.indices;if(n.length>=6){for(var c=[],u=0;uv&&(v+=Math.PI*2);var B=p,G=v-p,T=Math.abs(G),V=Math.sqrt(f*f+m*m),E=(15*T*Math.sqrt(V)/Math.PI>>0)+1,W=G/E;if(B+=W,u){c.push(e,i),c.push(n,r);for(var x=1,k=B;xx?(dt?(B.push(xe,it),B.push(Y+X*de,L+$*de),B.push(xe,it),B.push(Y+ee*de,L+ne*de)):(B.push(Y-X*_,L-$*_),B.push(Ct,It),B.push(Y-ee*_,L-ne*_),B.push(Ct,It)),T+=2):l.join===Nh.ROUND?dt?(B.push(xe,it),B.push(Y+X*de,L+$*de),T+=nG(Y,L,Y+X*de,L+$*de,Y+ee*de,L+ne*de,B,!0)+4,B.push(xe,it),B.push(Y+ee*de,L+ne*de)):(B.push(Y-X*_,L-$*_),B.push(Ct,It),T+=nG(Y,L,Y-X*_,L-$*_,Y-ee*_,L-ne*_,B,!1)+4,B.push(Y-ee*_,L-ne*_),B.push(Ct,It)):(B.push(xe,it),B.push(Ct,It)):(B.push(Y-X*_,L-$*_),B.push(Y+X*de,L+$*de),l.join===Nh.BEVEL||lt/W>x||(l.join===Nh.ROUND?dt?T+=nG(Y,L,Y+X*de,L+$*de,Y+ee*de,L+ne*de,B,!0)+2:T+=nG(Y,L,Y-X*_,L-$*_,Y-ee*_,L-ne*_,B,!1)+2:(dt?(B.push(Ct,It),B.push(Ct,It)):(B.push(xe,it),B.push(xe,it)),T+=2)),B.push(Y-ee*_,L-ne*_),B.push(Y+ee*de,L+ne*de),T+=2)}k=r[(G-2)*2],F=r[(G-2)*2+1],Y=r[(G-1)*2],L=r[(G-1)*2+1],X=-(F-L),$=k-Y,ge=Math.sqrt(X*X+$*$),X/=ge,$/=ge,X*=E,$*=E,B.push(Y-X*_,L-$*_),B.push(Y+X*de,L+$*de),f||(l.cap===kh.ROUND?T+=nG(Y-X*(_-de)*.5,L-$*(_-de)*.5,Y-X*_,L-$*_,Y+X*de,L+$*de,B,!1)+2:l.cap===kh.SQUARE&&(T+=MNe(Y,L,X,$,_,de,!1,B)));for(var Ut=i.indices,ti=VS.epsilon*VS.epsilon,Ze=V;ZeB*m}},e.arc=function(i,n,r,o,l,c,u,f,m){for(var p=u-c,v=VS._segmentsCount(Math.abs(p)*l,Math.ceil(Math.abs(p)/CH)*40),B=p/(v*2),G=B*2,T=Math.cos(B),V=Math.sin(B),E=v-1,W=E%1/E,x=0;x<=E;++x){var k=x+W*x,F=B+c+G*k,Y=Math.cos(F),L=-Math.sin(F);m.push((T*Y+V*L)*l+r,(T*-L+V*Y)*l+o)}},e}(),_ze=function(){function e(){}return e.curveLength=function(i,n,r,o,l,c,u,f){for(var m=10,p=0,v=0,B=0,G=0,T=0,V=0,E=0,W=0,x=0,k=0,F=0,Y=i,L=n,O=1;O<=m;++O)v=O/m,B=v*v,G=B*v,T=1-v,V=T*T,E=V*T,W=E*i+3*V*v*r+3*T*B*l+G*u,x=E*n+3*V*v*o+3*T*B*c+G*f,k=Y-W,F=L-x,Y=W,L=x,p+=Math.sqrt(k*k+F*F);return p},e.curveTo=function(i,n,r,o,l,c,u){var f=u[u.length-2],m=u[u.length-1];u.length-=2;var p=VS._segmentsCount(e.curveLength(f,m,i,n,r,o,l,c)),v=0,B=0,G=0,T=0,V=0;u.push(f,m);for(var E=1,W=0;E<=p;++E)W=E/p,v=1-W,B=v*v,G=B*v,T=W*W,V=T*W,u.push(G*f+3*B*W*i+3*v*T*r+V*l,G*m+3*B*W*n+3*v*T*o+V*c)},e}(),Pze=function(){function e(){}return e.curveLength=function(i,n,r,o,l,c){var u=i-2*r+l,f=n-2*o+c,m=2*r-2*i,p=2*o-2*n,v=4*(u*u+f*f),B=4*(u*m+f*p),G=m*m+p*p,T=2*Math.sqrt(v+B+G),V=Math.sqrt(v),E=2*v*V,W=2*Math.sqrt(G),x=B/V;return(E*T+V*B*(T-W)+(4*G*v-B*B)*Math.log((2*V+x+T)/(x+W)))/(4*E)},e.curveTo=function(i,n,r,o,l){for(var c=l[l.length-2],u=l[l.length-1],f=VS._segmentsCount(e.curveLength(c,u,i,n,r,o)),m=0,p=0,v=1;v<=f;++v){var B=v/f;m=c+(i-c)*B,p=u+(n-u)*B,l.push(m+(i+(r-i)*B-m)*B,p+(n+(o-n)*B-p)*B)}},e}(),zze=function(){function e(){this.reset()}return e.prototype.begin=function(i,n,r){this.reset(),this.style=i,this.start=n,this.attribStart=r},e.prototype.end=function(i,n){this.attribSize=n-this.attribStart,this.size=i-this.start},e.prototype.reset=function(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0},e}(),zb,fY=(zb={},zb[Io.POLY]=IIe,zb[Io.CIRC]=_ne,zb[Io.ELIP]=_ne,zb[Io.RECT]=Yze,zb[Io.RREC]=Kze,zb),One=[],R9=[],Lne=function(){function e(i,n,r,o){n===void 0&&(n=null),r===void 0&&(r=null),o===void 0&&(o=null),this.shape=i,this.lineStyle=r,this.fillStyle=n,this.matrix=o,this.type=i.type,this.points=[],this.holes=[]}return e.prototype.clone=function(){return new e(this.shape,this.fillStyle,this.lineStyle,this.matrix)},e.prototype.destroy=function(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null},e}(),rG=new Co,jQt=new cH,Oze=function(e){sIe(i,e);function i(){var n=e.call(this)||this;return n.uvsFloat32=null,n.indicesUint16=null,n.points=[],n.colors=[],n.uvs=[],n.indices=[],n.textureIds=[],n.graphicsData=[],n.dirty=0,n.batchDirty=-1,n.cacheDirty=-1,n.clearDirty=0,n.drawCalls=[],n.batches=[],n.shapeIndex=0,n._bounds=new cH,n.boundsDirty=-1,n.boundsPadding=0,n.batchable=!1,n.indicesUint16=null,n.uvsFloat32=null,n.closePointEps=1e-4,n}return Object.defineProperty(i.prototype,"bounds",{get:function(){return this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds},enumerable:!1,configurable:!0}),i.prototype.invalidate=function(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(var n=0;n0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this},i.prototype.drawShape=function(n,r,o,l){r===void 0&&(r=null),o===void 0&&(o=null),l===void 0&&(l=null);var c=new Lne(n,r,o,l);return this.graphicsData.push(c),this.dirty++,this},i.prototype.drawHole=function(n,r){if(r===void 0&&(r=null),!this.graphicsData.length)return null;var o=new Lne(n,null,null,r),l=this.graphicsData[this.graphicsData.length-1];return o.lineStyle=l.lineStyle,l.holes.push(o),this.dirty++,this},i.prototype.destroy=function(){e.prototype.destroy.call(this);for(var n=0;n0&&(l=this.batches[this.batches.length-1],c=l.style);for(var u=this.shapeIndex;u65535&&n;this.indicesUint16=F?new Uint32Array(this.indices):new Uint16Array(this.indices)}this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}},i.prototype._compareStyles=function(n,r){return!(!n||!r||n.texture.baseTexture!==r.texture.baseTexture||n.color+n.alpha!==r.color+r.alpha||!!n.native!=!!r.native)},i.prototype.validateBatching=function(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(var n=0,r=this.graphicsData.length;n65535*2)return!1;for(var n=this.batches,r=0;r0&&(c=R9.pop(),c||(c=new GK,c.texArray=new SK),this.drawCalls.push(c)),c.start=B,c.size=0,c.texArray.count=0,c.type=v),E.touched=1,E._batchEnabled=n,E._batchLocation=u,E.wrapMode=Ou.REPEAT,c.texArray.elements[c.texArray.count++]=E,u++)),c.size+=G.size,B+=G.size,m=E._batchLocation,this.addColors(o,V.color,V.alpha,G.attribSize),this.addTextureIds(l,m,G.attribSize)}Lr._globalBatch=n,this.packAttributes()},i.prototype.packAttributes=function(){for(var n=this.points,r=this.uvs,o=this.colors,l=this.textureIds,c=new ArrayBuffer(n.length*3*4),u=new Float32Array(c),f=new Uint32Array(c),m=0,p=0;p>16)+(r&65280)+((r&255)<<16),u=cP(c,o);l-- >0;)n.push(u)},i.prototype.addTextureIds=function(n,r,o){for(;o-- >0;)n.push(r)},i.prototype.addUvs=function(n,r,o,l,c,u){u===void 0&&(u=null);for(var f=0,m=r.length,p=o.frame;f0&&n.alpha>0;return r?(n.matrix&&(n.matrix=n.matrix.clone(),n.matrix.invert()),Object.assign(this._lineStyle,{visible:r},n)):this._lineStyle.reset(),this},i.prototype.startPoly=function(){if(this.currentPath){var n=this.currentPath.points,r=this.currentPath.points.length;r>2&&(this.drawShape(this.currentPath),this.currentPath=new fE,this.currentPath.closeStroke=!1,this.currentPath.points.push(n[r-2],n[r-1]))}else this.currentPath=new fE,this.currentPath.closeStroke=!1},i.prototype.finishPoly=function(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)},i.prototype.moveTo=function(n,r){return this.startPoly(),this.currentPath.points[0]=n,this.currentPath.points[1]=r,this},i.prototype.lineTo=function(n,r){this.currentPath||this.moveTo(0,0);var o=this.currentPath.points,l=o[o.length-2],c=o[o.length-1];return(l!==n||c!==r)&&o.push(n,r),this},i.prototype._initCurve=function(n,r){n===void 0&&(n=0),r===void 0&&(r=0),this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[n,r]):this.moveTo(n,r)},i.prototype.quadraticCurveTo=function(n,r,o,l){this._initCurve();var c=this.currentPath.points;return c.length===0&&this.moveTo(0,0),Pze.curveTo(n,r,o,l,c),this},i.prototype.bezierCurveTo=function(n,r,o,l,c,u){return this._initCurve(),_ze.curveTo(n,r,o,l,c,u,this.currentPath.points),this},i.prototype.arcTo=function(n,r,o,l,c){this._initCurve(n,r);var u=this.currentPath.points,f=zne.curveTo(n,r,o,l,c,u);if(f){var m=f.cx,p=f.cy,v=f.radius,B=f.startAngle,G=f.endAngle,T=f.anticlockwise;this.arc(m,p,v,B,G,T)}return this},i.prototype.arc=function(n,r,o,l,c,u){if(u===void 0&&(u=!1),l===c)return this;!u&&c<=l?c+=CH:u&&l<=c&&(l+=CH);var f=c-l;if(f===0)return this;var m=n+Math.cos(l)*o,p=r+Math.sin(l)*o,v=this._geometry.closePointEps,B=this.currentPath?this.currentPath.points:null;if(B){var G=Math.abs(B[B.length-2]-m),T=Math.abs(B[B.length-1]-p);G0;return r?(n.matrix&&(n.matrix=n.matrix.clone(),n.matrix.invert()),Object.assign(this._fillStyle,{visible:r},n)):this._fillStyle.reset(),this},i.prototype.endFill=function(){return this.finishPoly(),this._fillStyle.reset(),this},i.prototype.drawRect=function(n,r,o,l){return this.drawShape(new cr(n,r,o,l))},i.prototype.drawRoundedRect=function(n,r,o,l,c){return this.drawShape(new LPe(n,r,o,l,c))},i.prototype.drawCircle=function(n,r,o){return this.drawShape(new zPe(n,r,o))},i.prototype.drawEllipse=function(n,r,o,l){return this.drawShape(new OPe(n,r,o,l))},i.prototype.drawPolygon=function(){for(var n=arguments,r=[],o=0;o>16&255)/255*c,u.tint[1]=(l>>8&255)/255*c,u.tint[2]=(l&255)/255*c,u.tint[3]=c,n.shader.bind(r),n.geometry.bind(o,r),n.state.set(this.state);for(var m=0,p=f.length;m>16)+(m&65280)+((m&255)<<16)}}},i.prototype.calculateVertices=function(){var n=this.transform._worldID;if(this._transformID!==n){this._transformID=n;for(var r=this.transform.worldTransform,o=r.a,l=r.b,c=r.c,u=r.d,f=r.tx,m=r.ty,p=this._geometry.points,v=this.vertexData,B=0,G=0;G=l&&MV.x=c&&MV.y>16)+(n&65280)+((n&255)<<16)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"texture",{get:function(){return this._texture},set:function(n){this._texture!==n&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=n||hn.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,n&&(n.baseTexture.valid?this._onTextureUpdate():n.once("update",this._onTextureUpdate,this)))},enumerable:!1,configurable:!0}),i}(vA);/*! - * @pixi/text - v6.0.4 - * Compiled Tue, 11 May 2021 18:00:23 UTC - * - * @pixi/text is licensed under the MIT License. - * http://www.opensource.org/licenses/mit-license - *//*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */var Une=function(e,i){return Une=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)r.hasOwnProperty(o)&&(n[o]=r[o])},Une(e,i)};function ijt(e,i){Une(e,i);function n(){this.constructor=e}e.prototype=i===null?Object.create(i):(n.prototype=i.prototype,new n)}var ES;(function(e){e[e.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",e[e.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL"})(ES||(ES={}));var Wq={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:ES.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100,leading:0},njt=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],cv=function(){function e(i){this.styleID=0,this.reset(),kq(this,i,i)}return e.prototype.clone=function(){var i={};return kq(i,this,Wq),new e(i)},e.prototype.reset=function(){kq(this,Wq,Wq)},Object.defineProperty(e.prototype,"align",{get:function(){return this._align},set:function(i){this._align!==i&&(this._align=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"breakWords",{get:function(){return this._breakWords},set:function(i){this._breakWords!==i&&(this._breakWords=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dropShadow",{get:function(){return this._dropShadow},set:function(i){this._dropShadow!==i&&(this._dropShadow=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dropShadowAlpha",{get:function(){return this._dropShadowAlpha},set:function(i){this._dropShadowAlpha!==i&&(this._dropShadowAlpha=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dropShadowAngle",{get:function(){return this._dropShadowAngle},set:function(i){this._dropShadowAngle!==i&&(this._dropShadowAngle=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dropShadowBlur",{get:function(){return this._dropShadowBlur},set:function(i){this._dropShadowBlur!==i&&(this._dropShadowBlur=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dropShadowColor",{get:function(){return this._dropShadowColor},set:function(i){var n=Nq(i);this._dropShadowColor!==n&&(this._dropShadowColor=n,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dropShadowDistance",{get:function(){return this._dropShadowDistance},set:function(i){this._dropShadowDistance!==i&&(this._dropShadowDistance=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fill",{get:function(){return this._fill},set:function(i){var n=Nq(i);this._fill!==n&&(this._fill=n,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fillGradientType",{get:function(){return this._fillGradientType},set:function(i){this._fillGradientType!==i&&(this._fillGradientType=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fillGradientStops",{get:function(){return this._fillGradientStops},set:function(i){rjt(this._fillGradientStops,i)||(this._fillGradientStops=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fontFamily",{get:function(){return this._fontFamily},set:function(i){this.fontFamily!==i&&(this._fontFamily=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fontSize",{get:function(){return this._fontSize},set:function(i){this._fontSize!==i&&(this._fontSize=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fontStyle",{get:function(){return this._fontStyle},set:function(i){this._fontStyle!==i&&(this._fontStyle=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fontVariant",{get:function(){return this._fontVariant},set:function(i){this._fontVariant!==i&&(this._fontVariant=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fontWeight",{get:function(){return this._fontWeight},set:function(i){this._fontWeight!==i&&(this._fontWeight=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"letterSpacing",{get:function(){return this._letterSpacing},set:function(i){this._letterSpacing!==i&&(this._letterSpacing=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineHeight",{get:function(){return this._lineHeight},set:function(i){this._lineHeight!==i&&(this._lineHeight=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leading",{get:function(){return this._leading},set:function(i){this._leading!==i&&(this._leading=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineJoin",{get:function(){return this._lineJoin},set:function(i){this._lineJoin!==i&&(this._lineJoin=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"miterLimit",{get:function(){return this._miterLimit},set:function(i){this._miterLimit!==i&&(this._miterLimit=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"padding",{get:function(){return this._padding},set:function(i){this._padding!==i&&(this._padding=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stroke",{get:function(){return this._stroke},set:function(i){var n=Nq(i);this._stroke!==n&&(this._stroke=n,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"strokeThickness",{get:function(){return this._strokeThickness},set:function(i){this._strokeThickness!==i&&(this._strokeThickness=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textBaseline",{get:function(){return this._textBaseline},set:function(i){this._textBaseline!==i&&(this._textBaseline=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"trim",{get:function(){return this._trim},set:function(i){this._trim!==i&&(this._trim=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"whiteSpace",{get:function(){return this._whiteSpace},set:function(i){this._whiteSpace!==i&&(this._whiteSpace=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"wordWrap",{get:function(){return this._wordWrap},set:function(i){this._wordWrap!==i&&(this._wordWrap=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"wordWrapWidth",{get:function(){return this._wordWrapWidth},set:function(i){this._wordWrapWidth!==i&&(this._wordWrapWidth=i,this.styleID++)},enumerable:!1,configurable:!0}),e.prototype.toFontString=function(){var i=typeof this.fontSize=="number"?this.fontSize+"px":this.fontSize,n=this.fontFamily;Array.isArray(this.fontFamily)||(n=this.fontFamily.split(","));for(var r=n.length-1;r>=0;r--){var o=n[r].trim();!/([\"\'])[^\'\"]+\1/.test(o)&&njt.indexOf(o)<0&&(o='"'+o+'"'),n[r]=o}return this.fontStyle+" "+this.fontVariant+" "+this.fontWeight+" "+i+" "+n.join(",")},e}();function FNe(e){return typeof e=="number"?Tse(e):(typeof e=="string"&&e.indexOf("0x")===0&&(e=e.replace("0x","#")),e)}function Nq(e){if(Array.isArray(e)){for(var i=0;iT)if(c!==""&&(u+=e.addLine(c),c="",l=0),e.canBreakWords(W,n.breakWords))for(var Y=e.wordWrapSplit(W),L=0;LT&&(u+=e.addLine(c),G=!1,c="",l=0),c+=O,l+=ee}else{c.length>0&&(u+=e.addLine(c),c="",l=0);var ne=E===V.length-1;u+=e.addLine(W,!ne),G=!1,c="",l=0}else F+l>T&&(G=!1,u+=e.addLine(c),c="",l=0),(c.length>0||!e.isBreakingSpace(W)||G)&&(c+=W,l+=F)}return u+=e.addLine(c,!1),u},e.addLine=function(i,n){return n===void 0&&(n=!0),i=e.trimRight(i),i=n?i+` -`:i,i},e.getFromCache=function(i,n,r,o){var l=r[i];if(typeof l!="number"){var c=i.length*n;l=o.measureText(i).width+c,r[i]=l}return l},e.collapseSpaces=function(i){return i==="normal"||i==="pre-line"},e.collapseNewlines=function(i){return i==="normal"},e.trimRight=function(i){if(typeof i!="string")return"";for(var n=i.length-1;n>=0;n--){var r=i[n];if(!e.isBreakingSpace(r))break;i=i.slice(0,-1)}return i},e.isNewline=function(i){return typeof i!="string"?!1:e._newlines.indexOf(i.charCodeAt(0))>=0},e.isBreakingSpace=function(i,n){return typeof i!="string"?!1:e._breakingSpaces.indexOf(i.charCodeAt(0))>=0},e.tokenize=function(i){var n=[],r="";if(typeof i!="string")return n;for(var o=0;ou;--B){for(var V=0;V0},e}();function ajt(e,i){var n=!1;if(e&&e._textures&&e._textures.length){for(var r=0;r=0;n--)this.add(i.children[n]);return this},e.prototype.destroy=function(){this.ticking&&aa.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null},e}();function Qze(e,i){return i instanceof Lr?(i._glTextures[e.CONTEXT_UID]||e.texture.bind(i),!0):!1}function ujt(e,i){if(!(i instanceof lIe))return!1;var n=i.geometry;i.finishPoly(),n.updateBatches();for(var r=n.batches,o=0;o=l&&FV.x=c&&FV.y>16)+(n&65280)+((n&255)<<16),this._colorDirty=!0)},enumerable:!1,configurable:!0}),i.prototype.update=function(){if(this._colorDirty){this._colorDirty=!1;var n=this.texture.baseTexture;Hse(this._tint,this._alpha,this.uniforms.uColor,n.alphaMode)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)},i}(kp),ZW=function(e){cIe(i,e);function i(n,r,o){var l=e.call(this)||this,c=new oa(n),u=new oa(r,!0),f=new oa(o,!0,!0);return l.addAttribute("aVertexPosition",c,2,!1,Ur.FLOAT).addAttribute("aTextureCoord",u,2,!1,Ur.FLOAT).addIndex(f),l._updateId=-1,l}return Object.defineProperty(i.prototype,"vertexDirtyId",{get:function(){return this.buffers[0]._updateID},enumerable:!1,configurable:!0}),i}(ww);/*! - * @pixi/text-bitmap - v6.0.4 - * Compiled Tue, 11 May 2021 18:00:23 UTC - * - * @pixi/text-bitmap is licensed under the MIT License. - * http://www.opensource.org/licenses/mit-license - *//*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */var qne=function(e,i){return qne=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)r.hasOwnProperty(o)&&(n[o]=r[o])},qne(e,i)};function vjt(e,i){qne(e,i);function n(){this.constructor=e}e.prototype=i===null?Object.create(i):(n.prototype=i.prototype,new n)}var dH=function(){function e(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[]}return e}(),Zjt=function(){function e(){}return e.test=function(i){return typeof i=="string"&&i.indexOf("info face=")===0},e.parse=function(i){var n=i.match(/^[a-z]+\s+.+$/gm),r={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[]};for(var o in n){var l=n[o].match(/^[a-z]+/gm)[0],c=n[o].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),u={};for(var f in c){var m=c[f].split("="),p=m[0],v=m[1].replace(/"/gm,""),B=parseFloat(v),G=isNaN(B)?v:B;u[p]=G}r[l].push(u)}var T=new dH;return r.info.forEach(function(V){return T.info.push({face:V.face,size:parseInt(V.size,10)})}),r.common.forEach(function(V){return T.common.push({lineHeight:parseInt(V.lineHeight,10)})}),r.page.forEach(function(V){return T.page.push({id:parseInt(V.id,10),file:V.file})}),r.char.forEach(function(V){return T.char.push({id:parseInt(V.id,10),page:parseInt(V.page,10),x:parseInt(V.x,10),y:parseInt(V.y,10),width:parseInt(V.width,10),height:parseInt(V.height,10),xoffset:parseInt(V.xoffset,10),yoffset:parseInt(V.yoffset,10),xadvance:parseInt(V.xadvance,10)})}),r.kerning.forEach(function(V){return T.kerning.push({first:parseInt(V.first,10),second:parseInt(V.second,10),amount:parseInt(V.amount,10)})}),T},e}(),ere=function(){function e(){}return e.test=function(i){return i instanceof XMLDocument&&i.getElementsByTagName("page").length&&i.getElementsByTagName("info")[0].getAttribute("face")!==null},e.parse=function(i){for(var n=new dH,r=i.getElementsByTagName("info"),o=i.getElementsByTagName("common"),l=i.getElementsByTagName("page"),c=i.getElementsByTagName("char"),u=i.getElementsByTagName("kerning"),f=0;f")>-1){var n=new self.DOMParser().parseFromString(i,"text/xml");return ere.test(n)}return!1},e.parse=function(i){var n=new self.DOMParser().parseFromString(i,"text/xml");return ere.parse(n)},e}(),xq=[Zjt,ere,Bjt];function nOe(e){for(var i=0;i=m-Q*u){if(V===0)throw new Error("[BitmapFont] textureHeight "+m+"px is "+("too small for "+v.fontSize+"px fonts"));--Y,E=null,W=null,x=null,V=0,T=0,k=0;continue}if(k=Math.max(Q+L.fontProperties.descent,k),X*u+T>=B){--Y,V+=k*u,V=Math.ceil(V),T=0,k=0;continue}Gjt(E,W,L,T,V,u,v);var $=L.text.charCodeAt(0);G.char.push({id:$,page:F.length-1,x:T/u,y:V/u,width:X,height:Q,xoffset:0,yoffset:0,xadvance:Math.ceil(O-(v.dropShadow?v.dropShadowDistance:0)-(v.stroke?v.strokeThickness:0))}),T+=(X+2*c)*u,T=Math.ceil(T)}for(var Y=0,ee=p.length;Y0&&l.x>v&&(++x,Dy(c,1+E-x,1+Y-E),Y=E,E=-1,u.push(W),f.push(c.length>0?c[c.length-1].prevSpaces:0),T=Math.max(T,W),V++,l.x=0,l.y+=r.lineHeight,B=null,F=0)}}var $=m.charAt(m.length-1);$!=="\r"&&$!==` -`&&(/(?:\s)/.test($)&&(G=W),u.push(G),T=Math.max(T,G),f.push(-1));for(var ee=[],Y=0;Y<=V;Y++){var ne=0;this._align==="right"?ne=T-u[Y]:this._align==="center"?ne=(T-u[Y])/2:this._align==="justify"&&(ne=f[Y]<0?0:(T-u[Y])/f[Y]),ee.push(ne)}for(var ge=c.length,Ae={},_=[],de=this._activePagesMeshData,Y=0;Y6*rt)||be.vertices.length=n&&(c=e-u-1),f=f.replace("%value%",i[c].toString()),o+=f,o+=` -`}return r=r.replace("%blur%",o),r=r.replace("%size%",e.toString()),r}var ONe;(function(e){e[e.WEBGL_LEGACY=0]="WEBGL_LEGACY",e[e.WEBGL=1]="WEBGL",e[e.WEBGL2=2]="WEBGL2"})(ONe||(ONe={}));var LNe;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.WEBGL=1]="WEBGL",e[e.CANVAS=2]="CANVAS"})(LNe||(LNe={}));var JNe;(function(e){e[e.COLOR=16384]="COLOR",e[e.DEPTH=256]="DEPTH",e[e.STENCIL=1024]="STENCIL"})(JNe||(JNe={}));var UNe;(function(e){e[e.NORMAL=0]="NORMAL",e[e.ADD=1]="ADD",e[e.MULTIPLY=2]="MULTIPLY",e[e.SCREEN=3]="SCREEN",e[e.OVERLAY=4]="OVERLAY",e[e.DARKEN=5]="DARKEN",e[e.LIGHTEN=6]="LIGHTEN",e[e.COLOR_DODGE=7]="COLOR_DODGE",e[e.COLOR_BURN=8]="COLOR_BURN",e[e.HARD_LIGHT=9]="HARD_LIGHT",e[e.SOFT_LIGHT=10]="SOFT_LIGHT",e[e.DIFFERENCE=11]="DIFFERENCE",e[e.EXCLUSION=12]="EXCLUSION",e[e.HUE=13]="HUE",e[e.SATURATION=14]="SATURATION",e[e.COLOR=15]="COLOR",e[e.LUMINOSITY=16]="LUMINOSITY",e[e.NORMAL_NPM=17]="NORMAL_NPM",e[e.ADD_NPM=18]="ADD_NPM",e[e.SCREEN_NPM=19]="SCREEN_NPM",e[e.NONE=20]="NONE",e[e.SRC_OVER=0]="SRC_OVER",e[e.SRC_IN=21]="SRC_IN",e[e.SRC_OUT=22]="SRC_OUT",e[e.SRC_ATOP=23]="SRC_ATOP",e[e.DST_OVER=24]="DST_OVER",e[e.DST_IN=25]="DST_IN",e[e.DST_OUT=26]="DST_OUT",e[e.DST_ATOP=27]="DST_ATOP",e[e.ERASE=26]="ERASE",e[e.SUBTRACT=28]="SUBTRACT",e[e.XOR=29]="XOR"})(UNe||(UNe={}));var QNe;(function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN"})(QNe||(QNe={}));var jNe;(function(e){e[e.RGBA=6408]="RGBA",e[e.RGB=6407]="RGB",e[e.ALPHA=6406]="ALPHA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL"})(jNe||(jNe={}));var $Ne;(function(e){e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z"})($Ne||($Ne={}));var qNe;(function(e){e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.FLOAT=5126]="FLOAT",e[e.HALF_FLOAT=36193]="HALF_FLOAT"})(qNe||(qNe={}));var eke;(function(e){e[e.FLOAT=0]="FLOAT",e[e.INT=1]="INT",e[e.UINT=2]="UINT"})(eke||(eke={}));var tke;(function(e){e[e.NEAREST=0]="NEAREST",e[e.LINEAR=1]="LINEAR"})(tke||(tke={}));var ike;(function(e){e[e.CLAMP=33071]="CLAMP",e[e.REPEAT=10497]="REPEAT",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"})(ike||(ike={}));var nke;(function(e){e[e.OFF=0]="OFF",e[e.POW2=1]="POW2",e[e.ON=2]="ON",e[e.ON_MANUAL=3]="ON_MANUAL"})(nke||(nke={}));var rke;(function(e){e[e.NPM=0]="NPM",e[e.UNPACK=1]="UNPACK",e[e.PMA=2]="PMA",e[e.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",e[e.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",e[e.PREMULTIPLY_ALPHA=2]="PREMULTIPLY_ALPHA"})(rke||(rke={}));var hH;(function(e){e[e.NO=0]="NO",e[e.YES=1]="YES",e[e.AUTO=2]="AUTO",e[e.BLEND=0]="BLEND",e[e.CLEAR=1]="CLEAR",e[e.BLIT=2]="BLIT"})(hH||(hH={}));var gke;(function(e){e[e.AUTO=0]="AUTO",e[e.MANUAL=1]="MANUAL"})(gke||(gke={}));var oke;(function(e){e.LOW="lowp",e.MEDIUM="mediump",e.HIGH="highp"})(oke||(oke={}));var ake;(function(e){e[e.NONE=0]="NONE",e[e.SCISSOR=1]="SCISSOR",e[e.STENCIL=2]="STENCIL",e[e.SPRITE=3]="SPRITE"})(ake||(ake={}));var ske;(function(e){e[e.NONE=0]="NONE",e[e.LOW=2]="LOW",e[e.MEDIUM=4]="MEDIUM",e[e.HIGH=8]="HIGH"})(ske||(ske={}));var nre=function(e){gOe(i,e);function i(n,r,o,l,c){r===void 0&&(r=8),o===void 0&&(o=4),l===void 0&&(l=tn.FILTER_RESOLUTION),c===void 0&&(c=5);var u=this,f=Hjt(c,n),m=kjt(c);return u=e.call(this,f,m)||this,u.horizontal=n,u.resolution=l,u._quality=0,u.quality=o,u.blur=r,u}return i.prototype.apply=function(n,r,o,l){if(o?this.horizontal?this.uniforms.strength=1/o.width*(o.width/r.width):this.uniforms.strength=1/o.height*(o.height/r.height):this.horizontal?this.uniforms.strength=1/n.renderer.width*(n.renderer.width/r.width):this.uniforms.strength=1/n.renderer.height*(n.renderer.height/r.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)n.applyFilter(this,r,o,l);else{var c=n.getFilterTexture(),u=n.renderer,f=r,m=c;this.state.blend=!1,n.applyFilter(this,f,m,hH.CLEAR);for(var p=1;p 0.0) { - c.rgb /= c.a; - } - - vec4 result; - - result.r = (m[0] * c.r); - result.r += (m[1] * c.g); - result.r += (m[2] * c.b); - result.r += (m[3] * c.a); - result.r += m[4]; - - result.g = (m[5] * c.r); - result.g += (m[6] * c.g); - result.g += (m[7] * c.b); - result.g += (m[8] * c.a); - result.g += m[9]; - - result.b = (m[10] * c.r); - result.b += (m[11] * c.g); - result.b += (m[12] * c.b); - result.b += (m[13] * c.a); - result.b += m[14]; - - result.a = (m[15] * c.r); - result.a += (m[16] * c.g); - result.a += (m[17] * c.b); - result.a += (m[18] * c.a); - result.a += m[19]; - - vec3 rgb = mix(c.rgb, result.rgb, uAlpha); - - // Premultiply alpha again. - rgb *= result.a; - - gl_FragColor = vec4(rgb, result.a); -} -`,gre=function(e){xjt(i,e);function i(){var n=this,r={m:new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),uAlpha:1};return n=e.call(this,rIe,Djt,r)||this,n.alpha=1,n}return i.prototype._loadMatrix=function(n,r){r===void 0&&(r=!1);var o=n;r&&(this._multiply(o,this.uniforms.m,n),o=this._colorMatrix(o)),this.uniforms.m=o},i.prototype._multiply=function(n,r,o){return n[0]=r[0]*o[0]+r[1]*o[5]+r[2]*o[10]+r[3]*o[15],n[1]=r[0]*o[1]+r[1]*o[6]+r[2]*o[11]+r[3]*o[16],n[2]=r[0]*o[2]+r[1]*o[7]+r[2]*o[12]+r[3]*o[17],n[3]=r[0]*o[3]+r[1]*o[8]+r[2]*o[13]+r[3]*o[18],n[4]=r[0]*o[4]+r[1]*o[9]+r[2]*o[14]+r[3]*o[19]+r[4],n[5]=r[5]*o[0]+r[6]*o[5]+r[7]*o[10]+r[8]*o[15],n[6]=r[5]*o[1]+r[6]*o[6]+r[7]*o[11]+r[8]*o[16],n[7]=r[5]*o[2]+r[6]*o[7]+r[7]*o[12]+r[8]*o[17],n[8]=r[5]*o[3]+r[6]*o[8]+r[7]*o[13]+r[8]*o[18],n[9]=r[5]*o[4]+r[6]*o[9]+r[7]*o[14]+r[8]*o[19]+r[9],n[10]=r[10]*o[0]+r[11]*o[5]+r[12]*o[10]+r[13]*o[15],n[11]=r[10]*o[1]+r[11]*o[6]+r[12]*o[11]+r[13]*o[16],n[12]=r[10]*o[2]+r[11]*o[7]+r[12]*o[12]+r[13]*o[17],n[13]=r[10]*o[3]+r[11]*o[8]+r[12]*o[13]+r[13]*o[18],n[14]=r[10]*o[4]+r[11]*o[9]+r[12]*o[14]+r[13]*o[19]+r[14],n[15]=r[15]*o[0]+r[16]*o[5]+r[17]*o[10]+r[18]*o[15],n[16]=r[15]*o[1]+r[16]*o[6]+r[17]*o[11]+r[18]*o[16],n[17]=r[15]*o[2]+r[16]*o[7]+r[17]*o[12]+r[18]*o[17],n[18]=r[15]*o[3]+r[16]*o[8]+r[17]*o[13]+r[18]*o[18],n[19]=r[15]*o[4]+r[16]*o[9]+r[17]*o[14]+r[18]*o[19]+r[19],n},i.prototype._colorMatrix=function(n){var r=new Float32Array(n);return r[4]/=255,r[9]/=255,r[14]/=255,r[19]/=255,r},i.prototype.brightness=function(n,r){var o=[n,0,0,0,0,0,n,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(o,r)},i.prototype.greyscale=function(n,r){var o=[n,n,n,0,0,n,n,n,0,0,n,n,n,0,0,0,0,0,1,0];this._loadMatrix(o,r)},i.prototype.blackAndWhite=function(n){var r=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(r,n)},i.prototype.hue=function(n,r){n=(n||0)/180*Math.PI;var o=Math.cos(n),l=Math.sin(n),c=Math.sqrt,u=1/3,f=c(u),m=o+(1-o)*u,p=u*(1-o)-f*l,v=u*(1-o)+f*l,B=u*(1-o)+f*l,G=o+u*(1-o),T=u*(1-o)-f*l,V=u*(1-o)-f*l,E=u*(1-o)+f*l,W=o+u*(1-o),x=[m,p,v,0,0,B,G,T,0,0,V,E,W,0,0,0,0,0,1,0];this._loadMatrix(x,r)},i.prototype.contrast=function(n,r){var o=(n||0)+1,l=-.5*(o-1),c=[o,0,0,0,l,0,o,0,0,l,0,0,o,0,l,0,0,0,1,0];this._loadMatrix(c,r)},i.prototype.saturate=function(n,r){n===void 0&&(n=0);var o=n*2/3+1,l=(o-1)*-.5,c=[o,l,l,0,0,l,o,l,0,0,l,l,o,0,0,0,0,0,1,0];this._loadMatrix(c,r)},i.prototype.desaturate=function(){this.saturate(-1)},i.prototype.negative=function(n){var r=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(r,n)},i.prototype.sepia=function(n){var r=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(r,n)},i.prototype.technicolor=function(n){var r=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(r,n)},i.prototype.polaroid=function(n){var r=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(r,n)},i.prototype.toBGR=function(n){var r=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(r,n)},i.prototype.kodachrome=function(n){var r=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(r,n)},i.prototype.browni=function(n){var r=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(r,n)},i.prototype.vintage=function(n){var r=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(r,n)},i.prototype.colorTone=function(n,r,o,l,c){n=n||.2,r=r||.15,o=o||16770432,l=l||3375104;var u=(o>>16&255)/255,f=(o>>8&255)/255,m=(o&255)/255,p=(l>>16&255)/255,v=(l>>8&255)/255,B=(l&255)/255,G=[.3,.59,.11,0,0,u,f,m,n,0,p,v,B,r,0,u-p,f-v,m-B,0,0];this._loadMatrix(G,c)},i.prototype.night=function(n,r){n=n||.1;var o=[n*-2,-n,0,0,0,-n,0,n,0,0,0,n,n*2,0,0,0,0,0,1,0];this._loadMatrix(o,r)},i.prototype.predator=function(n,r){var o=[11.224130630493164*n,-4.794486999511719*n,-2.8746118545532227*n,0*n,.40342438220977783*n,-3.6330697536468506*n,9.193157196044922*n,-2.951810836791992*n,0*n,-1.316135048866272*n,-3.2184197902679443*n,-4.2375030517578125*n,7.476448059082031*n,0*n,.8044459223747253*n,0,0,0,1,0];this._loadMatrix(o,r)},i.prototype.lsd=function(n){var r=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(r,n)},i.prototype.reset=function(){var n=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(n,!1)},Object.defineProperty(i.prototype,"matrix",{get:function(){return this.uniforms.m},set:function(n){this.uniforms.m=n},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"alpha",{get:function(){return this.uniforms.uAlpha},set:function(n){this.uniforms.uAlpha=n},enumerable:!1,configurable:!0}),i}(df);gre.prototype.grayscale=gre.prototype.greyscale;/*! - * @pixi/filter-displacement - v6.0.4 - * Compiled Tue, 11 May 2021 18:00:23 UTC - * - * @pixi/filter-displacement is licensed under the MIT License. - * http://www.opensource.org/licenses/mit-license - *//*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */var ore=function(e,i){return ore=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)r.hasOwnProperty(o)&&(n[o]=r[o])},ore(e,i)};function Mjt(e,i){ore(e,i);function n(){this.constructor=e}e.prototype=i===null?Object.create(i):(n.prototype=i.prototype,new n)}var Fjt=`varying vec2 vFilterCoord; -varying vec2 vTextureCoord; - -uniform vec2 scale; -uniform mat2 rotation; -uniform sampler2D uSampler; -uniform sampler2D mapSampler; - -uniform highp vec4 inputSize; -uniform vec4 inputClamp; - -void main(void) -{ - vec4 map = texture2D(mapSampler, vFilterCoord); - - map -= 0.5; - map.xy = scale * inputSize.zw * (rotation * map.xy); - - gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw)); -} -`,Yjt=`attribute vec2 aVertexPosition; - -uniform mat3 projectionMatrix; -uniform mat3 filterMatrix; - -varying vec2 vTextureCoord; -varying vec2 vFilterCoord; - -uniform vec4 inputSize; -uniform vec4 outputFrame; - -vec4 filterVertexPosition( void ) -{ - vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; - - return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); -} - -vec2 filterTextureCoord( void ) -{ - return aVertexPosition * (outputFrame.zw * inputSize.zw); -} - -void main(void) -{ - gl_Position = filterVertexPosition(); - vTextureCoord = filterTextureCoord(); - vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy; -} -`,Kjt=function(e){Mjt(i,e);function i(n,r){var o=this,l=new Zo;return n.renderable=!1,o=e.call(this,Yjt,Fjt,{mapSampler:n._texture,filterMatrix:l,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])})||this,o.maskSprite=n,o.maskMatrix=l,r==null&&(r=20),o.scale=new Co(r,r),o}return i.prototype.apply=function(n,r,o,l){this.uniforms.filterMatrix=n.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;var c=this.maskSprite.worldTransform,u=Math.sqrt(c.a*c.a+c.b*c.b),f=Math.sqrt(c.c*c.c+c.d*c.d);u!==0&&f!==0&&(this.uniforms.rotation[0]=c.a/u,this.uniforms.rotation[1]=c.b/u,this.uniforms.rotation[2]=c.c/f,this.uniforms.rotation[3]=c.d/f),n.applyFilter(this,r,o,l)},Object.defineProperty(i.prototype,"map",{get:function(){return this.uniforms.mapSampler},set:function(n){this.uniforms.mapSampler=n},enumerable:!1,configurable:!0}),i}(df);/*! - * @pixi/filter-fxaa - v6.0.4 - * Compiled Tue, 11 May 2021 18:00:23 UTC - * - * @pixi/filter-fxaa is licensed under the MIT License. - * http://www.opensource.org/licenses/mit-license - *//*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */var are=function(e,i){return are=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)r.hasOwnProperty(o)&&(n[o]=r[o])},are(e,i)};function _jt(e,i){are(e,i);function n(){this.constructor=e}e.prototype=i===null?Object.create(i):(n.prototype=i.prototype,new n)}var Pjt=` -attribute vec2 aVertexPosition; - -uniform mat3 projectionMatrix; - -varying vec2 v_rgbNW; -varying vec2 v_rgbNE; -varying vec2 v_rgbSW; -varying vec2 v_rgbSE; -varying vec2 v_rgbM; - -varying vec2 vFragCoord; - -uniform vec4 inputSize; -uniform vec4 outputFrame; - -vec4 filterVertexPosition( void ) -{ - vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; - - return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); -} - -void texcoords(vec2 fragCoord, vec2 inverseVP, - out vec2 v_rgbNW, out vec2 v_rgbNE, - out vec2 v_rgbSW, out vec2 v_rgbSE, - out vec2 v_rgbM) { - v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP; - v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP; - v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP; - v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP; - v_rgbM = vec2(fragCoord * inverseVP); -} - -void main(void) { - - gl_Position = filterVertexPosition(); - - vFragCoord = aVertexPosition * outputFrame.zw; - - texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM); -} -`,zjt=`varying vec2 v_rgbNW; -varying vec2 v_rgbNE; -varying vec2 v_rgbSW; -varying vec2 v_rgbSE; -varying vec2 v_rgbM; - -varying vec2 vFragCoord; -uniform sampler2D uSampler; -uniform highp vec4 inputSize; - - -/** - Basic FXAA implementation based on the code on geeks3d.com with the - modification that the texture2DLod stuff was removed since it's - unsupported by WebGL. - - -- - - From: - https://github.com/mitsuhiko/webgl-meincraft - - Copyright (c) 2011 by Armin Ronacher. - - Some rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * The names of the contributors may not be used to endorse or - promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef FXAA_REDUCE_MIN -#define FXAA_REDUCE_MIN (1.0/ 128.0) -#endif -#ifndef FXAA_REDUCE_MUL -#define FXAA_REDUCE_MUL (1.0 / 8.0) -#endif -#ifndef FXAA_SPAN_MAX -#define FXAA_SPAN_MAX 8.0 -#endif - -//optimized version for mobile, where dependent -//texture reads can be a bottleneck -vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inverseVP, - vec2 v_rgbNW, vec2 v_rgbNE, - vec2 v_rgbSW, vec2 v_rgbSE, - vec2 v_rgbM) { - vec4 color; - vec3 rgbNW = texture2D(tex, v_rgbNW).xyz; - vec3 rgbNE = texture2D(tex, v_rgbNE).xyz; - vec3 rgbSW = texture2D(tex, v_rgbSW).xyz; - vec3 rgbSE = texture2D(tex, v_rgbSE).xyz; - vec4 texColor = texture2D(tex, v_rgbM); - vec3 rgbM = texColor.xyz; - vec3 luma = vec3(0.299, 0.587, 0.114); - float lumaNW = dot(rgbNW, luma); - float lumaNE = dot(rgbNE, luma); - float lumaSW = dot(rgbSW, luma); - float lumaSE = dot(rgbSE, luma); - float lumaM = dot(rgbM, luma); - float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); - float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); - - mediump vec2 dir; - dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); - dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); - - float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * - (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); - - float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce); - dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), - max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), - dir * rcpDirMin)) * inverseVP; - - vec3 rgbA = 0.5 * ( - texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz + - texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz); - vec3 rgbB = rgbA * 0.5 + 0.25 * ( - texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz + - texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz); - - float lumaB = dot(rgbB, luma); - if ((lumaB < lumaMin) || (lumaB > lumaMax)) - color = vec4(rgbA, texColor.a); - else - color = vec4(rgbB, texColor.a); - return color; -} - -void main() { - - vec4 color; - - color = fxaa(uSampler, vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM); - - gl_FragColor = color; -} -`,Ojt=function(e){_jt(i,e);function i(){return e.call(this,Pjt,zjt)||this}return i}(df);/*! - * @pixi/filter-noise - v6.0.4 - * Compiled Tue, 11 May 2021 18:00:23 UTC - * - * @pixi/filter-noise is licensed under the MIT License. - * http://www.opensource.org/licenses/mit-license - *//*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */var sre=function(e,i){return sre=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)r.hasOwnProperty(o)&&(n[o]=r[o])},sre(e,i)};function Ljt(e,i){sre(e,i);function n(){this.constructor=e}e.prototype=i===null?Object.create(i):(n.prototype=i.prototype,new n)}var Jjt=`precision highp float; - -varying vec2 vTextureCoord; -varying vec4 vColor; - -uniform float uNoise; -uniform float uSeed; -uniform sampler2D uSampler; - -float rand(vec2 co) -{ - return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); -} - -void main() -{ - vec4 color = texture2D(uSampler, vTextureCoord); - float randomValue = rand(gl_FragCoord.xy * uSeed); - float diff = (randomValue - 0.5) * uNoise; - - // Un-premultiply alpha before applying the color matrix. See issue #3539. - if (color.a > 0.0) { - color.rgb /= color.a; - } - - color.r += diff; - color.g += diff; - color.b += diff; - - // Premultiply alpha again. - color.rgb *= color.a; - - gl_FragColor = color; -} -`,Ujt=function(e){Ljt(i,e);function i(n,r){n===void 0&&(n=.5),r===void 0&&(r=Math.random());var o=e.call(this,rIe,Jjt,{uNoise:0,uSeed:0})||this;return o.noise=n,o.seed=r,o}return Object.defineProperty(i.prototype,"noise",{get:function(){return this.uniforms.uNoise},set:function(n){this.uniforms.uNoise=n},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"seed",{get:function(){return this.uniforms.uSeed},set:function(n){this.uniforms.uSeed=n},enumerable:!1,configurable:!0}),i}(df);/*! - * @pixi/mixin-cache-as-bitmap - v6.0.4 - * Compiled Tue, 11 May 2021 18:00:23 UTC - * - * @pixi/mixin-cache-as-bitmap is licensed under the MIT License. - * http://www.opensource.org/licenses/mit-license - */var oOe=new Zo;Bo.prototype._cacheAsBitmap=!1;Bo.prototype._cacheData=null;Bo.prototype._cacheAsBitmapResolution=null;var Qjt=function(){function e(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}return e}();Object.defineProperties(Bo.prototype,{cacheAsBitmapResolution:{get:function(){return this._cacheAsBitmapResolution},set:function(e){e!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=e,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get:function(){return this._cacheAsBitmap},set:function(e){if(this._cacheAsBitmap!==e){this._cacheAsBitmap=e;var i;e?(this._cacheData||(this._cacheData=new Qjt),i=this._cacheData,i.originalRender=this.render,i.originalRenderCanvas=this.renderCanvas,i.originalUpdateTransform=this.updateTransform,i.originalCalculateBounds=this.calculateBounds,i.originalGetLocalBounds=this.getLocalBounds,i.originalDestroy=this.destroy,i.originalContainsPoint=this.containsPoint,i.originalMask=this._mask,i.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(i=this._cacheData,i.sprite&&this._destroyCachedDisplayObject(),this.render=i.originalRender,this.renderCanvas=i.originalRenderCanvas,this.calculateBounds=i.originalCalculateBounds,this.getLocalBounds=i.originalGetLocalBounds,this.destroy=i.originalDestroy,this.updateTransform=i.originalUpdateTransform,this.containsPoint=i.originalContainsPoint,this._mask=i.originalMask,this.filterArea=i.originalFilterArea)}}}});Bo.prototype._renderCached=function(i){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(i),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(i))};Bo.prototype._initCachedDisplayObject=function(i){if(!(this._cacheData&&this._cacheData.sprite)){var n=this.alpha;this.alpha=1,i.batch.flush();var r=this.getLocalBounds(null,!0).clone();if(this.filters){var o=this.filters[0].padding;r.pad(o)}r.ceil(tn.RESOLUTION);var l=i.renderTexture.current,c=i.renderTexture.sourceFrame.clone(),u=i.renderTexture.destinationFrame.clone(),f=i.projection.transform,m=of.create({width:r.width,height:r.height,resolution:this.cacheAsBitmapResolution||i.resolution}),p="cacheAsBitmap_"+Iv();this._cacheData.textureCacheId=p,Lr.addToCache(m.baseTexture,p),hn.addToCache(m,p);var v=this.transform.localTransform.copyTo(oOe).invert().translate(-r.x,-r.y);this.render=this._cacheData.originalRender,i.render(this,{renderTexture:m,clear:!0,transform:v,skipUpdateTransform:!1}),i.projection.transform=f,i.renderTexture.bind(l,c,u),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=n;var B=new Tw(m);B.transform.worldTransform=this.transform.worldTransform,B.anchor.x=-(r.x/r.width),B.anchor.y=-(r.y/r.height),B.alpha=n,B._bounds=this._bounds,this._cacheData.sprite=B,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=B.containsPoint.bind(B)}};Bo.prototype._renderCachedCanvas=function(i){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(i),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(i))};Bo.prototype._initCachedDisplayObjectCanvas=function(i){if(!(this._cacheData&&this._cacheData.sprite)){var n=this.getLocalBounds(null,!0),r=this.alpha;this.alpha=1;var o=i.context,l=i._projTransform;n.ceil(tn.RESOLUTION);var c=of.create({width:n.width,height:n.height}),u="cacheAsBitmap_"+Iv();this._cacheData.textureCacheId=u,Lr.addToCache(c.baseTexture,u),hn.addToCache(c,u);var f=oOe;this.transform.localTransform.copyTo(f),f.invert(),f.tx-=n.x,f.ty-=n.y,this.renderCanvas=this._cacheData.originalRenderCanvas,i.render(this,{renderTexture:c,clear:!0,transform:f,skipUpdateTransform:!1}),i.context=o,i._projTransform=l,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=r;var m=new Tw(c);m.transform.worldTransform=this.transform.worldTransform,m.anchor.x=-(n.x/n.width),m.anchor.y=-(n.y/n.height),m.alpha=r,m._bounds=this._bounds,this._cacheData.sprite=m,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=i._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=m.containsPoint.bind(m)}};Bo.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID};Bo.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)};Bo.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,Lr.removeFromCache(this._cacheData.textureCacheId),hn.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null};Bo.prototype._cacheAsBitmapDestroy=function(i){this.cacheAsBitmap=!1,this.destroy(i)};/*! - * @pixi/mixin-get-child-by-name - v6.0.4 - * Compiled Tue, 11 May 2021 18:00:23 UTC - * - * @pixi/mixin-get-child-by-name is licensed under the MIT License. - * http://www.opensource.org/licenses/mit-license - */Bo.prototype.name=null;vA.prototype.getChildByName=function(i,n){for(var r=0,o=this.children.length;r0){var T=m.x-n[B].x,V=m.y-n[B].y,E=Math.sqrt(T*T+V*V);m=n[B],f+=E/p}else f=B/(v-1);c[G]=f,c[G+1]=0,c[G+2]=f,c[G+3]=1}for(var W=0,B=0;B0?this.textureScale*this._width/2:this._width/2;l/=B,c/=B,l*=G,c*=G,u[v]=p.x+l,u[v+1]=p.y+c,u[v+2]=p.x-l,u[v+3]=p.y-c,r=p}this.buffers[0].update()}},i.prototype.update=function(){this.textureScale>0?this.build():this.updateVertices()},i}(ZW),jjt=function(e){Rw(i,e);function i(n,r,o){o===void 0&&(o=0);var l=this,c=new sOe(n.height,r,o),u=new vW(n);return o>0&&(n.baseTexture.wrapMode=Ou.REPEAT),l=e.call(this,c,u)||this,l.autoUpdate=!0,l}return i.prototype._render=function(n){var r=this.geometry;(this.autoUpdate||r._width!==this.shader.texture.height)&&(r._width=this.shader.texture.height,r.update()),e.prototype._render.call(this,n)},i}(HS),IOe=function(e){Rw(i,e);function i(n,r,o){var l=this,c=new aOe(n.width,n.height,r,o),u=new vW(hn.WHITE);return l=e.call(this,c,u)||this,l.texture=n,l}return i.prototype.textureUpdated=function(){this._textureID=this.shader.texture._updateID;var n=this.geometry;n.width=this.shader.texture.width,n.height=this.shader.texture.height,n.build()},Object.defineProperty(i.prototype,"texture",{get:function(){return this.shader.texture},set:function(n){this.shader.texture!==n&&(this.shader.texture=n,this._textureID=-1,n.baseTexture.valid?this.textureUpdated():n.once("update",this.textureUpdated,this))},enumerable:!1,configurable:!0}),i.prototype._render=function(n){this._textureID!==this.shader.texture._updateID&&this.textureUpdated(),e.prototype._render.call(this,n)},i.prototype.destroy=function(n){this.shader.texture.off("update",this.textureUpdated,this),e.prototype.destroy.call(this,n)},i}(HS),$jt=function(e){Rw(i,e);function i(n,r,o,l,c){n===void 0&&(n=hn.EMPTY);var u=this,f=new ZW(r,o,l);f.getBuffer("aVertexPosition").static=!1;var m=new vW(n);return u=e.call(this,f,m,null,c)||this,u.autoUpdate=!0,u}return Object.defineProperty(i.prototype,"vertices",{get:function(){return this.geometry.getBuffer("aVertexPosition").data},set:function(n){this.geometry.getBuffer("aVertexPosition").data=n},enumerable:!1,configurable:!0}),i.prototype._render=function(n){this.autoUpdate&&this.geometry.getBuffer("aVertexPosition").update(),e.prototype._render.call(this,n)},i}(HS),FM=10,qjt=function(e){Rw(i,e);function i(n,r,o,l,c){r===void 0&&(r=FM),o===void 0&&(o=FM),l===void 0&&(l=FM),c===void 0&&(c=FM);var u=e.call(this,hn.WHITE,4,4)||this;return u._origWidth=n.orig.width,u._origHeight=n.orig.height,u._width=u._origWidth,u._height=u._origHeight,u._leftWidth=r,u._rightWidth=l,u._topHeight=o,u._bottomHeight=c,u.texture=n,u}return i.prototype.textureUpdated=function(){this._textureID=this.shader.texture._updateID,this._refresh()},Object.defineProperty(i.prototype,"vertices",{get:function(){return this.geometry.getBuffer("aVertexPosition").data},set:function(n){this.geometry.getBuffer("aVertexPosition").data=n},enumerable:!1,configurable:!0}),i.prototype.updateHorizontalVertices=function(){var n=this.vertices,r=this._getMinScale();n[9]=n[11]=n[13]=n[15]=this._topHeight*r,n[17]=n[19]=n[21]=n[23]=this._height-this._bottomHeight*r,n[25]=n[27]=n[29]=n[31]=this._height},i.prototype.updateVerticalVertices=function(){var n=this.vertices,r=this._getMinScale();n[2]=n[10]=n[18]=n[26]=this._leftWidth*r,n[4]=n[12]=n[20]=n[28]=this._width-this._rightWidth*r,n[6]=n[14]=n[22]=n[30]=this._width},i.prototype._getMinScale=function(){var n=this._leftWidth+this._rightWidth,r=this._width>n?1:this._width/n,o=this._topHeight+this._bottomHeight,l=this._height>o?1:this._height/o,c=Math.min(r,l);return c},Object.defineProperty(i.prototype,"width",{get:function(){return this._width},set:function(n){this._width=n,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this._height},set:function(n){this._height=n,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"leftWidth",{get:function(){return this._leftWidth},set:function(n){this._leftWidth=n,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"rightWidth",{get:function(){return this._rightWidth},set:function(n){this._rightWidth=n,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"topHeight",{get:function(){return this._topHeight},set:function(n){this._topHeight=n,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"bottomHeight",{get:function(){return this._bottomHeight},set:function(n){this._bottomHeight=n,this._refresh()},enumerable:!1,configurable:!0}),i.prototype._refresh=function(){var n=this.texture,r=this.geometry.buffers[1].data;this._origWidth=n.orig.width,this._origHeight=n.orig.height;var o=1/this._origWidth,l=1/this._origHeight;r[0]=r[8]=r[16]=r[24]=0,r[1]=r[3]=r[5]=r[7]=0,r[6]=r[14]=r[22]=r[30]=1,r[25]=r[27]=r[29]=r[31]=1,r[2]=r[10]=r[18]=r[26]=o*this._leftWidth,r[4]=r[12]=r[20]=r[28]=1-o*this._rightWidth,r[9]=r[11]=r[13]=r[15]=l*this._topHeight,r[17]=r[19]=r[21]=r[23]=1-l*this._bottomHeight,this.updateHorizontalVertices(),this.updateVerticalVertices(),this.geometry.buffers[0].update(),this.geometry.buffers[1].update()},i}(IOe);/*! - * @pixi/sprite-animated - v6.0.4 - * Compiled Tue, 11 May 2021 18:00:23 UTC - * - * @pixi/sprite-animated is licensed under the MIT License. - * http://www.opensource.org/licenses/mit-license - *//*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */var lre=function(e,i){return lre=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)r.hasOwnProperty(o)&&(n[o]=r[o])},lre(e,i)};function e6t(e,i){lre(e,i);function n(){this.constructor=e}e.prototype=i===null?Object.create(i):(n.prototype=i.prototype,new n)}var t6t=function(e){e6t(i,e);function i(n,r){r===void 0&&(r=!0);var o=e.call(this,n[0]instanceof hn?n[0]:n[0].texture)||this;return o._textures=null,o._durations=null,o._autoUpdate=r,o._isConnectedToTicker=!1,o.animationSpeed=1,o.loop=!0,o.updateAnchor=!1,o.onComplete=null,o.onFrameChange=null,o.onLoop=null,o._currentTime=0,o._playing=!1,o._previousFrame=null,o.textures=n,o}return i.prototype.stop=function(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(aa.shared.remove(this.update,this),this._isConnectedToTicker=!1))},i.prototype.play=function(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(aa.shared.add(this.update,this,ad.HIGH),this._isConnectedToTicker=!0))},i.prototype.gotoAndStop=function(n){this.stop();var r=this.currentFrame;this._currentTime=n,r!==this.currentFrame&&this.updateTexture()},i.prototype.gotoAndPlay=function(n){var r=this.currentFrame;this._currentTime=n,r!==this.currentFrame&&this.updateTexture(),this.play()},i.prototype.update=function(n){if(this._playing){var r=this.animationSpeed*n,o=this.currentFrame;if(this._durations!==null){var l=this._currentTime%1*this._durations[this.currentFrame];for(l+=r/60*1e3;l<0;)this._currentTime--,l+=this._durations[this.currentFrame];var c=Math.sign(this.animationSpeed*n);for(this._currentTime=Math.floor(this._currentTime);l>=this._durations[this.currentFrame];)l-=this._durations[this.currentFrame]*c,this._currentTime+=c;this._currentTime+=l/this._durations[this.currentFrame]}else this._currentTime+=r;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):o!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrameo&&this.onLoop()),this.updateTexture())}},i.prototype.updateTexture=function(){var n=this.currentFrame;this._previousFrame!==n&&(this._previousFrame=n,this._texture=this._textures[n],this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this.uvs=this._texture._uvs.uvsFloat32,this.updateAnchor&&this._anchor.copyFrom(this._texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))},i.prototype.destroy=function(n){this.stop(),e.prototype.destroy.call(this,n),this.onComplete=null,this.onFrameChange=null,this.onLoop=null},i.fromFrames=function(n){for(var r=[],o=0;o>8&15|i>>4&240,i>>4&15|i&240,(i&15)<<4|i&15,1):n===8?YM(i>>24&255,i>>16&255,i>>8&255,(i&255)/255):n===4?YM(i>>12&15|i>>8&240,i>>8&15|i>>4&240,i>>4&15|i&240,((i&15)<<4|i&15)/255):null):(i=o6t.exec(e))?new lI(i[1],i[2],i[3],1):(i=a6t.exec(e))?new lI(i[1]*255/100,i[2]*255/100,i[3]*255/100,1):(i=s6t.exec(e))?YM(i[1],i[2],i[3],i[4]):(i=I6t.exec(e))?YM(i[1]*255/100,i[2]*255/100,i[3]*255/100,i[4]):(i=l6t.exec(e))?dke(i[1],i[2]/100,i[3]/100,1):(i=C6t.exec(e))?dke(i[1],i[2]/100,i[3]/100,i[4]):Ike.hasOwnProperty(e)?cke(Ike[e]):e==="transparent"?new lI(NaN,NaN,NaN,0):null}function cke(e){return new lI(e>>16&255,e>>8&255,e&255,1)}function YM(e,i,n,r){return r<=0&&(e=i=n=NaN),new lI(e,i,n,r)}function lOe(e){return e instanceof Vw||(e=uv(e)),e?(e=e.rgb(),new lI(e.r,e.g,e.b,e.opacity)):new lI}function NS(e,i,n,r){return arguments.length===1?lOe(e):new lI(e,i,n,r??1)}function lI(e,i,n,r){this.r=+e,this.g=+i,this.b=+n,this.opacity=+r}bP(lI,NS,AIe(Vw,{brighter:function(e){return e=e==null?WS:Math.pow(WS,e),new lI(this.r*e,this.g*e,this.b*e,this.opacity)},darker:function(e){return e=e==null?Av:Math.pow(Av,e),new lI(this.r*e,this.g*e,this.b*e,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Ake,formatHex:Ake,formatRgb:uke,toString:uke}));function Ake(){return"#"+Dq(this.r)+Dq(this.g)+Dq(this.b)}function uke(){var e=this.opacity;return e=isNaN(e)?1:Math.max(0,Math.min(1,e)),(e===1?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(e===1?")":", "+e+")")}function Dq(e){return e=Math.max(0,Math.min(255,Math.round(e)||0)),(e<16?"0":"")+e.toString(16)}function dke(e,i,n,r){return r<=0?e=i=n=NaN:n<=0||n>=1?e=i=NaN:i<=0&&(e=NaN),new ku(e,i,n,r)}function COe(e){if(e instanceof ku)return new ku(e.h,e.s,e.l,e.opacity);if(e instanceof Vw||(e=uv(e)),!e)return new ku;if(e instanceof ku)return e;e=e.rgb();var i=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(i,n,r),l=Math.max(i,n,r),c=NaN,u=l-o,f=(l+o)/2;return u?(i===l?c=(n-r)/u+(n0&&f<1?0:c,new ku(c,u,f,e.opacity)}function A6t(e,i,n,r){return arguments.length===1?COe(e):new ku(e,i,n,r??1)}function ku(e,i,n,r){this.h=+e,this.s=+i,this.l=+n,this.opacity=+r}bP(ku,A6t,AIe(Vw,{brighter:function(e){return e=e==null?WS:Math.pow(WS,e),new ku(this.h,this.s,this.l*e,this.opacity)},darker:function(e){return e=e==null?Av:Math.pow(Av,e),new ku(this.h,this.s,this.l*e,this.opacity)},rgb:function(){var e=this.h%360+(this.h<0)*360,i=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*i,o=2*n-r;return new lI(Mq(e>=240?e-240:e+120,o,r),Mq(e,o,r),Mq(e<120?e+240:e-120,o,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var e=this.opacity;return e=isNaN(e)?1:Math.max(0,Math.min(1,e)),(e===1?"hsl(":"hsla(")+(this.h||0)+", "+(this.s||0)*100+"%, "+(this.l||0)*100+"%"+(e===1?")":", "+e+")")}}));function Mq(e,i,n){return(e<60?i+(n-i)*e/60:e<180?n:e<240?i+(n-i)*(240-e)/60:i)*255}const u6t=Math.PI/180,d6t=180/Math.PI;var cOe=-.14861,uIe=1.78277,dIe=-.29227,yP=-.90649,mH=1.97294,hke=mH*yP,fke=mH*uIe,mke=uIe*dIe-yP*cOe;function h6t(e){if(e instanceof My)return new My(e.h,e.s,e.l,e.opacity);e instanceof lI||(e=lOe(e));var i=e.r/255,n=e.g/255,r=e.b/255,o=(mke*r+hke*i-fke*n)/(mke+hke-fke),l=r-o,c=(mH*(n-o)-dIe*l)/yP,u=Math.sqrt(c*c+l*l)/(mH*o*(1-o)),f=u?Math.atan2(c,l)*d6t-120:NaN;return new My(f<0?f+360:f,u,o,e.opacity)}function Xp(e,i,n,r){return arguments.length===1?h6t(e):new My(e,i,n,r??1)}function My(e,i,n,r){this.h=+e,this.s=+i,this.l=+n,this.opacity=+r}bP(My,Xp,AIe(Vw,{brighter:function(e){return e=e==null?WS:Math.pow(WS,e),new My(this.h,this.s,this.l*e,this.opacity)},darker:function(e){return e=e==null?Av:Math.pow(Av,e),new My(this.h,this.s,this.l*e,this.opacity)},rgb:function(){var e=isNaN(this.h)?0:(this.h+120)*u6t,i=+this.l,n=isNaN(this.s)?0:this.s*i*(1-i),r=Math.cos(e),o=Math.sin(e);return new lI(255*(i+n*(cOe*r+uIe*o)),255*(i+n*(dIe*r+yP*o)),255*(i+n*(mH*r)),this.opacity)}}));function AOe(e,i){return ei?1:e>=i?0:NaN}function hIe(e){let i=e,n=e;e.length===1&&(i=(c,u)=>e(c)-u,n=f6t(e));function r(c,u,f,m){for(f==null&&(f=0),m==null&&(m=c.length);f>>1;n(c[p],u)<0?f=p+1:m=p}return f}function o(c,u,f,m){for(f==null&&(f=0),m==null&&(m=c.length);f>>1;n(c[p],u)>0?m=p:f=p+1}return f}function l(c,u,f,m){f==null&&(f=0),m==null&&(m=c.length);const p=r(c,u,f,m-1);return p>f&&i(c[p-1],u)>-i(c[p],u)?p-1:p}return{left:r,center:l,right:o}}function f6t(e){return(i,n)=>AOe(e(i),n)}function m6t(e){return e===null?NaN:+e}const p6t=hIe(AOe),b6t=p6t.right;hIe(m6t).center;const y6t=b6t;let v6t=class extends Map{constructor(i,n=G6t){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),i!=null)for(const[r,o]of i)this.set(r,o)}get(i){return super.get(pke(this,i))}has(i){return super.has(pke(this,i))}set(i,n){return super.set(Z6t(this,i),n)}delete(i){return super.delete(B6t(this,i))}};function pke({_intern:e,_key:i},n){const r=i(n);return e.has(r)?e.get(r):n}function Z6t({_intern:e,_key:i},n){const r=i(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function B6t({_intern:e,_key:i},n){const r=i(n);return e.has(r)&&(n=e.get(n),e.delete(r)),n}function G6t(e){return e!==null&&typeof e=="object"?e.valueOf():e}function bke(e){return e}function vP(e,...i){return S6t(e,bke,bke,i)}function S6t(e,i,n,r){return function o(l,c){if(c>=r.length)return n(l);const u=new v6t,f=r[c++];let m=-1;for(const p of l){const v=f(p,++m,l),B=u.get(v);B?B.push(p):u.set(v,[p])}for(const[p,v]of u)u.set(p,o(v,c));return i(u)}(e,0)}var Cre=Math.sqrt(50),cre=Math.sqrt(10),Are=Math.sqrt(2);function w6t(e,i,n){var r,o=-1,l,c,u;if(i=+i,e=+e,n=+n,e===i&&n>0)return[e];if((r=i0){let f=Math.round(e/u),m=Math.round(i/u);for(f*ui&&--m,c=new Array(l=m-f+1);++oi&&--m,c=new Array(l=m-f+1);++o=0?(l>=Cre?10:l>=cre?5:l>=Are?2:1)*Math.pow(10,o):-Math.pow(10,-o)/(l>=Cre?10:l>=cre?5:l>=Are?2:1)}function T6t(e,i,n){var r=Math.abs(i-e)/Math.max(0,n),o=Math.pow(10,Math.floor(Math.log(r)/Math.LN10)),l=r/o;return l>=Cre?o*=10:l>=cre?o*=5:l>=Are&&(o*=2),i=r)&&(n=r);else{let r=-1;for(let o of e)(o=i(o,++r,e))!=null&&(n=o)&&(n=o)}return n}function mY(e,i){let n;if(i===void 0)for(const r of e)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let o of e)(o=i(o,++r,e))!=null&&(n>o||n===void 0&&o>=o)&&(n=o)}return n}function R6t(e,i,n){e=+e,i=+i,n=(o=arguments.length)<2?(i=e,e=0,1):o<3?1:+n;for(var r=-1,o=Math.max(0,Math.ceil((i-e)/n))|0,l=new Array(o);++r1;){for(let u=0;u1;o--,l--){const c=[];for(let u=0,f;u"u")e=.5;else if(e===0||e===1)return e;const n=BC(e,i)+BC(1-e,i),r=n-1;return YV(r/n)},projectionratio:function(e,i){if(i!==2&&i!==3)return!1;if(typeof e>"u")e=.5;else if(e===0||e===1)return e;const n=BC(1-e,i),r=BC(e,i)+n;return n/r},lli8:function(e,i,n,r,o,l,c,u){const f=(e*r-i*n)*(o-c)-(e-n)*(o*u-l*c),m=(e*r-i*n)*(l-u)-(i-r)*(o*u-l*c),p=(e-n)*(l-u)-(i-r)*(o-c);return p==0?!1:{x:f/p,y:m/p}},lli4:function(e,i,n,r){const o=e.x,l=e.y,c=i.x,u=i.y,f=n.x,m=n.y,p=r.x,v=r.y;return Ai.lli8(o,l,c,u,f,m,p,v)},lli:function(e,i){return Ai.lli4(e,e.c,i,i.c)},makeline:function(e,i){const n=e.x,r=e.y,o=i.x,l=i.y,c=(o-n)/3,u=(l-r)/3;return new po(n,r,n+c,r+u,n+2*c,r+2*u,o,l)},findbbox:function(e){let i=Fq,n=Fq,r=Yq,o=Yq;return e.forEach(function(l){const c=l.bbox();i>c.x.min&&(i=c.x.min),n>c.y.min&&(n=c.y.min),r0&&(p.c1=f,p.c2=m,p.s1=e,p.s2=n,l.push(p))})}),l},makeshape:function(e,i,n){const r=i.points.length,o=e.points.length,l=Ai.makeline(i.points[r-1],e.points[0]),c=Ai.makeline(e.points[o-1],i.points[0]),u={startcap:l,forward:e,back:i,endcap:c,bbox:Ai.findbbox([l,e,i,c])};return u.intersections=function(f){return Ai.shapeintersections(u,u.bbox,f,f.bbox,n)},u},getminmax:function(e,i,n){if(!n)return{min:0,max:0};let r=Fq,o=Yq,l,c;n.indexOf(0)===-1&&(n=[0].concat(n)),n.indexOf(1)===-1&&n.push(1);for(let u=0,f=n.length;uo&&(o=c[i]);return{min:r,mid:(r+o)/2,max:o,size:o-r}},align:function(e,i){const n=i.p1.x,r=i.p1.y,o=-KV(i.p2.y-r,i.p2.x-n),l=function(c){return{x:(c.x-n)*dh(o)-(c.y-r)*gG(o),y:(c.x-n)*gG(o)+(c.y-r)*dh(o)}};return e.map(l)},roots:function(e,i){i=i||{p1:{x:0,y:0},p2:{x:1,y:0}};const n=e.length-1,r=Ai.align(e,i),o=function(O){return 0<=O&&O<=1};if(n===2){const O=r[0].y,Q=r[1].y,X=r[2].y,$=O-2*Q+X;if($!==0){const ee=-Em(Q*Q-O*X),ne=-O+Q,ge=-(ee+ne)/$,Ae=-(-ee+ne)/$;return[ge,Ae].filter(o)}else if(Q!==X&&$===0)return[(2*Q-X)/(2*Q-2*X)].filter(o);return[]}const l=r[0].y,c=r[1].y,u=r[2].y,f=r[3].y;let m=-l+3*c-3*u+f,p=3*l-6*c+3*u,v=-3*l+3*c,B=l;if(Ai.approximately(m,0)){if(Ai.approximately(p,0))return Ai.approximately(v,0)?[]:[-B/v].filter(o);const O=Em(v*v-4*p*B),Q=2*p;return[(O-v)/Q,(-v-O)/Q].filter(o)}p/=m,v/=m,B/=m;const G=(3*v-p*p)/3,T=G/3,V=(2*p*p*p-9*p*v+27*B)/27,E=V/2,W=E*E+T*T*T;let x,k,F,Y,L;if(W<0){const O=-G/3,Q=O*O*O,X=Em(Q),$=-V/(2*X),ee=$<-1?-1:$>1?1:$,ne=V6t(ee),ge=_V(X),Ae=2*ge;return F=Ae*dh(ne/3)-p/3,Y=Ae*dh((ne+KM)/3)-p/3,L=Ae*dh((ne+2*KM)/3)-p/3,[F,Y,L].filter(o)}else{if(W===0)return x=E<0?_V(-E):-_V(E),F=2*x-p/3,Y=-x-p/3,[F,Y].filter(o);{const O=Em(W);return x=_V(-E+O),k=_V(E+O),[x-k-p/3].filter(o)}}},droots:function(e){if(e.length===3){const i=e[0],n=e[1],r=e[2],o=i-2*n+r;if(o!==0){const l=-Em(n*n-i*r),c=-i+n,u=-(l+c)/o,f=-(-l+c)/o;return[u,f]}else if(n!==r&&o===0)return[(2*n-r)/(2*(n-r))];return[]}if(e.length===2){const i=e[0],n=e[1];return i!==n?[i/(i-n)]:[]}return[]},curvature:function(e,i,n,r,o){let l,c,u,f,m=0,p=0;const v=Ai.compute(e,i),B=Ai.compute(e,n),G=v.x*v.x+v.y*v.y;if(r?(l=Em(BC(v.y*B.z-B.y*v.z,2)+BC(v.z*B.x-B.z*v.x,2)+BC(v.x*B.y-B.x*v.y,2)),c=BC(G+v.z*v.z,3/2)):(l=v.x*B.y-v.y*B.x,c=BC(G,3/2)),l===0||c===0)return{k:0,r:0};if(m=l/c,p=c/l,!o){const T=Ai.curvature(e-.001,i,n,r,!0).k,V=Ai.curvature(e+.001,i,n,r,!0).k;f=(V-m+(m-T))/2,u=(YV(V-m)+YV(m-T))/2}return{k:m,r:p,dk:f,adk:u}},inflections:function(e){if(e.length<4)return[];const i=Ai.align(e,{p1:e[0],p2:e.slice(-1)[0]}),n=i[2].x*i[1].y,r=i[3].x*i[1].y,o=i[1].x*i[2].y,l=i[3].x*i[2].y,c=18*(-3*n+2*r+3*o-l),u=18*(3*n-r-3*o),f=18*(o-n);if(Ai.approximately(c,0)){if(!Ai.approximately(u,0)){let B=-f/u;if(0<=B&&B<=1)return[B]}return[]}const m=u*u-4*c*f,p=Math.sqrt(m),v=2*c;return Ai.approximately(v,0)?[]:[(p-u)/v,-(u+p)/v].filter(function(B){return 0<=B&&B<=1})},bboxoverlap:function(e,i){const n=["x","y"],r=n.length;for(let o=0,l,c,u,f;o=f)return!1;return!0},expandbox:function(e,i){i.x.mine.x.max&&(e.x.max=i.x.max),i.y.max>e.y.max&&(e.y.max=i.y.max),i.z&&i.z.max>e.z.max&&(e.z.max=i.z.max),e.x.mid=(e.x.min+e.x.max)/2,e.y.mid=(e.y.min+e.y.max)/2,e.z&&(e.z.mid=(e.z.min+e.z.max)/2),e.x.size=e.x.max-e.x.min,e.y.size=e.y.max-e.y.min,e.z&&(e.z.size=e.z.max-e.z.min)},pairiteration:function(e,i,n){const r=e.bbox(),o=i.bbox(),l=1e5,c=n||.5;if(r.x.size+r.y.sizeL||L>O)&&(Y+=KM),Y>O&&(Q=O,O=Y,Y=Q)):O4){if(arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");o=!0}}else if(l!==6&&l!==8&&l!==9&&l!==12&&arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const c=this._3d=!o&&(l===9||l===12)||i&&i[0]&&typeof i[0].z<"u",u=this.points=[];for(let B=0,G=c?3:2;BPV(B.y)>1e-4),this._lut=[],this._t1=0,this._t2=1,this.update()}static quadraticFromPoints(i,n,r,o){if(typeof o>"u"&&(o=.5),o===0)return new po(n,n,r);if(o===1)return new po(i,n,n);const l=po.getABC(2,i,n,r,o);return new po(i,l.A,r)}static cubicFromPoints(i,n,r,o,l){typeof o>"u"&&(o=.5);const c=po.getABC(3,i,n,r,o);typeof l>"u"&&(l=Ai.dist(n,c.C));const u=l*(1-o)/o,f=Ai.dist(i,r),m=(r.x-i.x)/f,p=(r.y-i.y)/f,v=l*m,B=l*p,G=u*m,T=u*p,V={x:n.x-v,y:n.y-B},E={x:n.x+G,y:n.y+T},W=c.A,x={x:W.x+(V.x-W.x)/(1-o),y:W.y+(V.y-W.y)/(1-o)},k={x:W.x+(E.x-W.x)/o,y:W.y+(E.y-W.y)/o},F={x:i.x+(x.x-i.x)/o,y:i.y+(x.y-i.y)/o},Y={x:r.x+(k.x-r.x)/(1-o),y:r.y+(k.y-r.y)/(1-o)};return new po(i,F,Y,r)}static getUtils(){return Ai}getUtils(){return po.getUtils()}static get PolyBezier(){return VK}valueOf(){return this.toString()}toString(){return Ai.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const i=this.points,n=i[0].x,r=i[0].y,o=["M",n,r,this.order===2?"Q":"C"];for(let l=1,c=i.length;l0}length(){return Ai.length(this.derivative.bind(this))}static getABC(i=2,n,r,o,l=.5){const c=Ai.projectionratio(l,i),u=1-c,f={x:c*n.x+u*o.x,y:c*n.y+u*o.y},m=Ai.abcratio(l,i);return{A:{x:r.x+(r.x-f.x)/m,y:r.y+(r.y-f.y)/m},B:r,C:f,S:n,E:o}}getABC(i,n){n=n||this.get(i);let r=this.points[0],o=this.points[this.order];return po.getABC(this.order,r,n,o,i)}getLUT(i){if(this.verify(),i=i||100,this._lut.length===i)return this._lut;this._lut=[],i--;for(let n=0,r,o;n1?1:v,B=this.compute(v),B.t=v,B.d=m,B}get(i){return this.compute(i)}point(i){return this.points[i]}compute(i){return this.ratios?Ai.computeWithRatios(i,this.points,this.ratios,this._3d):Ai.compute(i,this.points,this._3d,this.ratios)}raise(){const i=this.points,n=[i[0]],r=i.length;for(let o=1,l,c;o1;){r=[];for(let c=0,u,f=n.length-1;c=0&&c<=1}),n=n.concat(i[r].sort(Ai.numberSort))}.bind(this)),i.values=n.sort(Ai.numberSort).filter(function(r,o){return n.indexOf(r)===o}),i}bbox(){const i=this.extrema(),n={};return this.dims.forEach(function(r){n[r]=Ai.getminmax(this,r,i[r])}.bind(this)),n}overlaps(i){const n=this.bbox(),r=i.bbox();return Ai.bboxoverlap(n,r)}offset(i,n){if(typeof n<"u"){const r=this.get(i),o=this.normal(i),l={c:r,n:o,x:r.x+o.x*n,y:r.y+o.y*n};return this._3d&&(l.z=r.z+o.z*n),l}if(this._linear){const r=this.normal(0),o=this.points.map(function(l){const c={x:l.x+i*r.x,y:l.y+i*r.y};return l.z&&r.z&&(c.z=l.z+i*r.z),c});return[new po(o)]}return this.reduce().map(function(r){return r._linear?r.offset(i)[0]:r.scale(i)})}simple(){if(this.order===3){const o=Ai.angle(this.points[0],this.points[3],this.points[1]),l=Ai.angle(this.points[0],this.points[3],this.points[2]);if(o>0&&l<0||o<0&&l>0)return!1}const i=this.normal(0),n=this.normal(1);let r=i.x*n.x+i.y*n.y;return this._3d&&(r+=i.z*n.z),PV(k6t(r)){if(n===2&&v)return;const B=m[v*n],G=this.derivative(v),T={x:B.x+G.x,y:B.y+G.y};m[v+1]=Ai.lli4(B,T,p,f[v+1])}),new po(m))}outline(i,n,r,o){n=typeof n>"u"?i:n;const l=this.reduce(),c=l.length,u=[];let f=[],m,p=0,v=this.length();const B=typeof r<"u"&&typeof o<"u";function G(Y,L,O,Q,X){return function($){const ee=Q/O,ne=(Q+X)/O,ge=L-Y;return Ai.map($,0,1,Y+ee*ge,Y+ne*ge)}}l.forEach(function(Y){const L=Y.length();B?(u.push(Y.scale(G(i,r,v,p,L))),f.push(Y.scale(G(-n,-o,v,p,L)))):(u.push(Y.scale(i)),f.push(Y.scale(-n))),p+=L}),f=f.map(function(Y){return m=Y.points,m[3]?Y.points=[m[3],m[2],m[1],m[0]]:Y.points=[m[2],m[1],m[0]],Y}).reverse();const T=u[0].points[0],V=u[c-1].points[u[c-1].points.length-1],E=f[c-1].points[f[c-1].points.length-1],W=f[0].points[0],x=Ai.makeline(E,T),k=Ai.makeline(V,W),F=[x].concat(u).concat([k]).concat(f);return F.length,new VK(F)}outlineshapes(i,n,r){n=n||i;const o=this.outline(i,n).curves,l=[];for(let c=1,u=o.length;c1,f.endcap.virtual=c{var u=this.get(c);return Ai.between(u.x,n,o)&&Ai.between(u.y,r,l)})}selfintersects(i){const n=this.reduce(),r=n.length-2,o=[];for(let l=0,c,u,f;l0&&(l=l.concat(u))}),l}arcs(i){return i=i||.5,this._iterate(i,[])}_error(i,n,r,o){const l=(o-r)/4,c=this.get(r+l),u=this.get(o-l),f=Ai.dist(i,n),m=Ai.dist(i,c),p=Ai.dist(i,u);return PV(m-f)+PV(p-f)}_iterate(i,n){let r=0,o=1,l;do{l=0,o=1;let c=this.get(r),u,f,m,p,v=!1,B=!1,G,T=o,V=1;do if(B=v,p=m,T=(r+o)/2,u=this.get(T),f=this.get(o),m=Ai.getccenter(c,u,f),m.interval={start:r,end:o},v=this._error(m,c,r,o)<=i,G=B&&!v,G||(V=o),v){if(o>=1){if(m.interval.end=V=1,p=m,o>1){let W={x:m.x+m.r*W6t(m.e),y:m.y+m.r*N6t(m.e)};m.e+=Ai.angle({x:m.x,y:m.y},W,this.get(1))}break}o=o+(o-r)/2}else o=T;while(!G&&l++<100);if(l>=100)break;p=p||m,n.push(p),r=V}while(o<1);return n}}function fIe(e,i){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(i).domain(e);break}return this}function x6t(e,i){switch(arguments.length){case 0:break;case 1:{typeof e=="function"?this.interpolator(e):this.range(e);break}default:{this.domain(e),typeof i=="function"?this.interpolator(i):this.range(i);break}}return this}const Bke=Symbol("implicit");function EK(){var e=new Map,i=[],n=[],r=Bke;function o(l){var c=l+"",u=e.get(c);if(!u){if(r!==Bke)return r;e.set(c,u=i.push(l))}return n[(u-1)%n.length]}return o.domain=function(l){if(!arguments.length)return i.slice();i=[],e=new Map;for(const c of l){const u=c+"";e.has(u)||e.set(u,i.push(c))}return o},o.range=function(l){return arguments.length?(n=Array.from(l),o):n.slice()},o.unknown=function(l){return arguments.length?(r=l,o):r},o.copy=function(){return EK(i,n).unknown(r)},fIe.apply(o,arguments),o}function hOe(){var e=EK().unknown(void 0),i=e.domain,n=e.range,r=0,o=1,l,c,u=!1,f=0,m=0,p=.5;delete e.unknown;function v(){var B=i().length,G=o()=>e;function D6t(e,i){return function(n){return e+n*i}}function M6t(e,i,n){return e=Math.pow(e,n),i=Math.pow(i,n)-e,n=1/n,function(r){return Math.pow(e+r*i,n)}}function F6t(e){return(e=+e)==1?fOe:function(i,n){return n-i?M6t(i,n,e):mIe(isNaN(i)?n:i)}}function fOe(e,i){var n=i-e;return n?D6t(e,n):mIe(isNaN(e)?i:e)}const Gke=function e(i){var n=F6t(i);function r(o,l){var c=n((o=NS(o)).r,(l=NS(l)).r),u=n(o.g,l.g),f=n(o.b,l.b),m=fOe(o.opacity,l.opacity);return function(p){return o.r=c(p),o.g=u(p),o.b=f(p),o.opacity=m(p),o+""}}return r.gamma=e,r}(1);function Y6t(e,i){i||(i=[]);var n=e?Math.min(i.length,e.length):0,r=i.slice(),o;return function(l){for(o=0;on&&(l=i.slice(n,l),u[c]?u[c]+=l:u[++c]=l),(r=r[0])===(o=o[0])?u[c]?u[c]+=o:u[++c]=o:(u[++c]=null,f.push({i:c,x:HK(r,o)})),n=Kq.lastIndex;return ni&&(n=e,e=i,i=n),function(r){return Math.max(e,Math.min(i,r))}}function $6t(e,i,n){var r=e[0],o=e[1],l=i[0],c=i[1];return o2?q6t:$6t,f=m=null,v}function v(B){return B==null||isNaN(B=+B)?l:(f||(f=u(e.map(r),i,n)))(r(c(B)))}return v.invert=function(B){return c(o((m||(m=u(i,e.map(r),HK)))(B)))},v.domain=function(B){return arguments.length?(e=Array.from(B,Q6t),p()):e.slice()},v.range=function(B){return arguments.length?(i=Array.from(B),p()):i.slice()},v.rangeRound=function(B){return i=Array.from(B),n=mOe,p()},v.clamp=function(B){return arguments.length?(c=B?!0:tp,p()):c!==tp},v.interpolate=function(B){return arguments.length?(n=B,p()):n},v.unknown=function(B){return arguments.length?(l=B,v):l},function(B,G){return r=B,o=G,p()}}function i8t(){return t8t()(tp,tp)}function n8t(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function WK(e,i){if((n=(e=i?e.toExponential(i-1):e.toExponential()).indexOf("e"))<0)return null;var n,r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function kS(e){return e=WK(Math.abs(e)),e?e[1]:NaN}function r8t(e,i){return function(n,r){for(var o=n.length,l=[],c=0,u=e[0],f=0;o>0&&u>0&&(f+u+1>r&&(u=Math.max(1,r-f)),l.push(n.substring(o-=u,o+u)),!((f+=u+1)>r));)u=e[c=(c+1)%e.length];return l.reverse().join(i)}}function g8t(e){return function(i){return i.replace(/[0-9]/g,function(n){return e[+n]})}}var o8t=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function NK(e){if(!(i=o8t.exec(e)))throw new Error("invalid format: "+e);var i;return new pIe({fill:i[1],align:i[2],sign:i[3],symbol:i[4],zero:i[5],width:i[6],comma:i[7],precision:i[8]&&i[8].slice(1),trim:i[9],type:i[10]})}NK.prototype=pIe.prototype;function pIe(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}pIe.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function a8t(e){e:for(var i=e.length,n=1,r=-1,o;n0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(o+1):e}var pOe;function s8t(e,i){var n=WK(e,i);if(!n)return e+"";var r=n[0],o=n[1],l=o-(pOe=Math.max(-8,Math.min(8,Math.floor(o/3)))*3)+1,c=r.length;return l===c?r:l>c?r+new Array(l-c+1).join("0"):l>0?r.slice(0,l)+"."+r.slice(l):"0."+new Array(1-l).join("0")+WK(e,Math.max(0,i+l-1))[0]}function wke(e,i){var n=WK(e,i);if(!n)return e+"";var r=n[0],o=n[1];return o<0?"0."+new Array(-o).join("0")+r:r.length>o+1?r.slice(0,o+1)+"."+r.slice(o+1):r+new Array(o-r.length+2).join("0")}const Tke={"%":(e,i)=>(e*100).toFixed(i),b:e=>Math.round(e).toString(2),c:e=>e+"",d:n8t,e:(e,i)=>e.toExponential(i),f:(e,i)=>e.toFixed(i),g:(e,i)=>e.toPrecision(i),o:e=>Math.round(e).toString(8),p:(e,i)=>wke(e*100,i),r:wke,s:s8t,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function Rke(e){return e}var Vke=Array.prototype.map,Eke=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function I8t(e){var i=e.grouping===void 0||e.thousands===void 0?Rke:r8t(Vke.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",r=e.currency===void 0?"":e.currency[1]+"",o=e.decimal===void 0?".":e.decimal+"",l=e.numerals===void 0?Rke:g8t(Vke.call(e.numerals,String)),c=e.percent===void 0?"%":e.percent+"",u=e.minus===void 0?"−":e.minus+"",f=e.nan===void 0?"NaN":e.nan+"";function m(v){v=NK(v);var B=v.fill,G=v.align,T=v.sign,V=v.symbol,E=v.zero,W=v.width,x=v.comma,k=v.precision,F=v.trim,Y=v.type;Y==="n"?(x=!0,Y="g"):Tke[Y]||(k===void 0&&(k=12),F=!0,Y="g"),(E||B==="0"&&G==="=")&&(E=!0,B="0",G="=");var L=V==="$"?n:V==="#"&&/[boxX]/.test(Y)?"0"+Y.toLowerCase():"",O=V==="$"?r:/[%p]/.test(Y)?c:"",Q=Tke[Y],X=/[defgprs%]/.test(Y);k=k===void 0?6:/[gprs]/.test(Y)?Math.max(1,Math.min(21,k)):Math.max(0,Math.min(20,k));function $(ee){var ne=L,ge=O,Ae,_,de;if(Y==="c")ge=Q(ee)+ge,ee="";else{ee=+ee;var Ze=ee<0||1/ee<0;if(ee=isNaN(ee)?f:Q(Math.abs(ee),k),F&&(ee=a8t(ee)),Ze&&+ee==0&&T!=="+"&&(Ze=!1),ne=(Ze?T==="("?T:u:T==="-"||T==="("?"":T)+ne,ge=(Y==="s"?Eke[8+pOe/3]:"")+ge+(Ze&&T==="("?")":""),X){for(Ae=-1,_=ee.length;++Ae<_;)if(de=ee.charCodeAt(Ae),48>de||de>57){ge=(de===46?o+ee.slice(Ae+1):ee.slice(Ae))+ge,ee=ee.slice(0,Ae);break}}}x&&!E&&(ee=i(ee,1/0));var me=ne.length+ee.length+ge.length,be=me>1)+ne+ee+ge+be.slice(me);break;default:ee=be+ne+ee+ge;break}return l(ee)}return $.toString=function(){return v+""},$}function p(v,B){var G=m((v=NK(v),v.type="f",v)),T=Math.max(-8,Math.min(8,Math.floor(kS(B)/3)))*3,V=Math.pow(10,-T),E=Eke[8+T/3];return function(W){return G(V*W)+E}}return{format:m,formatPrefix:p}}var _M,bOe,yOe;l8t({thousands:",",grouping:[3],currency:["$",""]});function l8t(e){return _M=I8t(e),bOe=_M.format,yOe=_M.formatPrefix,_M}function C8t(e){return Math.max(0,-kS(Math.abs(e)))}function c8t(e,i){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(kS(i)/3)))*3-kS(Math.abs(e)))}function A8t(e,i){return e=Math.abs(e),i=Math.abs(i)-e,Math.max(0,kS(i)-kS(e))+1}function u8t(e,i,n,r){var o=T6t(e,i,n),l;switch(r=NK(r??",f"),r.type){case"s":{var c=Math.max(Math.abs(e),Math.abs(i));return r.precision==null&&!isNaN(l=c8t(o,c))&&(r.precision=l),yOe(r,c)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(l=A8t(o,Math.max(Math.abs(e),Math.abs(i))))&&(r.precision=l-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(l=C8t(o))&&(r.precision=l-(r.type==="%")*2);break}}return bOe(r)}function vOe(e){var i=e.domain;return e.ticks=function(n){var r=i();return w6t(r[0],r[r.length-1],n??10)},e.tickFormat=function(n,r){var o=i();return u8t(o[0],o[o.length-1],n??10,r)},e.nice=function(n){n==null&&(n=10);var r=i(),o=0,l=r.length-1,c=r[o],u=r[l],f,m,p=10;for(u0;){if(m=uOe(c,u,n),m===f)return r[o]=c,r[l]=u,i(r);if(m>0)c=Math.floor(c/m)*m,u=Math.ceil(u/m)*m;else if(m<0)c=Math.ceil(c*m)/m,u=Math.floor(u*m)/m;else break;f=m}return e},e}function dv(){var e=i8t();return e.copy=function(){return e8t(e,dv())},fIe.apply(e,arguments),vOe(e)}function d8t(){var e=0,i=1,n,r,o,l,c=tp,u=!1,f;function m(v){return v==null||isNaN(v=+v)?f:c(o===0?.5:(v=(l(v)-n)*o,u?Math.max(0,Math.min(1,v)):v))}m.domain=function(v){return arguments.length?([e,i]=v,n=l(e=+e),r=l(i=+i),o=n===r?0:1/(r-n),m):[e,i]},m.clamp=function(v){return arguments.length?(u=!!v,m):u},m.interpolator=function(v){return arguments.length?(c=v,m):c};function p(v){return function(B){var G,T;return arguments.length?([G,T]=B,c=v(G,T),m):[c(0),c(1)]}}return m.range=p(ZP),m.rangeRound=p(mOe),m.unknown=function(v){return arguments.length?(f=v,m):f},function(v){return l=v,n=v(e),r=v(i),o=n===r?0:1/(r-n),m}}function h8t(e,i){return i.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown())}function ZOe(){var e=vOe(d8t()(tp));return e.copy=function(){return h8t(e,ZOe())},x6t.apply(e,arguments)}var f8t=typeof global=="object"&&global&&global.Object===Object&&global;const BOe=f8t;var m8t=typeof self=="object"&&self&&self.Object===Object&&self,p8t=BOe||m8t||Function("return this")();const bd=p8t;var b8t=bd.Symbol;const ld=b8t;var GOe=Object.prototype,y8t=GOe.hasOwnProperty,v8t=GOe.toString,OV=ld?ld.toStringTag:void 0;function Z8t(e){var i=y8t.call(e,OV),n=e[OV];try{e[OV]=void 0;var r=!0}catch{}var o=v8t.call(e);return r&&(i?e[OV]=n:delete e[OV]),o}var B8t=Object.prototype,G8t=B8t.toString;function S8t(e){return G8t.call(e)}var w8t="[object Null]",T8t="[object Undefined]",Hke=ld?ld.toStringTag:void 0;function Ew(e){return e==null?e===void 0?T8t:w8t:Hke&&Hke in Object(e)?Z8t(e):S8t(e)}function xp(e){return e!=null&&typeof e=="object"}var R8t="[object Symbol]";function BP(e){return typeof e=="symbol"||xp(e)&&Ew(e)==R8t}function SOe(e,i){for(var n=-1,r=e==null?0:e.length,o=Array(r);++n-1}var p$t=9007199254740991,b$t=/^(?:0|[1-9]\d*)$/;function bIe(e,i){var n=typeof e;return i=i??p$t,!!i&&(n=="number"||n!="symbol"&&b$t.test(e))&&e>-1&&e%1==0&&e-1&&e%1==0&&e<=Z$t}function vIe(e){return e!=null&&yIe(e.length)&&!TOe(e)}function B$t(e,i,n){if(!af(n))return!1;var r=typeof i;return(r=="number"?vIe(n)&&bIe(i,n.length):r=="string"&&i in n)?GP(n[i],e):!1}var G$t=Object.prototype;function ZIe(e){var i=e&&e.constructor,n=typeof i=="function"&&i.prototype||G$t;return e===n}function S$t(e,i){for(var n=-1,r=Array(e);++n-1}function Fqt(e,i){var n=this.__data__,r=wP(n,e);return r<0?(++this.size,n.push([e,i])):n[r][1]=i,this}function ff(e){var i=-1,n=e==null?0:e.length;for(this.clear();++i=i?e:i)),e}function gei(){this.__data__=new ff,this.size=0}function oei(e){var i=this.__data__,n=i.delete(e);return this.size=i.size,n}function aei(e){return this.__data__.get(e)}function sei(e){return this.__data__.has(e)}var Iei=200;function lei(e,i){var n=this.__data__;if(n instanceof ff){var r=n.__data__;if(!bH||r.lengthu))return!1;var m=l.get(e),p=l.get(i);if(m&&p)return m==i&&p==e;var v=-1,B=!0,G=n&jti?new vH:void 0;for(l.set(e,i),l.set(i,e);++v=Oii){var m=i?null:zii(e);if(m)return VIe(m);c=!1,o=jOe,f=new vH}else f=i?[]:u;e:for(;++r=1?(n=1,i-1):Math.floor(n*i),o=e[r],l=e[r+1],c=r>0?e[r-1]:2*o-l,u=r()=>e;function nLe(e,i){return function(n){return e+n*i}}function jii(e,i,n){return e=Math.pow(e,n),i=Math.pow(i,n)-e,n=1/n,function(r){return Math.pow(e+r*i,n)}}function $ii(e,i){var n=i-e;return n?nLe(e,n>180||n<-180?n-360*Math.round(n/360):n):HIe(isNaN(e)?i:e)}function qii(e){return(e=+e)==1?aS:function(i,n){return n-i?jii(i,n,e):HIe(isNaN(i)?n:i)}}function aS(e,i){var n=i-e;return n?nLe(e,n):HIe(isNaN(e)?i:e)}(function e(i){var n=qii(i);function r(o,l){var c=n((o=NS(o)).r,(l=NS(l)).r),u=n(o.g,l.g),f=n(o.b,l.b),m=aS(o.opacity,l.opacity);return function(p){return o.r=c(p),o.g=u(p),o.b=f(p),o.opacity=m(p),o+""}}return r.gamma=e,r})(1);function eni(e){return function(i){var n=i.length,r=new Array(n),o=new Array(n),l=new Array(n),c,u;for(c=0;ctni(e[e.length-1]);var ini=new Array(3).concat("ef8a62f7f7f767a9cf","ca0020f4a58292c5de0571b0","ca0020f4a582f7f7f792c5de0571b0","b2182bef8a62fddbc7d1e5f067a9cf2166ac","b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac","b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac","b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac","67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061","67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061").map(yd);const nni=Hw(ini);var rni=new Array(3).concat("fc8d59ffffbf99d594","d7191cfdae61abdda42b83ba","d7191cfdae61ffffbfabdda42b83ba","d53e4ffc8d59fee08be6f59899d5943288bd","d53e4ffc8d59fee08bffffbfe6f59899d5943288bd","d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd","d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd","9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2","9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2").map(yd);const gni=Hw(rni);var oni=new Array(3).concat("e0ecf49ebcda8856a7","edf8fbb3cde38c96c688419d","edf8fbb3cde38c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b").map(yd);const ani=Hw(oni);var sni=new Array(3).concat("fde0ddfa9fb5c51b8a","feebe2fbb4b9f768a1ae017e","feebe2fbb4b9f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a").map(yd);const Ini=Hw(sni);var lni=new Array(3).concat("fff7bcfec44fd95f0e","ffffd4fed98efe9929cc4c02","ffffd4fed98efe9929d95f0e993404","ffffd4fee391fec44ffe9929d95f0e993404","ffffd4fee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506").map(yd);const Cni=Hw(lni);var cni=new Array(3).concat("f0f0f0bdbdbd636363","f7f7f7cccccc969696525252","f7f7f7cccccc969696636363252525","f7f7f7d9d9d9bdbdbd969696636363252525","f7f7f7d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000").map(yd);const Ani=Hw(cni);function uni(e){return e=Math.max(0,Math.min(1,e)),"rgb("+Math.max(0,Math.min(255,Math.round(-4.54-e*(35.34-e*(2381.73-e*(6402.7-e*(7024.72-e*2710.57)))))))+", "+Math.max(0,Math.min(255,Math.round(32.49+e*(170.73+e*(52.82-e*(131.46-e*(176.58-e*67.37)))))))+", "+Math.max(0,Math.min(255,Math.round(81.24+e*(442.36-e*(2482.43-e*(6167.24-e*(6614.94-e*2475.67)))))))+")"}var dni=gLe(Xp(-100,.75,.35),Xp(80,1.5,.8));gLe(Xp(260,.75,.35),Xp(80,1.5,.8));Xp();function EP(e){var i=e.length;return function(n){return e[Math.max(0,Math.min(i-1,Math.floor(n*i)))]}}const oLe=EP(yd("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));EP(yd("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf"));EP(yd("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4"));EP(yd("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));window.higlassTracks=window.higlassTracks||{};window.higlassTracksByType=window.higlassTracksByType||{};window.higlassDataFetchersByType=window.higlassDataFetchersByType||{};const sXe=()=>Math.random().toString(36).substring(2,8),hni=(e,{force:i=!1}={})=>{let n=sXe();for(;window.higlassTracks[n];)n=sXe();e.name=n,window.higlassTracks[e.name]=e,window.higlassTracksByType[e.config.type]&&!i?console.warn(`A track with the same type (${e.config.type}) was already registered. To override it, set force to true.`):window.higlassTracksByType[e.config.type]=e},fni=(e,{force:i=!1}={})=>{window.higlassDataFetchersByType[e.config.type]&&!i?console.warn(`A data fetcher with the same type (${e.config.type}) was already registered. To override it, set force to true.`):window.higlassDataFetchersByType[e.config.type]=e},oG=(e,i={})=>{const{pluginType:n="track"}=i;n==="track"?hni(e,i):n==="dataFetcher"&&fni(e,i)};var GW={},bre={exports:{}},IXe=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(IXe){var lXe=new Uint8Array(16);bre.exports=function(){return IXe(lXe),lXe}}else{var CXe=new Array(16);bre.exports=function(){for(var i=0,n;i<16;i++)i&3||(n=Math.random()*4294967296),CXe[i]=n>>>((i&3)<<3)&255;return CXe}}var mni=bre.exports,aLe=[];for(var zM=0;zM<256;++zM)aLe[zM]=(zM+256).toString(16).substr(1);function pni(e,i){var n=i||0,r=aLe;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")}var bni=pni,yni=mni,vni=bni;function Zni(e,i,n){var r=i&&n||0;typeof e=="string"&&(i=e==="binary"?new Array(16):null,e=null),e=e||{};var o=e.random||(e.rng||yni)();if(o[6]=o[6]&15|64,o[8]=o[8]&63|128,i)for(var l=0;l<16;++l)i[r+l]=o[l];return i||vni(o)}var Bni=Zni,yre=[],sLe={};for(var aG=0;aG<256;aG++)yre[aG]=(aG+256).toString(16).substr(1),sLe[yre[aG]]=aG;function Gni(e,i,n){var r=i&&n||0,o=0;for(i=i||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(l){o<16&&(i[r+o++]=sLe[l])});o<16;)i[r+o++]=0;return i}function Sni(e,i){var n=i||0,r=yre;return r[e[n++]]+r[e[n++]]+r[e[n++]]+r[e[n++]]+"-"+r[e[n++]]+r[e[n++]]+"-"+r[e[n++]]+r[e[n++]]+"-"+r[e[n++]]+r[e[n++]]+"-"+r[e[n++]]+r[e[n++]]+r[e[n++]]+r[e[n++]]+r[e[n++]]+r[e[n++]]}var wni={parse:Gni,unparse:Sni},ILe=Bni,lLe=wni;GW.encode=function(e){var i=lLe.parse(e),n=new Buffer(i).toString("base64"),r=n.replace(/\+/g,"-").replace(/\//g,"_").substring(0,22);return r};GW.decode=function(e){var i=e.replace(/-/g,"+").replace(/_/g,"/")+"==";return lLe.unparse(new Buffer(i,"base64"))};GW.v4=function(){var e=ILe(null,new Buffer(16)),i=e.toString("base64"),n=i.replace(/\+/g,"-").replace(/\//g,"_").substring(0,22);return n};GW.nice=function(){var e=ILe(null,new Buffer(16));e[0]=e[0]&127;var i=e.toString("base64"),n=i.replace(/\+/g,"-").replace(/\//g,"_").substring(0,22);return n};var Tni=GW;const Rni=Al(Tni);var Vni=function(){function e(i,n){for(var r=0;r1?n-1:0),o=1;on;){if(r-n>600){var l=r-n+1,c=i-n+1,u=Math.log(l),f=.5*Math.exp(2*u/3),m=.5*Math.sqrt(u*f*(l-f)/l)*(c-l/2<0?-1:1),p=Math.max(n,Math.floor(i-c*f/l+m)),v=Math.min(r,Math.floor(i+(l-c)*f/l+m));CLe(e,i,p,v,o)}var B=e[i],G=n,T=r;for(LV(e,n,i),o(e[r],B)>0&&LV(e,n,r);G0;)T--}o(e[n],B)===0?LV(e,n,T):(T++,LV(e,T,r)),T<=i&&(n=T+1),i<=T&&(r=T-1)}}function LV(e,i,n){var r=e[i];e[i]=e[n],e[n]=r}function Fni(e,i){return ei?1:0}class Yni{constructor(i=9){this._maxEntries=Math.max(4,i),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(i){let n=this.data;const r=[];if(!LM(i,n))return r;const o=this.toBBox,l=[];for(;n;){for(let c=0;c=0&&l[n].children.length>this._maxEntries;)this._split(l,n),n--;this._adjustParentBBoxes(o,l,n)}_split(i,n){const r=i[n],o=r.children.length,l=this._minEntries;this._chooseSplitAxis(r,l,o);const c=this._chooseSplitIndex(r,l,o),u=SG(r.children.splice(c,r.children.length-c));u.height=r.height,u.leaf=r.leaf,sG(r,this.toBBox),sG(u,this.toBBox),n?i[n-1].children.push(u):this._splitRoot(r,u)}_splitRoot(i,n){this.data=SG([i,n]),this.data.height=i.height+1,this.data.leaf=!1,sG(this.data,this.toBBox)}_chooseSplitIndex(i,n,r){let o,l=1/0,c=1/0;for(let u=n;u<=r-n;u++){const f=V9(i,0,u,this.toBBox),m=V9(i,u,r,this.toBBox),p=Oni(f,m),v=Oq(f)+Oq(m);p=n;m--){const p=i.children[m];E9(u,i.leaf?l(p):p),f+=OM(u)}return f}_adjustParentBBoxes(i,n,r){for(let o=r;o>=0;o--)E9(n[o],i)}_condense(i){for(let n=i.length-1,r;n>=0;n--)i[n].children.length===0?n>0?(r=i[n-1].children,r.splice(r.indexOf(i[n]),1)):this.clear():sG(i[n],this.toBBox)}}function Kni(e,i,n){if(!n)return i.indexOf(e);for(let r=0;r=e.minX&&i.maxY>=e.minY}function SG(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function cXe(e,i,n,r,o){const l=[i,n];for(;l.length;){if(n=l.pop(),i=l.pop(),n-i<=r)continue;const c=i+Math.ceil((n-i)/r/2)*r;Mni(e,c,i,n,o),l.push(i,c,c,n)}}const Zre=Math.PI,Bre=2*Zre,Ay=1e-6,Lni=Bre-Ay;function Gre(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function cLe(){return new Gre}Gre.prototype=cLe.prototype={constructor:Gre,moveTo:function(e,i){this._+="M"+(this._x0=this._x1=+e)+","+(this._y0=this._y1=+i)},closePath:function(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(e,i){this._+="L"+(this._x1=+e)+","+(this._y1=+i)},quadraticCurveTo:function(e,i,n,r){this._+="Q"+ +e+","+ +i+","+(this._x1=+n)+","+(this._y1=+r)},bezierCurveTo:function(e,i,n,r,o,l){this._+="C"+ +e+","+ +i+","+ +n+","+ +r+","+(this._x1=+o)+","+(this._y1=+l)},arcTo:function(e,i,n,r,o){e=+e,i=+i,n=+n,r=+r,o=+o;var l=this._x1,c=this._y1,u=n-e,f=r-i,m=l-e,p=c-i,v=m*m+p*p;if(o<0)throw new Error("negative radius: "+o);if(this._x1===null)this._+="M"+(this._x1=e)+","+(this._y1=i);else if(v>Ay)if(!(Math.abs(p*u-f*m)>Ay)||!o)this._+="L"+(this._x1=e)+","+(this._y1=i);else{var B=n-l,G=r-c,T=u*u+f*f,V=B*B+G*G,E=Math.sqrt(T),W=Math.sqrt(v),x=o*Math.tan((Zre-Math.acos((T+v-V)/(2*E*W)))/2),k=x/W,F=x/E;Math.abs(k-1)>Ay&&(this._+="L"+(e+k*m)+","+(i+k*p)),this._+="A"+o+","+o+",0,0,"+ +(p*B>m*G)+","+(this._x1=e+F*u)+","+(this._y1=i+F*f)}},arc:function(e,i,n,r,o,l){e=+e,i=+i,n=+n,l=!!l;var c=n*Math.cos(r),u=n*Math.sin(r),f=e+c,m=i+u,p=1^l,v=l?r-o:o-r;if(n<0)throw new Error("negative radius: "+n);this._x1===null?this._+="M"+f+","+m:(Math.abs(this._x1-f)>Ay||Math.abs(this._y1-m)>Ay)&&(this._+="L"+f+","+m),n&&(v<0&&(v=v%Bre+Bre),v>Lni?this._+="A"+n+","+n+",0,1,"+p+","+(e-c)+","+(i-u)+"A"+n+","+n+",0,1,"+p+","+(this._x1=f)+","+(this._y1=m):v>Ay&&(this._+="A"+n+","+n+",0,"+ +(v>=Zre)+","+p+","+(this._x1=e+n*Math.cos(o))+","+(this._y1=i+n*Math.sin(o))))},rect:function(e,i,n,r){this._+="M"+(this._x0=this._x1=+e)+","+(this._y0=this._y1=+i)+"h"+ +n+"v"+ +r+"h"+-n+"Z"},toString:function(){return this._}};function Wm(e){return function(){return e}}var AXe=Math.abs,Cs=Math.atan2,Ob=Math.cos,Jni=Math.max,Jq=Math.min,vu=Math.sin,PG=Math.sqrt,DI=1e-12,ZH=Math.PI,xK=ZH/2,Uni=2*ZH;function Qni(e){return e>1?0:e<-1?ZH:Math.acos(e)}function uXe(e){return e>=1?xK:e<=-1?-xK:Math.asin(e)}function jni(e){return e.innerRadius}function $ni(e){return e.outerRadius}function qni(e){return e.startAngle}function eri(e){return e.endAngle}function tri(e){return e&&e.padAngle}function iri(e,i,n,r,o,l,c,u){var f=n-e,m=r-i,p=c-o,v=u-l,B=v*f-p*m;if(!(B*BAe*Ae+_*_&&(Q=$,X=ee),{cx:Q,cy:X,x01:-p,y01:-v,x11:Q*(o/Y-1),y11:X*(o/Y-1)}}function nri(){var e=jni,i=$ni,n=Wm(0),r=null,o=qni,l=eri,c=tri,u=null;function f(){var m,p,v=+e.apply(this,arguments),B=+i.apply(this,arguments),G=o.apply(this,arguments)-xK,T=l.apply(this,arguments)-xK,V=AXe(T-G),E=T>G;if(u||(u=m=cLe()),BDI))u.moveTo(0,0);else if(V>Uni-DI)u.moveTo(B*Ob(G),B*vu(G)),u.arc(0,0,B,G,T,!E),v>DI&&(u.moveTo(v*Ob(T),v*vu(T)),u.arc(0,0,v,T,G,E));else{var W=G,x=T,k=G,F=T,Y=V,L=V,O=c.apply(this,arguments)/2,Q=O>DI&&(r?+r.apply(this,arguments):PG(v*v+B*B)),X=Jq(AXe(B-v)/2,+n.apply(this,arguments)),$=X,ee=X,ne,ge;if(Q>DI){var Ae=uXe(Q/v*vu(O)),_=uXe(Q/B*vu(O));(Y-=Ae*2)>DI?(Ae*=E?1:-1,k+=Ae,F-=Ae):(Y=0,k=F=(G+T)/2),(L-=_*2)>DI?(_*=E?1:-1,W+=_,x-=_):(L=0,W=x=(G+T)/2)}var de=B*Ob(W),Ze=B*vu(W),me=v*Ob(F),be=v*vu(F);if(X>DI){var Ee=B*Ob(x),Je=B*vu(x),Ue=v*Ob(k),dt=v*vu(k),rt;if(VDI?ee>DI?(ne=JM(Ue,dt,de,Ze,B,ee,E),ge=JM(Ee,Je,me,be,B,ee,E),u.moveTo(ne.cx+ne.x01,ne.cy+ne.y01),eeDI)||!(Y>DI)?u.lineTo(me,be):$>DI?(ne=JM(me,be,Ee,Je,v,-$,E),ge=JM(de,Ze,Ue,dt,v,-$,E),u.lineTo(ne.cx+ne.x01,ne.cy+ne.y01),$e&&typeof e=="object"&&"__error_marker"in e&&e.__error_marker==="$$error";fv.DefaultSerializer={deserialize(e){return hri(e)?SXe.deserialize(e):e},serialize(e){return e instanceof Error?SXe.serialize(e):e}};Object.defineProperty(FC,"__esModule",{value:!0});FC.serialize=FC.deserialize=FC.registerSerializer=void 0;const uLe=fv;let MK=uLe.DefaultSerializer;function fri(e){MK=uLe.extendSerializer(MK,e)}FC.registerSerializer=fri;function mri(e){return MK.deserialize(e)}FC.deserialize=mri;function pri(e){return MK.serialize(e)}FC.serialize=pri;var dLe={},zh={},xS={};Object.defineProperty(xS,"__esModule",{value:!0});xS.getBundleURL=xS.getBaseURL=void 0;let Uq;function bri(){return Uq||(Uq=yri()),Uq}xS.getBundleURL=bri;function yri(){try{throw new Error}catch(e){const i=(""+e.stack).match(/(https?|file|ftp|chrome-extension|moz-extension):\/\/[^)\n]+/g);if(i)return hLe(i[0])}return"/"}function hLe(e){return(""+e).replace(/^((?:https?|file|ftp|chrome-extension|moz-extension):\/\/.+)?\/[^/]+(?:\?.*)?$/,"$1")+"/"}xS.getBaseURL=hLe;Object.defineProperty(zh,"__esModule",{value:!0});zh.isWorkerRuntime=zh.getWorkerImplementation=zh.defaultPoolSize=void 0;const wXe=xS;zh.defaultPoolSize=typeof navigator<"u"&&navigator.hardwareConcurrency?navigator.hardwareConcurrency:4;const TXe=e=>/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(e);function RXe(e){const i=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(i)}function vri(){if(typeof Worker>"u")return class{constructor(){throw Error("No web worker implementation available. You might have tried to spawn a worker within a worker in a browser that doesn't support workers in workers.")}};class e extends Worker{constructor(r,o){var l,c;typeof r=="string"&&o&&o._baseURL?r=new URL(r,o._baseURL):typeof r=="string"&&!TXe(r)&&wXe.getBundleURL().match(/^file:\/\//i)&&(r=new URL(r,wXe.getBundleURL().replace(/\/[^\/]+$/,"/")),(!((l=o?.CORSWorkaround)!==null&&l!==void 0)||l)&&(r=RXe(`importScripts(${JSON.stringify(r)});`))),typeof r=="string"&&TXe(r)&&(!((c=o?.CORSWorkaround)!==null&&c!==void 0)||c)&&(r=RXe(`importScripts(${JSON.stringify(r)});`)),super(r,o)}}class i extends e{constructor(r,o){const l=window.URL.createObjectURL(r);super(l,o)}static fromText(r,o){const l=new window.Blob([r],{type:"text/javascript"});return new i(l,o)}}return{blob:i,default:e}}let Qq;function Zri(){return Qq||(Qq=vri()),Qq}zh.getWorkerImplementation=Zri;function Bri(){const e=typeof self<"u"&&typeof Window<"u"&&self instanceof Window;return!!(typeof self<"u"&&self.postMessage&&!e)}zh.isWorkerRuntime=Bri;var fLe={},Rre={exports:{}},jq,VXe;function Gri(){if(VXe)return jq;VXe=1;var e=1e3,i=e*60,n=i*60,r=n*24,o=r*7,l=r*365.25;jq=function(p,v){v=v||{};var B=typeof p;if(B==="string"&&p.length>0)return c(p);if(B==="number"&&isFinite(p))return v.long?f(p):u(p);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(p))};function c(p){if(p=String(p),!(p.length>100)){var v=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(p);if(v){var B=parseFloat(v[1]),G=(v[2]||"ms").toLowerCase();switch(G){case"years":case"year":case"yrs":case"yr":case"y":return B*l;case"weeks":case"week":case"w":return B*o;case"days":case"day":case"d":return B*r;case"hours":case"hour":case"hrs":case"hr":case"h":return B*n;case"minutes":case"minute":case"mins":case"min":case"m":return B*i;case"seconds":case"second":case"secs":case"sec":case"s":return B*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return B;default:return}}}}function u(p){var v=Math.abs(p);return v>=r?Math.round(p/r)+"d":v>=n?Math.round(p/n)+"h":v>=i?Math.round(p/i)+"m":v>=e?Math.round(p/e)+"s":p+"ms"}function f(p){var v=Math.abs(p);return v>=r?m(p,v,r,"day"):v>=n?m(p,v,n,"hour"):v>=i?m(p,v,i,"minute"):v>=e?m(p,v,e,"second"):p+" ms"}function m(p,v,B,G){var T=v>=B*1.5;return Math.round(p/B)+" "+G+(T?"s":"")}return jq}function Sri(e){n.debug=n,n.default=n,n.coerce=f,n.disable=l,n.enable=o,n.enabled=c,n.humanize=Gri(),n.destroy=m,Object.keys(e).forEach(p=>{n[p]=e[p]}),n.names=[],n.skips=[],n.formatters={};function i(p){let v=0;for(let B=0;B{if(L==="%%")return"%";F++;const Q=n.formatters[O];if(typeof Q=="function"){const X=E[F];L=Q.call(W,X),E.splice(F,1),F--}return L}),n.formatArgs.call(W,E),(W.log||n.log).apply(W,E)}return V.namespace=p,V.useColors=n.useColors(),V.color=n.selectColor(p),V.extend=r,V.destroy=n.destroy,Object.defineProperty(V,"enabled",{enumerable:!0,configurable:!1,get:()=>B!==null?B:(G!==n.namespaces&&(G=n.namespaces,T=n.enabled(p)),T),set:E=>{B=E}}),typeof n.init=="function"&&n.init(V),V}function r(p,v){const B=n(this.namespace+(typeof v>"u"?":":v)+p);return B.log=this.log,B}function o(p){n.save(p),n.namespaces=p,n.names=[],n.skips=[];let v;const B=(typeof p=="string"?p:"").split(/[\s,]+/),G=B.length;for(v=0;v"-"+v)].join(",");return n.enable(""),p}function c(p){if(p[p.length-1]==="*")return!0;let v,B;for(v=0,B=n.skips.length;v{let f=!1;return()=>{f||(f=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),i.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function n(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(f){if(f[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+f[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const m="color: "+this.color;f.splice(1,0,m,"color: inherit");let p=0,v=0;f[0].replace(/%[a-zA-Z%]/g,B=>{B!=="%%"&&(p++,B==="%c"&&(v=p))}),f.splice(v,0,m)}i.log=console.debug||console.log||(()=>{});function o(f){try{f?i.storage.setItem("debug",f):i.storage.removeItem("debug")}catch{}}function l(){let f;try{f=i.storage.getItem("debug")}catch{}return!f&&typeof process<"u"&&"env"in process&&(f={}.DEBUG),f}function c(){try{return localStorage}catch{}}e.exports=wri(i);const{formatters:u}=e.exports;u.j=function(f){try{return JSON.stringify(f)}catch(m){return"[UnexpectedJSONParseError]: "+m.message}}})(Rre,Rre.exports);var NIe=Rre.exports,Tri=globalThis&&globalThis.__awaiter||function(e,i,n,r){function o(l){return l instanceof n?l:new n(function(c){c(l)})}return new(n||(n=Promise))(function(l,c){function u(p){try{m(r.next(p))}catch(v){c(v)}}function f(p){try{m(r.throw(p))}catch(v){c(v)}}function m(p){p.done?l(p.value):o(p.value).then(u,f)}m((r=r.apply(e,i||[])).next())})};class HP{constructor(i){this._baseObserver=i,this._pendingPromises=new Set}complete(){Promise.all(this._pendingPromises).then(()=>this._baseObserver.complete()).catch(i=>this._baseObserver.error(i))}error(i){this._baseObserver.error(i)}schedule(i){const n=Promise.all(this._pendingPromises),r=[],o=c=>r.push(c),l=Promise.resolve().then(()=>Tri(this,void 0,void 0,function*(){yield n,yield i(o),this._pendingPromises.delete(l);for(const c of r)this._baseObserver.next(c)})).catch(c=>{this._pendingPromises.delete(l),this._baseObserver.error(c)});this._pendingPromises.add(l)}}const mLe=()=>typeof Symbol=="function",SW=e=>mLe()&&!!Symbol[e],kIe=e=>SW(e)?Symbol[e]:"@@"+e;SW("asyncIterator")||(Symbol.asyncIterator=Symbol.asyncIterator||Symbol.for("Symbol.asyncIterator"));const Rri=kIe("iterator"),Vre=kIe("observable"),pLe=kIe("species");function FK(e,i){const n=e[i];if(n!=null){if(typeof n!="function")throw new TypeError(n+" is not a function");return n}}function JV(e){let i=e.constructor;return i!==void 0&&(i=i[pLe],i===null&&(i=void 0)),i!==void 0?i:mv}function Vri(e){return e instanceof mv}function DS(e){DS.log?DS.log(e):setTimeout(()=>{throw e},0)}function bY(e){Promise.resolve().then(()=>{try{e()}catch(i){DS(i)}})}function bLe(e){const i=e._cleanup;if(i!==void 0&&(e._cleanup=void 0,!!i))try{if(typeof i=="function")i();else{const n=FK(i,"unsubscribe");n&&n.call(i)}}catch(n){DS(n)}}function Ere(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function Eri(e){const i=e._queue;if(i){e._queue=void 0,e._state="ready";for(const n of i)if(yLe(e,n.type,n.value),e._state==="closed")break}}function yLe(e,i,n){e._state="running";const r=e._observer;try{const o=r?FK(r,i):void 0;switch(i){case"next":o&&o.call(r,n);break;case"error":if(Ere(e),o)o.call(r,n);else throw n;break;case"complete":Ere(e),o&&o.call(r);break}}catch(o){DS(o)}e._state==="closed"?bLe(e):e._state==="running"&&(e._state="ready")}function $q(e,i,n){if(e._state!=="closed"){if(e._state==="buffering"){e._queue=e._queue||[],e._queue.push({type:i,value:n});return}if(e._state!=="ready"){e._state="buffering",e._queue=[{type:i,value:n}],bY(()=>Eri(e));return}yLe(e,i,n)}}let Hri=class{constructor(i,n){this._cleanup=void 0,this._observer=i,this._queue=void 0,this._state="initializing";const r=new Wri(this);try{this._cleanup=n.call(void 0,r)}catch(o){r.error(o)}this._state==="initializing"&&(this._state="ready")}get closed(){return this._state==="closed"}unsubscribe(){this._state!=="closed"&&(Ere(this),bLe(this))}};class Wri{constructor(i){this._subscription=i}get closed(){return this._subscription._state==="closed"}next(i){$q(this._subscription,"next",i)}error(i){$q(this._subscription,"error",i)}complete(){$q(this._subscription,"complete")}}let mv=class H9{constructor(i){if(!(this instanceof H9))throw new TypeError("Observable cannot be called as a function");if(typeof i!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=i}subscribe(i,n,r){return(typeof i!="object"||i===null)&&(i={next:i,error:n,complete:r}),new Hri(i,this._subscriber)}pipe(i,...n){let r=this;for(const o of[i,...n])r=o(r);return r}tap(i,n,r){const o=typeof i!="object"||i===null?{next:i,error:n,complete:r}:i;return new H9(l=>this.subscribe({next(c){o.next&&o.next(c),l.next(c)},error(c){o.error&&o.error(c),l.error(c)},complete(){o.complete&&o.complete(),l.complete()},start(c){o.start&&o.start(c)}}))}forEach(i){return new Promise((n,r)=>{if(typeof i!="function"){r(new TypeError(i+" is not a function"));return}function o(){l.unsubscribe(),n(void 0)}const l=this.subscribe({next(c){try{i(c,o)}catch(u){r(u),l.unsubscribe()}},error(c){r(c)},complete(){n(void 0)}})})}map(i){if(typeof i!="function")throw new TypeError(i+" is not a function");const n=JV(this);return new n(r=>this.subscribe({next(o){let l=o;try{l=i(o)}catch(c){return r.error(c)}r.next(l)},error(o){r.error(o)},complete(){r.complete()}}))}filter(i){if(typeof i!="function")throw new TypeError(i+" is not a function");const n=JV(this);return new n(r=>this.subscribe({next(o){try{if(!i(o))return}catch(l){return r.error(l)}r.next(o)},error(o){r.error(o)},complete(){r.complete()}}))}reduce(i,n){if(typeof i!="function")throw new TypeError(i+" is not a function");const r=JV(this),o=arguments.length>1;let l=!1,c=n;return new r(u=>this.subscribe({next(f){const m=!l;if(l=!0,!m||o)try{c=i(c,f)}catch(p){return u.error(p)}else c=f},error(f){u.error(f)},complete(){if(!l&&!o)return u.error(new TypeError("Cannot reduce an empty sequence"));u.next(c),u.complete()}}))}concat(...i){const n=JV(this);return new n(r=>{let o,l=0;function c(u){o=u.subscribe({next(f){r.next(f)},error(f){r.error(f)},complete(){l===i.length?(o=void 0,r.complete()):c(n.from(i[l++]))}})}return c(this),()=>{o&&(o.unsubscribe(),o=void 0)}})}flatMap(i){if(typeof i!="function")throw new TypeError(i+" is not a function");const n=JV(this);return new n(r=>{const o=[],l=this.subscribe({next(u){let f;if(i)try{f=i(u)}catch(p){return r.error(p)}else f=u;const m=n.from(f).subscribe({next(p){r.next(p)},error(p){r.error(p)},complete(){const p=o.indexOf(m);p>=0&&o.splice(p,1),c()}});o.push(m)},error(u){r.error(u)},complete(){c()}});function c(){l.closed&&o.length===0&&r.complete()}return()=>{o.forEach(u=>u.unsubscribe()),l.unsubscribe()}})}[Vre](){return this}static from(i){const n=typeof this=="function"?this:H9;if(i==null)throw new TypeError(i+" is not an object");const r=FK(i,Vre);if(r){const o=r.call(i);if(Object(o)!==o)throw new TypeError(o+" is not an object");return Vri(o)&&o.constructor===n?o:new n(l=>o.subscribe(l))}if(SW("iterator")){const o=FK(i,Rri);if(o)return new n(l=>{bY(()=>{if(!l.closed){for(const c of o.call(i))if(l.next(c),l.closed)return;l.complete()}})})}if(Array.isArray(i))return new n(o=>{bY(()=>{if(!o.closed){for(const l of i)if(o.next(l),o.closed)return;o.complete()}})});throw new TypeError(i+" is not observable")}static of(...i){const n=typeof this=="function"?this:H9;return new n(r=>{bY(()=>{if(!r.closed){for(const o of i)if(r.next(o),r.closed)return;r.complete()}})})}static get[pLe](){return this}};mLe()&&Object.defineProperty(mv,Symbol("extensions"),{value:{symbol:Vre,hostReportError:DS},configurable:!0});const Qv=mv;function jv(e){typeof e=="function"?e():e&&typeof e.unsubscribe=="function"&&e.unsubscribe()}var Nri=globalThis&&globalThis.__awaiter||function(e,i,n,r){function o(l){return l instanceof n?l:new n(function(c){c(l)})}return new(n||(n=Promise))(function(l,c){function u(p){try{m(r.next(p))}catch(v){c(v)}}function f(p){try{m(r.throw(p))}catch(v){c(v)}}function m(p){p.done?l(p.value):o(p.value).then(u,f)}m((r=r.apply(e,i||[])).next())})};function kri(e){return i=>new Qv(n=>{const r=new HP(n),o=i.subscribe({complete(){r.complete()},error(l){r.error(l)},next(l){r.schedule(c=>Nri(this,void 0,void 0,function*(){(yield e(l))&&c(l)}))}});return()=>jv(o)})}function Xri(e){return e&&SW("asyncIterator")&&e[Symbol.asyncIterator]}function xri(e){return e&&SW("iterator")&&e[Symbol.iterator]}var Dri=globalThis&&globalThis.__awaiter||function(e,i,n,r){function o(l){return l instanceof n?l:new n(function(c){c(l)})}return new(n||(n=Promise))(function(l,c){function u(p){try{m(r.next(p))}catch(v){c(v)}}function f(p){try{m(r.throw(p))}catch(v){c(v)}}function m(p){p.done?l(p.value):o(p.value).then(u,f)}m((r=r.apply(e,i||[])).next())})},Mri=globalThis&&globalThis.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=e[Symbol.asyncIterator],n;return i?i.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(l){n[l]=e[l]&&function(c){return new Promise(function(u,f){c=e[l](c),o(u,f,c.done,c.value)})}}function o(l,c,u,f){Promise.resolve(f).then(function(m){l({value:m,done:u})},c)}};function Fri(e){return i=>new Qv(n=>{const r=new HP(n),o=i.subscribe({complete(){r.complete()},error(l){r.error(l)},next(l){r.schedule(c=>Dri(this,void 0,void 0,function*(){var u,f;const m=yield e(l);if(xri(m)||Xri(m))try{for(var p=Mri(m),v;v=yield p.next(),!v.done;){const B=v.value;c(B)}}catch(B){u={error:B}}finally{try{v&&!v.done&&(f=p.return)&&(yield f.call(p))}finally{if(u)throw u.error}}else m.map(B=>c(B))}))}});return()=>jv(o)})}function Yri(e){return new mv(i=>{let n=0;const r=setInterval(()=>{i.next(n++)},e);return()=>clearInterval(r)})}var Kri=globalThis&&globalThis.__awaiter||function(e,i,n,r){function o(l){return l instanceof n?l:new n(function(c){c(l)})}return new(n||(n=Promise))(function(l,c){function u(p){try{m(r.next(p))}catch(v){c(v)}}function f(p){try{m(r.throw(p))}catch(v){c(v)}}function m(p){p.done?l(p.value):o(p.value).then(u,f)}m((r=r.apply(e,i||[])).next())})};function _ri(e){return i=>new Qv(n=>{const r=new HP(n),o=i.subscribe({complete(){r.complete()},error(l){r.error(l)},next(l){r.schedule(c=>Kri(this,void 0,void 0,function*(){const u=yield e(l);c(u)}))}});return()=>jv(o)})}function Pri(...e){return e.length===0?mv.from([]):new mv(i=>{let n=0;const r=e.map(l=>l.subscribe({error(c){i.error(c),o()},next(c){i.next(c)},complete(){++n===e.length&&(i.complete(),o())}})),o=()=>{r.forEach(l=>jv(l))};return o})}class zri extends Qv{constructor(){super(i=>(this._observers.add(i),()=>this._observers.delete(i))),this._observers=new Set}next(i){for(const n of this._observers)n.next(i)}error(i){for(const n of this._observers)n.error(i)}complete(){for(const i of this._observers)i.complete()}}const vLe=zri;function Ori(e){const i=new vLe;let n,r=0;return new Qv(o=>{n||(n=e.subscribe(i));const l=i.subscribe(o);return r++,()=>{r--,l.unsubscribe(),r===0&&(jv(n),n=void 0)}})}var Lri=globalThis&&globalThis.__awaiter||function(e,i,n,r){function o(l){return l instanceof n?l:new n(function(c){c(l)})}return new(n||(n=Promise))(function(l,c){function u(p){try{m(r.next(p))}catch(v){c(v)}}function f(p){try{m(r.throw(p))}catch(v){c(v)}}function m(p){p.done?l(p.value):o(p.value).then(u,f)}m((r=r.apply(e,i||[])).next())})};function Jri(e,i){return n=>new Qv(r=>{let o,l=0;const c=new HP(r),u=n.subscribe({complete(){c.complete()},error(f){c.error(f)},next(f){c.schedule(m=>Lri(this,void 0,void 0,function*(){o=yield e(l===0?typeof i>"u"?f:i:o,f,l++),m(o)}))}});return()=>jv(u)})}const Uri=Object.freeze(Object.defineProperty({__proto__:null,Observable:Qv,Subject:vLe,filter:kri,flatMap:Fri,interval:Yri,map:_ri,merge:Pri,multicast:Ori,scan:Jri,unsubscribe:jv},Symbol.toStringTag,{value:"Module"})),WP=r3e(Uri);var NP={};Object.defineProperty(NP,"__esModule",{value:!0});NP.allSettled=void 0;function Qri(e){return Promise.all(e.map(i=>{const n=l=>({status:"fulfilled",value:l}),r=l=>({status:"rejected",reason:l}),o=Promise.resolve(i);try{return o.then(n,r)}catch(l){return Promise.reject(l)}}))}NP.allSettled=Qri;var ZLe={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.PoolEventType=void 0,function(i){i.initialized="initialized",i.taskCanceled="taskCanceled",i.taskCompleted="taskCompleted",i.taskFailed="taskFailed",i.taskQueued="taskQueued",i.taskQueueDrained="taskQueueDrained",i.taskStart="taskStart",i.terminated="terminated"}(e.PoolEventType||(e.PoolEventType={}))})(ZLe);var wW={},LI={};Object.defineProperty(LI,"__esModule",{value:!0});LI.$worker=LI.$transferable=LI.$terminate=LI.$events=LI.$errors=void 0;LI.$errors=Symbol("thread.errors");LI.$events=Symbol("thread.events");LI.$terminate=Symbol("thread.terminate");LI.$transferable=Symbol("thread.transferable");LI.$worker=Symbol("thread.worker");Object.defineProperty(wW,"__esModule",{value:!0});wW.Thread=void 0;const qq=LI;function EXe(e){throw Error(e)}wW.Thread={errors(e){return e[qq.$errors]||EXe("Error observable not found. Make sure to pass a thread instance as returned by the spawn() promise.")},events(e){return e[qq.$events]||EXe("Events observable not found. Make sure to pass a thread instance as returned by the spawn() promise.")},terminate(e){return e[qq.$terminate]()}};(function(e){var i=Qg&&Qg.__awaiter||function(W,x,k,F){function Y(L){return L instanceof k?L:new k(function(O){O(L)})}return new(k||(k=Promise))(function(L,O){function Q(ee){try{$(F.next(ee))}catch(ne){O(ne)}}function X(ee){try{$(F.throw(ee))}catch(ne){O(ne)}}function $(ee){ee.done?L(ee.value):Y(ee.value).then(Q,X)}$((F=F.apply(W,x||[])).next())})},n=Qg&&Qg.__importDefault||function(W){return W&&W.__esModule?W:{default:W}};Object.defineProperty(e,"__esModule",{value:!0}),e.Pool=e.Thread=e.PoolEventType=void 0;const r=n(NIe),o=WP,l=NP,c=zh,u=ZLe;Object.defineProperty(e,"PoolEventType",{enumerable:!0,get:function(){return u.PoolEventType}});const f=wW;Object.defineProperty(e,"Thread",{enumerable:!0,get:function(){return f.Thread}});let m=1;function p(W){const x=[];for(let k=0;ksetTimeout(x,W))}function B(W,x){return W.reduce((k,F)=>[...k,...x(F)],[])}function G(W){return W.replace(/\W/g," ").trim().replace(/\s+/g,"-")}function T(W,x){return p(x).map(()=>({init:W(),runningTasks:[]}))}class V{constructor(x,k){this.eventSubject=new o.Subject,this.initErrors=[],this.isClosing=!1,this.nextTaskID=1,this.taskQueue=[];const F=typeof k=="number"?{size:k}:k||{},{size:Y=c.defaultPoolSize}=F;this.debug=r.default(`threads:pool:${G(F.name||String(m++))}`),this.options=F,this.workers=T(x,Y),this.eventObservable=o.multicast(o.Observable.from(this.eventSubject)),Promise.all(this.workers.map(L=>L.init)).then(()=>this.eventSubject.next({type:u.PoolEventType.initialized,size:this.workers.length}),L=>{this.debug("Error while initializing pool worker:",L),this.eventSubject.error(L),this.initErrors.push(L)})}findIdlingWorker(){const{concurrency:x=1}=this.options;return this.workers.find(k=>k.runningTasks.lengthi(this,void 0,void 0,function*(){const Y=()=>{x.runningTasks=x.runningTasks.filter(L=>L!==F)};yield v(0);try{yield this.runPoolTask(x,k)}finally{Y(),this.isClosing||this.scheduleWork()}}))();x.runningTasks.push(F)})}scheduleWork(){this.debug("Attempt de-queueing a task in order to run it...");const x=this.findIdlingWorker();if(!x)return;const k=this.taskQueue.shift();if(!k){this.debug("Task queue is empty"),this.eventSubject.next({type:u.PoolEventType.taskQueueDrained});return}this.run(x,k)}taskCompletion(x){return new Promise((k,F)=>{const Y=this.events().subscribe(L=>{L.type===u.PoolEventType.taskCompleted&&L.taskID===x?(Y.unsubscribe(),k(L.returnValue)):L.type===u.PoolEventType.taskFailed&&L.taskID===x?(Y.unsubscribe(),F(L.error)):L.type===u.PoolEventType.terminated&&(Y.unsubscribe(),F(Error("Pool has been terminated before task was run.")))})})}settled(x=!1){return i(this,void 0,void 0,function*(){const k=()=>B(this.workers,L=>L.runningTasks),F=[],Y=this.eventObservable.subscribe(L=>{L.type===u.PoolEventType.taskFailed&&F.push(L.error)});return this.initErrors.length>0?Promise.reject(this.initErrors[0]):x&&this.taskQueue.length===0?(yield l.allSettled(k()),F):(yield new Promise((L,O)=>{const Q=this.eventObservable.subscribe({next(X){X.type===u.PoolEventType.taskQueueDrained&&(Q.unsubscribe(),L(void 0))},error:O})}),yield l.allSettled(k()),Y.unsubscribe(),F)})}completed(x=!1){return i(this,void 0,void 0,function*(){const k=this.settled(x),F=new Promise((L,O)=>{const Q=this.eventObservable.subscribe({next(X){X.type===u.PoolEventType.taskQueueDrained?(Q.unsubscribe(),L(k)):X.type===u.PoolEventType.taskFailed&&(Q.unsubscribe(),O(X.error))},error:O})}),Y=yield Promise.race([k,F]);if(Y.length>0)throw Y[0]})}events(){return this.eventObservable}queue(x){const{maxQueuedJobs:k=1/0}=this.options;if(this.isClosing)throw Error("Cannot schedule pool tasks after terminate() has been called.");if(this.initErrors.length>0)throw this.initErrors[0];const F=this.nextTaskID++,Y=this.taskCompletion(F);Y.catch(O=>{this.debug(`Task #${F} errored:`,O)});const L={id:F,run:x,cancel:()=>{this.taskQueue.indexOf(L)!==-1&&(this.taskQueue=this.taskQueue.filter(O=>O!==L),this.eventSubject.next({type:u.PoolEventType.taskCanceled,taskID:L.id}))},then:Y.then.bind(Y)};if(this.taskQueue.length>=k)throw Error(`Maximum number of pool tasks queued. Refusing to queue another one. -This usually happens for one of two reasons: We are either at peak workload right now or some tasks just won't finish, thus blocking the pool.`);return this.debug(`Queueing task #${L.id}...`),this.taskQueue.push(L),this.eventSubject.next({type:u.PoolEventType.taskQueued,taskID:L.id}),this.scheduleWork(),L}terminate(x){return i(this,void 0,void 0,function*(){this.isClosing=!0,x||(yield this.completed(!0)),this.eventSubject.next({type:u.PoolEventType.terminated,remainingQueue:[...this.taskQueue]}),this.eventSubject.complete(),yield Promise.all(this.workers.map(k=>i(this,void 0,void 0,function*(){return f.Thread.terminate(yield k.init)})))})}}V.EventType=u.PoolEventType;function E(W,x){return new V(W,x)}E.EventType=u.PoolEventType,e.Pool=E})(fLe);var kP={},XP={};Object.defineProperty(XP,"__esModule",{value:!0});XP.createPromiseWithResolver=void 0;const jri=()=>{};function $ri(){let e=!1,i,n=jri;return[new Promise(l=>{e?l(i):n=l}),l=>{e=!0,i=l,n(i)}]}XP.createPromiseWithResolver=$ri;var BLe={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.WorkerEventType=void 0,function(i){i.internalError="internalError",i.message="message",i.termination="termination"}(e.WorkerEventType||(e.WorkerEventType={}))})(BLe);var MS={},xP={};Object.defineProperty(xP,"__esModule",{value:!0});xP.ObservablePromise=void 0;const qri=WP,egi=()=>{},tgi=e=>e,HXe=e=>Promise.resolve().then(e);function igi(e){throw e}function ngi(e){return e&&typeof e.then=="function"}class XIe extends qri.Observable{constructor(i){super(n=>{const r=this,o=Object.assign(Object.assign({},n),{complete(){n.complete(),r.onCompletion()},error(l){n.error(l),r.onError(l)},next(l){n.next(l),r.onNext(l)}});try{return this.initHasRun=!0,i(o)}catch(l){o.error(l)}}),this.initHasRun=!1,this.fulfillmentCallbacks=[],this.rejectionCallbacks=[],this.firstValueSet=!1,this.state="pending"}onNext(i){this.firstValueSet||(this.firstValue=i,this.firstValueSet=!0)}onError(i){this.state="rejected",this.rejection=i;for(const n of this.rejectionCallbacks)HXe(()=>n(i))}onCompletion(){this.state="fulfilled";for(const i of this.fulfillmentCallbacks)HXe(()=>i(this.firstValue))}then(i,n){const r=i||tgi,o=n||igi;let l=!1;return new Promise((c,u)=>{const f=p=>{if(!l){l=!0;try{c(o(p))}catch(v){u(v)}}},m=p=>{try{c(r(p))}catch(v){f(v)}};if(this.initHasRun||this.subscribe({error:f}),this.state==="fulfilled")return c(r(this.firstValue));if(this.state==="rejected")return l=!0,c(o(this.rejection));this.fulfillmentCallbacks.push(m),this.rejectionCallbacks.push(f)})}catch(i){return this.then(void 0,i)}finally(i){const n=i||egi;return this.then(r=>(n(),r),()=>n())}static from(i){return ngi(i)?new XIe(n=>{const r=l=>{n.next(l),n.complete()},o=l=>{n.error(l)};i.then(r,o)}):super.from(i)}}xP.ObservablePromise=XIe;var sf={};Object.defineProperty(sf,"__esModule",{value:!0});sf.Transfer=sf.isTransferDescriptor=void 0;const GLe=LI;function rgi(e){return!(!e||typeof e!="object")}function ggi(e){return e&&typeof e=="object"&&e[GLe.$transferable]}sf.isTransferDescriptor=ggi;function ogi(e,i){if(!i){if(!rgi(e))throw Error();i=[e]}return{[GLe.$transferable]:!0,send:e,transferables:i}}sf.Transfer=ogi;var xIe={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.WorkerMessageType=e.MasterMessageType=void 0,function(i){i.cancel="cancel",i.run="run"}(e.MasterMessageType||(e.MasterMessageType={})),function(i){i.error="error",i.init="init",i.result="result",i.running="running",i.uncaughtError="uncaughtError"}(e.WorkerMessageType||(e.WorkerMessageType={}))})(xIe);var agi=Qg&&Qg.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(MS,"__esModule",{value:!0});MS.createProxyModule=MS.createProxyFunction=void 0;const sgi=agi(NIe),SLe=WP,bE=FC,WXe=xP,Igi=sf,TW=xIe,wLe=sgi.default("threads:master:messages");let lgi=1;const Cgi=e=>Array.from(new Set(e)),cgi=e=>e&&e.type===TW.WorkerMessageType.error,Agi=e=>e&&e.type===TW.WorkerMessageType.result,ugi=e=>e&&e.type===TW.WorkerMessageType.running;function dgi(e,i){return new SLe.Observable(n=>{let r;const o=l=>{if(wLe("Message from worker:",l.data),!(!l.data||l.data.uid!==i)){if(ugi(l.data))r=l.data.resultType;else if(Agi(l.data))r==="promise"?(typeof l.data.payload<"u"&&n.next(bE.deserialize(l.data.payload)),n.complete(),e.removeEventListener("message",o)):(l.data.payload&&n.next(bE.deserialize(l.data.payload)),l.data.complete&&(n.complete(),e.removeEventListener("message",o)));else if(cgi(l.data)){const c=bE.deserialize(l.data.error);n.error(c),e.removeEventListener("message",o)}}};return e.addEventListener("message",o),()=>{if(r==="observable"||!r){const l={type:TW.MasterMessageType.cancel,uid:i};e.postMessage(l)}e.removeEventListener("message",o)}})}function hgi(e){if(e.length===0)return{args:[],transferables:[]};const i=[],n=[];for(const r of e)Igi.isTransferDescriptor(r)?(i.push(bE.serialize(r.send)),n.push(...r.transferables)):i.push(bE.serialize(r));return{args:i,transferables:n.length===0?n:Cgi(n)}}function TLe(e,i){return(...n)=>{const r=lgi++,{args:o,transferables:l}=hgi(n),c={type:TW.MasterMessageType.run,uid:r,method:i,args:o};wLe("Sending command to run function to worker:",c);try{e.postMessage(c,l)}catch(u){return WXe.ObservablePromise.from(Promise.reject(u))}return WXe.ObservablePromise.from(SLe.multicast(dgi(e,r)))}}MS.createProxyFunction=TLe;function fgi(e,i){const n={};for(const r of i)n[r]=TLe(e,r);return n}MS.createProxyModule=fgi;var DIe=Qg&&Qg.__awaiter||function(e,i,n,r){function o(l){return l instanceof n?l:new n(function(c){c(l)})}return new(n||(n=Promise))(function(l,c){function u(p){try{m(r.next(p))}catch(v){c(v)}}function f(p){try{m(r.throw(p))}catch(v){c(v)}}function m(p){p.done?l(p.value):o(p.value).then(u,f)}m((r=r.apply(e,i||[])).next())})},mgi=Qg&&Qg.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(kP,"__esModule",{value:!0});kP.spawn=void 0;const MIe=mgi(NIe),pgi=WP,bgi=FC,ygi=XP,UM=LI,yY=BLe,NXe=MS,vgi=MIe.default("threads:master:messages"),Zgi=MIe.default("threads:master:spawn"),RLe=MIe.default("threads:master:thread-utils"),Bgi=e=>e&&e.type==="init",Ggi=e=>e&&e.type==="uncaughtError",Sgi=typeof process<"u"&&{}.THREADS_WORKER_INIT_TIMEOUT?Number.parseInt({}.THREADS_WORKER_INIT_TIMEOUT,10):1e4;function wgi(e,i,n){return DIe(this,void 0,void 0,function*(){let r;const o=new Promise((c,u)=>{r=setTimeout(()=>u(Error(n)),i)}),l=yield Promise.race([e,o]);return clearTimeout(r),l})}function Tgi(e){return new Promise((i,n)=>{const r=o=>{vgi("Message from worker before finishing initialization:",o.data),Bgi(o.data)?(e.removeEventListener("message",r),i(o.data)):Ggi(o.data)&&(e.removeEventListener("message",r),n(bgi.deserialize(o.data.error)))};e.addEventListener("message",r)})}function Rgi(e,i){return new pgi.Observable(n=>{const r=l=>{const c={type:yY.WorkerEventType.message,data:l.data};n.next(c)},o=l=>{RLe("Unhandled promise rejection event in thread:",l);const c={type:yY.WorkerEventType.internalError,error:Error(l.reason)};n.next(c)};e.addEventListener("message",r),e.addEventListener("unhandledrejection",o),i.then(()=>{const l={type:yY.WorkerEventType.termination};e.removeEventListener("message",r),e.removeEventListener("unhandledrejection",o),n.next(l),n.complete()})})}function Vgi(e){const[i,n]=ygi.createPromiseWithResolver();return{terminate:()=>DIe(this,void 0,void 0,function*(){RLe("Terminating worker"),yield e.terminate(),n()}),termination:i}}function kXe(e,i,n,r){const o=n.filter(l=>l.type===yY.WorkerEventType.internalError).map(l=>l.error);return Object.assign(e,{[UM.$errors]:o,[UM.$events]:n,[UM.$terminate]:r,[UM.$worker]:i})}function Egi(e,i){return DIe(this,void 0,void 0,function*(){Zgi("Initializing new thread");const n=i&&i.timeout?i.timeout:Sgi,o=(yield wgi(Tgi(e),n,`Timeout: Did not receive an init message from worker after ${n}ms. Make sure the worker calls expose().`)).exposed,{termination:l,terminate:c}=Vgi(e),u=Rgi(e,l);if(o.type==="function"){const f=NXe.createProxyFunction(e);return kXe(f,e,u,c)}else if(o.type==="module"){const f=NXe.createProxyModule(e,o.methods);return kXe(f,e,u,c)}else{const f=o.type;throw Error(`Worker init message states unexpected type of expose(): ${f}`)}})}kP.spawn=Egi;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Worker=e.BlobWorker=e.isWorkerRuntime=e.Thread=e.spawn=e.Pool=void 0;const i=zh;Object.defineProperty(e,"isWorkerRuntime",{enumerable:!0,get:function(){return i.isWorkerRuntime}});var n=fLe;Object.defineProperty(e,"Pool",{enumerable:!0,get:function(){return n.Pool}});var r=kP;Object.defineProperty(e,"spawn",{enumerable:!0,get:function(){return r.spawn}});var o=wW;Object.defineProperty(e,"Thread",{enumerable:!0,get:function(){return o.Thread}}),e.BlobWorker=i.getWorkerImplementation().blob,e.Worker=i.getWorkerImplementation().default})(dLe);var VLe={},Hgi=e=>e?typeof Symbol.observable=="symbol"&&typeof e[Symbol.observable]=="function"?e===e[Symbol.observable]():typeof e["@@observable"]=="function"?e===e["@@observable"]():!1:!1,FIe={};Object.defineProperty(FIe,"__esModule",{value:!0});const Wgi=function(){const i=typeof self<"u"&&typeof Window<"u"&&self instanceof Window;return!!(typeof self<"u"&&self.postMessage&&!i)},Ngi=function(i,n){self.postMessage(i,n)},kgi=function(i){const n=o=>{i(o.data)},r=()=>{self.removeEventListener("message",n)};return self.addEventListener("message",n),r};FIe.default={isWorkerRuntime:Wgi,postMessageToMaster:Ngi,subscribeToMasterMessages:kgi};(function(e){var i=Qg&&Qg.__awaiter||function(X,$,ee,ne){function ge(Ae){return Ae instanceof ee?Ae:new ee(function(_){_(Ae)})}return new(ee||(ee=Promise))(function(Ae,_){function de(be){try{me(ne.next(be))}catch(Ee){_(Ee)}}function Ze(be){try{me(ne.throw(be))}catch(Ee){_(Ee)}}function me(be){be.done?Ae(be.value):ge(be.value).then(de,Ze)}me((ne=ne.apply(X,$||[])).next())})},n=Qg&&Qg.__importDefault||function(X){return X&&X.__esModule?X:{default:X}};Object.defineProperty(e,"__esModule",{value:!0}),e.expose=e.isWorkerRuntime=e.Transfer=e.registerSerializer=void 0;const r=n(Hgi),o=FC,l=sf,c=xIe,u=n(FIe);var f=FC;Object.defineProperty(e,"registerSerializer",{enumerable:!0,get:function(){return f.registerSerializer}});var m=sf;Object.defineProperty(e,"Transfer",{enumerable:!0,get:function(){return m.Transfer}}),e.isWorkerRuntime=u.default.isWorkerRuntime;let p=!1;const v=new Map,B=X=>X&&X.type===c.MasterMessageType.cancel,G=X=>X&&X.type===c.MasterMessageType.run,T=X=>r.default(X)||V(X);function V(X){return X&&typeof X=="object"&&typeof X.subscribe=="function"}function E(X){return l.isTransferDescriptor(X)?{payload:X.send,transferables:X.transferables}:{payload:X,transferables:void 0}}function W(){const X={type:c.WorkerMessageType.init,exposed:{type:"function"}};u.default.postMessageToMaster(X)}function x(X){const $={type:c.WorkerMessageType.init,exposed:{type:"module",methods:X}};u.default.postMessageToMaster($)}function k(X,$){const{payload:ee,transferables:ne}=E($),ge={type:c.WorkerMessageType.error,uid:X,error:o.serialize(ee)};u.default.postMessageToMaster(ge,ne)}function F(X,$,ee){const{payload:ne,transferables:ge}=E(ee),Ae={type:c.WorkerMessageType.result,uid:X,complete:$?!0:void 0,payload:ne};u.default.postMessageToMaster(Ae,ge)}function Y(X,$){const ee={type:c.WorkerMessageType.running,uid:X,resultType:$};u.default.postMessageToMaster(ee)}function L(X){try{const $={type:c.WorkerMessageType.uncaughtError,error:o.serialize(X)};u.default.postMessageToMaster($)}catch($){console.error(`Not reporting uncaught error back to master thread as it occured while reporting an uncaught error already. -Latest error:`,$,` -Original error:`,X)}}function O(X,$,ee){return i(this,void 0,void 0,function*(){let ne;try{ne=$(...ee)}catch(Ae){return k(X,Ae)}const ge=T(ne)?"observable":"promise";if(Y(X,ge),T(ne)){const Ae=ne.subscribe(_=>F(X,!1,o.serialize(_)),_=>{k(X,o.serialize(_)),v.delete(X)},()=>{F(X,!0),v.delete(X)});v.set(X,Ae)}else try{const Ae=yield ne;F(X,!0,o.serialize(Ae))}catch(Ae){k(X,o.serialize(Ae))}})}function Q(X){if(!u.default.isWorkerRuntime())throw Error("expose() called in the master thread.");if(p)throw Error("expose() called more than once. This is not possible. Pass an object to expose() if you want to expose multiple functions.");if(p=!0,typeof X=="function")u.default.subscribeToMasterMessages($=>{G($)&&!$.method&&O($.uid,X,$.args.map(o.deserialize))}),W();else if(typeof X=="object"&&X){u.default.subscribeToMasterMessages(ee=>{G(ee)&&ee.method&&O(ee.uid,X[ee.method],ee.args.map(o.deserialize))});const $=Object.keys(X).filter(ee=>typeof X[ee]=="function");x($)}else throw Error(`Invalid argument passed to expose(). Expected a function or an object, got: ${X}`);u.default.subscribeToMasterMessages($=>{if(B($)){const ee=$.uid,ne=v.get(ee);ne&&(ne.unsubscribe(),v.delete(ee))}})}e.expose=Q,typeof self<"u"&&typeof self.addEventListener=="function"&&u.default.isWorkerRuntime()&&(self.addEventListener("error",X=>{setTimeout(()=>L(X.error||X),250)}),self.addEventListener("unhandledrejection",X=>{const $=X.reason;$&&typeof $.message=="string"&&setTimeout(()=>L($),250)})),typeof process<"u"&&typeof process.on=="function"&&u.default.isWorkerRuntime()&&(process.on("uncaughtException",X=>{setTimeout(()=>L(X),250)}),process.on("unhandledRejection",X=>{X&&typeof X.message=="string"&&setTimeout(()=>L(X),250)}))})(VLe);(function(e){var i=Qg&&Qg.__createBinding||(Object.create?function(u,f,m,p){p===void 0&&(p=m),Object.defineProperty(u,p,{enumerable:!0,get:function(){return f[m]}})}:function(u,f,m,p){p===void 0&&(p=m),u[p]=f[m]}),n=Qg&&Qg.__exportStar||function(u,f){for(var m in u)m!=="default"&&!Object.prototype.hasOwnProperty.call(f,m)&&i(f,u,m)};Object.defineProperty(e,"__esModule",{value:!0}),e.Transfer=e.DefaultSerializer=e.expose=e.registerSerializer=void 0;var r=FC;Object.defineProperty(e,"registerSerializer",{enumerable:!0,get:function(){return r.registerSerializer}}),n(dLe,e);var o=VLe;Object.defineProperty(e,"expose",{enumerable:!0,get:function(){return o.expose}});var l=fv;Object.defineProperty(e,"DefaultSerializer",{enumerable:!0,get:function(){return l.DefaultSerializer}});var c=sf;Object.defineProperty(e,"Transfer",{enumerable:!0,get:function(){return c.Transfer}})})(ALe);const r0=Al(ALe);r0.registerSerializer;const YIe=r0.spawn;r0.BlobWorker;r0.DefaultSerializer;r0.Pool;r0.Thread;r0.Transfer;r0.Worker;var pv={},DP={};DP.byteLength=Dgi;DP.toByteArray=Fgi;DP.fromByteArray=_gi;var Xu=[],GC=[],Xgi=typeof Uint8Array<"u"?Uint8Array:Array,eee="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var IG=0,xgi=eee.length;IG0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");n===-1&&(n=i);var r=n===i?0:4-n%4;return[n,r]}function Dgi(e){var i=ELe(e),n=i[0],r=i[1];return(n+r)*3/4-r}function Mgi(e,i,n){return(i+n)*3/4-n}function Fgi(e){var i,n=ELe(e),r=n[0],o=n[1],l=new Xgi(Mgi(e,r,o)),c=0,u=o>0?r-4:r,f;for(f=0;f>16&255,l[c++]=i>>8&255,l[c++]=i&255;return o===2&&(i=GC[e.charCodeAt(f)]<<2|GC[e.charCodeAt(f+1)]>>4,l[c++]=i&255),o===1&&(i=GC[e.charCodeAt(f)]<<10|GC[e.charCodeAt(f+1)]<<4|GC[e.charCodeAt(f+2)]>>2,l[c++]=i>>8&255,l[c++]=i&255),l}function Ygi(e){return Xu[e>>18&63]+Xu[e>>12&63]+Xu[e>>6&63]+Xu[e&63]}function Kgi(e,i,n){for(var r,o=[],l=i;lu?u:c+l));return r===1?(i=e[n-1],o.push(Xu[i>>2]+Xu[i<<4&63]+"==")):r===2&&(i=(e[n-2]<<8)+e[n-1],o.push(Xu[i>>10]+Xu[i>>4&63]+Xu[i<<2&63]+"=")),o.join("")}var KIe={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */KIe.read=function(e,i,n,r,o){var l,c,u=o*8-r-1,f=(1<>1,p=-7,v=n?o-1:0,B=n?-1:1,G=e[i+v];for(v+=B,l=G&(1<<-p)-1,G>>=-p,p+=u;p>0;l=l*256+e[i+v],v+=B,p-=8);for(c=l&(1<<-p)-1,l>>=-p,p+=r;p>0;c=c*256+e[i+v],v+=B,p-=8);if(l===0)l=1-m;else{if(l===f)return c?NaN:(G?-1:1)*(1/0);c=c+Math.pow(2,r),l=l-m}return(G?-1:1)*c*Math.pow(2,l-r)};KIe.write=function(e,i,n,r,o,l){var c,u,f,m=l*8-o-1,p=(1<>1,B=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,G=r?0:l-1,T=r?1:-1,V=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(u=isNaN(i)?1:0,c=p):(c=Math.floor(Math.log(i)/Math.LN2),i*(f=Math.pow(2,-c))<1&&(c--,f*=2),c+v>=1?i+=B/f:i+=B*Math.pow(2,1-v),i*f>=2&&(c++,f/=2),c+v>=p?(u=0,c=p):c+v>=1?(u=(i*f-1)*Math.pow(2,o),c=c+v):(u=i*Math.pow(2,v-1)*Math.pow(2,o),c=0));o>=8;e[n+G]=u&255,G+=T,u/=256,o-=8);for(c=c<0;e[n+G]=c&255,G+=T,c/=256,m-=8);e[n+G-T]|=V*128};/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */(function(e){const i=DP,n=KIe,r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=u,e.SlowBuffer=x,e.INSPECT_MAX_BYTES=50;const o=2147483647;e.kMaxLength=o,u.TYPED_ARRAY_SUPPORT=l(),!u.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function l(){try{const Be=new Uint8Array(1),le={foo:function(){return 42}};return Object.setPrototypeOf(le,Uint8Array.prototype),Object.setPrototypeOf(Be,le),Be.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function c(Be){if(Be>o)throw new RangeError('The value "'+Be+'" is invalid for option "size"');const le=new Uint8Array(Be);return Object.setPrototypeOf(le,u.prototype),le}function u(Be,le,ce){if(typeof Be=="number"){if(typeof le=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(Be)}return f(Be,le,ce)}u.poolSize=8192;function f(Be,le,ce){if(typeof Be=="string")return B(Be,le);if(ArrayBuffer.isView(Be))return T(Be);if(Be==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Be);if(ki(Be,ArrayBuffer)||Be&&ki(Be.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ki(Be,SharedArrayBuffer)||Be&&ki(Be.buffer,SharedArrayBuffer)))return V(Be,le,ce);if(typeof Be=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const Ke=Be.valueOf&&Be.valueOf();if(Ke!=null&&Ke!==Be)return u.from(Ke,le,ce);const ct=E(Be);if(ct)return ct;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof Be[Symbol.toPrimitive]=="function")return u.from(Be[Symbol.toPrimitive]("string"),le,ce);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Be)}u.from=function(Be,le,ce){return f(Be,le,ce)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function m(Be){if(typeof Be!="number")throw new TypeError('"size" argument must be of type number');if(Be<0)throw new RangeError('The value "'+Be+'" is invalid for option "size"')}function p(Be,le,ce){return m(Be),Be<=0?c(Be):le!==void 0?typeof ce=="string"?c(Be).fill(le,ce):c(Be).fill(le):c(Be)}u.alloc=function(Be,le,ce){return p(Be,le,ce)};function v(Be){return m(Be),c(Be<0?0:W(Be)|0)}u.allocUnsafe=function(Be){return v(Be)},u.allocUnsafeSlow=function(Be){return v(Be)};function B(Be,le){if((typeof le!="string"||le==="")&&(le="utf8"),!u.isEncoding(le))throw new TypeError("Unknown encoding: "+le);const ce=k(Be,le)|0;let Ke=c(ce);const ct=Ke.write(Be,le);return ct!==ce&&(Ke=Ke.slice(0,ct)),Ke}function G(Be){const le=Be.length<0?0:W(Be.length)|0,ce=c(le);for(let Ke=0;Ke=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return Be|0}function x(Be){return+Be!=Be&&(Be=0),u.alloc(+Be)}u.isBuffer=function(le){return le!=null&&le._isBuffer===!0&&le!==u.prototype},u.compare=function(le,ce){if(ki(le,Uint8Array)&&(le=u.from(le,le.offset,le.byteLength)),ki(ce,Uint8Array)&&(ce=u.from(ce,ce.offset,ce.byteLength)),!u.isBuffer(le)||!u.isBuffer(ce))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(le===ce)return 0;let Ke=le.length,ct=ce.length;for(let Wt=0,Mt=Math.min(Ke,ct);Wtct.length?(u.isBuffer(Mt)||(Mt=u.from(Mt)),Mt.copy(ct,Wt)):Uint8Array.prototype.set.call(ct,Mt,Wt);else if(u.isBuffer(Mt))Mt.copy(ct,Wt);else throw new TypeError('"list" argument must be an Array of Buffers');Wt+=Mt.length}return ct};function k(Be,le){if(u.isBuffer(Be))return Be.length;if(ArrayBuffer.isView(Be)||ki(Be,ArrayBuffer))return Be.byteLength;if(typeof Be!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof Be);const ce=Be.length,Ke=arguments.length>2&&arguments[2]===!0;if(!Ke&&ce===0)return 0;let ct=!1;for(;;)switch(le){case"ascii":case"latin1":case"binary":return ce;case"utf8":case"utf-8":return Ut(Be).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ce*2;case"hex":return ce>>>1;case"base64":return Cn(Be).length;default:if(ct)return Ke?-1:Ut(Be).length;le=(""+le).toLowerCase(),ct=!0}}u.byteLength=k;function F(Be,le,ce){let Ke=!1;if((le===void 0||le<0)&&(le=0),le>this.length||((ce===void 0||ce>this.length)&&(ce=this.length),ce<=0)||(ce>>>=0,le>>>=0,ce<=le))return"";for(Be||(Be="utf8");;)switch(Be){case"hex":return be(this,le,ce);case"utf8":case"utf-8":return Ae(this,le,ce);case"ascii":return Ze(this,le,ce);case"latin1":case"binary":return me(this,le,ce);case"base64":return ge(this,le,ce);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ee(this,le,ce);default:if(Ke)throw new TypeError("Unknown encoding: "+Be);Be=(Be+"").toLowerCase(),Ke=!0}}u.prototype._isBuffer=!0;function Y(Be,le,ce){const Ke=Be[le];Be[le]=Be[ce],Be[ce]=Ke}u.prototype.swap16=function(){const le=this.length;if(le%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let ce=0;cece&&(le+=" ... "),""},r&&(u.prototype[r]=u.prototype.inspect),u.prototype.compare=function(le,ce,Ke,ct,Wt){if(ki(le,Uint8Array)&&(le=u.from(le,le.offset,le.byteLength)),!u.isBuffer(le))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof le);if(ce===void 0&&(ce=0),Ke===void 0&&(Ke=le?le.length:0),ct===void 0&&(ct=0),Wt===void 0&&(Wt=this.length),ce<0||Ke>le.length||ct<0||Wt>this.length)throw new RangeError("out of range index");if(ct>=Wt&&ce>=Ke)return 0;if(ct>=Wt)return-1;if(ce>=Ke)return 1;if(ce>>>=0,Ke>>>=0,ct>>>=0,Wt>>>=0,this===le)return 0;let Mt=Wt-ct,fn=Ke-ce;const gg=Math.min(Mt,fn),Xr=this.slice(ct,Wt),qn=le.slice(ce,Ke);for(let Br=0;Br2147483647?ce=2147483647:ce<-2147483648&&(ce=-2147483648),ce=+ce,Ei(ce)&&(ce=ct?0:Be.length-1),ce<0&&(ce=Be.length+ce),ce>=Be.length){if(ct)return-1;ce=Be.length-1}else if(ce<0)if(ct)ce=0;else return-1;if(typeof le=="string"&&(le=u.from(le,Ke)),u.isBuffer(le))return le.length===0?-1:O(Be,le,ce,Ke,ct);if(typeof le=="number")return le=le&255,typeof Uint8Array.prototype.indexOf=="function"?ct?Uint8Array.prototype.indexOf.call(Be,le,ce):Uint8Array.prototype.lastIndexOf.call(Be,le,ce):O(Be,[le],ce,Ke,ct);throw new TypeError("val must be string, number or Buffer")}function O(Be,le,ce,Ke,ct){let Wt=1,Mt=Be.length,fn=le.length;if(Ke!==void 0&&(Ke=String(Ke).toLowerCase(),Ke==="ucs2"||Ke==="ucs-2"||Ke==="utf16le"||Ke==="utf-16le")){if(Be.length<2||le.length<2)return-1;Wt=2,Mt/=2,fn/=2,ce/=2}function gg(qn,Br){return Wt===1?qn[Br]:qn.readUInt16BE(Br*Wt)}let Xr;if(ct){let qn=-1;for(Xr=ce;XrMt&&(ce=Mt-fn),Xr=ce;Xr>=0;Xr--){let qn=!0;for(let Br=0;Brct&&(Ke=ct)):Ke=ct;const Wt=le.length;Ke>Wt/2&&(Ke=Wt/2);let Mt;for(Mt=0;Mt>>0,isFinite(Ke)?(Ke=Ke>>>0,ct===void 0&&(ct="utf8")):(ct=Ke,Ke=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const Wt=this.length-ce;if((Ke===void 0||Ke>Wt)&&(Ke=Wt),le.length>0&&(Ke<0||ce<0)||ce>this.length)throw new RangeError("Attempt to write outside buffer bounds");ct||(ct="utf8");let Mt=!1;for(;;)switch(ct){case"hex":return Q(this,le,ce,Ke);case"utf8":case"utf-8":return X(this,le,ce,Ke);case"ascii":case"latin1":case"binary":return $(this,le,ce,Ke);case"base64":return ee(this,le,ce,Ke);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,le,ce,Ke);default:if(Mt)throw new TypeError("Unknown encoding: "+ct);ct=(""+ct).toLowerCase(),Mt=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ge(Be,le,ce){return le===0&&ce===Be.length?i.fromByteArray(Be):i.fromByteArray(Be.slice(le,ce))}function Ae(Be,le,ce){ce=Math.min(Be.length,ce);const Ke=[];let ct=le;for(;ct239?4:Wt>223?3:Wt>191?2:1;if(ct+fn<=ce){let gg,Xr,qn,Br;switch(fn){case 1:Wt<128&&(Mt=Wt);break;case 2:gg=Be[ct+1],(gg&192)===128&&(Br=(Wt&31)<<6|gg&63,Br>127&&(Mt=Br));break;case 3:gg=Be[ct+1],Xr=Be[ct+2],(gg&192)===128&&(Xr&192)===128&&(Br=(Wt&15)<<12|(gg&63)<<6|Xr&63,Br>2047&&(Br<55296||Br>57343)&&(Mt=Br));break;case 4:gg=Be[ct+1],Xr=Be[ct+2],qn=Be[ct+3],(gg&192)===128&&(Xr&192)===128&&(qn&192)===128&&(Br=(Wt&15)<<18|(gg&63)<<12|(Xr&63)<<6|qn&63,Br>65535&&Br<1114112&&(Mt=Br))}}Mt===null?(Mt=65533,fn=1):Mt>65535&&(Mt-=65536,Ke.push(Mt>>>10&1023|55296),Mt=56320|Mt&1023),Ke.push(Mt),ct+=fn}return de(Ke)}const _=4096;function de(Be){const le=Be.length;if(le<=_)return String.fromCharCode.apply(String,Be);let ce="",Ke=0;for(;KeKe)&&(ce=Ke);let ct="";for(let Wt=le;WtKe&&(le=Ke),ce<0?(ce+=Ke,ce<0&&(ce=0)):ce>Ke&&(ce=Ke),cece)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(le,ce,Ke){le=le>>>0,ce=ce>>>0,Ke||Je(le,ce,this.length);let ct=this[le],Wt=1,Mt=0;for(;++Mt>>0,ce=ce>>>0,Ke||Je(le,ce,this.length);let ct=this[le+--ce],Wt=1;for(;ce>0&&(Wt*=256);)ct+=this[le+--ce]*Wt;return ct},u.prototype.readUint8=u.prototype.readUInt8=function(le,ce){return le=le>>>0,ce||Je(le,1,this.length),this[le]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(le,ce){return le=le>>>0,ce||Je(le,2,this.length),this[le]|this[le+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(le,ce){return le=le>>>0,ce||Je(le,2,this.length),this[le]<<8|this[le+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(le,ce){return le=le>>>0,ce||Je(le,4,this.length),(this[le]|this[le+1]<<8|this[le+2]<<16)+this[le+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(le,ce){return le=le>>>0,ce||Je(le,4,this.length),this[le]*16777216+(this[le+1]<<16|this[le+2]<<8|this[le+3])},u.prototype.readBigUInt64LE=Nr(function(le){le=le>>>0,Et(le,"offset");const ce=this[le],Ke=this[le+7];(ce===void 0||Ke===void 0)&&Zt(le,this.length-8);const ct=ce+this[++le]*2**8+this[++le]*2**16+this[++le]*2**24,Wt=this[++le]+this[++le]*2**8+this[++le]*2**16+Ke*2**24;return BigInt(ct)+(BigInt(Wt)<>>0,Et(le,"offset");const ce=this[le],Ke=this[le+7];(ce===void 0||Ke===void 0)&&Zt(le,this.length-8);const ct=ce*2**24+this[++le]*2**16+this[++le]*2**8+this[++le],Wt=this[++le]*2**24+this[++le]*2**16+this[++le]*2**8+Ke;return(BigInt(ct)<>>0,ce=ce>>>0,Ke||Je(le,ce,this.length);let ct=this[le],Wt=1,Mt=0;for(;++Mt=Wt&&(ct-=Math.pow(2,8*ce)),ct},u.prototype.readIntBE=function(le,ce,Ke){le=le>>>0,ce=ce>>>0,Ke||Je(le,ce,this.length);let ct=ce,Wt=1,Mt=this[le+--ct];for(;ct>0&&(Wt*=256);)Mt+=this[le+--ct]*Wt;return Wt*=128,Mt>=Wt&&(Mt-=Math.pow(2,8*ce)),Mt},u.prototype.readInt8=function(le,ce){return le=le>>>0,ce||Je(le,1,this.length),this[le]&128?(255-this[le]+1)*-1:this[le]},u.prototype.readInt16LE=function(le,ce){le=le>>>0,ce||Je(le,2,this.length);const Ke=this[le]|this[le+1]<<8;return Ke&32768?Ke|4294901760:Ke},u.prototype.readInt16BE=function(le,ce){le=le>>>0,ce||Je(le,2,this.length);const Ke=this[le+1]|this[le]<<8;return Ke&32768?Ke|4294901760:Ke},u.prototype.readInt32LE=function(le,ce){return le=le>>>0,ce||Je(le,4,this.length),this[le]|this[le+1]<<8|this[le+2]<<16|this[le+3]<<24},u.prototype.readInt32BE=function(le,ce){return le=le>>>0,ce||Je(le,4,this.length),this[le]<<24|this[le+1]<<16|this[le+2]<<8|this[le+3]},u.prototype.readBigInt64LE=Nr(function(le){le=le>>>0,Et(le,"offset");const ce=this[le],Ke=this[le+7];(ce===void 0||Ke===void 0)&&Zt(le,this.length-8);const ct=this[le+4]+this[le+5]*2**8+this[le+6]*2**16+(Ke<<24);return(BigInt(ct)<>>0,Et(le,"offset");const ce=this[le],Ke=this[le+7];(ce===void 0||Ke===void 0)&&Zt(le,this.length-8);const ct=(ce<<24)+this[++le]*2**16+this[++le]*2**8+this[++le];return(BigInt(ct)<>>0,ce||Je(le,4,this.length),n.read(this,le,!0,23,4)},u.prototype.readFloatBE=function(le,ce){return le=le>>>0,ce||Je(le,4,this.length),n.read(this,le,!1,23,4)},u.prototype.readDoubleLE=function(le,ce){return le=le>>>0,ce||Je(le,8,this.length),n.read(this,le,!0,52,8)},u.prototype.readDoubleBE=function(le,ce){return le=le>>>0,ce||Je(le,8,this.length),n.read(this,le,!1,52,8)};function Ue(Be,le,ce,Ke,ct,Wt){if(!u.isBuffer(Be))throw new TypeError('"buffer" argument must be a Buffer instance');if(le>ct||leBe.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(le,ce,Ke,ct){if(le=+le,ce=ce>>>0,Ke=Ke>>>0,!ct){const fn=Math.pow(2,8*Ke)-1;Ue(this,le,ce,Ke,fn,0)}let Wt=1,Mt=0;for(this[ce]=le&255;++Mt>>0,Ke=Ke>>>0,!ct){const fn=Math.pow(2,8*Ke)-1;Ue(this,le,ce,Ke,fn,0)}let Wt=Ke-1,Mt=1;for(this[ce+Wt]=le&255;--Wt>=0&&(Mt*=256);)this[ce+Wt]=le/Mt&255;return ce+Ke},u.prototype.writeUint8=u.prototype.writeUInt8=function(le,ce,Ke){return le=+le,ce=ce>>>0,Ke||Ue(this,le,ce,1,255,0),this[ce]=le&255,ce+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(le,ce,Ke){return le=+le,ce=ce>>>0,Ke||Ue(this,le,ce,2,65535,0),this[ce]=le&255,this[ce+1]=le>>>8,ce+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(le,ce,Ke){return le=+le,ce=ce>>>0,Ke||Ue(this,le,ce,2,65535,0),this[ce]=le>>>8,this[ce+1]=le&255,ce+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(le,ce,Ke){return le=+le,ce=ce>>>0,Ke||Ue(this,le,ce,4,4294967295,0),this[ce+3]=le>>>24,this[ce+2]=le>>>16,this[ce+1]=le>>>8,this[ce]=le&255,ce+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(le,ce,Ke){return le=+le,ce=ce>>>0,Ke||Ue(this,le,ce,4,4294967295,0),this[ce]=le>>>24,this[ce+1]=le>>>16,this[ce+2]=le>>>8,this[ce+3]=le&255,ce+4};function dt(Be,le,ce,Ke,ct){It(le,Ke,ct,Be,ce,7);let Wt=Number(le&BigInt(4294967295));Be[ce++]=Wt,Wt=Wt>>8,Be[ce++]=Wt,Wt=Wt>>8,Be[ce++]=Wt,Wt=Wt>>8,Be[ce++]=Wt;let Mt=Number(le>>BigInt(32)&BigInt(4294967295));return Be[ce++]=Mt,Mt=Mt>>8,Be[ce++]=Mt,Mt=Mt>>8,Be[ce++]=Mt,Mt=Mt>>8,Be[ce++]=Mt,ce}function rt(Be,le,ce,Ke,ct){It(le,Ke,ct,Be,ce,7);let Wt=Number(le&BigInt(4294967295));Be[ce+7]=Wt,Wt=Wt>>8,Be[ce+6]=Wt,Wt=Wt>>8,Be[ce+5]=Wt,Wt=Wt>>8,Be[ce+4]=Wt;let Mt=Number(le>>BigInt(32)&BigInt(4294967295));return Be[ce+3]=Mt,Mt=Mt>>8,Be[ce+2]=Mt,Mt=Mt>>8,Be[ce+1]=Mt,Mt=Mt>>8,Be[ce]=Mt,ce+8}u.prototype.writeBigUInt64LE=Nr(function(le,ce=0){return dt(this,le,ce,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Nr(function(le,ce=0){return rt(this,le,ce,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(le,ce,Ke,ct){if(le=+le,ce=ce>>>0,!ct){const gg=Math.pow(2,8*Ke-1);Ue(this,le,ce,Ke,gg-1,-gg)}let Wt=0,Mt=1,fn=0;for(this[ce]=le&255;++Wt>0)-fn&255;return ce+Ke},u.prototype.writeIntBE=function(le,ce,Ke,ct){if(le=+le,ce=ce>>>0,!ct){const gg=Math.pow(2,8*Ke-1);Ue(this,le,ce,Ke,gg-1,-gg)}let Wt=Ke-1,Mt=1,fn=0;for(this[ce+Wt]=le&255;--Wt>=0&&(Mt*=256);)le<0&&fn===0&&this[ce+Wt+1]!==0&&(fn=1),this[ce+Wt]=(le/Mt>>0)-fn&255;return ce+Ke},u.prototype.writeInt8=function(le,ce,Ke){return le=+le,ce=ce>>>0,Ke||Ue(this,le,ce,1,127,-128),le<0&&(le=255+le+1),this[ce]=le&255,ce+1},u.prototype.writeInt16LE=function(le,ce,Ke){return le=+le,ce=ce>>>0,Ke||Ue(this,le,ce,2,32767,-32768),this[ce]=le&255,this[ce+1]=le>>>8,ce+2},u.prototype.writeInt16BE=function(le,ce,Ke){return le=+le,ce=ce>>>0,Ke||Ue(this,le,ce,2,32767,-32768),this[ce]=le>>>8,this[ce+1]=le&255,ce+2},u.prototype.writeInt32LE=function(le,ce,Ke){return le=+le,ce=ce>>>0,Ke||Ue(this,le,ce,4,2147483647,-2147483648),this[ce]=le&255,this[ce+1]=le>>>8,this[ce+2]=le>>>16,this[ce+3]=le>>>24,ce+4},u.prototype.writeInt32BE=function(le,ce,Ke){return le=+le,ce=ce>>>0,Ke||Ue(this,le,ce,4,2147483647,-2147483648),le<0&&(le=4294967295+le+1),this[ce]=le>>>24,this[ce+1]=le>>>16,this[ce+2]=le>>>8,this[ce+3]=le&255,ce+4},u.prototype.writeBigInt64LE=Nr(function(le,ce=0){return dt(this,le,ce,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Nr(function(le,ce=0){return rt(this,le,ce,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ke(Be,le,ce,Ke,ct,Wt){if(ce+Ke>Be.length)throw new RangeError("Index out of range");if(ce<0)throw new RangeError("Index out of range")}function ze(Be,le,ce,Ke,ct){return le=+le,ce=ce>>>0,ct||ke(Be,le,ce,4),n.write(Be,le,ce,Ke,23,4),ce+4}u.prototype.writeFloatLE=function(le,ce,Ke){return ze(this,le,ce,!0,Ke)},u.prototype.writeFloatBE=function(le,ce,Ke){return ze(this,le,ce,!1,Ke)};function je(Be,le,ce,Ke,ct){return le=+le,ce=ce>>>0,ct||ke(Be,le,ce,8),n.write(Be,le,ce,Ke,52,8),ce+8}u.prototype.writeDoubleLE=function(le,ce,Ke){return je(this,le,ce,!0,Ke)},u.prototype.writeDoubleBE=function(le,ce,Ke){return je(this,le,ce,!1,Ke)},u.prototype.copy=function(le,ce,Ke,ct){if(!u.isBuffer(le))throw new TypeError("argument should be a Buffer");if(Ke||(Ke=0),!ct&&ct!==0&&(ct=this.length),ce>=le.length&&(ce=le.length),ce||(ce=0),ct>0&&ct=this.length)throw new RangeError("Index out of range");if(ct<0)throw new RangeError("sourceEnd out of bounds");ct>this.length&&(ct=this.length),le.length-ce>>0,Ke=Ke===void 0?this.length:Ke>>>0,le||(le=0);let Wt;if(typeof le=="number")for(Wt=ce;Wt2**32?ct=it(String(ce)):typeof ce=="bigint"&&(ct=String(ce),(ce>BigInt(2)**BigInt(32)||ce<-(BigInt(2)**BigInt(32)))&&(ct=it(ct)),ct+="n"),Ke+=` It must be ${le}. Received ${ct}`,Ke},RangeError);function it(Be){let le="",ce=Be.length;const Ke=Be[0]==="-"?1:0;for(;ce>=Ke+4;ce-=3)le=`_${Be.slice(ce-3,ce)}${le}`;return`${Be.slice(0,ce)}${le}`}function Ct(Be,le,ce){Et(le,"offset"),(Be[le]===void 0||Be[le+ce]===void 0)&&Zt(le,Be.length-(ce+1))}function It(Be,le,ce,Ke,ct,Wt){if(Be>ce||Be3?le===0||le===BigInt(0)?fn=`>= 0${Mt} and < 2${Mt} ** ${(Wt+1)*8}${Mt}`:fn=`>= -(2${Mt} ** ${(Wt+1)*8-1}${Mt}) and < 2 ** ${(Wt+1)*8-1}${Mt}`:fn=`>= ${le}${Mt} and <= ${ce}${Mt}`,new lt.ERR_OUT_OF_RANGE("value",fn,Be)}Ct(Ke,ct,Wt)}function Et(Be,le){if(typeof Be!="number")throw new lt.ERR_INVALID_ARG_TYPE(le,"number",Be)}function Zt(Be,le,ce){throw Math.floor(Be)!==Be?(Et(Be,ce),new lt.ERR_OUT_OF_RANGE(ce||"offset","an integer",Be)):le<0?new lt.ERR_BUFFER_OUT_OF_BOUNDS:new lt.ERR_OUT_OF_RANGE(ce||"offset",`>= ${ce?1:0} and <= ${le}`,Be)}const zt=/[^+/0-9A-Za-z-_]/g;function Kt(Be){if(Be=Be.split("=")[0],Be=Be.trim().replace(zt,""),Be.length<2)return"";for(;Be.length%4!==0;)Be=Be+"=";return Be}function Ut(Be,le){le=le||1/0;let ce;const Ke=Be.length;let ct=null;const Wt=[];for(let Mt=0;Mt55295&&ce<57344){if(!ct){if(ce>56319){(le-=3)>-1&&Wt.push(239,191,189);continue}else if(Mt+1===Ke){(le-=3)>-1&&Wt.push(239,191,189);continue}ct=ce;continue}if(ce<56320){(le-=3)>-1&&Wt.push(239,191,189),ct=ce;continue}ce=(ct-55296<<10|ce-56320)+65536}else ct&&(le-=3)>-1&&Wt.push(239,191,189);if(ct=null,ce<128){if((le-=1)<0)break;Wt.push(ce)}else if(ce<2048){if((le-=2)<0)break;Wt.push(ce>>6|192,ce&63|128)}else if(ce<65536){if((le-=3)<0)break;Wt.push(ce>>12|224,ce>>6&63|128,ce&63|128)}else if(ce<1114112){if((le-=4)<0)break;Wt.push(ce>>18|240,ce>>12&63|128,ce>>6&63|128,ce&63|128)}else throw new Error("Invalid code point")}return Wt}function ti(Be){const le=[];for(let ce=0;ce>8,ct=ce%256,Wt.push(ct),Wt.push(Ke);return Wt}function Cn(Be){return i.toByteArray(Kt(Be))}function on(Be,le,ce,Ke){let ct;for(ct=0;ct=le.length||ct>=Be.length);++ct)le[ct+ce]=Be[ct];return ct}function ki(Be,le){return Be instanceof le||Be!=null&&Be.constructor!=null&&Be.constructor.name!=null&&Be.constructor.name===le.name}function Ei(Be){return Be!==Be}const Bn=function(){const Be="0123456789abcdef",le=new Array(256);for(let ce=0;ce<16;++ce){const Ke=ce*16;for(let ct=0;ct<16;++ct)le[Ke+ct]=Be[ce]+Be[ct]}return le}();function Nr(Be){return typeof BigInt>"u"?kr:Be}function kr(){throw new Error("BigInt not supported")}})(pv);class Pgi extends Map{constructor(i={}){if(super(),!(i.maxSize&&i.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if(typeof i.maxAge=="number"&&i.maxAge===0)throw new TypeError("`maxAge` must be a number greater than 0");this.maxSize=i.maxSize,this.maxAge=i.maxAge||Number.POSITIVE_INFINITY,this.onEviction=i.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(i){if(typeof this.onEviction=="function")for(const[n,r]of i)this.onEviction(n,r.value)}_deleteIfExpired(i,n){return typeof n.expiry=="number"&&n.expiry<=Date.now()?(typeof this.onEviction=="function"&&this.onEviction(i,n.value),this.delete(i)):!1}_getOrDeleteIfExpired(i,n){if(this._deleteIfExpired(i,n)===!1)return n.value}_getItemValue(i,n){return n.expiry?this._getOrDeleteIfExpired(i,n):n.value}_peek(i,n){const r=n.get(i);return this._getItemValue(i,r)}_set(i,n){this.cache.set(i,n),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(i,n){this.oldCache.delete(i),this._set(i,n)}*_entriesAscending(){for(const i of this.oldCache){const[n,r]=i;this.cache.has(n)||this._deleteIfExpired(n,r)===!1&&(yield i)}for(const i of this.cache){const[n,r]=i;this._deleteIfExpired(n,r)===!1&&(yield i)}}get(i){if(this.cache.has(i)){const n=this.cache.get(i);return this._getItemValue(i,n)}if(this.oldCache.has(i)){const n=this.oldCache.get(i);if(this._deleteIfExpired(i,n)===!1)return this._moveToRecent(i,n),n.value}}set(i,n,{maxAge:r=this.maxAge}={}){const o=typeof r=="number"&&r!==Number.POSITIVE_INFINITY?Date.now()+r:void 0;this.cache.has(i)?this.cache.set(i,{value:n,expiry:o}):this._set(i,{value:n,expiry:o})}has(i){return this.cache.has(i)?!this._deleteIfExpired(i,this.cache.get(i)):this.oldCache.has(i)?!this._deleteIfExpired(i,this.oldCache.get(i)):!1}peek(i){if(this.cache.has(i))return this._peek(i,this.cache);if(this.oldCache.has(i))return this._peek(i,this.oldCache)}delete(i){const n=this.cache.delete(i);return n&&this._size--,this.oldCache.delete(i)||n}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(i){if(!(i&&i>0))throw new TypeError("`maxSize` must be a number greater than 0");const n=[...this._entriesAscending()],r=n.length-i;r<0?(this.cache=new Map(n),this.oldCache=new Map,this._size=n.length):(r>0&&this._emitEvictions(n.slice(0,r)),this.oldCache=new Map(n.slice(r)),this.cache=new Map,this._size=0),this.maxSize=i}*keys(){for(const[i]of this)yield i}*values(){for(const[,i]of this)yield i}*[Symbol.iterator](){for(const i of this.cache){const[n,r]=i;this._deleteIfExpired(n,r)===!1&&(yield[n,r.value])}for(const i of this.oldCache){const[n,r]=i;this.cache.has(n)||this._deleteIfExpired(n,r)===!1&&(yield[n,r.value])}}*entriesDescending(){let i=[...this.cache];for(let n=i.length-1;n>=0;--n){const r=i[n],[o,l]=r;this._deleteIfExpired(o,l)===!1&&(yield[o,l.value])}i=[...this.oldCache];for(let n=i.length-1;n>=0;--n){const r=i[n],[o,l]=r;this.cache.has(o)||this._deleteIfExpired(o,l)===!1&&(yield[o,l.value])}}*entriesAscending(){for(const[i,n]of this._entriesAscending())yield[i,n.value]}get size(){if(!this._size)return this.oldCache.size;let i=0;for(const n of this.oldCache.keys())this.cache.has(n)||i++;return Math.min(this._size+i,this.maxSize)}entries(){return this.entriesAscending()}forEach(i,n=this){for(const[r,o]of this.entriesAscending())i.call(n,o,r,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}}const zgi={},tee=typeof window<"u"?window:typeof self<"u"?self:{fetch:void 0};let HLe=class{async getBufferFromResponse(i){if(typeof i.buffer=="function")return i.buffer();if(typeof i.arrayBuffer=="function"){const n=await i.arrayBuffer();return pv.Buffer.from(n)}else throw new TypeError("invalid HTTP response object, has no buffer method, and no arrayBuffer method")}constructor(i,n={}){this.baseOverrides={},this.url=i;const r=n.fetch||tee.fetch&&tee.fetch.bind(tee);if(!r)throw new TypeError("no fetch function supplied, and none found in global environment");n.overrides&&(this.baseOverrides=n.overrides),this.fetchImplementation=r}async fetch(i,n){let r;try{r=await this.fetchImplementation(i,n)}catch(o){if(`${o}`.includes("Failed to fetch"))console.warn(`generic-filehandle: refetching ${i} to attempt to work around chrome CORS header caching bug`),r=await this.fetchImplementation(i,{...n,cache:"reload"});else throw o}return r}async read(i,n=0,r,o=0,l={}){const{headers:c={},signal:u,overrides:f={}}=l;r<1/0?c.range=`bytes=${o}-${o+r}`:r===1/0&&o!==0&&(c.range=`bytes=${o}-`);const m={...this.baseOverrides,...f,headers:{...c,...f.headers,...this.baseOverrides.headers},method:"GET",redirect:"follow",mode:"cors",signal:u},p=await this.fetch(this.url,m);if(!p.ok)throw new Error(`HTTP ${p.status} ${p.statusText} ${this.url}`);if(p.status===200&&o===0||p.status===206){const v=await this.getBufferFromResponse(p),B=v.copy(i,n,0,Math.min(r,v.length)),G=p.headers.get("content-range"),T=/\/(\d+)$/.exec(G||"");return T&&T[1]&&(this._stat={size:parseInt(T[1],10)}),{bytesRead:B,buffer:i}}throw p.status===200?new Error("${this.url} fetch returned status 200, expected 206"):new Error(`HTTP ${p.status} fetching ${this.url}`)}async readFile(i={}){let n,r;typeof i=="string"?(n=i,r={}):(n=i.encoding,r=i,delete r.encoding);const{headers:o={},signal:l,overrides:c={}}=r,u={headers:o,method:"GET",redirect:"follow",mode:"cors",signal:l,...this.baseOverrides,...c},f=await this.fetch(this.url,u);if(!f)throw new Error("generic-filehandle failed to fetch");if(f.status!==200)throw Object.assign(new Error(`HTTP ${f.status} fetching ${this.url}`),{status:f.status});if(n==="utf8")return f.text();if(n)throw new Error(`unsupported encoding: ${n}`);return this.getBufferFromResponse(f)}async stat(){if(!this._stat){const i=pv.Buffer.allocUnsafe(10);if(await this.read(i,0,10,0),!this._stat)throw new Error(`unable to determine size of file at ${this.url}`)}return this._stat}async close(){}};var XXe={},iee={},nee=34,UV=10,ree=13;function WLe(e){return new Function("d","return {"+e.map(function(i,n){return JSON.stringify(i)+": d["+n+'] || ""'}).join(",")+"}")}function Ogi(e,i){var n=WLe(e);return function(r,o){return i(n(r),o,e)}}function xXe(e){var i=Object.create(null),n=[];return e.forEach(function(r){for(var o in r)o in i||n.push(i[o]=o)}),n}function MI(e,i){var n=e+"",r=n.length;return r9999?"+"+MI(e,6):MI(e,4)}function Jgi(e){var i=e.getUTCHours(),n=e.getUTCMinutes(),r=e.getUTCSeconds(),o=e.getUTCMilliseconds();return isNaN(e)?"Invalid Date":Lgi(e.getUTCFullYear())+"-"+MI(e.getUTCMonth()+1,2)+"-"+MI(e.getUTCDate(),2)+(o?"T"+MI(i,2)+":"+MI(n,2)+":"+MI(r,2)+"."+MI(o,3)+"Z":r?"T"+MI(i,2)+":"+MI(n,2)+":"+MI(r,2)+"Z":n||i?"T"+MI(i,2)+":"+MI(n,2)+"Z":"")}function Ugi(e){var i=new RegExp('["'+e+` -\r]`),n=e.charCodeAt(0);function r(v,B){var G,T,V=o(v,function(E,W){if(G)return G(E,W-1);T=E,G=B?Ogi(E,B):WLe(E)});return V.columns=T||[],V}function o(v,B){var G=[],T=v.length,V=0,E=0,W,x=T<=0,k=!1;v.charCodeAt(T-1)===UV&&--T,v.charCodeAt(T-1)===ree&&--T;function F(){if(x)return iee;if(k)return k=!1,XXe;var L,O=V,Q;if(v.charCodeAt(O)===nee){for(;V++=T?x=!0:(Q=v.charCodeAt(V++))===UV?k=!0:Q===ree&&(k=!0,v.charCodeAt(V)===UV&&++V),v.slice(O+1,L-1).replace(/""/g,'"')}for(;V({events:{},emit(e,...i){let n=this.events[e]||[];for(let r=0,o=n.length;r{this.events[e]=this.events[e]?.filter(n=>i!==n)}}});var YK={exports:{}};const jgi=r3e(r6t);YK.exports;(function(e,i){function n(){return typeof Reflect<"u"&&Reflect.get?n=Reflect.get.bind():n=function(F,Y,L){var O=r(F,Y);if(O){var Q=Object.getOwnPropertyDescriptor(O,Y);return Q.get?Q.get.call(arguments.length<3?F:L):Q.value}},n.apply(this,arguments)}function r(k,F){for(;!Object.prototype.hasOwnProperty.call(k,F)&&(k=G(k),k!==null););return k}function o(k,F){if(typeof F!="function"&&F!==null)throw new TypeError("Super expression must either be null or a function");k.prototype=Object.create(F&&F.prototype,{constructor:{value:k,writable:!0,configurable:!0}}),Object.defineProperty(k,"prototype",{writable:!1}),F&&B(k,F)}function l(k){var F=p();return function(){var L=G(k),O;if(F){var Q=G(this).constructor;O=Reflect.construct(L,arguments,Q)}else O=L.apply(this,arguments);return c(this,O)}}function c(k,F){if(F&&(typeof F=="object"||typeof F=="function"))return F;if(F!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return u(k)}function u(k){if(k===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return k}function f(k){var F=typeof Map=="function"?new Map:void 0;return f=function(L){if(L===null||!v(L))return L;if(typeof L!="function")throw new TypeError("Super expression must either be null or a function");if(typeof F<"u"){if(F.has(L))return F.get(L);F.set(L,O)}function O(){return m(L,arguments,G(this).constructor)}return O.prototype=Object.create(L.prototype,{constructor:{value:O,enumerable:!1,writable:!0,configurable:!0}}),B(O,L)},f(k)}function m(k,F,Y){return p()?m=Reflect.construct.bind():m=function(O,Q,X){var $=[null];$.push.apply($,Q);var ee=Function.bind.apply(O,$),ne=new ee;return X&&B(ne,X.prototype),ne},m.apply(null,arguments)}function p(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function v(k){return Function.toString.call(k).indexOf("[native code]")!==-1}function B(k,F){return B=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(L,O){return L.__proto__=O,L},B(k,F)}function G(k){return G=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(Y){return Y.__proto__||Object.getPrototypeOf(Y)},G(k)}function T(k,F){if(!(k instanceof F))throw new TypeError("Cannot call a class as a function")}function V(k,F){for(var Y=0;Yg&&typeof g=="object"&&"default"in g?g:{default:g};function Q(g){if(g&&g.__esModule)return g;const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(g){for(const s in g)if(s!=="default"){const C=Object.getOwnPropertyDescriptor(g,s);Object.defineProperty(a,s,C.get?C:{enumerable:!0,get:()=>g[s]})}}return a.default=g,Object.freeze(a)}const X=O(F),$=O(Y),ee=Q(L);var ne=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};function ge(g){return g&&g.__esModule&&Object.prototype.hasOwnProperty.call(g,"default")?g.default:g}function Ae(g){var a=g.default;if(typeof a=="function"){var s=function(){return a.apply(this,arguments)};s.prototype=a.prototype}else s={};return Object.defineProperty(s,"__esModule",{value:!0}),Object.keys(g).forEach(function(C){var I=Object.getOwnPropertyDescriptor(g,C);Object.defineProperty(s,C,I.get?I:{enumerable:!0,get:function(){return g[C]}})}),s}var _={exports:{}},de,Ze;function me(){if(Ze)return de;Ze=1;var g="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return de=g,de}var be,Ee;function Je(){if(Ee)return be;Ee=1;var g=me();function a(){}function s(){}return s.resetWarningCache=a,be=function(){function C(d,h,y,Z,b,w){if(w!==g){var S=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw S.name="Invariant Violation",S}}C.isRequired=C;function I(){return C}var A={array:C,bigint:C,bool:C,func:C,number:C,object:C,string:C,symbol:C,any:C,arrayOf:I,element:C,elementType:C,instanceOf:I,node:C,objectOf:I,oneOf:I,oneOfType:I,shape:I,exact:I,checkPropTypes:s,resetWarningCache:a};return A.PropTypes=A,A},be}_.exports=Je()();var Ue="http://www.w3.org/1999/xhtml";const dt={svg:"http://www.w3.org/2000/svg",xhtml:Ue,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function rt(g){var a=g+="",s=a.indexOf(":");return s>=0&&(a=g.slice(0,s))!=="xmlns"&&(g=g.slice(s+1)),dt.hasOwnProperty(a)?{space:dt[a],local:g}:g}function ke(g){return function(){var a=this.ownerDocument,s=this.namespaceURI;return s===Ue&&a.documentElement.namespaceURI===Ue?a.createElement(g):a.createElementNS(s,g)}}function ze(g){return function(){return this.ownerDocument.createElementNS(g.space,g.local)}}function je(g){var a=rt(g);return(a.local?ze:ke)(a)}function lt(){}function xe(g){return g==null?lt:function(){return this.querySelector(g)}}function it(g){typeof g!="function"&&(g=xe(g));for(var a=this._groups,s=a.length,C=new Array(s),I=0;I=K&&(K=z+1);!(J=D[K])&&++K=0;)(d=C[I])&&(A&&d.compareDocumentPosition(A)^4&&A.parentNode.insertBefore(d,A),A=d);return this}function QO(g){g||(g=jO);function a(w,S){return w&&S?g(w.__data__,S.__data__):!w-!S}for(var s=this._groups,C=s.length,I=new Array(C),A=0;Aa?1:g>=a?0:NaN}function $O(){var g=arguments[0];return arguments[0]=this,g.apply(null,arguments),this}function qO(){return Array.from(this)}function eL(){for(var g=this._groups,a=0,s=g.length;a1?this.each((a==null?Le:typeof a=="function"?kt:ht)(g,a,s??"")):Si(this.node(),g)}function Si(g,a){return g.style.getPropertyValue(a)||st(g).getComputedStyle(g,null).getPropertyValue(a)}function Yi(g){return function(){delete this[g]}}function Jn(g,a){return function(){this[g]=a}}function eg(g,a){return function(){var s=a.apply(this,arguments);s==null?delete this[g]:this[g]=s}}function Yg(g,a){return arguments.length>1?this.each((a==null?Yi:typeof a=="function"?eg:Jn)(g,a)):this.node()[g]}function kn(g){return g.trim().split(/^|\s+/)}function Er(g){return g.classList||new Tg(g)}function Tg(g){this._node=g,this._names=kn(g.getAttribute("class")||"")}Tg.prototype={add:function(g){var a=this._names.indexOf(g);a<0&&(this._names.push(g),this._node.setAttribute("class",this._names.join(" ")))},remove:function(g){var a=this._names.indexOf(g);a>=0&&(this._names.splice(a,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(g){return this._names.indexOf(g)>=0}};function cn(g,a){for(var s=Er(g),C=-1,I=a.length;++C=0&&(s=a.slice(C+1),a=a.slice(0,C)),{type:a,name:s}})}function Snt(g){return function(){var a=this.__on;if(a){for(var s=0,C=-1,I=a.length,A;sxr(s,a))}function xnt(g){return typeof g=="string"?new _a([document.querySelectorAll(g)],[document.documentElement]):new _a([g==null?[]:Ct(g)],gL)}const Dnt=Object.freeze(Object.defineProperty({__proto__:null,create:Nnt,creator:je,local:$de,matcher:Kt,namespace:rt,namespaces:dt,pointer:xr,pointers:Xnt,select:Mn,selectAll:xnt,selection:ic,selector:xe,selectorAll:Et,style:Si,window:st},Symbol.toStringTag,{value:"Module"}));function Go(g,a){return ga?1:g>=a?0:NaN}function pZ(g){let a=g,s=g;g.length===1&&(a=(d,h)=>g(d)-h,s=Mnt(g));function C(d,h,y,Z){for(y==null&&(y=0),Z==null&&(Z=d.length);y>>1;s(d[b],h)<0?y=b+1:Z=b}return y}function I(d,h,y,Z){for(y==null&&(y=0),Z==null&&(Z=d.length);y>>1;s(d[b],h)>0?Z=b:y=b+1}return y}function A(d,h,y,Z){y==null&&(y=0),Z==null&&(Z=d.length);const b=C(d,h,y,Z-1);return b>y&&a(d[b-1],h)>-a(d[b],h)?b-1:b}return{left:C,center:A,right:I}}function Mnt(g){return(a,s)=>Go(g(a),s)}function ehe(g){return g===null?NaN:+g}function*Fnt(g,a){if(a===void 0)for(let s of g)s!=null&&(s=+s)>=s&&(yield s);else{let s=-1;for(let C of g)(C=a(C,++s,g))!=null&&(C=+C)>=C&&(yield C)}}const the=pZ(Go),ihe=the.right,Ynt=the.left,Knt=pZ(ehe).center,B0=ihe;function NN(g,a){let s=0;if(a===void 0)for(let C of g)C!=null&&(C=+C)>=C&&++s;else{let C=-1;for(let I of g)(I=a(I,++C,g))!=null&&(I=+I)>=I&&++s}return s}function _nt(g){return g.length|0}function Pnt(g){return!(g>0)}function znt(g){return typeof g!="object"||"length"in g?g:Array.from(g)}function Ont(g){return a=>g(...a)}function Lnt(...g){const a=typeof g[g.length-1]=="function"&&Ont(g.pop());g=g.map(znt);const s=g.map(_nt),C=g.length-1,I=new Array(C+1).fill(0),A=[];if(C<0||s.some(Pnt))return A;for(;;){A.push(I.map((h,y)=>g[y][h]));let d=C;for(;++I[d]===s[d];){if(d===0)return a?A.map(a):A;I[d--]=0}}}function Jnt(g,a){var s=0,C=0;return Float64Array.from(g,a===void 0?I=>s+=+I||0:I=>s+=+a(I,C++,g)||0)}function Unt(g,a){return ag?1:a>=g?0:NaN}function aL(g,a){let s=0,C,I=0,A=0;if(a===void 0)for(let d of g)d!=null&&(d=+d)>=d&&(C=d-I,I+=C/++s,A+=C*(d-I));else{let d=-1;for(let h of g)(h=a(h,++d,g))!=null&&(h=+h)>=h&&(C=h-I,I+=C/++s,A+=C*(h-I))}if(s>1)return A/(s-1)}function sL(g,a){const s=aL(g,a);return s&&Math.sqrt(s)}function kN(g,a){let s,C;if(a===void 0)for(const I of g)I!=null&&(s===void 0?I>=I&&(s=C=I):(s>I&&(s=I),C=A&&(s=C=A):(s>A&&(s=A),C0){for(h=s[--C];C>0&&(I=h,A=s[--C],h=I+A,d=A-(h-I),!d););C>0&&(d<0&&s[C-1]<0||d>0&&s[C-1]>0)&&(A=d*2,I=h+A,A==I-h&&(h=I))}return h}}]),g}();function Qnt(g,a){const s=new No;if(a===void 0)for(let C of g)(C=+C)&&s.add(C);else{let C=-1;for(let I of g)(I=+a(I,++C,g))&&s.add(I)}return+s}function jnt(g,a){const s=new No;let C=-1;return Float64Array.from(g,a===void 0?I=>s.add(+I||0):I=>s.add(+a(I,++C,g)||0))}let XN=function(g){o(s,g);var a=l(s);function s(C,I=ghe){var A;if(T(this,s),A=a.call(this),Object.defineProperties(u(A),{_intern:{value:new Map},_key:{value:I}}),C!=null)for(const[d,h]of C)A.set(d,h);return A}return E(s,[{key:"get",value:function(I){return n(G(s.prototype),"get",this).call(this,IL(this,I))}},{key:"has",value:function(I){return n(G(s.prototype),"has",this).call(this,IL(this,I))}},{key:"set",value:function(I,A){return n(G(s.prototype),"set",this).call(this,nhe(this,I),A)}},{key:"delete",value:function(I){return n(G(s.prototype),"delete",this).call(this,rhe(this,I))}}]),s}(f(Map)),$nt=function(g){o(s,g);var a=l(s);function s(C,I=ghe){var A;if(T(this,s),A=a.call(this),Object.defineProperties(u(A),{_intern:{value:new Map},_key:{value:I}}),C!=null)for(const d of C)A.add(d);return A}return E(s,[{key:"has",value:function(I){return n(G(s.prototype),"has",this).call(this,IL(this,I))}},{key:"add",value:function(I){return n(G(s.prototype),"add",this).call(this,nhe(this,I))}},{key:"delete",value:function(I){return n(G(s.prototype),"delete",this).call(this,rhe(this,I))}}]),s}(f(Set));function IL({_intern:g,_key:a},s){const C=a(s);return g.has(C)?g.get(C):s}function nhe({_intern:g,_key:a},s){const C=a(s);return g.has(C)?g.get(C):(g.set(C,s),s)}function rhe({_intern:g,_key:a},s){const C=a(s);return g.has(C)&&(s=g.get(s),g.delete(C)),s}function ghe(g){return g!==null&&typeof g=="object"?g.valueOf():g}function bZ(g){return g}function ohe(g,...a){return yZ(g,bZ,bZ,a)}function qnt(g,...a){return yZ(g,Array.from,bZ,a)}function ahe(g,a,...s){return yZ(g,bZ,a,s)}function ert(g,a,...s){return yZ(g,Array.from,a,s)}function trt(g,...a){return yZ(g,bZ,she,a)}function irt(g,...a){return yZ(g,Array.from,she,a)}function she(g){if(g.length!==1)throw new Error("duplicate key");return g[0]}function yZ(g,a,s,C){return function I(A,d){if(d>=C.length)return s(A);const h=new XN,y=C[d++];let Z=-1;for(const b of A){const w=y(b,++Z,A),S=h.get(w);S?S.push(b):h.set(w,[b])}for(const[b,w]of h)h.set(b,I(w,d));return a(h)}(g,0)}function Ihe(g,a){return Array.from(a,s=>g[s])}function lL(g,...a){if(typeof g[Symbol.iterator]!="function")throw new TypeError("values is not iterable");g=Array.from(g);let[s=Go]=a;if(s.length===1||a.length>1){const C=Uint32Array.from(g,(I,A)=>A);return a.length>1?(a=a.map(I=>g.map(I)),C.sort((I,A)=>{for(const d of a){const h=Go(d[I],d[A]);if(h)return h}})):(s=g.map(s),C.sort((I,A)=>Go(s[I],s[A]))),Ihe(g,C)}return g.sort(s)}function nrt(g,a,s){return(a.length===1?lL(ahe(g,a,s),([C,I],[A,d])=>Go(I,d)||Go(C,A)):lL(ohe(g,s),([C,I],[A,d])=>a(I,d)||Go(C,A))).map(([C])=>C)}var rrt=Array.prototype,grt=rrt.slice;function xN(g){return function(){return g}}var CL=Math.sqrt(50),cL=Math.sqrt(10),AL=Math.sqrt(2);function G0(g,a,s){var C,I=-1,A,d,h;if(a=+a,g=+g,s=+s,g===a&&s>0)return[g];if((C=a0){let y=Math.round(g/h),Z=Math.round(a/h);for(y*ha&&--Z,d=new Array(A=Z-y+1);++Ia&&--Z,d=new Array(A=Z-y+1);++I=0?(A>=CL?10:A>=cL?5:A>=AL?2:1)*Math.pow(10,I):-Math.pow(10,-I)/(A>=CL?10:A>=cL?5:A>=AL?2:1)}function DN(g,a,s){var C=Math.abs(a-g)/Math.max(0,s),I=Math.pow(10,Math.floor(Math.log(C)/Math.LN10)),A=C/I;return A>=CL?I*=10:A>=cL?I*=5:A>=AL&&(I*=2),a0?(g=Math.floor(g/I)*I,a=Math.ceil(a/I)*I):I<0&&(g=Math.ceil(g*I)/I,a=Math.floor(a*I)/I),C=I}}function Che(g){return Math.ceil(Math.log(NN(g))/Math.LN2)+1}function che(){var g=bZ,a=kN,s=Che;function C(I){Array.isArray(I)||(I=Array.from(I));var A,d=I.length,h,y=new Array(d);for(A=0;A=w)if(D>=w&&a===kN){const z=a2(b,w,M);isFinite(z)&&(z>0?w=(Math.floor(w/z)+1)*z:z<0&&(w=(Math.ceil(w*-z)+1)/-z))}else S.pop()}for(var R=S.length;S[0]<=b;)S.shift(),--R;for(;S[R-1]>w;)S.pop(),--R;var H=new Array(R+1),N;for(A=0;A<=R;++A)N=H[A]=[],N.x0=A>0?S[A-1]:b,N.x1=A=C)&&(s=C);else{let C=-1;for(let I of g)(I=a(I,++C,g))!=null&&(s=I)&&(s=I)}return s}function MN(g,a){let s;if(a===void 0)for(const C of g)C!=null&&(s>C||s===void 0&&C>=C)&&(s=C);else{let C=-1;for(let I of g)(I=a(I,++C,g))!=null&&(s>I||s===void 0&&I>=I)&&(s=I)}return s}function dL(g,a,s=0,C=g.length-1,I=Go){for(;C>s;){if(C-s>600){const y=C-s+1,Z=a-s+1,b=Math.log(y),w=.5*Math.exp(2*b/3),S=.5*Math.sqrt(b*w*(y-w)/y)*(Z-y/2<0?-1:1),R=Math.max(s,Math.floor(a-Z*w/y+S)),H=Math.min(C,Math.floor(a+(y-Z)*w/y+S));dL(g,a,R,H,I)}const A=g[a];let d=s,h=C;for(s2(g,s,a),I(g[C],A)>0&&s2(g,s,C);d0;)--h}I(g[s],A)===0?s2(g,s,h):(++h,s2(g,h,C)),h<=a&&(s=h+1),a<=h&&(C=h-1)}return g}function s2(g,a,s){const C=g[a];g[a]=g[s],g[s]=C}function I2(g,a,s){if(g=Float64Array.from(Fnt(g,s)),!!(C=g.length)){if((a=+a)<=0||C<2)return MN(g);if(a>=1)return uL(g);var C,I=(C-1)*a,A=Math.floor(I),d=uL(dL(g,A).subarray(0,A+1)),h=MN(g.subarray(A+1));return d+(h-d)*(I-A)}}function Ahe(g,a,s=ehe){if(C=g.length){if((a=+a)<=0||C<2)return+s(g[0],0,g);if(a>=1)return+s(g[C-1],C-1,g);var C,I=(C-1)*a,A=Math.floor(I),d=+s(g[A],A,g),h=+s(g[A+1],A+1,g);return d+(h-d)*(I-A)}}function ort(g,a,s){return Math.ceil((s-a)/(2*(I2(g,.75)-I2(g,.25))*Math.pow(NN(g),-1/3)))}function art(g,a,s){return Math.ceil((s-a)/(3.5*sL(g)*Math.pow(NN(g),-1/3)))}function uhe(g,a){let s,C=-1,I=-1;if(a===void 0)for(const A of g)++I,A!=null&&(s=A)&&(s=A,C=I);else for(let A of g)(A=a(A,++I,g))!=null&&(s=A)&&(s=A,C=I);return C}function hL(g,a){let s=0,C=0;if(a===void 0)for(let I of g)I!=null&&(I=+I)>=I&&(++s,C+=I);else{let I=-1;for(let A of g)(A=a(A,++I,g))!=null&&(A=+A)>=A&&(++s,C+=A)}if(s)return C/s}function fL(g,a){return I2(g,.5,a)}function*srt(g){for(const a of g)yield*a}function mL(g){return Array.from(srt(g))}function dhe(g,a){let s,C=-1,I=-1;if(a===void 0)for(const A of g)++I,A!=null&&(s>A||s===void 0&&A>=A)&&(s=A,C=I);else for(let A of g)(A=a(A,++I,g))!=null&&(s>A||s===void 0&&A>=A)&&(s=A,C=I);return C}function Irt(g,a=lrt){const s=[];let C,I=!1;for(const A of g)I&&s.push(a(C,A)),C=A,I=!0;return s}function lrt(g,a){return[g,a]}function Ns(g,a,s){g=+g,a=+a,s=(I=arguments.length)<2?(a=g,g=0,1):I<3?1:+s;for(var C=-1,I=Math.max(0,Math.ceil((a-g)/s))|0,A=new Array(I);++C0:Go(d,d)===0)&&(s=A,I=d,C=!0)}}else for(const I of g)(C?a(I,s)>0:a(I,I)===0)&&(s=I,C=!0);return s}function Art(g,a=Go){if(a.length===1)return uhe(g,a);let s,C=-1,I=-1;for(const A of g)++I,(C<0?a(A,A)===0:a(A,s)>0)&&(s=A,C=I);return C}function urt(g,a){const s=hhe(g,a);return s<0?void 0:s}const drt=fhe(Math.random);function fhe(g){return function(s,C=0,I=s.length){let A=I-(C=+C);for(;A;){const d=g()*A--|0,h=s[A+C];s[A+C]=s[d+C],s[d+C]=h}return s}}function mhe(g,a){let s=0;if(a===void 0)for(let C of g)(C=+C)&&(s+=C);else{let C=-1;for(let I of g)(I=+a(I,++C,g))&&(s+=I)}return s}function phe(g){if(!(A=g.length))return[];for(var a=-1,s=MN(g,hrt),C=new Array(s);++aa(s,C,g))}function vrt(g,a,s){if(typeof a!="function")throw new TypeError("reducer is not a function");const C=g[Symbol.iterator]();let I,A,d=-1;if(arguments.length<3){if({done:I,value:s}=C.next(),I)return;++d}for(;{done:I,value:A}=C.next(),!I;)s=a(s,A,++d,g);return s}function Zrt(g){if(typeof g[Symbol.iterator]!="function")throw new TypeError("values is not iterable");return Array.from(g).reverse()}function Brt(g,...a){g=new Set(g);for(const s of a)for(const C of s)g.delete(C);return g}function Grt(g,a){const s=a[Symbol.iterator](),C=new Set;for(const I of g){if(C.has(I))return!1;let A,d;for(;({value:A,done:d}=s.next())&&!d;){if(Object.is(I,A))return!1;C.add(A)}}return!0}function Srt(g){return g instanceof Set?g:new Set(g)}function wrt(g,...a){g=new Set(g),a=a.map(Srt);e:for(const s of g)for(const C of a)if(!C.has(s)){g.delete(s);continue e}return g}function bhe(g,a){const s=g[Symbol.iterator](),C=new Set;for(const I of a){if(C.has(I))continue;let A,d;for(;{value:A,done:d}=s.next();){if(d)return!1;if(C.add(A),Object.is(I,A))break}}return!0}function Trt(g,a){return bhe(a,g)}function Rrt(...g){const a=new Set;for(const s of g)for(const C of s)a.add(C);return a}const Vrt=Object.freeze(Object.defineProperty({__proto__:null,bisect:B0,bisectRight:ihe,bisectLeft:Ynt,bisectCenter:Knt,ascending:Go,bisector:pZ,count:NN,cross:Lnt,cumsum:Jnt,descending:Unt,deviation:sL,extent:kN,Adder:No,fsum:Qnt,fcumsum:jnt,group:ohe,groups:qnt,index:trt,indexes:irt,rollup:ahe,rollups:ert,groupSort:nrt,bin:che,histogram:che,thresholdFreedmanDiaconis:ort,thresholdScott:art,thresholdSturges:Che,max:uL,maxIndex:uhe,mean:hL,median:fL,merge:mL,min:MN,minIndex:dhe,nice:lhe,pairs:Irt,permute:Ihe,quantile:I2,quantileSorted:Ahe,quickselect:dL,range:Ns,least:Crt,leastIndex:hhe,greatest:crt,greatestIndex:Art,scan:urt,shuffle:drt,shuffler:fhe,sum:mhe,ticks:G0,tickIncrement:a2,tickStep:DN,transpose:phe,variance:aL,zip:frt,every:mrt,some:prt,filter:brt,map:yrt,reduce:vrt,reverse:Zrt,sort:lL,difference:Brt,disjoint:Grt,intersection:wrt,subset:Trt,superset:bhe,union:Rrt,InternMap:XN,InternSet:$nt},Symbol.toStringTag,{value:"Module"}));function iC(g,a){switch(arguments.length){case 0:break;case 1:this.range(g);break;default:this.range(a).domain(g);break}return this}function Xd(g,a){switch(arguments.length){case 0:break;case 1:{typeof g=="function"?this.interpolator(g):this.range(g);break}default:{this.domain(g),typeof a=="function"?this.interpolator(a):this.range(a);break}}return this}const pL=Symbol("implicit");function bL(){var g=new XN,a=[],s=[],C=pL;function I(A){let d=g.get(A);if(d===void 0){if(C!==pL)return C;g.set(A,d=a.push(A)-1)}return s[d%s.length]}return I.domain=function(A){if(!arguments.length)return a.slice();a=[],g=new XN;for(const d of A)g.has(d)||g.set(d,a.push(d)-1);return I},I.range=function(A){return arguments.length?(s=Array.from(A),I):s.slice()},I.unknown=function(A){return arguments.length?(C=A,I):C},I.copy=function(){return bL(a,s).unknown(C)},iC.apply(I,arguments),I}function l2(){var g=bL().unknown(void 0),a=g.domain,s=g.range,C=0,I=1,A,d,h=!1,y=0,Z=0,b=.5;delete g.unknown;function w(){var S=a().length,R=I>8&15|a>>4&240,a>>4&15|a&240,(a&15)<<4|a&15,1):s===8?FN(a>>24&255,a>>16&255,a>>8&255,(a&255)/255):s===4?FN(a>>12&15|a>>8&240,a>>8&15|a>>4&240,a>>4&15|a&240,((a&15)<<4|a&15)/255):null):(a=Wrt.exec(g))?new pa(a[1],a[2],a[3],1):(a=Nrt.exec(g))?new pa(a[1]*255/100,a[2]*255/100,a[3]*255/100,1):(a=krt.exec(g))?FN(a[1],a[2],a[3],a[4]):(a=Xrt.exec(g))?FN(a[1]*255/100,a[2]*255/100,a[3]*255/100,a[4]):(a=xrt.exec(g))?The(a[1],a[2]/100,a[3]/100,1):(a=Drt.exec(g))?The(a[1],a[2]/100,a[3]/100,a[4]):vhe.hasOwnProperty(g)?Ghe(vhe[g]):g==="transparent"?new pa(NaN,NaN,NaN,0):null}function Ghe(g){return new pa(g>>16&255,g>>8&255,g&255,1)}function FN(g,a,s,C){return C<=0&&(g=a=s=NaN),new pa(g,a,s,C)}function yL(g){return g instanceof Ef||(g=ko(g)),g?(g=g.rgb(),new pa(g.r,g.g,g.b,g.opacity)):new pa}function GZ(g,a,s,C){return arguments.length===1?yL(g):new pa(g,a,s,C??1)}function pa(g,a,s,C){this.r=+g,this.g=+a,this.b=+s,this.opacity=+C}vZ(pa,GZ,C2(Ef,{brighter:function(g){return g=g==null?ZZ:Math.pow(ZZ,g),new pa(this.r*g,this.g*g,this.b*g,this.opacity)},darker:function(g){return g=g==null?S0:Math.pow(S0,g),new pa(this.r*g,this.g*g,this.b*g,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:She,formatHex:She,formatRgb:whe,toString:whe}));function She(){return"#"+vL(this.r)+vL(this.g)+vL(this.b)}function whe(){var g=this.opacity;return g=isNaN(g)?1:Math.max(0,Math.min(1,g)),(g===1?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(g===1?")":", "+g+")")}function vL(g){return g=Math.max(0,Math.min(255,Math.round(g)||0)),(g<16?"0":"")+g.toString(16)}function The(g,a,s,C){return C<=0?g=a=s=NaN:s<=0||s>=1?g=a=NaN:a<=0&&(g=NaN),new MA(g,a,s,C)}function Rhe(g){if(g instanceof MA)return new MA(g.h,g.s,g.l,g.opacity);if(g instanceof Ef||(g=ko(g)),!g)return new MA;if(g instanceof MA)return g;g=g.rgb();var a=g.r/255,s=g.g/255,C=g.b/255,I=Math.min(a,s,C),A=Math.max(a,s,C),d=NaN,h=A-I,y=(A+I)/2;return h?(a===A?d=(s-C)/h+(s0&&y<1?0:d,new MA(d,h,y,g.opacity)}function Vhe(g,a,s,C){return arguments.length===1?Rhe(g):new MA(g,a,s,C??1)}function MA(g,a,s,C){this.h=+g,this.s=+a,this.l=+s,this.opacity=+C}vZ(MA,Vhe,C2(Ef,{brighter:function(g){return g=g==null?ZZ:Math.pow(ZZ,g),new MA(this.h,this.s,this.l*g,this.opacity)},darker:function(g){return g=g==null?S0:Math.pow(S0,g),new MA(this.h,this.s,this.l*g,this.opacity)},rgb:function(){var g=this.h%360+(this.h<0)*360,a=isNaN(g)||isNaN(this.s)?0:this.s,s=this.l,C=s+(s<.5?s:1-s)*a,I=2*s-C;return new pa(ZL(g>=240?g-240:g+120,I,C),ZL(g,I,C),ZL(g<120?g+240:g-120,I,C),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var g=this.opacity;return g=isNaN(g)?1:Math.max(0,Math.min(1,g)),(g===1?"hsl(":"hsla(")+(this.h||0)+", "+(this.s||0)*100+"%, "+(this.l||0)*100+"%"+(g===1?")":", "+g+")")}}));function ZL(g,a,s){return(g<60?a+(s-a)*g/60:g<180?s:g<240?a+(s-a)*(240-g)/60:a)*255}const Ehe=Math.PI/180,Hhe=180/Math.PI,YN=18,Whe=.96422,Nhe=1,khe=.82521,Xhe=4/29,SZ=6/29,xhe=3*SZ*SZ,Frt=SZ*SZ*SZ;function Dhe(g){if(g instanceof nc)return new nc(g.l,g.a,g.b,g.opacity);if(g instanceof FA)return Khe(g);g instanceof pa||(g=yL(g));var a=wL(g.r),s=wL(g.g),C=wL(g.b),I=BL((.2225045*a+.7168786*s+.0606169*C)/Nhe),A,d;return a===s&&s===C?A=d=I:(A=BL((.4360747*a+.3850649*s+.1430804*C)/Whe),d=BL((.0139322*a+.0971045*s+.7141733*C)/khe)),new nc(116*I-16,500*(A-I),200*(I-d),g.opacity)}function Yrt(g,a){return new nc(g,0,0,a??1)}function Mhe(g,a,s,C){return arguments.length===1?Dhe(g):new nc(g,a,s,C??1)}function nc(g,a,s,C){this.l=+g,this.a=+a,this.b=+s,this.opacity=+C}vZ(nc,Mhe,C2(Ef,{brighter:function(g){return new nc(this.l+YN*(g??1),this.a,this.b,this.opacity)},darker:function(g){return new nc(this.l-YN*(g??1),this.a,this.b,this.opacity)},rgb:function(){var g=(this.l+16)/116,a=isNaN(this.a)?g:g+this.a/500,s=isNaN(this.b)?g:g-this.b/200;return a=Whe*GL(a),g=Nhe*GL(g),s=khe*GL(s),new pa(SL(3.1338561*a-1.6168667*g-.4906146*s),SL(-.9787684*a+1.9161415*g+.033454*s),SL(.0719453*a-.2289914*g+1.4052427*s),this.opacity)}}));function BL(g){return g>Frt?Math.pow(g,1/3):g/xhe+Xhe}function GL(g){return g>SZ?g*g*g:xhe*(g-Xhe)}function SL(g){return 255*(g<=.0031308?12.92*g:1.055*Math.pow(g,1/2.4)-.055)}function wL(g){return(g/=255)<=.04045?g/12.92:Math.pow((g+.055)/1.055,2.4)}function Fhe(g){if(g instanceof FA)return new FA(g.h,g.c,g.l,g.opacity);if(g instanceof nc||(g=Dhe(g)),g.a===0&&g.b===0)return new FA(NaN,0()=>g;function zrt(g,a){return function(s){return g+s*a}}function Ort(g,a,s){return g=Math.pow(g,s),a=Math.pow(a,s)-g,s=1/s,function(C){return Math.pow(g+C*a,s)}}function Lrt(g){return(g=+g)==1?Jhe:function(a,s){return s-a?Ort(a,s,g):VL(isNaN(a)?s:a)}}function Jhe(g,a){var s=a-g;return s?zrt(g,s):VL(isNaN(g)?a:g)}const wZ=function g(a){var s=Lrt(a);function C(I,A){var d=s((I=GZ(I)).r,(A=GZ(A)).r),h=s(I.g,A.g),y=s(I.b,A.b),Z=Jhe(I.opacity,A.opacity);return function(b){return I.r=d(b),I.g=h(b),I.b=y(b),I.opacity=Z(b),I+""}}return C.gamma=g,C}(1);function Jrt(g,a){a||(a=[]);var s=g?Math.min(a.length,g.length):0,C=a.slice(),I;return function(A){for(I=0;Is&&(A=a.slice(s,A),h[d]?h[d]+=A:h[++d]=A),(C=C[0])===(I=I[0])?h[d]?h[d]+=I:h[++d]=I:(h[++d]=null,y.push({i:d,x:nC(C,I)})),s=HL.lastIndex;return s180?b+=360:b-Z>180&&(Z+=360),S.push({i:w.push(I(w)+"rotate(",null,C)-2,x:nC(Z,b)})):b&&w.push(I(w)+"rotate("+b+C)}function h(Z,b,w,S){Z!==b?S.push({i:w.push(I(w)+"skewX(",null,C)-2,x:nC(Z,b)}):b&&w.push(I(w)+"skewX("+b+C)}function y(Z,b,w,S,R,H){if(Z!==w||b!==S){var N=R.push(I(R)+"scale(",null,",",null,")");H.push({i:N-4,x:nC(Z,w)},{i:N-2,x:nC(b,S)})}else(w!==1||S!==1)&&R.push(I(R)+"scale("+w+","+S+")")}return function(Z,b){var w=[],S=[];return Z=g(Z),b=g(b),A(Z.translateX,Z.translateY,b.translateX,b.translateY,w,S),d(Z.rotate,b.rotate,w,S),h(Z.skewX,b.skewX,w,S),y(Z.scaleX,Z.scaleY,b.scaleX,b.scaleY,w,S),Z=b=null,function(R){for(var H=-1,N=S.length,D;++Ha&&(s=g,g=a,a=s),function(C){return Math.max(g,Math.min(a,C))}}function lgt(g,a,s){var C=g[0],I=g[1],A=a[0],d=a[1];return I2?Cgt:lgt,y=Z=null,w}function w(S){return S==null||isNaN(S=+S)?A:(y||(y=h(g.map(C),a,s)))(C(d(S)))}return w.invert=function(S){return d(I((Z||(Z=h(a,g.map(C),nC)))(S)))},w.domain=function(S){return arguments.length?(g=Array.from(S,PN),b()):g.slice()},w.range=function(S){return arguments.length?(a=Array.from(S),b()):a.slice()},w.rangeRound=function(S){return a=Array.from(S),s=NL,b()},w.clamp=function(S){return arguments.length?(d=S?!0:ks,b()):d!==ks},w.interpolate=function(S){return arguments.length?(s=S,b()):s},w.unknown=function(S){return arguments.length?(A=S,w):A},function(S,R){return C=S,I=R,b()}}function xL(){return zN()(ks,ks)}function cgt(g){return Math.abs(g=Math.round(g))>=1e21?g.toLocaleString("en").replace(/,/g,""):g.toString(10)}function ON(g,a){if((s=(g=a?g.toExponential(a-1):g.toExponential()).indexOf("e"))<0)return null;var s,C=g.slice(0,s);return[C.length>1?C[0]+C.slice(2):C,+g.slice(s+1)]}function TZ(g){return g=ON(Math.abs(g)),g?g[1]:NaN}function Agt(g,a){return function(s,C){for(var I=s.length,A=[],d=0,h=g[0],y=0;I>0&&h>0&&(y+h+1>C&&(h=Math.max(1,C-y)),A.push(s.substring(I-=h,I+h)),!((y+=h+1)>C));)h=g[d=(d+1)%g.length];return A.reverse().join(a)}}function ugt(g){return function(a){return a.replace(/[0-9]/g,function(s){return g[+s]})}}var dgt=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function RZ(g){if(!(a=dgt.exec(g)))throw new Error("invalid format: "+g);var a;return new LN({fill:a[1],align:a[2],sign:a[3],symbol:a[4],zero:a[5],width:a[6],comma:a[7],precision:a[8]&&a[8].slice(1),trim:a[9],type:a[10]})}RZ.prototype=LN.prototype;function LN(g){this.fill=g.fill===void 0?" ":g.fill+"",this.align=g.align===void 0?">":g.align+"",this.sign=g.sign===void 0?"-":g.sign+"",this.symbol=g.symbol===void 0?"":g.symbol+"",this.zero=!!g.zero,this.width=g.width===void 0?void 0:+g.width,this.comma=!!g.comma,this.precision=g.precision===void 0?void 0:+g.precision,this.trim=!!g.trim,this.type=g.type===void 0?"":g.type+""}LN.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function hgt(g){e:for(var a=g.length,s=1,C=-1,I;s0&&(C=0);break}return C>0?g.slice(0,C)+g.slice(I+1):g}var ife;function fgt(g,a){var s=ON(g,a);if(!s)return g+"";var C=s[0],I=s[1],A=I-(ife=Math.max(-8,Math.min(8,Math.floor(I/3)))*3)+1,d=C.length;return A===d?C:A>d?C+new Array(A-d+1).join("0"):A>0?C.slice(0,A)+"."+C.slice(A):"0."+new Array(1-A).join("0")+ON(g,Math.max(0,a+A-1))[0]}function nfe(g,a){var s=ON(g,a);if(!s)return g+"";var C=s[0],I=s[1];return I<0?"0."+new Array(-I).join("0")+C:C.length>I+1?C.slice(0,I+1)+"."+C.slice(I+1):C+new Array(I-C.length+2).join("0")}const rfe={"%":(g,a)=>(g*100).toFixed(a),b:g=>Math.round(g).toString(2),c:g=>g+"",d:cgt,e:(g,a)=>g.toExponential(a),f:(g,a)=>g.toFixed(a),g:(g,a)=>g.toPrecision(a),o:g=>Math.round(g).toString(8),p:(g,a)=>nfe(g*100,a),r:nfe,s:fgt,X:g=>Math.round(g).toString(16).toUpperCase(),x:g=>Math.round(g).toString(16)};function gfe(g){return g}var ofe=Array.prototype.map,afe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function sfe(g){var a=g.grouping===void 0||g.thousands===void 0?gfe:Agt(ofe.call(g.grouping,Number),g.thousands+""),s=g.currency===void 0?"":g.currency[0]+"",C=g.currency===void 0?"":g.currency[1]+"",I=g.decimal===void 0?".":g.decimal+"",A=g.numerals===void 0?gfe:ugt(ofe.call(g.numerals,String)),d=g.percent===void 0?"%":g.percent+"",h=g.minus===void 0?"−":g.minus+"",y=g.nan===void 0?"NaN":g.nan+"";function Z(w){w=RZ(w);var S=w.fill,R=w.align,H=w.sign,N=w.symbol,D=w.zero,M=w.width,z=w.comma,K=w.precision,P=w.trim,J=w.type;J==="n"?(z=!0,J="g"):rfe[J]||(K===void 0&&(K=12),P=!0,J="g"),(D||S==="0"&&R==="=")&&(D=!0,S="0",R="=");var j=N==="$"?s:N==="#"&&/[boxX]/.test(J)?"0"+J.toLowerCase():"",ie=N==="$"?C:/[%p]/.test(J)?d:"",te=rfe[J],Ce=/[defgprs%]/.test(J);K=K===void 0?6:/[gprs]/.test(J)?Math.max(1,Math.min(21,K)):Math.max(0,Math.min(20,K));function ue(oe){var he=j,ye=ie,Ie,fe,We;if(J==="c")ye=te(oe)+ye,oe="";else{oe=+oe;var _e=oe<0||1/oe<0;if(oe=isNaN(oe)?y:te(Math.abs(oe),K),P&&(oe=hgt(oe)),_e&&+oe==0&&H!=="+"&&(_e=!1),he=(_e?H==="("?H:h:H==="-"||H==="("?"":H)+he,ye=(J==="s"?afe[8+ife/3]:"")+ye+(_e&&H==="("?")":""),Ce){for(Ie=-1,fe=oe.length;++IeWe||We>57){ye=(We===46?I+oe.slice(Ie+1):oe.slice(Ie))+ye,oe=oe.slice(0,Ie);break}}}z&&!D&&(oe=a(oe,1/0));var qe=he.length+oe.length+ye.length,nt=qe>1)+he+oe+ye+nt.slice(qe);break;default:oe=nt+he+oe+ye;break}return A(oe)}return ue.toString=function(){return w+""},ue}function b(w,S){var R=Z((w=RZ(w),w.type="f",w)),H=Math.max(-8,Math.min(8,Math.floor(TZ(S)/3)))*3,N=Math.pow(10,-H),D=afe[8+H/3];return function(M){return R(N*M)+D}}return{format:Z,formatPrefix:b}}var JN,fl,R0;Ife({thousands:",",grouping:[3],currency:["$",""]});function Ife(g){return JN=sfe(g),fl=JN.format,R0=JN.formatPrefix,JN}function lfe(g){return Math.max(0,-TZ(Math.abs(g)))}function VZ(g,a){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(TZ(a)/3)))*3-TZ(Math.abs(g)))}function Cfe(g,a){return g=Math.abs(g),a=Math.abs(a)-g,Math.max(0,TZ(a)-TZ(g))+1}const mgt=Object.freeze(Object.defineProperty({__proto__:null,formatDefaultLocale:Ife,get format(){return fl},get formatPrefix(){return R0},formatLocale:sfe,formatSpecifier:RZ,FormatSpecifier:LN,precisionFixed:lfe,precisionPrefix:VZ,precisionRound:Cfe},Symbol.toStringTag,{value:"Module"}));function cfe(g,a,s,C){var I=DN(g,a,s),A;switch(C=RZ(C??",f"),C.type){case"s":{var d=Math.max(Math.abs(g),Math.abs(a));return C.precision==null&&!isNaN(A=VZ(I,d))&&(C.precision=A),R0(C,d)}case"":case"e":case"g":case"p":case"r":{C.precision==null&&!isNaN(A=Cfe(I,Math.max(Math.abs(g),Math.abs(a))))&&(C.precision=A-(C.type==="e"));break}case"f":case"%":{C.precision==null&&!isNaN(A=lfe(I))&&(C.precision=A-(C.type==="%")*2);break}}return fl(C)}function Hf(g){var a=g.domain;return g.ticks=function(s){var C=a();return G0(C[0],C[C.length-1],s??10)},g.tickFormat=function(s,C){var I=a();return cfe(I[0],I[I.length-1],s??10,C)},g.nice=function(s){s==null&&(s=10);var C=a(),I=0,A=C.length-1,d=C[I],h=C[A],y,Z,b=10;for(h0;){if(Z=a2(d,h,s),Z===y)return C[I]=d,C[A]=h,a(C);if(Z>0)d=Math.floor(d/Z)*Z,h=Math.ceil(h/Z)*Z;else if(Z<0)d=Math.ceil(d*Z)/Z,h=Math.floor(h*Z)/Z;else break;y=Z}return g},g}function Zn(){var g=xL();return g.copy=function(){return u2(g,Zn())},iC.apply(g,arguments),Hf(g)}function Afe(g){var a;function s(C){return C==null||isNaN(C=+C)?a:C}return s.invert=s,s.domain=s.range=function(C){return arguments.length?(g=Array.from(C,PN),s):g.slice()},s.unknown=function(C){return arguments.length?(a=C,s):a},s.copy=function(){return Afe(g).unknown(a)},g=arguments.length?Array.from(g,PN):[0,1],Hf(s)}function ufe(g,a){g=g.slice();var s=0,C=g.length-1,I=g[s],A=g[C],d;return AMath.pow(g,a)}function Zgt(g){return g===Math.E?Math.log:g===10&&Math.log10||g===2&&Math.log2||(g=Math.log(g),a=>Math.log(a)/g)}function ffe(g){return(a,s)=>-g(-a,s)}function DL(g){const a=g(dfe,hfe),s=a.domain;let C=10,I,A;function d(){return I=Zgt(C),A=vgt(C),s()[0]<0?(I=ffe(I),A=ffe(A),g(pgt,bgt)):g(dfe,hfe),a}return a.base=function(h){return arguments.length?(C=+h,d()):C},a.domain=function(h){return arguments.length?(s(h),d()):s()},a.ticks=h=>{const y=s();let Z=y[0],b=y[y.length-1];const w=b0){for(;S<=R;++S)for(H=1;Hb)break;M.push(N)}}else for(;S<=R;++S)for(H=C-1;H>=1;--H)if(N=S>0?H/A(-S):H*A(S),!(Nb)break;M.push(N)}M.length*2{if(h==null&&(h=10),y==null&&(y=C===10?"s":","),typeof y!="function"&&(!(C%1)&&(y=RZ(y)).precision==null&&(y.trim=!0),y=fl(y)),h===1/0)return y;const Z=Math.max(1,C*h/a.ticks().length);return b=>{let w=b/A(Math.round(I(b)));return w*Cs(ufe(s(),{floor:h=>A(Math.floor(I(h))),ceil:h=>A(Math.ceil(I(h)))})),a}function Wf(){const g=DL(zN()).domain([1,10]);return g.copy=()=>u2(g,Wf()).base(g.base()),iC.apply(g,arguments),g}function mfe(g){return function(a){return Math.sign(a)*Math.log1p(Math.abs(a/g))}}function pfe(g){return function(a){return Math.sign(a)*Math.expm1(Math.abs(a))*g}}function ML(g){var a=1,s=g(mfe(a),pfe(a));return s.constant=function(C){return arguments.length?g(mfe(a=+C),pfe(a)):a},Hf(s)}function bfe(){var g=ML(zN());return g.copy=function(){return u2(g,bfe()).constant(g.constant())},iC.apply(g,arguments)}function yfe(g){return function(a){return a<0?-Math.pow(-a,g):Math.pow(a,g)}}function Bgt(g){return g<0?-Math.sqrt(-g):Math.sqrt(g)}function Ggt(g){return g<0?-g*g:g*g}function FL(g){var a=g(ks,ks),s=1;function C(){return s===1?g(ks,ks):s===.5?g(Bgt,Ggt):g(yfe(s),yfe(1/s))}return a.exponent=function(I){return arguments.length?(s=+I,C()):s},Hf(a)}function YL(){var g=FL(zN());return g.copy=function(){return u2(g,YL()).exponent(g.exponent())},iC.apply(g,arguments),g}function Sgt(){return YL.apply(null,arguments).exponent(.5)}function vfe(g){return Math.sign(g)*g*g}function wgt(g){return Math.sign(g)*Math.sqrt(Math.abs(g))}function Zfe(){var g=xL(),a=[0,1],s=!1,C;function I(A){var d=wgt(g(A));return isNaN(d)?C:s?Math.round(d):d}return I.invert=function(A){return g.invert(vfe(A))},I.domain=function(A){return arguments.length?(g.domain(A),I):g.domain()},I.range=function(A){return arguments.length?(g.range((a=Array.from(A,PN)).map(vfe)),I):a.slice()},I.rangeRound=function(A){return I.range(A).round(!0)},I.round=function(A){return arguments.length?(s=!!A,I):s},I.clamp=function(A){return arguments.length?(g.clamp(A),I):g.clamp()},I.unknown=function(A){return arguments.length?(C=A,I):C},I.copy=function(){return Zfe(g.domain(),a).round(s).clamp(g.clamp()).unknown(C)},iC.apply(I,arguments),Hf(I)}function UN(){var g=[],a=[],s=[],C;function I(){var d=0,h=Math.max(1,a.length);for(s=new Array(h-1);++d0?s[h-1]:g[0],h=s?[C[s-1],a]:[C[Z-1],C[Z]]},d.unknown=function(y){return arguments.length&&(A=y),d},d.thresholds=function(){return C.slice()},d.copy=function(){return Bfe().domain([g,a]).range(I).unknown(A)},iC.apply(Hf(d),arguments)}function Gfe(){var g=[.5],a=[0,1],s,C=1;function I(A){return A!=null&&A<=A?a[B0(g,A,0,C)]:s}return I.domain=function(A){return arguments.length?(g=Array.from(A),C=Math.min(g.length,a.length-1),I):g.slice()},I.range=function(A){return arguments.length?(a=Array.from(A),C=Math.min(g.length,a.length-1),I):a.slice()},I.invertExtent=function(A){var d=a.indexOf(A);return[g[d-1],g[d]]},I.unknown=function(A){return arguments.length?(s=A,I):s},I.copy=function(){return Gfe().domain(g).range(a).unknown(s)},iC.apply(I,arguments)}const KL=new Date,_L=new Date;function Xo(g,a,s,C){function I(A){return g(A=arguments.length===0?new Date:new Date(+A)),A}return I.floor=A=>(g(A=new Date(+A)),A),I.ceil=A=>(g(A=new Date(A-1)),a(A,1),g(A),A),I.round=A=>{const d=I(A),h=I.ceil(A);return A-d(a(A=new Date(+A),d==null?1:Math.floor(d)),A),I.range=(A,d,h)=>{const y=[];if(A=I.ceil(A),h=h==null?1:Math.floor(h),!(A0))return y;let Z;do y.push(Z=new Date(+A)),a(A,h),g(A);while(ZXo(d=>{if(d>=d)for(;g(d),!A(d);)d.setTime(d-1)},(d,h)=>{if(d>=d)if(h<0)for(;++h<=0;)for(;a(d,-1),!A(d););else for(;--h>=0;)for(;a(d,1),!A(d););}),s&&(I.count=(A,d)=>(KL.setTime(+A),_L.setTime(+d),g(KL),g(_L),Math.floor(s(KL,_L))),I.every=A=>(A=Math.floor(A),!isFinite(A)||!(A>0)?null:A>1?I.filter(C?d=>C(d)%A===0:d=>I.count(0,d)%A===0):I)),I}const QN=Xo(()=>{},(g,a)=>{g.setTime(+g+a)},(g,a)=>a-g);QN.every=g=>(g=Math.floor(g),!isFinite(g)||!(g>0)?null:g>1?Xo(a=>{a.setTime(Math.floor(a/g)*g)},(a,s)=>{a.setTime(+a+s*g)},(a,s)=>(s-a)/g):QN),QN.range;const xd=1e3,rC=xd*60,Dd=rC*60,Md=Dd*24,PL=Md*7,Sfe=Md*30,zL=Md*365,V0=Xo(g=>{g.setTime(g-g.getMilliseconds())},(g,a)=>{g.setTime(+g+a*xd)},(g,a)=>(a-g)/xd,g=>g.getUTCSeconds());V0.range;const OL=Xo(g=>{g.setTime(g-g.getMilliseconds()-g.getSeconds()*xd)},(g,a)=>{g.setTime(+g+a*rC)},(g,a)=>(a-g)/rC,g=>g.getMinutes());OL.range;const LL=Xo(g=>{g.setUTCSeconds(0,0)},(g,a)=>{g.setTime(+g+a*rC)},(g,a)=>(a-g)/rC,g=>g.getUTCMinutes());LL.range;const JL=Xo(g=>{g.setTime(g-g.getMilliseconds()-g.getSeconds()*xd-g.getMinutes()*rC)},(g,a)=>{g.setTime(+g+a*Dd)},(g,a)=>(a-g)/Dd,g=>g.getHours());JL.range;const UL=Xo(g=>{g.setUTCMinutes(0,0,0)},(g,a)=>{g.setTime(+g+a*Dd)},(g,a)=>(a-g)/Dd,g=>g.getUTCHours());UL.range;const d2=Xo(g=>g.setHours(0,0,0,0),(g,a)=>g.setDate(g.getDate()+a),(g,a)=>(a-g-(a.getTimezoneOffset()-g.getTimezoneOffset())*rC)/Md,g=>g.getDate()-1);d2.range;const jN=Xo(g=>{g.setUTCHours(0,0,0,0)},(g,a)=>{g.setUTCDate(g.getUTCDate()+a)},(g,a)=>(a-g)/Md,g=>g.getUTCDate()-1);jN.range;const wfe=Xo(g=>{g.setUTCHours(0,0,0,0)},(g,a)=>{g.setUTCDate(g.getUTCDate()+a)},(g,a)=>(a-g)/Md,g=>Math.floor(g/Md));wfe.range;function E0(g){return Xo(a=>{a.setDate(a.getDate()-(a.getDay()+7-g)%7),a.setHours(0,0,0,0)},(a,s)=>{a.setDate(a.getDate()+s*7)},(a,s)=>(s-a-(s.getTimezoneOffset()-a.getTimezoneOffset())*rC)/PL)}const $N=E0(0),qN=E0(1),Tgt=E0(2),Rgt=E0(3),EZ=E0(4),Vgt=E0(5),Egt=E0(6);$N.range,qN.range,Tgt.range,Rgt.range,EZ.range,Vgt.range,Egt.range;function H0(g){return Xo(a=>{a.setUTCDate(a.getUTCDate()-(a.getUTCDay()+7-g)%7),a.setUTCHours(0,0,0,0)},(a,s)=>{a.setUTCDate(a.getUTCDate()+s*7)},(a,s)=>(s-a)/PL)}const ek=H0(0),tk=H0(1),Hgt=H0(2),Wgt=H0(3),HZ=H0(4),Ngt=H0(5),kgt=H0(6);ek.range,tk.range,Hgt.range,Wgt.range,HZ.range,Ngt.range,kgt.range;const QL=Xo(g=>{g.setDate(1),g.setHours(0,0,0,0)},(g,a)=>{g.setMonth(g.getMonth()+a)},(g,a)=>a.getMonth()-g.getMonth()+(a.getFullYear()-g.getFullYear())*12,g=>g.getMonth());QL.range;const jL=Xo(g=>{g.setUTCDate(1),g.setUTCHours(0,0,0,0)},(g,a)=>{g.setUTCMonth(g.getUTCMonth()+a)},(g,a)=>a.getUTCMonth()-g.getUTCMonth()+(a.getUTCFullYear()-g.getUTCFullYear())*12,g=>g.getUTCMonth());jL.range;const Fd=Xo(g=>{g.setMonth(0,1),g.setHours(0,0,0,0)},(g,a)=>{g.setFullYear(g.getFullYear()+a)},(g,a)=>a.getFullYear()-g.getFullYear(),g=>g.getFullYear());Fd.every=g=>!isFinite(g=Math.floor(g))||!(g>0)?null:Xo(a=>{a.setFullYear(Math.floor(a.getFullYear()/g)*g),a.setMonth(0,1),a.setHours(0,0,0,0)},(a,s)=>{a.setFullYear(a.getFullYear()+s*g)}),Fd.range;const Yd=Xo(g=>{g.setUTCMonth(0,1),g.setUTCHours(0,0,0,0)},(g,a)=>{g.setUTCFullYear(g.getUTCFullYear()+a)},(g,a)=>a.getUTCFullYear()-g.getUTCFullYear(),g=>g.getUTCFullYear());Yd.every=g=>!isFinite(g=Math.floor(g))||!(g>0)?null:Xo(a=>{a.setUTCFullYear(Math.floor(a.getUTCFullYear()/g)*g),a.setUTCMonth(0,1),a.setUTCHours(0,0,0,0)},(a,s)=>{a.setUTCFullYear(a.getUTCFullYear()+s*g)}),Yd.range;function Tfe(g,a,s,C,I,A){const d=[[V0,1,xd],[V0,5,5*xd],[V0,15,15*xd],[V0,30,30*xd],[A,1,rC],[A,5,5*rC],[A,15,15*rC],[A,30,30*rC],[I,1,Dd],[I,3,3*Dd],[I,6,6*Dd],[I,12,12*Dd],[C,1,Md],[C,2,2*Md],[s,1,PL],[a,1,Sfe],[a,3,3*Sfe],[g,1,zL]];function h(Z,b,w){const S=bD).right(d,S);if(R===d.length)return g.every(DN(Z/zL,b/zL,w));if(R===0)return QN.every(Math.max(DN(Z,b,w),1));const[H,N]=d[S/d[R-1][2]53)return null;"w"in Dt||(Dt.w=1),"Z"in Dt?(ui=qL(h2(Dt.y,0,1)),In=ui.getUTCDay(),ui=In>4||In===0?tk.ceil(ui):tk(ui),ui=jN.offset(ui,(Dt.V-1)*7),Dt.y=ui.getUTCFullYear(),Dt.m=ui.getUTCMonth(),Dt.d=ui.getUTCDate()+(Dt.w+6)%7):(ui=$L(h2(Dt.y,0,1)),In=ui.getDay(),ui=In>4||In===0?qN.ceil(ui):qN(ui),ui=d2.offset(ui,(Dt.V-1)*7),Dt.y=ui.getFullYear(),Dt.m=ui.getMonth(),Dt.d=ui.getDate()+(Dt.w+6)%7)}else("W"in Dt||"U"in Dt)&&("w"in Dt||(Dt.w="u"in Dt?Dt.u%7:"W"in Dt?1:0),In="Z"in Dt?qL(h2(Dt.y,0,1)).getUTCDay():$L(h2(Dt.y,0,1)).getDay(),Dt.m=0,Dt.d="W"in Dt?(Dt.w+6)%7+Dt.W*7-(In+5)%7:Dt.w+Dt.U*7-(In+6)%7);return"Z"in Dt?(Dt.H+=Dt.Z/100|0,Dt.M+=Dt.Z%100,qL(Dt)):$L(Dt)}}function te(Vt,_t,Ci,Dt){for(var Zi=0,ui=_t.length,In=Ci.length,Li,Bi;Zi=In)return-1;if(Li=_t.charCodeAt(Zi++),Li===37){if(Li=_t.charAt(Zi++),Bi=J[Li in Rfe?_t.charAt(Zi++):Li],!Bi||(Dt=Bi(Vt,Ci,Dt))<0)return-1}else if(Li!=Ci.charCodeAt(Dt++))return-1}return Dt}function Ce(Vt,_t,Ci){var Dt=Z.exec(_t.slice(Ci));return Dt?(Vt.p=b.get(Dt[0].toLowerCase()),Ci+Dt[0].length):-1}function ue(Vt,_t,Ci){var Dt=R.exec(_t.slice(Ci));return Dt?(Vt.w=H.get(Dt[0].toLowerCase()),Ci+Dt[0].length):-1}function oe(Vt,_t,Ci){var Dt=w.exec(_t.slice(Ci));return Dt?(Vt.w=S.get(Dt[0].toLowerCase()),Ci+Dt[0].length):-1}function he(Vt,_t,Ci){var Dt=M.exec(_t.slice(Ci));return Dt?(Vt.m=z.get(Dt[0].toLowerCase()),Ci+Dt[0].length):-1}function ye(Vt,_t,Ci){var Dt=N.exec(_t.slice(Ci));return Dt?(Vt.m=D.get(Dt[0].toLowerCase()),Ci+Dt[0].length):-1}function Ie(Vt,_t,Ci){return te(Vt,a,_t,Ci)}function fe(Vt,_t,Ci){return te(Vt,s,_t,Ci)}function We(Vt,_t,Ci){return te(Vt,C,_t,Ci)}function _e(Vt){return d[Vt.getDay()]}function qe(Vt){return A[Vt.getDay()]}function nt(Vt){return y[Vt.getMonth()]}function At(Vt){return h[Vt.getMonth()]}function Tt(Vt){return I[+(Vt.getHours()>=12)]}function Ne(Vt){return 1+~~(Vt.getMonth()/3)}function Ge(Vt){return d[Vt.getUTCDay()]}function He(Vt){return A[Vt.getUTCDay()]}function Xe(Vt){return y[Vt.getUTCMonth()]}function at(Vt){return h[Vt.getUTCMonth()]}function bt(Vt){return I[+(Vt.getUTCHours()>=12)]}function xt(Vt){return 1+~~(Vt.getUTCMonth()/3)}return{format:function(Vt){var _t=j(Vt+="",K);return _t.toString=function(){return Vt},_t},parse:function(Vt){var _t=ie(Vt+="",!1);return _t.toString=function(){return Vt},_t},utcFormat:function(Vt){var _t=j(Vt+="",P);return _t.toString=function(){return Vt},_t},utcParse:function(Vt){var _t=ie(Vt+="",!0);return _t.toString=function(){return Vt},_t}}}var Rfe={"-":"",_:" ",0:"0"},$o=/^\s*\d+/,Ygt=/^%/,Kgt=/[\\^$*+?|[\]().{}]/g;function ur(g,a,s){var C=g<0?"-":"",I=(C?-g:g)+"",A=I.length;return C+(A[a.toLowerCase(),s]))}function Pgt(g,a,s){var C=$o.exec(a.slice(s,s+1));return C?(g.w=+C[0],s+C[0].length):-1}function zgt(g,a,s){var C=$o.exec(a.slice(s,s+1));return C?(g.u=+C[0],s+C[0].length):-1}function Ogt(g,a,s){var C=$o.exec(a.slice(s,s+2));return C?(g.U=+C[0],s+C[0].length):-1}function Lgt(g,a,s){var C=$o.exec(a.slice(s,s+2));return C?(g.V=+C[0],s+C[0].length):-1}function Jgt(g,a,s){var C=$o.exec(a.slice(s,s+2));return C?(g.W=+C[0],s+C[0].length):-1}function Vfe(g,a,s){var C=$o.exec(a.slice(s,s+4));return C?(g.y=+C[0],s+C[0].length):-1}function Efe(g,a,s){var C=$o.exec(a.slice(s,s+2));return C?(g.y=+C[0]+(+C[0]>68?1900:2e3),s+C[0].length):-1}function Ugt(g,a,s){var C=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(a.slice(s,s+6));return C?(g.Z=C[1]?0:-(C[2]+(C[3]||"00")),s+C[0].length):-1}function Qgt(g,a,s){var C=$o.exec(a.slice(s,s+1));return C?(g.q=C[0]*3-3,s+C[0].length):-1}function jgt(g,a,s){var C=$o.exec(a.slice(s,s+2));return C?(g.m=C[0]-1,s+C[0].length):-1}function Hfe(g,a,s){var C=$o.exec(a.slice(s,s+2));return C?(g.d=+C[0],s+C[0].length):-1}function $gt(g,a,s){var C=$o.exec(a.slice(s,s+3));return C?(g.m=0,g.d=+C[0],s+C[0].length):-1}function Wfe(g,a,s){var C=$o.exec(a.slice(s,s+2));return C?(g.H=+C[0],s+C[0].length):-1}function qgt(g,a,s){var C=$o.exec(a.slice(s,s+2));return C?(g.M=+C[0],s+C[0].length):-1}function eot(g,a,s){var C=$o.exec(a.slice(s,s+2));return C?(g.S=+C[0],s+C[0].length):-1}function tot(g,a,s){var C=$o.exec(a.slice(s,s+3));return C?(g.L=+C[0],s+C[0].length):-1}function iot(g,a,s){var C=$o.exec(a.slice(s,s+6));return C?(g.L=Math.floor(C[0]/1e3),s+C[0].length):-1}function not(g,a,s){var C=Ygt.exec(a.slice(s,s+1));return C?s+C[0].length:-1}function rot(g,a,s){var C=$o.exec(a.slice(s));return C?(g.Q=+C[0],s+C[0].length):-1}function got(g,a,s){var C=$o.exec(a.slice(s));return C?(g.s=+C[0],s+C[0].length):-1}function Nfe(g,a){return ur(g.getDate(),a,2)}function oot(g,a){return ur(g.getHours(),a,2)}function aot(g,a){return ur(g.getHours()%12||12,a,2)}function sot(g,a){return ur(1+d2.count(Fd(g),g),a,3)}function kfe(g,a){return ur(g.getMilliseconds(),a,3)}function Iot(g,a){return kfe(g,a)+"000"}function lot(g,a){return ur(g.getMonth()+1,a,2)}function Cot(g,a){return ur(g.getMinutes(),a,2)}function cot(g,a){return ur(g.getSeconds(),a,2)}function Aot(g){var a=g.getDay();return a===0?7:a}function uot(g,a){return ur($N.count(Fd(g)-1,g),a,2)}function Xfe(g){var a=g.getDay();return a>=4||a===0?EZ(g):EZ.ceil(g)}function dot(g,a){return g=Xfe(g),ur(EZ.count(Fd(g),g)+(Fd(g).getDay()===4),a,2)}function hot(g){return g.getDay()}function fot(g,a){return ur(qN.count(Fd(g)-1,g),a,2)}function mot(g,a){return ur(g.getFullYear()%100,a,2)}function pot(g,a){return g=Xfe(g),ur(g.getFullYear()%100,a,2)}function bot(g,a){return ur(g.getFullYear()%1e4,a,4)}function yot(g,a){var s=g.getDay();return g=s>=4||s===0?EZ(g):EZ.ceil(g),ur(g.getFullYear()%1e4,a,4)}function vot(g){var a=g.getTimezoneOffset();return(a>0?"-":(a*=-1,"+"))+ur(a/60|0,"0",2)+ur(a%60,"0",2)}function xfe(g,a){return ur(g.getUTCDate(),a,2)}function Zot(g,a){return ur(g.getUTCHours(),a,2)}function Bot(g,a){return ur(g.getUTCHours()%12||12,a,2)}function Got(g,a){return ur(1+jN.count(Yd(g),g),a,3)}function Dfe(g,a){return ur(g.getUTCMilliseconds(),a,3)}function Sot(g,a){return Dfe(g,a)+"000"}function wot(g,a){return ur(g.getUTCMonth()+1,a,2)}function Tot(g,a){return ur(g.getUTCMinutes(),a,2)}function Rot(g,a){return ur(g.getUTCSeconds(),a,2)}function Vot(g){var a=g.getUTCDay();return a===0?7:a}function Eot(g,a){return ur(ek.count(Yd(g)-1,g),a,2)}function Mfe(g){var a=g.getUTCDay();return a>=4||a===0?HZ(g):HZ.ceil(g)}function Hot(g,a){return g=Mfe(g),ur(HZ.count(Yd(g),g)+(Yd(g).getUTCDay()===4),a,2)}function Wot(g){return g.getUTCDay()}function Not(g,a){return ur(tk.count(Yd(g)-1,g),a,2)}function kot(g,a){return ur(g.getUTCFullYear()%100,a,2)}function Xot(g,a){return g=Mfe(g),ur(g.getUTCFullYear()%100,a,2)}function xot(g,a){return ur(g.getUTCFullYear()%1e4,a,4)}function Dot(g,a){var s=g.getUTCDay();return g=s>=4||s===0?HZ(g):HZ.ceil(g),ur(g.getUTCFullYear()%1e4,a,4)}function Mot(){return"+0000"}function Ffe(){return"%"}function Yfe(g){return+g}function Kfe(g){return Math.floor(+g/1e3)}var WZ,_fe,Pfe;Fot({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function Fot(g){return WZ=Fgt(g),_fe=WZ.format,WZ.parse,Pfe=WZ.utcFormat,WZ.utcParse,WZ}function Yot(g){return new Date(g)}function Kot(g){return g instanceof Date?+g:+new Date(+g)}function eJ(g,a,s,C,I,A,d,h,y,Z){var b=xL(),w=b.invert,S=b.domain,R=Z(".%L"),H=Z(":%S"),N=Z("%I:%M"),D=Z("%I %p"),M=Z("%a %d"),z=Z("%b %d"),K=Z("%B"),P=Z("%Y");function J(j){return(y(j)a(I/(g.length-1)))},s.quantiles=function(C){return Array.from({length:C+1},(I,A)=>I2(g,A/C))},s.copy=function(){return Jfe(a).domain(g)},Xd.apply(s,arguments)}function nk(){var g=0,a=.5,s=1,C=1,I,A,d,h,y,Z=ks,b,w=!1,S;function R(N){return isNaN(N=+N)?S:(N=.5+((N=+b(N))-A)*(C*N1&&arguments[1]!==void 0?arguments[1]:0,s=(ba[g[a+0]]+ba[g[a+1]]+ba[g[a+2]]+ba[g[a+3]]+"-"+ba[g[a+4]]+ba[g[a+5]]+"-"+ba[g[a+6]]+ba[g[a+7]]+"-"+ba[g[a+8]]+ba[g[a+9]]+"-"+ba[g[a+10]]+ba[g[a+11]]+ba[g[a+12]]+ba[g[a+13]]+ba[g[a+14]]+ba[g[a+15]]).toLowerCase();if(!gk(s))throw TypeError("Stringified UUID is invalid");return s}var eme,rJ,gJ=0,oJ=0;function Qot(g,a,s){var C=a&&s||0,I=a||new Array(16);g=g||{};var A=g.node||eme,d=g.clockseq!==void 0?g.clockseq:rJ;if(A==null||d==null){var h=g.random||(g.rng||qfe)();A==null&&(A=eme=[h[0]|1,h[1],h[2],h[3],h[4],h[5]]),d==null&&(d=rJ=(h[6]<<8|h[7])&16383)}var y=g.msecs!==void 0?g.msecs:Date.now(),Z=g.nsecs!==void 0?g.nsecs:oJ+1,b=y-gJ+(Z-oJ)/1e4;if(b<0&&g.clockseq===void 0&&(d=d+1&16383),(b<0||y>gJ)&&g.nsecs===void 0&&(Z=0),Z>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");gJ=y,oJ=Z,rJ=d,y+=122192928e5;var w=((y&268435455)*1e4+Z)%4294967296;I[C++]=w>>>24&255,I[C++]=w>>>16&255,I[C++]=w>>>8&255,I[C++]=w&255;var S=y/4294967296*1e4&268435455;I[C++]=S>>>8&255,I[C++]=S&255,I[C++]=S>>>24&15|16,I[C++]=S>>>16&255,I[C++]=d>>>8|128,I[C++]=d&255;for(var R=0;R<6;++R)I[C+R]=A[R];return a||ok(I)}function tme(g){if(!gk(g))throw TypeError("Invalid UUID");var a,s=new Uint8Array(16);return s[0]=(a=parseInt(g.slice(0,8),16))>>>24,s[1]=a>>>16&255,s[2]=a>>>8&255,s[3]=a&255,s[4]=(a=parseInt(g.slice(9,13),16))>>>8,s[5]=a&255,s[6]=(a=parseInt(g.slice(14,18),16))>>>8,s[7]=a&255,s[8]=(a=parseInt(g.slice(19,23),16))>>>8,s[9]=a&255,s[10]=(a=parseInt(g.slice(24,36),16))/1099511627776&255,s[11]=a/4294967296&255,s[12]=a>>>24&255,s[13]=a>>>16&255,s[14]=a>>>8&255,s[15]=a&255,s}function jot(g){g=unescape(encodeURIComponent(g));for(var a=[],s=0;s>5]>>>I%32&255,d=parseInt(C.charAt(A>>>4&15)+C.charAt(A&15),16);a.push(d)}return a}function nme(g){return(g+64>>>9<<4)+14+1}function iat(g,a){g[a>>5]|=128<>5]|=(g[C/8]&255)<>16)+(a>>16)+(s>>16);return C<<16|s&65535}function rat(g,a){return g<>>32-a}function ak(g,a,s,C,I,A){return kf(rat(kf(kf(a,g),kf(C,A)),I),s)}function Pa(g,a,s,C,I,A,d){return ak(a&s|~a&C,g,a,I,A,d)}function za(g,a,s,C,I,A,d){return ak(a&C|s&~C,g,a,I,A,d)}function Oa(g,a,s,C,I,A,d){return ak(a^s^C,g,a,I,A,d)}function La(g,a,s,C,I,A,d){return ak(s^(a|~C),g,a,I,A,d)}var gat=ime("v3",48,eat);const oat=gat;function aat(g,a,s){g=g||{};var C=g.random||(g.rng||qfe)();if(C[6]=C[6]&15|64,C[8]=C[8]&63|128,a){s=s||0;for(var I=0;I<16;++I)a[s+I]=C[I];return a}return ok(C)}function sat(g,a,s,C){switch(g){case 0:return a&s^~a&C;case 1:return a^s^C;case 2:return a&s^a&C^s&C;case 3:return a^s^C}}function aJ(g,a){return g<>>32-a}function Iat(g){var a=[1518500249,1859775393,2400959708,3395469782],s=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof g=="string"){var C=unescape(encodeURIComponent(g));g=[];for(var I=0;I>>0;K=z,z=M,M=aJ(D,30)>>>0,D=N,N=j}s[0]=s[0]+N>>>0,s[1]=s[1]+D>>>0,s[2]=s[2]+M>>>0,s[3]=s[3]+z>>>0,s[4]=s[4]+K>>>0}return[s[0]>>24&255,s[0]>>16&255,s[0]>>8&255,s[0]&255,s[1]>>24&255,s[1]>>16&255,s[1]>>8&255,s[1]&255,s[2]>>24&255,s[2]>>16&255,s[2]>>8&255,s[2]&255,s[3]>>24&255,s[3]>>16&255,s[3]>>8&255,s[3]&255,s[4]>>24&255,s[4]>>16&255,s[4]>>8&255,s[4]&255]}var lat=ime("v5",80,Iat);const Cat=lat,cat="00000000-0000-0000-0000-000000000000";function Aat(g){if(!gk(g))throw TypeError("Invalid UUID");return parseInt(g.substr(14,1),16)}var sk=Ae(Object.freeze(Object.defineProperty({__proto__:null,v1:Qot,v3:oat,v4:aat,v5:Cat,NIL:cat,version:Aat,validate:gk,stringify:ok,parse:tme},Symbol.toStringTag,{value:"Module"}))),sJ=(()=>typeof Buffer<"u"?g=>Buffer.from(g).toString("base64"):g=>btoa(String.fromCharCode(...g)))(),uat=(()=>typeof Buffer<"u"?g=>Buffer.from(g,"base64"):g=>Uint8Array.from(atob(g),a=>a.charCodeAt(0)))();p2.encode=function(g){var a=sk.parse(g),s=sJ(a),C=s.replace(/\+/g,"-").replace(/\//g,"_").substring(0,22);return C},p2.decode=function(g){var a=g.replace(/-/g,"+").replace(/_/g,"/")+"==";return sk.stringify(uat(a))},p2.v4=function(){var g=sk.v4(null,new Uint8Array(16)),a=sJ(g),s=a.replace(/\+/g,"-").replace(/\//g,"_").substring(0,22);return s},p2.nice=function(){var g=sk.v4(null,new Uint8Array(16));g[0]=g[0]&127;var a=sJ(g),s=a.replace(/\+/g,"-").replace(/\//g,"_").substring(0,22);return s},function(g){g.exports=p2}($fe);const Fn=ge($fe.exports);var rme={exports:{}},Ik={},NZ={exports:{}};(function(g,a){var s=200,C="__lodash_hash_undefined__",I=1,A=2,d=9007199254740991,h="[object Arguments]",y="[object Array]",Z="[object AsyncFunction]",b="[object Boolean]",w="[object Date]",S="[object Error]",R="[object Function]",H="[object GeneratorFunction]",N="[object Map]",D="[object Number]",M="[object Null]",z="[object Object]",K="[object Promise]",P="[object Proxy]",J="[object RegExp]",j="[object Set]",ie="[object String]",te="[object Symbol]",Ce="[object Undefined]",ue="[object WeakMap]",oe="[object ArrayBuffer]",he="[object DataView]",ye="[object Float32Array]",Ie="[object Float64Array]",fe="[object Int8Array]",We="[object Int16Array]",_e="[object Int32Array]",qe="[object Uint8Array]",nt="[object Uint8ClampedArray]",At="[object Uint16Array]",Tt="[object Uint32Array]",Ne=/[\\^$.*+?()[\]{}|]/g,Ge=/^\[object .+?Constructor\]$/,He=/^(?:0|[1-9]\d*)$/,Xe={};Xe[ye]=Xe[Ie]=Xe[fe]=Xe[We]=Xe[_e]=Xe[qe]=Xe[nt]=Xe[At]=Xe[Tt]=!0,Xe[h]=Xe[y]=Xe[oe]=Xe[b]=Xe[he]=Xe[w]=Xe[S]=Xe[R]=Xe[N]=Xe[D]=Xe[z]=Xe[J]=Xe[j]=Xe[ie]=Xe[ue]=!1;var at=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis,bt=typeof self=="object"&&self&&self.Object===Object&&self,xt=at||bt||Function("return this")(),Vt=a&&!a.nodeType&&a,_t=Vt&&!0&&g&&!g.nodeType&&g,Ci=_t&&_t.exports===Vt,Dt=Ci&&at.process,Zi=function(){try{return Dt&&Dt.binding&&Dt.binding("util")}catch{}}(),ui=Zi&&Zi.isTypedArray;function In(Oe,Gt){for(var qt=-1,Ri=Oe==null?0:Oe.length,bg=0,En=[];++qt-1}function en(Oe,Gt){var qt=this.__data__,Ri=wa(qt,Oe);return Ri<0?(++this.size,qt.push([Oe,Gt])):qt[Ri][1]=Gt,this}mn.prototype.clear=Un,mn.prototype.delete=an,mn.prototype.get=Kn,mn.prototype.has=hr,mn.prototype.set=en;function Ln(Oe){var Gt=-1,qt=Oe==null?0:Oe.length;for(this.clear();++Gtna))return!1;var zg=En.get(Oe);if(zg&&En.get(Gt))return zg==Gt;var Wl=-1,Gc=!0,ss=qt&A?new Hi:void 0;for(En.set(Oe,Gt),En.set(Gt,Oe);++Wl-1&&Oe%1==0&&Oe-1&&Oe%1==0&&Oe<=d}function fHe(Oe){var Gt=typeof Oe;return Oe!=null&&(Gt=="object"||Gt=="function")}function BV(Oe){return Oe!=null&&typeof Oe=="object"}var mHe=ui?un(ui):W_t;function L_t(Oe){return z_t(Oe)?Rr(Oe):N_t(Oe)}function J_t(){return[]}function U_t(){return!1}g.exports=O_t})(NZ,NZ.exports);var IJ={exports:{}};/*! - Copyright (c) 2018 Jed Watson. - Licensed under the MIT License (MIT), see - http://jedwatson.github.io/classnames -*/(function(g){(function(){var a={}.hasOwnProperty;function s(){for(var C=[],I=0;Ia&&(a=s);return a}function pat(g){for(var a=Array(g.length),s=0,C=g.length;s=a.x+a.w||g.y+g.h<=a.y||g.y>=a.y+a.h)}function ome(g,a,s){for(var C=cJ(g),I=dJ(g,a),A=Array(g.length),d=0,h=I.length;da.y+a.h)break;Ck(a,h)&&CJ(g,h,s+a[I],C)}}a[C]=s}function ame(g,a,s,C,I){var A=s==="vertical",d=s==="horizontal";if(A)for(a.y=Math.min(lk(g),a.y);a.y>0&&!XZ(g,a);)a.y--;else if(d)for(a.y=Math.min(lk(g),a.y);a.x>0&&!XZ(g,a);)a.x--;for(var h=void 0;h=XZ(g,a);)d?CJ(I,a,h.x+h.w,"x"):CJ(I,a,h.y+h.h,"y"),d&&a.x+a.w>C&&(a.x=C-a.w,a.y++);return a}function sme(g,a){for(var s=cJ(g),C=0,I=g.length;Ca.cols&&(A.x=a.cols-A.w),A.x<0&&(A.x=0,A.w=a.cols),!A.static)s.push(A);else for(;XZ(s,A);)A.y++}return g}function Ime(g,a){for(var s=0,C=g.length;s=C:d==="horizontal"&&typeof s=="number"?y>=s:!1;w&&(b=b.reverse());var S=lme(b,a);if(A&&S.length)return""+a.i,a.x=y,a.y=Z,a.moved=!1,g;for(var R=0,H=S.length;Rs.y||a.y===s.y&&a.x>s.x?1:a.y===s.y&&a.x===s.x?0:-1})}function cme(g){return[].concat(g).sort(function(a,s){return a.x>s.x||a.x===s.x&&a.y>s.y?1:-1})}function Gat(g,a,s,C){g=g||[];var I=[];return lJ.default.Children.forEach(a,function(A,d){var h=Ime(g,String(A.key));if(h)I[d]=kZ(h);else{var y=A.props["data-grid"]||A.props._grid;y?I[d]=kZ(dat({},y,{i:A.key})):I[d]=kZ({w:1,h:1,x:0,y:lk(I),i:String(A.key)})}}),I=sme(I,{cols:s}),I=ome(I,C,s),I}function Sat(g){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Layout",s=["x","y","w","h"];if(!Array.isArray(g))throw new Error(a+" must be an array!");for(var C=0,I=g.length;C1?ot-1:0),wt=1;wt2?Bt-2:0),yt=2;yt"u"||ii===null)return""+ii;var Hi=fr(ii);if(Hi==="object"){if(ii instanceof Date)return"date";if(ii instanceof RegExp)return"regexp"}return Hi}function pg(ii){var Hi=wr(ii);switch(Hi){case"array":case"object":return"an "+Hi;case"boolean":case"date":case"regexp":return"a "+Hi;default:return Hi}}function as(ii){return!ii.constructor||!ii.constructor.name?yt:ii.constructor.name}return gt.checkPropTypes=oe,gt.PropTypes=gt,gt},ye=I(function(Re){{var Ve=typeof Symbol=="function"&&Symbol.for&&Symbol.for("react.element")||60103,ot=function(wt){return typeof wt=="object"&&wt!==null&&wt.$$typeof===Ve},Bt=!0;Re.exports=he(ot,Bt)}}),Ie=I(function(Re){/*! - Copyright (c) 2016 Jed Watson. - Licensed under the MIT License (MIT), see - http://jedwatson.github.io/classnames -*/(function(){var Ve={}.hasOwnProperty;function ot(){for(var Bt=[],wt=0;wt0&&arguments[0]!==void 0?arguments[0]:"transform";if(typeof window>"u"||typeof window.document>"u")return"";var Ve=window.document.documentElement.style;if(Re in Ve)return"";for(var ot=0;ot0&&arguments[0]!==void 0?arguments[0]:{};return xt({touchAction:"none"},Re)}function pe(Re,Ve){Re.classList?Re.classList.add(Ve):Re.className.match(new RegExp("(?:^|\\s)"+Ve+"(?!\\S)"))||(Re.className+=" "+Ve)}function Fe(Re,Ve){Re.classList?Re.classList.remove(Ve):Re.className=Re.className.replace(new RegExp("(?:^|\\s)"+Ve+"(?!\\S)","g"),"")}function $e(Re,Ve,ot){if(!Re.props.bounds)return[Ve,ot];var Bt=Re.props.bounds;Bt=typeof Bt=="string"?Bt:Ng(Bt);var wt=Sa(Re);if(typeof Bt=="string"){var yt=wt.ownerDocument,gt=yt.defaultView,mt=void 0;if(Bt==="parent"?mt=wt.parentNode:mt=yt.querySelector(Bt),!(mt instanceof gt.HTMLElement))throw new Error('Bounds selector "'+Bt+'" could not find an element.');var Se=gt.getComputedStyle(wt),ve=gt.getComputedStyle(mt);Bt={left:-wt.offsetLeft+qe(ve.paddingLeft)+qe(Se.marginLeft),top:-wt.offsetTop+qe(ve.paddingTop)+qe(Se.marginTop),right:On(mt)-pn(wt)-wt.offsetLeft+qe(ve.paddingRight)-qe(Se.marginRight),bottom:un(mt)-Bi(wt)-wt.offsetTop+qe(ve.paddingBottom)-qe(Se.marginBottom)}}return _e(Bt.right)&&(Ve=Math.min(Ve,Bt.right)),_e(Bt.bottom)&&(ot=Math.min(ot,Bt.bottom)),_e(Bt.left)&&(Ve=Math.max(Ve,Bt.left)),_e(Bt.top)&&(ot=Math.max(ot,Bt.top)),[Ve,ot]}function ft(Re,Ve,ot){var Bt=Math.round(Ve/Re[0])*Re[0],wt=Math.round(ot/Re[1])*Re[1];return[Bt,wt]}function ri(Re){return Re.props.axis==="both"||Re.props.axis==="x"}function bi(Re){return Re.props.axis==="both"||Re.props.axis==="y"}function Ni(Re,Ve,ot){var Bt=typeof Ve=="number"?Qe(Re,Ve):null;if(typeof Ve=="number"&&!Bt)return null;var wt=Sa(ot),yt=ot.props.offsetParent||wt.offsetParent||wt.ownerDocument.body;return Wg(Bt||Re,yt)}function Ti(Re,Ve,ot){var Bt=Re.state,wt=!_e(Bt.lastX),yt=Sa(Re);return wt?{node:yt,deltaX:0,deltaY:0,lastX:Ve,lastY:ot,x:Ve,y:ot}:{node:yt,deltaX:Ve-Bt.lastX,deltaY:ot-Bt.lastY,lastX:Bt.lastX,lastY:Bt.lastY,x:Ve,y:ot}}function Ki(Re,Ve){var ot=Re.props.scale;return{node:Ve.node,x:Re.state.x+Ve.deltaX/ot,y:Re.state.y+Ve.deltaY/ot,deltaX:Ve.deltaX/ot,deltaY:Ve.deltaY/ot,lastX:Re.state.x,lastY:Re.state.y}}function Ng(Re){return{left:Re.left,top:Re.top,right:Re.right,bottom:Re.bottom}}function Sa(Re){var Ve=s.findDOMNode(Re);if(!Ve)throw new Error(": Unmounted during event!");return Ve}function Hl(){}var gs={touch:{start:"touchstart",move:"touchmove",stop:"touchend"},mouse:{start:"mousedown",move:"mousemove",stop:"mouseup"}},os=gs.mouse,Rt=function(Re){Vt(Ve,Re);function Ve(){var ot,Bt,wt,yt;Xe(this,Ve);for(var gt=arguments.length,mt=Array(gt),Se=0;Se not mounted on DragStart!");var vt=Pe.ownerDocument;if(!(wt.props.disabled||!(ve.target instanceof vt.defaultView.Node)||wt.props.handle&&!ui(ve.target,wt.props.handle,Pe)||wt.props.cancel&&ui(ve.target,wt.props.cancel,Pe))){var St=pt(ve);wt.setState({touchIdentifier:St});var li=Ni(ve,St,wt);if(li!=null){var ci=li.x,qi=li.y,mn=Ti(wt,ci,qi);wt.props.onStart;var Un=wt.props.onStart(ve,mn);Un!==!1&&(wt.props.enableUserSelectHack&&re(vt),wt.setState({dragging:!0,lastX:ci,lastY:qi}),In(vt,os.move,wt.handleDrag),In(vt,os.stop,wt.handleDragStop))}}},wt.handleDrag=function(ve){ve.type==="touchmove"&&ve.preventDefault();var Pe=Ni(ve,wt.state.touchIdentifier,wt);if(Pe!=null){var vt=Pe.x,St=Pe.y;if(Array.isArray(wt.props.grid)){var li=vt-wt.state.lastX,ci=St-wt.state.lastY,qi=ft(wt.props.grid,li,ci),mn=Ci(qi,2);if(li=mn[0],ci=mn[1],!li&&!ci)return;vt=wt.state.lastX+li,St=wt.state.lastY+ci}var Un=Ti(wt,vt,St),an=wt.props.onDrag(ve,Un);if(an===!1){try{wt.handleDragStop(new MouseEvent("mouseup"))}catch{var Kn=document.createEvent("MouseEvents");Kn.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),wt.handleDragStop(Kn)}return}wt.setState({lastX:vt,lastY:St})}},wt.handleDragStop=function(ve){if(wt.state.dragging){var Pe=Ni(ve,wt.state.touchIdentifier,wt);if(Pe!=null){var vt=Pe.x,St=Pe.y,li=Ti(wt,vt,St),ci=s.findDOMNode(wt);ci&&wt.props.enableUserSelectHack&&U(ci.ownerDocument),wt.setState({dragging:!1,lastX:NaN,lastY:NaN}),wt.props.onStop(ve,li),ci&&(Li(ci.ownerDocument,os.move,wt.handleDrag),Li(ci.ownerDocument,os.stop,wt.handleDragStop))}}},wt.onMouseDown=function(ve){return os=gs.mouse,wt.handleDragStart(ve)},wt.onMouseUp=function(ve){return os=gs.mouse,wt.handleDragStop(ve)},wt.onTouchStart=function(ve){return os=gs.touch,wt.handleDragStart(ve)},wt.onTouchEnd=function(ve){return os=gs.touch,wt.handleDragStop(ve)},Bt),_t(wt,yt)}return at(Ve,[{key:"componentWillUnmount",value:function(){var Bt=s.findDOMNode(this);if(Bt){var wt=Bt.ownerDocument;Li(wt,gs.mouse.move,this.handleDrag),Li(wt,gs.touch.move,this.handleDrag),Li(wt,gs.mouse.stop,this.handleDragStop),Li(wt,gs.touch.stop,this.handleDragStop),this.props.enableUserSelectHack&&U(wt)}}},{key:"render",value:function(){return C.cloneElement(C.Children.only(this.props.children),{style:q(this.props.children.props.style),onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}}]),Ve}(C.Component);Rt.displayName="DraggableCore",Rt.propTypes={allowAnyClick:ye.bool,disabled:ye.bool,enableUserSelectHack:ye.bool,offsetParent:function(Ve,ot){if(Ve[ot]&&Ve[ot].nodeType!==1)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:ye.arrayOf(ye.number),scale:ye.number,handle:ye.string,cancel:ye.string,onStart:ye.func,onDrag:ye.func,onStop:ye.func,onMouseDown:ye.func,className:nt,style:nt,transform:nt},Rt.defaultProps={allowAnyClick:!1,cancel:null,disabled:!1,enableUserSelectHack:!0,offsetParent:null,handle:null,grid:null,transform:null,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){}};var ut=function(Re){Vt(Ve,Re);function Ve(ot){Xe(this,Ve);var Bt=_t(this,(Ve.__proto__||Object.getPrototypeOf(Ve)).call(this,ot));return Bt.onDragStart=function(wt,yt){var gt=Bt.props.onStart(wt,Ki(Bt,yt));if(gt===!1)return!1;Bt.setState({dragging:!0,dragged:!0})},Bt.onDrag=function(wt,yt){if(!Bt.state.dragging)return!1;var gt=Ki(Bt,yt),mt={x:gt.x,y:gt.y};if(Bt.props.bounds){var Se=mt.x,ve=mt.y;mt.x+=Bt.state.slackX,mt.y+=Bt.state.slackY;var Pe=$e(Bt,mt.x,mt.y),vt=Ci(Pe,2),St=vt[0],li=vt[1];mt.x=St,mt.y=li,mt.slackX=Bt.state.slackX+(Se-mt.x),mt.slackY=Bt.state.slackY+(ve-mt.y),gt.x=mt.x,gt.y=mt.y,gt.deltaX=mt.x-Bt.state.x,gt.deltaY=mt.y-Bt.state.y}var ci=Bt.props.onDrag(wt,gt);if(ci===!1)return!1;Bt.setState(mt)},Bt.onDragStop=function(wt,yt){if(!Bt.state.dragging)return!1;var gt=Bt.props.onStop(wt,Ki(Bt,yt));if(gt===!1)return!1;var mt={dragging:!1,slackX:0,slackY:0},Se=!!Bt.props.position;if(Se){var ve=Bt.props.position,Pe=ve.x,vt=ve.y;mt.x=Pe,mt.y=vt}Bt.setState(mt)},Bt.state={dragging:!1,dragged:!1,x:ot.position?ot.position.x:ot.defaultPosition.x,y:ot.position?ot.position.y:ot.defaultPosition.y,slackX:0,slackY:0,isElementSVG:!1},ot.position&&!(ot.onDrag||ot.onStop)&&console.warn("A `position` was applied to this , without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element."),Bt}return at(Ve,[{key:"componentDidMount",value:function(){typeof window.SVGElement<"u"&&s.findDOMNode(this)instanceof window.SVGElement&&this.setState({isElementSVG:!0})}},{key:"componentWillReceiveProps",value:function(Bt){Bt.position&&(!this.props.position||Bt.position.x!==this.props.position.x||Bt.position.y!==this.props.position.y)&&this.setState({x:Bt.position.x,y:Bt.position.y})}},{key:"componentWillUnmount",value:function(){this.setState({dragging:!1})}},{key:"render",value:function(){var Bt,wt={},yt=null,gt=!!this.props.position,mt=!gt||this.state.dragging,Se=this.props.position||this.props.defaultPosition,ve={x:ri(this)&&mt?this.state.x:Se.x,y:bi(this)&&mt?this.state.y:Se.y};this.state.isElementSVG?yt=Ht(ve,this.props.positionOffset):wt=ln(ve,this.props.positionOffset);var Pe=this.props,vt=Pe.defaultClassName,St=Pe.defaultClassNameDragging,li=Pe.defaultClassNameDragged,ci=C.Children.only(this.props.children),qi=Ie(ci.props.className||"",vt,(Bt={},bt(Bt,St,this.state.dragging),bt(Bt,li,this.state.dragged),Bt));return C.createElement(Rt,xt({},this.props,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),C.cloneElement(ci,{className:qi,style:xt({},ci.props.style,wt),transform:yt}))}}]),Ve}(C.Component);return ut.displayName="Draggable",ut.propTypes=xt({},Rt.propTypes,{axis:ye.oneOf(["both","x","y","none"]),bounds:ye.oneOfType([ye.shape({left:ye.number,right:ye.number,top:ye.number,bottom:ye.number}),ye.string,ye.oneOf([!1])]),defaultClassName:ye.string,defaultClassNameDragging:ye.string,defaultClassNameDragged:ye.string,defaultPosition:ye.shape({x:ye.number,y:ye.number}),positionOffset:ye.shape({x:ye.oneOfType([ye.number,ye.string]),y:ye.oneOfType([ye.number,ye.string])}),position:ye.shape({x:ye.number,y:ye.number}),className:nt,style:nt,transform:nt}),ut.defaultProps=xt({},Rt.defaultProps,{axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},position:null,scale:1}),ut.default=ut,ut.DraggableCore=Rt,ut})})(Ame);var ck={exports:{}},b2={},Ak={exports:{}},ume={};function dme(g){var a,s,C="";if(typeof g=="string"||typeof g=="number")C+=g;else if(typeof g=="object")if(Array.isArray(g))for(a=0;a0&&arguments[0]!==void 0?arguments[0]:"transform";if(typeof window>"u")return"";var C=(g=window.document)===null||g===void 0||(a=g.documentElement)===null||a===void 0?void 0:a.style;if(!C||s in C)return"";for(var I=0;I: Unmounted during event!");return a}var dk={},hk={};Object.defineProperty(hk,"__esModule",{value:!0}),hk.default=ost;function ost(){}function fk(g){return fk=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},fk(g)}Object.defineProperty(dk,"__esModule",{value:!0}),dk.default=void 0;var yJ=sst(X.default),bl=ZJ(_.exports),ast=ZJ($.default),Ja=to,Xf=KA,vJ=YA,y2=ZJ(hk);function ZJ(g){return g&&g.__esModule?g:{default:g}}function Sme(g){if(typeof WeakMap!="function")return null;var a=new WeakMap,s=new WeakMap;return(Sme=function(I){return I?s:a})(g)}function sst(g,a){if(!a&&g&&g.__esModule)return g;if(g===null||fk(g)!=="object"&&typeof g!="function")return{default:g};var s=Sme(a);if(s&&s.has(g))return s.get(g);var C={},I=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var A in g)if(A!=="default"&&Object.prototype.hasOwnProperty.call(g,A)){var d=I?Object.getOwnPropertyDescriptor(g,A):null;d&&(d.get||d.set)?Object.defineProperty(C,A,d):C[A]=g[A]}return C.default=g,s&&s.set(g,C),C}function wme(g,a){return cst(g)||Cst(g,a)||lst(g,a)||Ist()}function Ist(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function lst(g,a){if(g){if(typeof g=="string")return Tme(g,a);var s=Object.prototype.toString.call(g).slice(8,-1);if(s==="Object"&&g.constructor&&(s=g.constructor.name),s==="Map"||s==="Set")return Array.from(g);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return Tme(g,a)}}function Tme(g,a){(a==null||a>g.length)&&(a=g.length);for(var s=0,C=new Array(a);s"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function mk(g){return mk=Object.setPrototypeOf?Object.getPrototypeOf:function(s){return s.__proto__||Object.getPrototypeOf(s)},mk(g)}function gC(g,a,s){return a in g?Object.defineProperty(g,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):g[a]=s,g}var rc={touch:{start:"touchstart",move:"touchmove",stop:"touchend"},mouse:{start:"mousedown",move:"mousemove",stop:"mouseup"}},xf=rc.mouse,pk=function(g){dst(s,g);var a=hst(s);function s(){var C;Ast(this,s);for(var I=arguments.length,A=new Array(I),d=0;d not mounted on DragStart!");var Z=y.ownerDocument;if(!(C.props.disabled||!(h.target instanceof Z.defaultView.Node)||C.props.handle&&!(0,Ja.matchesSelectorAndParentsTo)(h.target,C.props.handle,y)||C.props.cancel&&(0,Ja.matchesSelectorAndParentsTo)(h.target,C.props.cancel,y))){h.type==="touchstart"&&h.preventDefault();var b=(0,Ja.getTouchIdentifier)(h);C.setState({touchIdentifier:b});var w=(0,Xf.getControlPosition)(h,b,Ua(C));if(w!=null){var S=w.x,R=w.y,H=(0,Xf.createCoreData)(Ua(C),S,R);(0,y2.default)("DraggableCore: handleDragStart: %j",H),(0,y2.default)("calling",C.props.onStart);var N=C.props.onStart(h,H);N===!1||C.mounted===!1||(C.props.enableUserSelectHack&&(0,Ja.addUserSelectStyles)(Z),C.setState({dragging:!0,lastX:S,lastY:R}),(0,Ja.addEvent)(Z,xf.move,C.handleDrag),(0,Ja.addEvent)(Z,xf.stop,C.handleDragStop))}}}),gC(Ua(C),"handleDrag",function(h){var y=(0,Xf.getControlPosition)(h,C.state.touchIdentifier,Ua(C));if(y!=null){var Z=y.x,b=y.y;if(Array.isArray(C.props.grid)){var w=Z-C.state.lastX,S=b-C.state.lastY,R=(0,Xf.snapToGrid)(C.props.grid,w,S),H=wme(R,2);if(w=H[0],S=H[1],!w&&!S)return;Z=C.state.lastX+w,b=C.state.lastY+S}var N=(0,Xf.createCoreData)(Ua(C),Z,b);(0,y2.default)("DraggableCore: handleDrag: %j",N);var D=C.props.onDrag(h,N);if(D===!1||C.mounted===!1){try{C.handleDragStop(new MouseEvent("mouseup"))}catch{var M=document.createEvent("MouseEvents");M.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),C.handleDragStop(M)}return}C.setState({lastX:Z,lastY:b})}}),gC(Ua(C),"handleDragStop",function(h){if(C.state.dragging){var y=(0,Xf.getControlPosition)(h,C.state.touchIdentifier,Ua(C));if(y!=null){var Z=y.x,b=y.y;if(Array.isArray(C.props.grid)){var w=Z-C.state.lastX||0,S=b-C.state.lastY||0,R=(0,Xf.snapToGrid)(C.props.grid,w,S),H=wme(R,2);w=H[0],S=H[1],Z=C.state.lastX+w,b=C.state.lastY+S}var N=(0,Xf.createCoreData)(Ua(C),Z,b),D=C.props.onStop(h,N);if(D===!1||C.mounted===!1)return!1;var M=C.findDOMNode();M&&C.props.enableUserSelectHack&&(0,Ja.removeUserSelectStyles)(M.ownerDocument),(0,y2.default)("DraggableCore: handleDragStop: %j",N),C.setState({dragging:!1,lastX:NaN,lastY:NaN}),M&&((0,y2.default)("DraggableCore: Removing handlers"),(0,Ja.removeEvent)(M.ownerDocument,xf.move,C.handleDrag),(0,Ja.removeEvent)(M.ownerDocument,xf.stop,C.handleDragStop))}}}),gC(Ua(C),"onMouseDown",function(h){return xf=rc.mouse,C.handleDragStart(h)}),gC(Ua(C),"onMouseUp",function(h){return xf=rc.mouse,C.handleDragStop(h)}),gC(Ua(C),"onTouchStart",function(h){return xf=rc.touch,C.handleDragStart(h)}),gC(Ua(C),"onTouchEnd",function(h){return xf=rc.touch,C.handleDragStop(h)}),C}return ust(s,[{key:"componentDidMount",value:function(){this.mounted=!0;var I=this.findDOMNode();I&&(0,Ja.addEvent)(I,rc.touch.start,this.onTouchStart,{passive:!1})}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var I=this.findDOMNode();if(I){var A=I.ownerDocument;(0,Ja.removeEvent)(A,rc.mouse.move,this.handleDrag),(0,Ja.removeEvent)(A,rc.touch.move,this.handleDrag),(0,Ja.removeEvent)(A,rc.mouse.stop,this.handleDragStop),(0,Ja.removeEvent)(A,rc.touch.stop,this.handleDragStop),(0,Ja.removeEvent)(I,rc.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,Ja.removeUserSelectStyles)(A)}}},{key:"findDOMNode",value:function(){var I,A,d;return(I=this.props)!==null&&I!==void 0&&I.nodeRef?(A=this.props)===null||A===void 0||(d=A.nodeRef)===null||d===void 0?void 0:d.current:ast.default.findDOMNode(this)}},{key:"render",value:function(){return yJ.cloneElement(yJ.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}}]),s}(yJ.Component);dk.default=pk,gC(pk,"displayName","DraggableCore"),gC(pk,"propTypes",{allowAnyClick:bl.default.bool,disabled:bl.default.bool,enableUserSelectHack:bl.default.bool,offsetParent:function(a,s){if(a[s]&&a[s].nodeType!==1)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:bl.default.arrayOf(bl.default.number),handle:bl.default.string,cancel:bl.default.string,nodeRef:bl.default.object,onStart:bl.default.func,onDrag:bl.default.func,onStop:bl.default.func,onMouseDown:bl.default.func,scale:bl.default.number,className:vJ.dontSetMe,style:vJ.dontSetMe,transform:vJ.dontSetMe}),gC(pk,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1}),function(g){function a(Ne){return a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(Ge){return typeof Ge}:function(Ge){return Ge&&typeof Symbol=="function"&&Ge.constructor===Symbol&&Ge!==Symbol.prototype?"symbol":typeof Ge},a(Ne)}Object.defineProperty(g,"__esModule",{value:!0}),Object.defineProperty(g,"DraggableCore",{enumerable:!0,get:function(){return Z.default}}),g.default=void 0;var s=H(X.default),C=S(_.exports),I=S($.default),A=S(Tat),d=to,h=KA,y=YA,Z=S(dk),b=S(hk),w=["axis","bounds","children","defaultPosition","defaultClassName","defaultClassNameDragging","defaultClassNameDragged","position","positionOffset","scale"];function S(Ne){return Ne&&Ne.__esModule?Ne:{default:Ne}}function R(Ne){if(typeof WeakMap!="function")return null;var Ge=new WeakMap,He=new WeakMap;return(R=function(at){return at?He:Ge})(Ne)}function H(Ne,Ge){if(!Ge&&Ne&&Ne.__esModule)return Ne;if(Ne===null||a(Ne)!=="object"&&typeof Ne!="function")return{default:Ne};var He=R(Ge);if(He&&He.has(Ne))return He.get(Ne);var Xe={},at=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var bt in Ne)if(bt!=="default"&&Object.prototype.hasOwnProperty.call(Ne,bt)){var xt=at?Object.getOwnPropertyDescriptor(Ne,bt):null;xt&&(xt.get||xt.set)?Object.defineProperty(Xe,bt,xt):Xe[bt]=Ne[bt]}return Xe.default=Ne,He&&He.set(Ne,Xe),Xe}function N(){return N=Object.assign||function(Ne){for(var Ge=1;Ge=0)&&Object.prototype.propertyIsEnumerable.call(Ne,Xe)&&(He[Xe]=Ne[Xe])}return He}function M(Ne,Ge){if(Ne==null)return{};var He={},Xe=Object.keys(Ne),at,bt;for(bt=0;bt=0)&&(He[at]=Ne[at]);return He}function z(Ne,Ge){var He=Object.keys(Ne);if(Object.getOwnPropertySymbols){var Xe=Object.getOwnPropertySymbols(Ne);Ge&&(Xe=Xe.filter(function(at){return Object.getOwnPropertyDescriptor(Ne,at).enumerable})),He.push.apply(He,Xe)}return He}function K(Ne){for(var Ge=1;GeNe.length)&&(Ge=Ne.length);for(var He=0,Xe=new Array(Ge);He"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function nt(Ne){return nt=Object.setPrototypeOf?Object.getPrototypeOf:function(He){return He.__proto__||Object.getPrototypeOf(He)},nt(Ne)}function At(Ne,Ge,He){return Ge in Ne?Object.defineProperty(Ne,Ge,{value:He,enumerable:!0,configurable:!0,writable:!0}):Ne[Ge]=He,Ne}var Tt=function(Ne){ye(He,Ne);var Ge=fe(He);function He(Xe){var at;return ue(this,He),at=Ge.call(this,Xe),At(_e(at),"onDragStart",function(bt,xt){(0,b.default)("Draggable: onDragStart: %j",xt);var Vt=at.props.onStart(bt,(0,h.createDraggableData)(_e(at),xt));if(Vt===!1)return!1;at.setState({dragging:!0,dragged:!0})}),At(_e(at),"onDrag",function(bt,xt){if(!at.state.dragging)return!1;(0,b.default)("Draggable: onDrag: %j",xt);var Vt=(0,h.createDraggableData)(_e(at),xt),_t={x:Vt.x,y:Vt.y};if(at.props.bounds){var Ci=_t.x,Dt=_t.y;_t.x+=at.state.slackX,_t.y+=at.state.slackY;var Zi=(0,h.getBoundPosition)(_e(at),_t.x,_t.y),ui=P(Zi,2),In=ui[0],Li=ui[1];_t.x=In,_t.y=Li,_t.slackX=at.state.slackX+(Ci-_t.x),_t.slackY=at.state.slackY+(Dt-_t.y),Vt.x=_t.x,Vt.y=_t.y,Vt.deltaX=_t.x-at.state.x,Vt.deltaY=_t.y-at.state.y}var Bi=at.props.onDrag(bt,Vt);if(Bi===!1)return!1;at.setState(_t)}),At(_e(at),"onDragStop",function(bt,xt){if(!at.state.dragging)return!1;var Vt=at.props.onStop(bt,(0,h.createDraggableData)(_e(at),xt));if(Vt===!1)return!1;(0,b.default)("Draggable: onDragStop: %j",xt);var _t={dragging:!1,slackX:0,slackY:0},Ci=!!at.props.position;if(Ci){var Dt=at.props.position,Zi=Dt.x,ui=Dt.y;_t.x=Zi,_t.y=ui}at.setState(_t)}),at.state={dragging:!1,dragged:!1,x:Xe.position?Xe.position.x:Xe.defaultPosition.x,y:Xe.position?Xe.position.y:Xe.defaultPosition.y,prevPropsPosition:K({},Xe.position),slackX:0,slackY:0,isElementSVG:!1},Xe.position&&!(Xe.onDrag||Xe.onStop)&&console.warn("A `position` was applied to this , without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element."),at}return he(He,[{key:"componentDidMount",value:function(){typeof window.SVGElement<"u"&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}},{key:"componentWillUnmount",value:function(){this.setState({dragging:!1})}},{key:"findDOMNode",value:function(){var at,bt,xt;return(at=(bt=this.props)===null||bt===void 0||(xt=bt.nodeRef)===null||xt===void 0?void 0:xt.current)!==null&&at!==void 0?at:I.default.findDOMNode(this)}},{key:"render",value:function(){var at,bt=this.props;bt.axis,bt.bounds;var xt=bt.children,Vt=bt.defaultPosition,_t=bt.defaultClassName,Ci=bt.defaultClassNameDragging,Dt=bt.defaultClassNameDragged,Zi=bt.position,ui=bt.positionOffset;bt.scale;var In=D(bt,w),Li={},Bi=null,pn=!!Zi,un=!pn||this.state.dragging,On=Zi||Vt,Wg={x:(0,h.canDragX)(this)&&un?this.state.x:On.x,y:(0,h.canDragY)(this)&&un?this.state.y:On.y};this.state.isElementSVG?Bi=(0,d.createSVGTransform)(Wg,ui):Li=(0,d.createCSSTransform)(Wg,ui);var ln=(0,A.default)(xt.props.className||"",_t,(at={},At(at,Ci,this.state.dragging),At(at,Dt,this.state.dragged),at));return s.createElement(Z.default,N({},In,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),s.cloneElement(s.Children.only(xt),{className:ln,style:K(K({},xt.props.style),Li),transform:Bi}))}}],[{key:"getDerivedStateFromProps",value:function(at,bt){var xt=at.position,Vt=bt.prevPropsPosition;return xt&&(!Vt||xt.x!==Vt.x||xt.y!==Vt.y)?((0,b.default)("Draggable: getDerivedStateFromProps %j",{position:xt,prevPropsPosition:Vt}),{x:xt.x,y:xt.y,prevPropsPosition:K({},xt)}):null}}]),He}(s.Component);g.default=Tt,At(Tt,"displayName","Draggable"),At(Tt,"propTypes",K(K({},Z.default.propTypes),{},{axis:C.default.oneOf(["both","x","y","none"]),bounds:C.default.oneOfType([C.default.shape({left:C.default.number,right:C.default.number,top:C.default.number,bottom:C.default.number}),C.default.string,C.default.oneOf([!1])]),defaultClassName:C.default.string,defaultClassNameDragging:C.default.string,defaultClassNameDragged:C.default.string,defaultPosition:C.default.shape({x:C.default.number,y:C.default.number}),positionOffset:C.default.shape({x:C.default.oneOfType([C.default.number,C.default.string]),y:C.default.oneOfType([C.default.number,C.default.string])}),position:C.default.shape({x:C.default.number,y:C.default.number}),className:y.dontSetMe,style:y.dontSetMe,transform:y.dontSetMe})),At(Tt,"defaultProps",K(K({},Z.default.defaultProps),{},{axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1}))}(ume);var Vme=ume,Eme=Vme.default,pst=Vme.DraggableCore;Ak.exports=Eme,Ak.exports.default=Eme,Ak.exports.DraggableCore=pst;var GJ={};GJ.__esModule=!0,GJ.cloneElement=Zst;var bst=yst(X.default);function yst(g){return g&&g.__esModule?g:{default:g}}function Hme(g,a){var s=Object.keys(g);if(Object.getOwnPropertySymbols){var C=Object.getOwnPropertySymbols(g);a&&(C=C.filter(function(I){return Object.getOwnPropertyDescriptor(g,I).enumerable})),s.push.apply(s,C)}return s}function Wme(g){for(var a=1;a=0)&&(s[I]=g[I]);return s}function TJ(g){if(g===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g}function Est(g,a){g.prototype=Object.create(a.prototype),g.prototype.constructor=g,g.__proto__=a}function DZ(g,a,s){return a in g?Object.defineProperty(g,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):g[a]=s,g}var RJ=function(g){Est(a,g);function a(){for(var C,I=arguments.length,A=new Array(I),d=0;d=0)&&(s[I]=g[I]);return s}function Mme(g){if(g===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g}function xst(g,a){g.prototype=Object.create(a.prototype),g.prototype.constructor=g,g.__proto__=a}function vk(g,a,s){return a in g?Object.defineProperty(g,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):g[a]=s,g}var Fme=function(g){xst(a,g);function a(){for(var C,I=arguments.length,A=new Array(I),d=0;da.w||C>a.maxW)return new Error("minWidth larger than item width/maxWidth")},maxW:function(a,s){var C=a[s];if(typeof C!="number")return new Error("maxWidth not Number");if(Ca.h||C>a.maxH)return new Error("minHeight larger than item height/maxHeight")},maxH:function(a,s){var C=a[s];if(typeof C!="number")return new Error("maxHeight not Number");if(C0,D){var z=1/0,K=1/0;M.forEach(function(J){J.x>N.x&&(z=Math.min(z,J.x)),J.y>N.y&&(K=Math.min(K,J.y))}),Number.isFinite(z)&&(N.w=z-N.x),Number.isFinite(K)&&(N.h=K-N.y)}}D||(N.w=I,N.h=A);var P={w:N.w,h:N.h,x:N.x,y:N.y,static:!0,i:C};this.props.onResize(b,w,N,P,h,y),this.setState({layout:(0,Dr.compact)(b,this.compactType(),R),activeDrag:P})}},a.prototype.onResizeStop=function(C,I,A,d){var h=d.e,y=d.node,Z=this.state,b=Z.layout,w=Z.oldResizeItem,S=this.props.cols,R=(0,Dr.getLayoutItem)(b,C);this.props.onResizeStop(b,w,R,null,h,y);var H=(0,Dr.compact)(b,this.compactType(),S),N=this.state.oldLayout;this.setState({activeDrag:null,layout:H,oldResizeItem:null,oldLayout:null}),this.onLayoutMaybeChanged(H,N)},a.prototype.placeholder=function(){var C=this.state.activeDrag;if(!C)return null;var I=this.props,A=I.width,d=I.cols,h=I.margin,y=I.containerPadding,Z=I.rowHeight,b=I.maxRows,w=I.useCSSTransforms;return N0.default.createElement(Pme.default,{w:C.w,h:C.h,x:C.x,y:C.y,i:C.i,className:"react-grid-placeholder",containerWidth:A,cols:d,margin:h,containerPadding:y||h,maxRows:b,rowHeight:Z,isDraggable:!1,isResizable:!1,useCSSTransforms:w},N0.default.createElement("div",null))},a.prototype.processGridItem=function(C){if(!(!C||!C.key)){var I=(0,Dr.getLayoutItem)(this.state.layout,String(C.key));if(!I)return null;var A=this.props,d=A.width,h=A.cols,y=A.margin,Z=A.containerPadding,b=A.rowHeight,w=A.maxRows,S=A.isDraggable,R=A.isResizable,H=A.useCSSTransforms,N=A.draggableCancel,D=A.draggableHandle,M=this.state.mounted,z=!!(!I.static&&S&&(I.isDraggable||I.isDraggable==null)),K=!!(!I.static&&R&&(I.isResizable||I.isResizable==null));return N0.default.createElement(Pme.default,{containerWidth:d,cols:h,margin:y,containerPadding:Z||y,maxRows:w,rowHeight:b,cancel:N,handle:D,onDragStop:this.onDragStop,onDragStart:this.onDragStart,onDrag:this.onDrag,onResizeStart:this.onResizeStart,onResize:this.onResize,onResizeStop:this.onResizeStop,isDraggable:z,isResizable:K,useCSSTransforms:H&&M,usePercentages:!M,w:I.w,h:I.h,x:I.x,y:I.y,i:I.i,minH:I.minH,minW:I.minW,maxH:I.maxH,maxW:I.maxW,static:I.static},C)}},a.prototype.render=function(){var C=this,I=this.props,A=I.className,d=I.style,h=(0,jst.default)("react-grid-layout",A),y=Kme({height:this.containerHeight()},d);return N0.default.createElement("div",{className:h,style:y},N0.default.Children.map(this.props.children,function(Z){return C.processGridItem(Z)}),this.placeholder())},a}(N0.default.Component);Bk.displayName="ReactGridLayout",Bk.propTypes={className:fg.default.string,style:fg.default.object,width:fg.default.number,autoSize:fg.default.bool,cols:fg.default.number,draggableCancel:fg.default.string,draggableHandle:fg.default.string,verticalCompact:function(a){a.verticalCompact},compactType:fg.default.oneOf(["vertical","horizontal"]),layout:function(a){var s=a.layout;s!==void 0&&(0,Dr.validateLayout)(s,"layout")},margin:fg.default.arrayOf(fg.default.number),containerPadding:fg.default.arrayOf(fg.default.number),rowHeight:fg.default.number,maxRows:fg.default.number,isDraggable:fg.default.bool,isResizable:fg.default.bool,preventCollision:fg.default.bool,useCSSTransforms:fg.default.bool,onLayoutChange:fg.default.func,onDragStart:fg.default.func,onDrag:fg.default.func,onDragStop:fg.default.func,onResizeStart:fg.default.func,onResize:fg.default.func,onResizeStop:fg.default.func,children:function(a,s){var C=a[s],I={};N0.default.Children.forEach(C,function(A){if(I[A.key])throw new Error('Duplicate child key "'+A.key+'" found! This will cause problems in ReactGridLayout.');I[A.key]=!0})}},Bk.defaultProps={autoSize:!0,cols:12,className:"",style:{},draggableHandle:"",draggableCancel:"",containerPadding:null,rowHeight:150,maxRows:1/0,layout:[],margin:[10,10],isDraggable:!0,isResizable:!0,useCSSTransforms:!0,verticalCompact:!0,compactType:"vertical",preventCollision:!1,onLayoutChange:Dr.noop,onDragStart:Dr.noop,onDrag:Dr.noop,onDragStop:Dr.noop,onResizeStart:Dr.noop,onResize:Dr.noop,onResizeStop:Dr.noop};var iIt=function(){this.state={activeDrag:null,layout:(0,Dr.synchronizeLayoutWithChildren)(this.props.layout,this.props.children,this.props.cols,this.compactType()),mounted:!1,oldDragItem:null,oldLayout:null,oldResizeItem:null}};Ik.default=Bk;var NJ={},k0={};k0.__esModule=!0,k0.getBreakpointFromWidth=nIt,k0.getColsFromBreakpoint=rIt,k0.findOrGenerateResponsiveLayout=gIt,k0.sortBreakpoints=kJ;var Gk=Gr;function nIt(g,a){for(var s=kJ(g),C=s[0],I=1,A=s.length;Ig[d]&&(C=d)}return C}function rIt(g,a){if(!a[g])throw new Error("ResponsiveReactGridLayout: `cols` entry for breakpoint "+g+" is missing!");return a[g]}function gIt(g,a,s,C,I,A){if(g[s])return(0,Gk.cloneLayout)(g[s]);for(var d=g[C],h=kJ(a),y=h.slice(h.indexOf(s)),Z=0,b=y.length;Z=0||Object.prototype.hasOwnProperty.call(g,C)&&(s[C]=g[C]);return s}function cIt(g,a){if(!(g instanceof a))throw new TypeError("Cannot call a class as a function")}function Lme(g,a){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a&&(typeof a=="object"||typeof a=="function")?a:g}function AIt(g,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof a);g.prototype=Object.create(a&&a.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),a&&(Object.setPrototypeOf?Object.setPrototypeOf(g,a):g.__proto__=a)}var Jme=function(a){return Object.prototype.toString.call(a)},xJ=function(g){AIt(a,g);function a(){var s,C,I;cIt(this,a);for(var A=arguments.length,d=Array(A),h=0;h=0||Object.prototype.hasOwnProperty.call(g,C)&&(s[C]=g[C]);return s}function yIt(g,a){if(!(g instanceof a))throw new TypeError("Cannot call a class as a function")}function Ume(g,a){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a&&(typeof a=="object"||typeof a=="function")?a:g}function vIt(g,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof a);g.prototype=Object.create(a&&a.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),a&&(Object.setPrototypeOf?Object.setPrototypeOf(g,a):g.__proto__=a)}function ZIt(g){var a,s;return s=a=function(C){vIt(I,C);function I(){var A,d,h;yIt(this,I);for(var y=arguments.length,Z=Array(y),b=0;b"u")return null;var s=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")(),C=s.requestAnimationFrame||s.mozRequestAnimationFrame||s.webkitRequestAnimationFrame||function(b){return s.setTimeout(b,20)},I=s.cancelAnimationFrame||s.mozCancelAnimationFrame||s.webkitCancelAnimationFrame||function(b){s.clearTimeout(b)};function A(b,w){var S=Object.prototype.toString.call(b),R=S==="[object Array]"||S==="[object NodeList]"||S==="[object HTMLCollection]"||S==="[object Object]"||typeof jQuery<"u"&&b instanceof jQuery||typeof Elements<"u"&&b instanceof Elements,H=0,N=b.length;if(R)for(;H=he&&(fe+=ue.value),ue.mode==="max"&&ye<=he&&(fe+=ue.value),Ie[We]||(Ie[We]=""),fe&&(" "+Ie[We]+" ").indexOf(" "+fe+" ")===-1&&(Ie[We]+=" "+fe));for(var qe in _e)_e.hasOwnProperty(qe)&&(Ie[_e[qe]]?this.element.setAttribute(_e[qe],Ie[_e[qe]].substr(1)):this.element.removeAttribute(_e[qe]))}}function S(ie,te){ie.elementQueriesSetupInformation||(ie.elementQueriesSetupInformation=new w(ie,te)),ie.elementQueriesSensor||(ie.elementQueriesSensor=new s(ie,function(){ie.elementQueriesSetupInformation.call()}))}function R(ie,te,Ce,ue){if(typeof d[ie]>"u"){d[ie]=[];var oe=h.length;A.innerHTML+=` -`+ie+" {animation: 0.1s element-queries;}",A.innerHTML+=` -`+ie+" > .resize-sensor {min-width: "+oe+"px;}",h.push(ie)}d[ie].push({mode:te,property:Ce,value:ue})}function H(ie){var te;if(document.querySelectorAll&&(te=ie?ie.querySelectorAll.bind(ie):document.querySelectorAll.bind(document)),!te&&typeof $$<"u"&&(te=$$),!te&&typeof jQuery<"u"&&(te=jQuery),!te)throw"No document.querySelectorAll, jQuery or Mootools's $$ found.";return te}function N(ie){var te=H(ie);for(var Ce in d)if(d.hasOwnProperty(Ce))for(var ue=te(Ce,ie),oe=0,he=ue.length;oeCe[At].minWidth&&(nt=At);if(nt||(nt=oe),he!==nt)if(ye[nt])te[he].style.display="none",te[nt].style.display="block",he=nt;else{var Tt=new Image;Tt.onload=function(){te[nt].src=ue[nt],te[he].style.display="none",te[nt].style.display="block",ye[nt]=!0,he=nt},Tt.src=ue[nt]}else te[nt].src=ue[nt]}ie.resizeSensorInstance=new s(ie,qe),qe()}function M(){for(var ie=H(),te=ie("[data-responsive-image],[responsive-image]"),Ce=0,ue=te.length;Ce img, [data-responsive-image] {overflow: hidden; padding: 0; } [responsive-image] > img, [data-responsive-image] > img {width: 100%;}",A.innerHTML+=` -@keyframes element-queries { 0% { visibility: inherit; } }`,document.getElementsByTagName("head")[0].appendChild(A),j=!0);for(var te=0,Ce=document.styleSheets.length;te\s{0,}<").replace(/-1?(d+=y[A]+s[h],I=!0,(s[h].search(/-->/)>-1||s[h].search(/\]>/)>-1||s[h].search(/!DOCTYPE/)>-1)&&(I=!1)):s[h].search(/-->/)>-1||s[h].search(/\]>/)>-1?(d+=s[h],I=!1):/^<\w/.exec(s[h-1])&&/^<\/\w/.exec(s[h])&&/^<[\w:\-\.\,]+/.exec(s[h-1])==/^<\/[\w:\-\.\,]+/.exec(s[h])[0].replace("/","")?(d+=s[h],I||A--):s[h].search(/<\w/)>-1&&s[h].search(/<\//)==-1&&s[h].search(/\/>/)==-1?d=I?d+=s[h]:d+=y[A++]+s[h]:s[h].search(/<\w/)>-1&&s[h].search(/<\//)>-1?d=I?d+=s[h]:d+=y[A]+s[h]:s[h].search(/<\//)>-1?d=I?d+=s[h]:d+=y[--A]+s[h]:s[h].search(/\/>/)>-1?d=I?d+=s[h]:d+=y[A]+s[h]:s[h].search(/<\?/)>-1||s[h].search(/xmlns\:/)>-1||s[h].search(/xmlns\=/)>-1?d+=y[A]+s[h]:d+=s[h];return d[0]==` -`?d.slice(1):d},Kd.prototype.json=function(g,s){var s=s||this.step;return typeof JSON>"u"?g:typeof g=="string"?JSON.stringify(JSON.parse(g),null,s):typeof g=="object"?JSON.stringify(g,null,s):g},Kd.prototype.css=function(g,a){var s=g.replace(/\s{1,}/g," ").replace(/\{/g,"{~::~").replace(/\}/g,"~::~}~::~").replace(/\;/g,";~::~").replace(/\/\*/g,"~::~/*").replace(/\*\//g,"*/~::~").replace(/~::~\s{0,}~::~/g,"~::~").split("~::~"),C=s.length,I=0,A="",d=0,h=a?Tk(a):this.shift;for(d=0;d/g,"").replace(/[ \r\n\t]{1,}xmlns/g," xmlns");return s.replace(/>\s{0,}<")},Kd.prototype.jsonmin=function(g){return typeof JSON>"u"?g:JSON.stringify(JSON.parse(g),null,0)},Kd.prototype.cssmin=function(g,a){var s=a?g:g.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\//g,"");return s.replace(/\s{1,}/g," ").replace(/\{\s{1,}/g,"{").replace(/\}\s{1,}/g,"}").replace(/\;\s{1,}/g,";").replace(/\/\*\s{1,}/g,"/*").replace(/\*\/\s{1,}/g,"*/")},Kd.prototype.sqlmin=function(g){return g.replace(/\s{1,}/g," ").replace(/\s{1,}\(/,"(").replace(/\s{1,}\)/,")")};var wIt=new Kd,TIt=function(a,s){if(s=s.split(":")[0],a=+a,!a)return!1;switch(s){case"http":case"ws":return a!==80;case"https":case"wss":return a!==443;case"ftp":return a!==21;case"gopher":return a!==70;case"file":return!1}return a!==0},KJ={},RIt=Object.prototype.hasOwnProperty,VIt;function jme(g){try{return decodeURIComponent(g.replace(/\+/g," "))}catch{return null}}function $me(g){try{return encodeURIComponent(g)}catch{return null}}function EIt(g){for(var a=/([^=?#&]+)=?([^&]*)/g,s={},C;C=a.exec(g);){var I=jme(C[1]),A=jme(C[2]);I===null||A===null||I in s||(s[I]=A)}return s}function HIt(g,a){a=a||"";var s=[],C,I;typeof a!="string"&&(a="?");for(I in g)if(RIt.call(g,I)){if(C=g[I],!C&&(C===null||C===VIt||isNaN(C))&&(C=""),I=$me(I),C=$me(C),I===null||C===null)continue;s.push(I+"="+C)}return s.length?a+s.join("&"):""}KJ.stringify=HIt,KJ.parse=EIt;var qme=TIt,Rk=KJ,WIt=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,epe=/[\n\r\t]/g,NIt=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,tpe=/:\d+$/,kIt=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,XIt=/^[a-zA-Z]:/;function _J(g){return(g||"").toString().replace(WIt,"")}var PJ=[["#","hash"],["?","query"],function(a,s){return _A(s.protocol)?a.replace(/\\/g,"/"):a},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],ipe={hash:1,query:1};function npe(g){var a;typeof window<"u"?a=window:typeof globalThis<"u"?a=globalThis:typeof self<"u"?a=self:a={};var s=a.location||{};g=g||s;var C={},I=typeof g,A;if(g.protocol==="blob:")C=new PA(unescape(g.pathname),{});else if(I==="string"){C=new PA(g,{});for(A in ipe)delete C[A]}else if(I==="object"){for(A in g)A in ipe||(C[A]=g[A]);C.slashes===void 0&&(C.slashes=NIt.test(g.href))}return C}function _A(g){return g==="file:"||g==="ftp:"||g==="http:"||g==="https:"||g==="ws:"||g==="wss:"}function rpe(g,a){g=_J(g),g=g.replace(epe,""),a=a||{};var s=kIt.exec(g),C=s[1]?s[1].toLowerCase():"",I=!!s[2],A=!!s[3],d=0,h;return I?A?(h=s[2]+s[3]+s[4],d=s[2].length+s[3].length):(h=s[2]+s[4],d=s[2].length):A?(h=s[3]+s[4],d=s[3].length):h=s[4],C==="file:"?d>=2&&(h=h.slice(2)):_A(C)?h=s[4]:C?I&&(h=h.slice(2)):d>=2&&_A(a.protocol)&&(h=s[4]),{protocol:C,slashes:I||_A(C),slashesCount:d,rest:h}}function xIt(g,a){if(g==="")return a;for(var s=(a||"/").split("/").slice(0,-1).concat(g.split("/")),C=s.length,I=s[C-1],A=!1,d=0;C--;)s[C]==="."?s.splice(C,1):s[C]===".."?(s.splice(C,1),d++):d&&(C===0&&(A=!0),s.splice(C,1),d--);return A&&s.unshift(""),(I==="."||I==="..")&&s.push(""),s.join("/")}function PA(g,a,s){if(g=_J(g),g=g.replace(epe,""),!(this instanceof PA))return new PA(g,a,s);var C,I,A,d,h,y,Z=PJ.slice(),b=typeof a,w=this,S=0;for(b!=="object"&&b!=="string"&&(s=a,a=null),s&&typeof s!="function"&&(s=Rk.parse),a=npe(a),I=rpe(g||"",a),C=!I.protocol&&!I.slashes,w.slashes=I.slashes||C&&a.slashes,w.protocol=I.protocol||a.protocol||"",g=I.rest,(I.protocol==="file:"&&(I.slashesCount!==2||XIt.test(g))||!I.slashes&&(I.protocol||I.slashesCount<2||!_A(w.protocol)))&&(Z[3]=[/(.*)/,"pathname"]);S{try{return new window.BroadcastChannel("pub-sub-es")}catch{return{postMessage:()=>{}}}})(),zJ=(g,a)=>a?g.toLowerCase():g,ope=(g,{caseInsensitive:a}={})=>(s,C,I=1/0)=>{const A=zJ(s,a);return g[A]||(g[A]=[],g.__times__[A]=[]),g[A].push(C),g.__times__[A].push(+I||1/0),{event:A,handler:C}},OJ=(g,{caseInsensitive:a}={})=>(s,C)=>{typeof s=="object"&&(C=s.handler,s=s.event);const I=zJ(s,a);if(!g[I])return;const A=g[I].indexOf(C);A===-1||A>=g[I].length||(g[I].splice(A,1),g.__times__[I].splice(A,1))},ape=(g,a)=>()=>{g.forEach(s=>s(a))},spe=(g,{isGlobal:a,caseInsensitive:s,async:C}={})=>{const I=OJ(g);return(A,d,h={})=>{const y=zJ(A,s);if(!g[y])return;const Z=[...g[y]];if(Z.forEach((b,w)=>{--g.__times__[y][w]<1&&I(y,b)}),C||h.async?setTimeout(ape(Z,d),0):ape(Z,d)(),a&&!h.isNoGlobalBroadcast)try{gpe.postMessage({event:y,news:d})}catch(b){if(b instanceof DOMException)console.warn(`Could not broadcast '${y}' globally. Payload is not clonable.`);else throw b}}},YIt=g=>()=>{Object.keys(g).filter(a=>a[0]!=="_").forEach(a=>{g[a]=void 0,g.__times__[a]=void 0,delete g[a],delete g.__times__[a]})},Ipe=()=>({__times__:{}}),Vk=({async:g=!1,caseInsensitive:a=!1,stack:s=Ipe()}={})=>(s.__times__||(s.__times__={}),{publish:spe(s,{async:g,caseInsensitive:a}),subscribe:ope(s,{caseInsensitive:a}),unsubscribe:OJ(s,{caseInsensitive:a}),clear:YIt(s),stack:s}),Ek=Ipe(),G2={publish:spe(Ek,{isGlobal:!0}),subscribe:ope(Ek),unsubscribe:OJ(Ek),stack:Ek};gpe.onmessage=({data:{event:g,news:a}})=>G2.publish(g,a,!0);const sn={"context-menu":"_context-menu_18ock_1","context-menu-dark":"_context-menu-dark_18ock_12","context-menu-icon":"_context-menu-icon_18ock_17","context-menu-item":"_context-menu-item_18ock_27","context-menu-hr":"_context-menu-hr_18ock_38","play-icon":"_play-icon_18ock_45","context-menu-span":"_context-menu-span_18ock_52","context-menu-thumbnail":"_context-menu-thumbnail_18ock_60","context-menu-thumbnail-inline":"_context-menu-thumbnail-inline_18ock_65"};function Gn(g){return X.default.createElement("div",{"data-menu-item-for":typeof g.children=="string"?g.children:null,className:sn["context-menu-item"],onClick:a=>g.onClick(a),onMouseEnter:a=>g.onMouseEnter(a),onMouseLeave:a=>g.onMouseLeave(a),role:"button",tabIndex:0},X.default.createElement("span",{className:sn["context-menu-span"]},g.children))}Gn.defaultProps={onMouseEnter:()=>{},onMouseLeave:()=>{}},Gn.propTypes={children:_.exports.node.isRequired,onClick:_.exports.func.isRequired,onMouseEnter:_.exports.func,onMouseLeave:_.exports.func};var KIt={value:()=>{}};function FZ(){for(var g=0,a=arguments.length,s={},C;g=0&&(C=s.slice(I+1),s=s.slice(0,I)),s&&!a.hasOwnProperty(s))throw new Error("unknown type: "+s);return{type:s,name:C}})}Hk.prototype=FZ.prototype={constructor:Hk,on:function(g,a){var s=this._,C=_It(g+"",s),I,A=-1,d=C.length;if(arguments.length<2){for(;++A0)for(var s=new Array(I),C=0,I,A;C()=>g;function JJ(g,{sourceEvent:a,subject:s,target:C,identifier:I,active:A,x:d,y:h,dx:y,dy:Z,dispatch:b}){Object.defineProperties(this,{type:{value:g,enumerable:!0,configurable:!0},sourceEvent:{value:a,enumerable:!0,configurable:!0},subject:{value:s,enumerable:!0,configurable:!0},target:{value:C,enumerable:!0,configurable:!0},identifier:{value:I,enumerable:!0,configurable:!0},active:{value:A,enumerable:!0,configurable:!0},x:{value:d,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:y,enumerable:!0,configurable:!0},dy:{value:Z,enumerable:!0,configurable:!0},_:{value:b}})}JJ.prototype.on=function(){var g=this._.on.apply(this._,arguments);return g===this._?this:g};function zIt(g){return!g.ctrlKey&&!g.button}function OIt(){return this.parentNode}function LIt(g,a){return a??{x:g.x,y:g.y}}function JIt(){return navigator.maxTouchPoints||"ontouchstart"in this}function _d(){var g=zIt,a=OIt,s=LIt,C=JIt,I={},A=FZ("start","drag","end"),d=0,h,y,Z,b,w=0;function S(P){P.on("mousedown.drag",R).filter(C).on("touchstart.drag",D).on("touchmove.drag",M).on("touchend.drag touchcancel.drag",z).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function R(P,J){if(!(b||!g.call(this,P,J))){var j=K(this,a.call(this,P,J),P,J,"mouse");j&&(Mn(P.view).on("mousemove.drag",H,!0).on("mouseup.drag",N,!0),Wk(P.view),LJ(P),Z=!1,h=P.clientX,y=P.clientY,j("start",P))}}function H(P){if(YZ(P),!Z){var J=P.clientX-h,j=P.clientY-y;Z=J*J+j*j>w}I.mouse("drag",P)}function N(P){Mn(P.view).on("mousemove.drag mouseup.drag",null),Nk(P.view,Z),YZ(P),I.mouse("end",P)}function D(P,J){if(g.call(this,P,J)){var j=P.changedTouches,ie=a.call(this,P,J),te=j.length,Ce,ue;for(Ce=0;Ce=0&&g._call.call(null,a),g=g._next;--KZ}function upe(){D0=(xk=R2.now())+Dk,KZ=S2=0;try{jIt()}finally{KZ=0,qIt(),D0=0}}function $It(){var g=R2.now(),a=g-xk;a>Cpe&&(Dk-=a,xk=g)}function qIt(){for(var g,a=Xk,s,C=1/0;a;)a._call?(C>a._time&&(C=a._time),g=a,a=a._next):(s=a._next,a._next=null,a=g?g._next=s:Xk=s);T2=g,QJ(C)}function QJ(g){if(!KZ){S2&&(S2=clearTimeout(S2));var a=g-D0;a>24?(g<1/0&&(S2=setTimeout(upe,g-R2.now()-Dk)),w2&&(w2=clearInterval(w2))):(w2||(xk=R2.now(),w2=setInterval($It,Cpe)),KZ=1,cpe(upe))}}function dpe(g,a,s){var C=new Mk;return a=a==null?0:+a,C.restart(I=>{C.stop(),g(I+a)},a,s),C}var elt=FZ("start","end","cancel","interrupt"),tlt=[],hpe=0,fpe=1,jJ=2,Fk=3,mpe=4,$J=5,Yk=6;function Kk(g,a,s,C,I,A){var d=g.__transition;if(!d)g.__transition={};else if(s in d)return;ilt(g,s,{name:a,index:C,group:I,on:elt,tween:tlt,time:A.time,delay:A.delay,duration:A.duration,ease:A.ease,timer:null,state:hpe})}function qJ(g,a){var s=gc(g,a);if(s.state>hpe)throw new Error("too late; already scheduled");return s}function zA(g,a){var s=gc(g,a);if(s.state>Fk)throw new Error("too late; already running");return s}function gc(g,a){var s=g.__transition;if(!s||!(s=s[a]))throw new Error("transition not found");return s}function ilt(g,a,s){var C=g.__transition,I;C[a]=s,s.timer=Ape(A,0,s.time);function A(Z){s.state=fpe,s.timer.restart(d,s.delay,s.time),s.delay<=Z&&d(Z-s.delay)}function d(Z){var b,w,S,R;if(s.state!==fpe)return y();for(b in C)if(R=C[b],R.name===s.name){if(R.state===Fk)return dpe(d);R.state===mpe?(R.state=Yk,R.timer.stop(),R.on.call("interrupt",g,g.__data__,R.index,R.group),delete C[b]):+bjJ&&C.state<$J,C.state=Yk,C.timer.stop(),C.on.call(I?"interrupt":"cancel",g,g.__data__,C.index,C.group),delete s[d]}A&&delete g.__transition}}function nlt(g){return this.each(function(){eU(this,g)})}function rlt(g,a){var s,C;return function(){var I=zA(this,g),A=I.tween;if(A!==s){C=s=A;for(var d=0,h=C.length;d=0&&(a=a.slice(0,s)),!a||a==="start"})}function Hlt(g,a,s){var C,I,A=Elt(a)?qJ:zA;return function(){var d=A(this,g),h=d.on;h!==C&&(I=(C=h).copy()).on(a,s),d.on=I}}function Wlt(g,a){var s=this._id;return arguments.length<2?gc(this.node(),s).on.on(g):this.each(Hlt(s,g,a))}function Nlt(g){return function(){var a=this.parentNode;for(var s in this.__transition)if(+s!==g)return;a&&a.removeChild(this)}}function klt(){return this.on("end.remove",Nlt(this._id))}function Xlt(g){var a=this._name,s=this._id;typeof g!="function"&&(g=xe(g));for(var C=this._groups,I=C.length,A=new Array(I),d=0;d()=>g;function aCt(g,{sourceEvent:a,target:s,selection:C,mode:I,dispatch:A}){Object.defineProperties(this,{type:{value:g,enumerable:!0,configurable:!0},sourceEvent:{value:a,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},selection:{value:C,enumerable:!0,configurable:!0},mode:{value:I,enumerable:!0,configurable:!0},_:{value:A}})}function sCt(g){g.stopImmediatePropagation()}function nU(g){g.preventDefault(),g.stopImmediatePropagation()}var vpe={name:"drag"},rU={name:"space"},_Z={name:"handle"},PZ={name:"center"};const{abs:Zpe,max:Qa,min:ja}=Math;function Bpe(g){return[+g[0],+g[1]]}function gU(g){return[Bpe(g[0]),Bpe(g[1])]}var _k={name:"x",handles:["w","e"].map(V2),input:function(g,a){return g==null?null:[[+g[0],a[0][1]],[+g[1],a[1][1]]]},output:function(g){return g&&[g[0][0],g[1][0]]}},Pk={name:"y",handles:["n","s"].map(V2),input:function(g,a){return g==null?null:[[a[0][0],+g[0]],[a[1][0],+g[1]]]},output:function(g){return g&&[g[0][1],g[1][1]]}},ICt={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(V2),input:function(g){return g==null?null:gU(g)},output:function(g){return g}},zd={overlay:"crosshair",selection:"move",n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Gpe={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},Spe={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},lCt={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},CCt={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function V2(g){return{type:g}}function cCt(g){return!g.ctrlKey&&!g.button}function ACt(){var g=this.ownerSVGElement||this;return g.hasAttribute("viewBox")?(g=g.viewBox.baseVal,[[g.x,g.y],[g.x+g.width,g.y+g.height]]):[[0,0],[g.width.baseVal.value,g.height.baseVal.value]]}function uCt(){return navigator.maxTouchPoints||"ontouchstart"in this}function oU(g){for(;!g.__brush;)if(!(g=g.parentNode))return;return g.__brush}function dCt(g){return g[0][0]===g[1][0]||g[0][1]===g[1][1]}function hCt(g){var a=g.__brush;return a?a.dim.output(a.selection):null}function zk(){return sU(_k)}function E2(){return sU(Pk)}function aU(){return sU(ICt)}function sU(g){var a=ACt,s=cCt,C=uCt,I=!0,A=FZ("start","brush","end"),d=6,h;function y(D){var M=D.property("__brush",N).selectAll(".overlay").data([V2("overlay")]);M.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",zd.overlay).merge(M).each(function(){var K=oU(this).extent;Mn(this).attr("x",K[0][0]).attr("y",K[0][1]).attr("width",K[1][0]-K[0][0]).attr("height",K[1][1]-K[0][1])}),D.selectAll(".selection").data([V2("selection")]).enter().append("rect").attr("class","selection").attr("cursor",zd.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var z=D.selectAll(".handle").data(g.handles,function(K){return K.type});z.exit().remove(),z.enter().append("rect").attr("class",function(K){return"handle handle--"+K.type}).attr("cursor",function(K){return zd[K.type]}),D.each(Z).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",S).filter(C).on("touchstart.brush",S).on("touchmove.brush",R).on("touchend.brush touchcancel.brush",H).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.move=function(D,M){D.tween?D.on("start.brush",function(z){b(this,arguments).beforestart().start(z)}).on("interrupt.brush end.brush",function(z){b(this,arguments).end(z)}).tween("brush",function(){var z=this,K=z.__brush,P=b(z,arguments),J=K.selection,j=g.input(typeof M=="function"?M.apply(this,arguments):M,K.extent),ie=T0(J,j);function te(Ce){K.selection=Ce===1&&j===null?null:ie(Ce),Z.call(z),P.brush()}return J!==null&&j!==null?te:te(1)}):D.each(function(){var z=this,K=arguments,P=z.__brush,J=g.input(typeof M=="function"?M.apply(z,K):M,P.extent),j=b(z,K).beforestart();eU(z),P.selection=J===null?null:J,Z.call(z),j.start().brush().end()})},y.clear=function(D){y.move(D,null)};function Z(){var D=Mn(this),M=oU(this).selection;M?(D.selectAll(".selection").style("display",null).attr("x",M[0][0]).attr("y",M[0][1]).attr("width",M[1][0]-M[0][0]).attr("height",M[1][1]-M[0][1]),D.selectAll(".handle").style("display",null).attr("x",function(z){return z.type[z.type.length-1]==="e"?M[1][0]-d/2:M[0][0]-d/2}).attr("y",function(z){return z.type[0]==="s"?M[1][1]-d/2:M[0][1]-d/2}).attr("width",function(z){return z.type==="n"||z.type==="s"?M[1][0]-M[0][0]+d:d}).attr("height",function(z){return z.type==="e"||z.type==="w"?M[1][1]-M[0][1]+d:d})):D.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function b(D,M,z){var K=D.__brush.emitter;return K&&(!z||!K.clean)?K:new w(D,M,z)}function w(D,M,z){this.that=D,this.args=M,this.state=D.__brush,this.active=0,this.clean=z}w.prototype={beforestart:function(){return++this.active===1&&(this.state.emitter=this,this.starting=!0),this},start:function(D,M){return this.starting?(this.starting=!1,this.emit("start",D,M)):this.emit("brush",D),this},brush:function(D,M){return this.emit("brush",D,M),this},end:function(D,M){return--this.active===0&&(delete this.state.emitter,this.emit("end",D,M)),this},emit:function(D,M,z){var K=Mn(this.that).datum();A.call(D,this.that,new aCt(D,{sourceEvent:M,target:y,selection:g.output(this.state.selection),mode:z,dispatch:A}),K)}};function S(D){if(h&&!D.touches||!s.apply(this,arguments))return;var M=this,z=D.target.__data__.type,K=(I&&D.metaKey?z="overlay":z)==="selection"?vpe:I&&D.altKey?PZ:_Z,P=g===Pk?null:lCt[z],J=g===_k?null:CCt[z],j=oU(M),ie=j.extent,te=j.selection,Ce=ie[0][0],ue,oe,he=ie[0][1],ye,Ie,fe=ie[1][0],We,_e,qe=ie[1][1],nt,At,Tt=0,Ne=0,Ge,He=P&&J&&I&&D.shiftKey,Xe,at,bt=Array.from(D.touches||[D],Bi=>{const pn=Bi.identifier;return Bi=xr(Bi,M),Bi.point0=Bi.slice(),Bi.identifier=pn,Bi});if(z==="overlay"){te&&(Ge=!0);const Bi=[bt[0],bt[1]||bt[0]];j.selection=te=[[ue=g===Pk?Ce:ja(Bi[0][0],Bi[1][0]),ye=g===_k?he:ja(Bi[0][1],Bi[1][1])],[We=g===Pk?fe:Qa(Bi[0][0],Bi[1][0]),nt=g===_k?qe:Qa(Bi[0][1],Bi[1][1])]],bt.length>1&&Zi()}else ue=te[0][0],ye=te[0][1],We=te[1][0],nt=te[1][1];oe=ue,Ie=ye,_e=We,At=nt;var xt=Mn(M).attr("pointer-events","none"),Vt=xt.selectAll(".overlay").attr("cursor",zd[z]);eU(M);var _t=b(M,arguments,!0).beforestart();if(D.touches)_t.moved=Dt,_t.ended=ui;else{var Ci=Mn(D.view).on("mousemove.brush",Dt,!0).on("mouseup.brush",ui,!0);I&&Ci.on("keydown.brush",In,!0).on("keyup.brush",Li,!0),Wk(D.view)}Z.call(M),_t.start(D,K.name);function Dt(Bi){for(const pn of Bi.changedTouches||[Bi])for(const un of bt)un.identifier===pn.identifier&&(un.cur=xr(pn,M));if(He&&!Xe&&!at&&bt.length===1){const pn=bt[0];Zpe(pn.cur[0]-pn[0])>Zpe(pn.cur[1]-pn[1])?at=!0:Xe=!0}for(const pn of bt)pn.cur&&(pn[0]=pn.cur[0],pn[1]=pn.cur[1]);Ge=!0,nU(Bi),Zi(Bi)}function Zi(Bi){const pn=bt[0],un=pn.point0;var On;switch(Tt=pn[0]-un[0],Ne=pn[1]-un[1],K){case rU:case vpe:{P&&(Tt=Qa(Ce-ue,ja(fe-We,Tt)),oe=ue+Tt,_e=We+Tt),J&&(Ne=Qa(he-ye,ja(qe-nt,Ne)),Ie=ye+Ne,At=nt+Ne);break}case _Z:{bt[1]?(P&&(oe=Qa(Ce,ja(fe,bt[0][0])),_e=Qa(Ce,ja(fe,bt[1][0])),P=1),J&&(Ie=Qa(he,ja(qe,bt[0][1])),At=Qa(he,ja(qe,bt[1][1])),J=1)):(P<0?(Tt=Qa(Ce-ue,ja(fe-ue,Tt)),oe=ue+Tt,_e=We):P>0&&(Tt=Qa(Ce-We,ja(fe-We,Tt)),oe=ue,_e=We+Tt),J<0?(Ne=Qa(he-ye,ja(qe-ye,Ne)),Ie=ye+Ne,At=nt):J>0&&(Ne=Qa(he-nt,ja(qe-nt,Ne)),Ie=ye,At=nt+Ne));break}case PZ:{P&&(oe=Qa(Ce,ja(fe,ue-Tt*P)),_e=Qa(Ce,ja(fe,We+Tt*P))),J&&(Ie=Qa(he,ja(qe,ye-Ne*J)),At=Qa(he,ja(qe,nt+Ne*J)));break}}_e0&&(ue=oe-Tt),J<0?nt=At-Ne:J>0&&(ye=Ie-Ne),K=rU,Vt.attr("cursor",zd.selection),Zi());break}default:return}nU(Bi)}function Li(Bi){switch(Bi.keyCode){case 16:{He&&(Xe=at=He=!1,Zi());break}case 18:{K===PZ&&(P<0?We=_e:P>0&&(ue=oe),J<0?nt=At:J>0&&(ye=Ie),K=_Z,Zi());break}case 32:{K===rU&&(Bi.altKey?(P&&(We=_e-Tt*P,ue=oe+Tt*P),J&&(nt=At-Ne*J,ye=Ie+Ne*J),K=PZ):(P<0?We=_e:P>0&&(ue=oe),J<0?nt=At:J>0&&(ye=Ie),K=_Z),Vt.attr("cursor",zd[z]),Zi());break}default:return}nU(Bi)}}function R(D){b(this,arguments).moved(D)}function H(D){b(this,arguments).ended(D)}function N(){var D=this.__brush||{selection:null};return D.extent=gU(a.apply(this,arguments)),D.dim=g,D}return y.extent=function(D){return arguments.length?(a=typeof D=="function"?D:iU(gU(D)),y):a},y.filter=function(D){return arguments.length?(s=typeof D=="function"?D:iU(!!D),y):s},y.touchable=function(D){return arguments.length?(C=typeof D=="function"?D:iU(!!D),y):C},y.handleSize=function(D){return arguments.length?(d=+D,y):d},y.keyModifiers=function(D){return arguments.length?(I=!!D,y):I},y.on=function(){var D=A.on.apply(A,arguments);return D===A?y:D},y}const fCt=Object.freeze(Object.defineProperty({__proto__:null,brush:aU,brushX:zk,brushY:E2,brushSelection:hCt},Symbol.toStringTag,{value:"Module"}));function H2(){return H2=Object.assign?Object.assign.bind():function(g){for(var a=1;ag.length)&&(a=g.length);for(var s=0,C=new Array(a);s0&&arguments[0]!==void 0?arguments[0]:this.active.collection;return this.refs[s].sort(TCt)}}]),g}();function TCt(g,a){var s=g.node.sortableInfo.index,C=a.node.sortableInfo.index;return s-C}function RCt(g,a,s){return g=g.slice(),g.splice(s<0?g.length+s:s,0,g.splice(a,1)[0]),g}function Epe(g,a){return Object.keys(g).reduce(function(s,C){return a.indexOf(C)===-1&&(s[C]=g[C]),s},{})}var OZ={end:["touchend","touchcancel","mouseup"],move:["touchmove","mousemove"],start:["touchstart","mousedown"]},Hpe=function(){if(typeof window>"u"||typeof document>"u")return"";var g=window.getComputedStyle(document.documentElement,"")||["-moz-hidden-iframe"],a=(Array.prototype.slice.call(g).join("").match(/-(moz|webkit|ms)-/)||g.OLink===""&&["","o"])[1];switch(a){case"ms":return"ms";default:return a&&a.length?a[0].toUpperCase()+a.substr(1):""}}();function Ok(g,a){Object.keys(a).forEach(function(s){g.style[s]=a[s]})}function Lk(g,a){g.style["".concat(Hpe,"Transform")]=a==null?"":"translate3d(".concat(a.x,"px,").concat(a.y,"px,0)")}function uU(g,a){g.style["".concat(Hpe,"TransitionDuration")]=a==null?"":"".concat(a,"ms")}function X2(g,a){for(;g;){if(a(g))return g;g=g.parentNode}return null}function Wpe(g,a,s){return Math.max(g,Math.min(s,a))}function LZ(g){return g.substr(-2)==="px"?parseFloat(g):0}function VCt(g){var a=window.getComputedStyle(g);return{bottom:LZ(a.marginBottom),left:LZ(a.marginLeft),right:LZ(a.marginRight),top:LZ(a.marginTop)}}function dU(g,a){var s=a.displayName||a.name;return s?"".concat(g,"(").concat(s,")"):g}function hU(g,a){var s=g.getBoundingClientRect();return{top:s.top+a.top,left:s.left+a.left}}function x2(g){return g.touches&&g.touches.length?{x:g.touches[0].pageX,y:g.touches[0].pageY}:g.changedTouches&&g.changedTouches.length?{x:g.changedTouches[0].pageX,y:g.changedTouches[0].pageY}:{x:g.pageX,y:g.pageY}}function ECt(g){return g.touches&&g.touches.length||g.changedTouches&&g.changedTouches.length}function Jk(g,a){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{left:0,top:0};if(g){var C={left:s.left+g.offsetLeft,top:s.top+g.offsetTop};return g.parentNode===a?C:Jk(g.parentNode,a,C)}}function HCt(g,a,s){return ga?g-1:g>s&&g0&&s[d].height>0){var h=A.getContext("2d");h.drawImage(s[d],0,0)}}),C}function fU(g){var a,s,C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{withRef:!1};return s=a=function(I){AU(A,I);function A(){return W2(this,A),CU(this,k2(A).apply(this,arguments))}return N2(A,[{key:"componentDidMount",value:function(){var h=Y.findDOMNode(this);h.sortableHandle=!0}},{key:"getWrappedInstance",value:function(){return F0(C.withRef,"To access the wrapped instance, you need to pass in {withRef: true} as the second argument of the SortableHandle() call"),this.refs.wrappedInstance}},{key:"render",value:function(){var h=C.withRef?"wrappedInstance":null;return F.createElement(g,H2({ref:h},this.props))}}]),A}(F.Component),_r(a,"displayName",dU("sortableHandle",g)),s}function Xpe(g){return g.sortableHandle!=null}var xCt=function(){function g(a,s){W2(this,g),this.container=a,this.onScrollCallback=s}return N2(g,[{key:"clear",value:function(){this.interval!=null&&(clearInterval(this.interval),this.interval=null)}},{key:"update",value:function(s){var C=this,I=s.translate,A=s.minTranslate,d=s.maxTranslate,h=s.width,y=s.height,Z={x:0,y:0},b={x:1,y:1},w={x:10,y:10},S=this.container,R=S.scrollTop,H=S.scrollLeft,N=S.scrollHeight,D=S.scrollWidth,M=S.clientHeight,z=S.clientWidth,K=R===0,P=N-R-M===0,J=H===0,j=D-H-z===0;I.y>=d.y-y/2&&!P?(Z.y=1,b.y=w.y*Math.abs((d.y-y/2-I.y)/y)):I.x>=d.x-h/2&&!j?(Z.x=1,b.x=w.x*Math.abs((d.x-h/2-I.x)/h)):I.y<=A.y+y/2&&!K?(Z.y=-1,b.y=w.y*Math.abs((I.y-y/2-A.y)/y)):I.x<=A.x+h/2&&!J&&(Z.x=-1,b.x=w.x*Math.abs((I.x-h/2-A.x)/h)),this.interval&&(this.clear(),this.isAutoScrolling=!1),(Z.x!==0||Z.y!==0)&&(this.interval=setInterval(function(){C.isAutoScrolling=!0;var ie={left:b.x*Z.x,top:b.y*Z.y};C.container.scrollTop+=ie.top,C.container.scrollLeft+=ie.left,C.onScrollCallback(ie)},5))}}]),g}();function DCt(g){var a=g.node;return{height:a.offsetHeight,width:a.offsetWidth}}function MCt(g){var a=[K0.Input,K0.Textarea,K0.Select,K0.Option,K0.Button];return!!(a.indexOf(g.target.tagName)!==-1||X2(g.target,function(s){return s.contentEditable==="true"}))}var xpe={axis:_.exports.oneOf(["x","y","xy"]),contentWindow:_.exports.any,disableAutoscroll:_.exports.bool,distance:_.exports.number,getContainer:_.exports.func,getHelperDimensions:_.exports.func,helperClass:_.exports.string,helperContainer:_.exports.oneOfType([_.exports.func,typeof HTMLElement>"u"?_.exports.any:_.exports.instanceOf(HTMLElement)]),hideSortableGhost:_.exports.bool,keyboardSortingTransitionDuration:_.exports.number,lockAxis:_.exports.string,lockOffset:_.exports.oneOfType([_.exports.number,_.exports.string,_.exports.arrayOf(_.exports.oneOfType([_.exports.number,_.exports.string]))]),lockToContainerEdges:_.exports.bool,onSortEnd:_.exports.func,onSortMove:_.exports.func,onSortOver:_.exports.func,onSortStart:_.exports.func,pressDelay:_.exports.number,pressThreshold:_.exports.number,keyCodes:_.exports.shape({lift:_.exports.arrayOf(_.exports.number),drop:_.exports.arrayOf(_.exports.number),cancel:_.exports.arrayOf(_.exports.number),up:_.exports.arrayOf(_.exports.number),down:_.exports.arrayOf(_.exports.number)}),shouldCancelStart:_.exports.func,transitionDuration:_.exports.number,updateBeforeSortStart:_.exports.func,useDragHandle:_.exports.bool,useWindowAsScrollContainer:_.exports.bool},Dpe={lift:[Y0.SPACE],drop:[Y0.SPACE],cancel:[Y0.ESC],up:[Y0.UP,Y0.LEFT],down:[Y0.DOWN,Y0.RIGHT]},FCt={axis:"y",disableAutoscroll:!1,distance:0,getHelperDimensions:DCt,hideSortableGhost:!0,lockOffset:"50%",lockToContainerEdges:!1,pressDelay:0,pressThreshold:5,keyCodes:Dpe,shouldCancelStart:MCt,transitionDuration:300,useWindowAsScrollContainer:!1},YCt=Object.keys(xpe);function KCt(g){F0(!(g.distance&&g.pressDelay),"Attempted to set both `pressDelay` and `distance` on SortableContainer, you may only use one or the other, not both at the same time.")}function _Ct(g,a){try{var s=g()}catch(C){return a(!0,C)}return s&&s.then?s.then(a.bind(null,!1),a.bind(null,!0)):a(!1,value)}function PCt(g){var a,s,C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{withRef:!1};return s=a=function(I){AU(A,I);function A(d){var h;return W2(this,A),h=CU(this,k2(A).call(this,d)),_r(er(er(h)),"state",{}),_r(er(er(h)),"handleStart",function(y){var Z=h.props,b=Z.distance,w=Z.shouldCancelStart;if(!(y.button===2||w(y))){h.touched=!0,h.position=x2(y);var S=X2(y.target,function(z){return z.sortableInfo!=null});if(S&&S.sortableInfo&&h.nodeIsChild(S)&&!h.state.sorting){var R=h.props.useDragHandle,H=S.sortableInfo,N=H.index,D=H.collection,M=H.disabled;if(M||R&&!X2(y.target,Xpe))return;h.manager.active={collection:D,index:N},!ECt(y)&&y.target.tagName===K0.Anchor&&y.preventDefault(),b||(h.props.pressDelay===0?h.handlePress(y):h.pressTimer=setTimeout(function(){return h.handlePress(y)},h.props.pressDelay))}}}),_r(er(er(h)),"nodeIsChild",function(y){return y.sortableInfo.manager===h.manager}),_r(er(er(h)),"handleMove",function(y){var Z=h.props,b=Z.distance,w=Z.pressThreshold;if(!h.state.sorting&&h.touched&&!h._awaitingUpdateBeforeSortStart){var S=x2(y),R={x:h.position.x-S.x,y:h.position.y-S.y},H=Math.abs(R.x)+Math.abs(R.y);h.delta=R,!b&&(!w||H>=w)?(clearTimeout(h.cancelTimer),h.cancelTimer=setTimeout(h.cancel,0)):b&&H>=b&&h.manager.isActive()&&h.handlePress(y)}}),_r(er(er(h)),"handleEnd",function(){h.touched=!1,h.cancel()}),_r(er(er(h)),"cancel",function(){var y=h.props.distance,Z=h.state.sorting;Z||(y||clearTimeout(h.pressTimer),h.manager.active=null)}),_r(er(er(h)),"handlePress",function(y){try{var Z=h.manager.getActive(),b=function(){if(Z){var w=function(){var Ce=P.sortableInfo.index,ue=VCt(P),oe=kCt(h.container),he=h.scrollContainer.getBoundingClientRect(),ye=H({index:Ce,node:P,collection:J});if(h.node=P,h.margin=ue,h.gridGap=oe,h.width=ye.width,h.height=ye.height,h.marginOffset={x:h.margin.left+h.margin.right+h.gridGap.x,y:Math.max(h.margin.top,h.margin.bottom,h.gridGap.y)},h.boundingClientRect=P.getBoundingClientRect(),h.containerBoundingRect=he,h.index=Ce,h.newIndex=Ce,h.axis={x:R.indexOf("x")>=0,y:R.indexOf("y")>=0},h.offsetEdge=Jk(P,h.container),j?h.initialOffset=x2(lU({},y,{pageX:h.boundingClientRect.left,pageY:h.boundingClientRect.top})):h.initialOffset=x2(y),h.initialScroll={left:h.scrollContainer.scrollLeft,top:h.scrollContainer.scrollTop},h.initialWindowScroll={left:window.pageXOffset,top:window.pageYOffset},h.helper=h.helperContainer.appendChild(XCt(P)),Ok(h.helper,{boxSizing:"border-box",height:"".concat(h.height,"px"),left:"".concat(h.boundingClientRect.left-ue.left,"px"),pointerEvents:"none",position:"fixed",top:"".concat(h.boundingClientRect.top-ue.top,"px"),width:"".concat(h.width,"px")}),j&&h.helper.focus(),D&&(h.sortableGhost=P,Ok(P,{opacity:0,visibility:"hidden"})),h.minTranslate={},h.maxTranslate={},j){var Ie=K?{top:0,left:0,width:h.contentWindow.innerWidth,height:h.contentWindow.innerHeight}:h.containerBoundingRect,fe=Ie.top,We=Ie.left,_e=Ie.width,qe=Ie.height,nt=fe+qe,At=We+_e;h.axis.x&&(h.minTranslate.x=We-h.boundingClientRect.left,h.maxTranslate.x=At-(h.boundingClientRect.left+h.width)),h.axis.y&&(h.minTranslate.y=fe-h.boundingClientRect.top,h.maxTranslate.y=nt-(h.boundingClientRect.top+h.height))}else h.axis.x&&(h.minTranslate.x=(K?0:he.left)-h.boundingClientRect.left-h.width/2,h.maxTranslate.x=(K?h.contentWindow.innerWidth:he.left+he.width)-h.boundingClientRect.left-h.width/2),h.axis.y&&(h.minTranslate.y=(K?0:he.top)-h.boundingClientRect.top-h.height/2,h.maxTranslate.y=(K?h.contentWindow.innerHeight:he.top+he.height)-h.boundingClientRect.top-h.height/2);N&&N.split(" ").forEach(function(Tt){return h.helper.classList.add(Tt)}),h.listenerNode=y.touches?P:h.contentWindow,j?(h.listenerNode.addEventListener("wheel",h.handleKeyEnd,!0),h.listenerNode.addEventListener("mousedown",h.handleKeyEnd,!0),h.listenerNode.addEventListener("keydown",h.handleKeyDown)):(OZ.move.forEach(function(Tt){return h.listenerNode.addEventListener(Tt,h.handleSortMove,!1)}),OZ.end.forEach(function(Tt){return h.listenerNode.addEventListener(Tt,h.handleSortEnd,!1)})),h.setState({sorting:!0,sortingIndex:Ce}),z&&z({node:P,index:Ce,collection:J,isKeySorting:j,nodes:h.manager.getOrderedRefs(),helper:h.helper},y),j&&h.keyMove(0)},S=h.props,R=S.axis,H=S.getHelperDimensions,N=S.helperClass,D=S.hideSortableGhost,M=S.updateBeforeSortStart,z=S.onSortStart,K=S.useWindowAsScrollContainer,P=Z.node,J=Z.collection,j=h.manager.isKeySorting,ie=function(){if(typeof M=="function"){h._awaitingUpdateBeforeSortStart=!0;var te=_Ct(function(){var Ce=P.sortableInfo.index;return Promise.resolve(M({collection:J,index:Ce,node:P,isKeySorting:j},y)).then(function(){})},function(Ce,ue){if(h._awaitingUpdateBeforeSortStart=!1,Ce)throw ue;return ue});if(te&&te.then)return te.then(function(){})}}();return ie&&ie.then?ie.then(w):w(ie)}}();return Promise.resolve(b&&b.then?b.then(function(){}):void 0)}catch(w){return Promise.reject(w)}}),_r(er(er(h)),"handleSortMove",function(y){var Z=h.props.onSortMove;typeof y.preventDefault=="function"&&y.preventDefault(),h.updateHelperPosition(y),h.animateNodes(),h.autoscroll(),Z&&Z(y)}),_r(er(er(h)),"handleSortEnd",function(y){var Z=h.props,b=Z.hideSortableGhost,w=Z.onSortEnd,S=h.manager,R=S.active.collection,H=S.isKeySorting,N=h.manager.getOrderedRefs();h.listenerNode&&(H?(h.listenerNode.removeEventListener("wheel",h.handleKeyEnd,!0),h.listenerNode.removeEventListener("mousedown",h.handleKeyEnd,!0),h.listenerNode.removeEventListener("keydown",h.handleKeyDown)):(OZ.move.forEach(function(P){return h.listenerNode.removeEventListener(P,h.handleSortMove)}),OZ.end.forEach(function(P){return h.listenerNode.removeEventListener(P,h.handleSortEnd)}))),h.helper.parentNode.removeChild(h.helper),b&&h.sortableGhost&&Ok(h.sortableGhost,{opacity:"",visibility:""});for(var D=0,M=N.length;Db)){h.prevIndex=S,h.newIndex=w;var R=HCt(h.newIndex,h.prevIndex,h.index),H=Z.find(function(j){var ie=j.node;return ie.sortableInfo.index===R}),N=H.node,D=h.containerScrollDelta,M=H.boundingClientRect||hU(N,D),z=H.translate||{x:0,y:0},K={top:M.top+z.y-D.top,left:M.left+z.x-D.left},P=Sj?j/2:this.height/2,width:this.width>J?J/2:this.width/2},te=N&&P>this.index&&P<=D,Ce=N&&P=D,ue={x:0,y:0},oe=R[M].edgeOffset;oe||(oe=Jk(K,this.container),R[M].edgeOffset=oe,N&&(R[M].boundingClientRect=hU(K,w)));var he=M0&&R[M-1];if(he&&!he.edgeOffset&&(he.edgeOffset=Jk(he.node,this.container),N&&(he.boundingClientRect=hU(he.node,w))),P===this.index){Z&&(this.sortableGhost=K,Ok(K,{opacity:0,visibility:"hidden"}));continue}y&&uU(K,y),this.axis.x?this.axis.y?Ce||Pthis.containerBoundingRect.width-ie.width&&he&&(ue.x=he.edgeOffset.left-oe.left,ue.y=he.edgeOffset.top-oe.top),this.newIndex===null&&(this.newIndex=P)):(te||P>this.index&&(H.left+S.left+ie.width>=oe.left&&H.top+S.top+ie.height>=oe.top||H.top+S.top+ie.height>=oe.top+j))&&(ue.x=-(this.width+this.marginOffset.x),oe.left+ue.xthis.index&&H.left+S.left+ie.width>=oe.left?(ue.x=-(this.width+this.marginOffset.x),this.newIndex=P):(Ce||Pthis.index&&H.top+S.top+ie.height>=oe.top?(ue.y=-(this.height+this.marginOffset.y),this.newIndex=P):(Ce||P1&&arguments[1]!==void 0?arguments[1]:{withRef:!1};return s=a=function(I){AU(A,I);function A(){return W2(this,A),CU(this,k2(A).apply(this,arguments))}return N2(A,[{key:"componentDidMount",value:function(){this.register()}},{key:"componentDidUpdate",value:function(h){this.node&&(h.index!==this.props.index&&(this.node.sortableInfo.index=this.props.index),h.disabled!==this.props.disabled&&(this.node.sortableInfo.disabled=this.props.disabled)),h.collection!==this.props.collection&&(this.unregister(h.collection),this.register())}},{key:"componentWillUnmount",value:function(){this.unregister()}},{key:"register",value:function(){var h=this.props,y=h.collection,Z=h.disabled,b=h.index,w=Y.findDOMNode(this);w.sortableInfo={collection:y,disabled:Z,index:b,manager:this.context.manager},this.node=w,this.ref={node:w},this.context.manager.add(y,this.ref)}},{key:"unregister",value:function(){var h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props.collection;this.context.manager.remove(h,this.ref)}},{key:"getWrappedInstance",value:function(){return F0(C.withRef,"To access the wrapped instance, you need to pass in {withRef: true} as the second argument of the SortableElement() call"),this.refs.wrappedInstance}},{key:"render",value:function(){var h=C.withRef?"wrappedInstance":null;return F.createElement(g,H2({ref:h},Epe(this.props,zCt)))}}]),A}(F.Component),_r(a,"displayName",dU("sortableElement",g)),_r(a,"contextTypes",{manager:_.exports.object.isRequired}),_r(a,"propTypes",Mpe),_r(a,"defaultProps",{collection:0}),s}const Ype=pZ(g=>g.pos).left,xo=(g,a)=>{if(!a||!a.cumPositions||!a.cumPositions.length)return null;let s=Ype(a.cumPositions,g);const C=a.cumPositions[a.cumPositions.length-1].chr,I=a.chromLengths[C];s-=s>0&&1;let A=Math.floor(g-a.cumPositions[s].pos),d=0;return A<0&&(d=A-1,A=1),s===a.cumPositions.length-1&&A>I&&(d=A-I,A=I),[a.cumPositions[s].chr,A,d,s]},Kpe=(g,a)=>s=>s%g*a+Math.floor(s/g),OCt=g=>g,_pe=(g,a,s=OCt)=>g.map((C,I)=>C+a[s(I)]),LCt="http://www.w3.org/2000/svg",Uk=(g,a)=>{if(g.namespaceURI===LCt){const s=g.getAttribute("class");return s&&!!s.match(new RegExp(`(\\s|^)${a}(\\s|$)`))}return g.classList?g.classList.contains(a):!!g.className.match(new RegExp(`(\\s|^)${a}(\\s|$)`))},JCt="http://www.w3.org/2000/svg",UCt=(g,a)=>{if(g.namespaceURI===JCt){if(!Uk(g,a)){const s=g.getAttribute("class")||"";g.setAttribute("class",`${s} ${a}`)}}else g.classList?g.classList.add(a):Uk(g,a)||(g.className+=` ${a}`)},QCt=(g,a,s)=>{const C=document.createElement("canvas");return new Promise((I,A)=>{const d=new window.Image;d.onload=()=>{C.width=a||d.width,C.height=s||d.height,C.getContext("2d").drawImage(d,0,0),I(C)},d.onerror=()=>{A(new Error("Could not convert base64 to canvas"))},d.src=`data:image/png;base64,${g}`})},Qk=(g,a,s)=>s.chrPositions[g].pos+a,Ppe=g=>{const a=new g.constructor(g.type,g);return a.sourceUid=g.sourceUid,a.forwarded=g.forwarded,a},Df=(g,a=!1)=>{const s=g.map((d,h)=>h*(255/(g.length-1))),C=Zn().domain(s).range(g),A=Ns(a?255:254,-1,-1).map(C).map(d=>{const h=GZ(d);return[h.r,h.g,h.b,h.opacity*255]});return A.length<256&&A.push([255,255,255,0]),A},D2=0,M2=5,zpe=10,Ope=10,Lpe=300,jk="move",oC="select",mU=100,$k=10,Jpe=110,F2=3e3,Y2="locationListenerPrefix",Upe=1e3,pU="http://higlass.io/api/v1",Qpe=400,jpe=300,bU=["top","left","right","bottom","center","whole","gallery"],$pe=20,qpe=20,qk=Symbol("Light theme"),ig=Symbol("Dark theme"),jCt=qk,$t={PIXI:ee},aC={"multitrack-header":"_multitrack-header_1yz7l_1","multitrack-header-focus":"_multitrack-header-focus_1yz7l_2","multitrack-header-squeazed":"_multitrack-header-squeazed_1yz7l_3","multitrack-header-dark":"_multitrack-header-dark_1yz7l_20","multitrack-header-id":"_multitrack-header-id_1yz7l_30","multitrack-header-left":"_multitrack-header-left_1yz7l_39","multitrack-header-grabber":"_multitrack-header-grabber_1yz7l_44","multitrack-header-grabber-squeazed":"_multitrack-header-grabber-squeazed_1yz7l_45","multitrack-header-search":"_multitrack-header-search_1yz7l_80","multitrack-header-nav-list":"_multitrack-header-nav-list_1yz7l_102","multitrack-header-icon":"_multitrack-header-icon_1yz7l_107","multitrack-header-icon-squeazed":"_multitrack-header-icon-squeazed_1yz7l_108","mouse-tool-selection":"_mouse-tool-selection_1yz7l_136"},$Ct=[{id:"cog",paths:["M466.895 305.125c-26.863-46.527-10.708-106.152 36.076-133.244l-50.313-87.146c-14.375 8.427-31.088 13.259-48.923 13.259-53.768 0-97.354-43.873-97.354-97.995h-100.629c0.133 16.705-4.037 33.641-12.979 49.126-26.862 46.528-86.578 62.351-133.431 35.379l-50.312 87.146c14.485 8.236 27.025 20.294 35.943 35.739 26.819 46.454 10.756 105.96-35.854 133.112l50.313 87.146c14.325-8.348 30.958-13.127 48.7-13.127 53.598 0 97.072 43.596 97.35 97.479h100.627c-0.043-16.537 4.136-33.285 12.983-48.609 26.818-46.453 86.388-62.297 133.207-35.506l50.313-87.145c-14.39-8.233-26.846-20.249-35.717-35.614zM256 359.666c-57.254 0-103.668-46.412-103.668-103.667 0-57.254 46.413-103.667 103.668-103.667s103.666 46.413 103.666 103.667c-0.001 57.255-46.412 103.667-103.666 103.667z"],viewBox:"0 0 512 512"},{id:"cross",paths:["M507.331 411.33c-0.002-0.002-0.004-0.004-0.006-0.005l-155.322-155.325 155.322-155.325c0.002-0.002 0.004-0.003 0.006-0.005 1.672-1.673 2.881-3.627 3.656-5.708 2.123-5.688 0.912-12.341-3.662-16.915l-73.373-73.373c-4.574-4.573-11.225-5.783-16.914-3.66-2.080 0.775-4.035 1.984-5.709 3.655 0 0.002-0.002 0.003-0.004 0.005l-155.324 155.326-155.324-155.325c-0.002-0.002-0.003-0.003-0.005-0.005-1.673-1.671-3.627-2.88-5.707-3.655-5.69-2.124-12.341-0.913-16.915 3.66l-73.374 73.374c-4.574 4.574-5.784 11.226-3.661 16.914 0.776 2.080 1.985 4.036 3.656 5.708 0.002 0.001 0.003 0.003 0.005 0.005l155.325 155.324-155.325 155.326c-0.001 0.002-0.003 0.003-0.004 0.005-1.671 1.673-2.88 3.627-3.657 5.707-2.124 5.688-0.913 12.341 3.661 16.915l73.374 73.373c4.575 4.574 11.226 5.784 16.915 3.661 2.080-0.776 4.035-1.985 5.708-3.656 0.001-0.002 0.003-0.003 0.005-0.005l155.324-155.325 155.324 155.325c0.002 0.001 0.004 0.003 0.006 0.004 1.674 1.672 3.627 2.881 5.707 3.657 5.689 2.123 12.342 0.913 16.914-3.661l73.373-73.374c4.574-4.574 5.785-11.227 3.662-16.915-0.776-2.080-1.985-4.034-3.657-5.707z"],viewBox:"0 0 512 512"},{id:"enlarge",paths:["M512 0h-208l80 80-96 96 48 48 96-96 80 80z","M512 512v-208l-80 80-96-96-48 48 96 96-80 80z","M0 512h208l-80-80 96-96-48-48-96 96-80-80z","M0 0v208l80-80 96 96 48-48-96-96 80-80z"],viewBox:"0 0 512 512"},{id:"minus",paths:["M0 208v96c0 8.836 7.164 16 16 16h480c8.836 0 16-7.164 16-16v-96c0-8.836-7.164-16-16-16h-480c-8.836 0-16 7.164-16 16z"],viewBox:"0 0 512 512"},{id:"move",paths:["M512,260.096L405.5,161.79v49.155H301.061v-104.45h49.149L251.904,0L160.77,106.495h49.15v104.45H106.495V161.79L0,260.096l106.495,91.135v-49.149h104.45v104.45H161.79L251.904,512l98.306-106.5h-49.149V301.061H405.5v49.149L512,260.096z"],viewBox:"0 0 512 512"},{id:"play",paths:["M96 64l320 192-320 192z"],viewBox:"0 0 512 512"},{id:"plus",paths:["M496 192h-176v-176c0-8.836-7.164-16-16-16h-96c-8.836 0-16 7.164-16 16v176h-176c-8.836 0-16 7.164-16 16v96c0 8.836 7.164 16 16 16h176v176c0 8.836 7.164 16 16 16h96c8.836 0 16-7.164 16-16v-176h176c8.836 0 16-7.164 16-16v-96c0-8.836-7.164-16-16-16z"],viewBox:"0 0 512 512"},{id:"copy",paths:["M607.5 672v-448.5h-351v448.5h351zM607.5 160.5c34.5 0 64.5 28.5 64.5 63v448.5c0 34.5-30 64.5-64.5 64.5h-351c-34.5 0-64.5-30-64.5-64.5v-448.5c0-34.5 30-63 64.5-63h351zM511.5 31.5v64.5h-384v448.5h-63v-448.5c0-34.5 28.5-64.5 63-64.5h384z"],viewBox:"0 0 712 712"},{id:"select",viewBox:"0 0 16 16",paths:["M2 14h2v1H1v-3h1v2zm8 1H6v-1h4v1zm5 0h-3v-1h2v-2h1v3zm0-5h-1V6h1v4zM2 10H1V6h1v4zm13-6h-1V2h-2V1h3v3zM4 2H2v2H1V1h3v1zm6 0H6V1h4.03L10 2z"]},{id:"check_square_o",viewBox:"0 0 1792 1792",paths:["M1472 930v318q0 119-84.5 203.5t-203.5 84.5h-832q-119 0-203.5-84.5t-84.5-203.5v-832q0-119 84.5-203.5t203.5-84.5h832q63 0 117 25 15 7 18 23 3 17-9 29l-49 49q-10 10-23 10-3 0-9-2-23-6-45-6h-832q-66 0-113 47t-47 113v832q0 66 47 113t113 47h832q66 0 113-47t47-113v-254q0-13 9-22l64-64q10-10 23-10 6 0 12 3 20 8 20 29zm231-489l-814 814q-24 24-57 24t-57-24l-430-430q-24-24-24-57t24-57l110-110q24-24 57-24t57 24l263 263 647-647q24-24 57-24t57 24l110 110q24 24 24 57t-24 57z"]},{id:"square_o",viewBox:"0 0 1792 1792",paths:["M1312 256h-832q-66 0-113 47t-47 113v832q0 66 47 113t113 47h832q66 0 113-47t47-113v-832q0-66-47-113t-113-47zm288 160v832q0 119-84.5 203.5t-203.5 84.5h-832q-119 0-203.5-84.5t-84.5-203.5v-832q0-119 84.5-203.5t203.5-84.5h832q119 0 203.5 84.5t84.5 203.5z"]},{id:"file_o",viewBox:"0 0 1792 1792",paths:["M1596 380q28 28 48 76t20 88v1152q0 40-28 68t-68 28h-1344q-40 0-68-28t-28-68v-1600q0-40 28-68t68-28h896q40 0 88 20t76 48zm-444-244v376h376q-10-29-22-41l-313-313q-12-12-41-22zm384 1528v-1024h-416q-40 0-68-28t-28-68v-416h-768v1536h1280z"]},{id:"folder_o",viewBox:"0 0 1792 1792",paths:["M1600 1312v-704q0-40-28-68t-68-28h-704q-40 0-68-28t-28-68v-64q0-40-28-68t-68-28h-320q-40 0-68 28t-28 68v960q0 40 28 68t68 28h1216q40 0 68-28t28-68zm128-704v704q0 92-66 158t-158 66h-1216q-92 0-158-66t-66-158v-960q0-92 66-158t158-66h320q92 0 158 66t66 158v32h672q92 0 158 66t66 158z"]},{id:"folder_open_o",viewBox:"0 0 1792 1792",paths:["M1845 931q0-35-53-35h-1088q-40 0-85.5 21.5t-71.5 52.5l-294 363q-18 24-18 40 0 35 53 35h1088q40 0 86-22t71-53l294-363q18-22 18-39zm-1141-163h768v-160q0-40-28-68t-68-28h-576q-40 0-68-28t-28-68v-64q0-40-28-68t-68-28h-320q-40 0-68 28t-28 68v853l256-315q44-53 116-87.5t140-34.5zm1269 163q0 62-46 120l-295 363q-43 53-116 87.5t-140 34.5h-1088q-92 0-158-66t-66-158v-960q0-92 66-158t158-66h320q92 0 158 66t66 158v32h544q92 0 158 66t66 158v160h192q54 0 99 24.5t67 70.5q15 32 15 68z"]},{id:"chevron_right",viewBox:"0 0 1792 1792",paths:["M1363 877l-742 742q-19 19-45 19t-45-19l-166-166q-19-19-19-45t19-45l531-531-531-531q-19-19-19-45t19-45l166-166q19-19 45-19t45 19l742 742q19 19 19 45t-19 45z"]},{id:"chevron_down",viewBox:"0 0 1792 1792",paths:["M1683 808l-742 741q-19 19-45 19t-45-19l-742-741q-19-19-19-45.5t19-45.5l166-165q19-19 45-19t45 19l531 531 531-531q19-19 45-19t45 19l166 165q19 19 19 45.5t-19 45.5z"]}],oc=new DOMParser,qCt='',yU=oc.parseFromString(qCt,"text/xml").documentElement,ect=` - - - - - - - - -`,tct=oc.parseFromString(ect,"text/xml").documentElement,ict=` - - line - - - - - -`,nct=oc.parseFromString(ict,"text/xml").documentElement,rct=` - - - 2d-tiles-icon - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - -`,e0e=oc.parseFromString(rct,"text/xml").documentElement,gct=` - - - 2d-heatmap - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - -`,t0e=oc.parseFromString(gct,"text/xml").documentElement,i0e=` - - - axis-1d - Created with Sketch. - - - - - -`,oct=oc.parseFromString(i0e,"text/xml").documentElement,act=Mn(oc.parseFromString(i0e,"text/xml").documentElement).style("transform","rotate(90deg)").node(),sct=` - - - gene-annotations - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - -`,Ict=oc.parseFromString(sct,"text/xml").documentElement,n0e=` - - - 1d-tiles-icon - Created with Sketch. - - - - - - - - - - - - - - - -`,lct=oc.parseFromString(n0e,"text/xml").documentElement,Cct=Mn(oc.parseFromString(n0e,"text/xml").documentElement).style("transform","rotate(90deg)").node(),cct=` - - - arrowhead-domains - Created with Sketch. - - - - - - - - - - - - - - - -`,K2=oc.parseFromString(cct,"text/xml").documentElement;function Act({theStyle:g,onClick:a}){return X.default.createElement("svg",{className:aC[g],viewBox:"0 0 12 13",onClick:a,xmlns:"http://www.w3.org/2000/svg"},X.default.createElement("g",{fill:"none",stroke:"#6c6c6c",strokeWidth:"2"},X.default.createElement("path",{d:"M11.29 11.71l-4-4"}),X.default.createElement("circle",{cx:"5",cy:"5",r:"4"})))}const r0e={type:"osm-tiles",datatype:["map-tiles"],local:!0,orientation:"2d",hidden:!0,name:"OSM Tiles",thumbnail:yU,availableOptions:["minPos","maxPos","maxZoom","labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","name"],defaultOptions:{minPos:-180,maxPos:180,maxZoom:19,labelPosition:"bottomRight",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0}},g0e={type:"mapbox-tiles",datatype:["map-tiles"],local:!0,orientation:"2d",hidden:!0,name:"Mapbox Tiles",thumbnail:yU,availableOptions:["style","labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","name"],defaultOptions:{style:"mapbox.streets",labelPosition:"bottomRight",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0}},_0=[r0e,{...r0e,type:"osm"},g0e,{...g0e,type:"mapbox"},{type:"left-axis",datatype:["axis"],local:!0,orientation:"1d-vertical",name:"Left Axis",thumbnail:act,availableOptions:["minWidth"],defaultOptions:{minWidth:100}},{type:"top-axis",datatype:["axis"],local:!0,orientation:"1d-horizontal",name:"Top Axis",thumbnail:oct,defaultOptions:{}},{type:"horizontal-rule",datatype:["x-coord"],local:!0,orientation:"whole",name:"Horizontal Rule",thumbnail:null,availableOptions:["color"],defaultOptions:{color:"black"}},{type:"vertical-rule",datatype:["y-coord"],local:!0,orientation:"whole",name:"Vertical Rule",thumbnail:null,availableOptions:["color"],defaultOptions:{color:"black"}},{type:"cross-rule",datatype:["xy-coord"],local:!0,orientation:"whole",name:"Cross Rule",thumbnail:null,availableOptions:["color"],defaultOptions:{color:"black"}},{type:"simple-svg",datatype:[],local:!1,orientation:"2d",exportable:!0,availableOptions:["minWidth","minHeight"],defaultOptions:{minWidth:100,minHeight:100}},{type:"heatmap",datatype:["matrix"],local:!1,orientation:"2d",thumbnail:t0e,exportable:!0,availableOptions:["backgroundColor","labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelShowResolution","labelShowAssembly","labelColor","labelTextOpacity","labelBackgroundOpacity","colorRange","colorbarBackgroundColor","maxZoom","minWidth","minHeight","dataTransform","colorbarPosition","trackBorderWidth","trackBorderColor","heatmapValueScaling","showMousePosition","mousePositionColor","showTooltip","extent","zeroValueColor"],defaultOptions:{backgroundColor:"#eeeeee",labelPosition:"bottomRight",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,labelShowResolution:!0,labelShowAssembly:!0,colorRange:["white","rgba(245,166,35,1.0)","rgba(208,2,27,1.0)","black"],colorbarBackgroundColor:"#ffffff",maxZoom:null,minWidth:100,minHeight:100,colorbarPosition:"topRight",trackBorderWidth:0,trackBorderColor:"black",heatmapValueScaling:"log",showMousePosition:!1,mousePositionColor:"#000000",showTooltip:!1,extent:"full",zeroValueColor:null},defaultOptionsByTheme:{[ig]:{backgroundColor:"#000000",colorRange:["black","rgba(208,2,27,1.0)","rgba(245,166,35,1.0)","white"],colorbarBackgroundColor:"#000000",labelColor:"#ffffff",labelBackgroundColor:"#000000",trackBorderColor:"#ffffff",mousePositionColor:"#ffffff"}}},{type:"linear-heatmap",aliases:["horizontal-heatmap","vertical-heatmap"],datatype:["matrix"],local:!1,orientation:"1d-horizontal",rotatable:!0,thumbnail:t0e,defaultOptions:{backgroundColor:"#eeeeee",labelPosition:"bottomRight",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,labelShowResolution:!0,labelShowAssembly:!0,labelColor:"black",colorRange:["white","rgba(245,166,35,1.0)","rgba(208,2,27,1.0)","black"],maxZoom:null,minWidth:100,minHeight:40,trackBorderWidth:0,trackBorderColor:"black"},availableOptions:["backgroundColor","labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelShowResolution","labelShowAssembly","labelColor","labelTextOpacity","labelBackgroundOpacity","colorRange","maxZoom","minWidth","minHeight","dataTransform","oneDHeatmapFlipped","colorbarPosition","trackBorderWidth","trackBorderColor","heatmapValueScaling"]},{type:"line",aliases:["horizontal-line","vertical-line"],datatype:["vector"],local:!1,orientation:"1d-horizontal",rotatable:!0,thumbnail:nct,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelShowResolution","labelShowAssembly","labelColor","labelTextOpacity","labelBackgroundColor","labelBackgroundOpacity","axisLabelFormatting","axisPositionHorizontal","axisMargin","lineStrokeWidth","lineStrokeColor","valueScaling","valueScaleMin","valueScaleMax","trackBorderWidth","trackBorderColor","trackType","showMousePosition","showTooltip","mousePositionColor","aggregationMode","minHeight"],defaultOptions:{labelColor:"black",labelPosition:"topLeft",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,labelBackgroundColor:"white",labelShowResolution:!1,labelShowAssembly:!0,axisLabelFormatting:"scientific",axisPositionHorizontal:"right",lineStrokeColor:"blue",lineStrokeWidth:1,valueScaling:"linear",trackBorderWidth:0,trackBorderColor:"black",labelTextOpacity:.4,showMousePosition:!1,minHeight:20,mousePositionColor:"#000000",showTooltip:!1},defaultOptionsByTheme:{[ig]:{labelColor:"#ffffff",labelBackgroundColor:"#000000",trackBorderColor:"#ffffff",mousePositionColor:"#ffffff"}}},{type:"1d-heatmap",aliases:["horizontal-1d-heatmap","vertical-1d-heatmap"],datatype:["vector"],local:!1,orientation:"1d-horizontal",rotatable:!0,thumbnail:tct,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelShowResolution","labelShowAssembly","labelColor","labelTextOpacity","labelBackgroundOpacity","axisPositionHorizontal","axisMargin","colorRange","valueScaling","trackBorderWidth","trackBorderColor","trackType","showMousePosition","showTooltip","mousePositionColor","aggregationMode"],defaultOptions:{labelColor:"black",labelPosition:"topLeft",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,labelShowResolution:!1,labelShowAssembly:!0,axisPositionHorizontal:"right",colorRange:["white","rgba(245,166,35,1.0)","rgba(208,2,27,1.0)","black"],valueScaling:"linear",trackBorderWidth:0,trackBorderColor:"black",labelTextOpacity:.4,showMousePosition:!1,mousePositionColor:"#000000",showTooltip:!1}},{type:"vector-heatmap",aliases:["horizontal-vector-heatmap","vertical-vector-heatmap"],datatype:["vector"],local:!1,orientation:"1d-horizontal",rotatable:!0,minHeight:1,thumbnail:null,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelShowResolution","labelShowAssembly","labelColor","valueScaling","labelTextOpacity","labelBackgroundOpacity","colorRange","trackBorderWidth","trackBorderColor","trackType","heatmapValueScaling"],defaultOptions:{labelPosition:"topLeft",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,labelShowResolution:!1,labelShowAssembly:!0,labelColor:"black",labelTextOpacity:.4,valueScaling:"linear",trackBorderWidth:0,trackBorderColor:"black",heatmapValueScaling:"log"}},{type:"multivec",aliases:["horizontal-multivec","vertical-multivec"],datatype:["multivec"],local:!1,orientation:"1d-horizontal",rotatable:!0,thumbnail:null,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelShowResolution","labelShowAssembly","labelColor","minHeight","valueScaling","labelTextOpacity","labelBackgroundOpacity","colorRange","trackBorderWidth","trackBorderColor","trackType","heatmapValueScaling","selectRows","selectRowsAggregationMode","selectRowsAggregationWithRelativeHeight","selectRowsAggregationMethod","colorbarBackgroundColor","colorbarPosition","zeroValueColor"],defaultOptions:{labelPosition:"topLeft",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,labelShowResolution:!0,labelShowAssembly:!0,labelColor:"black",labelTextOpacity:.4,minHeight:100,valueScaling:"linear",trackBorderWidth:0,trackBorderColor:"black",heatmapValueScaling:"log",selectRows:null,selectRowsAggregationMode:"mean",selectRowsAggregationWithRelativeHeight:!0,selectRowsAggregationMethod:"client",colorbarBackgroundColor:"#ffffff",colorbarPosition:"topRight",zeroValueColor:null},defaultOptionsByTheme:{[ig]:{colorbarBackgroundColor:"#000000"}}},{type:"point",aliases:["horizontal-point","vertical-point"],datatype:["vector"],local:!1,orientation:"1d-horizontal",rotatable:!0,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelShowResolution","labelShowAssembly","labelColor","labelTextOpacity","labelBackgroundOpacity","axisLabelFormatting","axisPositionHorizontal","axisMargin","pointColor","pointSize","valueScaling","trackBorderWidth","trackBorderColor"],defaultOptions:{labelColor:"black",labelPosition:"topLeft",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,labelShowResolution:!1,labelShowAssembly:!0,axisLabelFormatting:"scientific",axisPositionHorizontal:"right",pointColor:"red",pointSize:3,valueScaling:"linear",trackBorderWidth:0,trackBorderColor:"black",labelTextOpacity:.4}},{type:"divergent-bar",aliases:["horizontal-divergent-bar","vertical-divergent-bar"],datatype:["vector"],local:!1,orientation:"1d-horizontal",rotatable:!0,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelShowResolution","labelShowAssembly","labelColor","labelTextOpacity","labelBackgroundOpacity","axisLabelFormatting","axisPositionHorizontal","axisMargin","barFillColorTop","barFillColorBottom","valueScaling","trackBorderWidth","trackBorderColor","barOpacity"],defaultOptions:{labelColor:"black",labelPosition:"topLeft",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,labelShowResolution:!1,labelShowAssembly:!0,axisPositionHorizontal:"right",axisLabelFormatting:"scientific",barFillColorBottom:"red",barFillColorTop:"green",valueScaling:"linear",trackBorderWidth:0,trackBorderColor:"black",labelTextOpacity:.4,barOpacity:1}},{type:"bar",aliases:["horizontal-bar","vertical-bar"],datatype:["vector"],local:!1,orientation:"1d-horizontal",rotatable:!0,availableOptions:["align","labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelShowResolution","labelShowAssembly","labelColor","labelTextOpacity","labelBackgroundOpacity","axisLabelFormatting","axisPositionHorizontal","axisMargin","barFillColor","colorRange","colorRangeGradient","valueScaling","valueScaleMin","valueScaleMax","trackBorderWidth","trackBorderColor","barOpacity","showMousePosition","showTooltip","aggregationMode","zeroLineVisible","zeroLineColor","zeroLineOpacity"],defaultOptions:{align:"bottom",labelColor:"[glyph-color]",labelPosition:"topLeft",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,labelShowResolution:!1,labelShowAssembly:!0,axisLabelFormatting:"scientific",axisPositionHorizontal:"right",barFillColor:"darkgreen",valueScaling:"linear",trackBorderWidth:0,trackBorderColor:"black",labelTextOpacity:.4,barOpacity:1}},{type:"2d-tiles",datatype:["matrix"],local:!1,orientation:"2d",name:"2D Tile Outlines",thumbnail:e0e},{type:"1d-value-interval",aliases:["horizontal-1d-value-interval","vertical-1d-value-interval"],datatype:["bed-value"],local:!1,orientation:["1d-horizontal"],rotatable:!0,name:"1D Rectangles",availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelColor","labelTextOpacity","labelBackgroundOpacity","axisPositionHorizontal","axisMargin"],defaultOptions:{labelColor:"black",labelPosition:"bottomLeft",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,axisPositionHorizontal:"left",lineStrokeColor:"blue",valueScaling:"linear"}},{type:"stacked-interval",aliases:["top-stacked-interval","left-stacked-interval"],datatype:["stacked-interval"],local:!1,orientation:"1d-horizontal",rotatable:!0,thumbnail:"horizontal-stacked-interval.png",availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelColor","labelTextOpacity","labelBackgroundOpacity"]},{type:"viewport-projection-vertical",datatype:["1d-projection"],local:!0,hidden:!0,projection:!0,orientation:"1d-vertical",name:"Viewport Projection",thumbnail:"viewport-projection-center.png",availableOptions:["projectionFillColor","projectionStrokeColor","strokeWidth"],defaultOptions:{projectionFillColor:"#777",projectionStrokeColor:"#777",projectionFillOpacity:.3,projectionStrokeOpacity:.7,strokeWidth:1}},{type:"viewport-projection-horizontal",datatype:["1d-projection"],local:!0,hidden:!0,projection:!0,orientation:"1d-horizontal",name:"Viewport Projection",thumbnail:"viewport-projection-center.png",availableOptions:["projectionFillColor","projectionStrokeColor","strokeWidth"],defaultOptions:{projectionFillColor:"#777",projectionStrokeColor:"#777",projectionFillOpacity:.3,projectionStrokeOpacity:.7,strokeWidth:1}},{type:"viewport-projection-center",datatype:["2d-projection"],local:!0,hidden:!0,projection:!0,orientation:"2d",name:"Viewport Projection",thumbnail:"viewport-projection-center.png",availableOptions:["projectionFillColor","projectionStrokeColor","strokeWidth"],defaultOptions:{projectionFillColor:"#777",projectionStrokeColor:"#777",projectionFillOpacity:.3,projectionStrokeOpacity:.7,strokeWidth:1}},{type:"gene-annotations",aliases:["horizontal-gene-annotations","vertical-gene-annotations"],datatype:["gene-annotation"],local:!1,defaultHeight:90,defaultWidth:90,rotatable:!0,orientation:"1d-horizontal",name:"Gene Annotations",thumbnail:Ict,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelColor","labelTextOpacity","labelBackgroundColor","labelBackgroundOpacity","minHeight","plusStrandColor","minusStrandColor","trackBorderWidth","trackBorderColor","showMousePosition","mousePositionColor","fontSize","geneAnnotationHeight","geneLabelPosition","geneStrandSpacing"],defaultOptions:{fontSize:10,labelColor:"black",labelBackgroundColor:"#ffffff",labelPosition:"hidden",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,minHeight:24,plusStrandColor:"blue",minusStrandColor:"red",trackBorderWidth:0,trackBorderColor:"black",showMousePosition:!1,mousePositionColor:"#000000",geneAnnotationHeight:16,geneLabelPosition:"outside",geneStrandSpacing:4},defaultOptionsByTheme:{[ig]:{labelColor:"#ffffff",labelBackgroundColor:"#000000",trackBorderColor:"#ffffff",mousePositionColor:"#ffffff",plusStrandColor:"#40a0ff"}}},{type:"arrowhead-domains",datatype:["arrowhead-domains"],local:!1,orientation:"2d",name:"Arrowhead Domains",thumbnail:K2,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelColor","labelTextOpacity","labelBackgroundOpacity","trackBorderWidth","trackBorderColor"],defaultOptions:{labelColor:"black",labelPosition:"hidden",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,trackBorderWidth:0,trackBorderColor:"black"}},{type:"linear-2d-rectangle-domains",aliases:["horizontal-2d-rectangle-domains","vertical-2d-rectangle-domains"],datatype:["2d-rectangle-domains"],local:!1,orientation:"1d-horizontal",rotatable:!0,name:"Horizontal 2D Rectangle Domains",thumbnail:K2,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelColor","labelTextOpacity","labelBackgroundOpacity","trackBorderWidth","trackBorderColor","rectangleDomainFillColor","rectangleDomainStrokeColor","rectangleDomainOpacity","minSquareSize"],defaultOptions:{labelColor:"black",labelPosition:"bottomLeft",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,trackBorderWidth:0,trackBorderColor:"black",rectangleDomainFillColor:"grey",rectangleDomainStrokeColor:"black",rectangleDomainOpacity:.6,minSquareSize:"none"}},{type:"2d-rectangle-domains",datatype:["2d-rectangle-domains"],local:!1,orientation:"2d",name:"2D Rectangle Domains",thumbnail:K2,availableOptions:["flipDiagonal","labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelColor","labelTextOpacity","labelBackgroundOpacity","trackBorderWidth","trackBorderColor","rectangleDomainFillColor","rectangleDomainFillOpacity","rectangleDomainStrokeColor","rectangleDomainOpacity","minSquareSize"],defaultOptions:{flipDiagonal:"none",labelColor:"black",labelPosition:"hidden",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,trackBorderWidth:0,trackBorderColor:"black",rectangleDomainFillColor:"grey",rectangleDomainFillOpacity:.4,rectangleDomainStrokeColor:"black",rectangleDomainOpacity:.6,minSquareSize:"none"}},{type:"horizontal-1d-annotations",datatype:["nothing"],local:!1,orientation:"1d-horizontal",name:"Horizontal 1D Annotations",thumbnail:null,availableOptions:["fill","fillOpacity","stroke","strokeOpacity","strokeWidth","strokePos","regions"],defaultOptions:{fill:"red",fillOpacity:.2,stroke:"red",strokeOpacity:0,strokeWidth:1,regions:[],strokePos:[]}},{type:"vertical-1d-annotations",datatype:["nothing"],local:!1,orientation:"1d-vertical",name:"Vertical 1D Annotations",thumbnail:null,availableOptions:["fill","fillOpacity","stroke","strokeOpacity","regions"],defaultOptions:{fill:"red",fillOpacity:"0.2",stroke:"red",strokeOpacity:"0",regions:[]}},{type:"2d-annotations",datatype:["2d-annotations"],local:!1,orientation:"2d",name:"2D Annotations",thumbnail:K2,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelColor","labelTextOpacity","labelBackgroundOpacity","trackBorderWidth","trackBorderColor","rectangleDomainFillColor","rectangleDomainStrokeColor","rectangleDomainOpacity","minSquareSize","isClickable","hoverColor","selectColor","exclude","trackBorderBgWidth","trackBorderBgColor","trackBorderBgAlpha"],defaultOptions:{labelColor:"black",labelPosition:"hidden",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,trackBorderWidth:0,trackBorderColor:"black",rectangleDomainFillColor:"grey",rectangleDomainStrokeColor:"black",rectangleDomainOpacity:.6,minSquareSize:"none",isClickable:!1,hoverColor:"orange",selectColor:"fuchsia",exclude:[],trackBorderBgWidth:0,trackBorderBgColor:"black",trackBorderBgAlpha:.33}},{type:"square-markers",datatype:["bedpe"],local:!1,orientation:"2d",name:"Square Markers",thumbnail:K2,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelColor"],defaultOptions:{labelColor:"black",labelPosition:"hidden",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,trackBorderWidth:0,trackBorderColor:"black"}},{type:"combined",datatype:"any",local:!0,orientation:"any"},{type:"horizontal-chromosome-grid",datatype:["chromsizes"],local:!1,orientation:"1d-horizontal",name:"Chromosome Grid",chromInfoPath:"//s3.amazonaws.com/pkerp/data/hg19/chromSizes.tsv",thumbnail:null,availableOptions:["lineStrokeWidth","lineStrokeColor","showMousePosition"],defaultOptions:{lineStrokeWidth:1,lineStrokeColor:"grey",showMousePosition:!1}},{type:"vertical-chromosome-grid",datatype:["chromsizes"],local:!1,orientation:"1d-vertical",name:"Chromosome Grid",chromInfoPath:"//s3.amazonaws.com/pkerp/data/hg19/chromSizes.tsv",thumbnail:null,availableOptions:["lineStrokeWidth","lineStrokeColor","showMousePosition"],defaultOptions:{lineStrokeWidth:1,lineStrokeColor:"grey",showMousePosition:!1}},{type:"2d-chromosome-grid",datatype:["chromsizes"],local:!1,orientation:"2d",name:"Chromosome Grid",chromInfoPath:"//s3.amazonaws.com/pkerp/data/hg19/chromSizes.tsv",thumbnail:null,availableOptions:["lineStrokeWidth","lineStrokeColor"],defaultOptions:{lineStrokeWidth:1,lineStrokeColor:"grey"}},{type:"2d-chromosome-annotations",datatype:["chromsizes"],local:!0,orientation:"2d",name:"2D Chromosome Annotations",thumbnail:null,hidden:!0},{type:"2d-chromosome-labels",datatype:["chromsizes"],local:!0,orientation:"2d",name:"Pairwise Chromosome Labels",thumbnail:null},{type:"chromosome-labels",aliases:["horizontal-chromosome-labels","vertical-chromosome-labels"],datatype:["chromsizes"],orientation:"1d-horizontal",rotatable:!0,minHeight:35,defaultHeight:30,name:"Chromosome Axis",thumbnail:null,availableOptions:["color","stroke","fontSize","fontIsLeftAligned","showMousePosition","mousePositionColor","tickPositions","tickFormat","reverseOrientation"],defaultOptions:{color:"#808080",stroke:"#ffffff",fontSize:12,fontIsLeftAligned:!1,showMousePosition:!1,mousePositionColor:"#000000",reverseOrientation:!1},defaultOptionsByTheme:{[ig]:{color:"#808080",stroke:"#000000",mousePositionColor:"#ffffff"}}},{type:"vertical-1d-tiles",datatype:["1d-tiles"],local:!1,orientation:"1d-vertical",name:"Vertical 1D Tile Outlines",thumbnail:Cct},{type:"horizontal-1d-tiles",datatype:["vector","stacked-interval","gene-annotation"],local:!1,orientation:"1d-horizontal",name:"Horizontal 1D Tile Outlines",thumbnail:lct},{type:"osm-2d-tile-ids",datatype:["map-tiles"],local:!1,orientation:"2d",name:"OSM Tile Outlines",thumbnail:e0e,availableOptions:["minPos","maxPos","maxZoom","labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","name"],defaultOptions:{minPos:-180,maxPos:180,maxZoom:19,labelPosition:"bottomRight",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0}},{type:"raster-tiles",datatype:["map-tiles"],local:!0,orientation:"2d",hidden:!0,name:"Raster Tiles",thumbnail:yU,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","name"],defaultOptions:{labelPosition:"bottomRight",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0}},{type:"image-tiles",datatype:["image-tiles"],local:!0,orientation:"2d",hidden:!0,name:"Image Tiles",thumbnail:null},{type:"bedlike",datatype:["bedlike"],aliases:["vertical-bedlike"],local:!1,orientation:"1d-horizontal",rotatable:!0,name:"BED-like track",thumbnail:null,availableOptions:["alternating","annotationHeight","annotationStyle","fillColor","fillOpacity","fontColor","fontSize","minusStrandColor","plusStrandColor","labelBottomMargin","labelColor","labelLeftMargin","labelPosition","labelRightMargin","labelTopMargin","labelTextOpacity","labelBackgroundOpacity","maxAnnotationHeight","minHeight","trackBorderWidth","trackBorderColor","valueColumn","colorEncoding","colorRange","colorEncodingRange","separatePlusMinusStrands","showTexts","axisPositionHorizontal","axisMargin"],defaultOptions:{alternating:!1,annotationStyle:"box",fillColor:"blue",fillOpacity:.3,fontSize:"10",axisPositionHorizontal:"right",labelColor:"black",labelPosition:"hidden",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,minHeight:20,maxAnnotationHeight:null,trackBorderWidth:0,trackBorderColor:"black",valueColumn:null,colorEncoding:"itemRgb",showTexts:!1,colorRange:["#000000","#652537","#bf5458","#fba273","#ffffe0"],colorEncodingRange:!1,separatePlusMinusStrands:!0,annotationHeight:16}},{type:"empty",datatype:[],orientation:"1d-horizontal",name:"Empty track",thumbnail:null,availableOptions:[],defaultOptions:{}}],vU=g=>{const a={},s=C=>!!(C.orientation===g||g==="1d-vertical"&&C.orientation==="1d-horizontal"&&C.rotatable);return _0.filter(s).forEach(C=>{let I=C.datatype;Array.isArray(C.datatype)||(I=[I]),I.forEach(A=>{A in a||(a[A]=[]),a[A].push(C)})}),a.none=[],a},JZ=[[0,0,0,255],[35,0,0,255],[52,0,0,255],[60,0,0,255],[63,1,0,255],[64,2,0,255],[68,5,0,255],[69,6,0,255],[72,8,0,255],[74,10,0,255],[77,12,0,255],[78,14,0,255],[81,16,0,255],[83,17,0,255],[85,19,0,255],[86,20,0,255],[89,22,0,255],[91,24,0,255],[92,25,0,255],[94,26,0,255],[95,28,0,255],[98,30,0,255],[100,31,0,255],[102,33,0,255],[103,34,0,255],[105,35,0,255],[106,36,0,255],[108,38,0,255],[109,39,0,255],[111,40,0,255],[112,42,0,255],[114,43,0,255],[115,44,0,255],[117,45,0,255],[119,47,0,255],[119,47,0,255],[120,48,0,255],[122,49,0,255],[123,51,0,255],[125,52,0,255],[125,52,0,255],[126,53,0,255],[128,54,0,255],[129,56,0,255],[129,56,0,255],[131,57,0,255],[132,58,0,255],[134,59,0,255],[134,59,0,255],[136,61,0,255],[137,62,0,255],[137,62,0,255],[139,63,0,255],[139,63,0,255],[140,65,0,255],[142,66,0,255],[142,66,0,255],[143,67,0,255],[143,67,0,255],[145,68,0,255],[145,68,0,255],[146,70,0,255],[146,70,0,255],[148,71,0,255],[148,71,0,255],[149,72,0,255],[149,72,0,255],[151,73,0,255],[151,73,0,255],[153,75,0,255],[153,75,0,255],[154,76,0,255],[154,76,0,255],[154,76,0,255],[156,77,0,255],[156,77,0,255],[157,79,0,255],[157,79,0,255],[159,80,0,255],[159,80,0,255],[159,80,0,255],[160,81,0,255],[160,81,0,255],[162,82,0,255],[162,82,0,255],[163,84,0,255],[163,84,0,255],[165,85,0,255],[165,85,0,255],[166,86,0,255],[166,86,0,255],[166,86,0,255],[168,87,0,255],[168,87,0,255],[170,89,0,255],[170,89,0,255],[171,90,0,255],[171,90,0,255],[173,91,0,255],[173,91,0,255],[174,93,0,255],[174,93,0,255],[176,94,0,255],[176,94,0,255],[177,95,0,255],[177,95,0,255],[179,96,0,255],[179,96,0,255],[180,98,0,255],[182,99,0,255],[182,99,0,255],[183,100,0,255],[183,100,0,255],[185,102,0,255],[185,102,0,255],[187,103,0,255],[187,103,0,255],[188,104,0,255],[188,104,0,255],[190,105,0,255],[191,107,0,255],[191,107,0,255],[193,108,0,255],[193,108,0,255],[194,109,0,255],[196,110,0,255],[196,110,0,255],[197,112,0,255],[197,112,0,255],[199,113,0,255],[200,114,0,255],[200,114,0,255],[202,116,0,255],[202,116,0,255],[204,117,0,255],[205,118,0,255],[205,118,0,255],[207,119,0,255],[208,121,0,255],[208,121,0,255],[210,122,0,255],[211,123,0,255],[211,123,0,255],[213,124,0,255],[214,126,0,255],[214,126,0,255],[216,127,0,255],[217,128,0,255],[217,128,0,255],[219,130,0,255],[221,131,0,255],[221,131,0,255],[222,132,0,255],[224,133,0,255],[224,133,0,255],[225,135,0,255],[227,136,0,255],[227,136,0,255],[228,137,0,255],[230,138,0,255],[230,138,0,255],[231,140,0,255],[233,141,0,255],[233,141,0,255],[234,142,0,255],[236,144,0,255],[236,144,0,255],[238,145,0,255],[239,146,0,255],[241,147,0,255],[241,147,0,255],[242,149,0,255],[244,150,0,255],[244,150,0,255],[245,151,0,255],[247,153,0,255],[247,153,0,255],[248,154,0,255],[250,155,0,255],[251,156,0,255],[251,156,0,255],[253,158,0,255],[255,159,0,255],[255,159,0,255],[255,160,0,255],[255,161,0,255],[255,163,0,255],[255,163,0,255],[255,164,0,255],[255,165,0,255],[255,167,0,255],[255,167,0,255],[255,168,0,255],[255,169,0,255],[255,169,0,255],[255,170,0,255],[255,172,0,255],[255,173,0,255],[255,173,0,255],[255,174,0,255],[255,175,0,255],[255,177,0,255],[255,178,0,255],[255,179,0,255],[255,181,0,255],[255,181,0,255],[255,182,0,255],[255,183,0,255],[255,184,0,255],[255,187,7,255],[255,188,10,255],[255,189,14,255],[255,191,18,255],[255,192,21,255],[255,193,25,255],[255,195,29,255],[255,197,36,255],[255,198,40,255],[255,200,43,255],[255,202,51,255],[255,204,54,255],[255,206,61,255],[255,207,65,255],[255,210,72,255],[255,211,76,255],[255,214,83,255],[255,216,91,255],[255,219,98,255],[255,221,105,255],[255,223,109,255],[255,225,116,255],[255,228,123,255],[255,232,134,255],[255,234,142,255],[255,237,149,255],[255,239,156,255],[255,240,160,255],[255,243,167,255],[255,246,174,255],[255,248,182,255],[255,249,185,255],[255,252,193,255],[255,253,196,255],[255,255,204,255],[255,255,207,255],[255,255,211,255],[255,255,218,255],[255,255,222,255],[255,255,225,255],[255,255,229,255],[255,255,233,255],[255,255,236,255],[255,255,240,255],[255,255,244,255],[255,255,247,255],[255,255,255,0]],Pr=_0.reduce((g,a)=>{if(g[a.type]=a,a.aliases)for(const s of a.aliases)g[s]=a;return g},{}),uct=_0.reduce((g,a)=>{for(let s=0;s{const s=vU(a);let C=new Set(Object.values(s).flatMap(I=>I));for(const I of g){const A=new Set(I);C=new Set([...C].filter(d=>d.datatype.filter(h=>A.has(h)).length>0))}return[...C]},o0e=8,ZU=8,dct=Object.freeze(Object.defineProperty({__proto__:null,THEME_LIGHT:qk,THEME_DARK:ig,THEME_DEFAULT:jCt,GLOBALS:$t,DATATYPE_TO_TRACK_TYPE:vU,HEATED_OBJECT_MAP:JZ,TRACKS_INFO:_0,TRACKS_INFO_BY_TYPE:Pr,POSITIONS_BY_DATATYPE:uct,DEFAULT_TRACKS_FOR_DATATYPE:_2,AVAILABLE_TRACK_TYPES:eX,NUM_PRECOMP_SUBSETS_PER_1D_TTILE:o0e,NUM_PRECOMP_SUBSETS_PER_2D_TTILE:ZU,DEFAULT_VIEW_MARGIN:D2,DEFAULT_VIEW_PADDING:M2,DEFAULT_CONTAINER_PADDING_X:zpe,DEFAULT_CONTAINER_PADDING_Y:Ope,MAX_CLICK_DELAY:Lpe,MOUSE_TOOL_MOVE:jk,MOUSE_TOOL_SELECT:oC,TILE_FETCH_DEBOUNCE:mU,ZOOM_DEBOUNCE:$k,SHORT_DRAG_TIMEOUT:Jpe,LONG_DRAG_TIMEOUT:F2,LOCATION_LISTENER_PREFIX:Y2,ZOOM_TRANSITION_DURATION:Upe,DEFAULT_SERVER:pU,VIEW_HEADER_MED_WIDTH_SEARCH_BAR:Qpe,VIEW_HEADER_MIN_WIDTH_SEARCH_BAR:jpe,TRACK_LOCATIONS:bU,MIN_HORIZONTAL_HEIGHT:$pe,MIN_VERTICAL_WIDTH:qpe},Symbol.toStringTag,{value:"Module"})),Mi=g=>{const a=ko(g);return $t.PIXI.utils.rgb2hex([a.r/255,a.g/255,a.b/255])},a0e=g=>{if(g==="transparent")return[255,255,255,0];const a=ko(g);return[a.r,a.g,a.b,255]},tX=(g,a,s)=>{const C=xo(g,s),I=xo(a,s);return[C[0],Math.round(C[1]),I[0],Math.round(I[1])]},iX=(g,a,s)=>{let C;const I=(...A)=>{const d=()=>{C=null,s||g(...A)},h=s&&!C;clearTimeout(C),C=setTimeout(d,a),h&&g(...A)};return iX.cancel=()=>{clearTimeout(C),C=null},I},BU=g=>(g+16**6).toString(16).substr(-6),s0e=g=>{const a={};return g.forEach(s=>{a[s[0]]=s[1]}),a},sC=g=>{const a=[];for(const s in g)g.hasOwnProperty(s)&&a.push([s,g[s]]);return a};function IC(g){const a=[];for(const s in g)g.hasOwnProperty(s)&&a.push(s);return a}function Mr(g){const a=[];for(const s in g)g.hasOwnProperty(s)&&a.push(g[s]);return a}function P2(g,a){const s=typeof a=="string"?new Blob([a],{type:"application/octet-stream"}):a;if(window.navigator.msSaveOrOpenBlob)window.navigator.msSaveBlob(s,g);else{const C=window.document.createElement("a");C.href=window.URL.createObjectURL(s),C.download=g,document.body.appendChild(C),C.click(),document.body.removeChild(C),URL.revokeObjectURL(C.href)}}const I0e=g=>{const a=["top","bottom","gallery"],s=["left","right","gallery"];return g.center=g.center||[],g.left=g.left||[],g.right=g.right||[],g.top=g.top||[],g.bottom=g.bottom||[],g.whole=g.whole||[],g.gallery=g.gallery||[],a.map(C=>g[C]).forEach(C=>C.forEach(I=>{const A=Pr[I.type],d=A&&A.defaultOptions||{},h=I.options?{...d,...I.options}:d;h.minHeight!==void 0&&I.height===void 0&&(I.height=h.minHeight),I.height===void 0&&(I.height=A&&A.defaultHeight||$pe)})),s.map(C=>g[C]).forEach(C=>C.forEach(I=>{const A=Pr[I.type],d=A&&A.defaultOptions||{},h=I.options?{...d,...I.options}:d;h.minWidth!==void 0&&I.width===void 0&&(I.width=h.minWidth),I.width===void 0&&(I.width=A&&A.defaultWidth||qpe)})),g},l0e=g=>a=>Array.prototype.reduce.call(a,g),hct=l0e((g,a)=>g.concat(a)),fct=g=>a=>Array.prototype.forEach.call(a,g),nX=(g,a)=>{a.dispatchEvent(Ppe(g))},mct=(g,a)=>[Qk(g[0],g[1],a),Qk(g[2],g[3],a)];function pct(g,a,s,C,I){const{chr:A,pos:d}=a,{chr:h,pos:y}=s,Z=[];if(A===h){const b=A,w=Math.floor(d/C),S=Math.min(w+I,Math.ceil(y/C));Z.push([b,w,S])}else{let b=I;const w=g.findIndex(([R])=>R===A),S=g.findIndex(([R])=>R===h);for(let R=w;R<=S;R++){let H,N;const[D,M]=g[R];R{if(s.length===0)return;if(s.length===1)return s[0];let C=s[0];const I=_2[g]!==void 0?_2[g][a]:void 0;return I!==void 0&&(C=s.find(A=>A.type===I)||C),C};var C0e={},SU={},wU=34,z2=10,TU=13;function c0e(g){return new Function("d","return {"+g.map(function(a,s){return JSON.stringify(a)+": d["+s+'] || ""'}).join(",")+"}")}function bct(g,a){var s=c0e(g);return function(C,I){return a(s(C),I,g)}}function A0e(g){var a=Object.create(null),s=[];return g.forEach(function(C){for(var I in C)I in a||s.push(a[I]=I)}),s}function BI(g,a){var s=g+"",C=s.length;return C9999?"+"+BI(g,6):BI(g,4)}function vct(g){var a=g.getUTCHours(),s=g.getUTCMinutes(),C=g.getUTCSeconds(),I=g.getUTCMilliseconds();return isNaN(g)?"Invalid Date":yct(g.getUTCFullYear())+"-"+BI(g.getUTCMonth()+1,2)+"-"+BI(g.getUTCDate(),2)+(I?"T"+BI(a,2)+":"+BI(s,2)+":"+BI(C,2)+"."+BI(I,3)+"Z":C?"T"+BI(a,2)+":"+BI(s,2)+":"+BI(C,2)+"Z":s||a?"T"+BI(a,2)+":"+BI(s,2)+"Z":"")}function RU(g){var a=new RegExp('["'+g+` -\r]`),s=g.charCodeAt(0);function C(w,S){var R,H,N=I(w,function(D,M){if(R)return R(D,M-1);H=D,R=S?bct(D,S):c0e(D)});return N.columns=H||[],N}function I(w,S){var R=[],H=w.length,N=0,D=0,M,z=H<=0,K=!1;w.charCodeAt(H-1)===z2&&--H,w.charCodeAt(H-1)===TU&&--H;function P(){if(z)return SU;if(K)return K=!1,C0e;var j,ie=N,te;if(w.charCodeAt(ie)===wU){for(;N++=H?z=!0:(te=w.charCodeAt(N++))===z2?K=!0:te===TU&&(K=!0,w.charCodeAt(N)===z2&&++N),w.slice(ie+1,j-1).replace(/""/g,'"')}for(;NrX[g]?Promise.resolve(rX[g]):a(g),Fct=g=>{if(g.length===0)return null;const a=VU(g);return sX(a)},Yct=g=>fetch(g,{credentials:"same-origin"}).then(a=>a.text()).then(a=>Fct(a)).catch(a=>{console.error("Could not retrieve or parse chrom info.",a)}),Kct=(g,a,s)=>a(g,s).then(C=>(rX[g]=C,rX[g])),EU={get:g=>Kct(g,Mct,Yct)};let _ct=function(){function g(a){T(this,g),this.customEventHandlers={},this.registeredEls={},this.pubSub=a}return E(g,[{key:"getEventHandler",value:function(s){return this.customEventHandlers[s]?this.customEventHandlers[s]:C=>this.pubSub.publish(s,C)}},{key:"unregister",value:function(s,C){!this.registeredEls[s]&&this.registeredEls[s]!==C||(this.registeredEls[s].removeEventListener(s,this.registeredEls[s].__handler__),this.registeredEls[s]=void 0,delete this.registeredEls[s])}},{key:"register",value:function(s,C,I=!1){!C||this.registeredEls[s]===C||(this.registeredEls[s]&&this.unregister(this.registeredEls[s]),this.registeredEls[s]=C,this.registeredEls[s].__handler__=this.getEventHandler(s),this.registeredEls[s].addEventListener(s,this.registeredEls[s].__handler__,{capture:I,passive:!1}))}}]),g}();const u0e=g=>new _ct(g);let d0e=!1;const h0e={listen:()=>{if(d0e)return;const[g,a]=y0e(),s="102117110099116105111110040041123115101108102046099111110115111108101046108111103040039",C="072",I="105",A="071",d="108097115115",h="032118",y="058032104116116112058047047104105103108097115115046105111039041125",Z=[String.fromCharCode(...s.match(/.{1,3}/g).map(ie=>+ie)).toLowerCase(),String.fromCharCode(...C.match(/.{1,3}/g).map(ie=>+ie)),String.fromCharCode(...I.match(/.{1,3}/g).map(ie=>+ie)).toLowerCase(),String.fromCharCode(...A.match(/.{1,3}/g).map(ie=>+ie)),String.fromCharCode(...d.match(/.{1,3}/g).map(ie=>+ie)).toLowerCase(),String.fromCharCode(...h.match(/.{1,3}/g).map(ie=>+ie)).toLowerCase(),String.fromCharCode(...a.match(/.{1,3}/g).map(ie=>+ie)).toLowerCase(),String.fromCharCode(...y.match(/.{1,3}/g).map(ie=>+ie)).toLowerCase()].join(""),b="085082076",w="066076079066",S="087111114107101114",R="099114101097116101079098106101099116085082076",H="114101118111107101079098106101099116085082076",N=ie=>ie.charAt(0).toUpperCase()+ie.slice(1),D=ie=>ie.slice(0,6)+ie.charAt(6).toUpperCase()+ie.slice(7,12)+ie.slice(12).toUpperCase(),M=g[String.fromCharCode(...b.match(/.{1,3}/g).map(ie=>+ie))],z=g[N(String.fromCharCode(...w.match(/.{1,3}/g).map(ie=>+ie)).toLowerCase())],K=g[N(String.fromCharCode(...S.match(/.{1,3}/g).map(ie=>+ie)).toLowerCase())],P=D(String.fromCharCode(...R.match(/.{1,3}/g).map(ie=>+ie)).toLowerCase()),J=D(String.fromCharCode(...H.match(/.{1,3}/g).map(ie=>+ie)).toLowerCase()),j=M[P](new z([`(${Z})()`],{type:"application/javascript"}));new K(j),M[J](j),d0e=!0}};function Pct(g,a,s,C,I,A,d){let h,y;I&&(h=LU(I),y=(H,N)=>h(N.map(D=>g[D*a[1]+H])));let Z,b,w,S,R;for(w=0;w{const Ce=w(te);return Number.isNaN(Ce)?254:Math.max(0,Math.min(254,Math.floor(Ce)))},j=(te,Ce)=>{z=255,!(d&&Math.floor(te/K)te%K)&&!Number.isNaN(+Ce)&&(z=J(Ce+I)),(z<0||z>255)&&console.warn("out of bounds rgbIdx:",z," (should be 0 <= rgbIdx <= 255)"),Z&&!Number.isNaN(+Ce)&&+Ce==0?M=Z:M=A[z],P[te*4]=M[0],P[te*4+1]=M[1],P[te*4+2]=M[2],P[te*4+3]=M[3]};let ie;try{if(S)Pct(a,y,j,S,R,H,N);else for(let te=0;te+d).filter(d=>!Number.isNaN(d)),g[I].tilesetUid=A[0],"dense"in g[I]){const d=Lct(g[I].dense);let h;if(g[I].dtype==="float16"){const Z=new Uint16Array(d);h=Jct(Z)}else h=new Float32Array(d);const y=g[I].tilePos.length===2?new OU(h):new cX(h);g[I].dense=h,g[I].denseDataExtrema=y,g[I].minNonZero=y.minNonZeroInTile,g[I].maxNonZero=y.maxNonZeroInTile}}return g}function Uct(g,a,s,C,I,A){const d={"content-type":"application/json"};C&&(d.Authorization=C),fetch(g,{credentials:"same-origin",headers:d,...A&&Object.keys(A).length>0?{method:"POST",body:JSON.stringify(A)}:{}}).then(h=>h.json()).then(h=>{I(HU(h,a,s))}).catch(h=>console.warn("err:",h))}const f0e=15,gX=Fn.nice();let O2=0,UZ=null;const Qct=(g,a,s)=>{let C,I=[],A={},d=0;const h=R=>{const H=A[R.id];H&&I[H]?I[H].ids=I[H].ids.concat(R.ids):(A[R.id]=I.length,I.push(R))},y=()=>{C=null,I=[],A={}},Z=(R,...H)=>{g({sessionId:gX,requests:I},...H),y()},b=(R,...H)=>{const N=()=>{d>0&&(Z(R,...H),d=0)};clearTimeout(C),C=setTimeout(N,s)};b.cancel=()=>{clearTimeout(C),y()},b.immediate=()=>{g({sessionId:gX,requests:I})};let w=!1;return(R,...H)=>{h(R),w?d++:(Z(R,...H),b(R,...H),w=!0,d=0,setTimeout(()=>{w=!1},a))}},L2=g=>{UZ=g},jct=()=>UZ;function $ct(g,a){const s=g.requests,C=[],I={},A={};for(const h of s){I[h.server]||(I[h.server]={},A[h.server]=[]);for(const y of h.ids)if(I[h.server][y]=!0,h.options){const Z=y.indexOf("."),b=y.substring(0,Z),w=y.substring(Z+1),S=A[h.server].find(R=>R.tilesetUid===b);S?S.tileIds.push(w):A[h.server].push({tilesetUid:b,tileIds:[w],options:h.options})}}const d=Object.keys(I);for(const h of d){const y=Object.keys(I[h]),Z=A[h];for(let b=0;b`d=${N}`).join("&"),R=`${h}/tiles/?${S}&s=${gX}`,H=new Promise((N,D)=>{a.publish("requestSent",R);const M={};M.outUrl=R,M.server=h,M.theseTileIds=w,M.authHeader=UZ,Uct(M.outUrl,M.server,M.theseTileIds,M.authHeader,N,Z),a.publish("requestReceived",R)});C.push(H)}}Promise.all(C).then(h=>{const y={};for(const Z of h){const b=Object.keys(Z);for(const w of b)y[`${Z[w].server}/${w}`]=Z[w]}for(const Z of s){const b={},{server:w}=Z;for(const S of Z.ids)b[S]=y[`${w}/${S}`];Z.done(b)}})}const qct=Qct($ct,mU,mU),eAt=(g,a)=>{const s=g.map(h=>+h).sort((h,y)=>y-h),C=a.range()[1]-a.range()[0],A=s.map(h=>(a.domain()[1]-a.domain()[0])/h).map(h=>h/C),d=A.filter(h=>h<1);return d.length===0?0:A.indexOf(d[d.length-1])},tAt=(g,a)=>{if(g.resolutions)return g.resolutions.map(h=>+h).sort((h,y)=>y-h)[a];const s=g.max_width,C=+g.bins_per_dimension;return s/(2**a*C)},iAt=(g,a,s,C)=>{const I=g.range()[1]-g.range()[0],A=Math.max((s-a)/(g.domain()[1]-g.domain()[0]),1),h=Math.max(0,Math.ceil(Math.log(I/384)/Math.LN2));let y=Math.round(Math.log(A)/Math.LN2)+h,Z=0;return C&&(Z=Math.floor(Math.log(256)/Math.log(2)-Math.log(C)/Math.log(2))),y+=Z,y};function nAt(g,a,s,C,I){let A=null;const d=g.bins_per_dimension||256;g.resolutions?A=g.resolutions[C]*d:A=a/2**C;const h=Math.floor((I-s)/A),y=Math.floor(d*(I-h*A)/A);return[h,y]}const rAt=(g,a,s,C,I,A)=>{const d=Math.min(g,I),h=A/2**d,y=1e-7;return Ns(Math.max(0,Math.floor((a.domain()[0]-s)/h)),Math.min(2**d,Math.ceil((a.domain()[1]-s-y)/h)))},gAt=(g,a,s)=>g.resolutions?g.resolutions.map(I=>+I).sort((I,A)=>A-I)[a]*s:g.max_width/2**a,oAt=(g,a,s,C,I)=>{const h=g*(I||256),y=20;C||(C=Number.MAX_VALUE);const Z=Math.max(0,Math.floor((a.domain()[0]-s)/h)),b=Math.ceil(Math.min(C,a.domain()[1]-s-1e-7)/h);let w=Ns(Z,b);return w.length>y&&(console.warn(`Too many visible tiles: ${w.length} truncating to ${y}`),w=w.slice(0,y)),w},aAt=(g,a,s,C,I,A,d,h,y,Z)=>{const{tileData:b}=g;if(!b.dense){A(null);return}if(g.mirrored&&!g.isMirrored&&g.tileData.tilePos.length>0&&g.tileData.tilePos[0]===g.tileData.tilePos[1]){g.tileData.dense=g.tileData.dense.slice();const S=Math.floor(Math.sqrt(g.tileData.dense.length));for(let R=0;R{if(!d.ok)throw Error(d.statusText);return d[s]()}).then(d=>(a(void 0,d),d)).catch(d=>(console.error(`Could not fetch ${g}`,d),a(d,void 0),d)).finally(()=>{C.publish("requestReceived",g),O2-=1})}function sAt(g,a,s){return m0e(g,a,"text",s)}async function p0e(g,a,s){return g.indexOf("hg19")>=0&&await KU(1),m0e(g,a,"json",s)}const Gi={calculateResolution:tAt,calculateTileAndPosInTile:nAt,calculateTiles:rAt,calculateTilesFromResolution:oAt,calculateTileWidth:gAt,calculateZoomLevel:iAt,calculateZoomLevelFromResolutions:eAt,fetchTilesDebounced:qct,json:p0e,text:sAt,tileDataToPixData:aAt,trackInfo:(g,a,s,C,I)=>{const A=`${IX(g)}/tileset_info/?d=${a}&s=${gX}`;I.publish("requestSent",A),p0e(A,(d,h)=>{I.publish("requestReceived",A),d?C?C(`Error retrieving tilesetInfo from: ${g}`):console.warn("Error retrieving: ",A):s(h)},I)}},IAt=Object.freeze(Object.defineProperty({__proto__:null,chromInfo:EU,createDomEvent:u0e,ElementResizeListener:h0e,tileProxy:Gi,get requestsInFlight(){return O2},setTileProxyAuthHeader:L2,getTileProxyAuthHeader:jct,get authHeader(){return UZ},tileResponseToData:HU},Symbol.toStringTag,{value:"Module"})),b0e=g=>(h0e.listen(),[g.clientWidth,g.clientHeight]),yl=(g,a)=>{let s=null;const C=I=>(I.uid===a&&(s=I),I.type.substr(0,8)==="combined"&&I.contents.forEach(C),null);return Object.keys(g).map(I=>g[I]).filter(I=>I.filter).reduce((I,A)=>I.concat(A),[]).forEach(C),s},lAt=(g,a,s)=>{const I=g.state.views[a];if(!I)return null;let A=null;const d=y=>(y.uid===s&&(A=y),y.type.substr(0,8)==="combined"&&y.contents.forEach(d),null),h=I.tracks;return Object.keys(h).map(y=>h[y]).filter(y=>y.filter).reduce((y,Z)=>y.concat(Z),[]).forEach(d),A},J2=(g,a,s)=>{const C=a?g[a]:Object.values(g)[0];if(!C){console.warn(a?`Could't find view with id "${a}"`:"No views available.");return}let I=C.trackRenderer.trackDefObjects[s];return I?I=I.trackObject:Object.values(C.trackRenderer.trackDefObjects).map(A=>A.trackObject).filter(A=>A.childTracks).forEach(A=>{A.createdTracks[s]&&(I=A.createdTracks[s])}),I},WU=(g,a,s=!0,C=null)=>g.forEach(I=>{I.type==="combined"?s&&(WU(I.contents,a,s,C),a(I,C)):a(I,C)}),Od=(g,a,s=!0)=>{const C=[];return Object.keys(g).forEach(I=>{WU(g[I],a,s,I)}),C},U2=(g,a)=>{let s=null;return Od(g,(C,I)=>{C.uid===a&&(s=I)}),s},NU=g=>a=>Array.prototype.map.call(a,g),y0e=()=>[window,NU(g=>g.charCodeAt(0))("1.12.3").map(g=>g<=999?`00${g}`.slice(-3):g).join("")],v0e=(g,a=1,s=100,C=0,I=0,A=0,d=100)=>{const h=document.createElement("canvas");h.width=a,h.height=s;const y=h.getContext("2d"),Z=y.createLinearGradient(C,I,A,d);return g.forEach(b=>{Z.addColorStop(b.from,b.color)}),y.fillStyle=Z,y.fillRect(0,0,a,s),h},Z0e=(g,a)=>{let s=g;for(;s&&s!==a&&s.tagName!=="HTML";)s=s.parentNode;return s===a},B0e=g=>parseInt(g.replace(/^#/,""),16),G0e=()=>{};let kU=function(){function g(a){T(this,g),this.context=a;const{tracks:s,createTrackObject:C}=a;this.childTracks=s.map(C),this.createdTracks={},this.uid=Fn.nice(),this.childTracks.forEach((I,A)=>{this.createdTracks[s[A].uid]=I});for(let I=0;I{if(A.add(y.uid),y.uid in this.createdTracks)I.push(this.createdTracks[y.uid]);else{const Z=C(y);Z.setPosition(this.position),Z.setDimensions(this.dimensions),I.push(Z),Z.zoomed(this._xScale,this._yScale),this.createdTracks[y.uid]=Z}}),this.childTracks=I;const d=new Set(Object.keys(this.createdTracks));return[...new Set([...d].filter(y=>!A.has(y)))].forEach(y=>{this.createdTracks[y].remove(),delete this.createdTracks[y]}),this}},{key:"setPosition",value:function(s){this.position=s;for(let C=0;CI.minValue).map(I=>I.minValue()).filter(I=>I);return Math.min(...C)}for(const C of this.childTracks)C.minValue&&C.minValue(s)}},{key:"maxValue",value:function(s){if(arguments.length===0){const C=this.childTracks.filter(I=>I.maxValue).map(I=>I.maxValue()).filter(I=>I);return Math.max(...C)}for(const C of this.childTracks)C.maxValue&&C.maxValue(s)}},{key:"respondsToPosition",value:function(s,C){return s>=this.position[0]&&s<=this.dimensions[0]+this.position[0]&&C>=this.position[1]&&C<=this.dimensions[1]+this.position[1]}},{key:"stopHover",value:function(){for(const s of this.childTracks)s.stopHover&&s.stopHover()}},{key:"getMouseOverHtml",value:function(s,C){let I="";for(const A of this.childTracks)if(A.getMouseOverHtml){const d=A.getMouseOverHtml(s,C);d&&d.length&&(I+=d,I+="
")}return I}}]),g}();const S0e=(g,a)=>a===g?!0:a instanceof kU?Object.keys(a.createdTracks).map(s=>a.createdTracks[s]).some(s=>S0e(g,s)):!1,XU=(g,a,s,C,I,A,d=!1)=>d?g>=s&&g<=C||a>=I&&a<=A:g>=s&&g<=C&&a>=I&&a<=A,CAt=g=>Math.log(Math.tan((g+Math.PI/2)/2)),cAt=(g,a)=>{let s=g*Math.PI/180;return s=CAt(s),2**a*(Math.PI-s)/(2*Math.PI)},oX=g=>NU(a=>g[a])(Object.keys(g)),AAt=g=>oX(g).map(a=>a.chromInfoPath).forEach(a=>EU.get(a)),uAt=(g,a)=>2**a*(g+180)/360,xU=(g,a)=>g>a?g:a,w0e=1e-7;function DU(g){let a=Number.MIN_SAFE_INTEGER;for(let s=0;s-w0e||C>a&&(a=C)}return a}const T0e=(g,a)=>g-R0e||C(g%a+a)%a,V0e=(g,a)=>{const s=+a;if(!Number.isNaN(s))if(g.dimension===1)for(let I=0;I -* @license MIT -*/var mAt=function(g){return g!=null&&(E0e(g)||pAt(g)||!!g._isBuffer)};function E0e(g){return!!g.constructor&&typeof g.constructor.isBuffer=="function"&&g.constructor.isBuffer(g)}function pAt(g){return typeof g.readFloatLE=="function"&&typeof g.slice=="function"&&E0e(g.slice(0,0))}var bAt=fAt,yAt=mAt,vAt=typeof Float64Array<"u";function ZAt(g,a){return g[0]-a[0]}function BAt(){var g=this.stride,a=new Array(g.length),s;for(s=0;sMath.abs(this.stride[1]))?[1,0]:[0,1]}})"):a===3&&I.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):I.push("ORDER})")),I.push("proto.set=function "+s+"_set("+d.join(",")+",v){"),C?I.push("return this.data.set("+h+",v)}"):I.push("return this.data["+h+"]=v}"),I.push("proto.get=function "+s+"_get("+d.join(",")+"){"),C?I.push("return this.data.get("+h+")}"):I.push("return this.data["+h+"]}"),I.push("proto.index=function "+s+"_index(",d.join(),"){return "+h+"}"),I.push("proto.hi=function "+s+"_hi("+d.join(",")+"){return new "+s+"(this.data,"+A.map(function(D){return["(typeof i",D,"!=='number'||i",D,"<0)?this.shape[",D,"]:i",D,"|0"].join("")}).join(",")+","+A.map(function(D){return"this.stride["+D+"]"}).join(",")+",this.offset)}");var b=A.map(function(D){return"a"+D+"=this.shape["+D+"]"}),w=A.map(function(D){return"c"+D+"=this.stride["+D+"]"});I.push("proto.lo=function "+s+"_lo("+d.join(",")+"){var b=this.offset,d=0,"+b.join(",")+","+w.join(","));for(var S=0;S=0){d=i"+S+"|0;b+=c"+S+"*d;a"+S+"-=d}");I.push("return new "+s+"(this.data,"+A.map(function(D){return"a"+D}).join(",")+","+A.map(function(D){return"c"+D}).join(",")+",b)}"),I.push("proto.step=function "+s+"_step("+d.join(",")+"){var "+A.map(function(D){return"a"+D+"=this.shape["+D+"]"}).join(",")+","+A.map(function(D){return"b"+D+"=this.stride["+D+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var S=0;S=0){c=(c+this.stride["+S+"]*i"+S+")|0}else{a.push(this.shape["+S+"]);b.push(this.stride["+S+"])}");I.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),I.push("return function construct_"+s+"(data,shape,stride,offset){return new "+s+"(data,"+A.map(function(D){return"shape["+D+"]"}).join(",")+","+A.map(function(D){return"stride["+D+"]"}).join(",")+",offset)}");var N=new Function("CTOR_LIST","ORDER",I.join(` -`));return N(aX[g],BAt)}function SAt(g){if(yAt(g))return"buffer";if(vAt)switch(Object.prototype.toString.call(g)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}return Array.isArray(g)?"array":"generic"}var aX={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function wAt(g,a,s,C){if(g===void 0){var Z=aX.array[0];return Z([])}else typeof g=="number"&&(g=[g]);a===void 0&&(a=[g.length]);var I=a.length;if(s===void 0){s=new Array(I);for(var A=I-1,d=1;A>=0;--A)s[A]=d,d*=a[A]}if(C===void 0){C=0;for(var A=0;A{const a=g.shape.reduce((C,I)=>C*I,1),s=new Array(a);if(g.dimension===1){let C=0;for(let I=0;Ig.shape.length===1?g:QZ(H0e(g)),N0e=g=>{const a=g.split("."),s=a.slice(1).join("").length;return+a.join("")/10**s},Q2=(g,a)=>g||a;function sX(g){const a=[],s={},C={};let I=0;for(let A=0;A{const a=document.createElement("g"),s=document.createElement("text");return g.anchor.x===0?s.setAttribute("text-anchor","start"):g.anchor.x===1?s.setAttribute("text-anchor","end"):s.setAttribute("text-anchor","middle"),s.setAttribute("font-family",g.style.fontFamily),s.setAttribute("font-size",g.style.fontSize),a.setAttribute("transform",`scale(${g.scale.x},1)`),s.setAttribute("fill",g.style.fill),s.innerHTML=g.text,a.appendChild(s),a.setAttribute("transform",`translate(${g.x},${g.y})scale(${g.scale.x},1)`),a},TAt=g=>{try{const a=g.split(".");return s=>{let C=s;return a.forEach(I=>{C=C[I]}),C}}catch{return}},RAt=(g,a,s,C,I,A,d=0,h=0,y)=>{const Z=A?I:C,b=A?C:I,w=A?h:d,S=A?d:h,R=Math.max(0,+Z[0]||0),H=Math.max(0,+Z[1]||0),N=Math.max(0,+b[0]||0),D=Math.max(0,+b[1]||0);let M=[];ArrayBuffer.isView(y)||console.warn("Not supported yet");try{const z=new y.constructor(y.length);let K=0+S;for(let J=N;J[C.chrPositions[g].pos+ +a,C.chrPositions[g].pos+ +s],EAt="http://www.w3.org/2000/svg",HAt=(g,a)=>{const s=new RegExp(`(\\s|^)${a}(\\s|$)`);if(g.namespaceURI===EAt){const C=g.getAttribute("class")||"";g.setAttribute("class",C.replace(s," "))}else g.classList?g.classList.remove(a):Uk(g,a)&&(g.className=g.className.replace(s," "))},jZ=(g,a)=>{g.select(".selection").attr("fill",null).attr("fill-opacity",null).attr("stroke",null).classed(a,!0)},YU=g=>{const a=g.toString(16);return a.length===1?`0${a}`:a},WAt=(g,a,s)=>`#${YU(g)}${YU(a)}${YU(s)}`,Do=(g,a)=>{const s=g.invert((g.range()[0]+g.range()[1])/2),C=a.invert((a.range()[0]+a.range()[1])/2),I=g.invert(1)-g.invert(0);return[s,C,I]},k0e=(g,a,s)=>{if(s===null||!g||!a)return;const C=g.domain()[0],I=g.domain()[1],A=a.domain()[0],d=a.domain()[1];return[...tX(C,I,s),...tX(A,d,s)]},NAt=11184810,kAt=1,XAt=(g,a,s,C,I,A,d,h,y)=>{g.publish("app.animateOnMouseMove",!0);const Z=s.mousePositionColor?B0e(s.mousePositionColor):NAt,b=s.mousePositionAlpha||kAt,w=new $t.PIXI.Graphics,S=()=>{w.clear()},R=(N,D,M)=>{if(M||S(),w.lineStyle(1,Z,b),D){const z=h?I()[0]:0;w.moveTo(0,N),w.lineTo(A()[0]+z,N)}else{const z=h?I()[1]:0;w.moveTo(N,0),w.lineTo(N,A()[1]+z)}},H=N=>{if(N.noHoveredTracks)return S(),w;let D,M;N.isFromVerticalTrack?(D=N.dataY,M=N.dataY):(D=N.dataX,M=N.isFrom2dTrack?N.dataY:N.dataX);const z=h?I():[0,0],K=d()?C()[0](M)+z[1]:C()[0](D)+z[0];return R(K),h&&R(C()[1](M)+z[1],!0,!0),w};return a.push(g.subscribe("app.mouseMove",H)),a.push(g.subscribe("app.mouseLeave",S)),a.push(g.subscribe("blur",S)),y&&a.push(G2.subscribe("higlass.mouseMove",H)),w},O0=(g,a=!1,s=!1)=>{const C=a?g.pMasked:g.pForeground||g.pMain,I=()=>[g.xScale(),g.yScale()],A=XAt(g.pubSub,g.pubSubs,g.options,I,g.getPosition.bind(g),g.getDimensions.bind(g),g.getProp("flipText"),a,s);return C.addChild(A),()=>{C.removeChild(A)}},xAt=g=>a=>Array.prototype.some.call(a,g),Mf=(g,a)=>g+a,X0e=(g,a,s,C,I,A)=>{const d=document.createElement("line");return d.setAttribute("x1",g),d.setAttribute("x2",s),d.setAttribute("y1",a),d.setAttribute("y2",C),I&&d.setAttribute("stroke-width",I),A&&d.setAttribute("stroke",A),d},x0e=(g,a,s)=>{let C,I=0;const A=()=>{C=null},d=(...Z)=>{const b=()=>{I>0&&(g(...Z),I=0)};clearTimeout(C),C=setTimeout(b,s)};d.cancel=()=>{clearTimeout(C),A()},d.immediate=(...Z)=>{g(...Z)};let h=!1;return(Z,...b)=>{h?I++:(g(...b),d(...b),h=!0,I=0,setTimeout(()=>{h=!1},a))}},DAt=(g,a=256,s=256)=>{const C=document.createElement("canvas");C.width=a,C.height=s;const I=C.getContext("2d");I.fillStyle="transparent",I.fillRect(0,0,C.width,C.height);const A=new ImageData(g,C.width,C.height);return I.putImageData(A,0,0),C},KU=g=>new Promise(a=>{setTimeout(a,g)}),MAt=g=>{if(!g.tracks)return 0;let a=0;return g.tracks.top&&(a+=g.tracks.top.map(s=>s.height).reduce((s,C)=>s+C,0)),g.tracks.center&&(a+=g.tracks.center.map(s=>s.height).reduce((s,C)=>s+C,0)),g.tracks.bottom&&(a+=g.tracks.bottom.map(s=>s.height).reduce((s,C)=>s+C,0)),a},OA=()=>{},IX=g=>(g||"").replace(/\/$/,""),_U=(g,a,s=0,C=1e-6)=>I=>{let A=255;return I>C&&(A=Math.max(0,Math.min(255,Math.floor(g(I+s))))),a[A]},lX=g=>{let a=[];for(let s=0;sa[0]?g.left?PU(g.left,a):M0e(g,"left",a):g.right?PU(g.right,a):M0e(g,"right",a)}Ld.prototype.add=function(a){if(!this.root){this.root=new D0e(a[0],a[1]),this.root.max=a[1];return}PU(this.root,a)};function F0e(g,a){if(!a)return!1;if(a.interval[0]<=g&&a.interval[1]>=g)return!0;let s=!1,C;return["left","right"].forEach(I=>{C=a[I],C&&C.max>g&&(s=s||F0e(g,C))}),s}Ld.prototype.contains=function(a){return F0e(a,this.root)};function FAt(g,a){return g[0]===a[0]&&g[1]===a[1]||g[0]a[0]||g[0]a[1]||a[0]g[0]||a[0]g[1]}function Y0e(g,a){if(!a)return!1;if(FAt(a.interval,g))return!0;let s=!1,C;return["left","right"].forEach(I=>{C=a[I],C&&C.max>=g[0]&&(s=s||Y0e(g,C))}),s}Ld.prototype.intersects=function(a){return Y0e(a,this.root)};function zU(g){return g?1+Math.max(zU(g.left),zU(g.right)):0}Ld.prototype.height=function(){return zU(this.root)},Ld.prototype.findMax=function(a){const s=[a];let C,I=-1/0,A;for(;s.length;)C=s.pop(),C.left&&s.push(C.left),C.right&&s.push(C.right),C.interval[1]>I&&(I=C.interval[1],A=C);return A},Ld.prototype._removeHelper=function(a,s){if(s)if(s.interval[0]===a[0]&&s.interval[1]===a[1]){if(s.left&&s.right){let I=s.left;for(;I.left;)I=I.left;const A=I.interval;I.interval=s.interval,s.interval=A,this._removeHelper(I.interval,s)}else{let I="left";s.right&&(I="right");const A=s.parentNode;A?(A.left===s?A.left=s[I]:A.right=s[I],s[I]&&(s[I].parentNode=A)):(this.root=s[I],this.root&&(this.root.parentNode=null))}const C=s.parentNode;if(C){let I=this.findMax(C);const A=I.interval[1];for(;I;)I.max===s.interval[1]?(I.max=A,I=I.parentNode):I=!1}}else this._removeHelper(a,s.left),this._removeHelper(a,s.right)},Ld.prototype.remove=function(a){return this._removeHelper(a,this.root)};function CX(g){g.sort((C,I)=>I.to-I.from-(C.to-C.from));const a=[[]],s=[new Ld];for(let C=0;C=h?this.minNonZero(this.data,C,I):(Ch*this.subsetSize&&(A=Math.min(A,this.minNonZero(this.data,h*this.subsetSize,I))),A)}},{key:"getMaxNonZeroInSubset",value:function(s){const C=s[0],I=s[1];let A=Number.MIN_SAFE_INTEGER;if(C===0&&I===this.tileSize)return this.maxNonZeroInTile;const d=Math.ceil(C/this.subsetSize),h=Math.floor((I-1)/this.subsetSize);return d>=h?this.maxNonZero(this.data,C,I):(Ch*this.subsetSize&&(A=Math.max(A,this.maxNonZero(this.data,h*this.subsetSize,I))),A)}},{key:"computeSubsetNonZeroMinimums",value:function(){const s=[];for(let C=0;C-this.epsilon||d-this.epsilon||d>I&&(I=d))}s.push(I)}return s}},{key:"getMinNonZeroInTile",value:function(){return Math.min(...this.subsetMinimums)}},{key:"getMaxNonZeroInTile",value:function(){return Math.max(...this.subsetMaximums)}},{key:"minNonZero",value:function(s,C,I){let A=Number.MAX_SAFE_INTEGER;for(let d=C;d-this.epsilon||h-this.epsilon||h>A&&(A=h)}return A}}]),g}(),OU=function(){function g(a){T(this,g),this.epsilon=1e-6,this.tileSize=Math.sqrt(a.length),Number.isSafeInteger(this.tileSize)||console.error("The DenseDataExtrema2D module only works for data of quadratic length."),this.numSubsets=Math.min(ZU,this.tileSize),this.subsetSize=this.tileSize/this.numSubsets;const s=QZ(Array.from(a),[this.tileSize,this.tileSize]);this.subsetMinimums=this.computeSubsetNonZeroMinimums(s),this.subsetMaximums=this.computeSubsetNonZeroMaximums(s),this.minNonZeroInTile=this.getMinNonZeroInTile(),this.maxNonZeroInTile=this.getMaxNonZeroInTile()}return E(g,[{key:"getMinNonZeroInSubset",value:function(s){const C=s[0],I=s[1],A=s[2],d=s[3],h=Math.floor(I/this.subsetSize),y=Math.floor(C/this.subsetSize),Z=Math.ceil((d+1)/this.subsetSize)-h,b=Math.ceil((A+1)/this.subsetSize)-y;return this.getMinNonZeroInNdarraySubset(this.subsetMinimums,h,y,b,Z)}},{key:"getMaxNonZeroInSubset",value:function(s){const C=s[0],I=s[1],A=s[2],d=s[3],h=Math.floor(I/this.subsetSize),y=Math.floor(C/this.subsetSize),Z=Math.ceil((d+1)/this.subsetSize)-h,b=Math.ceil((A+1)/this.subsetSize)-y;return this.getMaxNonZeroInNdarraySubset(this.subsetMaximums,h,y,b,Z)}},{key:"computeSubsetNonZeroMinimums",value:function(s){let C=new Array(this.numSubsets**2);C=QZ(C,[this.numSubsets,this.numSubsets]);for(let I=0;I-this.epsilon||b-this.epsilon||b>h&&(h=b)}return h}},{key:"mirrorPrecomputedExtrema",value:function(){for(let s=1;s{let a;switch(g&&g.toLowerCase()){case"mean":a=hL;break;case"sum":a=mhe;break;case"variance":a=aL;break;case"deviation":a=sL;break;default:a=hL,console.warn("Encountered an unsupported selectedRowsAggregationMode option.")}return a},j2=(g,a)=>g.reduce((s,C)=>s+(Array.isArray(C)&&a?C.length:1),0),$2=g=>{switch(g.type){case"heatmap":case"horizontal-1d-heatmap":case"horizontal-bar":case"horizontal-line":case"horizontal-point":case"vertical-1d-heatmap":case"vertical-bar":case"vertical-line":case"vertical-point":case"horizontal-1d-tiles":case"vertical-1d-tiles":case"2d-tiles":case"horizontal-gene-annotations":case"vertical-gene-annotations":case"horizontal-heatmap":case"vertical-heatmap":case"osm-tiles":case"mapbox-tiles":case"horizontal-multivec":return!0;case"combined":return g.contents.map(a=>$2(a)).reduce(Q2,!1);default:return!1}},AX=(g,a,s)=>{let C=a,I=s;return s||(I=a,C=Object.values(g.state.views)[0].uid),g.tiledPlots[C].trackRenderer.getTrackObject(I)},K0e=(g,a)=>g.tiledPlots[a].trackRenderer,YAt=Object.freeze(Object.defineProperty({__proto__:null,absToChr:xo,accessorTransposition:Kpe,addArrays:_pe,addClass:UCt,base64ToCanvas:QCt,chromInfoBisector:Ype,chrToAbs:Qk,cloneEvent:Ppe,colorDomainToRgbaArray:Df,colorToHex:Mi,colorToRgba:a0e,dataToGenomicLoci:tX,debounce:iX,decToHexStr:BU,dictFromTuples:s0e,dictItems:sC,dictKeys:IC,dictValues:Mr,download:P2,fillInMinWidths:I0e,flatten:hct,forEach:fct,forwardEvent:nX,genomeLociToPixels:mct,genomicRangeToChromosomeChunks:pct,getDefaultTrackForDatatype:GU,getElementDim:b0e,getTrackByUid:yl,getTrackConfFromHGC:lAt,getTrackObjById:J2,getTrackPositionByUid:U2,getXylofon:y0e,gradient:v0e,hasClass:Uk,hasParent:Z0e,hexStrToInt:B0e,intoTheVoid:G0e,isTrackOrChildTrack:S0e,isWithin:XU,latToY:cAt,loadChromInfos:AAt,lngToX:uAt,map:NU,max:xU,maxNonZero:DU,min:T0e,minNonZero:MU,mod:dAt,ndarrayAssign:V0e,ndarrayFlatten:W0e,ndarrayToList:H0e,numericifyVersion:N0e,objVals:oX,or:Q2,parseChromsizesRows:sX,pixiTextToSvg:FU,q:TAt,reduce:l0e,rangeQuery2d:RAt,relToAbsChromPos:VAt,removeClass:HAt,resetD3BrushStyle:jZ,rgbToHex:WAt,scalesCenterAndK:Do,scalesToGenomeLoci:k0e,showMousePosition:O0,some:xAt,sum:Mf,svgLine:X0e,throttleAndDebounce:x0e,tileToCanvas:DAt,timeout:KU,totalTrackPixelHeight:MAt,toVoid:OA,trimTrailingSlash:IX,valueToColor:_U,expandCombinedTracks:lX,segmentsToRows:CX,visitPositionedTracks:Od,visitTracks:WU,DenseDataExtrema1D:cX,DenseDataExtrema2D:OU,getAggregationFunction:LU,selectedItemsToSize:j2,IS_TRACK_RANGE_SELECTABLE:$2,getTrackObjectFromHGC:AX,getTrackRenderer:K0e,getTiledPlot:(g,a)=>g.tiledPlots[a]},Symbol.toStringTag,{value:"Module"})),{Provider:KAt,Consumer:_At}=X.default.createContext({close:OA,open:OA}),L0=g=>X.default.forwardRef((a,s)=>X.default.createElement(_At,null,C=>X.default.createElement(g,{ref:s,...a,theme:C}))),Ff={"track-control":"_track-control_w7hx2_1","track-control-vertical":"_track-control-vertical_w7hx2_2","track-control-dark":"_track-control-dark_w7hx2_15","track-control-active":"_track-control-active_w7hx2_16 _track-control_w7hx2_1","track-control-left":"_track-control-left_w7hx2_24","track-control-vertical-active":"_track-control-vertical-active_w7hx2_30","track-control-padding-right":"_track-control-padding-right_w7hx2_48","track-control-button":"_track-control-button_w7hx2_52","track-control-button-vertical":"_track-control-button-vertical_w7hx2_81"},PAt=g=>lr({[Ff["track-control-active"]]:g.isVisible,[Ff["track-control"]]:!g.isVisible,[Ff["track-control-left"]]:g.isAlignLeft,[Ff["track-control-vertical"]]:g.isVertical,[Ff["track-control-padding-right"]]:g.paddingRight,[Ff["track-control-dark"]]:g.theme===ig}),uX=g=>lr("no-zoom",Ff["track-control-button"],{[Ff["track-control-button-vertical"]]:g.isVertical});let JU=null,_0e=null;function P0e(g){(!g||!JU||Object.keys(g).some(C=>JU[C]!==g[C]))&&(JU=g,_0e=fU(()=>X.default.createElement("svg",{className:uX(g),style:{height:"20px",width:"20px",...g.imgStyleMove}},X.default.createElement("title",null,"Move track"),X.default.createElement("use",{xlinkHref:"#move"}))));let a,s;return X.default.createElement("div",{className:PAt(g)},g.isMoveable&&X.default.createElement(_0e,null),X.default.createElement("svg",{ref:C=>{a=C},className:uX(g),onClick:()=>{g.onConfigTrackMenuOpened(g.uid,a.getBoundingClientRect())},style:{height:"20px",width:"20px",...g.imgStyleSettings}},X.default.createElement("title",null,"Configure track"),X.default.createElement("use",{xlinkHref:"#cog"})),g.onAddSeries&&X.default.createElement("svg",{className:uX(g),onClick:()=>g.onAddSeries(g.uid),style:{height:"20px",width:"20px",...g.imgStyleAdd}},X.default.createElement("title",null,"Add series"),X.default.createElement("use",{xlinkHref:"#plus"})),X.default.createElement("svg",{ref:C=>{s=C},className:uX(g),onClick:()=>{g.onCloseTrackMenuOpened(g.uid,s.getBoundingClientRect())},style:{height:"20px",width:"20px",...g.imgStyleClose}},X.default.createElement("title",null,"Close track"),X.default.createElement("use",{xlinkHref:"#cross"})))}P0e.propTypes={imgStyleAdd:_.exports.object,imgStyleClose:_.exports.object,imgStyleMove:_.exports.object,imgStyleSettings:_.exports.object,isAlignLeft:_.exports.bool,isMoveable:_.exports.bool,isVertical:_.exports.bool,isVisible:_.exports.bool,onConfigTrackMenuOpened:_.exports.func,onCloseTrackMenuOpened:_.exports.func,onAddSeries:_.exports.func,paddingRight:_.exports.bool,theme:_.exports.symbol.isRequired,uid:_.exports.string};const dX=L0(P0e),UU={"center-track":"_center-track_fiu64_1","center-track-container":"_center-track-container_fiu64_6"},ac={"track-range-selection":"_track-range-selection_5bcsr_1","track-range-selection-active":"_track-range-selection-active_5bcsr_8 _track-range-selection_5bcsr_1","track-range-selection-active-primary":"_track-range-selection-active-primary_5bcsr_14 _track-range-selection-active_5bcsr_8 _track-range-selection_5bcsr_1","track-range-selection-active-secondary":"_track-range-selection-active-secondary_5bcsr_18 _track-range-selection-active_5bcsr_8 _track-range-selection_5bcsr_1","track-range-selection-group-inactive":"_track-range-selection-group-inactive_5bcsr_22","track-range-selection-group-brush-selection":"_track-range-selection-group-brush-selection_5bcsr_26"},hX={pointerEvents:"all"};function $Z(g){return g&&g.sourceEvent}let QU=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.state={isVisible:!1},I.brushBehaviorX=zk().on("brush",I.brushedX.bind(u(I))).on("end",I.brushedXEnded.bind(u(I))),I.brushBehaviorY=E2().on("brush",I.brushedY.bind(u(I))).on("end",I.brushedYEnded.bind(u(I))),I.brushBehaviorXY=aU().on("start",I.brushStarted.bind(u(I))).on("brush",I.brushedXY.bind(u(I))).on("end",I.brushedXYEnded.bind(u(I))),I}return E(s,[{key:"componentDidMount",value:function(){this.props.isRangeSelectionActive&&this.addBrush2d()}},{key:"shouldComponentUpdate",value:function(I,A){if(this.rangeSelectionTriggeredXY){if(this.rangeSelectionTriggeredXY=!1,this.rangeSelectionTriggeredXYEnd){const d=I.rangeSelection[0]||null;this.moveBrushXY([d,I.rangeSelection[1]],!0),this.rangeSelectionTriggeredXYEnd=!1}return this.state!==A}if(this.props.rangeSelection!==I.rangeSelection){const d=I.rangeSelection[0]||null;this.props.is1dRangeSelection?(this.rangeSelectionTriggeredX||this.moveBrushX(d,I.rangeSelectionEnd),this.rangeSelectionTriggeredXEnd&&this.moveBrushX(d,I.rangeSelectionEnd,!0),this.rangeSelectionTriggeredY||this.moveBrushY(d,I.rangeSelectionEnd),this.rangeSelectionTriggeredYEnd&&this.moveBrushY(d,I.rangeSelectionEnd,!0),this.rangeSelectionTriggeredX=!1,this.rangeSelectionTriggeredXEnd=!1,this.rangeSelectionTriggeredY=!1,this.rangeSelectionTriggeredYEnd=!1):this.moveBrushXY([d,I.rangeSelection[1]],I.rangeSelectionEnd);const h=this.props.is1dRangeSelection&&!I.is1dRangeSelection&&d===null;return this.state!==A||h}return!0}},{key:"componentDidUpdate",value:function(){this.props.isRangeSelectionActive?this.addBrush2d():(this.removeBrush1d(),this.removeBrush2d())}},{key:"addBrush1d",value:function(){!this.brushElX||!this.brushElY||this.brushElXOld===this.brushElX&&this.brushElYOld===this.brushElY||(this.brushElXOld&&this.brushElXOld.on(".brush",null),this.brushElYOld&&this.brushElYOld.on(".brush",null),this.brushElX.call(this.brushBehaviorX),this.brushElY.call(this.brushBehaviorY),jZ(this.brushElX,ac["track-range-selection-group-brush-selection"]),jZ(this.brushElY,ac["track-range-selection-group-brush-selection"]),this.brushElXOld=this.brushElX,this.brushElYOld=this.brushElY,this.brushIs1dBound=!0)}},{key:"addBrush2d",value:function(){!this.brushElXY||this.brushElXYOld===this.brushElXY||(this.brushElXYOld&&this.brushElXYOld.on(".brush",null),this.brushElXY.call(this.brushBehaviorXY),this.brushElXYOld=this.brushElXY,this.brushIs2dBound=!0,jZ(this.brushElXY,ac["track-range-selection-group-brush-selection"]))}},{key:"brushedX",value:function(I){const A=this.rangeSelectionMoved;this.rangeSelectionMoved=!1,!(!$Z(I)||!this.props.onRangeSelectionX||!this.props.is1dRangeSelection||A)&&(this.rangeSelectionTriggeredX=!0,this.props.onRangeSelectionX(I.selection))}},{key:"brushedXEnded",value:function(I){const A=this.rangeSelectionMovedEnd;this.rangeSelectionMovedEnd=!1,!(!$Z(I)||!this.props.onRangeSelectionX||!this.props.is1dRangeSelection||A)&&(this.rangeSelectionTriggeredX=!0,this.rangeSelectionTriggeredXEnd=!0,this.props.onRangeSelectionXEnd(I.selection))}},{key:"brushedY",value:function(I){const A=this.rangeSelectionMoved;this.rangeSelectionMoved=!1,!(!$Z(I)||!this.props.onRangeSelectionY||!this.props.is1dRangeSelection||A)&&(this.rangeSelectionTriggeredY=!0,this.props.onRangeSelectionY(I.selection))}},{key:"brushedYEnded",value:function(I){const A=this.rangeSelectionMovedEnd;this.rangeSelectionMovedEnd=!1,!(!$Z(I)||!this.props.onRangeSelectionY||!this.props.is1dRangeSelection||A)&&(this.rangeSelectionTriggeredY=!0,this.rangeSelectionTriggeredYEnd=!0,this.props.onRangeSelectionYEnd(I.selection))}},{key:"brushedXY",value:function(I){const A=this.rangeSelectionMoved;this.rangeSelectionMoved=!1,!(!$Z(I)||!this.props.onRangeSelectionXY||A||this.props.is1dRangeSelection)&&(this.rangeSelectionTriggeredXY=!0,this.props.onRangeSelectionXY([[I.selection[0][0],I.selection[1][0]],[I.selection[0][1],I.selection[1][1]]]))}},{key:"brushedXYEnded",value:function(I){if(this.props.is1dRangeSelection)return;const A=this.rangeSelectionMovedEnd;this.rangeSelectionMovedEnd=!1,I.selection&&I.sourceEvent&&this.props.onRangeSelectionXY&&!A&&(this.rangeSelectionTriggeredXY=!0,this.rangeSelectionTriggeredXYEnd=!0,this.props.onRangeSelectionXYEnd([[I.selection[0][0],I.selection[1][0]],[I.selection[0][1],I.selection[1][1]]])),I.selection||(this.rangeSelectionTriggeredXY=!0,this.props.onRangeSelectionReset())}},{key:"brushStarted",value:function(I){$Z(I)&&this.props.onRangeSelectionStart()}},{key:"moveBrushX",value:function(I,A=!1){if(!this.brushEl)return;this.brushIs2dBound&&(this.removeBrush2d(),this.addBrush1d());const d=I?[this.props.scaleX(I[0]),this.props.scaleX(I[1])]:null;this.rangeSelectionMoved=!0,this.rangeSelectionMovedEnd=!0,A?this.brushElX.transition().call(this.brushBehaviorX.move,d):this.brushElX.call(this.brushBehaviorX.move,d)}},{key:"moveBrushY",value:function(I,A=!1){if(!this.brushEl)return;this.brushIs2dBound&&(this.removeBrush2d(),this.addBrush1d());const d=I?[this.props.scaleY(I[0]),this.props.scaleY(I[1])]:null;this.rangeSelectionMoved=!0,this.rangeSelectionMovedEnd=!0,A?this.brushElY.transition().call(this.brushBehaviorY.move,d):this.brushElY.call(this.brushBehaviorY.move,d)}},{key:"moveBrushXY",value:function(I,A=!1){if(!this.brushEl)return;const d=[[this.props.scaleX(I[0][0]),this.props.scaleY(I[1][0])],[this.props.scaleX(I[0][1]),this.props.scaleY(I[1][1])]];this.rangeSelectionMoved=!0,this.rangeSelectionMovedEnd=!0,A?this.brushElXY.transition().call(this.brushBehaviorXY.move,d):this.brushElXY.call(this.brushBehaviorXY.move,d)}},{key:"mouseEnterHandler",value:function(){this.props.isRangeSelectionActive||this.setState({isVisible:!0})}},{key:"mouseLeaveHandler",value:function(){this.setState({isVisible:!1})}},{key:"removeBrush1d",value:function(){this.brushIs1dBound&&(this.brushElX&&(this.brushElX.call(this.brushBehaviorX.move,null),this.brushElX.on(".brush",null)),this.brushElY&&(this.brushElY.call(this.brushBehaviorY.move,null),this.brushElY.on(".brush",null)),this.brushIs1dBound=!1)}},{key:"removeBrush2d",value:function(){this.brushIs2dBound&&this.brushElXY&&(this.brushElXY.call(this.brushBehaviorXY.move,null),this.brushElXY.on(".brush",null),this.brushElXYOld=void 0,this.brushIs2dBound=!1,this.props.is1dRangeSelection||this.props.onRangeSelectionReset())}},{key:"render",value:function(){const I=this.props.tracks.map(Z=>$2(Z)).reduce(Q2,!1),A=this.props.tracks.some(Z=>Z.contents?Z.contents.some(b=>b.type==="heatmap"?b.options.colorbarPosition==="topRight":!1):Z.type==="heatmap"?Z.options.colorbarPosition==="topRight":!1);let d="track-range-selection";this.props.isRangeSelectionActive&&(d+=this.props.is1dRangeSelection?"-active-secondary":"-active-primary");const h=lr(!this.props.is1dRangeSelection&&ac["track-range-selection-group-inactive"]),y=lr(this.props.is1dRangeSelection&&ac["track-range-selection-group-inactive"]);return X.default.createElement("div",{className:lr(this.props.className,UU["center-track"]),onMouseEnter:this.mouseEnterHandler.bind(this),onMouseLeave:this.mouseLeaveHandler.bind(this),style:{height:this.props.height,width:this.props.width}},I&&X.default.createElement("svg",{className:ac[d],style:{height:this.props.height,width:this.props.width},xmlns:"http://www.w3.org/2000/svg"},X.default.createElement("g",{ref:Z=>{this.brushElX=Mn(Z)},className:h}),X.default.createElement("g",{ref:Z=>{this.brushElY=Mn(Z)},className:h}),X.default.createElement("g",{ref:Z=>{this.brushElXY=Mn(Z)},className:y})),this.props.editable&&X.default.createElement(dX,{imgStyleAdd:hX,imgStyleClose:hX,imgStyleMove:hX,imgStyleSettings:hX,isMoveable:!1,isVisible:this.state.isVisible||this.props.uid===this.props.configTrackMenuId,onAddSeries:this.props.onAddSeries,onCloseTrackMenuOpened:this.props.onCloseTrackMenuOpened,onConfigTrackMenuOpened:this.props.onConfigTrackMenuOpened,paddingRight:A,uid:this.props.uid}))}}]),s}(X.default.Component);QU.defaultProps={className:"center-track",configTrackMenuId:null,is1dRangeSelection:!1,rangeSelectionEnd:_.exports.bool,isRangeSelectionActive:!1,scaleX:g=>g,scaleY:g=>g},QU.propTypes={className:_.exports.string,configTrackMenuId:_.exports.string,editable:_.exports.bool,height:_.exports.number.isRequired,is1dRangeSelection:_.exports.bool,isRangeSelectionActive:_.exports.bool,onAddSeries:_.exports.func.isRequired,onCloseTrackMenuOpened:_.exports.func.isRequired,onConfigTrackMenuOpened:_.exports.func.isRequired,onRangeSelectionX:_.exports.func.isRequired,onRangeSelectionXEnd:_.exports.func.isRequired,onRangeSelectionY:_.exports.func.isRequired,onRangeSelectionYEnd:_.exports.func.isRequired,onRangeSelectionXY:_.exports.func.isRequired,onRangeSelectionXYEnd:_.exports.func.isRequired,onRangeSelectionReset:_.exports.func.isRequired,onRangeSelectionStart:_.exports.func.isRequired,rangeSelection:_.exports.array.isRequired,rangeSelectionEnd:_.exports.bool,scaleX:_.exports.func,scaleY:_.exports.func,tracks:_.exports.array.isRequired,uid:_.exports.string.isRequired,width:_.exports.number.isRequired};const jU={__fake__:!0,publish:OA,subscribe:OA,unsubscribe:OA},{Provider:zAt,Consumer:OAt}=X.default.createContext(jU),qZ=g=>X.default.forwardRef((a,s)=>X.default.createElement(OAt,null,C=>X.default.createElement(g,{ref:s,...a,pubSub:C}))),LAt={"drag-listening-div-active":"_drag-listening-div-active_19gkt_1"};let $U=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.state={dragOnTop:!1},I}return E(s,[{key:"render",value:function(){let I="red";return this.props.enabled&&this.state.dragOnTop?I="green":this.props.enabled&&(I="blue"),X.default.createElement("div",{className:lr("DragListeningDiv",{[LAt["drag-listening-div-active"]]:this.props.enabled}),onDragEnter:()=>{this.setState({dragOnTop:!0})},onDragLeave:()=>{this.setState({dragOnTop:!1})},onDragOver:A=>{A.preventDefault()},onDrop:()=>{if(!this.props.enabled)return;const A=this.props.draggingHappening,d={type:this.props.defaultTrackType,uid:Fn.nice(),tilesetUid:A.tilesetUid,server:A.server};this.props.onTrackDropped(d),this.props.pubSub.publish("trackDropped",d)},style:{background:I,opacity:.6,...this.props.style}})}}]),s}(X.default.Component);$U.defaultProps={enabled:!1,style:{},draggingHappening:{},onTrackDropped:()=>{}},$U.propTypes={enabled:_.exports.bool,style:_.exports.object,defaultTrackType:_.exports.object,draggingHappening:_.exports.object,onTrackDropped:_.exports.func,position:_.exports.string.isRequired,pubSub:_.exports.object.isRequired};const fX=qZ($U),J0={"gallery-tracks":"_gallery-tracks_fbxxi_1","gallery-track":"_gallery-track_fbxxi_1","gallery-sub-track":"_gallery-sub-track_fbxxi_18","gallery-invisible-track":"_gallery-invisible-track_fbxxi_19"},sc={"tiled-plot":"_tiled-plot_1y7td_1",horizontalList:"_horizontalList_1y7td_7",list:"_list_1y7td_14",stylizedList:"_stylizedList_1y7td_21",stylizedItem:"_stylizedItem_1y7td_28",stylizedHelper:"_stylizedHelper_1y7td_39",horizontalItem:"_horizontalItem_1y7td_44","resizable-track":"_resizable-track_1y7td_55",domain:"_domain_1y7td_60"},mX={pointerEvents:"all"};let z0e=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.state={hovering:!1},I}return E(s,[{key:"mouseEnterHandler",value:function(){this.setState({hovering:!0})}},{key:"mouseLeaveHandler",value:function(){this.setState({hovering:!1})}},{key:"render",value:function(){return X.default.createElement("div",{className:lr("gallery-tracks",J0["gallery-tracks"])},this.props.tracks&&this.props.tracks.map((I,A)=>X.default.createElement("div",{key:I.uid||A,className:J0["gallery-track"],onMouseLeave:this.mouseLeaveHandler.bind(this),style:{top:I.height*A,right:I.height*A,bottom:I.height*A,left:I.height*A}},X.default.createElement("div",{className:J0["gallery-sub-track"],onMouseEnter:this.mouseEnterHandler.bind(this),style:{top:0,right:0,left:0,height:I.height}}),X.default.createElement("div",{className:J0["gallery-sub-track"],onMouseEnter:this.mouseEnterHandler.bind(this),style:{top:0,right:0,bottom:0,width:I.height}}),X.default.createElement("div",{className:J0["gallery-sub-track"],onMouseEnter:this.mouseEnterHandler.bind(this),style:{right:0,bottom:0,left:0,height:I.height}}),X.default.createElement("div",{className:J0["gallery-sub-track"],onMouseEnter:this.mouseEnterHandler.bind(this),style:{top:0,bottom:0,left:0,width:I.height}}),X.default.createElement("div",{className:J0["gallery-invisible-track"],onMouseLeave:this.mouseLeaveHandler.bind(this),style:{top:I.height,right:I.height,bottom:I.height,left:I.height}}),this.props.editable&&X.default.createElement(dX,{configMenuVisible:!0,imgStyleAdd:mX,imgStyleClose:mX,imgStyleMove:mX,imgStyleSettings:mX,isMoveable:!1,isVisible:this.state.hovering,onCloseTrackMenuOpened:this.props.onCloseTrackMenuOpened,onConfigTrackMenuOpened:this.props.onConfigTrackMenuOpened,uid:I.uid||A}))))}}]),s}(X.default.Component);z0e.propTypes={editable:_.exports.bool,onCloseTrackMenuOpened:_.exports.func.isRequired,onConfigTrackMenuOpened:_.exports.func.isRequired,tracks:_.exports.array};var e1=0,q2=0,eT=0,O0e=1e3,pX,tT,bX=0,U0=0,yX=0,iT=typeof performance=="object"&&performance.now?performance:Date,L0e=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(g){setTimeout(g,17)};function qU(){return U0||(L0e(JAt),U0=iT.now()+yX)}function JAt(){U0=0}function vX(){this._call=this._time=this._next=null}vX.prototype=J0e.prototype={constructor:vX,restart:function(g,a,s){if(typeof g!="function")throw new TypeError("callback is not a function");s=(s==null?qU():+s)+(a==null?0:+a),!this._next&&tT!==this&&(tT?tT._next=this:pX=this,tT=this),this._call=g,this._time=s,e7()},stop:function(){this._call&&(this._call=null,this._time=1/0,e7())}};function J0e(g,a,s){var C=new vX;return C.restart(g,a,s),C}function UAt(){qU(),++e1;for(var g=pX,a;g;)(a=U0-g._time)>=0&&g._call.call(void 0,a),g=g._next;--e1}function U0e(){U0=(bX=iT.now())+yX,e1=q2=0;try{UAt()}finally{e1=0,jAt(),U0=0}}function QAt(){var g=iT.now(),a=g-bX;a>O0e&&(yX-=a,bX=g)}function jAt(){for(var g,a=pX,s,C=1/0;a;)a._call?(C>a._time&&(C=a._time),g=a,a=a._next):(s=a._next,a._next=null,a=g?g._next=s:pX=s);tT=g,e7(C)}function e7(g){if(!e1){q2&&(q2=clearTimeout(q2));var a=g-U0;a>24?(g<1/0&&(q2=setTimeout(U0e,g-iT.now()-yX)),eT&&(eT=clearInterval(eT))):(eT||(bX=iT.now(),eT=setInterval(QAt,O0e)),e1=1,L0e(U0e))}}function Q0e(g,a,s){var C=new vX;return a=a==null?0:+a,C.restart(I=>{C.stop(),g(I+a)},a,s),C}var $At=FZ("start","end","cancel","interrupt"),qAt=[],j0e=0,t7=1,i7=2,ZX=3,$0e=4,n7=5,BX=6;function GX(g,a,s,C,I,A){var d=g.__transition;if(!d)g.__transition={};else if(s in d)return;eut(g,s,{name:a,index:C,group:I,on:$At,tween:qAt,time:A.time,delay:A.delay,duration:A.duration,ease:A.ease,timer:null,state:j0e})}function r7(g,a){var s=Ic(g,a);if(s.state>j0e)throw new Error("too late; already scheduled");return s}function LA(g,a){var s=Ic(g,a);if(s.state>ZX)throw new Error("too late; already running");return s}function Ic(g,a){var s=g.__transition;if(!s||!(s=s[a]))throw new Error("transition not found");return s}function eut(g,a,s){var C=g.__transition,I;C[a]=s,s.timer=J0e(A,0,s.time);function A(Z){s.state=t7,s.timer.restart(d,s.delay,s.time),s.delay<=Z&&d(Z-s.delay)}function d(Z){var b,w,S,R;if(s.state!==t7)return y();for(b in C)if(R=C[b],R.name===s.name){if(R.state===ZX)return Q0e(d);R.state===$0e?(R.state=BX,R.timer.stop(),R.on.call("interrupt",g,g.__data__,R.index,R.group),delete C[b]):+bi7&&C.state=0&&(a=a.slice(0,s)),!a||a==="start"})}function Vut(g,a,s){var C,I,A=Rut(a)?r7:LA;return function(){var d=A(this,g),h=d.on;h!==C&&(I=(C=h).copy()).on(a,s),d.on=I}}function Eut(g,a){var s=this._id;return arguments.length<2?Ic(this.node(),s).on.on(g):this.each(Vut(s,g,a))}function Hut(g){return function(){var a=this.parentNode;for(var s in this.__transition)if(+s!==g)return;a&&a.removeChild(this)}}function Wut(){return this.on("end.remove",Hut(this._id))}function Nut(g){var a=this._name,s=this._id;typeof g!="function"&&(g=xe(g));for(var C=this._groups,I=C.length,A=new Array(I),d=0;dt7&&C.name===a)return new JA([[g]],gdt,a,+I)}return null}const adt=Object.freeze(Object.defineProperty({__proto__:null,transition:tbe,active:odt,interrupt:nT},Symbol.toStringTag,{value:"Module"})),SX=g=>()=>g;function sdt(g,{sourceEvent:a,target:s,transform:C,dispatch:I}){Object.defineProperties(this,{type:{value:g,enumerable:!0,configurable:!0},sourceEvent:{value:a,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},transform:{value:C,enumerable:!0,configurable:!0},_:{value:I}})}function UA(g,a,s){this.k=g,this.x=a,this.y=s}UA.prototype={constructor:UA,scale:function(g){return g===1?this:new UA(this.k*g,this.x,this.y)},translate:function(g,a){return g===0&a===0?this:new UA(this.k,this.x+this.k*g,this.y+this.k*a)},apply:function(g){return[g[0]*this.k+this.x,g[1]*this.k+this.y]},applyX:function(g){return g*this.k+this.x},applyY:function(g){return g*this.k+this.y},invert:function(g){return[(g[0]-this.x)/this.k,(g[1]-this.y)/this.k]},invertX:function(g){return(g-this.x)/this.k},invertY:function(g){return(g-this.y)/this.k},rescaleX:function(g){return g.copy().domain(g.range().map(this.invertX,this).map(g.invert,g))},rescaleY:function(g){return g.copy().domain(g.range().map(this.invertY,this).map(g.invert,g))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var qo=new UA(1,0,0);nbe.prototype=UA.prototype;function nbe(g){for(;!g.__zoom;)if(!(g=g.parentNode))return qo;return g.__zoom}function o7(g){g.stopImmediatePropagation()}function rT(g){g.preventDefault(),g.stopImmediatePropagation()}function Idt(g){return(!g.ctrlKey||g.type==="wheel")&&!g.button}function ldt(){var g=this;return g instanceof SVGElement?(g=g.ownerSVGElement||g,g.hasAttribute("viewBox")?(g=g.viewBox.baseVal,[[g.x,g.y],[g.x+g.width,g.y+g.height]]):[[0,0],[g.width.baseVal.value,g.height.baseVal.value]]):[[0,0],[g.clientWidth,g.clientHeight]]}function rbe(){return this.__zoom||qo}function Cdt(g){return-g.deltaY*(g.deltaMode===1?.05:g.deltaMode?1:.002)*(g.ctrlKey?10:1)}function cdt(){return navigator.maxTouchPoints||"ontouchstart"in this}function Adt(g,a,s){var C=g.invertX(a[0][0])-s[0][0],I=g.invertX(a[1][0])-s[1][0],A=g.invertY(a[0][1])-s[0][1],d=g.invertY(a[1][1])-s[1][1];return g.translate(I>C?(C+I)/2:Math.min(0,C)||Math.max(0,I),d>A?(A+d)/2:Math.min(0,A)||Math.max(0,d))}function a7(){var g=Idt,a=ldt,s=Adt,C=Cdt,I=cdt,A=[0,1/0],d=[[-1/0,-1/0],[1/0,1/0]],h=250,y=ogt,Z=FZ("start","zoom","end"),b,w,S,R=500,H=150,N=0,D=10;function M(Ie){Ie.property("__zoom",rbe).on("wheel.zoom",te,{passive:!1}).on("mousedown.zoom",Ce).on("dblclick.zoom",ue).filter(I).on("touchstart.zoom",oe).on("touchmove.zoom",he).on("touchend.zoom touchcancel.zoom",ye).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}M.transform=function(Ie,fe,We,_e){var qe=Ie.selection?Ie.selection():Ie;qe.property("__zoom",rbe),Ie!==qe?J(Ie,fe,We,_e):qe.interrupt().each(function(){j(this,arguments).event(_e).start().zoom(null,typeof fe=="function"?fe.apply(this,arguments):fe).end()})},M.scaleBy=function(Ie,fe,We,_e){M.scaleTo(Ie,function(){var qe=this.__zoom.k,nt=typeof fe=="function"?fe.apply(this,arguments):fe;return qe*nt},We,_e)},M.scaleTo=function(Ie,fe,We,_e){M.transform(Ie,function(){var qe=a.apply(this,arguments),nt=this.__zoom,At=We==null?P(qe):typeof We=="function"?We.apply(this,arguments):We,Tt=nt.invert(At),Ne=typeof fe=="function"?fe.apply(this,arguments):fe;return s(K(z(nt,Ne),At,Tt),qe,d)},We,_e)},M.translateBy=function(Ie,fe,We,_e){M.transform(Ie,function(){return s(this.__zoom.translate(typeof fe=="function"?fe.apply(this,arguments):fe,typeof We=="function"?We.apply(this,arguments):We),a.apply(this,arguments),d)},null,_e)},M.translateTo=function(Ie,fe,We,_e,qe){M.transform(Ie,function(){var nt=a.apply(this,arguments),At=this.__zoom,Tt=_e==null?P(nt):typeof _e=="function"?_e.apply(this,arguments):_e;return s(qo.translate(Tt[0],Tt[1]).scale(At.k).translate(typeof fe=="function"?-fe.apply(this,arguments):-fe,typeof We=="function"?-We.apply(this,arguments):-We),nt,d)},_e,qe)};function z(Ie,fe){return fe=Math.max(A[0],Math.min(A[1],fe)),fe===Ie.k?Ie:new UA(fe,Ie.x,Ie.y)}function K(Ie,fe,We){var _e=fe[0]-We[0]*Ie.k,qe=fe[1]-We[1]*Ie.k;return _e===Ie.x&&qe===Ie.y?Ie:new UA(Ie.k,_e,qe)}function P(Ie){return[(+Ie[0][0]+ +Ie[1][0])/2,(+Ie[0][1]+ +Ie[1][1])/2]}function J(Ie,fe,We,_e){Ie.on("start.zoom",function(){j(this,arguments).event(_e).start()}).on("interrupt.zoom end.zoom",function(){j(this,arguments).event(_e).end()}).tween("zoom",function(){var qe=this,nt=arguments,At=j(qe,nt).event(_e),Tt=a.apply(qe,nt),Ne=We==null?P(Tt):typeof We=="function"?We.apply(qe,nt):We,Ge=Math.max(Tt[1][0]-Tt[0][0],Tt[1][1]-Tt[0][1]),He=qe.__zoom,Xe=typeof fe=="function"?fe.apply(qe,nt):fe,at=y(He.invert(Ne).concat(Ge/He.k),Xe.invert(Ne).concat(Ge/Xe.k));return function(bt){if(bt===1)bt=Xe;else{var xt=at(bt),Vt=Ge/xt[2];bt=new UA(Vt,Ne[0]-xt[0]*Vt,Ne[1]-xt[1]*Vt)}At.zoom(null,bt)}})}function j(Ie,fe,We){return!We&&Ie.__zooming||new ie(Ie,fe)}function ie(Ie,fe){this.that=Ie,this.args=fe,this.active=0,this.sourceEvent=null,this.extent=a.apply(Ie,fe),this.taps=0}ie.prototype={event:function(Ie){return Ie&&(this.sourceEvent=Ie),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(Ie,fe){return this.mouse&&Ie!=="mouse"&&(this.mouse[1]=fe.invert(this.mouse[0])),this.touch0&&Ie!=="touch"&&(this.touch0[1]=fe.invert(this.touch0[0])),this.touch1&&Ie!=="touch"&&(this.touch1[1]=fe.invert(this.touch1[0])),this.that.__zoom=fe,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(Ie){var fe=Mn(this.that).datum();Z.call(Ie,this.that,new sdt(Ie,{sourceEvent:this.sourceEvent,target:M,type:Ie,transform:this.that.__zoom,dispatch:Z}),fe)}};function te(Ie,...fe){if(!g.apply(this,arguments))return;var We=j(this,fe).event(Ie),_e=this.__zoom,qe=Math.max(A[0],Math.min(A[1],_e.k*Math.pow(2,C.apply(this,arguments)))),nt=xr(Ie);if(We.wheel)(We.mouse[0][0]!==nt[0]||We.mouse[0][1]!==nt[1])&&(We.mouse[1]=_e.invert(We.mouse[0]=nt)),clearTimeout(We.wheel);else{if(_e.k===qe)return;We.mouse=[nt,_e.invert(nt)],nT(this),We.start()}rT(Ie),We.wheel=setTimeout(At,H),We.zoom("mouse",s(K(z(_e,qe),We.mouse[0],We.mouse[1]),We.extent,d));function At(){We.wheel=null,We.end()}}function Ce(Ie,...fe){if(S||!g.apply(this,arguments))return;var We=Ie.currentTarget,_e=j(this,fe,!0).event(Ie),qe=Mn(Ie.view).on("mousemove.zoom",Ne,!0).on("mouseup.zoom",Ge,!0),nt=xr(Ie,We),At=Ie.clientX,Tt=Ie.clientY;Wk(Ie.view),o7(Ie),_e.mouse=[nt,this.__zoom.invert(nt)],nT(this),_e.start();function Ne(He){if(rT(He),!_e.moved){var Xe=He.clientX-At,at=He.clientY-Tt;_e.moved=Xe*Xe+at*at>N}_e.event(He).zoom("mouse",s(K(_e.that.__zoom,_e.mouse[0]=xr(He,We),_e.mouse[1]),_e.extent,d))}function Ge(He){qe.on("mousemove.zoom mouseup.zoom",null),Nk(He.view,_e.moved),rT(He),_e.event(He).end()}}function ue(Ie,...fe){if(g.apply(this,arguments)){var We=this.__zoom,_e=xr(Ie.changedTouches?Ie.changedTouches[0]:Ie,this),qe=We.invert(_e),nt=We.k*(Ie.shiftKey?.5:2),At=s(K(z(We,nt),_e,qe),a.apply(this,fe),d);rT(Ie),h>0?Mn(this).transition().duration(h).call(J,At,_e,Ie):Mn(this).call(M.transform,At,_e,Ie)}}function oe(Ie,...fe){if(g.apply(this,arguments)){var We=Ie.touches,_e=We.length,qe=j(this,fe,Ie.changedTouches.length===_e).event(Ie),nt,At,Tt,Ne;for(o7(Ie),At=0;At<_e;++At)Tt=We[At],Ne=xr(Tt,this),Ne=[Ne,this.__zoom.invert(Ne),Tt.identifier],qe.touch0?!qe.touch1&&qe.touch0[2]!==Ne[2]&&(qe.touch1=Ne,qe.taps=0):(qe.touch0=Ne,nt=!0,qe.taps=1+!!b);b&&(b=clearTimeout(b)),nt&&(qe.taps<2&&(w=Ne[0],b=setTimeout(function(){b=null},R)),nT(this),qe.start())}}function he(Ie,...fe){if(this.__zooming){var We=j(this,fe).event(Ie),_e=Ie.changedTouches,qe=_e.length,nt,At,Tt,Ne;for(rT(Ie),nt=0;nt{},this.pubSubs.push(this.pubSub.subscribe("app.mouseMove",this.defaultMouseMoveHandler.bind(this)))}return E(g,[{key:"isWithin",value:function(s,C){let I=s,A=C,d=this.position[0],h=this.position[1];return this.isLeftModified&&(I=C,A=s,d=this.position[1],h=this.position[0]),XU(I,A,d,this.dimensions[0]+d,h,this.dimensions[1]+h)}},{key:"getProp",value:function(s){return()=>this[s]}},{key:"getData",value:function(){}},{key:"click",value:function(s,C,I){return{type:"generic",event:I,payload:null}}},{key:"clickOutside",value:function(){}},{key:"getDimensions",value:function(){return this.dimensions}},{key:"setDimensions",value:function(s){this.dimensions=s,this._xScale.range([0,this.dimensions[0]]),this._yScale.range([0,this.dimensions[1]])}},{key:"refXScale",value:function(s){return arguments.length?(this._refXScale=s,this):this._refXScale}},{key:"refYScale",value:function(s){return arguments.length?(this._refYScale=s,this):this._refYScale}},{key:"xScale",value:function(s){return arguments.length?(this._xScale=s,this):this._xScale}},{key:"yScale",value:function(s){return arguments.length?(this._yScale=s,this):this._yScale}},{key:"zoomed",value:function(s,C){this.xScale(s),this.yScale(C)}},{key:"refScalesChanged",value:function(s,C){this._refXScale=s,this._refYScale=C}},{key:"draw",value:function(){}},{key:"getPosition",value:function(){return this.position}},{key:"setPosition",value:function(s){this.position=s}},{key:"defaultMouseMoveHandler",value:function(s){}},{key:"remove",value:function(){this.pubSubs.forEach(s=>this.pubSub.unsubscribe(s)),this.pubSubs=[]}},{key:"rerender",value:function(){}},{key:"respondsToPosition",value:function(s,C){return this.isWithin(s,C)}},{key:"zoomedY",value:function(s,C){}},{key:"movedY",value:function(s){}}]),g}();function ddt(g,a){const s=VZ(a,g);return R0(`.${s}`,g)(g)}function hdt(g,a){const s=g.map(A=>+A).sort((A,d)=>d-A),C=s[a],I=s[s.length-1];return ddt(C,I)}function fdt(g,a,s,C){const I=a/(2**g*s);if(!Number.isNaN(I)){const A=a/(2**C*s),d=VZ(A,I);return R0(`.${d}`,I)(I)}return console.warn("NaN resolution, screen is probably too small."),""}let Xs=function(g){o(s,g);var a=l(s);function s(C,I){var A;T(this,s),A=a.call(this,C,I);const{scene:d}=C;A.scene=d,A.delayDrawing=!1,A.pBase=new $t.PIXI.Graphics,A.pMasked=new $t.PIXI.Graphics,A.pMask=new $t.PIXI.Graphics,A.pMain=new $t.PIXI.Graphics,A.pBorder=new $t.PIXI.Graphics,A.pBackground=new $t.PIXI.Graphics,A.pForeground=new $t.PIXI.Graphics,A.pLabel=new $t.PIXI.Graphics,A.pMobile=new $t.PIXI.Graphics,A.pAxis=new $t.PIXI.Graphics,A.pMouseOver=new $t.PIXI.Graphics,A.scene.addChild(A.pBase),A.pBase.addChild(A.pMasked),A.pMasked.addChild(A.pBackground),A.pMasked.addChild(A.pMain),A.pMasked.addChild(A.pMask),A.pMasked.addChild(A.pMobile),A.pMasked.addChild(A.pBorder),A.pMasked.addChild(A.pLabel),A.pMasked.addChild(A.pForeground),A.pMasked.addChild(A.pMouseOver),A.pBase.addChild(A.pAxis),A.pMasked.mask=A.pMask,A.prevOptions="",A.options=Object.assign(A.options,I);const h=A.getName();return A.labelTextFontFamily="Arial",A.labelTextFontSize=12,A.labelXOffset=0,A.labelText=new $t.PIXI.Text(h,{fontSize:`${A.labelTextFontSize}px`,fontFamily:A.labelTextFontFamily,fill:"black"}),A.pLabel.addChild(A.labelText),A.errorText=new $t.PIXI.Text("",{fontSize:"12px",fontFamily:"Arial",fill:"red"}),A.errorText.anchor.x=.5,A.errorText.anchor.y=.5,A.pLabel.addChild(A.errorText),A}return E(s,[{key:"setLabelText",value:function(){}},{key:"setPosition",value:function(I){this.position=I,this.drawBorder(),this.drawLabel(),this.drawBackground(),this.setMask(this.position,this.dimensions),this.setForeground()}},{key:"setDimensions",value:function(I){n(G(s.prototype),"setDimensions",this).call(this,I),this.drawBorder(),this.drawLabel(),this.drawBackground(),this.setMask(this.position,this.dimensions),this.setForeground()}},{key:"setMask",value:function(I,A){this.pMask.clear(),this.pMask.beginFill(),this.pMask.drawRect(I[0],I[1],A[0],A[1]),this.pMask.endFill()}},{key:"setForeground",value:function(){this.pForeground.position.y=this.position[1],this.pForeground.position.x=this.position[0]}},{key:"remove",value:function(){this.pBase.clear(),this.scene.removeChild(this.pBase)}},{key:"drawBorder",value:function(){const I=this.pBorder;if(I.clear(),!this.options||!this.options.trackBorderWidth)return;const A=Mi(this.options.trackBorderColor?this.options.trackBorderColor:"white");I.lineStyle(this.options.trackBorderWidth,A),I.drawRect(this.position[0],this.position[1],this.dimensions[0],this.dimensions[1])}},{key:"drawError",value:function(){if(this.errorText.x=this.position[0]+this.dimensions[0]/2,this.errorText.y=this.position[1]+this.dimensions[1]/2,this.errorText.text=this.errorTextText,this.errorTextText&&this.errorTextText.length){const I=this.pBorder;I.clear(),I.lineStyle(1,Mi("red")),I.drawRect(this.position[0],this.position[1],this.dimensions[0],this.dimensions[1])}}},{key:"drawBackground",value:function(){const I=this.pBackground;if(I.clear(),!this.options||!this.options.backgroundColor)return;let A=1,d=this.options.backgroundColor;this.options.backgroundColor==="transparent"&&(A=0,d="white");const h=Mi(d);I.beginFill(h,A),I.drawRect(this.position[0],this.position[1],this.dimensions[0],this.dimensions[1])}},{key:"getLabelColor",value:function(){return this.options.labelColor&&this.options.labelColor!=="[glyph-color]"?this.options.labelColor:this.options.lineStrokeColor||this.options.barFillColor||"black"}},{key:"getName",value:function(){return this.options.name?this.options.name:this.tilesetInfo&&this.tilesetInfo.name||""}},{key:"drawLabel",value:function(){if(!this.labelText)return;const I=this.pLabel;if(I.clear(),!this.options||!this.options.labelPosition||this.options.labelPosition==="hidden"){this.labelText.alpha=0;return}I.beginFill(Mi(this.options.labelBackgroundColor||"white"),+this.options.labelBackgroundOpacity>=0?+this.options.labelBackgroundOpacity:.5);const A=Mi(this.getLabelColor()),d=2;if(this.dimensions[0]<0)return;let h=this.options.labelShowAssembly&&this.tilesetInfo&&this.tilesetInfo.coordSystem?`${this.tilesetInfo.coordSystem} | `:"";if(h+=this.getName(),this.options.labelShowResolution&&this.tilesetInfo&&this.tilesetInfo.max_width&&this.tilesetInfo.bins_per_dimension){const S=fdt(this.calculateZoomLevel(),this.tilesetInfo.max_width,this.tilesetInfo.bins_per_dimension,this.tilesetInfo.max_zoom);h+=` -[Current data resolution: ${S}]`}else if(this.options.labelShowResolution&&this.tilesetInfo&&this.tilesetInfo.resolutions){const S=hdt(this.tilesetInfo.resolutions,this.calculateZoomLevel());h+=` -[Current data resolution: ${S}]`}if(this.options&&this.options.dataTransform){let S=null;if(this.tilesetInfo&&this.tilesetInfo.transforms)for(const R of this.tilesetInfo.transforms)R.value===this.options.dataTransform&&(S=R);S?h+=` -[Transform: ${S.name}]`:this.options.dataTransform==="None"?h+=` -[Transform: None ]`:h+=` -[Transform: Default ]`}this.labelText.text=h,this.labelText.style={fontSize:`${this.labelTextFontSize}px`,fontFamily:this.labelTextFontFamily,fill:A},this.labelText.alpha=typeof this.options.labelTextOpacity<"u"?this.options.labelTextOpacity:1,this.labelText.visible=!0,this.flipText&&(this.labelText.scale.x=-1);const y=+this.options.labelLeftMargin||0,Z=+this.options.labelRightMargin||0,b=+this.options.labelTopMargin||0,w=+this.options.labelBottomMargin||0;this.options.labelPosition==="topLeft"?(this.labelText.x=this.position[0]+y+this.labelXOffset,this.labelText.y=this.position[1]+b,this.labelText.anchor.x=.5,this.labelText.anchor.y=0,this.labelText.x+=this.labelText.width/2,I.drawRect(this.position[0]+y+this.labelXOffset,this.position[1]+b,this.labelText.width+d,this.labelText.height+d)):this.options.labelPosition==="bottomLeft"&&!this.flipText||this.options.labelPosition==="topRight"&&this.flipText?(this.labelText.x=this.position[0]+(y||b),this.labelText.y=this.position[1]+this.dimensions[1]-(w||Z),this.labelText.anchor.x=.5,this.labelText.anchor.y=1,this.labelText.x+=this.labelText.width/2+this.labelXOffset,I.drawRect(this.position[0]+(y||b)+this.labelXOffset,this.position[1]+this.dimensions[1]-this.labelText.height-d-(w||Z),this.labelText.width+d,this.labelText.height+d)):this.options.labelPosition==="topRight"&&!this.flipText||this.options.labelPosition==="bottomLeft"&&this.flipText?(this.labelText.x=this.position[0]+this.dimensions[0]-(Z||w),this.labelText.y=this.position[1]+(b||y),this.labelText.anchor.x=.5,this.labelText.anchor.y=0,this.labelText.x-=this.labelText.width/2+this.labelXOffset,I.drawRect(this.position[0]+this.dimensions[0]-this.labelText.width-d-(Z||w)-this.labelXOffset,this.position[1]+(b||y),this.labelText.width+d,this.labelText.height+d)):this.options.labelPosition==="bottomRight"?(this.labelText.x=this.position[0]+this.dimensions[0]-Z,this.labelText.y=this.position[1]+this.dimensions[1]-w,this.labelText.anchor.x=.5,this.labelText.anchor.y=1,this.labelText.x-=this.labelText.width/2+this.labelXOffset,I.drawRect(this.position[0]+this.dimensions[0]-this.labelText.width-d-Z-this.labelXOffset,this.position[1]+this.dimensions[1]-this.labelText.height-d-w,this.labelText.width+d,this.labelText.height+d)):this.options.labelPosition==="outerLeft"&&!this.flipText||this.options.labelPosition==="outerTop"&&this.flipText?(this.labelText.x=this.position[0],this.labelText.y=this.position[1]+this.dimensions[1]/2,this.labelText.anchor.x=.5,this.labelText.anchor.y=.5,this.labelText.x-=this.labelText.width/2+3):this.options.labelPosition==="outerTop"&&!this.flipText||this.options.labelPosition==="outerLeft"&&this.flipText?(this.labelText.x=this.position[0]+this.dimensions[0]/2,this.labelText.y=this.position[1],this.labelText.anchor.x=.5,this.labelText.anchor.y=.5,this.labelText.y-=this.labelText.height/2+3):this.options.labelPosition==="outerBottom"&&!this.flipText||this.options.labelPosition==="outerRight"&&this.flipText?(this.labelText.x=this.position[0]+this.dimensions[0]/2,this.labelText.y=this.position[1]+this.dimensions[1],this.labelText.anchor.x=.5,this.labelText.anchor.y=.5,this.labelText.y+=this.labelText.height/2+3):this.options.labelPosition==="outerRight"&&!this.flipText||this.options.labelPosition==="outerBottom"&&this.flipText?(this.labelText.x=this.position[0]+this.dimensions[0],this.labelText.y=this.position[1]+this.dimensions[1]/2,this.labelText.anchor.x=.5,this.labelText.anchor.y=.5,this.labelText.x+=this.labelText.width/2+3):this.labelText.visible=!1,this.options.labelPosition==="outerLeft"||this.options.labelPosition==="outerRight"||this.options.labelPosition==="outerTop"||this.options.labelPosition==="outerBottom"?this.pLabel.setParent(this.pBase):this.pLabel.setParent(this.pMasked)}},{key:"rerender",value:function(I){this.options=I,this.draw(),this.drawBackground(),this.drawLabel(),this.drawError(),this.drawBorder()}},{key:"draw",value:function(){this.drawError()}},{key:"exportSVG",value:function(){const I=document.createElement("g"),A=document.createElement("rect");A.setAttribute("x",`${this.position[0]}`),A.setAttribute("y",`${this.position[1]}`),A.setAttribute("width",`${this.dimensions[0]}`),A.setAttribute("height",`${this.dimensions[1]}`),this.options&&this.options.backgroundColor?A.setAttribute("fill",this.options.backgroundColor):A.setAttribute("fill-opacity","0");const d=document.createElement("g");d.setAttribute("class","g-clipped"),I.appendChild(d),d.appendChild(A);const h=document.createElement("g");d.setAttribute("class","g-track"),d.appendChild(h);const y=document.createElement("g");d.setAttribute("class","g-labels"),d.appendChild(y);const Z=document.createElementNS("http://www.w3.org/2000/svg","clipPath");I.appendChild(Z);const b=document.createElementNS("http://www.w3.org/2000/svg","polygon");Z.appendChild(b),b.setAttribute("points",`${this.position[0]},${this.position[1]} ${this.position[0]+this.dimensions[0]},${this.position[1]} ${this.position[0]+this.dimensions[0]},${this.position[1]+this.dimensions[1]} ${this.position[0]},${this.position[1]+this.dimensions[1]} `);const w=Fn.nice();Z.setAttribute("id",w),d.setAttribute("style",`clip-path:url(#${w});`);const S=this.labelText.text.split(` -`);let R=0;const H=3,N=(this.labelTextFontSize+2)*S.length+H;this.labelText.anchor.y===.5?R=N/2:this.labelText.anchor.y===1&&(R=-N);for(let D=0;Dnew g(C,s)))}return E(g,[{key:"registerFileUrl",value:async function({server:s,url:C,filetype:I,coordSystem:A}){const d=`${IX(s)}/register_url/`;return fetch(d,{method:"POST",body:JSON.stringify({fileurl:C,filetype:I,coordSystem:A}),headers:{"Content-Type":"application/json; charset=utf-8"}})}},{key:"tilesetInfo",value:function(s){return this.dataConfig.server&&this.dataConfig.url&&this.dataConfig.filetype?this.registerFileUrl(this.dataConfig).then(C=>C.json()).then(C=>{this.dataConfig.tilesetUid=C.uid,this.tilesetInfoAfterRegister(s)}).catch(C=>{console.error("Error registering url",C)}):new Promise(()=>{this.tilesetInfoAfterRegister(s)})}},{key:"tilesetInfoAfterRegister",value:function(s){if(!this.dataConfig.children)!this.dataConfig.server||!this.dataConfig.tilesetUid?(console.warn("No dataConfig children, server or tilesetUid:",this.dataConfig),s(null)):Gi.trackInfo(this.dataConfig.server,this.dataConfig.tilesetUid,C=>{this.dataConfig.tilesetInfo=C[this.dataConfig.tilesetUid],s(C[this.dataConfig.tilesetUid],this.dataConfig.tilesetUid)},C=>{this.tilesetInfoLoading=!1,s({error:C})},this.pubSub);else{const C=this.dataConfig.children.map(I=>new Promise(A=>{I.tilesetInfo(A)}));Promise.all(C).then(I=>{s(I[0])})}}},{key:"fullTileId",value:function(s,C){return`${s}.${C}`}},{key:"fetchTilesDebounced",value:function(s,C){if(this.dataConfig.type==="horizontal-section")this.fetchHorizontalSection(s,C);else if(this.dataConfig.type==="vertical-section")this.fetchHorizontalSection(s,C,!0);else if(!this.dataConfig.children&&this.dataConfig.tilesetUid)new Promise(A=>{Gi.fetchTilesDebounced({id:Fn.nice(),server:this.dataConfig.server,done:A,ids:C.map(d=>`${this.dataConfig.tilesetUid}.${d}`),options:this.dataConfig.options},this.pubSub,!0)}).then(A=>{const d=Mr(A)[0].tilesetUid,h={};for(let y=0;ynew Promise(d=>{A.fetchTilesDebounced(d,C)},this.pubSub,!0));Promise.all(I).then(A=>{if(this.dataConfig.type==="divided"){const d=this.makeDivided(A,C);s(d)}else console.warn("Unimplemented dataConfig type. Returning first data source.",this.dataConfig),s(A[0])})}}},{key:"divideData",value:function(s,C){const I=new Float32Array(s.length);for(let A=0;A+M).sort((M,z)=>z-M);R=Gi.calculateTilesFromResolution(D[b],S,this.dataConfig.tilesetInfo.min_pos[I?1:0],this.dataConfig.tilesetInfo.max_pos[I?1:0])}else R=Gi.calculateTiles(b,S,this.dataConfig.tilesetInfo.min_pos[I?1:0],this.dataConfig.tilesetInfo.max_pos[I?1:0],this.dataConfig.tilesetInfo.max_zoom,this.dataConfig.tilesetInfo.max_width);const H=[w,R[0]].sort((D,M)=>D-M);H[0]===w?d.push(!1):d.push(!0);const N=`${b}.${H[0]}.${H[1]}`;A.push(N)}new Promise(y=>{Gi.fetchTilesDebounced({id:Fn.nice(),server:this.dataConfig.server,done:y,ids:A.map(Z=>`${this.dataConfig.tilesetUid}.${Z}`)},this.pubSub,!0)}).then(y=>{const Z=Mr(y)[0].tilesetUid,b={};for(let w=0;w=0;)g[a]=0}var ydt=0,abe=1,vdt=2,Zdt=3,Bdt=258,s7=29,oT=256,aT=oT+1+s7,r1=30,I7=19,sbe=2*aT+1,Q0=15,l7=16,Gdt=7,C7=256,Ibe=16,lbe=17,Cbe=18,c7=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],TX=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Sdt=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],cbe=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],wdt=512,Qd=new Array((aT+2)*2);n1(Qd);var sT=new Array(r1*2);n1(sT);var IT=new Array(wdt);n1(IT);var lT=new Array(Bdt-Zdt+1);n1(lT);var A7=new Array(s7);n1(A7);var RX=new Array(r1);n1(RX);function u7(g,a,s,C,I){this.static_tree=g,this.extra_bits=a,this.extra_base=s,this.elems=C,this.max_length=I,this.has_stree=g&&g.length}var Abe,ube,dbe;function d7(g,a){this.dyn_tree=g,this.max_code=0,this.stat_desc=a}function hbe(g){return g<256?IT[g]:IT[256+(g>>>7)]}function CT(g,a){g.pending_buf[g.pending++]=a&255,g.pending_buf[g.pending++]=a>>>8&255}function GI(g,a,s){g.bi_valid>l7-s?(g.bi_buf|=a<>l7-g.bi_valid,g.bi_valid+=s-l7):(g.bi_buf|=a<>>=1,s<<=1;while(--a>0);return s>>>1}function Tdt(g){g.bi_valid===16?(CT(g,g.bi_buf),g.bi_buf=0,g.bi_valid=0):g.bi_valid>=8&&(g.pending_buf[g.pending++]=g.bi_buf&255,g.bi_buf>>=8,g.bi_valid-=8)}function Rdt(g,a){var s=a.dyn_tree,C=a.max_code,I=a.stat_desc.static_tree,A=a.stat_desc.has_stree,d=a.stat_desc.extra_bits,h=a.stat_desc.extra_base,y=a.stat_desc.max_length,Z,b,w,S,R,H,N=0;for(S=0;S<=Q0;S++)g.bl_count[S]=0;for(s[g.heap[g.heap_max]*2+1]=0,Z=g.heap_max+1;Zy&&(S=y,N++),s[b*2+1]=S,!(b>C)&&(g.bl_count[S]++,R=0,b>=h&&(R=d[b-h]),H=s[b*2],g.opt_len+=H*(S+R),A&&(g.static_len+=H*(I[b*2+1]+R)));if(N!==0){do{for(S=y-1;g.bl_count[S]===0;)S--;g.bl_count[S]--,g.bl_count[S+1]+=2,g.bl_count[y]--,N-=2}while(N>0);for(S=y;S!==0;S--)for(b=g.bl_count[S];b!==0;)w=g.heap[--Z],!(w>C)&&(s[w*2+1]!==S&&(g.opt_len+=(S-s[w*2+1])*s[w*2],s[w*2+1]=S),b--)}}function mbe(g,a,s){var C=new Array(Q0+1),I=0,A,d;for(A=1;A<=Q0;A++)C[A]=I=I+s[A-1]<<1;for(d=0;d<=a;d++){var h=g[d*2+1];h!==0&&(g[d*2]=fbe(C[h]++,h))}}function Vdt(){var g,a,s,C,I,A=new Array(Q0+1);for(s=0,C=0;C>=7;C8?CT(g,g.bi_buf):g.bi_valid>0&&(g.pending_buf[g.pending++]=g.bi_buf),g.bi_buf=0,g.bi_valid=0}function Edt(g,a,s,C){bbe(g),C&&(CT(g,s),CT(g,~s)),mdt.arraySet(g.pending_buf,g.window,a,s,g.pending),g.pending+=s}function ybe(g,a,s,C){var I=a*2,A=s*2;return g[I]>1;d>=1;d--)h7(g,s,d);Z=A;do d=g.heap[1],g.heap[1]=g.heap[g.heap_len--],h7(g,s,1),h=g.heap[1],g.heap[--g.heap_max]=d,g.heap[--g.heap_max]=h,s[Z*2]=s[d*2]+s[h*2],g.depth[Z]=(g.depth[d]>=g.depth[h]?g.depth[d]:g.depth[h])+1,s[d*2+1]=s[h*2+1]=Z,g.heap[1]=Z++,h7(g,s,1);while(g.heap_len>=2);g.heap[--g.heap_max]=g.heap[1],Rdt(g,a),mbe(s,y,g.bl_count)}function Zbe(g,a,s){var C,I=-1,A,d=a[0*2+1],h=0,y=7,Z=4;for(d===0&&(y=138,Z=3),a[(s+1)*2+1]=65535,C=0;C<=s;C++)A=d,d=a[(C+1)*2+1],!(++h=3&&g.bl_tree[cbe[a]*2+1]===0;a--);return g.opt_len+=3*(a+1)+5+5+4,a}function Wdt(g,a,s,C){var I;for(GI(g,a-257,5),GI(g,s-1,5),GI(g,C-4,4),I=0;I>>=1)if(a&1&&g.dyn_ltree[s*2]!==0)return gbe;if(g.dyn_ltree[9*2]!==0||g.dyn_ltree[10*2]!==0||g.dyn_ltree[13*2]!==0)return obe;for(s=32;s0?(g.strm.data_type===bdt&&(g.strm.data_type=Ndt(g)),f7(g,g.l_desc),f7(g,g.d_desc),d=Hdt(g),I=g.opt_len+3+7>>>3,A=g.static_len+3+7>>>3,A<=I&&(I=A)):I=A=s+5,s+4<=I&&a!==-1?Sbe(g,a,s,C):g.strategy===pdt||A===I?(GI(g,(abe<<1)+(C?1:0),3),vbe(g,Qd,sT)):(GI(g,(vdt<<1)+(C?1:0),3),Wdt(g,g.l_desc.max_code+1,g.d_desc.max_code+1,d+1),vbe(g,g.dyn_ltree,g.dyn_dtree)),pbe(g),C&&bbe(g)}function Ddt(g,a,s){return g.pending_buf[g.d_buf+g.last_lit*2]=a>>>8&255,g.pending_buf[g.d_buf+g.last_lit*2+1]=a&255,g.pending_buf[g.l_buf+g.last_lit]=s&255,g.last_lit++,a===0?g.dyn_ltree[s*2]++:(g.matches++,a--,g.dyn_ltree[(lT[s]+oT+1)*2]++,g.dyn_dtree[hbe(a)*2]++),g.last_lit===g.lit_bufsize-1}i1._tr_init=kdt,i1._tr_stored_block=Sbe,i1._tr_flush_block=xdt,i1._tr_tally=Ddt,i1._tr_align=Xdt;function Mdt(g,a,s,C){for(var I=g&65535|0,A=g>>>16&65535|0,d=0;s!==0;){d=s>2e3?2e3:s,s-=d;do I=I+a[C++]|0,A=A+I|0;while(--d);I%=65521,A%=65521}return I|A<<16|0}var wbe=Mdt;function Fdt(){for(var g,a=[],s=0;s<256;s++){g=s;for(var C=0;C<8;C++)g=g&1?3988292384^g>>>1:g>>>1;a[s]=g}return a}var Ydt=Fdt();function Kdt(g,a,s,C){var I=Ydt,A=C+s;g^=-1;for(var d=C;d>>8^I[(g^a[d])&255];return g^-1}var Tbe=Kdt,m7={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},xs=Ud,lC=i1,Rbe=wbe,Yf=Tbe,_dt=m7,j0=0,Pdt=1,zdt=3,Kf=4,Vbe=5,$A=0,Ebe=1,CC=-2,Odt=-3,p7=-5,Ldt=-1,Jdt=1,VX=2,Udt=3,Qdt=4,jdt=0,$dt=2,EX=8,qdt=9,eht=15,tht=8,iht=29,nht=256,b7=nht+1+iht,rht=30,ght=19,oht=2*b7+1,aht=15,tr=3,_f=258,lc=_f+tr+1,sht=32,HX=42,y7=69,WX=73,NX=91,kX=103,$0=113,cT=666,Mo=1,AT=2,q0=3,g1=4,Iht=3;function Pf(g,a){return g.msg=_dt[a],a}function Hbe(g){return(g<<1)-(g>4?9:0)}function zf(g){for(var a=g.length;--a>=0;)g[a]=0}function Of(g){var a=g.state,s=a.pending;s>g.avail_out&&(s=g.avail_out),s!==0&&(xs.arraySet(g.output,a.pending_buf,a.pending_out,s,g.next_out),g.next_out+=s,a.pending_out+=s,g.total_out+=s,g.avail_out-=s,a.pending-=s,a.pending===0&&(a.pending_out=0))}function ya(g,a){lC._tr_flush_block(g,g.block_start>=0?g.block_start:-1,g.strstart-g.block_start,a),g.block_start=g.strstart,Of(g.strm)}function dr(g,a){g.pending_buf[g.pending++]=a}function uT(g,a){g.pending_buf[g.pending++]=a>>>8&255,g.pending_buf[g.pending++]=a&255}function lht(g,a,s,C){var I=g.avail_in;return I>C&&(I=C),I===0?0:(g.avail_in-=I,xs.arraySet(a,g.input,g.next_in,I,s),g.state.wrap===1?g.adler=Rbe(g.adler,a,I,s):g.state.wrap===2&&(g.adler=Yf(g.adler,a,I,s)),g.next_in+=I,g.total_in+=I,I)}function Wbe(g,a){var s=g.max_chain_length,C=g.strstart,I,A,d=g.prev_length,h=g.nice_match,y=g.strstart>g.w_size-lc?g.strstart-(g.w_size-lc):0,Z=g.window,b=g.w_mask,w=g.prev,S=g.strstart+_f,R=Z[C+d-1],H=Z[C+d];g.prev_length>=g.good_match&&(s>>=2),h>g.lookahead&&(h=g.lookahead);do if(I=a,!(Z[I+d]!==H||Z[I+d-1]!==R||Z[I]!==Z[C]||Z[++I]!==Z[C+1])){C+=2,I++;do;while(Z[++C]===Z[++I]&&Z[++C]===Z[++I]&&Z[++C]===Z[++I]&&Z[++C]===Z[++I]&&Z[++C]===Z[++I]&&Z[++C]===Z[++I]&&Z[++C]===Z[++I]&&Z[++C]===Z[++I]&&Cd){if(g.match_start=a,d=A,A>=h)break;R=Z[C+d-1],H=Z[C+d]}}while((a=w[a&b])>y&&--s!==0);return d<=g.lookahead?d:g.lookahead}function eb(g){var a=g.w_size,s,C,I,A,d;do{if(A=g.window_size-g.lookahead-g.strstart,g.strstart>=a+(a-lc)){xs.arraySet(g.window,g.window,a,a,0),g.match_start-=a,g.strstart-=a,g.block_start-=a,C=g.hash_size,s=C;do I=g.head[--s],g.head[s]=I>=a?I-a:0;while(--C);C=a,s=C;do I=g.prev[--s],g.prev[s]=I>=a?I-a:0;while(--C);A+=a}if(g.strm.avail_in===0)break;if(C=lht(g.strm,g.window,g.strstart+g.lookahead,A),g.lookahead+=C,g.lookahead+g.insert>=tr)for(d=g.strstart-g.insert,g.ins_h=g.window[d],g.ins_h=(g.ins_h<g.pending_buf_size-5&&(s=g.pending_buf_size-5);;){if(g.lookahead<=1){if(eb(g),g.lookahead===0&&a===j0)return Mo;if(g.lookahead===0)break}g.strstart+=g.lookahead,g.lookahead=0;var C=g.block_start+s;if((g.strstart===0||g.strstart>=C)&&(g.lookahead=g.strstart-C,g.strstart=C,ya(g,!1),g.strm.avail_out===0)||g.strstart-g.block_start>=g.w_size-lc&&(ya(g,!1),g.strm.avail_out===0))return Mo}return g.insert=0,a===Kf?(ya(g,!0),g.strm.avail_out===0?q0:g1):(g.strstart>g.block_start&&(ya(g,!1),g.strm.avail_out===0),Mo)}function v7(g,a){for(var s,C;;){if(g.lookahead=tr&&(g.ins_h=(g.ins_h<=tr)if(C=lC._tr_tally(g,g.strstart-g.match_start,g.match_length-tr),g.lookahead-=g.match_length,g.match_length<=g.max_lazy_match&&g.lookahead>=tr){g.match_length--;do g.strstart++,g.ins_h=(g.ins_h<=tr&&(g.ins_h=(g.ins_h<4096)&&(g.match_length=tr-1)),g.prev_length>=tr&&g.match_length<=g.prev_length){I=g.strstart+g.lookahead-tr,C=lC._tr_tally(g,g.strstart-1-g.prev_match,g.prev_length-tr),g.lookahead-=g.prev_length-1,g.prev_length-=2;do++g.strstart<=I&&(g.ins_h=(g.ins_h<=tr&&g.strstart>0&&(I=g.strstart-1,C=d[I],C===d[++I]&&C===d[++I]&&C===d[++I])){A=g.strstart+_f;do;while(C===d[++I]&&C===d[++I]&&C===d[++I]&&C===d[++I]&&C===d[++I]&&C===d[++I]&&C===d[++I]&&C===d[++I]&&Ig.lookahead&&(g.match_length=g.lookahead)}if(g.match_length>=tr?(s=lC._tr_tally(g,1,g.match_length-tr),g.lookahead-=g.match_length,g.strstart+=g.match_length,g.match_length=0):(s=lC._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++),s&&(ya(g,!1),g.strm.avail_out===0))return Mo}return g.insert=0,a===Kf?(ya(g,!0),g.strm.avail_out===0?q0:g1):g.last_lit&&(ya(g,!1),g.strm.avail_out===0)?Mo:AT}function Aht(g,a){for(var s;;){if(g.lookahead===0&&(eb(g),g.lookahead===0)){if(a===j0)return Mo;break}if(g.match_length=0,s=lC._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++,s&&(ya(g,!1),g.strm.avail_out===0))return Mo}return g.insert=0,a===Kf?(ya(g,!0),g.strm.avail_out===0?q0:g1):g.last_lit&&(ya(g,!1),g.strm.avail_out===0)?Mo:AT}function qA(g,a,s,C,I){this.good_length=g,this.max_lazy=a,this.nice_length=s,this.max_chain=C,this.func=I}var a1;a1=[new qA(0,0,0,0,Cht),new qA(4,4,8,4,v7),new qA(4,5,16,8,v7),new qA(4,6,32,32,v7),new qA(4,4,16,16,o1),new qA(8,16,32,32,o1),new qA(8,16,128,128,o1),new qA(8,32,128,256,o1),new qA(32,128,258,1024,o1),new qA(32,258,258,4096,o1)];function uht(g){g.window_size=2*g.w_size,zf(g.head),g.max_lazy_match=a1[g.level].max_lazy,g.good_match=a1[g.level].good_length,g.nice_match=a1[g.level].nice_length,g.max_chain_length=a1[g.level].max_chain,g.strstart=0,g.block_start=0,g.lookahead=0,g.insert=0,g.match_length=g.prev_length=tr-1,g.match_available=0,g.ins_h=0}function dht(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=EX,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new xs.Buf16(oht*2),this.dyn_dtree=new xs.Buf16((2*rht+1)*2),this.bl_tree=new xs.Buf16((2*ght+1)*2),zf(this.dyn_ltree),zf(this.dyn_dtree),zf(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new xs.Buf16(aht+1),this.heap=new xs.Buf16(2*b7+1),zf(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new xs.Buf16(2*b7+1),zf(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Nbe(g){var a;return!g||!g.state?Pf(g,CC):(g.total_in=g.total_out=0,g.data_type=$dt,a=g.state,a.pending=0,a.pending_out=0,a.wrap<0&&(a.wrap=-a.wrap),a.status=a.wrap?HX:$0,g.adler=a.wrap===2?0:1,a.last_flush=j0,lC._tr_init(a),$A)}function kbe(g){var a=Nbe(g);return a===$A&&uht(g.state),a}function hht(g,a){return!g||!g.state||g.state.wrap!==2?CC:(g.state.gzhead=a,$A)}function Xbe(g,a,s,C,I,A){if(!g)return CC;var d=1;if(a===Ldt&&(a=6),C<0?(d=0,C=-C):C>15&&(d=2,C-=16),I<1||I>qdt||s!==EX||C<8||C>15||a<0||a>9||A<0||A>Qdt)return Pf(g,CC);C===8&&(C=9);var h=new dht;return g.state=h,h.strm=g,h.wrap=d,h.gzhead=null,h.w_bits=C,h.w_size=1<Vbe||a<0)return g?Pf(g,CC):CC;if(C=g.state,!g.output||!g.input&&g.avail_in!==0||C.status===cT&&a!==Kf)return Pf(g,g.avail_out===0?p7:CC);if(C.strm=g,s=C.last_flush,C.last_flush=a,C.status===HX)if(C.wrap===2)g.adler=0,dr(C,31),dr(C,139),dr(C,8),C.gzhead?(dr(C,(C.gzhead.text?1:0)+(C.gzhead.hcrc?2:0)+(C.gzhead.extra?4:0)+(C.gzhead.name?8:0)+(C.gzhead.comment?16:0)),dr(C,C.gzhead.time&255),dr(C,C.gzhead.time>>8&255),dr(C,C.gzhead.time>>16&255),dr(C,C.gzhead.time>>24&255),dr(C,C.level===9?2:C.strategy>=VX||C.level<2?4:0),dr(C,C.gzhead.os&255),C.gzhead.extra&&C.gzhead.extra.length&&(dr(C,C.gzhead.extra.length&255),dr(C,C.gzhead.extra.length>>8&255)),C.gzhead.hcrc&&(g.adler=Yf(g.adler,C.pending_buf,C.pending,0)),C.gzindex=0,C.status=y7):(dr(C,0),dr(C,0),dr(C,0),dr(C,0),dr(C,0),dr(C,C.level===9?2:C.strategy>=VX||C.level<2?4:0),dr(C,Iht),C.status=$0);else{var d=EX+(C.w_bits-8<<4)<<8,h=-1;C.strategy>=VX||C.level<2?h=0:C.level<6?h=1:C.level===6?h=2:h=3,d|=h<<6,C.strstart!==0&&(d|=sht),d+=31-d%31,C.status=$0,uT(C,d),C.strstart!==0&&(uT(C,g.adler>>>16),uT(C,g.adler&65535)),g.adler=1}if(C.status===y7)if(C.gzhead.extra){for(I=C.pending;C.gzindex<(C.gzhead.extra.length&65535)&&!(C.pending===C.pending_buf_size&&(C.gzhead.hcrc&&C.pending>I&&(g.adler=Yf(g.adler,C.pending_buf,C.pending-I,I)),Of(g),I=C.pending,C.pending===C.pending_buf_size));)dr(C,C.gzhead.extra[C.gzindex]&255),C.gzindex++;C.gzhead.hcrc&&C.pending>I&&(g.adler=Yf(g.adler,C.pending_buf,C.pending-I,I)),C.gzindex===C.gzhead.extra.length&&(C.gzindex=0,C.status=WX)}else C.status=WX;if(C.status===WX)if(C.gzhead.name){I=C.pending;do{if(C.pending===C.pending_buf_size&&(C.gzhead.hcrc&&C.pending>I&&(g.adler=Yf(g.adler,C.pending_buf,C.pending-I,I)),Of(g),I=C.pending,C.pending===C.pending_buf_size)){A=1;break}C.gzindexI&&(g.adler=Yf(g.adler,C.pending_buf,C.pending-I,I)),A===0&&(C.gzindex=0,C.status=NX)}else C.status=NX;if(C.status===NX)if(C.gzhead.comment){I=C.pending;do{if(C.pending===C.pending_buf_size&&(C.gzhead.hcrc&&C.pending>I&&(g.adler=Yf(g.adler,C.pending_buf,C.pending-I,I)),Of(g),I=C.pending,C.pending===C.pending_buf_size)){A=1;break}C.gzindexI&&(g.adler=Yf(g.adler,C.pending_buf,C.pending-I,I)),A===0&&(C.status=kX)}else C.status=kX;if(C.status===kX&&(C.gzhead.hcrc?(C.pending+2>C.pending_buf_size&&Of(g),C.pending+2<=C.pending_buf_size&&(dr(C,g.adler&255),dr(C,g.adler>>8&255),g.adler=0,C.status=$0)):C.status=$0),C.pending!==0){if(Of(g),g.avail_out===0)return C.last_flush=-1,$A}else if(g.avail_in===0&&Hbe(a)<=Hbe(s)&&a!==Kf)return Pf(g,p7);if(C.status===cT&&g.avail_in!==0)return Pf(g,p7);if(g.avail_in!==0||C.lookahead!==0||a!==j0&&C.status!==cT){var y=C.strategy===VX?Aht(C,a):C.strategy===Udt?cht(C,a):a1[C.level].func(C,a);if((y===q0||y===g1)&&(C.status=cT),y===Mo||y===q0)return g.avail_out===0&&(C.last_flush=-1),$A;if(y===AT&&(a===Pdt?lC._tr_align(C):a!==Vbe&&(lC._tr_stored_block(C,0,0,!1),a===zdt&&(zf(C.head),C.lookahead===0&&(C.strstart=0,C.block_start=0,C.insert=0))),Of(g),g.avail_out===0))return C.last_flush=-1,$A}return a!==Kf?$A:C.wrap<=0?Ebe:(C.wrap===2?(dr(C,g.adler&255),dr(C,g.adler>>8&255),dr(C,g.adler>>16&255),dr(C,g.adler>>24&255),dr(C,g.total_in&255),dr(C,g.total_in>>8&255),dr(C,g.total_in>>16&255),dr(C,g.total_in>>24&255)):(uT(C,g.adler>>>16),uT(C,g.adler&65535)),Of(g),C.wrap>0&&(C.wrap=-C.wrap),C.pending!==0?$A:Ebe)}function pht(g){var a;return!g||!g.state?CC:(a=g.state.status,a!==HX&&a!==y7&&a!==WX&&a!==NX&&a!==kX&&a!==$0&&a!==cT?Pf(g,CC):(g.state=null,a===$0?Pf(g,Odt):$A))}function bht(g,a){var s=a.length,C,I,A,d,h,y,Z,b;if(!g||!g.state||(C=g.state,d=C.wrap,d===2||d===1&&C.status!==HX||C.lookahead))return CC;for(d===1&&(g.adler=Rbe(g.adler,a,s,0)),C.wrap=0,s>=C.w_size&&(d===0&&(zf(C.head),C.strstart=0,C.block_start=0,C.insert=0),b=new xs.Buf8(C.w_size),xs.arraySet(b,a,s-C.w_size,C.w_size,0),a=b,s=C.w_size),h=g.avail_in,y=g.next_in,Z=g.input,g.avail_in=s,g.next_in=0,g.input=a,eb(C);C.lookahead>=tr;){I=C.strstart,A=C.lookahead-(tr-1);do C.ins_h=(C.ins_h<=252?6:Lf>=248?5:Lf>=240?4:Lf>=224?3:Lf>=192?2:1;dT[254]=dT[254]=1,tb.string2buf=function(g){var a,s,C,I,A,d=g.length,h=0;for(I=0;I>>6,a[A++]=128|s&63):s<65536?(a[A++]=224|s>>>12,a[A++]=128|s>>>6&63,a[A++]=128|s&63):(a[A++]=240|s>>>18,a[A++]=128|s>>>12&63,a[A++]=128|s>>>6&63,a[A++]=128|s&63);return a};function Mbe(g,a){if(a<65534&&(g.subarray&&Dbe||!g.subarray&&xbe))return String.fromCharCode.apply(null,XX.shrinkBuf(g,a));for(var s="",C=0;C4){h[C++]=65533,s+=A-1;continue}for(I&=A===2?31:A===3?15:7;A>1&&s1){h[C++]=65533;continue}I<65536?h[C++]=I:(I-=65536,h[C++]=55296|I>>10&1023,h[C++]=56320|I&1023)}return Mbe(h,C)},tb.utf8border=function(g,a){var s;for(a=a||g.length,a>g.length&&(a=g.length),s=a-1;s>=0&&(g[s]&192)===128;)s--;return s<0||s===0?a:s+dT[g[s]]>a?s:a};function yht(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var Fbe=yht,hT=QA,fT=Ud,Z7=tb,B7=m7,vht=Fbe,Ybe=Object.prototype.toString,Zht=0,G7=4,s1=0,Kbe=1,_be=2,Bht=-1,Ght=0,Sht=8;function ib(g){if(!(this instanceof ib))return new ib(g);this.options=fT.assign({level:Bht,method:Sht,chunkSize:16384,windowBits:15,memLevel:8,strategy:Ght,to:""},g||{});var a=this.options;a.raw&&a.windowBits>0?a.windowBits=-a.windowBits:a.gzip&&a.windowBits>0&&a.windowBits<16&&(a.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new vht,this.strm.avail_out=0;var s=hT.deflateInit2(this.strm,a.level,a.method,a.windowBits,a.memLevel,a.strategy);if(s!==s1)throw new Error(B7[s]);if(a.header&&hT.deflateSetHeader(this.strm,a.header),a.dictionary){var C;if(typeof a.dictionary=="string"?C=Z7.string2buf(a.dictionary):Ybe.call(a.dictionary)==="[object ArrayBuffer]"?C=new Uint8Array(a.dictionary):C=a.dictionary,s=hT.deflateSetDictionary(this.strm,C),s!==s1)throw new Error(B7[s]);this._dict_set=!0}}ib.prototype.push=function(g,a){var s=this.strm,C=this.options.chunkSize,I,A;if(this.ended)return!1;A=a===~~a?a:a===!0?G7:Zht,typeof g=="string"?s.input=Z7.string2buf(g):Ybe.call(g)==="[object ArrayBuffer]"?s.input=new Uint8Array(g):s.input=g,s.next_in=0,s.avail_in=s.input.length;do{if(s.avail_out===0&&(s.output=new fT.Buf8(C),s.next_out=0,s.avail_out=C),I=hT.deflate(s,A),I!==Kbe&&I!==s1)return this.onEnd(I),this.ended=!0,!1;(s.avail_out===0||s.avail_in===0&&(A===G7||A===_be))&&(this.options.to==="string"?this.onData(Z7.buf2binstring(fT.shrinkBuf(s.output,s.next_out))):this.onData(fT.shrinkBuf(s.output,s.next_out)))}while((s.avail_in>0||s.avail_out===0)&&I!==Kbe);return A===G7?(I=hT.deflateEnd(this.strm),this.onEnd(I),this.ended=!0,I===s1):(A===_be&&(this.onEnd(s1),s.avail_out=0),!0)},ib.prototype.onData=function(g){this.chunks.push(g)},ib.prototype.onEnd=function(g){g===s1&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=fT.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg};function S7(g,a){var s=new ib(a);if(s.push(g,!0),s.err)throw s.msg||B7[s.err];return s.result}function wht(g,a){return a=a||{},a.raw=!0,S7(g,a)}function Tht(g,a){return a=a||{},a.gzip=!0,S7(g,a)}gT.Deflate=ib,gT.deflate=S7,gT.deflateRaw=wht,gT.gzip=Tht;var mT={},Cc={},xX=30,Rht=12,Vht=function(a,s){var C,I,A,d,h,y,Z,b,w,S,R,H,N,D,M,z,K,P,J,j,ie,te,Ce,ue,oe;C=a.state,I=a.next_in,ue=a.input,A=I+(a.avail_in-5),d=a.next_out,oe=a.output,h=d-(s-a.avail_out),y=d+(a.avail_out-257),Z=C.dmax,b=C.wsize,w=C.whave,S=C.wnext,R=C.window,H=C.hold,N=C.bits,D=C.lencode,M=C.distcode,z=(1<>>24,H>>>=J,N-=J,J=P>>>16&255,J===0)oe[d++]=P&65535;else if(J&16){j=P&65535,J&=15,J&&(N>>=J,N-=J),N<15&&(H+=ue[I++]<>>24,H>>>=J,N-=J,J=P>>>16&255,J&16){if(ie=P&65535,J&=15,NZ){a.msg="invalid distance too far back",C.mode=xX;break e}if(H>>>=J,N-=J,J=d-h,ie>J){if(J=ie-J,J>w&&C.sane){a.msg="invalid distance too far back",C.mode=xX;break e}if(te=0,Ce=R,S===0){if(te+=b-J,J2;)oe[d++]=Ce[te++],oe[d++]=Ce[te++],oe[d++]=Ce[te++],j-=3;j&&(oe[d++]=Ce[te++],j>1&&(oe[d++]=Ce[te++]))}else{te=d-ie;do oe[d++]=oe[te++],oe[d++]=oe[te++],oe[d++]=oe[te++],j-=3;while(j>2);j&&(oe[d++]=oe[te++],j>1&&(oe[d++]=oe[te++]))}}else if(J&64){a.msg="invalid distance code",C.mode=xX;break e}else{P=M[(P&65535)+(H&(1<>3,I-=j,N-=j<<3,H&=(1<=1&&he[R]===0;R--);if(H>R&&(H=R),R===0)return A[d++]=1<<24|64<<16|0,A[d++]=1<<24|64<<16|0,y.bits=1,0;for(S=1;S0&&(a===Lbe||R!==1))return-1;for(ye[1]=0,b=1;bzbe||a===Jbe&&z>Obe)return 1;for(;;){We=b-D,h[w]oe?(_e=Ie[fe+h[w]],qe=Ce[ue+h[w]]):(_e=32+64,qe=0),P=1<>D)+J]=We<<24|_e<<16|qe|0;while(J!==0);for(P=1<>=1;if(P!==0?(K&=P-1,K+=P):K=0,w++,--he[b]===0){if(b===R)break;b=s[C+h[w]]}if(b>H&&(K&ie)!==j){for(D===0&&(D=H),te+=S,N=b-D,M=1<zbe||a===Jbe&&z>Obe)return 1;j=K&ie,A[j]=H<<24|N<<16|te-d|0}}return K!==0&&(A[te+K]=b-D<<24|64<<16|0),y.bits=H,0},vl=Ud,T7=wbe,eu=Tbe,Xht=Vht,pT=kht,xht=0,Ube=1,Qbe=2,jbe=4,Dht=5,DX=6,nb=0,Mht=1,Fht=2,cC=-2,$be=-3,qbe=-4,Yht=-5,eye=8,tye=1,iye=2,nye=3,rye=4,gye=5,oye=6,aye=7,sye=8,Iye=9,lye=10,MX=11,jd=12,R7=13,Cye=14,V7=15,cye=16,Aye=17,uye=18,dye=19,FX=20,YX=21,hye=22,fye=23,mye=24,pye=25,bye=26,E7=27,yye=28,vye=29,Rg=30,Zye=31,Kht=32,_ht=852,Pht=592,zht=15,Oht=zht;function Bye(g){return(g>>>24&255)+(g>>>8&65280)+((g&65280)<<8)+((g&255)<<24)}function Lht(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new vl.Buf16(320),this.work=new vl.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Gye(g){var a;return!g||!g.state?cC:(a=g.state,g.total_in=g.total_out=a.total=0,g.msg="",a.wrap&&(g.adler=a.wrap&1),a.mode=tye,a.last=0,a.havedict=0,a.dmax=32768,a.head=null,a.hold=0,a.bits=0,a.lencode=a.lendyn=new vl.Buf32(_ht),a.distcode=a.distdyn=new vl.Buf32(Pht),a.sane=1,a.back=-1,nb)}function Sye(g){var a;return!g||!g.state?cC:(a=g.state,a.wsize=0,a.whave=0,a.wnext=0,Gye(g))}function wye(g,a){var s,C;return!g||!g.state||(C=g.state,a<0?(s=0,a=-a):(s=(a>>4)+1,a<48&&(a&=15)),a&&(a<8||a>15))?cC:(C.window!==null&&C.wbits!==a&&(C.window=null),C.wrap=s,C.wbits=a,Sye(g))}function Tye(g,a){var s,C;return g?(C=new Lht,g.state=C,C.window=null,s=wye(g,a),s!==nb&&(g.state=null),s):cC}function Jht(g){return Tye(g,Oht)}var Rye=!0,H7,W7;function Uht(g){if(Rye){var a;for(H7=new vl.Buf32(512),W7=new vl.Buf32(32),a=0;a<144;)g.lens[a++]=8;for(;a<256;)g.lens[a++]=9;for(;a<280;)g.lens[a++]=7;for(;a<288;)g.lens[a++]=8;for(pT(Ube,g.lens,0,288,H7,0,g.work,{bits:9}),a=0;a<32;)g.lens[a++]=5;pT(Qbe,g.lens,0,32,W7,0,g.work,{bits:5}),Rye=!1}g.lencode=H7,g.lenbits=9,g.distcode=W7,g.distbits=5}function Vye(g,a,s,C){var I,A=g.state;return A.window===null&&(A.wsize=1<=A.wsize?(vl.arraySet(A.window,a,s-A.wsize,A.wsize,0),A.wnext=0,A.whave=A.wsize):(I=A.wsize-A.wnext,I>C&&(I=C),vl.arraySet(A.window,a,s-C,I,A.wnext),C-=I,C?(vl.arraySet(A.window,a,s-C,C,0),A.wnext=C,A.whave=A.wsize):(A.wnext+=I,A.wnext===A.wsize&&(A.wnext=0),A.whave>>8&255,s.check=eu(s.check,Ce,2,0),Z=0,b=0,s.mode=iye;break}if(s.flags=0,s.head&&(s.head.done=!1),!(s.wrap&1)||(((Z&255)<<8)+(Z>>8))%31){g.msg="incorrect header check",s.mode=Rg;break}if((Z&15)!==eye){g.msg="unknown compression method",s.mode=Rg;break}if(Z>>>=4,b-=4,ie=(Z&15)+8,s.wbits===0)s.wbits=ie;else if(ie>s.wbits){g.msg="invalid window size",s.mode=Rg;break}s.dmax=1<>8&1),s.flags&512&&(Ce[0]=Z&255,Ce[1]=Z>>>8&255,s.check=eu(s.check,Ce,2,0)),Z=0,b=0,s.mode=nye;case nye:for(;b<32;){if(h===0)break e;h--,Z+=C[A++]<>>8&255,Ce[2]=Z>>>16&255,Ce[3]=Z>>>24&255,s.check=eu(s.check,Ce,4,0)),Z=0,b=0,s.mode=rye;case rye:for(;b<16;){if(h===0)break e;h--,Z+=C[A++]<>8),s.flags&512&&(Ce[0]=Z&255,Ce[1]=Z>>>8&255,s.check=eu(s.check,Ce,2,0)),Z=0,b=0,s.mode=gye;case gye:if(s.flags&1024){for(;b<16;){if(h===0)break e;h--,Z+=C[A++]<>>8&255,s.check=eu(s.check,Ce,2,0)),Z=0,b=0}else s.head&&(s.head.extra=null);s.mode=oye;case oye:if(s.flags&1024&&(R=s.length,R>h&&(R=h),R&&(s.head&&(ie=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),vl.arraySet(s.head.extra,C,A,R,ie)),s.flags&512&&(s.check=eu(s.check,C,R,A)),h-=R,A+=R,s.length-=R),s.length))break e;s.length=0,s.mode=aye;case aye:if(s.flags&2048){if(h===0)break e;R=0;do ie=C[A+R++],s.head&&ie&&s.length<65536&&(s.head.name+=String.fromCharCode(ie));while(ie&&R>9&1,s.head.done=!0),g.adler=s.check=0,s.mode=jd;break;case lye:for(;b<32;){if(h===0)break e;h--,Z+=C[A++]<>>=b&7,b-=b&7,s.mode=E7;break}for(;b<3;){if(h===0)break e;h--,Z+=C[A++]<>>=1,b-=1,Z&3){case 0:s.mode=Cye;break;case 1:if(Uht(s),s.mode=FX,a===DX){Z>>>=2,b-=2;break e}break;case 2:s.mode=Aye;break;case 3:g.msg="invalid block type",s.mode=Rg}Z>>>=2,b-=2;break;case Cye:for(Z>>>=b&7,b-=b&7;b<32;){if(h===0)break e;h--,Z+=C[A++]<>>16^65535)){g.msg="invalid stored block lengths",s.mode=Rg;break}if(s.length=Z&65535,Z=0,b=0,s.mode=V7,a===DX)break e;case V7:s.mode=cye;case cye:if(R=s.length,R){if(R>h&&(R=h),R>y&&(R=y),R===0)break e;vl.arraySet(I,C,A,R,d),h-=R,A+=R,y-=R,d+=R,s.length-=R;break}s.mode=jd;break;case Aye:for(;b<14;){if(h===0)break e;h--,Z+=C[A++]<>>=5,b-=5,s.ndist=(Z&31)+1,Z>>>=5,b-=5,s.ncode=(Z&15)+4,Z>>>=4,b-=4,s.nlen>286||s.ndist>30){g.msg="too many length or distance symbols",s.mode=Rg;break}s.have=0,s.mode=uye;case uye:for(;s.have>>=3,b-=3}for(;s.have<19;)s.lens[he[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,ue={bits:s.lenbits},te=pT(xht,s.lens,0,19,s.lencode,0,s.work,ue),s.lenbits=ue.bits,te){g.msg="invalid code lengths set",s.mode=Rg;break}s.have=0,s.mode=dye;case dye:for(;s.have>>24,z=D>>>16&255,K=D&65535,!(M<=b);){if(h===0)break e;h--,Z+=C[A++]<>>=M,b-=M,s.lens[s.have++]=K;else{if(K===16){for(oe=M+2;b>>=M,b-=M,s.have===0){g.msg="invalid bit length repeat",s.mode=Rg;break}ie=s.lens[s.have-1],R=3+(Z&3),Z>>>=2,b-=2}else if(K===17){for(oe=M+3;b>>=M,b-=M,ie=0,R=3+(Z&7),Z>>>=3,b-=3}else{for(oe=M+7;b>>=M,b-=M,ie=0,R=11+(Z&127),Z>>>=7,b-=7}if(s.have+R>s.nlen+s.ndist){g.msg="invalid bit length repeat",s.mode=Rg;break}for(;R--;)s.lens[s.have++]=ie}}if(s.mode===Rg)break;if(s.lens[256]===0){g.msg="invalid code -- missing end-of-block",s.mode=Rg;break}if(s.lenbits=9,ue={bits:s.lenbits},te=pT(Ube,s.lens,0,s.nlen,s.lencode,0,s.work,ue),s.lenbits=ue.bits,te){g.msg="invalid literal/lengths set",s.mode=Rg;break}if(s.distbits=6,s.distcode=s.distdyn,ue={bits:s.distbits},te=pT(Qbe,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,ue),s.distbits=ue.bits,te){g.msg="invalid distances set",s.mode=Rg;break}if(s.mode=FX,a===DX)break e;case FX:s.mode=YX;case YX:if(h>=6&&y>=258){g.next_out=d,g.avail_out=y,g.next_in=A,g.avail_in=h,s.hold=Z,s.bits=b,Xht(g,S),d=g.next_out,I=g.output,y=g.avail_out,A=g.next_in,C=g.input,h=g.avail_in,Z=s.hold,b=s.bits,s.mode===jd&&(s.back=-1);break}for(s.back=0;D=s.lencode[Z&(1<>>24,z=D>>>16&255,K=D&65535,!(M<=b);){if(h===0)break e;h--,Z+=C[A++]<>P)],M=D>>>24,z=D>>>16&255,K=D&65535,!(P+M<=b);){if(h===0)break e;h--,Z+=C[A++]<>>=P,b-=P,s.back+=P}if(Z>>>=M,b-=M,s.back+=M,s.length=K,z===0){s.mode=bye;break}if(z&32){s.back=-1,s.mode=jd;break}if(z&64){g.msg="invalid literal/length code",s.mode=Rg;break}s.extra=z&15,s.mode=hye;case hye:if(s.extra){for(oe=s.extra;b>>=s.extra,b-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=fye;case fye:for(;D=s.distcode[Z&(1<>>24,z=D>>>16&255,K=D&65535,!(M<=b);){if(h===0)break e;h--,Z+=C[A++]<>P)],M=D>>>24,z=D>>>16&255,K=D&65535,!(P+M<=b);){if(h===0)break e;h--,Z+=C[A++]<>>=P,b-=P,s.back+=P}if(Z>>>=M,b-=M,s.back+=M,z&64){g.msg="invalid distance code",s.mode=Rg;break}s.offset=K,s.extra=z&15,s.mode=mye;case mye:if(s.extra){for(oe=s.extra;b>>=s.extra,b-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){g.msg="invalid distance too far back",s.mode=Rg;break}s.mode=pye;case pye:if(y===0)break e;if(R=S-y,s.offset>R){if(R=s.offset-R,R>s.whave&&s.sane){g.msg="invalid distance too far back",s.mode=Rg;break}R>s.wnext?(R-=s.wnext,H=s.wsize-R):H=s.wnext-R,R>s.length&&(R=s.length),N=s.window}else N=I,H=d-s.offset,R=s.length;R>y&&(R=y),y-=R,s.length-=R;do I[d++]=N[H++];while(--R);s.length===0&&(s.mode=YX);break;case bye:if(y===0)break e;I[d++]=s.length,y--,s.mode=YX;break;case E7:if(s.wrap){for(;b<32;){if(h===0)break e;h--,Z|=C[A++]<=0&&a.windowBits<16&&(a.windowBits=-a.windowBits,a.windowBits===0&&(a.windowBits=-15)),a.windowBits>=0&&a.windowBits<16&&!(g&&g.windowBits)&&(a.windowBits+=32),a.windowBits>15&&a.windowBits<48&&(a.windowBits&15||(a.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ift,this.strm.avail_out=0;var s=l1.inflateInit2(this.strm,a.windowBits);if(s!==uo.Z_OK)throw new Error(N7[s]);if(this.header=new nft,l1.inflateGetHeader(this.strm,this.header),a.dictionary&&(typeof a.dictionary=="string"?a.dictionary=KX.string2buf(a.dictionary):Hye.call(a.dictionary)==="[object ArrayBuffer]"&&(a.dictionary=new Uint8Array(a.dictionary)),a.raw&&(s=l1.inflateSetDictionary(this.strm,a.dictionary),s!==uo.Z_OK)))throw new Error(N7[s])}rb.prototype.push=function(g,a){var s=this.strm,C=this.options.chunkSize,I=this.options.dictionary,A,d,h,y,Z,b=!1;if(this.ended)return!1;d=a===~~a?a:a===!0?uo.Z_FINISH:uo.Z_NO_FLUSH,typeof g=="string"?s.input=KX.binstring2buf(g):Hye.call(g)==="[object ArrayBuffer]"?s.input=new Uint8Array(g):s.input=g,s.next_in=0,s.avail_in=s.input.length;do{if(s.avail_out===0&&(s.output=new bT.Buf8(C),s.next_out=0,s.avail_out=C),A=l1.inflate(s,uo.Z_NO_FLUSH),A===uo.Z_NEED_DICT&&I&&(A=l1.inflateSetDictionary(this.strm,I)),A===uo.Z_BUF_ERROR&&b===!0&&(A=uo.Z_OK,b=!1),A!==uo.Z_STREAM_END&&A!==uo.Z_OK)return this.onEnd(A),this.ended=!0,!1;s.next_out&&(s.avail_out===0||A===uo.Z_STREAM_END||s.avail_in===0&&(d===uo.Z_FINISH||d===uo.Z_SYNC_FLUSH))&&(this.options.to==="string"?(h=KX.utf8border(s.output,s.next_out),y=s.next_out-h,Z=KX.buf2string(s.output,h),s.next_out=y,s.avail_out=C-y,y&&bT.arraySet(s.output,s.output,h,y,0),this.onData(Z)):this.onData(bT.shrinkBuf(s.output,s.next_out))),s.avail_in===0&&s.avail_out===0&&(b=!0)}while((s.avail_in>0||s.avail_out===0)&&A!==uo.Z_STREAM_END);return A===uo.Z_STREAM_END&&(d=uo.Z_FINISH),d===uo.Z_FINISH?(A=l1.inflateEnd(this.strm),this.onEnd(A),this.ended=!0,A===uo.Z_OK):(d===uo.Z_SYNC_FLUSH&&(this.onEnd(uo.Z_OK),s.avail_out=0),!0)},rb.prototype.onData=function(g){this.chunks.push(g)},rb.prototype.onEnd=function(g){g===uo.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=bT.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg};function k7(g,a){var s=new rb(a);if(s.push(g,!0),s.err)throw s.msg||N7[s.err];return s.result}function rft(g,a){return a=a||{},a.raw=!0,k7(g,a)}mT.Inflate=rb,mT.inflate=k7,mT.inflateRaw=rft,mT.ungzip=k7;var gft=Ud.assign,oft=gT,aft=mT,sft=Eye,Wye={};gft(Wye,oft,aft,sft);var Ift=Wye,lft=["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"];const Cft=lft;function cft(g){if(typeof g!="string")throw new TypeError("input must be a string");let a=[],s,C,I={LOCUS_TAG:"LOCUS",DEFINITION_TAG:"DEFINITION",ACCESSION_TAG:"ACCESSION",VERSION_TAG:"VERSION",KEYWORDS_TAG:"KEYWORDS",SOURCE_TAG:"SOURCE",ORGANISM_TAG:"ORGANISM",REFERENCE_TAG:"REFERENCE",AUTHORS_TAG:"AUTHORS",CONSORTIUM_TAG:"CONSRTM",TITLE_TAG:"TITLE",JOURNAL_TAG:"JOURNAL",PUBMED_TAG:"PUBMED",REMARK_TAG:"REMARK",FEATURES_TAG:"FEATURES",BASE_COUNT_TAG:"BASE COUNT",ORIGIN_TAG:"ORIGIN",END_SEQUENCE_TAG:"//"},A=g.split(/\r?\n/),d,h,y,Z,b,w=!1;for(let Ie of A){if(Ie===null)break;let fe=te(Ie),We=ue(Ie),_e=he(Ie),qe=oe(Ie);if(fe===I.END_SEQUENCE_TAG||qe?(d=fe,h=null):_e&&(h=fe),!(Ie.trim()===""||fe===";")){if(!w&&d!==I.LOCUS_TAG)break;switch(d){case I.LOCUS_TAG:w=!0,D(Ie);break;case I.FEATURES_TAG:K(Ie,fe,We);break;case I.ORIGIN_TAG:N(Ie,fe);break;case I.DEFINITION_TAG:case I.ACCESSION_TAG:case I.VERSION_TAG:case I.KEYWORDS_TAG:Ce(d,Ie,d.toLowerCase());break;case I.SOURCE_TAG:h===I.ORGANISM_TAG?Ce(h,Ie,"organism"):Ce(fe,Ie,"source");break;case I.REFERENCE_TAG:if(fe===I.REFERENCE_TAG){const nt=s.references||[];s.references=nt,nt.push({})}z(Ie,h);break;case I.END_SEQUENCE_TAG:S();break}}}return a[a.length-1]!==s&&S(),a;function S(){H(),a.push(s)}function R(){return s.features[s.features.length-1]}function H(){if(s&&s.features)for(let Ie=0;Ie0;a--){const s=Math.floor(Math.random()*(a+1)),C=g[a];g[a]=g[s],g[s]=C}return g}function hft(g){const a=g.end-g.start,s=g.strand===1?"+":"-",C=Fn.nice();return g.type==="filler"?{xStart:g.start,xEnd:g.end,strand:g.strand,fields:[],type:"filler",uid:C}:{xStart:g.start,xEnd:g.end,strand:s,chrOffset:0,importance:g.end-g.start,uid:C,type:g.type,fields:["chrom",g.start,g.end,g.name,a,s,"","",g.type,g.name,g.start.toString(),g.end.toString(),g.start.toString(),g.end.toString()]}}const Xye=g=>{const a=uft(g),s=dft(a[0].features.filter(C=>C.type!=="source").sort((C,I)=>C.start-I.start));return[a,s]};let xye=function(){function g(a){if(T(this,g),this.dataConfig=a,this.trackUid=Fn.nice(),a.url){const C=a.url.slice(a.url.length-3)===".gz";this.errorTxt="",this.dataPromise=fetch(a.url,{mode:"cors",redirect:"follow",method:"GET"}).then(I=>C?I.arrayBuffer():I.text()).then(I=>{const A=C?Ift.inflate(I,{to:"string"}):I;[this.gbJson,this.cdss]=Xye(A)})}else a.text&&(this.dataPromise=new Promise((s,C)=>{[this.gbJson,this.cdss]=Xye(a.text),s()}))}return E(g,[{key:"tilesetInfo",value:function(s){return this.tilesetInfoLoading=!0,this.dataPromise.then(()=>{this.tilesetInfoLoading=!1;const C=1024;let I={};return I={tile_size:C,max_zoom:Math.ceil(Math.log(this.gbJson[0].size/C)/Math.log(2)),max_width:this.gbJson[0].size,min_pos:[0],max_pos:[this.gbJson[0].size]},s&&s(I),I}).catch(C=>{this.tilesetInfoLoading=!1,s&&s({error:`Error parsing genbank: ${C}`})})}},{key:"fetchTilesDebounced",value:function(s,C){const I={},A=[],d=[];for(const h of C){const y=h.split("."),Z=parseInt(y[0],10),b=parseInt(y[1],10);if(Number.isNaN(b)||Number.isNaN(Z)){console.warn("Invalid tile zoom or position:",Z,b);continue}A.push(h),d.push(this.tile(Z,b))}return Promise.all(d).then(h=>{for(let y=0;y{const A=+I.max_width/2**+s,d=I.min_pos[0]+C*A,h=I.min_pos[0]+(C+1)*A,y=this.cdss.filter(H=>H.end>d&&H.startH.strand===1),Z),w=kye(y.filter(H=>H.strand!==1),Z);b.forEach(H=>{H.strand="+"}),w.forEach(H=>{H.strand="-"});let S=[];const R=20;for(let H=0;H=R);H++)this.cdss[H].end>=d&&this.cdss[H].start<=h&&S.push(this.cdss[H]);return S=[...S,...b,...w],S.map(H=>hft(H))})}}]),g}(),Dye=function(){function g(a){T(this,g),this.dataConfig=a,this.tilesetInfoData=Object.values(this.dataConfig.tilesetInfo)[0]}return E(g,[{key:"tilesetInfo",value:function(s){this.tilesetInfoLoading=!1,s(this.tilesetInfoData)}},{key:"fetchTilesDebounced",value:function(s,C){this.tilesData={};for(const d of Object.keys(this.dataConfig.tiles)){const y=`localtile.${d.split(".").slice(1).join(".")}`;this.tilesData[y]=this.dataConfig.tiles[d]}const I={},A=C.map(d=>`localtile.${d}`);HU(this.tilesData,"",A);for(const d of C)I[d]=this.tilesData[`localtile.${d}`];s(I)}},{key:"tile",value:function(s,C){}}]),g}(),fft=function(){function g(){T(this,g),this.taskList=[],this.taskHandle=null,this.requestIdleCallbackTimeout=300}return E(g,[{key:"enqueueTask",value:function(s,C,I=null){I===null?this.taskList.push({handler:s,data:C}):(this.taskList=this.taskList.filter(A=>A.trackId!==I),this.taskList.push({handler:s,data:C,trackId:I})),this.taskHandle||(this.taskHandle=requestIdleCallback(this.runTaskQueue.bind(this),{timeout:this.requestIdleCallbackTimeout}))}},{key:"runTaskQueue",value:function(s){for(;(s.timeRemaining()>0||s.didTimeout)&&this.taskList.length;){const C=this.taskList.shift();C.data===null?C.handler():C.handler(C.data)}this.taskList.length?this.taskHandle=requestIdleCallback(this.runTaskQueue.bind(this),{timeout:this.requestIdleCallbackTimeout}):this.taskHandle=0}}]),g}();const mft=new fft;function pft(g,a,s,C,I){const A=g||I,d=0;return A==="log"&&a>0?["log",Wf().range([254,0]).domain([a+d,C+d])]:["linear",Zn().range([254,0]).domain([a,C])]}let Jf=function(g){o(s,g);var a=l(s);function s(C,I){var A;T(this,s),A=a.call(this,C,I);const{pubSub:d,dataConfig:h,handleTilesetInfoReceived:y,animate:Z,onValueScaleChanged:b}=C;return A.renderVersion=1,A.visibleTiles=new Set,A.visibleTileIds=new Set,A.renderingTiles=new Set,A.fetching=new Set,A.scale={},A.fetchedTiles={},A.tileGraphics={},A.maxZoom=0,A.medianVisibleValue=null,A.backgroundTaskScheduler=mft,A.continuousScaling="requestIdleCallback"in window,A.valueScaleMin=null,A.fixedValueScaleMin=null,A.valueScaleMax=null,A.fixedValueScaleMax=null,A.listeners={},A.pubSub=d,A.animate=Z,A.onValueScaleChanged=b,A.prevValueScale=null,C.dataFetcher?A.dataFetcher=C.dataFetcher:A.dataFetcher=new wX(h,A.pubSub),A.tilesetInfo=null,A.uuid=Fn.nice(),A.trackNotFoundText=new $t.PIXI.Text("",{fontSize:"12px",fontFamily:"Arial",fill:"black"}),A.pLabel.addChild(A.trackNotFoundText),A.refreshTilesDebounced=x0e(A.refreshTiles.bind(u(A)),$k,$k),A.dataFetcher.tilesetInfo((w,S)=>{if(w){if(A.tilesetInfo=w,A.dataFetcher.dataConfig.tilesetUid||(A.dataFetcher.dataConfig.tilesetUid=S),A.tilesetUid=A.dataFetcher.dataConfig.tilesetUid,A.server=A.dataFetcher.dataConfig.server||"unknown",A.tilesetInfo&&A.tilesetInfo.chromsizes&&(A.chromInfo=sX(A.tilesetInfo.chromsizes)),"error"in A.tilesetInfo){console.warn("Error retrieving tilesetInfo:",h,A.tilesetInfo.error),A.tilesetInfo=null,A.setError(A.tilesetInfo.error);return}A.tilesetInfo.resolutions?A.maxZoom=A.tilesetInfo.resolutions.length:A.maxZoom=+A.tilesetInfo.max_zoom,A.options&&A.options.maxZoom&&(A.options.maxZoom>=0?A.maxZoom=Math.min(A.options.maxZoom,A.maxZoom):console.error("Invalid maxZoom on track:",u(A))),A.refreshTiles(),y&&y(w),A.options||(A.options={}),A.options.name=A.options.name||w.name,A.checkValueScaleLimits(),A.draw(),A.drawLabel(),A.animate()}}),A}return E(s,[{key:"setError",value:function(I){this.errorTextText=I,this.draw(),this.animate()}},{key:"setFixedValueScaleMin",value:function(I){Number.isNaN(+I)?this.fixedValueScaleMin=null:this.fixedValueScaleMin=+I}},{key:"setFixedValueScaleMax",value:function(I){Number.isNaN(+I)?this.fixedValueScaleMax=null:this.fixedValueScaleMax=+I}},{key:"checkValueScaleLimits",value:function(){this.valueScaleMin=typeof this.options.valueScaleMin<"u"?+this.options.valueScaleMin:null,this.fixedValueScaleMin!==null&&(this.valueScaleMin=this.fixedValueScaleMin),this.valueScaleMax=typeof this.options.valueScaleMax<"u"?+this.options.valueScaleMax:null,this.fixedValueScaleMax!==null&&(this.valueScaleMax=this.fixedValueScaleMax)}},{key:"on",value:function(I,A){this.listeners[I]||(this.listeners[I]=[]),this.listeners[I].push(A)}},{key:"off",value:function(I,A){const d=this.listeners[I].indexOf(A);d===-1||d>=this.listeners[I].length||this.listeners[I].splice(d,1)}},{key:"rerender",value:function(I){n(G(s.prototype),"rerender",this).call(this,I),this.renderVersion+=1,this.tilesetInfo&&(this.checkValueScaleLimits(),this.tilesetInfo.resolutions?this.maxZoom=this.tilesetInfo.resolutions.length:this.maxZoom=+this.tilesetInfo.max_zoom,this.options&&this.options.maxZoom&&(this.options.maxZoom>=0?this.maxZoom=Math.min(this.options.maxZoom,this.maxZoom):console.error("Invalid maxZoom on track:",this)))}},{key:"visibleAndFetchedIds",value:function(){return Object.keys(this.fetchedTiles).filter(I=>this.visibleTileIds.has(I))}},{key:"visibleAndFetchedTiles",value:function(){return this.visibleAndFetchedIds().map(I=>this.fetchedTiles[I])}},{key:"setVisibleTiles",value:function(I){this.visibleTiles=I.map(A=>({tileId:this.tileToLocalId(A),remoteId:this.tileToRemoteId(A),mirrored:A.mirrored})),this.visibleTileIds=new Set(this.visibleTiles.map(A=>A.tileId))}},{key:"removeOldTiles",value:function(){this.calculateVisibleTiles();const A=[...new Set(Object.keys(this.fetchedTiles))].filter(d=>!this.visibleTileIds.has(d));this.removeTiles(A)}},{key:"refreshTiles",value:function(){if(!this.tilesetInfo)return;this.calculateVisibleTiles();const I=new Set(Object.keys(this.fetchedTiles)),A=[...this.visibleTiles].filter(d=>!this.fetching.has(d.remoteId)&&!I.has(d.tileId));for(let d=0;d0;)if(d-=1,h=h.map(Z=>Math.floor(Z/2)),`${A}.${d}.${h.join(".")}`in this.fetchedTiles)return!0;return!1}},{key:"parentTileId",value:function(I){const A=I.tileData.zoomLevel-1,d=I.tileData.tilePos.map(y=>Math.floor(y/2));return`${I.tileData.tilesetUid}.${A}.${d.join(".")}`}},{key:"removeTiles",value:function(I){!I.length||!this.areAllVisibleTilesLoaded()||this.renderingTiles.size||(I.forEach(A=>{const d=A;this.destroyTile(this.fetchedTiles[d]),d in this.tileGraphics&&(this.pMain.removeChild(this.tileGraphics[d]),delete this.tileGraphics[d]),delete this.fetchedTiles[d]}),this.synchronizeTilesAndGraphics(),this.draw())}},{key:"zoomed",value:function(I,A,d=1,h=0,y=0){this.xScale(I),this.yScale(A),this.refreshTilesDebounced(),this.pMobile.position.x=h,this.pMobile.position.y=this.position[1],this.pMobile.scale.x=d,this.pMobile.scale.y=1}},{key:"setPosition",value:function(I){n(G(s.prototype),"setPosition",this).call(this,I)}},{key:"setDimensions",value:function(I){n(G(s.prototype),"setDimensions",this).call(this,I)}},{key:"areAllVisibleTilesLoaded",value:function(){const I=new Set(Object.keys(this.fetchedTiles)),A=[...this.visibleTileIds];for(let d=0;dA.tileData))}},{key:"loadTileData",value:function(I,A){let d=this.lruCache.get(I.tileId);return d||(d=A(I.data,I.type),this.lruCache.put(I.tileId,d)),d}},{key:"fetchNewTiles",value:function(I){if(I.length>0){const A=[...new Set(I.map(d=>d.remoteId))];this.dataFetcher.fetchTilesDebounced(this.receivedTiles.bind(this),A)}}},{key:"receivedTiles",value:function(I){for(let A=0;ANumber.isNaN(+y)).forEach(y=>{this.fetchedTiles[d].tileData[y]=h[y]})}else this.fetchedTiles[d].tileData={...I[this.visibleTiles[A].remoteId]};this.fetchedTiles[d].tileData.error&&console.warn("Error in loaded tile",d,this.fetchedTiles[d].tileData)}}for(const A in I)if(I[A]){const d=I[A].tilePositionId;this.fetching.has(d)&&this.fetching.delete(d)}this.synchronizeTilesAndGraphics(),this.draw(),this.drawLabel(),this.valueScale&&(!this.prevValueScale||JSON.stringify(this.valueScale.domain())!==JSON.stringify(this.prevValueScale.domain()))&&(this.prevValueScale=this.valueScale.copy(),this.onValueScaleChanged&&this.onValueScaleChanged()),this.animate(),this.areAllVisibleTilesLoaded()&&this.pubSub&&this.pubSub.publish("TiledPixiTrack.tilesLoaded",{uuid:this.uuid})}},{key:"draw",value:function(){if(this.delayDrawing)return;this.tilesetInfo?this.trackNotFoundText.visible=!1:(this.dataFetcher.tilesetInfoLoading?this.trackNotFoundText.text="Loading...":this.trackNotFoundText.text=`Tileset info not found. Server: [${this.server}] tilesetUid: [${this.tilesetUid}]`,[this.trackNotFoundText.x,this.trackNotFoundText.y]=this.position,this.flipText&&(this.trackNotFoundText.anchor.x=1,this.trackNotFoundText.scale.x=-1),this.trackNotFoundText.visible=!0),this.pubSub&&this.pubSub.publish("TiledPixiTrack.tilesDrawnStart",{uuid:this.uuid});const I=Object.values(this.fetchedTiles).map(A=>A.tileData&&A.tileData.error&&`${A.tileId}: ${A.tileData.error}`).filter(A=>A);I.length?this.errorTextText=I.join(` -`):this.errorTextText="",n(G(s.prototype),"draw",this).call(this),Object.keys(this.fetchedTiles).forEach(A=>{this.drawTile(this.fetchedTiles[A])}),this.pubSub&&this.pubSub.publish("TiledPixiTrack.tilesDrawnEnd",{uuid:this.uuid})}},{key:"drawTile",value:function(){}},{key:"calculateMedianVisibleValue",value:function(){this.areAllVisibleTilesLoaded()&&this.allTilesLoaded();let I=this.visibleAndFetchedIds();I.length===0&&(I=Object.keys(this.fetchedTiles));const A=[].concat(...I.filter(d=>this.fetchedTiles[d].tileData.dense).map(d=>Array.from(this.fetchedTiles[d].tileData.dense))).filter(d=>d>0);return this.medianVisibleValue=fL(A),this.medianVisibleValue}},{key:"allVisibleValues",value:function(){return[].concat(...this.visibleAndFetchedIds().map(I=>Array.from(this.fetchedTiles[I].tileData.dense)))}},{key:"minVisibleValue",value:function(I=!1){return this.minVisibleValueInTiles(I)}},{key:"minVisibleValueInTiles",value:function(I=!1){let A=this.visibleAndFetchedIds();A.length===0&&(A=Object.keys(this.fetchedTiles));let d=Math.min(...A.map(h=>this.fetchedTiles[h].tileData.minNonZero));return d===Number.MAX_SAFE_INTEGER&&(d=null),I?d:this.valueScaleMin!==null?this.valueScaleMin:d}},{key:"maxVisibleValue",value:function(I=!1){return this.maxVisibleValueInTiles(I)}},{key:"maxVisibleValueInTiles",value:function(I=!1){let A=this.visibleAndFetchedIds();A.length===0&&(A=Object.keys(this.fetchedTiles));let d=Math.max(...A.map(h=>this.fetchedTiles[h].tileData.maxNonZero));return d===Number.MIN_SAFE_INTEGER&&(d=null),I?d:this.valueScaleMax!==null?this.valueScaleMax:d}},{key:"makeValueScale",value:function(I,A,d,h){let y=null,Z=0,b=h;(b===null||typeof b>"u")&&(b=6);let w=Math.min(this.dimensions[1]-b,b),S=Math.max(this.dimensions[1]-b,b);if(this.dimensions[1]-bG0(R,H,D),[N,0]}else if(this.options.valueScaling==="setquantile"){const R=this.dimensions[1]-b,H=b,N=new Set(this.allVisibleValues()),D=UN().domain([...N]).range(Ns(R,H,(H-R)/256));return D.ticks=M=>G0(R,H,M),[D,0]}else y=Zn().domain([I,d]).range([S,w]);return[y,Z]}}]),s}(Xs);const bft=40,ea=0,SI=5,Mye=4;let _X=function(){function g(a){T(this,g),this.pAxis=new $t.PIXI.Graphics,this.track=a,this.axisTexts=[],this.axisTextFontFamily="Arial",this.axisTextFontSize=10}return E(g,[{key:"startAxis",value:function(s){const C=this.pAxis;C.clear(),C.lineStyle(1,this.track.getTheme()===ig?Mi("#ffffff"):0,1),C.moveTo(0,0),C.lineTo(0,s)}},{key:"createAxisTexts",value:function(s,C){this.tickValues=this.calculateAxisTickValues(s,C);let I=0;const A=this.track.getTheme()===ig?"white":"black";for(!this.track.options||!this.track.options.axisLabelFormatting||this.track.options.axisLabelFormatting==="scientific"?this.tickFormat=fl(".2"):this.tickFormat=d=>d;Ithis.tickValues.length;){const d=this.axisTexts.pop();this.pAxis.removeChild(d),d.destroy(!0)}}},{key:"calculateAxisTickValues",value:function(s,C){const I=Math.max(Math.ceil(C/bft),1);let A=s.ticks(I);return A.length<1&&(A=s.ticks(I+1),A.length>1&&(A=[A[0]])),A}},{key:"drawAxisLeft",value:function(s,C){this.startAxis(C),this.createAxisTexts(s,C);const I=this.pAxis;this.track.getTheme()===ig&&I.lineStyle(I.lineWidth||I._lineStyle.width,Mi("#ffffff")),I.moveTo(0,0),I.lineTo(-(ea+SI),0),I.moveTo(0,C),I.lineTo(-(ea+SI),C);for(let A=0;A=0;s--)this.axisTexts[s].visible=!0;for(let s=this.axisTexts.length-1;s>=0;s--){if(!this.axisTexts[s].visible)continue;let C=s-1;for(;C>=0&&this.axisTexts[s].y+this.axisTexts[s].height/2>this.axisTexts[C].y-this.axisTexts[C].height/2;){this.axisTexts[C].visible=!1;C-=1}}}},{key:"exportVerticalAxis",value:function(s){const C=document.createElement("g");C.setAttribute("class","axis-vertical");let I="black";this.track&&this.track.options.lineStrokeColor&&(I=this.track.options.lineStrokeColor),this.track.getTheme()===ig&&(I="#cccccc");const A=document.createElement("path");return A.setAttribute("fill","transparent"),A.setAttribute("stroke",I),A.setAttribute("id","axis-line"),A.setAttribute("d",`M0,0 L0,${s}`),C.appendChild(A),C}},{key:"createAxisSVGLine",value:function(){let s="black";this.track&&this.track.options.lineStrokeColor&&(s=this.track.options.lineStrokeColor),this.track.getTheme()===ig&&(s="#cccccc");const C=document.createElement("path");return C.setAttribute("id","tick-mark"),C.setAttribute("fill","transparent"),C.setAttribute("stroke",s),C}},{key:"createAxisSVGText",value:function(s){const C=document.createElement("text");return C.innerHTML=s,C.setAttribute("id","axis-text"),C.setAttribute("text-anchor","middle"),C.setAttribute("font-family",this.axisTextFontFamily),C.setAttribute("font-size",this.axisTextFontSize),C.setAttribute("dy",this.axisTextFontSize/2-2),C}},{key:"exportAxisLeftSVG",value:function(s,C){const I=this.exportVerticalAxis(C),A=this.createAxisSVGLine();I.appendChild(A),A.setAttribute("d",`M0,0 L${+(ea+SI)},0`);const d=this.createAxisSVGLine();I.appendChild(d),d.setAttribute("d",`M0,${C} L${+(ea+SI)},${C}`);for(let h=0;h{C.onValueScaleChanged(),A.drawColorbar()},A=a.call(this,d,I);const{pubSub:h,animate:y,svgElement:Z,onTrackOptionsChanged:b,onMouseMoveZoom:w,isShowGlobalMousePosition:S,isValueScaleLocked:R}=C;return A.pubSub=h,A.is2d=!0,A.animate=y,A.uid=Fn.nice(),A.scaleBrush=E2(),A.onTrackOptionsChanged=b,A.isShowGlobalMousePosition=S,A.isValueScaleLocked=R,A.pColorbarArea=new $t.PIXI.Graphics,A.pMasked.addChild(A.pColorbarArea),A.pColorbar=new $t.PIXI.Graphics,A.pColorbarArea.addChild(A.pColorbar),A.axis=new _X(u(A)),A.pColorbarArea.addChild(A.axis.pAxis),A.colorScale=JZ,I&&I.colorRange&&(A.colorScale=Df(I.colorRange)),A.gBase=Mn(Z).append("g"),A.gMain=A.gBase.append("g"),A.gColorscaleBrush=A.gMain.append("g"),A.brushing=!1,A.prevOptions="",A.prevIndUpperLeftTile="",A.onMouseMoveZoom=w,A.setDataLensSize(11),A.dataLens=new Float32Array(A.dataLensSize**2),A.mouseMoveHandlerBound=A.mouseMoveHandler.bind(u(A)),A.onMouseMoveZoom&&A.pubSubs.push(A.pubSub.subscribe("app.mouseMove",A.mouseMoveHandlerBound)),A.options&&A.options.showMousePosition&&!A.hideMousePosition&&(A.hideMousePosition=O0(u(A),A.is2d,A.isShowGlobalMousePosition())),A.prevOptions=JSON.stringify(I),A}return E(s,[{key:"mouseMoveHandler",value:function(I){this.isWithin(I.x,I.y)&&(this.mouseX=I.x,this.mouseY=I.y,this.mouseMoveZoomHandler())}},{key:"mouseMoveZoomHandler",value:function(I=this.mouseX,A=this.mouseY){if(typeof I>"u"||typeof A>"u"||!this.areAllVisibleTilesLoaded()||!this.tilesetInfo)return;const d=I-this.position[0],h=A-this.position[1];let y,Z;try{Z=this.getVisibleRectangleData(d-this.dataLensPadding,h-this.dataLensPadding,this.dataLensSize,this.dataLensSize),y=Z.get(this.dataLensPadding,this.dataLensPadding)}catch{return}const b=this.dataLensSize;let w;try{w=_U(this.limitedValueScale,this.colorScale,this.valueScale.domain()[0])}catch{return}if(!w)return;const S=Math.round(this._xScale.invert(d)),R=Math.round(this._yScale.invert(h));let H=[S,R],N=[Math.round(this._xScale.invert(d-this.dataLensPadding)),Math.round(this._xScale.invert(d+this.dataLensPadding))],D=[Math.round(this._yScale.invert(h-this.dataLensPadding)),Math.round(this._yScale.invert(h+this.dataLensPadding))];this.chromInfo&&(H=H.map(M=>xo(M,this.chromInfo).slice(0,2)),N=N.map(M=>xo(M,this.chromInfo).slice(0,2)),D=D.map(M=>xo(M,this.chromInfo).slice(0,2))),this.onMouseMoveZoom({trackId:this.id,data:y,absX:I,absY:A,relX:d,relY:h,dataX:S,dataY:R,orientation:"2d",dataLens:Z,dim:b,toRgb:w,center:H,xRange:N,yRange:D,isGenomicCoords:!!this.chromInfo})}},{key:"scheduleRerender",value:function(){this.backgroundTaskScheduler.enqueueTask(this.handleRerender.bind(this),null,this.uuid)}},{key:"handleRerender",value:function(){this.rerender(this.options,!0)}},{key:"getAbsTileDim",value:function(I,A,d){const{tileX:h,tileY:y,tileWidth:Z,tileHeight:b}=this.getTilePosAndDimensions(I,A),w={};return w.width=this._refXScale(h+Z)-this._refXScale(h),w.height=this._refYScale(y+b)-this._refYScale(y),d?(w.x=this._refXScale(y),w.y=this._refYScale(h)):(w.x=this._refXScale(h),w.y=this._refYScale(y)),w}},{key:"updateValueScale",value:function(){let I=this.minValue(),A=this.maxValue();const d=1e-6;I!=null&&A!==void 0&&A!==null&&Math.abs(I-A)this.renderTile(h)),this.hideMousePosition&&(this.hideMousePosition(),this.hideMousePosition=void 0),this.options&&this.options.showMousePosition&&!this.hideMousePosition&&(this.hideMousePosition=O0(this,this.is2d,this.isShowGlobalMousePosition())))}},{key:"drawLabel",value:function(){this.options.labelPosition===this.options.colorbarPosition?this.labelXOffset=vT:this.labelXOffset=0,n(G(s.prototype),"drawLabel",this).call(this)}},{key:"tileDataToCanvas",value:function(I){const A=document.createElement("canvas");A.width=this.binsPerTile(),A.height=this.binsPerTile();const d=A.getContext("2d");d.fillStyle="transparent",d.fillRect(0,0,A.width,A.height);const h=new ImageData(I,A.width,A.height);return d.putImageData(h,0,0),A}},{key:"exportData",value:function(){if(this.tilesetInfo){const I=this.getVisibleRectangleData(0,0,this.dimensions[0],this.dimensions[1]),A={bounds:[this._xScale.domain(),this._yScale.domain()],dimensions:I.shape,data:W0e(I)};P2("data.json",JSON.stringify(A))}}},{key:"setSpriteProperties",value:function(I,A,d,h){const y=this.getAbsTileDim(A,d,h);I.width=y.width,I.height=y.height,I.x=y.x,I.y=y.y,h&&d[0]!==d[1]&&(I.rotation=-Math.PI/2,I.scale.x=Math.abs(I.scale.x)*-1)}},{key:"refXScale",value:function(I){n(G(s.prototype),"refXScale",this).call(this,I),this.draw()}},{key:"refYScale",value:function(I){n(G(s.prototype),"refYScale",this).call(this,I),this.draw()}},{key:"draw",value:function(){n(G(s.prototype),"draw",this).call(this)}},{key:"newBrushOptions",value:function(I){const A=JSON.parse(JSON.stringify(this.options)),d=this.valueScale.copy().range([this.colorbarHeight,0]),h=d.invert(I[0]),Z=(d.invert(I[1])-d.domain()[0])/(d.domain()[1]-d.domain()[0]),b=(h-d.domain()[0])/(d.domain()[1]-d.domain()[0]);return A.scaleStartPercent=Z.toFixed(Kye),A.scaleEndPercent=b.toFixed(Kye),A}},{key:"brushStart",value:function(){this.brushing=!0}},{key:"brushMoved",value:function(I){if(!I.selection)return;const A=this.newBrushOptions(I.selection),d=JSON.stringify(A);this.gColorscaleBrush.selectAll(".handle--custom").attr("y",h=>h.type==="n"?I.selection[0]:I.selection[1]-Yye/2),d!==this.prevOptions&&(this.prevOptions=d,this.rerender(A,!0),this.onTrackOptionsChanged(A),this.isValueScaleLocked()&&this.onValueScaleChanged())}},{key:"brushEnd",value:function(){this.brushing=!1}},{key:"setPosition",value:function(I){n(G(s.prototype),"setPosition",this).call(this,I),this.drawColorbar()}},{key:"setDimensions",value:function(I){n(G(s.prototype),"setDimensions",this).call(this,I),this.drawColorbar()}},{key:"removeColorbar",value:function(){this.pColorbarArea.visible=!1,this.scaleBrush.on(".brush")&&this.gColorscaleBrush.call(this.scaleBrush.move,null),this.gColorscaleBrush.on(".brush",null),this.gColorscaleBrush.selectAll("rect").remove()}},{key:"drawColorbar",value:function(){if(this.pColorbar.clear(),!this.options||!this.options.colorbarPosition||this.options.colorbarPosition==="hidden"){this.removeColorbar();return}if(this.pColorbarArea.visible=!0,!this.valueScale||Number.isNaN(+this.valueScale.domain()[0])||Number.isNaN(+this.valueScale.domain()[1]))return;const I=Math.min(this.dimensions[1]/2,Fye);if(this.colorbarHeight=I-2*$a,this.colorbarHeight<0){this.removeColorbar();return}if(this.valueScale.domain()[1]===this.valueScale.domain()[0]){this.removeColorbar();return}const A=this.valueScale.copy().range([this.colorbarHeight,0]);this.options.colorbarPosition==="topLeft"||this.options.colorbarPosition==="bottomLeft"?this.scaleBrush.extent([[jf,0],[Qf,this.colorbarHeight]]):this.scaleBrush.extent([[0,0],[Qf-jf,this.colorbarHeight]]),this.options.colorbarPosition==="topLeft"&&([this.pColorbarArea.x,this.pColorbarArea.y]=this.position,this.pColorbar.y=$a,this.axis.pAxis.y=$a,this.axis.pAxis.x=jf+Qf+C1+Uf,this.pColorbar.x=jf+Qf+C1,this.gColorscaleBrush.attr("transform",`translate(${this.pColorbarArea.x+jf},${this.pColorbarArea.y+this.pColorbar.y-1})`)),this.options.colorbarPosition==="topRight"&&(this.pColorbarArea.x=this.position[0]+this.dimensions[0]-vT,this.pColorbarArea.y=this.position[1],this.pColorbar.y=$a,this.axis.pAxis.y=$a,this.axis.pAxis.x=yT+$a,this.pColorbar.x=yT+$a,this.gColorscaleBrush.attr("transform",`translate(${this.pColorbarArea.x+this.pColorbar.x+Uf+2},${this.pColorbarArea.y+this.pColorbar.y-1})`)),this.options.colorbarPosition==="bottomRight"&&(this.pColorbarArea.x=this.position[0]+this.dimensions[0]-vT,this.pColorbarArea.y=this.position[1]+this.dimensions[1]-I,this.pColorbar.y=$a,this.axis.pAxis.y=$a,this.axis.pAxis.x=yT+$a,this.pColorbar.x=yT+$a,this.gColorscaleBrush.attr("transform",`translate(${this.pColorbarArea.x+this.pColorbar.x+Uf+C1},${this.pColorbarArea.y+this.pColorbar.y-1})`)),this.options.colorbarPosition==="bottomLeft"&&(this.pColorbarArea.x=this.position[0],this.pColorbarArea.y=this.position[1]+this.dimensions[1]-I,this.pColorbar.y=$a,this.axis.pAxis.y=$a,this.axis.pAxis.x=jf+Qf+C1+Uf,this.pColorbar.x=jf+Qf+C1,this.gColorscaleBrush.attr("transform",`translate(${this.pColorbarArea.x+2},${this.pColorbarArea.y+this.pColorbar.y-1})`)),this.pColorbarArea.clear(),this.pColorbarArea.beginFill(Mi(this.options.colorbarBackgroundColor||"white"),+this.options.colorbarBackgroundOpacity>=0?+this.options.colorbarBackgroundOpacity:.6),this.pColorbarArea.drawRect(0,0,vT,I),this.options?(this.options.scaleStartPercent||(this.options.scaleStartPercent=0),this.options.scaleEndPercent||(this.options.scaleEndPercent=1)):this.options={scaleStartPercent:0,scaleEndPercent:1};const d=A.domain()[1]-A.domain()[0],h=A(this.options.scaleStartPercent*d+A.domain()[0]),y=A(this.options.scaleEndPercent*d+A.domain()[0]);this.brushing||(this.scaleBrush.on("start",this.brushStart.bind(this)).on("brush",this.brushMoved.bind(this)).on("end",this.brushEnd.bind(this)).handleSize(0),this.gColorscaleBrush.on(".brush",null),this.gColorscaleBrush.call(this.scaleBrush),this.northHandle=this.gColorscaleBrush.selectAll(".handle--custom").data([{type:"n"},{type:"s"}]).enter().append("rect").classed("handle--custom",!0).attr("cursor","ns-resize").attr("width",Qf).attr("height",Yye).style("fill","#666").style("stroke","white"),this.flipText&&this.northHandle.attr("cursor","ew-resize"),this.gColorscaleBrush.call(this.scaleBrush.move,[y,h]));const Z=Zn().domain([0,255]).range([0,this.colorbarHeight]);for(let b=0;b{const J=P.mirrored?[P.tileData.tilePos[1],P.tileData.tilePos[0]]:P.tileData.tilePos,{tileX:j,tileY:ie,tileWidth:te,tileHeight:Ce}=this.getTilePosAndDimensions(P.tileData.zoomLevel,J,this.binsPerTile()),ue=Math.floor(j/b),oe=Math.floor((j+te)/b),he=Math.floor(ie/b),ye=Math.floor((ie+Ce)/b);let Ie=Math.max(N,ue)-ue,fe=Math.max(D,he)-he;const We=Math.min(N+M,oe)-ue,_e=Math.min(D+z,ye)-he,qe=Math.max(ue-N,0),nt=Math.max(he-D,0),At=We-Ie,Tt=_e-fe;if(!(At<0||Tt<0)){if(P.mirrored&&Ie>fe){const Ne=Ie;Ie=fe,fe=Ne}V0e(K.hi(nt+Tt,qe+At).lo(nt,qe),P.dataArray.hi(fe+Tt,Ie+At).lo(fe,Ie))}}),K}},{key:"initTile",value:function(I){n(G(s.prototype),"initTile",this).call(this,I),I.tileData.dense.length===this.binsPerTile()**2&&(I.dataArray=QZ(Array.from(I.tileData.dense),[this.binsPerTile(),this.binsPerTile()]),this.continuousScaling&&I.tileData.tilePos[0]===I.tileData.tilePos[1]&&I.mirrored&&(I.tileData.denseDataExtrema.mirrorPrecomputedExtrema(),n(G(s.prototype),"initTile",this).call(this,I))),!(this.scale.minValue===null||this.scale.maxValue===null)&&this.renderTile(I)}},{key:"updateTile",value:function(I){I.scale&&this.scale&&this.scale.minValue===I.scale.minValue&&this.scale.maxValue===I.scale.maxValue||(this.renderTile(I),this.drawColorbar())}},{key:"destroyTile",value:function(I){I.sprite.destroy(!0),I.canvas=null,I.sprite=null,I.texture=null}},{key:"pixDataFunction",value:function(I,A){if(A){const{graphics:d}=I,h=this.tileDataToCanvas(A.pixData);I.sprite&&I.sprite.destroy(!0);const y=$t.PIXI.VERSION[0]==="4"?$t.PIXI.Texture.fromCanvas(h,$t.PIXI.SCALE_MODES.NEAREST):$t.PIXI.Texture.from(h,{scaleMode:$t.PIXI.SCALE_MODES.NEAREST}),Z=new $t.PIXI.Sprite(y);I.sprite=Z,I.texture=y,I.canvas=h,this.setSpriteProperties(I.sprite,I.tileData.zoomLevel,I.tileData.tilePos,I.mirrored),d.removeChildren(),d.addChild(I.sprite)}this.renderingTiles.delete(I.tileId)}},{key:"renderTile",value:function(I){const[A]=this.updateValueScale(),d=0;if(this.renderingTiles.add(I.tileId),this.tilesetInfo.tile_size&&I.tileData.dense.lengththis.pixDataFunction(I,h),this.mirrorTiles()&&!I.mirrored&&I.tileData.tilePos[0]===I.tileData.tilePos[1],this.options.extent==="upper-right"&&I.tileData.tilePos[0]===I.tileData.tilePos[1],this.options.zeroValueColor?a0e(this.options.zeroValueColor):void 0,{selectedRows:this.options.selectRows,selectedRowsAggregationMode:this.options.selectRowsAggregationMode,selectedRowsAggregationWithRelativeHeight:this.options.selectRowsAggregationWithRelativeHeight,selectedRowsAggregationMethod:this.options.selectRowsAggregationMethod})}},{key:"remove",value:function(){this.gMain.remove(),this.gMain=null,n(G(s.prototype),"remove",this).call(this)}},{key:"refScalesChanged",value:function(I,A){n(G(s.prototype),"refScalesChanged",this).call(this,I,A),oX(this.fetchedTiles).filter(d=>d.sprite).forEach(d=>this.setSpriteProperties(d.sprite,d.tileData.zoomLevel,d.tileData.tilePos,d.mirrored))}},{key:"superSVG",value:function(){return n(G(s.prototype),"exportSVG",this).call(this)}},{key:"exportSVG",value:function(){let I=null,A=null;n(G(s.prototype),"exportSVG",this)?[A,I]=n(G(s.prototype),"exportSVG",this).call(this):(A=document.createElement("g"),I=A);const d=document.createElement("g");I.appendChild(d),d.setAttribute("transform",`translate(${this.pMain.position.x},${this.pMain.position.y}) scale(${this.pMain.scale.x},${this.pMain.scale.y})`);for(const y of this.visibleAndFetchedTiles()){const Z=y.sprite.rotation*180/Math.PI,b=document.createElement("g");b.setAttribute("transform",`translate(${y.sprite.x},${y.sprite.y}) rotate(${Z}) scale(${y.sprite.scale.x},${y.sprite.scale.y})`);const w=document.createElement("image");w.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",y.canvas.toDataURL()),w.setAttribute("width",y.canvas.width),w.setAttribute("height",y.canvas.height),w.setAttribute("style","image-rendering: pixelated"),b.appendChild(w),d.appendChild(b)}const h=this.exportColorBarSVG();return I.appendChild(h),[A,A]}},{key:"getVisiblePartOfUppLeftTile",value:function(){const I=this.visibleAndFetchedTiles().map(H=>{const N=H.mirrored?[H.tileData.tilePos[1],H.tileData.tilePos[0]]:H.tileData.tilePos;return[N[0],N[1],H.tileId]});if(I.length===0)return null;let A=I[0];for(let H=0;HH.tileId===A[2])[0],Z=this.getIndicesOfVisibleDataInTile(y),b=Z[0],w=Z[1],S=b-b%h,R=w-w%h;return[y.tileId,S,R]}},{key:"getIndicesOfVisibleDataInTile",value:function(I){const A=this._xScale.range(),d=this._yScale.range(),h=I.mirrored?[I.tileData.tilePos[1],I.tileData.tilePos[0]]:I.tileData.tilePos,{tileX:y,tileY:Z,tileWidth:b,tileHeight:w}=this.getTilePosAndDimensions(I.tileData.zoomLevel,h,this.binsPerTile()),S=Zn().domain([0,this.binsPerTile()]).range([y,y+b]),R=Math.max(0,Math.round(S.invert(this._xScale.invert(A[0])))-1),H=Math.min(this.binsPerTile(),Math.round(S.invert(this._xScale.invert(A[1])))),N=Zn().domain([0,this.binsPerTile()]).range([Z,Z+w]),D=Math.max(0,Math.round(N.invert(this._yScale.invert(d[0])))-1),M=Math.min(this.binsPerTile(),Math.round(N.invert(this._yScale.invert(d[1]))));return I.mirrored&&h[0]!==h[1]?[D,R,M,H]:[R,D,H,M]}},{key:"minVisibleValue",value:function(I=!1){const A=this.visibleAndFetchedTiles().map(h=>{if(h.tileData.denseDataExtrema===void 0)return null;const y=this.getIndicesOfVisibleDataInTile(h);return h.tileData.denseDataExtrema.getMinNonZeroInSubset(y)});if(A.length===0&&this.valueScaleMax===null)return null;const d=Math.min.apply(null,A);return d===Number.MAX_SAFE_INTEGER?n(G(s.prototype),"minVisibleValue",this).call(this,I):I?d:this.valueScaleMin!==null?this.valueScaleMin:d}},{key:"maxVisibleValue",value:function(I=!1){const A=this.visibleAndFetchedTiles().map(h=>{if(h.tileData.denseDataExtrema===void 0)return null;const y=this.getIndicesOfVisibleDataInTile(h);return h.tileData.denseDataExtrema.getMaxNonZeroInSubset(y)});if(A.length===0&&this.valueScaleMax===null)return null;const d=Math.max.apply(null,A);return d===Number.MIN_SAFE_INTEGER?n(G(s.prototype),"maxVisibleValue",this).call(this,I):I?d:this.valueScaleMax!==null?this.valueScaleMax:d}},{key:"zoomed",value:function(I,A,d,h,y){if(this.brushing)return;n(G(s.prototype),"zoomed",this).call(this,I,A),this.pMain.position.x=h,this.pMain.position.y=y,this.pMain.scale.x=d,this.pMain.scale.y=d;const Z=this.isValueScaleLocked();if(this.continuousScaling&&this.minValue()!==void 0&&this.maxValue()!==void 0){const b=JSON.stringify(this.getVisiblePartOfUppLeftTile());if(this.valueScaleMin===null&&this.valueScaleMax===null&&!Z&&b!==this.prevIndUpperLeftTile){const w=this.minVisibleValue(),S=this.maxVisibleValue(),R=1e-6;w!==null&&S!==null&&(Math.abs(this.minValue()-w)>R||Math.abs(this.maxValue()-S)>R)&&(this.minValue(w),this.maxValue(S),this.scheduleRerender()),this.prevIndUpperLeftTile=b}Z&&this.onValueScaleChanged()}this.mouseMoveZoomHandler()}},{key:"addTileId",value:function(I,A,d,h,y,Z=!1){const b=[A,d,h];b.mirrored=Z,b.dataTransform=y,I.push(b)}},{key:"tilesToId",value:function(I,A,d){const h=I,y=A,Z=this.options&&this.options.dataTransform||"default",b=[];for(let w=0;w=y[S]?this.options.extent!=="lower-left"&&this.addTileId(b,d,y[S],h[w],Z,!0):this.options.extent!=="upper-right"&&this.addTileId(b,d,h[w],y[S],Z),h[w]===y[S]&&this.options.extent==="lower-left"&&this.addTileId(b,d,h[w],y[S],Z)):this.addTileId(b,d,h[w],y[S],Z);return b}},{key:"calculateVisibleTiles",value:function(){if(this.tilesetInfo){if(this.zoomLevel=this.calculateZoomLevel(),this.tilesetInfo.resolutions){const I=this.tilesetInfo.resolutions.map(A=>+A).sort((A,d)=>d-A);this.xTiles=Gi.calculateTilesFromResolution(I[this.zoomLevel],this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]),this.yTiles=Gi.calculateTilesFromResolution(I[this.zoomLevel],this._yScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0])}else this.xTiles=Gi.calculateTiles(this.zoomLevel,this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width),this.yTiles=Gi.calculateTiles(this.zoomLevel,this._yScale,this.options.reverseYAxis?-this.tilesetInfo.max_pos[1]:this.tilesetInfo.min_pos[1],this.options.reverseYAxis?-this.tilesetInfo.min_pos[1]:this.tilesetInfo.max_pos[1],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width1||this.tilesetInfo.max_width);this.setVisibleTiles(this.tilesToId(this.xTiles,this.yTiles,this.zoomLevel))}}},{key:"mirrorTiles",value:function(){return!(this.tilesetInfo.mirror_tiles&&(this.tilesetInfo.mirror_tiles===!1||this.tilesetInfo.mirror_tiles==="false"))}},{key:"getMouseOverHtml",value:function(I,A){if(!this.options||!this.options.showTooltip||!this.tilesetInfo)return"";const d=Gi.calculateResolution(this.tilesetInfo,this.zoomLevel),h=Math.max(this.tilesetInfo.max_pos[1]-this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[0]-this.tilesetInfo.min_pos[0]),y=Math.ceil(Math.log(h/d)/Math.log(10));this.setDataLensSize(1);const Z=this._xScale.invert(I),b=this._yScale.invert(A);let w="Position: ";if(this.chromInfo){const R=xo(Z,this.chromInfo),H=xo(b,this.chromInfo),N=D=>fl(`.${y}s`)(D);w+=`${R[0]}:${N(R[1])} & ${H[0]}:${N(H[1])}`,w+="
"}let S=null;try{S=this.getVisibleRectangleData(I,A,1,1).get(0,0)}catch{return""}return this.options&&this.options.heatmapValueScaling==="log"?S>0?`${w}Value: 1e${fl(".3f")(Math.log(S)/Math.log(10))}`:S===0?`${w}Value: 0`:`${w}Value: N/A`:`${w}Value: ${fl(".3f")(S)}`}},{key:"getTilePosAndDimensions",value:function(I,A,d){const h=d||this.binsPerTile();if(this.tilesetInfo.resolutions){const M=this.tilesetInfo.resolutions.map(j=>+j).sort((j,ie)=>ie-j)[I],z=M*h,K=z,P=M*h*A[0],J=M*h*A[1];return{tileX:P,tileY:J,tileWidth:z,tileHeight:K}}const y=A[0],Z=A[1],b=this.tilesetInfo.min_pos[0],w=this.options.reverseYAxis?-this.tilesetInfo.max_pos[1]:this.tilesetInfo.min_pos[1],S=this.tilesetInfo.max_width/2**I,R=this.tilesetInfo.max_width/2**I,H=b+y*S,N=w+Z*R;return{tileX:H,tileY:N,tileWidth:S,tileHeight:R}}},{key:"calculateZoomLevel",value:function(){const I=this.tilesetInfo.min_pos[0],A=this.tilesetInfo.max_pos[0],d=this.tilesetInfo.min_pos[1],h=this.tilesetInfo.max_pos[1];let y=null;if(this.tilesetInfo.resolutions){const Z=Gi.calculateZoomLevelFromResolutions(this.tilesetInfo.resolutions,this._xScale,I,A),b=Gi.calculateZoomLevelFromResolutions(this.tilesetInfo.resolutions,this._yScale,d,h);y=Math.min(Z,b)}else{const Z=Gi.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.binsPerTile()),b=Gi.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[1],this.binsPerTile());y=Math.max(Z,b),y=Math.min(y,this.maxZoom)}return this.options&&this.options.maxZoom&&(this.options.maxZoom>=0?y=Math.min(this.options.maxZoom,y):console.error("Invalid maxZoom on track:",this)),y}},{key:"tileToLocalId",value:function(I){return I.dataTransform&&I.dataTransform!=="default"?`${I.join(".")}.${I.mirrored}.${I.dataTransform}`:`${I.join(".")}.${I.mirrored}`}},{key:"tileToRemoteId",value:function(I){return I.dataTransform&&I.dataTransform!=="default"?`${I.join(".")}.${I.dataTransform}`:`${I.join(".")}`}},{key:"localToRemoteId",value:function(I){const A=I.split(".");return A.slice(0,A.length-1).join(".")}}]),s}(Jf);function _ye(g){if(!g.graphics)return;const a=g.graphics,{tileX:s,tileY:C,tileWidth:I}=this.getTilePosAndDimensions(g.tileData.zoomLevel,g.tileData.tilePos);g.drawnAtScale=this._xScale.copy();const A=1/((this._xScale(1)-this._xScale(0))/(this._refXScale(1)-this._refXScale(0))),d=1/((this._yScale(1)-this._yScale(0))/(this._refYScale(1)-this._refYScale(0)));g.text.scale.x=A,g.text.scale.y=d;const h=this._xScale(I)-this._xScale(0);if(g.textGraphics.scale.x=h/256,g.textGraphics.scale.y=h/256,a.clear(),a.lineStyle(4*A,255,1),a.beginFill(16740363,.4),a.alpha=.5,g.mirrored){const y=this._refXScale(C+I)-this._refXScale(C),Z=this._refYScale(s+I)-this._refYScale(s);g.textGraphics.position.x=this._refXScale(C)+y/2,g.textGraphics.position.y=this._refYScale(s)+Z/2,a.drawRect(this._refXScale(C),this._refYScale(s),y,Z)}else{const y=this._refXScale(s+I)-this._refXScale(s),Z=this._refYScale(C+I)-this._refYScale(C);g.textGraphics.position.x=this._refXScale(s)+y/2,g.textGraphics.position.y=this._refYScale(C)+Z/2,a.drawRect(this._refXScale(s),this._refYScale(C),y,Z)}}function Pye(g){const a=g.graphics;g.textGraphics=new $t.PIXI.Graphics,g.mirrored?g.text=new $t.PIXI.Text(`${g.tileData.zoomLevel}/${[g.tileData.tilePos[1],g.tileData.tilePos[0]].join("/")}`,{fontFamily:"Arial",fontSize:24,fill:16715792,align:"center"}):g.text=new $t.PIXI.Text(`${g.tileData.zoomLevel}/${g.tileData.tilePos.join("/")}`,{fontFamily:"Arial",fontSize:24,fill:16715792,align:"center"}),g.textGraphics.addChild(g.text),g.text.anchor.x=.5,g.text.anchor.y=.5,a.addChild(g.textGraphics)}let zye=function(g){o(s,g);var a=l(s);function s(){return T(this,s),a.apply(this,arguments)}return E(s,[{key:"areAllVisibleTilesLoaded",value:function(){return!0}},{key:"initTile",value:function(I){Pye.bind(this)(I),this.drawTile(I)}},{key:"destroyTile",value:function(I,A){}},{key:"drawTile",value:function(I){_ye.bind(this)(I)}},{key:"fetchNewTiles",value:function(I){I.forEach(A=>{const h=A.remoteId.split("."),y={zoomLevel:h[0],tilePos:h.slice(1,h.length).map(Z=>+Z)};this.fetchedTiles[A.tileId]=A,this.fetchedTiles[A.tileId].tileData=y,this.fetching.has(A.remoteId)&&this.fetching.delete(A.remoteId)}),this.synchronizeTilesAndGraphics()}}]),s}(ZT);const vft=1024;let X7=function(g){o(s,g);var a=l(s);function s(C,I){var A;T(this,s),A=a.call(this,C,I);const{onMouseMoveZoom:d,isValueScaleLocked:h,getLockGroupExtrema:y}=C;return A.onMouseMoveZoom=d,A.isValueScaleLocked=h,A.getLockGroupExtrema=y,A.onMouseMoveZoom&&A.pubSubs.push(A.pubSub.subscribe("app.mouseMove",A.mouseMoveHandler.bind(u(A)))),A}return E(s,[{key:"initTile",value:function(I){n(G(s.prototype),"initTile",this).call(this,I)}},{key:"tileToLocalId",value:function(I){return`${I.join(".")}`}},{key:"tileToRemoteId",value:function(I){return`${I.join(".")}`}},{key:"relevantScale",value:function(){return null}},{key:"setVisibleTiles",value:function(I){this.visibleTiles=I.map(A=>({tileId:this.tileToLocalId(A),remoteId:this.tileToRemoteId(A)})),this.visibleTileIds=new Set(this.visibleTiles.map(A=>A.tileId))}},{key:"calculateVisibleTiles",value:function(){if(!this.tilesetInfo)return;if(this.zoomLevel=this.calculateZoomLevel(),this.tilesetInfo.resolutions){const d=this.tilesetInfo.resolutions.map(Z=>+Z).sort((Z,b)=>b-Z),y=Gi.calculateTilesFromResolution(d[this.zoomLevel],this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]).map(Z=>[this.zoomLevel,Z]);this.setVisibleTiles(y);return}const A=Gi.calculateTiles(this.zoomLevel,this.relevantScale(),this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width).map(d=>[this.zoomLevel,d]);this.setVisibleTiles(A)}},{key:"getTilePosAndDimensions",value:function(I,A,d){const h=A[0],y=A[0];if(this.tilesetInfo.resolutions){const M=d||vft,K=this.tilesetInfo.resolutions.map(te=>+te).sort((te,Ce)=>Ce-te)[I],P=K*M,J=P,j=K*M*A[0],ie=K*M*A[1];return{tileX:j,tileY:ie,tileWidth:P,tileHeight:J}}const Z=this.tilesetInfo.max_width,b=this.tilesetInfo.max_width,w=this.tilesetInfo.min_pos[0],S=this.tilesetInfo.min_pos[1],R=Z/2**I,H=b/2**I,N=w+h*R,D=S+y*H;return{tileX:N,tileY:D,tileWidth:R,tileHeight:H}}},{key:"updateTile",value:function(I){}},{key:"scheduleRerender",value:function(){this.backgroundTaskScheduler.enqueueTask(this.handleRerender.bind(this),null,this.uuid)}},{key:"handleRerender",value:function(){this.rerender(this.options,!1)}},{key:"getIndicesOfVisibleDataInTile",value:function(I){const A=this._xScale.range();if(!this.tilesetInfo)return[null,null];const{tileX:d,tileWidth:h}=this.getTilePosAndDimensions(I.tileData.zoomLevel,I.tileData.tilePos,this.tilesetInfo.bins_per_dimension||this.tilesetInfo.tile_size),y=Zn().domain([0,this.tilesetInfo.tile_size||this.tilesetInfo.bins_per_dimension]).range([d,d+h]),Z=Math.max(0,Math.round(y.invert(this._xScale.invert(A[0])))),b=Math.min(I.tileData.dense.length,Math.round(y.invert(this._xScale.invert(A[1]))));return[Z,b]}},{key:"minVisibleValue",value:function(I=!1){let A=this.visibleAndFetchedIds();A.length===0&&(A=Object.keys(this.fetchedTiles));const d=A.map(y=>this.fetchedTiles[y]).map(y=>{const Z=this.getIndicesOfVisibleDataInTile(y);return y.tileData.denseDataExtrema.getMinNonZeroInSubset(Z)}),h=Math.min(...d);return I?h:this.valueScaleMin!==null?this.valueScaleMin:h}},{key:"maxVisibleValue",value:function(I=!1){let A=this.visibleAndFetchedIds();A.length===0&&(A=Object.keys(this.fetchedTiles));const d=A.map(y=>this.fetchedTiles[y]).map(y=>{const Z=this.getIndicesOfVisibleDataInTile(y);return y.tileData.denseDataExtrema.getMaxNonZeroInSubset(Z)}),h=Math.max(...d);return I?h:this.valueScaleMax!==null?this.valueScaleMax:h}},{key:"getAggregatedVisibleValue",value:function(I="max"){const A=I==="min"?Math.min:Math.max,d=I==="min"?1/0:-1/0;let h=this.visibleAndFetchedIds();h.length===0&&(h=Object.keys(this.fetchedTiles));const y=this._xScale.range();return h.map(Z=>this.fetchedTiles[Z]).map(Z=>{if(!Z.tileData.tilePos)return I==="min"?this.minVisibleValue():this.maxVisibleValue();const{tileX:b,tileWidth:w}=this.getTilePosAndDimensions(Z.tileData.zoomLevel,Z.tileData.tilePos,this.tilesetInfo.bins_per_dimension||this.tilesetInfo.tile_size),S=Zn().domain([0,this.tilesetInfo.tile_size||this.tilesetInfo.bins_per_dimension]).range([b,b+w]),R=Math.max(0,Math.round(S.invert(this._xScale.invert(y[0])))),H=Math.min(Z.tileData.dense.length,Math.round(S.invert(this._xScale.invert(y[1]))));return Z.tileData.dense.slice(R,H)}).reduce((Z,b)=>A(Z,...b),d)}},{key:"getDataAtPos",value:function(I){let A;if(!this.tilesetInfo)return A;const d=this.calculateZoomLevel(),h=Gi.calculateTileWidth(this.tilesetInfo,d,this.tilesetInfo.tile_size),y=this._xScale.invert(I)/h,Z=this.tileToLocalId([d,Math.floor(y)]),b=this.fetchedTiles[Z];if(!b)return A;const w=this.tilesetInfo.tile_size*(y-Math.floor(y));return b.tileData.dense?b.tileData.dense[Math.floor(w)]:null}},{key:"mouseMoveHandler",value:function({x:I,y:A}={}){this.isWithin(I,A)&&(this.mouseX=I,this.mouseY=A,this.mouseMoveZoomHandler())}},{key:"mouseMoveZoomHandler",value:function(){}},{key:"zoomed",value:function(...I){n(G(s.prototype),"zoomed",this).call(this,...I),this.mouseMoveZoomHandler()}}]),s}(Jf),c1=function(g){o(s,g);var a=l(s);function s(C,I){var A;T(this,s),A=a.call(this,C,I);const{animate:d,isShowGlobalMousePosition:h}=C;return A.constIndicator=new $t.PIXI.Graphics,A.pMain.addChild(A.constIndicator),A.axis=new _X(u(A)),A.pBase.addChild(A.axis.pAxis),A.animate=d,A.options=I,A.isShowGlobalMousePosition=h,A.pubSubs=[],A.options.showMousePosition&&!A.hideMousePosition&&(A.hideMousePosition=O0(u(A),A.is2d,A.isShowGlobalMousePosition())),A}return E(s,[{key:"rerender",value:function(I,A){const d=JSON.stringify(I);!A&&d===this.prevOptions||(n(G(s.prototype),"rerender",this).call(this,I,A),this.prevOptions=d,this.options=I,this.options.showMousePosition&&!this.hideMousePosition&&(this.hideMousePosition=O0(this,this.is2d,this.isShowGlobalMousePosition())),!this.options.showMousePosition&&this.hideMousePosition&&(this.hideMousePosition(),this.hideMousePosition=void 0))}},{key:"calculateZoomLevel",value:function(){if(this.tilesetInfo.resolutions)return Gi.calculateZoomLevelFromResolutions(this.tilesetInfo.resolutions,this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]-2);const I=Gi.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.bins_per_dimension||this.tilesetInfo.tile_size);let A=Math.min(I,this.maxZoom);return A=Math.max(A,0),A}},{key:"relevantScale",value:function(){return this._xScale}},{key:"draw",value:function(){n(G(s.prototype),"draw",this).call(this),this.drawConstIndicator()}},{key:"drawAxis",value:function(I){if(!this.options.axisPositionVertical&&!this.options.axisPositionHorizontal){this.axis.clearAxis();return}if(this.options.axisPositionVertical&&this.options.axisPositionVertical==="hidden"){this.axis.clearAxis();return}if(this.options.axisPositionHorizontal&&this.options.axisPositionHorizontal==="hidden"){this.axis.clearAxis();return}const A=this.options.axisMargin||0;this.options.axisPositionHorizontal==="left"||this.options.axisPositionVertical==="top"?(this.axis.pAxis.position.x=this.position[0]+A,this.axis.pAxis.position.y=this.position[1],this.axis.drawAxisRight(I,this.dimensions[1])):this.options.axisPositionHorizontal==="outsideLeft"||this.options.axisPositionVertical==="outsideTop"?(this.axis.pAxis.position.x=this.position[0]+A,this.axis.pAxis.position.y=this.position[1],this.axis.drawAxisLeft(I,this.dimensions[1])):this.options.axisPositionHorizontal==="right"||this.options.axisPositionVertical==="bottom"?(this.axis.pAxis.position.x=this.position[0]+this.dimensions[0]-A,this.axis.pAxis.position.y=this.position[1],this.axis.drawAxisLeft(I,this.dimensions[1])):(this.options.axisPositionHorizontal==="outsideRight"||this.options.axisPositionVertical==="outsideBottom")&&(this.axis.pAxis.position.x=this.position[0]+this.dimensions[0]-A,this.axis.pAxis.position.y=this.position[1],this.axis.drawAxisRight(I,this.dimensions[1]))}},{key:"mouseMoveZoomHandler",value:function(I=this.mouseX,A=this.mouseY){if(typeof I>"u"||!this.areAllVisibleTilesLoaded()||!this.tilesetInfo)return;let d=0,h=0,y="1d-horizontal";this.isLeftModified?(d=A-this.position[1],h=I-this.position[0],y="1d-vertical"):(d=I-this.position[0],h=A-this.position[1]);const Z=I-this.position[0],b=A-this.position[1],w=this._xScale.invert(d),S=this._yScale.invert(h),R=this.getDataAtPos(d);R&&this.onMouseMoveZoom({trackId:this.id,data:R,absX:I,absY:A,relX:Z,relY:b,dataX:w,dataY:S,orientation:y})}},{key:"drawConstIndicator",value:function(){if(this.constIndicator){for(this.constIndicator.clear();this.constIndicator.children[0];)this.constIndicator.removeChild(this.constIndicator.children[0]);!this.options.constIndicators||!this.valueScale||this.options.constIndicators.forEach(({color:I="black",opacity:A=1,label:d=null,labelColor:h="black",labelOpacity:y=1,labelPosition:Z="leftTop",labelSize:b=12,value:w=0}={})=>{const S=Mi(I),R=Mi(h);this.constIndicator.beginFill(S,A);const H=this.valueScale(w);let N=0,D=0;if(d){const M=new $t.PIXI.Text(d,{fontFamily:"Arial",fontSize:b,fill:R});switch(M.alpha=y,Z){case"right":M.anchor.x=1,M.anchor.y=.5,M.x=this.position[0]+this.dimensions[0]-6,M.y=H,D=M.width+8;break;case"rightBottom":M.anchor.x=1,M.anchor.y=0,M.x=this.position[0]+this.dimensions[0]-6,M.y=H;break;case"rightTop":M.anchor.x=1,M.anchor.y=1,M.x=this.position[0]+this.dimensions[0]-6,M.y=H;break;case"left":M.anchor.x=0,M.anchor.y=.5,M.x=this.position[0]+2,M.y=H,N=M.width+4;break;case"leftBottom":M.anchor.x=0,M.anchor.y=0,M.x=this.position[0]+2,M.y=H;break;case"leftTop":default:M.anchor.x=0,M.anchor.y=1,M.x=this.position[0]+2,M.y=H;break}this.constIndicator.addChild(M)}this.constIndicator.drawRect(this.position[0]+N,H,this.dimensions[0]-D,1)})}}},{key:"exportSVG",value:function(){let I=null,A=null;n(G(s.prototype),"exportSVG",this)?[A,I]=n(G(s.prototype),"exportSVG",this).call(this):(A=document.createElement("g"),I=A),A.setAttribute("class","horizontal-tiled-1d-track");const d=document.createElement("g");return I.appendChild(d),this.options.constIndicators&&this.options.constIndicators.forEach(({color:h="black",opacity:y=1,label:Z=null,labelColor:b="black",labelOpacity:w=1,labelPosition:S="leftTop",labelSize:R=12,value:H=0}={})=>{const N=this.valueScale(H);if(Z){const M=document.createElement("text");switch(M.textContent=Z,M.setAttribute("x",this.position[0]),M.setAttribute("y",N),M.setAttribute("style",`font-family: 'Arial'; font-size: ${R}px; fill: ${b}; fill-opacity: ${w};`),S){case"rightBottom":M.setAttribute("x",this.position[0]+this.dimensions[0]-6),M.setAttribute("y",N+R+2),M.setAttribute("text-anchor","end");break;case"right":case"rightTop":M.setAttribute("x",this.position[0]+this.dimensions[0]-6),M.setAttribute("y",N-2),M.setAttribute("text-anchor","end");break;case"leftBottom":M.setAttribute("x",this.position[0]+2),M.setAttribute("y",N+R+2);break;case"left":case"leftTop":default:M.setAttribute("x",this.position[0]+2),M.setAttribute("y",N-2);break}d.appendChild(M)}const D=document.createElement("line");D.setAttribute("x1",this.position[0]),D.setAttribute("y1",N),D.setAttribute("x2",this.dimensions[0]),D.setAttribute("y2",N),D.setAttribute("stroke",h),D.setAttribute("stroke-opacity",y),d.appendChild(D)}),[A,I]}}]),s}(X7),Oye=function(g){o(s,g);var a=l(s);function s(C,I){var A;return T(this,s),A=a.call(this,C,I),A.pMain=A.pMobile,A}return E(s,[{key:"areAllVisibleTilesLoaded",value:function(){return!0}},{key:"initTile",value:function(I){const A=I.graphics;I.textGraphics=new $t.PIXI.Graphics,I.text=new $t.PIXI.Text(`${I.tileData.zoomLevel}/${I.tileData.tilePos.join("/")}`,{fontFamily:"Arial",fontSize:32,fill:16715792,align:"center"}),I.textGraphics.addChild(I.text),I.text.anchor.x=.5,I.text.anchor.y=.5,A.addChild(I.textGraphics),this.drawTile(I)}},{key:"destroyTile",value:function(I){}},{key:"drawTile",value:function(I){if(n(G(s.prototype),"drawTile",this).call(this,I),!I.graphics)return;const A=I.graphics,{tileX:d,tileWidth:h}=this.getTilePosAndDimensions(I.tileData.zoomLevel,I.tileData.tilePos),y=1/((this._xScale(1)-this._xScale(0))/(this._refXScale(1)-this._refXScale(0)));I.text.scale.x=y,A.clear();const Z=this.dimensions[1],b=this._refXScale(d+h)-this._refXScale(d);I.textGraphics.position.x=this._refXScale(d)+b/2,I.textGraphics.position.y=Z/2;const w=this._refXScale(d);A.lineStyle(4*y,255,1),A.beginFill(16740363,.4),A.alpha=.5,A.moveTo(w,0),A.lineTo(w,Z),A.moveTo(w+b,0),A.lineTo(w+b,Z),A.lineStyle(0,255,1),A.drawRect(w,0,b,Z)}}]),s}(c1),Lye=function(g){o(s,g);var a=l(s);function s(){return T(this,s),a.apply(this,arguments)}return E(s,[{key:"calculateZoomLevel",value:function(){const I=Gi.calculateZoomLevel(this._yScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]);return Math.min(I,this.maxZoom)}},{key:"relevantScale",value:function(){return this._yScale}},{key:"zoomed",value:function(I,A){n(G(s.prototype),"zoomed",this).call(this,I,A);const d=1,h=(A(1)-A(0))/(this._refYScale(1)-this._refYScale(0)),y=this.position[0],Z=A(0)+this.position[1]-this._refYScale(1)*h;this.pMain.position.x=y,this.pMain.position.y=Z,this.pMain.scale.x=d,this.pMain.scale.y=h}}]),s}(X7),Jye=function(g){o(s,g);var a=l(s);function s(){return T(this,s),a.apply(this,arguments)}return E(s,[{key:"areAllVisibleTilesLoaded",value:function(){return!0}},{key:"initTile",value:function(I){const A=I.graphics;I.textGraphics=new $t.PIXI.Graphics,I.text=new $t.PIXI.Text(`${I.tileData.zoomLevel}/${I.tileData.tilePos.join("/")}`,{fontFamily:"Arial",fontSize:32,fill:16715792,align:"center"}),I.textGraphics.addChild(I.text),I.text.anchor.x=.5,I.text.anchor.y=.5,I.text.rotation=-Math.PI/2,A.addChild(I.textGraphics),this.drawTile(I,A)}},{key:"destroyTile",value:function(I,A){}},{key:"drawTile",value:function(I){if(n(G(s.prototype),"drawTile",this).call(this,I),!I.graphics)return;const A=I.graphics,{tileY:d,tileHeight:h}=this.getTilePosAndDimensions(I.tileData.zoomLevel,I.tileData.tilePos),y=1/((this._yScale(1)-this._yScale(0))/(this._refYScale(1)-this._refYScale(0)));I.text.scale.x=y,A.clear(),A.lineStyle(4*y,255,1),A.beginFill(16740363,.4),A.alpha=.5;const Z=this.dimensions[0],b=this._refYScale(d+h)-this._refYScale(d);I.textGraphics.position.x=Z/2,I.textGraphics.position.y=this._refYScale(d)+b/2,A.drawRect(0,this._refYScale(d),Z,b)}},{key:"fetchNewTiles",value:function(I){I.forEach(A=>{const h=A.remoteId.split("."),y={zoomLevel:h[1],tilePos:h.slice(2,h.length).map(Z=>+Z)};this.fetchedTiles[A.tileId]=A,this.fetchedTiles[A.tileId].tileData=y,this.fetching.has(A.remoteId)&&this.fetching.delete(A.remoteId)}),this.synchronizeTilesAndGraphics()}}]),s}(Lye);var x7=Array.prototype.slice;function Zft(g){return g}var PX=1,zX=2,D7=3,BT=4,Uye=1e-6;function Bft(g){return"translate("+g+",0)"}function Gft(g){return"translate(0,"+g+")"}function Sft(g){return a=>+g(a)}function wft(g,a){return a=Math.max(0,g.bandwidth()-a*2)/2,g.round()&&(a=Math.round(a)),s=>+g(s)+a}function Tft(){return!this.__axis}function OX(g,a){var s=[],C=null,I=null,A=6,d=6,h=3,y=typeof window<"u"&&window.devicePixelRatio>1?0:.5,Z=g===PX||g===BT?-1:1,b=g===BT||g===zX?"x":"y",w=g===PX||g===D7?Bft:Gft;function S(R){var H=C??(a.ticks?a.ticks.apply(a,s):a.domain()),N=I??(a.tickFormat?a.tickFormat.apply(a,s):Zft),D=Math.max(A,0)+h,M=a.range(),z=+M[0]+y,K=+M[M.length-1]+y,P=(a.bandwidth?wft:Sft)(a.copy(),y),J=R.selection?R.selection():R,j=J.selectAll(".domain").data([null]),ie=J.selectAll(".tick").data(H,a).order(),te=ie.exit(),Ce=ie.enter().append("g").attr("class","tick"),ue=ie.select("line"),oe=ie.select("text");j=j.merge(j.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),ie=ie.merge(Ce),ue=ue.merge(Ce.append("line").attr("stroke","currentColor").attr(b+"2",Z*A)),oe=oe.merge(Ce.append("text").attr("fill","currentColor").attr(b,Z*D).attr("dy",g===PX?"0em":g===D7?"0.71em":"0.32em")),R!==J&&(j=j.transition(R),ie=ie.transition(R),ue=ue.transition(R),oe=oe.transition(R),te=te.transition(R).attr("opacity",Uye).attr("transform",function(he){return isFinite(he=P(he))?w(he+y):this.getAttribute("transform")}),Ce.attr("opacity",Uye).attr("transform",function(he){var ye=this.parentNode.__axis;return w((ye&&isFinite(ye=ye(he))?ye:P(he))+y)})),te.remove(),j.attr("d",g===BT||g===zX?d?"M"+Z*d+","+z+"H"+y+"V"+K+"H"+Z*d:"M"+y+","+z+"V"+K:d?"M"+z+","+Z*d+"V"+y+"H"+K+"V"+Z*d:"M"+z+","+y+"H"+K),ie.attr("opacity",1).attr("transform",function(he){return w(P(he)+y)}),ue.attr(b+"2",Z*A),oe.attr(b,Z*D).text(N),J.filter(Tft).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",g===zX?"start":g===BT?"end":"middle"),J.each(function(){this.__axis=P})}return S.scale=function(R){return arguments.length?(a=R,S):a},S.ticks=function(){return s=x7.call(arguments),S},S.tickArguments=function(R){return arguments.length?(s=R==null?[]:x7.call(R),S):s.slice()},S.tickValues=function(R){return arguments.length?(C=R==null?null:x7.call(R),S):C&&C.slice()},S.tickFormat=function(R){return arguments.length?(I=R,S):I},S.tickSize=function(R){return arguments.length?(A=d=+R,S):A},S.tickSizeInner=function(R){return arguments.length?(A=+R,S):A},S.tickSizeOuter=function(R){return arguments.length?(d=+R,S):d},S.tickPadding=function(R){return arguments.length?(h=+R,S):h},S.offset=function(R){return arguments.length?(y=+R,S):y},S}function Qye(g){return OX(PX,g)}function Rft(g){return OX(zX,g)}function Vft(g){return OX(D7,g)}function jye(g){return OX(BT,g)}const Eft=Object.freeze(Object.defineProperty({__proto__:null,axisTop:Qye,axisRight:Rft,axisBottom:Vft,axisLeft:jye},Symbol.toStringTag,{value:"Module"}));let $f=function(g){o(s,g);var a=l(s);function s(C,I){var A;T(this,s),A=a.call(this,C,I);const{svgElement:d}=C;return A.gMain=Mn(d).append("g"),A.clipUid=Fn.nice(),A.clipRect=A.gMain.append("clipPath").attr("id",`track-bounds-${A.clipUid}`).append("rect"),A.gMain.attr("clip-path",`url(#track-bounds-${A.clipUid})`),A}return E(s,[{key:"setPosition",value:function(I){this.position=I,this.gMain.attr("transform",`translate(${this.position[0]},${this.position[1]})`),this.draw()}},{key:"setDimensions",value:function(I){this.dimensions=I,this._xScale.range([0,this.dimensions[0]]),this._yScale.range([0,this.dimensions[1]]),I[0]>=0&&I[1]>=0?(this.clipRect.attr("width",I[0]),this.clipRect.attr("height",I[1])):(this.clipRect.attr("width",0),this.clipRect.attr("height",0)),this.draw()}},{key:"remove",value:function(){this.gMain.remove(),this.gMain=null}},{key:"draw",value:function(){return this}}]),s}(t1),$ye=function(g){o(s,g);var a=l(s);function s(C,I){var A;return T(this,s),A=a.call(this,C,I),A.axis=Qye(A._xScale),A.gAxis=A.gMain.append("g"),A.tilesetInfo=!0,A}return E(s,[{key:"setDimensions",value:function(I){n(G(s.prototype),"setDimensions",this).call(this,I),this.axis.ticks(Math.ceil(this.dimensions[0]/150)),this.gAxis.attr("transform",`translate(0,${I[1]})`)}},{key:"draw",value:function(){return this.axis.scale(this._xScale),this.gAxis.call(this.axis),this}},{key:"zoomed",value:function(I,A){n(G(s.prototype),"zoomed",this).call(this,I,A),this.draw()}}]),s}($f),qye=function(g){o(s,g);var a=l(s);function s(C,I){var A;return T(this,s),A=a.call(this,C,I),A.axis=jye(A._yScale),A.gAxis=A.gMain.append("g"),A.tilesetInfo=!0,A}return E(s,[{key:"setDimensions",value:function(I){n(G(s.prototype),"setDimensions",this).call(this,I),this.axis.ticks(Math.ceil(this.dimensions[1]/150)),this.gAxis.attr("transform",`translate(${I[0]},0)`)}},{key:"draw",value:function(){return this.axis.scale(this._yScale),this.gAxis.call(this.axis),this}},{key:"zoomed",value:function(I,A){n(G(s.prototype),"zoomed",this).call(this,I,A),this.draw()}}]),s}($f);var Yn={},Vg={},M7=32;Vg.INT_BITS=M7,Vg.INT_MAX=2147483647,Vg.INT_MIN=-1<0)-(g<0)},Vg.abs=function(g){var a=g>>M7-1;return(g^a)-a},Vg.min=function(g,a){return a^(g^a)&-(g65535)<<4,g>>>=a,s=(g>255)<<3,g>>>=s,a|=s,s=(g>15)<<2,g>>>=s,a|=s,s=(g>3)<<1,g>>>=s,a|=s,a|g>>1},Vg.log10=function(g){return g>=1e9?9:g>=1e8?8:g>=1e7?7:g>=1e6?6:g>=1e5?5:g>=1e4?4:g>=1e3?3:g>=100?2:g>=10?1:0},Vg.popCount=function(g){return g=g-(g>>>1&1431655765),g=(g&858993459)+(g>>>2&858993459),(g+(g>>>4)&252645135)*16843009>>>24};function eve(g){var a=32;return g&=-g,g&&a--,g&65535&&(a-=16),g&16711935&&(a-=8),g&252645135&&(a-=4),g&858993459&&(a-=2),g&1431655765&&(a-=1),a}Vg.countTrailingZeros=eve,Vg.nextPow2=function(g){return g+=g===0,--g,g|=g>>>1,g|=g>>>2,g|=g>>>4,g|=g>>>8,g|=g>>>16,g+1},Vg.prevPow2=function(g){return g|=g>>>1,g|=g>>>2,g|=g>>>4,g|=g>>>8,g|=g>>>16,g-(g>>>1)},Vg.parity=function(g){return g^=g>>>16,g^=g>>>8,g^=g>>>4,g&=15,27030>>>g&1};var GT=new Array(256);(function(g){for(var a=0;a<256;++a){var s=a,C=a,I=7;for(s>>>=1;s;s>>>=1)C<<=1,C|=s&1,--I;g[a]=C<>>8&255]<<16|GT[g>>>16&255]<<8|GT[g>>>24&255]},Vg.interleave2=function(g,a){return g&=65535,g=(g|g<<8)&16711935,g=(g|g<<4)&252645135,g=(g|g<<2)&858993459,g=(g|g<<1)&1431655765,a&=65535,a=(a|a<<8)&16711935,a=(a|a<<4)&252645135,a=(a|a<<2)&858993459,a=(a|a<<1)&1431655765,g|a<<1},Vg.deinterleave2=function(g,a){return g=g>>>a&1431655765,g=(g|g>>>1)&858993459,g=(g|g>>>2)&252645135,g=(g|g>>>4)&16711935,g=(g|g>>>16)&65535,g<<16>>16},Vg.interleave3=function(g,a,s){return g&=1023,g=(g|g<<16)&4278190335,g=(g|g<<8)&251719695,g=(g|g<<4)&3272356035,g=(g|g<<2)&1227133513,a&=1023,a=(a|a<<16)&4278190335,a=(a|a<<8)&251719695,a=(a|a<<4)&3272356035,a=(a|a<<2)&1227133513,g|=a<<1,s&=1023,s=(s|s<<16)&4278190335,s=(s|s<<8)&251719695,s=(s|s<<4)&3272356035,s=(s|s<<2)&1227133513,g|s<<2},Vg.deinterleave3=function(g,a){return g=g>>>a&1227133513,g=(g|g>>>2)&3272356035,g=(g|g>>>4)&251719695,g=(g|g>>>8)&4278190335,g=(g|g>>>16)&1023,g<<22>>22},Vg.nextCombination=function(g){var a=g|g-1;return a+1|(~a&-~a)-1>>>eve(g)+1};function tve(g,a,s){var C=g[s]|0;if(C<=0)return[];var I=new Array(C),A;if(s===g.length-1)for(A=0;A"u"&&(a=0),typeof g){case"number":if(g>0)return Hft(g|0,a);break;case"object":if(typeof g.length=="number")return tve(g,a,0);break}return[]}var Nft=Wft,ive={},LX={};LX.byteLength=xft,LX.toByteArray=Mft,LX.fromByteArray=Kft;for(var tu=[],AC=[],kft=typeof Uint8Array<"u"?Uint8Array:Array,F7="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",A1=0,Xft=F7.length;A10)throw new Error("Invalid string. Length must be a multiple of 4");var s=g.indexOf("=");s===-1&&(s=a);var C=s===a?0:4-s%4;return[s,C]}function xft(g){var a=nve(g),s=a[0],C=a[1];return(s+C)*3/4-C}function Dft(g,a,s){return(a+s)*3/4-s}function Mft(g){var a,s=nve(g),C=s[0],I=s[1],A=new kft(Dft(g,C,I)),d=0,h=I>0?C-4:C,y;for(y=0;y>16&255,A[d++]=a>>8&255,A[d++]=a&255;return I===2&&(a=AC[g.charCodeAt(y)]<<2|AC[g.charCodeAt(y+1)]>>4,A[d++]=a&255),I===1&&(a=AC[g.charCodeAt(y)]<<10|AC[g.charCodeAt(y+1)]<<4|AC[g.charCodeAt(y+2)]>>2,A[d++]=a>>8&255,A[d++]=a&255),A}function Fft(g){return tu[g>>18&63]+tu[g>>12&63]+tu[g>>6&63]+tu[g&63]}function Yft(g,a,s){for(var C,I=[],A=a;Ah?h:d+A));return C===1?(a=g[s-1],I.push(tu[a>>2]+tu[a<<4&63]+"==")):C===2&&(a=(g[s-2]<<8)+g[s-1],I.push(tu[a>>10]+tu[a>>4&63]+tu[a<<2&63]+"=")),I.join("")}var Y7={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */Y7.read=function(g,a,s,C,I){var A,d,h=I*8-C-1,y=(1<>1,b=-7,w=s?I-1:0,S=s?-1:1,R=g[a+w];for(w+=S,A=R&(1<<-b)-1,R>>=-b,b+=h;b>0;A=A*256+g[a+w],w+=S,b-=8);for(d=A&(1<<-b)-1,A>>=-b,b+=C;b>0;d=d*256+g[a+w],w+=S,b-=8);if(A===0)A=1-Z;else{if(A===y)return d?NaN:(R?-1:1)*(1/0);d=d+Math.pow(2,C),A=A-Z}return(R?-1:1)*d*Math.pow(2,A-C)},Y7.write=function(g,a,s,C,I,A){var d,h,y,Z=A*8-I-1,b=(1<>1,S=I===23?Math.pow(2,-24)-Math.pow(2,-77):0,R=C?0:A-1,H=C?1:-1,N=a<0||a===0&&1/a<0?1:0;for(a=Math.abs(a),isNaN(a)||a===1/0?(h=isNaN(a)?1:0,d=b):(d=Math.floor(Math.log(a)/Math.LN2),a*(y=Math.pow(2,-d))<1&&(d--,y*=2),d+w>=1?a+=S/y:a+=S*Math.pow(2,1-w),a*y>=2&&(d++,y/=2),d+w>=b?(h=0,d=b):d+w>=1?(h=(a*y-1)*Math.pow(2,I),d=d+w):(h=a*Math.pow(2,w-1)*Math.pow(2,I),d=0));I>=8;g[s+R]=h&255,R+=H,h/=256,I-=8);for(d=d<0;g[s+R]=d&255,R+=H,d/=256,Z-=8);g[s+R-H]|=N*128};/*! -* The buffer module from node.js, for the browser. -* -* @author Feross Aboukhadijeh -* @license MIT -*/(function(g){const a=LX,s=Y7,C=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;g.Buffer=h,g.SlowBuffer=z,g.INSPECT_MAX_BYTES=50;const I=2147483647;g.kMaxLength=I,h.TYPED_ARRAY_SUPPORT=A(),!h.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function A(){try{const re=new Uint8Array(1),U={foo:function(){return 42}};return Object.setPrototypeOf(U,Uint8Array.prototype),Object.setPrototypeOf(re,U),re.foo()===42}catch{return!1}}Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}});function d(re){if(re>I)throw new RangeError('The value "'+re+'" is invalid for option "size"');const U=new Uint8Array(re);return Object.setPrototypeOf(U,h.prototype),U}function h(re,U,q){if(typeof re=="number"){if(typeof U=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return w(re)}return y(re,U,q)}h.poolSize=8192;function y(re,U,q){if(typeof re=="string")return S(re,U);if(ArrayBuffer.isView(re))return H(re);if(re==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof re);if(ln(re,ArrayBuffer)||re&&ln(re.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ln(re,SharedArrayBuffer)||re&&ln(re.buffer,SharedArrayBuffer)))return N(re,U,q);if(typeof re=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const pe=re.valueOf&&re.valueOf();if(pe!=null&&pe!==re)return h.from(pe,U,q);const Fe=D(re);if(Fe)return Fe;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof re[Symbol.toPrimitive]=="function")return h.from(re[Symbol.toPrimitive]("string"),U,q);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof re)}h.from=function(re,U,q){return y(re,U,q)},Object.setPrototypeOf(h.prototype,Uint8Array.prototype),Object.setPrototypeOf(h,Uint8Array);function Z(re){if(typeof re!="number")throw new TypeError('"size" argument must be of type number');if(re<0)throw new RangeError('The value "'+re+'" is invalid for option "size"')}function b(re,U,q){return Z(re),re<=0?d(re):U!==void 0?typeof q=="string"?d(re).fill(U,q):d(re).fill(U):d(re)}h.alloc=function(re,U,q){return b(re,U,q)};function w(re){return Z(re),d(re<0?0:M(re)|0)}h.allocUnsafe=function(re){return w(re)},h.allocUnsafeSlow=function(re){return w(re)};function S(re,U){if((typeof U!="string"||U==="")&&(U="utf8"),!h.isEncoding(U))throw new TypeError("Unknown encoding: "+U);const q=K(re,U)|0;let pe=d(q);const Fe=pe.write(re,U);return Fe!==q&&(pe=pe.slice(0,Fe)),pe}function R(re){const U=re.length<0?0:M(re.length)|0,q=d(U);for(let pe=0;pe=I)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I.toString(16)+" bytes");return re|0}function z(re){return+re!=re&&(re=0),h.alloc(+re)}h.isBuffer=function(U){return U!=null&&U._isBuffer===!0&&U!==h.prototype},h.compare=function(U,q){if(ln(U,Uint8Array)&&(U=h.from(U,U.offset,U.byteLength)),ln(q,Uint8Array)&&(q=h.from(q,q.offset,q.byteLength)),!h.isBuffer(U)||!h.isBuffer(q))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(U===q)return 0;let pe=U.length,Fe=q.length;for(let $e=0,ft=Math.min(pe,Fe);$eFe.length?(h.isBuffer(ft)||(ft=h.from(ft)),ft.copy(Fe,$e)):Uint8Array.prototype.set.call(Fe,ft,$e);else if(h.isBuffer(ft))ft.copy(Fe,$e);else throw new TypeError('"list" argument must be an Array of Buffers');$e+=ft.length}return Fe};function K(re,U){if(h.isBuffer(re))return re.length;if(ArrayBuffer.isView(re)||ln(re,ArrayBuffer))return re.byteLength;if(typeof re!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof re);const q=re.length,pe=arguments.length>2&&arguments[2]===!0;if(!pe&&q===0)return 0;let Fe=!1;for(;;)switch(U){case"ascii":case"latin1":case"binary":return q;case"utf8":case"utf-8":return Bi(re).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return q*2;case"hex":return q>>>1;case"base64":return On(re).length;default:if(Fe)return pe?-1:Bi(re).length;U=(""+U).toLowerCase(),Fe=!0}}h.byteLength=K;function P(re,U,q){let pe=!1;if((U===void 0||U<0)&&(U=0),U>this.length||((q===void 0||q>this.length)&&(q=this.length),q<=0)||(q>>>=0,U>>>=0,q<=U))return"";for(re||(re="utf8");;)switch(re){case"hex":return nt(this,U,q);case"utf8":case"utf-8":return Ie(this,U,q);case"ascii":return _e(this,U,q);case"latin1":case"binary":return qe(this,U,q);case"base64":return ye(this,U,q);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return At(this,U,q);default:if(pe)throw new TypeError("Unknown encoding: "+re);re=(re+"").toLowerCase(),pe=!0}}h.prototype._isBuffer=!0;function J(re,U,q){const pe=re[U];re[U]=re[q],re[q]=pe}h.prototype.swap16=function(){const U=this.length;if(U%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let q=0;qq&&(U+=" ... "),""},C&&(h.prototype[C]=h.prototype.inspect),h.prototype.compare=function(U,q,pe,Fe,$e){if(ln(U,Uint8Array)&&(U=h.from(U,U.offset,U.byteLength)),!h.isBuffer(U))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof U);if(q===void 0&&(q=0),pe===void 0&&(pe=U?U.length:0),Fe===void 0&&(Fe=0),$e===void 0&&($e=this.length),q<0||pe>U.length||Fe<0||$e>this.length)throw new RangeError("out of range index");if(Fe>=$e&&q>=pe)return 0;if(Fe>=$e)return-1;if(q>=pe)return 1;if(q>>>=0,pe>>>=0,Fe>>>=0,$e>>>=0,this===U)return 0;let ft=$e-Fe,ri=pe-q;const bi=Math.min(ft,ri),Ni=this.slice(Fe,$e),Ti=U.slice(q,pe);for(let Ki=0;Ki2147483647?q=2147483647:q<-2147483648&&(q=-2147483648),q=+q,Ht(q)&&(q=Fe?0:re.length-1),q<0&&(q=re.length+q),q>=re.length){if(Fe)return-1;q=re.length-1}else if(q<0)if(Fe)q=0;else return-1;if(typeof U=="string"&&(U=h.from(U,pe)),h.isBuffer(U))return U.length===0?-1:ie(re,U,q,pe,Fe);if(typeof U=="number")return U=U&255,typeof Uint8Array.prototype.indexOf=="function"?Fe?Uint8Array.prototype.indexOf.call(re,U,q):Uint8Array.prototype.lastIndexOf.call(re,U,q):ie(re,[U],q,pe,Fe);throw new TypeError("val must be string, number or Buffer")}function ie(re,U,q,pe,Fe){let $e=1,ft=re.length,ri=U.length;if(pe!==void 0&&(pe=String(pe).toLowerCase(),pe==="ucs2"||pe==="ucs-2"||pe==="utf16le"||pe==="utf-16le")){if(re.length<2||U.length<2)return-1;$e=2,ft/=2,ri/=2,q/=2}function bi(Ti,Ki){return $e===1?Ti[Ki]:Ti.readUInt16BE(Ki*$e)}let Ni;if(Fe){let Ti=-1;for(Ni=q;Nift&&(q=ft-ri),Ni=q;Ni>=0;Ni--){let Ti=!0;for(let Ki=0;KiFe&&(pe=Fe)):pe=Fe;const $e=U.length;pe>$e/2&&(pe=$e/2);let ft;for(ft=0;ft>>0,isFinite(pe)?(pe=pe>>>0,Fe===void 0&&(Fe="utf8")):(Fe=pe,pe=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const $e=this.length-q;if((pe===void 0||pe>$e)&&(pe=$e),U.length>0&&(pe<0||q<0)||q>this.length)throw new RangeError("Attempt to write outside buffer bounds");Fe||(Fe="utf8");let ft=!1;for(;;)switch(Fe){case"hex":return te(this,U,q,pe);case"utf8":case"utf-8":return Ce(this,U,q,pe);case"ascii":case"latin1":case"binary":return ue(this,U,q,pe);case"base64":return oe(this,U,q,pe);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,U,q,pe);default:if(ft)throw new TypeError("Unknown encoding: "+Fe);Fe=(""+Fe).toLowerCase(),ft=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ye(re,U,q){return U===0&&q===re.length?a.fromByteArray(re):a.fromByteArray(re.slice(U,q))}function Ie(re,U,q){q=Math.min(re.length,q);const pe=[];let Fe=U;for(;Fe239?4:$e>223?3:$e>191?2:1;if(Fe+ri<=q){let bi,Ni,Ti,Ki;switch(ri){case 1:$e<128&&(ft=$e);break;case 2:bi=re[Fe+1],(bi&192)===128&&(Ki=($e&31)<<6|bi&63,Ki>127&&(ft=Ki));break;case 3:bi=re[Fe+1],Ni=re[Fe+2],(bi&192)===128&&(Ni&192)===128&&(Ki=($e&15)<<12|(bi&63)<<6|Ni&63,Ki>2047&&(Ki<55296||Ki>57343)&&(ft=Ki));break;case 4:bi=re[Fe+1],Ni=re[Fe+2],Ti=re[Fe+3],(bi&192)===128&&(Ni&192)===128&&(Ti&192)===128&&(Ki=($e&15)<<18|(bi&63)<<12|(Ni&63)<<6|Ti&63,Ki>65535&&Ki<1114112&&(ft=Ki))}}ft===null?(ft=65533,ri=1):ft>65535&&(ft-=65536,pe.push(ft>>>10&1023|55296),ft=56320|ft&1023),pe.push(ft),Fe+=ri}return We(pe)}const fe=4096;function We(re){const U=re.length;if(U<=fe)return String.fromCharCode.apply(String,re);let q="",pe=0;for(;pepe)&&(q=pe);let Fe="";for(let $e=U;$epe&&(U=pe),q<0?(q+=pe,q<0&&(q=0)):q>pe&&(q=pe),qq)throw new RangeError("Trying to access beyond buffer length")}h.prototype.readUintLE=h.prototype.readUIntLE=function(U,q,pe){U=U>>>0,q=q>>>0,pe||Tt(U,q,this.length);let Fe=this[U],$e=1,ft=0;for(;++ft>>0,q=q>>>0,pe||Tt(U,q,this.length);let Fe=this[U+--q],$e=1;for(;q>0&&($e*=256);)Fe+=this[U+--q]*$e;return Fe},h.prototype.readUint8=h.prototype.readUInt8=function(U,q){return U=U>>>0,q||Tt(U,1,this.length),this[U]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(U,q){return U=U>>>0,q||Tt(U,2,this.length),this[U]|this[U+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(U,q){return U=U>>>0,q||Tt(U,2,this.length),this[U]<<8|this[U+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(U,q){return U=U>>>0,q||Tt(U,4,this.length),(this[U]|this[U+1]<<8|this[U+2]<<16)+this[U+3]*16777216},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(U,q){return U=U>>>0,q||Tt(U,4,this.length),this[U]*16777216+(this[U+1]<<16|this[U+2]<<8|this[U+3])},h.prototype.readBigUInt64LE=Qe(function(U){U=U>>>0,Zi(U,"offset");const q=this[U],pe=this[U+7];(q===void 0||pe===void 0)&&ui(U,this.length-8);const Fe=q+this[++U]*2**8+this[++U]*2**16+this[++U]*2**24,$e=this[++U]+this[++U]*2**8+this[++U]*2**16+pe*2**24;return BigInt(Fe)+(BigInt($e)<>>0,Zi(U,"offset");const q=this[U],pe=this[U+7];(q===void 0||pe===void 0)&&ui(U,this.length-8);const Fe=q*2**24+this[++U]*2**16+this[++U]*2**8+this[++U],$e=this[++U]*2**24+this[++U]*2**16+this[++U]*2**8+pe;return(BigInt(Fe)<>>0,q=q>>>0,pe||Tt(U,q,this.length);let Fe=this[U],$e=1,ft=0;for(;++ft=$e&&(Fe-=Math.pow(2,8*q)),Fe},h.prototype.readIntBE=function(U,q,pe){U=U>>>0,q=q>>>0,pe||Tt(U,q,this.length);let Fe=q,$e=1,ft=this[U+--Fe];for(;Fe>0&&($e*=256);)ft+=this[U+--Fe]*$e;return $e*=128,ft>=$e&&(ft-=Math.pow(2,8*q)),ft},h.prototype.readInt8=function(U,q){return U=U>>>0,q||Tt(U,1,this.length),this[U]&128?(255-this[U]+1)*-1:this[U]},h.prototype.readInt16LE=function(U,q){U=U>>>0,q||Tt(U,2,this.length);const pe=this[U]|this[U+1]<<8;return pe&32768?pe|4294901760:pe},h.prototype.readInt16BE=function(U,q){U=U>>>0,q||Tt(U,2,this.length);const pe=this[U+1]|this[U]<<8;return pe&32768?pe|4294901760:pe},h.prototype.readInt32LE=function(U,q){return U=U>>>0,q||Tt(U,4,this.length),this[U]|this[U+1]<<8|this[U+2]<<16|this[U+3]<<24},h.prototype.readInt32BE=function(U,q){return U=U>>>0,q||Tt(U,4,this.length),this[U]<<24|this[U+1]<<16|this[U+2]<<8|this[U+3]},h.prototype.readBigInt64LE=Qe(function(U){U=U>>>0,Zi(U,"offset");const q=this[U],pe=this[U+7];(q===void 0||pe===void 0)&&ui(U,this.length-8);const Fe=this[U+4]+this[U+5]*2**8+this[U+6]*2**16+(pe<<24);return(BigInt(Fe)<>>0,Zi(U,"offset");const q=this[U],pe=this[U+7];(q===void 0||pe===void 0)&&ui(U,this.length-8);const Fe=(q<<24)+this[++U]*2**16+this[++U]*2**8+this[++U];return(BigInt(Fe)<>>0,q||Tt(U,4,this.length),s.read(this,U,!0,23,4)},h.prototype.readFloatBE=function(U,q){return U=U>>>0,q||Tt(U,4,this.length),s.read(this,U,!1,23,4)},h.prototype.readDoubleLE=function(U,q){return U=U>>>0,q||Tt(U,8,this.length),s.read(this,U,!0,52,8)},h.prototype.readDoubleBE=function(U,q){return U=U>>>0,q||Tt(U,8,this.length),s.read(this,U,!1,52,8)};function Ne(re,U,q,pe,Fe,$e){if(!h.isBuffer(re))throw new TypeError('"buffer" argument must be a Buffer instance');if(U>Fe||U<$e)throw new RangeError('"value" argument is out of bounds');if(q+pe>re.length)throw new RangeError("Index out of range")}h.prototype.writeUintLE=h.prototype.writeUIntLE=function(U,q,pe,Fe){if(U=+U,q=q>>>0,pe=pe>>>0,!Fe){const ri=Math.pow(2,8*pe)-1;Ne(this,U,q,pe,ri,0)}let $e=1,ft=0;for(this[q]=U&255;++ft>>0,pe=pe>>>0,!Fe){const ri=Math.pow(2,8*pe)-1;Ne(this,U,q,pe,ri,0)}let $e=pe-1,ft=1;for(this[q+$e]=U&255;--$e>=0&&(ft*=256);)this[q+$e]=U/ft&255;return q+pe},h.prototype.writeUint8=h.prototype.writeUInt8=function(U,q,pe){return U=+U,q=q>>>0,pe||Ne(this,U,q,1,255,0),this[q]=U&255,q+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(U,q,pe){return U=+U,q=q>>>0,pe||Ne(this,U,q,2,65535,0),this[q]=U&255,this[q+1]=U>>>8,q+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(U,q,pe){return U=+U,q=q>>>0,pe||Ne(this,U,q,2,65535,0),this[q]=U>>>8,this[q+1]=U&255,q+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(U,q,pe){return U=+U,q=q>>>0,pe||Ne(this,U,q,4,4294967295,0),this[q+3]=U>>>24,this[q+2]=U>>>16,this[q+1]=U>>>8,this[q]=U&255,q+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(U,q,pe){return U=+U,q=q>>>0,pe||Ne(this,U,q,4,4294967295,0),this[q]=U>>>24,this[q+1]=U>>>16,this[q+2]=U>>>8,this[q+3]=U&255,q+4};function Ge(re,U,q,pe,Fe){Dt(U,pe,Fe,re,q,7);let $e=Number(U&BigInt(4294967295));re[q++]=$e,$e=$e>>8,re[q++]=$e,$e=$e>>8,re[q++]=$e,$e=$e>>8,re[q++]=$e;let ft=Number(U>>BigInt(32)&BigInt(4294967295));return re[q++]=ft,ft=ft>>8,re[q++]=ft,ft=ft>>8,re[q++]=ft,ft=ft>>8,re[q++]=ft,q}function He(re,U,q,pe,Fe){Dt(U,pe,Fe,re,q,7);let $e=Number(U&BigInt(4294967295));re[q+7]=$e,$e=$e>>8,re[q+6]=$e,$e=$e>>8,re[q+5]=$e,$e=$e>>8,re[q+4]=$e;let ft=Number(U>>BigInt(32)&BigInt(4294967295));return re[q+3]=ft,ft=ft>>8,re[q+2]=ft,ft=ft>>8,re[q+1]=ft,ft=ft>>8,re[q]=ft,q+8}h.prototype.writeBigUInt64LE=Qe(function(U,q=0){return Ge(this,U,q,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeBigUInt64BE=Qe(function(U,q=0){return He(this,U,q,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeIntLE=function(U,q,pe,Fe){if(U=+U,q=q>>>0,!Fe){const bi=Math.pow(2,8*pe-1);Ne(this,U,q,pe,bi-1,-bi)}let $e=0,ft=1,ri=0;for(this[q]=U&255;++$e>0)-ri&255;return q+pe},h.prototype.writeIntBE=function(U,q,pe,Fe){if(U=+U,q=q>>>0,!Fe){const bi=Math.pow(2,8*pe-1);Ne(this,U,q,pe,bi-1,-bi)}let $e=pe-1,ft=1,ri=0;for(this[q+$e]=U&255;--$e>=0&&(ft*=256);)U<0&&ri===0&&this[q+$e+1]!==0&&(ri=1),this[q+$e]=(U/ft>>0)-ri&255;return q+pe},h.prototype.writeInt8=function(U,q,pe){return U=+U,q=q>>>0,pe||Ne(this,U,q,1,127,-128),U<0&&(U=255+U+1),this[q]=U&255,q+1},h.prototype.writeInt16LE=function(U,q,pe){return U=+U,q=q>>>0,pe||Ne(this,U,q,2,32767,-32768),this[q]=U&255,this[q+1]=U>>>8,q+2},h.prototype.writeInt16BE=function(U,q,pe){return U=+U,q=q>>>0,pe||Ne(this,U,q,2,32767,-32768),this[q]=U>>>8,this[q+1]=U&255,q+2},h.prototype.writeInt32LE=function(U,q,pe){return U=+U,q=q>>>0,pe||Ne(this,U,q,4,2147483647,-2147483648),this[q]=U&255,this[q+1]=U>>>8,this[q+2]=U>>>16,this[q+3]=U>>>24,q+4},h.prototype.writeInt32BE=function(U,q,pe){return U=+U,q=q>>>0,pe||Ne(this,U,q,4,2147483647,-2147483648),U<0&&(U=4294967295+U+1),this[q]=U>>>24,this[q+1]=U>>>16,this[q+2]=U>>>8,this[q+3]=U&255,q+4},h.prototype.writeBigInt64LE=Qe(function(U,q=0){return Ge(this,U,q,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeBigInt64BE=Qe(function(U,q=0){return He(this,U,q,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Xe(re,U,q,pe,Fe,$e){if(q+pe>re.length)throw new RangeError("Index out of range");if(q<0)throw new RangeError("Index out of range")}function at(re,U,q,pe,Fe){return U=+U,q=q>>>0,Fe||Xe(re,U,q,4),s.write(re,U,q,pe,23,4),q+4}h.prototype.writeFloatLE=function(U,q,pe){return at(this,U,q,!0,pe)},h.prototype.writeFloatBE=function(U,q,pe){return at(this,U,q,!1,pe)};function bt(re,U,q,pe,Fe){return U=+U,q=q>>>0,Fe||Xe(re,U,q,8),s.write(re,U,q,pe,52,8),q+8}h.prototype.writeDoubleLE=function(U,q,pe){return bt(this,U,q,!0,pe)},h.prototype.writeDoubleBE=function(U,q,pe){return bt(this,U,q,!1,pe)},h.prototype.copy=function(U,q,pe,Fe){if(!h.isBuffer(U))throw new TypeError("argument should be a Buffer");if(pe||(pe=0),!Fe&&Fe!==0&&(Fe=this.length),q>=U.length&&(q=U.length),q||(q=0),Fe>0&&Fe=this.length)throw new RangeError("Index out of range");if(Fe<0)throw new RangeError("sourceEnd out of bounds");Fe>this.length&&(Fe=this.length),U.length-q>>0,pe=pe===void 0?this.length:pe>>>0,U||(U=0);let $e;if(typeof U=="number")for($e=q;$e2**32?Fe=_t(String(q)):typeof q=="bigint"&&(Fe=String(q),(q>BigInt(2)**BigInt(32)||q<-(BigInt(2)**BigInt(32)))&&(Fe=_t(Fe)),Fe+="n"),pe+=` It must be ${U}. Received ${Fe}`,pe},RangeError);function _t(re){let U="",q=re.length;const pe=re[0]==="-"?1:0;for(;q>=pe+4;q-=3)U=`_${re.slice(q-3,q)}${U}`;return`${re.slice(0,q)}${U}`}function Ci(re,U,q){Zi(U,"offset"),(re[U]===void 0||re[U+q]===void 0)&&ui(U,re.length-(q+1))}function Dt(re,U,q,pe,Fe,$e){if(re>q||re3?U===0||U===BigInt(0)?ri=`>= 0${ft} and < 2${ft} ** ${($e+1)*8}${ft}`:ri=`>= -(2${ft} ** ${($e+1)*8-1}${ft}) and < 2 ** ${($e+1)*8-1}${ft}`:ri=`>= ${U}${ft} and <= ${q}${ft}`,new xt.ERR_OUT_OF_RANGE("value",ri,re)}Ci(pe,Fe,$e)}function Zi(re,U){if(typeof re!="number")throw new xt.ERR_INVALID_ARG_TYPE(U,"number",re)}function ui(re,U,q){throw Math.floor(re)!==re?(Zi(re,q),new xt.ERR_OUT_OF_RANGE(q||"offset","an integer",re)):U<0?new xt.ERR_BUFFER_OUT_OF_BOUNDS:new xt.ERR_OUT_OF_RANGE(q||"offset",`>= ${q?1:0} and <= ${U}`,re)}const In=/[^+/0-9A-Za-z-_]/g;function Li(re){if(re=re.split("=")[0],re=re.trim().replace(In,""),re.length<2)return"";for(;re.length%4!==0;)re=re+"=";return re}function Bi(re,U){U=U||1/0;let q;const pe=re.length;let Fe=null;const $e=[];for(let ft=0;ft55295&&q<57344){if(!Fe){if(q>56319){(U-=3)>-1&&$e.push(239,191,189);continue}else if(ft+1===pe){(U-=3)>-1&&$e.push(239,191,189);continue}Fe=q;continue}if(q<56320){(U-=3)>-1&&$e.push(239,191,189),Fe=q;continue}q=(Fe-55296<<10|q-56320)+65536}else Fe&&(U-=3)>-1&&$e.push(239,191,189);if(Fe=null,q<128){if((U-=1)<0)break;$e.push(q)}else if(q<2048){if((U-=2)<0)break;$e.push(q>>6|192,q&63|128)}else if(q<65536){if((U-=3)<0)break;$e.push(q>>12|224,q>>6&63|128,q&63|128)}else if(q<1114112){if((U-=4)<0)break;$e.push(q>>18|240,q>>12&63|128,q>>6&63|128,q&63|128)}else throw new Error("Invalid code point")}return $e}function pn(re){const U=[];for(let q=0;q>8,Fe=q%256,$e.push(Fe),$e.push(pe);return $e}function On(re){return a.toByteArray(Li(re))}function Wg(re,U,q,pe){let Fe;for(Fe=0;Fe=U.length||Fe>=re.length);++Fe)U[Fe+q]=re[Fe];return Fe}function ln(re,U){return re instanceof U||re!=null&&re.constructor!=null&&re.constructor.name!=null&&re.constructor.name===U.name}function Ht(re){return re!==re}const Ye=function(){const re="0123456789abcdef",U=new Array(256);for(let q=0;q<16;++q){const pe=q*16;for(let Fe=0;Fe<16;++Fe)U[pe+Fe]=re[q]+re[Fe]}return U}();function Qe(re){return typeof BigInt>"u"?pt:re}function pt(){throw new Error("BigInt not supported")}})(ive);var qf=Vg,va=Nft,rve=ive.Buffer;globalThis.__TYPEDARRAY_POOL||(globalThis.__TYPEDARRAY_POOL={UINT8:va([32,0]),UINT16:va([32,0]),UINT32:va([32,0]),BIGUINT64:va([32,0]),INT8:va([32,0]),INT16:va([32,0]),INT32:va([32,0]),BIGINT64:va([32,0]),FLOAT:va([32,0]),DOUBLE:va([32,0]),DATA:va([32,0]),UINT8C:va([32,0]),BUFFER:va([32,0])});var _ft=typeof Uint8ClampedArray<"u",Pft=typeof BigUint64Array<"u",zft=typeof BigInt64Array<"u",ho=globalThis.__TYPEDARRAY_POOL;ho.UINT8C||(ho.UINT8C=va([32,0])),ho.BIGUINT64||(ho.BIGUINT64=va([32,0])),ho.BIGINT64||(ho.BIGINT64=va([32,0])),ho.BUFFER||(ho.BUFFER=va([32,0]));var JX=ho.DATA,UX=ho.BUFFER;Yn.free=function(a){if(rve.isBuffer(a))UX[qf.log2(a.length)].push(a);else{if(Object.prototype.toString.call(a)!=="[object ArrayBuffer]"&&(a=a.buffer),!a)return;var s=a.length||a.byteLength,C=qf.log2(s)|0;JX[C].push(a)}};function gve(g){if(g){var a=g.length||g.byteLength,s=qf.log2(a);JX[s].push(g)}}function Oft(g){gve(g.buffer)}Yn.freeUint8=Yn.freeUint16=Yn.freeUint32=Yn.freeBigUint64=Yn.freeInt8=Yn.freeInt16=Yn.freeInt32=Yn.freeBigInt64=Yn.freeFloat32=Yn.freeFloat=Yn.freeFloat64=Yn.freeDouble=Yn.freeUint8Clamped=Yn.freeDataView=Oft,Yn.freeArrayBuffer=gve,Yn.freeBuffer=function(a){UX[qf.log2(a.length)].push(a)},Yn.malloc=function(a,s){if(s===void 0||s==="arraybuffer")return wI(a);switch(s){case"uint8":return K7(a);case"uint16":return ove(a);case"uint32":return ave(a);case"int8":return sve(a);case"int16":return Ive(a);case"int32":return lve(a);case"float":case"float32":return Cve(a);case"double":case"float64":return cve(a);case"uint8_clamped":return Ave(a);case"bigint64":return dve(a);case"biguint64":return uve(a);case"buffer":return fve(a);case"data":case"dataview":return hve(a);default:return null}return null};function wI(a){var a=qf.nextPow2(a),s=qf.log2(a),C=JX[s];return C.length>0?C.pop():new ArrayBuffer(a)}Yn.mallocArrayBuffer=wI;function K7(g){return new Uint8Array(wI(g),0,g)}Yn.mallocUint8=K7;function ove(g){return new Uint16Array(wI(2*g),0,g)}Yn.mallocUint16=ove;function ave(g){return new Uint32Array(wI(4*g),0,g)}Yn.mallocUint32=ave;function sve(g){return new Int8Array(wI(g),0,g)}Yn.mallocInt8=sve;function Ive(g){return new Int16Array(wI(2*g),0,g)}Yn.mallocInt16=Ive;function lve(g){return new Int32Array(wI(4*g),0,g)}Yn.mallocInt32=lve;function Cve(g){return new Float32Array(wI(4*g),0,g)}Yn.mallocFloat32=Yn.mallocFloat=Cve;function cve(g){return new Float64Array(wI(8*g),0,g)}Yn.mallocFloat64=Yn.mallocDouble=cve;function Ave(g){return _ft?new Uint8ClampedArray(wI(g),0,g):K7(g)}Yn.mallocUint8Clamped=Ave;function uve(g){return Pft?new BigUint64Array(wI(8*g),0,g):null}Yn.mallocBigUint64=uve;function dve(g){return zft?new BigInt64Array(wI(8*g),0,g):null}Yn.mallocBigInt64=dve;function hve(g){return new DataView(wI(g),0,g)}Yn.mallocDataView=hve;function fve(g){g=qf.nextPow2(g);var a=qf.log2(g),s=UX[a];return s.length>0?s.pop():new rve(g)}Yn.mallocBuffer=fve,Yn.clearCache=function(){for(var a=0;a<32;++a)ho.UINT8[a].length=0,ho.UINT16[a].length=0,ho.UINT32[a].length=0,ho.INT8[a].length=0,ho.INT16[a].length=0,ho.INT32[a].length=0,ho.FLOAT[a].length=0,ho.DOUBLE[a].length=0,ho.BIGUINT64[a].length=0,ho.BIGINT64[a].length=0,ho.UINT8C[a].length=0,JX[a].length=0,UX[a].length=0};var Lft=Jft,QX=32;function Jft(g,a){a<=4*QX?jX(0,a-1,g):qX(0,a-1,g)}function jX(g,a,s){for(var C=2*(g+1),I=g+1;I<=a;++I){for(var A=s[C++],d=s[C++],h=I,y=C-2;h-- >g;){var Z=s[y-2],b=s[y-1];if(Zs[a+1]:!0}function $X(g,a,s,C){g*=2;var I=C[g];return I>1,h=d-C,y=d+C,Z=I,b=h,w=d,S=y,R=A,H=g+1,N=a-1,D=0;$d(Z,b,s)&&(D=Z,Z=b,b=D),$d(S,R,s)&&(D=S,S=R,R=D),$d(Z,w,s)&&(D=Z,Z=w,w=D),$d(b,w,s)&&(D=b,b=w,w=D),$d(Z,S,s)&&(D=Z,Z=S,S=D),$d(w,S,s)&&(D=w,w=S,S=D),$d(b,R,s)&&(D=b,b=R,R=D),$d(b,w,s)&&(D=b,b=w,w=D),$d(S,R,s)&&(D=S,S=R,R=D);for(var M=s[2*b],z=s[2*b+1],K=s[2*S],P=s[2*S+1],J=2*Z,j=2*w,ie=2*R,te=2*I,Ce=2*d,ue=2*A,oe=0;oe<2;++oe){var he=s[J+oe],ye=s[j+oe],Ie=s[ie+oe];s[te+oe]=he,s[Ce+oe]=ye,s[ue+oe]=Ie}pve(h,g,s),pve(y,a,s);for(var fe=H;fe<=N;++fe)if($X(fe,M,z,s))fe!==H&&mve(fe,H,s),++H;else if(!$X(fe,K,P,s))for(;;)if($X(N,K,P,s)){$X(N,M,z,s)?(Uft(fe,H,N,s),++H,--N):(mve(fe,N,s),--N);break}else{if(--N>>1;ex(Wn,z);for(var K=0,P=0,H=0;H=Zl)J=J-Zl|0,d1(eh,ob,P--,J);else if(J>=0)d1(Za,qd,K--,J);else if(J<=-Zl){J=-J-Zl|0;for(var j=0;j>>1;ex(Wn,z);for(var K=0,P=0,J=0,H=0;H>1===Wn[2*H+3]>>1&&(ie=2,H+=1),j<0){for(var te=-(j>>1)-1,Ce=0;Ce>1)-1;ie===0?d1(Za,qd,K--,te):ie===1?d1(eh,ob,P--,te):ie===2&&d1(u1,ST,J--,te)}}}function emt(g,a,s,C,I,A,d,h,y,Z,b,w){var S=0,R=2*g,H=a,N=a+g,D=1,M=1;C?M=Zl:D=Zl;for(var z=I;z>>1;ex(Wn,j);for(var ie=0,z=0;z=Zl?(Ce=!C,K-=Zl):(Ce=!!C,K-=1),Ce)h1(Za,qd,ie++,K);else{var ue=w[K],oe=R*K,he=b[oe+a+1],ye=b[oe+a+1+g];e:for(var Ie=0;Ie>>1;ex(Wn,K);for(var P=0,N=0;N=Zl)Za[P++]=D-Zl;else{D-=1;var j=b[D],ie=S*D,te=Z[ie+a+1],Ce=Z[ie+a+1+g];e:for(var ue=0;ue=0;--ue)if(Za[ue]===D){for(var Ie=ue+1;Ie"+O7+"-"+ix+"){"),g?(A(!0,!1),I.push("}else{"),A(!1,!1)):(I.push("if("+P7+"){"),A(!0,!0),I.push("}else{"),A(!0,!1),I.push("}}else{if("+P7+"){"),A(!1,!0),I.push("}else{"),A(!1,!1),I.push("}")),I.push("}}return "+a);var d=s.join("")+I.join(""),h=new Function(d);return h()}_7.partial=Gve(!1),_7.full=Gve(!0);var Sve=rmt,nmt="for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var _;if($)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t}var u=f[p];f[p]=f[m],f[m++]=u}}return m";function rmt(g,a){var s="abcdef".split("").concat(a),C=[];return g.indexOf("lo")>=0&&C.push("lo=e[k+n]"),g.indexOf("hi")>=0&&C.push("hi=e[k+o]"),s.push(nmt.replace("_",C.join()).replace("$",g)),Function.apply(void 0,s)}var gmt=Imt,omt=Sve,wve=omt("los&&I[w+a]>Z;--b,w-=d){for(var S=w,R=w+d,H=0;H>>1,Z=2*g,b=y,w=I[Z*y+a];d=D?(b=N,w=D):H>=z?(b=R,w=H):(b=M,w=z):D>=z?(b=N,w=D):z>=H?(b=R,w=H):(b=M,w=z);for(var J=Z*(h-1),j=Z*b,K=0;K=p0)&&!(p1>=hi)",["p0","p1"]),Vve=y1("lo===p0",["p0"]),fmt=y1("lo0;){Z-=1;var S=Z*j7,R=Ds[S],H=Ds[S+1],N=Ds[S+2],D=Ds[S+3],M=Ds[S+4],z=Ds[S+5],K=Z*$7,P=sb[K],J=sb[K+1],j=z&1,ie=!!(z&16),te=I,Ce=A,ue=h,oe=y;if(j&&(te=h,Ce=y,ue=I,oe=A),!(z&2&&(N=fmt(g,R,H,N,te,Ce,J),H>=N))&&!(z&4&&(H=mmt(g,R,H,N,te,Ce,P),H>=N))){var he=N-H,ye=M-D;if(ie){if(g*he*(he+ye)>>1;if(!(d<=0)){var h,y=tm.mallocDouble(2*d*I),Z=tm.mallocInt32(I);if(I=Wve(g,d,y,Z),I>0){if(d===1&&C)nx.init(I),h=nx.sweepComplete(d,s,0,I,y,Z,0,I,y,Z);else{var b=tm.mallocDouble(2*d*A),w=tm.mallocInt32(A);A=Wve(a,d,b,w),A>0&&(nx.init(I+A),d===1?h=nx.sweepBipartite(d,s,0,I,y,Z,0,A,b,w):h=Bmt(d,s,C,I,y,Z,A,b,w),tm.free(b),tm.free(w))}tm.free(y),tm.free(Z)}return h}}}var ET;function Nve(g,a){ET.push([g,a])}function Smt(g){return ET=[],rx(g,g,Nve,!0),ET}function wmt(g,a){return ET=[],rx(g,a,Nve,!1),ET}function Tmt(g,a,s){switch(arguments.length){case 1:return Smt(g);case 2:return typeof a=="function"?rx(g,g,a,!0):wmt(g,a);case 3:return rx(g,a,s,!1);default:throw new Error("box-intersect: Invalid arguments")}}var kve={exports:{}},Xve=Rmt,xve=+(Math.pow(2,27)+1);function Rmt(g,a,s){var C=g*a,I=xve*g,A=I-g,d=I-A,h=g-d,y=xve*a,Z=y-a,b=y-Z,w=a-b,S=C-d*b,R=S-h*b,H=R-d*w,N=h*w-H;return s?(s[0]=N,s[1]=C,s):[N,C]}var Vmt=Hmt;function Emt(g,a){var s=g+a,C=s-g,I=s-C,A=a-C,d=g-I,h=d+A;return h?[h,s]:[s]}function Hmt(g,a){var s=g.length|0,C=a.length|0;if(s===1&&C===1)return Emt(g[0],a[0]);var I=s+C,A=new Array(I),d=0,h=0,y=0,Z=Math.abs,b=g[h],w=Z(b),S=a[y],R=Z(S),H,N;w=C?(H=b,h+=1,h=C?(H=b,h+=1,h0){if(te<=0)return Ce;ue=ie+te}else if(ie<0){if(te>=0)return Ce;ue=-(ie+te)}else return Ce;var oe=h*ue;return Ce>=oe||Ce<=-oe?Ce:R(P,J,j)},function(P,J,j,ie){var te=P[0]-ie[0],Ce=J[0]-ie[0],ue=j[0]-ie[0],oe=P[1]-ie[1],he=J[1]-ie[1],ye=j[1]-ie[1],Ie=P[2]-ie[2],fe=J[2]-ie[2],We=j[2]-ie[2],_e=Ce*ye,qe=ue*he,nt=ue*oe,At=te*ye,Tt=te*he,Ne=Ce*oe,Ge=Ie*(_e-qe)+fe*(nt-At)+We*(Tt-Ne),He=(Math.abs(_e)+Math.abs(qe))*Math.abs(Ie)+(Math.abs(nt)+Math.abs(At))*Math.abs(fe)+(Math.abs(Tt)+Math.abs(Ne))*Math.abs(We),Xe=y*He;return Ge>Xe||-Ge>Xe?Ge:H(P,J,j,ie)}];function D(K){var P=N[K.length];return P||(P=N[K.length]=S(K.length)),P.apply(void 0,K)}function M(K,P,J,j,ie,te,Ce){return function(oe,he,ye,Ie,fe){switch(arguments.length){case 0:case 1:return 0;case 2:return j(oe,he);case 3:return ie(oe,he,ye);case 4:return te(oe,he,ye,Ie);case 5:return Ce(oe,he,ye,Ie,fe)}for(var We=new Array(arguments.length),_e=0;_e0;){var z=(y+I-1)%I,K=g[z];if(K[1]!==C)break;var P=K[0];D=Math.min(D,P),M=Math.max(M,P),y=z}if(y===0)return D<=s&&s<=M?0:1;d=y+1}for(var J=g[(y+I-1)%I][1];h+1{const s=[];for(let C=g;C{const s=g.map(h=>+h).sort((h,y)=>y-h),C=a.range()[1]-a.range()[0],A=s.map(h=>(a.domain()[1]-a.domain()[0])/h).map(h=>h/C),d=A.filter(h=>h<1);return d.length===0?0:A.indexOf(d[d.length-1])},_mt=(g,a,s,C)=>{const I=g.range()[1]-g.range()[0],A=Math.max((s-a)/(g.domain()[1]-g.domain()[0]),1),h=Math.max(0,Math.ceil(Math.log(I/384)/Math.LN2));let y=Math.round(Math.log(A)/Math.LN2)+h,Z=0;return C&&(Z=Math.floor(Math.log(256)/Math.log(2)-Math.log(C)/Math.log(2))),y+=Z,y},Fve=(g,a,s)=>{if(typeof s>"u"&&(s=Number.MAX_SAFE_INTEGER),g.resolutions)return Kmt(g.resolutions,a,g.min_pos[0],g.max_pos[0]-2);const C=_mt(a,g.min_pos[0],g.max_pos[0],g.bins_per_dimension||g.tile_size),I=Math.min(C,s);return Math.max(I,0)},Pmt=(g,a,s,C,I,A)=>{const d=Math.min(g,I),h=A/2**d,y=1e-7;return Mve(Math.max(0,Math.floor((a.domain()[0]-s)/h)),Math.min(2**d,Math.ceil((a.domain()[1]-s-y)/h)))},zmt=(g,a,s,C=Number.MAX_VALUE,I=256)=>{const d=g*I,h=20,y=Math.max(0,Math.floor((a.domain()[0]-s)/d)),Z=Math.ceil(Math.min(C,a.domain()[1]-s-1e-7)/d);let b=Mve(y,Z);return b.length>h&&(console.warn(`Too many visible tiles: ${b.length} truncating to ${h}`),b=b.slice(0,h)),b},Omt=(g,a)=>{if(!g)return[];const s=Fve(g,a,g.max_zoom);if(g.resolutions){const A=g.resolutions.map(y=>+y).sort((y,Z)=>Z-y);return zmt(A[s],a,g.min_pos[0],g.max_pos[0]).map(y=>[s,y])}return Pmt(s,a,g.min_pos[0],g.max_pos[0],g.max_zoom,g.max_width).map(A=>[s,A])},Lmt=(g,a)=>{if(g.axis||(g.axis=new _X(g),g.pBase.addChild(g.axis.pAxis)),!g.options.axisPositionVertical&&!g.options.axisPositionHorizontal){g.axis.clearAxis();return}if(g.options.axisPositionVertical&&g.options.axisPositionVertical==="hidden"){g.axis.clearAxis();return}if(g.options.axisPositionHorizontal&&g.options.axisPositionHorizontal==="hidden"){g.axis.clearAxis();return}const s=g.options.axisMargin||0;g.options.axisPositionHorizontal==="left"||g.options.axisPositionVertical==="top"?(g.axis.pAxis.position.x=g.position[0]+s,g.axis.pAxis.position.y=g.position[1],g.axis.drawAxisRight(a,g.dimensions[1])):g.options.axisPositionHorizontal==="outsideLeft"||g.options.axisPositionVertical==="outsideTop"?(g.axis.pAxis.position.x=g.position[0]+s,g.axis.pAxis.position.y=g.position[1],g.axis.drawAxisLeft(a,g.dimensions[1])):g.options.axisPositionHorizontal==="right"||g.options.axisPositionVertical==="bottom"?(g.axis.pAxis.position.x=g.position[0]+g.dimensions[0]-s,g.axis.pAxis.position.y=g.position[1],g.axis.drawAxisLeft(a,g.dimensions[1])):(g.options.axisPositionHorizontal==="outsideRight"||g.options.axisPositionVertical==="outsideBottom")&&(g.axis.pAxis.position.x=g.position[0]+g.dimensions[0]-s,g.axis.pAxis.position.y=g.position[1],g.axis.drawAxisRight(a,g.dimensions[1]))},Jmt=(g,a)=>{const s=g.valueScaleTransform,{y:C,k:I}=s,A=g.dimensions[1];C+a/I>-(I-1)*A&&C+a/I<0&&(g.valueScaleTransform=s.translate(0,a/I)),Object.values(g.fetchedTiles).forEach(d=>{d.graphics.position.y=g.valueScaleTransform.y}),g.animate()},Umt=(g,a,s,C)=>{const I=s.k,A=s.y,d=(g-A)/I,h=Math.max(I/a,1);let y=I*d+A-h*d;return y=Math.max(y,-(h-1)*C),y=Math.min(y,0),qo.translate(0,y).scale(h)},Qmt=(g,a)=>{const s=+a.split(".")[0],C=+a.split(".")[1],I=g.max_width,A=g.min_pos[0],d=I/2**s;return{tileX:A+C*d,tileWidth:d}};function jmt(g,a){Object.values(g.fetchedTiles).forEach(s=>{if(!s.drawnAtScale)return;const C=s.drawnAtScale.range(),I=g._xScale.range();if(C[0]!==I[0]||C[1]!==I[1]){g.renderTile(s);return}const A=(s.drawnAtScale.domain()[1]-s.drawnAtScale.domain()[0])/(g._xScale.domain()[1]-g._xScale.domain()[0]);if(A>2||A<.5)g.renderTile(s);else{const h=g._xScale.domain().map(s.drawnAtScale)[0];for(const y of a)y(s).scale.x=A,y(s).x=-h*A}})}const v1={calculate1DVisibleTiles:Omt,calculate1DZoomLevel:Fve,drawAxis:Lmt,movedY:Jmt,getTilePosAndDimensions:Qmt,stretchRects:jmt,zoomedY:Umt},Yve=16,Kve=50,e4=5e3,_ve=5,Ib={fontSize:"14px",fontFamily:"Arial",stroke:"white",strokeThickness:2,fontWeight:400,dropShadow:!0,dropShadowColor:"white",dropShadowDistance:0,dropShadowBlur:2};let Pve=function(g){o(s,g);var a=l(s);function s(C,I){var A;return T(this,s),A=a.call(this,C,I),A.valueScaleTransform=qo,A}return E(s,[{key:"initialize",value:function(){this.initialized||([this.prevK,this.vertK,this.vertY]=[1,1,0],this.drawnRects||(this.drawnRects={}),this.colorScale||(this.options.colorRange?this.colorScale=Df(this.options.colorRange):this.colorScale=JZ),this.initialized=!0)}},{key:"initTile",value:function(I){I.texts={},I.rectGraphics=new $t.PIXI.Graphics,I.textGraphics=new $t.PIXI.Graphics,I.graphics.addChild(I.rectGraphics),I.graphics.addChild(I.textGraphics);let A=[],d=[];if(I.tileData&&I.tileData.length){if(I.tileData.sort((h,y)=>y.importance-h.importance),!this.options||!this.options.valueColumn){const h=I.tileData.map(y=>{const Z=+y.chrOffset;return{from:+y.fields[1]+Z,to:+y.fields[2]+Z,value:y,text:y.fields[3],strand:y.fields.length>=6&&y.fields[5]==="-"?"-":"+"}});A=CX(h.filter(y=>y.strand==="+")),d=CX(h.filter(y=>y.strand==="-"))}else A=[I.tileData.map(h=>({value:h}))];I.plusStrandRows=A,I.minusStrandRows=d,this.options.showTexts&&I.tileData.forEach((h,y)=>{const Z=h.fields;if(h.importance||(h.importance=Math.random()),I.textWidths={},I.textHeights={},y>=(+this.options.maxTexts||Kve))return;const b=new $t.PIXI.Text(Z[3],{...Ib,fontSize:+this.options.fontSize||Ib.fontSize});this.flipText&&(b.scale.x=-1),b.anchor.x=.5,b.anchor.y=.5,I.texts[h.uid]=b,I.textGraphics.addChild(b)})}I.initialized=!0}},{key:"removeTileRects",value:function(I){const A=+I.tileId.split(".")[0];I.rectGraphics.clear(),I.rendered=!1,I.tileData&&I.tileData.length&&I.tileData.forEach((d,h)=>{this.drawnRects[A]&&this.drawnRects[A][d.uid]&&this.drawnRects[A][d.uid][2]===I.tileId&&delete this.drawnRects[A][d.uid]})}},{key:"destroyTile",value:function(I){this.removeTileRects(I),I.graphics.removeChild(I.textGraphics),I.graphics.removeChild(I.rectGraphics)}},{key:"removeTiles",value:function(I){n(G(s.prototype),"removeTiles",this).call(this,I)}},{key:"drawTile",value:function(I){this.options&&this.options.valueColumn&&this.valueScale&&this.drawAxis(this.valueScale)}},{key:"rerender",value:function(I,A){n(G(s.prototype),"rerender",this).call(this,I,A),this.valueScale=null,this.drawnRects={},this.options.colorRange?this.colorScale=Df(this.options.colorRange):this.colorScale=JZ;for(const d of this.visibleAndFetchedTiles())this.destroyTile(d),this.initTile(d),this.renderTile(d)}},{key:"updateTile",value:function(I){this.areAllVisibleTilesLoaded()&&this.renderTile(I)}},{key:"allVisibleRects",value:function(){const I={};Object.values(this.fetchedTiles).forEach(y=>{if(y.plusStrandRows)for(const Z of y.plusStrandRows[0])I[Z.value.uid]||(I[Z.value.uid]=Z)});const A=Object.values(I).sort((y,Z)=>y.from-Z.from);let d=0,h=0;for(let y=0;y=0&&A.length;y--)A[y].staggeredStartPosition=(h+d-y)%2;return I}},{key:"drawSegmentStyle",value:function(I,A,d,h,y,Z){const w=h+y/2,S=[A,h,A+2*.1,h,A+2*.1,w-.1,d-2*.1,w-.1,d-2*.1,h,d,h,d,h+y,d-2*.1,h+y,d-2*.1,w+.1,A+2*.1,w+.1,A+2*.1,h+y,A,h+y];return I.rectGraphics.drawPolygon(S),S}},{key:"drawPoly",value:function(I,A,d,h,y,Z){let b=null;return this.options.annotationStyle==="segment"?this.drawSegmentStyle(I,A,d,h,y,Z):((Z==="+"||Z==="-")&&d-A=(+this.options.maxTexts||Kve)||!I.texts[N.uid])continue;const he=I.texts[N.uid];he.position.x=this._xScale(P),he.position.y=te+j/2,he.nominalY=te+j/2,oe&&(he.alreadyDrawn=!0);const ye=this.options.fontColor!==void 0?Mi(this.options.fontColor):Z;if(he.style={...Ib,fill:ye,fontSize:+this.options.fontSize||Ib.fontSize},!(D[3]in I.textWidths)){he.updateTransform();const Ie=he.getBounds().width,fe=he.getBounds().height,We=5;I.textWidths[D[3]]=Ie,I.textHeights[D[3]]=fe-We}}}},{key:"renderTile",value:function(I){let A=I.plusStrandRows?I.plusStrandRows.length:1,d=I.minusStrandRows?I.minusStrandRows.length:1;for(const h of this.visibleAndFetchedTiles()){if(!h.initialized)return;!h.plusStrandRows&&!h.minusStrandRows||(A=Math.max(h.plusStrandRows.length,A),d=Math.max(h.minusStrandRows.length,d))}if(I.rendered&&this.removeTileRects(I),I.drawnAtScale=this._xScale.copy(),I.rendered=!0,this.setValueScale(),this.setColorValueScale(),I.tileData&&I.tileData.length){const h=this.options.plusStrandColor||this.options.fillColor||"blue",y=this.options.minusStrandColor||this.options.fillColor||"purple",Z=0;let b=0;this.options.separatePlusMinusStrands?b=A*this.dimensions[1]/(A+d)-Z/2:b=this.dimensions[1],this.renderRows(I,I.plusStrandRows,A,0,b,h),this.renderRows(I,I.minusStrandRows,d,this.options.separatePlusMinusStrands?b+Z/2:0,this.dimensions[1],y)}v1.stretchRects(this,[h=>h.rectGraphics])}},{key:"calculateZoomLevel",value:function(){const I=Gi.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]);let A=Math.min(I,this.maxZoom);return A=Math.max(A,0),A}},{key:"minVisibleValueInTiles",value:function(I){let A=this.visibleAndFetchedIds();A.length===0&&(A=Object.keys(this.fetchedTiles));let d=Math.min.apply(null,A.map(h=>this.fetchedTiles[h]).filter(h=>h.tileData&&h.tileData.length).map(h=>Math.min.apply(null,h.tileData.sort((y,Z)=>Z.importance-y.importance).slice(0,e4).map(y=>+y.fields[I-1]).filter(y=>!Number.isNaN(y)))));return d===Number.MAX_SAFE_INTEGER&&(d=null),d}},{key:"maxVisibleValueInTiles",value:function(I){let A=this.visibleAndFetchedIds();A.length===0&&(A=Object.keys(this.fetchedTiles));let d=Math.max.apply(null,A.map(h=>this.fetchedTiles[h]).filter(h=>h.tileData&&h.tileData.length).map(h=>Math.max.apply(null,h.tileData.sort((y,Z)=>Z.importance-y.importance).slice(0,e4).map(y=>+y.fields[I-1]).filter(y=>!Number.isNaN(y)))));return d===Number.MIN_SAFE_INTEGER&&(d=null),d}},{key:"calculateMedianVisibleValue",value:function(I){this.areAllVisibleTilesLoaded()&&this.allTilesLoaded();let A=this.visibleAndFetchedIds();A.length===0&&(A=Object.keys(this.fetchedTiles));const d=[].concat(...A.map(h=>this.fetchedTiles[h]).filter(h=>h.tileData&&h.tileData.length).map(h=>h.tileData.sort((y,Z)=>Z.importance-y.importance).slice(0,e4).map(y=>+y.fields[I-1]))).filter(h=>h>0);this.medianVisibleValue=fL(d)}},{key:"draw",value:function(){n(G(s.prototype),"draw",this).call(this),this.allTexts=[],this.allBoxes=[];for(const I in this.fetchedTiles){const A=this.fetchedTiles[I];if(A.rectGraphics.scale.y=this.vertK,A.rectGraphics.position.y=this.vertY,!A.drawnAtScale)return;v1.stretchRects(this,[h=>h.rectGraphics]);const d=this.parentInFetched(A);A.initialized&&A.tileData&&A.tileData.length&&A.tileData.forEach(h=>{if(!A.texts)return;const y=h.fields,Z=y[3],b=A.texts[h.uid];if(!b)return;const w=+h.chrOffset,S=+y[1]+w,R=+y[2]+w,H=(S+R)/2;if(b.position.x=this._xScale(H),b.position.y=b.nominalY*(this.vertK*this.prevK)+this.vertY,!d&&!b.alreadyDrawn){b.visible=!0;const N=3;this.allBoxes.push([b.position.x-N,b.position.y-A.textHeights[y[3]]/2,b.position.x+A.textWidths[y[3]]+N,b.position.y+A.textHeights[y[3]]/2]),this.allTexts.push({importance:h.importance,text:b,caption:Z,strand:y[5]})}else b.visible=!1})}this.hideOverlaps(this.allBoxes,this.allTexts)}},{key:"hideOverlaps",value:function(I,A){VT(I,(d,h)=>{A[d].importance>A[h].importance?A[d].text.visible&&(A[h].text.visible=!1):A[h].text.visible&&(A[d].text.visible=!1)})}},{key:"setPosition",value:function(I){n(G(s.prototype),"setPosition",this).call(this,I),[this.pMain.position.x,this.pMain.position.y]=this.position}},{key:"setDimensions",value:function(I){n(G(s.prototype),"setDimensions",this).call(this,I)}},{key:"zoomed",value:function(I,A){this.xScale(I),this.yScale(A),this.refreshTiles(),this.draw()}},{key:"exportSVG",value:function(){let I=null,A=null;n(G(s.prototype),"exportSVG",this)?[A,I]=n(G(s.prototype),"exportSVG",this).call(this):(A=document.createElement("g"),I=A);const d=document.createElement("g");d.setAttribute("transform",`translate(${this.position[0]},${this.position[1]})`),I.appendChild(d);const h=document.createElement("g"),y=document.createElement("g");d.appendChild(h),d.appendChild(y);for(const Z of this.visibleAndFetchedTiles())Z.tileData.length&&Z.tileData.forEach(b=>{const w=+Z.tileId.split(".")[0],S=document.createElement("g");if(S.setAttribute("transform",`translate(${Z.rectGraphics.position.x},${Z.rectGraphics.position.y})scale(${Z.rectGraphics.scale.x},${Z.rectGraphics.scale.y})`),h.appendChild(S),this.drawnRects[w]&&b.uid in this.drawnRects[w]){const R=this.drawnRects[w][b.uid][0],H=document.createElement("path");let N=`M ${R[0]} ${R[1]}`;for(let z=2;z{const d=this.valueScaleTransform,{y:h,k:y}=d,Z=this.dimensions[1];h+I/y>-(y-1)*Z&&h+I/y<0&&(this.valueScaleTransform=d.translate(0,I/y)),A.rectGraphics.position.y=this.valueScaleTransform.y,this.vertY=this.valueScaleTransform.y}),this.animate()}},{key:"zoomedY",value:function(I,A){const d=v1.zoomedY(I,A,this.valueScaleTransform,this.dimensions[1]);this.valueScaleTransform=d;let h=d.k;const y=d.y;let Z=!1;h/=this.prevK,(h>1.5||h<1/1.5)&&(this.prevK*=h,h=1,Z=!0),this.vertK=h,this.vertY=y,Object.values(this.fetchedTiles).forEach(b=>{Z&&this.renderTile(b),b.rectGraphics.scale.y=h,b.rectGraphics.position.y=y}),this.draw(),this.animate()}},{key:"getMouseOverHtml",value:function(I,A){if(!this.tilesetInfo)return"";const d=this.calculateZoomLevel(),h=[I,A];if(this.drawnRects[d]){const y=Object.values(this.drawnRects[d]);for(let Z=0;Z{I.drawRect(g,a,s,C)},qmt=(g,a,s,C,I,{fill:A=0,fillOpacity:d=0,stroke:h=0,strokeWidth:y=0,strokeOpacity:Z=0}={})=>{const b=document.createElement("rect");b.setAttribute("x",g),b.setAttribute("y",a),b.setAttribute("width",s),b.setAttribute("height",C),b.setAttribute("fill",`#${BU(A)}`),b.setAttribute("fill-opacity",d),b.setAttribute("stroke",`#${BU(h)}`),b.setAttribute("stroke-opacity",Z),b.setAttribute("stroke-width",y),I.appendChild(b)},iu=(g,a,s,C,I,A)=>{I instanceof HTMLElement?qmt(g,a,s,C,I,A):$mt(g,a,s,C,I)},zve=(g,a,s,C,I,A,d,h,{isVertical:y=!1,svg:Z=null}={})=>{let b=a,w=s,S=C,R=I;const H=h.width*2>C?C/2:h.width,N=h.width*2>I?I/2:h.width,D=Z||g,M={fill:0,fillOpacity:0,stroke:0,strokeOpacity:0,strokeWidth:1};if(h.positions&&h.positions.length?(g.lineStyle(1,0,0),g.beginFill(h.color,h.opacity),M.fill=h.color,M.fillOpacity=h.opacity,M.stroke=0,M.strokeOpacity=0,M.strokeWidth=1,h.positions.forEach(z=>{z==="top"&&!y||z==="left"&&y?iu(a-H,s-N,C+H*2,N,D,M):z==="bottom"&&!y||z==="right"&&y?iu(a-H,s+I,C+H*2,N,D,M):z==="left"&&!y||z==="top"&&y?iu(a-H,s-N,H,I+N*2,D,M):(z==="right"&&!y||z==="bottom"&&y)&&iu(a+C,s-N,H,I+N*2,D,M)})):h.width>0&&h.opacity>0&&(g.lineStyle(h.width,h.color,h.opacity),g.beginFill(0,0),M.fill=0,M.fillOpacity=0,M.stroke=h.color,M.strokeOpacity=h.opacity,M.strokeWidth=h.width,iu(a-H,s-N,C+H*2,I+N*2,D,M)),d.positions&&d.positions.length){g.lineStyle(1,0,0),g.beginFill(d.color,d.opacity);const z=d.width*2>C?C/2:d.width,K=d.width*2>I?I/2:d.width;M.fill=d.color,M.fillOpacity=d.opacity,M.stroke=0,M.strokeOpacity=0,M.strokeWidth=1,d.positions.forEach(P=>{P==="top"&&!y||P==="left"&&y?(iu(a,s,C,K,D,M),w+=K,R-=K):P==="bottom"&&!y||P==="right"&&y?(iu(a,s+I-K,C,K,D,M),R-=K):P==="left"&&!y||P==="top"&&y?(iu(a,s,z,I,D,M),b+=z,S-=z):(P==="right"&&!y||P==="bottom"&&y)&&(iu(a+C-z,s,z,I,D,M),S-=z)})}else g.lineStyle(d.width,d.color,d.opacity),M.stroke=d.color,M.strokeOpacity=d.opacity,M.strokeWidth=d.width;g.beginFill(A.color,A.opacity),M.fill=A.color,M.fillOpacity=A.opacity,iu(b,w,S,R,D,M)};let Ove=function(g){o(s,g);var a=l(s);function s(C,I){var A;return T(this,s),A=a.call(this,C,I),A.options=I||{},A.drawnRects={},A}return E(s,[{key:"drawHorizontalOverlay",value:function(I,A,d,h=0,y,Z,b,w){if(!d||d.length<2)return;let S=this.position[0]+A.left+this._xScale(d[0]);const R=this.position[1]+A.top,H=A.height;let N=this._xScale(d[1])-this._xScale(d[0]);N=4?d[2]:d[0]);const H=this.position[1]+A.top,N=this.position[1]+A.top+A.height;if(R>N)return;R=4?d[3]:d[1])-R+A.top+this.position[1];M<0||(R+M>N&&(M+=N-(R+M)),M{(w.orientation==="1d-horizontal"||w.orientation==="2d")&&this.options.extent.forEach(S=>this.drawHorizontalOverlay(A,w.position,S,Z,d,h,y,I)),(w.orientation==="1d-vertical"||w.orientation==="2d")&&this.options.extent.forEach(S=>this.drawVerticalOverlay(A,w.position,S,b,d,h,y,I))})}},{key:"zoomed",value:function(I,A){this.xScale(I),this.yScale(A),this.draw()}},{key:"setPosition",value:function(I){n(G(s.prototype),"setPosition",this).call(this,I),this.draw()}},{key:"setDimensions",value:function(I){n(G(s.prototype),"setDimensions",this).call(this,I),this.draw()}},{key:"exportSVG",value:function(){let I=null,A=null;n(G(s.prototype),"exportSVG",this)?[A,I]=n(G(s.prototype),"exportSVG",this).call(this):(A=document.createElement("g"),I=A);const d=document.createElement("g");return I.appendChild(d),this.draw({svg:d}),[A,I]}}]),s}(Xs),Z1=function(g){o(s,g);var a=l(s);function s(){return T(this,s),a.apply(this,arguments)}return E(s,[{key:"stopHover",value:function(){this.pMouseOver.clear(),this.animate()}},{key:"getMouseOverHtml",value:function(I){if(!this.tilesetInfo||!this.options.showTooltip||!this.valueScale)return"";const A=this.getDataAtPos(I);let d="";A&&(d=fl(".3f")(A));const h=this.pMouseOver,y=0,Z=this.valueScale(A);h.clear(),h.beginFill(y,.5),h.lineStyle(1,y,1);const b=4;return h.drawRect(I-b/2,Z-b/2,b,b),this.animate(),`${d}`}},{key:"initTile",value:function(I){if(n(G(s.prototype),"initTile",this).call(this,I),!I.tileData||!I.tileData.dense){console.warn("emptyTile:",I);return}if(I.xValues=new Array(I.tileData.dense.length),I.yValues=new Array(I.tileData.dense.length),this.isValueScaleLocked()){const A=this.getLockGroupExtrema();A!==null&&(this.minValue(A[0]),this.maxValue(A[1]))}this.drawTile(I)}},{key:"rerender",value:function(I,A){n(G(s.prototype),"rerender",this).call(this,I,A),this.options=I,n(G(s.prototype),"draw",this).call(this),this.visibleAndFetchedTiles().forEach(d=>{this.renderTile(d)})}},{key:"renderTile",value:function(I){this.drawTile(I),this.drawAxis(this.valueScale)}},{key:"drawTile",value:function(I){if(n(G(s.prototype),"drawTile",this).call(this,I),!I.graphics||!I.tileData||!I.tileData.dense)return;const A=I.graphics,{tileX:d,tileWidth:h}=this.getTilePosAndDimensions(I.tileData.zoomLevel,I.tileData.tilePos),y=I.tileData.dense;if(y.length===0)return;const[Z,b]=this.makeValueScale(this.minValue(),this.medianVisibleValue,this.maxValue());if(this.valueScale=Z,A.clear(),this.drawAxis(this.valueScale),this.options.valueScaling==="log"&&this.valueScale.domain()[1]<0){console.warn("Negative values present when using a log scale",this.valueScale.domain());return}const w=Mi(this.options.lineStrokeColor?this.options.lineStrokeColor:"blue");!this.tilesetInfo.tile_size&&!this.tilesetInfo.bins_per_dimension&&console.warn("No tileset_info.tile_size or tileset_info.bins_per_dimension",this.tilesetInfo);const S=this.tilesetInfo.tile_size||this.tilesetInfo.bins_per_dimension,R=Zn().domain([0,S]).range([d,d+h]),H=this.options.lineStrokeWidth?this.options.lineStrokeWidth:1;A.lineStyle(H,w,1),I.segments=[];let N=[];for(let D=0;D1&&I.segments.push(N),N=[];continue}if(R(D)>this.tilesetInfo.max_pos[0])break;N.push([M,z])}N.length>1&&I.segments.push(N);for(const D of I.segments){const M=D[0],z=D.slice(1);A.moveTo(M[0],M[1]);for(const K of z)A.lineTo(K[0],K[1])}}},{key:"setPosition",value:function(I){n(G(s.prototype),"setPosition",this).call(this,I),this.pMain.position.y=this.position[1],this.pMain.position.x=this.position[0],this.pMouseOver.position.y=this.position[1],this.pMouseOver.position.x=this.position[0]}},{key:"zoomed",value:function(I,A){this.xScale(I),this.yScale(A),this.refreshTiles(),this.draw();const d=this.isValueScaleLocked();if(this.continuousScaling&&this.minValue()!==void 0&&this.maxValue()!==void 0){if(this.valueScaleMin===null&&this.valueScaleMax===null&&!d){const h=this.minVisibleValue(),y=this.maxVisibleValue(),Z=1e-6;h!==null&&y!==null&&(Math.abs(this.minValue()-h)>Z||Math.abs(this.maxValue()-y)>Z)&&(this.minValue(h),this.maxValue(y),this.scheduleRerender())}d&&this.onValueScaleChanged()}}},{key:"superSVG",value:function(){return n(G(s.prototype),"exportSVG",this).call(this)}},{key:"exportSVG",value:function(){let I=null,A=null;n(G(s.prototype),"exportSVG",this)?[A,I]=n(G(s.prototype),"exportSVG",this).call(this):(A=document.createElement("g"),I=A),A.setAttribute("class","exported-line-track");const d=document.createElement("g");I.appendChild(d),d.setAttribute("transform",`translate(${this.position[0]},${this.position[1]})`);const h=this.options.lineStrokeColor?this.options.lineStrokeColor:"blue";this.visibleAndFetchedTiles().forEach(Z=>{const b=document.createElement("path");b.setAttribute("fill","transparent"),b.setAttribute("stroke",h);let w="";for(const S of Z.segments){const R=S[0],H=S.slice(1);w+=`M${R[0]} ${R[1]}`;for(const N of H)w+=`L${N[0]} ${N[1]}`}b.setAttribute("d",w),d.appendChild(b)});const y=document.createElement("g");if(y.setAttribute("id","axis"),A.appendChild(y),y.setAttribute("transform",`translate(${this.axis.pAxis.position.x}, ${this.axis.pAxis.position.y})`),this.options.axisPositionHorizontal==="left"||this.options.axisPositionVertical==="top"){const Z=this.axis.exportAxisLeftSVG(this.valueScale,this.dimensions[1]);y.appendChild(Z)}else if(this.options.axisPositionHorizontal==="right"||this.options.axisPositionVertical==="bottom"){const Z=this.axis.exportAxisRightSVG(this.valueScale,this.dimensions[1]);y.appendChild(Z)}return[A,I]}},{key:"tileToLocalId",value:function(I){return this.options.aggregationMode&&this.options.aggregationMode!=="mean"?`${I.join(".")}.${this.options.aggregationMode}`:`${I.join(".")}`}},{key:"tileToRemoteId",value:function(I){return this.tileToLocalId(I)}}]),s}(c1),Lve=function(g){o(s,g);var a=l(s);function s(){return T(this,s),a.apply(this,arguments)}return E(s,[{key:"initTile",value:function(I){I.barXValues=new Array(I.tileData.dense.length),I.barYValues=new Array(I.tileData.dense.length),I.barWidths=new Array(I.tileData.dense.length),I.barHeights=new Array(I.tileData.dense.length),n(G(s.prototype),"initTile",this).call(this,I)}},{key:"drawTile",value:function(I){if(!I.graphics||!I.tileData||!I.tileData.dense)return;const A=I.graphics,{tileX:d,tileWidth:h}=this.getTilePosAndDimensions(I.tileData.zoomLevel,I.tileData.tilePos),y=I.tileData.dense;if(y.length===0)return;let Z=0;if(this.valueScale=null,this.options.valueScaling==="log"){let N=this.medianVisibleValue;this.medianVisibleValue||(N=this.minValue()),this.valueScale=Wf().domain([N,this.maxValue()+N]).range([this.dimensions[1],0]),Z=N}else this.valueScale=Zn().domain([this.minValue(),this.maxValue()]).range([this.dimensions[1],0]);if(A.clear(),this.drawAxis(this.valueScale),this.options.valueScaling==="log"&&this.valueScale.domain()[1]<0){console.warn("Negative values present when using a log scale",this.valueScale.domain());return}const b=Mi(this.options.lineStrokeColor?this.options.lineStrokeColor:"blue"),w=Zn().domain([0,this.tilesetInfo.tile_size]).range([d,d+h]),S=0;A.lineStyle(S,b,1);const R=this.options.pointSize?this.options.pointSize:3,H=Mi(this.options.pointColor?this.options.pointColor:"red");A.beginFill(H,1),I.drawnAtScale=this._xScale.copy();for(let N=0;Nthis.tilesetInfo.max_pos[0])break;A.drawRect(D-R/2/this.pMain.scale.x,M-R/2/this.pMain.scale.y,R/this.pMain.scale.x,R/this.pMain.scale.y)}}},{key:"draw",value:function(){n(G(s.prototype),"draw",this).call(this);for(const I of Mr(this.fetchedTiles)){const A=(I.drawnAtScale.domain()[1]-I.drawnAtScale.domain()[0])/(this._xScale.domain()[1]-this._xScale.domain()[0]),h=this._xScale.domain().map(I.drawnAtScale)[0];I.graphics.scale.x=A,I.graphics.position.x=-h*A}}},{key:"zoomed",value:function(I,A,d,h,y){n(G(s.prototype),"zoomed",this).call(this,I,A)}},{key:"exportSVG",value:function(){let I=null,A=null;[A,I]=n(G(s.prototype),"superSVG",this).call(this),A.setAttribute("class","exported-line-track");const d=document.createElement("g");I.appendChild(d),d.setAttribute("transform",`translate(${this.position[0]},${this.position[1]})`);for(const y of this.visibleAndFetchedTiles())for(let Z=0;Z{a+=+C||0,s.push(a)}),Float64Array.from(s)}const tpt=(g,a)=>{const s=j2(g,a);return ept(g.map(C=>(Array.isArray(C)&&a?C.length:1)/s))};let Jve=function(g){o(s,g);var a=l(s);function s(C,I){var A;return T(this,s),A=a.call(this,C,I),A.pMain=A.pMobile,A.continuousScaling=!1,A.updateDataFetcher(I),A}return E(s,[{key:"updateDataFetcher",value:function(I){if(I&&I.selectRows&&I.selectRowsAggregationMethod==="server"){const{pubSub:A,dataFetcher:d}=this,h=d.dataConfig.options,y={aggGroups:I.selectRows,aggFunc:I.selectRowsAggregationMode};if(JSON.stringify(h)!==JSON.stringify(y)){const Z={...d.dataConfig,options:y};this.dataFetcher=new d.constructor(Z,A),this.dataFetcher.dataConfig.tilesetUid&&this.fetchNewTiles(Object.keys(this.fetchedTiles).map(b=>({tileId:b,remoteId:b})))}}}},{key:"rerender",value:function(I,A){this.updateDataFetcher(I),n(G(s.prototype),"rerender",this).call(this,I,A),I.selectRows&&(this.selectRowsCumWeights=tpt(I.selectRows,I.selectRowsAggregationWithRelativeHeight))}},{key:"tileDataToCanvas",value:function(I){const A=document.createElement("canvas");this.options.selectRows&&this.tilesetInfo.shape?(A.width=this.tilesetInfo.shape[0],A.height=j2(this.options.selectRows,this.options.selectRowsAggregationWithRelativeHeight)):this.tilesetInfo.shape?(A.width=this.tilesetInfo.shape[0],A.height=this.tilesetInfo.shape[1]):(A.width=this.tilesetInfo.tile_size,A.height=1);const d=A.getContext("2d");if(d.fillStyle="transparent",d.fillRect(0,0,A.width,A.height),I.length!==0&&I.length===4*A.width*A.height){const h=new ImageData(I,A.width,A.height);d.putImageData(h,0,0)}else console.warn("HorizontalMultivecTrack: pixData has an incorrect length.");return A}},{key:"setSpriteProperties",value:function(I,A,d){const{tileX:h,tileWidth:y}=this.getTilePosAndDimensions(A,d,this.tilesetInfo.tile_size),Z=h+y;I.width=this._refXScale(Z)-this._refXScale(h),I.height=this.dimensions[1],I.x=this._refXScale(h),I.y=0}},{key:"leftTrackZoomed",value:function(I,A,d,h,y){const Z=this._xScale(0)-d*this._refXScale(0);this.pMobile.position.x=Z+this.position[0],this.pMobile.position.y=this.position[1],this.pMobile.scale.x=d,this.pMobile.scale.y=1}},{key:"zoomed",value:function(I,A,d,h){n(G(s.prototype),"zoomed",this).call(this,I,A),this.pMain.position.x=h,this.pMain.position.y=this.position[1],this.pMain.scale.x=d,this.pMain.scale.y=1,this.drawColorbar()}},{key:"calculateVisibleTiles",value:function(){if(!this.tilesetInfo)return;if(this.zoomLevel=this.calculateZoomLevel(),this.tilesetInfo.resolutions){const A=this.tilesetInfo.resolutions.map(d=>+d).sort((d,h)=>h-d);this.xTiles=Gi.calculateTilesFromResolution(A[this.zoomLevel],this._xScale,this.tilesetInfo.min_pos[0],null,this.tilesetInfo.tile_size)}else this.xTiles=Gi.calculateTiles(this.zoomLevel,this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width);const I=this.xTiles.map(A=>[this.zoomLevel,A]);this.setVisibleTiles(I)}},{key:"calculateZoomLevel",value:function(){if(!this.tilesetInfo)return;const I=this.tilesetInfo.min_pos[0];let A=null;return this.tilesetInfo.resolutions?A=Gi.calculateZoomLevelFromResolutions(this.tilesetInfo.resolutions,this._xScale,I):A=Gi.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]),A}},{key:"tileToLocalId",value:function(I){return I.join(".")}},{key:"tileToRemoteId",value:function(I){return I.join(".")}},{key:"getTilePosAtPosition",value:function(I,A){if(!this.tilesetInfo)return;const d=this.calculateZoomLevel(),h=Gi.calculateTileWidth(this.tilesetInfo,d,this.tilesetInfo.tile_size),y=this._xScale.invert(I)/h;return[d,Math.floor(y)]}},{key:"getVisibleData",value:function(I,A){const d=this.calculateZoomLevel(),h=Gi.calculateTileWidth(this.tilesetInfo,d,this.tilesetInfo.tile_size),y=this._xScale.invert(I)/h;let Z=this.tilesetInfo.shape?this.tilesetInfo.shape[1]:1;this.options.selectRows&&(Z=j2(this.options.selectRows,this.options.selectRowsAggregationWithRelativeHeight));let b=this.tilesetInfo.tile_size*(y-Math.floor(y));const w=A/this.dimensions[1],S=w*Z;let R=Math.floor(S),H;this.options.selectRows&&(this.options.selectRowsAggregationWithRelativeHeight&&(R=this.selectRowsCumWeights.findIndex((z,K)=>w<=z&&(K===this.selectRowsCumWeights.length-1||this.selectRowsCumWeights[K+1]>=w))),H=this.options.selectRows[R]);const N=this.tileToLocalId([d,Math.floor(y)]),D=this.fetchedTiles[N];let M="";if(D){this.tilesetInfo.shape||(b=D.tileData.dense.length*(y-Math.floor(y)));let z=null;if(this.tilesetInfo.shape?Array.isArray(H)&&this.options.selectRowsAggregationMethod==="client"?z=H.map(K=>this.tilesetInfo.shape[0]*K+Math.floor(b)):H&&this.options.selectRowsAggregationMethod==="client"?z=this.tilesetInfo.shape[0]*H+Math.floor(b):z=this.tilesetInfo.shape[0]*R+Math.floor(b):z=D.tileData.dense.length*R+Math.floor(b),Array.isArray(z)){const K=LU(this.options.selectRowsAggregationMode),P=z.map(J=>D.tileData.dense[J]);M=fl(".3f")(K(P)),M+="
",M+=`${z.length}-item ${this.options.selectRowsAggregationMode}`}else M=fl(".3f")(D.tileData.dense[z]),Array.isArray(H)&&(M+="
",M+=`${H.length}-item ${this.options.selectRowsAggregationMode}`)}if(this.tilesetInfo.row_infos){M+="
";let z="";this.options.selectRows&&!Array.isArray(H)?z=this.tilesetInfo.row_infos[H]:R>=0&&R"),b=this.options.colorRange[parseInt(Z[0],10)-1],w=Z[1];if(Number.isNaN(b)||b==="NaN"||typeof b>"u"||b==="undefined")return"";h=` ${w}`}else h+=`Data value: ${this.getVisibleData(I,A)}
`,h+=`Zoom level: ${d[0]} tile position: ${d[1]}`;return h}}]),s}(ZT);const ipt=Mi("#FFFFFF");let t4=function(g){o(s,g);var a=l(s);function s(...C){var I;return T(this,s),I=a.call(this,...C),I.zeroLine=new $t.PIXI.Graphics,I.pMain.addChild(I.zeroLine),I.valueScaleTransform=qo,I.options&&I.options.colorRange&&(I.options.colorRangeGradient?I.setColorGradient(I.options.colorRange):I.setColorScale(I.options.colorRange)),I.initialized=!0,I}return E(s,[{key:"setColorScale",value:function(I){I&&(this.colorScale=Df(I),this.colorScale=this.colorScale.map(A=>A.map(d=>d/255)))}},{key:"setColorGradient",value:function(I){if(!I)return;const A=I.length-1;this.colorGradientColors=this.options.align==="bottom"?I.slice().reverse().map((d,h)=>({from:h/A,color:d})):I.map((d,h)=>({from:h/A,color:d}))}},{key:"initTile",value:function(I){this.initialized&&n(G(s.prototype),"initTile",this).call(this,I)}},{key:"updateTile",value:function(I){(!I.valueScale||!this.scale||this.scale.minValue!==I.scale.minValue||this.scale.maxValue!==I.scale.maxValue)&&this.renderTile(I)}},{key:"renderTile",value:function(I){this.initialized&&n(G(s.prototype),"renderTile",this).call(this,I)}},{key:"drawTile",value:function(I){if(!I.graphics||!I.tileData||!I.tileData.dense)return;const{graphics:A}=I;I.svgData=void 0;const{tileX:d,tileWidth:h}=this.getTilePosAndDimensions(I.tileData.zoomLevel,I.tileData.tilePos,this.tilesetInfo.bins_per_dimension||this.tilesetInfo.tile_size),y=I.tileData.dense;if(y.length===0)return;const[Z,b]=this.makeValueScale(this.minValue(),this.medianVisibleValue,this.maxValue(),0);Z.clamp(!0),this.valueScale=Z;const w=Z.copy();if(w.range([254,0]).clamp(!0),A.clear(),this.drawAxis(this.valueScale),this.options.valueScaling==="log"&&this.valueScale.domain()[1]<0){console.warn("Negative values present when using a log scale",this.valueScale.domain());return}const S=Mi(this.options.lineStrokeColor||"blue"),R=Zn().domain([0,this.tilesetInfo.tile_size||this.tilesetInfo.bins_per_dimension]).range([d,d+h]),H=0;A.lineStyle(H,S,1);const N=this.options.barFillColor||"grey",D=Mi(N),M="barOpacity"in this.options?this.options.barOpacity:1;A.beginFill(D,M),I.drawnAtScale=this._xScale.copy();const z=this.options.align==="top";let K,P,J,j,ie,te;if(this.colorGradientColors){ie=new $t.PIXI.Graphics,ie.beginFill(ipt,1);const Ce=v0e(this.colorGradientColors,1,this.dimensions[1],0,0,0,this.dimensions[1]);te=new $t.PIXI.Sprite($t.PIXI.Texture.fromCanvas(Ce,$t.PIXI.SCALE_MODES.NEAREST)),te.x=this._xScale(d),te.width=this._xScale(d+h)-te.x}for(let Ce=0;Cethis.tilesetInfo.max_pos[0])break;if(this.colorScale&&!this.options.colorRangeGradient){const ue=Math.round(w(y[Ce]+b)),oe=this.colorScale[ue],he=$t.PIXI.utils.rgb2hex(oe);A.beginFill(he,M)}(ie||A).drawRect(K,J,P,j)}this.colorGradientColors&&(te.mask=ie,A.removeChildren(),A.addChild(te,ie))}},{key:"rerender",value:function(I,A){I&&I.colorRange&&(I.colorRangeGradient?this.setColorGradient(I.colorRange):this.setColorScale(I.colorRange)),n(G(s.prototype),"rerender",this).call(this,I,A)}},{key:"drawZeroLine",value:function(){this.zeroLine.clear();const I=Mi(this.options.barFillColor||"grey"),A=+this.options.barOpacity||1,d=this.options.zeroLineColor?Mi(this.options.zeroLineColor):I,h=Number.isNaN(+this.options.zeroLineOpacity)?A:+this.options.zeroLineOpacity;this.zeroLine.beginFill(d,h),this.zeroLine.drawRect(0,this.dimensions[1]-1,this.dimensions[0],1)}},{key:"drawZeroLineSvg",value:function(I){const A=document.createElement("rect");A.setAttribute("id","zero-line"),A.setAttribute("x",0),A.setAttribute("y",this.dimensions[1]-1),A.setAttribute("height",1),A.setAttribute("width",this.dimensions[0]),A.setAttribute("fill",this.options.zeroLineColor||this.options.barFillColor),A.setAttribute("fill-opacity",this.options.zeroLineOpacity||this.options.barOpacity),I.appendChild(A)}},{key:"getXScaleAndOffset",value:function(I){const A=I.domain(),d=this._xScale.domain(),h=(A[1]-A[0])/(d[1]-d[0]),Z=this._xScale.domain().map(I)[0];return[h,-Z*h]}},{key:"draw",value:function(){this.initialized&&(n(G(s.prototype),"draw",this).call(this),this.options.zeroLineVisible?this.drawZeroLine():this.zeroLine.clear(),Object.values(this.fetchedTiles).forEach(I=>{const[A,d]=this.getXScaleAndOffset(I.drawnAtScale);I.graphics.scale.x=A,I.graphics.position.x=d}))}},{key:"zoomed",value:function(I,A){n(G(s.prototype),"zoomed",this).call(this,I,A)}},{key:"movedY",value:function(I){}},{key:"zoomedY",value:function(I,A){}},{key:"addSVGInfo",value:function(I,A,d,h,y,Z){I.svgData?(I.svgData.barXValues.push(A),I.svgData.barYValues.push(d),I.svgData.barWidths.push(h),I.svgData.barHeights.push(y),I.svgData.barColors.push(Z)):I.svgData={barXValues:[A],barYValues:[d],barWidths:[h],barHeights:[y],barColors:[Z]}}},{key:"exportSVG",value:function(){let I=null,A=null;[A,I]=n(G(s.prototype),"superSVG",this).call(this),A.setAttribute("class","exported-line-track");const d=document.createElement("g");I.appendChild(d),d.setAttribute("transform",`translate(${this.position[0]},${this.position[1]})`),this.options.zeroLine&&this.drawZeroLineSvg(d),this.visibleAndFetchedTiles().filter(y=>y.svgData&&y.svgData.barXValues).forEach(y=>{const Z=y.svgData;for(let b=0;bz?(A.beginFill(D,M),this.addSVGInfo(I,P,z,j,J-z,H)):(A.beginFill(N,M),this.addSVGInfo(I,P,J,j,z-J,R)),w(K)>this.tilesetInfo.max_pos[0])break;A.drawRect(P,I.svgData.barYValues[K],j,I.svgData.barHeights[K])}}}]),s}(t4),Qve=function(g){o(s,g);var a=l(s);function s(C,I){var A;return T(this,s),A=a.call(this,C,I),A.setColorScale(I.colorRange),A.opacity=I.opacity||1,A}return E(s,[{key:"setColorScale",value:function(I){this.colorScale=I?Df(I):JZ,this.colorScale=this.colorScale.map(A=>A.map(d=>d/255))}},{key:"rerender",value:function(I){I&&I.colorRange&&this.setColorScale(I.colorRange),this.opacity=I.opacity||1,n(G(s.prototype),"rerender",this).call(this,I)}},{key:"drawAxis",value:function(){}},{key:"drawTile",value:function(I){if(!I.graphics||!I.tileData||!I.tileData.dense)return;const A=I.graphics,{tileX:d,tileWidth:h}=this.getTilePosAndDimensions(I.tileData.zoomLevel,I.tileData.tilePos),y=I.tileData.dense;if(y.length===0)return;const[Z,b]=this.makeValueScale(this.minValue(),this.medianVisibleValue,this.maxValue());if(Z.range([254,0]).clamp(!0),this.valueScale=Z,A.clear(),this.options.valueScaling==="log"&&this.valueScale.domain()[1]<0){console.warn("Negative values present when using a log scale",this.valueScale.domain());return}const w=Zn().domain([0,this.tilesetInfo.tile_size]).range([d,d+h]);A.lineStyle(0,0,0);for(let S=0;Sthis.tilesetInfo.max_pos[0])break;y[S]!==0&&A.drawRect(H,0,N,D)}}}}]),s}(Z1),jve=function(g){o(s,g);var a=l(s);function s(C,I){var A;return T(this,s),A=a.call(this,C,I),A.seen=new Set,A.pMain=A.pMobile,A.rows=[],A}return E(s,[{key:"uid",value:function(I){return I[I.length-2]}},{key:"segmentOverlap",value:function(I,A){}},{key:"drawAll",value:function(I){this.pMain.clear();const A=new Set,d=I.map(y=>A.has(this.uid(y))?null:(A.add(this.uid(y)),{from:+y[1],to:+y[2],type:y[4],uid:this.uid(y)})).filter(y=>y),h=CX(d);this.rows=h,this.draw()}},{key:"draw",value:function(){const I=this.rows;if(!I)return;const A=l2().range([0,this.dimensions[1]]).padding(.1).domain(Ns(0,this.maxRows())),d=this.pMain;d.clear(),d.lineStyle(1,255,0),d.beginFill(16740363,.8);for(let h=0;hthis.fetchedTiles[h].tileData.discrete),d=[].concat(...A);this.drawAll(d)}},{key:"initTile",value:function(I){}},{key:"maxRows",value:function(){return this.rows.length}},{key:"updateTile",value:function(I){}},{key:"destroyTile",value:function(I){I.tileData.discrete.forEach(A=>{const d=A[A.length-2];this.seen.has(d)&&this.seen.delete(d)})}},{key:"drawTile",value:function(I){}}]),s}(c1),$ve=function(){function g(a){T(this,g),this.scene=a.scene,this.originalTrack=a,this.pBase=new $t.PIXI.Graphics,this.scene.removeChild(a.pBase),this.scene.addChild(this.pBase),this.moveToOrigin=new $t.PIXI.Graphics,this.moveToOrigin.addChild(a.pBase),this.pBase.addChild(this.moveToOrigin),this.moveToOrigin.rotation=Math.PI/2,a.isLeftModified=!0,a.flipText=!0,this.svgOutput=null,a.gBase&&a.gMain&&(this.originalTrack.gBase.attr("transform",`translate(${this.moveToOrigin.position.x},${this.moveToOrigin.position.y}) - rotate(90) - scale(${this.moveToOrigin.scale.x},${this.moveToOrigin.scale.y})`),this.originalTrack.gMain.attr("transform",`translate(${this.originalTrack.pBase.position.x},${this.originalTrack.pBase.position.y})`))}return E(g,[{key:"remove",value:function(){this.originalTrack.remove(),this.pBase.clear(),this.scene.removeChild(this.pBase)}},{key:"setDimensions",value:function(s){this.dimensions=s;const C=[s[1],s[0]];this.originalTrack.setDimensions(C)}},{key:"setPosition",value:function(s){this.position=s,this.originalTrack.setPosition(s),this.originalTrack.pBase.position.x=-this.originalTrack.position[0],this.originalTrack.pBase.position.y=-this.originalTrack.position[1],this.moveToOrigin.scale.y=-1,this.moveToOrigin.scale.x=1,this.moveToOrigin.position.x=this.originalTrack.position[0],this.moveToOrigin.position.y=this.originalTrack.position[1],this.originalTrack.gMain&&(this.originalTrack.gBase.attr("transform",`translate(${this.moveToOrigin.position.x},${this.moveToOrigin.position.y}) - rotate(90) - scale(${this.moveToOrigin.scale.x},${this.moveToOrigin.scale.y})`),this.originalTrack.gMain.attr("transform",`translate(${this.originalTrack.pBase.position.x},${this.originalTrack.pBase.position.y})`))}},{key:"refXScale",value:function(s){return arguments.length?(this.originalTrack._refXScale=s,this):this.originalTrack._refYScale}},{key:"refYScale",value:function(s){return arguments.length?(this.originalTrack._refYScale=s,this):this.originalTrack._refXScale}},{key:"xScale",value:function(s){return arguments.length?(this.originalTrack._yScale=s,this):this.originalTrack._xScale}},{key:"yScale",value:function(s){return arguments.length?(this.originalTrack._xScale=s,this):this.originalTrack._yScale}},{key:"getMouseOverHtml",value:function(s,C){return this.originalTrack.getMouseOverHtml(C,s)}},{key:"clickOutside",value:function(){this.originalTrack.clickOutside()}},{key:"click",value:function(...s){this.originalTrack.click(...s)}},{key:"draw",value:function(){this.originalTrack.draw()}},{key:"zoomed",value:function(s,C,I=1,A=0,d=0,h=0,y=0){if(this.xScale(s),this.yScale(C),this.originalTrack.leftTrackZoomed){this.originalTrack.refreshTiles&&this.originalTrack.refreshTiles(),this.originalTrack.leftTrackZoomed(s,C,I,A,d),this.originalTrack.draw();return}const Z=this.originalTrack._xScale(0)-I*this.originalTrack._refXScale(0);if(this.originalTrack.pMobile.position.x=Z+this.originalTrack.position[0],this.originalTrack.pMobile.position.y=this.originalTrack.position[1]+this.originalTrack.dimensions[1],this.originalTrack.pMobile.scale.x=I,this.originalTrack.pMobile.scale.y=I,this.originalTrack.options.oneDHeatmapFlipped&&(this.originalTrack.pMobile.scale.y=-I,this.originalTrack.pMobile.position.y=this.originalTrack.position[1]),this.originalTrack.leftTrackDraw){this.originalTrack.refreshTiles&&this.originalTrack.refreshTiles(),this.originalTrack.leftTrackDraw();return}this.originalTrack.zoomed(this.xScale(),this.yScale())}},{key:"zoomedY",value:function(s,C){this.originalTrack.zoomedY(s,C)}},{key:"movedY",value:function(s){this.originalTrack.movedY(s)}},{key:"refScalesChanged",value:function(s,C){this.originalTrack.refScalesChanged(C,s)}},{key:"rerender",value:function(s){this.originalTrack.rerender(s)}},{key:"exportSVG",value:function(){const s=document.createElement("g");if(s.setAttribute("transform",`translate(${this.moveToOrigin.position.x},${this.moveToOrigin.position.y}) - rotate(90) - scale(${this.moveToOrigin.scale.x},${this.moveToOrigin.scale.y})`),this.originalTrack.exportSVG){const C=document.createElement("g");C.setAttribute("transform",`translate(${this.originalTrack.pBase.position.x}, ${this.originalTrack.pBase.position.y})`),C.appendChild(this.originalTrack.exportSVG()[0]),s.appendChild(C)}return[s,s]}},{key:"respondsToPosition",value:function(s,C){return s>=this.position[0]&&s<=this.dimensions[0]+this.position[0]&&C>=this.position[1]&&C<=this.dimensions[1]+this.position[1]}}]),g}();const qve=11,i4="Arial",eZe="outside",n4=10,npt=4,rpt=20,gpt=Mi("#ffffff"),ox=2,B1=2*(2*n4/3)/3,opt=50,apt=5e3,r4="blue",g4="red",o4=(g,a,s)=>{s.type!=="filler"&&a.pubSub.publish("app.click",{type:"gene-annotation",event:g,payload:s})},tZe=(g,a)=>{const s=g.concat(a),C=s.map(I=>[I.xStart,1,I.xEnd,1]);VT(C,(I,A)=>{let d=null,h=null;if(s[I].type==="filler"?d=s[I]:h=s[I],s[A].type==="filler"){if(d)return;d=s[A]}else{if(!d)return;h=s[A]}d.xStart>=h.xStart&&d.xEnd<=h.xEnd&&(d.hide=!0)})};function spt(g,a,s){const{flipText:C,fontSize:I,fontFamily:A,plusStrandColor:d,minusStrandColor:h,maxGeneEntries:y,maxFillerEntries:Z,maxTexts:b}=s;if(a.texts={},a.rectGraphics=new $t.PIXI.Graphics,a.textBgGraphics=new $t.PIXI.Graphics,a.textGraphics=new $t.PIXI.Graphics,a.rectMaskGraphics=new $t.PIXI.Graphics,a.graphics.addChild(a.rectGraphics),a.graphics.addChild(a.textBgGraphics),a.graphics.addChild(a.textGraphics),a.graphics.addChild(a.rectMaskGraphics),a.rectGraphics.mask=a.rectMaskGraphics,!a.tileData.sort)return;a.tileData.sort((R,H)=>H.importance-R.importance);const w=a.tileData.filter(R=>R.type!=="filler").slice(0,y),S=a.tileData.filter(R=>R.type==="filler").slice(0,Z);a.tileData=w.concat(S),a.tileData.forEach((R,H)=>{if(R.type==="filler")return;const N=R.fields,D=N[3],M=g.geneId(N,R.type),z=R.strand||N[5];R.strand=R.strand||z;let K=d||r4;if(z==="-"&&(K=h||g4),a.textWidths={},a.textHeights={},H>=b)return;const P=new $t.PIXI.Text(D,{fontSize:`${I}px`,fontFamily:A,fill:Mi(K)});P.interactive=!0,C&&(P.scale.x=-1),P.anchor.x=.5,P.anchor.y=1,a.texts[M]=P,a.texts[M].strand=z,a.textGraphics.addChild(P)}),a.initialized=!0}function iZe(g,a,s,C,I,A,d,h,y){const Z=h-y/2,b=0;g.forEach(w=>{const S=new $t.PIXI.Graphics;s.rectGraphics.addChild(S),S.beginFill(A,.1),S.lineStyle(0,A);const R=[I(w.xStart)-b,Z,I(w.xEnd)+b,Z,I(w.xEnd)+b,Z+y,I(w.xStart)-b,Z+y,I(w.xStart)-b,Z];S.interactive=!0,S.buttonMode=!0,S.mouseup=H=>o4(H,a,w),S.drawPolygon(R),s.allRects.push([R,w.strand,w])})}function Ipt(g,a,s,C,I,A,d,h,y,Z){const b=h-y/2,w=I.split(",").map(P=>+P+d),S=A.split(",").map(P=>+P+d),R=g._xScale(s),H=g._xScale(C),N=H-R,D=h,M=[];let z=[R,D-ox/2,R+N,D-ox/2,R+N,D+ox/2,R,D+ox/2];a.drawPolygon(z),M.push(z);const K=2*y;for(let P=Math.max(g.position[0],R)+K;P{const w=a._xScale(b.xStart),S=a._xScale(b.xEnd),R=new $t.PIXI.Graphics;s.rectGraphics.addChild(R),R.beginFill(A,d),R.interactive=!0,R.buttonMode=!0,R.mouseup=D=>o4(D,a,b);const H=a.geneRectHeight/2;let N=[];if(b.strand==="+"||b.fields[5]==="+"){const D=Math.max(w,S-H),M=D+H;N=[D,Z,M,Z+a.geneRectHeight/2,D,Z+a.geneRectHeight]}else{const D=Math.min(S,w+H),M=D-H;N=[D,Z,M,Z+a.geneRectHeight/2,D,Z+a.geneRectHeight]}R.drawPolygon(N),s.allRects.push([N,b.strand,b])})}function Cpt(g,a,s,C,I,A,d,h,y){g.forEach(Z=>{const b=Z.fields,w=+Z.chrOffset,S=b[12],R=b[13],H=new $t.PIXI.Graphics;s.rectGraphics.addChild(H),H.beginFill(A,d),H.interactive=!0,H.buttonMode=!0,H.mouseup=N=>o4(N,a,Z),s.allRects=s.allRects.concat(Ipt(a,H,Z.xStart,Z.xEnd,S,R,w,h,y,Z.strand||Z.fields[5]).map(N=>[N,Z.strand,Z]))})}function nZe(g,a,s,C,I,A,d,h,y){lpt(g,a,s,C,I,A,d,h,y),Cpt(g,a,s,C,I,A,d,h,y)}function cpt(g,a){const{tileX:s,tileWidth:C}=v1.getTilePosAndDimensions(g.tilesetInfo,a.tileId);a.rectMaskGraphics.clear();const I=Math.floor(Math.random()*16**6);a.rectMaskGraphics.beginFill(I,.3);const A=g._xScale(s),d=0,h=g._xScale(s+C)-g._xScale(s),y=g.dimensions[1];a.rectMaskGraphics.drawRect(A,d,h,y)}let a4=function(g){o(s,g);var a=l(s);function s(C,I){var A;T(this,s),A=a.call(this,C,I);const{animate:d}=C;return A.animate=d,A.options=I,A.fontSize=+A.options.fontSize||qve,A.geneLabelPos=A.options.geneLabelPosition||eZe,A.geneRectHeight=+A.options.geneAnnotationHeight||n4,A.geneRectHeight-=2,A.geneStrandSpacing=+A.options.geneStrandSpacing||npt,A.geneStrandHSpacing=A.geneStrandSpacing/2,A.geneRectHHeight=A.geneRectHeight/2,A}return E(s,[{key:"initTile",value:function(I){spt(this,I,{flipText:this.flipText,fontSize:this.fontSize,fontFamily:i4,plusStrandColor:this.options.plusStrandColor,minusStrandColor:this.options.minusStrandColor,maxGeneEntries:opt,maxFillerEntries:apt,maxTexts:rpt}),this.renderTile(I)}},{key:"destroyTile",value:function(I){I.rectGraphics.destroy(),I.rectMaskGraphics.destroy(),I.textGraphics.destroy(),I.textBgGraphics.destroy(),I.graphics.destroy()}},{key:"rerender",value:function(I,A){const d=JSON.stringify(I);!A&&d===this.prevOptions||(n(G(s.prototype),"rerender",this).call(this,I,A),this.fontSize=+this.options.fontSize||qve,this.geneLabelPos=this.options.geneLabelPosition||eZe,this.geneRectHeight=+this.options.geneAnnotationHeight||n4,this.geneStrandHSpacing=this.geneStrandSpacing/2,this.geneRectHHeight=this.geneRectHeight/2,this.prevOptions=d,this.visibleAndFetchedTiles().forEach(h=>{this.renderTile(h)}))}},{key:"drawTile",value:function(){}},{key:"geneId",value:function(I,A){return`${A}_${I[0]}_${I[1]}_${I[2]}_${I[3]}`}},{key:"renderTile",value:function(I){if(!I.initialized)return;I.allRects=[],I.drawnAtScale=this._xScale.copy(),I.rectGraphics.removeChildren(),I.rectGraphics.clear(),I.textBgGraphics.clear();const A={},d=.3,h=.3;A["+"]=Mi(this.options.plusStrandColor||r4),A["-"]=Mi(this.options.minusStrandColor||g4);let y=I.tileData.filter(M=>M.type==="filler"&&M.strand==="+"),Z=I.tileData.filter(M=>M.type==="filler"&&M.strand==="-");const b=I.tileData.filter(M=>M.type!=="filler"&&(M.strand==="+"||M.fields[5]==="+")),w=I.tileData.filter(M=>M.type!=="filler"&&(M.strand==="-"||M.fields[5]==="-"));tZe(b,y),tZe(w,Z),y=y.filter(M=>!M.hide),Z=Z.filter(M=>!M.hide);const S=this.dimensions[1]/2,R=S-this.geneRectHeight/2-this.geneStrandSpacing/2,H=S+this.geneRectHeight/2+this.geneStrandSpacing/2,N=[this,I,I.rectGraphics,this._xScale,A["+"],d,R,this.geneRectHeight],D=[this,I,I.rectGraphics,this._xScale,A["-"],d,H,this.geneRectHeight];iZe(y,...N),iZe(Z,...D),N[5]=h,D[5]=h,nZe(b,...N),nZe(w,...D),cpt(this,I),v1.stretchRects(this,[M=>M.rectGraphics,M=>M.rectMaskGraphics]);for(const M of Object.values(I.texts))M.style={fontSize:`${this.fontSize}px`,FONT_FAMILY:i4,fill:Mi(M.strand==="-"?this.options.minusStrandColor||g4:this.options.plusStrandColor||r4)}}},{key:"calculateZoomLevel",value:function(){const I=Gi.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]);let A=Math.min(I,this.maxZoom);return A=Math.max(A,0),A}},{key:"draw",value:function(){n(G(s.prototype),"draw",this).call(this),this.allTexts=[],this.allBoxes=[];const I=[];this.geneAreaHeight=this.geneRectHeight;const A=this.fontSize/2;v1.stretchRects(this,[d=>d.rectGraphics,d=>d.rectMaskGraphics]),Object.values(this.fetchedTiles).filter(d=>d.drawnAtScale).forEach(d=>{d.textBgGraphics.clear(),d.textBgGraphics.beginFill(typeof this.options.labelBackgroundColor<"u"?Mi(this.options.labelBackgroundColor):gpt);const h=this.parentInFetched(d);d.initialized&&d.tileData.forEach(y=>{if(!d.texts||y.type==="filler")return;const Z=y.fields,b=Z[3],w=this.geneId(Z,y.type),S=d.texts[w];if(!S)return;const R=+y.chrOffset,H=+Z[1]+R,N=+Z[2]+R,D=(H+N)/2;let M=this.dimensions[1]/2;const z=(this.geneAreaHeight-this.fontSize)/2;if(Z[5]==="+"?M-=this.geneLabelPos==="inside"?z+this.geneStrandSpacing-2:this.fontSize/2+this.geneAreaHeight-2:M+=this.geneLabelPos==="inside"?this.fontSize+this.geneStrandSpacing/2+z+1:1.5*this.fontSize+this.geneAreaHeight+2,S.position.x=this._xScale(D),S.position.y=M,!d.textWidths[w]){const K=S.getBounds().width,P=S.getBounds().height;d.textHeights[w]=P,d.textWidths[w]=K}if(h)S.visible=!1;else{S.visible=!0;const K=2;this.flipText?this.allBoxes.push([S.position.x-d.textHeights[w]/2-K,M-A-1,S.position.x+d.textHeights[w]/2+K,M+A-1,b]):this.allBoxes.push([S.position.x-d.textWidths[w]/2-K,M-A-1,S.position.x+d.textWidths[w]/2+K,M+A-1,b]),this.allTexts.push({importance:+Z[4],text:S,caption:b,strand:Z[5]}),I.push(d.textBgGraphics)}})}),this.hideOverlaps(this.allBoxes,this.allTexts),this.renderTextBg(this.allBoxes,this.allTexts,I)}},{key:"renderTextBg",value:function(I,A,d){A.forEach((h,y)=>{if(h.text.visible&&I[y]&&d[y]){const[Z,b,w,S]=I[y],R=w-Z,H=S-b;d[y].drawRect(Z-R/2,b-H/2,R,H)}})}},{key:"hideOverlaps",value:function(I,A){VT(I,(d,h)=>{A[d].importance>A[h].importance?A[h].text.visible=!1:A[d].text.visible=!1})}},{key:"setPosition",value:function(I){n(G(s.prototype),"setPosition",this).call(this,I),[this.pMain.position.x,this.pMain.position.y]=this.position}},{key:"setDimensions",value:function(I){n(G(s.prototype),"setDimensions",this).call(this,I),this.halfRectHHeight=this.dimensions[1]/2,this.visibleAndFetchedTiles().forEach(A=>{this.renderTile(A)})}},{key:"zoomed",value:function(I,A){this.xScale(I),this.yScale(A),this.refreshTiles(),this.draw()}},{key:"getMouseOverHtml",value:function(I,A){if(!this.tilesetInfo)return"";const d=[I,A];for(const h of this.visibleAndFetchedTiles())for(let y=0;y - ${S.fields[3]}
- Position: ${S.fields[0]}:${S.fields[1]}-${S.fields[2]}
- Strand: ${S.fields[5]} - - `}}return""}},{key:"exportSVG",value:function(){let I=null,A=null;n(G(s.prototype),"exportSVG",this)?[A,I]=n(G(s.prototype),"exportSVG",this).call(this):(A=document.createElement("g"),I=A);const d=document.createElement("g");return d.setAttribute("transform",`translate(${this.position[0]},${this.position[1]})`),I.appendChild(d),this.visibleAndFetchedTiles().filter(h=>h.allRects).forEach(h=>{const y=document.createElement("g");y.setAttribute("transform",`translate(${h.rectGraphics.position.x}, - ${h.rectGraphics.position.y}) - scale(${h.rectGraphics.scale.x}, - ${h.rectGraphics.scale.y})`),h.allRects.forEach(Z=>{const b=document.createElement("path"),w=Z[0];let S=`M ${w[0]} ${w[1]}`;for(let R=2;Rh.text.visible).forEach(h=>{const y=document.createElement("g"),Z=document.createElement("text");Z.setAttribute("text-anchor","middle"),Z.setAttribute("font-family",i4),Z.setAttribute("font-size",`${this.fontSize}px`),Z.setAttribute("dy","-.2em"),y.setAttribute("transform",`scale(${h.text.scale.x},1)`),h.strand==="+"?Z.setAttribute("fill",this.options.plusStrandColor):Z.setAttribute("fill",this.options.minusStrandColor),Z.innerHTML=h.text.text,y.appendChild(Z),y.setAttribute("transform",`translate(${h.text.x},${h.text.y})scale(${h.text.scale.x},1)`),d.appendChild(y)}),[A,A]}}]),s}(c1);function rZe(g,a,s,C,I,A,d,h,y,Z){const b=Z?g._xScale(s.yStart):g._xScale(s.xStart),w=Z?g._xScale(s.yEnd):g._xScale(s.xEnd),S=Z?g._yScale(s.xStart):g._yScale(s.yStart),R=Z?g._yScale(s.xEnd):g._yScale(s.yEnd),H=s.uid+Z,N=w-b,D=R-S;let M={x:b,y:S,width:N,height:D};C&&(NI&&M.xI&&zd&&M.yd&&Ky||M.height>y)&&(a.drawRect(M.x,M.y,M.width,M.height),g.publish("annotationDrawn",{trackUuid:g.uuid,annotationUuid:H,viewPos:[M.x,M.y,M.width,M.height],dataPos:[s.xStart,s.xEnd,s.yStart,s.yEnd],importance:s.importance,info:{patternType:g.options.patternType}}))}let gZe=function(g){o(s,g);var a=l(s);function s(...C){var I;T(this,s),I=a.call(this,...C),I.drawnRects={};const{publish:A,subscribe:d,unsubscribe:h}=Vk();return I.publish=A,I.subscribe=d,I.unsubscribe=h,I}return E(s,[{key:"tileToLocalId",value:function(I){return`${I.join(".")}`}},{key:"tileToRemoteId",value:function(I){return`${I.join(".")}`}},{key:"localToRemoteId",value:function(I){const A=I.split(".");return A.slice(0,A.length-1).join(".")}},{key:"calculateZoomLevel",value:function(){const I=Gi.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]),A=Gi.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[1]);let d=Math.max(I,A);return d=Math.min(d,this.maxZoom),d}},{key:"setVisibleTiles",value:function(I){this.visibleTiles=I.map(A=>({tileId:this.tileToLocalId(A),remoteId:this.tileToRemoteId(A)})),this.visibleTileIds=new Set(this.visibleTiles.map(A=>A.remoteId))}},{key:"calculateVisibleTiles",value:function(){if(!this.tilesetInfo)return;this.zoomLevel=this.calculateZoomLevel(),this.xTiles=Gi.calculateTiles(this.zoomLevel,this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width),this.yTiles=Gi.calculateTiles(this.zoomLevel,this._yScale,this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[1],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width);const I=this.xTiles,A=this.yTiles,d=this.zoomLevel,h=[];for(let y=0;y!(H.uid in this.drawnRects)).forEach(H=>{rZe(this,A,H,y,b,w,S,R,Z,this.options.flipDiagonal==="yes"),this.options.flipDiagonal&&this.options.flipDiagonal==="copy"&&rZe(this,A,H,y,b,w,S,R,Z,!0)})}},{key:"exportSVG",value:function(){let I=null,A=null;n(G(s.prototype),"exportSVG",this)?[A,I]=n(G(s.prototype),"exportSVG",this).call(this):(A=document.createElement("g"),I=A);const d=document.createElement("g");d.setAttribute("transform",`translate(${this.position[0]},${this.position[1]})`),I.appendChild(d);for(const h of[!0,!1])for(const y of this.visibleAndFetchedTiles())!y.tileData||!y.tileData.length||y.tileData.forEach(Z=>{const b=Z.uid+h,w=document.createElement("g");if(w.setAttribute("transform",`translate(${y.graphics.position.x},${y.graphics.position.y})scale(${y.graphics.scale.x},${y.graphics.scale.y})`),d.appendChild(w),b in this.drawnRects){const S=this.drawnRects[b],R=document.createElement("rect");R.setAttribute("x",S.x),R.setAttribute("y",S.y),R.setAttribute("width",S.width),R.setAttribute("height",S.height),R.setAttribute("fill",this.options.rectangleDomainFillColor?this.options.rectangleDomainFillColor:"grey"),R.setAttribute("opacity",.3),R.style.stroke="black",R.style.strokeWidth="1px",w.appendChild(R)}});return[A,A]}},{key:"setPosition",value:function(I){n(G(s.prototype),"setPosition",this).call(this,I),this.pMain.position.y=this.position[1],this.pMain.position.x=this.position[0]}},{key:"zoomed",value:function(I,A){this.xScale().domain()[0]===I.domain()[0]&&this.xScale().domain()[1]===I.domain()[1]&&this.yScale().domain()[0]===A.domain()[0]&&this.yScale().domain()[1]===A.domain()[1]||(this.xScale(I),this.yScale(A),this.refreshTiles(),this.draw())}},{key:"leftTrackDraw",value:function(){this.draw()}}]),s}(Jf);const Apt=250;let oZe=function(g){o(s,g);var a=l(s);function s(C,I){var A;T(this,s),A=a.call(this,C,I);const{pubSub:d}=C;A.drawnAnnotations={},A.drawnAnnoGfx={},A.selectedAnno=null,A.options.minSquareSize=+A.options.minSquareSize;const{publish:h,subscribe:y,unsubscribe:Z}=Vk();return A.publish=h,A.subscribe=y,A.unsubscribe=Z,A.sT=0,A.annoSelectedBound=A.annoSelected.bind(u(A)),A.pubSubs.push(d.subscribe("annoSelected",A.annoSelectedBound)),A}return E(s,[{key:"minX",get:function(){return this.tilesetInfo&&this.tilesetInfo.min_pos?this.tilesetInfo.min_pos[0]:0}},{key:"maxX",get:function(){return this.tilesetInfo&&this.tilesetInfo.max_pos?this.tilesetInfo.max_pos[0]:this.tilesetInfo.max_width||this.tilesetInfo.max_size}},{key:"minY",get:function(){return this.minX}},{key:"maxY",get:function(){return this.maxX}},{key:"maxSize",get:function(){const C=this.tilesetInfo.max_pos&&Math.max(this.tilesetInfo.max_pos[0]-this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[1]-this.tilesetInfo.min_pos[1]);return C||(this.tilesetInfo.max_size?this.tilesetInfo.max_size:0)}},{key:"projection",value:function([I,A]){return[this._xScale(I),this._yScale(A)]}},{key:"tileToLocalId",value:function(I){return`${I.join(".")}`}},{key:"tileToRemoteId",value:function(I){return`${I.join(".")}`}},{key:"localToRemoteId",value:function(I){const A=I.split(".");return A.slice(0,A.length-1).join(".")}},{key:"calculateZoomLevel",value:function(){const I=Gi.calculateZoomLevel(this._xScale,this.minX,this.maxX),A=Gi.calculateZoomLevel(this._yScale,this.minY,this.maxY);return T0e(xU(I,A),this.maxZoom)}},{key:"setVisibleTiles",value:function(I){this.visibleTiles=I.map(A=>({tileId:this.tileToLocalId(A),remoteId:this.tileToRemoteId(A)})),this.visibleTileIds=new Set(this.visibleTiles.map(A=>A.tileId))}},{key:"calculateVisibleTiles",value:function(){if(!this.tilesetInfo)return;this.zoomLevel=this.calculateZoomLevel(),this.xTiles=Gi.calculateTiles(this.zoomLevel,this._xScale,this.minX,this.maxX,this.tilesetInfo.max_zoom,this.maxSize),this.yTiles=Gi.calculateTiles(this.zoomLevel,this._yScale,this.minY,this.maxY,this.tilesetInfo.max_zoom,this.maxSize);const I=this.zoomLevel,A=[];for(let d=0;d!(y.uid in this.drawnAnnotations)||A).forEach(y=>{const[Z,b]=this.projection([y.xStart,y.yStart]),[w,S]=this.projection([y.xEnd,y.yEnd]);this.options.exclude&&this.options.exclude.indexOf(y.uid)>=0||this.drawAnnotation(this.prepAnnotation(h,y.uid,Z,b,w-Z,S-b,y),d)})}},{key:"prepAnnotation",value:function(I,A,d,h,y,Z,b){let w;try{w=JSON.parse(b.fields)}catch{}return{graphics:I,id:b.id,uid:A,annotation:{x:d,y:h,width:y,height:Z},dataPos:[b.xStart,b.xEnd,b.yStart,b.yEnd],importance:b.importance,info:w}}},{key:"drawAnnotation",value:function({graphics:I,id:A,uid:d,annotation:h,dataPos:y,importance:Z,info:b},w){this.options.minSquareSize&&(h.widththis.hover(R,S,d),R.mouseout=()=>this.blur(R,S,d),R.mousedown=()=>this.mouseDown(),R.mouseup=N=>this.mouseUp(R,S,d,N,H),w||this.publish("annotationDrawn",{trackUuids:this.uuid,annotationUuid:d,annotationId:A,viewPos:S,dataPos:y,importance:Z,info:b})}},{key:"_drawRect",value:function(I,A,d){let h=this.options.rectangleDomainStrokeColor,y=this.options.rectangleDomainStrokeWidth,Z=this.options.rectangleDomainStrokeOpacity,b=this.options.rectangleDomainFillColor,w=this.options.rectangleDomainFillOpacity;this.hoveredAnno===d&&(h=this.options.hoverColor,y=this.options.rectangleDomainStrokeWidth+1||2,Z=1,b=this.options.hoverColor,w=this.options.rectangleDomainFillOpacity),this.selectedAnno&&this.selectedAnno.uid===d&&(h=this.options.selectColor,y=this.options.rectangleDomainStrokeWidth+1||2,Z=1,b=this.options.selectColor,w=xU(.33,this.options.rectangleDomainFillOpacity)),I.clear(),this.options.trackBorderBgWidth&&(this.setBorderStyle(I,this.options.trackBorderBgColor,this.options.trackBorderBgWidth,this.options.trackBorderBgAlpha),this.setFill(I,b,0),I.drawRect(...A)),this.setBorderStyle(I,h,y,Z),this.setFill(I,b,w),I.drawRect(...A),I.__viewPos__=A}},{key:"context",value:function(I,A,d){return h=>h(I,A,d)}},{key:"click",value:function(I,A,d,h,y){this.select(I,A,d),this.pubSub.publish("app.click",{type:"annotation",event:h,payload:y})}},{key:"mouseDown",value:function(){this.sT=performance.now()}},{key:"mouseUp",value:function(I,A,d,h,y){performance.now()-this.sT<=Apt&&this.click(I,A,d,h,y)}},{key:"hover",value:function(I,A,d){this.hoveredAnno=d,this._drawRect(I,A,d),this.animate()}},{key:"focus",value:function(I,A,d){this._drawRect(I,A,d),this.animate()}},{key:"blur",value:function(I,A,d){this.hoveredAnno=null,this._drawRect(I,A,d),this.animate()}},{key:"select",value:function(I,A,d,h=!1){let y=null,Z=null;this.selectedAnno&&(y=this.selectedAnno.graphics,Z=this.selectedAnno.uid),this.selectedAnno={graphics:I,uid:d},this.focus(I,A,d),this.options.onSelect&&!h&&(window[this.options.onSelect](d),this.pubSub.publish("annoSelected",d)),y&&Z&&this.blur(y,y.__viewPos__,Z)}},{key:"unselect",value:function(){const I=this.selectedAnno.graphics,A=this.selectedAnno.uid;this.selectedAnno=null,this.blur(I,I.__viewPos__,A)}},{key:"annoSelected",value:function(I){if(!this.selectedAnno||this.selectedAnno.uid!==I){this.selectedAnno&&this.unselect();const A=this.drawnAnnoGfx[I];A&&this.select(A,A.__viewPos__,I,!0)}}},{key:"exportSVG",value:function(){let I=null,A=null;n(G(s.prototype),"exportSVG",this)?[A,I]=n(G(s.prototype),"exportSVG",this).call(this):(A=document.createElement("g"),I=A);const d=document.createElement("g");return d.setAttribute("transform",`translate(${this.position[0]},${this.position[1]})`),I.appendChild(d),this.visibleAndFetchedTiles().filter(h=>h.tileData&&h.tileData.length).map(h=>({graphics:h.graphics,td:h.tileData})).forEach(({td:h,graphics:y})=>{const Z=document.createElement("g");if(Z.setAttribute("transform",`translate(${y.position.x},${y.position.y})scale(${y.scale.x},${y.scale.y})`),d.appendChild(Z),h.uid in this.drawnAnnotations){const b=this.drawnAnnotations[h.uid],w=document.createElement("rect");w.setAttribute("x",b.x),w.setAttribute("y",b.y),w.setAttribute("width",b.width),w.setAttribute("height",b.height),w.setAttribute("fill",this.options.fillColor||"grey"),w.setAttribute("opacity",.3),w.style.stroke=this.options.fillColor||"grey",w.style.strokeWidth="1px",Z.appendChild(w)}}),[A,A]}},{key:"setBorderStyle",value:function(I,A=this.options.rectangleDomainStrokeColor,d=this.options.rectangleDomainStrokeWidth,h=this.options.rectangleDomainStrokeOpacity){I.lineStyle(typeof d<"u"?d:1,Mi(A||"black"),typeof h<"u"?h:1)}},{key:"setFill",value:function(I,A=this.options.rectangleDomainFillColor,d=this.options.rectangleDomainFillOpacity){I.beginFill(Mi(A||"grey"),typeof d<"u"?d:.4)}},{key:"setPosition",value:function(I){n(G(s.prototype),"setPosition",this).call(this,I),this.pMain.position.y=this.position[1],this.pMain.position.x=this.position[0]}},{key:"zoomed",value:function(I,A){this.xScale(I),this.yScale(A),this.refreshTiles(),this.draw()}}]),s}(Jf),s4=function(g){o(s,g);var a=l(s);function s(C,I,A){var d;return T(this,s),d=a.call(this,C,I),d.pubSub=C.pubSub,d.options=I,d.isVertical=A,d.rects={},d.defaultColor=ko("red"),d}return E(s,[{key:"draw",value:function(){const I=typeof this.options.minRectWidth<"u"?this.options.minRectWidth:10,A=typeof this.options.fill<"u"?ko(this.options.fill):this.defaultColor,d=typeof this.options.fillOpacity<"u"?+this.options.fillOpacity:.2,h=typeof this.options.stroke<"u"?ko(this.options.stroke):this.defaultColor,y=typeof this.options.strokeWidth<"u"?+this.options.strokeWidth:1,Z=typeof this.options.strokeOpacity<"u"?+this.options.strokeOpacity:0;let b;this.options.strokePos&&this.options.strokePos.length&&(b=Array.isArray(this.options.strokePos)?this.options.strokePos:[this.options.strokePos]),n(G(s.prototype),"draw",this).call(this);const w=this.pMain;w.clear();const S=performance.now();this.options.regions.forEach(R=>{const H=`${R[0]}-${R[1]}`;this.rects[H]||(this.rects[H]={graphics:new $t.PIXI.Graphics},w.addChild(this.rects[H].graphics)),this.rects[H].timeStamp=S;const N=ko(R[2])||A;let D=ko(R[3])||h;D||(D=N);const M=$t.PIXI.utils.rgb2hex([N.r/255,N.g/255,N.b/255]),z=$t.PIXI.utils.rgb2hex([D.r/255,D.g/255,D.b/255]);b?(w.lineStyle(1,z,0),w.beginFill(z,+R[5]||Z)):(w.lineStyle(y,z,+R[5]||Z),w.beginFill(M,+R[4]||d));const K=this.isVertical?this._yScale:this._xScale;let P=K(+R[0]);const J=K(+R[1]);let j=J-P;const ie=typeof R[6]<"u"?R[6]:I;j{(te==="top"||te==="around")&&(this.isVertical?w.drawRect(0,P,y,j):w.drawRect(P,0,j,y)),(te==="right"||te==="around")&&(this.isVertical?w.drawRect(0,P,this.dimensions[0],y):w.drawRect(P,0,y,this.dimensions[1])),(te==="bottom"||te==="around")&&(this.isVertical?w.drawRect(this.dimensions[0]-y,P,y,j):w.drawRect(P,this.dimensions[1]-y,j,y)),(te==="left"||te==="around")&&(this.isVertical?w.drawRect(0,P+j-y,this.dimensions[0],y):w.drawRect(P+j-y,0,y,this.dimensions[1]))})):w.lineStyle(y,z,+R[5]||Z),this.rects[H].graphics.clear(),this.rects[H].graphics.interactive=!0,this.rects[H].graphics.buttonMode=!0,w.beginFill(M,+R[4]||d),this.isVertical?(w.drawRect(0,P,this.dimensions[0],j),this.rects[H].graphics.hitArea=new $t.PIXI.Rectangle(0,P,this.dimensions[0],j)):(w.drawRect(P,0,j,this.dimensions[1]),this.rects[H].graphics.hitArea=new $t.PIXI.Rectangle(P,0,j,this.dimensions[1])),this.rects[H].graphics.mousedown=()=>{this.rects[H].mouseDownTime=performance.now()},this.rects[H].graphics.mouseup=te=>{performance.now()-this.rects[H].mouseDownTimeR.timeStamp!==S).forEach(R=>w.removeChild(R.graphics))}},{key:"setPosition",value:function(I){n(G(s.prototype),"setPosition",this).call(this,I),this.pMain.position.y=this.position[1],this.pMain.position.x=this.position[0]}},{key:"zoomed",value:function(I,A){this.xScale(I),this.yScale(A),this.draw()}}]),s}(Xs),aZe=function(g){o(s,g);var a=l(s);function s(C,I){var A;return T(this,s),A=a.call(this,C,I),A.drawnRects=new Set,A.pMain=A.pMobile,A}return E(s,[{key:"tileToLocalId",value:function(I){return`${I.join(".")}`}},{key:"tileToRemoteId",value:function(I){return`${I.join(".")}`}},{key:"localToRemoteId",value:function(I){const A=I.split(".");return A.slice(0,A.length-1).join(".")}},{key:"calculateZoomLevel",value:function(){const I=Gi.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]),A=Gi.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[1]);let d=Math.max(I,A);return d=Math.min(d,this.maxZoom),this.options&&this.options.maxZoom&&(this.options.maxZoom>=0?d=Math.min(this.options.maxZoom,d):console.error("Invalid maxZoom on track:",this)),d}},{key:"setVisibleTiles",value:function(I){this.visibleTiles=I.map(A=>({tileId:this.tileToLocalId(A),remoteId:this.tileToRemoteId(A)})),this.visibleTileIds=new Set(this.visibleTiles.map(A=>A.tileId))}},{key:"calculateVisibleTiles",value:function(){if(!this.tilesetInfo)return;this.zoomLevel=this.calculateZoomLevel();const I=this._xScale.copy();I.domain([this._xScale.invert(this._xScale.range()[0]-this.dimensions[1]*Math.sqrt(2)),this._xScale.invert(this._xScale.range()[1]+this.dimensions[1]*Math.sqrt(2))]),this.xTiles=Gi.calculateTiles(this.zoomLevel,I,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width),this.yTiles=Gi.calculateTiles(this.zoomLevel,I,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width);const A=this.xTiles,d=this.yTiles,h=this.zoomLevel,Z=this.tilesetInfo.max_width/2**h,b=[];for(let w=0;wthis.dimensions[1])continue;const H=[h,A[w],d[S]];H.mirrored=!1,b.push(H)}this.setVisibleTiles(b)}},{key:"initTile",value:function(I){n(G(s.prototype),"initTile",this).call(this,I),this.drawTile(I)}},{key:"destroyTile",value:function(I,A){}},{key:"draw",value:function(){this.delayDrawing||this.drawnRects.clear(),n(G(s.prototype),"draw",this).call(this)}},{key:"drawTile",value:function(I){if(!I.graphics)return;const A=I.graphics;A.clear();const d=Mi(this.options.rectangleDomainStrokeColor?this.options.rectangleDomainStrokeColor:"black"),h=Mi(this.options.rectangleDomainFillColor?this.options.rectangleDomainFillColor:"grey");if(A.lineStyle(1/this.pMain.scale.x,d,1),A.beginFill(h,.4),A.alpha=this.options.rectangleDomainOpacity?this.options.rectangleDomainOpacity:.5,!!I.tileData.sort)for(const y of I.tileData){const Z=this._refXScale(y.xStart),b=this._refXScale(y.xEnd),w=this._refYScale(y.yStart),S=this._refYScale(y.yEnd),R=y.uid;this.drawnRects.has(R)||(this.drawnRects.add(R),A.drawRect(Z,w,b-Z,S-w),A.pivot.x=this._refXScale(0),A.pivot.y=this._refYScale(0),A.scale.x=-1/Math.sqrt(2),A.rotation=-3*Math.PI/4,A.scale.y=1/Math.sqrt(2),A.position.x=this._refXScale(0),A.position.y=0)}}},{key:"setPosition",value:function(I){n(G(s.prototype),"setPosition",this).call(this,I),this.pMain.position.y=this.position[1],this.pMain.position.x=this.position[0]}},{key:"refScalesChanged",value:function(I,A){n(G(s.prototype),"refScalesChanged",this).call(this,I,A);for(const d in this.fetchedTiles){const h=this.fetchedTiles[d];if(h.sprite){const y=h.graphics;y.pivot.x=this._refXScale(0),y.pivot.y=this._refYScale(0),y.scale.x=-1/Math.sqrt(2),y.rotation=-3*Math.PI/4,y.scale.y=1/Math.sqrt(2),y.position.x=this._refXScale(0),y.position.y=0}}}},{key:"zoomed",value:function(I,A,d,h,y){n(G(s.prototype),"zoomed",this).call(this,I,A,d,h,y),this.pMain.position.x=h,this.pMain.position.y=this.position[1]+this.dimensions[1],this.pMain.scale.x=d,this.pMain.scale.y=d,this.options.oneDHeatmapFlipped&&(this.pMain.scale.y=-d,this.pMain.position.y=this.position[1]),this.draw()}},{key:"leftTrackDraw",value:function(){this.draw()}}]),s}(Jf),sZe=function(g){o(s,g);var a=l(s);function s(C,I){var A;return T(this,s),A=a.call(this,C,I),A.drawnRects=new Set,A}return E(s,[{key:"tileToLocalId",value:function(I){return`${I.join(".")}`}},{key:"tileToRemoteId",value:function(I){return`${I.join(".")}`}},{key:"localToRemoteId",value:function(I){const A=I.split(".");return A.slice(0,A.length-1).join(".")}},{key:"calculateZoomLevel",value:function(){const I=Gi.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]),A=Gi.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[1]);let d=Math.max(I,A);return d=Math.min(d,this.maxZoom),d}},{key:"setVisibleTiles",value:function(I){this.visibleTiles=I.map(A=>({tileId:this.tileToLocalId(A),remoteId:this.tileToRemoteId(A)})),this.visibleTileIds=new Set(this.visibleTiles.map(A=>A.tileId))}},{key:"calculateVisibleTiles",value:function(I=!0){if(!this.tilesetInfo)return;this.zoomLevel=this.calculateZoomLevel(),this.xTiles=Gi.calculateTiles(this.zoomLevel,this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width),this.yTiles=Gi.calculateTiles(this.zoomLevel,this._yScale,this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[1],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width);const A=this.xTiles,d=this.yTiles,h=this.zoomLevel,y=[];for(let Z=0;ZC.chrPositions?xo(I,C):null,C.chrToAbs=([I,A]=[])=>C.chrPositions?Qk(I,A,C):null,Gi.text(g,(I,A)=>{if(I)a&&a(null);else{const d=VU(A),h=sX(d);Object.keys(h).forEach(y=>{C[y]=h[y]}),a&&a(C)}},s).then(()=>C)}let G1=function(){function g(a){T(this,g),this.chromInfo=a,this.chromInfoBisector=pZ(s=>s.pos).left}return E(g,[{key:"scalesToPositionText",value:function(s,C,I=!1){if(this.chromInfo===null||!s||!C)return"";const A=xo(s.domain()[0],this.chromInfo),d=xo(s.domain()[1],this.chromInfo),h=xo(C.domain()[0],this.chromInfo),y=xo(C.domain()[1],this.chromInfo);let Z=null;const b=fl(",d");return A[0]!==d[0]?Z=`${A[0]}:${b(Math.floor(A[1]))}-${d[0]}:${b(Math.ceil(d[1]))}`:Z=`${A[0]}:${b(Math.floor(A[1]))}-${b(Math.ceil(d[1]))}`,I&&(h[0]!==y[0]?Z+=` & ${h[0]}:${b(Math.floor(h[1]))}-${y[0]}:${b(Math.ceil(y[1]))}`:Z+=` & ${h[0]}:${b(Math.floor(h[1]))}-${b(Math.ceil(y[1]))}`),(A[2]<=0||d[2]>0||I&&(h[2]<=0||y[2]>0))&&(Z+=` [offset ${A[2]},${d[2]}`,I&&(Z+=`:${h[2]},${y[2]}`),Z+="]"),Z}},{key:"convertNumberNotation",value:function(s){let C=s;if(!C.includes("M",C.length-1)&&!C.includes("K",C.length-1))return C;let I=0,A=0;if(C.includes("M",C.length-1)?(I=6,C=C.replace("M","")):(I=3,C=C.replace("K","")),Number.isNaN(+C))return s;C=(+C).toString(),C.includes(".")&&(A=C.length-1-C.indexOf("."),C=(+C.replace(".","")).toString());const d=I-A;return d<0?s:(C+="0".repeat(d),C)}},{key:"parsePosition",value:function(s,C=null){const I=s.split(":");let A=null,d=0;I.length>1?(A=I[0],d=+this.convertNumberNotation(I[1].replace(/,/g,""))):I[0]in this.chromInfo.chrPositions?(A=I[0],d=0,C!==null&&(d=+this.chromInfo.chromLengths[A])):(d=+this.convertNumberNotation(I[0].replace(/,/g,"")),A=null,C&&(A=C));let h=null;return A===null?(A=C,h=d):A in this.chromInfo.chrPositions&&(h=this.chromInfo.chrPositions[A].pos+d),[A,d,h]}},{key:"matchRangesToLarger",value:function(s,C){if(s[1]-s[0]A.length>0);let I=null;if(C[0].indexOf("-")===0&&(C[0]=C[0].slice(3,C[0].length)),C.length>1){let[A,d,h]=this.parsePosition(C[0]),[y,Z,b]=this.parsePosition(C[1],A);const w=[h,b];[A,d,h]=this.parsePosition(C[1]),[y,Z,b]=this.parsePosition(C[0],A),A===null&&y!==null&&([A,d,h]=this.parsePosition(C[1],y));const S=[h,b];return S[1]-S[0]>w[1]-w[0]?S:w}if(C[0]in this.chromInfo.chrPositions){const A=+this.chromInfo.chrPositions[C[0]].pos;I=[A,A+ +this.chromInfo.chromLengths[C[0]]]}else{const[A,d,h]=this.parsePosition(C[0]);I=[h-8e6,h+8e6]}return I[0]>I[1]?[I[1],I[0]]:I}},{key:"parseOffset",value:function(s){const C=s.split(":");if(C.length===0)return[[0,0],[0,0]];if(C.length===1){const d=C[0].split(",");return[[+d[0],+d[1]],[0,0]]}const I=C[0].split(","),A=C[1].split(",");return[[+I[0],+I[1]],[+A[0],+A[1]]]}},{key:"searchPosition",value:function(s){let C=null,I=null;s=s.trim();const A=/\[offset (.+?)\]/.exec(s);let d=[[0,0],[0,0]];A&&(s=s.replace(A[0],""),d=this.parseOffset(A[1]));const h=s.split(" & ");return h.length>1?(C=this.getSearchRange(h[0].split(" ")[0]),I=this.getSearchRange(h[1].split(" ")[0])):C=this.getSearchRange(h[0]),C!==null&&I!==null&&([C,I]=this.matchRangesToLarger(C,I)),C&&(C[0]+=d[0][0],C[1]+=d[0][1]),I&&(I[0]+=d[1][0],I[1]+=d[1][1]),[C,I]}}]),g}(),IZe=function(g){o(s,g);var a=l(s);function s(C,I){var A;T(this,s),A=a.call(this,C,I);const{dataConfig:d,animate:h,pubSub:y}=C;A.searchField=null,A.chromInfo=null,A.animate=h;const Z=d.server,b=d.tilesetUid,w=`${Z}/chrom-sizes/?id=${b}`;return nu(w,S=>{A.chromInfo=S,A.searchField=new G1(A.chromInfo),A.draw(),A.texts=[];for(let R=0;Rthis.dimensions[0]?M.x-=N+K-this.dimensions[0]:N-K<0&&(M.x-=N-K),D+P>this.dimensions[1]?M.y-=D+P-this.dimensions[1]:D-P<0&&(M.y-=D-P),M.visible=!0,I.push({importance:this.texts[Z][b].hashValue,text:this.texts[Z][b],caption:null})}this.hideOverlaps(I)}},{key:"hideOverlaps",value:function(I){let A=[];A=I.map(d=>{const h=d.text;h.updateTransform();const y=h.getBounds();return[y.x,y.y,y.x+y.width,y.y+y.height]}),VT(A,(d,h)=>{I[d].importance>I[h].importance?I[h].text.visible=0:I[d].text.visible=0})}},{key:"setPosition",value:function(I){n(G(s.prototype),"setPosition",this).call(this,I),this.pMain.position.y=this.position[1],this.pMain.position.x=this.position[0]}},{key:"zoomed",value:function(I,A){this.xScale(I),this.yScale(A),this.draw()}}]),s}(Xs),HT=function(g){o(s,g);var a=l(s);function s(C,I){var A;T(this,s),A=a.call(this,C,I);const{chromInfoPath:d,dataConfig:h,animate:y,pubSub:Z,orientation:b="2d",isOverlay:w=!1}=C;A.searchField=null,A.chromInfo=null,A.animate=y,A.orientation=b,A.isOverlay=w;let S=d;return S||(S=`${h.server}/chrom-sizes/?id=${h.tilesetUid}`),nu(S,R=>{A.chromInfo=R,A.searchField=new G1(A.chromInfo),A.texts=[],A.lineGraphics=new $t.PIXI.Graphics,A.lineGraphics1dH=new $t.PIXI.Graphics,A.lineGraphics1dV=new $t.PIXI.Graphics,A.lineGraphics2d=new $t.PIXI.Graphics,A.mask1dH=new $t.PIXI.Graphics,A.mask1dV=new $t.PIXI.Graphics,A.mask2d=new $t.PIXI.Graphics,A.lineGraphics.addChild(A.lineGraphics1dH),A.lineGraphics1dH.addChild(A.mask1dH),A.lineGraphics.addChild(A.lineGraphics1dV),A.lineGraphics1dV.addChild(A.mask1dV),A.lineGraphics.addChild(A.lineGraphics2d),A.lineGraphics2d.addChild(A.mask2d),A.pMain.addChild(A.lineGraphics),A.draw(),A.animate()},Z),A}return E(s,[{key:"drawLines",value:function(I=this.orientation,A=0,d=0){let h=this.lineGraphics;this.isOverlay&&I==="1d-horizontal"&&(h=this.lineGraphics1dH),this.isOverlay&&I==="1d-vertical"&&(h=this.lineGraphics1dV),this.isOverlay&&I==="2d"&&(h=this.lineGraphics2d);const y=Mi(this.options.lineStrokeColor?this.options.lineStrokeColor:"blue"),Z=this.options.lineStrokeWidth?this.options.lineStrokeWidth:1;h.lineStyle(Z,y,1),(I==="2d"||I==="1d-horizontal")&&(h.moveTo(this._xScale(0)+A,d),h.lineTo(this._xScale(0)+A,this.dimensions[1]+d)),(I==="2d"||I==="1d-vertical")&&(h.moveTo(A,this._yScale(0)+d),h.lineTo(this.dimensions[0]+A,this._yScale(0)+d));for(let b=0;b0&&S0&&S0&&N0&&N{A.chromInfo=y,A.draw()},A.pubSub),A}return E(s,[{key:"draw",value:function(){if(!this.chromInfo)return;const I=this.options.minRectWidth?this.options.minRectWidth:10,A=this.options.minRectWidth?this.options.minRectHeight:10;n(G(s.prototype),"draw",this).call(this);const d=this.pMain;d.clear();const h=performance.now();this.options.regions.forEach(y=>{const Z=y.slice(0,6).join("-");this.rects[Z]||(this.rects[Z]={graphics:new $t.PIXI.Graphics},d.addChild(this.rects[Z].graphics)),this.rects[Z].timeStamp=h;const b=ko(y[6]);let w=ko(y[7]);w||(w=b);const S=$t.PIXI.utils.rgb2hex([b.r/255,b.g/255,b.b/255]),R=$t.PIXI.utils.rgb2hex([w.r/255,w.g/255,w.b/255]);d.lineStyle(1,R,w.opacity),d.beginFill(S,b.opacity);let H=this._xScale(this.chromInfo.chrPositions[y[0]].pos+ +y[1]);const N=this._xScale(this.chromInfo.chrPositions[y[0]].pos+ +y[2]);let D=this._yScale(this.chromInfo.chrPositions[y[3]].pos+ +y[4]);const M=this._yScale(this.chromInfo.chrPositions[y[3]].pos+ +y[5]);let z=N-H,K=M-D;const P=typeof y[8]<"u"?y[8]:I,J=typeof y[9]<"u"?y[9]:A;z{this.rects[Z].mouseDownTime=performance.now()},this.rects[Z].graphics.mouseup=j=>{performance.now()-this.rects[Z].mouseDownTime{A.chromInfo=w,A.searchField=new G1(A.chromInfo),A.rerender(A.options,!0),A.draw(),A.animate()},A.pubSub),A}return E(s,[{key:"initBoundsTicks",value:function(){this.pTicks&&(this.pMain.removeChild(this.pTicks),this.pTicks=null),this.gBoundTicks||(this.gBoundTicks=new $t.PIXI.Graphics,this.leftBoundTick=new $t.PIXI.Text("",this.pixiTextConfig),this.rightBoundTick=new $t.PIXI.Text("",this.pixiTextConfig),this.gBoundTicks.addChild(this.leftBoundTick),this.gBoundTicks.addChild(this.rightBoundTick),this.pMain.addChild(this.gBoundTicks)),this.texts=[]}},{key:"initChromLabels",value:function(){if(this.chromInfo){this.gBoundTicks&&(this.pMain.removeChild(this.gBoundTicks),this.gBoundTicks=null),this.pTicks||(this.pTicks=new $t.PIXI.Graphics,this.pMain.addChild(this.pTicks)),this.texts=[],this.pTicks.removeChildren();for(let I=0;INumber.isInteger(z)),S=this.tickTexts[I.chr],R=this.options.fontIsLeftAligned?(+this.options.fontSize||this.textFontSize)/2:this.tickHeight,H=this.flipText?-1:1,N=this.options.fontIsLeftAligned?H*4:0;let D=this.options.fontIsLeftAligned?0:R+this.tickTextSeparation;for(this.options.reverseOrientation&&(D=this.dimensions[1]-D);S.lengthw.length;){const z=S.pop();this.gTicks[I.chr].removeChild(z)}let M=0;for(;M{if(this.tickTexts[h])for(let y=0;y{d.updateTransform();const y=d.getBounds();return[y.x,y.y,y.x+y.width,y.y+y.height]}),VT(A,(d,h)=>{I[d].importance>I[h].importance?I[h].text.visible=!1:I[d].text.visible=!1})}},{key:"setPosition",value:function(I){n(G(s.prototype),"setPosition",this).call(this,I),[this.pMain.position.x,this.pMain.position.y]=this.position}},{key:"zoomed",value:function(I,A){this.xScale(I),this.yScale(A),this.draw()}},{key:"exportSVG",value:function(){let I=null,A=null;n(G(s.prototype),"exportSVG",this)?[A,I]=n(G(s.prototype),"exportSVG",this).call(this):(A=document.createElement("g"),I=A),A.setAttribute("class","chromosome-labels");const d=document.createElement("g");return I.appendChild(d),d.setAttribute("transform",`translate(${this.position[0]},${this.position[1]})`),this.allTexts.filter(h=>h.text.visible).forEach(h=>{const y=FU(h.text);d.appendChild(y)}),Object.values(this.tickTexts).forEach(h=>{h.filter(y=>y.visible).forEach(y=>{let Z=FU(y);d.appendChild(Z),Z=X0e(y.x,this.options.reverseOrientation?0:this.dimensions[1],y.x,this.options.reverseOrientation?this.tickHeight:this.dimensions[1]-this.tickHeight,1,this.tickColor);const b=document.createElement("line");b.setAttribute("x1",y.tickLine[0]),b.setAttribute("y1",y.tickLine[1]),b.setAttribute("x2",y.tickLine[2]),b.setAttribute("y2",y.tickLine[3]),b.setAttribute("style","stroke: grey"),d.appendChild(Z),d.appendChild(b)})}),[A,I]}}]),s}(Xs),AZe=function(g){o(s,g);var a=l(s);function s(C,I){var A;T(this,s),A=a.call(this,C,I);const{animate:d}=C;return A.pMain=A.pMobile,A.colorScale=JZ,A.continuousScaling=!1,I&&I.colorRange&&(A.colorScale=Df(I.colorRange)),A.animate=d,A.options=I,A.pubSubs=[],A}return E(s,[{key:"rerender",value:function(I,A){n(G(s.prototype),"rerender",this).call(this,I,A),this.zoomed(this.xScale(),this.yScale(),this.pMain.scale.x,this.pMain.position.x,this.pMain.position.y)}},{key:"calculateZoomLevel",value:function(){let I=null;if(this.tilesetInfo.resolutions){const A=Gi.calculateZoomLevelFromResolutions(this.tilesetInfo.resolutions,this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]),d=Gi.calculateZoomLevelFromResolutions(this.tilesetInfo.resolutions,this._xScale,this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[1]);I=Math.min(A,d)}else{const A=Gi.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]),d=Gi.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[1]);I=Math.max(A,d),I=Math.min(I,this.maxZoom)}return this.options&&this.options.maxZoom&&(this.options.maxZoom>=0?I=Math.min(this.options.maxZoom,I):console.error("Invalid maxZoom on track:",this)),I}},{key:"calculateVisibleTiles",value:function(){if(!this.tilesetInfo)return;this.zoomLevel=this.calculateZoomLevel();const I=this._xScale.copy();if(I.domain([this._xScale.invert(this._xScale.range()[0]-this.dimensions[1]*Math.sqrt(2)),this._xScale.invert(this._xScale.range()[1]+this.dimensions[1]*Math.sqrt(2))]),this.tilesetInfo.resolutions){const w=this.tilesetInfo.resolutions.map(S=>+S).sort((S,R)=>R-S);this.xTiles=Gi.calculateTilesFromResolution(w[this.zoomLevel],I,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]),this.yTiles=Gi.calculateTilesFromResolution(w[this.zoomLevel],I,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0])}else this.xTiles=Gi.calculateTiles(this.zoomLevel,I,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width),this.yTiles=Gi.calculateTiles(this.zoomLevel,I,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width);const A=this.xTiles,d=this.yTiles,h=this.zoomLevel,Z=this.tilesetInfo.max_width/2**h,b=[];for(let w=0;wthis.dimensions[1])continue;const H=[h,A[w],d[S]];H.mirrored=!1,H.dataTransform=this.options.dataTransform?this.options.dataTransform:"default",b.push(H)}this.setVisibleTiles(b)}},{key:"tileDataToCanvas",value:function(I){const A=document.createElement("canvas");A.width=256,A.height=256;const d=A.getContext("2d");d.fillStyle="transparent",d.fillRect(0,0,A.width,A.height);const h=new ImageData(I,A.width,A.height);return d.putImageData(h,0,0),A}},{key:"setSpriteProperties",value:function(I,A,d,h){const{tileX:y,tileY:Z,tileWidth:b,tileHeight:w}=this.getTilePosAndDimensions(A,d),S=y+b,R=Z+w;I.width=this._refXScale(S)-this._refXScale(y),I.height=this._refYScale(R)-this._refYScale(Z),I.x=this._refXScale(y),I.y=this._refYScale(Z)}},{key:"pixDataFunction",value:function(I,A){if(A){const d=I.graphics,h=this.tileDataToCanvas(A.pixData),y=$t.PIXI.VERSION[0]==="4"?$t.PIXI.Texture.fromCanvas(h,$t.PIXI.SCALE_MODES.NEAREST):$t.PIXI.Texture.from(h,{scaleMode:$t.PIXI.SCALE_MODES.NEAREST});I.sprite=new $t.PIXI.Sprite(y),I.canvas=h,this.setSpriteProperties(I.sprite,I.tileData.zoomLevel,I.tileData.tilePos,I.mirrored),d.pivot.x=this._refXScale(0),d.pivot.y=this._refYScale(0),d.scale.x=-1/Math.sqrt(2),d.rotation=-3*Math.PI/4,d.scale.y=1/Math.sqrt(2),d.position.x=this._refXScale(0),d.position.y=0,d.removeChildren(),d.addChild(I.sprite)}this.renderingTiles.delete(I.tileId)}},{key:"refScalesChanged",value:function(I,A){n(G(s.prototype),"refScalesChanged",this).call(this,I,A);for(const d in this.fetchedTiles){const h=this.fetchedTiles[d];if(h.sprite){this.setSpriteProperties(h.sprite,h.tileData.zoomLevel,h.tileData.tilePos,h.mirrored);const y=h.graphics;y.pivot.x=this._refXScale(0),y.pivot.y=this._refYScale(0),y.scale.x=-1/Math.sqrt(2),y.rotation=-3*Math.PI/4,y.scale.y=1/Math.sqrt(2),y.position.x=this._refXScale(0),y.position.y=0}}}},{key:"zoomed",value:function(I,A,d,h,y){n(G(s.prototype),"zoomed",this).call(this,I,A,d,h,y),n(G(s.prototype),"draw",this).call(this),this.pMain.position.x=h,this.pMain.position.y=this.position[1]+this.dimensions[1],this.pMain.scale.x=d,this.pMain.scale.y=d,this.options.oneDHeatmapFlipped&&(this.pMain.scale.y=-d,this.pMain.position.y=this.position[1])}},{key:"leftTrackDraw",value:function(){this.draw()}},{key:"exportSVG",value:function(){let I=null,A=null;[A,I]=n(G(s.prototype),"superSVG",this).call(this);const d=document.createElement("g");I.appendChild(d),d.setAttribute("transform",`translate(${this.pMain.position.x},${this.pMain.position.y}) scale(${this.pMain.scale.x},${this.pMain.scale.y})`);for(const y of this.visibleAndFetchedTiles()){const Z=document.createElement("g"),b=y.graphics,w=b.rotation*180/Math.PI,S=`translate(${b.position.x},${b.position.y}) rotate(${w}) scale(${b.scale.x},${b.scale.y}) translate(${-b.pivot.x},${-b.pivot.y})`;Z.setAttribute("transform",S);const R=y.sprite.rotation*180/Math.PI,H=document.createElement("g");H.setAttribute("transform",`translate(${y.sprite.x},${y.sprite.y}) rotate(${R}) scale(${y.sprite.scale.x},${y.sprite.scale.y})`);const N=document.createElement("image");N.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",y.canvas.toDataURL()),N.setAttribute("width",256),N.setAttribute("height",256),H.appendChild(N),Z.appendChild(H),d.appendChild(Z)}const h=this.exportColorBarSVG();return I.appendChild(h),[A,A]}}]),s}(ZT),uZe=function(g){o(s,g);var a=l(s);function s(C,I){var A;return T(this,s),A=a.call(this,C,I),A.tilesetInfo={},A.errorTextText=`Unknown track type: ${I.type}`,A}return E(s,[{key:"zoomed",value:function(){this.draw()}}]),s}(Xs),dZe=function(g){o(s,g);var a=l(s);function s(C,I){var A;return T(this,s),A=a.call(this,C,I),A.axis=new _X(u(A)),A.pBase.addChild(A.axis.pAxis),A}return E(s,[{key:"initTile",value:function(I){this.scale.minRawValue=this.minVisibleValueInTiles(),this.scale.maxRawValue=this.minVisibleValueInTiles(),this.scale.minValue=this.scale.minRawValue,this.scale.maxValue=this.scale.maxRawValue,this.drawTile(I)}},{key:"drawTile",value:function(I){if(!I.graphics)return;const A=I.graphics,d=6,h=4;A.clear(),this.valueScale=Wf().domain([this.minValue()+.01,this.maxValue()]).range([this.dimensions[1]-d/2,d/2]);const y=Mi("black");A.lineStyle(1,y,.3),A.beginFill(y,.3),this.drawAxis(this.valueScale),I.tileData.forEach(Z=>{const b=Z.fields,w=+Z.chrOffset,S=+b[1]+w,R=+b[2]+w,H=+b[3],N=this._xScale(S),D=this._xScale(R),M=Math.max(D-N,h),z=this.valueScale(H),K=(D+N)/2;A.drawRect(K-M/2,z-d/2,M,d)})}},{key:"minVisibleValueInTiles",value:function(){let I=this.visibleAndFetchedIds();return I.length===0&&(I=Object.keys(this.fetchedTiles)),Math.min.apply(null,I.map(d=>+Math.min(...this.fetchedTiles[d].tileData.filter(h=>!Number.isNaN(h.fields[3])).map(h=>+h.fields[3]))))}},{key:"maxVisibleValueInTiles",value:function(){let I=this.visibleAndFetchedIds();return I.length===0&&(I=Object.keys(this.fetchedTiles)),Math.max.apply(null,I.map(d=>+Math.max(...this.fetchedTiles[d].tileData.filter(h=>!Number.isNaN(h.fields[3])).map(h=>+h.fields[3]))))}}]),s}(Z1),hZe=function(g){o(s,g);var a=l(s);function s(C,I){var A;T(this,s),A=a.call(this,C,I);const{registerViewportChanged:d,removeViewportChanged:h,setDomainsCallback:y}=C,Z=Fn.nice();return A.uid=Z,A.options=I,A.hasFromView=!C.projectionXDomain||!C.projectionYDomain,A.removeViewportChanged=h,A.setDomainsCallback=y,A.viewportXDomain=A.hasFromView?null:C.projectionXDomain,A.viewportYDomain=A.hasFromView?null:C.projectionYDomain,A.brush=aU().on("brush",A.brushed.bind(u(A))),A.gBrush=A.gMain.append("g").attr("id",`brush-${A.uid}`).call(A.brush),A.gBrush.selectAll(".overlay").style("pointer-events","none"),A.gBrush.selectAll(".handle--n").style("pointer-events","none"),A.gBrush.selectAll(".handle--s").style("pointer-events","none"),A.gBrush.selectAll(".handle--w").style("pointer-events","none"),A.gBrush.selectAll(".handle--e").style("pointer-events","none"),d(Z,A.viewportChanged.bind(u(A))),A.rerender(),A.draw(),A}return E(s,[{key:"brushed",value:function(I){const A=I.selection;if(!this._xScale||!this._yScale)return;const d=[this._xScale.invert(A[0][0]),this._xScale.invert(A[1][0])],h=[this._yScale.invert(A[0][1]),this._yScale.invert(A[1][1])];this.hasFromView||(this.viewportXDomain=d,this.viewportYDomain=h),this.setDomainsCallback(d,h)}},{key:"viewportChanged",value:function(I,A){const d=I.domain(),h=A.domain();this.viewportXDomain=d,this.viewportYDomain=h,this.draw()}},{key:"remove",value:function(){this.removeViewportChanged(this.uid),n(G(s.prototype),"remove",this).call(this)}},{key:"rerender",value:function(){this.gBrush.selectAll(".selection").attr("fill",this.options.projectionFillColor).attr("stroke",this.options.projectionStrokeColor).attr("fill-opacity",this.options.projectionFillOpacity).attr("stroke-opacity",this.options.projectionStrokeOpacity).attr("stroke-width",this.options.strokeWidth)}},{key:"draw",value:function(){if(!this._xScale||!this.yScale||!this.viewportXDomain||!this.viewportYDomain)return;const I=this._xScale(this.viewportXDomain[0]),A=this._yScale(this.viewportYDomain[0]),d=this._xScale(this.viewportXDomain[1]),h=this._yScale(this.viewportYDomain[1]),y=[[I,A],[d,h]];this.brush.on("brush",null),this.gBrush.call(this.brush.move,y),this.brush.on("brush",this.brushed.bind(this))}},{key:"zoomed",value:function(I,A){this.xScale(I),this.yScale(A),this.draw()}},{key:"setPosition",value:function(I){n(G(s.prototype),"setPosition",this).call(this,I),this.draw()}},{key:"setDimensions",value:function(I){n(G(s.prototype),"setDimensions",this).call(this,I);const A=this._xScale.range(),d=this._yScale.range(),h=A[1]-A[0],y=d[1]-d[0];this.brush.extent([[A[0]-h,d[0]-y],[A[1]+h,d[1]+y]]),this.gBrush.call(this.brush),this.draw()}}]),s}($f),fZe=function(g){o(s,g);var a=l(s);function s(C,I){var A;T(this,s),A=a.call(this,C,I);const{registerViewportChanged:d,removeViewportChanged:h,setDomainsCallback:y}=C,Z=Fn.nice();return A.uid=Z,A.options=I,A.hasFromView=!C.projectionXDomain,A.removeViewportChanged=h,A.setDomainsCallback=y,A.viewportXDomain=A.hasFromView?null:C.projectionXDomain,A.viewportYDomain=A.hasFromView?null:[0,0],A.brush=zk().on("brush",A.brushed.bind(u(A))),A.gBrush=A.gMain.append("g").attr("id",`brush-${A.uid}`).call(A.brush),A.gBrush.selectAll(".overlay").style("pointer-events","none"),A.gBrush.selectAll(".handle--ne").style("pointer-events","none"),A.gBrush.selectAll(".handle--nw").style("pointer-events","none"),A.gBrush.selectAll(".handle--sw").style("pointer-events","none"),A.gBrush.selectAll(".handle--se").style("pointer-events","none"),A.gBrush.selectAll(".handle--n").style("pointer-events","none"),A.gBrush.selectAll(".handle--s").style("pointer-events","none"),d(Z,A.viewportChanged.bind(u(A))),A.rerender(),A.draw(),A}return E(s,[{key:"brushed",value:function(I){const A=I.selection;if(!this._xScale||!this._yScale)return;const d=[this._xScale.invert(A[0]),this._xScale.invert(A[1])],h=this.viewportYDomain;this.hasFromView||(this.viewportXDomain=d),this.setDomainsCallback(d,h)}},{key:"viewportChanged",value:function(I,A,d=!0){const h=I.domain(),y=A.domain();this.viewportXDomain=h,this.viewportYDomain=y,this.draw()}},{key:"remove",value:function(){this.removeViewportChanged(this.uid),n(G(s.prototype),"remove",this).call(this)}},{key:"rerender",value:function(){this.gBrush.selectAll(".selection").attr("fill",this.options.projectionFillColor).attr("stroke",this.options.projectionStrokeColor).attr("fill-opacity",this.options.projectionFillOpacity).attr("stroke-opacity",this.options.projectionStrokeOpacity).attr("stroke-width",this.options.strokeWidth)}},{key:"draw",value:function(){if(!this._xScale||!this.yScale||!this.viewportXDomain||!this.viewportYDomain)return;const I=this._xScale(this.viewportXDomain[0]),A=this._xScale(this.viewportXDomain[1]),d=[I,A];this.brush.on("brush",null),this.gBrush.call(this.brush.move,d),this.brush.on("brush",this.brushed.bind(this))}},{key:"zoomed",value:function(I,A){this.xScale(I),this.yScale(A),this.draw()}},{key:"setPosition",value:function(I){n(G(s.prototype),"setPosition",this).call(this,I),this.draw()}},{key:"setDimensions",value:function(I){n(G(s.prototype),"setDimensions",this).call(this,I);const A=this._xScale.range(),d=this._yScale.range(),h=A[1]-A[0];this.brush.extent([[A[0]-h,d[0]],[A[1]+h,d[1]]]),this.gBrush.call(this.brush),this.draw()}}]),s}($f),mZe=function(g){o(s,g);var a=l(s);function s(C,I){var A;T(this,s),A=a.call(this,C,I);const{registerViewportChanged:d,removeViewportChanged:h,setDomainsCallback:y}=C,Z=Fn.nice();return A.uid=Z,A.options=I,A.hasFromView=!C.projectionYDomain,A.removeViewportChanged=h,A.setDomainsCallback=y,A.viewportXDomain=A.hasFromView?null:[0,0],A.viewportYDomain=A.hasFromView?null:C.projectionYDomain,A.brush=E2().on("brush",A.brushed.bind(u(A))),A.gBrush=A.gMain.append("g").attr("id",`brush-${A.uid}`).call(A.brush),A.gBrush.selectAll(".overlay").style("pointer-events","none"),A.gBrush.selectAll(".handle--ne").style("pointer-events","none"),A.gBrush.selectAll(".handle--nw").style("pointer-events","none"),A.gBrush.selectAll(".handle--sw").style("pointer-events","none"),A.gBrush.selectAll(".handle--se").style("pointer-events","none"),A.gBrush.selectAll(".handle--e").style("pointer-events","none"),A.gBrush.selectAll(".handle--w").style("pointer-events","none"),d(Z,A.viewportChanged.bind(u(A))),A.rerender(),A.draw(),A}return E(s,[{key:"brushed",value:function(I){const A=I.selection;if(!this._xScale||!this._yScale)return;const d=this.viewportXDomain,h=[this._yScale.invert(A[0]),this._yScale.invert(A[1])];this.hasFromView||(this.viewportYDomain=h),this.setDomainsCallback(d,h)}},{key:"viewportChanged",value:function(I,A,d=!0){const h=I.domain(),y=A.domain();this.viewportXDomain=h,this.viewportYDomain=y,this.draw()}},{key:"remove",value:function(){this.removeViewportChanged(this.uid),n(G(s.prototype),"remove",this).call(this)}},{key:"rerender",value:function(){this.gBrush.selectAll(".selection").attr("fill",this.options.projectionFillColor).attr("stroke",this.options.projectionStrokeColor).attr("fill-opacity",this.options.projectionFillOpacity).attr("stroke-opacity",this.options.projectionStrokeOpacity).attr("stroke-width",this.options.strokeWidth)}},{key:"draw",value:function(){if(!this._xScale||!this.yScale||!this.viewportXDomain||!this.viewportYDomain)return;const I=this._yScale(this.viewportYDomain[0]),A=this._yScale(this.viewportYDomain[1]),d=[I,A];this.brush.on("brush",null),this.gBrush.call(this.brush.move,d),this.brush.on("brush",this.brushed.bind(this))}},{key:"zoomed",value:function(I,A){this.xScale(I),this.yScale(A),this.draw()}},{key:"setPosition",value:function(I){n(G(s.prototype),"setPosition",this).call(this,I),this.draw()}},{key:"setDimensions",value:function(I){n(G(s.prototype),"setDimensions",this).call(this,I);const A=this._xScale.range(),d=this._yScale.range(),h=d[1]-d[0];this.brush.extent([[A[0],d[0]-h],[A[1],d[1]+h]]),this.gBrush.call(this.brush),this.draw()}}]),s}($f);const I4="__mixwith_appliedMixin",l4="__mixwith_wrappedMixin",pZe=g=>g[l4]||g,mpt=(g,a)=>{const s=a(g);return s.prototype[I4]=pZe(a),s},ppt=(g,a)=>g.hasOwnProperty(I4)&&g[I4]===pZe(a),bpt=(g,a)=>{for(;g!==null;){if(ppt(g,a))return!0;g=Object.getPrototypeOf(g)}return!1},C4=(g,a)=>(Object.setPrototypeOf(a,g),g[l4]||(g[l4]=g),a),c4="__mixwith_cachedApplications",ypt=g=>C4(g,a=>{let s=a[c4];s||(a[c4]=new Map,s=a[c4]);let C=s.get(g);return C||(C=g(a),s.set(g,C)),C}),vpt=g=>C4(g,a=>bpt(a.prototype,g)?a:g(a)),Zpt=g=>C4(g,a=>mpt(a,g)),ax=g=>vpt(ypt(Zpt(g)));let Bpt=function(){function g(a){T(this,g),this.superclass=a||function(){function s(){T(this,s)}return E(s)}()}return E(g,[{key:"with",value:function(...s){return s.reduce((C,I)=>I(C),this.superclass)}}]),g}();const S1=g=>new Bpt(g),A4=ax(g=>function(a){o(C,a);var s=l(C);function C(I,A){var d;T(this,C),d=s.call(this,I,A);const{animate:h}=I;return d.highlighted=!1,d.animate=h,d.MOUSEOVER_RADIUS=4,d.pubSub=I.pubSub,d.pubSubs.push(d.pubSub.subscribe("app.mouseMove",d.mouseMoveHandler.bind(u(d)))),d}return E(C,[{key:"setPosition",value:function(A){n(G(C.prototype),"setPosition",this).call(this,A),this.pMain.position.x=this.position[0],this.pMain.position.y=this.position[1]}},{key:"zoomed",value:function(A,d){n(G(C.prototype),"zoomed",this).call(this,A,d),this.draw()}},{key:"respondsToPosition",value:function(){return this.highlighted}}]),C}(g)),Gpt=ax(g=>function(a){o(C,a);var s=l(C);function C(){return T(this,C),s.apply(this,arguments)}return E(C,[{key:"drawHorizontalRule",value:function(A){let d=Mi(this.options.color||"black");this.highlighted&&(d=Mi("red")),A.lineStyle(this.strokeWidth,d,this.strokeOpacity);let h=0;for(;hfunction(a){o(C,a);var s=l(C);function C(){return T(this,C),s.apply(this,arguments)}return E(C,[{key:"drawVerticalRule",value:function(A){let d=Mi(this.options.color||"black");this.highlighted&&(d=Mi("red")),A.lineStyle(this.strokeWidth,d,this.strokeOpacity);let h=0;for(;hthis.visibleTileIds.has(I))}},{key:"visibleAndFetchedTiles",value:function(){return this.visibleAndFetchedIds().map(I=>this.fetchedTiles[I])}},{key:"setVisibleTiles",value:function(I){this.visibleTiles=I.map(A=>({tileId:this.tileToLocalId(A),remoteId:this.tileToRemoteId(A),mirrored:A.mirrored})),this.visibleTileIds=new Set(this.visibleTiles.map(A=>A.tileId))}},{key:"removeAllTiles",value:function(){const I=new Set(Object.keys(this.fetchedTiles));this.removeTiles([...I])}},{key:"refreshTiles",value:function(){this.calculateVisibleTiles();const I=new Set(Object.keys(this.fetchedTiles)),A=[...this.visibleTiles].filter(h=>!this.fetching.has(h.remoteId)&&!I.has(h.tileId));for(let h=0;h!this.visibleTileIds.has(h));this.removeTiles(d),this.fetchNewTiles(A)}},{key:"removeTiles",value:function(I){I.length&&this.areAllVisibleTilesLoaded()&&(I.forEach(A=>{const d=A;this.destroyTile(this.fetchedTiles[d]),d in this.tileGraphics&&(this.pMain.removeChild(this.tileGraphics[d]),delete this.tileGraphics[d]),delete this.fetchedTiles[d]}),this.synchronizeTilesAndGraphics(),this.draw())}},{key:"tileToLocalId",value:function(I){return I.join(".")}},{key:"tileToRemoteId",value:function(I){return I.join(".")}},{key:"localToRemoteId",value:function(I){const A=I.split(".");return A.slice(0,A.length-1).join(".")}},{key:"calculateZoomLevel",value:function(){const I=Gi.calculateZoomLevel(this._xScale,this.minX,this.maxX),A=Gi.calculateZoomLevel(this._xScale,this.minY,this.maxY);let d=Math.min(Math.max(I,A),this.maxZoom);return this.options.maxZoom&&(this.options.maxZoom>=0?d=Math.min(this.options.maxZoom,d):console.error("Invalid maxZoom on track:",this)),d}},{key:"calculateVisibleTiles",value:function(){this.zoomLevel=this.calculateZoomLevel(),this.xTiles=Gi.calculateTiles(this.zoomLevel,this._xScale,this.minX,this.maxX,this.maxZoom,this.maxWidth),this.yTiles=Gi.calculateTiles(this.zoomLevel,this._yScale,this.minY,this.maxY,this.maxZoom,this.maxWidth);const I=this.xTiles,A=this.yTiles,d=this.zoomLevel,h=[];for(let y=0;y0){const A=[...new Set(I.map(d=>d.remoteId))];for(const d of A){const h=d.split("."),y=this.getTileUrl(h),Z=new Image;Z.crossOrigin="Anonymous",Z.src=y,Z.onload=()=>{const b={};b[d]={tileId:d,img:Z,zoomLevel:+h[0],tilePos:[+h[1],+h[2]],tileSrc:y},this.receivedTiles(b)}}}}},{key:"receivedTiles",value:function(I){for(let A=0;A{const h=A.remoteId.split("."),y={zoomLevel:h[0],tilePos:h.slice(1,h.length).map(Z=>+Z)};this.fetchedTiles[A.tileId]=A,this.fetchedTiles[A.tileId].tileData=y,this.fetching.has(A.remoteId)&&this.fetching.delete(A.remoteId)}),this.synchronizeTilesAndGraphics(),this.draw(),this.animate()}},{key:"draw",value:function(){n(G(s.prototype),"draw",this).call(this)}}]),s}(WT),GZe=function(g){o(s,g);var a=l(s);function s(C,I){var A;return T(this,s),A=a.call(this,C,I),A.style=I.style,A.options.accessToken||(A.errorTextText="No access token provided in the viewconf's track options ('accessToken' option).",A.drawError()),A}return E(s,[{key:"rerender",value:function(I){n(G(s.prototype),"rerender",this).call(this,I),I.style!==this.style&&(this.style=I.style,this.removeAllTiles(),this.refreshTiles())}},{key:"getTileUrl",value:function(I){const A=this.options&&this.options.style?this.options.style:"streets-v10",d=this.options&&+this.options.tileSize?+this.options.tileSize:256;return`https://api.mapbox.com/styles/v1/mapbox/${A}/tiles/${d}/${I[0]}/${I[1]}/${I[2]}?access_token=${this.options.accessToken}`}}]),s}(WT),SZe=function(g){o(s,g);var a=l(s);function s(C,I){var A;return T(this,s),A=a.call(this,C,I),A.style=I.style,A.options.tileSource||(A.errorTextText="No tile source string provided in the options. It should be in the form of http://a.com/{z}/{x}/{y}",A.drawError()),A}return E(s,[{key:"getTileUrl",value:function(I){let A=this.options.tileSource.replace("{z}",I[0]);return A=A.replace("{x}",I[1]),A=A.replace("{y}",I[2]),A}}]),s}(WT);const Spt=(g,a,s,C=$x)=>{const I=s[g.type];return I?new I.dataFetcher(C,g,a):g.type==="genbank"?new xye(g,a):g.type==="local-tiles"?new Dye(g,a):new wX(g,a)};var Ji=1e-6,NT=1e-12,Xn=Math.PI,io=Xn/2,sx=Xn/4,Ms=Xn*2,ng=180/Xn,$i=Xn/180,ir=Math.abs,w1=Math.atan,Fs=Math.atan2,xi=Math.cos,Ix=Math.ceil,wZe=Math.exp,u4=Math.hypot,lx=Math.log,d4=Math.pow,wi=Math.sin,uC=Math.sign||function(g){return g>0?1:g<0?-1:0},ta=Math.sqrt,h4=Math.tan;function TZe(g){return g>1?0:g<-1?Xn:Math.acos(g)}function Ys(g){return g>1?io:g<-1?-io:Math.asin(g)}function RZe(g){return(g=wi(g/2))*g}function Kg(){}function Cx(g,a){g&&EZe.hasOwnProperty(g.type)&&EZe[g.type](g,a)}var VZe={Feature:function(g,a){Cx(g.geometry,a)},FeatureCollection:function(g,a){for(var s=g.features,C=-1,I=s.length;++C=0?1:-1,I=C*s,A=xi(a),d=wi(a),h=b4*d,y=p4*A+h*xi(I),Z=h*C*wi(I);cx.add(Fs(Z,y)),m4=g,p4=A,b4=d}function Vpt(g){return Ax=new No,Ac(g,ru),Ax*2}function ux(g){return[Fs(g[1],g[0]),Ys(g[2])]}function lb(g){var a=g[0],s=g[1],C=xi(s);return[C*xi(a),C*wi(a),wi(s)]}function dx(g,a){return g[0]*a[0]+g[1]*a[1]+g[2]*a[2]}function T1(g,a){return[g[1]*a[2]-g[2]*a[1],g[2]*a[0]-g[0]*a[2],g[0]*a[1]-g[1]*a[0]]}function y4(g,a){g[0]+=a[0],g[1]+=a[1],g[2]+=a[2]}function hx(g,a){return[g[0]*a,g[1]*a,g[2]*a]}function fx(g){var a=ta(g[0]*g[0]+g[1]*g[1]+g[2]*g[2]);g[0]/=a,g[1]/=a,g[2]/=a}var _g,TI,no,Bl,Cb,XZe,xZe,R1,kT,im,th,ih={point:v4,lineStart:MZe,lineEnd:FZe,polygonStart:function(){ih.point=YZe,ih.lineStart=Ept,ih.lineEnd=Hpt,kT=new No,ru.polygonStart()},polygonEnd:function(){ru.polygonEnd(),ih.point=v4,ih.lineStart=MZe,ih.lineEnd=FZe,cx<0?(_g=-(no=180),TI=-(Bl=90)):kT>Ji?Bl=90:kT<-Ji&&(TI=-90),th[0]=_g,th[1]=no},sphere:function(){_g=-(no=180),TI=-(Bl=90)}};function v4(g,a){im.push(th=[_g=g,no=g]),aBl&&(Bl=a)}function DZe(g,a){var s=lb([g*$i,a*$i]);if(R1){var C=T1(R1,s),I=[C[1],-C[0],0],A=T1(I,C);fx(A),A=ux(A);var d=g-Cb,h=d>0?1:-1,y=A[0]*ng*h,Z,b=ir(d)>180;b^(h*CbBl&&(Bl=Z)):(y=(y+360)%360-180,b^(h*CbBl&&(Bl=a))),b?gGl(_g,no)&&(no=g):Gl(g,no)>Gl(_g,no)&&(_g=g):no>=_g?(g<_g&&(_g=g),g>no&&(no=g)):g>Cb?Gl(_g,g)>Gl(_g,no)&&(no=g):Gl(g,no)>Gl(_g,no)&&(_g=g)}else im.push(th=[_g=g,no=g]);aBl&&(Bl=a),R1=s,Cb=g}function MZe(){ih.point=DZe}function FZe(){th[0]=_g,th[1]=no,ih.point=v4,R1=null}function YZe(g,a){if(R1){var s=g-Cb;kT.add(ir(s)>180?s+(s>0?360:-360):s)}else XZe=g,xZe=a;ru.point(g,a),DZe(g,a)}function Ept(){ru.lineStart()}function Hpt(){YZe(XZe,xZe),ru.lineEnd(),ir(kT)>Ji&&(_g=-(no=180)),th[0]=_g,th[1]=no,R1=null}function Gl(g,a){return(a-=g)<0?a+360:a}function Wpt(g,a){return g[0]-a[0]}function KZe(g,a){return g[0]<=g[1]?g[0]<=a&&a<=g[1]:aGl(C[0],C[1])&&(C[1]=I[1]),Gl(I[0],C[1])>Gl(C[0],C[1])&&(C[0]=I[0])):A.push(C=I);for(d=-1/0,s=A.length-1,a=0,C=A[s];a<=s;C=I,++a)I=A[a],(h=Gl(C[1],I[0]))>d&&(d=h,_g=I[0],no=C[1])}return im=th=null,_g===1/0||TI===1/0?[[NaN,NaN],[NaN,NaN]]:[[_g,TI],[no,Bl]]}var XT,mx,px,bx,yx,vx,Zx,Bx,Z4,B4,G4,_Ze,PZe,Ks,_s,Ps,uc={sphere:Kg,point:S4,lineStart:zZe,lineEnd:OZe,polygonStart:function(){uc.lineStart=xpt,uc.lineEnd=Dpt},polygonEnd:function(){uc.lineStart=zZe,uc.lineEnd=OZe}};function S4(g,a){g*=$i,a*=$i;var s=xi(a);xT(s*xi(g),s*wi(g),wi(a))}function xT(g,a,s){++XT,px+=(g-px)/XT,bx+=(a-bx)/XT,yx+=(s-yx)/XT}function zZe(){uc.point=kpt}function kpt(g,a){g*=$i,a*=$i;var s=xi(a);Ks=s*xi(g),_s=s*wi(g),Ps=wi(a),uc.point=Xpt,xT(Ks,_s,Ps)}function Xpt(g,a){g*=$i,a*=$i;var s=xi(a),C=s*xi(g),I=s*wi(g),A=wi(a),d=Fs(ta((d=_s*A-Ps*I)*d+(d=Ps*C-Ks*A)*d+(d=Ks*I-_s*C)*d),Ks*C+_s*I+Ps*A);mx+=d,vx+=d*(Ks+(Ks=C)),Zx+=d*(_s+(_s=I)),Bx+=d*(Ps+(Ps=A)),xT(Ks,_s,Ps)}function OZe(){uc.point=S4}function xpt(){uc.point=Mpt}function Dpt(){LZe(_Ze,PZe),uc.point=S4}function Mpt(g,a){_Ze=g,PZe=a,g*=$i,a*=$i,uc.point=LZe;var s=xi(a);Ks=s*xi(g),_s=s*wi(g),Ps=wi(a),xT(Ks,_s,Ps)}function LZe(g,a){g*=$i,a*=$i;var s=xi(a),C=s*xi(g),I=s*wi(g),A=wi(a),d=_s*A-Ps*I,h=Ps*C-Ks*A,y=Ks*I-_s*C,Z=u4(d,h,y),b=Ys(Z),w=Z&&-b/Z;Z4.add(w*d),B4.add(w*h),G4.add(w*y),mx+=b,vx+=b*(Ks+(Ks=C)),Zx+=b*(_s+(_s=I)),Bx+=b*(Ps+(Ps=A)),xT(Ks,_s,Ps)}function Fpt(g){XT=mx=px=bx=yx=vx=Zx=Bx=0,Z4=new No,B4=new No,G4=new No,Ac(g,uc);var a=+Z4,s=+B4,C=+G4,I=u4(a,s,C);return IXn?g+Math.round(-g/Ms)*Ms:g,a]}T4.invert=T4;function R4(g,a,s){return(g%=Ms)?a||s?w4(UZe(g),QZe(a,s)):UZe(g):a||s?QZe(a,s):T4}function JZe(g){return function(a,s){return a+=g,[a>Xn?a-Ms:a<-Xn?a+Ms:a,s]}}function UZe(g){var a=JZe(g);return a.invert=JZe(-g),a}function QZe(g,a){var s=xi(g),C=wi(g),I=xi(a),A=wi(a);function d(h,y){var Z=xi(y),b=xi(h)*Z,w=wi(h)*Z,S=wi(y),R=S*s+b*C;return[Fs(w*I-R*A,b*s-S*C),Ys(R*I+w*A)]}return d.invert=function(h,y){var Z=xi(y),b=xi(h)*Z,w=wi(h)*Z,S=wi(y),R=S*I-w*A;return[Fs(w*I+S*A,b*s+R*C),Ys(R*s-b*C)]},d}function jZe(g){g=R4(g[0]*$i,g[1]*$i,g.length>2?g[2]*$i:0);function a(s){return s=g(s[0]*$i,s[1]*$i),s[0]*=ng,s[1]*=ng,s}return a.invert=function(s){return s=g.invert(s[0]*$i,s[1]*$i),s[0]*=ng,s[1]*=ng,s},a}function $Ze(g,a,s,C,I,A){if(s){var d=xi(a),h=wi(a),y=C*s;I==null?(I=a+C*Ms,A=a-y/2):(I=qZe(d,I),A=qZe(d,A),(C>0?IA)&&(I+=C*Ms));for(var Z,b=I;C>0?b>A:b1&&g.push(g.pop().concat(g.shift()))},result:function(){var s=g;return g=[],a=null,s}}}function Gx(g,a){return ir(g[0]-a[0])=0;--h)I.point((w=b[h])[0],w[1]);else C(S.x,S.p.x,-1,I);S=S.p}S=S.o,b=S.z,R=!R}while(!S.v);I.lineEnd()}}}function i1e(g){if(a=g.length){for(var a,s=0,C=g[0],I;++s=0?1:-1,ue=Ce*te,oe=ue>Xn,he=D*j;if(y.add(Fs(he*Ce*wi(ue),M*ie+he*xi(ue))),d+=oe?te+Ce*Ms:te,oe^H>=s^P>=s){var ye=T1(lb(R),lb(K));fx(ye);var Ie=T1(A,ye);fx(Ie);var fe=(oe^te>=0?-1:1)*Ys(Ie[2]);(C>fe||C===fe&&(ye[0]||ye[1]))&&(h+=oe^te>=0?1:-1)}}return(d<-Ji||d0){for(y||(I.polygonStart(),y=!0),I.lineStart(),j=0;j1&&P&2&&J.push(J.pop().concat(J.shift())),b.push(J.filter(Kpt))}}return S}}function Kpt(g){return g.length>1}function _pt(g,a){return((g=g.x)[0]<0?g[1]-io-Ji:io-g[1])-((a=a.x)[0]<0?a[1]-io-Ji:io-a[1])}const E4=r1e(function(){return!0},Ppt,Opt,[-Xn,-io]);function Ppt(g){var a=NaN,s=NaN,C=NaN,I;return{lineStart:function(){g.lineStart(),I=1},point:function(A,d){var h=A>0?Xn:-Xn,y=ir(A-a);ir(y-Xn)0?io:-io),g.point(C,s),g.lineEnd(),g.lineStart(),g.point(h,s),g.point(A,s),I=0):C!==h&&y>=Xn&&(ir(a-C)Ji?w1((wi(a)*(A=xi(C))*wi(s)-wi(C)*(I=xi(a))*wi(g))/(I*A*d)):(a+C)/2}function Opt(g,a,s,C){var I;if(g==null)I=s*io,C.point(-Xn,I),C.point(0,I),C.point(Xn,I),C.point(Xn,0),C.point(Xn,-I),C.point(0,-I),C.point(-Xn,-I),C.point(-Xn,0),C.point(-Xn,I);else if(ir(g[0]-a[0])>Ji){var A=g[0]0,I=ir(a)>Ji;function A(b,w,S,R){$Ze(R,g,s,S,b,w)}function d(b,w){return xi(b)*xi(w)>a}function h(b){var w,S,R,H,N;return{lineStart:function(){H=R=!1,N=1},point:function(D,M){var z=[D,M],K,P=d(D,M),J=C?P?0:Z(D,M):P?Z(D+(D<0?Xn:-Xn),M):0;if(!w&&(H=R=P)&&b.lineStart(),P!==R&&(K=y(w,z),(!K||Gx(w,K)||Gx(z,K))&&(z[2]=1)),P!==R)N=0,P?(b.lineStart(),K=y(z,w),b.point(K[0],K[1])):(K=y(w,z),b.point(K[0],K[1],2),b.lineEnd()),w=K;else if(I&&w&&C^P){var j;!(J&S)&&(j=y(z,w,!0))&&(N=0,C?(b.lineStart(),b.point(j[0][0],j[0][1]),b.point(j[1][0],j[1][1]),b.lineEnd()):(b.point(j[1][0],j[1][1]),b.lineEnd(),b.lineStart(),b.point(j[0][0],j[0][1],3)))}P&&(!w||!Gx(w,z))&&b.point(z[0],z[1]),w=z,R=P,S=J},lineEnd:function(){R&&b.lineEnd(),w=null},clean:function(){return N|(H&&R)<<1}}}function y(b,w,S){var R=lb(b),H=lb(w),N=[1,0,0],D=T1(R,H),M=dx(D,D),z=D[0],K=M-z*z;if(!K)return!S&&b;var P=a*M/K,J=-a*z/K,j=T1(N,D),ie=hx(N,P),te=hx(D,J);y4(ie,te);var Ce=j,ue=dx(ie,Ce),oe=dx(Ce,Ce),he=ue*ue-oe*(dx(ie,ie)-1);if(!(he<0)){var ye=ta(he),Ie=hx(Ce,(-ue-ye)/oe);if(y4(Ie,ie),Ie=ux(Ie),!S)return Ie;var fe=b[0],We=w[0],_e=b[1],qe=w[1],nt;We0^Ie[1]<(ir(Ie[0]-fe)Xn^(fe<=Ie[0]&&Ie[0]<=We)){var Ge=hx(Ce,(-ue+ye)/oe);return y4(Ge,ie),[Ie,ux(Ge)]}}}function Z(b,w){var S=C?g:Xn-g,R=0;return b<-S?R|=1:b>S&&(R|=2),w<-S?R|=4:w>S&&(R|=8),R}return r1e(d,h,A,C?[0,-g]:[-Xn,g-Xn])}function Lpt(g,a,s,C,I,A){var d=g[0],h=g[1],y=a[0],Z=a[1],b=0,w=1,S=y-d,R=Z-h,H;if(H=s-d,!(!S&&H>0)){if(H/=S,S<0){if(H0){if(H>w)return;H>b&&(b=H)}if(H=I-d,!(!S&&H<0)){if(H/=S,S<0){if(H>w)return;H>b&&(b=H)}else if(S>0){if(H0)){if(H/=R,R<0){if(H0){if(H>w)return;H>b&&(b=H)}if(H=A-h,!(!R&&H<0)){if(H/=R,R<0){if(H>w)return;H>b&&(b=H)}else if(R>0){if(H0&&(g[0]=d+b*S,g[1]=h+b*R),w<1&&(a[0]=d+w*S,a[1]=h+w*R),!0}}}}}var DT=1e9,wx=-DT;function Tx(g,a,s,C){function I(Z,b){return g<=Z&&Z<=s&&a<=b&&b<=C}function A(Z,b,w,S){var R=0,H=0;if(Z==null||(R=d(Z,w))!==(H=d(b,w))||y(Z,b)<0^w>0)do S.point(R===0||R===3?g:s,R>1?C:a);while((R=(R+w+4)%4)!==H);else S.point(b[0],b[1])}function d(Z,b){return ir(Z[0]-g)0?0:3:ir(Z[0]-s)0?2:1:ir(Z[1]-a)0?1:0:b>0?3:2}function h(Z,b){return y(Z.x,b.x)}function y(Z,b){var w=d(Z,1),S=d(b,1);return w!==S?w-S:w===0?b[1]-Z[1]:w===1?Z[0]-b[0]:w===2?Z[1]-b[1]:b[0]-Z[0]}return function(Z){var b=Z,w=e1e(),S,R,H,N,D,M,z,K,P,J,j,ie={point:te,lineStart:he,lineEnd:ye,polygonStart:ue,polygonEnd:oe};function te(fe,We){I(fe,We)&&b.point(fe,We)}function Ce(){for(var fe=0,We=0,_e=R.length;We<_e;++We)for(var qe=R[We],nt=1,At=qe.length,Tt=qe[0],Ne,Ge,He=Tt[0],Xe=Tt[1];ntC&&(He-Ne)*(C-Ge)>(Xe-Ge)*(g-Ne)&&++fe:Xe<=C&&(He-Ne)*(C-Ge)<(Xe-Ge)*(g-Ne)&&--fe;return fe}function ue(){b=w,S=[],R=[],j=!0}function oe(){var fe=Ce(),We=j&&fe,_e=(S=mL(S)).length;(We||_e)&&(Z.polygonStart(),We&&(Z.lineStart(),A(null,null,1,Z),Z.lineEnd()),_e&&t1e(S,h,fe,A,Z),Z.polygonEnd()),b=Z,S=R=H=null}function he(){ie.point=Ie,R&&R.push(H=[]),J=!0,P=!1,z=K=NaN}function ye(){S&&(Ie(N,D),M&&P&&w.rejoin(),S.push(w.result())),ie.point=te,P&&b.lineEnd()}function Ie(fe,We){var _e=I(fe,We);if(R&&H.push([fe,We]),J)N=fe,D=We,M=_e,J=!1,_e&&(b.lineStart(),b.point(fe,We));else if(_e&&P)b.point(fe,We);else{var qe=[z=Math.max(wx,Math.min(DT,z)),K=Math.max(wx,Math.min(DT,K))],nt=[fe=Math.max(wx,Math.min(DT,fe)),We=Math.max(wx,Math.min(DT,We))];Lpt(qe,nt,g,a,s,C)?(P||(b.lineStart(),b.point(qe[0],qe[1])),b.point(nt[0],nt[1]),_e||b.lineEnd(),j=!1):_e&&(b.lineStart(),b.point(fe,We),j=!1)}z=fe,K=We,P=_e}return ie}}function Jpt(){var g=0,a=0,s=960,C=500,I,A,d;return d={stream:function(h){return I&&A===h?I:I=Tx(g,a,s,C)(A=h)},extent:function(h){return arguments.length?(g=+h[0][0],a=+h[0][1],s=+h[1][0],C=+h[1][1],I=A=null,d):[[g,a],[s,C]]}}}var H4,W4,Rx,Vx,E1={sphere:Kg,point:Kg,lineStart:Upt,lineEnd:Kg,polygonStart:Kg,polygonEnd:Kg};function Upt(){E1.point=jpt,E1.lineEnd=Qpt}function Qpt(){E1.point=E1.lineEnd=Kg}function jpt(g,a){g*=$i,a*=$i,W4=g,Rx=wi(a),Vx=xi(a),E1.point=$pt}function $pt(g,a){g*=$i,a*=$i;var s=wi(a),C=xi(a),I=ir(g-W4),A=xi(I),d=wi(I),h=C*d,y=Vx*s-Rx*C*A,Z=Rx*s+Vx*C*A;H4.add(Fs(ta(h*h+y*y),Z)),W4=g,Rx=s,Vx=C}function o1e(g){return H4=new No,Ac(g,E1),+H4}var N4=[null,null],qpt={type:"LineString",coordinates:N4};function Ex(g,a){return N4[0]=g,N4[1]=a,o1e(qpt)}var a1e={Feature:function(g,a){return Hx(g.geometry,a)},FeatureCollection:function(g,a){for(var s=g.features,C=-1,I=s.length;++C0&&(I=Ex(g[A],g[A-1]),I>0&&s<=I&&C<=I&&(s+C-I)*(1-Math.pow((s-C)/I,2))Ji}).map(S)).concat(Ns(Ix(A/Z)*Z,I,Z).filter(function(K){return ir(K%w)>Ji}).map(R))}return M.lines=function(){return z().map(function(K){return{type:"LineString",coordinates:K}})},M.outline=function(){return{type:"Polygon",coordinates:[H(C).concat(N(d).slice(1),H(s).reverse().slice(1),N(h).reverse().slice(1))]}},M.extent=function(K){return arguments.length?M.extentMajor(K).extentMinor(K):M.extentMinor()},M.extentMajor=function(K){return arguments.length?(C=+K[0][0],s=+K[1][0],h=+K[0][1],d=+K[1][1],C>s&&(K=C,C=s,s=K),h>d&&(K=h,h=d,d=K),M.precision(D)):[[C,h],[s,d]]},M.extentMinor=function(K){return arguments.length?(a=+K[0][0],g=+K[1][0],A=+K[0][1],I=+K[1][1],a>g&&(K=a,a=g,g=K),A>I&&(K=A,A=I,I=K),M.precision(D)):[[a,A],[g,I]]},M.step=function(K){return arguments.length?M.stepMajor(K).stepMinor(K):M.stepMinor()},M.stepMajor=function(K){return arguments.length?(b=+K[0],w=+K[1],M):[b,w]},M.stepMinor=function(K){return arguments.length?(y=+K[0],Z=+K[1],M):[y,Z]},M.precision=function(K){return arguments.length?(D=+K,S=A1e(A,I,90),R=u1e(a,g,D),H=A1e(h,d,90),N=u1e(C,s,D),M):D},M.extentMajor([[-180,-90+Ji],[180,90-Ji]]).extentMinor([[-180,-80-Ji],[180,80+Ji]])}function i0t(){return d1e()()}function n0t(g,a){var s=g[0]*$i,C=g[1]*$i,I=a[0]*$i,A=a[1]*$i,d=xi(C),h=wi(C),y=xi(A),Z=wi(A),b=d*xi(s),w=d*wi(s),S=y*xi(I),R=y*wi(I),H=2*Ys(ta(RZe(A-C)+d*y*RZe(I-s))),N=wi(H),D=H?function(M){var z=wi(M*=H)/N,K=wi(H-M)/N,P=K*b+z*S,J=K*w+z*R,j=K*h+z*Z;return[Fs(J,P)*ng,Fs(j,ta(P*P+J*J))*ng]}:function(){return[s*ng,C*ng]};return D.distance=H,D}const MT=g=>g;var k4=new No,X4=new No,h1e,f1e,x4,D4,nm={point:Kg,lineStart:Kg,lineEnd:Kg,polygonStart:function(){nm.lineStart=r0t,nm.lineEnd=o0t},polygonEnd:function(){nm.lineStart=nm.lineEnd=nm.point=Kg,k4.add(ir(X4)),X4=new No},result:function(){var g=k4/2;return k4=new No,g}};function r0t(){nm.point=g0t}function g0t(g,a){nm.point=m1e,h1e=x4=g,f1e=D4=a}function m1e(g,a){X4.add(D4*g-x4*a),x4=g,D4=a}function o0t(){m1e(h1e,f1e)}const p1e=nm;var H1=1/0,Wx=H1,FT=-H1,Nx=FT,a0t={point:s0t,lineStart:Kg,lineEnd:Kg,polygonStart:Kg,polygonEnd:Kg,result:function(){var g=[[H1,Wx],[FT,Nx]];return FT=Nx=-(Wx=H1=1/0),g}};function s0t(g,a){gFT&&(FT=g),aNx&&(Nx=a)}const kx=a0t;var M4=0,F4=0,YT=0,Xx=0,xx=0,W1=0,Y4=0,K4=0,KT=0,b1e,y1e,gu,ou,dc={point:cb,lineStart:v1e,lineEnd:Z1e,polygonStart:function(){dc.lineStart=C0t,dc.lineEnd=c0t},polygonEnd:function(){dc.point=cb,dc.lineStart=v1e,dc.lineEnd=Z1e},result:function(){var g=KT?[Y4/KT,K4/KT]:W1?[Xx/W1,xx/W1]:YT?[M4/YT,F4/YT]:[NaN,NaN];return M4=F4=YT=Xx=xx=W1=Y4=K4=KT=0,g}};function cb(g,a){M4+=g,F4+=a,++YT}function v1e(){dc.point=I0t}function I0t(g,a){dc.point=l0t,cb(gu=g,ou=a)}function l0t(g,a){var s=g-gu,C=a-ou,I=ta(s*s+C*C);Xx+=I*(gu+g)/2,xx+=I*(ou+a)/2,W1+=I,cb(gu=g,ou=a)}function Z1e(){dc.point=cb}function C0t(){dc.point=A0t}function c0t(){B1e(b1e,y1e)}function A0t(g,a){dc.point=B1e,cb(b1e=gu=g,y1e=ou=a)}function B1e(g,a){var s=g-gu,C=a-ou,I=ta(s*s+C*C);Xx+=I*(gu+g)/2,xx+=I*(ou+a)/2,W1+=I,I=ou*g-gu*a,Y4+=I*(gu+g),K4+=I*(ou+a),KT+=I*3,cb(gu=g,ou=a)}const G1e=dc;function S1e(g){this._context=g}S1e.prototype={_radius:4.5,pointRadius:function(g){return this._radius=g,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(g,a){switch(this._point){case 0:{this._context.moveTo(g,a),this._point=1;break}case 1:{this._context.lineTo(g,a);break}default:{this._context.moveTo(g+this._radius,a),this._context.arc(g,a,this._radius,0,Ms);break}}},result:Kg};var _4=new No,P4,w1e,T1e,_T,PT,Dx={point:Kg,lineStart:function(){Dx.point=u0t},lineEnd:function(){P4&&R1e(w1e,T1e),Dx.point=Kg},polygonStart:function(){P4=!0},polygonEnd:function(){P4=null},result:function(){var g=+_4;return _4=new No,g}};function u0t(g,a){Dx.point=R1e,w1e=_T=g,T1e=PT=a}function R1e(g,a){_T-=g,PT-=a,_4.add(ta(_T*_T+PT*PT)),_T=g,PT=a}const V1e=Dx;function E1e(){this._string=[]}E1e.prototype={_radius:4.5,_circle:H1e(4.5),pointRadius:function(g){return(g=+g)!==this._radius&&(this._radius=g,this._circle=null),this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._string.push("Z"),this._point=NaN},point:function(g,a){switch(this._point){case 0:{this._string.push("M",g,",",a),this._point=1;break}case 1:{this._string.push("L",g,",",a);break}default:{this._circle==null&&(this._circle=H1e(this._radius)),this._string.push("M",g,",",a,this._circle);break}}},result:function(){if(this._string.length){var g=this._string.join("");return this._string=[],g}else return null}};function H1e(g){return"m0,"+g+"a"+g+","+g+" 0 1,1 0,"+-2*g+"a"+g+","+g+" 0 1,1 0,"+2*g+"z"}function d0t(g,a){var s=4.5,C,I;function A(d){return d&&(typeof s=="function"&&I.pointRadius(+s.apply(this,arguments)),Ac(d,C(I))),I.result()}return A.area=function(d){return Ac(d,C(p1e)),p1e.result()},A.measure=function(d){return Ac(d,C(V1e)),V1e.result()},A.bounds=function(d){return Ac(d,C(kx)),kx.result()},A.centroid=function(d){return Ac(d,C(G1e)),G1e.result()},A.projection=function(d){return arguments.length?(C=d==null?(g=null,MT):(g=d).stream,A):g},A.context=function(d){return arguments.length?(I=d==null?(a=null,new E1e):new S1e(a=d),typeof s!="function"&&I.pointRadius(s),A):a},A.pointRadius=function(d){return arguments.length?(s=typeof d=="function"?d:(I.pointRadius(+d),+d),A):s},A.projection(g).context(a)}function h0t(g){return{stream:zT(g)}}function zT(g){return function(a){var s=new z4;for(var C in g)s[C]=g[C];return s.stream=a,s}}function z4(){}z4.prototype={constructor:z4,point:function(g,a){this.stream.point(g,a)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function O4(g,a,s){var C=g.clipExtent&&g.clipExtent();return g.scale(150).translate([0,0]),C!=null&&g.clipExtent(null),Ac(s,g.stream(kx)),a(kx.result()),C!=null&&g.clipExtent(C),g}function Mx(g,a,s){return O4(g,function(C){var I=a[1][0]-a[0][0],A=a[1][1]-a[0][1],d=Math.min(I/(C[1][0]-C[0][0]),A/(C[1][1]-C[0][1])),h=+a[0][0]+(I-d*(C[1][0]+C[0][0]))/2,y=+a[0][1]+(A-d*(C[1][1]+C[0][1]))/2;g.scale(150*d).translate([h,y])},s)}function L4(g,a,s){return Mx(g,[[0,0],a],s)}function J4(g,a,s){return O4(g,function(C){var I=+a,A=I/(C[1][0]-C[0][0]),d=(I-A*(C[1][0]+C[0][0]))/2,h=-A*C[0][1];g.scale(150*A).translate([d,h])},s)}function U4(g,a,s){return O4(g,function(C){var I=+a,A=I/(C[1][1]-C[0][1]),d=-A*C[0][0],h=(I-A*(C[1][1]+C[0][1]))/2;g.scale(150*A).translate([d,h])},s)}var W1e=16,f0t=xi(30*$i);function N1e(g,a){return+a?p0t(g,a):m0t(g)}function m0t(g){return zT({point:function(a,s){a=g(a,s),this.stream.point(a[0],a[1])}})}function p0t(g,a){function s(C,I,A,d,h,y,Z,b,w,S,R,H,N,D){var M=Z-C,z=b-I,K=M*M+z*z;if(K>4*a&&N--){var P=d+S,J=h+R,j=y+H,ie=ta(P*P+J*J+j*j),te=Ys(j/=ie),Ce=ir(ir(j)-1)a||ir((M*ye+z*Ie)/K-.5)>.3||d*S+h*R+y*H2?fe[2]%360*$i:0,ye()):[h*ng,y*ng,Z*ng]},oe.angle=function(fe){return arguments.length?(w=fe%360*$i,ye()):w*ng},oe.reflectX=function(fe){return arguments.length?(S=fe?-1:1,ye()):S<0},oe.reflectY=function(fe){return arguments.length?(R=fe?-1:1,ye()):R<0},oe.precision=function(fe){return arguments.length?(j=N1e(ie,J=fe*fe),Ie()):ta(J)},oe.fitExtent=function(fe,We){return Mx(oe,fe,We)},oe.fitSize=function(fe,We){return L4(oe,fe,We)},oe.fitWidth=function(fe,We){return J4(oe,fe,We)},oe.fitHeight=function(fe,We){return U4(oe,fe,We)};function ye(){var fe=k1e(s,0,0,S,R,w).apply(null,a(A,d)),We=k1e(s,C-fe[0],I-fe[1],S,R,w);return b=R4(h,y,Z),ie=w4(a,We),te=w4(b,ie),j=N1e(ie,J),Ie()}function Ie(){return Ce=ue=null,oe}return function(){return a=g.apply(this,arguments),oe.invert=a.invert&&he,ye()}}function j4(g){var a=0,s=Xn/3,C=Q4(g),I=C(a,s);return I.parallels=function(A){return arguments.length?C(a=A[0]*$i,s=A[1]*$i):[a*ng,s*ng]},I}function Z0t(g){var a=xi(g);function s(C,I){return[C*a,wi(I)/a]}return s.invert=function(C,I){return[C/a,Ys(I*a)]},s}function X1e(g,a){var s=wi(g),C=(s+wi(a))/2;if(ir(C)=.12&&D<.234&&N>=-.425&&N<-.214?I:D>=.166&&D<.234&&N>=-.214&&N<-.115?d:s).invert(S)},b.stream=function(S){return g&&a===S?g:g=B0t([s.stream(a=S),I.stream(S),d.stream(S)])},b.precision=function(S){return arguments.length?(s.precision(S),I.precision(S),d.precision(S),w()):s.precision()},b.scale=function(S){return arguments.length?(s.scale(S),I.scale(S*.35),d.scale(S),b.translate(s.translate())):s.scale()},b.translate=function(S){if(!arguments.length)return s.translate();var R=s.scale(),H=+S[0],N=+S[1];return C=s.translate(S).clipExtent([[H-.455*R,N-.238*R],[H+.455*R,N+.238*R]]).stream(Z),A=I.translate([H-.307*R,N+.201*R]).clipExtent([[H-.425*R+Ji,N+.12*R+Ji],[H-.214*R-Ji,N+.234*R-Ji]]).stream(Z),h=d.translate([H-.205*R,N+.212*R]).clipExtent([[H-.214*R+Ji,N+.166*R+Ji],[H-.115*R-Ji,N+.234*R-Ji]]).stream(Z),w()},b.fitExtent=function(S,R){return Mx(b,S,R)},b.fitSize=function(S,R){return L4(b,S,R)},b.fitWidth=function(S,R){return J4(b,S,R)},b.fitHeight=function(S,R){return U4(b,S,R)};function w(){return g=a=null,b}return b.scale(1070)}function D1e(g){return function(a,s){var C=xi(a),I=xi(s),A=g(C*I);return A===1/0?[2,0]:[A*I*wi(a),A*wi(s)]}}function OT(g){return function(a,s){var C=ta(a*a+s*s),I=g(C),A=wi(I),d=xi(I);return[Fs(a*A,C*d),Ys(C&&s*A/C)]}}var $4=D1e(function(g){return ta(2/(1+g))});$4.invert=OT(function(g){return 2*Ys(g/2)});function S0t(){return au($4).scale(124.75).clipAngle(180-.001)}var q4=D1e(function(g){return(g=TZe(g))&&g/wi(g)});q4.invert=OT(function(g){return g});function w0t(){return au(q4).scale(79.4188).clipAngle(180-.001)}function LT(g,a){return[g,lx(h4((io+a)/2))]}LT.invert=function(g,a){return[g,2*w1(wZe(a))-io]};function T0t(){return M1e(LT).scale(961/Ms)}function M1e(g){var a=au(g),s=a.center,C=a.scale,I=a.translate,A=a.clipExtent,d=null,h,y,Z;a.scale=function(w){return arguments.length?(C(w),b()):C()},a.translate=function(w){return arguments.length?(I(w),b()):I()},a.center=function(w){return arguments.length?(s(w),b()):s()},a.clipExtent=function(w){return arguments.length?(w==null?d=h=y=Z=null:(d=+w[0][0],h=+w[0][1],y=+w[1][0],Z=+w[1][1]),b()):d==null?null:[[d,h],[y,Z]]};function b(){var w=Xn*C(),S=a(jZe(a.rotate()).invert([0,0]));return A(d==null?[[S[0]-w,S[1]-w],[S[0]+w,S[1]+w]]:g===LT?[[Math.max(S[0]-w,d),h],[Math.min(S[0]+w,y),Z]]:[[d,Math.max(S[1]-w,h)],[y,Math.min(S[1]+w,Z)]])}return b()}function Yx(g){return h4((io+g)/2)}function F1e(g,a){var s=xi(g),C=g===a?wi(g):lx(s/xi(a))/lx(Yx(a)/Yx(g)),I=s*d4(Yx(g),C)/C;if(!C)return LT;function A(d,h){I>0?h<-io+Ji&&(h=-io+Ji):h>io-Ji&&(h=io-Ji);var y=I/d4(Yx(h),C);return[y*wi(C*d),I-y*xi(C*d)]}return A.invert=function(d,h){var y=I-h,Z=uC(C)*ta(d*d+y*y),b=Fs(d,ir(y))*uC(y);return y*C<0&&(b-=Xn*uC(d)*uC(y)),[b/C,2*w1(d4(I/Z,1/C))-io]},A}function R0t(){return j4(F1e).scale(109.5).parallels([30,30])}function JT(g,a){return[g,a]}JT.invert=JT;function V0t(){return au(JT).scale(152.63)}function Y1e(g,a){var s=xi(g),C=g===a?wi(g):(s-xi(a))/(a-g),I=s/C+g;if(ir(C)Ji&&--C>0);return[g/(.8707+(A=s*s)*(-.131979+A*(-.013791+A*A*A*(.003971-.001529*A)))),s]};function X0t(){return au(iQ).scale(175.295)}function nQ(g,a){return[xi(a)*wi(g),wi(a)]}nQ.invert=OT(Ys);function x0t(){return au(nQ).scale(249.5).clipAngle(90+Ji)}function rQ(g,a){var s=xi(a),C=1+xi(g)*s;return[s*wi(g)/C,wi(a)/C]}rQ.invert=OT(function(g){return 2*w1(g)});function D0t(){return au(rQ).scale(250).clipAngle(142)}function gQ(g,a){return[lx(h4((io+a)/2)),-g]}gQ.invert=function(g,a){return[-a,2*w1(wZe(g))-io]};function M0t(){var g=M1e(gQ),a=g.center,s=g.rotate;return g.center=function(C){return arguments.length?a([-C[1],C[0]]):(C=a(),[C[1],-C[0]])},g.rotate=function(C){return arguments.length?s([C[0],C[1],C.length>2?C[2]+90:90]):(C=s(),[C[0],C[1],C[2]-90])},s([0,0,90]).scale(159.155)}const F0t=Object.freeze(Object.defineProperty({__proto__:null,geoArea:Vpt,geoBounds:Npt,geoCentroid:Fpt,geoCircle:Ypt,geoClipAntimeridian:E4,geoClipCircle:g1e,geoClipExtent:Jpt,geoClipRectangle:Tx,geoContains:t0t,geoDistance:Ex,geoGraticule:d1e,geoGraticule10:i0t,geoInterpolate:n0t,geoLength:o1e,geoPath:d0t,geoAlbers:x1e,geoAlbersUsa:G0t,geoAzimuthalEqualArea:S0t,geoAzimuthalEqualAreaRaw:$4,geoAzimuthalEquidistant:w0t,geoAzimuthalEquidistantRaw:q4,geoConicConformal:R0t,geoConicConformalRaw:F1e,geoConicEqualArea:Fx,geoConicEqualAreaRaw:X1e,geoConicEquidistant:E0t,geoConicEquidistantRaw:Y1e,geoEqualEarth:W0t,geoEqualEarthRaw:eQ,geoEquirectangular:V0t,geoEquirectangularRaw:JT,geoGnomonic:N0t,geoGnomonicRaw:tQ,geoIdentity:k0t,geoProjection:au,geoProjectionMutator:Q4,geoMercator:T0t,geoMercatorRaw:LT,geoNaturalEarth1:X0t,geoNaturalEarth1Raw:iQ,geoOrthographic:x0t,geoOrthographicRaw:nQ,geoStereographic:D0t,geoStereographicRaw:rQ,geoTransverseMercator:M0t,geoTransverseMercatorRaw:gQ,geoRotation:jZe,geoStream:Ac,geoTransform:h0t},Symbol.toStringTag,{value:"Module"}));var Y0t=[].slice,K0t={};function oQ(g){this._size=g,this._call=this._error=null,this._tasks=[],this._data=[],this._waiting=this._active=this._ended=this._start=0}oQ.prototype=_1e.prototype={constructor:oQ,defer:function(g){if(typeof g!="function")throw new Error("invalid callback");if(this._call)throw new Error("defer after await");if(this._error!=null)return this;var a=Y0t.call(arguments,1);return a.push(g),++this._waiting,this._tasks.push(a),K1e(this),this},abort:function(){return this._error==null&&aQ(this,new Error("abort")),this},await:function(g){if(typeof g!="function")throw new Error("invalid callback");if(this._call)throw new Error("multiple await");return this._call=function(a,s){g.apply(null,[a].concat(s))},_x(this),this},awaitAll:function(g){if(typeof g!="function")throw new Error("invalid callback");if(this._call)throw new Error("multiple await");return this._call=g,_x(this),this}};function K1e(g){if(!g._start)try{_0t(g)}catch(a){if(g._tasks[g._ended+g._active-1])aQ(g,a);else if(!g._data)throw a}}function _0t(g){for(;g._start=g._waiting&&g._active=0;)if((C=g._tasks[s])&&(g._tasks[s]=null,C.abort))try{C.abort()}catch{}g._active=NaN,_x(g)}function _x(g){if(!g._active&&g._call){var a=g._data;g._data=void 0,g._call(g._error,a)}}function _1e(g){if(g==null)g=1/0;else if(!((g=+g)>=1))throw new Error("invalid concurrency");return new oQ(g)}const z0t=Object.freeze(Object.defineProperty({__proto__:null,queue:_1e},Symbol.toStringTag,{value:"Module"}));var dC="$";function Px(){}Px.prototype=sQ.prototype={constructor:Px,has:function(g){return dC+g in this},get:function(g){return this[dC+g]},set:function(g,a){return this[dC+g]=a,this},remove:function(g){var a=dC+g;return a in this&&delete this[a]},clear:function(){for(var g in this)g[0]===dC&&delete this[g]},keys:function(){var g=[];for(var a in this)a[0]===dC&&g.push(a.slice(1));return g},values:function(){var g=[];for(var a in this)a[0]===dC&&g.push(this[a]);return g},entries:function(){var g=[];for(var a in this)a[0]===dC&&g.push({key:a.slice(1),value:this[a]});return g},size:function(){var g=0;for(var a in this)a[0]===dC&&++g;return g},empty:function(){for(var g in this)if(g[0]===dC)return!1;return!0},each:function(g){for(var a in this)a[0]===dC&&g(this[a],a.slice(1),this)}};function sQ(g,a){var s=new Px;if(g instanceof Px)g.each(function(h,y){s.set(y,h)});else if(Array.isArray(g)){var C=-1,I=g.length,A;if(a==null)for(;++C=0&&(C=s.slice(I+1),s=s.slice(0,I)),s&&!a.hasOwnProperty(s))throw new Error("unknown type: "+s);return{type:s,name:C}})}zx.prototype=z1e.prototype={constructor:zx,on:function(g,a){var s=this._,C=L0t(g+"",s),I,A=-1,d=C.length;if(arguments.length<2){for(;++A0)for(var s=new Array(I),C=0,I,A;C3&&S(R)};function S(R){var H=d.status,N;if(!H&&Q0t(d)||H>=200&&H<300||H===304){if(Z)try{N=Z.call(s,d)}catch(D){C.call("error",s,D);return}else N=d;C.call("load",s,N)}else C.call("error",s,R)}if(d.onprogress=function(R){C.call("progress",s,R)},s={header:function(R,H){return R=(R+"").toLowerCase(),arguments.length<2?A.get(R):(H==null?A.remove(R):A.set(R,H+""),s)},mimeType:function(R){return arguments.length?(I=R==null?null:R+"",s):I},responseType:function(R){return arguments.length?(b=R,s):b},timeout:function(R){return arguments.length?(w=+R,s):w},user:function(R){return arguments.length<1?h:(h=R==null?null:R+"",s)},password:function(R){return arguments.length<1?y:(y=R==null?null:R+"",s)},response:function(R){return Z=R,s},get:function(R,H){return s.send("GET",R,H)},post:function(R,H){return s.send("POST",R,H)},send:function(R,H,N){return d.open(R,g,!0,h,y),I!=null&&!A.has("accept")&&A.set("accept",I+",*/*"),d.setRequestHeader&&A.each(function(D,M){d.setRequestHeader(M,D)}),I!=null&&d.overrideMimeType&&d.overrideMimeType(I),b!=null&&(d.responseType=b),w>0&&(d.timeout=w),N==null&&typeof H=="function"&&(N=H,H=null),N!=null&&N.length===1&&(N=U0t(N)),N!=null&&s.on("error",N).on("load",function(D){N(null,D)}),C.call("beforesend",s,d),d.send(H??null),s},abort:function(){return d.abort(),s},on:function(){var R=C.on.apply(C,arguments);return R===C?s:R}},a!=null){if(typeof a!="function")throw new Error("invalid callback: "+a);return s.get(a)}return s}function U0t(g){return function(a,s){g(a==null?s:null)}}function Q0t(g){var a=g.responseType;return a&&a!=="text"?g.response:g.responseText}function Ox(g,a){return function(s,C){var I=IQ(s).mimeType(g).response(a);if(C!=null){if(typeof C!="function")throw new Error("invalid callback: "+C);return I.get(C)}return I}}const j0t=Ox("text/html",function(g){return document.createRange().createContextualFragment(g.responseText)}),$0t=Ox("application/json",function(g){return JSON.parse(g.responseText)}),q0t=Ox("text/plain",function(g){return g.responseText}),ebt=Ox("application/xml",function(g){var a=g.responseXML;if(!a)throw new Error("parse error");return a});var L1e={},lQ={},CQ=34,qT=10,cQ=13;function J1e(g){return new Function("d","return {"+g.map(function(a,s){return JSON.stringify(a)+": d["+s+'] || ""'}).join(",")+"}")}function tbt(g,a){var s=J1e(g);return function(C,I){return a(s(C),I,g)}}function U1e(g){var a=Object.create(null),s=[];return g.forEach(function(C){for(var I in C)I in a||s.push(a[I]=I)}),s}function RI(g,a){var s=g+"",C=s.length;return C9999?"+"+RI(g,6):RI(g,4)}function nbt(g){var a=g.getUTCHours(),s=g.getUTCMinutes(),C=g.getUTCSeconds(),I=g.getUTCMilliseconds();return isNaN(g)?"Invalid Date":ibt(g.getUTCFullYear())+"-"+RI(g.getUTCMonth()+1,2)+"-"+RI(g.getUTCDate(),2)+(I?"T"+RI(a,2)+":"+RI(s,2)+":"+RI(C,2)+"."+RI(I,3)+"Z":C?"T"+RI(a,2)+":"+RI(s,2)+":"+RI(C,2)+"Z":s||a?"T"+RI(a,2)+":"+RI(s,2)+"Z":"")}function Q1e(g){var a=new RegExp('["'+g+` -\r]`),s=g.charCodeAt(0);function C(w,S){var R,H,N=I(w,function(D,M){if(R)return R(D,M-1);H=D,R=S?tbt(D,S):J1e(D)});return N.columns=H||[],N}function I(w,S){var R=[],H=w.length,N=0,D=0,M,z=H<=0,K=!1;w.charCodeAt(H-1)===qT&&--H,w.charCodeAt(H-1)===cQ&&--H;function P(){if(z)return lQ;if(K)return K=!1,L1e;var j,ie=N,te;if(w.charCodeAt(ie)===CQ){for(;N++=H?z=!0:(te=w.charCodeAt(N++))===qT?K=!0:te===cQ&&(K=!0,w.charCodeAt(N)===qT&&++N),w.slice(ie+1,j-1).replace(/""/g,'"')}for(;N{this.ref=y}})}}]),s}(X.default.Component);Lx.propTypes={axis:_.exports.string,className:_.exports.string,component:_.exports.func,editable:_.exports.bool,handleConfigTrack:_.exports.func,handleResizeTrack:_.exports.func,height:_.exports.number,helperClass:_.exports.string,itemClass:_.exports.string,itemControlAlignLeft:_.exports.bool,itemReactClass:_.exports.func,items:_.exports.array,onAddSeries:_.exports.func,onCloseTrack:_.exports.func,onCloseTrackMenuOpened:_.exports.func,onConfigTrackMenuOpened:_.exports.func,onSortEnd:_.exports.func,onSortStart:_.exports.func,referenceAncestor:_.exports.string,resizeHandles:_.exports.object,useDragHandle:_.exports.bool,width:_.exports.number},Lx.defaultProps={className:"list stylizedList",itemClass:"item stylizedItem",width:400,height:600};const AQ={"top-right-handle":"_top-right-handle_cizw2_1","bottom-right-handle":"_bottom-right-handle_cizw2_2","top-left-handle":"_top-left-handle_cizw2_7","bottom-left-handle":"_bottom-left-handle_cizw2_8","top-draggable-handle":"_top-draggable-handle_cizw2_13","bottom-draggable-handle":"_bottom-draggable-handle_cizw2_14","left-draggable-handle":"_left-draggable-handle_cizw2_15","right-draggable-handle":"_right-draggable-handle_cizw2_16","draggable-div":"_draggable-div_cizw2_22","top-draggable-handle-grabber":"_top-draggable-handle-grabber_cizw2_27","bottom-draggable-handle-grabber":"_bottom-draggable-handle-grabber_cizw2_28","left-draggable-handle-grabber":"_left-draggable-handle-grabber_cizw2_43","right-draggable-handle-grabber":"_right-draggable-handle-grabber_cizw2_44"};let $1e=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.dragTopRight=_d().on("start",I.dragStart.bind(u(I))).on("drag",I.dragTopRightFunc.bind(u(I))),I.dragTopLeft=_d().on("start",I.dragStart.bind(u(I))).on("drag",I.dragTopLeftFunc.bind(u(I))),I.dragBottomRight=_d().on("start",I.dragStart.bind(u(I))).on("drag",I.dragBottomRightFunc.bind(u(I))),I.dragBottomLeft=_d().on("start",I.dragStart.bind(u(I))).on("drag",I.dragBottomLeftFunc.bind(u(I))),I.dragBottom=_d().on("start",I.dragStart.bind(u(I))).on("drag",I.dragBottomFunc.bind(u(I))),I.dragTop=_d().on("start",I.dragStart.bind(u(I))).on("drag",I.dragTopFunc.bind(u(I))),I.dragLeft=_d().on("start",I.dragStart.bind(u(I))).on("drag",I.dragLeftFunc.bind(u(I))),I.dragRight=_d().on("start",I.dragStart.bind(u(I))).on("drag",I.dragRightFunc.bind(u(I))),I.minWidth=10,I.minHeight=10,I.bottomHandleWidth=20,I.state={uid:I.props.uid,width:I.props.width,height:I.props.height,top:I.props.top,left:I.props.left},I.domBody=Mn("body").node(),I}return E(s,[{key:"componentDidMount",value:function(){Mn(this.bottomHandle).call(this.dragBottom),Mn(this.topHandle).call(this.dragTop),Mn(this.leftHandle).call(this.dragLeft),Mn(this.rightHandle).call(this.dragRight)}},{key:"UNSAFE_componentWillReceiveProps",value:function(I){"width"in I&&this.setState({width:I.width}),"height"in I&&this.setState({height:I.height})}},{key:"dragBottomFunc",value:function(I){const A=xr(I,this.domBody);let d=this.dragStartHeight+(A[1]-this.dragStartMousePos[1]);d=d>this.minHeight?d:this.minHeight,this.setState({height:d}),I.sourceEvent.stopPropagation(),this.sizeChanged()}},{key:"dragLeftFunc",value:function(I){const A=xr(I,this.domBody);let d=this.dragStartWidth-(A[0]-this.dragStartMousePos[0]);d=d>this.minWidth?d:this.minWidth;let h=this.dragStartLeft+A[0]-this.dragStartMousePos[0];h=d>this.minWidth?h:this.dragStartLeft+this.dragStartWidth-this.minWidth,this.setState({left:h,width:d}),I.sourceEvent.stopPropagation(),this.sizeChanged()}},{key:"dragTopFunc",value:function(I){const A=xr(I,this.domBody);let d=this.dragStartHeight-(A[1]-this.dragStartMousePos[1]);d=d>this.minHeight?d:this.minHeight;let h=this.dragStartTop+A[1]-this.dragStartMousePos[1];h=d>this.minHeight?h:this.dragStartTop+this.dragStartHeight-this.minHeight,this.setState({top:h,height:d}),I.sourceEvent.stopPropagation(),this.sizeChanged()}},{key:"dragRightFunc",value:function(I){const A=xr(I,this.domBody);let d=this.dragStartWidth+(A[0]-this.dragStartMousePos[0]);d=d>this.minWidth?d:this.minWidth,this.setState({width:d}),I.sourceEvent.stopPropagation(),this.sizeChanged()}},{key:"dragBottomLeftFunc",value:function(I){const A=xr(I,this.domBody);let d=this.dragStartHeight+(A[1]-this.dragStartMousePos[1]);d=d>this.minHeight?d:this.minHeight;let h=this.dragStartWidth-(A[0]-this.dragStartMousePos[0]);h=h>this.minWidth?h:this.minWidth;let y=this.dragStartLeft+A[0]-this.dragStartMousePos[0];y=h>this.minWidth?y:this.dragStartLeft+this.dragStartWidth-this.minWidth,this.setState({left:y,width:h,height:d}),I.sourceEvent.stopPropagation(),this.sizeChanged()}},{key:"dragBottomRightFunc",value:function(I){const A=xr(I,this.domBody);let d=this.dragStartWidth+(A[0]-this.dragStartMousePos[0]);d=d>this.minWidth?d:this.minWidth;let h=this.dragStartHeight+(A[1]-this.dragStartMousePos[1]);h=h>this.minHeight?h:this.minHeight,this.setState({width:d,height:h}),I.sourceEvent.stopPropagation(),this.sizeChanged()}},{key:"dragTopRightFunc",value:function(I){const A=xr(I,this.domBody);let d=this.dragStartHeight-(A[1]-this.dragStartMousePos[1]);d=d>this.minHeight?d:this.minHeight;let h=this.dragStartTop+A[1]-this.dragStartMousePos[1];h=d>this.minHeight?h:this.dragStartTop+this.dragStartHeight-this.minHeight;let y=this.dragStartWidth+(A[0]-this.dragStartMousePos[0]);y=y>this.minWidth?y:this.minWidth,this.setState({top:h,width:y,height:d}),I.sourceEvent.stopPropagation(),this.sizeChanged()}},{key:"dragTopLeftFunc",value:function(I){const A=xr(I,this.domBody);let d=this.dragStartWidth-(A[0]-this.dragStartMousePos[0]);d=d>this.minWidth?d:this.minWidth;let h=this.dragStartLeft+A[0]-this.dragStartMousePos[0];h=d>this.minWidth?h:this.dragStartLeft+this.dragStartWidth-this.minWidth;let y=this.dragStartHeight-(A[1]-this.dragStartMousePos[1]);y=y>this.minHeight?y:this.minHeight;let Z=this.dragStartTop+A[1]-this.dragStartMousePos[1];Z=y>this.minHeight?Z:this.dragStartTop+this.dragStartHeight-this.minHeight,this.setState({top:Z,left:h,width:d,height:y}),I.sourceEvent.stopPropagation(),this.sizeChanged()}},{key:"dragStart",value:function(I){this.dragStartMousePos=xr(I,this.domBody),this.dragStartWidth=this.state.width,this.dragStartHeight=this.state.height,this.dragStartTop=this.state.top,this.dragStartLeft=this.state.left,I.sourceEvent.stopPropagation()}},{key:"sizeChanged",value:function(){this.props.sizeChanged&&this.props.sizeChanged(this.state)}},{key:"rotateClicked",value:function(){this.props.trackRotated(this.state.uid)}},{key:"closeClicked",value:function(){this.props.trackClosed(this.state.uid)}},{key:"render",value:function(){const I=this.props.theme===ig?"white":"black",A={top:this.state.top,left:this.state.left,width:this.state.width,height:this.state.height,opacity:this.props.opacity},d=24,h=24,y={left:this.state.width/2-d/2,width:d},Z={top:this.state.height/2-h/2,height:h},b={bottom:{...y,bottom:1},top:{...y,top:1},left:{...Z,left:1},right:{...Z,right:1}},w=[...this.props.resizeHandles].map(S=>X.default.createElement("div",{key:S,ref:R=>{this[`${S}Handle`]=R},className:AQ[`${S}-draggable-handle`],style:b[S],title:"Resize track"},X.default.createElement("div",{className:AQ[`${S}-draggable-handle-grabber`],style:{borderColor:I}})));return X.default.createElement("div",{ref:S=>{this.divContainer=S},className:lr(this.props.className,AQ["draggable-div"]),style:A},w)}}]),s}(X.default.Component);$1e.propTypes={className:_.exports.string,height:_.exports.number,left:_.exports.number,opacity:_.exports.number,resizeHandles:_.exports.object,sizeChanged:_.exports.func,top:_.exports.number,trackClosed:_.exports.func,trackRotated:_.exports.func,uid:_.exports.string,width:_.exports.number,theme:_.exports.symbol};const cbt=L0($1e);let q1e=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.state={controlsVisible:!1},I}return E(s,[{key:"shouldComponentUpdate",value:function(){return!this.resizing}},{key:"handleMouseEnter",value:function(){this.setState({controlsVisible:!0})}},{key:"handleMouseLeave",value:function(){this.setState({controlsVisible:!1})}},{key:"handleMouseMove",value:function(){this.setState({controlsVisible:!0})}},{key:"getControls",value:function(){let I=null;return this.moveable?I=fU(()=>X.default.createElement("svg",{className:"no-zoom",height:"10px",onClick:()=>{},style:this.getMoveImgStyle(),width:"10px"},X.default.createElement("use",{xlinkHref:"#move"}))):I=fU(()=>X.default.createElement("div",null)),X.default.createElement("div",{style:{position:"absolute",backgroundColor:"rgba(255,255,255,0.7)",right:"3px",top:"3px",pointerEvents:"none",paddingLeft:"5px",paddingRight:"5px",borderRadius:"5px",border:"1px solid #dddddd"}},X.default.createElement(I,null),X.default.createElement("svg",{ref:A=>{this.imgConfig=A},className:"no-zoom",height:"10px",onClick:()=>{const d=$.default.findDOMNode(this.imgConfig).getBoundingClientRect();this.props.onConfigTrackMenuOpened(this.props.uid,d)},style:this.getSettingsImgStyle(),width:"10px"},X.default.createElement("use",{xlinkHref:"#cog"})),X.default.createElement("svg",{ref:A=>{this.imgAdd=A},className:"no-zoom",height:"10px",onClick:()=>this.props.onAddSeries(this.props.uid),style:this.getAddImgStyle(),width:"10px"},X.default.createElement("use",{xlinkHref:"#plus"})),X.default.createElement("svg",{ref:A=>{this.imgClose=A},className:"no-zoom",height:"10px",onClick:()=>{const d=$.default.findDOMNode(this.imgClose).getBoundingClientRect();this.props.onCloseTrackMenuOpened(this.props.uid,d)},style:this.getCloseImgStyle(),width:"10px"},X.default.createElement("use",{xlinkHref:"#cross"})))}}]),s}(X.default.Component);q1e.propTypes={configMenuOpen:_.exports.bool,onConfigTrackMenuOpened:_.exports.func,onCloseTrackMenuOpened:_.exports.func,onAddSeries:_.exports.func,uid:_.exports.string};let Jx=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.moveable=!0,I}return E(s,[{key:"render",value:function(){return X.default.createElement("div",{ref:I=>{this.el=I},className:this.props.className,onMouseEnter:this.handleMouseEnter.bind(this),onMouseLeave:()=>{this.handleMouseLeave()},style:{height:this.props.height,width:this.props.width}},X.default.createElement(cbt,{key:this.props.uid,height:this.props.height,resizeHandles:this.props.editable?this.props.resizeHandles:new Set,sizeChanged:I=>this.props.handleResizeTrack(this.props.uid,I.width,I.height),style:{background:"transparent"},uid:this.props.uid,width:this.props.width}),this.props.editable&&this.getControls(this.state.controlsVisible||this.props.item.configMenuVisible))}}]),s}(q1e);Jx.propTypes={className:_.exports.string,uid:_.exports.string,item:_.exports.object,height:_.exports.number,width:_.exports.number};const Ux={pointerEvents:"all"};let eBe=function(g){o(s,g);var a=l(s);function s(){return T(this,s),a.apply(this,arguments)}return E(s,[{key:"getControls",value:function(I){return X.default.createElement(dX,{configMenuVisible:this.props.item.configMenuVisible,imgStyleAdd:Ux,imgStyleClose:Ux,imgStyleMove:Ux,imgStyleSettings:Ux,isMoveable:this.moveable,isVisible:I,onAddSeries:this.props.onAddSeries,onCloseTrackMenuOpened:this.props.onCloseTrackMenuOpened,onConfigTrackMenuOpened:this.props.onConfigTrackMenuOpened,uid:this.props.uid})}}]),s}(Jx);const Abt=Fpe(g=>X.default.createElement(eBe,{className:g.className,editable:g.editable,handleConfigTrack:g.handleConfigTrack,handleResizeTrack:g.handleResizeTrack,height:g.height,item:g.item,onAddSeries:g.onAddSeries,onCloseTrack:g.onCloseTrack,onCloseTrackMenuOpened:g.onCloseTrackMenuOpened,onConfigTrackMenuOpened:g.onConfigTrackMenuOpened,resizeHandles:g.resizeHandles,uid:g.uid,width:g.width})),tBe=PCt(({className:g,items:a,itemClass:s,itemControlAlignLeft:C,sortingIndex:I,useDragHandle:A,sortableHandlers:d,height:h,width:y,onCloseTrack:Z,onCloseTrackMenuOpened:b,onConfigTrackMenuOpened:w,onAddSeries:S,handleConfigTrack:R,editable:H,itemReactClass:N,handleResizeTrack:D,resizeHandles:M})=>{const z=a.map((K,P)=>X.default.createElement(N,{key:`sci-${K.uid}`,className:s,controlAlignLeft:C,sortingIndex:I,index:P,uid:K.uid,height:K.height,width:K.width,item:K,useDragHandle:A,onCloseTrack:Z,onCloseTrackMenuOpened:b,onConfigTrackMenuOpened:w,onAddSeries:S,handleConfigTrack:R,editable:H,handleResizeTrack:D,resizeHandles:M}));return X.default.createElement("div",{className:g,style:{height:h,width:y,background:"transparent"},...d},z)}),ubt={"horizontal-tiled-plot":"_horizontal-tiled-plot_1bqkg_1"};function iBe(g){return g&&g.sourceEvent}let Qx=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.brushBehavior=zk().on("start",I.brushStarted.bind(u(I))).on("brush",I.brushed.bind(u(I))).on("end",I.brushedEnded.bind(u(I))),I}return E(s,[{key:"componentDidMount",value:function(){this.props.isRangeSelectionActive&&this.addBrush()}},{key:"shouldComponentUpdate",value:function(I,A){return this.rangeSelectionTriggered?(this.rangeSelectionTriggered=!1,this.rangeSelectionTriggeredEnd&&this.props.rangeSelection!==I.rangeSelection&&this.moveBrush(I.rangeSelection[0]?I.rangeSelection[0]:null,!0),this.rangeSelectionTriggeredEnd=!1,this.state!==A):this.props.rangeSelection!==I.rangeSelection?(this.moveBrush(I.rangeSelection[0]?I.rangeSelection[0]:null,I.rangeSelectionEnd),this.state!==A):!0}},{key:"componentDidUpdate",value:function(){this.props.isRangeSelectionActive?this.addBrush():this.removeBrush()}},{key:"addBrush",value:function(){!this.brushEl||this.brushElAddedBefore===this.brushEl||(this.brushElAddedBefore&&this.brushElAddedBefore.on(".brush",null),this.brushEl.call(this.brushBehavior),this.brushElAddedBefore=this.brushEl,jZ(this.brushEl,ac["track-range-selection-group-brush-selection"]))}},{key:"brushed",value:function(I){const A=this.rangeSelectionMoved;this.rangeSelectionMoved=!1,!(!iBe(I)||!this.props.onRangeSelection||A)&&(this.rangeSelectionTriggered=!0,this.props.onRangeSelection(I.selection))}},{key:"brushStarted",value:function(I){!iBe(I)||!I.selection||this.props.onRangeSelectionStart()}},{key:"brushedEnded",value:function(I){if(!this.props.is1dRangeSelection)return;const A=this.rangeSelectionMovedEnd;this.rangeSelectionMovedEnd=!1,I.selection&&I.sourceEvent&&this.props.onRangeSelection&&!A&&(this.rangeSelectionTriggered=!0,this.rangeSelectionTriggeredEnd=!0,this.props.onRangeSelectionEnd(I.selection)),I.selection||(this.rangeSelectionTriggered=!0,this.props.onRangeSelectionReset())}},{key:"moveBrush",value:function(I,A=!1){if(!this.brushEl)return;const d=I?[this.props.scale(I[0]),this.props.scale(I[1])]:null;this.rangeSelectionMoved=!0,this.rangeSelectionMovedEnd=!0,A?this.brushEl.transition().call(this.brushBehavior.move,d):this.brushEl.call(this.brushBehavior.move,d)}},{key:"removeBrush",value:function(){this.brushElAddedBefore&&(this.brushElAddedBefore.call(this.brushBehavior.move,null),this.brushElAddedBefore.on(".brush",null),this.brushElAddedBefore=void 0,this.props.onRangeSelectionReset())}},{key:"render",value:function(){const I=this.props.tracks.map(h=>h.height).reduce(Mf,0),A=this.props.tracks.map(h=>$2(h)).reduce(Q2,!1),d=this.props.isRangeSelectionActive?ac["track-range-selection-active"]:ac["track-range-selection"];return X.default.createElement("div",{className:lr("horizontal-tiled-plot",ubt["horizontal-tiled-plot"])},A&&X.default.createElement("svg",{ref:h=>{this.brushEl=Mn(h)},className:d,style:{height:I,width:this.props.width},xmlns:"http://www.w3.org/2000/svg"}),X.default.createElement(Lx,{className:lr(sc.list,sc.stylizedList),component:tBe,editable:this.props.editable,handleConfigTrack:this.props.handleConfigTrack,handleResizeTrack:this.props.handleResizeTrack,height:I,helperClass:sc.stylizedHelper,itemClass:sc.stylizedItem,itemReactClass:Abt,items:this.props.tracks.map(h=>({configMenuVisible:h.uid===this.props.configTrackMenuId,uid:h.uid||Fn.nice(),width:this.props.width,height:h.height,value:h.value})),onAddSeries:this.props.onAddSeries,onCloseTrack:this.props.onCloseTrack,onCloseTrackMenuOpened:this.props.onCloseTrackMenuOpened,onConfigTrackMenuOpened:this.props.onConfigTrackMenuOpened,onSortEnd:this.props.handleSortEnd,referenceAncestor:this.props.referenceAncestor,resizeHandles:this.props.resizeHandles,useDragHandle:!0,width:this.props.width}))}}]),s}(X.default.Component);Qx.propTypes={configTrackMenuId:_.exports.string,editable:_.exports.bool,handleConfigTrack:_.exports.func,handleResizeTrack:_.exports.func,handleSortEnd:_.exports.func,is1dRangeSelection:_.exports.bool,isRangeSelectionActive:_.exports.bool,onAddSeries:_.exports.func,onCloseTrack:_.exports.func,onCloseTrackMenuOpened:_.exports.func,onConfigTrackMenuOpened:_.exports.func,onRangeSelection:_.exports.func,onRangeSelectionEnd:_.exports.func,onRangeSelectionReset:_.exports.func,onRangeSelectionStart:_.exports.func,rangeSelection:_.exports.array,rangeSelectionEnd:_.exports.bool,referenceAncestor:_.exports.func,resizeHandles:_.exports.object,scale:_.exports.func,tracks:_.exports.array,width:_.exports.number};const jx={pointerEvents:"all"};let nBe=function(g){o(s,g);var a=l(s);function s(){return T(this,s),a.apply(this,arguments)}return E(s,[{key:"getControls",value:function(I){return X.default.createElement(dX,{imgStyleAdd:jx,imgStyleClose:jx,imgStyleMove:jx,imgStyleSettings:jx,isAlignLeft:this.props.controlAlignLeft,isMoveable:this.moveable,isVertical:!0,isVisible:I,onAddSeries:this.props.onAddSeries,onCloseTrackMenuOpened:this.props.onCloseTrackMenuOpened,onConfigTrackMenuOpened:this.props.onConfigTrackMenuOpened,uid:this.props.uid})}}]),s}(Jx),dbt=function(g){o(s,g);var a=l(s);function s(C,I){var A;T(this,s),A=a.call(this,C,I);const{registerViewportChanged:d,removeViewportChanged:h}=C,y=Fn.nice();return A.uid=y,A.removeViewportChanged=h,A.viewportXDomain=null,A.viewportYDomain=null,d(y,A.viewportChanged.bind(u(A))),A}return E(s,[{key:"viewportChanged",value:function(I,A){const d=I.domain(),h=A.domain();this.viewportXDomain=d,this.viewportYDomain=h,this.draw()}},{key:"draw",value:function(){const I=this.pMain;if(!this.viewportXDomain||!this.viewportYDomain)return;I.clear(),I.lineStyle(1,255,1),I.beginFill(16740363,1);const A=this._xScale(this.viewportXDomain[0]),d=this._yScale(this.viewportYDomain[0]),h=this._xScale(this.viewportXDomain[1])-this._xScale(this.viewportXDomain[0]),y=this._yScale(this.viewportYDomain[1])-this._yScale(this.viewportYDomain[0]);this.pMain.drawRect(A,d,h,y)}},{key:"zoomed",value:function(I,A){this.xScale(I),this.yScale(A),this.draw()}},{key:"setPosition",value:function(I){n(G(s.prototype),"setPosition",this).call(this,I),this.pMain.position.y=this.position[1],this.pMain.position.x=this.position[0],this.draw()}}]),s}(Xs);function rBe(g){this.size=0,this.limit=g,this._keymap={}}function hbt(g,a){const s={key:g,value:a};if(this._keymap[g]=s,this.tail?(this.tail.newer=s,s.older=this.tail):this.head=s,this.tail=s,this.size===this.limit)return this.shift();this.size+=1}function fbt(){const g=this.head;return g&&(this.head.newer?(this.head=this.head.newer,this.head.older=void 0):(this.head=void 0,this.tail=void 0),g.newer=void 0,g.older=void 0,delete this._keymap[g.key],this.size-=1),g}function mbt(g,a){const s=this._keymap[g];if(s!==void 0)return s===this.tail||(s.newer&&(s===this.head&&(this.head=s.newer),s.newer.older=s.older),s.older&&(s.older.newer=s.newer),s.newer=void 0,s.older=this.tail,this.tail&&(this.tail.newer=s),this.tail=s),a?s:s.value}function pbt(g){return this._keymap[g]}function bbt(g,a){const s=this.get(g,!0);let C;return s?(C=s.value,s.value=a):(C=this.put(g,a),C&&(C=C.value)),C}function ybt(g){const a=this._keymap[g];if(a)return delete this._keymap[a.key],a.newer&&a.older?(a.older.newer=a.newer,a.newer.older=a.older):a.newer?(a.newer.older=void 0,this.head=a.newer):a.older?(a.older.newer=void 0,this.tail=a.older):(this.head=void 0,this.tail=void 0),this.size-=1,a.value}function vbt(){this.head=void 0,this.tail=void 0,this.size=0,this._keymap={}}function Zbt(){return Object.keys(this._keymap)}function Bbt(g,a,s){let C;if(a===!0?(s=!0,a=void 0):typeof a!="object"&&(a=this),s)for(C=this.tail;C;)g.call(a,C.key,C.value,this),C=C.older;else for(C=this.head;C;)g.call(a,C.key,C.value,this),C=C.newer}function Gbt(){const g=[];let a=this.head;for(;a;)g.push({key:a.key.toJSON(),value:a.value.toJSON()}),a=a.newer;return g}function Sbt(){let g="",a=this.head;for(;a;)g+=`${String(a.key)}:${a.value}`,a=a.newer,a&&(g+=" < ");return g}Object.assign(rBe.prototype,{put:hbt,get:mbt,find:pbt,keys:Zbt,set:bbt,shift:fbt,remove:ybt,removeAll:vbt,forEach:Bbt,toJSON:Gbt,toString:Sbt});const uQ="1.12.3",wbt={d3Array:Vrt,d3Axis:Eft,d3Brush:fCt,d3Color:Prt,d3Drag:UIt,d3Dsv:Dct,d3Format:mgt,d3Geo:F0t,d3Queue:z0t,d3Request:Cbt,d3Scale:Lot,d3Selection:Dnt,d3Transition:adt,d3Zoom:udt,PIXI:$t.PIXI,mix:S1,slugid:Fn},$x={chromosomes:{ChromosomeInfo:nu,SearchField:G1},libraries:wbt,tracks:{Annotations1dTrack:s4,Annotations2dTrack:oZe,ArrowheadDomainsTrack:gZe,BarTrack:t4,BedLikeTrack:Pve,CNVIntervalTrack:jve,Chromosome2DAnnotations:lZe,Chromosome2DLabels:IZe,ChromosomeGrid:HT,CombinedTrack:kU,CrossRule:ZZe,DivergentBarTrack:Uve,HeatmapTiledPixiTrack:ZT,Horizontal1dHeatmapTrack:Qve,Horizontal2DDomainsTrack:aZe,HorizontalChromosomeLabels:cZe,HorizontalGeneAnnotationsTrack:a4,HorizontalHeatmapTrack:AZe,HorizontalLine1DPixiTrack:Z1,HorizontalMultivecTrack:Jve,HorizontalPoint1DPixiTrack:Lve,HorizontalRule:bZe,HorizontalTiled1DPixiTrack:c1,HorizontalTiledPlot:Qx,HorizontalTrack:eBe,Id2DTiledPixiTrack:zye,IdHorizontal1DTiledPixiTrack:Oye,IdVertical1DTiledPixiTrack:Jye,LeftAxisTrack:qye,MapboxTilesTrack:GZe,MoveableTrack:Jx,OSMTileIdsTrack:BZe,OSMTilesTrack:WT,OverlayTrack:Ove,PixiTrack:Xs,RasterTilesTrack:SZe,SVGTrack:$f,SquareMarkersTrack:sZe,Tiled1DPixiTrack:X7,TiledPixiTrack:Jf,TopAxisTrack:$ye,Track:t1,ValueIntervalTrack:dZe,VerticalRule:vZe,VerticalTiled1DPixiTrack:Lye,VerticalTrack:nBe,ViewportTracker2D:hZe,ViewportTracker2DPixi:dbt,ViewportTrackerHorizontal:fZe,ViewportTrackerVertical:mZe},dataFetchers:{DataFetcher:wX,GBKDataFetcher:xye,LocalDataFetcher:Dye,getDataFetcher:Spt},factories:{ContextMenuItem:Gn,DataFetcher:wX,LruCache:rBe},services:IAt,utils:YAt,configs:dct,VERSION:uQ},dQ={"track-renderer":"_track-renderer_11dwb_1","track-renderer-element":"_track-renderer-element_11dwb_5","track-renderer-events":"_track-renderer-events_11dwb_6"},{getDataFetcher:Tbt}=$x.dataFetchers,Rbt=100;let hQ=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.dragging=!1,I.element=null,I.closing=!1,I.yPositionOffset=0,I.xPositionOffset=0,I.scrollTop=0,I.scrollTimeout=null,I.activeTransitions=0,I.zoomTransform=qo,I.windowScrolledBound=I.windowScrolled.bind(u(I)),I.zoomStartedBound=I.zoomStarted.bind(u(I)),I.zoomedBound=I.zoomed.bind(u(I)),I.zoomEndedBound=I.zoomEnded.bind(u(I)),I.uid=Fn.nice(),I.viewUid=I.props.uid,I.availableForPlugins={...$x,services:{...$x.services,pubSub:I.props.pubSub,pixiRenderer:I.props.pixiRenderer}},I.mounted=!1,I.emptyZoomBehavior=a7(),I.currentProps=C,I.prevPropsStr="",I.zoomBehavior=a7().filter(A=>!(A.target.classList.contains("no-zoom")||A.target.classList.contains("react-resizable-handle"))).on("start",I.zoomStartedBound).on("zoom",I.zoomedBound).on("end",I.zoomEndedBound),I.zoomTransform=qo,I.prevZoomTransform=qo,I.initialXDomain=[0,1],I.initialYDomain=[0,1],I.xDomainLimits=[-Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],I.yDomainLimits=[-Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],I.zoomLimits=[0,Number.MAX_SAFE_INTEGER],I.prevCenterX=I.currentProps.paddingLeft+I.currentProps.leftWidth+I.currentProps.centerWidth/2,I.prevCenterY=I.currentProps.paddingTop+I.currentProps.topHeight+I.currentProps.centerHeight/2,I.cumCenterXOffset=0,I.cumCenterYOffset=0,I.setUpInitialScales(I.currentProps.initialXDomain,I.currentProps.initialYDomain,I.currentProps.xDomainLimits,I.currentProps.yDomainLimits,I.currentProps.zoomLimits),I.setUpScales(),I.trackDefObjects={},I.metaTracks={},I.pubSubs=[],window.higlassTracksByType&&Object.keys(window.higlassTracksByType).forEach(A=>{Pr[A]=window.higlassTracksByType[A].config}),I.boundForwardEvent=I.forwardEvent.bind(u(I)),I.boundScrollEvent=I.scrollEvent.bind(u(I)),I.boundForwardContextMenu=I.forwardContextMenu.bind(u(I)),I.dispatchEventBound=I.dispatchEvent.bind(u(I)),I.zoomToDataPosHandlerBound=I.zoomToDataPosHandler.bind(u(I)),I.onScrollHandlerBound=I.onScrollHandler.bind(u(I)),I}return E(s,[{key:"UNSAFE_componentWillMount",value:function(){this.pubSubs=[],this.pubSubs.push(this.props.pubSub.subscribe("scroll",this.windowScrolledBound)),this.pubSubs.push(this.props.pubSub.subscribe("app.event",this.dispatchEventBound)),this.pubSubs.push(this.props.pubSub.subscribe("zoomToDataPos",this.zoomToDataPosHandlerBound)),this.pubSubs.push(this.props.pubSub.subscribe("app.scroll",this.onScrollHandlerBound))}},{key:"componentDidMount",value:function(){if(this.elementPos=this.element.getBoundingClientRect(),this.elementSelection=Mn(this.element),this.svgTrackAreaSelection=Mn(this.svgTrackArea),this.pStage=new $t.PIXI.Graphics,this.pMask=new $t.PIXI.Graphics,this.pOutline=new $t.PIXI.Graphics,this.pBackground=new $t.PIXI.Graphics,this.pStage.addChild(this.pMask),this.pStage.addChild(this.pOutline),this.currentProps.pixiStage.addChild(this.pStage),this.pStage.mask=this.pMask,this.props.isRangeSelection||this.addZoom(),!this.currentProps.svgElement||!this.currentProps.canvasElement)return;this.svgElement=this.currentProps.svgElement,this.syncTrackObjects(this.currentProps.positionedTracks),this.syncMetaTracks(this.currentProps.metaTracks),this.currentProps.setCentersFunction(this.setCenter.bind(this)),this.currentProps.registerDraggingChangedListener(this.draggingChanged.bind(this)),this.draggingChanged(!0),this.addEventTracker();const I=[[this.xScale(this.xDomainLimits[0]),this.yScale(this.yDomainLimits[0])],[this.xScale(this.xDomainLimits[1]),this.yScale(this.yDomainLimits[1])]],A=this.svgElement.getBoundingClientRect(),d=[[Math.max(I[0][0],0),Math.max(I[0][1],0)],[Math.min(I[1][0],A.width),Math.min(I[1][1],A.height)]];this.zoomBehavior.extent(d).translateExtent(I).scaleExtent(this.zoomLimits)}},{key:"UNSAFE_componentWillReceiveProps",value:function(I){if(!I.svgElement||!I.canvasElement)return;const A=this.updatablePropsToString(I);if(this.currentProps=I,this.prevPropsStr===A)return;this.setBackground();for(const Z in this.trackDefObjects){const b=this.trackDefObjects[Z].trackObject;b.delayDrawing=!0}this.prevPropsStr=A,this.setUpInitialScales(I.initialXDomain,I.initialYDomain,I.xDomainLimits,I.yDomainLimits,I.zoomLimits),this.setUpScales(I.width!==this.props.width||I.height!==this.props.height),this.svgElement=I.svgElement;const d=[[this.xScale(this.xDomainLimits[0]),this.yScale(this.yDomainLimits[0])],[this.xScale(this.xDomainLimits[1]),this.yScale(this.yDomainLimits[1])]],h=this.svgElement.getBoundingClientRect(),y=[[Math.max(d[0][0],0),Math.max(d[0][1],0)],[Math.min(d[1][0],h.width),Math.min(d[1][1],h.height)]];this.zoomBehavior.extent(y).translateExtent(d).scaleExtent(this.zoomLimits),this.syncTrackObjects(I.positionedTracks),this.syncMetaTracks(I.metaTracks);for(const Z of I.positionedTracks){const b=Z.track.options,w=this.trackDefObjects[Z.track.uid].trackObject;if(w.rerender(b),Z.track.hasOwnProperty("contents")){const S={};for(const R of Z.track.contents)S[R.uid]=R;for(const R in w.createdTracks)w.createdTracks[R].rerender(S[R].options)}}this.props.onNewTilesLoaded();for(const Z in this.trackDefObjects){const b=this.trackDefObjects[Z].trackObject;b.delayDrawing=!1,b.draw()}}},{key:"componentDidUpdate",value:function(I){(this.props.initialXDomain[0]!==I.initialXDomain[0]||this.props.initialXDomain[1]!==I.initialXDomain[1]||this.props.initialYDomain[0]!==I.initialYDomain[0]||this.props.initialYDomain[1]!==I.initialYDomain[1])&&(this.element.__zoom=qo),I.isRangeSelection!==this.props.isRangeSelection&&(this.props.isRangeSelection?this.removeZoom():this.addZoom()),I.zoomable!==this.props.zoomable&&(this.props.zoomable?this.addZoom():this.removeZoom()),this.addEventTracker()}},{key:"componentWillUnmount",value:function(){this.mounted=!1,this.removeTracks(Object.keys(this.trackDefObjects)),this.removeMetaTracks(Object.keys(this.metaTracks)),this.currentProps.removeDraggingChangedListener(this.draggingChanged),this.currentProps.pixiStage.removeChild(this.pStage),this.pMask.destroy(!0),this.pStage.destroy(!0),this.pubSubs.forEach(I=>this.props.pubSub.unsubscribe(I)),this.pubSubs=[],this.removeEventTracker()}},{key:"dispatchEvent",value:function(I){I.sourceUid===this.uid&&I.type!=="contextmenu"&&nX(I,this.element)}},{key:"isWithin",value:function(I,A){if(!this.element)return!1;const d=I>=this.elementPos.left&&I<=this.elementPos.width+this.elementPos.left,h=A>=this.elementPos.top&&A<=this.elementPos.height+this.elementPos.top;return d&&h}},{key:"zoomToDataPosHandler",value:function({pos:I,animateTime:A,isMercator:d}){this.zoomToDataPos(...I,A,d)}},{key:"addZoom",value:function(){!this.elementSelection||!this.currentProps.zoomable||(this.elementSelection.call(this.zoomBehavior),this.zoomBehavior.transform(this.elementSelection,this.zoomTransform))}},{key:"removeZoom",value:function(){this.elementSelection&&(this.zoomEnded(),this.elementSelection.on(".zoom",null))}},{key:"setMask",value:function(){this.pMask.clear(),this.pMask.beginFill(),this.pMask.drawRect(this.xPositionOffset,this.yPositionOffset,this.currentProps.width,this.currentProps.height),this.pMask.endFill()}},{key:"setBackground",value:function(){const I=this.props.theme===ig?"black":"white",A=Mi(this.currentProps.viewOptions&&this.currentProps.viewOptions.backgroundColor||I);this.pBackground.clear(),this.pBackground.beginFill(A),this.pBackground.drawRect(this.xPositionOffset,this.yPositionOffset,this.currentProps.width,this.currentProps.height),this.pBackground.endFill()}},{key:"windowScrolled",value:function(){this.removeZoom(),this.scrollTimeout&&clearTimeout(this.scrollTimeout),this.scrollTimeout=setTimeout(()=>{this.addZoom()},Rbt)}},{key:"setUpInitialScales",value:function(I=[0,1],A=[0,1],d=[-Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],h=[-Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],y=[0,Number.MAX_SAFE_INTEGER]){y[0]=y[0]===null?0:y[0],y[1]=y[1]===null?1/0:y[1];const Z=I[1]-I[0],b=(A[0]+A[1])/2;if(A[0]=b-Z/2,A[1]=b+Z/2,I[0]===this.initialXDomain[0]&&I[1]===this.initialXDomain[1]&&A[0]===this.initialYDomain[0]&&A[1]===this.initialYDomain[1]&&d[0]===this.xDomainLimits[0]&&d[1]===this.xDomainLimits[1]&&h[0]===this.yDomainLimits[0]&&h[1]===this.yDomainLimits[1]&&y[0]===this.zoomLimits[0]&&y[1]===this.zoomLimits[1])return;this.initialXDomain=I,this.initialYDomain=A,this.xDomainLimits=d,this.yDomainLimits=h,this.zoomLimits=y,this.zoomTransform=qo,this.prevZoomTransform=qo,this.cumCenterYOffset=0,this.cumCenterXOffset=0,this.drawableToDomainX=Zn().domain([this.currentProps.paddingLeft+this.currentProps.leftWidth,this.currentProps.paddingLeft+this.currentProps.leftWidth+this.currentProps.centerWidth]).range([I[0],I[1]]);let w,S;this.currentProps.centerWidth===0?(w=this.currentProps.paddingTop+this.currentProps.topHeight,S=this.currentProps.paddingTop+this.currentProps.topHeight+this.currentProps.centerHeight):(w=this.currentProps.paddingTop+this.currentProps.topHeight+this.currentProps.centerHeight/2-this.currentProps.centerWidth/2,S=this.currentProps.paddingTop+this.currentProps.topHeight+this.currentProps.centerHeight/2+this.currentProps.centerWidth/2),this.drawableToDomainY=Zn().domain([w,S]).range([A[0],A[1]]),this.prevCenterX=this.currentProps.paddingLeft+this.currentProps.leftWidth+this.currentProps.centerWidth/2,this.prevCenterY=this.currentProps.paddingTop+this.currentProps.topHeight+this.currentProps.centerHeight/2}},{key:"updatablePropsToString",value:function(I){return JSON.stringify({positionedTracks:I.positionedTracks,initialXDomain:I.initialXDomain,initialYDomain:I.initialYDomain,width:I.width,height:I.height,paddingLeft:I.paddingLeft,paddingTop:I.paddingTop,leftWidth:I.leftWidth,topHeight:I.topHeight,dragging:I.dragging,viewOptions:I.viewOptions})}},{key:"draggingChanged",value:function(I){this.dragging=I,this.timedUpdatePositionAndDimensions()}},{key:"setUpScales",value:function(I=!1){const A=this.currentProps.paddingLeft+this.currentProps.leftWidth+this.currentProps.centerWidth/2,d=this.currentProps.paddingTop+this.currentProps.topHeight+this.currentProps.centerHeight/2,h=(this.drawableToDomainX(A)-this.drawableToDomainX(this.prevCenterX))/this.zoomTransform.k,y=(this.drawableToDomainY(d)-this.drawableToDomainY(this.prevCenterY))/this.zoomTransform.k;this.cumCenterYOffset+=y,this.cumCenterXOffset+=h,this.prevCenterY=d,this.prevCenterX=A;const Z=[this.drawableToDomainX(0)-this.cumCenterXOffset,this.drawableToDomainX(this.currentProps.width)-this.cumCenterXOffset],b=[this.drawableToDomainY(0)-this.cumCenterYOffset,this.drawableToDomainY(this.currentProps.height)-this.cumCenterYOffset];this.xScale=Zn().domain(Z).range([0,this.currentProps.width]),this.yScale=Zn().domain(b).range([0,this.currentProps.height]);for(const w in this.trackDefObjects)this.trackDefObjects[w].trackObject.refScalesChanged(this.xScale,this.yScale);this.applyZoomTransform(I)}},{key:"getTrackDef",value:function(I){const A=sC(this.trackDefObjects);for(const[,{trackDef:d,trackObject:h}]of A){if(h===I)return d.track;if(d.track.contents){for(const y of d.track.contents)if(h.createdTracks[y.uid]===I)return y}}return null}},{key:"getTrackObject",value:function(I){const A=sC(this.trackDefObjects);for(let d=0;dh.uid));this.addMetaTracks(I.filter(h=>!this.metaTracks[h.uid])),this.updateMetaTracks(I.filter(h=>this.metaTracks[h.uid])),this.removeMetaTracks(A.filter(h=>!d.has(h)))}},{key:"syncTrackObjects",value:function(I){this.prevTrackDefinitions=JSON.stringify(I);const A={};for(let w=0;w!d.has(w))),Z=new Set([...d].filter(w=>!h.has(w))),b=new Set([...h].filter(w=>d.has(w)));this.updateExistingTrackDefs([...b].map(w=>A[w])),this.addNewTracks([...y].map(w=>A[w])),this.updateExistingTrackDefs([...y].map(w=>A[w])),this.removeTracks([...Z])}},{key:"addMetaTracks",value:function(I){I.filter(A=>!this.metaTracks[A.uid]).forEach(A=>{this.metaTracks[A.uid]={trackDef:A,trackObject:this.createMetaTrack(A)}})}},{key:"addNewTracks",value:function(I){if(this.currentProps.pixiStage){for(let A=0;A{this.metaTracks[A].trackObject.remove(),this.metaTracks[A]=void 0,delete this.metaTracks[A]})}},{key:"removeTracks",value:function(I){for(let A=0;A{const K=qo.translate(N,D).scale(S);this.zoomTransform=K,this.emptyZoomBehavior.transform(this.elementSelection,K),M=this.applyZoomTransform(h)};if(y){let K=this.elementSelection;this.activeTransitions+=1,document.hidden||(K=K.transition().duration(y)),K.call(this.zoomBehavior.transform,qo.translate(N,D).scale(S)).on("end",()=>{z(),this.activeTransitions-=1})}else z();return M}},{key:"valueScaleMove",value:function(I){for(const A of this.getTracksAtPosition(...this.zoomStartPos))A.movedY(I);this.zoomTransform=this.zoomStartTransform}},{key:"valueScaleZoom",value:function(I,A){const d=I.sourceEvent.deltaY,h=I.sourceEvent.deltaMode,Z=((w,S)=>w*(S?120:1)/500)(d,h),b=xr(I.sourceEvent,this.props.canvasElement);for(const w of this.getTracksAtPosition(...b)){const S=A==="1d-horizontal"?b[1]-w.position[1]:b[0]-w.position[0];w.zoomedY(S,2**Z)}this.zoomTransform=this.zoomStartTransform}},{key:"zoomed",value:function(I){let A=null;if(this.zoomStartPos){const h=this.getTracksAtPosition(...this.zoomStartPos);if(h.length){const y=h[0],Z=this.getTrackDef(y);Pr[Z.type]&&(A=Pr[Z.type].orientation),y instanceof $ve&&(A="1d-vertical")}}if(A&&I.sourceEvent){if(I.shiftKey||this.valueScaleZooming){if(I.sourceEvent.deltaY!==void 0){this.valueScaleZoom(I,A);return}A==="1d-horizontal"?this.valueScaleMove(I.sourceEvent.movementY):A==="1d-vertical"&&this.valueScaleMove(I.sourceEvent.movementX)}A==="1d-horizontal"&&I.sourceEvent.movementY?this.valueScaleMove(I.sourceEvent.movementY):A==="1d-vertical"&&I.sourceEvent.movementX&&this.valueScaleMove(I.sourceEvent.movementX)}this.zoomTransform=this.currentProps.zoomable?I.transform:qo,this.prevZoomTransform.k!==this.zoomTransform.k||(A==="1d-horizontal"?this.zoomTransform=qo.translate(this.zoomTransform.x,this.prevZoomTransform.y).scale(this.zoomTransform.k):A==="1d-vertical"&&(this.zoomTransform=qo.translate(this.prevZoomTransform.x,this.zoomTransform.y).scale(this.zoomTransform.k)),this.element.__zoom=this.zoomTransform),this.applyZoomTransform(!0),this.prevZoomTransform=this.zoomTransform,this.props.pubSub.publish("app.zoom",I),I.sourceEvent&&(I.sourceEvent.stopPropagation(),I.sourceEvent.preventDefault())}},{key:"getTracksAtPosition",value:function(I,A){const d=[];let h=[];for(const y in this.trackDefObjects){const Z=this.trackDefObjects[y].trackObject;Z.childTracks?h=h.concat(Z.childTracks):h.push(Z)}for(const y of h){const Z=y.position[0]<=I&&I<=y.position[0]+y.dimensions[0],b=y.position[1]<=A&&A<=y.position[1]+y.dimensions[1];Z&&b&&d.push(y)}return d}},{key:"zoomStarted",value:function(I){this.zooming=!0,I&&I.sourceEvent&&(this.zoomStartPos=xr(I.sourceEvent,this.props.canvasElement),I.sourceEvent.shiftKey&&(this.valueScaleZooming=!0)),this.zoomStartTransform=this.zoomTransform,this.props.pubSub.publish("app.zoomStart")}},{key:"zoomEnded",value:function(){this.zooming=!1,this.zoomStartPos=null,this.valueScaleZooming&&(this.valueScaleZooming=!1,this.element.__zoom=this.zoomStartTransform),this.props.pubSub.publish("app.zoomEnd")}},{key:"applyZoomTransform",value:function(I=!0){const A=this.currentProps,d=A.paddingLeft+A.leftWidth,h=A.paddingTop+A.topHeight;this.zoomedXScale=this.zoomTransform.rescaleX(this.xScale),this.zoomedYScale=this.zoomTransform.rescaleY(this.yScale);const y=Zn().domain([d,d+A.centerWidth].map(this.zoomedXScale.invert)).range([0,A.centerWidth]),Z=Zn().domain([h,h+A.centerHeight].map(this.zoomedYScale.invert)).range([0,A.centerHeight]);for(const b in this.trackDefObjects){const w=this.trackDefObjects[b].trackObject,S=this.trackDefObjects[b].trackDef;let R="unknown";if(Pr[S.track.type]&&(R=Pr[S.track.type].orientation),R==="whole"){const H=Zn().domain([A.paddingLeft,A.width-A.paddingLeft].map(this.zoomedXScale.invert)).range([0,A.width-2*A.paddingLeft]),N=Zn().domain([A.paddingTop,A.height-A.paddingTop].map(this.zoomedYScale.invert)).range([0,A.height-2*A.paddingTop]);w.zoomed(H,N);continue}if(this.trackDefObjects[b].trackDef.track.position==="gallery"){const H=Zn().domain([A.paddingLeft+A.leftWidthNoGallery,A.paddingLeft+A.leftWidth+A.centerWidth+A.galleryDim].map(this.zoomedXScale.invert)).range([0,A.centerWidth+2*A.galleryDim]),N=Zn().domain([A.paddingTop+A.topHeightNoGallery,A.paddingTop+A.topHeight+A.centerHeight+A.galleryDim].map(this.zoomedYScale.invert)).range([0,A.centerHeight-2*A.galleryDim]);w.zoomed(H.copy(),N.copy(),this.zoomTransform.k);continue}w.zoomed(y.copy(),Z.copy(),this.zoomTransform.k,this.zoomTransform.x+this.xPositionOffset,this.zoomTransform.y+this.yPositionOffset,A.paddingLeft+A.leftWidth,A.paddingTop+A.topHeight)}return this.currentXScale=y,this.currentYScale=Z,I&&this.currentProps.onScalesChanged(y,Z),[y,Z]}},{key:"createMetaTrack",value:function(I){switch(I.type){default:{const A=this.props.pluginTracks[I.type];if(A&&A.isMetaTrack){const d={getTrackObject:this.getTrackObject.bind(this),onNewTilesLoaded:()=>{this.currentProps.onNewTilesLoaded(I.uid)},definition:I};try{return new A.track(this.availableForPlugins,d,I.options)}catch(h){console.error("Plugin meta track",I.type,"failed to instantiate.",h)}}return console.warn(`Unknown meta track of type: ${I.type}`),new uZe(this.pStage,{name:"Unknown Track Type",type:I.type},()=>this.currentProps.onNewTilesLoaded(I.uid))}}}},{key:"createTrackObject",value:function(I){const A=this.createLocationAgnosticTrackObject(I);return(I.position==="left"||I.position==="right")&&Pr[I.type].orientation==="1d-horizontal"?new $ve(A):A}},{key:"createLocationAgnosticTrackObject",value:function(I){const A=b=>{this.currentProps.onTilesetInfoReceived(I.uid,b)};let d=I.data;d||(d={server:IX(I.server),tilesetUid:I.tilesetUid}),I.coordSystem&&(d.coordSystem=I.coordSystem);const h=Tbt(d,this.props.pubSub,this.props.pluginDataFetchers,this.availableForPlugins),y={id:I.uid,trackUid:I.uid,trackType:I.type,viewUid:this.viewUid,pubSub:this.props.pubSub,scene:this.pStage,dataConfig:d,dataFetcher:h,getLockGroupExtrema:()=>this.currentProps.getLockGroupExtrema(I.uid),handleTilesetInfoReceived:A,animate:()=>{this.currentProps.onNewTilesLoaded(I.uid)},svgElement:this.svgElement,isValueScaleLocked:()=>this.currentProps.isValueScaleLocked(I.uid),onValueScaleChanged:()=>{this.currentProps.onValueScaleChanged(I.uid)},onTrackOptionsChanged:b=>{this.currentProps.onTrackOptionsChanged(I.uid,b)},onMouseMoveZoom:this.props.onMouseMoveZoom,chromInfoPath:I.chromInfoPath,isShowGlobalMousePosition:()=>this.props.isShowGlobalMousePosition,getTheme:()=>this.props.theme};I.y&&(y.yPosition=I.y),I.x&&(y.xPosition=I.x),I.projectionXDomain&&(y.projectionXDomain=I.projectionXDomain),I.projectionYDomain&&(y.projectionYDomain=I.projectionYDomain);const Z=I.options;switch(I.type){case"left-axis":return new qye(y,Z);case"top-axis":return new $ye(y,Z);case"heatmap":return new ZT(y,Z);case"multivec":case"vector-heatmap":case"horizontal-multivec":case"horizontal-vector-heatmap":case"vertical-multivec":case"vertical-vector-heatmap":return new Jve(y,Z);case"1d-heatmap":case"horizontal-1d-heatmap":case"vertical-1d-heatmap":return new Qve(y,Z);case"line":case"horizontal-line":case"vertical-line":return new Z1(y,Z);case"point":case"horizontal-point":case"vertical-point":return new Lve(y,Z);case"bar":case"horizontal-bar":case"vertical-bar":return new t4(y,Z);case"divergent-bar":case"horizontal-divergent-bar":case"vertical-divergent-bar":return new Uve(y,Z);case"horizontal-1d-tiles":return new Oye(y,Z);case"vertical-1d-tiles":return new Jye(y,Z);case"2d-tiles":return new zye(y,Z);case"stacked-interval":case"top-stacked-interval":case"left-stacked-interval":return new jve(y,Z);case"viewport-projection-center":return I.registerViewportChanged&&I.removeViewportChanged&&I.setDomainsCallback?(y.registerViewportChanged=I.registerViewportChanged,y.removeViewportChanged=I.removeViewportChanged,y.setDomainsCallback=I.setDomainsCallback,new hZe(y,Z)):new t1(y,Z);case"viewport-projection-horizontal":return I.registerViewportChanged&&I.removeViewportChanged&&I.setDomainsCallback?(y.registerViewportChanged=I.registerViewportChanged,y.removeViewportChanged=I.removeViewportChanged,y.setDomainsCallback=I.setDomainsCallback,new fZe(y,Z)):new t1(y,Z);case"viewport-projection-vertical":return I.registerViewportChanged&&I.removeViewportChanged&&I.setDomainsCallback?(y.registerViewportChanged=I.registerViewportChanged,y.removeViewportChanged=I.removeViewportChanged,y.setDomainsCallback=I.setDomainsCallback,new mZe(y,Z)):new t1(y,Z);case"gene-annotations":case"horizontal-gene-annotations":case"vertical-gene-annotations":return new a4(y,Z);case"2d-rectangle-domains":case"arrowhead-domains":return new gZe(y,Z);case"horizontal-1d-annotations":return new s4(y,Z);case"vertical-1d-annotations":return new s4(y,Z,!0);case"2d-annotations":return new oZe(y,Z);case"linear-2d-rectangle-domains":case"horizontal-2d-rectangle-domains":case"vertical-2d-rectangle-domains":return new aZe(y,Z);case"square-markers":return new sZe(y,Z);case"combined":return y.tracks=I.contents,y.createTrackObject=this.createTrackObject.bind(this),new kU(y,Z);case"2d-chromosome-labels":return new IZe(y,Z);case"horizontal-chromosome-grid":return y.orientation="1d-horizontal",new HT(y,Z);case"vertical-chromosome-grid":return y.orientation="1d-vertical",new HT(y,Z);case"2d-chromosome-grid":return new HT(y,Z);case"chromosome-labels":case"horizontal-chromosome-labels":case"vertical-chromosome-labels":return new cZe(y,Z);case"linear-heatmap":case"horizontal-heatmap":case"vertical-heatmap":return new AZe(y,Z);case"2d-chromosome-annotations":return new lZe(y,Z);case"1d-value-interval":case"horizontal-1d-value-interval":case"vertical-1d-value-interval":return new dZe(y,Z);case"osm":case"osm-tiles":return new WT(y,Z);case"osm-2d-tile-ids":return new BZe(y,Z);case"mapbox":case"mapbox-tiles":return new GZe(y,Z);case"raster-tiles":return new SZe(y,Z);case"bedlike":case"vertical-bedlike":return new Pve(y,Z);case"overlay-track":return new Ove(y,Z);case"overlay-chromosome-grid-track":return y.isOverlay=!0,new HT(y,Z);case"horizontal-rule":return new bZe(y,Z);case"vertical-rule":return new vZe(y,Z);case"cross-rule":return y.x=I.x,y.y=I.y,new ZZe(y,Z);case"simple-svg":return new $f(y,Z);case"empty":return new Xs(y,Z);default:{const b=this.props.pluginTracks[I.type];if(b&&!b.isMetaTrack){y.AVAILABLE_FOR_PLUGINS=this.availableForPlugins,y.baseEl=this.baseEl,y.definition=I,I.registerViewportChanged&&I.removeViewportChanged&&I.setDomainsCallback&&(y.registerViewportChanged=I.registerViewportChanged,y.removeViewportChanged=I.removeViewportChanged,y.setDomainsCallback=I.setDomainsCallback);try{return new b.track(this.availableForPlugins,y,Z)}catch(w){console.error("Plugin track",I.type,"failed to instantiate.",w)}}return console.warn("Unknown track type:",I.type),new uZe(y,{name:"Unknown Track Type",type:I.type})}}}},{key:"zoomToDataPos",value:function(I,A,d,h,y=3e3,Z=null){const[b,w,S]=Do(this.xScale.copy().domain([I,A]),this.yScale.copy().domain([d,h])),R=Z?Z(this.xScale,this.yScale):[this.xScale,this.yScale];this.setCenter(b,w,S,!1,y,R[0],R[1])}},{key:"forwardContextMenu",value:function(I){this.props.disableTrackMenu||I.altKey||(I.preventDefault(),setTimeout(()=>{this.props.pubSub.publish("contextmenu",I)},0))}},{key:"addEventTracker",value:function(){!this.eventTracker||this.eventTracker===this.eventTrackerOld||(this.eventTrackerOld||(this.eventTrackerOld=this.eventTracker),this.eventTracker=this.eventTrackerOld,this.eventTracker.addEventListener("click",this.boundForwardEvent),this.eventTracker.addEventListener("contextmenu",this.boundForwardContextMenu),this.eventTracker.addEventListener("dblclick",this.boundForwardEvent),this.eventTracker.addEventListener("wheel",this.boundForwardEvent),this.eventTracker.addEventListener("dragstart",this.boundForwardEvent),this.eventTracker.addEventListener("selectstart",this.boundForwardEvent),this.eventTracker.addEventListener("mouseover",this.boundForwardEvent),this.eventTracker.addEventListener("mouseenter",this.boundForwardEvent),this.eventTracker.addEventListener("mousedown",this.boundForwardEvent),this.eventTracker.addEventListener("mouseup",this.boundForwardEvent),this.eventTracker.addEventListener("mouseout",this.boundForwardEvent),this.eventTracker.addEventListener("mouseleave",this.boundForwardEvent),this.eventTracker.addEventListener("touchstart",this.boundForwardEvent),this.eventTracker.addEventListener("touchend",this.boundForwardEvent),this.eventTracker.addEventListener("touchmove",this.boundForwardEvent),this.eventTracker.addEventListener("touchcancel",this.boundForwardEvent),this.eventTracker.addEventListener("pointerover",this.boundForwardEvent),this.eventTracker.addEventListener("pointerenter",this.boundForwardEvent),this.eventTracker.addEventListener("pointerdown",this.boundForwardEvent),this.eventTracker.addEventListener("pointerup",this.boundForwardEvent),this.eventTracker.addEventListener("pointercancel",this.boundForwardEvent),this.eventTracker.addEventListener("pointerout",this.boundForwardEvent),this.eventTracker.addEventListener("pointerleave",this.boundForwardEvent),window.addEventListener("scroll",this.boundScrollEvent))}},{key:"removeEventTracker",value:function(){this.eventTracker&&(this.eventTracker.removeEventListener("click",this.boundForwardEvent),this.eventTracker.removeEventListener("contextmenu",this.boundForwardContextMenu),this.eventTracker.removeEventListener("dblclick",this.boundForwardEvent),this.eventTracker.removeEventListener("wheel",this.boundForwardEvent),this.eventTracker.removeEventListener("dragstart",this.boundForwardEvent),this.eventTracker.removeEventListener("selectstart",this.boundForwardEvent),this.eventTracker.removeEventListener("mouseover",this.boundForwardEvent),this.eventTracker.removeEventListener("mouseenter",this.boundForwardEvent),this.eventTracker.removeEventListener("mousedown",this.boundForwardEvent),this.eventTracker.removeEventListener("mouseup",this.boundForwardEvent),this.eventTracker.removeEventListener("mouseout",this.boundForwardEvent),this.eventTracker.removeEventListener("mouseleave",this.boundForwardEvent),this.eventTracker.removeEventListener("touchstart",this.boundForwardEvent),this.eventTracker.removeEventListener("touchend",this.boundForwardEvent),this.eventTracker.removeEventListener("touchcancel",this.boundForwardEvent),this.eventTracker.removeEventListener("pointerover",this.boundForwardEvent),this.eventTracker.removeEventListener("pointerenter",this.boundForwardEvent),this.eventTracker.removeEventListener("pointerdown",this.boundForwardEvent),this.eventTracker.removeEventListener("pointerup",this.boundForwardEvent),this.eventTracker.removeEventListener("pointercancel",this.boundForwardEvent),this.eventTracker.removeEventListener("pointerout",this.boundForwardEvent),this.eventTracker.removeEventListener("pointerleave",this.boundForwardEvent),window.removeEventListener("scroll",this.boundScrollEvent))}},{key:"scrollEvent",value:function(){this.elementPos=this.element.getBoundingClientRect()}},{key:"forwardEvent",value:function(I){I.sourceUid=this.uid,I.forwarded=!0,this.props.pubSub.publish("app.event",I)}},{key:"onScrollHandler",value:function(I){this.scrollTop=I}},{key:"render",value:function(){return X.default.createElement("div",{ref:I=>{this.baseEl=I},className:lr("track-renderer-div",dQ["track-renderer"]),style:{height:this.currentProps.height,width:this.currentProps.width}},X.default.createElement("div",{ref:I=>{this.element=I},className:lr("track-renderer-element",dQ["track-renderer-element"])}),X.default.createElement("div",{ref:I=>{this.eventTracker=I},className:lr("track-renderer-events",dQ["track-renderer-events"])},this.currentProps.children))}}]),s}(X.default.Component);hQ.defaultProps={pluginDataFetchers:{},pluginTracks:{},canvasElement:null,centerHeight:0,centerWidth:0,children:[],galleryDim:0,height:0,initialXDomain:[],initialYDomain:[],isShowGlobalMousePosition:!1,isRangeSelection:!1,leftWidth:0,leftWidthNoGallery:0,paddingLeft:0,paddingTop:0,positionedTracks:[],topHeight:0,topHeightNoGallery:0,width:0,metaTracks:[]},hQ.propTypes={canvasElement:_.exports.object,centerHeight:_.exports.number,centerWidth:_.exports.number,children:_.exports.array,disableTrackMenu:_.exports.bool,galleryDim:_.exports.number,height:_.exports.number,initialXDomain:_.exports.array,initialYDomain:_.exports.array,isShowGlobalMousePosition:_.exports.bool,isRangeSelection:_.exports.bool,leftWidth:_.exports.number,leftWidthNoGallery:_.exports.number,paddingLeft:_.exports.number,paddingTop:_.exports.number,metaTracks:_.exports.array,onMouseMoveZoom:_.exports.func,onNewTilesLoaded:_.exports.func.isRequired,onScalesChanged:_.exports.func.isRequired,pixiRenderer:_.exports.object.isRequired,pixiStage:_.exports.object.isRequired,pluginDataFetchers:_.exports.object,pluginTracks:_.exports.object,positionedTracks:_.exports.array,pubSub:_.exports.object.isRequired,setCentersFunction:_.exports.func,svgElement:_.exports.object.isRequired,theme:_.exports.symbol.isRequired,topHeight:_.exports.number,topHeightNoGallery:_.exports.number,viewOptions:_.exports.object,width:_.exports.number,xDomainLimits:_.exports.array,yDomainLimits:_.exports.array,valueScaleZoom:_.exports.bool,zoomable:_.exports.bool.isRequired,zoomDomain:_.exports.array};const Vbt=qZ(L0(hQ)),fQ={button:"_button_1wnjn_1","button-shortcut":"_button-shortcut_1wnjn_35"},nh=X.default.forwardRef((g,a)=>{var s;return X.default.createElement("button",{ref:a,className:(s=fQ[g.styleName])!=null?s:fQ.button,disabled:g.disable,onBlur:g.onBlur,onClick:g.onClick,onMouseDown:g.onMouseDown,onMouseOut:g.onMouseOut,onMouseUp:g.onMouseUp,type:"button"},g.children,g.shortcut&&X.default.createElement("span",{className:fQ["button-shortcut"]},g.shortcut))});nh.defaultProps={onClick:()=>{},styleName:"",type:"button"},nh.propTypes={children:_.exports.any,disable:_.exports.bool,onBlur:_.exports.func,onClick:_.exports.func,onMouseDown:_.exports.func,onMouseOut:_.exports.func,onMouseUp:_.exports.func,shortcut:_.exports.string,type:_.exports.string,styleName:_.exports.string};const Ebt={cross:"_cross_2ke8w_1"};function gBe(){return X.default.createElement("div",{className:Ebt.cross})}const{Provider:Hbt,Consumer:Wbt}=X.default.createContext({close:OA,open:OA}),qx=g=>X.default.forwardRef((a,s)=>X.default.createElement(Wbt,null,C=>X.default.createElement(g,{ref:s,...a,modal:C}))),N1={"modal-background":"_modal-background_zzhoe_1","fade-in":"_fade-in_zzhoe_1","modal-hide":"_modal-hide_zzhoe_13","modal-wrap":"_modal-wrap_zzhoe_17","modal-window":"_modal-window_zzhoe_25","fade-scale-in":"_fade-scale-in_zzhoe_1","modal-window-max-height":"_modal-window-max-height_zzhoe_38","modal-content":"_modal-content_zzhoe_42"};function mQ(g){const a=()=>{g.modal.close(),g.onClose&&g.onClose()};return X.default.createElement("div",{className:lr(N1["modal-background"],{[N1["modal-hide"]]:g.hide})},X.default.createElement("div",{className:N1["modal-wrap"]},X.default.createElement("div",{className:lr(N1["modal-window"],{[N1["modal-window-max-height"]]:g.maxHeight})},g.closeButton&&X.default.createElement(nh,{onClick:a},X.default.createElement(gBe,null)),X.default.createElement("div",{className:N1["modal-content"]},g.children))))}mQ.defaultProps={closeButton:!0,hide:!1,maxHeight:!1},mQ.propTypes={children:_.exports.element.isRequired,closeButton:_.exports.bool,hide:_.exports.bool,maxHeight:_.exports.bool,modal:_.exports.object.isRequired,onClose:_.exports.func};const Nbt=qx(mQ),pQ={"dialog-header":"_dialog-header_wp50s_1","dialog-main-max-height":"_dialog-main-max-height_wp50s_20","dialog-footer":"_dialog-footer_wp50s_31","dialog-footer-max-height":"_dialog-footer-max-height_wp50s_31"};function bQ(g){const a=()=>{g.modal.close(),g.onCancel&&g.onCancel()},s=()=>{g.modal.close(),g.onOkay&&g.onOkay()};return X.default.createElement(Nbt,{closeButton:!1,hide:g.hide,maxHeight:g.maxHeight},X.default.createElement(X.default.Fragment,null,X.default.createElement("header",{className:pQ["dialog-header"]},X.default.createElement("h3",null,g.title),X.default.createElement(nh,{onClick:a},X.default.createElement(gBe,null))),g.maxHeight?X.default.createElement("main",{className:lr(g.maxHeight&&pQ["dialog-main-max-height"])},g.children):X.default.createElement("main",null,g.children),X.default.createElement("footer",{className:pQ[g.maxHeight?"dialog-footer-max-height":"dialog-footer"]},g.okayOnly?X.default.createElement("div",null):X.default.createElement(nh,{onClick:a,shortcut:g.cancelShortcut},g.cancelTitle),X.default.createElement(nh,{onClick:s,shortcut:g.okayShortcut},g.okayTitle))))}bQ.defaultProps={cancelTitle:"Cancel",hide:!1,maxHeight:!1,okayOnly:!1,okayTitle:"Ok"},bQ.propTypes={cancelShortcut:_.exports.string,cancelTitle:_.exports.string,children:_.exports.object,hide:_.exports.bool,maxHeight:_.exports.bool,modal:_.exports.object.isRequired,okayShortcut:_.exports.string,okayTitle:_.exports.string,okayOnly:_.exports.bool,onCancel:_.exports.func.isRequired,onOkay:_.exports.func.isRequired,title:_.exports.string.isRequired};const eR=qx(bQ);var oBe={exports:{}};/*! react-checkbox-tree - v1.8.0 | 2022 */(function(g,a){/*! For license information please see index.browser.js.LICENSE.txt */(function(s,C){g.exports=C(X.default)})(self,s=>(()=>{var C={4184:(h,y)=>{var Z;(function(){var b={}.hasOwnProperty;function w(){for(var S=[],R=0;R{var b=Z(852)(Z(5639),"DataView");h.exports=b},1989:(h,y,Z)=>{var b=Z(1789),w=Z(401),S=Z(7667),R=Z(1327),H=Z(1866);function N(D){var M=-1,z=D==null?0:D.length;for(this.clear();++M{var b=Z(7040),w=Z(4125),S=Z(2117),R=Z(7518),H=Z(4705);function N(D){var M=-1,z=D==null?0:D.length;for(this.clear();++M{var b=Z(852)(Z(5639),"Map");h.exports=b},3369:(h,y,Z)=>{var b=Z(4785),w=Z(1285),S=Z(6e3),R=Z(9916),H=Z(5265);function N(D){var M=-1,z=D==null?0:D.length;for(this.clear();++M{var b=Z(852)(Z(5639),"Promise");h.exports=b},8525:(h,y,Z)=>{var b=Z(852)(Z(5639),"Set");h.exports=b},8668:(h,y,Z)=>{var b=Z(3369),w=Z(619),S=Z(2385);function R(H){var N=-1,D=H==null?0:H.length;for(this.__data__=new b;++N{var b=Z(8407),w=Z(7465),S=Z(3779),R=Z(7599),H=Z(4758),N=Z(4309);function D(M){var z=this.__data__=new b(M);this.size=z.size}D.prototype.clear=w,D.prototype.delete=S,D.prototype.get=R,D.prototype.has=H,D.prototype.set=N,h.exports=D},2705:(h,y,Z)=>{var b=Z(5639).Symbol;h.exports=b},1149:(h,y,Z)=>{var b=Z(5639).Uint8Array;h.exports=b},577:(h,y,Z)=>{var b=Z(852)(Z(5639),"WeakMap");h.exports=b},4963:h=>{h.exports=function(y,Z){for(var b=-1,w=y==null?0:y.length,S=0,R=[];++b{var b=Z(2545),w=Z(5694),S=Z(1469),R=Z(4144),H=Z(5776),N=Z(6719),D=Object.prototype.hasOwnProperty;h.exports=function(M,z){var K=S(M),P=!K&&w(M),J=!K&&!P&&R(M),j=!K&&!P&&!J&&N(M),ie=K||P||J||j,te=ie?b(M.length,String):[],Ce=te.length;for(var ue in M)!z&&!D.call(M,ue)||ie&&(ue=="length"||J&&(ue=="offset"||ue=="parent")||j&&(ue=="buffer"||ue=="byteLength"||ue=="byteOffset")||H(ue,Ce))||te.push(ue);return te}},2488:h=>{h.exports=function(y,Z){for(var b=-1,w=Z.length,S=y.length;++b{h.exports=function(y,Z){for(var b=-1,w=y==null?0:y.length;++b{var b=Z(7813);h.exports=function(w,S){for(var R=w.length;R--;)if(b(w[R][0],S))return R;return-1}},8866:(h,y,Z)=>{var b=Z(2488),w=Z(1469);h.exports=function(S,R,H){var N=R(S);return w(S)?N:b(N,H(S))}},4239:(h,y,Z)=>{var b=Z(2705),w=Z(9607),S=Z(2333),R=b?b.toStringTag:void 0;h.exports=function(H){return H==null?H===void 0?"[object Undefined]":"[object Null]":R&&R in Object(H)?w(H):S(H)}},9454:(h,y,Z)=>{var b=Z(4239),w=Z(7005);h.exports=function(S){return w(S)&&b(S)=="[object Arguments]"}},939:(h,y,Z)=>{var b=Z(2492),w=Z(7005);h.exports=function S(R,H,N,D,M){return R===H||(R==null||H==null||!w(R)&&!w(H)?R!=R&&H!=H:b(R,H,N,D,S,M))}},2492:(h,y,Z)=>{var b=Z(6384),w=Z(7114),S=Z(8351),R=Z(6096),H=Z(4160),N=Z(1469),D=Z(4144),M=Z(6719),z="[object Arguments]",K="[object Array]",P="[object Object]",J=Object.prototype.hasOwnProperty;h.exports=function(j,ie,te,Ce,ue,oe){var he=N(j),ye=N(ie),Ie=he?K:H(j),fe=ye?K:H(ie),We=(Ie=Ie==z?P:Ie)==P,_e=(fe=fe==z?P:fe)==P,qe=Ie==fe;if(qe&&D(j)){if(!D(ie))return!1;he=!0,We=!1}if(qe&&!We)return oe||(oe=new b),he||M(j)?w(j,ie,te,Ce,ue,oe):S(j,ie,Ie,te,Ce,ue,oe);if(!(1&te)){var nt=We&&J.call(j,"__wrapped__"),At=_e&&J.call(ie,"__wrapped__");if(nt||At){var Tt=nt?j.value():j,Ne=At?ie.value():ie;return oe||(oe=new b),ue(Tt,Ne,te,Ce,oe)}}return!!qe&&(oe||(oe=new b),R(j,ie,te,Ce,ue,oe))}},8458:(h,y,Z)=>{var b=Z(3560),w=Z(5346),S=Z(3218),R=Z(346),H=/^\[object .+?Constructor\]$/,N=Function.prototype,D=Object.prototype,M=N.toString,z=D.hasOwnProperty,K=RegExp("^"+M.call(z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");h.exports=function(P){return!(!S(P)||w(P))&&(b(P)?K:H).test(R(P))}},8749:(h,y,Z)=>{var b=Z(4239),w=Z(1780),S=Z(7005),R={};R["[object Float32Array]"]=R["[object Float64Array]"]=R["[object Int8Array]"]=R["[object Int16Array]"]=R["[object Int32Array]"]=R["[object Uint8Array]"]=R["[object Uint8ClampedArray]"]=R["[object Uint16Array]"]=R["[object Uint32Array]"]=!0,R["[object Arguments]"]=R["[object Array]"]=R["[object ArrayBuffer]"]=R["[object Boolean]"]=R["[object DataView]"]=R["[object Date]"]=R["[object Error]"]=R["[object Function]"]=R["[object Map]"]=R["[object Number]"]=R["[object Object]"]=R["[object RegExp]"]=R["[object Set]"]=R["[object String]"]=R["[object WeakMap]"]=!1,h.exports=function(H){return S(H)&&w(H.length)&&!!R[b(H)]}},280:(h,y,Z)=>{var b=Z(5726),w=Z(6916),S=Object.prototype.hasOwnProperty;h.exports=function(R){if(!b(R))return w(R);var H=[];for(var N in Object(R))S.call(R,N)&&N!="constructor"&&H.push(N);return H}},2545:h=>{h.exports=function(y,Z){for(var b=-1,w=Array(y);++b{h.exports=function(y){return function(Z){return y(Z)}}},4757:h=>{h.exports=function(y,Z){return y.has(Z)}},4429:(h,y,Z)=>{var b=Z(5639)["__core-js_shared__"];h.exports=b},7114:(h,y,Z)=>{var b=Z(8668),w=Z(2908),S=Z(4757);h.exports=function(R,H,N,D,M,z){var K=1&N,P=R.length,J=H.length;if(P!=J&&!(K&&J>P))return!1;var j=z.get(R),ie=z.get(H);if(j&&ie)return j==H&&ie==R;var te=-1,Ce=!0,ue=2&N?new b:void 0;for(z.set(R,H),z.set(H,R);++te{var b=Z(2705),w=Z(1149),S=Z(7813),R=Z(7114),H=Z(8776),N=Z(1814),D=b?b.prototype:void 0,M=D?D.valueOf:void 0;h.exports=function(z,K,P,J,j,ie,te){switch(P){case"[object DataView]":if(z.byteLength!=K.byteLength||z.byteOffset!=K.byteOffset)return!1;z=z.buffer,K=K.buffer;case"[object ArrayBuffer]":return!(z.byteLength!=K.byteLength||!ie(new w(z),new w(K)));case"[object Boolean]":case"[object Date]":case"[object Number]":return S(+z,+K);case"[object Error]":return z.name==K.name&&z.message==K.message;case"[object RegExp]":case"[object String]":return z==K+"";case"[object Map]":var Ce=H;case"[object Set]":var ue=1&J;if(Ce||(Ce=N),z.size!=K.size&&!ue)return!1;var oe=te.get(z);if(oe)return oe==K;J|=2,te.set(z,K);var he=R(Ce(z),Ce(K),J,j,ie,te);return te.delete(z),he;case"[object Symbol]":if(M)return M.call(z)==M.call(K)}return!1}},6096:(h,y,Z)=>{var b=Z(8234),w=Object.prototype.hasOwnProperty;h.exports=function(S,R,H,N,D,M){var z=1&H,K=b(S),P=K.length;if(P!=b(R).length&&!z)return!1;for(var J=P;J--;){var j=K[J];if(!(z?j in R:w.call(R,j)))return!1}var ie=M.get(S),te=M.get(R);if(ie&&te)return ie==R&&te==S;var Ce=!0;M.set(S,R),M.set(R,S);for(var ue=z;++J{var b=typeof Z.g=="object"&&Z.g&&Z.g.Object===Object&&Z.g;h.exports=b},8234:(h,y,Z)=>{var b=Z(8866),w=Z(9551),S=Z(3674);h.exports=function(R){return b(R,S,w)}},5050:(h,y,Z)=>{var b=Z(7019);h.exports=function(w,S){var R=w.__data__;return b(S)?R[typeof S=="string"?"string":"hash"]:R.map}},852:(h,y,Z)=>{var b=Z(8458),w=Z(7801);h.exports=function(S,R){var H=w(S,R);return b(H)?H:void 0}},9607:(h,y,Z)=>{var b=Z(2705),w=Object.prototype,S=w.hasOwnProperty,R=w.toString,H=b?b.toStringTag:void 0;h.exports=function(N){var D=S.call(N,H),M=N[H];try{N[H]=void 0;var z=!0}catch{}var K=R.call(N);return z&&(D?N[H]=M:delete N[H]),K}},9551:(h,y,Z)=>{var b=Z(4963),w=Z(479),S=Object.prototype.propertyIsEnumerable,R=Object.getOwnPropertySymbols,H=R?function(N){return N==null?[]:(N=Object(N),b(R(N),function(D){return S.call(N,D)}))}:w;h.exports=H},4160:(h,y,Z)=>{var b=Z(8552),w=Z(7071),S=Z(3818),R=Z(8525),H=Z(577),N=Z(4239),D=Z(346),M="[object Map]",z="[object Promise]",K="[object Set]",P="[object WeakMap]",J="[object DataView]",j=D(b),ie=D(w),te=D(S),Ce=D(R),ue=D(H),oe=N;(b&&oe(new b(new ArrayBuffer(1)))!=J||w&&oe(new w)!=M||S&&oe(S.resolve())!=z||R&&oe(new R)!=K||H&&oe(new H)!=P)&&(oe=function(he){var ye=N(he),Ie=ye=="[object Object]"?he.constructor:void 0,fe=Ie?D(Ie):"";if(fe)switch(fe){case j:return J;case ie:return M;case te:return z;case Ce:return K;case ue:return P}return ye}),h.exports=oe},7801:h=>{h.exports=function(y,Z){return y?.[Z]}},1789:(h,y,Z)=>{var b=Z(4536);h.exports=function(){this.__data__=b?b(null):{},this.size=0}},401:h=>{h.exports=function(y){var Z=this.has(y)&&delete this.__data__[y];return this.size-=Z?1:0,Z}},7667:(h,y,Z)=>{var b=Z(4536),w=Object.prototype.hasOwnProperty;h.exports=function(S){var R=this.__data__;if(b){var H=R[S];return H==="__lodash_hash_undefined__"?void 0:H}return w.call(R,S)?R[S]:void 0}},1327:(h,y,Z)=>{var b=Z(4536),w=Object.prototype.hasOwnProperty;h.exports=function(S){var R=this.__data__;return b?R[S]!==void 0:w.call(R,S)}},1866:(h,y,Z)=>{var b=Z(4536);h.exports=function(w,S){var R=this.__data__;return this.size+=this.has(w)?0:1,R[w]=b&&S===void 0?"__lodash_hash_undefined__":S,this}},5776:h=>{var y=/^(?:0|[1-9]\d*)$/;h.exports=function(Z,b){var w=typeof Z;return!!(b=b??9007199254740991)&&(w=="number"||w!="symbol"&&y.test(Z))&&Z>-1&&Z%1==0&&Z{h.exports=function(y){var Z=typeof y;return Z=="string"||Z=="number"||Z=="symbol"||Z=="boolean"?y!=="__proto__":y===null}},5346:(h,y,Z)=>{var b,w=Z(4429),S=(b=/[^.]+$/.exec(w&&w.keys&&w.keys.IE_PROTO||""))?"Symbol(src)_1."+b:"";h.exports=function(R){return!!S&&S in R}},5726:h=>{var y=Object.prototype;h.exports=function(Z){var b=Z&&Z.constructor;return Z===(typeof b=="function"&&b.prototype||y)}},7040:h=>{h.exports=function(){this.__data__=[],this.size=0}},4125:(h,y,Z)=>{var b=Z(8470),w=Array.prototype.splice;h.exports=function(S){var R=this.__data__,H=b(R,S);return!(H<0||(H==R.length-1?R.pop():w.call(R,H,1),--this.size,0))}},2117:(h,y,Z)=>{var b=Z(8470);h.exports=function(w){var S=this.__data__,R=b(S,w);return R<0?void 0:S[R][1]}},7518:(h,y,Z)=>{var b=Z(8470);h.exports=function(w){return b(this.__data__,w)>-1}},4705:(h,y,Z)=>{var b=Z(8470);h.exports=function(w,S){var R=this.__data__,H=b(R,w);return H<0?(++this.size,R.push([w,S])):R[H][1]=S,this}},4785:(h,y,Z)=>{var b=Z(1989),w=Z(8407),S=Z(7071);h.exports=function(){this.size=0,this.__data__={hash:new b,map:new(S||w),string:new b}}},1285:(h,y,Z)=>{var b=Z(5050);h.exports=function(w){var S=b(this,w).delete(w);return this.size-=S?1:0,S}},6e3:(h,y,Z)=>{var b=Z(5050);h.exports=function(w){return b(this,w).get(w)}},9916:(h,y,Z)=>{var b=Z(5050);h.exports=function(w){return b(this,w).has(w)}},5265:(h,y,Z)=>{var b=Z(5050);h.exports=function(w,S){var R=b(this,w),H=R.size;return R.set(w,S),this.size+=R.size==H?0:1,this}},8776:h=>{h.exports=function(y){var Z=-1,b=Array(y.size);return y.forEach(function(w,S){b[++Z]=[S,w]}),b}},4536:(h,y,Z)=>{var b=Z(852)(Object,"create");h.exports=b},6916:(h,y,Z)=>{var b=Z(5569)(Object.keys,Object);h.exports=b},1167:(h,y,Z)=>{h=Z.nmd(h);var b=Z(1957),w=y&&!y.nodeType&&y,S=w&&h&&!h.nodeType&&h,R=S&&S.exports===w&&b.process,H=function(){try{return S&&S.require&&S.require("util").types||R&&R.binding&&R.binding("util")}catch{}}();h.exports=H},2333:h=>{var y=Object.prototype.toString;h.exports=function(Z){return y.call(Z)}},5569:h=>{h.exports=function(y,Z){return function(b){return y(Z(b))}}},5639:(h,y,Z)=>{var b=Z(1957),w=typeof self=="object"&&self&&self.Object===Object&&self,S=b||w||Function("return this")();h.exports=S},619:h=>{h.exports=function(y){return this.__data__.set(y,"__lodash_hash_undefined__"),this}},2385:h=>{h.exports=function(y){return this.__data__.has(y)}},1814:h=>{h.exports=function(y){var Z=-1,b=Array(y.size);return y.forEach(function(w){b[++Z]=w}),b}},7465:(h,y,Z)=>{var b=Z(8407);h.exports=function(){this.__data__=new b,this.size=0}},3779:h=>{h.exports=function(y){var Z=this.__data__,b=Z.delete(y);return this.size=Z.size,b}},7599:h=>{h.exports=function(y){return this.__data__.get(y)}},4758:h=>{h.exports=function(y){return this.__data__.has(y)}},4309:(h,y,Z)=>{var b=Z(8407),w=Z(7071),S=Z(3369);h.exports=function(R,H){var N=this.__data__;if(N instanceof b){var D=N.__data__;if(!w||D.length<199)return D.push([R,H]),this.size=++N.size,this;N=this.__data__=new S(D)}return N.set(R,H),this.size=N.size,this}},346:h=>{var y=Function.prototype.toString;h.exports=function(Z){if(Z!=null){try{return y.call(Z)}catch{}try{return Z+""}catch{}}return""}},7813:h=>{h.exports=function(y,Z){return y===Z||y!=y&&Z!=Z}},5694:(h,y,Z)=>{var b=Z(9454),w=Z(7005),S=Object.prototype,R=S.hasOwnProperty,H=S.propertyIsEnumerable,N=b(function(){return arguments}())?b:function(D){return w(D)&&R.call(D,"callee")&&!H.call(D,"callee")};h.exports=N},1469:h=>{var y=Array.isArray;h.exports=y},8612:(h,y,Z)=>{var b=Z(3560),w=Z(1780);h.exports=function(S){return S!=null&&w(S.length)&&!b(S)}},4144:(h,y,Z)=>{h=Z.nmd(h);var b=Z(5639),w=Z(5062),S=y&&!y.nodeType&&y,R=S&&h&&!h.nodeType&&h,H=R&&R.exports===S?b.Buffer:void 0,N=(H?H.isBuffer:void 0)||w;h.exports=N},8446:(h,y,Z)=>{var b=Z(939);h.exports=function(w,S){return b(w,S)}},3560:(h,y,Z)=>{var b=Z(4239),w=Z(3218);h.exports=function(S){if(!w(S))return!1;var R=b(S);return R=="[object Function]"||R=="[object GeneratorFunction]"||R=="[object AsyncFunction]"||R=="[object Proxy]"}},1780:h=>{h.exports=function(y){return typeof y=="number"&&y>-1&&y%1==0&&y<=9007199254740991}},3218:h=>{h.exports=function(y){var Z=typeof y;return y!=null&&(Z=="object"||Z=="function")}},7005:h=>{h.exports=function(y){return y!=null&&typeof y=="object"}},6719:(h,y,Z)=>{var b=Z(8749),w=Z(1717),S=Z(1167),R=S&&S.isTypedArray,H=R?w(R):b;h.exports=H},3674:(h,y,Z)=>{var b=Z(4636),w=Z(280),S=Z(8612);h.exports=function(R){return S(R)?b(R):w(R)}},8306:(h,y,Z)=>{var b=Z(3369);function w(S,R){if(typeof S!="function"||R!=null&&typeof R!="function")throw new TypeError("Expected a function");var H=function(){var N=arguments,D=R?R.apply(this,N):N[0],M=H.cache;if(M.has(D))return M.get(D);var z=S.apply(this,N);return H.cache=M.set(D,z)||M,z};return H.cache=new(w.Cache||b),H}w.Cache=b,h.exports=w},479:h=>{h.exports=function(){return[]}},5062:h=>{h.exports=function(){return!1}},2703:(h,y,Z)=>{var b=Z(414);function w(){}function S(){}S.resetWarningCache=w,h.exports=function(){function R(D,M,z,K,P,J){if(J!==b){var j=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw j.name="Invariant Violation",j}}function H(){return R}R.isRequired=R;var N={array:R,bigint:R,bool:R,func:R,number:R,object:R,string:R,symbol:R,any:R,arrayOf:H,element:R,elementType:R,instanceOf:H,node:R,objectOf:H,oneOf:H,oneOfType:H,shape:H,exact:H,checkPropTypes:S,resetWarningCache:w};return N.PropTypes=N,N}},5697:(h,y,Z)=>{h.exports=Z(2703)()},414:h=>{h.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},9787:h=>{h.exports=s}},I={};function A(h){var y=I[h];if(y!==void 0)return y.exports;var Z=I[h]={id:h,loaded:!1,exports:{}};return C[h](Z,Z.exports,A),Z.loaded=!0,Z.exports}A.n=h=>{var y=h&&h.__esModule?()=>h.default:()=>h;return A.d(y,{a:y}),y},A.d=(h,y)=>{for(var Z in y)A.o(y,Z)&&!A.o(h,Z)&&Object.defineProperty(h,Z,{enumerable:!0,get:y[Z]})},A.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),A.o=(h,y)=>Object.prototype.hasOwnProperty.call(h,y),A.r=h=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(h,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(h,"__esModule",{value:!0})},A.nmd=h=>(h.paths=[],h.children||(h.children=[]),h);var d={};return(()=>{A.r(d),A.d(d,{default:()=>os,expandNodesToLevel:()=>gs});var h=A(4184),y=A.n(h),Z=A(8446),b=A.n(Z),w=A(8306),S=A.n(w);let R=(Rt=21)=>crypto.getRandomValues(new Uint8Array(Rt)).reduce((ut,Re)=>ut+((Re&=63)<36?Re.toString(36):Re<62?(Re-26).toString(36).toUpperCase():Re>62?"-":"_"),"");var H=A(5697),N=A.n(H),D=A(9787),M=A.n(D);function z(Rt){return z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(ut){return typeof ut}:function(ut){return ut&&typeof Symbol=="function"&&ut.constructor===Symbol&&ut!==Symbol.prototype?"symbol":typeof ut},z(Rt)}var K=["children","title"];function P(){return P=Object.assign?Object.assign.bind():function(Rt){for(var ut=1;ut"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var yt,gt=Ce(Ve);if(ot){var mt=Ce(this).constructor;yt=Reflect.construct(gt,arguments,mt)}else yt=gt.apply(this,arguments);return te(this,yt)});function wt(){return J(this,wt),Bt.apply(this,arguments)}return ut=wt,(Re=[{key:"render",value:function(){var yt=this.props,gt=yt.children,mt=yt.title,Se=function(ve,Pe){if(ve==null)return{};var vt,St,li=function(qi,mn){if(qi==null)return{};var Un,an,Kn={},hr=Object.keys(qi);for(an=0;an=0||(Kn[Un]=qi[Un]);return Kn}(ve,Pe);if(Object.getOwnPropertySymbols){var ci=Object.getOwnPropertySymbols(ve);for(St=0;St=0||Object.prototype.propertyIsEnumerable.call(ve,vt)&&(li[vt]=ve[vt])}return li}(yt,K);return M().createElement("button",P({"aria-label":mt,title:mt,type:"button"},Se),gt)}}])&&j(ut.prototype,Re),Object.defineProperty(ut,"prototype",{writable:!1}),wt}(M().PureComponent);ue(oe,"propTypes",{children:N().node.isRequired,title:N().string}),ue(oe,"defaultProps",{title:null});const he=oe,ye={ALL:"all",PARENT:"parent",LEAF:"leaf"};function Ie(Rt){this.message=Rt,this.stack=Error().stack}Ie.prototype=Object.create(Error.prototype),Ie.prototype.name="CheckboxTreeError";const fe=Ie;function We(Rt,ut){var Re=Object.keys(Rt);if(Object.getOwnPropertySymbols){var Ve=Object.getOwnPropertySymbols(Rt);ut&&(Ve=Ve.filter(function(ot){return Object.getOwnPropertyDescriptor(Rt,ot).enumerable})),Re.push.apply(Re,Ve)}return Re}function _e(Rt,ut,Re){return ut in Rt?Object.defineProperty(Rt,ut,{value:Re,enumerable:!0,configurable:!0,writable:!0}):Rt[ut]=Re,Rt}function qe(Rt,ut){if(!(Rt instanceof ut))throw new TypeError("Cannot call a class as a function")}function nt(Rt,ut){for(var Re=0;Re1&&arguments[1]!==void 0?arguments[1]:{};qe(this,Rt),this.props=Ve,this.flatNodes=ot}var ut,Re;return ut=Rt,Re=[{key:"setProps",value:function(Ve){this.props=Ve}},{key:"clone",value:function(){var Ve=this,ot={};return Object.keys(this.flatNodes).forEach(function(Bt){var wt=Ve.flatNodes[Bt];ot[Bt]=function(yt){for(var gt=1;gt1&&arguments[1]!==void 0?arguments[1]:{},wt=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(Array.isArray(Ve)&&Ve.length!==0){var yt=this.props,gt=yt.disabled,mt=yt.noCascade;Ve.forEach(function(Se,ve){var Pe=ot.nodeHasChildren(Se);if(ot.flatNodes[Se.value]!==void 0)throw new fe("Duplicate value '".concat(Se.value,"' detected. All node values must be unique."));ot.flatNodes[Se.value]={label:Se.label,value:Se.value,children:Se.children,parent:Bt,isChild:Bt.value!==void 0,isParent:Pe,isLeaf:!Pe,showCheckbox:Se.showCheckbox===void 0||Se.showCheckbox,disabled:ot.getDisabledState(Se,Bt,gt,mt),treeDepth:wt,index:ve},ot.flattenNodes(Se.children,Se,wt+1)})}}},{key:"nodeHasChildren",value:function(Ve){return Array.isArray(Ve.children)}},{key:"getDisabledState",value:function(Ve,ot,Bt,wt){return!!Bt||!(wt||!ot.disabled)||!!Ve.disabled}},{key:"deserializeLists",value:function(Ve){var ot=this,Bt=["checked","expanded"];Object.keys(this.flatNodes).forEach(function(wt){Bt.forEach(function(yt){ot.flatNodes[wt][yt]=!1})}),Bt.forEach(function(wt){Ve[wt].forEach(function(yt){ot.flatNodes[yt]!==void 0&&(ot.flatNodes[yt][wt]=!0)})})}},{key:"serializeList",value:function(Ve){var ot=this,Bt=[];return Object.keys(this.flatNodes).forEach(function(wt){ot.flatNodes[wt][Ve]&&Bt.push(wt)}),Bt}},{key:"expandAllNodes",value:function(Ve){var ot=this;return Object.keys(this.flatNodes).forEach(function(Bt){ot.flatNodes[Bt].isParent&&(ot.flatNodes[Bt].expanded=Ve)}),this}},{key:"toggleChecked",value:function(Ve,ot,Bt,wt){var yt=this,gt=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],mt=this.flatNodes[Ve.value],Se=[At.PARENT,At.ALL].indexOf(Bt)>-1,ve=[At.LEAF,At.ALL].indexOf(Bt)>-1;if(mt.isLeaf||wt){if(Ve.disabled)return this;this.toggleNode(Ve.value,"checked",ot)}else(Se||mt.children.length===0)&&this.toggleNode(Ve.value,"checked",ot),ve&&mt.children.forEach(function(Pe){yt.toggleChecked(Pe,ot,Bt,wt,!1)});return gt&&!wt&&mt.isChild&&Se&&this.toggleParentStatus(mt.parent,Bt),this}},{key:"toggleParentStatus",value:function(Ve,ot){var Bt=this.flatNodes[Ve.value];Bt.isChild?(ot===At.ALL&&this.toggleNode(Ve.value,"checked",this.isEveryChildChecked(Bt)),this.toggleParentStatus(Bt.parent,ot)):this.toggleNode(Ve.value,"checked",this.isEveryChildChecked(Bt))}},{key:"isEveryChildChecked",value:function(Ve){var ot=this;return Ve.children.every(function(Bt){return ot.getNode(Bt.value).checked})}},{key:"toggleNode",value:function(Ve,ot,Bt){return this.flatNodes[Ve][ot]=Bt,this}}],Re&&nt(ut.prototype,Re),Object.defineProperty(ut,"prototype",{writable:!1}),Rt}();function Ne(Rt){return Ne=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(ut){return typeof ut}:function(ut){return ut&&typeof Symbol=="function"&&ut.constructor===Symbol&&ut!==Symbol.prototype?"symbol":typeof ut},Ne(Rt)}function Ge(){return Ge=Object.assign?Object.assign.bind():function(Rt){for(var ut=1;ut"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var yt,gt=Vt(Ve);if(ot){var mt=Vt(this).constructor;yt=Reflect.construct(gt,arguments,mt)}else yt=gt.apply(this,arguments);return xt(this,yt)});function wt(){return Xe(this,wt),Bt.apply(this,arguments)}return ut=wt,Re=[{key:"componentDidMount",value:function(){this.updateDeterminateProperty()}},{key:"componentDidUpdate",value:function(){this.updateDeterminateProperty()}},{key:"updateDeterminateProperty",value:function(){var yt=this.props.indeterminate;this.checkbox.indeterminate=yt}},{key:"render",value:function(){var yt=this,gt=function(mt){for(var Se=1;Se"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var yt,gt=On(Ve);if(ot){var mt=On(this).constructor;yt=Reflect.construct(gt,arguments,mt)}else yt=gt.apply(this,arguments);return pn(this,yt)});function wt(yt){var gt;return function(mt,Se){if(!(mt instanceof Se))throw new TypeError("Cannot call a class as a function")}(this,wt),(gt=Bt.call(this,yt)).onCheck=gt.onCheck.bind(un(gt)),gt.onCheckboxKeyPress=gt.onCheckboxKeyPress.bind(un(gt)),gt.onCheckboxKeyUp=gt.onCheckboxKeyUp.bind(un(gt)),gt.onClick=gt.onClick.bind(un(gt)),gt.onExpand=gt.onExpand.bind(un(gt)),gt}return ut=wt,(Re=[{key:"onCheck",value:function(){var yt=this.props,gt=yt.value;(0,yt.onCheck)({value:gt,checked:this.getCheckState({toggle:!0})})}},{key:"onCheckboxKeyPress",value:function(yt){yt.which===32&&yt.preventDefault()}},{key:"onCheckboxKeyUp",value:function(yt){var gt=yt.keyCode;[13,32].includes(gt)&&this.onCheck()}},{key:"onClick",value:function(){var yt=this.props,gt=yt.expandOnClick,mt=yt.isParent,Se=yt.value,ve=yt.onClick;mt&>&&this.onExpand(),ve({value:Se,checked:this.getCheckState({toggle:!1})})}},{key:"onExpand",value:function(){var yt=this.props,gt=yt.expanded,mt=yt.value;(0,yt.onExpand)({value:mt,expanded:!gt})}},{key:"getCheckState",value:function(yt){var gt=yt.toggle,mt=this.props,Se=mt.checked,ve=mt.optimisticToggle;return!(Se!==0||!gt)||Se===1&&!gt||Se===2&&ve}},{key:"renderCollapseButton",value:function(){var yt=this.props,gt=yt.expandDisabled,mt=yt.isLeaf,Se=yt.lang;return mt?M().createElement("span",{className:"rct-collapse"},M().createElement("span",{className:"rct-icon"})):M().createElement(he,{className:"rct-collapse rct-collapse-btn",disabled:gt,title:Se.toggle,onClick:this.onExpand},this.renderCollapseIcon())}},{key:"renderCollapseIcon",value:function(){var yt=this.props,gt=yt.expanded,mt=yt.icons,Se=mt.expandClose,ve=mt.expandOpen;return gt?ve:Se}},{key:"renderCheckboxIcon",value:function(){var yt=this.props,gt=yt.checked,mt=yt.icons,Se=mt.uncheck,ve=mt.check,Pe=mt.halfCheck;return gt===0?Se:gt===1?ve:Pe}},{key:"renderNodeIcon",value:function(){var yt=this.props,gt=yt.expanded,mt=yt.icon,Se=yt.icons,ve=Se.leaf,Pe=Se.parentClose,vt=Se.parentOpen,St=yt.isLeaf;return mt!==null?mt:St?ve:gt?vt:Pe}},{key:"renderBareLabel",value:function(yt){var gt=this.props,mt=gt.onClick,Se=gt.title,ve=mt!==null;return M().createElement("span",{className:"rct-bare-label",title:Se},ve?M().createElement("span",{className:"rct-node-clickable",onClick:this.onClick,onKeyPress:this.onClick,role:"button",tabIndex:0},yt):yt)}},{key:"renderCheckboxLabel",value:function(yt){var gt=this.props,mt=gt.checked,Se=gt.disabled,ve=gt.title,Pe=gt.treeId,vt=gt.value,St=gt.onClick!==null,li="".concat(Pe,"-").concat(String(vt).split(" ").join("_")),ci=[M().createElement("label",{key:0,htmlFor:li,title:ve},M().createElement(Dt,{checked:mt===1,disabled:Se,id:li,indeterminate:mt===2,onClick:this.onCheck,onChange:function(){}}),M().createElement("span",{"aria-checked":mt===1,"aria-disabled":Se,className:"rct-checkbox",role:"checkbox",tabIndex:0,onKeyPress:this.onCheckboxKeyPress,onKeyUp:this.onCheckboxKeyUp},this.renderCheckboxIcon()),St?null:yt)];return St&&ci.push(M().createElement("span",{key:1,className:"rct-node-clickable",onClick:this.onClick,onKeyPress:this.onClick,role:"link",tabIndex:0},yt)),ci}},{key:"renderLabel",value:function(){var yt=this.props,gt=yt.label,mt=yt.showCheckbox,Se=[yt.showNodeIcon?M().createElement("span",{key:0,className:"rct-node-icon"},this.renderNodeIcon()):null,M().createElement("span",{key:1,className:"rct-title"},gt)];return mt?this.renderCheckboxLabel(Se):this.renderBareLabel(Se)}},{key:"renderChildren",value:function(){return this.props.expanded?this.props.children:null}},{key:"render",value:function(){var yt=this.props,gt=yt.className,mt=yt.disabled,Se=yt.expanded,ve=yt.isLeaf,Pe=y()({"rct-node":!0,"rct-node-leaf":ve,"rct-node-parent":!ve,"rct-node-expanded":!ve&&Se,"rct-node-collapsed":!ve&&!Se,"rct-disabled":mt},gt);return M().createElement("li",{className:Pe},M().createElement("span",{className:"rct-text"},this.renderCollapseButton(),this.renderLabel()),this.renderChildren())}}])&&Li(ut.prototype,Re),Object.defineProperty(ut,"prototype",{writable:!1}),wt}(M().PureComponent);Wg(ln,"propTypes",{checked:N().number.isRequired,disabled:N().bool.isRequired,expandDisabled:N().bool.isRequired,expanded:N().bool.isRequired,icons:Zi.isRequired,isLeaf:N().bool.isRequired,isParent:N().bool.isRequired,label:N().node.isRequired,lang:ui.isRequired,optimisticToggle:N().bool.isRequired,showNodeIcon:N().bool.isRequired,treeId:N().string.isRequired,value:N().oneOfType([N().string,N().number]).isRequired,onCheck:N().func.isRequired,onExpand:N().func.isRequired,children:N().node,className:N().string,expandOnClick:N().bool,icon:N().node,showCheckbox:N().bool,title:N().string,onClick:N().func}),Wg(ln,"defaultProps",{children:null,className:null,expandOnClick:!1,icon:null,showCheckbox:!0,title:null,onClick:function(){}});const Ht=ln,Ye=N().oneOfType([N().arrayOf(N().string),N().arrayOf(N().number)]);function Qe(Rt,ut){var Re=Object.keys(Rt);if(Object.getOwnPropertySymbols){var Ve=Object.getOwnPropertySymbols(Rt);ut&&(Ve=Ve.filter(function(ot){return Object.getOwnPropertyDescriptor(Rt,ot).enumerable})),Re.push.apply(Re,Ve)}return Re}function pt(Rt){for(var ut=1;ut"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var gt,mt=Ti(ot);if(Bt){var Se=Ti(this).constructor;gt=Reflect.construct(mt,arguments,Se)}else gt=mt.apply(this,arguments);return bi(this,gt)});function yt(gt){var mt;(function(ve,Pe){if(!(ve instanceof Pe))throw new TypeError("Cannot call a class as a function")})(this,yt),mt=wt.call(this,gt);var Se=new Tt(gt);return Se.flattenNodes(gt.nodes),Se.deserializeLists({checked:gt.checked,expanded:gt.expanded}),mt.state={id:gt.id||"rct-".concat(R()),model:Se,prevProps:gt},mt.onCheck=mt.onCheck.bind(Ni(mt)),mt.onExpand=mt.onExpand.bind(Ni(mt)),mt.onNodeClick=mt.onNodeClick.bind(Ni(mt)),mt.onExpandAll=mt.onExpandAll.bind(Ni(mt)),mt.onCollapseAll=mt.onCollapseAll.bind(Ni(mt)),mt.combineMemorized=S()(function(ve,Pe){return $e($e({},ve),Pe)}).bind(Ni(mt)),mt}return ut=yt,Re=[{key:"onCheck",value:function(gt){var mt=this.props,Se=mt.checkModel,ve=mt.noCascade,Pe=mt.onCheck,vt=this.state.model.clone(),St=vt.getNode(gt.value);vt.toggleChecked(gt,gt.checked,Se,ve),Pe(vt.serializeList("checked"),$e($e({},St),gt))}},{key:"onExpand",value:function(gt){var mt=this.props.onExpand,Se=this.state.model.clone(),ve=Se.getNode(gt.value);Se.toggleNode(gt.value,"expanded",gt.expanded),mt(Se.serializeList("expanded"),$e($e({},ve),gt))}},{key:"onNodeClick",value:function(gt){(0,this.props.onClick)($e($e({},this.state.model.getNode(gt.value)),gt))}},{key:"onExpandAll",value:function(){this.expandAllNodes()}},{key:"onCollapseAll",value:function(){this.expandAllNodes(!1)}},{key:"expandAllNodes",value:function(){var gt=!(arguments.length>0&&arguments[0]!==void 0)||arguments[0],mt=this.props.onExpand;mt(this.state.model.clone().expandAllNodes(gt).serializeList("expanded"))}},{key:"determineShallowCheckState",value:function(gt,mt){var Se=this.state.model.getNode(gt.value);return Se.isLeaf||mt||gt.children.length===0?Se.checked?1:0:this.isEveryChildChecked(gt)?1:this.isSomeChildChecked(gt)?2:0}},{key:"isEveryChildChecked",value:function(gt){var mt=this;return gt.children.every(function(Se){return mt.state.model.getNode(Se.value).checkState===1})}},{key:"isSomeChildChecked",value:function(gt){var mt=this;return gt.children.some(function(Se){return mt.state.model.getNode(Se.value).checkState>0})}},{key:"renderTreeNodes",value:function(gt){var mt=this,Se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ve=this.props,Pe=ve.expandDisabled,vt=ve.expandOnClick,St=ve.icons,li=ve.lang,ci=ve.noCascade,qi=ve.onClick,mn=ve.onlyLeafCheckboxes,Un=ve.optimisticToggle,an=ve.showNodeTitle,Kn=ve.showNodeIcon,hr=this.state,en=hr.id,Ln=hr.model,fr=yt.defaultProps.icons,wr=gt.map(function(pg){var as=pg.value,ii=Ln.getNode(pg.value),Hi=ii.isParent?mt.renderTreeNodes(pg.children,pg):null;ii.checkState=mt.determineShallowCheckState(pg,ci);var Vn=mn?ii.isLeaf:ii.showCheckbox;return!Se.value||Ln.getNode(Se.value).expanded?M().createElement(Ht,{key:as,checked:ii.checkState,className:pg.className,disabled:ii.disabled,expandDisabled:Pe,expandOnClick:vt,expanded:ii.expanded,icon:pg.icon,icons:mt.combineMemorized(fr,St),label:pg.label,lang:li,optimisticToggle:Un,isLeaf:ii.isLeaf,isParent:ii.isParent,showCheckbox:Vn,showNodeIcon:Kn,title:an?pg.title||pg.label:pg.title,treeId:en,value:pg.value,onCheck:mt.onCheck,onClick:qi&&mt.onNodeClick,onExpand:mt.onExpand},Hi):null});return M().createElement("ol",null,wr)}},{key:"renderExpandAll",value:function(){var gt=this.props,mt=gt.icons,Se=mt.expandAll,ve=mt.collapseAll,Pe=gt.lang;return gt.showExpandAll?M().createElement("div",{className:"rct-options"},M().createElement(he,{className:"rct-option rct-option-expand-all",title:Pe.expandAll,onClick:this.onExpandAll},Se),M().createElement(he,{className:"rct-option rct-option-collapse-all",title:Pe.collapseAll,onClick:this.onCollapseAll},ve)):null}},{key:"renderHiddenInput",value:function(){var gt=this.props,mt=gt.name,Se=gt.nameAsArray;return mt===void 0?null:Se?this.renderArrayHiddenInput():this.renderJoinedHiddenInput()}},{key:"renderArrayHiddenInput",value:function(){var gt=this.props,mt=gt.checked,Se=gt.name;return mt.map(function(ve){var Pe="".concat(Se,"[]");return M().createElement("input",{key:ve,name:Pe,type:"hidden",value:ve})})}},{key:"renderJoinedHiddenInput",value:function(){var gt=this.props,mt=gt.checked,Se=gt.name,ve=mt.join(",");return M().createElement("input",{name:Se,type:"hidden",value:ve})}},{key:"render",value:function(){var gt,mt=this.props,Se=mt.direction,ve=mt.disabled,Pe=mt.iconsClass,vt=mt.nodes,St=mt.nativeCheckboxes,li=this.state.id,ci=this.renderTreeNodes(vt),qi=y()((Ki(gt={"react-checkbox-tree":!0,"rct-disabled":ve},"rct-icons-".concat(Pe),!0),Ki(gt,"rct-native-display",St),Ki(gt,"rct-direction-rtl",Se==="rtl"),gt));return M().createElement("div",{className:qi,id:li},this.renderExpandAll(),this.renderHiddenInput(),ci)}}],Ve=[{key:"getDerivedStateFromProps",value:function(gt,mt){var Se=mt.model,ve=mt.prevProps,Pe=gt.disabled,vt=gt.id,St=gt.nodes,li=$e($e({},mt),{},{prevProps:gt});return Se.setProps(gt),b()(ve.nodes,St)&&ve.disabled===Pe||(Se.reset(),Se.flattenNodes(St)),vt!==null&&(li=$e($e({},li),{},{id:vt})),Se.deserializeLists({checked:gt.checked,expanded:gt.expanded}),li}}],Re&&ft(ut.prototype,Re),Ve&&ft(ut,Ve),Object.defineProperty(ut,"prototype",{writable:!1}),yt}(M().Component);function Sa(Rt){return function(ut){if(Array.isArray(ut))return Hl(ut)}(Rt)||function(ut){if(typeof Symbol<"u"&&ut[Symbol.iterator]!=null||ut["@@iterator"]!=null)return Array.from(ut)}(Rt)||function(ut,Re){if(ut){if(typeof ut=="string")return Hl(ut,Re);var Ve=Object.prototype.toString.call(ut).slice(8,-1);return Ve==="Object"&&ut.constructor&&(Ve=ut.constructor.name),Ve==="Map"||Ve==="Set"?Array.from(ut):Ve==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(Ve)?Hl(ut,Re):void 0}}(Rt)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Hl(Rt,ut){(ut==null||ut>Rt.length)&&(ut=Rt.length);for(var Re=0,Ve=new Array(ut);Re2&&arguments[2]!==void 0?arguments[2]:0;if(Re>ut)return[];var Ve=[];return Rt.forEach(function(ot){ot.children&&(Ve=[].concat(Sa(Ve),[ot.value],Sa(gs(ot.children,ut,Re+1))))}),Ve}Ki(Ng,"propTypes",{nodes:N().arrayOf(q).isRequired,checkModel:N().oneOf([ye.LEAF,ye.ALL]),checked:Ye,direction:N().string,disabled:N().bool,expandDisabled:N().bool,expandOnClick:N().bool,expanded:Ye,icons:Zi,iconsClass:N().string,id:N().string,lang:ui,name:N().string,nameAsArray:N().bool,nativeCheckboxes:N().bool,noCascade:N().bool,onlyLeafCheckboxes:N().bool,optimisticToggle:N().bool,showExpandAll:N().bool,showNodeIcon:N().bool,showNodeTitle:N().bool,onCheck:N().func,onClick:N().func,onExpand:N().func}),Ki(Ng,"defaultProps",{checkModel:ye.LEAF,checked:[],direction:"ltr",disabled:!1,expandDisabled:!1,expandOnClick:!1,expanded:[],icons:{check:M().createElement("span",{className:"rct-icon rct-icon-check"}),uncheck:M().createElement("span",{className:"rct-icon rct-icon-uncheck"}),halfCheck:M().createElement("span",{className:"rct-icon rct-icon-half-check"}),expandClose:M().createElement("span",{className:"rct-icon rct-icon-expand-close"}),expandOpen:M().createElement("span",{className:"rct-icon rct-icon-expand-open"}),expandAll:M().createElement("span",{className:"rct-icon rct-icon-expand-all"}),collapseAll:M().createElement("span",{className:"rct-icon rct-icon-collapse-all"}),parentClose:M().createElement("span",{className:"rct-icon rct-icon-parent-close"}),parentOpen:M().createElement("span",{className:"rct-icon rct-icon-parent-open"}),leaf:M().createElement("span",{className:"rct-icon rct-icon-leaf"})},iconsClass:"fa4",id:null,lang:{collapseAll:"Collapse all",expandAll:"Expand all",toggle:"Toggle"},name:void 0,nameAsArray:!1,nativeCheckboxes:!1,noCascade:!1,onlyLeafCheckboxes:!1,optimisticToggle:!0,showExpandAll:!1,showNodeIcon:!0,showNodeTitle:!1,onCheck:function(){},onClick:null,onExpand:function(){}});const os=Ng})(),d})())})(oBe);const kbt=ge(oBe.exports);let aBe=function(g){o(s,g);var a=l(s);function s(C){var I;T(this,s),I=a.call(this,C),I.localTracks=_0.filter(y=>y.local&&!y.hidden).map(y=>{const Z={...y};return Z.datatype=y.datatype[0],Z}),I.augmentedTracksInfo=_0,window.higlassTracksByType&&Object.keys(window.higlassTracksByType).forEach(y=>{I.augmentedTracksInfo.push(window.higlassTracksByType[y].config)}),C.datatype?I.localTracks=I.localTracks.filter(y=>y.datatype[0]===C.datatype):I.localTracks=I.localTracks.filter(y=>y.orientation===I.props.orientation),I.localTracks.forEach(y=>{y.uuid=Fn.nice()});const A=I.prepareNewEntries("",I.localTracks,{}),d=Object.keys(A),h=d.length?[d[0]]:null;return I.mounted=!1,I.state={selectedUuid:h,options:A,filter:"",checked:[],expanded:[]},I.requestTilesetLists(),I}return E(s,[{key:"componentDidMount",value:function(){this.mounted=!0,this.requestTilesetLists(),this.searchBox.focus()}},{key:"componentWillUnmount",value:function(){this.mounted=!1}},{key:"prepareNewEntries",value:function(I,A,d){const h=d;return A.map(Z=>({...Z,server:I,tilesetUid:Z.uuid,serverUidKey:this.serverUidKey(I,Z.uuid),datatype:Z.datatype,name:Z.name,uid:Fn.nice()})).forEach(Z=>{h[Z.serverUidKey]=Z}),h}},{key:"serverUidKey",value:function(I,A){return`${I}/${A}`}},{key:"requestTilesetLists",value:function(){let I=null;if(this.props.datatype?I=`dt=${this.props.datatype}`:I=[...new Set([].concat(...this.augmentedTracksInfo.filter(d=>d.datatype).filter(d=>d.orientation===this.props.orientation||this.props.orientation==="1d-vertical"&&d.orientation==="1d-horizontal").map(d=>d.datatype)))].map(d=>`dt=${d}`).join("&"),!this.props.trackSourceServers){console.warn("No track source servers specified in the viewconf");return}this.props.trackSourceServers.forEach(A=>{Gi.json(`${A}/tilesets/?limit=10000&${I}`,(d,h)=>{if(d)console.error("ERROR:",d);else{const y=this.prepareNewEntries(A,h.results,this.state.options),Z=Object.keys(y);let{selectedUuid:b}=this.state;if(!b){b=Z.length?[Z[0]]:null;const w=this.state.options[b[0]];this.props.selectedTilesetChanged([w])}this.mounted&&this.setState({selectedUuid:b,options:y})}},this.props.pubSub)})}},{key:"handleOptionDoubleClick",value:function(I){const A=this.state.options[I.target.value];this.props.onDoubleClick(A)}},{key:"handleSelectedOptions",value:function(I){const A=[],d=[];for(let h=0;hZ.label.toLowerCase().localeCompare(b.label.toLowerCase(),"en")),h.push(d[y]));return h.sort((y,Z)=>y.label.toLowerCase().localeCompare(Z.label.toLowerCase(),"en")),h}},{key:"handleChecked",value:function(I){this.handleSelectedOptions(I),this.setState({checked:I})}},{key:"handleExpanded",value:function(I){this.setState({expanded:I})}},{key:"render",value:function(){const I=[];for(const Z in this.state.options)I.push(this.state.options[Z]);const A=this.partitionByGroup(this.state.options,this.state.filter),d={width:15,height:15,top:2,right:2,position:"relative"},h=JSON.parse(JSON.stringify(d));h.opacity=.5;const y=X.default.createElement("form",{onSubmit:Z=>{Z.preventDefault()}},X.default.createElement("div",{className:"tileset-finder-search-bar"},X.default.createElement("span",{className:"tileset-finder-label"},"Select tileset:"),X.default.createElement("input",{ref:Z=>{this.searchBox=Z},className:"tileset-finder-search-box",onChange:this.handleSearchChange.bind(this),placeholder:"Search Term",type:"text"})),X.default.createElement("div",{className:"tileset-finder-checkbox-tree"},X.default.createElement(kbt,{checked:this.state.checked,expanded:this.state.expanded,icons:{uncheck:X.default.createElement("svg",{style:d},X.default.createElement("use",{xlinkHref:"#square_o"})),check:X.default.createElement("svg",{style:d},X.default.createElement("use",{xlinkHref:"#check_square_o"})),halfCheck:X.default.createElement("svg",{style:h},X.default.createElement("use",{xlinkHref:"#check_square_o"})),leaf:X.default.createElement("svg",{style:d},X.default.createElement("use",{xlinkHref:"#file_o"})),expandClose:X.default.createElement("svg",{style:d},X.default.createElement("use",{xlinkHref:"#chevron_right"})),expandOpen:X.default.createElement("svg",{style:d},X.default.createElement("use",{xlinkHref:"#chevron_down"})),parentClose:X.default.createElement("svg",{style:d},X.default.createElement("use",{xlinkHref:"#folder_o"})),parentOpen:X.default.createElement("svg",{style:d},X.default.createElement("use",{xlinkHref:"#folder_open_o"}))},nodes:A,onCheck:this.handleChecked.bind(this),onExpand:this.handleExpanded.bind(this)})));return X.default.createElement("div",null,y)}}]),s}(X.default.Component);aBe.propTypes={datatype:_.exports.string,orientation:_.exports.string,onDoubleClick:_.exports.func,pubSub:_.exports.object.isRequired,selectedTilesetChanged:_.exports.func,trackSourceServers:_.exports.array};const Xbt=qZ(aBe);let sBe=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.DATATYPE_TO_TRACK_TYPE=vU(I.props.orientation),I.AVAILABLE_TRACK_TYPES=eX(I.props.datatypes,I.props.orientation),I.state={selectedPlotType:I.AVAILABLE_TRACK_TYPES[0]},I}return E(s,[{key:"UNSAFE_componentWillReceiveProps",value:function(I){if(this.AVAILABLE_TRACK_TYPES=eX(I.datatypes,this.props.orientation),!!this.AVAILABLE_TRACK_TYPES&&I.allTracksSameDatatype&&this.AVAILABLE_TRACK_TYPES.length>0&&!this.AVAILABLE_TRACK_TYPES.includes(this.state.selectedPlotType)){const A=GU(I.datatypes[0][0],this.props.position,this.AVAILABLE_TRACK_TYPES);this.handlePlotTypeSelected(A)}}},{key:"handlePlotTypeSelected",value:function(I){this.setState({selectedPlotType:I}),this.props.onPlotTypeSelected(I.type)}},{key:"render",value:function(){let I="No plot types available for track";const A={};return _0.forEach(d=>{A[d.type]=d}),this.AVAILABLE_TRACK_TYPES&&(I=this.AVAILABLE_TRACK_TYPES.sort((d,h)=>d.type{const h=A[d.type].thumbnail,y=this.state.selectedPlotType.type===d.type?"plot-type-item plot-type-selected":"plot-type-item",Z=A[d.type].thumbnail?X.default.createElement("div",{className:"track-thumbnail",dangerouslySetInnerHTML:{__html:h.outerHTML}}):X.default.createElement("div",{className:"track-thumbnail"},X.default.createElement("svg",{height:20,width:30}));return X.default.createElement("li",{key:d.type,className:y,onClick:b=>{this.setState({selectedPlotType:d}),this.props.onPlotTypeSelected(d.type)},style:{listStyle:"none",paddingLeft:5,paddingBottom:0}},Z,X.default.createElement("span",{style:{verticalAlign:"middle"}},d.type))})),X.default.createElement("div",null,I.length>0&&this.props.allTracksSameDatatype&&X.default.createElement("div",{className:"plot-type-container"},I),!this.props.allTracksSameDatatype&&X.default.createElement("div",{className:"plot-type-container-empty"},"Datasets with multiple datatypes chosen. They will be added with their default track types."))}}]),s}(X.default.Component);sBe.propTypes={allTracksSameDatatype:_.exports.bool,datatypes:_.exports.array,orientation:_.exports.string,onPlotTypeSelected:_.exports.func,position:_.exports.string};let eD=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.options={},I.state={selectedTilesets:[{datatype:"none"}],allTracksSameDatatype:!0},I.handleSubmitBound=I.handleSubmit.bind(u(I)),I.handleTilesetPickerDoubleClickBound=I.handleTilesetPickerDoubleClick.bind(u(I)),I.selectedTilesetsChangedBound=I.selectedTilesetsChanged.bind(u(I)),I}return E(s,[{key:"getOrientation",value:function(I){let A=null;return I==="top"||I==="bottom"?A="1d-horizontal":I==="left"||I==="right"?A="1d-vertical":A="2d",A}},{key:"handleSubmit",value:function(I){I&&I.preventDefault(),this.props.onTracksChosen(this.state.selectedTilesets,this.props.position,this.props.host)}},{key:"handleTilesetPickerDoubleClick",value:function(I){this.selectedTilesetsChanged([I]),this.props.onTracksChosen(this.state.selectedTilesets,this.props.position,this.props.host)}},{key:"handleOptionsChanged",value:function(I){this.options=I}},{key:"handlePlotTypeSelected",value:function(I){const{selectedTilesets:A}=this.state;for(const d of A)d.type=I;this.selectedPlotType=I,this.setState({selectedTilesets:A})}},{key:"selectedTilesetsChanged",value:function(I){let A=null;I.length===0?A=[{datatype:"none"}]:A=I;let d=!0;const h=A[0].datatype;for(const y of A)y.datatype!==h&&(d=!1);if(d)for(const y of A)y.type=this.selectedPlotType;else for(const y of A){let Z=[y.datatype];const b=this.getOrientation(this.props.position);y.filetype==="cooler"&&(Z=[y.datatype,"chromsizes"]);const w=eX([Z],b),S=GU(Z[0],this.props.position,w);y.type=S.type}this.setState({selectedTilesets:A,allTracksSameDatatype:d})}},{key:"render",value:function(){const I=this.getOrientation(this.props.position),A=X.default.createElement("div",null,X.default.createElement(Xbt,{ref:d=>{this.tilesetFinder=d},datatype:this.props.datatype,onDoubleClick:this.handleTilesetPickerDoubleClick.bind(this),onTracksChosen:d=>this.props.onTracksChosen(d,this.props.position),orientation:I,selectedTilesetChanged:this.selectedTilesetsChanged.bind(this),trackSourceServers:this.props.trackSourceServers}));return X.default.createElement(eR,{maxHeight:!0,okayTitle:"Submit",onCancel:this.props.onCancel,onOkay:this.handleSubmitBound,title:"Add Track"},X.default.createElement(X.default.Fragment,null,A,X.default.createElement(sBe,{ref:d=>{this.plotTypeChooser=d},allTracksSameDatatype:this.state.allTracksSameDatatype,datatypes:this.state.selectedTilesets.map(d=>d.filetype==="cooler"?[d.datatype,"chromsizes"]:[d.datatype]),onPlotTypeSelected:this.handlePlotTypeSelected.bind(this),orientation:I,position:this.props.position})))}}]),s}(X.default.Component);eD.defaultProps={position:"top"},eD.propTypes={datatype:_.exports.string,host:_.exports.string,onCancel:_.exports.func.isRequired,onTracksChosen:_.exports.func.isRequired,position:_.exports.string,trackSourceServers:_.exports.array.isRequired};let yQ=function(g){o(s,g);var a=l(s);function s(){return T(this,s),a.apply(this,arguments)}return E(s,[{key:"render",value:function(){const I=[];return this.props.children.forEach((A,d)=>{const h=`customTrackDialog_${d}`;I.push(X.default.createElement(A,{key:h,...this.props.bodyProps[d]}))}),X.default.createElement(eR,{maxHeight:!0,okayOnly:!0,okayTitle:"Close",onCancel:this.props.onCancel,onOkay:this.props.onCancel,title:this.props.title},I)}}]),s}(X.default.PureComponent);yQ.defaultProps={},yQ.propTypes={onCancel:_.exports.func.isRequired};const IBe=20;let rm=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.adjusted=!1,I.state={orientation:I.props.orientation?I.props.orientation:"right",left:I.props.position.left,top:I.props.position.top,submenuShown:null},I}return E(s,[{key:"componentDidMount",value:function(){this.updateOrientation()}},{key:"UNSAFE_componentWillReceiveProps",value:function(I){this.adjusted=!1,this.setState({left:I.position.left,top:I.position.top})}},{key:"componentDidUpdate",value:function(){this.updateOrientation()}},{key:"handleItemMouseEnterWithRect",value:function(I,A){this.setState({submenuShown:A,submenuSourceBbox:I})}},{key:"handleItemMouseEnter",value:function(I,A){this.handleItemMouseEnterWithRect(I.currentTarget.getBoundingClientRect(),A)}},{key:"handleMouseLeave",value:function(){}},{key:"handleOtherMouseEnter",value:function(){this.setState({submenuShown:null})}},{key:"updateOrientation",value:function(){if(this.adjusted)return;this.adjusted=!0,this.divDom=$.default.findDOMNode(this.div);const I=this.divDom.getBoundingClientRect(),A=this.props.parentBbox?this.props.parentBbox:{top:this.props.position.top,left:this.props.position.left,width:0,height:0};let d=this.state.orientation,h=A.top;if(A.top+I.height>window.innerHeight&&(A.top-I.height>0?h=A.top-I.height+IBe:(h=A.top-I.height+IBe,h-=h+I.height-window.innerHeight)),this.state.orientation==="left"){let y=A.left-I.width;y<0&&(A.left+A.width+I.width>window.innerWidth?y=0:(y=A.left+A.width,d="right")),this.setState({left:y,top:h,orientation:d})}else{let y=A.left+A.width;A.left+A.width+I.width>window.innerWidth&&(A.left-I.width<0?(y=0,d="right"):(y=A.left-I.width,d="left")),this.setState({left:y,top:h,orientation:d})}}},{key:"render",value:function(){const I=this.state.left?{left:this.state.left}:{right:this.state.right},A={top:this.state.top},d=Object.assign(I,A);return X.default.createElement("div",{ref:h=>{this.div=h},className:lr("context-menu-item",sn["context-menu"],{[sn["context-menu-dark"]]:this.props.theme===ig}),style:d},this.props.children)}}]),s}(X.default.Component);rm.propTypes={children:_.exports.node,orientation:_.exports.string,parentBbox:_.exports.object,position:_.exports.object,theme:_.exports.symbol.isRequired};let vQ=function(g){o(s,g);var a=l(s);function s(){return T(this,s),a.apply(this,arguments)}return E(s,[{key:"getSubmenu",value:function(){if(this.state.submenuShown){const I=this.state.submenuSourceBbox,A=this.state.orientation==="left"?{left:this.state.left,top:I.top}:{left:this.state.left+I.width+7,top:I.top},d=this.state.submenuShown;return X.default.createElement(s,{menuItems:d.children,orientation:this.state.orientation,parentBbox:I,position:A,theme:this.props.theme})}return X.default.createElement("div",null)}},{key:"componentWillUnmount",value:function(){}},{key:"render",value:function(){const I=[];for(const A in this.props.menuItems){const d=this.props.menuItems[A];I.push(X.default.createElement(Gn,{key:A,onClick:d.handler?d.handler:()=>null,onMouseEnter:d.children?h=>this.handleItemMouseEnter(h,d):this.handleOtherMouseEnter.bind(this),onMouseLeave:this.handleMouseLeave},d.name,d.children&&X.default.createElement("svg",{className:sn["play-icon"]},X.default.createElement("use",{xlinkHref:"#play"}))))}return X.default.createElement("div",{ref:A=>{this.div=A},className:lr(sn["context-menu"],{[sn["context-menu-dark"]]:this.props.theme===ig}),style:{left:this.state.left,top:this.state.top}},I,this.getSubmenu())}}]),s}(rm);var hC={},tR={},xbt=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis;const lBe=xbt;var Dbt=typeof self=="object"&&self&&self.Object===Object&&self,Mbt=lBe||Dbt||Function("return this")();const hc=Mbt;var Fbt=hc.Symbol;const su=Fbt;var CBe=Object.prototype,Ybt=CBe.hasOwnProperty,Kbt=CBe.toString,iR=su?su.toStringTag:void 0;function _bt(g){var a=Ybt.call(g,iR),s=g[iR];try{g[iR]=void 0;var C=!0}catch{}var I=Kbt.call(g);return C&&(a?g[iR]=s:delete g[iR]),I}var Pbt=Object.prototype,zbt=Pbt.toString;function Obt(g){return zbt.call(g)}var Lbt="[object Null]",Jbt="[object Undefined]",cBe=su?su.toStringTag:void 0;function gm(g){return g==null?g===void 0?Jbt:Lbt:cBe&&cBe in Object(g)?_bt(g):Obt(g)}var Ubt=Array.isArray;const zs=Ubt;function fc(g){return g!=null&&typeof g=="object"}var Qbt="[object String]";function jbt(g){return typeof g=="string"||!zs(g)&&fc(g)&&gm(g)==Qbt}const $bt=Ae(Object.freeze(Object.defineProperty({__proto__:null,default:jbt},Symbol.toStringTag,{value:"Module"})));function qbt(g){return function(a,s,C){for(var I=-1,A=Object(a),d=C(a),h=d.length;h--;){var y=d[g?h:++I];if(s(A[y],y,A)===!1)break}return a}}var eyt=qbt();const ABe=eyt;function tyt(g,a){for(var s=-1,C=Array(g);++s-1&&g%1==0&&g-1&&g%1==0&&g<=cyt}var Ayt="[object Arguments]",uyt="[object Array]",dyt="[object Boolean]",hyt="[object Date]",fyt="[object Error]",myt="[object Function]",pyt="[object Map]",byt="[object Number]",yyt="[object Object]",vyt="[object RegExp]",Zyt="[object Set]",Byt="[object String]",Gyt="[object WeakMap]",Syt="[object ArrayBuffer]",wyt="[object DataView]",Tyt="[object Float32Array]",Ryt="[object Float64Array]",Vyt="[object Int8Array]",Eyt="[object Int16Array]",Hyt="[object Int32Array]",Wyt="[object Uint8Array]",Nyt="[object Uint8ClampedArray]",kyt="[object Uint16Array]",Xyt="[object Uint32Array]",mg={};mg[Tyt]=mg[Ryt]=mg[Vyt]=mg[Eyt]=mg[Hyt]=mg[Wyt]=mg[Nyt]=mg[kyt]=mg[Xyt]=!0,mg[Ayt]=mg[uyt]=mg[Syt]=mg[dyt]=mg[wyt]=mg[hyt]=mg[fyt]=mg[myt]=mg[pyt]=mg[byt]=mg[yyt]=mg[vyt]=mg[Zyt]=mg[Byt]=mg[Gyt]=!1;function xyt(g){return fc(g)&&BQ(g.length)&&!!mg[gm(g)]}function GQ(g){return function(a){return g(a)}}var pBe=typeof k=="object"&&k&&!k.nodeType&&k,rR=pBe&&!0&&e&&!e.nodeType&&e,Dyt=rR&&rR.exports===pBe,SQ=Dyt&&lBe.process,Myt=function(){try{var g=rR&&rR.require&&rR.require("util").types;return g||SQ&&SQ.binding&&SQ.binding("util")}catch{}}();const k1=Myt;var bBe=k1&&k1.isTypedArray,Fyt=bBe?GQ(bBe):xyt;const wQ=Fyt;var Yyt=Object.prototype,Kyt=Yyt.hasOwnProperty;function yBe(g,a){var s=zs(g),C=!s&&tD(g),I=!s&&!C&&nR(g),A=!s&&!C&&!I&&wQ(g),d=s||C||I||A,h=d?tyt(g.length,String):[],y=h.length;for(var Z in g)(a||Kyt.call(g,Z))&&!(d&&(Z=="length"||I&&(Z=="offset"||Z=="parent")||A&&(Z=="buffer"||Z=="byteLength"||Z=="byteOffset")||ZQ(Z,y)))&&h.push(Z);return h}var _yt=Object.prototype;function TQ(g){var a=g&&g.constructor,s=typeof a=="function"&&a.prototype||_yt;return g===s}function vBe(g,a){return function(s){return g(a(s))}}var Pyt=vBe(Object.keys,Object);const zyt=Pyt;var Oyt=Object.prototype,Lyt=Oyt.hasOwnProperty;function Jyt(g){if(!TQ(g))return zyt(g);var a=[];for(var s in Object(g))Lyt.call(g,s)&&s!="constructor"&&a.push(s);return a}function Sl(g){var a=typeof g;return g!=null&&(a=="object"||a=="function")}var Uyt="[object AsyncFunction]",Qyt="[object Function]",jyt="[object GeneratorFunction]",$yt="[object Proxy]";function RQ(g){if(!Sl(g))return!1;var a=gm(g);return a==Qyt||a==jyt||a==Uyt||a==$yt}function X1(g){return g!=null&&BQ(g.length)&&!RQ(g)}function gR(g){return X1(g)?yBe(g):Jyt(g)}function ZBe(g,a){return g&&ABe(g,a,gR)}function iD(g){return g}function BBe(g){return typeof g=="function"?g:iD}function qyt(g,a){return g&&ZBe(g,BBe(a))}const VQ=Ae(Object.freeze(Object.defineProperty({__proto__:null,default:qyt},Symbol.toStringTag,{value:"Module"})));var evt=vBe(Object.getPrototypeOf,Object);const EQ=evt;var tvt="[object Object]",ivt=Function.prototype,nvt=Object.prototype,GBe=ivt.toString,rvt=nvt.hasOwnProperty,gvt=GBe.call(Object);function SBe(g){if(!fc(g)||gm(g)!=tvt)return!1;var a=EQ(g);if(a===null)return!0;var s=rvt.call(a,"constructor")&&a.constructor;return typeof s=="function"&&s instanceof s&&GBe.call(s)==gvt}const ovt=Ae(Object.freeze(Object.defineProperty({__proto__:null,default:SBe},Symbol.toStringTag,{value:"Module"})));function wBe(g,a){for(var s=-1,C=g==null?0:g.length,I=Array(C);++s-1}function Avt(g,a){var s=this.__data__,C=nD(s,g);return C<0?(++this.size,s.push([g,a])):s[C][1]=a,this}function rh(g){var a=-1,s=g==null?0:g.length;for(this.clear();++ah))return!1;var Z=A.get(g),b=A.get(a);if(Z&&b)return Z==a&&b==g;var w=-1,S=!0,R=s&rZt?new gD:void 0;for(A.set(g,a),A.set(a,g);++w0&&arguments[0]!==void 0?arguments[0]:[],s=[];return(0,R1t.default)(a,function(C){Array.isArray(C)?g(C).map(function(I){return s.push(I)}):(0,w1t.default)(C)?(0,G1t.default)(C,function(I,A){I===!0&&s.push(A),s.push(A+"-"+I)}):(0,Z1t.default)(C)&&s.push(C)}),s};tR.default=V1t;var lR={};function jBe(g,a){for(var s=-1,C=g==null?0:g.length;++s1&&arguments[1]!==void 0?arguments[1]:[],C=a.default&&(0,sGt.default)(a.default)||{};return s.map(function(I){var A=a[I];return A&&(0,oGt.default)(A,function(d,h){C[h]||(C[h]={}),C[h]=IGt({},C[h],A[h])}),I}),C};lR.default=lGt;var AR={};Object.defineProperty(AR,"__esModule",{value:!0}),AR.autoprefix=void 0;var CGt=VQ,fGe=AGt(CGt),cGt=Object.assign||function(g){for(var a=1;a1&&arguments[1]!==void 0?arguments[1]:"span";return function(C){bGt(I,C);function I(){var A,d,h,y;pGt(this,I);for(var Z=arguments.length,b=Array(Z),w=0;w1&&arguments[1]!==void 0?arguments[1]:"span";return function(C){SGt(I,C);function I(){var A,d,h,y;GGt(this,I);for(var Z=arguments.length,b=Array(Z),w=0;w1&&arguments[1]!==void 0?arguments[1]:!0;C[d]=h};return a===0&&I("first-child"),a===s-1&&I("last-child"),(a===0||a%2===0)&&I("even"),Math.abs(a%2)===1&&I("odd"),I("nth-child",a),C};LQ.default=TGt,Object.defineProperty(hC,"__esModule",{value:!0}),hC.ReactCSS=hC.loop=hC.handleActive=JQ=hC.handleHover=hC.hover=void 0;var RGt=tR,VGt=x1(RGt),EGt=lR,HGt=x1(EGt),WGt=AR,NGt=x1(WGt),kGt=uR,bGe=x1(kGt),XGt=dR,xGt=x1(XGt),DGt=LQ,MGt=x1(DGt);function x1(g){return g&&g.__esModule?g:{default:g}}hC.hover=bGe.default;var JQ=hC.handleHover=bGe.default;hC.handleActive=xGt.default,hC.loop=MGt.default;var FGt=hC.ReactCSS=function(a){for(var s=arguments.length,C=Array(s>1?s-1:0),I=1;Ih?S=1:S=Math.round(w*100/h)/100,s.a!==S)return{h:s.h,s:s.s,l:s.l,a:S,source:"rgb"}}else{var R=void 0;if(b<0?R=0:b>d?R=1:R=Math.round(b*100/d)/100,I!==R)return{h:s.h,s:s.s,l:s.l,a:R,source:"rgb"}}return null},UQ={},KGt=function(a,s,C,I){if(typeof document>"u"&&!I)return null;var A=I?new I:document.createElement("canvas");A.width=C*2,A.height=C*2;var d=A.getContext("2d");return d?(d.fillStyle=a,d.fillRect(0,0,A.width,A.height),d.fillStyle=s,d.fillRect(0,0,C,C),d.translate(C,C),d.fillRect(0,0,C,C),A.toDataURL()):null},_Gt=function(a,s,C,I){var A=a+"-"+s+"-"+C+(I?"-server":"");if(UQ[A])return UQ[A];var d=KGt(a,s,C,I);return UQ[A]=d,d},yGe=Object.assign||function(g){for(var a=1;a-1},nSt=function(a){return Number(String(a).replace(/%/g,""))},rSt=1,nr=function(g){$Gt(a,g);function a(s){QGt(this,a);var C=jGt(this,(a.__proto__||Object.getPrototypeOf(a)).call(this));return C.handleBlur=function(){C.state.blurValue&&C.setState({value:C.state.blurValue,blurValue:null})},C.handleChange=function(I){C.setUpdatedValue(I.target.value,I)},C.handleKeyDown=function(I){var A=nSt(I.target.value);if(!isNaN(A)&&iSt(I.keyCode)){var d=C.getArrowOffset(),h=I.keyCode===ZGe?A+d:A-d;C.setUpdatedValue(h,I)}},C.handleDrag=function(I){if(C.props.dragLabel){var A=Math.round(C.props.value+I.movementX);A>=0&&A<=C.props.dragMax&&C.props.onChange&&C.props.onChange(C.getValueObjectWithLabel(A),I)}},C.handleMouseDown=function(I){C.props.dragLabel&&(I.preventDefault(),C.handleDrag(I),window.addEventListener("mousemove",C.handleDrag),window.addEventListener("mouseup",C.handleMouseUp))},C.handleMouseUp=function(){C.unbindEventListeners()},C.unbindEventListeners=function(){window.removeEventListener("mousemove",C.handleDrag),window.removeEventListener("mouseup",C.handleMouseUp)},C.state={value:String(s.value).toUpperCase(),blurValue:String(s.value).toUpperCase()},C.inputId="rc-editable-input-"+rSt++,C}return JGt(a,[{key:"componentDidUpdate",value:function(C,I){this.props.value!==this.state.value&&(C.value!==this.props.value||I.value!==this.state.value)&&(this.input===document.activeElement?this.setState({blurValue:String(this.props.value).toUpperCase()}):this.setState({value:String(this.props.value).toUpperCase(),blurValue:!this.state.blurValue&&String(this.props.value).toUpperCase()}))}},{key:"componentWillUnmount",value:function(){this.unbindEventListeners()}},{key:"getValueObjectWithLabel",value:function(C){return UGt({},this.props.label,C)}},{key:"getArrowOffset",value:function(){return this.props.arrowOffset||qGt}},{key:"setUpdatedValue",value:function(C,I){var A=this.props.label?this.getValueObjectWithLabel(C):C;this.props.onChange&&this.props.onChange(A,I),this.setState({value:C})}},{key:"render",value:function(){var C=this,I=An({default:{wrap:{position:"relative"}},"user-override":{wrap:this.props.style&&this.props.style.wrap?this.props.style.wrap:{},input:this.props.style&&this.props.style.input?this.props.style.input:{},label:this.props.style&&this.props.style.label?this.props.style.label:{}},"dragLabel-true":{label:{cursor:"ew-resize"}}},{"user-override":!0},this.props);return X.default.createElement("div",{style:I.wrap},X.default.createElement("input",{id:this.inputId,style:I.input,ref:function(d){return C.input=d},value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,onBlur:this.handleBlur,placeholder:this.props.placeholder,spellCheck:"false"}),this.props.label&&!this.props.hideLabel?X.default.createElement("label",{htmlFor:this.inputId,style:I.label,onMouseDown:this.handleMouseDown},this.props.label):null)}}]),a}(F.PureComponent||F.Component),gSt=function(a,s,C,I){var A=I.clientWidth,d=I.clientHeight,h=typeof a.pageX=="number"?a.pageX:a.touches[0].pageX,y=typeof a.pageY=="number"?a.pageY:a.touches[0].pageY,Z=h-(I.getBoundingClientRect().left+window.pageXOffset),b=y-(I.getBoundingClientRect().top+window.pageYOffset);if(s==="vertical"){var w=void 0;if(b<0)w=359;else if(b>d)w=0;else{var S=-(b*100/d)+100;w=360*S/100}if(C.h!==w)return{h:w,s:C.s,l:C.l,a:C.a,source:"hsl"}}else{var R=void 0;if(Z<0)R=0;else if(Z>A)R=359;else{var H=Z*100/A;R=360*H/100}if(C.h!==R)return{h:R,s:C.s,l:C.l,a:C.a,source:"hsl"}}return null},oSt=function(){function g(a,s){for(var C=0;C0){if(++a>=fSt)return arguments[0]}else a=0;return g.apply(void 0,arguments)}}var ySt=bSt(hSt);const vSt=ySt;function ZSt(g,a){return vSt(ASt(g,a,iD),g+"")}function BSt(g,a,s){if(!Sl(s))return!1;var C=typeof a;return(C=="number"?X1(s)&&ZQ(a,s.length):C=="string"&&a in s)?oR(s[a],g):!1}function GSt(g){return ZSt(function(a,s){var C=-1,I=s.length,A=I>1?s[I-1]:void 0,d=I>2?s[2]:void 0;for(A=g.length>3&&typeof A=="function"?(I--,A):void 0,d&&BSt(s[0],s[1],d)&&(A=I<3?void 0:A,I=1),a=Object(a);++C=a||ie<0||w&&te>=A}function M(){var j=qQ();if(D(j))return z(j);h=setTimeout(M,N(j))}function z(j){return h=void 0,S&&C?R(j):(C=I=void 0,d)}function K(){h!==void 0&&clearTimeout(h),Z=0,C=y=I=h=void 0}function P(){return h===void 0?d:z(qQ())}function J(){var j=qQ(),ie=D(j);if(C=arguments,I=this,y=j,ie){if(h===void 0)return H(y);if(w)return clearTimeout(h),h=setTimeout(M,a),R(y)}return h===void 0&&(h=setTimeout(M,a)),d}return J.cancel=K,J.flush=P,J}var MSt="Expected a function";function FSt(g,a,s){var C=!0,I=!0;if(typeof g!="function")throw new TypeError(MSt);return Sl(s)&&(C="leading"in s?!!s.leading:C,I="trailing"in s?!!s.trailing:I),RGe(g,a,{leading:C,maxWait:a,trailing:I})}var YSt=function(a,s,C){var I=C.getBoundingClientRect(),A=I.width,d=I.height,h=typeof a.pageX=="number"?a.pageX:a.touches[0].pageX,y=typeof a.pageY=="number"?a.pageY:a.touches[0].pageY,Z=h-(C.getBoundingClientRect().left+window.pageXOffset),b=y-(C.getBoundingClientRect().top+window.pageYOffset);Z<0?Z=0:Z>A&&(Z=A),b<0?b=0:b>d&&(b=d);var w=Z/A,S=1-b/d;return{h:s.h,s:w,v:S,a:s.a,source:"hsv"}},KSt=function(){function g(a,s){for(var C=0;C=0,I=!a&&C&&(g==="hex"||g==="hex6"||g==="hex3"||g==="hex4"||g==="hex8"||g==="name");return I?g==="name"&&this._a===0?this.toName():this.toRgbString():(g==="rgb"&&(s=this.toRgbString()),g==="prgb"&&(s=this.toPercentageRgbString()),(g==="hex"||g==="hex6")&&(s=this.toHexString()),g==="hex3"&&(s=this.toHexString(!0)),g==="hex4"&&(s=this.toHex8String(!0)),g==="hex8"&&(s=this.toHex8String()),g==="name"&&(s=this.toName()),g==="hsl"&&(s=this.toHslString()),g==="hsv"&&(s=this.toHsvString()),s||this.toHexString())},clone:function(){return Di(this.toString())},_applyModification:function(g,a){var s=g.apply(null,[this].concat([].slice.call(a)));return this._r=s._r,this._g=s._g,this._b=s._b,this.setAlpha(s._a),this},lighten:function(){return this._applyModification(nwt,arguments)},brighten:function(){return this._applyModification(rwt,arguments)},darken:function(){return this._applyModification(gwt,arguments)},desaturate:function(){return this._applyModification(ewt,arguments)},saturate:function(){return this._applyModification(twt,arguments)},greyscale:function(){return this._applyModification(iwt,arguments)},spin:function(){return this._applyModification(owt,arguments)},_applyCombination:function(g,a){return g.apply(null,[this].concat([].slice.call(a)))},analogous:function(){return this._applyCombination(Iwt,arguments)},complement:function(){return this._applyCombination(awt,arguments)},monochromatic:function(){return this._applyCombination(lwt,arguments)},splitcomplement:function(){return this._applyCombination(swt,arguments)},triad:function(){return this._applyCombination(NGe,[3])},tetrad:function(){return this._applyCombination(NGe,[4])}},Di.fromRatio=function(g,a){if(typeof g=="object"){var s={};for(var C in g)g.hasOwnProperty(C)&&(C==="a"?s[C]=g[C]:s[C]=fR(g[C]));g=s}return Di(g,a)};function USt(g){var a={r:0,g:0,b:0},s=1,C=null,I=null,A=null,d=!1,h=!1;return typeof g=="string"&&(g=dwt(g)),typeof g=="object"&&(oh(g.r)&&oh(g.g)&&oh(g.b)?(a=QSt(g.r,g.g,g.b),d=!0,h=String(g.r).substr(-1)==="%"?"prgb":"rgb"):oh(g.h)&&oh(g.s)&&oh(g.v)?(C=fR(g.s),I=fR(g.v),a=$St(g.h,C,I),d=!0,h="hsv"):oh(g.h)&&oh(g.s)&&oh(g.l)&&(C=fR(g.s),A=fR(g.l),a=jSt(g.h,C,A),d=!0,h="hsl"),g.hasOwnProperty("a")&&(s=g.a)),s=kGe(s),{ok:d,format:g.format||h,r:Math.min(255,Math.max(a.r,0)),g:Math.min(255,Math.max(a.g,0)),b:Math.min(255,Math.max(a.b,0)),a:s}}function QSt(g,a,s){return{r:Eg(g,255)*255,g:Eg(a,255)*255,b:Eg(s,255)*255}}function VGe(g,a,s){g=Eg(g,255),a=Eg(a,255),s=Eg(s,255);var C=Math.max(g,a,s),I=Math.min(g,a,s),A,d,h=(C+I)/2;if(C==I)A=d=0;else{var y=C-I;switch(d=h>.5?y/(2-C-I):y/(C+I),C){case g:A=(a-s)/y+(a1&&(w-=1),w<1/6?Z+(b-Z)*6*w:w<1/2?b:w<2/3?Z+(b-Z)*(2/3-w)*6:Z}if(a===0)C=I=A=s;else{var h=s<.5?s*(1+a):s+a-s*a,y=2*s-h;C=d(y,h,g+1/3),I=d(y,h,g),A=d(y,h,g-1/3)}return{r:C*255,g:I*255,b:A*255}}function EGe(g,a,s){g=Eg(g,255),a=Eg(a,255),s=Eg(s,255);var C=Math.max(g,a,s),I=Math.min(g,a,s),A,d,h=C,y=C-I;if(d=C===0?0:y/C,C==I)A=0;else{switch(C){case g:A=(a-s)/y+(a>1)+720)%360;--a;)C.h=(C.h+I)%360,A.push(Di(C));return A}function lwt(g,a){a=a||6;for(var s=Di(g).toHsv(),C=s.h,I=s.s,A=s.v,d=[],h=1/a;a--;)d.push(Di({h:C,s:I,v:A})),A=(A+h)%1;return d}Di.mix=function(g,a,s){s=s===0?0:s||50;var C=Di(g).toRgb(),I=Di(a).toRgb(),A=s/100,d={r:(I.r-C.r)*A+C.r,g:(I.g-C.g)*A+C.g,b:(I.b-C.b)*A+C.b,a:(I.a-C.a)*A+C.a};return Di(d)},Di.readability=function(g,a){var s=Di(g),C=Di(a);return(Math.max(s.getLuminance(),C.getLuminance())+.05)/(Math.min(s.getLuminance(),C.getLuminance())+.05)},Di.isReadable=function(g,a,s){var C=Di.readability(g,a),I,A;switch(A=!1,I=hwt(s),I.level+I.size){case"AAsmall":case"AAAlarge":A=C>=4.5;break;case"AAlarge":A=C>=3;break;case"AAAsmall":A=C>=7;break}return A},Di.mostReadable=function(g,a,s){var C=null,I=0,A,d,h,y;s=s||{},d=s.includeFallbackColors,h=s.level,y=s.size;for(var Z=0;ZI&&(I=A,C=Di(a[Z]));return Di.isReadable(g,C,{level:h,size:y})||!d?C:(s.includeFallbackColors=!1,Di.mostReadable(g,["#fff","#000"],s))};var ej=Di.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},Cwt=Di.hexNames=cwt(ej);function cwt(g){var a={};for(var s in g)g.hasOwnProperty(s)&&(a[g[s]]=s);return a}function kGe(g){return g=parseFloat(g),(isNaN(g)||g<0||g>1)&&(g=1),g}function Eg(g,a){Awt(g)&&(g="100%");var s=uwt(g);return g=Math.min(a,Math.max(0,parseFloat(g))),s&&(g=parseInt(g*a,10)/100),Math.abs(g-a)<1e-6?1:g%a/parseFloat(a)}function uD(g){return Math.min(1,Math.max(0,g))}function wl(g){return parseInt(g,16)}function Awt(g){return typeof g=="string"&&g.indexOf(".")!=-1&&parseFloat(g)===1}function uwt(g){return typeof g=="string"&&g.indexOf("%")!=-1}function pc(g){return g.length==1?"0"+g:""+g}function fR(g){return g<=1&&(g=g*100+"%"),g}function XGe(g){return Math.round(parseFloat(g)*255).toString(16)}function xGe(g){return wl(g)/255}var bc=function(){var g="[-\\+]?\\d+%?",a="[-\\+]?\\d*\\.\\d+%?",s="(?:"+a+")|(?:"+g+")",C="[\\s|\\(]+("+s+")[,|\\s]+("+s+")[,|\\s]+("+s+")\\s*\\)?",I="[\\s|\\(]+("+s+")[,|\\s]+("+s+")[,|\\s]+("+s+")[,|\\s]+("+s+")\\s*\\)?";return{CSS_UNIT:new RegExp(s),rgb:new RegExp("rgb"+C),rgba:new RegExp("rgba"+I),hsl:new RegExp("hsl"+C),hsla:new RegExp("hsla"+I),hsv:new RegExp("hsv"+C),hsva:new RegExp("hsva"+I),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function oh(g){return!!bc.CSS_UNIT.exec(g)}function dwt(g){g=g.replace(LSt,"").replace(JSt,"").toLowerCase();var a=!1;if(ej[g])g=ej[g],a=!0;else if(g=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var s;return(s=bc.rgb.exec(g))?{r:s[1],g:s[2],b:s[3]}:(s=bc.rgba.exec(g))?{r:s[1],g:s[2],b:s[3],a:s[4]}:(s=bc.hsl.exec(g))?{h:s[1],s:s[2],l:s[3]}:(s=bc.hsla.exec(g))?{h:s[1],s:s[2],l:s[3],a:s[4]}:(s=bc.hsv.exec(g))?{h:s[1],s:s[2],v:s[3]}:(s=bc.hsva.exec(g))?{h:s[1],s:s[2],v:s[3],a:s[4]}:(s=bc.hex8.exec(g))?{r:wl(s[1]),g:wl(s[2]),b:wl(s[3]),a:xGe(s[4]),format:a?"name":"hex8"}:(s=bc.hex6.exec(g))?{r:wl(s[1]),g:wl(s[2]),b:wl(s[3]),format:a?"name":"hex"}:(s=bc.hex4.exec(g))?{r:wl(s[1]+""+s[1]),g:wl(s[2]+""+s[2]),b:wl(s[3]+""+s[3]),a:xGe(s[4]+""+s[4]),format:a?"name":"hex8"}:(s=bc.hex3.exec(g))?{r:wl(s[1]+""+s[1]),g:wl(s[2]+""+s[2]),b:wl(s[3]+""+s[3]),format:a?"name":"hex"}:!1}function hwt(g){var a,s;return g=g||{level:"AA",size:"small"},a=(g.level||"AA").toUpperCase(),s=(g.size||"small").toLowerCase(),a!=="AA"&&a!=="AAA"&&(a="AA"),s!=="small"&&s!=="large"&&(s="small"),{level:a,size:s}}var DGe=function(a){var s=["r","g","b","a","h","s","l","v"],C=0,I=0;return OSt(s,function(A){if(a[A]&&(C+=1,isNaN(a[A])||(I+=1),A==="s"||A==="l")){var d=/^\d+%$/;d.test(a[A])&&(I+=1)}}),C===I?a:!1},mR=function(a,s){var C=a.hex?Di(a.hex):Di(a),I=C.toHsl(),A=C.toHsv(),d=C.toRgb(),h=C.toHex();I.s===0&&(I.h=s||0,A.h=s||0);var y=h==="000000"&&d.a===0;return{hsl:I,hex:y?"transparent":"#"+h,rgb:d,hsv:A,oldHue:a.h||s||I.h,source:a.source}},am=function(a){if(a==="transparent")return!0;var s=String(a).charAt(0)==="#"?1:0;return a.length!==4+s&&a.length<7+s&&Di(a).isValid()},tj=function(a){if(!a)return"#fff";var s=mR(a);if(s.hex==="transparent")return"rgba(0,0,0,0.4)";var C=(s.rgb.r*299+s.rgb.g*587+s.rgb.b*114)/1e3;return C>=128?"#000":"#fff"},ij=function(a,s){var C=a.replace("°","");return Di(s+" ("+C+")")._ok},pR=Object.assign||function(g){for(var a=1;a1&&arguments[1]!==void 0?arguments[1]:"span";return function(C){Bwt(I,C);function I(){var A,d,h,y;Zwt(this,I);for(var Z=arguments.length,b=Array(Z),w=0;w=0||Object.prototype.hasOwnProperty.call(g,C)&&(s[C]=g[C]);return s}var dD=24,kwt=PGe.default=function(g){var a=g.fill,s=a===void 0?"currentColor":a,C=g.width,I=C===void 0?dD:C,A=g.height,d=A===void 0?dD:A,h=g.style,y=h===void 0?{}:h,Z=Nwt(g,["fill","width","height","style"]);return OGe.default.createElement("svg",zGe({viewBox:"0 0 "+dD+" "+dD,style:zGe({fill:s,width:I,height:d},y)},Z),OGe.default.createElement("path",{d:"M12,18.17L8.83,15L7.42,16.41L12,21L16.59,16.41L15.17,15M12,5.83L15.17,9L16.58,7.59L12,3L7.41,7.59L8.83,9L12,5.83Z"}))},Xwt=function(){function g(a,s){for(var C=0;C1&&(I.a=1),C.props.onChange({h:C.props.hsl.h,s:C.props.hsl.s,l:C.props.hsl.l,a:Math.round(I.a*100)/100,source:"rgb"},A)):(I.h||I.s||I.l)&&(typeof I.s=="string"&&I.s.includes("%")&&(I.s=I.s.replace("%","")),typeof I.l=="string"&&I.l.includes("%")&&(I.l=I.l.replace("%","")),I.s==1?I.s=.01:I.l==1&&(I.l=.01),C.props.onChange({h:I.h||C.props.hsl.h,s:Number(_Ge(I.s)?C.props.hsl.s:I.s),l:Number(_Ge(I.l)?C.props.hsl.l:I.l),source:"hsl"},A))},C.showHighlight=function(I){I.currentTarget.style.background="#eee"},C.hideHighlight=function(I){I.currentTarget.style.background="transparent"},s.hsl.a!==1&&s.view==="hex"?C.state={view:"rgb"}:C.state={view:s.view},C}return Xwt(a,[{key:"render",value:function(){var C=this,I=An({default:{wrap:{paddingTop:"16px",display:"flex"},fields:{flex:"1",display:"flex",marginLeft:"-6px"},field:{paddingLeft:"6px",width:"100%"},alpha:{paddingLeft:"6px",width:"100%"},toggle:{width:"32px",textAlign:"right",position:"relative"},icon:{marginRight:"-4px",marginTop:"12px",cursor:"pointer",position:"relative"},iconHighlight:{position:"absolute",width:"24px",height:"28px",background:"#eee",borderRadius:"4px",top:"10px",left:"12px",display:"none"},input:{fontSize:"11px",color:"#333",width:"100%",borderRadius:"2px",border:"none",boxShadow:"inset 0 0 0 1px #dadada",height:"21px",textAlign:"center"},label:{textTransform:"uppercase",fontSize:"11px",lineHeight:"11px",color:"#969696",textAlign:"center",display:"block",marginTop:"12px"},svg:{fill:"#333",width:"24px",height:"24px",border:"1px transparent solid",borderRadius:"5px"}},disableAlpha:{alpha:{display:"none"}}},this.props,this.state),A=void 0;return this.state.view==="hex"?A=X.default.createElement("div",{style:I.fields,className:"flexbox-fix"},X.default.createElement("div",{style:I.field},X.default.createElement(nr,{style:{input:I.input,label:I.label},label:"hex",value:this.props.hex,onChange:this.handleChange}))):this.state.view==="rgb"?A=X.default.createElement("div",{style:I.fields,className:"flexbox-fix"},X.default.createElement("div",{style:I.field},X.default.createElement(nr,{style:{input:I.input,label:I.label},label:"r",value:this.props.rgb.r,onChange:this.handleChange})),X.default.createElement("div",{style:I.field},X.default.createElement(nr,{style:{input:I.input,label:I.label},label:"g",value:this.props.rgb.g,onChange:this.handleChange})),X.default.createElement("div",{style:I.field},X.default.createElement(nr,{style:{input:I.input,label:I.label},label:"b",value:this.props.rgb.b,onChange:this.handleChange})),X.default.createElement("div",{style:I.alpha},X.default.createElement(nr,{style:{input:I.input,label:I.label},label:"a",value:this.props.rgb.a,arrowOffset:.01,onChange:this.handleChange}))):this.state.view==="hsl"&&(A=X.default.createElement("div",{style:I.fields,className:"flexbox-fix"},X.default.createElement("div",{style:I.field},X.default.createElement(nr,{style:{input:I.input,label:I.label},label:"h",value:Math.round(this.props.hsl.h),onChange:this.handleChange})),X.default.createElement("div",{style:I.field},X.default.createElement(nr,{style:{input:I.input,label:I.label},label:"s",value:Math.round(this.props.hsl.s*100)+"%",onChange:this.handleChange})),X.default.createElement("div",{style:I.field},X.default.createElement(nr,{style:{input:I.input,label:I.label},label:"l",value:Math.round(this.props.hsl.l*100)+"%",onChange:this.handleChange})),X.default.createElement("div",{style:I.alpha},X.default.createElement(nr,{style:{input:I.input,label:I.label},label:"a",value:this.props.hsl.a,arrowOffset:.01,onChange:this.handleChange})))),X.default.createElement("div",{style:I.wrap,className:"flexbox-fix"},A,X.default.createElement("div",{style:I.toggle},X.default.createElement("div",{style:I.icon,onClick:this.toggleViews,ref:function(h){return C.icon=h}},X.default.createElement(kwt,{style:I.svg,onMouseOver:this.showHighlight,onMouseEnter:this.showHighlight,onMouseOut:this.hideHighlight}))))}}],[{key:"getDerivedStateFromProps",value:function(C,I){return C.hsl.a!==1&&I.view==="hex"?{view:"rgb"}:null}}]),a}(X.default.Component);LGe.defaultProps={view:"hex"};var JGe=function(){var a=An({default:{picker:{width:"12px",height:"12px",borderRadius:"6px",transform:"translate(-6px, -1px)",backgroundColor:"rgb(248, 248, 248)",boxShadow:"0 1px 4px 0 rgba(0, 0, 0, 0.37)"}}});return X.default.createElement("div",{style:a.picker})},Fwt=function(){var a=An({default:{picker:{width:"12px",height:"12px",borderRadius:"6px",boxShadow:"inset 0 0 0 1px #fff",transform:"translate(-6px, -6px)"}}});return X.default.createElement("div",{style:a.picker})},gj=function(a){var s=a.width,C=a.onChange,I=a.disableAlpha,A=a.rgb,d=a.hsl,h=a.hsv,y=a.hex,Z=a.renderers,b=a.styles,w=b===void 0?{}:b,S=a.className,R=S===void 0?"":S,H=a.defaultView,N=An(VI({default:{picker:{width:s,background:"#fff",borderRadius:"2px",boxShadow:"0 0 2px rgba(0,0,0,.3), 0 4px 8px rgba(0,0,0,.3)",boxSizing:"initial",fontFamily:"Menlo"},saturation:{width:"100%",paddingBottom:"55%",position:"relative",borderRadius:"2px 2px 0 0",overflow:"hidden"},Saturation:{radius:"2px 2px 0 0"},body:{padding:"16px 16px 12px"},controls:{display:"flex"},color:{width:"32px"},swatch:{marginTop:"6px",width:"16px",height:"16px",borderRadius:"8px",position:"relative",overflow:"hidden"},active:{absolute:"0px 0px 0px 0px",borderRadius:"8px",boxShadow:"inset 0 0 0 1px rgba(0,0,0,.1)",background:"rgba("+A.r+", "+A.g+", "+A.b+", "+A.a+")",zIndex:"2"},toggles:{flex:"1"},hue:{height:"10px",position:"relative",marginBottom:"8px"},Hue:{radius:"2px"},alpha:{height:"10px",position:"relative"},Alpha:{radius:"2px"}},disableAlpha:{color:{width:"22px"},alpha:{display:"none"},hue:{marginBottom:"0px"},swatch:{width:"10px",height:"10px",marginTop:"0px"}}},w),{disableAlpha:I});return X.default.createElement("div",{style:N.picker,className:"chrome-picker "+R},X.default.createElement("div",{style:N.saturation},X.default.createElement(AD,{style:N.Saturation,hsl:d,hsv:h,pointer:Fwt,onChange:C})),X.default.createElement("div",{style:N.body},X.default.createElement("div",{style:N.controls,className:"flexbox-fix"},X.default.createElement("div",{style:N.color},X.default.createElement("div",{style:N.swatch},X.default.createElement("div",{style:N.active}),X.default.createElement(D1,{renderers:Z}))),X.default.createElement("div",{style:N.toggles},X.default.createElement("div",{style:N.hue},X.default.createElement(M1,{style:N.Hue,hsl:d,pointer:JGe,onChange:C})),X.default.createElement("div",{style:N.alpha},X.default.createElement(QQ,{style:N.Alpha,rgb:A,hsl:d,pointer:JGe,renderers:Z,onChange:C})))),X.default.createElement(LGe,{rgb:A,hsl:d,hex:y,view:H,onChange:C,disableAlpha:I})))};gj.propTypes={width:_.exports.oneOfType([_.exports.string,_.exports.number]),disableAlpha:_.exports.bool,styles:_.exports.object,defaultView:_.exports.oneOf(["hex","rgb","hsl"])},gj.defaultProps={width:225,disableAlpha:!1,styles:{}},EI(gj);var Ywt=function(a){var s=a.color,C=a.onClick,I=C===void 0?function(){}:C,A=a.onSwatchHover,d=a.active,h=An({default:{color:{background:s,width:"15px",height:"15px",float:"left",marginRight:"5px",marginBottom:"5px",position:"relative",cursor:"pointer"},dot:{absolute:"5px 5px 5px 5px",background:tj(s),borderRadius:"50%",opacity:"0"}},active:{dot:{opacity:"1"}},"color-#FFFFFF":{color:{boxShadow:"inset 0 0 0 1px #ddd"},dot:{background:"#000"}},transparent:{dot:{background:"#000"}}},{active:d,"color-#FFFFFF":s==="#FFFFFF",transparent:s==="transparent"});return X.default.createElement(mb,{style:h.color,color:s,onClick:I,onHover:A,focusStyle:{boxShadow:"0 0 4px "+s}},X.default.createElement("div",{style:h.dot}))},Kwt=function(a){var s=a.hex,C=a.rgb,I=a.onChange,A=An({default:{fields:{display:"flex",paddingBottom:"6px",paddingRight:"5px",position:"relative"},active:{position:"absolute",top:"6px",left:"5px",height:"9px",width:"9px",background:s},HEXwrap:{flex:"6",position:"relative"},HEXinput:{width:"80%",padding:"0px",paddingLeft:"20%",border:"none",outline:"none",background:"none",fontSize:"12px",color:"#333",height:"16px"},HEXlabel:{display:"none"},RGBwrap:{flex:"3",position:"relative"},RGBinput:{width:"70%",padding:"0px",paddingLeft:"30%",border:"none",outline:"none",background:"none",fontSize:"12px",color:"#333",height:"16px"},RGBlabel:{position:"absolute",top:"3px",left:"0px",lineHeight:"16px",textTransform:"uppercase",fontSize:"12px",color:"#999"}}}),d=function(y,Z){y.r||y.g||y.b?I({r:y.r||C.r,g:y.g||C.g,b:y.b||C.b,source:"rgb"},Z):I({hex:y.hex,source:"hex"},Z)};return X.default.createElement("div",{style:A.fields,className:"flexbox-fix"},X.default.createElement("div",{style:A.active}),X.default.createElement(nr,{style:{wrap:A.HEXwrap,input:A.HEXinput,label:A.HEXlabel},label:"hex",value:s,onChange:d}),X.default.createElement(nr,{style:{wrap:A.RGBwrap,input:A.RGBinput,label:A.RGBlabel},label:"r",value:C.r,onChange:d}),X.default.createElement(nr,{style:{wrap:A.RGBwrap,input:A.RGBinput,label:A.RGBlabel},label:"g",value:C.g,onChange:d}),X.default.createElement(nr,{style:{wrap:A.RGBwrap,input:A.RGBinput,label:A.RGBlabel},label:"b",value:C.b,onChange:d}))},oj=function(a){var s=a.onChange,C=a.onSwatchHover,I=a.colors,A=a.hex,d=a.rgb,h=a.styles,y=h===void 0?{}:h,Z=a.className,b=Z===void 0?"":Z,w=An(VI({default:{Compact:{background:"#f6f6f6",radius:"4px"},compact:{paddingTop:"5px",paddingLeft:"5px",boxSizing:"initial",width:"240px"},clear:{clear:"both"}}},y)),S=function(H,N){H.hex?am(H.hex)&&s({hex:H.hex,source:"hex"},N):s(H,N)};return X.default.createElement(hR,{style:w.Compact,styles:y},X.default.createElement("div",{style:w.compact,className:"compact-picker "+b},X.default.createElement("div",null,om(I,function(R){return X.default.createElement(Ywt,{key:R,color:R,active:R.toLowerCase()===A,onClick:S,onSwatchHover:C})}),X.default.createElement("div",{style:w.clear})),X.default.createElement(Kwt,{hex:A,rgb:d,onChange:S})))};oj.propTypes={colors:_.exports.arrayOf(_.exports.string),styles:_.exports.object},oj.defaultProps={colors:["#4D4D4D","#999999","#FFFFFF","#F44E3B","#FE9200","#FCDC00","#DBDF00","#A4DD00","#68CCCA","#73D8FF","#AEA1FF","#FDA1FF","#333333","#808080","#cccccc","#D33115","#E27300","#FCC400","#B0BC00","#68BC00","#16A5A5","#009CE0","#7B64FF","#FA28FF","#000000","#666666","#B3B3B3","#9F0500","#C45100","#FB9E00","#808900","#194D33","#0C797D","#0062B1","#653294","#AB149E"],styles:{}},EI(oj);var _wt=function(a){var s=a.hover,C=a.color,I=a.onClick,A=a.onSwatchHover,d={position:"relative",zIndex:"2",outline:"2px solid #fff",boxShadow:"0 0 5px 2px rgba(0,0,0,0.25)"},h=An({default:{swatch:{width:"25px",height:"25px",fontSize:"0"}},hover:{swatch:d}},{hover:s});return X.default.createElement("div",{style:h.swatch},X.default.createElement(mb,{color:C,onClick:I,onHover:A,focusStyle:d}))};const Pwt=JQ(_wt);var aj=function(a){var s=a.width,C=a.colors,I=a.onChange,A=a.onSwatchHover,d=a.triangle,h=a.styles,y=h===void 0?{}:h,Z=a.className,b=Z===void 0?"":Z,w=An(VI({default:{card:{width:s,background:"#fff",border:"1px solid rgba(0,0,0,0.2)",boxShadow:"0 3px 12px rgba(0,0,0,0.15)",borderRadius:"4px",position:"relative",padding:"5px",display:"flex",flexWrap:"wrap"},triangle:{position:"absolute",border:"7px solid transparent",borderBottomColor:"#fff"},triangleShadow:{position:"absolute",border:"8px solid transparent",borderBottomColor:"rgba(0,0,0,0.15)"}},"hide-triangle":{triangle:{display:"none"},triangleShadow:{display:"none"}},"top-left-triangle":{triangle:{top:"-14px",left:"10px"},triangleShadow:{top:"-16px",left:"9px"}},"top-right-triangle":{triangle:{top:"-14px",right:"10px"},triangleShadow:{top:"-16px",right:"9px"}},"bottom-left-triangle":{triangle:{top:"35px",left:"10px",transform:"rotate(180deg)"},triangleShadow:{top:"37px",left:"9px",transform:"rotate(180deg)"}},"bottom-right-triangle":{triangle:{top:"35px",right:"10px",transform:"rotate(180deg)"},triangleShadow:{top:"37px",right:"9px",transform:"rotate(180deg)"}}},y),{"hide-triangle":d==="hide","top-left-triangle":d==="top-left","top-right-triangle":d==="top-right","bottom-left-triangle":d==="bottom-left","bottom-right-triangle":d==="bottom-right"}),S=function(H,N){return I({hex:H,source:"hex"},N)};return X.default.createElement("div",{style:w.card,className:"github-picker "+b},X.default.createElement("div",{style:w.triangleShadow}),X.default.createElement("div",{style:w.triangle}),om(C,function(R){return X.default.createElement(Pwt,{color:R,key:R,onClick:S,onSwatchHover:A})}))};aj.propTypes={width:_.exports.oneOfType([_.exports.string,_.exports.number]),colors:_.exports.arrayOf(_.exports.string),triangle:_.exports.oneOf(["hide","top-left","top-right","bottom-left","bottom-right"]),styles:_.exports.object},aj.defaultProps={width:200,colors:["#B80000","#DB3E00","#FCCB00","#008B02","#006B76","#1273DE","#004DCF","#5300EB","#EB9694","#FAD0C3","#FEF3BD","#C1E1C5","#BEDADC","#C4DEF6","#BED3F3","#D4C4FB"],triangle:"top-left",styles:{}},EI(aj);var zwt=function(a){var s=a.direction,C=An({default:{picker:{width:"18px",height:"18px",borderRadius:"50%",transform:"translate(-9px, -1px)",backgroundColor:"rgb(248, 248, 248)",boxShadow:"0 1px 4px 0 rgba(0, 0, 0, 0.37)"}},vertical:{picker:{transform:"translate(-3px, -9px)"}}},{vertical:s==="vertical"});return X.default.createElement("div",{style:C.picker})},Owt=Object.assign||function(g){for(var a=1;a.5});return X.default.createElement("div",{style:C.picker})},Qwt=function(){var a=An({default:{triangle:{width:0,height:0,borderStyle:"solid",borderWidth:"4px 0 4px 6px",borderColor:"transparent transparent transparent #fff",position:"absolute",top:"1px",left:"1px"},triangleBorder:{width:0,height:0,borderStyle:"solid",borderWidth:"5px 0 5px 8px",borderColor:"transparent transparent transparent #555"},left:{Extend:"triangleBorder",transform:"translate(-13px, -4px)"},leftInside:{Extend:"triangle",transform:"translate(-8px, -5px)"},right:{Extend:"triangleBorder",transform:"translate(20px, -14px) rotate(180deg)"},rightInside:{Extend:"triangle",transform:"translate(-8px, -5px)"}}});return X.default.createElement("div",{style:a.pointer},X.default.createElement("div",{style:a.left},X.default.createElement("div",{style:a.leftInside})),X.default.createElement("div",{style:a.right},X.default.createElement("div",{style:a.rightInside})))},UGe=function(a){var s=a.onClick,C=a.label,I=a.children,A=a.active,d=An({default:{button:{backgroundImage:"linear-gradient(-180deg, #FFFFFF 0%, #E6E6E6 100%)",border:"1px solid #878787",borderRadius:"2px",height:"20px",boxShadow:"0 1px 0 0 #EAEAEA",fontSize:"14px",color:"#000",lineHeight:"20px",textAlign:"center",marginBottom:"10px",cursor:"pointer"}},active:{button:{boxShadow:"0 0 0 1px #878787"}}},{active:A});return X.default.createElement("div",{style:d.button,onClick:s},C||I)},jwt=function(a){var s=a.rgb,C=a.currentColor,I=An({default:{swatches:{border:"1px solid #B3B3B3",borderBottom:"1px solid #F0F0F0",marginBottom:"2px",marginTop:"1px"},new:{height:"34px",background:"rgb("+s.r+","+s.g+", "+s.b+")",boxShadow:"inset 1px 0 0 #000, inset -1px 0 0 #000, inset 0 1px 0 #000"},current:{height:"34px",background:C,boxShadow:"inset 1px 0 0 #000, inset -1px 0 0 #000, inset 0 -1px 0 #000"},label:{fontSize:"14px",color:"#000",textAlign:"center"}}});return X.default.createElement("div",null,X.default.createElement("div",{style:I.label},"new"),X.default.createElement("div",{style:I.swatches},X.default.createElement("div",{style:I.new}),X.default.createElement("div",{style:I.current})),X.default.createElement("div",{style:I.label},"current"))},$wt=function(){function g(a,s){for(var C=0;C100&&(b.a=100),b.a/=100,s({h:I.h,s:I.s,l:I.l,a:b.a,source:"rgb"},w))};return X.default.createElement("div",{style:h.fields,className:"flexbox-fix"},X.default.createElement("div",{style:h.double},X.default.createElement(nr,{style:{input:h.input,label:h.label},label:"hex",value:A.replace("#",""),onChange:y})),X.default.createElement("div",{style:h.single},X.default.createElement(nr,{style:{input:h.input,label:h.label},label:"r",value:C.r,onChange:y,dragLabel:"true",dragMax:"255"})),X.default.createElement("div",{style:h.single},X.default.createElement(nr,{style:{input:h.input,label:h.label},label:"g",value:C.g,onChange:y,dragLabel:"true",dragMax:"255"})),X.default.createElement("div",{style:h.single},X.default.createElement(nr,{style:{input:h.input,label:h.label},label:"b",value:C.b,onChange:y,dragLabel:"true",dragMax:"255"})),X.default.createElement("div",{style:h.alpha},X.default.createElement(nr,{style:{input:h.input,label:h.label},label:"a",value:Math.round(C.a*100),onChange:y,dragLabel:"true",dragMax:"100"})))},n2t=Object.assign||function(g){for(var a=1;a=0||Object.prototype.hasOwnProperty.call(g,C)&&(s[C]=g[C]);return s}var hD=24,C2t=jGe.default=function(g){var a=g.fill,s=a===void 0?"currentColor":a,C=g.width,I=C===void 0?hD:C,A=g.height,d=A===void 0?hD:A,h=g.style,y=h===void 0?{}:h,Z=l2t(g,["fill","width","height","style"]);return qGe.default.createElement("svg",$Ge({viewBox:"0 0 "+hD+" "+hD,style:$Ge({fill:s,width:I,height:d},y)},Z),qGe.default.createElement("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"}))},c2t=function(a){var s=a.color,C=a.onClick,I=C===void 0?function(){}:C,A=a.onSwatchHover,d=a.first,h=a.last,y=a.active,Z=An({default:{color:{width:"40px",height:"24px",cursor:"pointer",background:s,marginBottom:"1px"},check:{color:tj(s),marginLeft:"8px",display:"none"}},first:{color:{overflow:"hidden",borderRadius:"2px 2px 0 0"}},last:{color:{overflow:"hidden",borderRadius:"0 0 2px 2px"}},active:{check:{display:"block"}},"color-#FFFFFF":{color:{boxShadow:"inset 0 0 0 1px #ddd"},check:{color:"#333"}},transparent:{check:{color:"#333"}}},{first:d,last:h,active:y,"color-#FFFFFF":s==="#FFFFFF",transparent:s==="transparent"});return X.default.createElement(mb,{color:s,style:Z.color,onClick:I,onHover:A,focusStyle:{boxShadow:"0 0 4px "+s}},X.default.createElement("div",{style:Z.check},X.default.createElement(C2t,null)))},A2t=function(a){var s=a.onClick,C=a.onSwatchHover,I=a.group,A=a.active,d=An({default:{group:{paddingBottom:"10px",width:"40px",float:"left",marginRight:"10px"}}});return X.default.createElement("div",{style:d.group},om(I,function(h,y){return X.default.createElement(c2t,{key:h,color:h,active:h.toLowerCase()===A,first:y===0,last:y===I.length-1,onClick:s,onSwatchHover:C})}))},cj=function(a){var s=a.width,C=a.height,I=a.onChange,A=a.onSwatchHover,d=a.colors,h=a.hex,y=a.styles,Z=y===void 0?{}:y,b=a.className,w=b===void 0?"":b,S=An(VI({default:{picker:{width:s,height:C},overflow:{height:C,overflowY:"scroll"},body:{padding:"16px 0 6px 16px"},clear:{clear:"both"}}},Z)),R=function(N,D){return I({hex:N,source:"hex"},D)};return X.default.createElement("div",{style:S.picker,className:"swatches-picker "+w},X.default.createElement(hR,null,X.default.createElement("div",{style:S.overflow},X.default.createElement("div",{style:S.body},om(d,function(H){return X.default.createElement(A2t,{key:H.toString(),group:H,active:h,onClick:R,onSwatchHover:A})}),X.default.createElement("div",{style:S.clear})))))};cj.propTypes={width:_.exports.oneOfType([_.exports.string,_.exports.number]),height:_.exports.oneOfType([_.exports.string,_.exports.number]),colors:_.exports.arrayOf(_.exports.arrayOf(_.exports.string)),styles:_.exports.object},cj.defaultProps={width:320,height:240,colors:[[F1[900],F1[700],F1[500],F1[300],F1[100]],[Y1[900],Y1[700],Y1[500],Y1[300],Y1[100]],[K1[900],K1[700],K1[500],K1[300],K1[100]],[_1[900],_1[700],_1[500],_1[300],_1[100]],[P1[900],P1[700],P1[500],P1[300],P1[100]],[z1[900],z1[700],z1[500],z1[300],z1[100]],[O1[900],O1[700],O1[500],O1[300],O1[100]],[L1[900],L1[700],L1[500],L1[300],L1[100]],[J1[900],J1[700],J1[500],J1[300],J1[100]],["#194D33",bR[700],bR[500],bR[300],bR[100]],[U1[900],U1[700],U1[500],U1[300],U1[100]],[Q1[900],Q1[700],Q1[500],Q1[300],Q1[100]],[j1[900],j1[700],j1[500],j1[300],j1[100]],[$1[900],$1[700],$1[500],$1[300],$1[100]],[q1[900],q1[700],q1[500],q1[300],q1[100]],[eB[900],eB[700],eB[500],eB[300],eB[100]],[tB[900],tB[700],tB[500],tB[300],tB[100]],[iB[900],iB[700],iB[500],iB[300],iB[100]],["#000000","#525252","#969696","#D9D9D9","#FFFFFF"]],styles:{}},EI(cj);var Aj=function(a){var s=a.onChange,C=a.onSwatchHover,I=a.hex,A=a.colors,d=a.width,h=a.triangle,y=a.styles,Z=y===void 0?{}:y,b=a.className,w=b===void 0?"":b,S=An(VI({default:{card:{width:d,background:"#fff",border:"0 solid rgba(0,0,0,0.25)",boxShadow:"0 1px 4px rgba(0,0,0,0.25)",borderRadius:"4px",position:"relative"},body:{padding:"15px 9px 9px 15px"},label:{fontSize:"18px",color:"#fff"},triangle:{width:"0px",height:"0px",borderStyle:"solid",borderWidth:"0 9px 10px 9px",borderColor:"transparent transparent #fff transparent",position:"absolute"},triangleShadow:{width:"0px",height:"0px",borderStyle:"solid",borderWidth:"0 9px 10px 9px",borderColor:"transparent transparent rgba(0,0,0,.1) transparent",position:"absolute"},hash:{background:"#F0F0F0",height:"30px",width:"30px",borderRadius:"4px 0 0 4px",float:"left",color:"#98A1A4",display:"flex",alignItems:"center",justifyContent:"center"},input:{width:"100px",fontSize:"14px",color:"#666",border:"0px",outline:"none",height:"28px",boxShadow:"inset 0 0 0 1px #F0F0F0",boxSizing:"content-box",borderRadius:"0 4px 4px 0",float:"left",paddingLeft:"8px"},swatch:{width:"30px",height:"30px",float:"left",borderRadius:"4px",margin:"0 6px 6px 0"},clear:{clear:"both"}},"hide-triangle":{triangle:{display:"none"},triangleShadow:{display:"none"}},"top-left-triangle":{triangle:{top:"-10px",left:"12px"},triangleShadow:{top:"-11px",left:"12px"}},"top-right-triangle":{triangle:{top:"-10px",right:"12px"},triangleShadow:{top:"-11px",right:"12px"}}},Z),{"hide-triangle":h==="hide","top-left-triangle":h==="top-left","top-right-triangle":h==="top-right"}),R=function(N,D){am(N)&&s({hex:N,source:"hex"},D)};return X.default.createElement("div",{style:S.card,className:"twitter-picker "+w},X.default.createElement("div",{style:S.triangleShadow}),X.default.createElement("div",{style:S.triangle}),X.default.createElement("div",{style:S.body},om(A,function(H,N){return X.default.createElement(mb,{key:N,color:H,hex:H,style:S.swatch,onClick:R,onHover:C,focusStyle:{boxShadow:"0 0 4px "+H}})}),X.default.createElement("div",{style:S.hash},"#"),X.default.createElement(nr,{label:null,style:{input:S.input},value:I.replace("#",""),onChange:R}),X.default.createElement("div",{style:S.clear})))};Aj.propTypes={width:_.exports.oneOfType([_.exports.string,_.exports.number]),triangle:_.exports.oneOf(["hide","top-left","top-right"]),colors:_.exports.arrayOf(_.exports.string),styles:_.exports.object},Aj.defaultProps={width:276,colors:["#FF6900","#FCB900","#7BDCB5","#00D084","#8ED1FC","#0693E3","#ABB8C3","#EB144C","#F78DA7","#9900EF"],triangle:"top-left",styles:{}},EI(Aj);var uj=function(a){var s=An({default:{picker:{width:"20px",height:"20px",borderRadius:"22px",border:"2px #fff solid",transform:"translate(-12px, -13px)",background:"hsl("+Math.round(a.hsl.h)+", "+Math.round(a.hsl.s*100)+"%, "+Math.round(a.hsl.l*100)+"%)"}}});return X.default.createElement("div",{style:s.picker})};uj.propTypes={hsl:_.exports.shape({h:_.exports.number,s:_.exports.number,l:_.exports.number,a:_.exports.number})},uj.defaultProps={hsl:{a:1,h:249.94,l:.2,s:.5}};var dj=function(a){var s=An({default:{picker:{width:"20px",height:"20px",borderRadius:"22px",transform:"translate(-10px, -7px)",background:"hsl("+Math.round(a.hsl.h)+", 100%, 50%)",border:"2px white solid"}}});return X.default.createElement("div",{style:s.picker})};dj.propTypes={hsl:_.exports.shape({h:_.exports.number,s:_.exports.number,l:_.exports.number,a:_.exports.number})},dj.defaultProps={hsl:{a:1,h:249.94,l:.2,s:.5}};var u2t=function(a){var s=a.onChange,C=a.rgb,I=a.hsl,A=a.hex,d=a.hsv,h=function(R,H){if(R.hex)am(R.hex)&&s({hex:R.hex,source:"hex"},H);else if(R.rgb){var N=R.rgb.split(",");ij(R.rgb,"rgb")&&s({r:N[0],g:N[1],b:N[2],a:1,source:"rgb"},H)}else if(R.hsv){var D=R.hsv.split(",");ij(R.hsv,"hsv")&&(D[2]=D[2].replace("%",""),D[1]=D[1].replace("%",""),D[0]=D[0].replace("°",""),D[1]==1?D[1]=.01:D[2]==1&&(D[2]=.01),s({h:Number(D[0]),s:Number(D[1]),v:Number(D[2]),source:"hsv"},H))}else if(R.hsl){var M=R.hsl.split(",");ij(R.hsl,"hsl")&&(M[2]=M[2].replace("%",""),M[1]=M[1].replace("%",""),M[0]=M[0].replace("°",""),w[1]==1?w[1]=.01:w[2]==1&&(w[2]=.01),s({h:Number(M[0]),s:Number(M[1]),v:Number(M[2]),source:"hsl"},H))}},y=An({default:{wrap:{display:"flex",height:"100px",marginTop:"4px"},fields:{width:"100%"},column:{paddingTop:"10px",display:"flex",justifyContent:"space-between"},double:{padding:"0px 4.4px",boxSizing:"border-box"},input:{width:"100%",height:"38px",boxSizing:"border-box",padding:"4px 10% 3px",textAlign:"center",border:"1px solid #dadce0",fontSize:"11px",textTransform:"lowercase",borderRadius:"5px",outline:"none",fontFamily:"Roboto,Arial,sans-serif"},input2:{height:"38px",width:"100%",border:"1px solid #dadce0",boxSizing:"border-box",fontSize:"11px",textTransform:"lowercase",borderRadius:"5px",outline:"none",paddingLeft:"10px",fontFamily:"Roboto,Arial,sans-serif"},label:{textAlign:"center",fontSize:"12px",background:"#fff",position:"absolute",textTransform:"uppercase",color:"#3c4043",width:"35px",top:"-6px",left:"0",right:"0",marginLeft:"auto",marginRight:"auto",fontFamily:"Roboto,Arial,sans-serif"},label2:{left:"10px",textAlign:"center",fontSize:"12px",background:"#fff",position:"absolute",textTransform:"uppercase",color:"#3c4043",width:"32px",top:"-6px",fontFamily:"Roboto,Arial,sans-serif"},single:{flexGrow:"1",margin:"0px 4.4px"}}}),Z=C.r+", "+C.g+", "+C.b,b=Math.round(I.h)+"°, "+Math.round(I.s*100)+"%, "+Math.round(I.l*100)+"%",w=Math.round(d.h)+"°, "+Math.round(d.s*100)+"%, "+Math.round(d.v*100)+"%";return X.default.createElement("div",{style:y.wrap,className:"flexbox-fix"},X.default.createElement("div",{style:y.fields},X.default.createElement("div",{style:y.double},X.default.createElement(nr,{style:{input:y.input,label:y.label},label:"hex",value:A,onChange:h})),X.default.createElement("div",{style:y.column},X.default.createElement("div",{style:y.single},X.default.createElement(nr,{style:{input:y.input2,label:y.label2},label:"rgb",value:Z,onChange:h})),X.default.createElement("div",{style:y.single},X.default.createElement(nr,{style:{input:y.input2,label:y.label2},label:"hsv",value:w,onChange:h})),X.default.createElement("div",{style:y.single},X.default.createElement(nr,{style:{input:y.input2,label:y.label2},label:"hsl",value:b,onChange:h})))))},hj=function(a){var s=a.width,C=a.onChange,I=a.rgb,A=a.hsl,d=a.hsv,h=a.hex,y=a.header,Z=a.styles,b=Z===void 0?{}:Z,w=a.className,S=w===void 0?"":w,R=An(VI({default:{picker:{width:s,background:"#fff",border:"1px solid #dfe1e5",boxSizing:"initial",display:"flex",flexWrap:"wrap",borderRadius:"8px 8px 0px 0px"},head:{height:"57px",width:"100%",paddingTop:"16px",paddingBottom:"16px",paddingLeft:"16px",fontSize:"20px",boxSizing:"border-box",fontFamily:"Roboto-Regular,HelveticaNeue,Arial,sans-serif"},saturation:{width:"70%",padding:"0px",position:"relative",overflow:"hidden"},swatch:{width:"30%",height:"228px",padding:"0px",background:"rgba("+I.r+", "+I.g+", "+I.b+", 1)",position:"relative",overflow:"hidden"},body:{margin:"auto",width:"95%"},controls:{display:"flex",boxSizing:"border-box",height:"52px",paddingTop:"22px"},color:{width:"32px"},hue:{height:"8px",position:"relative",margin:"0px 16px 0px 16px",width:"100%"},Hue:{radius:"2px"}}},b));return X.default.createElement("div",{style:R.picker,className:"google-picker "+S},X.default.createElement("div",{style:R.head},y),X.default.createElement("div",{style:R.swatch}),X.default.createElement("div",{style:R.saturation},X.default.createElement(AD,{hsl:A,hsv:d,pointer:uj,onChange:C})),X.default.createElement("div",{style:R.body},X.default.createElement("div",{style:R.controls,className:"flexbox-fix"},X.default.createElement("div",{style:R.hue},X.default.createElement(M1,{style:R.Hue,hsl:A,radius:"4px",pointer:dj,onChange:C}))),X.default.createElement(u2t,{rgb:I,hsl:A,hex:h,hsv:d,onChange:C})))};hj.propTypes={width:_.exports.oneOfType([_.exports.string,_.exports.number]),styles:_.exports.object,header:_.exports.string},hj.defaultProps={width:652,styles:{},header:"Color picker"},EI(hj);let eSe=function(g){o(s,g);var a=l(s);function s(C){var I;T(this,s),I=a.call(this,C);const A=GZ(C.color);return I.state={displayColorPicker:!1,color:{r:A.r,g:A.g,b:A.b,a:A.opacity}},I}return E(s,[{key:"handleClick",value:function(){this.setState(I=>({displayColorPicker:!I.displayColorPicker}))}},{key:"handleClose",value:function(){this.setState({displayColorPicker:!1})}},{key:"handleChange",value:function(I){const A=I.rgb,d=`rgba(${A.r},${A.g},${A.b},${A.a})`;this.props.onChange(d),this.setState({color:I.rgb})}},{key:"render",value:function(){const I=An({default:{color:{width:"32px",height:"14px",borderRadius:"2px",background:`rgba(${this.state.color.r}, ${this.state.color.g}, ${this.state.color.b}, ${this.state.color.a})`},swatch:{padding:"5px",background:"#fff",cursor:"pointer",borderRadius:"1px"},popover:{position:"absolute",zIndex:"2"},cover:{position:"fixed",top:"0px",right:"0px",bottom:"0px",left:"0px"}}});return X.default.createElement("div",null,X.default.createElement("div",{onClick:this.handleClick.bind(this),style:I.swatch},X.default.createElement("div",{style:I.color})),this.state.displayColorPicker?X.default.createElement("div",{style:I.popover},X.default.createElement("div",{onClick:this.handleClose.bind(this),style:I.cover}),X.default.createElement(g2t,{color:this.state.color,onChange:this.handleChange.bind(this)})):null)}}]),s}(X.default.Component);eSe.propTypes={color:_.exports.string,onChange:_.exports.func};let fj=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.state={colors:C.track.options.colorRange.slice()},I}return E(s,[{key:"handleColorsChanged",value:function(I){this.setState({colors:I})}},{key:"handleSubmit",value:function(){const I=this.props.track.options;I.colorRange=this.state.colors,this.props.onSubmit(this.props.track.options)}},{key:"handleAddColor",value:function(){this.setState(I=>({colors:I.colors.concat(I.colors[I.colors.length-1])}))}},{key:"handleRemoveColor",value:function(I){this.setState(A=>({colors:A.colors.slice(0,I).concat(A.colors.slice(I+1))}))}},{key:"render",value:function(){const I=JSON.parse(JSON.stringify(this.props.track)),A=Object.assign(I,{options:{colorRange:this.state.colors}}),d={editable:!1,zoomFixed:!0,views:[{uid:`hmo-${this.props.track.uid}`,initialXDomain:this.props.xScale?this.props.xScale.domain():[0,1],initialYDomain:this.props.yScale?this.props.yScale.domain():[0,1],tracks:{center:[A]},layout:{x:0,y:0,h:12,w:12,i:`hmo-${this.props.track.id}`}}]},h=this.state.colors.map((Z,b)=>{const w=this.state.colors.length>2&&b===this.state.colors.length-1?X.default.createElement("div",{onClick:()=>this.handleRemoveColor(b),style:{background:"white",position:"absolute",top:0,right:0,opacity:1,width:14,height:14,borderRadius:2,cursor:"pointer"}},X.default.createElement("svg",{height:"10px",style:{position:"absolute",top:2,right:2,opacity:.5,width:10,height:10}},X.default.createElement("use",{xlinkHref:"#cross"}))):null;return X.default.createElement("div",{key:`l${b}`,style:{borderRadius:"1px",boxShadow:"0 0 0 1px #E5E5E5",position:"relative",outline:"none"}},w,X.default.createElement(eSe,{key:b,color:this.state.colors[b],onChange:S=>{this.setState(R=>{const H=R.colors.slice();return H[b]=S,{colors:H}},()=>{this.handleColorsChanged(this.state.colors)})}}))}).reverse(),y=this.state.colors.length<10?X.default.createElement("div",{onClick:this.handleAddColor.bind(this),style:{position:"relative",outline:"none",height:"25px",padding:"5px",background:"#fff",borderRadius:"1px",boxShadow:"0 0 0 1px #E5E5E5",cursor:"pointer"}},X.default.createElement("div",{style:{textAlign:"center",width:"32px",height:"14px"}},X.default.createElement("svg",{height:"100%",style:{opacity:.5,margin:"auto",display:"block"},width:"10px"},X.default.createElement("use",{xlinkHref:"#plus"})))):null;return X.default.createElement(eR,{okayTitle:"Submit",onCancel:this.props.onCancel,onOkay:this.handleSubmit.bind(this),title:"Custom Color Map"},X.default.createElement("table",{className:"table-track-options"},X.default.createElement("thead",null),X.default.createElement("tbody",{style:{verticalAlign:"top"}},X.default.createElement("tr",null,X.default.createElement("td",{className:"td-track-options"},X.default.createElement("table",null,X.default.createElement("tbody",null,X.default.createElement("tr",null,X.default.createElement("td",{className:"td-track-options"},"Preview")),X.default.createElement("tr",null,X.default.createElement("td",{className:"td-track-options"},X.default.createElement("div",{style:{width:200}},X.default.createElement(kD,{options:{bounded:!1},viewConfig:d}))))))),X.default.createElement("td",{className:"td-track-options"},X.default.createElement("table",null,X.default.createElement("tbody",null,X.default.createElement("tr",null,X.default.createElement("td",{className:"td-track-options"},"Colors")),X.default.createElement("tr",null,X.default.createElement("td",{className:"td-track-options"},y,X.default.createElement("div",{style:{position:"relative"}},h))))))))))}}]),s}(X.default.Component);fj.propTypes={handleCancel:_.exports.func,onCancel:_.exports.func,onSubmit:_.exports.func,track:_.exports.object,xScale:_.exports.object,yScale:_.exports.object};const tSe=g=>{if(!g.header)return[];const a=g.header.split(" "),s=[];for(let C=0;Cg.reduce((C,I)=>(C[I]={name:`${I*s}${a}`,value:I},C),{}),Tl={yes:{name:"Yes",value:!0},no:{name:"No",value:!1}},Pg={black:{name:"Black",value:"black"},blue:{name:"Blue",value:"blue"},brown:{name:"Brown",value:"brown"},cyan:{name:"Cyan",value:"cyan"},green:{name:"Green",value:"green"},grey:{name:"Grey",value:"grey"},orange:{name:"Orange",value:"orange"},purple:{name:"Purple",value:"purple"},turquoise:{name:"Turquoise",value:"turquoise"},red:{name:"Red",value:"red"},white:{name:"White",value:"white"}},d2t={use_stroke:{name:"Glyph color",value:"[glyph-color]"}},vR=nB([1,2,3,5,8,13,21]),h2t=Object.assign(vR,{none:{name:"none",value:"none"}}),fD=nB([0,2,4,8,16,32,64,128,256]),sm=nB([0,.2,.4,.6,.8,1],"%",100),f2t=nB([.2,.4,.6,.8,1],"%",100),qa={axisLabelFormatting:{name:"Axis Label Formatting",inlineOptions:{normal:{name:"normal",value:"normal"},scientific:{name:"scientific",value:"scientific"}}},flipDiagonal:{name:"Flip Across Diagonal",inlineOptions:{none:{name:"No",value:"none"},yes:{name:"Yes",value:"yes"},copy:{name:"Copy",value:"copy"}}},heatmapValueScaling:{name:"Value Scaling",inlineOptions:{linear:{name:"Linear",value:"linear"},log:{name:"Log",value:"log"}}},valueScaling:{name:"Value Scaling",inlineOptions:{linear:{name:"Linear",value:"linear"},log:{name:"Log",value:"log"}}},extent:{name:"Extent",inlineOptions:{full:{name:"Full",value:"full"},upperRight:{name:"Upper Right",value:"upper-right"},lowerLeft:{name:"Lower Left",value:"lower-left"}}},labelLeftMargin:{name:"Label Left Margin",inlineOptions:fD},labelRightMargin:{name:"Label Right Margin",inlineOptions:fD},labelTopMargin:{name:"Label Top Margin",inlineOptions:fD},labelBottomMargin:{name:"Label Bottom Margin",inlineOptions:fD},labelShowResolution:{name:"Label Show Resolution",inlineOptions:Tl},labelShowAssembly:{name:"Label Show Assembly",inlineOptions:Tl},lineStrokeWidth:{name:"Stroke Width",inlineOptions:vR},strokeWidth:{name:"Stroke Width",inlineOptions:vR},trackBorderWidth:{name:"Track Border Width",inlineOptions:vR},separatePlusMinusStrands:{name:"Separate +/- strands",inlineOptions:Tl},sortLargestOnTop:{name:"Sort Largest On Top",inlineOptions:Tl},showTexts:{name:"Show texts",inlineOptions:Tl},staggered:{name:"Staggered",inlineOptions:Tl},minSquareSize:{name:"Minimum size",inlineOptions:h2t},pointSize:{name:"Point Size",inlineOptions:vR},pointColor:{name:"Point Color",inlineOptions:Pg},trackBorderColor:{name:"Track Border Color",inlineOptions:Pg},backgroundColor:{name:"Background Color",inlineOptions:{white:{name:"White",value:"white"},lightGrey:{name:"Light Grey",value:"#eeeeee"},grey:{name:"Grey",value:"#cccccc"},black:{name:"Black",value:"black"},transparent:{name:"Transparent",value:"transparent"}}},colorScale:{name:"Color Scale",inlineOptions:{epilogos:{name:"Epilogos",values:["#FF0000","#FF4500","#32CD32","#008000","#006400","#C2E105","#FFFF00","#66CDAA","#8A91D0","#CD5C5C","#E9967A","#BDB76B","#808080","#C0C0C0","#FFFFFF"]},category10:{name:"D3 Category10",values:["#1F77B4","#FF7F0E","#2CA02C","#D62728","#9467BD","#8C564B","#E377C2","#7F7F7F","#BCBD22","#17BECF"]}}},minusStrandColor:{name:"- Strand Color",inlineOptions:Pg},plusStrandColor:{name:"+ Strand Color",inlineOptions:Pg},lineStrokeColor:{name:"Stroke color",inlineOptions:Pg},projectionStrokeColor:{name:"Stroke color",inlineOptions:Pg},projectionFillColor:{name:"Fill color",inlineOptions:Pg},stroke:{name:"Stroke Color",inlineOptions:Pg},strokeColor:{name:"Stroke color",inlineOptions:Pg},fill:{name:"Fill Color",inlineOptions:Pg},color:{name:"Color",inlineOptions:Pg},fontColor:{name:"Font color",inlineOptions:Pg},fillColor:{name:"Fill color",inlineOptions:Pg},barFillColor:{name:"Fill color",inlineOptions:Pg},barFillColorTop:{name:"Top Fill color",inlineOptions:Pg},barFillColorBottom:{name:"Bottom Fill color",inlineOptions:Pg},barOpacity:{name:"Bar opacity",inlineOptions:sm},zeroLineVisible:{name:"Zero line visible",inlineOptions:Tl},zeroLineColor:{name:"Zero line color",inlineOptions:Pg},zeroLineOpacity:{name:"Zero line opacity",inlineOptions:f2t},fillOpacity:{name:"Fill Opacity",inlineOptions:sm},strokeOpacity:{name:"Stroke Opacity",inlineOptions:sm},strokePos:{name:"Stroke Position",inlineOptions:{aroundInner:{name:"Around Inner",value:"around"},aroundCenter:{name:"Around Center",value:null},hidden:{name:"Hidden",value:"hidden"},top:{name:"Top",value:"top"},right:{name:"Right",value:"right"},bottom:{name:"Bottom",value:"bottom"},left:{name:"Left",value:"left"}}},barBorder:{name:"Bar border",inlineOptions:Tl},scaledHeight:{name:"Scaled height",inlineOptions:Tl},rectangleDomainStrokeColor:{name:"Stroke color",inlineOptions:Pg},rectangleDomainFillColor:{name:"Fill color",inlineOptions:Pg},rectangleDomainFillOpacity:{name:"Fill opacity",inlineOptions:sm},rectangleDomainOpacity:{name:"Opacity",inlineOptions:sm},mapboxStyle:{name:"Map style",inlineOptions:{streets:{name:"streets",value:"mapbox.streets"},light:{name:"light",value:"mapbox.light"},dark:{name:"dark",value:"mapbox.dark"},satellite:{name:"satellite",value:"mapbox.satellite"},"streets-satellite":{name:"streets-satellite",value:"mapbox.streets-satellite"},wheatpaste:{name:"wheatpaste",value:"mapbox.wheatpaste"},"streets-basic":{name:"streets-basic",value:"mapbox.streets-basic"},comic:{name:"comic",value:"mapbox.comic"},outdoors:{name:"outdoors",value:"mapbox.outdoors"},"run-bike-hike":{name:"run-bike-hike",value:"mapbox.run-bike-hike"},pencil:{name:"pencil",value:"mapbox.pencil"},pirates:{name:"pirates",value:"mapbox.pirates"},emerald:{name:"emerald",value:"mapbox.emerald"},"high-contrast":{name:"high-contrast",value:"mapbox.high-contrast"}}},oneDHeatmapFlipped:{name:"Flip Heatmap",inlineOptions:{yes:{name:"Yes",value:"yes"},no:{name:"No",value:null}}},showMousePosition:{name:"Show Mouse Position",inlineOptions:Tl},showTooltip:{name:"Show Tooltip",inlineOptions:Tl},fontSize:{name:"Font Size",inlineOptions:nB([8,9,10,11,12,14,16,18,24],"px")},tickPositions:{name:"Tick Positions",inlineOptions:{even:{name:"Even",value:"even"},ends:{name:"Ends",value:"ends"}}},tickFormat:{name:"Tick Format",inlineOptions:{plain:{name:"Plain",value:"plain"},si:{name:"SI",value:"si"}}},colorEncoding:{name:"Color Encode Annotations",inlineOptions:{none:{name:"None",value:null},itemRgb:{name:"itemRgb",value:"itemRgb"}},generateOptions:tSe},fontIsAligned:{name:"Left-Align Font",inlineOptions:Tl},axisPositionHorizontal:{name:"Axis Position",inlineOptions:{left:{name:"Left",value:"left"},outsideLeft:{name:"Outside left",value:"outsideLeft"},right:{name:"Right",value:"right"},outsideRight:{name:"Outside right",value:"outsideRight"},hidden:{name:"Hidden",value:null}}},axisPositionVertical:{name:"Axis Position",inlineOptions:{top:{name:"Top",value:"top"},outsideTop:{name:"Outside top",value:"outsideTop"},bottom:{name:"Bottom",value:"bottom"},outsideBottom:{name:"Outside bottom",value:"outsideBottom"},hidden:{name:"Hidden",value:null}}},axisMargin:{name:"Axis Margin",inlineOptions:nB([0,10,20,30,40,50,100,200,400],"px")},colorbarPosition:{name:"Colorbar Position",inlineOptions:{topLeft:{name:"Top Left",value:"topLeft"},topRight:{name:"Top Right",value:"topRight"},bottomLeft:{name:"Bottom Left",value:"bottomLeft"},bottomRight:{name:"Bottom Right",value:"bottomRight"},hidden:{name:"Hidden",value:null}}},colorbarBackgroundColor:{name:"Colorbar Background Color",inlineOptions:Pg},colorbarBackgroundOpacity:{name:"Colorbar Background Opacity",inlineOptions:sm},colorbarLabelsPosition:{name:"Colorbar Labels Position",inlineOptions:{inside:{name:"Inside",value:"inside"},outside:{name:"Outside",value:"outside"}}},labelColor:{name:"Label Color",inlineOptions:{...Pg,...d2t}},labelPosition:{name:"Label Position",inlineOptions:{ol:{name:"Outer left",value:"outerLeft"},or:{name:"Outer right",value:"outerRight"},ot:{name:"Outer top",value:"outerTop"},ob:{name:"Outer bottom",value:"outerBottom"},tl:{name:"Top left",value:"topLeft"},tr:{name:"Top right",value:"topRight"},bl:{name:"Bottom left",value:"bottomLeft"},br:{name:"Bottom right",value:"bottomRight"},hidden:{name:"Hidden",value:"hidden"}}},labelTextOpacity:{name:"Label Text Opacity",inlineOptions:sm},geneAnnotationHeight:{name:"Gene Annotation Height",inlineOptions:{8:{name:"8px",value:8},10:{name:"10px",value:10},12:{name:"12px",value:12},16:{name:"16px",value:16}}},annotationHeight:{name:"Annotation Height",inlineOptions:{5:{name:"5px",value:5},8:{name:"8px",value:8},10:{name:"10px",value:10},12:{name:"12px",value:12},16:{name:"16px",value:16},20:{name:"20px",value:20},scaled:{name:"scaled",value:"scaled"}}},maxAnnotationHeight:{name:"Max Annotation Height",inlineOptions:{5:{name:"5px",value:5},8:{name:"8px",value:8},10:{name:"10px",value:10},12:{name:"12px",value:12},16:{name:"16px",value:16},20:{name:"20px",value:20},none:{name:"none",value:null}}},annotationStyle:{name:"Annotation Style",inlineOptions:{box:{name:"Box",value:"box"},segment:{name:"Segment",value:"segment"}}},geneLabelPosition:{name:"Gene Label Position",inlineOptions:{inside:{name:"Inside",value:"inside"},outside:{name:"Outside",value:"outside"}}},geneStrandSpacing:{name:"Gene Strand Spacing",inlineOptions:{2:{name:"2px",value:2},4:{name:"4px",value:4},8:{name:"8px",value:8}}},labelBackgroundColor:{name:"Label Background Color",inlineOptions:Pg},labelBackgroundOpacity:{name:"Label Background Opacity",inlineOptions:sm},viewResolution:{name:"View Resolution",inlineOptions:{high:{name:"High",value:384},medium:{name:"Medium",value:1024},low:{name:"Low",value:2048}}},colorRange:{name:"Color map",inlineOptions:{afmhot:{name:"afmhot",value:["rgba(0,0,0,1.0)","rgba(128,0,0,1.0)","rgba(256,129,1,1.0)","rgba(256,256,129,1.0)","rgba(256,256,256,1.0)"]},fall:{name:"fall",value:["white","rgba(245,166,35,1.0)","rgba(208,2,27,1.0)","black"]},hot:{name:"hot",value:["rgba(10,0,0,1.0)","rgba(179,0,0,1.0)","rgba(256,91,0,1.0)","rgba(256,256,6,1.0)","rgba(256,256,256,1.0)"]},jet:{name:"jet",value:["rgba(0,0,128,1.0)","rgba(0,129,256,1.0)","rgba(125,256,122,1.0)","rgba(256,148,0,1.0)","rgba(128,0,0,1.0)"]},bwr:{name:"bwr",value:["rgba(0,0,256,1.0)","rgba(128,128,256,1.0)","rgba(256,254,254,1.0)","rgba(256,126,126,1.0)","rgba(256,0,0,1.0)"]},cubehelix:{name:"cubehelix",value:["rgba(0,0,0,1.0)","rgba(21,83,76,1.0)","rgba(162,121,74,1.0)","rgba(199,180,238,1.0)","rgba(256,256,256,1.0)"]},rainbow:{name:"rainbow",value:["rgba(128,0,256,1.0)","rgba(0,181,236,1.0)","rgba(129,255,180,1.0)","rgba(256,179,96,1.0)","rgba(256,0,0,1.0)"]},gray:{name:"greys",value:["rgba(255,255,255,1)","rgba(0,0,0,1)"]},red:{name:"White to red",value:["rgba(255,255,255,1)","rgba(255,0,0,1)"]},green:{name:"White to green",value:["rgba(255,255,255,1)","rgba(0,255,0,1)"]},blue:{name:"White to blue",value:["rgba(255,255,255,1)","rgba(0,0,255,1)"]},custard:{name:"custard",value:["#FFFFFF","#F8E71C","rgba(245,166,35,1)","rgba(0,0,0,1)"]},magma:{name:"magma",value:["rgba(0,0,3,1)","rgba(0,0,4,1)","rgba(0,0,6,1)","rgba(1,0,7,1)","rgba(1,1,9,1)","rgba(1,1,11,1)","rgba(2,2,13,1)","rgba(2,2,15,1)","rgba(3,3,17,1)","rgba(4,3,19,1)","rgba(4,4,21,1)","rgba(5,4,23,1)","rgba(6,5,25,1)","rgba(7,5,27,1)","rgba(8,6,29,1)","rgba(9,7,32,1)","rgba(10,7,34,1)","rgba(11,8,36,1)","rgba(12,9,38,1)","rgba(13,10,40,1)","rgba(14,10,42,1)","rgba(15,11,45,1)","rgba(16,12,47,1)","rgba(17,12,49,1)","rgba(19,13,51,1)","rgba(20,13,54,1)","rgba(21,14,56,1)","rgba(22,14,58,1)","rgba(23,15,61,1)","rgba(25,15,63,1)","rgba(26,16,66,1)","rgba(27,16,68,1)","rgba(28,16,70,1)","rgba(30,17,73,1)","rgba(31,17,75,1)","rgba(33,17,78,1)","rgba(34,17,80,1)","rgba(36,17,83,1)","rgba(37,17,85,1)","rgba(39,17,87,1)","rgba(40,17,90,1)","rgba(42,17,92,1)","rgba(43,17,94,1)","rgba(45,17,97,1)","rgba(47,16,99,1)","rgba(49,16,101,1)","rgba(50,16,103,1)","rgba(52,16,105,1)","rgba(54,15,107,1)","rgba(55,15,108,1)","rgba(57,15,110,1)","rgba(59,15,112,1)","rgba(61,15,113,1)","rgba(62,15,114,1)","rgba(64,15,116,1)","rgba(66,15,117,1)","rgba(67,15,118,1)","rgba(69,15,119,1)","rgba(71,15,120,1)","rgba(72,16,120,1)","rgba(74,16,121,1)","rgba(76,16,122,1)","rgba(77,17,123,1)","rgba(79,17,123,1)","rgba(81,18,124,1)","rgba(82,18,124,1)","rgba(84,19,125,1)","rgba(85,20,125,1)","rgba(87,20,126,1)","rgba(88,21,126,1)","rgba(90,21,126,1)","rgba(92,22,127,1)","rgba(93,23,127,1)","rgba(95,23,127,1)","rgba(96,24,128,1)","rgba(98,25,128,1)","rgba(99,25,128,1)","rgba(101,26,128,1)","rgba(103,26,128,1)","rgba(104,27,129,1)","rgba(106,28,129,1)","rgba(107,28,129,1)","rgba(109,29,129,1)","rgba(110,30,129,1)","rgba(112,30,129,1)","rgba(113,31,129,1)","rgba(115,32,129,1)","rgba(117,32,129,1)","rgba(118,33,129,1)","rgba(120,33,129,1)","rgba(121,34,130,1)","rgba(123,35,130,1)","rgba(124,35,130,1)","rgba(126,36,130,1)","rgba(128,36,130,1)","rgba(129,37,129,1)","rgba(131,37,129,1)","rgba(132,38,129,1)","rgba(134,39,129,1)","rgba(136,39,129,1)","rgba(137,40,129,1)","rgba(139,40,129,1)","rgba(140,41,129,1)","rgba(142,41,129,1)","rgba(144,42,129,1)","rgba(145,42,129,1)","rgba(147,43,128,1)","rgba(148,43,128,1)","rgba(150,44,128,1)","rgba(152,44,128,1)","rgba(153,45,128,1)","rgba(155,46,127,1)","rgba(157,46,127,1)","rgba(158,47,127,1)","rgba(160,47,127,1)","rgba(161,48,126,1)","rgba(163,48,126,1)","rgba(165,49,126,1)","rgba(166,49,125,1)","rgba(168,50,125,1)","rgba(170,50,125,1)","rgba(171,51,124,1)","rgba(173,51,124,1)","rgba(175,52,123,1)","rgba(176,52,123,1)","rgba(178,53,123,1)","rgba(180,53,122,1)","rgba(181,54,122,1)","rgba(183,55,121,1)","rgba(185,55,121,1)","rgba(186,56,120,1)","rgba(188,56,120,1)","rgba(189,57,119,1)","rgba(191,57,118,1)","rgba(193,58,118,1)","rgba(194,59,117,1)","rgba(196,59,117,1)","rgba(198,60,116,1)","rgba(199,61,115,1)","rgba(201,61,115,1)","rgba(202,62,114,1)","rgba(204,63,113,1)","rgba(206,63,113,1)","rgba(207,64,112,1)","rgba(209,65,111,1)","rgba(210,66,110,1)","rgba(212,67,110,1)","rgba(213,67,109,1)","rgba(215,68,108,1)","rgba(216,69,107,1)","rgba(218,70,107,1)","rgba(219,71,106,1)","rgba(221,72,105,1)","rgba(222,73,104,1)","rgba(223,74,103,1)","rgba(225,75,103,1)","rgba(226,76,102,1)","rgba(227,78,101,1)","rgba(229,79,100,1)","rgba(230,80,100,1)","rgba(231,81,99,1)","rgba(232,83,98,1)","rgba(233,84,97,1)","rgba(234,85,97,1)","rgba(236,87,96,1)","rgba(237,88,95,1)","rgba(238,90,95,1)","rgba(239,91,94,1)","rgba(239,93,94,1)","rgba(240,95,93,1)","rgba(241,96,93,1)","rgba(242,98,93,1)","rgba(243,100,92,1)","rgba(243,101,92,1)","rgba(244,103,92,1)","rgba(245,105,92,1)","rgba(246,107,92,1)","rgba(246,108,92,1)","rgba(247,110,92,1)","rgba(247,112,92,1)","rgba(248,114,92,1)","rgba(248,116,92,1)","rgba(249,118,92,1)","rgba(249,120,92,1)","rgba(250,121,93,1)","rgba(250,123,93,1)","rgba(250,125,94,1)","rgba(251,127,94,1)","rgba(251,129,95,1)","rgba(251,131,95,1)","rgba(252,133,96,1)","rgba(252,135,97,1)","rgba(252,137,97,1)","rgba(252,139,98,1)","rgba(253,140,99,1)","rgba(253,142,100,1)","rgba(253,144,101,1)","rgba(253,146,102,1)","rgba(253,148,103,1)","rgba(254,150,104,1)","rgba(254,152,105,1)","rgba(254,154,106,1)","rgba(254,156,107,1)","rgba(254,157,108,1)","rgba(254,159,109,1)","rgba(254,161,110,1)","rgba(254,163,111,1)","rgba(254,165,112,1)","rgba(255,167,114,1)","rgba(255,169,115,1)","rgba(255,171,116,1)","rgba(255,172,118,1)","rgba(255,174,119,1)","rgba(255,176,120,1)","rgba(255,178,122,1)","rgba(255,180,123,1)","rgba(255,182,124,1)","rgba(255,184,126,1)","rgba(255,185,127,1)","rgba(255,187,129,1)","rgba(255,189,130,1)","rgba(255,191,132,1)","rgba(255,193,133,1)","rgba(255,195,135,1)","rgba(255,197,136,1)","rgba(255,198,138,1)","rgba(255,200,140,1)","rgba(255,202,141,1)","rgba(255,204,143,1)","rgba(254,206,144,1)","rgba(254,208,146,1)","rgba(254,209,148,1)","rgba(254,211,149,1)","rgba(254,213,151,1)","rgba(254,215,153,1)","rgba(254,217,155,1)","rgba(254,219,156,1)","rgba(254,220,158,1)","rgba(254,222,160,1)","rgba(254,224,162,1)","rgba(254,226,163,1)","rgba(253,228,165,1)","rgba(253,230,167,1)","rgba(253,231,169,1)","rgba(253,233,171,1)","rgba(253,235,172,1)","rgba(253,237,174,1)","rgba(253,239,176,1)","rgba(253,241,178,1)","rgba(253,242,180,1)","rgba(253,244,182,1)","rgba(253,246,184,1)","rgba(252,248,186,1)","rgba(252,250,188,1)","rgba(252,251,189,1)","rgba(252,253,191,1)"]},viridis:{name:"viridis",value:["rgba(68,1,84,1)","rgba(68,2,85,1)","rgba(69,3,87,1)","rgba(69,5,88,1)","rgba(69,6,90,1)","rgba(70,8,91,1)","rgba(70,9,93,1)","rgba(70,11,94,1)","rgba(70,12,96,1)","rgba(71,14,97,1)","rgba(71,15,98,1)","rgba(71,17,100,1)","rgba(71,18,101,1)","rgba(71,20,102,1)","rgba(72,21,104,1)","rgba(72,22,105,1)","rgba(72,24,106,1)","rgba(72,25,108,1)","rgba(72,26,109,1)","rgba(72,28,110,1)","rgba(72,29,111,1)","rgba(72,30,112,1)","rgba(72,32,113,1)","rgba(72,33,115,1)","rgba(72,34,116,1)","rgba(72,36,117,1)","rgba(72,37,118,1)","rgba(72,38,119,1)","rgba(72,39,120,1)","rgba(71,41,121,1)","rgba(71,42,121,1)","rgba(71,43,122,1)","rgba(71,44,123,1)","rgba(71,46,124,1)","rgba(70,47,125,1)","rgba(70,48,126,1)","rgba(70,49,126,1)","rgba(70,51,127,1)","rgba(69,52,128,1)","rgba(69,53,129,1)","rgba(69,54,129,1)","rgba(68,56,130,1)","rgba(68,57,131,1)","rgba(68,58,131,1)","rgba(67,59,132,1)","rgba(67,60,132,1)","rgba(67,62,133,1)","rgba(66,63,133,1)","rgba(66,64,134,1)","rgba(65,65,134,1)","rgba(65,66,135,1)","rgba(65,67,135,1)","rgba(64,69,136,1)","rgba(64,70,136,1)","rgba(63,71,136,1)","rgba(63,72,137,1)","rgba(62,73,137,1)","rgba(62,74,137,1)","rgba(61,75,138,1)","rgba(61,77,138,1)","rgba(60,78,138,1)","rgba(60,79,138,1)","rgba(59,80,139,1)","rgba(59,81,139,1)","rgba(58,82,139,1)","rgba(58,83,139,1)","rgba(57,84,140,1)","rgba(57,85,140,1)","rgba(56,86,140,1)","rgba(56,87,140,1)","rgba(55,88,140,1)","rgba(55,89,140,1)","rgba(54,91,141,1)","rgba(54,92,141,1)","rgba(53,93,141,1)","rgba(53,94,141,1)","rgba(52,95,141,1)","rgba(52,96,141,1)","rgba(51,97,141,1)","rgba(51,98,141,1)","rgba(51,99,141,1)","rgba(50,100,142,1)","rgba(50,101,142,1)","rgba(49,102,142,1)","rgba(49,103,142,1)","rgba(48,104,142,1)","rgba(48,105,142,1)","rgba(47,106,142,1)","rgba(47,107,142,1)","rgba(47,108,142,1)","rgba(46,109,142,1)","rgba(46,110,142,1)","rgba(45,111,142,1)","rgba(45,112,142,1)","rgba(45,112,142,1)","rgba(44,113,142,1)","rgba(44,114,142,1)","rgba(43,115,142,1)","rgba(43,116,142,1)","rgba(43,117,142,1)","rgba(42,118,142,1)","rgba(42,119,142,1)","rgba(41,120,142,1)","rgba(41,121,142,1)","rgba(41,122,142,1)","rgba(40,123,142,1)","rgba(40,124,142,1)","rgba(40,125,142,1)","rgba(39,126,142,1)","rgba(39,127,142,1)","rgba(38,128,142,1)","rgba(38,129,142,1)","rgba(38,130,142,1)","rgba(37,131,142,1)","rgba(37,131,142,1)","rgba(37,132,142,1)","rgba(36,133,142,1)","rgba(36,134,142,1)","rgba(35,135,142,1)","rgba(35,136,142,1)","rgba(35,137,142,1)","rgba(34,138,141,1)","rgba(34,139,141,1)","rgba(34,140,141,1)","rgba(33,141,141,1)","rgba(33,142,141,1)","rgba(33,143,141,1)","rgba(32,144,141,1)","rgba(32,145,140,1)","rgba(32,146,140,1)","rgba(32,147,140,1)","rgba(31,147,140,1)","rgba(31,148,140,1)","rgba(31,149,139,1)","rgba(31,150,139,1)","rgba(31,151,139,1)","rgba(30,152,139,1)","rgba(30,153,138,1)","rgba(30,154,138,1)","rgba(30,155,138,1)","rgba(30,156,137,1)","rgba(30,157,137,1)","rgba(30,158,137,1)","rgba(30,159,136,1)","rgba(30,160,136,1)","rgba(31,161,136,1)","rgba(31,162,135,1)","rgba(31,163,135,1)","rgba(31,163,134,1)","rgba(32,164,134,1)","rgba(32,165,134,1)","rgba(33,166,133,1)","rgba(33,167,133,1)","rgba(34,168,132,1)","rgba(35,169,131,1)","rgba(35,170,131,1)","rgba(36,171,130,1)","rgba(37,172,130,1)","rgba(38,173,129,1)","rgba(39,174,129,1)","rgba(40,175,128,1)","rgba(41,175,127,1)","rgba(42,176,127,1)","rgba(43,177,126,1)","rgba(44,178,125,1)","rgba(46,179,124,1)","rgba(47,180,124,1)","rgba(48,181,123,1)","rgba(50,182,122,1)","rgba(51,183,121,1)","rgba(53,183,121,1)","rgba(54,184,120,1)","rgba(56,185,119,1)","rgba(57,186,118,1)","rgba(59,187,117,1)","rgba(61,188,116,1)","rgba(62,189,115,1)","rgba(64,190,114,1)","rgba(66,190,113,1)","rgba(68,191,112,1)","rgba(70,192,111,1)","rgba(72,193,110,1)","rgba(73,194,109,1)","rgba(75,194,108,1)","rgba(77,195,107,1)","rgba(79,196,106,1)","rgba(81,197,105,1)","rgba(83,198,104,1)","rgba(85,198,102,1)","rgba(88,199,101,1)","rgba(90,200,100,1)","rgba(92,201,99,1)","rgba(94,201,98,1)","rgba(96,202,96,1)","rgba(98,203,95,1)","rgba(101,204,94,1)","rgba(103,204,92,1)","rgba(105,205,91,1)","rgba(108,206,90,1)","rgba(110,206,88,1)","rgba(112,207,87,1)","rgba(115,208,85,1)","rgba(117,208,84,1)","rgba(119,209,82,1)","rgba(122,210,81,1)","rgba(124,210,79,1)","rgba(127,211,78,1)","rgba(129,212,76,1)","rgba(132,212,75,1)","rgba(134,213,73,1)","rgba(137,213,72,1)","rgba(139,214,70,1)","rgba(142,215,68,1)","rgba(144,215,67,1)","rgba(147,216,65,1)","rgba(149,216,63,1)","rgba(152,217,62,1)","rgba(155,217,60,1)","rgba(157,218,58,1)","rgba(160,218,57,1)","rgba(163,219,55,1)","rgba(165,219,53,1)","rgba(168,220,51,1)","rgba(171,220,50,1)","rgba(173,221,48,1)","rgba(176,221,46,1)","rgba(179,221,45,1)","rgba(181,222,43,1)","rgba(184,222,41,1)","rgba(187,223,39,1)","rgba(189,223,38,1)","rgba(192,223,36,1)","rgba(195,224,35,1)","rgba(197,224,33,1)","rgba(200,225,32,1)","rgba(203,225,30,1)","rgba(205,225,29,1)","rgba(208,226,28,1)","rgba(211,226,27,1)","rgba(213,226,26,1)","rgba(216,227,25,1)","rgba(219,227,24,1)","rgba(221,227,24,1)","rgba(224,228,24,1)","rgba(226,228,24,1)","rgba(229,228,24,1)","rgba(232,229,25,1)","rgba(234,229,25,1)","rgba(237,229,26,1)","rgba(239,230,27,1)","rgba(242,230,28,1)","rgba(244,230,30,1)","rgba(247,230,31,1)","rgba(249,231,33,1)","rgba(251,231,35,1)","rgba(254,231,36,1)"]},custom:{name:"Custom...",componentPickers:{heatmap:fj,"horizontal-heatmap":fj}}}},align:{name:"Align",inlineOptions:{white:{name:"Top",value:"top"},lightGrey:{name:"Bottom",value:"bottom"}}},colorRangeGradient:{name:"Color Gradient",inlineOptions:Tl},dataTransform:{name:"Transforms",inlineOptions:{default:{name:"Default",value:"default"},None:{name:"None",value:"None"}},generateOptions:g=>{const a=[];if(g.transforms)for(const s of g.transforms)a.push({name:s.name,value:s.value});return a}},aggregationMode:{name:"Aggregation Mode",inlineOptions:{},generateOptions:g=>{const a=[];return g.aggregationModes?Object.values(g.aggregationModes).forEach(({name:s,value:C})=>{a.push({name:s,value:C})}):a.push({name:"Default",value:"default"}),a}},maxZoom:{name:"Zoom limit",inlineOptions:{none:{name:"None",value:null}},generateOptions:g=>{if(g.maxZoom){const a=[];for(let s=0;s<=g.maxZoom;s++){const{maxWidth:C,binsPerDimension:I,maxZoom:A}=g;let d=1,h=1;if(g.resolutions){const w=g.resolutions.map(S=>+S).sort((S,R)=>R-S);[d]=w,h=w[s]}else h=g.maxWidth/(2**s*g.binsPerDimension),d=C/(2**A*I);const y=VZ(d,h),b=R0(`.${y}`,h)(h);a.push({name:b,value:s.toString()})}return a}return[]}},valueColumn:{name:"Value column",inlineOptions:{none:{name:"None",value:null}},generateOptions:tSe},zeroValueColor:{name:"Zero Value Color",inlineOptions:Pg}};let m2t=function(g){o(s,g);var a=l(s);function s(){return T(this,s),a.apply(this,arguments)}return E(s,[{key:"getConfigureSeriesMenu",value:function(I,A,d){const h={},y=window.higlassTracksByType&&window.higlassTracksByType[d.type]&&window.higlassTracksByType[d.type].config&&window.higlassTracksByType[d.type].config.optionsInfo;if(y)for(const Z of Object.keys(y))qa[Z]=y[Z];if(!Pr[d.type]||!Pr[d.type].availableOptions)return null;for(const Z of Pr[d.type].availableOptions)if(Z in qa){if(h[Z]={name:qa[Z].name},qa[Z].generateOptions){const b=qa[Z].generateOptions(d);h[Z].children||(h[Z].children={});for(const w of b){const S={name:w.name,value:w.value,handler:()=>{d.options[Z]=w.value,this.props.onTrackOptionsChanged(d.uid,d.options),this.props.closeMenu()}};h[Z].children[w.value]=S}}if(qa[Z].inlineOptions)for(const b in qa[Z].inlineOptions){const w=qa[Z].inlineOptions[b];h[Z].children||(h[Z].children={});const S={name:w.name,value:w.value};w.componentPickers&&w.componentPickers[d.type]?S.handler=()=>{this.props.onConfigureTrack(d,w.componentPickers[d.type]),this.props.closeMenu()}:S.handler=()=>{d.options[Z]=w.value,this.props.onTrackOptionsChanged(d.uid,d.options),this.props.closeMenu()},h[Z].children[b]=S}else qa[Z].componentPickers&&qa[Z].componentPickers[d.type]&&(h[Z].handler=()=>{this.props.onConfigureTrack(d,qa[Z].componentPickers[d.type]),this.props.closeMenu()})}return X.default.createElement(vQ,{key:"config-series-menu",closeMenu:this.props.closeMenu,menuItems:h,orientation:this.state.orientation,parentBbox:A,position:I,theme:this.props.theme})}},{key:"getTrackTypeItems",value:function(I,A,d){window.higlassTracksByType&&Object.keys(window.higlassTracksByType).forEach(w=>{Pr[w]=window.higlassTracksByType[w].config});let{datatype:h}=d,y=null;d.type in Pr&&(h||(h=Pr[d.type].datatype[0]),{orientation:y}=Pr[d.type]);const Z=Object.values(Pr).filter(w=>w.datatype).filter(w=>w.orientation).filter(w=>w.datatype.includes(h)).filter(w=>w.orientation===y).map(w=>w.type),b={};for(let w=0;w{this.props.onChangeTrackType(d.uid,Z[w])}};return X.default.createElement(vQ,{key:"track-type-items",closeMenu:this.props.closeMenu,menuItems:b,orientation:this.state.orientation,parentBbox:A,position:I,theme:this.props.theme})}},{key:"getSubmenu",value:function(){if(this.state.submenuShown){const I=this.state.submenuSourceBbox,A=this.state.orientation==="left"?{left:this.state.left,top:I.top}:{left:this.state.left+I.width+7,top:I.top},d=this.state.submenuShown,h=d.value;return d.option==="track-type"?this.getTrackTypeItems(A,I,h):this.getConfigureSeriesMenu(A,I,h)}return X.default.createElement("div",null)}},{key:"getDivideByMenuItem",value:function(){if(this.props.series.data&&this.props.series.data.type==="divided"){const I={tilesetUid:this.props.series.data.children[0].tilesetUid,server:this.props.series.data.children[0].server};return X.default.createElement(Gn,{className:sn["context-menu-item"],onClick:()=>this.props.onChangeTrackData(this.props.series.uid,I),onMouseEnter:A=>this.handleOtherMouseEnter(A)},X.default.createElement("span",{className:sn["context-menu-span"]},"Remove divisor"))}return X.default.createElement(Gn,{className:sn["context-menu-item"],onClick:()=>this.props.onAddDivisor(this.props.series),onMouseEnter:I=>this.handleOtherMouseEnter(I)},X.default.createElement("span",{className:sn["context-menu-span"]},"Divide by"))}},{key:"componentWillUnmount",value:function(){}},{key:"render",value:function(){let I=null;Pr[this.props.series.type]&&Pr[this.props.series.type].exportable&&(I=X.default.createElement(Gn,{className:sn["context-menu-item"],onClick:()=>this.props.onExportData(this.props.hostTrack.uid,this.props.track.uid),onMouseEnter:d=>this.handleOtherMouseEnter(d)},X.default.createElement("span",{className:sn["context-menu-span"]},"Export Data")));const A=this.props.onAddSeries?X.default.createElement(Gn,{className:sn["context-menu-item"],onClick:()=>{this.props.onCloseTrack(this.props.series.uid),this.props.onAddSeries(this.props.hostTrack.uid)},onMouseEnter:d=>this.handleOtherMouseEnter(d)},X.default.createElement("span",{className:sn["context-menu-span"]},"Replace Series")):null;return X.default.createElement("div",{ref:d=>{this.div=d},className:lr(sn["context-menu"],{[sn["context-menu-dark"]]:this.props.theme===ig}),"data-menu-type":"SeriesListMenu",onMouseLeave:this.props.handleMouseLeave,style:{left:this.state.left,top:this.state.top}},X.default.createElement(Gn,{onClick:()=>{},onMouseEnter:d=>this.handleItemMouseEnter(d,{option:"configure-series",value:this.props.track}),onMouseLeave:d=>this.handleMouseLeave(d)},"Configure Series",X.default.createElement("svg",{className:sn["play-icon"]},X.default.createElement("use",{xlinkHref:"#play"}))),X.default.createElement(Gn,{className:sn["context-menu-item"],onClick:()=>{},onMouseEnter:d=>this.handleItemMouseEnter(d,{option:"track-type",value:this.props.track}),onMouseLeave:d=>this.handleMouseLeave(d)},X.default.createElement("span",{className:sn["context-menu-span"]},"Track Type",X.default.createElement("svg",{className:sn["play-icon"]},X.default.createElement("use",{xlinkHref:"#play"})))),I,this.getDivideByMenuItem(),X.default.createElement(Gn,{className:sn["context-menu-item"],onClick:this.props.onCloseTrack,onMouseEnter:d=>this.handleOtherMouseEnter(d)},X.default.createElement("span",{className:sn["context-menu-span"]},"Close Series")),A,this.getSubmenu())}}]),s}(rm);const iSe=g=>{let a=[];for(const s of g)s.contents?a=a.concat(s.contents):a.push(s);return a},mj=(g,a,s,C)=>g?(window.higlassTracksByType&&Object.keys(window.higlassTracksByType).forEach(I=>{Pr[I]=window.higlassTracksByType[I].config}),iSe(g).map(I=>{const A=Pr[I.type]?Pr[I.type].thumbnail:null,d=A?X.default.createElement("div",{className:sn["context-menu-icon"],dangerouslySetInnerHTML:{__html:A.outerHTML}}):X.default.createElement("div",{className:sn["context-menu-icon"]},X.default.createElement("svg",null));return X.default.createElement(Gn,{key:I.uid,className:sn["context-menu-item"],onClick:()=>{C&&C(I.uid)},onMouseEnter:h=>{a&&a(h,I)},onMouseLeave:h=>{s&&s(h)}},d,X.default.createElement("span",{className:sn["context-menu-span"]},I.options&&I.options.name&&I.options.name.length?I.options.name:I.type,a&&s?X.default.createElement("svg",{className:sn["play-icon"]},X.default.createElement("use",{xlinkHref:"#play"})):null))})):null,nSe=ax(g=>function(a){o(C,a);var s=l(C);function C(){return T(this,C),s.apply(this,arguments)}return E(C,[{key:"getSubmenu",value:function(){if(this.state.submenuShown){const A=this.state.submenuSourceBbox;let d=null;this.state.orientation==="left"?d={left:this.state.left,top:A.top}:d={left:this.state.left+A.width+7,top:A.top};const y=iSe(this.props.tracks).filter(b=>b.uid===this.state.submenuShown.uid)[0],Z=y&&y.position!=="whole";return X.default.createElement(m2t,{key:`series-list-menu-${y.uid}`,ref:b=>{this.seriesListMenu=b},closeMenu:this.props.closeMenu,hostTrack:this.props.tracks[0],onAddDivisor:this.props.onAddDivisor,onAddSeries:Z?this.props.onAddSeries:null,onChangeTrackData:this.props.onChangeTrackData,onChangeTrackType:this.props.onChangeTrackType,onCloseTrack:()=>this.props.onCloseTrack(this.state.submenuShown.uid),onConfigureTrack:this.props.onConfigureTrack,onDivideSeries:this.props.onDivideSeries,onExportData:this.props.onExportData,onLockScales:this.props.onLockScales,onTrackOptionsChanged:this.props.onTrackOptionsChanged,orientation:this.state.orientation,parentBbox:A,position:d,series:this.state.submenuShown,theme:this.props.theme,track:y,trackOrientation:this.props.trackOrientation,trackSourceServers:this.props.trackSourceServers})}return X.default.createElement("div",null)}}]),C}(g));let p2t=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.seriesRefs={},I.seriesListMenu=null,I}return E(s,[{key:"componentDidMount",value:function(){n(G(s.prototype),"componentDidMount",this).call(this)}},{key:"render",value:function(){return X.default.createElement("div",{ref:I=>{this.div=I},className:lr(sn["context-menu"],{[sn["context-menu-dark"]]:this.props.theme===ig}),"data-menu-type":"ConfigTrackMenu",style:{left:this.state.left,top:this.state.top}},mj(this.props.tracks,this.handleItemMouseEnter.bind(this),this.handleMouseLeave.bind(this),null),X.default.createElement("hr",{className:sn["context-menu-hr"]}),X.default.createElement(Gn,{contextMenu:this,onClick:()=>this.props.onLockValueScale(this.props.tracks[0].uid),onMouseEnter:I=>this.handleOtherMouseEnter(I)},"Lock Value Scale With"),X.default.createElement(Gn,{contextMenu:this,onClick:()=>this.props.onUnlockValueScale(this.props.tracks[0].uid),onMouseEnter:I=>this.handleOtherMouseEnter(I)},"Unlock Value Scale"),X.default.createElement("hr",{className:sn["context-menu-hr"]}),X.default.createElement(Gn,{contextMenu:this,onClick:()=>this.props.onAddSeries(this.props.tracks[0].uid),onMouseEnter:I=>this.handleOtherMouseEnter(I)},"Add Series"),X.default.createElement(Gn,{onClick:()=>this.props.onCloseTrack(this.props.tracks[0].uid)},"Close Track"),X.default.createElement(Gn,{onClick:()=>{this.props.onReplaceTrack(this.props.tracks[0].uid,this.props.trackOrientation)}},"Replace Track"),this.getSubmenu())}}]),s}(S1(rm).with(nSe));function rSe(g){return X.default.createElement("div",null,mj(g.tracks,null,null,g.onCloseTrack),X.default.createElement("hr",{className:sn["context-menu-hr"]}),X.default.createElement(Gn,{onClick:()=>g.onCloseTrack(g.tracks[0].uid)},"Close all series"))}rSe.propTypes={onCloseTrack:_.exports.func.isRequired,tracks:_.exports.array.isRequired};let Im=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.clickHandlerBound=I.clickHandler.bind(u(I)),I.contextMenuHandlerBound=I.contextMenuHandler.bind(u(I)),I.resizeHandlerBound=I.resizeHandler.bind(u(I)),I}return E(s,[{key:"componentDidMount",value:function(){this.popup=document.createElement("div"),document.body.appendChild(this.popup),this.popup.style.zIndex=99,this.popup.style.position="absolute",this.popup.className="hg-popup",document.addEventListener("click",this.clickHandlerBound,!0),document.addEventListener("contextmenu",this.contextMenuHandlerBound,!0),window.addEventListener("resize",this.resizeHandlerBound,!0),this._renderLayer()}},{key:"componentDidUpdate",value:function(){this._renderLayer()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("click",this.clickHandlerBound,!0),document.removeEventListener("contextmenu",this.contextMenuHandlerBound,!0),window.removeEventListener("resize",this.resizeHandlerBound,!0),$.default.unmountComponentAtNode(this.popup),document.body.removeChild(this.popup)}},{key:"_renderLayer",value:function(){$.default.render(this.props.children,this.popup)}},{key:"clickHandler",value:function(I){this.popup.contains(I.target)||this.props.onMenuClosed&&this.props.onMenuClosed(I)}},{key:"contextMenuHandler",value:function(I){I.altKey||(I.preventDefault(),this.clickHandler(I))}},{key:"resizeHandler",value:function(){this.props.onMenuClosed(null)}},{key:"render",value:function(){return X.default.createElement("div",null)}}]),s}(X.default.Component);Im.defaultProps={onMenuClosed:G0e},Im.propTypes={children:_.exports.node.isRequired,onMenuClosed:_.exports.func};const b2t=Fpe(g=>X.default.createElement(nBe,{className:g.className,controlAlignLeft:g.controlAlignLeft,editable:g.editable,handleConfigTrack:g.handleConfigTrack,handleResizeTrack:g.handleResizeTrack,height:g.height,item:g.item,onAddSeries:g.onAddSeries,onCloseTrack:g.onCloseTrack,onCloseTrackMenuOpened:g.onCloseTrackMenuOpened,onConfigTrackMenuOpened:g.onConfigTrackMenuOpened,resizeHandles:g.resizeHandles,uid:g.uid,width:g.width})),y2t={"vertical-tiled-plot":"_vertical-tiled-plot_f3ho8_1"};function gSe(g){return g&&g.sourceEvent}let pj=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.brushBehavior=E2().on("start",I.brushStarted.bind(u(I))).on("brush",I.brushed.bind(u(I))).on("end",I.brushedEnded.bind(u(I))),I}return E(s,[{key:"componentDidMount",value:function(){this.props.isRangeSelectionActive&&this.addBrush()}},{key:"shouldComponentUpdate",value:function(I,A){if(this.rangeSelectionTriggered)return this.rangeSelectionTriggered=!1,this.rangeSelectionTriggeredEnd&&this.props.rangeSelection!==I.rangeSelection&&this.moveBrush(I.rangeSelection[0]?I.rangeSelection[0]:null,!0),this.rangeSelectionTriggeredEnd=!1,this.state!==A;if(this.props.rangeSelection!==I.rangeSelection){const d=this.props.is1dRangeSelection?0:1;return this.moveBrush(I.rangeSelection[d]?I.rangeSelection[d]:null,I.rangeSelectionEnd),this.state!==A}return!0}},{key:"componentDidUpdate",value:function(){this.props.isRangeSelectionActive?this.addBrush():this.removeBrush()}},{key:"addBrush",value:function(){!this.brushEl||this.brushElAddedBefore===this.brushEl||(this.brushElAddedBefore&&this.brushElAddedBefore.on(".brush",null),this.brushEl.call(this.brushBehavior),this.brushElAddedBefore=this.brushEl,jZ(this.brushEl,ac["track-range-selection-group-brush-selection"]))}},{key:"brushed",value:function(I){const A=this.rangeSelectionMoved;this.rangeSelectionMoved=!1,!(!gSe(I)||!this.props.onRangeSelection||A)&&(this.rangeSelectionTriggered=!0,this.props.onRangeSelection(I.selection))}},{key:"brushStarted",value:function(I){!gSe(I)||!I.selection||this.props.onRangeSelectionStart()}},{key:"brushedEnded",value:function(I){if(!this.props.is1dRangeSelection)return;const A=this.rangeSelectionMovedEnd;this.rangeSelectionMovedEnd=!1,I.selection&&I.sourceEvent&&this.props.onRangeSelection&&!A&&(this.rangeSelectionTriggered=!0,this.rangeSelectionTriggeredEnd=!0,this.props.onRangeSelectionEnd(I.selection)),I.selection||(this.rangeSelectionTriggered=!0,this.props.onRangeSelectionReset())}},{key:"moveBrush",value:function(I,A=!1){if(!this.brushEl)return;const d=I?[this.props.scale(I[0]),this.props.scale(I[1])]:null;this.rangeSelectionMoved=!0,this.rangeSelectionMovedEnd=!0,A?this.brushEl.transition().call(this.brushBehavior.move,d):this.brushEl.call(this.brushBehavior.move,d)}},{key:"removeBrush",value:function(){this.brushElAddedBefore&&(this.brushElAddedBefore.call(this.brushBehavior.move,null),this.brushElAddedBefore.on(".brush",null),this.brushElAddedBefore=void 0,this.props.onRangeSelectionReset())}},{key:"render",value:function(){const I=this.props.tracks.map(h=>h.width).reduce(Mf,0),A=this.props.tracks.map(h=>$2(h)).reduce(Q2,!1),d=ac[this.props.isRangeSelectionActive?"track-range-selection-active":"track-range-selection"];return X.default.createElement("div",{className:y2t["vertical-tiled-plot"]},A&&X.default.createElement("svg",{ref:h=>{this.brushEl=Mn(h)},className:d,style:{height:this.props.height,width:I},xmlns:"http://www.w3.org/2000/svg"}),X.default.createElement(Lx,{axis:"x",className:lr(sc.list,sc.stylizedList,sc.horizontalList),component:tBe,editable:this.props.editable,handleConfigTrack:this.props.handleConfigTrack,handleResizeTrack:this.props.handleResizeTrack,height:this.props.height,helperClass:sc.stylizedHelper,itemClass:lr(sc.stylizedItem,sc.horizontalItem),itemControlAlignLeft:this.props.tracksControlAlignLeft,itemReactClass:b2t,items:this.props.tracks.map(h=>({configMenuVisible:h.uid===this.props.configTrackMenuId,uid:h.uid||Fn.nice(),height:this.props.height,width:h.width,value:h.value})),onAddSeries:this.props.onAddSeries,onCloseTrack:this.props.onCloseTrack,onCloseTrackMenuOpened:this.props.onCloseTrackMenuOpened,onConfigTrackMenuOpened:this.props.onConfigTrackMenuOpened,onSortEnd:this.props.handleSortEnd,referenceAncestor:this.props.referenceAncestor,resizeHandles:this.props.resizeHandles,useDragHandle:!0,width:I}))}}]),s}(X.default.Component);pj.propTypes={configTrackMenuId:_.exports.string,editable:_.exports.bool,handleConfigTrack:_.exports.func,handleResizeTrack:_.exports.func,handleSortEnd:_.exports.func,is1dRangeSelection:_.exports.bool,isRangeSelectionActive:_.exports.bool,height:_.exports.number,onAddSeries:_.exports.func,onCloseTrack:_.exports.func,onCloseTrackMenuOpened:_.exports.func,onConfigTrackMenuOpened:_.exports.func,onRangeSelection:_.exports.func,onRangeSelectionEnd:_.exports.func,onRangeSelectionReset:_.exports.func,onRangeSelectionStart:_.exports.func,rangeSelection:_.exports.array,rangeSelectionEnd:_.exports.bool,referenceAncestor:_.exports.func,resizeHandles:_.exports.object,scale:_.exports.func,tracks:_.exports.array,tracksControlAlignLeft:_.exports.bool};let oSe=function(g){o(s,g);var a=l(s);function s(){return T(this,s),a.apply(this,arguments)}return E(s,[{key:"render",value:function(){const I=mj(this.props.tracks,this.handleItemMouseEnter.bind(this),this.handleMouseLeave.bind(this)),A=this.props.customItems?X.default.Children.map(this.props.customItems,d=>X.default.cloneElement(d,{onMouseEnter:h=>{this.handleOtherMouseEnter(h)}})):null;return X.default.createElement("div",{ref:d=>{this.div=d},className:lr(sn["context-menu"],{[sn["context-menu-dark"]]:this.props.theme===ig}),"data-menu-type":"ViewContextMenu",style:{left:this.state.left,top:this.state.top}},A,A&&X.default.createElement("hr",{className:sn["context-menu-hr"]}),I,I&&X.default.createElement("hr",{className:sn["context-menu-hr"]}),X.default.createElement(Gn,{onClick:()=>this.props.onAddTrack({type:"horizontal-rule",y:this.props.coords[1],position:"whole"}),onMouseEnter:d=>this.handleOtherMouseEnter(d)},"Add Horizontal Rule"),X.default.createElement(Gn,{onClick:()=>this.props.onAddTrack({type:"vertical-rule",x:this.props.coords[0],position:"whole"}),onMouseEnter:d=>this.handleOtherMouseEnter(d)},"Add Vertical Rule"),X.default.createElement(Gn,{onClick:()=>this.props.onAddTrack({type:"cross-rule",x:this.props.coords[0],y:this.props.coords[1],position:"whole"}),onMouseEnter:d=>this.handleOtherMouseEnter(d)},"Add Cross Rule"),X.default.createElement("hr",{className:sn["context-menu-hr"]}),this.hasMatrixTrack(this.props.tracks)&&X.default.createElement(Gn,{onClick:this.handleAddHorizontalSection.bind(this),onMouseEnter:d=>this.handleOtherMouseEnter(d)},"Add Horizontal Cross Section"),this.hasMatrixTrack(this.props.tracks)&&X.default.createElement(Gn,{onClick:this.handleAddVerticalSection.bind(this),onMouseEnter:d=>this.handleOtherMouseEnter(d)},"Add Vertical Cross Section"),this.getSubmenu())}},{key:"hasMatrixTrack",value:function(I){return lX(this.props.tracks).filter(d=>d.type==="heatmap").length>0}},{key:"handleAddHorizontalSection",value:function(){const A=lX(this.props.tracks).filter(d=>d.type==="heatmap")[0];this.props.onAddTrack({type:"horizontal-rule",y:this.props.coords[1],position:"whole"}),this.props.onAddTrack({data:{type:"horizontal-section",server:A.server,tilesetUid:A.tilesetUid,slicePos:this.props.coords[1]},options:{valueScaling:"log"},type:"horizontal-bar",height:30,position:"top"})}},{key:"handleAddVerticalSection",value:function(){const A=lX(this.props.tracks).filter(d=>d.type==="heatmap")[0];this.props.onAddTrack({type:"vertical-rule",x:this.props.coords[0],position:"whole"}),this.props.onAddTrack({data:{type:"vertical-section",server:A.server,tilesetUid:A.tilesetUid,slicePos:this.props.coords[0]},options:{valueScaling:"log"},type:"vertical-bar",height:30,position:"left"})}}]),s}(S1(rm).with(nSe));oSe.propTypes={coords:_.exports.array,customItems:_.exports.array};let bj=function(g){o(s,g);var a=l(s);function s(C){var I;T(this,s),I=a.call(this,C),I.closing=!1;const{tracks:A}=I.props;return I.canvasElement=null,I.tracksByUidInit={},[...I.props.tracks.top||[],...I.props.tracks.right||[],...I.props.tracks.bottom||[],...I.props.tracks.left||[],...I.props.tracks.gallery||[],...I.props.tracks.center||[]].forEach(d=>{d.type==="combined"?d.contents.forEach(h=>{I.tracksByUidInit[h.uid]=!1}):I.tracksByUidInit[d.uid]=!1}),I.xScale=null,I.yScale=null,I.addUidsToTracks(A),I.trackToReplace=null,I.trackRenderer=null,I.configTrackMenu=null,I.state={sizeMeasured:!1,height:10,width:10,tracks:A,init:!1,addTrackPosition:null,customDialog:null,mouseOverOverlayUid:null,forceUpdate:0,rangeSelection:[null,null],rangeSelectionEnd:!1,chromInfo:null,defaultChromSizes:null,contextMenuCustomItems:null,contextMenuPosition:null,addDivisorDialog:null},I.reset=!0,window.higlassTracksByType&&Object.keys(window.higlassTracksByType).forEach(d=>{Pr[d]=window.higlassTracksByType[d].config}),I.topHeight=0,I.bottomHeight=0,I.leftWidth=0,I.rightWidth=0,I.centerHeight=0,I.centerWidth=0,I.dragTimeout=null,I.previousPropsStr="",I.contextMenuHandlerBound=I.contextMenuHandler.bind(u(I)),I.handleNoTrackAddedBound=I.handleNoTrackAdded.bind(u(I)),I.handleTracksAddedBound=I.handleTracksAdded.bind(u(I)),I.closeMenusBound=I.closeMenus.bind(u(I)),I.handleAddDivisorBound=I.handleAddDivisor.bind(u(I)),I.handleAddSeriesBound=I.handleAddSeries.bind(u(I)),I.handleChangeTrackDataBound=I.handleChangeTrackData.bind(u(I)),I.handleChangeTrackTypeBound=I.handleChangeTrackType.bind(u(I)),I.handleCloseTrackBound=I.handleCloseTrack.bind(u(I)),I.handleConfigureTrackBound=I.handleConfigureTrack.bind(u(I)),I.handleExportTrackDataBound=I.handleExportTrackData.bind(u(I)),I.handleLockValueScaleBound=I.handleLockValueScale.bind(u(I)),I.handleReplaceTrackBound=I.handleReplaceTrack.bind(u(I)),I.handleTrackOptionsChangedBound=I.handleTrackOptionsChanged.bind(u(I)),I.handleUnlockValueScaleBound=I.handleUnlockValueScale.bind(u(I)),I.onAddTrack=I.handleAddTrack.bind(u(I)),I}return E(s,[{key:"waitForDOMAttachment",value:function(I){if(!this.mounted)return;const A=$.default.findDOMNode(this);document.body.contains(A)?I():requestAnimationFrame(()=>this.waitForDOMAttachment(I))}},{key:"componentDidMount",value:function(){this.mounted=!0,this.element=$.default.findDOMNode(this),this.canvasElement=$.default.findDOMNode(this.props.canvasElement),this.waitForDOMAttachment(()=>{wk.ElementQueries.listen(),this.resizeSensor=new wk.ResizeSensor(this.element.parentNode,this.measureSize.bind(this)),this.measureSize()}),this.addEventListeners(),this.pubSubs=[],this.pubSubs.push(this.props.pubSub.subscribe("contextmenu",this.contextMenuHandlerBound))}},{key:"UNSAFE_componentWillReceiveProps",value:function(I){this.addUidsToTracks(I.tracks),this.setState({tracks:I.tracks})}},{key:"shouldComponentUpdate",value:function(I,A){const d=this.previousPropsStr,h=this.updatablePropsToString(I),y=JSON.stringify(this.state),Z=JSON.stringify(A),b=d!==h||y!==Z||this.props.chooseTrackHandler!==I.chooseTrackHandler||this.props.customDialog!==I.customDialog;b&&(this.previousPropsStr=h);const w=this.numTracks;return this.numTracks=0,Od(this.props.tracks,()=>this.numTracks++),this.reset=this.reset||w===0&&this.numTracks>0,this.numTracks||(this.tracksByUidInit={}),b}},{key:"UNSAFE_componentWillUpdate",value:function(){}},{key:"componentDidUpdate",value:function(I,A){if(A.rangeSelection!==this.state.rangeSelection){let d=[null,null];this.state.defaultChromSizes&&this.state.rangeSelection.every(h=>h&&h.length)&&(d=this.state.rangeSelection.map(h=>tX(...h,this.state.defaultChromSizes))),this.props.onRangeSelection({dataRange:this.state.rangeSelection,genomicRange:d})}if(this.state.customDialog||this.props.customDialog){const d=this.state.customDialog||this.props.customDialog;if(d.length>0){const h=[],y=[];d.forEach(Z=>{h.push(Z.bodyComponent),y.push(Z.bodyProps)}),this.props.modal.open(X.default.createElement(yQ,{children:h,bodyProps:y,onCancel:this.props.closeCustomDialog,title:d[0].title}))}}if(I.tracks.center,this.props.tracks.center,(this.state.addTrackPosition||this.props.addTrackPosition)&&this.props.modal.open(X.default.createElement(eD,{host:this.state.addTrackHost,onCancel:this.handleNoTrackAddedBound,onTracksChosen:this.handleTracksAddedBound,position:this.state.addTrackPosition||this.props.addTrackPosition,trackSourceServers:this.props.trackSourceServers})),this.state.addDivisorDialog){const d=this.state.addDivisorDialog;this.props.modal.open(X.default.createElement(eD,{datatype:Pr[d.type].datatype[0],host:this.state.addTrackHost,onCancel:()=>{this.setState({addDivisorDialog:null})},onTracksChosen:h=>{this.handleDivisorChosen(d,h)},trackSourceServers:this.props.trackSourceServers}))}}},{key:"componentWillUnmount",value:function(){this.closing=!0,this.removeEventListeners(),this.pubSubs.forEach(I=>this.props.pubSub.unsubscribe(I))}},{key:"addUidsToTracks",value:function(I){Object.keys(I).forEach(A=>{I[A].forEach(d=>{d.uid=d.uid||Fn.nice()})})}},{key:"contextMenuHandler",value:function(I){if(!this.divTiledPlot)return;const A=this.divTiledPlot.getBoundingClientRect();if(!XU(I.clientX,I.clientY,A.left,A.left+A.width,A.top,A.top+A.height))return;const h=[I.clientX,I.clientY],y=xr(I,this.divTiledPlot),Z=this.trackRenderer.zoomedXScale.invert(y[0]),b=this.trackRenderer.zoomedYScale.invert(y[1]);let w=null;I.hgCustomItems&&(w=I.hgCustomItems.map(S=>X.default.createElement(Gn,{key:S.key,onClick:S.onClick},S.text))),this.setState({contextMenuCustomItems:w,contextMenuPosition:{left:h[0],top:h[1],canvasLeft:y[0]+this.trackRenderer.xPositionOffset,canvasTop:y[1]+this.trackRenderer.yPositionOffset},contextMenuDataX:Z,contextMenuDataY:b})}},{key:"measureSize",value:function(){this.element.clientWidth>0&&this.element.clientHeight>0&&this.setState({sizeMeasured:!0,width:this.element.clientWidth,height:this.element.clientHeight})}},{key:"handleTrackOptionsChanged",value:function(I,A){return this.props.onTrackOptionsChanged(I,A)}},{key:"handleScalesChanged",value:function(I,A){this.xScale=I,this.yScale=A,this.props.onScalesChanged(I,A)}},{key:"handleTilesetInfoReceived",value:function(I,A){const d=yl(this.props.tracks,I);if(!d){console.warn("Strange, track not found:",I);return}this.tracksByUidInit[d.uid]=!0,this.checkAllTilesetInfoReceived(),d.options||(d.options={}),d.name=A.name,d.maxWidth=A.max_width,d.transforms=A.transforms,d.aggregationModes=A.aggregation_modes,d.header=A.header,d.binsPerDimension=A.bins_per_dimension,A.resolutions?(d.maxZoom=A.resolutions.length-1,d.resolutions=A.resolutions):d.maxZoom=A.max_zoom,d.coordSystem=A.coordSystem,d.datatype=A.datatype}},{key:"checkAllTilesetInfoReceived",value:function(){if(this.state.init&&!this.reset||!this.trackRenderer||!this.props.zoomToDataExtentOnInit())return;const I=Object.keys(this.trackRenderer.trackDefObjects).map(d=>{const h=this.trackRenderer.trackDefObjects[d].trackObject;return h.childTracks?h.childTracks:h}).reduce((d,h)=>d.concat(h),[]).filter(({tilesetInfo:d})=>typeof d<"u"&&d!==!0),A=Object.values(this.tracksByUidInit).filter(d=>d).length;I.length===A&&(this.setState({init:!0}),this.reset=!1,this.handleZoomToData())}},{key:"handleOverlayMouseEnter",value:function(I){this.setState({mouseOverOverlayUid:I})}},{key:"handleOverlayMouseLeave",value:function(I){I===this.state.mouseOverOverlayUid&&this.setState({mouseOverOverlayUid:null})}},{key:"handleTrackPositionChosen",value:function(I){this.setState({mouseOverOverlayUid:null}),this.props.chooseTrackHandler(I.track.uid)}},{key:"handleNoTrackAdded",value:function(){this.trackToReplace=null,this.props.onNoTrackAdded(),this.setState({addTrackPosition:null,addTrackHost:null})}},{key:"handleAddDivisor",value:function(I){this.setState({addDivisorDialog:I})}},{key:"handleDivisorChosen",value:function(I,A){this.setState({addDivisorDialog:null});const d=I.data?{server:I.data.server,tilesetUid:I.data.tilesetUid}:{server:I.server,tilesetUid:I.tilesetUid},h={server:A[0].server,tilesetUid:A[0].uuid};this.handleChangeTrackData(I.uid,{type:"divided",children:[d,h]})}},{key:"handleDivideSeries",value:function(I){}},{key:"handleAddSeries",value:function(I){const A=U2(this.props.tracks,I),d=yl(this.props.tracks,I);this.setState({addTrackPosition:A,addTrackHost:d})}},{key:"handleReplaceTrack",value:function(I,A){this.trackToReplace=I,this.handleAddTrack(A)}},{key:"handleAddTrack",value:function(I){this.setState({addTrackPosition:I,addTrackHost:null})}},{key:"handleResizeTrack",value:function(I,A,d){const{tracks:h}=this.state;for(const y in h){const b=h[y].filter(w=>w.uid===I);b.length>0&&(b[0].width=A,b[0].height=d)}this.setState({tracks:h,forceUpdate:Math.random()}),this.props.onResizeTrack()}},{key:"closeMenus",value:function(){this.setState({closeTrackMenuId:null,configTrackMenuId:null,contextMenuPosition:null,contextMenuCustomItems:null})}},{key:"handleLockValueScale",value:function(I){this.closeMenus(),this.props.onLockValueScale(I)}},{key:"handleUnlockValueScale",value:function(I){this.closeMenus(),this.props.onUnlockValueScale(I)}},{key:"handleCloseTrack",value:function(I){this.closeMenus(),this.props.onCloseTrack(I)}},{key:"handleChangeTrackType",value:function(I,A){this.closeMenus(),this.props.onChangeTrackType(I,A)}},{key:"handleChangeTrackData",value:function(I,A){this.closeMenus(),this.props.onChangeTrackData(I,A)}},{key:"handleTracksAdded",value:function(I,A,d){return this.trackToReplace&&(this.handleCloseTrack(this.trackToReplace),this.trackToReplace=null),this.props.onTracksAdded(I,A,d),this.setState({addTrackPosition:null,addTrackHost:null}),I}},{key:"handleCloseTrackMenuOpened",value:function(I,A){this.setState({closeTrackMenuId:I,closeTrackMenuLocation:A})}},{key:"handleCloseContextMenu",value:function(){this.setState({contextMenuCustomItems:null,contextMenuPosition:null,contextMenuDataX:null,contextMenuDataY:null})}},{key:"handleCloseTrackMenuClosed",value:function(){this.setState({closeTrackMenuId:null})}},{key:"handleConfigTrackMenuOpened",value:function(I,A){this.closeMenus(),this.setState({configTrackMenuId:I,configTrackMenuLocation:A})}},{key:"handleConfigureTrack",value:function(I,A){this.setState({configTrackMenuId:null,trackOptions:{track:I,configComponent:A}}),this.closeMenus()}},{key:"handleSortEnd",value:function(I){this.setState(A=>{const d=A.tracks,h={};for(let y=0;y{A[d]&&A[d].forEach(h=>{h.contents&&h.contents.forEach(y=>{y.position=d}),h.position=d,I.push({track:h,location:d})})}),I}},{key:"calculateTrackPosition",value:function(I,A){let d=this.props.paddingTop,h=this.props.paddingBottom,y=this.props.paddingLeft,Z=this.props.paddingRight,b=this.centerWidth,w=I.height,S=0,R=0;switch(A){case"top":y+=this.leftWidth;for(let H=0;Hd.includes&&d.includes.length).map(d=>{const h=d.type?`overlay-${d.type}-track`:"overlay-track",y={...d,uid:d.uid||Fn.nice(),includes:d.includes,type:h,options:Object.assign(d.options,{orientationsAndPositions:d.includes.map(Z=>{const b=yl(this.props.tracks,Z);if(!b)return console.warn(`OverlayTrack included uid (${Z}) not found in the track list`),null;const w=U2(this.props.tracks,b.uid);let S;if((w==="top"||w==="bottom")&&(S="1d-horizontal"),(w==="left"||w==="right")&&(S="1d-vertical"),w==="center"&&(S="2d"),!S)return console.warn("Only top, bottom, left, right, or center tracks can be overlaid at the moment"),null;const R=I.filter(N=>N.track.uid===Z);if(!R.length)return null;const H={left:R[0].left-this.props.paddingLeft,top:R[0].top-this.props.paddingTop,width:R[0].width,height:R[0].height};return{orientation:S,position:H}}).filter(Z=>Z)})};return{top:this.props.paddingTop,left:this.props.paddingLeft,width:this.leftWidth+this.centerWidth+this.rightWidth,height:this.topHeight+this.centerHeight+this.bottomHeight+this.props.marginTop+this.props.marginBottom,track:y}}):[]}},{key:"positionedTracks",value:function(){return this.createTracksAndLocations().map(({track:A,location:d})=>this.calculateTrackPosition(A,d))}},{key:"createTrackPositionTexts",value:function(){const I=this.positionedTracks();return this.createTracksAndLocations(),I.map(d=>{const{track:h}=d;return X.default.createElement("div",{key:h.uid,style:{left:d.left,top:d.top,width:d.width,height:d.height,position:"absolute"}},h.uid.slice(0,2))})}},{key:"handleExportTrackData",value:function(I,A){const d=yl(this.props.tracks,A);let h=null;I!==A?h=this.trackRenderer.trackDefObjects[I].trackObject.createdTracks[d.uid]:{trackObject:h}=this.trackRenderer.trackDefObjects[I],h.exportData(),this.closeMenus()}},{key:"listTracksAtPosition",value:function(I,A,d=!1){const h=[];if(!this.trackRenderer)return[];for(const y in this.trackRenderer.trackDefObjects){const Z=this.trackRenderer.trackDefObjects[y].trackObject;if(Z.respondsToPosition(I,A))if(d){if(this.props.tracks.center)if(this.props.tracks.center.contents)for(let b=0;bh[H]&&(h[H]=R.tilesetInfo.max_pos[H]);const Z=this.trackRenderer.currentProps.paddingLeft+this.trackRenderer.currentProps.leftWidth;let b=[Z,Z+this.trackRenderer.currentProps.centerWidth].map(this.trackRenderer.zoomTransform.rescaleX(this.trackRenderer.xScale).invert);const w=this.trackRenderer.currentProps.paddingTop+this.trackRenderer.currentProps.topHeight;let S=[w,w+this.trackRenderer.currentProps.centerHeight].map(this.trackRenderer.zoomTransform.rescaleY(this.trackRenderer.yScale).invert);this.trackRenderer.zoomTransform.k=1,this.trackRenderer.zoomTransform.x=0,this.trackRenderer.zoomTransform.y=0,this.trackRenderer.applyZoomTransform(),d[0]Number.MIN_SAFE_INTEGER&&(b=[d[0],h[0]]),d[1]Number.MIN_SAFE_INTEGER&&(S=[d[1],h[1]]),this.props.onDataDomainChanged(b,S)}},{key:"resetViewport",value:function(){this.trackRenderer.zoomTransform.k=1,this.trackRenderer.zoomTransform.x=0,this.trackRenderer.zoomTransform.y=0,this.trackRenderer.applyZoomTransform(),this.props.onDataDomainChanged(this.props.initialXDomain,this.props.initialYDomain)}},{key:"updatablePropsToString",value:function(I){return JSON.stringify({tracks:I.tracks,overlays:I.overlays,viewOptions:I.viewOptions,uid:I.uid,addTrackPosition:I.addTrackPosition,editable:I.editable,marginTop:I.marginTop,marginBottom:I.marginBottom,marginLeft:I.marginLeft,marginRight:I.marginRight,paddingTop:I.paddingTop,paddingBottom:I.paddingBottom,paddingLeft:I.paddingLeft,paddingRight:I.paddingRight,mouseTool:I.mouseTool,initialXDomain:I.initialXDomain,initialYDomain:I.initialYDomain,trackSourceServers:I.trackSourceServers,zoomable:I.zoomable,draggingHappening:I.draggingHappening})}},{key:"getXYScales",value:function(){this.trackRenderer&&(this.xScale=this.trackRenderer.currentXScale,this.yScale=this.trackRenderer.currentYScale)}},{key:"rangeViewToDataLoci",value:function(I,A){return A?[parseInt(A.invert(I[0]),10),parseInt(A.invert(I[1]),10)]:[null,null]}},{key:"rangeSelectionResetHandler",value:function(){this.state.rangeSelectionMaster&&this.setState({is1dRangeSelection:null,rangeSelection:[null,null],rangeSelectionMaster:null,rangeSelectionEnd:!1})}},{key:"rangeSelection1dEndHandler",value:function(I){(!this.xScale||!this.yScale)&&this.getXYScales();const A=I==="x"?this.xScale:this.yScale;return d=>{this.setState(h=>{const y=h.is1dRangeSelection?[null,null]:h.rangeSelection.slice(),Z=!this.state.is1dRangeSelection&&I==="y"?1:0;let b=this.rangeViewToDataLoci(d,A);const w=b[1]-b[0];if(this.props.rangeSelection1dSize[0]>w){const S=b[0]+w/2;b=[S-this.props.rangeSelection1dSize[0]/2,S+this.props.rangeSelection1dSize[0]/2]}else if(this.props.rangeSelection1dSize[1]Math.round(S))),{rangeSelection:y,rangeSelectionEnd:!0}})}}},{key:"rangeSelection1dHandler",value:function(I){(!this.xScale||!this.yScale)&&this.getXYScales();const A=I==="x"?this.xScale:this.yScale;return d=>{this.setState(h=>{const y=h.is1dRangeSelection?[null,null]:h.rangeSelection.slice(),Z=!h.is1dRangeSelection&&I==="y"?1:0;return y[Z]=this.rangeViewToDataLoci(d,A),{rangeSelection:y,rangeSelectionEnd:!1}})}}},{key:"rangeSelection1dStartHandler",value:function(){this.state.rangeSelectionMaster||this.setState({is1dRangeSelection:!0,rangeSelectionMaster:!0,rangeSelectionEnd:!1})}},{key:"rangeSelection2dHandler",value:function(I){(!this.xScale||!this.yScale)&&this.getXYScales(),this.setState({rangeSelection:[this.rangeViewToDataLoci(I[0],this.xScale),this.rangeViewToDataLoci(I[1],this.yScale)],rangeSelectionEnd:!1})}},{key:"rangeSelection2dStartHandler",value:function(){this.state.rangeSelectionMaster||this.setState({is1dRangeSelection:!1,rangeSelectionMaster:!0,rangeSelectionEnd:!1})}},{key:"rangeSelection2dEndHandler",value:function(I){(!this.xScale||!this.yScale)&&this.getXYScales();const A=this.rangeViewToDataLoci(I[0],this.xScale),d=this.rangeViewToDataLoci(I[1],this.yScale);let h=[A,d];const y=A[1]-A[0],Z=d[1]-d[0],b=[y,Z];h.forEach((w,S)=>{if(this.props.rangeSelection1dSize[0]>b[S]){const R=w[0]+Math.round(b[S]/2);w[0]=R-this.props.rangeSelection1dSize[0]/2,w[1]=R+this.props.rangeSelection1dSize[0]/2}else if(this.props.rangeSelection1dSize[1]w.map(S=>Math.round(S)))),this.setState({rangeSelection:h,rangeSelectionEnd:!0})}},{key:"getContextMenu",value:function(){if(this.state.contextMenuPosition){const I=this.listTracksAtPosition(this.state.contextMenuPosition.canvasLeft,this.state.contextMenuPosition.canvasTop);return X.default.createElement(Im,{onMenuClosed:this.closeMenusBound},X.default.createElement(oSe,{closeMenu:this.closeMenusBound,coords:[this.state.contextMenuDataX,this.state.contextMenuDataY],customItems:this.state.contextMenuCustomItems,onAddDivisor:this.handleAddDivisorBound,onAddSeries:this.handleAddSeriesBound,onAddTrack:A=>{this.props.onTracksAdded([A],A.position,null),this.handleCloseContextMenu()},onChangeTrackData:this.handleChangeTrackDataBound,onChangeTrackType:this.handleChangeTrackTypeBound,onCloseTrack:this.handleCloseTrackBound,onConfigureTrack:this.handleConfigureTrackBound,onExportData:this.handleExportTrackDataBound,onLockValueScale:this.handleLockValueScaleBound,onReplaceTrack:this.handleReplaceTrackBound,onTrackOptionsChanged:this.handleTrackOptionsChangedBound,onUnlockValueScale:this.handleUnlockValueScaleBound,orientation:"right",position:this.state.contextMenuPosition,theme:this.props.theme,tracks:I,trackSourceServers:this.props.trackSourceServers}))}return null}},{key:"getIdealizedTrackPositionsOverlay",value:function(){const I=this.props.draggingHappening,A=I.datatype;if(!(A in _2)&&!I.defaultTracks){console.warn("unknown data type:",I.higlassTrack);return}const d={"1d-horizontal":["top","bottom","left","right"],"2d":["center"],"1d-vertical":["left","right"]},h=_2[A]||{};if(I.defaultTracks)for(const oe of I.defaultTracks)if(!Pr[oe])console.warn("unknown track type",oe);else for(const he of d[Pr[oe].orientation])h[he]=oe;const y=new Set(["top","left","right","center","bottom"].filter(oe=>oe in this.state.tracks&&this.state.tracks[oe].length)),Z="top"in h,b="left"in h,w="right"in h,S="bottom"in h,R="center"in h,H="center"in h||y.has("left")||y.has("right")||y.has("center"),N="top"in h,D="bottom"in h&&H,M="left"in h&&H,z="right"in h&&H,K=Object.keys(h).length&&("center"in h||H),P=X.default.createElement("div",{style:{flexGrow:1}}),J=X.default.cloneElement(P),j=X.default.createElement("div",{style:{display:"flex",flexGrow:1}},N&&(K||M)?P:null,X.default.createElement(fX,{defaultTrackType:h.top,draggingHappening:this.props.draggingHappening,enabled:Z,onTrackDropped:oe=>this.handleTracksAdded([oe],"top"),style:{border:"1px solid black",flexGrow:1}}),N&&(K||M)?J:null),ie=X.default.createElement("div",{style:{display:"flex",flexGrow:1}},N&&(K||M)?P:null,X.default.createElement(fX,{defaultTrackType:h.bottom,draggingHappening:this.props.draggingHappening,enabled:S,onTrackDropped:oe=>this.handleTracksAdded([oe],"bottom"),style:{border:"1px solid black",flexGrow:1}}),N&&(K||M)?J:null),te=X.default.createElement(fX,{defaultTrackType:h.left,draggingHappening:this.props.draggingHappening,enabled:b,onTrackDropped:oe=>this.handleTracksAdded([oe],"left"),style:{border:"1px solid black",flexGrow:1}}),Ce=X.default.createElement(fX,{defaultTrackType:h.center,draggingHappening:this.props.draggingHappening,enabled:R,onTrackDropped:oe=>this.handleTracksAdded([oe],"center"),position:"center",style:{border:"1px solid black",flexGrow:1}}),ue=X.default.cloneElement(te,{defaultTrackType:h.right,enabled:w,onTrackDropped:oe=>this.handleTracksAdded([oe],"right")});return X.default.createElement("div",{style:{position:"absolute",left:"0px",top:"0px",width:this.state.width,height:this.state.height}},X.default.createElement("div",{style:{position:"absolute",width:this.state.width,height:this.state.height,background:"white",opacity:.4}}),X.default.createElement("div",{style:{width:this.state.width,height:this.state.height,position:"absolute",display:"flex",flexDirection:"column"}},N?j:null,H&&X.default.createElement("div",{style:{display:"flex",height:N||D?"40%":"100%",width:"100%"}},M?te:null,K?Ce:null,z?ue:null),D?ie:null))}},{key:"render",value:function(){this.galleryDim=this.props.tracks.gallery?this.props.tracks.gallery.map(K=>K.height).reduce(Mf,0):0,this.topHeightNoGallery=this.props.tracks.top.map(K=>K.height).reduce(Mf,0),this.topHeight=this.topHeightNoGallery+this.galleryDim,this.bottomHeightNoGallery=this.props.tracks.bottom.map(K=>K.height).reduce(Mf,0),this.bottomHeight=this.bottomHeightNoGallery+this.galleryDim,this.leftWidthNoGallery=this.props.tracks.left.map(K=>K.width).reduce(Mf,0),this.leftWidth=this.leftWidthNoGallery+this.galleryDim,this.rightWidthNoGallery=this.props.tracks.right.map(K=>K.width).reduce(Mf,0),this.rightWidth=this.rightWidthNoGallery+this.galleryDim;const I=this.props.paddingTop+this.props.paddingBottom,A=this.props.paddingLeft+this.props.paddingRight;this.centerHeight=Math.max(0,this.state.height-this.topHeight-this.bottomHeight-I),this.centerWidth=Math.max(0,this.state.width-this.leftWidth-this.rightWidth-A);const d="none",h=X.default.createElement("div",{className:"top-track-container",style:{left:this.leftWidth+this.props.paddingLeft,top:this.props.paddingTop,width:this.centerWidth,height:this.topHeightNoGallery,outline:d,position:"absolute"}},X.default.createElement(Qx,{configTrackMenuId:this.state.configTrackMenuId,editable:this.props.editable,handleConfigTrack:this.handleConfigTrackMenuOpened.bind(this),handleResizeTrack:this.handleResizeTrack.bind(this),handleSortEnd:this.handleSortEnd.bind(this),is1dRangeSelection:this.state.is1dRangeSelection,isRangeSelectionActive:this.props.mouseTool===oC,onAddSeries:this.handleAddSeries.bind(this),onCloseTrack:this.handleCloseTrack.bind(this),onCloseTrackMenuOpened:this.handleCloseTrackMenuOpened.bind(this),onConfigTrackMenuOpened:this.handleConfigTrackMenuOpened.bind(this),onRangeSelection:this.rangeSelection1dHandler("x").bind(this),onRangeSelectionEnd:this.rangeSelection1dEndHandler("x").bind(this),onRangeSelectionReset:this.rangeSelectionResetHandler.bind(this),onRangeSelectionStart:this.rangeSelection1dStartHandler.bind(this),rangeSelection:this.state.rangeSelection,rangeSelectionEnd:this.state.rangeSelectionEnd,resizeHandles:new Set(["bottom"]),scale:this.xScale,tracks:this.props.tracks.top,width:this.centerWidth})),y=X.default.createElement("div",{className:"left-track-container",style:{left:this.props.paddingLeft,top:this.topHeight+this.props.paddingTop,width:this.leftWidthNoGallery,height:this.centerHeight,outline:d,position:"absolute"}},X.default.createElement(pj,{configTrackMenuId:this.state.configTrackMenuId,editable:this.props.editable,handleConfigTrack:this.handleConfigTrackMenuOpened.bind(this),handleResizeTrack:this.handleResizeTrack.bind(this),handleSortEnd:this.handleSortEnd.bind(this),height:this.centerHeight,is1dRangeSelection:this.state.is1dRangeSelection,isRangeSelectionActive:this.props.mouseTool===oC,onAddSeries:this.handleAddSeries.bind(this),onCloseTrack:this.handleCloseTrack.bind(this),onCloseTrackMenuOpened:this.handleCloseTrackMenuOpened.bind(this),onConfigTrackMenuOpened:this.handleConfigTrackMenuOpened.bind(this),onRangeSelection:this.rangeSelection1dHandler("y").bind(this),onRangeSelectionEnd:this.rangeSelection1dEndHandler("y").bind(this),onRangeSelectionReset:this.rangeSelectionResetHandler.bind(this),onRangeSelectionStart:this.rangeSelection1dStartHandler.bind(this),rangeSelection:this.state.rangeSelection,rangeSelectionEnd:this.state.rangeSelectionEnd,resizeHandles:new Set(["right"]),scale:this.yScale,tracks:this.props.tracks.left})),Z=X.default.createElement("div",{className:"right-track-container",style:{right:this.props.paddingRight,top:this.topHeight+this.props.paddingTop,width:this.rightWidthNoGallery,height:this.centerHeight,outline:d,position:"absolute"}},X.default.createElement(pj,{configTrackMenuId:this.state.configTrackMenuId,editable:this.props.editable,handleConfigTrack:this.handleConfigTrackMenuOpened.bind(this),handleResizeTrack:this.handleResizeTrack.bind(this),handleSortEnd:this.handleSortEnd.bind(this),height:this.centerHeight,is1dRangeSelection:this.state.is1dRangeSelection,isRangeSelectionActive:this.props.mouseTool===oC,onAddSeries:this.handleAddSeries.bind(this),onCloseTrack:this.handleCloseTrack.bind(this),onCloseTrackMenuOpened:this.handleCloseTrackMenuOpened.bind(this),onConfigTrackMenuOpened:this.handleConfigTrackMenuOpened.bind(this),onRangeSelection:this.rangeSelection1dHandler("y").bind(this),onRangeSelectionEnd:this.rangeSelection1dEndHandler("y").bind(this),onRangeSelectionReset:this.rangeSelectionResetHandler.bind(this),onRangeSelectionStart:this.rangeSelection1dStartHandler.bind(this),rangeSelection:this.state.rangeSelection,rangeSelectionEnd:this.state.rangeSelectionEnd,resizeHandles:new Set(["left"]),scale:this.yScale,tracks:this.props.tracks.right,tracksControlAlignLeft:!0})),b=X.default.createElement("div",{className:"bottom-track-container",style:{left:this.leftWidth+this.props.paddingLeft,bottom:this.props.paddingBottom,width:this.centerWidth,height:this.bottomHeightNoGallery,outline:d,position:"absolute"}},X.default.createElement(Qx,{configTrackMenuId:this.state.configTrackMenuId,editable:this.props.editable,handleConfigTrack:this.handleConfigTrackMenuOpened.bind(this),handleResizeTrack:this.handleResizeTrack.bind(this),handleSortEnd:this.handleSortEnd.bind(this),is1dRangeSelection:this.state.is1dRangeSelection,isRangeSelectionActive:this.props.mouseTool===oC,onAddSeries:this.handleAddSeries.bind(this),onCloseTrack:this.handleCloseTrack.bind(this),onCloseTrackMenuOpened:this.handleCloseTrackMenuOpened.bind(this),onConfigTrackMenuOpened:this.handleConfigTrackMenuOpened.bind(this),onRangeSelection:this.rangeSelection1dHandler("x").bind(this),onRangeSelectionEnd:this.rangeSelection1dEndHandler("x").bind(this),onRangeSelectionReset:this.rangeSelectionResetHandler.bind(this),onRangeSelectionStart:this.rangeSelection1dStartHandler.bind(this),rangeSelection:this.state.rangeSelection,rangeSelectionEnd:this.state.rangeSelectionEnd,resizeHandles:new Set(["top"]),scale:this.xScale,tracks:this.props.tracks.bottom,width:this.centerWidth})),w=X.default.createElement("div",{key:"galleryTracksDiv",className:"gallery-track-container",style:{left:this.leftWidthNoGallery+this.props.paddingLeft,top:this.topHeightNoGallery+this.props.paddingTop,width:this.centerWidth+2*this.galleryDim,height:this.centerHeight+2*this.galleryDim,outline:d,position:"absolute"}},X.default.createElement(z0e,{configTrackMenuId:this.state.configTrackMenuId,editable:this.props.editable,height:this.centerHeight+2*this.galleryDim,onAddSeries:this.handleAddSeries.bind(this),onCloseTrack:this.handleCloseTrack.bind(this),onCloseTrackMenuOpened:this.handleCloseTrackMenuOpened.bind(this),onConfigTrackMenuOpened:this.handleConfigTrackMenuOpened.bind(this),tracks:this.props.tracks.gallery,width:this.centerWidth+2*this.galleryDim}));let S=X.default.createElement("div",{className:["center-track-container",UU["center-track-container"]].join(" "),style:{left:this.leftWidth+this.props.paddingLeft,top:this.topHeight+this.props.paddingTop,width:this.centerWidth,height:this.bottomHeight,outline:d}});this.props.tracks.center.length&&(S=X.default.createElement("div",{className:["center-track-container",UU["center-track-container"]].join(" "),style:{left:this.leftWidth+this.props.paddingLeft,top:this.topHeight+this.props.paddingTop,width:this.centerWidth,height:this.centerHeight,outline:d}},X.default.createElement(QU,{configTrackMenuId:this.state.configTrackMenuId,editable:this.props.editable,height:this.centerHeight,is1dRangeSelection:this.state.is1dRangeSelection,isRangeSelectionActive:this.props.mouseTool===oC,onAddSeries:this.handleAddSeries.bind(this),onCloseTrackMenuOpened:this.handleCloseTrackMenuOpened.bind(this),onConfigTrackMenuOpened:this.handleConfigTrackMenuOpened.bind(this),onRangeSelectionReset:this.rangeSelectionResetHandler.bind(this),onRangeSelectionStart:this.rangeSelection2dStartHandler.bind(this),onRangeSelectionX:this.rangeSelection1dHandler("x").bind(this),onRangeSelectionXEnd:this.rangeSelection1dEndHandler("x").bind(this),onRangeSelectionXY:this.rangeSelection2dHandler.bind(this),onRangeSelectionXYEnd:this.rangeSelection2dEndHandler.bind(this),onRangeSelectionY:this.rangeSelection1dHandler("y").bind(this),onRangeSelectionYEnd:this.rangeSelection1dEndHandler("y").bind(this),rangeSelection:this.state.rangeSelection,rangeSelectionEnd:this.state.rangeSelectionEnd,scaleX:this.xScale,scaleY:this.yScale,tracks:this.props.tracks.center,uid:this.props.tracks.center[0].uid,width:this.centerWidth}))),this.createTrackPositionTexts();let R=this.positionedTracks();R=R.concat(this.overlayTracks(R));let H=null;this.state.sizeMeasured&&(H=X.default.createElement(Vbt,{ref:K=>{this.trackRenderer=K,this.checkAllTilesetInfoReceived()},canvasElement:this.canvasElement,centerHeight:this.centerHeight,centerWidth:this.centerWidth,disableTrackMenu:this.props.disableTrackMenu,dragging:this.props.dragging,galleryDim:this.galleryDim,getLockGroupExtrema:this.props.getLockGroupExtrema,height:this.state.height,initialXDomain:this.props.initialXDomain,initialYDomain:this.props.initialYDomain,isRangeSelection:this.props.mouseTool===oC,isShowGlobalMousePosition:this.props.isShowGlobalMousePosition,isValueScaleLocked:this.props.isValueScaleLocked,leftWidth:this.leftWidth,leftWidthNoGallery:this.leftWidthNoGallery,metaTracks:this.props.metaTracks,onMouseMoveZoom:this.props.onMouseMoveZoom,onNewTilesLoaded:this.props.onNewTilesLoaded,onScalesChanged:this.handleScalesChanged.bind(this),onTilesetInfoReceived:this.handleTilesetInfoReceived.bind(this),onTrackOptionsChanged:this.handleTrackOptionsChanged.bind(this),onValueScaleChanged:this.props.onValueScaleChanged,paddingLeft:this.props.paddingLeft,paddingTop:this.props.paddingTop,pixiRenderer:this.props.pixiRenderer,pixiStage:this.props.pixiStage,pluginDataFetchers:this.props.pluginDataFetchers,pluginTracks:this.props.pluginTracks,positionedTracks:R,registerDraggingChangedListener:this.props.registerDraggingChangedListener,removeDraggingChangedListener:this.props.removeDraggingChangedListener,setCentersFunction:this.props.setCentersFunction,svgElement:this.props.svgElement,topHeight:this.topHeight,topHeightNoGallery:this.topHeightNoGallery,uid:this.props.uid,viewOptions:this.props.viewOptions,width:this.state.width,xDomainLimits:this.props.xDomainLimits,yDomainLimits:this.props.yDomainLimits,zoomable:this.props.zoomable,zoomLimits:this.props.zoomLimits},h,y,Z,b,w,S));let N=null,D=null;this.state.configTrackMenuId&&(N=X.default.createElement(Im,{onMenuClosed:this.closeMenusBound},X.default.createElement(p2t,{ref:K=>{this.configTrackMenu=K},closeMenu:this.closeMenusBound,onAddDivisor:this.handleAddDivisorBound,onAddSeries:this.handleAddSeriesBound,onAddTrack:this.handleAddTrackBound,onChangeTrackType:this.handleChangeTrackTypeBound,onCloseTrack:this.handleCloseTrackBound,onConfigureTrack:this.handleConfigureTrackBound,onExportData:this.handleExportTrackDataBound,onLockValueScale:this.handleLockValueScaleBound,onReplaceTrack:this.handleReplaceTrackBound,onTrackOptionsChanged:this.handleTrackOptionsChangedBound,onUnlockValueScale:this.handleUnlockValueScaleBound,position:this.state.configTrackMenuLocation,theme:this.props.theme,trackOrientation:U2(this.props.tracks,this.state.configTrackMenuId),tracks:[yl(this.props.tracks,this.state.configTrackMenuId)]}))),this.state.closeTrackMenuId&&(D=X.default.createElement(Im,{onMenuClosed:this.handleCloseTrackMenuClosed.bind(this)},X.default.createElement(rm,{position:this.state.closeTrackMenuLocation,theme:this.props.theme},X.default.createElement(rSe,{onCloseTrack:this.handleCloseTrack.bind(this),tracks:[yl(this.props.tracks,this.state.closeTrackMenuId)]}))));let M=null;this.props.chooseTrackHandler&&(M=R.filter(K=>K.track.position!=="whole").map(K=>{let P="transparent",J="none";return this.state.mouseOverOverlayUid===K.track.uid&&(P="yellow",J="1px solid black"),X.default.createElement("div",{key:K.track.uid,className:"tiled-plot-track-overlay",onClick:()=>this.handleTrackPositionChosen(K),onDragEnter:j=>{this.handleOverlayMouseEnter(K.track.uid),j.preventDefault()},onDragLeave:()=>this.handleOverlayMouseLeave(K.track.uid),onDragOver:j=>j.preventDefault(),onDrop:()=>this.handleTrackPositionChosen(K),onMouseEnter:()=>this.handleOverlayMouseEnter(K.track.uid),onMouseLeave:()=>this.handleOverlayMouseLeave(K.track.uid),style:{position:"absolute",left:K.left,top:K.top,width:K.width,height:K.height,background:P,opacity:.4,border:J,zIndex:1}})}));let z=null;if(this.xScale&&this.yScale&&this.props.editable&&this.state.trackOptions){const K=this.state.trackOptions.configComponent,P=this.state.trackOptions.track;z=X.default.createElement(K,{track:P,xScale:this.xScale,yScale:this.yScale,onCancel:()=>{this.setState({trackOptions:null})},onTrackOptionsChanged:J=>J,onSubmit:J=>{this.handleTrackOptionsChanged(this.state.trackOptions.track.uid,J),this.setState({trackOptions:null})}})}return X.default.createElement("div",{ref:K=>{this.divTiledPlot=K},className:["tiled-plot-div",sc["tiled-plot"]].join(" "),style:{marginBottom:this.props.marginBottom,marginLeft:this.props.marginLeft,marginRight:this.props.marginRight,marginTop:this.props.marginTop}},H,M,N,D,z,this.getContextMenu(),this.props.draggingHappening&&this.getIdealizedTrackPositionsOverlay())}},{key:"addEventListeners",value:function(){this.eventListeners=[],this.eventListeners.forEach(I=>document.addEventListener(I.name,I.callback,!1))}},{key:"removeEventListeners",value:function(){this.eventListeners.forEach(I=>document.removeEventListener(I.name,I.callback))}}]),s}(X.default.Component);bj.defaultProps={isShowGlobalMousePosition:!1,pluginDataFetchers:{},pluginTracks:{},metaTracks:[],zoomable:!0},bj.propTypes={addTrackPosition:_.exports.string,canvasElement:_.exports.object,chooseTrackHandler:_.exports.func,chromInfoPath:_.exports.string,disableTrackMenu:_.exports.bool,dragging:_.exports.bool,draggingHappening:_.exports.bool,editable:_.exports.bool,getLockGroupExtrema:_.exports.func,initialXDomain:_.exports.array,initialYDomain:_.exports.array,isShowGlobalMousePosition:_.exports.bool,isValueScaleLocked:_.exports.func,marginBottom:_.exports.number.isRequired,marginLeft:_.exports.number.isRequired,marginRight:_.exports.number.isRequired,marginTop:_.exports.number.isRequired,paddingBottom:_.exports.number.isRequired,paddingLeft:_.exports.number.isRequired,paddingRight:_.exports.number.isRequired,paddingTop:_.exports.number.isRequired,metaTracks:_.exports.array,modal:_.exports.object,mouseTool:_.exports.string,onCloseTrack:_.exports.func,onChangeTrackData:_.exports.func,onChangeTrackType:_.exports.func,onDataDomainChanged:_.exports.func,onLockValueScale:_.exports.func,onMouseMoveZoom:_.exports.func,onNewTilesLoaded:_.exports.func,onNoTrackAdded:_.exports.func,onRangeSelection:_.exports.func.isRequired,onScalesChanged:_.exports.func,onTrackOptionsChanged:_.exports.func,onTrackPositionChosen:_.exports.func,onTracksAdded:_.exports.func,onUnlockValueScale:_.exports.func,onValueScaleChanged:_.exports.func,onResizeTrack:_.exports.func,overlays:_.exports.array,openModal:_.exports.func,pixiRenderer:_.exports.object,pixiStage:_.exports.object,pluginDataFetchers:_.exports.object,pluginTracks:_.exports.object,pubSub:_.exports.object.isRequired,rangeSelection1dSize:_.exports.array,rangeSelectionToInt:_.exports.bool,registerDraggingChangedListener:_.exports.func,removeDraggingChangedListener:_.exports.func,setCentersFunction:_.exports.func,svgElement:_.exports.object,theme:_.exports.symbol.isRequired,tracks:_.exports.object,trackSourceServers:_.exports.array,uid:_.exports.string,viewOptions:_.exports.object,xDomainLimits:_.exports.array,yDomainLimits:_.exports.array,zoomable:_.exports.bool,zoomLimits:_.exports.array,zoomToDataExtentOnInit:_.exports.func};const v2t=qZ(qx(L0(bj)));var aSe={exports:{}},Z2t=Object.assign||function(g){for(var a=1;a"u"?"undefined":B2t(a))==="object"){for(var I in a)a.hasOwnProperty(I)&&rB(g,I,a[I]);return}if(typeof C<"u"){typeof C=="number"&&(C+="px"),g.style[a]=C;return}return bb(g,a)}Gj(["width","height"],function(g){var a=g.charAt(0).toUpperCase()+g.slice(1);Iu["outer"+a]=function(C,I){return C&&cSe(C,g,I?N2t:wj)};var s=g==="width"?["Left","Right"]:["Top","Bottom"];Iu[g]=function(C,I){if(I!==void 0){if(C){bb(C);var A=lSe(C);return A&&(I+=ZR(C,["padding","border"],s)),rB(C,g,I)}return}return C&&cSe(C,g,Sj)}});function x2t(g,a){rB(g,"position")==="static"&&(g.style.position="relative");var s=ISe(g),C={},I=void 0,A=void 0;for(A in a)a.hasOwnProperty(A)&&(I=parseFloat(rB(g,A))||0,C[A]=I+a[A]-s[A]);rB(g,C)}var D2t=Z2t({getWindow:function(a){var s=a.ownerDocument||a;return s.defaultView||s.parentWindow},offset:function(a,s){if(typeof s<"u")x2t(a,s);else return ISe(a)},isWindow:mD,each:Gj,css:rB,clone:function(a){var s={};for(var C in a)a.hasOwnProperty(C)&&(s[C]=a[C]);var I=a.overflow;if(I)for(var C in a)a.hasOwnProperty(C)&&(s.overflow[C]=a.overflow[C]);return s},scrollLeft:function(a,s){if(mD(a)){if(s===void 0)return yj(a);window.scrollTo(s,vj(a))}else{if(s===void 0)return a.scrollLeft;a.scrollLeft=s}},scrollTop:function(a,s){if(mD(a)){if(s===void 0)return vj(a);window.scrollTo(yj(a),s)}else{if(s===void 0)return a.scrollTop;a.scrollTop=s}},viewportWidth:0,viewportHeight:0},Iu),sg=D2t;function M2t(g,a,s){s=s||{},a.nodeType===9&&(a=sg.getWindow(a));var C=s.allowHorizontalScroll,I=s.onlyScrollIfNeeded,A=s.alignWithTop,d=s.alignWithLeft,h=s.offsetTop||0,y=s.offsetLeft||0,Z=s.offsetBottom||0,b=s.offsetRight||0;C=C===void 0?!0:C;var w=sg.isWindow(a),S=sg.offset(g),R=sg.outerHeight(g),H=sg.outerWidth(g),N=void 0,D=void 0,M=void 0,z=void 0,K=void 0,P=void 0,J=void 0,j=void 0,ie=void 0,te=void 0;w?(J=a,te=sg.height(J),ie=sg.width(J),j={left:sg.scrollLeft(J),top:sg.scrollTop(J)},K={left:S.left-j.left-y,top:S.top-j.top-h},P={left:S.left+H-(j.left+ie)+b,top:S.top+R-(j.top+te)+Z},z=j):(N=sg.offset(a),D=a.clientHeight,M=a.clientWidth,z={left:a.scrollLeft,top:a.scrollTop},K={left:S.left-(N.left+(parseFloat(sg.css(a,"borderLeftWidth"))||0))-y,top:S.top-(N.top+(parseFloat(sg.css(a,"borderTopWidth"))||0))-h},P={left:S.left+H-(N.left+M+(parseFloat(sg.css(a,"borderRightWidth"))||0))+b,top:S.top+R-(N.top+D+(parseFloat(sg.css(a,"borderBottomWidth"))||0))+Z}),K.top<0||P.top>0?A===!0?sg.scrollTop(a,z.top+K.top):A===!1?sg.scrollTop(a,z.top+P.top):K.top<0?sg.scrollTop(a,z.top+K.top):sg.scrollTop(a,z.top+P.top):I||(A=A===void 0?!0:!!A,A?sg.scrollTop(a,z.top+K.top):sg.scrollTop(a,z.top+P.top)),C&&(K.left<0||P.left>0?d===!0?sg.scrollLeft(a,z.left+K.left):d===!1?sg.scrollLeft(a,z.left+P.left):K.left<0?sg.scrollLeft(a,z.left+K.left):sg.scrollLeft(a,z.left+P.left):I||(d=d===void 0?!0:!!d,d?sg.scrollLeft(a,z.left+K.left):sg.scrollLeft(a,z.left+P.left)))}var F2t=M2t;(function(g){g.exports=F2t})(aSe);const Y2t=ge(aSe.exports),BR=[];let Tj=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.state={highlightedIndex:null,menuTop:0,menuLeft:0,menuWidth:0,isOpen:!1},I.keyDownHandlers={ArrowDown(A){A.preventDefault();const d=this.getFilteredItems().length;if(!d)return;const{highlightedIndex:h}=this.state,y=h===null||h===d-1?0:h+1;this._performAutoCompleteOnKeyUp=!0,this.setState({highlightedIndex:y,isOpen:!0})},ArrowUp(A){A.preventDefault();const d=this.getFilteredItems().length;if(!d)return;const{highlightedIndex:h}=this.state,y=h===0||h===null?d-1:h-1;this._performAutoCompleteOnKeyUp=!0,this.setState({highlightedIndex:y,isOpen:!0})},Enter(A){if(this.state.isOpen!==!1)if(this.state.highlightedIndex===null)this.setState({isOpen:!1},()=>{this.inputEl.select()});else{A.preventDefault();const d=this.getFilteredItems()[this.state.highlightedIndex],h=this.props.getItemValue(d);this.setState({isOpen:!1,highlightedIndex:null},()=>{this.inputEl.setSelectionRange(h.length,h.length),this.props.onSelect(h,d)})}},Escape(){this.setState({highlightedIndex:null,isOpen:!1})}},I}return E(s,[{key:"getInitialState",value:function(){return{isOpen:!1,highlightedIndex:null}}},{key:"UNSAFE_componentWillMount",value:function(){this._ignoreBlur=!1,this._performAutoCompleteOnUpdate=!1,this._performAutoCompleteOnKeyUp=!1}},{key:"UNSAFE_componentWillReceiveProps",value:function(I){this._performAutoCompleteOnUpdate=!0,(this.props.items!==I.items||this.state.highlightedIndex>=I.items.length)&&this.setState({highlightedIndex:null})}},{key:"componentDidUpdate",value:function(I,A){this.state.isOpen===!0&&A.isOpen===!1&&this.setMenuPositions(),this.state.isOpen&&this._performAutoCompleteOnUpdate&&(this._performAutoCompleteOnUpdate=!1,this.maybeAutoCompleteText()),this.maybeScrollItemIntoView(),A.isOpen!==this.state.isOpen&&this.props.onMenuVisibilityChange(this.state.isOpen,this.inputEl)}},{key:"maybeScrollItemIntoView",value:function(){if(this.state.isOpen===!0&&this.state.highlightedIndex!==null){const I=this.refs[`item-${this.state.highlightedIndex}`],A=this.refs.menu;I&&Y2t(Y.findDOMNode(I),Y.findDOMNode(A),{onlyScrollIfNeeded:!0})}}},{key:"handleKeyDown",value:function(I){this.keyDownHandlers[I.key]?this.keyDownHandlers[I.key].call(this,I):this.setState({highlightedIndex:null,isOpen:!0})}},{key:"handleChange",value:function(I){this._performAutoCompleteOnKeyUp=!0,this.props.onChange(I,I.target.value)}},{key:"handleKeyUp",value:function(){this._performAutoCompleteOnKeyUp&&(this._performAutoCompleteOnKeyUp=!1,this.maybeAutoCompleteText())}},{key:"getFilteredItems",value:function(){let I=this.props.items;return this.props.shouldItemRender&&(I=I.filter(A=>this.props.shouldItemRender(A,this.props.value))),this.props.sortItems&&I.sort((A,d)=>this.props.sortItems(A,d,this.props.value)),I}},{key:"maybeAutoCompleteText",value:function(){if(!this.props.autoHighlight||this.props.value==="")return;const{highlightedIndex:I}=this.state,A=this.getFilteredItems();if(A.length===0)return;const d=I!==null?A[I]:A[0];this.props.getItemValue(d).toLowerCase().indexOf(this.props.value.toLowerCase())===0&&I===null&&this.setState({highlightedIndex:0})}},{key:"setMenuPositions",value:function(){const I=this.inputEl,A=I.getBoundingClientRect(),d=globalThis.window.getComputedStyle(I),h=parseInt(d.marginBottom,10)||0,y=parseInt(d.marginLeft,10)||0,Z=parseInt(d.marginRight,10)||0;this.setState({menuTop:A.bottom+h,menuLeft:A.left+y,menuWidth:A.width+y+Z})}},{key:"highlightItemFromMouse",value:function(I){this.setState({highlightedIndex:I})}},{key:"selectItemFromMouse",value:function(I){const A=this.props.getItemValue(I);this.setState({isOpen:!1,highlightedIndex:null},()=>{this.props.onSelect(A,I),this.inputEl.focus()})}},{key:"setIgnoreBlur",value:function(I){this._ignoreBlur=I}},{key:"renderMenu",value:function(){const I=this.getFilteredItems().map((h,y)=>{const Z=this.props.renderItem(h,this.state.highlightedIndex===y,{cursor:"default"});return X.default.cloneElement(Z,{onMouseDown:()=>this.setIgnoreBlur(!0),onMouseEnter:()=>this.highlightItemFromMouse(y),onClick:()=>this.selectItemFromMouse(h),ref:`item-${y}`})}),A={left:this.state.menuLeft,top:this.state.menuTop,minWidth:this.state.menuWidth};if(!I.length)return null;const d=this.props.renderMenu(I,this.props.value,A);return X.default.cloneElement(d,{ref:"menu"})}},{key:"handleInputBlur",value:function(){this.props.onFocus&&this.props.onFocus(),!this._ignoreBlur&&this.setState({isOpen:!1,highlightedIndex:null})}},{key:"handleInputFocus",value:function(){if(this.props.onFocus&&this.props.onFocus(!0),this._ignoreBlur){this.setIgnoreBlur(!1);return}this._ignoreClick=!0,this.setState({isOpen:!0})}},{key:"isInputFocused",value:function(){return this.inputEl.ownerDocument&&this.inputEl===this.inputEl.ownerDocument.activeElement}},{key:"handleInputClick",value:function(){this.isInputFocused()&&this.state.isOpen===!1?this.setState({isOpen:!0}):this.state.highlightedIndex!==null&&!this._ignoreClick&&this.selectItemFromMouse(this.getFilteredItems()[this.state.highlightedIndex]),this._ignoreClick=!1}},{key:"composeEventHandlers",value:function(I,A){return A?d=>{I(d),A(d)}:I}},{key:"render",value:function(){this.props.debug&&BR.push({id:BR.length,state:this.state});const{inputProps:I}=this.props;return X.default.createElement("div",{style:{...this.props.wrapperStyle},...this.props.wrapperProps},X.default.createElement("input",{...I,ref:A=>{this.inputEl=A},"aria-autocomplete":"list",autoComplete:"off",onBlur:this.composeEventHandlers(this.handleInputBlur.bind(this),I.onBlur&&I.onBlur.bind(this)),onChange:this.handleChange.bind(this),onClick:this.composeEventHandlers(this.handleInputClick.bind(this),I.onClick&&I.onClick.bind(this)),onFocus:this.composeEventHandlers(this.handleInputFocus.bind(this),I.onFocus&&I.onFocus.bind(this)),onKeyDown:this.composeEventHandlers(this.handleKeyDown.bind(this),I.onKeyDown&&I.onKeyDown.bind(this)),onKeyUp:this.composeEventHandlers(this.handleKeyUp.bind(this),I.onKeyUp&&I.onKeyUp.bind(this)),role:"combobox",value:this.props.value}),("open"in this.props?this.props.open:this.state.isOpen)&&this.renderMenu(),this.props.debug&&X.default.createElement("pre",{style:{marginLeft:300}},JSON.stringify(BR.slice(BR.length-5,BR.length),null,2)))}}]),s}(X.default.Component);Tj.defaultProps={value:"",wrapperProps:{},wrapperStyle:{display:"inline-block"},inputProps:{},onChange(){},onSelect(){},renderMenu(g,a,s){return X.default.createElement("div",{style:{...s,...this.menuStyle}},g)},shouldItemRender(){return!0},menuStyle:{borderRadius:"3px",boxShadow:"0 2px 12px rgba(0, 0, 0, 0.1)",background:"rgba(255, 255, 255, 0.9)",padding:"2px 0",fontSize:"90%",position:"fixed",overflow:"auto",maxHeight:"50%"},autoHighlight:!0,onMenuVisibilityChange(){}},Tj.propTypes={autoHighlight:_.exports.bool,debug:_.exports.bool,getItemValue:_.exports.func.isRequired,inputProps:_.exports.object,items:_.exports.array,menuStyle:_.exports.object,onChange:_.exports.func,onFocus:_.exports.func,onMenuVisibilityChange:_.exports.func,onSelect:_.exports.func,open:_.exports.bool,renderItem:_.exports.func.isRequired,renderMenu:_.exports.func,shouldItemRender:_.exports.func,sortItems:_.exports.func,value:_.exports.any,wrapperProps:_.exports.object,wrapperStyle:_.exports.object};const gB={"genome-position-search":"_genome-position-search_1l2sx_1","genome-position-search-focus":"_genome-position-search-focus_1l2sx_2","genome-position-search-bar":"_genome-position-search-bar_1l2sx_16","genome-position-search-dark":"_genome-position-search-dark_1l2sx_34","genome-position-search-bar-button":"_genome-position-search-bar-button_1l2sx_38","genome-position-search-bar-button-focus":"_genome-position-search-bar-button-focus_1l2sx_39","genome-position-search-bar-icon":"_genome-position-search-bar-icon_1l2sx_62","genome-position-search-bar-icon-focus":"_genome-position-search-bar-icon-focus_1l2sx_63","genome-position-search-bar-suggestions":"_genome-position-search-bar-suggestions_1l2sx_83",btn:"_btn_1l2sx_95","btn-sm":"_btn-sm_1l2sx_116","btn-default":"_btn-default_1l2sx_122"};let ASe=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.mounted=!1,I.uid=Fn.nice(),I.chromInfo=null,I.searchField=null,I.autocompleteMenu=null,I.xScale=null,I.yScale=null,I.prevParts=[],I.props.registerViewportChangedListener(I.scalesChanged.bind(u(I))),I.menuPosition={left:0,top:0},I.positionText="chr4:190,998,876-191,000,255",I.state={genes:[],isFocused:!1,autocompleteServer:I.props.autocompleteServer,autocompleteId:I.props.autocompleteId,availableAssemblies:[],selectedAssembly:null},I.styles={item:{padding:"2px 6px",cursor:"default"},highlightedItem:{color:"white",background:"hsl(200, 50%, 50%)",padding:"2px 6px",cursor:"default"},menu:{border:"solid 1px #ccc"}},I.availableAutocompletes={},I.props.autocompleteId&&(I.availableAutocompletes[I.props.chromInfoId]=new Set([{server:I.props.autocompleteServer,acId:I.props.autocompleteId}])),I.availableChromSizes={},I}return E(s,[{key:"componentDidMount",value:function(){this.mounted=!0,Mn(this.autocompleteMenu.inputEl).on("keypress",this.autocompleteKeyPress.bind(this)),this.findAvailableAutocompleteSources(),this.findAvailableChromSizes(),this.props.chromInfoPath&&(this.searchPosition=!0,nu(this.props.chromInfoPath,I=>{if(!I){this.searchPosition=null;return}this.chromInfo=I,this.searchField=new G1(this.chromInfo),this.setPositionText()})),this.setPositionText()}},{key:"componentWillUnmount",value:function(){this.mounted=!1,this.props.removeViewportChangedListener()}},{key:"onAutocompleteChange",value:function(I,A){this.positionText=A,this.setState({value:A,loading:!0}),this.changedPart=null;const d=A.split(/ /);let h=0;const y=[];let Z=!1;for(let b=0;b{if(w)this.setState({loading:!1,genes:[]});else if(this.changedPart>0&&!Z){const R=`${this.state.autocompleteServer}/suggest/?d=${this.state.autocompleteId}&ac=${y[this.changedPart-1].toLowerCase()}-${y[this.changedPart].toLowerCase()}`;Gi.json(R,(H,N)=>{H?this.setState({loading:!1,genes:S}):this.setState({loading:!1,genes:N.concat(S)})},this.props.pubSub)}else this.setState({loading:!1,genes:S})},this.props.pubSub)}}},{key:"setAvailableAssemblies",value:function(){const I=new Set(IC(this.availableChromSizes)),A=new Set([...I]);this.gpsbForm&&this.setState({availableAssemblies:[...A]})}},{key:"setSelectedAssembly",value:function(I){if(!this.mounted||!this.availableChromSizes[I])return;const A=[...this.availableChromSizes[I]][0];this.setState({autocompleteServer:A.server});const{server:d}=A;if(this.availableAutocompletes[I]){const h=[...this.availableAutocompletes[I]][0].acId;this.props.onSelectedAssemblyChanged(I,h,d),this.gpsbForm&&this.setState({autocompleteId:h})}else this.props.onSelectedAssemblyChanged(I,null,d),this.gpsbForm&&this.setState({autocompleteId:null});this.fetchChromInfo(A.uuid,A.server)}},{key:"setPositionText",value:function(){if(!this.mounted||!this.searchField)return;const I=this.searchField.scalesToPositionText(this.xScale,this.yScale,this.props.twoD);this.prevParts=I.split(/[ -]/),this.gpsbForm&&(this.positionText=I,this.origPositionText=I,this.autocompleteMenu.inputEl.value=I)}},{key:"scalesChanged",value:function(I,A){this.xScale=I,this.yScale=A,this.setPositionText()}},{key:"findAvailableChromSizes",value:function(){this.props.trackSourceServers&&this.props.trackSourceServers.forEach(I=>{Gi.json(`${I}/available-chrom-sizes/`,(A,d)=>{A?console.error(A):(d.results.forEach(h=>{h.coordSystem in this.availableChromSizes||(this.availableChromSizes[h.coordSystem]=new Set),this.availableChromSizes[h.coordSystem].add({server:I,uuid:h.uuid}),this.setAvailableAssemblies()}),this.searchField||this.fetchChromInfo(this.props.chromInfoId in this.availableChromSizes?[...this.availableChromSizes[this.props.chromInfoId]][0].uuid:this.props.chromInfoId,this.props.chromInfoId in this.availableChromSizes?[...this.availableChromSizes[this.props.chromInfoId]][0].server:this.props.chromInfoServer))},this.props.pubSub)})}},{key:"findAvailableAutocompleteSources",value:function(){this.props.trackSourceServers&&this.props.trackSourceServers.forEach(I=>{Gi.json(`${I}/tilesets/?limit=100&dt=gene-annotation`,(A,d)=>{A?console.error(A):(d.results.forEach(h=>{h.coordSystem in this.availableAutocompletes||(this.availableAutocompletes[h.coordSystem]=new Set),this.availableAutocompletes[h.coordSystem].add({server:I,acId:h.uuid}),this.setAvailableAssemblies()}),this.state.autocompleteId||this.gpsbForm&&this.availableAutocompletes[this.props.chromInfoId]&&this.setState({autocompleteId:[...this.availableAutocompletes[this.props.chromInfoId]][0].acId}))},this.props.pubSub)})}},{key:"fetchChromInfo",value:function(I,A){nu(`${A}/chrom-sizes/?id=${I}`,d=>{d&&(Gi.json(`${A}/tileset_info/?d=${I}`,(h,y)=>{h||this.gpsbForm&&this.setState({selectedAssembly:y[I].coordSystem})},this.props.pubSub),this.chromInfo=d,this.searchField=new G1(this.chromInfo),this.setPositionText())},this.props.pubSub)}},{key:"autocompleteKeyPress",value:function(I){I.keyCode===13&&this.buttonClick()}},{key:"genePositionToSearchBarText",value:function(I){}},{key:"replaceGenesWithLoadedPositions",value:function(I){const A=this.positionText,d=A.split(" ");let h=!1;for(let Z=0;Zw;){const H=b.slice(w,S).join("-");if(I[H.toLowerCase()]){const N=I[H.toLowerCase()],D=Math.floor((N.txEnd-N.txStart)/4);w===0&&S{if(h){const y={};for(let b=0;bconsole.error(h))}},{key:"buttonClick",value:function(){this.setState({genes:[]}),this.replaceGenesWithPositions(I=>{const A=this.positionText;if(this.searchField!==null){const d=this.searchField.searchPosition(A),h=d[0];let y=d[1];if(!h){this.setPositionText();return}if(h&&(Number.isNaN(+h[0])||Number.isNaN(+h[1]))||y&&(Number.isNaN(+y[0])||Number.isNaN(+y[1])))return;y||(y=h);const Z=this.xScale.copy().domain(h),b=this.yScale.copy().domain(y),[w,S,R]=Do(Z,b);I&&this.props.onGeneSearch({geneSymbol:I,range:h,centerX:w,centerY:S}),this.props.setCenters(w,S,R,Upe)}})}},{key:"searchFieldSubmit",value:function(){this.buttonClick()}},{key:"pathJoin",value:function(I,A){const d=A||"/",h=new RegExp(`${d}{1,}`,"g");return I.join(d).replace(h,d)}},{key:"geneSelected",value:function(I,A){const d=this.positionText.split(" ");let h=this.changedPart;for(let y=0;yZ.length-1)h-=Z.length;else{if(Z[h]=A.geneName,b.length===2&&h>0&&Z[h-1].toLowerCase()===b[0].toLowerCase()){const w=Z.slice(0,h-1);w.push(b.join("-")),hX.default.createElement("option",{key:A,value:A},A));return X.default.createElement("div",{ref:A=>{this.gpsbForm=A},className:lr({[gB["genome-position-search-focus"]]:this.state.isFocused,[gB["genome-position-search"]]:!this.state.isFocused,[gB["genome-position-search-dark"]]:this.props.theme===ig})},!this.props.hideAvailableAssemblies&&X.default.createElement("select",{ref:A=>{this.assemblyPickButton=A},className:gB["genome-position-search-bar-button"],id:this.uid,onChange:this.handleAssemblySelectEvt.bind(this),value:this.state.selectedAssembly||void 0},I),X.default.createElement(Tj,{ref:A=>{this.autocompleteMenu=A},getItemValue:A=>A.geneName,inputProps:{className:gB["genome-position-search-bar"],title:"Current location: enter a symbol or location to change the position of the current view"},items:this.state.genes,menuStyle:{position:"absolute",left:this.menuPosition.left,top:this.menuPosition.top,border:"1px solid black"},onChange:this.onAutocompleteChange.bind(this),onFocus:this.focusHandler.bind(this),onMenuVisibilityChange:this.handleMenuVisibilityChange.bind(this),onSelect:(A,d)=>this.geneSelected(A,d),onSubmit:this.searchFieldSubmit.bind(this),renderItem:(A,d)=>X.default.createElement("div",{key:A.refseqid,id:A.refseqid,style:d?this.styles.highlightedItem:this.styles.item},A.geneName),renderMenu:this.handleRenderMenu.bind(this),value:this.state.selectedAssembly?this.positionText:"No valid assembly selected",wrapperStyle:{width:"100%"}}),X.default.createElement(Act,{onClick:this.buttonClick.bind(this),theStyle:"multitrack-header-icon"}))}}]),s}(X.default.Component);ASe.propTypes={autocompleteId:_.exports.string,autocompleteServer:_.exports.string,chromInfoId:_.exports.string,chromInfoServer:_.exports.string,hideAvailableAssemblies:_.exports.bool,isFocused:_.exports.bool,pubSub:_.exports.object,onFocus:_.exports.func,onGeneSearch:_.exports.func,onSelectedAssemblyChanged:_.exports.func,registerViewportChangedListener:_.exports.func,removeViewportChangedListener:_.exports.func,setCenters:_.exports.func,theme:_.exports.symbol.isRequired,trackSourceServers:_.exports.array,twoD:_.exports.bool};const K2t=qZ(L0(ASe)),_2t={"export-link-dialog-wrapper":"_export-link-dialog-wrapper_p9gxw_1"};let Rj=function(g){o(s,g);var a=l(s);function s(){return T(this,s),a.apply(this,arguments)}return E(s,[{key:"render",value:function(){return X.default.createElement(eR,{okayOnly:!0,okayTitle:"Done",onOkay:this.props.onDone,title:"Share view link"},X.default.createElement("div",{className:_2t["export-link-dialog-wrapper"]},X.default.createElement("input",{ref:I=>{I&&(this.input=I,I.focus(),I.select())},onClick:I=>{I.target.select()},placeholder:"Generating the link...",readOnly:!0,value:this.props.url}),X.default.createElement(nh,{onClick:I=>{this.input.select(),document.execCommand("copy")}},"Copy")))}}]),s}(X.default.Component);Rj.defaultProps={onDone:()=>{},url:""},Rj.propTypes={onDone:_.exports.func,url:_.exports.string};let uSe=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.state={submenuShown:!1},I}return E(s,[{key:"getConfigureViewMenu",value:function(I,A){const d=["backgroundColor"],h={},y={};for(const Z of d)if(Z in Object.keys(qa)&&(h[Z]={name:qa[Z].name},qa[Z].inlineOptions))for(const b in qa[Z].inlineOptions){const w=qa[Z].inlineOptions[b];h[Z].children||(h[Z].children={});const S={name:w.name,value:w.value};S.handler=()=>{y[Z]=w.value,this.props.onOptionsChanged(y)},h[Z].children[b]=S}return X.default.createElement(vQ,{key:"config-series-menu",closeMenu:this.props.closeMenu,menuItems:h,orientation:this.state.orientation,parentBbox:A,position:I,theme:this.props.theme})}},{key:"getSubmenu",value:function(){if(this.state.submenuShown){const I=this.state.submenuSourceBbox,A=this.state.orientation==="left"?{left:this.state.left,top:I.top}:{left:this.state.left+I.width+7,top:I.top};return this.state.submenuShown.option==="options"?this.getConfigureViewMenu(A,I):X.default.createElement("div",null)}return X.default.createElement("div",null)}},{key:"render",value:function(){return X.default.createElement("div",{ref:I=>{this.div=I},className:lr(sn["context-menu"],{[sn["context-menu-dark"]]:this.props.theme===ig}),"data-menu-type":"ConfigViewMenu",style:{left:this.state.left,top:this.state.top}},X.default.createElement(Gn,{onClick:I=>this.props.onTogglePositionSearchBox(I)},"Toggle position search box"),X.default.createElement("hr",{className:sn["context-menu-hr"]}),X.default.createElement(Gn,{onClick:I=>this.props.onZoomToData(I)},"Zoom to data extent"),X.default.createElement(Gn,{onClick:I=>this.props.onClearView(I)},"Clear View"),X.default.createElement("hr",{className:sn["context-menu-hr"]}),X.default.createElement(Gn,{onClick:I=>this.props.onYankZoom(I)},"Take zoom from"),X.default.createElement(Gn,{onClick:I=>this.props.onYankLocation(I)},"Take location from"),X.default.createElement(Gn,{onClick:I=>this.props.onYankZoomAndLocation(I)},"Take zoom and location from"),X.default.createElement("hr",{className:sn["context-menu-hr"]}),X.default.createElement(Gn,{onClick:this.props.onLockZoom},"Lock zoom with"),X.default.createElement(Gn,{onClick:this.props.onLockLocation},"Lock location with"),X.default.createElement(Gn,{onClick:this.props.onLockZoomAndLocation},"Lock zoom and location with"),X.default.createElement("hr",{className:sn["context-menu-hr"]}),X.default.createElement(Gn,{onClick:this.props.onTakeAndLockZoomAndLocation},"Take and lock zoom and location with"),X.default.createElement("hr",{className:sn["context-menu-hr"]}),X.default.createElement(Gn,{onClick:I=>this.props.onUnlockZoom(I)},"Unlock zoom"),X.default.createElement(Gn,{onClick:I=>this.props.onUnlockLocation(I)},"Unlock location"),X.default.createElement(Gn,{onClick:I=>this.props.onUnlockZoomAndLocation(I)},"Unlock zoom and location"),X.default.createElement("hr",{className:sn["context-menu-hr"]}),X.default.createElement(Gn,{onClick:I=>this.props.onProjectViewport(I)},"Show this viewport on"),X.default.createElement("hr",{className:sn["context-menu-hr"]}),X.default.createElement(Gn,{onClick:I=>this.props.onEditViewConfig(I)},"Edit view config"),X.default.createElement("hr",{className:sn["context-menu-hr"]}),X.default.createElement(Gn,{onClick:()=>this.props.onExportSVG()},"Export views as SVG"),X.default.createElement(Gn,{onClick:()=>this.props.onExportPNG()},"Export views as PNG"),X.default.createElement(Gn,{onClick:()=>this.props.onExportViewAsJSON()},"Export views as JSON"),X.default.createElement(Gn,{onClick:()=>this.props.onExportViewAsLink()},"Export views as Link"),this.getSubmenu())}}]),s}(rm);uSe.propTypes={onEditViewConfig:_.exports.func.isRequired,onExportSVG:_.exports.func,onExportPNG:_.exports.func,onExportViewAsJSON:_.exports.func,onExportViewAsLink:_.exports.func,onLockLocation:_.exports.func,onLockZoom:_.exports.func,onLockZoomAndLocation:_.exports.func,onProjectViewport:_.exports.func,onTakeAndLockZoomAndLocation:_.exports.func,onTogglePositionSearchBox:_.exports.func,onUnlockLocation:_.exports.func,onUnlockZoom:_.exports.func,onUnlockZoomAndLocation:_.exports.func,onYankLocation:_.exports.func,onYankZoom:_.exports.func,onYankZoomAndLocation:_.exports.func,onZoomToData:_.exports.func,theme:_.exports.symbol};const fC={"add-track-position-table":"_add-track-position-table_wdy5w_1","add-track-position-table-dark":"_add-track-position-table-dark_wdy5w_7","add-track-position-other":"_add-track-position-other_wdy5w_11","add-track-position-top-center":"_add-track-position-top-center_wdy5w_15","add-track-position-middle-left":"_add-track-position-middle-left_wdy5w_30","add-track-position-middle-right":"_add-track-position-middle-right_wdy5w_45","add-track-position-middle-middle":"_add-track-position-middle-middle_wdy5w_60","add-track-position-bottom-middle":"_add-track-position-bottom-middle_wdy5w_71","add-track-position-span":"_add-track-position-span_wdy5w_86"};function dSe(g){return X.default.createElement("div",null,X.default.createElement("div",{className:fC["add-track-position-span"]},"Add Track..."),X.default.createElement("table",{className:lr(fC["add-track-position-table"],{[fC["add-track-position-table-dark"]]:g.theme===ig})},X.default.createElement("tbody",null,X.default.createElement("tr",{style:{height:"30px"}},X.default.createElement("td",{className:fC["add-track-position-other"]}),X.default.createElement("td",{className:fC["add-track-position-top-center"],onClick:()=>g.onTrackPositionChosen("top")},"top"),X.default.createElement("td",{className:fC["add-track-position-other"]})),X.default.createElement("tr",{style:{height:"80px"}},X.default.createElement("td",{className:fC["add-track-position-middle-left"],onClick:()=>g.onTrackPositionChosen("left")},"left"),X.default.createElement("td",{className:fC["add-track-position-middle-middle"],onClick:()=>g.onTrackPositionChosen("center")},"center"),X.default.createElement("td",{className:fC["add-track-position-middle-right"],onClick:()=>g.onTrackPositionChosen("right")},"right")),X.default.createElement("tr",{style:{height:"30px"}},X.default.createElement("td",{className:fC["add-track-position-other"]}),X.default.createElement("td",{className:fC["add-track-position-bottom-middle"],onClick:()=>g.onTrackPositionChosen("bottom")},"bottom"),X.default.createElement("td",{className:fC["add-track-position-other"]})))))}dSe.propTypes={onTrackPositionChosen:_.exports.func.isRequired,theme:_.exports.symbol.isRequired};const P2t=L0(dSe);let Vj=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.configImg=null,I.plusImg=null,I.state={addTrackPositionMenuUid:null,addTrackPositionMenuPosition:null,configMenuUid:null,configMenuPosition:null,isFocused:!1,width:-1},I.handleTrackPositionChosenBound=I.handleTrackPositionChosen.bind(u(I)),I}return E(s,[{key:"componentDidMount",value:function(){this.setState({width:this.el.clientWidth})}},{key:"checkWidth",value:function(){const I=this.el.clientWidth;I!==this.state.width&&this.setState({width:I})}},{key:"handleConfigMenuOpened",value:function(I){this.setState({configMenuUid:I,configMenuPosition:this.configImg.getBoundingClientRect()})}},{key:"handleAddTrackPositionMenuOpened",value:function(I){this.setState({addTrackPositionMenuUid:I,addTrackPositionMenuPosition:this.plusImg.getBoundingClientRect()})}},{key:"handleTrackPositionChosen",value:function(I){this.props.onTrackPositionChosen(I),this.setState({addTrackPositionMenuUid:null,addTrackPositionMenuPosition:null})}},{key:"render",value:function(){let I=null,A=null;this.state.addTrackPositionMenuPosition&&(A=X.default.createElement(Im,{onMenuClosed:()=>{this.setState({addTrackPositionMenuUid:null,addTrackPositionMenuPosition:null})}},X.default.createElement(rm,{orientation:"left",position:this.state.addTrackPositionMenuPosition,theme:this.props.theme},X.default.createElement(P2t,{onTrackPositionChosen:this.handleTrackPositionChosenBound})))),this.state.configMenuUid&&(I=X.default.createElement(Im,{onMenuClosed:()=>this.setState({configMenuUid:null})},X.default.createElement(uSe,{onClearView:()=>{this.setState({configMenuUid:null}),this.props.onClearView()},onEditViewConfig:()=>{this.setState({configMenuUid:null}),this.props.onEditViewConfig(this.state.configMenuUid)},onExportPNG:()=>{this.setState({configMenuUid:null}),this.props.onExportPNG()},onExportSVG:()=>{this.setState({configMenuUid:null}),this.props.onExportSVG()},onExportViewAsJSON:()=>{this.setState({configMenuUid:null}),this.props.onExportViewsAsJSON()},onExportViewAsLink:()=>{this.setState({configMenuUid:null}),this.props.onExportViewsAsLink()},onLockLocation:()=>{this.setState({configMenuUid:null}),this.props.onLockLocation(this.state.configMenuUid)},onLockZoom:()=>{this.setState({configMenuUid:null}),this.props.onLockZoom(this.state.configMenuUid)},onLockZoomAndLocation:()=>{this.setState({configMenuUid:null}),this.props.onLockZoomAndLocation(this.state.configMenuUid)},onOptionsChanged:Z=>{this.props.onViewOptionsChanged(Z),this.setState({configMenuUid:null})},onProjectViewport:()=>{this.setState({configMenuUid:null}),this.props.onProjectViewport(this.state.configMenuUid)},onTakeAndLockZoomAndLocation:()=>{this.setState({configMenuUid:null}),this.props.onTakeAndLockZoomAndLocation(this.state.configMenuUid)},onTogglePositionSearchBox:()=>{this.setState({configMenuUid:null}),this.props.onTogglePositionSearchBox(this.state.configMenuUid)},onUnlockLocation:()=>{this.setState({configMenuUid:null}),this.props.onUnlockLocation(this.state.configMenuUid)},onUnlockZoom:()=>{this.setState({configMenuUid:null}),this.props.onUnlockZoom(this.state.configMenuUid)},onUnlockZoomAndLocation:()=>{this.setState({configMenuUid:null}),this.props.onUnlockZoomAndLocation(this.state.configMenuUid)},onYankLocation:()=>{this.setState({configMenuUid:null}),this.props.onYankLocation(this.state.configMenuUid)},onYankZoom:()=>{this.setState({configMenuUid:null}),this.props.onYankZoom(this.state.configMenuUid)},onYankZoomAndLocation:()=>{this.setState({configMenuUid:null}),this.props.onYankZoomAndLocation(this.state.configMenuUid)},onZoomToData:()=>{this.setState({configMenuUid:null}),this.props.onZoomToData(this.state.configMenuUid)},orientation:"left",position:this.state.configMenuPosition,theme:this.props.theme})));const d=this.props.getGenomePositionSearchBox(this.state.isFocused,Z=>{this.setState({isFocused:Z})}),h=lr(this.state.isFocused?aC["multitrack-header-focus"]:aC["multitrack-header"],{[aC["multitrack-header-dark"]]:this.props.theme===ig}),y=this.state.width<=Qpe?aC["multitrack-header-icon-squeazed"]:aC["multitrack-header-icon"];return X.default.createElement("div",{ref:Z=>{this.el=Z},className:h},X.default.createElement("div",{className:aC["multitrack-header-left"]},this.props.mouseTool===oC&&X.default.createElement("svg",{className:lr(aC["mouse-tool-selection"],y),title:"Selection tool active"},X.default.createElement("use",{xlinkHref:"#select"})),X.default.createElement("div",{className:aC["multitrack-header-grabber"],title:"Drag to move the view"},X.default.createElement("div",null),X.default.createElement("div",null),X.default.createElement("div",null)),this.state.width>jpe&&X.default.createElement("div",{className:aC["multitrack-header-search"]},this.props.isGenomePositionSearchBoxVisible&&d)),X.default.createElement("nav",{className:aC["multitrack-header-nav-list"]},X.default.createElement("svg",{className:y,onClick:this.props.onAddView},X.default.createElement("title",null,"Add new view (clone this view)"),X.default.createElement("use",{xlinkHref:"#copy"})),X.default.createElement("svg",{ref:Z=>{this.configImg=Z},className:y,onClick:()=>this.handleConfigMenuOpened(this.props.viewUid)},X.default.createElement("title",null,"Configure this view"),X.default.createElement("use",{xlinkHref:"#cog"})),X.default.createElement("svg",{ref:Z=>{this.plusImg=Z},className:y,onClick:()=>this.handleAddTrackPositionMenuOpened(this.props.viewUid)},X.default.createElement("title",null,"Add Track"),X.default.createElement("use",{xlinkHref:"#plus"})),X.default.createElement("svg",{className:y,onClick:this.props.onCloseView},X.default.createElement("title",null,"Close View"),X.default.createElement("use",{xlinkHref:"#cross"}))),I,A)}}]),s}(X.default.Component);Vj.defaultProps={isGenomePositionSearchBoxVisible:!1},Vj.propTypes={getGenomePositionSearchBox:_.exports.func.isRequired,isGenomePositionSearchBoxVisible:_.exports.bool,mouseTool:_.exports.string.isRequired,onAddView:_.exports.func.isRequired,onClearView:_.exports.func.isRequired,onCloseView:_.exports.func.isRequired,onEditViewConfig:_.exports.func.isRequired,onExportSVG:_.exports.func.isRequired,onExportPNG:_.exports.func.isRequired,onExportViewsAsJSON:_.exports.func.isRequired,onExportViewsAsLink:_.exports.func.isRequired,onLockLocation:_.exports.func.isRequired,onLockZoom:_.exports.func.isRequired,onLockZoomAndLocation:_.exports.func.isRequired,onProjectViewport:_.exports.func.isRequired,onTakeAndLockZoomAndLocation:_.exports.func.isRequired,onTogglePositionSearchBox:_.exports.func.isRequired,onTrackPositionChosen:_.exports.func.isRequired,onUnlockLocation:_.exports.func.isRequired,onUnlockZoom:_.exports.func.isRequired,onUnlockZoomAndLocation:_.exports.func.isRequired,onViewOptionsChanged:_.exports.func.isRequired,onYankLocation:_.exports.func.isRequired,onYankZoom:_.exports.func.isRequired,onYankZoomAndLocation:_.exports.func.isRequired,onZoomToData:_.exports.func.isRequired,theme:_.exports.symbol.isRequired,viewUid:_.exports.string.isRequired};const z2t=L0(Vj);var hSe={};Object.defineProperty(hSe,"__esModule",{value:!0});var lm=Object.assign||function(g){for(var a=1;a=0||Object.prototype.hasOwnProperty.call(g,C)&&(s[C]=g[C]);return s}function Q2t(g,a){if(!(g instanceof a))throw new TypeError("Cannot call a class as a function")}function fSe(g,a){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a&&(typeof a=="object"||typeof a=="function")?a:g}function j2t(g,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof a);g.prototype=Object.create(a&&a.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),a&&(Object.setPrototypeOf?Object.setPrototypeOf(g,a):g.__proto__=a)}var $2t=13,q2t=9,eTt=8,tTt=89,pD=90,iTt=77,mSe=57,pSe=219,bSe=222,ySe=192,nTt=27,vSe=100,rTt=3e3,gTt="navigator"in globalThis&&/Win/i.test(navigator.platform),Ej="navigator"in globalThis&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),bD="npm__react-simple-code-editor__textarea",oTt=` -/** - * Reset the text fill color so that placeholder is visible - */ -.`+bD+`:empty { - -webkit-text-fill-color: inherit !important; -} - -/** - * Hack to apply on some CSS on IE10 and IE11 - */ -@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) { - /** - * IE doesn't support '-webkit-text-fill-color' - * So we use 'color: transparent' to make the text transparent on IE - * Unlike other browsers, it doesn't affect caret color in IE - */ - .`+bD+` { - color: transparent !important; - } - - .`+bD+`::selection { - background-color: #accef7 !important; - color: transparent !important; - } -} -`,ZSe=function(g){j2t(a,g);function a(){var s,C,I,A;Q2t(this,a);for(var d=arguments.length,h=Array(d),y=0;y1&&arguments[1]!==void 0?arguments[1]:!1,w=I._history,S=w.stack,R=w.offset;if(S.length&&R>-1){I._history.stack=S.slice(0,R+1);var H=I._history.stack.length;if(H>vSe){var N=H-vSe;I._history.stack=S.slice(N,H),I._history.offset=Math.max(I._history.offset-N,0)}}var D=Date.now();if(b){var M=I._history.stack[I._history.offset];if(M&&D-M.timestamp=J&&Ge<=j&&Ne.startsWith(K)?Ne.substring(K.length):Ne}).join(` -`);if(D!==ie){var te=P[J];I._applyEdits({value:ie,selectionStart:te.startsWith(K)?M-K.length:M,selectionEnd:z-(D.length-ie.length)})}}else if(M!==z){var Ce=I._getLines(D,M),ue=Ce.length-1,oe=I._getLines(D,z).length-1,he=Ce[ue];I._applyEdits({value:D.split(` -`).map(function(Ne,Ge){return Ge>=ue&&Ge<=oe?K+Ne:Ne}).join(` -`),selectionStart:/\S/.test(he)?M+K.length:M,selectionEnd:z+K.length*(oe-ue+1)})}else{var ye=M+K.length;I._applyEdits({value:D.substring(0,M)+K+D.substring(z),selectionStart:ye,selectionEnd:ye})}else if(Z.keyCode===eTt){var Ie=M!==z,fe=D.substring(0,M);if(fe.endsWith(K)&&!Ie){Z.preventDefault();var We=M-K.length;I._applyEdits({value:D.substring(0,M-K.length)+D.substring(z),selectionStart:We,selectionEnd:We})}}else if(Z.keyCode===$2t){if(M===z){var _e=I._getLines(D,M).pop(),qe=_e.match(/^\s+/);if(qe&&qe[0]){Z.preventDefault();var nt=` -`+qe[0],At=M+nt.length;I._applyEdits({value:D.substring(0,M)+nt+D.substring(z),selectionStart:At,selectionEnd:At})}}}else if(Z.keyCode===mSe||Z.keyCode===pSe||Z.keyCode===bSe||Z.keyCode===ySe){var Tt=void 0;Z.keyCode===mSe&&Z.shiftKey?Tt=["(",")"]:Z.keyCode===pSe?Z.shiftKey?Tt=["{","}"]:Tt=["[","]"]:Z.keyCode===bSe?Z.shiftKey?Tt=['"','"']:Tt=["'","'"]:Z.keyCode===ySe&&!Z.shiftKey&&(Tt=["`","`"]),M!==z&&Tt&&(Z.preventDefault(),I._applyEdits({value:D.substring(0,M)+Tt[0]+D.substring(M,z)+Tt[1]+D.substring(z),selectionStart:M,selectionEnd:z+2}))}else(Ej?Z.metaKey&&Z.keyCode===pD:Z.ctrlKey&&Z.keyCode===pD)&&!Z.shiftKey&&!Z.altKey?(Z.preventDefault(),I._undoEdit()):(Ej?Z.metaKey&&Z.keyCode===pD&&Z.shiftKey:gTt?Z.ctrlKey&&Z.keyCode===tTt:Z.ctrlKey&&Z.keyCode===pD&&Z.shiftKey)&&!Z.altKey?(Z.preventDefault(),I._redoEdit()):Z.keyCode===iTt&&Z.ctrlKey&&(!Ej||Z.shiftKey)&&(Z.preventDefault(),I.setState(function(Ne){return{capture:!Ne.capture}}))}},I._handleChange=function(Z){var b=Z.target,w=b.value,S=b.selectionStart,R=b.selectionEnd;I._recordChange({value:w,selectionStart:S,selectionEnd:R},!0),I.props.onValueChange(w)},I._history={stack:[],offset:-1},C),fSe(I,A)}return O2t(a,[{key:"componentDidMount",value:function(){this._recordCurrentState()}},{key:"render",value:function(){var C=this,I=this.props,A=I.value,d=I.style,h=I.padding,y=I.highlight,Z=I.textareaId,b=I.autoFocus,w=I.disabled,S=I.form,R=I.maxLength,H=I.minLength,N=I.name,D=I.placeholder,M=I.readOnly,z=I.required,K=I.onClick,P=I.onFocus,J=I.onBlur,j=I.onKeyUp;I.onKeyDown,I.onValueChange,I.tabSize,I.insertSpaces,I.ignoreTabKey;var ie=U2t(I,["value","style","padding","highlight","textareaId","autoFocus","disabled","form","maxLength","minLength","name","placeholder","readOnly","required","onClick","onFocus","onBlur","onKeyUp","onKeyDown","onValueChange","tabSize","insertSpaces","ignoreTabKey"]),te={paddingTop:h,paddingRight:h,paddingBottom:h,paddingLeft:h},Ce=y(A);return GR.createElement("div",lm({},ie,{style:lm({},SR.container,d)}),GR.createElement("textarea",{ref:function(oe){return C._input=oe},style:lm({},SR.editor,SR.textarea,te),className:bD,id:Z,value:A,onChange:this._handleChange,onKeyDown:this._handleKeyDown,onClick:K,onKeyUp:j,onFocus:P,onBlur:J,disabled:w,form:S,maxLength:R,minLength:H,name:N,placeholder:D,readOnly:M,required:z,autoFocus:b,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"data-gramm":!1}),GR.createElement("pre",lm({"aria-hidden":"true",style:lm({},SR.editor,SR.highlight,te)},typeof Ce=="string"?{dangerouslySetInnerHTML:{__html:Ce+"
"}}:{children:Ce})),GR.createElement("style",{type:"text/css",dangerouslySetInnerHTML:{__html:oTt}}))}},{key:"session",get:function(){return{history:this._history}},set:function(C){this._history=C.history}}]),a}(GR.Component);ZSe.defaultProps={tabSize:2,insertSpaces:!0,ignoreTabKey:!1,padding:0};var aTt=hSe.default=ZSe,SR={container:{position:"relative",textAlign:"left",boxSizing:"border-box",padding:0,overflow:"hidden"},textarea:{position:"absolute",top:0,left:0,height:"100%",width:"100%",resize:"none",color:"inherit",overflow:"hidden",MozOsxFontSmoothing:"grayscale",WebkitFontSmoothing:"antialiased",WebkitTextFillColor:"transparent"},highlight:{position:"relative",pointerEvents:"none"},editor:{margin:0,border:0,background:"none",boxSizing:"inherit",display:"inherit",fontFamily:"inherit",fontSize:"inherit",fontStyle:"inherit",fontVariantLigatures:"inherit",fontWeight:"inherit",letterSpacing:"inherit",lineHeight:"inherit",tabSize:"inherit",textIndent:"inherit",textRendering:"inherit",textTransform:"inherit",whiteSpace:"pre-wrap",wordBreak:"keep-all",overflowWrap:"break-word"}},Hj={exports:{}};(function(g){var a=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};/** -* Prism: Lightweight, robust, elegant syntax highlighting -* -* @license MIT -* @author Lea Verou -* @namespace -* @public -*/var s=function(C){var I=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,A=0,d={},h={manual:C.Prism&&C.Prism.manual,disableWorkerMessageHandler:C.Prism&&C.Prism.disableWorkerMessageHandler,util:{encode:function z(K){return K instanceof y?new y(K.type,z(K.content),K.alias):Array.isArray(K)?K.map(z):K.replace(/&/g,"&").replace(/"u")return null;if("currentScript"in document&&1<2)return document.currentScript;try{throw new Error}catch(J){var z=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(J.stack)||[])[1];if(z){var K=document.getElementsByTagName("script");for(var P in K)if(K[P].src==z)return K[P]}return null}},isActive:function(z,K,P){for(var J="no-"+K;z;){var j=z.classList;if(j.contains(K))return!0;if(j.contains(J))return!1;z=z.parentElement}return!!P}},languages:{plain:d,plaintext:d,text:d,txt:d,extend:function(z,K){var P=h.util.clone(h.languages[z]);for(var J in K)P[J]=K[J];return P},insertBefore:function(z,K,P,J){J=J||h.languages;var j=J[z],ie={};for(var te in j)if(j.hasOwnProperty(te)){if(te==K)for(var Ce in P)P.hasOwnProperty(Ce)&&(ie[Ce]=P[Ce]);P.hasOwnProperty(te)||(ie[te]=j[te])}var ue=J[z];return J[z]=ie,h.languages.DFS(h.languages,function(oe,he){he===ue&&oe!=z&&(this[oe]=ie)}),ie},DFS:function z(K,P,J,j){j=j||{};var ie=h.util.objId;for(var te in K)if(K.hasOwnProperty(te)){P.call(K,te,K[te],J||te);var Ce=K[te],ue=h.util.type(Ce);ue==="Object"&&!j[ie(Ce)]?(j[ie(Ce)]=!0,z(Ce,P,null,j)):ue==="Array"&&!j[ie(Ce)]&&(j[ie(Ce)]=!0,z(Ce,P,te,j))}}},plugins:{},highlightAll:function(z,K){h.highlightAllUnder(document,z,K)},highlightAllUnder:function(z,K,P){var J={callback:P,container:z,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};h.hooks.run("before-highlightall",J),J.elements=Array.prototype.slice.apply(J.container.querySelectorAll(J.selector)),h.hooks.run("before-all-elements-highlight",J);for(var j=0,ie;ie=J.elements[j++];)h.highlightElement(ie,K===!0,J.callback)},highlightElement:function(z,K,P){var J=h.util.getLanguage(z),j=h.languages[J];h.util.setLanguage(z,J);var ie=z.parentElement;ie&&ie.nodeName.toLowerCase()==="pre"&&h.util.setLanguage(ie,J);var te=z.textContent,Ce={element:z,language:J,grammar:j,code:te};function ue(he){Ce.highlightedCode=he,h.hooks.run("before-insert",Ce),Ce.element.innerHTML=Ce.highlightedCode,h.hooks.run("after-highlight",Ce),h.hooks.run("complete",Ce),P&&P.call(Ce.element)}if(h.hooks.run("before-sanity-check",Ce),ie=Ce.element.parentElement,ie&&ie.nodeName.toLowerCase()==="pre"&&!ie.hasAttribute("tabindex")&&ie.setAttribute("tabindex","0"),!Ce.code){h.hooks.run("complete",Ce),P&&P.call(Ce.element);return}if(h.hooks.run("before-highlight",Ce),!Ce.grammar){ue(h.util.encode(Ce.code));return}if(K&&C.Worker){var oe=new Worker(h.filename);oe.onmessage=function(he){ue(he.data)},oe.postMessage(JSON.stringify({language:Ce.language,code:Ce.code,immediateClose:!0}))}else ue(h.highlight(Ce.code,Ce.grammar,Ce.language))},highlight:function(z,K,P){var J={code:z,grammar:K,language:P};if(h.hooks.run("before-tokenize",J),!J.grammar)throw new Error('The language "'+J.language+'" has no grammar.');return J.tokens=h.tokenize(J.code,J.grammar),h.hooks.run("after-tokenize",J),y.stringify(h.util.encode(J.tokens),J.language)},tokenize:function(z,K){var P=K.rest;if(P){for(var J in P)K[J]=P[J];delete K.rest}var j=new w;return S(j,j.head,z),b(z,j,K,j.head,0),H(j)},hooks:{all:{},add:function(z,K){var P=h.hooks.all;P[z]=P[z]||[],P[z].push(K)},run:function(z,K){var P=h.hooks.all[z];if(!(!P||!P.length))for(var J=0,j;j=P[J++];)j(K)}},Token:y};C.Prism=h;function y(z,K,P,J){this.type=z,this.content=K,this.alias=P,this.length=(J||"").length|0}y.stringify=function z(K,P){if(typeof K=="string")return K;if(Array.isArray(K)){var J="";return K.forEach(function(ue){J+=z(ue,P)}),J}var j={type:K.type,content:z(K.content,P),tag:"span",classes:["token",K.type],attributes:{},language:P},ie=K.alias;ie&&(Array.isArray(ie)?Array.prototype.push.apply(j.classes,ie):j.classes.push(ie)),h.hooks.run("wrap",j);var te="";for(var Ce in j.attributes)te+=" "+Ce+'="'+(j.attributes[Ce]||"").replace(/"/g,""")+'"';return"<"+j.tag+' class="'+j.classes.join(" ")+'"'+te+">"+j.content+""};function Z(z,K,P,J){z.lastIndex=K;var j=z.exec(P);if(j&&J&&j[1]){var ie=j[1].length;j.index+=ie,j[0]=j[0].slice(ie)}return j}function b(z,K,P,J,j,ie){for(var te in P)if(!(!P.hasOwnProperty(te)||!P[te])){var Ce=P[te];Ce=Array.isArray(Ce)?Ce:[Ce];for(var ue=0;ue=ie.reach);nt+=qe.value.length,qe=qe.next){var At=qe.value;if(K.length>z.length)return;if(!(At instanceof y)){var Tt=1,Ne;if(Ie){if(Ne=Z(_e,nt,z,ye),!Ne||Ne.index>=z.length)break;var at=Ne.index,Ge=Ne.index+Ne[0].length,He=nt;for(He+=qe.value.length;at>=He;)qe=qe.next,He+=qe.value.length;if(He-=qe.value.length,nt=He,qe.value instanceof y)continue;for(var Xe=qe;Xe!==K.tail&&(Heie.reach&&(ie.reach=_t);var Ci=qe.prev;xt&&(Ci=S(K,Ci,xt),nt+=xt.length),R(K,Ci,Tt);var Dt=new y(te,he?h.tokenize(bt,he):bt,fe,bt);if(qe=S(K,Ci,Dt),Vt&&S(K,qe,Vt),Tt>1){var Zi={cause:te+","+ue,reach:_t};b(z,K,P,qe.prev,nt,Zi),ie&&Zi.reach>ie.reach&&(ie.reach=Zi.reach)}}}}}}function w(){var z={value:null,prev:null,next:null},K={value:null,prev:z,next:null};z.next=K,this.head=z,this.tail=K,this.length=0}function S(z,K,P){var J=K.next,j={value:P,prev:K,next:J};return K.next=j,J.prev=j,z.length++,j}function R(z,K,P){for(var J=K.next,j=0;j1){ve[0]=ve[0].slice(0,-1);for(var vt=ve.length-1,St=1;St= 0x80 (not a basic code point)","invalid-input":"Invalid input"},oe=N-D,he=Math.floor,ye=String.fromCharCode;function Ie(Se){throw new RangeError(ue[Se])}function fe(Se,ve){for(var Pe=[],vt=Se.length;vt--;)Pe[vt]=ve(Se[vt]);return Pe}function We(Se,ve){var Pe=Se.split("@"),vt="";Pe.length>1&&(vt=Pe[0]+"@",Se=Pe[1]),Se=Se.replace(Ce,".");var St=Se.split("."),li=fe(St,ve).join(".");return vt+li}function _e(Se){for(var ve=[],Pe=0,vt=Se.length;Pe=55296&&St<=56319&&Pe>1,ve+=he(ve/Pe);ve>oe*M>>1;St+=N)ve=he(ve/oe);return he(St+(oe+1)*ve/(ve+z))},Ne=function(ve){var Pe=[],vt=ve.length,St=0,li=J,ci=P,qi=ve.lastIndexOf(j);qi<0&&(qi=0);for(var mn=0;mn=128&&Ie("not-basic"),Pe.push(ve.charCodeAt(mn));for(var Un=qi>0?qi+1:0;Un=vt&&Ie("invalid-input");var en=nt(ve.charCodeAt(Un++));(en>=N||en>he((H-St)/Kn))&&Ie("overflow"),St+=en*Kn;var Ln=hr<=ci?D:hr>=ci+M?M:hr-ci;if(enhe(H/fr)&&Ie("overflow"),Kn*=fr}var wr=Pe.length+1;ci=Tt(St-an,wr,an==0),he(St/wr)>H-li&&Ie("overflow"),li+=he(St/wr),St%=wr,Pe.splice(St++,0,li)}return String.fromCodePoint.apply(String,Pe)},Ge=function(ve){var Pe=[];ve=_e(ve);var vt=ve.length,St=J,li=0,ci=P,qi=!0,mn=!1,Un=void 0;try{for(var an=ve[Symbol.iterator](),Kn;!(qi=(Kn=an.next()).done);qi=!0){var hr=Kn.value;hr<128&&Pe.push(ye(hr))}}catch(wm){mn=!0,Un=wm}finally{try{!qi&&an.return&&an.return()}finally{if(mn)throw Un}}var en=Pe.length,Ln=en;for(en&&Pe.push(j);Ln=St&&Vnhe((H-li)/bn)&&Ie("overflow"),li+=(fr-St)*bn,St=fr;var rn=!0,Qn=!1,wn=void 0;try{for(var Nn=ve[Symbol.iterator](),or;!(rn=(or=Nn.next()).done);rn=!0){var Tr=or.value;if(TrH&&Ie("overflow"),Tr==St){for(var Rr=li,wa=N;;wa+=N){var mC=wa<=ci?D:wa>=ci+M?M:wa-ci;if(Rr>6|192).toString(16).toUpperCase()+"%"+(ve&63|128).toString(16).toUpperCase():Pe="%"+(ve>>12|224).toString(16).toUpperCase()+"%"+(ve>>6&63|128).toString(16).toUpperCase()+"%"+(ve&63|128).toString(16).toUpperCase(),Pe}function Vt(Se){for(var ve="",Pe=0,vt=Se.length;Pe=194&&St<224){if(vt-Pe>=6){var li=parseInt(Se.substr(Pe+4,2),16);ve+=String.fromCharCode((St&31)<<6|li&63)}else ve+=Se.substr(Pe,6);Pe+=6}else if(St>=224){if(vt-Pe>=9){var ci=parseInt(Se.substr(Pe+4,2),16),qi=parseInt(Se.substr(Pe+7,2),16);ve+=String.fromCharCode((St&15)<<12|(ci&63)<<6|qi&63)}else ve+=Se.substr(Pe,9);Pe+=9}else ve+=Se.substr(Pe,3),Pe+=3}return ve}function _t(Se,ve){function Pe(vt){var St=Vt(vt);return St.match(ve.UNRESERVED)?St:vt}return Se.scheme&&(Se.scheme=String(Se.scheme).replace(ve.PCT_ENCODED,Pe).toLowerCase().replace(ve.NOT_SCHEME,"")),Se.userinfo!==void 0&&(Se.userinfo=String(Se.userinfo).replace(ve.PCT_ENCODED,Pe).replace(ve.NOT_USERINFO,xt).replace(ve.PCT_ENCODED,d)),Se.host!==void 0&&(Se.host=String(Se.host).replace(ve.PCT_ENCODED,Pe).toLowerCase().replace(ve.NOT_HOST,xt).replace(ve.PCT_ENCODED,d)),Se.path!==void 0&&(Se.path=String(Se.path).replace(ve.PCT_ENCODED,Pe).replace(Se.scheme?ve.NOT_PATH:ve.NOT_PATH_NOSCHEME,xt).replace(ve.PCT_ENCODED,d)),Se.query!==void 0&&(Se.query=String(Se.query).replace(ve.PCT_ENCODED,Pe).replace(ve.NOT_QUERY,xt).replace(ve.PCT_ENCODED,d)),Se.fragment!==void 0&&(Se.fragment=String(Se.fragment).replace(ve.PCT_ENCODED,Pe).replace(ve.NOT_FRAGMENT,xt).replace(ve.PCT_ENCODED,d)),Se}function Ci(Se){return Se.replace(/^0*(.*)/,"$1")||"0"}function Dt(Se,ve){var Pe=Se.match(ve.IPV4ADDRESS)||[],vt=S(Pe,2),St=vt[1];return St?St.split(".").map(Ci).join("."):Se}function Zi(Se,ve){var Pe=Se.match(ve.IPV6ADDRESS)||[],vt=S(Pe,3),St=vt[1],li=vt[2];if(St){for(var ci=St.toLowerCase().split("::").reverse(),qi=S(ci,2),mn=qi[0],Un=qi[1],an=Un?Un.split(":").map(Ci):[],Kn=mn.split(":").map(Ci),hr=ve.IPV4ADDRESS.test(Kn[Kn.length-1]),en=hr?7:8,Ln=Kn.length-en,fr=Array(en),wr=0;wr1){var Hi=fr.slice(0,as.index),Vn=fr.slice(as.index+as.length);ii=Hi.join(":")+"::"+Vn.join(":")}else ii=fr.join(":");return li&&(ii+="%"+li),ii}else return Se}var ui=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,In="".match(/(){0}/)[1]===void 0;function Li(Se){var ve=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Pe={},vt=ve.iri!==!1?w:b;ve.reference==="suffix"&&(Se=(ve.scheme?ve.scheme+":":"")+"//"+Se);var St=Se.match(ui);if(St){In?(Pe.scheme=St[1],Pe.userinfo=St[3],Pe.host=St[4],Pe.port=parseInt(St[5],10),Pe.path=St[6]||"",Pe.query=St[7],Pe.fragment=St[8],isNaN(Pe.port)&&(Pe.port=St[5])):(Pe.scheme=St[1]||void 0,Pe.userinfo=Se.indexOf("@")!==-1?St[3]:void 0,Pe.host=Se.indexOf("//")!==-1?St[4]:void 0,Pe.port=parseInt(St[5],10),Pe.path=St[6]||"",Pe.query=Se.indexOf("?")!==-1?St[7]:void 0,Pe.fragment=Se.indexOf("#")!==-1?St[8]:void 0,isNaN(Pe.port)&&(Pe.port=Se.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?St[4]:void 0)),Pe.host&&(Pe.host=Zi(Dt(Pe.host,vt),vt)),Pe.scheme===void 0&&Pe.userinfo===void 0&&Pe.host===void 0&&Pe.port===void 0&&!Pe.path&&Pe.query===void 0?Pe.reference="same-document":Pe.scheme===void 0?Pe.reference="relative":Pe.fragment===void 0?Pe.reference="absolute":Pe.reference="uri",ve.reference&&ve.reference!=="suffix"&&ve.reference!==Pe.reference&&(Pe.error=Pe.error||"URI is not a "+ve.reference+" reference.");var li=bt[(ve.scheme||Pe.scheme||"").toLowerCase()];if(!ve.unicodeSupport&&(!li||!li.unicodeSupport)){if(Pe.host&&(ve.domainHost||li&&li.domainHost))try{Pe.host=at.toASCII(Pe.host.replace(vt.PCT_ENCODED,Vt).toLowerCase())}catch(ci){Pe.error=Pe.error||"Host's domain name can not be converted to ASCII via punycode: "+ci}_t(Pe,b)}else _t(Pe,vt);li&&li.parse&&li.parse(Pe,ve)}else Pe.error=Pe.error||"URI can not be parsed.";return Pe}function Bi(Se,ve){var Pe=ve.iri!==!1?w:b,vt=[];return Se.userinfo!==void 0&&(vt.push(Se.userinfo),vt.push("@")),Se.host!==void 0&&vt.push(Zi(Dt(String(Se.host),Pe),Pe).replace(Pe.IPV6ADDRESS,function(St,li,ci){return"["+li+(ci?"%25"+ci:"")+"]"})),(typeof Se.port=="number"||typeof Se.port=="string")&&(vt.push(":"),vt.push(String(Se.port))),vt.length?vt.join(""):void 0}var pn=/^\.\.?\//,un=/^\/\.(\/|$)/,On=/^\/\.\.(\/|$)/,Wg=/^\/?(?:.|\n)*?(?=\/|$)/;function ln(Se){for(var ve=[];Se.length;)if(Se.match(pn))Se=Se.replace(pn,"");else if(Se.match(un))Se=Se.replace(un,"/");else if(Se.match(On))Se=Se.replace(On,"/"),ve.pop();else if(Se==="."||Se==="..")Se="";else{var Pe=Se.match(Wg);if(Pe){var vt=Pe[0];Se=Se.slice(vt.length),ve.push(vt)}else throw new Error("Unexpected dot segment condition")}return ve.join("")}function Ht(Se){var ve=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Pe=ve.iri?w:b,vt=[],St=bt[(ve.scheme||Se.scheme||"").toLowerCase()];if(St&&St.serialize&&St.serialize(Se,ve),Se.host&&!Pe.IPV6ADDRESS.test(Se.host)){if(ve.domainHost||St&&St.domainHost)try{Se.host=ve.iri?at.toUnicode(Se.host):at.toASCII(Se.host.replace(Pe.PCT_ENCODED,Vt).toLowerCase())}catch(qi){Se.error=Se.error||"Host's domain name can not be converted to "+(ve.iri?"Unicode":"ASCII")+" via punycode: "+qi}}_t(Se,Pe),ve.reference!=="suffix"&&Se.scheme&&(vt.push(Se.scheme),vt.push(":"));var li=Bi(Se,ve);if(li!==void 0&&(ve.reference!=="suffix"&&vt.push("//"),vt.push(li),Se.path&&Se.path.charAt(0)!=="/"&&vt.push("/")),Se.path!==void 0){var ci=Se.path;!ve.absolutePath&&(!St||!St.absolutePath)&&(ci=ln(ci)),li===void 0&&(ci=ci.replace(/^\/\//,"/%2F")),vt.push(ci)}return Se.query!==void 0&&(vt.push("?"),vt.push(Se.query)),Se.fragment!==void 0&&(vt.push("#"),vt.push(Se.fragment)),vt.join("")}function Ye(Se,ve){var Pe=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},vt=arguments[3],St={};return vt||(Se=Li(Ht(Se,Pe),Pe),ve=Li(Ht(ve,Pe),Pe)),Pe=Pe||{},!Pe.tolerant&&ve.scheme?(St.scheme=ve.scheme,St.userinfo=ve.userinfo,St.host=ve.host,St.port=ve.port,St.path=ln(ve.path||""),St.query=ve.query):(ve.userinfo!==void 0||ve.host!==void 0||ve.port!==void 0?(St.userinfo=ve.userinfo,St.host=ve.host,St.port=ve.port,St.path=ln(ve.path||""),St.query=ve.query):(ve.path?(ve.path.charAt(0)==="/"?St.path=ln(ve.path):((Se.userinfo!==void 0||Se.host!==void 0||Se.port!==void 0)&&!Se.path?St.path="/"+ve.path:Se.path?St.path=Se.path.slice(0,Se.path.lastIndexOf("/")+1)+ve.path:St.path=ve.path,St.path=ln(St.path)),St.query=ve.query):(St.path=Se.path,ve.query!==void 0?St.query=ve.query:St.query=Se.query),St.userinfo=Se.userinfo,St.host=Se.host,St.port=Se.port),St.scheme=Se.scheme),St.fragment=ve.fragment,St}function Qe(Se,ve,Pe){var vt=y({scheme:"null"},Pe);return Ht(Ye(Li(Se,vt),Li(ve,vt),vt,!0),vt)}function pt(Se,ve){return typeof Se=="string"?Se=Ht(Li(Se,ve),ve):A(Se)==="object"&&(Se=Li(Ht(Se,ve),ve)),Se}function re(Se,ve,Pe){return typeof Se=="string"?Se=Ht(Li(Se,Pe),Pe):A(Se)==="object"&&(Se=Ht(Se,Pe)),typeof ve=="string"?ve=Ht(Li(ve,Pe),Pe):A(ve)==="object"&&(ve=Ht(ve,Pe)),Se===ve}function U(Se,ve){return Se&&Se.toString().replace(!ve||!ve.iri?b.ESCAPE:w.ESCAPE,xt)}function q(Se,ve){return Se&&Se.toString().replace(!ve||!ve.iri?b.PCT_ENCODED:w.PCT_ENCODED,Vt)}var pe={scheme:"http",domainHost:!0,parse:function(ve,Pe){return ve.host||(ve.error=ve.error||"HTTP URIs must have a host."),ve},serialize:function(ve,Pe){var vt=String(ve.scheme).toLowerCase()==="https";return(ve.port===(vt?443:80)||ve.port==="")&&(ve.port=void 0),ve.path||(ve.path="/"),ve}},Fe={scheme:"https",domainHost:pe.domainHost,parse:pe.parse,serialize:pe.serialize};function $e(Se){return typeof Se.secure=="boolean"?Se.secure:String(Se.scheme).toLowerCase()==="wss"}var ft={scheme:"ws",domainHost:!0,parse:function(ve,Pe){var vt=ve;return vt.secure=$e(vt),vt.resourceName=(vt.path||"/")+(vt.query?"?"+vt.query:""),vt.path=void 0,vt.query=void 0,vt},serialize:function(ve,Pe){if((ve.port===($e(ve)?443:80)||ve.port==="")&&(ve.port=void 0),typeof ve.secure=="boolean"&&(ve.scheme=ve.secure?"wss":"ws",ve.secure=void 0),ve.resourceName){var vt=ve.resourceName.split("?"),St=S(vt,2),li=St[0],ci=St[1];ve.path=li&&li!=="/"?li:void 0,ve.query=ci,ve.resourceName=void 0}return ve.fragment=void 0,ve}},ri={scheme:"wss",domainHost:ft.domainHost,parse:ft.parse,serialize:ft.serialize},bi={},Ni="[A-Za-z0-9\\-\\.\\_\\~\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]",Ti="[0-9A-Fa-f]",Ki=I(I("%[EFef]"+Ti+"%"+Ti+Ti+"%"+Ti+Ti)+"|"+I("%[89A-Fa-f]"+Ti+"%"+Ti+Ti)+"|"+I("%"+Ti+Ti)),Ng="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",Sa="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",Hl=C(Sa,'[\\"\\\\]'),gs="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",os=new RegExp(Ni,"g"),Rt=new RegExp(Ki,"g"),ut=new RegExp(C("[^]",Ng,"[\\.]",'[\\"]',Hl),"g"),Re=new RegExp(C("[^]",Ni,gs),"g"),Ve=Re;function ot(Se){var ve=Vt(Se);return ve.match(os)?ve:Se}var Bt={scheme:"mailto",parse:function(ve,Pe){var vt=ve,St=vt.to=vt.path?vt.path.split(","):[];if(vt.path=void 0,vt.query){for(var li=!1,ci={},qi=vt.query.split("&"),mn=0,Un=qi.length;mn=55296&&A<=56319&&I=a)throw new Error("Cannot access property/index "+C+" levels up, current level is "+a);return s[a-C]}if(C>a)throw new Error("Cannot access data "+C+" levels up, current level is "+a);if(A="data"+(a-C||""),!I)return A}for(var h=A,y=I.split("/"),Z=0;Z=0?{index:C,compiling:!0}:(C=this._compilations.length,this._compilations[C]={schema:g,root:a,baseId:s},{index:C,compiling:!1})}function KTt(g,a,s){var C=XSe.call(this,g,a,s);C>=0&&this._compilations.splice(C,1)}function XSe(g,a,s){for(var C=0;C%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,FSe=/^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i,YSe=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,KSe=/^(?:\/(?:[^~/]|~0|~1)*)*$/,_Se=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,PSe=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,qTt=ED;function ED(g){return g=g=="full"?"full":"fast",LTt.copy(ED[g])}ED.fast={date:/^\d\d\d\d-[0-1]\d-[0-3]\d$/,time:/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,"date-time":/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,"uri-template":MSe,url:FSe,email:/^[a-z0-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})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:LSe,uuid:YSe,"json-pointer":KSe,"json-pointer-uri-fragment":_Se,"relative-json-pointer":PSe},ED.full={date:zSe,time:OSe,"date-time":iRt,uri:rRt,"uri-reference":$Tt,"uri-template":MSe,url:FSe,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:DSe,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:LSe,uuid:YSe,"json-pointer":KSe,"json-pointer-uri-fragment":_Se,"relative-json-pointer":PSe};function eRt(g){return g%4===0&&(g%100!==0||g%400===0)}function zSe(g){var a=g.match(JTt);if(!a)return!1;var s=+a[1],C=+a[2],I=+a[3];return C>=1&&C<=12&&I>=1&&I<=(C==2&&eRt(s)?29:UTt[C])}function OSe(g,a){var s=g.match(QTt);if(!s)return!1;var C=s[1],I=s[2],A=s[3],d=s[5];return(C<=23&&I<=59&&A<=59||C==23&&I==59&&A==60)&&(!a||d)}var tRt=/t|\s/i;function iRt(g){var a=g.split(tRt);return a.length==2&&zSe(a[0])&&OSe(a[1],!0)}var nRt=/\/|:/;function rRt(g){return nRt.test(g)&&jTt.test(g)}var gRt=/[^\\]\\Z/;function LSe(g){if(gRt.test(g))return!1;try{return new RegExp(g),!0}catch{return!1}}var oRt=function(a,s,C){var I=" ",A=a.level,d=a.dataLevel,h=a.schema[s],y=a.errSchemaPath+"/"+s,Z=!a.opts.allErrors,b="data"+(d||""),w="valid"+A,S,R;if(h=="#"||h=="#/")a.isRoot?(S=a.async,R="validate"):(S=a.root.schema.$async===!0,R="root.refVal[0]");else{var H=a.resolveRef(a.baseId,h,a.isRoot);if(H===void 0){var N=a.MissingRefError.message(a.baseId,h);if(a.opts.missingRefs=="fail"){a.logger.error(N);var D=D||[];D.push(I),I="",a.createErrors!==!1?(I+=" { keyword: '$ref' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(y)+" , params: { ref: '"+a.util.escapeQuotes(h)+"' } ",a.opts.messages!==!1&&(I+=" , message: 'can\\'t resolve reference "+a.util.escapeQuotes(h)+"' "),a.opts.verbose&&(I+=" , schema: "+a.util.toQuotedString(h)+" , parentSchema: validate.schema"+a.schemaPath+" , data: "+b+" "),I+=" } "):I+=" {} ";var M=I;I=D.pop(),!a.compositeRule&&Z?a.async?I+=" throw new ValidationError(["+M+"]); ":I+=" validate.errors = ["+M+"]; return false; ":I+=" var err = "+M+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",Z&&(I+=" if (false) { ")}else if(a.opts.missingRefs=="ignore")a.logger.warn(N),Z&&(I+=" if (true) { ");else throw new a.MissingRefError(a.baseId,h,N)}else if(H.inline){var z=a.util.copy(a);z.level++;var K="valid"+z.level;z.schema=H.schema,z.schemaPath="",z.errSchemaPath=h;var P=a.validate(z).replace(/validate\.schema/g,H.code);I+=" "+P+" ",Z&&(I+=" if ("+K+") { ")}else S=H.$async===!0||a.async&&H.$async!==!1,R=H.code}if(R){var D=D||[];D.push(I),I="",a.opts.passContext?I+=" "+R+".call(this, ":I+=" "+R+"( ",I+=" "+b+", (dataPath || '')",a.errorPath!='""'&&(I+=" + "+a.errorPath);var J=d?"data"+(d-1||""):"parentData",j=d?a.dataPathArr[d]:"parentDataProperty";I+=" , "+J+" , "+j+", rootData) ";var ie=I;if(I=D.pop(),S){if(!a.async)throw new Error("async schema referenced by sync schema");Z&&(I+=" var "+w+"; "),I+=" try { await "+ie+"; ",Z&&(I+=" "+w+" = true; "),I+=" } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ",Z&&(I+=" "+w+" = false; "),I+=" } ",Z&&(I+=" if ("+w+") { ")}else I+=" if (!"+ie+") { if (vErrors === null) vErrors = "+R+".errors; else vErrors = vErrors.concat("+R+".errors); errors = vErrors.length; } ",Z&&(I+=" else { ")}return I},aRt=function(a,s,C){var I=" ",A=a.schema[s],d=a.schemaPath+a.util.getProperty(s),h=a.errSchemaPath+"/"+s,y=!a.opts.allErrors,Z=a.util.copy(a),b="";Z.level++;var w="valid"+Z.level,S=Z.baseId,R=!0,H=A;if(H)for(var N,D=-1,M=H.length-1;D0||N===!1:a.util.schemaHasRules(N,a.RULES.all))&&(R=!1,Z.schema=N,Z.schemaPath=d+"["+D+"]",Z.errSchemaPath=h+"/"+D,I+=" "+a.validate(Z)+" ",Z.baseId=S,y&&(I+=" if ("+w+") { ",b+="}"));return y&&(R?I+=" if (true) { ":I+=" "+b.slice(0,-1)+" "),I},sRt=function(a,s,C){var I=" ",A=a.level,d=a.dataLevel,h=a.schema[s],y=a.schemaPath+a.util.getProperty(s),Z=a.errSchemaPath+"/"+s,b=!a.opts.allErrors,w="data"+(d||""),S="valid"+A,R="errs__"+A,H=a.util.copy(a),N="";H.level++;var D="valid"+H.level,M=h.every(function(te){return a.opts.strictKeywords?typeof te=="object"&&Object.keys(te).length>0||te===!1:a.util.schemaHasRules(te,a.RULES.all)});if(M){var z=H.baseId;I+=" var "+R+" = errors; var "+S+" = false; ";var K=a.compositeRule;a.compositeRule=H.compositeRule=!0;var P=h;if(P)for(var J,j=-1,ie=P.length-1;j0||h===!1:a.util.schemaHasRules(h,a.RULES.all);if(I+="var "+R+" = errors;var "+S+";",J){var j=a.compositeRule;a.compositeRule=H.compositeRule=!0,H.schema=h,H.schemaPath=y,H.errSchemaPath=Z,I+=" var "+D+" = false; for (var "+M+" = 0; "+M+" < "+w+".length; "+M+"++) { ",H.errorPath=a.util.getPathExpr(a.errorPath,M,a.opts.jsonPointers,!0);var ie=w+"["+M+"]";H.dataPathArr[z]=M;var te=a.validate(H);H.baseId=P,a.util.varOccurences(te,K)<2?I+=" "+a.util.varReplace(te,K,ie)+" ":I+=" var "+K+" = "+ie+"; "+te+" ",I+=" if ("+D+") break; } ",a.compositeRule=H.compositeRule=j,I+=" "+N+" if (!"+D+") {"}else I+=" if ("+w+".length == 0) {";var Ce=Ce||[];Ce.push(I),I="",a.createErrors!==!1?(I+=" { keyword: 'contains' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(Z)+" , params: {} ",a.opts.messages!==!1&&(I+=" , message: 'should contain a valid item' "),a.opts.verbose&&(I+=" , schema: validate.schema"+y+" , parentSchema: validate.schema"+a.schemaPath+" , data: "+w+" "),I+=" } "):I+=" {} ";var ue=I;return I=Ce.pop(),!a.compositeRule&&b?a.async?I+=" throw new ValidationError(["+ue+"]); ":I+=" validate.errors = ["+ue+"]; return false; ":I+=" var err = "+ue+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } else { ",J&&(I+=" errors = "+R+"; if (vErrors !== null) { if ("+R+") vErrors.length = "+R+"; else vErrors = null; } "),a.opts.allErrors&&(I+=" } "),I},cRt=function(a,s,C){var I=" ",A=a.level,d=a.dataLevel,h=a.schema[s],y=a.schemaPath+a.util.getProperty(s),Z=a.errSchemaPath+"/"+s,b=!a.opts.allErrors,w="data"+(d||""),S="errs__"+A,R=a.util.copy(a),H="";R.level++;var N="valid"+R.level,D={},M={},z=a.opts.ownProperties;for(j in h)if(j!="__proto__"){var K=h[j],P=Array.isArray(K)?M:D;P[j]=K}I+="var "+S+" = errors;";var J=a.errorPath;I+="var missing"+A+";";for(var j in M)if(P=M[j],P.length){if(I+=" if ( "+w+a.util.getProperty(j)+" !== undefined ",z&&(I+=" && Object.prototype.hasOwnProperty.call("+w+", '"+a.util.escapeQuotes(j)+"') "),b){I+=" && ( ";var ie=P;if(ie)for(var te,Ce=-1,ue=ie.length-1;Ce0||K===!1:a.util.schemaHasRules(K,a.RULES.all))&&(I+=" "+N+" = true; if ( "+w+a.util.getProperty(j)+" !== undefined ",z&&(I+=" && Object.prototype.hasOwnProperty.call("+w+", '"+a.util.escapeQuotes(j)+"') "),I+=") { ",R.schema=K,R.schemaPath=y+a.util.getProperty(j),R.errSchemaPath=Z+"/"+a.util.escapeFragment(j),I+=" "+a.validate(R)+" ",R.baseId=At,I+=" } ",b&&(I+=" if ("+N+") { ",H+="}"))}return b&&(I+=" "+H+" if ("+S+" == errors) {"),I},ARt=function(a,s,C){var I=" ",A=a.level,d=a.dataLevel,h=a.schema[s],y=a.schemaPath+a.util.getProperty(s),Z=a.errSchemaPath+"/"+s,b=!a.opts.allErrors,w="data"+(d||""),S="valid"+A,R=a.opts.$data&&h&&h.$data;R&&(I+=" var schema"+A+" = "+a.util.getData(h.$data,d,a.dataPathArr)+"; ");var H="i"+A,N="schema"+A;R||(I+=" var "+N+" = validate.schema"+y+";"),I+="var "+S+";",R&&(I+=" if (schema"+A+" === undefined) "+S+" = true; else if (!Array.isArray(schema"+A+")) "+S+" = false; else {"),I+=""+S+" = false;for (var "+H+"=0; "+H+"<"+N+".length; "+H+"++) if (equal("+w+", "+N+"["+H+"])) { "+S+" = true; break; }",R&&(I+=" } "),I+=" if (!"+S+") { ";var D=D||[];D.push(I),I="",a.createErrors!==!1?(I+=" { keyword: 'enum' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(Z)+" , params: { allowedValues: schema"+A+" } ",a.opts.messages!==!1&&(I+=" , message: 'should be equal to one of the allowed values' "),a.opts.verbose&&(I+=" , schema: validate.schema"+y+" , parentSchema: validate.schema"+a.schemaPath+" , data: "+w+" "),I+=" } "):I+=" {} ";var M=I;return I=D.pop(),!a.compositeRule&&b?a.async?I+=" throw new ValidationError(["+M+"]); ":I+=" validate.errors = ["+M+"]; return false; ":I+=" var err = "+M+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" }",b&&(I+=" else { "),I},uRt=function(a,s,C){var I=" ",A=a.level,d=a.dataLevel,h=a.schema[s],y=a.schemaPath+a.util.getProperty(s),Z=a.errSchemaPath+"/"+s,b=!a.opts.allErrors,w="data"+(d||"");if(a.opts.format===!1)return b&&(I+=" if (true) { "),I;var S=a.opts.$data&&h&&h.$data,R;S?(I+=" var schema"+A+" = "+a.util.getData(h.$data,d,a.dataPathArr)+"; ",R="schema"+A):R=h;var H=a.opts.unknownFormats,N=Array.isArray(H);if(S){var D="format"+A,M="isObject"+A,z="formatType"+A;I+=" var "+D+" = formats["+R+"]; var "+M+" = typeof "+D+" == 'object' && !("+D+" instanceof RegExp) && "+D+".validate; var "+z+" = "+M+" && "+D+".type || 'string'; if ("+M+") { ",a.async&&(I+=" var async"+A+" = "+D+".async; "),I+=" "+D+" = "+D+".validate; } if ( ",S&&(I+=" ("+R+" !== undefined && typeof "+R+" != 'string') || "),I+=" (",H!="ignore"&&(I+=" ("+R+" && !"+D+" ",N&&(I+=" && self._opts.unknownFormats.indexOf("+R+") == -1 "),I+=") || "),I+=" ("+D+" && "+z+" == '"+C+"' && !(typeof "+D+" == 'function' ? ",a.async?I+=" (async"+A+" ? await "+D+"("+w+") : "+D+"("+w+")) ":I+=" "+D+"("+w+") ",I+=" : "+D+".test("+w+"))))) {"}else{var D=a.formats[h];if(!D){if(H=="ignore")return a.logger.warn('unknown format "'+h+'" ignored in schema at path "'+a.errSchemaPath+'"'),b&&(I+=" if (true) { "),I;if(N&&H.indexOf(h)>=0)return b&&(I+=" if (true) { "),I;throw new Error('unknown format "'+h+'" is used in schema at path "'+a.errSchemaPath+'"')}var M=typeof D=="object"&&!(D instanceof RegExp)&&D.validate,z=M&&D.type||"string";if(M){var K=D.async===!0;D=D.validate}if(z!=C)return b&&(I+=" if (true) { "),I;if(K){if(!a.async)throw new Error("async format in sync schema");var P="formats"+a.util.getProperty(h)+".validate";I+=" if (!(await "+P+"("+w+"))) { "}else{I+=" if (! ";var P="formats"+a.util.getProperty(h);M&&(P+=".validate"),typeof D=="function"?I+=" "+P+"("+w+") ":I+=" "+P+".test("+w+") ",I+=") { "}}var J=J||[];J.push(I),I="",a.createErrors!==!1?(I+=" { keyword: 'format' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(Z)+" , params: { format: ",S?I+=""+R:I+=""+a.util.toQuotedString(h),I+=" } ",a.opts.messages!==!1&&(I+=` , message: 'should match format "`,S?I+="' + "+R+" + '":I+=""+a.util.escapeQuotes(h),I+=`"' `),a.opts.verbose&&(I+=" , schema: ",S?I+="validate.schema"+y:I+=""+a.util.toQuotedString(h),I+=" , parentSchema: validate.schema"+a.schemaPath+" , data: "+w+" "),I+=" } "):I+=" {} ";var j=I;return I=J.pop(),!a.compositeRule&&b?a.async?I+=" throw new ValidationError(["+j+"]); ":I+=" validate.errors = ["+j+"]; return false; ":I+=" var err = "+j+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } ",b&&(I+=" else { "),I},dRt=function(a,s,C){var I=" ",A=a.level,d=a.dataLevel,h=a.schema[s],y=a.schemaPath+a.util.getProperty(s),Z=a.errSchemaPath+"/"+s,b=!a.opts.allErrors,w="data"+(d||""),S="valid"+A,R="errs__"+A,H=a.util.copy(a);H.level++;var N="valid"+H.level,D=a.schema.then,M=a.schema.else,z=D!==void 0&&(a.opts.strictKeywords?typeof D=="object"&&Object.keys(D).length>0||D===!1:a.util.schemaHasRules(D,a.RULES.all)),K=M!==void 0&&(a.opts.strictKeywords?typeof M=="object"&&Object.keys(M).length>0||M===!1:a.util.schemaHasRules(M,a.RULES.all)),P=H.baseId;if(z||K){var J;H.createErrors=!1,H.schema=h,H.schemaPath=y,H.errSchemaPath=Z,I+=" var "+R+" = errors; var "+S+" = true; ";var j=a.compositeRule;a.compositeRule=H.compositeRule=!0,I+=" "+a.validate(H)+" ",H.baseId=P,H.createErrors=!0,I+=" errors = "+R+"; if (vErrors !== null) { if ("+R+") vErrors.length = "+R+"; else vErrors = null; } ",a.compositeRule=H.compositeRule=j,z?(I+=" if ("+N+") { ",H.schema=a.schema.then,H.schemaPath=a.schemaPath+".then",H.errSchemaPath=a.errSchemaPath+"/then",I+=" "+a.validate(H)+" ",H.baseId=P,I+=" "+S+" = "+N+"; ",z&&K?(J="ifClause"+A,I+=" var "+J+" = 'then'; "):J="'then'",I+=" } ",K&&(I+=" else { ")):I+=" if (!"+N+") { ",K&&(H.schema=a.schema.else,H.schemaPath=a.schemaPath+".else",H.errSchemaPath=a.errSchemaPath+"/else",I+=" "+a.validate(H)+" ",H.baseId=P,I+=" "+S+" = "+N+"; ",z&&K?(J="ifClause"+A,I+=" var "+J+" = 'else'; "):J="'else'",I+=" } "),I+=" if (!"+S+") { var err = ",a.createErrors!==!1?(I+=" { keyword: 'if' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(Z)+" , params: { failingKeyword: "+J+" } ",a.opts.messages!==!1&&(I+=` , message: 'should match "' + `+J+` + '" schema' `),a.opts.verbose&&(I+=" , schema: validate.schema"+y+" , parentSchema: validate.schema"+a.schemaPath+" , data: "+w+" "),I+=" } "):I+=" {} ",I+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!a.compositeRule&&b&&(a.async?I+=" throw new ValidationError(vErrors); ":I+=" validate.errors = vErrors; return false; "),I+=" } ",b&&(I+=" else { ")}else b&&(I+=" if (true) { ");return I},hRt=function(a,s,C){var I=" ",A=a.level,d=a.dataLevel,h=a.schema[s],y=a.schemaPath+a.util.getProperty(s),Z=a.errSchemaPath+"/"+s,b=!a.opts.allErrors,w="data"+(d||""),S="valid"+A,R="errs__"+A,H=a.util.copy(a),N="";H.level++;var D="valid"+H.level,M="i"+A,z=H.dataLevel=a.dataLevel+1,K="data"+z,P=a.baseId;if(I+="var "+R+" = errors;var "+S+";",Array.isArray(h)){var J=a.schema.additionalItems;if(J===!1){I+=" "+S+" = "+w+".length <= "+h.length+"; ";var j=Z;Z=a.errSchemaPath+"/additionalItems",I+=" if (!"+S+") { ";var ie=ie||[];ie.push(I),I="",a.createErrors!==!1?(I+=" { keyword: 'additionalItems' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(Z)+" , params: { limit: "+h.length+" } ",a.opts.messages!==!1&&(I+=" , message: 'should NOT have more than "+h.length+" items' "),a.opts.verbose&&(I+=" , schema: false , parentSchema: validate.schema"+a.schemaPath+" , data: "+w+" "),I+=" } "):I+=" {} ";var te=I;I=ie.pop(),!a.compositeRule&&b?a.async?I+=" throw new ValidationError(["+te+"]); ":I+=" validate.errors = ["+te+"]; return false; ":I+=" var err = "+te+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } ",Z=j,b&&(N+="}",I+=" else { ")}var Ce=h;if(Ce){for(var ue,oe=-1,he=Ce.length-1;oe0||ue===!1:a.util.schemaHasRules(ue,a.RULES.all)){I+=" "+D+" = true; if ("+w+".length > "+oe+") { ";var ye=w+"["+oe+"]";H.schema=ue,H.schemaPath=y+"["+oe+"]",H.errSchemaPath=Z+"/"+oe,H.errorPath=a.util.getPathExpr(a.errorPath,oe,a.opts.jsonPointers,!0),H.dataPathArr[z]=oe;var Ie=a.validate(H);H.baseId=P,a.util.varOccurences(Ie,K)<2?I+=" "+a.util.varReplace(Ie,K,ye)+" ":I+=" var "+K+" = "+ye+"; "+Ie+" ",I+=" } ",b&&(I+=" if ("+D+") { ",N+="}")}}if(typeof J=="object"&&(a.opts.strictKeywords?typeof J=="object"&&Object.keys(J).length>0||J===!1:a.util.schemaHasRules(J,a.RULES.all))){H.schema=J,H.schemaPath=a.schemaPath+".additionalItems",H.errSchemaPath=a.errSchemaPath+"/additionalItems",I+=" "+D+" = true; if ("+w+".length > "+h.length+") { for (var "+M+" = "+h.length+"; "+M+" < "+w+".length; "+M+"++) { ",H.errorPath=a.util.getPathExpr(a.errorPath,M,a.opts.jsonPointers,!0);var ye=w+"["+M+"]";H.dataPathArr[z]=M;var Ie=a.validate(H);H.baseId=P,a.util.varOccurences(Ie,K)<2?I+=" "+a.util.varReplace(Ie,K,ye)+" ":I+=" var "+K+" = "+ye+"; "+Ie+" ",b&&(I+=" if (!"+D+") break; "),I+=" } } ",b&&(I+=" if ("+D+") { ",N+="}")}}else if(a.opts.strictKeywords?typeof h=="object"&&Object.keys(h).length>0||h===!1:a.util.schemaHasRules(h,a.RULES.all)){H.schema=h,H.schemaPath=y,H.errSchemaPath=Z,I+=" for (var "+M+" = 0; "+M+" < "+w+".length; "+M+"++) { ",H.errorPath=a.util.getPathExpr(a.errorPath,M,a.opts.jsonPointers,!0);var ye=w+"["+M+"]";H.dataPathArr[z]=M;var Ie=a.validate(H);H.baseId=P,a.util.varOccurences(Ie,K)<2?I+=" "+a.util.varReplace(Ie,K,ye)+" ":I+=" var "+K+" = "+ye+"; "+Ie+" ",b&&(I+=" if (!"+D+") break; "),I+=" }"}return b&&(I+=" "+N+" if ("+R+" == errors) {"),I},JSe=function(a,s,C){var I=" ",A=a.level,d=a.dataLevel,h=a.schema[s],y=a.schemaPath+a.util.getProperty(s),Z=a.errSchemaPath+"/"+s,b=!a.opts.allErrors,P,w="data"+(d||""),S=a.opts.$data&&h&&h.$data,R;S?(I+=" var schema"+A+" = "+a.util.getData(h.$data,d,a.dataPathArr)+"; ",R="schema"+A):R=h;var H=s=="maximum",N=H?"exclusiveMaximum":"exclusiveMinimum",D=a.schema[N],M=a.opts.$data&&D&&D.$data,z=H?"<":">",K=H?">":"<",P=void 0;if(!(S||typeof h=="number"||h===void 0))throw new Error(s+" must be number");if(!(M||D===void 0||typeof D=="number"||typeof D=="boolean"))throw new Error(N+" must be number or boolean");if(M){var J=a.util.getData(D.$data,d,a.dataPathArr),j="exclusive"+A,ie="exclType"+A,te="exclIsNumber"+A,Ce="op"+A,ue="' + "+Ce+" + '";I+=" var schemaExcl"+A+" = "+J+"; ",J="schemaExcl"+A,I+=" var "+j+"; var "+ie+" = typeof "+J+"; if ("+ie+" != 'boolean' && "+ie+" != 'undefined' && "+ie+" != 'number') { ";var P=N,oe=oe||[];oe.push(I),I="",a.createErrors!==!1?(I+=" { keyword: '"+(P||"_exclusiveLimit")+"' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(Z)+" , params: {} ",a.opts.messages!==!1&&(I+=" , message: '"+N+" should be boolean' "),a.opts.verbose&&(I+=" , schema: validate.schema"+y+" , parentSchema: validate.schema"+a.schemaPath+" , data: "+w+" "),I+=" } "):I+=" {} ";var he=I;I=oe.pop(),!a.compositeRule&&b?a.async?I+=" throw new ValidationError(["+he+"]); ":I+=" validate.errors = ["+he+"]; return false; ":I+=" var err = "+he+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } else if ( ",S&&(I+=" ("+R+" !== undefined && typeof "+R+" != 'number') || "),I+=" "+ie+" == 'number' ? ( ("+j+" = "+R+" === undefined || "+J+" "+z+"= "+R+") ? "+w+" "+K+"= "+J+" : "+w+" "+K+" "+R+" ) : ( ("+j+" = "+J+" === true) ? "+w+" "+K+"= "+R+" : "+w+" "+K+" "+R+" ) || "+w+" !== "+w+") { var op"+A+" = "+j+" ? '"+z+"' : '"+z+"='; ",h===void 0&&(P=N,Z=a.errSchemaPath+"/"+N,R=J,S=M)}else{var te=typeof D=="number",ue=z;if(te&&S){var Ce="'"+ue+"'";I+=" if ( ",S&&(I+=" ("+R+" !== undefined && typeof "+R+" != 'number') || "),I+=" ( "+R+" === undefined || "+D+" "+z+"= "+R+" ? "+w+" "+K+"= "+D+" : "+w+" "+K+" "+R+" ) || "+w+" !== "+w+") { "}else{te&&h===void 0?(j=!0,P=N,Z=a.errSchemaPath+"/"+N,R=D,K+="="):(te&&(R=Math[H?"min":"max"](D,h)),D===(te?R:!0)?(j=!0,P=N,Z=a.errSchemaPath+"/"+N,K+="="):(j=!1,ue+="="));var Ce="'"+ue+"'";I+=" if ( ",S&&(I+=" ("+R+" !== undefined && typeof "+R+" != 'number') || "),I+=" "+w+" "+K+" "+R+" || "+w+" !== "+w+") { "}}P=P||s;var oe=oe||[];oe.push(I),I="",a.createErrors!==!1?(I+=" { keyword: '"+(P||"_limit")+"' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(Z)+" , params: { comparison: "+Ce+", limit: "+R+", exclusive: "+j+" } ",a.opts.messages!==!1&&(I+=" , message: 'should be "+ue+" ",S?I+="' + "+R:I+=""+R+"'"),a.opts.verbose&&(I+=" , schema: ",S?I+="validate.schema"+y:I+=""+h,I+=" , parentSchema: validate.schema"+a.schemaPath+" , data: "+w+" "),I+=" } "):I+=" {} ";var he=I;return I=oe.pop(),!a.compositeRule&&b?a.async?I+=" throw new ValidationError(["+he+"]); ":I+=" validate.errors = ["+he+"]; return false; ":I+=" var err = "+he+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } ",b&&(I+=" else { "),I},USe=function(a,s,C){var I=" ",A=a.level,d=a.dataLevel,h=a.schema[s],y=a.schemaPath+a.util.getProperty(s),Z=a.errSchemaPath+"/"+s,b=!a.opts.allErrors,N,w="data"+(d||""),S=a.opts.$data&&h&&h.$data,R;if(S?(I+=" var schema"+A+" = "+a.util.getData(h.$data,d,a.dataPathArr)+"; ",R="schema"+A):R=h,!(S||typeof h=="number"))throw new Error(s+" must be number");var H=s=="maxItems"?">":"<";I+="if ( ",S&&(I+=" ("+R+" !== undefined && typeof "+R+" != 'number') || "),I+=" "+w+".length "+H+" "+R+") { ";var N=s,D=D||[];D.push(I),I="",a.createErrors!==!1?(I+=" { keyword: '"+(N||"_limitItems")+"' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(Z)+" , params: { limit: "+R+" } ",a.opts.messages!==!1&&(I+=" , message: 'should NOT have ",s=="maxItems"?I+="more":I+="fewer",I+=" than ",S?I+="' + "+R+" + '":I+=""+h,I+=" items' "),a.opts.verbose&&(I+=" , schema: ",S?I+="validate.schema"+y:I+=""+h,I+=" , parentSchema: validate.schema"+a.schemaPath+" , data: "+w+" "),I+=" } "):I+=" {} ";var M=I;return I=D.pop(),!a.compositeRule&&b?a.async?I+=" throw new ValidationError(["+M+"]); ":I+=" validate.errors = ["+M+"]; return false; ":I+=" var err = "+M+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+="} ",b&&(I+=" else { "),I},QSe=function(a,s,C){var I=" ",A=a.level,d=a.dataLevel,h=a.schema[s],y=a.schemaPath+a.util.getProperty(s),Z=a.errSchemaPath+"/"+s,b=!a.opts.allErrors,N,w="data"+(d||""),S=a.opts.$data&&h&&h.$data,R;if(S?(I+=" var schema"+A+" = "+a.util.getData(h.$data,d,a.dataPathArr)+"; ",R="schema"+A):R=h,!(S||typeof h=="number"))throw new Error(s+" must be number");var H=s=="maxLength"?">":"<";I+="if ( ",S&&(I+=" ("+R+" !== undefined && typeof "+R+" != 'number') || "),a.opts.unicode===!1?I+=" "+w+".length ":I+=" ucs2length("+w+") ",I+=" "+H+" "+R+") { ";var N=s,D=D||[];D.push(I),I="",a.createErrors!==!1?(I+=" { keyword: '"+(N||"_limitLength")+"' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(Z)+" , params: { limit: "+R+" } ",a.opts.messages!==!1&&(I+=" , message: 'should NOT be ",s=="maxLength"?I+="longer":I+="shorter",I+=" than ",S?I+="' + "+R+" + '":I+=""+h,I+=" characters' "),a.opts.verbose&&(I+=" , schema: ",S?I+="validate.schema"+y:I+=""+h,I+=" , parentSchema: validate.schema"+a.schemaPath+" , data: "+w+" "),I+=" } "):I+=" {} ";var M=I;return I=D.pop(),!a.compositeRule&&b?a.async?I+=" throw new ValidationError(["+M+"]); ":I+=" validate.errors = ["+M+"]; return false; ":I+=" var err = "+M+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+="} ",b&&(I+=" else { "),I},jSe=function(a,s,C){var I=" ",A=a.level,d=a.dataLevel,h=a.schema[s],y=a.schemaPath+a.util.getProperty(s),Z=a.errSchemaPath+"/"+s,b=!a.opts.allErrors,N,w="data"+(d||""),S=a.opts.$data&&h&&h.$data,R;if(S?(I+=" var schema"+A+" = "+a.util.getData(h.$data,d,a.dataPathArr)+"; ",R="schema"+A):R=h,!(S||typeof h=="number"))throw new Error(s+" must be number");var H=s=="maxProperties"?">":"<";I+="if ( ",S&&(I+=" ("+R+" !== undefined && typeof "+R+" != 'number') || "),I+=" Object.keys("+w+").length "+H+" "+R+") { ";var N=s,D=D||[];D.push(I),I="",a.createErrors!==!1?(I+=" { keyword: '"+(N||"_limitProperties")+"' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(Z)+" , params: { limit: "+R+" } ",a.opts.messages!==!1&&(I+=" , message: 'should NOT have ",s=="maxProperties"?I+="more":I+="fewer",I+=" than ",S?I+="' + "+R+" + '":I+=""+h,I+=" properties' "),a.opts.verbose&&(I+=" , schema: ",S?I+="validate.schema"+y:I+=""+h,I+=" , parentSchema: validate.schema"+a.schemaPath+" , data: "+w+" "),I+=" } "):I+=" {} ";var M=I;return I=D.pop(),!a.compositeRule&&b?a.async?I+=" throw new ValidationError(["+M+"]); ":I+=" validate.errors = ["+M+"]; return false; ":I+=" var err = "+M+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+="} ",b&&(I+=" else { "),I},fRt=function(a,s,C){var I=" ",A=a.level,d=a.dataLevel,h=a.schema[s],y=a.schemaPath+a.util.getProperty(s),Z=a.errSchemaPath+"/"+s,b=!a.opts.allErrors,w="data"+(d||""),S=a.opts.$data&&h&&h.$data,R;if(S?(I+=" var schema"+A+" = "+a.util.getData(h.$data,d,a.dataPathArr)+"; ",R="schema"+A):R=h,!(S||typeof h=="number"))throw new Error(s+" must be number");I+="var division"+A+";if (",S&&(I+=" "+R+" !== undefined && ( typeof "+R+" != 'number' || "),I+=" (division"+A+" = "+w+" / "+R+", ",a.opts.multipleOfPrecision?I+=" Math.abs(Math.round(division"+A+") - division"+A+") > 1e-"+a.opts.multipleOfPrecision+" ":I+=" division"+A+" !== parseInt(division"+A+") ",I+=" ) ",S&&(I+=" ) "),I+=" ) { ";var H=H||[];H.push(I),I="",a.createErrors!==!1?(I+=" { keyword: 'multipleOf' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(Z)+" , params: { multipleOf: "+R+" } ",a.opts.messages!==!1&&(I+=" , message: 'should be multiple of ",S?I+="' + "+R:I+=""+R+"'"),a.opts.verbose&&(I+=" , schema: ",S?I+="validate.schema"+y:I+=""+h,I+=" , parentSchema: validate.schema"+a.schemaPath+" , data: "+w+" "),I+=" } "):I+=" {} ";var N=I;return I=H.pop(),!a.compositeRule&&b?a.async?I+=" throw new ValidationError(["+N+"]); ":I+=" validate.errors = ["+N+"]; return false; ":I+=" var err = "+N+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+="} ",b&&(I+=" else { "),I},mRt=function(a,s,C){var I=" ",A=a.level,d=a.dataLevel,h=a.schema[s],y=a.schemaPath+a.util.getProperty(s),Z=a.errSchemaPath+"/"+s,b=!a.opts.allErrors,w="data"+(d||""),S="errs__"+A,R=a.util.copy(a);R.level++;var H="valid"+R.level;if(a.opts.strictKeywords?typeof h=="object"&&Object.keys(h).length>0||h===!1:a.util.schemaHasRules(h,a.RULES.all)){R.schema=h,R.schemaPath=y,R.errSchemaPath=Z,I+=" var "+S+" = errors; ";var N=a.compositeRule;a.compositeRule=R.compositeRule=!0,R.createErrors=!1;var D;R.opts.allErrors&&(D=R.opts.allErrors,R.opts.allErrors=!1),I+=" "+a.validate(R)+" ",R.createErrors=!0,D&&(R.opts.allErrors=D),a.compositeRule=R.compositeRule=N,I+=" if ("+H+") { ";var M=M||[];M.push(I),I="",a.createErrors!==!1?(I+=" { keyword: 'not' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(Z)+" , params: {} ",a.opts.messages!==!1&&(I+=" , message: 'should NOT be valid' "),a.opts.verbose&&(I+=" , schema: validate.schema"+y+" , parentSchema: validate.schema"+a.schemaPath+" , data: "+w+" "),I+=" } "):I+=" {} ";var z=I;I=M.pop(),!a.compositeRule&&b?a.async?I+=" throw new ValidationError(["+z+"]); ":I+=" validate.errors = ["+z+"]; return false; ":I+=" var err = "+z+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } else { errors = "+S+"; if (vErrors !== null) { if ("+S+") vErrors.length = "+S+"; else vErrors = null; } ",a.opts.allErrors&&(I+=" } ")}else I+=" var err = ",a.createErrors!==!1?(I+=" { keyword: 'not' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(Z)+" , params: {} ",a.opts.messages!==!1&&(I+=" , message: 'should NOT be valid' "),a.opts.verbose&&(I+=" , schema: validate.schema"+y+" , parentSchema: validate.schema"+a.schemaPath+" , data: "+w+" "),I+=" } "):I+=" {} ",I+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",b&&(I+=" if (false) { ");return I},pRt=function(a,s,C){var I=" ",A=a.level,d=a.dataLevel,h=a.schema[s],y=a.schemaPath+a.util.getProperty(s),Z=a.errSchemaPath+"/"+s,b=!a.opts.allErrors,w="data"+(d||""),S="valid"+A,R="errs__"+A,H=a.util.copy(a),N="";H.level++;var D="valid"+H.level,M=H.baseId,z="prevValid"+A,K="passingSchemas"+A;I+="var "+R+" = errors , "+z+" = false , "+S+" = false , "+K+" = null; ";var P=a.compositeRule;a.compositeRule=H.compositeRule=!0;var J=h;if(J)for(var j,ie=-1,te=J.length-1;ie0||j===!1:a.util.schemaHasRules(j,a.RULES.all))?(H.schema=j,H.schemaPath=y+"["+ie+"]",H.errSchemaPath=Z+"/"+ie,I+=" "+a.validate(H)+" ",H.baseId=M):I+=" var "+D+" = true; ",ie&&(I+=" if ("+D+" && "+z+") { "+S+" = false; "+K+" = ["+K+", "+ie+"]; } else { ",N+="}"),I+=" if ("+D+") { "+S+" = "+z+" = true; "+K+" = "+ie+"; }";return a.compositeRule=H.compositeRule=P,I+=""+N+"if (!"+S+") { var err = ",a.createErrors!==!1?(I+=" { keyword: 'oneOf' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(Z)+" , params: { passingSchemas: "+K+" } ",a.opts.messages!==!1&&(I+=" , message: 'should match exactly one schema in oneOf' "),a.opts.verbose&&(I+=" , schema: validate.schema"+y+" , parentSchema: validate.schema"+a.schemaPath+" , data: "+w+" "),I+=" } "):I+=" {} ",I+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!a.compositeRule&&b&&(a.async?I+=" throw new ValidationError(vErrors); ":I+=" validate.errors = vErrors; return false; "),I+="} else { errors = "+R+"; if (vErrors !== null) { if ("+R+") vErrors.length = "+R+"; else vErrors = null; }",a.opts.allErrors&&(I+=" } "),I},bRt=function(a,s,C){var I=" ",A=a.level,d=a.dataLevel,h=a.schema[s],y=a.schemaPath+a.util.getProperty(s),Z=a.errSchemaPath+"/"+s,b=!a.opts.allErrors,w="data"+(d||""),S=a.opts.$data&&h&&h.$data,R;S?(I+=" var schema"+A+" = "+a.util.getData(h.$data,d,a.dataPathArr)+"; ",R="schema"+A):R=h;var H=S?"(new RegExp("+R+"))":a.usePattern(h);I+="if ( ",S&&(I+=" ("+R+" !== undefined && typeof "+R+" != 'string') || "),I+=" !"+H+".test("+w+") ) { ";var N=N||[];N.push(I),I="",a.createErrors!==!1?(I+=" { keyword: 'pattern' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(Z)+" , params: { pattern: ",S?I+=""+R:I+=""+a.util.toQuotedString(h),I+=" } ",a.opts.messages!==!1&&(I+=` , message: 'should match pattern "`,S?I+="' + "+R+" + '":I+=""+a.util.escapeQuotes(h),I+=`"' `),a.opts.verbose&&(I+=" , schema: ",S?I+="validate.schema"+y:I+=""+a.util.toQuotedString(h),I+=" , parentSchema: validate.schema"+a.schemaPath+" , data: "+w+" "),I+=" } "):I+=" {} ";var D=I;return I=N.pop(),!a.compositeRule&&b?a.async?I+=" throw new ValidationError(["+D+"]); ":I+=" validate.errors = ["+D+"]; return false; ":I+=" var err = "+D+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+="} ",b&&(I+=" else { "),I},yRt=function(a,s,C){var I=" ",A=a.level,d=a.dataLevel,h=a.schema[s],y=a.schemaPath+a.util.getProperty(s),Z=a.errSchemaPath+"/"+s,b=!a.opts.allErrors,w="data"+(d||""),S="errs__"+A,R=a.util.copy(a),H="";R.level++;var N="valid"+R.level,D="key"+A,M="idx"+A,z=R.dataLevel=a.dataLevel+1,K="data"+z,P="dataProperties"+A,J=Object.keys(h||{}).filter(qe),j=a.schema.patternProperties||{},ie=Object.keys(j).filter(qe),te=a.schema.additionalProperties,Ce=J.length||ie.length,ue=te===!1,oe=typeof te=="object"&&Object.keys(te).length,he=a.opts.removeAdditional,ye=ue||oe||he,Ie=a.opts.ownProperties,fe=a.baseId,We=a.schema.required;if(We&&!(a.opts.$data&&We.$data)&&We.length8)I+=" || validate.schema"+y+".hasOwnProperty("+D+") ";else{var nt=J;if(nt)for(var At,Tt=-1,Ne=nt.length-1;Tt0||un===!1:a.util.schemaHasRules(un,a.RULES.all)){var On=a.util.getProperty(At),Zi=w+On,Wg=In&&un.default!==void 0;R.schema=un,R.schemaPath=y+On,R.errSchemaPath=Z+"/"+a.util.escapeFragment(At),R.errorPath=a.util.getPath(a.errorPath,At,a.opts.jsonPointers),R.dataPathArr[z]=a.util.toQuotedString(At);var ui=a.validate(R);if(R.baseId=fe,a.util.varOccurences(ui,K)<2){ui=a.util.varReplace(ui,K,Zi);var ln=Zi}else{var ln=K;I+=" var "+K+" = "+Zi+"; "}if(Wg)I+=" "+ui+" ";else{if(_e&&_e[At]){I+=" if ( "+ln+" === undefined ",Ie&&(I+=" || ! Object.prototype.hasOwnProperty.call("+w+", '"+a.util.escapeQuotes(At)+"') "),I+=") { "+N+" = false; ";var bt=a.errorPath,Vt=Z,Ht=a.util.escapeQuotes(At);a.opts._errorDataPathProperty&&(a.errorPath=a.util.getPath(bt,At,a.opts.jsonPointers)),Z=a.errSchemaPath+"/required";var _t=_t||[];_t.push(I),I="",a.createErrors!==!1?(I+=" { keyword: 'required' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(Z)+" , params: { missingProperty: '"+Ht+"' } ",a.opts.messages!==!1&&(I+=" , message: '",a.opts._errorDataPathProperty?I+="is a required property":I+="should have required property \\'"+Ht+"\\'",I+="' "),a.opts.verbose&&(I+=" , schema: validate.schema"+y+" , parentSchema: validate.schema"+a.schemaPath+" , data: "+w+" "),I+=" } "):I+=" {} ";var Ci=I;I=_t.pop(),!a.compositeRule&&b?a.async?I+=" throw new ValidationError(["+Ci+"]); ":I+=" validate.errors = ["+Ci+"]; return false; ":I+=" var err = "+Ci+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",Z=Vt,a.errorPath=bt,I+=" } else { "}else b?(I+=" if ( "+ln+" === undefined ",Ie&&(I+=" || ! Object.prototype.hasOwnProperty.call("+w+", '"+a.util.escapeQuotes(At)+"') "),I+=") { "+N+" = true; } else { "):(I+=" if ("+ln+" !== undefined ",Ie&&(I+=" && Object.prototype.hasOwnProperty.call("+w+", '"+a.util.escapeQuotes(At)+"') "),I+=" ) { ");I+=" "+ui+" } "}}b&&(I+=" if ("+N+") { ",H+="}")}}if(ie.length){var Ye=ie;if(Ye)for(var He,Qe=-1,pt=Ye.length-1;Qe0||un===!1:a.util.schemaHasRules(un,a.RULES.all)){R.schema=un,R.schemaPath=a.schemaPath+".patternProperties"+a.util.getProperty(He),R.errSchemaPath=a.errSchemaPath+"/patternProperties/"+a.util.escapeFragment(He),Ie?I+=" "+P+" = "+P+" || Object.keys("+w+"); for (var "+M+"=0; "+M+"<"+P+".length; "+M+"++) { var "+D+" = "+P+"["+M+"]; ":I+=" for (var "+D+" in "+w+") { ",I+=" if ("+a.usePattern(He)+".test("+D+")) { ",R.errorPath=a.util.getPathExpr(a.errorPath,D,a.opts.jsonPointers);var Zi=w+"["+D+"]";R.dataPathArr[z]=D;var ui=a.validate(R);R.baseId=fe,a.util.varOccurences(ui,K)<2?I+=" "+a.util.varReplace(ui,K,Zi)+" ":I+=" var "+K+" = "+Zi+"; "+ui+" ",b&&(I+=" if (!"+N+") break; "),I+=" } ",b&&(I+=" else "+N+" = true; "),I+=" } ",b&&(I+=" if ("+N+") { ",H+="}")}}}return b&&(I+=" "+H+" if ("+S+" == errors) {"),I},vRt=function(a,s,C){var I=" ",A=a.level,d=a.dataLevel,h=a.schema[s],y=a.schemaPath+a.util.getProperty(s),Z=a.errSchemaPath+"/"+s,b=!a.opts.allErrors,w="data"+(d||""),S="errs__"+A,R=a.util.copy(a),H="";R.level++;var N="valid"+R.level;if(I+="var "+S+" = errors;",a.opts.strictKeywords?typeof h=="object"&&Object.keys(h).length>0||h===!1:a.util.schemaHasRules(h,a.RULES.all)){R.schema=h,R.schemaPath=y,R.errSchemaPath=Z;var D="key"+A,M="idx"+A,z="i"+A,K="' + "+D+" + '",P=R.dataLevel=a.dataLevel+1,J="data"+P,j="dataProperties"+A,ie=a.opts.ownProperties,te=a.baseId;ie&&(I+=" var "+j+" = undefined; "),ie?I+=" "+j+" = "+j+" || Object.keys("+w+"); for (var "+M+"=0; "+M+"<"+j+".length; "+M+"++) { var "+D+" = "+j+"["+M+"]; ":I+=" for (var "+D+" in "+w+") { ",I+=" var startErrs"+A+" = errors; ";var Ce=D,ue=a.compositeRule;a.compositeRule=R.compositeRule=!0;var oe=a.validate(R);R.baseId=te,a.util.varOccurences(oe,J)<2?I+=" "+a.util.varReplace(oe,J,Ce)+" ":I+=" var "+J+" = "+Ce+"; "+oe+" ",a.compositeRule=R.compositeRule=ue,I+=" if (!"+N+") { for (var "+z+"=startErrs"+A+"; "+z+"0||P===!1:a.util.schemaHasRules(P,a.RULES.all))||(N[N.length]=M)}}else var N=h;if(R||N.length){var J=a.errorPath,j=R||N.length>=a.opts.loopRequired,ie=a.opts.ownProperties;if(b)if(I+=" var missing"+A+"; ",j){R||(I+=" var "+H+" = validate.schema"+y+"; ");var te="i"+A,Ce="schema"+A+"["+te+"]",ue="' + "+Ce+" + '";a.opts._errorDataPathProperty&&(a.errorPath=a.util.getPathExpr(J,Ce,a.opts.jsonPointers)),I+=" var "+S+" = true; ",R&&(I+=" if (schema"+A+" === undefined) "+S+" = true; else if (!Array.isArray(schema"+A+")) "+S+" = false; else {"),I+=" for (var "+te+" = 0; "+te+" < "+H+".length; "+te+"++) { "+S+" = "+w+"["+H+"["+te+"]] !== undefined ",ie&&(I+=" && Object.prototype.hasOwnProperty.call("+w+", "+H+"["+te+"]) "),I+="; if (!"+S+") break; } ",R&&(I+=" } "),I+=" if (!"+S+") { ";var oe=oe||[];oe.push(I),I="",a.createErrors!==!1?(I+=" { keyword: 'required' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(Z)+" , params: { missingProperty: '"+ue+"' } ",a.opts.messages!==!1&&(I+=" , message: '",a.opts._errorDataPathProperty?I+="is a required property":I+="should have required property \\'"+ue+"\\'",I+="' "),a.opts.verbose&&(I+=" , schema: validate.schema"+y+" , parentSchema: validate.schema"+a.schemaPath+" , data: "+w+" "),I+=" } "):I+=" {} ";var he=I;I=oe.pop(),!a.compositeRule&&b?a.async?I+=" throw new ValidationError(["+he+"]); ":I+=" validate.errors = ["+he+"]; return false; ":I+=" var err = "+he+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } else { "}else{I+=" if ( ";var ye=N;if(ye)for(var Ie,te=-1,fe=ye.length-1;te 1) { ";var N=a.schema.items&&a.schema.items.type,D=Array.isArray(N);if(!N||N=="object"||N=="array"||D&&(N.indexOf("object")>=0||N.indexOf("array")>=0))I+=" outer: for (;i--;) { for (j = i; j--;) { if (equal("+w+"[i], "+w+"[j])) { "+S+" = false; break outer; } } } ";else{I+=" var itemIndices = {}, item; for (;i--;) { var item = "+w+"[i]; ";var M="checkDataType"+(D?"s":"");I+=" if ("+a.util[M](N,"item",a.opts.strictNumbers,!0)+") continue; ",D&&(I+=` if (typeof item == 'string') item = '"' + item; `),I+=" if (typeof itemIndices[item] == 'number') { "+S+" = false; j = itemIndices[item]; break; } itemIndices[item] = i; } "}I+=" } ",R&&(I+=" } "),I+=" if (!"+S+") { ";var z=z||[];z.push(I),I="",a.createErrors!==!1?(I+=" { keyword: 'uniqueItems' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(Z)+" , params: { i: i, j: j } ",a.opts.messages!==!1&&(I+=" , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' "),a.opts.verbose&&(I+=" , schema: ",R?I+="validate.schema"+y:I+=""+h,I+=" , parentSchema: validate.schema"+a.schemaPath+" , data: "+w+" "),I+=" } "):I+=" {} ";var K=I;I=z.pop(),!a.compositeRule&&b?a.async?I+=" throw new ValidationError(["+K+"]); ":I+=" validate.errors = ["+K+"]; return false; ":I+=" var err = "+K+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } ",b&&(I+=" else { ")}else b&&(I+=" if (true) { ");return I},GRt={$ref:oRt,allOf:aRt,anyOf:sRt,$comment:IRt,const:lRt,contains:CRt,dependencies:cRt,enum:ARt,format:uRt,if:dRt,items:hRt,maximum:JSe,minimum:JSe,maxItems:USe,minItems:USe,maxLength:QSe,minLength:QSe,maxProperties:jSe,minProperties:jSe,multipleOf:fRt,not:mRt,oneOf:pRt,pattern:bRt,properties:yRt,propertyNames:vRt,required:ZRt,uniqueItems:BRt,validate:WSe},$Se=GRt,Qj=oB.toHash,SRt=function(){var a=[{type:"number",rules:[{maximum:["exclusiveMaximum"]},{minimum:["exclusiveMinimum"]},"multipleOf","format"]},{type:"string",rules:["maxLength","minLength","pattern","format"]},{type:"array",rules:["maxItems","minItems","items","contains","uniqueItems"]},{type:"object",rules:["maxProperties","minProperties","required","dependencies","propertyNames",{properties:["additionalProperties","patternProperties"]}]},{rules:["$ref","const","enum","not","anyOf","oneOf","allOf","if"]}],s=["type","$comment"],C=["$schema","$id","id","$data","$async","title","description","default","definitions","examples","readOnly","writeOnly","contentMediaType","contentEncoding","additionalItems","then","else"],I=["number","integer","string","array","object","boolean","null"];return a.all=Qj(s),a.types=Qj(I),a.forEach(function(A){A.rules=A.rules.map(function(d){var h;if(typeof d=="object"){var y=Object.keys(d)[0];h=d[y],d=y,h.forEach(function(b){s.push(b),a.all[b]=!0})}s.push(d);var Z=a.all[d]={keyword:d,code:$Se[d],implements:h};return Z}),a.all.$comment={keyword:"$comment",code:$Se.$comment},A.type&&(a.types[A.type]=A)}),a.keywords=Qj(s.concat(C)),a.custom={},a},qSe=["multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","additionalItems","maxItems","minItems","uniqueItems","maxProperties","minProperties","required","additionalProperties","enum","format","const"],wRt=function(g,a){for(var s=0;sthis.props.pubSub.unsubscribe(I)),this.pubSubs=[]}},{key:"handleChange",value:function(I){const A=this.getLogMsgs(I);this.setState({code:I,logMsgs:A})}},{key:"handleKeyDown",value:function(I){I.key==="s"&&(I.ctrlKey||I.metaKey)&&(I.preventDefault(),this.props.onChange(this.state.code)),I.key==="Enter"&&(I.ctrlKey||I.metaKey)&&(I.preventDefault(),this.props.onChange(this.state.code),this.props.modal.close())}},{key:"handleKeyUp",value:function(I){this.setState({hide:!1}),I.key==="Escape"&&(I.preventDefault(),this.props.modal.close(),this.props.onCancel())}},{key:"handleSubmit",value:function(I){I&&I.preventDefault(),this.props.onSave(this.state.code)}},{key:"getLogMsgs",value:function(I){const A=[];let d;try{d=JSON.parse(I)}catch(Z){return console.warn(Z),A.push({type:"Error",msg:Z.toString()}),A}const h=new awe().compile(qj);return h(d)||(console.warn("Invalid viewconf"),A.push({type:"Warning",msg:"Invalid viewconf"})),h.errors&&(console.warn(JSON.stringify(h.errors,null,2)),h.errors.forEach(Z=>{A.push({type:"Warning",msg:JSON.stringify(Z,null,2)})})),A.length===0&&A.push({type:"Success",msg:"No error or warnings"}),A}},{key:"hide",value:function(){this.setState({hide:!0})}},{key:"show",value:function(){this.setState({hide:!1})}},{key:"hideLog",value:function(){this.setState({showLog:!1})}},{key:"showLog",value:function(){this.setState({showLog:!0})}},{key:"toggleLog",value:function(){this.state.showLog?this.hideLog():this.showLog()}},{key:"render",value:function(){const I=this.state.logMsgs.map((A,d)=>{const h=`${d}-${A.msg}`;return X.default.createElement("tr",{key:h},X.default.createElement("td",{className:lr(vb.title,vb[A.type])},`[${d}] ${A.type}`),X.default.createElement("td",null,X.default.createElement("pre",null,A.msg)))});return X.default.createElement(eR,{cancelShortcut:"ESC",cancelTitle:"Discard Changes",hide:this.state.hide,maxHeight:!0,okayShortcut:"⌘+Enter",okayTitle:"Save and Close",onCancel:this.props.onCancel,onOkay:this.handleSubmitBound,title:"Edit View Config"},X.default.createElement(X.default.Fragment,null,X.default.createElement("header",{className:vb["view-config-editor-header"]},X.default.createElement(nh,{onBlur:this.showBound,onMouseDown:this.hideBound,onMouseOut:this.showBound,onMouseUp:this.showBound},"Hide While Mousedown"),X.default.createElement(nh,{onClick:()=>{this.props.onChange(this.state.code)},shortcut:"⌘+S"},"Save")),X.default.createElement("div",{ref:A=>{this.editorWrap=A},className:vb["view-config-editor"]},X.default.createElement(aTt,{ref:A=>{this.editor=A},highlight:A=>Hj.exports.highlight(A,Hj.exports.languages.json),onValueChange:this.handleChangeBound,padding:10,style:{fontFamily:'"Fira code", "Fira Mono", monospace',fontSize:"inherit"},value:this.state.code})),X.default.createElement("div",{className:vb["view-config-log"],style:{height:this.state.showLog?"50%":"30px"}},X.default.createElement("div",{className:vb["view-config-log-header"],onClick:()=>this.toggleLogBound()},`Log Messages (${this.state.logMsgs.filter(A=>A.type!=="Success").length})`),X.default.createElement("div",{className:vb["view-config-log-msg"],style:{padding:this.state.showLog?"10px":0}},X.default.createElement("table",null,X.default.createElement("tbody",null,I))))))}}]),s}(X.default.Component);cwe.propTypes={modal:_.exports.object.isRequired,onCancel:_.exports.func.isRequired,onChange:_.exports.func.isRequired,onSave:_.exports.func.isRequired,pubSub:_.exports.object.isRequired,viewConfig:_.exports.string.isRequired};const uVt=qZ(qx(cwe));function dVt(g,a,s,C){const I=g.append("symbol").attr("id",a).attr("viewBox",C);s.forEach(A=>I.append("path").attr("d",A).attr("fill","currentColor"))}const hVt=g=>{g.setState(g.state)},fVt=function(a,s){const C=a;let I=[];const A=Vk(),d=()=>{I.forEach(h=>s.unsubscribe(h)),I=[]};return{destroy:d,publish:A.publish,stack:A.stack,public:{get version(){return uQ},setBroadcastMousePositionGlobally(h=!1){C.setBroadcastMousePositionGlobally(h)},setShowGlobalMousePosition(h=!1){C.setShowGlobalMousePosition(h)},setGlobalMousePosition(h=!1){C.setBroadcastMousePositionGlobally(h),C.setShowGlobalMousePosition(h)},setAuthHeader(h){L2(h),C.reload()},getAuthHeader(){return L2()},getComponent(){return C},reload(h){let y;h?y=h.flatMap(Z=>typeof Z=="string"?C.iterateOverTracksInView(Z):Z):y=C.iterateOverTracks();for(const{viewId:Z,trackId:b}of y){const w=C.getTrackObject(Z,b);for(const S of w.childTracks||[w])S.fetchedTiles&&(S.removeTiles(Object.keys(S.fetchedTiles)),S.fetching.clear(),S.refreshTiles()),S.rerender(S.options,!0)}},destroy(){d(),$.default.unmountComponentAtNode(C.topDiv.parentNode)},setRangeSelectionToInt(){C.setState({rangeSelectionToInt:!0})},setRangeSelectionToFloat(){C.setState({rangeSelectionToInt:!1})},setRangeSelection1dSize(h=0,y=1/0){C.setState({rangeSelection1dSize:[h,y]})},setViewConfig(h,y=!1){const Z=C.processViewConfig(h);return new Promise(w=>{this.requestsInFlight=0,I.push(s.subscribe("requestSent",()=>{this.requestsInFlight+=1})),I.push(s.subscribe("requestReceived",()=>{this.requestsInFlight-=1,this.requestsInFlight===0&&w()})),C.setState({viewConfig:h,views:Z},()=>{y&&w()})})},getViewConfig(){return C.getViewsAsJson()},validateViewConfig(h,{verbose:y=!1}={}){const Z=new awe().compile(qj),b=Z(h);return y&&Z.errors&&console.warn(JSON.stringify(Z.errors,null,2)),b},getMinMaxValue(h,y,Z=!1,b=!1){return C.getMinMaxValue(h,y,Z,b)},shareViewConfigAsLink(h){return C.handleExportViewsAsLink(h,!0)},showAvailableTrackPositions(h){C.setState({draggingHappening:h})},hideAvailableTrackPositions(){C.setState({draggingHappening:null})},showTrackChooser(h){C.setState({chooseTrackHandler:(...y)=>{C.setState({chooseTrackHandler:null}),h(...y)}})},hideTrackChooser(){this.setState({chooseTrackHandler:null})},setTrackValueScaleLimits(h,y,Z,b){C.setTrackValueScaleLimits(h,y,Z,b)},setDarkTheme(h){console.warn('`setDarkTheme(true)` is deprecated. Please use `setTheme("dark")`.');const y=h?"dark":"light";C.setTheme(y)},setTheme(h){console.warn("Please note that theming is still in beta!"),C.setTheme(h)},zoomTo(h,y,Z,b,w,S=0){C.zoomTo(h,y,Z,b,w,S)},zoomToGene(h,y,Z=0,b=0){C.zoomToGene(h,y,Z,b)},suggestGene(h,y,Z){return C.suggestGene(h,y,Z)},zoomToDataExtent(h){C.handleZoomToData(h)},resetViewport(h){C.resetViewport(h)},activateTool(h){switch(h){case"select":C.setMouseTool(oC);break;default:C.setMouseTool(jk);break}},exportAsPngBlobPromise(){return C.createPNGBlobPromise()},exportAsSvg(){return C.createSVGString()},exportAsViewConfString(){return C.getViewsAsString()},getRangeSelection(){return C.rangeSelection},getLocation(h){const y=h?C.xScales[h]&&C.yScales[h]&&h:Object.values(C.tiledPlots)[0]&&Object.values(C.tiledPlots)[0].props.uid;return y?{xDomain:C.xScales[y].domain(),yDomain:C.yScales[y].domain(),xRange:C.xScales[y].range(),yRange:C.yScales[y].range()}:"Please provide a valid view UUID sweetheart 😙"},getTrackObject(h,y){let Z=h,b=y;return y||(Z=Object.values(C.state.views)[0].uid,b=h),AX(C,Z,b)},option(h,y){if(typeof y>"u")return C.props.options[h];switch(h){case"sizeMode":C.props.options[h]=y,hVt(C);break;default:console.warn(`This option "${h}" is either unknown or not settable.`)}},off(h,y,Z){const b=typeof y=="object"?y.callback:y;switch(h){case"click":A.unsubscribe("click",b);break;case"cursorLocation":A.unsubscribe("cursorLocation",b);break;case"location":C.offLocationChange(Z,y);break;case"mouseMoveZoom":A.unsubscribe("mouseMoveZoom",b);break;case"wheel":A.unsubscribe("wheel",b);break;case"rangeSelection":A.unsubscribe("rangeSelection",b);break;case"viewConfig":C.offViewChange(y);break;case"createSVG":C.offPostCreateSVG();break;case"geneSearch":A.unsubscribe("geneSearch",b);break}},on(h,y,Z,b){switch(h){case"click":return A.subscribe("click",y);case"cursorLocation":return A.subscribe("cursorLocation",y);case"location":return C.onLocationChange(Z,y,b);case"mouseMoveZoom":return A.subscribe("mouseMoveZoom",y);case"wheel":return A.subscribe("wheel",y);case"rangeSelection":return A.subscribe("rangeSelection",y);case"viewConfig":return C.onViewChange(y);case"createSVG":return C.onPostCreateSVG(y);case"geneSearch":return A.subscribe("geneSearch",y);default:return}}}}},aB={higlass:"_higlass_1uoq8_1","higlass-dark-theme":"_higlass-dark-theme_1uoq8_5","higlass-container-overflow":"_higlass-container-overflow_1uoq8_9","higlass-scroll-container-overflow":"_higlass-scroll-container-overflow_1uoq8_10","higlass-scroll-container-scroll":"_higlass-scroll-container-scroll_1uoq8_11","higlass-canvas":"_higlass-canvas_1uoq8_28","higlass-drawing-surface":"_higlass-drawing-surface_1uoq8_34","higlass-svg":"_higlass-svg_1uoq8_38","tiled-area":"_tiled-area_1uoq8_47","track-mouseover-menu":"_track-mouseover-menu_1uoq8_52"},Awe=12,mVt=12,pVt=20,bVt="default",uwe="bounded",dwe="overflow",TR="scroll";let e6=function(g){o(s,g);var a=l(s);function s(C){var I;T(this,s),I=a.call(this,C),N0e(X.default.version)<15.6&&console.warn("HiGlass requires React v15.6 or higher. Current version: ",X.default.version),I.pubSub=Vk(),I.domEvent=u0e(I.pubSub),I.pubSubs=[],I.minHorizontalHeight=20,I.minVerticalWidth=20,I.resizeSensor=null,I.uid=Fn.nice(),I.tiledPlots={},I.genomePositionSearchBoxes={},I.xScales={},I.yScales={},I.projectionXDomains={},I.projectionYDomains={},I.topDiv=null,I.zoomToDataExtentOnInit=new Set,I.viewTrackUidsToCombinedUid={},I.combinedUidToViewTrack={},I.scalesChangedListeners={},I.draggingChangedListeners={},I.valueScalesChangedListeners={},I.zoomLocks={},I.locationLocks={},I.locationLocksAxisWise={x:{},y:{}},I.valueScaleLocks={},I.prevAuthToken=C.options.authToken,I.setCenters={},I.plusImg={},I.configImg={},$t.PIXI=C.options&&C.options.PIXI||ee,I.viewMarginTop=+C.options.viewMarginTop>=0?+C.options.viewMarginTop:D2,I.viewMarginBottom=+C.options.viewMarginBottom>=0?+C.options.viewMarginBottom:D2,I.viewMarginLeft=+C.options.viewMarginLeft>=0?+C.options.viewMarginLeft:D2,I.viewMarginRight=+C.options.viewMarginRight>=0?+C.options.viewMarginRight:D2,I.viewPaddingTop=+C.options.viewPaddingTop>=0?+C.options.viewPaddingTop:M2,I.viewPaddingBottom=+C.options.viewPaddingBottom>=0?+C.options.viewPaddingBottom:M2,I.viewPaddingLeft=+C.options.viewPaddingLeft>=0?+C.options.viewPaddingLeft:M2,I.viewPaddingRight=+C.options.viewPaddingRight>=0?+C.options.viewPaddingRight:M2,I.genomePositionSearchBox=null,I.viewHeaders={},I.boundRefreshView=()=>{I.refreshView(F2)},I.unsetOnLocationChange=[],I.setTheme(C.options.theme,C.options.isDarkTheme),I.viewconfLoaded=!1;const{viewConfig:A}=I.props,d=I.loadIfRemoteViewConfig(I.props.viewConfig);C.options.authToken&&L2(C.options.authToken),I.pixiRoot=new $t.PIXI.Container,I.pixiRoot.interactive=!0,I.pixiStage=new $t.PIXI.Container,I.pixiStage.interactive=!0,I.pixiRoot.addChild(I.pixiStage),I.pixiMask=new $t.PIXI.Graphics,I.pixiRoot.addChild(I.pixiMask),I.pixiStage.mask=I.pixiMask,I.element=null,I.scrollTop=0;let h=jk;if(I.props.options)switch(I.props.options.mouseTool){case oC:h=oC;break}I.props.options.pluginTracks&&(window.higlassTracksByType=Object.assign(window.higlassTracksByType||{},I.props.options.pluginTracks));const y={};try{window.higlassTracksByType&&Object.entries(window.higlassTracksByType).forEach(([N,D])=>{y[N]=D})}catch{console.warn("Broken config of a plugin track")}I.props.options.pluginDataFetchers&&(window.higlassDataFetchersByType=Object.assign(window.higlassDataFetchersByType||{},I.props.options.pluginDataFetchers));const Z=window.higlassDataFetchersByType,b=I.props.options.pixelPreciseMarginPadding?1:30;I.mounted=!1,I.pluginTracks=y,I.pluginDataFetchers=Z,I.state={currentBreakpoint:"lg",width:0,height:0,rowHeight:b,svgElement:null,canvasElement:null,customDialog:null,views:d,viewConfig:A,addTrackPositionMenuPosition:null,typedEditable:void 0,mouseOverOverlayUid:null,mouseTool:h,isDarkTheme:!1,rangeSelection1dSize:[0,1/0],rangeSelectionToInt:!1,modal:null},I.attachedToDOM=!1;const{public:w,destroy:S,publish:R,stack:H}=fVt(u(I),I.pubSub);return I.api=w,I.apiDestroy=S,I.apiPublish=R,I.apiStack=H,I.viewChangeListener=[],I.triggerViewChangeDb=iX(I.triggerViewChange.bind(u(I)),250),I.pubSubs=[],I.rangeSelection=[null,null],I.prevMouseHoverTrack=null,I.zooming=!1,I.appClickHandlerBound=I.appClickHandler.bind(u(I)),I.canvasClickHandlerBound=I.canvasClickHandler.bind(u(I)),I.keyDownHandlerBound=I.keyDownHandler.bind(u(I)),I.keyUpHandlerBound=I.keyUpHandler.bind(u(I)),I.resizeHandlerBound=I.resizeHandler.bind(u(I)),I.resizeHandlerBound=I.resizeHandler.bind(u(I)),I.dispatchEventBound=I.dispatchEvent.bind(u(I)),I.animateOnMouseMoveHandlerBound=I.animateOnMouseMoveHandler.bind(u(I)),I.zoomStartHandlerBound=I.zoomStartHandler.bind(u(I)),I.zoomEndHandlerBound=I.zoomEndHandler.bind(u(I)),I.zoomHandlerBound=I.zoomHandler.bind(u(I)),I.trackDroppedHandlerBound=I.trackDroppedHandler.bind(u(I)),I.trackDimensionsModifiedHandlerBound=I.trackDimensionsModifiedHandler.bind(u(I)),I.animateBound=I.animate.bind(u(I)),I.animateOnGlobalEventBound=I.animateOnGlobalEvent.bind(u(I)),I.requestReceivedHandlerBound=I.requestReceivedHandler.bind(u(I)),I.wheelHandlerBound=I.wheelHandler.bind(u(I)),I.mouseMoveHandlerBound=I.mouseMoveHandler.bind(u(I)),I.onMouseLeaveHandlerBound=I.onMouseLeaveHandler.bind(u(I)),I.onBlurHandlerBound=I.onBlurHandler.bind(u(I)),I.openModalBound=I.openModal.bind(u(I)),I.closeModalBound=I.closeModal.bind(u(I)),I.handleEditViewConfigBound=I.handleEditViewConfig.bind(u(I)),I.onScrollHandlerBound=I.onScrollHandler.bind(u(I)),I.typedText="",I.typedTextTimeout=null,I.modal={open:I.openModalBound,close:I.closeModalBound},I.setBroadcastMousePositionGlobally(I.props.options.broadcastMousePositionGlobally||I.props.options.globalMousePosition),I.setShowGlobalMousePosition(I.props.options.showGlobalMousePosition||I.props.options.globalMousePosition),I}return E(s,[{key:"UNSAFE_componentWillMount",value:function(){this.domEvent.register("keydown",document),this.domEvent.register("keyup",document),this.domEvent.register("scroll",document),this.domEvent.register("resize",window),this.domEvent.register("orientationchange",window),this.domEvent.register("wheel",window),this.domEvent.register("mousedown",window,!0),this.domEvent.register("mouseup",window,!0),this.domEvent.register("click",window,!0),this.domEvent.register("mousemove",window),this.domEvent.register("touchmove",window),this.domEvent.register("touchstart",window),this.domEvent.register("touchend",window),this.domEvent.register("touchcancel",window),this.domEvent.register("blur",window),this.pubSubs.push(this.pubSub.subscribe("app.click",this.appClickHandlerBound),this.pubSub.subscribe("blur",this.onBlurHandlerBound),this.pubSub.subscribe("keydown",this.keyDownHandlerBound),this.pubSub.subscribe("keyup",this.keyUpHandlerBound),this.pubSub.subscribe("resize",this.resizeHandlerBound),this.pubSub.subscribe("wheel",this.wheelHandlerBound),this.pubSub.subscribe("orientationchange",this.resizeHandlerBound),this.pubSub.subscribe("app.event",this.dispatchEventBound),this.pubSub.subscribe("app.animateOnMouseMove",this.animateOnMouseMoveHandlerBound),this.pubSub.subscribe("trackDropped",this.trackDroppedHandlerBound),this.pubSub.subscribe("trackDimensionsModified",this.trackDimensionsModifiedHandlerBound),this.pubSub.subscribe("app.zoomStart",this.zoomStartHandlerBound),this.pubSub.subscribe("app.zoomEnd",this.zoomEndHandlerBound),this.pubSub.subscribe("app.zoom",this.zoomHandlerBound),this.pubSub.subscribe("requestReceived",this.requestReceivedHandlerBound)),this.props.getApi&&this.props.getApi(this.api)}},{key:"sizeMode",get:function(){return typeof this.props.options.sizeMode>"u"?this.props.options.bounded?"bounded":bVt:this.props.options.sizeMode}},{key:"setBroadcastMousePositionGlobally",value:function(I=!1){this.isBroadcastMousePositionGlobally=I}},{key:"setShowGlobalMousePosition",value:function(I=!1){if(this.isShowGlobalMousePosition=I,this.isShowGlobalMousePosition&&!this.globalMousePositionListener&&(this.globalMousePositionListener=G2.subscribe("higlass.mouseMove",this.animateOnGlobalEventBound),this.pubSubs.push(this.globalMousePositionListener)),this.isShowGlobalMousePosition&&!this.globalMousePositionListener){const A=this.pubSubs.findIndex(d=>d===this.globalMousePositionListener);G2.unsubscribe(this.globalMousePositionListener),A>=0&&this.pubSubs.splice(A,1),this.globalMousePositionListener=void 0}}},{key:"zoomStartHandler",value:function(){this.hideHoverMenu(),this.zooming=!0}},{key:"zoomEndHandler",value:function(){this.zooming=!1}},{key:"zoomHandler",value:function(I){I.sourceEvent&&this.mouseMoveHandler(I.sourceEvent)}},{key:"waitForDOMAttachment",value:function(I){if(!this.mounted)return;const A=$.default.findDOMNode(this);document.body.contains(A)?I():requestAnimationFrame(()=>this.waitForDOMAttachment(I))}},{key:"componentDidMount",value:function(){this.mounted=!0,this.element=$.default.findDOMNode(this),window.addEventListener("focus",this.boundRefreshView),Object.values(this.state.views).forEach(h=>{this.adjustLayoutToTrackSizes(h),h.layout?h.layout.i=h.uid:h.layout=this.generateViewLayout(h)});const I={width:this.state.width,height:this.state.height,view:this.canvasElement,antialias:!0,transparent:!0,resolution:2,autoResize:!0},A=parseInt(ee.VERSION[0],10);A===4?(console.warn("Deprecation warning: please update Pixi.js to version 5 or above!"),this.props.options.renderer==="canvas"?this.pixiRenderer=new $t.PIXI.CanvasRenderer(I):this.pixiRenderer=new $t.PIXI.WebGLRenderer(I)):(A<4&&console.warn("Deprecation warning: please update Pixi.js to version 5 or above! This version of Pixi.js is unsupported. Good luck 🤞"),this.props.options.renderer==="canvas"?this.pixiRenderer=new $t.PIXI.CanvasRenderer(I):this.pixiRenderer=new $t.PIXI.Renderer(I)),this.fitPixiToParentContainer(),this.setState({svgElement:this.svgElement,canvasElement:this.canvasElement}),this.waitForDOMAttachment(()=>{wk.ElementQueries.listen(),this.resizeSensor=new wk.ResizeSensor(this.element.parentNode,this.updateAfterResize.bind(this)),this.updateAfterResize()}),this.handleDragStart(),this.handleDragStop(),this.animate();const d=Mn(this.element).append("svg").style("display","none");$Ct.forEach(h=>dVt(d,h.id,h.paths,h.viewBox))}},{key:"getTrackObject",value:function(I,A){return this.tiledPlots[I].trackRenderer.getTrackObject(A)}},{key:"getTrackRenderer",value:function(I){return this.tiledPlots[I].trackRenderer}},{key:"loadIfRemoteViewConfig",value:function(I){let A={};return typeof I=="string"?Gi.json(I,(d,h)=>{I=h,this.setState({views:this.processViewConfig(JSON.parse(JSON.stringify(h))),viewConfig:h}),this.unsetOnLocationChange.forEach(({viewId:y,callback:Z,callbackId:b})=>{this.onLocationChange(y,Z,b)})},this.pubSub):(A=this.processViewConfig(JSON.parse(JSON.stringify(I))),this.mounted&&this.setState({viewConfig:I})),A}},{key:"UNSAFE_componentWillReceiveProps",value:function(I){const A=this.loadIfRemoteViewConfig(I.viewConfig);if(I.options.authToken!==this.prevAuthToken){L2(I.options.authToken);for(const d of this.iterateOverViews()){const h=this.getTrackRenderer(d),y=JSON.parse(h.prevTrackDefinitions);h.syncTrackObjects([]),h.syncTrackObjects(y)}this.prevAuthToken=I.options.authToken}for(const d of Mr(A))this.adjustLayoutToTrackSizes(d);this.setState({views:A})}},{key:"UNSAFE_componentWillUpdate",value:function(){this.pixiRenderer.render(this.pixiRoot)}},{key:"componentDidUpdate",value:function(){this.setTheme(this.props.options.theme,this.props.options.isDarkTheme),this.animate(),this.triggerViewChangeDb()}},{key:"componentWillUnmount",value:function(){this.mounted=!1,this.pixiStage.destroy(!1),this.pixiStage=null,this.pixiRenderer.destroy(!0),this.pixiRenderer=null,window.removeEventListener("focus",this.boundRefreshView),this.resizeSensor&&this.resizeSensor.detach(),this.domEvent.unregister("keydown",document),this.domEvent.unregister("keyup",document),this.domEvent.unregister("scroll",document),this.domEvent.unregister("wheel",window),this.domEvent.unregister("mousedown",window),this.domEvent.unregister("mouseup",window),this.domEvent.unregister("click",window),this.domEvent.unregister("mousemove",window),this.domEvent.unregister("touchmove",window),this.domEvent.unregister("touchstart",window),this.domEvent.unregister("touchend",window),this.domEvent.unregister("touchcancel",window),this.pubSubs.forEach(I=>this.pubSub.unsubscribe(I)),this.pubSubs=[],this.apiDestroy()}},{key:"setTheme",value:function(I=this.props.options.theme,A=this.props.options.isDarkTheme){if(typeof A<"u")console.warn("The option `isDarkTheme` is deprecated. Please use `theme` instead."),this.theme=A?"dark":"light";else switch(I){case"dark":this.theme=ig;break;case"light":case void 0:this.theme=qk;break;default:console.warn(`Unknown theme "${I}". Using light theme.`),this.theme=qk;break}}},{key:"dispatchEvent",value:function(I){this.canvasElement&&nX(I,this.canvasElement)}},{key:"trackDroppedHandler",value:function(){this.setState({draggingHappening:null})}},{key:"requestReceivedHandler",value:function(){!this.viewconfLoaded&&O2===0&&(this.viewconfLoaded=!0,this.props.options.onViewConfLoaded&&this.props.options.onViewConfLoaded())}},{key:"animateOnMouseMoveHandler",value:function(I){I&&!this.animateOnMouseMove&&this.pubSubs.push(this.pubSub.subscribe("app.mouseMove",this.animateBound)),this.animateOnMouseMove=I}},{key:"fitPixiToParentContainer",value:function(){if(!this.element||!this.element.parentNode){console.warn("No parentNode:",this.element);return}const I=this.element.parentNode.clientWidth,A=this.element.parentNode.clientHeight;this.pixiMask.beginFill(16777215).drawRect(0,0,I,A).endFill(),this.pixiRenderer.resize(I,A),this.pixiRenderer.view.style.width=`${I}px`,this.pixiRenderer.view.style.height=`${A}px`,this.pixiRenderer.render(this.pixiRoot)}},{key:"addDefaultTrackOptions",value:function(I){const A=this.getTrackInfo(I.type);if(!A)return;typeof I.options>"u"&&(I.options={});const d=I.options?I.options:{};if(this.props.options.defaultTrackOptions){if(this.props.options.defaultTrackOptions.trackSpecific&&this.props.options.defaultTrackOptions.trackSpecific[I.type]){const h=this.props.options.defaultTrackOptions.trackSpecific[I.type];for(const y in h)I.options[y]=typeof I.options[y]<"u"?I.options[y]:JSON.parse(JSON.stringify(h[y]))}if(this.props.options.defaultTrackOptions.all){const h=this.props.options.defaultTrackOptions.all;for(const y in h)I.options[y]=typeof I.options[y]<"u"?I.options[y]:JSON.parse(JSON.stringify(h[y]))}}if(A.defaultOptions){const h=A.defaultOptionsByTheme&&A.defaultOptionsByTheme[this.theme]?A.defaultOptionsByTheme[this.theme]:{},y={...A.defaultOptions,...h};if(!I.options)I.options=JSON.parse(JSON.stringify(y));else for(const Z in y)I.options[Z]=typeof I.options[Z]<"u"?I.options[Z]:JSON.parse(JSON.stringify(y[Z]))}else I.options=d}},{key:"toggleTypedEditable",value:function(){this.setState({typedEditable:!this.isEditable()})}},{key:"typedTextHandler",value:function(I){if(!this.props.options.cheatCodesEnabled)return;this.typedText=this.typedText.concat(I.key),this.typedText.endsWith("hgedit")&&(this.toggleTypedEditable(),this.typedText="");const A=750;this.typedTextTimeout&&clearTimeout(this.typedTextTimeout),this.typedTextTimeout=setTimeout(()=>{this.typedText=""},A)}},{key:"keyDownHandler",value:function(I){this.typedTextHandler(I),this.props.options.rangeSelectionOnAlt&&I.key==="Alt"&&this.setState({mouseTool:oC})}},{key:"keyUpHandler",value:function(I){this.props.options.rangeSelectionOnAlt&&I.key==="Alt"&&this.setState({mouseTool:jk})}},{key:"openModal",value:function(I){this.setState({modal:X.default.cloneElement(I,{ref:A=>{this.modalRef=A}})})}},{key:"closeModal",value:function(){this.modalRef=null,this.setState({modal:null})}},{key:"handleEditViewConfig",value:function(){const{viewConfig:I}=this.state;this.setState({viewConfigTmp:I}),this.openModal(X.default.createElement(uVt,{onCancel:()=>{const{viewConfigTmp:A}=this.state,d=this.processViewConfig(A);for(const h of Mr(d))this.adjustLayoutToTrackSizes(h);this.setState({views:d,viewConfig:A,viewConfigTmp:null})},onChange:A=>{const d=JSON.parse(A),h=this.processViewConfig(d);for(const y of Mr(h))this.adjustLayoutToTrackSizes(y);this.setState({views:h,viewConfig:d})},onSave:A=>{const d=JSON.parse(A),h=this.processViewConfig(d);for(const y of Mr(h))this.adjustLayoutToTrackSizes(y);this.setState({views:h,viewConfig:d,viewConfigTmp:null})},viewConfig:this.getViewsAsString()}))}},{key:"animate",value:function(){this.isRequestingAnimationFrame||(this.isRequestingAnimationFrame=!0,requestAnimationFrame(()=>{this.pixiRenderer&&(this.pixiRenderer.render(this.pixiRoot),this.isRequestingAnimationFrame=!1)}))}},{key:"animateOnGlobalEvent",value:function({sourceUid:I}={}){I!==this.uid&&this.animateOnMouseMove&&this.animate()}},{key:"measureSize",value:function(){const[I,A]=b0e(this.element);I>0&&A>0&&this.setState({sizeMeasured:!0,width:I,height:A})}},{key:"updateAfterResize",value:function(){this.measureSize(),this.updateRowHeight(),this.fitPixiToParentContainer(),this.refreshView(F2),this.resizeHandler()}},{key:"onBreakpointChange",value:function(I){this.setState({currentBreakpoint:I})}},{key:"handleOverlayMouseEnter",value:function(I){this.setState({mouseOverOverlayUid:I})}},{key:"handleOverlayMouseLeave",value:function(){this.setState({mouseOverOverlayUid:null})}},{key:"handleLockLocation",value:function(I){this.setState({chooseViewHandler:A=>this.handleLocationLockChosen(I,A),mouseOverOverlayUid:I})}},{key:"isEditable",value:function(){return this.state.typedEditable!==void 0?this.state.typedEditable:!this.props.options||!("editable"in this.props.options)?this.state.viewConfig.editable:this.props.options.editable&&this.state.viewConfig.editable}},{key:"isTrackMenuDisabled",value:function(){return this.props.options&&(this.props.options.editable===!1||this.props.options.tracksEditable===!1)?!0:this.state.viewConfig&&(this.state.viewConfig.tracksEditable===!1||this.state.viewConfig.editable===!1)}},{key:"isViewHeaderDisabled",value:function(){return this.props.options&&(this.props.options.editable===!1||this.props.options.viewEditable===!1)?!0:this.state.viewConfig&&(this.state.viewConfig.viewEditable===!1||this.state.viewConfig.editable===!1)}},{key:"iterateOverViews",value:function(){const I=[];for(const A in Object.keys(this.state.views))I.push(A);return I}},{key:"iterateOverTracksInView",value:function(I){const A=[],{tracks:d}=this.state.views[I];for(const h in d)for(const y of d[h])if(y.type==="combined"&&y.contents)for(const Z of y.contents)A.push({viewId:I,trackId:Z.uid,track:Z});else A.push({viewId:I,trackId:y.uid,track:y});return A}},{key:"iterateOverTracks",value:function(){const I=[];for(const A in this.state.views){const{tracks:d}=this.state.views[A];for(const h in d)for(const y of d[h])if(y.type==="combined"&&y.contents)for(const Z of y.contents)I.push({viewId:A,trackId:Z.uid,track:Z});else I.push({viewId:A,trackId:y.uid,track:y})}return I}},{key:"setMouseTool",value:function(I){this.setState({mouseTool:I})}},{key:"isValueScaleLocked",value:function(I,A){const d=this.combineViewAndTrackUid(I,A);return this.state.views[I]?!!this.valueScaleLocks[d]:!1}},{key:"getLockGroupExtrema",value:function(I,A){const d=this.combineViewAndTrackUid(I,A);if(!this.state.views[I]||!this.valueScaleLocks[d])return null;const h=this.valueScaleLocks[d],y=Object.values(h).filter(R=>this.tiledPlots[R.view]).map(R=>this.tiledPlots[R.view].trackRenderer.getTrackObject(R.track)).filter(R=>R).map(R=>R.originalTrack===void 0?R:R.originalTrack),Z=y.filter(R=>R.minRawValue&&R.maxRawValue).map(R=>h.ignoreOffScreenValues?R.minVisibleValue(!0):R.minVisibleValueInTiles(!0)),b=y.filter(R=>R.minRawValue&&R.maxRawValue).map(R=>h.ignoreOffScreenValues?R.maxVisibleValue(!0):R.maxVisibleValueInTiles(!0));if(Z.length===0||Z.filter(R=>R===null||R===1/0).length>0||b.length===0||b.filter(R=>R===null||R===-1/0).length>0)return null;const w=Math.min(...Z),S=Math.max(...b);return[w,S]}},{key:"syncValueScales",value:function(I,A){const d=this.combineViewAndTrackUid(I,A);if(!this.state.views[I])return;const h=yl(this.state.views[I].tracks,A);if(this.valueScaleLocks[d]){const y=this.valueScaleLocks[d],Z=Object.values(y).filter(H=>this.tiledPlots[H.view]).map(H=>this.tiledPlots[H.view].trackRenderer.getTrackObject(H.track)).filter(H=>H).map(H=>H.originalTrack===void 0?H:H.originalTrack),b=this.getLockGroupExtrema(I,A);if(b===null)return;const w=b[0],S=b[1],R=1e-6;for(const H of Z){if(H.minValue&&H.minValue(w),H.maxValue&&H.maxValue(S),!H.valueScale)continue;const N=Math.abs(H.minValue()-H.valueScale.domain()[0])>R||Math.abs(H.maxValue()-H.valueScale.domain()[1])>R,D=h.options&&H.options&&typeof h.options.scaleStartPercent<"u"&&typeof h.options.scaleEndPercent<"u"&&(Math.abs(H.options.scaleStartPercent-h.options.scaleStartPercent)>R||Math.abs(H.options.scaleEndPercent-h.options.scaleEndPercent)>R);H.continuousScaling&&!N&&!D||(H.valueScale.domain([w,S]),H.prevValueScale=H.valueScale.copy(),D&&(H.options.scaleStartPercent=h.options.scaleStartPercent,H.options.scaleEndPercent=h.options.scaleEndPercent),H.rerender(H.options,!0))}}}},{key:"handleNewTilesLoaded",value:function(I,A){this.animate()}},{key:"notifyDragChangedListeners",value:function(I){Mr(this.draggingChangedListeners).forEach(A=>{Mr(A).forEach(d=>d(I))})}},{key:"addDraggingChangedListener",value:function(I,A,d){this.draggingChangedListeners.hasOwnProperty(I)||(this.draggingChangedListeners[I]={}),this.draggingChangedListeners[I][A]=d,d(!0),d(!1)}},{key:"removeDraggingChangedListener",value:function(I,A){if(this.draggingChangedListeners.hasOwnProperty(I)){const d=this.draggingChangedListeners[I];d.hasOwnProperty(A)&&(d[A](!1),delete d[A])}}},{key:"addScalesChangedListener",value:function(I,A,d){this.scalesChangedListeners[I]||(this.scalesChangedListeners[I]={}),this.scalesChangedListeners[I][A]=d,!(!this.xScales[I]||!this.yScales[I])&&d(this.xScales[I],this.yScales[I])}},{key:"removeScalesChangedListener",value:function(I,A){if(this.scalesChangedListeners[I]){const d=this.scalesChangedListeners[I];d[A]&&delete d[A]}}},{key:"createSVG",value:function(){const I=document.createElement("svg");I.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),I.setAttribute("xmlns","http://www.w3.org/2000/svg"),I.setAttribute("version","1.1");for(const A of Mr(this.tiledPlots))if(A){for(const d of Mr(A.trackRenderer.trackDefObjects))if(d.trackObject.exportSVG){const h=d.trackObject.exportSVG();h&&I.appendChild(h[0])}}return I.setAttribute("width",this.canvasElement.style.width),I.setAttribute("height",this.canvasElement.style.height),this.postCreateSVGCallback?this.postCreateSVGCallback(I):I}},{key:"createSVGString",value:function(){const I=this.createSVG();let A=wIt.xml(new window.XMLSerializer().serializeToString(I));return A=A.replace(/ - -${A}`}},{key:"handleExportSVG",value:function(){P2("export.svg",new Blob([this.createSVGString()],{type:"image/svg+xml"}))}},{key:"offPostCreateSVG",value:function(){this.postCreateSVGCallback=null}},{key:"onPostCreateSVG",value:function(I){this.postCreateSVGCallback=I}},{key:"createPNGBlobPromise",value:function(){return new Promise(I=>{const A=this.createSVGString(),d=new Image(this.canvasElement.width,this.canvasElement.height);d.src=`data:image/svg+xml;base64,${btoa(A)}`,d.onload=()=>{const h=document.createElement("canvas");h.width=this.canvasElement.width/2,h.height=this.canvasElement.height/2,h.getContext("2d").drawImage(d,0,0),h.toBlob(y=>{I(y)})}})}},{key:"handleExportPNG",value:function(){this.createPNGBlobPromise().then(I=>{P2("export.png",I)})}},{key:"handleScalesChanged",value:function(I,A,d,h=!0){if(this.xScales[I]=A,this.yScales[I]=d,h&&I in this.scalesChangedListeners&&Mr(this.scalesChangedListeners[I]).forEach(y=>{y(A,d)}),this.zoomLocks[I]){const y=this.zoomLocks[I],Z=sC(y),[b,w,S]=Do(this.xScales[I],this.yScales[I]);for(let R=0;R{ie(J,j)})}}if(this.locationLocks[I]){const y=this.locationLocks[I],Z=sC(y),[b,w,S]=Do(this.xScales[I],this.yScales[I]);for(let R=0;R{Ce(ie,te)})}}if(this.locationLocksAxisWise.x[I]){const y=this.locationLocksAxisWise.x[I].lock,Z=sC(y),b=this.locationLocksAxisWise.x[I].axis!=="x",[w,S,R]=Do(this.xScales[I],this.yScales[I]);for(let H=0;H{te(j,ie)})}}if(this.locationLocksAxisWise.y[I]){const y=this.locationLocksAxisWise.y[I].lock,Z=sC(y),b=this.locationLocksAxisWise.y[I].axis!=="y",[w,S,R]=Do(this.xScales[I],this.yScales[I]);for(let H=0;H{te(j,ie)})}}this.animate(),this.triggerViewChangeDb()}},{key:"handleProjectViewport",value:function(I){this.setState({chooseTrackHandler:(A,d)=>this.handleViewportProjected(I,A,d)})}},{key:"handleZoomToData",value:function(I){if(I&&!this.tiledPlots[I])throw new Error(`View uid ${I} does not exist in the current viewConfig`);I?this.tiledPlots[I].handleZoomToData():Object.values(this.tiledPlots).forEach(A=>A.handleZoomToData())}},{key:"resetViewport",value:function(I){if(I&&!this.tiledPlots[I])throw new Error(`View uid ${I} does not exist in the current viewConfig`);I?this.tiledPlots[I].resetViewport():Object.values(this.tiledPlots).forEach(A=>A.resetViewport())}},{key:"handleYankFunction",value:function(I,A){this.setState({chooseViewHandler:d=>A(I,d),mouseOverOverlayUid:I})}},{key:"handleUnlock",value:function(I,A){const d=A[I],h=IC(d);if(h.length===2){delete A[h[0]],delete A[h[1]];return}A[I]&&A[I][I]&&delete A[I][I],A[I]&&delete A[I]}},{key:"viewScalesLockData",value:function(I){return!this.xScales[I]||!this.yScales[I]?(console.warn("View scale lock doesn't correspond to existing uid: ",I),null):Do(this.xScales[I],this.yScales[I])}},{key:"addLock",value:function(I,A,d,h){let y=[],Z=[];d[I]?y=sC(d[I]).filter(S=>h(S[0])).map(S=>[S[0],h(S[0])]):y=[[I,h.bind(this)(I)]],d[A]?Z=sC(d[A]).filter(S=>h.bind(this)(S[0])).map(S=>[S[0],h.bind(this)(S[0])]):Z=[[A,h.bind(this)(A)]];const b=y.concat(Z),w=s0e(b);b.forEach(S=>{d[S[0]]=w})}},{key:"handleLocationLockChosen",value:function(I,A){if(I===A){this.setState({chooseViewHandler:null});return}this.addLock(I,A,this.locationLocks,this.viewScalesLockData.bind(this)),this.setState({chooseViewHandler:null})}},{key:"handleZoomLockChosen",value:function(I,A){if(I===A){this.setState({chooseViewHandler:null});return}this.addLock(I,A,this.zoomLocks,this.viewScalesLockData.bind(this)),this.setState({chooseViewHandler:null})}},{key:"handleViewportProjected",value:function(I,A,d){let h=null;if(I===A)console.warn("A view can not show its own viewport.");else{const y=yl(this.state.views[A].tracks,d),Z=U2(this.state.views[A].tracks,d);h=Fn.nice();const w={uid:h,type:`viewport-projection-${{top:"horizontal",bottom:"horizontal",center:"center",left:"vertical",right:"vertical"}[Z]}`,fromViewUid:I};this.addCallbacks(A,w),this.handleTrackAdded(A,w,Z,y)}return this.setState({chooseTrackHandler:null}),h}},{key:"handleLocationYanked",value:function(I,A){const d=this.xScales[A],h=this.yScales[A],y=this.xScales[I],Z=this.yScales[I],[b,w,S]=Do(y,Z),[R,H,N]=Do(d,h);this.setCenters[I](R,H,S,!0),this.setState({chooseViewHandler:null})}},{key:"handleZoomYanked",value:function(I,A){const d=this.xScales[A],h=this.yScales[A],y=this.xScales[I],Z=this.yScales[I],[b,w,S]=Do(y,Z),[R,H,N]=Do(d,h);this.setCenters[I](b,w,N,!0),this.setState({chooseViewHandler:null})}},{key:"handleTrackPositionChosen",value:function(I,A){this.setState({addTrackPosition:A,addTrackPositionView:I})}},{key:"updateRowHeight",value:function(){if(!this.props.options||this.sizeMode!==uwe||this.props.options.pixelPreciseMarginPadding)return;const I=this.element.parentNode.clientHeight;let A=0;for(const w of Mr(this.state.views))A=Math.max(A,w.layout.y+w.layout.h);this.handleDragStart(),this.handleDragStop();const h=(this.isEditable()?10:0)*A-1,Z=(I-h)/A,b=Math.floor(Z);this.setState({rowHeight:b})}},{key:"handleLayoutChange",value:function(I){this.element&&(I.forEach(A=>{const d=this.state.views[A.i];d&&(d.layout.x=A.x,d.layout.y=A.y,d.layout.w=A.w,d.layout.h=A.h,d.layout.i=A.i)}),this.updateRowHeight(),this.refreshView(F2))}},{key:"clearDragTimeout",value:function(){this.dragTimeout&&(clearTimeout(this.dragTimeout),this.dragTimeout=null)}},{key:"getTrackInfo",value:function(I){if(Pr[I])return Pr[I];if(this.pluginTracks&&this.pluginTracks[I])return this.pluginTracks[I].config;if(window.higlassTracksByType&&window.higlassTracksByType[I])return window.higlassTracksByType[I].config;console.warn("Track type not found:",I,"(check app/scripts/config/ for a list of defined track types)")}},{key:"forceRefreshView",value:function(){this.setState(this.state)}},{key:"refreshView",value:function(I=Jpe){this.clearDragTimeout(),this.notifyDragChangedListeners(!0),this.clearDragTimeout(),this.dragTimeout=setTimeout(()=>{this.notifyDragChangedListeners(!1)},I)}},{key:"handleDragStart",value:function(){this.clearDragTimeout(),this.notifyDragChangedListeners(!0)}},{key:"handleDragStop",value:function(){this.clearDragTimeout(),this.dragTimeout=setTimeout(()=>{this.notifyDragChangedListeners(!1)},F2)}},{key:"resizeHandler",value:function(){oX(this.viewHeaders).filter(I=>I).forEach(I=>I.checkWidth())}},{key:"calculateViewDimensions",value:function(I){let Z=this.viewMarginTop+this.viewMarginBottom+this.viewPaddingTop+this.viewPaddingBottom,b=this.viewMarginLeft+this.viewMarginRight+this.viewPaddingLeft+this.viewPaddingRight,w=0;w+=10;const S=20;if(I.tracks.top)for(let j=0;j0||I.tracks.right&&I.tracks.right.length>0||I.tracks.center&&I.tracks.center.length>0)&&(w+=S);let R=0;if(I.tracks.left)for(let j=0;j0){if(!I.tracks.center[0].contents||I.tracks.center[0].contents.length>0){let j=null,ie=null;if(I.tracks.center[0].contents)for(const te of I.tracks.center[0].contents)j=Math.max(j,te.height?te.height:100),ie=Math.max(ie,te.width?te.width:100);else j=I.tracks.center[0].height?I.tracks.center[0].height:100,ie=I.tracks.center[0].width?I.tracks.center[0].width:100;Z+=j,b+=ie}}else(I.tracks.top&&Mr(I.tracks.top).length>1||I.tracks.bottom&&Mr(I.tracks.bottom).length>1)&&(I.tracks.left&&Mr(I.tracks.left).length||I.tracks.right&&Mr(I.tracks.right).length)&&(M=100,D=100);N>D?Z+=N:Z+=D;let z=0,K=0,P=0,J=0;return"top"in I.tracks&&(z=I.tracks.top.map(j=>j.height?j.height:20).reduce((j,ie)=>j+ie,0)),"bottom"in I.tracks&&(K=I.tracks.bottom.map(j=>j.height?j.height:20).reduce((j,ie)=>j+ie,0)),"left"in I.tracks&&(P=I.tracks.left.map(j=>j.width?j.width:0).reduce((j,ie)=>j+ie,0)),"right"in I.tracks&&(J=I.tracks.right.map(j=>j.width?j.width:0).reduce((j,ie)=>j+ie,0)),{totalWidth:b,totalHeight:Z,topHeight:z,bottomHeight:K,leftWidth:P,rightWidth:J,centerWidth:M,centerHeight:D,minNecessaryHeight:w}}},{key:"calculateZoomLimits",value:function(I,A){const d=[0,1/0],h=I.zoomLimits||[1,null],y=A[1]-A[0];if(h.length!==2)return d;if(h[0]!==null&&h[0]>0){const Z=y/h[0];d[1]=Math.max(Z,1),Z<1&&console.warn(`Invalid zoom limits. Lower limit set to ${y}`)}if(h[1]!==null&&h[1]>h[0]){const Z=y/h[1];d[0]=Math.min(Z,1),Z>1&&console.warn(`Invalid zoom limits. Upper limit set to ${y}`)}return d}},{key:"generateViewLayout",value:function(I){let A=null;return"layout"in I?{layout:A}=I.layout:A={x:0,y:0,w:Awe,h:mVt},A}},{key:"handleClearView",value:function(I){const{views:A}=this.state;A[I].tracks.top=[],A[I].tracks.bottom=[],A[I].tracks.center=[],A[I].tracks.left=[],A[I].tracks.right=[],A[I].tracks.whole=[],this.setState({views:A})}},{key:"handleCloseView",value:function(I){Mr(this.state.views).length!==1&&(this.handleUnlock(I,this.zoomLocks),this.setState(A=>(delete A.views[I],{views:this.removeInvalidTracks(A.views)})))}},{key:"handleSeriesAdded",value:function(I,A,d,h){const{tracks:y}=this.state.views[I];if(h.type==="combined")h.contents.push(A),A.type==="heatmap"&&this.compatibilityfyStackedHeatmaps(A,h);else{const Z={type:"combined",uid:Fn.nice(),height:h.height,width:h.width,contents:[h,A]},b=y[d];for(let w=0;w({views:Z.views}))}},{key:"handleNoTrackAdded",value:function(){this.state.addTrackPosition&&this.setState({addTrackPosition:null})}},{key:"handleTracksAdded",value:function(I,A,d,h){this.storeTrackSizes(I);for(const y of A)this.handleTrackAdded(I,y,d,h)}},{key:"handleChangeTrackType",value:function(I,A,d){const h=this.state.views[I],y=yl(h.tracks,A),Z=y.uid;y.uid=Fn.nice(),y.type=d;const b=y.uid;this.updateTrackLocks(I,Z,b),this.setState(w=>({views:w.views}))}},{key:"handleChangeTrackData",value:function(I,A,d){const h=this.state.views[I],y=yl(h.tracks,A);y.uid=Fn.nice(),y.data=d,this.setState(Z=>({views:Z.views}))}},{key:"handleTrackAdded",value:function(I,A,d,h=null){if(this.addDefaultTrackOptions(A),A.uid||(A.uid=Fn.nice()),A.contents)for(const w of A.contents)this.addDefaultTrackOptions(w);if(this.state.addTrackPosition&&this.setState({addTrackPosition:null}),h)return this.handleSeriesAdded(I,A,d,h),null;A.position=d;const y=this.getTrackInfo(A.type);A.width=y.defaultWidth||y.defaultOptions&&y.defaultOptions.minWidth||this.minVerticalWidth,A.height=y.defaultHeight||y.defaultOptions&&y.defaultOptions.minHeight||this.minHorizontalHeight;const{tracks:Z}=this.state.views[I];let b=0;if(Od(Z,()=>b++),d==="left"||d==="top")Z[d].unshift(A);else if(d==="center")if(Z.center.length===0){const w={uid:Fn.nice(),type:"combined",contents:[A]};Z.center=[w]}else if(Z.center[0].type==="combined")Z.center[0].contents.push(A),A.type==="heatmap"&&this.compatibilityfyStackedHeatmaps(A,Z.center[0]);else{const w={uid:Fn.nice(),type:"combined",contents:[Z.center[0],A]};Z.center=[w],A.type==="heatmap"&&this.compatibilityfyStackedHeatmaps(A,w)}else Z[d]||(Z[d]=[]),Z[d].push(A);return this.adjustLayoutToTrackSizes(this.state.views[I]),Object.keys(this.state.views).length===1&&b===0&&(this.handleZoomToData(I),this.zoomToDataExtentOnInit.add(I)),A}},{key:"compatibilityfyStackedHeatmaps",value:function(I,A){let d;A.contents.some(y=>(d=y,y.type==="heatmap"))&&(I.options.backgroundColor="transparent",I.options.showTooltip=d.options.showTooltip,I.options.showMousePosition=d.options.showMousePosition,I.options.mousePositionColor=d.options.mousePositionColor)}},{key:"storeTrackSizes",value:function(I){Od(this.state.views[I].tracks,A=>{const d=this.tiledPlots[I].trackRenderer.getTrackObject(A.uid);d&&([A.width,A.height]=d.dimensions)})}},{key:"adjustLayoutToTrackSizes",value:function(I){if(!I.layout)return;const A=this.isEditable();let d=0;A&&(d+=pVt);const{totalHeight:h}=this.calculateViewDimensions(I);d+=h;const y=this.isEditable()?10:0;d+=y;const Z=this.state.rowHeight+y;this.sizeMode!==uwe&&(I.layout.h=Math.ceil(d/Z))}},{key:"handleCloseTrack",value:function(I,A){const{tracks:d}=this.state.views[I];this.handleUnlockValueScale(I,A);for(const h in d){const y=d[h],Z=y.filter(b=>b.uid!==A);Z.length===y.length?Z.filter(w=>w.type==="combined").forEach(w=>{w.contents=w.contents.filter(S=>S.uid!==A)}):d[h]=Z}return this.storeTrackSizes(I),this.adjustLayoutToTrackSizes(this.state.views[I]),this.setState(h=>({views:h.views})),this.state.views}},{key:"handleLockValueScale",value:function(I,A){this.setState({chooseTrackHandler:(d,h)=>this.handleValueScaleLocked(I,A,d,h)})}},{key:"combineViewAndTrackUid",value:function(I,A){const d=`${I}.${A}`;if(this.combinedUidToViewTrack[d]={view:I,track:A},this.viewTrackUidsToCombinedUid[I]){if(this.viewTrackUidsToCombinedUid[A])return this.viewTrackUidsToCombinedUid[I][A];this.viewTrackUidsToCombinedUid[I][A]=d}else this.viewTrackUidsToCombinedUid[I]={},this.viewTrackUidsToCombinedUid[I][A]=d;return d}},{key:"updateTrackLocks",value:function(I,A,d){const h=this.combineViewAndTrackUid(I,A),y=this.combineViewAndTrackUid(I,d);if(this.valueScaleLocks[h]){const Z=this.valueScaleLocks[h];this.valueScaleLocks[y]=Z,delete this.valueScaleLocks[h]}for(const Z in this.valueScaleLocks)if(this.valueScaleLocks[Z][h]){const b=this.valueScaleLocks[Z][h];this.valueScaleLocks[Z][y]=b,b.track=d,delete this.valueScaleLocks[Z][h]}}},{key:"handleUnlockValueScale",value:function(I,A){if(this.tiledPlots[I].trackRenderer.getTrackObject(A).createdTracks){const d=IC(this.tiledPlots[I].trackRenderer.getTrackObject(A).createdTracks);for(const h of d)this.handleUnlock(this.combineViewAndTrackUid(I,h),this.valueScaleLocks)}else this.handleUnlock(this.combineViewAndTrackUid(I,A),this.valueScaleLocks)}},{key:"handleValueScaleLocked",value:function(I,A,d,h){if(this.tiledPlots[I].trackRenderer.getTrackObject(A).createdTracks){const b=IC(this.tiledPlots[I].trackRenderer.getTrackObject(A).createdTracks);for(const w of b)this.handleValueScaleLocked(I,w,d,h);return}if(this.tiledPlots[d].trackRenderer.getTrackObject(h).createdTracks){const b=IC(this.tiledPlots[d].trackRenderer.getTrackObject(h).createdTracks);for(const w of b)this.handleValueScaleLocked(I,A,d,w);return}const y=this.combineViewAndTrackUid(I,A),Z=this.combineViewAndTrackUid(d,h);this.addLock(y,Z,this.valueScaleLocks,b=>this.combinedUidToViewTrack[b]),this.syncValueScales(I,A),this.setState({chooseTrackHandler:null})}},{key:"addCallbacks",value:function(I,A){const d=this.getTrackInfo(A.type);if(A.type==="viewport-projection-center"||A.type==="viewport-projection-horizontal"||A.type==="viewport-projection-vertical"||d&&d.projection){const h=A.fromViewUid;A.registerViewportChanged=(y,Z)=>this.addScalesChangedListener(h,y,Z),A.removeViewportChanged=y=>this.removeScalesChangedListener(h,y),A.setDomainsCallback=(y,Z)=>{if(!h){this.projectionXDomains[I]||(this.projectionXDomains[I]={}),this.projectionYDomains[I]||(this.projectionYDomains[I]={}),(A.type==="viewport-projection-horizontal"||A.type==="viewport-projection-center")&&(this.projectionXDomains[I][A.uid]=y),(A.type==="viewport-projection-vertical"||A.type==="viewport-projection-center")&&(this.projectionYDomains[I][A.uid]=Z),this.triggerViewChangeDb();return}const b=Zn().domain(y).range(this.xScales[h].range()),w=Zn().domain(Z).range(this.yScales[h].range()),[S,R,H]=Do(b,w);this.setCenters[h](S,R,H,!1);let N=!1,D=!1;I in this.zoomLocks&&(N=h in this.zoomLocks[I]),N&&this.handleUnlock(I,this.zoomLocks),I in this.locationLocks&&(D=h in this.locationLocks[I]),D&&this.handleUnlock(I,this.locationLocks),this.handleScalesChanged(h,b,w,!0),N&&this.addLock(I,h,this.zoomLocks,this.viewScalesLockData),D&&this.addLock(I,h,this.locationLocks,this.viewScalesLockData)}}}},{key:"validateLocks",value:function(I){const A=[];for(const d of IC(I))(!I[d]||!I[d][d])&&A.push(d);for(const d of A)I[d]&&(console.warn(`View ${d} not present in lock group. Removing...`),this.handleUnlock(d,I),delete I[d])}},{key:"deserializeLocationLocks",value:function(I){if(this.locationLocks={},I.locationLocks)for(const A of IC(I.locationLocks.locksByViewUid))if(typeof I.locationLocks.locksByViewUid[A]!="object")this.locationLocks[A]=I.locationLocks.locksDict[I.locationLocks.locksByViewUid[A]];else{if("x"in I.locationLocks.locksByViewUid[A]){const d=I.locationLocks.locksDict[I.locationLocks.locksByViewUid[A].x.lock];this.locationLocksAxisWise.x[A]={lock:d,axis:I.locationLocks.locksByViewUid[A].x.axis}}if("y"in I.locationLocks.locksByViewUid[A]){const d=I.locationLocks.locksDict[I.locationLocks.locksByViewUid[A].y.lock];this.locationLocksAxisWise.y[A]={lock:d,axis:I.locationLocks.locksByViewUid[A].y.axis}}}this.validateLocks(this.locationLocks)}},{key:"deserializeZoomLocks",value:function(I){if(this.zoomLocks={},I.zoomLocks)for(const A of IC(I.zoomLocks.locksByViewUid))this.zoomLocks[A]=I.zoomLocks.locksDict[I.zoomLocks.locksByViewUid[A]];this.validateLocks(this.zoomLocks)}},{key:"deserializeValueScaleLocks",value:function(I){if(this.valueScaleLocks={},I.valueScaleLocks)for(const A of IC(I.valueScaleLocks.locksByViewUid))this.valueScaleLocks[A]=I.valueScaleLocks.locksDict[I.valueScaleLocks.locksByViewUid[A]]}},{key:"serializeLocks",value:function(I){const A={},d={};for(const h of IC(I)){let y=I[h]&&I[h].uid;y||(y=Fn.nice()),I[h].uid=y,A[y]=I[h],d[h]=I[h].uid}return{locksByViewUid:d,locksDict:A}}},{key:"getViewsAsJson",value:function(){const I=JSON.parse(JSON.stringify(this.state.viewConfig));return I.views=Object.values(this.state.views).map(A=>{const d=JSON.parse(JSON.stringify(A));return Od(d.tracks,h=>{if(h.server){const y=FIt(h.server,{});if(!y.hostname.length){const Z=window.location.host,{protocol:b}=window.location,w=`${b}//${Z}${y.pathname}`;h.server=w}}(h.type==="viewport-projection-center"||h.type==="viewport-projection-horizontal")&&this.projectionXDomains[A.uid]&&this.projectionXDomains[A.uid][h.uid]&&(h.projectionXDomain=this.projectionXDomains[A.uid][h.uid]),(h.type==="viewport-projection-center"||h.type==="viewport-projection-vertical")&&this.projectionYDomains[A.uid]&&this.projectionYDomains[A.uid][h.uid]&&(h.projectionYDomain=this.projectionYDomains[A.uid][h.uid]),delete h.name,delete h.position,delete h.header,delete h.description,delete h.created,delete h.project,delete h.project_name,delete h.serverUidKey,delete h.uuid,delete h.private,delete h.maxZoom,delete h.coordSystem,delete h.coordSystem2,delete h.datatype,delete h.maxWidth,delete h.datafile,delete h.binsPerDimension,delete h.resolutions,delete h.aggregationModes}),d.uid=A.uid,d.initialXDomain=this.xScales[A.uid].domain(),d.initialYDomain=this.yScales[A.uid].domain(),delete d.layout.i,d}),I.zoomLocks=this.serializeLocks(this.zoomLocks),I.locationLocks=this.serializeLocks(this.locationLocks),I.valueScaleLocks=this.serializeLocks(this.valueScaleLocks),I}},{key:"getViewsAsString",value:function(){return JSON.stringify(this.getViewsAsJson(),null,2)}},{key:"handleExportViewAsJSON",value:function(){const I=this.getViewsAsString();P2("viewconf.json",I)}},{key:"handleExportViewsAsLink",value:function(I=this.state.viewConfig.exportViewUrl,A=!1){const d=new URL(I,window.location.origin),h=fetch(I,{method:"POST",headers:{Accept:"application/json, text/plain, */*","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},body:`{"viewconf":${this.getViewsAsString()}}`,credentials:"same-origin"}).then(y=>{if(!y.ok)throw y;return y.json()}).catch(y=>{console.warn("err:",y)}).then(y=>({id:y.uid,url:`${d.origin}/l/?d=${y.uid}`}));return A||h.then(y=>{this.openModal(X.default.createElement(Rj,{onDone:()=>{this.closeModalBound()},url:y.url}))}).catch(y=>console.error("Exporting view config as link failed:",y)),h}},{key:"handleDataDomainChanged",value:function(I,A,d){const{views:h}=this.state;if(h[I].initialXDomain=A,h[I].initialYDomain=d,this.xScales[I]=Zn().domain(A),this.yScales[I]=Zn().domain(d),this.zoomLocks[I]){const y=this.zoomLocks[I],Z=sC(y);for(let b=0;bAwe)return!1;const b=Mr(this.state.views);for(let w=0;wS&&AR)return!1}return!0}},{key:"handleAddView",value:function(I){const A=Mr(this.state.views),d=I,h=[];I.layout.w===12&&(I.layout.w=6);for(let b=0;b{const S=b[1]-w[1];return S===0?b[0]-w[0]:S});const y=JSON.stringify(d),Z=JSON.parse(y);Z.initialXDomain=this.xScales[Z.uid].domain(),Z.initialYDomain=this.yScales[Z.uid].domain(),[[Z.layout.x,Z.layout.y]]=h,Z.uid=Fn.nice(),Z.layout.i=Z.uid,Od(Z.tracks,b=>{this.addCallbacks(Z.uid,b)}),this.setState(b=>{const w=JSON.parse(JSON.stringify(b.views));return w[Z.uid]=Z,{views:w}})}},{key:"handleSelectedAssemblyChanged",value:function(I,A,d,h){const{views:y}=this.state;y[I].genomePositionSearchBox.chromInfoId=A,y[I].genomePositionSearchBox.autocompleteId=d,y[I].genomePositionSearchBox.autocompleteServer=h}},{key:"createGenomePostionSearchBoxEntry",value:function(I,A){let d=I;const h={autocompleteServer:pU,chromInfoServer:pU,visible:!1};return d||(d=JSON.parse(JSON.stringify(h))),d.autocompleteServer||(d.autocompleteServer=h.autocompleteServer),d.chromInfoId||(d.chromInfoId=A),d.chromInfoServer||(d.chromInfoServer=h.chromInfoServer),d.visible||(d.visible=!1),d}},{key:"handleTogglePositionSearchBox",value:function(I){const A=this.state.views[I];A.genomePositionSearchBoxVisible=!A.genomePositionSearchBoxVisible;const d={};Od(A.tracks,Z=>{Z.coordSystem&&(d[Z.coordSystem]||(d[Z.coordSystem]=0),d[Z.coordSystem]+=1)});const h=sC(d).sort((Z,b)=>b[1]-Z[1]);let y="hg19";h.length&&(y=h[0][0]),A.genomePositionSearchBox=this.createGenomePostionSearchBoxEntry(A.genomePositionSearchBox,y),A.genomePositionSearchBox.visible=!A.genomePositionSearchBox.visible,this.refreshView(),this.setState({configMenuUid:null})}},{key:"handleTrackOptionsChanged",value:function(I,A,d){const h=this.state.views[I],y=yl(h.tracks,A);y&&(y.options=Object.assign(y.options,d),this.mounted&&(this.setState(Z=>({views:Z.views})),this.adjustSplitHeatmapTrackOptions(y,d,h.tracks,I)))}},{key:"adjustSplitHeatmapTrackOptions",value:function(I,A,d,h){I.type==="heatmap"&&(A.extent==="upper-right"&&d.center[0].type==="combined"&&d.center[0].contents.length>1&&d.center[0].contents.some(y=>{if(y.type==="heatmap"&&y.uid!==I.uid&&y.options.extent!=="lower-left"){const Z={...y.options,extent:"lower-left",labelPosition:"bottomLeft",colorbarPosition:"bottomLeft"},b={...A,labelPosition:"topRight",colorbarPosition:"topRight"};return this.handleTrackOptionsChanged(h,y.uid,Z),this.handleTrackOptionsChanged(h,I.uid,b),!0}return!1}),A.extent==="lower-left"&&A.extent==="lower-left"&&d.center[0].type==="combined"&&d.center[0].contents.length>1&&d.center[0].contents.some(y=>{if(y.type==="heatmap"&&y.uid!==I.uid&&y.options.extent!=="upper-right"){const Z={...y.options,extent:"upper-right",labelPosition:"topRight",colorbarPosition:"topRight"},b={...A,labelPosition:"bottomLeft",colorbarPosition:"bottomLeft"};return this.handleTrackOptionsChanged(h,y.uid,Z),this.handleTrackOptionsChanged(h,I.uid,b),!0}return!1}))}},{key:"handleViewOptionsChanged",value:function(I,A){const d=this.state.views[I];d&&(d.options=Object.assign(d.options||{},A),this.mounted&&this.setState(h=>({views:h.views})))}},{key:"isTrackValid",value:function(I,A){return!(I.type==="viewport-projection-center"&&!A.has(I.fromViewUid))}},{key:"removeInvalidTracks",value:function(I){const A=new Set(IC(I));for(const d of Mr(I))for(const h of["left","top","center","right","bottom"])d.tracks&&d.tracks.hasOwnProperty(h)&&(d.tracks[h]=d.tracks[h].filter(y=>this.isTrackValid(y,A)),d.tracks[h].forEach(y=>{y.type==="combined"&&(y.contents=y.contents.filter(Z=>this.isTrackValid(Z,A)))}));return I}},{key:"processViewConfig",value:function(I){let{views:A}=I,d={};return(!I.views||I.views.length===0)&&(console.warn("No views provided in viewConfig"),A=[{editable:!0,tracks:{}}]),A.forEach(h=>{h.tracks&&I0e(h.tracks),h.uid||(h.uid=Fn.nice()),d[h.uid]=h,this.zoomToDataExtentOnInit.has(h.uid)&&this.zoomToDataExtentOnInit.delete(h.uid),h.initialXDomain?(h.initialXDomain[0]=+h.initialXDomain[0],h.initialXDomain[1]=+h.initialXDomain[1]):(h.initialXDomain=[0,100],this.zoomToDataExtentOnInit.add(h.uid)),h.initialYDomain?(h.initialXDomain[0]=+h.initialXDomain[0],h.initialXDomain[1]=+h.initialXDomain[1]):h.initialYDomain=[h.initialXDomain[0],h.initialXDomain[1]],this.xScales[h.uid]||(this.xScales[h.uid]=Zn().domain(h.initialXDomain)),this.yScales[h.uid]||(this.yScales[h.uid]=Zn().domain(h.initialYDomain)),Od(h.tracks,y=>{if(y.uid||(y.uid=Fn.nice()),this.addCallbacks(h.uid,y),this.addDefaultTrackOptions(y),y.contents)for(const Z of y.contents)this.addDefaultTrackOptions(Z)}),h.layout?h.layout.i=h.uid:h.layout=this.generateViewLayout(h)}),this.deserializeZoomLocks(I),this.deserializeLocationLocks(I),this.deserializeValueScaleLocks(I),d=this.removeInvalidTracks(d),d}},{key:"handleWindowFocused",value:function(){}},{key:"rangeSelectionHandler",value:function(I){this.rangeSelection=I,this.apiPublish("rangeSelection",I)}},{key:"offViewChange",value:function(I){this.viewChangeListener.splice(I,1)}},{key:"onViewChange",value:function(I){return this.viewChangeListener.push(I)-1}},{key:"triggerViewChange",value:function(){this.viewChangeListener.forEach(I=>I(this.getViewsAsString()))}},{key:"getGenomeLocation",value:function(I){return EU.get(this.state.views[I].chromInfoPath).then(A=>k0e(this.xScales[I],this.yScales[I],A))}},{key:"offLocationChange",value:function(I,A){this.removeScalesChangedListener(I,A)}},{key:"zoomTo",value:function(I,A,d,h,y,Z){if(!(I in this.setCenters))throw Error(`Invalid viewUid. Current uuids: ${Object.keys(this.setCenters).join(",")}`);if(Number.isNaN(+A)||Number.isNaN(+d)){const R=[A,d].join(", ");console.warn([`Invalid coordinates (${R}). All coordinates need to be numbers - and should represent absolute coordinates (not chromosome - coordinates).`].join(" "));return}(Number.isNaN(+h)||Number.isNaN(+y)||h===null||y===null)&&(h=A,y=d);const[b,w,S]=Do(this.xScales[I].copy().domain([A,d]),this.yScales[I].copy().domain([h,y]));this.setCenters[I](b,w,S,!1,Z)}},{key:"zoomToGene",value:function(I,A,d,h){if(!(I in this.setCenters))throw Error(`Invalid viewUid. Current uuids: ${Object.keys(this.setCenters).join(",")}`);if(!this.state.views[I].genomePositionSearchBox||!this.state.views[I].genomePositionSearchBox.autocompleteServer||!this.state.views[I].genomePositionSearchBox.autocompleteId||!this.state.views[I].chromInfoPath){console.warn("Please set chromInfoPath, autocompleteServer, and autocompleteId to use the zoomToGene API");return}this.suggestGene(I,A,y=>{if(y){const Z=y.find(b=>b.geneName.toLowerCase()===A.toLowerCase());if(Z){const{chr:b,txStart:w,txEnd:S}=Z;nu(this.state.views[I].chromInfoPath,R=>{const H=R.chrToAbs([b,w])-d,N=R.chrToAbs([b,S])+d,[D,M,z]=Do(this.xScales[I].copy().domain([H,N]),this.yScales[I].copy().domain([H,N]));this.setCenters[I](D,M,z,!1,h)},this.pubSub)}else console.warn(`Couldn't find the gene symbol: ${A}`)}})}},{key:"suggestGene",value:function(I,A,d){if(!(I in this.setCenters))throw Error(`Invalid viewUid. Current uuids: ${Object.keys(this.setCenters).join(",")}`);if(!this.state.views[I].genomePositionSearchBox||!this.state.views[I].genomePositionSearchBox.autocompleteServer||!this.state.views[I].genomePositionSearchBox.autocompleteId){console.warn("Please set autocompleteServer and autocompleteId to use the suggestGene API");return}const h=this.state.views[I].genomePositionSearchBox.autocompleteServer,y=this.state.views[I].genomePositionSearchBox.autocompleteId,Z=`${h}/suggest/?d=${y}&ac=${A.toLowerCase()}`;Gi.json(Z,OA,this.pubSub).then(b=>{d(b)}).catch(b=>console.error(b))}},{key:"onLocationChange",value:function(I,A,d){const h=Object.keys(this.state.views);if(!h.length)return this.unsetOnLocationChange.push({viewId:I,callback:A,callbackId:d}),null;if(I=typeof I>"u"&&h.length===1?h[0]:I,typeof I>"u"||h.indexOf(I)===-1)return console.error("onLocationChange either missing a viewId or passed an invalid viewId: ",I),null;const y=this.state.views[I],Z=(w,S)=>{A({xDomain:w.domain(),yDomain:S.domain(),xRange:w.range(),yRange:S.range()})};let b=1;return this.scalesChangedListeners[y.uid]&&(b=Object.keys(this.scalesChangedListeners[y.uid]).filter(w=>w.indexOf(Y2)===0).map(w=>parseInt(w.slice(Y2.length+1),10)).reduce((w,S)=>Math.max(w,S),0)+1),this.addScalesChangedListener(y.uid,`${Y2}.${b}`,Z),d&&d(`${Y2}.${b}`),b}},{key:"getTiledPlotAtPosition",value:function(I,A){let d;const h=Mr(this.state.views);for(let y=0;y=S&&I<=H,D=A>=w&&A<=R;if(N&&D){d=Z;break}}return d}},{key:"mouseMoveHandler",value:function(I){if(!this.topDiv||this.state.modal)return;const A=I.clientX,d=I.clientY,h=xr(I,this.topDiv);h[1]+=this.scrollTop;const y=this.getTiledPlotAtPosition(A,d),Z=y?y.listTracksAtPosition(h[0],h[1],!0).map(N=>N.originalTrack||N):[],b=Z.find(N=>!N.isAugmentationTrack),w=b?[h[0]-b.position[0],h[1]-b.position[1]]:h;let S=-1,R=-1;b&&(S=b.flipText?b._xScale.invert(w[1]):b._xScale.invert(w[0]),R=b.is2d?b._yScale.invert(w[1]):S);const H={x:h[0],y:h[1],relTrackX:b&&b.flipText?w[1]:w[0],relTrackY:b&&b.flipText?w[0]:w[1],dataX:S,dataY:R,isFrom2dTrack:!!(b&&b.is2d),isFromVerticalTrack:!!(b&&b.flipText),track:b,origEvt:I,sourceUid:this.uid,hoveredTracks:Z,noHoveredTracks:Z.length===0};if(this.pubSub.publish("app.mouseMove",H),this.isBroadcastMousePositionGlobally){const N={...H};N.origEvt=void 0,N.track=void 0,N.hoveredTracks=void 0,delete N.origEvt,delete N.track,delete N.hoveredTracks,G2.publish("higlass.mouseMove",N)}this.apiPublish("cursorLocation",{absX:A,absY:d,relX:H.x,relY:H.y,relTrackX:H.relTrackX,relTrackY:H.relTrackY,dataX:H.dataX,dataY:H.dataY,isFrom2dTrack:H.isFrom2dTrack,isFromVerticalTrack:H.isFromVerticalTrack}),this.showHoverMenu(H)}},{key:"getMinMaxValue",value:function(I,A,d,h){const y=J2(this.tiledPlots,I,A);if(!y){console.warn(`Track with ID: ${A} not found!`);return}if(!y.minVisibleValueInTiles||!y.maxVisibleValueInTiles){console.warn(`Track ${A} doesn't support the retrieval of min or max values.`);return}return d&&y.getAggregatedVisibleValue?[y.getAggregatedVisibleValue("min"),y.getAggregatedVisibleValue("max")]:[y.minVisibleValueInTiles(h),y.maxVisibleValueInTiles(h)]}},{key:"showHoverMenu",value:function(I){const A=I.track&&I.track.getMouseOverHtml?I.track.getMouseOverHtml(I.relTrackX,I.relTrackY):"";if(I.track!==this.prevMouseHoverTrack&&this.prevMouseHoverTrack&&this.prevMouseHoverTrack.stopHover&&this.prevMouseHoverTrack.stopHover(),this.prevMouseHoverTrack=I.track,this.zooming)return;const d=A&&A.length?[1]:[];let h=Mn("body").selectAll(".track-mouseover-menu").data(d);h.exit().remove(),h.enter().append("div").classed("track-mouseover-menu",!0).classed(aB["track-mouseover-menu"],!0),h=Mn("body").selectAll(".track-mouseover-menu");const y=xr(I.origEvt,Mn("body").node()),Z=[y[0]-window.scrollX,y[1]-window.scrollY];if(h.style("left",`${Z[0]}px`).style("top",`${Z[1]}px`),!h.node())return;const b=h.node().getBoundingClientRect();b.x+b.width>window.innerWidth&&h.style("left",`${Z[0]-b.width}px`),b.y+b.height>window.innerHeight&&h.style("top",`${Z[1]-b.height}px`),h.html(A)}},{key:"hideHoverMenu",value:function(){Mn("body").selectAll(".track-mouseover-menu").remove()}},{key:"closeCustomDialog",value:function(){this.setState(I=>({customDialog:null}))}},{key:"appClickHandler",value:function(I){this.apiPublish("click",I)}},{key:"canvasClickHandler",value:function(I){const A=I.nativeEvent||I,d=A.clientX,h=A.clientY,y=this.getTiledPlotAtPosition(d,h),Z=xr(A,this.topDiv);Z[1]+=this.scrollTop;const b=y?y.listTracksAtPosition(Z[0],Z[1],!0).map(M=>M.originalTrack||M):[],w=b.find(M=>!M.isAugmentationTrack),S=w?[Z[0]-w.position[0],Z[1]-w.position[1]]:Z,R=w&&w.flipText?S[1]:S[0],H=w&&w.flipText?S[0]:S[1];for(const M of this.iterateOverTracks()){const z=J2(this.tiledPlots,M.viewId,M.trackId);z.respondsToPosition(Z[0],Z[1])||z.clickOutside()}const N=[];for(const M of b)if(M.childTracks){for(const z of M.childTracks)N.push({trackUid:z.context.trackUid,viewUid:z.context.viewUid,trackType:z.context.trackType,data:z.click(R,H,I)});N.push({trackUid:M.context.trackUid,viewUid:M.context.viewUid,trackType:M.context.trackType,data:{type:"generic",event:I}})}else N.push({trackUid:M.context.trackUid,viewUid:M.context.viewUid,trackType:M.context.trackType,data:M.click(R,H,I)});const D=[];N.forEach((M,z)=>{const K=J2(this.tiledPlots,M.viewUid,M.trackUid);if(typeof K.clickDialog=="function"){const P=K.clickDialog();P&&D.push(P)}}),D.length>0&&this.setState(M=>({customDialog:D})),this.pubSub.publish("app.click",N)}},{key:"mouseMoveZoomHandler",value:function(I){this.apiPublish("mouseMoveZoom",I)}},{key:"geneSearchHandler",value:function(I){this.apiPublish("geneSearch",I)}},{key:"mouseDownHandler",value:function(I){}},{key:"onScrollHandler",value:function(){this.props.options.sizeMode===TR&&(this.scrollTop=this.scrollContainer.scrollTop,this.pixiStage.y=-this.scrollTop,this.pubSub.publish("app.scroll",this.scrollTop),this.animate())}},{key:"setTrackValueScaleLimits",value:function(I,A,d,h){const y=J2(this.tiledPlots,I,A);if(!y){console.warn(`Could't find track: ${A}`);return}y.setFixedValueScaleMin&&y.setFixedValueScaleMax?(y.setFixedValueScaleMin(d),y.setFixedValueScaleMax(h),y.rerender(y.options,!0),y.animate()):console.warn("Track doesn't support fixed value scales.")}},{key:"setChromInfo",value:function(I,A){nu(I,d=>{this.chromInfo=d,A()},this.pubSub)}},{key:"onMouseLeaveHandler",value:function(){this.pubSub.publish("app.mouseLeave"),this.hideHoverMenu(),this.animate()}},{key:"onBlurHandler",value:function(){this.animate()}},{key:"isZoomFixed",value:function(I){return this.props.zoomFixed||this.props.options.zoomFixed||this.state.viewConfig.zoomFixed||this.props.options.sizeMode===TR||I&&I.zoomFixed}},{key:"trackDimensionsModifiedHandler",value:function(I){const A=this.state.views[I.viewId];if(!A)return;const d=yl(A.tracks,I.trackId);d&&(I.height!==void 0&&(d.height=I.height),I.width!==void 0&&(d.width=I.width),this.adjustLayoutToTrackSizes(A),this.setState(h=>({views:h.views})))}},{key:"wheelHandler",value:function(I){if(this.state.modal||this.props.options.sizeMode===TR)return;const A=I.nativeEvent||I,d=I.target===this.canvasElement;if(!Z0e(A.target,this.topDiv)||this.isZoomFixed())return;const h=A.clientX,y=A.clientY,Z=this.getTiledPlotAtPosition(h,y);if(this.apiStack.wheel&&this.apiStack.wheel.length>0){const b=xr(A,this.topDiv);b[1]+=this.scrollTop;const w=Z?Z.listTracksAtPosition(b[0],b[1],!0).map(N=>N.originalTrack||N):[],S=w.find(N=>!N.isAugmentationTrack),R=S?[b[0]-S.position[0],b[1]-S.position[1]]:b,H={x:b[0],y:b[1],relTrackX:S&&S.flipText?R[1]:R[0],relTrackY:S&&S.flipText?R[0]:R[1],track:S,origEvt:A,sourceUid:this.uid,hoveredTracks:w,noHoveredTracks:w.length===0};this.apiPublish("wheel",H)}if(A.forwarded||d){I.stopPropagation(),I.preventDefault();return}if(I.preventDefault(),Z){const{trackRenderer:b}=Z;A.forwarded=!0,A&&(nX(A,b.eventTracker),A.preventDefault())}}},{key:"render",value:function(){this.tiledAreasDivs={},this.tiledAreas=X.default.createElement("div",{className:aB["tiled-area"]}),this.mounted&&(this.tiledAreas=Mr(this.state.views).map(b=>{const w=b.uid===this.state.addTrackPositionMenuUid?this.state.addTrackPositionMenuPosition:null;let S=null;if(this.state.chooseViewHandler){let D="transparent";this.state.mouseOverOverlayUid===b.uid&&(D="green"),S=X.default.createElement("div",{className:"tiled-plot-overlay",onClick:()=>this.state.chooseViewHandler(b.uid),onMouseEnter:()=>this.handleOverlayMouseEnter(b.uid),onMouseLeave:()=>this.handleOverlayMouseLeave(b.uid),onMouseMove:()=>this.handleOverlayMouseEnter(b.uid),style:{position:"absolute",width:"100%",height:"100%",background:D,opacity:.3,zIndex:1}})}const R=X.default.createElement(v2t,{key:`tp${b.uid}`,ref:D=>{this.tiledPlots[b.uid]=D},addTrackPosition:this.state.addTrackPositionView===b.uid?this.state.addTrackPosition:null,addTrackPositionMenuPosition:w,canvasElement:this.state.canvasElement,chooseTrackHandler:this.state.chooseTrackHandler?D=>this.state.chooseTrackHandler(b.uid,D):null,customDialog:this.state.customDialog,closeCustomDialog:()=>this.closeCustomDialog(),chromInfoPath:b.chromInfoPath,disableTrackMenu:this.isTrackMenuDisabled(),draggingHappening:this.state.draggingHappening!==null,editable:this.isEditable(),getLockGroupExtrema:D=>this.getLockGroupExtrema(b.uid,D),initialXDomain:b.initialXDomain,initialYDomain:b.initialYDomain,isShowGlobalMousePosition:this.isShowGlobalMousePosition,isValueScaleLocked:D=>this.isValueScaleLocked(b.uid,D),marginBottom:this.viewMarginBottom,marginLeft:this.viewMarginLeft,marginRight:this.viewMarginRight,marginTop:this.viewMarginTop,metaTracks:b.metaTracks,mouseTool:this.state.mouseTool,onChangeTrackData:(D,M)=>this.handleChangeTrackData(b.uid,D,M),onChangeTrackType:(D,M)=>this.handleChangeTrackType(b.uid,D,M),onCloseTrack:D=>this.handleCloseTrack(b.uid,D),onDataDomainChanged:(D,M)=>this.handleDataDomainChanged(b.uid,D,M),onLockValueScale:D=>this.handleLockValueScale(b.uid,D),onMouseMoveZoom:this.mouseMoveZoomHandler.bind(this),onNewTilesLoaded:D=>this.handleNewTilesLoaded(b.uid,D),onNoTrackAdded:this.handleNoTrackAdded.bind(this),onRangeSelection:this.rangeSelectionHandler.bind(this),onResizeTrack:this.triggerViewChangeDb,onScalesChanged:(D,M)=>this.handleScalesChanged(b.uid,D,M),onTrackOptionsChanged:(D,M)=>this.handleTrackOptionsChanged(b.uid,D,M),onTrackPositionChosen:this.handleTrackPositionChosen.bind(this),onTracksAdded:(D,M,z)=>this.handleTracksAdded(b.uid,D,M,z),onUnlockValueScale:D=>this.handleUnlockValueScale(b.uid,D),onValueScaleChanged:D=>this.syncValueScales(b.uid,D),overlays:b.overlays,paddingBottom:this.viewPaddingBottom,paddingLeft:this.viewPaddingLeft,paddingRight:this.viewPaddingRight,paddingTop:this.viewPaddingTop,pixiRenderer:this.pixiRenderer,pixiStage:this.pixiStage,pluginDataFetchers:this.pluginDataFetchers,pluginTracks:this.pluginTracks,rangeSelection1dSize:this.state.rangeSelection1dSize,rangeSelectionToInt:this.state.rangeSelectionToInt,registerDraggingChangedListener:D=>this.addDraggingChangedListener(b.uid,b.uid,D),removeDraggingChangedListener:D=>this.removeDraggingChangedListener(b.uid,b.uid,D),setCentersFunction:D=>{this.setCenters[b.uid]=D},svgElement:this.state.svgElement,tracks:b.tracks,trackSourceServers:this.state.viewConfig.trackSourceServers,uid:b.uid,verticalMargin:this.verticalMargin,viewOptions:b.options,xDomainLimits:b.xDomainLimits,yDomainLimits:b.yDomainLimits,zoomable:!this.isZoomFixed(b),zoomLimits:this.calculateZoomLimits(b,b.initialXDomain),zoomToDataExtentOnInit:()=>this.zoomToDataExtentOnInit.has(b.uid)}),H=(D,M)=>b.genomePositionSearchBox?X.default.createElement(K2t,{key:`gpsb${b.uid}`,ref:z=>{this.genomePositionSearchBoxes[b.uid]=z},autocompleteId:b.genomePositionSearchBox.autocompleteId,autocompleteServer:b.genomePositionSearchBox.autocompleteServer,chromInfoId:b.genomePositionSearchBox.chromInfoId,chromInfoPath:b.genomePositionSearchBox.chromInfoPath,chromInfoServer:b.genomePositionSearchBox.chromInfoServer,hideAvailableAssemblies:b.genomePositionSearchBox.hideAvailableAssemblies,isFocused:D,onFocus:M,onGeneSearch:this.geneSearchHandler.bind(this),onSelectedAssemblyChanged:(z,K,P)=>this.handleSelectedAssemblyChanged(b.uid,z,K,P),registerViewportChangedListener:z=>this.addScalesChangedListener(b.uid,b.uid,z),removeViewportChangedListener:()=>this.removeScalesChangedListener(b.uid,b.uid),setCenters:(z,K,P,J)=>this.setCenters[b.uid](z,K,P,!1,J),trackSourceServers:this.state.viewConfig.trackSourceServers,twoD:!!(b.tracks.left.length||b.tracks.right.length||b.tracks.center.length)}):null,N=this.isEditable()&&!this.isViewHeaderDisabled()&&!this.state.viewConfig.hideHeader?X.default.createElement(z2t,{ref:D=>{this.viewHeaders[b.uid]=D},getGenomePositionSearchBox:H,isGenomePositionSearchBoxVisible:b.genomePositionSearchBox&&b.genomePositionSearchBox.visible,mouseTool:this.state.mouseTool,onAddView:()=>this.handleAddView(b),onClearView:()=>this.handleClearView(b.uid),onCloseView:()=>this.handleCloseView(b.uid),onEditViewConfig:this.handleEditViewConfigBound,onExportPNG:this.handleExportPNG.bind(this),onExportSVG:this.handleExportSVG.bind(this),onExportViewsAsJSON:this.handleExportViewAsJSON.bind(this),onExportViewsAsLink:this.handleExportViewsAsLink.bind(this),onLockLocation:D=>this.handleYankFunction(D,this.handleLocationLockChosen.bind(this)),onLockZoom:D=>this.handleYankFunction(D,this.handleZoomLockChosen.bind(this)),onLockZoomAndLocation:D=>this.handleYankFunction(D,(M,z)=>{this.handleZoomLockChosen(M,z),this.handleLocationLockChosen(M,z)}),onProjectViewport:this.handleProjectViewport.bind(this),onTakeAndLockZoomAndLocation:D=>{this.handleYankFunction(D,(M,z)=>{this.handleZoomYanked(M,z),this.handleLocationYanked(M,z),this.handleZoomLockChosen(M,z),this.handleLocationLockChosen(M,z)})},onTogglePositionSearchBox:this.handleTogglePositionSearchBox.bind(this),onTrackPositionChosen:D=>this.handleTrackPositionChosen(b.uid,D),onUnlockLocation:D=>this.handleUnlock(D,this.locationLocks),onUnlockZoom:D=>this.handleUnlock(D,this.zoomLocks),onUnlockZoomAndLocation:D=>{this.handleUnlock(D,this.zoomLocks),this.handleUnlock(D,this.locationLocks)},onViewOptionsChanged:D=>this.handleViewOptionsChanged(b.uid,D),onYankLocation:D=>this.handleYankFunction(D,this.handleLocationYanked.bind(this)),onYankZoom:D=>this.handleYankFunction(D,this.handleZoomYanked.bind(this)),onYankZoomAndLocation:D=>this.handleYankFunction(D,(M,z)=>{this.handleZoomYanked(M,z),this.handleLocationYanked(M,z)}),onZoomToData:D=>this.handleZoomToData(D),viewUid:b.uid}):null;return X.default.createElement("div",{key:b.uid,ref:D=>{this.tiledAreasDivs[b.uid]=D},className:aB["tiled-area"]},N,R,S)}));let I=this.mounted?Object.values(this.state.views).filter(b=>b.layout).map(b=>b.layout):[];I=JSON.parse(JSON.stringify(I));const A=this.isEditable()?zpe:0,d=this.isEditable()?Ope:0,h=+this.props.options.containerPaddingX>=0?+this.props.options.containerPaddingX:A,y=+this.props.options.containerPaddingY>=0?+this.props.options.containerPaddingY:d,Z=X.default.createElement(BIt,{ref:b=>{this.gridLayout=b},cols:12,containerPadding:[h,y],draggableHandle:`.${aC["multitrack-header-grabber"]}`,isDraggable:this.isEditable(),isResizable:this.isEditable(),layout:I,margin:this.isEditable()?[10,10]:[0,0],measureBeforeMount:!1,onBreakpointChange:this.onBreakpointChange.bind(this),onDragStart:this.handleDragStart.bind(this),onDragStop:this.handleDragStop.bind(this),onLayoutChange:this.handleLayoutChange.bind(this),onResize:this.resizeHandler.bind(this),rowHeight:this.state.rowHeight,useCSSTransforms:this.mounted,verticalCompact:this.state.viewConfig.compactLayout,width:this.state.width},this.tiledAreas);return X.default.createElement("div",{key:this.uid,ref:b=>{this.topDiv=b},className:lr("higlass",{"higlass-dark-theme":this.theme===ig,"higlass-container-overflow":this.props.options.sizeMode===dwe||this.props.options.sizeMode===TR}),onMouseLeave:this.onMouseLeaveHandlerBound,onMouseMove:this.mouseMoveHandlerBound},X.default.createElement(zAt,{value:this.pubSub},X.default.createElement(Hbt,{value:this.modal},X.default.createElement(KAt,{value:this.theme},this.state.modal,X.default.createElement("canvas",{key:this.uid,ref:b=>{this.canvasElement=b},onClick:this.canvasClickHandlerBound,className:aB["higlass-canvas"]}),X.default.createElement("div",{ref:b=>{this.scrollContainer=b},className:lr("higlass-scroll-container",{"higlass-scroll-container-overflow":this.props.options.sizeMode===dwe,"higlass-scroll-container-scroll":this.props.options.sizeMode===TR}),onScroll:this.onScrollHandlerBound},X.default.createElement("div",{ref:b=>{this.divDrawingSurface=b},className:lr("higlass-drawing-surface",aB["higlass-drawing-surface"])},Z),X.default.createElement("svg",{ref:b=>{this.svgElement=b},className:aB["higlass-svg"],style:{position:"absolute",width:"100%",height:"100%",left:0,top:0,pointerEvents:"none"}}))))))}}]),s}(X.default.Component);e6.defaultProps={options:{},zoomFixed:!1,compactLayout:!0},e6.propTypes={getApi:_.exports.func,options:_.exports.object,viewConfig:_.exports.oneOfType([_.exports.string,_.exports.object]).isRequired,zoomFixed:_.exports.bool,compactLayout:_.exports.bool};const kD=e6,hwe=(g,[a,s,C,I],A)=>{A.options.colorbarPosition||(A.options.colorbarPosition="hidden"),A.options.labelPosition||(A.options.labelPosition="hidden");const d="arbitary-id",y=CHe(g,{editable:!1,zoomFixed:!1,views:[{uid:d,initialXDomain:[a,s],initialYDomain:[C,I],tracks:{center:[A]},layout:{w:12,h:12,x:0,y:0,moved:!1,static:!1}}]},{sizeMode:"bounded"});return{id:d,hgApi:y}};let fwe=function(g){o(s,g);var a=l(s);function s(C){var I;return T(this,s),I=a.call(this,C),I.id=`id-${Math.random()}`,I}return E(s,[{key:"componentDidMount",value:function(){this.initTrackViewer()}},{key:"shouldComponentUpdate",value:function(I){const{x:A,y:d,width:h,height:y}=I;return this.zoomTo(A,d,h,y),!1}},{key:"initTrackViewer",value:function(){const{trackConfig:I,x:A,y:d,width:h,height:y}=this.props,Z=document.getElementById(this.id),{id:b,hgApi:w}=hwe(Z,[A,A+h,d,d+y],I);this.viewUid=b,this.viewer=w}},{key:"zoomTo",value:function(I,A,d,h){this.viewer.zoomTo(this.viewUid,I,I+d,A,A+h)}},{key:"render",value:function(){return X.default.createElement("div",{id:this.id,style:{height:"100%",width:"100%"}})}}]),s}(X.default.Component);fwe.propTypes={trackConfig:_.exports.object,width:_.exports.number,height:_.exports.number,x:_.exports.number,y:_.exports.number};var t6={},mwe=Object.prototype.toString,pwe=function(a){var s=mwe.call(a),C=s==="[object Arguments]";return C||(C=s!=="[object Array]"&&a!==null&&typeof a=="object"&&typeof a.length=="number"&&a.length>=0&&mwe.call(a.callee)==="[object Function]"),C},i6,bwe;function yVt(){if(bwe)return i6;bwe=1;var g;if(!Object.keys){var a=Object.prototype.hasOwnProperty,s=Object.prototype.toString,C=pwe,I=Object.prototype.propertyIsEnumerable,A=!I.call({toString:null},"toString"),d=I.call(function(){},"prototype"),h=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],y=function(S){var R=S.constructor;return R&&R.prototype===S},Z={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},b=function(){if(typeof window>"u")return!1;for(var S in window)try{if(!Z["$"+S]&&a.call(window,S)&&window[S]!==null&&typeof window[S]=="object")try{y(window[S])}catch{return!0}}catch{return!0}return!1}(),w=function(S){if(typeof window>"u"||!b)return y(S);try{return y(S)}catch{return!1}};g=function(R){var H=R!==null&&typeof R=="object",N=s.call(R)==="[object Function]",D=C(R),M=H&&s.call(R)==="[object String]",z=[];if(!H&&!N&&!D)throw new TypeError("Object.keys called on a non-object");var K=d&&N;if(M&&R.length>0&&!a.call(R,0))for(var P=0;P0)for(var J=0;J"u"?rr:lu(Uint8Array),Bb={"%AggregateError%":typeof AggregateError>"u"?rr:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?rr:ArrayBuffer,"%ArrayIteratorPrototype%":lB?lu([][Symbol.iterator]()):rr,"%AsyncFromSyncIteratorPrototype%":rr,"%AsyncFunction%":CB,"%AsyncGenerator%":CB,"%AsyncGeneratorFunction%":CB,"%AsyncIteratorPrototype%":CB,"%Atomics%":typeof Atomics>"u"?rr:Atomics,"%BigInt%":typeof BigInt>"u"?rr:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?rr:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?rr:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?rr:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?rr:Float32Array,"%Float64Array%":typeof Float64Array>"u"?rr:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?rr:FinalizationRegistry,"%Function%":Swe,"%GeneratorFunction%":CB,"%Int8Array%":typeof Int8Array>"u"?rr:Int8Array,"%Int16Array%":typeof Int16Array>"u"?rr:Int16Array,"%Int32Array%":typeof Int32Array>"u"?rr:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":lB?lu(lu([][Symbol.iterator]())):rr,"%JSON%":typeof JSON=="object"?JSON:rr,"%Map%":typeof Map>"u"?rr:Map,"%MapIteratorPrototype%":typeof Map>"u"||!lB?rr:lu(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?rr:Promise,"%Proxy%":typeof Proxy>"u"?rr:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?rr:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?rr:Set,"%SetIteratorPrototype%":typeof Set>"u"||!lB?rr:lu(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?rr:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":lB?lu(""[Symbol.iterator]()):rr,"%Symbol%":lB?Symbol:rr,"%SyntaxError%":sB,"%ThrowTypeError%":EVt,"%TypedArray%":HVt,"%TypeError%":IB,"%Uint8Array%":typeof Uint8Array>"u"?rr:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?rr:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?rr:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?rr:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?rr:WeakMap,"%WeakRef%":typeof WeakRef>"u"?rr:WeakRef,"%WeakSet%":typeof WeakSet>"u"?rr:WeakSet};try{null.error}catch(g){var WVt=lu(lu(g));Bb["%Error.prototype%"]=WVt}var NVt=function g(a){var s;if(a==="%AsyncFunction%")s=o6("async function () {}");else if(a==="%GeneratorFunction%")s=o6("function* () {}");else if(a==="%AsyncGeneratorFunction%")s=o6("async function* () {}");else if(a==="%AsyncGenerator%"){var C=g("%AsyncGeneratorFunction%");C&&(s=C.prototype)}else if(a==="%AsyncIteratorPrototype%"){var I=g("%AsyncGenerator%");I&&(s=lu(I.prototype))}return Bb[a]=s,s},wwe={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},RR=g6,xD=Os,kVt=RR.call(Function.call,Array.prototype.concat),XVt=RR.call(Function.apply,Array.prototype.splice),Twe=RR.call(Function.call,String.prototype.replace),DD=RR.call(Function.call,String.prototype.slice),xVt=RR.call(Function.call,RegExp.prototype.exec),DVt=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,MVt=/\\(\\)?/g,FVt=function(a){var s=DD(a,0,1),C=DD(a,-1);if(s==="%"&&C!=="%")throw new sB("invalid intrinsic syntax, expected closing `%`");if(C==="%"&&s!=="%")throw new sB("invalid intrinsic syntax, expected opening `%`");var I=[];return Twe(a,DVt,function(A,d,h,y){I[I.length]=h?Twe(y,MVt,"$1"):d||A}),I},YVt=function(a,s){var C=a,I;if(xD(wwe,C)&&(I=wwe[C],C="%"+I[0]+"%"),xD(Bb,C)){var A=Bb[C];if(A===CB&&(A=NVt(C)),typeof A>"u"&&!s)throw new IB("intrinsic "+a+" exists, but is not available. Please file an issue!");return{alias:I,name:C,value:A}}throw new sB("intrinsic "+a+" does not exist!")},Sr=function(a,s){if(typeof a!="string"||a.length===0)throw new IB("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof s!="boolean")throw new IB('"allowMissing" argument must be a boolean');if(xVt(/^%?[^%]*%?$/,a)===null)throw new sB("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var C=FVt(a),I=C.length>0?C[0]:"",A=YVt("%"+I+"%",s),d=A.name,h=A.value,y=!1,Z=A.alias;Z&&(I=Z[0],XVt(C,kVt([0,1],Z)));for(var b=1,w=!0;b=C.length){var N=Zb(h,S);w=!!N,w&&"get"in N&&!("originalValue"in N.get)?h=N.get:h=h[S]}else w=xD(h,S),h=h[S];w&&!y&&(Bb[d]=h)}}return h},KVt=Sr,s6=KVt("%Object.defineProperty%",!0),I6=function(){if(s6)try{return s6({},"a",{value:1}),!0}catch{return!1}return!1};I6.hasArrayLengthDefineBug=function(){if(!I6())return null;try{return s6([],"length",{value:1}).length!==1}catch{return!0}};var Rwe=I6,_Vt=Zwe,PVt=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",zVt=Object.prototype.toString,OVt=Array.prototype.concat,Vwe=Object.defineProperty,LVt=function(g){return typeof g=="function"&&zVt.call(g)==="[object Function]"},JVt=Rwe(),Ewe=Vwe&&JVt,UVt=function(g,a,s,C){a in g&&(!LVt(C)||!C())||(Ewe?Vwe(g,a,{configurable:!0,enumerable:!1,value:s,writable:!0}):g[a]=s)},Hwe=function(g,a){var s=arguments.length>2?arguments[2]:{},C=_Vt(a);PVt&&(C=OVt.call(C,Object.getOwnPropertySymbols(a)));for(var I=0;I-1?Nwe(C):C},jVt=Zwe,kwe=n6(),Xwe=ts,xwe=Object,$Vt=Xwe("Array.prototype.push"),Dwe=Xwe("Object.prototype.propertyIsEnumerable"),qVt=kwe?Object.getOwnPropertySymbols:null,Mwe=function(a,s){if(a==null)throw new TypeError("target must be an object");var C=xwe(a);if(arguments.length===1)return C;for(var I=1;I"u")return"Undefined";if(typeof a=="function"||typeof a=="object")return"Object";if(typeof a=="number")return"Number";if(typeof a=="boolean")return"Boolean";if(typeof a=="string")return"String"}),C6}var c6,zwe;function Ls(){if(zwe)return c6;zwe=1;var g=c9t();return c6=function(s){return typeof s=="symbol"?"Symbol":typeof s=="bigint"?"BigInt":g(s)},c6}var A9t=Ls(),u9t=Math.floor,Owe=function(a){return A9t(a)==="BigInt"?a:u9t(a)},MD=Number.isNaN||function(a){return a!==a},d9t=MD,Lwe=function(g){return(typeof g=="number"||typeof g=="bigint")&&!d9t(g)&&g!==1/0&&g!==-1/0},A6,Jwe;function Uwe(){if(Jwe)return A6;Jwe=1;var g=_we,a=Owe,s=Ls(),C=MD,I=Lwe;return A6=function(d){if(s(d)!=="Number"||C(d)||!I(d))return!1;var h=g(d);return a(h)===h},A6}var u6,Qwe;function h9t(){if(Qwe)return u6;Qwe=1;var g={foo:{}},a=Object;return u6=function(){return{__proto__:g}.foo===g.foo&&!({__proto__:null}instanceof a)},u6}var d6,jwe;function f9t(){if(jwe)return d6;jwe=1;var g=Sr,a=g("%Array.prototype%"),s=g("%RangeError%"),C=g("%SyntaxError%"),I=g("%TypeError%"),A=Uwe(),d=Math.pow(2,32)-1,h=h9t()(),y=g("%Object.setPrototypeOf%",!0)||(h?function(Z,b){return Z.__proto__=b,Z}:null);return d6=function(b){if(!A(b)||b<0)throw new I("Assertion failed: `length` must be an integer Number >= 0");if(b>d)throw new s("length is greater than (2**32 - 1)");var w=arguments.length>1?arguments[1]:a,S=[];if(w!==a){if(!y)throw new C("ArrayCreate: a `proto` argument that is not `Array.prototype` is not supported in an environment that does not support setting the [[Prototype]]");y(S,w)}return b!==0&&(S.length=b),S},d6}const m9t=Ae(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var h6=typeof Map=="function"&&Map.prototype,f6=Object.getOwnPropertyDescriptor&&h6?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,FD=h6&&f6&&typeof f6.get=="function"?f6.get:null,$we=h6&&Map.prototype.forEach,m6=typeof Set=="function"&&Set.prototype,p6=Object.getOwnPropertyDescriptor&&m6?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,YD=m6&&p6&&typeof p6.get=="function"?p6.get:null,qwe=m6&&Set.prototype.forEach,p9t=typeof WeakMap=="function"&&WeakMap.prototype,VR=p9t?WeakMap.prototype.has:null,b9t=typeof WeakSet=="function"&&WeakSet.prototype,ER=b9t?WeakSet.prototype.has:null,y9t=typeof WeakRef=="function"&&WeakRef.prototype,e2e=y9t?WeakRef.prototype.deref:null,v9t=Boolean.prototype.valueOf,Z9t=Object.prototype.toString,B9t=Function.prototype.toString,G9t=String.prototype.match,b6=String.prototype.slice,um=String.prototype.replace,S9t=String.prototype.toUpperCase,t2e=String.prototype.toLowerCase,i2e=RegExp.prototype.test,n2e=Array.prototype.concat,cu=Array.prototype.join,w9t=Array.prototype.slice,r2e=Math.floor,y6=typeof BigInt=="function"?BigInt.prototype.valueOf:null,v6=Object.getOwnPropertySymbols,Z6=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,AB=typeof Symbol=="function"&&typeof Symbol.iterator=="object",is=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===AB||"symbol")?Symbol.toStringTag:null,g2e=Object.prototype.propertyIsEnumerable,o2e=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(g){return g.__proto__}:null);function a2e(g,a){if(g===1/0||g===-1/0||g!==g||g&&g>-1e3&&g<1e3||i2e.call(/e/,a))return a;var s=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof g=="number"){var C=g<0?-r2e(-g):r2e(g);if(C!==g){var I=String(C),A=b6.call(a,I.length+1);return um.call(I,s,"$&_")+"."+um.call(um.call(A,/([0-9]{3})/g,"$&_"),/_$/,"")}}return um.call(a,s,"$&_")}var B6=m9t,s2e=B6.custom,I2e=A2e(s2e)?s2e:null,l2e=function g(a,s,C,I){var A=s||{};if(dm(A,"quoteStyle")&&A.quoteStyle!=="single"&&A.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(dm(A,"maxStringLength")&&(typeof A.maxStringLength=="number"?A.maxStringLength<0&&A.maxStringLength!==1/0:A.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var d=dm(A,"customInspect")?A.customInspect:!0;if(typeof d!="boolean"&&d!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(dm(A,"indent")&&A.indent!==null&&A.indent!==" "&&!(parseInt(A.indent,10)===A.indent&&A.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(dm(A,"numericSeparator")&&typeof A.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var h=A.numericSeparator;if(typeof a>"u")return"undefined";if(a===null)return"null";if(typeof a=="boolean")return a?"true":"false";if(typeof a=="string")return d2e(a,A);if(typeof a=="number"){if(a===0)return 1/0/a>0?"0":"-0";var y=String(a);return h?a2e(a,y):y}if(typeof a=="bigint"){var Z=String(a)+"n";return h?a2e(a,Z):Z}var b=typeof A.depth>"u"?5:A.depth;if(typeof C>"u"&&(C=0),C>=b&&b>0&&typeof a=="object")return G6(a)?"[Array]":"[Object]";var w=z9t(A,C);if(typeof I>"u")I=[];else if(u2e(I,a)>=0)return"[Circular]";function S(ye,Ie,fe){if(Ie&&(I=w9t.call(I),I.push(Ie)),fe){var We={depth:A.depth};return dm(A,"quoteStyle")&&(We.quoteStyle=A.quoteStyle),g(ye,We,C+1,I)}return g(ye,A,C+1,I)}if(typeof a=="function"&&!c2e(a)){var R=X9t(a),H=KD(a,S);return"[Function"+(R?": "+R:" (anonymous)")+"]"+(H.length>0?" { "+cu.call(H,", ")+" }":"")}if(A2e(a)){var N=AB?um.call(String(a),/^(Symbol\(.*\))_[^)]*$/,"$1"):Z6.call(a);return typeof a=="object"&&!AB?HR(N):N}if(K9t(a)){for(var D="<"+t2e.call(String(a.nodeName)),M=a.attributes||[],z=0;z",D}if(G6(a)){if(a.length===0)return"[]";var K=KD(a,S);return w&&!P9t(K)?"["+w6(K,w)+"]":"[ "+cu.call(K,", ")+" ]"}if(V9t(a)){var P=KD(a,S);return!("cause"in Error.prototype)&&"cause"in a&&!g2e.call(a,"cause")?"{ ["+String(a)+"] "+cu.call(n2e.call("[cause]: "+S(a.cause),P),", ")+" }":P.length===0?"["+String(a)+"]":"{ ["+String(a)+"] "+cu.call(P,", ")+" }"}if(typeof a=="object"&&d){if(I2e&&typeof a[I2e]=="function"&&B6)return B6(a,{depth:b-C});if(d!=="symbol"&&typeof a.inspect=="function")return a.inspect()}if(x9t(a)){var J=[];return $we&&$we.call(a,function(ye,Ie){J.push(S(Ie,a,!0)+" => "+S(ye,a))}),h2e("Map",FD.call(a),J,w)}if(F9t(a)){var j=[];return qwe&&qwe.call(a,function(ye){j.push(S(ye,a))}),h2e("Set",YD.call(a),j,w)}if(D9t(a))return S6("WeakMap");if(Y9t(a))return S6("WeakSet");if(M9t(a))return S6("WeakRef");if(H9t(a))return HR(S(Number(a)));if(N9t(a))return HR(S(y6.call(a)));if(W9t(a))return HR(v9t.call(a));if(E9t(a))return HR(S(String(a)));if(!R9t(a)&&!c2e(a)){var ie=KD(a,S),te=o2e?o2e(a)===Object.prototype:a instanceof Object||a.constructor===Object,Ce=a instanceof Object?"":"null prototype",ue=!te&&is&&Object(a)===a&&is in a?b6.call(hm(a),8,-1):Ce?"Object":"",oe=te||typeof a.constructor!="function"?"":a.constructor.name?a.constructor.name+" ":"",he=oe+(ue||Ce?"["+cu.call(n2e.call([],ue||[],Ce||[]),": ")+"] ":"");return ie.length===0?he+"{}":w?he+"{"+w6(ie,w)+"}":he+"{ "+cu.call(ie,", ")+" }"}return String(a)};function C2e(g,a,s){var C=(s.quoteStyle||a)==="double"?'"':"'";return C+g+C}function T9t(g){return um.call(String(g),/"/g,""")}function G6(g){return hm(g)==="[object Array]"&&(!is||!(typeof g=="object"&&is in g))}function R9t(g){return hm(g)==="[object Date]"&&(!is||!(typeof g=="object"&&is in g))}function c2e(g){return hm(g)==="[object RegExp]"&&(!is||!(typeof g=="object"&&is in g))}function V9t(g){return hm(g)==="[object Error]"&&(!is||!(typeof g=="object"&&is in g))}function E9t(g){return hm(g)==="[object String]"&&(!is||!(typeof g=="object"&&is in g))}function H9t(g){return hm(g)==="[object Number]"&&(!is||!(typeof g=="object"&&is in g))}function W9t(g){return hm(g)==="[object Boolean]"&&(!is||!(typeof g=="object"&&is in g))}function A2e(g){if(AB)return g&&typeof g=="object"&&g instanceof Symbol;if(typeof g=="symbol")return!0;if(!g||typeof g!="object"||!Z6)return!1;try{return Z6.call(g),!0}catch{}return!1}function N9t(g){if(!g||typeof g!="object"||!y6)return!1;try{return y6.call(g),!0}catch{}return!1}var k9t=Object.prototype.hasOwnProperty||function(g){return g in this};function dm(g,a){return k9t.call(g,a)}function hm(g){return Z9t.call(g)}function X9t(g){if(g.name)return g.name;var a=G9t.call(B9t.call(g),/^function\s*([\w$]+)/);return a?a[1]:null}function u2e(g,a){if(g.indexOf)return g.indexOf(a);for(var s=0,C=g.length;sa.maxStringLength){var s=g.length-a.maxStringLength,C="... "+s+" more character"+(s>1?"s":"");return d2e(b6.call(g,0,a.maxStringLength),a)+C}var I=um.call(um.call(g,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,_9t);return C2e(I,"single",a)}function _9t(g){var a=g.charCodeAt(0),s={8:"b",9:"t",10:"n",12:"f",13:"r"}[a];return s?"\\"+s:"\\x"+(a<16?"0":"")+S9t.call(a.toString(16))}function HR(g){return"Object("+g+")"}function S6(g){return g+" { ? }"}function h2e(g,a,s,C){var I=C?w6(s,C):cu.call(s,", ");return g+" ("+a+") {"+I+"}"}function P9t(g){for(var a=0;a=0)return!1;return!0}function z9t(g,a){var s;if(g.indent===" ")s=" ";else if(typeof g.indent=="number"&&g.indent>0)s=cu.call(Array(g.indent+1)," ");else return null;return{base:s,prev:cu.call(Array(a+1),s)}}function w6(g,a){if(g.length===0)return"";var s=` -`+a.prev+a.base;return s+cu.call(g,","+s)+` -`+a.prev}function KD(g,a){var s=G6(g),C=[];if(s){C.length=g.length;for(var I=0;I=0&&s["[[EndIndex]]"]>=s["[[StartIndex]]"]&&String(parseInt(s["[[StartIndex]]"],10))===String(s["[[StartIndex]]"])&&String(parseInt(s["[[EndIndex]]"],10))===String(s["[[EndIndex]]"])},N6}var k6,w2e;function X6(){if(w2e)return k6;w2e=1;var g=Sr,a=g("%TypeError%"),s=g("%SyntaxError%"),C=Os,I=$9t(),A={"Property Descriptor":function(h){var y={"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0};for(var Z in h)if(C(h,Z)&&!y[Z])return!1;var b=C(h,"[[Value]]"),w=C(h,"[[Get]]")||C(h,"[[Set]]");if(b&&w)throw new a("Property Descriptors may not be both accessor and data descriptors");return!0},"Match Record":I,"Iterator Record":function(h){return C(h,"[[Iterator]]")&&C(h,"[[NextMethod]]")&&C(h,"[[Done]]")},"PromiseCapability Record":function(h){return h&&C(h,"[[Resolve]]")&&typeof h["[[Resolve]]"]=="function"&&C(h,"[[Reject]]")&&typeof h["[[Reject]]"]=="function"&&C(h,"[[Promise]]")&&h["[[Promise]]"]&&typeof h["[[Promise]]"].then=="function"},"AsyncGeneratorRequest Record":function(h){return h&&C(h,"[[Completion]]")&&C(h,"[[Capability]]")&&A["PromiseCapability Record"](h["[[Capability]]"])}};return k6=function(h,y,Z,b){var w=A[y];if(typeof w!="function")throw new s("unknown record type: "+y);if(h(b)!=="Object"||!w(b))throw new a(Z+" must be a "+y)},k6}var x6,T2e;function q9t(){return T2e||(T2e=1,x6=function(a){if(typeof a>"u")return a;var s={};return"[[Value]]"in a&&(s.value=a["[[Value]]"]),"[[Writable]]"in a&&(s.writable=!!a["[[Writable]]"]),"[[Get]]"in a&&(s.get=a["[[Get]]"]),"[[Set]]"in a&&(s.set=a["[[Set]]"]),"[[Enumerable]]"in a&&(s.enumerable=!!a["[[Enumerable]]"]),"[[Configurable]]"in a&&(s.configurable=!!a["[[Configurable]]"]),s}),x6}var D6,R2e;function V2e(){if(R2e)return D6;R2e=1;var g=X6(),a=q9t(),s=Ls();return D6=function(I){return typeof I<"u"&&g(s,"Property Descriptor","Desc",I),a(I)},D6}var M6,E2e;function eEt(){if(E2e)return M6;E2e=1;var g=Os,a=X6(),s=Ls();return M6=function(I){return!(typeof I>"u"||(a(s,"Property Descriptor","Desc",I),!g(I,"[[Get]]")&&!g(I,"[[Set]]")))},M6}var F6,H2e;function W2e(){if(H2e)return F6;H2e=1;var g=Os,a=X6(),s=Ls();return F6=function(I){return!(typeof I>"u"||(a(s,"Property Descriptor","Desc",I),!g(I,"[[Value]]")&&!g(I,"[[Writable]]")))},F6}var Y6,N2e;function k2e(){if(N2e)return Y6;N2e=1;var g=MD;return Y6=function(s,C){return s===C?s===0?1/s===1/C:!0:g(s)&&g(C)},Y6}var K6=function(a){return!!a},_6={exports:{}},X2e=Function.prototype.toString,dB=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,P6,zD;if(typeof dB=="function"&&typeof Object.defineProperty=="function")try{P6=Object.defineProperty({},"length",{get:function(){throw zD}}),zD={},dB(function(){throw 42},null,P6)}catch(g){g!==zD&&(dB=null)}else dB=null;var tEt=/^\s*class\b/,z6=function(a){try{var s=X2e.call(a);return tEt.test(s)}catch{return!1}},O6=function(a){try{return z6(a)?!1:(X2e.call(a),!0)}catch{return!1}},OD=Object.prototype.toString,iEt="[object Object]",nEt="[object Function]",rEt="[object GeneratorFunction]",gEt="[object HTMLAllCollection]",oEt="[object HTML document.all class]",aEt="[object HTMLCollection]",sEt=typeof Symbol=="function"&&!!Symbol.toStringTag,IEt=!(0 in[,]),L6=function(){return!1};if(typeof document=="object"){var lEt=document.all;OD.call(lEt)===OD.call(document.all)&&(L6=function(a){if((IEt||!a)&&(typeof a>"u"||typeof a=="object"))try{var s=OD.call(a);return(s===gEt||s===oEt||s===aEt||s===iEt)&&a("")==null}catch{}return!1})}var LD=dB?function(a){if(L6(a))return!0;if(!a||typeof a!="function"&&typeof a!="object")return!1;try{dB(a,null,P6)}catch(s){if(s!==zD)return!1}return!z6(a)&&O6(a)}:function(a){if(L6(a))return!0;if(!a||typeof a!="function"&&typeof a!="object")return!1;if(sEt)return O6(a);if(z6(a))return!1;var s=OD.call(a);return s!==nEt&&s!==rEt&&!/^\[object HTML/.test(s)?!1:O6(a)};(function(g){g.exports=LD})(_6);var J6,x2e;function D2e(){if(x2e)return J6;x2e=1;var g=Os,a=Sr,s=a("%TypeError%"),C=Ls(),I=K6,A=_6.exports;return J6=function(h){if(C(h)!=="Object")throw new s("ToPropertyDescriptor requires an object");var y={};if(g(h,"enumerable")&&(y["[[Enumerable]]"]=I(h.enumerable)),g(h,"configurable")&&(y["[[Configurable]]"]=I(h.configurable)),g(h,"value")&&(y["[[Value]]"]=h.value),g(h,"writable")&&(y["[[Writable]]"]=I(h.writable)),g(h,"get")){var Z=h.get;if(typeof Z<"u"&&!A(Z))throw new s("getter must be a function");y["[[Get]]"]=Z}if(g(h,"set")){var b=h.set;if(typeof b<"u"&&!A(b))throw new s("setter must be a function");y["[[Set]]"]=b}if((g(y,"[[Get]]")||g(y,"[[Set]]"))&&(g(y,"[[Value]]")||g(y,"[[Writable]]")))throw new s("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return y},J6}var U6,M2e;function CEt(){if(M2e)return U6;M2e=1;var g=Sr,a=g("%TypeError%"),s=j9t(),C=G2e(),I=V2e(),A=eEt(),d=W2e(),h=uB(),y=k2e(),Z=D2e(),b=Ls();return U6=function(S,R,H){if(b(S)!=="Object")throw new a("Assertion failed: Type(O) is not Object");if(!h(R))throw new a("Assertion failed: IsPropertyKey(P) is not true");var N=s({Type:b,IsDataDescriptor:d,IsAccessorDescriptor:A},H)?H:Z(H);if(!s({Type:b,IsDataDescriptor:d,IsAccessorDescriptor:A},N))throw new a("Assertion failed: Desc is not a valid Property Descriptor");return C(d,y,I,S,R,N)},U6}var F2e;function cEt(){if(F2e)return PD.exports;F2e=1;var g=Q9t(),a=g("%Reflect.construct%",!0),s=CEt();try{s({},"",{"[[Get]]":function(){}})}catch{s=null}if(s&&a){var C={},I={};s(I,"length",{"[[Get]]":function(){throw C},"[[Enumerable]]":!0}),PD.exports=function(d){try{a(d,I)}catch(h){return h===C}}}else PD.exports=function(d){return typeof d=="function"&&!!d.prototype};return PD.exports}var Y2e=Sr,K2e=Y2e("%Symbol.species%",!0),_2e=Y2e("%TypeError%"),P2e=f9t(),z2e=WR,AEt=_D(),uEt=cEt(),dEt=Uwe(),hEt=Ls(),O2e=function(a,s){if(!dEt(s)||s<0)throw new _2e("Assertion failed: length must be an integer >= 0");var C=AEt(a);if(!C)return P2e(s);var I=z2e(a,"constructor");if(K2e&&hEt(I)==="Object"&&(I=z2e(I,K2e),I===null&&(I=void 0)),typeof I>"u")return P2e(s);if(!uEt(I))throw new _2e("C must be a constructor");return new I(s)},L2e=Sr,fEt=L2e("%Math%"),mEt=L2e("%Number%"),J2e=mEt.MAX_SAFE_INTEGER||fEt.pow(2,53)-1,Q6,U2e;function Q2e(){if(U2e)return Q6;U2e=1;var g=Sr,a=ts,s=g("%TypeError%"),C=_D(),I=g("%Reflect.apply%",!0)||a("%Function.prototype.apply%");return Q6=function(d,h){var y=arguments.length>2?arguments[2]:[];if(!C(y))throw new s("Assertion failed: optional `argumentsList`, if provided, must be a List");return I(d,h,y)},Q6}var j6,j2e;function pEt(){if(j2e)return j6;j2e=1;var g=Sr,a=g("%Object.getOwnPropertyDescriptor%",!0);if(a)try{a([],"length")}catch{a=null}return j6=a,j6}var bEt=n6,NR=function(){return bEt()&&!!Symbol.toStringTag},$6=ts,$2e=NR(),q2e,eTe,q6,e8;if($2e){q2e=$6("Object.prototype.hasOwnProperty"),eTe=$6("RegExp.prototype.exec"),q6={};var t8=function(){throw q6};e8={toString:t8,valueOf:t8},typeof Symbol.toPrimitive=="symbol"&&(e8[Symbol.toPrimitive]=t8)}var yEt=$6("Object.prototype.toString"),vEt=Object.getOwnPropertyDescriptor,ZEt="[object RegExp]",i8=$2e?function(a){if(!a||typeof a!="object")return!1;var s=vEt(a,"lastIndex"),C=s&&q2e(s,"value");if(!C)return!1;try{eTe(a,e8)}catch(I){return I===q6}}:function(a){return!a||typeof a!="object"&&typeof a!="function"?!1:yEt(a)===ZEt},n8,tTe;function BEt(){if(tTe)return n8;tTe=1;var g=Sr,a=g("%Symbol.match%",!0),s=i8,C=K6;return n8=function(A){if(!A||typeof A!="object")return!1;if(a){var d=A[a];if(typeof d<"u")return C(d)}return s(A)},n8}var r8,iTe;function GEt(){if(iTe)return r8;iTe=1;var g=Sr,a=pEt(),s=g("%TypeError%"),C=ts,I=C("Object.prototype.propertyIsEnumerable"),A=Os,d=_D(),h=uB(),y=BEt(),Z=D2e(),b=Ls();return r8=function(S,R){if(b(S)!=="Object")throw new s("Assertion failed: O must be an Object");if(!h(R))throw new s("Assertion failed: P must be a Property Key");if(A(S,R)){if(!a){var H=d(S)&&R==="length",N=y(S)&&R==="lastIndex";return{"[[Configurable]]":!(H||N),"[[Enumerable]]":I(S,R),"[[Value]]":S[R],"[[Writable]]":!0}}return Z(a(S,R))}},r8}var g8,nTe;function rTe(){return nTe||(nTe=1,g8=function(a){return a===null||typeof a!="function"&&typeof a!="object"}),g8}var o8,gTe;function SEt(){if(gTe)return o8;gTe=1;var g=Sr,a=g("%Object.preventExtensions%",!0),s=g("%Object.isExtensible%",!0),C=rTe();return o8=a?function(A){return!C(A)&&s(A)}:function(A){return!C(A)},o8}var a8,oTe;function wEt(){if(oTe)return a8;oTe=1;var g=Sr,a=g("%TypeError%"),s=G2e(),C=V2e(),I=GEt(),A=W2e(),d=SEt(),h=uB(),y=k2e(),Z=Ls();return a8=function(w,S,R){if(Z(w)!=="Object")throw new a("Assertion failed: Type(O) is not Object");if(!h(S))throw new a("Assertion failed: IsPropertyKey(P) is not true");var H=I(w,S),N=!H||d(w),D=H&&!H["[[Configurable]]"];return D||!N?!1:s(A,y,C,w,S,{"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Value]]":R,"[[Writable]]":!0})},a8}var s8,aTe;function sTe(){if(aTe)return s8;aTe=1;var g=Sr,a=g("%TypeError%"),s=wEt(),C=uB(),I=Ls();return s8=function(d,h,y){if(I(d)!=="Object")throw new a("Assertion failed: Type(O) is not Object");if(!C(h))throw new a("Assertion failed: IsPropertyKey(P) is not true");var Z=s(d,h,y);if(!Z)throw new a("unable to create data property");return Z},s8}var I8,ITe;function lTe(){if(ITe)return I8;ITe=1;var g=Sr,a=g("%TypeError%"),s=uB(),C=Ls();return I8=function(A,d){if(C(A)!=="Object")throw new a("Assertion failed: `O` must be an Object");if(!s(d))throw new a("Assertion failed: `P` must be a Property Key");return d in A},I8}var l8,CTe;function TEt(){return CTe||(CTe=1,l8=function(a){return a===null||typeof a!="function"&&typeof a!="object"}),l8}var C8,cTe;function REt(){if(cTe)return C8;cTe=1;var g=Date.prototype.getDay,a=function(d){try{return g.call(d),!0}catch{return!1}},s=Object.prototype.toString,C="[object Date]",I=NR();return C8=function(d){return typeof d!="object"||d===null?!1:I?a(d):s.call(d)===C},C8}var JD={exports:{}},ATe;function VEt(){if(ATe)return JD.exports;ATe=1;var g=Object.prototype.toString,a=Gwe();if(a){var s=Symbol.prototype.toString,C=/^Symbol\(.*\)$/,I=function(d){return typeof d.valueOf()!="symbol"?!1:C.test(s.call(d))};JD.exports=function(d){if(typeof d=="symbol")return!0;if(g.call(d)!=="[object Symbol]")return!1;try{return I(d)}catch{return!1}}}else JD.exports=function(d){return!1};return JD.exports}var c8,uTe;function EEt(){if(uTe)return c8;uTe=1;var g=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol",a=TEt(),s=LD,C=REt(),I=VEt(),A=function(y,Z){if(typeof y>"u"||y===null)throw new TypeError("Cannot call method on "+y);if(typeof Z!="string"||Z!=="number"&&Z!=="string")throw new TypeError('hint must be "string" or "number"');var b=Z==="string"?["toString","valueOf"]:["valueOf","toString"],w,S,R;for(R=0;R1&&(arguments[1]===String?Z="string":arguments[1]===Number&&(Z="number"));var b;if(g&&(Symbol.toPrimitive?b=d(y,Symbol.toPrimitive):I(y)&&(b=Symbol.prototype.valueOf)),typeof b<"u"){var w=b.call(y,Z);if(a(w))return w;throw new TypeError("unable to convert exotic object to primitive")}return Z==="default"&&(C(y)||I(y))&&(Z="string"),A(y,Z==="default"?"number":Z)},c8}var A8,dTe;function HEt(){if(dTe)return A8;dTe=1;var g=EEt();return A8=function(s){return arguments.length>1?g(s,arguments[1]):g(s)},A8}var u8,hTe;function WEt(){if(hTe)return u8;hTe=1;var g=ts,a=Sr,s=i8,C=g("RegExp.prototype.exec"),I=a("%TypeError%");return u8=function(d){if(!s(d))throw new I("`regex` must be a RegExp");return function(y){return C(d,y)!==null}},u8}var d8,fTe;function NEt(){if(fTe)return d8;fTe=1;var g=Sr,a=g("%Number%"),s=g("%RegExp%"),C=g("%TypeError%"),I=g("%parseInt%"),A=ts,d=WEt(),h=A("String.prototype.slice"),y=d(/^0b[01]+$/i),Z=d(/^0o[0-7]+$/i),b=d(/^[-+]0x[0-9a-f]+$/i),w=["…","​","￾"].join(""),S=new s("["+w+"]","g"),R=d(S),H=[` -\v\f\r   ᠎    `,"          \u2028","\u2029\uFEFF"].join(""),N=new RegExp("(^["+H+"]+)|(["+H+"]+$)","g"),D=A("String.prototype.replace"),M=function(K){return D(K,N,"")},z=Ls();return d8=function K(P){if(z(P)!=="String")throw new C("Assertion failed: `argument` is not a String");if(y(P))return a(I(h(P,2),2));if(Z(P))return a(I(h(P,2),8));if(R(P)||b(P))return NaN;var J=M(P);return J!==P?K(J):a(P)},d8}var mTe=Sr,pTe=mTe("%TypeError%"),bTe=mTe("%Number%"),kEt=rTe(),XEt=HEt(),xEt=NEt(),DEt=function(a){var s=kEt(a)?a:XEt(a,bTe);if(typeof s=="symbol")throw new pTe("Cannot convert a Symbol value to a number");if(typeof s=="bigint")throw new pTe("Conversion from 'BigInt' to 'number' is not allowed.");return typeof s=="string"?xEt(s):bTe(s)},MEt=function(a){return a>=0?1:-1},FEt=_we,YEt=Owe,KEt=DEt,_Et=MD,PEt=Lwe,zEt=MEt,yTe=function(a){var s=KEt(a);if(_Et(s)||s===0)return 0;if(!PEt(s))return s;var C=YEt(FEt(s));return C===0?0:zEt(s)*C},vTe=J2e,OEt=yTe,ZTe=function(a){var s=OEt(a);return s<=0?0:s>vTe?vTe:s},h8,BTe;function GTe(){if(BTe)return h8;BTe=1;var g=Sr,a=g("%TypeError%"),s=WR,C=ZTe,I=Ls();return h8=function(d){if(I(d)!=="Object")throw new a("Assertion failed: `obj` must be an Object");return C(s(d,"length"))},h8}var STe=Sr,LEt=STe("%String%"),JEt=STe("%TypeError%"),f8=function(a){if(typeof a=="symbol")throw new JEt("Cannot convert a Symbol value to a string");return LEt(a)},UEt=Sr,wTe=UEt("%TypeError%"),QEt=J2e,jEt=Q2e(),$Et=sTe(),qEt=WR,eHt=lTe(),tHt=_D(),iHt=GTe(),TTe=f8,nHt=function g(a,s,C,I,A){var d;arguments.length>5&&(d=arguments[5]);for(var h=I,y=0;y0&&(S=tHt(w)),S){var R=iHt(w);h=g(a,w,R,h,A-1)}else{if(h>=QEt)throw new wTe("index too large");$Et(a,TTe(h),w),h+=1}}y+=1}return h},Gb={exports:{}},rHt=Sr,gHt=rHt("%TypeError%"),oHt=function(a,s){if(a==null)throw new gHt(s||"Cannot call method on "+a);return a};(function(g){g.exports=oHt})(Gb);var aHt=Sr,sHt=aHt("%Object%"),IHt=Gb.exports,RTe=function(a){return IHt(a),sHt(a)},lHt=O2e,CHt=nHt,cHt=WR,AHt=yTe,uHt=ZTe,dHt=RTe,VTe=function(){var a=dHt(this),s=uHt(cHt(a,"length")),C=1;arguments.length>0&&typeof arguments[0]<"u"&&(C=AHt(arguments[0]));var I=lHt(a,0);return CHt(I,a,s,0,C),I},hHt=VTe,ETe=function(){return Array.prototype.flat||hHt},m8,HTe;function fHt(){if(HTe)return m8;HTe=1;var g=Os,a=typeof Symbol=="function"&&typeof Symbol.unscopables=="symbol",s=a&&Array.prototype[Symbol.unscopables],C=TypeError;return m8=function(A){if(typeof A!="string"||!A)throw new C("method must be a non-empty string");if(!g(Array.prototype,A))throw new C("method must be on Array.prototype");a&&(s[A]=!0)},m8}var p8,WTe;function mHt(){if(WTe)return p8;WTe=1;var g=es,a=fHt(),s=ETe;return p8=function(){var I=s();return g(Array.prototype,{flat:I},{flat:function(){return Array.prototype.flat!==I}}),a("flat"),I},p8}var pHt=es,bHt=Cu.exports,yHt=VTe,NTe=ETe,vHt=NTe(),ZHt=mHt(),kTe=bHt(vHt);pHt(kTe,{getPolyfill:NTe,implementation:yHt,shim:ZHt});var kR=kTe,XR={},UD={exports:{}},XTe=function(g){return g!==g},xTe=function(a,s){return a===0&&s===0?1/a===1/s:!!(a===s||XTe(a)&&XTe(s))},BHt=xTe,DTe=function(){return typeof Object.is=="function"?Object.is:BHt},GHt=DTe,SHt=es,wHt=function(){var a=GHt();return SHt(Object,{is:a},{is:function(){return Object.is!==a}}),a},THt=es,RHt=Cu.exports,VHt=xTe,MTe=DTe,EHt=wHt,FTe=RHt(MTe(),Object);THt(FTe,{getPolyfill:MTe,implementation:VHt,shim:EHt});var b8=FTe;(function(g,a){Object.defineProperty(a,"__esModule",{value:!0}),a.default=d;var s=I(b8),C=I(Os);function I(h){return h&&h.__esModule?h:{default:h}}function A(h){return A=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(y){return typeof y}:function(y){return y&&typeof Symbol=="function"&&y.constructor===Symbol&&y!==Symbol.prototype?"symbol":typeof y},A(h)}function d(h,y){if((0,s.default)(h,y))return!0;if(!h||!y||A(h)!=="object"||A(y)!=="object")return!1;var Z=Object.keys(h),b=Object.keys(y);if(Z.length!==b.length)return!1;Z.sort(),b.sort();for(var w=0;w0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"childNodes",{get:function(){return this.children},set:function(s){this.children=s},enumerable:!1,configurable:!0}),a}(v8);zn.NodeWithChildren=qD;var fRe=function(g){fm(a,g);function a(){var s=g!==null&&g.apply(this,arguments)||this;return s.type=HI.ElementType.CDATA,s}return Object.defineProperty(a.prototype,"nodeType",{get:function(){return 4},enumerable:!1,configurable:!0}),a}(qD);zn.CDATA=fRe;var mRe=function(g){fm(a,g);function a(){var s=g!==null&&g.apply(this,arguments)||this;return s.type=HI.ElementType.Root,s}return Object.defineProperty(a.prototype,"nodeType",{get:function(){return 9},enumerable:!1,configurable:!0}),a}(qD);zn.Document=mRe;var pRe=function(g){fm(a,g);function a(s,C,I,A){I===void 0&&(I=[]),A===void 0&&(A=s==="script"?HI.ElementType.Script:s==="style"?HI.ElementType.Style:HI.ElementType.Tag);var d=g.call(this,I)||this;return d.name=s,d.attribs=C,d.type=A,d}return Object.defineProperty(a.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"tagName",{get:function(){return this.name},set:function(s){this.name=s},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"attributes",{get:function(){var s=this;return Object.keys(this.attribs).map(function(C){var I,A;return{name:C,value:s.attribs[C],namespace:(I=s["x-attribsNamespace"])===null||I===void 0?void 0:I[C],prefix:(A=s["x-attribsPrefix"])===null||A===void 0?void 0:A[C]}})},enumerable:!1,configurable:!0}),a}(qD);zn.Element=pRe;function bRe(g){return(0,HI.isTag)(g)}zn.isTag=bRe;function yRe(g){return g.type===HI.ElementType.CDATA}zn.isCDATA=yRe;function vRe(g){return g.type===HI.ElementType.Text}zn.isText=vRe;function ZRe(g){return g.type===HI.ElementType.Comment}zn.isComment=ZRe;function BRe(g){return g.type===HI.ElementType.Directive}zn.isDirective=BRe;function GRe(g){return g.type===HI.ElementType.Root}zn.isDocument=GRe;function ZWt(g){return Object.prototype.hasOwnProperty.call(g,"children")}zn.hasChildren=ZWt;function Z8(g,a){a===void 0&&(a=!1);var s;if(vRe(g))s=new uRe(g.data);else if(ZRe(g))s=new dRe(g.data);else if(bRe(g)){var C=a?B8(g.children):[],I=new pRe(g.name,MR({},g.attribs),C);C.forEach(function(y){return y.parent=I}),g.namespace!=null&&(I.namespace=g.namespace),g["x-attribsNamespace"]&&(I["x-attribsNamespace"]=MR({},g["x-attribsNamespace"])),g["x-attribsPrefix"]&&(I["x-attribsPrefix"]=MR({},g["x-attribsPrefix"])),s=I}else if(yRe(g)){var C=a?B8(g.children):[],A=new fRe(C);C.forEach(function(Z){return Z.parent=A}),s=A}else if(GRe(g)){var C=a?B8(g.children):[],d=new mRe(C);C.forEach(function(Z){return Z.parent=d}),g["x-mode"]&&(d["x-mode"]=g["x-mode"]),s=d}else if(BRe(g)){var h=new hRe(g.name,g.data);g["x-name"]!=null&&(h["x-name"]=g["x-name"],h["x-publicId"]=g["x-publicId"],h["x-systemId"]=g["x-systemId"]),s=h}else throw new Error("Not implemented yet: ".concat(g.type));return s.startIndex=g.startIndex,s.endIndex=g.endIndex,g.sourceCodeLocation!=null&&(s.sourceCodeLocation=g.sourceCodeLocation),s}zn.cloneNode=Z8;function B8(g){for(var a=g.map(function(C){return Z8(C,!0)}),s=1;s䀾mmaĀ;d׷׸䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇܎ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ޷޼߂ߐĀiyޱ޵rc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄΀HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶߻dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣ঳সে্਷ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗ࡜ࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४Ānrࢃ࢏gleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpw৔ਖਛgȀLRlr৞৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼੝੠੷੼અઋ઎p;椅y;䐜Ādl੥੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑ඗ඞcy;䐊cute;䅃ƀaey઴હાron;䅇dil;䅅;䐝ƀgswે૰଎ativeƀMTV૓૟૨ediumSpace;怋hiĀcn૦૘ë૙eryThiî૙tedĀGL૸ଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷ଺reak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪୼஡௫ఄ౞಄ದ೘ൡඅ櫬Āou୛୤ngruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊ஛ement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater΀;EFGLSTஶஷ஽௉௓௘௥扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲௽ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ೒拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨೹setĀ;E೰ೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂ෉෕ෛ෠෧෼ขภยา฿ไlig;䅒cute耻Ó䃓Āiy෎ීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲ෶cr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬื฼de耻Õ䃕es;樷ml耻Ö䃖erĀBP๋๠Āar๐๓r;怾acĀek๚๜;揞et;掴arenthesis;揜Ҁacfhilors๿ງຊຏຒດຝະ໼rtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ໠໤檻cedesȀ;EST່້໏໚扺qual;檯lantEqual;扼ilde;找me;怳Ādp໩໮uct;戏ortionĀ;aȥ໹l;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬؀BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁࿫࿳ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL࿜࿝࿡憒ar;懥eftArrow;懄eiling;按oǵ࿹\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»࿝pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄ቉ቕ቞ቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHc቎ቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗Āeiቻ኉Dzኀ\0ኇefore;戴a;䎘Ācn኎ኘkSpace;쀀  Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0᏿ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0጖y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻፿on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtè૙a;䎖r;愨pf;愤cr;쀀𝒵௡ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚΀;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒΀;Eaeiop዁ᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;e዁ᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;e዁ᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰ᜼ᝃᝈ᝸᝽០៦ᠹᡐᜍ᤽᥈ᥰot;櫭Ācrᛶ᜞kȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e᜚᜛戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;t፜᜷brk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓ᝛ᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯ᝱ᝳ;䎲;愶een;扬r;쀀𝔟g΀costuvwឍឝឳេ៕៛៞ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀako៭ᠦᠵĀcn៲ᠣkƀlst៺֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘᠝斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈؀DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬ᣿ᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教΀;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ᣷᣹᣻᣽;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ᤟;敛;敘;攘;攔΀;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģ᥂bar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;e᜚᜜lƀ;bhᥨᥩᥫ䁜;槅sub;柈Ŭᥴ᥾lĀ;e᥹᥺怢t»᥺pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭍᭒\0᯽\0ᰌƀcpr᦭ᦲ᧝ute;䄇̀;abcdsᦿᧀᧄ᧊᧕᧙戩nd;橄rcup;橉Āau᧏᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r΀;Ecefms᩟᩠ᩢᩫ᪤᪪᪮旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖᪚᪟»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇᫔᫺\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ᫙\0\0᫢aĀ;t᫞᫟䀬;䁀ƀ;fl᫨᫩᫫戁îᅠeĀmx᫱᫶ent»᫩eóɍǧ᫾\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯΀delprvw᭠᭬᭷ᮂᮬᯔ᯹arrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;p᭿ᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰸᰻᰿ᱝᱩᱵᲊᲞᲬᲷ᳻᳿ᴍᵻᶑᶫᶻ᷆᷍rò΁ar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂͸᳖᳜᳠mƀ;oș᳊᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄ὎὚ĀDoḆᴴoôᲉĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»Ṻƀaeiἒ἖Ἒls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙ῜ῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao‌⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧‪‬\0‮耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₟₥₰₴⃰⃵⃺⃿℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕ₝ute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽⃉ƀ;qsؾٌ⃄lanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqr׮ⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0↎proø₞r;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢␧␭␱␵␻ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀஀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼rò৆òΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonó྘quigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d྘➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ᠛旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐௏쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop඄⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roø඄urĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓΀;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨í஘istĀ;s஠டr;쀀𝔫ȀEest௅⩦⩹⩼ƀ;qs஼⩭௡ƀ;qs஼௅⩴lanô௢ií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚΀AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs఻⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs఻⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast୻⭕⭚⭟lleì୻l;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖ΀chimpqu⮽⯍⯙⬄୸⯤⯯Ȁ;cerല⯆ഷ⯉uå൅;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭å೸åഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñ೗Ā;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰⳴ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥ⵲ⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;c᪞ⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācr⵩⵭ir;榿;쀀𝔬ͯ⵹\0\0⵼\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕ⶘ⶥⶨrò᪀Āir⶝ⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔ⷗ǒr;榷rp;榹΀;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ⹞\0⹽\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ⹧⹲຅脀¶;l⹭⹮䂶leìЃɩ⹸\0\0⹻m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳⻴ᤈ⻹⻽⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp໬⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t໻⾴ï໻rel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⿚⋢⿟⿥⿫⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei⿾々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔઀ABHabcdefhilmnoprstux぀けさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤΀cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstw࿜ガクシスゼゾダッデナp;極Ā;f࿠ゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes㄂㄄;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ì࿲âヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘㇤㇮rrowĀ;t࿜ㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowó࿪arpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓rò࿪aòՑ;怏oustĀ;a㈞㈟掱che»㈟mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦΀Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼਴t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì⹯耻­䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;q኱ኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫ਩war;椪lig耻ß䃟௡㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rë๟ƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproø዁im»ኬsðኞĀas㚺㚮ð዁rn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈ΀adempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xô᝷headĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜΀eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roð໻tré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚΀cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜ៟tré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map(function(g){return g.charCodeAt(0)}));var S8={};Object.defineProperty(S8,"__esModule",{value:!0}),S8.default=new Uint16Array("Ȁaglq \x1Bɭ\0\0p;䀦os;䀧t;䀾t;䀼uot;䀢".split("").map(function(g){return g.charCodeAt(0)}));var w8={};(function(g){var a;Object.defineProperty(g,"__esModule",{value:!0}),g.replaceCodePoint=g.fromCodePoint=void 0;var s=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]);g.fromCodePoint=(a=String.fromCodePoint)!==null&&a!==void 0?a:function(A){var d="";return A>65535&&(A-=65536,d+=String.fromCharCode(A>>>10&1023|55296),A=56320|A&1023),d+=String.fromCharCode(A),d};function C(A){var d;return A>=55296&&A<=57343||A>1114111?65533:(d=s.get(A))!==null&&d!==void 0?d:A}g.replaceCodePoint=C;function I(A){return(0,g.fromCodePoint)(C(A))}g.default=I})(w8),function(g){var a=ne&&ne.__importDefault||function(N){return N&&N.__esModule?N:{default:N}};Object.defineProperty(g,"__esModule",{value:!0}),g.decodeXML=g.decodeHTMLStrict=g.decodeHTML=g.determineBranch=g.BinTrieFlags=g.fromCodePoint=g.replaceCodePoint=g.decodeCodePoint=g.xmlDecodeTree=g.htmlDecodeTree=void 0;var s=a(G8);g.htmlDecodeTree=s.default;var C=a(S8);g.xmlDecodeTree=C.default;var I=a(w8);g.decodeCodePoint=I.default;var A=w8;Object.defineProperty(g,"replaceCodePoint",{enumerable:!0,get:function(){return A.replaceCodePoint}}),Object.defineProperty(g,"fromCodePoint",{enumerable:!0,get:function(){return A.fromCodePoint}});var d;(function(N){N[N.NUM=35]="NUM",N[N.SEMI=59]="SEMI",N[N.ZERO=48]="ZERO",N[N.NINE=57]="NINE",N[N.LOWER_A=97]="LOWER_A",N[N.LOWER_F=102]="LOWER_F",N[N.LOWER_X=120]="LOWER_X",N[N.To_LOWER_BIT=32]="To_LOWER_BIT"})(d||(d={}));var h;(function(N){N[N.VALUE_LENGTH=49152]="VALUE_LENGTH",N[N.BRANCH_LENGTH=16256]="BRANCH_LENGTH",N[N.JUMP_TABLE=127]="JUMP_TABLE"})(h=g.BinTrieFlags||(g.BinTrieFlags={}));function y(N){return function(M,z){for(var K="",P=0,J=0;(J=M.indexOf("&",J))>=0;){if(K+=M.slice(P,J),P=J,J+=1,M.charCodeAt(J)===d.NUM){var j=J+1,ie=10,te=M.charCodeAt(j);(te|d.To_LOWER_BIT)===d.LOWER_X&&(ie=16,J+=1,j+=1);do te=M.charCodeAt(++J);while(te>=d.ZERO&&te<=d.NINE||ie===16&&(te|d.To_LOWER_BIT)>=d.LOWER_A&&(te|d.To_LOWER_BIT)<=d.LOWER_F);if(j!==J){var Ce=M.substring(j,J),ue=parseInt(Ce,ie);if(M.charCodeAt(J)===d.SEMI)J+=1;else if(z)continue;K+=(0,I.default)(ue),P=J}continue}for(var oe=0,he=1,ye=0,Ie=N[ye];J>14)-1;if(We===0)break;ye+=We}}if(oe!==0){var We=(N[oe]&h.VALUE_LENGTH)>>14;K+=We===1?String.fromCharCode(N[oe]&~h.VALUE_LENGTH):We===2?String.fromCharCode(N[oe+1]):String.fromCharCode(N[oe+1],N[oe+2]),P=J-he+1}}return K+M.slice(P)}}function Z(N,D,M,z){var K=(D&h.BRANCH_LENGTH)>>7,P=D&h.JUMP_TABLE;if(K===0)return P!==0&&z===P?M:-1;if(P){var J=z-P;return J<0||J>=K?-1:N[M+J]-1}for(var j=M,ie=j+K-1;j<=ie;){var te=j+ie>>>1,Ce=N[te];if(Cez)ie=te-1;else return N[te+K]}return-1}g.determineBranch=Z;var b=y(s.default),w=y(C.default);function S(N){return b(N,!1)}g.decodeHTML=S;function R(N){return b(N,!0)}g.decodeHTMLStrict=R;function H(N){return w(N,!0)}g.decodeXML=H}(Sb);var wb={},T8={};Object.defineProperty(T8,"__esModule",{value:!0});function e5(g){for(var a=1;a$\x80-\uFFFF]/g;var a=new Map([[34,"""],[38,"&"],[39,"'"],[60,"<"],[62,">"]]);g.getCodePoint=String.prototype.codePointAt!=null?function(I,A){return I.codePointAt(A)}:function(I,A){return(I.charCodeAt(A)&64512)===55296?(I.charCodeAt(A)-55296)*1024+I.charCodeAt(A+1)-56320+65536:I.charCodeAt(A)};function s(I){for(var A="",d=0,h;(h=g.xmlReplacer.exec(I))!==null;){var y=h.index,Z=I.charCodeAt(y),b=a.get(Z);b!==void 0?(A+=I.substring(d,y)+b,d=y+1):(A+="".concat(I.substring(d,y),"&#x").concat((0,g.getCodePoint)(I,y).toString(16),";"),d=g.xmlReplacer.lastIndex+=+((Z&64512)===55296))}return A+I.substr(d)}g.encodeXML=s,g.escape=s;function C(I,A){return function(h){for(var y,Z=0,b="";y=I.exec(h);)Z!==y.index&&(b+=h.substring(Z,y.index)),b+=A.get(y[0].charCodeAt(0)),Z=y.index+1;return b+h.substring(Z)}}g.escapeUTF8=C(/[&<>'"]/g,a),g.escapeAttribute=C(/["&\u00A0]/g,new Map([[34,"""],[38,"&"],[160," "]])),g.escapeText=C(/[&<>\u00A0]/g,new Map([[38,"&"],[60,"<"],[62,">"],[160," "]]))})(bB);var BWt=ne&&ne.__importDefault||function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(wb,"__esModule",{value:!0}),wb.encodeNonAsciiHTML=wb.encodeHTML=void 0;var GWt=BWt(T8),wRe=bB,SWt=/[\t\n!-,./:-@[-`\f{-}$\x80-\uFFFF]/g;function wWt(g){return TRe(SWt,g)}wb.encodeHTML=wWt;function TWt(g){return TRe(wRe.xmlReplacer,g)}wb.encodeNonAsciiHTML=TWt;function TRe(g,a){for(var s="",C=0,I;(I=g.exec(a))!==null;){var A=I.index;s+=a.substring(C,A);var d=a.charCodeAt(A),h=GWt.default.get(d);if(typeof h=="object"){if(A+10&&(C+=i5(g.children,a)),(a.xmlMode||!VRe.has(g.name))&&(C+=""))),C}function MWt(g){return"<".concat(g.data,">")}function FWt(g,a){var s,C=g.data||"";return((s=a.encodeEntities)!==null&&s!==void 0?s:a.decodeEntities)!==!1&&!(!a.xmlMode&&g.parent&&HWt.has(g.parent.name))&&(C=a.xmlMode||a.encodeEntities!=="utf8"?(0,t5.encodeXML)(C):(0,t5.escapeText)(C)),C}function YWt(g){return"")}function KWt(g){return"")}var _Wt=ne&&ne.__importDefault||function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(Rl,"__esModule",{value:!0}),Rl.innerText=Rl.textContent=Rl.getText=Rl.getInnerHTML=Rl.getOuterHTML=void 0;var uu=Js,PWt=_Wt(pB),zWt=mB;function ERe(g,a){return(0,PWt.default)(g,a)}Rl.getOuterHTML=ERe;function OWt(g,a){return(0,uu.hasChildren)(g)?g.children.map(function(s){return ERe(s,a)}).join(""):""}Rl.getInnerHTML=OWt;function n5(g){return Array.isArray(g)?g.map(n5).join(""):(0,uu.isTag)(g)?g.name==="br"?` -`:n5(g.children):(0,uu.isCDATA)(g)?n5(g.children):(0,uu.isText)(g)?g.data:""}Rl.getText=n5;function R8(g){return Array.isArray(g)?g.map(R8).join(""):(0,uu.hasChildren)(g)&&!(0,uu.isComment)(g)?R8(g.children):(0,uu.isText)(g)?g.data:""}Rl.textContent=R8;function V8(g){return Array.isArray(g)?g.map(V8).join(""):(0,uu.hasChildren)(g)&&(g.type===zWt.ElementType.Tag||(0,uu.isCDATA)(g))?V8(g.children):(0,uu.isText)(g)?g.data:""}Rl.innerText=V8;var ia={};Object.defineProperty(ia,"__esModule",{value:!0}),ia.prevElementSibling=ia.nextElementSibling=ia.getName=ia.hasAttrib=ia.getAttributeValue=ia.getSiblings=ia.getParent=ia.getChildren=void 0;var E8=Js;function HRe(g){return(0,E8.hasChildren)(g)?g.children:[]}ia.getChildren=HRe;function WRe(g){return g.parent||null}ia.getParent=WRe;function LWt(g){var a,s,C=WRe(g);if(C!=null)return HRe(C);for(var I=[g],A=g.prev,d=g.next;A!=null;)I.unshift(A),a=A,A=a.prev;for(;d!=null;)I.push(d),s=d,d=s.next;return I}ia.getSiblings=LWt;function JWt(g,a){var s;return(s=g.attribs)===null||s===void 0?void 0:s[a]}ia.getAttributeValue=JWt;function UWt(g,a){return g.attribs!=null&&Object.prototype.hasOwnProperty.call(g.attribs,a)&&g.attribs[a]!=null}ia.hasAttrib=UWt;function QWt(g){return g.name}ia.getName=QWt;function jWt(g){for(var a,s=g.next;s!==null&&!(0,E8.isTag)(s);)a=s,s=a.next;return s}ia.nextElementSibling=jWt;function $Wt(g){for(var a,s=g.prev;s!==null&&!(0,E8.isTag)(s);)a=s,s=a.prev;return s}ia.prevElementSibling=$Wt;var WI={};Object.defineProperty(WI,"__esModule",{value:!0}),WI.prepend=WI.prependChild=WI.append=WI.appendChild=WI.replaceElement=WI.removeElement=void 0;function FR(g){if(g.prev&&(g.prev.next=g.next),g.next&&(g.next.prev=g.prev),g.parent){var a=g.parent.children;a.splice(a.lastIndexOf(g),1)}}WI.removeElement=FR;function qWt(g,a){var s=a.prev=g.prev;s&&(s.next=a);var C=a.next=g.next;C&&(C.prev=a);var I=a.parent=g.parent;if(I){var A=I.children;A[A.lastIndexOf(g)]=a,g.parent=null}}WI.replaceElement=qWt;function eNt(g,a){if(FR(a),a.next=null,a.parent=g,g.children.push(a)>1){var s=g.children[g.children.length-2];s.next=a,a.prev=s}else a.prev=null}WI.appendChild=eNt;function tNt(g,a){FR(a);var s=g.parent,C=g.next;if(a.next=C,a.prev=g,g.next=a,a.parent=s,C){if(C.prev=a,s){var I=s.children;I.splice(I.lastIndexOf(C),0,a)}}else s&&s.children.push(a)}WI.append=tNt;function iNt(g,a){if(FR(a),a.parent=g,a.prev=null,g.children.unshift(a)!==1){var s=g.children[1];s.prev=a,a.next=s}else a.next=null}WI.prependChild=iNt;function nNt(g,a){FR(a);var s=g.parent;if(s){var C=s.children;C.splice(C.indexOf(g),0,a)}g.prev&&(g.prev.next=a),a.parent=s,a.prev=g.prev,a.next=g,g.prev=a}WI.prepend=nNt;var Us={};Object.defineProperty(Us,"__esModule",{value:!0}),Us.findAll=Us.existsOne=Us.findOne=Us.findOneChild=Us.find=Us.filter=void 0;var YR=Js;function rNt(g,a,s,C){return s===void 0&&(s=!0),C===void 0&&(C=1/0),Array.isArray(a)||(a=[a]),H8(g,a,s,C)}Us.filter=rNt;function H8(g,a,s,C){for(var I=[],A=0,d=a;A0){var y=H8(g,h.children,s,C);if(I.push.apply(I,y),C-=y.length,C<=0)break}}return I}Us.find=H8;function gNt(g,a){return a.find(g)}Us.findOneChild=gNt;function NRe(g,a,s){s===void 0&&(s=!0);for(var C=null,I=0;I0&&(C=NRe(g,A.children,!0));else continue}return C}Us.findOne=NRe;function kRe(g,a){return a.some(function(s){return(0,YR.isTag)(s)&&(g(s)||s.children.length>0&&kRe(g,s.children))})}Us.existsOne=kRe;function oNt(g,a){for(var s,C=[],I=a.filter(YR.isTag),A;A=I.shift();){var d=(s=A.children)===null||s===void 0?void 0:s.filter(YR.isTag);d&&d.length>0&&I.unshift.apply(I,d),g(A)&&C.push(A)}return C}Us.findAll=oNt;var Vl={};Object.defineProperty(Vl,"__esModule",{value:!0}),Vl.getElementsByTagType=Vl.getElementsByTagName=Vl.getElementById=Vl.getElements=Vl.testElement=void 0;var Tb=Js,r5=Us,g5={tag_name:function(g){return typeof g=="function"?function(a){return(0,Tb.isTag)(a)&&g(a.name)}:g==="*"?Tb.isTag:function(a){return(0,Tb.isTag)(a)&&a.name===g}},tag_type:function(g){return typeof g=="function"?function(a){return g(a.type)}:function(a){return a.type===g}},tag_contains:function(g){return typeof g=="function"?function(a){return(0,Tb.isText)(a)&&g(a.data)}:function(a){return(0,Tb.isText)(a)&&a.data===g}}};function XRe(g,a){return typeof a=="function"?function(s){return(0,Tb.isTag)(s)&&a(s.attribs[g])}:function(s){return(0,Tb.isTag)(s)&&s.attribs[g]===a}}function aNt(g,a){return function(s){return g(s)||a(s)}}function xRe(g){var a=Object.keys(g).map(function(s){var C=g[s];return Object.prototype.hasOwnProperty.call(g5,s)?g5[s](C):XRe(s,C)});return a.length===0?null:a.reduce(aNt)}function sNt(g,a){var s=xRe(g);return s?s(a):!0}Vl.testElement=sNt;function INt(g,a,s,C){C===void 0&&(C=1/0);var I=xRe(g);return I?(0,r5.filter)(I,a,s,C):[]}Vl.getElements=INt;function lNt(g,a,s){return s===void 0&&(s=!0),Array.isArray(a)||(a=[a]),(0,r5.findOne)(XRe("id",g),a,s)}Vl.getElementById=lNt;function CNt(g,a,s,C){return s===void 0&&(s=!0),C===void 0&&(C=1/0),(0,r5.filter)(g5.tag_name(g),a,s,C)}Vl.getElementsByTagName=CNt;function cNt(g,a,s,C){return s===void 0&&(s=!0),C===void 0&&(C=1/0),(0,r5.filter)(g5.tag_type(g),a,s,C)}Vl.getElementsByTagType=cNt;var DRe={};(function(g){Object.defineProperty(g,"__esModule",{value:!0}),g.uniqueSort=g.compareDocumentPosition=g.DocumentPosition=g.removeSubsets=void 0;var a=Js;function s(d){for(var h=d.length;--h>=0;){var y=d[h];if(h>0&&d.lastIndexOf(y,h-1)>=0){d.splice(h,1);continue}for(var Z=y.parent;Z;Z=Z.parent)if(d.includes(Z)){d.splice(h,1);break}}return d}g.removeSubsets=s;var C;(function(d){d[d.DISCONNECTED=1]="DISCONNECTED",d[d.PRECEDING=2]="PRECEDING",d[d.FOLLOWING=4]="FOLLOWING",d[d.CONTAINS=8]="CONTAINS",d[d.CONTAINED_BY=16]="CONTAINED_BY"})(C=g.DocumentPosition||(g.DocumentPosition={}));function I(d,h){var y=[],Z=[];if(d===h)return 0;for(var b=(0,a.hasChildren)(d)?d:d.parent;b;)y.unshift(b),b=b.parent;for(b=(0,a.hasChildren)(h)?h:h.parent;b;)Z.unshift(b),b=b.parent;for(var w=Math.min(y.length,Z.length),S=0;SH.indexOf(D)?R===h?C.FOLLOWING|C.CONTAINED_BY:C.FOLLOWING:R===d?C.PRECEDING|C.CONTAINS:C.PRECEDING}g.compareDocumentPosition=I;function A(d){return d=d.filter(function(h,y,Z){return!Z.includes(h,y+1)}),d.sort(function(h,y){var Z=I(h,y);return Z&C.PRECEDING?-1:Z&C.FOLLOWING?1:0}),d}g.uniqueSort=A})(DRe);var o5={};Object.defineProperty(o5,"__esModule",{value:!0}),o5.getFeed=void 0;var ANt=Rl,KR=Vl;function uNt(g){var a=a5(pNt,g);return a?a.name==="feed"?dNt(a):hNt(a):null}o5.getFeed=uNt;function dNt(g){var a,s=g.children,C={type:"atom",items:(0,KR.getElementsByTagName)("entry",s).map(function(d){var h,y=d.children,Z={media:MRe(y)};NI(Z,"id","id",y),NI(Z,"title","title",y);var b=(h=a5("link",y))===null||h===void 0?void 0:h.attribs.href;b&&(Z.link=b);var w=Rb("summary",y)||Rb("content",y);w&&(Z.description=w);var S=Rb("updated",y);return S&&(Z.pubDate=new Date(S)),Z})};NI(C,"id","id",s),NI(C,"title","title",s);var I=(a=a5("link",s))===null||a===void 0?void 0:a.attribs.href;I&&(C.link=I),NI(C,"description","subtitle",s);var A=Rb("updated",s);return A&&(C.updated=new Date(A)),NI(C,"author","email",s,!0),C}function hNt(g){var a,s,C=(s=(a=a5("channel",g.children))===null||a===void 0?void 0:a.children)!==null&&s!==void 0?s:[],I={type:g.name.substr(0,3),id:"",items:(0,KR.getElementsByTagName)("item",g.children).map(function(d){var h=d.children,y={media:MRe(h)};NI(y,"id","guid",h),NI(y,"title","title",h),NI(y,"link","link",h),NI(y,"description","description",h);var Z=Rb("pubDate",h);return Z&&(y.pubDate=new Date(Z)),y})};NI(I,"title","title",C),NI(I,"link","link",C),NI(I,"description","description",C);var A=Rb("lastBuildDate",C);return A&&(I.updated=new Date(A)),NI(I,"author","managingEditor",C,!0),I}var fNt=["url","type","lang"],mNt=["fileSize","bitrate","framerate","samplingrate","channels","duration","height","width"];function MRe(g){return(0,KR.getElementsByTagName)("media:content",g).map(function(a){for(var s=a.attribs,C={medium:s.medium,isDefault:!!s.isDefault},I=0,A=fNt;Ib.length-3)return!1;var S=b.charCodeAt(w+1);return(S>=y.LowerA&&S<=y.LowerZ||S>=y.UpperA&&S<=y.UpperZ||S===y.Exclamation)&&b.includes(">",w+2)}g.isHtml=Z})(mm),Object.defineProperty(So,"__esModule",{value:!0}),So.toggleClass=So.removeClass=So.addClass=So.hasClass=So.removeAttr=So.val=So.data=So.prop=So.attr=void 0;var KRe=mo,Fr=mm,_Re=Au,ZB=Object.prototype.hasOwnProperty,_R=/\s+/,N8="data-",PRe={null:null,true:!0,false:!1},k8=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,HNt=/^{[^]*}$|^\[[^]*]$/;function I5(g,a,s){var C;if(!(!g||!(0,Fr.isTag)(g))){if((C=g.attribs)!==null&&C!==void 0||(g.attribs={}),!a)return g.attribs;if(ZB.call(g.attribs,a))return!s&&k8.test(a)?a:g.attribs[a];if(g.name==="option"&&a==="value")return(0,KRe.text)(g.children);if(g.name==="input"&&(g.attribs.type==="radio"||g.attribs.type==="checkbox")&&a==="value")return"on"}}function BB(g,a,s){s===null?JRe(g,a):g.attribs[a]="".concat(s)}function WNt(g,a){if(typeof g=="object"||a!==void 0){if(typeof a=="function"){if(typeof g!="string")throw new Error("Bad combination of arguments.");return(0,Fr.domEach)(this,function(s,C){(0,Fr.isTag)(s)&&BB(s,g,a.call(s,C,s.attribs[g]))})}return(0,Fr.domEach)(this,function(s){(0,Fr.isTag)(s)&&(typeof g=="object"?Object.keys(g).forEach(function(C){var I=g[C];BB(s,C,I)}):BB(s,g,a))})}return arguments.length>1?this:I5(this[0],g,this.options.xmlMode)}So.attr=WNt;function zRe(g,a,s){return a in g?g[a]:!s&&k8.test(a)?I5(g,a,!1)!==void 0:I5(g,a,s)}function X8(g,a,s,C){a in g?g[a]=s:BB(g,a,!C&&k8.test(a)?s?"":null:"".concat(s))}function NNt(g,a){var s=this,C;if(typeof g=="string"&&a===void 0){var I=this[0];if(!I||!(0,Fr.isTag)(I))return;switch(g){case"style":{var A=this.css(),d=Object.keys(A);return d.forEach(function(y,Z){A[Z]=y}),A.length=d.length,A}case"tagName":case"nodeName":return I.name.toUpperCase();case"href":case"src":{var h=(C=I.attribs)===null||C===void 0?void 0:C[g];return typeof URL<"u"&&(g==="href"&&(I.tagName==="a"||I.name==="link")||g==="src"&&(I.tagName==="img"||I.tagName==="iframe"||I.tagName==="audio"||I.tagName==="video"||I.tagName==="source"))&&h!==void 0&&this.options.baseURI?new URL(h,this.options.baseURI).href:h}case"innerText":return(0,_Re.innerText)(I);case"textContent":return(0,_Re.textContent)(I);case"outerHTML":return this.clone().wrap("").parent().html();case"innerHTML":return this.html();default:return zRe(I,g,this.options.xmlMode)}}if(typeof g=="object"||a!==void 0){if(typeof a=="function"){if(typeof g=="object")throw new Error("Bad combination of arguments.");return(0,Fr.domEach)(this,function(y,Z){(0,Fr.isTag)(y)&&X8(y,g,a.call(y,Z,zRe(y,g,s.options.xmlMode)),s.options.xmlMode)})}return(0,Fr.domEach)(this,function(y){(0,Fr.isTag)(y)&&(typeof g=="object"?Object.keys(g).forEach(function(Z){var b=g[Z];X8(y,Z,b,s.options.xmlMode)}):X8(y,g,a,s.options.xmlMode))})}}So.prop=NNt;function ORe(g,a,s){var C,I=g;(C=I.data)!==null&&C!==void 0||(I.data={}),typeof a=="object"?Object.assign(I.data,a):typeof a=="string"&&s!==void 0&&(I.data[a]=s)}function LRe(g,a){var s,C,I;a==null?(s=Object.keys(g.attribs).filter(function(y){return y.startsWith(N8)}),C=s.map(function(y){return(0,Fr.camelCase)(y.slice(N8.length))})):(s=[N8+(0,Fr.cssCase)(a)],C=[a]);for(var A=0;A-1;){var I=C+g.length;if((C===0||_R.test(s[C-1]))&&(I===s.length||_R.test(s[I])))return!0}return!1})}So.hasClass=DNt;function URe(g){if(typeof g=="function")return(0,Fr.domEach)(this,function(Z,b){if((0,Fr.isTag)(Z)){var w=Z.attribs.class||"";URe.call([Z],g.call(Z,b,w))}});if(!g||typeof g!="string")return this;for(var a=g.split(_R),s=this.length,C=0;C=0&&(A.splice(y,1),d=!0,h--)}d&&(I.attribs.class=A.join(" "))}})}So.removeClass=QRe;function jRe(g,a){if(typeof g=="function")return(0,Fr.domEach)(this,function(w,S){(0,Fr.isTag)(w)&&jRe.call([w],g.call(w,S,w.attribs.class||"",a),a)});if(!g||typeof g!="string")return this;for(var s=g.split(_R),C=s.length,I=typeof a=="boolean"?a?1:-1:0,A=this.length,d=0;d=0&&b<0?y.push(s[Z]):I<=0&&b>=0&&y.splice(b,1)}h.attribs.class=y.join(" ")}}return this}So.toggleClass=jRe;var Wi={},$Re={},gr;(function(g){g.Attribute="attribute",g.Pseudo="pseudo",g.PseudoElement="pseudo-element",g.Tag="tag",g.Universal="universal",g.Adjacent="adjacent",g.Child="child",g.Descendant="descendant",g.Parent="parent",g.Sibling="sibling",g.ColumnCombinator="column-combinator"})(gr||(gr={}));const MNt={Unknown:null,QuirksMode:"quirks",IgnoreCase:!0,CaseSensitive:!1};var Hg;(function(g){g.Any="any",g.Element="element",g.End="end",g.Equals="equals",g.Exists="exists",g.Hyphen="hyphen",g.Not="not",g.Start="start"})(Hg||(Hg={}));const qRe=/^[^\\#]?(?:\\(?:[\da-f]{1,6}\s?|.)|[\w\-\u00b0-\uFFFF])+/,FNt=/\\([\da-f]{1,6}\s?|(\s)|.)/gi,YNt=new Map([[126,Hg.Element],[94,Hg.Start],[36,Hg.End],[42,Hg.Any],[33,Hg.Not],[124,Hg.Hyphen]]),KNt=new Set(["has","not","matches","is","where","host","host-context"]);function eVe(g){switch(g.type){case gr.Adjacent:case gr.Child:case gr.Descendant:case gr.Parent:case gr.Sibling:case gr.ColumnCombinator:return!0;default:return!1}}const _Nt=new Set(["contains","icontains"]);function PNt(g,a,s){const C=parseInt(a,16)-65536;return C!==C||s?a:C<0?String.fromCharCode(C+65536):String.fromCharCode(C>>10|55296,C&1023|56320)}function PR(g){return g.replace(FNt,PNt)}function x8(g){return g===39||g===34}function tVe(g){return g===32||g===9||g===10||g===12||g===13}function zNt(g){const a=[],s=iVe(a,`${g}`,0);if(s0&&s0&&eVe(C[C.length-1]))throw new Error("Did not expect successive traversals.")}function Z(S){if(C.length>0&&C[C.length-1].type===gr.Descendant){C[C.length-1].type=S;return}y(),C.push({type:S})}function b(S,R){C.push({type:gr.Attribute,name:S,action:R,value:I(1),namespace:null,ignoreCase:"quirks"})}function w(){if(C.length&&C[C.length-1].type===gr.Descendant&&C.pop(),C.length===0)throw new Error("Empty sub-selector");g.push(C)}if(A(0),a.length===s)return s;e:for(;sg.charCodeAt(0))),gVe=new Set(rVe.map(g=>g.charCodeAt(0))),GB=new Set([...rVe,"~","^","$","*","+","!","|",":","[","]"," ","."].map(g=>g.charCodeAt(0)));function oVe(g){return g.map(a=>a.map(LNt).join("")).join(", ")}function LNt(g,a,s){switch(g.type){case gr.Child:return a===0?"> ":" > ";case gr.Parent:return a===0?"< ":" < ";case gr.Sibling:return a===0?"~ ":" ~ ";case gr.Adjacent:return a===0?"+ ":" + ";case gr.Descendant:return" ";case gr.ColumnCombinator:return a===0?"|| ":" || ";case gr.Universal:return g.namespace==="*"&&a+10?C+g.slice(s):g}const zR=Ae(Object.freeze(Object.defineProperty({__proto__:null,isTraversal:eVe,parse:zNt,stringify:oVe,get SelectorType(){return gr},IgnoreCaseMode:MNt,get AttributeAction(){return Hg}},Symbol.toStringTag,{value:"Module"})));var D8={},Eb={trueFunc:function(){return!0},falseFunc:function(){return!1}},pm={},SB={};Object.defineProperty(SB,"__esModule",{value:!0}),SB.isTraversal=void 0;var El=zR,IVe=new Map([[El.SelectorType.Universal,50],[El.SelectorType.Tag,30],[El.SelectorType.Attribute,1],[El.SelectorType.Pseudo,0]]);function UNt(g){return!IVe.has(g.type)}SB.isTraversal=UNt;var QNt=new Map([[El.AttributeAction.Exists,10],[El.AttributeAction.Equals,8],[El.AttributeAction.Not,7],[El.AttributeAction.Start,6],[El.AttributeAction.End,6],[El.AttributeAction.Any,5]]);function jNt(g){for(var a=g.map(lVe),s=1;s=0&&C>=1)):g.type===El.SelectorType.Pseudo&&(g.data?g.name==="has"||g.name==="contains"?C=0:Array.isArray(g.data)?(C=Math.min.apply(Math,g.data.map(function(I){return Math.min.apply(Math,I.map(lVe))})),C<0&&(C=0)):C=2:C=3),C}var C5={},c5={},$Nt=ne&&ne.__importDefault||function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(c5,"__esModule",{value:!0}),c5.attributeRules=void 0;var A5=$Nt(Eb),qNt=/[-[\]{}()*+?.,\\^$|#\s]/g;function CVe(g){return g.replace(qNt,"\\$&")}var ekt=new Set(["accept","accept-charset","align","alink","axis","bgcolor","charset","checked","clear","codetype","color","compact","declare","defer","dir","direction","disabled","enctype","face","frame","hreflang","http-equiv","lang","language","link","media","method","multiple","nohref","noresize","noshade","nowrap","readonly","rel","rev","rules","scope","scrolling","selected","shape","target","text","type","valign","valuetype","vlink"]);function Hb(g,a){return typeof g.ignoreCase=="boolean"?g.ignoreCase:g.ignoreCase==="quirks"?!!a.quirksMode:!a.xmlMode&&ekt.has(g.name)}c5.attributeRules={equals:function(g,a,s){var C=s.adapter,I=a.name,A=a.value;return Hb(a,s)?(A=A.toLowerCase(),function(d){var h=C.getAttributeValue(d,I);return h!=null&&h.length===A.length&&h.toLowerCase()===A&&g(d)}):function(d){return C.getAttributeValue(d,I)===A&&g(d)}},hyphen:function(g,a,s){var C=s.adapter,I=a.name,A=a.value,d=A.length;return Hb(a,s)?(A=A.toLowerCase(),function(y){var Z=C.getAttributeValue(y,I);return Z!=null&&(Z.length===d||Z.charAt(d)==="-")&&Z.substr(0,d).toLowerCase()===A&&g(y)}):function(y){var Z=C.getAttributeValue(y,I);return Z!=null&&(Z.length===d||Z.charAt(d)==="-")&&Z.substr(0,d)===A&&g(y)}},element:function(g,a,s){var C=s.adapter,I=a.name,A=a.value;if(/\s/.test(A))return A5.default.falseFunc;var d=new RegExp("(?:^|\\s)".concat(CVe(A),"(?:$|\\s)"),Hb(a,s)?"i":"");return function(y){var Z=C.getAttributeValue(y,I);return Z!=null&&Z.length>=A.length&&d.test(Z)&&g(y)}},exists:function(g,a,s){var C=a.name,I=s.adapter;return function(A){return I.hasAttrib(A,C)&&g(A)}},start:function(g,a,s){var C=s.adapter,I=a.name,A=a.value,d=A.length;return d===0?A5.default.falseFunc:Hb(a,s)?(A=A.toLowerCase(),function(h){var y=C.getAttributeValue(h,I);return y!=null&&y.length>=d&&y.substr(0,d).toLowerCase()===A&&g(h)}):function(h){var y;return!!(!((y=C.getAttributeValue(h,I))===null||y===void 0)&&y.startsWith(A))&&g(h)}},end:function(g,a,s){var C=s.adapter,I=a.name,A=a.value,d=-A.length;return d===0?A5.default.falseFunc:Hb(a,s)?(A=A.toLowerCase(),function(h){var y;return((y=C.getAttributeValue(h,I))===null||y===void 0?void 0:y.substr(d).toLowerCase())===A&&g(h)}):function(h){var y;return!!(!((y=C.getAttributeValue(h,I))===null||y===void 0)&&y.endsWith(A))&&g(h)}},any:function(g,a,s){var C=s.adapter,I=a.name,A=a.value;if(A==="")return A5.default.falseFunc;if(Hb(a,s)){var d=new RegExp(CVe(A),"i");return function(y){var Z=C.getAttributeValue(y,I);return Z!=null&&Z.length>=A.length&&d.test(Z)&&g(y)}}return function(h){var y;return!!(!((y=C.getAttributeValue(h,I))===null||y===void 0)&&y.includes(A))&&g(h)}},not:function(g,a,s){var C=s.adapter,I=a.name,A=a.value;return A===""?function(d){return!!C.getAttributeValue(d,I)&&g(d)}:Hb(a,s)?(A=A.toLowerCase(),function(d){var h=C.getAttributeValue(d,I);return(h==null||h.length!==A.length||h.toLowerCase()!==A)&&g(d)}):function(d){return C.getAttributeValue(d,I)!==A&&g(d)}}};var M8={},cVe={},AVe={},u5={};Object.defineProperty(u5,"__esModule",{value:!0}),u5.parse=void 0;var tkt=new Set([9,10,12,13,32]),uVe="0".charCodeAt(0),ikt="9".charCodeAt(0);function nkt(g){if(g=g.trim().toLowerCase(),g==="even")return[2,0];if(g==="odd")return[2,1];var a=0,s=0,C=A(),I=d();if(a=uVe&&g.charCodeAt(a)<=ikt;)Z=Z*10+(g.charCodeAt(a)-uVe),a++;return a===y?null:Z}function h(){for(;a=s};var C=Math.abs(a),I=(s%C+C)%C;return a>1?function(A){return A>=s&&A%C===I}:function(A){return A<=s&&A%C===I}}wB.compile=gkt;function okt(g){var a=g[0],s=g[1]-1,C=0;if(a<0){var I=-a,A=(s%I+I)%I;return function(){var d=A+I*C++;return d>s?null:d}}return a===0?s<0?function(){return null}:function(){return C++===0?s:null}:(s<0&&(s+=a*Math.ceil(-s/a)),function(){return a*C+++s})}wB.generate=okt,function(g){Object.defineProperty(g,"__esModule",{value:!0}),g.sequence=g.generate=g.compile=g.parse=void 0;var a=u5;Object.defineProperty(g,"parse",{enumerable:!0,get:function(){return a.parse}});var s=wB;Object.defineProperty(g,"compile",{enumerable:!0,get:function(){return s.compile}}),Object.defineProperty(g,"generate",{enumerable:!0,get:function(){return s.generate}});function C(A){return(0,s.compile)((0,a.parse)(A))}g.default=C;function I(A){return(0,s.generate)((0,a.parse)(A))}g.sequence=I}(AVe),function(g){var a=ne&&ne.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(g,"__esModule",{value:!0}),g.filters=void 0;var s=a(AVe),C=a(Eb);function I(d,h){return function(y){var Z=h.getParent(y);return Z!=null&&h.isTag(Z)&&d(y)}}g.filters={contains:function(d,h,y){var Z=y.adapter;return function(w){return d(w)&&Z.getText(w).includes(h)}},icontains:function(d,h,y){var Z=y.adapter,b=h.toLowerCase();return function(S){return d(S)&&Z.getText(S).toLowerCase().includes(b)}},"nth-child":function(d,h,y){var Z=y.adapter,b=y.equals,w=(0,s.default)(h);return w===C.default.falseFunc?C.default.falseFunc:w===C.default.trueFunc?I(d,Z):function(R){for(var H=Z.getSiblings(R),N=0,D=0;D=0&&!b(R,H[D]);D--)Z.isTag(H[D])&&N++;return w(N)&&d(R)}},"nth-of-type":function(d,h,y){var Z=y.adapter,b=y.equals,w=(0,s.default)(h);return w===C.default.falseFunc?C.default.falseFunc:w===C.default.trueFunc?I(d,Z):function(R){for(var H=Z.getSiblings(R),N=0,D=0;D=0;D--){var M=H[D];if(b(R,M))break;Z.isTag(M)&&Z.getName(M)===Z.getName(R)&&N++}return w(N)&&d(R)}},root:function(d,h,y){var Z=y.adapter;return function(b){var w=Z.getParent(b);return(w==null||!Z.isTag(w))&&d(b)}},scope:function(d,h,y,Z){var b=y.equals;return!Z||Z.length===0?g.filters.root(d,h,y):Z.length===1?function(w){return b(Z[0],w)&&d(w)}:function(w){return Z.includes(w)&&d(w)}},hover:A("isHovered"),visited:A("isVisited"),active:A("isActive")};function A(d){return function(y,Z,b){var w=b.adapter,S=w[d];return typeof S!="function"?C.default.falseFunc:function(H){return S(H)&&y(H)}}}}(cVe);var TB={};Object.defineProperty(TB,"__esModule",{value:!0}),TB.verifyPseudoArgs=TB.pseudos=void 0,TB.pseudos={empty:function(g,a){var s=a.adapter;return!s.getChildren(g).some(function(C){return s.isTag(C)||s.getText(C)!==""})},"first-child":function(g,a){var s=a.adapter,C=a.equals;if(s.prevElementSibling)return s.prevElementSibling(g)==null;var I=s.getSiblings(g).find(function(A){return s.isTag(A)});return I!=null&&C(g,I)},"last-child":function(g,a){for(var s=a.adapter,C=a.equals,I=s.getSiblings(g),A=I.length-1;A>=0;A--){if(C(g,I[A]))return!0;if(s.isTag(I[A]))break}return!1},"first-of-type":function(g,a){for(var s=a.adapter,C=a.equals,I=s.getSiblings(g),A=s.getName(g),d=0;d=0;d--){var h=I[d];if(C(g,h))return!0;if(s.isTag(h)&&s.getName(h)===A)break}return!1},"only-of-type":function(g,a){var s=a.adapter,C=a.equals,I=s.getName(g);return s.getSiblings(g).every(function(A){return C(g,A)||!s.isTag(A)||s.getName(A)!==I})},"only-child":function(g,a){var s=a.adapter,C=a.equals;return s.getSiblings(g).every(function(I){return C(g,I)||!s.isTag(I)})}};function akt(g,a,s,C){if(s===null){if(g.length>C)throw new Error("Pseudo-class :".concat(a," requires an argument"))}else if(g.length===C)throw new Error("Pseudo-class :".concat(a," doesn't have any arguments"))}TB.verifyPseudoArgs=akt;var d5={};Object.defineProperty(d5,"__esModule",{value:!0}),d5.aliases=void 0,d5.aliases={"any-link":":is(a, area, link)[href]",link:":any-link:not(:visited)",disabled:`:is( - :is(button, input, select, textarea, optgroup, option)[disabled], - optgroup[disabled] > option, - fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *) - )`,enabled:":not(:disabled)",checked:":is(:is(input[type=radio], input[type=checkbox])[checked], option:selected)",required:":is(input, select, textarea)[required]",optional:":is(input, select, textarea):not([required])",selected:"option:is([selected], select:not([multiple]):not(:has(> option[selected])) > :first-of-type)",checkbox:"[type=checkbox]",file:"[type=file]",password:"[type=password]",radio:"[type=radio]",reset:"[type=reset]",image:"[type=image]",submit:"[type=submit]",parent:":not(:empty)",header:":is(h1, h2, h3, h4, h5, h6)",button:":is(button, input[type=button])",input:":is(input, textarea, select, button)",text:"input:is(:not([type!='']), [type=text])"};var h5={};(function(g){var a=ne&&ne.__spreadArray||function(Z,b,w){if(w||arguments.length===2)for(var S=0,R=b.length,H;S"u")return function(b){for(var w=b;w=F8(w,A);)if(g(w))return!0;return!1};var y=new WeakSet;return function(b){for(var w=b;w=F8(w,A);)if(!y.has(w)){if(A.isTag(w)&&g(w))return!0;y.add(w)}return!1}}case"_flexibleDescendant":return function(b){var w=b;do if(g(w))return!0;while(w=F8(w,A));return!1};case yc.SelectorType.Parent:return function(b){return A.getChildren(b).some(function(w){return A.isTag(w)&&g(w)})};case yc.SelectorType.Child:return function(b){var w=A.getParent(b);return w!=null&&A.isTag(w)&&g(w)};case yc.SelectorType.Sibling:return function(b){for(var w=A.getSiblings(b),S=0;S0&&(0,Y8.isTraversal)(h[0])&&h[0].type!==Ih.SelectorType.Descendant))if(I&&!h.some(mVe))h.unshift(fkt);else continue;h.unshift(pkt)}}function K8(g,a,s){var C;g.forEach(Y8.default),s=(C=a.context)!==null&&C!==void 0?C:s;var I=Array.isArray(s),A=s&&(Array.isArray(s)?s:[s]);if(a.relativeSelector!==!1)bkt(g,a,A);else if(g.some(function(y){return y.length>0&&(0,Y8.isTraversal)(y[0])}))throw new Error("Relative selectors are not allowed when the `relativeSelector` option is disabled");var d=!1,h=g.map(function(y){if(y.length>=2){var Z=y[0],b=y[1];Z.type!==Ih.SelectorType.Pseudo||Z.name!=="scope"||(I&&b.type===Ih.SelectorType.Descendant?y[1]=mkt:(b.type===Ih.SelectorType.Adjacent||b.type===Ih.SelectorType.Sibling)&&(d=!0))}return ykt(y,a,A)}).reduce(vkt,bm.default.falseFunc);return h.shouldTestNextSiblings=d,h}pm.compileToken=K8;function ykt(g,a,s){var C;return g.reduce(function(I,A){return I===bm.default.falseFunc?bm.default.falseFunc:(0,dkt.compileGeneralSelector)(I,A,a,s,K8)},(C=a.rootFunc)!==null&&C!==void 0?C:bm.default.trueFunc)}function vkt(g,a){return a===bm.default.falseFunc||g===bm.default.trueFunc?g:g===bm.default.falseFunc||a===bm.default.trueFunc?a:function(C){return g(C)||a(C)}}(function(g){var a=ne&&ne.__createBinding||(Object.create?function(z,K,P,J){J===void 0&&(J=P);var j=Object.getOwnPropertyDescriptor(K,P);(!j||("get"in j?!K.__esModule:j.writable||j.configurable))&&(j={enumerable:!0,get:function(){return K[P]}}),Object.defineProperty(z,J,j)}:function(z,K,P,J){J===void 0&&(J=P),z[J]=K[P]}),s=ne&&ne.__setModuleDefault||(Object.create?function(z,K){Object.defineProperty(z,"default",{enumerable:!0,value:K})}:function(z,K){z.default=K}),C=ne&&ne.__importStar||function(z){if(z&&z.__esModule)return z;var K={};if(z!=null)for(var P in z)P!=="default"&&Object.prototype.hasOwnProperty.call(z,P)&&a(K,z,P);return s(K,z),K},I=ne&&ne.__importDefault||function(z){return z&&z.__esModule?z:{default:z}};Object.defineProperty(g,"__esModule",{value:!0}),g.aliases=g.pseudos=g.filters=g.is=g.selectOne=g.selectAll=g.prepareContext=g._compileToken=g._compileUnsafe=g.compile=void 0;var A=C(Au),d=I(Eb),h=pm,y=h5,Z=function(z,K){return z===K},b={adapter:A,equals:Z};function w(z){var K,P,J,j,ie=z??b;return(K=ie.adapter)!==null&&K!==void 0||(ie.adapter=A),(P=ie.equals)!==null&&P!==void 0||(ie.equals=(j=(J=ie.adapter)===null||J===void 0?void 0:J.equals)!==null&&j!==void 0?j:Z),ie}function S(z){return function(P,J,j){var ie=w(J);return z(P,ie,j)}}g.compile=S(h.compile),g._compileUnsafe=S(h.compileUnsafe),g._compileToken=S(h.compileToken);function R(z){return function(P,J,j){var ie=w(j);typeof P!="function"&&(P=(0,h.compileUnsafe)(P,ie,J));var te=H(J,ie.adapter,P.shouldTestNextSiblings);return z(P,te,ie)}}function H(z,K,P){return P===void 0&&(P=!1),P&&(z=N(z,K)),Array.isArray(z)?K.removeSubsets(z):K.getChildren(z)}g.prepareContext=H;function N(z,K){for(var P=Array.isArray(z)?z.slice(0):[z],J=P.length,j=0;j=0?d+1:1/0:0;case"lt":return isFinite(d)?d>=0?Math.min(d,A):1/0:0;case"gt":return isFinite(d)?1/0:0;case"odd":return 2*A;case"even":return 2*A-1;case"last":case"not":return 1/0}}g.getLimit=s})(_8),Object.defineProperty(RB,"__esModule",{value:!0}),RB.groupSelectors=RB.getDocumentRoot=void 0;var Zkt=_8;function Bkt(g){for(;g.parent;)g=g.parent;return g}RB.getDocumentRoot=Bkt;function Gkt(g){for(var a=[],s=[],C=0,I=g;C0&&ue.some((0,h._compileToken)(Ie,he))||fe.some(function(We){return P(We,ue,he).length>0})}g.some=D;function M(ue,oe,he,ye){var Ie=typeof he=="string"?parseInt(he,10):NaN;switch(ue){case"first":case"lt":return oe;case"last":return oe.length>0?[oe[oe.length-1]]:oe;case"nth":case"eq":return isFinite(Ie)&&Math.abs(Ie)1&&d.length>1?s.reduce(function(h,y){return y(h)},d):d)}}}var OR=z8(function(g,a){for(var s,C=[],I=0;I0})}Wi.has=Mkt;function Fkt(){return this.length>1?this._make(this[0]):this}Wi.first=Fkt;function Ykt(){return this.length>0?this._make(this[this.length-1]):this}Wi.last=Ykt;function Kkt(g){var a;return g=+g,g===0&&this.length<=1?this:(g<0&&(g=this.length+g),this._make((a=this[g])!==null&&a!==void 0?a:[]))}Wi.eq=Kkt;function _kt(g){return g==null?this.toArray():this[g<0?this.length+g:g]}Wi.get=_kt;function Pkt(){return Array.prototype.slice.call(this)}Wi.toArray=Pkt;function zkt(g){var a,s;return g==null?(a=this.parent().children(),s=this[0]):typeof g=="string"?(a=this._make(g),s=this[0]):(a=this,s=(0,vc.isCheerio)(g)?g[0]:g),Array.prototype.indexOf.call(a,s)}Wi.index=zkt;function Okt(g,a){return this._make(Array.prototype.slice.call(this,g,a))}Wi.slice=Okt;function Lkt(){var g;return(g=this.prevObject)!==null&&g!==void 0?g:this._make([])}Wi.end=Lkt;function Jkt(g,a){var s=this._make(g,a),C=(0,du.uniqueSort)(P8(P8([],this.get(),!0),s.get(),!0));return this._make(C)}Wi.add=Jkt;function Ukt(g){return this.prevObject?this.add(g?this.prevObject.filter(g):this.prevObject):this}Wi.addBack=Ukt;var Sn={},Wb={};Object.defineProperty(Wb,"__esModule",{value:!0}),Wb.update=Wb.getParse=void 0;var Qkt=Au,pVe=Js;function jkt(g){return function(s,C,I,A){if(typeof Buffer<"u"&&Buffer.isBuffer(s)&&(s=s.toString()),typeof s=="string")return g(s,C,I,A);var d=s;if(!Array.isArray(d)&&(0,pVe.isDocument)(d))return d;var h=new pVe.Document([]);return bVe(d,h),h}}Wb.getParse=jkt;function bVe(g,a){var s=Array.isArray(g)?g:[g];a?a.children=s:a=null;for(var C=0;C=g.length?null:g[a+s],b=0;b-1&&(S.children.splice(H,1),I===S&&a>H&&h[0]--)}w.parent=I,w.prev&&(w.prev.next=(A=w.next)!==null&&A!==void 0?A:null),w.next&&(w.next.prev=(d=w.prev)!==null&&d!==void 0?d:null),w.prev=b===0?y:C[b-1],w.next=b===C.length-1?Z:C[b+1]}return y&&(y.next=C[0]),Z&&(Z.prev=C[C.length-1]),g.splice.apply(g,h)}function tXt(g){var a=(0,Fo.isCheerio)(g)?g:this._make(g);return a.append(this),this}Sn.appendTo=tXt;function iXt(g){var a=(0,Fo.isCheerio)(g)?g:this._make(g);return a.prepend(this),this}Sn.prependTo=iXt,Sn.append=vVe(function(g,a,s){ym(a,a.length,0,g,s)}),Sn.prepend=vVe(function(g,a,s){ym(a,0,0,g,s)});function ZVe(g){return function(a){for(var s=this.length-1,C=this.parents().last(),I=0;I0&&s!==void 0&&(a[s]+=";".concat(h))}else s=A.slice(0,d).trim(),a[s]=A.slice(d+1).trim()}return a}var WB={};Object.defineProperty(WB,"__esModule",{value:!0}),WB.serializeArray=WB.serialize=void 0;var pXt=mm,SVe="input,select,textarea,keygen",bXt=/%20/g,wVe=/\r?\n/g;function yXt(){var g=this.serializeArray(),a=g.map(function(s){return"".concat(encodeURIComponent(s.name),"=").concat(encodeURIComponent(s.value))});return a.join("&").replace(bXt,"+")}WB.serialize=yXt;function vXt(){var g=this;return this.map(function(a,s){var C=g._make(s);return(0,pXt.isTag)(s)&&s.name==="form"?C.find(SVe).toArray():C.filter(SVe).toArray()}).filter('[name!=""]:enabled:not(:submit, :button, :image, :reset, :file):matches([checked], :not(:checkbox, :radio))').map(function(a,s){var C,I=g._make(s),A=I.attr("name"),d=(C=I.val())!==null&&C!==void 0?C:"";return Array.isArray(d)?d.map(function(h){return{name:A,value:h.replace(wVe,`\r -`)}}):{name:A,value:d.replace(wVe,`\r -`)}}).toArray()}WB.serializeArray=vXt;var ZXt=ne&&ne.__createBinding||(Object.create?function(g,a,s,C){C===void 0&&(C=s);var I=Object.getOwnPropertyDescriptor(a,s);(!I||("get"in I?!a.__esModule:I.writable||I.configurable))&&(I={enumerable:!0,get:function(){return a[s]}}),Object.defineProperty(g,C,I)}:function(g,a,s,C){C===void 0&&(C=s),g[C]=a[s]}),BXt=ne&&ne.__setModuleDefault||(Object.create?function(g,a){Object.defineProperty(g,"default",{enumerable:!0,value:a})}:function(g,a){g.default=a}),JR=ne&&ne.__importStar||function(g){if(g&&g.__esModule)return g;var a={};if(g!=null)for(var s in g)s!=="default"&&Object.prototype.hasOwnProperty.call(g,s)&&ZXt(a,g,s);return BXt(a,g),a};Object.defineProperty(s5,"__esModule",{value:!0}),s5.Cheerio=void 0;var GXt=JR(So),SXt=JR(Wi),wXt=JR(Sn),TXt=JR(m5),RXt=JR(WB),UR=function(){function g(a,s,C){if(this.length=0,this.options=C,this._root=s,a){for(var I=0;I=55296&&h<=57343}g.isSurrogate=s;function C(h){return h>=56320&&h<=57343}g.isSurrogatePair=C;function I(h,y){return(h-55296)*1024+9216+y}g.getSurrogatePairCodePoint=I;function A(h){return h!==32&&h!==10&&h!==13&&h!==9&&h!==12&&h>=1&&h<=31||h>=127&&h<=159}g.isControlCodePoint=A;function d(h){return h>=64976&&h<=65007||a.has(h)}g.isUndefinedCodePoint=d})(b5);var $R={};(function(g){Object.defineProperty(g,"__esModule",{value:!0}),g.ERR=void 0,function(a){a.controlCharacterInInputStream="control-character-in-input-stream",a.noncharacterInInputStream="noncharacter-in-input-stream",a.surrogateInInputStream="surrogate-in-input-stream",a.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",a.endTagWithAttributes="end-tag-with-attributes",a.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",a.unexpectedSolidusInTag="unexpected-solidus-in-tag",a.unexpectedNullCharacter="unexpected-null-character",a.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",a.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",a.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",a.missingEndTagName="missing-end-tag-name",a.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",a.unknownNamedCharacterReference="unknown-named-character-reference",a.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",a.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",a.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",a.eofBeforeTagName="eof-before-tag-name",a.eofInTag="eof-in-tag",a.missingAttributeValue="missing-attribute-value",a.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",a.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",a.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",a.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",a.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",a.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",a.missingDoctypePublicIdentifier="missing-doctype-public-identifier",a.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",a.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",a.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",a.cdataInHtmlContent="cdata-in-html-content",a.incorrectlyOpenedComment="incorrectly-opened-comment",a.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",a.eofInDoctype="eof-in-doctype",a.nestedComment="nested-comment",a.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",a.eofInComment="eof-in-comment",a.incorrectlyClosedComment="incorrectly-closed-comment",a.eofInCdata="eof-in-cdata",a.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",a.nullCharacterReference="null-character-reference",a.surrogateCharacterReference="surrogate-character-reference",a.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",a.controlCharacterReference="control-character-reference",a.noncharacterCharacterReference="noncharacter-character-reference",a.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",a.missingDoctypeName="missing-doctype-name",a.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",a.duplicateAttribute="duplicate-attribute",a.nonConformingDoctype="non-conforming-doctype",a.missingDoctype="missing-doctype",a.misplacedDoctype="misplaced-doctype",a.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",a.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",a.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",a.openElementsLeftAfterEof="open-elements-left-after-eof",a.abandonedHeadElementChild="abandoned-head-element-child",a.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",a.nestedNoscriptInHead="nested-noscript-in-head",a.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"}(g.ERR||(g.ERR={}))})($R),Object.defineProperty(p5,"__esModule",{value:!0}),p5.Preprocessor=void 0;const Qs=b5,j8=$R,xXt=1<<16;let DXt=function(){function g(a){T(this,g),this.handler=a,this.html="",this.pos=-1,this.lastGapPos=-2,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=xXt,this.isEol=!1,this.lineStartPos=0,this.droppedBufferSize=0,this.line=1,this.lastErrOffset=-1}return E(g,[{key:"col",get:function(){return this.pos-this.lineStartPos+ +(this.lastGapPos!==this.pos)}},{key:"offset",get:function(){return this.droppedBufferSize+this.pos}},{key:"getError",value:function(s){const{line:C,col:I,offset:A}=this;return{code:s,startLine:C,endLine:C,startCol:I,endCol:I,startOffset:A,endOffset:A}}},{key:"_err",value:function(s){this.handler.onParseError&&this.lastErrOffset!==this.offset&&(this.lastErrOffset=this.offset,this.handler.onParseError(this.getError(s)))}},{key:"_addGap",value:function(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos}},{key:"_processSurrogate",value:function(s){if(this.pos!==this.html.length-1){const C=this.html.charCodeAt(this.pos+1);if((0,Qs.isSurrogatePair)(C))return this.pos++,this._addGap(),(0,Qs.getSurrogatePairCodePoint)(s,C)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,Qs.CODE_POINTS.EOF;return this._err(j8.ERR.surrogateInInputStream),s}},{key:"willDropParsedChunk",value:function(){return this.pos>this.bufferWaterline}},{key:"dropParsedChunk",value:function(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}},{key:"write",value:function(s,C){this.html.length>0?this.html+=s:this.html=s,this.endOfChunkHit=!1,this.lastChunkWritten=C}},{key:"insertHtmlAtCurrentPos",value:function(s){this.html=this.html.substring(0,this.pos+1)+s+this.html.substring(this.pos+1),this.endOfChunkHit=!1}},{key:"startsWith",value:function(s,C){if(this.pos+s.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(C)return this.html.startsWith(s,this.pos);for(let I=0;I=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,Qs.CODE_POINTS.EOF;const I=this.html.charCodeAt(C);return I===Qs.CODE_POINTS.CARRIAGE_RETURN?Qs.CODE_POINTS.LINE_FEED:I}},{key:"advance",value:function(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,Qs.CODE_POINTS.EOF;let s=this.html.charCodeAt(this.pos);return s===Qs.CODE_POINTS.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,Qs.CODE_POINTS.LINE_FEED):s===Qs.CODE_POINTS.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,(0,Qs.isSurrogate)(s)&&(s=this._processSurrogate(s)),this.handler.onParseError===null||s>31&&s<127||s===Qs.CODE_POINTS.LINE_FEED||s===Qs.CODE_POINTS.CARRIAGE_RETURN||s>159&&s<64976||this._checkForProblematicCharacters(s),s)}},{key:"_checkForProblematicCharacters",value:function(s){(0,Qs.isControlCodePoint)(s)?this._err(j8.ERR.controlCharacterInInputStream):(0,Qs.isUndefinedCodePoint)(s)&&this._err(j8.ERR.noncharacterInInputStream)}},{key:"retreat",value:function(s){for(this.pos-=s;this.pos=0;I--)if(s.attrs[I].name===C)return s.attrs[I].value;return null}g.getTokenAttr=a})(y5);var lh={};(function(g){Object.defineProperty(g,"__esModule",{value:!0}),g.hasUnescapedText=g.isNumberedHeader=g.SPECIAL_ELEMENTS=g.getTagID=g.TAG_ID=g.TAG_NAMES=g.DOCUMENT_MODE=g.ATTRS=g.NS=void 0;var a;(function(b){b.HTML="http://www.w3.org/1999/xhtml",b.MATHML="http://www.w3.org/1998/Math/MathML",b.SVG="http://www.w3.org/2000/svg",b.XLINK="http://www.w3.org/1999/xlink",b.XML="http://www.w3.org/XML/1998/namespace",b.XMLNS="http://www.w3.org/2000/xmlns/"})(a=g.NS||(g.NS={})),function(b){b.TYPE="type",b.ACTION="action",b.ENCODING="encoding",b.PROMPT="prompt",b.NAME="name",b.COLOR="color",b.FACE="face",b.SIZE="size"}(g.ATTRS||(g.ATTRS={})),function(b){b.NO_QUIRKS="no-quirks",b.QUIRKS="quirks",b.LIMITED_QUIRKS="limited-quirks"}(g.DOCUMENT_MODE||(g.DOCUMENT_MODE={}));var s;(function(b){b.A="a",b.ADDRESS="address",b.ANNOTATION_XML="annotation-xml",b.APPLET="applet",b.AREA="area",b.ARTICLE="article",b.ASIDE="aside",b.B="b",b.BASE="base",b.BASEFONT="basefont",b.BGSOUND="bgsound",b.BIG="big",b.BLOCKQUOTE="blockquote",b.BODY="body",b.BR="br",b.BUTTON="button",b.CAPTION="caption",b.CENTER="center",b.CODE="code",b.COL="col",b.COLGROUP="colgroup",b.DD="dd",b.DESC="desc",b.DETAILS="details",b.DIALOG="dialog",b.DIR="dir",b.DIV="div",b.DL="dl",b.DT="dt",b.EM="em",b.EMBED="embed",b.FIELDSET="fieldset",b.FIGCAPTION="figcaption",b.FIGURE="figure",b.FONT="font",b.FOOTER="footer",b.FOREIGN_OBJECT="foreignObject",b.FORM="form",b.FRAME="frame",b.FRAMESET="frameset",b.H1="h1",b.H2="h2",b.H3="h3",b.H4="h4",b.H5="h5",b.H6="h6",b.HEAD="head",b.HEADER="header",b.HGROUP="hgroup",b.HR="hr",b.HTML="html",b.I="i",b.IMG="img",b.IMAGE="image",b.INPUT="input",b.IFRAME="iframe",b.KEYGEN="keygen",b.LABEL="label",b.LI="li",b.LINK="link",b.LISTING="listing",b.MAIN="main",b.MALIGNMARK="malignmark",b.MARQUEE="marquee",b.MATH="math",b.MENU="menu",b.META="meta",b.MGLYPH="mglyph",b.MI="mi",b.MO="mo",b.MN="mn",b.MS="ms",b.MTEXT="mtext",b.NAV="nav",b.NOBR="nobr",b.NOFRAMES="noframes",b.NOEMBED="noembed",b.NOSCRIPT="noscript",b.OBJECT="object",b.OL="ol",b.OPTGROUP="optgroup",b.OPTION="option",b.P="p",b.PARAM="param",b.PLAINTEXT="plaintext",b.PRE="pre",b.RB="rb",b.RP="rp",b.RT="rt",b.RTC="rtc",b.RUBY="ruby",b.S="s",b.SCRIPT="script",b.SECTION="section",b.SELECT="select",b.SOURCE="source",b.SMALL="small",b.SPAN="span",b.STRIKE="strike",b.STRONG="strong",b.STYLE="style",b.SUB="sub",b.SUMMARY="summary",b.SUP="sup",b.TABLE="table",b.TBODY="tbody",b.TEMPLATE="template",b.TEXTAREA="textarea",b.TFOOT="tfoot",b.TD="td",b.TH="th",b.THEAD="thead",b.TITLE="title",b.TR="tr",b.TRACK="track",b.TT="tt",b.U="u",b.UL="ul",b.SVG="svg",b.VAR="var",b.WBR="wbr",b.XMP="xmp"})(s=g.TAG_NAMES||(g.TAG_NAMES={}));var C;(function(b){b[b.UNKNOWN=0]="UNKNOWN",b[b.A=1]="A",b[b.ADDRESS=2]="ADDRESS",b[b.ANNOTATION_XML=3]="ANNOTATION_XML",b[b.APPLET=4]="APPLET",b[b.AREA=5]="AREA",b[b.ARTICLE=6]="ARTICLE",b[b.ASIDE=7]="ASIDE",b[b.B=8]="B",b[b.BASE=9]="BASE",b[b.BASEFONT=10]="BASEFONT",b[b.BGSOUND=11]="BGSOUND",b[b.BIG=12]="BIG",b[b.BLOCKQUOTE=13]="BLOCKQUOTE",b[b.BODY=14]="BODY",b[b.BR=15]="BR",b[b.BUTTON=16]="BUTTON",b[b.CAPTION=17]="CAPTION",b[b.CENTER=18]="CENTER",b[b.CODE=19]="CODE",b[b.COL=20]="COL",b[b.COLGROUP=21]="COLGROUP",b[b.DD=22]="DD",b[b.DESC=23]="DESC",b[b.DETAILS=24]="DETAILS",b[b.DIALOG=25]="DIALOG",b[b.DIR=26]="DIR",b[b.DIV=27]="DIV",b[b.DL=28]="DL",b[b.DT=29]="DT",b[b.EM=30]="EM",b[b.EMBED=31]="EMBED",b[b.FIELDSET=32]="FIELDSET",b[b.FIGCAPTION=33]="FIGCAPTION",b[b.FIGURE=34]="FIGURE",b[b.FONT=35]="FONT",b[b.FOOTER=36]="FOOTER",b[b.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",b[b.FORM=38]="FORM",b[b.FRAME=39]="FRAME",b[b.FRAMESET=40]="FRAMESET",b[b.H1=41]="H1",b[b.H2=42]="H2",b[b.H3=43]="H3",b[b.H4=44]="H4",b[b.H5=45]="H5",b[b.H6=46]="H6",b[b.HEAD=47]="HEAD",b[b.HEADER=48]="HEADER",b[b.HGROUP=49]="HGROUP",b[b.HR=50]="HR",b[b.HTML=51]="HTML",b[b.I=52]="I",b[b.IMG=53]="IMG",b[b.IMAGE=54]="IMAGE",b[b.INPUT=55]="INPUT",b[b.IFRAME=56]="IFRAME",b[b.KEYGEN=57]="KEYGEN",b[b.LABEL=58]="LABEL",b[b.LI=59]="LI",b[b.LINK=60]="LINK",b[b.LISTING=61]="LISTING",b[b.MAIN=62]="MAIN",b[b.MALIGNMARK=63]="MALIGNMARK",b[b.MARQUEE=64]="MARQUEE",b[b.MATH=65]="MATH",b[b.MENU=66]="MENU",b[b.META=67]="META",b[b.MGLYPH=68]="MGLYPH",b[b.MI=69]="MI",b[b.MO=70]="MO",b[b.MN=71]="MN",b[b.MS=72]="MS",b[b.MTEXT=73]="MTEXT",b[b.NAV=74]="NAV",b[b.NOBR=75]="NOBR",b[b.NOFRAMES=76]="NOFRAMES",b[b.NOEMBED=77]="NOEMBED",b[b.NOSCRIPT=78]="NOSCRIPT",b[b.OBJECT=79]="OBJECT",b[b.OL=80]="OL",b[b.OPTGROUP=81]="OPTGROUP",b[b.OPTION=82]="OPTION",b[b.P=83]="P",b[b.PARAM=84]="PARAM",b[b.PLAINTEXT=85]="PLAINTEXT",b[b.PRE=86]="PRE",b[b.RB=87]="RB",b[b.RP=88]="RP",b[b.RT=89]="RT",b[b.RTC=90]="RTC",b[b.RUBY=91]="RUBY",b[b.S=92]="S",b[b.SCRIPT=93]="SCRIPT",b[b.SECTION=94]="SECTION",b[b.SELECT=95]="SELECT",b[b.SOURCE=96]="SOURCE",b[b.SMALL=97]="SMALL",b[b.SPAN=98]="SPAN",b[b.STRIKE=99]="STRIKE",b[b.STRONG=100]="STRONG",b[b.STYLE=101]="STYLE",b[b.SUB=102]="SUB",b[b.SUMMARY=103]="SUMMARY",b[b.SUP=104]="SUP",b[b.TABLE=105]="TABLE",b[b.TBODY=106]="TBODY",b[b.TEMPLATE=107]="TEMPLATE",b[b.TEXTAREA=108]="TEXTAREA",b[b.TFOOT=109]="TFOOT",b[b.TD=110]="TD",b[b.TH=111]="TH",b[b.THEAD=112]="THEAD",b[b.TITLE=113]="TITLE",b[b.TR=114]="TR",b[b.TRACK=115]="TRACK",b[b.TT=116]="TT",b[b.U=117]="U",b[b.UL=118]="UL",b[b.SVG=119]="SVG",b[b.VAR=120]="VAR",b[b.WBR=121]="WBR",b[b.XMP=122]="XMP"})(C=g.TAG_ID||(g.TAG_ID={}));const I=new Map([[s.A,C.A],[s.ADDRESS,C.ADDRESS],[s.ANNOTATION_XML,C.ANNOTATION_XML],[s.APPLET,C.APPLET],[s.AREA,C.AREA],[s.ARTICLE,C.ARTICLE],[s.ASIDE,C.ASIDE],[s.B,C.B],[s.BASE,C.BASE],[s.BASEFONT,C.BASEFONT],[s.BGSOUND,C.BGSOUND],[s.BIG,C.BIG],[s.BLOCKQUOTE,C.BLOCKQUOTE],[s.BODY,C.BODY],[s.BR,C.BR],[s.BUTTON,C.BUTTON],[s.CAPTION,C.CAPTION],[s.CENTER,C.CENTER],[s.CODE,C.CODE],[s.COL,C.COL],[s.COLGROUP,C.COLGROUP],[s.DD,C.DD],[s.DESC,C.DESC],[s.DETAILS,C.DETAILS],[s.DIALOG,C.DIALOG],[s.DIR,C.DIR],[s.DIV,C.DIV],[s.DL,C.DL],[s.DT,C.DT],[s.EM,C.EM],[s.EMBED,C.EMBED],[s.FIELDSET,C.FIELDSET],[s.FIGCAPTION,C.FIGCAPTION],[s.FIGURE,C.FIGURE],[s.FONT,C.FONT],[s.FOOTER,C.FOOTER],[s.FOREIGN_OBJECT,C.FOREIGN_OBJECT],[s.FORM,C.FORM],[s.FRAME,C.FRAME],[s.FRAMESET,C.FRAMESET],[s.H1,C.H1],[s.H2,C.H2],[s.H3,C.H3],[s.H4,C.H4],[s.H5,C.H5],[s.H6,C.H6],[s.HEAD,C.HEAD],[s.HEADER,C.HEADER],[s.HGROUP,C.HGROUP],[s.HR,C.HR],[s.HTML,C.HTML],[s.I,C.I],[s.IMG,C.IMG],[s.IMAGE,C.IMAGE],[s.INPUT,C.INPUT],[s.IFRAME,C.IFRAME],[s.KEYGEN,C.KEYGEN],[s.LABEL,C.LABEL],[s.LI,C.LI],[s.LINK,C.LINK],[s.LISTING,C.LISTING],[s.MAIN,C.MAIN],[s.MALIGNMARK,C.MALIGNMARK],[s.MARQUEE,C.MARQUEE],[s.MATH,C.MATH],[s.MENU,C.MENU],[s.META,C.META],[s.MGLYPH,C.MGLYPH],[s.MI,C.MI],[s.MO,C.MO],[s.MN,C.MN],[s.MS,C.MS],[s.MTEXT,C.MTEXT],[s.NAV,C.NAV],[s.NOBR,C.NOBR],[s.NOFRAMES,C.NOFRAMES],[s.NOEMBED,C.NOEMBED],[s.NOSCRIPT,C.NOSCRIPT],[s.OBJECT,C.OBJECT],[s.OL,C.OL],[s.OPTGROUP,C.OPTGROUP],[s.OPTION,C.OPTION],[s.P,C.P],[s.PARAM,C.PARAM],[s.PLAINTEXT,C.PLAINTEXT],[s.PRE,C.PRE],[s.RB,C.RB],[s.RP,C.RP],[s.RT,C.RT],[s.RTC,C.RTC],[s.RUBY,C.RUBY],[s.S,C.S],[s.SCRIPT,C.SCRIPT],[s.SECTION,C.SECTION],[s.SELECT,C.SELECT],[s.SOURCE,C.SOURCE],[s.SMALL,C.SMALL],[s.SPAN,C.SPAN],[s.STRIKE,C.STRIKE],[s.STRONG,C.STRONG],[s.STYLE,C.STYLE],[s.SUB,C.SUB],[s.SUMMARY,C.SUMMARY],[s.SUP,C.SUP],[s.TABLE,C.TABLE],[s.TBODY,C.TBODY],[s.TEMPLATE,C.TEMPLATE],[s.TEXTAREA,C.TEXTAREA],[s.TFOOT,C.TFOOT],[s.TD,C.TD],[s.TH,C.TH],[s.THEAD,C.THEAD],[s.TITLE,C.TITLE],[s.TR,C.TR],[s.TRACK,C.TRACK],[s.TT,C.TT],[s.U,C.U],[s.UL,C.UL],[s.SVG,C.SVG],[s.VAR,C.VAR],[s.WBR,C.WBR],[s.XMP,C.XMP]]);function A(b){var w;return(w=I.get(b))!==null&&w!==void 0?w:C.UNKNOWN}g.getTagID=A;const d=C;g.SPECIAL_ELEMENTS={[a.HTML]:new Set([d.ADDRESS,d.APPLET,d.AREA,d.ARTICLE,d.ASIDE,d.BASE,d.BASEFONT,d.BGSOUND,d.BLOCKQUOTE,d.BODY,d.BR,d.BUTTON,d.CAPTION,d.CENTER,d.COL,d.COLGROUP,d.DD,d.DETAILS,d.DIR,d.DIV,d.DL,d.DT,d.EMBED,d.FIELDSET,d.FIGCAPTION,d.FIGURE,d.FOOTER,d.FORM,d.FRAME,d.FRAMESET,d.H1,d.H2,d.H3,d.H4,d.H5,d.H6,d.HEAD,d.HEADER,d.HGROUP,d.HR,d.HTML,d.IFRAME,d.IMG,d.INPUT,d.LI,d.LINK,d.LISTING,d.MAIN,d.MARQUEE,d.MENU,d.META,d.NAV,d.NOEMBED,d.NOFRAMES,d.NOSCRIPT,d.OBJECT,d.OL,d.P,d.PARAM,d.PLAINTEXT,d.PRE,d.SCRIPT,d.SECTION,d.SELECT,d.SOURCE,d.STYLE,d.SUMMARY,d.TABLE,d.TBODY,d.TD,d.TEMPLATE,d.TEXTAREA,d.TFOOT,d.TH,d.THEAD,d.TITLE,d.TR,d.TRACK,d.UL,d.WBR,d.XMP]),[a.MATHML]:new Set([d.MI,d.MO,d.MN,d.MS,d.MTEXT,d.ANNOTATION_XML]),[a.SVG]:new Set([d.TITLE,d.FOREIGN_OBJECT,d.DESC]),[a.XLINK]:new Set,[a.XML]:new Set,[a.XMLNS]:new Set};function h(b){return b===d.H1||b===d.H2||b===d.H3||b===d.H4||b===d.H5||b===d.H6}g.isNumberedHeader=h;const y=new Set([s.STYLE,s.SCRIPT,s.XMP,s.IFRAME,s.NOEMBED,s.NOFRAMES,s.PLAINTEXT]);function Z(b,w){return y.has(b)||w&&b===s.NOSCRIPT}g.hasUnescapedText=Z})(lh),Object.defineProperty(Nb,"__esModule",{value:!0}),Nb.Tokenizer=Nb.TokenizerMode=void 0;const MXt=p5,we=b5,kI=y5,fu=Sb,Lt=$R,$8=lh,FXt=new Map([[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]);var De;(function(g){g[g.DATA=0]="DATA",g[g.RCDATA=1]="RCDATA",g[g.RAWTEXT=2]="RAWTEXT",g[g.SCRIPT_DATA=3]="SCRIPT_DATA",g[g.PLAINTEXT=4]="PLAINTEXT",g[g.TAG_OPEN=5]="TAG_OPEN",g[g.END_TAG_OPEN=6]="END_TAG_OPEN",g[g.TAG_NAME=7]="TAG_NAME",g[g.RCDATA_LESS_THAN_SIGN=8]="RCDATA_LESS_THAN_SIGN",g[g.RCDATA_END_TAG_OPEN=9]="RCDATA_END_TAG_OPEN",g[g.RCDATA_END_TAG_NAME=10]="RCDATA_END_TAG_NAME",g[g.RAWTEXT_LESS_THAN_SIGN=11]="RAWTEXT_LESS_THAN_SIGN",g[g.RAWTEXT_END_TAG_OPEN=12]="RAWTEXT_END_TAG_OPEN",g[g.RAWTEXT_END_TAG_NAME=13]="RAWTEXT_END_TAG_NAME",g[g.SCRIPT_DATA_LESS_THAN_SIGN=14]="SCRIPT_DATA_LESS_THAN_SIGN",g[g.SCRIPT_DATA_END_TAG_OPEN=15]="SCRIPT_DATA_END_TAG_OPEN",g[g.SCRIPT_DATA_END_TAG_NAME=16]="SCRIPT_DATA_END_TAG_NAME",g[g.SCRIPT_DATA_ESCAPE_START=17]="SCRIPT_DATA_ESCAPE_START",g[g.SCRIPT_DATA_ESCAPE_START_DASH=18]="SCRIPT_DATA_ESCAPE_START_DASH",g[g.SCRIPT_DATA_ESCAPED=19]="SCRIPT_DATA_ESCAPED",g[g.SCRIPT_DATA_ESCAPED_DASH=20]="SCRIPT_DATA_ESCAPED_DASH",g[g.SCRIPT_DATA_ESCAPED_DASH_DASH=21]="SCRIPT_DATA_ESCAPED_DASH_DASH",g[g.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]="SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN",g[g.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]="SCRIPT_DATA_ESCAPED_END_TAG_OPEN",g[g.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]="SCRIPT_DATA_ESCAPED_END_TAG_NAME",g[g.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]="SCRIPT_DATA_DOUBLE_ESCAPE_START",g[g.SCRIPT_DATA_DOUBLE_ESCAPED=26]="SCRIPT_DATA_DOUBLE_ESCAPED",g[g.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH",g[g.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH",g[g.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]="SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN",g[g.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]="SCRIPT_DATA_DOUBLE_ESCAPE_END",g[g.BEFORE_ATTRIBUTE_NAME=31]="BEFORE_ATTRIBUTE_NAME",g[g.ATTRIBUTE_NAME=32]="ATTRIBUTE_NAME",g[g.AFTER_ATTRIBUTE_NAME=33]="AFTER_ATTRIBUTE_NAME",g[g.BEFORE_ATTRIBUTE_VALUE=34]="BEFORE_ATTRIBUTE_VALUE",g[g.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]="ATTRIBUTE_VALUE_DOUBLE_QUOTED",g[g.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]="ATTRIBUTE_VALUE_SINGLE_QUOTED",g[g.ATTRIBUTE_VALUE_UNQUOTED=37]="ATTRIBUTE_VALUE_UNQUOTED",g[g.AFTER_ATTRIBUTE_VALUE_QUOTED=38]="AFTER_ATTRIBUTE_VALUE_QUOTED",g[g.SELF_CLOSING_START_TAG=39]="SELF_CLOSING_START_TAG",g[g.BOGUS_COMMENT=40]="BOGUS_COMMENT",g[g.MARKUP_DECLARATION_OPEN=41]="MARKUP_DECLARATION_OPEN",g[g.COMMENT_START=42]="COMMENT_START",g[g.COMMENT_START_DASH=43]="COMMENT_START_DASH",g[g.COMMENT=44]="COMMENT",g[g.COMMENT_LESS_THAN_SIGN=45]="COMMENT_LESS_THAN_SIGN",g[g.COMMENT_LESS_THAN_SIGN_BANG=46]="COMMENT_LESS_THAN_SIGN_BANG",g[g.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]="COMMENT_LESS_THAN_SIGN_BANG_DASH",g[g.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH",g[g.COMMENT_END_DASH=49]="COMMENT_END_DASH",g[g.COMMENT_END=50]="COMMENT_END",g[g.COMMENT_END_BANG=51]="COMMENT_END_BANG",g[g.DOCTYPE=52]="DOCTYPE",g[g.BEFORE_DOCTYPE_NAME=53]="BEFORE_DOCTYPE_NAME",g[g.DOCTYPE_NAME=54]="DOCTYPE_NAME",g[g.AFTER_DOCTYPE_NAME=55]="AFTER_DOCTYPE_NAME",g[g.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]="AFTER_DOCTYPE_PUBLIC_KEYWORD",g[g.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER",g[g.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED",g[g.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED",g[g.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]="AFTER_DOCTYPE_PUBLIC_IDENTIFIER",g[g.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS",g[g.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]="AFTER_DOCTYPE_SYSTEM_KEYWORD",g[g.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER",g[g.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED",g[g.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED",g[g.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]="AFTER_DOCTYPE_SYSTEM_IDENTIFIER",g[g.BOGUS_DOCTYPE=67]="BOGUS_DOCTYPE",g[g.CDATA_SECTION=68]="CDATA_SECTION",g[g.CDATA_SECTION_BRACKET=69]="CDATA_SECTION_BRACKET",g[g.CDATA_SECTION_END=70]="CDATA_SECTION_END",g[g.CHARACTER_REFERENCE=71]="CHARACTER_REFERENCE",g[g.NAMED_CHARACTER_REFERENCE=72]="NAMED_CHARACTER_REFERENCE",g[g.AMBIGUOUS_AMPERSAND=73]="AMBIGUOUS_AMPERSAND",g[g.NUMERIC_CHARACTER_REFERENCE=74]="NUMERIC_CHARACTER_REFERENCE",g[g.HEXADEMICAL_CHARACTER_REFERENCE_START=75]="HEXADEMICAL_CHARACTER_REFERENCE_START",g[g.HEXADEMICAL_CHARACTER_REFERENCE=76]="HEXADEMICAL_CHARACTER_REFERENCE",g[g.DECIMAL_CHARACTER_REFERENCE=77]="DECIMAL_CHARACTER_REFERENCE",g[g.NUMERIC_CHARACTER_REFERENCE_END=78]="NUMERIC_CHARACTER_REFERENCE_END"})(De||(De={})),Nb.TokenizerMode={DATA:De.DATA,RCDATA:De.RCDATA,RAWTEXT:De.RAWTEXT,SCRIPT_DATA:De.SCRIPT_DATA,PLAINTEXT:De.PLAINTEXT,CDATA_SECTION:De.CDATA_SECTION};function qR(g){return g>=we.CODE_POINTS.DIGIT_0&&g<=we.CODE_POINTS.DIGIT_9}function eV(g){return g>=we.CODE_POINTS.LATIN_CAPITAL_A&&g<=we.CODE_POINTS.LATIN_CAPITAL_Z}function YXt(g){return g>=we.CODE_POINTS.LATIN_SMALL_A&&g<=we.CODE_POINTS.LATIN_SMALL_Z}function vm(g){return YXt(g)||eV(g)}function q8(g){return vm(g)||qR(g)}function VVe(g){return g>=we.CODE_POINTS.LATIN_CAPITAL_A&&g<=we.CODE_POINTS.LATIN_CAPITAL_F}function EVe(g){return g>=we.CODE_POINTS.LATIN_SMALL_A&&g<=we.CODE_POINTS.LATIN_SMALL_F}function KXt(g){return qR(g)||VVe(g)||EVe(g)}function v5(g){return g+32}function HVe(g){return g===we.CODE_POINTS.SPACE||g===we.CODE_POINTS.LINE_FEED||g===we.CODE_POINTS.TABULATION||g===we.CODE_POINTS.FORM_FEED}function _Xt(g){return g===we.CODE_POINTS.EQUALS_SIGN||q8(g)}function WVe(g){return HVe(g)||g===we.CODE_POINTS.SOLIDUS||g===we.CODE_POINTS.GREATER_THAN_SIGN}let PXt=function(){function g(a,s){T(this,g),this.options=a,this.handler=s,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=De.DATA,this.returnState=De.DATA,this.charRefCode=-1,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new MXt.Preprocessor(s),this.currentLocation=this.getCurrentLocation(-1)}return E(g,[{key:"_err",value:function(s){var C,I;(I=(C=this.handler).onParseError)===null||I===void 0||I.call(C,this.preprocessor.getError(s))}},{key:"getCurrentLocation",value:function(s){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-s,startOffset:this.preprocessor.offset-s,endLine:-1,endCol:-1,endOffset:-1}:null}},{key:"_runParsingLoop",value:function(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;const s=this._consume();this._ensureHibernation()||this._callState(s)}this.inLoop=!1}}},{key:"pause",value:function(){this.paused=!0}},{key:"resume",value:function(s){if(!this.paused)throw new Error("Parser was already resumed");this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||s?.())}},{key:"write",value:function(s,C,I){this.active=!0,this.preprocessor.write(s,C),this._runParsingLoop(),this.paused||I?.()}},{key:"insertHtmlAtCurrentPos",value:function(s){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(s),this._runParsingLoop()}},{key:"_ensureHibernation",value:function(){return this.preprocessor.endOfChunkHit?(this._unconsume(this.consumedAfterSnapshot),this.active=!1,!0):!1}},{key:"_consume",value:function(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}},{key:"_unconsume",value:function(s){this.consumedAfterSnapshot-=s,this.preprocessor.retreat(s)}},{key:"_reconsumeInState",value:function(s,C){this.state=s,this._callState(C)}},{key:"_advanceBy",value:function(s){this.consumedAfterSnapshot+=s;for(let C=0;C0&&this._err(Lt.ERR.endTagWithAttributes),s.selfClosing&&this._err(Lt.ERR.endTagWithTrailingSolidus),this.handler.onEndTag(s)),this.preprocessor.dropParsedChunk()}},{key:"emitCurrentComment",value:function(s){this.prepareToken(s),this.handler.onComment(s),this.preprocessor.dropParsedChunk()}},{key:"emitCurrentDoctype",value:function(s){this.prepareToken(s),this.handler.onDoctype(s),this.preprocessor.dropParsedChunk()}},{key:"_emitCurrentCharacterToken",value:function(s){if(this.currentCharacterToken){switch(s&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=s.startLine,this.currentCharacterToken.location.endCol=s.startCol,this.currentCharacterToken.location.endOffset=s.startOffset),this.currentCharacterToken.type){case kI.TokenType.CHARACTER:{this.handler.onCharacter(this.currentCharacterToken);break}case kI.TokenType.NULL_CHARACTER:{this.handler.onNullCharacter(this.currentCharacterToken);break}case kI.TokenType.WHITESPACE_CHARACTER:{this.handler.onWhitespaceCharacter(this.currentCharacterToken);break}}this.currentCharacterToken=null}}},{key:"_emitEOFToken",value:function(){const s=this.getCurrentLocation(0);s&&(s.endLine=s.startLine,s.endCol=s.startCol,s.endOffset=s.startOffset),this._emitCurrentCharacterToken(s),this.handler.onEof({type:kI.TokenType.EOF,location:s}),this.active=!1}},{key:"_appendCharToCurrentCharacterToken",value:function(s,C){if(this.currentCharacterToken)if(this.currentCharacterToken.type!==s)this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk();else{this.currentCharacterToken.chars+=C;return}this._createCharacterToken(s,C)}},{key:"_emitCodePoint",value:function(s){const C=HVe(s)?kI.TokenType.WHITESPACE_CHARACTER:s===we.CODE_POINTS.NULL?kI.TokenType.NULL_CHARACTER:kI.TokenType.CHARACTER;this._appendCharToCurrentCharacterToken(C,String.fromCodePoint(s))}},{key:"_emitChars",value:function(s){this._appendCharToCurrentCharacterToken(kI.TokenType.CHARACTER,s)}},{key:"_matchNamedCharacterReference",value:function(s){let C=null,I=0,A=!1;for(let d=0,h=fu.htmlDecodeTree[0];d>=0&&(d=(0,fu.determineBranch)(fu.htmlDecodeTree,h,d+1,s),!(d<0));s=this._consume()){I+=1,h=fu.htmlDecodeTree[d];const y=h&fu.BinTrieFlags.VALUE_LENGTH;if(y){const Z=(y>>14)-1;if(s!==we.CODE_POINTS.SEMICOLON&&this._isCharacterReferenceInAttribute()&&_Xt(this.preprocessor.peek(1))?(C=[we.CODE_POINTS.AMPERSAND],d+=Z):(C=Z===0?[fu.htmlDecodeTree[d]&~fu.BinTrieFlags.VALUE_LENGTH]:Z===1?[fu.htmlDecodeTree[++d]]:[fu.htmlDecodeTree[++d],fu.htmlDecodeTree[++d]],I=0,A=s!==we.CODE_POINTS.SEMICOLON),Z===0){this._consume();break}}}return this._unconsume(I),A&&!this.preprocessor.endOfChunkHit&&this._err(Lt.ERR.missingSemicolonAfterCharacterReference),this._unconsume(1),C}},{key:"_isCharacterReferenceInAttribute",value:function(){return this.returnState===De.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===De.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===De.ATTRIBUTE_VALUE_UNQUOTED}},{key:"_flushCodePointConsumedAsCharacterReference",value:function(s){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(s):this._emitCodePoint(s)}},{key:"_callState",value:function(s){switch(this.state){case De.DATA:{this._stateData(s);break}case De.RCDATA:{this._stateRcdata(s);break}case De.RAWTEXT:{this._stateRawtext(s);break}case De.SCRIPT_DATA:{this._stateScriptData(s);break}case De.PLAINTEXT:{this._statePlaintext(s);break}case De.TAG_OPEN:{this._stateTagOpen(s);break}case De.END_TAG_OPEN:{this._stateEndTagOpen(s);break}case De.TAG_NAME:{this._stateTagName(s);break}case De.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(s);break}case De.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(s);break}case De.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(s);break}case De.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(s);break}case De.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(s);break}case De.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(s);break}case De.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(s);break}case De.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(s);break}case De.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(s);break}case De.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(s);break}case De.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(s);break}case De.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(s);break}case De.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(s);break}case De.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(s);break}case De.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(s);break}case De.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(s);break}case De.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(s);break}case De.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(s);break}case De.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(s);break}case De.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(s);break}case De.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(s);break}case De.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(s);break}case De.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(s);break}case De.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(s);break}case De.ATTRIBUTE_NAME:{this._stateAttributeName(s);break}case De.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(s);break}case De.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(s);break}case De.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(s);break}case De.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(s);break}case De.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(s);break}case De.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(s);break}case De.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(s);break}case De.BOGUS_COMMENT:{this._stateBogusComment(s);break}case De.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(s);break}case De.COMMENT_START:{this._stateCommentStart(s);break}case De.COMMENT_START_DASH:{this._stateCommentStartDash(s);break}case De.COMMENT:{this._stateComment(s);break}case De.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(s);break}case De.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(s);break}case De.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(s);break}case De.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(s);break}case De.COMMENT_END_DASH:{this._stateCommentEndDash(s);break}case De.COMMENT_END:{this._stateCommentEnd(s);break}case De.COMMENT_END_BANG:{this._stateCommentEndBang(s);break}case De.DOCTYPE:{this._stateDoctype(s);break}case De.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(s);break}case De.DOCTYPE_NAME:{this._stateDoctypeName(s);break}case De.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(s);break}case De.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(s);break}case De.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(s);break}case De.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(s);break}case De.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(s);break}case De.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(s);break}case De.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(s);break}case De.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(s);break}case De.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(s);break}case De.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(s);break}case De.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(s);break}case De.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(s);break}case De.BOGUS_DOCTYPE:{this._stateBogusDoctype(s);break}case De.CDATA_SECTION:{this._stateCdataSection(s);break}case De.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(s);break}case De.CDATA_SECTION_END:{this._stateCdataSectionEnd(s);break}case De.CHARACTER_REFERENCE:{this._stateCharacterReference(s);break}case De.NAMED_CHARACTER_REFERENCE:{this._stateNamedCharacterReference(s);break}case De.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(s);break}case De.NUMERIC_CHARACTER_REFERENCE:{this._stateNumericCharacterReference(s);break}case De.HEXADEMICAL_CHARACTER_REFERENCE_START:{this._stateHexademicalCharacterReferenceStart(s);break}case De.HEXADEMICAL_CHARACTER_REFERENCE:{this._stateHexademicalCharacterReference(s);break}case De.DECIMAL_CHARACTER_REFERENCE:{this._stateDecimalCharacterReference(s);break}case De.NUMERIC_CHARACTER_REFERENCE_END:{this._stateNumericCharacterReferenceEnd(s);break}default:throw new Error("Unknown state")}}},{key:"_stateData",value:function(s){switch(s){case we.CODE_POINTS.LESS_THAN_SIGN:{this.state=De.TAG_OPEN;break}case we.CODE_POINTS.AMPERSAND:{this.returnState=De.DATA,this.state=De.CHARACTER_REFERENCE;break}case we.CODE_POINTS.NULL:{this._err(Lt.ERR.unexpectedNullCharacter),this._emitCodePoint(s);break}case we.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(s)}}},{key:"_stateRcdata",value:function(s){switch(s){case we.CODE_POINTS.AMPERSAND:{this.returnState=De.RCDATA,this.state=De.CHARACTER_REFERENCE;break}case we.CODE_POINTS.LESS_THAN_SIGN:{this.state=De.RCDATA_LESS_THAN_SIGN;break}case we.CODE_POINTS.NULL:{this._err(Lt.ERR.unexpectedNullCharacter),this._emitChars(we.REPLACEMENT_CHARACTER);break}case we.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(s)}}},{key:"_stateRawtext",value:function(s){switch(s){case we.CODE_POINTS.LESS_THAN_SIGN:{this.state=De.RAWTEXT_LESS_THAN_SIGN;break}case we.CODE_POINTS.NULL:{this._err(Lt.ERR.unexpectedNullCharacter),this._emitChars(we.REPLACEMENT_CHARACTER);break}case we.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(s)}}},{key:"_stateScriptData",value:function(s){switch(s){case we.CODE_POINTS.LESS_THAN_SIGN:{this.state=De.SCRIPT_DATA_LESS_THAN_SIGN;break}case we.CODE_POINTS.NULL:{this._err(Lt.ERR.unexpectedNullCharacter),this._emitChars(we.REPLACEMENT_CHARACTER);break}case we.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(s)}}},{key:"_statePlaintext",value:function(s){switch(s){case we.CODE_POINTS.NULL:{this._err(Lt.ERR.unexpectedNullCharacter),this._emitChars(we.REPLACEMENT_CHARACTER);break}case we.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(s)}}},{key:"_stateTagOpen",value:function(s){if(vm(s))this._createStartTagToken(),this.state=De.TAG_NAME,this._stateTagName(s);else switch(s){case we.CODE_POINTS.EXCLAMATION_MARK:{this.state=De.MARKUP_DECLARATION_OPEN;break}case we.CODE_POINTS.SOLIDUS:{this.state=De.END_TAG_OPEN;break}case we.CODE_POINTS.QUESTION_MARK:{this._err(Lt.ERR.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=De.BOGUS_COMMENT,this._stateBogusComment(s);break}case we.CODE_POINTS.EOF:{this._err(Lt.ERR.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(Lt.ERR.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=De.DATA,this._stateData(s)}}},{key:"_stateEndTagOpen",value:function(s){if(vm(s))this._createEndTagToken(),this.state=De.TAG_NAME,this._stateTagName(s);else switch(s){case we.CODE_POINTS.GREATER_THAN_SIGN:{this._err(Lt.ERR.missingEndTagName),this.state=De.DATA;break}case we.CODE_POINTS.EOF:{this._err(Lt.ERR.eofBeforeTagName),this._emitChars("");break}case we.CODE_POINTS.NULL:{this._err(Lt.ERR.unexpectedNullCharacter),this.state=De.SCRIPT_DATA_ESCAPED,this._emitChars(we.REPLACEMENT_CHARACTER);break}case we.CODE_POINTS.EOF:{this._err(Lt.ERR.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=De.SCRIPT_DATA_ESCAPED,this._emitCodePoint(s)}}},{key:"_stateScriptDataEscapedLessThanSign",value:function(s){s===we.CODE_POINTS.SOLIDUS?this.state=De.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:vm(s)?(this._emitChars("<"),this.state=De.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(s)):(this._emitChars("<"),this.state=De.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(s))}},{key:"_stateScriptDataEscapedEndTagOpen",value:function(s){vm(s)?(this.state=De.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(s)):(this._emitChars("");break}case we.CODE_POINTS.NULL:{this._err(Lt.ERR.unexpectedNullCharacter),this.state=De.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(we.REPLACEMENT_CHARACTER);break}case we.CODE_POINTS.EOF:{this._err(Lt.ERR.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=De.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(s)}}},{key:"_stateScriptDataDoubleEscapedLessThanSign",value:function(s){s===we.CODE_POINTS.SOLIDUS?(this.state=De.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=De.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(s))}},{key:"_stateScriptDataDoubleEscapeEnd",value:function(s){if(this.preprocessor.startsWith(we.SEQUENCES.SCRIPT,!1)&&WVe(this.preprocessor.peek(we.SEQUENCES.SCRIPT.length))){this._emitCodePoint(s);for(let C=0;C1114111)this._err(Lt.ERR.characterReferenceOutsideUnicodeRange),this.charRefCode=we.CODE_POINTS.REPLACEMENT_CHARACTER;else if((0,we.isSurrogate)(this.charRefCode))this._err(Lt.ERR.surrogateCharacterReference),this.charRefCode=we.CODE_POINTS.REPLACEMENT_CHARACTER;else if((0,we.isUndefinedCodePoint)(this.charRefCode))this._err(Lt.ERR.noncharacterCharacterReference);else if((0,we.isControlCodePoint)(this.charRefCode)||this.charRefCode===we.CODE_POINTS.CARRIAGE_RETURN){this._err(Lt.ERR.controlCharacterReference);const C=FXt.get(this.charRefCode);C!==void 0&&(this.charRefCode=C)}this._flushCodePointConsumedAsCharacterReference(this.charRefCode),this._reconsumeInState(this.returnState,s)}}]),g}();Nb.Tokenizer=PXt;var Z5={};Object.defineProperty(Z5,"__esModule",{value:!0}),Z5.OpenElementStack=void 0;const Qt=lh,NVe=new Set([Qt.TAG_ID.DD,Qt.TAG_ID.DT,Qt.TAG_ID.LI,Qt.TAG_ID.OPTGROUP,Qt.TAG_ID.OPTION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UXt=[Qt.TAG_ID.TD,Qt.TAG_ID.TH];let QXt=function(){function g(a,s,C){T(this,g),this.treeAdapter=s,this.handler=C,this.items=[],this.tagIDs=[],this.stackTop=-1,this.tmplCount=0,this.currentTagId=Qt.TAG_ID.UNKNOWN,this.current=a}return E(g,[{key:"currentTmplContentOrNode",get:function(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}},{key:"_indexOf",value:function(s){return this.items.lastIndexOf(s,this.stackTop)}},{key:"_isInTemplate",value:function(){return this.currentTagId===Qt.TAG_ID.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===Qt.NS.HTML}},{key:"_updateCurrentElement",value:function(){this.current=this.items[this.stackTop],this.currentTagId=this.tagIDs[this.stackTop]}},{key:"push",value:function(s,C){this.stackTop++,this.items[this.stackTop]=s,this.current=s,this.tagIDs[this.stackTop]=C,this.currentTagId=C,this._isInTemplate()&&this.tmplCount++,this.handler.onItemPush(s,C,!0)}},{key:"pop",value:function(){const s=this.current;this.tmplCount>0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(s,!0)}},{key:"replace",value:function(s,C){const I=this._indexOf(s);this.items[I]=C,I===this.stackTop&&(this.current=C)}},{key:"insertAfter",value:function(s,C,I){const A=this._indexOf(s)+1;this.items.splice(A,0,C),this.tagIDs.splice(A,0,I),this.stackTop++,A===this.stackTop&&this._updateCurrentElement(),this.handler.onItemPush(this.current,this.currentTagId,A===this.stackTop)}},{key:"popUntilTagNamePopped",value:function(s){let C=this.stackTop+1;do C=this.tagIDs.lastIndexOf(s,C-1);while(C>0&&this.treeAdapter.getNamespaceURI(this.items[C])!==Qt.NS.HTML);this.shortenToLength(C<0?0:C)}},{key:"shortenToLength",value:function(s){for(;this.stackTop>=s;){const C=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(C,this.stackTop=0;I--)if(s.includes(this.tagIDs[I])&&this.treeAdapter.getNamespaceURI(this.items[I])===C)return I;return-1}},{key:"clearBackTo",value:function(s,C){const I=this._indexOfTagNames(s,C);this.shortenToLength(I+1)}},{key:"clearBackToTableContext",value:function(){this.clearBackTo(JXt,Qt.NS.HTML)}},{key:"clearBackToTableBodyContext",value:function(){this.clearBackTo(LXt,Qt.NS.HTML)}},{key:"clearBackToTableRowContext",value:function(){this.clearBackTo(OXt,Qt.NS.HTML)}},{key:"remove",value:function(s){const C=this._indexOf(s);C>=0&&(C===this.stackTop?this.pop():(this.items.splice(C,1),this.tagIDs.splice(C,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(s,!1)))}},{key:"tryPeekProperlyNestedBodyElement",value:function(){return this.stackTop>=1&&this.tagIDs[1]===Qt.TAG_ID.BODY?this.items[1]:null}},{key:"contains",value:function(s){return this._indexOf(s)>-1}},{key:"getCommonAncestor",value:function(s){const C=this._indexOf(s)-1;return C>=0?this.items[C]:null}},{key:"isRootHtmlElementCurrent",value:function(){return this.stackTop===0&&this.tagIDs[0]===Qt.TAG_ID.HTML}},{key:"hasInScope",value:function(s){for(let C=this.stackTop;C>=0;C--){const I=this.tagIDs[C],A=this.treeAdapter.getNamespaceURI(this.items[C]);if(I===s&&A===Qt.NS.HTML)return!0;if(B5.get(I)===A)return!1}return!0}},{key:"hasNumberedHeaderInScope",value:function(){for(let s=this.stackTop;s>=0;s--){const C=this.tagIDs[s],I=this.treeAdapter.getNamespaceURI(this.items[s]);if((0,Qt.isNumberedHeader)(C)&&I===Qt.NS.HTML)return!0;if(B5.get(C)===I)return!1}return!0}},{key:"hasInListItemScope",value:function(s){for(let C=this.stackTop;C>=0;C--){const I=this.tagIDs[C],A=this.treeAdapter.getNamespaceURI(this.items[C]);if(I===s&&A===Qt.NS.HTML)return!0;if((I===Qt.TAG_ID.UL||I===Qt.TAG_ID.OL)&&A===Qt.NS.HTML||B5.get(I)===A)return!1}return!0}},{key:"hasInButtonScope",value:function(s){for(let C=this.stackTop;C>=0;C--){const I=this.tagIDs[C],A=this.treeAdapter.getNamespaceURI(this.items[C]);if(I===s&&A===Qt.NS.HTML)return!0;if(I===Qt.TAG_ID.BUTTON&&A===Qt.NS.HTML||B5.get(I)===A)return!1}return!0}},{key:"hasInTableScope",value:function(s){for(let C=this.stackTop;C>=0;C--){const I=this.tagIDs[C];if(this.treeAdapter.getNamespaceURI(this.items[C])===Qt.NS.HTML){if(I===s)return!0;if(I===Qt.TAG_ID.TABLE||I===Qt.TAG_ID.TEMPLATE||I===Qt.TAG_ID.HTML)return!1}}return!0}},{key:"hasTableBodyContextInTableScope",value:function(){for(let s=this.stackTop;s>=0;s--){const C=this.tagIDs[s];if(this.treeAdapter.getNamespaceURI(this.items[s])===Qt.NS.HTML){if(C===Qt.TAG_ID.TBODY||C===Qt.TAG_ID.THEAD||C===Qt.TAG_ID.TFOOT)return!0;if(C===Qt.TAG_ID.TABLE||C===Qt.TAG_ID.HTML)return!1}}return!0}},{key:"hasInSelectScope",value:function(s){for(let C=this.stackTop;C>=0;C--){const I=this.tagIDs[C];if(this.treeAdapter.getNamespaceURI(this.items[C])===Qt.NS.HTML){if(I===s)return!0;if(I!==Qt.TAG_ID.OPTION&&I!==Qt.TAG_ID.OPTGROUP)return!1}}return!0}},{key:"generateImpliedEndTags",value:function(){for(;NVe.has(this.currentTagId);)this.pop()}},{key:"generateImpliedEndTagsThoroughly",value:function(){for(;kVe.has(this.currentTagId);)this.pop()}},{key:"generateImpliedEndTagsWithExclusion",value:function(s){for(;this.currentTagId!==s&&kVe.has(this.currentTagId);)this.pop()}}]),g}();Z5.OpenElementStack=QXt;var XVe={};(function(g){Object.defineProperty(g,"__esModule",{value:!0}),g.FormattingElementList=g.EntryType=void 0;const a=3;var s;(function(A){A[A.Marker=0]="Marker",A[A.Element=1]="Element"})(s=g.EntryType||(g.EntryType={}));const C={type:s.Marker};let I=function(){function A(d){T(this,A),this.treeAdapter=d,this.entries=[],this.bookmark=null}return E(A,[{key:"_getNoahArkConditionCandidates",value:function(h,y){const Z=[],b=y.length,w=this.treeAdapter.getTagName(h),S=this.treeAdapter.getNamespaceURI(h);for(let R=0;R[S.name,S.value]));let w=0;for(let S=0;Sb.get(H.name)===H.value)&&(w+=1,w>=a&&this.entries.splice(R.idx,1))}}},{key:"insertMarker",value:function(){this.entries.unshift(C)}},{key:"pushElement",value:function(h,y){this._ensureNoahArkCondition(h),this.entries.unshift({type:s.Element,element:h,token:y})}},{key:"insertElementAfterBookmark",value:function(h,y){const Z=this.entries.indexOf(this.bookmark);this.entries.splice(Z,0,{type:s.Element,element:h,token:y})}},{key:"removeEntry",value:function(h){const y=this.entries.indexOf(h);y>=0&&this.entries.splice(y,1)}},{key:"clearToLastMarker",value:function(){const h=this.entries.indexOf(C);h>=0?this.entries.splice(0,h+1):this.entries.length=0}},{key:"getElementEntryInScopeWithTagName",value:function(h){const y=this.entries.find(Z=>Z.type===s.Marker||this.treeAdapter.getTagName(Z.element)===h);return y&&y.type===s.Element?y:null}},{key:"getElementEntry",value:function(h){return this.entries.find(y=>y.type===s.Element&&y.element===h)}}]),A}();g.FormattingElementList=I})(XVe);var G5={};(function(g){Object.defineProperty(g,"__esModule",{value:!0}),g.defaultTreeAdapter=void 0;const a=lh;function s(C){return{nodeName:"#text",value:C,parentNode:null}}g.defaultTreeAdapter={createDocument(){return{nodeName:"#document",mode:a.DOCUMENT_MODE.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:"#document-fragment",childNodes:[]}},createElement(C,I,A){return{nodeName:C,tagName:C,attrs:A,namespaceURI:I,childNodes:[],parentNode:null}},createCommentNode(C){return{nodeName:"#comment",data:C,parentNode:null}},appendChild(C,I){C.childNodes.push(I),I.parentNode=C},insertBefore(C,I,A){const d=C.childNodes.indexOf(A);C.childNodes.splice(d,0,I),I.parentNode=C},setTemplateContent(C,I){C.content=I},getTemplateContent(C){return C.content},setDocumentType(C,I,A,d){const h=C.childNodes.find(y=>y.nodeName==="#documentType");if(h)h.name=I,h.publicId=A,h.systemId=d;else{const y={nodeName:"#documentType",name:I,publicId:A,systemId:d,parentNode:null};g.defaultTreeAdapter.appendChild(C,y)}},setDocumentMode(C,I){C.mode=I},getDocumentMode(C){return C.mode},detachNode(C){if(C.parentNode){const I=C.parentNode.childNodes.indexOf(C);C.parentNode.childNodes.splice(I,1),C.parentNode=null}},insertText(C,I){if(C.childNodes.length>0){const A=C.childNodes[C.childNodes.length-1];if(g.defaultTreeAdapter.isTextNode(A)){A.value+=I;return}}g.defaultTreeAdapter.appendChild(C,s(I))},insertTextBefore(C,I,A){const d=C.childNodes[C.childNodes.indexOf(A)-1];d&&g.defaultTreeAdapter.isTextNode(d)?d.value+=I:g.defaultTreeAdapter.insertBefore(C,s(I),A)},adoptAttributes(C,I){const A=new Set(C.attrs.map(d=>d.name));for(let d=0;dg.startsWith(s))}function ixt(g){return g.name===xVe&&g.publicId===null&&(g.systemId===null||g.systemId===jXt)}XB.isConforming=ixt;function nxt(g){if(g.name!==xVe)return xB.DOCUMENT_MODE.QUIRKS;const{systemId:a}=g;if(a&&a.toLowerCase()===$Xt)return xB.DOCUMENT_MODE.QUIRKS;let{publicId:s}=g;if(s!==null){if(s=s.toLowerCase(),ext.has(s))return xB.DOCUMENT_MODE.QUIRKS;let C=a===null?qXt:DVe;if(FVe(s,C))return xB.DOCUMENT_MODE.QUIRKS;if(C=a===null?MVe:txt,FVe(s,C))return xB.DOCUMENT_MODE.LIMITED_QUIRKS}return xB.DOCUMENT_MODE.NO_QUIRKS}XB.getDocumentMode=nxt;var e$={};(function(g){Object.defineProperty(g,"__esModule",{value:!0}),g.isIntegrationPoint=g.adjustTokenSVGTagName=g.adjustTokenXMLAttrs=g.adjustTokenSVGAttrs=g.adjustTokenMathMLAttrs=g.causesExit=g.SVG_TAG_NAMES_ADJUSTMENT_MAP=void 0;const a=lh,s={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},C="definitionurl",I="definitionURL",A=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map(D=>[D.toLowerCase(),D])),d=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:a.NS.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:a.NS.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:a.NS.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:a.NS.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:a.NS.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:a.NS.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:a.NS.XLINK}],["xml:base",{prefix:"xml",name:"base",namespace:a.NS.XML}],["xml:lang",{prefix:"xml",name:"lang",namespace:a.NS.XML}],["xml:space",{prefix:"xml",name:"space",namespace:a.NS.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:a.NS.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:a.NS.XMLNS}]]);g.SVG_TAG_NAMES_ADJUSTMENT_MAP=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map(D=>[D.toLowerCase(),D]));const h=new Set([a.TAG_ID.B,a.TAG_ID.BIG,a.TAG_ID.BLOCKQUOTE,a.TAG_ID.BODY,a.TAG_ID.BR,a.TAG_ID.CENTER,a.TAG_ID.CODE,a.TAG_ID.DD,a.TAG_ID.DIV,a.TAG_ID.DL,a.TAG_ID.DT,a.TAG_ID.EM,a.TAG_ID.EMBED,a.TAG_ID.H1,a.TAG_ID.H2,a.TAG_ID.H3,a.TAG_ID.H4,a.TAG_ID.H5,a.TAG_ID.H6,a.TAG_ID.HEAD,a.TAG_ID.HR,a.TAG_ID.I,a.TAG_ID.IMG,a.TAG_ID.LI,a.TAG_ID.LISTING,a.TAG_ID.MENU,a.TAG_ID.META,a.TAG_ID.NOBR,a.TAG_ID.OL,a.TAG_ID.P,a.TAG_ID.PRE,a.TAG_ID.RUBY,a.TAG_ID.S,a.TAG_ID.SMALL,a.TAG_ID.SPAN,a.TAG_ID.STRONG,a.TAG_ID.STRIKE,a.TAG_ID.SUB,a.TAG_ID.SUP,a.TAG_ID.TABLE,a.TAG_ID.TT,a.TAG_ID.U,a.TAG_ID.UL,a.TAG_ID.VAR]);function y(D){const M=D.tagID;return M===a.TAG_ID.FONT&&D.attrs.some(({name:K})=>K===a.ATTRS.COLOR||K===a.ATTRS.SIZE||K===a.ATTRS.FACE)||h.has(M)}g.causesExit=y;function Z(D){for(let M=0;M0&&this._setContextModes(s,C)}},{key:"onItemPop",value:function(s,C){var I,A;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(s,this.currentToken),(A=(I=this.treeAdapter).onItemPop)===null||A===void 0||A.call(I,s,this.openElements.current),C){let d,h;this.openElements.stackTop===0&&this.fragmentContext?(d=this.fragmentContext,h=this.fragmentContextID):{current:d,currentTagId:h}=this.openElements,this._setContextModes(d,h)}}},{key:"_setContextModes",value:function(s,C){const I=s===this.document||this.treeAdapter.getNamespaceURI(s)===ae.NS.HTML;this.currentNotInHTML=!I,this.tokenizer.inForeignNode=!I&&!this._isIntegrationPoint(C,s)}},{key:"_switchToTextParsing",value:function(s,C){this._insertElement(s,ae.NS.HTML),this.tokenizer.state=C,this.originalInsertionMode=this.insertionMode,this.insertionMode=et.TEXT}},{key:"switchToPlaintextParsing",value:function(){this.insertionMode=et.TEXT,this.originalInsertionMode=et.IN_BODY,this.tokenizer.state=js.TokenizerMode.PLAINTEXT}},{key:"_getAdjustedCurrentElement",value:function(){return this.openElements.stackTop===0&&this.fragmentContext?this.fragmentContext:this.openElements.current}},{key:"_findFormInFragmentContext",value:function(){let s=this.fragmentContext;for(;s;){if(this.treeAdapter.getTagName(s)===ae.TAG_NAMES.FORM){this.formElement=s;break}s=this.treeAdapter.getParentNode(s)}}},{key:"_initTokenizerForFragmentParsing",value:function(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==ae.NS.HTML))switch(this.fragmentContextID){case ae.TAG_ID.TITLE:case ae.TAG_ID.TEXTAREA:{this.tokenizer.state=js.TokenizerMode.RCDATA;break}case ae.TAG_ID.STYLE:case ae.TAG_ID.XMP:case ae.TAG_ID.IFRAME:case ae.TAG_ID.NOEMBED:case ae.TAG_ID.NOFRAMES:case ae.TAG_ID.NOSCRIPT:{this.tokenizer.state=js.TokenizerMode.RAWTEXT;break}case ae.TAG_ID.SCRIPT:{this.tokenizer.state=js.TokenizerMode.SCRIPT_DATA;break}case ae.TAG_ID.PLAINTEXT:{this.tokenizer.state=js.TokenizerMode.PLAINTEXT;break}}}},{key:"_setDocumentType",value:function(s){const C=s.name||"",I=s.publicId||"",A=s.systemId||"";if(this.treeAdapter.setDocumentType(this.document,C,I,A),s.location){const h=this.treeAdapter.getChildNodes(this.document).find(y=>this.treeAdapter.isDocumentTypeNode(y));h&&this.treeAdapter.setNodeSourceCodeLocation(h,s.location)}}},{key:"_attachElementToTree",value:function(s,C){if(this.options.sourceCodeLocationInfo){const I=C&&Object.assign(Object.assign({},C),{startTag:C});this.treeAdapter.setNodeSourceCodeLocation(s,I)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(s);else{const I=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(I,s)}}},{key:"_appendElement",value:function(s,C){const I=this.treeAdapter.createElement(s.tagName,C,s.attrs);this._attachElementToTree(I,s.location)}},{key:"_insertElement",value:function(s,C){const I=this.treeAdapter.createElement(s.tagName,C,s.attrs);this._attachElementToTree(I,s.location),this.openElements.push(I,s.tagID)}},{key:"_insertFakeElement",value:function(s,C){const I=this.treeAdapter.createElement(s,ae.NS.HTML,[]);this._attachElementToTree(I,null),this.openElements.push(I,C)}},{key:"_insertTemplate",value:function(s){const C=this.treeAdapter.createElement(s.tagName,ae.NS.HTML,s.attrs),I=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(C,I),this._attachElementToTree(C,s.location),this.openElements.push(C,s.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(I,null)}},{key:"_insertFakeRootElement",value:function(){const s=this.treeAdapter.createElement(ae.TAG_NAMES.HTML,ae.NS.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(s,null),this.treeAdapter.appendChild(this.openElements.current,s),this.openElements.push(s,ae.TAG_ID.HTML)}},{key:"_appendCommentNode",value:function(s,C){const I=this.treeAdapter.createCommentNode(s.data);this.treeAdapter.appendChild(C,I),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(I,s.location)}},{key:"_insertCharacters",value:function(s){let C,I;if(this._shouldFosterParentOnInsertion()?({parent:C,beforeElement:I}=this._findFosterParentingLocation(),I?this.treeAdapter.insertTextBefore(C,s.chars,I):this.treeAdapter.insertText(C,s.chars)):(C=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(C,s.chars)),!s.location)return;const A=this.treeAdapter.getChildNodes(C),d=I?A.lastIndexOf(I):A.length,h=A[d-1];if(this.treeAdapter.getNodeSourceCodeLocation(h)){const{endLine:Z,endCol:b,endOffset:w}=s.location;this.treeAdapter.updateNodeSourceCodeLocation(h,{endLine:Z,endCol:b,endOffset:w})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(h,s.location)}},{key:"_adoptNodes",value:function(s,C){for(let I=this.treeAdapter.getFirstChild(s);I;I=this.treeAdapter.getFirstChild(s))this.treeAdapter.detachNode(I),this.treeAdapter.appendChild(C,I)}},{key:"_setEndLocation",value:function(s,C){if(this.treeAdapter.getNodeSourceCodeLocation(s)&&C.location){const I=C.location,A=this.treeAdapter.getTagName(s),d=C.type===Yo.TokenType.END_TAG&&A===C.tagName?{endTag:Object.assign({},I),endLine:I.endLine,endCol:I.endCol,endOffset:I.endOffset}:{endLine:I.startLine,endCol:I.startCol,endOffset:I.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(s,d)}}},{key:"shouldProcessStartTagTokenInForeignContent",value:function(s){if(!this.currentNotInHTML)return!1;let C,I;return this.openElements.stackTop===0&&this.fragmentContext?(C=this.fragmentContext,I=this.fragmentContextID):{current:C,currentTagId:I}=this.openElements,s.tagID===ae.TAG_ID.SVG&&this.treeAdapter.getTagName(C)===ae.TAG_NAMES.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(C)===ae.NS.MATHML?!1:this.tokenizer.inForeignNode||(s.tagID===ae.TAG_ID.MGLYPH||s.tagID===ae.TAG_ID.MALIGNMARK)&&!this._isIntegrationPoint(I,C,ae.NS.HTML)}},{key:"_processToken",value:function(s){switch(s.type){case Yo.TokenType.CHARACTER:{this.onCharacter(s);break}case Yo.TokenType.NULL_CHARACTER:{this.onNullCharacter(s);break}case Yo.TokenType.COMMENT:{this.onComment(s);break}case Yo.TokenType.DOCTYPE:{this.onDoctype(s);break}case Yo.TokenType.START_TAG:{this._processStartTag(s);break}case Yo.TokenType.END_TAG:{this.onEndTag(s);break}case Yo.TokenType.EOF:{this.onEof(s);break}case Yo.TokenType.WHITESPACE_CHARACTER:{this.onWhitespaceCharacter(s);break}}}},{key:"_isIntegrationPoint",value:function(s,C,I){const A=this.treeAdapter.getNamespaceURI(C),d=this.treeAdapter.getAttrList(C);return mu.isIntegrationPoint(s,A,d,I)}},{key:"_reconstructActiveFormattingElements",value:function(){const s=this.activeFormattingElements.entries.length;if(s){const C=this.activeFormattingElements.entries.findIndex(A=>A.type===YVe.EntryType.Marker||this.openElements.contains(A.element)),I=C<0?s-1:C-1;for(let A=I;A>=0;A--){const d=this.activeFormattingElements.entries[A];this._insertElement(d.token,this.treeAdapter.getNamespaceURI(d.element)),d.element=this.openElements.current}}}},{key:"_closeTableCell",value:function(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=et.IN_ROW}},{key:"_closePElement",value:function(){this.openElements.generateImpliedEndTagsWithExclusion(ae.TAG_ID.P),this.openElements.popUntilTagNamePopped(ae.TAG_ID.P)}},{key:"_resetInsertionMode",value:function(){for(let s=this.openElements.stackTop;s>=0;s--)switch(s===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[s]){case ae.TAG_ID.TR:{this.insertionMode=et.IN_ROW;return}case ae.TAG_ID.TBODY:case ae.TAG_ID.THEAD:case ae.TAG_ID.TFOOT:{this.insertionMode=et.IN_TABLE_BODY;return}case ae.TAG_ID.CAPTION:{this.insertionMode=et.IN_CAPTION;return}case ae.TAG_ID.COLGROUP:{this.insertionMode=et.IN_COLUMN_GROUP;return}case ae.TAG_ID.TABLE:{this.insertionMode=et.IN_TABLE;return}case ae.TAG_ID.BODY:{this.insertionMode=et.IN_BODY;return}case ae.TAG_ID.FRAMESET:{this.insertionMode=et.IN_FRAMESET;return}case ae.TAG_ID.SELECT:{this._resetInsertionModeForSelect(s);return}case ae.TAG_ID.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case ae.TAG_ID.HTML:{this.insertionMode=this.headElement?et.AFTER_HEAD:et.BEFORE_HEAD;return}case ae.TAG_ID.TD:case ae.TAG_ID.TH:{if(s>0){this.insertionMode=et.IN_CELL;return}break}case ae.TAG_ID.HEAD:{if(s>0){this.insertionMode=et.IN_HEAD;return}break}}this.insertionMode=et.IN_BODY}},{key:"_resetInsertionModeForSelect",value:function(s){if(s>0)for(let C=s-1;C>0;C--){const I=this.openElements.tagIDs[C];if(I===ae.TAG_ID.TEMPLATE)break;if(I===ae.TAG_ID.TABLE){this.insertionMode=et.IN_SELECT_IN_TABLE;return}}this.insertionMode=et.IN_SELECT}},{key:"_isElementCausesFosterParenting",value:function(s){return PVe.has(s)}},{key:"_shouldFosterParentOnInsertion",value:function(){return this.fosterParentingEnabled&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}},{key:"_findFosterParentingLocation",value:function(){for(let s=this.openElements.stackTop;s>=0;s--){const C=this.openElements.items[s];switch(this.openElements.tagIDs[s]){case ae.TAG_ID.TEMPLATE:{if(this.treeAdapter.getNamespaceURI(C)===ae.NS.HTML)return{parent:this.treeAdapter.getTemplateContent(C),beforeElement:null};break}case ae.TAG_ID.TABLE:{const I=this.treeAdapter.getParentNode(C);return I?{parent:I,beforeElement:C}:{parent:this.openElements.items[s-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}},{key:"_fosterParentElement",value:function(s){const C=this._findFosterParentingLocation();C.beforeElement?this.treeAdapter.insertBefore(C.parent,s,C.beforeElement):this.treeAdapter.appendChild(C.parent,s)}},{key:"_isSpecialElement",value:function(s,C){const I=this.treeAdapter.getNamespaceURI(s);return ae.SPECIAL_ELEMENTS[I].has(C)}},{key:"onCharacter",value:function(s){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){FDt(this,s);return}switch(this.insertionMode){case et.INITIAL:{tV(this,s);break}case et.BEFORE_HTML:{iV(this,s);break}case et.BEFORE_HEAD:{nV(this,s);break}case et.IN_HEAD:{rV(this,s);break}case et.IN_HEAD_NO_SCRIPT:{gV(this,s);break}case et.AFTER_HEAD:{oV(this,s);break}case et.IN_BODY:case et.IN_CAPTION:case et.IN_CELL:case et.IN_TEMPLATE:{LVe(this,s);break}case et.TEXT:case et.IN_SELECT:case et.IN_SELECT_IN_TABLE:{this._insertCharacters(s);break}case et.IN_TABLE:case et.IN_TABLE_BODY:case et.IN_ROW:{r$(this,s);break}case et.IN_TABLE_TEXT:{t9e(this,s);break}case et.IN_COLUMN_GROUP:{T5(this,s);break}case et.AFTER_BODY:{E5(this,s);break}case et.AFTER_AFTER_BODY:{H5(this,s);break}}}},{key:"onNullCharacter",value:function(s){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){MDt(this,s);return}switch(this.insertionMode){case et.INITIAL:{tV(this,s);break}case et.BEFORE_HTML:{iV(this,s);break}case et.BEFORE_HEAD:{nV(this,s);break}case et.IN_HEAD:{rV(this,s);break}case et.IN_HEAD_NO_SCRIPT:{gV(this,s);break}case et.AFTER_HEAD:{oV(this,s);break}case et.TEXT:{this._insertCharacters(s);break}case et.IN_TABLE:case et.IN_TABLE_BODY:case et.IN_ROW:{r$(this,s);break}case et.IN_COLUMN_GROUP:{T5(this,s);break}case et.AFTER_BODY:{E5(this,s);break}case et.AFTER_AFTER_BODY:{H5(this,s);break}}}},{key:"onComment",value:function(s){if(this.skipNextNewLine=!1,this.currentNotInHTML){i$(this,s);return}switch(this.insertionMode){case et.INITIAL:case et.BEFORE_HTML:case et.BEFORE_HEAD:case et.IN_HEAD:case et.IN_HEAD_NO_SCRIPT:case et.AFTER_HEAD:case et.IN_BODY:case et.IN_TABLE:case et.IN_CAPTION:case et.IN_COLUMN_GROUP:case et.IN_TABLE_BODY:case et.IN_ROW:case et.IN_CELL:case et.IN_SELECT:case et.IN_SELECT_IN_TABLE:case et.IN_TEMPLATE:case et.IN_FRAMESET:case et.AFTER_FRAMESET:{i$(this,s);break}case et.IN_TABLE_TEXT:{IV(this,s);break}case et.AFTER_BODY:{fxt(this,s);break}case et.AFTER_AFTER_BODY:case et.AFTER_AFTER_FRAMESET:{mxt(this,s);break}}}},{key:"onDoctype",value:function(s){switch(this.skipNextNewLine=!1,this.insertionMode){case et.INITIAL:{pxt(this,s);break}case et.BEFORE_HEAD:case et.IN_HEAD:case et.IN_HEAD_NO_SCRIPT:case et.AFTER_HEAD:{this._err(s,Ba.ERR.misplacedDoctype);break}case et.IN_TABLE_TEXT:{IV(this,s);break}}}},{key:"onStartTag",value:function(s){this.skipNextNewLine=!1,this.currentToken=s,this._processStartTag(s),s.selfClosing&&!s.ackSelfClosing&&this._err(s,Ba.ERR.nonVoidHtmlElementStartTagWithTrailingSolidus)}},{key:"_processStartTag",value:function(s){this.shouldProcessStartTagTokenInForeignContent(s)?YDt(this,s):this._startTagOutsideForeignContent(s)}},{key:"_startTagOutsideForeignContent",value:function(s){switch(this.insertionMode){case et.INITIAL:{tV(this,s);break}case et.BEFORE_HTML:{bxt(this,s);break}case et.BEFORE_HEAD:{vxt(this,s);break}case et.IN_HEAD:{Zc(this,s);break}case et.IN_HEAD_NO_SCRIPT:{Gxt(this,s);break}case et.AFTER_HEAD:{wxt(this,s);break}case et.IN_BODY:{ns(this,s);break}case et.IN_TABLE:{DB(this,s);break}case et.IN_TABLE_TEXT:{IV(this,s);break}case et.IN_CAPTION:{ZDt(this,s);break}case et.IN_COLUMN_GROUP:{g$(this,s);break}case et.IN_TABLE_BODY:{R5(this,s);break}case et.IN_ROW:{V5(this,s);break}case et.IN_CELL:{SDt(this,s);break}case et.IN_SELECT:{r9e(this,s);break}case et.IN_SELECT_IN_TABLE:{TDt(this,s);break}case et.IN_TEMPLATE:{VDt(this,s);break}case et.AFTER_BODY:{HDt(this,s);break}case et.IN_FRAMESET:{WDt(this,s);break}case et.AFTER_FRAMESET:{kDt(this,s);break}case et.AFTER_AFTER_BODY:{xDt(this,s);break}case et.AFTER_AFTER_FRAMESET:{DDt(this,s);break}}}},{key:"onEndTag",value:function(s){this.skipNextNewLine=!1,this.currentToken=s,this.currentNotInHTML?KDt(this,s):this._endTagOutsideForeignContent(s)}},{key:"_endTagOutsideForeignContent",value:function(s){switch(this.insertionMode){case et.INITIAL:{tV(this,s);break}case et.BEFORE_HTML:{yxt(this,s);break}case et.BEFORE_HEAD:{Zxt(this,s);break}case et.IN_HEAD:{Bxt(this,s);break}case et.IN_HEAD_NO_SCRIPT:{Sxt(this,s);break}case et.AFTER_HEAD:{Txt(this,s);break}case et.IN_BODY:{w5(this,s);break}case et.TEXT:{ADt(this,s);break}case et.IN_TABLE:{aV(this,s);break}case et.IN_TABLE_TEXT:{IV(this,s);break}case et.IN_CAPTION:{BDt(this,s);break}case et.IN_COLUMN_GROUP:{GDt(this,s);break}case et.IN_TABLE_BODY:{o$(this,s);break}case et.IN_ROW:{n9e(this,s);break}case et.IN_CELL:{wDt(this,s);break}case et.IN_SELECT:{g9e(this,s);break}case et.IN_SELECT_IN_TABLE:{RDt(this,s);break}case et.IN_TEMPLATE:{EDt(this,s);break}case et.AFTER_BODY:{a9e(this,s);break}case et.IN_FRAMESET:{NDt(this,s);break}case et.AFTER_FRAMESET:{XDt(this,s);break}case et.AFTER_AFTER_BODY:{H5(this,s);break}}}},{key:"onEof",value:function(s){switch(this.insertionMode){case et.INITIAL:{tV(this,s);break}case et.BEFORE_HTML:{iV(this,s);break}case et.BEFORE_HEAD:{nV(this,s);break}case et.IN_HEAD:{rV(this,s);break}case et.IN_HEAD_NO_SCRIPT:{gV(this,s);break}case et.AFTER_HEAD:{oV(this,s);break}case et.IN_BODY:case et.IN_TABLE:case et.IN_CAPTION:case et.IN_COLUMN_GROUP:case et.IN_TABLE_BODY:case et.IN_ROW:case et.IN_CELL:case et.IN_SELECT:case et.IN_SELECT_IN_TABLE:{qVe(this,s);break}case et.TEXT:{uDt(this,s);break}case et.IN_TABLE_TEXT:{IV(this,s);break}case et.IN_TEMPLATE:{o9e(this,s);break}case et.AFTER_BODY:case et.IN_FRAMESET:case et.AFTER_FRAMESET:case et.AFTER_AFTER_BODY:case et.AFTER_AFTER_FRAMESET:{n$(this,s);break}}}},{key:"onWhitespaceCharacter",value:function(s){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,s.chars.charCodeAt(0)===_Ve.CODE_POINTS.LINE_FEED)){if(s.chars.length===1)return;s.chars=s.chars.substr(1)}if(this.tokenizer.inForeignNode){this._insertCharacters(s);return}switch(this.insertionMode){case et.IN_HEAD:case et.IN_HEAD_NO_SCRIPT:case et.AFTER_HEAD:case et.TEXT:case et.IN_COLUMN_GROUP:case et.IN_SELECT:case et.IN_SELECT_IN_TABLE:case et.IN_FRAMESET:case et.AFTER_FRAMESET:{this._insertCharacters(s);break}case et.IN_BODY:case et.IN_CAPTION:case et.IN_CELL:case et.IN_TEMPLATE:case et.AFTER_BODY:case et.AFTER_AFTER_BODY:case et.AFTER_AFTER_FRAMESET:{OVe(this,s);break}case et.IN_TABLE:case et.IN_TABLE_BODY:case et.IN_ROW:{r$(this,s);break}case et.IN_TABLE_TEXT:{e9e(this,s);break}}}}],[{key:"parse",value:function(s,C){const I=new this(C);return I.tokenizer.write(s,!0),I.document}},{key:"getFragmentParser",value:function(s,C){const I=Object.assign(Object.assign({},zVe),C);s??(s=I.treeAdapter.createElement(ae.TAG_NAMES.TEMPLATE,ae.NS.HTML,[]));const A=I.treeAdapter.createElement("documentmock",ae.NS.HTML,[]),d=new this(I,A,s);return d.fragmentContextID===ae.TAG_ID.TEMPLATE&&d.tmplInsertionModeStack.unshift(et.IN_TEMPLATE),d._initTokenizerForFragmentParsing(),d._insertFakeRootElement(),d._resetInsertionMode(),d._findFormInFragmentContext(),d}}]),g}();jR.Parser=lxt;function Cxt(g,a){let s=g.activeFormattingElements.getElementEntryInScopeWithTagName(a.tagName);return s?g.openElements.contains(s.element)?g.openElements.hasInScope(a.tagID)||(s=null):(g.activeFormattingElements.removeEntry(s),s=null):$Ve(g,a),s}function cxt(g,a){let s=null,C=g.openElements.stackTop;for(;C>=0;C--){const I=g.openElements.items[C];if(I===a.element)break;g._isSpecialElement(I,g.openElements.tagIDs[C])&&(s=I)}return s||(g.openElements.shortenToLength(C<0?0:C),g.activeFormattingElements.removeEntry(a)),s}function Axt(g,a,s){let C=a,I=g.openElements.getCommonAncestor(a);for(let A=0,d=I;d!==s;A++,d=I){I=g.openElements.getCommonAncestor(d);const h=g.activeFormattingElements.getElementEntry(d),y=h&&A>=sxt;!h||y?(y&&g.activeFormattingElements.removeEntry(h),g.openElements.remove(d)):(d=uxt(g,h),C===a&&(g.activeFormattingElements.bookmark=h),g.treeAdapter.detachNode(C),g.treeAdapter.appendChild(d,C),C=d)}return C}function uxt(g,a){const s=g.treeAdapter.getNamespaceURI(a.element),C=g.treeAdapter.createElement(a.token.tagName,s,a.token.attrs);return g.openElements.replace(a.element,C),a.element=C,C}function dxt(g,a,s){const C=g.treeAdapter.getTagName(a),I=(0,ae.getTagID)(C);if(g._isElementCausesFosterParenting(I))g._fosterParentElement(s);else{const A=g.treeAdapter.getNamespaceURI(a);I===ae.TAG_ID.TEMPLATE&&A===ae.NS.HTML&&(a=g.treeAdapter.getTemplateContent(a)),g.treeAdapter.appendChild(a,s)}}function hxt(g,a,s){const C=g.treeAdapter.getNamespaceURI(s.element),{token:I}=s,A=g.treeAdapter.createElement(I.tagName,C,I.attrs);g._adoptNodes(a,A),g.treeAdapter.appendChild(a,A),g.activeFormattingElements.insertElementAfterBookmark(A,I),g.activeFormattingElements.removeEntry(s),g.openElements.remove(s.element),g.openElements.insertAfter(a,A,I.tagID)}function t$(g,a){for(let s=0;s=s;C--)g._setEndLocation(g.openElements.items[C],a);if(!g.fragmentContext&&g.openElements.stackTop>=0){const C=g.openElements.items[0],I=g.treeAdapter.getNodeSourceCodeLocation(C);if(I&&!I.endTag&&(g._setEndLocation(C,a),g.openElements.stackTop>=1)){const A=g.openElements.items[1],d=g.treeAdapter.getNodeSourceCodeLocation(A);d&&!d.endTag&&g._setEndLocation(A,a)}}}}function pxt(g,a){g._setDocumentType(a);const s=a.forceQuirks?ae.DOCUMENT_MODE.QUIRKS:KVe.getDocumentMode(a);KVe.isConforming(a)||g._err(a,Ba.ERR.nonConformingDoctype),g.treeAdapter.setDocumentMode(g.document,s),g.insertionMode=et.BEFORE_HTML}function tV(g,a){g._err(a,Ba.ERR.missingDoctype,!0),g.treeAdapter.setDocumentMode(g.document,ae.DOCUMENT_MODE.QUIRKS),g.insertionMode=et.BEFORE_HTML,g._processToken(a)}function bxt(g,a){a.tagID===ae.TAG_ID.HTML?(g._insertElement(a,ae.NS.HTML),g.insertionMode=et.BEFORE_HEAD):iV(g,a)}function yxt(g,a){const s=a.tagID;(s===ae.TAG_ID.HTML||s===ae.TAG_ID.HEAD||s===ae.TAG_ID.BODY||s===ae.TAG_ID.BR)&&iV(g,a)}function iV(g,a){g._insertFakeRootElement(),g.insertionMode=et.BEFORE_HEAD,g._processToken(a)}function vxt(g,a){switch(a.tagID){case ae.TAG_ID.HTML:{ns(g,a);break}case ae.TAG_ID.HEAD:{g._insertElement(a,ae.NS.HTML),g.headElement=g.openElements.current,g.insertionMode=et.IN_HEAD;break}default:nV(g,a)}}function Zxt(g,a){const s=a.tagID;s===ae.TAG_ID.HEAD||s===ae.TAG_ID.BODY||s===ae.TAG_ID.HTML||s===ae.TAG_ID.BR?nV(g,a):g._err(a,Ba.ERR.endTagWithoutMatchingOpenElement)}function nV(g,a){g._insertFakeElement(ae.TAG_NAMES.HEAD,ae.TAG_ID.HEAD),g.headElement=g.openElements.current,g.insertionMode=et.IN_HEAD,g._processToken(a)}function Zc(g,a){switch(a.tagID){case ae.TAG_ID.HTML:{ns(g,a);break}case ae.TAG_ID.BASE:case ae.TAG_ID.BASEFONT:case ae.TAG_ID.BGSOUND:case ae.TAG_ID.LINK:case ae.TAG_ID.META:{g._appendElement(a,ae.NS.HTML),a.ackSelfClosing=!0;break}case ae.TAG_ID.TITLE:{g._switchToTextParsing(a,js.TokenizerMode.RCDATA);break}case ae.TAG_ID.NOSCRIPT:{g.options.scriptingEnabled?g._switchToTextParsing(a,js.TokenizerMode.RAWTEXT):(g._insertElement(a,ae.NS.HTML),g.insertionMode=et.IN_HEAD_NO_SCRIPT);break}case ae.TAG_ID.NOFRAMES:case ae.TAG_ID.STYLE:{g._switchToTextParsing(a,js.TokenizerMode.RAWTEXT);break}case ae.TAG_ID.SCRIPT:{g._switchToTextParsing(a,js.TokenizerMode.SCRIPT_DATA);break}case ae.TAG_ID.TEMPLATE:{g._insertTemplate(a),g.activeFormattingElements.insertMarker(),g.framesetOk=!1,g.insertionMode=et.IN_TEMPLATE,g.tmplInsertionModeStack.unshift(et.IN_TEMPLATE);break}case ae.TAG_ID.HEAD:{g._err(a,Ba.ERR.misplacedStartTagForHeadElement);break}default:rV(g,a)}}function Bxt(g,a){switch(a.tagID){case ae.TAG_ID.HEAD:{g.openElements.pop(),g.insertionMode=et.AFTER_HEAD;break}case ae.TAG_ID.BODY:case ae.TAG_ID.BR:case ae.TAG_ID.HTML:{rV(g,a);break}case ae.TAG_ID.TEMPLATE:{kb(g,a);break}default:g._err(a,Ba.ERR.endTagWithoutMatchingOpenElement)}}function kb(g,a){g.openElements.tmplCount>0?(g.openElements.generateImpliedEndTagsThoroughly(),g.openElements.currentTagId!==ae.TAG_ID.TEMPLATE&&g._err(a,Ba.ERR.closingOfElementWithOpenChildElements),g.openElements.popUntilTagNamePopped(ae.TAG_ID.TEMPLATE),g.activeFormattingElements.clearToLastMarker(),g.tmplInsertionModeStack.shift(),g._resetInsertionMode()):g._err(a,Ba.ERR.endTagWithoutMatchingOpenElement)}function rV(g,a){g.openElements.pop(),g.insertionMode=et.AFTER_HEAD,g._processToken(a)}function Gxt(g,a){switch(a.tagID){case ae.TAG_ID.HTML:{ns(g,a);break}case ae.TAG_ID.BASEFONT:case ae.TAG_ID.BGSOUND:case ae.TAG_ID.HEAD:case ae.TAG_ID.LINK:case ae.TAG_ID.META:case ae.TAG_ID.NOFRAMES:case ae.TAG_ID.STYLE:{Zc(g,a);break}case ae.TAG_ID.NOSCRIPT:{g._err(a,Ba.ERR.nestedNoscriptInHead);break}default:gV(g,a)}}function Sxt(g,a){switch(a.tagID){case ae.TAG_ID.NOSCRIPT:{g.openElements.pop(),g.insertionMode=et.IN_HEAD;break}case ae.TAG_ID.BR:{gV(g,a);break}default:g._err(a,Ba.ERR.endTagWithoutMatchingOpenElement)}}function gV(g,a){const s=a.type===Yo.TokenType.EOF?Ba.ERR.openElementsLeftAfterEof:Ba.ERR.disallowedContentInNoscriptInHead;g._err(a,s),g.openElements.pop(),g.insertionMode=et.IN_HEAD,g._processToken(a)}function wxt(g,a){switch(a.tagID){case ae.TAG_ID.HTML:{ns(g,a);break}case ae.TAG_ID.BODY:{g._insertElement(a,ae.NS.HTML),g.framesetOk=!1,g.insertionMode=et.IN_BODY;break}case ae.TAG_ID.FRAMESET:{g._insertElement(a,ae.NS.HTML),g.insertionMode=et.IN_FRAMESET;break}case ae.TAG_ID.BASE:case ae.TAG_ID.BASEFONT:case ae.TAG_ID.BGSOUND:case ae.TAG_ID.LINK:case ae.TAG_ID.META:case ae.TAG_ID.NOFRAMES:case ae.TAG_ID.SCRIPT:case ae.TAG_ID.STYLE:case ae.TAG_ID.TEMPLATE:case ae.TAG_ID.TITLE:{g._err(a,Ba.ERR.abandonedHeadElementChild),g.openElements.push(g.headElement,ae.TAG_ID.HEAD),Zc(g,a),g.openElements.remove(g.headElement);break}case ae.TAG_ID.HEAD:{g._err(a,Ba.ERR.misplacedStartTagForHeadElement);break}default:oV(g,a)}}function Txt(g,a){switch(a.tagID){case ae.TAG_ID.BODY:case ae.TAG_ID.HTML:case ae.TAG_ID.BR:{oV(g,a);break}case ae.TAG_ID.TEMPLATE:{kb(g,a);break}default:g._err(a,Ba.ERR.endTagWithoutMatchingOpenElement)}}function oV(g,a){g._insertFakeElement(ae.TAG_NAMES.BODY,ae.TAG_ID.BODY),g.insertionMode=et.IN_BODY,S5(g,a)}function S5(g,a){switch(a.type){case Yo.TokenType.CHARACTER:{LVe(g,a);break}case Yo.TokenType.WHITESPACE_CHARACTER:{OVe(g,a);break}case Yo.TokenType.COMMENT:{i$(g,a);break}case Yo.TokenType.START_TAG:{ns(g,a);break}case Yo.TokenType.END_TAG:{w5(g,a);break}case Yo.TokenType.EOF:{qVe(g,a);break}}}function OVe(g,a){g._reconstructActiveFormattingElements(),g._insertCharacters(a)}function LVe(g,a){g._reconstructActiveFormattingElements(),g._insertCharacters(a),g.framesetOk=!1}function Rxt(g,a){g.openElements.tmplCount===0&&g.treeAdapter.adoptAttributes(g.openElements.items[0],a.attrs)}function Vxt(g,a){const s=g.openElements.tryPeekProperlyNestedBodyElement();s&&g.openElements.tmplCount===0&&(g.framesetOk=!1,g.treeAdapter.adoptAttributes(s,a.attrs))}function Ext(g,a){const s=g.openElements.tryPeekProperlyNestedBodyElement();g.framesetOk&&s&&(g.treeAdapter.detachNode(s),g.openElements.popAllUpToHtmlElement(),g._insertElement(a,ae.NS.HTML),g.insertionMode=et.IN_FRAMESET)}function Hxt(g,a){g.openElements.hasInButtonScope(ae.TAG_ID.P)&&g._closePElement(),g._insertElement(a,ae.NS.HTML)}function Wxt(g,a){g.openElements.hasInButtonScope(ae.TAG_ID.P)&&g._closePElement(),(0,ae.isNumberedHeader)(g.openElements.currentTagId)&&g.openElements.pop(),g._insertElement(a,ae.NS.HTML)}function Nxt(g,a){g.openElements.hasInButtonScope(ae.TAG_ID.P)&&g._closePElement(),g._insertElement(a,ae.NS.HTML),g.skipNextNewLine=!0,g.framesetOk=!1}function kxt(g,a){const s=g.openElements.tmplCount>0;(!g.formElement||s)&&(g.openElements.hasInButtonScope(ae.TAG_ID.P)&&g._closePElement(),g._insertElement(a,ae.NS.HTML),s||(g.formElement=g.openElements.current))}function Xxt(g,a){g.framesetOk=!1;const s=a.tagID;for(let C=g.openElements.stackTop;C>=0;C--){const I=g.openElements.tagIDs[C];if(s===ae.TAG_ID.LI&&I===ae.TAG_ID.LI||(s===ae.TAG_ID.DD||s===ae.TAG_ID.DT)&&(I===ae.TAG_ID.DD||I===ae.TAG_ID.DT)){g.openElements.generateImpliedEndTagsWithExclusion(I),g.openElements.popUntilTagNamePopped(I);break}if(I!==ae.TAG_ID.ADDRESS&&I!==ae.TAG_ID.DIV&&I!==ae.TAG_ID.P&&g._isSpecialElement(g.openElements.items[C],I))break}g.openElements.hasInButtonScope(ae.TAG_ID.P)&&g._closePElement(),g._insertElement(a,ae.NS.HTML)}function xxt(g,a){g.openElements.hasInButtonScope(ae.TAG_ID.P)&&g._closePElement(),g._insertElement(a,ae.NS.HTML),g.tokenizer.state=js.TokenizerMode.PLAINTEXT}function Dxt(g,a){g.openElements.hasInScope(ae.TAG_ID.BUTTON)&&(g.openElements.generateImpliedEndTags(),g.openElements.popUntilTagNamePopped(ae.TAG_ID.BUTTON)),g._reconstructActiveFormattingElements(),g._insertElement(a,ae.NS.HTML),g.framesetOk=!1}function Mxt(g,a){const s=g.activeFormattingElements.getElementEntryInScopeWithTagName(ae.TAG_NAMES.A);s&&(t$(g,a),g.openElements.remove(s.element),g.activeFormattingElements.removeEntry(s)),g._reconstructActiveFormattingElements(),g._insertElement(a,ae.NS.HTML),g.activeFormattingElements.pushElement(g.openElements.current,a)}function Fxt(g,a){g._reconstructActiveFormattingElements(),g._insertElement(a,ae.NS.HTML),g.activeFormattingElements.pushElement(g.openElements.current,a)}function Yxt(g,a){g._reconstructActiveFormattingElements(),g.openElements.hasInScope(ae.TAG_ID.NOBR)&&(t$(g,a),g._reconstructActiveFormattingElements()),g._insertElement(a,ae.NS.HTML),g.activeFormattingElements.pushElement(g.openElements.current,a)}function Kxt(g,a){g._reconstructActiveFormattingElements(),g._insertElement(a,ae.NS.HTML),g.activeFormattingElements.insertMarker(),g.framesetOk=!1}function _xt(g,a){g.treeAdapter.getDocumentMode(g.document)!==ae.DOCUMENT_MODE.QUIRKS&&g.openElements.hasInButtonScope(ae.TAG_ID.P)&&g._closePElement(),g._insertElement(a,ae.NS.HTML),g.framesetOk=!1,g.insertionMode=et.IN_TABLE}function JVe(g,a){g._reconstructActiveFormattingElements(),g._appendElement(a,ae.NS.HTML),g.framesetOk=!1,a.ackSelfClosing=!0}function UVe(g){const a=(0,Yo.getTokenAttr)(g,ae.ATTRS.TYPE);return a!=null&&a.toLowerCase()===oxt}function Pxt(g,a){g._reconstructActiveFormattingElements(),g._appendElement(a,ae.NS.HTML),UVe(a)||(g.framesetOk=!1),a.ackSelfClosing=!0}function zxt(g,a){g._appendElement(a,ae.NS.HTML),a.ackSelfClosing=!0}function Oxt(g,a){g.openElements.hasInButtonScope(ae.TAG_ID.P)&&g._closePElement(),g._appendElement(a,ae.NS.HTML),g.framesetOk=!1,a.ackSelfClosing=!0}function Lxt(g,a){a.tagName=ae.TAG_NAMES.IMG,a.tagID=ae.TAG_ID.IMG,JVe(g,a)}function Jxt(g,a){g._insertElement(a,ae.NS.HTML),g.skipNextNewLine=!0,g.tokenizer.state=js.TokenizerMode.RCDATA,g.originalInsertionMode=g.insertionMode,g.framesetOk=!1,g.insertionMode=et.TEXT}function Uxt(g,a){g.openElements.hasInButtonScope(ae.TAG_ID.P)&&g._closePElement(),g._reconstructActiveFormattingElements(),g.framesetOk=!1,g._switchToTextParsing(a,js.TokenizerMode.RAWTEXT)}function Qxt(g,a){g.framesetOk=!1,g._switchToTextParsing(a,js.TokenizerMode.RAWTEXT)}function QVe(g,a){g._switchToTextParsing(a,js.TokenizerMode.RAWTEXT)}function jxt(g,a){g._reconstructActiveFormattingElements(),g._insertElement(a,ae.NS.HTML),g.framesetOk=!1,g.insertionMode=g.insertionMode===et.IN_TABLE||g.insertionMode===et.IN_CAPTION||g.insertionMode===et.IN_TABLE_BODY||g.insertionMode===et.IN_ROW||g.insertionMode===et.IN_CELL?et.IN_SELECT_IN_TABLE:et.IN_SELECT}function $xt(g,a){g.openElements.currentTagId===ae.TAG_ID.OPTION&&g.openElements.pop(),g._reconstructActiveFormattingElements(),g._insertElement(a,ae.NS.HTML)}function qxt(g,a){g.openElements.hasInScope(ae.TAG_ID.RUBY)&&g.openElements.generateImpliedEndTags(),g._insertElement(a,ae.NS.HTML)}function eDt(g,a){g.openElements.hasInScope(ae.TAG_ID.RUBY)&&g.openElements.generateImpliedEndTagsWithExclusion(ae.TAG_ID.RTC),g._insertElement(a,ae.NS.HTML)}function tDt(g,a){g._reconstructActiveFormattingElements(),mu.adjustTokenMathMLAttrs(a),mu.adjustTokenXMLAttrs(a),a.selfClosing?g._appendElement(a,ae.NS.MATHML):g._insertElement(a,ae.NS.MATHML),a.ackSelfClosing=!0}function iDt(g,a){g._reconstructActiveFormattingElements(),mu.adjustTokenSVGAttrs(a),mu.adjustTokenXMLAttrs(a),a.selfClosing?g._appendElement(a,ae.NS.SVG):g._insertElement(a,ae.NS.SVG),a.ackSelfClosing=!0}function jVe(g,a){g._reconstructActiveFormattingElements(),g._insertElement(a,ae.NS.HTML)}function ns(g,a){switch(a.tagID){case ae.TAG_ID.I:case ae.TAG_ID.S:case ae.TAG_ID.B:case ae.TAG_ID.U:case ae.TAG_ID.EM:case ae.TAG_ID.TT:case ae.TAG_ID.BIG:case ae.TAG_ID.CODE:case ae.TAG_ID.FONT:case ae.TAG_ID.SMALL:case ae.TAG_ID.STRIKE:case ae.TAG_ID.STRONG:{Fxt(g,a);break}case ae.TAG_ID.A:{Mxt(g,a);break}case ae.TAG_ID.H1:case ae.TAG_ID.H2:case ae.TAG_ID.H3:case ae.TAG_ID.H4:case ae.TAG_ID.H5:case ae.TAG_ID.H6:{Wxt(g,a);break}case ae.TAG_ID.P:case ae.TAG_ID.DL:case ae.TAG_ID.OL:case ae.TAG_ID.UL:case ae.TAG_ID.DIV:case ae.TAG_ID.DIR:case ae.TAG_ID.NAV:case ae.TAG_ID.MAIN:case ae.TAG_ID.MENU:case ae.TAG_ID.ASIDE:case ae.TAG_ID.CENTER:case ae.TAG_ID.FIGURE:case ae.TAG_ID.FOOTER:case ae.TAG_ID.HEADER:case ae.TAG_ID.HGROUP:case ae.TAG_ID.DIALOG:case ae.TAG_ID.DETAILS:case ae.TAG_ID.ADDRESS:case ae.TAG_ID.ARTICLE:case ae.TAG_ID.SECTION:case ae.TAG_ID.SUMMARY:case ae.TAG_ID.FIELDSET:case ae.TAG_ID.BLOCKQUOTE:case ae.TAG_ID.FIGCAPTION:{Hxt(g,a);break}case ae.TAG_ID.LI:case ae.TAG_ID.DD:case ae.TAG_ID.DT:{Xxt(g,a);break}case ae.TAG_ID.BR:case ae.TAG_ID.IMG:case ae.TAG_ID.WBR:case ae.TAG_ID.AREA:case ae.TAG_ID.EMBED:case ae.TAG_ID.KEYGEN:{JVe(g,a);break}case ae.TAG_ID.HR:{Oxt(g,a);break}case ae.TAG_ID.RB:case ae.TAG_ID.RTC:{qxt(g,a);break}case ae.TAG_ID.RT:case ae.TAG_ID.RP:{eDt(g,a);break}case ae.TAG_ID.PRE:case ae.TAG_ID.LISTING:{Nxt(g,a);break}case ae.TAG_ID.XMP:{Uxt(g,a);break}case ae.TAG_ID.SVG:{iDt(g,a);break}case ae.TAG_ID.HTML:{Rxt(g,a);break}case ae.TAG_ID.BASE:case ae.TAG_ID.LINK:case ae.TAG_ID.META:case ae.TAG_ID.STYLE:case ae.TAG_ID.TITLE:case ae.TAG_ID.SCRIPT:case ae.TAG_ID.BGSOUND:case ae.TAG_ID.BASEFONT:case ae.TAG_ID.TEMPLATE:{Zc(g,a);break}case ae.TAG_ID.BODY:{Vxt(g,a);break}case ae.TAG_ID.FORM:{kxt(g,a);break}case ae.TAG_ID.NOBR:{Yxt(g,a);break}case ae.TAG_ID.MATH:{tDt(g,a);break}case ae.TAG_ID.TABLE:{_xt(g,a);break}case ae.TAG_ID.INPUT:{Pxt(g,a);break}case ae.TAG_ID.PARAM:case ae.TAG_ID.TRACK:case ae.TAG_ID.SOURCE:{zxt(g,a);break}case ae.TAG_ID.IMAGE:{Lxt(g,a);break}case ae.TAG_ID.BUTTON:{Dxt(g,a);break}case ae.TAG_ID.APPLET:case ae.TAG_ID.OBJECT:case ae.TAG_ID.MARQUEE:{Kxt(g,a);break}case ae.TAG_ID.IFRAME:{Qxt(g,a);break}case ae.TAG_ID.SELECT:{jxt(g,a);break}case ae.TAG_ID.OPTION:case ae.TAG_ID.OPTGROUP:{$xt(g,a);break}case ae.TAG_ID.NOEMBED:{QVe(g,a);break}case ae.TAG_ID.FRAMESET:{Ext(g,a);break}case ae.TAG_ID.TEXTAREA:{Jxt(g,a);break}case ae.TAG_ID.NOSCRIPT:{g.options.scriptingEnabled?QVe(g,a):jVe(g,a);break}case ae.TAG_ID.PLAINTEXT:{xxt(g,a);break}case ae.TAG_ID.COL:case ae.TAG_ID.TH:case ae.TAG_ID.TD:case ae.TAG_ID.TR:case ae.TAG_ID.HEAD:case ae.TAG_ID.FRAME:case ae.TAG_ID.TBODY:case ae.TAG_ID.TFOOT:case ae.TAG_ID.THEAD:case ae.TAG_ID.CAPTION:case ae.TAG_ID.COLGROUP:break;default:jVe(g,a)}}function nDt(g,a){if(g.openElements.hasInScope(ae.TAG_ID.BODY)&&(g.insertionMode=et.AFTER_BODY,g.options.sourceCodeLocationInfo)){const s=g.openElements.tryPeekProperlyNestedBodyElement();s&&g._setEndLocation(s,a)}}function rDt(g,a){g.openElements.hasInScope(ae.TAG_ID.BODY)&&(g.insertionMode=et.AFTER_BODY,a9e(g,a))}function gDt(g,a){const s=a.tagID;g.openElements.hasInScope(s)&&(g.openElements.generateImpliedEndTags(),g.openElements.popUntilTagNamePopped(s))}function oDt(g){const a=g.openElements.tmplCount>0,{formElement:s}=g;a||(g.formElement=null),(s||a)&&g.openElements.hasInScope(ae.TAG_ID.FORM)&&(g.openElements.generateImpliedEndTags(),a?g.openElements.popUntilTagNamePopped(ae.TAG_ID.FORM):s&&g.openElements.remove(s))}function aDt(g){g.openElements.hasInButtonScope(ae.TAG_ID.P)||g._insertFakeElement(ae.TAG_NAMES.P,ae.TAG_ID.P),g._closePElement()}function sDt(g){g.openElements.hasInListItemScope(ae.TAG_ID.LI)&&(g.openElements.generateImpliedEndTagsWithExclusion(ae.TAG_ID.LI),g.openElements.popUntilTagNamePopped(ae.TAG_ID.LI))}function IDt(g,a){const s=a.tagID;g.openElements.hasInScope(s)&&(g.openElements.generateImpliedEndTagsWithExclusion(s),g.openElements.popUntilTagNamePopped(s))}function lDt(g){g.openElements.hasNumberedHeaderInScope()&&(g.openElements.generateImpliedEndTags(),g.openElements.popUntilNumberedHeaderPopped())}function CDt(g,a){const s=a.tagID;g.openElements.hasInScope(s)&&(g.openElements.generateImpliedEndTags(),g.openElements.popUntilTagNamePopped(s),g.activeFormattingElements.clearToLastMarker())}function cDt(g){g._reconstructActiveFormattingElements(),g._insertFakeElement(ae.TAG_NAMES.BR,ae.TAG_ID.BR),g.openElements.pop(),g.framesetOk=!1}function $Ve(g,a){const s=a.tagName,C=a.tagID;for(let I=g.openElements.stackTop;I>0;I--){const A=g.openElements.items[I],d=g.openElements.tagIDs[I];if(C===d&&(C!==ae.TAG_ID.UNKNOWN||g.treeAdapter.getTagName(A)===s)){g.openElements.generateImpliedEndTagsWithExclusion(C),g.openElements.stackTop>=I&&g.openElements.shortenToLength(I);break}if(g._isSpecialElement(A,d))break}}function w5(g,a){switch(a.tagID){case ae.TAG_ID.A:case ae.TAG_ID.B:case ae.TAG_ID.I:case ae.TAG_ID.S:case ae.TAG_ID.U:case ae.TAG_ID.EM:case ae.TAG_ID.TT:case ae.TAG_ID.BIG:case ae.TAG_ID.CODE:case ae.TAG_ID.FONT:case ae.TAG_ID.NOBR:case ae.TAG_ID.SMALL:case ae.TAG_ID.STRIKE:case ae.TAG_ID.STRONG:{t$(g,a);break}case ae.TAG_ID.P:{aDt(g);break}case ae.TAG_ID.DL:case ae.TAG_ID.UL:case ae.TAG_ID.OL:case ae.TAG_ID.DIR:case ae.TAG_ID.DIV:case ae.TAG_ID.NAV:case ae.TAG_ID.PRE:case ae.TAG_ID.MAIN:case ae.TAG_ID.MENU:case ae.TAG_ID.ASIDE:case ae.TAG_ID.BUTTON:case ae.TAG_ID.CENTER:case ae.TAG_ID.FIGURE:case ae.TAG_ID.FOOTER:case ae.TAG_ID.HEADER:case ae.TAG_ID.HGROUP:case ae.TAG_ID.DIALOG:case ae.TAG_ID.ADDRESS:case ae.TAG_ID.ARTICLE:case ae.TAG_ID.DETAILS:case ae.TAG_ID.SECTION:case ae.TAG_ID.SUMMARY:case ae.TAG_ID.LISTING:case ae.TAG_ID.FIELDSET:case ae.TAG_ID.BLOCKQUOTE:case ae.TAG_ID.FIGCAPTION:{gDt(g,a);break}case ae.TAG_ID.LI:{sDt(g);break}case ae.TAG_ID.DD:case ae.TAG_ID.DT:{IDt(g,a);break}case ae.TAG_ID.H1:case ae.TAG_ID.H2:case ae.TAG_ID.H3:case ae.TAG_ID.H4:case ae.TAG_ID.H5:case ae.TAG_ID.H6:{lDt(g);break}case ae.TAG_ID.BR:{cDt(g);break}case ae.TAG_ID.BODY:{nDt(g,a);break}case ae.TAG_ID.HTML:{rDt(g,a);break}case ae.TAG_ID.FORM:{oDt(g);break}case ae.TAG_ID.APPLET:case ae.TAG_ID.OBJECT:case ae.TAG_ID.MARQUEE:{CDt(g,a);break}case ae.TAG_ID.TEMPLATE:{kb(g,a);break}default:$Ve(g,a)}}function qVe(g,a){g.tmplInsertionModeStack.length>0?o9e(g,a):n$(g,a)}function ADt(g,a){var s;a.tagID===ae.TAG_ID.SCRIPT&&((s=g.scriptHandler)===null||s===void 0||s.call(g,g.openElements.current)),g.openElements.pop(),g.insertionMode=g.originalInsertionMode}function uDt(g,a){g._err(a,Ba.ERR.eofInElementThatCanContainOnlyText),g.openElements.pop(),g.insertionMode=g.originalInsertionMode,g.onEof(a)}function r$(g,a){if(PVe.has(g.openElements.currentTagId))switch(g.pendingCharacterTokens.length=0,g.hasNonWhitespacePendingCharacterToken=!1,g.originalInsertionMode=g.insertionMode,g.insertionMode=et.IN_TABLE_TEXT,a.type){case Yo.TokenType.CHARACTER:{t9e(g,a);break}case Yo.TokenType.WHITESPACE_CHARACTER:{e9e(g,a);break}}else sV(g,a)}function dDt(g,a){g.openElements.clearBackToTableContext(),g.activeFormattingElements.insertMarker(),g._insertElement(a,ae.NS.HTML),g.insertionMode=et.IN_CAPTION}function hDt(g,a){g.openElements.clearBackToTableContext(),g._insertElement(a,ae.NS.HTML),g.insertionMode=et.IN_COLUMN_GROUP}function fDt(g,a){g.openElements.clearBackToTableContext(),g._insertFakeElement(ae.TAG_NAMES.COLGROUP,ae.TAG_ID.COLGROUP),g.insertionMode=et.IN_COLUMN_GROUP,g$(g,a)}function mDt(g,a){g.openElements.clearBackToTableContext(),g._insertElement(a,ae.NS.HTML),g.insertionMode=et.IN_TABLE_BODY}function pDt(g,a){g.openElements.clearBackToTableContext(),g._insertFakeElement(ae.TAG_NAMES.TBODY,ae.TAG_ID.TBODY),g.insertionMode=et.IN_TABLE_BODY,R5(g,a)}function bDt(g,a){g.openElements.hasInTableScope(ae.TAG_ID.TABLE)&&(g.openElements.popUntilTagNamePopped(ae.TAG_ID.TABLE),g._resetInsertionMode(),g._processStartTag(a))}function yDt(g,a){UVe(a)?g._appendElement(a,ae.NS.HTML):sV(g,a),a.ackSelfClosing=!0}function vDt(g,a){!g.formElement&&g.openElements.tmplCount===0&&(g._insertElement(a,ae.NS.HTML),g.formElement=g.openElements.current,g.openElements.pop())}function DB(g,a){switch(a.tagID){case ae.TAG_ID.TD:case ae.TAG_ID.TH:case ae.TAG_ID.TR:{pDt(g,a);break}case ae.TAG_ID.STYLE:case ae.TAG_ID.SCRIPT:case ae.TAG_ID.TEMPLATE:{Zc(g,a);break}case ae.TAG_ID.COL:{fDt(g,a);break}case ae.TAG_ID.FORM:{vDt(g,a);break}case ae.TAG_ID.TABLE:{bDt(g,a);break}case ae.TAG_ID.TBODY:case ae.TAG_ID.TFOOT:case ae.TAG_ID.THEAD:{mDt(g,a);break}case ae.TAG_ID.INPUT:{yDt(g,a);break}case ae.TAG_ID.CAPTION:{dDt(g,a);break}case ae.TAG_ID.COLGROUP:{hDt(g,a);break}default:sV(g,a)}}function aV(g,a){switch(a.tagID){case ae.TAG_ID.TABLE:{g.openElements.hasInTableScope(ae.TAG_ID.TABLE)&&(g.openElements.popUntilTagNamePopped(ae.TAG_ID.TABLE),g._resetInsertionMode());break}case ae.TAG_ID.TEMPLATE:{kb(g,a);break}case ae.TAG_ID.BODY:case ae.TAG_ID.CAPTION:case ae.TAG_ID.COL:case ae.TAG_ID.COLGROUP:case ae.TAG_ID.HTML:case ae.TAG_ID.TBODY:case ae.TAG_ID.TD:case ae.TAG_ID.TFOOT:case ae.TAG_ID.TH:case ae.TAG_ID.THEAD:case ae.TAG_ID.TR:break;default:sV(g,a)}}function sV(g,a){const s=g.fosterParentingEnabled;g.fosterParentingEnabled=!0,S5(g,a),g.fosterParentingEnabled=s}function e9e(g,a){g.pendingCharacterTokens.push(a)}function t9e(g,a){g.pendingCharacterTokens.push(a),g.hasNonWhitespacePendingCharacterToken=!0}function IV(g,a){let s=0;if(g.hasNonWhitespacePendingCharacterToken)for(;s0&&g.openElements.currentTagId===ae.TAG_ID.OPTION&&g.openElements.tagIDs[g.openElements.stackTop-1]===ae.TAG_ID.OPTGROUP&&g.openElements.pop(),g.openElements.currentTagId===ae.TAG_ID.OPTGROUP&&g.openElements.pop();break}case ae.TAG_ID.OPTION:{g.openElements.currentTagId===ae.TAG_ID.OPTION&&g.openElements.pop();break}case ae.TAG_ID.SELECT:{g.openElements.hasInSelectScope(ae.TAG_ID.SELECT)&&(g.openElements.popUntilTagNamePopped(ae.TAG_ID.SELECT),g._resetInsertionMode());break}case ae.TAG_ID.TEMPLATE:{kb(g,a);break}}}function TDt(g,a){const s=a.tagID;s===ae.TAG_ID.CAPTION||s===ae.TAG_ID.TABLE||s===ae.TAG_ID.TBODY||s===ae.TAG_ID.TFOOT||s===ae.TAG_ID.THEAD||s===ae.TAG_ID.TR||s===ae.TAG_ID.TD||s===ae.TAG_ID.TH?(g.openElements.popUntilTagNamePopped(ae.TAG_ID.SELECT),g._resetInsertionMode(),g._processStartTag(a)):r9e(g,a)}function RDt(g,a){const s=a.tagID;s===ae.TAG_ID.CAPTION||s===ae.TAG_ID.TABLE||s===ae.TAG_ID.TBODY||s===ae.TAG_ID.TFOOT||s===ae.TAG_ID.THEAD||s===ae.TAG_ID.TR||s===ae.TAG_ID.TD||s===ae.TAG_ID.TH?g.openElements.hasInTableScope(s)&&(g.openElements.popUntilTagNamePopped(ae.TAG_ID.SELECT),g._resetInsertionMode(),g.onEndTag(a)):g9e(g,a)}function VDt(g,a){switch(a.tagID){case ae.TAG_ID.BASE:case ae.TAG_ID.BASEFONT:case ae.TAG_ID.BGSOUND:case ae.TAG_ID.LINK:case ae.TAG_ID.META:case ae.TAG_ID.NOFRAMES:case ae.TAG_ID.SCRIPT:case ae.TAG_ID.STYLE:case ae.TAG_ID.TEMPLATE:case ae.TAG_ID.TITLE:{Zc(g,a);break}case ae.TAG_ID.CAPTION:case ae.TAG_ID.COLGROUP:case ae.TAG_ID.TBODY:case ae.TAG_ID.TFOOT:case ae.TAG_ID.THEAD:{g.tmplInsertionModeStack[0]=et.IN_TABLE,g.insertionMode=et.IN_TABLE,DB(g,a);break}case ae.TAG_ID.COL:{g.tmplInsertionModeStack[0]=et.IN_COLUMN_GROUP,g.insertionMode=et.IN_COLUMN_GROUP,g$(g,a);break}case ae.TAG_ID.TR:{g.tmplInsertionModeStack[0]=et.IN_TABLE_BODY,g.insertionMode=et.IN_TABLE_BODY,R5(g,a);break}case ae.TAG_ID.TD:case ae.TAG_ID.TH:{g.tmplInsertionModeStack[0]=et.IN_ROW,g.insertionMode=et.IN_ROW,V5(g,a);break}default:g.tmplInsertionModeStack[0]=et.IN_BODY,g.insertionMode=et.IN_BODY,ns(g,a)}}function EDt(g,a){a.tagID===ae.TAG_ID.TEMPLATE&&kb(g,a)}function o9e(g,a){g.openElements.tmplCount>0?(g.openElements.popUntilTagNamePopped(ae.TAG_ID.TEMPLATE),g.activeFormattingElements.clearToLastMarker(),g.tmplInsertionModeStack.shift(),g._resetInsertionMode(),g.onEof(a)):n$(g,a)}function HDt(g,a){a.tagID===ae.TAG_ID.HTML?ns(g,a):E5(g,a)}function a9e(g,a){var s;if(a.tagID===ae.TAG_ID.HTML){if(g.fragmentContext||(g.insertionMode=et.AFTER_AFTER_BODY),g.options.sourceCodeLocationInfo&&g.openElements.tagIDs[0]===ae.TAG_ID.HTML){g._setEndLocation(g.openElements.items[0],a);const C=g.openElements.items[1];C&&!(!((s=g.treeAdapter.getNodeSourceCodeLocation(C))===null||s===void 0)&&s.endTag)&&g._setEndLocation(C,a)}}else E5(g,a)}function E5(g,a){g.insertionMode=et.IN_BODY,S5(g,a)}function WDt(g,a){switch(a.tagID){case ae.TAG_ID.HTML:{ns(g,a);break}case ae.TAG_ID.FRAMESET:{g._insertElement(a,ae.NS.HTML);break}case ae.TAG_ID.FRAME:{g._appendElement(a,ae.NS.HTML),a.ackSelfClosing=!0;break}case ae.TAG_ID.NOFRAMES:{Zc(g,a);break}}}function NDt(g,a){a.tagID===ae.TAG_ID.FRAMESET&&!g.openElements.isRootHtmlElementCurrent()&&(g.openElements.pop(),!g.fragmentContext&&g.openElements.currentTagId!==ae.TAG_ID.FRAMESET&&(g.insertionMode=et.AFTER_FRAMESET))}function kDt(g,a){switch(a.tagID){case ae.TAG_ID.HTML:{ns(g,a);break}case ae.TAG_ID.NOFRAMES:{Zc(g,a);break}}}function XDt(g,a){a.tagID===ae.TAG_ID.HTML&&(g.insertionMode=et.AFTER_AFTER_FRAMESET)}function xDt(g,a){a.tagID===ae.TAG_ID.HTML?ns(g,a):H5(g,a)}function H5(g,a){g.insertionMode=et.IN_BODY,S5(g,a)}function DDt(g,a){switch(a.tagID){case ae.TAG_ID.HTML:{ns(g,a);break}case ae.TAG_ID.NOFRAMES:{Zc(g,a);break}}}function MDt(g,a){a.chars=_Ve.REPLACEMENT_CHARACTER,g._insertCharacters(a)}function FDt(g,a){g._insertCharacters(a),g.framesetOk=!1}function s9e(g){for(;g.treeAdapter.getNamespaceURI(g.openElements.current)!==ae.NS.HTML&&!g._isIntegrationPoint(g.openElements.currentTagId,g.openElements.current);)g.openElements.pop()}function YDt(g,a){if(mu.causesExit(a))s9e(g),g._startTagOutsideForeignContent(a);else{const s=g._getAdjustedCurrentElement(),C=g.treeAdapter.getNamespaceURI(s);C===ae.NS.MATHML?mu.adjustTokenMathMLAttrs(a):C===ae.NS.SVG&&(mu.adjustTokenSVGTagName(a),mu.adjustTokenSVGAttrs(a)),mu.adjustTokenXMLAttrs(a),a.selfClosing?g._appendElement(a,C):g._insertElement(a,C),a.ackSelfClosing=!0}}function KDt(g,a){if(a.tagID===ae.TAG_ID.P||a.tagID===ae.TAG_ID.BR){s9e(g),g._endTagOutsideForeignContent(a);return}for(let s=g.openElements.stackTop;s>0;s--){const C=g.openElements.items[s];if(g.treeAdapter.getNamespaceURI(C)===ae.NS.HTML){g._endTagOutsideForeignContent(a);break}const I=g.treeAdapter.getTagName(C);if(I.toLowerCase()===a.tagName){a.tagName=I,g.openElements.shortenToLength(s);break}}}var MB={};Object.defineProperty(MB,"__esModule",{value:!0}),MB.serializeOuter=MB.serialize=void 0;const Ig=lh,I9e=bB,_Dt=G5,PDt=new Set([Ig.TAG_NAMES.AREA,Ig.TAG_NAMES.BASE,Ig.TAG_NAMES.BASEFONT,Ig.TAG_NAMES.BGSOUND,Ig.TAG_NAMES.BR,Ig.TAG_NAMES.COL,Ig.TAG_NAMES.EMBED,Ig.TAG_NAMES.FRAME,Ig.TAG_NAMES.HR,Ig.TAG_NAMES.IMG,Ig.TAG_NAMES.INPUT,Ig.TAG_NAMES.KEYGEN,Ig.TAG_NAMES.LINK,Ig.TAG_NAMES.META,Ig.TAG_NAMES.PARAM,Ig.TAG_NAMES.SOURCE,Ig.TAG_NAMES.TRACK,Ig.TAG_NAMES.WBR]);function l9e(g,a){return a.treeAdapter.isElementNode(g)&&a.treeAdapter.getNamespaceURI(g)===Ig.NS.HTML&&PDt.has(a.treeAdapter.getTagName(g))}const C9e={treeAdapter:_Dt.defaultTreeAdapter,scriptingEnabled:!0};function zDt(g,a){const s=Object.assign(Object.assign({},C9e),a);return l9e(g,s)?"":c9e(g,s)}MB.serialize=zDt;function ODt(g,a){const s=Object.assign(Object.assign({},C9e),a);return A9e(g,s)}MB.serializeOuter=ODt;function c9e(g,a){let s="";const C=a.treeAdapter.isElementNode(g)&&a.treeAdapter.getTagName(g)===Ig.TAG_NAMES.TEMPLATE&&a.treeAdapter.getNamespaceURI(g)===Ig.NS.HTML?a.treeAdapter.getTemplateContent(g):g,I=a.treeAdapter.getChildNodes(C);if(I)for(const A of I)s+=A9e(A,a);return s}function A9e(g,a){return a.treeAdapter.isElementNode(g)?LDt(g,a):a.treeAdapter.isTextNode(g)?UDt(g,a):a.treeAdapter.isCommentNode(g)?QDt(g,a):a.treeAdapter.isDocumentTypeNode(g)?jDt(g,a):""}function LDt(g,a){const s=a.treeAdapter.getTagName(g);return`<${s}${JDt(g,a)}>${l9e(g,a)?"":`${c9e(g,a)}`}`}function JDt(g,{treeAdapter:a}){let s="";for(const C of a.getAttrList(g)){if(s+=" ",!C.namespace)s+=C.name;else switch(C.namespace){case Ig.NS.XML:{s+=`xml:${C.name}`;break}case Ig.NS.XMLNS:{C.name!=="xmlns"&&(s+="xmlns:"),s+=C.name;break}case Ig.NS.XLINK:{s+=`xlink:${C.name}`;break}default:s+=`${C.prefix}:${C.name}`}s+=`="${(0,I9e.escapeAttribute)(C.value)}"`}return s}function UDt(g,a){const{treeAdapter:s}=a,C=s.getTextNodeContent(g),I=s.getParentNode(g),A=I&&s.isElementNode(I)&&s.getTagName(I);return A&&s.getNamespaceURI(I)===Ig.NS.HTML&&(0,Ig.hasUnescapedText)(A,a.scriptingEnabled)?C:(0,I9e.escapeText)(C)}function QDt(g,{treeAdapter:a}){return``}function jDt(g,{treeAdapter:a}){return``}(function(g){Object.defineProperty(g,"__esModule",{value:!0}),g.parseFragment=g.parse=g.TokenizerMode=g.Tokenizer=g.Token=g.html=g.foreignContent=g.ErrorCodes=g.serializeOuter=g.serialize=g.Parser=g.defaultTreeAdapter=void 0;const a=jR;var s=G5;Object.defineProperty(g,"defaultTreeAdapter",{enumerable:!0,get:function(){return s.defaultTreeAdapter}});var C=jR;Object.defineProperty(g,"Parser",{enumerable:!0,get:function(){return C.Parser}});var I=MB;Object.defineProperty(g,"serialize",{enumerable:!0,get:function(){return I.serialize}}),Object.defineProperty(g,"serializeOuter",{enumerable:!0,get:function(){return I.serializeOuter}});var A=$R;Object.defineProperty(g,"ErrorCodes",{enumerable:!0,get:function(){return A.ERR}}),g.foreignContent=e$,g.html=lh,g.Token=y5;var d=Nb;Object.defineProperty(g,"Tokenizer",{enumerable:!0,get:function(){return d.Tokenizer}}),Object.defineProperty(g,"TokenizerMode",{enumerable:!0,get:function(){return d.TokenizerMode}});function h(Z,b){return a.Parser.parse(Z,b)}g.parse=h;function y(Z,b,w){typeof Z=="string"&&(w=b,b=Z,Z=null);const S=a.Parser.getFragmentParser(Z,w);return S.tokenizer.write(b,!0),S.getFragment()}g.parseFragment=y})(RVe);var u9e={},d9e={},lV={},Xb={},W5={},N5={};(function(g){Object.defineProperty(g,"__esModule",{value:!0}),g.isUndefinedCodePoint=g.isControlCodePoint=g.getSurrogatePairCodePoint=g.isSurrogatePair=g.isSurrogate=g.SEQUENCES=g.CODE_POINTS=g.REPLACEMENT_CHARACTER=void 0;const a=new Set([65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111]);g.REPLACEMENT_CHARACTER="�",function(h){h[h.EOF=-1]="EOF",h[h.NULL=0]="NULL",h[h.TABULATION=9]="TABULATION",h[h.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",h[h.LINE_FEED=10]="LINE_FEED",h[h.FORM_FEED=12]="FORM_FEED",h[h.SPACE=32]="SPACE",h[h.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",h[h.QUOTATION_MARK=34]="QUOTATION_MARK",h[h.NUMBER_SIGN=35]="NUMBER_SIGN",h[h.AMPERSAND=38]="AMPERSAND",h[h.APOSTROPHE=39]="APOSTROPHE",h[h.HYPHEN_MINUS=45]="HYPHEN_MINUS",h[h.SOLIDUS=47]="SOLIDUS",h[h.DIGIT_0=48]="DIGIT_0",h[h.DIGIT_9=57]="DIGIT_9",h[h.SEMICOLON=59]="SEMICOLON",h[h.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",h[h.EQUALS_SIGN=61]="EQUALS_SIGN",h[h.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",h[h.QUESTION_MARK=63]="QUESTION_MARK",h[h.LATIN_CAPITAL_A=65]="LATIN_CAPITAL_A",h[h.LATIN_CAPITAL_F=70]="LATIN_CAPITAL_F",h[h.LATIN_CAPITAL_X=88]="LATIN_CAPITAL_X",h[h.LATIN_CAPITAL_Z=90]="LATIN_CAPITAL_Z",h[h.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",h[h.GRAVE_ACCENT=96]="GRAVE_ACCENT",h[h.LATIN_SMALL_A=97]="LATIN_SMALL_A",h[h.LATIN_SMALL_F=102]="LATIN_SMALL_F",h[h.LATIN_SMALL_X=120]="LATIN_SMALL_X",h[h.LATIN_SMALL_Z=122]="LATIN_SMALL_Z",h[h.REPLACEMENT_CHARACTER=65533]="REPLACEMENT_CHARACTER"}(g.CODE_POINTS||(g.CODE_POINTS={})),g.SEQUENCES={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"};function s(h){return h>=55296&&h<=57343}g.isSurrogate=s;function C(h){return h>=56320&&h<=57343}g.isSurrogatePair=C;function I(h,y){return(h-55296)*1024+9216+y}g.getSurrogatePairCodePoint=I;function A(h){return h!==32&&h!==10&&h!==13&&h!==9&&h!==12&&h>=1&&h<=31||h>=127&&h<=159}g.isControlCodePoint=A;function d(h){return h>=64976&&h<=65007||a.has(h)}g.isUndefinedCodePoint=d})(N5);var CV={};(function(g){Object.defineProperty(g,"__esModule",{value:!0}),g.ERR=void 0,function(a){a.controlCharacterInInputStream="control-character-in-input-stream",a.noncharacterInInputStream="noncharacter-in-input-stream",a.surrogateInInputStream="surrogate-in-input-stream",a.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",a.endTagWithAttributes="end-tag-with-attributes",a.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",a.unexpectedSolidusInTag="unexpected-solidus-in-tag",a.unexpectedNullCharacter="unexpected-null-character",a.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",a.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",a.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",a.missingEndTagName="missing-end-tag-name",a.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",a.unknownNamedCharacterReference="unknown-named-character-reference",a.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",a.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",a.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",a.eofBeforeTagName="eof-before-tag-name",a.eofInTag="eof-in-tag",a.missingAttributeValue="missing-attribute-value",a.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",a.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",a.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",a.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",a.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",a.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",a.missingDoctypePublicIdentifier="missing-doctype-public-identifier",a.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",a.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",a.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",a.cdataInHtmlContent="cdata-in-html-content",a.incorrectlyOpenedComment="incorrectly-opened-comment",a.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",a.eofInDoctype="eof-in-doctype",a.nestedComment="nested-comment",a.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",a.eofInComment="eof-in-comment",a.incorrectlyClosedComment="incorrectly-closed-comment",a.eofInCdata="eof-in-cdata",a.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",a.nullCharacterReference="null-character-reference",a.surrogateCharacterReference="surrogate-character-reference",a.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",a.controlCharacterReference="control-character-reference",a.noncharacterCharacterReference="noncharacter-character-reference",a.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",a.missingDoctypeName="missing-doctype-name",a.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",a.duplicateAttribute="duplicate-attribute",a.nonConformingDoctype="non-conforming-doctype",a.missingDoctype="missing-doctype",a.misplacedDoctype="misplaced-doctype",a.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",a.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",a.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",a.openElementsLeftAfterEof="open-elements-left-after-eof",a.abandonedHeadElementChild="abandoned-head-element-child",a.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",a.nestedNoscriptInHead="nested-noscript-in-head",a.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"}(g.ERR||(g.ERR={}))})(CV),Object.defineProperty(W5,"__esModule",{value:!0}),W5.Preprocessor=void 0;const $s=N5,a$=CV,$Dt=1<<16;let qDt=function(){function g(a){T(this,g),this.handler=a,this.html="",this.pos=-1,this.lastGapPos=-2,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=$Dt,this.isEol=!1,this.lineStartPos=0,this.droppedBufferSize=0,this.line=1,this.lastErrOffset=-1}return E(g,[{key:"col",get:function(){return this.pos-this.lineStartPos+ +(this.lastGapPos!==this.pos)}},{key:"offset",get:function(){return this.droppedBufferSize+this.pos}},{key:"getError",value:function(s){const{line:C,col:I,offset:A}=this;return{code:s,startLine:C,endLine:C,startCol:I,endCol:I,startOffset:A,endOffset:A}}},{key:"_err",value:function(s){this.handler.onParseError&&this.lastErrOffset!==this.offset&&(this.lastErrOffset=this.offset,this.handler.onParseError(this.getError(s)))}},{key:"_addGap",value:function(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos}},{key:"_processSurrogate",value:function(s){if(this.pos!==this.html.length-1){const C=this.html.charCodeAt(this.pos+1);if((0,$s.isSurrogatePair)(C))return this.pos++,this._addGap(),(0,$s.getSurrogatePairCodePoint)(s,C)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,$s.CODE_POINTS.EOF;return this._err(a$.ERR.surrogateInInputStream),s}},{key:"willDropParsedChunk",value:function(){return this.pos>this.bufferWaterline}},{key:"dropParsedChunk",value:function(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}},{key:"write",value:function(s,C){this.html.length>0?this.html+=s:this.html=s,this.endOfChunkHit=!1,this.lastChunkWritten=C}},{key:"insertHtmlAtCurrentPos",value:function(s){this.html=this.html.substring(0,this.pos+1)+s+this.html.substring(this.pos+1),this.endOfChunkHit=!1}},{key:"startsWith",value:function(s,C){if(this.pos+s.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(C)return this.html.startsWith(s,this.pos);for(let I=0;I=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,$s.CODE_POINTS.EOF;const I=this.html.charCodeAt(C);return I===$s.CODE_POINTS.CARRIAGE_RETURN?$s.CODE_POINTS.LINE_FEED:I}},{key:"advance",value:function(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,$s.CODE_POINTS.EOF;let s=this.html.charCodeAt(this.pos);return s===$s.CODE_POINTS.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,$s.CODE_POINTS.LINE_FEED):s===$s.CODE_POINTS.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,(0,$s.isSurrogate)(s)&&(s=this._processSurrogate(s)),this.handler.onParseError===null||s>31&&s<127||s===$s.CODE_POINTS.LINE_FEED||s===$s.CODE_POINTS.CARRIAGE_RETURN||s>159&&s<64976||this._checkForProblematicCharacters(s),s)}},{key:"_checkForProblematicCharacters",value:function(s){(0,$s.isControlCodePoint)(s)?this._err(a$.ERR.controlCharacterInInputStream):(0,$s.isUndefinedCodePoint)(s)&&this._err(a$.ERR.noncharacterInInputStream)}},{key:"retreat",value:function(s){for(this.pos-=s;this.pos=0;I--)if(s.attrs[I].name===C)return s.attrs[I].value;return null}g.getTokenAttr=a})(k5);var Ch={};(function(g){Object.defineProperty(g,"__esModule",{value:!0}),g.hasUnescapedText=g.isNumberedHeader=g.SPECIAL_ELEMENTS=g.getTagID=g.TAG_ID=g.TAG_NAMES=g.DOCUMENT_MODE=g.ATTRS=g.NS=void 0;var a;(function(b){b.HTML="http://www.w3.org/1999/xhtml",b.MATHML="http://www.w3.org/1998/Math/MathML",b.SVG="http://www.w3.org/2000/svg",b.XLINK="http://www.w3.org/1999/xlink",b.XML="http://www.w3.org/XML/1998/namespace",b.XMLNS="http://www.w3.org/2000/xmlns/"})(a=g.NS||(g.NS={})),function(b){b.TYPE="type",b.ACTION="action",b.ENCODING="encoding",b.PROMPT="prompt",b.NAME="name",b.COLOR="color",b.FACE="face",b.SIZE="size"}(g.ATTRS||(g.ATTRS={})),function(b){b.NO_QUIRKS="no-quirks",b.QUIRKS="quirks",b.LIMITED_QUIRKS="limited-quirks"}(g.DOCUMENT_MODE||(g.DOCUMENT_MODE={}));var s;(function(b){b.A="a",b.ADDRESS="address",b.ANNOTATION_XML="annotation-xml",b.APPLET="applet",b.AREA="area",b.ARTICLE="article",b.ASIDE="aside",b.B="b",b.BASE="base",b.BASEFONT="basefont",b.BGSOUND="bgsound",b.BIG="big",b.BLOCKQUOTE="blockquote",b.BODY="body",b.BR="br",b.BUTTON="button",b.CAPTION="caption",b.CENTER="center",b.CODE="code",b.COL="col",b.COLGROUP="colgroup",b.DD="dd",b.DESC="desc",b.DETAILS="details",b.DIALOG="dialog",b.DIR="dir",b.DIV="div",b.DL="dl",b.DT="dt",b.EM="em",b.EMBED="embed",b.FIELDSET="fieldset",b.FIGCAPTION="figcaption",b.FIGURE="figure",b.FONT="font",b.FOOTER="footer",b.FOREIGN_OBJECT="foreignObject",b.FORM="form",b.FRAME="frame",b.FRAMESET="frameset",b.H1="h1",b.H2="h2",b.H3="h3",b.H4="h4",b.H5="h5",b.H6="h6",b.HEAD="head",b.HEADER="header",b.HGROUP="hgroup",b.HR="hr",b.HTML="html",b.I="i",b.IMG="img",b.IMAGE="image",b.INPUT="input",b.IFRAME="iframe",b.KEYGEN="keygen",b.LABEL="label",b.LI="li",b.LINK="link",b.LISTING="listing",b.MAIN="main",b.MALIGNMARK="malignmark",b.MARQUEE="marquee",b.MATH="math",b.MENU="menu",b.META="meta",b.MGLYPH="mglyph",b.MI="mi",b.MO="mo",b.MN="mn",b.MS="ms",b.MTEXT="mtext",b.NAV="nav",b.NOBR="nobr",b.NOFRAMES="noframes",b.NOEMBED="noembed",b.NOSCRIPT="noscript",b.OBJECT="object",b.OL="ol",b.OPTGROUP="optgroup",b.OPTION="option",b.P="p",b.PARAM="param",b.PLAINTEXT="plaintext",b.PRE="pre",b.RB="rb",b.RP="rp",b.RT="rt",b.RTC="rtc",b.RUBY="ruby",b.S="s",b.SCRIPT="script",b.SECTION="section",b.SELECT="select",b.SOURCE="source",b.SMALL="small",b.SPAN="span",b.STRIKE="strike",b.STRONG="strong",b.STYLE="style",b.SUB="sub",b.SUMMARY="summary",b.SUP="sup",b.TABLE="table",b.TBODY="tbody",b.TEMPLATE="template",b.TEXTAREA="textarea",b.TFOOT="tfoot",b.TD="td",b.TH="th",b.THEAD="thead",b.TITLE="title",b.TR="tr",b.TRACK="track",b.TT="tt",b.U="u",b.UL="ul",b.SVG="svg",b.VAR="var",b.WBR="wbr",b.XMP="xmp"})(s=g.TAG_NAMES||(g.TAG_NAMES={}));var C;(function(b){b[b.UNKNOWN=0]="UNKNOWN",b[b.A=1]="A",b[b.ADDRESS=2]="ADDRESS",b[b.ANNOTATION_XML=3]="ANNOTATION_XML",b[b.APPLET=4]="APPLET",b[b.AREA=5]="AREA",b[b.ARTICLE=6]="ARTICLE",b[b.ASIDE=7]="ASIDE",b[b.B=8]="B",b[b.BASE=9]="BASE",b[b.BASEFONT=10]="BASEFONT",b[b.BGSOUND=11]="BGSOUND",b[b.BIG=12]="BIG",b[b.BLOCKQUOTE=13]="BLOCKQUOTE",b[b.BODY=14]="BODY",b[b.BR=15]="BR",b[b.BUTTON=16]="BUTTON",b[b.CAPTION=17]="CAPTION",b[b.CENTER=18]="CENTER",b[b.CODE=19]="CODE",b[b.COL=20]="COL",b[b.COLGROUP=21]="COLGROUP",b[b.DD=22]="DD",b[b.DESC=23]="DESC",b[b.DETAILS=24]="DETAILS",b[b.DIALOG=25]="DIALOG",b[b.DIR=26]="DIR",b[b.DIV=27]="DIV",b[b.DL=28]="DL",b[b.DT=29]="DT",b[b.EM=30]="EM",b[b.EMBED=31]="EMBED",b[b.FIELDSET=32]="FIELDSET",b[b.FIGCAPTION=33]="FIGCAPTION",b[b.FIGURE=34]="FIGURE",b[b.FONT=35]="FONT",b[b.FOOTER=36]="FOOTER",b[b.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",b[b.FORM=38]="FORM",b[b.FRAME=39]="FRAME",b[b.FRAMESET=40]="FRAMESET",b[b.H1=41]="H1",b[b.H2=42]="H2",b[b.H3=43]="H3",b[b.H4=44]="H4",b[b.H5=45]="H5",b[b.H6=46]="H6",b[b.HEAD=47]="HEAD",b[b.HEADER=48]="HEADER",b[b.HGROUP=49]="HGROUP",b[b.HR=50]="HR",b[b.HTML=51]="HTML",b[b.I=52]="I",b[b.IMG=53]="IMG",b[b.IMAGE=54]="IMAGE",b[b.INPUT=55]="INPUT",b[b.IFRAME=56]="IFRAME",b[b.KEYGEN=57]="KEYGEN",b[b.LABEL=58]="LABEL",b[b.LI=59]="LI",b[b.LINK=60]="LINK",b[b.LISTING=61]="LISTING",b[b.MAIN=62]="MAIN",b[b.MALIGNMARK=63]="MALIGNMARK",b[b.MARQUEE=64]="MARQUEE",b[b.MATH=65]="MATH",b[b.MENU=66]="MENU",b[b.META=67]="META",b[b.MGLYPH=68]="MGLYPH",b[b.MI=69]="MI",b[b.MO=70]="MO",b[b.MN=71]="MN",b[b.MS=72]="MS",b[b.MTEXT=73]="MTEXT",b[b.NAV=74]="NAV",b[b.NOBR=75]="NOBR",b[b.NOFRAMES=76]="NOFRAMES",b[b.NOEMBED=77]="NOEMBED",b[b.NOSCRIPT=78]="NOSCRIPT",b[b.OBJECT=79]="OBJECT",b[b.OL=80]="OL",b[b.OPTGROUP=81]="OPTGROUP",b[b.OPTION=82]="OPTION",b[b.P=83]="P",b[b.PARAM=84]="PARAM",b[b.PLAINTEXT=85]="PLAINTEXT",b[b.PRE=86]="PRE",b[b.RB=87]="RB",b[b.RP=88]="RP",b[b.RT=89]="RT",b[b.RTC=90]="RTC",b[b.RUBY=91]="RUBY",b[b.S=92]="S",b[b.SCRIPT=93]="SCRIPT",b[b.SECTION=94]="SECTION",b[b.SELECT=95]="SELECT",b[b.SOURCE=96]="SOURCE",b[b.SMALL=97]="SMALL",b[b.SPAN=98]="SPAN",b[b.STRIKE=99]="STRIKE",b[b.STRONG=100]="STRONG",b[b.STYLE=101]="STYLE",b[b.SUB=102]="SUB",b[b.SUMMARY=103]="SUMMARY",b[b.SUP=104]="SUP",b[b.TABLE=105]="TABLE",b[b.TBODY=106]="TBODY",b[b.TEMPLATE=107]="TEMPLATE",b[b.TEXTAREA=108]="TEXTAREA",b[b.TFOOT=109]="TFOOT",b[b.TD=110]="TD",b[b.TH=111]="TH",b[b.THEAD=112]="THEAD",b[b.TITLE=113]="TITLE",b[b.TR=114]="TR",b[b.TRACK=115]="TRACK",b[b.TT=116]="TT",b[b.U=117]="U",b[b.UL=118]="UL",b[b.SVG=119]="SVG",b[b.VAR=120]="VAR",b[b.WBR=121]="WBR",b[b.XMP=122]="XMP"})(C=g.TAG_ID||(g.TAG_ID={}));const I=new Map([[s.A,C.A],[s.ADDRESS,C.ADDRESS],[s.ANNOTATION_XML,C.ANNOTATION_XML],[s.APPLET,C.APPLET],[s.AREA,C.AREA],[s.ARTICLE,C.ARTICLE],[s.ASIDE,C.ASIDE],[s.B,C.B],[s.BASE,C.BASE],[s.BASEFONT,C.BASEFONT],[s.BGSOUND,C.BGSOUND],[s.BIG,C.BIG],[s.BLOCKQUOTE,C.BLOCKQUOTE],[s.BODY,C.BODY],[s.BR,C.BR],[s.BUTTON,C.BUTTON],[s.CAPTION,C.CAPTION],[s.CENTER,C.CENTER],[s.CODE,C.CODE],[s.COL,C.COL],[s.COLGROUP,C.COLGROUP],[s.DD,C.DD],[s.DESC,C.DESC],[s.DETAILS,C.DETAILS],[s.DIALOG,C.DIALOG],[s.DIR,C.DIR],[s.DIV,C.DIV],[s.DL,C.DL],[s.DT,C.DT],[s.EM,C.EM],[s.EMBED,C.EMBED],[s.FIELDSET,C.FIELDSET],[s.FIGCAPTION,C.FIGCAPTION],[s.FIGURE,C.FIGURE],[s.FONT,C.FONT],[s.FOOTER,C.FOOTER],[s.FOREIGN_OBJECT,C.FOREIGN_OBJECT],[s.FORM,C.FORM],[s.FRAME,C.FRAME],[s.FRAMESET,C.FRAMESET],[s.H1,C.H1],[s.H2,C.H2],[s.H3,C.H3],[s.H4,C.H4],[s.H5,C.H5],[s.H6,C.H6],[s.HEAD,C.HEAD],[s.HEADER,C.HEADER],[s.HGROUP,C.HGROUP],[s.HR,C.HR],[s.HTML,C.HTML],[s.I,C.I],[s.IMG,C.IMG],[s.IMAGE,C.IMAGE],[s.INPUT,C.INPUT],[s.IFRAME,C.IFRAME],[s.KEYGEN,C.KEYGEN],[s.LABEL,C.LABEL],[s.LI,C.LI],[s.LINK,C.LINK],[s.LISTING,C.LISTING],[s.MAIN,C.MAIN],[s.MALIGNMARK,C.MALIGNMARK],[s.MARQUEE,C.MARQUEE],[s.MATH,C.MATH],[s.MENU,C.MENU],[s.META,C.META],[s.MGLYPH,C.MGLYPH],[s.MI,C.MI],[s.MO,C.MO],[s.MN,C.MN],[s.MS,C.MS],[s.MTEXT,C.MTEXT],[s.NAV,C.NAV],[s.NOBR,C.NOBR],[s.NOFRAMES,C.NOFRAMES],[s.NOEMBED,C.NOEMBED],[s.NOSCRIPT,C.NOSCRIPT],[s.OBJECT,C.OBJECT],[s.OL,C.OL],[s.OPTGROUP,C.OPTGROUP],[s.OPTION,C.OPTION],[s.P,C.P],[s.PARAM,C.PARAM],[s.PLAINTEXT,C.PLAINTEXT],[s.PRE,C.PRE],[s.RB,C.RB],[s.RP,C.RP],[s.RT,C.RT],[s.RTC,C.RTC],[s.RUBY,C.RUBY],[s.S,C.S],[s.SCRIPT,C.SCRIPT],[s.SECTION,C.SECTION],[s.SELECT,C.SELECT],[s.SOURCE,C.SOURCE],[s.SMALL,C.SMALL],[s.SPAN,C.SPAN],[s.STRIKE,C.STRIKE],[s.STRONG,C.STRONG],[s.STYLE,C.STYLE],[s.SUB,C.SUB],[s.SUMMARY,C.SUMMARY],[s.SUP,C.SUP],[s.TABLE,C.TABLE],[s.TBODY,C.TBODY],[s.TEMPLATE,C.TEMPLATE],[s.TEXTAREA,C.TEXTAREA],[s.TFOOT,C.TFOOT],[s.TD,C.TD],[s.TH,C.TH],[s.THEAD,C.THEAD],[s.TITLE,C.TITLE],[s.TR,C.TR],[s.TRACK,C.TRACK],[s.TT,C.TT],[s.U,C.U],[s.UL,C.UL],[s.SVG,C.SVG],[s.VAR,C.VAR],[s.WBR,C.WBR],[s.XMP,C.XMP]]);function A(b){var w;return(w=I.get(b))!==null&&w!==void 0?w:C.UNKNOWN}g.getTagID=A;const d=C;g.SPECIAL_ELEMENTS={[a.HTML]:new Set([d.ADDRESS,d.APPLET,d.AREA,d.ARTICLE,d.ASIDE,d.BASE,d.BASEFONT,d.BGSOUND,d.BLOCKQUOTE,d.BODY,d.BR,d.BUTTON,d.CAPTION,d.CENTER,d.COL,d.COLGROUP,d.DD,d.DETAILS,d.DIR,d.DIV,d.DL,d.DT,d.EMBED,d.FIELDSET,d.FIGCAPTION,d.FIGURE,d.FOOTER,d.FORM,d.FRAME,d.FRAMESET,d.H1,d.H2,d.H3,d.H4,d.H5,d.H6,d.HEAD,d.HEADER,d.HGROUP,d.HR,d.HTML,d.IFRAME,d.IMG,d.INPUT,d.LI,d.LINK,d.LISTING,d.MAIN,d.MARQUEE,d.MENU,d.META,d.NAV,d.NOEMBED,d.NOFRAMES,d.NOSCRIPT,d.OBJECT,d.OL,d.P,d.PARAM,d.PLAINTEXT,d.PRE,d.SCRIPT,d.SECTION,d.SELECT,d.SOURCE,d.STYLE,d.SUMMARY,d.TABLE,d.TBODY,d.TD,d.TEMPLATE,d.TEXTAREA,d.TFOOT,d.TH,d.THEAD,d.TITLE,d.TR,d.TRACK,d.UL,d.WBR,d.XMP]),[a.MATHML]:new Set([d.MI,d.MO,d.MN,d.MS,d.MTEXT,d.ANNOTATION_XML]),[a.SVG]:new Set([d.TITLE,d.FOREIGN_OBJECT,d.DESC]),[a.XLINK]:new Set,[a.XML]:new Set,[a.XMLNS]:new Set};function h(b){return b===d.H1||b===d.H2||b===d.H3||b===d.H4||b===d.H5||b===d.H6}g.isNumberedHeader=h;const y=new Set([s.STYLE,s.SCRIPT,s.XMP,s.IFRAME,s.NOEMBED,s.NOFRAMES,s.PLAINTEXT]);function Z(b,w){return y.has(b)||w&&b===s.NOSCRIPT}g.hasUnescapedText=Z})(Ch),Object.defineProperty(Xb,"__esModule",{value:!0}),Xb.Tokenizer=Xb.TokenizerMode=void 0;const e5t=W5,Te=N5,XI=k5,pu=Sb,Jt=CV,s$=Ch,t5t=new Map([[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]);var Me;(function(g){g[g.DATA=0]="DATA",g[g.RCDATA=1]="RCDATA",g[g.RAWTEXT=2]="RAWTEXT",g[g.SCRIPT_DATA=3]="SCRIPT_DATA",g[g.PLAINTEXT=4]="PLAINTEXT",g[g.TAG_OPEN=5]="TAG_OPEN",g[g.END_TAG_OPEN=6]="END_TAG_OPEN",g[g.TAG_NAME=7]="TAG_NAME",g[g.RCDATA_LESS_THAN_SIGN=8]="RCDATA_LESS_THAN_SIGN",g[g.RCDATA_END_TAG_OPEN=9]="RCDATA_END_TAG_OPEN",g[g.RCDATA_END_TAG_NAME=10]="RCDATA_END_TAG_NAME",g[g.RAWTEXT_LESS_THAN_SIGN=11]="RAWTEXT_LESS_THAN_SIGN",g[g.RAWTEXT_END_TAG_OPEN=12]="RAWTEXT_END_TAG_OPEN",g[g.RAWTEXT_END_TAG_NAME=13]="RAWTEXT_END_TAG_NAME",g[g.SCRIPT_DATA_LESS_THAN_SIGN=14]="SCRIPT_DATA_LESS_THAN_SIGN",g[g.SCRIPT_DATA_END_TAG_OPEN=15]="SCRIPT_DATA_END_TAG_OPEN",g[g.SCRIPT_DATA_END_TAG_NAME=16]="SCRIPT_DATA_END_TAG_NAME",g[g.SCRIPT_DATA_ESCAPE_START=17]="SCRIPT_DATA_ESCAPE_START",g[g.SCRIPT_DATA_ESCAPE_START_DASH=18]="SCRIPT_DATA_ESCAPE_START_DASH",g[g.SCRIPT_DATA_ESCAPED=19]="SCRIPT_DATA_ESCAPED",g[g.SCRIPT_DATA_ESCAPED_DASH=20]="SCRIPT_DATA_ESCAPED_DASH",g[g.SCRIPT_DATA_ESCAPED_DASH_DASH=21]="SCRIPT_DATA_ESCAPED_DASH_DASH",g[g.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]="SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN",g[g.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]="SCRIPT_DATA_ESCAPED_END_TAG_OPEN",g[g.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]="SCRIPT_DATA_ESCAPED_END_TAG_NAME",g[g.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]="SCRIPT_DATA_DOUBLE_ESCAPE_START",g[g.SCRIPT_DATA_DOUBLE_ESCAPED=26]="SCRIPT_DATA_DOUBLE_ESCAPED",g[g.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH",g[g.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH",g[g.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]="SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN",g[g.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]="SCRIPT_DATA_DOUBLE_ESCAPE_END",g[g.BEFORE_ATTRIBUTE_NAME=31]="BEFORE_ATTRIBUTE_NAME",g[g.ATTRIBUTE_NAME=32]="ATTRIBUTE_NAME",g[g.AFTER_ATTRIBUTE_NAME=33]="AFTER_ATTRIBUTE_NAME",g[g.BEFORE_ATTRIBUTE_VALUE=34]="BEFORE_ATTRIBUTE_VALUE",g[g.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]="ATTRIBUTE_VALUE_DOUBLE_QUOTED",g[g.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]="ATTRIBUTE_VALUE_SINGLE_QUOTED",g[g.ATTRIBUTE_VALUE_UNQUOTED=37]="ATTRIBUTE_VALUE_UNQUOTED",g[g.AFTER_ATTRIBUTE_VALUE_QUOTED=38]="AFTER_ATTRIBUTE_VALUE_QUOTED",g[g.SELF_CLOSING_START_TAG=39]="SELF_CLOSING_START_TAG",g[g.BOGUS_COMMENT=40]="BOGUS_COMMENT",g[g.MARKUP_DECLARATION_OPEN=41]="MARKUP_DECLARATION_OPEN",g[g.COMMENT_START=42]="COMMENT_START",g[g.COMMENT_START_DASH=43]="COMMENT_START_DASH",g[g.COMMENT=44]="COMMENT",g[g.COMMENT_LESS_THAN_SIGN=45]="COMMENT_LESS_THAN_SIGN",g[g.COMMENT_LESS_THAN_SIGN_BANG=46]="COMMENT_LESS_THAN_SIGN_BANG",g[g.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]="COMMENT_LESS_THAN_SIGN_BANG_DASH",g[g.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH",g[g.COMMENT_END_DASH=49]="COMMENT_END_DASH",g[g.COMMENT_END=50]="COMMENT_END",g[g.COMMENT_END_BANG=51]="COMMENT_END_BANG",g[g.DOCTYPE=52]="DOCTYPE",g[g.BEFORE_DOCTYPE_NAME=53]="BEFORE_DOCTYPE_NAME",g[g.DOCTYPE_NAME=54]="DOCTYPE_NAME",g[g.AFTER_DOCTYPE_NAME=55]="AFTER_DOCTYPE_NAME",g[g.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]="AFTER_DOCTYPE_PUBLIC_KEYWORD",g[g.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER",g[g.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED",g[g.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED",g[g.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]="AFTER_DOCTYPE_PUBLIC_IDENTIFIER",g[g.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS",g[g.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]="AFTER_DOCTYPE_SYSTEM_KEYWORD",g[g.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER",g[g.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED",g[g.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED",g[g.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]="AFTER_DOCTYPE_SYSTEM_IDENTIFIER",g[g.BOGUS_DOCTYPE=67]="BOGUS_DOCTYPE",g[g.CDATA_SECTION=68]="CDATA_SECTION",g[g.CDATA_SECTION_BRACKET=69]="CDATA_SECTION_BRACKET",g[g.CDATA_SECTION_END=70]="CDATA_SECTION_END",g[g.CHARACTER_REFERENCE=71]="CHARACTER_REFERENCE",g[g.NAMED_CHARACTER_REFERENCE=72]="NAMED_CHARACTER_REFERENCE",g[g.AMBIGUOUS_AMPERSAND=73]="AMBIGUOUS_AMPERSAND",g[g.NUMERIC_CHARACTER_REFERENCE=74]="NUMERIC_CHARACTER_REFERENCE",g[g.HEXADEMICAL_CHARACTER_REFERENCE_START=75]="HEXADEMICAL_CHARACTER_REFERENCE_START",g[g.HEXADEMICAL_CHARACTER_REFERENCE=76]="HEXADEMICAL_CHARACTER_REFERENCE",g[g.DECIMAL_CHARACTER_REFERENCE=77]="DECIMAL_CHARACTER_REFERENCE",g[g.NUMERIC_CHARACTER_REFERENCE_END=78]="NUMERIC_CHARACTER_REFERENCE_END"})(Me||(Me={})),Xb.TokenizerMode={DATA:Me.DATA,RCDATA:Me.RCDATA,RAWTEXT:Me.RAWTEXT,SCRIPT_DATA:Me.SCRIPT_DATA,PLAINTEXT:Me.PLAINTEXT,CDATA_SECTION:Me.CDATA_SECTION};function cV(g){return g>=Te.CODE_POINTS.DIGIT_0&&g<=Te.CODE_POINTS.DIGIT_9}function AV(g){return g>=Te.CODE_POINTS.LATIN_CAPITAL_A&&g<=Te.CODE_POINTS.LATIN_CAPITAL_Z}function i5t(g){return g>=Te.CODE_POINTS.LATIN_SMALL_A&&g<=Te.CODE_POINTS.LATIN_SMALL_Z}function Zm(g){return i5t(g)||AV(g)}function I$(g){return Zm(g)||cV(g)}function h9e(g){return g>=Te.CODE_POINTS.LATIN_CAPITAL_A&&g<=Te.CODE_POINTS.LATIN_CAPITAL_F}function f9e(g){return g>=Te.CODE_POINTS.LATIN_SMALL_A&&g<=Te.CODE_POINTS.LATIN_SMALL_F}function n5t(g){return cV(g)||h9e(g)||f9e(g)}function X5(g){return g+32}function m9e(g){return g===Te.CODE_POINTS.SPACE||g===Te.CODE_POINTS.LINE_FEED||g===Te.CODE_POINTS.TABULATION||g===Te.CODE_POINTS.FORM_FEED}function r5t(g){return g===Te.CODE_POINTS.EQUALS_SIGN||I$(g)}function p9e(g){return m9e(g)||g===Te.CODE_POINTS.SOLIDUS||g===Te.CODE_POINTS.GREATER_THAN_SIGN}let g5t=function(){function g(a,s){T(this,g),this.options=a,this.handler=s,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=Me.DATA,this.returnState=Me.DATA,this.charRefCode=-1,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new e5t.Preprocessor(s),this.currentLocation=this.getCurrentLocation(-1)}return E(g,[{key:"_err",value:function(s){var C,I;(I=(C=this.handler).onParseError)===null||I===void 0||I.call(C,this.preprocessor.getError(s))}},{key:"getCurrentLocation",value:function(s){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-s,startOffset:this.preprocessor.offset-s,endLine:-1,endCol:-1,endOffset:-1}:null}},{key:"_runParsingLoop",value:function(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;const s=this._consume();this._ensureHibernation()||this._callState(s)}this.inLoop=!1}}},{key:"pause",value:function(){this.paused=!0}},{key:"resume",value:function(s){if(!this.paused)throw new Error("Parser was already resumed");this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||s?.())}},{key:"write",value:function(s,C,I){this.active=!0,this.preprocessor.write(s,C),this._runParsingLoop(),this.paused||I?.()}},{key:"insertHtmlAtCurrentPos",value:function(s){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(s),this._runParsingLoop()}},{key:"_ensureHibernation",value:function(){return this.preprocessor.endOfChunkHit?(this._unconsume(this.consumedAfterSnapshot),this.active=!1,!0):!1}},{key:"_consume",value:function(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}},{key:"_unconsume",value:function(s){this.consumedAfterSnapshot-=s,this.preprocessor.retreat(s)}},{key:"_reconsumeInState",value:function(s,C){this.state=s,this._callState(C)}},{key:"_advanceBy",value:function(s){this.consumedAfterSnapshot+=s;for(let C=0;C0&&this._err(Jt.ERR.endTagWithAttributes),s.selfClosing&&this._err(Jt.ERR.endTagWithTrailingSolidus),this.handler.onEndTag(s)),this.preprocessor.dropParsedChunk()}},{key:"emitCurrentComment",value:function(s){this.prepareToken(s),this.handler.onComment(s),this.preprocessor.dropParsedChunk()}},{key:"emitCurrentDoctype",value:function(s){this.prepareToken(s),this.handler.onDoctype(s),this.preprocessor.dropParsedChunk()}},{key:"_emitCurrentCharacterToken",value:function(s){if(this.currentCharacterToken){switch(s&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=s.startLine,this.currentCharacterToken.location.endCol=s.startCol,this.currentCharacterToken.location.endOffset=s.startOffset),this.currentCharacterToken.type){case XI.TokenType.CHARACTER:{this.handler.onCharacter(this.currentCharacterToken);break}case XI.TokenType.NULL_CHARACTER:{this.handler.onNullCharacter(this.currentCharacterToken);break}case XI.TokenType.WHITESPACE_CHARACTER:{this.handler.onWhitespaceCharacter(this.currentCharacterToken);break}}this.currentCharacterToken=null}}},{key:"_emitEOFToken",value:function(){const s=this.getCurrentLocation(0);s&&(s.endLine=s.startLine,s.endCol=s.startCol,s.endOffset=s.startOffset),this._emitCurrentCharacterToken(s),this.handler.onEof({type:XI.TokenType.EOF,location:s}),this.active=!1}},{key:"_appendCharToCurrentCharacterToken",value:function(s,C){if(this.currentCharacterToken)if(this.currentCharacterToken.type!==s)this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk();else{this.currentCharacterToken.chars+=C;return}this._createCharacterToken(s,C)}},{key:"_emitCodePoint",value:function(s){const C=m9e(s)?XI.TokenType.WHITESPACE_CHARACTER:s===Te.CODE_POINTS.NULL?XI.TokenType.NULL_CHARACTER:XI.TokenType.CHARACTER;this._appendCharToCurrentCharacterToken(C,String.fromCodePoint(s))}},{key:"_emitChars",value:function(s){this._appendCharToCurrentCharacterToken(XI.TokenType.CHARACTER,s)}},{key:"_matchNamedCharacterReference",value:function(s){let C=null,I=0,A=!1;for(let d=0,h=pu.htmlDecodeTree[0];d>=0&&(d=(0,pu.determineBranch)(pu.htmlDecodeTree,h,d+1,s),!(d<0));s=this._consume()){I+=1,h=pu.htmlDecodeTree[d];const y=h&pu.BinTrieFlags.VALUE_LENGTH;if(y){const Z=(y>>14)-1;if(s!==Te.CODE_POINTS.SEMICOLON&&this._isCharacterReferenceInAttribute()&&r5t(this.preprocessor.peek(1))?(C=[Te.CODE_POINTS.AMPERSAND],d+=Z):(C=Z===0?[pu.htmlDecodeTree[d]&~pu.BinTrieFlags.VALUE_LENGTH]:Z===1?[pu.htmlDecodeTree[++d]]:[pu.htmlDecodeTree[++d],pu.htmlDecodeTree[++d]],I=0,A=s!==Te.CODE_POINTS.SEMICOLON),Z===0){this._consume();break}}}return this._unconsume(I),A&&!this.preprocessor.endOfChunkHit&&this._err(Jt.ERR.missingSemicolonAfterCharacterReference),this._unconsume(1),C}},{key:"_isCharacterReferenceInAttribute",value:function(){return this.returnState===Me.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===Me.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===Me.ATTRIBUTE_VALUE_UNQUOTED}},{key:"_flushCodePointConsumedAsCharacterReference",value:function(s){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(s):this._emitCodePoint(s)}},{key:"_callState",value:function(s){switch(this.state){case Me.DATA:{this._stateData(s);break}case Me.RCDATA:{this._stateRcdata(s);break}case Me.RAWTEXT:{this._stateRawtext(s);break}case Me.SCRIPT_DATA:{this._stateScriptData(s);break}case Me.PLAINTEXT:{this._statePlaintext(s);break}case Me.TAG_OPEN:{this._stateTagOpen(s);break}case Me.END_TAG_OPEN:{this._stateEndTagOpen(s);break}case Me.TAG_NAME:{this._stateTagName(s);break}case Me.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(s);break}case Me.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(s);break}case Me.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(s);break}case Me.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(s);break}case Me.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(s);break}case Me.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(s);break}case Me.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(s);break}case Me.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(s);break}case Me.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(s);break}case Me.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(s);break}case Me.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(s);break}case Me.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(s);break}case Me.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(s);break}case Me.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(s);break}case Me.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(s);break}case Me.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(s);break}case Me.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(s);break}case Me.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(s);break}case Me.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(s);break}case Me.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(s);break}case Me.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(s);break}case Me.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(s);break}case Me.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(s);break}case Me.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(s);break}case Me.ATTRIBUTE_NAME:{this._stateAttributeName(s);break}case Me.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(s);break}case Me.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(s);break}case Me.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(s);break}case Me.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(s);break}case Me.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(s);break}case Me.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(s);break}case Me.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(s);break}case Me.BOGUS_COMMENT:{this._stateBogusComment(s);break}case Me.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(s);break}case Me.COMMENT_START:{this._stateCommentStart(s);break}case Me.COMMENT_START_DASH:{this._stateCommentStartDash(s);break}case Me.COMMENT:{this._stateComment(s);break}case Me.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(s);break}case Me.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(s);break}case Me.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(s);break}case Me.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(s);break}case Me.COMMENT_END_DASH:{this._stateCommentEndDash(s);break}case Me.COMMENT_END:{this._stateCommentEnd(s);break}case Me.COMMENT_END_BANG:{this._stateCommentEndBang(s);break}case Me.DOCTYPE:{this._stateDoctype(s);break}case Me.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(s);break}case Me.DOCTYPE_NAME:{this._stateDoctypeName(s);break}case Me.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(s);break}case Me.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(s);break}case Me.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(s);break}case Me.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(s);break}case Me.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(s);break}case Me.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(s);break}case Me.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(s);break}case Me.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(s);break}case Me.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(s);break}case Me.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(s);break}case Me.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(s);break}case Me.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(s);break}case Me.BOGUS_DOCTYPE:{this._stateBogusDoctype(s);break}case Me.CDATA_SECTION:{this._stateCdataSection(s);break}case Me.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(s);break}case Me.CDATA_SECTION_END:{this._stateCdataSectionEnd(s);break}case Me.CHARACTER_REFERENCE:{this._stateCharacterReference(s);break}case Me.NAMED_CHARACTER_REFERENCE:{this._stateNamedCharacterReference(s);break}case Me.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(s);break}case Me.NUMERIC_CHARACTER_REFERENCE:{this._stateNumericCharacterReference(s);break}case Me.HEXADEMICAL_CHARACTER_REFERENCE_START:{this._stateHexademicalCharacterReferenceStart(s);break}case Me.HEXADEMICAL_CHARACTER_REFERENCE:{this._stateHexademicalCharacterReference(s);break}case Me.DECIMAL_CHARACTER_REFERENCE:{this._stateDecimalCharacterReference(s);break}case Me.NUMERIC_CHARACTER_REFERENCE_END:{this._stateNumericCharacterReferenceEnd(s);break}default:throw new Error("Unknown state")}}},{key:"_stateData",value:function(s){switch(s){case Te.CODE_POINTS.LESS_THAN_SIGN:{this.state=Me.TAG_OPEN;break}case Te.CODE_POINTS.AMPERSAND:{this.returnState=Me.DATA,this.state=Me.CHARACTER_REFERENCE;break}case Te.CODE_POINTS.NULL:{this._err(Jt.ERR.unexpectedNullCharacter),this._emitCodePoint(s);break}case Te.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(s)}}},{key:"_stateRcdata",value:function(s){switch(s){case Te.CODE_POINTS.AMPERSAND:{this.returnState=Me.RCDATA,this.state=Me.CHARACTER_REFERENCE;break}case Te.CODE_POINTS.LESS_THAN_SIGN:{this.state=Me.RCDATA_LESS_THAN_SIGN;break}case Te.CODE_POINTS.NULL:{this._err(Jt.ERR.unexpectedNullCharacter),this._emitChars(Te.REPLACEMENT_CHARACTER);break}case Te.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(s)}}},{key:"_stateRawtext",value:function(s){switch(s){case Te.CODE_POINTS.LESS_THAN_SIGN:{this.state=Me.RAWTEXT_LESS_THAN_SIGN;break}case Te.CODE_POINTS.NULL:{this._err(Jt.ERR.unexpectedNullCharacter),this._emitChars(Te.REPLACEMENT_CHARACTER);break}case Te.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(s)}}},{key:"_stateScriptData",value:function(s){switch(s){case Te.CODE_POINTS.LESS_THAN_SIGN:{this.state=Me.SCRIPT_DATA_LESS_THAN_SIGN;break}case Te.CODE_POINTS.NULL:{this._err(Jt.ERR.unexpectedNullCharacter),this._emitChars(Te.REPLACEMENT_CHARACTER);break}case Te.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(s)}}},{key:"_statePlaintext",value:function(s){switch(s){case Te.CODE_POINTS.NULL:{this._err(Jt.ERR.unexpectedNullCharacter),this._emitChars(Te.REPLACEMENT_CHARACTER);break}case Te.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(s)}}},{key:"_stateTagOpen",value:function(s){if(Zm(s))this._createStartTagToken(),this.state=Me.TAG_NAME,this._stateTagName(s);else switch(s){case Te.CODE_POINTS.EXCLAMATION_MARK:{this.state=Me.MARKUP_DECLARATION_OPEN;break}case Te.CODE_POINTS.SOLIDUS:{this.state=Me.END_TAG_OPEN;break}case Te.CODE_POINTS.QUESTION_MARK:{this._err(Jt.ERR.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=Me.BOGUS_COMMENT,this._stateBogusComment(s);break}case Te.CODE_POINTS.EOF:{this._err(Jt.ERR.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(Jt.ERR.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=Me.DATA,this._stateData(s)}}},{key:"_stateEndTagOpen",value:function(s){if(Zm(s))this._createEndTagToken(),this.state=Me.TAG_NAME,this._stateTagName(s);else switch(s){case Te.CODE_POINTS.GREATER_THAN_SIGN:{this._err(Jt.ERR.missingEndTagName),this.state=Me.DATA;break}case Te.CODE_POINTS.EOF:{this._err(Jt.ERR.eofBeforeTagName),this._emitChars("");break}case Te.CODE_POINTS.NULL:{this._err(Jt.ERR.unexpectedNullCharacter),this.state=Me.SCRIPT_DATA_ESCAPED,this._emitChars(Te.REPLACEMENT_CHARACTER);break}case Te.CODE_POINTS.EOF:{this._err(Jt.ERR.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=Me.SCRIPT_DATA_ESCAPED,this._emitCodePoint(s)}}},{key:"_stateScriptDataEscapedLessThanSign",value:function(s){s===Te.CODE_POINTS.SOLIDUS?this.state=Me.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:Zm(s)?(this._emitChars("<"),this.state=Me.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(s)):(this._emitChars("<"),this.state=Me.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(s))}},{key:"_stateScriptDataEscapedEndTagOpen",value:function(s){Zm(s)?(this.state=Me.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(s)):(this._emitChars("");break}case Te.CODE_POINTS.NULL:{this._err(Jt.ERR.unexpectedNullCharacter),this.state=Me.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(Te.REPLACEMENT_CHARACTER);break}case Te.CODE_POINTS.EOF:{this._err(Jt.ERR.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=Me.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(s)}}},{key:"_stateScriptDataDoubleEscapedLessThanSign",value:function(s){s===Te.CODE_POINTS.SOLIDUS?(this.state=Me.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=Me.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(s))}},{key:"_stateScriptDataDoubleEscapeEnd",value:function(s){if(this.preprocessor.startsWith(Te.SEQUENCES.SCRIPT,!1)&&p9e(this.preprocessor.peek(Te.SEQUENCES.SCRIPT.length))){this._emitCodePoint(s);for(let C=0;C1114111)this._err(Jt.ERR.characterReferenceOutsideUnicodeRange),this.charRefCode=Te.CODE_POINTS.REPLACEMENT_CHARACTER;else if((0,Te.isSurrogate)(this.charRefCode))this._err(Jt.ERR.surrogateCharacterReference),this.charRefCode=Te.CODE_POINTS.REPLACEMENT_CHARACTER;else if((0,Te.isUndefinedCodePoint)(this.charRefCode))this._err(Jt.ERR.noncharacterCharacterReference);else if((0,Te.isControlCodePoint)(this.charRefCode)||this.charRefCode===Te.CODE_POINTS.CARRIAGE_RETURN){this._err(Jt.ERR.controlCharacterReference);const C=t5t.get(this.charRefCode);C!==void 0&&(this.charRefCode=C)}this._flushCodePointConsumedAsCharacterReference(this.charRefCode),this._reconsumeInState(this.returnState,s)}}]),g}();Xb.Tokenizer=g5t;var x5={};Object.defineProperty(x5,"__esModule",{value:!0}),x5.OpenElementStack=void 0;const jt=Ch,b9e=new Set([jt.TAG_ID.DD,jt.TAG_ID.DT,jt.TAG_ID.LI,jt.TAG_ID.OPTGROUP,jt.TAG_ID.OPTION,jt.TAG_ID.P,jt.TAG_ID.RB,jt.TAG_ID.RP,jt.TAG_ID.RT,jt.TAG_ID.RTC]),y9e=new Set([...b9e,jt.TAG_ID.CAPTION,jt.TAG_ID.COLGROUP,jt.TAG_ID.TBODY,jt.TAG_ID.TD,jt.TAG_ID.TFOOT,jt.TAG_ID.TH,jt.TAG_ID.THEAD,jt.TAG_ID.TR]),D5=new Map([[jt.TAG_ID.APPLET,jt.NS.HTML],[jt.TAG_ID.CAPTION,jt.NS.HTML],[jt.TAG_ID.HTML,jt.NS.HTML],[jt.TAG_ID.MARQUEE,jt.NS.HTML],[jt.TAG_ID.OBJECT,jt.NS.HTML],[jt.TAG_ID.TABLE,jt.NS.HTML],[jt.TAG_ID.TD,jt.NS.HTML],[jt.TAG_ID.TEMPLATE,jt.NS.HTML],[jt.TAG_ID.TH,jt.NS.HTML],[jt.TAG_ID.ANNOTATION_XML,jt.NS.MATHML],[jt.TAG_ID.MI,jt.NS.MATHML],[jt.TAG_ID.MN,jt.NS.MATHML],[jt.TAG_ID.MO,jt.NS.MATHML],[jt.TAG_ID.MS,jt.NS.MATHML],[jt.TAG_ID.MTEXT,jt.NS.MATHML],[jt.TAG_ID.DESC,jt.NS.SVG],[jt.TAG_ID.FOREIGN_OBJECT,jt.NS.SVG],[jt.TAG_ID.TITLE,jt.NS.SVG]]),o5t=[jt.TAG_ID.H1,jt.TAG_ID.H2,jt.TAG_ID.H3,jt.TAG_ID.H4,jt.TAG_ID.H5,jt.TAG_ID.H6],a5t=[jt.TAG_ID.TR,jt.TAG_ID.TEMPLATE,jt.TAG_ID.HTML],s5t=[jt.TAG_ID.TBODY,jt.TAG_ID.TFOOT,jt.TAG_ID.THEAD,jt.TAG_ID.TEMPLATE,jt.TAG_ID.HTML],I5t=[jt.TAG_ID.TABLE,jt.TAG_ID.TEMPLATE,jt.TAG_ID.HTML],l5t=[jt.TAG_ID.TD,jt.TAG_ID.TH];let C5t=function(){function g(a,s,C){T(this,g),this.treeAdapter=s,this.handler=C,this.items=[],this.tagIDs=[],this.stackTop=-1,this.tmplCount=0,this.currentTagId=jt.TAG_ID.UNKNOWN,this.current=a}return E(g,[{key:"currentTmplContentOrNode",get:function(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}},{key:"_indexOf",value:function(s){return this.items.lastIndexOf(s,this.stackTop)}},{key:"_isInTemplate",value:function(){return this.currentTagId===jt.TAG_ID.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===jt.NS.HTML}},{key:"_updateCurrentElement",value:function(){this.current=this.items[this.stackTop],this.currentTagId=this.tagIDs[this.stackTop]}},{key:"push",value:function(s,C){this.stackTop++,this.items[this.stackTop]=s,this.current=s,this.tagIDs[this.stackTop]=C,this.currentTagId=C,this._isInTemplate()&&this.tmplCount++,this.handler.onItemPush(s,C,!0)}},{key:"pop",value:function(){const s=this.current;this.tmplCount>0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(s,!0)}},{key:"replace",value:function(s,C){const I=this._indexOf(s);this.items[I]=C,I===this.stackTop&&(this.current=C)}},{key:"insertAfter",value:function(s,C,I){const A=this._indexOf(s)+1;this.items.splice(A,0,C),this.tagIDs.splice(A,0,I),this.stackTop++,A===this.stackTop&&this._updateCurrentElement(),this.handler.onItemPush(this.current,this.currentTagId,A===this.stackTop)}},{key:"popUntilTagNamePopped",value:function(s){let C=this.stackTop+1;do C=this.tagIDs.lastIndexOf(s,C-1);while(C>0&&this.treeAdapter.getNamespaceURI(this.items[C])!==jt.NS.HTML);this.shortenToLength(C<0?0:C)}},{key:"shortenToLength",value:function(s){for(;this.stackTop>=s;){const C=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(C,this.stackTop=0;I--)if(s.includes(this.tagIDs[I])&&this.treeAdapter.getNamespaceURI(this.items[I])===C)return I;return-1}},{key:"clearBackTo",value:function(s,C){const I=this._indexOfTagNames(s,C);this.shortenToLength(I+1)}},{key:"clearBackToTableContext",value:function(){this.clearBackTo(I5t,jt.NS.HTML)}},{key:"clearBackToTableBodyContext",value:function(){this.clearBackTo(s5t,jt.NS.HTML)}},{key:"clearBackToTableRowContext",value:function(){this.clearBackTo(a5t,jt.NS.HTML)}},{key:"remove",value:function(s){const C=this._indexOf(s);C>=0&&(C===this.stackTop?this.pop():(this.items.splice(C,1),this.tagIDs.splice(C,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(s,!1)))}},{key:"tryPeekProperlyNestedBodyElement",value:function(){return this.stackTop>=1&&this.tagIDs[1]===jt.TAG_ID.BODY?this.items[1]:null}},{key:"contains",value:function(s){return this._indexOf(s)>-1}},{key:"getCommonAncestor",value:function(s){const C=this._indexOf(s)-1;return C>=0?this.items[C]:null}},{key:"isRootHtmlElementCurrent",value:function(){return this.stackTop===0&&this.tagIDs[0]===jt.TAG_ID.HTML}},{key:"hasInScope",value:function(s){for(let C=this.stackTop;C>=0;C--){const I=this.tagIDs[C],A=this.treeAdapter.getNamespaceURI(this.items[C]);if(I===s&&A===jt.NS.HTML)return!0;if(D5.get(I)===A)return!1}return!0}},{key:"hasNumberedHeaderInScope",value:function(){for(let s=this.stackTop;s>=0;s--){const C=this.tagIDs[s],I=this.treeAdapter.getNamespaceURI(this.items[s]);if((0,jt.isNumberedHeader)(C)&&I===jt.NS.HTML)return!0;if(D5.get(C)===I)return!1}return!0}},{key:"hasInListItemScope",value:function(s){for(let C=this.stackTop;C>=0;C--){const I=this.tagIDs[C],A=this.treeAdapter.getNamespaceURI(this.items[C]);if(I===s&&A===jt.NS.HTML)return!0;if((I===jt.TAG_ID.UL||I===jt.TAG_ID.OL)&&A===jt.NS.HTML||D5.get(I)===A)return!1}return!0}},{key:"hasInButtonScope",value:function(s){for(let C=this.stackTop;C>=0;C--){const I=this.tagIDs[C],A=this.treeAdapter.getNamespaceURI(this.items[C]);if(I===s&&A===jt.NS.HTML)return!0;if(I===jt.TAG_ID.BUTTON&&A===jt.NS.HTML||D5.get(I)===A)return!1}return!0}},{key:"hasInTableScope",value:function(s){for(let C=this.stackTop;C>=0;C--){const I=this.tagIDs[C];if(this.treeAdapter.getNamespaceURI(this.items[C])===jt.NS.HTML){if(I===s)return!0;if(I===jt.TAG_ID.TABLE||I===jt.TAG_ID.TEMPLATE||I===jt.TAG_ID.HTML)return!1}}return!0}},{key:"hasTableBodyContextInTableScope",value:function(){for(let s=this.stackTop;s>=0;s--){const C=this.tagIDs[s];if(this.treeAdapter.getNamespaceURI(this.items[s])===jt.NS.HTML){if(C===jt.TAG_ID.TBODY||C===jt.TAG_ID.THEAD||C===jt.TAG_ID.TFOOT)return!0;if(C===jt.TAG_ID.TABLE||C===jt.TAG_ID.HTML)return!1}}return!0}},{key:"hasInSelectScope",value:function(s){for(let C=this.stackTop;C>=0;C--){const I=this.tagIDs[C];if(this.treeAdapter.getNamespaceURI(this.items[C])===jt.NS.HTML){if(I===s)return!0;if(I!==jt.TAG_ID.OPTION&&I!==jt.TAG_ID.OPTGROUP)return!1}}return!0}},{key:"generateImpliedEndTags",value:function(){for(;b9e.has(this.currentTagId);)this.pop()}},{key:"generateImpliedEndTagsThoroughly",value:function(){for(;y9e.has(this.currentTagId);)this.pop()}},{key:"generateImpliedEndTagsWithExclusion",value:function(s){for(;this.currentTagId!==s&&y9e.has(this.currentTagId);)this.pop()}}]),g}();x5.OpenElementStack=C5t;var v9e={};(function(g){Object.defineProperty(g,"__esModule",{value:!0}),g.FormattingElementList=g.EntryType=void 0;const a=3;var s;(function(A){A[A.Marker=0]="Marker",A[A.Element=1]="Element"})(s=g.EntryType||(g.EntryType={}));const C={type:s.Marker};let I=function(){function A(d){T(this,A),this.treeAdapter=d,this.entries=[],this.bookmark=null}return E(A,[{key:"_getNoahArkConditionCandidates",value:function(h,y){const Z=[],b=y.length,w=this.treeAdapter.getTagName(h),S=this.treeAdapter.getNamespaceURI(h);for(let R=0;R[S.name,S.value]));let w=0;for(let S=0;Sb.get(H.name)===H.value)&&(w+=1,w>=a&&this.entries.splice(R.idx,1))}}},{key:"insertMarker",value:function(){this.entries.unshift(C)}},{key:"pushElement",value:function(h,y){this._ensureNoahArkCondition(h),this.entries.unshift({type:s.Element,element:h,token:y})}},{key:"insertElementAfterBookmark",value:function(h,y){const Z=this.entries.indexOf(this.bookmark);this.entries.splice(Z,0,{type:s.Element,element:h,token:y})}},{key:"removeEntry",value:function(h){const y=this.entries.indexOf(h);y>=0&&this.entries.splice(y,1)}},{key:"clearToLastMarker",value:function(){const h=this.entries.indexOf(C);h>=0?this.entries.splice(0,h+1):this.entries.length=0}},{key:"getElementEntryInScopeWithTagName",value:function(h){const y=this.entries.find(Z=>Z.type===s.Marker||this.treeAdapter.getTagName(Z.element)===h);return y&&y.type===s.Element?y:null}},{key:"getElementEntry",value:function(h){return this.entries.find(y=>y.type===s.Element&&y.element===h)}}]),A}();g.FormattingElementList=I})(v9e);var M5={};(function(g){Object.defineProperty(g,"__esModule",{value:!0}),g.defaultTreeAdapter=void 0;const a=Ch;function s(C){return{nodeName:"#text",value:C,parentNode:null}}g.defaultTreeAdapter={createDocument(){return{nodeName:"#document",mode:a.DOCUMENT_MODE.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:"#document-fragment",childNodes:[]}},createElement(C,I,A){return{nodeName:C,tagName:C,attrs:A,namespaceURI:I,childNodes:[],parentNode:null}},createCommentNode(C){return{nodeName:"#comment",data:C,parentNode:null}},appendChild(C,I){C.childNodes.push(I),I.parentNode=C},insertBefore(C,I,A){const d=C.childNodes.indexOf(A);C.childNodes.splice(d,0,I),I.parentNode=C},setTemplateContent(C,I){C.content=I},getTemplateContent(C){return C.content},setDocumentType(C,I,A,d){const h=C.childNodes.find(y=>y.nodeName==="#documentType");if(h)h.name=I,h.publicId=A,h.systemId=d;else{const y={nodeName:"#documentType",name:I,publicId:A,systemId:d,parentNode:null};g.defaultTreeAdapter.appendChild(C,y)}},setDocumentMode(C,I){C.mode=I},getDocumentMode(C){return C.mode},detachNode(C){if(C.parentNode){const I=C.parentNode.childNodes.indexOf(C);C.parentNode.childNodes.splice(I,1),C.parentNode=null}},insertText(C,I){if(C.childNodes.length>0){const A=C.childNodes[C.childNodes.length-1];if(g.defaultTreeAdapter.isTextNode(A)){A.value+=I;return}}g.defaultTreeAdapter.appendChild(C,s(I))},insertTextBefore(C,I,A){const d=C.childNodes[C.childNodes.indexOf(A)-1];d&&g.defaultTreeAdapter.isTextNode(d)?d.value+=I:g.defaultTreeAdapter.insertBefore(C,s(I),A)},adoptAttributes(C,I){const A=new Set(C.attrs.map(d=>d.name));for(let d=0;dg.startsWith(s))}function f5t(g){return g.name===Z9e&&g.publicId===null&&(g.systemId===null||g.systemId===c5t)}FB.isConforming=f5t;function m5t(g){if(g.name!==Z9e)return YB.DOCUMENT_MODE.QUIRKS;const{systemId:a}=g;if(a&&a.toLowerCase()===A5t)return YB.DOCUMENT_MODE.QUIRKS;let{publicId:s}=g;if(s!==null){if(s=s.toLowerCase(),d5t.has(s))return YB.DOCUMENT_MODE.QUIRKS;let C=a===null?u5t:B9e;if(S9e(s,C))return YB.DOCUMENT_MODE.QUIRKS;if(C=a===null?G9e:h5t,S9e(s,C))return YB.DOCUMENT_MODE.LIMITED_QUIRKS}return YB.DOCUMENT_MODE.NO_QUIRKS}FB.getDocumentMode=m5t;var l$={};(function(g){Object.defineProperty(g,"__esModule",{value:!0}),g.isIntegrationPoint=g.adjustTokenSVGTagName=g.adjustTokenXMLAttrs=g.adjustTokenSVGAttrs=g.adjustTokenMathMLAttrs=g.causesExit=g.SVG_TAG_NAMES_ADJUSTMENT_MAP=void 0;const a=Ch,s={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},C="definitionurl",I="definitionURL",A=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map(D=>[D.toLowerCase(),D])),d=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:a.NS.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:a.NS.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:a.NS.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:a.NS.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:a.NS.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:a.NS.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:a.NS.XLINK}],["xml:base",{prefix:"xml",name:"base",namespace:a.NS.XML}],["xml:lang",{prefix:"xml",name:"lang",namespace:a.NS.XML}],["xml:space",{prefix:"xml",name:"space",namespace:a.NS.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:a.NS.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:a.NS.XMLNS}]]);g.SVG_TAG_NAMES_ADJUSTMENT_MAP=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map(D=>[D.toLowerCase(),D]));const h=new Set([a.TAG_ID.B,a.TAG_ID.BIG,a.TAG_ID.BLOCKQUOTE,a.TAG_ID.BODY,a.TAG_ID.BR,a.TAG_ID.CENTER,a.TAG_ID.CODE,a.TAG_ID.DD,a.TAG_ID.DIV,a.TAG_ID.DL,a.TAG_ID.DT,a.TAG_ID.EM,a.TAG_ID.EMBED,a.TAG_ID.H1,a.TAG_ID.H2,a.TAG_ID.H3,a.TAG_ID.H4,a.TAG_ID.H5,a.TAG_ID.H6,a.TAG_ID.HEAD,a.TAG_ID.HR,a.TAG_ID.I,a.TAG_ID.IMG,a.TAG_ID.LI,a.TAG_ID.LISTING,a.TAG_ID.MENU,a.TAG_ID.META,a.TAG_ID.NOBR,a.TAG_ID.OL,a.TAG_ID.P,a.TAG_ID.PRE,a.TAG_ID.RUBY,a.TAG_ID.S,a.TAG_ID.SMALL,a.TAG_ID.SPAN,a.TAG_ID.STRONG,a.TAG_ID.STRIKE,a.TAG_ID.SUB,a.TAG_ID.SUP,a.TAG_ID.TABLE,a.TAG_ID.TT,a.TAG_ID.U,a.TAG_ID.UL,a.TAG_ID.VAR]);function y(D){const M=D.tagID;return M===a.TAG_ID.FONT&&D.attrs.some(({name:K})=>K===a.ATTRS.COLOR||K===a.ATTRS.SIZE||K===a.ATTRS.FACE)||h.has(M)}g.causesExit=y;function Z(D){for(let M=0;M0&&this._setContextModes(s,C)}},{key:"onItemPop",value:function(s,C){var I,A;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(s,this.currentToken),(A=(I=this.treeAdapter).onItemPop)===null||A===void 0||A.call(I,s,this.openElements.current),C){let d,h;this.openElements.stackTop===0&&this.fragmentContext?(d=this.fragmentContext,h=this.fragmentContextID):{current:d,currentTagId:h}=this.openElements,this._setContextModes(d,h)}}},{key:"_setContextModes",value:function(s,C){const I=s===this.document||this.treeAdapter.getNamespaceURI(s)===se.NS.HTML;this.currentNotInHTML=!I,this.tokenizer.inForeignNode=!I&&!this._isIntegrationPoint(C,s)}},{key:"_switchToTextParsing",value:function(s,C){this._insertElement(s,se.NS.HTML),this.tokenizer.state=C,this.originalInsertionMode=this.insertionMode,this.insertionMode=tt.TEXT}},{key:"switchToPlaintextParsing",value:function(){this.insertionMode=tt.TEXT,this.originalInsertionMode=tt.IN_BODY,this.tokenizer.state=qs.TokenizerMode.PLAINTEXT}},{key:"_getAdjustedCurrentElement",value:function(){return this.openElements.stackTop===0&&this.fragmentContext?this.fragmentContext:this.openElements.current}},{key:"_findFormInFragmentContext",value:function(){let s=this.fragmentContext;for(;s;){if(this.treeAdapter.getTagName(s)===se.TAG_NAMES.FORM){this.formElement=s;break}s=this.treeAdapter.getParentNode(s)}}},{key:"_initTokenizerForFragmentParsing",value:function(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==se.NS.HTML))switch(this.fragmentContextID){case se.TAG_ID.TITLE:case se.TAG_ID.TEXTAREA:{this.tokenizer.state=qs.TokenizerMode.RCDATA;break}case se.TAG_ID.STYLE:case se.TAG_ID.XMP:case se.TAG_ID.IFRAME:case se.TAG_ID.NOEMBED:case se.TAG_ID.NOFRAMES:case se.TAG_ID.NOSCRIPT:{this.tokenizer.state=qs.TokenizerMode.RAWTEXT;break}case se.TAG_ID.SCRIPT:{this.tokenizer.state=qs.TokenizerMode.SCRIPT_DATA;break}case se.TAG_ID.PLAINTEXT:{this.tokenizer.state=qs.TokenizerMode.PLAINTEXT;break}}}},{key:"_setDocumentType",value:function(s){const C=s.name||"",I=s.publicId||"",A=s.systemId||"";if(this.treeAdapter.setDocumentType(this.document,C,I,A),s.location){const h=this.treeAdapter.getChildNodes(this.document).find(y=>this.treeAdapter.isDocumentTypeNode(y));h&&this.treeAdapter.setNodeSourceCodeLocation(h,s.location)}}},{key:"_attachElementToTree",value:function(s,C){if(this.options.sourceCodeLocationInfo){const I=C&&Object.assign(Object.assign({},C),{startTag:C});this.treeAdapter.setNodeSourceCodeLocation(s,I)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(s);else{const I=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(I,s)}}},{key:"_appendElement",value:function(s,C){const I=this.treeAdapter.createElement(s.tagName,C,s.attrs);this._attachElementToTree(I,s.location)}},{key:"_insertElement",value:function(s,C){const I=this.treeAdapter.createElement(s.tagName,C,s.attrs);this._attachElementToTree(I,s.location),this.openElements.push(I,s.tagID)}},{key:"_insertFakeElement",value:function(s,C){const I=this.treeAdapter.createElement(s,se.NS.HTML,[]);this._attachElementToTree(I,null),this.openElements.push(I,C)}},{key:"_insertTemplate",value:function(s){const C=this.treeAdapter.createElement(s.tagName,se.NS.HTML,s.attrs),I=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(C,I),this._attachElementToTree(C,s.location),this.openElements.push(C,s.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(I,null)}},{key:"_insertFakeRootElement",value:function(){const s=this.treeAdapter.createElement(se.TAG_NAMES.HTML,se.NS.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(s,null),this.treeAdapter.appendChild(this.openElements.current,s),this.openElements.push(s,se.TAG_ID.HTML)}},{key:"_appendCommentNode",value:function(s,C){const I=this.treeAdapter.createCommentNode(s.data);this.treeAdapter.appendChild(C,I),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(I,s.location)}},{key:"_insertCharacters",value:function(s){let C,I;if(this._shouldFosterParentOnInsertion()?({parent:C,beforeElement:I}=this._findFosterParentingLocation(),I?this.treeAdapter.insertTextBefore(C,s.chars,I):this.treeAdapter.insertText(C,s.chars)):(C=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(C,s.chars)),!s.location)return;const A=this.treeAdapter.getChildNodes(C),d=I?A.lastIndexOf(I):A.length,h=A[d-1];if(this.treeAdapter.getNodeSourceCodeLocation(h)){const{endLine:Z,endCol:b,endOffset:w}=s.location;this.treeAdapter.updateNodeSourceCodeLocation(h,{endLine:Z,endCol:b,endOffset:w})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(h,s.location)}},{key:"_adoptNodes",value:function(s,C){for(let I=this.treeAdapter.getFirstChild(s);I;I=this.treeAdapter.getFirstChild(s))this.treeAdapter.detachNode(I),this.treeAdapter.appendChild(C,I)}},{key:"_setEndLocation",value:function(s,C){if(this.treeAdapter.getNodeSourceCodeLocation(s)&&C.location){const I=C.location,A=this.treeAdapter.getTagName(s),d=C.type===Ko.TokenType.END_TAG&&A===C.tagName?{endTag:Object.assign({},I),endLine:I.endLine,endCol:I.endCol,endOffset:I.endOffset}:{endLine:I.startLine,endCol:I.startCol,endOffset:I.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(s,d)}}},{key:"shouldProcessStartTagTokenInForeignContent",value:function(s){if(!this.currentNotInHTML)return!1;let C,I;return this.openElements.stackTop===0&&this.fragmentContext?(C=this.fragmentContext,I=this.fragmentContextID):{current:C,currentTagId:I}=this.openElements,s.tagID===se.TAG_ID.SVG&&this.treeAdapter.getTagName(C)===se.TAG_NAMES.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(C)===se.NS.MATHML?!1:this.tokenizer.inForeignNode||(s.tagID===se.TAG_ID.MGLYPH||s.tagID===se.TAG_ID.MALIGNMARK)&&!this._isIntegrationPoint(I,C,se.NS.HTML)}},{key:"_processToken",value:function(s){switch(s.type){case Ko.TokenType.CHARACTER:{this.onCharacter(s);break}case Ko.TokenType.NULL_CHARACTER:{this.onNullCharacter(s);break}case Ko.TokenType.COMMENT:{this.onComment(s);break}case Ko.TokenType.DOCTYPE:{this.onDoctype(s);break}case Ko.TokenType.START_TAG:{this._processStartTag(s);break}case Ko.TokenType.END_TAG:{this.onEndTag(s);break}case Ko.TokenType.EOF:{this.onEof(s);break}case Ko.TokenType.WHITESPACE_CHARACTER:{this.onWhitespaceCharacter(s);break}}}},{key:"_isIntegrationPoint",value:function(s,C,I){const A=this.treeAdapter.getNamespaceURI(C),d=this.treeAdapter.getAttrList(C);return bu.isIntegrationPoint(s,A,d,I)}},{key:"_reconstructActiveFormattingElements",value:function(){const s=this.activeFormattingElements.entries.length;if(s){const C=this.activeFormattingElements.entries.findIndex(A=>A.type===w9e.EntryType.Marker||this.openElements.contains(A.element)),I=C<0?s-1:C-1;for(let A=I;A>=0;A--){const d=this.activeFormattingElements.entries[A];this._insertElement(d.token,this.treeAdapter.getNamespaceURI(d.element)),d.element=this.openElements.current}}}},{key:"_closeTableCell",value:function(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=tt.IN_ROW}},{key:"_closePElement",value:function(){this.openElements.generateImpliedEndTagsWithExclusion(se.TAG_ID.P),this.openElements.popUntilTagNamePopped(se.TAG_ID.P)}},{key:"_resetInsertionMode",value:function(){for(let s=this.openElements.stackTop;s>=0;s--)switch(s===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[s]){case se.TAG_ID.TR:{this.insertionMode=tt.IN_ROW;return}case se.TAG_ID.TBODY:case se.TAG_ID.THEAD:case se.TAG_ID.TFOOT:{this.insertionMode=tt.IN_TABLE_BODY;return}case se.TAG_ID.CAPTION:{this.insertionMode=tt.IN_CAPTION;return}case se.TAG_ID.COLGROUP:{this.insertionMode=tt.IN_COLUMN_GROUP;return}case se.TAG_ID.TABLE:{this.insertionMode=tt.IN_TABLE;return}case se.TAG_ID.BODY:{this.insertionMode=tt.IN_BODY;return}case se.TAG_ID.FRAMESET:{this.insertionMode=tt.IN_FRAMESET;return}case se.TAG_ID.SELECT:{this._resetInsertionModeForSelect(s);return}case se.TAG_ID.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case se.TAG_ID.HTML:{this.insertionMode=this.headElement?tt.AFTER_HEAD:tt.BEFORE_HEAD;return}case se.TAG_ID.TD:case se.TAG_ID.TH:{if(s>0){this.insertionMode=tt.IN_CELL;return}break}case se.TAG_ID.HEAD:{if(s>0){this.insertionMode=tt.IN_HEAD;return}break}}this.insertionMode=tt.IN_BODY}},{key:"_resetInsertionModeForSelect",value:function(s){if(s>0)for(let C=s-1;C>0;C--){const I=this.openElements.tagIDs[C];if(I===se.TAG_ID.TEMPLATE)break;if(I===se.TAG_ID.TABLE){this.insertionMode=tt.IN_SELECT_IN_TABLE;return}}this.insertionMode=tt.IN_SELECT}},{key:"_isElementCausesFosterParenting",value:function(s){return V9e.has(s)}},{key:"_shouldFosterParentOnInsertion",value:function(){return this.fosterParentingEnabled&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}},{key:"_findFosterParentingLocation",value:function(){for(let s=this.openElements.stackTop;s>=0;s--){const C=this.openElements.items[s];switch(this.openElements.tagIDs[s]){case se.TAG_ID.TEMPLATE:{if(this.treeAdapter.getNamespaceURI(C)===se.NS.HTML)return{parent:this.treeAdapter.getTemplateContent(C),beforeElement:null};break}case se.TAG_ID.TABLE:{const I=this.treeAdapter.getParentNode(C);return I?{parent:I,beforeElement:C}:{parent:this.openElements.items[s-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}},{key:"_fosterParentElement",value:function(s){const C=this._findFosterParentingLocation();C.beforeElement?this.treeAdapter.insertBefore(C.parent,s,C.beforeElement):this.treeAdapter.appendChild(C.parent,s)}},{key:"_isSpecialElement",value:function(s,C){const I=this.treeAdapter.getNamespaceURI(s);return se.SPECIAL_ELEMENTS[I].has(C)}},{key:"onCharacter",value:function(s){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){tFt(this,s);return}switch(this.insertionMode){case tt.INITIAL:{uV(this,s);break}case tt.BEFORE_HTML:{dV(this,s);break}case tt.BEFORE_HEAD:{hV(this,s);break}case tt.IN_HEAD:{fV(this,s);break}case tt.IN_HEAD_NO_SCRIPT:{mV(this,s);break}case tt.AFTER_HEAD:{pV(this,s);break}case tt.IN_BODY:case tt.IN_CAPTION:case tt.IN_CELL:case tt.IN_TEMPLATE:{W9e(this,s);break}case tt.TEXT:case tt.IN_SELECT:case tt.IN_SELECT_IN_TABLE:{this._insertCharacters(s);break}case tt.IN_TABLE:case tt.IN_TABLE_BODY:case tt.IN_ROW:{u$(this,s);break}case tt.IN_TABLE_TEXT:{Y9e(this,s);break}case tt.IN_COLUMN_GROUP:{K5(this,s);break}case tt.AFTER_BODY:{z5(this,s);break}case tt.AFTER_AFTER_BODY:{O5(this,s);break}}}},{key:"onNullCharacter",value:function(s){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){eFt(this,s);return}switch(this.insertionMode){case tt.INITIAL:{uV(this,s);break}case tt.BEFORE_HTML:{dV(this,s);break}case tt.BEFORE_HEAD:{hV(this,s);break}case tt.IN_HEAD:{fV(this,s);break}case tt.IN_HEAD_NO_SCRIPT:{mV(this,s);break}case tt.AFTER_HEAD:{pV(this,s);break}case tt.TEXT:{this._insertCharacters(s);break}case tt.IN_TABLE:case tt.IN_TABLE_BODY:case tt.IN_ROW:{u$(this,s);break}case tt.IN_COLUMN_GROUP:{K5(this,s);break}case tt.AFTER_BODY:{z5(this,s);break}case tt.AFTER_AFTER_BODY:{O5(this,s);break}}}},{key:"onComment",value:function(s){if(this.skipNextNewLine=!1,this.currentNotInHTML){c$(this,s);return}switch(this.insertionMode){case tt.INITIAL:case tt.BEFORE_HTML:case tt.BEFORE_HEAD:case tt.IN_HEAD:case tt.IN_HEAD_NO_SCRIPT:case tt.AFTER_HEAD:case tt.IN_BODY:case tt.IN_TABLE:case tt.IN_CAPTION:case tt.IN_COLUMN_GROUP:case tt.IN_TABLE_BODY:case tt.IN_ROW:case tt.IN_CELL:case tt.IN_SELECT:case tt.IN_SELECT_IN_TABLE:case tt.IN_TEMPLATE:case tt.IN_FRAMESET:case tt.AFTER_FRAMESET:{c$(this,s);break}case tt.IN_TABLE_TEXT:{vV(this,s);break}case tt.AFTER_BODY:{H5t(this,s);break}case tt.AFTER_AFTER_BODY:case tt.AFTER_AFTER_FRAMESET:{W5t(this,s);break}}}},{key:"onDoctype",value:function(s){switch(this.skipNextNewLine=!1,this.insertionMode){case tt.INITIAL:{N5t(this,s);break}case tt.BEFORE_HEAD:case tt.IN_HEAD:case tt.IN_HEAD_NO_SCRIPT:case tt.AFTER_HEAD:{this._err(s,Ga.ERR.misplacedDoctype);break}case tt.IN_TABLE_TEXT:{vV(this,s);break}}}},{key:"onStartTag",value:function(s){this.skipNextNewLine=!1,this.currentToken=s,this._processStartTag(s),s.selfClosing&&!s.ackSelfClosing&&this._err(s,Ga.ERR.nonVoidHtmlElementStartTagWithTrailingSolidus)}},{key:"_processStartTag",value:function(s){this.shouldProcessStartTagTokenInForeignContent(s)?iFt(this,s):this._startTagOutsideForeignContent(s)}},{key:"_startTagOutsideForeignContent",value:function(s){switch(this.insertionMode){case tt.INITIAL:{uV(this,s);break}case tt.BEFORE_HTML:{k5t(this,s);break}case tt.BEFORE_HEAD:{x5t(this,s);break}case tt.IN_HEAD:{Bc(this,s);break}case tt.IN_HEAD_NO_SCRIPT:{F5t(this,s);break}case tt.AFTER_HEAD:{K5t(this,s);break}case tt.IN_BODY:{rs(this,s);break}case tt.IN_TABLE:{KB(this,s);break}case tt.IN_TABLE_TEXT:{vV(this,s);break}case tt.IN_CAPTION:{DMt(this,s);break}case tt.IN_COLUMN_GROUP:{d$(this,s);break}case tt.IN_TABLE_BODY:{_5(this,s);break}case tt.IN_ROW:{P5(this,s);break}case tt.IN_CELL:{YMt(this,s);break}case tt.IN_SELECT:{P9e(this,s);break}case tt.IN_SELECT_IN_TABLE:{_Mt(this,s);break}case tt.IN_TEMPLATE:{zMt(this,s);break}case tt.AFTER_BODY:{LMt(this,s);break}case tt.IN_FRAMESET:{JMt(this,s);break}case tt.AFTER_FRAMESET:{QMt(this,s);break}case tt.AFTER_AFTER_BODY:{$Mt(this,s);break}case tt.AFTER_AFTER_FRAMESET:{qMt(this,s);break}}}},{key:"onEndTag",value:function(s){this.skipNextNewLine=!1,this.currentToken=s,this.currentNotInHTML?nFt(this,s):this._endTagOutsideForeignContent(s)}},{key:"_endTagOutsideForeignContent",value:function(s){switch(this.insertionMode){case tt.INITIAL:{uV(this,s);break}case tt.BEFORE_HTML:{X5t(this,s);break}case tt.BEFORE_HEAD:{D5t(this,s);break}case tt.IN_HEAD:{M5t(this,s);break}case tt.IN_HEAD_NO_SCRIPT:{Y5t(this,s);break}case tt.AFTER_HEAD:{_5t(this,s);break}case tt.IN_BODY:{Y5(this,s);break}case tt.TEXT:{TMt(this,s);break}case tt.IN_TABLE:{bV(this,s);break}case tt.IN_TABLE_TEXT:{vV(this,s);break}case tt.IN_CAPTION:{MMt(this,s);break}case tt.IN_COLUMN_GROUP:{FMt(this,s);break}case tt.IN_TABLE_BODY:{h$(this,s);break}case tt.IN_ROW:{_9e(this,s);break}case tt.IN_CELL:{KMt(this,s);break}case tt.IN_SELECT:{z9e(this,s);break}case tt.IN_SELECT_IN_TABLE:{PMt(this,s);break}case tt.IN_TEMPLATE:{OMt(this,s);break}case tt.AFTER_BODY:{L9e(this,s);break}case tt.IN_FRAMESET:{UMt(this,s);break}case tt.AFTER_FRAMESET:{jMt(this,s);break}case tt.AFTER_AFTER_BODY:{O5(this,s);break}}}},{key:"onEof",value:function(s){switch(this.insertionMode){case tt.INITIAL:{uV(this,s);break}case tt.BEFORE_HTML:{dV(this,s);break}case tt.BEFORE_HEAD:{hV(this,s);break}case tt.IN_HEAD:{fV(this,s);break}case tt.IN_HEAD_NO_SCRIPT:{mV(this,s);break}case tt.AFTER_HEAD:{pV(this,s);break}case tt.IN_BODY:case tt.IN_TABLE:case tt.IN_CAPTION:case tt.IN_COLUMN_GROUP:case tt.IN_TABLE_BODY:case tt.IN_ROW:case tt.IN_CELL:case tt.IN_SELECT:case tt.IN_SELECT_IN_TABLE:{M9e(this,s);break}case tt.TEXT:{RMt(this,s);break}case tt.IN_TABLE_TEXT:{vV(this,s);break}case tt.IN_TEMPLATE:{O9e(this,s);break}case tt.AFTER_BODY:case tt.IN_FRAMESET:case tt.AFTER_FRAMESET:case tt.AFTER_AFTER_BODY:case tt.AFTER_AFTER_FRAMESET:{A$(this,s);break}}}},{key:"onWhitespaceCharacter",value:function(s){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,s.chars.charCodeAt(0)===R9e.CODE_POINTS.LINE_FEED)){if(s.chars.length===1)return;s.chars=s.chars.substr(1)}if(this.tokenizer.inForeignNode){this._insertCharacters(s);return}switch(this.insertionMode){case tt.IN_HEAD:case tt.IN_HEAD_NO_SCRIPT:case tt.AFTER_HEAD:case tt.TEXT:case tt.IN_COLUMN_GROUP:case tt.IN_SELECT:case tt.IN_SELECT_IN_TABLE:case tt.IN_FRAMESET:case tt.AFTER_FRAMESET:{this._insertCharacters(s);break}case tt.IN_BODY:case tt.IN_CAPTION:case tt.IN_CELL:case tt.IN_TEMPLATE:case tt.AFTER_BODY:case tt.AFTER_AFTER_BODY:case tt.AFTER_AFTER_FRAMESET:{H9e(this,s);break}case tt.IN_TABLE:case tt.IN_TABLE_BODY:case tt.IN_ROW:{u$(this,s);break}case tt.IN_TABLE_TEXT:{F9e(this,s);break}}}}],[{key:"parse",value:function(s,C){const I=new this(C);return I.tokenizer.write(s,!0),I.document}},{key:"getFragmentParser",value:function(s,C){const I=Object.assign(Object.assign({},E9e),C);s??(s=I.treeAdapter.createElement(se.TAG_NAMES.TEMPLATE,se.NS.HTML,[]));const A=I.treeAdapter.createElement("documentmock",se.NS.HTML,[]),d=new this(I,A,s);return d.fragmentContextID===se.TAG_ID.TEMPLATE&&d.tmplInsertionModeStack.unshift(tt.IN_TEMPLATE),d._initTokenizerForFragmentParsing(),d._insertFakeRootElement(),d._resetInsertionMode(),d._findFormInFragmentContext(),d}}]),g}();lV.Parser=G5t;function S5t(g,a){let s=g.activeFormattingElements.getElementEntryInScopeWithTagName(a.tagName);return s?g.openElements.contains(s.element)?g.openElements.hasInScope(a.tagID)||(s=null):(g.activeFormattingElements.removeEntry(s),s=null):D9e(g,a),s}function w5t(g,a){let s=null,C=g.openElements.stackTop;for(;C>=0;C--){const I=g.openElements.items[C];if(I===a.element)break;g._isSpecialElement(I,g.openElements.tagIDs[C])&&(s=I)}return s||(g.openElements.shortenToLength(C<0?0:C),g.activeFormattingElements.removeEntry(a)),s}function T5t(g,a,s){let C=a,I=g.openElements.getCommonAncestor(a);for(let A=0,d=I;d!==s;A++,d=I){I=g.openElements.getCommonAncestor(d);const h=g.activeFormattingElements.getElementEntry(d),y=h&&A>=Z5t;!h||y?(y&&g.activeFormattingElements.removeEntry(h),g.openElements.remove(d)):(d=R5t(g,h),C===a&&(g.activeFormattingElements.bookmark=h),g.treeAdapter.detachNode(C),g.treeAdapter.appendChild(d,C),C=d)}return C}function R5t(g,a){const s=g.treeAdapter.getNamespaceURI(a.element),C=g.treeAdapter.createElement(a.token.tagName,s,a.token.attrs);return g.openElements.replace(a.element,C),a.element=C,C}function V5t(g,a,s){const C=g.treeAdapter.getTagName(a),I=(0,se.getTagID)(C);if(g._isElementCausesFosterParenting(I))g._fosterParentElement(s);else{const A=g.treeAdapter.getNamespaceURI(a);I===se.TAG_ID.TEMPLATE&&A===se.NS.HTML&&(a=g.treeAdapter.getTemplateContent(a)),g.treeAdapter.appendChild(a,s)}}function E5t(g,a,s){const C=g.treeAdapter.getNamespaceURI(s.element),{token:I}=s,A=g.treeAdapter.createElement(I.tagName,C,I.attrs);g._adoptNodes(a,A),g.treeAdapter.appendChild(a,A),g.activeFormattingElements.insertElementAfterBookmark(A,I),g.activeFormattingElements.removeEntry(s),g.openElements.remove(s.element),g.openElements.insertAfter(a,A,I.tagID)}function C$(g,a){for(let s=0;s=s;C--)g._setEndLocation(g.openElements.items[C],a);if(!g.fragmentContext&&g.openElements.stackTop>=0){const C=g.openElements.items[0],I=g.treeAdapter.getNodeSourceCodeLocation(C);if(I&&!I.endTag&&(g._setEndLocation(C,a),g.openElements.stackTop>=1)){const A=g.openElements.items[1],d=g.treeAdapter.getNodeSourceCodeLocation(A);d&&!d.endTag&&g._setEndLocation(A,a)}}}}function N5t(g,a){g._setDocumentType(a);const s=a.forceQuirks?se.DOCUMENT_MODE.QUIRKS:T9e.getDocumentMode(a);T9e.isConforming(a)||g._err(a,Ga.ERR.nonConformingDoctype),g.treeAdapter.setDocumentMode(g.document,s),g.insertionMode=tt.BEFORE_HTML}function uV(g,a){g._err(a,Ga.ERR.missingDoctype,!0),g.treeAdapter.setDocumentMode(g.document,se.DOCUMENT_MODE.QUIRKS),g.insertionMode=tt.BEFORE_HTML,g._processToken(a)}function k5t(g,a){a.tagID===se.TAG_ID.HTML?(g._insertElement(a,se.NS.HTML),g.insertionMode=tt.BEFORE_HEAD):dV(g,a)}function X5t(g,a){const s=a.tagID;(s===se.TAG_ID.HTML||s===se.TAG_ID.HEAD||s===se.TAG_ID.BODY||s===se.TAG_ID.BR)&&dV(g,a)}function dV(g,a){g._insertFakeRootElement(),g.insertionMode=tt.BEFORE_HEAD,g._processToken(a)}function x5t(g,a){switch(a.tagID){case se.TAG_ID.HTML:{rs(g,a);break}case se.TAG_ID.HEAD:{g._insertElement(a,se.NS.HTML),g.headElement=g.openElements.current,g.insertionMode=tt.IN_HEAD;break}default:hV(g,a)}}function D5t(g,a){const s=a.tagID;s===se.TAG_ID.HEAD||s===se.TAG_ID.BODY||s===se.TAG_ID.HTML||s===se.TAG_ID.BR?hV(g,a):g._err(a,Ga.ERR.endTagWithoutMatchingOpenElement)}function hV(g,a){g._insertFakeElement(se.TAG_NAMES.HEAD,se.TAG_ID.HEAD),g.headElement=g.openElements.current,g.insertionMode=tt.IN_HEAD,g._processToken(a)}function Bc(g,a){switch(a.tagID){case se.TAG_ID.HTML:{rs(g,a);break}case se.TAG_ID.BASE:case se.TAG_ID.BASEFONT:case se.TAG_ID.BGSOUND:case se.TAG_ID.LINK:case se.TAG_ID.META:{g._appendElement(a,se.NS.HTML),a.ackSelfClosing=!0;break}case se.TAG_ID.TITLE:{g._switchToTextParsing(a,qs.TokenizerMode.RCDATA);break}case se.TAG_ID.NOSCRIPT:{g.options.scriptingEnabled?g._switchToTextParsing(a,qs.TokenizerMode.RAWTEXT):(g._insertElement(a,se.NS.HTML),g.insertionMode=tt.IN_HEAD_NO_SCRIPT);break}case se.TAG_ID.NOFRAMES:case se.TAG_ID.STYLE:{g._switchToTextParsing(a,qs.TokenizerMode.RAWTEXT);break}case se.TAG_ID.SCRIPT:{g._switchToTextParsing(a,qs.TokenizerMode.SCRIPT_DATA);break}case se.TAG_ID.TEMPLATE:{g._insertTemplate(a),g.activeFormattingElements.insertMarker(),g.framesetOk=!1,g.insertionMode=tt.IN_TEMPLATE,g.tmplInsertionModeStack.unshift(tt.IN_TEMPLATE);break}case se.TAG_ID.HEAD:{g._err(a,Ga.ERR.misplacedStartTagForHeadElement);break}default:fV(g,a)}}function M5t(g,a){switch(a.tagID){case se.TAG_ID.HEAD:{g.openElements.pop(),g.insertionMode=tt.AFTER_HEAD;break}case se.TAG_ID.BODY:case se.TAG_ID.BR:case se.TAG_ID.HTML:{fV(g,a);break}case se.TAG_ID.TEMPLATE:{xb(g,a);break}default:g._err(a,Ga.ERR.endTagWithoutMatchingOpenElement)}}function xb(g,a){g.openElements.tmplCount>0?(g.openElements.generateImpliedEndTagsThoroughly(),g.openElements.currentTagId!==se.TAG_ID.TEMPLATE&&g._err(a,Ga.ERR.closingOfElementWithOpenChildElements),g.openElements.popUntilTagNamePopped(se.TAG_ID.TEMPLATE),g.activeFormattingElements.clearToLastMarker(),g.tmplInsertionModeStack.shift(),g._resetInsertionMode()):g._err(a,Ga.ERR.endTagWithoutMatchingOpenElement)}function fV(g,a){g.openElements.pop(),g.insertionMode=tt.AFTER_HEAD,g._processToken(a)}function F5t(g,a){switch(a.tagID){case se.TAG_ID.HTML:{rs(g,a);break}case se.TAG_ID.BASEFONT:case se.TAG_ID.BGSOUND:case se.TAG_ID.HEAD:case se.TAG_ID.LINK:case se.TAG_ID.META:case se.TAG_ID.NOFRAMES:case se.TAG_ID.STYLE:{Bc(g,a);break}case se.TAG_ID.NOSCRIPT:{g._err(a,Ga.ERR.nestedNoscriptInHead);break}default:mV(g,a)}}function Y5t(g,a){switch(a.tagID){case se.TAG_ID.NOSCRIPT:{g.openElements.pop(),g.insertionMode=tt.IN_HEAD;break}case se.TAG_ID.BR:{mV(g,a);break}default:g._err(a,Ga.ERR.endTagWithoutMatchingOpenElement)}}function mV(g,a){const s=a.type===Ko.TokenType.EOF?Ga.ERR.openElementsLeftAfterEof:Ga.ERR.disallowedContentInNoscriptInHead;g._err(a,s),g.openElements.pop(),g.insertionMode=tt.IN_HEAD,g._processToken(a)}function K5t(g,a){switch(a.tagID){case se.TAG_ID.HTML:{rs(g,a);break}case se.TAG_ID.BODY:{g._insertElement(a,se.NS.HTML),g.framesetOk=!1,g.insertionMode=tt.IN_BODY;break}case se.TAG_ID.FRAMESET:{g._insertElement(a,se.NS.HTML),g.insertionMode=tt.IN_FRAMESET;break}case se.TAG_ID.BASE:case se.TAG_ID.BASEFONT:case se.TAG_ID.BGSOUND:case se.TAG_ID.LINK:case se.TAG_ID.META:case se.TAG_ID.NOFRAMES:case se.TAG_ID.SCRIPT:case se.TAG_ID.STYLE:case se.TAG_ID.TEMPLATE:case se.TAG_ID.TITLE:{g._err(a,Ga.ERR.abandonedHeadElementChild),g.openElements.push(g.headElement,se.TAG_ID.HEAD),Bc(g,a),g.openElements.remove(g.headElement);break}case se.TAG_ID.HEAD:{g._err(a,Ga.ERR.misplacedStartTagForHeadElement);break}default:pV(g,a)}}function _5t(g,a){switch(a.tagID){case se.TAG_ID.BODY:case se.TAG_ID.HTML:case se.TAG_ID.BR:{pV(g,a);break}case se.TAG_ID.TEMPLATE:{xb(g,a);break}default:g._err(a,Ga.ERR.endTagWithoutMatchingOpenElement)}}function pV(g,a){g._insertFakeElement(se.TAG_NAMES.BODY,se.TAG_ID.BODY),g.insertionMode=tt.IN_BODY,F5(g,a)}function F5(g,a){switch(a.type){case Ko.TokenType.CHARACTER:{W9e(g,a);break}case Ko.TokenType.WHITESPACE_CHARACTER:{H9e(g,a);break}case Ko.TokenType.COMMENT:{c$(g,a);break}case Ko.TokenType.START_TAG:{rs(g,a);break}case Ko.TokenType.END_TAG:{Y5(g,a);break}case Ko.TokenType.EOF:{M9e(g,a);break}}}function H9e(g,a){g._reconstructActiveFormattingElements(),g._insertCharacters(a)}function W9e(g,a){g._reconstructActiveFormattingElements(),g._insertCharacters(a),g.framesetOk=!1}function P5t(g,a){g.openElements.tmplCount===0&&g.treeAdapter.adoptAttributes(g.openElements.items[0],a.attrs)}function z5t(g,a){const s=g.openElements.tryPeekProperlyNestedBodyElement();s&&g.openElements.tmplCount===0&&(g.framesetOk=!1,g.treeAdapter.adoptAttributes(s,a.attrs))}function O5t(g,a){const s=g.openElements.tryPeekProperlyNestedBodyElement();g.framesetOk&&s&&(g.treeAdapter.detachNode(s),g.openElements.popAllUpToHtmlElement(),g._insertElement(a,se.NS.HTML),g.insertionMode=tt.IN_FRAMESET)}function L5t(g,a){g.openElements.hasInButtonScope(se.TAG_ID.P)&&g._closePElement(),g._insertElement(a,se.NS.HTML)}function J5t(g,a){g.openElements.hasInButtonScope(se.TAG_ID.P)&&g._closePElement(),(0,se.isNumberedHeader)(g.openElements.currentTagId)&&g.openElements.pop(),g._insertElement(a,se.NS.HTML)}function U5t(g,a){g.openElements.hasInButtonScope(se.TAG_ID.P)&&g._closePElement(),g._insertElement(a,se.NS.HTML),g.skipNextNewLine=!0,g.framesetOk=!1}function Q5t(g,a){const s=g.openElements.tmplCount>0;(!g.formElement||s)&&(g.openElements.hasInButtonScope(se.TAG_ID.P)&&g._closePElement(),g._insertElement(a,se.NS.HTML),s||(g.formElement=g.openElements.current))}function j5t(g,a){g.framesetOk=!1;const s=a.tagID;for(let C=g.openElements.stackTop;C>=0;C--){const I=g.openElements.tagIDs[C];if(s===se.TAG_ID.LI&&I===se.TAG_ID.LI||(s===se.TAG_ID.DD||s===se.TAG_ID.DT)&&(I===se.TAG_ID.DD||I===se.TAG_ID.DT)){g.openElements.generateImpliedEndTagsWithExclusion(I),g.openElements.popUntilTagNamePopped(I);break}if(I!==se.TAG_ID.ADDRESS&&I!==se.TAG_ID.DIV&&I!==se.TAG_ID.P&&g._isSpecialElement(g.openElements.items[C],I))break}g.openElements.hasInButtonScope(se.TAG_ID.P)&&g._closePElement(),g._insertElement(a,se.NS.HTML)}function $5t(g,a){g.openElements.hasInButtonScope(se.TAG_ID.P)&&g._closePElement(),g._insertElement(a,se.NS.HTML),g.tokenizer.state=qs.TokenizerMode.PLAINTEXT}function q5t(g,a){g.openElements.hasInScope(se.TAG_ID.BUTTON)&&(g.openElements.generateImpliedEndTags(),g.openElements.popUntilTagNamePopped(se.TAG_ID.BUTTON)),g._reconstructActiveFormattingElements(),g._insertElement(a,se.NS.HTML),g.framesetOk=!1}function eMt(g,a){const s=g.activeFormattingElements.getElementEntryInScopeWithTagName(se.TAG_NAMES.A);s&&(C$(g,a),g.openElements.remove(s.element),g.activeFormattingElements.removeEntry(s)),g._reconstructActiveFormattingElements(),g._insertElement(a,se.NS.HTML),g.activeFormattingElements.pushElement(g.openElements.current,a)}function tMt(g,a){g._reconstructActiveFormattingElements(),g._insertElement(a,se.NS.HTML),g.activeFormattingElements.pushElement(g.openElements.current,a)}function iMt(g,a){g._reconstructActiveFormattingElements(),g.openElements.hasInScope(se.TAG_ID.NOBR)&&(C$(g,a),g._reconstructActiveFormattingElements()),g._insertElement(a,se.NS.HTML),g.activeFormattingElements.pushElement(g.openElements.current,a)}function nMt(g,a){g._reconstructActiveFormattingElements(),g._insertElement(a,se.NS.HTML),g.activeFormattingElements.insertMarker(),g.framesetOk=!1}function rMt(g,a){g.treeAdapter.getDocumentMode(g.document)!==se.DOCUMENT_MODE.QUIRKS&&g.openElements.hasInButtonScope(se.TAG_ID.P)&&g._closePElement(),g._insertElement(a,se.NS.HTML),g.framesetOk=!1,g.insertionMode=tt.IN_TABLE}function N9e(g,a){g._reconstructActiveFormattingElements(),g._appendElement(a,se.NS.HTML),g.framesetOk=!1,a.ackSelfClosing=!0}function k9e(g){const a=(0,Ko.getTokenAttr)(g,se.ATTRS.TYPE);return a!=null&&a.toLowerCase()===y5t}function gMt(g,a){g._reconstructActiveFormattingElements(),g._appendElement(a,se.NS.HTML),k9e(a)||(g.framesetOk=!1),a.ackSelfClosing=!0}function oMt(g,a){g._appendElement(a,se.NS.HTML),a.ackSelfClosing=!0}function aMt(g,a){g.openElements.hasInButtonScope(se.TAG_ID.P)&&g._closePElement(),g._appendElement(a,se.NS.HTML),g.framesetOk=!1,a.ackSelfClosing=!0}function sMt(g,a){a.tagName=se.TAG_NAMES.IMG,a.tagID=se.TAG_ID.IMG,N9e(g,a)}function IMt(g,a){g._insertElement(a,se.NS.HTML),g.skipNextNewLine=!0,g.tokenizer.state=qs.TokenizerMode.RCDATA,g.originalInsertionMode=g.insertionMode,g.framesetOk=!1,g.insertionMode=tt.TEXT}function lMt(g,a){g.openElements.hasInButtonScope(se.TAG_ID.P)&&g._closePElement(),g._reconstructActiveFormattingElements(),g.framesetOk=!1,g._switchToTextParsing(a,qs.TokenizerMode.RAWTEXT)}function CMt(g,a){g.framesetOk=!1,g._switchToTextParsing(a,qs.TokenizerMode.RAWTEXT)}function X9e(g,a){g._switchToTextParsing(a,qs.TokenizerMode.RAWTEXT)}function cMt(g,a){g._reconstructActiveFormattingElements(),g._insertElement(a,se.NS.HTML),g.framesetOk=!1,g.insertionMode=g.insertionMode===tt.IN_TABLE||g.insertionMode===tt.IN_CAPTION||g.insertionMode===tt.IN_TABLE_BODY||g.insertionMode===tt.IN_ROW||g.insertionMode===tt.IN_CELL?tt.IN_SELECT_IN_TABLE:tt.IN_SELECT}function AMt(g,a){g.openElements.currentTagId===se.TAG_ID.OPTION&&g.openElements.pop(),g._reconstructActiveFormattingElements(),g._insertElement(a,se.NS.HTML)}function uMt(g,a){g.openElements.hasInScope(se.TAG_ID.RUBY)&&g.openElements.generateImpliedEndTags(),g._insertElement(a,se.NS.HTML)}function dMt(g,a){g.openElements.hasInScope(se.TAG_ID.RUBY)&&g.openElements.generateImpliedEndTagsWithExclusion(se.TAG_ID.RTC),g._insertElement(a,se.NS.HTML)}function hMt(g,a){g._reconstructActiveFormattingElements(),bu.adjustTokenMathMLAttrs(a),bu.adjustTokenXMLAttrs(a),a.selfClosing?g._appendElement(a,se.NS.MATHML):g._insertElement(a,se.NS.MATHML),a.ackSelfClosing=!0}function fMt(g,a){g._reconstructActiveFormattingElements(),bu.adjustTokenSVGAttrs(a),bu.adjustTokenXMLAttrs(a),a.selfClosing?g._appendElement(a,se.NS.SVG):g._insertElement(a,se.NS.SVG),a.ackSelfClosing=!0}function x9e(g,a){g._reconstructActiveFormattingElements(),g._insertElement(a,se.NS.HTML)}function rs(g,a){switch(a.tagID){case se.TAG_ID.I:case se.TAG_ID.S:case se.TAG_ID.B:case se.TAG_ID.U:case se.TAG_ID.EM:case se.TAG_ID.TT:case se.TAG_ID.BIG:case se.TAG_ID.CODE:case se.TAG_ID.FONT:case se.TAG_ID.SMALL:case se.TAG_ID.STRIKE:case se.TAG_ID.STRONG:{tMt(g,a);break}case se.TAG_ID.A:{eMt(g,a);break}case se.TAG_ID.H1:case se.TAG_ID.H2:case se.TAG_ID.H3:case se.TAG_ID.H4:case se.TAG_ID.H5:case se.TAG_ID.H6:{J5t(g,a);break}case se.TAG_ID.P:case se.TAG_ID.DL:case se.TAG_ID.OL:case se.TAG_ID.UL:case se.TAG_ID.DIV:case se.TAG_ID.DIR:case se.TAG_ID.NAV:case se.TAG_ID.MAIN:case se.TAG_ID.MENU:case se.TAG_ID.ASIDE:case se.TAG_ID.CENTER:case se.TAG_ID.FIGURE:case se.TAG_ID.FOOTER:case se.TAG_ID.HEADER:case se.TAG_ID.HGROUP:case se.TAG_ID.DIALOG:case se.TAG_ID.DETAILS:case se.TAG_ID.ADDRESS:case se.TAG_ID.ARTICLE:case se.TAG_ID.SECTION:case se.TAG_ID.SUMMARY:case se.TAG_ID.FIELDSET:case se.TAG_ID.BLOCKQUOTE:case se.TAG_ID.FIGCAPTION:{L5t(g,a);break}case se.TAG_ID.LI:case se.TAG_ID.DD:case se.TAG_ID.DT:{j5t(g,a);break}case se.TAG_ID.BR:case se.TAG_ID.IMG:case se.TAG_ID.WBR:case se.TAG_ID.AREA:case se.TAG_ID.EMBED:case se.TAG_ID.KEYGEN:{N9e(g,a);break}case se.TAG_ID.HR:{aMt(g,a);break}case se.TAG_ID.RB:case se.TAG_ID.RTC:{uMt(g,a);break}case se.TAG_ID.RT:case se.TAG_ID.RP:{dMt(g,a);break}case se.TAG_ID.PRE:case se.TAG_ID.LISTING:{U5t(g,a);break}case se.TAG_ID.XMP:{lMt(g,a);break}case se.TAG_ID.SVG:{fMt(g,a);break}case se.TAG_ID.HTML:{P5t(g,a);break}case se.TAG_ID.BASE:case se.TAG_ID.LINK:case se.TAG_ID.META:case se.TAG_ID.STYLE:case se.TAG_ID.TITLE:case se.TAG_ID.SCRIPT:case se.TAG_ID.BGSOUND:case se.TAG_ID.BASEFONT:case se.TAG_ID.TEMPLATE:{Bc(g,a);break}case se.TAG_ID.BODY:{z5t(g,a);break}case se.TAG_ID.FORM:{Q5t(g,a);break}case se.TAG_ID.NOBR:{iMt(g,a);break}case se.TAG_ID.MATH:{hMt(g,a);break}case se.TAG_ID.TABLE:{rMt(g,a);break}case se.TAG_ID.INPUT:{gMt(g,a);break}case se.TAG_ID.PARAM:case se.TAG_ID.TRACK:case se.TAG_ID.SOURCE:{oMt(g,a);break}case se.TAG_ID.IMAGE:{sMt(g,a);break}case se.TAG_ID.BUTTON:{q5t(g,a);break}case se.TAG_ID.APPLET:case se.TAG_ID.OBJECT:case se.TAG_ID.MARQUEE:{nMt(g,a);break}case se.TAG_ID.IFRAME:{CMt(g,a);break}case se.TAG_ID.SELECT:{cMt(g,a);break}case se.TAG_ID.OPTION:case se.TAG_ID.OPTGROUP:{AMt(g,a);break}case se.TAG_ID.NOEMBED:{X9e(g,a);break}case se.TAG_ID.FRAMESET:{O5t(g,a);break}case se.TAG_ID.TEXTAREA:{IMt(g,a);break}case se.TAG_ID.NOSCRIPT:{g.options.scriptingEnabled?X9e(g,a):x9e(g,a);break}case se.TAG_ID.PLAINTEXT:{$5t(g,a);break}case se.TAG_ID.COL:case se.TAG_ID.TH:case se.TAG_ID.TD:case se.TAG_ID.TR:case se.TAG_ID.HEAD:case se.TAG_ID.FRAME:case se.TAG_ID.TBODY:case se.TAG_ID.TFOOT:case se.TAG_ID.THEAD:case se.TAG_ID.CAPTION:case se.TAG_ID.COLGROUP:break;default:x9e(g,a)}}function mMt(g,a){if(g.openElements.hasInScope(se.TAG_ID.BODY)&&(g.insertionMode=tt.AFTER_BODY,g.options.sourceCodeLocationInfo)){const s=g.openElements.tryPeekProperlyNestedBodyElement();s&&g._setEndLocation(s,a)}}function pMt(g,a){g.openElements.hasInScope(se.TAG_ID.BODY)&&(g.insertionMode=tt.AFTER_BODY,L9e(g,a))}function bMt(g,a){const s=a.tagID;g.openElements.hasInScope(s)&&(g.openElements.generateImpliedEndTags(),g.openElements.popUntilTagNamePopped(s))}function yMt(g){const a=g.openElements.tmplCount>0,{formElement:s}=g;a||(g.formElement=null),(s||a)&&g.openElements.hasInScope(se.TAG_ID.FORM)&&(g.openElements.generateImpliedEndTags(),a?g.openElements.popUntilTagNamePopped(se.TAG_ID.FORM):s&&g.openElements.remove(s))}function vMt(g){g.openElements.hasInButtonScope(se.TAG_ID.P)||g._insertFakeElement(se.TAG_NAMES.P,se.TAG_ID.P),g._closePElement()}function ZMt(g){g.openElements.hasInListItemScope(se.TAG_ID.LI)&&(g.openElements.generateImpliedEndTagsWithExclusion(se.TAG_ID.LI),g.openElements.popUntilTagNamePopped(se.TAG_ID.LI))}function BMt(g,a){const s=a.tagID;g.openElements.hasInScope(s)&&(g.openElements.generateImpliedEndTagsWithExclusion(s),g.openElements.popUntilTagNamePopped(s))}function GMt(g){g.openElements.hasNumberedHeaderInScope()&&(g.openElements.generateImpliedEndTags(),g.openElements.popUntilNumberedHeaderPopped())}function SMt(g,a){const s=a.tagID;g.openElements.hasInScope(s)&&(g.openElements.generateImpliedEndTags(),g.openElements.popUntilTagNamePopped(s),g.activeFormattingElements.clearToLastMarker())}function wMt(g){g._reconstructActiveFormattingElements(),g._insertFakeElement(se.TAG_NAMES.BR,se.TAG_ID.BR),g.openElements.pop(),g.framesetOk=!1}function D9e(g,a){const s=a.tagName,C=a.tagID;for(let I=g.openElements.stackTop;I>0;I--){const A=g.openElements.items[I],d=g.openElements.tagIDs[I];if(C===d&&(C!==se.TAG_ID.UNKNOWN||g.treeAdapter.getTagName(A)===s)){g.openElements.generateImpliedEndTagsWithExclusion(C),g.openElements.stackTop>=I&&g.openElements.shortenToLength(I);break}if(g._isSpecialElement(A,d))break}}function Y5(g,a){switch(a.tagID){case se.TAG_ID.A:case se.TAG_ID.B:case se.TAG_ID.I:case se.TAG_ID.S:case se.TAG_ID.U:case se.TAG_ID.EM:case se.TAG_ID.TT:case se.TAG_ID.BIG:case se.TAG_ID.CODE:case se.TAG_ID.FONT:case se.TAG_ID.NOBR:case se.TAG_ID.SMALL:case se.TAG_ID.STRIKE:case se.TAG_ID.STRONG:{C$(g,a);break}case se.TAG_ID.P:{vMt(g);break}case se.TAG_ID.DL:case se.TAG_ID.UL:case se.TAG_ID.OL:case se.TAG_ID.DIR:case se.TAG_ID.DIV:case se.TAG_ID.NAV:case se.TAG_ID.PRE:case se.TAG_ID.MAIN:case se.TAG_ID.MENU:case se.TAG_ID.ASIDE:case se.TAG_ID.BUTTON:case se.TAG_ID.CENTER:case se.TAG_ID.FIGURE:case se.TAG_ID.FOOTER:case se.TAG_ID.HEADER:case se.TAG_ID.HGROUP:case se.TAG_ID.DIALOG:case se.TAG_ID.ADDRESS:case se.TAG_ID.ARTICLE:case se.TAG_ID.DETAILS:case se.TAG_ID.SECTION:case se.TAG_ID.SUMMARY:case se.TAG_ID.LISTING:case se.TAG_ID.FIELDSET:case se.TAG_ID.BLOCKQUOTE:case se.TAG_ID.FIGCAPTION:{bMt(g,a);break}case se.TAG_ID.LI:{ZMt(g);break}case se.TAG_ID.DD:case se.TAG_ID.DT:{BMt(g,a);break}case se.TAG_ID.H1:case se.TAG_ID.H2:case se.TAG_ID.H3:case se.TAG_ID.H4:case se.TAG_ID.H5:case se.TAG_ID.H6:{GMt(g);break}case se.TAG_ID.BR:{wMt(g);break}case se.TAG_ID.BODY:{mMt(g,a);break}case se.TAG_ID.HTML:{pMt(g,a);break}case se.TAG_ID.FORM:{yMt(g);break}case se.TAG_ID.APPLET:case se.TAG_ID.OBJECT:case se.TAG_ID.MARQUEE:{SMt(g,a);break}case se.TAG_ID.TEMPLATE:{xb(g,a);break}default:D9e(g,a)}}function M9e(g,a){g.tmplInsertionModeStack.length>0?O9e(g,a):A$(g,a)}function TMt(g,a){var s;a.tagID===se.TAG_ID.SCRIPT&&((s=g.scriptHandler)===null||s===void 0||s.call(g,g.openElements.current)),g.openElements.pop(),g.insertionMode=g.originalInsertionMode}function RMt(g,a){g._err(a,Ga.ERR.eofInElementThatCanContainOnlyText),g.openElements.pop(),g.insertionMode=g.originalInsertionMode,g.onEof(a)}function u$(g,a){if(V9e.has(g.openElements.currentTagId))switch(g.pendingCharacterTokens.length=0,g.hasNonWhitespacePendingCharacterToken=!1,g.originalInsertionMode=g.insertionMode,g.insertionMode=tt.IN_TABLE_TEXT,a.type){case Ko.TokenType.CHARACTER:{Y9e(g,a);break}case Ko.TokenType.WHITESPACE_CHARACTER:{F9e(g,a);break}}else yV(g,a)}function VMt(g,a){g.openElements.clearBackToTableContext(),g.activeFormattingElements.insertMarker(),g._insertElement(a,se.NS.HTML),g.insertionMode=tt.IN_CAPTION}function EMt(g,a){g.openElements.clearBackToTableContext(),g._insertElement(a,se.NS.HTML),g.insertionMode=tt.IN_COLUMN_GROUP}function HMt(g,a){g.openElements.clearBackToTableContext(),g._insertFakeElement(se.TAG_NAMES.COLGROUP,se.TAG_ID.COLGROUP),g.insertionMode=tt.IN_COLUMN_GROUP,d$(g,a)}function WMt(g,a){g.openElements.clearBackToTableContext(),g._insertElement(a,se.NS.HTML),g.insertionMode=tt.IN_TABLE_BODY}function NMt(g,a){g.openElements.clearBackToTableContext(),g._insertFakeElement(se.TAG_NAMES.TBODY,se.TAG_ID.TBODY),g.insertionMode=tt.IN_TABLE_BODY,_5(g,a)}function kMt(g,a){g.openElements.hasInTableScope(se.TAG_ID.TABLE)&&(g.openElements.popUntilTagNamePopped(se.TAG_ID.TABLE),g._resetInsertionMode(),g._processStartTag(a))}function XMt(g,a){k9e(a)?g._appendElement(a,se.NS.HTML):yV(g,a),a.ackSelfClosing=!0}function xMt(g,a){!g.formElement&&g.openElements.tmplCount===0&&(g._insertElement(a,se.NS.HTML),g.formElement=g.openElements.current,g.openElements.pop())}function KB(g,a){switch(a.tagID){case se.TAG_ID.TD:case se.TAG_ID.TH:case se.TAG_ID.TR:{NMt(g,a);break}case se.TAG_ID.STYLE:case se.TAG_ID.SCRIPT:case se.TAG_ID.TEMPLATE:{Bc(g,a);break}case se.TAG_ID.COL:{HMt(g,a);break}case se.TAG_ID.FORM:{xMt(g,a);break}case se.TAG_ID.TABLE:{kMt(g,a);break}case se.TAG_ID.TBODY:case se.TAG_ID.TFOOT:case se.TAG_ID.THEAD:{WMt(g,a);break}case se.TAG_ID.INPUT:{XMt(g,a);break}case se.TAG_ID.CAPTION:{VMt(g,a);break}case se.TAG_ID.COLGROUP:{EMt(g,a);break}default:yV(g,a)}}function bV(g,a){switch(a.tagID){case se.TAG_ID.TABLE:{g.openElements.hasInTableScope(se.TAG_ID.TABLE)&&(g.openElements.popUntilTagNamePopped(se.TAG_ID.TABLE),g._resetInsertionMode());break}case se.TAG_ID.TEMPLATE:{xb(g,a);break}case se.TAG_ID.BODY:case se.TAG_ID.CAPTION:case se.TAG_ID.COL:case se.TAG_ID.COLGROUP:case se.TAG_ID.HTML:case se.TAG_ID.TBODY:case se.TAG_ID.TD:case se.TAG_ID.TFOOT:case se.TAG_ID.TH:case se.TAG_ID.THEAD:case se.TAG_ID.TR:break;default:yV(g,a)}}function yV(g,a){const s=g.fosterParentingEnabled;g.fosterParentingEnabled=!0,F5(g,a),g.fosterParentingEnabled=s}function F9e(g,a){g.pendingCharacterTokens.push(a)}function Y9e(g,a){g.pendingCharacterTokens.push(a),g.hasNonWhitespacePendingCharacterToken=!0}function vV(g,a){let s=0;if(g.hasNonWhitespacePendingCharacterToken)for(;s0&&g.openElements.currentTagId===se.TAG_ID.OPTION&&g.openElements.tagIDs[g.openElements.stackTop-1]===se.TAG_ID.OPTGROUP&&g.openElements.pop(),g.openElements.currentTagId===se.TAG_ID.OPTGROUP&&g.openElements.pop();break}case se.TAG_ID.OPTION:{g.openElements.currentTagId===se.TAG_ID.OPTION&&g.openElements.pop();break}case se.TAG_ID.SELECT:{g.openElements.hasInSelectScope(se.TAG_ID.SELECT)&&(g.openElements.popUntilTagNamePopped(se.TAG_ID.SELECT),g._resetInsertionMode());break}case se.TAG_ID.TEMPLATE:{xb(g,a);break}}}function _Mt(g,a){const s=a.tagID;s===se.TAG_ID.CAPTION||s===se.TAG_ID.TABLE||s===se.TAG_ID.TBODY||s===se.TAG_ID.TFOOT||s===se.TAG_ID.THEAD||s===se.TAG_ID.TR||s===se.TAG_ID.TD||s===se.TAG_ID.TH?(g.openElements.popUntilTagNamePopped(se.TAG_ID.SELECT),g._resetInsertionMode(),g._processStartTag(a)):P9e(g,a)}function PMt(g,a){const s=a.tagID;s===se.TAG_ID.CAPTION||s===se.TAG_ID.TABLE||s===se.TAG_ID.TBODY||s===se.TAG_ID.TFOOT||s===se.TAG_ID.THEAD||s===se.TAG_ID.TR||s===se.TAG_ID.TD||s===se.TAG_ID.TH?g.openElements.hasInTableScope(s)&&(g.openElements.popUntilTagNamePopped(se.TAG_ID.SELECT),g._resetInsertionMode(),g.onEndTag(a)):z9e(g,a)}function zMt(g,a){switch(a.tagID){case se.TAG_ID.BASE:case se.TAG_ID.BASEFONT:case se.TAG_ID.BGSOUND:case se.TAG_ID.LINK:case se.TAG_ID.META:case se.TAG_ID.NOFRAMES:case se.TAG_ID.SCRIPT:case se.TAG_ID.STYLE:case se.TAG_ID.TEMPLATE:case se.TAG_ID.TITLE:{Bc(g,a);break}case se.TAG_ID.CAPTION:case se.TAG_ID.COLGROUP:case se.TAG_ID.TBODY:case se.TAG_ID.TFOOT:case se.TAG_ID.THEAD:{g.tmplInsertionModeStack[0]=tt.IN_TABLE,g.insertionMode=tt.IN_TABLE,KB(g,a);break}case se.TAG_ID.COL:{g.tmplInsertionModeStack[0]=tt.IN_COLUMN_GROUP,g.insertionMode=tt.IN_COLUMN_GROUP,d$(g,a);break}case se.TAG_ID.TR:{g.tmplInsertionModeStack[0]=tt.IN_TABLE_BODY,g.insertionMode=tt.IN_TABLE_BODY,_5(g,a);break}case se.TAG_ID.TD:case se.TAG_ID.TH:{g.tmplInsertionModeStack[0]=tt.IN_ROW,g.insertionMode=tt.IN_ROW,P5(g,a);break}default:g.tmplInsertionModeStack[0]=tt.IN_BODY,g.insertionMode=tt.IN_BODY,rs(g,a)}}function OMt(g,a){a.tagID===se.TAG_ID.TEMPLATE&&xb(g,a)}function O9e(g,a){g.openElements.tmplCount>0?(g.openElements.popUntilTagNamePopped(se.TAG_ID.TEMPLATE),g.activeFormattingElements.clearToLastMarker(),g.tmplInsertionModeStack.shift(),g._resetInsertionMode(),g.onEof(a)):A$(g,a)}function LMt(g,a){a.tagID===se.TAG_ID.HTML?rs(g,a):z5(g,a)}function L9e(g,a){var s;if(a.tagID===se.TAG_ID.HTML){if(g.fragmentContext||(g.insertionMode=tt.AFTER_AFTER_BODY),g.options.sourceCodeLocationInfo&&g.openElements.tagIDs[0]===se.TAG_ID.HTML){g._setEndLocation(g.openElements.items[0],a);const C=g.openElements.items[1];C&&!(!((s=g.treeAdapter.getNodeSourceCodeLocation(C))===null||s===void 0)&&s.endTag)&&g._setEndLocation(C,a)}}else z5(g,a)}function z5(g,a){g.insertionMode=tt.IN_BODY,F5(g,a)}function JMt(g,a){switch(a.tagID){case se.TAG_ID.HTML:{rs(g,a);break}case se.TAG_ID.FRAMESET:{g._insertElement(a,se.NS.HTML);break}case se.TAG_ID.FRAME:{g._appendElement(a,se.NS.HTML),a.ackSelfClosing=!0;break}case se.TAG_ID.NOFRAMES:{Bc(g,a);break}}}function UMt(g,a){a.tagID===se.TAG_ID.FRAMESET&&!g.openElements.isRootHtmlElementCurrent()&&(g.openElements.pop(),!g.fragmentContext&&g.openElements.currentTagId!==se.TAG_ID.FRAMESET&&(g.insertionMode=tt.AFTER_FRAMESET))}function QMt(g,a){switch(a.tagID){case se.TAG_ID.HTML:{rs(g,a);break}case se.TAG_ID.NOFRAMES:{Bc(g,a);break}}}function jMt(g,a){a.tagID===se.TAG_ID.HTML&&(g.insertionMode=tt.AFTER_AFTER_FRAMESET)}function $Mt(g,a){a.tagID===se.TAG_ID.HTML?rs(g,a):O5(g,a)}function O5(g,a){g.insertionMode=tt.IN_BODY,F5(g,a)}function qMt(g,a){switch(a.tagID){case se.TAG_ID.HTML:{rs(g,a);break}case se.TAG_ID.NOFRAMES:{Bc(g,a);break}}}function eFt(g,a){a.chars=R9e.REPLACEMENT_CHARACTER,g._insertCharacters(a)}function tFt(g,a){g._insertCharacters(a),g.framesetOk=!1}function J9e(g){for(;g.treeAdapter.getNamespaceURI(g.openElements.current)!==se.NS.HTML&&!g._isIntegrationPoint(g.openElements.currentTagId,g.openElements.current);)g.openElements.pop()}function iFt(g,a){if(bu.causesExit(a))J9e(g),g._startTagOutsideForeignContent(a);else{const s=g._getAdjustedCurrentElement(),C=g.treeAdapter.getNamespaceURI(s);C===se.NS.MATHML?bu.adjustTokenMathMLAttrs(a):C===se.NS.SVG&&(bu.adjustTokenSVGTagName(a),bu.adjustTokenSVGAttrs(a)),bu.adjustTokenXMLAttrs(a),a.selfClosing?g._appendElement(a,C):g._insertElement(a,C),a.ackSelfClosing=!0}}function nFt(g,a){if(a.tagID===se.TAG_ID.P||a.tagID===se.TAG_ID.BR){J9e(g),g._endTagOutsideForeignContent(a);return}for(let s=g.openElements.stackTop;s>0;s--){const C=g.openElements.items[s];if(g.treeAdapter.getNamespaceURI(C)===se.NS.HTML){g._endTagOutsideForeignContent(a);break}const I=g.treeAdapter.getTagName(C);if(I.toLowerCase()===a.tagName){a.tagName=I,g.openElements.shortenToLength(s);break}}}var _B={};Object.defineProperty(_B,"__esModule",{value:!0}),_B.serializeOuter=_B.serialize=void 0;const lg=Ch,U9e=bB,rFt=M5,gFt=new Set([lg.TAG_NAMES.AREA,lg.TAG_NAMES.BASE,lg.TAG_NAMES.BASEFONT,lg.TAG_NAMES.BGSOUND,lg.TAG_NAMES.BR,lg.TAG_NAMES.COL,lg.TAG_NAMES.EMBED,lg.TAG_NAMES.FRAME,lg.TAG_NAMES.HR,lg.TAG_NAMES.IMG,lg.TAG_NAMES.INPUT,lg.TAG_NAMES.KEYGEN,lg.TAG_NAMES.LINK,lg.TAG_NAMES.META,lg.TAG_NAMES.PARAM,lg.TAG_NAMES.SOURCE,lg.TAG_NAMES.TRACK,lg.TAG_NAMES.WBR]);function Q9e(g,a){return a.treeAdapter.isElementNode(g)&&a.treeAdapter.getNamespaceURI(g)===lg.NS.HTML&&gFt.has(a.treeAdapter.getTagName(g))}const j9e={treeAdapter:rFt.defaultTreeAdapter,scriptingEnabled:!0};function oFt(g,a){const s=Object.assign(Object.assign({},j9e),a);return Q9e(g,s)?"":$9e(g,s)}_B.serialize=oFt;function aFt(g,a){const s=Object.assign(Object.assign({},j9e),a);return q9e(g,s)}_B.serializeOuter=aFt;function $9e(g,a){let s="";const C=a.treeAdapter.isElementNode(g)&&a.treeAdapter.getTagName(g)===lg.TAG_NAMES.TEMPLATE&&a.treeAdapter.getNamespaceURI(g)===lg.NS.HTML?a.treeAdapter.getTemplateContent(g):g,I=a.treeAdapter.getChildNodes(C);if(I)for(const A of I)s+=q9e(A,a);return s}function q9e(g,a){return a.treeAdapter.isElementNode(g)?sFt(g,a):a.treeAdapter.isTextNode(g)?lFt(g,a):a.treeAdapter.isCommentNode(g)?CFt(g,a):a.treeAdapter.isDocumentTypeNode(g)?cFt(g,a):""}function sFt(g,a){const s=a.treeAdapter.getTagName(g);return`<${s}${IFt(g,a)}>${Q9e(g,a)?"":`${$9e(g,a)}`}`}function IFt(g,{treeAdapter:a}){let s="";for(const C of a.getAttrList(g)){if(s+=" ",!C.namespace)s+=C.name;else switch(C.namespace){case lg.NS.XML:{s+=`xml:${C.name}`;break}case lg.NS.XMLNS:{C.name!=="xmlns"&&(s+="xmlns:"),s+=C.name;break}case lg.NS.XLINK:{s+=`xlink:${C.name}`;break}default:s+=`${C.prefix}:${C.name}`}s+=`="${(0,U9e.escapeAttribute)(C.value)}"`}return s}function lFt(g,a){const{treeAdapter:s}=a,C=s.getTextNodeContent(g),I=s.getParentNode(g),A=I&&s.isElementNode(I)&&s.getTagName(I);return A&&s.getNamespaceURI(I)===lg.NS.HTML&&(0,lg.hasUnescapedText)(A,a.scriptingEnabled)?C:(0,U9e.escapeText)(C)}function CFt(g,{treeAdapter:a}){return``}function cFt(g,{treeAdapter:a}){return``}(function(g){Object.defineProperty(g,"__esModule",{value:!0}),g.parseFragment=g.parse=g.TokenizerMode=g.Tokenizer=g.Token=g.html=g.foreignContent=g.ErrorCodes=g.serializeOuter=g.serialize=g.Parser=g.defaultTreeAdapter=void 0;const a=lV;var s=M5;Object.defineProperty(g,"defaultTreeAdapter",{enumerable:!0,get:function(){return s.defaultTreeAdapter}});var C=lV;Object.defineProperty(g,"Parser",{enumerable:!0,get:function(){return C.Parser}});var I=_B;Object.defineProperty(g,"serialize",{enumerable:!0,get:function(){return I.serialize}}),Object.defineProperty(g,"serializeOuter",{enumerable:!0,get:function(){return I.serializeOuter}});var A=CV;Object.defineProperty(g,"ErrorCodes",{enumerable:!0,get:function(){return A.ERR}}),g.foreignContent=l$,g.html=Ch,g.Token=k5;var d=Xb;Object.defineProperty(g,"Tokenizer",{enumerable:!0,get:function(){return d.Tokenizer}}),Object.defineProperty(g,"TokenizerMode",{enumerable:!0,get:function(){return d.TokenizerMode}});function h(Z,b){return a.Parser.parse(Z,b)}g.parse=h;function y(Z,b,w){typeof Z=="string"&&(w=b,b=Z,Z=null);const S=a.Parser.getFragmentParser(Z,w);return S.tokenizer.write(b,!0),S.getFragment()}g.parseFragment=y})(d9e),function(g){Object.defineProperty(g,"__esModule",{value:!0}),g.adapter=g.serializeDoctypeContent=void 0;const a=d9e,s=Js;function C(d){return new s.Text(d)}function I(d){const h=d.includes('"')?"'":'"';return h+d+h}function A(d,h,y){let Z="!DOCTYPE ";return d&&(Z+=d),h?Z+=` PUBLIC ${I(h)}`:y&&(Z+=" SYSTEM"),y&&(Z+=` ${I(y)}`),Z}g.serializeDoctypeContent=A,g.adapter={isCommentNode:s.isComment,isElementNode:s.isTag,isTextNode:s.isText,createDocument(){const d=new s.Document([]);return d["x-mode"]=a.html.DOCUMENT_MODE.NO_QUIRKS,d},createDocumentFragment(){return new s.Document([])},createElement(d,h,y){const Z=Object.create(null),b=Object.create(null),w=Object.create(null);for(let R=0;R(0,s.isDirective)(S)&&S.name==="!doctype");w?w.data=b??null:(w=new s.ProcessingInstruction("!doctype",b),g.adapter.appendChild(d,w)),w["x-name"]=h??void 0,w["x-publicId"]=y??void 0,w["x-systemId"]=Z??void 0},setDocumentMode(d,h){d["x-mode"]=h},getDocumentMode(d){return d["x-mode"]},detachNode(d){if(d.parent){const h=d.parent.children.indexOf(d),{prev:y,next:Z}=d;d.prev=null,d.next=null,y&&(y.next=Z),Z&&(Z.prev=y),d.parent.children.splice(h,1),d.parent=null}},insertText(d,h){const y=d.children[d.children.length-1];y&&(0,s.isText)(y)?y.data+=h:g.adapter.appendChild(d,C(h))},insertTextBefore(d,h,y){const Z=d.children[d.children.indexOf(y)-1];Z&&(0,s.isText)(Z)?Z.data+=h:g.adapter.insertBefore(d,C(h),y)},adoptAttributes(d,h){for(let y=0;y"u"&&(d.attribs[Z]=h[y].value,d["x-attribsNamespace"][Z]=h[y].namespace,d["x-attribsPrefix"][Z]=h[y].prefix)}},getFirstChild(d){return d.children[0]},getChildNodes(d){return d.children},getParentNode(d){return d.parent},getAttrList(d){return d.attributes},getTagName(d){return d.name},getNamespaceURI(d){return d.namespace},getTextNodeContent(d){return d.data},getCommentNodeContent(d){return d.data},getDocumentTypeNodeName(d){var h;return(h=d["x-name"])!==null&&h!==void 0?h:""},getDocumentTypeNodePublicId(d){var h;return(h=d["x-publicId"])!==null&&h!==void 0?h:""},getDocumentTypeNodeSystemId(d){var h;return(h=d["x-systemId"])!==null&&h!==void 0?h:""},isDocumentTypeNode(d){return(0,s.isDirective)(d)&&d.name==="!doctype"},setNodeSourceCodeLocation(d,h){h&&(d.startIndex=h.startOffset,d.endIndex=h.endOffset),d.sourceCodeLocation=h},getNodeSourceCodeLocation(d){return d.sourceCodeLocation},updateNodeSourceCodeLocation(d,h){h.endOffset!=null&&(d.endIndex=h.endOffset),d.sourceCodeLocation=Object.assign(Object.assign({},d.sourceCodeLocation),h)}}}(u9e);var AFt=ne&&ne.__spreadArray||function(g,a,s){if(s||arguments.length===2)for(var C=0,I=a.length,A;C=s.Zero&&S<=s.Nine}function h(S){return S>=s.LowerA&&S<=s.LowerZ||S>=s.UpperA&&S<=s.UpperZ}function y(S){return S>=s.UpperA&&S<=s.UpperF||S>=s.LowerA&&S<=s.LowerF}var Z;(function(S){S[S.NoValue=0]="NoValue",S[S.Unquoted=1]="Unquoted",S[S.Single=2]="Single",S[S.Double=3]="Double"})(Z=g.QuoteType||(g.QuoteType={}));var b={Cdata:new Uint8Array([67,68,65,84,65,91]),CdataEnd:new Uint8Array([93,93,62]),CommentEnd:new Uint8Array([45,45,62]),ScriptEnd:new Uint8Array([60,47,115,99,114,105,112,116]),StyleEnd:new Uint8Array([60,47,115,116,121,108,101]),TitleEnd:new Uint8Array([60,47,116,105,116,108,101])},w=function(){function S(R,H){var N=R.xmlMode,D=N===void 0?!1:N,M=R.decodeEntities,z=M===void 0?!0:M;this.cbs=H,this.state=C.Text,this.buffer="",this.sectionStart=0,this.index=0,this.baseState=C.Text,this.isSpecial=!1,this.running=!0,this.offset=0,this.sequenceIndex=0,this.trieIndex=0,this.trieCurrent=0,this.entityResult=0,this.entityExcess=0,this.xmlMode=D,this.decodeEntities=z,this.entityTrie=D?a.xmlDecodeTree:a.htmlDecodeTree}return S.prototype.reset=function(){this.state=C.Text,this.buffer="",this.sectionStart=0,this.index=0,this.baseState=C.Text,this.currentSequence=void 0,this.running=!0,this.offset=0},S.prototype.write=function(R){this.offset+=this.buffer.length,this.buffer=R,this.parse()},S.prototype.end=function(){this.running&&this.finish()},S.prototype.pause=function(){this.running=!1},S.prototype.resume=function(){this.running=!0,this.indexthis.sectionStart&&this.cbs.ontext(this.sectionStart,this.index),this.state=C.BeforeTagName,this.sectionStart=this.index):this.decodeEntities&&R===s.Amp&&(this.state=C.BeforeEntity)},S.prototype.stateSpecialStartSequence=function(R){var H=this.sequenceIndex===this.currentSequence.length,N=H?A(R):(R|32)===this.currentSequence[this.sequenceIndex];if(!N)this.isSpecial=!1;else if(!H){this.sequenceIndex++;return}this.sequenceIndex=0,this.state=C.InTagName,this.stateInTagName(R)},S.prototype.stateInSpecialTag=function(R){if(this.sequenceIndex===this.currentSequence.length){if(R===s.Gt||I(R)){var H=this.index-this.currentSequence.length;if(this.sectionStart>14)-1;if(!this.allowLegacyEntity()&&R!==s.Semi)this.trieIndex+=N;else{var D=this.index-this.entityExcess+1;D>this.sectionStart&&this.emitPartial(this.sectionStart,D),this.entityResult=this.trieIndex,this.trieIndex+=N,this.entityExcess=0,this.sectionStart=this.index+1,N===0&&this.emitNamedEntity()}}},S.prototype.emitNamedEntity=function(){if(this.state=this.baseState,this.entityResult!==0){var R=(this.entityTrie[this.entityResult]&a.BinTrieFlags.VALUE_LENGTH)>>14;switch(R){case 1:this.emitCodePoint(this.entityTrie[this.entityResult]&~a.BinTrieFlags.VALUE_LENGTH);break;case 2:this.emitCodePoint(this.entityTrie[this.entityResult+1]);break;case 3:this.emitCodePoint(this.entityTrie[this.entityResult+1]),this.emitCodePoint(this.entityTrie[this.entityResult+2])}}},S.prototype.stateBeforeNumericEntity=function(R){(R|32)===s.LowerX?(this.entityExcess++,this.state=C.InHexEntity):(this.state=C.InNumericEntity,this.stateInNumericEntity(R))},S.prototype.emitNumericEntity=function(R){var H=this.index-this.entityExcess-1,N=H+2+ +(this.state===C.InHexEntity);N!==this.index&&(H>this.sectionStart&&this.emitPartial(this.sectionStart,H),this.sectionStart=this.index+Number(R),this.emitCodePoint((0,a.replaceCodePoint)(this.entityResult))),this.state=this.baseState},S.prototype.stateInNumericEntity=function(R){R===s.Semi?this.emitNumericEntity(!0):d(R)?(this.entityResult=this.entityResult*10+(R-s.Zero),this.entityExcess++):(this.allowLegacyEntity()?this.emitNumericEntity(!1):this.state=this.baseState,this.index--)},S.prototype.stateInHexEntity=function(R){R===s.Semi?this.emitNumericEntity(!0):d(R)?(this.entityResult=this.entityResult*16+(R-s.Zero),this.entityExcess++):y(R)?(this.entityResult=this.entityResult*16+((R|32)-s.LowerA+10),this.entityExcess++):(this.allowLegacyEntity()?this.emitNumericEntity(!1):this.state=this.baseState,this.index--)},S.prototype.allowLegacyEntity=function(){return!this.xmlMode&&(this.baseState===C.Text||this.baseState===C.InSpecialTag)},S.prototype.cleanup=function(){this.running&&this.sectionStart!==this.index&&(this.state===C.Text||this.state===C.InSpecialTag&&this.sequenceIndex===0?(this.cbs.ontext(this.sectionStart,this.index),this.sectionStart=this.index):(this.state===C.InAttributeValueDq||this.state===C.InAttributeValueSq||this.state===C.InAttributeValueNq)&&(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=this.index))},S.prototype.shouldContinue=function(){return this.index0&&d.has(this.stack[this.stack.length-1]);){var h=this.stack.pop();(C=(s=this.cbs).onclosetag)===null||C===void 0||C.call(s,h,!0)}this.isVoidElement(a)||(this.stack.push(a),oEe.has(a)?this.foreignContext.push(!0):aEe.has(a)&&this.foreignContext.push(!1)),(A=(I=this.cbs).onopentagname)===null||A===void 0||A.call(I,a),this.cbs.onopentag&&(this.attribs={})},g.prototype.endOpenTag=function(a){var s,C;this.startIndex=this.openTagStart,this.attribs&&((C=(s=this.cbs).onopentag)===null||C===void 0||C.call(s,this.tagname,this.attribs,a),this.attribs=null),this.cbs.onclosetag&&this.isVoidElement(this.tagname)&&this.cbs.onclosetag(this.tagname,!0),this.tagname=""},g.prototype.onopentagend=function(a){this.endIndex=a,this.endOpenTag(!1),this.startIndex=a+1},g.prototype.onclosetag=function(a,s){var C,I,A,d,h,y;this.endIndex=s;var Z=this.getSlice(a,s);if(this.lowerCaseTagNames&&(Z=Z.toLowerCase()),(oEe.has(Z)||aEe.has(Z))&&this.foreignContext.pop(),this.isVoidElement(Z))!this.options.xmlMode&&Z==="br"&&((I=(C=this.cbs).onopentagname)===null||I===void 0||I.call(C,"br"),(d=(A=this.cbs).onopentag)===null||d===void 0||d.call(A,"br",{},!0),(y=(h=this.cbs).onclosetag)===null||y===void 0||y.call(h,"br",!1));else{var b=this.stack.lastIndexOf(Z);if(b!==-1)if(this.cbs.onclosetag)for(var w=this.stack.length-b;w--;)this.cbs.onclosetag(this.stack.pop(),w!==0);else this.stack.length=b;else!this.options.xmlMode&&Z==="p"&&(this.emitOpenTag("p"),this.closeCurrentTag(!0))}this.startIndex=s+1},g.prototype.onselfclosingtag=function(a){this.endIndex=a,this.options.xmlMode||this.options.recognizeSelfClosing||this.foreignContext[this.foreignContext.length-1]?(this.closeCurrentTag(!1),this.startIndex=a+1):this.onopentagend(a)},g.prototype.closeCurrentTag=function(a){var s,C,I=this.tagname;this.endOpenTag(a),this.stack[this.stack.length-1]===I&&((C=(s=this.cbs).onclosetag)===null||C===void 0||C.call(s,I,!a),this.stack.pop())},g.prototype.onattribname=function(a,s){this.startIndex=a;var C=this.getSlice(a,s);this.attribname=this.lowerCaseAttributeNames?C.toLowerCase():C},g.prototype.onattribdata=function(a,s){this.attribvalue+=this.getSlice(a,s)},g.prototype.onattribentity=function(a){this.attribvalue+=(0,iEe.fromCodePoint)(a)},g.prototype.onattribend=function(a,s){var C,I;this.endIndex=s,(I=(C=this.cbs).onattribute)===null||I===void 0||I.call(C,this.attribname,this.attribvalue,a===J5.QuoteType.Double?'"':a===J5.QuoteType.Single?"'":a===J5.QuoteType.NoValue?void 0:null),this.attribs&&!Object.prototype.hasOwnProperty.call(this.attribs,this.attribname)&&(this.attribs[this.attribname]=this.attribvalue),this.attribvalue=""},g.prototype.getInstructionName=function(a){var s=a.search(ZFt),C=s<0?a:a.substr(0,s);return this.lowerCaseTagNames&&(C=C.toLowerCase()),C},g.prototype.ondeclaration=function(a,s){this.endIndex=s;var C=this.getSlice(a,s);if(this.cbs.onprocessinginstruction){var I=this.getInstructionName(C);this.cbs.onprocessinginstruction("!".concat(I),"!".concat(C))}this.startIndex=s+1},g.prototype.onprocessinginstruction=function(a,s){this.endIndex=s;var C=this.getSlice(a,s);if(this.cbs.onprocessinginstruction){var I=this.getInstructionName(C);this.cbs.onprocessinginstruction("?".concat(I),"?".concat(C))}this.startIndex=s+1},g.prototype.oncomment=function(a,s,C){var I,A,d,h;this.endIndex=s,(A=(I=this.cbs).oncomment)===null||A===void 0||A.call(I,this.getSlice(a,s-C)),(h=(d=this.cbs).oncommentend)===null||h===void 0||h.call(d),this.startIndex=s+1},g.prototype.oncdata=function(a,s,C){var I,A,d,h,y,Z,b,w,S,R;this.endIndex=s;var H=this.getSlice(a,s-C);this.options.xmlMode||this.options.recognizeCDATA?((A=(I=this.cbs).oncdatastart)===null||A===void 0||A.call(I),(h=(d=this.cbs).ontext)===null||h===void 0||h.call(d,H),(Z=(y=this.cbs).oncdataend)===null||Z===void 0||Z.call(y)):((w=(b=this.cbs).oncomment)===null||w===void 0||w.call(b,"[CDATA[".concat(H,"]]")),(R=(S=this.cbs).oncommentend)===null||R===void 0||R.call(S)),this.startIndex=s+1},g.prototype.onend=function(){var a,s;if(this.cbs.onclosetag){this.endIndex=this.startIndex;for(var C=this.stack.length;C>0;this.cbs.onclosetag(this.stack[--C],!0));}(s=(a=this.cbs).onend)===null||s===void 0||s.call(a)},g.prototype.reset=function(){var a,s,C,I;(s=(a=this.cbs).onreset)===null||s===void 0||s.call(a),this.tokenizer.reset(),this.tagname="",this.attribname="",this.attribs=null,this.stack.length=0,this.startIndex=0,this.endIndex=0,(I=(C=this.cbs).onparserinit)===null||I===void 0||I.call(C,this),this.buffers.length=0,this.bufferOffset=0,this.writeIndex=0,this.ended=!1},g.prototype.parseComplete=function(a){this.reset(),this.end(a)},g.prototype.getSlice=function(a,s){for(;a-this.bufferOffset>=this.buffers[0].length;)this.shiftBuffer();for(var C=this.buffers[0].slice(a-this.bufferOffset,s-this.bufferOffset);s-this.bufferOffset>this.buffers[0].length;)this.shiftBuffer(),C+=this.buffers[0].slice(0,s-this.bufferOffset);return C},g.prototype.shiftBuffer=function(){this.bufferOffset+=this.buffers[0].length,this.writeIndex--,this.buffers.shift()},g.prototype.write=function(a){var s,C;if(this.ended){(C=(s=this.cbs).onerror)===null||C===void 0||C.call(s,new Error(".write() after done!"));return}this.buffers.push(a),this.tokenizer.running&&(this.tokenizer.write(a),this.writeIndex++)},g.prototype.end=function(a){var s,C;if(this.ended){(C=(s=this.cbs).onerror)===null||C===void 0||C.call(s,Error(".end() after done!"));return}a&&this.write(a),this.ended=!0,this.tokenizer.end()},g.prototype.pause=function(){this.tokenizer.pause()},g.prototype.resume=function(){for(this.tokenizer.resume();this.tokenizer.running&&this.writeIndex0&&arguments[0]!==void 0?arguments[0]:{};p$={},cEe(g)}var _o={},b$={exports:{}};(function(g,a){Object.defineProperty(a,"__esModule",{value:!0});var s=function(C){function I(A,d){return C.apply(this,arguments)}return I.toString=function(){return C.toString()},I}(function(C,I){return typeof C!="object"||C===null||typeof I!="object"||I===null?!1:Object.keys(I).every(function(A){if(!C.propertyIsEnumerable(A))return!1;var d=I[A],h=C[A];return!(typeof d=="object"&&d!==null?!s(h,d):h!==d)})});a.default=s,g.exports=a.default})(b$,b$.exports);var Bm={};(function(g){Object.defineProperty(g,"__esModule",{value:!0}),g.default=A;var a=U5,s=I(a),C=Db;function I(d){return d&&d.__esModule?d:{default:d}}function A(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(d.adapter)return(0,s.default)(d.adapter),d.adapter;var h=(0,C.get)(),y=h.adapter;return(0,s.default)(y),y}})(Bm),Object.defineProperty(_o,"__esModule",{value:!0});var HFt=function(){function g(a,s){var C=[],I=!0,A=!1,d=void 0;try{for(var h=a[Symbol.iterator](),y;!(I=(y=h.next()).done)&&(C.push(y.value),!(s&&C.length===s));I=!0);}catch(Z){A=!0,d=Z}finally{try{!I&&h.return&&h.return()}finally{if(A)throw d}}return C}return function(a,s){if(Array.isArray(a))return a;if(Symbol.iterator in Object(a))return g(a,s);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();_o.propsOfNode=j5,_o.childrenOfNode=zB,_o.hasClassName=JFt,_o.treeForEach=y$,_o.treeFilter=v$,_o.findParentNode=UFt,_o.pathToNode=uEe,_o.parentsOfNode=jFt,_o.nodeHasId=$Ft,_o.nodeMatchesObjectProps=iYt,_o.getTextFromNode=dEe,_o.getTextFromHostNodes=hEe,_o.getHTMLFromHostNodes=fEe;var WFt=cB,NFt=Mb(WFt),kFt=kR,AEe=Mb(kFt),XFt=OTe,xFt=Mb(XFt),DFt=b$.exports,MFt=Mb(DFt),FFt=y8,YFt=Mb(FFt),KFt=i8,_Ft=Mb(KFt),PFt=Bm,zFt=Mb(PFt);function Mb(g){return g&&g.__esModule?g:{default:g}}function OFt(g,a,s){return a in g?Object.defineProperty(g,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):g[a]=s,g}function LFt(g){if(Array.isArray(g)){for(var a=0,s=Array(g.length);a-1}function y$(g,a){g&&a(g),zB(g).forEach(function(s){return y$(s,a)})}function v$(g,a){var s=[];return y$(g,function(C){a(C)&&s.push(C)}),s}function UFt(g,a){var s=v$(g,function(C){return C.rendered?zB(C).indexOf(a)!==-1:!1});return s[0]||null}function QFt(g,a){return g.filter(function(s){return v$(s,a).length!==0})}function uEe(g,a){for(var s=[a],C=[],I=function(y){return g===y};s.length;){var A=s.pop(),d=zB(A);if(A===g)return QFt(C,I);C.push(A),d.length===0&&C.pop(),s.push.apply(s,LFt(d))}return null}function jFt(g,a){return(uEe(g,a)||[]).reverse()}function $Ft(g,a){return j5(g).id===a}var qFt={};function eYt(g){return typeof g<"u"?g:qFt}function tYt(g){return(0,xFt.default)(g).reduce(function(a,s){var C=HFt(s,2),I=C[0],A=C[1];return(0,NFt.default)({},a,OFt({},I,eYt(A)))},{})}function iYt(g,a){return(0,MFt.default)(j5(g),tYt(a))}function nYt(g){return typeof g=="string"?String(g||""):g&&g.textContent||""}function Z$(g,a){var s=a.getCustom,C=a.handleHostNodes,I=a.recurse,A=a.nullRenderReturnsNull,d=A===void 0?!1:A;return g==null?"":typeof g=="string"||typeof g=="number"?String(g):s&&g.type&&typeof g.type=="function"?s(g):C&&g.nodeType==="host"?C(g):g.rendered==null&&d?null:zB(g).map(I).join("")}function dEe(g){return Z$(g,{recurse:dEe,getCustom:function(){function a(s){var C=s.type;return"<"+String(C.displayName||(0,YFt.default)(C))+" />"}return a}()})}function hEe(g,a){return Z$(g,{recurse:function(){function s(C){return hEe(C,a)}return s}(),handleHostNodes:function(){function s(C){var I=[].concat(a.nodeToHostNode(C,!0));return I.map(nYt).join("")}return s}()})}function rYt(g){return g==null?null:g.outerHTML.replace(/\sdata-(reactid|reactroot)+="([^"]*)+"/g,"")}function fEe(g,a){return Z$(g,{recurse:function(){function s(C){return fEe(C,a)}return s}(),handleHostNodes:function(){function s(C){var I=[].concat(a.nodeToHostNode(C,!0));return I.map(rYt).join("")}return s}(),nullRenderReturnsNull:!0})}(function(g){Object.defineProperty(g,"__esModule",{value:!0}),g.shallowEqual=g.ITERATOR_SYMBOL=void 0;var a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(re){return typeof re}:function(re){return re&&typeof Symbol=="function"&&re.constructor===Symbol&&re!==Symbol.prototype?"symbol":typeof re},s=function(){function re(U,q){var pe=[],Fe=!0,$e=!1,ft=void 0;try{for(var ri=U[Symbol.iterator](),bi;!(Fe=(bi=ri.next()).done)&&(pe.push(bi.value),!(q&&pe.length===q));Fe=!0);}catch(Ni){$e=!0,ft=Ni}finally{try{!Fe&&ri.return&&ri.return()}finally{if($e)throw ft}}return pe}return function(U,q){if(Array.isArray(U))return U;if(Symbol.iterator in Object(U))return re(U,q);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();g.getAdapter=We,g.makeOptions=qe,g.isCustomComponent=nt,g.isCustomComponentElement=At,g.propsOfNode=Tt,g.typeOfNode=Ne,g.nodeHasType=Ge,g.nodeMatches=Vt,g.nodeEqual=_t,g.containsChildrenSubArray=Ci,g.childrenToSimplifiedArray=ui,g.isReactElementAlike=Li,g.withSetStateAllowed=Bi,g.AND=pn,g.displayNameOfNode=un,g.sym=On,g.privateSet=Wg,g.cloneElement=ln,g.spyMethod=Ht;var C=UD.exports;Object.defineProperty(g,"shallowEqual",{enumerable:!0,get:function(){function re(){return ye(C).default}return re}()}),g.isEmptyValue=Ye,g.renderedDive=Qe,g.loadCheerioRoot=pt;var I=cB,A=ye(I),d=NZ.exports,h=ye(d),y=b8,Z=ye(y),b=OTe,w=ye(b),S=y8,R=ye(S),H=Os,N=ye(H),D=kR,M=ye(D),z=bWt,K=ye(z),P=CRe,J=ye(P),j=mm,ie=Db,te=_o,Ce=Bm,ue=ye(Ce),oe=U5,he=ye(oe);function ye(re){return re&&re.__esModule?re:{default:re}}function Ie(re,U,q){return U in re?Object.defineProperty(re,U,{value:q,enumerable:!0,configurable:!0,writable:!0}):re[U]=q,re}function fe(re,U){var q={};for(var pe in re)U.indexOf(pe)>=0||Object.prototype.hasOwnProperty.call(re,pe)&&(q[pe]=re[pe]);return q}g.ITERATOR_SYMBOL=typeof Symbol=="function"&&Symbol.iterator;function We(){var re=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return console.warn("getAdapter from Utils is deprecated; please use ./getAdapter instead"),(0,ue.default)(re)}function _e(re,U){if(re&&U&&re!==U)throw new TypeError("If both the `attachTo` and `hydrateIn` options are provided, they must be === (for backwards compatibility)")}function qe(re){var U=(0,ie.get)(),q=U.attachTo,pe=U.hydrateIn,Fe=fe(U,["attachTo","hydrateIn"]);_e(q,pe);var $e=re.attachTo,ft=re.hydrateIn;_e($e,ft);var ri=ft||pe||q||$e||void 0,bi=ft||pe||void 0,Ni=(0,A.default)({},ri&&{attachTo:ri},bi&&{hydrateIn:bi});return(0,A.default)({},Fe,re,Ni)}function nt(re,U){return(0,he.default)(U),U.isCustomComponent?!!U.isCustomComponent(re):typeof re=="function"}function At(re,U){return U.isCustomComponentElement?!!U.isCustomComponentElement(re):!!re&&U.isValidElement(re)&&typeof re.type=="function"}function Tt(re){return(0,w.default)(re&&re.props||{}).filter(function(U){var q=s(U,2),pe=q[1];return typeof pe<"u"}).reduce(function(U,q){var pe=s(q,2),Fe=pe[0],$e=pe[1];return(0,A.default)(U,Ie({},Fe,$e))},{})}function Ne(re){return re?re.type:null}function Ge(re,U){if(!U||!re)return!1;var q=(0,ue.default)();if(q.displayNameOfNode){var pe=q.displayNameOfNode(re);return pe===U}return re.type?typeof re.type=="string"?re.type===U:(typeof re.type=="function"?(0,R.default)(re.type)===U:re.type.name===U)||re.type.displayName===U:!1}function He(re,U,q,pe){var Fe=pe?Vt:_t;if(re===U)return!0;if(!Array.isArray(re)&&!Array.isArray(U))return Fe(re,U,q);var $e=(0,M.default)(re,1/0),ft=(0,M.default)(U,1/0);if($e.length!==ft.length)return!1;if($e.length===0&&ft.length===0)return!0;for(var ri=0;ri<$e.length;ri+=1)if(!Fe($e[ri],ft[ri],q))return!1;return!0}function Xe(re,U,q){return He(re,U,q,!0)}function at(re,U,q){return He(re,U,q,!1)}function bt(re,U){var q=s(U,2),pe=q[0],Fe=q[1],$e=Fe==null?{}:Ie({},pe,Fe);return(0,A.default)({},re,$e)}function xt(re,U,q,pe){if(re===U)return!0;if(!re||!U||re.type!==U.type)return!1;var Fe=Tt(re),$e=Tt(U);pe&&(Fe=(0,w.default)(Fe).reduce(bt,{}),$e=(0,w.default)($e).reduce(bt,{}));for(var ft=Object.keys(Fe),ri=0;ri2&&arguments[2]!==void 0?arguments[2]:Z.default;return xt(re,U,q,!0)}function _t(re,U){var q=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Z.default;return xt(re,U,q,!1)}function Ci(re,U,q){var pe=(0,te.childrenOfNode)(U),Fe=function(ft,ri){return Dt(re,pe.slice(ri,ri+q.length),q)};return pe.some(Fe)}function Dt(re,U,q){return U.length===q.length&&U.every(function(pe,Fe){return re(pe,q[Fe])})}function Zi(re){var U=[],q=function(Fe){Fe===null||Fe===!1||typeof Fe>"u"||U.push(Fe)};return Array.isArray(re)?re.forEach(q):q(re),U}function ui(re){for(var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,q=Zi(re),pe=[],Fe=0;Fe"u"?pe.push($e):In($e)&&In(ft)?pe.push(ft+$e):(pe.push(ft),pe.push($e))}return U?pe.map(function(ri){return typeof ri=="string"?(0,K.default)(ri):ri}):pe}function In(re){return typeof re=="string"||typeof re=="number"}function Li(re,U){return U.isValidElement(re)||In(re)||Array.isArray(re)}function Bi(re){var U=!1;typeof globalThis.document>"u"&&(U=!0,globalThis.document={}),re(),U&&(globalThis.document=void 0,delete globalThis.document)}function pn(re){var U=re.slice().reverse();return function(q){return U.every(function(pe){return pe(q)})}}function un(re){if(!re)return null;var U=re.type;return U?U.displayName||(typeof U=="function"?(0,R.default)(U):U.name||U):null}function On(re){return typeof Symbol=="function"?Symbol.for("enzyme."+String(re)):re}function Wg(re,U,q){Object.defineProperty(re,U,{value:q,enumerable:!1,writable:!0})}function ln(re,U,q){return re.createElement(U.type,(0,A.default)({},U.props,q))}function Ht(re,U){var q=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){},pe=void 0,Fe=re[U],$e=(0,N.default)(re,U),ft=void 0;return $e&&(ft=Object.getOwnPropertyDescriptor(re,U)),Object.defineProperty(re,U,{configurable:!0,enumerable:!ft||!!ft.enumerable,value:q(Fe)||function(){function ri(){for(var bi=arguments.length,Ni=Array(bi),Ti=0;Ti"'`]/g,aYt=RegExp(mEe.source),sYt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},IYt=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis,lYt=typeof self=="object"&&self&&self.Object===Object&&self,CYt=IYt||lYt||Function("return this")();function cYt(g){return function(a){return g?.[a]}}var AYt=cYt(sYt),uYt=Object.prototype,dYt=uYt.toString,pEe=CYt.Symbol,bEe=pEe?pEe.prototype:void 0,yEe=bEe?bEe.toString:void 0;function hYt(g){if(typeof g=="string")return g;if(mYt(g))return yEe?yEe.call(g):"";var a=g+"";return a=="0"&&1/g==-gYt?"-0":a}function fYt(g){return!!g&&typeof g=="object"}function mYt(g){return typeof g=="symbol"||fYt(g)&&dYt.call(g)==oYt}function pYt(g){return g==null?"":hYt(g)}function bYt(g){return g=pYt(g),g&&aYt.test(g)?g.replace(mEe,AYt):g}var yYt=bYt,vYt=String.prototype.valueOf,ZYt=function(a){try{return vYt.call(a),!0}catch{return!1}},BYt=Object.prototype.toString,GYt="[object String]",SYt=NR(),vEe=function(a){return typeof a=="string"?!0:typeof a!="object"?!1:SYt?ZYt(a):BYt.call(a)===GYt},wYt=Number.prototype.toString,TYt=function(a){try{return wYt.call(a),!0}catch{return!1}},RYt=Object.prototype.toString,VYt="[object Number]",EYt=NR(),HYt=function(a){return typeof a=="number"?!0:typeof a!="object"?!1:EYt?TYt(a):RYt.call(a)===VYt},ZEe=ts,WYt=ZEe("Boolean.prototype.toString"),NYt=ZEe("Object.prototype.toString"),kYt=function(a){try{return WYt(a),!0}catch{return!1}},XYt="[object Boolean]",xYt=NR(),DYt=function(a){return typeof a=="boolean"?!0:a===null||typeof a!="object"?!1:xYt&&Symbol.toStringTag in a?kYt(a):NYt(a)===XYt};Object.defineProperty(Gm,"__esModule",{value:!0});var BEe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(g){return typeof g}:function(g){return g&&typeof Symbol=="function"&&g.constructor===Symbol&&g!==Symbol.prototype?"symbol":typeof g};Gm.typeName=wEe,Gm.spaces=TEe,Gm.indent=REe,Gm.debugNode=G$,Gm.debugNodes=rKt;var MYt=yYt,FYt=ch(MYt),YYt=y8,GEe=ch(YYt),KYt=vEe,_Yt=ch(KYt),PYt=HYt,zYt=ch(PYt),OYt=LD,LYt=ch(OYt),JYt=DYt,UYt=ch(JYt),QYt=l2e,OB=ch(QYt),jYt=Os,LB=ch(jYt),SEe=_o,$Yt=Bm,B$=ch($Yt);function ch(g){return g&&g.__esModule?g:{default:g}}var qYt=Function.bind.call(Function.call,Boolean.prototype.valueOf);function wEe(g){var a=(0,B$.default)();return a.displayNameOfNode?(0,B$.default)().displayNameOfNode(g)||"Component":typeof g.type=="function"?g.type.displayName||(0,GEe.default)(g.type)||"Component":g.type}function TEe(g){return Array(g+1).join(" ")}function REe(g,a){return a.split(` -`).map(function(s){return""+String(TEe(g))+String(s)}).join(` -`)}function eKt(g,a){return(0,_Yt.default)(g)?(0,OB.default)(String(g),{quoteStyle:"double"}):(0,zYt.default)(g)?"{"+String((0,OB.default)(Number(g)))+"}":(0,UYt.default)(g)?"{"+String((0,OB.default)(qYt(g)))+"}":(0,LYt.default)(g)?"{"+String((0,OB.default)(g))+"}":(typeof g>"u"?"undefined":BEe(g))==="object"?a.verbose?"{"+String((0,OB.default)(g))+"}":"{{...}}":"{["+(typeof g>"u"?"undefined":BEe(g))+"]}"}function tKt(g,a){var s=(0,SEe.propsOfNode)(g),C=Object.keys(s).filter(function(I){return I!=="children"});return C.map(function(I){return String(I)+"="+String(eKt(s[I],a))}).join(" ")}function iKt(g,a){return g.length?` -`+String(g.map(function(s){return REe(a,s)}).join(` -`))+` -`:""}function nKt(g){return(0,LB.default)(g,"nodeType")&&typeof g.nodeType=="string"&&(0,LB.default)(g,"type")&&(0,LB.default)(g,"key")&&(0,LB.default)(g,"ref")&&(0,LB.default)(g,"instance")&&(0,LB.default)(g,"rendered")}function G$(g){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(typeof g=="string"||typeof g=="number")return(0,FYt.default)(g);if(typeof g=="function"){var C=(0,GEe.default)(g);return"[function"+(C?" "+String(C):"")+"]"}if(!g)return"";var I=(0,B$.default)();if(!I.isValidElement(g)&&!nKt(g))return"{"+String((0,OB.default)(g))+"}";var A=(0,SEe.childrenOfNode)(g).map(function(S){return G$(S,a,s)}).filter(Boolean),d=wEe(g),h=s.ignoreProps?"":tKt(g,s),y=h?" ":"",Z=A.length?">":" ",b=iKt(A,a),w=A.length?"":"/>";return"<"+String(d)+y+String(h)+Z+String(b)+w}function rKt(g){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return g.map(function(s){return G$(s,void 0,a)}).join(` - - -`)}var JB={},UB={},S$={};Object.defineProperty(S$,"__esModule",{value:!0});var VEe=function(a){return JSON.stringify(a)},gKt=function(a){var s=a.body,C=[],I=!0,A=!1,d=void 0;try{for(var h=s[Symbol.iterator](),y;!(I=(y=h.next()).done);I=!0){var Z=y.value,b=void 0;if(Z.type==="universalSelector")b="*";else if(Z.type==="typeSelector")b=Z.name;else if(Z.type==="idSelector")b="#"+Z.name;else if(Z.type==="classSelector")b="."+Z.name;else if(Z.type==="attributePresenceSelector")b="["+Z.name+"]";else if(Z.type==="attributeValueSelector")b="["+Z.name+Z.operator+VEe(Z.value)+"]";else if(Z.type==="pseudoClassSelector")b=":"+Z.name,Z.parameters.length&&(b+="("+Z.parameters.map(VEe).join(", ")+")");else if(Z.type==="pseudoElementSelector")b="::"+Z.name;else throw new Error("Unknown token.");C.push(b)}}catch(w){A=!0,d=w}finally{try{!I&&h.return&&h.return()}finally{if(A)throw d}}return C.join("")};S$.default=function(){var g=function(s){var C=[],I=!0,A=!1,d=void 0;try{for(var h=s[Symbol.iterator](),y;!(I=(y=h.next()).done);I=!0){var Z=y.value;if(Z.type==="selector")C.push(gKt(Z));else if(Z.type==="descendantCombinator")C.push(" ");else if(Z.type==="childCombinator")C.push(" > ");else if(Z.type==="adjacentSiblingCombinator")C.push(" + ");else if(Z.type==="generalSiblingCombinator")C.push(" ~ ");else throw new Error("Unknown token.")}}catch(b){A=!0,d=b}finally{try{!I&&h.return&&h.return()}finally{if(A)throw d}}return C.join("")};return{generate:g}};var w$={},EEe={exports:{}};(function(g){(function(a,s){g.exports?g.exports=s():a.nearley=s()})(ne,function(){function a(Z,b,w){return this.id=++a.highestId,this.name=Z,this.symbols=b,this.postprocess=w,this}a.highestId=0,a.prototype.toString=function(Z){var b=typeof Z>"u"?this.symbols.map(y).join(" "):this.symbols.slice(0,Z).map(y).join(" ")+" ● "+this.symbols.slice(Z).map(y).join(" ");return this.name+" → "+b};function s(Z,b,w,S){this.rule=Z,this.dot=b,this.reference=w,this.data=[],this.wantedBy=S,this.isComplete=this.dot===Z.symbols.length}s.prototype.toString=function(){return"{"+this.rule.toString(this.dot)+"}, from: "+(this.reference||0)},s.prototype.nextState=function(Z){var b=new s(this.rule,this.dot+1,this.reference,this.wantedBy);return b.left=this,b.right=Z,b.isComplete&&(b.data=b.build(),b.right=void 0),b},s.prototype.build=function(){var Z=[],b=this;do Z.push(b.right.data),b=b.left;while(b.left);return Z.reverse(),Z},s.prototype.finish=function(){this.rule.postprocess&&(this.data=this.rule.postprocess(this.data,this.reference,d.fail))};function C(Z,b){this.grammar=Z,this.index=b,this.states=[],this.wants={},this.scannable=[],this.completed={}}C.prototype.process=function(Z){for(var b=this.states,w=this.wants,S=this.completed,R=0;R0&&b.push(" ^ "+S+" more lines identical to this"),S=0,b.push(" "+N)),w=N}},d.prototype.getSymbolDisplay=function(Z){return h(Z)},d.prototype.buildFirstStateStack=function(Z,b){if(b.indexOf(Z)!==-1)return null;if(Z.wantedBy.length===0)return[Z];var w=Z.wantedBy[0],S=[Z].concat(b),R=this.buildFirstStateStack(w,S);return R===null?null:[Z].concat(R)},d.prototype.save=function(){var Z=this.table[this.current];return Z.lexerState=this.lexerState,Z},d.prototype.restore=function(Z){var b=Z.index;this.current=b,this.table[b]=Z,this.table.splice(b+1),this.lexerState=Z.lexerState,this.results=this.finish()},d.prototype.rewind=function(Z){if(!this.options.keepHistory)throw new Error("set option `keepHistory` to enable rewinding");this.restore(this.table[Z])},d.prototype.finish=function(){var Z=[],b=this.grammar.start,w=this.table[this.table.length-1];return w.states.forEach(function(S){S.rule.name===b&&S.dot===S.rule.symbols.length&&S.reference===0&&S.data!==d.fail&&Z.push(S)}),Z.map(function(S){return S.data})};function h(Z){var b=typeof Z;if(b==="string")return Z;if(b==="object"){if(Z.literal)return JSON.stringify(Z.literal);if(Z instanceof RegExp)return"character matching "+Z;if(Z.type)return Z.type+" token";if(Z.test)return"token matching "+String(Z.test);throw new Error("Unknown symbol type: "+Z)}}function y(Z){var b=typeof Z;if(b==="string")return Z;if(b==="object"){if(Z.literal)return JSON.stringify(Z.literal);if(Z instanceof RegExp)return Z.toString();if(Z.type)return"%"+Z.type;if(Z.test)return"<"+String(Z.test)+">";throw new Error("Unknown symbol type: "+Z)}}return{Parser:d,Grammar:I,Rule:a}})})(EEe);var HEe={exports:{}},oKt=1/0,aKt=9007199254740991,sKt="[object Arguments]",IKt="[object Function]",lKt="[object GeneratorFunction]",CKt=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis,cKt=typeof self=="object"&&self&&self.Object===Object&&self,AKt=CKt||cKt||Function("return this")();function uKt(g,a){for(var s=-1,C=a.length,I=g.length;++s0&&s(h)?a>1?XEe(h,a-1,s,C,I):uKt(I,h):C||(I[I.length]=h)}return I}function fKt(g){return bKt(g)||pKt(g)||!!(kEe&&g&&g[kEe])}function mKt(g){var a=g?g.length:0;return a?XEe(g,oKt):[]}function pKt(g){return vKt(g)&&dKt.call(g,"callee")&&(!hKt.call(g,"callee")||WEe.call(g)==sKt)}var bKt=Array.isArray;function yKt(g){return g!=null&&BKt(g.length)&&!ZKt(g)}function vKt(g){return SKt(g)&&yKt(g)}function ZKt(g){var a=GKt(g)?WEe.call(g):"";return a==IKt||a==lKt}function BKt(g){return typeof g=="number"&&g>-1&&g%1==0&&g<=aKt}function GKt(g){var a=typeof g;return!!g&&(a=="object"||a=="function")}function SKt(g){return!!g&&typeof g=="object"}var wKt=mKt;(function(g){(function(){function a(w){return w[0]}var s=wKt,C=function(S,R){return function(H){return H[S].concat([H[R]])}},I=function(S){return S=S.filter(function(R){return R!==null}),s(S)},A={" ":"descendantCombinator","+":"adjacentSiblingCombinator",">":"childCombinator","~":"generalSiblingCombinator"},d=function(S){return(Array.isArray(S[0])?S[0]:[S[0]]).concat({type:A[S[2]]}).concat(S[4])},h=function(S,R,H){var N=s(S).join(""),D=parseFloat(N);return isNaN(D)?H:D},y=function(S,R,H){return S[0]==="true"?!0:S[0]==="false"?!1:H},Z=function(S,R,H){if(S[0]==="NaN")return NaN;if(S[0]!=="undefined")return S[0]==="null"?null:H},b={Lexer:void 0,ParserRules:[{name:"combinator",symbols:["selector"]},{name:"combinator",symbols:["combinator","_",/[>+~ ]/,"_","selector"],postprocess:d},{name:"selector",symbols:["selectorBody"],postprocess:function(S){return{type:"selector",body:S[0]}}},{name:"selectorBody$ebnf$1",symbols:["typeSelector"],postprocess:a},{name:"selectorBody$ebnf$1",symbols:[],postprocess:function(S){return null}},{name:"selectorBody$ebnf$2",symbols:[]},{name:"selectorBody$ebnf$2",symbols:["selectorBody$ebnf$2","simpleSelector"],postprocess:function(S){return S[0].concat([S[1]])}},{name:"selectorBody",symbols:["selectorBody$ebnf$1","selectorBody$ebnf$2"],postprocess:function(S,R,H){var N=I(S);return N.length?N:H}},{name:"selectorBody$ebnf$3",symbols:[]},{name:"selectorBody$ebnf$3",symbols:["selectorBody$ebnf$3","simpleSelector"],postprocess:function(S){return S[0].concat([S[1]])}},{name:"selectorBody",symbols:["universalSelector","selectorBody$ebnf$3"],postprocess:I},{name:"simpleSelector",symbols:["idSelector"]},{name:"simpleSelector",symbols:["classSelector"]},{name:"simpleSelector",symbols:["attributeValueSelector"]},{name:"simpleSelector",symbols:["attributePresenceSelector"]},{name:"simpleSelector",symbols:["pseudoClassSelector"]},{name:"simpleSelector",symbols:["pseudoElementSelector"]},{name:"typeSelector",symbols:["attributeName"],postprocess:function(S){return{type:"typeSelector",name:S[0]}}},{name:"className$ebnf$1",symbols:[{literal:"-"}],postprocess:a},{name:"className$ebnf$1",symbols:[],postprocess:function(S){return null}},{name:"className$ebnf$2",symbols:[]},{name:"className$ebnf$2",symbols:["className$ebnf$2",/[_a-zA-Z0-9-]/],postprocess:function(S){return S[0].concat([S[1]])}},{name:"className",symbols:["className$ebnf$1",/[_a-zA-Z]/,"className$ebnf$2"],postprocess:function(S){return(S[0]||"")+S[1]+S[2].join("")}},{name:"attributeName$ebnf$1",symbols:[]},{name:"attributeName$ebnf$1",symbols:["attributeName$ebnf$1",/[_a-zA-Z()0-9-]/],postprocess:function(S){return S[0].concat([S[1]])}},{name:"attributeName",symbols:[/[_a-z()A-Z]/,"attributeName$ebnf$1"],postprocess:function(S){return S[0]+S[1].join("")}},{name:"classSelector",symbols:[{literal:"."},"className"],postprocess:function(S){return{type:"classSelector",name:S[1]}}},{name:"idSelector",symbols:[{literal:"#"},"attributeName"],postprocess:function(S){return{type:"idSelector",name:S[1]}}},{name:"universalSelector",symbols:[{literal:"*"}],postprocess:function(S){return{type:"universalSelector"}}},{name:"attributePresenceSelector",symbols:[{literal:"["},"attributeName",{literal:"]"}],postprocess:function(S){return{type:"attributePresenceSelector",name:S[1]}}},{name:"attributeOperator",symbols:[{literal:"="}]},{name:"attributeOperator$string$1",symbols:[{literal:"~"},{literal:"="}],postprocess:function(S){return S.join("")}},{name:"attributeOperator",symbols:["attributeOperator$string$1"]},{name:"attributeOperator$string$2",symbols:[{literal:"|"},{literal:"="}],postprocess:function(S){return S.join("")}},{name:"attributeOperator",symbols:["attributeOperator$string$2"]},{name:"attributeOperator$string$3",symbols:[{literal:"^"},{literal:"="}],postprocess:function(S){return S.join("")}},{name:"attributeOperator",symbols:["attributeOperator$string$3"]},{name:"attributeOperator$string$4",symbols:[{literal:"$"},{literal:"="}],postprocess:function(S){return S.join("")}},{name:"attributeOperator",symbols:["attributeOperator$string$4"]},{name:"attributeOperator$string$5",symbols:[{literal:"*"},{literal:"="}],postprocess:function(S){return S.join("")}},{name:"attributeOperator",symbols:["attributeOperator$string$5"]},{name:"attributeValueSelector",symbols:[{literal:"["},"attributeName","attributeOperator","attributeValue",{literal:"]"}],postprocess:function(S){return{type:"attributeValueSelector",name:S[1],value:S[3],operator:S[2][0]}}},{name:"attributeValue",symbols:["falsyPrimitiveStrings"],postprocess:a},{name:"attributeValue",symbols:["numericValue"],postprocess:a},{name:"attributeValue",symbols:["sqstring"],postprocess:a},{name:"attributeValue",symbols:["dqstring"],postprocess:a},{name:"falsyPrimitiveStrings$string$1",symbols:[{literal:"f"},{literal:"a"},{literal:"l"},{literal:"s"},{literal:"e"}],postprocess:function(S){return S.join("")}},{name:"falsyPrimitiveStrings",symbols:["falsyPrimitiveStrings$string$1"],postprocess:y},{name:"falsyPrimitiveStrings$string$2",symbols:[{literal:"t"},{literal:"r"},{literal:"u"},{literal:"e"}],postprocess:function(S){return S.join("")}},{name:"falsyPrimitiveStrings",symbols:["falsyPrimitiveStrings$string$2"],postprocess:y},{name:"falsyPrimitiveStrings$string$3",symbols:[{literal:"N"},{literal:"a"},{literal:"N"}],postprocess:function(S){return S.join("")}},{name:"falsyPrimitiveStrings",symbols:["falsyPrimitiveStrings$string$3"],postprocess:Z},{name:"falsyPrimitiveStrings$string$4",symbols:[{literal:"n"},{literal:"u"},{literal:"l"},{literal:"l"}],postprocess:function(S){return S.join("")}},{name:"falsyPrimitiveStrings",symbols:["falsyPrimitiveStrings$string$4"],postprocess:Z},{name:"falsyPrimitiveStrings$string$5",symbols:[{literal:"u"},{literal:"n"},{literal:"d"},{literal:"e"},{literal:"f"},{literal:"i"},{literal:"n"},{literal:"e"},{literal:"d"}],postprocess:function(S){return S.join("")}},{name:"falsyPrimitiveStrings",symbols:["falsyPrimitiveStrings$string$5"],postprocess:Z},{name:"numericValue",symbols:["int",{literal:"."},"int"],postprocess:h},{name:"numericValue",symbols:[{literal:"+"},"int",{literal:"."},"int"],postprocess:h},{name:"numericValue",symbols:[{literal:"-"},"int",{literal:"."},"int"],postprocess:h},{name:"numericValue",symbols:[{literal:"-"},"int"],postprocess:h},{name:"numericValue",symbols:["int"],postprocess:h},{name:"numericValue",symbols:[{literal:"+"},"int"],postprocess:h},{name:"numericValue$string$1",symbols:[{literal:"I"},{literal:"n"},{literal:"f"},{literal:"i"},{literal:"n"},{literal:"i"},{literal:"t"},{literal:"y"}],postprocess:function(S){return S.join("")}},{name:"numericValue",symbols:["numericValue$string$1"],postprocess:h},{name:"numericValue$string$2",symbols:[{literal:"+"},{literal:"I"},{literal:"n"},{literal:"f"},{literal:"i"},{literal:"n"},{literal:"i"},{literal:"t"},{literal:"y"}],postprocess:function(S){return S.join("")}},{name:"numericValue",symbols:["numericValue$string$2"],postprocess:h},{name:"numericValue$string$3",symbols:[{literal:"-"},{literal:"I"},{literal:"n"},{literal:"f"},{literal:"i"},{literal:"n"},{literal:"i"},{literal:"t"},{literal:"y"}],postprocess:function(S){return S.join("")}},{name:"numericValue",symbols:["numericValue$string$3"],postprocess:h},{name:"int$ebnf$1",symbols:[/[0-9]/]},{name:"int$ebnf$1",symbols:["int$ebnf$1",/[0-9]/],postprocess:function(S){return S[0].concat([S[1]])}},{name:"int",symbols:["int$ebnf$1"]},{name:"classParameters",symbols:[]},{name:"classParameters",symbols:["classParameter"]},{name:"classParameters",symbols:["classParameters",{literal:","},"_","classParameter"],postprocess:C(0,3)},{name:"classParameter$ebnf$1",symbols:[/[^()"', ]/]},{name:"classParameter$ebnf$1",symbols:["classParameter$ebnf$1",/[^()"', ]/],postprocess:function(S){return S[0].concat([S[1]])}},{name:"classParameter",symbols:["classParameter$ebnf$1"],postprocess:function(S){return S[0].join("")}},{name:"classParameter",symbols:["sqstring"],postprocess:a},{name:"classParameter",symbols:["dqstring"],postprocess:a},{name:"pseudoElementSelector$string$1",symbols:[{literal:":"},{literal:":"}],postprocess:function(S){return S.join("")}},{name:"pseudoElementSelector",symbols:["pseudoElementSelector$string$1","pseudoClassSelectorName"],postprocess:function(S){return{type:"pseudoElementSelector",name:S[1]}}},{name:"pseudoClassSelector",symbols:[{literal:":"},"pseudoClassSelectorName"],postprocess:function(S){return{type:"pseudoClassSelector",name:S[1]}}},{name:"pseudoClassSelector",symbols:[{literal:":"},"pseudoClassSelectorName",{literal:"("},"classParameters",{literal:")"}],postprocess:function(S){return{type:"pseudoClassSelector",name:S[1],parameters:S[3]}}},{name:"pseudoClassSelectorName$ebnf$1",symbols:[/[a-zA-Z0-9-_]/]},{name:"pseudoClassSelectorName$ebnf$1",symbols:["pseudoClassSelectorName$ebnf$1",/[a-zA-Z0-9-_]/],postprocess:function(S){return S[0].concat([S[1]])}},{name:"pseudoClassSelectorName",symbols:[/[a-zA-Z]/,"pseudoClassSelectorName$ebnf$1"],postprocess:function(S){return S[0]+S[1].join("")}},{name:"dqstring$ebnf$1",symbols:[]},{name:"dqstring$ebnf$1",symbols:["dqstring$ebnf$1","dstrchar"],postprocess:function(S){return S[0].concat([S[1]])}},{name:"dqstring",symbols:[{literal:'"'},"dqstring$ebnf$1",{literal:'"'}],postprocess:function(S){return S[1].join("")}},{name:"dstrchar",symbols:[/[^"]/],postprocess:a},{name:"dstrchar$string$1",symbols:[{literal:"\\"},{literal:'"'}],postprocess:function(S){return S.join("")}},{name:"dstrchar",symbols:["dstrchar$string$1"],postprocess:function(S){return'"'}},{name:"sqstring$ebnf$1",symbols:[]},{name:"sqstring$ebnf$1",symbols:["sqstring$ebnf$1","sstrchar"],postprocess:function(S){return S[0].concat([S[1]])}},{name:"sqstring",symbols:[{literal:"'"},"sqstring$ebnf$1",{literal:"'"}],postprocess:function(S){return S[1].join("")}},{name:"sstrchar",symbols:[/[^']/],postprocess:a},{name:"sstrchar$string$1",symbols:[{literal:"\\"},{literal:"'"}],postprocess:function(S){return S.join("")}},{name:"sstrchar",symbols:["sstrchar$string$1"],postprocess:function(S){return"'"}},{name:"_$ebnf$1",symbols:[]},{name:"_$ebnf$1",symbols:["_$ebnf$1",/[ ]/],postprocess:function(S){return S[0].concat([S[1]])}},{name:"_",symbols:["_$ebnf$1"],postprocess:function(S){return null}}],ParserStart:"combinator"};g.exports=b})()})(HEe),Object.defineProperty(w$,"__esModule",{value:!0});var TKt=EEe.exports,RKt=HEe.exports,xEe=VKt(RKt);function VKt(g){return g&&g.__esModule?g:{default:g}}w$.default=function(){var g=function(s){var C=new TKt.Parser(xEe.default.ParserRules,xEe.default.ParserStart),I=C.feed(s).results;if(I.length===0)throw new Error("Found no parsings.");if(I.length>1)throw new Error("Ambiguous results.");return I[0]};return{parse:g}},Object.defineProperty(UB,"__esModule",{value:!0}),UB.createParser=UB.createGenerator=void 0;var EKt=S$,HKt=DEe(EKt),WKt=w$,NKt=DEe(WKt);function DEe(g){return g&&g.__esModule?g:{default:g}}UB.createGenerator=HKt.default,UB.createParser=NKt.default;var kKt=Gb.exports,MEe=ts,XKt=MEe("Object.prototype.propertyIsEnumerable"),xKt=MEe("Array.prototype.push"),FEe=function(a){var s=kKt(a),C=[];for(var I in s)XKt(s,I)&&xKt(C,s[I]);return C},DKt=FEe,YEe=function(){return typeof Object.values=="function"?Object.values:DKt},MKt=YEe,FKt=es,YKt=function(){var a=MKt();return FKt(Object,{values:a},{values:function(){return Object.values!==a}}),a},KKt=es,_Kt=Cu.exports,PKt=FEe,KEe=YEe,zKt=YKt,_Ee=_Kt(KEe(),Object);KKt(_Ee,{getPolyfill:KEe,implementation:PKt,shim:zKt});var OKt=_Ee,LKt=O2e,JKt=Q2e(),UKt=sTe(),QKt=WR,jKt=lTe(),$Kt=_6.exports,qKt=GTe(),e3t=K6,t3t=RTe,PEe=f8,i3t=ts,n3t=vEe,zEe=Object("a"),r3t=zEe[0]!=="a"||!(0 in zEe),g3t=i3t("String.prototype.split"),OEe=function(a){var s=t3t(this),C=r3t&&n3t(s)?g3t(s,""):s,I=qKt(C);if(!$Kt(a))throw new TypeError("Array.prototype.filter callback must be a function");var A;arguments.length>1&&(A=arguments[1]);for(var d=LKt(s,0),h=0,y=0;h"u")return!1;if(a.type===tHe)return(0,X3t.default)(A,a.name);if((typeof h!="string"||typeof C!="string")&&s!==iHe)return!1;switch(s){case iHe:return(0,N3t.default)(h,C);case q3t:return h.split(" ").indexOf(C)!==-1;case e_t:return h===C||h.startsWith(String(C)+"-");case t_t:return C===""?!1:h.slice(0,C.length)===C;case i_t:return C===""?!1:h.slice(-C.length)===C;case n_t:return C===""?!1:h.indexOf(C)!==-1;default:throw new Error('Enzyme::Selector: Unknown attribute selector operator "'+String(s)+'"')}}function r_t(g,a,s){var C=a.name,I=a.parameters;if(C==="not")return I.every(function(S){return $5(S,g).length===0});if(C==="empty")return(0,eI.treeFilter)(g,function(S){return S!==g}).length===0;if(C==="first-child"){var A=(0,eI.findParentNode)(s,g),d=A.rendered,h=T3t(d,1),y=h[0];return y===g}if(C==="last-child"){var Z=(0,eI.findParentNode)(s,g),b=Z.rendered;return b[b.length-1]===g}if(C==="focus"){if(typeof document>"u")throw new Error('Enzyme::Selector does not support the ":focus" pseudo-element without a globalThis `document`.');var w=(0,qEe.default)();return document.activeElement&&w.nodeToHostNode(g)===document.activeElement}throw new TypeError('Enzyme::Selector does not support the "'+String(a.name)+'" pseudo-element or pseudo-class selectors.')}function g_t(g,a,s){if(g===null||typeof g=="string")return!1;switch(a.type){case U3t:return!0;case L3t:return(0,eI.hasClassName)(g,a.name);case O3t:return(0,$Ee.nodeHasType)(g,a.name);case J3t:return(0,eI.nodeHasId)(g,a.name);case tHe:return gHe(g,a);case Q3t:return gHe(g,a);case $3t:case j3t:return r_t(g,a,s);default:throw new Error("Unknown token type: "+String(a.type))}}function H$(g,a){return function(s){return g.body.every(function(C){return g_t(s,C,a)})}}function o_t(g){return g.some(function(a){return a.type!==eHe})}function oHe(g){if(typeof g=="string"){var a=rHe(g);if(o_t(a))throw new TypeError("This method does not support complex CSS selectors");return H$(a[0])}var s=(0,qEe.default)(),C=s.isValidElementType?s.isValidElementType(g):typeof g=="function";if(C)return function(A){return s.matchesElementType(A,g)};if((typeof g>"u"?"undefined":jEe(g))==="object"){if(!Array.isArray(g)&&g!==null&&Object.keys(g).length>0){var I=(0,E3t.default)(g).some(function(A){return typeof A>"u"});if(I)throw new TypeError("Enzyme::Props can’t have `undefined` values. Try using ‘findWhere()’ instead.");return function(A){return(0,eI.nodeMatchesObjectProps)(A,g)}}throw new TypeError("Enzyme::Selector does not support an array, null, or empty object as a selector")}throw new TypeError("Enzyme::Selector expects a string, object, or valid element type (Component Constructor)")}function a_t(g,a,s){return g.reduce(function(C,I){var A=(0,eI.findParentNode)(s,I);if(!A)return C;var d=(0,eI.childrenOfNode)(A),h=d.indexOf(I),y=d[h+1];return y&&a(y)&&C.push(y),C},[])}function s_t(g,a,s){return E$(function(C,I){var A=(0,eI.findParentNode)(s,I);if(!A)return C;var d=(0,eI.childrenOfNode)(A),h=d.indexOf(I),y=d.slice(h+1);return C.concat(y.filter(a))},g)}function I_t(g,a){return E$(function(s,C){return s.concat((0,eI.childrenOfNode)(C).filter(a))},g)}function l_t(g,a){return E$(function(s,C){return s.concat((0,eI.treeFilter)(C,a))},(0,V$.default)(g.map(eI.childrenOfNode)))}function $5(g,a){if(typeof g!="string"){var s=(0,D3t.default)(g);if(s.length>0)return(0,V$.default)(s.map(function(b){return $5(b.tag,a)}))}if(typeof g=="function"||(typeof g>"u"?"undefined":jEe(g))==="object")return(0,eI.treeFilter)(a,oHe(g));var C=[];if(typeof g=="string")for(var I=rHe(g),A=0;A2&&arguments[2]!==void 0?arguments[2]:R.treeFilter;return Ne.flatMap(function(Xe){return He(Xe.getNodeInternal(),Ge)})}function fe(Ne,Ge){return Ne.wrap(Ne.getNodesInternal().filter(Ge).filter(Boolean))}function We(Ne){if(Ne[te].length!==1)throw new Error("getRootNodeInternal(wrapper) can only be called when wrapper wraps one node");return Ne[te]!==Ne?Ne[ue][0]:Ne[te][P]}function _e(Ne,Ge){return(0,R.parentsOfNode)(Ge,We(Ne))}function qe(Ne,Ge){Ge?Array.isArray(Ge)?((0,Z.privateSet)(Ne,P,Ge[0]),(0,Z.privateSet)(Ne,J,Ge)):((0,Z.privateSet)(Ne,P,Ge),(0,Z.privateSet)(Ne,J,[Ge])):((0,Z.privateSet)(Ne,P,null),(0,Z.privateSet)(Ne,J,[])),(0,Z.privateSet)(Ne,"length",Ne[J].length)}var nt=function(){function Ne(Ge,He){var Xe=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(K(this,Ne),!globalThis.window&&!globalThis.document)throw new Error("It looks like you called `mount()` without a globalThis document being loaded.");var at=(0,Z.makeOptions)(Xe);if(He)(0,Z.privateSet)(this,j,He[j]),(0,Z.privateSet)(this,te,He),qe(this,Ge),(0,Z.privateSet)(this,ue,He[J]),(0,Z.privateSet)(this,Ce,He[Ce]),(0,Z.privateSet)(this,he,[]);else{var bt=(0,w.default)(at);if(!bt.isValidElement(Ge))throw new TypeError("ReactWrapper can only wrap valid elements");var xt=bt.createRenderer((0,I.default)({mode:"mount"},at));if((0,Z.privateSet)(this,j,xt),xt.render(Ge,at.context),(0,Z.privateSet)(this,te,this),qe(this,this[j].getNode()),(0,Z.privateSet)(this,Ce,at),(0,Z.privateSet)(this,he,[]),(0,Z.isCustomComponent)(at.wrappingComponent,bt)){if(typeof this[j].getWrappingComponentRenderer!="function")throw new TypeError("your adapter does not support `wrappingComponent`. Try upgrading it!");(0,Z.privateSet)(this,oe,new At(this,this[j].getWrappingComponentRenderer())),this[he].push(this[oe])}}(0,Z.privateSet)(this,ie,Ge),(0,Z.privateSet)(this,ye,null)}return s(Ne,[{key:"root",value:function(){function Ge(){return this[te]}return Ge}()},{key:"getNodeInternal",value:function(){function Ge(){if(this.length!==1)throw new Error("ReactWrapper::getNode() can only be called when wrapping one node");return this[J][0]}return Ge}()},{key:"getNodesInternal",value:function(){function Ge(){return this[J]}return Ge}()},{key:"getElement",value:function(){function Ge(){var He=this;return this.single("getElement",function(){return(0,w.default)(He[Ce]).nodeToElement(He[P])})}return Ge}()},{key:"getElements",value:function(){function Ge(){var He=this;return this[J].map(function(Xe){return(0,w.default)(He[Ce]).nodeToElement(Xe)})}return Ge}()},{key:"getNode",value:function(){function Ge(){throw new Error("ReactWrapper::getNode() is no longer supported. Use ReactWrapper::instance() instead")}return Ge}()},{key:"getNodes",value:function(){function Ge(){throw new Error("ReactWrapper::getNodes() is no longer supported.")}return Ge}()},{key:"getDOMNode",value:function(){function Ge(){var He=(0,w.default)(this[Ce]);return this.single("getDOMNode",function(Xe){return He.nodeToHostNode(Xe,!0)})}return Ge}()},{key:"ref",value:function(){function Ge(He){if(this[te]!==this)throw new Error("ReactWrapper::ref(refname) can only be called on the root");return this.instance().refs[He]}return Ge}()},{key:"instance",value:function(){function Ge(){var He=this;return this.single("instance",function(){return He[P].instance})}return Ge}()},{key:"getWrappingComponent",value:function(){function Ge(){if(this[te]!==this)throw new Error("ReactWrapper::getWrappingComponent() can only be called on the root");if(!this[Ce].wrappingComponent)throw new Error("ReactWrapper::getWrappingComponent() can only be called on a wrapper that was originally passed a `wrappingComponent` option");return this[oe]}return Ge}()},{key:"update",value:function(){function Ge(){var He=this,Xe=this[te];return this!==Xe?Xe.update():(qe(this,this[j].getNode()),this[he].forEach(function(at){if(at!==He[ye]){at[ye]=He;try{at.update()}finally{at[ye]=null}}}),this)}return Ge}()},{key:"unmount",value:function(){function Ge(){var He=this;if(this[te]!==this)throw new Error("ReactWrapper::unmount() can only be called on the root");return this.single("unmount",function(){He[j].unmount(),He.update()}),this}return Ge}()},{key:"mount",value:function(){function Ge(){var He=this;if(this[te]!==this)throw new Error("ReactWrapper::mount() can only be called on the root");return this[j].render(this[ie],this[Ce].context,function(){return He.update()}),this}return Ge}()},{key:"setProps",value:function(){function Ge(He){var Xe=this,at=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;if(this[te]!==this)throw new Error("ReactWrapper::setProps() can only be called on the root");if(arguments.length>1&&typeof at!="function")throw new TypeError("ReactWrapper::setProps() expects a function as its second argument");var bt=(0,w.default)(this[Ce]);return this[ie]=(0,Z.cloneElement)(bt,this[ie],He),this[j].render(this[ie],null,function(){Xe.update(),at&&at()}),this}return Ge}()},{key:"setState",value:function(){function Ge(He){var Xe=this,at=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;if(this.instance()===null||this.getNodeInternal().nodeType!=="class")throw new Error("ReactWrapper::setState() can only be called on class components");if(arguments.length>1&&typeof at!="function")throw new TypeError("ReactWrapper::setState() expects a function as its second argument");return this.instance().setState(He,function(){if(Xe.update(),at){var bt=(0,w.default)(Xe[Ce]),xt=Xe.instance();bt.invokeSetStateCallback?bt.invokeSetStateCallback(xt,at):at.call(xt)}}),this}return Ge}()},{key:"setContext",value:function(){function Ge(He){var Xe=this;if(this[te]!==this)throw new Error("ReactWrapper::setContext() can only be called on the root");if(!this[Ce].context)throw new Error("ReactWrapper::setContext() can only be called on a wrapper that was originally passed a context option");return this[j].render(this[ie],He,function(){return Xe.update()}),this}return Ge}()},{key:"contains",value:function(){function Ge(He){var Xe=(0,w.default)(this[Ce]),at=Array.isArray(He)?function(bt){return(0,Z.containsChildrenSubArray)(Z.nodeEqual,bt,He.map(function(xt){return Xe.elementToNode(xt)}))}:function(bt){return(0,Z.nodeEqual)(Xe.elementToNode(He),bt)};return Ie(this,at).length>0}return Ge}()},{key:"containsMatchingElement",value:function(){function Ge(He){var Xe=(0,w.default)(this[Ce]).elementToNode(He),at=function(){function bt(xt){return(0,Z.nodeMatches)(Xe,xt,function(Vt,_t){return Vt<=_t})}return bt}();return Ie(this,at).length>0}return Ge}()},{key:"containsAllMatchingElements",value:function(){function Ge(He){var Xe=this;if(!Array.isArray(He))throw new TypeError("nodes should be an Array");return He.every(function(at){return Xe.containsMatchingElement(at)})}return Ge}()},{key:"containsAnyMatchingElements",value:function(){function Ge(He){var Xe=this;return Array.isArray(He)&&He.some(function(at){return Xe.containsMatchingElement(at)})}return Ge}()},{key:"equals",value:function(){function Ge(He){var Xe=this;return this.single("equals",function(){return(0,Z.nodeEqual)(Xe.getNodeInternal(),He)})}return Ge}()},{key:"matchesElement",value:function(){function Ge(He){var Xe=this;return this.single("matchesElement",function(){var at=(0,w.default)(Xe[Ce]),bt=at.elementToNode(He);return(0,Z.nodeMatches)(bt,Xe.getNodeInternal(),function(xt,Vt){return xt<=Vt})})}return Ge}()},{key:"find",value:function(){function Ge(He){return this.wrap((0,H.reduceTreesBySelector)(He,this.getNodesInternal()))}return Ge}()},{key:"is",value:function(){function Ge(He){var Xe=(0,H.buildPredicate)(He);return this.single("is",function(at){return Xe(at)})}return Ge}()},{key:"isEmptyRender",value:function(){function Ge(){var He=this.getNodeInternal();return(0,Z.renderedDive)(He)}return Ge}()},{key:"filterWhere",value:function(){function Ge(He){var Xe=this;return fe(this,function(at){return He(Xe.wrap(at))})}return Ge}()},{key:"filter",value:function(){function Ge(He){var Xe=(0,H.buildPredicate)(He);return fe(this,Xe)}return Ge}()},{key:"not",value:function(){function Ge(He){var Xe=(0,H.buildPredicate)(He);return fe(this,function(at){return!Xe(at)})}return Ge}()},{key:"text",value:function(){function Ge(){var He=(0,w.default)(this[Ce]);return this.single("text",function(Xe){return(0,R.getTextFromHostNodes)(Xe,He)})}return Ge}()},{key:"html",value:function(){function Ge(){var He=(0,w.default)(this[Ce]);return this.single("html",function(Xe){return(0,R.getHTMLFromHostNodes)(Xe,He)})}return Ge}()},{key:"render",value:function(){function Ge(){var He=this.html();return(0,Z.loadCheerioRoot)(He)}return Ge}()},{key:"simulate",value:function(){function Ge(He){var Xe=this,at=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.single("simulate",function(bt){return Xe[j].simulateEvent(bt,He,at),Xe[te].update(),Xe})}return Ge}()},{key:"simulateError",value:function(){function Ge(He){var Xe=this;if(this[te]===this)throw new Error("ReactWrapper::simulateError() may not be called on the root");return this.single("simulateError",function(at){if(at.nodeType==="host")throw new Error("ReactWrapper::simulateError() can only be called on custom components");var bt=Xe[j];if(typeof bt.simulateError!="function")throw new TypeError("your adapter does not support `simulateError`. Try upgrading it!");var xt=We(Xe),Vt=[at].concat(_e(Xe,at));return bt.simulateError(Vt,xt,He),Xe[te].update(),Xe})}return Ge}()},{key:"props",value:function(){function Ge(){return this.single("props",R.propsOfNode)}return Ge}()},{key:"state",value:function(){function Ge(He){var Xe=this,at=this[te]===this?this[j].getNode():this.getNodeInternal();if(this.instance()===null||at.nodeType!=="class")throw new Error("ReactWrapper::state() can only be called on class components");var bt=this.single("state",function(){return Xe.instance().state});if(typeof He<"u"){if(bt==null)throw new TypeError('ReactWrapper::state("'+String(He)+'") requires that `state` not be `null` or `undefined`');return bt[He]}return bt}return Ge}()},{key:"context",value:function(){function Ge(He){var Xe=this;if(this[te]!==this)throw new Error("ReactWrapper::context() can only be called on the root");var at=this.single("context",function(){return Xe.instance()});if(at===null)throw new Error("ReactWrapper::context() can only be called on components with instances");var bt=at.context;return typeof He<"u"?bt[He]:bt}return Ge}()},{key:"children",value:function(){function Ge(He){var Xe=this.flatMap(function(at){return(0,R.childrenOfNode)(at.getNodeInternal())});return He?Xe.filter(He):Xe}return Ge}()},{key:"childAt",value:function(){function Ge(He){var Xe=this;return this.single("childAt",function(){return Xe.children().at(He)})}return Ge}()},{key:"parents",value:function(){function Ge(He){var Xe=this;return this.single("parents",function(at){var bt=Xe.wrap(_e(Xe,at));return He?bt.filter(He):bt})}return Ge}()},{key:"parent",value:function(){function Ge(){return this.flatMap(function(He){return[He.parents().get(0)]})}return Ge}()},{key:"closest",value:function(){function Ge(He){if(this.is(He))return this;var Xe=this.parents().filter(He);return Xe.length>0?Xe.first():this.findWhere(function(){return!1})}return Ge}()},{key:"prop",value:function(){function Ge(He){return this.props()[He]}return Ge}()},{key:"invoke",value:function(){function Ge(He){var Xe=this;return this.single("invoke",function(){var at=Xe.prop(He);if(typeof at!="function")throw new TypeError("ReactWrapper::invoke() requires the name of a prop whose value is a function");return function(){for(var bt=arguments.length,xt=Array(bt),Vt=0;Vt"u"?"undefined":a(Vt))+"“");return function(){var _t=Vt.apply(void 0,arguments),Ci=at.wrap(_t);return Xe.wrap(Ci,null,Xe[Ce])}})}return Ge}()},{key:"key",value:function(){function Ge(){return this.single("key",function(He){return He.key===void 0?null:He.key})}return Ge}()},{key:"type",value:function(){function Ge(){return this.single("type",function(He){return(0,Z.typeOfNode)(He)})}return Ge}()},{key:"name",value:function(){function Ge(){var He=(0,w.default)(this[Ce]);return this.single("name",function(Xe){return He.displayNameOfNode?He.displayNameOfNode(Xe):(0,Z.displayNameOfNode)(Xe)})}return Ge}()},{key:"hasClass",value:function(){function Ge(He){return typeof He=="string"&&He.indexOf(".")!==-1&&console.warn("It looks like you're calling `ReactWrapper::hasClass()` with a CSS selector. hasClass() expects a class name, not a CSS selector."),this.single("hasClass",function(Xe){return(0,R.hasClassName)(Xe,He)})}return Ge}()},{key:"forEach",value:function(){function Ge(He){var Xe=this;return this.getNodesInternal().forEach(function(at,bt){return He.call(Xe,Xe.wrap(at),bt)}),this}return Ge}()},{key:"map",value:function(){function Ge(He){var Xe=this;return this.getNodesInternal().map(function(at,bt){return He.call(Xe,Xe.wrap(at),bt)})}return Ge}()},{key:"reduce",value:function(){function Ge(He){var Xe=this,at=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;return arguments.length>1?this.getNodesInternal().reduce(function(bt,xt,Vt){return He.call(Xe,bt,Xe.wrap(xt),Vt)},at):this.getNodesInternal().reduce(function(bt,xt,Vt){return He.call(Xe,Vt===1?Xe.wrap(bt):bt,Xe.wrap(xt),Vt)})}return Ge}()},{key:"reduceRight",value:function(){function Ge(He){var Xe=this,at=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;return arguments.length>1?this.getNodesInternal().reduceRight(function(bt,xt,Vt){return He.call(Xe,bt,Xe.wrap(xt),Vt)},at):this.getNodesInternal().reduceRight(function(bt,xt,Vt){return He.call(Xe,Vt===1?Xe.wrap(bt):bt,Xe.wrap(xt),Vt)})}return Ge}()},{key:"slice",value:function(){function Ge(He,Xe){return this.wrap(this.getNodesInternal().slice(He,Xe))}return Ge}()},{key:"some",value:function(){function Ge(He){if(this[te]===this)throw new Error("ReactWrapper::some() can not be called on the root");var Xe=(0,H.buildPredicate)(He);return this.getNodesInternal().some(Xe)}return Ge}()},{key:"someWhere",value:function(){function Ge(He){var Xe=this;return this.getNodesInternal().some(function(at,bt){return He.call(Xe,Xe.wrap(at),bt)})}return Ge}()},{key:"every",value:function(){function Ge(He){var Xe=(0,H.buildPredicate)(He);return this.getNodesInternal().every(Xe)}return Ge}()},{key:"everyWhere",value:function(){function Ge(He){var Xe=this;return this.getNodesInternal().every(function(at,bt){return He.call(Xe,Xe.wrap(at),bt)})}return Ge}()},{key:"flatMap",value:function(){function Ge(He){var Xe=this,at=this.getNodesInternal().map(function(xt,Vt){return He.call(Xe,Xe.wrap(xt),Vt)}),bt=(0,d.default)(at,1);return this.wrap(bt.filter(Boolean))}return Ge}()},{key:"findWhere",value:function(){function Ge(He){var Xe=this;return Ie(this,function(at){var bt=Xe.wrap(at);return bt.length>0&&He(bt)})}return Ge}()},{key:"get",value:function(){function Ge(He){return this.getElements()[He]}return Ge}()},{key:"at",value:function(){function Ge(He){var Xe=this.getNodesInternal();return He0&&arguments[0]!==void 0?arguments[0]:null;return arguments.length>0?this.find(He).exists():this.length>0}return Ge}()},{key:"single",value:function(){function Ge(He,Xe){var at=typeof He=="string"?He:"unknown",bt=typeof Xe=="function"?Xe:He;if(this.length!==1)throw new Error("Method “"+at+"” is meant to be run on 1 node. "+String(this.length)+" found instead.");return bt.call(this,this.getNodeInternal())}return Ge}()},{key:"wrap",value:function(){function Ge(He){var Xe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this[te];if(He instanceof Ne)return He;for(var at=arguments.length,bt=Array(at>2?at-2:0),xt=2;xt0&&arguments[0]!==void 0?arguments[0]:{};return(0,S.debugNodes)(this.getNodesInternal(),He)}return Ge}()},{key:"tap",value:function(){function Ge(He){return He(this),this}return Ge}()},{key:"detach",value:function(){function Ge(){if(this[te]!==this)throw new Error("ReactWrapper::detach() can only be called on the root");if(!this[Ce].attachTo)throw new Error("ReactWrapper::detach() can only be called on when the `attachTo` option was passed into `mount()`.");this[j].unmount()}return Ge}()},{key:"hostNodes",value:function(){function Ge(){return this.filterWhere(function(He){return typeof He.type()=="string"})}return Ge}()}]),Ne}(),At=function(Ne){z(Ge,Ne);function Ge(He,Xe){K(this,Ge);var at=M(this,(Ge.__proto__||Object.getPrototypeOf(Ge)).call(this,Xe.getNode(),He));return(0,Z.privateSet)(at,te,at),(0,Z.privateSet)(at,j,Xe),at[he].push(He),at}return s(Ge,[{key:"getWrappingComponent",value:function(){function He(){throw new TypeError("ReactWrapper::getWrappingComponent() can only be called on the root")}return He}()}]),Ge}(nt);Z.ITERATOR_SYMBOL&&Object.defineProperty(nt.prototype,Z.ITERATOR_SYMBOL,{configurable:!0,value:function(){function Ne(){var Ge,He=this[J][Z.ITERATOR_SYMBOL](),Xe=(0,w.default)(this[Ce]);return Ge={},D(Ge,Z.ITERATOR_SYMBOL,function(){return this}),D(Ge,"next",function(){function at(){var bt=He.next();return bt.done?{done:!0}:{done:!1,value:Xe.nodeToElement(bt.value)}}return at}()),Ge}return Ne}()});function Tt(Ne,Ge){Object.defineProperty(nt.prototype,Ne,{get:function(){function He(){throw new Error(` - Attempted to access ReactWrapper::`+String(Ne)+`, which was previously a private property on - Enzyme ReactWrapper instances, but is no longer and should not be relied upon. - `+String(Ge)+` - `)}return He}(),enumerable:!1,configurable:!1})}Tt("node","Consider using the getElement() method instead."),Tt("nodes","Consider using the getElements() method instead."),Tt("renderer",""),Tt("options",""),Tt("complexSelector",""),g.default=nt})(t6);var W$={};(function(g){Object.defineProperty(g,"__esModule",{value:!0});var a=function(){function Ht(Ye,Qe,pt){Ye===null&&(Ye=Function.prototype);var re=Object.getOwnPropertyDescriptor(Ye,Qe);if(re===void 0){var U=Object.getPrototypeOf(Ye);return U===null?void 0:Ht(U,Qe,pt)}else{if("value"in re)return re.value;var q=re.get;return q===void 0?void 0:q.call(pt)}}return Ht}(),s=function(){function Ht(Ye,Qe){for(var pt=0;pt2&&arguments[2]!==void 0?arguments[2]:D.treeFilter;return Ht.flatMap(function(pt){return Qe(pt.getNodeInternal(),Ye)})}function Ne(Ht,Ye){return Ht.wrap(Ht.getNodesInternal().filter(Ye).filter(Boolean))}function Ge(Ht){var Ye=Ht.lifecycleExperimental,Qe=Ht.disableLifecycleMethods,pt=Ht.enableComponentDidUpdateOnSetState,re=Ht.supportPrevContextArgumentOfComponentDidUpdate,U=Ht.lifecycles;if(typeof Ye<"u"&&typeof Ye!="boolean")throw new Error("lifecycleExperimental must be either true or false if provided");if(typeof Qe<"u"&&typeof Qe!="boolean")throw new Error("disableLifecycleMethods must be either true or false if provided");if(Ye!=null&&Qe!=null&&Ye===Qe)throw new Error("lifecycleExperimental and disableLifecycleMethods cannot be set to the same value");if(typeof pt<"u"&&U.componentDidUpdate&&U.componentDidUpdate.onSetState!==pt)throw new TypeError("the legacy enableComponentDidUpdateOnSetState option should be matched by `lifecycles: { componentDidUpdate: { onSetState: true } }`, for compatibility");if(typeof re<"u"&&U.componentDidUpdate&&U.componentDidUpdate.prevContext!==re)throw new TypeError("the legacy supportPrevContextArgumentOfComponentDidUpdate option should be matched by `lifecycles: { componentDidUpdate: { prevContext: true } }`, for compatibility")}function He(Ht){var Ye=Ht.options,Qe=Ye.lifecycles,pt=Qe===void 0?{}:Qe,re=Ye.enableComponentDidUpdateOnSetState,U=Ye.supportPrevContextArgumentOfComponentDidUpdate,q=typeof re<"u",pe=typeof U<"u",Fe=q||pe?(0,A.default)({},q&&{onSetState:!!re},pe&&{prevContext:!!U}):null,$e=pt.getDerivedStateFromProps,ft=$e?{hasShouldComponentUpdateBug:!!$e.hasShouldComponentUpdateBug}:!1;return(0,A.default)({},pt,{setState:(0,A.default)({},pt.setState),getChildContext:(0,A.default)({calledByRenderer:!0},pt.getChildContext)},Fe&&{componentDidUpdate:Fe},{getDerivedStateFromProps:ft})}function Xe(Ht){return Ht.nodeType==="host"?Ht:Ht.rendered}function at(Ht){if(Ht[he].length!==1)throw new Error("getRootNodeInternal(wrapper) can only be called when wrapper wraps one node");return Ht[he]!==Ht?Ht[fe][0]:Ht[he][te]}function bt(Ht,Ye){return(0,D.parentsOfNode)(Ye,at(Ht))}function xt(Ht,Ye){Array.isArray(Ye)?((0,S.privateSet)(Ht,te,Ye[0]),(0,S.privateSet)(Ht,Ce,Ye)):((0,S.privateSet)(Ht,te,Ye),(0,S.privateSet)(Ht,Ce,[Ye])),(0,S.privateSet)(Ht,"length",Ht[Ce].length)}function Vt(Ht,Ye,Qe,pt){return!(0,w.default)(Ht,Ye)||!(0,w.default)(Qe,pt)}function _t(Ht){return Ht&&Ht.isPureReactComponent}function Ci(Ht,Ye,Qe){var pt=Ht.instance,re=Ht.type,U=(0,S.displayNameOfNode)(Ht);if(C(re.childContextTypes)!=="object")return console.warn(String(U)+".getChildContext(): childContextTypes must be defined in order to use getChildContext()."),{};var q=pt.getChildContext();return Object.keys(q).forEach(function(pe){if(!(pe in re.childContextTypes))throw new Error(String(U)+'.getChildContext(): key "'+String(pe)+'" is not defined in childContextTypes.')}),typeof Qe.checkPropTypes=="function"&&Qe.checkPropTypes(re.childContextTypes,q,"child context",Ye),q}function Dt(Ht,Ye){return!(0,S.isCustomComponentElement)(Ht,Ye)||!Ht.type.prototype||typeof Ht.type.prototype.getChildContext!="function"?null:(0,S.spyMethod)(Ht.type.prototype,"getChildContext")}function Zi(Ht,Ye,Qe,pt,re){var U=Ye[ue];if(Ht.options.legacyContextMode==="parent")if(re)(0,S.privateSet)(Ye,We,re.getLastReturnValue()),re.restore();else if(typeof Qe.getChildContext=="function"){var q=[Ye[te]].concat(bt(Ye,Ye[te])),pe=Ci(pt,q,U);(0,S.privateSet)(Ye,We,pe)}else(0,S.privateSet)(Ye,We,null)}function ui(Ht,Ye){var Qe=Ht.type.getDerivedStateFromProps;if(typeof Qe=="function")var pt=Ht.instance,re=(0,S.spyMethod)(pt,"shouldComponentUpdate",function(q){return function(){function pe(){pt.state=Ye;for(var Fe=arguments.length,$e=Array(Fe),ft=0;ft1&&arguments[1]!==void 0?arguments[1]:{},Qe=(0,A.default)({},Ht[ye],Ye,{context:Ye.context||(0,A.default)({},Ht[ye].context,Ht[he][We])});return(0,S.privateSet)(Qe,At,Ht[he][At]),Qe}var un=function(){function Ht(Ye,Qe){var pt=this,re=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};j(this,Ht),Ge(re);var U=Bi(Ye,Qe,re,this),q=(0,H.default)(U),pe=He(q);if(Qe)(0,S.privateSet)(this,he,Qe),(0,S.privateSet)(this,oe,null),(0,S.privateSet)(this,ue,Qe[ue]),xt(this,Ye),(0,S.privateSet)(this,ye,Qe[ye]),(0,S.privateSet)(this,fe,Qe[Ce]),(0,S.privateSet)(this,At,null);else{if(!q.isValidElement(Ye))throw new TypeError("ShallowWrapper can only wrap valid elements");var Fe=pe.getChildContext.calledByRenderer?Dt(Ye,q):null;(0,S.privateSet)(this,he,this),(0,S.privateSet)(this,oe,Ye);var $e=q.createRenderer((0,A.default)({mode:"shallow"},U));(0,S.privateSet)(this,ue,$e);var ft=new Map(U[At]||[]);this[ue].render(Ye,U.context,{providerValues:ft});var ri=this[ue].getNode();xt(this,Xe(ri)),(0,S.privateSet)(this,ye,U),(0,S.privateSet)(this,At,ft);var bi=ri.instance;bi&&!U.disableLifecycleMethods&&(pe.componentDidUpdate.onSetState&&!bi[Ie]&&((0,S.privateSet)(bi,Ie,bi.setState),bi.setState=function(Ni){var Ti=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;return pt.setState.apply(pt,J(Ti==null?[Ni]:[Ni,Ti]))}),typeof bi.componentDidMount=="function"&&this[ue].batchedUpdates(function(){bi.componentDidMount()}),Zi(q,this,bi,ri,Fe))}}return s(Ht,[{key:"root",value:function(){function Ye(){return this[he]}return Ye}()},{key:"getNodeInternal",value:function(){function Ye(){if(this.length!==1)throw new Error("ShallowWrapper::getNode() can only be called when wrapping one node");return this[he]===this&&this.update(),this[te]}return Ye}()},{key:"getNodesInternal",value:function(){function Ye(){return this[he]===this&&this.length===1&&this.update(),this[Ce]}return Ye}()},{key:"getElement",value:function(){function Ye(){var Qe=this;return this.single("getElement",function(pt){return(0,H.default)(Qe[ye]).nodeToElement(pt)})}return Ye}()},{key:"getElements",value:function(){function Ye(){var Qe=this;return this.getNodesInternal().map(function(pt){return(0,H.default)(Qe[ye]).nodeToElement(pt)})}return Ye}()},{key:"getNode",value:function(){function Ye(){throw new Error("ShallowWrapper::getNode() is no longer supported. Use ShallowWrapper::getElement() instead")}return Ye}()},{key:"getNodes",value:function(){function Ye(){throw new Error("ShallowWrapper::getNodes() is no longer supported. Use ShallowWrapper::getElements() instead")}return Ye}()},{key:"instance",value:function(){function Ye(){if(this[he]!==this)throw new Error("ShallowWrapper::instance() can only be called on the root");return this[ue].getNode().instance}return Ye}()},{key:"getWrappingComponent",value:function(){function Ye(){if(this[he]!==this)throw new Error("ShallowWrapper::getWrappingComponent() can only be called on the root");if(!this[ye].wrappingComponent)throw new Error("ShallowWrapper::getWrappingComponent() can only be called on a wrapper that was originally passed a `wrappingComponent` option");return this[_e]}return Ye}()},{key:"update",value:function(){function Ye(){if(this[he]!==this)throw new Error("ShallowWrapper::update() can only be called on the root");if(this.length!==1)throw new Error("ShallowWrapper::update() can only be called when wrapping one node");return xt(this,Xe(this[ue].getNode())),this}return Ye}()},{key:"unmount",value:function(){function Ye(){return this[ue].unmount(),this[he][_e]&&this[he][_e].unmount(),this}return Ye}()},{key:"rerender",value:function(){function Ye(Qe,pt){var re=this,U=(0,H.default)(this[ye]);return this.single("rerender",function(){(0,S.withSetStateAllowed)(function(){var q=re[ue].getNode(),pe=q.instance||{},Fe=q.type||{},$e=pe.state,ft=pe.props||re[oe].props,ri=pe.context||re[ye].context,bi=pt||ri;pt&&(re[ye]=(0,A.default)({},re[ye],{context:bi})),re[ue].batchedUpdates(function(){var Ni=He(U),Ti=!0,Ki=void 0,Ng=void 0;if(!re[ye].disableLifecycleMethods&&pe){if(typeof pe.shouldComponentUpdate=="function"){var Sa=Ni.getDerivedStateFromProps;Sa&&Sa.hasShouldComponentUpdateBug&&ui(q,$e),Ki=(0,S.spyMethod)(pe,"shouldComponentUpdate")}Ni.getChildContext.calledByRenderer&&typeof pe.getChildContext=="function"&&(Ng=(0,S.spyMethod)(pe,"getChildContext"))}if(!Ki&&_t(pe)&&(Ti=Vt(ft,Qe,$e,pe.state)),Qe&&(re[oe]=(0,S.cloneElement)(U,re[oe],Qe)),re[ue].render(re[oe],bi,{providerValues:re[At]}),Ki&&(Ti=Ki.getLastReturnValue(),Ki.restore()),Ti&&!re[ye].disableLifecycleMethods&&pe)if(Zi(U,re,pe,q,Ng),Ni.getSnapshotBeforeUpdate){var Hl=void 0;typeof pe.getSnapshotBeforeUpdate=="function"&&(Hl=pe.getSnapshotBeforeUpdate(ft,$e)),Ni.componentDidUpdate&&typeof pe.componentDidUpdate=="function"&&(!$e||(0,w.default)($e,re.instance().state)||typeof Fe.getDerivedStateFromProps=="function")&&pe.componentDidUpdate(ft,$e,Hl)}else Ni.componentDidUpdate&&typeof pe.componentDidUpdate=="function"&&(Ni.componentDidUpdate.prevContext?pe.componentDidUpdate(ft,$e,ri):(!$e||(0,w.default)(re.instance().state,$e))&&pe.componentDidUpdate(ft,$e));else(0,w.default)(Qe,pe.props)||(pe.props=(Object.freeze||Object)((0,A.default)({},pe.props,Qe)));re.update()})})}),this}return Ye}()},{key:"setProps",value:function(){function Ye(Qe){var pt=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;if(this[he]!==this)throw new Error("ShallowWrapper::setProps() can only be called on the root");if(arguments.length>1&&typeof pt!="function")throw new TypeError("ReactWrapper::setProps() expects a function as its second argument");return this.rerender(Qe),pt&&pt(),this}return Ye}()},{key:"setState",value:function(){function Ye(Qe){var pt=this,re=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;if(this[he]!==this)throw new Error("ShallowWrapper::setState() can only be called on the root");if(this.instance()===null||this[ue].getNode().nodeType!=="class")throw new Error("ShallowWrapper::setState() can only be called on class components");if(arguments.length>1&&typeof re!="function")throw new TypeError("ReactWrapper::setState() expects a function as its second argument");return this.single("setState",function(){(0,S.withSetStateAllowed)(function(){var U=(0,H.default)(pt[ye]),q=He(U),pe=pt[ue].getNode(),Fe=pe.instance,$e=Fe.props,ft=Fe.state,ri=Fe.context,bi=typeof Qe=="function"?Qe.call(Fe,ft,$e):Qe,Ni=!q.setState.skipsComponentDidUpdateOnNullish||bi!=null,Ti=void 0,Ki=void 0,Ng=!0;if(!pt[ye].disableLifecycleMethods&&Fe){if(q.componentDidUpdate&&q.componentDidUpdate.onSetState&&typeof Fe.shouldComponentUpdate=="function"){var Sa=q.getDerivedStateFromProps;Sa&&Sa.hasShouldComponentUpdateBug&&ui(pe,Qe),Ti=(0,S.spyMethod)(Fe,"shouldComponentUpdate")}q.getChildContext.calledByRenderer&&typeof Fe.getChildContext=="function"&&(Ki=(0,S.spyMethod)(Fe,"getChildContext"))}if(!Ti&&_t(Fe)&&(Ng=Vt($e,Fe.props,ft,(0,A.default)({},ft,bi))),Fe[Ie]?Fe[Ie](bi):Fe.setState(bi),Ti&&(Ng=Ti.getLastReturnValue(),Ti.restore()),Ni&&Ng&&!pt[ye].disableLifecycleMethods&&(Zi(U,pt,Fe,pe,Ki),q.componentDidUpdate&&q.componentDidUpdate.onSetState))if(q.getSnapshotBeforeUpdate&&typeof Fe.getSnapshotBeforeUpdate=="function"){var Hl=Fe.getSnapshotBeforeUpdate($e,ft);typeof Fe.componentDidUpdate=="function"&&Fe.componentDidUpdate($e,ft,Hl)}else typeof Fe.componentDidUpdate=="function"&&(q.componentDidUpdate.prevContext?Fe.componentDidUpdate($e,ft,ri):Fe.componentDidUpdate($e,ft));pt.update(),re&&(U.invokeSetStateCallback?U.invokeSetStateCallback(Fe,re):re.call(Fe))})}),this}return Ye}()},{key:"setContext",value:function(){function Ye(Qe){if(this[he]!==this)throw new Error("ShallowWrapper::setContext() can only be called on the root");if(!this[ye].context)throw new Error("ShallowWrapper::setContext() can only be called on a wrapper that was originally passed a context option");return this.rerender(null,Qe)}return Ye}()},{key:"contains",value:function(){function Ye(Qe){var pt=(0,H.default)(this[ye]);if(!(0,S.isReactElementAlike)(Qe,pt))throw new Error("ShallowWrapper::contains() can only be called with a ReactElement (or an array of them), a string, or a number as an argument.");var re=Array.isArray(Qe)?function(U){return(0,S.containsChildrenSubArray)(S.nodeEqual,U,Qe.map(function(q){return pt.elementToNode(q)}))}:function(U){return(0,S.nodeEqual)(pt.elementToNode(Qe),U)};return Tt(this,re).length>0}return Ye}()},{key:"containsMatchingElement",value:function(){function Ye(Qe){var pt=(0,H.default)(this[ye]),re=pt.elementToNode(Qe),U=function(){function q(pe){return(0,S.nodeMatches)(re,pe,function(Fe,$e){return Fe<=$e})}return q}();return Tt(this,U).length>0}return Ye}()},{key:"containsAllMatchingElements",value:function(){function Ye(Qe){var pt=this;if(!Array.isArray(Qe))throw new TypeError("nodes should be an Array");return Qe.every(function(re){return pt.containsMatchingElement(re)})}return Ye}()},{key:"containsAnyMatchingElements",value:function(){function Ye(Qe){var pt=this;return Array.isArray(Qe)&&Qe.some(function(re){return pt.containsMatchingElement(re)})}return Ye}()},{key:"equals",value:function(){function Ye(Qe){var pt=this;return this.single("equals",function(){return(0,S.nodeEqual)(pt.getNodeInternal(),Qe)})}return Ye}()},{key:"matchesElement",value:function(){function Ye(Qe){var pt=this;return this.single("matchesElement",function(){var re=(0,H.default)(pt[ye]),U=re.elementToNode(Qe);return(0,S.nodeMatches)(U,pt.getNodeInternal(),function(q,pe){return q<=pe})})}return Ye}()},{key:"find",value:function(){function Ye(Qe){return this.wrap((0,M.reduceTreesBySelector)(Qe,this.getNodesInternal()))}return Ye}()},{key:"is",value:function(){function Ye(Qe){var pt=(0,M.buildPredicate)(Qe);return this.single("is",function(re){return pt(re)})}return Ye}()},{key:"isEmptyRender",value:function(){function Ye(){var Qe=this.getNodesInternal();return Qe.every(function(pt){return(0,S.isEmptyValue)(pt)})}return Ye}()},{key:"filterWhere",value:function(){function Ye(Qe){var pt=this;return Ne(this,function(re){return Qe(pt.wrap(re))})}return Ye}()},{key:"filter",value:function(){function Ye(Qe){var pt=(0,M.buildPredicate)(Qe);return Ne(this,pt)}return Ye}()},{key:"not",value:function(){function Ye(Qe){var pt=(0,M.buildPredicate)(Qe);return Ne(this,function(re){return!pt(re)})}return Ye}()},{key:"text",value:function(){function Ye(){return this.single("text",D.getTextFromNode)}return Ye}()},{key:"html",value:function(){function Ye(){var Qe=this;return this.single("html",function(pt){if(Qe.type()===null)return null;var re=(0,H.default)(Qe[ye]),U=re.createRenderer((0,A.default)({},Qe[ye],{mode:"string"}));return U.render(re.nodeToElement(pt))})}return Ye}()},{key:"render",value:function(){function Ye(){var Qe=this.html();return(0,S.loadCheerioRoot)(Qe)}return Ye}()},{key:"simulate",value:function(){function Ye(Qe){for(var pt=this,re=arguments.length,U=Array(re>1?re-1:0),q=1;q0?pt.first():this.findWhere(function(){return!1})}return Ye}()},{key:"shallow",value:function(){function Ye(){var Qe=this,pt=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return this.single("shallow",function(re){var U=pn(Qe,pt);return Qe.wrap((0,H.default)(Qe[ye]).nodeToElement(re),null,U)})}return Ye}()},{key:"prop",value:function(){function Ye(Qe){return this.props()[Qe]}return Ye}()},{key:"invoke",value:function(){function Ye(Qe){var pt=this;return this.single("invoke",function(){var re=pt.prop(Qe);if(typeof re!="function")throw new TypeError("ShallowWrapper::invoke() requires the name of a prop whose value is a function");return function(){var U=re.apply(void 0,arguments);return pt[he].update(),U}})}return Ye}()},{key:"renderProp",value:function(){function Ye(Qe){var pt=this,re=(0,H.default)(this[ye]);if(typeof re.wrap!="function")throw new RangeError("your adapter does not support `wrap`. Try upgrading it!");return this.single("renderProp",function(U){if(U.nodeType==="host")throw new TypeError("ShallowWrapper::renderProp() can only be called on custom components");if(typeof Qe!="string")throw new TypeError("ShallowWrapper::renderProp(): `propName` must be a string");var q=pt.props();if(!(0,Z.default)(q,Qe))throw new Error("ShallowWrapper::renderProp(): no prop called “"+String(Qe)+"“ found");var pe=q[Qe];if(typeof pe!="function")throw new TypeError("ShallowWrapper::renderProp(): expected prop “"+String(Qe)+"“ to contain a function, but it holds “"+(typeof pe>"u"?"undefined":C(pe))+"“");return function(){var Fe=pe.apply(void 0,arguments),$e=re.wrap(Fe);return pt.wrap($e,null,pt[ye])}})}return Ye}()},{key:"key",value:function(){function Ye(){return this.single("key",function(Qe){return Qe.key===void 0?null:Qe.key})}return Ye}()},{key:"type",value:function(){function Ye(){return this.single("type",function(Qe){return(0,S.typeOfNode)(Qe)})}return Ye}()},{key:"name",value:function(){function Ye(){var Qe=(0,H.default)(this[ye]);return this.single("name",function(pt){return Qe.displayNameOfNode?Qe.displayNameOfNode(pt):(0,S.displayNameOfNode)(pt)})}return Ye}()},{key:"hasClass",value:function(){function Ye(Qe){return typeof Qe=="string"&&Qe.indexOf(".")!==-1&&console.warn("It looks like you're calling `ShallowWrapper::hasClass()` with a CSS selector. hasClass() expects a class name, not a CSS selector."),this.single("hasClass",function(pt){return(0,D.hasClassName)(pt,Qe)})}return Ye}()},{key:"forEach",value:function(){function Ye(Qe){var pt=this;return this.getNodesInternal().forEach(function(re,U){return Qe.call(pt,pt.wrap(re),U)}),this}return Ye}()},{key:"map",value:function(){function Ye(Qe){var pt=this;return this.getNodesInternal().map(function(re,U){return Qe.call(pt,pt.wrap(re),U)})}return Ye}()},{key:"reduce",value:function(){function Ye(Qe){var pt=this,re=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;return arguments.length>1?this.getNodesInternal().reduce(function(U,q,pe){return Qe.call(pt,U,pt.wrap(q),pe)},re):this.getNodesInternal().reduce(function(U,q,pe){return Qe.call(pt,pe===1?pt.wrap(U):U,pt.wrap(q),pe)})}return Ye}()},{key:"reduceRight",value:function(){function Ye(Qe){var pt=this,re=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;return arguments.length>1?this.getNodesInternal().reduceRight(function(U,q,pe){return Qe.call(pt,U,pt.wrap(q),pe)},re):this.getNodesInternal().reduceRight(function(U,q,pe){return Qe.call(pt,pe===1?pt.wrap(U):U,pt.wrap(q),pe)})}return Ye}()},{key:"slice",value:function(){function Ye(Qe,pt){return this.wrap(this.getNodesInternal().slice(Qe,pt))}return Ye}()},{key:"some",value:function(){function Ye(Qe){if(this[he]===this)throw new Error("ShallowWrapper::some() can not be called on the root");var pt=(0,M.buildPredicate)(Qe);return this.getNodesInternal().some(pt)}return Ye}()},{key:"someWhere",value:function(){function Ye(Qe){var pt=this;return this.getNodesInternal().some(function(re,U){return Qe.call(pt,pt.wrap(re),U)})}return Ye}()},{key:"every",value:function(){function Ye(Qe){var pt=(0,M.buildPredicate)(Qe);return this.getNodesInternal().every(pt)}return Ye}()},{key:"everyWhere",value:function(){function Ye(Qe){var pt=this;return this.getNodesInternal().every(function(re,U){return Qe.call(pt,pt.wrap(re),U)})}return Ye}()},{key:"flatMap",value:function(){function Ye(Qe){var pt=this,re=this.getNodesInternal().map(function(q,pe){return Qe.call(pt,pt.wrap(q),pe)}),U=(0,h.default)(re,1);return this.wrap(U.filter(Boolean))}return Ye}()},{key:"findWhere",value:function(){function Ye(Qe){var pt=this;return Tt(this,function(re){var U=pt.wrap(re);return U.length>0&&Qe(U)})}return Ye}()},{key:"get",value:function(){function Ye(Qe){return this.getElements()[Qe]}return Ye}()},{key:"at",value:function(){function Ye(Qe){var pt=this.getNodesInternal();return Qe0&&arguments[0]!==void 0?arguments[0]:null;return arguments.length>0?this.find(Qe).exists():this.length>0}return Ye}()},{key:"single",value:function(){function Ye(Qe,pt){var re=typeof Qe=="string"?Qe:"unknown",U=typeof pt=="function"?pt:Qe;if(this.length!==1)throw new Error("Method “"+re+"” is meant to be run on 1 node. "+String(this.length)+" found instead.");return U.call(this,this.getNodeInternal())}return Ye}()},{key:"wrap",value:function(){function Ye(Qe){var pt=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this[he];if(Qe instanceof Ht)return Qe;for(var re=arguments.length,U=Array(re>2?re-2:0),q=2;q0&&arguments[0]!==void 0?arguments[0]:{};return(0,N.debugNodes)(this.getNodesInternal(),Qe)}return Ye}()},{key:"tap",value:function(){function Ye(Qe){return Qe(this),this}return Ye}()},{key:"dive",value:function(){function Ye(){var Qe=this,pt=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},re=(0,H.default)(this[ye]),U="dive";return this.single(U,function(q){if(q&&q.nodeType==="host")throw new TypeError("ShallowWrapper::"+U+"() can not be called on Host Components");var pe=(0,H.default)(Qe[ye]).nodeToElement(q);if(!(0,S.isCustomComponentElement)(pe,re))throw new TypeError("ShallowWrapper::"+U+"() can only be called on components");var Fe=pn(Qe,pt);return Qe.wrap(pe,null,Fe)})}return Ye}()},{key:"hostNodes",value:function(){function Ye(){return this.filterWhere(function(Qe){return typeof Qe.type()=="string"})}return Ye}()}]),Ht}();function On(Ht){var Ye=(0,H.default)(Ht[ye]),Qe=Ht[qe],pt=Qe[ue],re=pt.getNode(),U=Li(Ht,Ye),q=U.legacyContext,pe=U.providerValues,Fe=Qe[At];if(Qe.setContext((0,A.default)({},Ht[qe][ye].context,q)),Qe[At]=new Map([].concat(J(Fe),J(pe))),typeof Ye.isContextConsumer=="function"&&Ye.isContextConsumer(re.type)){var $e=re.type,ft=Ye.getProviderFromConsumer($e),ri=pe.get(ft),bi=Fe.get(ft);ri!==bi&&Qe.rerender()}}var Wg=function(Ht){P(Ye,Ht);function Ye(Qe,pt,re){j(this,Ye);var U=K(this,(Ye.__proto__||Object.getPrototypeOf(Ye)).call(this,Qe));return(0,S.privateSet)(U,qe,pt),(0,S.privateSet)(U,nt,re),U}return s(Ye,[{key:"rerender",value:function(){function Qe(){for(var pt,re=arguments.length,U=Array(re),q=0;q1&&arguments[1]!==void 0?arguments[1]:{},b=(0,I.default)(Z),w=b.createRenderer((0,s.default)({mode:"string"},Z)),S=w.render(y,Z.context);return(0,A.loadCheerioRoot)(S)}})(IHe);var c_t=t6,A_t=jB(c_t),u_t=W$,d_t=jB(u_t),h_t=IEe,f_t=jB(h_t),m_t=aHe,p_t=jB(m_t),b_t=sHe,y_t=jB(b_t),v_t=IHe,Z_t=jB(v_t),B_t=Db;function jB(g){return g&&g.__esModule?g:{default:g}}var G_t={render:Z_t.default,shallow:y_t.default,mount:p_t.default,ShallowWrapper:d_t.default,ReactWrapper:A_t.default,configure:B_t.merge,EnzymeAdapter:f_t.default};const N$=100,S_t=g=>{for(const a of g.iterateOverTracks())if(K0e(g,a.viewId,a.trackId).activeTransitions>0)return!0;return!1},lHe=(g,a)=>{S_t(g)?setTimeout(()=>{lHe(g,a)},N$):a()},k$=g=>{O2>0?setTimeout(()=>k$(g),N$):g()},w_t=g=>{for(const a of g.iterateOverTracks()){let s=AX(g,a.viewId,a.trackId);if(!(!a.track.server&&!a.track.tilesetUid&&!(a.track.data&&a.track.data.type==="divided")))if(a.track.data&&a.track.data.type==="divided"||a.track.server&&a.track.tilesetUid){if(s.originalTrack&&(s=s.originalTrack),!(s.tilesetInfo||s.chromInfo)||s.fetching&&s.fetching.size)return!0}else throw Error('"server" and "tilesetUid" belong together')}return!1},q5=(g,a)=>{w_t(g)?setTimeout(()=>{q5(g,a)},N$):a()},T_t=(g,a,s,C,I={})=>{const{style:A="width:800px; background-color: lightgreen;",bounded:d=!1,extendedDelay:h=!1}=I;a&&(a.unmount(),a.detach()),g&&globalThis.document.body.removeChild(g);const y=globalThis.document.createElement("div");globalThis.document.body.appendChild(y),y.setAttribute("style",A),y.setAttribute("id","simple-hg-component");const Z=G_t.mount(X.default.createElement(kD,{options:{bounded:d},viewConfig:s}),{attachTo:y});return Z.update(),k$(()=>{if(h){const b=()=>setTimeout(()=>{C()},1e3);q5(Z.instance(),b)}else q5(Z.instance(),C)}),[y,Z]},R_t={SVGTrack:$f,TiledPixiTrack:Jf,HorizontalGeneAnnotationsTrack:a4},V_t=(g,a,s)=>{const C=X.default.createRef();return $.default.render(X.default.createElement(kD,{ref:C,options:s||{},viewConfig:a}),g),C.current},CHe=(g,a,s)=>V_t(g,a,s).api;k.ChromosomeInfo=nu,k.HiGlassComponent=kD,k.HiGlassTrackComponent=fwe,k.getTrackObjectFromHGC=AX,k.mountHGComponent=T_t,k.schema=qj,k.trackViewer=hwe,k.tracks=R_t,k.version=uQ,k.viewer=CHe,k.waitForJsonComplete=k$,k.waitForTilesLoaded=q5,k.waitForTransitionsFinished=lHe,Object.defineProperties(k,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})})})(YK,YK.exports);var $gi=YK.exports,_Ie=(e,i,n)=>{if(!i.has(e))throw TypeError("Cannot "+n)},dn=(e,i,n)=>(_Ie(e,i,"read from private field"),n?n.call(e):i.get(e)),mr=(e,i,n)=>{if(i.has(e))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(e):i.set(e,n)},wo=(e,i,n,r)=>(_Ie(e,i,"write to private field"),r?r.call(e,n):i.set(e,n),n),Og=(e,i,n)=>(_Ie(e,i,"access private method"),n),W9,BH,GH,Fy,KK,Hre,NLe,PIe,kLe,_K,Wre,Nre,XLe,kre,xLe,Xre,DLe;const qgi="#/definitions/GoslingSpec",eoi="http://json-schema.org/draft-07/schema#",toi={Aggregate:{enum:["max","min","mean","bin","count"],type:"string"},Assembly:{anyOf:[{const:"hg38",type:"string"},{const:"hg19",type:"string"},{const:"hg18",type:"string"},{const:"hg17",type:"string"},{const:"hg16",type:"string"},{const:"mm10",type:"string"},{const:"mm9",type:"string"},{const:"unknown",type:"string"},{$ref:"#/definitions/ChromSizes"}]},AxisPosition:{enum:["none","top","bottom","left","right"],type:"string"},BamData:{additionalProperties:!1,description:"Binary Alignment Map (BAM) is the comprehensive raw data of genome sequencing; it consists of the lossless, compressed binary representation of the Sequence Alignment Map-files.",properties:{extractJunction:{description:"Determine whether to extract exon-to-exon junctions. __Default__: `false`",type:"boolean"},indexUrl:{description:"URL link to the index file of the BAM file",type:"string"},junctionMinCoverage:{description:"Determine the threshold of coverage when extracting exon-to-exon junctions. __Default__: `1`",type:"number"},loadMates:{description:"Load mates that are located in the same chromosome. __Default__: `false`",type:"boolean"},maxInsertSize:{description:"Determines the threshold of insert sizes for determining the structural variants. __Default__: `5000`",type:"number"},type:{const:"bam",type:"string"},url:{description:"URL link to the BAM data file",type:"string"}},required:["type","url","indexUrl"],type:"object"},BedData:{additionalProperties:!1,description:"BED file format",properties:{customFields:{description:"An array of strings, where each string is the name of a non-standard field in the BED file. If there are `n` custom fields, we assume that the last `n` columns of the BED file correspond to the custom fields.",items:{type:"string"},type:"array"},indexUrl:{description:"Specify the URL address of the data file index.",type:"string"},sampleLength:{description:"Specify the number of rows loaded from the URL.\n\n__Default:__ `1000`",type:"number"},type:{const:"bed",type:"string"},url:{description:"Specify the URL address of the data file.",type:"string"}},required:["type","url","indexUrl"],type:"object"},BeddbData:{additionalProperties:!1,description:"Regular BED or similar files can be pre-aggregated for the scalable data exploration. Find our more about this format at [HiGlass Docs](https://docs.higlass.io/data_preparation.html#bed-files).",properties:{exonIntervalFields:{description:"experimental",items:[{additionalProperties:!1,properties:{index:{type:"number"},name:{type:"string"}},required:["index","name"],type:"object"},{additionalProperties:!1,properties:{index:{type:"number"},name:{type:"string"}},required:["index","name"],type:"object"}],maxItems:2,minItems:2,type:"array"},genomicFields:{description:"Specify the name of genomic data fields.",items:{additionalProperties:!1,properties:{index:{type:"number"},name:{type:"string"}},required:["index","name"],type:"object"},type:"array"},type:{const:"beddb",type:"string"},url:{description:"Specify the URL address of the data file.",type:"string"},valueFields:{description:"Specify the column indexes, field names, and field types.",items:{additionalProperties:!1,properties:{index:{type:"number"},name:{type:"string"},type:{enum:["nominal","quantitative"],type:"string"}},required:["index","name","type"],type:"object"},type:"array"}},required:["type","url","genomicFields"],type:"object"},BigWigData:{additionalProperties:!1,properties:{aggregation:{$ref:"#/definitions/BinAggregate",description:'Determine aggregation function to apply within bins. __Default__: `"mean"`'},binSize:{description:"Binning the genomic interval in tiles (unit size: 256).",type:"number"},column:{description:'Assign a field name of the middle position of genomic intervals. __Default__: `"position"`',type:"string"},end:{description:'Assign a field name of the end position of genomic intervals. __Default__: `"end"`',type:"string"},start:{description:'Assign a field name of the start position of genomic intervals. __Default__: `"start"`',type:"string"},type:{const:"bigwig",type:"string"},url:{description:"Specify the URL address of the data file.",type:"string"},value:{description:'Assign a field name of quantitative values. __Default__: `"value"`',type:"string"}},required:["type","url"],type:"object"},BinAggregate:{enum:["mean","sum"],type:"string"},Channel:{anyOf:[{$ref:"#/definitions/ChannelDeep"},{$ref:"#/definitions/ChannelValue"}]},ChannelDeep:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/Y"},{$ref:"#/definitions/Row"},{$ref:"#/definitions/Color"},{$ref:"#/definitions/Size"},{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/Text"}]},ChannelValue:{additionalProperties:!1,properties:{value:{description:"Assign a constant value for a visual channel.",type:["number","string"]}},required:["value"],type:"object"},ChromSizes:{description:'Custom chromosome sizes, e.g., [["foo", 1000], ["bar", 300], ["baz", 240]]',items:{items:[{type:"string"},{type:"number"}],maxItems:2,minItems:2,type:"array"},type:"array"},Color:{additionalProperties:!1,properties:{domain:{$ref:"#/definitions/ValueExtent",description:"Values of the data"},field:{description:"Name of the data field",type:"string"},legend:{description:"Whether to display legend. __Default__: `false`",type:"boolean"},range:{$ref:"#/definitions/Range",description:"Determine the colors that should be bound to data value. Default properties are determined considering the field type."},scale:{enum:["linear","log"],type:"string"},scaleOffset:{description:"Whether to use offset of the domain proportionally. This is bound to brushes on the color legend. __Default__: `[0, 1]`",items:{type:"number"},maxItems:2,minItems:2,type:"array"},title:{description:"Title of the legend. __Default__: `undefined`",type:"string"},type:{description:"Specify the data type",enum:["quantitative","nominal"],type:"string"}},type:"object"},CoverageTransform:{additionalProperties:!1,description:"Aggregate rows and calculate coverage",properties:{endField:{type:"string"},groupField:{description:"The name of a nominal field to group rows by in prior to piling-up",type:"string"},newField:{type:"string"},startField:{type:"string"},type:{const:"coverage",type:"string"}},required:["type","startField","endField"],type:"object"},CsvData:{additionalProperties:!1,description:'Any small enough tabular data files, such as tsv, csv, BED, BEDPE, and GFF, can be loaded using "csv" data specification.',properties:{chromosomeField:{description:"Specify the name of chromosome data fields.",type:"string"},chromosomePrefix:{description:'Specify the chromosome prefix if chromosomes are denoted using a prefix besides "chr" or a number',type:"string"},genomicFields:{description:"Specify the name of genomic data fields.",items:{type:"string"},type:"array"},genomicFieldsToConvert:{description:"experimental",items:{additionalProperties:!1,properties:{chromosomeField:{type:"string"},genomicFields:{items:{type:"string"},type:"array"}},required:["chromosomeField","genomicFields"],type:"object"},type:"array"},headerNames:{description:"Specify the names of data fields if a CSV file does not contain a header.",items:{type:"string"},type:"array"},longToWideId:{description:"experimental",type:"string"},sampleLength:{description:"Specify the number of rows loaded from the URL.\n\n__Default:__ `1000`",type:"number"},separator:{description:"Specify file separator, __Default:__ ','",type:"string"},type:{const:"csv",type:"string"},url:{description:"Specify the URL address of the data file.",type:"string"}},required:["type","url"],type:"object"},DataDeep:{anyOf:[{$ref:"#/definitions/JsonData"},{$ref:"#/definitions/CsvData"},{$ref:"#/definitions/BedData"},{$ref:"#/definitions/BigWigData"},{$ref:"#/definitions/MultivecData"},{$ref:"#/definitions/BeddbData"},{$ref:"#/definitions/VectorData"},{$ref:"#/definitions/MatrixData"},{$ref:"#/definitions/BamData"},{$ref:"#/definitions/VcfData"}]},DataTrack:{additionalProperties:!1,description:"Partial specification of `BasicSingleTrack` to use default visual encoding predefined by data type.",properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},data:{$ref:"#/definitions/DataDeep"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},height:{description:"Specify the track height in pixels.",type:"number"},id:{type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},width:{description:"Specify the track width in pixels.",type:"number"},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["data"],type:"object"},DataTransform:{anyOf:[{$ref:"#/definitions/FilterTransform"},{$ref:"#/definitions/StrConcatTransform"},{$ref:"#/definitions/StrReplaceTransform"},{$ref:"#/definitions/LogTransform"},{$ref:"#/definitions/DisplaceTransform"},{$ref:"#/definitions/ExonSplitTransform"},{$ref:"#/definitions/GenomicLengthTransform"},{$ref:"#/definitions/SvTypeTransform"},{$ref:"#/definitions/CoverageTransform"},{$ref:"#/definitions/JsonParseTransform"}]},Datum:{additionalProperties:{type:["number","string"]},description:"Values in the form of JSON.",type:"object"},DisplaceTransform:{additionalProperties:!1,properties:{boundingBox:{additionalProperties:!1,properties:{endField:{description:"The name of a quantitative field that represents the end position.",type:"string"},groupField:{description:"The name of a nominal field to group rows by in prior to piling-up.",type:"string"},isPaddingBP:{description:"Whether to consider `padding` as the bp length.",type:"boolean"},padding:{description:"The padding around visual lements. Either px or bp",type:"number"},startField:{description:"The name of a quantitative field that represents the start position.",type:"string"}},required:["startField","endField"],type:"object"},maxRows:{description:"Specify maximum rows to be generated (default has no limit).",type:"number"},method:{$ref:"#/definitions/DisplacementType",description:"A string that specifies the type of displacement."},newField:{type:"string"},type:{const:"displace",type:"string"}},required:["type","boundingBox","method","newField"],type:"object"},Displacement:{additionalProperties:!1,properties:{padding:{type:"number"},type:{$ref:"#/definitions/DisplacementType"}},required:["type"],type:"object"},DisplacementType:{enum:["pile","spread"],type:"string"},DomainChr:{additionalProperties:!1,properties:{chromosome:{type:"string"}},required:["chromosome"],type:"object"},DomainChrInterval:{additionalProperties:!1,properties:{chromosome:{description:"If specified, only showing a certain interval in a chromosome.",type:"string"},interval:{items:{type:"number"},maxItems:2,minItems:2,type:"array"}},required:["chromosome","interval"],type:"object"},DomainInterval:{additionalProperties:!1,properties:{interval:{description:"Show a certain interval within entire chromosome",items:{type:"number"},maxItems:2,minItems:2,type:"array"}},required:["interval"],type:"object"},EventStyle:{additionalProperties:!1,description:"The styles defined here will be applied to the target marks of mouse events, such as a point mark after the user clicks on it.",properties:{arrange:{description:"Show event effects behind or in front of marks.",enum:["behind","front"],type:"string"},color:{description:"color of the marks when mouse events are triggered",type:"string"},opacity:{description:"opacity of the marks when mouse events are triggered",type:"number"},stroke:{description:"stroke color of the marks when mouse events are triggered",type:"string"},strokeOpacity:{type:"number"},strokeWidth:{description:"stroke width of the marks when mouse events are triggered",type:"number"}},type:"object"},ExonSplitTransform:{additionalProperties:!1,properties:{fields:{items:{additionalProperties:!1,properties:{chrField:{type:"string"},field:{type:"string"},newField:{type:"string"},type:{$ref:"#/definitions/FieldType"}},required:["field","type","newField","chrField"],type:"object"},type:"array"},flag:{additionalProperties:!1,properties:{field:{type:"string"},value:{type:["number","string"]}},required:["field","value"],type:"object"},separator:{type:"string"},type:{const:"exonSplit",type:"string"}},required:["type","separator","flag","fields"],type:"object"},FieldType:{enum:["genomic","nominal","quantitative"],type:"string"},FilterTransform:{anyOf:[{$ref:"#/definitions/OneOfFilter"},{$ref:"#/definitions/RangeFilter"},{$ref:"#/definitions/IncludeFilter"}]},GenomicDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}]},GenomicLengthTransform:{additionalProperties:!1,description:"Calculate genomic length using two genomic fields",properties:{endField:{type:"string"},newField:{type:"string"},startField:{type:"string"},type:{const:"genomicLength",type:"string"}},required:["type","startField","endField","newField"],type:"object"},GoslingSpec:{anyOf:[{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{const:"overlay",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},description:{type:"string"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},responsiveSize:{$ref:"#/definitions/ResponsiveSize",description:"Determine whether to make the size of `GoslingComponent` bound to its parent element. __Default__: `false`"},responsiveSpec:{items:{additionalProperties:!1,properties:{selectivity:{items:{$ref:"#/definitions/SelectivityCondition"},type:"array"},spec:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{enum:["overlay","stack"],type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{anyOf:[{items:{$ref:"#/definitions/PartialTrack"},type:"array"},{items:{anyOf:[{$ref:"#/definitions/PartialTrack"},{$ref:"#/definitions/OverlaidTracks"}]},type:"array"}]},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},type:"object"}},required:["spec","selectivity"],type:"object"},type:"array"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{items:{$ref:"#/definitions/PartialTrack"},type:"array"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["alignment","tracks"],type:"object"},{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{const:"stack",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},description:{type:"string"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},responsiveSize:{$ref:"#/definitions/ResponsiveSize",description:"Determine whether to make the size of `GoslingComponent` bound to its parent element. __Default__: `false`"},responsiveSpec:{items:{additionalProperties:!1,properties:{selectivity:{items:{$ref:"#/definitions/SelectivityCondition"},type:"array"},spec:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{enum:["overlay","stack"],type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{anyOf:[{items:{$ref:"#/definitions/PartialTrack"},type:"array"},{items:{anyOf:[{$ref:"#/definitions/PartialTrack"},{$ref:"#/definitions/OverlaidTracks"}]},type:"array"}]},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},type:"object"}},required:["spec","selectivity"],type:"object"},type:"array"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{items:{anyOf:[{$ref:"#/definitions/PartialTrack"},{$ref:"#/definitions/OverlaidTracks"}]},type:"array"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["tracks"],type:"object"},{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},description:{type:"string"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},responsiveSize:{$ref:"#/definitions/ResponsiveSize",description:"Determine whether to make the size of `GoslingComponent` bound to its parent element. __Default__: `false`"},responsiveSpec:{items:{additionalProperties:!1,properties:{selectivity:{items:{$ref:"#/definitions/SelectivityCondition"},type:"array"},spec:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{enum:["overlay","stack"],type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{anyOf:[{items:{$ref:"#/definitions/PartialTrack"},type:"array"},{items:{anyOf:[{$ref:"#/definitions/PartialTrack"},{$ref:"#/definitions/OverlaidTracks"}]},type:"array"}]},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},type:"object"}},required:["spec","selectivity"],type:"object"},type:"array"},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},title:{type:"string"},tracks:{items:{$ref:"#/definitions/Track"},type:"array"},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["tracks"],type:"object"},{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},arrangement:{description:"Specify how multiple views are arranged.",enum:["parallel","serial","horizontal","vertical"],type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},description:{type:"string"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},responsiveSize:{$ref:"#/definitions/ResponsiveSize",description:"Determine whether to make the size of `GoslingComponent` bound to its parent element. __Default__: `false`"},responsiveSpec:{items:{additionalProperties:!1,properties:{selectivity:{items:{$ref:"#/definitions/SelectivityCondition"},type:"array"},spec:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},arrangement:{description:"Specify how multiple views are arranged.",enum:["parallel","serial","horizontal","vertical"],type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},views:{description:"An array of view specifications",items:{anyOf:[{$ref:"#/definitions/SingleView"},{$ref:"#/definitions/MultipleViews"}]},type:"array"},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},type:"object"}},required:["spec","selectivity"],type:"object"},type:"array"},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},title:{type:"string"},views:{description:"An array of view specifications",items:{anyOf:[{$ref:"#/definitions/SingleView"},{$ref:"#/definitions/MultipleViews"}]},type:"array"},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["views"],type:"object"}]},IncludeFilter:{additionalProperties:!1,properties:{field:{description:"A filter is applied based on the values of the specified data field",type:"string"},include:{description:"Check whether the value includes a substring.",type:"string"},not:{description:'when `{"not": true}`, apply a NOT logical operation to the filter.\n\n__Default:__ `false`',type:"boolean"},type:{const:"filter",type:"string"}},required:["field","include","type"],type:"object"},JsonData:{additionalProperties:!1,description:"The JSON data format allows users to include data directly in the Gosling's JSON specification.",properties:{chromosomeField:{description:"Specify the name of chromosome data fields.",type:"string"},genomicFields:{description:"Specify the name of genomic data fields.",items:{type:"string"},type:"array"},genomicFieldsToConvert:{description:"experimental",items:{additionalProperties:!1,properties:{chromosomeField:{type:"string"},genomicFields:{items:{type:"string"},type:"array"}},required:["chromosomeField","genomicFields"],type:"object"},type:"array"},sampleLength:{description:"Specify the number of rows loaded from the URL.\n\n__Default:__ `1000`",type:"number"},type:{const:"json",description:"Define data type.",type:"string"},values:{description:"Values in the form of JSON.",items:{$ref:"#/definitions/Datum"},type:"array"}},required:["type","values"],type:"object"},JsonParseTransform:{additionalProperties:!1,description:"Parse JSON Object Array and append vertically",properties:{baseGenomicField:{description:"Base genomic position when parsing relative position.",type:"string"},field:{description:"The field that contains the JSON object array.",type:"string"},genomicField:{description:"Relative genomic position to parse.",type:"string"},genomicLengthField:{description:"Length of genomic interval.",type:"string"},type:{const:"subjson",type:"string"}},required:["type","field","baseGenomicField","genomicField","genomicLengthField"],type:"object"},Layout:{enum:["linear","circular"],type:"string"},LogBase:{anyOf:[{type:"number"},{const:"e",type:"string"}]},LogTransform:{additionalProperties:!1,properties:{base:{$ref:"#/definitions/LogBase",description:"If not specified, 10 is used."},field:{type:"string"},newField:{description:"If specified, store transformed values in a new field.",type:"string"},type:{const:"log",type:"string"}},required:["type","field"],type:"object"},LogicalOperation:{enum:["less-than","lt","LT","greater-than","gt","GT","less-than-or-equal-to","ltet","LTET","greater-than-or-equal-to","gtet","GTET"],type:"string"},Mark:{enum:["point","line","area","bar","rect","text","withinLink","betweenLink","rule","triangleLeft","triangleRight","triangleBottom","brush","header"],type:"string"},MatrixData:{additionalProperties:!1,properties:{binSize:{description:"Determine the number of nearby cells to aggregate. __Default__: `1`",type:"number"},column:{description:"The name of the first genomic field. __Default__: `x`",type:"string"},row:{description:"The name of the first genomic field. __Default__: `y`",type:"string"},type:{const:"matrix",type:"string"},url:{description:"URL link to the matrix data file",type:"string"},value:{description:"The name of the value field. __Default__: `value`",type:"string"}},required:["type","url"],type:"object"},MouseEventsDeep:{additionalProperties:!1,description:"Options for determining mouse events in detail, e.g., turning on specific events only",properties:{click:{description:"Whether to enable click events.",type:"boolean"},enableMouseOverOnMultipleMarks:{description:"Determine whether all marks underneath the mouse point should be affected by mouse over. __Default__: `false`",type:"boolean"},groupMarksByField:{description:"Group marks using keys in a data field. This affects how a set of marks are highlighted/selected by interaction. __Default__: `undefined`",type:"string"},mouseOver:{description:"Whether to enable mouseover events.",type:"boolean"},rangeSelect:{description:"Whether to send range selection events.",type:"boolean"}},type:"object"},MultipleViews:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},arrangement:{description:"Specify how multiple views are arranged.",enum:["parallel","serial","horizontal","vertical"],type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},views:{description:"An array of view specifications",items:{anyOf:[{$ref:"#/definitions/SingleView"},{$ref:"#/definitions/MultipleViews"}]},type:"array"},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["views"],type:"object"},MultivecData:{additionalProperties:!1,description:'Two-dimensional quantitative values, one axis for genomic coordinate and the other for different samples, can be converted into HiGlass\' `"multivec"` data. For example, multiple BigWig files can be converted into a single multivec file. You can also convert sequence data (FASTA) into this format where rows will be different nucleotide bases (e.g., A, T, G, C) and quantitative values represent the frequency. Find out more about this format at [HiGlass Docs](https://docs.higlass.io/data_preparation.html#multivec-files).',properties:{aggregation:{$ref:"#/definitions/BinAggregate",description:'Determine aggregation function to apply within bins. __Default__: `"mean"`'},binSize:{description:"Binning the genomic interval in tiles (unit size: 256).",type:"number"},categories:{description:"assign names of individual samples.",items:{type:"string"},type:"array"},column:{description:'Assign a field name of the middle position of genomic intervals. __Default__: `"position"`',type:"string"},end:{description:'Assign a field name of the end position of genomic intervals. __Default__: `"end"`',type:"string"},row:{description:'Assign a field name of samples. __Default__: `"category"`',type:"string"},start:{description:'Assign a field name of the start position of genomic intervals. __Default__: `"start"`',type:"string"},type:{const:"multivec",type:"string"},url:{description:"Specify the URL address of the data file.",type:"string"},value:{description:'Assign a field name of quantitative values. __Default__: `"value"`',type:"string"}},required:["type","url"],type:"object"},OneOfFilter:{additionalProperties:!1,properties:{field:{description:"A filter is applied based on the values of the specified data field",type:"string"},not:{description:'when `{"not": true}`, apply a NOT logical operation to the filter.\n\n__Default:__ `false`',type:"boolean"},oneOf:{description:"Check whether the value is an element in the provided list.",items:{type:["string","number","null"]},type:"array"},type:{const:"filter",type:"string"}},required:["field","oneOf","type"],type:"object"},Opacity:{additionalProperties:!1,properties:{domain:{$ref:"#/definitions/ValueExtent",description:"Values of the data"},field:{description:"Name of the data field",type:"string"},range:{$ref:"#/definitions/ValueExtent",description:"Ranges of visual channel values"},type:{description:"Specify the data type",enum:["quantitative","nominal"],type:"string"}},type:"object"},Orientation:{enum:["horizontal","vertical"],type:"string"},OverlaidTrack:{additionalProperties:!1,description:"Superposing multiple tracks.",properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlay:{items:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"}},type:"object"},flipY:{type:"boolean"},id:{type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},type:"object"},type:"array"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["overlay"],type:"object"},OverlaidTracks:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{const:"overlay",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{items:{$ref:"#/definitions/PartialTrack"},type:"array"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["alignment","tracks"],type:"object"},PartialTrack:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},encoding:{additionalProperties:{$ref:"#/definitions/Channel"},type:"object"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlay:{items:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"}},type:"object"},flipY:{type:"boolean"},id:{type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},type:"object"},type:"array"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},template:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},type:"object"},PredefinedColors:{enum:["viridis","grey","spectral","warm","cividis","bupu","rdbu","hot","pink"],type:"string"},Range:{anyOf:[{$ref:"#/definitions/ValueExtent"},{$ref:"#/definitions/PredefinedColors"}]},RangeFilter:{additionalProperties:!1,properties:{field:{description:"A filter is applied based on the values of the specified data field",type:"string"},inRange:{description:"Check whether the value is in a number range.",items:{type:"number"},type:"array"},not:{description:'when `{"not": true}`, apply a NOT logical operation to the filter.\n\n__Default:__ `false`',type:"boolean"},type:{const:"filter",type:"string"}},required:["field","inRange","type"],type:"object"},ResponsiveSize:{anyOf:[{type:"boolean"},{additionalProperties:!1,properties:{height:{type:"boolean"},width:{type:"boolean"}},type:"object"}]},Row:{additionalProperties:!1,properties:{clip:{description:"Clip row when the actual y value exceeds the max value of the y scale. Used only for bar marks at the moment. __Default__: `true`",type:"boolean"},domain:{$ref:"#/definitions/ValueExtent",description:"Values of the data"},field:{description:"Name of the data field",type:"string"},grid:{description:"Whether to display grid. __Default__: `false`",type:"boolean"},legend:{description:"Whether to display legend. __Default__: `false`",type:"boolean"},padding:{description:"Determines the size of inner white spaces on the top and bottom of individiual rows. __Default__: `0`",type:"number"},range:{$ref:"#/definitions/ValueExtent",description:"Determine the start and end position of rendering area of this track along vertical axis. __Default__: `[0, height]`"},type:{const:"nominal",description:"Specify the data type",type:"string"}},type:"object"},SelectivityCondition:{additionalProperties:!1,properties:{measure:{enum:["width","height","aspectRatio"],type:"string"},operation:{$ref:"#/definitions/LogicalOperation"},target:{description:"Does the condition applied to the visualization itself or its container? __Default__: `'self'`",enum:["self","container"],type:"string"},threshold:{description:"Threshold in the unit of pixels.",type:"number"}},required:["operation","measure","threshold"],type:"object"},SingleTrack:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["data","mark"],type:"object"},SingleView:{anyOf:[{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{const:"overlay",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},responsiveSpec:{items:{additionalProperties:!1,properties:{selectivity:{items:{$ref:"#/definitions/SelectivityCondition"},type:"array"},spec:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{enum:["overlay","stack"],type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{anyOf:[{items:{$ref:"#/definitions/PartialTrack"},type:"array"},{items:{anyOf:[{$ref:"#/definitions/PartialTrack"},{$ref:"#/definitions/OverlaidTracks"}]},type:"array"}]},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},type:"object"}},required:["spec","selectivity"],type:"object"},type:"array"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{items:{$ref:"#/definitions/PartialTrack"},type:"array"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["alignment","tracks"],type:"object"},{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{const:"stack",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},responsiveSpec:{items:{additionalProperties:!1,properties:{selectivity:{items:{$ref:"#/definitions/SelectivityCondition"},type:"array"},spec:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{enum:["overlay","stack"],type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{anyOf:[{items:{$ref:"#/definitions/PartialTrack"},type:"array"},{items:{anyOf:[{$ref:"#/definitions/PartialTrack"},{$ref:"#/definitions/OverlaidTracks"}]},type:"array"}]},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},type:"object"}},required:["spec","selectivity"],type:"object"},type:"array"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{items:{anyOf:[{$ref:"#/definitions/PartialTrack"},{$ref:"#/definitions/OverlaidTracks"}]},type:"array"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["tracks"],type:"object"},{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},responsiveSpec:{items:{additionalProperties:!1,properties:{selectivity:{items:{$ref:"#/definitions/SelectivityCondition"},type:"array"},spec:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{enum:["overlay","stack"],type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{anyOf:[{items:{$ref:"#/definitions/PartialTrack"},type:"array"},{items:{anyOf:[{$ref:"#/definitions/PartialTrack"},{$ref:"#/definitions/OverlaidTracks"}]},type:"array"}]},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},type:"object"}},required:["spec","selectivity"],type:"object"},type:"array"},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},tracks:{items:{$ref:"#/definitions/Track"},type:"array"},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["tracks"],type:"object"}]},Size:{additionalProperties:!1,properties:{domain:{$ref:"#/definitions/ValueExtent",description:"Values of the data"},field:{description:"Name of the data field",type:"string"},legend:{description:"not supported: Whether to display legend. __Default__: `false`",type:"boolean"},range:{$ref:"#/definitions/ValueExtent",description:"Ranges of visual channel values"},type:{description:"Specify the data type",enum:["quantitative","nominal"],type:"string"}},type:"object"},SizeVisibilityCondition:{additionalProperties:!1,properties:{conditionPadding:{description:"Specify the buffer size (in pixel) of width or height when calculating the visibility.\n\n__Default__: `0`",type:"number"},measure:{description:"Specify which aspect of the `target` will be compared to the `threshold`.",enum:["width","height"],type:"string"},operation:{$ref:"#/definitions/LogicalOperation",description:`A string that specifies the logical operation to conduct between \`threshold\` and the \`measure\` of \`target\`. Support - -- greater than : "greater-than", "gt", "GT" - -- less than : "less-than", "lt", "LT" - -- greater than or equal to : "greater-than-or-equal-to", "gtet", "GTET" - -- less than or equal to : "less-than-or-equal-to", "ltet", "LTET"`},target:{description:"Target specifies the object that you want to compare with the threshold.",enum:["track","mark"],type:"string"},threshold:{anyOf:[{type:"number"},{const:"|xe-x|",type:"string"}],description:'Specify the threshold as one of:\n\n- A number representing a fixed threshold in the unit of pixels;\n\n- `"|xe-x|"`, using the distance between `xe` and `x` as threshold'},transitionPadding:{description:"Specify the buffer size (in pixel) of width or height for smooth transition.\n\n__Default__: `0`",type:"number"}},required:["measure","operation","target","threshold"],type:"object"},StrConcatTransform:{additionalProperties:!1,properties:{fields:{items:{type:"string"},type:"array"},newField:{type:"string"},separator:{type:"string"},type:{const:"concat",type:"string"}},required:["type","fields","newField","separator"],type:"object"},StrReplaceTransform:{additionalProperties:!1,properties:{field:{type:"string"},newField:{type:"string"},replace:{items:{additionalProperties:!1,properties:{from:{type:"string"},to:{type:"string"}},required:["from","to"],type:"object"},type:"array"},type:{const:"replace",type:"string"}},required:["type","field","newField","replace"],type:"object"},Stroke:{additionalProperties:!1,properties:{domain:{$ref:"#/definitions/ValueExtent",description:"Values of the data"},field:{description:"Name of the data field",type:"string"},legend:{description:"Whether to display legend. __Default__: `false`",type:"boolean"},range:{$ref:"#/definitions/Range",description:"Ranges of visual channel values"},scaleOffset:{description:"Whether to use offset of the domain proportionally. This is bound to brushes on the color legend. __Default__: `[0, 1]`",items:{type:"number"},maxItems:2,minItems:2,type:"array"},title:{description:"Title of the legend. __Default__: `undefined`",type:"string"},type:{description:"Specify the data type",enum:["quantitative","nominal"],type:"string"}},type:"object"},StrokeWidth:{additionalProperties:!1,properties:{domain:{$ref:"#/definitions/ValueExtent",description:"Values of the data"},field:{description:"Name of the data field",type:"string"},range:{$ref:"#/definitions/ValueExtent",description:"Ranges of visual channel values"},type:{description:"Specify the data type",enum:["quantitative","nominal"],type:"string"}},type:"object"},Style:{additionalProperties:!1,properties:{align:{description:"Specify the alignment of marks. This property is currently only supported for `triangle` marks.",enum:["left","right"],type:"string"},background:{type:"string"},backgroundOpacity:{type:"number"},brush:{additionalProperties:!1,description:"Customize the style of the brush mark in the `rangeSelect` mouse event.",properties:{color:{description:"color of the marks when mouse events are triggered",type:"string"},opacity:{description:"opacity of the marks when mouse events are triggered",type:"number"},stroke:{description:"stroke color of the marks when mouse events are triggered",type:"string"},strokeOpacity:{type:"number"},strokeWidth:{description:"stroke width of the marks when mouse events are triggered",type:"number"}},type:"object"},curve:{description:"Specify the curve of `rule` marks.",enum:["top","bottom","left","right"],type:"string"},dashed:{description:"Specify the pattern of dashes and gaps for `rule` marks.",items:{type:"number"},maxItems:2,minItems:2,type:"array"},dx:{description:"Offset the position of marks in x direction. This property is currently only supported for `text` marks",type:"number"},dy:{description:"Offset the position of marks in y direction. This property is currently only supported for `text` marks.",type:"number"},enableSmoothPath:{description:"Whether to enable smooth paths when drawing curves.\n\n__Default__: `false`",type:"boolean"},inlineLegend:{description:"Specify whether to show legend in a single horizontal line?",type:"boolean"},legendTitle:{description:"If defined, show legend title on the top or left",type:"string"},linePattern:{additionalProperties:!1,description:"Specify the pattern of dashes and gaps for `rule` marks.",properties:{size:{type:"number"},type:{enum:["triangleLeft","triangleRight"],type:"string"}},required:["type","size"],type:"object"},linkConnectionType:{description:'Specify the connetion type of `betweenLink` marks.\n\n__Default__: `"corner"`',enum:["straight","curve","corner"],type:"string"},linkMinHeight:{description:"The minimum height of `withinLink` and `betweenLink` marks. Unit is a percentagle. __Default__: `0.5`",type:"number"},linkStyle:{description:"The style of `withinLink` and `betweenLink` marks. __Default__: `'circular'` `'elliptical'` will be used as a default option.",enum:["elliptical","circular","straight"],type:"string"},matrixExtent:{description:'Determine to show only one side of the diagonal in a HiGlass matrix. __Default__: `"full"`',enum:["full","upper-right","lower-left"],type:"string"},mouseOver:{$ref:"#/definitions/EventStyle",description:"Customize visual effects of `mouseOver` events on marks."},outline:{type:"string"},outlineWidth:{type:"number"},select:{$ref:"#/definitions/EventStyle",description:"Customize visual effects of `rangeSelect` events on marks ."},textAnchor:{description:"Specify the alignment of `text` marks to a given point.",enum:["start","middle","end"],type:"string"},textFontSize:{description:"Specify the font size of `text` marks. Can also be specified using the `size` channel option of `text` marks.",type:"number"},textFontWeight:{description:"Specify the font weight of `text` marks.",enum:["bold","normal"],type:"string"},textStroke:{description:"Specify the stroke of `text` marks. Can also be specified using the `stroke` channel option of `text` marks.",type:"string"},textStrokeWidth:{description:"Specify the stroke width of `text` marks. Can also be specified using the `strokeWidth` channel option of `text` marks.",type:"number"},withinLinkVerticalLines:{description:"Whether to show vertical lines that connect to the baseline (axis) when `y` and `ye` are both used. __Default__: `false`",type:"boolean"}},type:"object"},SvTypeTransform:{additionalProperties:!1,properties:{firstBp:{additionalProperties:!1,description:"Based on the BEDPE, infer SV types. SV types are specified as one of the following strings: DUP, TRA, DEL, t2tINV, h2hINV.",properties:{chrField:{type:"string"},posField:{type:"string"},strandField:{type:"string"}},required:["chrField","posField","strandField"],type:"object"},newField:{type:"string"},secondBp:{additionalProperties:!1,description:"Based on the BEDPE, infer SV types. SV types are specified as one of the following strings: DUP, TRA, DEL, t2tINV, h2hINV.",properties:{chrField:{type:"string"},posField:{type:"string"},strandField:{type:"string"}},required:["chrField","posField","strandField"],type:"object"},type:{const:"svType",type:"string"}},required:["type","firstBp","secondBp","newField"],type:"object"},TemplateTrack:{additionalProperties:!1,description:"Template specification that will be internally converted into `SingleTrack` for rendering.",properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},data:{$ref:"#/definitions/DataDeep"},encoding:{additionalProperties:{$ref:"#/definitions/Channel"},type:"object"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},height:{description:"Specify the track height in pixels.",type:"number"},id:{type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},template:{type:"string"},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},width:{description:"Specify the track width in pixels.",type:"number"},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["template","data"],type:"object"},Text:{additionalProperties:!1,properties:{domain:{description:"Values of the data",items:{type:"string"},type:"array"},field:{description:"Name of the data field",type:"string"},range:{description:"Ranges of visual channel values",items:{type:"string"},type:"array"},type:{description:"Specify the data type",enum:["quantitative","nominal"],type:"string"}},type:"object"},Tooltip:{additionalProperties:!1,properties:{alt:{description:"Name of the data field for showing in the tooltip. Will use the field name if not specified.",type:"string"},field:{description:"Specifiy a data field whose value will show in the tooltip.",type:"string"},format:{description:"format of the data value.",type:"string"},type:{$ref:"#/definitions/FieldType",description:"Type of the data field."}},required:["field","type"],type:"object"},Track:{anyOf:[{$ref:"#/definitions/SingleTrack"},{$ref:"#/definitions/OverlaidTrack"},{$ref:"#/definitions/DataTrack"},{$ref:"#/definitions/TemplateTrack"}]},ValueExtent:{anyOf:[{items:{type:"string"},type:"array"},{items:{type:"number"},type:"array"}]},VcfData:{additionalProperties:!1,description:"The Variant Call Format (VCF).",properties:{indexUrl:{description:"URL link to the tabix index file",type:"string"},sampleLength:{description:"The maximum number of rows to be loaded from the URL. __Default:__ `1000`",type:"number"},type:{const:"vcf",type:"string"},url:{description:"URL link to the VCF file",type:"string"}},required:["type","url","indexUrl"],type:"object"},VectorData:{additionalProperties:!1,description:'One-dimensional quantitative values along genomic position (e.g., bigwig) can be converted into HiGlass\' `"vector"` format data. Find out more about this format at [HiGlass Docs](https://docs.higlass.io/data_preparation.html#bigwig-files).',properties:{aggregation:{$ref:"#/definitions/BinAggregate",description:'Determine aggregation function to apply within bins. __Default__: `"mean"`'},binSize:{description:"Binning the genomic interval in tiles (unit size: 256).",type:"number"},column:{description:'Assign a field name of the middle position of genomic intervals. __Default__: `"position"`',type:"string"},end:{description:'Assign a field name of the end position of genomic intervals. __Default__: `"end"`',type:"string"},start:{description:'Assign a field name of the start position of genomic intervals. __Default__: `"start"`',type:"string"},type:{const:"vector",type:"string"},url:{description:"Specify the URL address of the data file.",type:"string"},value:{description:'Assign a field name of quantitative values. __Default__: `"value"`',type:"string"}},required:["type","url"],type:"object"},VisibilityCondition:{anyOf:[{$ref:"#/definitions/SizeVisibilityCondition"},{$ref:"#/definitions/ZoomLevelVisibilityCondition"}]},X:{additionalProperties:!1,properties:{aggregate:{$ref:"#/definitions/Aggregate",description:"Specify how to aggregate data. __Default__: `undefined`"},axis:{$ref:"#/definitions/AxisPosition",description:"Specify where should the axis be put"},domain:{$ref:"#/definitions/GenomicDomain",description:"Values of the data"},field:{description:"Name of the data field.",type:"string"},grid:{description:"Whether to display grid. __Default__: `false`",type:"boolean"},legend:{description:"Whether to display legend. __Default__: `false`",type:"boolean"},linkingId:{description:"Users need to assign a unique linkingId for [linking views](/docs/user-interaction#linking-views) and [Brushing and Linking](/docs/user-interaction#brushing-and-linking)",type:"string"},range:{$ref:"#/definitions/ValueExtent",description:"Values of the visual channel."},type:{const:"genomic",description:"Specify the data type.",type:"string"}},type:"object"},Y:{additionalProperties:!1,properties:{aggregate:{$ref:"#/definitions/Aggregate",description:"Specify how to aggregate data. __Default__: `undefined`"},axis:{$ref:"#/definitions/AxisPosition",description:"Specify where should the axis be put"},baseline:{description:"Custom baseline of the y-axis. __Default__: `0`",type:["string","number"]},domain:{anyOf:[{$ref:"#/definitions/ValueExtent"},{$ref:"#/definitions/GenomicDomain"}],description:"Values of the data"},field:{description:"Name of the data field.",type:"string"},flip:{description:"Whether to flip the y-axis. This is done by inverting the `range` property. __Default__: `false`",type:"boolean"},grid:{description:"Whether to display grid. __Default__: `false`",type:"boolean"},legend:{description:"Whether to display legend. __Default__: `false`",type:"boolean"},linkingId:{description:"Users need to assign a unique linkingId for [linking views](/docs/user-interaction#linking-views) and [Brushing and Linking](/docs/user-interaction#brushing-and-linking)",type:"string"},range:{$ref:"#/definitions/ValueExtent",description:"Values of the visual channel."},type:{description:"Specify the data type.",enum:["quantitative","nominal","genomic"],type:"string"},zeroBaseline:{description:"Specify whether to use zero baseline. __Default__: `true`",type:"boolean"}},type:"object"},ZoomLevelVisibilityCondition:{additionalProperties:!1,properties:{conditionPadding:{description:"Specify the buffer size (in pixel) of width or height when calculating the visibility.\n\n__Default__: `0`",type:"number"},measure:{const:"zoomLevel",description:"Specify which aspect of the `target` will be compared to the `threshold`.",type:"string"},operation:{$ref:"#/definitions/LogicalOperation",description:`A string that specifies the logical operation to conduct between \`threshold\` and the \`measure\` of \`target\`. Support - -- greater than : "greater-than", "gt", "GT" - -- less than : "less-than", "lt", "LT" - -- greater than or equal to : "greater-than-or-equal-to", "gtet", "GTET" - -- less than or equal to : "less-than-or-equal-to", "ltet", "LTET"`},target:{description:"Target specifies the object that you want to compare with the threshold.",enum:["track","mark"],type:"string"},threshold:{description:"Set a threshold in the unit of base pairs (bp)",type:"number"},transitionPadding:{description:"Specify the buffer size (in pixel) of width or height for smooth transition.\n\n__Default__: `0`",type:"number"}},required:["measure","operation","target","threshold"],type:"object"},ZoomLimits:{items:{type:["number","null"]},maxItems:2,minItems:2,type:"array"}};var ioi={$ref:qgi,$schema:eoi,definitions:toi};const PK=6,noi=130,roi=600,DXe=600,vY=10,MLe=.3,goi=0,ooi="gray",hi=e=>{let i=uv(e);return i||(i=uv(ooi)),XPe([i.rgb().r/255,i.rgb().g/255,i.rgb().b/255])},Ra=0;function Jr(e,i,n,r,o){const l=Math.max(Math.min(i,e),0),c=o??Ra,u=(r-n)/360*Math.PI*2-c*2;return-(n/360*Math.PI*2+l/i*u)-Math.PI/2-c}function Qi(e,i,n,r,o,l,c){return{x:r+n*Math.cos(Jr(e,i,l,c)),y:o+n*Math.sin(Jr(e,i,l,c))}}function ip(e,i,n,r){return n<=e?Math.atan((i-r)/(e-n)):Math.atan((i-r)/(e-n))-Math.PI}function aoi(e,i,n,r){return(Math.atan2(-(i-r),e-n)/Math.PI*180+270)%360}function soi(e,i,n){var r,o,l,c,u;const f=n.spec();if(!f.width||!f.height){console.warn("Size of a track is not properly determined, so visual mark cannot be rendered");return}const m=n.data(),[p,v]=e.dimensions,B=n.getChannelScale("x").invert(p)-n.getChannelScale("x").invert(0),G=f.layout==="circular",T=(r=f.innerRadius)!=null?r:220,V=(o=f.outerRadius)!=null?o:300,E=(l=f.startAngle)!=null?l:0,W=(c=f.endAngle)!=null?c:360,x=V-T,k=p/2,F=v/2,Y=(u=n.getChannelDomainArray("row"))!=null?u:["___SINGLE_ROW___"],L=v/Y.length;Y.forEach(O=>{const Q=n.encodedValue("row",O);m.filter(X=>!Zg(X,f.row)||Zg(X,f.row)===O).forEach(X=>{const $=n.encodedPIXIProperty("x-center",X),ee=n.encodedPIXIProperty("y-center",X),ne=n.encodedPIXIProperty("color",X),ge=n.encodedPIXIProperty("p-size",X),Ae=n.encodedPIXIProperty("strokeWidth",X),_=n.encodedPIXIProperty("stroke",X),de=n.encodedPIXIProperty("opacity",X),Ze=n.markVisibility(X,{width:ge,zoomLevel:B}),me=Math.min(Ze,de);if(!(ge<=.1||me===0||$+ge<0||$-ge>p))if(i.lineStyle(Ae,hi(_),me,1),G){const be=V-(Q+L-ee)/v*x,Ee=Qi($,p,be,k,F,E,W);i.beginFill(hi(ne),me),i.drawCircle(Ee.x,Ee.y,ge),n.getMouseEventModel().addPointBasedEvent(X,[Ee.x,Ee.y,ge])}else i.beginFill(hi(ne),me),i.drawCircle($,Q+L-ee,ge),n.getMouseEventModel().addPointBasedEvent(X,[$,Q+L-ee,ge])})})}function Ioi(e,i,n){const r=e.visualPropertyByChannel("xe",n),o=e.visualPropertyByChannel("x",n),l=e.visualPropertyByChannel("size",n);switch(i){case"x-center":return r?(r+o)/2:o;case"y-center":{const c=e.visualPropertyByChannel("ye",n),u=e.visualPropertyByChannel("y",n);return c?(c+u)/2:u}case"p-size":return r&&e.spec().stretch?(r-o)/2:l;default:return}}function loi(e,i,n,r){var o,l,c,u,f,m;const p=i.spec();if(!p.width||!p.height){console.warn("Size of a track is not properly determined, so visual mark cannot be rendered");return}const v=i.data(),B=p.layout==="circular",G=(o=p.innerRadius)!=null?o:220,T=(l=p.outerRadius)!=null?l:300,V=(c=p.startAngle)!=null?c:0,E=(u=p.endAngle)!=null?u:360,W=T-G,x=n/2,k=r/2,F=(f=i.getChannelDomainArray("row"))!=null?f:["___SINGLE_ROW___"],Y=r/F.length,L=(m=i.getChannelDomainArray("color"))!=null?m:["___SINGLE_COLOR___"];F.forEach(O=>{const Q=i.encodedValue("row",O);L.forEach(X=>{v.filter($=>(!Zg($,p.row)||Zg($,p.row)===O)&&(!Zg($,p.color)||Zg($,p.color)===X)).sort(($,ee)=>Zg($,p.x)-Zg(ee,p.x)).forEach(($,ee)=>{const ne=i.encodedPIXIProperty("x",$),ge=i.encodedPIXIProperty("y",$),Ae=i.encodedPIXIProperty("size",$),_=i.encodedPIXIProperty("color",$),de=i.encodedPIXIProperty("opacity",$);if(e.lineStyle(Ae,hi(_),de,.5),B){const Ze=T-(Q+Y-ge)/r*W,me=Qi(ne,n,Ze,x,k,V,E);ee===0?e.moveTo(me.x,me.y):e.lineTo(me.x,me.y),i.getMouseEventModel().addPointBasedEvent($,[me.x,me.y,1])}else ee===0?e.moveTo(ne,Q+Y-ge):e.lineTo(ne,Q+Y-ge),i.getMouseEventModel().addPointBasedEvent($,[ne,Q+Y-ge,1])})})})}function Coi(e,i,n){var r,o,l,c,u,f,m;const p=n.spec();if(!p.width||!p.height){console.warn("Size of a track is not properly determined, so visual mark cannot be rendered");return}const v=n.data(),[B,G]=e.dimensions,T=e.tilesetInfo.tile_size,V=n.getChannelScale("x").invert(B)-n.getChannelScale("x").invert(0),E=p.layout==="circular",W=(r=p.innerRadius)!=null?r:220,x=(o=p.outerRadius)!=null?o:300,k=(l=p.startAngle)!=null?l:0,F=(c=p.endAngle)!=null?c:360,Y=x-W,L=B/2,O=G/2,Q=n.getChannelScale("x");let X;if(i.tileData.tilePos){const{tileX:de,tileWidth:Ze}=e.getTilePosAndDimensions(i.tileData.zoomLevel,i.tileData.tilePos,T);X=Q(de+Ze/T)-Q(de)}const $=(u=n.getChannelDomainArray("row"))!=null?u:["___SINGLE_ROW___"],ee=G/$.length,ne=!Ii(p.row)||Ii(p.row)&&typeof p.row.clip>"u"||p.row.clip,ge=Ii(p.y)?(f=p.y)==null?void 0:f.baseline:void 0,Ae=(m=n.encodedValue("y",ge))!=null?m:0,_=i.graphics;if(MP(p)){const de=n.getGenomicChannel();if(!de||!de.field){console.warn("Genomic field is not provided in the specification");return}const Ze=vP(v,be=>be[de.field]);[...Ze.keys()].forEach(be=>{var Ee;let Je=0;(Ee=Ze.get(be))==null||Ee.forEach(Ue=>{const dt=n.encodedPIXIProperty("color",Ue),rt=n.encodedPIXIProperty("stroke",Ue),ke=n.encodedPIXIProperty("strokeWidth",Ue),ze=n.encodedPIXIProperty("opacity",Ue),je=n.encodedPIXIProperty("y",Ue),lt=n.encodedPIXIProperty("width",Ue,{tileUnitWidth:X}),xe=n.encodedPIXIProperty("x-start",Ue,{markWidth:lt}),it=xe+lt,Ct=n.markVisibility(Ue,{width:lt,zoomLevel:V}),It=Math.min(Ct,ze);if(It===0||lt<=0||je<=0)return;_.lineStyle(ke,hi(rt),It,0);let Et=[];if(E){const Zt=x-(ee-Je)/G*Y,zt=x-(ee-je-Je)/G*Y,Kt=Qi(xe,B,zt,L,O,k,F),Ut=Jr(xe,B,k,F),ti=Jr(xe+lt,B,k,F);_.beginFill(hi(dt),dt==="none"?0:It),_.moveTo(Kt.x,Kt.y),_.arc(L,O,zt,Ut,ti,!0),_.arc(L,O,Zt,ti,Ut,!1),Et=Array.from(_.currentPath.points),_.closePath()}else{_.beginFill(hi(dt),dt==="none"?0:It),_.drawRect(xe,ee-je-Je,lt,je);const Zt=ee-je-Je,zt=Zt+je;Et=[xe,Zt,xe,zt,it,zt,it,Zt]}n.getMouseEventModel().addPolygonBasedEvent(Ue,Et),Je+=je})})}else $.forEach(de=>{const Ze=n.encodedValue("row",de);v.filter(me=>{const be=Zg(me,p.row);return!be||be===de}).forEach(me=>{const be=n.encodedPIXIProperty("color",me),Ee=n.encodedPIXIProperty("stroke",me),Je=n.encodedPIXIProperty("strokeWidth",me),Ue=n.encodedPIXIProperty("opacity");let dt=n.encodedPIXIProperty("y",me),rt=n.encodedPIXIProperty("ye",me);typeof rt<"u"&&dt>rt&&([dt,rt]=[rt,dt]);const ke=n.encodedPIXIProperty("width",me,{tileUnitWidth:X}),ze=n.encodedPIXIProperty("x-start",me,{markWidth:ke}),je=ze+ke;let lt;typeof rt>"u"?(lt=Ze+ee-Ae-dt,rt=Ze+ee-Ae,(Ii(p.y)&&p.y.flip||p.flipY)&&(rt=lt,lt=Ze)):(lt=Ze+ee-rt,rt=Ze+ee-dt),ne&&(lt=Math.max(Ze,lt),lt=Math.min(lt,Ze+ee),rt=Math.max(Ze,rt),rt=Math.min(rt,Ze+ee));const xe=n.markVisibility(me,{width:ke,zoomLevel:V}),it=Math.min(xe,Ue);if(it===0||ke===0||rt-lt===0)return;_.lineStyle(Je,hi(Ee),it,0);let Ct=[];if(E){const It=x-lt/G*Y,Et=x-rt/G*Y,Zt=Qi(ze,B,Et,L,O,k,F),zt=Jr(ze,B,k,F),Kt=Jr(ze+ke,B,k,F);_.beginFill(hi(be),be==="none"?0:it),_.moveTo(Zt.x,Zt.y),_.arc(L,O,Et,zt,Kt,!0),_.arc(L,O,It,Kt,zt,!1),Ct=Array.from(_.currentPath.points),_.closePath()}else _.beginFill(hi(be),be==="none"?0:it),_.drawRect(ze,lt,ke,rt-lt),Ct=[ze,lt,ze,rt,je,rt,je,lt];n.getMouseEventModel().addPolygonBasedEvent(me,Ct)})})}function coi(e,i,n,r){const o=e.visualPropertyByChannel("x",n),l=e.visualPropertyByChannel("xe",n),c=e.visualPropertyByChannel("size",n);switch(i){case"width":return c??(l?l-o:r?.tileUnitWidth);case"x-start":return r?.markWidth?l?(o+l-r?.markWidth)/2:o-r?.markWidth/2:void 0;default:return}}function Aoi(e,i,n,r){var o,l,c,u,f,m;const p=r.spec(),v=r.data(),[B,G]=i.dimensions,T=p.layout==="circular",V=(o=p.innerRadius)!=null?o:220,E=(l=p.outerRadius)!=null?l:300,W=(c=p.startAngle)!=null?c:0,x=(u=p.endAngle)!=null?u:360,k=E-V,F=B/2,Y=G/2,L=i._xScale,O=(f=r.getChannelDomainArray("row"))!=null?f:["___SINGLE_ROW___"],Q=G/O.length,X=(m=r.getChannelDomainArray("color"))!=null?m:["___SINGLE_COLOR___"],$=r.encodedPIXIProperty("opacity"),ee=r.encodedPIXIProperty("strokeWidth"),ne=r.encodedPIXIProperty("stroke"),ge=n.graphics;if(MP(p)){const Ae=r.getGenomicChannel();if(!Ae||!Ae.field){console.warn("Genomic field is not provided in the specification");return}const _=vP(v,me=>me[Ae.field]),de=[..._.keys()];ge.lineStyle(ee,hi(ne),$,1);const Ze={};X.forEach(me=>{const be=[],Ee=[];de.forEach((Ue,dt,rt)=>{var ke,ze;(ze=(ke=_.get(Ue))==null?void 0:ke.filter(je=>Zg(je,p.color)===me))==null||ze.forEach(je=>{const lt=+Ue,xe=L(lt),it=mE([r.encodedPIXIProperty("y",je),0]);typeof Ze[Ue]>"u"&&(Ze[Ue]=0);const Ct=Q-it-Ze[Ue],It=Q-Ze[Ue];if(T){if(dt===0){const Ut=E-Q/G*k,ti=Qi(xe,B,Ut,F,Y,W,x);be.push([ti.x,ti.y]),Ee.push([ti.x,ti.y])}const Et=E-Ct/G*k,Zt=Qi(xe,B,Et,F,Y,W,x);be.push([Zt.x,Zt.y]);const zt=E-It/G*k,Kt=Qi(xe,B,zt,F,Y,W,x);if(Ee.push([Kt.x,Kt.y]),dt===rt.length-1){const Ut=E-Q/G*k,ti=Qi(xe,B,Ut,F,Y,W,x);be.push([ti.x,ti.y]),Ee.push([ti.x,ti.y])}r.getMouseEventModel().addPointBasedEvent(je,[Kt.x,Kt.y,1])}else dt===0&&(be.push([xe,Q]),Ee.push([xe,Q])),be.push([xe,Ct]),Ee.push([xe,It]),dt===rt.length-1&&(be.push([xe,Q]),Ee.push([xe,Q])),r.getMouseEventModel().addPointBasedEvent(je,[xe,Ct,1]);Ze[Ue]+=it})});const Je=r.encodedValue("color",me);ge.beginFill(hi(Je),$),ge.drawPolygon([...be.reduce((Ue,dt)=>Ue.concat(dt)),...Ee.reverse().reduce((Ue,dt)=>Ue.concat(dt))]),ge.endFill()})}else O.forEach(Ae=>{const _=r.encodedValue("row",Ae);ge.lineStyle(ee,hi(ne),$,0),X.forEach(de=>{const Ze=[],me=[],be=E-(_+Q)/G*k;let Ee=0;v.filter(Ue=>(typeof Zg(Ue,p.row)>"u"||Zg(Ue,p.row)===Ae)&&(typeof Zg(Ue,p.color)>"u"||Zg(Ue,p.color)===de)).sort((Ue,dt)=>r.encodedPIXIProperty("x",Ue)-r.encodedPIXIProperty("x",dt)).forEach((Ue,dt,rt)=>{const ke=mY([mE([r.encodedPIXIProperty("y",Ue),0]),Q]),ze=r.encodedPIXIProperty("x",Ue);if(T){const je=Qi(ze,B,be,F,Y,W,x);Ze.push([je.x,je.y]),dt===0&&me.push(je.x,je.y);const lt=E-(_+Q-ke)/G*k,xe=Qi(ze,B,lt,F,Y,W,x);if(me.push(xe.x,xe.y),dt===rt.length-1){const it=E-(_+Q)/G*k,Ct=Qi(ze,B,it,F,Y,W,x);me.push(Ct.x,Ct.y)}r.getMouseEventModel().addPointBasedEvent(Ue,[xe.x,xe.y,1])}else dt===0&&(me.push(ze,_+Q),Ee=ze),me.push(ze,_+Q-ke),dt===rt.length-1&&(me.push(ze,_+Q),me.push(Ee,_+Q)),r.getMouseEventModel().addPointBasedEvent(Ue,[ze,_+Q-ke,1])}),T&&Ze.length!==0&&me.push(...Ze.reverse().reduce((Ue,dt)=>Ue.concat(dt)));const Je=r.encodedValue("color",de);ge.beginFill(hi(Je),$),ge.drawPolygon(me),ge.endFill()})})}function uoi(e,i,n,r){var o,l,c,u,f,m;const p=r.spec(),v=r.data(),[B,G]=i.dimensions,T=p.layout==="circular",V=(o=p.innerRadius)!=null?o:220,E=(l=p.outerRadius)!=null?l:300,W=(c=p.startAngle)!=null?c:0,x=(u=p.endAngle)!=null?u:360,k=E-V,F=B/2,Y=G/2,L=i._xScale;let O;if(n.tileData.tilePos){const Ae=i.tilesetInfo.tile_size,{tileX:_,tileWidth:de}=i.getTilePosAndDimensions(n.tileData.zoomLevel,n.tileData.tilePos,Ae);O=L(_+de/Ae)-L(_)}const Q=(f=r.getChannelDomainArray("row"))!=null?f:["___SINGLE_ROW___"],X=G/Q.length,$=Ii(p.row)&&p.row.padding?p.row.padding:0,ee=(m=r.getChannelDomainArray("y"))!=null?m:["___SINGLE_Y_POSITION___"],ne=X/ee.length-$*2,ge=n.graphics;v.forEach(Ae=>{var _;const de=r.encodedPIXIProperty("row",Ae)+$,Ze=r.encodedPIXIProperty("x",Ae),me=r.encodedPIXIProperty("color",Ae),be=r.encodedPIXIProperty("stroke",Ae),Ee=r.encodedPIXIProperty("strokeWidth",Ae),Je=r.encodedPIXIProperty("opacity",Ae),Ue=r.encodedPIXIProperty("width",Ae,{markWidth:O}),dt=r.encodedPIXIProperty("height",Ae,{markHeight:ne}),rt=r.encodedPIXIProperty("y",Ae),ke=r.markVisibility(Ae,{width:Ue,zoomLevel:i._xScale.invert(B)-i._xScale.invert(0)}),ze=Math.min(ke,Je);if(ze===0||dt===0||Ue<=1e-4)return;const[je,lt,xe,it]=[Ze,Ze+Ue,de+X-rt-dt/2,de+X-rt+dt/2],Ct=(_=r.visualPropertyByChannel("size",Ae))!=null?_:void 0;ge.lineStyle(Ee,hi(be),ze,.5);let It=[];if(T){if(lt<0||B{const ee=i.encodedValue("row",$);B.filter(ne=>!Zg(ne,v.row)||Zg(ne,v.row)===$).forEach(ne=>{var ge,Ae,_;const de=i.encodedPIXIProperty("x",ne),Ze=i.encodedPIXIProperty("xe",ne),me=(ge=i.encodedPIXIProperty("size",ne))!=null?ge:Ze===void 0?X:Ze-de,be=i.encodedPIXIProperty("y",ne),Ee=i.encodedPIXIProperty("strokeWidth",ne),Je=i.encodedPIXIProperty("stroke",ne),Ue=i.encodedPIXIProperty("color",ne),dt=i.encodedPIXIProperty("opacity",ne);let rt=[];if(T){let ke=de||Ze-me,ze=Ze||de+me,je=(ke+ze)/2;const lt=E-(ee+O-be)/r*k,xe=lt-X/2,it=lt+X/2;if(((Ae=v.style)==null?void 0:Ae.align)==="right"&&!Ze&&(ke-=me,ze-=me,je-=me),v.mark==="triangleLeft"){const Et=Qi(ze,n,xe,F,Y,W,x),Zt=Qi(ke,n,lt,F,Y,W,x),zt=Qi(ze,n,it,F,Y,W,x),Kt=Qi(ze,n,xe,F,Y,W,x);rt=[Et.x,Et.y,Zt.x,Zt.y,zt.x,zt.y,Kt.x,Kt.y]}else if(v.mark==="triangleRight"){const Et=Qi(ke,n,xe,F,Y,W,x),Zt=Qi(ze,n,lt,F,Y,W,x),zt=Qi(ke,n,it,F,Y,W,x),Kt=Qi(ke,n,xe,F,Y,W,x);rt=[Et.x,Et.y,Zt.x,Zt.y,zt.x,zt.y,Kt.x,Kt.y]}else if(v.mark==="triangleBottom"){ke=je-me/2,ze=je+me/2;const Et=Qi(ke,n,it,F,Y,W,x),Zt=Qi(ze,n,it,F,Y,W,x),zt=Qi(je,n,xe,F,Y,W,x),Kt=Qi(ke,n,it,F,Y,W,x);rt=[Et.x,Et.y,Zt.x,Zt.y,zt.x,zt.y,Kt.x,Kt.y]}const Ct=i.markVisibility(ne,{width:ze-ke,zoomLevel:G}),It=Math.min(Ct,dt);e.lineStyle(Ee,hi(Je),ze-ke>2?It:0,0),e.beginFill(hi(Ue),It),e.drawPolygon(rt),e.endFill()}else{let ke=de||Ze-me,ze=Ze||de+me,je=ke+(ze-ke)/2;const lt=ee+O-be,xe=ee+O-be-X/2,it=ee+O-be+X/2;((_=v.style)==null?void 0:_.align)==="right"&&!Ze&&(ke-=me,ze-=me,je-=me),rt={triangleLeft:[ze,xe,ke,lt,ze,it,ze,xe],triangleRight:[ke,xe,ze,lt,ke,it,ke,xe],triangleBottom:[ke,xe,ze,xe,je,it,ke,xe]}[v.mark];const Ct=i.markVisibility(ne,{width:ze-ke,zoomLevel:G}),It=Math.min(Ct,dt);e.lineStyle(Ee,hi(Je),ze-ke>2?It:0,.5),e.beginFill(hi(Ue),It),e.drawPolygon(rt),e.endFill()}i.getMouseEventModel().addPolygonBasedEvent(ne,rt)})})}const Zu={fontSize:"12px",fontFamily:"sans-serif",fontWeight:"normal",fill:"black",background:"white",lineJoin:"round",stroke:"#ffffff",strokeThickness:0};function foi(e,i,n,r){var o,l,c,u,f,m,p,v,B,G;const T=r.spec(),V=r.data(),[E,W]=i.dimensions,x=T.layout==="circular",k=(o=T.innerRadius)!=null?o:220,F=(l=T.outerRadius)!=null?l:300,Y=(c=T.startAngle)!=null?c:0,L=(u=T.endAngle)!=null?u:360,O=F-k,Q=E/2,X=W/2,$=(f=r.getChannelDomainArray("row"))!=null?f:["___SINGLE_ROW___"],ee=W/$.length,ne=(p=(m=T.style)==null?void 0:m.dx)!=null?p:0,ge=(B=(v=T.style)==null?void 0:v.dy)!=null?B:0,Ae=(G=T.style)!=null&&G.textAnchor?T.style.textAnchor:"middle";if(MP(T)){if(x)return;const _=n.graphics,de=r.getGenomicChannel();if(!de||!de.field){console.warn("Genomic field is not provided in the specification");return}const Ze=vP(V,be=>be[de.field]);[...Ze.keys()].forEach(be=>{var Ee;let Je=0;(Ee=Ze.get(be))==null||Ee.forEach(Ue=>{var dt,rt,ke,ze,je,lt,xe,it;const Ct=r.encodedPIXIProperty("text",Ue),It=r.encodedPIXIProperty("color",Ue),Et=r.encodedPIXIProperty("x",Ue)+ne,Zt=r.encodedPIXIProperty("xe",Ue)+ne,zt=r.encodedPIXIProperty("x-center",Ue)+ne,Kt=r.encodedPIXIProperty("y",Ue)+ge,Ut=r.encodedPIXIProperty("size",Ue),ti=r.encodedPIXIProperty("stroke",Ue),mi=r.encodedPIXIProperty("strokeWidth",Ue),Cn=r.encodedPIXIProperty("opacity",Ue);if(zt<0||zt>E||i.textsBeingUsed>1e3)return;const on={...Zu,fontSize:Ut??((dt=T.style)!=null&&dt.textFontSize?`${(rt=T.style)==null?void 0:rt.textFontSize}px`:Zu.fontSize),stroke:(ze=ti??((ke=T.style)==null?void 0:ke.textStroke))!=null?ze:Zu.stroke,strokeThickness:(lt=mi??((je=T.style)==null?void 0:je.textStrokeWidth))!=null?lt:Zu.strokeThickness,fontWeight:(it=(xe=T.style)==null?void 0:xe.textFontWeight)!=null?it:Zu.fontWeight},ki=new e.libraries.PIXI.TextStyle(on);let Ei;i.textGraphics.length>i.textsBeingUsed?(Ei=i.textGraphics[i.textsBeingUsed],Ei.style.fill=It,Ei.visible=!0,Ei.text=Ct,Ei.alpha=1):(Ei=new e.libraries.PIXI.Text(Ct,{...on,fill:It}),i.textGraphics.push(Ei));const Bn=e.libraries.PIXI.TextMetrics.measureText(Ct,ki);i.textsBeingUsed++;const Nr=r.markVisibility(Ue,{...Bn,zoomLevel:i._xScale.invert(E)-i._xScale.invert(0)}),kr=Math.min(Nr,Cn);if(!Ct||kr===0){i.textsBeingUsed--,Ei.visible=!1;return}Ei.alpha=kr,Ei.resolution=8,Ei.updateText(),Ei.texture.baseTexture.scaleMode=e.libraries.PIXI.SCALE_MODES.LINEAR;const Be=new e.libraries.PIXI.Sprite(Ei.texture);Be.x=Et,Be.y=ee-Kt-Je,Be.width=Zt-Et,Be.height=Kt,_.addChild(Be),Je+=Kt})})}else $.forEach(_=>{const de=n.graphics,Ze=r.encodedValue("row",_);V.filter(me=>!Zg(me,T.row)||Zg(me,T.row)===_).forEach(me=>{var be,Ee,Je,Ue,dt,rt,ke,ze;const je=r.encodedPIXIProperty("text",me),lt=r.encodedPIXIProperty("color",me),xe=r.encodedPIXIProperty("x-center",me)+ne,it=r.encodedPIXIProperty("y",me)+ge,Ct=r.encodedPIXIProperty("size",me),It=r.encodedPIXIProperty("stroke",me),Et=r.encodedPIXIProperty("strokeWidth",me),Zt=r.encodedPIXIProperty("opacity",me);if(xe<0||xe>E||i.textsBeingUsed>1e3)return;const zt={...Zu,fontSize:Ct??((be=T.style)!=null&&be.textFontSize?`${(Ee=T.style)==null?void 0:Ee.textFontSize}px`:Zu.fontSize),stroke:(Ue=It??((Je=T.style)==null?void 0:Je.textStroke))!=null?Ue:Zu.stroke,strokeThickness:(rt=Et??((dt=T.style)==null?void 0:dt.textStrokeWidth))!=null?rt:Zu.strokeThickness,fontWeight:(ze=(ke=T.style)==null?void 0:ke.textFontWeight)!=null?ze:Zu.fontWeight},Kt=new e.libraries.PIXI.TextStyle(zt);let Ut;i.textGraphics.length>i.textsBeingUsed?(Ut=i.textGraphics[i.textsBeingUsed],Ut.style.fill=lt,Ut.visible=!0,Ut.text=je,Ut.alpha=1):(Ut=new e.libraries.PIXI.Text(je,{...zt,fill:lt}),i.textGraphics.push(Ut));const ti=e.libraries.PIXI.TextMetrics.measureText(je,Kt);i.textsBeingUsed++;const mi=r.markVisibility(me,{...ti,zoomLevel:i._xScale.invert(E)-i._xScale.invert(0)}),Cn=Math.min(mi,Zt);if(!je||Cn===0){i.textsBeingUsed--,Ut.visible=!1;return}Ut.alpha=Cn,Ut.anchor.y=.5,Ut.anchor.x=Ae==="middle"?.5:Ae==="start"?0:1;let on=[];if(x){const ki=F-(Ze+ee-it)/W*O,Ei=Qi(xe,E,ki,Q,X,Y,L);Ut.x=Ei.x,Ut.y=Ei.y,Ut.resolution=4;const Bn=ti.width/(2*ki*Math.PI)*E;let[Nr,kr]=[xe-Bn/2,xe+Bn/2];if(Nr<0){const ct=-Nr;Nr=0,kr+=ct}else if(kr>E){const ct=kr-E;kr=E,Nr-=ct}const Be=[],le=[],ce=[];for(let ct=kr;ct>=Nr;ct-=Bn/10){const Wt=Qi(ct,E,ki,Q,X,Y,L);Be.push(new e.libraries.PIXI.Point(Wt.x,Wt.y));const Mt=Qi(ct,E,ki+ti.height/2,Q,X,Y,L),fn=Qi(ct,E,ki-ti.height/2,Q,X,Y,L);le.push(Mt.x,Mt.y),ct===kr&&ce.push(Mt.y,Mt.x),ce.push(fn.y,fn.x)}Ut.updateText();const Ke=new e.libraries.PIXI.SimpleRope(Ut.texture,Be);Ke.alpha=Cn,de.addChild(Ke),ce.reverse(),on=le.concat(ce)}else{Ut.position.x=xe,Ut.position.y=Ze+ee-it,de.addChild(Ut);const{height:ki,width:Ei}=ti,Bn=Ut.position.y-ki/2,Nr=Bn+ki;let kr=0,Be=0;Ae==="start"?(kr=xe,Be=xe+Ei):Ae==="middle"?(kr=xe-Ei/2,Be=xe+Ei/2):(kr=xe-Ei,Be=xe),on=[kr,Bn,kr,Nr,Be,Nr,Be,Bn]}r.getMouseEventModel().addPolygonBasedEvent(me,on)})})}function moi(e,i,n,r){var o,l,c,u,f,m,p,v;const B=r.spec(),G=r.data(),[T,V]=i.dimensions,E=B.layout==="circular",W=(o=B.innerRadius)!=null?o:220,x=(l=B.outerRadius)!=null?l:300,k=(c=B.startAngle)!=null?c:0,F=(u=B.endAngle)!=null?u:360,Y=x-W,L=T/2,O=V/2,Q=(f=r.getChannelDomainArray("row"))!=null?f:["___SINGLE_ROW___"],X=V/Q.length,$=(m=B.style)==null?void 0:m.dashed,ee=(p=B.style)==null?void 0:p.linePattern,ne=(v=B.style)==null?void 0:v.curve,ge=n.graphics;Q.forEach(Ae=>{const _=r.encodedValue("row",Ae);G.filter(de=>!Zg(de,B.row)||Zg(de,B.row)===Ae).forEach(de=>{const Ze=r.encodedPIXIProperty("x",de),me=r.encodedPIXIProperty("xe",de),be=r.encodedPIXIProperty("y",de),Ee=r.encodedPIXIProperty("color",de),Je=r.encodedPIXIProperty("strokeWidth",de),Ue=r.encodedPIXIProperty("opacity",de),dt=r.markVisibility(de,{width:me-Ze,zoomLevel:i._xScale.invert(T)-i._xScale.invert(0)}),rt=Math.min(dt,Ue);if(ge.lineStyle(Je,hi(Ee),rt,.5),!me&&(!B.y||!("field"in B.y))){if(E)return;if($){const[ke,ze]=$;let je=0;do ge.moveTo(Ze,je),ge.lineTo(Ze,je+ke),je+=ke+ze;while(je{const _=n.encodedValue("row",Ae);T.filter(de=>!Zg(de,G.row)||Zg(de,G.row)===Ae).forEach(de=>{var Ze,me,be,Ee,Je;let Ue=n.encodedPIXIProperty("x",de),dt=n.encodedPIXIProperty("xe",de),rt=n.encodedPIXIProperty("x1",de),ke=n.encodedPIXIProperty("x1e",de);const ze=n.encodedPIXIProperty("y",de),je=n.encodedPIXIProperty("ye",de),lt=n.encodedPIXIProperty("stroke",de),xe=n.encodedPIXIProperty("strokeWidth",de),it=n.encodedPIXIProperty("color",de),Ct=n.encodedPIXIProperty("opacity",de);typeof dt<"u"&&([Ue,dt]=[Ue,dt].sort((Kt,Ut)=>Kt-Ut)),typeof rt<"u"&&typeof ke<"u"&&([rt,ke]=[rt,ke].sort((Kt,Ut)=>Kt-Ut));const It=typeof dt<"u"&&typeof rt<"u"&&typeof ke<"u"&&Math.abs(Ue-dt)>.1&&Math.abs(rt-ke)>.1;if(!It&&dt===void 0&&!CI(G)){if(rt===void 0&&ke===void 0)return;dt=rt!==void 0?rt:ke}!It&&Math.abs(Ue-dt)<=.1&&Math.abs(rt-ke)<=.1&&(Ue=(Ue+dt)/2,dt=(rt+ke)/2),e.lineStyle(xe,hi(lt),Ct,.5);const Et=Ii(G.y)&&G.y.flip||G.flipY,Zt=(Ze=G.baselineY)!=null?Ze:_+(Et?0:$);let zt=[];if(It){e.beginFill(hi(it==="none"?"white":it),it==="none"?0:Ct);let[Kt,Ut,ti,mi]=[Ue,dt,rt,ke];if([Kt,Ut,ti,mi]=[Kt,Ut,ti,mi].sort((Cn,on)=>Cn-on),Kt>V||mi<0||Math.abs(mi-Kt)<.5)return;if(W){if(Kt<0||mi>V)return;const Cn=k-_/E*L,on=Qi(Kt,V,Cn,O,Q,F,Y),ki=Qi(Ut,V,Cn,O,Q,F,Y),Ei=Qi(ti,V,Cn,O,Q,F,Y),Bn=Qi(mi,V,Cn,O,Q,F,Y);e.moveTo(on.x,on.y),e.bezierCurveTo(O,Q,O,Q,Bn.x,Bn.y),e.arc(O,Q,k,ip(Bn.x,Bn.y,O,Q),ip(Ei.x,Ei.y,O,Q),!1),e.bezierCurveTo(O,Q,O,Q,ki.x,ki.y),e.arc(O,Q,k,ip(ki.x,ki.y,O,Q),ip(on.x,on.y,O,Q),!1),zt=Array.from(e.currentPath.points),e.endFill()}else e.moveTo(Kt,Zt),!((me=G.style)!=null&&me.linkStyle)||((be=G.style)==null?void 0:be.linkStyle)==="circular"?(e.arc((Kt+mi)/2,Zt,(mi-Kt)/2,-Math.PI,Math.PI,!1),e.arc((Ut+ti)/2,Zt,(ti-Ut)/2,Math.PI,-Math.PI,!0),zt=Array.from(e.currentPath.points),e.closePath()):(e.lineTo(ti,_+$),e.bezierCurveTo(ti+(Ut-ti)/3,_+$-(Ut-ti)/2,ti+(Ut-ti)/3*2,_+$-(Ut-ti)/2,Ut,_+$),e.lineTo(mi,_+$),e.bezierCurveTo(Kt+(mi-Kt)/3*2,_+$-(mi-Kt)/2,Kt+(mi-Kt)/3,_+$-(mi-Kt)/2,Kt,_+$),zt=Array.from(e.currentPath.points),e.endFill());n.getMouseEventModel().addPolygonBasedEvent(de,zt)}else{const Kt=(Ue+dt)/2;if(e.beginFill(hi("white"),0),W){if(Ue<0||dt>V)return;if(((Ee=G.style)==null?void 0:Ee.linkStyle)==="straight"){const Ut=k-_/E*L,ti=Qi(Ue,V,Ut,O,Q,F,Y),mi=Qi(dt,V,Ut,O,Q,F,Y),Cn=ti.x,on=ti.y,ki=mi.x,Ei=mi.y;e.moveTo(Cn,on),e.lineTo(ki,Ei);const Bn=100;zt=Array.from({length:Bn},(kr,Be)=>({x:(ki-Cn)/(Bn-1)*Be+Cn,y:(Ei-on)/(Bn-1)*Be+on})).flatMap(kr=>[kr.x,kr.y])}else{const Ut=k-_/E*L,ti=Qi(Ue,V,Ut,O,Q,F,Y),mi=Qi(dt,V,Ut,O,Q,F,Y),Cn=ti.x,on=ti.y,ki=ti.x,Ei=ti.y,Bn=V/2,Nr=E/2,kr=mi.x,Be=mi.y;e.moveTo(Cn,on);const le=new po(Cn,on,ki,Ei,Bn,Nr,kr,Be);le.getLUT(14).forEach(ct=>e.lineTo(ct.x,ct.y)),zt=le.getLUT(1e3).flatMap(ct=>[ct.x,ct.y])}}else if(((Je=G.style)==null?void 0:Je.linkStyle)==="elliptical"){if(!(0<=Ue&&Ue<=V)&&!(0<=dt&&dt<=V))return;const Ut=[],ti=Ii(G.y);for(let mi=0;mi<=ne;mi++){const Cn=Math.PI*(mi/ne),on=(dt-Ue)/2*Math.cos(Cn)+(Ue+dt)/2;let ki=Zt-ze*Math.sin(Cn)*(ti?1:Math.min(dt-Ue+V*ee,V)/V)*(Et?-1:1);if(typeof ze<"u"&&typeof je<"u"){const Ei=Math.abs(je-ze),Bn=je>ze;ki=ze-Ei*Math.sin(Cn)*(Bn?-1:1)}if(mi===0)if(ge){const Ei=Et?Zt-E:Zt;e.moveTo(on,Ei),Ut.push({x:on,y:Ei}),e.lineTo(on,ki)}else e.moveTo(on,ki);else e.lineTo(on,ki);if(Ut.push({x:on,y:ki}),mi===ne&&ge){const Ei=Et?Zt-E:Zt;e.lineTo(on,Ei),Ut.push({x:on,y:Ei})}}zt=Ut.flatMap(mi=>[mi.x,mi.y])}else{if(dt<0||Ue>V)return;e.arc(Kt,Zt,(dt-Ue)/2,-Math.PI,Math.PI),zt=Array.from(e.currentPath.points),e.closePath()}n.getMouseEventModel().addLineBasedEvent(de,zt)}})})}function boi(e,i,n){return[...e.slice(0,i),n,...e.slice(i)]}function yoi(e){const i=[];for(let n=0;ntypeof i=="number")}function YLe(e){return FLe(e,i=>typeof i=="string")}function voi(e,i,n){Boi(e,i,n),Zoi(e,i,n)}function Zoi(e,i,n){var r,o,l,c;const u=i.spec();if(!Ii(u.row)||u.row.grid!==!0)return;const[f,m]=e.position,[p,v]=e.dimensions,B=i.spec().layout==="circular",G=(r=u.innerRadius)!=null?r:220,T=(o=u.outerRadius)!=null?o:300,V=(l=u.startAngle)!=null?l:0,E=(c=u.endAngle)!=null?c:360,W=T-G,x=p/2,k=v/2,F=i.getChannelDomainArray("row");if(!F)return;const Y=v/F.length;if(B&&W<=20||!B&&Y<=20)return;const L=e.pBackground,O=n.axis.gridStrokeWidth;F.forEach(Q=>{const X=i.encodedValue("row",Q);if(B){const $=X+Y/2,ee=T-$/v*W,ne=ee+O/2,ge=ee-O/2,Ae=Qi(0,p,ge,x,k,V,E),_=Jr(0,p,V,E),de=Jr(p,p,V,E);L.lineStyle(O,hi("black"),0,.5),L.beginFill(hi(n.axis.gridColor),1),L.moveTo(f+Ae.x,m+Ae.y),L.arc(f+x,m+k,ge,_,de,!0),L.arc(f+x,m+k,ne,de,_,!1),L.closePath()}else{L.lineStyle(O,hi(n.axis.gridColor),1,.5);const $=m+X+Y/2;L.moveTo(f,$),L.lineTo(f+p,$)}})}function Boi(e,i,n){var r,o,l,c,u;const f=i.spec();if(!Ii(f.y)||f.y.grid!==!0)return;const[m,p]=e.position,[v,B]=e.dimensions,G=m,T=m+v,V=i.spec().layout==="circular",E=(r=f.innerRadius)!=null?r:220,W=(o=f.outerRadius)!=null?o:300,x=(l=f.startAngle)!=null?l:0,k=(c=f.endAngle)!=null?c:360,F=W-E,Y=v/2,L=B/2,O=(u=i.getChannelDomainArray("row"))!=null?u:["___SINGLE_ROW___"],Q=B/O.length;if(!YLe(O))return;const X=i.getChannelScale("y"),$=i.getChannelDomainArray("y");if(!X||!$||!zIe($)||V&&Q/B*F<=20||!V&&Q<=20)return;const ee=e.pBackground,ne=n.axis.gridStrokeWidth;O.forEach(ge=>{const Ae=i.encodedValue("row",ge),_=V?Q/B*F:Q,de=Math.max(Math.ceil(_/40),1);let Ze=X.ticks(de).filter(me=>$[0]<=me&&me<=$[1]);Ze.length===1&&(Ze=X.ticks(de+1).filter(me=>$[0]<=me&&me<=$[1])),V?Ze.forEach(me=>{const be=X(me),Ee=W-(Ae+Q-be)/B*F,Je=Ee+ne/2,Ue=Ee-ne/2,dt=Qi(0,v,Ue,Y,L,x,k),rt=Jr(0,v,x,k),ke=Jr(v,v,x,k);ee.lineStyle(ne,hi("black"),0,.5),ee.beginFill(hi(n.axis.gridColor),1),ee.moveTo(m+dt.x,p+dt.y),ee.arc(m+Y,p+L,Ue,rt,ke,!0),ee.arc(m+Y,p+L,Je,ke,rt,!1),ee.closePath()}):(ee.lineStyle(ne,hi(n.axis.gridColor),1,.5),Ze.forEach(me=>{var be;const Ee=p+Ae+Q-X(me);if(n.axis.gridStrokeType==="solid")ee.moveTo(G,Ee),ee.lineTo(T,Ee);else if(n.axis.gridStrokeType==="dashed"){const[Je,Ue]=(be=n.axis.gridStrokeDash)!=null?be:[1,1];for(let dt=G;dt=$;de-=X/10){const Ze=Qi(de,p,x-Q.height/2,V,E,G,T);ne.push(new e.libraries.PIXI.Point(Ze.x,Ze.y))}const ge=Jr($,p,G,T),Ae=Jr(ee+k,p,G,T);W.lineStyle(1,hi("red"),0,.5),W.beginFill(hi(o.track.titleBackground),.5),W.moveTo(F.x,F.y),W.arc(V,E,x-Q.height,ge,Ae,!0),W.arc(V,E,x,Ae,ge,!1),W.closePath(),L.updateText();const _=new e.libraries.PIXI.SimpleRope(L.texture,ne);W.addChild(_)}function Soi(e,i,n){var r,o,l,c;const u=e.pBorder,[f,m]=e.position,[p,v]=e.dimensions;u.lineStyle((o=(r=i.spec().style)==null?void 0:r.outlineWidth)!=null?o:1,hi((c=(l=i.spec().style)==null?void 0:l.outline)!=null?c:n.track.outline),1,.5),u.beginFill(hi("white"),0),u.drawRect(f,m,p,v);const B=i.spec().x;u.lineStyle(1,hi(n.axis.baselineColor),1,.5),Ii(B)&&B.axis==="top"?(u.moveTo(f,m),u.lineTo(f+p,m)):Ii(B)&&B.axis==="bottom"&&(u.moveTo(f,m+v),u.lineTo(f+p,m+v))}function woi(e,i,n,r,o){if(!i.gLegend)return;i.gLegend.selectAll(".brush").remove();const l=r.spec(),c={offsetRight:0};if(Ii(l.color)&&l.color.legend)switch(l.color.type){case"nominal":Toi(e,i,n,r,o);break;case"quantitative":MXe(e,i,n,r,o,"color",c);break}if(Ii(l.stroke)&&l.stroke.legend)switch(l.stroke.type){case"quantitative":MXe(e,i,n,r,o,"stroke",c);break}}function MXe(e,i,n,r,o,l,c){const u=r.spec(),f=u[l];if(!Ii(f)||f.type!=="quantitative"||!f.legend)return;const[m,p]=i.position,[v,B]=i.dimensions,G=80,T=B-2>110?110:Math.max(B-2,40-2),V={top:10,left:55,width:20,height:T-20},E=m+v-G-1-c.offsetRight,W=p+1,x=r.getChannelScale(l),k=r.getChannelDomainArray(l);if(!x||!k)return;const F=i.pBorder;if(F.beginFill(hi(o.legend.background),o.legend.backgroundOpacity),F.lineStyle(1,hi(o.legend.backgroundStroke),o.legend.backgroundOpacity,0),F.drawRect(E,W,G,T),f.title){const _=f.title,de=If({color:o.legend.labelColor,size:o.legend.labelFontSize,fontWeight:o.legend.labelFontWeight,fontFamily:o.legend.labelFontFamily}),Ze=new e.libraries.PIXI.Text(_,{...de,fontWeight:"bold"});Ze.anchor.x=0,Ze.anchor.y=0,Ze.position.x=E+10,Ze.position.y=W+10;const me=new e.libraries.PIXI.TextStyle({...de,fontWeight:"bold"}),be=e.libraries.PIXI.TextMetrics.measureText(_,me);F.addChild(Ze),V.top+=be.height+4,V.height-=be.height+4}const[Y,L]=k,O=L-Y,Q=Ii(f)&&f.scaleOffset?f.scaleOffset:[0,1];[...Array(V.height).keys()].forEach(_=>{let de;const Ze=Array.from(Q).sort();if(_/V.height>=Ze[1])de=L;else if(_/V.height<=Ze[0])de=Y;else{const me=dv().domain([V.height*Ze[0],V.height*Ze[1]]).range([0,V.height]);de=dv().domain([0,V.height]).range([Y,L])(me(_))}F.beginFill(hi(x(de)),1),F.lineStyle(1,hi(o.legend.backgroundStroke),0,.5),F.drawRect(E+V.left,W+V.top+V.height-_,V.width,1)});const X=4;i.colorBrushes=i.gLegend.append("g").attr("class",l).selectAll(".brush").data(Q.map((_,de)=>({y:_,id:de}))).enter().append("rect").attr("class","brush").attr("pointer-events","all").attr("cursor","ns-resize").attr("transform",_=>`translate(${E+V.left}, ${W+V.top-X/2+V.height-V.height*_.y})`).attr("width",`${V.width}px`).attr("height",`${X}px`).attr("fill","lightgrey").attr("stroke","black").attr("stroke-width","0.5px").call(e.libraries.d3Drag.drag().on("start",_=>{i.startEvent=_.sourceEvent}).on("drag",(_,de)=>{if(f&&f.scaleOffset){const Ze=_.sourceEvent,me=i.startEvent.clientY-Ze.clientY,be=[f.scaleOffset[0],f.scaleOffset[1]];de.id===0?be[0]+=me/V.height:be[1]+=me/V.height,be[0]=Math.min(1,Math.max(0,be[0])),be[1]=Math.min(1,Math.max(0,be[1])),i.updateScaleOffsetFromOriginalSpec(u._renderingId,be,l),i.shareScaleOffsetAcrossTracksAndTiles(be,l),i.draw(),i.startEvent=_.sourceEvent}}));const $=Math.max(Math.ceil(V.height/30),2);let ee=x.ticks($).filter(_=>k[0]<=_&&_<=k[1]);ee.length===1&&(ee=x.ticks($+1).filter(_=>k[0]<=_&&_<=k[1]));const ne=1;F.lineStyle(ne,hi(o.legend.tickColor),1,.5);const ge=If({color:o.legend.labelColor,size:o.legend.labelFontSize,fontWeight:o.legend.labelFontWeight,fontFamily:o.legend.labelFontFamily}),Ae=E+V.left;ee.forEach(_=>{let de=W+V.top+V.height-(_-Y)/O*V.height;de===W+V.top?de+=ne/2:de===W+V.top+V.height&&(de-=ne/2),F.moveTo(Ae-3,de),F.lineTo(Ae,de);const Ze=new e.libraries.PIXI.Text(_,ge);Ze.anchor.x=1,Ze.anchor.y=.5,Ze.position.x=Ae-6,Ze.position.y=de,F.addChild(Ze)}),c.offsetRight=v-E}function Toi(e,i,n,r,o){var l,c,u,f,m;const p=r.spec();if(!Ii(p.color)||p.color.type!=="nominal"||!p.color.legend)return;const v=(l=r.getChannelDomainArray("color"))!=null?l:["___SINGLE_COLOR___"];if(v.length===0)return;const B=p.color.domain,G=p.color.range,T=i.displayedLegends,V=O=>typeof O=="string"?O:O.join();if(T.find(O=>V(O.domain)===V(B)&&V(O.range)===V(G)))return;T.push({domain:B,range:G});const E=i.pBorder,W=10,x=4;let k=x,F=0;const Y=[],L=If({color:o.legend.labelColor,size:o.legend.labelFontSize,fontWeight:o.legend.labelFontWeight,fontFamily:o.legend.labelFontFamily});if((c=p.style)!=null&&c.inlineLegend)v.map(O=>O).reverse().forEach(O=>{if(F>i.dimensions[0])return;const Q=r.encodedValue("color",O),X=new e.libraries.PIXI.Text(O,L);X.anchor.x=1,X.anchor.y=0,X.position.x=i.position[0]+i.dimensions[0]-F-W,X.position.y=i.position[1]+x,E.addChild(X);const $=new e.libraries.PIXI.TextStyle(L),ee=e.libraries.PIXI.TextMetrics.measureText(O,$);k{if(k>i.dimensions[1])return;const Q=r.encodedValue("color",O),X=new e.libraries.PIXI.Text(O,L);X.anchor.x=1,X.anchor.y=0,X.position.x=i.position[0]+i.dimensions[0]-W,X.position.y=i.position[1]+k,E.addChild(X);const $=new e.libraries.PIXI.TextStyle(L),ee=e.libraries.PIXI.TextMetrics.measureText(O,$);F{E.lineStyle(1,hi("black"),0,0),E.beginFill(hi(O.color),1),E.drawCircle(O.x,O.y,4)})}function Roi(e,i,n,r,o){var l;const c=r.spec();if(!Ii(c.row)||c.row.type!=="nominal"||!c.row.legend)return;const u=(l=r.getChannelDomainArray("row"))!=null?l:["___SINGLE_ROW___"];if(u.length===0)return;const f=i.pBorder,m=4,p=2,v=If({color:o.legend.labelColor,size:o.legend.labelFontSize,fontWeight:o.legend.labelFontWeight,fontFamily:o.legend.labelFontFamily});u.forEach(B=>{const G=r.encodedValue("row",B),T=new e.libraries.PIXI.Text(B,v);T.anchor.x=0,T.anchor.y=0,T.position.x=i.position[0]+m,T.position.y=i.position[1]+G+p,f.addChild(T);const V=new e.libraries.PIXI.TextStyle(v),E=e.libraries.PIXI.TextMetrics.measureText(B,V);f.beginFill(hi(o.legend.background),o.legend.backgroundOpacity),f.lineStyle(1,hi(o.legend.backgroundStroke),0,0),f.drawRect(i.position[0]+1,i.position[1]+G+1,E.width+m*2,E.height+p*2)})}const Dre=8,N9=6;function Voi(e,i,n,r,o){var l;const c=r.spec(),u=c.layout==="circular",f=r.getChannelDomainArray("y"),m=r.getChannelRangeArray("y");if(u||!r.isShowYAxis()||!f||!m||!zIe(f))return;const[p,v]=i.dimensions,[B,G]=i.position,T=(l=r.getChannelDomainArray("row"))!=null?l:["___SINGLE_ROW___"];if(!YLe(T))return;const V=v/T.length;if(V<=20)return;const E=r.spec().y,W=!(Ii(E)&&"axis"in E&&E.axis==="right"),x=dv().domain(f).range(m),k=i.pBorder;T.forEach(F=>{const Y=r.encodedValue("row",F),L=W?B:B+p,O=G+Y;k.lineStyle(1,hi(o.axis.baselineColor),1,.5),k.moveTo(L,O),k.lineTo(L,O+V);const Q=Math.max(Math.ceil(V/40),1);let X=x.ticks(Q).filter(ne=>f[0]<=ne&&ne<=f[1]);X.length===1&&(X=x.ticks(Q+1).filter(ne=>f[0]<=ne&&ne<=f[1])),k.lineStyle(1,hi(o.axis.tickColor),1,.5);let $=W?L+N9:L-N9;X.forEach(ne=>{const ge=x(ne);k.moveTo(L,O+V-ge),k.lineTo($,O+V-ge)}),$=W?L+Dre:L-Dre,k.moveTo(L,O),k.lineTo($,O),k.moveTo(L,O+V),k.lineTo($,O+V);const ee=If({color:o.axis.labelColor,size:o.axis.labelFontSize,fontFamily:o.axis.labelFontFamily,fontWeight:o.axis.labelFontWeight});X.forEach(ne=>{const ge=x(ne);$=W?L+N9*2:L-N9*2;const Ae=new e.libraries.PIXI.Text(ne,ee);Ae.anchor.x=W?0:1,Ae.anchor.y=ge===0?.9:.5,Ae.position.x=$,Ae.position.y=O+V-ge,c.orientation==="vertical"&&(Ae.anchor.x=W?1:0,Ae.scale.x*=-1),k.addChild(Ae)})})}function Eoi(e,i,n,r,o){var l,c,u,f,m;const p=r.spec(),v=p.layout==="circular",B=r.getChannelDomainArray("y"),G=r.getChannelRangeArray("y");if(!v||!r.isShowYAxis()||!B||!G||!zIe(B))return;const[T,V]=i.dimensions,E=(l=p.innerRadius)!=null?l:220,W=(c=p.outerRadius)!=null?c:300,x=W-E,k=(u=p.startAngle)!=null?u:0,F=(f=p.endAngle)!=null?f:360,Y=T/2,L=V/2,O=(m=r.getChannelDomainArray("row"))!=null?m:["___SINGLE_ROW___"],Q=V/O.length;if(Q/V*x<=20)return;const X=r.spec().y,$=!(Ii(X)&&"axis"in X&&X.axis==="right"),ee=dv().domain(B).range(G),ne=n.graphics;O.forEach(ge=>{const Ae=r.encodedValue("row",ge),_=W-(Ae+Q)/V*x,de=W-Ae/V*x,Ze=Qi($?0:T,T,_,Y,L,k,F),me=Qi($?0:T,T,de,Y,L,k,F);ne.lineStyle(1,hi(o.axis.baselineColor),1,.5),ne.moveTo(Ze.x,Ze.y),ne.lineTo(me.x,me.y);const be=rt=>N9*T/2/Math.PI/rt,Ee=rt=>Dre*T/2/Math.PI/rt,Je=Q/V*x,Ue=Math.max(Math.ceil(Je/40),1);let dt=ee.ticks(Ue).filter(rt=>B[0]<=rt&&rt<=B[1]);dt.length===1&&(dt=ee.ticks(Ue+1).filter(rt=>B[0]<=rt&&rt<=B[1])),ne.lineStyle(1,hi(o.axis.tickColor),1,.5),dt.forEach(rt=>{const ke=ee(rt),ze=W-(Ae+Q-ke)/V*x,je=$?0:T-be(ze),lt=$?be(ze):T,xe=Qi(je,T,ze,Y,L,k,F),it=Jr(je,T,k,F),Ct=Jr(lt,T,k,F);ne.moveTo(xe.x,xe.y),ne.arc(Y,L,ze,it,Ct,!0),ne.arc(Y,L,ze,Ct,it,!1),ne.closePath()});{const rt=$?0:T-Ee(E),ke=$?Ee(E):T,ze=Jr(rt,T,k,F),je=Jr(ke,T,k,F);ne.moveTo(Ze.x,Ze.y),ne.arc(Y,L,E,ze,je,!0),ne.arc(Y,L,E,je,ze,!1),ne.closePath()}{const rt=$?0:T-Ee(W),ke=$?Ee(W):T,ze=Jr(rt,T,k,F),je=Jr(ke,T,k,F);ne.moveTo(me.x,me.y),ne.arc(Y,L,W,ze,je,!0),ne.arc(Y,L,W,je,ze,!1),ne.closePath()}dt.forEach(rt=>{const ke=ee(rt),ze=W-(Ae+Q-ke)/V*x,je=Qi(be(ze)*2,T,ze,Y,L,k,F),lt=If({color:o.axis.labelColor,size:o.axis.labelFontSize,fontFamily:o.axis.labelFontFamily,fontWeight:o.axis.labelFontWeight}),xe=new e.libraries.PIXI.Text(rt,lt);xe.anchor.x=$?1:0,xe.anchor.y=.5,xe.position.x=je.x,xe.position.y=je.y,xe.resolution=4;const it=new e.libraries.PIXI.TextStyle(lt),It=e.libraries.PIXI.TextMetrics.measureText(xe.text,it).width/(2*ze*Math.PI)*T*360/(F-k),Et=$?be(ze)*2:T-be(ze)*2-It,Zt=$?be(ze)*2+It:T-be(ze)*2,zt=[];for(let Ut=Zt;Ut>=Et;Ut-=It/10){const ti=Qi(Ut,T,ze,Y,L,k,F);zt.push(new e.libraries.PIXI.Point(ti.x,ti.y))}xe.updateText();const Kt=new e.libraries.PIXI.SimpleRope(xe.texture,zt);ne.addChild(Kt)})})}function Hoi(e,i,n){var r,o,l,c,u,f,m,p,v,B,G,T;const V=i.spec(),[E,W]=e.position,[x,k]=e.dimensions,F=(r=V.innerRadius)!=null?r:220,Y=(o=V.outerRadius)!=null?o:300,L=(l=V.startAngle)!=null?l:0,O=(c=V.endAngle)!=null?c:360,Q=E+x/2,X=W+k/2,$=Qi(0,x,F,Q,X,L,O),ee=Jr(0,x,L,O),ne=Jr(x,x,L,O),ge=e.pBackground;V.layout==="circular"&&V.mark==="withinLink"||(ge.lineStyle((u=V.style)!=null&&u.outlineWidth?((f=V.style)==null?void 0:f.outlineWidth)/2.5:0,hi((p=(m=V.style)==null?void 0:m.outline)!=null?p:"#DBDBDB"),1,1),ge.beginFill(hi((B=(v=i.spec().style)==null?void 0:v.background)!=null?B:n.track.background),(T=(G=i.spec().style)==null?void 0:G.backgroundOpacity)!=null?T:!n.track.background||n.track.background==="transparent"?0:1),ge.moveTo($.x,$.y),ge.arc(Q,X,F,ee,ne,!0),ge.arc(Q,X,Y,ne,ee,!1),ge.closePath()),Ii(V.x)&&V.x.axis==="top"&&(ge.lineStyle(.5,hi("black"),0,.5),ge.beginFill(hi("white"),0),ge.moveTo($.x,$.y),ge.arc(Q,X,Y-.5,ee,ne,!0),ge.arc(Q,X,Y,ne,ee,!1),ge.closePath()),ge.lineStyle(.5,hi("black"),0,.5),ge.beginFill(hi("white"),0),ge.moveTo(Q,X),ge.arc(Q,X,Y+3,ee,ne,!1),ge.closePath(),ge.lineStyle(1,hi("#DBDBDB"),0,0),ge.beginFill(hi("white"),0),ge.drawCircle(Q,X,F-1)}function Woi(e,i,n){var r,o,l,c,u,f;const[m,p]=e.position,[v,B]=e.dimensions,G=e.pBackground;if((r=i.spec().style)!=null&&r.background||n.track.background&&n.track.background!=="transparent"){G.clear();const T=(l=(o=i.spec().style)==null?void 0:o.background)!=null?l:n.track.background,V=aXe((c=i.spec().style)==null?void 0:c.backgroundOpacity)?1:(u=i.spec().style)==null?void 0:u.backgroundOpacity;G.lineStyle(1,hi("white"),0,0),G.beginFill(hi(T),V),G.drawRect(m,p,v,B)}if(n.track.alternatingBackground&&n.track.alternatingBackground!=="transparent"){const T=i.spec();if(!Ii(T.row)||T.row.type!=="nominal")return;const V=(f=i.getChannelDomainArray("row"))!=null?f:["___SINGLE_ROW___"];if(V.length===0)return;V.forEach((E,W)=>{var x,k,F,Y;if(W%2===0)return;const L=i.encodedValue("row",E),O=(k=(x=i.spec().style)==null?void 0:x.background)!=null?k:n.track.alternatingBackground,Q=aXe((F=i.spec().style)==null?void 0:F.backgroundOpacity)?1:(Y=i.spec().style)==null?void 0:Y.backgroundOpacity;G.lineStyle(1,hi("white"),0,0),G.beginFill(hi(O),Q),G.drawRect(e.position[0],e.position[1]+L,v,B/V.length)})}}function Noi(e,i,n){var r,o,l,c,u;const f=n.spec();if(!f.width||!f.height){console.warn("Size of a track is not properly determined, so visual mark cannot be rendered");return}const m=n.data(),[p,v]=i.dimensions,B=f.layout==="circular",G=(r=f.innerRadius)!=null?r:220,T=(o=f.outerRadius)!=null?o:300,V=(l=f.startAngle)!=null?l:0,E=(c=f.endAngle)!=null?c:360,W=T-G,x=p/2,k=v/2,F=(u=n.getChannelDomainArray("row"))!=null?u:["___SINGLE_ROW___"],Y=v/F.length;F.forEach(L=>{const O=n.encodedValue("row",L);m.filter(Q=>!Zg(Q,f.row)||Zg(Q,f.row)===L).forEach(Q=>{var X,$;let ee=n.encodedPIXIProperty("x",Q),ne=n.encodedPIXIProperty("xe",Q),ge=n.encodedPIXIProperty("x1",Q),Ae=n.encodedPIXIProperty("x1e",Q);const _=n.encodedPIXIProperty("y",Q),de=n.encodedPIXIProperty("stroke",Q),Ze=n.encodedPIXIProperty("strokeWidth",Q),me=n.encodedPIXIProperty("color",Q),be=n.encodedPIXIProperty("opacity",Q);typeof ne<"u"&&([ee,ne]=[ee,ne].sort((Je,Ue)=>Je-Ue)),typeof ge<"u"&&typeof Ae<"u"&&([ge,Ae]=[ge,Ae].sort((Je,Ue)=>Je-Ue));const Ee=typeof ne<"u"&&typeof ge<"u"&&typeof Ae<"u"&&Math.abs(ee-ne)>.1&&Math.abs(ge-Ae)>.1;if(!Ee&&ne===void 0&&!CI(f)){if(ge===void 0&&Ae===void 0)return;ne=ge!==void 0?ge:Ae}if(!Ee&&Math.abs(ee-ne)<=.1&&Math.abs(ge-Ae)<=.1&&(ee=(ee+ne)/2,ne=(ge+Ae)/2),e.lineStyle(Ze,hi(de),be,.5),Ee){e.beginFill(hi(me==="none"?"white":me),me==="none"?0:be);let[Je,Ue,dt,rt]=[ee,ne,ge,Ae];if([Je,Ue]=[Je,Ue].sort((ke,ze)=>ke-ze),[dt,rt]=[dt,rt].sort((ke,ze)=>ke-ze),Je>p||rt<0||Math.abs(rt-Je)<.5)return;if(B){if(Je<0||rt>p)return;const ke=T-O/v*W,ze=Qi(Je,p,ke,x,k,V,E),je=Qi(Ue,p,ke,x,k,V,E),lt=Qi(dt,p,ke,x,k,V,E),xe=Qi(rt,p,ke,x,k,V,E);e.moveTo(ze.x,ze.y),e.bezierCurveTo(x,k,x,k,xe.x,xe.y),e.arc(x,k,T,ip(xe.x,xe.y,x,k),ip(lt.x,lt.y,x,k),!1),e.bezierCurveTo(x,k,x,k,je.x,je.y),e.arc(x,k,T,ip(je.x,je.y,x,k),ip(ze.x,ze.y,x,k),!1),e.endFill()}else e.moveTo(Je,O),e.lineTo(Ue,O),e.lineTo(rt,O+Y),e.lineTo(dt,O+Y),e.lineTo(Je,O),e.closePath()}else{if(CI(f)){((X=f.style)==null?void 0:X.linkConnectionType)==="curve"?(e.moveTo(ee,0),e.bezierCurveTo(ee/5*4,(O+Y-_)/2,ee/2,(O+Y-_)/5*4,0,O+Y-_)):(($=f.style)==null?void 0:$.linkConnectionType)==="straight"?(e.moveTo(ee,0),e.lineTo(0,O+Y-_)):(e.moveTo(ee,0),e.lineTo(ee,O+Y-_),e.lineTo(0,O+Y-_));return}if(B){let Je,Ue;for(let dt=0;dt<=1;dt+=.02){const rt=xe=>Math.log(xe/(1-xe)),ke=xe=>T-1/(1+Math.exp(rt(xe)))*W+3,ze=(xe,it,Ct)=>((Ct-it)*xe+it)/p,je=x+ke(dt)*Math.cos(-ze(dt,ee,ne)*2*Math.PI-Math.PI/2),lt=k+ke(dt)*Math.sin(-ze(dt,ee,ne)*2*Math.PI-Math.PI/2);Je&&Ue&&(e.lineStyle(Ze,hi(de),be,.5),e.moveTo(Je,Ue),e.lineTo(je,lt)),Je=je,Ue=lt}return}e.moveTo(ne,O+Y),e.lineTo(ee,O)}})})}const Yy=["x","xe","x1","x1e","y","ye","y1","y1e","color","size","row","stroke","strokeWidth","opacity","text"];function koi(e,i,n,r){if(!e||!i||!n||r.spec().mark==="brush")return;if(["x","x1","x1e","xe"].forEach(c=>{r.setChannelScale(c,i._xScale)}),CI(r.spec())||Joi(r.spec())){const c=i._yScale.copy();c.range([c.range()[1],c.range()[0]]),["y","y1","y1e","ye"].forEach(u=>{r.setChannelScale(u,c)})}const[o,l]=i.dimensions;switch(r.spec().mark){case"point":soi(i,n.graphics,r);break;case"bar":Coi(i,n,r);break;case"line":loi(n.graphics,r,o,l);break;case"area":Aoi(e,i,n,r);break;case"rect":uoi(e,i,n,r);break;case"triangleLeft":case"triangleRight":case"triangleBottom":hoi(n.graphics,r,o,l);break;case"text":foi(e,i,n,r);break;case"rule":moi(e,i,n,r);break;case"betweenLink":Noi(n.graphics,i,r);break;case"withinLink":poi(n.graphics,i,r);break;default:console.warn("Unsupported mark type");break}}function Xoi(e,i,n,r,o){if(!e||!i||!n||r.spec().mark==="brush")return;["x","x1","x1e","xe"].forEach(c=>{r.setChannelScale(c,i._xScale)}),r.spec().layout==="circular"?Hoi(i,r,o):(Woi(i,r,o),Soi(i,r,o)),voi(i,r,o)}function xoi(e,i,n,r,o){if(!e||!i||!n||r.spec().mark==="brush")return;["x","x1","x1e","xe"].forEach(c=>{r.setChannelScale(c,i._xScale)}),r.spec().layout==="circular"?(Eoi(e,i,n,r,o),Goi(e,i,n,r,o)):(Voi(e,i,n,r,o),Roi(e,i,n,r,o)),woi(e,i,n,r,o)}function xu(e){if(_Le(e))return[];if(!To(e))return[e];if(e.overlay.length===0)return[{...e,superpose:void 0}];const i=JSON.parse(JSON.stringify(e));delete i.overlay;const n=[];e.overlay.forEach((l,c)=>{const u=Object.assign(JSON.parse(JSON.stringify(i)),l);u.title&&c!==0&&delete u.title,n.push(u)});let r;return n.forEach(l=>{Ii(l.x)&&l.x.axis&&!r&&(r=l.x.axis)}),n.map(l=>({...l,x:{...l.x,axis:r}}))}function Doi(e){return[].concat(...e.map(i=>{if(_Le(i)||!To(i)||i.overlay.length<=1)return[i];if(i.overlay.filter(c=>c.data).length===0)return[i];if(FXe([i.data,...i.overlay.map(c=>c.data)]))return[i];const n=JSON.parse(JSON.stringify(i));delete n.overlay;const r=[],o=JSON.parse(JSON.stringify(n));return o.overlay=[],i.overlay.forEach(c=>{if(o.data||(o.data=c.data),!c.data||FXe([o.data,c.data])){o.overlay.push(c);return}const u=Object.assign(JSON.parse(JSON.stringify(n)),c);r.push(u)}),(o.overlay.length>0?[o,...r]:r).map((c,u,f)=>{const m=u!==0,p=RC(c)&&Ii(c.y)&&!c.y.axis&&m?{...c.y,axis:u===1?"right":"none"}:RC(c)?c.y:void 0;return c.title&&u!==f.length-1&&f.length!==1&&delete c.title,{...c,overlayOnPreviousTrack:m,y:p}})}))}function FXe(e){if(e.length===0)return!1;const i=e.filter(o=>o);if(i.length!==e.length)return!1;const n=Object.keys(i[0]).sort();let r=!0;return n.forEach(o=>{if(Array.from(new Set(i.map(c=>JSON.stringify(c[o])))).length!==1){r=!1;return}}),r}const zK={viridis:oLe,grey:Ani,warm:dni,spectral:gni,cividis:uni,bupu:ani,rdbu:nni,hot:Cni,pink:Ini};function OIe(e){return typeof e=="object"&&e!==null}function QM(e){return OIe(e)&&"getTabularData"in e}function Moi(e,i){var n;return((n=e.dataTransform)!=null?n:[]).some(r=>r.type===i)}function Foi(e="viridis",i=100){var n;const r=(n=zK[e])!=null?n:zK.viridis;return[...Array(i)].map((o,l)=>r(1/i*l))}function KLe(e){return!("alignment"in e)&&!e.tracks.find(i=>i.alignment==="overlay"||"tracks"in i)}function Yoi(e){return"alignment"in e&&e.alignment==="overlay"}function Koi(e){return!KLe(e)&&!Yoi(e)}function _Le(e){return!To(e)&&"data"in e&&!("mark"in e)}function _oi(e){return!!("data"in e&&"overrideTemplate"in e&&e.overrideTemplate)}function YXe(e){return typeof e=="object"}function Poi(e){return"chromosome"in e&&!("interval"in e)}function zoi(e){return!("chromosome"in e)&&"interval"in e}function Ooi(e){return"chromosome"in e&&"interval"in e}function RC(e){return!("overlay"in e)}function To(e){return"overlay"in e}function Loi(e){return"template"in e}function Joi(e){return RC(e)&&!Ii(e.x)&&Ii(e.y)&&e.y.type==="genomic"}function CI(e){const i=RC(e)?e:xu(e)[0];return Ii(i.x)&&i.x.type==="genomic"&&Ii(i.y)&&i.y.type==="genomic"}function Uoi(e){return CI(e)&&e.data.type==="matrix"&&(e.mark==="bar"||e.mark==="rect")&&e.xe&&e.ye}function ZY(e){return e!==null&&typeof e=="object"&&"value"in e}function LIe(e){return e!==void 0&&(e.type==="vector"||e.type==="beddb"||e.type==="multivec"||e.type==="bigwig"||e.type==="matrix"||e.type==="bam"||e.type==="vcf"||e.type==="bed")}function Ii(e){return OIe(e)&&!("value"in e)}function Qoi(e){return"oneOf"in e}function joi(e){return"inRange"in e}function $oi(e){return"include"in e}function KXe(e){return Array.isArray(e)}function qoi(e){return Array.isArray(e)}function MP(e){return(e.mark==="bar"||e.mark==="area"||e.mark==="text")&&Ii(e.color)&&e.color.type==="nominal"&&(!e.row||ZY(e.row))&&Ii(e.y)&&e.y.type==="quantitative"&&!Ii(e.ye)}function eai(e,i){const n=e[i];return MP(e)&&(i==="x"||i==="y")&&Ii(n)&&n.type==="quantitative"}function Zg(e,i){if(Ii(i)&&i.field)return e[i?.field]}function tai(e){const i=[];return Yy.forEach(n=>{const r=e[n];Ii(r)&&"aggregate"in r&&i.push(n)}),i}function gee(e,i){const n=[];return Yy.forEach(r=>{const o=e[r];Ii(o)&&o.type===i&&n.push(r)}),n}function OK(e){if((RC(e)||To(e))&&Ii(e.x)&&e.x.axis&&e.x.axis!=="none")return!0;if(To(e)){let i=!1;return e.overlay.forEach(n=>{i||Ii(n.x)&&n.x.axis&&n.x.axis!=="none"&&(i=!0)}),i}return!1}function iai(e){if((RC(e)||To(e))&&Ii(e.y)&&e.y.axis&&e.y.axis!=="none")return!0;if(To(e)){let i=!1;return e.overlay.forEach(n=>{i||Ii(n.y)&&n.y.axis&&n.y.axis!=="none"&&(i=!0)}),i}return!1}function lG(e){return typeof e=="object"}var jM,nai=new Uint8Array(16);function PLe(){if(!jM&&(jM=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!jM))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return jM(nai)}var rai=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function zLe(e){return typeof e=="string"&&rai.test(e)}var Va=[];for(var oee=0;oee<256;++oee)Va.push((oee+256).toString(16).substr(1));function JIe(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(Va[e[i+0]]+Va[e[i+1]]+Va[e[i+2]]+Va[e[i+3]]+"-"+Va[e[i+4]]+Va[e[i+5]]+"-"+Va[e[i+6]]+Va[e[i+7]]+"-"+Va[e[i+8]]+Va[e[i+9]]+"-"+Va[e[i+10]]+Va[e[i+11]]+Va[e[i+12]]+Va[e[i+13]]+Va[e[i+14]]+Va[e[i+15]]).toLowerCase();if(!zLe(n))throw TypeError("Stringified UUID is invalid");return n}var _Xe,aee,see=0,Iee=0;function LK(e,i,n){var r=i&&n||0,o=i||new Array(16);e=e||{};var l=e.node||_Xe,c=e.clockseq!==void 0?e.clockseq:aee;if(l==null||c==null){var u=e.random||(e.rng||PLe)();l==null&&(l=_Xe=[u[0]|1,u[1],u[2],u[3],u[4],u[5]]),c==null&&(c=aee=(u[6]<<8|u[7])&16383)}var f=e.msecs!==void 0?e.msecs:Date.now(),m=e.nsecs!==void 0?e.nsecs:Iee+1,p=f-see+(m-Iee)/1e4;if(p<0&&e.clockseq===void 0&&(c=c+1&16383),(p<0||f>see)&&e.nsecs===void 0&&(m=0),m>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");see=f,Iee=m,aee=c,f+=122192928e5;var v=((f&268435455)*1e4+m)%4294967296;o[r++]=v>>>24&255,o[r++]=v>>>16&255,o[r++]=v>>>8&255,o[r++]=v&255;var B=f/4294967296*1e4&268435455;o[r++]=B>>>8&255,o[r++]=B&255,o[r++]=B>>>24&15|16,o[r++]=B>>>16&255,o[r++]=c>>>8|128,o[r++]=c&255;for(var G=0;G<6;++G)o[r+G]=l[G];return i||JIe(o)}function gai(e){if(!zLe(e))throw TypeError("Invalid UUID");var i,n=new Uint8Array(16);return n[0]=(i=parseInt(e.slice(0,8),16))>>>24,n[1]=i>>>16&255,n[2]=i>>>8&255,n[3]=i&255,n[4]=(i=parseInt(e.slice(9,13),16))>>>8,n[5]=i&255,n[6]=(i=parseInt(e.slice(14,18),16))>>>8,n[7]=i&255,n[8]=(i=parseInt(e.slice(19,23),16))>>>8,n[9]=i&255,n[10]=(i=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=i/4294967296&255,n[12]=i>>>24&255,n[13]=i>>>16&255,n[14]=i>>>8&255,n[15]=i&255,n}function oai(e){e=unescape(encodeURIComponent(e));for(var i=[],n=0;n>5]>>>o%32&255,c=parseInt(r.charAt(l>>>4&15)+r.charAt(l&15),16);i.push(c)}return i}function LLe(e){return(e+64>>>9<<4)+14+1}function Cai(e,i){e[i>>5]|=128<>5]|=(e[r/8]&255)<>16)+(i>>16)+(n>>16);return r<<16|n&65535}function Aai(e,i){return e<>>32-i}function FP(e,i,n,r,o,l){return np(Aai(np(np(i,e),np(r,l)),o),n)}function cs(e,i,n,r,o,l,c){return FP(i&n|~i&r,e,i,o,l,c)}function As(e,i,n,r,o,l,c){return FP(i&r|n&~r,e,i,o,l,c)}function us(e,i,n,r,o,l,c){return FP(i^n^r,e,i,o,l,c)}function ds(e,i,n,r,o,l,c){return FP(n^(i|~r),e,i,o,l,c)}OLe("v3",48,Iai);function hA(e,i,n){e=e||{};var r=e.random||(e.rng||PLe)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,i){n=n||0;for(var o=0;o<16;++o)i[n+o]=r[o];return i}return JIe(r)}function uai(e,i,n,r){switch(e){case 0:return i&n^~i&r;case 1:return i^n^r;case 2:return i&n^i&r^n&r;case 3:return i^n^r}}function lee(e,i){return e<>>32-i}function dai(e){var i=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){var r=unescape(encodeURIComponent(e));e=[];for(var o=0;o>>0;k=x,x=W,W=lee(E,30)>>>0,E=V,V=L}n[0]=n[0]+V>>>0,n[1]=n[1]+E>>>0,n[2]=n[2]+W>>>0,n[3]=n[3]+x>>>0,n[4]=n[4]+k>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}OLe("v5",80,dai);function Cee(e,i){const n=e?JSON.parse(JSON.stringify(e)):{};return i?Object.assign(n,i):n}function JK(e,i){"tracks"in e?e.tracks.forEach((n,r,o)=>{i(n,r,o),JK(n,i)}):"views"in e&&e.views.forEach(n=>JK(n,i))}function Mre(e,i){"tracks"in e?e.tracks.forEach(n=>{i(n),Mre(n,i)}):"views"in e&&e.views.forEach(n=>{i(n),Mre(n,i)})}function JLe(e,i){"tracks"in e||(i(e),e.views.forEach(n=>{JLe(n,i)}))}function hai(e){if(KLe(e)){const n=JSON.parse(JSON.stringify(e));return delete n.tracks,e.tracks.filter(r=>!r._invalidTrack).map(r=>Object.assign(JSON.parse(JSON.stringify(n)),r))}const i=[];return Koi(e)?e.tracks.filter(n=>!n._invalidTrack).map(n=>{if("alignment"in n)i.push({...n,overlay:[...n.tracks],tracks:void 0,alignment:void 0});else{const r=JSON.parse(JSON.stringify(e));delete r.tracks;const o=Object.assign(JSON.parse(JSON.stringify(r)),n);i.push(o)}}):i.push({...e,overlay:[...e.tracks.filter(n=>!n._invalidTrack)],tracks:void 0,alignment:void 0}),JSON.parse(JSON.stringify(i))}function Fre(e,i){if(i?(e.assembly===void 0&&(e.assembly=i.assembly),e.layout===void 0&&(e.layout=i.layout),e.orientation===void 0&&(e.orientation=i.orientation),e.static===void 0&&(e.static=i.static!==void 0?i.static:!1),e.zoomLimits===void 0&&(e.zoomLimits=i.zoomLimits),e.xDomain===void 0&&(e.xDomain=i.xDomain),e.yDomain===void 0&&(e.yDomain=i.yDomain),e.linkingId===void 0&&(e.linkingId=i.linkingId),e.centerRadius===void 0&&(e.centerRadius=i.centerRadius),e.spacing===void 0&&!("tracks"in e)&&(e.spacing=i.spacing),e.xOffset===void 0&&(e.xOffset=i.xOffset),e.yOffset===void 0&&(e.yOffset=i.yOffset),"views"in e&&"arrangement"in i&&e.arrangement===void 0&&(e.arrangement=i.arrangement),e.style=Cee(i.style,e.style)):(e.assembly===void 0&&(e.assembly="hg38"),e.layout===void 0&&(e.layout="linear"),e.orientation===void 0&&(e.orientation="horizontal"),e.static===void 0&&(e.static=!1),e.zoomLimits===void 0&&(e.zoomLimits=[1,null]),e.centerRadius===void 0&&(e.centerRadius=MLe),e.spacing===void 0&&(e.spacing=vY),"views"in e&&e.arrangement===void 0&&(e.arrangement="vertical"),e.xOffset===void 0&&(e.xOffset=0),e.yOffset===void 0&&(e.yOffset=0)),"tracks"in e){let n=hai(e);n=Doi(n);const r=hA();n.forEach((o,l,c)=>{var u,f,m;if(o.width||(o.width=CI(o)?DXe:roi),o.height||(o.height=CI(o)?DXe:noi),"displacement"in o)if(((u=o.displacement)==null?void 0:u.type)==="pile"&&o.row===void 0&&Ii(o.x)&&o.x.field&&Ii(o.xe)&&o.xe.field){const p=hA(),v=o.x.field,B=o.xe.field,G=o.displacement.padding,T={type:"displace",newField:p,boundingBox:{startField:v,endField:B,padding:G},method:"pile"};o.dataTransform||(o.dataTransform=[]),o.dataTransform=[...o.dataTransform,T],o.row={field:p,type:"nominal"}}else(f=o.displacement)==null||f.type;if(o.layout&&(o.layout=void 0),o.zoomLimits&&(o.zoomLimits=void 0),o.assembly||(o.assembly=e.assembly),o.layout||(o.layout=e.layout),o.orientation||(o.orientation=e.orientation),o.static===void 0&&(o.static=e.static!==void 0?e.static:!1),o.zoomLimits||(o.zoomLimits=e.zoomLimits),o.style=Cee(e.style,o.style),To(o)&&o.overlay.forEach(p=>{p.style=Cee(o.style,p.style)}),(o.layout==="circular"||CI(o))&&o.orientation==="vertical"&&(o.orientation="horizontal"),CI(o)&&(o.layout="linear",(RC(o)||To(o))&&Ii(o.y)&&!o.y.domain?o.y.domain=e.yDomain:To(o)&&o.overlay.forEach(p=>{Ii(p.y)&&!p.y.domain&&(p.y.domain=e.yDomain)})),(RC(o)||To(o))&&Ii(o.x)&&!o.x.domain?o.x.domain=e.xDomain:To(o)&&o.overlay.forEach(p=>{Ii(p.x)&&!p.x.domain&&(p.x.domain=e.xDomain)}),(RC(o)||To(o))&&Ii(o.x)&&!o.x.linkingId)o.x.linkingId=(m=e.linkingId)!=null?m:r;else if(To(o)){let p=!1;o.overlay.forEach(v=>{var B;p||Ii(v.x)&&!v.x.linkingId&&(v.x.linkingId=(B=e.linkingId)!=null?B:r,p=!0)})}l===0&&(o.overlayOnPreviousTrack=!1),(l===0||l!==0&&n.slice(0,l).filter(p=>!p.overlayOnPreviousTrack).length===1&&o.overlayOnPreviousTrack===!0)&&((RC(o)||To(o))&&Ii(o.x)&&!o.x.axis?o.orientation==="vertical"?o.x.axis="left":o.x.axis="top":To(o)&&o.overlay.forEach(p=>{Ii(p.x)&&!p.x.axis&&(o.orientation==="vertical"?p.x.axis="left":p.x.axis="top")})),(RC(o)||To(o))&&Ii(o.x)&&o.x.axis&&o.x.axis!=="none"?o.orientation==="vertical"?o.x.axis==="top"?o.x.axis="left":o.x.axis==="bottom"&&(o.x.axis="right"):o.x.axis==="left"?o.x.axis="top":o.x.axis==="right"&&(o.x.axis="bottom"):To(o)&&o.overlay.forEach(p=>{Ii(p.x)&&p.x.axis&&p.x.axis!=="none"&&(o.orientation==="vertical"?p.x.axis==="top"?p.x.axis="left":p.x.axis==="bottom"&&(p.x.axis="right"):p.x.axis==="left"?p.x.axis="top":p.x.axis==="right"&&(p.x.axis="bottom"))}),l!==0&&(l===c.length-1&&c.slice(0,l+1).filter(p=>p.overlayOnPreviousTrack).lengthp.overlayOnPreviousTrack).length===c.length-l-1&&c.slice(0,l+1).filter(p=>p.overlayOnPreviousTrack).length{p.mark==="withinLink"&&p.flipY===void 0&&(p.flipY=!0)}))),o.overlayOnPreviousTrack&&c[l-1]&&(o.width=c[l-1].width,o.height=c[l-1].height,o.layout=c[l-1].layout,o.assembly=c[l-1].assembly)}),e.tracks=n}else e.views.forEach(n=>{Fre(n,e)})}function fai(e,i){return{data:{type:"vector",url:"",column:e,value:i},mark:"bar",x:{field:e,type:"genomic",axis:"top"},y:{field:i,type:"quantitative"},width:400,height:100}}function mai(e,i,n,r){return r&&r.length<10?{data:{type:"multivec",url:"",row:e,column:i,value:n,categories:r},mark:"bar",x:{field:i,type:"genomic",axis:"top"},y:{field:n,type:"quantitative"},row:{field:e,type:"nominal",legend:!0},color:{field:e,type:"nominal"},width:400,height:100}:{data:{type:"multivec",url:"",row:e,column:i,value:n,categories:r},mark:"rect",x:{field:i,type:"genomic",axis:"top"},row:{field:e,type:"nominal",legend:!0},color:{field:n,type:"quantitative"},width:400,height:100}}function pai(e){JK(e,(i,n,r)=>{var o,l,c,u,f;if(!(!i.data||!LIe(i.data))&&!("alignment"in i)&&_oi(i))switch(i.data.type){case"vector":case"bigwig":r[n]=Object.assign(fai((o=i.data.column)!=null?o:"position",(l=i.data.value)!=null?l:"value"),i);break;case"multivec":r[n]=Object.assign(mai((c=i.data.row)!=null?c:"category",(u=i.data.column)!=null?u:"position",(f=i.data.value)!=null?f:"value",i.data.categories),i);break}})}const bai=[{name:"gene",channels:[{name:"startPosition",type:"genomic",required:!0},{name:"endPosition",type:"genomic",required:!0},{name:"strandColor",type:"nominal",required:!0},{name:"strandRow",type:"nominal",required:!0},{name:"opacity",type:"value",required:!1},{name:"geneHeight",type:"value",required:!1},{name:"geneLabel",type:"nominal",required:!0},{name:"geneLabelColor",type:"nominal",required:!0},{name:"geneLabelFontSize",type:"value",required:!1},{name:"geneLabelStroke",type:"value",required:!1},{name:"geneLabelStrokeThickness",type:"value",required:!1},{name:"geneLabelOpacity",type:"value",required:!1},{name:"type",type:"nominal",required:!0}],mapping:[{dataTransform:[{type:"filter",base:"type",oneOf:["gene"]},{type:"filter",base:"strandColor",oneOf:["-"]}],mark:"triangleLeft",x:{base:"startPosition",type:"genomic"},size:{base:"geneHeight",value:12},row:{base:"strandRow",type:"nominal",domain:["+","-"]},color:{base:"strandColor",type:"nominal",domain:["+","-"],range:["blue","red"]},opacity:{base:"opacity",value:.4},style:{align:"right"}},{dataTransform:[{type:"filter",base:"type",oneOf:["gene"]},{type:"filter",base:"strandColor",oneOf:["+"]}],mark:"triangleRight",x:{base:"endPosition",type:"genomic"},size:{base:"geneHeight",value:12},row:{base:"strandRow",type:"nominal",domain:["+","-"]},color:{base:"strandColor",type:"nominal",domain:["+","-"],range:["blue","red"]},opacity:{base:"opacity",value:.4},style:{align:"left"}},{dataTransform:[{type:"filter",base:"type",oneOf:["exon"]}],mark:"rect",x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},size:{base:"geneHeight",value:12},row:{base:"strandRow",type:"nominal",domain:["+","-"]},color:{base:"strandColor",type:"nominal",domain:["+","-"],range:["blue","red"]},opacity:{base:"opacity",value:.4}},{dataTransform:[{type:"filter",base:"type",oneOf:["gene"]},{type:"filter",base:"strandColor",oneOf:["+"]}],mark:"rect",x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},row:{base:"strandRow",type:"nominal",domain:["+","-"]},color:{base:"strandColor",type:"nominal",domain:["+","-"],range:["blue","red"]},opacity:{base:"opacity",value:.4},size:{value:3}},{dataTransform:[{type:"filter",base:"type",oneOf:["gene"]},{type:"filter",base:"strandColor",oneOf:["-"]}],mark:"rect",x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},row:{base:"strandRow",type:"nominal",domain:["+","-"]},color:{base:"strandColor",type:"nominal",domain:["+","-"],range:["blue","red"]},opacity:{base:"opacity",value:.4},size:{value:3}},{dataTransform:[{type:"filter",base:"type",oneOf:["gene"]}],mark:"text",text:{base:"geneLabel",type:"nominal"},x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},row:{base:"strandRow",type:"nominal",domain:["+","-"]},color:{base:"geneLabelColor",type:"nominal",domain:["+","-"],range:["blue","red"]},opacity:{base:"opacity",value:1},size:{base:"geneLabelFontSize",value:18},stroke:{base:"geneLabelStroke",value:"white"},strokeWidth:{base:"geneLabelStrokeThickness",value:2},visibility:[{operation:"less-than",measure:"width",threshold:"|xe-x|",transitionPadding:10,target:"mark"}]}]},{name:"ideogram",channels:[{name:"startPosition",type:"genomic",required:!0},{name:"endPosition",type:"genomic",required:!0},{name:"chrHeight",type:"value",required:!1},{name:"name",type:"nominal",required:!0},{name:"stainBackgroundColor",type:"nominal",required:!0},{name:"stainLabelColor",type:"nominal",required:!0},{name:"stainStroke",type:"value",required:!1},{name:"stainStrokeWidth",type:"value",required:!1}],mapping:[{mark:"rect",dataTransform:[{type:"filter",base:"stainBackgroundColor",oneOf:["acen"],not:!0}],color:{base:"stainBackgroundColor",type:"nominal",domain:["gneg","gpos25","gpos50","gpos75","gpos100","gvar","acen"],range:["white","lightgray","gray","gray","black","#7B9CC8","#DC4542"]},size:{base:"chrHeight",value:18},x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},stroke:{base:"stainStroke",value:"gray"},strokeWidth:{base:"stainStrokeWidth",value:.3}},{mark:"triangleRight",dataTransform:[{type:"filter",base:"stainBackgroundColor",oneOf:["acen"]},{type:"filter",base:"name",include:"q"}],color:{base:"stainBackgroundColor",type:"nominal",domain:["gneg","gpos25","gpos50","gpos75","gpos100","gvar","acen"],range:["white","lightgray","gray","gray","black","#7B9CC8","#DC4542"]},size:{base:"chrHeight",value:18},x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},stroke:{base:"stainStroke",value:"gray"},strokeWidth:{base:"stainStrokeWidth",value:.3}},{mark:"triangleLeft",dataTransform:[{type:"filter",base:"stainBackgroundColor",oneOf:["acen"]},{type:"filter",base:"name",include:"p"}],color:{base:"stainBackgroundColor",type:"nominal",domain:["gneg","gpos25","gpos50","gpos75","gpos100","gvar","acen"],range:["white","lightgray","gray","gray","black","#7B9CC8","#DC4542"]},size:{base:"chrHeight",value:18},x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},stroke:{base:"stainStroke",value:"gray"},strokeWidth:{base:"stainStrokeWidth",value:.3}},{mark:"text",dataTransform:[{type:"filter",base:"stainLabelColor",oneOf:["acen"],not:!0}],color:{base:"stainLabelColor",type:"nominal",domain:["gneg","gpos25","gpos50","gpos75","gpos100","gvar"],range:["black","black","black","black","white","black"]},text:{base:"name",type:"nominal"},x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},visibility:[{operation:"less-than",measure:"width",threshold:"|xe-x|",transitionPadding:10,target:"mark"}]}]},{name:"sequence",channels:[{name:"startPosition",type:"genomic",required:!0},{name:"endPosition",type:"genomic",required:!0},{name:"barLength",type:"quantitative",required:!0},{name:"baseBackground",type:"nominal",required:!0},{name:"baseLabelColor",type:"nominal",required:!0},{name:"baseLabelFontSize",type:"value",required:!1}],mapping:[{mark:"bar",x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},y:{base:"barLength",type:"quantitative",axis:"none"},color:{base:"baseBackground",type:"nominal",domain:["A","T","G","C"]}},{dataTransform:[{type:"filter",base:"barLength",oneOf:[0],not:!0}],mark:"text",x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},color:{base:"baseLabelColor",type:"nominal",domain:["A","T","G","C"],range:["white"]},text:{base:"baseBackground",type:"nominal"},size:{base:"baseLabelFontSize",value:18},visibility:[{operation:"less-than",measure:"width",threshold:"|xe-x|",transitionPadding:30,target:"mark"},{operation:"LT",measure:"zoomLevel",threshold:10,target:"track"}]}]}];function yai(e,i){JK(e,(n,r,o)=>{var l,c;if(!Loi(n))return;const{template:u}=n,f=i.find(B=>B.name===u);if(!f){n._invalidTrack=!0,console.warn(`There is no track template named '${u}'`);return}let m=!0;if(f.channels.forEach(B=>{B.required&&(!n.encoding||!(B.name in n.encoding))&&(m=!1,console.warn(`A template spec ('${u}') does not contain a required channel, ${B.name}`))}),!m){n._invalidTrack=!0;return}const p=JSON.parse(JSON.stringify(n));"encoding"in p&&delete p.encoding;const v={...p,alignment:"overlay",tracks:[],width:(l=n.width)!=null?l:100,height:(c=n.height)!=null?c:100};f.mapping.forEach(B=>{const G={data:n.data,mark:B.mark},{dataTransform:T}=B;T&&T.map(E=>{const W=E.base;W&&n.encoding&&W in n.encoding&&"field"in n.encoding[W]&&(delete E.base,E.field=n.encoding[W].field)});const V=n.encoding;V?Object.keys(B).filter(E=>E!=="mark").forEach(E=>{const W=JSON.parse(JSON.stringify(B[E]));if("base"in W){const x=W.base;if(x in V){const k=JSON.parse(JSON.stringify(V[x]));delete W.base;const F=Object.assign(W,JSON.parse(JSON.stringify(k)));G[E]=F}else delete W.base,G[E]=W}else G[E]=W}):Object.keys(B).filter(E=>E!=="mark").forEach(E=>{const W=JSON.parse(JSON.stringify(B[E]));"base"in W&&delete W.base,G[E]=W}),v.tracks.push(G)}),o[r]=v})}function vai(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function UK(e,i){if((n=(e=i?e.toExponential(i-1):e.toExponential()).indexOf("e"))<0)return null;var n,r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function Yre(e){return e=UK(Math.abs(e)),e?e[1]:NaN}function Zai(e,i){return function(n,r){for(var o=n.length,l=[],c=0,u=e[0],f=0;o>0&&u>0&&(f+u+1>r&&(u=Math.max(1,r-f)),l.push(n.substring(o-=u,o+u)),!((f+=u+1)>r));)u=e[c=(c+1)%e.length];return l.reverse().join(i)}}function Bai(e){return function(i){return i.replace(/[0-9]/g,function(n){return e[+n]})}}var Gai=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Kre(e){if(!(i=Gai.exec(e)))throw new Error("invalid format: "+e);var i;return new UIe({fill:i[1],align:i[2],sign:i[3],symbol:i[4],zero:i[5],width:i[6],comma:i[7],precision:i[8]&&i[8].slice(1),trim:i[9],type:i[10]})}Kre.prototype=UIe.prototype;function UIe(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}UIe.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Sai(e){e:for(var i=e.length,n=1,r=-1,o;n0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(o+1):e}var ULe;function wai(e,i){var n=UK(e,i);if(!n)return e+"";var r=n[0],o=n[1],l=o-(ULe=Math.max(-8,Math.min(8,Math.floor(o/3)))*3)+1,c=r.length;return l===c?r:l>c?r+new Array(l-c+1).join("0"):l>0?r.slice(0,l)+"."+r.slice(l):"0."+new Array(1-l).join("0")+UK(e,Math.max(0,i+l-1))[0]}function PXe(e,i){var n=UK(e,i);if(!n)return e+"";var r=n[0],o=n[1];return o<0?"0."+new Array(-o).join("0")+r:r.length>o+1?r.slice(0,o+1)+"."+r.slice(o+1):r+new Array(o-r.length+2).join("0")}var zXe={"%":(e,i)=>(e*100).toFixed(i),b:e=>Math.round(e).toString(2),c:e=>e+"",d:vai,e:(e,i)=>e.toExponential(i),f:(e,i)=>e.toFixed(i),g:(e,i)=>e.toPrecision(i),o:e=>Math.round(e).toString(8),p:(e,i)=>PXe(e*100,i),r:PXe,s:wai,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function OXe(e){return e}var LXe=Array.prototype.map,JXe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Tai(e){var i=e.grouping===void 0||e.thousands===void 0?OXe:Zai(LXe.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",r=e.currency===void 0?"":e.currency[1]+"",o=e.decimal===void 0?".":e.decimal+"",l=e.numerals===void 0?OXe:Bai(LXe.call(e.numerals,String)),c=e.percent===void 0?"%":e.percent+"",u=e.minus===void 0?"−":e.minus+"",f=e.nan===void 0?"NaN":e.nan+"";function m(v){v=Kre(v);var B=v.fill,G=v.align,T=v.sign,V=v.symbol,E=v.zero,W=v.width,x=v.comma,k=v.precision,F=v.trim,Y=v.type;Y==="n"?(x=!0,Y="g"):zXe[Y]||(k===void 0&&(k=12),F=!0,Y="g"),(E||B==="0"&&G==="=")&&(E=!0,B="0",G="=");var L=V==="$"?n:V==="#"&&/[boxX]/.test(Y)?"0"+Y.toLowerCase():"",O=V==="$"?r:/[%p]/.test(Y)?c:"",Q=zXe[Y],X=/[defgprs%]/.test(Y);k=k===void 0?6:/[gprs]/.test(Y)?Math.max(1,Math.min(21,k)):Math.max(0,Math.min(20,k));function $(ee){var ne=L,ge=O,Ae,_,de;if(Y==="c")ge=Q(ee)+ge,ee="";else{ee=+ee;var Ze=ee<0||1/ee<0;if(ee=isNaN(ee)?f:Q(Math.abs(ee),k),F&&(ee=Sai(ee)),Ze&&+ee==0&&T!=="+"&&(Ze=!1),ne=(Ze?T==="("?T:u:T==="-"||T==="("?"":T)+ne,ge=(Y==="s"?JXe[8+ULe/3]:"")+ge+(Ze&&T==="("?")":""),X){for(Ae=-1,_=ee.length;++Ae<_;)if(de=ee.charCodeAt(Ae),48>de||de>57){ge=(de===46?o+ee.slice(Ae+1):ee.slice(Ae))+ge,ee=ee.slice(0,Ae);break}}}x&&!E&&(ee=i(ee,1/0));var me=ne.length+ee.length+ge.length,be=me>1)+ne+ee+ge+be.slice(me);break;default:ee=be+ne+ee+ge;break}return l(ee)}return $.toString=function(){return v+""},$}function p(v,B){var G=m((v=Kre(v),v.type="f",v)),T=Math.max(-8,Math.min(8,Math.floor(Yre(B)/3)))*3,V=Math.pow(10,-T),E=JXe[8+T/3];return function(W){return G(V*W)+E}}return{format:m,formatPrefix:p}}var $M,QLe,jLe;Rai({thousands:",",grouping:[3],currency:["$",""]});function Rai(e){return $M=Tai(e),QLe=$M.format,jLe=$M.formatPrefix,$M}function Vai(e,i){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Yre(i)/3)))*3-Yre(Math.abs(e)))}const cee={chr1:248956422,chr2:242193529,chr3:198295559,chr4:190214555,chr5:181538259,chr6:170805979,chr7:159345973,chr8:145138636,chr9:138394717,chr10:133797422,chr11:135086622,chr12:133275309,chr13:114364328,chr14:107043718,chr15:101991189,chr16:90338345,chr17:83257441,chr18:80373285,chr19:58617616,chr20:64444167,chr21:46709983,chr22:50818468,chrX:156040895,chrY:57227415},Aee={chr1:249250621,chr2:243199373,chr3:198022430,chr4:191154276,chr5:180915260,chr6:171115067,chr7:159138663,chr8:146364022,chr9:141213431,chr10:135534747,chr11:135006516,chr12:133851895,chr13:115169878,chr14:107349540,chr15:102531392,chr16:90354753,chr17:81195210,chr18:78077248,chr19:59128983,chr20:63025520,chr21:48129895,chr22:51304566,chrX:155270560,chrY:59373566,chrM:16571},uee={chr1:247249719,chr2:242951149,chr3:199501827,chr4:191273063,chr5:180857866,chr6:170899992,chr7:158821424,chr8:146274826,chr9:140273252,chr10:135374737,chr11:134452384,chr12:132349534,chr13:114142980,chr14:106368585,chr15:100338915,chr16:88827254,chr17:78774742,chr18:76117153,chr19:63811651,chr20:62435964,chr21:46944323,chr22:49691432,chrX:154913754,chrY:57772954,chrM:16571},dee={chr1:245522847,chr2:243018229,chr3:199505740,chr4:191411218,chr5:180857866,chr6:170975699,chr7:158628139,chr8:146274826,chr9:138429268,chr10:135413628,chr11:134452384,chr12:132449811,chr13:114142980,chr14:106368585,chr15:100338915,chr16:88827254,chr17:78774742,chr18:76117153,chr19:63811651,chr20:62435964,chr21:46944323,chr22:49554710,chrX:154824264,chrY:57701691,chrM:16571},hee={chr1:246127941,chr2:243615958,chr3:199344050,chr4:191731959,chr5:181034922,chr6:170914576,chr7:158545518,chr8:146308819,chr9:136372045,chr10:135037215,chr11:134482954,chr12:132078379,chr13:113042980,chr14:105311216,chr15:100256656,chr16:90041932,chr17:81860266,chr18:76115139,chr19:63811651,chr20:63741868,chr21:46976097,chr22:49396972,chrX:153692391,chrY:50286555,chrM:16571},fee={chr1:195471971,chr2:182113224,chr3:160039680,chr4:156508116,chr5:151834684,chr6:149736546,chr7:145441459,chr8:129401213,chr9:124595110,chr10:130694993,chr11:122082543,chr12:120129022,chr13:120421639,chr14:124902244,chr15:104043685,chr16:98207768,chr17:94987271,chr18:90702639,chr19:61431566,chrX:171031299,chrY:91744698,chrM:16299},mee={chr1:197195432,chr2:181748087,chr3:159599783,chr4:155630120,chr5:152537259,chr6:149517037,chr7:152524553,chr8:131738871,chr9:124076172,chr10:129993255,chr11:121843856,chr12:121257530,chr13:120284312,chr14:125194864,chr15:103494974,chr16:98319150,chr17:95272651,chr18:90772031,chr19:61342430,chrX:166650296,chrY:15902555,chrM:16299};function QV(e,i){var n;const[r,o]=(n=Object.entries(Sg(i).interval).find(l=>{const[c,u]=l[1];return c<=e&&er.join(" ")).join(` -`),n=new Blob([i],{type:"text/tsv"});return URL.createObjectURL(n)}function Sg(e){if(e&&typeof e=="string"&&e in pee)return pee[e];if(Array.isArray(e)&&e.length!==0){const i=Object.fromEntries(e);return{size:i,interval:Xm(i),total:xm(i),path:Eai(e)}}else return pee.hg38}const Nm=e=>`https://s3.amazonaws.com/gosling-lang.org/data/${e}.chrom.sizes`,pee=Object.freeze({hg38:{size:cee,interval:Xm(cee),total:xm(cee),path:Nm("hg38")},hg19:{size:Aee,interval:Xm(Aee),total:xm(Aee),path:Nm("hg19")},hg18:{size:uee,interval:Xm(uee),total:xm(uee),path:Nm("hg18")},hg17:{size:dee,interval:Xm(dee),total:xm(dee),path:Nm("hg17")},hg16:{size:hee,interval:Xm(hee),total:xm(hee),path:Nm("hg16")},mm10:{size:fee,interval:Xm(fee),total:xm(fee),path:Nm("mm10")},mm9:{size:mee,interval:Xm(mee),total:xm(mee),path:Nm("mm9")},unknown:{size:{chr:Number.MAX_VALUE},interval:{chr:[0,Number.MAX_VALUE]},total:Number.MAX_VALUE,path:Nm("hg38")}});function Hai(e){switch(e){case"hg19":return"OHJakQICQD6gTD7skx4EWA";case"mm10":return"QDutvmyiSrec5nX4pA5WGQ";case"mm9":return"GUm5aBiLRCyz2PsBea7Yzg";case"hg38":default:return"P0PLbQMwTYGy-5uPIQid7A"}}function Xm(e){const i={};return Object.keys(e).reduce((n,r)=>(i[r]=[n,n+e[r]],n+e[r]),0),i}function xm(e){return Object.values(e).reduce((i,n)=>i+n,0)}function Wai(e){const[i,n]=e.split(":");if(n){const[r,o]=n.split("-").map(l=>+l.replace(/,/g,""));if(!Number.isNaN(r)&&!Number.isNaN(o))return{chromosome:i,start:r,end:o}}return{chromosome:i}}class QIe{constructor(i,n,r){this.chromosome=i,this.start=n,this.end=r}static fromString(i){const n=Wai(i);return new QIe(n.chromosome,n.start,n.end)}toAbsoluteCoordinates(i,n=0){const r=Sg(i),o=r.size[this.chromosome],l=r.interval[this.chromosome];if(o===void 0||l===void 0)throw new Error(`Chromosome name ${this.chromosome} is not valid`);let{start:c,end:u}=this;(c===void 0||u===void 0)&&([c,u]=[1,o]);const f=l[0];return[c+f-n,u+f+n]}}function $Le(e,i){var n;function r(...o){if(!new.target)throw new Error('Uncaught TypeError: Class constructor cannot be invoked without "new"');return i(...o)}return r.config={...e,availableOptions:Object.keys((n=e.defaultOptions)!=null?n:{})},r}const Nai=200,kai=6,Xai=2,qLe=7829367,xai=' ',Dai={type:"axis-track",datatype:["multivec","epilogos"],local:!1,orientation:"1d-horizontal",thumbnail:new DOMParser().parseFromString(xai,"text/xml").documentElement,defaultOptions:{innerRadius:340,outerRadius:310,startAngle:0,endAngle:360,width:700,height:700,layout:"linear",labelPosition:"none",labelColor:"black",labelTextOpacity:.4,trackBorderWidth:0,trackBorderColor:"black",tickPositions:"even",fontSize:12,fontFamily:"sans-serif",fontWeight:"normal",color:"#808080",stroke:"#ffffff",backgroundColor:"transparent",showMousePosition:!1,tickColor:qLe}},Mai=(e,i,n)=>{const{absToChr:r,colorToHex:o,pixiTextToSvg:l,svgLine:c,showMousePosition:u}=e.utils;function f(p,v){return Object.assign(new e.libraries.PIXI.Text(p,v),{hashValue:Math.random()})}class m extends e.tracks.PixiTrack{constructor(){super(i,n);const{dataConfig:v,animate:B,chromInfoPath:G,isShowGlobalMousePosition:T}=i;this.searchField=null,this.dataConfig=v,this.allTexts=[],this.pTicksCircular=new e.libraries.PIXI.Graphics,this.pTicks=new e.libraries.PIXI.Graphics,this.pMain.addChild(this.pTicks),this.pMain.addChild(this.pTicksCircular),this.gTicks={},this.tickTexts={},this.options=n,this.isShowGlobalMousePosition=T,this.pixiTextConfig=If({size:+this.options.fontSize,fontFamily:this.options.fontFamily,fontWeight:this.options.fontWeight,color:this.options.color,stroke:this.options.stroke,strokeThickness:2}),this.stroke=o(this.pixiTextConfig.stroke),this.tickWidth=Nai,this.tickHeight=kai,this.tickTextSeparation=Xai,this.tickColor=o(this.options.tickColor),this.animate=B,this.pubSubs=[],this.options.showMousePosition&&!this.hideMousePosition&&(this.hideMousePosition=u(this,this.is2d,this.isShowGlobalMousePosition()));let V=G;V||(V=`${v.server}/chrom-sizes/?id=${v.tilesetUid}`);const E=this.options.assembly,W={},x={...Sg(E).size},k=[];Object.keys(Sg(E).size).forEach(F=>{W[F]={chr:F,pos:Sg(E).size[F]}}),Object.keys(Sg(E).interval).forEach(F=>{k.push({chr:F,pos:Sg(E).interval[F][0]})}),this.chromInfo={chrPositions:W,chromLengths:x,cumPositions:k},this.rerender(this.options,!0),this.draw(),this.animate()}initBoundsTicks(){this.pTicks&&(this.pMain.removeChild(this.pTicks),this.pTicks=null),this.gBoundTicks||(this.gBoundTicks=new e.libraries.PIXI.Graphics,this.leftBoundTick=f("",this.pixiTextConfig),this.rightBoundTick=f("",this.pixiTextConfig),this.gBoundTicks.addChild(this.leftBoundTick),this.gBoundTicks.addChild(this.rightBoundTick),this.pMain.addChild(this.gBoundTicks)),this.texts=[]}initChromLabels(){this.chromInfo&&(this.gBoundTicks&&(this.pMain.removeChild(this.gBoundTicks),this.gBoundTicks=void 0),this.pTicks||(this.pTicks=new e.libraries.PIXI.Graphics,this.pMain.addChild(this.pTicks)),this.texts=[],this.pTicks.removeChildren(),this.chromInfo.cumPositions.forEach(v=>{var B,G,T;const V=v.chr;this.gTicks[V]=new e.libraries.PIXI.Graphics,this.tickTexts[V]||(this.tickTexts[V]=[]);const E=f(V,this.pixiTextConfig);(B=this.pTicks)==null||B.addChild(E),(G=this.pTicks)==null||G.addChild(this.gTicks[V]),(T=this.texts)==null||T.push(E)}))}rerender(v,B){const G=JSON.stringify(v);!B&&G===this.prevOptions||(this.prevOptions=G,this.options=v,this.pixiTextConfig.fontSize=+this.options.fontSize?`${+this.options.fontSize}px`:this.pixiTextConfig.fontSize,this.pixiTextConfig.fill=this.options.color||this.pixiTextConfig.fill,this.pixiTextConfig.stroke=this.options.stroke||this.pixiTextConfig.stroke,this.stroke=o(this.pixiTextConfig.stroke),this.tickColor=this.options.tickColor?o(this.options.tickColor):qLe,this.options.tickPositions==="ends"&&this.options.layout!=="circular"?this.initBoundsTicks():this.initChromLabels(),super.rerender(v,B),this.options.showMousePosition&&!this.hideMousePosition&&(this.hideMousePosition=u(this,this.is2d,this.isShowGlobalMousePosition())),!this.options.showMousePosition&&this.hideMousePosition&&(this.hideMousePosition(),this.hideMousePosition=void 0))}formatTick(v){if(isNaN(v))return"null";const B=this._xScale.domain(),G=B[1]-B[0],T=Vai(v,G),V=QLe(","),E=jLe(`,.${T}`,G);let W=V;return this.options.tickFormat==="si"?W=E:this.options.tickFormat==="plain"?W=V:this.options.tickPositions==="ends"&&(W=E),W(v)}drawBoundsTicks(v,B){if(!this.gBoundTicks||!this.leftBoundTick||!this.rightBoundTick)return;const G=this.gBoundTicks;G.clear(),G.lineStyle(1,0);const T=this.options.reverseOrientation?0:this.dimensions[1],V=this.options.reverseOrientation?this.tickHeight:this.dimensions[1]-this.tickHeight;G.moveTo(1,T),G.lineTo(1,V),G.moveTo(this.dimensions[0]-1,T),G.lineTo(this.dimensions[0]-1,V),this.leftBoundTick.x=0,this.leftBoundTick.y=this.options.reverseOrientation?V+this.tickTextSeparation:V-this.tickTextSeparation,this.leftBoundTick.text=this.options.assembly==="unknown"?`${this.formatTick(v[1])}`:`${v[0]}: ${this.formatTick(v[1])}`,this.leftBoundTick.anchor.y=this.options.reverseOrientation?0:1,this.rightBoundTick.x=this.dimensions[0],this.rightBoundTick.text=this.options.assembly==="unknown"?`${this.formatTick(B[1])}`:`${B[0]}: ${this.formatTick(B[1])}`,this.rightBoundTick.y=this.options.reverseOrientation?V+this.tickTextSeparation:V-this.tickTextSeparation,this.rightBoundTick.anchor.y=this.options.reverseOrientation?0:1,this.rightBoundTick.anchor.x=1,this.flipText&&(this.leftBoundTick.scale.x=-1,this.leftBoundTick.anchor.x=1,this.rightBoundTick.scale.x=-1,this.rightBoundTick.anchor.x=0),this.leftBoundTick.tickLine=[1,this.dimensions[1],1,this.dimensions[1]-this.tickHeight],this.rightBoundTick.tickLine=[this.dimensions[0]-1,this.dimensions[1],this.dimensions[0]-1,this.dimensions[1]-this.tickHeight],this.tickTexts={},this.tickTexts.all=[this.leftBoundTick,this.rightBoundTick]}drawTicks(v){const B=this.gTicks[v.chr];B.visible=!0,B.clear();const G=+this.chromInfo.chromLengths[v.chr],T=Math.max(this._xScale(v.pos),0),V=Math.min(this._xScale(v.pos+G),this.dimensions[0]),E=(V-T)/this.tickWidth,x=dv().domain([Math.max(1,this._xScale.invert(0)-v.pos),Math.min(G,this._xScale.invert(this.dimensions[0])-v.pos)]).range([T,V]).ticks(E).filter(Q=>Number.isInteger(Q)),k=this.tickTexts[v.chr],F=this.tickHeight,Y=0;let L=F+this.tickTextSeparation;for(this.options.reverseOrientation&&(L=this.dimensions[1]-L);k.lengthx.length;){const Q=k.pop();this.gTicks[v.chr].removeChild(Q)}let O=0;for(;OG){const Ae=$-G;$=G,X-=Ae}const ee=[],ne=x+O.height/2+3;for(let Ae=$;Ae>=X;Ae-=Q/10){const _=Qi(Ae,G,ne,G/2,T/2,V,E);ee.push(new e.libraries.PIXI.Point(_.x,_.y))}return ee.length===0?void 0:(v.updateText(),new e.libraries.PIXI.SimpleRope(v.texture,ee))}draw(){if(this.allTexts=[],!this.texts)return;const v=r(this._xScale.domain()[0],this.chromInfo),B=r(this._xScale.domain()[1],this.chromInfo);if(!v||!B){console.warn("Empty chromInfo:",this.dataConfig,this.chromInfo);return}if(this.options.tickPositions==="ends"&&this.options.layout!=="circular"){if(!this.gBoundTicks)return;this.gBoundTicks.visible=!0,this.drawBoundsTicks(v,B);return}if(!this.pTicks)return;const G=this.options.layout==="circular";for(let V=0;V{this.tickTexts[V]&&this.tickTexts[V].forEach(E=>{E.visible=!1})}),this.pTicksCircular.removeChildren();for(let V=v[3];V<=B[3];V++){const E=this.chromInfo.cumPositions[V],W=E.pos+this.chromInfo.chromLengths[E.chr]/2,x=this._xScale(W),k=this.texts[V];k.anchor.x=.5,k.anchor.y=G?.5:this.options.reverseOrientation?0:1;let F;G?(F=this.addCurvedText(k,x),F&&this.pTicksCircular.addChild(F)):(k.x=x,k.y=this.dimensions[1]-T),k.updateTransform(),this.flipText&&(k.scale.x=-1);const Y=this.drawTicks(E);G?Y>0&&F&&this.pTicksCircular.removeChild(F):k.visible=Y<=0,this.allTexts.push({importance:k.hashValue,text:k,rope:F})}this.hideOverlaps(this.allTexts)}hideOverlaps(v){const B=new Yni;v.sort((G,T)=>T.importance-G.importance).forEach(({text:G,rope:T})=>{G.updateTransform();const V=G.getBounds(),E=5,W={minX:V.x-E,minY:V.y-E,maxX:V.x+V.width+E*2,maxY:V.y+V.height+E*2};B.collides(W)?(G.visible=!1,this.options.layout==="circular"&&T&&this.pTicksCircular.removeChild(T)):B.insert(W)})}setPosition(v){super.setPosition(v),[this.pMain.position.x,this.pMain.position.y]=this.position}zoomed(v,B){[...v.domain(),...B.domain()].filter(T=>isNaN(T)).length===0&&(this.xScale(v),this.yScale(B),this.draw())}exportSVG(){let v=null,B=null;super.exportSVG?[B,v]=super.exportSVG():(B=document.createElement("g"),v=B),B.setAttribute("class","chromosome-labels");const G=document.createElement("g");return v.appendChild(G),G.setAttribute("transform",`translate(${this.position[0]},${this.position[1]})`),this.allTexts.filter(T=>T.text.visible).forEach(T=>{const V=l(T.text);G.appendChild(V)}),Object.values(this.tickTexts).forEach(T=>{T.filter(V=>V.visible).forEach(V=>{if(!V.tickLine)return;let E=l(V);G.appendChild(E),E=c(V.x,this.options.reverseOrientation?0:this.dimensions[1],V.x,this.options.reverseOrientation?this.tickHeight:this.dimensions[1]-this.tickHeight,1,this.tickColor);const W=document.createElement("line");W.setAttribute("x1",String(V.tickLine[0])),W.setAttribute("y1",String(V.tickLine[1])),W.setAttribute("x2",String(V.tickLine[2])),W.setAttribute("y2",String(V.tickLine[3])),W.setAttribute("style","stroke: grey"),G.appendChild(E),G.appendChild(W)})}),[B,v]}}return new m};var UXe=$Le(Dai,Mai);function _re(e,...i){if(!new.target)throw new Error('Uncaught TypeError: Class constructor cannot be invoked without "new"');class n extends e.tracks.SVGTrack{constructor(o){var l,c;super(...o);const[u,f]=o,{registerViewportChanged:m,removeViewportChanged:p,setDomainsCallback:v}=u;this.uid=LK(),this.options=f,this.hasFromView=!u.projectionXDomain,this.removeViewportChanged=p,this.setDomainsCallback=v,this.viewportXDomain=this.hasFromView?null:u.projectionXDomain,this.viewportYDomain=this.hasFromView?null:[0,0],this.prevExtent=[0,0],this.RR=.02;const B=[0,Math.PI*1.7];this.circularBrushData=this.getBrushData(B),this.brush=nri().innerRadius((l=this.options.innerRadius)!=null?l:100).outerRadius((c=this.options.outerRadius)!=null?c:200),this.gBrush=this.gMain.append("g").attr("id",`brush-${this.uid}`).selectAll(".brush").data(this.circularBrushData).enter().append("path").attr("class","brush").attr("d",this.brush).attr("fill",this.options.projectionFillColor).attr("stroke",this.options.projectionStrokeColor).attr("fill-opacity",G=>G.type==="brush"?this.options.projectionFillOpacity:0).attr("stroke-opacity",G=>G.type==="brush"?this.options.projectionStrokeOpacity:0).attr("stroke-width",this.options.strokeWidth).style("pointer-events","all").style("cursor",G=>G.cursor).call(this.dragged()),m(this.uid,this.viewportChanged.bind(this)),this.draw()}getBrushData(o){return[{type:"brush",startAngle:o[0],endAngle:o[1],cursor:"grab"},{type:"start",startAngle:o[0],endAngle:o[0]+this.RR,cursor:"move"},{type:"end",startAngle:o[1]-this.RR,endAngle:o[1],cursor:"move"}]}cropExtent(o){let[l,c]=o,u=0;for(;(l>Math.PI*2||c>Math.PI*2||l<0||c<0)&&!(u++>10);)l>Math.PI*2||c>Math.PI*2?(l-=Math.PI*2,c-=Math.PI*2):(l<0||c<0)&&(l+=Math.PI*2,c+=Math.PI*2);return[l,c].sort((f,m)=>f-m)}updateBrush(o){let[l,c]=o;if(l<=Ra&&c<=Ra||l>=Math.PI*2-Ra&&c>=Math.PI*2-Ra){this.gBrush.attr("visibility","hidden");return}lMath.PI*2-Ra&&(l=Math.PI*2-Ra),cMath.PI*2-Ra&&(c=Math.PI*2-Ra),this.circularBrushData=this.getBrushData(o),this.gBrush.data(this.circularBrushData).attr("d",this.brush).attr("visibility","visible")}dragged(){const o=c=>{this.startEvent=c.sourceEvent,this.prevExtent=[this.circularBrushData[0].startAngle,this.circularBrushData[0].endAngle]},l=(c,u)=>{const[f,m]=this.position,[p,v]=this.dimensions,B=c.sourceEvent,G=this.startEvent.layerX-f,T=this.startEvent.layerY-m,V=B.layerX-f,E=B.layerY-m,W=Math.atan2(G-p/2,T-v/2)-Math.atan2(V-p/2,E-v/2);let[x,k]=this.prevExtent;if(u.type==="brush"){if(x=x+W,k=k+W,x$?(k+=X,x+=X):(x-=$,k-=$)}}else u.type==="start"?x=x+W:u.type==="end"&&(k=k+W);if([x,k]=this.cropExtent([x,k]),!this._xScale||!this._yScale)return;const F=(this.options.endAngle-this.options.startAngle)/360,Y=x-this.options.startAngle/360*Math.PI*2,L=k-this.options.startAngle/360*Math.PI*2,O=[this._xScale.invert(p-p*L/(Math.PI*2*F)),this._xScale.invert(p-p*Y/(Math.PI*2*F))],Q=this.viewportYDomain;this.hasFromView||(this.viewportXDomain=O),this.setDomainsCallback(O,Q),this.updateBrush([x,k])};return e.libraries.d3Drag.drag().on("start",o).on("drag",l)}draw(){if(!this._xScale||!this.yScale||!this.viewportXDomain||!this.viewportYDomain)return;const o=this._xScale(this.viewportXDomain[0]),l=this._xScale(this.viewportXDomain[1]),[c]=this.dimensions;let u=Jr(o,c,this.options.startAngle,this.options.endAngle)+Math.PI/2,f=Jr(l,c,this.options.startAngle,this.options.endAngle)+Math.PI/2;[f,u]=this.cropExtent([f,u]),this.updateBrush([f,u])}viewportChanged(o,l){const c=o.domain(),u=l.domain();this.viewportXDomain=c,this.viewportYDomain=u,this.draw()}remove(){this.removeViewportChanged(this.uid),super.remove()}rerender(){}zoomed(o,l){this.xScale(o),this.yScale(l),this.draw()}setPosition(o){super.setPosition(o),this.draw()}setDimensions(o){super.setDimensions(o),this.gBrush.attr("transform",`translate(${o[0]/2},${o[1]/2})`),this.draw()}}return new n(i)}const Fai=' ';_re.config={type:"brush-track",datatype:["projection"],local:!1,projection:!0,orientation:"2d",thumbnail:new DOMParser().parseFromString(Fai,"text/xml").documentElement,availableOptions:["innerRadius","outerRadius","startAngle","endAngle","axisPositionHorizontal","projectionFillColor","projectionStrokeColor","projectionFillOpacity","projectionStrokeOpacity","strokeWidth"],defaultOptions:{innerRadius:100,outerRadius:200,startAngle:0,endAngle:360,axisPositionHorizontal:"left",projectionFillColor:"#777",projectionStrokeColor:"#777",projectionFillOpacity:.3,projectionStrokeOpacity:.7,strokeWidth:1}};var Dp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Pre={exports:{}};/** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */(function(e,i){(function(n,r){r(i)})(Dp,function(n){function r(){for(var st=arguments.length,Le=Array(st),ht=0;ht1){Le[0]=Le[0].slice(0,-1);for(var kt=Le.length-1,Nt=1;Nt= 0x80 (not a basic code point)","invalid-input":"Invalid input"},ee=V-E,ne=Math.floor,ge=String.fromCharCode;function Ae(st){throw new RangeError($[st])}function _(st,Le){for(var ht=[],kt=st.length;kt--;)ht[kt]=Le(st[kt]);return ht}function de(st,Le){var ht=st.split("@"),kt="";ht.length>1&&(kt=ht[0]+"@",st=ht[1]),st=st.replace(X,".");var Nt=st.split("."),Si=_(Nt,Le).join(".");return kt+Si}function Ze(st){for(var Le=[],ht=0,kt=st.length;ht=55296&&Nt<=56319&&ht>1,Le+=ne(Le/ht);Le>ee*W>>1;Nt+=V)Le=ne(Le/ee);return ne(Nt+(ee+1)*Le/(Le+x))},Ue=function(Le){var ht=[],kt=Le.length,Nt=0,Si=Y,Yi=F,Jn=Le.lastIndexOf(L);Jn<0&&(Jn=0);for(var eg=0;eg=128&&Ae("not-basic"),ht.push(Le.charCodeAt(eg));for(var Yg=Jn>0?Jn+1:0;Yg=kt&&Ae("invalid-input");var cn=be(Le.charCodeAt(Yg++));(cn>=V||cn>ne((T-Nt)/Er))&&Ae("overflow"),Nt+=cn*Er;var tg=Tg<=Yi?E:Tg>=Yi+W?W:Tg-Yi;if(cnne(T/eo)&&Ae("overflow"),Er*=eo}var og=ht.length+1;Yi=Je(Nt-kn,og,kn==0),ne(Nt/og)>T-Si&&Ae("overflow"),Si+=ne(Nt/og),Nt%=og,ht.splice(Nt++,0,Si)}return String.fromCodePoint.apply(String,ht)},dt=function(Le){var ht=[];Le=Ze(Le);var kt=Le.length,Nt=Y,Si=0,Yi=F,Jn=!0,eg=!1,Yg=void 0;try{for(var kn=Le[Symbol.iterator](),Er;!(Jn=(Er=kn.next()).done);Jn=!0){var Tg=Er.value;Tg<128&&ht.push(ge(Tg))}}catch(Z0){eg=!0,Yg=Z0}finally{try{!Jn&&kn.return&&kn.return()}finally{if(eg)throw Yg}}var cn=ht.length,tg=cn;for(cn&&ht.push(L);tg=Nt&&Ndne((T-Si)/ZI)&&Ae("overflow"),Si+=(eo-Nt)*ZI,Nt=eo;var tC=!0,kd=!1,tc=void 0;try{for(var v0=Le[Symbol.iterator](),VN;!(tC=(VN=v0.next()).done);tC=!0){var EN=VN.value;if(ENT&&Ae("overflow"),EN==Nt){for(var hZ=Si,fZ=V;;fZ+=V){var mZ=fZ<=Yi?E:fZ>=Yi+W?W:fZ-Yi;if(hZ>6|192).toString(16).toUpperCase()+"%"+(Le&63|128).toString(16).toUpperCase():ht="%"+(Le>>12|224).toString(16).toUpperCase()+"%"+(Le>>6&63|128).toString(16).toUpperCase()+"%"+(Le&63|128).toString(16).toUpperCase(),ht}function xe(st){for(var Le="",ht=0,kt=st.length;ht=194&&Nt<224){if(kt-ht>=6){var Si=parseInt(st.substr(ht+4,2),16);Le+=String.fromCharCode((Nt&31)<<6|Si&63)}else Le+=st.substr(ht,6);ht+=6}else if(Nt>=224){if(kt-ht>=9){var Yi=parseInt(st.substr(ht+4,2),16),Jn=parseInt(st.substr(ht+7,2),16);Le+=String.fromCharCode((Nt&15)<<12|(Yi&63)<<6|Jn&63)}else Le+=st.substr(ht,9);ht+=9}else Le+=st.substr(ht,3),ht+=3}return Le}function it(st,Le){function ht(kt){var Nt=xe(kt);return Nt.match(Le.UNRESERVED)?Nt:kt}return st.scheme&&(st.scheme=String(st.scheme).replace(Le.PCT_ENCODED,ht).toLowerCase().replace(Le.NOT_SCHEME,"")),st.userinfo!==void 0&&(st.userinfo=String(st.userinfo).replace(Le.PCT_ENCODED,ht).replace(Le.NOT_USERINFO,lt).replace(Le.PCT_ENCODED,c)),st.host!==void 0&&(st.host=String(st.host).replace(Le.PCT_ENCODED,ht).toLowerCase().replace(Le.NOT_HOST,lt).replace(Le.PCT_ENCODED,c)),st.path!==void 0&&(st.path=String(st.path).replace(Le.PCT_ENCODED,ht).replace(st.scheme?Le.NOT_PATH:Le.NOT_PATH_NOSCHEME,lt).replace(Le.PCT_ENCODED,c)),st.query!==void 0&&(st.query=String(st.query).replace(Le.PCT_ENCODED,ht).replace(Le.NOT_QUERY,lt).replace(Le.PCT_ENCODED,c)),st.fragment!==void 0&&(st.fragment=String(st.fragment).replace(Le.PCT_ENCODED,ht).replace(Le.NOT_FRAGMENT,lt).replace(Le.PCT_ENCODED,c)),st}function Ct(st){return st.replace(/^0*(.*)/,"$1")||"0"}function It(st,Le){var ht=st.match(Le.IPV4ADDRESS)||[],kt=B(ht,2),Nt=kt[1];return Nt?Nt.split(".").map(Ct).join("."):st}function Et(st,Le){var ht=st.match(Le.IPV6ADDRESS)||[],kt=B(ht,3),Nt=kt[1],Si=kt[2];if(Nt){for(var Yi=Nt.toLowerCase().split("::").reverse(),Jn=B(Yi,2),eg=Jn[0],Yg=Jn[1],kn=Yg?Yg.split(":").map(Ct):[],Er=eg.split(":").map(Ct),Tg=Le.IPV4ADDRESS.test(Er[Er.length-1]),cn=Tg?7:8,tg=Er.length-cn,eo=Array(cn),og=0;og1){var Vf=eo.slice(0,ql.index),Nd=eo.slice(ql.index+ql.length);eC=Vf.join(":")+"::"+Nd.join(":")}else eC=eo.join(":");return Si&&(eC+="%"+Si),eC}else return st}var Zt=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,zt="".match(/(){0}/)[1]===void 0;function Kt(st){var Le=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ht={},kt=Le.iri!==!1?v:p;Le.reference==="suffix"&&(st=(Le.scheme?Le.scheme+":":"")+"//"+st);var Nt=st.match(Zt);if(Nt){zt?(ht.scheme=Nt[1],ht.userinfo=Nt[3],ht.host=Nt[4],ht.port=parseInt(Nt[5],10),ht.path=Nt[6]||"",ht.query=Nt[7],ht.fragment=Nt[8],isNaN(ht.port)&&(ht.port=Nt[5])):(ht.scheme=Nt[1]||void 0,ht.userinfo=st.indexOf("@")!==-1?Nt[3]:void 0,ht.host=st.indexOf("//")!==-1?Nt[4]:void 0,ht.port=parseInt(Nt[5],10),ht.path=Nt[6]||"",ht.query=st.indexOf("?")!==-1?Nt[7]:void 0,ht.fragment=st.indexOf("#")!==-1?Nt[8]:void 0,isNaN(ht.port)&&(ht.port=st.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?Nt[4]:void 0)),ht.host&&(ht.host=Et(It(ht.host,kt),kt)),ht.scheme===void 0&&ht.userinfo===void 0&&ht.host===void 0&&ht.port===void 0&&!ht.path&&ht.query===void 0?ht.reference="same-document":ht.scheme===void 0?ht.reference="relative":ht.fragment===void 0?ht.reference="absolute":ht.reference="uri",Le.reference&&Le.reference!=="suffix"&&Le.reference!==ht.reference&&(ht.error=ht.error||"URI is not a "+Le.reference+" reference.");var Si=je[(Le.scheme||ht.scheme||"").toLowerCase()];if(!Le.unicodeSupport&&(!Si||!Si.unicodeSupport)){if(ht.host&&(Le.domainHost||Si&&Si.domainHost))try{ht.host=ze.toASCII(ht.host.replace(kt.PCT_ENCODED,xe).toLowerCase())}catch(Yi){ht.error=ht.error||"Host's domain name can not be converted to ASCII via punycode: "+Yi}it(ht,p)}else it(ht,kt);Si&&Si.parse&&Si.parse(ht,Le)}else ht.error=ht.error||"URI can not be parsed.";return ht}function Ut(st,Le){var ht=Le.iri!==!1?v:p,kt=[];return st.userinfo!==void 0&&(kt.push(st.userinfo),kt.push("@")),st.host!==void 0&&kt.push(Et(It(String(st.host),ht),ht).replace(ht.IPV6ADDRESS,function(Nt,Si,Yi){return"["+Si+(Yi?"%25"+Yi:"")+"]"})),(typeof st.port=="number"||typeof st.port=="string")&&(kt.push(":"),kt.push(String(st.port))),kt.length?kt.join(""):void 0}var ti=/^\.\.?\//,mi=/^\/\.(\/|$)/,Cn=/^\/\.\.(\/|$)/,on=/^\/?(?:.|\n)*?(?=\/|$)/;function ki(st){for(var Le=[];st.length;)if(st.match(ti))st=st.replace(ti,"");else if(st.match(mi))st=st.replace(mi,"/");else if(st.match(Cn))st=st.replace(Cn,"/"),Le.pop();else if(st==="."||st==="..")st="";else{var ht=st.match(on);if(ht){var kt=ht[0];st=st.slice(kt.length),Le.push(kt)}else throw new Error("Unexpected dot segment condition")}return Le.join("")}function Ei(st){var Le=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ht=Le.iri?v:p,kt=[],Nt=je[(Le.scheme||st.scheme||"").toLowerCase()];if(Nt&&Nt.serialize&&Nt.serialize(st,Le),st.host&&!ht.IPV6ADDRESS.test(st.host)){if(Le.domainHost||Nt&&Nt.domainHost)try{st.host=Le.iri?ze.toUnicode(st.host):ze.toASCII(st.host.replace(ht.PCT_ENCODED,xe).toLowerCase())}catch(Jn){st.error=st.error||"Host's domain name can not be converted to "+(Le.iri?"Unicode":"ASCII")+" via punycode: "+Jn}}it(st,ht),Le.reference!=="suffix"&&st.scheme&&(kt.push(st.scheme),kt.push(":"));var Si=Ut(st,Le);if(Si!==void 0&&(Le.reference!=="suffix"&&kt.push("//"),kt.push(Si),st.path&&st.path.charAt(0)!=="/"&&kt.push("/")),st.path!==void 0){var Yi=st.path;!Le.absolutePath&&(!Nt||!Nt.absolutePath)&&(Yi=ki(Yi)),Si===void 0&&(Yi=Yi.replace(/^\/\//,"/%2F")),kt.push(Yi)}return st.query!==void 0&&(kt.push("?"),kt.push(st.query)),st.fragment!==void 0&&(kt.push("#"),kt.push(st.fragment)),kt.join("")}function Bn(st,Le){var ht=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},kt=arguments[3],Nt={};return kt||(st=Kt(Ei(st,ht),ht),Le=Kt(Ei(Le,ht),ht)),ht=ht||{},!ht.tolerant&&Le.scheme?(Nt.scheme=Le.scheme,Nt.userinfo=Le.userinfo,Nt.host=Le.host,Nt.port=Le.port,Nt.path=ki(Le.path||""),Nt.query=Le.query):(Le.userinfo!==void 0||Le.host!==void 0||Le.port!==void 0?(Nt.userinfo=Le.userinfo,Nt.host=Le.host,Nt.port=Le.port,Nt.path=ki(Le.path||""),Nt.query=Le.query):(Le.path?(Le.path.charAt(0)==="/"?Nt.path=ki(Le.path):((st.userinfo!==void 0||st.host!==void 0||st.port!==void 0)&&!st.path?Nt.path="/"+Le.path:st.path?Nt.path=st.path.slice(0,st.path.lastIndexOf("/")+1)+Le.path:Nt.path=Le.path,Nt.path=ki(Nt.path)),Nt.query=Le.query):(Nt.path=st.path,Le.query!==void 0?Nt.query=Le.query:Nt.query=st.query),Nt.userinfo=st.userinfo,Nt.host=st.host,Nt.port=st.port),Nt.scheme=st.scheme),Nt.fragment=Le.fragment,Nt}function Nr(st,Le,ht){var kt=f({scheme:"null"},ht);return Ei(Bn(Kt(st,kt),Kt(Le,kt),kt,!0),kt)}function kr(st,Le){return typeof st=="string"?st=Ei(Kt(st,Le),Le):l(st)==="object"&&(st=Kt(Ei(st,Le),Le)),st}function Be(st,Le,ht){return typeof st=="string"?st=Ei(Kt(st,ht),ht):l(st)==="object"&&(st=Ei(st,ht)),typeof Le=="string"?Le=Ei(Kt(Le,ht),ht):l(Le)==="object"&&(Le=Ei(Le,ht)),st===Le}function le(st,Le){return st&&st.toString().replace(!Le||!Le.iri?p.ESCAPE:v.ESCAPE,lt)}function ce(st,Le){return st&&st.toString().replace(!Le||!Le.iri?p.PCT_ENCODED:v.PCT_ENCODED,xe)}var Ke={scheme:"http",domainHost:!0,parse:function(Le,ht){return Le.host||(Le.error=Le.error||"HTTP URIs must have a host."),Le},serialize:function(Le,ht){var kt=String(Le.scheme).toLowerCase()==="https";return(Le.port===(kt?443:80)||Le.port==="")&&(Le.port=void 0),Le.path||(Le.path="/"),Le}},ct={scheme:"https",domainHost:Ke.domainHost,parse:Ke.parse,serialize:Ke.serialize};function Wt(st){return typeof st.secure=="boolean"?st.secure:String(st.scheme).toLowerCase()==="wss"}var Mt={scheme:"ws",domainHost:!0,parse:function(Le,ht){var kt=Le;return kt.secure=Wt(kt),kt.resourceName=(kt.path||"/")+(kt.query?"?"+kt.query:""),kt.path=void 0,kt.query=void 0,kt},serialize:function(Le,ht){if((Le.port===(Wt(Le)?443:80)||Le.port==="")&&(Le.port=void 0),typeof Le.secure=="boolean"&&(Le.scheme=Le.secure?"wss":"ws",Le.secure=void 0),Le.resourceName){var kt=Le.resourceName.split("?"),Nt=B(kt,2),Si=Nt[0],Yi=Nt[1];Le.path=Si&&Si!=="/"?Si:void 0,Le.query=Yi,Le.resourceName=void 0}return Le.fragment=void 0,Le}},fn={scheme:"wss",domainHost:Mt.domainHost,parse:Mt.parse,serialize:Mt.serialize},gg={},Xr="[A-Za-z0-9\\-\\.\\_\\~\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]",qn="[0-9A-Fa-f]",Br=o(o("%[EFef]"+qn+"%"+qn+qn+"%"+qn+qn)+"|"+o("%[89A-Fa-f]"+qn+"%"+qn+qn)+"|"+o("%"+qn+qn)),QO="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",jO="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",$O=r(jO,'[\\"\\\\]'),qO="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",eL=new RegExp(Xr,"g"),Rf=new RegExp(Br,"g"),tL=new RegExp(r("[^]",QO,"[\\.]",'[\\"]',$O),"g"),SN=new RegExp(r("[^]",Xr,qO),"g"),iL=SN;function o2(st){var Le=xe(st);return Le.match(eL)?Le:st}var wN={scheme:"mailto",parse:function(Le,ht){var kt=Le,Nt=kt.to=kt.path?kt.path.split(","):[];if(kt.path=void 0,kt.query){for(var Si=!1,Yi={},Jn=kt.query.split("&"),eg=0,Yg=Jn.length;eg=55296&&l<=56319&&o=i)throw new Error("Cannot access property/index "+r+" levels up, current level is "+i);return n[i-r]}if(r>i)throw new Error("Cannot access data "+r+" levels up, current level is "+i);if(l="data"+(i-r||""),!o)return l}for(var u=l,f=o.split("/"),m=0;m=0?{index:r,compiling:!0}:(r=this._compilations.length,this._compilations[r]={schema:e,root:i,baseId:n},{index:r,compiling:!1})}function ysi(e,i,n){var r=sJe.call(this,e,i,n);r>=0&&this._compilations.splice(r,1)}function sJe(e,i,n){for(var r=0;r%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,cJe=/^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i,AJe=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,uJe=/^(?:\/(?:[^~/]|~0|~1)*)*$/,dJe=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,hJe=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,Hsi=PP;function PP(e){return e=e=="full"?"full":"fast",Ssi.copy(PP[e])}PP.fast={date:/^\d\d\d\d-[0-1]\d-[0-3]\d$/,time:/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,"date-time":/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,"uri-template":CJe,url:cJe,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,hostname:lJe,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:pJe,uuid:AJe,"json-pointer":uJe,"json-pointer-uri-fragment":dJe,"relative-json-pointer":hJe};PP.full={date:fJe,time:mJe,"date-time":ksi,uri:xsi,"uri-reference":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3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:pJe,uuid:AJe,"json-pointer":uJe,"json-pointer-uri-fragment":dJe,"relative-json-pointer":hJe};function Wsi(e){return e%4===0&&(e%100!==0||e%400===0)}function fJe(e){var i=e.match(wsi);if(!i)return!1;var n=+i[1],r=+i[2],o=+i[3];return r>=1&&r<=12&&o>=1&&o<=(r==2&&Wsi(n)?29:Tsi[r])}function mJe(e,i){var n=e.match(Rsi);if(!n)return!1;var r=n[1],o=n[2],l=n[3],c=n[5];return(r<=23&&o<=59&&l<=59||r==23&&o==59&&l==60)&&(!i||c)}var Nsi=/t|\s/i;function ksi(e){var i=e.split(Nsi);return i.length==2&&fJe(i[0])&&mJe(i[1],!0)}var Xsi=/\/|:/;function xsi(e){return Xsi.test(e)&&Vsi.test(e)}var Dsi=/[^\\]\\Z/;function pJe(e){if(Dsi.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}var Msi=function(i,n,r){var o=" ",l=i.level,c=i.dataLevel,u=i.schema[n],f=i.errSchemaPath+"/"+n,m=!i.opts.allErrors,p="data"+(c||""),v="valid"+l,B,G;if(u=="#"||u=="#/")i.isRoot?(B=i.async,G="validate"):(B=i.root.schema.$async===!0,G="root.refVal[0]");else{var T=i.resolveRef(i.baseId,u,i.isRoot);if(T===void 0){var V=i.MissingRefError.message(i.baseId,u);if(i.opts.missingRefs=="fail"){i.logger.error(V);var E=E||[];E.push(o),o="",i.createErrors!==!1?(o+=" { keyword: '$ref' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(f)+" , params: { ref: '"+i.util.escapeQuotes(u)+"' } ",i.opts.messages!==!1&&(o+=" , message: 'can\\'t resolve reference "+i.util.escapeQuotes(u)+"' "),i.opts.verbose&&(o+=" , schema: "+i.util.toQuotedString(u)+" , parentSchema: validate.schema"+i.schemaPath+" , data: "+p+" "),o+=" } "):o+=" {} ";var W=o;o=E.pop(),!i.compositeRule&&m?i.async?o+=" throw new ValidationError(["+W+"]); ":o+=" validate.errors = ["+W+"]; return false; ":o+=" var err = "+W+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",m&&(o+=" if (false) { ")}else if(i.opts.missingRefs=="ignore")i.logger.warn(V),m&&(o+=" if (true) { ");else throw new i.MissingRefError(i.baseId,u,V)}else if(T.inline){var x=i.util.copy(i);x.level++;var k="valid"+x.level;x.schema=T.schema,x.schemaPath="",x.errSchemaPath=u;var F=i.validate(x).replace(/validate\.schema/g,T.code);o+=" "+F+" ",m&&(o+=" if ("+k+") { ")}else B=T.$async===!0||i.async&&T.$async!==!1,G=T.code}if(G){var E=E||[];E.push(o),o="",i.opts.passContext?o+=" "+G+".call(this, ":o+=" "+G+"( ",o+=" "+p+", (dataPath || '')",i.errorPath!='""'&&(o+=" + "+i.errorPath);var Y=c?"data"+(c-1||""):"parentData",L=c?i.dataPathArr[c]:"parentDataProperty";o+=" , "+Y+" , "+L+", rootData) ";var O=o;if(o=E.pop(),B){if(!i.async)throw new Error("async schema referenced by sync schema");m&&(o+=" var "+v+"; "),o+=" try { await "+O+"; ",m&&(o+=" "+v+" = true; "),o+=" } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ",m&&(o+=" "+v+" = false; "),o+=" } ",m&&(o+=" if ("+v+") { ")}else o+=" if (!"+O+") { if (vErrors === null) vErrors = "+G+".errors; else vErrors = vErrors.concat("+G+".errors); errors = vErrors.length; } ",m&&(o+=" else { ")}return o},Fsi=function(i,n,r){var o=" ",l=i.schema[n],c=i.schemaPath+i.util.getProperty(n),u=i.errSchemaPath+"/"+n,f=!i.opts.allErrors,m=i.util.copy(i),p="";m.level++;var v="valid"+m.level,B=m.baseId,G=!0,T=l;if(T)for(var V,E=-1,W=T.length-1;E0||V===!1:i.util.schemaHasRules(V,i.RULES.all))&&(G=!1,m.schema=V,m.schemaPath=c+"["+E+"]",m.errSchemaPath=u+"/"+E,o+=" "+i.validate(m)+" ",m.baseId=B,f&&(o+=" if ("+v+") { ",p+="}"));return f&&(G?o+=" if (true) { ":o+=" "+p.slice(0,-1)+" "),o},Ysi=function(i,n,r){var o=" ",l=i.level,c=i.dataLevel,u=i.schema[n],f=i.schemaPath+i.util.getProperty(n),m=i.errSchemaPath+"/"+n,p=!i.opts.allErrors,v="data"+(c||""),B="valid"+l,G="errs__"+l,T=i.util.copy(i),V="";T.level++;var E="valid"+T.level,W=u.every(function(Q){return i.opts.strictKeywords?typeof Q=="object"&&Object.keys(Q).length>0||Q===!1:i.util.schemaHasRules(Q,i.RULES.all)});if(W){var x=T.baseId;o+=" var "+G+" = errors; var "+B+" = false; ";var k=i.compositeRule;i.compositeRule=T.compositeRule=!0;var F=u;if(F)for(var Y,L=-1,O=F.length-1;L0||u===!1:i.util.schemaHasRules(u,i.RULES.all);if(o+="var "+G+" = errors;var "+B+";",Y){var L=i.compositeRule;i.compositeRule=T.compositeRule=!0,T.schema=u,T.schemaPath=f,T.errSchemaPath=m,o+=" var "+E+" = false; for (var "+W+" = 0; "+W+" < "+v+".length; "+W+"++) { ",T.errorPath=i.util.getPathExpr(i.errorPath,W,i.opts.jsonPointers,!0);var O=v+"["+W+"]";T.dataPathArr[x]=W;var Q=i.validate(T);T.baseId=F,i.util.varOccurences(Q,k)<2?o+=" "+i.util.varReplace(Q,k,O)+" ":o+=" var "+k+" = "+O+"; "+Q+" ",o+=" if ("+E+") break; } ",i.compositeRule=T.compositeRule=L,o+=" "+V+" if (!"+E+") {"}else o+=" if ("+v+".length == 0) {";var X=X||[];X.push(o),o="",i.createErrors!==!1?(o+=" { keyword: 'contains' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: {} ",i.opts.messages!==!1&&(o+=" , message: 'should contain a valid item' "),i.opts.verbose&&(o+=" , schema: validate.schema"+f+" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ";var $=o;return o=X.pop(),!i.compositeRule&&p?i.async?o+=" throw new ValidationError(["+$+"]); ":o+=" validate.errors = ["+$+"]; return false; ":o+=" var err = "+$+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",o+=" } else { ",Y&&(o+=" errors = "+G+"; if (vErrors !== null) { if ("+G+") vErrors.length = "+G+"; else vErrors = null; } "),i.opts.allErrors&&(o+=" } "),o},zsi=function(i,n,r){var o=" ",l=i.level,c=i.dataLevel,u=i.schema[n],f=i.schemaPath+i.util.getProperty(n),m=i.errSchemaPath+"/"+n,p=!i.opts.allErrors,v="data"+(c||""),B="errs__"+l,G=i.util.copy(i),T="";G.level++;var V="valid"+G.level,E={},W={},x=i.opts.ownProperties;for(L in u)if(L!="__proto__"){var k=u[L],F=Array.isArray(k)?W:E;F[L]=k}o+="var "+B+" = errors;";var Y=i.errorPath;o+="var missing"+l+";";for(var L in W)if(F=W[L],F.length){if(o+=" if ( "+v+i.util.getProperty(L)+" !== undefined ",x&&(o+=" && Object.prototype.hasOwnProperty.call("+v+", '"+i.util.escapeQuotes(L)+"') "),p){o+=" && ( ";var O=F;if(O)for(var Q,X=-1,$=O.length-1;X<$;){Q=O[X+=1],X&&(o+=" || ");var ee=i.util.getProperty(Q),ne=v+ee;o+=" ( ( "+ne+" === undefined ",x&&(o+=" || ! Object.prototype.hasOwnProperty.call("+v+", '"+i.util.escapeQuotes(Q)+"') "),o+=") && (missing"+l+" = "+i.util.toQuotedString(i.opts.jsonPointers?Q:ee)+") ) "}o+=")) { ";var ge="missing"+l,Ae="' + "+ge+" + '";i.opts._errorDataPathProperty&&(i.errorPath=i.opts.jsonPointers?i.util.getPathExpr(Y,ge,!0):Y+" + "+ge);var _=_||[];_.push(o),o="",i.createErrors!==!1?(o+=" { keyword: 'dependencies' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: { property: '"+i.util.escapeQuotes(L)+"', missingProperty: '"+Ae+"', depsCount: "+F.length+", deps: '"+i.util.escapeQuotes(F.length==1?F[0]:F.join(", "))+"' } ",i.opts.messages!==!1&&(o+=" , message: 'should have ",F.length==1?o+="property "+i.util.escapeQuotes(F[0]):o+="properties "+i.util.escapeQuotes(F.join(", ")),o+=" when property "+i.util.escapeQuotes(L)+" is present' "),i.opts.verbose&&(o+=" , schema: validate.schema"+f+" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ";var de=o;o=_.pop(),!i.compositeRule&&p?i.async?o+=" throw new ValidationError(["+de+"]); ":o+=" validate.errors = ["+de+"]; return false; ":o+=" var err = "+de+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}else{o+=" ) { ";var Ze=F;if(Ze)for(var Q,me=-1,be=Ze.length-1;me0||k===!1:i.util.schemaHasRules(k,i.RULES.all))&&(o+=" "+V+" = true; if ( "+v+i.util.getProperty(L)+" !== undefined ",x&&(o+=" && Object.prototype.hasOwnProperty.call("+v+", '"+i.util.escapeQuotes(L)+"') "),o+=") { ",G.schema=k,G.schemaPath=f+i.util.getProperty(L),G.errSchemaPath=m+"/"+i.util.escapeFragment(L),o+=" "+i.validate(G)+" ",G.baseId=Ee,o+=" } ",p&&(o+=" if ("+V+") { ",T+="}"))}return p&&(o+=" "+T+" if ("+B+" == errors) {"),o},Osi=function(i,n,r){var o=" ",l=i.level,c=i.dataLevel,u=i.schema[n],f=i.schemaPath+i.util.getProperty(n),m=i.errSchemaPath+"/"+n,p=!i.opts.allErrors,v="data"+(c||""),B="valid"+l,G=i.opts.$data&&u&&u.$data;G&&(o+=" var schema"+l+" = "+i.util.getData(u.$data,c,i.dataPathArr)+"; ");var T="i"+l,V="schema"+l;G||(o+=" var "+V+" = validate.schema"+f+";"),o+="var "+B+";",G&&(o+=" if (schema"+l+" === undefined) "+B+" = true; else if (!Array.isArray(schema"+l+")) "+B+" = false; else {"),o+=""+B+" = false;for (var "+T+"=0; "+T+"<"+V+".length; "+T+"++) if (equal("+v+", "+V+"["+T+"])) { "+B+" = true; break; }",G&&(o+=" } "),o+=" if (!"+B+") { ";var E=E||[];E.push(o),o="",i.createErrors!==!1?(o+=" { keyword: 'enum' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: { allowedValues: schema"+l+" } ",i.opts.messages!==!1&&(o+=" , message: 'should be equal to one of the allowed values' "),i.opts.verbose&&(o+=" , schema: validate.schema"+f+" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ";var W=o;return o=E.pop(),!i.compositeRule&&p?i.async?o+=" throw new ValidationError(["+W+"]); ":o+=" validate.errors = ["+W+"]; return false; ":o+=" var err = "+W+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",o+=" }",p&&(o+=" else { "),o},Lsi=function(i,n,r){var o=" ",l=i.level,c=i.dataLevel,u=i.schema[n],f=i.schemaPath+i.util.getProperty(n),m=i.errSchemaPath+"/"+n,p=!i.opts.allErrors,v="data"+(c||"");if(i.opts.format===!1)return p&&(o+=" if (true) { "),o;var B=i.opts.$data&&u&&u.$data,G;B?(o+=" var schema"+l+" = "+i.util.getData(u.$data,c,i.dataPathArr)+"; ",G="schema"+l):G=u;var T=i.opts.unknownFormats,V=Array.isArray(T);if(B){var E="format"+l,W="isObject"+l,x="formatType"+l;o+=" var "+E+" = formats["+G+"]; var "+W+" = typeof "+E+" == 'object' && !("+E+" instanceof RegExp) && "+E+".validate; var "+x+" = "+W+" && "+E+".type || 'string'; if ("+W+") { ",i.async&&(o+=" var async"+l+" = "+E+".async; "),o+=" "+E+" = "+E+".validate; } if ( ",B&&(o+=" ("+G+" !== undefined && typeof "+G+" != 'string') || "),o+=" (",T!="ignore"&&(o+=" ("+G+" && !"+E+" ",V&&(o+=" && self._opts.unknownFormats.indexOf("+G+") == -1 "),o+=") || "),o+=" ("+E+" && "+x+" == '"+r+"' && !(typeof "+E+" == 'function' ? ",i.async?o+=" (async"+l+" ? await "+E+"("+v+") : "+E+"("+v+")) ":o+=" "+E+"("+v+") ",o+=" : "+E+".test("+v+"))))) {"}else{var E=i.formats[u];if(!E){if(T=="ignore")return i.logger.warn('unknown format "'+u+'" ignored in schema at path "'+i.errSchemaPath+'"'),p&&(o+=" if (true) { "),o;if(V&&T.indexOf(u)>=0)return p&&(o+=" if (true) { "),o;throw new Error('unknown format "'+u+'" is used in schema at path "'+i.errSchemaPath+'"')}var W=typeof E=="object"&&!(E instanceof RegExp)&&E.validate,x=W&&E.type||"string";if(W){var k=E.async===!0;E=E.validate}if(x!=r)return p&&(o+=" if (true) { "),o;if(k){if(!i.async)throw new Error("async format in sync schema");var F="formats"+i.util.getProperty(u)+".validate";o+=" if (!(await "+F+"("+v+"))) { "}else{o+=" if (! ";var F="formats"+i.util.getProperty(u);W&&(F+=".validate"),typeof E=="function"?o+=" "+F+"("+v+") ":o+=" "+F+".test("+v+") ",o+=") { "}}var Y=Y||[];Y.push(o),o="",i.createErrors!==!1?(o+=" { keyword: 'format' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: { format: ",B?o+=""+G:o+=""+i.util.toQuotedString(u),o+=" } ",i.opts.messages!==!1&&(o+=` , message: 'should match format "`,B?o+="' + "+G+" + '":o+=""+i.util.escapeQuotes(u),o+=`"' `),i.opts.verbose&&(o+=" , schema: ",B?o+="validate.schema"+f:o+=""+i.util.toQuotedString(u),o+=" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ";var L=o;return o=Y.pop(),!i.compositeRule&&p?i.async?o+=" throw new ValidationError(["+L+"]); ":o+=" validate.errors = ["+L+"]; return false; ":o+=" var err = "+L+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",o+=" } ",p&&(o+=" else { "),o},Jsi=function(i,n,r){var o=" ",l=i.level,c=i.dataLevel,u=i.schema[n],f=i.schemaPath+i.util.getProperty(n),m=i.errSchemaPath+"/"+n,p=!i.opts.allErrors,v="data"+(c||""),B="valid"+l,G="errs__"+l,T=i.util.copy(i);T.level++;var V="valid"+T.level,E=i.schema.then,W=i.schema.else,x=E!==void 0&&(i.opts.strictKeywords?typeof E=="object"&&Object.keys(E).length>0||E===!1:i.util.schemaHasRules(E,i.RULES.all)),k=W!==void 0&&(i.opts.strictKeywords?typeof W=="object"&&Object.keys(W).length>0||W===!1:i.util.schemaHasRules(W,i.RULES.all)),F=T.baseId;if(x||k){var Y;T.createErrors=!1,T.schema=u,T.schemaPath=f,T.errSchemaPath=m,o+=" var "+G+" = errors; var "+B+" = true; ";var L=i.compositeRule;i.compositeRule=T.compositeRule=!0,o+=" "+i.validate(T)+" ",T.baseId=F,T.createErrors=!0,o+=" errors = "+G+"; if (vErrors !== null) { if ("+G+") vErrors.length = "+G+"; else vErrors = null; } ",i.compositeRule=T.compositeRule=L,x?(o+=" if ("+V+") { ",T.schema=i.schema.then,T.schemaPath=i.schemaPath+".then",T.errSchemaPath=i.errSchemaPath+"/then",o+=" "+i.validate(T)+" ",T.baseId=F,o+=" "+B+" = "+V+"; ",x&&k?(Y="ifClause"+l,o+=" var "+Y+" = 'then'; "):Y="'then'",o+=" } ",k&&(o+=" else { ")):o+=" if (!"+V+") { ",k&&(T.schema=i.schema.else,T.schemaPath=i.schemaPath+".else",T.errSchemaPath=i.errSchemaPath+"/else",o+=" "+i.validate(T)+" ",T.baseId=F,o+=" "+B+" = "+V+"; ",x&&k?(Y="ifClause"+l,o+=" var "+Y+" = 'else'; "):Y="'else'",o+=" } "),o+=" if (!"+B+") { var err = ",i.createErrors!==!1?(o+=" { keyword: 'if' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: { failingKeyword: "+Y+" } ",i.opts.messages!==!1&&(o+=` , message: 'should match "' + `+Y+` + '" schema' `),i.opts.verbose&&(o+=" , schema: validate.schema"+f+" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ",o+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!i.compositeRule&&p&&(i.async?o+=" throw new ValidationError(vErrors); ":o+=" validate.errors = vErrors; return false; "),o+=" } ",p&&(o+=" else { ")}else p&&(o+=" if (true) { ");return o},Usi=function(i,n,r){var o=" ",l=i.level,c=i.dataLevel,u=i.schema[n],f=i.schemaPath+i.util.getProperty(n),m=i.errSchemaPath+"/"+n,p=!i.opts.allErrors,v="data"+(c||""),B="valid"+l,G="errs__"+l,T=i.util.copy(i),V="";T.level++;var E="valid"+T.level,W="i"+l,x=T.dataLevel=i.dataLevel+1,k="data"+x,F=i.baseId;if(o+="var "+G+" = errors;var "+B+";",Array.isArray(u)){var Y=i.schema.additionalItems;if(Y===!1){o+=" "+B+" = "+v+".length <= "+u.length+"; ";var L=m;m=i.errSchemaPath+"/additionalItems",o+=" if (!"+B+") { ";var O=O||[];O.push(o),o="",i.createErrors!==!1?(o+=" { keyword: 'additionalItems' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: { limit: "+u.length+" } ",i.opts.messages!==!1&&(o+=" , message: 'should NOT have more than "+u.length+" items' "),i.opts.verbose&&(o+=" , schema: false , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ";var Q=o;o=O.pop(),!i.compositeRule&&p?i.async?o+=" throw new ValidationError(["+Q+"]); ":o+=" validate.errors = ["+Q+"]; return false; ":o+=" var err = "+Q+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",o+=" } ",m=L,p&&(V+="}",o+=" else { ")}var X=u;if(X){for(var $,ee=-1,ne=X.length-1;ee0||$===!1:i.util.schemaHasRules($,i.RULES.all)){o+=" "+E+" = true; if ("+v+".length > "+ee+") { ";var ge=v+"["+ee+"]";T.schema=$,T.schemaPath=f+"["+ee+"]",T.errSchemaPath=m+"/"+ee,T.errorPath=i.util.getPathExpr(i.errorPath,ee,i.opts.jsonPointers,!0),T.dataPathArr[x]=ee;var Ae=i.validate(T);T.baseId=F,i.util.varOccurences(Ae,k)<2?o+=" "+i.util.varReplace(Ae,k,ge)+" ":o+=" var "+k+" = "+ge+"; "+Ae+" ",o+=" } ",p&&(o+=" if ("+E+") { ",V+="}")}}if(typeof Y=="object"&&(i.opts.strictKeywords?typeof Y=="object"&&Object.keys(Y).length>0||Y===!1:i.util.schemaHasRules(Y,i.RULES.all))){T.schema=Y,T.schemaPath=i.schemaPath+".additionalItems",T.errSchemaPath=i.errSchemaPath+"/additionalItems",o+=" "+E+" = true; if ("+v+".length > "+u.length+") { for (var "+W+" = "+u.length+"; "+W+" < "+v+".length; "+W+"++) { ",T.errorPath=i.util.getPathExpr(i.errorPath,W,i.opts.jsonPointers,!0);var ge=v+"["+W+"]";T.dataPathArr[x]=W;var Ae=i.validate(T);T.baseId=F,i.util.varOccurences(Ae,k)<2?o+=" "+i.util.varReplace(Ae,k,ge)+" ":o+=" var "+k+" = "+ge+"; "+Ae+" ",p&&(o+=" if (!"+E+") break; "),o+=" } } ",p&&(o+=" if ("+E+") { ",V+="}")}}else if(i.opts.strictKeywords?typeof u=="object"&&Object.keys(u).length>0||u===!1:i.util.schemaHasRules(u,i.RULES.all)){T.schema=u,T.schemaPath=f,T.errSchemaPath=m,o+=" for (var "+W+" = 0; "+W+" < "+v+".length; "+W+"++) { ",T.errorPath=i.util.getPathExpr(i.errorPath,W,i.opts.jsonPointers,!0);var ge=v+"["+W+"]";T.dataPathArr[x]=W;var Ae=i.validate(T);T.baseId=F,i.util.varOccurences(Ae,k)<2?o+=" "+i.util.varReplace(Ae,k,ge)+" ":o+=" var "+k+" = "+ge+"; "+Ae+" ",p&&(o+=" if (!"+E+") break; "),o+=" }"}return p&&(o+=" "+V+" if ("+G+" == errors) {"),o},exe=function(i,n,r){var o=" ",l=i.level,c=i.dataLevel,u=i.schema[n],f=i.schemaPath+i.util.getProperty(n),m=i.errSchemaPath+"/"+n,p=!i.opts.allErrors,F,v="data"+(c||""),B=i.opts.$data&&u&&u.$data,G;B?(o+=" var schema"+l+" = "+i.util.getData(u.$data,c,i.dataPathArr)+"; ",G="schema"+l):G=u;var T=n=="maximum",V=T?"exclusiveMaximum":"exclusiveMinimum",E=i.schema[V],W=i.opts.$data&&E&&E.$data,x=T?"<":">",k=T?">":"<",F=void 0;if(!(B||typeof u=="number"||u===void 0))throw new Error(n+" must be number");if(!(W||E===void 0||typeof E=="number"||typeof E=="boolean"))throw new Error(V+" must be number or boolean");if(W){var Y=i.util.getData(E.$data,c,i.dataPathArr),L="exclusive"+l,O="exclType"+l,Q="exclIsNumber"+l,X="op"+l,$="' + "+X+" + '";o+=" var schemaExcl"+l+" = "+Y+"; ",Y="schemaExcl"+l,o+=" var "+L+"; var "+O+" = typeof "+Y+"; if ("+O+" != 'boolean' && "+O+" != 'undefined' && "+O+" != 'number') { ";var F=V,ee=ee||[];ee.push(o),o="",i.createErrors!==!1?(o+=" { keyword: '"+(F||"_exclusiveLimit")+"' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: {} ",i.opts.messages!==!1&&(o+=" , message: '"+V+" should be boolean' "),i.opts.verbose&&(o+=" , schema: validate.schema"+f+" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ";var ne=o;o=ee.pop(),!i.compositeRule&&p?i.async?o+=" throw new ValidationError(["+ne+"]); ":o+=" validate.errors = ["+ne+"]; return false; ":o+=" var err = "+ne+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",o+=" } else if ( ",B&&(o+=" ("+G+" !== undefined && typeof "+G+" != 'number') || "),o+=" "+O+" == 'number' ? ( ("+L+" = "+G+" === undefined || "+Y+" "+x+"= "+G+") ? "+v+" "+k+"= "+Y+" : "+v+" "+k+" "+G+" ) : ( ("+L+" = "+Y+" === true) ? "+v+" "+k+"= "+G+" : "+v+" "+k+" "+G+" ) || "+v+" !== "+v+") { var op"+l+" = "+L+" ? '"+x+"' : '"+x+"='; ",u===void 0&&(F=V,m=i.errSchemaPath+"/"+V,G=Y,B=W)}else{var Q=typeof E=="number",$=x;if(Q&&B){var X="'"+$+"'";o+=" if ( ",B&&(o+=" ("+G+" !== undefined && typeof "+G+" != 'number') || "),o+=" ( "+G+" === undefined || "+E+" "+x+"= "+G+" ? "+v+" "+k+"= "+E+" : "+v+" "+k+" "+G+" ) || "+v+" !== "+v+") { "}else{Q&&u===void 0?(L=!0,F=V,m=i.errSchemaPath+"/"+V,G=E,k+="="):(Q&&(G=Math[T?"min":"max"](E,u)),E===(Q?G:!0)?(L=!0,F=V,m=i.errSchemaPath+"/"+V,k+="="):(L=!1,$+="="));var X="'"+$+"'";o+=" if ( ",B&&(o+=" ("+G+" !== undefined && typeof "+G+" != 'number') || "),o+=" "+v+" "+k+" "+G+" || "+v+" !== "+v+") { "}}F=F||n;var ee=ee||[];ee.push(o),o="",i.createErrors!==!1?(o+=" { keyword: '"+(F||"_limit")+"' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: { comparison: "+X+", limit: "+G+", exclusive: "+L+" } ",i.opts.messages!==!1&&(o+=" , message: 'should be "+$+" ",B?o+="' + "+G:o+=""+G+"'"),i.opts.verbose&&(o+=" , schema: ",B?o+="validate.schema"+f:o+=""+u,o+=" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ";var ne=o;return o=ee.pop(),!i.compositeRule&&p?i.async?o+=" throw new ValidationError(["+ne+"]); ":o+=" validate.errors = ["+ne+"]; return false; ":o+=" var err = "+ne+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",o+=" } ",p&&(o+=" else { "),o},txe=function(i,n,r){var o=" ",l=i.level,c=i.dataLevel,u=i.schema[n],f=i.schemaPath+i.util.getProperty(n),m=i.errSchemaPath+"/"+n,p=!i.opts.allErrors,V,v="data"+(c||""),B=i.opts.$data&&u&&u.$data,G;if(B?(o+=" var schema"+l+" = "+i.util.getData(u.$data,c,i.dataPathArr)+"; ",G="schema"+l):G=u,!(B||typeof u=="number"))throw new Error(n+" must be number");var T=n=="maxItems"?">":"<";o+="if ( ",B&&(o+=" ("+G+" !== undefined && typeof "+G+" != 'number') || "),o+=" "+v+".length "+T+" "+G+") { ";var V=n,E=E||[];E.push(o),o="",i.createErrors!==!1?(o+=" { keyword: '"+(V||"_limitItems")+"' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: { limit: "+G+" } ",i.opts.messages!==!1&&(o+=" , message: 'should NOT have ",n=="maxItems"?o+="more":o+="fewer",o+=" than ",B?o+="' + "+G+" + '":o+=""+u,o+=" items' "),i.opts.verbose&&(o+=" , schema: ",B?o+="validate.schema"+f:o+=""+u,o+=" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ";var W=o;return o=E.pop(),!i.compositeRule&&p?i.async?o+=" throw new ValidationError(["+W+"]); ":o+=" validate.errors = ["+W+"]; return false; ":o+=" var err = "+W+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",o+="} ",p&&(o+=" else { "),o},ixe=function(i,n,r){var o=" ",l=i.level,c=i.dataLevel,u=i.schema[n],f=i.schemaPath+i.util.getProperty(n),m=i.errSchemaPath+"/"+n,p=!i.opts.allErrors,V,v="data"+(c||""),B=i.opts.$data&&u&&u.$data,G;if(B?(o+=" var schema"+l+" = "+i.util.getData(u.$data,c,i.dataPathArr)+"; ",G="schema"+l):G=u,!(B||typeof u=="number"))throw new Error(n+" must be number");var T=n=="maxLength"?">":"<";o+="if ( ",B&&(o+=" ("+G+" !== undefined && typeof "+G+" != 'number') || "),i.opts.unicode===!1?o+=" "+v+".length ":o+=" ucs2length("+v+") ",o+=" "+T+" "+G+") { ";var V=n,E=E||[];E.push(o),o="",i.createErrors!==!1?(o+=" { keyword: '"+(V||"_limitLength")+"' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: { limit: "+G+" } ",i.opts.messages!==!1&&(o+=" , message: 'should NOT be ",n=="maxLength"?o+="longer":o+="shorter",o+=" than ",B?o+="' + "+G+" + '":o+=""+u,o+=" characters' "),i.opts.verbose&&(o+=" , schema: ",B?o+="validate.schema"+f:o+=""+u,o+=" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ";var W=o;return o=E.pop(),!i.compositeRule&&p?i.async?o+=" throw new ValidationError(["+W+"]); ":o+=" validate.errors = ["+W+"]; return false; ":o+=" var err = "+W+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",o+="} ",p&&(o+=" else { "),o},nxe=function(i,n,r){var o=" ",l=i.level,c=i.dataLevel,u=i.schema[n],f=i.schemaPath+i.util.getProperty(n),m=i.errSchemaPath+"/"+n,p=!i.opts.allErrors,V,v="data"+(c||""),B=i.opts.$data&&u&&u.$data,G;if(B?(o+=" var schema"+l+" = "+i.util.getData(u.$data,c,i.dataPathArr)+"; ",G="schema"+l):G=u,!(B||typeof u=="number"))throw new Error(n+" must be number");var T=n=="maxProperties"?">":"<";o+="if ( ",B&&(o+=" ("+G+" !== undefined && typeof "+G+" != 'number') || "),o+=" Object.keys("+v+").length "+T+" "+G+") { ";var V=n,E=E||[];E.push(o),o="",i.createErrors!==!1?(o+=" { keyword: '"+(V||"_limitProperties")+"' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: { limit: "+G+" } ",i.opts.messages!==!1&&(o+=" , message: 'should NOT have ",n=="maxProperties"?o+="more":o+="fewer",o+=" than ",B?o+="' + "+G+" + '":o+=""+u,o+=" properties' "),i.opts.verbose&&(o+=" , schema: ",B?o+="validate.schema"+f:o+=""+u,o+=" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ";var W=o;return o=E.pop(),!i.compositeRule&&p?i.async?o+=" throw new ValidationError(["+W+"]); ":o+=" validate.errors = ["+W+"]; return false; ":o+=" var err = "+W+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",o+="} ",p&&(o+=" else { "),o},Qsi=function(i,n,r){var o=" ",l=i.level,c=i.dataLevel,u=i.schema[n],f=i.schemaPath+i.util.getProperty(n),m=i.errSchemaPath+"/"+n,p=!i.opts.allErrors,v="data"+(c||""),B=i.opts.$data&&u&&u.$data,G;if(B?(o+=" var schema"+l+" = "+i.util.getData(u.$data,c,i.dataPathArr)+"; ",G="schema"+l):G=u,!(B||typeof u=="number"))throw new Error(n+" must be number");o+="var division"+l+";if (",B&&(o+=" "+G+" !== undefined && ( typeof "+G+" != 'number' || "),o+=" (division"+l+" = "+v+" / "+G+", ",i.opts.multipleOfPrecision?o+=" Math.abs(Math.round(division"+l+") - division"+l+") > 1e-"+i.opts.multipleOfPrecision+" ":o+=" division"+l+" !== parseInt(division"+l+") ",o+=" ) ",B&&(o+=" ) "),o+=" ) { ";var T=T||[];T.push(o),o="",i.createErrors!==!1?(o+=" { keyword: 'multipleOf' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: { multipleOf: "+G+" } ",i.opts.messages!==!1&&(o+=" , message: 'should be multiple of ",B?o+="' + "+G:o+=""+G+"'"),i.opts.verbose&&(o+=" , schema: ",B?o+="validate.schema"+f:o+=""+u,o+=" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ";var V=o;return o=T.pop(),!i.compositeRule&&p?i.async?o+=" throw new ValidationError(["+V+"]); ":o+=" validate.errors = ["+V+"]; return false; ":o+=" var err = "+V+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",o+="} ",p&&(o+=" else { "),o},jsi=function(i,n,r){var o=" ",l=i.level,c=i.dataLevel,u=i.schema[n],f=i.schemaPath+i.util.getProperty(n),m=i.errSchemaPath+"/"+n,p=!i.opts.allErrors,v="data"+(c||""),B="errs__"+l,G=i.util.copy(i);G.level++;var T="valid"+G.level;if(i.opts.strictKeywords?typeof u=="object"&&Object.keys(u).length>0||u===!1:i.util.schemaHasRules(u,i.RULES.all)){G.schema=u,G.schemaPath=f,G.errSchemaPath=m,o+=" var "+B+" = errors; ";var V=i.compositeRule;i.compositeRule=G.compositeRule=!0,G.createErrors=!1;var E;G.opts.allErrors&&(E=G.opts.allErrors,G.opts.allErrors=!1),o+=" "+i.validate(G)+" ",G.createErrors=!0,E&&(G.opts.allErrors=E),i.compositeRule=G.compositeRule=V,o+=" if ("+T+") { ";var W=W||[];W.push(o),o="",i.createErrors!==!1?(o+=" { keyword: 'not' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: {} ",i.opts.messages!==!1&&(o+=" , message: 'should NOT be valid' "),i.opts.verbose&&(o+=" , schema: validate.schema"+f+" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ";var x=o;o=W.pop(),!i.compositeRule&&p?i.async?o+=" throw new ValidationError(["+x+"]); ":o+=" validate.errors = ["+x+"]; return false; ":o+=" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",o+=" } else { errors = "+B+"; if (vErrors !== null) { if ("+B+") vErrors.length = "+B+"; else vErrors = null; } ",i.opts.allErrors&&(o+=" } ")}else o+=" var err = ",i.createErrors!==!1?(o+=" { keyword: 'not' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: {} ",i.opts.messages!==!1&&(o+=" , message: 'should NOT be valid' "),i.opts.verbose&&(o+=" , schema: validate.schema"+f+" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ",o+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",p&&(o+=" if (false) { ");return o},$si=function(i,n,r){var o=" ",l=i.level,c=i.dataLevel,u=i.schema[n],f=i.schemaPath+i.util.getProperty(n),m=i.errSchemaPath+"/"+n,p=!i.opts.allErrors,v="data"+(c||""),B="valid"+l,G="errs__"+l,T=i.util.copy(i),V="";T.level++;var E="valid"+T.level,W=T.baseId,x="prevValid"+l,k="passingSchemas"+l;o+="var "+G+" = errors , "+x+" = false , "+B+" = false , "+k+" = null; ";var F=i.compositeRule;i.compositeRule=T.compositeRule=!0;var Y=u;if(Y)for(var L,O=-1,Q=Y.length-1;O0||L===!1:i.util.schemaHasRules(L,i.RULES.all))?(T.schema=L,T.schemaPath=f+"["+O+"]",T.errSchemaPath=m+"/"+O,o+=" "+i.validate(T)+" ",T.baseId=W):o+=" var "+E+" = true; ",O&&(o+=" if ("+E+" && "+x+") { "+B+" = false; "+k+" = ["+k+", "+O+"]; } else { ",V+="}"),o+=" if ("+E+") { "+B+" = "+x+" = true; "+k+" = "+O+"; }";return i.compositeRule=T.compositeRule=F,o+=""+V+"if (!"+B+") { var err = ",i.createErrors!==!1?(o+=" { keyword: 'oneOf' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: { passingSchemas: "+k+" } ",i.opts.messages!==!1&&(o+=" , message: 'should match exactly one schema in oneOf' "),i.opts.verbose&&(o+=" , schema: validate.schema"+f+" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ",o+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!i.compositeRule&&p&&(i.async?o+=" throw new ValidationError(vErrors); ":o+=" validate.errors = vErrors; return false; "),o+="} else { errors = "+G+"; if (vErrors !== null) { if ("+G+") vErrors.length = "+G+"; else vErrors = null; }",i.opts.allErrors&&(o+=" } "),o},qsi=function(i,n,r){var o=" ",l=i.level,c=i.dataLevel,u=i.schema[n],f=i.schemaPath+i.util.getProperty(n),m=i.errSchemaPath+"/"+n,p=!i.opts.allErrors,v="data"+(c||""),B=i.opts.$data&&u&&u.$data,G;B?(o+=" var schema"+l+" = "+i.util.getData(u.$data,c,i.dataPathArr)+"; ",G="schema"+l):G=u;var T=B?"(new RegExp("+G+"))":i.usePattern(u);o+="if ( ",B&&(o+=" ("+G+" !== undefined && typeof "+G+" != 'string') || "),o+=" !"+T+".test("+v+") ) { ";var V=V||[];V.push(o),o="",i.createErrors!==!1?(o+=" { keyword: 'pattern' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: { pattern: ",B?o+=""+G:o+=""+i.util.toQuotedString(u),o+=" } ",i.opts.messages!==!1&&(o+=` , message: 'should match pattern "`,B?o+="' + "+G+" + '":o+=""+i.util.escapeQuotes(u),o+=`"' `),i.opts.verbose&&(o+=" , schema: ",B?o+="validate.schema"+f:o+=""+i.util.toQuotedString(u),o+=" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ";var E=o;return o=V.pop(),!i.compositeRule&&p?i.async?o+=" throw new ValidationError(["+E+"]); ":o+=" validate.errors = ["+E+"]; return false; ":o+=" var err = "+E+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",o+="} ",p&&(o+=" else { "),o},eIi=function(i,n,r){var o=" ",l=i.level,c=i.dataLevel,u=i.schema[n],f=i.schemaPath+i.util.getProperty(n),m=i.errSchemaPath+"/"+n,p=!i.opts.allErrors,v="data"+(c||""),B="errs__"+l,G=i.util.copy(i),T="";G.level++;var V="valid"+G.level,E="key"+l,W="idx"+l,x=G.dataLevel=i.dataLevel+1,k="data"+x,F="dataProperties"+l,Y=Object.keys(u||{}).filter(me),L=i.schema.patternProperties||{},O=Object.keys(L).filter(me),Q=i.schema.additionalProperties,X=Y.length||O.length,$=Q===!1,ee=typeof Q=="object"&&Object.keys(Q).length,ne=i.opts.removeAdditional,ge=$||ee||ne,Ae=i.opts.ownProperties,_=i.baseId,de=i.schema.required;if(de&&!(i.opts.$data&&de.$data)&&de.length8)o+=" || validate.schema"+f+".hasOwnProperty("+E+") ";else{var be=Y;if(be)for(var Ee,Je=-1,Ue=be.length-1;Je0||mi===!1:i.util.schemaHasRules(mi,i.RULES.all)){var Cn=i.util.getProperty(Ee),Et=v+Cn,on=zt&&mi.default!==void 0;G.schema=mi,G.schemaPath=f+Cn,G.errSchemaPath=m+"/"+i.util.escapeFragment(Ee),G.errorPath=i.util.getPath(i.errorPath,Ee,i.opts.jsonPointers),G.dataPathArr[x]=i.util.toQuotedString(Ee);var Zt=i.validate(G);if(G.baseId=_,i.util.varOccurences(Zt,k)<2){Zt=i.util.varReplace(Zt,k,Et);var ki=Et}else{var ki=k;o+=" var "+k+" = "+Et+"; "}if(on)o+=" "+Zt+" ";else{if(Ze&&Ze[Ee]){o+=" if ( "+ki+" === undefined ",Ae&&(o+=" || ! Object.prototype.hasOwnProperty.call("+v+", '"+i.util.escapeQuotes(Ee)+"') "),o+=") { "+V+" = false; ";var je=i.errorPath,xe=m,Ei=i.util.escapeQuotes(Ee);i.opts._errorDataPathProperty&&(i.errorPath=i.util.getPath(je,Ee,i.opts.jsonPointers)),m=i.errSchemaPath+"/required";var it=it||[];it.push(o),o="",i.createErrors!==!1?(o+=" { keyword: 'required' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: { missingProperty: '"+Ei+"' } ",i.opts.messages!==!1&&(o+=" , message: '",i.opts._errorDataPathProperty?o+="is a required property":o+="should have required property \\'"+Ei+"\\'",o+="' "),i.opts.verbose&&(o+=" , schema: validate.schema"+f+" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ";var Ct=o;o=it.pop(),!i.compositeRule&&p?i.async?o+=" throw new ValidationError(["+Ct+"]); ":o+=" validate.errors = ["+Ct+"]; return false; ":o+=" var err = "+Ct+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",m=xe,i.errorPath=je,o+=" } else { "}else p?(o+=" if ( "+ki+" === undefined ",Ae&&(o+=" || ! Object.prototype.hasOwnProperty.call("+v+", '"+i.util.escapeQuotes(Ee)+"') "),o+=") { "+V+" = true; } else { "):(o+=" if ("+ki+" !== undefined ",Ae&&(o+=" && Object.prototype.hasOwnProperty.call("+v+", '"+i.util.escapeQuotes(Ee)+"') "),o+=" ) { ");o+=" "+Zt+" } "}}p&&(o+=" if ("+V+") { ",T+="}")}}if(O.length){var Bn=O;if(Bn)for(var rt,Nr=-1,kr=Bn.length-1;Nr0||mi===!1:i.util.schemaHasRules(mi,i.RULES.all)){G.schema=mi,G.schemaPath=i.schemaPath+".patternProperties"+i.util.getProperty(rt),G.errSchemaPath=i.errSchemaPath+"/patternProperties/"+i.util.escapeFragment(rt),Ae?o+=" "+F+" = "+F+" || Object.keys("+v+"); for (var "+W+"=0; "+W+"<"+F+".length; "+W+"++) { var "+E+" = "+F+"["+W+"]; ":o+=" for (var "+E+" in "+v+") { ",o+=" if ("+i.usePattern(rt)+".test("+E+")) { ",G.errorPath=i.util.getPathExpr(i.errorPath,E,i.opts.jsonPointers);var Et=v+"["+E+"]";G.dataPathArr[x]=E;var Zt=i.validate(G);G.baseId=_,i.util.varOccurences(Zt,k)<2?o+=" "+i.util.varReplace(Zt,k,Et)+" ":o+=" var "+k+" = "+Et+"; "+Zt+" ",p&&(o+=" if (!"+V+") break; "),o+=" } ",p&&(o+=" else "+V+" = true; "),o+=" } ",p&&(o+=" if ("+V+") { ",T+="}")}}}return p&&(o+=" "+T+" if ("+B+" == errors) {"),o},tIi=function(i,n,r){var o=" ",l=i.level,c=i.dataLevel,u=i.schema[n],f=i.schemaPath+i.util.getProperty(n),m=i.errSchemaPath+"/"+n,p=!i.opts.allErrors,v="data"+(c||""),B="errs__"+l,G=i.util.copy(i),T="";G.level++;var V="valid"+G.level;if(o+="var "+B+" = errors;",i.opts.strictKeywords?typeof u=="object"&&Object.keys(u).length>0||u===!1:i.util.schemaHasRules(u,i.RULES.all)){G.schema=u,G.schemaPath=f,G.errSchemaPath=m;var E="key"+l,W="idx"+l,x="i"+l,k="' + "+E+" + '",F=G.dataLevel=i.dataLevel+1,Y="data"+F,L="dataProperties"+l,O=i.opts.ownProperties,Q=i.baseId;O&&(o+=" var "+L+" = undefined; "),O?o+=" "+L+" = "+L+" || Object.keys("+v+"); for (var "+W+"=0; "+W+"<"+L+".length; "+W+"++) { var "+E+" = "+L+"["+W+"]; ":o+=" for (var "+E+" in "+v+") { ",o+=" var startErrs"+l+" = errors; ";var X=E,$=i.compositeRule;i.compositeRule=G.compositeRule=!0;var ee=i.validate(G);G.baseId=Q,i.util.varOccurences(ee,Y)<2?o+=" "+i.util.varReplace(ee,Y,X)+" ":o+=" var "+Y+" = "+X+"; "+ee+" ",i.compositeRule=G.compositeRule=$,o+=" if (!"+V+") { for (var "+x+"=startErrs"+l+"; "+x+"0||F===!1:i.util.schemaHasRules(F,i.RULES.all))||(V[V.length]=W)}}else var V=u;if(G||V.length){var Y=i.errorPath,L=G||V.length>=i.opts.loopRequired,O=i.opts.ownProperties;if(p)if(o+=" var missing"+l+"; ",L){G||(o+=" var "+T+" = validate.schema"+f+"; ");var Q="i"+l,X="schema"+l+"["+Q+"]",$="' + "+X+" + '";i.opts._errorDataPathProperty&&(i.errorPath=i.util.getPathExpr(Y,X,i.opts.jsonPointers)),o+=" var "+B+" = true; ",G&&(o+=" if (schema"+l+" === undefined) "+B+" = true; else if (!Array.isArray(schema"+l+")) "+B+" = false; else {"),o+=" for (var "+Q+" = 0; "+Q+" < "+T+".length; "+Q+"++) { "+B+" = "+v+"["+T+"["+Q+"]] !== undefined ",O&&(o+=" && Object.prototype.hasOwnProperty.call("+v+", "+T+"["+Q+"]) "),o+="; if (!"+B+") break; } ",G&&(o+=" } "),o+=" if (!"+B+") { ";var ee=ee||[];ee.push(o),o="",i.createErrors!==!1?(o+=" { keyword: 'required' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: { missingProperty: '"+$+"' } ",i.opts.messages!==!1&&(o+=" , message: '",i.opts._errorDataPathProperty?o+="is a required property":o+="should have required property \\'"+$+"\\'",o+="' "),i.opts.verbose&&(o+=" , schema: validate.schema"+f+" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ";var ne=o;o=ee.pop(),!i.compositeRule&&p?i.async?o+=" throw new ValidationError(["+ne+"]); ":o+=" validate.errors = ["+ne+"]; return false; ":o+=" var err = "+ne+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",o+=" } else { "}else{o+=" if ( ";var ge=V;if(ge)for(var Ae,Q=-1,_=ge.length-1;Q<_;){Ae=ge[Q+=1],Q&&(o+=" || ");var de=i.util.getProperty(Ae),Ze=v+de;o+=" ( ( "+Ze+" === undefined ",O&&(o+=" || ! Object.prototype.hasOwnProperty.call("+v+", '"+i.util.escapeQuotes(Ae)+"') "),o+=") && (missing"+l+" = "+i.util.toQuotedString(i.opts.jsonPointers?Ae:de)+") ) "}o+=") { ";var X="missing"+l,$="' + "+X+" + '";i.opts._errorDataPathProperty&&(i.errorPath=i.opts.jsonPointers?i.util.getPathExpr(Y,X,!0):Y+" + "+X);var ee=ee||[];ee.push(o),o="",i.createErrors!==!1?(o+=" { keyword: 'required' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: { missingProperty: '"+$+"' } ",i.opts.messages!==!1&&(o+=" , message: '",i.opts._errorDataPathProperty?o+="is a required property":o+="should have required property \\'"+$+"\\'",o+="' "),i.opts.verbose&&(o+=" , schema: validate.schema"+f+" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ";var ne=o;o=ee.pop(),!i.compositeRule&&p?i.async?o+=" throw new ValidationError(["+ne+"]); ":o+=" validate.errors = ["+ne+"]; return false; ":o+=" var err = "+ne+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",o+=" } else { "}else if(L){G||(o+=" var "+T+" = validate.schema"+f+"; ");var Q="i"+l,X="schema"+l+"["+Q+"]",$="' + "+X+" + '";i.opts._errorDataPathProperty&&(i.errorPath=i.util.getPathExpr(Y,X,i.opts.jsonPointers)),G&&(o+=" if ("+T+" && !Array.isArray("+T+")) { var err = ",i.createErrors!==!1?(o+=" { keyword: 'required' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: { missingProperty: '"+$+"' } ",i.opts.messages!==!1&&(o+=" , message: '",i.opts._errorDataPathProperty?o+="is a required property":o+="should have required property \\'"+$+"\\'",o+="' "),i.opts.verbose&&(o+=" , schema: validate.schema"+f+" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ",o+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if ("+T+" !== undefined) { "),o+=" for (var "+Q+" = 0; "+Q+" < "+T+".length; "+Q+"++) { if ("+v+"["+T+"["+Q+"]] === undefined ",O&&(o+=" || ! Object.prototype.hasOwnProperty.call("+v+", "+T+"["+Q+"]) "),o+=") { var err = ",i.createErrors!==!1?(o+=" { keyword: 'required' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: { missingProperty: '"+$+"' } ",i.opts.messages!==!1&&(o+=" , message: '",i.opts._errorDataPathProperty?o+="is a required property":o+="should have required property \\'"+$+"\\'",o+="' "),i.opts.verbose&&(o+=" , schema: validate.schema"+f+" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ",o+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } ",G&&(o+=" } ")}else{var me=V;if(me)for(var Ae,be=-1,Ee=me.length-1;be 1) { ";var V=i.schema.items&&i.schema.items.type,E=Array.isArray(V);if(!V||V=="object"||V=="array"||E&&(V.indexOf("object")>=0||V.indexOf("array")>=0))o+=" outer: for (;i--;) { for (j = i; j--;) { if (equal("+v+"[i], "+v+"[j])) { "+B+" = false; break outer; } } } ";else{o+=" var itemIndices = {}, item; for (;i--;) { var item = "+v+"[i]; ";var W="checkDataType"+(E?"s":"");o+=" if ("+i.util[W](V,"item",i.opts.strictNumbers,!0)+") continue; ",E&&(o+=` if (typeof item == 'string') item = '"' + item; `),o+=" if (typeof itemIndices[item] == 'number') { "+B+" = false; j = itemIndices[item]; break; } itemIndices[item] = i; } "}o+=" } ",G&&(o+=" } "),o+=" if (!"+B+") { ";var x=x||[];x.push(o),o="",i.createErrors!==!1?(o+=" { keyword: 'uniqueItems' , dataPath: (dataPath || '') + "+i.errorPath+" , schemaPath: "+i.util.toQuotedString(m)+" , params: { i: i, j: j } ",i.opts.messages!==!1&&(o+=" , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' "),i.opts.verbose&&(o+=" , schema: ",G?o+="validate.schema"+f:o+=""+u,o+=" , parentSchema: validate.schema"+i.schemaPath+" , data: "+v+" "),o+=" } "):o+=" {} ";var k=o;o=x.pop(),!i.compositeRule&&p?i.async?o+=" throw new ValidationError(["+k+"]); ":o+=" validate.errors = ["+k+"]; return false; ":o+=" var err = "+k+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",o+=" } ",p&&(o+=" else { ")}else p&&(o+=" if (true) { ");return o},rIi={$ref:Msi,allOf:Fsi,anyOf:Ysi,$comment:Ksi,const:_si,contains:Psi,dependencies:zsi,enum:Osi,format:Lsi,if:Jsi,items:Usi,maximum:exe,minimum:exe,maxItems:txe,minItems:txe,maxLength:ixe,minLength:ixe,maxProperties:nxe,minProperties:nxe,multipleOf:Qsi,not:jsi,oneOf:$si,pattern:qsi,properties:eIi,propertyNames:tIi,required:iIi,uniqueItems:nIi,validate:oJe},rxe=rIi,yee=Ww.toHash,gIi=function(){var i=[{type:"number",rules:[{maximum:["exclusiveMaximum"]},{minimum:["exclusiveMinimum"]},"multipleOf","format"]},{type:"string",rules:["maxLength","minLength","pattern","format"]},{type:"array",rules:["maxItems","minItems","items","contains","uniqueItems"]},{type:"object",rules:["maxProperties","minProperties","required","dependencies","propertyNames",{properties:["additionalProperties","patternProperties"]}]},{rules:["$ref","const","enum","not","anyOf","oneOf","allOf","if"]}],n=["type","$comment"],r=["$schema","$id","id","$data","$async","title","description","default","definitions","examples","readOnly","writeOnly","contentMediaType","contentEncoding","additionalItems","then","else"],o=["number","integer","string","array","object","boolean","null"];return i.all=yee(n),i.types=yee(o),i.forEach(function(l){l.rules=l.rules.map(function(c){var u;if(typeof c=="object"){var f=Object.keys(c)[0];u=c[f],c=f,u.forEach(function(p){n.push(p),i.all[p]=!0})}n.push(c);var m=i.all[c]={keyword:c,code:rxe[c],implements:u};return m}),i.all.$comment={keyword:"$comment",code:rxe.$comment},l.type&&(i.types[l.type]=l)}),i.keywords=yee(n.concat(r)),i.custom={},i},gxe=["multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","additionalItems","maxItems","minItems","uniqueItems","maxProperties","minProperties","required","additionalProperties","enum","format","const"],oIi=function(e,i){for(var n=0;n{!ole(o)&&o.mark!=="brush"&&o.mark!=="rule"&&(n.push("genomic type is not encoded to either a x- or y- axis"),i=!1);const l=o.color;o.mark==="line"&&Ii(l)&&l.type==="quantitative"&&(n.push("`line` mark cannot be used with `quantitative` value"),i=!1)}),{valid:i,errorMessages:n}}function ole(e){let i;return["x","y","xe","ye","x1","y1","x1e","y1e"].reverse().forEach(n=>{const r=e[n];Ii(r)&&r.type==="genomic"&&(i=r)}),i}function EJe(e){let i;return["x","xe","y","ye","x1","y1","x1e","y1e"].reverse().forEach(n=>{const r=e[n];Ii(r)&&r.type==="genomic"&&(i=n)}),i}const sli="#/definitions/HiGlassSpec",Ili="http://json-schema.org/draft-07/schema#",lli={Assembly:{anyOf:[{const:"hg38",type:"string"},{const:"hg19",type:"string"},{const:"hg18",type:"string"},{const:"hg17",type:"string"},{const:"hg16",type:"string"},{const:"mm10",type:"string"},{const:"mm9",type:"string"},{const:"unknown",type:"string"},{$ref:"#/definitions/ChromSizes"}]},ChromSizes:{description:'Custom chromosome sizes, e.g., [["foo", 1000], ["bar", 300], ["baz", 240]]',items:{items:[{type:"string"},{type:"number"}],maxItems:2,minItems:2,type:"array"},type:"array"},CombinedTrack:{additionalProperties:!1,properties:{contents:{items:{$ref:"#/definitions/Track"},type:"array"},height:{type:"number"},options:{},position:{type:"string"},type:{const:"combined",type:"string"},uid:{type:"string"},width:{type:"number"}},required:["type","contents"],type:"object"},Data:{additionalProperties:!1,properties:{assembly:{$ref:"#/definitions/Assembly"},children:{items:{},type:"array"},filter:{items:{$ref:"#/definitions/FilterTransform"},type:"array"},tiles:{},tilesetInfo:{},type:{type:"string"},url:{type:"string"}},type:"object"},EnumTrack:{additionalProperties:!1,properties:{chromInfoPath:{type:"string"},data:{$ref:"#/definitions/Data"},fromViewUid:{type:["null","string"]},height:{type:"number"},options:{},server:{type:"string"},tilesetUid:{type:"string"},type:{$ref:"#/definitions/EnumTrackType"},uid:{type:"string"},width:{type:"number"},x:{type:"number"},y:{type:"number"}},required:["type"],type:"object"},EnumTrackType:{enum:["heatmap","2d-annotations","2d-chromosome-annotations","2d-chromosome-grid","2d-chromosome-labels","2d-rectangle-domains","2d-tiles","arrowhead-domains","bedlike","cross-rule","dummy","horizontal-1d-annotations","horizontal-1d-heatmap","horizontal-1d-tiles","horizontal-1d-value-interval","horizontal-2d-rectangle-domains","horizontal-bar","horizontal-chromosome-grid","horizontal-chromosome-labels","horizontal-divergent-bar","horizontal-gene-annotations","horizontal-heatmap","horizontal-line","horizontal-multivec","horizontal-point","horizontal-rule","horizontal-vector-heatmap","image-tiles","left-axis","left-stacked-interval","mapbox-tiles","osm-2d-tile-ids","osm-tiles","raster-tiles","simple-svg","square-markers","top-axis","top-stacked-interval","vertical-1d-annotations","vertical-1d-heatmap","vertical-1d-tiles","vertical-1d-value-interval","vertical-2d-rectangle-domains","vertical-bar","vertical-bedlike","vertical-chromosome-grid","vertical-chromosome-labels","vertical-gene-annotations","vertical-heatmap","vertical-line","vertical-multivec","vertical-point","vertical-rule","vertical-vector-heatmap","viewport-projection-center","viewport-projection-horizontal","viewport-projection-vertical","gosling-track","gosling-2d-track","axis-track","text"],type:"string"},FilterTransform:{anyOf:[{$ref:"#/definitions/OneOfFilter"},{$ref:"#/definitions/RangeFilter"},{$ref:"#/definitions/IncludeFilter"}]},GenericLocks:{additionalProperties:!1,properties:{locksByViewUid:{$ref:"#/definitions/LocksByViewUid"},locksDict:{}},required:["locksByViewUid","locksDict"],type:"object"},GenomePositionSearchBox:{additionalProperties:!1,properties:{autocompleteId:{type:"string"},autocompleteServer:{type:"string"},chromInfoId:{type:"string"},chromInfoServer:{type:"string"},visible:{type:"boolean"}},required:["chromInfoId","chromInfoServer"],type:"object"},HeatmapTrack:{additionalProperties:!1,properties:{data:{$ref:"#/definitions/Data"},height:{type:"number"},options:{},position:{type:"string"},server:{type:"string"},tilesetUid:{type:"string"},type:{const:"heatmap",type:"string"},uid:{type:"string"},width:{type:"number"}},required:["type"],type:"object"},HiGlassSpec:{additionalProperties:!1,properties:{chromInfoPath:{type:"string"},compactLayout:{type:"boolean"},editable:{type:"boolean"},exportViewUrl:{type:"string"},locationLocks:{$ref:"#/definitions/GenericLocks"},trackSourceServers:{items:{type:"string"},type:"array"},tracksEditable:{type:"boolean"},valueScaleLocks:{$ref:"#/definitions/ValueScaleLocks"},viewEditable:{type:"boolean"},views:{items:{$ref:"#/definitions/View"},type:"array"},zoomFixed:{type:"boolean"},zoomLocks:{$ref:"#/definitions/GenericLocks"}},required:["views","zoomLocks","locationLocks"],type:"object"},IncludeFilter:{additionalProperties:!1,properties:{field:{description:"A filter is applied based on the values of the specified data field",type:"string"},include:{description:"Check whether the value includes a substring.",type:"string"},not:{description:'when `{"not": true}`, apply a NOT logical operation to the filter.\n\n__Default:__ `false`',type:"boolean"},type:{const:"filter",type:"string"}},required:["field","include","type"],type:"object"},IndependentViewportProjectionTrack:{additionalProperties:!1,properties:{fromViewUid:{type:"null"},options:{},projectionXDomain:{items:{type:"number"},type:"array"},projectionYDomain:{items:{type:"number"},type:"array"},transforms:{items:{},type:"array"},type:{enum:["viewport-projection-horizontal","viewport-projection-vertical","viewport-projection-center"],type:"string"},uid:{type:"string"},width:{type:"number"},x:{type:"number"},y:{type:"number"}},required:["type"],type:"object"},Layout:{additionalProperties:!1,properties:{h:{type:"number"},w:{type:"number"},x:{type:"number"},y:{type:"number"}},required:["h","w","x","y"],type:"object"},LocksByViewUid:{additionalProperties:{type:"string"},type:"object"},OneOfFilter:{additionalProperties:!1,properties:{field:{description:"A filter is applied based on the values of the specified data field",type:"string"},not:{description:'when `{"not": true}`, apply a NOT logical operation to the filter.\n\n__Default:__ `false`',type:"boolean"},oneOf:{description:"Check whether the value is an element in the provided list.",items:{type:["string","number","null"]},type:"array"},type:{const:"filter",type:"string"}},required:["field","oneOf","type"],type:"object"},Overlay:{additionalProperties:!1,properties:{chromInfoPath:{type:"string"},includes:{items:{},type:"array"},options:{$ref:"#/definitions/OverlayOptions"},type:{type:"string"},uid:{type:"string"}},type:"object"},OverlayOptions:{additionalProperties:!1,properties:{extent:{items:{},type:"array"},fill:{type:"string"},fillOpacity:{type:"number"},minWidth:{type:"number"},outline:{type:"string"},outlineOpacity:{type:"number"},outlinePos:{anyOf:[{items:{},type:"array"},{type:"string"}]},outlineWidth:{type:"number"},stroke:{type:"string"},strokeOpacity:{type:"number"},strokePos:{anyOf:[{items:{},type:"array"},{type:"string"}]},strokeWidth:{type:"number"}},type:"object"},RangeFilter:{additionalProperties:!1,properties:{field:{description:"A filter is applied based on the values of the specified data field",type:"string"},inRange:{description:"Check whether the value is in a number range.",items:{type:"number"},type:"array"},not:{description:'when `{"not": true}`, apply a NOT logical operation to the filter.\n\n__Default:__ `false`',type:"boolean"},type:{const:"filter",type:"string"}},required:["field","inRange","type"],type:"object"},Track:{anyOf:[{$ref:"#/definitions/HeatmapTrack"},{$ref:"#/definitions/CombinedTrack"},{$ref:"#/definitions/IndependentViewportProjectionTrack"},{$ref:"#/definitions/EnumTrack"}]},Tracks:{additionalProperties:!1,properties:{bottom:{items:{$ref:"#/definitions/Track"},type:"array"},center:{items:{$ref:"#/definitions/Track"},type:"array"},gallery:{items:{$ref:"#/definitions/Track"},type:"array"},left:{items:{$ref:"#/definitions/Track"},type:"array"},right:{items:{$ref:"#/definitions/Track"},type:"array"},top:{items:{$ref:"#/definitions/Track"},type:"array"},whole:{items:{$ref:"#/definitions/Track"},type:"array"}},required:["top","left","center","right","bottom","gallery","whole"],type:"object"},ValueScaleLocks:{additionalProperties:!1,properties:{locksByViewUid:{$ref:"#/definitions/LocksByViewUid"},locksDict:{}},required:["locksByViewUid"],type:"object"},View:{additionalProperties:!1,properties:{autocompleteSource:{type:"string"},chromInfoPath:{type:"string"},genomePositionSearchBox:{$ref:"#/definitions/GenomePositionSearchBox"},genomePositionSearchBoxVisible:{type:"boolean"},initialXDomain:{items:{type:"number"},type:"array"},initialYDomain:{items:{type:"number"},type:"array"},layout:{$ref:"#/definitions/Layout"},overlays:{items:{$ref:"#/definitions/Overlay"},type:"array"},selectionView:{type:"boolean"},tracks:{$ref:"#/definitions/Tracks"},uid:{type:"string"},zoomFixed:{type:"boolean"},zoomLimits:{items:{type:["number","null"]},maxItems:2,minItems:2,type:"array"}},required:["tracks","layout"],type:"object"}};var Cli={$ref:sli,$schema:Ili,definitions:lli};function $re(e,i){const n=Sg(i).interval;if(!("chromosome"in e&&!Object.keys(n).find(o=>o===e.chromosome))){if(Poi(e))return[n[e.chromosome][0]+1,n[e.chromosome][1]];if(zoi(e))return e.interval;if(Ooi(e)){const r=n[e.chromosome][0],[o,l]=e.interval;return[r+o,r+l]}}}function cli(e,i){const n={},r=Yy;e.forEach(o=>{r.forEach(l=>{const c=o.spec()[l];if(!Ii(c)||c.domain===void 0)return;const{domain:u,type:f}=c;if(f==="quantitative"){const m=Array.from(u);if(!n[l])n[l]=m;else{const p=n[l];p[0]>m[0]&&(p[0]=m[0]),p[1]{r.forEach(l=>{const c=o.spec()[l];Ii(c)&&c.type==="genomic"||(o.setChannelDomain(l,n[l],i),o.generateScales())}),o.updateChannelValue()})}const Ali={compactLayout:!1,trackSourceServers:["https://server.gosling-lang.org/api/v1/"],views:[{genomePositionSearchBoxVisible:!1,genomePositionSearchBox:{autocompleteServer:"https://higlass.io/api/v1",autocompleteId:"P0PLbQMwTYGy-5uPIQid7A",chromInfoServer:"https://higlass.io/api/v1",chromInfoId:"hg38"},layout:{x:0,y:0,w:6.4,h:600},tracks:{top:[],left:[{type:"combined",width:130,height:600,contents:[{type:"gosling-track",server:"https://server.gosling-lang.org/api/v1/",tilesetUid:"cistrome-multivec",width:130,height:600,options:{showMousePosition:!0,mousePositionColor:"#000000",fontSize:24,labelPosition:"none",labelShowResolution:!1,labelColor:"black",labelBackgroundColor:"white",labelTextOpacity:1,labelLeftMargin:1,labelTopMargin:1,labelRightMargin:0,labelBottomMargin:0,backgroundColor:"transparent",spec:{spacing:10,orientation:"vertical",assembly:"hg38",layout:"linear",static:!1,xDomain:{interval:[0,1e9]},centerRadius:.3,xOffset:0,yOffset:0,style:{outlineWidth:.5},data:{url:"https://server.gosling-lang.org/api/v1/tileset_info/?d=cistrome-multivec",type:"multivec",row:"sample",column:"position",value:"peak",categories:["sample 1","sample 2","sample 3","sample 4"],binSize:4},mark:"rect",x:{field:"start",type:"genomic",axis:"left",domain:{interval:[0,1e9]},linkingId:"7f94b74e-25ec-4e67-8c75-3dc0f1b0d6bd"},xe:{field:"end",type:"genomic"},row:{field:"sample",type:"nominal",legend:!0},color:{field:"peak",type:"quantitative",legend:!0},tooltip:[{field:"start",type:"genomic",alt:"Start Position"},{field:"end",type:"genomic",alt:"End Position"},{field:"peak",type:"quantitative",alt:"Value",format:".2"},{field:"sample",type:"nominal",alt:"Sample"}],width:160,height:600,overlayOnPreviousTrack:!1},theme:{base:"light",root:{background:"white",titleColor:"black",titleBackgroundColor:"transparent",titleFontSize:18,titleFontFamily:"Arial",titleAlign:"left",titleFontWeight:"bold",subtitleColor:"gray",subtitleBackgroundColor:"transparent",subtitleFontSize:16,subtitleFontFamily:"Arial",subtitleFontWeight:"normal",subtitleAlign:"left",mousePositionColor:"#000000"},track:{background:"transparent",alternatingBackground:"transparent",titleColor:"black",titleBackground:"white",titleFontSize:24,titleAlign:"left",outline:"black",outlineWidth:1},legend:{position:"top",background:"white",backgroundOpacity:.7,labelColor:"black",labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",backgroundStroke:"#DBDBDB",tickColor:"black"},axis:{tickColor:"black",labelColor:"black",labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",baselineColor:"black",gridColor:"#E3E3E3",gridStrokeWidth:1,gridStrokeType:"solid",gridStrokeDash:[4,4]},markCommon:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},point:{color:"#E79F00",size:3,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},rect:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},triangle:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},area:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},line:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},bar:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},rule:{color:"#E79F00",size:1,stroke:"black",strokeWidth:1,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},link:{color:"#E79F00",size:1,stroke:"black",strokeWidth:1,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},text:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6],textAnchor:"middle",textFontWeight:"normal"},brush:{color:"gray",size:1,stroke:"black",strokeWidth:1,opacity:.3,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]}}}}]},{uid:"15483511-f6fb-11eb-914b-976b6ecda162",type:"axis-track",chromInfoPath:"https://s3.amazonaws.com/gosling-lang.org/data/hg38.chrom.sizes",options:{layout:"linear",outerRadius:null,width:160,height:600,theme:{base:"light",root:{background:"white",titleColor:"black",titleBackgroundColor:"transparent",titleFontSize:18,titleFontFamily:"Arial",titleAlign:"left",titleFontWeight:"bold",subtitleColor:"gray",subtitleBackgroundColor:"transparent",subtitleFontSize:16,subtitleFontFamily:"Arial",subtitleFontWeight:"normal",subtitleAlign:"left",mousePositionColor:"#000000"},track:{background:"transparent",alternatingBackground:"transparent",titleColor:"black",titleBackground:"white",titleFontSize:24,titleAlign:"left",outline:"black",outlineWidth:1},legend:{position:"top",background:"white",backgroundOpacity:.7,labelColor:"black",labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",backgroundStroke:"#DBDBDB",tickColor:"black"},axis:{tickColor:"black",labelColor:"black",labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",baselineColor:"black",gridColor:"#E3E3E3",gridStrokeWidth:1,gridStrokeType:"solid",gridStrokeDash:[4,4]},markCommon:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},point:{color:"#E79F00",size:3,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},rect:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},triangle:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},area:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},line:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},bar:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},rule:{color:"#E79F00",size:1,stroke:"black",strokeWidth:1,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},link:{color:"#E79F00",size:1,stroke:"black",strokeWidth:1,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},text:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6],textAnchor:"middle",textFontWeight:"normal"},brush:{color:"gray",size:1,stroke:"black",strokeWidth:1,opacity:.3,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]}},assembly:"hg38",stroke:"transparent",color:"black",fontSize:12,fontFamily:"Arial",fontWeight:"normal",tickColor:"black",tickFormat:"plain",tickPositions:"even",reverseOrientation:!1},width:30}],center:[],right:[],bottom:[],gallery:[],whole:[]},initialXDomain:[0,1e9],initialYDomain:[0,1e9],zoomFixed:!1,zoomLimits:[1,null],uid:"15483510-f6fb-11eb-914b-976b6ecda162",chromInfoPath:"https://s3.amazonaws.com/gosling-lang.org/data/hg38.chrom.sizes"},{genomePositionSearchBoxVisible:!1,genomePositionSearchBox:{autocompleteServer:"https://higlass.io/api/v1",autocompleteId:"P0PLbQMwTYGy-5uPIQid7A",chromInfoServer:"https://higlass.io/api/v1",chromInfoId:"hg38"},layout:{x:6.8,y:0,w:5.2,h:600},tracks:{top:[],left:[{type:"combined",width:130,height:600,contents:[{type:"gosling-track",server:"https://server.gosling-lang.org/api/v1/",tilesetUid:"cistrome-multivec",width:130,height:600,options:{showMousePosition:!0,mousePositionColor:"#000000",fontSize:24,labelPosition:"none",labelShowResolution:!1,labelColor:"black",labelBackgroundColor:"white",labelTextOpacity:1,labelLeftMargin:1,labelTopMargin:1,labelRightMargin:0,labelBottomMargin:0,backgroundColor:"transparent",spec:{spacing:10,orientation:"vertical",assembly:"hg38",layout:"linear",static:!1,xDomain:{interval:[0,1e9]},centerRadius:.3,xOffset:0,yOffset:0,style:{outlineWidth:.5},data:{url:"https://server.gosling-lang.org/api/v1/tileset_info/?d=cistrome-multivec",type:"multivec",row:"sample",column:"position",value:"peak",categories:["sample 1","sample 2","sample 3","sample 4"],binSize:4},mark:"rect",x:{field:"start",type:"genomic",domain:{interval:[0,1e9]},linkingId:"7f94b74e-25ec-4e67-8c75-3dc0f1b0d6bd"},xe:{field:"end",type:"genomic"},row:{field:"sample",type:"nominal",legend:!0},color:{field:"peak",type:"quantitative",legend:!0},tooltip:[{field:"start",type:"genomic",alt:"Start Position"},{field:"end",type:"genomic",alt:"End Position"},{field:"peak",type:"quantitative",alt:"Value",format:".2"},{field:"sample",type:"nominal",alt:"Sample"}],width:130,height:600},theme:{base:"light",root:{background:"white",titleColor:"black",titleBackgroundColor:"transparent",titleFontSize:18,titleFontFamily:"Arial",titleAlign:"left",titleFontWeight:"bold",subtitleColor:"gray",subtitleBackgroundColor:"transparent",subtitleFontSize:16,subtitleFontFamily:"Arial",subtitleFontWeight:"normal",subtitleAlign:"left",mousePositionColor:"#000000"},track:{background:"transparent",alternatingBackground:"transparent",titleColor:"black",titleBackground:"white",titleFontSize:24,titleAlign:"left",outline:"black",outlineWidth:1},legend:{position:"top",background:"white",backgroundOpacity:.7,labelColor:"black",labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",backgroundStroke:"#DBDBDB",tickColor:"black"},axis:{tickColor:"black",labelColor:"black",labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",baselineColor:"black",gridColor:"#E3E3E3",gridStrokeWidth:1,gridStrokeType:"solid",gridStrokeDash:[4,4]},markCommon:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},point:{color:"#E79F00",size:3,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},rect:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},triangle:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},area:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},line:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},bar:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},rule:{color:"#E79F00",size:1,stroke:"black",strokeWidth:1,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},link:{color:"#E79F00",size:1,stroke:"black",strokeWidth:1,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},text:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6],textAnchor:"middle",textFontWeight:"normal"},brush:{color:"gray",size:1,stroke:"black",strokeWidth:1,opacity:.3,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]}}}}]}],center:[],right:[],bottom:[],gallery:[],whole:[]},initialXDomain:[0,1e9],initialYDomain:[0,1e9],zoomFixed:!1,zoomLimits:[1,null],uid:"154b1b40-f6fb-11eb-914b-976b6ecda162"}],zoomLocks:{locksByViewUid:{},locksDict:{}},locationLocks:{locksByViewUid:{},locksDict:{}},editable:!1,chromInfoPath:"https://s3.amazonaws.com/gosling-lang.org/data/hg38.chrom.sizes"},WC=30,uli=e=>({genomePositionSearchBoxVisible:!1,genomePositionSearchBox:{autocompleteServer:"https://higlass.io/api/v1",autocompleteId:Hai(e),chromInfoServer:"https://higlass.io/api/v1",chromInfoId:e??"hg38"},layout:{w:12,h:12,x:0,y:0},tracks:{top:[],left:[],center:[],right:[],bottom:[],gallery:[],whole:[]},initialXDomain:[0,Sg(e).total],initialYDomain:[0,Sg(e).total],zoomFixed:!1});class dli{constructor(){this.assembly="hg38",this.hg={compactLayout:!1,trackSourceServers:[],views:[],zoomLocks:{locksByViewUid:{},locksDict:{}},locationLocks:{locksByViewUid:{},locksDict:{}}},this.setEditable(!1)}spec(){return this.hg}setViewOrientation(i){return this.orientation=i,this}addDefaultView(i,n){return this.hg.views.push(JSON.parse(JSON.stringify({...uli(n),uid:i}))),this}setAssembly(i){return this.assembly=i,this.setChromInfoPath(Sg(this.assembly).path),this}getAssembly(){return this.assembly}setTextTrack(i,n,r,o="black",l=14,c="normal",u="left",f="transparent",m="Arial"){var p;return this.getLastView()&&((p=this.getLastView().tracks.top)==null||p.push({type:"text",width:i,height:n,options:{backgroundColor:f,textColor:o,fontSize:l,fontWeight:c,fontFamily:m,offsetY:0,align:u,text:r}})),this}addBrush(i,n,r,o,l){var c,u,f,m,p,v;if(o)return(v=this.getView(n))==null||v.tracks.whole.push({type:i==="circular"?"brush-track":"viewport-projection-horizontal",uid:hA(),fromViewUid:o,options:{projectionFillColor:(c=l?.color)!=null?c:r.brush.color,projectionStrokeColor:(u=l?.stroke)!=null?u:r.brush.stroke,projectionFillOpacity:(f=l?.opacity)!=null?f:r.brush.opacity,projectionStrokeOpacity:(m=l?.opacity)!=null?m:r.brush.opacity,strokeWidth:(p=l?.strokeWidth)!=null?p:r.brush.strokeWidth,startAngle:l?.startAngle,endAngle:l?.endAngle,innerRadius:l?.innerRadius,outerRadius:l?.outerRadius}}),this}getLastView(){return this.hg.views[this.hg.views.length-1]}getMainTrackPosition(){return this.orientation==="vertical"?"left":"center"}getLastVisView(){const i=this.hg.views.filter(n=>{var r,o;return((o=(r=n.tracks[this.getMainTrackPosition()])==null?void 0:r[0])==null?void 0:o.type)==="combined"});return i[i.length-1]}getView(i){return this.hg.views.find(n=>n.uid===i)}validateSpec(i=!1){return RJe(Cli,this.spec(),i).state==="success"}setDomain(i,n){return i&&(this.getLastView().initialXDomain=$re(i,this.getAssembly())),n&&(this.getLastView().initialYDomain=$re(n,this.getAssembly())),this}adjustDomain(i="horizontal",n,r){if(i!=="vertical")return this;const o=this.getLastView().initialXDomain;if(!o)return this;const[l,c]=o,u=c-l,f=(l+c)/2;return this.getLastView().initialXDomain=[f-u/n/2/r*n,f+u/n/2/r*n],this}setZoomFixed(i){return this.getLastView().zoomFixed=i,this}setZoomLimits(i){return this.getLastView().zoomLimits=i,this}setLayout(i){return this.getLastView().layout=i,this}setEditable(i){return this.hg.editable=i,this}setChromInfoPath(i){return this.getLastView()&&(this.getLastView().chromInfoPath=i),this.hg.chromInfoPath=i,this}addTrackSourceServers(i){var n,r;return i&&((n=this.hg.trackSourceServers)==null?void 0:n.indexOf(i))===-1&&((r=this.hg.trackSourceServers)==null||r.push(i)),this}setMainTrack(i){var n;return this.getLastView()?(this.getLastView().tracks[this.getMainTrackPosition()]=[{type:"combined",uid:`${(n=i.uid)!=null?n:hA()}-${this.getMainTrackPosition()}-combined`,width:i.width-1,height:i.height,contents:[i]}],this):this}addTrackToCombined(i){var n;return this.getLastVisView()?((n=this.getLastVisView().tracks[this.getMainTrackPosition()][0])==null||n.contents.push(i),this):this}setAxisTrack(i,n="regular",r){if(!this.hg.views)return this;const o=i==="left"||i==="right"?"width":"height",l={type:"axis-track",chromInfoPath:this.hg.chromInfoPath,options:{...r,assembly:this.getAssembly(),stroke:"transparent",color:r.theme.axis.labelColor,fontSize:r.theme.axis.labelFontSize,fontFamily:r.theme.axis.labelFontFamily,fontWeight:r.theme.axis.labelFontWeight,tickColor:r.theme.axis.tickColor,tickFormat:n==="narrower"?"si":"plain",tickPositions:n==="regular"?"even":"ends",reverseOrientation:i==="bottom"||i==="right"}};if(r.layout==="circular")this.addTrackToCombined({...l,options:{...l.options,layout:"circular"}});else{const c={...l,[o]:WC};if(i==="left"){if(this.getLastView().tracks.left.filter(u=>u.type==="axis-track").length!==0)return this;this.getLastView().tracks.left=boi(this.getLastView().tracks.left,0,c)}else if(i==="right"){if(this.getLastView().tracks.right.filter(u=>u.type==="axis-track").length!==0)return this;this.getLastView().tracks.right.push(c)}else{if(this.getLastView().tracks[i].filter(u=>u.type==="axis-track").length!==0)return this;this.getLastView().tracks[i].push(c)}}return this}setExampleHiglassViewConfig(){this.hg=Ali}}function k9(e,i,n,r){const o=r&&r!==0?r:void 0;let l=0;switch(i){case"less-than":case"LT":case"lt":l=n>e?o?(n-e)/o:1:0;break;case"less-than-or-equal-to":case"LTET":case"ltet":l=n>=e?o?(n-e)/o:1:0;break;case"greater-than":case"GT":case"gt":l=nr?l.indexOf(c[n])===-1:l.indexOf(c[n])!==-1)}else if(joi(e)){const{inRange:l}=e;o=o.filter(c=>{const u=+c[n];return r?!(l[0]<=u&&u<=l[1]):l[0]<=u&&u<=l[1]})}else if($oi(e)){const{include:l}=e;o=o.filter(c=>r?`${c[n]}`.includes(l):!`${c[n]}`.includes(l))}return o}function hli(e,i){const{fields:n,separator:r,newField:o}=e;let l=Array.from(i);return l=l.map(c=>{const u=n.map(f=>c[f]);return c[o]=u.join(r),c}),l}function fli(e,i){const{field:n,replace:r,newField:o}=e;let l=Array.from(i);return l=l.map(c=>(c[o]=c[n],r.forEach(u=>{const{from:f,to:m}=u;c[o]=c[o].toString().replaceAll(f,m)}),c)),l}function mli(e,i){const{field:n,base:r,newField:o}=e;let l=Array.from(i);return l=l.map(c=>(+c[n]&&(r==="e"?c[o??n]=Math.log(+c[n]):c[o??n]=Math.log(+c[n])/Math.log(r??10)),c)),l}function pli(e,i){const{startField:n,endField:r,newField:o}=e,l=Array.from(i);return l.forEach(c=>{const u=c[n],f=c[r];!u||!f||(c[o]=Math.abs(+f-+u))}),l}function bli(e,i){const{firstBp:n,secondBp:r,newField:o}=e,l=Array.from(i),[c,u,f,m,p]=["DUP","TRA","DEL","t2tINV","h2hINV"];return l.forEach(v=>{const B=v[n.chrField],G=v[r.chrField];if(B!==G){v[o]=u;return}let T=v[n.posField],V=v[r.posField],E=v[n.strandField],W=v[r.strandField];if(T>V){const x=T,k=E;T=V,E=W,V=x,W=k}switch(`${E}${W}`){case"+-":v[o]=f;break;case"--":v[o]=m;break;case"++":v[o]=p;break;case"-+":v[o]=c;break;default:v[o]="unknown"}}),l}function yli(e,i,n){const{startField:r,endField:o,newField:l,groupField:c}=e,u={},f=1;return i.forEach(p=>{const v=n(p[r]),B=n(p[o]),G=c?p[c]:"__NO_GROUP__",T=Math.floor(v);for(let V=T;V{const[v,B]=p;return Object.entries(B).map(G=>{const[T,V]=G;return{[r]:n.invert(+T),[o]:n.invert(+T+f),[l??"coverage"]:V,[c??"group"]:v}})})}function vli(e,i,n){const{boundingBox:r,method:o,newField:l}=e,{startField:c,endField:u,groupField:f}=r;let m=0;r.padding&&n&&!r.isPaddingBP?m=Math.abs(n.invert(r.padding)-n.invert(0)):r.padding&&r.isPaddingBP&&(m=r.padding);const p=Array.from(i);if(p&&p.length>0&&(!Object.keys(p[0]).find(v=>v===c)||!Object.keys(p[0]).find(v=>v===u)))return p;if(o==="pile"){const{maxRows:v}=e,B={};p.sort((T,V)=>T[c]-V[c]).forEach(T=>{const V=+T[c]-m,E=+T[u]+m,W=f?T[f]:"__NO_GROUP__";B[W]||(B[W]=[]);let x=B[W].findIndex(k=>EB[c]-G[c]).forEach(B=>{let G=B[c]-m,T=B[u]+m,V=v.filter(E=>E.start===G&&T===E.end||E.start0){let E=0;do V=v.filter(W=>W.start===G&&T===W.end||W.start0&&(E%2===0?(G+=m*E,T+=m*E):(G-=m*E,T-=m*E)),E++;while(V.length>0&&E<1e3)}B[`${l}Start`]=`${G+m}`,B[`${l}Etart`]=`${T-m}`,v.push({start:G,end:T})})}return p}function Zli(e,i,n="hg38"){const{separator:r,fields:o,flag:l}=e;let c=Array.from(i);return c=c.map(u=>{const f=[];return o.forEach(m=>{const{field:p,type:v,newField:B,chrField:G}=m;u[p].toString().split(r).forEach((V,E)=>{let W=V;v==="genomic"&&(W=Sg(n).interval[u[G]][0]+ +V),f[E]?f[E][B]=W:f[E]=Object.assign(JSON.parse(JSON.stringify(u)),{[B]:W,[l.field]:l.value})})}),[u,...f]}).reduce((u,f)=>u.concat(f),[]),c}function Bli(e,i){const{field:n,genomicField:r,baseGenomicField:o,genomicLengthField:l}=e;let c=Array.from(i);return c=c.map(u=>{let f=JSON.parse(u[n]);return f=f.map(m=>{var p,v;return m[r]&&u[o]&&(m[`${r}_start`]=+m[r]+ +u[o],m[`${r}_end`]=+m[r]+ +u[o]+ +m[l]),Object.assign(JSON.parse(JSON.stringify(u)),{...m,[`${r}_start`]:m[`${r}_start`],[`${r}_end`]:m[`${r}_end`],type:(v=(p=m.type)!=null?p:m.variant)!=null?v:null,isParsedRow:"yes"})}),[u,...f]}).reduce((u,f)=>u.concat(f),[]),c}function Gli(e,i){if(tai(e).length===0)return i;const n=gee(e,"nominal");if(n.length!==1)return console.warn("Currently, we only support aggregating datasets with single nominal field."),i;const r=e[n[0]];if(!Ii(r))return i;const o=r.field;if(!o)return i;const l=[...gee(e,"quantitative"),...gee(e,"genomic")],c=[],u=Array.from(new Set(i.map(m=>m[o])));let f=!1;return u.forEach(m=>{const p={};p[o]=m,l.forEach(v=>{const B=e[v];if(!Ii(B)){f=!0;return}const{field:G}=B;if(!G||!("aggregate"in B)){f=!0;return}p[G]=B.aggregate==="max"?Math.max(...i.filter(T=>T[o]===m).map(T=>+T[G])):Math.min(...i.filter(T=>T[o]===m).map(T=>+T[G]))}),c.push(p)}),f?i:c}const qre={NOMINAL_COLOR:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],NOMINAL_COLOR_EXTENDED:["#d60000","#018700","#b500ff","#05acc6","#97ff00","#ffa52f","#ff8ec8","#79525e","#00fdcf","#afa5ff","#93ac83","#9a6900","#366962","#d3008c","#fdf490","#c86e66","#9ee2ff","#00c846","#a877ac","#b8ba01","#f4bfb1","#ff28fd","#f2cdff","#009e7c","#ff6200","#56642a","#953f1f","#90318e","#ff3464","#a0e491","#8c9ab1","#829026","#ae083f","#77c6ba","#bc9157","#e48eff","#72b8ff","#c6a5c1","#ff9070","#d3c37c","#bceddb","#6b8567","#916e56","#f9ff00","#bac1df","#ac567c","#ffcd03","#ff49b1","#c15603","#5d8c90","#c144bc","#00753f","#ba6efd","#00d493","#00ff75","#49a150","#cc9790","#00ebed","#db7e01","#f77589","#b89500","#c84248","#00cff9","#755726","#85d401","#ebffd4","#a77b87","#db72c8","#cae256","#8abf5d","#a1216b","#855b89","#89bacf","#ffbad6","#b6cfaa","#97414d","#67aa00","#fde1b1","#ff3628","#80793d","#d6e8ff","#a795c6","#7ea59a","#d182a3","#54823b","#e6a872","#9cffff","#da5480","#05b3aa","#ffaaf6","#d1afef","#da015d","#ac1a13","#60b385","#d442fd","#acaa59","#fb9ca7","#b3723b","#f26952","#aed1d4","#9affc3","#dbb333","#eb01c3","#9900c4","#cfff9e","#a55949","#3b6d01","#008579","#959167","#89dbb3","#6d7400","#aa5dca","#07ef00","#804f3d","#d88052","#ffc862","#b8009e","#99acdd","#904f00","#8c4470","#4f6e52","#ff8734","#c68ecd","#d4e29e","#b1826d","#9cfb75","#56dd77","#f90087","#a1cdff","#13cad1","#118e54","#d154a5","#00dfc3","#a3832f","#77975b","#baaa80","#70a3af","#d6fbff","#e8013a","#d84621","#ff82ed","#b63862","#b6cd72","#97626b","#897490","#00a316","#00f4a1","#bf90f2","#89e4d8","#a34d95","#6e5d00","#8cc68e","#95aa2a","#c672dd","#b33b01","#d69a36","#dfacb6","#009aa0","#599000","#97bca8","#ac8ca8","#dad4ff","#547c72","#00ba69","#ffc38e","#b800d4","#dfcf5b","#629a7b","#bfedbc","#c1bdfd","#80d3dd","#e2857e","#f9eb4d","#bf6d82","#caff4f","#ef72aa","#ed67ff","#9946ae","#6d6942","#e25660","#dd662d","#9cdb5d","#e29ccf","#b87500","#c6002d","#dfbcda","#59b5df","#ff59da","#38c1a1","#9e698c","#acaac8","#95622f","#b55662","#2b7e60","#b1e400","#eda590","#95fde2","#ff548e","#bd6ea1","#aa3b36","#d8cf00","#aa80cd","#a08052","#e100e8","#c35b3d","#b53a85","#8c7700","#dbbc95","#529e93","#afbc82","#91b5b6","#a75423","#ffd4ef","#79ae6b","#5db54b","#80fb9a","#48ffef","#979548","#9387a7","#31d400","#6ee956","#b6d4eb","#705470","#f2db8a","#aad4c1","#7ecdf2","#89ba00","#64b6ba","#ffb500","#c38285","#caaa5e","#647748","#59e2ff","#df4dcd","#e9ff79","#bc66b8","#c395a5","#64c674","#d19570","#70cf4f","#aa6e66","#9c60a5","#00b800","#e299b3","#bc006b","#b3e8ef","#cdbfe4","#77a342","#856277","#568e5b","#9eafc4","#e82fa0","#247c2a","#826723","#bfbc4d","#ddd3a5"],QUANTITATIVE_COLOR:"viridis",SIZE:3,SIZE_RANGE:[2,6]};function WJe(e="light"){if(typeof e=="string")return wre(e)?Tre(e):e==="dark"||e==="light"?iF[e]:iF.light;{let i=JSON.parse(JSON.stringify(iF.light));return wre(e.base)?i=Tre(e.base):(e.base==="light"||e.base==="dark")&&(i=JSON.parse(JSON.stringify(iF[e.base]))),Object.keys(i).forEach(n=>{e[n]&&n!=="base"&&(i[n]=Object.assign(JSON.parse(JSON.stringify(i[n])),JSON.parse(JSON.stringify(e[n]))))}),i}}const ZC={color:qre.NOMINAL_COLOR[0],size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:qre.NOMINAL_COLOR,quantitativeSizeRange:[2,6]},Fc={...ZC,stroke:"white"},iF={light:{base:"light",root:{background:"white",titleColor:"black",titleBackgroundColor:"transparent",titleFontSize:18,titleFontFamily:"Arial",titleAlign:"left",titleFontWeight:"bold",subtitleColor:"gray",subtitleBackgroundColor:"transparent",subtitleFontSize:16,subtitleFontFamily:"Arial",subtitleFontWeight:"normal",subtitleAlign:"left",showMousePosition:!0,mousePositionColor:"#000000"},track:{background:"transparent",alternatingBackground:"transparent",titleColor:"black",titleBackground:"white",titleFontSize:24,titleAlign:"left",outline:"black",outlineWidth:1},legend:{position:"top",background:"white",backgroundOpacity:.7,labelColor:"black",labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",backgroundStroke:"#DBDBDB",tickColor:"black"},axis:{tickColor:"black",labelColor:"black",labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",baselineColor:"black",gridColor:"#E3E3E3",gridStrokeWidth:1,gridStrokeType:"solid",gridStrokeDash:[4,4]},markCommon:{...ZC},point:{...ZC,size:3},rect:{...ZC},triangle:{...ZC},area:{...ZC},line:{...ZC},bar:{...ZC},rule:{...ZC,strokeWidth:1},link:{...ZC,strokeWidth:1},text:{...ZC,textAnchor:"middle",textFontWeight:"normal"},brush:{...ZC,color:"gray",opacity:.3,stroke:"black",strokeWidth:1}},dark:{base:"dark",root:{background:"black",titleColor:"white",titleBackgroundColor:"transparent",titleFontSize:18,titleFontFamily:"Arial",titleAlign:"middle",titleFontWeight:"bold",subtitleColor:"lightgray",subtitleBackgroundColor:"transparent",subtitleFontSize:16,subtitleFontFamily:"Arial",subtitleAlign:"middle",subtitleFontWeight:"normal",showMousePosition:!0,mousePositionColor:"#FFFFFF"},track:{background:"transparent",alternatingBackground:"transparent",titleColor:"white",titleBackground:"black",titleFontSize:18,titleAlign:"left",outline:"white",outlineWidth:1},legend:{position:"right",background:"black",backgroundOpacity:.7,labelColor:"white",labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",backgroundStroke:"#DBDBDB",tickColor:"white"},axis:{tickColor:"white",labelColor:"white",labelFontSize:10,labelFontWeight:"normal",labelFontFamily:"Arial",baselineColor:"white",gridColor:"gray",gridStrokeWidth:1,gridStrokeType:"solid",gridStrokeDash:[4,4]},markCommon:{...Fc},point:{...Fc,size:3},rect:{...Fc},triangle:{...Fc},area:{...Fc},line:{...Fc},bar:{...Fc},rule:{...Fc,strokeWidth:1},link:{...Fc,strokeWidth:1},text:{...Fc,textAnchor:"middle",textFontWeight:"normal"},brush:{...Fc,color:"lightgray",opacity:.3,stroke:"white",strokeWidth:1}}},Sli=([e,i],[n,r],[o,l],[c,u])=>{const f=Math.sqrt((e-n)**2+(i-r)**2);if(fMath.sqrt((e-n)**2+(i-r)**2)e<=n&&n<=i,Tli=(e,i,n=5)=>ege(e,i-n)&&ege(e,i+n),Rli=(e,i)=>i.filter((n,r)=>r%2===0).every(n=>ege(e,n)),Vli=([e,i],n,r=5)=>{let o,l,c,u,f=!1;for(let m=0;m0?V=Math.sqrt((i-u)**2+(e-c)**2):T<0?V=Math.sqrt((i-l)**2+(e-o)**2):V=Math.abs(p[0]*B[1]-p[1]*B[0])/Math.sqrt(p[0]**2+p[1]**2),V{let r,o,l,c,u=!1;for(let f=0,m=n.length-2;fi!=c>i&&e<(l-r)*(i-o)/(c-o)+r&&(u=!u),m=f;return u};class Hli{constructor(){this.data=[]}size(){return this.data.length}addPolygonBasedEvent(i,n){this.data.push({uid:hA(),type:"polygon",value:i,polygon:n})}addPointBasedEvent(i,n){this.data.push({uid:hA(),type:"point",value:i,polygon:n})}addLineBasedEvent(i,n){this.data.push({uid:hA(),type:"line",value:i,polygon:n})}clear(){this.data=[]}find(i,n,r=!1){const o=Array.from(this.data);return r&&o.reverse(),o.find(l=>this.isMouseWithin(l,i,n))}findAll(i,n,r=!1){const o=Array.from(this.data);return r&&o.reverse(),o.filter(l=>this.isMouseWithin(l,i,n))}getSiblings(i,n){const r=[],o=Array.from(new Set(i.map(l=>l.uid)));return i.forEach(l=>{const c=l.value[n];c&&r.push(...this.data.filter(u=>u.value[n]===c&&o.indexOf(u.uid)===-1))}),r}isMouseWithin(i,n,r){switch(i.type){case"point":return wli([n,r],i.polygon);case"line":return Vli([n,r],i.polygon);case"polygon":default:return Eli([n,r],i.polygon)}}findAllWithinRange(i,n,r=!1){const o=Array.from(this.data);return r&&o.reverse(),o.filter(l=>this.isWithinRange(l,i,n))}isWithinRange(i,n,r){switch(i.type){case"point":return Tli([n,r],i.polygon[0],i.polygon[2]);case"line":case"polygon":default:return Rli([n,r],i.polygon)}}}class Wli{constructor(i,n,r){this.id=LK(),this.theme=r??WJe(),this.dataOriginal=JSON.parse(JSON.stringify(n)),this.dataAggregated=JSON.parse(JSON.stringify(n)),this.specOriginal=JSON.parse(JSON.stringify(i)),this.specComplete=JSON.parse(JSON.stringify(i)),this.channelScales={},this.mouseEventModel=new Hli;const o=this.validateSpec();if(!o.valid){console.warn("Gosling specification is not valid!",o.errorMessages);return}this.generateCompleteSpec(this.specComplete),this.flipRanges(this.specComplete),this.generateScales(),this.dataAggregated=Gli(this.spec(),this.dataAggregated)}getId(){return this.id}getRenderingId(){var i;return(i=this.spec()._renderingId)!=null?i:this.getId()}originalSpec(){return this.specOriginal}spec(){return this.specComplete}data(){return this.dataAggregated}getMouseEventModel(){return this.mouseEventModel}generateCompleteSpec(i){if(!i.width||!i.height){console.warn("Size of track is not determined yet.");return}if(i.orientation==="vertical"){const o=i.width;i.width=i.height,i.height=o}const n=this.getGenomicChannelKey();let r=!1;n==="x"&&(r=Ii(i.x)&&i.x.axis!==void 0&&i.x.axis!=="none"),n==="y"&&(r=Ii(i.y)&&i.y.axis!==void 0&&i.y.axis!=="none"),i.layout!=="circular"?Ii(i.x)&&i.x.axis!==void 0&&i.x.axis!=="none"&&(i.height-=WC):n==="x"&&r&&Ii(i.x)&&i.x.axis==="top"?i.outerRadius=i.outerRadius-WC:n==="x"&&r&&Ii(i.x)&&i.x.axis==="bottom"&&(i.innerRadius=i.innerRadius+WC),Yy.forEach(o=>{const l=i[o];Ii(l)&&!("zeroBaseline"in l)&&l.type==="quantitative"&&(l.zeroBaseline=!0)}),this.addScaleMaterials(i)}flipRanges(i){Ii(i.y)&&i.y.flip&&Array.isArray(i.y.range)&&(i.y.range=i.y.range.reverse())}getGenomicChannelKey(){return EJe(this.spec())}getGenomicChannel(){return ole(this.spec())}setChannelDomain(i,n,r){const o=this.originalSpec()[i];if(!r&&Ii(o)&&o.domain!==void 0)return;const l=this.specComplete[i];Ii(l)&&(l.domain=n)}setChannelRange(i,n){const r=this.specComplete[i];Ii(r)&&(r.range=n)}updateChannelValue(){if(this.originalSpec().y===void 0){const i=this.spec().y,n=this.getChannelDomainArray("row");i&&ZY(i)&&n&&this.spec().mark!=="withinLink"&&(i.value=this.spec().height/n.length/2)}}encodedValue(i,n){var r;if(i==="text"&&n!==void 0)return`${+n?~~n:n}`;const o=this.spec()[i],l=Ii(o)?o.type:ZY(o)?"constant":void 0;if(l){if(l==="constant")return this.channelScales[i]();if(n!==void 0&&(n===null&&(l==="quantitative"?n=0:l==="nominal"&&(n="null")),typeof this.channelScales[i]=="function"))switch(i){case"x":case"y":case"x1":case"y1":case"xe":case"ye":case"x1e":if(l==="quantitative"||l==="genomic")return this.channelScales[i](n);if(l==="nominal")return this.channelScales[i](n);break;case"stroke":case"color":if(l==="quantitative"){const c=this.channelScales[i].copy(),u=c.domain(),f=u[1]-u[0],m=Array.from((r=o.scaleOffset)!=null?r:[0,1]);return c.domain([u[0]+f*m.sort()[0],u[0]+f*m.sort()[1]])(n)}if(l==="nominal")return this.channelScales[i](n);break;case"size":if(l==="quantitative")return this.channelScales[i](n);if(l==="nominal")return this.channelScales[i](n);break;case"row":if(l==="nominal")return this.channelScales[i](n);break;case"strokeWidth":case"opacity":if(l==="quantitative")return this.channelScales[i](n);break;default:console.warn(`${i} is not supported for encoding values, so returning a undefined value`);return}}}trackVisibility(i){const n=this.spec();if(!n.visibility||n.visibility.length===0||n.visibility.filter(o=>o.target==="track").length===0)return!0;let r=!0;return n.visibility.filter(o=>o.target==="track").forEach(o=>{const{operation:l,measure:c,threshold:u}=o;let f;c==="zoomLevel"?f=i[c]:f=n[c],f!==void 0&&(r=r&&k9(f,l,u)===1)}),r}markVisibility(i,n){const r=this.spec();if(!r.visibility||r.visibility.length===0||r.visibility.filter(l=>l.target==="mark").length===0)return 1;let o=1;return r.visibility.filter(l=>l.target==="mark").forEach(l=>{const{operation:c,threshold:u,conditionPadding:f,transitionPadding:m,measure:p}=l,v=f??0,B=r.mark;let G=1;if(B==="text"&&u==="|xe-x|"&&p==="width"){const T=this.encodedPIXIProperty("xe",i),V=this.encodedPIXIProperty("x",i);T!==void 0&&n?.width&&(G=k9(n.width+v,c,Math.abs(T-V),m))}else p==="width"&&typeof u=="number"&&n?.width?G=k9(n.width+v,c,u,m):p==="zoomLevel"&&typeof u=="number"&&n?.zoomLevel&&(G=k9(n.zoomLevel,c,u,m));o>G&&(o=G)}),o}visualPropertyByChannel(i,n){const r=n!==void 0?Zg(n,this.spec()[i]):void 0;return this.encodedValue(i,r)}encodedPIXIProperty(i,n,r){const o=this.spec().mark;if(["text","color","row","stroke","opacity","strokeWidth","x","y","xe","x1","x1e","ye","size"].includes(i))return this.visualPropertyByChannel(i,n);switch(o){case"bar":return coi(this,i,n,r);case"point":case"text":return Ioi(this,i,n);case"rect":return doi(this,i,n,r);default:return}}addScaleMaterials(i){const n=this.data(),r=this.getGenomicChannel();if(!r||!r.field){console.warn("Genomic field is not provided in the specification");return}if(typeof i.width>"u"||typeof i.height>"u"){console.warn("Track size is not determined yet");return}Yy.forEach(o=>{var l,c,u,f;const m=i[o];if(eai(i,o)&&Ii(m)){const p=vP(n,B=>B[r.field]),v=[...p.keys()];if(!m.domain){const B="zeroBaseline"in m&&m.zeroBaseline?0:mY(v.map(T=>yke(p.get(T).map(V=>m.field?V[m.field]:void 0)))),G=mE(v.map(T=>yke(p.get(T).map(V=>m.field?V[m.field]:void 0))));m.domain=[B,G]}if(!m.range){const B=i.row,G=Ii(B)?B.field:void 0,T=(l=this.getChannelDomainArray("row"))!=null?l:G?Array.from(new Set(n.map(E=>E[G]))):[1],V=i.height/T.length;switch(o){case"x":m.range=[0,i.width];break;case"y":m.range=[0,V];break}}}else{const p=i.row,v=Ii(p)?p.field:void 0,B=(c=this.getChannelDomainArray("row"))!=null?c:v?Array.from(new Set(n.map(T=>T[v]))):[1],G=i.height/B.length;if(m){if(Ii(m)&&(m.type==="quantitative"||m.type==="genomic")){if(m.domain===void 0){const T="zeroBaseline"in m&&m.zeroBaseline?0:(u=mY(n.map(E=>+E[m.field])))!=null?u:0,V=(f=mE(n.map(E=>+E[m.field])))!=null?f:0;m.domain=[T,V]}else m.type==="genomic"&&!KXe(m.domain)&&(m.domain=$re(m.domain));if((o==="color"||o==="stroke")&&m.type==="quantitative"&&!m.scaleOffset&&(m.scaleOffset=[0,1]),!m.range){let T;switch(o){case"x":case"xe":case"x1":case"x1e":T=[0,i.width];break;case"y":case"ye":T=[0,G];break;case"color":case"stroke":T=qre.QUANTITATIVE_COLOR;break;case"size":T=this.theme.markCommon.quantitativeSizeRange;break;case"strokeWidth":T=[1,3];break;case"opacity":T=[0,1];break}T&&(m.range=T)}}else if(Ii(m)&&m.type==="nominal"&&(m.domain===void 0&&(m.domain=Array.from(new Set(n.map(T=>{var V;return(V=T[m.field])!=null?V:"null"})))),!m.range)){let T=2,V;switch(o){case"x":case"xe":V=[0,i.width];break;case"y":case"ye":V=[G,0];break;case"color":case"stroke":V=this.theme.markCommon.nominalColorRange;break;case"row":V=[0,i.height];break;case"size":V=m.domain.map(()=>T++);break}V&&(m.range=V)}}else{let T;switch(o){case"x":T=i.width/2;break;case"y":i.mark==="withinLink"?T=G:T=G/2;break;case"size":i.mark==="line"?T=this.theme.line.size:i.mark==="bar"||i.mark==="rect"||i.mark==="triangleRight"||i.mark==="triangleLeft"||i.mark==="triangleBottom"||i.stretch&&i.mark==="point"&&Ii(i.x)&&Ii(i.xe)?T=void 0:i.mark==="text"?T=12:T=this.theme.point.size;break;case"color":T=this.theme.markCommon.color;break;case"row":T=0;break;case"stroke":i.mark==="text"?T=this.theme.text.stroke:T=this.theme.markCommon.stroke;break;case"strokeWidth":i.mark==="rule"?T=this.theme.rule.strokeWidth:i.mark==="withinLink"||i.mark==="betweenLink"?T=this.theme.link.strokeWidth:i.mark==="text"?T=this.theme.text.strokeWidth:T=this.theme.markCommon.strokeWidth;break;case"opacity":T=this.theme.markCommon.opacity;break;case"text":T="";break}typeof T<"u"&&(i[o]={value:T})}}}),[["x","xe"],["y","ye"]].forEach(o=>{const[l,c]=o,u=i[l],f=i[c];if(Ii(u)&&Ii(f)&&u.type===f.type&&u.domain&&f.domain&&Array.isArray(u.domain)&&Array.isArray(f.domain)){if(u.type==="genomic"||u.type==="quantitative"){const m=mY([u.domain[0],f.domain[0]]),p=mE([u.domain[1],f.domain[1]]);u.domain=f.domain=[m,p]}else if(u.type==="nominal"){const m=Array.from(new Set([...u.domain,...f.domain]));u.range=f.range=m}}})}generateScales(){const i=this.spec();Yy.forEach(n=>{const r=i[n];if(ZY(r))this.channelScales[n]=()=>r.value;else if(Ii(r)){if(n==="text")return;const o=r.domain,l=r.range;if(o===void 0||l===void 0)return;if(r.type==="quantitative"||r.type==="genomic")switch(n){case"x":case"x1":case"xe":case"x1e":case"y":case"ye":case"size":case"opacity":case"strokeWidth":this.channelScales[n]=dv().domain(o).range(l);break;case"color":case"stroke":let c=oLe;Object.keys(zK).includes(l)&&(c=zK[l]),this.channelScales[n]=ZOe(c).domain(o);break}else if(r.type==="nominal")switch(n){case"x":case"xe":case"y":case"ye":case"row":this.channelScales[n]=hOe().domain(o).range(l);break;case"size":this.channelScales[n]=EK().domain(o).range(l);break;case"color":case"stroke":this.channelScales[n]=EK(l).domain(o);break}}})}getChannelScale(i){return this.channelScales[i]}setChannelScale(i,n){this.channelScales[i]=n}addDataRows(i){this.dataAggregated=[...this.dataAggregated,...i]}isShowYAxis(){const i=this.spec(),n=this.getChannelDomainArray("y"),r=this.getChannelRangeArray("y");return Ii(i.y)&&i.y.axis!=="none"&&i.y.type==="quantitative"&&!!n&&!!r}getChannelDomainArray(i){const n=this.spec()[i];return Ii(n)&&KXe(n.domain)?n.domain:void 0}getChannelRangeArray(i){const n=this.spec()[i];return Ii(n)&&qoi(n.range)?n.range:void 0}validateSpec(){return VJe(this.originalSpec())}}const Nli="gosling-data-row-uid";function kli(e,i){var n,r,o,l,c,u,f,m,p,v,B,G,T,V,E,W;const x=[];if(!LIe(e.data)){console.warn("No data is specified");return}if(e.data.type==="vector"||e.data.type==="bigwig"){if(!("dense"in i))return;const k=(n=e.data.binSize)!=null?n:1,F=i.dense,Y=i.tileSize,L=i.tileWidth/i.tileSize,O=(r=e.data.value)!=null?r:"value",Q=(o=e.data.column)!=null?o:"position",X=(l=e.data.start)!=null?l:"start",$=(c=e.data.end)!=null?c:"end",ee=`${O}_min`,ne=`${O}_max`,ge=(u=e.data.aggregation)!=null?u:"mean";let Ae=0,_=Number.MAX_SAFE_INTEGER,de=Number.MIN_SAFE_INTEGER,Ze=Number.MIN_SAFE_INTEGER,me=Number.MAX_SAFE_INTEGER;Array.from(Array(Y).keys()).forEach((be,Ee)=>{if(k===1){const Je=F[Ee]/(ge==="mean"?L:1);x.push({[O]:Je,[Q]:i.tileX+(Ee+.5)*L,[X]:i.tileX+Ee*L,[$]:i.tileX+(Ee+1)*L,[ee]:Je,[ne]:Je})}else if(Ee%k===0)Ae=_=de=F[Ee],Ze=Ee,me=Ee+k;else if(Ee%k===k-1)x.push({[O]:Ae/k/(ge==="mean"?L:1),[Q]:i.tileX+(Ze+k/2)*L,[X]:i.tileX+Ze*L,[$]:i.tileX+me*L,[ee]:_,[ne]:de});else if(Ee===Y-1){const Je=Y%k,Ue=Ze+Je;x.push({[O]:Ae/Je/(ge==="mean"?L:1),[Q]:i.tileX+(Ze+Je/2)*L,[X]:i.tileX+Ze*L,[$]:i.tileX+Ue*L,[ee]:_,[ne]:de})}else Ae+=F[Ee],_>F[Ee]&&(_=F[Ee]),de{let be=0,Ee=Number.MIN_SAFE_INTEGER,Je=Number.MAX_SAFE_INTEGER,Ue=Number.MAX_SAFE_INTEGER,dt=Number.MIN_SAFE_INTEGER;Array.from(Array(O).keys()).forEach((rt,ke)=>{if(k===1){const ze=L[O*me+ke]/(de==="mean"?Q:1);x.push({[X]:Ze,[$]:ze,[ee]:i.tileX+(ke+.5)*Q,[ne]:i.tileX+ke*Q,[ge]:i.tileX+(ke+1)*Q,[Ae]:ze,[_]:ze})}else if(ke%k===0)be=Ue=dt=L[O*me+ke],Ee=ke,Je=ke+k;else if(ke%k===k-1)x.push({[X]:Ze,[$]:de==="mean"?be/k/Q:be,[ee]:i.tileX+(Ee+k/2)*Q,[ne]:i.tileX+Ee*Q,[ge]:i.tileX+Je*Q,[Ae]:Ue,[_]:dt});else if(ke===O-1){const ze=O%k,je=Ee+ze;x.push({[X]:Ze,[$]:de==="mean"?be/ze/Q:be,[ee]:i.tileX+(Ee+ze/2)*Q,[ne]:i.tileX+Ee*Q,[ge]:i.tileX+je*Q,[Ae]:Ue,[_]:dt})}else{const ze=L[O*me+ke];be+=ze,Ue>ze&&(Ue=ze),dt"u"||typeof i.tileHeight>"u")return;const k=Math.sqrt(i.dense.length),{tileX:F,tileY:Y,tileWidth:L,tileHeight:O}=i,Q=i.dense,X=L/k,$=O/k,ee=(E=e.data.column)!=null?E:"x",ne=(W=e.data.row)!=null?W:"y",ge=16;for(let Ae=0;Ae{const{chrOffset:Q,fields:X}=L,$={};if($[Nli]=`${O}`,k.forEach(ee=>{$[ee.name]=+X[ee.index]+Q}),Y?.forEach(ee=>{$[ee.name]=ee.type==="quantitative"?+X[ee.index]:X[ee.index]}),x.push({...$,type:"gene"}),F){const[ee,ne]=F,ge=X[ee.index].split(","),Ae=X[ne.index].split(",");ge.forEach((_,de)=>{const Ze=Ae[de];if(x.push({...$,[ee.name]:+_+Q,[ne.name]:+Ze+Q,type:"exon"}),de+1{const f=Object.entries(Sg(l).size);return await u.init(this.uid,{url:r,indexUrl:o},f,c),u})}async tilesetInfo(i){(await this.worker).tilesetInfo(this.uid).then(i)}fetchTilesDebounced(i,n){var r;const{toFetch:o}=this,l=n[0].split(".")[0],c=o.size?[...o][0].split(".")[0]:null;if(l!==c){for(const u of this.toFetch)(r=this.track)==null||r.fetching.delete(u);this.toFetch.clear()}n.forEach(u=>this.toFetch.add(u)),this.fetchTimeout&&clearTimeout(this.fetchTimeout),this.fetchTimeout=setTimeout(()=>{this.sendFetch(i,[...this.toFetch]),this.toFetch.clear()},Mli)}async sendFetch(i,n){(await this.worker).fetchTilesDebounced(this.uid,n).then(i)}async getTabularData(i){const n=await(await this.worker).getTabularData(this.uid,i);return JSON.parse(new TextDecoder().decode(n))}}ale.config={type:"bam"};const kJe="KCgpID0+IHsKICB2YXIgX19jcmVhdGUgPSBPYmplY3QuY3JlYXRlOwogIHZhciBfX2RlZlByb3AgPSBPYmplY3QuZGVmaW5lUHJvcGVydHk7CiAgdmFyIF9fZGVmUHJvcHMgPSBPYmplY3QuZGVmaW5lUHJvcGVydGllczsKICB2YXIgX19nZXRPd25Qcm9wRGVzYyA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3I7CiAgdmFyIF9fZ2V0T3duUHJvcERlc2NzID0gT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcnM7CiAgdmFyIF9fZ2V0T3duUHJvcE5hbWVzID0gT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXM7CiAgdmFyIF9fZ2V0T3duUHJvcFN5bWJvb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dGUgdG8gcHJpdmF0ZSBmaWVsZCIpOwogICAgc2V0dGVyID8gc2V0dGVyLmNhbGwob2JqLCB2YWx1ZSkgOiBtZW1iZXIuc2V0KG9iaiwgdmFsdWUpOwogICAgcmV0dXJuIHZhbHVlOwogIH07CiAgdmFyIF9fYXN5bmMgPSAoX190aGlzLCBfX2FyZ3VtZW50cywgZ2VuZXJhdG9yKSA9PiB7CiAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4gewogICAgICB2YXIgZnVsZmlsbGVkID0gKHZhbHVlKSA9PiB7CiAgICAgICAgdHJ5IHsKICAgICAgICAgIHN0ZXAoZ2VuZXJhdG9yLm5leHQodmFsdWUpKTsKICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICByZWplY3QoZSk7CiAgICAgICAgfQogICAgICB9OwogICAgICB2YXIgcmVqZWN0ZWQgPSAodmFsdWUpID0+IHsKICAgICAgICB0cnkgewogICAgICAgICAgc3RlcChnZW5lcmF0b3IudGhyb3codmFsdWUpKTsKICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICByZWplY3QoZSk7CiAgICAgICAgfQogICAgICB9OwogICAgICB2YXIgc3RlcCA9ICh4KSA9PiB4LmRvbmUgPyByZXNvbHZlKHgudmFsdWUpIDogUHJvbWlzZS5yZXNvbHZlKHgudmFsdWUpLnRoZW4oZnVsZmlsbGVkLCByZWplY3RlZCk7CiAgICAgIHN0ZXAoKGdlbmVyYXRvciA9IGdlbmVyYXRvci5hcHBseShfX3RoaXMsIF9fYXJndW1lbnRzKSkubmV4dCgpKTsKICAgIH0pOwogIH07CgogIC8vIG5vZGVfbW9kdWxlcy9iYXNlNjQtanMvaW5kZXguanMKICB2YXIgcmVxdWlyZV9iYXNlNjRfanMgPSBfX2NvbW1vbkpTKHsKICAgICJub2RlX21vZHVsZXMvYmFzZTY0LWpzL2luZGV4LmpzIihleHBvcnRzMikgewogICAgICBpbml0X2J1ZmZlcl9zaGlt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A7CiAgICAgICAgdmFyIGQgPSBpc0xFID8gLTEgOiAxOwogICAgICAgIHZhciBzID0gYnVmZmVyW29mZnNldCArIGldOwogICAgICAgIGkgKz0gZDsKICAgICAgICBlID0gcyAmICgxIDw8IC1uQml0cykgLSAxOwogICAgICAgIHMgPj49IC1uQml0czsKICAgICAgICBuQml0cyArPSBlTGVuOwogICAgICAgIGZvciAoOyBuQml0cyA+IDA7IGUgPSBlICogMjU2ICsgYnVmZmVyW29mZnNldCArIGldLCBpICs9IGQsIG5CaXRzIC09IDgpIHsKICAgICAgICB9CiAgICAgICAgbSA9IGUgJiAoMSA8PCAtbkJpdHMpIC0gMTsKICAgICAgICBlID4+PSAtbkJpdHM7CiAgICAgICAgbkJpdHMgKz0gbUxlbjsKICAgICAgICBmb3IgKDsgbkJpdHMgPiAwOyBtID0gbSAqIDI1NiArIGJ1ZmZlcltvZmZzZXQgKyBpXSwgaSArPSBkLCBuQml0cyAtPSA4KSB7CiAgICAgICAgfQogICAgICAgIGlmIChlID09PSAwKSB7CiAgICAgICAgICBlID0gMSAtIGVCaWFzOwogICAgICAgIH0gZWxzZSBpZiAoZSA9PT0gZU1heCkgewogICAgICAgICAgcmV0dXJuIG0gPyBOYU4gOiAocyA/IC0xIDogMSkgKiBJbmZpbml0eTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgbSA9IG0gKyBNYXRoLnBvdygyLCBtTGVuKTsKICAgICAgICAgIGUgPSBlIC0gZUJpYXM7CiAgICAgICAgfQogICAgICAgIHJldHVybiAocyA/IC0xIDogMSkgKiBtICogTWF0aC5wb3coMiwgZSAtIG1MZW4pOwogICAgICB9OwogICAgICBleHBvcnRzMi53cml0ZSA9IGZ1bmN0aW9uKGJ1ZmZlciwgdmFsdWUsIG9mZnNldCwgaXNMRSwgbUxlbiwgbkJ5dGVzKSB7CiAgICAgICAgdmFyIGUsIG0sIGM7CiAgICAgICAgdmFyIGVMZW4gPSBuQnl0ZXMgKiA4IC0gbUxlbiAtIDE7CiAgICAgICAgdmFyIGVNYXggPSAoMSA8PCBlTGVuKSAtIDE7CiAgICAgICAgdmFyIGVCaWFzID0gZU1heCA+PiAxOwogICAgICAgIHZhciBydCA9IG1MZW4gPT09IDIzID8gTWF0aC5wb3coMiwgLTI0KSAtIE1hdGgucG93KDIsIC03NykgOiAwOwogICAgICAgIHZhciBpID0gaXNMRSA/IDAgOiBuQnl0ZXMgLSAxOwogICAgICAgIHZhciBkID0gaXNMRSA/IDEgOiAtMTsKICAgICAgICB2YXIgcyA9IHZhbHVlIDwgMCB8fCB2YWx1ZSA9PT0gMCAmJiAxIC8gdmFsdWUgPCAwID8gMSA6IDA7CiAgICAgICAgdmFsdWUgPSBNYXRoLmFicyh2YWx1ZSk7CiAgICAgICAgaWYgKGlzTmFOKHZhbHVlKSB8fCB2YWx1ZSA9PT0gSW5maW5pdHkpIHsKICAgICAgICAgIG0gPSBpc05hTih2YWx1ZSkgPyAxIDogMDsKICAgICAgICAgIGUgPSBlTWF4OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBlID0gTWF0aC5mbG9vcihNYXRoLmxvZyh2YWx1ZSkgLyBNYXRoLkxOMik7CiAgICAgICAgICBpZiAodmFsdWUgKiAoYyA9IE1hdGgucG93KDIsIC1lKSkgPCAxKSB7CiAgICAgICAgICAgIGUtLTsKICAgICAgICAgICAgYyAqPSAyOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGUgKyBlQmlhcyA+PSAxKSB7CiAgICAgICAgICAgIHZhbHVlICs9IHJ0IC8gYzsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHZhbHVlICs9IHJ0ICogTWF0aC5wb3coMiwgMSAtIGVCaWFzKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh2YWx1ZSAqIGMgPj0gMikgewogICAgICAgICAgICBlKys7CiAgICAgICAgICAgIGMgLz0gMjsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChlICsgZUJpYXMgPj0gZU1heCkgewogICAgICAgICAgICBtID0gMDsKICAgICAgICAgICAgZSA9IGVNYXg7CiAgICAgICAgICB9IGVsc2UgaWYgKGUgKyBlQmlhcyA+PSAxKSB7CiAgICAgICAgICAgIG0gPSAodmFsdWUgKiBjIC0gMSkgKiBNYXRoLnBvdygyLCBtTGVuKTsKICAgICAgICAgICAgZSA9IGUgKyBlQmlhczsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIG0gPSB2YWx1ZSAqIE1hdGgucG93KDIsIGVCaWFzIC0gMSkgKiBNYXRoLnBvdygyLCBtTGVuKTsKICAgICAgICAgICAgZSA9IDA7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGZvciAoOyBtTGVuID49IDg7IGJ1ZmZlcltvZmZzZXQgKyBpXSA9IG0gJiAyNTUsIGkgKz0gZCwgbSAvPSAyNTYsIG1MZW4gLT0gOCkgewogICAgICAgIH0KICAgICAgICBlID0gZSA8PCBtTGVuIHwgbTsKICAgICAgICBlTGVuICs9IG1MZW47CiAgICAgICAgZm9yICg7IGVMZW4gPiAwOyBidWZmZXJbb2Zmc2V0ICsgaV0gPSBlICYgMjU1LCBpICs9IGQsIGUgLz0gMjU2LCBlTGVuIC09IDgpIHsKICAgICAgICB9CiAgICAgICAgYnVmZmVyW29mZnNldCArIGkgLSBkXSB8PSBzICogMTI4OwogICAgICB9OwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvYnVmZmVyL2luZGV4LmpzCiAgdmFyIHJlcXVpcmVfYnVmZmVyID0gX19jb21tb25KUyh7CiAgICAibm9kZV9tb2R1bGVzL2J1ZmZlci9pbmRleC5qcyIoZXhwb3J0czIpIHsKICAgICAgaW5pdF9idWZmZXJfc2hpbSgpOwogICAgICAidXNlIHN0cmljdCI7CiAgICAgIHZhciBiYXNlNjQgPSByZXF1aXJlX2Jhc2U2NF9qcygpOwogICAgICB2YXIgaWVlZTc1NCA9IHJlcXVpcmVfaWVlZTc1NCgpOwogICAgICB2YXIgY3VzdG9tSW5zc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gICAgcmV0dXJuIDQyOwogICAgICAgICAgfSB9OwogICAgICAgICAgT2JqZWN0LnNldFByb3RvdHlwZU9mKHByb3RvLCBVaW50OEFycmF5LnByb3RvdHlwZSk7CiAgICAgICAgICBPYmplY3Quc2V0UHJvdG90eXBlT2YoYXJyLCBwcm90byk7CiAgICAgICAgICByZXR1cm4gYXJyLmZvbygpID09PSA0MjsKICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfQogICAgICB9CiAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShCdWZmZXI2LnByb3RvdHlwZSwgInBhcmVudCIsIHsKICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgIGdldDogZnVuY3Rpb24oKSB7CiAgICAgICAgICBpZiAoIUJ1ZmZlcjYuaXNCdWZmZXIodGhpcykpCiAgICAgICAgICAgIHJldHVybiB2b2lkIDA7CiAgICAgICAgICByZXR1cm4gdGhpcy5idWZmZXI7CiAgICAgICAgfQogICAgICB9KTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KEJ1ZmZlcjYucHJvdG90eXBlLCAib2Zmc2V0IiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHsKICAgICAgICAgIGlmICghQnVmZmVyNi5pc0J1ZmZlcih0aGlzKSkKICAgICAgICAgICAgcmV0dXJuIHZvaWQgMDsKICAgICAgICAgIHJldHVybiB0aGlzLmJ5dGVPZmZzZXQ7CiAgICAgICAgfQogICAgICB9KTsKICAgICAgZnVuY3Rpb24gY3JlYXRlQnVmZmVyKGxlbmd0aCkgewogICAgICAgIGlmIChsZW5ndGggPiBLX01BWF9MRU5HVEgpIHsKICAgICAgICAgIHRocm93IG5ldyBSYW5nZUVycm9yKCdUaGUgdmFsdWUgIicgKyBsZW5ndGggKyAnIiBpcyBpbnZhbGlkIGZvciBvcHRpb24gInNpemUiJyk7CiAgICAgICAgfQogICAgICAgIGNvbnN0IGJ1ZiA9IG5ldyBVaW50OEFycmF5KGxlbmd0aCk7CiAgICAgICAgT2JqZWN0LnNldFByb3RvdHlwZU9mKGJ1ZiwgQnVmZmVyNi5wcm90b3R5cGUpOwogICAgICAgIHJldHVybiBidWY7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gQnVmZmVyNihhcmcsIGVuY29kaW5nT3JPZmZzZXQsIGxlbmd0aCkgewogICAgICAgIGlmICh0eXBlb2YgYXJnID09PSAibnVtYmVyIikgewogICAgICAgICAgaWYgKHR5cGVvZiBlbmNvZGluZ09yT2Zmc2V0ID09PSAic3RyaW5nIikgewogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCdUaGUgInN0cmluZyIgYXJndW1lbnQgbXVzdCBiZSBvZiB0eXBlIHN0cmluZy4gUmVjZWl2ZWQgdHlwZSBudW1iZXInKTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBhbGxvY1Vuc2FmZShhcmcpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gZnJvbShhcmcsIGVuY29kaW5nT3JPZmZzZXQsIGxlbmd0aCk7CiAgICAgIH0KICAgICAgQnVmZmVyNi5wb29sU2l6ZSA9IDgxOTI7CiAgICAgIGZ1bmN0aW9uIGZyb20odmFsdWUsIGVuY29kaW5nT3JPZmZzZXQsIGxlbmd0aCkgewogICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICByZXR1cm4gZnJvbVN0cmluZzIodmFsdWUsIGVuY29kaW5nT3JPZmZzZXQpOwogICAgICAgIH0KICAgICAgICBpZiAoQXJyYXlCdWZmZXIuaXNWaWV3KHZhbHVlKSkgewogICAgICAgICAgcmV0dXJuIGZyb21BcnJheVZpZXcodmFsdWUpOwogICAgICAgIH0KICAgICAgICBpZiAodmFsdWUgPT0gbnVsbCkgewogICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcigiVGhlIGZ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ZvaWQgMCkgewogICAgICAgICAgYnVmID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXkpOwogICAgICAgIH0gZWxzZSBpZiAobGVuZ3RoID09PSB2b2lkIDApIHsKICAgICAgICAgIGJ1ZiA9IG5ldyBVaW50OEFycmF5KGFycmF5LCBieXRlT2Zmc2V0KTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgYnVmID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXksIGJ5dGVPZmZzZXQsIGxlbmd0aCk7CiAgICAgICAgfQogICAgICAgIE9iamVjdC5zZXRQcm90b3R5cGVPZihidWYsIEJ1ZmZlcjYucHJvdG90eXBlKTsKICAgICAgICByZXR1cm4gYnVmOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGZyb21PYmplY3Qob2JqKSB7CiAgICAgICAgaWYgKEJ1ZmZlcjYuaXNCdWZmZXIob2JqKSkgewogICAgICAgICAgY29uc3QgbGVuID0gY2hlY2tlZChvYmoubGVuZ3RoKSB8IDA7CiAgICAgICAgICBjb25zdCBidWYgPSBjcmVhdGVCdWZmZXIobGVuKTsKICAgICAgICAgIGlmIChidWYubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBidWY7CiAgICAgICAgICB9CiAgICAgICAgICBvYmouY29weShidWYsIDAsIDAsIGxlbik7CiAgICAgICAgICByZXR1cm4gYnVmOwogICAgICAgIH0KICAgICAgICBpZiAob2JqLmxlbmd0aCAhPT0gdm9pZCAwKSB7CiAgICAgICAgICBpZiAodHlwZW9mIG9iai5sZW5ndGggIT09ICJudW1iZXIiIHx8IG51bWJlcklzTmFOKG9iai5sZW5ndGgpKSB7CiAgICAgICAgICAgIHJldHVybiBjcmVhdGVCdWZmZXIoMCk7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gZnJvbUFycmF5TGlrZShvYmopOwogICAgICAgIH0KICAgICAgICBpZiAob2JqLnR5cGUgPT09ICJCdWZmZXIiICYmIEFycmF5LmlzQXJyYXkob2J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KTsKICAgICAgICBpZiAoIUJ1ZmZlcjYuaXNCdWZmZXIoYSkgfHwgIUJ1ZmZlcjYuaXNCdWZmZXIoYikpIHsKICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoJ1RoZSAiYnVmMSIsICJidWYyIiBhcmd1bWVudHMgbXVzdCBiZSBvbmUgb2YgdHlwZSBCdWZmZXIgb3IgVWludDhBcnJheScpOwogICAgICAgIH0KICAgICAgICBpZiAoYSA9PT0gYikKICAgICAgICAgIHJldHVybiAwOwogICAgICAgIGxldCB4ID0gYS5sZW5ndGg7CiAgICAgICAgbGV0IHkgPSBiLmxlbmd0aDsKICAgICAgICBmb3IgKGxldCBpID0gMCwgbGVuID0gTWF0aC5taW4oeCwgeSk7IGkgPCBsZW47ICsraSkgewogICAgICAgICAgaWYgKGFbaV0gIT09IGJbaV0pIHsKICAgICAgICAgICAgeCA9IGFbaV07CiAgICAgICAgICAgIHkgPSBiW2ldOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHggPCB5KQogICAgICAgICAgcmV0dXJuIC0xOwogICAgICAgIGlmICh5IDwgeCkKICAgICAgICAgIHJldHVybiAxOwogICAgICAgIHJldHVybiAwOwogICAgICB9OwogICAgICBCdWZmZXI2LmlzRW5jb2RpbmcgPSBmdW5jdGlvbiBpc0VuY29kaW5nKGVuY29kaW5nKSB7CiAgICAgICAgc3dpdGNoIChTdHJpbmcoZW5jb2RpbmcpLnRvTG93ZXJDYXNlKCkpIHsKICAgICAgICAgIGNhc2UgImhleCI6CiAgICAgICAgICBjYXNlICJ1dGY4IjoKICAgICAgICAgIGNhc2UgInV0Zi04IjoKICAgICAgICAgIGNhc2UgImFzY2lpIjoKICAgICAgICAgIGNhc2UgImxhdGluMSI6CiAgICAgICAgICBjYXNlICJiaW5hcnkiOgogICAgICAgICAgY2FzZSAiYmFzZTY0IjoKICAgICAgICAgIGNhc2UgInVjczIiOgogICAgICAgICAgY2FzZSAidWNzLTIiOgogICAgICAgICAgY2FzZSAidXRmMTZsZSI6CiAgICAgICAgICBjYXNlICJ1dGYtMTZsZSI6CiAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgfTsKICAgICAgQnVmZmVyNi5jb25jYXQgPSBmdW5jdGlvbiBjb25jYXQobGlzdCwgbGVuZ3RoKSB7CiAgICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGxpc3QpKSB7CiAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCcibGlzdCIgYXJndW1lbnQgbXVzdCBiZSBhbiBBcnJheSBvZiBCdWZmZXJzJyk7CiAgICAgICAgfQogICAgICAgIGlmIChsaXN0Lmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgcmV0dXJuIEJ1ZmZlcjYuYWxsb2MoMCk7CiAgICAgICAgfQogICAgICAgIGxldCBpOwogICAgICAgIGlmIChsZW5ndGggPT09IHZvaWQgMCkgewogICAgICAgICAgbGVuZ3RoID0gMDsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBsaXN0Lmxlbmd0aDsgKytpKSB7CiAgICAgICAgICAgIGxlbmd0aCArPSBsaXN0W2ldLmxlbmd0aDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgY29uc3QgYnVmZmVyID0gQnVmZmVyNi5hbGxvY1Vuc2FmZShsZW5ndGgpOwogICAgICAgIGxldCBwb3MgPSAwOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsaXN0Lmxlbmd0aDsgKytpKSB7CiAgICAgICAgICBsZXQgYnVmID0gbGlzdFtpXTsKICAgICAgICAgIGlmIChpc0luc3RhbmNlKGJ1ZiwgVWludDhBcnJheSkpIHsKICAgICAgICAgICAgaWYgKHBvcyArIGJ1Zi5sZW5ndGggPiBidWZmZXIubGVuZ3RoKSB7CiAgICAgICAgICAgICAgaWYgKCFCdWZmZXI2LmlzQnVmZmVyKGJ1ZikpCiAgICAgICAgICAgICAgICBidWYgPSBCdWZmZXI2LmZyb20oYnVmKTsKICAgICAgICAgICAgICBidWYuY29weShidWZmZXIsIHBvcyk7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgVWludDhBcnJheS5wcm90b3R5cGUuc2V0LmNhbGwoYnVmZmVyLCBidWYsIHBvcyk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSBpZiAoIUJ1ZmZlcjYuaXNCdWZmZXIoYnVmKSkgewogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCcibGlzdCIgYXJndW1lbnQgbXVzdCBiZSBhbiBBcnJheSBvZiBCdWZmZXJzJyk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBidWYuY29weShidWZmZXIsIHBvcyk7CiAgICAgICAgICB9CiAgICAgICAgICBwb3MgKz0gYnVmLmxlbmd0aDsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJ1ZmZlcjsKICAgICAgfTsKICAgICAgZnVuY3Rpb24gYnl0ZUxlbmd0aChzdHJpbmcsIGVuY29kaW5nKSB7CiAgICAgICAgaWYgKEJ1ZmZlcjYuaXNCdWZmZXIoc3RyaW5nKSkgewogICAgICAgICAgcmV0dXJuIHN0cmluZy5sZW5ndGg7CiAgICAgICAgfQogICAgICAgIGlmIChBcnJheUJ1ZmZlci5pc1ZpZXcoc3RyaW5nKSB8fCBpc0luc3RhbmNlKHN0cmluZywgQXJyYXlCdWZmZXIpKSB7CiAgICAgICAgICByZXR1cm4gc3RyaW5nLmJ5dGVMZW5ndGg7CiAgICAgICAgfQogICAgICAgIGlmICh0eXBlb2Ygc3RyaW5nICE9PSAic3RyaW5nIikgewogICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcignVGhlICJzdHJpbmciIGFyZ3VtZW50IG11c3QgYmUgb25lIG9mIHR5cGUgc3RyaW5nLCBCdWZmZXIsIG9yIEFycmF5QnVmZmVyLiBSZWNlaXZlZCB0eXBlICcgKyB0eXBlb2Ygc3RyaW5nKTsKICAgICAgICB9CiAgICAgICAgY29uc3QgbGVuID0gc3RyaW5nLmxlbmd0aDsKICAgICAgICBjb25zdCBtdXN0TWF0Y2ggPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gPT09IHRydWU7CiAgICAgICAgaWYgKCFtdXN0TWF0Y2ggJiYgbGVuID09PSAwKQogICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgbGV0IGxvd2VyZWRDYXNlID0gZmFsc2U7CiAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICBzd2l0Y2ggKGVuY29kaW5nKSB7CiAgICAgICAgICAgIGNhc2UgImFzY2lpIjoKICAgICAgICAgICAgY2FzZSAibGF0aW4xIjoKICAgICAgICAgICAgY2FzZSAiYmluYXJ5IjoKICAgICAgICAgICAgICByZXR1cm4gbGVuOwogICAgICAgICAgICBjYXNlICJ1dGY4IjoKICAgICAgICAgICAgY2FzZSAidXRmLTgiOgogICAgICAgICAgICAgIHJldHVybiB1dGY4VG9CeXRlcyhzdHJpbmcpLmxlbmd0aDsKICAgICAgICAgICAgY2FzZSAidWNzMiI6CiAgICAgICAgICAgIGNhc2UgInVjcy0yIjoKICAgICAgICAgICAgY2FzZSAidXRmMTZsZSI6CiAgICAgICAgICAgIGNhc2UgInV0Zi0xNmxlIjoKICAgICAgICAgICAgICByZXR1cm4gbGVuICogMjsKICAgICAgICAgICAgY2FzZSAiaGV4IjoKICAgICAgICAgICAgICByZXR1cm4gbGVuID4+PiAxOwogICAgICAgICAgICBjYXNlICJiYXNlNjQiOgogICAgICAgICAgICAgIHJldHVybiBiYXNlNjRUb0J5dGVzKHN0cmluZykubGVuZ3RoOwogICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgIGlmIChsb3dlcmVkQ2FzZSkgewogICAgICAgICAgICAgICAgcmV0dXJuIG11c3RNYXRjaCA/IC0xIDogdXRmOFRvQnl0ZXMoc3RyaW5nKS5sZW5ndGg7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGVuY29kaW5nID0gKCIiICsgZW5jb2RpbmcpLnRvTG93ZXJDYXNlKCk7CiAgICAgICAgICAgICAgbG93ZXJlZENhc2UgPSB0cnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBCdWZmZXI2LmJ5dGVMZW5ndGggPSBieXRlTGVuZ3RoOwogICAgICBmdW5jdGlvbiBzbG93VG9TdHJpbmcoZW5jb2RpbmcsIHN0YXJ0LCBlbmQpIHsKICAgICAgICBsZXQgbG93ZXJlZENhc2UgPSBmYWxzZTsKICAgICAgICBpZiAoc3RhcnQgPT09IHZvaWQgMCB8fCBzdGFydCA8IDApIHsKICAgICAgICAgIHN0YXJ0ID0gMDsKICAgICAgICB9CiAgICAgICAgaWYgKHN0YXJ0ID4gdGhpcy5sZW5ndGgpIHsKICAgICAgICAgIHJldHVybiAiIjsKICAgICAgICB9CiAgICAgICAgaWYgKGVuZCA9PT0gdm9pZCAwIHx8IGVuZCA+IHRoaXMubGVuZ3RoKSB7CiAgICAgICAgICBlbmQgPSB0aGlzLmxlbmd0aDsKICAgICAgICB9CiAgICAgICAgaWYgKGVuZCA8PSAwKSB7CiAgICAgICAgICByZXR1cm4gIiI7CiAgICAgICAgfQogICAgICAgIGVuZCA+Pj49IDA7CiAgICAgICAgc3RhcnQgPj4+PSAwOwogICAgICAgIGlmIChlbmQgPD0gc3RhcnQpIHsKICAgICAgICAgIHJldHVybiAiIjsKICAgICAgICB9CiAgICAgICAgaWYgKCFlbmNvZGluZykKICAgICAgICAgIGVuY29kaW5nID0gInV0ZjgiOwogICAgICAgIHdoaWxlICh0cnVlKSB7CiAgICAgICAgICBzd2l0Y2ggKGVuY29kaW5nKSB7CiAgICAgICAgICAgIGNhc2UgImhleCI6CiAgICAgICAgICAgICAgcmV0dXJuIGhleFNsaWNlKHRoaXMsIHN0YXJ0LCBlbmQpOwogICAgICAgICAgICBjYXNlICJ1dGY4IjoKICAgICAgICAgICAgY2FzZSAidXRmLTgiOgogICAgICAgICAgICAgIHJldHVybiB1dGY4U2xpY2UodGhpcywgc3RhcnQsIGVuZCk7CiAgICAgICAgICAgIGNhc2UgImFzY2lpIjoKICAgICAgICAgICAgICByZXR1cm4gYXNjaWlTbGljZSh0aGlzLCBzdGFydCwgZW5kKTsKICAgICAgICAgICAgY2FzZSAibGF0aW4xIjoKICAgICAgICAgICAgY2FzZSAiYmluYXJ5IjoKICAgICAgICAgICAgICByZXR1cm4gbGF0aW4xU2xpY2UodGhpcywgc3RhcnQsIGVuZCk7CiAgICAgICAgICAgIGNhc2UgImJhc2U2NCI6CiAgICAgICAgICAgICAgcmV0dXJuIGJhc2U2NFNsaWNlKHRoaXMsIHN0YXJ0LCBlbmQpOwogICAgICAgICAgICBjYXNlICJ1Y3MyIjoKICAgICAgICAgICAgY2FzZSAidWNzLTIiOgogICAgICAgICAgICBjYXNlICJ1dGYxNmxlIjoKICAgICAgICAgICAgY2FzZSAidXRmLTE2bGUiOgogICAgICAgICAgICAgIHJldHVybiB1dGYxNmxlU2xpY2UodGhpcywgc3RhcnQsIGVuZCk7CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgaWYgKGxvd2VyZWRDYXNlKQogICAgICAgICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcigiVW5rbm93biBlbmNvZGluZzogIiArIGVuY29kaW5nKTsKICAgICAgICAgICAgICBlbmNvZGluZyA9IChlbmNvZGluZyArICIiKS50b0xvd2VyQ2FzZSgpOwogICAgICAgICAgICAgIGxvd2VyZWRDYXNlID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgQnVmZmVyNi5wcm90b3R5cGUuX2lzQnVmZmVyID0gdHJ1ZTsKICAgICAgZnVuY3Rpb24gc3dhcChiLCBuLCBtKSB7CiAgICAgICAgY29uc3QgaSA9IGJbbl07CiAgICAgICAgYltuXSA9IGJbbV07CiAgICAgICAgYlttXSA9IGk7CiAgICAgIH0KICAgICAgQnVmZmVyNi5wcm90b3R5cGUuc3dhcDE2ID0gZnVuY3Rpb24gc3dhcDE2KCkgewogICAgICAgIGNvbnN0IGxlbiA9IHRoaXMubGVuZ3RoOwogICAgICAgIGlmIChsZW4gJSAyICE9PSAwKSB7CiAgICAgICAgICB0aHJvdyBuZXcgUmFuZ2VFcnJvcigiQnVmZmVyIHNpemUgbXVzdCBiZSBhIG11bHRpcGxlIG9mIDE2LWJpdHMiKTsKICAgICAgICB9CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsZW47IGkgKz0gMikgewogICAgICAgICAgc3dhcCh0aGlzLCBpLCBpICsgMSk7CiAgICAgICAgfQogICAgICAgIHJldHVybiB0aGlzOwogICAgICB9OwogICAgICBCdWZmZXI2LnByb3RvdHlwZS5zd2FwMzIgPSBmdW5jdGlvbiBzd2FwMzIoKSB7CiAgICAgICAgY29uc3QgbGVuID0gdGhpcy5sZW5ndGg7CiAgICAgICAgaWYgKGxlbiAlIDQgIT09IDApIHsKICAgICAgICAgIHRocm93IG5ldyBSYW5nZUVycm9yKCJCdWZmZXIgc2l6ZSBtdXN0IGJlIGEgbXVsdGlwbGUgb2YgMzItYml0cyIpOwogICAgICAgIH0KICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbjsgaSArPSA0KSB7CiAgICAgICAgICBzd2FwKHRoaXMsIGksIGkgKyAzKTsKICAgICAgICAgIHN3YXAodGhpcywgaSArIDEsIGkgKyAyKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgIH07CiAgICAgIEJ1ZmZlcjYucHJvdG90eXBlLnN3YXA2NCA9IGZ1bmN0aW9uIHN3YXA2NCgpIHsKICAgICAgICBjb25zdCBsZW4gPSB0aGlzLmxlbmd0aDsKICAgICAgICBpZiAobGVuICUgOCAhPT0gMCkgewogICAgICAgICAgdGhyb3cgbmV3IFJhbmdlRXJyb3IoIkJ1ZmZlciBzaXplIG11c3QgYmUgYSBtdWx0aXBsZSBvZiA2NC1iaXRzIik7CiAgICAgICAgfQogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGVuOyBpICs9IDgpIHsKICAgICAgICAgIHN3YXAodGhpcywgaSwgaSArIDcpOwogICAgICAgICAgc3dhcCh0aGlzLCBpICsgMSwgaSArIDYpOwogICAgICAgICAgc3dhcCh0aGlzLCBpICsgMiwgaSArIDUpOwogICAgICAgICAgc3dhcCh0aGlzLCBpICsgMywgaSArIDQpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gdGhpczsKICAgICAgfTsKICAgICAgQnVmZmVyNi5wcm90b3R5cGUudG9TdHJpbmcgPSBmdW5jdGlvbiB0b1N0cmluZzIoKSB7CiAgICAgICAgY29uc3QgbGVuZ3RoID0gdGhpcy5sZW5ndGg7CiAgICAgICAgaWYgKGxlbmd0aCA9PT0gMCkKICAgICAgICAgIHJldHVybiAiIjsKICAgICAgICBpZiAoYXJndW1lbnRzLmxlbmd0aCA9PT0gMCkKICAgICAgICAgIHJldHVybiB1dGY4U2xpY2UodGhpcywgMCwgbGVuZ3RoKTsKICAgICAgICByZXR1cm4gc2xvd1RvU3RyaW5nLmFwcGx5KHRoaXMsIGFyZ3VtZW50cyk7CiAgICAgIH07CiAgICAgIEJ1ZmZlcjYucHJvdG90eXBlLnRvTG9jYWxlU3RyaW5nID0gQnVmZmVyNi5wcm90b3R5cGUudG9TdHJpbmc7CiAgICAgIEJ1ZmZlcjYucHJvdG90eXBlLmVxdWFscyA9IGZ1bmN0aW9uIGVxdWFsczIoYikgewogICAgICAgIGlmICghQnVmZmVyNi5pc0J1ZmZlcihiKSkKICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoIkFyZ3VtZW50IG11c3QgYmUgYSBCdWZmZXIiKTsKICAgICAgICBpZiAodGhpcyA9PT0gYikKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIHJld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ZWl2ZWQgdHlwZSAnICsgdHlwZW9mIHRhcmdldCk7CiAgICAgICAgfQogICAgICAgIGlmIChzdGFydCA9PT0gdm9pZCAwKSB7CiAgICAgICAgICBzdGFydCA9IDA7CiAgICAgICAgfQogICAgICAgIGlmIChlbmQgPT09IHZvaWQgMCkgewogICAgICAgICAgZW5kID0gdGFyZ2V0ID8gdGFyZ2V0Lmxlbmd0aCA6IDA7CiAgICAgICAgfQogICAgICAgIGlmICh0aGlzU3RhcnQgPT09IHZvaWQgMCkgewogICAgICAgICAgdGhpc1N0YXJ0ID0gMDsKICAgICAgICB9CiAgICAgICAgaWYgKHRoaXNFbmQgPT09IHZvaWQgMCkgewogICAgICAgICAgdGhpc0VuZCA9IHRoaXMubGVuZ3RoOwogICAgICAgIH0KICAgICAgICBpZiAoc3RhcnQgPCAwIHx8IGVuZCA+IHRhcmdldC5sZW5ndGggfHwgdGhpc1N0YXJ0IDwgMCB8fCB0aGlzRW5kID4gdGhpcy5sZW5ndGgpIHsKICAgICAgICAgIHRocm93IG5ldyBSYW5nZUVycm9yKCJvdXQgb2YgcmFuZ2UgaW5kZXgiKTsKICAgICAgICB9CiAgICAgICAgaWYgKHRoaXNTdGFydCA+PSB0aGlzRW5kICYmIHN0YXJ0ID49IGVuZCkgewogICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgfQogICAgICAgIGlmICh0aGlzU3RhcnQgPj0gdGhpc0VuZCkgewogICAgICAgICAgcmV0dXJuIC0xOwogICAgICAgIH0KICAgICAgICBpZiAoc3RhcnQgPj0gZW5kKSB7CiAgICAgICAgICByZXR1cm4gMTsKICAgICAgICB9CiAgICAgICAgc3RhcnQgPj4+PSAwOwogICAgICAgIGVuZCA+Pj49IDA7CiAgICAgICAgdGhpc1N0YXJ0ID4+Pj0gMDsKICAgICAgICB0aGlzRW5kID4+Pj0gMDsKICAgICAgICBpZiAodGhpcyA9PT0gdGFyZ2V0KQogICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgbGV0IH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gPCAtMjE0NzQ4MzY0OCkgewogICAgICAgICAgYnl0ZU9mZnNldCA9IC0yMTQ3NDgzNjQ4OwogICAgICAgIH0KICAgICAgICBieXRlT2Zmc2V0ID0gK2J5dGVPZmZzZXQ7CiAgICAgICAgaWYgKG51bWJlcklzTmFOKGJ5dGVPZmZzZXQpKSB7CiAgICAgICAgICBieXRlT2Zmc2V0ID0gZGlyID8gMCA6IGJ1ZmZlci5sZW5ndGggLSAxOwogICAgICAgIH0KICAgICAgICBpZiAoYnl0ZU9mZnNldCA8IDApCiAgICAgICAgICBieXRlT2Zmc2V0ID0gYnVmZmVyLmxlbmd0aCArIGJ5dGVPZmZzZXQ7CiAgICAgICAgaWYgKGJ5dGVPZmZzZXQgPj0gYnVmZmVyLmxlbmd0aCkgewogICAgICAgICAgaWYgKGRpcikKICAgICAgICAgICAgcmV0dXJuIC0xOwogICAgICAgICAgZWxzZQogICAgICAgICAgICBieXRlT2Zmc2V0ID0gYnVmZmVyLmxlbmd0aCAtIDE7CiAgICAgICAgfSBlbHNlIGlmIChieXRlT2Zmc2V0IDwgMCkgewogICAgICAgICAgaWYgKGRpcikKICAgICAgICAgICAgYnl0ZU9mZnNldCA9IDA7CiAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICB9CiAgICAgICAgaWYgKHR5cGVvZiB2YWwgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICB2YWwgPSBCdWZmZXI2LmZyb20odmFsLCBlbmNvZGluZyk7CiAgICAgICAgfQogICAgICAgIGlmIChCdWZmZXI2LmlzQnVmZmVyKHZhbCkpIHsKICAgICAgICAgIGlmICh2YWwubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBhcnJheUluZGV4T2YoYnVmZmVyLCB2YWwsIGJ5dGVPZmZzZXQsIGVuY29kaW5nLCBkaXIpOwogICAgICAgIH0gZWxzZSBpZiAodHlwZW9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luZyA9PT0gInV0ZjE2bGUiIHx8IGVuY29kaW5nID09PSAidXRmLTE2bGUiKSB7CiAgICAgICAgICAgIGlmIChhcnIubGVuZ3RoIDwgMiB8fCB2YWwubGVuZ3RoIDwgMikgewogICAgICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpbmRleFNpemUgPSAyOwogICAgICAgICAgICBhcnJMZW5ndGggLz0gMjsKICAgICAgICAgICAgdmFsTGVuZ3RoIC89IDI7CiAgICAgICAgICAgIGJ5dGVPZmZzZXQgLz0gMjsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZnVuY3Rpb24gcmVhZChidWYsIGkyKSB7CiAgICAgICAgICBpZiAoaW5kZXhTaXplID09PSAxKSB7CiAgICAgICAgICAgIHJldHVybiBidWZbaTJdOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcmV0dXJuIGJ1Zi5yZWFkVUludDE2QkUoaTIgKiBpbmRleFNpemUpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBsZXQgaTsKICAgICAgICBpZiAoZGlyKSB7CiAgICAgICAgICBsZXQgZm91bmRJbmRleCA9IC0xOwogICAgICAgICAgZm9yIChpID0gYnl0ZU9mZnNldDsgaSA8IGFyckxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgIGlmIChyZWFkKGFyciwgaSkgPT09IHJlYWQodmFsLCBmb3VuZEluZGV4ID09PSAtMSA/IDAgOiBpIC0gZm91bmRJbmRleCkpIHsKICAgICAgICAgICAgICBpZiAoZm91bmRJbmRleCA9PT0gLTEpCiAgICAgICAgICAgICAgICBmb3VuZEluZGV4ID0gaTsKICAgICAgICAgICAgICBpZiAoaSAtIGZvdW5kSW5kZXggKyAxID09PSB2YWxMZW5ndGgpCiAgICAgICAgICAgICAgICByZXR1cm4gZm91bmRJbmRleCAqIGluZGV4U2l6ZTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBpZiAoZm91bmRJbmRleCAhPT0gLTEpCiAgICAgICAgICAgICAgICBpIC09IGkgLSBmb3VuZEluZGV4OwogICAgICAgICAgICAgIGZvdW5kSW5kZXggPSAtMTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBpZiAoYnl0ZU9mZnNldCArIHZhbExlbmd0aCA+IGFyckxlbmd0aCkKICAgICAgICAgICAgYnl0ZU9mZnNldCA9IGFyckxlbmd0aCAtIHZhbExlbmd0aDsKICAgICAgICAgIGZvciAoaSA9IGJ5dGVPZmZzZXQ7IGkgPj0gMDsgaS0tKSB7CiAgICAgICAgICAgIGxldCBmb3VuZCA9IHRydWU7CiAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgdmFsTGVuZ3RoOyBqKyspIHsKICAgICAgICAgICAgICBpZiAocmVhZChhcnIsIGkgKyBqKSAhPT0gcmVhZCh2YWwsIGopKSB7CiAgICAgICAgICAgICAgICBmb3VuZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChmb3VuZCkKICAgICAgICAgICAgICByZXR1cm4gaTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIC0xOwogICAgICB9CiAgICAgIEJ1ZmZlcjYucHJvdG90eXBlLmluY2x1ZGVzID0gZnVuY3Rpb24gaW5jbHVkZXModmFsLCBieXRlT2Zmc2V0LCBlbmNvZGluZykgewogICAgICAgIHJldHVybiB0aGlzLmluZGV4T2YodmFsLCBieXRlT2Zmc2V0LCBlbmNvZGluZykgIT09IC0xOwogICAgICB9OwogICAgICBCdWZmZXI2LnByb3RvdHlwZS5pbmRleE9mID0gZnVuY3Rpb24gaW5kZXhPZih2YWwsIGJ5dGVPZmZzZXQsIGVuY29kaW5nKSB7CiAgICAgICAgcmV0dXJuIGJpZGlyZWN0aW9uYWxJbmRleE9mKHRoaXMsIHZhbCwgYnl0ZU9mZnNldCwgZW5jb2RpbmcsIHRydWUpOwogICAgICB9OwogICAgICBCdWZmZXI2LnByb3RvdHlwZS5sYXN0SW5kZXhPZiA9IGZ1bmN0aW9uIGxhc3RJbmRleE9mKHZhbCwgYnl0ZU9mZnNldCwgZW5jb2RpbmcpIHsKICAgICAgICByZXR1cm4gYmlkaXJlY3Rpb25hbEluZGV4T2YodGhpcywgdmFsLCBieXRlT2Zmc2V0LCBlbmNvZGluZywgZmFsc2UpOwogICAgICB9OwogICAgICBmdW5jdGlvbiBoZXhXcml0ZShidWYsIHN0cmluZywgb2Zmc2V0LCBsZW5ndGgpIHsKICAgICAgICBvZmZzZXQgPSBOdW1iZXIob2Zmc2V0KSB8fCAwOwogICAgICAgIGNvbnN0IHJlbWFpbmluZyA9IGJ1Zi5sZW5ndGggLSBvZmZzZXQ7CiAgICAgICAgaWYgKCFsZW5ndGgpIHsKICAgICAgICAgIGxlbmd0aCA9IHJlbWFpbmluZzsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgbGVuZ3RoID0gTnVtYmVyKGxlbmd0aCk7CiAgICAgICAgICBpZiAobGVuZ3RoID4gcmVtYWluaW5nKSB7CiAgICAgICAgICAgIGxlbmd0aCA9IHJlbWFpbmluZzsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgY29uc3Qgc3RyTGVuID0gc3RyaW5nLmxlbmd0aDsKICAgICAgICBpZiAobGVuZ3RoID4gc3RyTGVuIC8gMikgewogICAgICAgICAgbGVuZ3RoID0gc3RyTGVuIC8gMjsKICAgICAgICB9CiAgICAgICAgbGV0IGk7CiAgICAgICAgZm9yIChpID0gMDsgaSA8IGxlbmd0aDsgKytpKSB7CiAgICAgICAgICBjb25zdCBwYXJzZWQgPSBwYXJzZUludChzdHJpbmcuc3Vic3RyKGkgKiAyLCAyKSwgMTYpOwogICAgICAgICAgaWYgKG51bWJlcklzTmFOKHBhcnNlZCkpCiAgICAgICAgICAgIHJldHVybiBpOwogICAgICAgICAgYnVm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0aDsKICAgICAgICAgIG9mZnNldCA9IDA7CiAgICAgICAgfSBlbHNlIGlmIChsZW5ndGggPT09IHZvaWQgMCAmJiB0eXBlb2Ygb2Zmc2V0ID09PSAic3RyaW5nIikgewogICAgICAgICAgZW5jb2RpbmcgPSBvZmZzZXQ7CiAgICAgICAgICBsZW5ndGggPSB0aGlzLmxlbmd0aDsKICAgICAgICAgIG9mZnNldCA9IDA7CiAgICAgICAgfSBlbHNlIGlmIChpc0Zpbml0ZShvZmZzZXQpKSB7CiAgICAgICAgICBvZmZzZXQgPSBvZmZzZXQgPj4+IDA7CiAgICAgICAgICBpZiAoaXNGaW5pdGUobGVuZ3RoKSkgewogICAgICAgICAgICBsZW5ndGggPSBsZW5ndGggPj4+IDA7CiAgICAgICAgICAgIGlmIChlbmNvZGluZyA9PT0gdm9pZCAwKQogICAgICAgICAgICAgIGVuY29kaW5nID0gInV0ZjgiOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgZW5jb2RpbmcgPSBsZW5ndGg7CiAgICAgICAgICAgIGxlbmd0aCA9IHZvaWQgMDsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJCdWZmZXIud3JpdGUoc3RyaW5nLCBlbmNvZGluZywgb2Zmc2V0WywgbGVuZ3RoXSkgaXMgbm8gbG9uZ2VyIHN1cHBvcnRlZCIpOwogICAgICAgIH0KICAgICAgICBjb25zdCByZW1haW5pbmcgPSB0aGlzLmxlbmd0aCAtIG9mZnNldDsKICAgICAgICBpZiAobGVuZ3RoID09PSB2b2lkIDAgfHwgbGVuZ3RoID4gcmVtYWluaW5nKQogICAgICAgICAgbGVuZ3RoID0gcmVtYWluaW5nOwogICAgICAgIGlmIChzdHJpbmcubGVuZ3RoID4gMCAmJiAobGVuZ3RoIDwgMCB8fCBvZmZzZXQgPCAwKSB8fCBvZmZzZXQgPiB0aGlzLmxlbmd0aCkgewogICAgICAgICAgdGhyb3cgbmV3IFJhbmdlRXJyb3IoIkF0dGVtcHQgdG8gd3JpdGUgb3V0c2lkZSBidWZmZXIgYm91bmRzIik7CiAgICAgICAgfQogICAgICAgIGlmICghZW5jb2RpbmcpCiAgICAgICAgICBlbmNvZGluZyA9ICJ1dGY4IjsKICAgICAgICBsZXQgbG93ZXJlZENhc2UgPSBmYWxzZTsKICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgIHN3aXRjaCAoZW5jb2RpbmcpIHsKICAgICAgICAgICAgY2FzZSAiaGV4IjoKICAgICAgICAgICAgICByZXR1cm4gaGV4V3JpdGUodGhpcywgc3RyaW5nLCBvZmZzZXQsIGxlbmd0aCk7CiAgICAgICAgICAgIGNhc2UgInV0ZjgiOgogICAgICAgICAgICBjYXNlICJ1dGYtOCI6CiAgICAgICAgICAgICAgcmV0dXJuIHV0ZjhXcml0ZSh0aGlzLCBzdHJpbmcsIG9mZnNldCwgbGVuZ3RoKTsKICAgICAgICAgICAgY2FzZSAiYXNjaWkiOgogICAgICAgICAgICBjYXNlICJsYXRpbjEiOgogICAgICAgICAgICBjYXNlICJiaW5hcnkiOgogICAgICAgICAgICAgIHJldHVybiBhc2NpaVdyaXRlKHRoaXMsIHN0cmluZywgb2Zmc2V0LCBsZW5ndGgpOwogICAgICAgICAgICBjYXNlICJiYXNlNjQiOgogICAgICAgICAgICAgIHJldHVybiBiYXNlNjRXcml0ZSh0aGlzLCBzdHJpbmcsIG9mZnNldCwgbGVuZ3RoKTsKICAgICAgICAgICAgY2FzZSAidWNzMiI6CiAgICAgICAgICAgIGNhc2UgInVjcy0yIjoKICAgICAgICAgICAgY2FzZSAidXRmMTZsZSI6CiAgICAgICAgICAgIGNhc2UgInV0Zi0xNmxlIjoKICAgICAgICAgICAgICByZXR1cm4gdWNzMldyaXRlKHRoaXMsIHN0cmluZywgb2Zmc2V0LCBsZW5ndGgpOwogICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgIGlmIChsb3dlcmVkQ2FzZSkKICAgICAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoIlVua25vd24gZW5jb2Rpbmc6ICIgKyBlbmNvZGluZyk7CiAgICAgICAgICAgICAgZW5jb2RpbmcgPSAoIiIgKyBlbmNvZGluZykudG9Mb3dlckNhc2UoKTsKICAgICAgICAgICAgICBsb3dlcmVkQ2FzZSA9IHRydWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9OwogICAgICBCdWZmZXI2LnByb3RvdHlwZS50b0pTT04gPSBmdW5jdGlvbiB0b0pTT04oKSB7CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIHR5cGU6ICJCdWZmZXIiLAogICAgICAgICAgZGF0YTogQXJyYXkucHJvdG90eXBlLnNsaWNlLmNhbGwodGhpcy5fYXJyIHx8IHRoaXMsIDApCiAgICAgICAgfTsKICAgICAgfTsKICAgICAgZnVuY3Rpb24gYmFzZTY0U2xpY2UoYnVmLCBzdGFydCwgZW5kKSB7CiAgICAgICAgaWYgKHN0YXJ0ID09PSAwICYmIGVuZCA9PT0gYnVmLmxlbmd0aCkgewogICAgICAgICAgcmV0dXJuIGJhc2U2NC5mcm9tQnl0ZUFycmF5KGJ1Zik7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHJldHVybiBiYXNlNjQuZnJvbUJ5dGVBcnJheShidWYuc2xpY2Uoc3RhcnQsIGVuZCkpOwogICAgICAgIH0KICAgICAgfQogICAgICBmdW5jdGlvbiB1dGY4U2xpY2UoYnVmLCBzdGFydCwgZW5kKSB7CiAgICAgICAgZW5kID0gTWF0aC5taW4oYnVmLmxlbmd0aCwgZW5kKTsKICAgICAgICBjb25zdCByZXMgPSBbXTsKICAgICAgICBsZXQgaSA9IHN0YXJ0OwogICAgICAgIHdoaWxlIChpIDwgZW5kKSB7CiAgICAgICAgICBjb25zdCBmaXJzdEJ5dGUgPSBidWZbaV07CiAgICAgICAgICBsZXQgY29kZVBvaW50ID0gbnVsbDsKICAgICAgICAgIGxldCBieXRlc1BlclNlcXVlbmNlID0gZmlyc3RCeXRlID4gMjM5ID8gNCA6IGZpcnN0Qnl0ZSA+IDIyMyA/IDMgOiBmaXJzdEJ5dGUgPiAxOTEgPyAyIDogMTsKICAgICAgICAgIGlmIChpICsgYnl0ZXNQZXJTZXF1ZW5jZSA8PSBlbmQpIHsKICAgICAgICAgICAgbGV0IHNlY29uZEJ5dGUsIHRoaXJkQnl0ZSwgZm91cnRoQnl0ZSwgdGVtcENvZGVQb2ludDsKICAgICAgICAgICAgc3dpdGNoIChieXRlc1BlclNlcXVlbmNlKSB7CiAgICAgICAgICAgICAgY2FzZSAxOgogICAgICAgICAgICAgICAgaWYgKGZpcnN0Qnl0ZSA8IDEyOCkgewogICAgICAgICAgICAgICAgICBjb2RlUG9pbnQgPSBmaXJzdEJ5dGU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIDI6CiAgICAgICAgICAgICAgICBzZWNvbmRCeXRlID0gYnVmW2kgKyAxXTsKICAgICAgICAgICAgICAgIGlmICgoc2Vjb25kQnl0ZSAmIDE5MikgPT09IDEyOCkgewogICAgICAgICAgICAgICAgICB0ZW1wQ29kZVBvaW50ID0gKGZpcnN0Qnl0ZSAmIDMxKSA8PCA2IHwgc2Vjb25kQnl0ZSAmIDYzOwogICAgICAgICAgICAgICAgICBpZiAodGVtcENvZGVQb2ludCA+IDEyNykgewogICAgICAgICAgICAgICAgICAgIGNvZGVQb2ludCA9IHRlbXBDb2RlUG9pbnQ7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGNhc2UgMzoKICAgICAgICAgICAgICAgIHNlY29uZEJ5dGUgPSBidWZbaSArIDFdOwogICAgICAgICAgICAgICAgdGhpcmRCeXRlID0gYnVmW2kgKyAyXTsKICAgICAgICAgICAgICAgIGlmICgoc2Vjb25kQnl0ZSAmIDE5MikgPT09IDEyOCAmJiAodGhpcmRCeXRlICYgMTkyKSA9PT0gMTI4KSB7CiAgICAgICAgICAgICAgICAgIHRlbXBDb2RlUG9pbnQgPSAoZmlyc3RCeXRlICYgMTUpIDw8IDEyIHwgKHNlY29uZEJ5dGUgJiA2MykgPDwgNiB8IHRoaXJkQnl0ZSAmIDYzOwogICAgICAgICAgICAgICAgICBpZiAodGVtcENvZGVQb2ludCA+IDIwNDcgJiYgKHRlbXBDb2RlUG9pbnQgPCA1NTI5NiB8fCB0ZW1wQ29kZVBvaW50ID4gNTczNDMpKSB7CiAgICAgICAgICAgICAgICAgICAgY29kZVBvaW50ID0gdGVtcENvZGVQb2ludDsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSA0OgogICAgICAgICAgICAgICAgc2Vjb25kQnl0ZSA9IGJ1ZltpICsgMV07CiAgICAgICAgICAgICAgICB0aGlyZEJ5dGUgPSBidWZbaSArIDJdOwogICAgICAgICAgICAgICAgZm91cnRoQnl0ZSA9IGJ1ZltpICsgM107CiAgICAgICAgICAgICAgICBpZiAoKHNlY29uZEJ5dGUgJiAxOTIpID09PSAxMjggJiYgKHRoaXJkQnl0ZSAmIDE5MikgPT09IDEyOCAmJiAoZm91cnRoQnl0ZSAmIDE5MikgPT09IDEyOCkgewogICAgICAgICAgICAgICAgICB0ZW1wQ29kZVBvaW50ID0gKGZpcnN0Qnl0ZSAmIDE1KSA8PCAxOCB8IChzZWNvbmRCeXRlICYgNjMpIDw8IDEyIHwgKHRoaXJkQnl0ZSAmIDYzKSA8PCA2IHwgZm91cnRoQnl0ZSAmIDYzOwogICAgICAgICAgICAgICAgICBpZiAodGVtcENvZGVQb2ludCA+IDY1NTM1ICYmIHRlbXBDb2RlUG9pbnQgPCAxMTE0MTEyKSB7CiAgICAgICAgICAgICAgICAgICAgY29kZVBvaW50ID0gdGVtcENvZGVQb2ludDsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoY29kZVBvaW50ID09PSBudWxsKSB7CiAgICAgICAgICAgIGNvZGVQb2ludCA9IDY1NTMzOwogICAgICAgICAgICBieXRlc1BlclNlcXVlbmNlID0gMTsKICAgICAgICAgIH0gZWxzZSBpZiAoY29kZVBvaW50ID4gNjU1MzUpIHsKICAgICAgICAgICAgY29kZVBvaW50IC09IDY1NTM2OwogICAgICAgICAgICByZXMucHVzaChjb2RlUG9pbnQgPj4+IDEwICYgMTAyMyB8IDU1Mjk2KTsKICAgICAgICAgICAgY29kZVBvaW50ID0gNTYzMjAgfCBjb2RlUG9pbnQgJiAxMDIzOwogICAgICAgICAgfQogICAgICAgICAgcmVzLnB1c2goY29kZVBvaW50KTsKICAgICAgICAgIGkgKz0gYnl0ZXNQZXJTZXF1ZW5jZTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGRlY29kZUNvZGVQb2ludHNBcnJheShyZXMpOwogICAgICB9CiAgICAgIHZhciBNQVhfQVJHVU1FTlRTX0xFTkdUSCA9IDQwOTY7CiAgICAgIGZ1bmN0aW9uIGRlY29kZUNvZGVQb2ludHNBcnJheShjb2RlUG9pbnRzKSB7CiAgICAgICAgY29uc3QgbGVuID0gY29kZVBvaW50cy5sZW5ndGg7CiAgICAgICAgaWYgKGxlbiA8PSBNQVhfQVJHVU1FTlRTX0xFTkdUSCkgewogICAgICAgICAgcmV0dXJuIFN0cmluZy5mcm9tQ2hhckNvZGUuYXBwbHkoU3RyaW5nLCBjb2RlUG9pbnRzKTsKICAgICAgICB9CiAgICAgICAgbGV0IHJlcyA9ICIiOwogICAgICAgIGxldCBpID0gMDsKICAgICAgICB3aGlsZSAoaSA8IGxlbikgewogICAgICAgICAgcmVzICs9IFN0cmluZy5mcm9tQ2hhckNvZGUuYXBwbHkoU3RyaW5nLCBjb2RlUG9pbnRzLnNsaWNlKGksIGkgKz0gTUFYX0FSR1VNRU5UU19MRU5HVEgpKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHJlczsKICAgICAgfQogICAgICBmdW5jdGlvbiBhc2NpaVNsaWNlKGJ1Ziwgc3RhcnQsIGVuZCkgewogICAgICAgIGxldCByZXQgPSAiIjsKICAgICAgICBlbmQgPSBNYXRoLm1pbihidWYubGVuZ3RoLCBlbmQpOwogICAgICAgIGZvciAobGV0IGkgPSBzdGFydDsgaSA8IGVuZDsgKytpKSB7CiAgICAgICAgICByZXQgKz0gU3RyaW5nLmZyb21DaGFyQ29kZShidWZbaV0gJiAxMjcpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gcmV0OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGxhdGluMVNsaWNlKGJ1Ziwgc3RhcnQsIGVuZCkgewogICAgICAgIGxldCByZXQgPSAiIjsKICAgICAgICBlbmQgPSBNYXRoLm1pbihidWYubGVuZ3RoLCBlbmQpOwogICAgICAgIGZvciAobGV0IGkgPSBzdGFydDsgaSA8IGVuZDsgKytpKSB7CiAgICAgICAgICByZXQgKz0gU3RyaW5nLmZyb21DaGFyQ29kZShidWZbaV0pOwogICAgICAgIH0KICAgICAgICByZXR1cm4gcmV0OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGhleFNsaWNlKGJ1Ziwgc3RhcnQsIGVuZCkgewogICAgICAgIGNvbnN0IGxlbiA9IGJ1Zi5sZW5ndGg7CiAgICAgICAgaWYgKCFzdGFydCB8fCBzdGFydCA8IDApCiAgICAgICAgICBzdGFydCA9IDA7CiAgICAgICAgaWYgKCFlbmQgfHwgZW5kIDwgMCB8fCBlbmQgPiBsZW4pCiAgICAgICAgICBlbmQgPSBsZW47CiAgICAgICAgbGV0IG91dCA9ICIiOwogICAgICAgIGZvciAobGV0IGkgPSBzdGFydDsgaSA8IGVuZDsgKytpKSB7CiAgICAgICAgICBvdXQgKz0gaGV4U2xpY2VMb29rdXBUYWJsZVtidWZbaV1dOwogICAgICAgIH0KICAgICAgICByZXR1cm4gb3V0OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIHV0ZjE2bGVTbGljZShidWYsIHN0YXJ0LCBlbmQpIHsKICAgICAgICBjb25zdCBieXRlcyA9IGJ1Zi5zbGljZShzdGFydCwgZW5kKTsKICAgICAgICBsZXQgcmVzID0gIiI7CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBieXRlcy5sZW5ndGggLSAxOyBpICs9IDIpIHsKICAgICAgICAgIHJlcyArPSBTdHJpbmcuZnJvbUNoYXJDb2RlKGJ5dGVzW2ldICsgYnl0ZXNbaSArIDFdICogMjU2KTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHJlczsKICAgICAgfQogICAgICBCdWZmZXI2LnByb3RvdHlwZS5zbGljZSA9IGZ1bmN0aW9uIHNsaWNlKHN0YXJ0LCBlbmQpIHsKICAgICAgICBjb25zdCBsZW4gPSB0aGlzLmxlbmd0aDsKICAgICAgICBzdGFydCA9IH5+c3RhcnQ7CiAgICAgICAgZW5kID0gZW5kID09PSB2b2lkIDAgPyBsZW4gOiB+fmVuZDsKICAgICAgICBpZiAoc3RhcnQgPCAwKSB7CiAgICAgICAgICBzdGFydCArPSBsZW47CiAgICAgICAgICBpZiAoc3RhcnQgPCAwKQogICAgICAgICAgICBzdGFydCA9IDA7CiAgICAgICAgfSBlbHNlIGlmIChzdGFydCA+IGxlbikgewogICAgICAgICAgc3RhcnQgPSBsZW47CiAgICAgICAgfQogICAgICAgIGlmIChlbmQgPCAwKSB7CiAgICAgICAgICBlbmQgKz0gbGVuOwogICAgICAgICAgaWYgKGVuZCA8IDApCiAgICAgICAgICAgIGVuZCA9IDA7CiAgICAgICAgfSBlbHNlIGlmIChlbmQgPiBsZW4pIHsKICAgICAgICAgIGVuZCA9IGxlbjsKICAgICAgICB9CiAgICAgICAgaWYgKGVuZCA8IHN0YXJ0KQogICAgICAgICAgZW5kID0gc3RhcnQ7CiAgICAgICAgY29uc3QgbmV3QnVmID0gdGhp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ICB0aGlzLmNvcHlXaXRoaW4odGFyZ2V0U3RhcnQsIHN0YXJ0LCBlbmQpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBVaW50OEFycmF5LnByb3RvdHlwZS5zZXQuY2FsbCh0YXJnZXQsIHRoaXMuc3ViYXJyYXkoc3RhcnQsIGVuZCksIHRhcmdldFN0YXJ0KTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGxlbjsKICAgICAgfTsKICAgICAgQnVmZmVyNi5wcm90b3R5cGUuZmlsbCA9IGZ1bmN0aW9uIGZpbGwodmFsLCBzdGFydCwgZW5kLCBlbmNvZGluZykgewogICAgICAgIGlmICh0eXBlb2YgdmFsID09PSAic3RyaW5nIikgewogICAgICAgICAgaWYgKHR5cGVvZiBzdGFydCA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgZW5jb2RpbmcgPSBzdGFydDsKICAgICAgICAgICAgc3RhcnQgPSAwOwogICAgICAgICAgICBlbmQgPSB0aGlzLmxlbmd0aDsKICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGVuZCA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgZW5jb2RpbmcgPSBlbmQ7CiAgICAgICAgICAgIGVuZCA9IHRoaXMubGVuZ3RoOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGVuY29kaW5nICE9PSB2b2lkIDAgJiYgdHlwZW9mIGVuY29kaW5nICE9PSAic3RyaW5nIikgewogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCJlbmNvZGluZyBtdXN0IGJlIGEgc3RyaW5nIik7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAodHlwZW9mIGVuY29kaW5nID09PSAic3RyaW5nIiAmJiAhQnVmZmVyNi5pc0VuY29kaW5nKGVuY29kaW5nKSkgewogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCJVbmtub3duIGVuY29kaW5nOiAiICsgZW5jb2RpbmcpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHZhbC5sZW5ndGggPT09IDEpIHsKICAgICAgICAgICAgY29uc3QgY29kZSA9IHZhbC5jaGFyQ29kZUF0KDApOwogICAgICAgICAgICBpZiAoZW5jb2RpbmcgPT09ICJ1dGY4IiAmJiBjb2RlIDwgMTI4IHx8IGVuY29kaW5nID09PSAibGF0aW4xIikgewogICAgICAgICAgICAgIHZhbCA9IGNvZGU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiB2YWwgPT09ICJudW1iZXIiKSB7CiAgICAgICAgICB2YWwgPSB2YWwgJiAyNTU7CiAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgdmFsID09PSAiYm9vbGVhbiIpIHsKICAgICAgICAgIHZhbCA9IE51bWJlcih2YWwpOwogICAgICAgIH0KICAgICAgICBpZiAoc3RhcnQgPCAwIHx8IHRoaXMubGVuZ3RoIDwgc3RhcnQgfHwgdGhpcy5sZW5ndGggPCBlbmQpIHsKICAgICAgICAgIHRocm93IG5ldyBSYW5nZUVycm9yKCJPdXQgb2YgcmFuZ2UgaW5kZXgiKTsKICAgICAgICB9CiAgICAgICAgaWYgKGVuZCA8PSBzdGFydCkgewogICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgfQogICAgICAgIHN0YXJ0ID0gc3RhcnQgPj4+IDA7CiAgICAgICAgZW5kID0gZW5kID09PSB2b2lkIDAgPyB0aGlzLmxlbmd0aCA6IGVuZCA+Pj4gMDsKICAgICAgICBpZiAoIXZhbCkKICAgICAgICAgIHZhbCA9IDA7CiAgICAgICAgbGV0IGk7CiAgICAgICAgaWYgKHR5cGVvZiB2YWwgPT09ICJudW1iZXIiKSB7CiAgICAgICAgICBmb3IgKGkgPSBzdGFydDsgaSA8IGVuZDsgKytpKSB7CiAgICAgICAgICAgIHRoaXNbaV0gPSB2YWw7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGNvbnN0IGJ5dGVzID0gQnVmZmVyNi5pc0J1ZmZlcih2YWwpID8gdmFsIDogQnVmZmVyNi5mcm9tKHZhbCwgZW5jb2RpbmcpOwogICAgICAgICAgY29uc3QgbGVuID0gYnl0ZXMubGVuZ3RoOwogICAgICAgICAgaWYgKGxlbiA9PT0gMCkgewogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCdUaGUgdmFsdWUgIicgKyB2YWwgKyAnIiBpcyBpbnZhbGlkIGZvciBhcmd1bWVudCAidmFsdWUiJyk7CiAgICAgICAgICB9CiAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgZW5kIC0gc3RhcnQ7ICsraSkgewogICAgICAgICAgICB0aGlzW2kgKyBzdGFydF0gPSBieXRlc1tpICUgbGVuXTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgIH07CiAgICAgIHZhciBlcnJvcnMgPSB7fTsKICAgICAgZnVuY3Rpb24gRShzeW0sIGdldE1lc3NhZ2UsIEJhc2UpIHsKICAgICAgICBlcnJvcnNbc3ltXSA9IGNsYXNzIE5vZGVFcnJvciBleHRlbmRzIEJhc2UgewogICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgIHN1cGVyKCk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAibWVzc2FnZSIsIHsKICAgICAgICAgICAgICB2YWx1ZTogZ2V0TWVzc2FnZS5hcHBseSh0aGlzLCBhcmd1bWVudHMpLAogICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZQogICAgICAgICAgICB9KTsKICAgICAgICAgICAgdGhpcy5uYW1lID0gYCR7dGhpcy5uYW1lfSBbJHtzeW19XWA7CiAgICAgICAgICAgIHRoaXMuc3RhY2s7CiAgICAgICAgICAgIGRlbGV0ZSB0aGlzLm5hbWU7CiAgICAgICAgICB9CiAgICAgICAgICBnZXQgY29kZSgpIHsKICAgICAgICAgICAgcmV0dXJuIHN5bTsKICAgICAgICAgIH0KICAgICAgICAgIHNldCBjb2RlKHZhbHVlKSB7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiY29kZSIsIHsKICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZQogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICAgIHRvU3RyaW5nKCkgewogICAgICAgICAgICByZXR1cm4gYCR7dGhpcy5uYW1lfSBbJHtzeW19XTogJHt0aGlzLm1lc3NhZ2V9YDsKICAgICAgICAgIH0KICAgICAgICB9OwogICAgICB9CiAgICAgIEUoIkVSUl9CVUZGRVJfT1VUX09GX0JPVU5EUyIsIGZ1bmN0aW9uKG5hbWUpIHsKICAgICAgICBpZiAobmFtZSkgewogICAgICAgICAgcmV0dXJuIGAke25hbWV9IGlzIG91dHNpZGUgb2YgYnVmZmVyIGJvdW5kc2A7CiAgICAgICAgfQogICAgICAgIHJldHVybiAiQXR0ZW1wdCB0byBhY2Nlc3MgbWVtb3J5IG91dHNpZGUgYnVmZmVyIGJvdW5kcyI7CiAgICAgIH0sIFJhbmdlRXJyb3IpOwogICAgICBFKCJFUlJfSU5WQUxJRF9BUkdfVFlQRSIsIGZ1bmN0aW9uKG5hbWUsIGFjdHVhbCkgewogICAgICAgIHJldHVybiBgVGhlICIke25hbWV9IiBhcmd1bWVudCBtdXN0IGJlIG9mIHR5cGUgbnVtYmVyLiBSZWNlaXZlZCB0eXBlICR7dHlwZW9mIGFjdHVhbH1gOwogICAgICB9LCBUeXBlRXJyb3IpOwogICAgICBFKCJFUlJfT1VUX09GX1JBTkdFIiwgZnVuY3Rpb24oc3RyLCByYW5nZSwgaW5wdXQpIHsKICAgICAgICB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ICAgIHJldHVybiBgJHt2YWwuc2xpY2UoMCwgaSl9JHtyZXN9YDsKICAgICAgfQogICAgICBmdW5jdGlvbiBjaGVja0JvdW5kcyhidWYsIG9mZnNldCwgYnl0ZUxlbmd0aDIpIHsKICAgICAgICB2YWxpZGF0ZU51bWJlcihvZmZzZXQsICJvZmZzZXQiKTsKICAgICAgICBpZiAoYnVmW29mZnNldF0gPT09IHZvaWQgMCB8fCBidWZbb2Zmc2V0ICsgYnl0ZUxlbmd0aDJdID09PSB2b2lkIDApIHsKICAgICAgICAgIGJvdW5kc0Vycm9yKG9mZnNldCwgYnVmLmxlbmd0aCAtIChieXRlTGVuZ3RoMiArIDEpKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgZnVuY3Rpb24gY2hlY2tJbnRCSSh2YWx1ZSwgbWluLCBtYXgsIGJ1Ziwgb2Zmc2V0LCBieXRlTGVuZ3RoMikgewogICAgICAgIGlmICh2YWx1ZSA+IG1heCB8fCB2YWx1ZSA8IG1pbikgewogICAgICAgICAgY29uc3QgbiA9IHR5cGVvZiBtaW4gPT09ICJiaWdpbnQiID8gIm4iIDogIiI7CiAgICAgICAgICBsZXQgcmFuZ2U7CiAgICAgICAgICBpZiAoYnl0ZUxlbmd0aDIgPiAzKSB7CiAgICAgICAgICAgIGlmIChtaW4gPT09IDAgfHwgbWluID09PSBCaWdJbnQoMCkpIHsKICAgICAgICAgICAgICByYW5nZSA9IGA+PSAwJHtufSBhbmQgPCAyJHtufSAqKiAkeyhieXRlTGVuZ3RoMiArIDEpICogOH0ke259YDsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICByYW5nZSA9IGA+PSAtKDIke259ICoqICR7KGJ5dGVMZW5ndGgyICsgMSkgKiA4IC0gMX0ke259KSBhbmQgPCAyICoqICR7KGJ5dGVMZW5ndGgyICsgMSkgKiA4IC0gMX0ke259YDsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcmFuZ2UgPSB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05QS1aYS16LV9dL2c7CiAgICAgIGZ1bmN0aW9uIGJhc2U2NGNsZWFuKHN0cikgewogICAgICAgIHN0ciA9IHN0ci5zcGxpdCgiPSIpWzBdOwogICAgICAgIHN0ciA9IHN0ci50cmltKCkucmVwbGFjZShJTlZBTElEX0JBU0U2NF9SRSwgIiIpOwogICAgICAgIGlmIChzdHIubGVuZ3RoIDwgMikKICAgICAgICAgIHJldHVybiAiIjsKICAgICAgICB3aGlsZSAoc3RyLmxlbmd0aCAlIDQgIT09IDApIHsKICAgICAgICAgIHN0ciA9IHN0ciArICI9IjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHN0cjsKICAgICAgfQogICAgICBmdW5jdGlvbiB1dGY4VG9CeXRlcyhzdHJpbmcsIHVuaXRzKSB7CiAgICAgICAgdW5pdHMgPSB1bml0cyB8fCBJbmZpbml0eTsKICAgICAgICBsZXQgY29kZVBvaW50OwogICAgICAgIGNvbnN0IGxlbmd0aCA9IHN0cmluZy5sZW5ndGg7CiAgICAgICAgbGV0IGxlYWRTdXJyb2dhdGUgPSBudWxsOwogICAgICAgIGNvbnN0IGJ5dGVzID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsZW5ndGg7ICsraSkgewogICAgICAgICAgY29kZVBvaW50ID0gc3RyaW5nLmNoYXJDb2RlQXQoaSk7CiAgICAgICAgICBpZiAoY29kZVBvaW50ID4gNTUyOTUgJiYgY29kZVBvaW50IDwgNTczNDQpIHsKICAgICAgICAgICAgaWYgKCFsZWFkU3Vycm9nYXRlKSB7CiAgICAgICAgICAgICAgaWYgKGNvZGVQb2ludCA+IDU2MzE5KSB7CiAgICAgICAgICAgICAgICBpZiAoKHVuaXRzIC09IDMpID4gLTEpCiAgICAgICAgICAgICAgICAgIGJ5dGVzLnB1c2goMjM5LCAxOTEsIDE4OSk7CiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICB9IGVsc2UgaWYgKGkgKyAxID09PSBsZW5ndGgpIHsKICAgICAgICAgICAgICAgIGlmICgodW5pdHMgLT0gMykgPiAtMSkKICAgICAgICAgICAgICAgICAgYnl0ZXMucHVzaCgyMzksIDE5MSwgMTg5KTsKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBsZWFkU3Vycm9nYXRlID0gY29kZVBvaW50OwogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChjb2RlUG9pbnQgPCA1NjMyMCkgewogICAgICAgICAgICAgIGlmICgodW5pdHMgLT0gMykgPiAtMSkKICAgICAgICAgICAgICAgIGJ5dGVzLnB1c2goMjM5LCAxOTEsIDE4OSk7CiAgICAgICAgICAgICAgbGVhZFN1cnJvZ2F0ZSA9IGNvZGVQb2ludDsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb2RlUG9pbnQgPSAobGVhZFN1cnJvZ2F0ZSAtIDU1Mjk2IDw8IDEwIHwgY29kZVBvaW50IC0gNTYzMjApICsgNjU1MzY7CiAgICAgICAgICB9IGVsc2UgaWYgKGxlYWRTdXJyb2dhdGUpIHsKICAgICAgICAgICAgaWYgKCh1bml0cyAtPSAzKSA+IC0xKQogICAgICAgICAgICAgIGJ5dGVzLnB1c2goMjM5LCAxOTEsIDE4OSk7CiAgICAgICAgICB9CiAgICAgICAgICBsZWFkU3Vycm9nYXRlID0gbnVsbDsKICAgICAgICAgIGlmIChjb2RlUG9pbnQgPCAxMjgpIHsKICAgICAgICAgICAgaWYgKCh1bml0cyAtPSAxKSA8IDApCiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGJ5dGVzLnB1c2goY29kZVBvaW50KTsKICAgICAgICAgIH0gZWxzZSBpZiAoY29kZVBvaW50IDwgMjA0OCkgewogICAgICAgICAgICBpZiAoKHVuaXRzIC09IDIpIDwgMCkKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgYnl0ZXMucHVzaChjb2RlUG9pbnQgPj4gNiB8IDE5MiwgY29kZVBvaW50ICYgNjMgfCAxMjgpOwogICAgICAgICAgfSBlbHNlIGlmIChjb2RlUG9pbnQgPCA2NTUzNikgewogICAgICAgICAgICBpZiAoKHVuaXRzIC09IDMpIDwgMCkKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgYnl0ZXMucHVzaChjb2RlUG9pbnQgPj4gMTIgfCAyMjQsIGNvZGVQb2ludCA+PiA2ICYgNjMgfCAxMjgsIGNvZGVQb2ludCAmIDYzIHwgMTI4KTsKICAgICAgICAgIH0gZWxzZSBpZiAoY29kZVBvaW50IDwgMTExNDExMikgewogICAgICAgICAgICBpZiAoKHVuaXRzIC09IDQpIDwgMCkKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgYnl0ZXMucHVzaChjb2RlUG9pbnQgPj4gMTggfCAyNDAsIGNvZGVQb2ludCA+PiAxMiAmIDYzIHwgMTI4LCBjb2RlUG9pbnQgPj4gNiAmIDYzIHwgMTI4LCBjb2RlUG9pbnQgJiA2MyB8IDEyOCk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgY29kZSBwb2ludCIpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gYnl0ZXM7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gYXNjaWlUb0J5dGVzKHN0cikgewogICAgICAgIGNvbnN0IGJ5dGVBcnJheSA9IFtdOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgc3RyLmxlbmd0aDsgKytpKSB7CiAgICAgICAgICBieXRlQXJyYXkucHVzaChzdHIuY2hhckNvZGVBdChpKSAmIDI1NSk7CiAgICAgICAgfQogICAgICAgIHJldHVybiBieXRlQXJyYXk7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gdXRmMTZsZVRvQnl0ZXMoc3RyLCB1bml0cykgewogICAgICAgIGxldCBjLCBoaSwgbG87CiAgICAgICAgY29uc3QgYnl0ZUFycmF5ID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBzdHIubGVuZ3RoOyArK2kpIHsKICAgICAgICAgIGlmICgodW5pdHMgLT0gMikgPCAwKQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGMgPSBzdHIuY2hhckNvZGVBdChpKTsKICAgICAgICAgIGhpID0gYyA+PiA4OwogICAgICAgICAgbG8gPSBjICUgMjU2OwogICAgICAgICAgYnl0ZUFycmF5LnB1c2gobG8pOwogICAgICAgICAgYnl0ZUFycmF5LnB1c2goaGkpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gYnl0ZUFycmF5OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGJhc2U2NFRvQnl0ZXMoc3RyKSB7CiAgICAgICAgcmV0dXJuIGJhc2U2NC50b0J5dGVBcnJheShiYXNlNjRjbGVhbihzdHIpKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBibGl0QnVmZmVyKHNyYywgZHN0LCBvZmZzZXQsIGxlbmd0aCkgewogICAgICAgIGxldCBpOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW5ndGg7ICsraSkgewogICAgICAgICAgaWYgKGkgKyBvZmZzZXQgPj0gZHN0Lmxlbmd0aCB8fCBpID49IHNyYy5sZW5ndGgpCiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZHN0W2kgKyBvZmZzZXRdID0gc3JjW2ldOwogICAgICAgIH0KICAgICAgICByZXR1cm4gaTsKICAgICAgfQogICAgICBmdW5jdGlvbiBpc0luc3RhbmNlKG9iaiwgdHlwZSkgewogICAgICAgIHJldHVybiBvYmogaW5zdGFuY2VvZiB0eXBlIHx8IG9iaiAhPSBudWxsICYmIG9iai5jb25zdHJ1Y3RvciAhPSBudWxsICYmIG9iai5jb25zdHJ1Y3Rvci5uYW1lICE9IG51bGwgJiYgb2JqLmNvbnN0cnVjdG9yLm5hbWUgPT09IHR5cGUubmFtZTsKICAgICAgfQogICAgICBmdW5jdGlvbiBudW1iZXJJc05hTihvYmopIHsKICAgICAgICByZXR1cm4gb2JqICE9PSBvYmo7CiAgICAgIH0KICAgICAgdmFyIGhleFNsaWNlTG9va3VwVGFibGUgPSBmdW5jdGlvbigpIHsKICAgICAgICBjb25zdCBhbHBoYWJldCA9ICIwMTIzNDU2Nzg5YWJjZGVmIjsKICAgICAgICBjb25zdCB0YWJsZSA9IG5ldyBBcnJheSgyNTYpOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgMTY7ICsraSkgewogICAgICAgICAgY29uc3QgaTE2ID0gaSAqIDE2OwogICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCAxNjsgKytqKSB7CiAgICAgICAgICAgIHRhYmxlW2kxNiArIGpdID0gYWxwaGFiZXRbaV0gKyBhbHBoYWJldFtqXTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRhYmxlOwogICAgICB9KCk7CiAgICAgIGZ1bmN0aW9uIGRlZmluZUJpZ0ludE1ldGhvZChmbikgewogICAgICAgIHJldHVybiB0eXBlb2YgQmlnSW50ID09PSAidW5kZWZpbmVkIiA/IEJ1ZmZlckJpZ0ludE5vdERlZmluZWQgOiBmbjsKICAgICAgfQogICAgICBmdW5jdGlvbiBCdWZmZXJCaWdJbnROb3REZWZpbmVkKCkgewogICAgICAgIHRocm93IG5ldyBFcnJvcigiQmlnSW50IG5vdCBzdXBwb3J0ZWQiKTsKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBzcmMvYWxpYXMvYnVmZmVyLXNoaW0uanMKICB2YXIgaW1wb3J0X2J1ZmZlcjsKICB2YXIgaW5pdF9idWZmZXJfc2hpbSA9IF9fZXNtKHsKICAgICJzcmMvYWxpYXMvYnVmZmVyLXNoaW0uanMiKCkgewogICAgICBpbXBvcnRfYnVmZmVyID0gX190b01vZHVsZShyZXF1aXJlX2J1ZmZlcigpKTsKICAgIH0KICB9KTsKCiAgL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ydWUKICAgICAgICAgIH0KICAgICAgICB9KTsKICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoc3ViQ2xhc3MsICJwcm90b3R5cGUiLCB7CiAgICAgICAgICB3cml0YWJsZTogZmFsc2UKICAgICAgICB9KTsKICAgICAgICBpZiAoc3VwZXJDbGFzcykKICAgICAgICAgIF9zZXRQcm90b3R5cGVPZihzdWJDbGFzcywgc3VwZXJDbGFzcyk7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gX2dldFByb3RvdHlwZU9mKG8pIHsKICAgICAgICBfZ2V0UHJvdG90eXBlT2YgPSBPYmplY3Quc2V0UHJvdG90eXBlT2YgPyBPYmplY3QuZ2V0UHJvdG90eXBlT2YuYmluZCgpIDogZnVuY3Rpb24gX2dldFByb3RvdHlwZU9mMihvMikgewogICAgICAgICAgcmV0dXJuIG8yLl9fcHJvdG9fXyB8fCBPYmplY3QuZ2V0UHJvdG90eXBlT2YobzIpOwogICAgICAgIH07CiAgICAgICAgcmV0dXJuIF9nZXRQcm90b3R5cGVPZihvKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBfc2V0UHJvdG90eXBlT2YobywgcCkgewogICAgICAgIF9zZXRQcm90b3R5cGVPZiA9IE9iamVjdC5zZXRQcm90b3R5cGVPZiA/IE9iamVjdC5zZXRQcm90b3R5cGVPZi5iaW5kKCkgOiBmdW5jdGlvbiBfc2V0UHJvdG90eXBlT2YyKG8yLCBwMikgewogICAgICAgICAgbzIuX19wcm90b19fID0gcDI7CiAgICAgICAgICByZXR1cm4gbzI7CiAgICAgICAgfTsKICAgICAgICByZXR1cm4gX3NldFByb3RvdHlwZU9mKG8sIHApOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIF9pc05hdGl2ZVJlZmxlY3RDb25zdHJ1Y3QoKSB7CiAgICAgICAgaWYgKHR5cGVvZiBSZWZsZWN0ID09PSAidW5kZWZpbmVkIiB8fCAhUmVmbGVjdC5jb25zdHJ1Y3QpCiAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgaWYgKFJlZmxlY3QuY29uc3RydWN0LnNoYW0pCiAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgaWYgKHR5cGVvZiBQcm94eSA9PT0gImZ1bmN0aW9uIikKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIHRyeSB7CiAgICAgICAgICBCb29sZWFuLnByb3RvdHlwZS52YWx1ZU9mLmNhbGwoUmVmbGVjdC5jb25zdHJ1Y3QoQm9vbGVhbiwgW10sIGZ1bmN0aW9uKCkgewogICAgICAgICAgfSkpOwogICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgfQogICAgICBmdW5jdGlvbiBfYXNzZXJ0VGhpc0luaXRpYWxpemVkKHNlbGYyKSB7CiAgICAgICAgaWYgKHNlbGYyID09PSB2b2lkIDApIHsKICAgICAgICAgIHRocm93IG5ldyBSZWZlcmVuY2VFcnJvcigidGhpcyBoYXNuJ3QgYmVlbiBpbml0aWFsaXNlZCAtIHN1cGVyKCkgaGFzbid0IGJlZW4gY2FsbGVkIik7CiAgICAgICAgfQogICAgICAgIHJldHVybiBzZWxmMjsKICAgICAgfQogICAgICBmdW5jdGlvbiBfcG9zc2libGVDb25zdHJ1Y3RvclJldHVybihzZWxmMiwgY2FsbCkgewogICAgICAgIGlmIChjYWxsICYmICh0eXBlb2YgY2FsbCA9PT0gIm9iamVjdCIgfHwgdHlwZW9mIGNhbGwgPT09ICJmdW5jdGlvbiIpKSB7CiAgICAgICAgICByZXR1cm4gY2FsbDsKICAgICAgICB9IGVsc2UgaWYgKGNhbGwgIT09IHZvaWQgMCkgewogICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcigiRGVyaXZlZCBjb25zdHJ1Y3RvcnMgbWF5IG9ubHkgcmV0dXJuIG9iamVjdCBvciB1bmRlZmluZWQiKTsKICAgICAgICB9C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4gb2JqZWN0OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIF9nZXQoKSB7CiAgICAgICAgaWYgKHR5cGVvZiBSZWZsZWN0ICE9PSAidW5kZWZpbmVkIiAmJiBSZWZsZWN0LmdldCkgewogICAgICAgICAgX2dldCA9IFJlZmxlY3QuZ2V0LmJpbmQoKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgX2dldCA9IGZ1bmN0aW9uIF9nZXQyKHRhcmdldCwgcHJvcGVydHksIHJlY2VpdmVyKSB7CiAgICAgICAgICAgIHZhciBiYXNlID0gX3N1cGVyUHJvcEJhc2UodGFyZ2V0LCBwcm9wZXJ0eSk7CiAgICAgICAgICAgIGlmICghYmFzZSkKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIHZhciBkZXNjID0gT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcihiYXNlLCBwcm9wZXJ0eSk7CiAgICAgICAgICAgIGlmIChkZXNjLmdldCkgewogICAgICAgICAgICAgIHJldHVybiBkZXNjLmdldC5jYWxsKGFyZ3VtZW50cy5sZW5ndGggPCAzID8gdGFyZ2V0IDogcmVjZWl2ZXIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiBkZXNjLnZhbHVlOwogICAgICAgICAgfTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIF9nZXQuYXBwbHkodGhpcywgYXJndW1lbnRzKTsKICAgICAgfQogICAgICB2YXIgRW1pdHRlciA9IC8qIEBfX1BVUkVfXyAqLyBmdW5jdGlvbigpIHsKICAgICAgICBmdW5jdGlvbiBFbWl0dGVyMigpIHsKICAgICAgICAgIF9jbGFzc0NhbGxDaGVjayh0aGlzLCBFbWl0dGVyMik7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImxpc3RlbmVycyIsIHsKICAgICAgICAgICAgdmFsdWU6IHt9LAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgX2NyZWF0ZUNsYXNzKEVtaXR0ZXIyLCBbewogICAgICAgICAga2V5OiAiYWRkRXZlbnRMaXN0ZW5lciIsCiAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24gYWRkRXZlbnRMaXN0ZW5lcih0eXBlLCBjYWxsYmFjaywgb3B0aW9ucykgewogICAgICAgICAgICBpZiAoISh0eXBlIGluIHRoaXMubGlzdGVuZXJzKSkgewogICAgICAgICAgICAgIHRoaXMubGlzdGVuZXJzW3R5cGVdID0gW107CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGhpcy5saXN0ZW5lcnNbdHlwZV0ucHVzaCh7CiAgICAgICAgICAgICAgY2FsbGJhY2ssCiAgICAgICAgICAgICAgb3B0aW9ucwogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICB9LCB7CiAgICAgICAgICBrZXk6ICJyZW1vdmVFdmVudExpc3RlbmVyIiwKICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbiByZW1vdmVFdmVudExpc3RlbmVyKHR5cGUsIGNhbGxiYWNrKSB7CiAgICAgICAgICAgIGlmICghKHR5cGUgaW4gdGhpcy5saXN0ZW5lcnMpKSB7CiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHZhciBzdGFjayA9IHRoaXMubGlzdGVuZXJzW3R5cGVdOwogICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgbCA9IHN0YWNrLmxlbmd0aDsgaSA8IGw7IGkrKykgewogICAgICAgICAgICAgIGlmIChzdGFja1tpXS5jYWxsYmFjayA9PT0gY2FsbGJhY2spIHsKICAgICAgICAgICAgICAgIHN0YWNrLnNwbGljZShpLCAxKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9LCB7CiAgICAgICAgICBrZXk6ICJkaXNwYXRjaEV2ZW50IiwKICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbiBkaXNwYXRjaEV2ZW50KGV2ZW50KSB7CiAgICAgICAgICAgIGlmICghKGV2ZW50LnR5cGUgaW4gdGhpcy5saXN0ZW5lcnMpKSB7CiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHZhciBzdGFjayA9IHRoaXMubGlzdGVuZXJzW2V2ZW50LnR5cGVdOwogICAgICAgICAgICB2YXIgc3RhY2tUb0NhbGwgPSBzdGFjay5zbGljZSgpOwogICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgbCA9IHN0YWNrVG9DYWxsLmxlbmd0aDsgaSA8IGw7IGkrKykgewogICAgICAgICAgICAgIHZhciBsaXN0ZW5lciA9IHN0YWNrVG9DYWxsW2ldOwogICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICBsaXN0ZW5lci5jYWxsYmFjay5jYWxsKHRoaXMsIGV2ZW50KTsKICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICBQcm9taXNlLnJlc29sdmUoKS50aGVuKGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgICB0aHJvdyBlOwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChsaXN0ZW5lci5vcHRpb25zICYmIGxpc3RlbmVyLm9wdGlvbnMub25jZSkgewogICAgICAgICAgICAgICAgdGhpcy5yZW1vdmVFdmVudExpc3RlbmVyKGV2ZW50LnR5cGUsIGxpc3RlbmVyLmNhbGxiYWNrKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuICFldmVudC5kZWZhdWx0UHJldmVudGVkOwogICAgICAgICAgfQogICAgICAgIH1dKTsKICAgICAgICByZXR1cm4gRW1pdHRlcjI7CiAgICAgIH0oKTsKICAgICAgdmFyIEFib3J0U2lnbmFsID0gLyogQF9fUFVSRV9fICovIGZ1bmN0aW9uKF9FbWl0dGVyKSB7CiAgICAgICAgX2luaGVyaXRzKEFib3J0U2lnbmFsMiwgX0VtaXR0ZXIpOwogICAgICAgIHZhciBfc3VwZXIgPSBfY3JlYXRlU3VwZXIoQWJvcnRTaWduYWwyKTsKICAgICAgICBmdW5jdGlvbiBBYm9ydFNpZ25hbDIoKSB7CiAgICAgICAgICB2YXIgX3RoaXM7CiAgICAgICAgICBfY2xhc3NDYWxsQ2hlY2sodGhpcywgQWJvcnRTaWduYWwyKTsKICAgICAgICAgIF90aGlzID0gX3N1cGVyLmNhbGwodGhpcyk7CiAgICAgICAgICBpZiAoIV90aGlzLmxpc3RlbmVycykgewogICAgICAgICAgICBFbWl0dGVyLmNhbGwoX2Fzc2VydFRoaXNJbml0aWFsaXplZChfdGhpcykpOwogICAgICAgICAgfQogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KF9hc3NlcnRUaGlzSW5pdGlhbGl6ZWQoX3RoaXMpLCAiYWJvcnRlZCIsIHsKICAgICAgICAgICAgdmFsdWU6IGZhbHNlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShfYXNzZXJ0VGhpc0luaXRpYWxpemVkKF90aGlzKSwgIm9uYWJvcnQiLCB7CiAgICAgICAgICAgIHZhbHVlOiBudWxsLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShfYXNzZXJ0VGhpc0luaXRpYWxpemVkKF90aGlzKSwgInJlYXNvbiIsIHsKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMCwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZQogICAgICAgICAgfSk7CiAgICAgICAgICByZXR1cm4gX3RoaXM7CiAgICAgICAgfQogICAgICAgIF9jcmVhdGVDbGFzcyhBYm9ydFNpZ25hbDIsIFt7CiAgICAgICAgICBrZXk6ICJ0b1N0cmluZyIsCiAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24gdG9TdHJpbmcyKCkgewogICAgICAgICAgICByZXR1cm4gIltvYmplY3QgQWJvcnRTaWduYWxdIjsKICAgICAgICAgIH0KICAgICAgICB9LCB7CiAgICAgICAgICBrZXk6ICJkaXNwYXRjaEV2ZW50IiwKICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbiBkaXNwYXRjaEV2ZW50KGV2ZW50KSB7CiAgICAgICAgICAgIGlmIChldmVudC50eXBlID09PSAiYWJvcnQiKSB7CiAgICAgICAgICAgICAgdGhpcy5hYm9ydGVkID0gdHJ1ZTsKICAgICAgICAgICAgICBpZiAodHlwZW9mIHRoaXMub25hYm9ydCA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgdGhpcy5vbmFib3J0LmNhbGwodGhpcywgZXZlbnQpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBfZ2V0KF9nZXRQcm90b3R5cGVPZihBYm9ydFNpZ25hbDIucHJvdG90eXBlKSwgImRpc3BhdGNoRXZlbnQiLCB0aGlzKS5jYWxsKHRoaXMsIGV2ZW50KTsKICAgICAgICAgIH0KICAgICAgICB9XSk7CiAgICAgICAgcmV0dXJuIEFib3J0U2lnbmFsMjsKICAgICAgfShFbWl0dGVyKTsKICAgICAgdmFyIEFib3J0Q29udHJvbGxlciA9IC8qIEBfX1BVUkVfXyAqLyBmdW5jdGlvbigpIHsKICAgICAgICBmdW5jdGlvbiBBYm9ydENvbnRyb2xsZXIyKCkgewogICAgICAgICAgX2NsYXNzQ2FsbENoZWNrKHRoaXMsIEFib3J0Q29udHJvbGxlcjIpOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJzaWduYWwiLCB7CiAgICAgICAgICAgIHZhbHVlOiBuZXcgQWJvcnRTaWduYWwoKSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZQogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICAgIF9jcmVhdGVDbGFzcyhBYm9ydENvbnRyb2xsZXIyLCBbewogICAgICAgICAga2V5OiAiYWJvcnQiLAogICAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIGFib3J0KHJlYXNvbikgewogICAgICAgICAgICB2YXIgZXZlbnQ7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgZXZlbnQgPSBuZXcgRXZlbnQoImFib3J0Iik7CiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICBpZiAodHlwZW9mIGRvY3VtZW50ICE9PSAidW5kZWZpbmVkIikgewogICAgICAgICAgICAgICAgaWYgKCFkb2N1bWVudC5jcmVhdGVFdmVudCkgewogICAgICAgICAgICAgICAgICBldmVudCA9IGRvY3VtZW50LmNyZWF0ZUV2ZW50T2JqZWN0KCk7CiAgICAgICAgICAgICAgICAgIGV2ZW50LnR5cGUgPSAiYWJvcnQiOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgZXZlbnQgPSBkb2N1bWVudC5jcmVhdGVFdmVudCgiRXZlbnQiKTsKICAgICAgICAgICAgICAgICAgZXZlbnQuaW5pdEV2ZW50KCJhYm9ydCIsIGZhbHNlLCBmYWxzZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGV2ZW50ID0gewogICAgICAgICAgICAgICAgICB0eXBlOiAiYWJvcnQiLAogICAgICAgICAgICAgICAgICBidWJibGVzOiBmYWxzZSwKICAgICAgICAgICAgICAgICAgY2FuY2VsYWJsZTogZmFsc2UKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIHZhciBzaWduYWxSZWFzb24gPSByZWFzb247CiAgICAgICAgICAgIGlmIChzaWduYWxSZWFzb24gPT09IHZvaWQgMCkgewogICAgICAgICAgICAgIGlmICh0eXBlb2YgZG9jdW1lbnQgPT09ICJ1bmRlZmluZWQiKSB7CiAgICAgICAgICAgICAgICBzaWduYWxSZWFzb24gPSBuZXcgRXJyb3IoIlRoaXMgb3BlcmF0aW9uIHdhcyBhYm9ydGVkIik7CiAgICAgICAgICAgICAgICBzaWduYWxSZWFzb24ubmFtZSA9ICJBYm9ydEVycm9yIjsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgc2lnbmFsUmVhc29uID0gbmV3IERPTUV4Y2VwdGlvbigic2lnbmFsIGlzIGFib3J0ZWQgd2l0aG91dCByZWFzb24iKTsKICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICAgICAgICBzaWduYWxSZWFzb24gPSBuZXcgRXJyb3IoIlRoaXMgb3BlcmF0aW9uIHdhcyBhYm9ydGVkIik7CiAgICAgICAgICAgICAgICAgIHNpZ25hbFJlYXNvbi5uYW1lID0gIkFib3J0RXJyb3IiOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnNpZ25hbC5yZWFzb24gPSBzaWduYWxSZWFzb247CiAgICAgICAgICAgIHRoaXMuc2lnbmFsLmRpc3BhdGNoRXZlbnQoZXZlbnQpOwogICAgICAgICAgfQogICAgICAgIH0sIHsKICAgICAgICAgIGtleTogInRvU3RyaW5nIiwKICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbiB0b1N0cmluZzIoKSB7CiAgICAgICAgICAgIHJldHVybiAiW29iamVjdCBBYm9ydENvbnRyb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JiYgIVJlcXVlc3QucHJvdG90eXBlLmhhc093blByb3BlcnR5KCJzaWduYWwiKSB8fCBfX0ZPUkNFX0lOU1RBTExfQUJPUlRDT05UUk9MTEVSX1BPTFlGSUxMKSB7CiAgICAgICAgICBSZXF1ZXN0ID0gZnVuY3Rpb24gUmVxdWVzdDIoaW5wdXQsIGluaXQyKSB7CiAgICAgICAgICAgIHZhciBzaWduYWw7CiAgICAgICAgICAgIGlmIChpbml0MiAmJiBpbml0Mi5zaWduYWwpIHsKICAgICAgICAgICAgICBzaWduYWwgPSBpbml0Mi5zaWduYWw7CiAgICAgICAgICAgICAgZGVsZXRlIGluaXQyLnNpZ25hbDsKICAgICAgICAgICAgfQogICAgICAgICAgICB2YXIgcmVxdWVzdCA9IG5ldyBOYXRpdmVSZXF1ZXN0KGlucHV0LCBpbml0Mik7CiAgICAgICAgICAgIGlmIChzaWduYWwpIHsKICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkocmVxdWVzdCwgInNpZ25hbCIsIHsKICAgICAgICAgICAgICAgIHdyaXRhYmxlOiBmYWxzZSwKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IGZhbHNlLAogICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgdmFsdWU6IHNpZ25hbAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiByZXF1ZXN0OwogICAgICAgICAgfTsKICAgICAgICAgIFJlcXVlc3QucHJvdG90eXBlID0gTmF0aXZlUmVxdWVzdC5wcm90b3R5cGU7CiAgICAgICAgfQogICAgICAgIHZhciByZWFsRmV0Y2ggPSBmZXRjaDsKICAgICAgICB2YXIgYWJvcnRhYmxlRmV0Y2ggPSBmdW5jdGlvbiBhYm9ydGFibGVGZXRjaDIoaW5wdXQsIGluaXQyKSB7CiAgICAgICAgICB2YXIgc2lnbmFsID0gUmVxdWVzdCAmJiBSZXF1ZXN0LnByb3RvdHlwZS5pc1Byb3RvdHlwZU9mKGlucHV0KSA/IGlucHV0LnNpZ25hbCA6IGluaXQyID8gaW5pdDIuc2lnbmFsIDogdm9pZCAwOwogICAgICAgICAgaWYgKHNpZ25hbCkgewogICAgICAgICAgICB2YXIgYWJvcnRFcnJvcjsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBhYm9ydEVycm9yID0gbmV3IERPTUV4Y2VwdGlvbigiQWJvcnRlZCIsICJBYm9ydEVycm9yIik7CiAgICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICAgIGFib3J0RXJyb3IgPSBuZXcgRXJyb3IoIkFib3J0ZWQiKTsKICAgICAgICAgICAgICBhYm9ydEVycm9yLm5hbWUgPSAiQWJvcnRFcnJvciI7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHNpZ25hbC5hYm9ydGVkKSB7CiAgICAgICAgICAgICAgcmV0dXJuIFByb21pc2UucmVqZWN0KGFib3J0RXJyb3IpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHZhciBjYW5jZWxsYXRpb24gPSBuZXcgUHJvbWlzZShmdW5jdGlvbihfLCByZWplY3QpIHsKICAgICAgICAgICAgICBzaWduYWwuYWRkRXZlbnRMaXN0ZW5lcigiYWJvcnQiLCBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgIHJldHVybiByZWplY3QoYWJvcnRFcnJvcik7CiAgICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgICAgb25jZTogdHJ1ZQogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9KTsKICAgICAgICAgICAgaWYgKGluaXQyICYmIGluaXQyLnNpZ25hbCkgewogICAgICAgICAgICAgIGRlbGV0ZSBpbml0Mi5zaWduYWw7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIFByb21pc2UucmFjZShbY2FuY2VsbGF0aW9uLCByZWFsRmV0Y2goaW5wdXQsIGluaXQyKV0pOwogICAgICAgICAgfQogICAgICA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lzLmZpbGxDYWxsYmFjayhkYXRhLCBhYm9ydGVyLnNpZ25hbCwgKG1lc3NhZ2UpID0+IHsKICAgICAgICAgICAgICBzdGF0dXNSZXBvcnRlci5jYWxsYmFjayhtZXNzYWdlKTsKICAgICAgICAgICAgfSksCiAgICAgICAgICAgIHNldHRsZWQ6IGZhbHNlLAogICAgICAgICAgICBzdGF0dXNSZXBvcnRlciwKICAgICAgICAgICAgZ2V0IGFib3J0ZWQoKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuYWJvcnRlci5zaWduYWwuYWJvcnRlZDsKICAgICAgICAgICAgfQogICAgICAgICAgfTsKICAgICAgICAgIG5ld0VudHJ5LmFib3J0ZXIuYWRkU2lnbmFsKHNpZ25hbCk7CiAgICAgICAgICBuZXdFbnRyeS5hYm9ydGVyLnNpZ25hbC5hZGRFdmVudExpc3RlbmVyKCJhYm9ydCIsICgpID0+IHsKICAgICAgICAgICAgaWYgKCFuZXdFbnRyeS5zZXR0bGVkKSB7CiAgICAgICAgICAgICAgdGhpcy5ldmljdChrZXksIG5ld0VudHJ5KTsKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgICBuZXdFbnRyeS5wcm9taXNlLnRoZW4oKCkgPT4gewogICAgICAgICAgICBuZXdFbnRyeS5zZXR0bGVkID0gdHJ1ZTsKICAgICAgICAgIH0sICgpID0+IHsKICAgICAgICAgICAgbmV3RW50cnkuc2V0dGxlZCA9IHRydWU7CiAgICAgICAgICAgIHRoaXMuZXZpY3Qoa2V5LCBuZXdFbnRyeSk7CiAgICAgICAgICB9KS5jYXRjaCgoZSkgPT4gewogICAgICAgICAgICBjb25zb2xlLmVycm9yKGUpOwogICAgICAgICAgICB0aHJvdyBlOwogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmNhY2hlLnNldChrZXksIG5ld0VudHJ5KTsKICAgICAgICB9CiAgICAgICAgc3RhdGljIGNoZWNrU2luZ2xlUHJvbWlzZShwcm9taXNlLCBzaWduYWwpIHsKICAgICAgICAgIGZ1bmN0aW9uIGNoZWNrRm9yU2luZ2xlQWJvcnQoKSB7CiAgICAgICAgICAgIGlmIChzaWduYWwgJiYgc2lnbmFsLmFib3J0ZWQpIHsKICAgICAgICAgICAgICB0aHJvdyBPYmplY3QuYXNzaWduKG5ldyBFcnJvcigiYWJvcnRlZCIpLCB7IGNvZGU6ICJFUlJfQUJPUlRFRCIgfSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBwcm9taXNlLnRoZW4oKHJlc3VsdCkgPT4gewogICAgICAgICAgICBjaGVja0ZvclNpbmdsZUFib3J0KCk7CiAgICAgICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgICAgICB9LCAoZXJyb3IpID0+IHsKICAgICAgICAgICAgY2hlY2tGb3JTaW5nbGVBYm9ydCgpOwogICAgICAgICAgICB0aHJvdyBlcnJvcjsKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgICBoYXMoa2V5KSB7CiAgICAgICAgICByZXR1cm4gdGhpcy5jYWNoZS5oYXMoa2V5KTsKICAgICAgICB9CiAgICAgICAgZ2V0KGtleSwgZGF0YSwgc2lnbmFsLCBzdGF0dXNDYWxsYmFjaykgewogICAgICAgICAgaWYgKCFzaWduYWwgJiYgZGF0YSBpbnN0YW5jZW9mIGFib3J0Y29udHJvbGxlcl9wb255ZmlsbF8xLkFib3J0U2lnbmFsKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoInNlY29uZCBnZXQgYXJndW1lbnQgYXBwZWFycyB0byBiZSBhbiBBYm9ydFNpZ25hbCwgcGVyaGFwcyB5b3UgbWVhbnQgdG8gcGFzcyBgbnVsbGAgZm9yIHRoZSBmaWxsIGRhdGE/Iik7CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCBjYWNoZUVudHJ5ID0gdGhpcy5jYWNoZS5nZXQoa2V5KTsKICAgICAgICAgIGlmIChjYWNoZUVudHJ5KSB7Ci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gdmFsdWUpOwogICAgICAgICAgdGhpcy5fc2l6ZSsrOwogICAgICAgICAgaWYgKHRoaXMuX3NpemUgPj0gdGhpcy5tYXhTaXplKSB7CiAgICAgICAgICAgIHRoaXMuX3NpemUgPSAwOwogICAgICAgICAgICB0aGlzLm9sZENhY2hlID0gdGhpcy5jYWNoZTsKICAgICAgICAgICAgdGhpcy5jYWNoZSA9IG5ldyBNYXAoKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZ2V0KGtleSkgewogICAgICAgICAgaWYgKHRoaXMuY2FjaGUuaGFzKGtleSkpIHsKICAgICAgICAgICAgcmV0dXJuIHRoaXMuY2FjaGUuZ2V0KGtleSk7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAodGhpcy5vbGRDYWNoZS5oYXMoa2V5KSkgewogICAgICAgICAgICBjb25zdCB2YWx1ZSA9IHRoaXMub2xkQ2FjaGUuZ2V0KGtleSk7CiAgICAgICAgICAgIHRoaXMub2xkQ2FjaGUuZGVsZXRlKGtleSk7CiAgICAgICAgICAgIHRoaXMuX3NldChrZXksIHZhbHVlKTsKICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBzZXQoa2V5LCB2YWx1ZSkgewogICAgICAgICAgaWYgKHRoaXMuY2FjaGUuaGFzKGtleSkpIHsKICAgICAgICAgICAgdGhpcy5jYWNoZS5zZXQoa2V5LCB2YWx1ZSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICB0aGlzLl9zZXQoa2V5LCB2YWx1ZSk7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICB9CiAgICAgICAgaGFzKGtleSkgewogICAgICAgICAgcmV0dXJuIHRoaXMuY2FjaGUuaGFzKGtleSkgfHwgdGhpcy5vbGRDYWNoZS5oYXMoa2V5KTsKICAgICAgICB9CiAgICAgICAgcGVlayhrZXkpIHsKICAgICAgICAgIGlmICh0aGlzLmNhY2hlLmhhcyhrZXkpKSB7CiAgICAgICAgICAgIHJldHVybiB0aGlzLmNhY2hlLmdldChrZXkpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHRoaXMub2xkQ2FjaGUuaGFzKGtleSkpIHsKICAgICAgICAgICAgcmV0dXJuIHRoaXMub2xkQ2FjaGUuZ2V0KGtleSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGRlbGV0ZShrZXkpIHsKICAgICAgICAgIGNvbnN0IGRlbGV0ZWQgPSB0aGlzLmNhY2hlLmRlbGV0ZShrZXkpOwogICAgICAgICAgaWYgKGRlbGV0ZWQpIHsKICAgICAgICAgICAgdGhpcy5fc2l6ZS0tOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIHRoaXMub2xkQ2FjaGUuZGVsZXRlKGtleSkgfHwgZGVsZXRlZDsKICAgICAgICB9CiAgICAgICAgY2xlYXIoKSB7CiAgICAgICAgICB0aGlzLmNhY2hlLmNsZWFyKCk7CiAgICAgICAgICB0aGlzLm9sZENhY2hlLmNsZWFyKCk7CiAgICAgICAgICB0aGlzLl9zaXplID0gMDsKICAgICAgICB9CiAgICAgICAgKmtleXMoKSB7CiAgICAgICAgICBmb3IgKGNvbnN0IFtrZXldIG9mIHRoaXMpIHsKICAgICAgICAgICAgeWllbGQga2V5OwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICAqdmFsdWVzKCkgewogICAgICAgICAgZm9yIChjb25zdCBbLCB2YWx1ZV0gb2YgdGhpcykgewogICAgICAgICAgICB5aWVsZCB2YWx1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgKltTeW1ib2wuaXRlcmF0b3JdKCkgewogICAgICAgICAgZm9yIChjb25zdCBpdGVtIG9mIHRoaXMuY2FjaGUpIHsKICAgICAgICAgICAgeWllbGQgaXRlbTsKICAgICAgICAgIH0KICAgICAgICAgIGZvciAoY29uc3QgaXRlbSBvZiB0aGlzLm9sZENhY2hlKSB7CiAgICAgICAgICAgIGNvbnN0IFtrZXldID0gaXRlbTsKICAgICAgICAgICAgaWYgKCF0aGlzLmNhY2hlLmhhcyhrZXkpKSB7CiAgICAgICAgICAgICAgeWllbGQgaXRlbTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBnZXQgc2l6ZSgpIHsKICAgICAgICAgIGxldCBvbGRDYWNoZVNpemUgPSAwOwogICAgICAgICAgZm9yIChjb25zdCBrZXkgb2YgdGhpcy5vbGRDYWNoZS5rZXlzKCkpIHsKICAgICAgICAgICAgaWYgKCF0aGlzLmNhY2hlLmhhcyhrZXkpKSB7CiAgICAgICAgICAgICAgb2xkQ2FjaGVTaXplKys7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiB0aGlzLl9zaXplICsgb2xkQ2FjaGVTaXplOwogICAgICAgIH0KICAgICAgfTsKICAgICAgbW9kdWxlMi5leHBvcnRzID0gUXVpY2tMUlU7CiAgICB9CiAgfSk7CgogIC8vIChkaXNhYmxlZCk6bm9kZV9tb2R1bGVzL2dlbmVyaWMtZmlsZWhhbmRsZS9lc20vbG9jYWxGaWxlCiAgdmFyIHJlcXVpcmVfbG9jYWxGaWxlID0gX19jb21tb25KUyh7CiAgICAiKGRpc2FibGVkKTpub2RlX21vZHVsZXMvZ2VuZXJpYy1maWxlaGFuZGxlL2VzbS9sb2NhbEZpbGUiKCkgewogICAgICBpbml0X2J1ZmZlcl9zaGltKCk7CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy9wYWtvL2xpYi91dGlscy9jb21tb24uanMKICB2YXIgcmVxdWlyZV9jb21tb24gPSBfX2NvbW1vbkpTKHsKICAgICJub2RlX21vZHVsZXMvcGFrby9saWIvdXRpbHMvY29tbW9uLmpzIihleHBvcnRzMikgewogICAgICBpbml0X2J1ZmZlcl9zaGltKCk7CiAgICAgICJ1c2Ugc3RyaWN0IjsKICAgICAgdmFyIFRZUEVEX09LID0gdHlwZW9mIFVpbnQ4QXJyYXkgIT09ICJ1bmRlZmluZWQiICYmIHR5cGVvZiBVaW50MTZBcnJheSAhPT0gInVuZGVmaW5lZCIgJiYgdHlwZW9mIEludDMyQXJyYXkgIT09ICJ1bmRlZmluZWQiOwogICAgICBmdW5jdGlvbiBfaGFzKG9iaiwga2V5KSB7CiAgICAgICAgcmV0dXJuIE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbChvYmosIGtleSk7CiAgICAgIH0KICAgICAgZXhwb3J0czIuYXNzaWduID0gZnVuY3Rpb24ob2JqKSB7CiAgICAgICAgdmFyIHNvdXJjZXMgPSBBcnJheS5wcm90b3R5cGUuc2xpY2UuY2FsbChhcmd1bWVudHMsIDEpOwogICAgICAgIHdoaWxlIChzb3VyY2VzLmxlbmd0aCkgewogICAgICAgICAgdmFyIHNvdXJjZSA9IHNvdXJjZXMuc2hpZnQoKTsKICAgICAgICAgIGlmICghc291cmNlKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHR5cGVvZiBzb3VyY2UgIT09ICJvYmplY3QiKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3Ioc291cmNlICsgIm11c3QgYmUgbm9uLW9iamVjdCIpOwogICAgICAgICAgfQogICAgICAgICAgZm9yICh2YXIgcCBpbiBzb3VyY2UpIHsKICAgICAgICAgICAgaWYgKF9oYXMoc291cmNlLCBwKSkgewogICAgICAgICAgICAgIG9ialtwXSA9IHNvdXJjZVtwXTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gb2JqOwogICAgICB9OwogICAgICBleHBvcnRzMi5zaHJpbmtCdWYgPSBmdW5jdGlvbihidWYsIHNpemUpIHsKICAgICAgICBpZiAoYnVmLmxlbmd0aCA9PT0gc2l6ZSkgewogICAgICAgICAgcmV0dXJuIGJ1ZjsKICAgICAgICB9CiAgICAgICAgaWYgKGJ1Zi5zdWJhcnJheSkgewogICAgICAgICAgcmV0dXJuIGJ1Zi5zdWJhcnJheSgwLCBzaXplKTsKICAgICAgICB9CiAgICAgICAgYnVmLmxlbmd0aCA9IHNpemU7CiAgICAgICAgcmV0dXJuIGJ1ZjsKICAgICAgfTsKICAgICAgdmFyIGZuVHlwZWQgPSB7CiAgICAgICAgYXJyYXlTZXQ6IGZ1bmN0aW9uKGRlc3QsIHNyYywgc3JjX29mZnMsIGxlbiwgZGVzdF9vZmZzKSB7CiAgICAgICAgICBpZiAoc3JjLnN1YmFycmF5ICYmIGRlc3Quc3ViYXJyYXkpIHsKICAgICAgICAgICAgZGVzdC5zZXQoc3JjLnN1YmFycmF5KHNyY19vZmZzLCBzcmNfb2ZmcyArIGxlbiksIGRlc3Rfb2Zmcyk7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgIH0KICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgbGVuOyBpKyspIHsKICAgICAgICAgICAgZGVzdFtkZXN0X29mZnMgKyBpXSA9IHNyY1tzcmNfb2ZmcyArIGldOwogICAgICAgICAgfQogICAgICAgIH0sCiAgICAgICAgZmxhdHRlbkNodW5rczogZnVuY3Rpb24oY2h1bmtzKSB7CiAgICAgICAgICB2YXIgaSwgbCwgbGVuLCBwb3MsIGNodW5rLCByZXN1bHQ7CiAgICAgICAgICBsZW4gPSAwOwogICAgICAgICAgZm9yIChpID0gMCwgbCA9IGNodW5rcy5sZW5ndGg7IGkgPCBsOyBpKyspIHsKICAgICAgICAgICAgbGVuICs9IGNodW5rc1tpXS5sZW5ndGg7CiAgICAgICAgICB9CiAgICAgICAgICByZXN1bHQgPSBuZXcgVWludDhBcnJheShsZW4pOwogICAgICAgICAgcG9zID0gMDsKICAgICAgICAgIGZvciAoaSA9IDAsIGwgPSBjaHVua3MubGVuZ3RoOyBpIDwgbDsgaSsrKSB7CiAgICAgICAgICAgIGNodW5rID0gY2h1bmtzW2ldOwogICAgICAgICAgICByZXN1bHQuc2V0KGNodW5rLCBwb3MpOwogICAgICAgICAgICBwb3MgKz0gY2h1bmsubGVuZ3RoOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICB9CiAgICAgIH07CiAgICAgIHZhciBmblVudHlwZWQgPSB7CiAgICAgICAgYXJyYXlTZXQ6IGZ1bmN0aW9uKGRlc3QsIHNyYywgc3JjX29mZnMsIGxlbiwgZGVzdF9vZmZzKSB7CiAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgICAgIGRlc3RbZGVzdF9vZmZzICsgaV0gPSBzcmNbc3JjX29mZnMgKyBpXTsKICAgICAgICAgIH0KICAgICAgICB9LAogICAgICAgIGZsYXR0ZW5DaHVua3M6IGZ1bmN0aW9uKGNodW5rcykgewogICAgICAgICAgcmV0dXJuIFtdLmNvbmNhdC5hcHBseShbXSwgY2h1bmtzKTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIGV4cG9ydHMyLnNldFR5cGVkID0gZnVuY3Rpb24ob24pIHsKICAgICAgICBpZiAob24pIHsKICAgICAgICAgIGV4cG9ydHMyLkJ1ZjggPSBVaW50OEFycmF5OwogICAgICAgICAgZXhwb3J0czIuQnVmMTYgPSBVaW50MTZBcnJheTsKICAgICAgICAgIGV4cG9ydHMyLkJ1ZjMyID0gSW50MzJBcnJheTsKICAgICAgICAgIGV4cG9ydHMyLmFzc2lnbihleHBvcnRzMiwgZm5UeXBlZCk7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGV4cG9ydHMyLkJ1ZjggPSBBcnJheTsKICAgICAgICAgIGV4cG9ydHMyLkJ1ZjE2ID0gQXJyYXk7CiAgICAgICAgICBleHBvcnRzMi5CdWYzMiA9IEFycmF5OwogICAgICAgICAgZXhwb3J0czIuYXNzaWduKGV4cG9ydHMyLCBmblVudHlwZWQpOwogICAgICAgIH0KICAgICAgfTsKICAgICAgZXhwb3J0czIuc2V0VHlwZWQoVFlQRURfT0spOwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvcGFrby9saWIvemxpYi90cmVlcy5qcwogIHZhciByZXF1aXJlX3RyZWVzID0gX19jb21tb25KUyh7CiAgICAibm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvdHJlZXMuanMiKGV4cG9ydHMyKSB7CiAgICAgIGluaXRfYnVmZmVyX3NoaW0oKTsKICAgICAgInVzZSBzdHJpY3QiOwogICAgICB2YXIgdXRpbHMgPSByZXF1aXJlX2NvbW1vbigpOwogICAgICB2YXIgWl9GSVhFRCA9IDQ7CiAgICAgIHZhciBaX0JJTkFSWSA9IDA7CiAgICAgIHZhciBaX1RFWFQgPSAxOwogICAgICB2YXIgWl9VTktOT1dOID0gMjsKICAgICAgZnVuY3Rpb24gemVybyhidWYpIHsKICAgICAgICB2YXIgbGVuID0gYnVmLmxlbmd0aDsKICAgICAgICB3aGlsZSAoLS1sZW4gPj0gMCkgewogICAgICAgICAgYnVmW2xlbl0gPSAwOwogICAgICAgIH0KICAgICAgfQogICAgICB2YXIgU1RPUkVEX0JMT0NLID0gMDsKICAgICAgdmFyIFNUQVRJQ19UUkVFUyA9IDE7CiAgICAgIHZhciBEWU5fVFJFRVMgPSAyOwogICAgICB2YXIgTUlOX01BVENIID0gMzsKICAgICAgdmFyIE1BWF9NQVRDSCA9IDI1ODsKICAgICAgdmFyIExFTkdUSF9DT0RFUyA9IDI5OwogICAgICB2YXIgTElURVJBTFMgPSAyNTY7CiAgICAgIHZhciBMX0NPREVTID0gTElURVJBTFMgKyAxICsgTEVOR1RIX0NPREVTOwogICAgICB2YXIgRF9DT0RFUyA9IDMwOwogICAgICB2YXIgQkxfQ09ERVMgPSAxOTsKICAgICAgdmFyIEhFQVBfU0laRSA9IDIgKiBMX0NPREVTICsgMTsKICAgICAgdmFyIE1BWF9CSVRTID0gMTU7CiAgICAgIHZhciBCdWZfc2l6ZSA9IDE2OwogICAgICB2YXIgTUFYX0JMX0JJVFMgPSA3OwogICAgICB2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gPj4+IDE7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gYmlfZmx1c2gocykgewogICAgICAgIGlmIChzLmJpX3ZhbGlkID09PSAxNikgewogICAgICAgICAgcHV0X3Nob3J0KHMsIHMuYmlfYnVmKTsKICAgICAgICAgIHMuYmlfYnVmID0gMDsKICAgICAgICAgIHMuYmlfdmFsaWQgPSAwOwogICAgICAgIH0gZWxzZSBpZiAocy5iaV92YWxpZCA+PSA4KSB7CiAgICAgICAgICBzLnBlbmRpbmdfYnVmW3MucGVuZGluZysrXSA9IHMuYmlfYnVmICYgMjU1OwogICAgICAgICAgcy5iaV9idWYgPj49IDg7CiAgICAgICAgICBzLmJpX3ZhbGlkIC09IDg7CiAgICAgICAgfQogICAgICB9CiAgICAgIGZ1bmN0aW9uIGdlbl9iaXRsZW4ocywgZGVzYykgewogICAgICAgIHZhciB0cmVlID0gZGVzYy5keW5fdHJlZTsKICAgICAgICB2YXIgbWF4X2NvZGUgPSBkZXNjLm1heF9jb2RlOwogICAgICAgIHZhciBzdHJlZSA9IGRlc2Muc3RhdF9kZXNjLnN0YXRpY190cmVlOwogICAgICAgIHZhciBoYXNfc3RyZWUgPSBkZXNjLnN0YXRfZGVzYy5oYXNfc3RyZWU7CiAgICAgICAgdmFyIGV4dHJhID0gZGVzYy5zdGF0X2Rlc2MuZXh0cmFfYml0czsKICAgICAgICB2YXIgYmFzZSA9IGRlc2Muc3RhdF9kZXNjLmV4dHJhX2Jhc2U7CiAgICAgICAgdmFyIG1heF9sZW5ndGggPSBkZXNjLnN0YXRfZGVzYy5tYXhfbGVuZ3RoOwogICAgICAgIHZhciBoOwogICAgICAgIHZhciBuLCBtOwogICAgICAgIHZhciBiaXRzOwogICAgICAgIHZhciB4Yml0czsKICAgICAgICB2YXIgZjsKICAgICAgICB2YXIgb3ZlcmZsb3cgPSAwOwogICAgICAgIGZvciAoYml0cyA9IDA7IGJpdHMgPD0gTUFYX0JJVFM7IGJpdHMrKykgewogICAgICAgICAgcy5ibF9jb3VudFtiaXRzXSA9IDA7CiAgICAgICAgfQogICAgICAgIHRyZWVbcy5oZWFwW3MuaGVhcF9tYXhdICogMiArIDFdID0gMDsKICAgICAgICBmb3IgKGggPSBzLmhlYXBfbWF4ICsgMTsgaCA8IEhFQVBfU0laRTsgaCsrKSB7CiAgICAgICAgICBuID0gcy5oZWFwW2hdOwogICAgICAgICAgYml0cyA9IHRyZWVbdHJlZVtuICogMiArIDFdICogMiArIDFdICsgMTsKICAgICAgICAgIGlmIChiaXRzID4gbWF4X2xlbmd0aCkgewogICAgICAgICAgICBiaXRzID0gbWF4X2xlbmd0aDsKICAgICAgICAgICAgb3ZlcmZsb3crKzsKICAgICAgICAgIH0KICAgICAgICAgIHRyZWVbbiAqIDIgKyAxXSA9IGJpdHM7CiAgICAgICAgICBpZiAobiA+IG1heF9jb2RlKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgcy5ibF9jb3VudFtiaXRzXSsrOwogICAgICAgICAgeGJpdHMgPSAwOwogICAgICAgICAgaWYgKG4gPj0gYmFzZSkgewogICAgICAgICAgICB4Yml0cyA9IGV4dHJhW24gLSBiYXNlXTsKICAgICAgICAgIH0KICAgICAgICAgIGYgPSB0cmVlW24gKiAyXTsKICAgICAgICAgIHMub3B0X2xlbiArPSBmICogKGJpdHMgKyB4Yml0cyk7CiAgICAgICAgICBpZiAoaGFzX3N0cmVlKSB7CiAgICAgICAgICAgIHMuc3RhdGljX2xlbiArPSBmICogKHN0cmVlW24gKiAyICsgMV0gKyB4Yml0cyk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChvdmVyZmxvdyA9PT0gMCkgewogICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBkbyB7CiAgICAgICAgICBiaXRzID0gbWF4X2xlbmd0aCAtIDE7CiAgICAgICAgICB3aGlsZSAocy5ibF9jb3VudFtiaXRzXSA9PT0gMCkgewogICAgICAgICAgICBiaXRzLS07CiAgICAgICAgICB9CiAgICAgICAgICBzLmJsX2NvdW50W2JpdHNdLS07CiAgICAgICAgICBzLmJsX2NvdW50W2JpdHMgKyAxXSArPSAyOwogICAgICAgICAgcy5ibF9jb3VudFttYXhfbGVuZ3RoXS0tOwogICAgICAgICAgb3ZlcmZsb3cgLT0gMjsKICAgICAgICB9IHdoaWxlIChvdmVyZmxvdyA+IDApOwogICAgICAgIGZvciAoYml0cyA9IG1heF9sZW5ndGg7IGJpdHMgIT09IDA7IGJpdHMtLSkgewogICAgICAgICAgbiA9IHMuYmxfY291bnRbYml0c107CiAgICAgICAgICB3aGlsZSAobiAhPT0gMCkgewogICAgICAgICAgICBtID0gcy5oZWFwWy0taF07CiAgICAgICAgICAgIGlmIChtID4gbWF4X2NvZGUpIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodHJlZVttICogMiArIDFdICE9PSBiaXRzKSB7CiAgICAgICAgICAgICAgcy5vcHRfbGVuICs9IChiaXRzIC0gdHJlZVttICogMiArIDFdKSAqIHRyZWVbbSAqIDJdOwogICAgICAgICAgICAgIHRyZWVbbSAqIDIgKyAxXSA9IGJpdHM7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbi0tOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBmdW5jdGlvbiBnZW5fY29kZXModHJlZSwgbWF4X2NvZGUsIGJsX2NvdW50KSB7CiAgICAgICAgdmFyIG5leHRfY29kZSA9IG5ldyBBcnJheShNQVhfQklUUyArIDEpOwogICAgICAgIHZhciBjb2RlID0gMDsKICAgICAgICB2YXIgYml0czsKICAgICAgICB2YXIgbjsKICAgICAgICBmb3IgKGJpdHMgPSAxOyBiaXRzIDw9IE1BWF9CSVRTOyBiaXRzKyspIHsKICAgICAgICAgIG5leHRfY29kZVtiaXRzXSA9IGNvZGUgPSBjb2RlICsgYmxfY291bnRbYml0cyAtIDFdIDw8IDE7CiAgICAgICAgfQogICAgICAgIGZvciAobiA9IDA7IG4gPD0gbWF4X2NvZGU7IG4rKykgewogICAgICAgICAgdmFyIGxlbiA9IHRyZWVbbiAqIDIgKyAxXTsKICAgICAgICAgIGlmIChsZW4gPT09IDApIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICB0cmVlW24gKiAyXSA9IGJpX3JldmVyc2UobmV4dF9jb2RlW2xlbl0rKywgbGVuKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgZnVuY3Rpb24gdHJfc3RhdGljX2luaXQoKSB7CiAgICAgICAgdmFyIG47CiAgICAgICAgdmFyIGJpdHM7CiAgICAgICAgdmFyIGxlbmd0aDsKICAgICAgICB2YXIgY29kZTsKICAgICAgICB2YXIgZGlzdDsKICAgICAgICB2YXIgYmxfY291bnQgPSBuZXcgQXJyYXkoTUFYX0JJVFMgKyAxKTsKICAgICAgICBsZW5ndGggPSAwOwogICAgICAgIGZvciAoY29kZSA9IDA7IGNvZGUgPCBMRU5HVEhfQ09ERVMgLSAxOyBjb2RlKyspIHsKICAgICAgICAgIGJhc2VfbGVuZ3RoW2NvZGVdID0gbGVuZ3RoOwogICAgICAgICAgZm9yIChuID0gMDsgbiA8IDEgPDwgZXh0cmFfbGJpdHNbY29kZV07IG4rKykgewogICAgICAgICAgICBfbGVuZ3RoX2NvZGVbbGVuZ3RoKytdID0gY29kZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgX2xlbmd0aF9jb2RlW2xlbmd0aCAtIDFdID0gY29kZTsKICAgICAgICBkaXN0ID0gMDsKICAgICAgICBmb3IgKGNvZGUgPSAwOyBjb2RlIDwgMTY7IGNvZGUrKykgewogICAgICAgICAgYmFzZV9kaXN0W2NvZGVdID0gZGlzdDsKICAgICAgICAgIGZvciAobiA9IDA7IG4gPCAxIDw8IGV4dHJhX2RiaXRzW2NvZGVdOyBuKyspIHsKICAgICAgICAgICAgX2Rpc3RfY29kZVtkaXN0KytdID0gY29kZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZGlzdCA+Pj0gNzsKICAgICAgICBmb3IgKDsgY29kZSA8IERfQ09ERVM7IGNvZGUrKykgewogICAgICAgICAgYmFzZV9kaXN0W2NvZGVdID0gZGlzdCA8PCA3OwogICAgICAgICAgZm9yIChuID0gMDsgbiA8IDEgPDwgZXh0cmFfZGJpdHNbY29kZV0gLSA3OyBuKyspIHsKICAgICAgICAgICAgX2Rpc3RfY29kZVsyNTYgKyBkaXN0KytdID0gY29kZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZm9yIChiaXRzID0gMDsgYml0cyA8PSBNQVhfQklUUzsgYml0cysrKSB7CiAgICAgICAgICBibF9jb3VudFtiaXRzXSA9IDA7CiAgICAgICAgfQogICAgICAgIG4gPSAwOwogICAgICAgIHdoaWxlIChuIDw9IDE0MykgewogICAgICAgICAgc3RhdGljX2x0cmVlW24gKiAyICsgMV0gPSA4OwogICAgICAgICAgbisrOwogICAgICAgICAgYmxfY291bnRbOF0rKzsKICAgICAgICB9CiAgICAgICAgd2hpbGUgKG4gPD0gMjU1KSB7CiAgICAgICAgICBzdGF0aWNfbHRyZWVbbiAqIDIgKyAxXSA9IDk7CiAgICAgICAgICBuKys7CiAgICAgICAgICBibF9jb3VudFs5XSsrOwogICAgICAgIH0KICAgICAgICB3aGlsZSAobiA8PSAyNzkpIHsKICAgICAgICAgIHN0YXRpY19sdHJlZVtuICogMiArIDFdID0gNzsKICAgICAgICAgIG4rKzsKICAgICAgICAgIGJsX2NvdW50WzddKys7CiAgICAgICAgfQogICAgICAgIHdoaWxlIChuIDw9IDI4NykgewogICAgICAgICAgc3RhdGljX2x0cmVlW24gKiAyICsgMV0gPSA4OwogICAgICAgICAgbisrOwogICAgICAgICAgYmxfY291bnRbOF0rKzsKICAgICAgICB9CiAgICAgICAgZ2VuX2NvZGVzKHN0YXRpY19sdHJlZSwgTF9DT0RFUyArIDEsIGJsX2NvdW50KTsKICAgICAgICBmb3IgKG4gPSAwOyB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ICAgICB9CiAgICAgIGZ1bmN0aW9uIGJpX3dpbmR1cChzKSB7CiAgICAgICAgaWYgKHMuYmlfdmFsaWQgPiA4KSB7CiAgICAgICAgICBwdXRfc2hvcnQocywgcy5iaV9idWYpOwogICAgICAgIH0gZWxzZSBpZiAocy5iaV92YWxpZCA+IDApIHsKICAgICAgICAgIHMucGVuZGluZ19idWZbcy5wZW5kaW5nKytdID0gcy5iaV9idWY7CiAgICAgICAgfQogICAgICAgIHMuYmlfYnVmID0gMDsKICAgICAgICBzLmJpX3ZhbGlkID0gMDsKICAgICAgfQogICAgICBmdW5jdGlvbiBjb3B5X2Jsb2NrKHMsIGJ1ZiwgbGVuLCBoZWFkZXIpIHsKICAgICAgICBiaV93aW5kdXAocyk7CiAgICAgICAgaWYgKGhlYWRlcikgewogICAgICAgICAgcHV0X3Nob3J0KHMsIGxlbik7CiAgICAgICAgICBwdXRfc2hvcnQocywgfmxlbik7CiAgICAgICAgfQogICAgICAgIHV0aWxzLmFycmF5U2V0KHMucGVuZGluZ19idWYsIHMud2luZG93LCBidWYsIGxlbiwgcy5wZW5kaW5nKTsKICAgICAgICBzLnBlbmRpbmcgKz0gbGVuOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIHNtYWxsZXIodHJlZSwgbiwgbSwgZGVwdGgpIHsKICAgICAgICB2YXIgX24yID0gbiAqIDI7CiAgICAgICAgdmFyIF9tMiA9IG0gKiAyOwogICAgICAgIHJldHVybiB0cmVlW19uMl0gPCB0cmVlW19tMl0gfHwgdHJlZVtfbjJdID09PSB0cmVlW19tMl0gJiYgZGVwdGhbbl0gPD0gZGVwdGhbbV07CiAgICAgIH0KICAgICAgZnVuY3Rpb24gcHFkb3duaGVhcChzLCB0cmVlLCBrKSB7CiAgICAgICAgdmFyIHYgPSBzLmhlYXBba107CiAgICAgICAgdmFyIGogPSBrIDw8IDE7CiAgICAgICAgd2hpbGUgKGogPD0gcy5oZWFwX2xlbikgewogICAgICAgICAgaWYgKGogPCBzLmhlYXBfbGVuICYmIHNtYWxsZXIodHJlZSwgcy5oZWFwW2ogKyAxXSwgcy5oZWFwW2pdLCBzLmRlcHRoKSkgewogICAgICAgICAgICBqKys7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoc21hbGxlcih0cmVlLCB2LCBzLmhlYXBbal0sIHMuZGVwdGgpKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgcy5oZWFwW2tdID0gcy5oZWFwW2pdOwogICAgICAgICAgayA9IGo7CiAgICAgICAgICBqIDw8PSAxOwogICAgICAgIH0KICAgICAgICBzLmhlYXBba10gPSB2OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGNvbXByZXNzX2Jsb2NrKHMsIGx0cmVlLCBkdHJlZSkgewogICAgICAgIHZhciBkaXN0OwogICAgICAgIHZhciBsYzsKICAgICAgICB2YXIgbHggPSAwOwogICAgICAgIHZhciBjb2RlOwogICAgICAgIHZhciBleHRyYTsKICAgICAgICBpZiAocy5sYXN0X2xpdCAhPT0gMCkgewogICAgICAgICAgZG8gewogICAgICAgICAgICBkaXN0ID0gcy5wZW5kaW5nX2J1ZltzLmRfYnVmICsgbHggKiAyXSA8PCA4IHwgcy5wZW5kaW5nX2J1ZltzLmRfYnVmICsgbHggKiAyICsgMV07CiAgICAgICAgICAgIGxjID0gcy5wZW5kaW5nX2J1ZltzLmxfYnVmICsgbHhdOwogICAgICAgICAgICBseCsrOwogICAgICAgICAgICBpZiAoZGlzdCA9PT0gMCkgewogICAgICAgICAgICAgIHNlbmRfY29kZShzLCBsYywgbHRyZWUpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGNvZGUgPSBfbGVuZ3RoX2NvZGVbbGNdOwogICAgICAgICAgICAgIHNlbmRfY29kZShzLCBjb2RlICsgTElURVJBTFMgKyAxLCBsdHJlZSk7CiAgICAgICAgICAgICAgZXh0cmEgPSBleHRyYV9sYml0c1tjb2RlXTsKICAgICAgICAgICAgICBpZiAoZXh0cmEgIT09IDApIHsKICAgICAgICAgICAgICAgIGxjIC09IGJhc2VfbGVuZ3RoW2NvZGVdOwogICAgICAgICAgICAgICAgc2VuZF9iaXRzKHMsIGxjLCBleHRyYSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGRpc3QtLTsKICAgICAgICAgICAgICBjb2RlID0gZF9jb2RlKGRpc3QpOwogICAgICAgICAgICAgIHNlbmRfY29kZShzLCBjb2RlLCBkdHJlZSk7CiAgICAgICAgICAgICAgZXh0cmEgPSBleHRyYV9kYml0c1tjb2RlXTsKICAgICAgICAgICAgICBpZiAoZXh0cmEgIT09IDApIHsKICAgICAgICAgICAgICAgIGRpc3QgLT0gYmFzZV9kaXN0W2NvZGVdOwogICAgICAgICAgICAgICAgc2VuZF9iaXRzKHMsIGRpc3QsIGV4dHJhKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gd2hpbGUgKGx4IDwgcy5sYXN0X2xpdCk7CiAgICAgICAgfQogICAgICAgIHNlbmRfY29kZShzLCBFTkRfQkxPQ0ssIGx0cmVlKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBidWlsZF90cmVlKHMsIGRlc2MpIHsKICAgICAgICB2YXIgdHJlZSA9IGRlc2MuZHluX3RyZWU7CiAgICAgICAgdmFyIHN0cmVlID0gZGVzYy5zdGF0X2Rlc2Muc3RhdGljX3RyZWU7CiAgICAgICAgdmFyIGhhc19zdHJlZSA9IGRlc2Muc3RhdF9kZXNjLmhhc19zdHJlZTsKICAgICAgICB2YXIgZWxlbXMgPSBkZXNjLnN0YXRfZGVzYy5lbGVtczsKICAgICAgICB2YXIgbiwgbTsKICAgICAgICB2YXIgbWF4X2NvZGUgPSAtMTsKICAgICAgICB2YXIgbm9kZTsKICAgICAgICBzLmhlYXBfbGVuID0gMDsKICAgICAgICBzLmhlYXBfbWF4ID0gSEVBUF9TSVpFOwogICAgICAgIGZvciAobiA9IDA7IG4gPCBlbGVtczsgbisrKSB7CiAgICAgICAgICBpZiAodHJlZVtuICogMl0gIT09IDApIHsKICAgICAgICAgICAgcy5oZWFwWysrcy5oZWFwX2xlbl0gPSBtYXhfY29kZSA9IG47CiAgICAgICAgICAgIHMuZGVwdGhbbl0gPSAwOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgdHJlZVtuICogMiArIDFdID0gMDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgd2hpbGUgKHMuaGVhcF9sZW4gPCAyKSB7CiAgICAgICAgICBub2RlID0gcy5oZWFwWysrcy5oZWFwX2xlbl0gPSBtYXhfY29kZSA8IDIgPyArK21heF9jb2RlIDogMDsKICAgICAgICAgIHRyZWVbbm9kZSAqIDJdID0gMTsKICAgICAgICAgIHMuZGVwdGhbbm9kZV0gPSAwOwogICAgICAgICAgcy5vcHRfbGVuLS07CiAgICAgICAgICBpZiAoaGFzX3N0cmVlKSB7CiAgICAgICAgICAgIHMuc3RhdGljX2xlbiAtPSBzdHJlZVtub2RlICogMiArIDFdOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBkZXNjLm1heF9jb2RlID0gbWF4X2NvZGU7CiAgICAgICAgZm9yIChuID0gcy5oZWFwX2xlbiA+PiAxOyBuID49IDE7IG4tLSkgewogICAgICAgICAgcHFkb3duaGVhcChzLCB0cmVlLCBuKTsKICAgICAgICB9CiAgICAgICAgbm9kZSA9IGVsZW1zOwogICAgICAgIGRvIHsKICAgICAgICAgIG4gPSBzLmhlYXBbMV07CiAgICAgICAgICBzLmhlYXBbMV0gPSBzLmhlYXBbcy5oZWFwX2xlbi0tXTsKICAgICAgICAgIHBxZG93bmhlYXAocywgdHJlZSwgMSk7CiAgICAgICAgICBtID0gcy5oZWFwWzFdOwogICAgICAgICAgcy5oZWFwWy0tcy5oZWFwX21heF0gPSBuOwogICAgICAgICAgcy5oZWFwWy0tcy5oZWFwX21heF0gPSBtOwogICAgICAgICAgdHJlZVtub2RlICogMl0gPSB0cmVlW24gKiAyXSArIHRyZWVbbSAqIDJdOwogICAgICAgICAgcy5kZXB0aFtub2RlXSA9IChzLmRlcHRoW25dID49IHMuZGVwdGhbbV0gPyBzLmRlcHRoW25dIDogcy5kZXB0aFttXSkgKyAxOwogICAgICAgICAgdHJlZVtuICogMiArIDFdID0gdHJlZVttICogMiArIDFdID0gbm9kZTsKICAgICAgICAgIHMuaGVhcFsxXSA9IG5vZGUrKzsKICAgICAgICAgIHBxZG93bmhlYXAocywgdHJlZSwgMSk7CiAgICAgICAgfSB3aGlsZSAocy5oZWFwX2xlbiA+PSAyKTsKICAgICAgICBzLmhlYXBbLS1zLmhlYXBfbWF4XSA9IHMuaGVhcFsxXTsKICAgICAgICBnZW5fYml0bGVuKHMsIGRlc2MpOwogICAgICAgIGdlbl9jb2Rlcyh0cmVlLCBtYXhfY29kZSwgcy5ibF9jb3VudCk7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gc2Nhbl90cmVlKHMsIHRyZWUsIG1heF9jb2RlKSB7CiAgICAgICAgdmFyIG47CiAgICAgICAgdmFyIHByZXZsZW4gPSAtMTsKICAgICAgICB2YXIgY3VybGVuOwogICAgICAgIHZhciBuZXh0bGVuID0gdHJlZVswICogMiArIDFdOwogICAgICAgIHZhciBjb3VudCA9IDA7CiAgICAgICAgdmFyIG1heF9jb3VudCA9IDc7CiAgICAgICAgdmFyIG1pbl9jb3VudCA9IDQ7CiAgICAgICAgaWYgKG5leHRsZW4gPT09IDApIHsKICAgICAgICAgIG1heF9jb3VudCA9IDEzODsKICAgICAgICAgIG1pbl9jb3VudCA9IDM7CiAgICAgICAgfQogICAgICAgIHRyZWVbKG1heF9jb2RlICsgMSkgKiAyICsgMV0gPSA2NTUzNTsKICAgICAgICBmb3IgKG4gPSAwOyBuIDw9IG1heF9jb2RlOyBuKyspIHsKICAgICAgICAgIGN1cmxlbiA9IG5leHRsZW47CiAgICAgICAgICBuZXh0bGVuID0gdHJlZVsobiArIDEpICogMiArIDFdOwogICAgICAgICAgaWYgKCsrY291bnQgPCBtYXhfY291bnQgJiYgY3VybGVuID09PSBuZXh0bGVuKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfSBlbHNlIGlmIChjb3VudCA8IG1pbl9jb3VudCkgewogICAgICAgICAgICBzLmJsX3RyZWVbY3VybGVuICogMl0gKz0gY291bnQ7CiAgICAgICAgICB9IGVsc2UgaWYgKGN1cmxlbiAhPT0gMCkgewogICAgICAgICAgICBpZiAoY3VybGVuICE9PSBwcmV2bGVuKSB7CiAgICAgICAgICAgICAgcy5ibF90cmVlW2N1cmxlbiAqIDJdKys7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcy5ibF90cmVlW1JFUF8zXzYgKiAyXSsrOwogICAgICAgICAgfSBlbHNlIGlmIChjb3VudCA8PSAxMCkgewogICAgICAgICAgICBzLmJsX3RyZWVbUkVQWl8zXzEwICogMl0rKzsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHMuYmxfdHJlZVtSRVBaXzExXzEzOCAqIDJdKys7CiAgICAgICAgICB9CiAgICAgICAgICBjb3VudCA9IDA7CiAgICAgICAgICBwcmV2bGVuID0gY3VybGVuOwogICAgICAgICAgaWYgKG5leHRsZW4gPT09IDApIHsKICAgICAgICAgICAgbWF4X2NvdW50ID0gMTM4OwogICAgICAgICAgICBtaW5fY291bnQgPSAzOwogICAgICAgICAgfSBlbHNlIGlmIChjdXJsZW4gPT09IG5leHRsZW4pIHsKICAgICAgICAgICAgbWF4X2NvdW50ID0gNjsKICAgICAgICAgICAgbWluX2NvdW50ID0gMzsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIG1heF9jb3VudCA9IDc7CiAgICAgICAgICAgIG1pbl9jb3VudCA9IDQ7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIGZ1bmN0aW9uIHNlbmRfdHJlZShzLCB0cmVlLCBtYXhfY29kZSkgewogICAgICAgIHZhciBuOwogICAgICAgIHZhciBwcmV2bGVuID0gLTE7CiAgICAgICAgdmFyIGN1cmxlbjsKICAgICAgICB2YXIgbmV4dGxlbiA9IHRyZWVbMCAqIDIgKyAxXTsKICAgICAgICB2YXIgY291bnQgPSAwOwogICAgICAgIHZhciBtYXhfY291bnQgPSA3OwogICAgICAgIHZhciBtaW5fY291bnQgPSA0OwogICAgICAgIGlmIChuZXh0bGVuID09PSAwKSB7CiAgICAgICAgICBtYXhfY291bnQgPSAxMzg7CiAgICAgICAgICBtaW5fY291bnQgPSAzOwogICAgICAgIH0KICAgICAgICBmb3IgKG4gPSAwOyBuIDw9IG1heF9jb2RlOyBuKyspIHsKICAgICAgICAgIGN1cmxlbiA9IG5leHRsZW47CiAgICAgICAgICBuZXh0bGVuID0gdHJlZVsobiArIDEpICogMiArIDFdOwogICAgICAgICAgaWYgKCsrY291bnQgPCBtYXhfY291bnQgJiYgY3VybGVuID09PSBuZXh0bGVuKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfSBlbHNlIGlmIChjb3VudCA8IG1pbl9jb3VudCkgewogICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgc2VuZF9jb2RlKHMsIGN1cmxlbiwgcy5ibF90cmVlKTsKICAgICAgICAgICAgfSB3aGlsZSAoLS1jb3VudCAhPT0gMCk7CiAgICAgICAgICB9IGVsc2UgaWYgKGN1cmxlbiAhPT0gMCkgewogICAgICAgICAgICBpZiAoY3VybGVuICE9PSBwcmV2bGVuKSB7CiAgICAgICAgICAgICAgc2VuZF9jb2RlKHMsIGN1cmxlbiwgcy5ibF90cmVlKTsKICAgICAgICAgICAgICBjb3VudC0tOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHNlbmRfY29kZShzLCBSRVBfM182LCBzLmJsX3RyZWUpOwogICAgICAgICAgICBzZW5kX2JpdHMocywgY291bnQgLSAzLCAyKTsKICAgICAgICAgIH0gZWxzZSBpZiAoY291bnQgPD0gMTApIHsKICAgICAgICAgICAgc2VuZF9jb2RlKHMsIFJFUFpfM18xMCwgcy5ibF90cmVlKTsKICAgICAgICAgICAgc2VuZF9iaXRzKHMsIGNvdW50IC0gMywgMyk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzZW5kX2NvZGUocywgUkVQWl8xMV8xMzgsIHMuYmxfdHJlZSk7CiAgICAgICAgICAgIHNlbmRfYml0cyhzLCBjb3VudCAtIDExLCA3KTsKICAgICAgICAgIH0KICAgICAgICAgIGNvdW50ID0gMDsKICAgICAgICAgIHByZXZsZW4gPSBjdXJsZW47CiAgICAgICAgICBpZiAobmV4dGxlbiA9PT0gMCkgewogICAgICAgICAgICBtYXhfY291bnQgPSAxMzg7CiAgICAgICAgICAgIG1pbl9jb3VudCA9IDM7CiAgICAgICAgICB9IGVsc2UgaWYgKGN1cmxlbiA9PT0gbmV4dGxlbikgewogICAgICAgICAgICBtYXhfY291bnQgPSA2OwogICAgICAgICAgICBtaW5fY291bnQgPSAzOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgbWF4X2NvdW50ID0gNzsKICAgICAgICAgICAgbWluX2NvdW50ID0gNDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgZnVuY3Rpb24gYnVpbGRfYmxfdHJlZShzKSB7CiAgICAgICAgdmFyIG1heF9ibGluZGV4OwogICAgICAgIHNjYW5fdHJlZShzLCBzLmR5bl9sdHJlZSwgcy5sX2Rlc2MubWF4X2NvZGUpOwogICAgICAgIHNjYW5fdHJlZShzLCBzLmR5bl9kdHJlZSwgcy5kX2Rlc2MubWF4X2NvZGUpOwogICAgICAgIGJ1aWxkX3RyZWUocywgcy5ibF9kZXNjKTsKICAgICAgICBmb3IgKG1heF9ibGluZGV4ID0gQkxfQ09ERVMgLSAxOyBtYXhfYmxpbmRleCA+PSAzOyBtYXhfYmxpbmRleC0tKSB7CiAgICAgICAgICBpZiAocy5ibF90cmVlW2JsX29yZGVyW21heF9ibGluZGV4XSAqIDIgKyAxXSAhPT0gMCkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcy5vcHRfbGVuICs9IDMgKiAobWF4X2JsaW5kZXggKyAxKSArIDUgKyA1ICsgNDsKICAgICAgICByZXR1cm4gbWF4X2JsaW5kZXg7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gc2VuZF9hbGxfdHJlZXMocywgbGNvZGVzLCBkY29kZXMsIGJsY29kZXMpIHsKICAgICAgICB2YXIgcmFuazsKICAgICAgICBzZW5kX2JpdHMocywgbGNvZGVzIC0gMjU3LCA1KTsKICAgICAgICBzZW5kX2JpdHMocywgZGNvZGVzIC0gMSwgNSk7CiAgICAgICAgc2VuZF9iaXRzKHMsIGJsY29kZXMgLSA0LCA0KTsKICAgICAgICBmb3IgKHJhbmsgPSAwOyByYW5rIDwgYmxjb2RlczsgcmFuaysrKSB7CiAgICAgICAgICBzZW5kX2JpdHMocywgcy5ibF90cmVlW2JsX29yZGVyW3JhbmtdICogMiArIDFdLCAzKTsKICAgICAgICB9CiAgICAgICAgc2VuZF90cmVlKHMsIHMuZHluX2x0cmVlLCBsY29kZXMgLSAxKTsKICAgICAgICBzZW5kX3RyZWUocywgcy5keW5fZHRyZWUsIGRjb2RlcyAtIDEpOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRldGVjdF9kYXRhX3R5cGUocykgewogICAgICAgIHZhciBibGFja19tYXNrID0gNDA5MzYyNDQ0NzsKICAgICAgICB2YXIgbjsKICAgICAgICBmb3IgKG4gPSAwOyBuIDw9IDMxOyBuKyssIGJsYWNrX21hc2sgPj4+PSAxKSB7CiAgICAgICAgICBpZiAoYmxhY2tfbWFzayAmIDEgJiYgcy5keW5fbHRyZWVbbiAqIDJdICE9PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBaX0JJTkFSWTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHMuZHluX2x0cmVlWzkgKiAyXSAhPT0gMCB8fCBzLmR5bl9sdHJlZVsxMCAqIDJdICE9PSAwIHx8IHMuZHluX2x0cmVlWzEzICogMl0gIT09IDApIHsKICAgICAgICAgIHJldHVybiBaX1RFWFQ7CiAgICAgICAgfQogICAgICAgIGZvciAobiA9IDMyOyBuIDwgTElURVJBTFM7IG4rKykgewogICAgICAgICAgaWYgKHMuZHluX2x0cmVlW24gKiAyXSAhPT0gMCkgewogICAgICAgICAgICByZXR1cm4gWl9URVhUOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gWl9CSU5BUlk7CiAgICAgIH0KICAgICAgdmFyIHN0YXRpY19pbml0X2RvbmUgPSBmYWxzZTsKICAgICAgZnVuY3Rpb24gX3RyX2luaXQocykgewogICAgICAgIGlmICghc3RhdGljX2luaXRfZG9uZSkgewogICAgICAgICAgdHJfc3RhdGljX2luaXQoKTsKICAgICAgICAgIHN0YXRpY19pbml0X2RvbmUgPSB0cnVlOwogICAgICAgIH0KICAgICAgICBzLmxfZGVzYyA9IG5ldyBUcmVlRGVzYyhzLmR5bl9sdHJlZSwgc3RhdGljX2xfZGVzYyk7CiAgICAgICAgcy5kX2Rlc2MgPSBuZXcgVHJlZURlc2Mocy5keW5fZHRyZWUsIHN0YXRpY19kX2Rlc2MpOwogICAgICAgIHMuYmxfZGVzYyA9IG5ldyBUcmVlRGVzYyhzLmJsX3RyZWUsIHN0YXRpY19ibF9kZXNjKTsKICAgICAgICBzLmJpX2J1ZiA9IDA7CiAgICAgICAgcy5iaV92YWxpZCA9IDA7CiAgICAgICAgaW5pdF9ibG9jayhzKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBfdHJfc3RvcmVkX2Jsb2NrKHMsIGJ1Ziwgc3RvcmVkX2xlbiwgbGFzdCkgewogICAgICAgIHNlbmRfYml0cyhzLCAoU1RPUkVEX0JMT0NLIDw8IDEpICsgKGxhc3QgPyAxIDogMCksIDMpOwogICAgICAgIGNvcHlfYmxvY2socywgYnVmLCBzdG9yZWRfbGVuLCB0cnVlKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBfdHJfYWxpZ24ocykgewogICAgICAgIHNlbmRfYml0cyhzLCBTVEFUSUNfVFJFRVMgPDwgMSwgMyk7CiAgICAgICAgc2VuZF9jb2RlKHMsIEVORF9CTE9DSywgc3RhdGljX2x0cmVlKTsKICAgICAgICBiaV9mbHVzaChzKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBfdHJfZmx1c2hfYmxvY2socywgYnVmLCBzdG9yZWRfbGVuLCBsYXN0KSB7CiAgICAgICAgdmFyIG9wdF9sZW5iLCBzdGF0aWNfbGVuYjsKICAgICAgICB2YXIgbWF4X2JsaW5kZXggPSAwOwogICAgICAgIGlmIChzLmxldmVsID4gMCkgewogICAgICAgICAgaWYgKHMuc3RybS5kYXRhX3R5cGUgPT09IFpfVU5LTk9XTikgewogICAgICAgICAgICBzLnN0cm0uZGF0YV90eXBlID0gZGV0ZWN0X2RhdGFfdHlwZShzKTsKICAgICAgICAgIH0KICAgICAgICAgIGJ1aWxkX3RyZWUocywgcy5sX2Rlc2MpOwogICAgICAgICAgYnVpbGRfdHJlZShzLCBzLmRfZGVzYyk7CiAgICAgICAgICBtYXhfYmxpbmRleCA9IGJ1aWxkX2JsX3RyZWUocyk7CiAgICAgICAgICBvcHRfbGVuYiA9IHMub3B0X2xlbiArIDMgKyA3ID4+PiAzOwogICAgICAgICAgc3RhdGljX2xlbmIgPSBzLnN0YXRpY19sZW4gKyAzICsgNyA+Pj4gMzsKICAgICAgICAgIGlmIChzdGF0aWNfbGVuYiA8PSBvcHRfbGVuYikgewogICAgICAgICAgICBvcHRfbGVuYiA9IHN0YXRpY19sZW5iOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBvcHRfbGVuYiA9IHN0YXRpY19sZW5iID0gc3RvcmVkX2xlbiArIDU7CiAgICAgICAgfQogICAgICAgIGlmIChzdG9yZWRfbGVuICsgNCA8PSBvcHRfbGVuYiAmJiBidWYgIT09IC0xKSB7CiAgICAgICAgICBfdHJfc3RvcmVkX2Jsb2Nr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ogbGVuOwogICAgICAgICAgbGVuIC09IG47CiAgICAgICAgICBkbyB7CiAgICAgICAgICAgIHMxID0gczEgKyBidWZbcG9zKytdIHwgMDsKICAgICAgICAgICAgczIgPSBzMiArIHMxIHwgMDsKICAgICAgICAgIH0gd2hpbGUgKC0tbik7CiAgICAgICAgICBzMSAlPSA2NTUyMTsKICAgICAgICAgIHMyICU9IDY1NTIxOwogICAgICAgIH0KICAgICAgICByZXR1cm4gczEgfCBzMiA8PCAxNiB8IDA7CiAgICAgIH0KICAgICAgbW9kdWxlMi5leHBvcnRzID0gYWRsZXIzMjsKICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvY3JjMzIuanMKICB2YXIgcmVxdWlyZV9jcmMzMiA9IF9fY29tbW9uSlMoewogICAgIm5vZGVfbW9kdWxlcy9wYWtvL2xpYi96bGliL2NyYzMyLmpzIihleHBvcnRzMiwgbW9kdWxlMikgewogICAgICBpbml0X2J1ZmZlcl9zaGltKCk7CiAgICAgICJ1c2Ugc3RyaWN0IjsKICAgICAgZnVuY3Rpb24gbWFrZVRhYmxlKCkgewogICAgICAgIHZhciBjLCB0YWJsZSA9IFtdOwogICAgICAgIGZvciAodmFyIG4gPSAwOyBuIDwgMjU2OyBuKyspIHsKICAgICAgICAgIGMgPSBuOwogICAgICAgICAgZm9yICh2YXIgayA9IDA7IGsgPCA4OyBrKyspIHsKICAgICAgICAgICAgYyA9IGMgJiAxID8gMzk4ODI5MjM4NCBeIGMgPj4+IDEgOiBjID4+PiAxOwogICAgICAgICAgfQogICAgICAgICAgdGFibGVbbl0gPSBjOwogICAgICAgIH0KICAgICAgICByZXR1cm4gdGFibGU7CiAgICAgIH0KICAgICAgdmFyIGNyY1RhYmxlID0gbWFrZVRhYmxlKCk7CiAgICAgIGZ1bmN0aW9uIGNyYzMyKGNyYywgYnVmLCBsZW4sIHBvcykgewogICAgICAgIHZhciB0ID0gY3JjVGFibGUsIGVuZCA9IHBvcyArIGxlbjsKICAgICAgICBjcmMgXj0gLTE7CiAgICAgICAgZm9yICh2YXIgaSA9IHBvczsgaSA8IGVuZDsgaSsrKSB7CiAgICAgICAgICBjcmMgPSBjcmMgPj4+IDggXiB0WyhjcmMgXiBidWZbaV0pICYgMjU1XTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGNyYyBeIC0xOwogICAgICB9CiAgICAgIG1vZHVsZTIuZXhwb3J0cyA9IGNyYzMyOwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvcGFrby9saWIvemxpYi9tZXNzYWdlcy5qcwogIHZhciByZXF1aXJlX21lc3NhZ2VzID0gX19jb21tb25KUyh7CiAgICAibm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvbWVzc2FnZXMuanMiKGV4cG9ydHMyLCBtb2R1bGUyKSB7CiAgICAgIGluaXRfYnVmZmVyX3NoaW0oKTsKICAgICAgInVzZSBzdHJpY3QiOwogICAgICBtb2R1bGUyLmV4cG9ydHMgPSB7CiAgICAgICAgMjogIm5lZWQgZGljdGlvbmFyeSIsCiAgICAgICAgMTogInN0cmVhbSBlbmQiLAogICAgICAgIDA6ICIiLAogICAgICAgICItMSI6ICJmaWxlIGVycm9yIiwKICAgICAgICAiLTIiOiAic3RyZWFtIGVycm9yIiwKICAgICAgICAiLTMiOiAiZGF0YSBlcnJvciIsCiAgICAgICAgIi00IjogImluc3VmZmljaWVudCBtZW1vcnkiLAogICAgICAgICItNSI6ICJidWZmZXIgZXJyb3IiLAogICAgICAgICItNiI6ICJpbmNvbXBhdGlibGUgdmVyc2lvbiIKICAgICAgfTsKICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvZGVmbGF0ZS5qcwogIHZhciByZXF1aXJlX2RlZmxhdGUgPSBfX2NvbW1vbkpTKHsKICAgICJub2RlX21vZHVsZXMvcGFrby9saWIvemxpYi9kZWZsYXRlLmpzIihleHBvcnRzMikgewogICAgICBpbml0X2J1Zm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9wZW5kaW5nKHMuc3RybSk7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gcHV0X2J5dGUocywgYikgewogICAgICAgIHMucGVuZGluZ19idWZbcy5wZW5kaW5nKytdID0gYjsKICAgICAgfQogICAgICBmdW5jdGlvbiBwdXRTaG9ydE1TQihzLCBiKSB7CiAgICAgICAgcy5wZW5kaW5nX2J1ZltzLnBlbmRpbmcrK10gPSBiID4+PiA4ICYgMjU1OwogICAgICAgIHMucGVuZGluZ19idWZbcy5wZW5kaW5nKytdID0gYiAmIDI1NTsKICAgICAgfQogICAgICBmdW5jdGlvbiByZWFkX2J1ZihzdHJtLCBidWYsIHN0YXJ0LCBzaXplKSB7CiAgICAgICAgdmFyIGxlbiA9IHN0cm0uYXZhaWxfaW47CiAgICAgICAgaWYgKGxlbiA+IHNpemUpIHsKICAgICAgICAgIGxlbiA9IHNpemU7CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gPT09IDApIHsKICAgICAgICAgIHJldHVybiAwOwogICAgICAgIH0KICAgICAgICBzdHJtLmF2YWlsX2luIC09IGxlbjsKICAgICAgICB1dGlscy5hcnJheVNldChidWYsIHN0cm0uaW5wdXQsIHN0cm0ubmV4dF9pbiwgbGVuLCBzdGFydCk7CiAgICAgICAgaWYgKHN0cm0uc3RhdGUud3JhcCA9PT0gMSkgewogICAgICAgICAgc3RybS5hZGxlciA9IGFkbGVyMzIoc3RybS5hZGxlciwgYnVmLCBsZW4sIHN0YXJ0KTsKICAgICAgICB9IGVsc2UgaWYgKHN0cm0uc3RhdGUud3JhcCA9PT0gMikgewogICAgICAgICAgc3RybS5hZGxlciA9IGNyYzMyKHN0cm0uYWRsZXIsIGJ1ZiwgbGVuLCBzdGFydCk7CiAgICAgICAgfQogICAgICAgIHN0cm0ubmV4dF9pbiArPSBsZW47CiAgICAgICAgc3RybS50b3RhbF9pbiArPSBsZW47CiAgICAgICAgcmV0dXJuIGxlbjsKICAgICAgfQogICAgICBmdW5jdGlvbiBsb25nZXN0X21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YW5fZW5kMSB8fCBfd2luW21hdGNoXSAhPT0gX3dpbltzY2FuXSB8fCBfd2luWysrbWF0Y2hdICE9PSBfd2luW3NjYW4gKyAxXSkgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHNjYW4gKz0gMjsKICAgICAgICAgIG1hdGNoKys7CiAgICAgICAgICBkbyB7CiAgICAgICAgICB9IHdoaWxlIChfd2luWysrc2Nhbl0gPT09IF93aW5bKyttYXRjaF0gJiYgX3dpblsrK3NjYW5dID09PSBfd2luWysrbWF0Y2hdICYmIF93aW5bKytzY2FuXSA9PT0gX3dpblsrK21hdGNoXSAmJiBfd2luWysrc2Nhbl0gPT09IF93aW5bKyttYXRjaF0gJiYgX3dpblsrK3NjYW5dID09PSBfd2luWysrbWF0Y2hdICYmIF93aW5bKytzY2FuXSA9PT0gX3dpblsrK21hdGNoXSAmJiBfd2luWysrc2Nhbl0gPT09IF93aW5bKyttYXRjaF0gJiYgX3dpblsrK3NjYW5dID09PSBfd2luWysrbWF0Y2hdICYmIHNjYW4gPCBzdHJlbmQpOwogICAgICAgICAgbGVuID0gTUFYX01BVENIIC0gKHN0cmVuZCAtIHNjYW4pOwogICAgICAgICAgc2NhbiA9IHN0cmVuZCAtIE1BWF9NQVRDSDsKICAgICAgICAgIGlmIChsZW4gPiBiZXN0X2xlbikgewogICAgICAgICAgICBzLm1hdGNoX3N0YXJ0ID0gY3VyX21hdGNoOwogICAgICAgICAgICBiZXN0X2xlbiA9IGxlbjsKICAgICAgICAgICAgaWYgKGxlbiA+PSBuaWNlX21hdGNoKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc2Nhbl9lbmQxID0gX3dpbltzY2FuICsgYmVzdF9sZW4gLSAxXTsKICAgICAgICAgICAgc2Nhbl9lbmQgPSBfd2luW3NjYW4gKyBiZXN0X2xlbl07CiAgICAgICAgICB9CiAgICAgICAgfSB3aGlsZSAoKGN1cl9tYXRjaCA9IHByZXZbY3VyX21hdGNoICYgd21hc2tdKSA+IGxpbWl0ICYmIC0tY2hhaW5fbGVuZ3RoICE9PSAwKTsKICAgICAgICBpZiAoYmVzdF9sZW4gPD0gcy5sb29rYWhlYWQpIHsKICAgICAgICAgIHJldHVybiBiZXN0X2xlbjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHMubG9va2FoZWFkOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGZpbGxfd2luZG93KHMpIHsKICAgICAgICB2YXIgX3dfc2l6ZSA9IHMud19zaXplOwogICAgICAgIHZhciBwLCBuLCBtLCBtb3JlLCBzdHI7CiAgICAgICAgZG8gewogICAgICAgICAgbW9yZSA9IHMud2luZG93X3NpemUgLSBzLmxvb2thaGVhZCAtIHMuc3Ryc3RhcnQ7CiAgICAgICAgICBpZiAocy5zdHJzdGFydCA+PSBfd19zaXplICsgKF93X3NpemUgLSBNSU5fTE9PS0FIRUFEKSkgewogICAgICAgICAgICB1dGlscy5hcnJheVNldChzLndpbmRvdywgcy53aW5kb3csIF93X3NpemUsIF93X3NpemUsIDApOwogICAgICAgICAgICBzLm1hdGNoX3N0YXJ0IC09IF93X3NpemU7CiAgICAgICAgICAgIHMuc3Ryc3RhcnQgLT0gX3dfc2l6ZTsKICAgICAgICAgICAgcy5ibG9ja19zdGFydCAtPSBfd19zaXplOwogICAgICAgICAgICBuID0gcy5oYXNoX3NpemU7CiAgICAgICAgICAgIHAgPSBuOwogICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgbSA9IHMuaGVhZFstLXBdOwogICAgICAgICAgICAgIHMuaGVhZFtwXSA9IG0gPj0gX3dfc2l6ZSA/IG0gLSBfd19zaXplIDogMDsKICAgICAgICAgICAgfSB3aGlsZSAoLS1uKTsKICAgICAgICAgICAgbiA9IF93X3NpemU7CiAgICAgICAgICAgIHAgPSBuOwogICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgbSA9IHMucHJldlstLXBdOwogICAgICAgICAgICAgIHMucHJldltwXSA9IG0gPj0gX3dfc2l6ZSA/IG0gLSBfd19zaXplIDogMDsKICAgICAgICAgICAgfSB3aGlsZSAoLS1uKTsKICAgICAgICAgICAgbW9yZSArPSBfd19zaXplOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9pbiA9PT0gMCkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIG4gPSByZWFkX2J1ZihzLnN0cm0sIHMud2luZG93LCBzLnN0cnN0YXJ0ICsgcy5sb29rYWhlYWQsIG1vcmUpOwogICAgICAgICAgcy5sb29rYWhlYWQgKz0gbjsKICAgICAgICAgIGlmIChzLmxvb2thaGVhZCArIHMuaW5zZXJ0ID49IE1JTl9NQVRDSCkgewogICAgICAgICAgICBzdHIgPSBzLnN0cnN0YXJ0IC0gcy5pbnNlcnQ7CiAgICAgICAgICAgIHMuaW5zX2ggPSBzLndpbmRvd1tzdHJdOwogICAgICAgICAgICBzLmluc19oID0gKHMuaW5zX2ggPDwgcy5oYXNoX3NoaWZ0IF4gcy53aW5kb3dbc3RyICsgMV0pICYgcy5oYXNoX21hc2s7CiAgICAgICAgICAgIHdoaWxlIChzLmluc2VydCkgewogICAgICAgICAgICAgIHMuaW5zX2ggPSAocy5pbnNfaCA8PCBzLmhhc2hfc2hpZnQgXiBzLndpbmRvd1tzdHIgKyBNSU5fTUFUQ0ggLSAxXSkgJiBzLmhhc2hfbWFzazsKICAgICAgICAgICAgICBzLnByZXZbc3RyICYgcy53X21hc2tdID0gcy5oZWFkW3MuaW5zX2hdOwogICAgICAgICAgICAgIHMuaGVhZFtzLmluc19oXSA9IHN0cjsKICAgICAgICAgICAgICBzdHIrKzsKICAgICAgICAgICAgICBzLmluc2VydC0tOwogICAgICAgICAgICAgIGlmIChzLmxvb2thaGVhZCArIHMuaW5zZXJ0IDwgTUlOX01BVENIKSB7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9IHdoaWxlIChzLmxvb2thaGVhZCA8IE1JTl9MT09LQUhFQUQgJiYgcy5zdHJtLmF2YWlsX2luICE9PSAwKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBkZWZsYXRlX3N0b3JlZChzLCBmbHVzaCkgewogICAgICAgIHZhciBtYXhfYmxvY2tfc2l6ZSA9IDY1NTM1OwogICAgICAgIGlmIChtYXhfYmxvY2tfc2l6ZSA+IHMucGVuZGluZ19idWZfc2l6ZSAtIDUpIHsKICAgICAgICAgIG1heF9ibG9ja19zaXplID0gcy5wZW5kaW5nX2J1Zl9zaXplIC0gNTsKICAgICAgICB9CiAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICBpZiAocy5sb29rYWhlYWQgPD0gMSkgewogICAgICAgICAgICBmaWxsX3dpbmRvdyhzKTsKICAgICAgICAgICAgaWYgKHMubG9va2FoZWFkID09PSAwICYmIGZsdXNoID09PSBaX05PX0ZMVVNIKSB7CiAgICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAocy5sb29rYWhlYWQgPT09IDApIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgcy5zdHJzdGFydCArPSBzLmxvb2thaGVhZDsKICAgICAgICAgIHMubG9va2FoZWFkID0gMDsKICAgICAgICAgIHZhciBtYXhfc3RhcnQgPSBzLmJsb2NrX3N0YXJ0ICsgbWF4X2Jsb2NrX3NpemU7CiAgICAgICAgICBpZiAocy5zdHJzdGFydCA9PT0gMCB8fCBzLnN0cnN0YXJ0ID49IG1heF9zdGFydCkgewogICAgICAgICAgICBzLmxvb2thaGVhZCA9IHMuc3Ryc3RhcnQgLSBtYXhfc3RhcnQ7CiAgICAgICAgICAgIHMuc3Ryc3RhcnQgPSBtYXhfc3RhcnQ7CiAgICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgZmFsc2UpOwogICAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzLnN0cnN0YXJ0IC0gcy5ibG9ja19zdGFydCA+PSBzLndfc2l6ZSAtIE1JTl9MT09LQUhFQUQpIHsKICAgICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCBmYWxzZSk7CiAgICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBzLmluc2VydCA9IDA7CiAgICAgICAgaWYgKGZsdXNoID09PSBaX0ZJTklTSCkgewogICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCB0cnVlKTsKICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBCU19GSU5JU0hfU1RBUlRFRDsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBCU19GSU5JU0hfRE9ORTsKICAgICAgICB9CiAgICAgICAgaWYgKHMuc3Ryc3RhcnQgPiBzLmJsb2NrX3N0YXJ0KSB7CiAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIGZhbHNlKTsKICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZGVmbGF0ZV9mYXN0KHMsIGZsdXNoKSB7CiAgICAgICAgdmFyIGhhc2hfaGVhZDsKICAgICAgICB2YXIgYmZsdXNoOwogICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgaWYgKHMubG9va2FoZWFkIDwgTUlOX0xPT0tBSEVBRCkgewogICAgICAgICAgICBmaWxsX3dpbmRvdyhzKTsKICAgICAgICAgICAgaWYgKHMubG9va2FoZWFkIDwgTUlOX0xPT0tBSEVBRCAmJiBmbHVzaCA9PT0gWl9OT19GTFVTSCkgewogICAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHMubG9va2FoZWFkID09PSAwKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGhhc2hfaGVhZCA9IDA7CiAgICAgICAgICBpZiAocy5sb29rYWhlYWQgPj0gTUlOX01BVENIKSB7CiAgICAgICAgICAgIHMuaW5zX2ggPSAocy5pbnNfaCA8PCBzLmhhc2hfc2hpZnQgXiBzLndpbmRvd1tzLnN0cnN0YXJ0ICsgTUlOX01BVENIIC0gMV0pICYgcy5oYXNoX21hc2s7CiAgICAgICAgICAgIGhhc2hfaGVhZCA9IHMucHJldltzLnN0cnN0YXJ0ICYgcy53X21hc2tdID0gcy5oZWFkW3MuaW5zX2hdOwogICAgICAgICAgICBzLmhlYWRbcy5pbnNfaF0gPSBzLnN0cnN0YXJ0OwogICAgICAgICAgfQogICAgICAgICAgaWYgKGhhc2hfaGVhZCAhPT0gMCAmJiBzLnN0cnN0YXJ0IC0gaGFzaF9oZWFkIDw9IHMud19zaXplIC0gTUlOX0xPT0tBSEVBRCkgewogICAgICAgICAgICBzLm1hdGNoX2xlbmd0aCA9IGxvbmdlc3RfbWF0Y2gocywgaGFzaF9oZWFkKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChzLm1hdGNoX2xlbmd0aCA+PSBNSU5fTUFUQ0gpIHsKICAgICAgICAgICAgYmZsdXNoID0gdHJlZXMuX3RyX3RhbGx5KHMsIHMuc3Ryc3RhcnQgLSBzLm1hdGNoX3N0YXJ0LCBzLm1hdGNoX2xlbmd0aCAtIE1JTl9NQVRDSCk7CiAgICAgICAgICAgIHMubG9va2FoZWFkIC09IHMubWF0Y2hfbGVuZ3RoOwogICAgICAgICAgICBpZiAocy5tYXRjaF9sZW5ndGggPD0gcy5tYXhfbGF6eV9tYXRjaCAmJiBzLmxvb2thaGVhZCA+PSBNSU5fTUFUQ0gpIHsKICAgICAgICAgICAgICBzLm1hdGNoX2xlbmd0aC0tOwogICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgIHMuc3Ryc3RhcnQrKzsKICAgICAgICAgICAgICAgIHMuaW5zX2ggPSAocy5pbnNfaCA8PCBzLmhhc2hfc2hpZnQgXiBzLndpbmRvd1tzLnN0cnN0YXJ0ICsgTUlOX01BVENIIC0gMV0pICYgcy5oYXNoX21hc2s7CiAgICAgICAgICAgICAgICBoYXNoX2hlYWQgPSBzLnByZXZbcy5zdHJzdGFydCAmIHMud19tYXNrXSA9IHMuaGVhZFtzLmluc19oXTsKICAgICAgICAgICAgICAgIHMuaGVhZFtzLmluc19oXSA9IHMuc3Ryc3RhcnQ7CiAgICAgICAgICAgICAgfSB3aGlsZSAoLS1zLm1hdGNoX2xlbmd0aCAhPT0gMCk7CiAgICAgICAgICAgICAgcy5zdHJzdGFydCsrOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHMuc3Ryc3RhcnQgKz0gcy5tYXRjaF9sZW5ndGg7CiAgICAgICAgICAgICAgcy5tYXRjaF9sZW5ndGggPSAwOwogICAgICAgICAgICAgIHMuaW5zX2ggPSBzLndpbmRvd1tzLnN0cnN0YXJ0XTsKICAgICAgICAgICAgICBzLmluc19oID0gKHMuaW5zX2ggPDwgcy5oYXNoX3NoaWZ0IF4gcy53aW5kb3dbcy5zdHJzdGFydCArIDFdKSAmIHMuaGFzaF9tYXNrOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBiZmx1c2ggPSB0cmVlcy5fdHJfdGFsbHkocywgMCwgcy53aW5kb3dbcy5zdHJzdGFydF0pOwogICAgICAgICAgICBzLmxvb2thaGVhZC0tOwogICAgICAgICAgICBzLnN0cnN0YXJ0Kys7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYmZsdXNoKSB7CiAgICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgZmFsc2UpOwogICAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcy5pbnNlcnQgPSBzLnN0cnN0YXJ0IDwgTUlOX01BVENIIC0gMSA/IHMuc3Ryc3RhcnQgOiBNSU5fTUFUQ0ggLSAxOwogICAgICAgIGlmIChmbHVzaCA9PT0gWl9GSU5JU0gpIHsKICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgdHJ1ZSk7CiAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICByZXR1cm4gQlNfRklOSVNIX1NUQVJURUQ7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gQlNfRklOSVNIX0RPTkU7CiAgICAgICAgfQogICAgICAgIGlmIChzLmxhc3RfbGl0KSB7CiAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIGZhbHNlKTsKICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiBCU19CTE9DS19ET05FOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRlZmxhdGVfc2xvdyhzLCBmbHVzaCkgewogICAgICAgIHZhciBoYXNoX2hlYWQ7CiAgICAgICAgdmFyIGJmbHVzaDsKICAgICAgICB2YXIgbWF4X2luc2VydDsKICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA8IE1JTl9MT09LQUhFQUQpIHsKICAgICAgICAgICAgZmlsbF93aW5kb3cocyk7CiAgICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA8IE1JTl9MT09LQUhFQUQgJiYgZmx1c2ggPT09IFpfTk9fRkxVU0gpIHsKICAgICAgICAgICAgICByZXR1cm4gQlNfTkVFRF9NT1JFOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA9PT0gMCkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBoYXNoX2hlYWQgPSAwOwogICAgICAgICAgaWYgKHMubG9va2FoZWFkID49IE1JTl9NQVRDSCkgewogICAgICAgICAgICBzLmluc19oID0gKHMuaW5zX2ggPDwgcy5oYXNoX3NoaWZ0IF4gcy53aW5kb3dbcy5zdHJzdGFydCArIE1JTl9NQVRDSCAtIDFdKSAmIHMuaGFzaF9tYXNrOwogICAgICAgICAgICBoYXNoX2hlYWQgPSBzLnByZXZbcy5zdHJzdGFydCAmIHMud19tYXNrXSA9IHMuaGVhZFtzLmluc19oXTsKICAgICAgICAgICAgcy5oZWFkW3MuaW5zX2hdID0gcy5zdHJzdGFydDsKICAgICAgICAgIH0KICAgICAgICAgIHMucHJldl9sZW5ndGggPSBzLm1hdGNoX2xlbmd0aDsKICAgICAgICAgIHMucHJldl9tYXRjaCA9IHMubWF0Y2hfc3RhcnQ7CiAgICAgICAgICBzLm1hdGNoX2xlbmd0aCA9IE1JTl9NQVRDSCAtIDE7CiAgICAgICAgICBpZiAoaGFzaF9oZWFkICE9PSAwICYmIHMucHJldl9sZW5ndGggPCBzLm1heF9sYXp5X21hdGNoICYmIHMuc3Ryc3RhcnQgLSBoYXNoX2hlYWQgPD0gcy53X3NpemUgLSBNSU5fTE9PS0FIRUFEKSB7CiAgICAgICAgICAgIHMubWF0Y2hfbGVuZ3R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luc19oXSA9IHMuc3Ryc3RhcnQ7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IHdoaWxlICgtLXMucHJldl9sZW5ndGggIT09IDApOwogICAgICAgICAgICBzLm1hdGNoX2F2YWlsYWJsZSA9IDA7CiAgICAgICAgICAgIHMubWF0Y2hfbGVuZ3RoID0gTUlOX01BVENIIC0gMTsKICAgICAgICAgICAgcy5zdHJzdGFydCsrOwogICAgICAgICAgICBpZiAoYmZsdXNoKSB7CiAgICAgICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCBmYWxzZSk7CiAgICAgICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgaWYgKHMubWF0Y2hfYXZhaWxhYmxlKSB7CiAgICAgICAgICAgIGJmbHVzaCA9IHRyZWVzLl90cl90YWxseShzLCAwLCBzLndpbmRvd1tzLnN0cnN0YXJ0IC0gMV0pOwogICAgICAgICAgICBpZiAoYmZsdXNoKSB7CiAgICAgICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCBmYWxzZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcy5zdHJzdGFydCsrOwogICAgICAgICAgICBzLmxvb2thaGVhZC0tOwogICAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHMubWF0Y2hfYXZhaWxhYmxlID0gMTsKICAgICAgICAgICAgcy5zdHJzdGFydCsrOwogICAgICAgICAgICBzLmxvb2thaGVhZC0tOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAocy5tYXRjaF9hdmFpbGFibGUpIHsKICAgICAgICAgIGJmbHVzaCA9IHRyZWVzLl90cl90YWxseShzLCAwLCBzLndpbmRvd1tzLnN0cnN0YXJ0IC0gMV0pOwogICAgICAgICAgcy5tYXRjaF9hdmFpbGFibGUgPSAwOwogICAgICAgIH0KICAgICAgICBzLmluc2VydCA9IHMuc3Ryc3RhcnQgPCBNSU5fTUFUQ0ggLSAxID8gcy5zdHJzdGFydCA6IE1JTl9NQVRDSCAtIDE7CiAgICAgICAgaWYgKGZsdXNoID09PSBaX0ZJTklTSCkgewogICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCB0cnVlKTsKICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBCU19GSU5JU0hfU1RBUlRFRDsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBCU19GSU5JU0hfRE9ORTsKICAgICAgICB9CiAgICAgICAgaWYgKHMubGFzdF9saXQpIHsKICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgZmFsc2UpOwogICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIEJTX0JMT0NLX0RPTkU7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZGVmbGF0ZV9ybGUocywgZmx1c2gpIHsKICAgICAgICB2YXIgYmZsdXNoOwogICAgICAgIHZhciBwcmV2OwogICAgICAgIHZhciBzY2FuLCBzdHJlbmQ7CiAgICAgICAgdmFyIF93aW4gPSBzLndpbmRvdzsKICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA8PSBNQVhfTUFUQ0gpIHsKICAgICAgICAgICAgZmlsbF93aW5kb3cocyk7CiAgICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA8PSBNQVhfTUFUQ0ggJiYgZmx1c2ggPT09IFpfTk9fRkxVU0gpIHsKICAgICAgICAgICAgICByZXR1cm4gQlNfTkVFRF9NT1JFOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA9PT0gMCkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBzLm1hdGNoX2xlbmd0aCA9IDA7CiAgICAgICAgICBpZiAocy5sb29rYWhlYWQgPj0gTUlOX01BVENIICYmIHMuc3Ryc3RhcnQgPiAwKSB7CiAgICAgICAgICAgIHNjYW4gPSBzLnN0cnN0YXJ0IC0gMTsKICAgICAgICAgICAgcHJldiA9IF93aW5bc2Nhbl07CiAgICAgICAgICAgIGlmIChwcmV2ID09PSBfd2luWysrc2Nhbl0gJiYgcHJldiA9PT0gX3dpblsrK3NjYW5dICYmIHByZXYgPT09IF93aW5bKytzY2FuXSkgewogICAgICAgICAgICAgIHN0cmVuZCA9IHMuc3Ryc3RhcnQgKyBNQVhfTUFUQ0g7CiAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgIH0gd2hpbGUgKHByZXYgPT09IF93aW5bKytzY2FuXSAmJiBwcmV2ID09PSBfd2luWysrc2Nhbl0gJiYgcHJldiA9PT0gX3dpblsrK3NjYW5dICYmIHByZXYgPT09IF93aW5bKytzY2FuXSAmJiBwcmV2ID09PSBfd2luWysrc2Nhbl0gJiYgcHJldiA9PT0gX3dpblsrK3NjYW5dICYmIHByZXYgPT09IF93aW5bKytzY2FuXSAmJiBwcmV2ID09PSBfd2luWysrc2Nhbl0gJiYgc2NhbiA8IHN0cmVuZCk7CiAgICAgICAgICAgICAgcy5tYXRjaF9sZW5ndGggPSBNQVhfTUFUQ0ggLSAoc3RyZW5kIC0gc2Nhbik7CiAgICAgICAgICAgICAgaWYgKHMubWF0Y2hfbGVuZ3RoID4gcy5sb29rYWhlYWQpIHsKICAgICAgICAgICAgICAgIHMubWF0Y2hfbGVuZ3RoID0gcy5sb29rYWhlYWQ7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAocy5tYXRjaF9sZW5ndGggPj0gTUlOX01BVENIKSB7CiAgICAgICAgICAgIGJmbHVzaCA9IHRyZWVzLl90cl90YWxseShzLCAxLCBzLm1hdGNoX2xlbmd0aCAtIE1JTl9NQVRDSCk7CiAgICAgICAgICAgIHMubG9va2FoZWFkIC09IHMubWF0Y2hfbGVuZ3RoOwogICAgICAgICAgICBzLnN0cnN0YXJ0ICs9IHMubWF0Y2hfbGVuZ3RoOwogICAgICAgICAgICBzLm1hdGNoX2xlbmd0aCA9IDA7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBiZmx1c2ggPSB0cmVlcy5fdHJfdGFsbHkocywgMCwgcy53aW5kb3dbcy5zdHJzdGFydF0pOwogICAgICAgICAgICBzLmxvb2thaGVhZC0tOwogICAgICAgICAgICBzLnN0cnN0YXJ0Kys7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYmZsdXNoKSB7CiAgICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgZmFsc2UpOwogICAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcy5pbnNlcnQgPSAwOwogICAgICAgIGlmIChmbHVzaCA9PT0gWl9GSU5JU0gpIHsKICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgdHJ1ZSk7CiAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICByZXR1cm4gQlNfRklOSVNIX1NUQVJURUQ7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gQlNfRklOSVNIX0RPTkU7CiAgICAgICAgfQogICAgICAgIGlmIChzLmxhc3RfbGl0KSB7CiAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIGZhbHNlKTsKICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiBCU19CTE9DS19ET05FOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRlZmxhdGVfaHVmZihzLCBmbHVzaCkgewogICAgICAgIHZhciBiZmx1c2g7CiAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICBpZiAocy5sb29rYWhlYWQgPT09IDApIHsKICAgICAgICAgICAgZmlsbF93aW5kb3cocyk7CiAgICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA9PT0gMCkgewogICAgICAgICAgICAgIGlmIChmbHVzaCA9PT0gWl9OT19GTFVTSCkgewogICAgICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHMubWF0Y2hfbGVuZ3RoID0gMDsKICAgICAgICAgIGJmbHVzaCA9IHRyZWVzLl90cl90YWxseShzLCAwLCBzLndpbmRvd1tzLnN0cnN0YXJ0XSk7CiAgICAgICAgICBzLmxvb2thaGVhZC0tOwogICAgICAgICAgcy5zdHJzdGFydCsrOwogICAgICAgICAgaWYgKGJmbHVzaCkgewogICAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIGZhbHNlKTsKICAgICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgICByZXR1cm4gQlNfTkVFRF9NT1JFOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHMuaW5zZXJ0ID0gMDsKICAgICAgICBpZiAoZmx1c2ggPT09IFpfRklOSVNIKSB7CiAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIHRydWUpOwogICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgcmV0dXJuIEJTX0ZJTklTSF9TVEFSVEVEOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIEJTX0ZJTklTSF9ET05FOwogICAgICAgIH0KICAgICAgICBpZiAocy5sYXN0X2xpdCkgewogICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCBmYWxzZSk7CiAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICByZXR1cm4gQlNfTkVFRF9NT1JFOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gQlNfQkxPQ0tfRE9ORTsKICAgICAgfQogICAgICBmdW5jdGlvbiBDb25maWcoZ29vZF9sZW5ndGgsIG1heF9sYXp5LCBuaWNlX2xlbmd0aCwgbWF4X2NoYWluLCBmdW5jKSB7CiAgICAgICAgdGhpcy5nb29kX2xlbmd0aCA9IGdvb2RfbGVuZ3RoOwogICAgICAgIHRoaXMubWF4X2xhenkgPSBtYXhfbGF6eTsKICAgICAgICB0aGlzLm5pY2VfbGVuZ3RoID0gbmljZV9sZW5ndGg7CiAgICAgICAgdGhpcy5tYXhfY2hhaW4gPSBtYXhfY2hhaW47CiAgICAgICAgdGhpcy5mdW5jID0gZnVuYzsKICAgICAgfQogICAgICB2YXIgY29uZmlndXJhdGlvbl90YWJsZTsKICAgICAgY29uZmlndXJhdGlvbl90YWJsZSA9IFsKICAgICAgICBuZXcgQ29uZmlnKDAsIDAsIDAsIDAsIGRlZmxhdGVfc3RvcmVkKSwKICAgICAgICBuZXcgQ29uZmlnKDQsIDQsIDgsIDQsIGRlZmxhdGVfZmFzdCksCiAgICAgICAgbmV3IENvbmZpZyg0LCA1LCAxNiwgOCwgZGVmbGF0ZV9mYXN0KSwKICAgICAgICBuZXcgQ29uZmlnKDQsIDYsIDMyLCAzMiwgZGVmbGF0ZV9mYXN0KSwKICAgICAgICBuZXcgQ29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YWJsZSA9IDA7CiAgICAgICAgcy5pbnNfaCA9IDA7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gRGVmbGF0ZVN0YXRlKCkgewogICAgICAgIHRoaXMuc3RybSA9IG51bGw7CiAgICAgICAgdGhpcy5zdGF0dXMgPSAwOwogICAgICAgIHRoaXMucGVuZGluZ19idWYgPSBudWxsOwogICAgICAgIHRoaXMucGVuZGluZ19idWZfc2l6ZSA9IDA7CiAgICAgICAgdGhpcy5wZW5kaW5nX291dCA9IDA7CiAgICAgICAgdGhpcy5wZW5kaW5nID0gMDsKICAgICAgICB0aGlzLndyYXAgPSAwOwogICAgICAgIHRoaXMuZ3poZWFkID0gbnVsbDsKICAgICAgICB0aGlzLmd6aW5kZXggPSAwOwogICAgICAgIHRoaXMubWV0aG9kID0gWl9ERUZMQVRFRDsKICAgICAgICB0aGlzLmxhc3RfZmx1c2ggPSAtMTsKICAgICAgICB0aGlzLndfc2l6ZSA9IDA7CiAgICAgICAgdGhpcy53X2JpdHMgPSAwOwogICAgICAgIHRoaXMud19tYXNrID0gMDsKICAgICAgICB0aGlzLndpbmRvdyA9IG51bGw7CiAgICAgICAgdGhpcy53aW5kb3dfc2l6ZSA9IDA7CiAgICAgICAgdGhpcy5wcmV2ID0gbnVsbDsKICAgICAgICB0aGlzLmhlYWQgPSBudWxsOwogICAgICAgIHRoaXMuaW5zX2ggPSAwOwogICAgICAgIHRoaXMuaGFzaF9zaXplID0gMDsKICAgICAgICB0aGlzLmhhc2hfYml0cyA9IDA7CiAgICAgICAgdGhpcy5oYXNoX21hc2sgPSAwOwogICAgICAgIHRoaXMuaGFzaF9zaGlmdCA9IDA7CiAgICAgICAgdGhpcy5ibG9ja19zdGFydCA9IDA7CiAgICAgICAgdGhpcy5tYXRjaF9sZW5ndGggPSAwOwogICAgICAgIHRoaXMucHJldl9tYXRjaCA9IDA7CiAgICAgICAgdGhpcy5tYXRjaF9hdmFpbGFibGUgPSAwOwogICAgICAgIHRoaXMuc3Ryc3R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kZXB0aCA9IG5ldyB1dGlscy5CdWYxNigyICogTF9DT0RFUyArIDEpOwogICAgICAgIHplcm8odGhpcy5kZXB0aCk7CiAgICAgICAgdGhpcy5sX2J1ZiA9IDA7CiAgICAgICAgdGhpcy5saXRfYnVmc2l6ZSA9IDA7CiAgICAgICAgdGhpcy5sYXN0X2xpdCA9IDA7CiAgICAgICAgdGhpcy5kX2J1ZiA9IDA7CiAgICAgICAgdGhpcy5vcHRfbGVuID0gMDsKICAgICAgICB0aGlzLnN0YXRpY19sZW4gPSAwOwogICAgICAgIHRoaXMubWF0Y2hlcyA9IDA7CiAgICAgICAgdGhpcy5pbnNlcnQgPSAwOwogICAgICAgIHRoaXMuYmlfYnVmID0gMDsKICAgICAgICB0aGlzLmJpX3ZhbGlkID0gMDsKICAgICAgfQogICAgICBmdW5jdGlvbiBkZWZsYXRlUmVzZXRLZWVwKHN0cm0pIHsKICAgICAgICB2YXIgczsKICAgICAgICBpZiAoIXN0cm0gfHwgIXN0cm0uc3RhdGUpIHsKICAgICAgICAgIHJldHVybiBlcnIoc3RybSwgWl9TVFJFQU1fRVJST1IpOwogICAgICAgIH0KICAgICAgICBzdHJtLnRvdGFsX2luID0gc3RybS50b3RhbF9vdXQgPSAwOwogICAgICAgIHN0cm0uZGF0YV90eXBlID0gWl9VTktOT1dOOwogICAgICAgIHMgPSBzdHJtLnN0YXRlOwogICAgICAgIHMucGVuZGluZyA9IDA7CiAgICAgICAgcy5wZW5kaW5nX291dCA9IDA7CiAgICAgICAgaWYgKHMud3JhcCA8IDApIHsKICAgICAgICAgIHMud3JhcCA9IC1zLndyYXA7CiAgICAgICAgfQogICAgICAgIHMuc3RhdHVzID0gcy53cmFwID8gSU5JVF9TVEFURSA6IEJVU1lfU1RBVEU7CiAgICAgICAgc3RybS5hZGxlciA9IHMud3JhcCA9PT0gMiA/IDAgOiAxOwogICAgICAgIHMubGFzdF9mbHVzaCA9IFpfTk9fRkxVU0g7CiAgICAgICAgdHJlZXMuX3RyX2luaXQocyk7CiAgICAgICAgcmV0dXJuIFpfT0s7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZGVmbGF0ZVJlc2V0KHN0cm0pIHsKICAgICAgICB2YXIgcmV0ID0gZGVmbGF0ZVJlc2V0S2VlcChzdHJtKTsKICAgICAgICBpZiAocmV0ID09PSBaX09LKSB7CiAgICAgICAgICBsbV9pbml0KHN0cm0uc3RhdGUpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gcmV0OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRlZmxhdGVTZXRIZWFkZXIoc3RybSwgaGVhZCkgewogICAgICAgIGlmICghc3RybSB8fCAhc3RybS5zdGF0ZSkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgIH0KICAgICAgICBpZiAoc3RybS5zdGF0ZS53cmFwICE9PSAyKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIHN0cm0uc3RhdGUuZ3poZWFkID0gaGVhZDsKICAgICAgICByZXR1cm4gWl9PSzsKICAgICAgfQogICAgICBmdW5jdGlvbiBkZWZsYXRlSW5pdDIoc3RybSwgbGV2ZWwsIG1ldGhvZCwgd2luZG93Qml0cywgbWVtTGV2ZWwsIHN0cmF0ZWd5KSB7CiAgICAgICAgaWYgKCFzdHJtKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIHZhciB3cmFwID0gMTsKICAgICAgICBpZiAobGV2ZWwgPT09IFpfREVGQVVMVF9DT01QUkVTU0lPTikgewogICAgICAgICAgbGV2ZWwgPSA2OwogICAgICAgIH0KICAgICAgICBpZiAod2luZG93Qml0cyA8IDApIHsKICAgICAgICAgIHdyYXAgPSAwOwogICAgICAgICAgd2luZG93Qml0cyA9IC13aW5kb3dCaXRzOwogICAgICAgIH0gZWxzZSBpZiAod2luZG93Qml0cyA+IDE1KSB7CiAgICAgICAgICB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ZiAoIXN0cm0ub3V0cHV0IHx8ICFzdHJtLmlucHV0ICYmIHN0cm0uYXZhaWxfaW4gIT09IDAgfHwgcy5zdGF0dXMgPT09IEZJTklTSF9TVEFURSAmJiBmbHVzaCAhPT0gWl9GSU5JU0gpIHsKICAgICAgICAgIHJldHVybiBlcnIoc3RybSwgc3RybS5hdmFpbF9vdXQgPT09IDAgPyBaX0JVRl9FUlJPUiA6IFpfU1RSRUFNX0VSUk9SKTsKICAgICAgICB9CiAgICAgICAgcy5zdHJtID0gc3RybTsKICAgICAgICBvbGRfZmx1c2ggPSBzLmxhc3RfZmx1c2g7CiAgICAgICAgcy5sYXN0X2ZsdXNoID0gZmx1c2g7CiAgICAgICAgaWYgKHMuc3RhdHVzID09PSBJTklUX1NUQVRFKSB7CiAgICAgICAgICBpZiAocy53cmFwID09PSAyKSB7CiAgICAgICAgICAgIHN0cm0uYWRsZXIgPSAwOwogICAgICAgICAgICBwdXRfYnl0ZShzLCAzMSk7CiAgICAgICAgICAgIHB1dF9ieXRlKHMsIDEzOSk7CiAgICAgICAgICAgIHB1dF9ieXRlKHMsIDgpOwogICAgICAgICAgICBpZiAoIXMuZ3poZWFkKSB7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgMCk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgMCk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgMCk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgMCk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgMCk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgcy5sZXZlbCA9PT0gOSA/IDIgOiBzLnN0cmF0ZWd5ID49IFpfSFVGRk1BTl9PTkxZIHx8IHMubGV2ZWwgPCAyID8gNCA6IDApOwogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIE9TX0NPREUpOwogICAgICAgICAgICAgIHMuc3RhdHVzID0gQlVTWV9TVEFURTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCAocy5nemhlYWQudGV4dCA/IDEgOiAwKSArIChzLmd6aGVhZC5oY3JjID8gMiA6IDApICsgKCFzLmd6aGVhZC5leHRyYSA/IDAgOiA0KSArICghcy5nemhlYWQubmFtZSA/IDAgOiA4KSArICghcy5nemhlYWQuY29tbWVudCA/IDAgOiAxNikpOwogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIHMuZ3poZWFkLnRpbWUgJiAyNTUpOwogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIHMuZ3poZWFkLnRpbWUgPj4gOCAmIDI1NSk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgcy5nemhlYWQudGltZSA+PiAxNiAmIDI1NSk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgcy5nemhlYWQudGltZSA+PiAyNCAmIDI1NSk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgcy5sZXZlbCA9PT0gOSA/IDIgOiBzLnN0cmF0ZWd5ID49IFpfSFVGRk1BTl9PTkxZIHx8IHMubGV2ZWwgPCAyID8gNCA6IDApOwogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIHMuZ3poZWFkLm9zICYgMjU1KTsKICAgICAgICAgICAgICBpZiAocy5nemhlYWQuZXh0cmEgJiYgcy5nemhlYWQuZXh0cmEubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICBwdXRfYnl0ZShzLCBzLmd6aGVhZC5leHRyYS5sZW5ndGggJiAyNTUpOwogICAgICAgICAgICAgICAgcHV0X2J5dGUocywgcy5nemhlYWQuZXh0cmEubGVuZ3RoID4+IDggJiAyNTUpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAocy5nemhlYWQuaGNyYykgewogICAgICAgICAgICAgICAgc3RybS5hZGxlciA9IGNyYzMyKHN0cm0uYWRsZXIsIHMucGVuZGluZ19idWYsIHMucGVuZGluZywgMCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHMuZ3ppbmRleCA9IDA7CiAgICAgICAgICAgICAgcy5zdGF0dXMgPSBFWFRSQV9TVEFURTsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgdmFyIGhlYWRlciA9IFpfREVGTEFURUQgKyAocy53X2JpdHMgLSA4IDw8IDQpIDw8IDg7CiAgICAgICAgICAgIHZhciBsZXZlbF9mbGFncyA9IC0xOwogICAgICAgICAgICBpZiAocy5zdHJhdGVneSA+PSBaX0hVRkZNQU5fT05MWSB8fCBzLmxldmVsIDwgMikgewogICAgICAgICAgICAgIGxldmVsX2ZsYWdzID0gMDsKICAgICAgICAgICAgfSBlbHNlIGlmIChzLmxldmVsIDwgNikgewogICAgICAgICAgICAgIGxldmVsX2ZsYWdzID0gMTsKICAgICAgICAgICAgfSBlbHNlIGlmIChzLmxldmVsID09PSA2KSB7CiAgICAgICAgICAgICAgbGV2ZWxfZmxhZ3MgPSAyOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGxldmVsX2ZsYWdzID0gMzsKICAgICAgICAgICAgfQogICAgICAgICAgICBoZWFkZXIgfD0gbGV2ZWxfZmxhZ3MgPDwgNjsKICAgICAgICAgICAgaWYgKHMuc3Ryc3RhcnQgIT09IDApIHsKICAgICAgICAgICAgICBoZWFkZXIgfD0gUFJFU0VUX0RJQ1Q7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaGVhZGVyICs9IDMxIC0gaGVhZGVyICUgMzE7CiAgICAgICAgICAgIHMuc3RhdHVzID0gQlVTWV9TVEFURTsKICAgICAgICAgICAgcHV0U2hvcnRNU0IocywgaGVhZGVyKTsKICAgICAgICAgICAgaWYgKHMuc3Ryc3RhcnQgIT09IDApIHsKICAgICAgICAgICAgICBwdXRTaG9ydE1TQihzLCBzdHJtLmFkbGVyID4+PiAxNik7CiAgICAgICAgICAgICAgcHV0U2hvcnRNU0Iocywgc3RybS5hZGxlciAmIDY1NTM1KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBzdHJtLmFkbGVyID0gMTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHMuc3RhdHVzID09PSBFWFRSQV9TVEFURSkgewogICAgICAgICAgaWYgKHMuZ3poZWFkLmV4dHJhKSB7CiAgICAgICAgICAgIGJlZyA9IHMucGVuZGluZzsKICAgICAgICAgICAgd2hpbGUgKHMuZ3ppbmRleCA8IChzLmd6aGVhZC5leHRyYS5sZW5ndGggJiA2NTUzNSkpIHsKICAgICAgICAgICAgICBpZiAocy5wZW5kaW5nID09PSBzLnBlbmRpbmdfYnVmX3NpemUpIHsKICAgICAgICAgICAgICAgIGlmIChzLmd6aGVhZC5oY3JjICYmIHMucGVuZGluZyA+IGJlZykgewogICAgICAgICAgICAgICAgICBzdHJtLmFkbGVyID0gY3JjMzIoc3RybS5hZGxlciwgcy5wZW5kaW5nX2J1Ziwgcy5wZW5kaW5nIC0gYmVnLCBiZWcpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZmx1c2hfcGVuZGluZyhzdHJtKTsKICAgICAgICAgICAgICAgIGJlZyA9IHMucGVuZGluZzsKICAgICAgICAgICAgICAgIGlmIChzLnBlbmRpbmcgPT09IHMucGVuZGluZ19idWZfc2l6ZSkgewogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgcy5nemhlYWQuZXh0cmFbcy5nemluZGV4XSAmIDI1NSk7CiAgICAgICAgICAgICAgcy5nemluZGV4Kys7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHMuZ3poZWFkLmhjcmMgJiYgcy5wZW5kaW5nID4gYmVnKSB7CiAgICAgICAgICAgICAgc3RybS5hZGxlciA9IGNyYzMyKHN0cm0uYWRsZXIsIHMucGVuZGluZ19idWYsIHMucGVuZGluZyAtIGJlZywgYmVnKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAocy5nemluZGV4ID09PSBzLmd6aGVhZC5leHRyYS5sZW5ndGgpIHsKICAgICAgICAgICAgICBzLmd6aW5kZXggPSAwOwogICAgICAgICAgICAgIHMuc3RhdHVzID0gTkFNRV9TVEFURTsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcy5zdGF0dXMgPSBOQU1FX1NUQVRFOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAocy5zdGF0dXMgPT09IE5BTUVfU1RBVEUpIHsKICAgICAgICAgIGlmIChzLmd6aGVhZC5uYW1lKSB7CiAgICAgICAgICAgIGJlZyA9IHMucGVuZGluZzsKICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgIGlmIChzLnBlbmRpbmcgPT09IHMucGVuZGluZ19idWZfc2l6ZSkgewogICAgICAgICAgICAgICAgaWYgKHMuZ3poZWFkLmhjcmMgJiYgcy5wZW5kaW5nID4gYmVnKSB7CiAgICAgICAgICAgICAgICAgIHN0cm0uYWRsZXIgPSBjcmMzMihzdHJtLmFkbGVyLCBzLnBlbmRpbmdfYnVmLCBzLnBlbmRpbmcgLSBiZWcsIGJlZyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmbHVzaF9wZW5kaW5nKHN0cm0pOwogICAgICAgICAgICAgICAgYmVnID0gcy5wZW5kaW5nOwogICAgICAgICAgICAgICAgaWYgKHMucGVuZGluZyA9PT0gcy5wZW5kaW5nX2J1Zl9zaXplKSB7CiAgICAgICAgICAgICAgICAgIHZhbCA9IDE7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAocy5nemluZGV4IDwgcy5nemhlYWQubmFtZS5sZW5ndGgpIHsKICAgICAgICAgICAgICAgIHZhbCA9IHMuZ3poZWFkLm5hbWUuY2hhckNvZGVBdChzLmd6aW5kZXgrKykgJiAyNTU7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHZhbCA9IDA7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIHZhbCk7CiAgICAgICAgICAgIH0gd2hpbGUgKHZhbCAhPT0gMCk7CiAgICAgICAgICAgIGlmIChzLmd6aGVhZC5oY3JjICYmIHMucGVuZGluZyA+IGJlZykgewogICAgICAgICAgICAgIHN0cm0uYWRsZXIgPSBjcmMzMihzdHJtLmFkbGVyLCBzLnBlbmRpbmdfYnVmLCBzLnBlbmRpbmcgLSBiZWcsIGJlZyk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHZhbCA9PT0gMCkgewogICAgICAgICAgICAgIHMuZ3ppbmRleCA9IDA7CiAgICAgICAgICAgICAgcy5zdGF0dXMgPSBDT01NRU5UX1NUQVRFOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzLnN0YXR1cyA9IENPTU1FTlRfU1RBVEU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChzLnN0YXR1cyA9PT0gQ09NTUVOVF9TVEFURSkgewogICAgICAgICAgaWYgKHMuZ3poZWFkLmNvbW1lbnQpIHsKICAgICAgICAgICAgYmVnID0gcy5wZW5kaW5nOwogICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgaWYgKHMucGVuZGluZyA9PT0gcy5wZW5kaW5nX2J1Zl9zaXplKSB7CiAgICAgICAgICAgICAgICBpZiAocy5nemhlYWQuaGNyYyAmJiBzLnBlbmRpbmcgPiBiZWcpIHsKICAgICAgICAgICAgICAgICAgc3RybS5hZGxlciA9IGNyYzMyKHN0cm0uYWRsZXIsIHMucGVuZGluZ19idWYsIHMucGVuZGluZyAtIGJlZywgYmVnKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZsdXNoX3BlbmRpbmcoc3RybSk7CiAgICAgICAgICAgICAgICBiZWcgPSBzLnBlbmRpbmc7CiAgICAgICAgICAgICAgICBpZiAocy5wZW5kaW5nID09PSBzLnBlbmRpbmdfYnVmX3NpemUpIHsKICAgICAgICAgICAgICAgICAgdmFsID0gMTsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChzLmd6aW5kZXggPCBzLmd6aGVhZC5jb21tZW50Lmxlbmd0aCkgewogICAgICAgICAgICAgICAgdmFsID0gcy5nemhlYWQuY29tbWVudC5jaGFyQ29kZUF0KHMuZ3ppbmRleCsrKSAmIDI1NTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgdmFsID0gMDsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgdmFsKTsKICAgICAgICAgICAgfSB3aGlsZSAodmFsICE9PSAwKTsKICAgICAgICAgICAgaWYgKHMuZ3poZWFkLmhjcmMgJiYgcy5wZW5kaW5nID4gYmVnKSB7CiAgICAgICAgICAgICAgc3RybS5hZGxlciA9IGNyYzMyKHN0cm0uYWRsZXIsIHMucGVuZGluZ19idWYsIHMucGVuZGluZyAtIGJlZywgYmVnKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodmFsID09PSAwKSB7CiAgICAgICAgICAgICAgcy5zdGF0dXMgPSBIQ1JDX1NUQVRFOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzLnN0YXR1cyA9IEhDUkNfU1RBVEU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChzLnN0YXR1cyA9PT0gSENSQ19TVEFURSkgewogICAgICAgICAgaWYgKHMuZ3poZWFkLmhjcmMpIHsKICAgICAgICAgICAgaWYgKHMucGVuZGluZyArIDIgPiBzLnBlbmRpbmdfYnVmX3NpemUpIHsKICAgICAgICAgICAgICBmbHVzaF9wZW5kaW5nKHN0cm0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzLnBlbmRpbmcgKyAyIDw9IHMucGVuZGluZ19idWZfc2l6ZSkgewogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIHN0cm0uYWRsZXIgJiAyNTUpOwogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIHN0cm0uYWRsZXIgPj4gOCAmIDI1NSk7CiAgICAgICAgICAgICAgc3RybS5hZGxlciA9IDA7CiAgICAgICAgICAgICAgcy5zdGF0dXMgPSBCVVNZX1NUQVRFOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzLnN0YXR1cyA9IEJVU1lfU1RBVEU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChzLnBlbmRpbmcgIT09IDApIHsKICAgICAgICAgIGZsdXNoX3BlbmRpbmcoc3RybSk7CiAgICAgICAgICBpZiAoc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgcy5sYXN0X2ZsdXNoID0gLTE7CiAgICAgICAgICAgIHJldHVybiBaX09LOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoc3RybS5hdmFpbF9pbiA9PT0gMCAmJiByYW5rKGZsdXNoKSA8PSByYW5rKG9sZF9mbHVzaCkgJiYgZmx1c2ggIT09IFpfRklOSVNIKSB7CiAgICAgICAgICByZXR1cm4gZXJyKHN0cm0sIFpfQlVGX0VSUk9SKTsKICAgICAgICB9CiAgICAgICAgaWYgKHMuc3RhdHVzID09PSBGSU5JU0hfU1RBVEUgJiYgc3RybS5hdmFpbF9pbiAhPT0gMCkgewogICAgICAgICAgcmV0dXJuIGVycihzdHJtLCBaX0JVRl9FUlJPUik7CiAgICAgICAgfQogICAgICAgIGlmIChzdHJtLmF2YWlsX2luICE9PSAwIHx8IHMubG9va2FoZWFkICE9PSAwIHx8IGZsdXNoICE9PSBaX05PX0ZMVVNIICYmIHMuc3RhdHVzICE9PSBGSU5JU0hfU1RBVEUpIHsKICAgICAgICAgIHZhciBic3RhdGUgPSBzLnN0cmF0ZWd5ID09PSBaX0hVRkZNQU5fT05MWSA/IGRlZmxhdGVfaHVmZihzLCBmbHVzaCkgOiBzLnN0cmF0ZWd5ID09PSBaX1JMRSA/IGRlZmxhdGVfcmxlKHMsIGZsdXNoKSA6IGNvbmZpZ3VyYXRpb25fdGFibGVbcy5sZXZlbF0uZnVuYyhzLCBmbHVzaCk7CiAgICAgICAgICBpZiAoYnN0YXRlID09PSBCU19GSU5JU0hfU1RBUlRFRCB8fCBic3RhdGUgPT09IEJTX0ZJTklTSF9ET05FKSB7CiAgICAgICAgICAgIHMuc3RhdHVzID0gRklOSVNIX1NUQVRFOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGJzdGF0ZSA9PT0gQlNfTkVFRF9NT1JFIHx8IGJzdGF0ZSA9PT0gQlNfRklOSVNIX1NUQVJURUQpIHsKICAgICAgICAgICAgaWYgKHN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgICAgcy5sYXN0X2ZsdXNoID0gLTE7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIFpfT0s7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYnN0YXRlID09PSBCU19CTE9DS19ET05FKSB7CiAgICAgICAgICAgIGlmIChmbHVzaCA9PT0gWl9QQVJUSUFMX0ZMVVNIKSB7CiAgICAgICAgICAgICAgdHJlZXMuX3RyX2FsaWduKHMpOwogICAgICAgICAgICB9IGVsc2UgaWYgKGZsdXNoICE9PSBaX0JMT0NLKSB7CiAgICAgICAgICAgICAgdHJlZXMuX3RyX3N0b3JlZF9ibG9jayhzLCAwLCAwLCBmYWxzZSk7CiAgICAgICAgICAgICAgaWYgKGZsdXNoID09PSBaX0ZVTExfRkxVU0gpIHsKICAgICAgICAgICAgICAgIHplcm8ocy5oZWFkKTsKICAgICAgICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA9PT0gMCkgewogICAgICAgICAgICAgICAgICBzLnN0cnN0YXJ0ID0gMDsKICAgICAgICAgICAgICAgICAgcy5ibG9ja19zdGFydCA9IDA7CiAgICAgICAgICAgICAgICAgIHMuaW5zZXJ0ID0gMDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZmx1c2hfcGVuZGluZyhzdHJtKTsKICAgICAgICAgICAgaWYgKHN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgICAgcy5sYXN0X2ZsdXNoID0gLTE7CiAgICAgICAgICAgICAgcmV0dXJuIFpfT0s7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKGZsdXNoICE9PSBaX0ZJTklTSCkgewogICAgICAgICAgcmV0dXJuIFpfT0s7CiAgICAgICAgfQogICAgICAgIGlmIChzLndyYXAgPD0gMCkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VORDsKICAgICAgICB9CiAgICAgICAgaWYgKHMud3JhcCA9PT0gMikgewogICAgICAgICAgcHV0X2J5dGUocywgc3RybS5hZGxlciAmIDI1NSk7CiAgICAgICAgICBwdXRfYnl0ZShzLCBzdHJtLmFkbGVyID4+IDggJiAyNTUpOwogICAgICAgICAgcHV0X2J5dGUocywgc3RybS5hZGxlciA+PiAxNiAmIDI1NSk7CiAgICAgICAgICBwdXRfYnl0ZShzLCBzdHJtLmFkbGVyID4+IDI0ICYgMjU1KTsKICAgICAgICAgIHB1dF9ieXRlKHMsIHN0cm0udG90YWxfaW4gJiAyNTUpOwogICAgICAgICAgcHV0X2J5dGUocywgc3RybS50b3RhbF9pbiA+PiA4ICYgMjU1KTsKICAgICAgICAgIHB1dF9ieXRlKHMsIHN0cm0udG90YWxfaW4gPj4gMTYgJiAyNTUpOwogICAgICAgICAgcHV0X2J5dGUocywgc3RybS50b3RhbF9pbiA+PiAyNCAmIDI1NSk7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHB1dFNob3J0TVNCKHMsIHN0cm0uYWRsZXIgPj4+IDE2KTsKICAgICAgICAgIHB1dFNob3J0TVNCKHMsIHN0cm0uYWRsZXIgJiA2NTUzNSk7CiAgICAgICAgfQogICAgICAgIGZsdXNoX3BlbmRpbmcoc3RybSk7CiAgICAgICAgaWYgKHMud3JhcCA+IDApIHsKICAgICAgICAgIHMud3JhcCA9IC1zLndyYXA7CiAgICAgICAgfQogICAgICAgIHJldHVybiBzLnBlbmRpbmcgIT09IDAgPyBaX09LIDogWl9TVFJFQU1fRU5EOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRlZmxhdGVFbmQoc3RybSkgewogICAgICAgIHZhciBzdGF0dXM7CiAgICAgICAgaWYgKCFzdHJtIHx8ICFzdHJtLnN0YXRlKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIHN0YXR1cyA9IHN0cm0uc3RhdGUuc3RhdHVzOwogICAgICAgIGlmIChzdGF0dXMgIT09IElOSVRfU1RBVEUgJiYgc3RhdHVzICE9PSBFWFRSQV9TVEFURSAmJiBzdGF0dXMgIT09IE5BTUVfU1RBVEUgJiYgc3RhdHVzICE9PSBDT01NRU5UX1NUQVRFICYmIHN0YXR1cyAhPT0gSENSQ19TVEFURSAmJiBzdGF0dXMgIT09IEJVU1lfU1RBVEUgJiYgc3RhdHVzICE9PSBGSU5JU0hfU1RBVEUpIHsKICAgICAgICAgIHJldHVybiBlcnIoc3RybSwgWl9TVFJFQU1fRVJST1IpOwogICAgICAgIH0KICAgICAgICBzdHJtLnN0YXRlID0gbnVsbDsKICAgICAgICByZXR1cm4gc3RhdHVzID09PSBCVVNZX1NUQVRFID8gZXJyKHN0cm0sIFpfREFUQV9FUlJPUikgOiBaX09LOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRlZmxhdGVTZXREaWN0aW9uYXJ5KHN0cm0sIGRpY3Rpb25hcnkpIHsKICAgICAgICB2YXIgZGljdExlbmd0aCA9IGRpY3Rpb25hcnkubGVuZ3RoOwogICAgICAgIHZhciBzOwogICAgICAgIHZhciBzdHIsIG47CiAgICAgICAgdmFyIHdyYXA7CiAgICAgICAgdmFyIGF2YWlsOwogICAgICAgIHZhciBuZXh0OwogICAgICAgIHZhciBpbnB1dDsKICAgICAgICB2YXIgdG1wRGljdDsKICAgICAgICBpZiAoIXN0cm0gfHwgIXN0cm0uc3RhdGUpIHsKICAgICAgICAgIHJldHVybiBaX1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgcyA9IHN0cm0uc3RhdGU7CiAgICAgICAgd3JhcCA9IHMud3JhcDsKICAgICAgICBpZiAod3JhcCA9PT0gMiB8fCB3cmFwID09PSAxICYmIHMuc3RhdHVzICE9PSBJTklUX1NUQVRFIHx8IHMubG9va2FoZWFkKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIGlmICh3cmFwID09PSAxKSB7CiAgICAgICAgICBzdHJtLmFkbGVyID0gYWRsZXIzMihzdHJtLmFkbGVyLCBkaWN0aW9uYXJ5LCBkaWN0TGVuZ3RoLCAwKTsKICAgICAgICB9CiAgICAgICAgcy53cmFwID0gMDsKICAgICAgICBpZiAoZGljdExlbmd0aCA+PSBzLndfc2l6ZSkgewogICAgICAgICAgaWYgKHdyYXAgPT09IDApIHsKICAgICAgICAgICAgemVybyhzLmhlYWQpOwogICAgICAgICAgICBzLnN0cnN0YXJ0ID0gMDsKICAgICAgICAgICAgcy5ibG9ja19zdGFydCA9IDA7CiAgICAgICAgICAgIHMuaW5zZXJ0ID0gMDsKICAgICAgICAgIH0KICAgICAgICAgIHRtcERpY3QgPSBuZXcgdXRpbHMuQnVmOChzLndfc2l6ZSk7CiAgICAgICAgICB1dGlscy5hcnJheVNldCh0bXBEaWN0LCBkaWN0aW9uYXJ5LCBkaWN0TGVuZ3RoIC0gcy53X3NpemUsIHMud19zaXplLCAwKTsKICAgICAgICAgIGRpY3Rpb25hcnkgPSB0bXBEaWN0OwogICAgICAgICAgZGljdExlbmd0aCA9IHMud19zaXplOwogICAgICAgIH0KICAgICAgICBhdmFpbCA9IHN0cm0uYXZhaWxfaW47CiAgICAgICAgbmV4dCA9IHN0cm0ubmV4dF9pbjsKICAgICAgICBpbnB1dCA9IHN0cm0uaW5wdXQ7CiAgICAgICAgc3RybS5hdmFpbF9pbiA9IGRpY3RMZW5ndGg7CiAgICAgICAgc3RybS5uZXh0X2luID0gMDsKICAgICAgICBzdHJtLmlucHV0ID0gZGljdGlvbmFyeTsKICAgICAgICBmaWxsX3dpbmRvdyhzKTsKICAgICAgICB3aGlsZSAocy5sb29rYWhlYWQgPj0gTUlOX01BVENIKSB7CiAgICAgICAgICBzdHIgPSBzLnN0cnN0YXJ0OwogICAgICAgICAgbiA9IHMubG9va2FoZWFkIC0gKE1JTl9NQVRDSCAtIDEpOwogICAgICAgICAgZG8gewogICAgICAgICAgICBzLmluc19oID0gKHMuaW5zX2ggPDwgcy5oYXNoX3NoaWZ0IF4gcy53aW5kb3dbc3RyICsgTUlOX01BVENIIC0gMV0pICYgcy5oYXNoX21hc2s7CiAgICAgICAgICAgIHMucHJldltzdHIgJiBzLndfbWFza10gPSBzLmhlYWRbcy5pbnNfaF07CiAgICAgICAgICAgIHMuaGVhZFtzLmluc19oXSA9IHN0cjsKICAgICAgICAgICAgc3RyKys7CiAgICAgICAgICB9IHdoaWxlICgtLW4pOwogICAgICAgICAgcy5zdHJzdGFydCA9IHN0cjsKICAgICAgICAgIHMubG9va2FoZWFkID0gTUlOX01BVENIIC0gMTsKICAgICAgICAgIGZpbGxfd2luZG93KHMpOwogICAgICAgIH0KICAgICAgICBzLnN0cnN0YXJ0ICs9IHMubG9va2FoZWFkOwogICAgICAgIHMuYmxvY2tfc3RhcnQgPSBzLnN0cnN0YXJ0OwogICAgICAgIHMuaW5zZXJ0ID0gcy5sb29rYWhlYWQ7CiAgICAgICAgcy5sb29rYWhlYWQgPSAwOwogICAgICAgIHMubWF0Y2hfbGVuZ3RoID0gcy5wcmV2X2xlbmd0aCA9IE1JTl9NQVRDSCAtIDE7Ci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AgICAgICAgICAgIGMyID0gc3RyLmNoYXJDb2RlQXQobV9wb3MgKyAxKTsKICAgICAgICAgICAgaWYgKChjMiAmIDY0NTEyKSA9PT0gNTYzMjApIHsKICAgICAgICAgICAgICBjID0gNjU1MzYgKyAoYyAtIDU1Mjk2IDw8IDEwKSArIChjMiAtIDU2MzIwKTsKICAgICAgICAgICAgICBtX3BvcysrOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBidWZfbGVuICs9IGMgPCAxMjggPyAxIDogYyA8IDIwNDggPyAyIDogYyA8IDY1NTM2ID8gMyA6IDQ7CiAgICAgICAgfQogICAgICAgIGJ1ZiA9IG5ldyB1dGlscy5CdWY4KGJ1Zl9sZW4pOwogICAgICAgIGZvciAoaSA9IDAsIG1fcG9zID0gMDsgaSA8IGJ1Zl9sZW47IG1fcG9zKyspIHsKICAgICAgICAgIGMgPSBzdHIuY2hhckNvZGVBdChtX3Bvcyk7CiAgICAgICAgICBpZiAoKGMgJiA2NDUxMikgPT09IDU1Mjk2ICYmIG1fcG9zICsgMSA8IHN0cl9sZW4pIHsKICAgICAgICAgICAgYzIgPSBzdHIuY2hhckNvZGVBdChtX3BvcyArIDEpOwogICAgICAgICAgICBpZiAoKGMyICYgNjQ1MTIpID09PSA1NjMyMCkgewogICAgICAgICAgICAgIGMgPSA2NTUzNiArIChjIC0gNTUyOTYgPDwgMTApICsgKGMyIC0gNTYzMjApOwogICAgICAgICAgICAgIG1fcG9zKys7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChjIDwgMTI4KSB7CiAgICAgICAgICAgIGJ1ZltpKytdID0gYzsKICAgICAgICAgIH0gZWxzZSBpZiAoYyA8IDIwNDgpIHsKICAgICAgICAgICAgYnVmW2krK10gPSAxOTIgfCBjID4+PiA2OwogICAgICAgICAgICBidWZbaSsrXSA9IDEyOCB8IGMgJiA2MzsKICAgICAgICAgIH0gZWxzZSBpZiAoYyA8IDY1NTM2KSB7CiAgICA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sZW5ndGgpOwogICAgICB9OwogICAgICBleHBvcnRzMi5iaW5zdHJpbmcyYnVmID0gZnVuY3Rpb24oc3RyKSB7CiAgICAgICAgdmFyIGJ1ZiA9IG5ldyB1dGlscy5CdWY4KHN0ci5sZW5ndGgpOwogICAgICAgIGZvciAodmFyIGkgPSAwLCBsZW4gPSBidWYubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHsKICAgICAgICAgIGJ1ZltpXSA9IHN0ci5jaGFyQ29kZUF0KGkpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gYnVmOwogICAgICB9OwogICAgICBleHBvcnRzMi5idWYyc3RyaW5nID0gZnVuY3Rpb24oYnVmLCBtYXgpIHsKICAgICAgICB2YXIgaSwgb3V0LCBjLCBjX2xlbjsKICAgICAgICB2YXIgbGVuID0gbWF4IHx8IGJ1Zi5sZW5ndGg7CiAgICAgICAgdmFyIHV0ZjE2YnVmID0gbmV3IEFycmF5KGxlbiAqIDIpOwogICAgICAgIGZvciAob3V0ID0gMCwgaSA9IDA7IGkgPCBsZW47ICkgewogICAgICAgICAgYyA9IGJ1ZltpKytdOwogICAgICAgICAgaWYgKGMgPCAxMjgpIHsKICAgICAgICAgICAgdXRmMTZidWZbb3V0KytdID0gYzsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBjX2xlbiA9IF91dGY4bGVuW2NdOwogICAgICAgICAgaWYgKGNfbGVuID4gNCkgewogICAgICAgICAgICB1dGYxNmJ1ZltvdXQrK10gPSA2NTUzMzsKICAgICAgICAgICAgaSArPSBjX2xlbiAtIDE7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgYyAmPSBjX2xlbiA9PT0gMiA/IDMxIDogY19sZW4gPT09IDMgPyAxNSA6IDc7CiAgICAgICAgICB3aGlsZSAoY19sZW4gPiAxICYmIGkgPCBsZW4pIHsKICAgICAgICAgICAgYyA9IGMgPDwgNiB8IGJ1ZltpKytdICYgNjM7CiAgICAgICAgICAgIGNfbGVuLS07CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoY19sZW4gPiAxKSB7CiAgICAgICAgICAgIHV0ZjE2YnVmW291dCsrXSA9IDY1NTMzOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChjIDwgNjU1MzYpIHsKICAgICAgICAgICAgdXRmMTZidWZbb3V0KytdID0gYzsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGMgLT0gNjU1MzY7CiAgICAgICAgICAgIHV0ZjE2YnVmW291dCsrXSA9IDU1Mjk2IHwgYyA+PiAxMCAmIDEwMjM7CiAgICAgICAgICAgIHV0ZjE2YnVmW291dCsrXSA9IDU2MzIwIHwgYyAmIDEwMjM7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiBidWYyYmluc3RyaW5nKHV0ZjE2YnVmLCBvdXQpOwogICAgICB9OwogICAgICBleHBvcnRzMi51dGY4Ym9yZGVyID0gZnVuY3Rpb24oYnVmLCBtYXgpIHsKICAgICAgICB2YXIgcG9zOwogICAgICAgIG1heCA9IG1heCB8fCBidWYubGVuZ3RoOwogICAgICAgIGlmIChtYXggPiBidWYubGVuZ3RoKSB7CiAgICAgICAgICBtYXggPSBidWYubGVuZ3RoOwogICAgICAgIH0KICAgICAgICBwb3MgPSBtYXggLSAxOwogICAgICAgIHdoaWxlIChwb3MgPj0gMCAmJiAoYnVmW3Bvc10gJiAxOTIpID09PSAxMjgpIHsKICAgICAgICAgIHBvcy0tOwogICAgICAgIH0KICAgICAgICBpZiAocG9zIDwgMCkgewogICAgICAgICAgcmV0dXJuIG1heDsKICAgICAgICB9CiAgICAgICAgaWYgKHBvcyA9PT0gMCkgewogICAgICAgICAgcmV0dXJuIG1heDsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHBvcyArIF91dGY4bGVuW2J1Zltwb3NdXSA+IG1heCA/IHBvcyA6IG1heDsKICAgICAgfTsKICAgIH0KICB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Rvd0JpdHMgPiAwKSB7CiAgICAgICAgICBvcHQud2luZG93Qml0cyA9IC1vcHQud2luZG93Qml0czsKICAgICAgICB9IGVsc2UgaWYgKG9wdC5nemlwICYmIG9wdC53aW5kb3dCaXRzID4gMCAmJiBvcHQud2luZG93Qml0cyA8IDE2KSB7CiAgICAgICAgICBvcHQud2luZG93Qml0cyArPSAxNjsKICAgICAgICB9CiAgICAgICAgdGhpcy5lcnIgPSAwOwogICAgICAgIHRoaXMubXNnID0gIiI7CiAgICAgICAgdGhpcy5lbmRlZCA9IGZhbHNlOwogICAgICAgIHRoaXMuY2h1bmtzID0gW107CiAgICAgICAgdGhpcy5zdHJtID0gbmV3IFpTdHJlYW0oKTsKICAgICAgICB0aGlzLnN0cm0uYXZhaWxfb3V0ID0gMDsKICAgICAgICB2YXIgc3RhdHVzID0gemxpYl9kZWZsYXRlLmRlZmxhdGVJbml0Mih0aGlzLnN0cm0sIG9wdC5sZXZlbCwgb3B0Lm1ldGhvZCwgb3B0LndpbmRvd0JpdHMsIG9wdC5tZW1MZXZlbCwgb3B0LnN0cmF0ZWd5KTsKICAgICAgICBpZiAoc3RhdHVzICE9PSBaX09LKSB7CiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IobXNnW3N0YXR1c10pOwogICAgICAgIH0KICAgICAgICBpZiAob3B0LmhlYWRlcikgewogICAgICAgICAgemxpYl9kZWZsYXRlLmRlZmxhdGVTZXRIZWFkZXIodGhpcy5zdHJtLCBvcHQuaGVhZGVyKTsKICAgICAgICB9CiAgICAgICAgaWYgKG9wdC5kaWN0aW9uYXJ5KSB7CiAgICAgICAgICB2YXIgZGljdDsKICAgICAgICAgIGlmICh0eXBlb2Ygb3B0LmRpY3Rpb25hcnkgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgIGRpY3QgPSBzdHJpbmdzLnN0cmluZzJidWYob3B0LmRpY3Rpb25hcnkpOwogICAgICAgICAgfSBlbHNlIGlmICh0b1N0cmluZzIuY2FsbChvcHQuZGljdGlvbmFyeSkgPT09ICJbb2JqZWN0IEFycmF5QnVmZmVyXSIpIHsKICAgICAgICAgICAgZGljdCA9IG5ldyBVaW50OEFycmF5KG9wdC5kaWN0aW9uYXJ5KTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGRpY3QgPSBvcHQuZGljdGlvbmFyeTsKICAgICAgICAgIH0KICAgICAgICAgIHN0YXR1cyA9IHpsaWJfZGVmbGF0ZS5kZWZsYXRlU2V0RGljdGlvbmFyeSh0aGlzLnN0cm0sIGRpY3QpOwogICAgICAgICAgaWYgKHN0YXR1cyAhPT0gWl9PSykgewogICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IobXNnW3N0YXR1c10pOwogICAgICAgICAgfQogICAgICAgICAgdGhpcy5fZGljdF9zZXQgPSB0cnVlOwogICAgICAgIH0KICAgICAgfQogICAgICBEZWZsYXRlLnByb3RvdHlwZS5wdXNoID0gZnVuY3Rpb24oZGF0YSwgbW9kZSkgewogICAgICAgIHZhciBzdHJtID0gdGhpcy5zdHJtOwogICAgICAgIHZhciBjaHVua1NpemUgPSB0aGlzLm9wdGlvbnMuY2h1bmtTaXplOwogICAgICAgIHZhciBzdGF0dXMsIF9tb2RlOwogICAgICAgIGlmICh0aGlzLmVuZGVkKSB7CiAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfQogICAgICAgIF9tb2RlID0gbW9kZSA9PT0gfn5tb2RlID8gbW9kZSA6IG1vZGUgPT09IHRydWUgPyBaX0ZJTklTSCA6IFpfTk9fRkxVU0g7CiAgICAgICAgaWYgKHR5cGVvZiBkYXRhID09PSAic3RyaW5nIikgewogICAgICAgICAgc3RybS5pbnB1dCA9IHN0cmluZ3Muc3RyaW5nMmJ1ZihkYXRhKTsKICAgICAgICB9IGVsc2UgaWYgKHRvU3RyaW5nMi5jYWxsKGRhdGEpID09PSAiW29iamVjdCBBcnJheUJ1ZmZlcl0iKSB7CiAgICAgICAgICBzdHJtLmlucHV0ID0gbmV3IFVpbnQ4QXJyYXkoZGF0YSk7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHN0cm0uaW5wdXQgPSBkYXRhOwogICAgICAgIH0KICAgICAgICBzdHJtLm5leHRfaW4gPSAwOwogICAgICAgIHN0cm0uYXZhaWxfaW4gPSBzdHJtLmlucHV0Lmxlbmd0aDsKICAgICAgICBkbyB7CiAgICAgICAgICBpZiAoc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgc3RybS5vdXRwdXQgPSBuZXcgdXRpbHMuQnVmOChjaHVua1NpemUpOwogICAgICAgICAgICBzdHJtLm5leHRfb3V0ID0gMDsKICAgICAgICAgICAgc3RybS5hdmFpbF9vdXQgPSBjaHVua1NpemU7CiAgICAgICAgICB9CiAgICAgICAgICBzdGF0dXMgPSB6bGliX2RlZmxhdGUuZGVmbGF0ZShzdHJtLCBfbW9kZSk7CiAgICAgICAgICBpZiAoc3RhdHVzICE9PSBaX1NUUkVBTV9FTkQgJiYgc3RhdHVzICE9PSBaX09LKSB7CiAgICAgICAgICAgIHRoaXMub25FbmQoc3RhdHVzKTsKICAgICAgICAgICAgdGhpcy5lbmRlZCA9IHRydWU7CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChzdHJtLmF2YWlsX291dCA9PT0gMCB8fCBzdHJtLmF2YWlsX2luID09PSAwICYmIChfbW9kZSA9PT0gWl9GSU5JU0ggfHwgX21vZGUgPT09IFpfU1lOQ19GTFVTSDIpKSB7CiAgICAgICAgICAgIGlmICh0aGlzLm9wdGlvbnMudG8gPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgdGhpcy5vbkRhdGEoc3RyaW5ncy5idWYyYmluc3RyaW5nKHV0aWxzLnNocmlua0J1ZihzdHJtLm91dHB1dCwgc3RybS5uZXh0X291dCkpKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICB0aGlzLm9uRGF0YSh1dGlscy5zaHJpbmtCdWYoc3RybS5vdXRwdXQsIHN0cm0ubmV4dF9vdXQpKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gd2hpbGUgKChzdHJtLmF2YWlsX2luID4gMCB8fCBzdHJtLmF2YWlsX291dCA9PT0gMCkgJiYgc3RhdHVzICE9PSBaX1NUUkVBTV9FTkQpOwogICAgICAgIGlmIChfbW9kZSA9PT0gWl9GSU5JU0gpIHsKICAgICAgICAgIHN0YXR1cyA9IHpsaWJfZGVmbGF0ZS5kZWZsYXRlRW5kKHRoaXMuc3RybSk7CiAgICAgICAgICB0aGlzLm9uRW5kKHN0YXR1cyk7CiAgICAgICAgICB0aGlzLmVuZGVkID0gdHJ1ZTsKICAgICAgICAgIHJldHVybiBzdGF0dXMgPT09IFpfT0s7CiAgICAgICAgfQogICAgICAgIGlmIChfbW9kZSA9PT0gWl9TWU5DX0ZMVVNIMikgewogICAgICAgICAgdGhpcy5vbkVuZChaX09LKTsKICAgICAgICAgIHN0cm0uYXZhaWxfb3V0ID0gMDsKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfTsKICAgICAgRGVmbGF0ZS5wcm90b3R5cGUub25EYXRhID0gZnVuY3Rpb24oY2h1bmspIHsKICAgICAgICB0aGlzLmNodW5rcy5wdXNoKGNodW5rKTsKICAgICAgfTsKICAgICAgRGVmbGF0ZS5wcm90b3R5cGUub25FbmQgPSBmdW5jdGlvbihzdGF0dXMpIHsKICAgICAgICBpZiAoc3RhdHVzID09PSBaX09LKSB7CiAgICAgICAgICBpZiAodGhpcy5vcHRpb25zLnRvID09PSAic3RyaW5nIikgewogICAgICAgICAgICB0aGlzLnJlc3VsdCA9IHRoaXMuY2h1bmtzLmpvaW4oIiIpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgdGhpcy5yZXN1bHQgPSB1dGlscy5mbGF0dGVuQ2h1bmtzKHRoaXMuY2h1bm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HVsZXMvcGFrby9saWIvemxpYi9pbmZmYXN0LmpzCiAgdmFyIHJlcXVpcmVfaW5mZmFzdCA9IF9fY29tbW9uSlMoewogICAgIm5vZGVfbW9kdWxlcy9wYWtvL2xpYi96bGliL2luZmZhc3QuanMiKGV4cG9ydHMyLCBtb2R1bGUyKSB7CiAgICAgIGluaXRfYnVmZmVyX3NoaW0oKTsKICAgICAgInVzZSBzdHJpY3QiOwogICAgICB2YXIgQkFEID0gMzA7CiAgICAgIHZhciBUWVBFID0gMTI7CiAgICAgIG1vZHVsZTIuZXhwb3J0cyA9IGZ1bmN0aW9uIGluZmxhdGVfZmFzdChzdHJtLCBzdGFydCkgewogICAgICAgIHZhciBzdGF0ZTsKICAgICAgICB2YXIgX2luOwogICAgICAgIHZhciBsYXN0OwogICAgICAgIHZhciBfb3V0OwogICAgICAgIHZhciBiZWc7CiAgICAgICAgdmFyIGVuZDsKICAgICAgICB2YXIgZG1heDsKICAgICAgICB2YXIgd3NpemU7CiAgICAgICAgdmFyIHdoYXZlOwogICAgICAgIHZhciB3bmV4dDsKICAgICAgICB2YXIgc193aW5kb3c7CiAgICAgICAgdmFyIGhvbGQ7CiAgICAgICAgdmFyIGJpdHM7CiAgICAgICAgdmFyIGxjb2RlOwogICAgICAgIHZhciBkY29kZTsKICAgICAgICB2YXIgbG1hc2s7CiAgICAgICAgdmFyIGRtYXNrOwogICAgICAgIHZhciBoZXJlOwogICAgICAgIHZhciBvcDsKICAgICAgICB2YXIgbGVuOwogICAgICAgIHZhciBkaXN0OwogICAgICAgIHZhciBmcm9tOwogICAgICAgIHZhciBmcm9tX3NvdXJjZTsKICAgICAgICB2YXIgaW5wdXQsIG91dHB1dDsKICAgICAgICBzdGF0ZSA9IHN0cm0uc3RhdGU7CiAgICAgICAgX2luID0gc3RybS5uZXh0X2luOwogICAgICAgIGlucHV0ID0gc3RybS5pbnB1dDsKICAgICAgICBsYXN0ID0gX2luICsgKHN0cm0uYXZhaWxfaW4gLSA1KTsKICAgICAgICBfb3V0ID0gc3RybS5uZXh0X291dDsKICAgICAgICBvdXRwdXQgPSBzdHJtLm91dHB1dDsKICAgICAgICBiZWcgPSBfb3V0IC0gKHN0YXJ0IC0gc3RybS5hdmFpbF9vdXQpOwogICAgICAgIGVuZCA9IF9vdXQgKyAoc3RybS5hdmFpbF9vdXQgLSAyNTcpOwogICAgICAgIGRtYXggPSBzdGF0ZS5kbWF4OwogICAgICAgIHdzaXplID0gc3RhdGUud3NpemU7CiAgICAgICAgd2hhdmUgPSBzdGF0ZS53aGF2ZTsKICAgICAgICB3bmV4dCA9IHN0YXRlLnduZXh0OwogICAgICAgIHNfd2luZG93ID0gc3RhdGUud2luZG93OwogICAgICAgIGhvbGQgPSBzdGF0ZS5ob2xkOwogICAgICAgIGJpdHMgPSBzdGF0ZS5iaXRzOwogICAgICAgIGxjb2RlID0gc3RhdGUubGVuY29kZTsKICAgICAgICBkY29kZSA9IHN0YXRlLmRpc3Rjb2RlOwogICAgICAgIGxtYXNrID0gKDEgPDwgc3RhdGUubGVuYml0cykgLSAxOwogICAgICAgIGRtYXNrID0gKDEgPDwgc3RhdGUuZGlzdGJpdHMpIC0gMTsKICAgICAgICB0b3A6CiAgICAgICAgICBkbyB7CiAgICAgICAgICAgIGlmIChiaXRzIDwgMTUpIHsKICAgICAgICAgICAgICBob2xkICs9IGlucHV0W19pbisrXSA8PCBiaXRzOwogICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICBob2xkICs9IGlucHV0W19pbisrXSA8PCBiaXRzOwogICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgfQogICAgICAgICAgICBoZXJlID0gbGNvZGVbaG9sZCAmIGxtYXNrXTsKICAgICAgICAgICAgZG9sZW46CiAgICAgICAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICAgICAgICBvcCA9IGhlcmUgPj4+IDI0OwogICAgICAgICAgICAgICAgaG9sZCA+Pj49IG9wOwogICAgICAgICAgICAgICAgYml0cyAtPSBvcDsKICAgICAgICAgICAgICAgIG9wID0gaGVyZSA+Pj4gMTYgJiAyNTU7CiAgICAgICAgICAgICAgICBpZiAob3AgPT09IDApIHsKICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBoZXJlICYgNjU1MzU7CiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG9wICYgMTYpIHsKICAgICAgICAgICAgICAgICAgbGVuID0gaGVyZSAmIDY1NTM1OwogICAgICAgICAgICAgICAgICBvcCAmPSAxNTsKICAgICAgICAgICAgICAgICAgaWYgKG9wKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGJpdHMgPCBvcCkgewogICAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtfaW4rK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgbGVuICs9IGhvbGQgJiAoMSA8PCBvcCkgLSAxOwogICAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBvcDsKICAgICAgICAgICAgICAgICAgICBiaXRzIC09IG9wOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChiaXRzIDwgMTUpIHsKICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W19pbisrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W19pbisrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoZXJlID0gZGNvZGVbaG9sZCAmIGRtYXNrXTsKICAgICAgICAgICAgICAgICAgZG9kaXN0OgogICAgICAgICAgICAgICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgICAgICAgICAgICAgb3AgPSBoZXJlID4+PiAyNDsKICAgICAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBvcDsKICAgICAgICAgICAgICAgICAgICAgIGJpdHMgLT0gb3A7CiAgICAgICAgICAgICAgICAgICAgICBvcCA9IGhlcmUgPj4+IDE2ICYgMjU1OwogICAgICAgICAgICAgICAgICAgICAgaWYgKG9wICYgMTYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGlzdCA9IGhlcmUgJiA2NTUzNTsKICAgICAgICAgICAgICAgICAgICAgICAgb3AgJj0gMTU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiaXRzIDwgb3ApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W19pbisrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYml0cyA8IG9wKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W19pbisrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBkaXN0ICs9IGhvbGQgJiAoMSA8PCBvcCkgLSAxOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGlzdCA+IGRtYXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGRpc3RhbmNlIHRvbyBmYXIgYmFjayI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhayB0b3A7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IG9wOwogICAgICAgICAgICAgICAgICAgICAgICBiaXRzIC09IG9wOwogICAgICAgICAgICAgICAgICAgICAgICBvcCA9IF9vdXQgLSBiZWc7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkaXN0ID4gb3ApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICBvcCA9IGRpc3QgLSBvcDsKICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3AgPiB3aGF2ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLnNhbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBkaXN0YW5jZSB0b28gZmFyIGJhY2siOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhayB0b3A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgIGZyb20gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgIGZyb21fc291cmNlID0gc193aW5kb3c7CiAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHduZXh0ID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tICs9IHdzaXplIC0gb3A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3AgPCBsZW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuIC09IG9wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBzX3dpbmRvd1tmcm9tKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IHdoaWxlICgtLW9wKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbSA9IF9vdXQgLSBkaXN0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tX3NvdXJjZSA9IG91dHB1dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHduZXh0IDwgb3ApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyb20gKz0gd3NpemUgKyB3bmV4dCAtIG9wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3AgLT0gd25leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3AgPCBsZW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuIC09IG9wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBzX3dpbmRvd1tmcm9tKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IHdoaWxlICgtLW9wKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3bmV4dCA8IGxlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wID0gd25leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuIC09IG9wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gc193aW5kb3dbZnJvbSsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IHdoaWxlICgtLW9wKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tID0gX291dCAtIGRpc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbV9zb3VyY2UgPSBvdXRwdXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbSArPSB3bmV4dCAtIG9wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wIDwgbGVuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlbiAtPSBvcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gc193aW5kb3dbZnJvbSsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSB3aGlsZSAoLS1vcCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyb20gPSBfb3V0IC0gZGlzdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbV9zb3VyY2UgPSBvdXRwdXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChsZW4gPiAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IGZyb21fc291cmNlW2Zyb20rK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IGZyb21fc291cmNlW2Zyb20rK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IGZyb21fc291cmNlW2Zyb20rK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW4gLT0gMzsKICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBmcm9tX3NvdXJjZVtmcm9tKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxlbiA+IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBmcm9tX3NvdXJjZVtmcm9tKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tID0gX291dCAtIGRpc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBvdXRwdXRbZnJvbSsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gb3V0cHV0W2Zyb20rK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IG91dHB1dFtmcm9tKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuIC09IDM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgfSB3aGlsZSAobGVuID4gMik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBvdXRwdXRbZnJvbSsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsZW4gPiAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gb3V0cHV0W2Zyb20rK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKChvcCAmIDY0KSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICBoZXJlID0gZGNvZGVbKGhlcmUgJiA2NTUzNSkgKyAoaG9sZCAmICgxIDw8IG9wKSAtIDEpXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWUgZG9kaXN0OwogICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBkaXN0YW5jZSBjb2RlIjsKICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWsgdG9wOwogICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSBlbHNlIGlmICgob3AgJiA2NCkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgaGVyZSA9IGxjb2RlWyhoZXJlICYgNjU1MzUpICsgKGhvbGQgJiAoMSA8PCBvcCkgLSAxKV07CiAgICAgICAgICAgICAgICAgIGNvbnRpbnVlIGRvbGVuOwogICAgICAgICAgICAgICAgfSBlbHNlIGlmIChvcCAmIDMyKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBUWVBFOwogICAgICAgICAgICAgICAgICBicmVhayB0b3A7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGxpdGVyYWwvbGVuZ3RoIGNvZGUiOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICBicmVhayB0b3A7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICB9IHdoaWxlIChfaW4gPCBsYXN0ICYmIF9vdXQgPCBlbmQpOwogICAgICAgIGxlbiA9IGJpdHMgPj4gMzsKICAgICAgICBfaW4gLT0gbGVuOwogICAgICAgIGJpdHMgLT0gbGVuIDw8IDM7CiAgICAgICAgaG9sZCAmPSAoMSA8PCBiaXRzKSAtIDE7CiAgICAgICAgc3RybS5uZXh0X2luID0gX2luOwogICAgICAgIHN0cm0ubmV4dF9vdXQgPSBfb3V0OwogICAgICAgIHN0cm0uYXZhaWxfaW4gPSBfaW4gPCBsYXN0ID8gNSArIChsYXN0IC0gX2luKSA6IDUgLSAoX2luIC0gbGFzdCk7CiAgICAgICAgc3RybS5hdmFpbF9vdXQgPSBfb3V0IDwgZW5kID8gMjU3ICsgKGVuZCAtIF9vdXQpIDogMjU3IC0gKF9vdXQgLSBlbmQpOwogICAgICAgIHN0YXRlLmhvbGQgPSBob2xkOwogICAgICAgIHN0YXRlLmJpdHMgPSBiaXRzOwogICAgICAgIHJldHVybjsKICAgICAgfTsKICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvaW5mdHJlZXMuanMKICB2YXIgcmVxdWlyZV9pbmZ0cmVlcyA9IF9fY29tbW9uSlMoewogICAgIm5vZGVfbW9kdWxlcy9wYWtvL2xpYi96bGliL2luZnRyZWVzLmpzIihleHBvcnRzMiwgbW9kdWxlMikgewogICAgICBpbml0X2J1ZmZlcl9zaGltKCk7CiAgICAgICJ1c2Ugc3RyaWN0IjsKICAgICAgdmFyIHV0aWxzID0gcmVxdWlyZV9jb21tb24oKTsKICAgICAgdmFyIE1BWEJJVFMgPSAxNTsKICAgICAgdmFyIEVOT1VHSF9MRU5TID0gODUyOwogICAgICB2YXIgRU5PVUdIX0RJU1RTID0gNTkyOwogICAgICB2YXIgQ09ERVMgPSAwOwogICAgICB2YXIgTEVOUyA9IDE7CiAgICAgIHZhciBESVNUUyA9IDI7CiAgICAgIHZhciBsYmFzZSA9IFsKICAgICAgICAzLAogICAgICAgIDQsCiAgICAgICAgNSwKICAgICAgICA2LAogICAgICAgIDcsCiAgICAgICAgOCwKICAgICAgICA5LAogICAgICAgIDEwLAogICAgICAgIDExLAogICAgICAgIDEzLAogICAgICAgIDE1LAogICAgICAgIDE3LAogICAgICAgIDE5LAogICAgICAgIDIzLAogICAgICAgIDI3LAogICAgICAgIDMxLAogICAgICAgIDM1LAogICAgICAgIDQzLAogICAgICAgIDUxLAogICAgICAgIDU5LAogICAgICAgIDY3LAogICAgICAgIDgzLAogICAgICAgIDk5LAogICAgICAgIDExNSwKICAgICAgICAxMzEsCiAgICAgICAgMTYzLAogICAgICAgIDE5NSwKICAgICAgICAyMjcsCiAgICAgICAgMjU4LAogICAgICAgIDAsCiAgICAgICAgMAogICAgICBdOwogICAgICB2YXIgbGV4dCA9IFsKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNywKICAgICAgICAxNywKICAgICAgICAxNywKICAgICAgICAxNywKICAgICAgICAxOCwKICAgICAgICAxOCwKICAgICAgICAxOCwKICAgICAgICAxOCwKICAgICAgICAxOSwKICAgICAgICAxOSwKICAgICAgICAxOSwKICAgICAgICAxOSwKICAgICAgICAyMCwKICAgICAgICAyMCwKICAgICAgICAyMCwKICAgICAgICAyMCwKICAgICAgICAyMSwKICAgICAgICAyMSwKICAgICAgICAyMSwKICAgICAgICAyMSwKICAgICAgICAxNiwKICAgICAgICA3MiwKICAgICAgICA3OAogICAgICBdOwogICAgICB2YXIgZGJhc2UgPSBbCiAgICAgICAgMSwKICAgICAgICAyLAogICAgICAgIDMsCiAgICAgICAgNCwKICAgICAgICA1LAogICAgICAgIDcsCiAgICAgICAgOSwKICAgICAgICAxMywKICAgICAgICAxNywKICAgICAgICAyNSwKICAgICAgICAzMywKICAgICAgICA0OSwKICAgICAgICA2NSwKICAgICAgICA5NywKICAgICAgICAxMjksCiAgICAgICAgMTkzLAogICAgICAgIDI1NywKICAgICAgICAzODUsCiAgICAgICAgNTEzLAogICAgICAgIDc2OSwKICAgICAgICAxMDI1LAogICAgICAgIDE1MzcsCiAgICAgICAgMjA0OSwKICAgICAgICAzMDczLAogICAgICAgIDQwOTcsCiAgICAgICAgNjE0NSwKICAgICAgICA4MTkzLAogICAgICAgIDEyMjg5LAogICAgICAgIDE2Mzg1LAogICAgICAgIDI0NTc3LAogICAgICAgIDAsCiAgICAgICAgMAogICAgICBdOwogICAgICB2YXIgZGV4dCA9IFsKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNywKICAgICAgICAxNywKICAgICAgICAxOCwKICAgICAgICAxOCwKICAgICAgICAxOSwKICAgICAgICAxOSwKICAgICAgICAyMCwKICAgICAgICAyMCwKICAgICAgICAyMSwKICAgICAgICAyMSwKICAgICAgICAyMiwKICAgICAgICAyMiwKICAgICAgICAyMywKICAgICAgICAyMywKICAgICAgICAyNCwKICAgICAgICAyNCwKICAgICAgICAyNSwKICAgICAgICAyNSwKICAgICAgICAyNiwKICAgICAgICAyNiwKICAgICAgICAyNywKICAgICAgICAyNywKICAgICAgICAyOCwKICAgICAgICAyOCwKICAgICAgICAyOSwKICAgICAgICAyOSwKICAgICAgICA2NCwKICAgICAgICA2NAogICAgICBdOwogICAgICBtb2R1bGUyLmV4cG9ydHMgPSBmdW5jdGlvbiBpbmZsYXRlX3RhYmxlKHR5cGUsIGxlbnMsIGxlbnNfaW5kZXgsIGNvZGVzLCB0YWJsZSwgdGFibGVfaW5kZXgsIHdvcmssIG9wdHMpIHsKICAgICAgICB2YXIgYml0cyA9IG9wdHMuYml0czsKICAgICAgICB2YXIgbGVuID0gMDsKICAgICAgICB2YXIgc3ltID0gMDsKICAgICAgICB2YXIgbWluID0gMCwgbWF4ID0gMDsKICAgICAgICB2YXIgcm9vdDIgPSAwOwogICAgICAgIHZhciBjdXJyID0gMDsKICAgICAgICB2YXIgZHJvcCA9IDA7CiAgICAgICAgdmFyIGxlZnQgPSAwOwogICAgICAgIHZhciB1c2VkID0gMDsKICAgICAgICB2YXIgaHVmZiA9IDA7CiAgICAgICAgdmFyIGluY3I7CiAgICAgICAgdmFyIGZpbGw7CiAgICAgICAgdmFyIGxvdzsKICAgICAgICB2YXIgbWFzazsKICAgICAgICB2YXIgbmV4dDsKICAgICAgICB2YXIgYmFzZSA9IG51bGw7CiAgICAgICAgdmFyIGJhc2VfaW5kZXggPSAwOwogICAgICAgIHZhciBlbmQ7CiAgICAgICAgdmFyIGNvdW50ID0gbmV3IHV0aWxzLkJ1ZjE2KE1BWEJJVFMgKyAxKTsKICAgICAgICB2YXIgb2ZmcyA9IG5ldyB1dGlscy5CdWYxNihNQVhCSVRTICsgMSk7CiAgICAgICAgdmFyIGV4dHJhID0gbnVsbDsKICAgICAgICB2YXIgZXh0cmFfaW5kZXggPSAwOwogICAgICAgIHZhciBoZXJlX2JpdHMsIGhlcmVfb3AsIGhlcmVfdmFsOwogICAgICAgIGZvciAobGVuID0gMDsgbGVuIDw9IE1BWEJJVFM7IGxlbisrKSB7CiAgICAgICAgICBjb3VudFtsZW5dID0gMDsKICAgICAgICB9CiAgICAgICAgZm9yIChzeW0gPSAwOyBzeW0gPCBjb2Rlczsgc3ltKyspIHsKICAgICAgICAgIGNvdW50W2xlbnNbbGVuc19pbmRleCArIHN5bV1dKys7CiAgICAgICAgfQogICAgICAgIHJvb3QyID0gYml0czsKICAgICAgICBmb3IgKG1heCA9IE1BWEJJVFM7IG1heCA+PSAxOyBtYXgtLSkgewogICAgICAgICAgaWYgKGNvdW50W21heF0gIT09IDApIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChyb290MiA+IG1heCkgewogICAgICAgICAgcm9vdDIgPSBtYXg7CiAgICAgICAgfQogICAgICAgIGlmIChtYXggPT09IDApIHsKICAgICAgICAgIHRhYmxlW3RhYmxlX2luZGV4KytdID0gMSA8PCAyNCB8IDY0IDw8IDE2IHwgMDsKICAgICAgICAgIHRhYmxlW3RhYmxlX2luZGV4KytdID0gMSA8PCAyNCB8IDY0IDw8IDE2IHwgMDsKICAgICAgICAgIG9wdHMuYml0cyA9IDE7CiAgICAgICAgICByZXR1cm4gMDsKICAgICAgICB9CiAgICAgICAgZm9yIChtaW4gPSAxOyBtaW4gPCBtYXg7IG1pbisrKSB7CiAgICAgICAgICBpZiAoY291bnRbbWluXSAhPT0gMCkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHJvb3QyIDwgbWluKSB7CiAgICAgICAgICByb290MiA9IG1pbjsKICAgICAgICB9CiAgICAgICAgbGVmdCA9IDE7CiAgICAgICAgZm9yIChsZW4gPSAxOyBsZW4gPD0gTUFYQklUUzsgbGVuKyspIHsKICAgICAgICAgIGxlZnQgPDw9IDE7CiAgICAgICAgICBsZWZ0IC09IGNvdW50W2xlbl07CiAgICAgICAgICBpZiAobGVmdCA8IDApIHsKICAgICAgICAgICAgcmV0dXJuIC0xOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAobGVmdCA+IDAgJiYgKHR5cGUgPT09IENPREVTIHx8IG1heCAhPT0gMSkpIHsKICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICB9CiAgICAgICAgb2Zmc1sxXSA9IDA7CiAgICAgICAgZm9yIChsZW4gPSAxOyBsZW4gPCBNQVhCSVRTOyBsZW4rKykgewogICAgICAgICAgb2Zmc1tsZW4gKyAxXSA9IG9mZnNbbGVuXSArIGNvdW50W2xlbl07CiAgICAgICAgfQogICAgICAgIGZvciAoc3ltID0gMDsgc3ltIDwgY29kZXM7IHN5bSsrKSB7CiAgICAgICAgICBpZiAobGVuc1tsZW5zX2luZGV4ICsgc3ltXSAhPT0gMCkgewogICAgICAgICAgICB3b3JrW29mZnNbbGVuc1tsZW5zX2luZGV4ICsgc3ltXV0rK10gPSBzeW07CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmICh0eXBlID09PSBDT0RFUykgewogICAgICAgICAgYmFzZSA9IGV4dHJhID0gd29yazsKICAgICAgICAgIGVuZCA9IDE5OwogICAgICAgIH0gZWxzZSBpZiAodHlwZSA9PT0gTEVOUykgewogICAgICAgICAgYmFzZSA9IGxiYXNlOwogICAgICAgICAgYmFzZV9pbmRleCAtPSAyNTc7CiAgICAgICAgICBleHRyYSA9IGxleHQ7CiAgICAgICAgICBleHRyYV9pbmRleCAtPSAyNTc7CiAgICAgICAgICBlbmQgPSAyNTY7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGJhc2UgPSBkYmFzZTsKICAgICAgICAgIGV4dHJhID0gZGV4dDsKICAgICAgICAgIGVuZCA9IC0xOwogICAgICAgIH0KICAgICAgICBodWZmID0gMDsKICAgICAgICBzeW0gPSAwOwogICAgICAgIGxlbiA9IG1pbjsKICAgICAgICBuZXh0ID0gdGFibGVfaW5kZXg7CiAgICAgICAgY3VyciA9IHJvb3QyOwogICAgICAgIGRyb3AgPSAwOwogICAgICAgIGxvdyA9IC0xOwogICAgICAgIHVzZWQgPSAxIDw8IHJvb3QyOwogICAgICAgIG1hc2sgPSB1c2VkIC0gMTsKICAgICAgICBpZiAodHlwZSA9PT0gTEVOUyAmJiB1c2VkID4gRU5PVUdIX0xFTlMgfHwgdHlwZSA9PT0gRElTVFMgJiYgdXNlZCA+IEVOT1VHSF9ESVNUUykgewogICAgICAgICAgcmV0dXJuIDE7CiAgICAgICAgfQogICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgaGVyZV9iaXRzID0gbGVuIC0gZHJvcDsKICAgICAgICAgIGlmICh3b3JrW3N5bV0gPCBlbmQpIHsKICAgICAgICAgICAgaGVyZV9vcCA9IDA7CiAgICAgICAgICAgIGhlcmVfdmFsID0gd29ya1tzeW1dOwogICAgICAgICAgfSBlbHNlIGlmICh3b3JrW3N5bV0gPiBlbmQpIHsKICAgICAgICAgICAgaGVyZV9vcCA9IGV4dHJhW2V4dHJhX2luZGV4ICsgd29ya1tzeW1dXTsKICAgICAgICAgICAgaGVyZV92YWwgPSBiYXNlW2Jhc2VfaW5kZXggKyB3b3JrW3N5bV1dOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgaGVyZV9vcCA9IDMyICsgNjQ7CiAgICAgICAgICAgIGhlcmVfdmFsID0gMDsKICAgICAgICAgIH0KICAgICAgICAgIGluY3IgPSAxIDw8IGxlbiAtIGRyb3A7CiAgICAgICAgICBmaWxsID0gMSA8PCBjdXJyOwogICAgICAgICAgbWluID0gZmlsbDsKICAgICAgICAgIGRvIHsKICAgICAgICAgICAgZmlsbCAtPSBpbmNyOwogICAgICAgICAgICB0YWJsZVtuZXh0ICsgKGh1ZmYgPj4gZHJvcCkgKyBmaWxsXSA9IGhlcmVfYml0cyA8PCAyNCB8IGhlcmVfb3AgPDwgMTYgfCBoZXJlX3ZhbCB8IDA7CiAgICAgICAgICB9IHdoaWxlIChmaWxsICE9PSAwKTsKICAgICAgICAgIGluY3IgPSAxIDw8IGxlbiAtIDE7CiAgICAgICAgICB3aGlsZSAoaHVmZiAmIGluY3IpIHsKICAgICAgICAgICAgaW5jciA+Pj0gMTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChpbmNyICE9PSAwKSB7CiAgICAgICAgICAgIGh1ZmYgJj0gaW5jciAtIDE7CiAgICAgICAgICAgIGh1ZmYgKz0gaW5jcjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGh1ZmYgPSAwOwogICAgICAgICAgfQogICAgICAgICAgc3ltKys7CiAgICAgICAgICBpZiAoLS1jb3VudFtsZW5dID09PSAwKSB7CiAgICAgICAgICAgIGlmIChsZW4gPT09IG1heCkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGxlbiA9IGxlbnNbbGVuc19pbmRleCArIHdvcmtbc3ltXV07CiAgICAgICAgICB9CiAgICAgICAgICBpZiAobGVuID4gcm9vdDIgJiYgKGh1ZmYgJiBtYXNrKSAhPT0gbG93KSB7CiAgICAgICAgICAgIGlmIChkcm9wID09PSAwKSB7CiAgICAgICAgICAgICAgZHJvcCA9IHJvb3QyOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG5leHQgKz0gbWluOwogICAgICAgICAgICBjdXJyID0gbGVuIC0gZHJvcDsKICAgICAgICAgICAgbGVmdCA9IDEgPDwgY3VycjsKICAgICAgICAgICAgd2hpbGUgKGN1cnIgKyBkcm9wIDwgbWF4KSB7CiAgICAgICAgICAgICAgbGVmdCAtPSBjb3VudFtjdXJyICsgZHJvcF07CiAgICAgICAgICAgICAgaWYgKGxlZnQgPD0gMCkgewogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGN1cnIrKzsKICAgICAgICAgICAgICBsZWZ0IDw8PSAxOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHVzZWQgKz0gMSA8PCBjdXJyOwogICAgICAgICAgICBpZiAodHlwZSA9PT0gTEVOUyAmJiB1c2VkID4gRU5PVUdIX0xFTlMgfHwgdHlwZSA9PT0gRElTVFMgJiYgdXNlZCA+IEVOT1VHSF9ESVNUUykgewogICAgICAgICAgICAgIHJldHVybiAxOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGxvdyA9IGh1ZmYgJiBtYXNrOwogICAgICAgICAgICB0YWJsZVtsb3ddID0gcm9vdDIgPDwgMjQgfCBjdXJyIDw8IDE2IHwgbmV4dCAtIHRhYmxlX2luZGV4IHwgMDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKGh1ZmYgIT09IDApIHsKICAgICAgICAgIHRhYmxlW25leHQgKyBodWZmXSA9IGxlbiAtIGRyb3AgPDwgMjQgfCA2NCA8PCAxNiB8IDA7CiAgICAgICAgfQogICAgICAgIG9wdHMuYml0cyA9IHJvb3QyOwogICAgICAgIHJldHVybiAwOwogICAgICB9OwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvcGFrby9saWIvemxpYi9pbmZsYXRlLmpzCiAgdmFyIHJlcXVpcmVfaW5mbGF0ZSA9IF9fY29tbW9uSlMoewogICAgIm5vZGVfbW9kdWxlcy9wYWtvL2xpYi96bGliL2luZmxhdGUuanMiKGV4cG9ydHMyKSB7CiAgICAgIGluaXRfYnVmZmVyX3NoaW0oKTsKICAgICAgInVzZSBzdHJpY3QiOwogICAgICB2YXIgdXRpbHMgPSByZXF1aXJlX2NvbW1vbigpOwogICAgICB2YXIgYWRsZXIzMiA9IHJlcXVpcmVfYWRsZXIzMigpOwogICAgICB2YXIgY3JjMzIgPSByZXF1aXJlX2NyYzMyKCk7CiAgICAgIHZhciBpbmZsYXRlX2Zhc3QgPSByZXF1aXJlX2luZmZhc3QoKTsKICAgICAgdmFyIGluZmxhdGVfdGFibGUgPSByZXF1aXJlX2luZnRyZWVzKCk7CiAgICAgIHZhciBDT0RFUyA9IDA7CiAgICAgIHZhciBMRU5TID0gMTsKICAgICAgdmFyIERJU1RTID0gMjsKICAgICAgdmFyIFpfRklOSVNIID0gNDsKICAgICAgdmFyIFpfQkxPQ0sgPSA1OwogICAgICB2YXIgWl9UUkVFUyA9IDY7CiAgICAgIHZhciBaX09LID0gMDsKICAgICAgdmFyIFpfU1RSRUFNX0VORCA9IDE7CiAgICAgIHZhciBaX05FRURfRElDVCA9IDI7CiAgICAgIHZhciBaX1NUUkVBTV9FUlJPUiA9IC0yOwogICAgICB2YXIgWl9EQVRBX0VSUk9SID0gLTM7CiAgICAgIHZhciBaX01FTV9FUlJPUiA9IC00OwogICAgICB2YXIgWl9CVUZfRVJST1IgPSAtNTsKICAgICAgdmFyIFpfREVGTEFURUQgPSA4OwogICAgICB2YXIgSEVBRCA9IDE7CiAgICAgIHZhciBGTEFHUyA9IDI7CiAgICAgIHZhciBUSU1FID0gMzsKICAgICAgdmFyIE9TID0gNDsKICAgICAgdmFyIEVYTEVOID0gNTsKICAgICAgdmFyIEVYVFJBID0gNjsKICAgICAgdmFyIE5BTUUgPSA3OwogICAgICB2YXIgQ09NTUVOVCA9IDg7CiAgICAgIHZhciBIQ1JDID0gOTsKICAgICAgdmFyIERJQ1RJRCA9IDEwOwogICAgICB2YXIgRElDVCA9IDExOwogICAgICB2YXIgVFlQRSA9IDEyOwogICAgICB2YXIgVFlQRURPID0gMTM7CiAgICAgIHZhciBTVE9SRUQgPSAxNDsKICAgICAgdmFyIENPUFlfID0gMTU7CiAgICAgIHZhciBDT1BZID0gMTY7CiAgICAgIHZhciBUQUJMRSA9IDE3OwogICAgICB2YXIgTEVOTEVOUyA9IDE4OwogICAgICB2YXIgQ09ERUxFTlMgPSAxOTsKICAgICAgdmFyIExFTl8gPSAyMDsKICAgICAgdmFyIExFTiA9IDIxOwogICAgICB2YXIgTEVORVhUID0gMjI7CiAgICAgIHZhciBESVNUID0gMjM7CiAgICAgIHZhciBESVNURVhUID0gMjQ7CiAgICAgIHZhciBNQVRDSCA9IDI1OwogICAgICB2YXIgTElUID0gMjY7CiAgICAgIHZhciBDSEVDSyA9IDI3OwogICAgICB2YXIgTEVOR1RIID0gMjg7CiAgICAgIHZhciBET05FID0gMjk7CiAgICAgIHZhciBCQUQgPSAzMDsKICAgICAgdmFyIE1FTSA9IDMxOwogICAgICB2YXIgU1lOQyA9IDMyOwogICAgICB2YXIgRU5PVUdIX0xFTlMgPSA4NTI7CiAgICAgIHZhciBFTk9VR0hfRElTVFMgPSA1OTI7CiAgICAgIHZhciBNQVhfV0JJVFMgPSAxNTsKICAgICAgdmFyIERFRl9XQklUUyA9IE1BWF9XQklUUzsKICAgICAgZnVuY3Rpb24genN3YXAzMihxKSB7CiAgICAgICAgcmV0dXJuIChxID4+PiAyNCAmIDI1NSkgKyAocSA+Pj4gOCAmIDY1MjgwKSArICgocSAmIDY1MjgwKSA8PCA4KSArICgocSAmIDI1NSkgPDwgMjQpOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIEluZmxhdGVTdGF0ZSgpIHsKICAgICAgICB0aGlzLm1vZGUgPSAwOwogICAgICAgIHRoaXMubGFzdCA9IGZhbHNlOwogICAgICAgIHRoaXMud3JhcCA9IDA7CiAgICAgICAgdGhpcy5oYXZlZGljdCA9IGZhbHNlOwogICAgICAgIHRoaXMuZmxhZ3MgPSAwOwogICAgICAgIHRoaXMuZG1heCA9IDA7CiAgICAgICAgdGhpcy5jaGVjayA9IDA7CiAgICAgICAgdGhpcy50b3RhbCA9IDA7CiAgICAgICAgdGhpcy5oZWFkID0gbnVsbDsKICAgICAgICB0aGlzLndiaXRzID0gMDsKICAgICAgICB0aGlzLndzaXplID0gMDsKICAgICAgICB0aGlzLndoYXZlID0gMDsKICAgICAgICB0aGlzLnduZXh0ID0gMDsKICAgICAgICB0aGlzLndpbmRvdyA9IG51bGw7CiAgICAgICAgdGhpcy5ob2xkID0gMDsKICAgICAgICB0aGlzLmJpdHMgPSAwOwogICAgICAgIHRoaXMubGVuZ3RoID0gMDsKICAgICAgICB0aGlzLm9mZnNldCA9IDA7CiAgICAgICAgdGhpcy5leHRyYSA9IDA7CiAgICAgICAgdGhpcy5sZW5jb2RlID0gbnVsbDsKICAgICAgICB0aGlzLmRpc3Rjb2RlID0gbnVsbDsKICAgICAgICB0aGlzLmxlbmJpdHMgPSAwOwogICAgICAgIHRoaXMuZGlzdGJpdHMgPSAwOwogICAgICAgIHRoaXMubmNvZGUgPSAwOwogICAgICAgIHRoaXMubmxlbiA9IDA7CiAgICAgICAgdGhpcy5uZGlzdCA9IDA7CiAgICAgICAgdGhpcy5oYXZlID0gMDsKICAgICAgICB0aGlzLm5leHQgPSBudWxsOwogICAgICAgIHRoaXMubGVucyA9IG5ldyB1dGlscy5CdWYxNigzMjApOwogICAgICAgIHRoaXMud29yayA9IG5ldyB1dGlscy5CdWYxNigyODgpOwogICAgICAgIHRoaXMubGVuZHluID0gbnVsbDsKICAgICAgICB0aGlzLmRpc3RkeW4gPSBudWxsOwogICAgICAgIHRoaXMuc2FuZSA9IDA7CiAgICAgICAgdGhpcy5iYWNrID0gMDsKICAgICAgICB0aGlzLndhcyA9IDA7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gaW5mbGF0ZVJlc2V0S2VlcChzdHJtKSB7CiAgICAgICAgdmFyIHN0YXRlOwogICAgICAgIGlmICghc3RybSB8fCAhc3RybS5zdGF0ZSkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk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sKICAgICAgICByZXR1cm4gaW5mbGF0ZVJlc2V0S2VlcChzdHJtKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBpbmZsYXRlUmVzZXQyKHN0cm0sIHdpbmRvd0JpdHMpIHsKICAgICAgICB2YXIgd3JhcDsKICAgICAgICB2YXIgc3RhdGU7CiAgICAgICAgaWYgKCFzdHJtIHx8ICFzdHJtLnN0YXRlKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIHN0YXRlID0gc3RybS5zdGF0ZTsKICAgICAgICBpZiAod2luZG93Qml0cyA8IDApIHsKICAgICAgICAgIHdyYXAgPSAwOwogICAgICAgICAgd2luZG93Qml0cyA9IC13aW5kb3dCaXRzOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB3cmFwID0gKHdpbmRvd0JpdHMgPj4gNCkgKyAxOwogICAgICAgICAgaWYgKHdpbmRvd0JpdHMgPCA0OCkgewogICAgICAgICAgICB3aW5kb3dCaXRzICY9IDE1OwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAod2luZG93Qml0cyAmJiAod2luZG93Qml0cyA8IDggfHwgd2luZG93Qml0cyA+IDE1KSkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgIH0KICAgICAgICBpZiAoc3RhdGUud2luZG93ICE9PSBudWxsICYmIHN0YXRlLndiaXRzICE9PSB3aW5kb3dCaXRzKSB7CiAgICAgICAgICBzdGF0ZS53aW5kb3cgPSBudWxsOwogICAgICAgIH0KICAgICAgICBzdGF0ZS53cmFwID0gd3JhcDsKICAgICAgICBzdGF0ZS53Yml0cyA9IHdpbmRvd0JpdHM7CiAgICAgICAgcmV0dXJuIGluZmxhdGVSZXNldChzdHJtKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBpbmZsYXRlSW5pdDIoc3RybSwgd2luZG93Qml0cykgewogICAgICAgIHZhciByZXQ7CiAgICAgICAgdmFyIHN0YXRlOwogICAgICAgIGlmICghc3RybSkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgIH0KICAgICAgICBzdGF0ZSA9IG5ldyBJbmZsYXRlU3RhdGUoKTsKICAgICAgICBzdHJtLnN0YXRlID0gc3RhdGU7CiAgICAgICAgc3RhdGUud2luZG93ID0gbnVsbDsKICAgICAgICByZXQgPSBpbmZsYXRlUmVzZXQyKHN0cm0sIHdpbmRvd0JpdHMpOwogICAgICAgIGlmIChyZXQgIT09IFpfT0spIHsKICAgICAgICAgIHN0cm0uc3RhdGUgPSBudWxsOwogICAgICAgIH0KICAgICAgICByZXR1cm4gcmV0OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGluZmxhdGVJbml0KHN0cm0pIHsKICAgICAgICByZXR1cm4gaW5mbGF0ZUluaXQyKHN0cm0sIERFRl9XQklUUyk7CiAgICAgIH0KICAgICAgdmFyIHZpcmdpbiA9IHRydWU7CiAgICAgIHZhciBsZW5maXg7CiAgICAgIHZhciBkaXN0Zml4OwogICAgICBmdW5jdGlvbiBmaXhlZHRhYmxlcyhzdGF0ZSkgewogICAgICAgIGlmICh2aXJnaW4pIHsKICAgICAgICAgIHZhciBzeW07CiAgICAgICAgICBsZW5maXggPSBuZXcgdXRpbHMuQnVmMzIoNTEyKTsKICAgICAgICAgIGRpc3RmaXggPSBuZXcgdXRpbHMuQnVmMzIoMzIpOwogICAgICAgICAgc3ltID0gMDsKICAgICAgICAgIHdoaWxlIChzeW0gPCAxNDQpIHsKICAgICAgICAgICAgc3RhdGUubGVuc1tzeW0rK10gPSA4OwogICAgICAgICAgfQogICAgICAgICAgd2hpbGUgKHN5bSA8IDI1NikgewogICAgICAgICAgICBzdGF0ZS5sZW5zW3N5bSsrXSA9IDk7CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3ltIDwgMjgwKSB7CiAgICAgICAgICAgIHN0YXRlLmxlbnNbc3ltKytdID0gNzsKICAgICAgICAgIH0KICAgICAgICAgIHdoaWxlIChzeW0gPCAyODgpIHsKICAgICAgICAgICAgc3RhdGUubGVuc1tzeW0rK10gPSA4OwogICAgICAgICAgfQogICAgICAgICAgaW5mbGF0ZV90YWJsZShMRU5TLCBzdGF0ZS5sZW5zLCAwLCAyODgsIGxlbmZpeCwgMCwgc3RhdGUud29yaywgeyBiaXRzOiA5IH0pOwogICAgICAgICAgc3ltID0gMDsKICAgICAgICAgIHdoaWxlIChzeW0gPCAzMikgewogICAgICAgICAgICBzdGF0ZS5sZW5zW3N5bSsrXSA9IDU7CiAgICAgICAgICB9CiAgICAgICAgICBpbmZsYXRlX3RhYmxlKERJU1RTLCBzdGF0ZS5sZW5zLCAwLCAzMiwgZGlzdGZpeCwgMCwgc3RhdGUud29yaywgeyBiaXRzOiA1IH0pOwogICAgICAgICAgdmlyZ2luID0gZmFsc2U7CiAgICAgICAgfQogICAgICAgIHN0YXRlLmxlbmNvZGUgPSBsZW5maXg7CiAgICAgICAgc3RhdGUubGVuYml0cyA9IDk7CiAgICAgICAgc3RhdGUuZGlzdGNvZGUgPSBkaXN0Zml4OwogICAgICAgIHN0YXRlLmRpc3RiaXRzID0gNTsKICAgICAgfQogICAgICBmdW5jdGlvbiB1cGRhdGV3aW5kb3coc3RybSwgc3JjLCBlbmQsIGNvcHkpIHsKICAgICAgICB2YXIgZGlzdDsKICAgICAgICB2YXIgc3RhdGUgPSBzdHJtLnN0YXRlOwogICAgICAgIGlmIChzdGF0ZS53aW5kb3cgPT09IG51bGwpIHsKICAgICAgICAgIHN0YXRlLndzaXplID0gMSA8PCBzdGF0ZS53Yml0czsKICAgICAgICAgIHN0YXRlLnduZXh0ID0gMDsKICAgICAgICAgIHN0YXRlLndoYXZlID0gMDsKICAgICAgICAgIHN0YXRlLndpbmRvdyA9IG5ldyB1dGlscy5CdWY4KHN0YXRlLndzaXplKTsKICAgICAgICB9CiAgICAgICAgaWYgKGNvcHkgPj0gc3RhdGUud3NpemUpIHsKICAgICAgICAgIHV0aWxzLmFycmF5U2V0KHN0YXRlLndpbmRvdywgc3JjLCBlbmQgLSBzdGF0ZS53c2l6ZSwgc3RhdGUud3NpemUsIDApOwogICAgICAgICAgc3RhdGUud25leHQgPSAwOwogICAgICAgICAgc3RhdGUud2hhdmUgPSBzdGF0ZS53c2l6ZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGlzdCA9IHN0YXRlLndzaXplIC0gc3RhdGUud25leHQ7CiAgICAgICAgICBpZiAoZGlzdCA+IGNvcHkpIHsKICAgICAgICAgICAgZGlzdCA9IGNvcHk7CiAgICAgICAgICB9CiAgICAgICAgICB1dGlscy5hcnJheVNldChzdGF0ZS53aW5kb3csIHNyYywgZW5kIC0gY29weSwgZGlzdCwgc3RhdGUud25leHQpOwogICAgICAgICAgY29weSAtPSBkaXN0OwogICAgICAgICAgaWYgKGNvcHkpIHsKICAgICAgICAgICAgdXRpbHMuYXJyYXlTZXQoc3RhdGUud2luZG93LCBzcmMsIGVuZCAtIGNvcHksIGNvcHksIDApOwogICAgICAgICAgICBzdGF0ZS53bmV4dCA9IGNvcHk7CiAgICAgICAgICAgIHN0YXRlLndoYXZlID0gc3RhdGUud3NpemU7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzdGF0ZS53bmV4dCArPSBkaXN0OwogICAgICAgICAgICBpZiAoc3RhdGUud25leHQgPT09IHN0YXRlLndzaXplKSB7CiAgICAgICAgICAgICAgc3RhdGUud25leHQgPSAwOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzdGF0ZS53aGF2ZSA8IHN0YXRlLndzaXplKSB7CiAgICAgICAgICAgICAgc3RhdGUud2hhdmUgKz0gZGlzdDsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gMDsKICAgICAgfQogICAgICBmdW5jdGlvbiBpbmZsYXRlKHN0cm0sIGZsdXNoKSB7CiAgICAgICAgdmFyIHN0YXRlOwogICAgICAgIHZhciBpbnB1dCwgb3V0cHV0OwogICAgICAgIHZhciBuZXh0OwogICAgICAgIHZhciBwdXQ7CiAgICAgICAgdmFyIGhhdmUsIGxlZnQ7CiAgICAgICAgdmFyIGhvbGQ7CiAgICAgICAgdmFyIGJpdHM7CiAgICAgICAgdmFyIF9pbiwgX291dDsKICAgICAgICB2YXIgY29weTsKICAgICAgICB2YXIgZnJvbTsKICAgICAgICB2YXIgZnJvbV9zb3VyY2U7CiAgICAgICAgdmFyIGhlcmUgPSAwOwogICAgICAgIHZhciBoZXJlX2JpdHMsIGhlcmVfb3AsIGhlcmVfdmFsOwogICAgICAgIHZhciBsYXN0X2JpdHMsIGxhc3Rfb3AsIGxhc3RfdmFsOwogICAgICAgIHZhciBsZW47CiAgICAgICAgdmFyIHJldDsKICAgICAgICB2YXIgaGJ1ZiA9IG5ldyB1dGlscy5CdWY4KDQpOwogICAgICAgIHZhciBvcHRzOwogICAgICAgIHZhciBuOwogICAgICAgIHZhciBvcmRlciA9IFsxNiwgMTcsIDE4LCAwLCA4LCA3LCA5LCA2LCAxMCwgNSwgMTEsIDQsIDEyLCAzLCAxMywgMiwgMTQsIDEsIDE1XTsKICAgICAgICBpZiAoIXN0cm0gfHwgIXN0cm0uc3RhdGUgfHwgIXN0cm0ub3V0cHV0IHx8ICFzdHJtLmlucHV0ICYmIHN0cm0uYXZhaWxfaW4gIT09IDApIHsKICAgICAgICAgIHJldHVybiBaX1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgc3RhdGUgPSBzdHJtLnN0YXRlOwogICAgICAgIGlmIChzdGF0ZS5tb2RlID09PSBUWVBFKSB7CiAgICAgICAgICBzdGF0ZS5tb2RlID0gVFlQRURPOwogICAgICAgIH0KICAgICAgICBwdXQgPSBzdHJtLm5leHRfb3V0OwogICAgICAgIG91dHB1dCA9IHN0cm0ub3V0cHV0OwogICAgICAgIGxlZnQgPSBzdHJtLmF2YWlsX291dDsKICAgICAgICBuZXh0ID0gc3RybS5uZXh0X2luOwogICAgICAgIGlucHV0ID0gc3RybS5pbnB1dDsKICAgICAgICBoYXZlID0gc3RybS5hdmFpbF9pbjsKICAgICAgICBob2xkID0gc3RhdGUuaG9sZDsKICAgICAgICBiaXRzID0gc3RhdGUuYml0czsKICAgICAgICBfaW4gPSBoYXZlOwogICAgICAgIF9vdXQgPSBsZWZ0OwogICAgICAgIHJldCA9IFpfT0s7CiAgICAgICAgaW5mX2xlYXZlOgogICAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICAgIHN3aXRjaCAoc3RhdGUubW9kZSkgewogICAgICAgICAgICAgIGNhc2UgSEVBRDoKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS53cmFwID09PSAwKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBUWVBFRE87CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAxNikgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUud3JhcCAmIDIgJiYgaG9sZCA9PT0gMzU2MTUpIHsKICAgICAgICAgICAgICAgICAgc3RhdGUuY2hlY2sgPSAwOwogICAgICAgICAgICAgICAgICBoYnVmWzBdID0gaG9sZCAmIDI1NTsKICAgICAgICAgICAgICAgICAgaGJ1ZlsxXSA9IGhvbGQgPj4+IDggJiAyNTU7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmNoZWNrID0gY3JjMzIoc3RhdGUuY2hlY2ssIGhidWYsIDIsIDApOwogICAgICAgICAgICAgICAgICBob2xkID0gMDsKICAgICAgICAgICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBGTEFHUzsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5mbGFncyA9IDA7CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuaGVhZCkgewogICAgICAgICAgICAgICAgICBzdGF0ZS5oZWFkLmRvbmUgPSBmYWxzZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmICghKHN0YXRlLndyYXAgJiAxKSB8fCAoKChob2xkICYgMjU1KSA8PCA4KSArIChob2xkID4+IDgpKSAlIDMxKSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImluY29ycmVjdCBoZWFkZXIgY2hlY2siOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmICgoaG9sZCAmIDE1KSAhPT0gWl9ERUZMQVRFRCkgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJ1bmtub3duIGNvbXByZXNzaW9uIG1ldGhvZCI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaG9sZCA+Pj49IDQ7CiAgICAgICAgICAgICAgICBiaXRzIC09IDQ7CiAgICAgICAgICAgICAgICBsZW4gPSAoaG9sZCAmIDE1KSArIDg7CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUud2JpdHMgPT09IDApIHsKICAgICAgICAgICAgICAgICAgc3RhdGUud2JpdHMgPSBsZW47CiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGxlbiA+IHN0YXRlLndiaXRzKSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgd2luZG93IHNpemUiOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLmRtYXggPSAxIDw8IGxlbjsKICAgICAgICAgICAgICAgIHN0cm0uYWRsZXIgPSBzdGF0ZS5jaGVjayA9IDE7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gaG9sZCAmIDUxMiA/IERJQ1RJRCA6IFRZUEU7CiAgICAgICAgICAgICAgICBob2xkID0gMDsKICAgICAgICAgICAgICAgIGJpdHMgPSAwOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSBGTEFHUzoKICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMTYpIHsKICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUuZmxhZ3MgPSBob2xkOwogICAgICAgICAgICAgICAgaWYgKChzdGF0ZS5mbGFncyAmIDI1NSkgIT09IFpfREVGTEFURUQpIHsKICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAidW5rbm93biBjb21wcmVzc2lvbiBtZXRob2QiOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDU3MzQ0KSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gInVua25vd24gaGVhZGVyIGZsYWdzIHNldCI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHsKICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC50ZXh0ID0gaG9sZCA+PiA4ICYgMTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDUxMikgewogICAgICAgICAgICAgICAgICBoYnVmWzBdID0gaG9sZCAmIDI1NTsKICAgICAgICAgICAgICAgICAgaGJ1ZlsxXSA9IGhvbGQgPj4+IDggJiAyNTU7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmNoZWNrID0gY3JjMzIoc3RhdGUuY2hlY2ssIGhidWYsIDIsIDApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICBiaXRzID0gMDsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBUSU1FOwogICAgICAgICAgICAgIGNhc2UgVElNRToKICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMzIpIHsKICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHsKICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC50aW1lID0gaG9sZDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDUxMikgewogICAgICAgICAgICAgICAgICBoYnVmWzBdID0gaG9sZCAmIDI1NTsKICAgICAgICAgICAgICAgICAgaGJ1ZlsxXSA9IGhvbGQgPj4+IDggJiAyNTU7CiAgICAgICAgICAgICAgICAgIGhidWZbMl0gPSBob2xkID4+PiAxNiAmIDI1NTsKICAgICAgICAgICAgICAgICAgaGJ1ZlszXSA9IGhvbGQgPj4+IDI0ICYgMjU1OwogICAgICAgICAgICAgICAgICBzdGF0ZS5jaGVjayA9IGNyYzMyKHN0YXRlLmNoZWNrLCBoYnVmLCA0LCAwKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGhvbGQgPSAwOwogICAgICAgICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gT1M7CiAgICAgICAgICAgICAgY2FzZSBPUzoKICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMTYpIHsKICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHsKICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC54ZmxhZ3MgPSBob2xkICYgMjU1OwogICAgICAgICAgICAgICAgICBzdGF0ZS5oZWFkLm9zID0gaG9sZCA+PiA4OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgNTEyKSB7CiAgICAgICAgICAgICAgICAgIGhidWZbMF0gPSBob2xkICYgMjU1OwogICAgICAgICAgICAgICAgICBoYnVmWzFdID0gaG9sZCA+Pj4gOCAmIDI1NTsKICAgICAgICAgICAgICAgICAgc3RhdGUuY2hlY2sgPSBjcmMzMihzdGF0ZS5jaGVjaywgaGJ1ZiwgMiwgMCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBob2xkID0gMDsKICAgICAgICAgICAgICAgIGJpdHMgPSAwOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEVYTEVOOwogICAgICAgICAgICAgIGNhc2UgRVhMRU46CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiAxMDI0KSB7CiAgICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMTYpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIHN0YXRlLmxlbmd0aCA9IGhvbGQ7CiAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5oZWFkKSB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC5leHRyYV9sZW4gPSBob2xkOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDUxMikgewogICAgICAgICAgICAgICAgICAgIGhidWZbMF0gPSBob2xkICYgMjU1OwogICAgICAgICAgICAgICAgICAgIGhidWZbMV0gPSBob2xkID4+PiA4ICYgMjU1OwogICAgICAgICAgICAgICAgICAgIHN0YXRlLmNoZWNrID0gY3JjMzIoc3RhdGUuY2hlY2ssIGhidWYsIDIsIDApOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGhvbGQgPSAwOwogICAgICAgICAgICAgICAgICBiaXRzID0gMDsKICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoc3RhdGUuaGVhZCkgewogICAgICAgICAgICAgICAgICBzdGF0ZS5oZWFkLmV4dHJhID0gbnVsbDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBFWFRSQTsKICAgICAgICAgICAgICBjYXNlIEVYVFJBOgogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgMTAyNCkgewogICAgICAgICAgICAgICAgICBjb3B5ID0gc3RhdGUubGVuZ3RoOwogICAgICAgICAgICAgICAgICBpZiAoY29weSA+IGhhdmUpIHsKICAgICAgICAgICAgICAgICAgICBjb3B5ID0gaGF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoY29weSkgewogICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5oZWFkKSB7CiAgICAgICAgICAgICAgICAgICAgICBsZW4gPSBzdGF0ZS5oZWFkLmV4dHJhX2xlbiAtIHN0YXRlLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgIGlmICghc3RhdGUuaGVhZC5leHRyYSkgewogICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5oZWFkLmV4dHJhID0gbmV3IEFycmF5KHN0YXRlLmhlYWQuZXh0cmFfbGVuKTsKICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgIHV0aWxzLmFycmF5U2V0KHN0YXRlLmhlYWQuZXh0cmEsIGlucHV0LCBuZXh0LCBjb3B5LCBsZW4pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiA1MTIpIHsKICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLmNoZWNrID0gY3JjMzIoc3RhdGUuY2hlY2ssIGlucHV0LCBjb3B5LCBuZXh0KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGF2ZSAtPSBjb3B5OwogICAgICAgICAgICAgICAgICAgIG5leHQgKz0gY29weTsKICAgICAgICAgICAgICAgICAgICBzdGF0ZS5sZW5ndGggLT0gY29weTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoc3RhdGUubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IE5BTUU7CiAgICAgICAgICAgICAgY2FzZSBOQU1FOgogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgMjA0OCkgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBjb3B5ID0gMDsKICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgIGxlbiA9IGlucHV0W25leHQgKyBjb3B5KytdOwogICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5oZWFkICYmIGxlbiAmJiBzdGF0ZS5sZW5ndGggPCA2NTUzNikgewogICAgICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC5uYW1lICs9IFN0cmluZy5mcm9tQ2hhckNvZGUobGVuKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKGxlbiAmJiBjb3B5IDwgaGF2ZSk7CiAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDUxMikgewogICAgICAgICAgICAgICAgICAgIHN0YXRlLmNoZWNrID0gY3JjMzIoc3RhdGUuY2hlY2ssIGlucHV0LCBjb3B5LCBuZXh0KTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlIC09IGNvcHk7CiAgICAgICAgICAgICAgICAgIG5leHQgKz0gY29weTsKICAgICAgICAgICAgICAgICAgaWYgKGxlbikgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzdGF0ZS5oZWFkKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmhlYWQubmFtZSA9IG51bGw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IENPTU1FTlQ7CiAgICAgICAgICAgICAgY2FzZSBDT01NRU5UOgogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgNDA5NikgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBjb3B5ID0gMDsKICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgIGxlbiA9IGlucHV0W25leHQgKyBjb3B5KytdOwogICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5oZWFkICYmIGxlbiAmJiBzdGF0ZS5sZW5ndGggPCA2NTUzNikgewogICAgICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC5jb21tZW50ICs9IFN0cmluZy5mcm9tQ2hhckNvZGUobGVuKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKGxlbiAmJiBjb3B5IDwgaGF2ZSk7CiAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDUxMikgewogICAgICAgICAgICAgICAgICAgIHN0YXRlLmNoZWNrID0gY3JjMzIoc3RhdGUuY2hlY2ssIGlucHV0LCBjb3B5LCBuZXh0KTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlIC09IGNvcHk7CiAgICAgICAgICAgICAgICAgIG5leHQgKz0gY29weTsKICAgICAgICAgICAgICAgICAgaWYgKGxlbikgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzdGF0ZS5oZWFkKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmhlYWQuY29tbWVudCA9IG51bGw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gSENSQzsKICAgICAgICAgICAgICBjYXNlIEhDUkM6CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiA1MTIpIHsKICAgICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAxNikgewogICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaWYgKGhvbGQgIT09IChzdGF0ZS5jaGVjayAmIDY1NTM1KSkgewogICAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImhlYWRlciBjcmMgbWlzbWF0Y2giOwogICAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICAgIGJpdHMgPSAwOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHsKICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC5oY3JjID0gc3RhdGUuZmxhZ3MgPj4gOSAmIDE7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmhlYWQuZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdHJtLmFkbGVyID0gc3RhdGUuY2hlY2sgPSAwOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IFRZUEU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIERJQ1RJRDoKICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMzIpIHsKICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RybS5hZGxlciA9IHN0YXRlLmNoZWNrID0genN3YXAzMihob2xkKTsKICAgICAgICAgICAgICAgIGhvbGQgPSAwOwogICAgICAgICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gRElDVDsKICAgICAgICAgICAgICBjYXNlIERJQ1Q6CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuaGF2ZWRpY3QgPT09IDApIHsKICAgICAgICAgICAgICAgICAgc3RybS5uZXh0X291dCA9IHB1dDsKICAgICAgICAgICAgICAgICAgc3RybS5hdmFpbF9vdXQgPSBsZWZ0OwogICAgICAgICAgICAgICAgICBzdHJtLm5leHRfaW4gPSBuZXh0OwogICAgICAgICAgICAgICAgICBzdHJtLmF2YWlsX2luID0gaGF2ZTsKICAgICAgICAgICAgICAgICAgc3RhdGUuaG9sZCA9IGhvbGQ7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmJpdHMgPSBiaXRzOwogICAgICAgICAgICAgICAgICByZXR1cm4gWl9ORUVEX0RJQ1Q7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdHJtLmFkbGVyID0gc3RhdGUuY2hlY2sgPSAxOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IFRZUEU7CiAgICAgICAgICAgICAgY2FzZSBUWVBFOgogICAgICAgICAgICAgICAgaWYgKGZsdXNoID09PSBaX0JMT0NLIHx8IGZsdXNoID09PSBaX1RSRUVTKSB7CiAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjYXNlIFRZUEVETzoKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5sYXN0KSB7CiAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBiaXRzICYgNzsKICAgICAgICAgICAgICAgICAgYml0cyAtPSBiaXRzICYgNzsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IENIRUNLOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMykgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5sYXN0ID0gaG9sZCAmIDE7CiAgICAgICAgICAgICAgICBob2xkID4+Pj0gMTsKICAgICAgICAgICAgICAgIGJpdHMgLT0gMTsKICAgICAgICAgICAgICAgIHN3aXRjaCAoaG9sZCAmIDMpIHsKICAgICAgICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBTVE9SRUQ7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgICAgICAgICBmaXhlZHRhYmxlcyhzdGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IExFTl87CiAgICAgICAgICAgICAgICAgICAgaWYgKGZsdXNoID09PSBaX1RSRUVTKSB7CiAgICAgICAgICAgICAgICAgICAgICBob2xkID4+Pj0gMjsKICAgICAgICAgICAgICAgICAgICAgIGJpdHMgLT0gMjsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gVEFCTEU7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgIGNhc2UgMzoKICAgICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGJsb2NrIHR5cGUiOwogICAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBob2xkID4+Pj0gMjsKICAgICAgICAgICAgICAgIGJpdHMgLT0gMjsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGNhc2UgU1RPUkVEOgogICAgICAgICAgICAgICAgaG9sZCA+Pj49IGJpdHMgJiA3OwogICAgICAgICAgICAgICAgYml0cyAtPSBiaXRzICYgNzsKICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMzIpIHsKICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKChob2xkICYgNjU1MzUpICE9PSAoaG9sZCA+Pj4gMTYgXiA2NTUzNSkpIHsKICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBzdG9yZWQgYmxvY2sgbGVuZ3RocyI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUubGVuZ3RoID0gaG9sZCAmIDY1NTM1OwogICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICBiaXRzID0gMDsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBDT1BZXzsKICAgICAgICAgICAgICAgIGlmIChmbHVzaCA9PT0gWl9UUkVFUykgewogICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY2FzZSBDT1BZXzoKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBDT1BZOwogICAgICAgICAgICAgIGNhc2UgQ09QWToKICAgICAgICAgICAgICAgIGNvcHkgPSBzdGF0ZS5sZW5ndGg7CiAgICAgICAgICAgICAgICBpZiAoY29weSkgewogICAgICAgICAgICAgICAgICBpZiAoY29weSA+IGhhdmUpIHsKICAgICAgICAgICAgICAgICAgICBjb3B5ID0gaGF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoY29weSA+IGxlZnQpIHsKICAgICAgICAgICAgICAgICAgICBjb3B5ID0gbGVmdDsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoY29weSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICB1dGlscy5hcnJheVNldChvdXRwdXQsIGlucHV0LCBuZXh0LCBjb3B5LCBwdXQpOwogICAgICAgICAgICAgICAgICBoYXZlIC09IGNvcHk7CiAgICAgICAgICAgICAgICAgIG5leHQgKz0gY29weTsKICAgICAgICAgICAgICAgICAgbGVmdCAtPSBjb3B5OwogICAgICAgICAgICAgICAgICBwdXQgKz0gY29weTsKICAgICAgICAgICAgICAgICAgc3RhdGUubGVuZ3RoIC09IGNvcHk7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IFRZUEU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIFRBQkxFOgogICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAxNCkgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5ubGVuID0gKGhvbGQgJiAzMSkgKyAyNTc7CiAgICAgICAgICAgICAgICBob2xkID4+Pj0gNTsKICAgICAgICAgICAgICAgIGJpdHMgLT0gNTsKICAgICAgICAgICAgICAgIHN0YXRlLm5kaXN0ID0gKGhvbGQgJiAzMSkgKyAxOwogICAgICAgICAgICAgICAgaG9sZCA+Pj49IDU7CiAgICAgICAgICAgICAgICBiaXRzIC09IDU7CiAgICAgICAgICAgICAgICBzdGF0ZS5uY29kZSA9IChob2xkICYgMTUpICsgNDsKICAgICAgICAgICAgICAgIGhvbGQgPj4+PSA0OwogICAgICAgICAgICAgICAgYml0cyAtPSA0OwogICAgICAgICAgICAgICAgaWYgKHN0YXRlLm5sZW4gPiAyODYgfHwgc3RhdGUubmRpc3QgPiAzMCkgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJ0b28gbWFueSBsZW5ndGggb3IgZGlzdGFuY2Ugc3ltYm9scyI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUuaGF2ZSA9IDA7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gTEVOTEVOUzsKICAgICAgICAgICAgICBjYXNlIExFTkxFTlM6CiAgICAgICAgICAgICAgICB3aGlsZSAoc3RhdGUuaGF2ZSA8IHN0YXRlLm5jb2RlKSB7CiAgICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMykgewogICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgc3RhdGUubGVuc1tvcmRlcltzdGF0ZS5oYXZlKytdXSA9IGhvbGQgJiA3OwogICAgICAgICAgICAgICAgICBob2xkID4+Pj0gMzsKICAgICAgICAgICAgICAgICAgYml0cyAtPSAzOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgd2hpbGUgKHN0YXRlLmhhdmUgPCAxOSkgewogICAgICAgICAgICAgICAgICBzdGF0ZS5sZW5zW29yZGVyW3N0YXRlLmhhdmUrK11dID0gMDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLmxlbmNvZGUgPSBzdGF0ZS5sZW5keW47CiAgICAgICAgICAgICAgICBzdGF0ZS5sZW5iaXRzID0gNzsKICAgICAgICAgICAgICAgIG9wdHMgPSB7IGJpdHM6IHN0YXRlLmxlbmJpdHMgfTsKICAgICAgICAgICAgICAgIHJldCA9IGluZmxhdGVfdGFibGUoQ09ERVMsIHN0YXRlLmxlbnMsIDAsIDE5LCBzdGF0ZS5sZW5jb2RlLCAwLCBzdGF0ZS53b3JrLCBvcHRzKTsKICAgICAgICAgICAgICAgIHN0YXRlLmxlbmJpdHMgPSBvcHRzLmJpdHM7CiAgICAgICAgICAgICAgICBpZiAocmV0KSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgY29kZSBsZW5ndGhzIHNldCI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUuaGF2ZSA9IDA7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQ09ERUxFTlM7CiAgICAgICAgICAgICAgY2FzZSBDT0RFTEVOUzoKICAgICAgICAgICAgICAgIHdoaWxlIChzdGF0ZS5oYXZlIDwgc3RhdGUubmxlbiArIHN0YXRlLm5kaXN0KSB7CiAgICAgICAgICAgICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgICAgICAgICAgIGhlcmUgPSBzdGF0ZS5sZW5jb2RlW2hvbGQgJiAoMSA8PCBzdGF0ZS5sZW5iaXRzKSAtIDFdOwogICAgICAgICAgICAgICAgICAgIGhlcmVfYml0cyA9IGhlcmUgPj4+IDI0OwogICAgICAgICAgICAgICAgICAgIGhlcmVfb3AgPSBoZXJlID4+PiAxNiAmIDI1NTsKICAgICAgICAgICAgICAgICAgICBoZXJlX3ZhbCA9IGhlcmUgJiA2NTUzNTsKICAgICAgICAgICAgICAgICAgICBpZiAoaGVyZV9iaXRzIDw9IGJpdHMpIHsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChoZXJlX3ZhbCA8IDE2KSB7CiAgICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IGhlcmVfYml0czsKICAgICAgICAgICAgICAgICAgICBiaXRzIC09IGhlcmVfYml0czsKICAgICAgICAgICAgICAgICAgICBzdGF0ZS5sZW5zW3N0YXRlLmhhdmUrK10gPSBoZXJlX3ZhbDsKICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaGVyZV92YWwgPT09IDE2KSB7CiAgICAgICAgICAgICAgICAgICAgICBuID0gaGVyZV9iaXRzICsgMjsKICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgbikgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICBob2xkID4+Pj0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgICAgICAgYml0cyAtPSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGUuaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGJpdCBsZW5ndGggcmVwZWF0IjsKICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICBsZW4gPSBzdGF0ZS5sZW5zW3N0YXRlLmhhdmUgLSAxXTsKICAgICAgICAgICAgICAgICAgICAgIGNvcHkgPSAzICsgKGhvbGQgJiAzKTsKICAgICAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSAyOwogICAgICAgICAgICAgICAgICAgICAgYml0cyAtPSAyOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaGVyZV92YWwgPT09IDE3KSB7CiAgICAgICAgICAgICAgICAgICAgICBuID0gaGVyZV9iaXRzICsgMzsKICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgbikgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICBob2xkID4+Pj0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgICAgICAgYml0cyAtPSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICAgICAgICBsZW4gPSAwOwogICAgICAgICAgICAgICAgICAgICAgY29weSA9IDMgKyAoaG9sZCAmIDcpOwogICAgICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IDM7CiAgICAgICAgICAgICAgICAgICAgICBiaXRzIC09IDM7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgIG4gPSBoZXJlX2JpdHMgKyA3OwogICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCBuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICAgICAgICBiaXRzIC09IGhlcmVfYml0czsKICAgICAgICAgICAgICAgICAgICAgIGxlbiA9IDA7CiAgICAgICAgICAgICAgICAgICAgICBjb3B5ID0gMTEgKyAoaG9sZCAmIDEyNyk7CiAgICAgICAgICAgICAgICAgICAgICBob2xkID4+Pj0gNzsKICAgICAgICAgICAgICAgICAgICAgIGJpdHMgLT0gNzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLmhhdmUgKyBjb3B5ID4gc3RhdGUubmxlbiArIHN0YXRlLm5kaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGJpdCBsZW5ndGggcmVwZWF0IjsKICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGNvcHktLSkgewogICAgICAgICAgICAgICAgICAgICAgc3RhdGUubGVuc1tzdGF0ZS5oYXZlKytdID0gbGVuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLm1vZGUgPT09IEJBRCkgewogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5sZW5zWzI1Nl0gPT09IDApIHsKICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBjb2RlIC0tIG1pc3NpbmcgZW5kLW9mLWJsb2NrIjsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5sZW5iaXRzID0gOTsKICAgICAgICAgICAgICAgIG9wdHMgPSB7IGJpdHM6IHN0YXRlLmxlbmJpdHMgfTsKICAgICAgICAgICAgICAgIHJldCA9IGluZmxhdGVfdGFibGUoTEVOUywgc3RhdGUubGVucywgMCwgc3RhdGUubmxlbiwgc3RhdGUubGVuY29kZSwgMCwgc3RhdGUud29yaywgb3B0cyk7CiAgICAgICAgICAgICAgICBzdGF0ZS5sZW5iaXRzID0gb3B0cy5iaXRzOwogICAgICAgICAgICAgICAgaWYgKHJldCkgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGxpdGVyYWwvbGVuZ3RocyBzZXQiOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLmRpc3RiaXRzID0gNjsKICAgICAgICAgICAgICAgIHN0YXRlLmRpc3Rjb2RlID0gc3RhdGUuZGlzdGR5bjsKICAgICAgICAgICAgICAgIG9wdHMgPSB7IGJpdHM6IHN0YXRlLmRpc3RiaXRzIH07CiAgICAgICAgICAgICAgICByZXQgPSBpbmZsYXRlX3RhYmxlKERJU1RTLCBzdGF0ZS5sZW5zLCBzdGF0ZS5ubGVuLCBzdGF0ZS5uZGlzdCwgc3RhdGUuZGlzdGNvZGUsIDAsIHN0YXRlLndvcmssIG9wdHMpOwogICAgICAgICAgICAgICAgc3RhdGUuZGlzdGJpdHMgPSBvcHRzLmJpdHM7CiAgICAgICAgICAgICAgICBpZiAocmV0KSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgZGlzdGFuY2VzIHNldCI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IExFTl87CiAgICAgICAgICAgICAgICBpZiAoZmx1c2ggPT09IFpfVFJFRVMpIHsKICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNhc2UgTEVOXzoKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBMRU47CiAgICAgICAgICAgICAgY2FzZSBMRU46CiAgICAgICAgICAgICAgICBpZiAoaGF2ZSA+PSA2ICYmIGxlZnQgPj0gMjU4KSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubmV4dF9vdXQgPSBwdXQ7CiAgICAgICAgICAgICAgICAgIHN0cm0uYXZhaWxfb3V0ID0gbGVmdDsKICAgICAgICAgICAgICAgICAgc3RybS5uZXh0X2luID0gbmV4dDsKICAgICAgICAgICAgICAgICAgc3RybS5hdmFpbF9pbiA9IGhhdmU7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmhvbGQgPSBob2xkOwogICAgICAgICAgICAgICAgICBzdGF0ZS5iaXRzID0gYml0czsKICAgICAgICAgICAgICAgICAgaW5mbGF0ZV9mYXN0KHN0cm0sIF9vdXQpOwogICAgICAgICAgICAgICAgICBwdXQgPSBzdHJtLm5leHRfb3V0OwogICAgICAgICAgICAgICAgICBvdXRwdXQgPSBzdHJtLm91dHB1dDsKICAgICAgICAgICAgICAgICAgbGVmdCA9IHN0cm0uYXZhaWxfb3V0OwogICAgICAgICAgICAgICAgICBuZXh0ID0gc3RybS5uZXh0X2luOwogICAgICAgICAgICAgICAgICBpbnB1dCA9IHN0cm0uaW5wdXQ7CiAgICAgICAgICAgICAgICAgIGhhdmUgPSBzdHJtLmF2YWlsX2luOwogICAgICAgICAgICAgICAgICBob2xkID0gc3RhdGUuaG9sZDsKICAgICAgICAgICAgICAgICAgYml0cyA9IHN0YXRlLmJpdHM7CiAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5tb2RlID09PSBUWVBFKSB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGUuYmFjayA9IC0xOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUuYmFjayA9IDA7CiAgICAgICAgICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgICAgICAgICAgaGVyZSA9IHN0YXRlLmxlbmNvZGVbaG9sZCAmICgxIDw8IHN0YXRlLmxlbmJpdHMpIC0gMV07CiAgICAgICAgICAgICAgICAgIGhlcmVfYml0cyA9IGhlcmUgPj4+IDI0OwogICAgICAgICAgICAgICAgICBoZXJlX29wID0gaGVyZSA+Pj4gMTYgJiAyNTU7CiAgICAgICAgICAgICAgICAgIGhlcmVfdmFsID0gaGVyZSAmIDY1NTM1OwogICAgICAgICAgICAgICAgICBpZiAoaGVyZV9iaXRzIDw9IGJpdHMpIHsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoaGVyZV9vcCAmJiAoaGVyZV9vcCAmIDI0MCkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgbGFzdF9iaXRzID0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgICBsYXN0X29wID0gaGVyZV9vcDsKICAgICAgICAgICAgICAgICAgbGFzdF92YWwgPSBoZXJlX3ZhbDsKICAgICAgICAgICAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICAgICAgICAgICAgaGVyZSA9IHN0YXRlLmxlbmNvZGVbbGFzdF92YWwgKyAoKGhvbGQgJiAoMSA8PCBsYXN0X2JpdHMgKyBsYXN0X29wKSAtIDEpID4+IGxhc3RfYml0cyldOwogICAgICAgICAgICAgICAgICAgIGhlcmVfYml0cyA9IGhlcmUgPj4+IDI0OwogICAgICAgICAgICAgICAgICAgIGhlcmVfb3AgPSBoZXJlID4+PiAxNiAmIDI1NTsKICAgICAgICAgICAgICAgICAgICBoZXJlX3ZhbCA9IGhlcmUgJiA2NTUzNTsKICAgICAgICAgICAgICAgICAgICBpZiAobGFzdF9iaXRzICsgaGVyZV9iaXRzIDw9IGJpdHMpIHsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBsYXN0X2JpdHM7CiAgICAgICAgICAgICAgICAgIGJpdHMgLT0gbGFzdF9iaXRzOwogICAgICAgICAgICAgICAgICBzdGF0ZS5iYWNrICs9IGxhc3RfYml0czsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICBiaXRzIC09IGhlcmVfYml0czsKICAgICAgICAgICAgICAgIHN0YXRlLmJhY2sgKz0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgc3RhdGUubGVuZ3RoID0gaGVyZV92YWw7CiAgICAgICAgICAgICAgICBpZiAoaGVyZV9vcCA9PT0gMCkgewogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gTElUOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChoZXJlX29wICYgMzIpIHsKICAgICAgICAgICAgICAgICAgc3RhdGUuYmFjayA9IC0xOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gVFlQRTsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoaGVyZV9vcCAmIDY0KSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgbGl0ZXJhbC9sZW5ndGggY29kZSI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUuZXh0cmEgPSBoZXJlX29wICYgMTU7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gTEVORVhUOwogICAgICAgICAgICAgIGNhc2UgTEVORVhUOgogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmV4dHJhKSB7CiAgICAgICAgICAgICAgICAgIG4gPSBzdGF0ZS5leHRyYTsKICAgICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCBuKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBzdGF0ZS5sZW5ndGggKz0gaG9sZCAmICgxIDw8IHN0YXRlLmV4dHJhKSAtIDE7CiAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBzdGF0ZS5leHRyYTsKICAgICAgICAgICAgICAgICAgYml0cyAtPSBzdGF0ZS5leHRyYTsKICAgICAgICAgICAgICAgICAgc3RhdGUuYmFjayArPSBzdGF0ZS5leHRyYTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLndhcyA9IHN0YXRlLmxlbmd0aDsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBESVNUOwogICAgICAgICAgICAgIGNhc2UgRElTVDoKICAgICAgICAgICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgICAgICAgICBoZXJlID0gc3RhdGUuZGlzdGNvZGVbaG9sZCAmICgxIDw8IHN0YXRlLmRpc3RiaXRzKSAtIDFdOwogICAgICAgICAgICAgICAgICBoZXJlX2JpdHMgPSBoZXJlID4+PiAyNDsKICAgICAgICAgICAgICAgICAgaGVyZV9vcCA9IGhlcmUgPj4+IDE2ICYgMjU1OwogICAgICAgICAgICAgICAgICBoZXJlX3ZhbCA9IGhlcmUgJiA2NTUzNTsKICAgICAgICAgICAgICAgICAgaWYgKGhlcmVfYml0cyA8PSBiaXRzKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKChoZXJlX29wICYgMjQwKSA9PT0gMCkgewogICAgICAgICAgICAgICAgICBsYXN0X2JpdHMgPSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICAgIGxhc3Rfb3AgPSBoZXJlX29wOwogICAgICAgICAgICAgICAgICBsYXN0X3ZhbCA9IGhlcmVfdmFsOwogICAgICAgICAgICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgICAgICAgICAgICBoZXJlID0gc3RhdGUuZGlzdGNvZGVbbGFzdF92YWwgKyAoKGhvbGQgJiAoMSA8PCBsYXN0X2JpdHMgKyBsYXN0X29wKSAtIDEpID4+IGxhc3RfYml0cyldOwogICAgICAgICAgICAgICAgICAgIGhlcmVfYml0cyA9IGhlcmUgPj4+IDI0OwogICAgICAgICAgICAgICAgICAgIGhlcmVfb3AgPSBoZXJlID4+PiAxNiAmIDI1NTsKICAgICAgICAgICAgICAgICAgICBoZXJlX3ZhbCA9IGhlcmUgJiA2NTUzNTsKICAgICAgICAgICAgICAgICAgICBpZiAobGFzdF9iaXRzICsgaGVyZV9iaXRzIDw9IGJpdHMpIHsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBsYXN0X2JpdHM7CiAgICAgICAgICAgICAgICAgIGJpdHMgLT0gbGFzdF9iaXRzOwogICAgICAgICAgICAgICAgICBzdGF0ZS5iYWNrICs9IGxhc3RfYml0czsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICBiaXRzIC09IGhlcmVfYml0czsKICAgICAgICAgICAgICAgIHN0YXRlLmJhY2sgKz0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgaWYgKGhlcmVfb3AgJiA2NCkgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGRpc3RhbmNlIGNvZGUiOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLm9mZnNldCA9IGhlcmVfdmFsOwogICAgICAgICAgICAgICAgc3RhdGUuZXh0cmEgPSBoZXJlX29wICYgMTU7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gRElTVEVYVDsKICAgICAgICAgICAgICBjYXNlIERJU1RFWFQ6CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuZXh0cmEpIHsKICAgICAgICAgICAgICAgICAgbiA9IHN0YXRlLmV4dHJhOwogICAgICAgICAgICAgICAgICB3aGlsZSAoYml0cyA8IG4pIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIHN0YXRlLm9mZnNldCArPSBob2xkICYgKDEgPDwgc3RhdGUuZXh0cmEpIC0gMTsKICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IHN0YXRlLmV4dHJhOwogICAgICAgICAgICAgICAgICBiaXRzIC09IHN0YXRlLmV4dHJhOwogICAgICAgICAgICAgICAgICBzdGF0ZS5iYWNrICs9IHN0YXRlLmV4dHJhOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLm9mZnNldCA+IHN0YXRlLmRtYXgpIHsKICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBkaXN0YW5jZSB0b28gZmFyIGJhY2siOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBNQVRDSDsKICAgICAgICAgICAgICBjYXNlIE1BVENIOgogICAgICAgICAgICAgICAgaWYgKGxlZnQgPT09IDApIHsKICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY29weSA9IF9vdXQgLSBsZWZ0OwogICAgICAgICAgICAgICAgaWYgKHN0YXRlLm9mZnNldCA+IGNvcHkpIHsKICAgICAgICAgICAgICAgICAgY29weSA9IHN0YXRlLm9mZnNldCAtIGNvcHk7CiAgICAgICAgICAgICAgICAgIGlmIChjb3B5ID4gc3RhdGUud2hhdmUpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGUuc2FuZSkgewogICAgICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBkaXN0YW5jZSB0b28gZmFyIGJhY2siOwogICAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoY29weSA+IHN0YXRlLnduZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgY29weSAtPSBzdGF0ZS53bmV4dDsKICAgICAgICAgICAgICAgICAgICBmcm9tID0gc3RhdGUud3NpemUgLSBjb3B5OwogICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgIGZyb20gPSBzdGF0ZS53bmV4dCAtIGNvcHk7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaWYgKGNvcHkgPiBzdGF0ZS5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICBjb3B5ID0gc3RhdGUubGVuZ3RoOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGZyb21fc291cmNlID0gc3RhdGUud2luZG93OwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgZnJvbV9zb3VyY2UgPSBvdXRwdXQ7CiAgICAgICAgICAgICAgICAgIGZyb20gPSBwdXQgLSBzdGF0ZS5vZmZzZXQ7CiAgICAgICAgICAgICAgICAgIGNvcHkgPSBzdGF0ZS5sZW5ndGg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoY29weSA+IGxlZnQpIHsKICAgICAgICAgICAgICAgICAgY29weSA9IGxlZnQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBsZWZ0IC09IGNvcHk7CiAgICAgICAgICAgICAgICBzdGF0ZS5sZW5ndGggLT0gY29weTsKICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgb3V0cHV0W3B1dCsrXSA9IGZyb21fc291cmNlW2Zyb20rK107CiAgICAgICAgICAgICAgICB9IHdoaWxlICgtLWNvcHkpOwogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gTEVOOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSBMSVQ6CiAgICAgICAgICAgICAgICBpZiAobGVmdCA9PT0gMCkgewogICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBvdXRwdXRbcHV0KytdID0gc3RhdGUubGVuZ3RoOwogICAgICAgICAgICAgICAgbGVmdC0tOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IExFTjsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGNhc2UgQ0hFQ0s6CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUud3JhcCkgewogICAgICAgICAgICAgICAgICB3aGlsZSAoYml0cyA8IDMyKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICAgIGhvbGQgfD0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBfb3V0IC09IGxlZnQ7CiAgICAgICAgICAgICAgICAgIHN0cm0udG90YWxfb3V0ICs9IF9vdXQ7CiAgICAgICAgICAgICAgICAgIHN0YXRlLnRvdGFsICs9IF9vdXQ7CiAgICAgICAgICAgICAgICAgIGlmIChfb3V0KSB7CiAgICAgICAgICAgICAgICAgICAgc3RybS5hZGxlciA9IHN0YXRlLmNoZWNrID0gc3RhdGUuZmxhZ3MgPyBjcmMzMihzdGF0ZS5jaGVjaywgb3V0cHV0LCBfb3V0LCBwdXQgLSBfb3V0KSA6IGFkbGVyMzIoc3RhdGUuY2hlY2ssIG91dHB1dCwgX291dCwgcHV0IC0gX291dCk7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgX291dCA9IGxlZnQ7CiAgICAgICAgICAgICAgICAgIGlmICgoc3RhdGUuZmxhZ3MgPyBob2xkIDogenN3YXAzMihob2xkKSkgIT09IHN0YXRlLmNoZWNrKSB7CiAgICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW5jb3JyZWN0IGRhdGEgY2hlY2siOwogICAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICAgIGJpdHMgPSAwOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IExFTkdUSDsKICAgICAgICAgICAgICBjYXNlIExFTkdUSDoKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS53cmFwICYmIHN0YXRlLmZsYWdzKSB7CiAgICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMzIpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChob2xkICE9PSAoc3RhdGUudG90YWwgJiA0Mjk0OTY3Mjk1KSkgewogICAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImluY29ycmVjdCBsZW5ndGggY2hlY2siOwogICAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICAgIGJpdHMgPSAwOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IERPTkU7CiAgICAgICAgICAgICAgY2FzZSBET05FOgogICAgICAgICAgICAgICAgcmV0ID0gWl9TVFJFQU1fRU5EOwogICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgIGNhc2UgQkFEOgogICAgICAgICAgICAgICAgcmV0ID0gWl9EQVRBX0VSUk9SOwogICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgIGNhc2UgTUVNOgogICAgICAgICAgICAgICAgcmV0dXJuIFpfTUVNX0VSUk9SOwogICAgICAgICAgICAgIGNhc2UgU1lOQzoKICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgc3RybS5uZXh0X291dCA9IHB1dDsKICAgICAgICBzdHJtLmF2YWlsX291dCA9IGxlZnQ7CiAgICAgICAgc3RybS5uZXh0X2luID0gbmV4dDsKICAgICAgICBzdHJtLmF2YWlsX2luID0gaGF2ZTsKICAgICAgICBzdGF0ZS5ob2xkID0gaG9sZDsKICAgICAgICBzdGF0ZS5iaXRzID0gYml0czsKICAgICAgICBpZiAoc3RhdGUud3NpemUgfHwgX291dCAhPT0gc3RybS5hdmFpbF9vdXQgJiYgc3RhdGUubW9kZSA8IEJBRCAmJiAoc3RhdGUubW9kZSA8IENIRUNLIHx8IGZsdXNoICE9PSBaX0ZJTklTSCkpIHsKICAgICAgICAgIGlmICh1cGRhdGV3aW5kb3coc3RybSwgc3RybS5vdXRwdXQsIHN0cm0ubmV4dF9vdXQsIF9vdXQgLSBzdHJtLmF2YWlsX291dCkpIHsKICAgICAgICAgICAgc3RhdGUubW9kZSA9IE1FTTsKICAgICAgICAgICAgcmV0dXJuIFpfTUVNX0VSUk9SOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBfaW4gLT0gc3RybS5hdmFpbF9pbjsKICAgICAgICBfb3V0IC09IHN0cm0uYXZhaWxfb3V0OwogICAgICAgIHN0cm0udG90YWxfaW4gKz0gX2luOwogICAgICAgIHN0cm0udG90YWxfb3V0ICs9IF9vdXQ7CiAgICAgICAgc3RhdGUudG90YWwgKz0gX291dDsKICAgICAgICBpZiAoc3RhdGUud3JhcCAmJiBfb3V0KSB7CiAgICAgICAgICBzdHJtLmFkbGVyID0gc3RhdGUuY2hlY2sgPSBzdGF0ZS5mbGFncyA/IGNyYzMyKHN0YXRlLmNoZWNrLCBvdXRwdXQsIF9vdXQsIHN0cm0ubmV4dF9vdXQgLSBfb3V0KSA6IGFkbGVyMzIoc3RhdGUuY2hlY2ssIG91dHB1dCwgX291dCwgc3RybS5uZXh0X291dCAtIF9vdXQpOwogICAgICAgIH0KICAgICAgICBzdHJtLmRhdGFfdHlwZSA9IHN0YXRlLmJpdHMgKyAoc3RhdGUubGFzdCA/IDY0IDogMCkgKyAoc3RhdGUubW9kZSA9PT0gVFlQRSA/IDEyOCA6IDApICsgKHN0YXRlLm1vZGUgPT09IExFTl8gfHwgc3RhdGUubW9kZSA9PT0gQ09QWV8gPyAyNTYgOiAwKTsKICAgICAgICBpZiAoKF9pbiA9PT0gMCAmJiBfb3V0ID09PSAwIHx8IGZsdXNoID09PSBaX0ZJTklTSCkgJiYgcmV0ID09PSBaX09LKSB7CiAgICAgICAgICByZXQgPSBaX0JVRl9FUlJPUjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHJldDsKICAgICAgfQogICAgICBmdW5jdGlvbiBpbmZsYXRlRW5kKHN0cm0pIHsKICAgICAgICBpZiAoIXN0cm0gfHwgIXN0cm0uc3RhdGUpIHsKICAgICAgICAgIHJldHVybiBaX1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgdmFyIHN0YXRlID0gc3RybS5zdGF0ZTsKICAgICAgICBpZiAoc3RhdGUud2luZG93KSB7CiAgICAgICAgICBzdGF0ZS53aW5kb3cgPSBudWxsOwogICAgICAgIH0KICAgICAgICBzdHJtLnN0YXRlID0gbnVsbDsKICAgICAgICByZXR1cm4gWl9PSzsKICAgICAgfQogICAgICBmdW5jdGlvbiBpbmZsYXRlR2V0SGVhZGVyKHN0cm0sIGhlYWQpIHsKICAgICAgICB2YXIgc3RhdGU7CiAgICAgICAgaWYgKCFzdHJtIHx8ICFzdHJtLnN0YXRlKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIHN0YXRlID0gc3RybS5zdGF0ZTsKICAgICAgICBpZiAoKHN0YXRlLndyYXAgJiAyKSA9PT0gMCkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgIH0KICAgICAgICBzdGF0ZS5oZWFkID0gaGVhZDsKICAgICAgICBoZWFkLmRvbmUgPSBmYWxzZTsKICAgICAgICByZXR1cm4gWl9PSzsKICAgICAgfQogICAgICBmdW5jdGlvbiBpbmZsYXRlU2V0RGljdGlvbmFyeShzdHJtLCBkaWN0aW9uYXJ5KSB7CiAgICAgICAgdmFyIGRpY3RMZW5ndGggPSBkaWN0aW9uYXJ5Lmxlbmd0aDsKICAgICAgICB2YXIgc3RhdGU7CiAgICAgICAgdmFyIGRpY3RpZDsKICAgICAgICB2YXIgcmV0OwogICAgICAgIGlmICghc3RybSB8fCAhc3RybS5zdGF0ZSkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgIH0KICAgICAgICBzdGF0ZSA9IHN0cm0uc3RhdGU7CiAgICAgICAgaWYgKHN0YXRlLndyYXAgIT09IDAgJiYgc3RhdGUubW9kZSAhPT0gRElDVCkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgIH0KICAgICAgICBpZiAoc3RhdGUubW9kZSA9PT0gRElDVCkgewogICAgICAgICAgZGljdGlkID0gMTsKICAgICAgICAgIGRpY3RpZCA9IGFkbGVyMzIoZGljdGlkLCBkaWN0aW9uYXJ5LCBkaWN0TGVuZ3RoLCAwKTsKICAgICAgICAgIGlmIChkaWN0aWQgIT09IHN0YXRlLmNoZWNrKSB7CiAgICAgICAgICAgIHJldHVybiBaX0RBVEFfRVJST1I7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldCA9IHVwZGF0ZXdpbmRvdyhzdHJtLCBkaWN0aW9uYXJ5LCBkaWN0TGVuZ3RoLCBkaWN0TGVuZ3RoKTsKICAgICAgICBpZiAocmV0KSB7CiAgICAgICAgICBzdGF0ZS5tb2RlID0gTUVNOwogICAgICAgICAgcmV0dXJuIFpfTUVN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EFSVElBTF9GTFVTSDogMSwKICAgICAgICBaX1NZTkNfRkxVU0g6IDIsCiAgICAgICAgWl9GVUxMX0ZMVVNIOiAzLAogICAgICAgIFpfRklOSVNIOiA0LAogICAgICAgIFpfQkxPQ0s6IDUsCiAgICAgICAgWl9UUkVFUzogNiwKICAgICAgICBaX09LOiAwLAogICAgICAgIFpfU1RSRUFNX0VORDogMSwKICAgICAgICBaX05FRURfRElDVDogMiwKICAgICAgICBaX0VSUk5POiAtMSwKICAgICAgICBaX1NUUkVBTV9FUlJPUjogLTIsCiAgICAgICAgWl9EQVRBX0VSUk9SOiAtMywKICAgICAgICBaX0JVRl9FUlJPUjogLTUsCiAgICAgICAgWl9OT19DT01QUkVTU0lPTjogMCwKICAgICAgICBaX0JFU1RfU1BFRUQ6IDEsCiAgICAgICAgWl9CRVNUX0NPTVBSRVNTSU9OOiA5LAogICAgICAgIFpfREVGQVVMVF9DT01QUkVTU0lPTjogLTEsCiAgICAgICAgWl9GSUxURVJFRDogMSwKICAgICAgICBaX0hVRkZNQU5fT05MWTogMiwKICAgICAgICBaX1JMRTogMywKICAgICAgICBaX0ZJWEVEOiA0LAogICAgICAgIFpfREVGQVVMVF9TVFJBVEVHWTogMCwKICAgICAgICBaX0JJTkFSWTogMCwKICAgICAgICBaX1RFWFQ6IDEsCiAgICAgICAgWl9VTktOT1dOOiAyLAogICAgICAgIFpfREVGTEFURUQ6IDgKICAgICAgfTsKICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvZ3poZWFkZXIuanMKICB2YXIgcmVxdWlyZV9nemhlYWRlciA9IF9fY29tbW9uSlMoewogICAgIm5vZGVfbW9kdWxlcy9wYWtvL2xpYi96bGliL2d6aGVhZGVyLmpzIihleHBvcnRzMiwgbW9kdWxlMikgewogICAgICBpbml0X2J1ZmZlcl9zaGltKCk7CiAgICAgICJ1c2Ugc3RyaWN0IjsKICAgICAgZnVuY3Rpb24gR1poZWFkZXIoKSB7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ICAgICBpZiAoISh0aGlzIGluc3RhbmNlb2YgSW5mbGF0ZTIpKQogICAgICAgICAgcmV0dXJuIG5ldyBJbmZsYXRlMihvcHRpb25zKTsKICAgICAgICB0aGlzLm9wdGlvbnMgPSB1dGlscy5hc3NpZ24oewogICAgICAgICAgY2h1bmtTaXplOiAxNjM4NCwKICAgICAgICAgIHdpbmRvd0JpdHM6IDAsCiAgICAgICAgICB0bzogIiIKICAgICAgICB9LCBvcHRpb25zIHx8IHt9KTsKICAgICAgICB2YXIgb3B0ID0gdGhpcy5vcHRpb25zOwogICAgICAgIGlmIChvcHQucmF3ICYmIG9wdC53aW5kb3dCaXRzID49IDAgJiYgb3B0LndpbmRvd0JpdHMgPCAxNikgewogICAgICAgICAgb3B0LndpbmRvd0JpdHMgPSAtb3B0LndpbmRvd0JpdHM7CiAgICAgICAgICBpZiAob3B0LndpbmRvd0JpdHMgPT09IDApIHsKICAgICAgICAgICAgb3B0LndpbmRvd0JpdHMgPSAtMTU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChvcHQud2luZG93Qml0cyA+PSAwICYmIG9wdC53aW5kb3dCaXRzIDwgMTYgJiYgIShvcHRpb25zICYmIG9wdGlvbnMud2luZG93Qml0cykpIHsKICAgICAgICAgIG9wdC53aW5kb3dCaXRzICs9IDMyOwogICAgICAgIH0KICAgICAgICBpZiAob3B0LndpbmRvd0JpdHMgPiAxNSAmJiBvcHQud2luZG93Qml0cyA8IDQ4KSB7CiAgICAgICAgICBpZiAoKG9wdC53aW5kb3dCaXRzICYgMTUpID09PSAwKSB7CiAgICAgICAgICAgIG9wdC53aW5kb3dCaXRzIHw9IDE1OwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICB0aGlzLmVyciA9IDA7CiAgICAgICAgdGhpcy5tc2cgPSAiIjsKICAgICAgICB0aGlzLmVuZGVkID0gZmFsc2U7CiAgICAgICAgdGhpcy5jaHVua3MgPSBbXTsKICAgICAgICB0aGlzLnN0cm0gPSBuZ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gICAgIEluZmxhdGUyLnByb3RvdHlwZS5wdXNoID0gZnVuY3Rpb24oZGF0YSwgbW9kZSkgewogICAgICAgIHZhciBzdHJtID0gdGhpcy5zdHJtOwogICAgICAgIHZhciBjaHVua1NpemUgPSB0aGlzLm9wdGlvbnMuY2h1bmtTaXplOwogICAgICAgIHZhciBkaWN0aW9uYXJ5ID0gdGhpcy5vcHRpb25zLmRpY3Rpb25hcnk7CiAgICAgICAgdmFyIHN0YXR1cywgX21vZGU7CiAgICAgICAgdmFyIG5leHRfb3V0X3V0ZjgsIHRhaWwsIHV0ZjhzdHI7CiAgICAgICAgdmFyIGFsbG93QnVmRXJyb3IgPSBmYWxzZTsKICAgICAgICBpZiAodGhpcy5lbmRlZCkgewogICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgICBfbW9kZSA9IG1vZGUgPT09IH5+bW9kZSA/IG1vZGUgOiBtb2RlID09PSB0cnVlID8gYy5aX0ZJTklTSCA6IGMuWl9OT19GTFVTSDsKICAgICAgICBpZiAodHlwZW9mIGRhdGEgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICBzdHJtLmlucHV0ID0gc3RyaW5ncy5iaW5zdHJpbmcyYnVmKGRhdGEpOwogICAgICAgIH0gZWxzZSBpZiAodG9TdHJpbmcyLmNhbGwoZGF0YSkgPT09ICJbb2JqZWN0IEFycmF5QnVmZmVyXSIpIHsKICAgICAgICAgIHN0cm0uaW5wdXQgPSBuZXcgVWludDhBcnJheShkYXRhKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgc3RybS5pbnB1dCA9IGRhdGE7CiAgICAgICAgfQogICAgICAgIHN0cm0ubmV4dF9pbiA9IDA7CiAgICAgICAgc3RybS5hdmFpbF9pbiA9IHN0cm0uaW5wdXQubGVuZ3RoOwogICAgICAgIGRvIHsKICAgICAgICAgIGlmIChzdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICBzdHJtLm91dHB1dCA9IG5ldyB1dGlscy5CdWY4KGNodW5rU2l6ZSk7CiAgICAgICAgICAgIHN0cm0ubmV4dF9vdXQgPSAwOwogICAgICAgICAgICBzdHJtLmF2YWlsX291dCA9IGNodW5rU2l6ZTsKICAgICAgICAgIH0KICAgICAgICAgIHN0YXR1cyA9IHpsaWJfaW5mbGF0ZS5pbmZsYXRlKHN0cm0sIGMuWl9OT19GTFVTSCk7CiAgICAgICAgICBpZiAoc3RhdHVzID09PSBjLlpfTkVFRF9ESUNUICYmIGRpY3Rpb25hcnkpIHsKICAgICAgICAgICAgc3RhdHVzID0gemxpYl9pbmZsYXRlLmluZmxhdGVTZXREaWN0aW9uYXJ5KHRoaXMuc3RybSwgZGljdGlvbmFyeSk7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoc3RhdHVzID09PSBjLlpfQlVGX0VSUk9SICYmIGFsbG93QnVmRXJyb3IgPT09IHRydWUpIHsKICAgICAgICAgICAgc3RhdHVzID0gYy5aX09LOwogICAgICAgICAgICBhbGxvd0J1ZkVycm9yID0gZmFsc2U7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoc3RhdHVzICE9PSBjLlpfU1RSRUFNX0VORCAmJiBzdGF0dXMgIT09IGMuWl9PSykgewogICAgICAgICAgICB0aGlzLm9uRW5kKHN0YXR1cyk7CiAgICAgICAgICAgIHRoaXMuZW5kZWQgPSB0cnVlOwogICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoc3RybS5uZXh0X291dCkgewogICAgICAgICAgICBpZiAoc3RybS5hdmFpbF9vdXQgPT09IDAgfHwgc3RhdHVzID09PSBjLlpfU1RSRUFNX0VORCB8fCBzdHJtLmF2YWlsX2luID09PSAwICYmIChfbW9kZSA9PT0gYy5aX0ZJTklTSCB8fCBfbW9kZSA9PT0gYy5aX1NZTkNfRkxVU0gpKSB7CiAgICAgICAgICAgICAgaWYgKHRoaXMub3B0aW9ucy50byA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgIG5leHRfb3V0X3V0ZjggPSBzdHJpbmdzLnV0Zjhib3JkZXIoc3RybS5vdXRwdXQsIHN0cm0ubmV4dF9vdXQpOwogICAgICAgICAgICAgICAgdGFpbCA9IHN0cm0ubmV4dF9vdXQgLSBuZXh0X291dF91dGY4OwogICAgICAgICAgICAgICAgdXRmOHN0ciA9IHN0cmluZ3MuYnVmMnN0cmluZyhzdHJtLm91dHB1dCwgbmV4dF9vdXRfdXRmOCk7CiAgICAgICAgICAgICAgICBzdHJtLm5leHRfb3V0ID0gdGFpbDsKICAgICAgICAgICAgICAgIHN0cm0uYXZhaWxfb3V0ID0gY2h1bmtTaXplIC0gdGFpbDsKICAgICAgICAgICAgICAgIGlmICh0YWlsKSB7CiAgICAgICAgICAgICAgICAgIHV0aWxzLmFycmF5U2V0KHN0cm0ub3V0cHV0LCBzdHJtLm91dHB1dCwgbmV4dF9vdXRfdXRmOCwgdGFpbCwgMCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB0aGlzLm9uRGF0YSh1dGY4c3RyKTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgdGhpcy5vbkRhdGEodXRpbHMuc2hyaW5rQnVmKHN0cm0ub3V0cHV0LCBzdHJtLm5leHRfb3V0KSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoc3RybS5hdmFpbF9pbiA9PT0gMCAmJiBzdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICBhbGxvd0J1ZkVycm9yID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICB9IHdoaWxlICgoc3RybS5hdmFpbF9pbiA+IDAgfHwgc3RybS5hdmFpbF9vdXQgPT09IDApICYmIHN0YXR1cyAhPT0gYy5aX1NUUkVBTV9FTkQpOwogICAgICAgIGlmIChzdGF0dXMgPT09IGMuWl9TVFJFQU1fRU5EKSB7CiAgICAgICAgICBfbW9kZSA9IGMuWl9GSU5JU0g7CiAgICAgICAgfQogICAgICAgIGlmIChfbW9kZSA9PT0gYy5aX0ZJTklTSCkgewogICAgICAgICAgc3RhdHVzID0gemxpYl9pbmZsYXRlLmluZmxhdGVFbmQodGhpcy5zdHJtKTsKICAgICAgICAgIHRoaXMub25FbmQoc3RhdHVzKTsKICAgICAgICAgIHRoaXMuZW5kZWQgPSB0cnVlOwogICAgICAgICAgcmV0dXJuIHN0YXR1cyA9PT0gYy5aX09LOwogICAgICAgIH0KICAgICAgICBpZiAoX21vZGUgPT09IGMuWl9TWU5DX0ZMVVNIKSB7CiAgICAgICAgICB0aGlzLm9uRW5kKGMuWl9PSyk7CiAgICAgICAgICBzdHJtLmF2YWlsX291dCA9IDA7CiAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIH07CiAgICAgIEluZmxhdGUyLnByb3RvdHlwZS5vbkRhdGEgPSBmdW5jdGlvbihjaHVuaykgewogICAgICAgIHRoaXMuY2h1bmtzLnB1c2goY2h1bmspOwogICAgICB9OwogICAgICBJbmZsYXRlMi5wcm90b3R5cGUub25FbmQgPSBmdW5jdGlvbihzdGF0dXMpIHsKICAgICAgICBpZiAoc3RhdHVzID09PSBjLlpfT0spIHsKICAgICAgICAgIGlmICh0aGlzLm9wdGlvbnMudG8gPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgIHRoaXMucmVzdWx0ID0gdGhpcy5jaHVua3Muam9pbigiIik7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICB0aGlzLnJlc3VsdCA9IHV0aWxzLmZsYXR0ZW5DaHVua3ModGhpcy5jaHVua3MpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICB0aGlzLmNodW5rcyA9IFtdOwogICAgICAgIHRoaXMuZXJyID0gc3RhdHVzOwogICAgICAgIHRoaXMubXNnID0gdGhpcy5zdHJtLm1zZzsKICAgICAgfTsKICAgICAgZnVuY3Rpb24ga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KCk7CiAgICAgIHZhciBjb25zdGFudHMgPSByZXF1aXJlX2NvbnN0YW50cygpOwogICAgICB2YXIgcGFrbyA9IHt9OwogICAgICBhc3NpZ24ocGFrbywgZGVmbGF0ZSwgaW5mbGF0ZSwgY29uc3RhbnRzKTsKICAgICAgbW9kdWxlMi5leHBvcnRzID0gcGFrbzsKICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzL2xvbmcvc3JjL2xvbmcuanMKICB2YXIgcmVxdWlyZV9sb25nID0gX19jb21tb25KUyh7CiAgICAibm9kZV9tb2R1bGVzL2xvbmcvc3JjL2xvbmcuanMiKGV4cG9ydHMyLCBtb2R1bGUyKSB7CiAgICAgIGluaXRfYnVmZmVyX3NoaW0oKTsKICAgICAgbW9kdWxlMi5leHBvcnRzID0gTG9uZzQ7CiAgICAgIHZhciB3YXNtMiA9IG51bGw7CiAgICAgIHRyeSB7CiAgICAgICAgd2FzbTIgPSBuZXcgV2ViQXNzZW1ibHkuSW5zdGFuY2UobmV3IFdlYkFzc2VtYmx5Lk1vZHVsZShuZXcgVWludDhBcnJheShbCiAgICAgICAgICAwLAogICAgICAgICAgOTcsCiAgICAgICAgICAxMTUsCiAgICAgICAgICAxMDksCiAgICAgICAgICAxLAogICAgICAgICAgMCwKICAgICAgICAgIDAsCiAgICAgICAgICAwLAogICAgICAgICAgMSwKICAgICAgICAgIDEzLAogICAgICAgICAgMiwKICAgICAgICAgIDk2LAogICAgICAgICAgMCwKICAgICAgICAgIDEsCiAgICAgICAgICAxMjcsCiAgICAgICAgICA5NiwKICAgICAgICAgIDQsCiAgICAgICAgICAxMjcsCiAgICAgICAgICAxMjcsCiAgICAgICAgICAxMjcsCiAgICAgICAgICAxMjcsCiAgICAgICAgICAxLAogICAgICAgICAgMTI3LAogICAgICAgICAgMywKICAgICAgICAgIDcsCiAgICAgICAgICA2LAogICAgICAgICAgMCwKICAgICAgICAgIDEsCiAgICAgICAgICAxLAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICAxLAogICAgICAgICAgNiwKICAgICAgICAgIDYsCiAgICAgICAgICAxLAogICAgICAgICAgMTI3LAogICAgICAgICAgMSwKICAgICAgICAgIDY1LAogICAgICAgICAgMCwKICAgICAgICAgIDExLAogICAgICAgICAgNywKICAgICAgICAgIDUwLAogICAgICAgICAgNiwKICAgICAgICAgIDMsCiAgICAgICAgICAxMDksCiAgICAgICAgICAxMTcsCiAgICAgICAgICAxMDgsCiAgICAgICAgICAwLAogICAgICAgICAgMSwKICAgICAgICAgIDUsCiAgICAgICAgICAxMDAsCiAgICAgICAgICAxMDUsCiAgICAgICAgICAxMTgsCiAgICAgICAgICA5NSwKICAgICAgICAgIDExNSwKICAgICAgICAgIDAsCiAgICAgICAgICAyLAogICAgICAgICAgNSwKICAgICAgICAgIDEwMCwKICAgICAgICAgIDEwNSwKICAgICAgICAgIDExOCwKICAgICAgICAgIDk1LAogICAgICAgICAgMTE3LAogICAgICAgICAgMCwKICAgICAgICAgIDMsCiAgICAgICAgICA1LAogICAgICAgICAgMTE0LAogICAgICAgICAgMTAxLAogICAgICAgICAgMTA5LAogICAgICAgICAgOTUsCiAgICAgICAgICAxMTUsCiAgICAgICAgICAwLAogICAgICAgICAgNCwKICAgICAgICAgIDUsCiAgICAgICAgICAxMTQsCiAgICAgICAgICAxMDEsCiAgICAgICAgICAxMDksCiAgICAgICAgICA5NSwKICAgICAgICAgIDExNywKICAgICAgICAgIDAsCiAgICAgICAgICA1LAogICAgICAgICAgOCwKICAgICAgICAgIDEwMywKICAgICAgICAgIDEwMSwKICAgICAgICAgIDExNiwKICAgICAgICAgIDk1LAogICAgICAgICAgMTA0LAogICAgICAgICAgMTA1LAogICAgICAgICAgMTAzLAogICAgICAgICAgMTA0LAogICAgICAgICAgMCwKICAgICAgICAgIDAsCiAgICAgICAgICAxMCwKICAgICAgICAgIDE5MSwKICAgICAgICAgIDEsCiAgICAgICAgICA2LAogICAgICAgICAgNCwKICAgICAgICAgIDAsCiAgICAgICAgICAzNSwKICAgICAgICAgIDAsCiAgICAgICAgICAxMSwKICAgICAgICAgIDM2LAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICAxMjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDAsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMzIsCiAgICAgICAgICAyLAogICAgICAgICAgMTczLAogICAgICAgICAgMzIsCiAgICAgICAgICAzLAogICAgICAgICAgMTczLAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNCwKICAgICAgICAgIDEzMiwKICAgICAgICAgIDEyNiwKICAgICAgICAgIDM0LAogICAgICAgICAgNCwKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzUsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAzNiwKICAgICAgICAgIDAsCiAgICAgICAgICAzMiwKICAgICAgICAgIDQsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAxMSwKICAgICAgICAgIDM2LAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICAxMjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDAsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMzIsCiAgICAgICAgICAyLAogICAgICAgICAgMTczLAogICAgICAgICAgMzIsCiAgICAgICAgICAzLAogICAgICAgICAgMTczLAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNCwKICAgICAgICAgIDEzMiwKICAgICAgICAgIDEyNywKICAgICAgICAgIDM0LAogICAgICAgICAgNCwKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzUsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAzNiwKICAgICAgICAgIDAsCiAgICAgICAgICAzMiwKICAgICAgICAgIDQsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAxMSwKICAgICAgICAgIDM2LAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICAxMjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDAsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMzIsCiAgICAgICAgICAyLAogICAgICAgICAgMTczLAogICAgICAgICAgMzIsCiAgICAgICAgICAzLAogICAgICAgICAgMTczLAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNCwKICAgICAgICAgIDEzMiwKICAgICAgICAgIDEyOCwKICAgICAgICAgIDM0LAogICAgICAgICAgNCwKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzUsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAzNiwKICAgICAgICAgIDAsCiAgICAgICAgICAzMiwKICAgICAgICAgIDQsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAxMSwKICAgICAgICAgIDM2LAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICAxMjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDAsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMzIsCiAgICAgICAgICAyLAogICAgICAgICAgMTczLAogICAgICAgICAgMzIsCiAgICAgICAgICAzLAogICAgICAgICAgMTczLAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNCwKICAgICAgICAgIDEzMiwKICAgICAgICAgIDEyOSwKICAgICAgICAgIDM0LAogICAgICAgICAgNCwKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzUsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAzNiwKICAgICAgICAgIDAsCiAgICAgICAgICAzMiwKICAgICAgICAgIDQsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAxMSwKICAgICAgICAgIDM2LAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICAxMjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDAsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMzIsCiAgICAgICAgICAyLAogICAgICAgICAgMTczLAogICAgICAgICAgMzIsCiAgICAgICAgICAzLAogICAgICAgICAgMTczLAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNCwKICAgICAgICAgIDEzMiwKICAgICAgICAgIDEzMCwKICAgICAgICAgIDM0LAogICAgICAgICAgNCwKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzUsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAzNiwKICAgICAgICAgIDAsCiAgICAgICAgICAzMiwKICAgICAgICAgIDQsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAxMQogICAgICAgIF0pKSwge30pLmV4cG9ydHM7CiAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgfQogICAgICBmdW5jdGlvbiBMb25nNChsb3csIGhpZ2gsIHVuc2lnbmVkKSB7CiAgICAgICAgdGhpcy5sb3cgPSBsb3cgfCAwOwogICAgICAgIHRoaXMuaGlnaCA9IGhpZ2ggfCAwOwogICAgICAgIHRoaXMudW5zaWduZWQgPSAhIXVuc2lnbmVkOwogICAgICB9CiAgICAgIExvbmc0LnByb3RvdHlwZS5fX2lzTG9uZ19fOwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoTG9uZzQucHJvdG90eXBlLCAiX19pc0xvbmdfXyIsIHsgdmFsdWU6IHRydWUgfSk7CiAgICAgIGZ1bmN0aW9uIGlzTG9uZzIob2JqKSB7CiAgICAgICAgcmV0dXJuIChvYmogJiYgb2JqWyJfX2lzTG9uZ19fIl0pID09PSB0cnVlOwogICAgICB9CiAgICAgIExvbmc0LmlzTG9uZyA9IGlzTG9uZzI7CiAgICAgIHZhciBJTlRfQ0FDSEUyID0ge307CiAgICAgIHZhciBVSU5UX0NBQ0hFMiA9IHt9OwogICAgICBmdW5jdGlvbiBmcm9tSW50Mih2YWx1ZSwgdW5zaWduZWQpIHsKICAgICAgICB2YXIgb2JqLCBjYWNoZWRPYmosIGNhY2hlOwogICAgICAgIGlmICh1bnNpZ25lZCkgewogICAgICAgICAgdmFsdWUgPj4+PSAwOwogICAgICAgICAgaWYgKGNhY2hlID0gMCA8PSB2YWx1ZSAmJiB2YWx1ZSA8IDI1NikgewogICAgICAgICAgICBjYWNoZWRPYmogPSBVSU5UX0NBQ0hFMlt2YWx1ZV07CiAgICAgICAgICAgIGlmIChjYWNoZWRPYmopCiAgICAgICAgICAgICAgcmV0dXJuIGNhY2hlZE9iajsKICAgICAgICAgIH0KICAgICAgICAgIG9iaiA9IGZyb21CaXRzMih2YWx1ZSwgKHZhbHVlIHwgMCkgPCAwID8gLTEgOiAwLCB0cnVlKTsKICAgICAgICAgIGlmIChjYWNoZSkKICAgICAgICAgICAgVUlOVF9DQUNIRTJbdmFsdWVdID0gb2JqOwogICAgICAgICAgcmV0dXJuIG9iajsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgdmFsdWUgfD0gMDsKICAgICAgICAgIGlmIChjYWNoZSA9IC0xMjggPD0gdmFsdWUgJiYgdmFsdWUgPCAxMjgpIHsKICAgICAgICAgICAgY2FjaGVkT2JqID0gSU5UX0NBQ0hFMlt2YWx1ZV07CiAgICAgICAgICAgIGlmIChjYWNoZWRPYmopCiAgICAgICAgICAgICAgcmV0dXJuIGNhY2hlZE9iajsKICAgICAgICAgIH0KICAgICAgICAgIG9iaiA9IGZyb21CaXRzMih2YWx1ZSwgdmFsdWUgPCAwID8gLTEgOiAwLCBmYWxzZSk7CiAgICAgICAgICBpZiAoY2FjaGUpCiAgICAgICAgICAgIElOVF9DQUNIRTJbdmFsdWVdID0gb2JqOwogICAgICAgICAgcmV0dXJuIG9iajsKICAgICAgICB9CiAgICAgIH0KICAgICAgTG9uZzQuZnJvbUludCA9IGZyb21JbnQyOwogICAgICBmdW5jdGlvbiBmcm9tTnVtYmVyMih2YWx1ZSwgdW5zaWduZWQpIHsKICAgICAgICBpZiAoaXNOYU4odmFsdWUpKQogICAgICAgICAgcmV0dXJuIHVuc2lnbmVkID8gVVpFUk8yIDogWkVSTzI7CiAgICAgICAgaWYgKHVuc2lnbmVkKSB7CiAgICAgICAgICBpZiAodmFsdWUgPCAwKQogICAgICAgICAgICByZXR1cm4gVVpFUk8yOwogICAgICAgICAgaWYgKHZhbHVlID49IFRXT19QV1JfNjRfREJMMikKICAgICAgICAgICAgcmV0dXJuIE1BWF9VTlNJR05FRF9WQUxVRTI7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGlmICh2YWx1ZSA8PSAtVFdPX1BXUl82M19EQkwyKQogICAgICAgICAgICByZXR1cm4gTUlOX1ZBTFVFMjsKICAgICAgICAgIGlmICh2YWx1ZSArIDEgPj0gVFdPX1BXUl82M19EQkwyKQogICAgICAgICAgICByZXR1cm4gTUFYX1ZBTFVFMjsKICAgICAgICB9CiAgICAgICAgaWYgKHZhbHVlIDwgMCkKICAgICAgICAgIHJldHVybiBmcm9tTnVtYmVyMigtdmFsdWUsIHVuc2lnbmVkKS5uZWcoKTsKICAgICAgICByZXR1cm4gZnJvbUJpdHMyKHZhbHVlICUgVFdPX1BXUl8zMl9EQkwyIHwgMCwgdmFsdWUgLyBUV09fUFdSXzMyX0RCTDIgfCAwLCB1bnNpZ25lZCk7CiAgICAgIH0KICAgICAgTG9uZzQuZnJvbU51bWJlciA9IGZyb21OdW1iZXIyOwogICAgICBmdW5jdGlvbiBmcm9tQml0czIobG93Qml0cywgaGlnaEJpdHMsIHVuc2lnbmVkKSB7CiAgICAgICAgcmV0dXJuIG5ldyBMb25nNChsb3dCaXRzLCBoaWdoQml0cywgdW5zaWduZWQpOwogICAgICB9CiAgICAgIExvbmc0LmZyb21CaXRzID0gZnJvbUJpdHMyOwogICAgICB2YXIgcG93X2RibDIgPSBNYXRoLnBvdzsKICAgICAgZnVuY3Rpb24gZnJvbVN0cmluZzIoc3RyLCB1bnNpZ25lZCwgcmFkaXgpIHsKICAgICAgICBpZiAoc3RyLmxlbmd0aCA9PT0gMCkKICAgICAgICAgIHRocm93IEVycm9yKCJlbXB0eSBzdHJpbmciKTsKICAgICAgICBpZiAoc3RyID09PSAiTmFOIiB8fCBzdHIgPT09ICJJbmZpbml0eSIgfHwgc3RyID09PSAiK0luZmluaXR5IiB8fCBzdHIgPT09ICItSW5maW5pdHkiKQogICAgICAgICAgcmV0dXJuIFpFUk8yOwogICAgICAgIGlmICh0eXBlb2YgdW5zaWduZWQgPT09ICJudW1iZXIiKSB7CiAgICAgICAgICByYWRpeCA9IHVuc2lnbmVkLCB1bnNpZ25lZCA9IGZhbHNlOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB1bnNpZ25lZCA9ICEhdW5zaWduZWQ7CiAgICAgICAgfQogICAgICAgIHJhZGl4ID0gcmFkaXggfHwgMTA7CiAgICAgICAgaWYgKHJhZGl4IDwgMiB8fCAzNiA8IHJhZGl4KQogICAgICAgICAgdGhyb3cgUmFuZ2VFcnJvcigicmFkaXgiKTsKICAgICAgICB2YXIgcDsKICAgICAgICBpZiAoKHAgPSBzdHIuaW5kZXhPZigiLSIpKSA+IDApCiAgICAgICAgICB0aHJvdyBFcnJvcigiaW50ZXJpb3IgaHlwaGVuIik7CiAgICAgICAgZWxzZSBpZiAocCA9PT0gMCkgewogICAgICAgICAgcmV0dXJuIGZyb21TdHJpbmcyKHN0ci5zdWJzdHJpbmcoMSksIHVuc2lnbmVkLCByYWRpeCkubmVnKCk7CiAgICAgICAgfQogICAgICAgIHZhciByYWRpeFRvUG93ZXIgPSBmcm9tTnVtYmVyMihwb3dfZGJsMihyYWRpeCwgOCkpOwogICAgICAgIHZhciByZXN1bHQgPSBaRVJPMjsKICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHN0ci5sZW5ndGg7IGkgKz0gOCkgewogICAgICAgICAgdmFyIHNpemUgPSBNYXRoLm1pbig4LCBzdHIubGVuZ3RoIC0gaSksIHZhbHVlID0gcGFyc2VJbnQoc3RyLnN1YnN0cmluZyhpLCBpICsgc2l6ZSksIHJhZGl4KTsKICAgICAgICAgIGlmIChzaXplIDwgOCkgewogICAgICAgICAgICB2YXIgcG93ZXIgPSBmcm9tTnVtYmVyMihwb3dfZGJsMihyYWRpeCwgc2l6ZSkpOwogICAgICAgICAgICByZXN1bHQgPSByZXN1bHQubXVsKHBvd2VyKS5hZGQoZnJvbU51bWJlcjIodmFsdWUpKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHJlc3VsdCA9IHJlc3VsdC5tdWwocmFkaXhUb1Bvd2VyKTsKICAgICAgICAgICAgcmVzdWx0ID0gcmVzdWx0LmFkZChmcm9tTnVtYmVyMih2YWx1ZSkpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXN1bHQudW5zaWduZWQgPSB1bnNpZ25lZDsKICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICB9CiAgICAgIExvbmc0LmZyb21TdHJpbmcgPSBmcm9tU3RyaW5nMjsKICAgICAgZnVuY3Rpb24gZnJvbVZhbHVlMih2YWwsIHVuc2ln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90b3R5cGUyLnRvU3RyaW5nID0gZnVuY3Rpb24gdG9TdHJpbmcyKHJhZGl4KSB7CiAgICAgICAgcmFkaXggPSByYWRpeCB8fCAxMDsKICAgICAgICBpZiAocmFkaXggPCAyIHx8IDM2IDwgcmFkaXgpCiAgICAgICAgICB0aHJvdyBSYW5nZUVycm9yKCJyYWRpeCIpOwogICAgICAgIGlmICh0aGlzLmlzWmVybygpKQogICAgICAgICAgcmV0dXJuICIwIjsKICAgICAgICBpZiAodGhpcy5pc05lZ2F0aXZlKCkpIHsKICAgICAgICAgIGlmICh0aGlzLmVxKE1JTl9WQUxVRTIpKSB7CiAgICAgICAgICAgIHZhciByYWRpeExvbmcgPSBmcm9tTnVtYmVyMihyYWRpeCksIGRpdiA9IHRoaXMuZGl2KHJhZGl4TG9uZyksIHJlbTEgPSBkaXYubXVsKHJhZGl4TG9uZykuc3ViKHRoaXMpOwogICAgICAgICAgICByZXR1cm4gZGl2LnRvU3RyaW5nKHJhZGl4KSArIHJlbTEudG9JbnQoKS50b1N0cmluZyhyYWRpeCk7CiAgICAgICAgICB9IGVsc2UKICAgICAgICAgICAgcmV0dXJuICItIiArIHRoaXMubmVnKCkudG9TdHJpbmcocmFkaXgpOwogICAgICAgIH0KICAgICAgICB2YXIgcmFkaXhUb1Bvd2VyID0gZnJvbU51bWJlcjIocG93X2RibDIocmFkaXgsIDYpLCB0aGlzLnVuc2lnbmVkKSwgcmVtID0gdGhpczsKICAgICAgICB2YXIgcmVzdWx0ID0gIiI7CiAgICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICAgIHZhciByZW1EaXYgPSByZW0uZGl2KHJhZGl4VG9Qb3dlciksIGludHZhbCA9IHJlbS5zdWIocmVtRGl2Lm11bChyYWRpeFRvUG93ZXIpKS50b0ludCgpID4+PiAwLCBkaWdpdHMgPSBpbnR2YWwudG9TdHJpbmcocmFkaXgpOwogICAgICAgICAgcmVtID0gcmVtRGl2OwogICAgICAgICAgaWYgKHJlbS5pc1plcm8oKSkKICAgICAgICAgICAgcmV0dXJuIGRpZ2l0cyArIHJlc3VsdDsKICAgICAgICAgIGVsc2UgewogICAgICAgICAgICB3aGlsZSAoZGlnaXRzLmxlbmd0aCA8IDYpCiAgICAgICAgICAgICAgZGlnaXRzID0gIjAiICsgZGlnaXRzOwogICAgICAgICAgICByZXN1bHQgPSAiIiArIGRpZ2l0cyArIHJlc3VsdDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUyLmdldEhpZ2hCaXRzID0gZnVuY3Rpb24gZ2V0SGlnaEJpdHMyKCkgewogICAgICAgIHJldHVybiB0aGlzLmhpZ2g7CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUyLmdldEhpZ2hCaXRzVW5zaWduZWQgPSBmdW5jdGlvbiBnZXRIaWdoQml0c1Vuc2lnbmVkMigpIHsKICAgICAgICByZXR1cm4gdGhpcy5oaWdoID4+PiAwOwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlMi5nZXRMb3dCaXRzID0gZnVuY3Rpb24gZ2V0TG93Qml0czIoKSB7CiAgICAgICAgcmV0dXJuIHRoaXMubG93OwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlMi5nZXRMb3dCaXRzVW5zaWduZWQgPSBmdW5jdGlvbiBnZXRMb3dCaXRzVW5zaWduZWQyKCkgewogICAgICAgIHJldHVybiB0aGlzLmxvdyA+Pj4gMDsKICAgICAgfTsKICAgICAgTG9uZ1Byb3RvdHlwZTIuZ2V0TnVtQml0c0FicyA9IGZ1bmN0aW9uIGdldE51bUJpdHNBYnMyKCkgewogICAgICAgIGlmICh0aGlzLmlzTmVnYXRpdmUoKSkKICAgICAgICAgIHJldHVybiB0aGlzLmVxKE1JTl9WQUxVRTIpID8gNjQgOiB0aGlzLm5lZygpLmdldE51bUJpdHNBYnMoKTsKICAgICAgICB2YXIgdmFsID0gdGhpcy5oaWdoICE9IDAgPyB0aGlzLmhpZ2ggOiB0aGlzL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yOwogICAgICAgIGlmICghaXNMb25nMihtdWx0aXBsaWVyKSkKICAgICAgICAgIG11bHRpcGxpZXIgPSBmcm9tVmFsdWUyKG11bHRpcGxpZXIpOwogICAgICAgIGlmICh3YXNtMikgewogICAgICAgICAgdmFyIGxvdyA9IHdhc20yLm11bCh0aGlzLmxvdywgdGhpcy5oaWdoLCBtdWx0aXBsaWVyLmxvdywgbXVsdGlwbGllci5oaWdoKTsKICAgICAgICAgIHJldHVybiBmcm9tQml0czIobG93LCB3YXNtMi5nZXRfaGlnaCgpLCB0aGlzLnVuc2lnbmVkKTsKICAgICAgICB9CiAgICAgICAgaWYgKG11bHRpcGxpZXIuaXNaZXJvKCkpCiAgICAgICAgICByZXR1cm4gWkVSTzI7CiAgICAgICAgaWYgKHRoaXMuZXEoTUlOX1ZBTFVFMikpCiAgICAgICAgICByZXR1cm4gbXVsdGlwbGllci5pc09kZCgpID8gTUlOX1ZBTFVFMiA6IFpFUk8yOwogICAgICAgIGlmIChtdWx0aXBsaWVyLmVxKE1JTl9WQUxVRTIpKQogICAgICAgICAgcmV0dXJuIHRoaXMuaXNPZGQoKSA/IE1JTl9WQUxVRTIgOiBaRVJPMjsKICAgICAgICBpZiAodGhpcy5pc05lZ2F0aXZlKCkpIHsKICAgICAgICAgIGlmIChtdWx0aXBsaWVyLmlzTmVnYXRpdmUoKSkKICAgICAgICAgICAgcmV0dXJuIHRoaXMubmVnKCkubXVsKG11bHRpcGxpZXIubmVnKCkpOwogICAgICAgICAgZWxzZQogICAgICAgICAgICByZXR1cm4gdGhpcy5uZWcoKS5tdWwobXVsdGlwbGllcikubmVnKCk7CiAgICAgICAgfSBlbHNlIGlmIChtdWx0aXBsaWVyLmlzTmVnYXRpdmUoKSkKICAgICAgICAgIHJldHVybiB0aGlzLm11bChtdWx0aXBsaWVyLm5lZygpKS5uZWcoKTsKICAgICAgICBpZiAodGhpcy5sdChUV09fUFdSXzI0MikgJiYgbXVsdGlwbGllci5sdChUV09fUFdSXzI0MikpCiAgICAgICAgICByZXR1cm4gZnJvbU51bWJlcjIodGhpcy50b051bWJlcigpICogbXVsdGlwbGllci50b051bWJlcigpLCB0aGlzLnVuc2lnbmVkKTsKICAgICAgICB2YXIgYTQ4ID0gdGhpcy5oaWdoID4+PiAxNjsKICAgICAgICB2YXIgYTMyID0gdGhpcy5oaWdoICYgNjU1MzU7CiAgICAgICAgdmFyIGExNiA9IHRoaXMubG93ID4+PiAxNjsKICAgICAgICB2YXIgYTAwID0gdGhpcy5sb3cgJiA2NTUzNTsKICAgICAgICB2YXIgYjQ4ID0gbXVsdGlwbGllci5oaWdoID4+PiAxNjsKICAgICAgICB2YXIgYjMyID0gbXVsdGlwbGllci5oaWdoICYgNjU1MzU7CiAgICAgICAgdmFyIGIxNiA9IG11bHRpcGxpZXIubG93ID4+PiAxNjsKICAgICAgICB2YXIgYjAwID0gbXVsdGlwbGllci5sb3cgJiA2NTUzNTsKICAgICAgICB2YXIgYzQ4ID0gMCwgYzMyID0gMCwgYzE2ID0gMCwgYzAwID0gMDsKICAgICAgICBjMDAgKz0gYTAwICogYjAwOwogICAgICAgIGMxNiArPSBjMDAgPj4+IDE2OwogICAgICAgIGMwMCAmPSA2NTUzNTsKICAgICAgICBjMTYgKz0gYTE2ICogYjAwOwogICAgICAgIGMzMiArPSBjMTYgPj4+IDE2OwogICAgICAgIGMxNiAmPSA2NTUzNTsKICAgICAgICBjMTYgKz0gYTAwICogYjE2OwogICAgICAgIGMzMiArPSBjMTYgPj4+IDE2OwogICAgICAgIGMxNiAmPSA2NTUzNTsKICAgICAgICBjMzIgKz0gYTMyICogYjAwOwogICAgICAgIGM0OCArPSBjMzIgPj4+IDE2OwogICAgICAgIGMzMiAmPSA2NTUzNTsKICAgICAgICBjMzIgKz0gYTE2ICogYjE2OwogICAgICAgIGM0OCArPSBjMzIgPj4+IDE2OwogICAgICAgIGMzMiAmPSA2NTUzNTsKICAgICAgICBjMzIgKz0gYTAwICogYjMyOwogICAgICAgIGM0OCArPSBjM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gICAgcmV0dXJuIHRoaXMudW5zaWduZWQgPyBVWkVSTzIgOiBaRVJPMjsKICAgICAgICB2YXIgYXBwcm94LCByZW0sIHJlczsKICAgICAgICBpZiAoIXRoaXMudW5zaWduZWQpIHsKICAgICAgICAgIGlmICh0aGlzLmVxKE1JTl9WQUxVRTIpKSB7CiAgICAgICAgICAgIGlmIChkaXZpc29yLmVxKE9ORTIpIHx8IGRpdmlzb3IuZXEoTkVHX09ORTIpKQogICAgICAgICAgICAgIHJldHVybiBNSU5fVkFMVUUyOwogICAgICAgICAgICBlbHNlIGlmIChkaXZpc29yLmVxKE1JTl9WQUxVRTIpKQogICAgICAgICAgICAgIHJldHVybiBPTkUyOwogICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICB2YXIgaGFsZlRoaXMgPSB0aGlzLnNocigxKTsKICAgICAgICAgICAgICBhcHByb3ggPSBoYWxmVGhpcy5kaXYoZGl2aXNvcikuc2hsKDEpOwogICAgICAgICAgICAgIGlmIChhcHByb3guZXEoWkVSTzIpKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gZGl2aXNvci5pc05lZ2F0aXZlKCkgPyBPTkUyIDogTkVHX09ORTI7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHJlbSA9IHRoaXMuc3ViKGRpdmlzb3IubXVsKGFwcHJveCkpOwogICAgICAgICAgICAgICAgcmVzID0gYXBwcm94LmFkZChyZW0uZGl2KGRpdmlzb3IpKTsKICAgICAgICAgICAgICAgIHJldHVybiByZXM7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgaWYgKGRpdmlzb3IuZXEoTUlOX1ZBTFVFMikpCiAgICAgICAgICAgIHJldHVybiB0aGlzLnVuc2lnbmVkID8gVVpFUk8yIDogWkVSTzI7CiAgICAgICAgICBpZiAodGhpcy5pc05lZ2F0aXZlKCkpIHsKICAgICAgICAgICAgaWYgKGRpdmlzb3IuaXNOZWdhdGl2ZSgpKQogICAgICAgICAgICAgIHJldHVybiB0aGlzLm5lZygpLmRpdihkaXZpc29yLm5lZygpKTsKICAgICAgICAgICAgcmV0dXJuIHRoaXMubmVnKCkuZGl2KGRpdmlzb3IpLm5lZygpOwogICAgICAgICAgfSBlbHNlIGlmIChkaXZpc29yLmlzTmVnYXRpdmUoKSkKICAgICAgICAgICAgcmV0dXJuIHRoaXMuZGl2KGRpdmlzb3IubmVnKCkpLm5lZygpOwogICAgICAgICAgcmVzID0gWkVSTzI7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGlmICghZGl2aXNvci51bnNpZ25lZCkKICAgICAgICAgICAgZGl2aXNvciA9IGRpdmlzb3IudG9VbnNpZ25lZCgpOwogICAgICAgICAgaWYgKGRpdmlzb3IuZ3QodGhpcykpCiAgICAgICAgICAgIHJldHVybiBVWkVSTzI7CiAgICAgICAgICBpZiAoZGl2aXNvci5ndCh0aGlzLnNocnUoMSkpKQogICAgICAgICAgICByZXR1cm4gVU9ORTI7CiAgICAgICAgICByZXMgPSBVWkVSTzI7CiAgICAgICAgfQogICAgICAgIHJlbSA9IHRoaXM7CiAgICAgICAgd2hpbGUgKHJlbS5ndGUoZGl2aXNvcikpIHsKICAgICAgICAgIGFwcHJveCA9IE1hdGgubWF4KDEsIE1hdGguZmxvb3IocmVtLnRvTnVtYmVyKCkgLyBkaXZpc29yLnRvTnVtYmVyKCkpKTsKICAgICAgICAgIHZhciBsb2cyID0gTWF0aC5jZWlsKE1hdGgubG9nKGFwcHJveCkgLyBNYXRoLkxOMiksIGRlbHRhID0gbG9nMiA8PSA0OCA/IDEgOiBwb3dfZGJsMigyLCBsb2cyIC0gNDgpLCBhcHByb3hSZXMgPSBmcm9tTnVtYmVyMihhcHByb3gpLCBhcHByb3hSZW0gPSBhcHByb3hSZXMubXVsKGRpdmlzb3IpOwogICAgICAgICAgd2hpbGUgKGFwcHJveFJlbS5pc05lZ2F0aXZlKCkgfHwgYXBwcm94UmVtLmd0KHJlbSkpIHsKICAgICAgICAgICAgYXBwcm94IC09IGRlbHRhOwogICAgICAgICAgICBhcHByb3hSZXMgPSBmcm9tTnVtYmVyMihhcHByb3gsIHRoaXMudW5zaWduZWQpOwogICAgICAgICAgICBhcHByb3hSZW0gPSBhcHByb3hSZXMubXVsKGRpdmlzb3IpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGFwcHJveFJlcy5pc1plcm8oKSkKICAgICAgICAgICAgYXBwcm94UmVzID0gT05FMjsKICAgICAgICAgIHJlcyA9IHJlcy5hZGQoYXBwcm94UmVzKTsKICAgICAgICAgIHJlbSA9IHJlbS5zdWIoYXBwcm94UmVtKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHJlczsKICAgICAgfTsKICAgICAgTG9uZ1Byb3RvdHlwZTIuZGl2ID0gTG9uZ1Byb3RvdHlwZTIuZGl2aWRlOwogICAgICBMb25nUHJvdG90eXBlMi5tb2R1bG8gPSBmdW5jdGlvbiBtb2R1bG8yKGRpdmlzb3IpIHsKICAgICAgICBpZiAoIWlzTG9uZzIoZGl2aXNvcikpCiAgICAgICAgICBkaXZpc29yID0gZnJvbVZhbHVlMihkaXZpc29yKTsKICAgICAgICBpZiAod2FzbTIpIHsKICAgICAgICAgIHZhciBsb3cgPSAodGhpcy51bnNpZ25lZCA/IHdhc20yLnJlbV91IDogd2FzbTIucmVtX3MpKHRoaXMubG93LCB0aGlzLmhpZ2gsIGRpdmlzb3IubG93LCBkaXZpc29yLmhpZ2gpOwogICAgICAgICAgcmV0dXJuIGZyb21CaXRzMihsb3csIHdhc20yLmdldF9oaWdoKCksIHRoaXMudW5zaWduZWQpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gdGhpcy5zdWIodGhpcy5kaXYoZGl2aXNvcikubXVsKGRpdmlzb3IpKTsKICAgICAgfTsKICAgICAgTG9uZ1Byb3RvdHlwZTIubW9kID0gTG9uZ1Byb3RvdHlwZTIubW9kdWxvOwogICAgICBMb25nUHJvdG90eXBlMi5yZW0gPSBM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SB7CiAgICAgICAgaWYgKGlzTG9uZzIobnVtQml0cykpCiAgICAgICAgICBudW1CaXRzID0gbnVtQml0cy50b0ludCgpOwogICAgICAgIGlmICgobnVtQml0cyAmPSA2MykgPT09IDApCiAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICBlbHNlIGlmIChudW1CaXRzIDwgMzIpCiAgICAgICAgICByZXR1cm4gZnJvbUJpdHMyKHRoaXMubG93IDw8IG51bUJpdHMsIHRoaXMuaGlnaCA8PCBudW1CaXRzIHwgdGhpcy5sb3cgPj4+IDMyIC0gbnVtQml0cywgdGhpcy51bnNpZ25lZCk7CiAgICAgICAgZWxzZQogICAgICAgICAgcmV0dXJuIGZyb21CaXRzMigwLCB0aGlzLmxvdyA8PCBudW1CaXRzIC0gMzIsIHRoaXMudW5zaWduZWQpOwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlMi5zaGwgPSBMb25nUHJvdG90eXBlMi5zaGlmdExlZnQ7CiAgICAgIExvbmdQcm90b3R5cGUyLnNoaWZ0UmlnaHQgPSBmdW5jdGlvbiBzaGlmdFJpZ2h0MihudW1CaXRzKSB7CiAgICAgICAgaWYgKGlzTG9uZzIobnVtQml0cykpCiAgICAgICAgICBudW1CaXRzID0gbnVtQml0cy50b0ludCgpOwogICAgICAgIGlmICgobnVtQml0cyAmPSA2MykgPT09IDApCiAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICBlbHNlIGlmIChudW1CaXRzIDwgMzIpCiAgICAgICAgICByZXR1cm4gZnJvbUJpdHMyKHRoaXMubG93ID4+PiBudW1CaXRzIHwgdGhpcy5oaWdoIDw8IDMyIC0gbnVtQml0cywgdGhpcy5oaWdoID4+IG51bUJpdHMsIHRoaXMudW5zaWduZWQpOwogICAgICAgIGVsc2UKICAgICAgICAgIHJldHVybiBmcm9tQml0czIodGhpcy5oaWdoID4+IG51bUJpdHMgLSAzMiwgdGhpcy5oaWdoID49IDAgPyAwIDogLTEsIHRoaXMudW5zaWduZWQpOwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlMi5zaHIgPSBMb25nUHJvdG90eXBlMi5zaGlmdFJpZ2h0OwogICAgICBMb25nUHJvdG90eXBlMi5zaGlmdFJpZ2h0VW5zaWduZWQgPSBmdW5jdGlvbiBzaGlmdFJpZ2h0VW5zaWduZWQyKG51bUJpdHMpIHsKICAgICAgICBpZiAoaXNMb25nMihudW1CaXRzKSkKICAgICAgICAgIG51bUJpdHMgPSBudW1CaXRzLnRvSW50KCk7CiAgICAgICAgbnVtQml0cyAmPSA2MzsKICAgICAgICBpZiAobnVtQml0cyA9PT0gMCkKICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgIGVsc2UgewogICAgICAgICAgdmFyIGhpZ2ggPSB0aGlzLmhpZ2g7CiAgICAgICAgICBpZiAobnVtQml0cyA8IDMyKSB7CiAgICAgICAgICAgIHZhciBsb3cgPSB0aGlzLmxvdzsKICAgICAgICAgICAgcmV0dXJuIGZyb21CaXRzMihsb3cgPj4+IG51bUJpdHMgfCBoaWdoIDw8IDMyIC0gbnVtQml0cywgaGlnaCA+Pj4gbnVtQml0cywgdGhpcy51bnNpZ25lZCk7CiAgICAgICAgICB9IGVsc2UgaWYgKG51bUJpdHMgPT09IDMyKQogICAgICAgICAgICByZXR1cm4gZnJvbUJpdHMyKGhpZ2gsIDAsIHRoaXMudW5zaWduZWQpOwogICAgICAgICAgZWxzZQogICAgICAgICAgICByZXR1cm4gZnJvbUJpdHMyKGhpZ2ggPj4+IG51bUJpdHMgLSAzMiwgMCwgdGhpcy51bnNpZ25lZCk7CiAgICAgICAgfQogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlMi5zaHJ1ID0gTG9uZ1Byb3RvdHlwZTIuc2hpZnRSaWdodFVuc2lnbmVkOwogICAgICBMb25nUHJvdG90eXBlMi5zaHJfdSA9IExvbmdQcm90b3R5cGUyLnNoaWZ0UmlnaHRVbnNpZ25lZDsKICAgICAgTG9uZ1Byb3RvdHlwZTIudG9TaWduZWQgPSBmdW5jdGlvbiB0b1NpZ25lZDIoKSB7CiAgICAgICAgaWYgKCF0aGlzLnVuc2lnbmVkKQogICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgcmV0dXJuIGZyb21CaXRzMih0aGlzLmxvdywgdGhpcy5oaWdoLCBmYWxzZSk7CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUyLnRvVW5zaWduZWQgPSBmdW5jdGlvbiB0b1Vuc2lnbmVkMigpIHsKICAgICAgICBpZiAodGhpcy51bnNpZ25lZCkKICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgIHJldHVybiBmcm9tQml0czIodGhpcy5sb3csIHRoaXMuaGlnaCwgdHJ1ZSk7CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUyLnRvQnl0ZXMgPSBmdW5jdGlvbiB0b0J5dGVzMihsZSkgewogICAgICAgIHJldHVybiBsZSA/IHRoaXMudG9CeXRlc0xFKCkgOiB0aGlzLnRvQnl0ZXNCRSgpOwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlMi50b0J5dGVzTEUgPSBmdW5jdGlvbiB0b0J5dGVzTEUyKCkgewogICAgICAgIHZhciBoaSA9IHRoaXMuaGlnaCwgbG8gPSB0aGlzLmxvdzsKICAgICAgICByZXR1cm4gWwogICAgICAgICAgbG8gJiAyNTUsCiAgICAgICAgICBsbyA+Pj4gOCAmIDI1NSwKICAgICAgICAgIGxvID4+PiAxNiAmIDI1NSwKICAgICAgICAgIGxvID4+PiAyNCwKICAgICAgICAgIGhpICYgMjU1LAogICAgICAgICAgaGkgPj4+IDggJiAyNTUsCiAgICAgICAgICBoaSA+Pj4gMTYgJiAyNTUsCiAgICAgICAgICBoaSA+Pj4gMjQKICAgICAgICBdOwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlMi50b0J5dGVzQkUgPSBmdW5jdGlvbiB0b0J5dGVzQkUyKCkgewogICAgICAgIHZhciBoaSA9IHRoaXMuaGlnaCwgbG8gPSB0a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nZS5uYW1lLAogICAgICAgICAgICBzdGFjazogbWVzc2FnZS5zdGFjawogICAgICAgICAgfSk7CiAgICAgICAgfSwKICAgICAgICBzZXJpYWxpemUoZXJyb3IpIHsKICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgIF9fZXJyb3JfbWFya2VyOiAiJCRlcnJvciIsCiAgICAgICAgICAgIG1lc3NhZ2U6IGVycm9yLm1lc3NhZ2UsCiAgICAgICAgICAgIG5hbWU6IGVycm9yLm5hbWUsCiAgICAgICAgICAgIHN0YWNrOiBlcnJvci5zdGFjawogICAgICAgICAgfTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIHZhciBpc1NlcmlhbGl6ZWRFcnJvciA9ICh0aGluZykgPT4gdGhpbmcgJiYgdHlwZW9mIHRoaW5nID09PSAib2JqZWN0IiAmJiAiX19lcnJvcl9tYXJrZXIiIGluIHRoaW5nICYmIHRoaW5nLl9fZXJyb3JfbWFya2VyID09PSAiJCRlcnJvciI7CiAgICAgIGV4cG9ydHMyLkRlZmF1bHRTZXJpYWxpemVyID0gewogICAgICAgIGRlc2VyaWFsaXplKG1lc3NhZ2UpIHsKICAgICAgICAgIGlmIChpc1NlcmlhbGl6ZWRFcnJvcihtZXNzYWdlKSkgewogICAgICAgICAgICByZXR1cm4gRGVmYXVsdEVycm9yU2VyaWFsaXplci5kZXNlcmlhbGl6ZShtZXNzYWdlKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHJldHVybiBtZXNzYWdlOwogICAgICAgICAgfQogICAgICAgIH0sCiAgICAgICAgc2VyaWFsaXplKGlucHV0KSB7CiAgICAgICAgICBpZiAoaW5wdXQgaW5zdGFuY2VvZiBFcnJvcikgewogICAgICAgICAgICByZXR1cm4gRGVmYXVsdEVycm9yU2VyaWFsaXplci5zZXJpYWxpemUoaW5wdXQpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcmV0dXJuIGlucHV0OwogICAgICAgICAgfQogICAgICAgIH0KICAgIC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pOwogICAgICAgICAgICAgIGFjdGl2ZVN1YnNjcmlwdGlvbnMuZGVsZXRlKGpvYlVJRCk7CiAgICAgICAgICAgIH0sICgpID0+IHsKICAgICAgICAgICAgICBwb3N0Sm9iUmVzdWx0TWVzc2FnZShqb2JVSUQsIHRydWUpOwogICAgICAgICAgICAgIGFjdGl2ZVN1YnNjcmlwdGlvbnMuZGVsZXRlKGpvYlVJRCk7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBhY3RpdmVTdWJzY3JpcHRpb25zLnNldChqb2JVSUQsIHN1YnNjcmlwdGlvbik7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgIGNvbnN0IHJlc3VsdCA9IHlpZWxkIHN5bmNSZXN1bHQ7CiAgICAgICAgICAgICAgcG9zdEpvYlJlc3VsdE1lc3NhZ2Uoam9iVUlELCB0cnVlLCBjb21tb25fMS5zZXJpYWxpemUocmVzdWx0KSk7CiAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgcG9zdEpvYkVycm9yTWVzc2FnZShqb2JVSUQsIGNvbW1vbl8xLnNlcmlhbGl6ZShlcnJvcikpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZXhwb3NlMihleHBvc2VkKSB7CiAgICAgICAgaWYgKCFpbXBsZW1lbnRhdGlvbl8xLmRlZmF1bHQuaXNXb3JrZXJSdW50aW1lKCkpIHsKICAgICAgICAgIHRocm93IEVycm9yKCJleHBvc2UoKSBjYWxsZWQgaW4gdGhlIG1hc3RlciB0aHJlYWQuIik7CiAgICAgICAgfQogICAgICAgIGlmIChleHBvc2VDYWxsZWQpIHsKICAgICAgICAgIHRocm93IEVycm9yKCJleHBvc2UoKSBjYWxsZWQgbW9yZSB0aGFuIG9uY2UuIFRoaXMgaXMgbm90IHBvc3NpYmxlLiBQYXNzIGFuIG9iamVjdCB0by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AgaGVhZGVycywKICAgICAgICBtZXRob2Q6ICJHRVQiLAogICAgICAgIHJlZGlyZWN0OiAiZm9sbG93IiwKICAgICAgICBtb2RlOiAiY29ycyIsCiAgICAgICAgc2lnbmFsLAogICAgICAgIC4uLnRoaXMuYmFzZU92ZXJyaWRlcywKICAgICAgICAuLi5vdmVycmlkZXMKICAgICAgfTsKICAgICAgY29uc3QgcmVzcG9uc2UgPSBhd2FpdCB0aGlzLmZldGNoKHRoaXMudXJsLCBhcmdzKTsKICAgICAgaWYgKCFyZXNwb25zZSkgewogICAgICAgIHRocm93IG5ldyBFcnJvcigiZ2VuZXJpYy1maWxlaGFuZGxlIGZhaWxlZCB0byBmZXRjaCIpOwogICAgICB9CiAgICAgIGlmIChyZXNwb25zZS5zdGF0dXMgIT09IDIwMCkgewogICAgICAgIHRocm93IE9iamVjdC5hc3NpZ24obmV3IEVycm9yKGBIVFRQICR7cmVzcG9uc2Uuc3RhdHVzfSBmZXRjaGluZyAke3RoaXMudXJsfWApLCB7CiAgICAgICAgICBzdGF0dXM6IHJlc3BvbnNlLnN0YXR1cwogICAgICAgIH0pOwogICAgICB9CiAgICAgIGlmIChlbmNvZGluZyA9PT0gInV0ZjgiKSB7CiAgICAgICAgcmV0dXJuIHJlc3BvbnNlLnRleHQoKTsKICAgICAgfQogICAgICBpZiAoZW5jb2RpbmcpIHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYHVuc3VwcG9ydGVkIGVuY29kaW5nOiAke2VuY29kaW5nfWApOwogICAgICB9CiAgICAgIHJldHVybiB0aGlzLmdldEJ1ZmZlckZyb21SZXNwb25zZShyZXNwb25zZSk7CiAgICB9CiAgICBhc3luYyBzdGF0KCkgewogICAgICBpZiAoIXRoaXMuX3N0YXQpIHsKICAgICAgICBjb25zdCBidWYgPSBpbXBvcnRfYnVmZmVyMi5CdWZmZXIuYWxsb2NVbnNhZmUoMTApOwogICAgICAgIGF3YWl0IHRoaXMucmVhZChidWYsIDAsIDEwLCAwKTs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dOwogICAgICBsZXQgdG90YWxTaXplID0gMDsKICAgICAgbGV0IGluZmxhdG9yOwogICAgICBkbyB7CiAgICAgICAgY29uc3QgcmVtYWluaW5nSW5wdXQgPSBpbnB1dERhdGEuc3ViYXJyYXkocG9zKTsKICAgICAgICBpbmZsYXRvciA9IG5ldyBpbXBvcnRfcGFrby5JbmZsYXRlKCk7CiAgICAgICAgKHsgc3RybSB9ID0gaW5mbGF0b3IpOwogICAgICAgIGluZmxhdG9yLnB1c2gocmVtYWluaW5nSW5wdXQsIGltcG9ydF9wYWtvLlpfU1lOQ19GTFVTSCk7CiAgICAgICAgaWYgKGluZmxhdG9yLmVycikgewogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGluZmxhdG9yLm1zZyk7CiAgICAgICAgfQogICAgICAgIHBvcyArPSBzdHJtLm5leHRfaW47CiAgICAgICAgY2h1bmtzW2ldID0gaW5mbGF0b3IucmVzdWx0OwogICAgICAgIHRvdGFsU2l6ZSArPSBjaHVua3NbaV0ubGVuZ3RoOwogICAgICAgIGkgKz0gMTsKICAgICAgfSB3aGlsZSAoc3RybS5hdmFpbF9pbik7CiAgICAgIGNvbnN0IHJlc3VsdCA9IG5ldyBVaW50OEFycmF5KHRvdGFsU2l6ZSk7CiAgICAgIGZvciAobGV0IGkyID0gMCwgb2Zmc2V0ID0gMDsgaTIgPCBjaHVua3MubGVuZ3RoOyBpMisrKSB7CiAgICAgICAgcmVzdWx0LnNldChjaHVua3NbaTJdLCBvZmZzZXQpOwogICAgICAgIG9mZnNldCArPSBjaHVua3NbaTJdLmxlbmd0aDsKICAgICAgfQogICAgICByZXR1cm4gaW1wb3J0X2J1ZmZlci5CdWZmZXIuZnJvbShyZXN1bHQpOwogICAgfSBjYXRjaCAoZSkgewogICAgICBpZiAoYCR7ZX1gLm1hdGNoKC9pbmNvcnJlY3QgaGVhZGVyIGNoZWNrLykpIHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoInByb2JsZW0gZGVjb21wcmVzc2luZyBibG9jazogaW5jb3JyZWN0IGd6aXAgaGVhZGVyIGNoZWNrIik7CiAgICAgIH0KICAgICAgdGhyb3cgZTsKICAgIH0KICB9CiAgYXN5bmMgZnVuY3Rpb24gdW56aXBDaHVua1NsaWNlKGlucHV0RGF0YSwgY2h1bmspIHsKICAgIHRyeSB7CiAgICAgIGxldCBzdHJtOwogICAgICBjb25zdCB7IG1pbnYsIG1heHYgfSA9IGNodW5rOwogICAgICBsZXQgY3BvcyA9IG1pbnYuYmxvY2tQb3NpdGlvbjsKICAgICAgbGV0IGRwb3MgPSBtaW52LmRhdGFQb3NpdGlvbjsKICAgICAgY29uc3QgY2h1bmtzID0gW107CiAgICAgIGNvbnN0IGNwb3NpdGlvbnMgPSBbXTsKICAgICAgY29uc3QgZHBvc2l0aW9ucyA9IFtdOwogICAgICBsZXQgdG90YWxTaXplID0gMDsKICAgICAgbGV0IGkgPSAwOwogICAgICBkbyB7CiAgICAgICAgY29uc3QgcmVtYWluaW5nSW5wdXQgPSBpbnB1dERhdGEuc3ViYXJyYXkoY3BvcyAtIG1pbnYuYmxvY2tQb3NpdGlvbik7CiAgICAgICAgY29uc3QgaW5mbGF0b3IgPSBuZXcgaW1wb3J0X3Bha28uSW5mbGF0ZSgpOwogICAgICAgICh7IHN0cm0gfSA9IGluZmxhdG9yKTsKICAgICAgICBpbmZsYXRvci5wdXNoKHJlbWFpbmluZ0lucHV0LCBpbXBvcnRfcGFrby5aX1NZTkNfRkxVU0gpOwogICAgICAgIGlmIChpbmZsYXRvci5lcnIpIHsKICAgICAgICAgIHRocm93IG5ldyBFcnJvcihpbmZsYXRvci5tc2cpOwogICAgICAgIH0KICAgICAgICBjb25zdCBidWZmZXIyID0gaW5mbGF0b3IucmVzdWx0OwogICAgICAgIGNodW5rcy5wdXNoKGJ1ZmZlcjIpOwogICAgICAgIGxldCBsZW4gPSBidWZmZXIyLmxlbmd0aDsKICAgICAgICBjcG9zaXRpb25zLnB1c2goY3Bvcyk7CiAgICAgICAg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gICAgIG9mZnNldCArPSBjaHVua3NbaTJdLmxlbmd0aDsKICAgICAgfQogICAgICBjb25zdCBidWZmZXIgPSBpbXBvcnRfYnVmZmVyLkJ1ZmZlci5mcm9tKHJlc3VsdCk7CiAgICAgIHJldHVybiB7IGJ1ZmZlciwgY3Bvc2l0aW9ucywgZHBvc2l0aW9ucyB9OwogICAgfSBjYXRjaCAoZSkgewogICAgICBpZiAoYCR7ZX1gLm1hdGNoKC9pbmNvcnJlY3QgaGVhZGVyIGNoZWNrLykpIHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoInByb2JsZW0gZGVjb21wcmVzc2luZyBibG9jazogaW5jb3JyZWN0IGd6aXAgaGVhZGVyIGNoZWNrIik7CiAgICAgIH0KICAgICAgdGhyb3cgZTsKICAgIH0KICB9CgogIC8vIG5vZGVfbW9kdWxlcy9AZ21vZC9iZ3pmLWZpbGVoYW5kbGUvZXNtL2d6aUluZGV4LmpzCiAgaW5pdF9idWZmZXJfc2hpbSgpOwoKICAvLyBub2RlX21vZHVsZXMvQGdtb2QvYmd6Zi1maWxlaGFuZGxlL25vZGVfbW9kdWxlcy9sb25nL2luZGV4LmpzCiAgaW5pdF9idWZmZXJfc2hpbSgpOwogIHZhciB3YXNtID0gbnVsbDsKICB0cnkgewogICAgd2FzbSA9IG5ldyBXZWJBc3NlbWJseS5JbnN0YW5jZShuZXcgV2ViQXNzZW1ibHkuTW9kdWxlKG5ldyBVaW50OEFycmF5KFsKICAgICAgMCwKICAgICAgOTcsCiAgICAgIDExNSwKICAgICAgMTA5LAogICAgICAxLAogICAgICAwLAogICAgICAwLAogICAgICAwLAogICAgICAxLAogICAgICAxMywKICAgICAgMiwKICAgICAgOTYsCiAgICAgIDAsCiAgICAgIDEsCiAgICAgIDEyNywKICAgICAgOTYsCiAgICAgIDQsCiAgICAgIDEyNywKICAgICAgMTI3LAogICAgICAxMjcsCiAgICAgIDEyNywKICAgICAgMSwKICAgICAgMTI3LAogICAgICAzLAogICAgICA3LAogICAgICA2LAogICAgICAwLAogICAgICAxLAogICAgICAxLAogICAgICAxLAogICAgICAxLAogICAgICAxLAogICAgICA2LAogICAgICA2LAogICAgICAxLAogICAgICAxMjcsCiAgICAgIDEsCiAgICAgIDY1LAogICAgICAwLAogICAgICAxMSwKICAgICAgNywKICAgICAgNTAsCiAgICAgIDYsCiAgICAgIDMsCiAgICAgIDEwOSwKICAgICAgMTE3LAogICAgICAxMDgsCiAgICAgIDAsCiAgICAgIDEsCiAgICAgIDUsCiAgICAgIDEwMCwKICAgICAgMTA1LAogICAgICAxMTgsCiAgICAgIDk1LAogICAgICAxMTUsCiAgICAgIDAsCiAgICAgIDIsCiAgICAgIDUsCiAgICAgIDEwMCwKICAgICAgMTA1LAogICAgICAxMTgsCiAgICAgIDk1LAogICAgICAxMTcsCiAgICAgIDAsCiAgICAgIDMsCiAgICAgIDUsCiAgICAgIDExNCwKICAgICAgMTAxLAogICAgICAxMDksCiAgICAgIDk1LAogICAgICAxMTUsCiAgICAgIDAsCiAgICAgIDQsCiAgICAgIDUsCiAgICAgIDExNCwKICAgICAgMTAxLAogICAgICAxMDksCiAgICAgIDk1LAogICAgICAxMTcsCiAgICAgIDAsCiAgICAgIDUsCiAgICAgIDgsCiAgICAgIDEwMywKICAgICAgMTAxLAogICAgICAxMTYsCiAgICAgIDk1LAogICAgICAxMDQsCiAgICAgIDEwNSwKICAgICAgMTAzLAogICAgICAxMDQsCiAgICAgIDAsCiAgICAgIDAsCiAgICAgIDEwLAogICAgICAxOTEsCiAgICAgIDEsCiAgICAgIDYsCiAgICAgIDQsCiAgICAgIDAsCiAgICAgIDM1LAogICAgICAwLAogICAgICAxMSwKICAgICAgMzYsCiAgICAgIDEsCiAgICAgIDEsCiAgICAgIDEyNiwKICAgICAgMzIsCiAgICAgIDAsCiAgICAgIDE3MywKICAgICAgMzIsCiAgICAgIDEsCiAgICAgIDE3MywKICAgICAgNjYsCiAgICAgIDMyLAogICAgICAxMzQsCiAgICAgIDEzMiwKICAgICAgMzIsCiAgICAgIDIsCiAgICAgIDE3MywKICAgICAgMzIsCiAgICAgIDMsCiAgICAgIDE3MywKICAgICAgNjYsCiAgICAgIDMyLAogICAgICAxMzQsCiAgICAgIDEzMiwKICAgICAgMTI2LAogICAgICAzNCwKICAgICAgNCwKICAgICAgNjYsCiAgICAgIDMyLAogICAgICAxMzUsCiAgICAgIDE2NywKICAgICAgMzYsCiAgICAgIDAsCiAgICAgIDMyLAogICAgICA0LAogICAgICAxNjcsCiAgICAgIDExLAogICAgICAzNiwKICAgICAgMSwKICAgICAgMSwKICAgICAgMTI2LAogICAgICAzMiwKICAgICAgMCwKICAgICAgMTczLAogICAgICAzMiwKICAgICAgMSwKICAgICAgMTczLAogICAgICA2NiwKICAgICAgMzIsCiAgICAgIDEzNCwKICAgICAgMTMyLAogICAgICAzMiwKICAgICAgMiwKICAgICAgMTczLAogICAgICAzMiwKICAgICAgMywKICAgICAgMTczLAogICAgICA2NiwKICAgICAgMzIsCiAgICAgIDEzNCwKICAgICAgMTMyLAogICAgICAxMjcsCiAgICAgIDM0LAogICAgICA0LAogICAgICA2NiwKICAgICAgMzIsCiAgICAgIDEzNSwKICAgICAgMTY3LAogICAgICAzNiwKICAgICAgMCwKICAgICAgMzIsCiAgICAgIDQsCiAgICAgIDE2NywKICAgICAgMTEsCiAgICAgIDM2LAogICAgICAxLAogICAgICAxLAogICAgICAxMjYsCiAgICAgIDMyLAogICAgICAwLAogICAgICAxNzMsCiAgICAgIDMyLAogICAgICAxLAogICAgICAxNzMsCiAgICAgIDY2LAogICAgICAzMiwKICAgICAgMTM0LAogICAgICAxMzIsCiAgICAgIDMyLAogICAgICAyLAogICAgICAxNzMsCiAgICAgIDMyLAogICAgICAzLAogICAgICAxNzMsCiAgICAgIDY2LAogICAgICAzMiwKICAgICAgMTM0LAogICAgICAxMzIsCiAgICAgIDEyOCwKICAgICAgMzQsCiAgICAgIDQsCiAgICAgIDY2LAogICAgICAzMiwKICAgICAgMTM1LAogICAgICAxNjcsCiAgICAgIDM2LAogICAgICAwLAogICAgICAzMiwKICAgICAgNCwKICAgICAgMTY3LAogICAgICAxMSwKICAgICAgMzYsCiAgICAgIDEsCiAgICAgIDEsCiAgICAgIDEyNiwKICAgICAgMzIsCiAgICAgIDAsCiAgICAgIDE3MywKICAgICAgMzIsCiAgICAgIDEsCiAgICAgIDE3MywKICAgICAgNjYsCiAgICAgIDMyLAogICAgICAxMzQsCiAgICAgIDEzMiwKICAgICAgMzIsCiAgICAgIDIsCiAgICAgIDE3MywKICAgICAgMzIsCiAgICAgIDMsCiAgICAgIDE3MywKICAgICAgNjYsCiAgICAgIDMyLAogICAgICAxMzQsCiAgICAgIDEzMiwKICAgICAgMTI5LAogICAgICAzNCwKICAgICAgNCwKICAgICAgNjYsCiAgICAgIDMyLAogICAgICAxMzUsCiAgICAgIDE2NywKICAgICAgMzYsCiAgICAgIDAsCiAgICAgIDMyLAogICAgICA0LAogICAgICAxNjcsCiAgICAgIDExLAogICAgICAzNiwKICAgICAgMSwKICAgICAgMSwKICAgICAgMTI2LAogICAgICAzMiwKICAgICAgMCwKICAgICAgMTczLAogICAgICAzMiwKICAgICAgMSwKICAgICAgMTczLAogICAgICA2NiwKICAgICAgMzIsCiAgICAgIDEzNCwKICAgICAgMTMyLAogICAgICAzMiwKICAgICAgMiwKICAgICAgMTczLAogICAgICAzMiwKICAgICAgMywKICAgICAgMTczLAogICAgICA2NiwKICAgICAgMzIsCiAgICAgIDEzNCwKICAgICAgMTMyLAogICAgICAxMzAsCiAgICAgIDM0LAogICAgICA0LAogICAgICA2NiwKICAgICAgMzIsCiAgICAgIDEzNSwKICAgICAgMTY3LAogICAgICAzNiwKICAgICAgMCwKICAgICAgMzIsCiAgICAgIDQsCiAgICAgIDE2NywKICAgICAgMTEKICAgIF0pKSwge30pLmV4cG9ydHM7CiAgfSBjYXRjaCAoZSkgewogIH0KICBmdW5jdGlvbiBMb25nKGxvdywgaGlnaCwgdW5zaWduZWQpIHsKICAgIHRoaXMub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ICAgIGlmIChhcHByb3guZXEoWkVSTykpIHsKICAgICAgICAgICAgcmV0dXJuIGRpdmlzb3IuaXNOZWdhdGl2ZSgpID8gT05FIDogTkVHX09ORTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHJlbSA9IHRoaXMuc3ViKGRpdmlzb3IubXVsKGFwcHJveCkpOwogICAgICAgICAgICByZXMgPSBhcHByb3guYWRkKHJlbS5kaXYoZGl2aXNvcikpOwogICAgICAgICAgICByZXR1cm4gcmVzOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfSBlbHNlIGlmIChkaXZpc29yLmVxKE1JTl9WQUxVRSkpCiAgICAgICAgcmV0dXJuIHRoaXMudW5zaWduZWQgPyBVWkVSTyA6IFpFUk87CiAgICAgIGlmICh0aGlzLmlzTmVnYXRpdmUoKSkgewogICAgICAgIGlmIChkaXZpc29yLmlzTmVnYXRpdmUoKSkKICAgICAgICAgIHJldHVybiB0aGlzLm5lZygpLmRpdihkaXZpc29yLm5lZygpKTsKICAgICAgICByZXR1cm4gdGhpcy5uZWcoKS5kaXYoZGl2aXNvcikubmVnKCk7CiAgICAgIH0gZWxzZSBpZiAoZGl2aXNvci5pc05lZ2F0aXZlKCkpCiAgICAgICAgcmV0dXJuIHRoaXMuZGl2KGRpdmlzb3IubmVnKCkpLm5lZygpOwogICAgICByZXMgPSBaRVJPOwogICAgfSBlbHNlIHsKICAgICAgaWYgKCFkaXZpc29yLnVuc2lnbmVkKQogICAgICAgIGRpdmlzb3IgPSBkaXZpc29yLnRvVW5zaWduZWQoKTsKICAgICAgaWYgKGRpdmlzb3IuZ3QodGhpcykpCiAgICAgICAgcmV0dXJuIFVaRVJPOwogICAgICBpZiAoZGl2aXNvci5ndCh0aGlzLnNocnUoMSkpKQogICAgICAgIHJldHVybiBVT05FOwogICAgICByZXMgPSBVWkVSTzsKICAgIH0KICAgIHJlbSA9IHRoaXM7CiAgICB3aGlsZSAocmVtLmd0ZShkaXZpc29yKSkgewogICAgICB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ICAgIGNvbnN0IGRpZiA9IGMwLm1pbnYuYmxvY2tQb3NpdGlvbiAtIGMxLm1pbnYuYmxvY2tQb3NpdGlvbjsKICAgICAgaWYgKGRpZiAhPT0gMCkgewogICAgICAgIHJldHVybiBkaWY7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcmV0dXJuIGMwLm1pbnYuZGF0YVBvc2l0aW9uIC0gYzEubWludi5kYXRhUG9zaXRpb247CiAgICAgIH0KICAgIH0pOwogICAgY2h1bmtzLmZvckVhY2goKGNodW5rKSA9PiB7CiAgICAgIGlmICghbG93ZXN0IHx8IGNodW5rLm1heHYuY29tcGFyZVRvKGxvd2VzdCkgPiAwKSB7CiAgICAgICAgaWYgKGxhc3RDaHVuayA9PT0gbnVsbCkgewogICAgICAgICAgbWVyZ2VkQ2h1bmtzLnB1c2goY2h1bmspOwogICAgICAgICAgbGFzdENodW5rID0gY2h1bms7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGlmIChjYW5NZXJnZUJsb2NrcyhsYXN0Q2h1bmssIGNodW5rKSkgewogICAgICAgICAgICBpZiAoY2h1bmsubWF4di5jb21wYXJlVG8obGFzdENodW5rLm1heHYpID4gMCkgewogICAgICAgICAgICAgIGxhc3RDaHVuay5tYXh2ID0gY2h1bmsubWF4djsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgbWVyZ2VkQ2h1bmtzLnB1c2goY2h1bmspOwogICAgICAgICAgICBsYXN0Q2h1bmsgPSBjaHVuazsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH0pOwogICAgcmV0dXJuIG1lcmdlZENodW5rczsKICB9CgogIC8vIG5vZGVfbW9kdWxlcy9AZ21vZC90YWJpeC9lc20vdGJpLmpzCiAgaW5pdF9idWZmZXJfc2hpbSgpOwogIHZhciBpbXBvcnRfbG9uZzIgPSBfX3RvTW9kdWxlKHJlcXVpcmVfbG9uZygpKTsKCiAgLy8gbm9kZV9tb2R1bG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IWluZGV4RGF0YSkgewogICAgICAgIHJldHVybiAtMTsKICAgICAgfQogICAgICBjb25zdCByZWZJZCA9IGluZGV4RGF0YS5yZWZOYW1lVG9JZFtyZWZOYW1lXTsKICAgICAgY29uc3QgaWR4ID0gaW5kZXhEYXRhLmluZGljZXNbcmVmSWRdOwogICAgICBpZiAoIWlkeCkgewogICAgICAgIHJldHVybiAtMTsKICAgICAgfQogICAgICBjb25zdCB7IHN0YXRzIH0gPSBpbmRleERhdGEuaW5kaWNlc1tyZWZJZF07CiAgICAgIGlmIChzdGF0cykgewogICAgICAgIHJldHVybiBzdGF0cy5saW5lQ291bnQ7CiAgICAgIH0KICAgICAgcmV0dXJuIC0xOwogICAgfQogICAgYXN5bmMgX3BhcnNlKG9wdHMgPSB7fSkgewogICAgICBjb25zdCBidWYgPSBhd2FpdCB0aGlzLmZpbGVoYW5kbGUucmVhZEZpbGUob3B0cyk7CiAgICAgIGNvbnN0IGJ5dGVzID0gYXdhaXQgdW56aXAoYnVmKTsKICAgICAgY2hlY2tBYm9ydFNpZ25hbChvcHRzLnNpZ25hbCk7CiAgICAgIGlmIChieXRlcy5yZWFkVUludDMyTEUoMCkgIT09IFRCSV9NQUdJQykgewogICAgICAgIHRocm93IG5ldyBFcnJvcigiTm90IGEgVEJJIGZpbGUiKTsKICAgICAgfQogICAgICBjb25zdCByZWZDb3VudCA9IGJ5dGVzLnJlYWRJbnQzMkxFKDQpOwogICAgICBjb25zdCBmb3JtYXRGbGFncyA9IGJ5dGVzLnJlYWRJbnQzMkxFKDgpOwogICAgICBjb25zdCBjb29yZGluYXRlVHlwZSA9IGZvcm1hdEZsYWdzICYgNjU1MzYgPyAiemVyby1iYXNlZC1oYWxmLW9wZW4iIDogIjEtYmFzZWQtY2xvc2VkIjsKICAgICAgY29uc3QgZm9ybWF0T3B0cyA9IHsKICAgICAgICAwOiAiZ2VuZXJpYyIsCiAgICAgICAgMTogIlNBTSIsCiAgICAgICAgMjogIlZDRiIKICAgICAgfTsKIC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XQgZmlyc3REYXRhTGluZTsKICAgICAgY29uc3QgaW5kaWNlcyA9IG5ldyBBcnJheShyZWZDb3VudCkuZmlsbCgwKS5tYXAoKCkgPT4gewogICAgICAgIGNvbnN0IGJpbkNvdW50ID0gYnl0ZXMucmVhZEludDMyTEUoY3Vyck9mZnNldCk7CiAgICAgICAgY3Vyck9mZnNldCArPSA0OwogICAgICAgIGNvbnN0IGJpbkluZGV4ID0ge307CiAgICAgICAgbGV0IHN0YXRzOwogICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgYmluQ291bnQ7IGogKz0gMSkgewogICAgICAgICAgY29uc3QgYmluID0gYnl0ZXMucmVhZFVJbnQzMkxFKGN1cnJPZmZzZXQpOwogICAgICAgICAgY3Vyck9mZnNldCArPSA0OwogICAgICAgICAgaWYgKGJpbiA+IG1heEJpbk51bWJlciArIDEpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJ0YWJpeCBpbmRleCBjb250YWlucyB0b28gbWFueSBiaW5zLCBwbGVhc2UgdXNlIGEgQ1NJIGluZGV4Iik7CiAgICAgICAgICB9IGVsc2UgaWYgKGJpbiA9PT0gbWF4QmluTnVtYmVyICsgMSkgewogICAgICAgICAgICBjb25zdCBjaHVua0NvdW50ID0gYnl0ZXMucmVhZEludDMyTEUoY3Vyck9mZnNldCk7CiAgICAgICAgICAgIGN1cnJPZmZzZXQgKz0gNDsKICAgICAgICAgICAgaWYgKGNodW5rQ291bnQgPT09IDIpIHsKICAgICAgICAgICAgICBzdGF0cyA9IHRoaXMucGFyc2VQc2V1ZG9CaW4oYnl0ZXMsIGN1cnJPZmZzZXQpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGN1cnJPZmZzZXQgKz0gMTYgKiBjaHVua0NvdW50OwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY29uc3QgY2h1bmtDb3VudCA9IGJ5dGVzLnJlYWRJbnQzMkxFKGN1cnJPZmZzZXQpOwogICAgICAgICAgICBjdXJyT2Zmc2V0ICs9IDQ7CiAgICAgICAgICAgIGNvbnN0IGNodW5rcyA9IG5ldyBBcnJheShjaHVua0NvdW50KTsKICAgICAgICAgICAgZm9yIChsZXQgayA9IDA7IGsgPCBjaHVua0NvdW50OyBrICs9IDEpIHsKICAgICAgICAgICAgICBjb25zdCB1ID0gZnJvbUJ5dGVzMihieXRlcywgY3Vyck9mZnNldCk7CiAgICAgICAgICAgICAgY29uc3QgdiA9IGZyb21CeXRlczIoYnl0ZXMsIGN1cnJPZmZzZXQgKyA4KTsKICAgICAgICAgICAgICBjdXJyT2Zmc2V0ICs9IDE2OwogICAgICAgICAgICAgIGZpcnN0RGF0YUxpbmUgPSB0aGlzLl9maW5kRmlyc3REYXRhKGZpcnN0RGF0YUxpbmUsIHUpOwogICAgICAgICAgICAgIGNodW5rc1trXSA9IG5ldyBDaHVuayh1LCB2LCBiaW4pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJpbkluZGV4W2Jpbl0gPSBjaHVua3M7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGNvbnN0IGxpbmVhckNvdW50ID0gYnl0ZXMucmVhZEludDMyTEUoY3Vyck9mZnNldCk7CiAgICAgICAgY3Vyck9mZnNldCArPSA0OwogICAgICAgIGNvbnN0IGxpbmVhckluZGV4ID0gbmV3IEFycmF5KGxpbmVhckNvdW50KTsKICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IGxpbmVhckNvdW50OyBrICs9IDEpIHsKICAgICAgICAgIGxpbmVhckluZGV4W2tdID0gZnJvbUJ5dGVzMihieXRlcywgY3Vyck9mZnNldCk7CiAgICAgICAgICBjdXJyT2Zmc2V0ICs9IDg7CiAgICAgICAgICBmaXJzdERhdGFMaW5lID0gdGhpcy5fZmluZEZpcnN0RGF0YShmaXJzdERhdGFMaW5lLCBsaW5lYXJJbmRleFtrXSk7CiAgICAgICAgfQogICAgICAgIHJldHVybiB7IGJpbkluZGV4LCBsaW5lYXJJbmRleCwgc3RhdHMgfTsKICAgICAgfSk7CiAgICAgIHJldHVybiB7CiAgICAgICAgaW5kaWNlcywKICAgICAgICBtZXRhQ2hhciwKICAgICAgICBtYXhCaW5OdW1iZXIsCiAgICAgICAgbWF4UmVmTGVuZ3RoLAogICAgICAgIHNraXBMaW5lcywKICAgICAgICBmaXJzdERhdGFMaW5lLAogICAgICAgIGNvbHVtbk51bWJlcnMsCiAgICAgICAgY29vcmRpbmF0ZVR5cGUsCiAgICAgICAgZm9ybWF0LAogICAgICAgIHJlZklkVG9OYW1lLAogICAgICAgIHJlZk5hbWVUb0lkLAogICAgICAgIG1heEJsb2NrU2l6ZTogMSA8PCAxNgogICAgICB9OwogICAgfQogICAgcGFyc2VQc2V1ZG9CaW4oYnl0ZXMsIG9mZnNldCkgewogICAgICBjb25zdCBsaW5lQ291bnQgPSBsb25nVG9OdW1iZXIoaW1wb3J0X2xvbmcyLmRlZmF1bHQuZnJvbUJ5dGVzTEUoYnl0ZXMuc2xpY2Uob2Zmc2V0ICsgMTYsIG9mZnNldCArIDI0KSwgdHJ1ZSkpOwogICAgICByZXR1cm4geyBsaW5lQ291bnQgfTsKICAgIH0KICAgIF9wYXJzZU5hbWVCeXRlcyhuYW1lc0J5dGVzKSB7CiAgICAgIGxldCBjdXJyUmVmSWQgPSAwOwogICAgICBsZXQgY3Vyck5hbWVTdGFydCA9IDA7CiAgICAgIGNvbnN0IHJlZklkVG9OYW1lID0gW107CiAgICAgIGNvbnN0IHJlZk5hbWVUb0lkID0ge307CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbmFtZXNCeXRlcy5sZW5ndGg7IGkgKz0gMSkgewogICAgICAgIGlmICghbmFtZXNCeXRlc1tpXSkgewogICAgICAgICAgaWYgKGN1cnJOYW1lU3RhcnQgPCBpKSB7CiAgICAgICAgICAgIGxldCByZWZOYW1lID0gbmFtZXNCeXRlcy50b1N0cmluZygidXRmOCIsIGN1cnJOYW1lU3RhcnQsIGkpOwogICAgICAgICAgICByZWZOYW1lID0gdGhpcy5yZW5hbWVSZWZTZXEocmVmTmFtZSk7CiAgICAgICAgICAgIHJlZklkVG9OYW1lW2N1cnJSZWZJZF0gPSByZWZOYW1lOwogICAgICAgICAgICByZWZOYW1lVG9JZFtyZWZOYW1lXSA9IGN1cnJSZWZJZDsKICAgICAgICAgIH0KICAgICAgICAgIGN1cnJOYW1lU3RhcnQgPSBpICsgMTsKICAgICAgICAgIGN1cnJSZWZJZCArPSAxOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4geyByZWZOYW1lVG9JZCwgcmVmSWRUb05hbWUgfTsKICAgIH0KICAgIGFzeW5jIGJsb2Nrc0ZvclJhbmdlKHJlZk5hbWUsIG1pbiwgbWF4LCBvcHRzID0ge30pIHsKICAgICAgaWYgKG1pbiA8IDApIHsKICAgICAgICBtaW4gPSAwOwogICAgICB9CiAgICAgIGNvbnN0IGluZGV4RGF0YSA9IGF3YWl0IHRoaXMucGFyc2Uob3B0cyk7CiAgICAgIGlmICghaW5kZXhEYXRhKSB7CiAgICAgICAgcmV0dXJuIFtdOwogICAgICB9CiAgICAgIGNvbnN0IHJlZklkID0gaW5kZXhEYXRhLnJlZk5hbWVUb0lkW3JlZk5hbWVdOwogICAgICBjb25zdCBiYSA9IGluZGV4RGF0YS5pbmRpY2VzW3JlZklkXTsKICAgICAgaWYgKCFiYSkgewogICAgICAgIHJldHVybiBbXTsKICAgICAgfQogICAgICBjb25zdCBtaW5PZmZzZXQgPSBiYS5saW5lYXJJbmRleC5sZW5ndGggPyBiYS5saW5lYXJJbmRleFttaW4gPj4gVEFEX0xJRFhfU0hJRlQgPj0gYmEubGluZWFySW5kZXgubGVuZ3RoID8gYmEubGluZWFySW5kZXgubGVuZ3RoIC0gMSA6IG1pbiA+PiBUQURfTElEWF9TSElGVF0gOiBuZXcgVmlydHVhbE9mZnNldCgwLCAwKTsKICAgICAgaWYgKCFtaW5PZmZzZXQpIHsKICAgICAgICBjb25zb2xlLndhcm4oInF1ZXJ5aW5nIG91dHNpZGUgb2YgcG9zc2libGUgdGFiaXggcmFuZ2UiKTsKICAgICAgfQogICAgICBjb25zdCBvdmVybGFwcGluZ0JpbnMgPSByZWcyYmlucyhtaW4sIG1heCk7CiAgICAgIGNvbnN0IGNodW5rcyA9IFtdOwogICAgICBmb3IgKGNvbnN0IFtzdGFydCwgZW5kXSBvZiBvdmVybGFwcGluZ0JpbnMpIHsKICAgICAgICBmb3IgKGxldCBiaW4gPSBzdGFydDsgYmluIDw9IGVuZDsgYmluKyspIHsKICAgICAgICAgIGlmIChiYS5iaW5JbmRleFtiaW5dKSB7CiAgICAgICAgICAgIGNvbnN0IGJpbkNodW5rcyA9IGJhLmJpbkluZGV4W2Jpbl07CiAgICAgICAgICAgIGZvciAobGV0IGMgPSAwOyBjIDwgYmluQ2h1bmtzLmxlbmd0aDsgKytjKSB7CiAgICAgICAgICAgICAgY2h1bmtzLnB1c2gobmV3IENodW5rKGJpbkNodW5rc1tjXS5taW52LCBiaW5DaHVua3NbY10ubWF4diwgYmluKSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgY29uc3QgbmludHYgPSBiYS5saW5lYXJJbmRleC5sZW5ndGg7CiAgICAgIGxldCBsb3dlc3QgPSBudWxsOwogICAgICBjb25zdCBtaW5MaW4gPSBNYXRoLm1pbihtaW4gPj4gMTQsIG5pbnR2IC0gMSk7CiAgICAgIGNvbnN0IG1heExpbiA9IE1hdGgubWluKG1heCA+PiAxNCwgbmludHYgLSAxKTsKICAgICAgZm9yIChsZXQgaSA9IG1pbkxpbjsgaSA8PSBtYXhMaW47ICsraSkgewogICAgICAgIGNvbnN0IHZwID0gYmEubGluZWFySW5kZXhbaV07CiAgICAgICAgaWYgKHZwKSB7CiAgICAgICAgICBpZiAoIWxvd2VzdCB8fCB2cC5jb21wYXJlVG8obG93ZXN0KSA8IDApIHsKICAgICAgICAgICAgbG93ZXN0ID0gdnA7CiAgICAgICAgICB9CiAgICAgICAgfQog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TEUoMTIpOwogICAgICBjb25zdCBhdXggPSBhdXhMZW5ndGggJiYgYXV4TGVuZ3RoID49IDMwID8gdGhpcy5wYXJzZUF1eERhdGEoYnl0ZXMsIDE2KSA6IHsKICAgICAgICByZWZJZFRvTmFtZTogW10sCiAgICAgICAgcmVmTmFtZVRvSWQ6IHt9LAogICAgICAgIG1ldGFDaGFyOiBudWxsLAogICAgICAgIGNvbHVtbk51bWJlcnM6IHsgcmVmOiAwLCBzdGFydDogMSwgZW5kOiAyIH0sCiAgICAgICAgY29vcmRpbmF0ZVR5cGU6ICJ6ZXJvLWJhc2VkLWhhbGYtb3BlbiIsCiAgICAgICAgZm9ybWF0OiAiZ2VuZXJpYyIKICAgICAgfTsKICAgICAgY29uc3QgcmVmQ291bnQgPSBieXRlcy5yZWFkSW50MzJMRSgxNiArIGF1eExlbmd0aCk7CiAgICAgIGxldCBmaXJzdERhdGFMaW5lOwogICAgICBsZXQgY3Vyck9mZnNldCA9IDE2ICsgYXV4TGVuZ3RoICsgNDsKICAgICAgY29uc3QgaW5kaWNlcyA9IG5ldyBBcnJheShyZWZDb3VudCkuZmlsbCgwKS5tYXAoKCkgPT4gewogICAgICAgIGNvbnN0IGJpbkNvdW50ID0gYnl0ZXMucmVhZEludDMyTEUoY3Vyck9mZnNldCk7CiAgICAgICAgY3Vyck9mZnNldCArPSA0OwogICAgICAgIGNvbnN0IGJpbkluZGV4ID0ge307CiAgICAgICAgbGV0IHN0YXRzOwogICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgYmluQ291bnQ7IGogKz0gMSkgewogICAgICAgICAgY29uc3QgYmluID0gYnl0ZXMucmVhZFVJbnQzMkxFKGN1cnJPZmZzZXQpOwogICAgICAgICAgaWYgKGJpbiA+IHRoaXMubWF4QmluTnVtYmVyKSB7CiAgICAgICAgICAgIHN0YXRzID0gdGhpcy5wYXJzZVBzZXVkb0JpbihieXRlcywgY3Vyck9mZnNldCArIDQpOwogICAgICAgICAgICBjdXJyT2Zmc2V0ICs9IDQgKyA4ICsgNCArIDE2ICsgMTY7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjb25zdCBsb2Zmc2V0ID0gZnJvbUJ5dGVzMihieXRlcywgY3Vyck9mZnNldCArIDQpOwogICAgICAgICAgICBmaXJzdERhdGFMaW5lID0gdGhpcy5fZmluZEZpcnN0RGF0YShmaXJzdERhdGFMaW5lLCBsb2Zmc2V0KTsKICAgICAgICAgICAgY29uc3QgY2h1bmtDb3VudCA9IGJ5dGVzLnJlYWRJbnQzMkxFKGN1cnJPZmZzZXQgKyAxMik7CiAgICAgICAgICAgIGN1cnJPZmZzZXQgKz0gMTY7CiAgICAgICAgICAgIGNvbnN0IGNodW5rcyA9IG5ldyBBcnJheShjaHVua0NvdW50KTsKICAgICAgICAgICAgZm9yIChsZXQgayA9IDA7IGsgPCBjaHVua0NvdW50OyBrICs9IDEpIHsKICAgICAgICAgICAgICBjb25zdCB1ID0gZnJvbUJ5dGVzMihieXRlcywgY3Vyck9mZnNldCk7CiAgICAgICAgICAgICAgY29uc3QgdiA9IGZyb21CeXRlczIoYnl0ZXMsIGN1cnJPZmZzZXQgKyA4KTsKICAgICAgICAgICAgICBjdXJyT2Zmc2V0ICs9IDE2OwogICAgICAgICAgICAgIGNodW5rc1trXSA9IG5ldyBDaHVuayh1LCB2LCBiaW4pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJpbkluZGV4W2Jpbl0gPSBjaHVua3M7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiB7IGJpbkluZGV4LCBzdGF0cyB9OwogICAgICB9KTsKICAgICAgcmV0dXJuIHsKICAgICAgICAuLi5hdXgsCiAgICAgICAgY3NpOiB0cnVlLAogICAgICAgIHJlZkNvdW50LAogICAgICAgIG1heEJsb2NrU2l6ZTogMSA8PCAxNiwKICAgICAgICBmaXJzdERhdGFMaW5lLAogICAgICAgIGNzaVZlcnNpb24sCiAgICAgICAgaW5kaWNlcywKICAgICAgICBkZXB0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ICAgICAgICAgY29uc3QgYmluQ2h1bmtzID0gYmEuYmluSW5kZXhbYmluXTsKICAgICAgICAgICAgZm9yIChsZXQgYyA9IDA7IGMgPCBiaW5DaHVua3MubGVuZ3RoOyArK2MpIHsKICAgICAgICAgICAgICBjaHVua3MucHVzaChuZXcgQ2h1bmsoYmluQ2h1bmtzW2NdLm1pbnYsIGJpbkNodW5rc1tjXS5tYXh2LCBiaW4pKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gb3B0aW1pemVDaHVua3MoY2h1bmtzLCBuZXcgVmlydHVhbE9mZnNldCgwLCAwKSk7CiAgICB9CiAgICByZWcyYmlucyhiZWcsIGVuZCkgewogICAgICBiZWcgLT0gMTsKICAgICAgaWYgKGJlZyA8IDEpIHsKICAgICAgICBiZWcgPSAxOwogICAgICB9CiAgICAgIGlmIChlbmQgPiAyICoqIDUwKSB7CiAgICAgICAgZW5kID0gMiAqKiAzNDsKICAgICAgfQogICAgICBlbmQgLT0gMTsKICAgICAgbGV0IGwgPSAwOwogICAgICBsZXQgdCA9IDA7CiAgICAgIGxldCBzID0gdGhpcy5taW5TaGlmdCArIHRoaXMuZGVwdGggKiAzOwogICAgICBjb25zdCBiaW5zID0gW107CiAgICAgIGZvciAoOyBsIDw9IHRoaXMuZGVwdGg7IHMgLT0gMywgdCArPSBsc2hpZnQoMSwgbCAqIDMpLCBsICs9IDEpIHsKICAgICAgICBjb25zdCBiID0gdCArIHJzaGlmdChiZWcsIHMpOwogICAgICAgIGNvbnN0IGUgPSB0ICsgcnNoaWZ0KGVuZCwgcyk7CiAgICAgICAgaWYgKGUgLSBiICsgYmlucy5sZW5ndGggPiB0aGlzLm1heEJpbk51bWJlcikgewogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBxdWVyeSAke2JlZ30tJHtlbmR9IGlzIHRvbyBsYXJnZSBmb3IgY3VycmVudCBiaW5uaW5nIHNjaGVtZSAoc2hpZnQgJHt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m92aWRlIGVpdGhlciBmaWxlaGFuZGxlIG9yIHBhdGgiKTsKICAgICAgfQogICAgICBpZiAodGJpRmlsZWhhbmRsZSkgewogICAgICAgIHRoaXMuaW5kZXggPSBuZXcgVGFiaXhJbmRleCh7CiAgICAgICAgICBmaWxlaGFuZGxlOiB0YmlGaWxlaGFuZGxlLAogICAgICAgICAgcmVuYW1lUmVmU2VxcwogICAgICAgIH0pOwogICAgICB9IGVsc2UgaWYgKGNzaUZpbGVoYW5kbGUpIHsKICAgICAgICB0aGlzLmluZGV4ID0gbmV3IENTSSh7CiAgICAgICAgICBmaWxlaGFuZGxlOiBjc2lGaWxlaGFuZGxlLAogICAgICAgICAgcmVuYW1lUmVmU2VxcwogICAgICAgIH0pOwogICAgICB9IGVsc2UgaWYgKHRiaVBhdGgpIHsKICAgICAgICB0aGlzLmluZGV4ID0gbmV3IFRhYml4SW5kZXgoewogICAgICAgICAgZmlsZWhhbmRsZTogbmV3IGltcG9ydF9sb2NhbEZpbGUuZGVmYXVsdCh0YmlQYXRoKSwKICAgICAgICAgIHJlbmFtZVJlZlNlcXMKICAgICAgICB9KTsKICAgICAgfSBlbHNlIGlmIChjc2lQYXRoKSB7CiAgICAgICAgdGhpcy5pbmRleCA9IG5ldyBDU0koewogICAgICAgICAgZmlsZWhhbmRsZTogbmV3IGltcG9ydF9sb2NhbEZpbGUuZGVmYXVsdChjc2lQYXRoKSwKICAgICAgICAgIHJlbmFtZVJlZlNlcXMKICAgICAgICB9KTsKICAgICAgfSBlbHNlIGlmIChwYXRoKSB7CiAgICAgICAgdGhpcy5pbmRleCA9IG5ldyBUYWJpeEluZGV4KHsKICAgICAgICAgIGZpbGVoYW5kbGU6IG5ldyBpbXBvcnRfbG9jYWxGaWxlLmRlZmF1bHQoYCR7cGF0aH0udGJpYCksCiAgICAgICAgICByZW5hbWVSZWZTZXFzCiAgICAgICAgfSk7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcig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gICAgICBpZiAoZHBvc2l0aW9ucykgewogICAgICAgICAgICB3aGlsZSAoYmxvY2tTdGFydCArIGMubWludi5kYXRhUG9zaXRpb24gPj0gZHBvc2l0aW9uc1twb3MrK10pIHsKICAgICAgICAgICAgfQogICAgICAgICAgICBwb3MtLTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IHsgc3RhcnRDb29yZGluYXRlLCBvdmVybGFwcyB9ID0gdGhpcy5jaGVja0xpbmUobWV0YWRhdGEsIHJlZk5hbWUsIHN0YXJ0LCBlbmQsIGxpbmUpOwogICAgICAgICAgaWYgKHByZXZpb3VzU3RhcnRDb29yZGluYXRlICE9PSB2b2lkIDAgJiYgc3RhcnRDb29yZGluYXRlICE9PSB2b2lkIDAgJiYgcHJldmlvdXNTdGFydENvb3JkaW5hdGUgPiBzdGFydENvb3JkaW5hdGUpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBMaW5lcyBub3Qgc29ydGVkIGJ5IHN0YXJ0IGNvb3JkaW5hdGUgKCR7cHJldmlvdXNTdGFydENvb3JkaW5hdGV9ID4gJHtzdGFydENvb3JkaW5hdGV9KSwgdGhpcyBmaWxlIGlzIG5vdCB1c2FibGUgd2l0aCBUYWJpeC5gKTsKICAgICAgICAgIH0KICAgICAgICAgIHByZXZpb3VzU3RhcnRDb29yZGluYXRlID0gc3RhcnRDb29yZGluYXRlOwogICAgICAgICAgaWYgKG92ZXJsYXBzKSB7CiAgICAgICAgICAgIGNhbGxiYWNrKGxpbmUudHJpbSgpLCBjcG9zaXRpb25zW3Bvc10gKiAoMSA8PCA4KSArIChibG9ja1N0YXJ0IC0gZHBvc2l0aW9uc1twb3NdKSArIGMubWludi5kYXRhUG9zaXRpb24gKyAxKTsKICAgICAgICAgIH0gZWxzZSBpZiAoc3RhcnRDb29yZGluYXRlICE9PSB2b2lkIDAgJiYgc3RhcnRDb29yZGluYXRlID49IGVuZCkgewogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICB9CiA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HJlZ2lvblJlZk5hbWUsIHJlZ2lvblN0YXJ0LCByZWdpb25FbmQsIGxpbmUpIHsKICAgICAgY29uc3QgeyBjb2x1bW5OdW1iZXJzLCBtZXRhQ2hhciwgY29vcmRpbmF0ZVR5cGUsIGZvcm1hdCB9ID0gbWV0YWRhdGE7CiAgICAgIGlmIChsaW5lLmNoYXJBdCgwKSA9PT0gbWV0YUNoYXIpIHsKICAgICAgICByZXR1cm4geyBvdmVybGFwczogZmFsc2UgfTsKICAgICAgfQogICAgICBsZXQgeyByZWYsIHN0YXJ0LCBlbmQgfSA9IGNvbHVtbk51bWJlcnM7CiAgICAgIGlmICghcmVmKSB7CiAgICAgICAgcmVmID0gMDsKICAgICAgfQogICAgICBpZiAoIXN0YXJ0KSB7CiAgICAgICAgc3RhcnQgPSAwOwogICAgICB9CiAgICAgIGlmICghZW5kKSB7CiAgICAgICAgZW5kID0gMDsKICAgICAgfQogICAgICBpZiAoZm9ybWF0ID09PSAiVkNGIikgewogICAgICAgIGVuZCA9IDg7CiAgICAgIH0KICAgICAgY29uc3QgbWF4Q29sdW1uID0gTWF0aC5tYXgocmVmLCBzdGFydCwgZW5kKTsKICAgICAgbGV0IGN1cnJlbnRDb2x1bW5OdW1iZXIgPSAxOwogICAgICBsZXQgY3VycmVudENvbHVtblN0YXJ0ID0gMDsKICAgICAgbGV0IHJlZlNlcSA9ICIiOwogICAgICBsZXQgc3RhcnRDb29yZGluYXRlID0gLUluZmluaXR5OwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxpbmUubGVuZ3RoICsgMTsgaSArPSAxKSB7CiAgICAgICAgaWYgKGxpbmVbaV0gPT09ICIJIiB8fCBpID09PSBsaW5lLmxlbmd0aCkgewogICAgICAgICAgaWYgKGN1cnJlbnRDb2x1bW5OdW1iZXIgPT09IHJlZikgewogICAgICAgICAgICBpZiAodGhpcy5yZW5hbWVSZWZTZXEobGluZS5zbGljZShjdXJyZW50Q29sdW1uU3RhcnQsIGkpKSAhPT0gcmVnaW9uUmVmTmFtZSkgewogICAgICAgICAgICAgIHJldHVybiB7IG92ZXJsYXBzOiBmYWxzZSB9OwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgaWYgKGN1cnJlbnRDb2x1bW5OdW1iZXIgPT09IHN0YXJ0KSB7CiAgICAgICAgICAgIHN0YXJ0Q29vcmRpbmF0ZSA9IHBhcnNlSW50KGxpbmUuc2xpY2UoY3VycmVudENvbHVtblN0YXJ0LCBpKSwgMTApOwogICAgICAgICAgICBpZiAoY29vcmRpbmF0ZVR5cGUgPT09ICIxLWJhc2VkLWNsb3NlZCIpIHsKICAgICAgICAgICAgICBzdGFydENvb3JkaW5hdGUgLT0gMTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoc3RhcnRDb29yZGluYXRlID49IHJlZ2lvbkVuZCkgewogICAgICAgICAgICAgIHJldHVybiB7IHN0YXJ0Q29vcmRpbmF0ZSwgb3ZlcmxhcHM6IGZhbHNlIH07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGVuZCA9PT0gMCB8fCBlbmQgPT09IHN0YXJ0KSB7CiAgICAgICAgICAgICAgaWYgKHN0YXJ0Q29vcmRpbmF0ZSArIDEgPD0gcmVnaW9uU3RhcnQpIHsKICAgICAgICAgICAgICAgIHJldHVybiB7IHN0YXJ0Q29vcmRpbmF0ZSwgb3ZlcmxhcHM6IGZhbHNlIH07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgaWYgKGZvcm1hdCA9PT0gIlZDRiIgJiYgY3VycmVudENvbHVtbk51bWJlciA9PT0gNCkgewogICAgICAgICAgICByZWZTZXEgPSBsaW5lLnNsaWNlKGN1cnJlbnRDb2x1bW5TdGFydCwgaSk7CiAgICAgICAgICB9IGVsc2UgaWYgKGN1cnJlbnRDb2x1bW5OdW1iZXIgPT09IGVuZCkgewogICAgICAgICAgICBsZXQgZW5kQ29vcmRpbmF0ZTsKICAgICAgICAgICAgaWYgKGZvcm1hdCA9PT0gIlZDRiIpIHsKICAgICAgICAgICAgICBlbmRDb29yZGluYXRlID0gdGhpcy5fZ2V0VmNmRW5kKHN0YXJ0Q29vcmRpbmF0ZSwgcmVmU2VxLCBsaW5lLnNsaWNlKGN1cnJlbnRDb2x1bW5TdGFydCwgaSkpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGVuZENvb3JkaW5hdGUgPSBwYXJzZUludChsaW5lLnNsaWNlKGN1cnJlbnRDb2x1bW5TdGFydCwgaSksIDEwKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoZW5kQ29vcmRpbmF0ZSA8PSByZWdpb25TdGFydCkgewogICAgICAgICAgICAgIHJldHVybiB7IG92ZXJsYXBzOiBmYWxzZSB9OwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBjdXJyZW50Q29sdW1uU3RhcnQgPSBpICsgMTsKICAgICAgICAgIGN1cnJlbnRDb2x1bW5OdW1iZXIgKz0gMTsKICAgICAgICAgIGlmIChjdXJyZW50Q29sdW1uTnVtYmVyID4gbWF4Q29sdW1uKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4geyBzdGFydENvb3JkaW5hdGUsIG92ZXJsYXBzOiB0cnVlIH07CiAgICB9CiAgICBfZ2V0VmNmRW5kKHN0YXJ0Q29vcmRpbmF0ZSwgcmVmU2VxLCBpbmZvKSB7CiAgICAgIGxldCBlbmRDb29yZGluYXRlID0gc3RhcnRDb29yZGluYXRlICsgcmVmU2VxLmxlbmd0aDsKICAgICAgY29uc3QgaXNUUkEgPSBpbmZvLmluZGV4T2YoIlNWVFlQRT1UUkEiKSAhPT0gLTE7CiAgICAgIGlmIChpbmZvWzBdICE9PSAiLiIgJiYgIWlzVFJBKSB7CiAgICAgICAgbGV0IHByZXZDaGFyID0gIjsiOwogICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgaW5mby5sZW5ndGg7IGogKz0gMSkgewogICAgICAgICAgaWYgKHByZXZDaGFyID09PSAiOyIgJiYgaW5mby5zbGljZShqLCBqICsgNCkgPT09ICJFTkQ9IikgewogICAgICAgICAgICBsZXQgdmFsdWVFbmQgPSBpbmZvLmluZGV4T2YoIjsiLCBqKTsKICAgICAgICAgICAgaWYgKHZhbHVlRW5kID09PSAtMSkgewogICAgICAgICAgICAgIHZhbHVlRW5kID0gaW5mby5sZW5ndGg7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZW5kQ29vcmRpbmF0ZSA9IHBhcnNlSW50KGluZm8uc2xpY2UoaiArIDQsIHZhbHVlRW5kKSwgMTApOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIHByZXZDaGFyID0gaW5mb1tqXTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoaXNUUkEpIHsKICAgICAgICByZXR1cm4gc3RhcnRDb29yZGluYXRlICsgMTsKICAgICAgfQogICAgICByZXR1cm4gZW5kQ29vcmRpbmF0ZTsKICAgIH0KICAgIGFzeW5jIGxpbmVDb3VudChyZWZOYW1lLCBvcHRzID0ge30pIHsKICAgICAgcmV0dXJuIHRoaXMuaW5kZXgubGluZUNvdW50KHJlZk5hbWUsIG9wdHMpOwogICAgfQogICAgYXN5bmMgX3JlYWRSZWdpb24ocG9zLCBzaXplLCBvcHRzID0ge30pIHsKICAgICAgY29uc3QgYiA9IGltcG9ydF9idWZmZXIuQnVmZmVyLmFsbG9jKHNpemUpOwogICAgICBjb25zdCB7IGJ5dGVzUmVhZCwgYnVmZmVyIH0gPSBhd2FpdCB0aGlzLmZpbGVoYW5kbGUucmVhZChiLCAwLCBzaXplLCBwb3MsIG9wdHMpOwogICAgICByZXR1cm4gYnVmZmVyLnNsaWNlKDAsIGJ5dGVzUmVhZCk7CiAgICB9CiAgICBhc3luYyByZWFkQ2h1bmsoYywgb3B0cyA9IHt9KSB7CiAgICAgIGNvbnN0IGRhdGEgPSBhd2F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IKICAgICAgfSwKICAgICAgQURGOiB7CiAgICAgICAgTnVtYmVyOiAiUiIsCiAgICAgICAgVHlwZTogIkludGVnZXIiLAogICAgICAgIERlc2NyaXB0aW9uOiAiUmVhZCBkZXB0aCBmb3IgZWFjaCBhbGxlbGUgb24gdGhlIGZvcndhcmQgc3RyYW5kIgogICAgICB9LAogICAgICBBRFI6IHsKICAgICAgICBOdW1iZXI6ICJSIiwKICAgICAgICBUeXBlOiAiSW50ZWdlciIsCiAgICAgICAgRGVzY3JpcHRpb246ICJSZWFkIGRlcHRoIGZvciBlYWNoIGFsbGVsZSBvbiB0aGUgcmV2ZXJzZSBzdHJhbmQiCiAgICAgIH0sCiAgICAgIEFGOiB7CiAgICAgICAgTnVtYmVyOiAiQSIsCiAgICAgICAgVHlwZTogIkZsb2F0IiwKICAgICAgICBEZXNjcmlwdGlvbjogIkFsbGVsZSBmcmVxdWVuY3kgZm9yIGVhY2ggQUxUIGFsbGVsZSBpbiB0aGUgc2FtZSBvcmRlciBhcyBsaXN0ZWQgKGVzdGltYXRlZCBmcm9tIHByaW1hcnkgZGF0YSwgbm90IGNhbGxlZCBnZW5vdHlwZXMpIgogICAgICB9LAogICAgICBBTjogewogICAgICAgIE51bWJlcjogMSwKICAgICAgICBUeXBlOiAiSW50ZWdlciIsCiAgICAgICAgRGVzY3JpcHRpb246ICJUb3RhbCBudW1iZXIgb2YgYWxsZWxlcyBpbiBjYWxsZWQgZ2Vub3R5cGVzIgogICAgICB9LAogICAgICBCUTogewogICAgICAgIE51bWJlcjogMSwKICAgICAgICBUeXBlOiAiRmxvYXQiLAogICAgICAgIERlc2NyaXB0aW9uOiAiUk1TIGJhc2UgcXVhbGl0eSIKICAgICAgfSwKICAgICAgQ0lHQVI6IHsKICAgICAgICBOdW1iZXI6IDEsCiAgICAgICAgVHlwZTogIkZsb2F0IiwKICAgICAgICBEZXNjcmlwdGlvbjogIkNpZ2FyIHN0cmluZyBkZXNjcmliaW5nIGhvdyB0byBhbGlnbiBhbiBhbHRlcm5hdGUgYWxsZWxlIHRvIHRoZSByZWZlcmVuY2UgYWxsZWxlIgogICAgICB9LAogICAgICBEQjogewogICAgICAgIE51bWJlcjogMCwKICAgICAgICBUeXBlOiAiRmxhZyIsCiAgICAgICAgRGVzY3JpcHRpb246ICJkYlNOUCBtZW1iZXJzaGlwIgogICAgICB9LAogICAgICBEUDogewogICAgICAgIE51bWJlcjogMSwKICAgICAgICBUeXBlOiAiSW50ZWdlciIsCiAgICAgICAgRGVzY3JpcHRpb246ICJjb21iaW5lZCBkZXB0aCBhY3Jvc3Mgc2FtcGxlcyIKICAgICAgfSwKICAgICAgRU5EOiB7CiAgICAgICAgTnVtYmVyOiAxLAogICAgICAgIFR5cGU6ICJJbnRlZ2VyIiwKICAgICAgICBEZXNjcmlwdGlvbjogIkVuZCBwb3NpdGlvbiAoZm9yIHVzZSB3aXRoIHN5bWJvbGljIGFsbGVsZXMpIgogICAgICB9LAogICAgICBIMjogewogICAgICAgIE51bWJlcjogMCwKICAgICAgICBUeXBlOiAiRmxhZyIsCiAgICAgICAgRGVzY3JpcHRpb246ICJIYXBNYXAyIG1lbWJlcnNoaXAiCiAgICAgIH0sCiAgICAgIEgzOiB7CiAgICAgICAgTnVtYmVyOiAwLAogICAgICAgIFR5cGU6ICJGbGFnIiwKICAgICAgICBEZXNjcmlwdGlvbjogIkhhcE1hcDMgbWVtYmVyc2hpcCIKICAgICAgfSwKICAgICAgTVE6IHsKICAgICAgICBOdW1iZXI6IDEsCiAgICAgICAgVHlwZTogbnVsbCwKICAgICAgICBEZXNjcmlwdGlvbjogIlJNUyBtYXBwaW5nIHF1YWxpdHkiCiAgICAgIH0sCiAgICAgIE1RMDogewogICAgICAgIE51bWJlcjogMSwKICAgICAgICBUeXBlOiAiSW50ZWdlciIsCiAgICAgICAgRGVzY3JpcHRpb246ICJOdW1iZXIgb2YgTUFQUSA9PSAwIHJlYWRzIgogICAgICB9LAogICAgICBOUzogewogICAgICAgIE51bWJlcjogMSwKICAgICAgICBUeXBlOiAiSW50ZWdlciIsCiAgICAgICAgRGVzY3JpcHRpb246ICJOdW1iZXIgb2Ygc2FtcGxlcyB3aXRoIGRhdGEiCiAgICAgIH0sCiAgICAgIFNCOiB7CiAgICAgICAgTnVtYmVyOiA0LAogICAgICAgIFR5cGU6ICJJbnRlZ2VyIiwKICAgICAgICBEZXNjcmlwdGlvbjogIlN0cmFuZCBiaWFzIgogICAgICB9LAogICAgICBTT01BVElDOiB7CiAgICAgICAgTnVtYmVyOiAwLAogICAgICAgIFR5cGU6ICJGbGFnIiwKICAgICAgICBEZXNjcmlwdGlvbjogIlNvbWF0aWMgbXV0YXRpb24gKGZvciBjYW5jZXIgZ2Vub21pY3MpIgogICAgICB9LAogICAgICBWQUxJREFURUQ6IHsKICAgICAgICBOdW1iZXI6IDAsCiAgICAgICAgVHlwZTogIkZsYWciLAogICAgICAgIERlc2NyaXB0aW9uOiAiVmFsaWRhdGVkIGJ5IGZvbGxvdy11cCBleHBlcmltZW50IgogICAgICB9LAogICAgICAiMTAwMEciOiB7CiAgICAgICAgTnVtYmVyOiAwLAogICAgICAgIFR5cGU6ICJGbGFnIiwKICAgICAgICBEZXNjcmlwdGlvbjogIjEwMDAgR2Vub21lcyBtZW1iZXJzaGlwIgogICAgICB9LAogICAgICBJTVBSRUNJU0U6IHsKICAgICAgICBOdW1iZXI6IDAsCiAgICAgICAgVHlwZTogIkZsYWciLAogICAgICAgIERlc2NyaXB0aW9uOiAiSW1wcmVjaXNlIHN0cnVjdHVyYWwgdmFyaWF0aW9uIgogICAgICB9LAogICAgICBOT1ZFTDogewogICAgICAgIE51bWJlcjogMCwKICAgICAgICBUeXBlOiAiRmxhZyIsCiAgICAgICAgRGVzY3JpcHRpb246ICJJbmRpY2F0ZXMgYSBub3ZlbCBzdHJ1Y3R1cmFsIHZhcmlhdGlvbiIKICAgICAgfSwKICAgICAgU1ZUWVBFOiB7CiAgICAgICAgTnVtYmVyOiAxLAogICAgICAgIFR5cGU6ICJ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bjogIklEIG9mIHRoZSBhc3NlbWJsZWQgYWx0ZXJuYXRlIGFsbGVsZSBpbiB0aGUgYXNzZW1ibHkgZmlsZSIKICAgICAgfSwKICAgICAgTUVJTkZPOiB7CiAgICAgICAgTnVtYmVyOiA0LAogICAgICAgIFR5cGU6ICJTdHJpbmciLAogICAgICAgIERlc2NyaXB0aW9uOiAiTW9iaWxlIGVsZW1lbnQgaW5mbyBvZiB0aGUgZm9ybSBOQU1FLFNUQVJULEVORCxQT0xBUklUWSIKICAgICAgfSwKICAgICAgTUVUUkFOUzogewogICAgICAgIE51bWJlcjogNCwKICAgICAgICBUeXBlOiAiU3RyaW5nIiwKICAgICAgICBEZXNjcmlwdGlvbjogIk1vYmlsZSBlbGVtZW50IHRyYW5zZHVjdGlvbiBpbmZvIG9mIHRoZSBmb3JtIENIUixTVEFSVCxFTkQsUE9MQVJJVFkiCiAgICAgIH0sCiAgICAgIERHVklEOiB7CiAgICAgICAgTnVtYmVyOiAxLAogICAgICAgIFR5cGU6ICJTdHJpbmciLAogICAgICAgIERlc2NyaXB0aW9uOiAiSUQgb2YgdGhpcyBlbGVtZW50IGluIERhdGFiYXNlIG9mIEdlbm9taWMgVmFyaWF0aW9uIgogICAgICB9LAogICAgICBEQlZBUklEOiB7CiAgICAgICAgTnVtYmVyOiAxLAogICAgICAgIFR5cGU6ICJTdHJpbmciLAogICAgICAgIERlc2NyaXB0aW9uOiAiSUQgb2YgdGhpcyBlbGVtZW50IGluIERCVkFSIgogICAgICB9LAogICAgICBEQlJJUElEOiB7CiAgICAgICAgTnVtYmVyOiAxLAogICAgICAgIFR5cGU6ICJTdHJpbmciLAogICAgICAgIERlc2NyaXB0aW9uOiAiSUQgb2YgdGhpcyBlbGVtZW50IGluIERCUklQIgogICAgICB9LAogICAgICBNQVRFSUQ6IHsKICAgICAgICBOdW1iZXI6IG51bGwsCiAgICAgICAgVHlwZTogIlN0cmluZyIsCiAgICAgICAgRGVzY3JpcHRpb246ICJJRCBvZiBtYXR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W5kIGNvcHkgbnVtYmVyIGZvciB0aGUgc2VnbWVudCIKICAgICAgfSwKICAgICAgQ0lDTkFESjogewogICAgICAgIE51bWJlcjogbnVsbCwKICAgICAgICBUeXBlOiAiSW50ZWdlciIsCiAgICAgICAgRGVzY3JpcHRpb246ICJDb25maWRlbmNlIGludGVydmFsIGFyb3VuZCBjb3B5IG51bWJlciBmb3IgdGhlIGFkamFjZW5jeSIKICAgICAgfQogICAgfSwKICAgIEdlbm90eXBlRmllbGRzOiB7CiAgICAgIEFEOiB7CiAgICAgICAgTnVtYmVyOiAiUiIsCiAgICAgICAgVHlwZTogIkludGVnZXIiLAogICAgICAgIERlc2NyaXB0aW9uOiAiUmVhZCBkZXB0aCBmb3IgZWFjaCBhbGxlbGUiCiAgICAgIH0sCiAgICAgIEFERjogewogICAgICAgIE51bWJlcjogIlIiLAogICAgICAgIFR5cGU6ICJJbnRlZ2VyIiwKICAgICAgICBEZXNjcmlwdGlvbjogIlJlYWQgZGVwdGggZm9yIGVhY2ggYWxsZWxlIG9uIHRoZSBmb3J3YXJkIHN0cmFuZCIKICAgICAgfSwKICAgICAgQURSOiB7CiAgICAgICAgTnVtYmVyOiAiUiIsCiAgICAgICAgVHlwZTogIkludGVnZXIiLAogICAgICAgIERlc2NyaXB0aW9uOiAiUmVhZCBkZXB0aCBmb3IgZWFjaCBhbGxlbGUgb24gdGhlIHJldmVyc2Ugc3RyYW5kIgogICAgICB9LAogICAgICBEUDogewogICAgICAgIE51bWJlcjogMSwKICAgICAgICBUeXBlOiAiSW50ZWdlciIsCiAgICAgICAgRGVzY3JpcHRpb246ICJSZWFkIGRlcHRoIgogICAgICB9LAogICAgICBFQzogewogICAgICAgIE51bWJlcjogIkEiLAogICAgICAgIFR5cGU6ICJJbnRlZ2VyIiwKICAgICAgICBEZXNjcmlwdGlvbjogIkV4cGVjdGVkIGFsdGVybmF0ZSBhbGxlbGUgY291bnRzIgogICAgICB9LAogICAgICBGVDogewogICAgICAgIE51bWJlcjogMSwKICAgICAgICBUeXBlOiAiU3RyaW5nIiwKICAgICAgICBEZXNjcmlwdGlvbjogJ0ZpbHRlciBpbmRpY2F0aW5nIGlmIHRoaXMgZ2Vub3R5cGUgd2FzICJjYWxsZWQiJwogICAgICB9LAogICAgICBHTDogewogICAgICAgIE51bWJlcjogIkciLAogICAgICAgIFR5cGU6ICJGbG9hdCIsCiAgICAgICAgRGVzY3JpcHRpb246ICJHZW5vdHlwZSBsaWtlbGlob29kcyIKICAgICAgfSwKICAgICAgR1A6IHsKICAgICAgICBOdW1iZXI6ICJHIiwKICAgICAgICBUeXBlOiAiRmxvYXQiLAogICAgICAgIERlc2NyaXB0aW9uOiAiR2Vub3R5cGUgcG9zdGVyaW9yIHByb2JhYmlsaXRpZXMiCiAgICAgIH0sCiAgICAgIEdROiB7CiAgICAgICAgTnVtYmVyOiAxLAogICAgICAgIFR5cGU6ICJJbnRlZ2VyIiwKICAgICAgICBEZXNjcmlwdGlvbjogIkNvbmRpdGlvbmFsIGdlbm90eXBlIHF1YWxpdHkiCiAgICAgIH0sCiAgICAgIEdUOiB7CiAgICAgICAgTnVtYmVyOiAxLAogICAgICAgIFR5cGU6ICJTdHJpbmciLAogICAgICAgIERlc2NyaXB0aW9uOiAiR2Vub3R5cGUiCiAgICAgIH0sCiAgICAgIEhROiB7CiAgICAgICAgTnVtYmVyOiAyLAogICAgICAgIFR5cGU6ICJJbnRlZ2VyIiwKICAgICAgICBEZXNjcmlwdGlvbjogIkhhcGxvdHlwZSBxdWFsaXR5IgogICAgICB9LAogICAgICBNUTogewogICAgICAgIE51bWJlcjogMSwKICAgICAgICBUeXBlOiAiSW50ZWdlciIsCiAgICAgICAgRGVzY3JpcHRpb246ICJSTVMgbWFwcGluZyBxdWFsaXR5IgogICAgICB9LAogICAgICBQTDogewogICAgICAgIE51bWJlcjogIkciLAogICAgICAgIFR5cGU6ICJJbnRlZ2VyIiwKICAgICAgICBEZXNjcmlwdGlvbjogIlBocmVkLXNjYWxlZCBnZW5vdHlwZSBsaWtlbGlob29kcyByb3VuZGVkIHRvIHRoZSBjbG9zZXN0IGludGVnZXIiCiAgICAgIH0sCiAgICAgIFBROiB7CiAgICAgICAgTnVtYmVyOiAxLAogICAgICAgIFR5cGU6ICJJbnRlZ2VyIiwKICAgICAgICBEZXNjcmlwdGlvbjogIlBoYXNpbmcgcXVhbGl0eSIKICAgICAgfSwKICAgICAgUFM6IHsKICAgICAgICBOdW1iZXI6IDEsCiAgICAgICAgVHlwZTogIkludGVnZXIiLAogICAgICAgIERlc2NyaXB0aW9uOiAiUGhhc2Ugc2V0IgogICAgICB9CiAgICB9LAogICAgQWx0VHlwZXM6IHsKICAgICAgREVMOiB7CiAgICAgICAgRGVzY3JpcHRpb246ICJEZWxldGlvbiByZWxhdGl2ZSB0byB0aGUgcmVmZXJlbmNlIgogICAgICB9LAogICAgICBJTlM6IHsKICAgICAgICBEZXNjcmlwdGlvbjogIkluc2VydGlvbiBvZiBub3ZlbCBzZXF1ZW5jZSByZWxhdGl2ZSB0byB0aGUgcmVmZXJlbmNlIgogICAgICB9LAogICAgICBEVVA6IHsKICAgICAgICBEZXNjcmlwdGlvbjogIlJlZ2lvbiBvZiBlbGV2YXRlZCBjb3B5IG51bWJlciByZWxhdGl2ZSB0byB0aGUgcmVmZXJlbmNlIgogICAgICB9LAogICAgICBJTlY6IHsKICAgICAgICBEZXNjcmlwdGlvbjogIkludmVyc2lvbiBvZiByZWZlcmVuY2Ugc2VxdWVuY2UiCiAgICAgIH0sCiAgICAgIENOVjogewogICAgICAgIERlc2NyaXB0aW9uOiAiQ29weSBudW1iZXIgdmFyaWFibGUgcmVnaW9uIChtYXkgYmUgYm90aCBkZWxldGlvbiBhbmQgZHVwbGljYXRpb24pIgogICAgICB9LAogICAgICAiRFVQOlRBTkRFTSI6IHsKICAgICAgICBEZXNjcmlwdGlvbjogIlRhbmRlbSBkdXBsaWNhdGlvbiIKICAgICAgfSwKICAgICAgIkRFTDpNRSI6IHsKICAgICAgICBEZXNj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XlzID0gZm9ybWF0ID09PSBudWxsIHx8IGZvcm1hdCA9PT0gdm9pZCAwID8gdm9pZCAwIDogZm9ybWF0LnNwbGl0KCI6Iik7CiAgICAgIGlmIChmb3JtYXRLZXlzKSB7CiAgICAgICAgdGhpcy5zYW1wbGVzLmZvckVhY2goKHNhbXBsZSwgaW5kZXgpID0+IHsKICAgICAgICAgIGdlbm90eXBlc1tzYW1wbGVdID0ge307CiAgICAgICAgICBmb3JtYXRLZXlzLmZvckVhY2goKGtleSkgPT4gewogICAgICAgICAgICBnZW5vdHlwZXNbc2FtcGxlXVtrZXldID0gbnVsbDsKICAgICAgICAgIH0pOwogICAgICAgICAgcmVzdFtpbmRleF0uc3BsaXQoIjoiKS5maWx0ZXIoKGYpID0+IGYpLmZvckVhY2goKHZhbCwgaW5kZXgyKSA9PiB7CiAgICAgICAgICAgIGxldCB0aGlzVmFsdWU7CiAgICAgICAgICAgIGlmICh2YWwgPT09ICIiIHx8IHZhbCA9PT0gIi4iIHx8IHZhbCA9PT0gdm9pZCAwKSB7CiAgICAgICAgICAgICAgdGhpc1ZhbHVlID0gbnVsbDsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjb25zdCBlbnRyaWVzID0gdmFsLnNwbGl0KCIsIikubWFwKChlbnQpID0+IGVudCA9PT0gIi4iID8gbnVsbCA6IGVudCk7CiAgICAgICAgICAgICAgY29uc3QgdmFsdWVUeXBlID0gdGhpcy5nZXRNZXRhZGF0YSgiRk9STUFUIiwgZm9ybWF0S2V5c1tpbmRleDJdLCAiVHlwZSIpOwogICAgICAgICAgICAgIGlmICh2YWx1ZVR5cGUgPT09ICJJbnRlZ2VyIiB8fCB2YWx1ZVR5cGUgPT09ICJGbG9hdCIpIHsKICAgICAgICAgICAgICAgIHRoaXNWYWx1ZSA9IGVudHJpZXMubWFwKCh2YWwyKSA9PiB2YWwyID8gK3ZhbDIgOiB2YWwyKTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgdGhpc1ZhbHVlID0gZW50cmllczsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZ2Vub3R5cGVzW3NhbXBsZV1bZm9ybWF0S2V5c1tpbmRleDJdXSA9IHRoaXNWYWx1ZTsKICAgICAgICAgIH0sIHt9KTsKICAgICAgICB9KTsKICAgICAgfQogICAgICByZXR1cm4gZ2Vub3R5cGVzOwogICAgfQogICAgX3BhcnNlTWV0YWRhdGEobGluZSkgewogICAgICBjb25zdCBtYXRjaCA9IGxpbmUudHJpbSgpLm1hdGNoKC9eIyMoLis/KT0oLiopLyk7CiAgICAgIGlmICghbWF0Y2gpIHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYExpbmUgaXMgbm90IGEgdmFsaWQgbWV0YWRhdGEgbGluZTogJHtsaW5lfWApOwogICAgICB9CiAgICAgIGNvbnN0IFttZXRhS2V5LCBtZXRhVmFsXSA9IG1hdGNoLnNsaWNlKDEsIDMpOwogICAgICBpZiAobWV0YVZhbC5zdGFydHNXaXRoKCI8IikpIHsKICAgICAgICBpZiAoIShtZXRhS2V5IGluIHRoaXMubWV0YWRhdGEpKSB7CiAgICAgICAgICB0aGlzLm1ldGFkYXRhW21ldGFLZXldID0ge307CiAgICAgICAgfQogICAgICAgIGNvbnN0IFtpZCwga2V5VmFsc10gPSB0aGlzLl9wYXJzZVN0cnVjdHVyZWRNZXRhVmFsKG1ldGFWYWwpOwogICAgICAgIHRoaXMubWV0YWRhdGFbbWV0YUtleV1baWRdID0ga2V5VmFsczsKICAgICAgfSBlbHNlIHsKICAgICAgICB0aGlzLm1ldGFkYXRhW21ldGFLZXldID0gbWV0YVZhbDsKICAgICAgfQogICAgfQogICAgX3BhcnNlU3RydWN0dXJlZE1ldGFWYWwobWV0YVZhbCkgewogICAgICBjb25zdCBrZXlWYWxzID0gdGhpcy5fcGFyc2VLZXlWYWx1ZShtZXRhVmFsLnJlcGxhY2UoL148fD4kL2csICIiKSwgIiwiKTsKICAgICAgY29uc3QgaWQgPSBrZXlWYWxzLklEOwogICAgICBkZWxldGUga2V5VmFscy5JRDsKICAgICAgaWYgKCJOdW1iZXIiIGluIGtleVZhbHMpIHsKICAgICAgICBpZiAoIU51bWJlci5pc05hTihOdW1iZXIoa2V5VmFscy5OdW1iZXIpKSkgewogICAgICAgICAga2V5VmFscy5OdW1iZXIgPSBOdW1iZXIoa2V5VmFscy5OdW1iZXIpOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gW2lkLCBrZXlWYWxzXTsKICAgIH0KICAgIGdldE1ldGFkYXRhKC4uLmFyZ3MpIHsKICAgICAgbGV0IGZpbHRlcmVkTWV0YWRhdGEgPSB0aGlzLm1ldGFkYXRhOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyZ3MubGVuZ3RoOyBpICs9IDEpIHsKICAgICAgICBmaWx0ZXJlZE1ldGFkYXRhID0gZmlsdGVyZWRNZXRhZGF0YVthcmdzW2ldXTsKICAgICAgICBpZiAoIWZpbHRlcmVkTWV0YWRhdGEpIHsKICAgICAgICAgIHJldHVybiBmaWx0ZXJlZE1ldGFkYXRhOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gZmlsdGVyZWRNZXRhZGF0YTsKICAgIH0KICAgIF9wYXJzZUtleVZhbHVlKHN0ciwgcGFpclNlcGFyYXRvciA9ICI7IikgewogICAgICBjb25zdCBkYXRhID0ge307CiAgICAgIGxldCBjdXJyS2V5ID0gIiI7CiAgICAgIGxldCBjdXJyVmFsdWUgPSAiIjsKICAgICAgbGV0IHN0YXRlID0gMTsKICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBzdHIubGVuZ3RoOyBpICs9IDEpIHsKICAgICAgICBpZiAoc3RhdGUgPT09IDEpIHsKICAgICAgICAgIGlmIChzdHJbaV0gPT09ICI9IikgewogICAgICAgICAgICBzdGF0ZSA9IDI7CiAgICAgICAgICB9IGVsc2UgaWYgKHN0cltpXSAhPT0gcGFpclNlcGFyYXRvcikgewogICAgICAgICAgICBjdXJyS2V5ICs9IHN0cltpXTsKICAgICAgICAgIH0gZWxzZSBpZiAoY3VyclZhbHVlID09PSAiIikgewogICAgICAgICAgICBkYXRhW2N1cnJLZXldID0gbnVsbDsKICAgICAgICAgICAgY3VycktleSA9ICIiOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoc3RhdGUgPT09IDIpIHsKICAgICAgICAgIGlmIChzdHJbaV0gPT09IHBhaXJTZXBhcmF0b3IpIHsKICAgICAgICAgICAgZGF0YVtjdXJyS2V5XSA9IGN1cnJWYWx1ZTsKICAgICAgICAgICAgY3VycktleSA9ICIiOwogICAgICAgICAgICBjdXJyVmFsdWUgPSAiIjsKICAgICAgICAgICAgc3RhdGUgPSAxOwogICAgICAgICAgfSBlbHNlIGlmIChzdHJbaV0gPT09ICciJykgewogICAgICAgICAgICBzdGF0ZSA9IDM7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjdXJyVmFsdWUgKz0gc3RyW2ldOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoc3RhdGUgPT09IDMpIHsKICAgICAgICAgIGlmIChzdHJbaV0gIT09ICciJykgewogICAgICAgICAgICBjdXJyVmFsdWUgKz0gc3RyW2ldOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhdGUgPSAyOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoc3RhdGUgPT09IDIgfHwgc3RhdGUgPT09IDMpIHsKICAgICAgICBkYXRhW2N1cnJLZXldID0gY3VyclZhbHVlOwogICAgICB9IGVsc2UgaWYgKHN0YXRlID09PSAxKSB7CiAgICAgICAgZGF0YVtjdXJyS2V5XSA9IG51bGw7CiAgICAgIH0KICAgICAgcmV0dXJuIGRhdGE7CiAgICB9CiAgICBwYXJzZUxpbmUobGluZSkgewogICAgICBsaW5lID0gbGluZS50cmltKCk7CiAgICAgIGlmICghbGluZS5sZW5ndGgpIHsKICAgICAgIC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NwZWNpZmllZCwgbXVzdCBjb250YWluIGF0IGxlYXN0IGEgJy4nICh0dXJuIG9mZiBzdHJpY3QgbW9kZSB0byBhbGxvdykiKTsKICAgICAgfQogICAgICBjb25zdCBpbmZvID0gZmllbGRzWzddID09PSB2b2lkIDAgfHwgZmllbGRzWzddID09PSAiLiIgPyB7fSA6IHRoaXMuX3BhcnNlS2V5VmFsdWUoZmllbGRzWzddKTsKICAgICAgT2JqZWN0LmtleXMoaW5mbykuZm9yRWFjaCgoa2V5KSA9PiB7CiAgICAgICAgbGV0IGl0ZW1zOwogICAgICAgIGlmIChpbmZvW2tleV0pIHsKICAgICAgICAgIGl0ZW1zID0gaW5mb1trZXldLnNwbGl0KCIsIikubWFwKCh2YWwpID0+IHZhbCA9PT0gIi4iID8gbnVsbCA6IHZhbCkubWFwKChmKSA9PiBmID8gZGVjb2RlVVJJQ29tcG9uZW50Tm9UaHJvdyhmKSA6IGYpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBpdGVtcyA9IGluZm9ba2V5XTsKICAgICAgICB9CiAgICAgICAgY29uc3QgaXRlbVR5cGUgPSB0aGlzLmdldE1ldGFkYXRhKCJJTkZPIiwga2V5LCAiVHlwZSIpOwogICAgICAgIGlmIChpdGVtVHlwZSkgewogICAgICAgICAgaWYgKGl0ZW1UeXBlID09PSAiSW50ZWdlciIgfHwgaXRlbVR5cGUgPT09ICJGbG9hdCIpIHsKICAgICAgICAgICAgaXRlbXMgPSBpdGVtcy5tYXAoKHZhbCkgPT4gewogICAgICAgICAgICAgIGlmICh2YWwgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICByZXR1cm4gTnVtYmVyKHZhbCk7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgfSBlbHNlIGlmIChpdGVtVHlwZSA9PT0gIkZsYWciKSB7CiAgICAgICAgICAgIGlmIChpbmZvW2tleV0pIHsKICAgICAgICAgICAgICBjb25zb2xlLndhcm4oYEluZm8gZmllbGQgJHtrZXl9IGlzIGEgRmxhZyBhbmQgc2hvdWxkIG5vdCBoYXZlIGEgdmFsdWUgKGdvdCB2YWx1ZSAke2luZm9ba2V5XX0pYCk7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgaXRlbXMgPSB0cnVlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGluZm9ba2V5XSA9IGl0ZW1zOwogICAgICB9KTsKICAgICAgY29uc3QgdmFyaWFudCA9IG5ldyBWYXJpYW50KHsKICAgICAgICBDSFJPTTogY2hyb20sCiAgICAgICAgUE9TOiBwb3MsCiAgICAgICAgQUxUOiBhbHQsCiAgICAgICAgSU5GTzogaW5mbywKICAgICAgICBSRUY6IHJlZiwKICAgICAgICBGSUxURVI6IGZpbHRlciAmJiBmaWx0ZXIubGVuZ3RoID09PSAxICYmIGZpbHRlclswXSA9PT0gIlBBU1MiID8gIlBBU1MiIDogZmlsdGVyLAogICAgICAgIElEOiBpZCwKICAgICAgICBRVUFMOiBxdWFsCiAgICAgIH0pOwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodmFyaWFudCwgIlNBTVBMRVMiLCB7CiAgICAgICAgZ2V0KCkgewogICAgICAgICAgY29uc3Qgc2FtcGxlcyA9IHBhcnNlci5fcGFyc2VHZW5vdHlwZXMoZmllbGRzWzhdLCByZXN0KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiU0FNUExFUyIsIHsKICAgICAgICAgICAgdmFsdWU6IHNhbXBsZXMsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogZmFsc2UKICAgICAgICAgIH0pOwogICAgICAgICAgcmV0dXJuIHNhbXBsZXM7CiAgICAgICAgfSwKICAgICAgICBjb25maWd1cmFibGU6IHRydWUKICAgICAgfSk7CiAgICAgIHJldHVybiB2YXJpYW50OwogICAgfQogIH07CgogIC8vIG5v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ID0gZjsKICAgIGlmIChmLmxlbmd0aCA9PT0gMSkgewogICAgICBkZWx0YSA9IChkLCB4KSA9PiBmKGQpIC0geDsKICAgICAgY29tcGFyZTIgPSBhc2NlbmRpbmdDb21wYXJhdG9yKGYpOwogICAgfQogICAgZnVuY3Rpb24gbGVmdChhLCB4LCBsbywgaGkpIHsKICAgICAgaWYgKGxvID09IG51bGwpCiAgICAgICAgbG8gPSAwOwogICAgICBpZiAoaGkgPT0gbnVsbCkKICAgICAgICBoaSA9IGEubGVuZ3RoOwogICAgICB3aGlsZSAobG8gPCBoaSkgewogICAgICAgIGNvbnN0IG1pZCA9IGxvICsgaGkgPj4+IDE7CiAgICAgICAgaWYgKGNvbXBhcmUyKGFbbWlkXSwgeCkgPCAwKQogICAgICAgICAgbG8gPSBtaWQgKyAxOwogICAgICAgIGVsc2UKICAgICAgICAgIGhpID0gbWlkOwogICAgICB9CiAgICAgIHJldHVybiBsbzsKICAgIH0KICAgIGZ1bmN0aW9uIHJpZ2h0KGEsIHgsIGxvLCBoaSkgewogICAgICBpZiAobG8gPT0gbnVsbCkKICAgICAgICBsbyA9IDA7CiAgICAgIGlmIChoaSA9PSBudWxsKQogICAgICAgIGhpID0gYS5sZW5ndGg7CiAgICAgIHdoaWxlIChsbyA8IGhpKSB7CiAgICAgICAgY29uc3QgbWlkID0gbG8gKyBoaSA+Pj4gMTsKICAgICAgICBpZiAoY29tcGFyZTIoYVttaWRdLCB4KSA+IDApCiAgICAgICAgICBoaSA9IG1pZDsKICAgICAgICBlbHNlCiAgICAgICAgICBsbyA9IG1pZCArIDE7CiAgICAgIH0KICAgICAgcmV0dXJuIGxvOwogICAgfQogICAgZnVuY3Rpb24gY2VudGVyKGEsIHgsIGxvLCBoaSkgewogICAgICBpZiAobG8gPT0gbnVsbCkKICAgICAgICBsbyA9IDA7CiAgICAgIGlmIChoaSA9PSBudWxsKQogICAgICAgIGhpID0gYS5sZW5ndGg7CiAgICAgIGNvbnN0IGkgPSBsZWZ0KGE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UIiwKICAgICAgICAgIHJlZGlyZWN0OiAiZm9sbG93IiwKICAgICAgICAgIG1vZGU6ICJjb3JzIiwKICAgICAgICAgIHNpZ25hbAogICAgICAgIH0pOwogICAgICAgIGNvbnN0IHJlc3BvbnNlID0geWllbGQgdGhpcy5mZXRjaCh0aGlzLnVybCwgYXJncyk7CiAgICAgICAgaWYgKCFyZXNwb25zZS5vaykgewogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBIVFRQICR7cmVzcG9uc2Uuc3RhdHVzfSAke3Jlc3BvbnNlLnN0YXR1c1RleHR9ICR7dGhpcy51cmx9YCk7CiAgICAgICAgfQogICAgICAgIGlmIChyZXNwb25zZS5zdGF0dXMgPT09IDIwMCB8fCByZXNwb25zZS5zdGF0dXMgPT09IDIwNikgewogICAgICAgICAgY29uc3QgcmVzcG9uc2VEYXRhID0geWllbGQgdGhpcy5nZXRCdWZmZXJGcm9tUmVzcG9uc2UocmVzcG9uc2UpOwogICAgICAgICAgY29uc3QgYnl0ZXNDb3BpZWQgPSByZXNwb25zZURhdGEuY29weShidWZmZXIsIG9mZnNldCwgMCwgTWF0aC5taW4obGVuZ3RoLCByZXNwb25zZURhdGEubGVuZ3RoKSk7CiAgICAgICAgICBjb25zdCByZXMgPSByZXNwb25zZS5oZWFkZXJzLmdldCgiY29udGVudC1yYW5nZSIpOwogICAgICAgICAgY29uc3Qgc2l6ZU1hdGNoID0gL1wvKFxkKykkLy5leGVjKHJlcyB8fCAiIik7CiAgICAgICAgICBpZiAoc2l6ZU1hdGNoICYmIHNpemVNYXRjaFsxXSkgewogICAgICAgICAgICB0aGlzLl9zdGF0ID0geyBzaXplOiBwYXJzZUludChzaXplTWF0Y2hbMV0sIDEwKSB9OwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIHsgYnl0ZXNSZWFkOiBieXRlc0NvcGllZCwgYnVmZmVyIH07CiAgICAgICAgfQogICAgICAgIHRocm93IG5ldyBFcnJvcihgSFRUUCAke3Jlc3BvbnNlLnN0YXR1c30gZmV0Y2hpbmcgJHt0aGlzLnVybH1gKTsKICAgICAgfSk7CiAgICB9CiAgfTsKCiAgLy8gc3JjL2RhdGEtZmV0Y2hlcnMvdmNmL3V0aWxzLnRzCiAgaW5pdF9idWZmZXJfc2hpbSgpOwogIHZhciBnZXRNdXRhdGlvblR5cGUgPSAocmVmLCBhbHQpID0+IHsKICAgIGlmICghYWx0KQogICAgICByZXR1cm4gInVua25vd24iOwogICAgaWYgKHJlZi5sZW5ndGggPT09IGFsdC5sZW5ndGgpCiAgICAgIHJldHVybiAic3Vic3RpdHV0aW9uIjsKICAgIGlmIChyZWYubGVuZ3RoID4gYWx0Lmxlbmd0aCkKICAgICAgcmV0dXJuICJkZWxldGlvbiI7CiAgICBpZiAocmVmLmxlbmd0aCA8IGFsdC5sZW5ndGgpCiAgICAgIHJldHVybiAiaW5zZXJ0aW9uIjsKICAgIHJldHVybiAidW5rbm93biI7CiAgfTsKICB2YXIgZ2V0U3Vic3RpdHV0aW9uVHlwZSA9IChyZWYsIGFsdCkgPT4gewogICAgc3dpdGNoIChyZWYgKyBhbHQpIHsKICAgICAgY2FzZSAiQ0EiOgogICAgICBjYXNlICJHVCI6CiAgICAgICAgcmV0dXJuICJDPkEiOwogICAgICBjYXNlICJDRyI6CiAgICAgIGNhc2UgIkdDIjoKICAgICAgICByZXR1cm4gIkM+RyI7CiAgICAgIGNhc2UgIkNUIjoKICAgICAgY2FzZSAiR0EiOgogICAgICAgIHJldHVybiAiQz5UIjsKICAgICAgY2FzZSAiVEEiOgogICAgICBjYXNlICJBVCI6CiAgICAgICAgcmV0dXJuICJUPkEiOwogICAgICBjYXNlICJUQyI6CiAgICAgIGNhc2UgIkFHIjoKICAgICAgICByZXR1cm4gIlQ+QyI7CiAgICAgIGNhc2UgIlRHIjoKICAgICAgY2FzZSAiQUMiOgogICAgICAgIHJldHVybiAiVD5HIjsKICAgICAgZGVmYXVsdDoKICAgICAgICByZXR1cm4gInVua25vd24iOwogICAgfQogI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IpKSB7CiAgICAgICAgICBjb25zdCBoZWFkZXIgPSB5aWVsZCB0aGlzLnRiaS5nZXRIZWFkZXIoKTsKICAgICAgICAgIF9fcHJpdmF0ZVNldCh0aGlzLCBfcGFyc2VyLCBuZXcgZXNtX2RlZmF1bHQoeyBoZWFkZXIgfSkpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gX19wcml2YXRlR2V0KHRoaXMsIF9wYXJzZXIpOwogICAgICB9KTsKICAgIH0KICAgIGdldFRpbGVEYXRhKG1pblgsIG1heFgpIHsKICAgICAgcmV0dXJuIF9fYXN5bmModGhpcywgbnVsbCwgZnVuY3Rpb24qICgpIHsKICAgICAgICBjb25zdCBzb3VyY2UgPSBkYXRhU291cmNlcy5nZXQoX19wcml2YXRlR2V0KHRoaXMsIF91aWQpKTsKICAgICAgICBjb25zdCBwYXJzZXIgPSB5aWVsZCB0aGlzLmdldFBhcnNlcigpOwogICAgICAgIGxldCBjdXJNaW5YID0gbWluWDsKICAgICAgICBjb25zdCB7IGNocm9tTGVuZ3RocywgY3VtUG9zaXRpb25zIH0gPSBzb3VyY2UuY2hyb21JbmZvOwogICAgICAgIGNvbnN0IHJlY29yZFByb21pc2VzID0gW107CiAgICAgICAgZm9yIChjb25zdCBjdW1Qb3Mgb2YgY3VtUG9zaXRpb25zKSB7CiAgICAgICAgICBjb25zdCBjaHJvbU5hbWUgPSBjdW1Qb3MuY2hyOwogICAgICAgICAgY29uc3QgY2hyb21TdGFydCA9IGN1bVBvcy5wb3M7CiAgICAgICAgICBjb25zdCBjaHJvbUVuZCA9IGN1bVBvcy5wb3MgKyBjaHJvbUxlbmd0aHNbY2hyb21OYW1lXTsKICAgICAgICAgIGxldCBzdGFydFBvcywgZW5kUG9zOwogICAgICAgICAgaWYgKGNocm9tU3RhcnQgPiBjdXJNaW5YIHx8IGN1ck1pblggPj0gY2hyb21FbmQpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBsZXQgcHJldlBPUzsKICAgICAgICAgIGNvbnN0IHRpbGVzUHJvbWlzZSA9IG5ldyBQcm9taXNlKChyZXNvbHZlKSA9PiB7CiAgICAgICAgICAgIGNvbnN0IHRpbGVzID0gW107CiAgICAgICAgICAgIGNvbnN0IGxpbmVDYWxsYmFjayA9IChsaW5lKSA9PiB7CiAgICAgICAgICAgICAgY29uc3QgdmNmUmVjb3JkID0gcGFyc2VyLnBhcnNlTGluZShsaW5lKTsKICAgICAgICAgICAgICBjb25zdCB2Y2ZUaWxlID0gcmVjb3JkVG9UaWxlKHZjZlJlY29yZCwgY2hyb21TdGFydCwgcHJldlBPUyk7CiAgICAgICAgICAgICAgcHJldlBPUyA9IHZjZlRpbGUuUE9TOwogICAgICAgICAgICAgIHRpbGVzLnB1c2godmNmVGlsZSk7CiAgICAgICAgICAgIH07CiAgICAgICAgICAgIGlmIChtYXhYID4gY2hyb21FbmQpIHsKICAgICAgICAgICAgICBzdGFydFBvcyA9IGN1ck1pblggLSBjaHJvbVN0YXJ0OwogICAgICAgICAgICAgIGVuZFBvcyA9IGNocm9tRW5kIC0gY2hyb21TdGFydDsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBzdGFydFBvcyA9IE1hdGguZmxvb3IoY3VyTWluWCAtIGNocm9tU3RhcnQpOwogICAgICAgICAgICAgIGVuZFBvcyA9IE1hdGguY2VpbChtYXhYIC0gY2hyb21TdGFydCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc291cmNlLmZpbGUudGJpLmdldExpbmVzKGNocm9tTmFtZSwgc3RhcnRQb3MsIGVuZFBvcywgbGluZUNhbGxiYWNrKS50aGVuKCgpID0+IHsKICAgICAgICAgICAgICByZXNvbHZlKHRpbGVzKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9KTsKICAgICAgICAgIHJlY29yZFByb21pc2VzLnB1c2godGlsZXNQcm9taXNlKTsKICAgICAgICAgIGlmIChtYXhYIDw9IGNocm9tRW5kKSB7CiAgICAgICAgICAg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WNlbnNlCiAqIExvZGFzaCAoQ3VzdG9tIEJ1aWxkKSA8aHR0cHM6Ly9sb2Rhc2guY29tLz4KICogQnVpbGQ6IGBsb2Rhc2ggbW9kdWxhcml6ZSBleHBvcnRzPSJlcyIgLW8gLi9gCiAqIENvcHlyaWdodCBPcGVuSlMgRm91bmRhdGlvbiBhbmQgb3RoZXIgY29udHJpYnV0b3JzIDxodHRwczovL29wZW5qc2Yub3JnLz4KICogUmVsZWFzZWQgdW5kZXIgTUlUIGxpY2Vuc2UgPGh0dHBzOi8vbG9kYXNoLmNvbS9saWNlbnNlPgogKiBCYXNlZCBvbiBVbmRlcnNjb3JlLmpzIDEuOC4zIDxodHRwOi8vdW5kZXJzY29yZWpzLm9yZy9MSUNFTlNFPgogKiBDb3B5cmlnaHQgSmVyZW15IEFzaGtlbmFzLCBEb2N1bWVudENsb3VkIGFuZCBJbnZlc3RpZ2F0aXZlIFJlcG9ydGVycyAmIEVkaXRvcnMKICovCg==",Ixe=typeof window<"u"&&window.Blob&&new Blob([atob(kJe)],{type:"text/javascript;charset=utf-8"});function Fli(){const e=Ixe&&(window.URL||window.webkitURL).createObjectURL(Ixe);try{return e?new Worker(e):new Worker("data:application/javascript;base64,"+kJe,{type:"module"})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const Yli=200;class XJe{constructor(i,n){this.dataConfig={},this.uid=i.libraries.slugid.nice(),this.prevRequestTime=0,this.toFetch=new Set;const{url:r,indexUrl:o,assembly:l,...c}=n;this.worker=YIe(new Fli).then(async u=>{const f=Object.entries(Sg(l).size);return await u.init(this.uid,{url:r,indexUrl:o},f,c),u})}async tilesetInfo(i){(await this.worker).tilesetInfo(this.uid).then(i)}fetchTilesDebounced(i,n){this.track.drawLoadingCue(),n.forEach(r=>this.toFetch.add(r)),this.fetchTimeout&&clearTimeout(this.fetchTimeout),this.fetchTimeout=setTimeout(()=>{this.sendFetch(i,[...this.toFetch]),this.toFetch.clear()},Yli)}async sendFetch(i,n){(await this.worker).fetchTilesDebounced(this.uid,n).then(i)}async getTabularData(i){const n=await(await this.worker).getTabularData(this.uid,i);return JSON.parse(new TextDecoder().decode(n))}}XJe.config={type:"vcf"};const OP=BigInt(32);function Kli(e,i,n){const r=+!!n,o=+!n;return BigInt(e.getInt32(i,n)*o+e.getInt32(i+4,n)*r)<>OP),l=Number(n&BigInt(4294967295));r?(e.setInt32(i+4,o,r),e.setUint32(i,l,r)):(e.setInt32(i,o,r),e.setUint32(i+4,l,r))}function zli(e,i,n,r){const o=Number(n>>OP),l=Number(n&BigInt(4294967295));r?(e.setUint32(i+4,o,r),e.setUint32(i,l,r)):(e.setUint32(i,o,r),e.setUint32(i+4,l,r))}"getBigInt64"in DataView||(DataView.prototype.getBigInt64=function(e,i){return Kli(this,e,i)});"getBigUint64"in DataView||(DataView.prototype.getBigUint64=function(e,i){return _li(this,e,i)});"setBigInt64"in DataView||(DataView.prototype.setBigInt64=function(e,i,n){Pli(this,e,i,n)});"setBigUint64"in DataView||(DataView.prototype.setBigUint64=function(e,i,n){zli(this,e,i,n)});let Oli=class{constructor(i,n){this.code="",this.scopes=[["vars"]],this.bitFields=[],this.tmpVariableCount=0,this.references=new Map,this.imports=[],this.reverseImports=new Map,this.useContextVariables=!1,this.importPath=i,this.useContextVariables=n}generateVariable(i){const n=[...this.scopes[this.scopes.length-1]];return i&&n.push(i),n.join(".")}generateOption(i){switch(typeof i){case"number":return i.toString();case"string":return this.generateVariable(i);case"function":return`${this.addImport(i)}.call(${this.generateVariable()}, vars)`}}generateError(i){this.pushCode(`throw new Error(${i});`)}generateTmpVariable(){return"$tmp"+this.tmpVariableCount++}pushCode(i){this.code+=i+` -`}pushPath(i){i&&this.scopes[this.scopes.length-1].push(i)}popPath(i){i&&this.scopes[this.scopes.length-1].pop()}pushScope(i){this.scopes.push([i])}popScope(){this.scopes.pop()}addImport(i){if(!this.importPath)return`(${i})`;let n=this.reverseImports.get(i);return n||(n=this.imports.push(i)-1,this.reverseImports.set(i,n)),`${this.importPath}[${n}]`}addReference(i){this.references.has(i)||this.references.set(i,{resolved:!1,requested:!1})}markResolved(i){const n=this.references.get(i);n&&(n.resolved=!0)}markRequested(i){i.forEach(n=>{const r=this.references.get(n);r&&(r.requested=!0)})}getUnresolvedReferences(){return Array.from(this.references).filter(([i,n])=>!n.resolved&&!n.requested).map(([i,n])=>i)}};const Yc=new Map,Jb="___parser_",Kc={uint8:1,uint16le:2,uint16be:2,uint32le:4,uint32be:4,int8:1,int16le:2,int16be:2,int32le:4,int32be:4,int64be:8,int64le:8,uint64be:8,uint64le:8,floatle:4,floatbe:4,doublele:8,doublebe:8},nF={uint8:"Uint8",uint16le:"Uint16",uint16be:"Uint16",uint32le:"Uint32",uint32be:"Uint32",int8:"Int8",int16le:"Int16",int16be:"Int16",int32le:"Int32",int32be:"Int32",int64be:"BigInt64",int64le:"BigInt64",uint64be:"BigUint64",uint64le:"BigUint64",floatle:"Float32",floatbe:"Float32",doublele:"Float64",doublebe:"Float64"},rF={uint8:!1,uint16le:!0,uint16be:!1,uint32le:!0,uint32be:!1,int8:!1,int16le:!0,int16be:!1,int32le:!0,int32be:!1,int64be:!1,int64le:!0,uint64be:!1,uint64le:!0,floatle:!0,floatbe:!1,doublele:!0,doublebe:!1};class pr{constructor(){this.varName="",this.type="",this.options={},this.endian="be",this.useContextVariables=!1}static start(){return new pr}primitiveGenerateN(i,n){const r=nF[i],o=rF[i];n.pushCode(`${n.generateVariable(this.varName)} = dataView.get${r}(offset, ${o});`),n.pushCode(`offset += ${Kc[i]};`)}primitiveN(i,n,r){return this.setNextParser(i,n,r)}useThisEndian(i){return i+this.endian.toLowerCase()}uint8(i,n={}){return this.primitiveN("uint8",i,n)}uint16(i,n={}){return this.primitiveN(this.useThisEndian("uint16"),i,n)}uint16le(i,n={}){return this.primitiveN("uint16le",i,n)}uint16be(i,n={}){return this.primitiveN("uint16be",i,n)}uint32(i,n={}){return this.primitiveN(this.useThisEndian("uint32"),i,n)}uint32le(i,n={}){return this.primitiveN("uint32le",i,n)}uint32be(i,n={}){return this.primitiveN("uint32be",i,n)}int8(i,n={}){return this.primitiveN("int8",i,n)}int16(i,n={}){return this.primitiveN(this.useThisEndian("int16"),i,n)}int16le(i,n={}){return this.primitiveN("int16le",i,n)}int16be(i,n={}){return this.primitiveN("int16be",i,n)}int32(i,n={}){return this.primitiveN(this.useThisEndian("int32"),i,n)}int32le(i,n={}){return this.primitiveN("int32le",i,n)}int32be(i,n={}){return this.primitiveN("int32be",i,n)}bigIntVersionCheck(){if(!DataView.prototype.getBigInt64)throw new Error("BigInt64 is unsupported on this runtime")}int64(i,n={}){return this.bigIntVersionCheck(),this.primitiveN(this.useThisEndian("int64"),i,n)}int64be(i,n={}){return this.bigIntVersionCheck(),this.primitiveN("int64be",i,n)}int64le(i,n={}){return this.bigIntVersionCheck(),this.primitiveN("int64le",i,n)}uint64(i,n={}){return this.bigIntVersionCheck(),this.primitiveN(this.useThisEndian("uint64"),i,n)}uint64be(i,n={}){return this.bigIntVersionCheck(),this.primitiveN("uint64be",i,n)}uint64le(i,n={}){return this.bigIntVersionCheck(),this.primitiveN("uint64le",i,n)}floatle(i,n={}){return this.primitiveN("floatle",i,n)}floatbe(i,n={}){return this.primitiveN("floatbe",i,n)}doublele(i,n={}){return this.primitiveN("doublele",i,n)}doublebe(i,n={}){return this.primitiveN("doublebe",i,n)}bitN(i,n,r){return r.length=i,this.setNextParser("bit",n,r)}bit1(i,n={}){return this.bitN(1,i,n)}bit2(i,n={}){return this.bitN(2,i,n)}bit3(i,n={}){return this.bitN(3,i,n)}bit4(i,n={}){return this.bitN(4,i,n)}bit5(i,n={}){return this.bitN(5,i,n)}bit6(i,n={}){return this.bitN(6,i,n)}bit7(i,n={}){return this.bitN(7,i,n)}bit8(i,n={}){return this.bitN(8,i,n)}bit9(i,n={}){return this.bitN(9,i,n)}bit10(i,n={}){return this.bitN(10,i,n)}bit11(i,n={}){return this.bitN(11,i,n)}bit12(i,n={}){return this.bitN(12,i,n)}bit13(i,n={}){return this.bitN(13,i,n)}bit14(i,n={}){return this.bitN(14,i,n)}bit15(i,n={}){return this.bitN(15,i,n)}bit16(i,n={}){return this.bitN(16,i,n)}bit17(i,n={}){return this.bitN(17,i,n)}bit18(i,n={}){return this.bitN(18,i,n)}bit19(i,n={}){return this.bitN(19,i,n)}bit20(i,n={}){return this.bitN(20,i,n)}bit21(i,n={}){return this.bitN(21,i,n)}bit22(i,n={}){return this.bitN(22,i,n)}bit23(i,n={}){return this.bitN(23,i,n)}bit24(i,n={}){return this.bitN(24,i,n)}bit25(i,n={}){return this.bitN(25,i,n)}bit26(i,n={}){return this.bitN(26,i,n)}bit27(i,n={}){return this.bitN(27,i,n)}bit28(i,n={}){return this.bitN(28,i,n)}bit29(i,n={}){return this.bitN(29,i,n)}bit30(i,n={}){return this.bitN(30,i,n)}bit31(i,n={}){return this.bitN(31,i,n)}bit32(i,n={}){return this.bitN(32,i,n)}namely(i){return Yc.set(i,this),this.alias=i,this}skip(i,n={}){return this.seek(i,n)}seek(i,n={}){if(n.assert)throw new Error("assert option on seek is not allowed.");return this.setNextParser("seek","",{length:i})}string(i,n){if(!n.zeroTerminated&&!n.length&&!n.greedy)throw new Error("One of length, zeroTerminated, or greedy must be defined for string.");if((n.zeroTerminated||n.length)&&n.greedy)throw new Error("greedy is mutually exclusive with length and zeroTerminated for string.");if(n.stripNull&&!(n.length||n.greedy))throw new Error("length or greedy must be defined if stripNull is enabled.");return n.encoding=n.encoding||"utf8",this.setNextParser("string",i,n)}buffer(i,n){if(!n.length&&!n.readUntil)throw new Error("length or readUntil must be defined for buffer.");return this.setNextParser("buffer",i,n)}wrapped(i,n){if(typeof n!="object"&&typeof i=="object"&&(n=i,i=""),!n||!n.wrapper||!n.type)throw new Error("Both wrapper and type must be defined for wrapped.");if(!n.length&&!n.readUntil)throw new Error("length or readUntil must be defined for wrapped.");return this.setNextParser("wrapper",i,n)}array(i,n){if(!n.readUntil&&!n.length&&!n.lengthInBytes)throw new Error("One of readUntil, length and lengthInBytes must be defined for array.");if(!n.type)throw new Error("type is required for array.");if(typeof n.type=="string"&&!Yc.has(n.type)&&!(n.type in Kc))throw new Error(`Array element type "${n.type}" is unkown.`);return this.setNextParser("array",i,n)}choice(i,n){if(typeof n!="object"&&typeof i=="object"&&(n=i,i=""),!n)throw new Error("tag and choices are are required for choice.");if(!n.tag)throw new Error("tag is requird for choice.");if(!n.choices)throw new Error("choices is required for choice.");for(const r in n.choices){const o=parseInt(r,10),l=n.choices[o];if(isNaN(o))throw new Error(`Choice key "${r}" is not a number.`);if(typeof l=="string"&&!Yc.has(l)&&!(l in Kc))throw new Error(`Choice type "${l}" is unkown.`)}return this.setNextParser("choice",i,n)}nest(i,n){if(typeof n!="object"&&typeof i=="object"&&(n=i,i=""),!n||!n.type)throw new Error("type is required for nest.");if(!(n.type instanceof pr)&&!Yc.has(n.type))throw new Error("type must be a known parser name or a Parser object.");if(!(n.type instanceof pr)&&!i)throw new Error("type must be a Parser object if the variable name is omitted.");return this.setNextParser("nest",i,n)}pointer(i,n){if(!n.offset)throw new Error("offset is required for pointer.");if(!n.type)throw new Error("type is required for pointer.");if(typeof n.type=="string"&&!(n.type in Kc)&&!Yc.has(n.type))throw new Error(`Pointer type "${n.type}" is unkown.`);return this.setNextParser("pointer",i,n)}saveOffset(i,n={}){return this.setNextParser("saveOffset",i,n)}endianness(i){switch(i.toLowerCase()){case"little":this.endian="le";break;case"big":this.endian="be";break;default:throw new Error('endianness must be one of "little" or "big"')}return this}endianess(i){return this.endianness(i)}useContextVars(i=!0){return this.useContextVariables=i,this}create(i){if(!(i instanceof Function))throw new Error("Constructor must be a Function object.");return this.constructorFn=i,this}getContext(i){const n=new Oli(i,this.useContextVariables);return n.pushCode("var dataView = new DataView(buffer.buffer, buffer.byteOffset, buffer.length);"),this.alias?(this.addAliasedCode(n),n.pushCode(`return ${Jb+this.alias}(0).result;`)):this.addRawCode(n),n}getCode(){const i="imports";return this.getContext(i).code}addRawCode(i){i.pushCode("var offset = 0;"),i.pushCode(`var vars = ${this.constructorFn?"new constructorFn()":"{}"};`),i.pushCode("vars.$parent = null;"),i.pushCode("vars.$root = vars;"),this.generate(i),this.resolveReferences(i),i.pushCode("delete vars.$parent;"),i.pushCode("delete vars.$root;"),i.pushCode("return vars;")}addAliasedCode(i){return i.pushCode(`function ${Jb+this.alias}(offset, context) {`),i.pushCode(`var vars = ${this.constructorFn?"new constructorFn()":"{}"};`),i.pushCode("var ctx = Object.assign({$parent: null, $root: vars}, context || {});"),i.pushCode("vars = Object.assign(vars, ctx);"),this.generate(i),i.markResolved(this.alias),this.resolveReferences(i),i.pushCode("Object.keys(ctx).forEach(function (item) { delete vars[item]; });"),i.pushCode("return { offset: offset, result: vars };"),i.pushCode("}"),i}resolveReferences(i){const n=i.getUnresolvedReferences();i.markRequested(n),n.forEach(r=>{var o;(o=Yc.get(r))===null||o===void 0||o.addAliasedCode(i)})}compile(){const i="imports",n=this.getContext(i);this.compiled=new Function(i,"TextDecoder",`return function (buffer, constructorFn) { ${n.code} };`)(n.imports,TextDecoder)}sizeOf(){let i=NaN;if(Object.keys(Kc).indexOf(this.type)>=0)i=Kc[this.type];else if(this.type==="string"&&typeof this.options.length=="number")i=this.options.length;else if(this.type==="buffer"&&typeof this.options.length=="number")i=this.options.length;else if(this.type==="array"&&typeof this.options.length=="number"){let n=NaN;typeof this.options.type=="string"?n=Kc[this.options.type]:this.options.type instanceof pr&&(n=this.options.type.sizeOf()),i=this.options.length*n}else this.type==="seek"?i=this.options.length:this.type==="nest"?i=this.options.type.sizeOf():this.type||(i=0);return this.next&&(i+=this.next.sizeOf()),i}parse(i){return this.compiled||this.compile(),this.compiled(i,this.constructorFn)}setNextParser(i,n,r){const o=new pr;return o.type=i,o.varName=n,o.options=r,o.endian=this.endian,this.head?this.head.next=o:this.next=o,this.head=o,this}generate(i){if(this.type){switch(this.type){case"uint8":case"uint16le":case"uint16be":case"uint32le":case"uint32be":case"int8":case"int16le":case"int16be":case"int32le":case"int32be":case"int64be":case"int64le":case"uint64be":case"uint64le":case"floatle":case"floatbe":case"doublele":case"doublebe":this.primitiveGenerateN(this.type,i);break;case"bit":this.generateBit(i);break;case"string":this.generateString(i);break;case"buffer":this.generateBuffer(i);break;case"seek":this.generateSeek(i);break;case"nest":this.generateNest(i);break;case"array":this.generateArray(i);break;case"choice":this.generateChoice(i);break;case"pointer":this.generatePointer(i);break;case"saveOffset":this.generateSaveOffset(i);break;case"wrapper":this.generateWrapper(i);break}this.type!=="bit"&&this.generateAssert(i)}const n=i.generateVariable(this.varName);return this.options.formatter&&this.type!=="bit"&&this.generateFormatter(i,n,this.options.formatter),this.generateNext(i)}generateAssert(i){if(!this.options.assert)return;const n=i.generateVariable(this.varName);switch(typeof this.options.assert){case"function":{const r=i.addImport(this.options.assert);i.pushCode(`if (!${r}.call(vars, ${n})) {`)}break;case"number":i.pushCode(`if (${this.options.assert} !== ${n}) {`);break;case"string":i.pushCode(`if (${JSON.stringify(this.options.assert)} !== ${n}) {`);break;default:throw new Error("assert option must be a string, number or a function.")}i.generateError(`"Assertion error: ${n} is " + ${JSON.stringify(this.options.assert.toString())}`),i.pushCode("}")}generateNext(i){return this.next&&(i=this.next.generate(i)),i}generateBit(i){const n=JSON.parse(JSON.stringify(this));if(n.options=this.options,n.generateAssert=this.generateAssert.bind(this),n.generateFormatter=this.generateFormatter.bind(this),n.varName=i.generateVariable(n.varName),i.bitFields.push(n),!this.next||this.next&&["bit","nest"].indexOf(this.next.type)<0){const r=i.generateTmpVariable();i.pushCode(`var ${r} = 0;`);const o=(p=0)=>{let v=0;for(let B=p;B32)break;v+=G}return v},l=p=>(p<=8?(i.pushCode(`${r} = dataView.getUint8(offset);`),p=8):p<=16?(i.pushCode(`${r} = dataView.getUint16(offset);`),p=16):p<=24?(i.pushCode(`${r} = (dataView.getUint16(offset) << 8) | dataView.getUint8(offset + 2);`),p=24):(i.pushCode(`${r} = dataView.getUint32(offset);`),p=32),i.pushCode(`offset += ${p/8};`),p);let c=0;const u=this.endian==="be";let f=0,m=0;i.bitFields.forEach((p,v)=>{let B=p.options.length;if(B>m){if(m){const V=-1>>>32-m;i.pushCode(`${p.varName} = (${r} & 0x${V.toString(16)}) << ${B-m};`),B-=m}c=0,m=f=l(o(v)-m)}const G=u?f-c-B:c,T=-1>>>32-B;i.pushCode(`${p.varName} ${B> ${G} & 0x${T.toString(16)};`),p.options.length===32&&i.pushCode(`${p.varName} >>>= 0`),p.options.assert&&p.generateAssert(i),p.options.formatter&&p.generateFormatter(i,p.varName,p.options.formatter),c+=B,m-=B}),i.bitFields=[]}}generateSeek(i){const n=i.generateOption(this.options.length);i.pushCode(`offset += ${n};`)}generateString(i){const n=i.generateVariable(this.varName),r=i.generateTmpVariable(),o=this.options.encoding,l=o.toLowerCase()==="hex",c='b => b.toString(16).padStart(2, "0")';if(this.options.length&&this.options.zeroTerminated){const u=this.options.length;i.pushCode(`var ${r} = offset;`),i.pushCode(`while(dataView.getUint8(offset++) !== 0 && offset - ${r} < ${u});`);const f=`offset - ${r} < ${u} ? offset - 1 : offset`;i.pushCode(l?`${n} = Array.from(buffer.subarray(${r}, ${f}), ${c}).join('');`:`${n} = new TextDecoder('${o}').decode(buffer.subarray(${r}, ${f}));`)}else if(this.options.length){const u=i.generateOption(this.options.length);i.pushCode(l?`${n} = Array.from(buffer.subarray(offset, offset + ${u}), ${c}).join('');`:`${n} = new TextDecoder('${o}').decode(buffer.subarray(offset, offset + ${u}));`),i.pushCode(`offset += ${u};`)}else this.options.zeroTerminated?(i.pushCode(`var ${r} = offset;`),i.pushCode("while(dataView.getUint8(offset++) !== 0);"),i.pushCode(l?`${n} = Array.from(buffer.subarray(${r}, offset - 1), ${c}).join('');`:`${n} = new TextDecoder('${o}').decode(buffer.subarray(${r}, offset - 1));`)):this.options.greedy&&(i.pushCode(`var ${r} = offset;`),i.pushCode("while(buffer.length > offset++);"),i.pushCode(l?`${n} = Array.from(buffer.subarray(${r}, offset), ${c}).join('');`:`${n} = new TextDecoder('${o}').decode(buffer.subarray(${r}, offset));`));this.options.stripNull&&i.pushCode(`${n} = ${n}.replace(/\\x00+$/g, '')`)}generateBuffer(i){const n=i.generateVariable(this.varName);if(typeof this.options.readUntil=="function"){const r=this.options.readUntil,o=i.generateTmpVariable(),l=i.generateTmpVariable();i.pushCode(`var ${o} = offset;`),i.pushCode(`var ${l} = 0;`),i.pushCode("while (offset < buffer.length) {"),i.pushCode(`${l} = dataView.getUint8(offset);`);const c=i.addImport(r);i.pushCode(`if (${c}.call(${i.generateVariable()}, ${l}, buffer.subarray(offset))) break;`),i.pushCode("offset += 1;"),i.pushCode("}"),i.pushCode(`${n} = buffer.subarray(${o}, offset);`)}else if(this.options.readUntil==="eof")i.pushCode(`${n} = buffer.subarray(offset);`);else{const r=i.generateOption(this.options.length);i.pushCode(`${n} = buffer.subarray(offset, offset + ${r});`),i.pushCode(`offset += ${r};`)}this.options.clone&&i.pushCode(`${n} = buffer.constructor.from(${n});`)}generateArray(i){const n=i.generateOption(this.options.length),r=i.generateOption(this.options.lengthInBytes),o=this.options.type,l=i.generateTmpVariable(),c=i.generateVariable(this.varName),u=i.generateTmpVariable(),f=this.options.key,m=typeof f=="string";if(m?i.pushCode(`${c} = {};`):i.pushCode(`${c} = [];`),typeof this.options.readUntil=="function"?i.pushCode("do {"):this.options.readUntil==="eof"?i.pushCode(`for (var ${l} = 0; offset < buffer.length; ${l}++) {`):r!==void 0?i.pushCode(`for (var ${l} = offset + ${r}; offset < ${l}; ) {`):i.pushCode(`for (var ${l} = ${n}; ${l} > 0; ${l}--) {`),typeof o=="string")if(Yc.get(o)){const p=i.generateTmpVariable();if(i.pushCode(`var ${p} = ${Jb+o}(offset, {`),i.useContextVariables){const v=i.generateVariable();i.pushCode(`$parent: ${v},`),i.pushCode(`$root: ${v}.$root,`),!this.options.readUntil&&r===void 0&&i.pushCode(`$index: ${n} - ${l},`)}i.pushCode("});"),i.pushCode(`var ${u} = ${p}.result; offset = ${p}.offset;`),o!==this.alias&&i.addReference(o)}else{const p=nF[o],v=rF[o];i.pushCode(`var ${u} = dataView.get${p}(offset, ${v});`),i.pushCode(`offset += ${Kc[o]};`)}else if(o instanceof pr){i.pushCode(`var ${u} = {};`);const p=i.generateVariable();i.pushScope(u),i.useContextVariables&&(i.pushCode(`${u}.$parent = ${p};`),i.pushCode(`${u}.$root = ${p}.$root;`),!this.options.readUntil&&r===void 0&&i.pushCode(`${u}.$index = ${n} - ${l};`)),o.generate(i),i.useContextVariables&&(i.pushCode(`delete ${u}.$parent;`),i.pushCode(`delete ${u}.$root;`),i.pushCode(`delete ${u}.$index;`)),i.popScope()}if(m?i.pushCode(`${c}[${u}.${f}] = ${u};`):i.pushCode(`${c}.push(${u});`),i.pushCode("}"),typeof this.options.readUntil=="function"){const p=this.options.readUntil,v=i.addImport(p);i.pushCode(`while (!${v}.call(${i.generateVariable()}, ${u}, buffer.subarray(offset)));`)}}generateChoiceCase(i,n,r){if(typeof r=="string"){const o=i.generateVariable(this.varName);if(Yc.has(r)){const l=i.generateTmpVariable();i.pushCode(`var ${l} = ${Jb+r}(offset, {`),i.useContextVariables&&(i.pushCode(`$parent: ${o}.$parent,`),i.pushCode(`$root: ${o}.$root,`)),i.pushCode("});"),i.pushCode(`${o} = ${l}.result; offset = ${l}.offset;`),r!==this.alias&&i.addReference(r)}else{const l=nF[r],c=rF[r];i.pushCode(`${o} = dataView.get${l}(offset, ${c});`),i.pushCode(`offset += ${Kc[r]}`)}}else r instanceof pr&&(i.pushPath(n),r.generate(i),i.popPath(n))}generateChoice(i){const n=i.generateOption(this.options.tag),r=i.generateVariable(this.varName);if(this.varName&&(i.pushCode(`${r} = {};`),i.useContextVariables)){const o=i.generateVariable();i.pushCode(`${r}.$parent = ${o};`),i.pushCode(`${r}.$root = ${o}.$root;`)}i.pushCode(`switch(${n}) {`);for(const o in this.options.choices){const l=parseInt(o,10),c=this.options.choices[l];i.pushCode(`case ${l}:`),this.generateChoiceCase(i,this.varName,c),i.pushCode("break;")}i.pushCode("default:"),this.options.defaultChoice?this.generateChoiceCase(i,this.varName,this.options.defaultChoice):i.generateError(`"Met undefined tag value " + ${n} + " at choice"`),i.pushCode("}"),this.varName&&i.useContextVariables&&(i.pushCode(`delete ${r}.$parent;`),i.pushCode(`delete ${r}.$root;`))}generateNest(i){const n=i.generateVariable(this.varName);if(this.options.type instanceof pr){if(this.varName&&(i.pushCode(`${n} = {};`),i.useContextVariables)){const r=i.generateVariable();i.pushCode(`${n}.$parent = ${r};`),i.pushCode(`${n}.$root = ${r}.$root;`)}i.pushPath(this.varName),this.options.type.generate(i),i.popPath(this.varName),this.varName&&i.useContextVariables&&i.useContextVariables&&(i.pushCode(`delete ${n}.$parent;`),i.pushCode(`delete ${n}.$root;`))}else if(Yc.has(this.options.type)){const r=i.generateTmpVariable();if(i.pushCode(`var ${r} = ${Jb+this.options.type}(offset, {`),i.useContextVariables){const o=i.generateVariable();i.pushCode(`$parent: ${o},`),i.pushCode(`$root: ${o}.$root,`)}i.pushCode("});"),i.pushCode(`${n} = ${r}.result; offset = ${r}.offset;`),this.options.type!==this.alias&&i.addReference(this.options.type)}}generateWrapper(i){const n=i.generateVariable(this.varName),r=i.generateTmpVariable();if(typeof this.options.readUntil=="function"){const f=this.options.readUntil,m=i.generateTmpVariable(),p=i.generateTmpVariable();i.pushCode(`var ${m} = offset;`),i.pushCode(`var ${p} = 0;`),i.pushCode("while (offset < buffer.length) {"),i.pushCode(`${p} = dataView.getUint8(offset);`);const v=i.addImport(f);i.pushCode(`if (${v}.call(${i.generateVariable()}, ${p}, buffer.subarray(offset))) break;`),i.pushCode("offset += 1;"),i.pushCode("}"),i.pushCode(`${r} = buffer.subarray(${m}, offset);`)}else if(this.options.readUntil==="eof")i.pushCode(`${r} = buffer.subarray(offset);`);else{const f=i.generateOption(this.options.length);i.pushCode(`${r} = buffer.subarray(offset, offset + ${f});`),i.pushCode(`offset += ${f};`)}this.options.clone&&i.pushCode(`${r} = buffer.constructor.from(${r});`);const o=i.generateTmpVariable(),l=i.generateTmpVariable(),c=i.generateTmpVariable(),u=i.addImport(this.options.wrapper);if(i.pushCode(`${r} = ${u}.call(this, ${r}).subarray(0);`),i.pushCode(`var ${o} = buffer;`),i.pushCode(`var ${l} = offset;`),i.pushCode(`var ${c} = dataView;`),i.pushCode(`buffer = ${r};`),i.pushCode("offset = 0;"),i.pushCode("dataView = new DataView(buffer.buffer, buffer.byteOffset, buffer.length);"),this.options.type instanceof pr)this.varName&&i.pushCode(`${n} = {};`),i.pushPath(this.varName),this.options.type.generate(i),i.popPath(this.varName);else if(Yc.has(this.options.type)){const f=i.generateTmpVariable();i.pushCode(`var ${f} = ${Jb+this.options.type}(0);`),i.pushCode(`${n} = ${f}.result;`),this.options.type!==this.alias&&i.addReference(this.options.type)}i.pushCode(`buffer = ${o};`),i.pushCode(`dataView = ${c};`),i.pushCode(`offset = ${l};`)}generateFormatter(i,n,r){if(typeof r=="function"){const o=i.addImport(r);i.pushCode(`${n} = ${o}.call(${i.generateVariable()}, ${n});`)}}generatePointer(i){const n=this.options.type,r=i.generateOption(this.options.offset),o=i.generateTmpVariable(),l=i.generateVariable(this.varName);if(i.pushCode(`var ${o} = offset;`),i.pushCode(`offset = ${r};`),this.options.type instanceof pr){if(i.pushCode(`${l} = {};`),i.useContextVariables){const c=i.generateVariable();i.pushCode(`${l}.$parent = ${c};`),i.pushCode(`${l}.$root = ${c}.$root;`)}i.pushPath(this.varName),this.options.type.generate(i),i.popPath(this.varName),i.useContextVariables&&(i.pushCode(`delete ${l}.$parent;`),i.pushCode(`delete ${l}.$root;`))}else if(Yc.has(this.options.type)){const c=i.generateTmpVariable();if(i.pushCode(`var ${c} = ${Jb+this.options.type}(offset, {`),i.useContextVariables){const u=i.generateVariable();i.pushCode(`$parent: ${u},`),i.pushCode(`$root: ${u}.$root,`)}i.pushCode("});"),i.pushCode(`${l} = ${c}.result; offset = ${c}.offset;`),this.options.type!==this.alias&&i.addReference(this.options.type)}else if(Object.keys(Kc).indexOf(this.options.type)>=0){const c=nF[n],u=rF[n];i.pushCode(`${l} = dataView.get${c}(offset, ${u});`),i.pushCode(`offset += ${Kc[n]};`)}i.pushCode(`offset = ${o};`)}generateSaveOffset(i){const n=i.generateVariable(this.varName);i.pushCode(`${n} = offset`)}}var xJe={},sle={},bv={},VW={};Object.defineProperty(VW,"__esModule",{value:!0});function Ile(e,i){if(!(e instanceof i))throw new TypeError("Cannot call a class as a function")}function lxe(e,i){for(var n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function X9(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Uli(e,i){if(i&&(typeof i=="object"||typeof i=="function"))return i;if(i!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return X9(e)}function Qli(e){var i=Jli();return function(){var r=FS(e),o;if(i){var l=FS(this).constructor;o=Reflect.construct(r,arguments,l)}else o=r.apply(this,arguments);return Uli(this,o)}}function jli(e,i){for(;!Object.prototype.hasOwnProperty.call(e,i)&&(e=FS(e),e!==null););return e}function GY(){return typeof Reflect<"u"&&Reflect.get?GY=Reflect.get.bind():GY=function(i,n,r){var o=jli(i,n);if(o){var l=Object.getOwnPropertyDescriptor(o,n);return l.get?l.get.call(arguments.length<3?i:r):l.value}},GY.apply(this,arguments)}var Cxe=function(){function e(){Ile(this,e),Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}return lle(e,[{key:"addEventListener",value:function(n,r,o){n in this.listeners||(this.listeners[n]=[]),this.listeners[n].push({callback:r,options:o})}},{key:"removeEventListener",value:function(n,r){if(n in this.listeners){for(var o=this.listeners[n],l=0,c=o.length;l"u")o=new Error("This operation was aborted"),o.name="AbortError";else try{o=new DOMException("signal is aborted without reason")}catch{o=new Error("This operation was aborted"),o.name="AbortError"}this.signal.reason=o,this.signal.dispatchEvent(r)}},{key:"toString",value:function(){return"[object AbortController]"}}]),e}();typeof Symbol<"u"&&Symbol.toStringTag&&(DJe.prototype[Symbol.toStringTag]="AbortController",Cle.prototype[Symbol.toStringTag]="AbortSignal");function $li(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof e.Request=="function"&&!e.Request.prototype.hasOwnProperty("signal")||!e.AbortController}function qli(e){typeof e=="function"&&(e={fetch:e});var i=e,n=i.fetch,r=i.Request,o=r===void 0?n.Request:r,l=i.AbortController,c=i.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,u=c===void 0?!1:c;if(!$li({fetch:n,Request:o,AbortController:l,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:u}))return{fetch:n,Request:f};var f=o;(f&&!f.prototype.hasOwnProperty("signal")||u)&&(f=function(B,G){var T;G&&G.signal&&(T=G.signal,delete G.signal);var V=new o(B,G);return T&&Object.defineProperty(V,"signal",{writable:!1,enumerable:!1,configurable:!0,value:T}),V},f.prototype=o.prototype);var m=n,p=function(B,G){var T=f&&f.prototype.isPrototypeOf(B)?B.signal:G?G.signal:void 0;if(T){var V;try{V=new DOMException("Aborted","AbortError")}catch{V=new Error("Aborted"),V.name="AbortError"}if(T.aborted)return Promise.reject(V);var E=new Promise(function(W,x){T.addEventListener("abort",function(){return x(V)},{once:!0})});return G&&G.signal&&delete G.signal,Promise.race([E,m(B,G)])}return m(B,G)};return{fetch:p,Request:f}}VW.AbortController=DJe;VW.AbortSignal=Cle;VW.abortableFetch=qli;Object.defineProperty(bv,"__esModule",{value:!0});bv.AbortSignal=bv.AbortController=void 0;const MJe=VW;var t3=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof Dp<"u")return Dp;throw new Error("unable to locate global object")};let eCi=typeof t3().AbortController>"u"?MJe.AbortController:t3().AbortController;bv.AbortController=eCi;let tCi=typeof t3().AbortController>"u"?MJe.AbortSignal:t3().AbortSignal;bv.AbortSignal=tCi;var cle={};Object.defineProperty(cle,"__esModule",{value:!0});const iCi=bv;class nCi{}class rCi{constructor(){this.signals=new Set,this.abortController=new iCi.AbortController}addSignal(i=new nCi){if(this.signal.aborted)throw new Error("cannot add a signal, already aborted!");this.signals.add(i),i.aborted?this.handleAborted(i):typeof i.addEventListener=="function"&&i.addEventListener("abort",()=>{this.handleAborted(i)})}handleAborted(i){this.signals.delete(i),this.signals.size===0&&this.abortController.abort()}get signal(){return this.abortController.signal}abort(){this.abortController.abort()}}cle.default=rCi;var Ale={};Object.defineProperty(Ale,"__esModule",{value:!0});class gCi{constructor(){this.callbacks=new Set}addCallback(i=()=>{}){this.callbacks.add(i),i(this.currentMessage)}callback(i){this.currentMessage=i,this.callbacks.forEach(n=>{n(i)})}}Ale.default=gCi;var FJe=Dp&&Dp.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(sle,"__esModule",{value:!0});const oCi=bv,aCi=FJe(cle),sCi=FJe(Ale);class i3{constructor({fill:i,cache:n}){if(typeof i!="function")throw new TypeError("must pass a fill function");if(typeof n!="object")throw new TypeError("must pass a cache object");if(typeof n.get!="function"||typeof n.set!="function"||typeof n.delete!="function")throw new TypeError("cache must implement get(key), set(key, val), and and delete(key)");this.cache=n,this.fillCallback=i}static isAbortException(i){return i.name==="AbortError"||i.code==="ERR_ABORTED"||i.message==="AbortError: aborted"||i.message==="Error: aborted"}evict(i,n){this.cache.get(i)===n&&this.cache.delete(i)}fill(i,n,r,o){const l=new aCi.default,c=new sCi.default;c.addCallback(o);const u={aborter:l,promise:this.fillCallback(n,l.signal,f=>{c.callback(f)}),settled:!1,statusReporter:c,get aborted(){return this.aborter.signal.aborted}};u.aborter.addSignal(r),u.aborter.signal.addEventListener("abort",()=>{u.settled||this.evict(i,u)}),u.promise.then(()=>{u.settled=!0},()=>{u.settled=!0,this.evict(i,u)}).catch(f=>{throw console.error(f),f}),this.cache.set(i,u)}static checkSinglePromise(i,n){function r(){if(n&&n.aborted)throw Object.assign(new Error("aborted"),{code:"ERR_ABORTED"})}return i.then(o=>(r(),o),o=>{throw r(),o})}has(i){return this.cache.has(i)}get(i,n,r,o){if(!r&&n instanceof oCi.AbortSignal)throw new TypeError("second get argument appears to be an AbortSignal, perhaps you meant to pass `null` for the fill data?");const l=this.cache.get(i);return l?l.aborted&&!l.settled?(this.evict(i,l),this.get(i,n,r,o)):l.settled?l.promise:(l.aborter.addSignal(r),l.statusReporter.addCallback(o),i3.checkSinglePromise(l.promise,r)):(this.fill(i,n,r,o),i3.checkSinglePromise(this.cache.get(i).promise,r))}delete(i){const n=this.cache.get(i);n&&(n.settled||n.aborter.abort(),this.cache.delete(i))}clear(){const i=this.cache.keys();let n=0;for(let r=i.next();!r.done;r=i.next())this.delete(r.value),n+=1;return n}}sle.default=i3;var ICi=Dp&&Dp.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(xJe,"__esModule",{value:!0});const lCi=ICi(sle);var CCi=xJe.default=lCi.default;let cxe=class wG{constructor(i,n){this.ranges=arguments.length===2?[{min:i,max:n}]:0 in i?Object.assign({},i):[i]}min(){return this.ranges[0].min}max(){return this.ranges[this.ranges.length-1].max}contains(i){for(let n=0;n=i)return!0}return!1}isContiguous(){return this.ranges.length>1}getRanges(){return this.ranges.map(i=>new wG(i.min,i.max))}toString(){return this.ranges.map(i=>`[${i.min}-${i.max}]`).join(",")}union(i){const n=this.getRanges().concat(i.getRanges()).sort(this.rangeOrder),r=[];let o=n[0];for(let l=1;lo.max()+1?(r.push(o),o=c):c.max()>o.max()&&(o=new wG(o.min(),c.max()))}return r.push(o),r.length===1?r[0]:new wG(r)}intersection(i){let n=this,r=i;const o=this.ranges(),l=r.ranges(),c=o.length,u=l.length;let f=0,m=0;const p=[];for(;f=v&&p.push(new wG(v,B)),n.max()>r.max()?m+=1:f+=1}if(p.length===0)throw new Error("found range of length 0");return p.length===1?p[0]:new wG(p)}coverage(){let i=0;const n=this.ranges();for(let r=0;ro.min()?1:r.max()r.max()?1:0}};function Nw(e){let i=e.length;for(;--i>=0;)e[i]=0}const cCi=3,ACi=258,YJe=29,uCi=256,dCi=uCi+1+YJe,KJe=30,hCi=512,fCi=new Array((dCi+2)*2);Nw(fCi);const mCi=new Array(KJe*2);Nw(mCi);const pCi=new Array(hCi);Nw(pCi);const bCi=new Array(ACi-cCi+1);Nw(bCi);const yCi=new Array(YJe);Nw(yCi);const vCi=new Array(KJe);Nw(vCi);const ZCi=(e,i,n,r)=>{let o=e&65535|0,l=e>>>16&65535|0,c=0;for(;n!==0;){c=n>2e3?2e3:n,n-=c;do o=o+i[r++]|0,l=l+o|0;while(--c);o%=65521,l%=65521}return o|l<<16|0};var ige=ZCi;const BCi=()=>{let e,i=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;i[n]=e}return i},GCi=new Uint32Array(BCi()),SCi=(e,i,n,r)=>{const o=GCi,l=r+n;e^=-1;for(let c=r;c>>8^o[(e^i[c])&255];return e^-1};var Bu=SCi,nge={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},ule={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const wCi=(e,i)=>Object.prototype.hasOwnProperty.call(e,i);var TCi=function(e){const i=Array.prototype.slice.call(arguments,1);for(;i.length;){const n=i.shift();if(n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(const r in n)wCi(n,r)&&(e[r]=n[r])}}return e},RCi=e=>{let i=0;for(let r=0,o=e.length;r=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;SH[254]=SH[254]=1;var VCi=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let i,n,r,o,l,c=e.length,u=0;for(o=0;o>>6,i[l++]=128|n&63):n<65536?(i[l++]=224|n>>>12,i[l++]=128|n>>>6&63,i[l++]=128|n&63):(i[l++]=240|n>>>18,i[l++]=128|n>>>12&63,i[l++]=128|n>>>6&63,i[l++]=128|n&63);return i};const ECi=(e,i)=>{if(i<65534&&e.subarray&&PJe)return String.fromCharCode.apply(null,e.length===i?e:e.subarray(0,i));let n="";for(let r=0;r{const n=i||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,i));let r,o;const l=new Array(n*2);for(o=0,r=0;r4){l[o++]=65533,r+=u-1;continue}for(c&=u===2?31:u===3?15:7;u>1&&r1){l[o++]=65533;continue}c<65536?l[o++]=c:(c-=65536,l[o++]=55296|c>>10&1023,l[o++]=56320|c&1023)}return ECi(l,o)},WCi=(e,i)=>{i=i||e.length,i>e.length&&(i=e.length);let n=i-1;for(;n>=0&&(e[n]&192)===128;)n--;return n<0||n===0?i:n+SH[e[n]]>i?n:i},rge={string2buf:VCi,buf2string:HCi,utf8border:WCi};function NCi(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var kCi=NCi;const gF=16209,XCi=16191;var xCi=function(i,n){let r,o,l,c,u,f,m,p,v,B,G,T,V,E,W,x,k,F,Y,L,O,Q,X,$;const ee=i.state;r=i.next_in,X=i.input,o=r+(i.avail_in-5),l=i.next_out,$=i.output,c=l-(n-i.avail_out),u=l+(i.avail_out-257),f=ee.dmax,m=ee.wsize,p=ee.whave,v=ee.wnext,B=ee.window,G=ee.hold,T=ee.bits,V=ee.lencode,E=ee.distcode,W=(1<>>24,G>>>=F,T-=F,F=k>>>16&255,F===0)$[l++]=k&65535;else if(F&16){Y=k&65535,F&=15,F&&(T>>=F,T-=F),T<15&&(G+=X[r++]<>>24,G>>>=F,T-=F,F=k>>>16&255,F&16){if(L=k&65535,F&=15,Tf){i.msg="invalid distance too far back",ee.mode=gF;break e}if(G>>>=F,T-=F,F=l-c,L>F){if(F=L-F,F>p&&ee.sane){i.msg="invalid distance too far back",ee.mode=gF;break e}if(O=0,Q=B,v===0){if(O+=m-F,F2;)$[l++]=Q[O++],$[l++]=Q[O++],$[l++]=Q[O++],Y-=3;Y&&($[l++]=Q[O++],Y>1&&($[l++]=Q[O++]))}else{O=l-L;do $[l++]=$[O++],$[l++]=$[O++],$[l++]=$[O++],Y-=3;while(Y>2);Y&&($[l++]=$[O++],Y>1&&($[l++]=$[O++]))}}else if(F&64){i.msg="invalid distance code",ee.mode=gF;break e}else{k=E[(k&65535)+(G&(1<>3,r-=Y,T-=Y<<3,G&=(1<{const f=u.bits;let m=0,p=0,v=0,B=0,G=0,T=0,V=0,E=0,W=0,x=0,k,F,Y,L,O,Q=null,X;const $=new Uint16Array(CG+1),ee=new Uint16Array(CG+1);let ne=null,ge,Ae,_;for(m=0;m<=CG;m++)$[m]=0;for(p=0;p=1&&$[B]===0;B--);if(G>B&&(G=B),B===0)return o[l++]=1<<24|64<<16|0,o[l++]=1<<24|64<<16|0,u.bits=1,0;for(v=1;v0&&(e===dxe||B!==1))return-1;for(ee[1]=0,m=1;mAxe||e===hxe&&W>uxe)return 1;for(;;){ge=m-V,c[p]+1=X?(Ae=ne[c[p]-X],_=Q[c[p]-X]):(Ae=32+64,_=0),k=1<>V)+F]=ge<<24|Ae<<16|_|0;while(F!==0);for(k=1<>=1;if(k!==0?(x&=k-1,x+=k):x=0,p++,--$[m]===0){if(m===B)break;m=i[n+c[p]]}if(m>G&&(x&L)!==Y){for(V===0&&(V=G),O+=v,T=m-V,E=1<Axe||e===hxe&&W>uxe)return 1;Y=x&L,o[Y]=G<<24|T<<16|O-l|0}}return x!==0&&(o[O+x]=m-V<<24|64<<16|0),u.bits=G,0};var yE=KCi;const _Ci=0,zJe=1,OJe=2,{Z_FINISH:fxe,Z_BLOCK:PCi,Z_TREES:oF,Z_OK:yv,Z_STREAM_END:zCi,Z_NEED_DICT:OCi,Z_STREAM_ERROR:zC,Z_DATA_ERROR:LJe,Z_MEM_ERROR:JJe,Z_BUF_ERROR:LCi,Z_DEFLATED:mxe}=ule,LP=16180,pxe=16181,bxe=16182,yxe=16183,vxe=16184,Zxe=16185,Bxe=16186,Gxe=16187,Sxe=16188,wxe=16189,n3=16190,hh=16191,Bee=16192,Txe=16193,Gee=16194,Rxe=16195,Vxe=16196,Exe=16197,Hxe=16198,aF=16199,sF=16200,Wxe=16201,Nxe=16202,kxe=16203,Xxe=16204,xxe=16205,See=16206,Dxe=16207,Mxe=16208,kg=16209,UJe=16210,QJe=16211,JCi=852,UCi=592,QCi=15,jCi=QCi,Fxe=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function $Ci(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const $v=e=>{if(!e)return 1;const i=e.state;return!i||i.strm!==e||i.modeQJe?1:0},jJe=e=>{if($v(e))return zC;const i=e.state;return e.total_in=e.total_out=i.total=0,e.msg="",i.wrap&&(e.adler=i.wrap&1),i.mode=LP,i.last=0,i.havedict=0,i.flags=-1,i.dmax=32768,i.head=null,i.hold=0,i.bits=0,i.lencode=i.lendyn=new Int32Array(JCi),i.distcode=i.distdyn=new Int32Array(UCi),i.sane=1,i.back=-1,yv},$Je=e=>{if($v(e))return zC;const i=e.state;return i.wsize=0,i.whave=0,i.wnext=0,jJe(e)},qJe=(e,i)=>{let n;if($v(e))return zC;const r=e.state;return i<0?(n=0,i=-i):(n=(i>>4)+5,i<48&&(i&=15)),i&&(i<8||i>15)?zC:(r.window!==null&&r.wbits!==i&&(r.window=null),r.wrap=n,r.wbits=i,$Je(e))},eUe=(e,i)=>{if(!e)return zC;const n=new $Ci;e.state=n,n.strm=e,n.window=null,n.mode=LP;const r=qJe(e,i);return r!==yv&&(e.state=null),r},qCi=e=>eUe(e,jCi);let Yxe=!0,wee,Tee;const eci=e=>{if(Yxe){wee=new Int32Array(512),Tee=new Int32Array(32);let i=0;for(;i<144;)e.lens[i++]=8;for(;i<256;)e.lens[i++]=9;for(;i<280;)e.lens[i++]=7;for(;i<288;)e.lens[i++]=8;for(yE(zJe,e.lens,0,288,wee,0,e.work,{bits:9}),i=0;i<32;)e.lens[i++]=5;yE(OJe,e.lens,0,32,Tee,0,e.work,{bits:5}),Yxe=!1}e.lencode=wee,e.lenbits=9,e.distcode=Tee,e.distbits=5},tUe=(e,i,n,r)=>{let o;const l=e.state;return l.window===null&&(l.wsize=1<=l.wsize?(l.window.set(i.subarray(n-l.wsize,n),0),l.wnext=0,l.whave=l.wsize):(o=l.wsize-l.wnext,o>r&&(o=r),l.window.set(i.subarray(n-r,n-r+o),l.wnext),r-=o,r?(l.window.set(i.subarray(n-r,n),0),l.wnext=r,l.whave=l.wsize):(l.wnext+=o,l.wnext===l.wsize&&(l.wnext=0),l.whave{let n,r,o,l,c,u,f,m,p,v,B,G,T,V,E=0,W,x,k,F,Y,L,O,Q;const X=new Uint8Array(4);let $,ee;const ne=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if($v(e)||!e.output||!e.input&&e.avail_in!==0)return zC;n=e.state,n.mode===hh&&(n.mode=Bee),c=e.next_out,o=e.output,f=e.avail_out,l=e.next_in,r=e.input,u=e.avail_in,m=n.hold,p=n.bits,v=u,B=f,Q=yv;e:for(;;)switch(n.mode){case LP:if(n.wrap===0){n.mode=Bee;break}for(;p<16;){if(u===0)break e;u--,m+=r[l++]<>>8&255,n.check=Bu(n.check,X,2,0),m=0,p=0,n.mode=pxe;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((m&255)<<8)+(m>>8))%31){e.msg="incorrect header check",n.mode=kg;break}if((m&15)!==mxe){e.msg="unknown compression method",n.mode=kg;break}if(m>>>=4,p-=4,O=(m&15)+8,n.wbits===0&&(n.wbits=O),O>15||O>n.wbits){e.msg="invalid window size",n.mode=kg;break}n.dmax=1<>8&1),n.flags&512&&n.wrap&4&&(X[0]=m&255,X[1]=m>>>8&255,n.check=Bu(n.check,X,2,0)),m=0,p=0,n.mode=bxe;case bxe:for(;p<32;){if(u===0)break e;u--,m+=r[l++]<>>8&255,X[2]=m>>>16&255,X[3]=m>>>24&255,n.check=Bu(n.check,X,4,0)),m=0,p=0,n.mode=yxe;case yxe:for(;p<16;){if(u===0)break e;u--,m+=r[l++]<>8),n.flags&512&&n.wrap&4&&(X[0]=m&255,X[1]=m>>>8&255,n.check=Bu(n.check,X,2,0)),m=0,p=0,n.mode=vxe;case vxe:if(n.flags&1024){for(;p<16;){if(u===0)break e;u--,m+=r[l++]<>>8&255,n.check=Bu(n.check,X,2,0)),m=0,p=0}else n.head&&(n.head.extra=null);n.mode=Zxe;case Zxe:if(n.flags&1024&&(G=n.length,G>u&&(G=u),G&&(n.head&&(O=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(l,l+G),O)),n.flags&512&&n.wrap&4&&(n.check=Bu(n.check,r,G,l)),u-=G,l+=G,n.length-=G),n.length))break e;n.length=0,n.mode=Bxe;case Bxe:if(n.flags&2048){if(u===0)break e;G=0;do O=r[l+G++],n.head&&O&&n.length<65536&&(n.head.name+=String.fromCharCode(O));while(O&&G>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=hh;break;case wxe:for(;p<32;){if(u===0)break e;u--,m+=r[l++]<>>=p&7,p-=p&7,n.mode=See;break}for(;p<3;){if(u===0)break e;u--,m+=r[l++]<>>=1,p-=1,m&3){case 0:n.mode=Txe;break;case 1:if(eci(n),n.mode=aF,i===oF){m>>>=2,p-=2;break e}break;case 2:n.mode=Vxe;break;case 3:e.msg="invalid block type",n.mode=kg}m>>>=2,p-=2;break;case Txe:for(m>>>=p&7,p-=p&7;p<32;){if(u===0)break e;u--,m+=r[l++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=kg;break}if(n.length=m&65535,m=0,p=0,n.mode=Gee,i===oF)break e;case Gee:n.mode=Rxe;case Rxe:if(G=n.length,G){if(G>u&&(G=u),G>f&&(G=f),G===0)break e;o.set(r.subarray(l,l+G),c),u-=G,l+=G,f-=G,c+=G,n.length-=G;break}n.mode=hh;break;case Vxe:for(;p<14;){if(u===0)break e;u--,m+=r[l++]<>>=5,p-=5,n.ndist=(m&31)+1,m>>>=5,p-=5,n.ncode=(m&15)+4,m>>>=4,p-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=kg;break}n.have=0,n.mode=Exe;case Exe:for(;n.have>>=3,p-=3}for(;n.have<19;)n.lens[ne[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,$={bits:n.lenbits},Q=yE(_Ci,n.lens,0,19,n.lencode,0,n.work,$),n.lenbits=$.bits,Q){e.msg="invalid code lengths set",n.mode=kg;break}n.have=0,n.mode=Hxe;case Hxe:for(;n.have>>24,x=E>>>16&255,k=E&65535,!(W<=p);){if(u===0)break e;u--,m+=r[l++]<>>=W,p-=W,n.lens[n.have++]=k;else{if(k===16){for(ee=W+2;p>>=W,p-=W,n.have===0){e.msg="invalid bit length repeat",n.mode=kg;break}O=n.lens[n.have-1],G=3+(m&3),m>>>=2,p-=2}else if(k===17){for(ee=W+3;p>>=W,p-=W,O=0,G=3+(m&7),m>>>=3,p-=3}else{for(ee=W+7;p>>=W,p-=W,O=0,G=11+(m&127),m>>>=7,p-=7}if(n.have+G>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=kg;break}for(;G--;)n.lens[n.have++]=O}}if(n.mode===kg)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=kg;break}if(n.lenbits=9,$={bits:n.lenbits},Q=yE(zJe,n.lens,0,n.nlen,n.lencode,0,n.work,$),n.lenbits=$.bits,Q){e.msg="invalid literal/lengths set",n.mode=kg;break}if(n.distbits=6,n.distcode=n.distdyn,$={bits:n.distbits},Q=yE(OJe,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,$),n.distbits=$.bits,Q){e.msg="invalid distances set",n.mode=kg;break}if(n.mode=aF,i===oF)break e;case aF:n.mode=sF;case sF:if(u>=6&&f>=258){e.next_out=c,e.avail_out=f,e.next_in=l,e.avail_in=u,n.hold=m,n.bits=p,xCi(e,B),c=e.next_out,o=e.output,f=e.avail_out,l=e.next_in,r=e.input,u=e.avail_in,m=n.hold,p=n.bits,n.mode===hh&&(n.back=-1);break}for(n.back=0;E=n.lencode[m&(1<>>24,x=E>>>16&255,k=E&65535,!(W<=p);){if(u===0)break e;u--,m+=r[l++]<>F)],W=E>>>24,x=E>>>16&255,k=E&65535,!(F+W<=p);){if(u===0)break e;u--,m+=r[l++]<>>=F,p-=F,n.back+=F}if(m>>>=W,p-=W,n.back+=W,n.length=k,x===0){n.mode=xxe;break}if(x&32){n.back=-1,n.mode=hh;break}if(x&64){e.msg="invalid literal/length code",n.mode=kg;break}n.extra=x&15,n.mode=Wxe;case Wxe:if(n.extra){for(ee=n.extra;p>>=n.extra,p-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=Nxe;case Nxe:for(;E=n.distcode[m&(1<>>24,x=E>>>16&255,k=E&65535,!(W<=p);){if(u===0)break e;u--,m+=r[l++]<>F)],W=E>>>24,x=E>>>16&255,k=E&65535,!(F+W<=p);){if(u===0)break e;u--,m+=r[l++]<>>=F,p-=F,n.back+=F}if(m>>>=W,p-=W,n.back+=W,x&64){e.msg="invalid distance code",n.mode=kg;break}n.offset=k,n.extra=x&15,n.mode=kxe;case kxe:if(n.extra){for(ee=n.extra;p>>=n.extra,p-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=kg;break}n.mode=Xxe;case Xxe:if(f===0)break e;if(G=B-f,n.offset>G){if(G=n.offset-G,G>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=kg;break}G>n.wnext?(G-=n.wnext,T=n.wsize-G):T=n.wnext-G,G>n.length&&(G=n.length),V=n.window}else V=o,T=c-n.offset,G=n.length;G>f&&(G=f),f-=G,n.length-=G;do o[c++]=V[T++];while(--G);n.length===0&&(n.mode=sF);break;case xxe:if(f===0)break e;o[c++]=n.length,f--,n.mode=sF;break;case See:if(n.wrap){for(;p<32;){if(u===0)break e;u--,m|=r[l++]<{if($v(e))return zC;let i=e.state;return i.window&&(i.window=null),e.state=null,yv},nci=(e,i)=>{if($v(e))return zC;const n=e.state;return n.wrap&2?(n.head=i,i.done=!1,yv):zC},rci=(e,i)=>{const n=i.length;let r,o,l;return $v(e)||(r=e.state,r.wrap!==0&&r.mode!==n3)?zC:r.mode===n3&&(o=1,o=ige(o,i,n,0),o!==r.check)?LJe:(l=tUe(e,i,n,n),l?(r.mode=UJe,JJe):(r.havedict=1,yv))};var gci=$Je,oci=qJe,aci=jJe,sci=qCi,Ici=eUe,lci=tci,Cci=ici,cci=nci,Aci=rci,uci="pako inflate (from Nodeca project)",Sh={inflateReset:gci,inflateReset2:oci,inflateResetKeep:aci,inflateInit:sci,inflateInit2:Ici,inflate:lci,inflateEnd:Cci,inflateGetHeader:cci,inflateSetDictionary:Aci,inflateInfo:uci};function dci(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var hci=dci;const iUe=Object.prototype.toString,{Z_NO_FLUSH:fci,Z_FINISH:mci,Z_OK:wH,Z_STREAM_END:Ree,Z_NEED_DICT:Vee,Z_STREAM_ERROR:pci,Z_DATA_ERROR:Kxe,Z_MEM_ERROR:bci}=ule;function EW(e){this.options=_Je.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});const i=this.options;i.raw&&i.windowBits>=0&&i.windowBits<16&&(i.windowBits=-i.windowBits,i.windowBits===0&&(i.windowBits=-15)),i.windowBits>=0&&i.windowBits<16&&!(e&&e.windowBits)&&(i.windowBits+=32),i.windowBits>15&&i.windowBits<48&&(i.windowBits&15||(i.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new kCi,this.strm.avail_out=0;let n=Sh.inflateInit2(this.strm,i.windowBits);if(n!==wH)throw new Error(nge[n]);if(this.header=new hci,Sh.inflateGetHeader(this.strm,this.header),i.dictionary&&(typeof i.dictionary=="string"?i.dictionary=rge.string2buf(i.dictionary):iUe.call(i.dictionary)==="[object ArrayBuffer]"&&(i.dictionary=new Uint8Array(i.dictionary)),i.raw&&(n=Sh.inflateSetDictionary(this.strm,i.dictionary),n!==wH)))throw new Error(nge[n])}EW.prototype.push=function(e,i){const n=this.strm,r=this.options.chunkSize,o=this.options.dictionary;let l,c,u;if(this.ended)return!1;for(i===~~i?c=i:c=i===!0?mci:fci,iUe.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),l=Sh.inflate(n,c),l===Vee&&o&&(l=Sh.inflateSetDictionary(n,o),l===wH?l=Sh.inflate(n,c):l===Kxe&&(l=Vee));n.avail_in>0&&l===Ree&&n.state.wrap>0&&e[n.next_in]!==0;)Sh.inflateReset(n),l=Sh.inflate(n,c);switch(l){case pci:case Kxe:case Vee:case bci:return this.onEnd(l),this.ended=!0,!1}if(u=n.avail_out,n.next_out&&(n.avail_out===0||l===Ree))if(this.options.to==="string"){let f=rge.utf8border(n.output,n.next_out),m=n.next_out-f,p=rge.buf2string(n.output,f);n.next_out=m,n.avail_out=r-m,m&&n.output.set(n.output.subarray(f,f+m),0),this.onData(p)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(!(l===wH&&u===0)){if(l===Ree)return l=Sh.inflateEnd(this.strm),this.onEnd(l),this.ended=!0,!0;if(n.avail_in===0)break}}return!0};EW.prototype.onData=function(e){this.chunks.push(e)};EW.prototype.onEnd=function(e){e===wH&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=_Je.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function dle(e,i){const n=new EW(i);if(n.push(e),n.err)throw n.msg||nge[n.err];return n.result}function yci(e,i){return i=i||{},i.raw=!0,dle(e,i)}var vci=EW,Zci=dle,Bci=yci,Gci=dle,Sci=ule,wci={Inflate:vci,inflate:Zci,inflateRaw:Bci,ungzip:Gci,constants:Sci};const{Inflate:TPi,inflate:RPi,inflateRaw:Tci,ungzip:VPi}=wci;var Rci=Tci;function Vci(e){return Rci(e.subarray(2))}class Eci extends Error{constructor(i){super(i),this.code="ERR_ABORTED"}}function Hci(e){e.sort((o,l)=>Number(o.offset)-Number(l.offset));const i=[];let n,r;for(let o=0;o=n}function Xci(e){const i=e?"big":"little",n=new pr().endianess(i).uint32("chromId").uint32("start").uint32("end").uint32("validCnt").floatle("minScore").floatle("maxScore").floatle("sumData").floatle("sumSqData").saveOffset("offset"),r=new pr().endianess(i).uint8("isLeaf").skip(1).uint16("cnt").choice({tag:"isLeaf",choices:{1:new pr().endianess(i).array("blocksToFetch",{length:"cnt",type:new pr().endianess(i).uint32("startChrom").uint32("startBase").uint32("endChrom").uint32("endBase").uint64("blockOffset").uint64("blockSize").saveOffset("offset")}),0:new pr().array("recurOffsets",{length:"cnt",type:new pr().endianess(i).uint32("startChrom").uint32("startBase").uint32("endChrom").uint32("endBase").uint64("blockOffset").saveOffset("offset")})}}),o=new pr().endianess(i).uint32("chromId").int32("start").int32("end").string("rest",{zeroTerminated:!0}).saveOffset("offset");return{bigWigParser:new pr().endianess(i).skip(4).int32("blockStart").skip(4).uint32("itemStep").uint32("itemSpan").uint8("blockType").skip(1).uint16("itemCount").choice({tag:"blockType",choices:{[kci]:new pr().array("items",{length:"itemCount",type:new pr().floatle("score")}),[Nci]:new pr().array("items",{length:"itemCount",type:new pr().endianess(i).int32("start").floatle("score")}),[Wci]:new pr().array("items",{length:"itemCount",type:new pr().endianess(i).int32("start").int32("end").floatle("score")})}}),bigBedParser:o,summaryParser:n,leafParser:r}}class nUe{constructor(i,n,r,o,l,c){if(this.bbi=i,this.refsByName=n,this.cirTreeOffset=r,this.isBigEndian=o,this.isCompressed=l,this.blockType=c,this.featureCache=new CCi({cache:new Pgi({maxSize:1e3}),fill:async(f,m)=>{const p=Number(f.length),v=Number(f.offset),{buffer:B}=await this.bbi.read(pv.Buffer.alloc(p),0,p,v,{signal:m});return B}}),!(r>=0))throw new Error("invalid cirTreeOffset!");const u=Xci(o);this.leafParser=u.leafParser,this.bigBedParser=u.bigBedParser}async readWigData(i,n,r,o,l){try{const{refsByName:c,bbi:u,cirTreeOffset:f,isBigEndian:m}=this,p=c[i];p===void 0&&o.complete();const v={chrId:p,start:n,end:r};this.cirTreePromise||(this.cirTreePromise=u.read(pv.Buffer.alloc(48),0,48,Number(f),l));const{buffer:B}=await this.cirTreePromise,G=m?B.readUInt32BE(4):B.readUInt32LE(4);let T=[],V=0;const E=(F,Y,L)=>{try{const O=F.subarray(Y),Q=this.leafParser.parse(O);if(Q.blocksToFetch&&(T=T.concat(Q.blocksToFetch.filter(W).map(X=>({offset:X.blockOffset,length:X.blockSize})))),Q.recurOffsets){const X=Q.recurOffsets.filter(W).map($=>Number($.blockOffset));X.length>0&&k(X,L+1)}}catch(O){o.error(O)}},W=F=>{const{startChrom:Y,startBase:L,endChrom:O,endBase:Q}=F;return(Yp||O===p&&Q>=n)},x=async(F,Y,L)=>{try{const O=Y.max()-Y.min(),Q=Y.min(),X=await this.featureCache.get(`${O}_${Q}`,{length:O,offset:Q},l.signal);for(let $=0;${try{V+=F.length;const L=4+Number(G)*32;let O=new cxe(F[0],F[0]+L);for(let Q=1;Qx(F,Q,Y))}catch(L){o.error(L)}};return k([Number(f)+48],1)}catch(c){o.error(c)}}parseSummaryBlock(i,n,r){const o=[];let l=n;const c=new DataView(i.buffer,i.byteOffset,i.length);for(;lEee(u.start,u.end,o.start,o.end)):l}parseBigWigBlock(i,n,r){const o=i.subarray(n),l=new DataView(o.buffer,o.byteOffset,o.length);let c=0;c+=4;const u=l.getInt32(c,!0);c+=8;const f=l.getUint32(c,!0);c+=4;const m=l.getUint32(c,!0);c+=4;const p=l.getUint8(c);c+=2;const v=l.getUint16(c,!0);c+=2;const B=new Array(v);switch(p){case 1:for(let G=0;GEee(G.start,G.end,r.start,r.end)):B}async readFeatures(i,n,r={}){try{const{blockType:o,isCompressed:l}=this,{signal:c,request:u}=r,f=Hci(n);IF(c),await Promise.all(f.map(async m=>{IF(c);const{length:p,offset:v}=m,B=await this.featureCache.get(`${p}_${v}`,m,c);m.blocks.forEach(G=>{IF(c);let T=Number(G.offset)-Number(m.offset),V=B;switch(l&&(V=Vci(B.subarray(T)),T=0),IF(c),o){case"summary":i.next(this.parseSummaryBlock(V,T,u));break;case"bigwig":i.next(this.parseBigWigBlock(V,T,u));break;case"bigbed":i.next(this.parseBigBedBlock(V,T,Number(G.offset)*(1<<8),u));break;default:console.warn(`Don't know what to do with ${o}`)}})})),i.complete()}catch(o){i.error(o)}}}var gge=function(e,i){return gge=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},gge(e,i)};function hle(e,i){if(typeof i!="function"&&i!==null)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");gge(e,i);function n(){this.constructor=e}e.prototype=i===null?Object.create(i):(n.prototype=i.prototype,new n)}function _xe(e){var i=typeof Symbol=="function"&&Symbol.iterator,n=i&&e[i],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(i?"Object is not iterable.":"Symbol.iterator is not defined.")}function oge(e,i){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),o,l=[],c;try{for(;(i===void 0||i-- >0)&&!(o=r.next()).done;)l.push(o.value)}catch(u){c={error:u}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(c)throw c.error}}return l}function age(e,i,n){if(n||arguments.length===2)for(var r=0,o=i.length,l;r=2,!1,!0))}var nAi=function(e,i){return e.push(i),e};function rAi(){return aUe(function(e,i){iAi(nAi,[])(e).subscribe(i)})}const Jxe=-2003829722,Nee=-2021002517;function gAi(e){return new TextDecoder().decode(e)}function Uxe(e){const i=e?"big":"little",n=new pr().endianess(i).int32("magic").uint16("version").uint16("numZoomLevels").uint64("chromTreeOffset").uint64("unzoomedDataOffset").uint64("unzoomedIndexOffset").uint16("fieldCount").uint16("definedFieldCount").uint64("asOffset").uint64("totalSummaryOffset").uint32("uncompressBufSize").uint64("extHeaderOffset").array("zoomLevels",{length:"numZoomLevels",type:new pr().endianess(i).uint32("reductionLevel").uint32("reserved").uint64("dataOffset").uint64("indexOffset")}),r=new pr().endianess(i).uint64("basesCovered").doublele("scoreMin").doublele("scoreMax").doublele("scoreSum").doublele("scoreSumSquares"),o=new pr().endianess(i).uint32("magic").uint32("blockSize").uint32("keySize").uint32("valSize").uint64("itemCount"),l=new pr().endianess(i).uint8("isLeafNode").skip(1).uint16("cnt").saveOffset("offset");return{chromTreeParser:o,totalSummaryParser:r,headerParser:n,isLeafNode:l}}class oAi{getHeader(i={}){const n="aborted"in i?{signal:i}:i;return this.headerP||(this.headerP=this._getHeader(n).catch(r=>{throw this.headerP=void 0,r})),this.headerP}constructor(i={}){const{filehandle:n,renameRefSeqs:r=c=>c,path:o,url:l}=i;if(this.renameRefSeqs=r,n)this.bbi=n;else if(l)this.bbi=new HLe(l);else if(o)this.bbi=new zgi(o);else throw new Error("no file given")}async _getHeader(i){const n=await this._getMainHeader(i),r=await this._readChromTree(n,i);return{...n,...r}}async _getMainHeader(i,n=2e3){const{buffer:r}=await this.bbi.read(pv.Buffer.alloc(n),0,n,0,i),o=this._isBigEndian(r),l=Uxe(o),c=l.headerParser.parse(r),{magic:u,asOffset:f,totalSummaryOffset:m}=c;if(c.fileType=u===Nee?"bigbed":"bigwig",f>n||m>n)return this._getMainHeader(i,n*2);if(f){const p=Number(c.asOffset);c.autoSql=gAi(r.subarray(p,r.indexOf(0,p)))}if(c.totalSummaryOffset>n)return this._getMainHeader(i,n*2);if(c.totalSummaryOffset){const p=r.subarray(Number(c.totalSummaryOffset)),v=l.totalSummaryParser.parse(p);c.totalSummary={...v,basesCovered:Number(v.basesCovered)}}return{...c,isBigEndian:o}}_isBigEndian(i){let n=i.readInt32LE(0);if(n===Jxe||n===Nee)return!1;if(n=i.readInt32BE(0),n===Jxe||n===Nee)return!0;throw new Error("not a BigWig/BigBed file")}async _readChromTree(i,n){const r=i.isBigEndian,o=r?"big":"little",l=[],c={};let u=Number(i.unzoomedDataOffset);const f=Number(i.chromTreeOffset);for(;u%4!==0;)u+=1;const m=u-f,{buffer:p}=await this.bbi.read(pv.Buffer.alloc(m),0,m,Number(f),n),v=Uxe(r),{keySize:B}=v.chromTreeParser.parse(p),G=new pr().endianess(o).string("key",{stripNull:!0,length:B}).uint32("refId").uint32("refSize").saveOffset("offset"),T=new pr().endianess(o).skip(B).uint64("childOffset").saveOffset("offset"),V=32,E=async W=>{let x=W;if(x>=p.length)throw new Error("reading beyond end of buffer");const k=v.isLeafNode.parse(p.subarray(x)),{isLeafNode:F,cnt:Y}=k;if(x+=k.offset,F)for(let L=0;L0,c)}async getFeatureStream(i,n,r,o={scale:1}){await this.getHeader(o);const l=this.renameRefSeqs(i);let c;if(o.basesPerSpan?c=await this.getView(1/o.basesPerSpan,o):o.scale?c=await this.getView(o.scale,o):c=await this.getView(1,o),!c)throw new Error("unable to get block view for data");return new Lci(u=>{c.readWigData(l,n,r,u,o)})}async getFeatures(i,n,r,o={scale:1}){const l=await this.getFeatureStream(i,n,r,o);return(await eAi(l.pipe(rAi()))).flat()}}class aAi extends oAi{async getView(i,n){const{zoomLevels:r,refsByName:o,fileSize:l,isBigEndian:c,uncompressBufSize:u}=await this.getHeader(n),f=1/i;let m=r.length;l||(m-=1);for(let p=m;p>=0;p-=1){const v=r[p];if(v&&v.reductionLevel<=2*f){const B=Number(v.indexOffset);return new nUe(this.bbi,o,B,c,u>0,"summary")}}return this.getUnzoomedView(n)}}function sUe(e,[i,n],r){const{x:o,xe:l,x1:c,x1e:u}=r,f=[o,l,c,u].filter(m=>m);return e.filter(m=>{if(f.length===0)return!0;if(f.length===1){const p=+m[f[0]];return typeof p=="number"&&i+m[G]).filter(G=>!isNaN(G)),v=Math.min(...p),B=Math.max(...p);return i<=B&&v<=n}})}hIe(e=>e.pos).left;function IUe(e,i,n){return Array.isArray(i)||(n?e=e.replace(n,"chr"):e.includes("chr")||(e=`chr${e}`)),e}class sAi extends HLe{constructor(){super(...arguments),this.read=async(i,n=0,r,o=0,l={})=>{const{headers:c={},signal:u,overrides:f={}}=l;r<1/0?c.range=`bytes=${o}-${o+r}`:r===1/0&&o!==0&&(c.range=`bytes=${o}-`);const m={...this.baseOverrides,...f,headers:{...c,...f.headers,...this.baseOverrides.headers},method:"GET",redirect:"follow",mode:"cors",signal:u},p=await this.fetch(this.url,m);if(!p.ok)throw new Error(`HTTP ${p.status} ${p.statusText} ${this.url}`);if(p.status===200||p.status===206){const v=await this.getBufferFromResponse(p),B=v.copy(i,n,0,Math.min(r,v.length)),G=p.headers.get("content-range"),T=/\/(\d+)$/.exec(G||"");return T&&T[1]&&(this._stat={size:parseInt(T[1],10)}),{bytesRead:B,buffer:i}}throw new Error(`HTTP ${p.status} fetching ${this.url}`)}}}function lUe(e,i){if(!new.target)throw new Error('Uncaught TypeError: Class constructor cannot be invoked without "new"');const n=class{constructor(){this.dataConfig=i,this.assembly=this.dataConfig.assembly,this.bwFileHeader=null,this.bwFile=null,this.TILE_SIZE=1024,this.errorTxt="",this.dataPromises=[];const o=Sg(this.assembly).size,l=[],c={};let u=0;Object.keys(Sg(this.assembly).size).forEach((f,m)=>{const p={id:m,chr:f,pos:u};l.push(p),c[f]=p,u+=Sg(this.assembly).size[f]}),this.chromSizes={chrToAbs:(f,m)=>this.chromSizes.chrPositions[f].pos+m,cumPositions:l,chrPositions:c,totalLength:u,chromLengths:o},this.dataPromises.push(this.loadBBI(i))}async loadBBI(o){return o.url?(this.bwFile=new aAi({filehandle:new sAi(o.url)}),this.bwFile.getHeader().then(l=>{this.bwFileHeader=l})):(console.error('Please enter a "url" field to the data config'),null)}tilesetInfo(o){return this.tilesetInfoLoading=!0,Promise.all(this.dataPromises).then(()=>{this.tilesetInfoLoading=!1;const l=this.chromSizes.totalLength,c={tile_size:this.TILE_SIZE,max_zoom:Math.ceil(Math.log(l/this.TILE_SIZE)/Math.log(2)),max_width:2**Math.ceil(Math.log(l)/Math.log(2)),min_pos:[0],max_pos:[l]};return o&&o(c),c}).catch(l=>(this.tilesetInfoLoading=!1,console.error(l),o&&o({error:`Error parsing bigwig: ${l}`}),null))}fetchTilesDebounced(o,l){const c={},u=[],f=[];for(const m of l){const p=m.split("."),v=parseInt(p[0],10),B=parseInt(p[1],10);if(Number.isNaN(B)||Number.isNaN(v)){console.warn("Invalid tile zoom or position:",v,B);continue}u.push(m),f.push(this.tile(v,B))}return Promise.all(f).then(m=>{for(let p=0;p{const k=x.chr,F=x.pos,Y=x.pos+E[k];let L,O;if(F<=v&&vY)L=v-F,O=Y-F,f.push(this.bwFile.getFeatures(k,L,O,{scale:1/G}).then(Q=>(Q.forEach(X=>{X.startAbs=e.utils.chrToAbs(k,X.start,this.chromSizes),X.endAbs=e.utils.chrToAbs(k,X.end,this.chromSizes)}),Q))),v=Y;else{if(L=Math.floor(v-F),O=Math.ceil(B-F),!this.bwFile)return;f.push(this.bwFile.getFeatures(k,L,O,{scale:1/G}).then(Q=>(Q.forEach(X=>{X.startAbs=e.utils.chrToAbs(k,X.start,this.chromSizes),X.endAbs=e.utils.chrToAbs(k,X.end,this.chromSizes)}),Q)));return}}),Promise.all(f).then(x=>{const k=x.flat(),F=[];for(let L=0;L{if(LB)return;const Q=k.filter(X=>L>=X.startAbs&&LX.score);F[O]=Q.length>0?Q[0]:null});const Y=new e.utils.DenseDataExtrema1D(F);return m.min_value=Math.min(...F),m.max_value=Math.max(...F),m.dense=F,m.denseDataExtrema=Y,m.minNonZero=Y.minNonZeroInTile,m.maxNonZero=Y.maxNonZeroInTile,m})}determineScale(o,l){const c=[1],u=l-o;if(!this.bwFileHeader)throw Error("no bigwig header");this.bwFileHeader.zoomLevels.forEach(m=>{c.push(m.reductionLevel)});let f;return c.forEach(m=>{if(f)return;u/m<=this.TILE_SIZE*20&&(f=m)}),f||c.slice(-1)[0]}};return new n}lUe.config={type:"bigwig"};class IAi{constructor(i){mr(this,Hre),mr(this,PIe),mr(this,_K),mr(this,Nre),mr(this,kre),mr(this,Xre),mr(this,W9,void 0),mr(this,BH,void 0),mr(this,GH,void 0),mr(this,Fy,void 0),mr(this,KK,void 0),this.dataConfig=i,this.tilesetInfoLoading=!1,wo(this,Fy,this.dataConfig.assembly),wo(this,KK,this.dataConfig.filter),i.url||console.error("Please provide the `url` of the data"),wo(this,BH,Og(this,Xre,DLe).call(this)),wo(this,W9,Og(this,Hre,NLe).call(this))}tilesetInfo(i){if(dn(this,W9))return this.tilesetInfoLoading=!0,dn(this,W9).then(()=>Og(this,Nre,XLe).call(this,i)).catch(n=>{this.tilesetInfoLoading=!1,console.error("[Gosling Data Fetcher] Error parsing data:",n)})}fetchTilesDebounced(i,n){const r={},o=[],l=[];for(const c of n){const u=c.split("."),f=parseInt(u[0],10),m=parseInt(u[1],10),p=parseInt(u[2],10);if(Number.isNaN(m)||Number.isNaN(f)){console.warn("[Gosling Data Fetcher] Invalid tile zoom or position:",f,m,p);continue}o.push(c),l.push(Og(this,kre,xLe).call(this,f,m,p))}Promise.all(l).then(c=>{c.forEach((u,f)=>{if(u){const m=o[f];r[m]=u,r[m].tilePositionId=m}}),i(r)})}}W9=new WeakMap;BH=new WeakMap;GH=new WeakMap;Fy=new WeakMap;KK=new WeakMap;Hre=new WeakSet;NLe=async function(){var e,i;const{url:n,chromosomeField:r,genomicFields:o,headerNames:l,longToWideId:c,genomicFieldsToConvert:u}=this.dataConfig,f=(e=this.dataConfig.separator)!=null?e:",";try{const m=await fetch(n),p=await(m.ok?m.text():Promise.reject(m.status)),v=l?`${l.join(f)} -${p}`:p,B=Ugi(f).parse(v,G=>Og(this,PIe,kLe).call(this,G,u,r,o));if(c&&((i=B[0])!=null&&i[c])){const G=Object.keys(B[0]),T={};B.forEach(V=>{T[V[c]]?G.forEach(E=>{T[V[c]][`${E}_2`]=V[E]}):T[V[c]]=JSON.parse(JSON.stringify(V))}),wo(this,GH,Object.keys(T).map(V=>T[V]))}else wo(this,GH,B)}catch(m){console.error("[Gosling Data Fetcher] Error fetching data",m)}};PIe=new WeakSet;kLe=function(e,i,n,r){try{return i?i.forEach(o=>{const l=o.genomicFields,c=e[o.chromosomeField];l.forEach(u=>{const f=e[u];e[u]=String(Og(this,_K,Wre).call(this,c,f))})}):n&&r&&r.forEach(o=>{const l=e[o],c=e[n];e[o]=String(Og(this,_K,Wre).call(this,c,l))}),e}catch{return}};_K=new WeakSet;Wre=function(e,i){if(dn(this,Fy)!=="unknown"){const n=IUe(e,dn(this,Fy),this.dataConfig.chromosomePrefix);return Sg(dn(this,Fy)).interval[n][0]+ +i}else return i};Nre=new WeakSet;XLe=function(e){this.tilesetInfoLoading=!1;const i=1024,n=dn(this,BH).totalLength,r={tile_size:i,max_zoom:Math.ceil(Math.log(n/i)/Math.log(2)),max_width:n,min_pos:[0,0],max_pos:[n,n]};return e&&e(r),r};kre=new WeakSet;xLe=async function(e,i,n){var r,o;const l=await this.tilesetInfo();if(!l)return;const c=+l.max_width/2**+e,u=l.min_pos[0]+i*c,f=l.min_pos[0]+(i+1)*c;let m=sUe(dn(this,GH),[u,f],this.dataConfig);(r=dn(this,KK))==null||r.forEach(v=>{m=HJe(v,m)});const p=(o=this.dataConfig.sampleLength)!=null?o:1e3;return{tabularData:m.length>p?EIe(m,p):m,server:null,tilePos:[i,n],zoomLevel:e}};Xre=new WeakSet;DLe=function(){const e=Sg(dn(this,Fy)).size,i=[],n={};let r=0;return Object.keys(e).forEach((o,l)=>{const c={id:l,chr:o,pos:r};i.push(c),n[o]=c,r+=e[o]}),{chrToAbs:(o,l)=>dn(this,BH).chrPositions[o].pos+l,cumPositions:i,chrPositions:n,totalLength:r,chromLengths:e}};function CUe(e,i,n){if(!new.target)throw new Error('Uncaught TypeError: Class constructor cannot be invoked without "new"');return new IAi(i)}CUe.config={type:"csv"};function cUe(e,...i){if(!new.target)throw new Error('Uncaught TypeError: Class constructor cannot be invoked without "new"');class n{constructor(o){const[l]=o;if(this.dataConfig=l,this.tilesetInfoLoading=!1,this.assembly=this.dataConfig.assembly,!l.values){console.error("Please provide `values` of the JSON data");return}const c=Sg(this.assembly).size,u=[],f={};let m=0;Object.keys(Sg(this.assembly).size).forEach((B,G)=>{const T={id:G,chr:B,pos:m};u.push(T),f[B]=T,m+=Sg(this.assembly).size[B]}),this.chromSizes={chrToAbs:(B,G)=>this.chromSizes.chrPositions[B].pos+G,cumPositions:u,chrPositions:f,totalLength:m,chromLengths:c};const{chromosomeField:p,genomicFields:v}=this.dataConfig;this.values=l.values.map(B=>{let G=!0;if(v&&p&&v.forEach(T=>{if(B[p])try{const V=IUe(B[p],this.assembly);B[T]=Sg(this.assembly).interval[V][0]+ +B[T]}catch{G=!1}}),!!G)return B})}tilesetInfo(o){this.tilesetInfoLoading=!1;const l=1024,c=this.chromSizes.totalLength,u={tile_size:l,max_zoom:Math.ceil(Math.log(c/l)/Math.log(2)),max_width:c,min_pos:[0,0],max_pos:[c,c]};return o&&o(u),u}fetchTilesDebounced(o,l){const c={},u=[],f=[];for(const m of l){const p=m.split("."),v=parseInt(p[0],10),B=parseInt(p[1],10),G=parseInt(p[2],10);if(Number.isNaN(B)||Number.isNaN(v)){console.warn("[Gosling Data Fetcher] Invalid tile zoom or position:",v,B,G);continue}u.push(m),f.push(this.tile(v,B,G))}return Promise.all(f).then(m=>{m.forEach((p,v)=>{const B=u[v];c[B]=p,c[B].tilePositionId=B}),o(c)}),c}tile(o,l,c){var u;const f=this.tilesetInfo(),m=+f.max_width/2**+o,p=f.min_pos[0]+l*m,v=f.min_pos[0]+(l+1)*m;let B=sUe(this.values,[p,v],this.dataConfig);const G=(u=this.dataConfig.sampleLength)!=null?u:1e3;return G{const f=Object.entries(Sg(l).size);return await u.init(this.uid,{url:r,indexUrl:o},f,c),u})}async tilesetInfo(i){(await this.worker).tilesetInfo(this.uid).then(i)}fetchTilesDebounced(i,n){this.track.drawLoadingCue(),n.forEach(r=>this.toFetch.add(r)),this.fetchTimeout&&clearTimeout(this.fetchTimeout),this.fetchTimeout=setTimeout(()=>{this.sendFetch(i,[...this.toFetch]),this.toFetch.clear()},CAi)}async sendFetch(i,n){(await this.worker).fetchTilesDebounced(this.uid,n).then(i)}async getTabularData(i){const n=await(await this.worker).getTabularData(this.uid,i);return JSON.parse(new TextDecoder().decode(n))}}uUe.config={type:"bed"};var cAi=Object.freeze(Object.defineProperty({__proto__:null,BamDataFetcher:ale,VcfDataFetcher:XJe,BigWigDataFetcher:lUe,CsvDataFetcher:CUe,JsonDataFetcher:cUe,BedDataFetcher:uUe},Symbol.toStringTag,{value:"Module"}));const jxe=3,AAi={color:"#777",stroke:"#777",strokeWidth:1,strokeOpacity:.7,opacity:.3};class uAi{constructor(i,n,r={}){this.emitter=Qgi(),this.range=null,this.prevExtent=[0,0],this.data=this.rangeToData(0,0),this.offset=[0,0],this.size=0,this.externals={d3Selection:n.d3Selection,d3Drag:n.d3Drag},this.style=Object.assign({},AAi,r),this.brushSelection=i.selectAll(".genomic-range-brush").data(this.data).enter().append("rect").attr("class","genomic-range-brush").call(this.onDrag())}getRange(){return this.range}setSize(i){return this.size=i,this}setOffset(i,n){return this.offset=[i,n],this}updateRange(i){return i?(this.range=[Math.min(...i),Math.max(...i)],this.data=this.rangeToData(...this.range)):this.range=null,this}drawBrush(i=!1){const[n,r]=this.offset,o=this.size,l=c=>Math.abs(c.end-c.start);return this.brushSelection.data(this.data).attr("transform",c=>`translate(${n+c.start}, ${r+1})`).attr("width",c=>`${l(c)}px`).attr("height",`${o-2}px`).attr("fill",this.style.color).attr("stroke",this.style.stroke).attr("stroke-width",`${this.style.strokeWidth}px`).attr("fill-opacity",c=>c.type==="body"?this.style.opacity:0).attr("stroke-opacity",c=>c.type==="body"?this.style.strokeOpacity:0).attr("cursor",c=>c.cursor),this.emitter.emit("brush",this.getRange(),i),this}enable(){return this.brushSelection.attr("pointer-events","all"),this}disable(){return this.brushSelection.attr("pointer-events","none"),this}visible(){return this.brushSelection.attr("visibility","visible"),this}hidden(){return this.brushSelection.attr("visibility","hidden"),this}clear(){return this.updateRange(null).drawBrush().hidden().disable(),this}remove(){return this.brushSelection.remove(),this}rangeToData(i,n){return[{type:"body",cursor:"grab",start:i,end:n},{type:"start",cursor:"ew-resize",start:i-jxe,end:i},{type:"end",cursor:"ew-resize",start:n,end:n+jxe}]}onDrag(){const i=r=>{this.startEvent=r.sourceEvent,this.prevExtent=this.range},n=(r,o)=>{var l;const c=r.sourceEvent.layerX-this.startEvent.layerX;let[u,f]=(l=this.prevExtent)!=null?l:[0,0];o.type==="body"?(u+=c,f+=c):o.type==="start"?u+=c:o.type==="end"&&(f+=c),this.updateRange([u,f]).drawBrush()};return this.externals.d3Drag.drag().on("start",i).on("drag",n)}on(i,n){this.emitter.on(i,n)}}const $xe={stroke:"black",strokeWidth:1,strokeOpacity:1,color:"none",opacity:1,arrange:"front"};function dAi(){return{goslingModels:[],tabularData:[],skipRendering:!1}}const hAi={type:"gosling-track",datatype:["multivec","epilogos"],orientation:"1d-horizontal",defaultOptions:{theme:Tre("light")}},fAi=(e,i,n)=>{var r,o,l,c,u,f,m,p,v,B,G,T,V,E,W,x,k,F,Y,L,O,Q,X,$,ee,ne,ge,Ae,_,de,Ze,me,be;const{tileProxy:Ee}=e.services,{BarTrack:Je}=e.tracks,Ue=If({color:"black",size:12}),dt=class extends Je{constructor(){var ke,ze,je,lt,xe,it;super(i,n),mr(this,T),mr(this,E),mr(this,x),mr(this,F),mr(this,L),mr(this,Q),mr(this,$),mr(this,ne),mr(this,Ae),mr(this,de),mr(this,me),mr(this,r,void 0),mr(this,o,void 0),mr(this,l,void 0),mr(this,c,void 0),mr(this,u,void 0),mr(this,f,void 0),mr(this,m,void 0),mr(this,p,void 0),mr(this,v,void 0),this.gLegend=e.libraries.d3Selection.select(i.svgElement).append("g"),this.displayedLegends=[],this.textGraphics=[],this.textsBeingUsed=0,this.pMouseHover=new e.libraries.PIXI.Graphics,this.pMouseSelection=new e.libraries.PIXI.Graphics,wo(this,l,0),wo(this,c,0),wo(this,u,!1),wo(this,f,e.libraries.d3Selection.select(i.svgElement).append("g")),wo(this,m,new e.libraries.PIXI.TextStyle(Ue)),wo(this,p,new e.libraries.PIXI.Graphics),wo(this,v,new e.libraries.PIXI.Text("",Ue)),i.dataFetcher.track=this,wo(this,o,{}),wo(this,r,this.options.spec.assembly),"overlay"in this.options.spec?this.options.spec.overlay=this.options.spec.overlay.map(Et=>({...Et,_renderingId:LK()})):this.options.spec._renderingId=LK(),this.fetchedTiles={},this.tileSize=(ze=(ke=this.tilesetInfo)==null?void 0:ke.tile_size)!=null?ze:1024;const{valid:Ct,errorMessages:It}=VJe(this.options.spec);Ct||console.warn("The specification of the following track is invalid",It,this.options.spec),this.pMain.addChild(this.pMouseHover),this.pMain.addChild(this.pMouseSelection),this.pMask.interactive=!0,this.mRangeBrush=new uAi(dn(this,f),e.libraries,(je=this.options.spec.style)==null?void 0:je.brush),this.mRangeBrush.on("brush",Og(this,de,Ze).bind(this)),this.pMask.on("mousedown",Et=>{const{x:Zt,y:zt}=Et.data.getLocalPosition(this.pMain);Og(this,F,Y).call(this,Zt,zt,Et.data.originalEvent.altKey)}),this.pMask.on("mouseup",Et=>{const{x:Zt,y:zt}=Et.data.getLocalPosition(this.pMain);Og(this,Q,X).call(this,Zt,zt)}),this.pMask.on("mousemove",Et=>{const{x:Zt}=Et.data.getLocalPosition(this.pMain);Og(this,L,O).call(this,Zt)}),this.pMask.on("mouseout",Og(this,$,ee).bind(this)),this.flipText=this.options.spec.orientation==="vertical",this.hideMousePosition&&(this.hideMousePosition(),this.hideMousePosition=void 0),(lt=this.options)!=null&<.showMousePosition&&!this.hideMousePosition&&(this.hideMousePosition=e.utils.showMousePosition(this,CI(xu(this.options.spec)[0]),this.isShowGlobalMousePosition())),this.pLabel.removeChild(this.trackNotFoundText),dn(this,v).anchor.x=1,dn(this,v).anchor.y=1,this.pLabel.addChild(dn(this,p)),this.pLabel.addChild(dn(this,v)),e.libraries.PIXI.GRAPHICS_CURVES.adaptive=(it=(xe=this.options.spec.style)==null?void 0:xe.enableSmoothPath)!=null?it:!1,e.libraries.PIXI.GRAPHICS_CURVES.adaptive&&(e.libraries.PIXI.GRAPHICS_CURVES.maxLength=1,e.libraries.PIXI.GRAPHICS_CURVES.maxSegments=2048*10)}draw(){var ke,ze;this.clearMouseEventData(),this.textsBeingUsed=0,(ke=this.pMouseHover)==null||ke.clear();const je=()=>{this.processAllTiles(),super.draw(),this.prevVisibleAndFetchedTiles=this.visibleAndFetchedTiles()};QM(this.dataFetcher)&&!tLe(this.visibleAndFetchedTiles(),this.prevVisibleAndFetchedTiles)?this.updateTileAsync(this.dataFetcher,je):je(),(ze=this.mRangeBrush)==null||ze.drawBrush(!0)}initTile(ke){this.drawTile(ke)}updateTile(){}renderTile(){}drawTile(ke){var ze,je;ke.drawnAtScale=this._xScale.copy();const lt=dn(this,o)[ke.tileId];lt&&((ze=ke.graphics)==null||ze.clear(),(je=ke.graphics)==null||je.removeChildren(),this.pBackground.clear(),this.pBackground.removeChildren(),this.pBorder.clear(),this.pBorder.removeChildren(),this.displayedLegends=[],lt.goslingModels.forEach(xe=>{const it=this.dimensions[0],Ct=this._xScale.invert(it)-this._xScale.invert(0);xe.trackVisibility({zoomLevel:Ct})&&(Xoi(e,this,ke,xe,this.options.theme),koi(e,this,ke,xe),xoi(e,this,ke,xe,this.options.theme))}),this.forceDraw())}rerender(ke){this.options=ke,this.options.spec.layout==="circular"&&this.mRangeBrush.remove(),this.clearMouseEventData(),this.textsBeingUsed=0,this.processAllTiles(!0),this.draw(),this.forceDraw()}clearMouseEventData(){this.visibleAndFetchedGoslingModels().forEach(ke=>ke.getMouseEventModel().clear())}visibleAndFetchedGoslingModels(){return this.visibleAndFetchedTiles().flatMap(ke=>{var ze,je;return(je=(ze=dn(this,o)[ke.tileId])==null?void 0:ze.goslingModels)!=null?je:[]})}remove(){super.remove(),this.gLegend&&(this.gLegend.remove(),this.gLegend=void 0),this.mRangeBrush.remove()}setDimensions(ke){super.setDimensions(ke),this.mRangeBrush.setSize(ke[1])}setPosition(ke){super.setPosition(ke),[this.pMain.position.x,this.pMain.position.y]=this.position,this.mRangeBrush.setOffset(...ke)}forceDraw(){this.animate()}zoomed(ke,ze){const je=this.mRangeBrush.getRange();this.mRangeBrush.updateRange(je?[ke(this._xScale.invert(je[0])),ke(this._xScale.invert(je[1]))]:null),this.xScale(ke),this.yScale(ze),this.refreshTiles(),this.draw(),this.forceDraw()}processAllTiles(ke=!1){var ze,je;this.tileSize=(je=(ze=this.tilesetInfo)==null?void 0:ze.tile_size)!=null?je:1024;const lt=this.visibleAndFetchedTiles();lt.forEach(Ct=>Og(this,x,k).call(this,Ct,ke)),this.combineAllTilesIfNeeded();const xe=lt.flatMap(Ct=>this.transformDataAndCreateModels(Ct));cli(xe);const it=[].concat(...xe.map(Ct=>Ct.data()));it.length!==0&&Lb("rawData",{id:i.viewUid,data:it})}async updateTileAsync(ke,ze){if(!this.tilesetInfo)return;const je=await ke.getTabularData(Object.values(this.fetchedTiles).map(xe=>xe.remoteId)),lt=this.visibleAndFetchedTiles();if(lt?.[0]){const xe=lt[0],[it]=e.utils.trackUtils.calculate1DVisibleTiles(this.tilesetInfo,this._xScale);xe.tileData.zoomLevel=it[0],xe.tileData.tilePos=[it[1],it[1]],xe.tileData.tabularData=je}ze()}calculateVisibleTiles(){var ke,ze,je,lt,xe;if(this.tilesetInfo)if(QM(this.dataFetcher)){const it=e.utils.trackUtils.calculate1DVisibleTiles(this.tilesetInfo,this._xScale),Ct=(ze=(ke=this.tilesetInfo.max_tile_width)!=null?ke:this.dataFetcher.MAX_TILE_WIDTH)!=null?ze:Number.MAX_SAFE_INTEGER;for(const It of it){const{tileWidth:Et}=this.getTilePosAndDimensions(It[0],[It[1],It[1]]);if(this.forceDraw(),Et>Ct)return}this.setVisibleTiles(it)}else{if(!this.tilesetInfo)return;const it=this.calculateZoomLevel();if("resolutions"in this.tilesetInfo){const Ct=this.tilesetInfo.resolutions.map(zt=>+zt).sort((zt,Kt)=>Kt-zt),It=Ee.calculateTilesFromResolution(Ct[it],this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]);let Et;CI(xu(this.options.spec)[0])&&(Et=Ee.calculateTilesFromResolution(Ct[it],this._yScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]));const Zt=Og(je=dt,B,G).call(je,It,Et,it);this.setVisibleTiles(Zt)}else{const Ct=Ee.calculateTiles(it,this.relevantScale(),this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width);let It;CI(xu(this.options.spec)[0])&&(It=Ee.calculateTiles(it,this._yScale,this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[1],this.tilesetInfo.max_zoom,(lt=this.tilesetInfo.max_width1)!=null?lt:this.tilesetInfo.max_width));const Et=Og(xe=dt,B,G).call(xe,Ct,It,it);this.setVisibleTiles(Et)}}}getTilePosAndDimensions(ke,ze){if(!this.tilesetInfo)throw Error("tilesetInfo not parsed");if("resolutions"in this.tilesetInfo){const lt=this.tilesetInfo.resolutions.map(zt=>+zt).sort((zt,Kt)=>Kt-zt)[ke],[xe,it]=ze,Ct=lt*dn(this,T,V),It=Ct,Et=Ct*xe,Zt=It*it;return{tileX:Et,tileY:Zt,tileWidth:Ct,tileHeight:It}}else{const[je,lt]=ze,xe=this.tilesetInfo.min_pos[0],it=this.tilesetInfo.min_pos[1],Ct=this.tilesetInfo.max_width/2**ke,It=this.tilesetInfo.max_width/2**ke,Et=xe+je*Ct,Zt=it+lt*It;return{tileX:Et,tileY:Zt,tileWidth:Ct,tileHeight:It}}}getIndicesOfVisibleDataInTile(ke){const ze=this._xScale.range();if(!this.tilesetInfo||!ke.tileData.tilePos||!("dense"in ke.tileData))return[0,0];const{tileX:je,tileWidth:lt}=this.getTilePosAndDimensions(ke.tileData.zoomLevel,ke.tileData.tilePos),xe=e.libraries.d3Scale.scaleLinear().domain([0,dn(this,T,V)]).range([je,je+lt]),it=Math.max(0,Math.round(xe.invert(this._xScale.invert(ze[0])))),Ct=Math.min(ke.tileData.dense.length,Math.round(xe.invert(this._xScale.invert(ze[1]))));return[it,Ct]}receivedTiles(ke){super.receivedTiles(ke),QM(this.dataFetcher)&&this.drawLoadingCue()}removeOldTiles(){super.removeOldTiles(),QM(this.dataFetcher)&&this.drawLoadingCue()}combineAllTilesIfNeeded(){var ke,ze,je;if(!this.shouldCombineTiles())return;const lt=this.visibleAndFetchedTiles();if(!lt||lt.length<=1)return;this.tileSize=((ze=(ke=this.tilesetInfo)==null?void 0:ke.tile_size)!=null?ze:1024)*lt.length;let xe=[];lt.forEach((Ct,It)=>{const Et=dn(this,o)[Ct.tileId];Et&&(xe=[...xe,...Et.tabularData],Et.skipRendering=It!==0)});const it=dn(this,o)[lt[0].tileId];it.tabularData=xe,(je=it.tabularData[0])!=null&&je.uid&&(it.tabularData=Jii(it.tabularData,"uid"))}shouldCombineTiles(){const ke=Moi(this.options.spec,"displace"),ze=()=>{const lt=this.visibleAndFetchedTiles();return lt.length>=1&&"dense"in lt[0].tileData},je=this.dataFetcher instanceof ale;return ke&&!ze()||je}transformDataAndCreateModels(ke){const ze=dn(this,o)[ke.tileId];return!ze||ze.skipRendering?[]:(ze.goslingModels=[],Og(this,E,W).call(this).forEach(lt=>{var xe;let it=Array.from(ze.tabularData);(xe=lt.dataTransform)==null||xe.forEach(ti=>{switch(ti.type){case"filter":it=HJe(ti,it);break;case"concat":it=hli(ti,it);break;case"replace":it=fli(ti,it);break;case"log":it=mli(ti,it);break;case"exonSplit":it=Zli(ti,it,lt.assembly);break;case"genomicLength":it=pli(ti,it);break;case"svType":it=bli(ti,it);break;case"coverage":it=yli(ti,it,this._xScale.copy());break;case"subjson":it=Bli(ti,it);break;case"displace":it=vli(ti,it,this._xScale.copy());break}});try{if(PubSub){const mi=it.length;PubSub.publish("data-preview",{id:i.viewUid,dataConfig:JSON.stringify({data:lt.data}),data:100>mi?it:EIe(it,100)})}}catch{}const[Ct,It]=this.dimensions,Et=OK(lt)?WC:0,[Zt,zt]=[Ct,It+Et],Kt=Math.min(Zt,zt)/Math.min(lt.width,lt.height);lt.innerRadius&&(lt.innerRadius=lt.innerRadius*Kt),lt.outerRadius&&(lt.outerRadius=lt.outerRadius*Kt),lt.width=Zt,lt.height=zt;const Ut=new Wli(lt,it,this.options.theme);ze.goslingModels.push(Ut)}),ze.goslingModels)}getMouseOverHtml(ke,ze){var je,lt,xe,it,Ct;if(Og(this,Ae,_).call(this,"trackMouseOver",ke,ze),dn(this,u)||!this.tilesetInfo)return"";this.pMouseHover.clear();const It=QV(Math.floor(this._xScale.invert(ke)),dn(this,r)),Et=Og(this,ne,ge).call(this,ke,ze);if(Et.length!==0?document.body.style.cursor="pointer":document.body.style.cursor="default",Et.length!==0){const Zt=(je=this.options.spec.experimental)==null?void 0:je.mouseEvents;if(!!Zt||lG(Zt)&&!!Zt.mouseOver){const ti=this.pMouseHover;((xe=(lt=this.options.spec.style)==null?void 0:lt.mouseOver)==null?void 0:xe.arrange)!=="behind"&&(this.pMain.removeChild(ti),this.pMain.addChild(ti)),Og(this,me,be).call(this,ti,Et,Object.assign({},$xe,(it=this.options.spec.style)==null?void 0:it.mouseOver)),Lb("mouseOver",{id:i.viewUid,genomicPosition:It,data:Et.map(mi=>mi.value)})}const Ut=(Ct=this.visibleAndFetchedGoslingModels().find(ti=>{var mi;return ti.spec().tooltip&&((mi=ti.spec().tooltip)==null?void 0:mi.length)!==0}))==null?void 0:Ct.spec().tooltip;if(Ut){let ti=Ut.map(mi=>{var Cn;const on=Et[0].value[mi.field];let ki=on;if(mi.type==="quantitative"&&mi.format)ki=e.libraries.d3Format.format(mi.format)(+on);else if(mi.type==="genomic"){const{chromosome:Ei,position:Bn}=QV(+on,dn(this,r));ki=`${Ei}:${e.libraries.d3Format.format(",")(Bn)}`}return`${(Cn=mi.alt)!=null?Cn:mi.field}${ki}`}).join("");return ti=`${ti}
`,Et.length>1&&(ti+=`
${Et.length-1} Additional Selections...
`),`
${ti}
`}}return""}minVisibleValue(){return 0}maxVisibleValue(){return 0}exportSVG(){throw new Error("exportSVG() not supported for gosling-track")}drawLoadingCue(){if(this.fetching.size){const ze=`Fetching... ${Array.from(this.fetching).join(" ")}`;dn(this,v).text=ze,dn(this,v).x=this.position[0]+this.dimensions[0]-6/2,dn(this,v).y=this.position[1]+this.dimensions[1]-6/2;const je=e.libraries.PIXI.TextMetrics.measureText(ze,dn(this,m)),{width:lt,height:xe}=je;dn(this,p).clear(),dn(this,p).lineStyle(1,hi("grey"),1,.5),dn(this,p).beginFill(hi("white"),.8),dn(this,p).drawRect(this.position[0]+this.dimensions[0]-lt-6-1,this.position[1]+this.dimensions[1]-xe-6-1,lt+6,xe+6),dn(this,v).visible=!0,dn(this,p).visible=!0}else dn(this,v).visible=!1,dn(this,p).visible=!1}updateScaleOffsetFromOriginalSpec(ke,ze,je){xu(this.options.spec).map(lt=>{if(lt._renderingId===ke){const xe=lt[je];Ii(xe)&&(xe.scaleOffset=ze)}})}shareScaleOffsetAcrossTracksAndTiles(ke,ze){this.visibleAndFetchedGoslingModels().forEach(lt=>{const xe=lt.spec()[ze];Ii(xe)&&(xe.scaleOffset=ke);const it=lt.originalSpec()[ze];Ii(it)&&(it.scaleOffset=ke)})}};let rt=dt;return r=new WeakMap,o=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,f=new WeakMap,m=new WeakMap,p=new WeakMap,v=new WeakMap,B=new WeakSet,G=function(ke,ze,je){if(!ze)return ke.map(xe=>[je,xe]);const lt=[];return ke.forEach(xe=>ze.forEach(it=>lt.push([je,xe,it]))),lt},T=new WeakSet,V=function(){let ke;return this.tilesetInfo&&(ke="bins_per_dimension"in this.tilesetInfo?this.tilesetInfo.bins_per_dimension:this.tilesetInfo.tile_size),ke??256},E=new WeakSet,W=function(){const ke=structuredClone(this.options.spec);return xu(ke).filter(ze=>ze.mark!=="brush")},x=new WeakSet,k=function(ke,ze=!1){if(dn(this,o)[ke.tileId]&&!ze||!ke.tileData.tilePos)return;const je=dAi(),lt=Og(this,E,W).call(this);if(lt.length===0)return[];const xe=lt[0];if("tabularData"in ke.tileData)je.tabularData=ke.tileData.tabularData;else{const{tileX:it,tileY:Ct,tileWidth:It,tileHeight:Et}=this.getTilePosAndDimensions(ke.tileData.zoomLevel,ke.tileData.tilePos),Zt="length"in ke.tileData?Array.from(ke.tileData):[],zt=Object.assign({},ke.tileData,{sparse:Zt,tileX:it,tileY:Ct,tileWidth:It,tileHeight:Et,tileSize:this.tileSize}),Kt=kli(xe,zt);Kt&&(je.tabularData=Kt)}dn(this,o)[ke.tileId]=je},F=new WeakSet,Y=function(ke,ze,je){var lt;wo(this,l,ke),wo(this,c,ze);const xe=(lt=this.options.spec.experimental)==null?void 0:lt.mouseEvents,it=!!xe||lG(xe)&&!!xe.rangeSelect;wo(this,u,it&&je),this.pMouseHover.clear()},L=new WeakSet,O=function(ke){this.options.spec.layout!=="circular"&&dn(this,u)&&this.mRangeBrush.updateRange([ke,dn(this,l)]).drawBrush().visible().disable()},Q=new WeakSet,X=function(ke,ze){var je;Og(this,Ae,_).call(this,"trackClick",ke,ze);const lt=(je=this.options.spec.experimental)==null?void 0:je.mouseEvents,xe=!!lt||lG(lt)&&!!lt.click,it=Math.sqrt((dn(this,l)-ke)**2+(dn(this,c)-ze)**2)>1;if(!dn(this,u)&&!it?(this.mRangeBrush.clear(),this.pMouseSelection.clear()):this.mRangeBrush.enable(),wo(this,u,!1),!!this.tilesetInfo&&!it&&xe){const Ct=QV(Math.floor(this._xScale.invert(ke)),dn(this,r)),It=Og(this,ne,ge).call(this,ke,ze);It.length!==0&&Lb("click",{id:i.viewUid,genomicPosition:Ct,data:It.map(Et=>Et.value)})}},$=new WeakSet,ee=function(){wo(this,u,!1),document.body.style.cursor="default",this.pMouseHover.clear()},ne=new WeakSet,ge=function(ke,ze){var je;const lt=this.visibleAndFetchedGoslingModels(),xe=(je=this.options.spec.experimental)==null?void 0:je.mouseEvents,it=lG(xe)&&xe.enableMouseOverOnMultipleMarks,Ct=lG(xe)&&xe.groupMarksByField,It=lt.map(Et=>Et.getMouseEventModel().findAll(ke,ze,!0)).flat();if(it||It.splice(1,It.length-1),It.length!==0&&Ct){const Et=Array.from(It);lt.forEach(Zt=>{const zt=Zt.getMouseEventModel().getSiblings(Et,Ct);It.push(...zt)})}return It},Ae=new WeakSet,_=function(ke,ze,je){const[lt,xe]=this.position,[it,Ct]=this.dimensions;if(this.options.spec.layout==="circular"){const It=lt+it/2,Et=xe+Ct/2,Zt=this.options.spec.innerRadius,zt=this.options.spec.outerRadius,Kt=this.options.spec.startAngle,Ut=this.options.spec.endAngle;Sli([ze,je],[it/2,Ct/2],[Zt,zt],[Kt,Ut])&&Lb(ke,{id:i.viewUid,spec:structuredClone(this.options.spec),shape:{cx:It,cy:Et,innerRadius:Zt,outerRadius:zt,startAngle:Kt,endAngle:Ut}})}else Lb(ke,{id:i.viewUid,spec:structuredClone(this.options.spec),shape:{x:lt,y:xe,width:it,height:Ct}})},de=new WeakSet,Ze=function(ke,ze=!1){var je,lt,xe,it;if(this.pMouseSelection.clear(),ke===null){ze||Lb("rangeSelect",{id:i.viewUid,genomicRange:null,data:[]});return}const Ct=this.visibleAndFetchedGoslingModels(),[It,Et]=ke;let Zt=Ct.map(Ut=>Ut.getMouseEventModel().findAllWithinRange(It,Et,!0)).flat();const zt=(je=this.options.spec.experimental)==null?void 0:je.mouseEvents,Kt=lG(zt)&&zt.groupMarksByField;if(Zt.length!==0&&Kt&&Ct.forEach(Ut=>{const ti=Ut.getMouseEventModel().getSiblings(Zt,Kt),mi=Array.from(new Set(ti.map(Cn=>Cn.value[Kt])));Zt=Zt.filter(Cn=>mi.indexOf(Cn.value[Kt])===-1)}),Zt.length!==0){const Ut=this.pMouseSelection;((xe=(lt=this.options.spec.style)==null?void 0:lt.select)==null?void 0:xe.arrange)!=="behind"&&(this.pMain.removeChild(Ut),this.pMain.addChild(Ut)),Og(this,me,be).call(this,Ut,Zt,Object.assign({},$xe,(it=this.options.spec.style)==null?void 0:it.select))}if(!ze){const Ut=[QV(Math.floor(this._xScale.invert(It)),dn(this,r)),QV(Math.floor(this._xScale.invert(Et)),dn(this,r))];Lb("rangeSelect",{id:i.viewUid,genomicRange:Ut,data:Zt.map(ti=>ti.value)})}this.forceDraw()},me=new WeakSet,be=function(ke,ze,je){ke.lineStyle(je.strokeWidth,hi(je.stroke),je.strokeOpacity,.5),ke.beginFill(hi(je.color),je.color==="none"?0:je.opacity),ze.forEach(lt=>{if(lt.type==="point"){const[xe,it,Ct=3]=lt.polygon;ke.drawCircle(xe,it,Ct)}else lt.type==="line"?(ke.moveTo(lt.polygon[0],lt.polygon[1]),yoi(lt.polygon).map(xe=>ke.lineTo(xe[0],xe[1]))):ke.drawPolygon(lt.polygon)})},mr(rt,B),new rt};var CF=$Le(hAi,fAi);let qxe=!1;function mAi(){if(!qxe){oG({name:"GoslingTrack",track:CF,config:CF.config}),oG({name:"Gosling2DTrack",track:CF,config:{...CF.config,type:"gosling-2d-track",orientation:"2d"}}),oG({name:"AxisTrack",track:UXe,config:UXe.config}),oG({name:"TextTrack",track:vre,config:vre.config}),oG({name:"BrushTrack",track:_re,config:_re.config});for(const e of Object.values(cAi)){const{config:i}=e;oG({dataFetcher:e,config:i},{pluginType:"dataFetcher"})}qxe=!0}}function dUe(e){let i=0,n=0;return e.forEach(r=>{const o=r.boundingBox.x+r.boundingBox.width,l=r.boundingBox.y+r.boundingBox.height;n{m.boundingBox.y+=u+f}),o=[{track:bAi({width:l.width,height:u},e.title,e.subtitle),boundingBox:{x:0,y:0,width:l.width,height:u},layout:{x:0,y:0,w:12,h:u/l.height*12}},...o]}else l.height=l.height+(8-l.height%8);const c=!(typeof e.responsiveSize!="object"?e.responsiveSize:e.responsiveSize.height);return o.forEach(u=>{u.layout.x=u.boundingBox.x/l.width*12,u.layout.w=u.boundingBox.width/l.width*12,u.layout.y=c?u.boundingBox.y:u.boundingBox.y/l.height*12,u.layout.h=c?u.boundingBox.height:u.boundingBox.height/l.height*12}),{trackInfos:o,size:l}}function sge(e,i,n=0,r=0,o=!0){let l=0,c=0,u=!0,f=!1;Mre(e,B=>{f=!0,B.layout!=="circular"&&(u=!1)});let m=!0;JLe(e,B=>{(B.arrangement==="vertical"||B.arrangement==="horizontal")&&(m=!1)});const p=o&&u&&f&&m&&("views"in e&&(e.arrangement==="parallel"||e.arrangement==="serial")||"tracks"in e),v=i.length;if("tracks"in e){const B=e.tracks;e.orientation==="vertical"?(c=Math.max(...B.map(G=>G.height)),B.forEach((G,T,V)=>{tDe([G])===1&&(G.width+=WC),G.height=c,i.push({track:G,boundingBox:{x:n+l,y:r,width:G.width,height:c},layout:{x:0,y:0,w:0,h:0}}),V[T+1]&&V[T+1].overlayOnPreviousTrack||(l+=G.width,T!==V.length-1&&(l+=e.spacing!==void 0?e.spacing:0))})):(l=Math.max(...B.map(G=>G.width)),B.forEach((G,T,V)=>{tDe([G])===1&&(G.height+=WC),CI(xu(G)[0])&&pAi([G])===1&&(l+=WC),G.width=l,i.push({track:G,boundingBox:{x:n,y:r+c,width:l,height:G.height},layout:{x:0,y:0,w:0,h:0}}),V[T+1]&&V[T+1].overlayOnPreviousTrack||(c+=G.height,T!==V.length-1&&(c+=e.spacing!==void 0?e.spacing:0))}))}else if(e.arrangement==="parallel"||e.arrangement==="vertical"){const B=e.spacing!==void 0?e.spacing:vY;e.views.forEach((G,T,V)=>{var E,W,x,k,F;const Y=sge(G,i,n+((E=G.xOffset)!=null?E:0),r+((W=G.yOffset)!=null?W:0)+c,!p&&o);l<((x=G.xOffset)!=null?x:0)+Y.width&&(l=((k=G.xOffset)!=null?k:0)+Y.width),T!==V.length-1&&(c+=B),c+=((F=G.yOffset)!=null?F:0)+Y.height})}else(e.arrangement==="serial"||e.arrangement==="horizontal")&&e.views.forEach((B,G,T)=>{var V,E,W,x,k;const F=e.spacing!==void 0?e.spacing:vY,Y=sge(B,i,n+((V=B.xOffset)!=null?V:0)+l,r+((E=B.yOffset)!=null?E:0),!p&&o);c<((W=B.xOffset)!=null?W:0)+Y.height&&(c=((x=B.xOffset)!=null?x:0)+Y.height),G!==T.length-1&&(l+=F),l+=((k=B.xOffset)!=null?k:0)+Y.width});if(p){const B=i.slice(v),G="views"in e&&(e.arrangement==="parallel"||e.arrangement==="serial")&&e.views.length>1,T=e.spacing!==void 0?e.spacing:vY,V=goi,E=e.centerRadius!==void 0?e.centerRadius:MLe,W=l/2+V,x=W*(1-E);B.forEach((k,F)=>{var Y,L;k.track.layout="circular",k.track.outerRadius=W-V-(k.boundingBox.y-r)/c*x,k.track.innerRadius=W-V-(k.boundingBox.y+k.boundingBox.height-r)/c*x;const O=T/l*360;k.track.startAngle=O+(k.boundingBox.x-n)/l*(l-T)/l*360,k.track.endAngle=(k.boundingBox.x+k.boundingBox.width-n)/l*(l-T)/l*360,k.boundingBox.x=n+((Y=k.track.xOffset)!=null?Y:0),k.boundingBox.y=r+((L=k.track.yOffset)!=null?L:0),k.boundingBox.height=k.track.height=k.boundingBox.width=k.track.width=W*2,F!==0&&(k.track.overlayOnPreviousTrack=!0),G&&To(k.track)&&(k.track.overlay=k.track.overlay.filter(Q=>Q.mark!=="brush"))}),c=W*2}return e._assignedWidth=l,e._assignedHeight=c,{x:n,y:r,width:l,height:c}}function tDe(e){return e.filter(i=>OK(i)).length}function pAi(e){return e.filter(i=>iai(i)).length}const bAi=(e,i,n)=>JSON.parse(JSON.stringify({mark:"header",width:e.width,height:e.height,title:i,subtitle:n}));function yAi(e){if(!e.includes("tileset_info/?d=")||!e.includes("https:")&&!e.includes("http:"))return{server:void 0,tilesetUid:void 0};const i=e.split("tileset_info/?d=")[0],n=e.split("tileset_info/?d=")[1];return{server:i,tilesetUid:n}}function vAi(e,i,n,r,o){var l,c,u,f,m,p,v,B,G,T,V,E,W,x;const k=xu(i)[0];k.id||(k.id=hA());const F=k.assembly;if(YXe(k.data)){let Y,L;if(LIe(k.data)){const de=yAi(k.data.url);Y=de.server,L=de.tilesetUid}const O=ole(k),Q=EJe(k),$=(Q==="x"||Q==="xe")&&Ii(O)?O.domain:void 0,ee=CI(k)&&Ii(k.y)?k.y.domain:void 0,ne=n.width-(k.layout!=="circular"&&k.orientation==="vertical"&&OK(k)?WC:0),ge=n.height-(k.layout!=="circular"&&k.orientation==="horizontal"&&OK(k)?WC:0),Ae={uid:`${k.id}-track`,type:CI(k)?"gosling-2d-track":"gosling-track",server:Y,tilesetUid:L,width:ne,height:ge,options:{showMousePosition:k.layout==="circular"?!1:o.root.showMousePosition,mousePositionColor:o.root.mousePositionColor,name:k.layout==="linear"?k.title:" ",labelPosition:k.title?o.track.titleAlign==="left"?"topLeft":"topRight":"none",labelShowResolution:!1,labelColor:o.track.titleColor,labelBackgroundColor:o.track.titleBackground,labelBackgroundOpacity:.5,labelTextOpacity:1,labelLeftMargin:1,labelTopMargin:1,labelRightMargin:0,labelBottomMargin:0,backgroundColor:"transparent",spec:{...i},theme:o}};if(k.data&&YXe(k.data)&&(k.data.type==="csv"||k.data.type==="json"||k.data.type==="bigwig"||k.data.type==="bam"||k.data.type==="vcf"||k.data.type==="bed")){const de=me=>{const be=k[me];return be&&Ii(be)?be.field:void 0},Ze={x:de("x"),xe:de("xe"),x1:de("x1"),x1e:de("x1e")};Ae.data={...k.data,...Ze,assembly:F}}if(Uoi(k)){Ae.type="heatmap";const de=Ii(k.color)&&typeof k.color.range=="string"?k.color.range:"viridis";Ae.options.colorRange=Foi(de),Ae.options.trackBorderWidth=(c=(l=k.style)==null?void 0:l.outlineWidth)!=null?c:o.track.outlineWidth,Ae.options.trackBorderColor=(f=(u=k.style)==null?void 0:u.outline)!=null?f:o.track.outline,Ae.options.extent=(p=(m=k.style)==null?void 0:m.matrixExtent)!=null?p:"full",Ae.options.colorbarPosition=(v=k.color)!=null&&v.legend?Ae.options.extent==="lower-left"?"bottomLeft":"topRight":"hidden"}k.overlayOnPreviousTrack?e.setViewOrientation(k.orientation).addTrackToCombined(Ae):e.setViewOrientation(k.orientation).setAssembly(F).addDefaultView(k.id,F).setDomain($,ee??$).adjustDomain(k.orientation,ne,ge).setMainTrack(Ae).addTrackSourceServers(Y).setZoomFixed(k.static===!0).setZoomLimits((B=k.zoomLimits)!=null?B:[1,null]).setLayout(r);const _=(de,Ze="horizontal",me,be)=>Ze==="horizontal"?de==="x"&&me<=200||de==="y"&&be<=200?"narrower":de==="x"&&me<=400||de==="y"&&be<=400?"narrow":"regular":de==="x"&&be<=200||de==="y"&&me<=200?"narrower":de==="x"&&be<=400||de==="y"&&me<=400?"narrow":"regular";["x","y"].forEach(de=>{const Ze=k[de];if(Ii(Ze)&&"axis"in Ze&&Ze.axis&&Ze.axis!=="none"&&Ze.type==="genomic"){const me=_(de,i.orientation,n.width,n.height);e.setAxisTrack(Ze.axis,me,{id:`${k.id}-${Ze.axis}-axis`,layout:k.layout,innerRadius:Ze.axis==="top"?k.outerRadius-WC:k.innerRadius,outerRadius:Ze.axis==="top"?k.outerRadius:k.innerRadius+WC,width:k.width,height:k.height,startAngle:k.startAngle,endAngle:k.endAngle,theme:o})}}),e.validateSpec(!0)}else k.mark==="header"&&(e.addDefaultView(`${k.id}-title`).setLayout(r),typeof k.title=="string"&&e.setTextTrack(n.width,((G=o.root.titleFontSize)!=null?G:18)+PK,k.title,o.root.titleColor,(T=o.root.titleFontSize)!=null?T:18,o.root.titleFontWeight,o.root.titleAlign,o.root.titleBackgroundColor,(V=o.root.titleFontFamily)!=null?V:xre.fontFamily),typeof k.subtitle=="string"&&e.setTextTrack(n.width,((E=o.root.subtitleFontSize)!=null?E:14)+PK,k.subtitle,o.root.subtitleColor,(W=o.root.subtitleFontSize)!=null?W:14,o.root.subtitleFontWeight,o.root.subtitleAlign,o.root.subtitleBackgroundColor,(x=o.root.subtitleFontFamily)!=null?x:xre.fontFamily));return e}function ZAi(e){const i=[];return e.spec().views.forEach(n=>{var r,o,l,c,u,f,m,p,v,B,G,T,V,E,W;const x=n.uid;let k=(u=(c=(l=(o=(r=n.tracks.center)==null?void 0:r[0])==null?void 0:o.contents)==null?void 0:l[0])==null?void 0:c.options)==null?void 0:u.spec;if(k||(k=(B=(v=(p=(m=(f=n.tracks.left)==null?void 0:f[0])==null?void 0:m.contents)==null?void 0:p[0])==null?void 0:v.options)==null?void 0:B.spec,k||(k=(W=(E=(V=(T=(G=n.tracks.left)==null?void 0:G[1])==null?void 0:T.contents)==null?void 0:V[0])==null?void 0:E.options)==null?void 0:W.spec)),!x||!k)return;xu(k).forEach(Y=>{Yy.forEach(L=>{var O,Q,X,$;const ee=Y[L];if(Ii(ee)&&"linkingId"in ee&&ee.linkingId){i.push({layout:Y.layout==="circular"?"circular":"linear",viewId:x,linkId:ee.linkingId,isBrush:Y.mark==="brush",style:{color:(O=Y.color)==null?void 0:O.value,stroke:(Q=Y.stroke)==null?void 0:Q.value,strokeWidth:(X=Y.strokeWidth)==null?void 0:X.value,opacity:($=Y.opacity)==null?void 0:$.value,startAngle:Y.startAngle,endAngle:Y.endAngle,innerRadius:Y.innerRadius,outerRadius:Y.outerRadius}});return}})})}),i}function BAi(e,i,n,r){if(i.length===0)return;const o=new dli;i.forEach(f=>{const{track:m,boundingBox:p,layout:v}=f;vAi(o,m,p,v,r)});const l=ZAi(o);l.filter(f=>f.isBrush).forEach(f=>{var m;o.addBrush(f.layout,f.viewId,r,(m=l.find(p=>!p.isBrush&&p.linkId===f.linkId))==null?void 0:m.viewId,f.style)}),l.filter(f=>!f.isBrush).forEach(f=>{o.spec().zoomLocks.locksByViewUid[f.viewId]=f.linkId,o.spec().locationLocks.locksByViewUid[f.viewId]=f.linkId}),Array.from(new Set(l.map(f=>f.linkId))).forEach(f=>{o.spec().zoomLocks.locksDict[f]={uid:f},o.spec().locationLocks.locksDict[f]={uid:f},l.filter(m=>!m.isBrush).filter(m=>m.linkId===f).forEach(m=>{o.spec().zoomLocks.locksDict[f][m.viewId]=[1246253105e-1,1246253105e-1,249250.621],o.spec().locationLocks.locksDict[f][m.viewId]=[1246253105e-1,1246253105e-1,249250.621]})});const u=i.map(f=>({id:f.track.id,spec:f.track,shape:f.track.layout==="linear"?f.boundingBox:{cx:f.boundingBox.x+f.boundingBox.width/2,cy:f.boundingBox.y+f.boundingBox.height/2,innerRadius:f.track.innerRadius,outerRadius:f.track.outerRadius,startAngle:f.track.startAngle,endAngle:f.track.endAngle}}));n(o.spec(),dUe(i),e,u)}function hUe(e,i,n,r,o){if(typeof e._assignedWidth>"u"||typeof e._assignedHeight>"u")return console.warn("Responsive spec cannot be used when width and height of a view is not determined yet."),!1;let l=!1;const{responsiveSpec:c}=e,u=e._assignedWidth*i,f=e._assignedHeight*n,m={width:u,height:f,aspectRatio:u/f},p={width:r,height:o,aspectRatio:r/o};return c&&c.forEach(v=>{const{spec:B,selectivity:G}=v;if(GAi(G,m,p)&&!l){Object.keys(B).forEach(T=>{e[T]=B[T]}),delete e.responsiveSpec,l=!0;return}}),"views"in e&&e.views.forEach(v=>{l=hUe(v,i,n,r,o)||l}),l}function GAi(e,i,n){if(e.length===0)return!1;let r=!0;return e.forEach(o=>{const{measure:l,operation:c,threshold:u,target:f}=o;r=r&&k9((f==="container"?n:i)[l],c,u)===1}),r}function SAi(e,i,n,r,o){var l,c;const u=JSON.parse(JSON.stringify(e));pai(u),yai(u,n),Fre(u);const f=eDe(u,r);let{trackInfos:m}=f;const{size:p}=f,v=typeof e.responsiveSize=="object"&&((l=e.responsiveSize)==null?void 0:l.width)||e.responsiveSize,B=typeof e.responsiveSize=="object"&&((c=e.responsiveSize)==null?void 0:c.height)||e.responsiveSize,G=v&&o.containerSize?o.containerSize.width/p.width:1,T=B&&o.containerSize?o.containerSize.height/p.height:1,V=o.containerParentSize?o.containerParentSize.width:Number.MAX_SAFE_INTEGER,E=o.containerParentSize?o.containerParentSize.height:Number.MAX_SAFE_INTEGER;hUe(u,G,T,V,E)&&(Fre(u),m=eDe(u,r).trackInfos),BAi(u,m,i,r)}mAi();const fUe=Ot.forwardRef((e,i)=>{var n;const[r,o]=Ot.useState((n=e.id)!=null?n:hA());Ot.useEffect(()=>{var G;o((G=e.id)!=null?G:hA())},[e.id]);const l=e.viewConfig||{},c=!1,u=Ot.useMemo(()=>yi.createElement($gi.HiGlassComponent,{ref:i,options:{pixelPreciseMarginPadding:c,containerPaddingX:0,containerPaddingY:0,viewMarginTop:0,viewMarginBottom:0,viewMarginLeft:0,viewMarginRight:0,viewPaddingTop:0,viewPaddingBottom:0,viewPaddingLeft:0,viewPaddingRight:0,sizeMode:"bounded",rangeSelectionOnAlt:!0},viewConfig:l}),[l,c]),{padding:f=60,margin:m=0,border:p="none",background:v,alt:B="Gosling visualization"}=e.options||{};return yi.createElement(yi.Fragment,null,yi.createElement("div",{id:r,className:`gosling-component ${e.className||""}`,style:{position:"relative",padding:f,margin:m,border:p,background:v,width:e.options.responsiveWidth?`calc(100% - ${f*2}px)`:e.size.width,height:e.options.responsiveHeight?`calc(100% - ${f*2}px)`:e.size.height,textAlign:"left"},"aria-label":B,role:"graphics-document","aria-roledescription":"visualization"},yi.createElement("div",{key:JSON.stringify(l),id:"higlass-wrapper",className:"higlass-wrapper",style:{position:"relative",display:"block",background:v,margin:0,padding:0,width:e.options.responsiveWidth?"100%":e.size.width,height:e.options.responsiveHeight?"100%":e.size.height}},u)))});fUe.displayName="HiGlassComponentWrapper";var mUe={exports:{}};(function(e,i){(function(n,r){e.exports=r()})(typeof window<"u"?window:Dp,function(){if(typeof window>"u")return null;var n=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")(),r=n.requestAnimationFrame||n.mozRequestAnimationFrame||n.webkitRequestAnimationFrame||function(p){return n.setTimeout(p,20)},o=n.cancelAnimationFrame||n.mozCancelAnimationFrame||n.webkitCancelAnimationFrame||function(p){n.clearTimeout(p)};function l(p,v){var B=Object.prototype.toString.call(p),G=B==="[object Array]"||B==="[object NodeList]"||B==="[object HTMLCollection]"||B==="[object Object]"||typeof jQuery<"u"&&p instanceof jQuery||typeof Elements<"u"&&p instanceof Elements,T=0,V=p.length;if(G)for(;T{n&&n.uid&&i(n)})}function TAi(e,i,n,r){const o=()=>[...n],l=u=>{const f=n.find(m=>m.id===u);return f||console.warn(`[getTrack()] Unable to find a track using the ID (${u})`),f},c=u=>{var f,m;const p=(f=u?.resolution)!=null?f:4,v=(m=u?.transparentBackground)!=null?m:!1,B=e.pixiRenderer,G=of.create({width:B.width/2,height:B.height/2,resolution:p});B.render(e.pixiStage,G);const T=B.plugins.extract.canvas(G),V=document.createElement("canvas");V.width=T.width,V.height=T.height;const E=V.getContext("2d");return v||(E.fillStyle=r.root.background,E.fillRect(0,0,V.width,V.height)),E.drawImage(T,0,0),{canvas:V,resolution:p,canvasWidth:T.width,canvasHeight:T.height}};return{subscribe:Xli,unsubscribe:xli,zoomTo:(u,f,m=0,p=1e3)=>{var v;const B=(v=l(u))==null?void 0:v.spec.assembly,T=QIe.fromString(f).toAbsoluteCoordinates(B,m);e.api.zoomTo(u,...T,...T,p)},zoomToExtent:(u,f=1e3)=>{var m;const p=(m=l(u))==null?void 0:m.spec.assembly,[v,B]=[0,Sg(p).total];e.api.zoomTo(u,v,B,v,B,f)},zoomToGene:(u,f,m=0,p=1e3)=>{e.api.zoomToGene(u,f,m,p)},suggestGene:(u,f,m)=>{e.api.suggestGene(u,f,m)},getViewIds:()=>{if(!i)return[];const u=[];return wAi(i,f=>{f.uid&&u.push(f.uid)}),u},getTracks:o,getTrack:l,getCanvas:c,exportPng:u=>{const{canvas:f}=c({resolution:4,transparentBackground:u});f.toBlob(m=>{const p=document.createElement("a");document.body.append(p),p.download="gosling-visualization",p.href=URL.createObjectURL(m),p.click(),p.remove()},"image/png")},exportPdf:async u=>{const{jsPDF:f}=await dLt(()=>import("./jspdf.es.min-b9cca550.js").then(B=>B.j),[]),{canvas:m}=c({resolution:4,transparentBackground:u}),p=m.toDataURL("image/jpeg",1),v=new f({orientation:m.width{OIe(n)&&i.forEach(r=>{delete n[r]})})}const RAi=300,o0=Ot.forwardRef((e,i)=>{var n,r,o;const[l,c]=Ot.useState(),[u,f]=Ot.useState({width:200,height:200}),m=Ot.useRef(),p=Ot.useRef(),v=Ot.useRef(),B=Ot.useRef([]),G=Ot.useRef(null),T=WJe(e.theme||"light"),V=(n=e.id)!=null?n:hA();Ot.useImperativeHandle(i,()=>{const k=rDe(G),F=rDe(B);return{api:TAi(k,l,F,T),hgApi:k}},[l,T]);const E=Ot.useCallback(()=>{if(e.spec){if(ali(e.spec).state==="error"){console.warn("Gosling spec is not valid. Please refer to the console message.");return}SAi(e.spec,(F,Y,L,O)=>{var Q,X;if(v.current&&tLe(nDe(v.current,["linkingId"]),nDe(L,["linkingId"])))return;(Q=e.compiled)==null||Q.call(e,e.spec,F),f(Y);const $=typeof l<"u";(X=e.experimental)!=null&&X.reactive&&$?setTimeout(()=>{var ee;(ee=G.current)==null||ee.api.setViewConfig(F)},RAi):c(F),v.current=L,B.current=O},[...bai],T,{containerSize:m.current,containerParentSize:p.current})}},[e.spec,T]);Ot.useEffect(()=>{const k=document.getElementById(V);if(!k)return;const F=new iDe(k,O=>{(!m.current||m.current.height!==O.height||m.current.width!==O.width)&&(m.current=O,E())}),Y=k.parentElement;if(!Y)return;const L=new iDe(Y,O=>{(!p.current||p.current.height!==O.height||p.current.width!==O.width)&&(p.current=O,E())});return()=>{F.detach(),L.detach()}}),Ot.useEffect(()=>{E()},[e.spec,T]);const W=typeof((r=e.spec)==null?void 0:r.responsiveSize)!="object"?(o=e.spec)==null?void 0:o.responsiveSize:e.spec.responsiveSize.height;return Ot.useMemo(()=>{var k,F,Y;return yi.createElement(fUe,{ref:G,viewConfig:l,size:u,id:V,className:e.className,options:{padding:e.padding,border:e.border,margin:e.margin,responsiveWidth:typeof((k=e.spec)==null?void 0:k.responsiveSize)!="object"?(F=e.spec)==null?void 0:F.responsiveSize:e.spec.responsiveSize.width,responsiveHeight:W,background:T.root.background,alt:(Y=e.spec)==null?void 0:Y.description}})},[l,u,T,W])});o0.displayName="GoslingComponent";function rDe(e){return new Proxy({},{get(i,n,r){if(!e.current)throw Error("ref is not set!");return Reflect.get(e.current,n,r)}})}var VAi=uOt;VAi.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function EAi(){return yi.createElement(yi.Fragment,null,yi.createElement(o0,{spec:{tracks:[{id:"heatmap-track",data:{url:"https://server.gosling-lang.org/api/v1/tileset_info/?d=cistrome-multivec",type:"multivec",row:"sample",column:"position",value:"peak",categories:["sample 1","sample 2","sample 3","sample 4"],binSize:4},mark:"rect",x:{field:"start",type:"genomic"},xe:{field:"end",type:"genomic"},row:{field:"sample",type:"nominal",legend:!0},color:{field:"peak",type:"quantitative",legend:!0,range:"pink"},width:600,height:130}]},experimental:{reactive:!0}}))}var pUe={exports:{}},HAi="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",WAi=HAi,NAi=WAi;function bUe(){}function yUe(){}yUe.resetWarningCache=bUe;var kAi=function(){function e(r,o,l,c,u,f){if(f!==NAi){var m=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw m.name="Invariant Violation",m}}e.isRequired=e;function i(){return e}var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:i,element:e,elementType:e,instanceOf:i,node:e,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:yUe,resetWarningCache:bUe};return n.PropTypes=n,n};pUe.exports=kAi();var XAi=pUe.exports;const gDe=Al(XAi),oDe={};function Ige(e,i){e===void 0&&(e=oDe),i===void 0&&(i=oDe);const n=Object.keys(e),r=Object.keys(i);return e===i||n.length===r.length&&n.every(o=>e[o]===i[o])}/*! - * https://github.com/Starcounter-Jack/JSON-Patch - * (c) 2017-2022 Joachim Wester - * MIT licensed - */var xAi=globalThis&&globalThis.__extends||function(){var e=function(i,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var l in o)o.hasOwnProperty(l)&&(r[l]=o[l])},e(i,n)};return function(i,n){e(i,n);function r(){this.constructor=i}i.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),DAi=Object.prototype.hasOwnProperty;function lge(e,i){return DAi.call(e,i)}function Cge(e){if(Array.isArray(e)){for(var i=new Array(e.length),n=0;n=48&&r<=57){i++;continue}return!1}return!0}function uy(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function vUe(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Age(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(var i=0,n=e.length;i0&&f[p-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(n&&B===void 0&&(m[G]===void 0?B=f.slice(0,p).join("/"):p==v-1&&(B=i.path),B!==void 0&&T(i,0,e,B)),p++,Array.isArray(m)){if(G==="-")G=m.length;else{if(n&&!cge(G))throw new ao("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",l,i,e);cge(G)&&(G=~~G)}if(p>=v){if(n&&i.op==="add"&&G>m.length)throw new ao("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",l,i,e);var c=FAi[i.op].call(i,m,G,e);if(c.test===!1)throw new ao("Test operation failed","TEST_OPERATION_FAILED",l,i,e);return c}}else if(p>=v){var c=zG[i.op].call(i,m,G,e);if(c.test===!1)throw new ao("Test operation failed","TEST_OPERATION_FAILED",l,i,e);return c}if(m=m[G],n&&p0)throw new ao('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",i,e,n);if((e.op==="move"||e.op==="copy")&&typeof e.from!="string")throw new ao("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",i,e,n);if((e.op==="add"||e.op==="replace"||e.op==="test")&&e.value===void 0)throw new ao("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",i,e,n);if((e.op==="add"||e.op==="replace"||e.op==="test")&&Age(e.value))throw new ao("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",i,e,n);if(n){if(e.op=="add"){var o=e.path.split("/").length,l=r.split("/").length;if(o!==l+1&&o!==l)throw new ao("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",i,e,n)}else if(e.op==="replace"||e.op==="remove"||e.op==="_get"){if(e.path!==r)throw new ao("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",i,e,n)}else if(e.op==="move"||e.op==="copy"){var c={op:"_get",path:e.from,value:void 0},u=BUe([c],n);if(u&&u.name==="OPERATION_PATH_UNRESOLVABLE")throw new ao("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",i,e,n)}}}else throw new ao("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",i,e,n)}function BUe(e,i,n){try{if(!Array.isArray(e))throw new ao("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(i)JP(Fl(i),Fl(e),n||!0);else{n=n||o3;for(var r=0;r0&&(e.patches=[],e.callback&&e.callback(r)),r}function ble(e,i,n,r,o){if(i!==e){typeof i.toJSON=="function"&&(i=i.toJSON());for(var l=Cge(i),c=Cge(e),u=!1,f=c.length-1;f>=0;f--){var m=c[f],p=e[m];if(lge(i,m)&&!(i[m]===void 0&&p!==void 0&&Array.isArray(i)===!1)){var v=i[m];typeof p=="object"&&p!=null&&typeof v=="object"&&v!=null&&Array.isArray(p)===Array.isArray(v)?ble(p,v,n,r+"/"+uy(m),o):p!==v&&(o&&n.push({op:"test",path:r+"/"+uy(m),value:Fl(p)}),n.push({op:"replace",path:r+"/"+uy(m),value:Fl(v)}))}else Array.isArray(e)===Array.isArray(i)?(o&&n.push({op:"test",path:r+"/"+uy(m),value:Fl(p)}),n.push({op:"remove",path:r+"/"+uy(m)}),u=!0):(o&&n.push({op:"test",path:r,value:e}),n.push({op:"replace",path:r,value:i}))}if(!(!u&&l.length==c.length))for(var f=0;f0)return[k,r+B.join(`, -`+W),p].join(` -`+f)}return F}(i,"",0)};const kee=Al(qAi);function dl(e,i,n){return e.fields=i||[],e.fname=n,e}function co(e){return e==null?null:e.fname}function ws(e){return e==null?null:e.fields}function GUe(e){return e.length===1?eui(e[0]):tui(e)}const eui=e=>function(i){return i[e]},tui=e=>{const i=e.length;return function(n){for(let r=0;rc?m():c=u+1:f==="["?(u>c&&m(),o=c=u+1):f==="]"&&(o||Yt("Access path missing open bracket: "+e),o>0&&m(),o=0,c=u+1)}return o&&Yt("Access path missing closing bracket: "+e),r&&Yt("Access path missing closing quote: "+e),u>c&&(u++,m()),i}function ol(e,i,n){const r=vd(e);return e=r.length===1?r[0]:e,dl((n&&n.get||GUe)(r),[e],i||e)}const HW=ol("id"),Hs=dl(e=>e,[],"identity"),Qm=dl(()=>0,[],"zero"),kw=dl(()=>1,[],"one"),OC=dl(()=>!0,[],"true"),Dm=dl(()=>!1,[],"false");function iui(e,i,n){const r=[i].concat([].slice.call(n));console[e].apply(console,r)}const SUe=0,yle=1,vle=2,wUe=3,TUe=4;function Zle(e,i){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:iui,r=e||SUe;return{level(o){return arguments.length?(r=+o,this):r},error(){return r>=yle&&n(i||"error","ERROR",arguments),this},warn(){return r>=vle&&n(i||"warn","WARN",arguments),this},info(){return r>=wUe&&n(i||"log","INFO",arguments),this},debug(){return r>=TUe&&n(i||"log","DEBUG",arguments),this}}}var Pt=Array.isArray;function vi(e){return e===Object(e)}const sDe=e=>e!=="__proto__";function Xw(){for(var e=arguments.length,i=new Array(e),n=0;n{for(const l in o)if(l==="signals")r.signals=nui(r.signals,o.signals);else{const c=l==="legend"?{layout:1}:l==="style"?!0:null;xw(r,l,o[l],c)}return r},{})}function xw(e,i,n,r){if(!sDe(i))return;let o,l;if(vi(n)&&!Pt(n)){l=vi(e[i])?e[i]:e[i]={};for(o in n)r&&(r===!0||r[o])?xw(l,o,n[o]):sDe(o)&&(l[o]=n[o])}else e[i]=n}function nui(e,i){if(e==null)return i;const n={},r=[];function o(l){n[l.name]||(n[l.name]=1,r.push(l))}return i.forEach(o),e.forEach(o),r}function sr(e){return e[e.length-1]}function Zs(e){return e==null||e===""?null:+e}const RUe=e=>i=>e*Math.exp(i),VUe=e=>i=>Math.log(e*i),EUe=e=>i=>Math.sign(i)*Math.log1p(Math.abs(i/e)),HUe=e=>i=>Math.sign(i)*Math.expm1(Math.abs(i))*e,a3=e=>i=>i<0?-Math.pow(-i,e):Math.pow(i,e);function UP(e,i,n,r){const o=n(e[0]),l=n(sr(e)),c=(l-o)*i;return[r(o-c),r(l-c)]}function WUe(e,i){return UP(e,i,Zs,Hs)}function NUe(e,i){var n=Math.sign(e[0]);return UP(e,i,VUe(n),RUe(n))}function kUe(e,i,n){return UP(e,i,a3(n),a3(1/n))}function XUe(e,i,n){return UP(e,i,EUe(n),HUe(n))}function QP(e,i,n,r,o){const l=r(e[0]),c=r(sr(e)),u=i!=null?r(i):(l+c)/2;return[o(u+(l-u)*n),o(u+(c-u)*n)]}function Ble(e,i,n){return QP(e,i,n,Zs,Hs)}function Gle(e,i,n){const r=Math.sign(e[0]);return QP(e,i,n,VUe(r),RUe(r))}function s3(e,i,n,r){return QP(e,i,n,a3(r),a3(1/r))}function Sle(e,i,n,r){return QP(e,i,n,EUe(r),HUe(r))}function xUe(e){return 1+~~(new Date(e).getMonth()/3)}function DUe(e){return 1+~~(new Date(e).getUTCMonth()/3)}function pi(e){return e!=null?Pt(e)?e:[e]:[]}function MUe(e,i,n){let r=e[0],o=e[1],l;return o=n-i?[i,n]:[r=Math.min(Math.max(r,i),n-l),r+l]}function Rn(e){return typeof e=="function"}const rui="descending";function wle(e,i,n){n=n||{},i=pi(i)||[];const r=[],o=[],l={},c=n.comparator||gui;return pi(e).forEach((u,f)=>{u!=null&&(r.push(i[f]===rui?-1:1),o.push(u=Rn(u)?u:ol(u,null,n)),(ws(u)||[]).forEach(m=>l[m]=1))}),o.length===0?null:dl(c(o,r),Object.keys(l))}const jP=(e,i)=>(ei||i==null)&&e!=null?1:(i=i instanceof Date?+i:i,(e=e instanceof Date?+e:e)!==e&&i===i?-1:i!==i&&e===e?1:0),gui=(e,i)=>e.length===1?oui(e[0],i[0]):aui(e,i,e.length),oui=(e,i)=>function(n,r){return jP(e(n),e(r))*i},aui=(e,i,n)=>(i.push(0),function(r,o){let l,c=0,u=-1;for(;c===0&&++ue}function Tle(e,i){let n;return r=>{n&&clearTimeout(n),n=setTimeout(()=>(i(r),n=null),e)}}function Tn(e){for(let i,n,r=1,o=arguments.length;rc&&(c=o))}else{for(o=i(e[n]);nc&&(c=o))}return[l,c]}function FUe(e,i){const n=e.length;let r=-1,o,l,c,u,f;if(i==null){for(;++r=l){o=c=l;break}if(r===n)return[-1,-1];for(u=f=r;++rl&&(o=l,u=r),c=l){o=c=l;break}if(r===n)return[-1,-1];for(u=f=r;++rl&&(o=l,u=r),c{o.set(l,e[l])}),o}function YUe(e,i,n,r,o,l){if(!n&&n!==0)return l;const c=+n;let u=e[0],f=sr(e),m;fl&&(c=o,o=l,l=c),n=n===void 0||n,r=r===void 0||r,(n?o<=e:ou.replace(/\\(.)/g,"$1")):pi(e));const r=e&&e.length,o=n&&n.get||GUe,l=u=>o(i?[u]:vd(u));let c;if(!r)c=function(){return""};else if(r===1){const u=l(e[0]);c=function(f){return""+u(f)}}else{const u=e.map(l);c=function(f){let m=""+u[0](f),p=0;for(;++p{i={},n={},r=0},l=(c,u)=>(++r>e&&(n=i,i={},r=1),i[c]=u);return o(),{clear:o,has:c=>Oi(i,c)||Oi(n,c),get:c=>Oi(i,c)?i[c]:Oi(n,c)?l(c,n[c]):void 0,set:(c,u)=>Oi(i,c)?i[c]=u:l(c,u)}}function OUe(e,i,n,r){const o=i.length,l=n.length;if(!l)return i;if(!o)return n;const c=r||new i.constructor(o+l);let u=0,f=0,m=0;for(;u0?n[f++]:i[u++];for(;u=0;)n+=e;return n}function LUe(e,i,n,r){const o=n||" ",l=e+"",c=i-l.length;return c<=0?l:r==="left"?x9(o,c)+l:r==="center"?x9(o,~~(c/2))+l+x9(o,Math.ceil(c/2)):l+x9(o,c)}function WW(e){return e&&sr(e)-e[0]||0}function ai(e){return Pt(e)?"["+e.map(ai)+"]":vi(e)||fi(e)?JSON.stringify(e).replace("\u2028","\\u2028").replace("\u2029","\\u2029"):e}function Vle(e){return e==null||e===""?null:!e||e==="false"||e==="0"?!1:!!e}const lui=e=>jr(e)||Sp(e)?e:Date.parse(e);function Ele(e,i){return i=i||lui,e==null||e===""?null:i(e)}function Hle(e){return e==null||e===""?null:e+""}function BA(e){const i={},n=e.length;for(let r=0;r9999?"+"+FI(e,6):FI(e,4)}function Aui(e){var i=e.getUTCHours(),n=e.getUTCMinutes(),r=e.getUTCSeconds(),o=e.getUTCMilliseconds();return isNaN(e)?"Invalid Date":cui(e.getUTCFullYear())+"-"+FI(e.getUTCMonth()+1,2)+"-"+FI(e.getUTCDate(),2)+(o?"T"+FI(i,2)+":"+FI(n,2)+":"+FI(r,2)+"."+FI(o,3)+"Z":r?"T"+FI(i,2)+":"+FI(n,2)+":"+FI(r,2)+"Z":n||i?"T"+FI(i,2)+":"+FI(n,2)+"Z":"")}function uui(e){var i=new RegExp('["'+e+` -\r]`),n=e.charCodeAt(0);function r(v,B){var G,T,V=o(v,function(E,W){if(G)return G(E,W-1);T=E,G=B?Cui(E,B):UUe(E)});return V.columns=T||[],V}function o(v,B){var G=[],T=v.length,V=0,E=0,W,x=T<=0,k=!1;v.charCodeAt(T-1)===jV&&--T,v.charCodeAt(T-1)===Dee&&--T;function F(){if(x)return Xee;if(k)return k=!1,IDe;var L,O=V,Q;if(v.charCodeAt(O)===xee){for(;V++=T?x=!0:(Q=v.charCodeAt(V++))===jV?k=!0:Q===Dee&&(k=!0,v.charCodeAt(V)===jV&&++V),v.slice(O+1,L-1).replace(/""/g,'"')}for(;V1)r=vui(e,i,n);else for(o=0,r=new Array(l=e.arcs.length);oi?1:e>=i?0:NaN}function Zui(e,i){return e==null||i==null?NaN:ie?1:i>=e?0:NaN}function NW(e){let i,n,r;e.length!==2?(i=Oh,n=(u,f)=>Oh(e(u),f),r=(u,f)=>e(u)-f):(i=e===Oh||e===Zui?e:Bui,n=e,r=e);function o(u,f,m=0,p=u.length){if(m>>1;n(u[v],f)<0?m=v+1:p=v}while(m>>1;n(u[v],f)<=0?m=v+1:p=v}while(mm&&r(u[v-1],f)>-r(u[v],f)?v-1:v}return{left:o,center:c,right:l}}function Bui(){return 0}function jUe(e){return e===null?NaN:+e}function*Gui(e,i){if(i===void 0)for(let n of e)n!=null&&(n=+n)>=n&&(yield n);else{let n=-1;for(let r of e)(r=i(r,++n,e))!=null&&(r=+r)>=r&&(yield r)}}const $Ue=NW(Oh),I3=$Ue.right,Sui=$Ue.left;NW(jUe).center;const kW=I3;function wui(e,i){let n=0,r,o=0,l=0;if(i===void 0)for(let c of e)c!=null&&(c=+c)>=c&&(r=c-o,o+=r/++n,l+=r*(c-o));else{let c=-1;for(let u of e)(u=i(u,++c,e))!=null&&(u=+u)>=u&&(r=u-o,o+=r/++n,l+=r*(u-o))}if(n>1)return l/(n-1)}function Tui(e,i){const n=wui(e,i);return n&&Math.sqrt(n)}class uI{constructor(){this._partials=new Float64Array(32),this._n=0}add(i){const n=this._partials;let r=0;for(let o=0;o0){for(c=i[--n];n>0&&(r=c,o=i[--n],c=r+o,l=o-(c-r),!l););n>0&&(l<0&&i[n-1]<0||l>0&&i[n-1]>0)&&(o=l*2,r=c+o,o==r-c&&(c=r))}return c}}class cDe extends Map{constructor(i,n=t7e){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),i!=null)for(const[r,o]of i)this.set(r,o)}get(i){return super.get(dge(this,i))}has(i){return super.has(dge(this,i))}set(i,n){return super.set(qUe(this,i),n)}delete(i){return super.delete(e7e(this,i))}}class l3 extends Set{constructor(i,n=t7e){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),i!=null)for(const r of i)this.add(r)}has(i){return super.has(dge(this,i))}add(i){return super.add(qUe(this,i))}delete(i){return super.delete(e7e(this,i))}}function dge({_intern:e,_key:i},n){const r=i(n);return e.has(r)?e.get(r):n}function qUe({_intern:e,_key:i},n){const r=i(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function e7e({_intern:e,_key:i},n){const r=i(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function t7e(e){return e!==null&&typeof e=="object"?e.valueOf():e}function Rui(e,i){return Array.from(i,n=>e[n])}function Vui(e=Oh){if(e===Oh)return i7e;if(typeof e!="function")throw new TypeError("compare is not a function");return(i,n)=>{const r=e(i,n);return r||r===0?r:(e(n,n)===0)-(e(i,i)===0)}}function i7e(e,i){return(e==null||!(e>=e))-(i==null||!(i>=i))||(ei?1:0)}const Eui=Math.sqrt(50),Hui=Math.sqrt(10),Wui=Math.sqrt(2);function C3(e,i,n){const r=(i-e)/Math.max(0,n),o=Math.floor(Math.log10(r)),l=r/Math.pow(10,o),c=l>=Eui?10:l>=Hui?5:l>=Wui?2:1;let u,f,m;return o<0?(m=Math.pow(10,-o)/c,u=Math.round(e*m),f=Math.round(i*m),u/mi&&--f,m=-m):(m=Math.pow(10,o)*c,u=Math.round(e/m),f=Math.round(i/m),u*mi&&--f),f0))return[];if(e===i)return[e];const r=i=o))return[];const u=l-o+1,f=new Array(u);if(r)if(c<0)for(let m=0;m=r)&&(n=r);else{let r=-1;for(let o of e)(o=i(o,++r,e))!=null&&(n=o)&&(n=o)}return n}function mge(e,i){let n;if(i===void 0)for(const r of e)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let o of e)(o=i(o,++r,e))!=null&&(n>o||n===void 0&&o>=o)&&(n=o)}return n}function n7e(e,i,n=0,r=1/0,o){if(i=Math.floor(i),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(e.length-1,r)),!(n<=i&&i<=r))return e;for(o=o===void 0?i7e:Vui(o);r>n;){if(r-n>600){const f=r-n+1,m=i-n+1,p=Math.log(f),v=.5*Math.exp(2*p/3),B=.5*Math.sqrt(p*v*(f-v)/f)*(m-f/2<0?-1:1),G=Math.max(n,Math.floor(i-m*v/f+B)),T=Math.min(r,Math.floor(i+(f-m)*v/f+B));n7e(e,i,G,T,o)}const l=e[i];let c=n,u=r;for($V(e,n,i),o(e[r],l)>0&&$V(e,n,r);c0;)--u}o(e[n],l)===0?$V(e,n,u):(++u,$V(e,u,r)),u<=i&&(n=u+1),i<=u&&(r=u-1)}return e}function $V(e,i,n){const r=e[i];e[i]=e[n],e[n]=r}function pge(e,i,n){if(e=Float64Array.from(Gui(e,n)),!(!(r=e.length)||isNaN(i=+i))){if(i<=0||r<2)return mge(e);if(i>=1)return Py(e);var r,o=(r-1)*i,l=Math.floor(o),c=Py(n7e(e,l).subarray(0,l+1)),u=mge(e.subarray(l+1));return c+(u-c)*(o-l)}}function r7e(e,i,n=jUe){if(!(!(r=e.length)||isNaN(i=+i))){if(i<=0||r<2)return+n(e[0],0,e);if(i>=1)return+n(e[r-1],r-1,e);var r,o=(r-1)*i,l=Math.floor(o),c=+n(e[l],l,e),u=+n(e[l+1],l+1,e);return c+(u-c)*(o-l)}}function Nui(e,i){let n=0,r=0;if(i===void 0)for(let o of e)o!=null&&(o=+o)>=o&&(++n,r+=o);else{let o=-1;for(let l of e)(l=i(l,++o,e))!=null&&(l=+l)>=l&&(++n,r+=l)}if(n)return r/n}function g7e(e,i){return pge(e,.5,i)}function*kui(e){for(const i of e)yield*i}function o7e(e){return Array.from(kui(e))}function Yl(e,i,n){e=+e,i=+i,n=(o=arguments.length)<2?(i=e,e=0,1):o<3?1:+n;for(var r=-1,o=Math.max(0,Math.ceil((i-e)/n))|0,l=new Array(o);++r=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function c3(e,i){if((n=(e=i?e.toExponential(i-1):e.toExponential()).indexOf("e"))<0)return null;var n,r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function YS(e){return e=c3(Math.abs(e)),e?e[1]:NaN}function xui(e,i){return function(n,r){for(var o=n.length,l=[],c=0,u=e[0],f=0;o>0&&u>0&&(f+u+1>r&&(u=Math.max(1,r-f)),l.push(n.substring(o-=u,o+u)),!((f+=u+1)>r));)u=e[c=(c+1)%e.length];return l.reverse().join(i)}}function Dui(e){return function(i){return i.replace(/[0-9]/g,function(n){return e[+n]})}}var Mui=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function RH(e){if(!(i=Mui.exec(e)))throw new Error("invalid format: "+e);var i;return new Wle({fill:i[1],align:i[2],sign:i[3],symbol:i[4],zero:i[5],width:i[6],comma:i[7],precision:i[8]&&i[8].slice(1),trim:i[9],type:i[10]})}RH.prototype=Wle.prototype;function Wle(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}Wle.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Fui(e){e:for(var i=e.length,n=1,r=-1,o;n0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(o+1):e}var s7e;function Yui(e,i){var n=c3(e,i);if(!n)return e+"";var r=n[0],o=n[1],l=o-(s7e=Math.max(-8,Math.min(8,Math.floor(o/3)))*3)+1,c=r.length;return l===c?r:l>c?r+new Array(l-c+1).join("0"):l>0?r.slice(0,l)+"."+r.slice(l):"0."+new Array(1-l).join("0")+c3(e,Math.max(0,i+l-1))[0]}function ADe(e,i){var n=c3(e,i);if(!n)return e+"";var r=n[0],o=n[1];return o<0?"0."+new Array(-o).join("0")+r:r.length>o+1?r.slice(0,o+1)+"."+r.slice(o+1):r+new Array(o-r.length+2).join("0")}const uDe={"%":(e,i)=>(e*100).toFixed(i),b:e=>Math.round(e).toString(2),c:e=>e+"",d:Xui,e:(e,i)=>e.toExponential(i),f:(e,i)=>e.toFixed(i),g:(e,i)=>e.toPrecision(i),o:e=>Math.round(e).toString(8),p:(e,i)=>ADe(e*100,i),r:ADe,s:Yui,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function dDe(e){return e}var hDe=Array.prototype.map,fDe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function I7e(e){var i=e.grouping===void 0||e.thousands===void 0?dDe:xui(hDe.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",r=e.currency===void 0?"":e.currency[1]+"",o=e.decimal===void 0?".":e.decimal+"",l=e.numerals===void 0?dDe:Dui(hDe.call(e.numerals,String)),c=e.percent===void 0?"%":e.percent+"",u=e.minus===void 0?"−":e.minus+"",f=e.nan===void 0?"NaN":e.nan+"";function m(v){v=RH(v);var B=v.fill,G=v.align,T=v.sign,V=v.symbol,E=v.zero,W=v.width,x=v.comma,k=v.precision,F=v.trim,Y=v.type;Y==="n"?(x=!0,Y="g"):uDe[Y]||(k===void 0&&(k=12),F=!0,Y="g"),(E||B==="0"&&G==="=")&&(E=!0,B="0",G="=");var L=V==="$"?n:V==="#"&&/[boxX]/.test(Y)?"0"+Y.toLowerCase():"",O=V==="$"?r:/[%p]/.test(Y)?c:"",Q=uDe[Y],X=/[defgprs%]/.test(Y);k=k===void 0?6:/[gprs]/.test(Y)?Math.max(1,Math.min(21,k)):Math.max(0,Math.min(20,k));function $(ee){var ne=L,ge=O,Ae,_,de;if(Y==="c")ge=Q(ee)+ge,ee="";else{ee=+ee;var Ze=ee<0||1/ee<0;if(ee=isNaN(ee)?f:Q(Math.abs(ee),k),F&&(ee=Fui(ee)),Ze&&+ee==0&&T!=="+"&&(Ze=!1),ne=(Ze?T==="("?T:u:T==="-"||T==="("?"":T)+ne,ge=(Y==="s"?fDe[8+s7e/3]:"")+ge+(Ze&&T==="("?")":""),X){for(Ae=-1,_=ee.length;++Ae<_;)if(de=ee.charCodeAt(Ae),48>de||de>57){ge=(de===46?o+ee.slice(Ae+1):ee.slice(Ae))+ge,ee=ee.slice(0,Ae);break}}}x&&!E&&(ee=i(ee,1/0));var me=ne.length+ee.length+ge.length,be=me>1)+ne+ee+ge+be.slice(me);break;default:ee=be+ne+ee+ge;break}return l(ee)}return $.toString=function(){return v+""},$}function p(v,B){var G=m((v=RH(v),v.type="f",v)),T=Math.max(-8,Math.min(8,Math.floor(YS(B)/3)))*3,V=Math.pow(10,-T),E=fDe[8+T/3];return function(W){return G(V*W)+E}}return{format:m,formatPrefix:p}}var AF,l7e,C7e;Kui({thousands:",",grouping:[3],currency:["$",""]});function Kui(e){return AF=I7e(e),l7e=AF.format,C7e=AF.formatPrefix,AF}function _ui(e){return Math.max(0,-YS(Math.abs(e)))}function Pui(e,i){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(YS(i)/3)))*3-YS(Math.abs(e)))}function zui(e,i){return e=Math.abs(e),i=Math.abs(i)-e,Math.max(0,YS(i)-YS(e))+1}const Mee=new Date,Fee=new Date;function Qo(e,i,n,r){function o(l){return e(l=arguments.length===0?new Date:new Date(+l)),l}return o.floor=l=>(e(l=new Date(+l)),l),o.ceil=l=>(e(l=new Date(l-1)),i(l,1),e(l),l),o.round=l=>{const c=o(l),u=o.ceil(l);return l-c(i(l=new Date(+l),c==null?1:Math.floor(c)),l),o.range=(l,c,u)=>{const f=[];if(l=o.ceil(l),u=u==null?1:Math.floor(u),!(l0))return f;let m;do f.push(m=new Date(+l)),i(l,u),e(l);while(mQo(c=>{if(c>=c)for(;e(c),!l(c);)c.setTime(c-1)},(c,u)=>{if(c>=c)if(u<0)for(;++u<=0;)for(;i(c,-1),!l(c););else for(;--u>=0;)for(;i(c,1),!l(c););}),n&&(o.count=(l,c)=>(Mee.setTime(+l),Fee.setTime(+c),e(Mee),e(Fee),Math.floor(n(Mee,Fee))),o.every=l=>(l=Math.floor(l),!isFinite(l)||!(l>0)?null:l>1?o.filter(r?c=>r(c)%l===0:c=>o.count(0,c)%l===0):o)),o}const KS=Qo(()=>{},(e,i)=>{e.setTime(+e+i)},(e,i)=>i-e);KS.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?Qo(i=>{i.setTime(Math.floor(i/e)*e)},(i,n)=>{i.setTime(+i+n*e)},(i,n)=>(n-i)/e):KS);KS.range;const Xh=1e3,NC=Xh*60,xh=NC*60,lf=xh*24,Nle=lf*7,mDe=lf*30,Yee=lf*365,Dh=Qo(e=>{e.setTime(e-e.getMilliseconds())},(e,i)=>{e.setTime(+e+i*Xh)},(e,i)=>(i-e)/Xh,e=>e.getUTCSeconds());Dh.range;const $P=Qo(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Xh)},(e,i)=>{e.setTime(+e+i*NC)},(e,i)=>(i-e)/NC,e=>e.getMinutes());$P.range;const qP=Qo(e=>{e.setUTCSeconds(0,0)},(e,i)=>{e.setTime(+e+i*NC)},(e,i)=>(i-e)/NC,e=>e.getUTCMinutes());qP.range;const ez=Qo(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Xh-e.getMinutes()*NC)},(e,i)=>{e.setTime(+e+i*xh)},(e,i)=>(i-e)/xh,e=>e.getHours());ez.range;const tz=Qo(e=>{e.setUTCMinutes(0,0,0)},(e,i)=>{e.setTime(+e+i*xh)},(e,i)=>(i-e)/xh,e=>e.getUTCHours());tz.range;const Lh=Qo(e=>e.setHours(0,0,0,0),(e,i)=>e.setDate(e.getDate()+i),(e,i)=>(i-e-(i.getTimezoneOffset()-e.getTimezoneOffset())*NC)/lf,e=>e.getDate()-1);Lh.range;const wp=Qo(e=>{e.setUTCHours(0,0,0,0)},(e,i)=>{e.setUTCDate(e.getUTCDate()+i)},(e,i)=>(i-e)/lf,e=>e.getUTCDate()-1);wp.range;const c7e=Qo(e=>{e.setUTCHours(0,0,0,0)},(e,i)=>{e.setUTCDate(e.getUTCDate()+i)},(e,i)=>(i-e)/lf,e=>Math.floor(e/lf));c7e.range;function qv(e){return Qo(i=>{i.setDate(i.getDate()-(i.getDay()+7-e)%7),i.setHours(0,0,0,0)},(i,n)=>{i.setDate(i.getDate()+n*7)},(i,n)=>(n-i-(n.getTimezoneOffset()-i.getTimezoneOffset())*NC)/Nle)}const Mw=qv(0),A3=qv(1),Oui=qv(2),Lui=qv(3),_S=qv(4),Jui=qv(5),Uui=qv(6);Mw.range;A3.range;Oui.range;Lui.range;_S.range;Jui.range;Uui.range;function eZ(e){return Qo(i=>{i.setUTCDate(i.getUTCDate()-(i.getUTCDay()+7-e)%7),i.setUTCHours(0,0,0,0)},(i,n)=>{i.setUTCDate(i.getUTCDate()+n*7)},(i,n)=>(n-i)/Nle)}const Fw=eZ(0),u3=eZ(1),Qui=eZ(2),jui=eZ(3),PS=eZ(4),$ui=eZ(5),qui=eZ(6);Fw.range;u3.range;Qui.range;jui.range;PS.range;$ui.range;qui.range;const VH=Qo(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,i)=>{e.setMonth(e.getMonth()+i)},(e,i)=>i.getMonth()-e.getMonth()+(i.getFullYear()-e.getFullYear())*12,e=>e.getMonth());VH.range;const EH=Qo(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,i)=>{e.setUTCMonth(e.getUTCMonth()+i)},(e,i)=>i.getUTCMonth()-e.getUTCMonth()+(i.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());EH.range;const cd=Qo(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,i)=>{e.setFullYear(e.getFullYear()+i)},(e,i)=>i.getFullYear()-e.getFullYear(),e=>e.getFullYear());cd.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Qo(i=>{i.setFullYear(Math.floor(i.getFullYear()/e)*e),i.setMonth(0,1),i.setHours(0,0,0,0)},(i,n)=>{i.setFullYear(i.getFullYear()+n*e)});cd.range;const Ad=Qo(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,i)=>{e.setUTCFullYear(e.getUTCFullYear()+i)},(e,i)=>i.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());Ad.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Qo(i=>{i.setUTCFullYear(Math.floor(i.getUTCFullYear()/e)*e),i.setUTCMonth(0,1),i.setUTCHours(0,0,0,0)},(i,n)=>{i.setUTCFullYear(i.getUTCFullYear()+n*e)});Ad.range;function A7e(e,i,n,r,o,l){const c=[[Dh,1,Xh],[Dh,5,5*Xh],[Dh,15,15*Xh],[Dh,30,30*Xh],[l,1,NC],[l,5,5*NC],[l,15,15*NC],[l,30,30*NC],[o,1,xh],[o,3,3*xh],[o,6,6*xh],[o,12,12*xh],[r,1,lf],[r,2,2*lf],[n,1,Nle],[i,1,mDe],[i,3,3*mDe],[e,1,Yee]];function u(m,p,v){const B=pE).right(c,B);if(G===c.length)return e.every(Mp(m/Yee,p/Yee,v));if(G===0)return KS.every(Math.max(Mp(m,p,v),1));const[T,V]=c[B/c[G-1][2](e[i]=1+n,e),{});function Xle(e){const i=pi(e).slice(),n={};return i.length||Yt("Missing time unit."),i.forEach(o=>{Oi(Kee,o)?n[o]=1:Yt(`Invalid time unit: ${o}.`)}),(n[Lo]||n[vs]?1:0)+(n[al]||n[Ts]||n[sl]?1:0)+(n[ud]?1:0)>1&&Yt(`Incompatible time units: ${e}`),i.sort((o,l)=>Kee[o]-Kee[l]),i}const rdi={[xa]:"%Y ",[al]:"Q%q ",[Ts]:"%b ",[sl]:"%d ",[Lo]:"W%U ",[vs]:"%a ",[ud]:"%j ",[zl]:"%H:00",[Ol]:"00:%M",[LC]:":%S",[GA]:".%L",[`${xa}-${Ts}`]:"%Y-%m ",[`${xa}-${Ts}-${sl}`]:"%Y-%m-%d ",[`${zl}-${Ol}`]:"%H:%M"};function u7e(e,i){const n=Tn({},rdi,i),r=Xle(e),o=r.length;let l="",c=0,u,f;for(c=0;cc;--u)if(f=r.slice(c,u).join("-"),n[f]!=null){l+=n[f],c=u;break}return l.trim()}const fy=new Date;function xle(e){return fy.setFullYear(e),fy.setMonth(0),fy.setDate(1),fy.setHours(0,0,0,0),fy}function d7e(e){return f7e(new Date(e))}function h7e(e){return bge(new Date(e))}function f7e(e){return Lh.count(xle(e.getFullYear())-1,e)}function bge(e){return Mw.count(xle(e.getFullYear())-1,e)}function yge(e){return xle(e).getDay()}function gdi(e,i,n,r,o,l,c){if(0<=e&&e<100){const u=new Date(-1,i,n,r,o,l,c);return u.setFullYear(e),u}return new Date(e,i,n,r,o,l,c)}function m7e(e){return b7e(new Date(e))}function p7e(e){return vge(new Date(e))}function b7e(e){const i=Date.UTC(e.getUTCFullYear(),0,1);return wp.count(i-1,e)}function vge(e){const i=Date.UTC(e.getUTCFullYear(),0,1);return Fw.count(i-1,e)}function Zge(e){return fy.setTime(Date.UTC(e,0,1)),fy.getUTCDay()}function odi(e,i,n,r,o,l,c){if(0<=e&&e<100){const u=new Date(Date.UTC(-1,i,n,r,o,l,c));return u.setUTCFullYear(n.y),u}return new Date(Date.UTC(e,i,n,r,o,l,c))}function y7e(e,i,n,r,o){const l=i||1,c=sr(e),u=(W,x,k)=>(k=k||W,adi(n[k],r[k],W===c&&l,x)),f=new Date,m=BA(e),p=m[xa]?u(xa):Ws(2012),v=m[Ts]?u(Ts):m[al]?u(al):Qm,B=m[Lo]&&m[vs]?u(vs,1,Lo+vs):m[Lo]?u(Lo,1):m[vs]?u(vs,1):m[sl]?u(sl,1):m[ud]?u(ud,1):kw,G=m[zl]?u(zl):Qm,T=m[Ol]?u(Ol):Qm,V=m[LC]?u(LC):Qm,E=m[GA]?u(GA):Qm;return function(W){f.setTime(+W);const x=p(f);return o(x,v(f),B(f,x),G(f),T(f),V(f),E(f))}}function adi(e,i,n,r){const o=n<=1?e:r?(l,c)=>r+n*Math.floor((e(l,c)-r)/n):(l,c)=>n*Math.floor(e(l,c)/n);return i?(l,c)=>i(o(l,c),c):o}function zS(e,i,n){return i+e*7-(n+6)%7}const sdi={[xa]:e=>e.getFullYear(),[al]:e=>Math.floor(e.getMonth()/3),[Ts]:e=>e.getMonth(),[sl]:e=>e.getDate(),[zl]:e=>e.getHours(),[Ol]:e=>e.getMinutes(),[LC]:e=>e.getSeconds(),[GA]:e=>e.getMilliseconds(),[ud]:e=>f7e(e),[Lo]:e=>bge(e),[Lo+vs]:(e,i)=>zS(bge(e),e.getDay(),yge(i)),[vs]:(e,i)=>zS(1,e.getDay(),yge(i))},Idi={[al]:e=>3*e,[Lo]:(e,i)=>zS(e,0,yge(i))};function v7e(e,i){return y7e(e,i||1,sdi,Idi,gdi)}const ldi={[xa]:e=>e.getUTCFullYear(),[al]:e=>Math.floor(e.getUTCMonth()/3),[Ts]:e=>e.getUTCMonth(),[sl]:e=>e.getUTCDate(),[zl]:e=>e.getUTCHours(),[Ol]:e=>e.getUTCMinutes(),[LC]:e=>e.getUTCSeconds(),[GA]:e=>e.getUTCMilliseconds(),[ud]:e=>b7e(e),[Lo]:e=>vge(e),[vs]:(e,i)=>zS(1,e.getUTCDay(),Zge(i)),[Lo+vs]:(e,i)=>zS(vge(e),e.getUTCDay(),Zge(i))},Cdi={[al]:e=>3*e,[Lo]:(e,i)=>zS(e,0,Zge(i))};function Z7e(e,i){return y7e(e,i||1,ldi,Cdi,odi)}const cdi={[xa]:cd,[al]:VH.every(3),[Ts]:VH,[Lo]:Mw,[sl]:Lh,[vs]:Lh,[ud]:Lh,[zl]:ez,[Ol]:$P,[LC]:Dh,[GA]:KS},Adi={[xa]:Ad,[al]:EH.every(3),[Ts]:EH,[Lo]:Fw,[sl]:wp,[vs]:wp,[ud]:wp,[zl]:tz,[Ol]:qP,[LC]:Dh,[GA]:KS};function Yw(e){return cdi[e]}function Kw(e){return Adi[e]}function B7e(e,i,n){return e?e.offset(i,n):void 0}function G7e(e,i,n){return B7e(Yw(e),i,n)}function S7e(e,i,n){return B7e(Kw(e),i,n)}function w7e(e,i,n,r){return e?e.range(i,n,r):void 0}function T7e(e,i,n,r){return w7e(Yw(e),i,n,r)}function R7e(e,i,n,r){return w7e(Kw(e),i,n,r)}const D9=1e3,M9=D9*60,F9=M9*60,iz=F9*24,udi=iz*7,pDe=iz*30,Bge=iz*365,V7e=[xa,Ts,sl,zl,Ol,LC,GA],Y9=V7e.slice(0,-1),K9=Y9.slice(0,-1),_9=K9.slice(0,-1),ddi=_9.slice(0,-1),hdi=[xa,Lo],bDe=[xa,Ts],E7e=[xa],qV=[[Y9,1,D9],[Y9,5,5*D9],[Y9,15,15*D9],[Y9,30,30*D9],[K9,1,M9],[K9,5,5*M9],[K9,15,15*M9],[K9,30,30*M9],[_9,1,F9],[_9,3,3*F9],[_9,6,6*F9],[_9,12,12*F9],[ddi,1,iz],[hdi,1,udi],[bDe,1,pDe],[bDe,3,3*pDe],[E7e,1,Bge]];function H7e(e){const i=e.extent,n=e.maxbins||40,r=Math.abs(WW(i))/n;let o=NW(u=>u[2]).right(qV,r),l,c;return o===qV.length?(l=E7e,c=Mp(i[0]/Bge,i[1]/Bge,n)):o?(o=qV[r/qV[o-1][2]53)return null;"w"in It||(It.w=1),"Z"in It?(Zt=Pee(e9(It.y,0,1)),zt=Zt.getUTCDay(),Zt=zt>4||zt===0?u3.ceil(Zt):u3(Zt),Zt=wp.offset(Zt,(It.V-1)*7),It.y=Zt.getUTCFullYear(),It.m=Zt.getUTCMonth(),It.d=Zt.getUTCDate()+(It.w+6)%7):(Zt=_ee(e9(It.y,0,1)),zt=Zt.getDay(),Zt=zt>4||zt===0?A3.ceil(Zt):A3(Zt),Zt=Lh.offset(Zt,(It.V-1)*7),It.y=Zt.getFullYear(),It.m=Zt.getMonth(),It.d=Zt.getDate()+(It.w+6)%7)}else("W"in It||"U"in It)&&("w"in It||(It.w="u"in It?It.u%7:"W"in It?1:0),zt="Z"in It?Pee(e9(It.y,0,1)).getUTCDay():_ee(e9(It.y,0,1)).getDay(),It.m=0,It.d="W"in It?(It.w+6)%7+It.W*7-(zt+5)%7:It.w+It.U*7-(zt+6)%7);return"Z"in It?(It.H+=It.Z/100|0,It.M+=It.Z%100,Pee(It)):_ee(It)}}function Q(xe,it,Ct,It){for(var Et=0,Zt=it.length,zt=Ct.length,Kt,Ut;Et=zt)return-1;if(Kt=it.charCodeAt(Et++),Kt===37){if(Kt=it.charAt(Et++),Ut=Y[Kt in yDe?it.charAt(Et++):Kt],!Ut||(It=Ut(xe,Ct,It))<0)return-1}else if(Kt!=Ct.charCodeAt(It++))return-1}return It}function X(xe,it,Ct){var It=m.exec(it.slice(Ct));return It?(xe.p=p.get(It[0].toLowerCase()),Ct+It[0].length):-1}function $(xe,it,Ct){var It=G.exec(it.slice(Ct));return It?(xe.w=T.get(It[0].toLowerCase()),Ct+It[0].length):-1}function ee(xe,it,Ct){var It=v.exec(it.slice(Ct));return It?(xe.w=B.get(It[0].toLowerCase()),Ct+It[0].length):-1}function ne(xe,it,Ct){var It=W.exec(it.slice(Ct));return It?(xe.m=x.get(It[0].toLowerCase()),Ct+It[0].length):-1}function ge(xe,it,Ct){var It=V.exec(it.slice(Ct));return It?(xe.m=E.get(It[0].toLowerCase()),Ct+It[0].length):-1}function Ae(xe,it,Ct){return Q(xe,i,it,Ct)}function _(xe,it,Ct){return Q(xe,n,it,Ct)}function de(xe,it,Ct){return Q(xe,r,it,Ct)}function Ze(xe){return c[xe.getDay()]}function me(xe){return l[xe.getDay()]}function be(xe){return f[xe.getMonth()]}function Ee(xe){return u[xe.getMonth()]}function Je(xe){return o[+(xe.getHours()>=12)]}function Ue(xe){return 1+~~(xe.getMonth()/3)}function dt(xe){return c[xe.getUTCDay()]}function rt(xe){return l[xe.getUTCDay()]}function ke(xe){return f[xe.getUTCMonth()]}function ze(xe){return u[xe.getUTCMonth()]}function je(xe){return o[+(xe.getUTCHours()>=12)]}function lt(xe){return 1+~~(xe.getUTCMonth()/3)}return{format:function(xe){var it=L(xe+="",k);return it.toString=function(){return xe},it},parse:function(xe){var it=O(xe+="",!1);return it.toString=function(){return xe},it},utcFormat:function(xe){var it=L(xe+="",F);return it.toString=function(){return xe},it},utcParse:function(xe){var it=O(xe+="",!0);return it.toString=function(){return xe},it}}}var yDe={"-":"",_:" ",0:"0"},ma=/^\s*\d+/,fdi=/^%/,mdi=/[\\^$*+?|[\]().{}]/g;function yr(e,i,n){var r=e<0?"-":"",o=(r?-e:e)+"",l=o.length;return r+(l[i.toLowerCase(),n]))}function bdi(e,i,n){var r=ma.exec(i.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function ydi(e,i,n){var r=ma.exec(i.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function vdi(e,i,n){var r=ma.exec(i.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function Zdi(e,i,n){var r=ma.exec(i.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function Bdi(e,i,n){var r=ma.exec(i.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function vDe(e,i,n){var r=ma.exec(i.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function ZDe(e,i,n){var r=ma.exec(i.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Gdi(e,i,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(i.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function Sdi(e,i,n){var r=ma.exec(i.slice(n,n+1));return r?(e.q=r[0]*3-3,n+r[0].length):-1}function wdi(e,i,n){var r=ma.exec(i.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function BDe(e,i,n){var r=ma.exec(i.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function Tdi(e,i,n){var r=ma.exec(i.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function GDe(e,i,n){var r=ma.exec(i.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function Rdi(e,i,n){var r=ma.exec(i.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function Vdi(e,i,n){var r=ma.exec(i.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function Edi(e,i,n){var r=ma.exec(i.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function Hdi(e,i,n){var r=ma.exec(i.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Wdi(e,i,n){var r=fdi.exec(i.slice(n,n+1));return r?n+r[0].length:-1}function Ndi(e,i,n){var r=ma.exec(i.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function kdi(e,i,n){var r=ma.exec(i.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function SDe(e,i){return yr(e.getDate(),i,2)}function Xdi(e,i){return yr(e.getHours(),i,2)}function xdi(e,i){return yr(e.getHours()%12||12,i,2)}function Ddi(e,i){return yr(1+Lh.count(cd(e),e),i,3)}function N7e(e,i){return yr(e.getMilliseconds(),i,3)}function Mdi(e,i){return N7e(e,i)+"000"}function Fdi(e,i){return yr(e.getMonth()+1,i,2)}function Ydi(e,i){return yr(e.getMinutes(),i,2)}function Kdi(e,i){return yr(e.getSeconds(),i,2)}function _di(e){var i=e.getDay();return i===0?7:i}function Pdi(e,i){return yr(Mw.count(cd(e)-1,e),i,2)}function k7e(e){var i=e.getDay();return i>=4||i===0?_S(e):_S.ceil(e)}function zdi(e,i){return e=k7e(e),yr(_S.count(cd(e),e)+(cd(e).getDay()===4),i,2)}function Odi(e){return e.getDay()}function Ldi(e,i){return yr(A3.count(cd(e)-1,e),i,2)}function Jdi(e,i){return yr(e.getFullYear()%100,i,2)}function Udi(e,i){return e=k7e(e),yr(e.getFullYear()%100,i,2)}function Qdi(e,i){return yr(e.getFullYear()%1e4,i,4)}function jdi(e,i){var n=e.getDay();return e=n>=4||n===0?_S(e):_S.ceil(e),yr(e.getFullYear()%1e4,i,4)}function $di(e){var i=e.getTimezoneOffset();return(i>0?"-":(i*=-1,"+"))+yr(i/60|0,"0",2)+yr(i%60,"0",2)}function wDe(e,i){return yr(e.getUTCDate(),i,2)}function qdi(e,i){return yr(e.getUTCHours(),i,2)}function ehi(e,i){return yr(e.getUTCHours()%12||12,i,2)}function thi(e,i){return yr(1+wp.count(Ad(e),e),i,3)}function X7e(e,i){return yr(e.getUTCMilliseconds(),i,3)}function ihi(e,i){return X7e(e,i)+"000"}function nhi(e,i){return yr(e.getUTCMonth()+1,i,2)}function rhi(e,i){return yr(e.getUTCMinutes(),i,2)}function ghi(e,i){return yr(e.getUTCSeconds(),i,2)}function ohi(e){var i=e.getUTCDay();return i===0?7:i}function ahi(e,i){return yr(Fw.count(Ad(e)-1,e),i,2)}function x7e(e){var i=e.getUTCDay();return i>=4||i===0?PS(e):PS.ceil(e)}function shi(e,i){return e=x7e(e),yr(PS.count(Ad(e),e)+(Ad(e).getUTCDay()===4),i,2)}function Ihi(e){return e.getUTCDay()}function lhi(e,i){return yr(u3.count(Ad(e)-1,e),i,2)}function Chi(e,i){return yr(e.getUTCFullYear()%100,i,2)}function chi(e,i){return e=x7e(e),yr(e.getUTCFullYear()%100,i,2)}function Ahi(e,i){return yr(e.getUTCFullYear()%1e4,i,4)}function uhi(e,i){var n=e.getUTCDay();return e=n>=4||n===0?PS(e):PS.ceil(e),yr(e.getUTCFullYear()%1e4,i,4)}function dhi(){return"+0000"}function TDe(){return"%"}function RDe(e){return+e}function VDe(e){return Math.floor(+e/1e3)}var cG,Dle,D7e,Mle,M7e;hhi({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function hhi(e){return cG=W7e(e),Dle=cG.format,D7e=cG.parse,Mle=cG.utcFormat,M7e=cG.utcParse,cG}function P9(e){const i={};return n=>i[n]||(i[n]=e(n))}function fhi(e,i){return n=>{const r=e(n),o=r.indexOf(i);if(o<0)return r;let l=mhi(r,o);const c=lo;)if(r[l]!=="0"){++l;break}return r.slice(0,l)+c}}function mhi(e,i){let n=e.lastIndexOf("e"),r;if(n>0)return n;for(n=e.length;--n>i;)if(r=e.charCodeAt(n),r>=48&&r<=57)return n+1}function F7e(e){const i=P9(e.format),n=e.formatPrefix;return{format:i,formatPrefix:n,formatFloat(r){const o=RH(r||",");if(o.precision==null){switch(o.precision=12,o.type){case"%":o.precision-=2;break;case"e":o.precision-=1;break}return fhi(i(o),i(".1f")(1)[1])}else return i(o)},formatSpan(r,o,l,c){c=RH(c??",f");const u=Mp(r,o,l),f=Math.max(Math.abs(r),Math.abs(o));let m;if(c.precision==null)switch(c.type){case"s":return isNaN(m=Pui(u,f))||(c.precision=m),n(c,f);case"":case"e":case"g":case"p":case"r":{isNaN(m=zui(u,f))||(c.precision=m-(c.type==="e"));break}case"f":case"%":{isNaN(m=_ui(u))||(c.precision=m-(c.type==="%")*2);break}}return i(c)}}}let Gge;Y7e();function Y7e(){return Gge=F7e({format:l7e,formatPrefix:C7e})}function K7e(e){return F7e(I7e(e))}function d3(e){return arguments.length?Gge=K7e(e):Gge}function EDe(e,i,n){n=n||{},vi(n)||Yt(`Invalid time multi-format specifier: ${n}`);const r=i(LC),o=i(Ol),l=i(zl),c=i(sl),u=i(Lo),f=i(Ts),m=i(al),p=i(xa),v=e(n[GA]||".%L"),B=e(n[LC]||":%S"),G=e(n[Ol]||"%I:%M"),T=e(n[zl]||"%I %p"),V=e(n[sl]||n[vs]||"%a %d"),E=e(n[Lo]||"%b %d"),W=e(n[Ts]||"%B"),x=e(n[al]||"%B"),k=e(n[xa]||"%Y");return F=>(r(F)fi(r)?i(r):EDe(i,Yw,r),utcFormat:r=>fi(r)?n(r):EDe(n,Kw,r),timeParse:P9(e.parse),utcParse:P9(e.utcParse)}}let Sge;P7e();function P7e(){return Sge=_7e({format:Dle,parse:D7e,utcFormat:Mle,utcParse:M7e})}function z7e(e){return _7e(W7e(e))}function HH(e){return arguments.length?Sge=z7e(e):Sge}const wge=(e,i)=>Tn({},e,i);function O7e(e,i){const n=e?K7e(e):d3(),r=i?z7e(i):HH();return wge(n,r)}function Fle(e,i){const n=arguments.length;return n&&n!==2&&Yt("defaultLocale expects either zero or two arguments."),n?wge(d3(e),HH(i)):wge(d3(),HH())}function phi(){return Y7e(),P7e(),Fle()}const bhi=/^(data:|([A-Za-z]+:)?\/\/)/,yhi=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|file|data):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,vhi=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,HDe="file://";function Zhi(e,i){return n=>({options:n||{},sanitize:Ghi,load:Bhi,fileAccess:!!i,file:Shi(i),http:Thi(e)})}async function Bhi(e,i){const n=await this.sanitize(e,i),r=n.href;return n.localFile?this.file(r):this.http(r,i)}async function Ghi(e,i){i=Tn({},this.options,i);const n=this.fileAccess,r={href:null};let o,l,c;const u=yhi.test(e.replace(vhi,""));(e==null||typeof e!="string"||!u)&&Yt("Sanitize failure, invalid URI: "+ai(e));const f=bhi.test(e);return(c=i.baseURL)&&!f&&(!e.startsWith("/")&&!c.endsWith("/")&&(e="/"+e),e=c+e),l=(o=e.startsWith(HDe))||i.mode==="file"||i.mode!=="http"&&!f&&n,o?e=e.slice(HDe.length):e.startsWith("//")&&(i.defaultProtocol==="file"?(e=e.slice(2),l=!0):e=(i.defaultProtocol||"http")+":"+e),Object.defineProperty(r,"localFile",{value:!!l}),r.href=e,i.target&&(r.target=i.target+""),i.rel&&(r.rel=i.rel+""),i.context==="image"&&i.crossOrigin&&(r.crossOrigin=i.crossOrigin+""),r}function Shi(e){return e?i=>new Promise((n,r)=>{e.readFile(i,(o,l)=>{o?r(o):n(l)})}):whi}async function whi(){Yt("No file system access.")}function Thi(e){return e?async function(i,n){const r=Tn({},this.options.http,n),o=n&&n.response,l=await e(i,r);return l.ok?Rn(l[o])?l[o]():l.text():Yt(l.status+""+l.statusText)}:Rhi}async function Rhi(){Yt("No HTTP fetch method available.")}const Vhi=e=>e!=null&&e===e,Ehi=e=>e==="true"||e==="false"||e===!0||e===!1,Hhi=e=>!Number.isNaN(Date.parse(e)),L7e=e=>!Number.isNaN(+e)&&!(e instanceof Date),Whi=e=>L7e(e)&&Number.isInteger(+e),Tge={boolean:Vle,integer:Zs,number:Zs,date:Ele,string:Hle,unknown:Hs},uF=[Ehi,Whi,L7e,Hhi],Nhi=["boolean","integer","number","date"];function J7e(e,i){if(!e||!e.length)return"unknown";const n=e.length,r=uF.length,o=uF.map((l,c)=>c+1);for(let l=0,c=0,u,f;ll===0?c:l,0)-1]}function U7e(e,i){return i.reduce((n,r)=>(n[r]=J7e(e,r),n),{})}function WDe(e){const i=function(n,r){const o={delimiter:e};return Yle(n,r?Tn(r,o):o)};return i.responseType="text",i}function Yle(e,i){return i.header&&(e=i.header.map(ai).join(i.delimiter)+` -`+e),uui(i.delimiter).parse(e+"")}Yle.responseType="text";function khi(e){return typeof Buffer=="function"&&Rn(Buffer.isBuffer)?Buffer.isBuffer(e):!1}function Kle(e,i){const n=i&&i.property?ol(i.property):Hs;return vi(e)&&!khi(e)?Xhi(n(e),i):n(JSON.parse(e))}Kle.responseType="json";function Xhi(e,i){return!Pt(e)&&KUe(e)&&(e=[...e]),i&&i.copy?JSON.parse(JSON.stringify(e)):e}const xhi={interior:(e,i)=>e!==i,exterior:(e,i)=>e===i};function Q7e(e,i){let n,r,o,l;return e=Kle(e,i),i&&i.feature?(n=mui,o=i.feature):i&&i.mesh?(n=bui,o=i.mesh,l=xhi[i.filter]):Yt("Missing TopoJSON feature or mesh parameter."),r=(r=e.objects[o])?n(e,r,l):Yt("Invalid TopoJSON object: "+o),r&&r.features||[r]}Q7e.responseType="json";const SY={dsv:Yle,csv:WDe(","),tsv:WDe(" "),json:Kle,topojson:Q7e};function _le(e,i){return arguments.length>1?(SY[e]=i,this):Oi(SY,e)?SY[e]:null}function j7e(e){const i=_le(e);return i&&i.responseType||"text"}function $7e(e,i,n,r){i=i||{};const o=_le(i.type||"json");return o||Yt("Unknown data format type: "+i.type),e=o(e,i),i.parse&&Dhi(e,i.parse,n,r),Oi(e,"columns")&&delete e.columns,e}function Dhi(e,i,n,r){if(!e.length)return;const o=HH();n=n||o.timeParse,r=r||o.utcParse;let l=e.columns||Object.keys(e[0]),c,u,f,m,p,v;i==="auto"&&(i=U7e(e,l)),l=Object.keys(i);const B=l.map(G=>{const T=i[G];let V,E;if(T&&(T.startsWith("date:")||T.startsWith("utc:")))return V=T.split(/:(.+)?/,2),E=V[1],(E[0]==="'"&&E[E.length-1]==="'"||E[0]==='"'&&E[E.length-1]==='"')&&(E=E.slice(1,-1)),(V[0]==="utc"?r:n)(E);if(!Tge[T])throw Error("Illegal format pattern: "+G+":"+T);return Tge[T]});for(f=0,p=e.length,v=l.length;f{const l=i(o);return r[l]||(r[l]=1,n.push(o)),n},n.remove=o=>{const l=i(o);if(r[l]){r[l]=0;const c=n.indexOf(o);c>=0&&n.splice(c,1)}return n},n}async function wY(e,i){try{await i(e)}catch(n){e.error(n)}}const q7e=Symbol("vega_id");let Mhi=1;function gz(e){return!!(e&&Pi(e))}function Pi(e){return e[q7e]}function e4e(e,i){return e[q7e]=i,e}function Vr(e){const i=e===Object(e)?e:{data:e};return Pi(i)?i:e4e(i,Mhi++)}function Ple(e){return oz(e,Vr({}))}function oz(e,i){for(const n in e)i[n]=e[n];return i}function t4e(e,i){return e4e(i,Pi(e))}function tZ(e,i){return e?i?(n,r)=>e(n,r)||Pi(i(n))-Pi(i(r)):(n,r)=>e(n,r)||Pi(n)-Pi(r):null}function i4e(e){return e&&e.constructor===iZ}function iZ(){const e=[],i=[],n=[],r=[],o=[];let l=null,c=!1;return{constructor:iZ,insert(u){const f=pi(u),m=f.length;for(let p=0;p{T(x)&&(m[Pi(x)]=-1)});for(v=0,B=e.length;v0&&(W(V,T,G.value),u.modifies(T));for(v=0,B=o.length;v{T(x)&&m[Pi(x)]>0&&W(x,G.field,G.value)}),u.modifies(G.field);if(c)u.mod=i.length||r.length?f.filter(x=>m[Pi(x)]>0):f.slice();else for(E in p)u.mod.push(p[E]);return(l||l==null&&(i.length||r.length))&&u.clean(!0),u}}}const TY="_:mod:_";function az(){Object.defineProperty(this,TY,{writable:!0,value:{}})}az.prototype={set(e,i,n,r){const o=this,l=o[e],c=o[TY];return i!=null&&i>=0?(l[i]!==n||r)&&(l[i]=n,c[i+":"+e]=-1,c[e]=-1):(l!==n||r)&&(o[e]=n,c[e]=Pt(n)?1+n.length:-1),o},modified(e,i){const n=this[TY];if(arguments.length){if(Pt(e)){for(let r=0;r=0?i+1{G instanceof rg?(G!==this&&(i&&G.targets().add(this),l.push(G)),o.push({op:G,name:v,index:B})):r.set(v,B,G)};for(c in e)if(u=e[c],c===Yhi)pi(u).forEach(v=>{v instanceof rg?v!==this&&(v.targets().add(this),l.push(v)):Yt("Pulse parameters must be operator instances.")}),this.source=u;else if(Pt(u))for(r.set(c,-1,Array(f=u.length)),m=0;m{const n=Date.now();return n-i>e?(i=n,1):0})},debounce(e){const i=Mm();return this.targets().add(Mm(null,null,Tle(e,n=>{const r=n.dataflow;i.receive(n),r&&r.run&&r.run()}))),i},between(e,i){let n=!1;return e.targets().add(Mm(null,null,()=>n=!0)),i.targets().add(Mm(null,null,()=>n=!1)),this.filter(()=>n)},detach(){this._filter=OC,this._targets=null}};function Jhi(e,i,n,r){const o=this,l=Mm(n,r),c=function(m){m.dataflow=o;try{l.receive(m)}catch(p){o.error(p)}finally{o.run()}};let u;typeof e=="string"&&typeof document<"u"?u=document.querySelectorAll(e):u=pi(e);const f=u.length;for(let m=0;mi=r);return n.requests=0,n.done=()=>{--n.requests===0&&(e._pending=null,i(e))},e._pending=n}const efi={skip:!0};function tfi(e,i,n,r,o){return(e instanceof rg?nfi:ifi)(this,e,i,n,r,o),this}function ifi(e,i,n,r,o,l){const c=Tn({},l,efi);let u,f;Rn(n)||(n=Ws(n)),r===void 0?u=m=>e.touch(n(m)):Rn(r)?(f=new rg(null,r,o,!1),u=m=>{f.evaluate(m);const p=n(m),v=f.value;i4e(v)?e.pulse(p,v,l):e.update(p,v,c)}):u=m=>e.update(n(m),r,c),i.apply(u)}function nfi(e,i,n,r,o,l){if(r===void 0)i.targets().add(n);else{const c=l||{},u=new rg(null,rfi(n,r),o,!1);u.modified(c.force),u.rank=i.rank,i.targets().add(u),n&&(u.skip(!0),u.value=n.value,u.targets().add(n),e.connect(n,[u]))}}function rfi(e,i){return i=Rn(i)?i:Ws(i),e?function(n,r){const o=i(n,r);return e.skip()||(e.skip(o!==this.value).value=o),o}:i}function gfi(e){e.rank=++this._rank}function ofi(e){const i=[e];let n,r,o;for(;i.length;)if(this.rank(n=i.pop()),r=n._targets)for(o=r.length;--o>=0;)i.push(n=r[o]),n===e&&Yt("Cycle detected in dataflow graph.")}const h3={},Vu=1<<0,Pm=1<<1,vh=1<<2,afi=Vu|Pm,kDe=Vu|vh,AG=Vu|Pm|vh,XDe=1<<3,n9=1<<4,xDe=1<<5,DDe=1<<6;function Tp(e,i,n){this.dataflow=e,this.stamp=i??-1,this.add=[],this.rem=[],this.mod=[],this.fields=null,this.encode=n||null}function zee(e,i){const n=[];return _m(e,i,r=>n.push(r)),n}function MDe(e,i){const n={};return e.visit(i,r=>{n[Pi(r)]=1}),r=>n[Pi(r)]?null:r}function dF(e,i){return e?(n,r)=>e(n,r)&&i(n,r):i}Tp.prototype={StopPropagation:h3,ADD:Vu,REM:Pm,MOD:vh,ADD_REM:afi,ADD_MOD:kDe,ALL:AG,REFLOW:XDe,SOURCE:n9,NO_SOURCE:xDe,NO_FIELDS:DDe,fork(e){return new Tp(this.dataflow).init(this,e)},clone(){const e=this.fork(AG);return e.add=e.add.slice(),e.rem=e.rem.slice(),e.mod=e.mod.slice(),e.source&&(e.source=e.source.slice()),e.materialize(AG|n9)},addAll(){let e=this;return!e.source||e.add===e.rem||!e.rem.length&&e.source.length===e.add.length||(e=new Tp(this.dataflow).init(this),e.add=e.source,e.rem=[]),e},init(e,i){const n=this;return n.stamp=e.stamp,n.encode=e.encode,e.fields&&!(i&DDe)&&(n.fields=e.fields),i&Vu?(n.addF=e.addF,n.add=e.add):(n.addF=null,n.add=[]),i&Pm?(n.remF=e.remF,n.rem=e.rem):(n.remF=null,n.rem=[]),i&vh?(n.modF=e.modF,n.mod=e.mod):(n.modF=null,n.mod=[]),i&xDe?(n.srcF=null,n.source=null):(n.srcF=e.srcF,n.source=e.source,e.cleans&&(n.cleans=e.cleans)),n},runAfter(e){this.dataflow.runAfter(e)},changed(e){const i=e||AG;return i&Vu&&this.add.length||i&Pm&&this.rem.length||i&vh&&this.mod.length},reflow(e){if(e)return this.fork(AG).reflow();const i=this.add.length,n=this.source&&this.source.length;return n&&n!==i&&(this.mod=this.source,i&&this.filter(vh,MDe(this,Vu))),this},clean(e){return arguments.length?(this.cleans=!!e,this):this.cleans},modifies(e){const i=this.fields||(this.fields={});return Pt(e)?e.forEach(n=>i[n]=!0):i[e]=!0,this},modified(e,i){const n=this.fields;return(i||this.mod.length)&&n?arguments.length?Pt(e)?e.some(r=>n[r]):n[e]:!!n:!1},filter(e,i){const n=this;return e&Vu&&(n.addF=dF(n.addF,i)),e&Pm&&(n.remF=dF(n.remF,i)),e&vh&&(n.modF=dF(n.modF,i)),e&n9&&(n.srcF=dF(n.srcF,i)),n},materialize(e){e=e||AG;const i=this;return e&Vu&&i.addF&&(i.add=zee(i.add,i.addF),i.addF=null),e&Pm&&i.remF&&(i.rem=zee(i.rem,i.remF),i.remF=null),e&vh&&i.modF&&(i.mod=zee(i.mod,i.modF),i.modF=null),e&n9&&i.srcF&&(i.source=i.source.filter(i.srcF),i.srcF=null),i},visit(e,i){const n=this,r=i;if(e&n9)return _m(n.source,n.srcF,r),n;e&Vu&&_m(n.add,n.addF,r),e&Pm&&_m(n.rem,n.remF,r),e&vh&&_m(n.mod,n.modF,r);const o=n.source;if(e&XDe&&o){const l=n.add.length+n.mod.length;l===o.length||(l?_m(o,MDe(n,kDe),r):_m(o,n.srcF,r))}return n}};function zle(e,i,n,r){const o=this;let l=0;this.dataflow=e,this.stamp=i,this.fields=null,this.encode=r||null,this.pulses=n;for(const c of n)if(c.stamp===i){if(c.fields){const u=o.fields||(o.fields={});for(const f in c.fields)u[f]=1}c.changed(o.ADD)&&(l|=o.ADD),c.changed(o.REM)&&(l|=o.REM),c.changed(o.MOD)&&(l|=o.MOD)}this.changes=l}si(zle,Tp,{fork(e){const i=new Tp(this.dataflow).init(this,e&this.NO_FIELDS);return e!==void 0&&(e&i.ADD&&this.visit(i.ADD,n=>i.add.push(n)),e&i.REM&&this.visit(i.REM,n=>i.rem.push(n)),e&i.MOD&&this.visit(i.MOD,n=>i.mod.push(n))),i},changed(e){return this.changes&e},modified(e){const i=this,n=i.fields;return n&&i.changes&i.MOD?Pt(e)?e.some(r=>n[r]):n[e]:0},filter(){Yt("MultiPulse does not support filtering.")},materialize(){Yt("MultiPulse does not support materialization.")},visit(e,i){const n=this,r=n.pulses,o=r.length;let l=0;if(e&n.SOURCE)for(;lr._enqueue(p,!0)),r._touched=rz(HW);let c=0,u,f,m;try{for(;r._heap.size()>0;){if(u=r._heap.pop(),u.rank!==u.qrank){r._enqueue(u,!0);continue}f=u.run(r._getPulse(u,e)),f.then?f=await f:f.async&&(o.push(f.async),f=h3),f!==h3&&u._targets&&u._targets.forEach(p=>r._enqueue(p)),++c}}catch(p){r._heap.clear(),m=p}if(r._input={},r._pulse=null,r.debug(`Pulse ${l}: ${c} operators`),m&&(r._postrun=[],r.error(m)),r._postrun.length){const p=r._postrun.sort((v,B)=>B.priority-v.priority);r._postrun=[];for(let v=0;vr.runAsync(null,()=>{p.forEach(v=>{try{v(r)}catch(B){r.error(B)}})})),r}async function Ifi(e,i,n){for(;this._running;)await this._running;const r=()=>this._running=null;return(this._running=this.evaluate(e,i,n)).then(r,r),this._running}function lfi(e,i,n){return this._pulse?n4e(this):(this.evaluate(e,i,n),this)}function Cfi(e,i,n){if(this._pulse||i)this._postrun.push({priority:n||0,callback:e});else try{e(this)}catch(r){this.error(r)}}function n4e(e){return e.error("Dataflow already running. Use runAsync() to chain invocations."),e}function cfi(e,i){const n=e.stampo.pulse),i):this._input[e.id]||ufi(this._pulse,n&&n.pulse)}function ufi(e,i){return i&&i.stamp===e.stamp?i:(e=e.fork(),i&&i!==h3&&(e.source=i.source),e)}const Ole={skip:!1,force:!1};function dfi(e,i){const n=i||Ole;return this._pulse?this._enqueue(e):this._touched.add(e),n.skip&&e.skip(!0),this}function hfi(e,i,n){const r=n||Ole;return(e.set(i)||r.force)&&this.touch(e,r),this}function ffi(e,i,n){this.touch(e,n||Ole);const r=new Tp(this,this._clock+(this._pulse?0:1)),o=e.pulse&&e.pulse.source||[];return r.target=e,this._input[e.id]=i.pulse(r,o),this}function mfi(e){let i=[];return{clear:()=>i=[],size:()=>i.length,peek:()=>i[0],push:n=>(i.push(n),r4e(i,0,i.length-1,e)),pop:()=>{const n=i.pop();let r;return i.length?(r=i[0],i[0]=n,pfi(i,0,e)):r=n,r}}}function r4e(e,i,n,r){let o,l;const c=e[n];for(;n>i;){if(l=n-1>>1,o=e[l],r(c,o)<0){e[n]=o,n=l;continue}break}return e[n]=c}function pfi(e,i,n){const r=i,o=e.length,l=e[i];let c=(i<<1)+1,u;for(;c=0&&(c=u),e[i]=e[c],i=c,c=(i<<1)+1;return e[i]=l,r4e(e,r,i,n)}function sS(){this.logger(Zle()),this.logLevel(yle),this._clock=0,this._rank=0,this._locale=Fle();try{this._loader=nz()}catch{}this._touched=rz(HW),this._input={},this._pulse=null,this._heap=mfi((e,i)=>e.qrank-i.qrank),this._postrun=[]}function r9(e){return function(){return this._log[e].apply(this,arguments)}}sS.prototype={stamp(){return this._clock},loader(e){return arguments.length?(this._loader=e,this):this._loader},locale(e){return arguments.length?(this._locale=e,this):this._locale},logger(e){return arguments.length?(this._log=e,this):this._log},error:r9("error"),warn:r9("warn"),info:r9("info"),debug:r9("debug"),logLevel:r9("level"),cleanThreshold:1e4,add:zhi,connect:Ohi,rank:gfi,rerank:ofi,pulse:ffi,touch:dfi,update:hfi,changeset:iZ,ingest:Qhi,parse:Uhi,preload:$hi,request:jhi,events:Jhi,on:tfi,evaluate:sfi,run:lfi,runAsync:Ifi,runAfter:Cfi,_enqueue:cfi,_getPulse:Afi};function Xt(e,i){rg.call(this,e,null,i)}si(Xt,rg,{run(e){if(e.stampthis.pulse=n):i!==e.StopPropagation&&(this.pulse=i),i},evaluate(e){const i=this.marshall(e.stamp),n=this.transform(i,e);return i.clear(),n},transform(){}});const OS={};function g4e(e){const i=o4e(e);return i&&i.Definition||null}function o4e(e){return e=e&&e.toLowerCase(),Oi(OS,e)?OS[e]:null}function*a4e(e,i){if(i==null)for(let n of e)n!=null&&n!==""&&(n=+n)>=n&&(yield n);else{let n=-1;for(let r of e)r=i(r,++n,e),r!=null&&r!==""&&(r=+r)>=r&&(yield r)}}function Lle(e,i,n){const r=Float64Array.from(a4e(e,n));return r.sort(Oh),i.map(o=>r7e(r,o))}function Jle(e,i){return Lle(e,[.25,.5,.75],i)}function Ule(e,i){const n=e.length,r=Tui(e,i),o=Jle(e,i),l=(o[2]-o[0])/1.34;return 1.06*(Math.min(r,l)||r||Math.abs(o[0])||1)*Math.pow(n,-.2)}function s4e(e){const i=e.maxbins||20,n=e.base||10,r=Math.log(n),o=e.divide||[5,2];let l=e.extent[0],c=e.extent[1],u,f,m,p,v,B;const G=e.span||c-l||Math.abs(l)||1;if(e.step)u=e.step;else if(e.steps){for(p=G/i,v=0,B=e.steps.length;vi;)u*=n;for(v=0,B=o.length;v=m&&G/p<=i&&(u=p)}p=Math.log(u);const T=p>=0?0:~~(-p/r)+1,V=Math.pow(n,-T-1);return(e.nice||e.nice===void 0)&&(p=Math.floor(l/u+V)*u,l=lB);const o=e.length,l=new Float64Array(o);let c=0,u=1,f=r(e[0]),m=f,p=f+i,v;for(;u=p){for(m=(f+m)/2;c>1);co;)e[c--]=e[r]}r=o,o=l}return e}function vfi(e){return function(){return e=(1103515245*e+12345)%2147483647,e/2147483647}}function Zfi(e,i){i==null&&(i=e,e=0);let n,r,o;const l={min(c){return arguments.length?(n=c||0,o=r-n,l):n},max(c){return arguments.length?(r=c||0,o=r-n,l):r},sample(){return n+Math.floor(o*JC())},pdf(c){return c===Math.floor(c)&&c>=n&&c=r?1:(u-n+1)/o},icdf(c){return c>=0&&c<=1?n-1+Math.floor(c*o):NaN}};return l.min(e).max(i)}const C4e=Math.sqrt(2*Math.PI),Bfi=Math.SQRT2;let g9=NaN;function Iz(e,i){e=e||0,i=i??1;let n=0,r=0,o,l;if(g9===g9)n=g9,g9=NaN;else{do n=JC()*2-1,r=JC()*2-1,o=n*n+r*r;while(o===0||o>1);l=Math.sqrt(-2*Math.log(o)/o),n*=l,g9=r*l}return e+n*i}function Qle(e,i,n){n=n??1;const r=(e-(i||0))/n;return Math.exp(-.5*r*r)/(n*C4e)}function lz(e,i,n){i=i||0,n=n??1;const r=(e-i)/n,o=Math.abs(r);let l;if(o>37)l=0;else{const c=Math.exp(-o*o/2);let u;o<7.07106781186547?(u=.0352624965998911*o+.700383064443688,u=u*o+6.37396220353165,u=u*o+33.912866078383,u=u*o+112.079291497871,u=u*o+221.213596169931,u=u*o+220.206867912376,l=c*u,u=.0883883476483184*o+1.75566716318264,u=u*o+16.064177579207,u=u*o+86.7807322029461,u=u*o+296.564248779674,u=u*o+637.333633378831,u=u*o+793.826512519948,u=u*o+440.413735824752,l=l/u):(u=o+.65,u=o+4/u,u=o+3/u,u=o+2/u,u=o+1/u,l=c/u/2.506628274631)}return r>0?1-l:l}function Cz(e,i,n){return e<0||e>1?NaN:(i||0)+(n??1)*Bfi*Gfi(2*e-1)}function Gfi(e){let i=-Math.log((1-e)*(1+e)),n;return i<6.25?(i-=3.125,n=-364441206401782e-35,n=-16850591381820166e-35+n*i,n=128584807152564e-32+n*i,n=11157877678025181e-33+n*i,n=-1333171662854621e-31+n*i,n=20972767875968562e-33+n*i,n=6637638134358324e-30+n*i,n=-4054566272975207e-29+n*i,n=-8151934197605472e-29+n*i,n=26335093153082323e-28+n*i,n=-12975133253453532e-27+n*i,n=-5415412054294628e-26+n*i,n=10512122733215323e-25+n*i,n=-4112633980346984e-24+n*i,n=-29070369957882005e-24+n*i,n=42347877827932404e-23+n*i,n=-13654692000834679e-22+n*i,n=-13882523362786469e-21+n*i,n=.00018673420803405714+n*i,n=-.000740702534166267+n*i,n=-.006033670871430149+n*i,n=.24015818242558962+n*i,n=1.6536545626831027+n*i):i<16?(i=Math.sqrt(i)-3.25,n=22137376921775787e-25,n=9075656193888539e-23+n*i,n=-27517406297064545e-23+n*i,n=18239629214389228e-24+n*i,n=15027403968909828e-22+n*i,n=-4013867526981546e-21+n*i,n=29234449089955446e-22+n*i,n=12475304481671779e-21+n*i,n=-47318229009055734e-21+n*i,n=6828485145957318e-20+n*i,n=24031110387097894e-21+n*i,n=-.0003550375203628475+n*i,n=.0009532893797373805+n*i,n=-.0016882755560235047+n*i,n=.002491442096107851+n*i,n=-.003751208507569241+n*i,n=.005370914553590064+n*i,n=1.0052589676941592+n*i,n=3.0838856104922208+n*i):Number.isFinite(i)?(i=Math.sqrt(i)-5,n=-27109920616438573e-27,n=-2555641816996525e-25+n*i,n=15076572693500548e-25+n*i,n=-3789465440126737e-24+n*i,n=761570120807834e-23+n*i,n=-1496002662714924e-23+n*i,n=2914795345090108e-23+n*i,n=-6771199775845234e-23+n*i,n=22900482228026655e-23+n*i,n=-99298272942317e-20+n*i,n=4526062597223154e-21+n*i,n=-1968177810553167e-20+n*i,n=7599527703001776e-20+n*i,n=-.00021503011930044477+n*i,n=-.00013871931833623122+n*i,n=1.0103004648645344+n*i,n=4.849906401408584+n*i):n=1/0,n*e}function jle(e,i){let n,r;const o={mean(l){return arguments.length?(n=l||0,o):n},stdev(l){return arguments.length?(r=l??1,o):r},sample:()=>Iz(n,r),pdf:l=>Qle(l,n,r),cdf:l=>lz(l,n,r),icdf:l=>Cz(l,n,r)};return o.mean(e).stdev(i)}function $le(e,i){const n=jle();let r=0;const o={data(l){return arguments.length?(e=l,r=l?l.length:0,o.bandwidth(i)):e},bandwidth(l){return arguments.length?(i=l,!i&&e&&(i=Ule(e)),o):i},sample(){return e[~~(JC()*r)]+i*n.sample()},pdf(l){let c=0,u=0;for(;uqle(n,r),pdf:l=>eCe(l,n,r),cdf:l=>tCe(l,n,r),icdf:l=>iCe(l,n,r)};return o.mean(e).stdev(i)}function A4e(e,i){let n=0,r;function o(c){const u=[];let f=0,m;for(m=0;m=i&&e<=n?1/(n-i):0}function gCe(e,i,n){return n==null&&(n=i??1,i=0),en?1:(e-i)/(n-i)}function oCe(e,i,n){return n==null&&(n=i??1,i=0),e>=0&&e<=1?i+e*(n-i):NaN}function u4e(e,i){let n,r;const o={min(l){return arguments.length?(n=l||0,o):n},max(l){return arguments.length?(r=l??1,o):r},sample:()=>nCe(n,r),pdf:l=>rCe(l,n,r),cdf:l=>gCe(l,n,r),icdf:l=>oCe(l,n,r)};return i==null&&(i=e??1,e=0),o.min(e).max(i)}function aCe(e,i,n){let r=0,o=0;for(const l of e){const c=n(l);i(l)==null||c==null||isNaN(c)||(r+=(c-r)/++o)}return{coef:[r],predict:()=>r,rSquared:0}}function XW(e,i,n,r){const o=r-e*e,l=Math.abs(o)<1e-24?0:(n-e*i)/o;return[i-l*e,l]}function cz(e,i,n,r){e=e.filter(G=>{let T=i(G),V=n(G);return T!=null&&(T=+T)>=T&&V!=null&&(V=+V)>=V}),r&&e.sort((G,T)=>i(G)-i(T));const o=e.length,l=new Float64Array(o),c=new Float64Array(o);let u=0,f=0,m=0,p,v,B;for(B of e)l[u]=p=+i(B),c[u]=v=+n(B),++u,f+=(p-f)/u,m+=(v-m)/u;for(u=0;u=l&&c!=null&&(c=+c)>=c&&r(l,c,++o)}function _w(e,i,n,r,o){let l=0,c=0;return xW(e,i,n,(u,f)=>{const m=f-o(u),p=f-r;l+=m*m,c+=p*p}),1-l/c}function sCe(e,i,n){let r=0,o=0,l=0,c=0,u=0;xW(e,i,n,(p,v)=>{++u,r+=(p-r)/u,o+=(v-o)/u,l+=(p*v-l)/u,c+=(p*p-c)/u});const f=XW(r,o,l,c),m=p=>f[0]+f[1]*p;return{coef:f,predict:m,rSquared:_w(e,i,n,o,m)}}function d4e(e,i,n){let r=0,o=0,l=0,c=0,u=0;xW(e,i,n,(p,v)=>{++u,p=Math.log(p),r+=(p-r)/u,o+=(v-o)/u,l+=(p*v-l)/u,c+=(p*p-c)/u});const f=XW(r,o,l,c),m=p=>f[0]+f[1]*Math.log(p);return{coef:f,predict:m,rSquared:_w(e,i,n,o,m)}}function h4e(e,i,n){const[r,o,l,c]=cz(e,i,n);let u=0,f=0,m=0,p=0,v=0,B,G,T;xW(e,i,n,(x,k)=>{B=r[v++],G=Math.log(k),T=B*k,u+=(k*G-u)/v,f+=(T-f)/v,m+=(T*G-m)/v,p+=(B*T-p)/v});const[V,E]=XW(f/c,u/c,m/c,p/c),W=x=>Math.exp(V+E*(x-l));return{coef:[Math.exp(V-E*l),E],predict:W,rSquared:_w(e,i,n,c,W)}}function f4e(e,i,n){let r=0,o=0,l=0,c=0,u=0,f=0;xW(e,i,n,(v,B)=>{const G=Math.log(v),T=Math.log(B);++f,r+=(G-r)/f,o+=(T-o)/f,l+=(G*T-l)/f,c+=(G*G-c)/f,u+=(B-u)/f});const m=XW(r,o,l,c),p=v=>m[0]*Math.pow(v,m[1]);return m[0]=Math.exp(m[0]),{coef:m,predict:p,rSquared:_w(e,i,n,u,p)}}function ICe(e,i,n){const[r,o,l,c]=cz(e,i,n),u=r.length;let f=0,m=0,p=0,v=0,B=0,G,T,V,E;for(G=0;G(O=O-l,k*O*O+F*O+Y+c);return{coef:[Y-F*l+k*l*l+c,F-2*k*l,k],predict:L,rSquared:_w(e,i,n,c,L)}}function m4e(e,i,n,r){if(r===0)return aCe(e,i,n);if(r===1)return sCe(e,i,n);if(r===2)return ICe(e,i,n);const[o,l,c,u]=cz(e,i,n),f=o.length,m=[],p=[],v=r+1;let B,G,T,V,E;for(B=0;B{k-=c;let F=u+W[0]+W[1]*k+W[2]*k*k;for(B=3;B=0;--l)for(u=i[l],f=1,o[l]+=u,c=1;c<=l;++c)f*=(l+1-c)/c,o[l-c]+=u*Math.pow(n,c)*f;return o[0]+=r,o}function wfi(e){const i=e.length-1,n=[];let r,o,l,c,u;for(r=0;rMath.abs(e[r][c])&&(c=o);for(l=r;l=r;l--)e[l][o]-=e[l][r]*e[r][o]/e[r][r]}for(o=i-1;o>=0;--o){for(u=0,l=o+1;lo[k]-W?x:k;let Y=0,L=0,O=0,Q=0,X=0;const $=1/Math.abs(o[F]-W||1);for(let ge=x;ge<=k;++ge){const Ae=o[ge],_=l[ge],de=Tfi(Math.abs(W-Ae)*$)*B[ge],Ze=Ae*de;Y+=de,L+=Ze,O+=_*de,Q+=_*Ze,X+=Ae*Ze}const[ee,ne]=XW(L/Y,O/Y,Q/Y,X/Y);p[E]=ee+ne*W,v[E]=Math.abs(l[E]-p[E]),Rfi(o,E+1,T)}if(G===FDe)break;const V=g7e(v);if(Math.abs(V)=1?YDe:(x=1-W*W)*x}return Vfi(o,p,c,u)}function Tfi(e){return(e=1-e*e*e)*e*e}function Rfi(e,i,n){const r=e[i];let o=n[0],l=n[1]+1;if(!(l>=e.length))for(;i>o&&e[l]-r<=r-e[o];)n[0]=++o,n[1]=l,++l}function Vfi(e,i,n,r){const o=e.length,l=[];let c=0,u=0,f=[],m;for(;c[V,e(V)],l=i[0],c=i[1],u=c-l,f=u/r,m=[o(l)],p=[];if(n===r){for(let V=1;V0;)p.push(o(l+V/n*u))}let v=m[0],B=p[p.length-1];const G=1/u,T=Hfi(v[1],p);for(;B;){const V=o((v[0]+B[0])/2);V[0]-v[0]>=f&&Wfi(v,V,B,G,T)>Efi?p.push(V):(v=B,m.push(B),p.pop()),B=p[p.length-1]}return m}function Hfi(e,i){let n=e,r=e;const o=i.length;for(let l=0;lr&&(r=c)}return 1/(r-n)}function Wfi(e,i,n,r,o){const l=Math.atan2(o*(n[1]-e[1]),r*(n[0]-e[0])),c=Math.atan2(o*(i[1]-e[1]),r*(i[0]-e[0]));return Math.abs(l-c)}function Nfi(e){return i=>{const n=e.length;let r=1,o=String(e[0](i));for(;r{},kfi={init:Oee,add:Oee,rem:Oee,idx:0},WH={values:{init:e=>e.cell.store=!0,value:e=>e.cell.data.values(),idx:-1},count:{value:e=>e.cell.num},__count__:{value:e=>e.missing+e.valid},missing:{value:e=>e.missing},valid:{value:e=>e.valid},sum:{init:e=>e.sum=0,value:e=>e.sum,add:(e,i)=>e.sum+=+i,rem:(e,i)=>e.sum-=i},product:{init:e=>e.product=1,value:e=>e.valid?e.product:void 0,add:(e,i)=>e.product*=i,rem:(e,i)=>e.product/=i},mean:{init:e=>e.mean=0,value:e=>e.valid?e.mean:void 0,add:(e,i)=>(e.mean_d=i-e.mean,e.mean+=e.mean_d/e.valid),rem:(e,i)=>(e.mean_d=i-e.mean,e.mean-=e.valid?e.mean_d/e.valid:e.mean)},average:{value:e=>e.valid?e.mean:void 0,req:["mean"],idx:1},variance:{init:e=>e.dev=0,value:e=>e.valid>1?e.dev/(e.valid-1):void 0,add:(e,i)=>e.dev+=e.mean_d*(i-e.mean),rem:(e,i)=>e.dev-=e.mean_d*(i-e.mean),req:["mean"],idx:1},variancep:{value:e=>e.valid>1?e.dev/e.valid:void 0,req:["variance"],idx:2},stdev:{value:e=>e.valid>1?Math.sqrt(e.dev/(e.valid-1)):void 0,req:["variance"],idx:2},stdevp:{value:e=>e.valid>1?Math.sqrt(e.dev/e.valid):void 0,req:["variance"],idx:2},stderr:{value:e=>e.valid>1?Math.sqrt(e.dev/(e.valid*(e.valid-1))):void 0,req:["variance"],idx:2},distinct:{value:e=>e.cell.data.distinct(e.get),req:["values"],idx:3},ci0:{value:e=>e.cell.data.ci0(e.get),req:["values"],idx:3},ci1:{value:e=>e.cell.data.ci1(e.get),req:["values"],idx:3},median:{value:e=>e.cell.data.q2(e.get),req:["values"],idx:3},q1:{value:e=>e.cell.data.q1(e.get),req:["values"],idx:3},q3:{value:e=>e.cell.data.q3(e.get),req:["values"],idx:3},min:{init:e=>e.min=void 0,value:e=>e.min=Number.isNaN(e.min)?e.cell.data.min(e.get):e.min,add:(e,i)=>{(i{i<=e.min&&(e.min=NaN)},req:["values"],idx:4},max:{init:e=>e.max=void 0,value:e=>e.max=Number.isNaN(e.max)?e.cell.data.max(e.get):e.max,add:(e,i)=>{(i>e.max||e.max===void 0)&&(e.max=i)},rem:(e,i)=>{i>=e.max&&(e.max=NaN)},req:["values"],idx:4},argmin:{init:e=>e.argmin=void 0,value:e=>e.argmin||e.cell.data.argmin(e.get),add:(e,i,n)=>{i{i<=e.min&&(e.argmin=void 0)},req:["min","values"],idx:3},argmax:{init:e=>e.argmax=void 0,value:e=>e.argmax||e.cell.data.argmax(e.get),add:(e,i,n)=>{i>e.max&&(e.argmax=n)},rem:(e,i)=>{i>=e.max&&(e.argmax=void 0)},req:["max","values"],idx:3}},DW=Object.keys(WH).filter(e=>e!=="__count__");function Xfi(e,i){return n=>Tn({name:e,out:n||e},kfi,i)}[...DW,"__count__"].forEach(e=>{WH[e]=Xfi(e,WH[e])});function y4e(e,i){return WH[e](i)}function v4e(e,i){return e.idx-i.idx}function xfi(e){const i={};e.forEach(r=>i[r.name]=r);const n=r=>{r.req&&r.req.forEach(o=>{i[o]||n(i[o]=WH[o]())})};return e.forEach(n),Object.values(i).sort(v4e)}function Dfi(){this.valid=0,this.missing=0,this._ops.forEach(e=>e.init(this))}function Mfi(e,i){if(e==null||e===""){++this.missing;return}e===e&&(++this.valid,this._ops.forEach(n=>n.add(this,e,i)))}function Ffi(e,i){if(e==null||e===""){--this.missing;return}e===e&&(--this.valid,this._ops.forEach(n=>n.rem(this,e,i)))}function Yfi(e){return this._out.forEach(i=>e[i.out]=i.value(this)),e}function Z4e(e,i){const n=i||Hs,r=xfi(e),o=e.slice().sort(v4e);function l(c){this._ops=r,this._out=o,this.cell=c,this.init()}return l.prototype.init=Dfi,l.prototype.add=Mfi,l.prototype.rem=Ffi,l.prototype.set=Yfi,l.prototype.get=n,l.fields=e.map(c=>c.out),l}function lCe(e){this._key=e?ol(e):Pi,this.reset()}const Ka=lCe.prototype;Ka.reset=function(){this._add=[],this._rem=[],this._ext=null,this._get=null,this._q=null};Ka.add=function(e){this._add.push(e)};Ka.rem=function(e){this._rem.push(e)};Ka.values=function(){if(this._get=null,this._rem.length===0)return this._add;const e=this._add,i=this._rem,n=this._key,r=e.length,o=i.length,l=Array(r-o),c={};let u,f,m;for(u=0;u=0;)l=e(i[r])+"",Oi(n,l)||(n[l]=1,++o);return o};Ka.extent=function(e){if(this._get!==e||!this._ext){const i=this.values(),n=FUe(i,e);this._ext=[i[n[0]],i[n[1]]],this._get=e}return this._ext};Ka.argmin=function(e){return this.extent(e)[0]||{}};Ka.argmax=function(e){return this.extent(e)[1]||{}};Ka.min=function(e){const i=this.extent(e)[0];return i!=null?e(i):void 0};Ka.max=function(e){const i=this.extent(e)[1];return i!=null?e(i):void 0};Ka.quartile=function(e){return(this._get!==e||!this._q)&&(this._q=Jle(this.values(),e),this._get=e),this._q};Ka.q1=function(e){return this.quartile(e)[0]};Ka.q2=function(e){return this.quartile(e)[1]};Ka.q3=function(e){return this.quartile(e)[2]};Ka.ci=function(e){return(this._get!==e||!this._ci)&&(this._ci=I4e(this.values(),1e3,.05,e),this._get=e),this._ci};Ka.ci0=function(e){return this.ci(e)[0]};Ka.ci1=function(e){return this.ci(e)[1]};function Fp(e){Xt.call(this,null,e),this._adds=[],this._mods=[],this._alen=0,this._mlen=0,this._drop=!0,this._cross=!1,this._dims=[],this._dnames=[],this._measures=[],this._countOnly=!1,this._counts=null,this._prev=null,this._inputs=null,this._outputs=null}Fp.Definition={type:"Aggregate",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:DW},{name:"fields",type:"field",null:!0,array:!0},{name:"as",type:"string",null:!0,array:!0},{name:"drop",type:"boolean",default:!0},{name:"cross",type:"boolean",default:!1},{name:"key",type:"field"}]};si(Fp,Xt,{transform(e,i){const n=this,r=i.fork(i.NO_SOURCE|i.NO_FIELDS),o=e.modified();return n.stamp=r.stamp,n.value&&(o||i.modified(n._inputs,!0))?(n._prev=n.value,n.value=o?n.init(e):Object.create(null),i.visit(i.SOURCE,l=>n.add(l))):(n.value=n.value||n.init(e),i.visit(i.REM,l=>n.rem(l)),i.visit(i.ADD,l=>n.add(l))),r.modifies(n._outputs),n._drop=e.drop!==!1,e.cross&&n._dims.length>1&&(n._drop=!1,n.cross()),i.clean()&&n._drop&&r.clean(!0).runAfter(()=>this.clean()),n.changes(r)},cross(){const e=this,i=e.value,n=e._dnames,r=n.map(()=>({})),o=n.length;function l(u){let f,m,p,v;for(f in u)for(p=u[f].tuple,m=0;m{const W=co(E);return o(E),n.push(W),W}),this.cellkey=e.key?e.key:Rge(this._dims),this._countOnly=!0,this._counts=[],this._measures=[];const l=e.fields||[null],c=e.ops||["count"],u=e.as||[],f=l.length,m={};let p,v,B,G,T,V;for(f!==c.length&&Yt("Unmatched number of fields and aggregate ops."),V=0;VZ4e(E,E.field)),Object.create(null)},cellkey:Rge(),cell(e,i){let n=this.value[e];return n?n.num===0&&this._drop&&n.stamp{const v=r(p);p[u]=v,p[f]=v==null?null:o+l*(1+(v-o)/l)}:p=>p[u]=r(p)),i.modifies(n?c:u)},_bins(e){if(this.value&&!e.modified())return this.value;const i=e.field,n=s4e(e),r=n.step;let o=n.start,l=o+Math.ceil((n.stop-o)/r)*r,c,u;(c=e.anchor)!=null&&(u=c-(o+r*Math.floor((c-o)/r)),o+=u,l+=u);const f=function(m){let p=Zs(i(m));return p==null?null:pl?1/0:(p=Math.max(o,Math.min(p,l-r)),o+r*Math.floor(Kfi+(p-o)/r))};return f.start=o,f.stop=n.stop,f.step=r,this.value=dl(f,ws(i),e.name||"bin_"+co(i))}});function B4e(e,i,n){const r=e;let o=i||[],l=n||[],c={},u=0;return{add:f=>l.push(f),remove:f=>c[r(f)]=++u,size:()=>o.length,data:(f,m)=>(u&&(o=o.filter(p=>!c[r(p)]),c={},u=0),m&&f&&o.sort(f),l.length&&(o=f?OUe(f,o,l.sort(f)):o.concat(l),l=[]),o)}}function cCe(e){Xt.call(this,[],e)}cCe.Definition={type:"Collect",metadata:{source:!0},params:[{name:"sort",type:"compare"}]};si(cCe,Xt,{transform(e,i){const n=i.fork(i.ALL),r=B4e(Pi,this.value,n.materialize(n.ADD).add),o=e.sort,l=i.changed()||o&&(e.modified("sort")||i.modified(o.fields));return n.visit(n.REM,r.remove),this.modified(l),this.value=n.source=r.data(tZ(o),l),i.source&&i.source.root&&(this.value.root=i.source.root),n}});function G4e(e){rg.call(this,null,_fi,e)}si(G4e,rg);function _fi(e){return this.value&&!e.modified()?this.value:wle(e.fields,e.orders)}function ACe(e){Xt.call(this,null,e)}ACe.Definition={type:"CountPattern",metadata:{generates:!0,changes:!0},params:[{name:"field",type:"field",required:!0},{name:"case",type:"enum",values:["upper","lower","mixed"],default:"mixed"},{name:"pattern",type:"string",default:'[\\w"]+'},{name:"stopwords",type:"string",default:""},{name:"as",type:"string",array:!0,length:2,default:["text","count"]}]};function Pfi(e,i,n){switch(i){case"upper":e=e.toUpperCase();break;case"lower":e=e.toLowerCase();break}return e.match(n)}si(ACe,Xt,{transform(e,i){const n=v=>B=>{for(var G=Pfi(u(B),e.case,l)||[],T,V=0,E=G.length;Vo[v]=1+(o[v]||0)),p=n(v=>o[v]-=1);return r?i.visit(i.SOURCE,m):(i.visit(i.ADD,m),i.visit(i.REM,p)),this._finish(i,f)},_parameterCheck(e,i){let n=!1;return(e.modified("stopwords")||!this._stop)&&(this._stop=new RegExp("^"+(e.stopwords||"")+"$","i"),n=!0),(e.modified("pattern")||!this._match)&&(this._match=new RegExp(e.pattern||"[\\w']+","g"),n=!0),(e.modified("field")||i.modified(e.field.fields))&&(n=!0),n&&(this._counts={}),n},_finish(e,i){const n=this._counts,r=this._tuples||(this._tuples={}),o=i[0],l=i[1],c=e.fork(e.NO_SOURCE|e.NO_FIELDS);let u,f,m;for(u in n)f=r[u],m=n[u]||0,!f&&m?(r[u]=f=Vr({}),f[o]=u,f[l]=m,c.add.push(f)):m===0?(f&&c.rem.push(f),n[u]=null,r[u]=null):f[l]!==m&&(f[l]=m,c.mod.push(f));return c.modifies(i)}});function uCe(e){Xt.call(this,null,e)}uCe.Definition={type:"Cross",metadata:{generates:!0},params:[{name:"filter",type:"expr"},{name:"as",type:"string",array:!0,length:2,default:["a","b"]}]};si(uCe,Xt,{transform(e,i){const n=i.fork(i.NO_SOURCE),r=e.as||["a","b"],o=r[0],l=r[1],c=!this.value||i.changed(i.ADD_REM)||e.modified("as")||e.modified("filter");let u=this.value;return c?(u&&(n.rem=u),u=i.materialize(i.SOURCE).source,n.add=this.value=zfi(u,o,l,e.filter||OC)):n.mod=u,n.source=this.value,n.modifies(r)}});function zfi(e,i,n,r){for(var o=[],l={},c=e.length,u=0,f,m;uS4e(l,i))):typeof r[o]===_De&&r[o](e[o]);return r}function dCe(e){Xt.call(this,null,e)}const w4e=[{key:{function:"normal"},params:[{name:"mean",type:"number",default:0},{name:"stdev",type:"number",default:1}]},{key:{function:"lognormal"},params:[{name:"mean",type:"number",default:0},{name:"stdev",type:"number",default:1}]},{key:{function:"uniform"},params:[{name:"min",type:"number",default:0},{name:"max",type:"number",default:1}]},{key:{function:"kde"},params:[{name:"field",type:"field",required:!0},{name:"from",type:"data"},{name:"bandwidth",type:"number",default:0}]}],Jfi={key:{function:"mixture"},params:[{name:"distributions",type:"param",array:!0,params:w4e},{name:"weights",type:"number",array:!0}]};dCe.Definition={type:"Density",metadata:{generates:!0},params:[{name:"extent",type:"number",array:!0,length:2},{name:"steps",type:"number"},{name:"minsteps",type:"number",default:25},{name:"maxsteps",type:"number",default:200},{name:"method",type:"string",default:"pdf",values:["pdf","cdf"]},{name:"distribution",type:"param",params:w4e.concat(Jfi)},{name:"as",type:"string",array:!0,default:["value","density"]}]};si(dCe,Xt,{transform(e,i){const n=i.fork(i.NO_SOURCE|i.NO_FIELDS);if(!this.value||i.changed()||e.modified()){const r=S4e(e.distribution,Ufi(i)),o=e.steps||e.minsteps||25,l=e.steps||e.maxsteps||200;let c=e.method||"pdf";c!=="pdf"&&c!=="cdf"&&Yt("Invalid density method: "+c),!e.extent&&!r.data&&Yt("Missing density extent parameter."),c=r[c];const u=e.as||["value","density"],f=e.extent||Cd(r.data()),m=Az(c,f,o,l).map(p=>{const v={};return v[u[0]]=p[0],v[u[1]]=p[1],Vr(v)});this.value&&(n.rem=this.value),this.value=n.add=n.source=m}return n}});function Ufi(e){return()=>e.materialize(e.SOURCE).source}function T4e(e,i){return e?e.map((n,r)=>i[r]||co(n)):null}function hCe(e,i,n){const r=[],o=v=>v(f);let l,c,u,f,m,p;if(i==null)r.push(e.map(n));else for(l={},c=0,u=e.length;cWW(Cd(e,i))/30;si(fCe,Xt,{transform(e,i){if(this.value&&!(e.modified()||i.changed()))return i;const n=i.materialize(i.SOURCE).source,r=hCe(i.source,e.groupby,Hs),o=e.smooth||!1,l=e.field,c=e.step||Qfi(n,l),u=tZ((T,V)=>l(T)-l(V)),f=e.as||R4e,m=r.length;let p=1/0,v=-1/0,B=0,G;for(;Bv&&(v=V),T[++G][f]=V}return this.value={start:p,stop:v,step:c},i.reflow(!0).modifies(f)}});function V4e(e){rg.call(this,null,jfi,e),this.modified(!0)}si(V4e,rg);function jfi(e){const i=e.expr;return this.value&&!e.modified("expr")?this.value:dl(n=>i(n,e),ws(i),co(i))}function mCe(e){Xt.call(this,[void 0,void 0],e)}mCe.Definition={type:"Extent",metadata:{},params:[{name:"field",type:"field",required:!0}]};si(mCe,Xt,{transform(e,i){const n=this.value,r=e.field,o=i.changed()||i.modified(r.fields)||e.modified("field");let l=n[0],c=n[1];if((o||l==null)&&(l=1/0,c=-1/0),i.visit(o?i.SOURCE:i.ADD,u=>{const f=Zs(r(u));f!=null&&(fc&&(c=f))}),!Number.isFinite(l)||!Number.isFinite(c)){let u=co(r);u&&(u=` for field "${u}"`),i.dataflow.warn(`Infinite extent${u}: [${l}, ${c}]`),l=c=void 0}this.value=[l,c]}});function pCe(e,i){rg.call(this,e),this.parent=i,this.count=0}si(pCe,rg,{connect(e){return this.detachSubflow=e.detachSubflow,this.targets().add(e),e.source=this},add(e){this.count+=1,this.value.add.push(e)},rem(e){this.count-=1,this.value.rem.push(e)},mod(e){this.value.mod.push(e)},init(e){this.value.init(e,e.NO_SOURCE)},evaluate(){return this.value}});function uz(e){Xt.call(this,{},e),this._keys=Dw();const i=this._targets=[];i.active=0,i.forEach=n=>{for(let r=0,o=i.active;rr&&r.count>0);this.initTargets(n)}},initTargets(e){const i=this._targets,n=i.length,r=e?e.length:0;let o=0;for(;othis.subflow(f,o,i);return this._group=e.group||{},this.initTargets(),i.visit(i.REM,f=>{const m=Pi(f),p=l.get(m);p!==void 0&&(l.delete(m),u(p).rem(f))}),i.visit(i.ADD,f=>{const m=r(f);l.set(Pi(f),m),u(m).add(f)}),c||i.modified(r.fields)?i.visit(i.MOD,f=>{const m=Pi(f),p=l.get(m),v=r(f);p===v?u(v).mod(f):(l.set(m,v),u(p).rem(f),u(v).add(f))}):i.changed(i.MOD)&&i.visit(i.MOD,f=>{u(l.get(Pi(f))).mod(f)}),c&&i.visit(i.REFLOW,f=>{const m=Pi(f),p=l.get(m),v=r(f);p!==v&&(l.set(m,v),u(p).rem(f),u(v).add(f))}),i.clean()?n.runAfter(()=>{this.clean(),l.clean()}):l.empty>n.cleanThreshold&&n.runAfter(l.clean),i}});function E4e(e){rg.call(this,null,$fi,e)}si(E4e,rg);function $fi(e){return this.value&&!e.modified()?this.value:Pt(e.name)?pi(e.name).map(i=>ol(i)):ol(e.name,e.as)}function bCe(e){Xt.call(this,Dw(),e)}bCe.Definition={type:"Filter",metadata:{changes:!0},params:[{name:"expr",type:"expr",required:!0}]};si(bCe,Xt,{transform(e,i){const n=i.dataflow,r=this.value,o=i.fork(),l=o.add,c=o.rem,u=o.mod,f=e.expr;let m=!0;i.visit(i.REM,v=>{const B=Pi(v);r.has(B)?r.delete(B):c.push(v)}),i.visit(i.ADD,v=>{f(v,e)?l.push(v):r.set(Pi(v),1)});function p(v){const B=Pi(v),G=f(v,e),T=r.get(B);G&&T?(r.delete(B),l.push(v)):!G&&!T?(r.set(B,1),c.push(v)):m&&G&&!T&&u.push(v)}return i.visit(i.MOD,p),e.modified()&&(m=!1,i.visit(i.REFLOW,p)),r.empty>n.cleanThreshold&&n.runAfter(r.clean),o}});function yCe(e){Xt.call(this,[],e)}yCe.Definition={type:"Flatten",metadata:{generates:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"index",type:"string"},{name:"as",type:"string",array:!0}]};si(yCe,Xt,{transform(e,i){const n=i.fork(i.NO_SOURCE),r=e.fields,o=T4e(r,e.as||[]),l=e.index||null,c=o.length;return n.rem=this.value,i.visit(i.SOURCE,u=>{const f=r.map(T=>T(u)),m=f.reduce((T,V)=>Math.max(T,V.length),0);let p=0,v,B,G;for(;p{for(let p=0,v;pc[r]=n(c,e))}});function H4e(e){Xt.call(this,[],e)}si(H4e,Xt,{transform(e,i){const n=i.fork(i.ALL),r=e.generator;let o=this.value,l=e.size-o.length,c,u,f;if(l>0){for(c=[];--l>=0;)c.push(f=Vr(r(e))),o.push(f);n.add=n.add.length?n.materialize(n.ADD).add.concat(c):c}else u=o.slice(0,-l),n.rem=n.rem.length?n.materialize(n.REM).rem.concat(u):u,o=o.slice(-l);return n.source=this.value=o,n}});const hF={value:"value",median:g7e,mean:Nui,min:mge,max:Py},qfi=[];function BCe(e){Xt.call(this,[],e)}BCe.Definition={type:"Impute",metadata:{changes:!0},params:[{name:"field",type:"field",required:!0},{name:"key",type:"field",required:!0},{name:"keyvals",array:!0},{name:"groupby",type:"field",array:!0},{name:"method",type:"enum",default:"value",values:["value","mean","median","max","min"]},{name:"value",default:0}]};function emi(e){var i=e.method||hF.value,n;if(hF[i]==null)Yt("Unrecognized imputation method: "+i);else return i===hF.value?(n=e.value!==void 0?e.value:0,()=>n):hF[i]}function tmi(e){const i=e.field;return n=>n?i(n):NaN}si(BCe,Xt,{transform(e,i){var n=i.fork(i.ALL),r=emi(e),o=tmi(e),l=co(e.field),c=co(e.key),u=(e.groupby||[]).map(co),f=imi(i.source,e.groupby,e.key,e.keyvals),m=[],p=this.value,v=f.domain.length,B,G,T,V,E,W,x,k,F,Y;for(E=0,k=f.length;EW(E),l=[],c=r?r.slice():[],u={},f={},m,p,v,B,G,T,V,E;for(c.forEach((W,x)=>u[W]=x+1),B=0,V=e.length;Bn.add(l))):(o=n.value=n.value||this.init(e),i.visit(i.REM,l=>n.rem(l)),i.visit(i.ADD,l=>n.add(l))),n.changes(),i.visit(i.SOURCE,l=>{Tn(l,o[n.cellkey(l)].tuple)}),i.reflow(r).modifies(this._outputs)},changes(){const e=this._adds,i=this._mods;let n,r;for(n=0,r=this._alen;n{const T=$le(G,c)[u],V=e.counts?G.length:1,E=p||Cd(G);Az(T,E,v,B).forEach(W=>{const x={};for(let k=0;k(this._pending=pi(o.data),l=>l.touch(this)))}:n.request(e.url,e.format).then(r=>Lee(this,i,pi(r.data)))}});function rmi(e){return e.modified("async")&&!(e.modified("values")||e.modified("url")||e.modified("format"))}function Lee(e,i,n){n.forEach(Vr);const r=i.fork(i.NO_FIELDS&i.NO_SOURCE);return r.rem=e.value,e.value=r.source=r.add=n,e._pending=null,r.rem.length&&r.clean(!0),r}function wCe(e){Xt.call(this,{},e)}wCe.Definition={type:"Lookup",metadata:{modifies:!0},params:[{name:"index",type:"index",params:[{name:"from",type:"data",required:!0},{name:"key",type:"field",required:!0}]},{name:"values",type:"field",array:!0},{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0},{name:"default",default:null}]};si(wCe,Xt,{transform(e,i){const n=e.fields,r=e.index,o=e.values,l=e.default==null?null:e.default,c=e.modified(),u=n.length;let f=c?i.SOURCE:i.ADD,m=i,p=e.as,v,B,G;return o?(B=o.length,u>1&&!p&&Yt('Multi-field lookup requires explicit "as" parameter.'),p&&p.length!==u*B&&Yt('The "as" parameter has too few output field names.'),p=p||o.map(co),v=function(T){for(var V=0,E=0,W,x;Vi.modified(T.fields)),f|=G?i.MOD:0),i.visit(f,v),m.modifies(p)}});function k4e(e){rg.call(this,null,gmi,e)}si(k4e,rg);function gmi(e){if(this.value&&!e.modified())return this.value;const i=e.extents,n=i.length;let r=1/0,o=-1/0,l,c;for(l=0;lo&&(o=c[1]);return[r,o]}function X4e(e){rg.call(this,null,omi,e)}si(X4e,rg);function omi(e){return this.value&&!e.modified()?this.value:e.values.reduce((i,n)=>i.concat(n),[])}function x4e(e){Xt.call(this,null,e)}si(x4e,Xt,{transform(e,i){return this.modified(e.modified()),this.value=e,i.fork(i.NO_SOURCE|i.NO_FIELDS)}});function TCe(e){Fp.call(this,e)}TCe.Definition={type:"Pivot",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"field",type:"field",required:!0},{name:"value",type:"field",required:!0},{name:"op",type:"enum",values:DW,default:"sum"},{name:"limit",type:"number",default:0},{name:"key",type:"field"}]};si(TCe,Fp,{_transform:Fp.prototype.transform,transform(e,i){return this._transform(ami(e,i),i)}});function ami(e,i){const n=e.field,r=e.value,o=(e.op==="count"?"__count__":e.op)||"sum",l=ws(n).concat(ws(r)),c=Imi(n,e.limit||0,i);return i.changed()&&e.set("__pivot__",null,null,!0),{key:e.key,groupby:e.groupby,ops:c.map(()=>o),fields:c.map(u=>smi(u,n,r,l)),as:c.map(u=>u+""),modified:e.modified.bind(e)}}function smi(e,i,n,r){return dl(o=>i(o)===e?n(o):NaN,r,e+"")}function Imi(e,i,n){const r={},o=[];return n.visit(n.SOURCE,l=>{const c=e(l);r[c]||(r[c]=1,o.push(c))}),o.sort(jP),i?o.slice(0,i):o}function D4e(e){uz.call(this,e)}si(D4e,uz,{transform(e,i){const n=e.subflow,r=e.field,o=l=>this.subflow(Pi(l),n,i,l);return(e.modified("field")||r&&i.modified(ws(r)))&&Yt("PreFacet does not support field modification."),this.initTargets(),r?(i.visit(i.MOD,l=>{const c=o(l);r(l).forEach(u=>c.mod(u))}),i.visit(i.ADD,l=>{const c=o(l);r(l).forEach(u=>c.add(Vr(u)))}),i.visit(i.REM,l=>{const c=o(l);r(l).forEach(u=>c.rem(u))})):(i.visit(i.MOD,l=>o(l).mod(l)),i.visit(i.ADD,l=>o(l).add(l)),i.visit(i.REM,l=>o(l).rem(l))),i.clean()&&i.runAfter(()=>this.clean()),i}});function RCe(e){Xt.call(this,null,e)}RCe.Definition={type:"Project",metadata:{generates:!0,changes:!0},params:[{name:"fields",type:"field",array:!0},{name:"as",type:"string",null:!0,array:!0}]};si(RCe,Xt,{transform(e,i){const n=i.fork(i.NO_SOURCE),r=e.fields,o=T4e(e.fields,e.as||[]),l=r?(u,f)=>lmi(u,f,r,o):oz;let c;return this.value?c=this.value:(i=i.addAll(),c=this.value={}),i.visit(i.REM,u=>{const f=Pi(u);n.rem.push(c[f]),c[f]=null}),i.visit(i.ADD,u=>{const f=l(u,Vr({}));c[Pi(u)]=f,n.add.push(f)}),i.visit(i.MOD,u=>{n.mod.push(l(u,c[Pi(u)]))}),n}});function lmi(e,i,n,r){for(let o=0,l=n.length;o{const B=Lle(v,m);for(let G=0;G{const l=Pi(o);n.rem.push(r[l]),r[l]=null}),i.visit(i.ADD,o=>{const l=Ple(o);r[Pi(o)]=l,n.add.push(l)}),i.visit(i.MOD,o=>{const l=r[Pi(o)];for(const c in o)l[c]=o[c],n.modifies(c);n.mod.push(l)})),n}});function ECe(e){Xt.call(this,[],e),this.count=0}ECe.Definition={type:"Sample",metadata:{},params:[{name:"size",type:"number",default:1e3}]};si(ECe,Xt,{transform(e,i){const n=i.fork(i.NO_SOURCE),r=e.modified("size"),o=e.size,l=this.value.reduce((p,v)=>(p[Pi(v)]=1,p),{});let c=this.value,u=this.count,f=0;function m(p){let v,B;c.length=f&&(v=c[B],l[Pi(v)]&&n.rem.push(v),c[B]=p)),++u}if(i.rem.length&&(i.visit(i.REM,p=>{const v=Pi(p);l[v]&&(l[v]=-1,n.rem.push(p)),--u}),c=c.filter(p=>l[Pi(p)]!==-1)),(i.rem.length||r)&&c.length{l[Pi(p)]||m(p)}),f=-1),r&&c.length>o){const p=c.length-o;for(let v=0;v{l[Pi(p)]&&n.mod.push(p)}),i.add.length&&i.visit(i.ADD,m),(i.add.length||f<0)&&(n.add=c.filter(p=>!l[Pi(p)])),this.count=u,this.value=n.source=c,n}});function HCe(e){Xt.call(this,null,e)}HCe.Definition={type:"Sequence",metadata:{generates:!0,changes:!0},params:[{name:"start",type:"number",required:!0},{name:"stop",type:"number",required:!0},{name:"step",type:"number",default:1},{name:"as",type:"string",default:"data"}]};si(HCe,Xt,{transform(e,i){if(this.value&&!e.modified())return;const n=i.materialize().fork(i.MOD),r=e.as||"data";return n.rem=this.value?i.rem.concat(this.value):i.rem,this.value=Yl(e.start,e.stop,e.step||1).map(o=>{const l={};return l[r]=o,Vr(l)}),n.add=i.add.concat(this.value),n}});function Y4e(e){Xt.call(this,null,e),this.modified(!0)}si(Y4e,Xt,{transform(e,i){return this.value=i.source,i.changed()?i.fork(i.NO_SOURCE|i.NO_FIELDS):i.StopPropagation}});function WCe(e){Xt.call(this,null,e)}const K4e=["unit0","unit1"];WCe.Definition={type:"TimeUnit",metadata:{modifies:!0},params:[{name:"field",type:"field",required:!0},{name:"interval",type:"boolean",default:!0},{name:"units",type:"enum",values:kle,array:!0},{name:"step",type:"number",default:1},{name:"maxbins",type:"number",default:40},{name:"extent",type:"date",array:!0},{name:"timezone",type:"enum",default:"local",values:["local","utc"]},{name:"as",type:"string",array:!0,length:2,default:K4e}]};si(WCe,Xt,{transform(e,i){const n=e.field,r=e.interval!==!1,o=e.timezone==="utc",l=this._floor(e,i),c=(o?Kw:Yw)(l.unit).offset,u=e.as||K4e,f=u[0],m=u[1],p=l.step;let v=l.start||1/0,B=l.stop||-1/0,G=i.ADD;return(e.modified()||i.changed(i.REM)||i.modified(ws(n)))&&(i=i.reflow(!0),G=i.SOURCE,v=1/0,B=-1/0),i.visit(G,T=>{const V=n(T);let E,W;V==null?(T[f]=null,r&&(T[m]=null)):(T[f]=E=W=l(V),r&&(T[m]=W=c(E,p)),EB&&(B=W))}),l.start=v,l.stop=B,i.modifies(r?u:f)},_floor(e,i){const n=e.timezone==="utc",{units:r,step:o}=e.units?{units:e.units,step:e.step||1}:H7e({extent:e.extent||Cd(i.materialize(i.SOURCE).source,e.field),maxbins:e.maxbins}),l=Xle(r),c=this.value||{},u=(n?Z7e:v7e)(l,o);return u.unit=sr(l),u.units=l,u.step=o,u.start=c.start,u.stop=c.stop,this.value=u}});function _4e(e){Xt.call(this,Dw(),e)}si(_4e,Xt,{transform(e,i){const n=i.dataflow,r=e.field,o=this.value,l=u=>o.set(r(u),u);let c=!0;return e.modified("field")||i.modified(r.fields)?(o.clear(),i.visit(i.SOURCE,l)):i.changed()?(i.visit(i.REM,u=>o.delete(r(u))),i.visit(i.ADD,l)):c=!1,this.modified(c),o.empty>n.cleanThreshold&&n.runAfter(o.clean),i.fork()}});function P4e(e){Xt.call(this,null,e)}si(P4e,Xt,{transform(e,i){(!this.value||e.modified("field")||e.modified("sort")||i.changed()||e.sort&&i.modified(e.sort.fields))&&(this.value=(e.sort?i.source.slice().sort(tZ(e.sort)):i.source).map(e.field))}});function cmi(e,i,n,r){const o=NH[e](i,n);return{init:o.init||Qm,update:function(l,c){c[r]=o.next(l)}}}const NH={row_number:function(){return{next:e=>e.index+1}},rank:function(){let e;return{init:()=>e=1,next:i=>{const n=i.index,r=i.data;return n&&i.compare(r[n-1],r[n])?e=n+1:e}}},dense_rank:function(){let e;return{init:()=>e=1,next:i=>{const n=i.index,r=i.data;return n&&i.compare(r[n-1],r[n])?++e:e}}},percent_rank:function(){const e=NH.rank(),i=e.next;return{init:e.init,next:n=>(i(n)-1)/(n.data.length-1)}},cume_dist:function(){let e;return{init:()=>e=0,next:i=>{const n=i.data,r=i.compare;let o=i.index;if(e0||Yt("ntile num must be greater than zero.");const n=NH.cume_dist(),r=n.next;return{init:n.init,next:o=>Math.ceil(i*r(o))}},lag:function(e,i){return i=+i||1,{next:n=>{const r=n.index-i;return r>=0?e(n.data[r]):null}}},lead:function(e,i){return i=+i||1,{next:n=>{const r=n.index+i,o=n.data;return re(i.data[i.i0])}},last_value:function(e){return{next:i=>e(i.data[i.i1-1])}},nth_value:function(e,i){return i=+i,i>0||Yt("nth_value nth must be greater than zero."),{next:n=>{const r=n.i0+(i-1);return ri=null,next:n=>{const r=e(n.data[n.index]);return r!=null?i=r:i}}},next_value:function(e){let i,n;return{init:()=>(i=null,n=-1),next:r=>{const o=r.data;return r.index<=n?i:(n=Ami(e,o,r.index))<0?(n=o.length,i=null):i=e(o[n])}}}};function Ami(e,i,n){for(let r=i.length;nu[T]=1)}B(e.sort),i.forEach((G,T)=>{const V=n[T],E=co(V),W=b4e(G,E,o[T]);if(B(V),l.push(W),Oi(NH,G))c.push(cmi(G,n[T],r[T],W));else{if(V==null&&G!=="count"&&Yt("Null aggregate field specified."),G==="count"){m.push(W);return}v=!1;let x=f[E];x||(x=f[E]=[],x.field=V,p.push(x)),x.push(y4e(G,W))}}),(m.length||p.length)&&(this.cell=dmi(p,m,v)),this.inputs=Object.keys(u)}const O4e=z4e.prototype;O4e.init=function(){this.windows.forEach(e=>e.init()),this.cell&&this.cell.init()};O4e.update=function(e,i){const n=this.cell,r=this.windows,o=e.data,l=r&&r.length;let c;if(n){for(c=e.p0;cZ4e(f,f.field));const r={num:0,agg:null,store:!1,count:i};if(!n)for(var o=e.length,l=r.agg=Array(o),c=0;cthis.group(o(u));let c=this.state;(!c||n)&&(c=this.state=new z4e(e)),n||i.modified(c.inputs)?(this.value={},i.visit(i.SOURCE,u=>l(u).add(u))):(i.visit(i.REM,u=>l(u).remove(u)),i.visit(i.ADD,u=>l(u).add(u)));for(let u=0,f=this._mlen;u0&&!o(l[n],l[n-1])&&(e.i0=i.left(l,l[n])),r1?0:e<-1?LS:Math.acos(e)}function zDe(e){return e>=1?f3:e<=-1?-f3:Math.asin(e)}const Vge=Math.PI,Ege=2*Vge,dy=1e-6,vmi=Ege-dy;function J4e(e){this._+=e[0];for(let i=1,n=e.length;i=0))throw new Error(`invalid digits: ${e}`);if(i>15)return J4e;const n=10**i;return function(r){this._+=r[0];for(let o=1,l=r.length;ody)if(!(Math.abs(v*f-m*p)>dy)||!l)this._append`L${this._x1=i},${this._y1=n}`;else{let G=r-c,T=o-u,V=f*f+m*m,E=G*G+T*T,W=Math.sqrt(V),x=Math.sqrt(B),k=l*Math.tan((Vge-Math.acos((V+B-E)/(2*W*x)))/2),F=k/x,Y=k/W;Math.abs(F-1)>dy&&this._append`L${i+F*p},${n+F*v}`,this._append`A${l},${l},0,0,${+(v*G>p*T)},${this._x1=i+Y*f},${this._y1=n+Y*m}`}}arc(i,n,r,o,l,c){if(i=+i,n=+n,r=+r,c=!!c,r<0)throw new Error(`negative radius: ${r}`);let u=r*Math.cos(o),f=r*Math.sin(o),m=i+u,p=n+f,v=1^c,B=c?o-l:l-o;this._x1===null?this._append`M${m},${p}`:(Math.abs(this._x1-m)>dy||Math.abs(this._y1-p)>dy)&&this._append`L${m},${p}`,r&&(B<0&&(B=B%Ege+Ege),B>vmi?this._append`A${r},${r},0,1,${v},${i-u},${n-f}A${r},${r},0,1,${v},${this._x1=m},${this._y1=p}`:B>dy&&this._append`A${r},${r},0,${+(B>=Vge)},${v},${this._x1=i+r*Math.cos(l)},${this._y1=n+r*Math.sin(l)}`)}rect(i,n,r,o){this._append`M${this._x0=this._x1=+i},${this._y0=this._y1=+n}h${r=+r}v${+o}h${-r}Z`}toString(){return this._}};function dz(){return new kCe}dz.prototype=kCe.prototype;function hz(e){let i=3;return e.digits=function(n){if(!arguments.length)return i;if(n==null)i=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);i=r}return e},()=>new kCe(i)}function Bmi(e){return e.innerRadius}function Gmi(e){return e.outerRadius}function Smi(e){return e.startAngle}function wmi(e){return e.endAngle}function Tmi(e){return e&&e.padAngle}function Rmi(e,i,n,r,o,l,c,u){var f=n-e,m=r-i,p=c-o,v=u-l,B=v*f-p*m;if(!(B*BAe*Ae+_*_&&(Q=$,X=ee),{cx:Q,cy:X,x01:-p,y01:-v,x11:Q*(o/Y-1),y11:X*(o/Y-1)}}function Vmi(){var e=Bmi,i=Gmi,n=Hr(0),r=null,o=Smi,l=wmi,c=Tmi,u=null,f=hz(m);function m(){var p,v,B=+e.apply(this,arguments),G=+i.apply(this,arguments),T=o.apply(this,arguments)-f3,V=l.apply(this,arguments)-f3,E=PDe(V-T),W=V>T;if(u||(u=p=f()),Gms))u.moveTo(0,0);else if(E>L4e-ms)u.moveTo(G*Ub(T),G*Gu(T)),u.arc(0,0,G,T,V,!W),B>ms&&(u.moveTo(B*Ub(V),B*Gu(V)),u.arc(0,0,B,V,T,W));else{var x=T,k=V,F=T,Y=V,L=E,O=E,Q=c.apply(this,arguments)/2,X=Q>ms&&(r?+r.apply(this,arguments):Ry(B*B+G*G)),$=Jee(PDe(G-B)/2,+n.apply(this,arguments)),ee=$,ne=$,ge,Ae;if(X>ms){var _=zDe(X/B*Gu(Q)),de=zDe(X/G*Gu(Q));(L-=_*2)>ms?(_*=W?1:-1,F+=_,Y-=_):(L=0,F=Y=(T+V)/2),(O-=de*2)>ms?(de*=W?1:-1,x+=de,k-=de):(O=0,x=k=(T+V)/2)}var Ze=G*Ub(x),me=G*Gu(x),be=B*Ub(Y),Ee=B*Gu(Y);if($>ms){var Je=G*Ub(k),Ue=G*Gu(k),dt=B*Ub(F),rt=B*Gu(F),ke;if(Ems?ne>ms?(ge=fF(dt,rt,Ze,me,G,ne,W),Ae=fF(Je,Ue,be,Ee,G,ne,W),u.moveTo(ge.cx+ge.x01,ge.cy+ge.y01),ne<$?u.arc(ge.cx,ge.cy,ne,hs(ge.y01,ge.x01),hs(Ae.y01,Ae.x01),!W):(u.arc(ge.cx,ge.cy,ne,hs(ge.y01,ge.x01),hs(ge.y11,ge.x11),!W),u.arc(0,0,G,hs(ge.cy+ge.y11,ge.cx+ge.x11),hs(Ae.cy+Ae.y11,Ae.cx+Ae.x11),!W),u.arc(Ae.cx,Ae.cy,ne,hs(Ae.y11,Ae.x11),hs(Ae.y01,Ae.x01),!W))):(u.moveTo(Ze,me),u.arc(0,0,G,x,k,!W)):u.moveTo(Ze,me),!(B>ms)||!(L>ms)?u.lineTo(be,Ee):ee>ms?(ge=fF(be,Ee,Je,Ue,B,-ee,W),Ae=fF(Ze,me,dt,rt,B,-ee,W),u.lineTo(ge.cx+ge.x01,ge.cy+ge.y01),ee<$?u.arc(ge.cx,ge.cy,ee,hs(ge.y01,ge.x01),hs(Ae.y01,Ae.x01),!W):(u.arc(ge.cx,ge.cy,ee,hs(ge.y01,ge.x01),hs(ge.y11,ge.x11),!W),u.arc(0,0,B,hs(ge.cy+ge.y11,ge.cx+ge.x11),hs(Ae.cy+Ae.y11,Ae.cx+Ae.x11),W),u.arc(Ae.cx,Ae.cy,ee,hs(Ae.y11,Ae.x11),hs(Ae.y01,Ae.x01),!W))):u.arc(0,0,B,Y,F,W)}if(u.closePath(),p)return u=null,p+""||null}return m.centroid=function(){var p=(+e.apply(this,arguments)+ +i.apply(this,arguments))/2,v=(+o.apply(this,arguments)+ +l.apply(this,arguments))/2-LS/2;return[Ub(v)*p,Gu(v)*p]},m.innerRadius=function(p){return arguments.length?(e=typeof p=="function"?p:Hr(+p),m):e},m.outerRadius=function(p){return arguments.length?(i=typeof p=="function"?p:Hr(+p),m):i},m.cornerRadius=function(p){return arguments.length?(n=typeof p=="function"?p:Hr(+p),m):n},m.padRadius=function(p){return arguments.length?(r=p==null?null:typeof p=="function"?p:Hr(+p),m):r},m.startAngle=function(p){return arguments.length?(o=typeof p=="function"?p:Hr(+p),m):o},m.endAngle=function(p){return arguments.length?(l=typeof p=="function"?p:Hr(+p),m):l},m.padAngle=function(p){return arguments.length?(c=typeof p=="function"?p:Hr(+p),m):c},m.context=function(p){return arguments.length?(u=p??null,m):u},m}function U4e(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Q4e(e){this._context=e}Q4e.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,i){switch(e=+e,i=+i,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,i):this._context.moveTo(e,i);break;case 1:this._point=2;default:this._context.lineTo(e,i);break}}};function XCe(e){return new Q4e(e)}function j4e(e){return e[0]}function $4e(e){return e[1]}function q4e(e,i){var n=Hr(!0),r=null,o=XCe,l=null,c=hz(u);e=typeof e=="function"?e:e===void 0?j4e:Hr(e),i=typeof i=="function"?i:i===void 0?$4e:Hr(i);function u(f){var m,p=(f=U4e(f)).length,v,B=!1,G;for(r==null&&(l=o(G=c())),m=0;m<=p;++m)!(m=G;--T)u.point(k[T],F[T]);u.lineEnd(),u.areaEnd()}W&&(k[B]=+e(E,B,v),F[B]=+i(E,B,v),u.point(r?+r(E,B,v):k[B],n?+n(E,B,v):F[B]))}if(x)return u=null,x+""||null}function p(){return q4e().defined(o).curve(c).context(l)}return m.x=function(v){return arguments.length?(e=typeof v=="function"?v:Hr(+v),r=null,m):e},m.x0=function(v){return arguments.length?(e=typeof v=="function"?v:Hr(+v),m):e},m.x1=function(v){return arguments.length?(r=v==null?null:typeof v=="function"?v:Hr(+v),m):r},m.y=function(v){return arguments.length?(i=typeof v=="function"?v:Hr(+v),n=null,m):i},m.y0=function(v){return arguments.length?(i=typeof v=="function"?v:Hr(+v),m):i},m.y1=function(v){return arguments.length?(n=v==null?null:typeof v=="function"?v:Hr(+v),m):n},m.lineX0=m.lineY0=function(){return p().x(e).y(i)},m.lineY1=function(){return p().x(e).y(n)},m.lineX1=function(){return p().x(r).y(i)},m.defined=function(v){return arguments.length?(o=typeof v=="function"?v:Hr(!!v),m):o},m.curve=function(v){return arguments.length?(c=v,l!=null&&(u=c(l)),m):c},m.context=function(v){return arguments.length?(v==null?l=u=null:u=c(l=v),m):l},m}const Emi={draw(e,i){const n=Ry(i/LS);e.moveTo(n,0),e.arc(0,0,n,0,L4e)}};function Hmi(e,i){let n=null,r=hz(o);e=typeof e=="function"?e:Hr(e||Emi),i=typeof i=="function"?i:Hr(i===void 0?64:+i);function o(){let l;if(n||(n=l=r()),e.apply(this,arguments).draw(n,+i.apply(this,arguments)),l)return n=null,l+""||null}return o.type=function(l){return arguments.length?(e=typeof l=="function"?l:Hr(l),o):e},o.size=function(l){return arguments.length?(i=typeof l=="function"?l:Hr(+l),o):i},o.context=function(l){return arguments.length?(n=l??null,o):n},o}function Yp(){}function m3(e,i,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+i)/6,(e._y0+4*e._y1+n)/6)}function fz(e){this._context=e}fz.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:m3(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,i){switch(e=+e,i=+i,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,i):this._context.moveTo(e,i);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:m3(this,e,i);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=i}};function Wmi(e){return new fz(e)}function tQe(e){this._context=e}tQe.prototype={areaStart:Yp,areaEnd:Yp,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,i){switch(e=+e,i=+i,this._point){case 0:this._point=1,this._x2=e,this._y2=i;break;case 1:this._point=2,this._x3=e,this._y3=i;break;case 2:this._point=3,this._x4=e,this._y4=i,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+i)/6);break;default:m3(this,e,i);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=i}};function Nmi(e){return new tQe(e)}function iQe(e){this._context=e}iQe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,i){switch(e=+e,i=+i,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+i)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:m3(this,e,i);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=i}};function kmi(e){return new iQe(e)}function nQe(e,i){this._basis=new fz(e),this._beta=i}nQe.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var e=this._x,i=this._y,n=e.length-1;if(n>0)for(var r=e[0],o=i[0],l=e[n]-r,c=i[n]-o,u=-1,f;++u<=n;)f=u/n,this._basis.point(this._beta*e[u]+(1-this._beta)*(r+f*l),this._beta*i[u]+(1-this._beta)*(o+f*c));this._x=this._y=null,this._basis.lineEnd()},point:function(e,i){this._x.push(+e),this._y.push(+i)}};const Xmi=function e(i){function n(r){return i===1?new fz(r):new nQe(r,i)}return n.beta=function(r){return e(+r)},n}(.85);function p3(e,i,n){e._context.bezierCurveTo(e._x1+e._k*(e._x2-e._x0),e._y1+e._k*(e._y2-e._y0),e._x2+e._k*(e._x1-i),e._y2+e._k*(e._y1-n),e._x2,e._y2)}function xCe(e,i){this._context=e,this._k=(1-i)/6}xCe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:p3(this,this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,i){switch(e=+e,i=+i,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,i):this._context.moveTo(e,i);break;case 1:this._point=2,this._x1=e,this._y1=i;break;case 2:this._point=3;default:p3(this,e,i);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=i}};const xmi=function e(i){function n(r){return new xCe(r,i)}return n.tension=function(r){return e(+r)},n}(0);function DCe(e,i){this._context=e,this._k=(1-i)/6}DCe.prototype={areaStart:Yp,areaEnd:Yp,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x3,this._y3),this._context.closePath();break}case 2:{this._context.lineTo(this._x3,this._y3),this._context.closePath();break}case 3:{this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5);break}}},point:function(e,i){switch(e=+e,i=+i,this._point){case 0:this._point=1,this._x3=e,this._y3=i;break;case 1:this._point=2,this._context.moveTo(this._x4=e,this._y4=i);break;case 2:this._point=3,this._x5=e,this._y5=i;break;default:p3(this,e,i);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=i}};const Dmi=function e(i){function n(r){return new DCe(r,i)}return n.tension=function(r){return e(+r)},n}(0);function MCe(e,i){this._context=e,this._k=(1-i)/6}MCe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,i){switch(e=+e,i=+i,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:p3(this,e,i);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=i}};const Mmi=function e(i){function n(r){return new MCe(r,i)}return n.tension=function(r){return e(+r)},n}(0);function FCe(e,i,n){var r=e._x1,o=e._y1,l=e._x2,c=e._y2;if(e._l01_a>ms){var u=2*e._l01_2a+3*e._l01_a*e._l12_a+e._l12_2a,f=3*e._l01_a*(e._l01_a+e._l12_a);r=(r*u-e._x0*e._l12_2a+e._x2*e._l01_2a)/f,o=(o*u-e._y0*e._l12_2a+e._y2*e._l01_2a)/f}if(e._l23_a>ms){var m=2*e._l23_2a+3*e._l23_a*e._l12_a+e._l12_2a,p=3*e._l23_a*(e._l23_a+e._l12_a);l=(l*m+e._x1*e._l23_2a-i*e._l12_2a)/p,c=(c*m+e._y1*e._l23_2a-n*e._l12_2a)/p}e._context.bezierCurveTo(r,o,l,c,e._x2,e._y2)}function rQe(e,i){this._context=e,this._alpha=i}rQe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,i){if(e=+e,i=+i,this._point){var n=this._x2-e,r=this._y2-i;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,i):this._context.moveTo(e,i);break;case 1:this._point=2;break;case 2:this._point=3;default:FCe(this,e,i);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=i}};const Fmi=function e(i){function n(r){return i?new rQe(r,i):new xCe(r,0)}return n.alpha=function(r){return e(+r)},n}(.5);function gQe(e,i){this._context=e,this._alpha=i}gQe.prototype={areaStart:Yp,areaEnd:Yp,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x3,this._y3),this._context.closePath();break}case 2:{this._context.lineTo(this._x3,this._y3),this._context.closePath();break}case 3:{this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5);break}}},point:function(e,i){if(e=+e,i=+i,this._point){var n=this._x2-e,r=this._y2-i;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._x3=e,this._y3=i;break;case 1:this._point=2,this._context.moveTo(this._x4=e,this._y4=i);break;case 2:this._point=3,this._x5=e,this._y5=i;break;default:FCe(this,e,i);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=i}};const Ymi=function e(i){function n(r){return i?new gQe(r,i):new DCe(r,0)}return n.alpha=function(r){return e(+r)},n}(.5);function oQe(e,i){this._context=e,this._alpha=i}oQe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,i){if(e=+e,i=+i,this._point){var n=this._x2-e,r=this._y2-i;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha))}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:FCe(this,e,i);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=i}};const Kmi=function e(i){function n(r){return i?new oQe(r,i):new MCe(r,0)}return n.alpha=function(r){return e(+r)},n}(.5);function aQe(e){this._context=e}aQe.prototype={areaStart:Yp,areaEnd:Yp,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,i){e=+e,i=+i,this._point?this._context.lineTo(e,i):(this._point=1,this._context.moveTo(e,i))}};function _mi(e){return new aQe(e)}function ODe(e){return e<0?-1:1}function LDe(e,i,n){var r=e._x1-e._x0,o=i-e._x1,l=(e._y1-e._y0)/(r||o<0&&-0),c=(n-e._y1)/(o||r<0&&-0),u=(l*o+c*r)/(r+o);return(ODe(l)+ODe(c))*Math.min(Math.abs(l),Math.abs(c),.5*Math.abs(u))||0}function JDe(e,i){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-i)/2:i}function Uee(e,i,n){var r=e._x0,o=e._y0,l=e._x1,c=e._y1,u=(l-r)/3;e._context.bezierCurveTo(r+u,o+u*i,l-u,c-u*n,l,c)}function b3(e){this._context=e}b3.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:Uee(this,this._t0,JDe(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,i){var n=NaN;if(e=+e,i=+i,!(e===this._x1&&i===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,i):this._context.moveTo(e,i);break;case 1:this._point=2;break;case 2:this._point=3,Uee(this,JDe(this,n=LDe(this,e,i)),n);break;default:Uee(this,this._t0,n=LDe(this,e,i));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=i,this._t0=n}}};function sQe(e){this._context=new IQe(e)}(sQe.prototype=Object.create(b3.prototype)).point=function(e,i){b3.prototype.point.call(this,i,e)};function IQe(e){this._context=e}IQe.prototype={moveTo:function(e,i){this._context.moveTo(i,e)},closePath:function(){this._context.closePath()},lineTo:function(e,i){this._context.lineTo(i,e)},bezierCurveTo:function(e,i,n,r,o,l){this._context.bezierCurveTo(i,e,r,n,l,o)}};function Pmi(e){return new b3(e)}function zmi(e){return new sQe(e)}function lQe(e){this._context=e}lQe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,i=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],i[0]):this._context.moveTo(e[0],i[0]),n===2)this._context.lineTo(e[1],i[1]);else for(var r=UDe(e),o=UDe(i),l=0,c=1;c=0;--i)o[i]=(c[i]-o[i+1])/l[i];for(l[n-1]=(e[n]+o[n-1])/2,i=0;i=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,i){switch(e=+e,i=+i,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,i):this._context.moveTo(e,i);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,i),this._context.lineTo(e,i);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,i)}break}}this._x=e,this._y=i}};function Lmi(e){return new mz(e,.5)}function Jmi(e){return new mz(e,0)}function Umi(e){return new mz(e,1)}function Rp(e,i){if(typeof document<"u"&&document.createElement){const n=document.createElement("canvas");if(n&&n.getContext)return n.width=e,n.height=i,n}return null}const Qmi=()=>typeof Image<"u"?Image:null;function Zd(e,i){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(i).domain(e);break}return this}function s0(e,i){switch(arguments.length){case 0:break;case 1:{typeof e=="function"?this.interpolator(e):this.range(e);break}default:{this.domain(e),typeof i=="function"?this.interpolator(i):this.range(i);break}}return this}const Hge=Symbol("implicit");function YCe(){var e=new cDe,i=[],n=[],r=Hge;function o(l){let c=e.get(l);if(c===void 0){if(r!==Hge)return r;e.set(l,c=i.push(l)-1)}return n[c%n.length]}return o.domain=function(l){if(!arguments.length)return i.slice();i=[],e=new cDe;for(const c of l)e.has(c)||e.set(c,i.push(c)-1);return o},o.range=function(l){return arguments.length?(n=Array.from(l),o):n.slice()},o.unknown=function(l){return arguments.length?(r=l,o):r},o.copy=function(){return YCe(i,n).unknown(r)},Zd.apply(o,arguments),o}function Pw(e,i,n){e.prototype=i.prototype=n,n.constructor=e}function MW(e,i){var n=Object.create(e.prototype);for(var r in i)n[r]=i[r];return n}function I0(){}var vv=.7,JS=1/vv,IS="\\s*([+-]?\\d+)\\s*",kH="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Qu="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",jmi=/^#([0-9a-f]{3,8})$/,$mi=new RegExp(`^rgb\\(${IS},${IS},${IS}\\)$`),qmi=new RegExp(`^rgb\\(${Qu},${Qu},${Qu}\\)$`),epi=new RegExp(`^rgba\\(${IS},${IS},${IS},${kH}\\)$`),tpi=new RegExp(`^rgba\\(${Qu},${Qu},${Qu},${kH}\\)$`),ipi=new RegExp(`^hsl\\(${kH},${Qu},${Qu}\\)$`),npi=new RegExp(`^hsla\\(${kH},${Qu},${Qu},${kH}\\)$`),QDe={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Pw(I0,XH,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:jDe,formatHex:jDe,formatHex8:rpi,formatHsl:gpi,formatRgb:$De,toString:$De});function jDe(){return this.rgb().formatHex()}function rpi(){return this.rgb().formatHex8()}function gpi(){return CQe(this).formatHsl()}function $De(){return this.rgb().formatRgb()}function XH(e){var i,n;return e=(e+"").trim().toLowerCase(),(i=jmi.exec(e))?(n=i[1].length,i=parseInt(i[1],16),n===6?qDe(i):n===3?new Ia(i>>8&15|i>>4&240,i>>4&15|i&240,(i&15)<<4|i&15,1):n===8?mF(i>>24&255,i>>16&255,i>>8&255,(i&255)/255):n===4?mF(i>>12&15|i>>8&240,i>>8&15|i>>4&240,i>>4&15|i&240,((i&15)<<4|i&15)/255):null):(i=$mi.exec(e))?new Ia(i[1],i[2],i[3],1):(i=qmi.exec(e))?new Ia(i[1]*255/100,i[2]*255/100,i[3]*255/100,1):(i=epi.exec(e))?mF(i[1],i[2],i[3],i[4]):(i=tpi.exec(e))?mF(i[1]*255/100,i[2]*255/100,i[3]*255/100,i[4]):(i=ipi.exec(e))?i5e(i[1],i[2]/100,i[3]/100,1):(i=npi.exec(e))?i5e(i[1],i[2]/100,i[3]/100,i[4]):QDe.hasOwnProperty(e)?qDe(QDe[e]):e==="transparent"?new Ia(NaN,NaN,NaN,0):null}function qDe(e){return new Ia(e>>16&255,e>>8&255,e&255,1)}function mF(e,i,n,r){return r<=0&&(e=i=n=NaN),new Ia(e,i,n,r)}function KCe(e){return e instanceof I0||(e=XH(e)),e?(e=e.rgb(),new Ia(e.r,e.g,e.b,e.opacity)):new Ia}function y3(e,i,n,r){return arguments.length===1?KCe(e):new Ia(e,i,n,r??1)}function Ia(e,i,n,r){this.r=+e,this.g=+i,this.b=+n,this.opacity=+r}Pw(Ia,y3,MW(I0,{brighter(e){return e=e==null?JS:Math.pow(JS,e),new Ia(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?vv:Math.pow(vv,e),new Ia(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ia(zy(this.r),zy(this.g),zy(this.b),v3(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:e5e,formatHex:e5e,formatHex8:opi,formatRgb:t5e,toString:t5e}));function e5e(){return`#${Vy(this.r)}${Vy(this.g)}${Vy(this.b)}`}function opi(){return`#${Vy(this.r)}${Vy(this.g)}${Vy(this.b)}${Vy((isNaN(this.opacity)?1:this.opacity)*255)}`}function t5e(){const e=v3(this.opacity);return`${e===1?"rgb(":"rgba("}${zy(this.r)}, ${zy(this.g)}, ${zy(this.b)}${e===1?")":`, ${e})`}`}function v3(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function zy(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Vy(e){return e=zy(e),(e<16?"0":"")+e.toString(16)}function i5e(e,i,n,r){return r<=0?e=i=n=NaN:n<=0||n>=1?e=i=NaN:i<=0&&(e=NaN),new iA(e,i,n,r)}function CQe(e){if(e instanceof iA)return new iA(e.h,e.s,e.l,e.opacity);if(e instanceof I0||(e=XH(e)),!e)return new iA;if(e instanceof iA)return e;e=e.rgb();var i=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(i,n,r),l=Math.max(i,n,r),c=NaN,u=l-o,f=(l+o)/2;return u?(i===l?c=(n-r)/u+(n0&&f<1?0:c,new iA(c,u,f,e.opacity)}function Wge(e,i,n,r){return arguments.length===1?CQe(e):new iA(e,i,n,r??1)}function iA(e,i,n,r){this.h=+e,this.s=+i,this.l=+n,this.opacity=+r}Pw(iA,Wge,MW(I0,{brighter(e){return e=e==null?JS:Math.pow(JS,e),new iA(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?vv:Math.pow(vv,e),new iA(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,i=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*i,o=2*n-r;return new Ia(Qee(e>=240?e-240:e+120,o,r),Qee(e,o,r),Qee(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new iA(n5e(this.h),pF(this.s),pF(this.l),v3(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=v3(this.opacity);return`${e===1?"hsl(":"hsla("}${n5e(this.h)}, ${pF(this.s)*100}%, ${pF(this.l)*100}%${e===1?")":`, ${e})`}`}}));function n5e(e){return e=(e||0)%360,e<0?e+360:e}function pF(e){return Math.max(0,Math.min(1,e||0))}function Qee(e,i,n){return(e<60?i+(n-i)*e/60:e<180?n:e<240?i+(n-i)*(240-e)/60:i)*255}const cQe=Math.PI/180,AQe=180/Math.PI,Z3=18,uQe=.96422,dQe=1,hQe=.82521,fQe=4/29,lS=6/29,mQe=3*lS*lS,api=lS*lS*lS;function pQe(e){if(e instanceof ju)return new ju(e.l,e.a,e.b,e.opacity);if(e instanceof Mh)return bQe(e);e instanceof Ia||(e=KCe(e));var i=ete(e.r),n=ete(e.g),r=ete(e.b),o=jee((.2225045*i+.7168786*n+.0606169*r)/dQe),l,c;return i===n&&n===r?l=c=o:(l=jee((.4360747*i+.3850649*n+.1430804*r)/uQe),c=jee((.0139322*i+.0971045*n+.7141733*r)/hQe)),new ju(116*o-16,500*(l-o),200*(o-c),e.opacity)}function Nge(e,i,n,r){return arguments.length===1?pQe(e):new ju(e,i,n,r??1)}function ju(e,i,n,r){this.l=+e,this.a=+i,this.b=+n,this.opacity=+r}Pw(ju,Nge,MW(I0,{brighter(e){return new ju(this.l+Z3*(e??1),this.a,this.b,this.opacity)},darker(e){return new ju(this.l-Z3*(e??1),this.a,this.b,this.opacity)},rgb(){var e=(this.l+16)/116,i=isNaN(this.a)?e:e+this.a/500,n=isNaN(this.b)?e:e-this.b/200;return i=uQe*$ee(i),e=dQe*$ee(e),n=hQe*$ee(n),new Ia(qee(3.1338561*i-1.6168667*e-.4906146*n),qee(-.9787684*i+1.9161415*e+.033454*n),qee(.0719453*i-.2289914*e+1.4052427*n),this.opacity)}}));function jee(e){return e>api?Math.pow(e,1/3):e/mQe+fQe}function $ee(e){return e>lS?e*e*e:mQe*(e-fQe)}function qee(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function ete(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function spi(e){if(e instanceof Mh)return new Mh(e.h,e.c,e.l,e.opacity);if(e instanceof ju||(e=pQe(e)),e.a===0&&e.b===0)return new Mh(NaN,0=1?(n=1,i-1):Math.floor(n*i),o=e[r],l=e[r+1],c=r>0?e[r-1]:2*o-l,u=r()=>e;function GQe(e,i){return function(n){return e+n*i}}function lpi(e,i,n){return e=Math.pow(e,n),i=Math.pow(i,n)-e,n=1/n,function(r){return Math.pow(e+r*i,n)}}function yz(e,i){var n=i-e;return n?GQe(e,n>180||n<-180?n-360*Math.round(n/360):n):bz(isNaN(e)?i:e)}function Cpi(e){return(e=+e)==1?la:function(i,n){return n-i?lpi(i,n,e):bz(isNaN(i)?n:i)}}function la(e,i){var n=i-e;return n?GQe(e,n):bz(isNaN(e)?i:e)}const xge=function e(i){var n=Cpi(i);function r(o,l){var c=n((o=y3(o)).r,(l=y3(l)).r),u=n(o.g,l.g),f=n(o.b,l.b),m=la(o.opacity,l.opacity);return function(p){return o.r=c(p),o.g=u(p),o.b=f(p),o.opacity=m(p),o+""}}return r.gamma=e,r}(1);function SQe(e){return function(i){var n=i.length,r=new Array(n),o=new Array(n),l=new Array(n),c,u;for(c=0;cn&&(l=i.slice(n,l),u[c]?u[c]+=l:u[++c]=l),(r=r[0])===(o=o[0])?u[c]?u[c]+=o:u[++c]=o:(u[++c]=null,f.push({i:c,x:qc(r,o)})),n=tte.lastIndex;return n180?p+=360:p-m>180&&(m+=360),B.push({i:v.push(o(v)+"rotate(",null,r)-2,x:qc(m,p)})):p&&v.push(o(v)+"rotate("+p+r)}function u(m,p,v,B){m!==p?B.push({i:v.push(o(v)+"skewX(",null,r)-2,x:qc(m,p)}):p&&v.push(o(v)+"skewX("+p+r)}function f(m,p,v,B,G,T){if(m!==v||p!==B){var V=G.push(o(G)+"scale(",null,",",null,")");T.push({i:V-4,x:qc(m,v)},{i:V-2,x:qc(p,B)})}else(v!==1||B!==1)&&G.push(o(G)+"scale("+v+","+B+")")}return function(m,p){var v=[],B=[];return m=e(m),p=e(p),l(m.translateX,m.translateY,p.translateX,p.translateY,v,B),c(m.rotate,p.rotate,v,B),u(m.skewX,p.skewX,v,B),f(m.scaleX,m.scaleY,p.scaleX,p.scaleY,v,B),m=p=null,function(G){for(var T=-1,V=B.length,E;++Ti&&(n=e,e=i,i=n),function(r){return Math.max(e,Math.min(i,r))}}function Dpi(e,i,n){var r=e[0],o=e[1],l=i[0],c=i[1];return o2?Mpi:Dpi,f=m=null,v}function v(B){return B==null||isNaN(B=+B)?l:(f||(f=u(e.map(r),i,n)))(r(c(B)))}return v.invert=function(B){return c(o((m||(m=u(i,e.map(r),qc)))(B)))},v.domain=function(B){return arguments.length?(e=Array.from(B,Fge),p()):e.slice()},v.range=function(B){return arguments.length?(i=Array.from(B),p()):i.slice()},v.rangeRound=function(B){return i=Array.from(B),n=FW,p()},v.clamp=function(B){return arguments.length?(c=B?!0:jI,p()):c!==jI},v.interpolate=function(B){return arguments.length?(n=B,p()):n},v.unknown=function(B){return arguments.length?(l=B,v):l},function(B,G){return r=B,o=G,p()}}function xQe(){return vz()(jI,jI)}function Fpi(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function B3(e,i){if((n=(e=i?e.toExponential(i-1):e.toExponential()).indexOf("e"))<0)return null;var n,r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function US(e){return e=B3(Math.abs(e)),e?e[1]:NaN}function Ypi(e,i){return function(n,r){for(var o=n.length,l=[],c=0,u=e[0],f=0;o>0&&u>0&&(f+u+1>r&&(u=Math.max(1,r-f)),l.push(n.substring(o-=u,o+u)),!((f+=u+1)>r));)u=e[c=(c+1)%e.length];return l.reverse().join(i)}}function Kpi(e){return function(i){return i.replace(/[0-9]/g,function(n){return e[+n]})}}var _pi=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function DH(e){if(!(i=_pi.exec(e)))throw new Error("invalid format: "+e);var i;return new LCe({fill:i[1],align:i[2],sign:i[3],symbol:i[4],zero:i[5],width:i[6],comma:i[7],precision:i[8]&&i[8].slice(1),trim:i[9],type:i[10]})}DH.prototype=LCe.prototype;function LCe(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}LCe.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Ppi(e){e:for(var i=e.length,n=1,r=-1,o;n0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(o+1):e}var DQe;function zpi(e,i){var n=B3(e,i);if(!n)return e+"";var r=n[0],o=n[1],l=o-(DQe=Math.max(-8,Math.min(8,Math.floor(o/3)))*3)+1,c=r.length;return l===c?r:l>c?r+new Array(l-c+1).join("0"):l>0?r.slice(0,l)+"."+r.slice(l):"0."+new Array(1-l).join("0")+B3(e,Math.max(0,i+l-1))[0]}function l5e(e,i){var n=B3(e,i);if(!n)return e+"";var r=n[0],o=n[1];return o<0?"0."+new Array(-o).join("0")+r:r.length>o+1?r.slice(0,o+1)+"."+r.slice(o+1):r+new Array(o-r.length+2).join("0")}const C5e={"%":(e,i)=>(e*100).toFixed(i),b:e=>Math.round(e).toString(2),c:e=>e+"",d:Fpi,e:(e,i)=>e.toExponential(i),f:(e,i)=>e.toFixed(i),g:(e,i)=>e.toPrecision(i),o:e=>Math.round(e).toString(8),p:(e,i)=>l5e(e*100,i),r:l5e,s:zpi,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function c5e(e){return e}var A5e=Array.prototype.map,u5e=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Opi(e){var i=e.grouping===void 0||e.thousands===void 0?c5e:Ypi(A5e.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",r=e.currency===void 0?"":e.currency[1]+"",o=e.decimal===void 0?".":e.decimal+"",l=e.numerals===void 0?c5e:Kpi(A5e.call(e.numerals,String)),c=e.percent===void 0?"%":e.percent+"",u=e.minus===void 0?"−":e.minus+"",f=e.nan===void 0?"NaN":e.nan+"";function m(v){v=DH(v);var B=v.fill,G=v.align,T=v.sign,V=v.symbol,E=v.zero,W=v.width,x=v.comma,k=v.precision,F=v.trim,Y=v.type;Y==="n"?(x=!0,Y="g"):C5e[Y]||(k===void 0&&(k=12),F=!0,Y="g"),(E||B==="0"&&G==="=")&&(E=!0,B="0",G="=");var L=V==="$"?n:V==="#"&&/[boxX]/.test(Y)?"0"+Y.toLowerCase():"",O=V==="$"?r:/[%p]/.test(Y)?c:"",Q=C5e[Y],X=/[defgprs%]/.test(Y);k=k===void 0?6:/[gprs]/.test(Y)?Math.max(1,Math.min(21,k)):Math.max(0,Math.min(20,k));function $(ee){var ne=L,ge=O,Ae,_,de;if(Y==="c")ge=Q(ee)+ge,ee="";else{ee=+ee;var Ze=ee<0||1/ee<0;if(ee=isNaN(ee)?f:Q(Math.abs(ee),k),F&&(ee=Ppi(ee)),Ze&&+ee==0&&T!=="+"&&(Ze=!1),ne=(Ze?T==="("?T:u:T==="-"||T==="("?"":T)+ne,ge=(Y==="s"?u5e[8+DQe/3]:"")+ge+(Ze&&T==="("?")":""),X){for(Ae=-1,_=ee.length;++Ae<_;)if(de=ee.charCodeAt(Ae),48>de||de>57){ge=(de===46?o+ee.slice(Ae+1):ee.slice(Ae))+ge,ee=ee.slice(0,Ae);break}}}x&&!E&&(ee=i(ee,1/0));var me=ne.length+ee.length+ge.length,be=me>1)+ne+ee+ge+be.slice(me);break;default:ee=be+ne+ee+ge;break}return l(ee)}return $.toString=function(){return v+""},$}function p(v,B){var G=m((v=DH(v),v.type="f",v)),T=Math.max(-8,Math.min(8,Math.floor(US(B)/3)))*3,V=Math.pow(10,-T),E=u5e[8+T/3];return function(W){return G(V*W)+E}}return{format:m,formatPrefix:p}}var yF,JCe,MQe;Lpi({thousands:",",grouping:[3],currency:["$",""]});function Lpi(e){return yF=Opi(e),JCe=yF.format,MQe=yF.formatPrefix,yF}function Jpi(e){return Math.max(0,-US(Math.abs(e)))}function Upi(e,i){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(US(i)/3)))*3-US(Math.abs(e)))}function Qpi(e,i){return e=Math.abs(e),i=Math.abs(i)-e,Math.max(0,US(i)-US(e))+1}function FQe(e,i,n,r){var o=Mp(e,i,n),l;switch(r=DH(r??",f"),r.type){case"s":{var c=Math.max(Math.abs(e),Math.abs(i));return r.precision==null&&!isNaN(l=Upi(o,c))&&(r.precision=l),MQe(r,c)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(l=Qpi(o,Math.max(Math.abs(e),Math.abs(i))))&&(r.precision=l-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(l=Jpi(o))&&(r.precision=l-(r.type==="%")*2);break}}return JCe(r)}function nZ(e){var i=e.domain;return e.ticks=function(n){var r=i();return hge(r[0],r[r.length-1],n??10)},e.tickFormat=function(n,r){var o=i();return FQe(o[0],o[o.length-1],n??10,r)},e.nice=function(n){n==null&&(n=10);var r=i(),o=0,l=r.length-1,c=r[o],u=r[l],f,m,p=10;for(u0;){if(m=fge(c,u,n),m===f)return r[o]=c,r[l]=u,i(r);if(m>0)c=Math.floor(c/m)*m,u=Math.ceil(u/m)*m;else if(m<0)c=Math.ceil(c*m)/m,u=Math.floor(u*m)/m;else break;f=m}return e},e}function YQe(){var e=xQe();return e.copy=function(){return YW(e,YQe())},Zd.apply(e,arguments),nZ(e)}function KQe(e){var i;function n(r){return r==null||isNaN(r=+r)?i:r}return n.invert=n,n.domain=n.range=function(r){return arguments.length?(e=Array.from(r,Fge),n):e.slice()},n.unknown=function(r){return arguments.length?(i=r,n):i},n.copy=function(){return KQe(e).unknown(i)},e=arguments.length?Array.from(e,Fge):[0,1],nZ(n)}function _Qe(e,i){e=e.slice();var n=0,r=e.length-1,o=e[n],l=e[r],c;return lMath.pow(e,i)}function t0i(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),i=>Math.log(i)/e)}function f5e(e){return(i,n)=>-e(-i,n)}function UCe(e){const i=e(d5e,h5e),n=i.domain;let r=10,o,l;function c(){return o=t0i(r),l=e0i(r),n()[0]<0?(o=f5e(o),l=f5e(l),e(jpi,$pi)):e(d5e,h5e),i}return i.base=function(u){return arguments.length?(r=+u,c()):r},i.domain=function(u){return arguments.length?(n(u),c()):n()},i.ticks=u=>{const f=n();let m=f[0],p=f[f.length-1];const v=p0){for(;B<=G;++B)for(T=1;Tp)break;W.push(V)}}else for(;B<=G;++B)for(T=r-1;T>=1;--T)if(V=B>0?T/l(-B):T*l(B),!(Vp)break;W.push(V)}W.length*2{if(u==null&&(u=10),f==null&&(f=r===10?"s":","),typeof f!="function"&&(!(r%1)&&(f=DH(f)).precision==null&&(f.trim=!0),f=JCe(f)),u===1/0)return f;const m=Math.max(1,r*u/i.ticks().length);return p=>{let v=p/l(Math.round(o(p)));return v*rn(_Qe(n(),{floor:u=>l(Math.floor(o(u))),ceil:u=>l(Math.ceil(o(u)))})),i}function PQe(){const e=UCe(vz()).domain([1,10]);return e.copy=()=>YW(e,PQe()).base(e.base()),Zd.apply(e,arguments),e}function m5e(e){return function(i){return Math.sign(i)*Math.log1p(Math.abs(i/e))}}function p5e(e){return function(i){return Math.sign(i)*Math.expm1(Math.abs(i))*e}}function QCe(e){var i=1,n=e(m5e(i),p5e(i));return n.constant=function(r){return arguments.length?e(m5e(i=+r),p5e(i)):i},nZ(n)}function zQe(){var e=QCe(vz());return e.copy=function(){return YW(e,zQe()).constant(e.constant())},Zd.apply(e,arguments)}function b5e(e){return function(i){return i<0?-Math.pow(-i,e):Math.pow(i,e)}}function i0i(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function n0i(e){return e<0?-e*e:e*e}function jCe(e){var i=e(jI,jI),n=1;function r(){return n===1?e(jI,jI):n===.5?e(i0i,n0i):e(b5e(n),b5e(1/n))}return i.exponent=function(o){return arguments.length?(n=+o,r()):n},nZ(i)}function $Ce(){var e=jCe(vz());return e.copy=function(){return YW(e,$Ce()).exponent(e.exponent())},Zd.apply(e,arguments),e}function r0i(){return $Ce.apply(null,arguments).exponent(.5)}function OQe(){var e=[],i=[],n=[],r;function o(){var c=0,u=Math.max(1,i.length);for(n=new Array(u-1);++c0?n[u-1]:e[0],u=n?[r[n-1],i]:[r[m-1],r[m]]},c.unknown=function(f){return arguments.length&&(l=f),c},c.thresholds=function(){return r.slice()},c.copy=function(){return LQe().domain([e,i]).range(o).unknown(l)},Zd.apply(nZ(c),arguments)}function JQe(){var e=[.5],i=[0,1],n,r=1;function o(l){return l!=null&&l<=l?i[kW(e,l,0,r)]:n}return o.domain=function(l){return arguments.length?(e=Array.from(l),r=Math.min(e.length,i.length-1),o):e.slice()},o.range=function(l){return arguments.length?(i=Array.from(l),r=Math.min(e.length,i.length-1),o):i.slice()},o.invertExtent=function(l){var c=i.indexOf(l);return[e[c-1],e[c]]},o.unknown=function(l){return arguments.length?(n=l,o):n},o.copy=function(){return JQe().domain(e).range(i).unknown(n)},Zd.apply(o,arguments)}function g0i(e){return new Date(e)}function o0i(e){return e instanceof Date?+e:+new Date(+e)}function qCe(e,i,n,r,o,l,c,u,f,m){var p=xQe(),v=p.invert,B=p.domain,G=m(".%L"),T=m(":%S"),V=m("%I:%M"),E=m("%I %p"),W=m("%a %d"),x=m("%b %d"),k=m("%B"),F=m("%Y");function Y(L){return(f(L)0?r:1:0}const C0i="identity",QS="linear",Cf="log",KW="pow",_W="sqrt",Gz="symlog",Zv="time",Bv="utc",$u="sequential",zw="diverging",jS="quantile",Sz="quantize",wz="threshold",rce="ordinal",Kge="point",eje="band",gce="bin-ordinal",jo="continuous",PW="discrete",zW="discretizing",$C="interpolating",oce="temporal";function c0i(e){return function(i){let n=i[0],r=i[1],o;return r=r&&n[f]<=o&&(l<0&&(l=f),c=f);if(!(l<0))return r=e.invertExtent(n[l]),o=e.invertExtent(n[c]),[r[0]===void 0?r[1]:r[0],o[1]===void 0?o[0]:o[1]]}}function ace(){const e=YCe().unknown(void 0),i=e.domain,n=e.range;let r=[0,1],o,l,c=!1,u=0,f=0,m=.5;delete e.unknown;function p(){const v=i().length,B=r[1]V+o*W);return n(B?E.reverse():E)}return e.domain=function(v){return arguments.length?(i(v),p()):i()},e.range=function(v){return arguments.length?(r=[+v[0],+v[1]],p()):r.slice()},e.rangeRound=function(v){return r=[+v[0],+v[1]],c=!0,p()},e.bandwidth=function(){return l},e.step=function(){return o},e.round=function(v){return arguments.length?(c=!!v,p()):c},e.padding=function(v){return arguments.length?(f=Math.max(0,Math.min(1,v)),u=f,p()):u},e.paddingInner=function(v){return arguments.length?(u=Math.max(0,Math.min(1,v)),p()):u},e.paddingOuter=function(v){return arguments.length?(f=Math.max(0,Math.min(1,v)),p()):f},e.align=function(v){return arguments.length?(m=Math.max(0,Math.min(1,v)),p()):m},e.invertRange=function(v){if(v[0]==null||v[1]==null)return;const B=r[1]r[1-B])))return W=Math.max(0,I3(G,V)-1),x=V===E?W:I3(G,E)-1,V-G[W]>l+1e-10&&++W,B&&(k=W,W=T-x,x=T-k),W>x?void 0:i().slice(W,x+1)},e.invert=function(v){const B=e.invertRange([v,v]);return B&&B[0]},e.copy=function(){return ace().domain(i()).range(r).round(c).paddingInner(u).paddingOuter(f).align(m)},p()}function tje(e){const i=e.copy;return e.padding=e.paddingOuter,delete e.paddingInner,e.copy=function(){return tje(i())},e}function u0i(){return tje(ace().paddingInner(1))}var d0i=Array.prototype.map;function h0i(e){return d0i.call(e,Zs)}const f0i=Array.prototype.slice;function ije(){let e=[],i=[];function n(r){return r==null||r!==r?void 0:i[(kW(e,r)-1)%i.length]}return n.domain=function(r){return arguments.length?(e=h0i(r),n):e.slice()},n.range=function(r){return arguments.length?(i=f0i.call(r),n):i.slice()},n.tickFormat=function(r,o){return FQe(e[0],sr(e),r??10,o)},n.copy=function(){return ije().domain(n.domain()).range(n.range())},n}const G3=new Map,nje=Symbol("vega_scale");function rje(e){return e[nje]=!0,e}function m0i(e){return e&&e[nje]===!0}function p0i(e,i,n){const r=function(){const l=i();return l.invertRange||(l.invertRange=l.invert?c0i(l):l.invertExtent?A0i(l):void 0),l.type=e,rje(l)};return r.metadata=BA(pi(n)),r}function vr(e,i,n){return arguments.length>1?(G3.set(e,p0i(e,i,n)),this):gje(e)?G3.get(e):void 0}vr(C0i,KQe);vr(QS,YQe,jo);vr(Cf,PQe,[jo,Cf]);vr(KW,$Ce,jo);vr(_W,r0i,jo);vr(Gz,zQe,jo);vr(Zv,a0i,[jo,oce]);vr(Bv,s0i,[jo,oce]);vr($u,ece,[jo,$C]);vr(`${$u}-${QS}`,ece,[jo,$C]);vr(`${$u}-${Cf}`,UQe,[jo,$C,Cf]);vr(`${$u}-${KW}`,tce,[jo,$C]);vr(`${$u}-${_W}`,I0i,[jo,$C]);vr(`${$u}-${Gz}`,QQe,[jo,$C]);vr(`${zw}-${QS}`,jQe,[jo,$C]);vr(`${zw}-${Cf}`,$Qe,[jo,$C,Cf]);vr(`${zw}-${KW}`,ice,[jo,$C]);vr(`${zw}-${_W}`,l0i,[jo,$C]);vr(`${zw}-${Gz}`,qQe,[jo,$C]);vr(jS,OQe,[zW,jS]);vr(Sz,LQe,zW);vr(wz,JQe,zW);vr(gce,ije,[PW,zW]);vr(rce,YCe,PW);vr(eje,ace,PW);vr(Kge,u0i,PW);function gje(e){return G3.has(e)}function rZ(e,i){const n=G3.get(e);return n&&n.metadata[i]}function sce(e){return rZ(e,jo)}function $S(e){return rZ(e,PW)}function _ge(e){return rZ(e,zW)}function oje(e){return rZ(e,Cf)}function b0i(e){return rZ(e,oce)}function aje(e){return rZ(e,$C)}function sje(e){return rZ(e,jS)}const y0i=["clamp","base","constant","exponent"];function Ije(e,i){const n=i[0],r=sr(i)-n;return function(o){return e(n+o*r)}}function Tz(e,i,n){return OCe(Ice(i||"rgb",n),e)}function lje(e,i){const n=new Array(i),r=i+1;for(let o=0;oe[u]?c[u](e[u]()):0),c)}function Ice(e,i){const n=kpi[v0i(e)];return i!=null&&n&&n.gamma?n.gamma(i):n}function v0i(e){return"interpolate"+e.toLowerCase().split("-").map(i=>i[0].toUpperCase()+i.slice(1)).join("")}const Z0i={blues:"cfe1f2bed8eca8cee58fc1de74b2d75ba3cf4592c63181bd206fb2125ca40a4a90",greens:"d3eecdc0e6baabdda594d3917bc77d60ba6c46ab5e329a512089430e7735036429",greys:"e2e2e2d4d4d4c4c4c4b1b1b19d9d9d8888887575756262624d4d4d3535351e1e1e",oranges:"fdd8b3fdc998fdb87bfda55efc9244f87f2cf06b18e4580bd14904b93d029f3303",purples:"e2e1efd4d4e8c4c5e0b4b3d6a3a0cc928ec3827cb97566ae684ea25c3696501f8c",reds:"fdc9b4fcb49afc9e80fc8767fa7051f6573fec3f2fdc2a25c81b1db21218970b13",blueGreen:"d5efedc1e8e0a7ddd18bd2be70c6a958ba9144ad77319c5d2089460e7736036429",bluePurple:"ccddecbad0e4a8c2dd9ab0d4919cc98d85be8b6db28a55a6873c99822287730f71",greenBlue:"d3eecec5e8c3b1e1bb9bd8bb82cec269c2ca51b2cd3c9fc7288abd1675b10b60a1",orangeRed:"fddcaffdcf9bfdc18afdad77fb9562f67d53ee6545e24932d32d1ebf130da70403",purpleBlue:"dbdaebc8cee4b1c3de97b7d87bacd15b9fc93a90c01e7fb70b70ab056199045281",purpleBlueGreen:"dbd8eac8cee4b0c3de93b7d872acd1549fc83892bb1c88a3097f8702736b016353",purpleRed:"dcc9e2d3b3d7ce9eccd186c0da6bb2e14da0e23189d91e6fc61159ab07498f023a",redPurple:"fccfccfcbec0faa9b8f98faff571a5ec539ddb3695c41b8aa908808d0179700174",yellowGreen:"e4f4acd1eca0b9e2949ed68880c97c62bb6e47aa5e3297502083440e723b036034",yellowOrangeBrown:"feeaa1fedd84fecc63feb746fca031f68921eb7215db5e0bc54c05ab3d038f3204",yellowOrangeRed:"fee087fed16ffebd59fea849fd903efc7335f9522bee3423de1b20ca0b22af0225",blueOrange:"134b852f78b35da2cb9dcae1d2e5eff2f0ebfce0bafbbf74e8932fc5690d994a07",brownBlueGreen:"704108a0651ac79548e3c78af3e6c6eef1eac9e9e48ed1c74da79e187a72025147",purpleGreen:"5b1667834792a67fb6c9aed3e6d6e8eff0efd9efd5aedda971bb75368e490e5e29",purpleOrange:"4114696647968f83b7b9b4d6dadbebf3eeeafce0bafbbf74e8932fc5690d994a07",redBlue:"8c0d25bf363adf745ef4ae91fbdbc9f2efeed2e5ef9dcae15da2cb2f78b3134b85",redGrey:"8c0d25bf363adf745ef4ae91fcdccbfaf4f1e2e2e2c0c0c0969696646464343434",yellowGreenBlue:"eff9bddbf1b4bde5b594d5b969c5be45b4c22c9ec02182b82163aa23479c1c3185",redYellowBlue:"a50026d4322cf16e43fcac64fedd90faf8c1dcf1ecabd6e875abd04a74b4313695",redYellowGreen:"a50026d4322cf16e43fcac63fedd8df9f7aed7ee8ea4d86e64bc6122964f006837",pinkYellowGreen:"8e0152c0267edd72adf0b3d6faddedf5f3efe1f2cab6de8780bb474f9125276419",spectral:"9e0142d13c4bf0704afcac63fedd8dfbf8b0e0f3a1a9dda269bda94288b55e4fa2",viridis:"440154470e61481a6c482575472f7d443a834144873d4e8a39568c35608d31688e2d708e2a788e27818e23888e21918d1f988b1fa08822a8842ab07f35b77943bf7154c56866cc5d7ad1518fd744a5db36bcdf27d2e21be9e51afde725",magma:"0000040404130b0924150e3720114b2c11603b0f704a107957157e651a80721f817f24828c29819a2e80a8327db6377ac43c75d1426fde4968e95462f1605df76f5cfa7f5efc8f65fe9f6dfeaf78febf84fece91fddea0fcedaffcfdbf",inferno:"0000040403130c0826170c3b240c4f330a5f420a68500d6c5d126e6b176e781c6d86216b932667a12b62ae305cbb3755c73e4cd24644dd513ae65c30ed6925f3771af8850ffb9506fca50afcb519fac62df6d645f2e661f3f484fcffa4",plasma:"0d088723069033059742039d5002a25d01a66a00a87801a88405a7900da49c179ea72198b12a90ba3488c33d80cb4779d35171da5a69e16462e76e5bed7953f2834cf68f44fa9a3dfca636fdb32ffec029fcce25f9dc24f5ea27f0f921",cividis:"00205100235800265d002961012b65042e670831690d346b11366c16396d1c3c6e213f6e26426e2c456e31476e374a6e3c4d6e42506e47536d4c566d51586e555b6e5a5e6e5e616e62646f66676f6a6a706e6d717270717573727976737c79747f7c75827f758682768985778c8877908b78938e789691789a94789e9778a19b78a59e77a9a177aea575b2a874b6ab73bbaf71c0b26fc5b66dc9b96acebd68d3c065d8c462ddc85fe2cb5ce7cf58ebd355f0d652f3da4ff7de4cfae249fce647",rainbow:"6e40aa883eb1a43db3bf3cafd83fa4ee4395fe4b83ff576eff6659ff7847ff8c38f3a130e2b72fcfcc36bee044aff05b8ff4576ff65b52f6673af27828ea8d1ddfa319d0b81cbecb23abd82f96e03d82e14c6edb5a5dd0664dbf6e40aa",sinebow:"ff4040fc582af47218e78d0bd5a703bfbf00a7d5038de70b72f41858fc2a40ff402afc5818f4720be78d03d5a700bfbf03a7d50b8de71872f42a58fc4040ff582afc7218f48d0be7a703d5bf00bfd503a7e70b8df41872fc2a58ff4040",turbo:"23171b32204a3e2a71453493493eae4b49c54a53d7485ee44569ee4074f53c7ff8378af93295f72e9ff42ba9ef28b3e926bce125c5d925cdcf27d5c629dcbc2de3b232e9a738ee9d3ff39347f68950f9805afc7765fd6e70fe667cfd5e88fc5795fb51a1f84badf545b9f140c5ec3cd0e637dae034e4d931ecd12ef4c92bfac029ffb626ffad24ffa223ff9821ff8d1fff821dff771cfd6c1af76118f05616e84b14df4111d5380fcb2f0dc0260ab61f07ac1805a313029b0f00950c00910b00",browns:"eedbbdecca96e9b97ae4a865dc9856d18954c7784cc0673fb85536ad44339f3632",tealBlues:"bce4d89dd3d181c3cb65b3c245a2b9368fae347da0306a932c5985",teals:"bbdfdfa2d4d58ac9c975bcbb61b0af4da5a43799982b8b8c1e7f7f127273006667",warmGreys:"dcd4d0cec5c1c0b8b4b3aaa7a59c9998908c8b827f7e7673726866665c5a59504e",goldGreen:"f4d166d5ca60b6c35c98bb597cb25760a6564b9c533f8f4f33834a257740146c36",goldOrange:"f4d166f8be5cf8aa4cf5983bf3852aef701be2621fd65322c54923b142239e3a26",goldRed:"f4d166f6be59f9aa51fc964ef6834bee734ae56249db5247cf4244c43141b71d3e",lightGreyRed:"efe9e6e1dad7d5cbc8c8bdb9bbaea9cd967ddc7b43e15f19df4011dc000b",lightGreyTeal:"e4eaead6dcddc8ced2b7c2c7a6b4bc64b0bf22a6c32295c11f85be1876bc",lightMulti:"e0f1f2c4e9d0b0de9fd0e181f6e072f6c053f3993ef77440ef4a3c",lightOrange:"f2e7daf7d5baf9c499fab184fa9c73f68967ef7860e8645bde515bd43d5b",lightTealBlue:"e3e9e0c0dccf9aceca7abfc859afc0389fb9328dad2f7ca0276b95255988",darkBlue:"3232322d46681a5c930074af008cbf05a7ce25c0dd38daed50f3faffffff",darkGold:"3c3c3c584b37725e348c7631ae8b2bcfa424ecc31ef9de30fff184ffffff",darkGreen:"3a3a3a215748006f4d048942489e4276b340a6c63dd2d836ffeb2cffffaa",darkMulti:"3737371f5287197d8c29a86995ce3fffe800ffffff",darkRed:"3434347036339e3c38cc4037e75d1eec8620eeab29f0ce32ffeb2c"},B0i={category10:"1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf",category20:"1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5",category20b:"393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6",category20c:"3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9",tableau10:"4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac",tableau20:"4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5",accent:"7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666",dark2:"1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666",paired:"a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928",pastel1:"fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2",pastel2:"b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc",set1:"e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999",set2:"66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3",set3:"8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"};function cje(e){const i=e.length/6|0,n=new Array(i);for(let r=0;rTz(cje(e)));function lce(e,i){return e=e&&e.toLowerCase(),arguments.length>1?(y5e[e]=i,this):y5e[e]}const RY="symbol",G0i="discrete",S0i="gradient",w0i=e=>Pt(e)?e.map(i=>String(i)):String(e),T0i=(e,i)=>e[1]-i[1],R0i=(e,i)=>i[1]-e[1];function Cce(e,i,n){let r;return jr(i)&&(e.bins&&(i=Math.max(i,e.bins.length)),n!=null&&(i=Math.min(i,Math.floor(WW(e.domain())/n||1)))),vi(i)&&(r=i.step,i=i.interval),fi(i)&&(i=e.type===Zv?Yw(i):e.type==Bv?Kw(i):Yt("Only time and utc scales accept interval strings."),r&&(i=i.every(r))),i}function uje(e,i,n){let r=e.range(),o=r[0],l=sr(r),c=T0i;if(o>l&&(r=l,l=o,o=r,c=R0i),o=Math.floor(o),l=Math.ceil(l),i=i.map(u=>[u,e(u)]).filter(u=>o<=u[1]&&u[1]<=l).sort(c).map(u=>u[0]),n>0&&i.length>1){const u=[i[0],sr(i)];for(;i.length>n&&i.length>=3;)i=i.filter((f,m)=>!(m%2));i.length<3&&(i=u)}return i}function cce(e,i){return e.bins?uje(e,e.bins):e.ticks?e.ticks(i):e.domain()}function dje(e,i,n,r,o,l){const c=i.type;let u=w0i;if(c===Zv||o===Zv)u=e.timeFormat(r);else if(c===Bv||o===Bv)u=e.utcFormat(r);else if(oje(c)){const f=e.formatFloat(r);if(l||i.bins)u=f;else{const m=hje(i,n,!1);u=p=>m(p)?f(p):""}}else if(i.tickFormat){const f=i.domain();u=e.formatSpan(f[0],f[f.length-1],n,r)}else r&&(u=e.format(r));return u}function hje(e,i,n){const r=cce(e,i),o=e.base(),l=Math.log(o),c=Math.max(1,o*i/r.length),u=f=>{let m=f/Math.pow(o,Math.round(Math.log(f)/l));return m*o1?r[1]-r[0]:r[0],c;for(c=1;cPge[e.type]||e.bins;function pje(e,i,n,r,o,l,c){const u=fje[i.type]&&l!==Zv&&l!==Bv?V0i(e,i,o):dje(e,i,n,o,l,c);return r===RY&&W0i(i)?N0i(u):r===G0i?k0i(u):X0i(u)}const N0i=e=>(i,n,r)=>{const o=v5e(r[n+1],v5e(r.max,1/0)),l=Z5e(i,e),c=Z5e(o,e);return l&&c?l+" – "+c:c?"< "+c:"≥ "+l},v5e=(e,i)=>e??i,k0i=e=>(i,n)=>n?e(i):null,X0i=e=>i=>e(i),Z5e=(e,i)=>Number.isFinite(e)?i(e):null;function x0i(e){const i=e.domain(),n=i.length-1;let r=+i[0],o=+sr(i),l=o-r;if(e.type===wz){const c=n?l/n:.1;r-=c,o+=c,l=o-r}return c=>(c-r)/l}function D0i(e,i,n,r){const o=r||i.type;return fi(n)&&b0i(o)&&(n=n.replace(/%a/g,"%A").replace(/%b/g,"%B")),!n&&o===Zv?e.timeFormat("%A, %d %B %Y, %X"):!n&&o===Bv?e.utcFormat("%A, %d %B %Y, %X UTC"):pje(e,i,5,null,n,r,!0)}function bje(e,i,n){n=n||{};const r=Math.max(3,n.maxlen||7),o=D0i(e,i,n.format,n.formatType);if(_ge(i.type)){const l=mje(i).slice(1).map(o),c=l.length;return`${c} boundar${c===1?"y":"ies"}: ${l.join(", ")}`}else if($S(i.type)){const l=i.domain(),c=l.length,u=c>r?l.slice(0,r-2).map(o).join(", ")+", ending with "+l.slice(-1).map(o):l.map(o).join(", ");return`${c} value${c===1?"":"s"}: ${u}`}else{const l=i.domain();return`values from ${o(l[0])} to ${o(sr(l))}`}}let yje=0;function M0i(){yje=0}const S3="p_";function Ace(e){return e&&e.gradient}function vje(e,i,n){const r=e.gradient;let o=e.id,l=r==="radial"?S3:"";return o||(o=e.id="gradient_"+yje++,r==="radial"?(e.x1=Su(e.x1,.5),e.y1=Su(e.y1,.5),e.r1=Su(e.r1,0),e.x2=Su(e.x2,.5),e.y2=Su(e.y2,.5),e.r2=Su(e.r2,.5),l=S3):(e.x1=Su(e.x1,0),e.y1=Su(e.y1,0),e.x2=Su(e.x2,1),e.y2=Su(e.y2,0))),i[o]=e,"url("+(n||"")+"#"+l+o+")"}function Su(e,i){return e??i}function Zje(e,i){var n=[],r;return r={gradient:"linear",x1:e?e[0]:0,y1:e?e[1]:0,x2:i?i[0]:1,y2:i?i[1]:0,stops:n,stop:function(o,l){return n.push({offset:o,color:l}),r}}}const B5e={basis:{curve:Wmi},"basis-closed":{curve:Nmi},"basis-open":{curve:kmi},bundle:{curve:Xmi,tension:"beta",value:.85},cardinal:{curve:xmi,tension:"tension",value:0},"cardinal-open":{curve:Mmi,tension:"tension",value:0},"cardinal-closed":{curve:Dmi,tension:"tension",value:0},"catmull-rom":{curve:Fmi,tension:"alpha",value:.5},"catmull-rom-closed":{curve:Ymi,tension:"alpha",value:.5},"catmull-rom-open":{curve:Kmi,tension:"alpha",value:.5},linear:{curve:XCe},"linear-closed":{curve:_mi},monotone:{horizontal:zmi,vertical:Pmi},natural:{curve:Omi},step:{curve:Lmi},"step-after":{curve:Umi},"step-before":{curve:Jmi}};function uce(e,i,n){var r=Oi(B5e,e)&&B5e[e],o=null;return r&&(o=r.curve||r[i||"vertical"],r.tension&&n!=null&&(o=o[r.tension](n))),o}const F0i={m:2,l:2,h:1,v:1,z:0,c:6,s:4,q:4,t:2,a:7},Y0i=/[mlhvzcsqta]([^mlhvzcsqta]+|$)/gi,K0i=/^[+-]?(([0-9]*\.[0-9]+)|([0-9]+\.)|([0-9]+))([eE][+-]?[0-9]+)?/,_0i=/^((\s+,?\s*)|(,\s*))/,P0i=/^[01]/;function qS(e){const i=[];return(e.match(Y0i)||[]).forEach(r=>{let o=r[0];const l=o.toLowerCase(),c=F0i[l],u=z0i(l,c,r.slice(1).trim()),f=u.length;if(f1&&(V=Math.sqrt(V),n*=V,r*=V);const E=B/n,W=v/n,x=-v/r,k=B/r,F=E*u+W*f,Y=x*u+k*f,L=E*e+W*i,O=x*e+k*i;let X=1/((L-F)*(L-F)+(O-Y)*(O-Y))-.25;X<0&&(X=0);let $=Math.sqrt(X);l==o&&($=-$);const ee=.5*(F+L)-$*(O-Y),ne=.5*(Y+O)+$*(L-F),ge=Math.atan2(Y-ne,F-ee);let _=Math.atan2(O-ne,L-ee)-ge;_<0&&l===1?_+=Du:_>0&&l===0&&(_-=Du);const de=Math.ceil(Math.abs(_/(my+.001))),Ze=[];for(let me=0;me+e}function vF(e,i,n){return Math.max(i,Math.min(e,n))}function Sje(){var e=j0i,i=$0i,n=q0i,r=ebi,o=fh(0),l=o,c=o,u=o,f=null;function m(p,v,B){var G,T=v??+e.call(this,p),V=B??+i.call(this,p),E=+n.call(this,p),W=+r.call(this,p),x=Math.min(E,W)/2,k=vF(+o.call(this,p),0,x),F=vF(+l.call(this,p),0,x),Y=vF(+c.call(this,p),0,x),L=vF(+u.call(this,p),0,x);if(f||(f=G=dz()),k<=0&&F<=0&&Y<=0&&L<=0)f.rect(T,V,E,W);else{var O=T+E,Q=V+W;f.moveTo(T+k,V),f.lineTo(O-F,V),f.bezierCurveTo(O-km*F,V,O,V+km*F,O,V+F),f.lineTo(O,Q-L),f.bezierCurveTo(O,Q-km*L,O-km*L,Q,O-L,Q),f.lineTo(T+Y,Q),f.bezierCurveTo(T+km*Y,Q,T,Q-km*Y,T,Q-Y),f.lineTo(T,V+k),f.bezierCurveTo(T,V+km*k,T+km*k,V,T+k,V),f.closePath()}if(G)return f=null,G+""||null}return m.x=function(p){return arguments.length?(e=fh(p),m):e},m.y=function(p){return arguments.length?(i=fh(p),m):i},m.width=function(p){return arguments.length?(n=fh(p),m):n},m.height=function(p){return arguments.length?(r=fh(p),m):r},m.cornerRadius=function(p,v,B,G){return arguments.length?(o=fh(p),l=v!=null?fh(v):o,u=B!=null?fh(B):o,c=G!=null?fh(G):l,m):o},m.context=function(p){return arguments.length?(f=p??null,m):f},m}function wje(){var e,i,n,r,o=null,l,c,u,f;function m(v,B,G){const T=G/2;if(l){var V=u-B,E=v-c;if(V||E){var W=Math.sqrt(V*V+E*E),x=(V/=W)*f,k=(E/=W)*f,F=Math.atan2(E,V);o.moveTo(c-x,u-k),o.lineTo(v-V*T,B-E*T),o.arc(v,B,T,F-Math.PI,F),o.lineTo(c+x,u+k),o.arc(c,u,f,F,F+Math.PI)}else o.arc(v,B,T,0,Du);o.closePath()}else l=1;c=v,u=B,f=T}function p(v){var B,G=v.length,T,V=!1,E;for(o==null&&(o=E=dz()),B=0;B<=G;++B)!(Be.x||0,JW=e=>e.y||0,tbi=e=>e.width||0,ibi=e=>e.height||0,nbi=e=>(e.x||0)+(e.width||0),rbi=e=>(e.y||0)+(e.height||0),gbi=e=>e.startAngle||0,obi=e=>e.endAngle||0,abi=e=>e.padAngle||0,sbi=e=>e.innerRadius||0,Ibi=e=>e.outerRadius||0,lbi=e=>e.cornerRadius||0,Cbi=e=>OW(e.cornerRadiusTopLeft,e.cornerRadius)||0,cbi=e=>OW(e.cornerRadiusTopRight,e.cornerRadius)||0,Abi=e=>OW(e.cornerRadiusBottomRight,e.cornerRadius)||0,ubi=e=>OW(e.cornerRadiusBottomLeft,e.cornerRadius)||0,dbi=e=>OW(e.size,64),hbi=e=>e.size||1,Rz=e=>e.defined!==!1,fbi=e=>Gje(e.shape||"circle"),mbi=Vmi().startAngle(gbi).endAngle(obi).padAngle(abi).innerRadius(sbi).outerRadius(Ibi).cornerRadius(lbi),pbi=eQe().x(LW).y1(JW).y0(rbi).defined(Rz),bbi=eQe().y(JW).x1(LW).x0(nbi).defined(Rz),ybi=q4e().x(LW).y(JW).defined(Rz),vbi=Sje().x(LW).y(JW).width(tbi).height(ibi).cornerRadius(Cbi,cbi,Abi,ubi),Zbi=Hmi().type(fbi).size(dbi),Bbi=wje().x(LW).y(JW).defined(Rz).size(hbi);function dce(e){return e.cornerRadius||e.cornerRadiusTopLeft||e.cornerRadiusTopRight||e.cornerRadiusBottomRight||e.cornerRadiusBottomLeft}function Gbi(e,i){return mbi.context(e)(i)}function Sbi(e,i){const n=i[0],r=n.interpolate||"linear";return(n.orient==="horizontal"?bbi:pbi).curve(uce(r,n.orient,n.tension)).context(e)(i)}function wbi(e,i){const n=i[0],r=n.interpolate||"linear";return ybi.curve(uce(r,n.orient,n.tension)).context(e)(i)}function Ow(e,i,n,r){return vbi.context(e)(i,n,r)}function Tbi(e,i){return(i.mark.shape||i.shape).context(e)(i)}function Rbi(e,i){return Zbi.context(e)(i)}function Vbi(e,i){return Bbi.context(e)(i)}var Tje=1;function Rje(){Tje=1}function hce(e,i,n){var r=i.clip,o=e._defs,l=i.clip_id||(i.clip_id="clip"+Tje++),c=o.clipping[l]||(o.clipping[l]={id:l});return Rn(r)?c.path=r(null):dce(n)?c.path=Ow(null,n,0,0):(c.width=n.width||0,c.height=n.height||0),"url(#"+l+")"}function Eo(e){this.clear(),e&&this.union(e)}Eo.prototype={clone(){return new Eo(this)},clear(){return this.x1=+Number.MAX_VALUE,this.y1=+Number.MAX_VALUE,this.x2=-Number.MAX_VALUE,this.y2=-Number.MAX_VALUE,this},empty(){return this.x1===+Number.MAX_VALUE&&this.y1===+Number.MAX_VALUE&&this.x2===-Number.MAX_VALUE&&this.y2===-Number.MAX_VALUE},equals(e){return this.x1===e.x1&&this.y1===e.y1&&this.x2===e.x2&&this.y2===e.y2},set(e,i,n,r){return nthis.x2&&(this.x2=e),i>this.y2&&(this.y2=i),this},expand(e){return this.x1-=e,this.y1-=e,this.x2+=e,this.y2+=e,this},round(){return this.x1=Math.floor(this.x1),this.y1=Math.floor(this.y1),this.x2=Math.ceil(this.x2),this.y2=Math.ceil(this.y2),this},scale(e){return this.x1*=e,this.y1*=e,this.x2*=e,this.y2*=e,this},translate(e,i){return this.x1+=e,this.x2+=e,this.y1+=i,this.y2+=i,this},rotate(e,i,n){const r=this.rotatedPoints(e,i,n);return this.clear().add(r[0],r[1]).add(r[2],r[3]).add(r[4],r[5]).add(r[6],r[7])},rotatedPoints(e,i,n){var{x1:r,y1:o,x2:l,y2:c}=this,u=Math.cos(e),f=Math.sin(e),m=i-i*u+n*f,p=n-i*f-n*u;return[u*r-f*o+m,f*r+u*o+p,u*r-f*c+m,f*r+u*c+p,u*l-f*o+m,f*l+u*o+p,u*l-f*c+m,f*l+u*c+p]},union(e){return e.x1this.x2&&(this.x2=e.x2),e.y2>this.y2&&(this.y2=e.y2),this},intersect(e){return e.x1>this.x1&&(this.x1=e.x1),e.y1>this.y1&&(this.y1=e.y1),e.x2=e.x2&&this.y1<=e.y1&&this.y2>=e.y2},alignsWith(e){return e&&(this.x1==e.x1||this.x2==e.x2||this.y1==e.y1||this.y2==e.y2)},intersects(e){return e&&!(this.x2e.x2||this.y2e.y2)},contains(e,i){return!(ethis.x2||ithis.y2)},width(){return this.x2-this.x1},height(){return this.y2-this.y1}};function Vz(e){this.mark=e,this.bounds=this.bounds||new Eo}function Ez(e){Vz.call(this,e),this.items=this.items||[]}si(Ez,Vz);function fce(e){this._pending=0,this._loader=e||nz()}function T5e(e){e._pending+=1}function o9(e){e._pending-=1}fce.prototype={pending(){return this._pending},sanitizeURL(e){const i=this;return T5e(i),i._loader.sanitize(e,{context:"href"}).then(n=>(o9(i),n)).catch(()=>(o9(i),null))},loadImage(e){const i=this,n=Qmi();return T5e(i),i._loader.sanitize(e,{context:"image"}).then(r=>{const o=r.href;if(!o||!n)throw{url:o};const l=new n,c=Oi(r,"crossOrigin")?r.crossOrigin:"anonymous";return c!=null&&(l.crossOrigin=c),l.onload=()=>o9(i),l.onerror=()=>o9(i),l.src=o,l}).catch(r=>(o9(i),{complete:!1,width:0,height:0,src:r&&r.url||""}))},ready(){const e=this;return new Promise(i=>{function n(r){e.pending()?setTimeout(()=>{n(!0)},10):i(r)}n(!1)})}};function pf(e,i,n){if(i.stroke&&i.opacity!==0&&i.strokeOpacity!==0){const r=i.strokeWidth!=null?+i.strokeWidth:1;e.expand(r+(n?Ebi(i,r):0))}return e}function Ebi(e,i){return e.strokeJoin&&e.strokeJoin!=="miter"?0:i}const Hbi=Du-1e-8;let Hz,VY,EY,Ey,zge,HY,Oge,Lge;const gp=(e,i)=>Hz.add(e,i),WY=(e,i)=>gp(VY=e,EY=i),R5e=e=>gp(e,Hz.y1),V5e=e=>gp(Hz.x1,e),py=(e,i)=>zge*e+Oge*i,by=(e,i)=>HY*e+Lge*i,gte=(e,i)=>gp(py(e,i),by(e,i)),ote=(e,i)=>WY(py(e,i),by(e,i));function UW(e,i){return Hz=e,i?(Ey=i*Kp,zge=Lge=Math.cos(Ey),HY=Math.sin(Ey),Oge=-HY):(zge=Lge=1,Ey=HY=Oge=0),Wbi}const Wbi={beginPath(){},closePath(){},moveTo:ote,lineTo:ote,rect(e,i,n,r){Ey?(gte(e+n,i),gte(e+n,i+r),gte(e,i+r),ote(e,i)):(gp(e+n,i+r),WY(e,i))},quadraticCurveTo(e,i,n,r){const o=py(e,i),l=by(e,i),c=py(n,r),u=by(n,r);E5e(VY,o,c,R5e),E5e(EY,l,u,V5e),WY(c,u)},bezierCurveTo(e,i,n,r,o,l){const c=py(e,i),u=by(e,i),f=py(n,r),m=by(n,r),p=py(o,l),v=by(o,l);H5e(VY,c,f,p,R5e),H5e(EY,u,m,v,V5e),WY(p,v)},arc(e,i,n,r,o,l){if(r+=Ey,o+=Ey,VY=n*Math.cos(o)+e,EY=n*Math.sin(o)+i,Math.abs(o-r)>Hbi)gp(e-n,i-n),gp(e+n,i+n);else{const c=m=>gp(n*Math.cos(m)+e,n*Math.sin(m)+i);let u,f;if(c(r),c(o),o!==r)if(r=r%Du,r<0&&(r+=Du),o=o%Du,o<0&&(o+=Du),oo;++f,u-=my)c(u);else for(u=r-r%my+my,f=0;f<4&&uO0i?(p=c*c+u*l,p>=0&&(p=Math.sqrt(p),f=(-c+p)/l,m=(-c-p)/l)):f=.5*u/c,0B)return!1;V>v&&(v=V)}else if(G>0){if(V0?(e.globalAlpha=n,e.fillStyle=Hje(e,i,i.fill),!0):!1}var kbi=[];function tw(e,i,n){var r=(r=i.strokeWidth)!=null?r:1;return r<=0?!1:(n*=i.strokeOpacity==null?1:i.strokeOpacity,n>0?(e.globalAlpha=n,e.strokeStyle=Hje(e,i,i.stroke),e.lineWidth=r,e.lineCap=i.strokeCap||"butt",e.lineJoin=i.strokeJoin||"miter",e.miterLimit=i.strokeMiterLimit||10,e.setLineDash&&(e.setLineDash(i.strokeDash||kbi),e.lineDashOffset=i.strokeDashOffset||0),!0):!1)}function Xbi(e,i){return e.zindex-i.zindex||e.index-i.index}function bce(e){if(!e.zdirty)return e.zitems;var i=e.items,n=[],r,o,l;for(o=0,l=i.length;o=0;)if(r=i(n[o]))return r;if(n===l){for(n=e.items,o=n.length;--o>=0;)if(!n[o].zindex&&(r=i(n[o])))return r}return null}function yce(e){return function(i,n,r){SA(n,o=>{(!r||r.intersects(o.bounds))&&Wje(e,i,o,o)})}}function xbi(e){return function(i,n,r){n.items.length&&(!r||r.intersects(n.bounds))&&Wje(e,i,n.items[0],n.items)}}function Wje(e,i,n,r){var o=n.opacity==null?1:n.opacity;o!==0&&(e(i,r)||(ew(i,n),n.fill&&w3(i,n,o)&&i.fill(),n.stroke&&tw(i,n,o)&&i.stroke()))}function Wz(e){return e=e||OC,function(i,n,r,o,l,c){return r*=i.pixelRatio,o*=i.pixelRatio,T3(n,u=>{const f=u.bounds;if(!(f&&!f.contains(l,c)||!f)&&e(i,u,r,o,l,c))return u})}}function QW(e,i){return function(n,r,o,l){var c=Array.isArray(r)?r[0]:r,u=i??c.fill,f=c.stroke&&n.isPointInStroke,m,p;return f&&(m=c.strokeWidth,p=c.strokeCap,n.lineWidth=m??1,n.lineCap=p??"butt"),e(n,r)?!1:u&&n.isPointInPath(o,l)||f&&n.isPointInStroke(o,l)}}function vce(e){return Wz(QW(e))}function Ly(e,i){return"translate("+e+","+i+")"}function Zce(e){return"rotate("+e+")"}function Dbi(e,i){return"scale("+e+","+i+")"}function Nje(e){return Ly(e.x||0,e.y||0)}function Mbi(e){return Ly(e.x||0,e.y||0)+(e.angle?" "+Zce(e.angle):"")}function Fbi(e){return Ly(e.x||0,e.y||0)+(e.angle?" "+Zce(e.angle):"")+(e.scaleX||e.scaleY?" "+Dbi(e.scaleX||1,e.scaleY||1):"")}function Bce(e,i,n){function r(c,u){c("transform",Mbi(u)),c("d",i(null,u))}function o(c,u){return i(UW(c,u.angle),u),pf(c,u).translate(u.x||0,u.y||0)}function l(c,u){var f=u.x||0,m=u.y||0,p=u.angle||0;c.translate(f,m),p&&c.rotate(p*=Kp),c.beginPath(),i(c,u),p&&c.rotate(-p),c.translate(-f,-m)}return{type:e,tag:"path",nested:!1,attr:r,bound:o,draw:yce(l),pick:vce(l),isect:n||mce(l)}}var Ybi=Bce("arc",Gbi);function Kbi(e,i){for(var n=e[0].orient==="horizontal"?i[1]:i[0],r=e[0].orient==="horizontal"?"y":"x",o=e.length,l=1/0,c,u;--o>=0;)e[o].defined!==!1&&(u=Math.abs(e[o][r]-n),u=0;)if(e[r].defined!==!1&&(o=e[r].x-i[0],l=e[r].y-i[1],c=o*o+l*l,c=0;)if(e[n].defined!==!1&&(r=e[n].x-i[0],o=e[n].y-i[1],l=r*r+o*o,r=e[n].size||1,l.5&&i<1.5?.5-Math.abs(i-1):0}function Lbi(e,i){e("transform",Nje(i))}function xje(e,i){const n=Xje(i);e("d",Ow(null,i,n,n))}function Jbi(e,i){e("class","background"),e("aria-hidden",!0),xje(e,i)}function Ubi(e,i){e("class","foreground"),e("aria-hidden",!0),i.strokeForeground?xje(e,i):e("d","")}function Qbi(e,i,n){const r=i.clip?hce(n,i,i):null;e("clip-path",r)}function jbi(e,i){if(!i.clip&&i.items){const n=i.items,r=n.length;for(let o=0;o{const o=r.x||0,l=r.y||0,c=r.strokeForeground,u=r.opacity==null?1:r.opacity;(r.stroke||r.fill)&&u&&(FH(e,r,o,l),ew(e,r),r.fill&&w3(e,r,u)&&e.fill(),r.stroke&&!c&&tw(e,r,u)&&e.stroke()),e.save(),e.translate(o,l),r.clip&&kje(e,r),n&&n.translate(-o,-l),SA(r,f=>{this.draw(e,f,n)}),n&&n.translate(o,l),e.restore(),c&&r.stroke&&u&&(FH(e,r,o,l),ew(e,r),tw(e,r,u)&&e.stroke())})}function iyi(e,i,n,r,o,l){if(i.bounds&&!i.bounds.contains(o,l)||!i.items)return null;const c=n*e.pixelRatio,u=r*e.pixelRatio;return T3(i,f=>{let m,p,v;const B=f.bounds;if(B&&!B.contains(o,l))return;p=f.x||0,v=f.y||0;const G=p+(f.width||0),T=v+(f.height||0),V=f.clip;if(V&&(oG||lT))return;if(e.save(),e.translate(p,v),p=o-p,v=l-v,V&&dce(f)&&!eyi(e,f,c,u))return e.restore(),null;const E=f.strokeForeground,W=i.interactive!==!1;return W&&E&&f.stroke&&qbi(e,f,c,u)?(e.restore(),f):(m=T3(f,x=>nyi(x,p,v)?this.pick(x,n,r,p,v):null),!m&&W&&(f.fill||!E&&f.stroke)&&$bi(e,f,c,u)&&(m=f),e.restore(),m||null)})}function nyi(e,i,n){return(e.interactive!==!1||e.marktype==="group")&&e.bounds&&e.bounds.contains(i,n)}var ryi={type:"group",tag:"g",nested:!1,attr:Lbi,bound:jbi,draw:tyi,pick:iyi,isect:Vje,content:Qbi,background:Jbi,foreground:Ubi},YH={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"};function Sce(e,i){var n=e.image;return(!n||e.url&&e.url!==n.url)&&(n={complete:!1,width:0,height:0},i.loadImage(e.url).then(r=>{e.image=r,e.image.url=e.url})),n}function wce(e,i){return e.width!=null?e.width:!i||!i.width?0:e.aspect!==!1&&e.height?e.height*i.width/i.height:i.width}function Tce(e,i){return e.height!=null?e.height:!i||!i.height?0:e.aspect!==!1&&e.width?e.width*i.height/i.width:i.height}function Nz(e,i){return e==="center"?i/2:e==="right"?i:0}function kz(e,i){return e==="middle"?i/2:e==="bottom"?i:0}function gyi(e,i,n){const r=Sce(i,n),o=wce(i,r),l=Tce(i,r),c=(i.x||0)-Nz(i.align,o),u=(i.y||0)-kz(i.baseline,l),f=!r.src&&r.toDataURL?r.toDataURL():r.src||"";e("href",f,YH["xmlns:xlink"],"xlink:href"),e("transform",Ly(c,u)),e("width",o),e("height",l),e("preserveAspectRatio",i.aspect===!1?"none":"xMidYMid")}function oyi(e,i){const n=i.image,r=wce(i,n),o=Tce(i,n),l=(i.x||0)-Nz(i.align,r),c=(i.y||0)-kz(i.baseline,o);return e.set(l,c,l+r,c+o)}function ayi(e,i,n){SA(i,r=>{if(n&&!n.intersects(r.bounds))return;const o=Sce(r,this);let l=wce(r,o),c=Tce(r,o);if(l===0||c===0)return;let u=(r.x||0)-Nz(r.align,l),f=(r.y||0)-kz(r.baseline,c),m,p,v,B;r.aspect!==!1&&(p=o.width/o.height,v=r.width/r.height,p===p&&v===v&&p!==v&&(v{if(!(n&&!n.intersects(r.bounds))){var o=r.opacity==null?1:r.opacity;o&&Dje(e,r,o)&&(ew(e,r),e.stroke())}})}function pyi(e,i,n,r){return e.isPointInStroke?Dje(e,i,1)&&e.isPointInStroke(n,r):!1}var byi={type:"rule",tag:"line",nested:!1,attr:hyi,bound:fyi,draw:myi,pick:Wz(pyi),isect:Eje},yyi=Bce("shape",Tbi),vyi=Bce("symbol",Rbi,pce);const X5e=zUe();var fA={height:Bd,measureWidth:Rce,estimateWidth:Uge,width:Uge,canvas:Mje};Mje(!0);function Mje(e){fA.width=e&&Vp?Rce:Uge}function Uge(e,i){return Fje(Pp(e,i),Bd(e))}function Fje(e,i){return~~(.8*e.length*i)}function Rce(e,i){return Bd(e)<=0||!(i=Pp(e,i))?0:Yje(i,Xz(e))}function Yje(e,i){const n=`(${i}) ${e}`;let r=X5e.get(n);return r===void 0&&(Vp.font=i,r=Vp.measureText(e).width,X5e.set(n,r)),r}function Bd(e){return e.fontSize!=null?+e.fontSize||0:11}function _p(e){return e.lineHeight!=null?e.lineHeight:Bd(e)+2}function Zyi(e){return Pt(e)?e.length>1?e:e[0]:e}function jW(e){return Zyi(e.lineBreak&&e.text&&!Pt(e.text)?e.text.split(e.lineBreak):e.text)}function Vce(e){const i=jW(e);return(Pt(i)?i.length-1:0)*_p(e)}function Pp(e,i){const n=i==null?"":(i+"").trim();return e.limit>0&&n.length?Gyi(e,n):n}function Byi(e){if(fA.width===Rce){const i=Xz(e);return n=>Yje(n,i)}else{const i=Bd(e);return n=>Fje(n,i)}}function Gyi(e,i){var n=+e.limit,r=Byi(e);if(r(i)>>1,r(i.slice(f))>n?c=f+1:u=f;return o+i.slice(c)}else{for(;c>>1),r(i.slice(0,f))Math.max(B,fA.width(i,G)),0)):v=fA.width(i,p),o==="center"?f-=v/2:o==="right"&&(f-=v),e.set(f+=c,m+=u,f+v,m+r),i.angle&&!n)e.rotate(i.angle*Kp,c,u);else if(n===2)return e.rotatedPoints(i.angle*Kp,c,u);return e}function Tyi(e,i,n){SA(i,r=>{var o=r.opacity==null?1:r.opacity,l,c,u,f,m,p,v;if(!(n&&!n.intersects(r.bounds)||o===0||r.fontSize<=0||r.text==null||r.text.length===0)){if(e.font=Xz(r),e.textAlign=r.align||"left",l=xz(r),c=l.x1,u=l.y1,r.angle&&(e.save(),e.translate(c,u),e.rotate(r.angle*Kp),c=u=0),c+=r.dx||0,u+=(r.dy||0)+Ece(r),p=jW(r),ew(e,r),Pt(p))for(m=_p(r),f=0;fi;)e.removeChild(n[--r]);return e}function Lje(e){return"mark-"+e.marktype+(e.role?" role-"+e.role:"")+(e.name?" "+e.name:"")}function Dz(e,i){const n=i.getBoundingClientRect();return[e.clientX-n.left-(i.clientLeft||0),e.clientY-n.top-(i.clientTop||0)]}function Nyi(e,i,n,r){var o=e&&e.mark,l,c;if(o&&(l=Ll[o.marktype]).tip){for(c=Dz(i,n),c[0]-=r[0],c[1]-=r[1];e=e.mark.group;)c[0]-=e.x||0,c[1]-=e.y||0;e=l.tip(o.items,c)}return e}function zp(e,i){this._active=null,this._handlers={},this._loader=e||nz(),this._tooltip=i||kyi}function kyi(e,i,n,r){e.element().setAttribute("title",r||"")}zp.prototype={initialize(e,i,n){return this._el=e,this._obj=n||null,this.origin(i)},element(){return this._el},canvas(){return this._el&&this._el.firstChild},origin(e){return arguments.length?(this._origin=e||[0,0],this):this._origin.slice()},scene(e){return arguments.length?(this._scene=e,this):this._scene},on(){},off(){},_handlerIndex(e,i,n){for(let r=e?e.length:0;--r>=0;)if(e[r].type===i&&(!n||e[r].handler===n))return r;return-1},handlers(e){const i=this._handlers,n=[];if(e)n.push(...i[this.eventName(e)]);else for(const r in i)n.push(...i[r]);return n},eventName(e){const i=e.indexOf(".");return i<0?e:e.slice(0,i)},handleHref(e,i,n){this._loader.sanitize(n,{context:"href"}).then(r=>{const o=new MouseEvent(e.type,e),l=op(null,"a");for(const c in r)l.setAttribute(c,r[c]);l.dispatchEvent(o)}).catch(()=>{})},handleTooltip(e,i,n){if(i&&i.tooltip!=null){i=Nyi(i,e,this.canvas(),this._origin);const r=n&&i&&i.tooltip||null;this._tooltip.call(this._obj,this,e,i,r)}},getItemBoundingClientRect(e){const i=this.canvas();if(!i)return;const n=i.getBoundingClientRect(),r=this._origin,o=e.bounds,l=o.width(),c=o.height();let u=o.x1+r[0]+n.left,f=o.y1+r[1]+n.top;for(;e.mark&&(e=e.mark.group);)u+=e.x||0,f+=e.y||0;return{x:u,y:f,width:l,height:c,left:u,top:f,right:u+l,bottom:f+c}}};function Gd(e){this._el=null,this._bgcolor=null,this._loader=new fce(e)}Gd.prototype={initialize(e,i,n,r,o){return this._el=e,this.resize(i,n,r,o)},element(){return this._el},canvas(){return this._el&&this._el.firstChild},background(e){return arguments.length===0?this._bgcolor:(this._bgcolor=e,this)},resize(e,i,n,r){return this._width=e,this._height=i,this._origin=n||[0,0],this._scale=r||1,this},dirty(){},render(e){const i=this;return i._call=function(){i._render(e)},i._call(),i._call=null,i},_render(){},renderAsync(e){const i=this.render(e);return this._ready?this._ready.then(()=>i):Promise.resolve(i)},_load(e,i){var n=this,r=n._loader[e](i);if(!n._ready){const o=n._call;n._ready=n._loader.ready().then(l=>{l&&o(),n._ready=null})}return r},sanitizeURL(e){return this._load("sanitizeURL",e)},loadImage(e){return this._load("loadImage",e)}};const Xyi="keydown",xyi="keypress",Dyi="keyup",Jje="dragenter",kY="dragleave",Uje="dragover",jge="mousedown",Myi="mouseup",R3="mousemove",ZE="mouseout",Qje="mouseover",V3="click",Fyi="dblclick",Yyi="wheel",jje="mousewheel",E3="touchstart",H3="touchmove",W3="touchend",Kyi=[Xyi,xyi,Dyi,Jje,kY,Uje,jge,Myi,R3,ZE,Qje,V3,Fyi,Yyi,jje,E3,H3,W3],$ge=R3,KH=ZE,qge=V3;function qW(e,i){zp.call(this,e,i),this._down=null,this._touch=null,this._first=!0,this._events={}}const _yi=e=>e===E3||e===H3||e===W3?[E3,H3,W3]:[e];function D5e(e,i){_yi(i).forEach(n=>Pyi(e,n))}function Pyi(e,i){const n=e.canvas();n&&!e._events[i]&&(e._events[i]=1,n.addEventListener(i,e[i]?r=>e[i](r):r=>e.fire(i,r)))}function M5e(e,i,n){return function(r){const o=this._active,l=this.pickEvent(r);l===o?this.fire(e,r):((!o||!o.exit)&&this.fire(n,r),this._active=l,this.fire(i,r),this.fire(e,r))}}function F5e(e){return function(i){this.fire(e,i),this._active=null}}si(qW,zp,{initialize(e,i,n){return this._canvas=e&&Nce(e,"canvas"),[V3,jge,R3,ZE,kY].forEach(r=>D5e(this,r)),zp.prototype.initialize.call(this,e,i,n)},canvas(){return this._canvas},context(){return this._canvas.getContext("2d")},events:Kyi,DOMMouseScroll(e){this.fire(jje,e)},mousemove:M5e(R3,Qje,ZE),dragover:M5e(Uje,Jje,kY),mouseout:F5e(ZE),dragleave:F5e(kY),mousedown(e){this._down=this._active,this.fire(jge,e)},click(e){this._down===this._active&&(this.fire(V3,e),this._down=null)},touchstart(e){this._touch=this.pickEvent(e.changedTouches[0]),this._first&&(this._active=this._touch,this._first=!1),this.fire(E3,e,!0)},touchmove(e){this.fire(H3,e,!0)},touchend(e){this.fire(W3,e,!0),this._touch=null},fire(e,i,n){const r=n?this._touch:this._active,o=this._handlers[e];if(i.vegaType=e,e===qge&&r&&r.href?this.handleHref(i,r,r.href):(e===$ge||e===KH)&&this.handleTooltip(i,r,e!==KH),o)for(let l=0,c=o.length;l=0&&r.splice(o,1),this},pickEvent(e){const i=Dz(e,this._canvas),n=this._origin;return this.pick(this._scene,i[0],i[1],i[0]-n[0],i[1]-n[1])},pick(e,i,n,r,o){const l=this.context();return Ll[e.marktype].pick.call(this,l,e,i,n,r,o)}});function zyi(){return typeof window<"u"&&window.devicePixelRatio||1}var Oyi=zyi();function Lyi(e,i,n,r,o,l){const c=typeof HTMLElement<"u"&&e instanceof HTMLElement&&e.parentNode!=null,u=e.getContext("2d"),f=c?Oyi:o;e.width=i*f,e.height=n*f;for(const m in l)u[m]=l[m];return c&&f!==1&&(e.style.width=i+"px",e.style.height=n+"px"),u.pixelRatio=f,u.setTransform(f,0,0,f,f*r[0],f*r[1]),e}function N3(e){Gd.call(this,e),this._options={},this._redraw=!1,this._dirty=new Eo,this._tempb=new Eo}const Y5e=Gd.prototype,Jyi=(e,i,n)=>new Eo().set(0,0,i,n).translate(-e[0],-e[1]);function Uyi(e,i,n){return i.expand(1).round(),e.pixelRatio%1&&i.scale(e.pixelRatio).round().scale(1/e.pixelRatio),i.translate(-(n[0]%1),-(n[1]%1)),e.beginPath(),e.rect(i.x1,i.y1,i.width(),i.height()),e.clip(),i}si(N3,Gd,{initialize(e,i,n,r,o,l){return this._options=l||{},this._canvas=this._options.externalContext?null:Rp(1,1,this._options.type),e&&this._canvas&&(nA(e,0).appendChild(this._canvas),this._canvas.setAttribute("class","marks")),Y5e.initialize.call(this,e,i,n,r,o)},resize(e,i,n,r){if(Y5e.resize.call(this,e,i,n,r),this._canvas)Lyi(this._canvas,this._width,this._height,this._origin,this._scale,this._options.context);else{const o=this._options.externalContext;o||Yt("CanvasRenderer is missing a valid canvas or context"),o.scale(this._scale,this._scale),o.translate(this._origin[0],this._origin[1])}return this._redraw=!0,this},canvas(){return this._canvas},context(){return this._options.externalContext||(this._canvas?this._canvas.getContext("2d"):null)},dirty(e){const i=this._tempb.clear().union(e.bounds);let n=e.mark.group;for(;n;)i.translate(n.x||0,n.y||0),n=n.mark.group;this._dirty.union(i)},_render(e){const i=this.context(),n=this._origin,r=this._width,o=this._height,l=this._dirty,c=Jyi(n,r,o);i.save();const u=this._redraw||l.empty()?(this._redraw=!1,c.expand(1)):Uyi(i,c.intersect(l),n);return this.clear(-n[0],-n[1],r,o),this.draw(i,e,u),i.restore(),l.clear(),this},draw(e,i,n){const r=Ll[i.marktype];i.clip&&Obi(e,i),r.draw.call(this,e,i,n),i.clip&&e.restore()},clear(e,i,n,r){const o=this._options,l=this.context();o.type!=="pdf"&&!o.externalContext&&l.clearRect(e,i,n,r),this._bgcolor!=null&&(l.fillStyle=this._bgcolor,l.fillRect(e,i,n,r))}});function kce(e,i){zp.call(this,e,i);const n=this;n._hrefHandler=eoe(n,(r,o)=>{o&&o.href&&n.handleHref(r,o,o.href)}),n._tooltipHandler=eoe(n,(r,o)=>{n.handleTooltip(r,o,r.type!==KH)})}const eoe=(e,i)=>n=>{let r=n.target.__data__;r=Array.isArray(r)?r[0]:r,n.vegaType=n.type,i.call(e._obj,n,r)};si(kce,zp,{initialize(e,i,n){let r=this._svg;return r&&(r.removeEventListener(qge,this._hrefHandler),r.removeEventListener($ge,this._tooltipHandler),r.removeEventListener(KH,this._tooltipHandler)),this._svg=r=e&&Nce(e,"svg"),r&&(r.addEventListener(qge,this._hrefHandler),r.addEventListener($ge,this._tooltipHandler),r.addEventListener(KH,this._tooltipHandler)),zp.prototype.initialize.call(this,e,i,n)},canvas(){return this._svg},on(e,i){const n=this.eventName(e),r=this._handlers;if(this._handlerIndex(r[n],e,i)<0){const l={type:e,handler:i,listener:eoe(this,i)};(r[n]||(r[n]=[])).push(l),this._svg&&this._svg.addEventListener(n,l.listener)}return this},off(e,i){const n=this.eventName(e),r=this._handlers[n],o=this._handlerIndex(r,e,i);return o>=0&&(this._svg&&this._svg.removeEventListener(n,r[o].listener),r.splice(o,1)),this}});const $je="aria-hidden",Xce="aria-label",xce="role",Dce="aria-roledescription",qje="graphics-object",Mce="graphics-symbol",e6e=(e,i,n)=>({[xce]:e,[Dce]:i,[Xce]:n||void 0}),Qyi=BA(["axis-domain","axis-grid","axis-label","axis-tick","axis-title","legend-band","legend-entry","legend-gradient","legend-label","legend-title","legend-symbol","title"]),K5e={axis:{desc:"axis",caption:qyi},legend:{desc:"legend",caption:evi},"title-text":{desc:"title",caption:e=>`Title text '${P5e(e)}'`},"title-subtitle":{desc:"subtitle",caption:e=>`Subtitle text '${P5e(e)}'`}},_5e={ariaRole:xce,ariaRoleDescription:Dce,description:Xce};function t6e(e,i){const n=i.aria===!1;if(e($je,n||void 0),n||i.description==null)for(const r in _5e)e(_5e[r],void 0);else{const r=i.mark.marktype;e(Xce,i.description),e(xce,i.ariaRole||(r==="group"?qje:Mce)),e(Dce,i.ariaRoleDescription||`${r} mark`)}}function i6e(e){return e.aria===!1?{[$je]:!0}:Qyi[e.role]?null:K5e[e.role]?$yi(e,K5e[e.role]):jyi(e)}function jyi(e){const i=e.marktype,n=i==="group"||i==="text"||e.items.some(r=>r.description!=null&&r.aria!==!1);return e6e(n?qje:Mce,`${i} mark container`,e.description)}function $yi(e,i){try{const n=e.items[0],r=i.caption||(()=>"");return e6e(i.role||Mce,i.desc,n.description||r(n))}catch{return null}}function P5e(e){return pi(e.text).join(" ")}function qyi(e){const i=e.datum,n=e.orient,r=i.title?n6e(e):null,o=e.context,l=o.scales[i.scale].value,c=o.dataflow.locale(),u=l.type;return`${n==="left"||n==="right"?"Y":"X"}-axis`+(r?` titled '${r}'`:"")+` for a ${$S(u)?"discrete":u} scale with ${bje(c,l,e)}`}function evi(e){const i=e.datum,n=i.title?n6e(e):null,r=`${i.type||""} legend`.trim(),o=i.scales,l=Object.keys(o),c=e.context,u=c.scales[o[l[0]]].value,f=c.dataflow.locale();return ivi(r)+(n?` titled '${n}'`:"")+` for ${tvi(l)} with ${bje(f,u,e)}`}function n6e(e){try{return pi(sr(e.items).items[0].text).join(" ")}catch{return null}}function tvi(e){return e=e.map(i=>i+(i==="fill"||i==="stroke"?" color":"")),e.length<2?e[0]:e.slice(0,-1).join(", ")+" and "+sr(e)}function ivi(e){return e.length?e[0].toUpperCase()+e.slice(1):e}const r6e=e=>(e+"").replace(/&/g,"&").replace(//g,">"),nvi=e=>r6e(e).replace(/"/g,""").replace(/\t/g," ").replace(/\n/g," ").replace(/\r/g," ");function Fce(){let e="",i="",n="";const r=[],o=()=>i=n="",l=f=>{i&&(e+=`${i}>${n}`,o()),r.push(f)},c=(f,m)=>(m!=null&&(i+=` ${f}="${nvi(m)}"`),u),u={open(f){l(f),i="<"+f;for(var m=arguments.length,p=new Array(m>1?m-1:0),v=1;v${n}`:"/>"):e+=``,o(),u},attr:c,text:f=>(n+=r6e(f),u),toString:()=>e};return u}const g6e=e=>o6e(Fce(),e)+"";function o6e(e,i){if(e.open(i.tagName),i.hasAttributes()){const n=i.attributes,r=n.length;for(let o=0;o{m.dirty=i})),!r.zdirty){if(n.exit){l.nested&&r.items.length?(f=r.items[0],f._svg&&this._update(l,f._svg,f)):n._svg&&(f=n._svg.parentNode,f&&f.removeChild(n._svg)),n._svg=null;continue}n=l.nested?r.items[0]:n,n._update!==i&&(!n._svg||!n._svg.ownerSVGElement?(this._dirtyAll=!1,O5e(n,i)):this._update(l,n._svg,n),n._update=i)}return!this._dirtyAll},mark(e,i,n){if(!this.isDirty(i))return i._svg;const r=this._svg,o=Ll[i.marktype],l=i.interactive===!1?"none":null,c=o.tag==="g",u=L5e(i,e,n,"g",r);u.setAttribute("class",Lje(i));const f=i6e(i);for(const B in f)nI(u,B,f[B]);c||nI(u,"pointer-events",l),nI(u,"clip-path",i.clip?hce(this,i,i.group):null);let m=null,p=0;const v=B=>{const G=this.isDirty(B),T=L5e(B,u,m,o.tag,r);G&&(this._update(o,T,B),c&&ovi(this,T,B)),m=T,++p};return o.nested?i.items.length&&v(i.items[0]):SA(i,v),nA(u,p),u},_update(e,i,n){Fh=i,bs=i.__values__,t6e(BE,n),e.attr(BE,n,this);const r=svi[e.type];r&&r.call(this,e,i,n),Fh&&this.style(Fh,n)},style(e,i){if(i!=null){for(const n in k3){let r=n==="font"?$W(i):i[n];if(r===bs[n])continue;const o=k3[n];r==null?e.removeAttribute(o):(Ace(r)&&(r=vje(r,this._defs.gradient,s6e())),e.setAttribute(o,r+"")),bs[n]=r}for(const n in X3)XY(e,X3[n],i[n])}},defs(){const e=this._svg,i=this._defs;let n=i.el,r=0;for(const o in i.gradient)n||(i.el=n=JI(e,a9+1,"defs",zo)),r=rvi(n,i.gradient[o],r);for(const o in i.clipping)n||(i.el=n=JI(e,a9+1,"defs",zo)),r=gvi(n,i.clipping[o],r);n&&(r===0?(e.removeChild(n),i.el=null):nA(n,r))},_clearDefs(){const e=this._defs;e.gradient={},e.clipping={}}});function O5e(e,i){for(;e&&e.dirty!==i;e=e.mark.group)if(e.dirty=i,e.mark&&e.mark.dirty!==i)e.mark.dirty=i;else return}function rvi(e,i,n){let r,o,l;if(i.gradient==="radial"){let c=JI(e,n++,"pattern",zo);ap(c,{id:S3+i.id,viewBox:"0,0,1,1",width:"100%",height:"100%",preserveAspectRatio:"xMidYMid slice"}),c=JI(c,0,"rect",zo),ap(c,{width:1,height:1,fill:`url(${s6e()}#${i.id})`}),e=JI(e,n++,"radialGradient",zo),ap(e,{id:i.id,fx:i.x1,fy:i.y1,fr:i.r1,cx:i.x2,cy:i.y2,r:i.r2})}else e=JI(e,n++,"linearGradient",zo),ap(e,{id:i.id,x1:i.x1,x2:i.x2,y1:i.y1,y2:i.y2});for(r=0,o=i.stops.length;r{r=e.mark(i,l,r),++o}),nA(i,1+o)}function L5e(e,i,n,r,o){let l=e._svg,c;if(!l&&(c=i.ownerDocument,l=op(c,r,zo),e._svg=l,e.mark&&(l.__data__=e,l.__values__={fill:"default"},r==="g"))){const u=op(c,"path",zo);l.appendChild(u),u.__data__=e;const f=op(c,"g",zo);l.appendChild(f),f.__data__=e;const m=op(c,"path",zo);l.appendChild(m),m.__data__=e,m.__values__={fill:"default"}}return(l.ownerSVGElement!==o||avi(l,n))&&i.insertBefore(l,n?n.nextSibling:i.firstChild),l}function avi(e,i){return e.parentNode&&e.parentNode.childNodes.length>1&&e.previousSibling!=i}let Fh=null,bs=null;const svi={group(e,i,n){const r=Fh=i.childNodes[2];bs=r.__values__,e.foreground(BE,n,this),bs=i.__values__,Fh=i.childNodes[1],e.content(BE,n,this);const o=Fh=i.childNodes[0];e.background(BE,n,this);const l=n.mark.interactive===!1?"none":null;if(l!==bs.events&&(nI(r,"pointer-events",l),nI(o,"pointer-events",l),bs.events=l),n.strokeForeground&&n.stroke){const c=n.fill;nI(r,"display",null),this.style(o,n),nI(o,"stroke",null),c&&(n.fill=null),bs=r.__values__,this.style(r,n),c&&(n.fill=c),Fh=null}else nI(r,"display","none")},image(e,i,n){n.smooth===!1?(XY(i,"image-rendering","optimizeSpeed"),XY(i,"image-rendering","pixelated")):XY(i,"image-rendering",null)},text(e,i,n){const r=jW(n);let o,l,c,u;Pt(r)?(l=r.map(f=>Pp(n,f)),o=l.join(` -`),o!==bs.text&&(nA(i,0),c=i.ownerDocument,u=_p(n),l.forEach((f,m)=>{const p=op(c,"tspan",zo);p.__data__=n,p.textContent=f,m&&(p.setAttribute("x",0),p.setAttribute("dy",u)),i.appendChild(p)}),bs.text=o)):(l=Pp(n,r),l!==bs.text&&(i.textContent=l,bs.text=l)),nI(i,"font-family",$W(n)),nI(i,"font-size",Bd(n)+"px"),nI(i,"font-style",n.fontStyle),nI(i,"font-variant",n.fontVariant),nI(i,"font-weight",n.fontWeight)}};function BE(e,i,n){i!==bs[e]&&(n?Ivi(Fh,e,i,n):nI(Fh,e,i),bs[e]=i)}function XY(e,i,n){n!==bs[i]&&(n==null?e.style.removeProperty(i):e.style.setProperty(i,n+""),bs[i]=n)}function ap(e,i){for(const n in i)nI(e,n,i[n])}function nI(e,i,n){n!=null?e.setAttribute(i,n):e.removeAttribute(i)}function Ivi(e,i,n,r){n!=null?e.setAttributeNS(r,i,n):e.removeAttributeNS(r,i)}function s6e(){let e;return typeof window>"u"?"":(e=window.location).hash?e.href.slice(0,-e.hash.length):e.href}function Kce(e){Gd.call(this,e),this._text=null,this._defs={gradient:{},clipping:{}}}si(Kce,Gd,{svg(){return this._text},_render(e){const i=Fce();i.open("svg",Tn({},YH,{class:"marks",width:this._width*this._scale,height:this._height*this._scale,viewBox:`0 0 ${this._width} ${this._height}`}));const n=this._bgcolor;return n&&n!=="transparent"&&n!=="none"&&i.open("rect",{width:this._width,height:this._height,fill:n}).close(),i.open("g",a6e,{transform:"translate("+this._origin+")"}),this.mark(i,e),i.close(),this.defs(i),this._text=i.close()+"",this},mark(e,i){const n=Ll[i.marktype],r=n.tag,o=[t6e,n.attr];e.open("g",{class:Lje(i),"clip-path":i.clip?hce(this,i,i.group):null},i6e(i),{"pointer-events":r!=="g"&&i.interactive===!1?"none":null});const l=c=>{const u=this.href(c);if(u&&e.open("a",u),e.open(r,this.attr(i,c,o,r!=="g"?r:null)),r==="text"){const f=jW(c);if(Pt(f)){const m={x:0,dy:_p(c)};for(let p=0;pthis.mark(e,v)),e.close(),f&&p?(m&&(c.fill=null),c.stroke=p,e.open("path",this.attr(i,c,n.foreground,"bgrect")).close(),m&&(c.fill=m)):e.open("path",this.attr(i,c,n.foreground,"bgfore")).close()}e.close(),u&&e.close()};return n.nested?i.items&&i.items.length&&l(i.items[0]):SA(i,l),e.close()},href(e){const i=e.href;let n;if(i){if(n=this._hrefs&&this._hrefs[i])return n;this.sanitizeURL(i).then(r=>{r["xlink:href"]=r.href,r.href=null,(this._hrefs||(this._hrefs={}))[i]=r})}return null},attr(e,i,n,r){const o={},l=(c,u,f,m)=>{o[m||c]=u};return Array.isArray(n)?n.forEach(c=>c(l,i,this)):n(l,i,this),r&&lvi(o,i,e,r,this._defs),o},defs(e){const i=this._defs.gradient,n=this._defs.clipping;if(Object.keys(i).length+Object.keys(n).length!==0){e.open("defs");for(const o in i){const l=i[o],c=l.stops;l.gradient==="radial"?(e.open("pattern",{id:S3+o,viewBox:"0,0,1,1",width:"100%",height:"100%",preserveAspectRatio:"xMidYMid slice"}),e.open("rect",{width:"1",height:"1",fill:"url(#"+o+")"}).close(),e.close(),e.open("radialGradient",{id:o,fx:l.x1,fy:l.y1,fr:l.r1,cx:l.x2,cy:l.y2,r:l.r2})):e.open("linearGradient",{id:o,x1:l.x1,x2:l.x2,y1:l.y1,y2:l.y2});for(let u=0;u1?(iw[e]=i,this):iw[e]}function A6e(e,i,n){const r=[],o=new Eo().union(i),l=e.marktype;return l?u6e(e,o,n,r):l==="group"?d6e(e,o,n,r):Yt("Intersect scene must be mark node or group item.")}function u6e(e,i,n,r){if(Cvi(e,i,n)){const o=e.items,l=e.marktype,c=o.length;let u=0;if(l==="group")for(;u=0;l--)if(n[l]!=r[l])return!1;for(l=n.length-1;l>=0;l--)if(o=n[l],!_ce(e[o],i[o],o))return!1;return typeof e==typeof i}function uvi(){Rje(),M0i()}const nw="top",rA="left",IA="right",Op="bottom",dvi="top-left",hvi="top-right",fvi="bottom-left",mvi="bottom-right",Pce="start",toe="middle",gI="end",pvi="x",bvi="y",Fz="group",zce="axis",Oce="title",yvi="frame",vvi="scope",Lce="legend",p6e="row-header",b6e="row-footer",y6e="row-title",v6e="column-header",Z6e="column-footer",B6e="column-title",Zvi="padding",Bvi="symbol",G6e="fit",S6e="fit-x",w6e="fit-y",Gvi="pad",Jce="none",ZF="all",ioe="each",Uce="flush",Ip="column",lp="row";function T6e(e){Xt.call(this,null,e)}si(T6e,Xt,{transform(e,i){const n=i.dataflow,r=e.mark,o=r.marktype,l=Ll[o],c=l.bound;let u=r.bounds,f;if(l.nested)r.items.length&&n.dirty(r.items[0]),u=BF(r,c),r.items.forEach(m=>{m.bounds.clear().union(u)});else if(o===Fz||e.modified())switch(i.visit(i.MOD,m=>n.dirty(m)),u.clear(),r.items.forEach(m=>u.union(BF(m,c))),r.role){case zce:case Lce:case Oce:i.reflow()}else f=i.changed(i.REM),i.visit(i.ADD,m=>{u.union(BF(m,c))}),i.visit(i.MOD,m=>{f=f||u.alignsWith(m.bounds),n.dirty(m),u.union(BF(m,c))}),f&&(u.clear(),r.items.forEach(m=>u.union(m.bounds)));return f6e(r),i.modifies("bounds")}});function BF(e,i,n){return i(e.bounds.clear(),e,n)}const J5e=":vega_identifier:";function Qce(e){Xt.call(this,0,e)}Qce.Definition={type:"Identifier",metadata:{modifies:!0},params:[{name:"as",type:"string",required:!0}]};si(Qce,Xt,{transform(e,i){const n=Svi(i.dataflow),r=e.as;let o=n.value;return i.visit(i.ADD,l=>l[r]=l[r]||++o),n.set(this.value=o),i}});function Svi(e){return e._signals[J5e]||(e._signals[J5e]=e.add(0))}function R6e(e){Xt.call(this,null,e)}si(R6e,Xt,{transform(e,i){let n=this.value;n||(n=i.dataflow.scenegraph().mark(e.markdef,wvi(e),e.index),n.group.context=e.context,e.context.group||(e.context.group=n.group),n.source=this.source,n.clip=e.clip,n.interactive=e.interactive,this.value=n);const r=n.marktype===Fz?Ez:Vz;return i.visit(i.ADD,o=>r.call(o,n)),(e.modified("clip")||e.modified("interactive"))&&(n.clip=e.clip,n.interactive=!!e.interactive,n.zdirty=!0,i.reflow()),n.items=i.source,i}});function wvi(e){const i=e.groups,n=e.parent;return i&&i.size===1?i.get(Object.keys(i.object)[0]):i&&n?i.lookup(n):null}function V6e(e){Xt.call(this,null,e)}const U5e={parity:e=>e.filter((i,n)=>n%2?i.opacity=0:1),greedy:(e,i)=>{let n;return e.filter((r,o)=>!o||!E6e(n.bounds,r.bounds,i)?(n=r,1):r.opacity=0)}},E6e=(e,i,n)=>n>Math.max(i.x1-e.x2,e.x1-i.x2,i.y1-e.y2,e.y1-i.y2),Q5e=(e,i)=>{for(var n=1,r=e.length,o=e[0].bounds,l;n{const i=e.bounds;return i.width()>1&&i.height()>1},Rvi=(e,i,n)=>{var r=e.range(),o=new Eo;return i===nw||i===Op?o.set(r[0],-1/0,r[1],1/0):o.set(-1/0,r[0],1/0,r[1]),o.expand(n||1),l=>o.encloses(l.bounds)},j5e=e=>(e.forEach(i=>i.opacity=1),e),$5e=(e,i)=>e.reflow(i.modified()).modifies("opacity");si(V6e,Xt,{transform(e,i){const n=U5e[e.method]||U5e.parity,r=e.separation||0;let o=i.materialize(i.SOURCE).source,l,c;if(!o||!o.length)return;if(!e.method)return e.modified("method")&&(j5e(o),i=$5e(i,e)),i;if(o=o.filter(Tvi),!o.length)return;if(e.sort&&(o=o.slice().sort(e.sort)),l=j5e(o),i=$5e(i,e),l.length>=3&&Q5e(l,r)){do l=n(l,r);while(l.length>=3&&Q5e(l,r));l.length<3&&!sr(o).opacity&&(l.length>1&&(sr(l).opacity=0),sr(o).opacity=1)}e.boundScale&&e.boundTolerance>=0&&(c=Rvi(e.boundScale,e.boundOrient,+e.boundTolerance),o.forEach(f=>{c(f)||(f.opacity=0)}));const u=l[0].mark.bounds.clear();return o.forEach(f=>{f.opacity&&u.union(f.bounds)}),i}});function H6e(e){Xt.call(this,null,e)}si(H6e,Xt,{transform(e,i){const n=i.dataflow;if(i.visit(i.ALL,r=>n.dirty(r)),i.fields&&i.fields.zindex){const r=i.source&&i.source[0];r&&(r.mark.zdirty=!0)}}});const ps=new Eo;function JG(e,i,n){return e[i]===n?0:(e[i]=n,1)}function Vvi(e){var i=e.items[0].orient;return i===rA||i===IA}function Evi(e){let i=+e.grid;return[e.ticks?i++:-1,e.labels?i++:-1,i+ +e.domain]}function Hvi(e,i,n,r){var o=i.items[0],l=o.datum,c=o.translate!=null?o.translate:.5,u=o.orient,f=Evi(l),m=o.range,p=o.offset,v=o.position,B=o.minExtent,G=o.maxExtent,T=l.title&&o.items[f[2]].items[0],V=o.titlePadding,E=o.bounds,W=T&&Vce(T),x=0,k=0,F,Y;switch(ps.clear().union(E),E.clear(),(F=f[0])>-1&&E.union(o.items[F].bounds),(F=f[1])>-1&&E.union(o.items[F].bounds),u){case nw:x=v||0,k=-p,Y=Math.max(B,Math.min(G,-E.y1)),E.add(0,-Y).add(m,0),T&&GF(e,T,Y,V,W,0,-1,E);break;case rA:x=-p,k=v||0,Y=Math.max(B,Math.min(G,-E.x1)),E.add(-Y,0).add(0,m),T&&GF(e,T,Y,V,W,1,-1,E);break;case IA:x=n+p,k=v||0,Y=Math.max(B,Math.min(G,E.x2)),E.add(0,0).add(Y,m),T&&GF(e,T,Y,V,W,1,1,E);break;case Op:x=v||0,k=r+p,Y=Math.max(B,Math.min(G,E.y2)),E.add(0,0).add(m,Y),T&&GF(e,T,Y,V,0,0,1,E);break;default:x=o.x,k=o.y}return pf(E.translate(x,k),o),JG(o,"x",x+c)|JG(o,"y",k+c)&&(o.bounds=ps,e.dirty(o),o.bounds=E,e.dirty(o)),o.mark.bounds.clear().union(E)}function GF(e,i,n,r,o,l,c,u){const f=i.bounds;if(i.auto){const m=c*(n+o+r);let p=0,v=0;e.dirty(i),l?p=(i.x||0)-(i.x=m):v=(i.y||0)-(i.y=m),i.mark.bounds.clear().union(f.translate(-p,-v)),e.dirty(i)}u.union(f)}const q5e=(e,i)=>Math.floor(Math.min(e,i)),eMe=(e,i)=>Math.ceil(Math.max(e,i));function Wvi(e){var i=e.items,n=i.length,r=0,o,l;const c={marks:[],rowheaders:[],rowfooters:[],colheaders:[],colfooters:[],rowtitle:null,coltitle:null};for(;r1)for(O=0;O0&&(k[O]+=Ae/2);if(u&&Xg(n.center,lp)&&p!==1)for(O=0;O0&&(F[O]+=_/2);for(O=0;Oo&&(e.warn("Grid headers exceed limit: "+o),i=i.slice(0,o)),V+=l,x=0,F=i.length;x=0&&(O=n[k])==null;k-=B);u?(Q=G==null?O.x:Math.round(O.bounds.x1+G*O.bounds.width()),X=V):(Q=V,X=G==null?O.y:Math.round(O.bounds.y1+G*O.bounds.height())),Y.union(L.bounds.translate(Q-(L.x||0),X-(L.y||0))),L.x=Q,L.y=X,e.dirty(L),E=c(E,Y[m])}return E}function iMe(e,i,n,r,o,l){if(i){e.dirty(i);var c=n,u=n;r?c=Math.round(o.x1+l*o.width()):u=Math.round(o.y1+l*o.height()),i.bounds.translate(c-(i.x||0),u-(i.y||0)),i.mark.bounds.clear().union(i.bounds),i.x=c,i.y=u,e.dirty(i)}}function Mvi(e,i){const n=e[i]||{};return(r,o)=>n[r]!=null?n[r]:e[r]!=null?e[r]:o}function Fvi(e,i){let n=-1/0;return e.forEach(r=>{r.offset!=null&&(n=Math.max(n,r.offset))}),n>-1/0?n:i}function Yvi(e,i,n,r,o,l,c){const u=Mvi(n,i),f=Fvi(e,u("offset",0)),m=u("anchor",Pce),p=m===gI?1:m===toe?.5:0,v={align:ioe,bounds:u("bounds",Uce),columns:u("direction")==="vertical"?1:e.length,padding:u("margin",8),center:u("center"),nodirty:!0};switch(i){case rA:v.anchor={x:Math.floor(r.x1)-f,column:gI,y:p*(c||r.height()+2*r.y1),row:m};break;case IA:v.anchor={x:Math.ceil(r.x2)+f,y:p*(c||r.height()+2*r.y1),row:m};break;case nw:v.anchor={y:Math.floor(o.y1)-f,row:gI,x:p*(l||o.width()+2*o.x1),column:m};break;case Op:v.anchor={y:Math.ceil(o.y2)+f,x:p*(l||o.width()+2*o.x1),column:m};break;case dvi:v.anchor={x:f,y:f};break;case hvi:v.anchor={x:l-f,y:f,column:gI};break;case fvi:v.anchor={x:f,y:c-f,row:gI};break;case mvi:v.anchor={x:l-f,y:c-f,column:gI,row:gI};break}return v}function Kvi(e,i){var n=i.items[0],r=n.datum,o=n.orient,l=n.bounds,c=n.x,u=n.y,f,m;return n._bounds?n._bounds.clear().union(l):n._bounds=l.clone(),l.clear(),Pvi(e,n,n.items[0].items[0]),l=_vi(n,l),f=2*n.padding,m=2*n.padding,l.empty()||(f=Math.ceil(l.width()+f),m=Math.ceil(l.height()+m)),r.type===Bvi&&zvi(n.items[0].items[0].items[0].items),o!==Jce&&(n.x=c=0,n.y=u=0),n.width=f,n.height=m,pf(l.set(c,u,c+f,u+m),n),n.mark.bounds.clear().union(l),n}function _vi(e,i){return e.items.forEach(n=>i.union(n.bounds)),i.x1=e.padding,i.y1=e.padding,i}function Pvi(e,i,n){var r=i.padding,o=r-n.x,l=r-n.y;if(!i.datum.title)(o||l)&&s9(e,n,o,l);else{var c=i.items[1].items[0],u=c.anchor,f=i.titlePadding||0,m=r-c.x,p=r-c.y;switch(c.orient){case rA:o+=Math.ceil(c.bounds.width())+f;break;case IA:case Op:break;default:l+=c.bounds.height()+f}switch((o||l)&&s9(e,n,o,l),c.orient){case rA:p+=dG(i,n,c,u,1,1);break;case IA:m+=dG(i,n,c,gI,0,0)+f,p+=dG(i,n,c,u,1,1);break;case Op:m+=dG(i,n,c,u,0,0),p+=dG(i,n,c,gI,-1,0,1)+f;break;default:m+=dG(i,n,c,u,0,0)}(m||p)&&s9(e,c,m,p),(m=Math.round(c.bounds.x1-r))<0&&(s9(e,n,-m,0),s9(e,c,-m,0))}}function dG(e,i,n,r,o,l,c){const u=e.datum.type!=="symbol",f=n.datum.vgrad,m=u&&(l||!f)&&!c?i.items[0]:i,p=m.bounds[o?"y2":"x2"]-e.padding,v=f&&l?p:0,B=f&&l?0:p,G=o<=0?0:Vce(n);return Math.round(r===Pce?v:r===gI?B-G:.5*(p-G))}function s9(e,i,n,r){i.x+=n,i.y+=r,i.bounds.translate(n,r),i.mark.bounds.translate(n,r),e.dirty(i)}function zvi(e){const i=e.reduce((n,r)=>(n[r.column]=Math.max(r.bounds.x2-r.x,n[r.column]||0),n),{});e.forEach(n=>{n.width=i[n.column],n.height=n.bounds.y2-n.y})}function Ovi(e,i,n,r,o){var l=i.items[0],c=l.frame,u=l.orient,f=l.anchor,m=l.offset,p=l.padding,v=l.items[0].items[0],B=l.items[1]&&l.items[1].items[0],G=u===rA||u===IA?r:n,T=0,V=0,E=0,W=0,x=0,k;if(c!==Fz?u===rA?(T=o.y2,G=o.y1):u===IA?(T=o.y1,G=o.y2):(T=o.x1,G=o.x2):u===rA&&(T=r,G=0),k=f===Pce?T:f===gI?G:(T+G)/2,B&&B.text){switch(u){case nw:case Op:x=v.bounds.height()+p;break;case rA:W=v.bounds.width()+p;break;case IA:W=-v.bounds.width()-p;break}ps.clear().union(B.bounds),ps.translate(W-(B.x||0),x-(B.y||0)),JG(B,"x",W)|JG(B,"y",x)&&(e.dirty(B),B.bounds.clear().union(ps),B.mark.bounds.clear().union(ps),e.dirty(B)),ps.clear().union(B.bounds)}else ps.clear();switch(ps.union(v.bounds),u){case nw:V=k,E=o.y1-ps.height()-m;break;case rA:V=o.x1-ps.width()-m,E=k;break;case IA:V=o.x2+ps.width()+m,E=k;break;case Op:V=k,E=o.y2+m;break;default:V=l.x,E=l.y}return JG(l,"x",V)|JG(l,"y",E)&&(ps.translate(V,E),e.dirty(l),l.bounds.clear().union(ps),i.bounds.clear().union(ps),e.dirty(l)),l.bounds}function N6e(e){Xt.call(this,null,e)}si(N6e,Xt,{transform(e,i){const n=i.dataflow;return e.mark.items.forEach(r=>{e.layout&&Xvi(n,r,e.layout),Jvi(n,r,e)}),Lvi(e.mark.group)?i.reflow():i}});function Lvi(e){return e&&e.mark.role!=="legend-entry"}function Jvi(e,i,n){var r=i.items,o=Math.max(0,i.width||0),l=Math.max(0,i.height||0),c=new Eo().set(0,0,o,l),u=c.clone(),f=c.clone(),m=[],p,v,B,G,T,V;for(T=0,V=r.length;T{B=W.orient||IA,B!==Jce&&(E[B]||(E[B]=[])).push(W)});for(const W in E){const x=E[W];W6e(e,x,Yvi(x,W,n.legends,u,f,o,l))}m.forEach(W=>{const x=W.bounds;if(x.equals(W._bounds)||(W.bounds=W._bounds,e.dirty(W),W.bounds=x,e.dirty(W)),n.autosize&&(n.autosize.type===G6e||n.autosize.type===S6e||n.autosize.type===w6e))switch(W.orient){case rA:case IA:c.add(x.x1,0).add(x.x2,0);break;case nw:case Op:c.add(0,x.y1).add(0,x.y2)}else c.union(x)})}c.union(u).union(f),p&&c.union(Ovi(e,p,o,l,c)),i.clip&&c.set(0,0,i.width||0,i.height||0),Uvi(e,i,c,n)}function Uvi(e,i,n,r){const o=r.autosize||{},l=o.type;if(e._autosize<1||!l)return;let c=e._width,u=e._height,f=Math.max(0,i.width||0),m=Math.max(0,Math.ceil(-n.x1)),p=Math.max(0,i.height||0),v=Math.max(0,Math.ceil(-n.y1));const B=Math.max(0,Math.ceil(n.x2-f)),G=Math.max(0,Math.ceil(n.y2-p));if(o.contains===Zvi){const T=e.padding();c-=T.left+T.right,u-=T.top+T.bottom}l===Jce?(m=0,v=0,f=c,p=u):l===G6e?(f=Math.max(0,c-m-B),p=Math.max(0,u-v-G)):l===S6e?(f=Math.max(0,c-m-B),u=p+v+G):l===w6e?(c=f+m+B,p=Math.max(0,u-v-G)):l===Gvi&&(c=f+m+B,u=p+v+G),e._resizeView(c,u,f,p,[m,v],o.resize)}const Qvi=Object.freeze(Object.defineProperty({__proto__:null,bound:T6e,identifier:Qce,mark:R6e,overlap:V6e,render:H6e,viewlayout:N6e},Symbol.toStringTag,{value:"Module"}));function k6e(e){Xt.call(this,null,e)}si(k6e,Xt,{transform(e,i){if(this.value&&!e.modified())return i.StopPropagation;var n=i.dataflow.locale(),r=i.fork(i.NO_SOURCE|i.NO_FIELDS),o=this.value,l=e.scale,c=e.count==null?e.values?e.values.length:10:e.count,u=Cce(l,c,e.minstep),f=e.format||dje(n,l,u,e.formatSpecifier,e.formatType,!!e.values),m=e.values?uje(l,e.values,u):cce(l,u);return o&&(r.rem=o),o=m.map((p,v)=>Vr({index:v/(m.length-1||1),value:p,label:f(p)})),e.extra&&o.length&&o.push(Vr({index:-1,extra:{value:o[0].value},label:""})),r.source=o,r.add=o,this.value=o,r}});function X6e(e){Xt.call(this,null,e)}function jvi(){return Vr({})}function $vi(e){const i=Dw().test(n=>n.exit);return i.lookup=n=>i.get(e(n)),i}si(X6e,Xt,{transform(e,i){var n=i.dataflow,r=i.fork(i.NO_SOURCE|i.NO_FIELDS),o=e.item||jvi,l=e.key||Pi,c=this.value;return Pt(r.encode)&&(r.encode=null),c&&(e.modified("key")||i.modified(l))&&Yt("DataJoin does not support modified key function or fields."),c||(i=i.addAll(),this.value=c=$vi(l)),i.visit(i.ADD,u=>{const f=l(u);let m=c.get(f);m?m.exit?(c.empty--,r.add.push(m)):r.mod.push(m):(m=o(u),c.set(f,m),r.add.push(m)),m.datum=u,m.exit=!1}),i.visit(i.MOD,u=>{const f=l(u),m=c.get(f);m&&(m.datum=u,r.mod.push(m))}),i.visit(i.REM,u=>{const f=l(u),m=c.get(f);u===m.datum&&!m.exit&&(r.rem.push(m),m.exit=!0,++c.empty)}),i.changed(i.ADD_MOD)&&r.modifies("datum"),(i.clean()||e.clean&&c.empty>n.cleanThreshold)&&n.runAfter(c.clean),r}});function x6e(e){Xt.call(this,null,e)}si(x6e,Xt,{transform(e,i){var n=i.fork(i.ADD_REM),r=e.mod||!1,o=e.encoders,l=i.encode;if(Pt(l))if(n.changed()||l.every(v=>o[v]))l=l[0],n.encode=null;else return i.StopPropagation;var c=l==="enter",u=o.update||Dm,f=o.enter||Dm,m=o.exit||Dm,p=(l&&!c?o[l]:u)||Dm;if(i.changed(i.ADD)&&(i.visit(i.ADD,v=>{f(v,e),u(v,e)}),n.modifies(f.output),n.modifies(u.output),p!==Dm&&p!==u&&(i.visit(i.ADD,v=>{p(v,e)}),n.modifies(p.output))),i.changed(i.REM)&&m!==Dm&&(i.visit(i.REM,v=>{m(v,e)}),n.modifies(m.output)),c||p!==Dm){const v=i.MOD|(e.modified()?i.REFLOW:0);c?(i.visit(v,B=>{const G=f(B,e)||r;(p(B,e)||G)&&n.mod.push(B)}),n.mod.length&&n.modifies(f.output)):i.visit(v,B=>{(p(B,e)||r)&&n.mod.push(B)}),n.mod.length&&n.modifies(p.output)}return n.changed()?n:i.StopPropagation}});function D6e(e){Xt.call(this,[],e)}si(D6e,Xt,{transform(e,i){if(this.value!=null&&!e.modified())return i.StopPropagation;var n=i.dataflow.locale(),r=i.fork(i.NO_SOURCE|i.NO_FIELDS),o=this.value,l=e.type||RY,c=e.scale,u=+e.limit,f=Cce(c,e.count==null?5:e.count,e.minstep),m=!!e.values||l===RY,p=e.format||pje(n,c,f,l,e.formatSpecifier,e.formatType,m),v=e.values||mje(c,f),B,G,T,V,E;return o&&(r.rem=o),l===RY?(u&&v.length>u?(i.dataflow.warn("Symbol legend count exceeds limit, filtering items."),o=v.slice(0,u-1),E=!0):o=v,Rn(T=e.size)?(!e.values&&c(o[0])===0&&(o=o.slice(1)),V=o.reduce((W,x)=>Math.max(W,T(x,e)),0)):T=Ws(V=T||8),o=o.map((W,x)=>Vr({index:x,label:p(W,x,o),value:W,offset:V,size:T(W,e)})),E&&(E=v[o.length],o.push(Vr({index:o.length,label:`…${v.length-o.length} entries`,value:E,offset:V,size:T(E,e)})))):l===S0i?(B=c.domain(),G=Cje(c,B[0],sr(B)),v.length<3&&!e.values&&B[0]!==sr(B)&&(v=[B[0],sr(B)]),o=v.map((W,x)=>Vr({index:x,label:p(W,x,v),value:W,perc:G(W)}))):(T=v.length-1,G=x0i(c),o=v.map((W,x)=>Vr({index:x,label:p(W,x,v),value:W,perc:x?G(W):0,perc2:x===T?1:G(v[x+1])}))),r.source=o,r.add=o,this.value=o,r}});const qvi=e=>e.source.x,eZi=e=>e.source.y,tZi=e=>e.target.x,iZi=e=>e.target.y;function jce(e){Xt.call(this,{},e)}jce.Definition={type:"LinkPath",metadata:{modifies:!0},params:[{name:"sourceX",type:"field",default:"source.x"},{name:"sourceY",type:"field",default:"source.y"},{name:"targetX",type:"field",default:"target.x"},{name:"targetY",type:"field",default:"target.y"},{name:"orient",type:"enum",default:"vertical",values:["horizontal","vertical","radial"]},{name:"shape",type:"enum",default:"line",values:["line","arc","curve","diagonal","orthogonal"]},{name:"require",type:"signal"},{name:"as",type:"string",default:"path"}]};si(jce,Xt,{transform(e,i){var n=e.sourceX||qvi,r=e.sourceY||eZi,o=e.targetX||tZi,l=e.targetY||iZi,c=e.as||"path",u=e.orient||"vertical",f=e.shape||"line",m=nMe.get(f+"-"+u)||nMe.get(f);return m||Yt("LinkPath unsupported type: "+e.shape+(e.orient?"-"+e.orient:"")),i.visit(i.SOURCE,p=>{p[c]=m(n(p),r(p),o(p),l(p))}),i.reflow(e.modified()).modifies(c)}});const M6e=(e,i,n,r)=>"M"+e+","+i+"L"+n+","+r,nZi=(e,i,n,r)=>M6e(i*Math.cos(e),i*Math.sin(e),r*Math.cos(n),r*Math.sin(n)),F6e=(e,i,n,r)=>{var o=n-e,l=r-i,c=Math.hypot(o,l)/2,u=180*Math.atan2(l,o)/Math.PI;return"M"+e+","+i+"A"+c+","+c+" "+u+" 0 1 "+n+","+r},rZi=(e,i,n,r)=>F6e(i*Math.cos(e),i*Math.sin(e),r*Math.cos(n),r*Math.sin(n)),Y6e=(e,i,n,r)=>{const o=n-e,l=r-i,c=.2*(o+l),u=.2*(l-o);return"M"+e+","+i+"C"+(e+c)+","+(i+u)+" "+(n+u)+","+(r-c)+" "+n+","+r},gZi=(e,i,n,r)=>Y6e(i*Math.cos(e),i*Math.sin(e),r*Math.cos(n),r*Math.sin(n)),oZi=(e,i,n,r)=>"M"+e+","+i+"V"+r+"H"+n,aZi=(e,i,n,r)=>"M"+e+","+i+"H"+n+"V"+r,sZi=(e,i,n,r)=>{const o=Math.cos(e),l=Math.sin(e),c=Math.cos(n),u=Math.sin(n),f=Math.abs(n-e)>Math.PI?n<=e:n>e;return"M"+i*o+","+i*l+"A"+i+","+i+" 0 0,"+(f?1:0)+" "+i*c+","+i*u+"L"+r*c+","+r*u},IZi=(e,i,n,r)=>{const o=(e+n)/2;return"M"+e+","+i+"C"+o+","+i+" "+o+","+r+" "+n+","+r},lZi=(e,i,n,r)=>{const o=(i+r)/2;return"M"+e+","+i+"C"+e+","+o+" "+n+","+o+" "+n+","+r},CZi=(e,i,n,r)=>{const o=Math.cos(e),l=Math.sin(e),c=Math.cos(n),u=Math.sin(n),f=(i+r)/2;return"M"+i*o+","+i*l+"C"+f*o+","+f*l+" "+f*c+","+f*u+" "+r*c+","+r*u},nMe=Dw({line:M6e,"line-radial":nZi,arc:F6e,"arc-radial":rZi,curve:Y6e,"curve-radial":gZi,"orthogonal-horizontal":oZi,"orthogonal-vertical":aZi,"orthogonal-radial":sZi,"diagonal-horizontal":IZi,"diagonal-vertical":lZi,"diagonal-radial":CZi});function $ce(e){Xt.call(this,null,e)}$ce.Definition={type:"Pie",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"startAngle",type:"number",default:0},{name:"endAngle",type:"number",default:6.283185307179586},{name:"sort",type:"boolean",default:!1},{name:"as",type:"string",array:!0,length:2,default:["startAngle","endAngle"]}]};si($ce,Xt,{transform(e,i){var n=e.as||["startAngle","endAngle"],r=n[0],o=n[1],l=e.field||kw,c=e.startAngle||0,u=e.endAngle!=null?e.endAngle:2*Math.PI,f=i.source,m=f.map(l),p=m.length,v=c,B=(u-c)/a7e(m),G=Yl(p),T,V,E;for(e.sort&&G.sort((W,x)=>m[W]-m[x]),T=0;T-1)return r;var o=i.domain,l=e.type,c=i.zero||i.zero===void 0&&AZi(e),u,f;if(!o)return 0;if(K6e(l)&&i.padding&&o[0]!==sr(o)&&(o=pZi(l,o,i.range,i.padding,i.exponent,i.constant)),(c||i.domainMin!=null||i.domainMax!=null||i.domainMid!=null)&&(u=(o=o.slice()).length-1||1,c&&(o[0]>0&&(o[0]=0),o[u]<0&&(o[u]=0)),i.domainMin!=null&&(o[0]=i.domainMin),i.domainMax!=null&&(o[u]=i.domainMax),i.domainMid!=null)){f=i.domainMid;const m=f>o[u]?u+1:fo+(l<0?-1:l>0?1:0),0));r!==i.length&&n.warn("Log scale domain includes zero: "+ai(i))}return i}function bZi(e,i,n){let r=i.bins;if(r&&!Pt(r)){const o=e.domain(),l=o[0],c=sr(o),u=r.step;let f=r.start==null?l:r.start,m=r.stop==null?c:r.stop;u||Yt("Scale bins parameter missing step property."),fc&&(m=u*Math.floor(c/u)),r=Yl(f,m+u/2,u)}return r?e.bins=r:e.bins&&delete e.bins,e.type===gce&&(r?!i.domain&&!i.domainRaw&&(e.domain(r),n=r.length):e.bins=e.domain()),n}function yZi(e,i,n){var r=e.type,o=i.round||!1,l=i.range;if(i.rangeStep!=null)l=vZi(r,i,n);else if(i.scheme&&(l=ZZi(r,i,n),Rn(l))){if(e.interpolator)return e.interpolator(l);Yt(`Scale type ${r} does not support interpolating color schemes.`)}if(l&&aje(r))return e.interpolator(Tz(noe(l,i.reverse),i.interpolate,i.interpolateGamma));l&&i.interpolate&&e.interpolate?e.interpolate(Ice(i.interpolate,i.interpolateGamma)):Rn(e.round)?e.round(o):Rn(e.rangeRound)&&e.interpolate(o?FW:l0),l&&e.range(noe(l,i.reverse))}function vZi(e,i,n){e!==eje&&e!==Kge&&Yt("Only band and point scales support rangeStep.");var r=(i.paddingOuter!=null?i.paddingOuter:i.padding)||0,o=e===Kge?1:(i.paddingInner!=null?i.paddingInner:i.padding)||0;return[0,i.rangeStep*nce(n,o,r)]}function ZZi(e,i,n){var r=i.schemeExtent,o,l;return Pt(i.scheme)?l=Tz(i.scheme,i.interpolate,i.interpolateGamma):(o=i.scheme.toLowerCase(),l=lce(o),l||Yt(`Unrecognized scheme name: ${i.scheme}`)),n=e===wz?n+1:e===gce?n-1:e===jS||e===Sz?+i.schemeCount||cZi:n,aje(e)?rMe(l,r,i.reverse):Rn(l)?lje(rMe(l,r),n):e===rce?l:l.slice(0,n)}function rMe(e,i,n){return Rn(e)&&(i||n)?Ije(e,noe(i||[0,1],n)):e}function noe(e,i){return i?e.slice().reverse():e}function z6e(e){Xt.call(this,null,e)}si(z6e,Xt,{transform(e,i){const n=e.modified("sort")||i.changed(i.ADD)||i.modified(e.sort.fields)||i.modified("datum");return n&&i.source.sort(tZ(e.sort)),this.modified(n),i}});const gMe="zero",O6e="center",L6e="normalize",J6e=["y0","y1"];function qce(e){Xt.call(this,null,e)}qce.Definition={type:"Stack",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"groupby",type:"field",array:!0},{name:"sort",type:"compare"},{name:"offset",type:"enum",default:gMe,values:[gMe,O6e,L6e]},{name:"as",type:"string",array:!0,length:2,default:J6e}]};si(qce,Xt,{transform(e,i){var n=e.as||J6e,r=n[0],o=n[1],l=tZ(e.sort),c=e.field||kw,u=e.offset===O6e?BZi:e.offset===L6e?GZi:SZi,f,m,p,v;for(f=wZi(i.source,e.groupby,l,c),m=0,p=f.length,v=f.max;mV(p),c,u,f,m,p,v,B,G,T;if(i==null)o.push(e.slice());else for(c={},u=0,f=e.length;uT&&(T=G),n&&B.sort(n)}return o.max=T,o}const TZi=Object.freeze(Object.defineProperty({__proto__:null,axisticks:k6e,datajoin:X6e,encode:x6e,legendentries:D6e,linkpath:jce,pie:$ce,scale:_6e,sortitems:z6e,stack:qce},Symbol.toStringTag,{value:"Module"}));var ji=1e-6,x3=1e-12,_n=Math.PI,lo=_n/2,D3=_n/4,hI=_n*2,bo=180/_n,xn=_n/180,ar=Math.abs,Lw=Math.atan,UC=Math.atan2,nn=Math.cos,wF=Math.ceil,U6e=Math.exp,roe=Math.hypot,M3=Math.log,Ite=Math.pow,zi=Math.sin,kC=Math.sign||function(e){return e>0?1:e<0?-1:0},fI=Math.sqrt,eAe=Math.tan;function Q6e(e){return e>1?0:e<-1?_n:Math.acos(e)}function Il(e){return e>1?lo:e<-1?-lo:Math.asin(e)}function Na(){}function F3(e,i){e&&aMe.hasOwnProperty(e.type)&&aMe[e.type](e,i)}var oMe={Feature:function(e,i){F3(e.geometry,i)},FeatureCollection:function(e,i){for(var n=e.features,r=-1,o=n.length;++r=0?1:-1,o=r*n,l=nn(i),c=zi(i),u=soe*c,f=aoe*l+u*nn(o),m=u*r*zi(o);Y3.add(UC(m,f)),ooe=e,aoe=l,soe=c}function HZi(e){return K3=new uI,Eh(e,dd),K3*2}function _3(e){return[UC(e[1],e[0]),Il(e[2])]}function Gv(e){var i=e[0],n=e[1],r=nn(n);return[r*nn(i),r*zi(i),zi(n)]}function TF(e,i){return e[0]*i[0]+e[1]*i[1]+e[2]*i[2]}function rw(e,i){return[e[1]*i[2]-e[2]*i[1],e[2]*i[0]-e[0]*i[2],e[0]*i[1]-e[1]*i[0]]}function lte(e,i){e[0]+=i[0],e[1]+=i[1],e[2]+=i[2]}function RF(e,i){return[e[0]*i,e[1]*i,e[2]*i]}function P3(e){var i=fI(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=i,e[1]/=i,e[2]/=i}var Lg,zI,oo,xl,hy,e8e,t8e,CS,GE,zm,cf,wh={point:Ioe,lineStart:IMe,lineEnd:lMe,polygonStart:function(){wh.point=n8e,wh.lineStart=WZi,wh.lineEnd=NZi,GE=new uI,dd.polygonStart()},polygonEnd:function(){dd.polygonEnd(),wh.point=Ioe,wh.lineStart=IMe,wh.lineEnd=lMe,Y3<0?(Lg=-(oo=180),zI=-(xl=90)):GE>ji?xl=90:GE<-ji&&(zI=-90),cf[0]=Lg,cf[1]=oo},sphere:function(){Lg=-(oo=180),zI=-(xl=90)}};function Ioe(e,i){zm.push(cf=[Lg=e,oo=e]),ixl&&(xl=i)}function i8e(e,i){var n=Gv([e*xn,i*xn]);if(CS){var r=rw(CS,n),o=[r[1],-r[0],0],l=rw(o,r);P3(l),l=_3(l);var c=e-hy,u=c>0?1:-1,f=l[0]*bo*u,m,p=ar(c)>180;p^(u*hyxl&&(xl=m)):(f=(f+360)%360-180,p^(u*hyxl&&(xl=i))),p?eXl(Lg,oo)&&(oo=e):Xl(e,oo)>Xl(Lg,oo)&&(Lg=e):oo>=Lg?(eoo&&(oo=e)):e>hy?Xl(Lg,e)>Xl(Lg,oo)&&(oo=e):Xl(e,oo)>Xl(Lg,oo)&&(Lg=e)}else zm.push(cf=[Lg=e,oo=e]);ixl&&(xl=i),CS=n,hy=e}function IMe(){wh.point=i8e}function lMe(){cf[0]=Lg,cf[1]=oo,wh.point=Ioe,CS=null}function n8e(e,i){if(CS){var n=e-hy;GE.add(ar(n)>180?n+(n>0?360:-360):n)}else e8e=e,t8e=i;dd.point(e,i),i8e(e,i)}function WZi(){dd.lineStart()}function NZi(){n8e(e8e,t8e),dd.lineEnd(),ar(GE)>ji&&(Lg=-(oo=180)),cf[0]=Lg,cf[1]=oo,CS=null}function Xl(e,i){return(i-=e)<0?i+360:i}function kZi(e,i){return e[0]-i[0]}function CMe(e,i){return e[0]<=e[1]?e[0]<=i&&i<=e[1]:iXl(r[0],r[1])&&(r[1]=o[1]),Xl(o[0],r[1])>Xl(r[0],r[1])&&(r[0]=o[0])):l.push(r=o);for(c=-1/0,n=l.length-1,i=0,r=l[n];i<=n;r=o,++i)o=l[i],(u=Xl(r[1],o[0]))>c&&(c=u,Lg=o[0],oo=r[1])}return zm=cf=null,Lg===1/0||zI===1/0?[[NaN,NaN],[NaN,NaN]]:[[Lg,zI],[oo,xl]]}var z9,z3,O3,L3,J3,U3,Q3,j3,loe,Coe,coe,r8e,g8e,oI,aI,sI,lA={sphere:Na,point:tAe,lineStart:cMe,lineEnd:AMe,polygonStart:function(){lA.lineStart=MZi,lA.lineEnd=FZi},polygonEnd:function(){lA.lineStart=cMe,lA.lineEnd=AMe}};function tAe(e,i){e*=xn,i*=xn;var n=nn(i);eN(n*nn(e),n*zi(e),zi(i))}function eN(e,i,n){++z9,O3+=(e-O3)/z9,L3+=(i-L3)/z9,J3+=(n-J3)/z9}function cMe(){lA.point=xZi}function xZi(e,i){e*=xn,i*=xn;var n=nn(i);oI=n*nn(e),aI=n*zi(e),sI=zi(i),lA.point=DZi,eN(oI,aI,sI)}function DZi(e,i){e*=xn,i*=xn;var n=nn(i),r=n*nn(e),o=n*zi(e),l=zi(i),c=UC(fI((c=aI*l-sI*o)*c+(c=sI*r-oI*l)*c+(c=oI*o-aI*r)*c),oI*r+aI*o+sI*l);z3+=c,U3+=c*(oI+(oI=r)),Q3+=c*(aI+(aI=o)),j3+=c*(sI+(sI=l)),eN(oI,aI,sI)}function AMe(){lA.point=tAe}function MZi(){lA.point=YZi}function FZi(){o8e(r8e,g8e),lA.point=tAe}function YZi(e,i){r8e=e,g8e=i,e*=xn,i*=xn,lA.point=o8e;var n=nn(i);oI=n*nn(e),aI=n*zi(e),sI=zi(i),eN(oI,aI,sI)}function o8e(e,i){e*=xn,i*=xn;var n=nn(i),r=n*nn(e),o=n*zi(e),l=zi(i),c=aI*l-sI*o,u=sI*r-oI*l,f=oI*o-aI*r,m=roe(c,u,f),p=Il(m),v=m&&-p/m;loe.add(v*c),Coe.add(v*u),coe.add(v*f),z3+=p,U3+=p*(oI+(oI=r)),Q3+=p*(aI+(aI=o)),j3+=p*(sI+(sI=l)),eN(oI,aI,sI)}function KZi(e){z9=z3=O3=L3=J3=U3=Q3=j3=0,loe=new uI,Coe=new uI,coe=new uI,Eh(e,lA);var i=+loe,n=+Coe,r=+coe,o=roe(i,n,r);return o_n&&(e-=Math.round(e/hI)*hI),[e,i]}uoe.invert=uoe;function a8e(e,i,n){return(e%=hI)?i||n?Aoe(dMe(e),hMe(i,n)):dMe(e):i||n?hMe(i,n):uoe}function uMe(e){return function(i,n){return i+=e,ar(i)>_n&&(i-=Math.round(i/hI)*hI),[i,n]}}function dMe(e){var i=uMe(e);return i.invert=uMe(-e),i}function hMe(e,i){var n=nn(e),r=zi(e),o=nn(i),l=zi(i);function c(u,f){var m=nn(f),p=nn(u)*m,v=zi(u)*m,B=zi(f),G=B*n+p*r;return[UC(v*o-G*l,p*n-B*r),Il(G*o+v*l)]}return c.invert=function(u,f){var m=nn(f),p=nn(u)*m,v=zi(u)*m,B=zi(f),G=B*o-v*l;return[UC(v*o+B*l,p*n+G*r),Il(G*n-p*r)]},c}function _Zi(e){e=a8e(e[0]*xn,e[1]*xn,e.length>2?e[2]*xn:0);function i(n){return n=e(n[0]*xn,n[1]*xn),n[0]*=bo,n[1]*=bo,n}return i.invert=function(n){return n=e.invert(n[0]*xn,n[1]*xn),n[0]*=bo,n[1]*=bo,n},i}function PZi(e,i,n,r,o,l){if(n){var c=nn(i),u=zi(i),f=r*n;o==null?(o=i+r*hI,l=i-f/2):(o=fMe(c,o),l=fMe(c,l),(r>0?ol)&&(o+=r*hI));for(var m,p=o;r>0?p>l:p1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],i=null,n}}}function xY(e,i){return ar(e[0]-i[0])=0;--u)o.point((v=p[u])[0],v[1]);else r(B.x,B.p.x,-1,o);B=B.p}B=B.o,p=B.z,G=!G}while(!B.v);o.lineEnd()}}}function mMe(e){if(i=e.length){for(var i,n=0,r=e[0],o;++n=0?1:-1,$=X*Q,ee=$>_n,ne=E*L;if(f.add(UC(ne*X*zi($),W*O+ne*nn($))),c+=ee?Q+X*hI:Q,ee^T>=n^F>=n){var ge=rw(Gv(G),Gv(k));P3(ge);var Ae=rw(l,ge);P3(Ae);var _=(ee^Q>=0?-1:1)*Il(Ae[2]);(r>_||r===_&&(ge[0]||ge[1]))&&(u+=ee^Q>=0?1:-1)}}return(c<-ji||c0){for(f||(o.polygonStart(),f=!0),o.lineStart(),L=0;L1&&F&2&&Y.push(Y.pop().concat(Y.shift())),p.push(Y.filter(OZi))}}return B}}function OZi(e){return e.length>1}function LZi(e,i){return((e=e.x)[0]<0?e[1]-lo-ji:lo-e[1])-((i=i.x)[0]<0?i[1]-lo-ji:lo-i[1])}const pMe=l8e(function(){return!0},JZi,QZi,[-_n,-lo]);function JZi(e){var i=NaN,n=NaN,r=NaN,o;return{lineStart:function(){e.lineStart(),o=1},point:function(l,c){var u=l>0?_n:-_n,f=ar(l-i);ar(f-_n)0?lo:-lo),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(u,n),e.point(l,n),o=0):r!==u&&f>=_n&&(ar(i-r)ji?Lw((zi(i)*(l=nn(r))*zi(n)-zi(r)*(o=nn(i))*zi(e))/(o*l*c)):(i+r)/2}function QZi(e,i,n,r){var o;if(e==null)o=n*lo,r.point(-_n,o),r.point(0,o),r.point(_n,o),r.point(_n,0),r.point(_n,-o),r.point(0,-o),r.point(-_n,-o),r.point(-_n,0),r.point(-_n,o);else if(ar(e[0]-i[0])>ji){var l=e[0]0,o=ar(i)>ji;function l(p,v,B,G){PZi(G,e,n,B,p,v)}function c(p,v){return nn(p)*nn(v)>i}function u(p){var v,B,G,T,V;return{lineStart:function(){T=G=!1,V=1},point:function(E,W){var x=[E,W],k,F=c(E,W),Y=r?F?0:m(E,W):F?m(E+(E<0?_n:-_n),W):0;if(!v&&(T=G=F)&&p.lineStart(),F!==G&&(k=f(v,x),(!k||xY(v,k)||xY(x,k))&&(x[2]=1)),F!==G)V=0,F?(p.lineStart(),k=f(x,v),p.point(k[0],k[1])):(k=f(v,x),p.point(k[0],k[1],2),p.lineEnd()),v=k;else if(o&&v&&r^F){var L;!(Y&B)&&(L=f(x,v,!0))&&(V=0,r?(p.lineStart(),p.point(L[0][0],L[0][1]),p.point(L[1][0],L[1][1]),p.lineEnd()):(p.point(L[1][0],L[1][1]),p.lineEnd(),p.lineStart(),p.point(L[0][0],L[0][1],3)))}F&&(!v||!xY(v,x))&&p.point(x[0],x[1]),v=x,G=F,B=Y},lineEnd:function(){G&&p.lineEnd(),v=null},clean:function(){return V|(T&&G)<<1}}}function f(p,v,B){var G=Gv(p),T=Gv(v),V=[1,0,0],E=rw(G,T),W=TF(E,E),x=E[0],k=W-x*x;if(!k)return!B&&p;var F=i*W/k,Y=-i*x/k,L=rw(V,E),O=RF(V,F),Q=RF(E,Y);lte(O,Q);var X=L,$=TF(O,X),ee=TF(X,X),ne=$*$-ee*(TF(O,O)-1);if(!(ne<0)){var ge=fI(ne),Ae=RF(X,(-$-ge)/ee);if(lte(Ae,O),Ae=_3(Ae),!B)return Ae;var _=p[0],de=v[0],Ze=p[1],me=v[1],be;de<_&&(be=_,_=de,de=be);var Ee=de-_,Je=ar(Ee-_n)0^Ae[1]<(ar(Ae[0]-_)_n^(_<=Ae[0]&&Ae[0]<=de)){var dt=RF(X,(-$+ge)/ee);return lte(dt,O),[Ae,_3(dt)]}}}function m(p,v){var B=r?e:_n-e,G=0;return p<-B?G|=1:p>B&&(G|=2),v<-B?G|=4:v>B&&(G|=8),G}return l8e(c,u,l,r?[0,-e]:[-_n,e-_n])}function $Zi(e,i,n,r,o,l){var c=e[0],u=e[1],f=i[0],m=i[1],p=0,v=1,B=f-c,G=m-u,T;if(T=n-c,!(!B&&T>0)){if(T/=B,B<0){if(T0){if(T>v)return;T>p&&(p=T)}if(T=o-c,!(!B&&T<0)){if(T/=B,B<0){if(T>v)return;T>p&&(p=T)}else if(B>0){if(T0)){if(T/=G,G<0){if(T0){if(T>v)return;T>p&&(p=T)}if(T=l-u,!(!G&&T<0)){if(T/=G,G<0){if(T>v)return;T>p&&(p=T)}else if(G>0){if(T0&&(e[0]=c+p*B,e[1]=u+p*G),v<1&&(i[0]=c+v*B,i[1]=u+v*G),!0}}}}}var O9=1e9,EF=-O9;function C8e(e,i,n,r){function o(m,p){return e<=m&&m<=n&&i<=p&&p<=r}function l(m,p,v,B){var G=0,T=0;if(m==null||(G=c(m,v))!==(T=c(p,v))||f(m,p)<0^v>0)do B.point(G===0||G===3?e:n,G>1?r:i);while((G=(G+v+4)%4)!==T);else B.point(p[0],p[1])}function c(m,p){return ar(m[0]-e)0?0:3:ar(m[0]-n)0?2:1:ar(m[1]-i)0?1:0:p>0?3:2}function u(m,p){return f(m.x,p.x)}function f(m,p){var v=c(m,1),B=c(p,1);return v!==B?v-B:v===0?p[1]-m[1]:v===1?m[0]-p[0]:v===2?m[1]-p[1]:p[0]-m[0]}return function(m){var p=m,v=s8e(),B,G,T,V,E,W,x,k,F,Y,L,O={point:Q,lineStart:ne,lineEnd:ge,polygonStart:$,polygonEnd:ee};function Q(_,de){o(_,de)&&p.point(_,de)}function X(){for(var _=0,de=0,Ze=G.length;der&&(rt-Ue)*(r-dt)>(ke-dt)*(e-Ue)&&++_:ke<=r&&(rt-Ue)*(r-dt)<(ke-dt)*(e-Ue)&&--_;return _}function $(){p=v,B=[],G=[],L=!0}function ee(){var _=X(),de=L&&_,Ze=(B=o7e(B)).length;(de||Ze)&&(m.polygonStart(),de&&(m.lineStart(),l(null,null,1,m),m.lineEnd()),Ze&&I8e(B,u,_,l,m),m.polygonEnd()),p=m,B=G=T=null}function ne(){O.point=Ae,G&&G.push(T=[]),Y=!0,F=!1,x=k=NaN}function ge(){B&&(Ae(V,E),W&&F&&v.rejoin(),B.push(v.result())),O.point=Q,F&&p.lineEnd()}function Ae(_,de){var Ze=o(_,de);if(G&&T.push([_,de]),Y)V=_,E=de,W=Ze,Y=!1,Ze&&(p.lineStart(),p.point(_,de));else if(Ze&&F)p.point(_,de);else{var me=[x=Math.max(EF,Math.min(O9,x)),k=Math.max(EF,Math.min(O9,k))],be=[_=Math.max(EF,Math.min(O9,_)),de=Math.max(EF,Math.min(O9,de))];$Zi(me,be,e,i,n,r)?(F||(p.lineStart(),p.point(me[0],me[1])),p.point(be[0],be[1]),Ze||p.lineEnd(),L=!1):Ze&&(p.lineStart(),p.point(_,de),L=!1)}x=_,k=de,F=Ze}return O}}function bMe(e,i,n){var r=Yl(e,i-ji,n).concat(i);return function(o){return r.map(function(l){return[o,l]})}}function yMe(e,i,n){var r=Yl(e,i-ji,n).concat(i);return function(o){return r.map(function(l){return[l,o]})}}function qZi(){var e,i,n,r,o,l,c,u,f=10,m=f,p=90,v=360,B,G,T,V,E=2.5;function W(){return{type:"MultiLineString",coordinates:x()}}function x(){return Yl(wF(r/p)*p,n,p).map(T).concat(Yl(wF(u/v)*v,c,v).map(V)).concat(Yl(wF(i/f)*f,e,f).filter(function(k){return ar(k%p)>ji}).map(B)).concat(Yl(wF(l/m)*m,o,m).filter(function(k){return ar(k%v)>ji}).map(G))}return W.lines=function(){return x().map(function(k){return{type:"LineString",coordinates:k}})},W.outline=function(){return{type:"Polygon",coordinates:[T(r).concat(V(c).slice(1),T(n).reverse().slice(1),V(u).reverse().slice(1))]}},W.extent=function(k){return arguments.length?W.extentMajor(k).extentMinor(k):W.extentMinor()},W.extentMajor=function(k){return arguments.length?(r=+k[0][0],n=+k[1][0],u=+k[0][1],c=+k[1][1],r>n&&(k=r,r=n,n=k),u>c&&(k=u,u=c,c=k),W.precision(E)):[[r,u],[n,c]]},W.extentMinor=function(k){return arguments.length?(i=+k[0][0],e=+k[1][0],l=+k[0][1],o=+k[1][1],i>e&&(k=i,i=e,e=k),l>o&&(k=l,l=o,o=k),W.precision(E)):[[i,l],[e,o]]},W.step=function(k){return arguments.length?W.stepMajor(k).stepMinor(k):W.stepMinor()},W.stepMajor=function(k){return arguments.length?(p=+k[0],v=+k[1],W):[p,v]},W.stepMinor=function(k){return arguments.length?(f=+k[0],m=+k[1],W):[f,m]},W.precision=function(k){return arguments.length?(E=+k,B=bMe(l,o,90),G=yMe(i,e,E),T=bMe(u,c,90),V=yMe(r,n,E),W):E},W.extentMajor([[-180,-90+ji],[180,90-ji]]).extentMinor([[-180,-80-ji],[180,80+ji]])}const _H=e=>e;var cte=new uI,doe=new uI,c8e,A8e,hoe,foe,jm={point:Na,lineStart:Na,lineEnd:Na,polygonStart:function(){jm.lineStart=e1i,jm.lineEnd=i1i},polygonEnd:function(){jm.lineStart=jm.lineEnd=jm.point=Na,cte.add(ar(doe)),doe=new uI},result:function(){var e=cte/2;return cte=new uI,e}};function e1i(){jm.point=t1i}function t1i(e,i){jm.point=u8e,c8e=hoe=e,A8e=foe=i}function u8e(e,i){doe.add(foe*e-hoe*i),hoe=e,foe=i}function i1i(){u8e(c8e,A8e)}const vMe=jm;var gw=1/0,$3=gw,PH=-gw,q3=PH,n1i={point:r1i,lineStart:Na,lineEnd:Na,polygonStart:Na,polygonEnd:Na,result:function(){var e=[[gw,$3],[PH,q3]];return PH=q3=-($3=gw=1/0),e}};function r1i(e,i){ePH&&(PH=e),i<$3&&($3=i),i>q3&&(q3=i)}const e_=n1i;var moe=0,poe=0,L9=0,t_=0,i_=0,UG=0,boe=0,yoe=0,J9=0,d8e,h8e,Mu,Fu,gA={point:Sv,lineStart:ZMe,lineEnd:BMe,polygonStart:function(){gA.lineStart=a1i,gA.lineEnd=s1i},polygonEnd:function(){gA.point=Sv,gA.lineStart=ZMe,gA.lineEnd=BMe},result:function(){var e=J9?[boe/J9,yoe/J9]:UG?[t_/UG,i_/UG]:L9?[moe/L9,poe/L9]:[NaN,NaN];return moe=poe=L9=t_=i_=UG=boe=yoe=J9=0,e}};function Sv(e,i){moe+=e,poe+=i,++L9}function ZMe(){gA.point=g1i}function g1i(e,i){gA.point=o1i,Sv(Mu=e,Fu=i)}function o1i(e,i){var n=e-Mu,r=i-Fu,o=fI(n*n+r*r);t_+=o*(Mu+e)/2,i_+=o*(Fu+i)/2,UG+=o,Sv(Mu=e,Fu=i)}function BMe(){gA.point=Sv}function a1i(){gA.point=I1i}function s1i(){f8e(d8e,h8e)}function I1i(e,i){gA.point=f8e,Sv(d8e=Mu=e,h8e=Fu=i)}function f8e(e,i){var n=e-Mu,r=i-Fu,o=fI(n*n+r*r);t_+=o*(Mu+e)/2,i_+=o*(Fu+i)/2,UG+=o,o=Fu*e-Mu*i,boe+=o*(Mu+e),yoe+=o*(Fu+i),J9+=o*3,Sv(Mu=e,Fu=i)}const GMe=gA;function m8e(e){this._context=e}m8e.prototype={_radius:4.5,pointRadius:function(e){return this._radius=e,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(e,i){switch(this._point){case 0:{this._context.moveTo(e,i),this._point=1;break}case 1:{this._context.lineTo(e,i);break}default:{this._context.moveTo(e+this._radius,i),this._context.arc(e,i,this._radius,0,hI);break}}},result:Na};var voe=new uI,Ate,p8e,b8e,U9,Q9,n_={point:Na,lineStart:function(){n_.point=l1i},lineEnd:function(){Ate&&y8e(p8e,b8e),n_.point=Na},polygonStart:function(){Ate=!0},polygonEnd:function(){Ate=null},result:function(){var e=+voe;return voe=new uI,e}};function l1i(e,i){n_.point=y8e,p8e=U9=e,b8e=Q9=i}function y8e(e,i){U9-=e,Q9-=i,voe.add(fI(U9*U9+Q9*Q9)),U9=e,Q9=i}const SMe=n_;let wMe,r_,TMe,RMe;class VMe{constructor(i){this._append=i==null?v8e:C1i(i),this._radius=4.5,this._=""}pointRadius(i){return this._radius=+i,this}polygonStart(){this._line=0}polygonEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){this._line===0&&(this._+="Z"),this._point=NaN}point(i,n){switch(this._point){case 0:{this._append`M${i},${n}`,this._point=1;break}case 1:{this._append`L${i},${n}`;break}default:{if(this._append`M${i},${n}`,this._radius!==TMe||this._append!==r_){const r=this._radius,o=this._;this._="",this._append`m0,${r}a${r},${r} 0 1,1 0,${-2*r}a${r},${r} 0 1,1 0,${2*r}z`,TMe=r,r_=this._append,RMe=this._,this._=o}this._+=RMe;break}}}result(){const i=this._;return this._="",i.length?i:null}}function v8e(e){let i=1;this._+=e[0];for(const n=e.length;i=0))throw new RangeError(`invalid digits: ${e}`);if(i>15)return v8e;if(i!==wMe){const n=10**i;wMe=i,r_=function(o){let l=1;this._+=o[0];for(const c=o.length;l=0))throw new RangeError(`invalid digits: ${u}`);n=f}return i===null&&(l=new VMe(n)),c},c.projection(e).digits(n).context(i)}function Yz(e){return function(i){var n=new Zoe;for(var r in e)n[r]=e[r];return n.stream=i,n}}function Zoe(){}Zoe.prototype={constructor:Zoe,point:function(e,i){this.stream.point(e,i)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function iAe(e,i,n){var r=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),r!=null&&e.clipExtent(null),Eh(n,e.stream(e_)),i(e_.result()),r!=null&&e.clipExtent(r),e}function Kz(e,i,n){return iAe(e,function(r){var o=i[1][0]-i[0][0],l=i[1][1]-i[0][1],c=Math.min(o/(r[1][0]-r[0][0]),l/(r[1][1]-r[0][1])),u=+i[0][0]+(o-c*(r[1][0]+r[0][0]))/2,f=+i[0][1]+(l-c*(r[1][1]+r[0][1]))/2;e.scale(150*c).translate([u,f])},n)}function nAe(e,i,n){return Kz(e,[[0,0],i],n)}function rAe(e,i,n){return iAe(e,function(r){var o=+i,l=o/(r[1][0]-r[0][0]),c=(o-l*(r[1][0]+r[0][0]))/2,u=-l*r[0][1];e.scale(150*l).translate([c,u])},n)}function gAe(e,i,n){return iAe(e,function(r){var o=+i,l=o/(r[1][1]-r[0][1]),c=-l*r[0][0],u=(o-l*(r[1][1]+r[0][1]))/2;e.scale(150*l).translate([c,u])},n)}var EMe=16,c1i=nn(30*xn);function HMe(e,i){return+i?u1i(e,i):A1i(e)}function A1i(e){return Yz({point:function(i,n){i=e(i,n),this.stream.point(i[0],i[1])}})}function u1i(e,i){function n(r,o,l,c,u,f,m,p,v,B,G,T,V,E){var W=m-r,x=p-o,k=W*W+x*x;if(k>4*i&&V--){var F=c+B,Y=u+G,L=f+T,O=fI(F*F+Y*Y+L*L),Q=Il(L/=O),X=ar(ar(L)-1)i||ar((W*ge+x*Ae)/k-.5)>.3||c*B+u*G+f*T2?_[2]%360*xn:0,ge()):[u*bo,f*bo,m*bo]},ee.angle=function(_){return arguments.length?(v=_%360*xn,ge()):v*bo},ee.reflectX=function(_){return arguments.length?(B=_?-1:1,ge()):B<0},ee.reflectY=function(_){return arguments.length?(G=_?-1:1,ge()):G<0},ee.precision=function(_){return arguments.length?(L=HMe(O,Y=_*_),Ae()):fI(Y)},ee.fitExtent=function(_,de){return Kz(ee,_,de)},ee.fitSize=function(_,de){return nAe(ee,_,de)},ee.fitWidth=function(_,de){return rAe(ee,_,de)},ee.fitHeight=function(_,de){return gAe(ee,_,de)};function ge(){var _=WMe(n,0,0,B,G,v).apply(null,i(l,c)),de=WMe(n,r-_[0],o-_[1],B,G,v);return p=a8e(u,f,m),O=Aoe(i,de),Q=Aoe(p,O),L=HMe(O,Y),Ae()}function Ae(){return X=$=null,ee}return function(){return i=e.apply(this,arguments),ee.invert=i.invert&&ne,ge()}}function oAe(e){var i=0,n=_n/3,r=B8e(e),o=r(i,n);return o.parallels=function(l){return arguments.length?r(i=l[0]*xn,n=l[1]*xn):[i*bo,n*bo]},o}function m1i(e){var i=nn(e);function n(r,o){return[r*i,zi(o)/i]}return n.invert=function(r,o){return[r/i,Il(o*i)]},n}function p1i(e,i){var n=zi(e),r=(n+zi(i))/2;if(ar(r)=.12&&E<.234&&V>=-.425&&V<-.214?o:E>=.166&&E<.234&&V>=-.214&&V<-.115?c:n).invert(B)},p.stream=function(B){return e&&i===B?e:e=b1i([n.stream(i=B),o.stream(B),c.stream(B)])},p.precision=function(B){return arguments.length?(n.precision(B),o.precision(B),c.precision(B),v()):n.precision()},p.scale=function(B){return arguments.length?(n.scale(B),o.scale(B*.35),c.scale(B),p.translate(n.translate())):n.scale()},p.translate=function(B){if(!arguments.length)return n.translate();var G=n.scale(),T=+B[0],V=+B[1];return r=n.translate(B).clipExtent([[T-.455*G,V-.238*G],[T+.455*G,V+.238*G]]).stream(m),l=o.translate([T-.307*G,V+.201*G]).clipExtent([[T-.425*G+ji,V+.12*G+ji],[T-.214*G-ji,V+.234*G-ji]]).stream(m),u=c.translate([T-.205*G,V+.212*G]).clipExtent([[T-.214*G+ji,V+.166*G+ji],[T-.115*G-ji,V+.234*G-ji]]).stream(m),v()},p.fitExtent=function(B,G){return Kz(p,B,G)},p.fitSize=function(B,G){return nAe(p,B,G)},p.fitWidth=function(B,G){return rAe(p,B,G)},p.fitHeight=function(B,G){return gAe(p,B,G)};function v(){return e=i=null,p}return p.scale(1070)}function S8e(e){return function(i,n){var r=nn(i),o=nn(n),l=e(r*o);return l===1/0?[2,0]:[l*o*zi(i),l*zi(n)]}}function tN(e){return function(i,n){var r=fI(i*i+n*n),o=e(r),l=zi(o),c=nn(o);return[UC(i*l,r*c),Il(r&&n*l/r)]}}var w8e=S8e(function(e){return fI(2/(1+e))});w8e.invert=tN(function(e){return 2*Il(e/2)});function v1i(){return Sd(w8e).scale(124.75).clipAngle(180-.001)}var T8e=S8e(function(e){return(e=Q6e(e))&&e/zi(e)});T8e.invert=tN(function(e){return e});function Z1i(){return Sd(T8e).scale(79.4188).clipAngle(180-.001)}function _z(e,i){return[e,M3(eAe((lo+i)/2))]}_z.invert=function(e,i){return[e,2*Lw(U6e(i))-lo]};function B1i(){return R8e(_z).scale(961/hI)}function R8e(e){var i=Sd(e),n=i.center,r=i.scale,o=i.translate,l=i.clipExtent,c=null,u,f,m;i.scale=function(v){return arguments.length?(r(v),p()):r()},i.translate=function(v){return arguments.length?(o(v),p()):o()},i.center=function(v){return arguments.length?(n(v),p()):n()},i.clipExtent=function(v){return arguments.length?(v==null?c=u=f=m=null:(c=+v[0][0],u=+v[0][1],f=+v[1][0],m=+v[1][1]),p()):c==null?null:[[c,u],[f,m]]};function p(){var v=_n*r(),B=i(_Zi(i.rotate()).invert([0,0]));return l(c==null?[[B[0]-v,B[1]-v],[B[0]+v,B[1]+v]]:e===_z?[[Math.max(B[0]-v,c),u],[Math.min(B[0]+v,f),m]]:[[c,Math.max(B[1]-v,u)],[f,Math.min(B[1]+v,m)]])}return p()}function HF(e){return eAe((lo+e)/2)}function G1i(e,i){var n=nn(e),r=e===i?zi(e):M3(n/nn(i))/M3(HF(i)/HF(e)),o=n*Ite(HF(e),r)/r;if(!r)return _z;function l(c,u){o>0?u<-lo+ji&&(u=-lo+ji):u>lo-ji&&(u=lo-ji);var f=o/Ite(HF(u),r);return[f*zi(r*c),o-f*nn(r*c)]}return l.invert=function(c,u){var f=o-u,m=kC(r)*fI(c*c+f*f),p=UC(c,ar(f))*kC(f);return f*r<0&&(p-=_n*kC(c)*kC(f)),[p/r,2*Lw(Ite(o/m,1/r))-lo]},l}function S1i(){return oAe(G1i).scale(109.5).parallels([30,30])}function o_(e,i){return[e,i]}o_.invert=o_;function w1i(){return Sd(o_).scale(152.63)}function T1i(e,i){var n=nn(e),r=e===i?zi(e):(n-nn(i))/(i-e),o=n/r+e;if(ar(r)ji&&--r>0);return[e/(.8707+(l=n*n)*(-.131979+l*(-.013791+l*l*l*(.003971-.001529*l)))),n]};function N1i(){return Sd(H8e).scale(175.295)}function W8e(e,i){return[nn(i)*zi(e),zi(i)]}W8e.invert=tN(Il);function k1i(){return Sd(W8e).scale(249.5).clipAngle(90+ji)}function N8e(e,i){var n=nn(i),r=1+nn(e)*n;return[n*zi(e)/r,zi(i)/r]}N8e.invert=tN(function(e){return 2*Lw(e)});function X1i(){return Sd(N8e).scale(250).clipAngle(142)}function k8e(e,i){return[M3(eAe((lo+i)/2)),-e]}k8e.invert=function(e,i){return[-i,2*Lw(U6e(e))-lo]};function x1i(){var e=R8e(k8e),i=e.center,n=e.rotate;return e.center=function(r){return arguments.length?i([-r[1],r[0]]):(r=i(),[r[1],-r[0]])},e.rotate=function(r){return arguments.length?n([r[0],r[1],r.length>2?r[2]+90:90]):(r=n(),[r[0],r[1],r[2]-90])},n([0,0,90]).scale(159.155)}var D1i=Math.abs,Boe=Math.cos,s_=Math.sin,M1i=1e-6,X8e=Math.PI,Goe=X8e/2,NMe=F1i(2);function kMe(e){return e>1?Goe:e<-1?-Goe:Math.asin(e)}function F1i(e){return e>0?Math.sqrt(e):0}function Y1i(e,i){var n=e*s_(i),r=30,o;do i-=o=(i+s_(i)-n)/(1+Boe(i));while(D1i(o)>M1i&&--r>0);return i/2}function K1i(e,i,n){function r(o,l){return[e*o*Boe(l=Y1i(n,l)),i*s_(l)]}return r.invert=function(o,l){return l=kMe(l/i),[o/(e*Boe(l)),kMe((2*l+s_(2*l))/n)]},r}var _1i=K1i(NMe/Goe,NMe,X8e);function P1i(){return Sd(_1i).scale(169.529)}const z1i=Z8e(),Soe=["clipAngle","clipExtent","scale","translate","center","rotate","parallels","precision","reflectX","reflectY","coefficient","distance","fraction","lobes","parallel","radius","ratio","spacing","tilt"];function O1i(e,i){return function n(){const r=i();return r.type=e,r.path=Z8e().projection(r),r.copy=r.copy||function(){const o=n();return Soe.forEach(l=>{r[l]&&o[l](r[l]())}),o.path.pointRadius(r.path.pointRadius()),o},rje(r)}}function aAe(e,i){if(!e||typeof e!="string")throw new Error("Projection type must be a name string.");return e=e.toLowerCase(),arguments.length>1?(I_[e]=O1i(e,i),this):I_[e]||null}function x8e(e){return e&&e.path||z1i}const I_={albers:G8e,albersusa:y1i,azimuthalequalarea:v1i,azimuthalequidistant:Z1i,conicconformal:S1i,conicequalarea:g_,conicequidistant:R1i,equalEarth:E1i,equirectangular:w1i,gnomonic:H1i,identity:W1i,mercator:B1i,mollweide:P1i,naturalEarth1:N1i,orthographic:k1i,stereographic:X1i,transversemercator:x1i};for(const e in I_)aAe(e,I_[e]);function sAe(e,i,n){e.prototype=i.prototype=n,n.constructor=e}function D8e(e,i){var n=Object.create(e.prototype);for(var r in i)n[r]=i[r];return n}function iN(){}var zH=.7,l_=1/zH,cS="\\s*([+-]?\\d+)\\s*",OH="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",qu="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",L1i=/^#([0-9a-f]{3,8})$/,J1i=new RegExp(`^rgb\\(${cS},${cS},${cS}\\)$`),U1i=new RegExp(`^rgb\\(${qu},${qu},${qu}\\)$`),Q1i=new RegExp(`^rgba\\(${cS},${cS},${cS},${OH}\\)$`),j1i=new RegExp(`^rgba\\(${qu},${qu},${qu},${OH}\\)$`),$1i=new RegExp(`^hsl\\(${OH},${qu},${qu}\\)$`),q1i=new RegExp(`^hsla\\(${OH},${qu},${qu},${OH}\\)$`),XMe={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};sAe(iN,IAe,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:xMe,formatHex:xMe,formatHex8:eBi,formatHsl:tBi,formatRgb:DMe,toString:DMe});function xMe(){return this.rgb().formatHex()}function eBi(){return this.rgb().formatHex8()}function tBi(){return M8e(this).formatHsl()}function DMe(){return this.rgb().formatRgb()}function IAe(e){var i,n;return e=(e+"").trim().toLowerCase(),(i=L1i.exec(e))?(n=i[1].length,i=parseInt(i[1],16),n===6?MMe(i):n===3?new $I(i>>8&15|i>>4&240,i>>4&15|i&240,(i&15)<<4|i&15,1):n===8?WF(i>>24&255,i>>16&255,i>>8&255,(i&255)/255):n===4?WF(i>>12&15|i>>8&240,i>>8&15|i>>4&240,i>>4&15|i&240,((i&15)<<4|i&15)/255):null):(i=J1i.exec(e))?new $I(i[1],i[2],i[3],1):(i=U1i.exec(e))?new $I(i[1]*255/100,i[2]*255/100,i[3]*255/100,1):(i=Q1i.exec(e))?WF(i[1],i[2],i[3],i[4]):(i=j1i.exec(e))?WF(i[1]*255/100,i[2]*255/100,i[3]*255/100,i[4]):(i=$1i.exec(e))?KMe(i[1],i[2]/100,i[3]/100,1):(i=q1i.exec(e))?KMe(i[1],i[2]/100,i[3]/100,i[4]):XMe.hasOwnProperty(e)?MMe(XMe[e]):e==="transparent"?new $I(NaN,NaN,NaN,0):null}function MMe(e){return new $I(e>>16&255,e>>8&255,e&255,1)}function WF(e,i,n,r){return r<=0&&(e=i=n=NaN),new $I(e,i,n,r)}function iBi(e){return e instanceof iN||(e=IAe(e)),e?(e=e.rgb(),new $I(e.r,e.g,e.b,e.opacity)):new $I}function woe(e,i,n,r){return arguments.length===1?iBi(e):new $I(e,i,n,r??1)}function $I(e,i,n,r){this.r=+e,this.g=+i,this.b=+n,this.opacity=+r}sAe($I,woe,D8e(iN,{brighter(e){return e=e==null?l_:Math.pow(l_,e),new $I(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?zH:Math.pow(zH,e),new $I(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new $I(Jy(this.r),Jy(this.g),Jy(this.b),C_(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:FMe,formatHex:FMe,formatHex8:nBi,formatRgb:YMe,toString:YMe}));function FMe(){return`#${Hy(this.r)}${Hy(this.g)}${Hy(this.b)}`}function nBi(){return`#${Hy(this.r)}${Hy(this.g)}${Hy(this.b)}${Hy((isNaN(this.opacity)?1:this.opacity)*255)}`}function YMe(){const e=C_(this.opacity);return`${e===1?"rgb(":"rgba("}${Jy(this.r)}, ${Jy(this.g)}, ${Jy(this.b)}${e===1?")":`, ${e})`}`}function C_(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Jy(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Hy(e){return e=Jy(e),(e<16?"0":"")+e.toString(16)}function KMe(e,i,n,r){return r<=0?e=i=n=NaN:n<=0||n>=1?e=i=NaN:i<=0&&(e=NaN),new oA(e,i,n,r)}function M8e(e){if(e instanceof oA)return new oA(e.h,e.s,e.l,e.opacity);if(e instanceof iN||(e=IAe(e)),!e)return new oA;if(e instanceof oA)return e;e=e.rgb();var i=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(i,n,r),l=Math.max(i,n,r),c=NaN,u=l-o,f=(l+o)/2;return u?(i===l?c=(n-r)/u+(n0&&f<1?0:c,new oA(c,u,f,e.opacity)}function rBi(e,i,n,r){return arguments.length===1?M8e(e):new oA(e,i,n,r??1)}function oA(e,i,n,r){this.h=+e,this.s=+i,this.l=+n,this.opacity=+r}sAe(oA,rBi,D8e(iN,{brighter(e){return e=e==null?l_:Math.pow(l_,e),new oA(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?zH:Math.pow(zH,e),new oA(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,i=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*i,o=2*n-r;return new $I(ute(e>=240?e-240:e+120,o,r),ute(e,o,r),ute(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new oA(_Me(this.h),NF(this.s),NF(this.l),C_(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=C_(this.opacity);return`${e===1?"hsl(":"hsla("}${_Me(this.h)}, ${NF(this.s)*100}%, ${NF(this.l)*100}%${e===1?")":`, ${e})`}`}}));function _Me(e){return e=(e||0)%360,e<0?e+360:e}function NF(e){return Math.max(0,Math.min(1,e||0))}function ute(e,i,n){return(e<60?i+(n-i)*e/60:e<180?n:e<240?i+(n-i)*(240-e)/60:i)*255}function gBi(){}const mh=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function F8e(){var e=1,i=1,n=u;function r(f,m){return m.map(p=>o(f,p))}function o(f,m){var p=[],v=[];return l(f,m,B=>{n(B,f,m),oBi(B)>0?p.push([B]):v.push(B)}),v.forEach(B=>{for(var G=0,T=p.length,V;G=m,mh[E<<1].forEach(k);++G=m,mh[V|E<<1].forEach(k);for(mh[E<<0].forEach(k);++T=m,W=f[T*e]>=m,mh[E<<1|W<<2].forEach(k);++G=m,x=W,W=f[T*e+G+1]>=m,mh[V|E<<1|W<<2|x<<3].forEach(k);mh[E|W<<3].forEach(k)}for(G=-1,W=f[T*e]>=m,mh[W<<2].forEach(k);++G=m,mh[W<<2|x<<3].forEach(k);mh[W<<3].forEach(k);function k(F){var Y=[F[0][0]+G,F[0][1]+T],L=[F[1][0]+G,F[1][1]+T],O=c(Y),Q=c(L),X,$;(X=B[O])?($=v[Q])?(delete B[X.end],delete v[$.start],X===$?(X.ring.push(L),p(X.ring)):v[X.start]=B[$.end]={start:X.start,end:$.end,ring:X.ring.concat($.ring)}):(delete B[X.end],X.ring.push(L),B[X.end=Q]=X):(X=v[Q])?($=B[O])?(delete v[X.start],delete B[$.end],X===$?(X.ring.push(L),p(X.ring)):v[$.start]=B[X.end]={start:$.start,end:X.end,ring:$.ring.concat(X.ring)}):(delete v[X.start],X.ring.unshift(Y),v[X.start=O]=X):v[O]=B[Q]={start:O,end:Q,ring:[Y,L]}}}function c(f){return f[0]*2+f[1]*(e+1)*4}function u(f,m,p){f.forEach(v=>{var B=v[0],G=v[1],T=B|0,V=G|0,E,W=m[V*e+T];B>0&&B0&&G=0&&p>=0||Yt("invalid size"),e=m,i=p,r},r.smooth=function(f){return arguments.length?(n=f?u:gBi,r):n===u},r}function oBi(e){for(var i=0,n=e.length,r=e[n-1][1]*e[0][0]-e[n-1][0]*e[0][1];++ir!=G>r&&n<(B-m)*(r-p)/(G-p)+m&&(o=-o)}return o}function IBi(e,i,n){var r;return lBi(e,i,n)&&CBi(e[r=+(e[0]===i[0])],n[r],i[r])}function lBi(e,i,n){return(i[0]-e[0])*(n[1]-e[1])===(n[0]-e[0])*(i[1]-e[1])}function CBi(e,i,n){return e<=i&&i<=n||n<=i&&i<=e}function Y8e(e,i,n){return function(r){var o=Cd(r),l=n?Math.min(o[0],0):o[0],c=o[1],u=c-l,f=i?Mp(l,c,e):u/(e+1);return Yl(l+f,c,f)}}function lAe(e){Xt.call(this,null,e)}lAe.Definition={type:"Isocontour",metadata:{generates:!0},params:[{name:"field",type:"field"},{name:"thresholds",type:"number",array:!0},{name:"levels",type:"number"},{name:"nice",type:"boolean",default:!1},{name:"resolve",type:"enum",values:["shared","independent"],default:"independent"},{name:"zero",type:"boolean",default:!0},{name:"smooth",type:"boolean",default:!0},{name:"scale",type:"number",expr:!0},{name:"translate",type:"number",array:!0,expr:!0},{name:"as",type:"string",null:!0,default:"contour"}]};si(lAe,Xt,{transform(e,i){if(this.value&&!i.changed()&&!e.modified())return i.StopPropagation;var n=i.fork(i.NO_SOURCE|i.NO_FIELDS),r=i.materialize(i.SOURCE).source,o=e.field||Hs,l=F8e().smooth(e.smooth!==!1),c=e.thresholds||cBi(r,o,e),u=e.as===null?null:e.as||"contour",f=[];return r.forEach(m=>{const p=o(m),v=l.size([p.width,p.height])(p.values,Pt(c)?c:c(p.values));ABi(v,p,m,e),v.forEach(B=>{f.push(oz(m,Vr(u!=null?{[u]:B}:B)))})}),this.value&&(n.rem=this.value),this.value=n.source=n.add=f,n}});function cBi(e,i,n){const r=Y8e(n.levels||10,n.nice,n.zero!==!1);return n.resolve!=="shared"?r:r(e.map(o=>Py(i(o).values)))}function ABi(e,i,n,r){let o=r.scale||i.scale,l=r.translate||i.translate;if(Rn(o)&&(o=o(n,r)),Rn(l)&&(l=l(n,r)),(o===1||o==null)&&!l)return;const c=(jr(o)?o:o[0])||1,u=(jr(o)?o:o[1])||1,f=l&&l[0]||0,m=l&&l[1]||0;e.forEach(K8e(i,c,u,f,m))}function K8e(e,i,n,r,o){const l=e.x1||0,c=e.y1||0,u=i*n<0;function f(v){v.forEach(m)}function m(v){u&&v.reverse(),v.forEach(p)}function p(v){v[0]=(v[0]-l)*i+r,v[1]=(v[1]-c)*n+o}return function(v){return v.coordinates.forEach(f),v}}function PMe(e,i,n){const r=e>=0?e:Ule(i,n);return Math.round((Math.sqrt(4*r*r+1)-1)/2)}function dte(e){return Rn(e)?e:Ws(+e)}function _8e(){var e=f=>f[0],i=f=>f[1],n=kw,r=[-1,-1],o=960,l=500,c=2;function u(f,m){const p=PMe(r[0],f,e)>>c,v=PMe(r[1],f,i)>>c,B=p?p+2:0,G=v?v+2:0,T=2*B+(o>>c),V=2*G+(l>>c),E=new Float32Array(T*V),W=new Float32Array(T*V);let x=E;f.forEach(F=>{const Y=B+(+e(F)>>c),L=G+(+i(F)>>c);Y>=0&&Y=0&&L0&&v>0?(hG(T,V,E,W,p),fG(T,V,W,E,v),hG(T,V,E,W,p),fG(T,V,W,E,v),hG(T,V,E,W,p),fG(T,V,W,E,v)):p>0?(hG(T,V,E,W,p),hG(T,V,W,E,p),hG(T,V,E,W,p),x=W):v>0&&(fG(T,V,E,W,v),fG(T,V,W,E,v),fG(T,V,E,W,v),x=W);const k=m?Math.pow(2,-2*c):1/a7e(x);for(let F=0,Y=T*V;F>c),y2:G+(l>>c)}}return u.x=function(f){return arguments.length?(e=dte(f),u):e},u.y=function(f){return arguments.length?(i=dte(f),u):i},u.weight=function(f){return arguments.length?(n=dte(f),u):n},u.size=function(f){if(!arguments.length)return[o,l];var m=+f[0],p=+f[1];return m>=0&&p>=0||Yt("invalid size"),o=m,l=p,u},u.cellSize=function(f){return arguments.length?((f=+f)>=1||Yt("invalid cell size"),c=Math.floor(Math.log(f)/Math.LN2),u):1<=o&&(u>=l&&(f-=n[u-l+c*e]),r[u-o+c*e]=f/Math.min(u+1,e-1+l-u,l))}function fG(e,i,n,r,o){const l=(o<<1)+1;for(let c=0;c=o&&(u>=l&&(f-=n[c+(u-l)*e]),r[c+(u-o)*e]=f/Math.min(u+1,i-1+l-u,l))}function CAe(e){Xt.call(this,null,e)}CAe.Definition={type:"KDE2D",metadata:{generates:!0},params:[{name:"size",type:"number",array:!0,length:2,required:!0},{name:"x",type:"field",required:!0},{name:"y",type:"field",required:!0},{name:"weight",type:"field"},{name:"groupby",type:"field",array:!0},{name:"cellSize",type:"number"},{name:"bandwidth",type:"number",array:!0,length:2},{name:"counts",type:"boolean",default:!1},{name:"as",type:"string",default:"grid"}]};const uBi=["x","y","weight","size","cellSize","bandwidth"];function P8e(e,i){return uBi.forEach(n=>i[n]!=null?e[n](i[n]):0),e}si(CAe,Xt,{transform(e,i){if(this.value&&!i.changed()&&!e.modified())return i.StopPropagation;var n=i.fork(i.NO_SOURCE|i.NO_FIELDS),r=i.materialize(i.SOURCE).source,o=dBi(r,e.groupby),l=(e.groupby||[]).map(co),c=P8e(_8e(),e),u=e.as||"grid",f=[];function m(p,v){for(let B=0;BVr(m({[u]:c(p,e.counts)},p.dims))),this.value&&(n.rem=this.value),this.value=n.source=n.add=f,n}});function dBi(e,i){var n=[],r=p=>p(u),o,l,c,u,f,m;if(i==null)n.push(e);else for(o={},l=0,c=e.length;ln.push(u(p))),l&&c&&(i.visit(f,p=>{var v=l(p),B=c(p);v!=null&&B!=null&&(v=+v)===v&&(B=+B)===B&&r.push([v,B])}),n=n.concat({type:Toe,geometry:{type:hBi,coordinates:r}})),this.value={type:AAe,features:n}}});function dAe(e){Xt.call(this,null,e)}dAe.Definition={type:"GeoPath",metadata:{modifies:!0},params:[{name:"projection",type:"projection"},{name:"field",type:"field"},{name:"pointRadius",type:"number",expr:!0},{name:"as",type:"string",default:"path"}]};si(dAe,Xt,{transform(e,i){var n=i.fork(i.ALL),r=this.value,o=e.field||Hs,l=e.as||"path",c=n.SOURCE;!r||e.modified()?(this.value=r=x8e(e.projection),n.materialize().reflow()):c=o===Hs||i.modified(o.fields)?n.ADD_MOD:n.ADD;const u=fBi(r,e.pointRadius);return n.visit(c,f=>f[l]=r(o(f))),r.pointRadius(u),n.modifies(l)}});function fBi(e,i){const n=e.pointRadius();return e.context(null),i!=null&&e.pointRadius(i),n}function hAe(e){Xt.call(this,null,e)}hAe.Definition={type:"GeoPoint",metadata:{modifies:!0},params:[{name:"projection",type:"projection",required:!0},{name:"fields",type:"field",array:!0,required:!0,length:2},{name:"as",type:"string",array:!0,length:2,default:["x","y"]}]};si(hAe,Xt,{transform(e,i){var n=e.projection,r=e.fields[0],o=e.fields[1],l=e.as||["x","y"],c=l[0],u=l[1],f;function m(p){const v=n([r(p),o(p)]);v?(p[c]=v[0],p[u]=v[1]):(p[c]=void 0,p[u]=void 0)}return e.modified()?i=i.materialize().reflow(!0).visit(i.SOURCE,m):(f=i.modified(r.fields)||i.modified(o.fields),i.visit(f?i.ADD_MOD:i.ADD,m)),i.modifies(l)}});function fAe(e){Xt.call(this,null,e)}fAe.Definition={type:"GeoShape",metadata:{modifies:!0,nomod:!0},params:[{name:"projection",type:"projection"},{name:"field",type:"field",default:"datum"},{name:"pointRadius",type:"number",expr:!0},{name:"as",type:"string",default:"shape"}]};si(fAe,Xt,{transform(e,i){var n=i.fork(i.ALL),r=this.value,o=e.as||"shape",l=n.ADD;return(!r||e.modified())&&(this.value=r=mBi(x8e(e.projection),e.field||ol("datum"),e.pointRadius),n.materialize().reflow(),l=n.SOURCE),n.visit(l,c=>c[o]=r),n.modifies(o)}});function mBi(e,i,n){const r=n==null?o=>e(i(o)):o=>{var l=e.pointRadius(),c=e.pointRadius(n)(i(o));return e.pointRadius(l),c};return r.context=o=>(e.context(o),r),r}function mAe(e){Xt.call(this,[],e),this.generator=qZi()}mAe.Definition={type:"Graticule",metadata:{changes:!0,generates:!0},params:[{name:"extent",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"extentMajor",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"extentMinor",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"step",type:"number",array:!0,length:2},{name:"stepMajor",type:"number",array:!0,length:2,default:[90,360]},{name:"stepMinor",type:"number",array:!0,length:2,default:[10,10]},{name:"precision",type:"number",default:2.5}]};si(mAe,Xt,{transform(e,i){var n=this.value,r=this.generator,o;if(!n.length||e.modified())for(const l in e)Rn(r[l])&&r[l](e[l]);return o=r(),n.length?i.mod.push(t4e(n[0],o)):i.add.push(Vr(o)),n[0]=o,i}});function pAe(e){Xt.call(this,null,e)}pAe.Definition={type:"heatmap",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"color",type:"string",expr:!0},{name:"opacity",type:"number",expr:!0},{name:"resolve",type:"enum",values:["shared","independent"],default:"independent"},{name:"as",type:"string",default:"image"}]};si(pAe,Xt,{transform(e,i){if(!i.changed()&&!e.modified())return i.StopPropagation;var n=i.materialize(i.SOURCE).source,r=e.resolve==="shared",o=e.field||Hs,l=bBi(e.opacity,e),c=pBi(e.color,e),u=e.as||"image",f={$x:0,$y:0,$value:0,$max:r?Py(n.map(m=>Py(o(m).values))):0};return n.forEach(m=>{const p=o(m),v=Tn({},m,f);r||(v.$max=Py(p.values||[])),m[u]=yBi(p,v,c.dep?c:Ws(c(v)),l.dep?l:Ws(l(v)))}),i.reflow(!0).modifies(u)}});function pBi(e,i){let n;return Rn(e)?(n=r=>woe(e(r,i)),n.dep=z8e(e)):n=Ws(woe(e||"#888")),n}function bBi(e,i){let n;return Rn(e)?(n=r=>e(r,i),n.dep=z8e(e)):e?n=Ws(e):(n=r=>r.$value/r.$max||0,n.dep=!0),n}function z8e(e){if(!Rn(e))return!1;const i=BA(ws(e));return i.$x||i.$y||i.$value||i.$max}function yBi(e,i,n,r){const o=e.width,l=e.height,c=e.x1||0,u=e.y1||0,f=e.x2||o,m=e.y2||l,p=e.values,v=p?E=>p[E]:Qm,B=Rp(f-c,m-u),G=B.getContext("2d"),T=G.getImageData(0,0,f-c,m-u),V=T.data;for(let E=u,W=0;E{e[r]!=null&&zMe(n,r,e[r])})):Soe.forEach(r=>{e.modified(r)&&zMe(n,r,e[r])}),e.pointRadius!=null&&n.path.pointRadius(e.pointRadius),e.fit&&vBi(n,e),i.fork(i.NO_SOURCE|i.NO_FIELDS)}});function vBi(e,i){const n=BBi(i.fit);i.extent?e.fitExtent(i.extent,n):i.size&&e.fitSize(i.size,n)}function ZBi(e){const i=aAe((e||"mercator").toLowerCase());return i||Yt("Unrecognized projection type: "+e),i()}function zMe(e,i,n){Rn(e[i])&&e[i](n)}function BBi(e){return e=pi(e),e.length===1?e[0]:{type:AAe,features:e.reduce((i,n)=>i.concat(GBi(n)),[])}}function GBi(e){return e.type===AAe?e.features:pi(e).filter(i=>i!=null).map(i=>i.type===Toe?i:{type:Toe,geometry:i})}const SBi=Object.freeze(Object.defineProperty({__proto__:null,contour:cAe,geojson:uAe,geopath:dAe,geopoint:hAe,geoshape:fAe,graticule:mAe,heatmap:pAe,isocontour:lAe,kde2d:CAe,projection:O8e},Symbol.toStringTag,{value:"Module"}));function wBi(e,i){var n,r=1;e==null&&(e=0),i==null&&(i=0);function o(){var l,c=n.length,u,f=0,m=0;for(l=0;l=(v=(u+m)/2))?u=v:m=v,(E=n>=(B=(f+p)/2))?f=B:p=B,o=l,!(l=l[W=E<<1|V]))return o[W]=c,e;if(G=+e._x.call(null,l.data),T=+e._y.call(null,l.data),i===G&&n===T)return c.next=l,o?o[W]=c:e._root=c,e;do o=o?o[W]=new Array(4):e._root=new Array(4),(V=i>=(v=(u+m)/2))?u=v:m=v,(E=n>=(B=(f+p)/2))?f=B:p=B;while((W=E<<1|V)===(x=(T>=B)<<1|G>=v));return o[x]=l,o[W]=c,e}function RBi(e){var i,n,r=e.length,o,l,c=new Array(r),u=new Array(r),f=1/0,m=1/0,p=-1/0,v=-1/0;for(n=0;np&&(p=o),lv&&(v=l));if(f>p||m>v)return this;for(this.cover(f,m).cover(p,v),n=0;ne||e>=o||r>i||i>=l;)switch(m=(ip||(u=T.y0)>v||(f=T.x1)=W)<<1|e>=E)&&(T=B[B.length-1],B[B.length-1]=B[B.length-1-V],B[B.length-1-V]=T)}else{var x=e-+this._x.call(null,G.data),k=i-+this._y.call(null,G.data),F=x*x+k*k;if(F=(B=(c+f)/2))?c=B:f=B,(V=v>=(G=(u+m)/2))?u=G:m=G,i=n,!(n=n[E=V<<1|T]))return this;if(!n.length)break;(i[E+1&3]||i[E+2&3]||i[E+3&3])&&(r=i,W=E)}for(;n.data!==e;)if(o=n,!(n=n.next))return this;return(l=n.next)&&delete n.next,o?(l?o.next=l:delete o.next,this):i?(l?i[E]=l:delete i[E],(n=i[0]||i[1]||i[2]||i[3])&&n===(i[3]||i[2]||i[1]||i[0])&&!n.length&&(r?r[W]=n:this._root=n),this):(this._root=l,this)}function kBi(e){for(var i=0,n=e.length;iB.index){var ee=G-Q.x-Q.vx,ne=T-Q.y-Q.vy,ge=ee*ee+ne*ne;ge<$*$&&(ee===0&&(ee=Cp(r),ge+=ee*ee),ne===0&&(ne=Cp(r),ge+=ne*ne),ge=($-(ge=Math.sqrt(ge)))/ge*o,B.vx+=(ee*=ge)*($=(X*=X)/(E+X)),B.vy+=(ne*=ge)*$,Q.vx-=ee*($=1-$),Q.vy-=ne*$)}return}return F>G+$||LT+$||Om.r&&(m.r=m[p].r)}function f(){if(i){var m,p=i.length,v;for(n=new Array(p),m=0;m[i(Y,L,c),Y])),F;for(E=0,u=new Array(W);E{}};function J8e(){for(var e=0,i=arguments.length,n={},r;e=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!i.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}DY.prototype=J8e.prototype={constructor:DY,on:function(e,i){var n=this._,r=QBi(e+"",n),o,l=-1,c=r.length;if(arguments.length<2){for(;++l0)for(var n=new Array(o),r=0,o,l;r=0&&e._call.call(void 0,i),e=e._next;--ow}function UMe(){wv=(A_=LH.now())+Pz,ow=j9=0;try{qBi()}finally{ow=0,tGi(),wv=0}}function eGi(){var e=LH.now(),i=e-A_;i>U8e&&(Pz-=i,A_=e)}function tGi(){for(var e,i=c_,n,r=1/0;i;)i._call?(r>i._time&&(r=i._time),e=i,i=i._next):(n=i._next,i._next=null,i=e?e._next=n:c_=n);$9=e,Roe(r)}function Roe(e){if(!ow){j9&&(j9=clearTimeout(j9));var i=e-wv;i>24?(e<1/0&&(j9=setTimeout(UMe,e-LH.now()-Pz)),I9&&(I9=clearInterval(I9))):(I9||(A_=LH.now(),I9=setInterval(eGi,U8e)),ow=1,Q8e(UMe))}}function iGi(e,i,n){var r=new u_,o=i;return i==null?(r.restart(e,i,n),r):(r._restart=r.restart,r.restart=function(l,c,u){c=+c,u=u==null?vAe():+u,r._restart(function f(m){m+=o,r._restart(f,o+=c,u),l(m)},c,u)},r.restart(e,i,n),r)}const nGi=1664525,rGi=1013904223,QMe=4294967296;function gGi(){let e=1;return()=>(e=(nGi*e+rGi)%QMe)/QMe}function oGi(e){return e.x}function aGi(e){return e.y}var sGi=10,IGi=Math.PI*(3-Math.sqrt(5));function lGi(e){var i,n=1,r=.001,o=1-Math.pow(r,1/300),l=0,c=.6,u=new Map,f=j8e(v),m=J8e("tick","end"),p=gGi();e==null&&(e=[]);function v(){B(),m.call("tick",i),n1?(E==null?u.delete(V):u.set(V,T(E)),i):u.get(V)},find:function(V,E,W){var x=0,k=e.length,F,Y,L,O,Q;for(W==null?W=1/0:W*=W,x=0;x1?(m.on(V,E),i):m.on(V)}}}function CGi(){var e,i,n,r,o=cI(-30),l,c=1,u=1/0,f=.81;function m(G){var T,V=e.length,E=bAe(e,oGi,aGi).visitAfter(v);for(r=G,T=0;T=u)return;(G.data!==i||G.next)&&(W===0&&(W=Cp(n),F+=W*W),x===0&&(x=Cp(n),F+=x*x),F=0;)n.tick();else if(n.stopped()&&n.restart(),!r)return i.StopPropagation}return this.finish(e,i)},finish(e,i){const n=i.dataflow;for(let u=this._argops,f=0,m=u.length,p;fe.touch(i).run()}function hGi(e,i){const n=lGi(e),r=n.stop,o=n.restart;let l=!1;return n.stopped=()=>l,n.restart=()=>(l=!1,o()),n.stop=()=>(l=!0,r()),q8e(n,i,!0).on("end",()=>l=!0)}function q8e(e,i,n,r){var o=pi(i.forces),l,c,u,f;for(l=0,c=Voe.length;li(r,n):i)}const bGi=Object.freeze(Object.defineProperty({__proto__:null,force:ZAe},Symbol.toStringTag,{value:"Module"}));function yGi(e,i){return e.parent===i.parent?1:2}function vGi(e){return e.reduce(ZGi,0)/e.length}function ZGi(e,i){return e+i.x}function BGi(e){return 1+e.reduce(GGi,0)}function GGi(e,i){return Math.max(e,i.y)}function SGi(e){for(var i;i=e.children;)e=i[0];return e}function wGi(e){for(var i;i=e.children;)e=i[i.length-1];return e}function TGi(){var e=yGi,i=1,n=1,r=!1;function o(l){var c,u=0;l.eachAfter(function(B){var G=B.children;G?(B.x=vGi(G),B.y=BGi(G)):(B.x=c?u+=e(B,c):0,B.y=0,c=B)});var f=SGi(l),m=wGi(l),p=f.x-e(f,m)/2,v=m.x+e(m,f)/2;return l.eachAfter(r?function(B){B.x=(B.x-l.x)*i,B.y=(l.y-B.y)*n}:function(B){B.x=(B.x-p)/(v-p)*i,B.y=(1-(l.y?B.y/l.y:1))*n})}return o.separation=function(l){return arguments.length?(e=l,o):e},o.size=function(l){return arguments.length?(r=!1,i=+l[0],n=+l[1],o):r?null:[i,n]},o.nodeSize=function(l){return arguments.length?(r=!0,i=+l[0],n=+l[1],o):r?[i,n]:null},o}function RGi(e){var i=0,n=e.children,r=n&&n.length;if(!r)i=1;else for(;--r>=0;)i+=n[r].value;e.value=i}function VGi(){return this.eachAfter(RGi)}function EGi(e,i){let n=-1;for(const r of this)e.call(i,r,++n,this);return this}function HGi(e,i){for(var n=this,r=[n],o,l,c=-1;n=r.pop();)if(e.call(i,n,++c,this),o=n.children)for(l=o.length-1;l>=0;--l)r.push(o[l]);return this}function WGi(e,i){for(var n=this,r=[n],o=[],l,c,u,f=-1;n=r.pop();)if(o.push(n),l=n.children)for(c=0,u=l.length;c=0;)n+=r[o].value;i.value=n})}function XGi(e){return this.eachBefore(function(i){i.children&&i.children.sort(e)})}function xGi(e){for(var i=this,n=DGi(i,e),r=[i];i!==n;)i=i.parent,r.push(i);for(var o=r.length;e!==n;)r.splice(o,0,e),e=e.parent;return r}function DGi(e,i){if(e===i)return e;var n=e.ancestors(),r=i.ancestors(),o=null;for(e=n.pop(),i=r.pop();e===i;)o=e,e=n.pop(),i=r.pop();return o}function MGi(){for(var e=this,i=[e];e=e.parent;)i.push(e);return i}function FGi(){return Array.from(this)}function YGi(){var e=[];return this.eachBefore(function(i){i.children||e.push(i)}),e}function KGi(){var e=this,i=[];return e.each(function(n){n!==e&&i.push({source:n.parent,target:n})}),i}function*_Gi(){var e=this,i,n=[e],r,o,l;do for(i=n.reverse(),n=[];e=i.pop();)if(yield e,r=e.children)for(o=0,l=r.length;o=0;--u)o.push(l=c[u]=new aw(c[u])),l.parent=r,l.depth=r.depth+1;return n.eachBefore(e$e)}function PGi(){return BAe(this).eachBefore(LGi)}function zGi(e){return e.children}function OGi(e){return Array.isArray(e)?e[1]:null}function LGi(e){e.data.value!==void 0&&(e.value=e.data.value),e.data=e.data.data}function e$e(e){var i=0;do e.height=i;while((e=e.parent)&&e.height<++i)}function aw(e){this.data=e,this.depth=this.height=0,this.parent=null}aw.prototype=BAe.prototype={constructor:aw,count:VGi,each:EGi,eachAfter:WGi,eachBefore:HGi,find:NGi,sum:kGi,sort:XGi,path:xGi,ancestors:MGi,descendants:FGi,leaves:YGi,links:KGi,copy:PGi,[Symbol.iterator]:_Gi};function MY(e){return e==null?null:t$e(e)}function t$e(e){if(typeof e!="function")throw new Error;return e}function yy(){return 0}function TG(e){return function(){return e}}const JGi=1664525,UGi=1013904223,$Me=4294967296;function QGi(){let e=1;return()=>(e=(JGi*e+UGi)%$Me)/$Me}function jGi(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function $Gi(e,i){let n=e.length,r,o;for(;n;)o=i()*n--|0,r=e[n],e[n]=e[o],e[o]=r;return e}function qGi(e,i){for(var n=0,r=(e=$Gi(Array.from(e),i)).length,o=[],l,c;n0&&n*n>r*r+o*o}function hte(e,i){for(var n=0;n1e-6?(ee+Math.sqrt(ee*ee-4*$*ne))/(2*$):ne/ee);return{x:r+L+O*ge,y:o+Q+X*ge,r:ge}}function qMe(e,i,n){var r=e.x-i.x,o,l,c=e.y-i.y,u,f,m=r*r+c*c;m?(l=i.r+n.r,l*=l,f=e.r+n.r,f*=f,l>f?(o=(m+f-l)/(2*m),u=Math.sqrt(Math.max(0,f/m-o*o)),n.x=e.x-o*r-u*c,n.y=e.y-o*c+u*r):(o=(m+l-f)/(2*m),u=Math.sqrt(Math.max(0,l/m-o*o)),n.x=i.x+o*r-u*c,n.y=i.y+o*c+u*r)):(n.x=i.x+n.r,n.y=i.y)}function eFe(e,i){var n=e.r+i.r-1e-6,r=i.x-e.x,o=i.y-e.y;return n>0&&n*n>r*r+o*o}function tFe(e){var i=e._,n=e.next._,r=i.r+n.r,o=(i.x*n.r+n.x*i.r)/r,l=(i.y*n.r+n.y*i.r)/r;return o*o+l*l}function XF(e){this._=e,this.next=null,this.previous=null}function nSi(e,i){if(!(l=(e=jGi(e)).length))return 0;var n,r,o,l,c,u,f,m,p,v,B;if(n=e[0],n.x=0,n.y=0,!(l>1))return n.r;if(r=e[1],n.x=-r.r,r.x=n.r,r.y=0,!(l>2))return n.r+r.r;qMe(r,n,o=e[2]),n=new XF(n),r=new XF(r),o=new XF(o),n.next=o.previous=r,r.next=n.previous=o,o.next=r.previous=n;e:for(f=3;flSi(n(F,Y,o))),x=W.map(oFe),k=new Set(W).add("");for(const F of x)k.has(F)||(k.add(F),W.push(F),x.push(oFe(F)),l.push(mte));c=(F,Y)=>W[Y],u=(F,Y)=>x[Y]}for(p=0,f=l.length;p=0&&(G=l[W],G.data===mte);--W)G.data=null}if(v.parent=aSi,v.eachBefore(function(W){W.depth=W.parent.depth+1,--f}).eachBefore(e$e),v.parent=null,f>0)throw new Error("cycle");return v}return r.id=function(o){return arguments.length?(e=MY(o),r):e},r.parentId=function(o){return arguments.length?(i=MY(o),r):i},r.path=function(o){return arguments.length?(n=MY(o),r):n},r}function lSi(e){e=`${e}`;let i=e.length;return Eoe(e,i-1)&&!Eoe(e,i-2)&&(e=e.slice(0,-1)),e[0]==="/"?e:`/${e}`}function oFe(e){let i=e.length;if(i<2)return"";for(;--i>1&&!Eoe(e,i););return e.slice(0,i)}function Eoe(e,i){if(e[i]==="/"){let n=0;for(;i>0&&e[--i]==="\\";)++n;if(!(n&1))return!0}return!1}function CSi(e,i){return e.parent===i.parent?1:2}function pte(e){var i=e.children;return i?i[0]:e.t}function bte(e){var i=e.children;return i?i[i.length-1]:e.t}function cSi(e,i,n){var r=n/(i.i-e.i);i.c-=r,i.s+=n,e.c+=r,i.z+=n,i.m+=n}function ASi(e){for(var i=0,n=0,r=e.children,o=r.length,l;--o>=0;)l=r[o],l.z+=i,l.m+=i,i+=l.s+(n+=l.c)}function uSi(e,i,n){return e.a.parent===i.parent?e.a:n}function FY(e,i){this._=e,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=i}FY.prototype=Object.create(aw.prototype);function dSi(e){for(var i=new FY(e,0),n,r=[i],o,l,c,u;n=r.pop();)if(l=n._.children)for(n.children=new Array(u=l.length),c=u-1;c>=0;--c)r.push(o=n.children[c]=new FY(l[c],c)),o.parent=n;return(i.parent=new FY(null,0)).children=[i],i}function hSi(){var e=CSi,i=1,n=1,r=null;function o(m){var p=dSi(m);if(p.eachAfter(l),p.parent.m=-p.z,p.eachBefore(c),r)m.eachBefore(f);else{var v=m,B=m,G=m;m.eachBefore(function(x){x.xB.x&&(B=x),x.depth>G.depth&&(G=x)});var T=v===B?1:e(v,B)/2,V=T-v.x,E=i/(B.x+T+V),W=n/(G.depth||1);m.eachBefore(function(x){x.x=(x.x+V)*E,x.y=x.depth*W})}return m}function l(m){var p=m.children,v=m.parent.children,B=m.i?v[m.i-1]:null;if(p){ASi(m);var G=(p[0].z+p[p.length-1].z)/2;B?(m.z=B.z+e(m._,B._),m.m=m.z-G):m.z=G}else B&&(m.z=B.z+e(m._,B._));m.parent.A=u(m,B,m.parent.A||v[0])}function c(m){m._.x=m.z+m.parent.m,m.m+=m.parent.m}function u(m,p,v){if(p){for(var B=m,G=m,T=p,V=B.parent.children[0],E=B.m,W=G.m,x=T.m,k=V.m,F;T=bte(T),B=pte(B),T&&B;)V=pte(V),G=bte(G),G.a=m,F=T.z+x-B.z-E+e(T._,B._),F>0&&(cSi(uSi(T,m,v),m,F),E+=F,W+=F),x+=T.m,E+=B.m,k+=V.m,W+=G.m;T&&!bte(G)&&(G.t=T,G.m+=x-W),B&&!pte(V)&&(V.t=B,V.m+=E-k,v=m)}return v}function f(m){m.x*=i,m.y=m.depth*n}return o.separation=function(m){return arguments.length?(e=m,o):e},o.size=function(m){return arguments.length?(r=!1,i=+m[0],n=+m[1],o):r?null:[i,n]},o.nodeSize=function(m){return arguments.length?(r=!0,i=+m[0],n=+m[1],o):r?[i,n]:null},o}function zz(e,i,n,r,o){for(var l=e.children,c,u=-1,f=l.length,m=e.value&&(o-n)/e.value;++ux&&(x=m),L=E*E*Y,k=Math.max(x/L,L/W),k>F){E-=m;break}F=k}c.push(f={value:E,dice:G1?r:1)},n}(g$e);function fSi(){var e=a$e,i=!1,n=1,r=1,o=[0],l=yy,c=yy,u=yy,f=yy,m=yy;function p(B){return B.x0=B.y0=0,B.x1=n,B.y1=r,B.eachBefore(v),o=[0],i&&B.eachBefore(r$e),B}function v(B){var G=o[B.depth],T=B.x0+G,V=B.y0+G,E=B.x1-G,W=B.y1-G;E=B-1){var x=l[v];x.x0=T,x.y0=V,x.x1=E,x.y1=W;return}for(var k=m[v],F=G/2+k,Y=v+1,L=B-1;Y>>1;m[O]W-V){var $=G?(T*X+E*Q)/G:E;p(v,Y,Q,T,V,$,W),p(Y,B,X,$,V,E,W)}else{var ee=G?(V*X+W*Q)/G:W;p(v,Y,Q,T,V,E,ee),p(Y,B,X,T,ee,E,W)}}}function pSi(e,i,n,r,o){(e.depth&1?zz:nN)(e,i,n,r,o)}const bSi=function e(i){function n(r,o,l,c,u){if((f=r._squarify)&&f.ratio===i)for(var f,m,p,v,B=-1,G,T=f.length,V=r.value;++B1?r:1)},n}(g$e);function Hoe(e,i,n){const r={};return e.each(o=>{const l=o.data;n(l)&&(r[i(l)]=o)}),e.lookup=r,e}function GAe(e){Xt.call(this,null,e)}GAe.Definition={type:"Nest",metadata:{treesource:!0,changes:!0},params:[{name:"keys",type:"field",array:!0},{name:"generate",type:"boolean"}]};const ySi=e=>e.values;si(GAe,Xt,{transform(e,i){i.source||Yt("Nest transform requires an upstream data source.");var n=e.generate,r=e.modified(),o=i.clone(),l=this.value;return(!l||r||i.changed())&&(l&&l.each(c=>{c.children&&gz(c.data)&&o.rem.push(c.data)}),this.value=l=BAe({values:pi(e.keys).reduce((c,u)=>(c.key(u),c),vSi()).entries(o.source)},ySi),n&&l.each(c=>{c.children&&(c=Vr(c.data),o.add.push(c),o.source.push(c))}),Hoe(l,Pi,Pi)),o.source.root=l,o}});function vSi(){const e=[],i={entries:o=>r(n(o,0),0),key:o=>(e.push(o),i)};function n(o,l){if(l>=e.length)return o;const c=o.length,u=e[l++],f={},m={};let p=-1,v,B,G;for(;++pe.length)return o;const c=[];for(const u in o)c.push({key:u,values:r(o[u],l)});return c}return i}function bf(e){Xt.call(this,null,e)}const ZSi=(e,i)=>e.parent===i.parent?1:2;si(bf,Xt,{transform(e,i){(!i.source||!i.source.root)&&Yt(this.constructor.name+" transform requires a backing tree data source.");const n=this.layout(e.method),r=this.fields,o=i.source.root,l=e.as||r;e.field?o.sum(e.field):o.count(),e.sort&&o.sort(tZ(e.sort,c=>c.data)),BSi(n,this.params,e),n.separation&&n.separation(e.separation!==!1?ZSi:kw);try{this.value=n(o)}catch(c){Yt(c)}return o.each(c=>GSi(c,r,l)),i.reflow(e.modified()).modifies(l).modifies("leaf")}});function BSi(e,i,n){for(let r,o=0,l=i.length;ol[Pi(c)]=1),r.each(c=>{const u=c.data,f=c.parent&&c.parent.data;f&&l[Pi(u)]&&l[Pi(f)]&&o.add.push(Vr({source:f,target:u}))}),this.value=o.add):i.changed(i.MOD)&&(i.visit(i.MOD,c=>l[Pi(c)]=1),n.forEach(c=>{(l[Pi(c.source)]||l[Pi(c.target)])&&o.mod.push(c)})),o}});const sFe={binary:mSi,dice:nN,slice:zz,slicedice:pSi,squarify:a$e,resquarify:bSi},Xoe=["x0","y0","x1","y1","depth","children"];function EAe(e){bf.call(this,e)}EAe.Definition={type:"Treemap",metadata:{tree:!0,modifies:!0},params:[{name:"field",type:"field"},{name:"sort",type:"compare"},{name:"method",type:"enum",default:"squarify",values:["squarify","resquarify","binary","dice","slice","slicedice"]},{name:"padding",type:"number",default:0},{name:"paddingInner",type:"number",default:0},{name:"paddingOuter",type:"number",default:0},{name:"paddingTop",type:"number",default:0},{name:"paddingRight",type:"number",default:0},{name:"paddingBottom",type:"number",default:0},{name:"paddingLeft",type:"number",default:0},{name:"ratio",type:"number",default:1.618033988749895},{name:"round",type:"boolean",default:!1},{name:"size",type:"number",array:!0,length:2},{name:"as",type:"string",array:!0,length:Xoe.length,default:Xoe}]};si(EAe,bf,{layout(){const e=fSi();return e.ratio=i=>{const n=e.tile();n.ratio&&e.tile(n.ratio(i))},e.method=i=>{Oi(sFe,i)?e.tile(sFe[i]):Yt("Unrecognized Treemap layout method: "+i)},e},params:["method","ratio","size","round","padding","paddingInner","paddingOuter","paddingTop","paddingRight","paddingBottom","paddingLeft"],fields:Xoe});const SSi=Object.freeze(Object.defineProperty({__proto__:null,nest:GAe,pack:SAe,partition:wAe,stratify:TAe,tree:RAe,treelinks:VAe,treemap:EAe},Symbol.toStringTag,{value:"Module"})),yte=4278190080;function wSi(e,i){const n=e.bitmap();return(i||[]).forEach(r=>n.set(e(r.boundary[0]),e(r.boundary[3]))),[n,void 0]}function TSi(e,i,n,r,o){const l=e.width,c=e.height,u=r||o,f=Rp(l,c).getContext("2d"),m=Rp(l,c).getContext("2d"),p=u&&Rp(l,c).getContext("2d");n.forEach(Q=>YY(f,Q,!1)),YY(m,i,!1),u&&YY(p,i,!0);const v=vte(f,l,c),B=vte(m,l,c),G=u&&vte(p,l,c),T=e.bitmap(),V=u&&e.bitmap();let E,W,x,k,F,Y,L,O;for(W=0;W{o.items.forEach(l=>YY(e,l.items,n))}):Ll[r].draw(e,{items:n?i.map(RSi):i})}function RSi(e){const i=oz(e,{});return i.stroke&&i.strokeOpacity!==0||i.fill&&i.fillOpacity!==0?{...i,strokeOpacity:1,stroke:"#000",fillOpacity:0}:i}const ph=5,tI=31,JH=32,Om=new Uint32Array(JH+1),eA=new Uint32Array(JH+1);eA[0]=0;Om[0]=~eA[0];for(let e=1;e<=JH;++e)eA[e]=eA[e-1]<<1|1,Om[e]=~eA[e];function VSi(e,i){const n=new Uint32Array(~~((e*i+JH)/JH));function r(l,c){n[l]|=c}function o(l,c){n[l]&=c}return{array:n,get:(l,c)=>{const u=c*e+l;return n[u>>>ph]&1<<(u&tI)},set:(l,c)=>{const u=c*e+l;r(u>>>ph,1<<(u&tI))},clear:(l,c)=>{const u=c*e+l;o(u>>>ph,~(1<<(u&tI)))},getRange:(l,c,u,f)=>{let m=f,p,v,B,G;for(;m>=c;--m)if(p=m*e+l,v=m*e+u,B=p>>>ph,G=v>>>ph,B===G){if(n[B]&Om[p&tI]&eA[(v&tI)+1])return!0}else{if(n[B]&Om[p&tI]||n[G]&eA[(v&tI)+1])return!0;for(let T=B+1;T{let m,p,v,B,G;for(;c<=f;++c)if(m=c*e+l,p=c*e+u,v=m>>>ph,B=p>>>ph,v===B)r(v,Om[m&tI]&eA[(p&tI)+1]);else for(r(v,Om[m&tI]),r(B,eA[(p&tI)+1]),G=v+1;G{let m,p,v,B,G;for(;c<=f;++c)if(m=c*e+l,p=c*e+u,v=m>>>ph,B=p>>>ph,v===B)o(v,eA[m&tI]|Om[(p&tI)+1]);else for(o(v,eA[m&tI]),o(B,Om[(p&tI)+1]),G=v+1;Gl<0||c<0||f>=i||u>=e}}function ESi(e,i,n){const r=Math.max(1,Math.sqrt(e*i/1e6)),o=~~((e+2*n+r)/r),l=~~((i+2*n+r)/r),c=u=>~~((u+n)/r);return c.invert=u=>u*r-n,c.bitmap=()=>VSi(o,l),c.ratio=r,c.padding=n,c.width=e,c.height=i,c}function HSi(e,i,n,r){const o=e.width,l=e.height;return function(c){const u=c.datum.datum.items[r].items,f=u.length,m=c.datum.fontSize,p=fA.width(c.datum,c.datum.text);let v=0,B,G,T,V,E,W,x;for(let k=0;k=v&&(v=x,c.x=E,c.y=W);return E=p/2,W=m/2,B=c.x-E,G=c.x+E,T=c.y-W,V=c.y+W,c.align="center",B<0&&G<=o?c.align="left":0<=B&&oo||i-(c=r/2)<0||i+c>l}function cp(e,i,n,r,o,l,c,u){const f=o*l/(r*2),m=e(i-f),p=e(i+f),v=e(n-(l=l/2)),B=e(n+l);return c.outOfBounds(m,v,p,B)||c.getRange(m,v,p,B)||u&&u.getRange(m,v,p,B)}function WSi(e,i,n,r){const o=e.width,l=e.height,c=i[0],u=i[1];function f(m,p,v,B,G){const T=e.invert(m),V=e.invert(p);let E=v,W=l,x;if(!d_(T,V,B,G,o,l)&&!cp(e,T,V,G,B,E,c,u)&&!cp(e,T,V,G,B,G,c,null)){for(;W-E>=1;)x=(E+W)/2,cp(e,T,V,G,B,x,c,u)?W=x:E=x;if(E>v)return[T,V,E,!0]}}return function(m){const p=m.datum.datum.items[r].items,v=p.length,B=m.datum.fontSize,G=fA.width(m.datum,m.datum.text);let T=n?B:0,V=!1,E=!1,W=0,x,k,F,Y,L,O,Q,X,$,ee,ne,ge,Ae,_,de,Ze,me;for(let be=0;bek&&(me=x,x=k,k=me),F>Y&&(me=F,F=Y,Y=me),$=e(x),ne=e(k),ee=~~(($+ne)/2),ge=e(F),_=e(Y),Ae=~~((ge+_)/2),Q=ee;Q>=$;--Q)for(X=Ae;X>=ge;--X)Ze=f(Q,X,T,G,B),Ze&&([m.x,m.y,T,V]=Ze);for(Q=ee;Q<=ne;++Q)for(X=Ae;X<=_;++X)Ze=f(Q,X,T,G,B),Ze&&([m.x,m.y,T,V]=Ze);!V&&!n&&(de=Math.abs(k-x+Y-F),L=(x+k)/2,O=(F+Y)/2,de>=W&&!d_(L,O,G,B,o,l)&&!cp(e,L,O,B,G,B,c,null)&&(W=de,m.x=L,m.y=O,E=!0))}return V||E?(L=G/2,O=B/2,c.setRange(e(m.x-L),e(m.y-O),e(m.x+L),e(m.y+O)),m.align="center",m.baseline="middle",!0):!1}}const NSi=[-1,-1,1,1],kSi=[-1,1,-1,1];function XSi(e,i,n,r){const o=e.width,l=e.height,c=i[0],u=i[1],f=e.bitmap();return function(m){const p=m.datum.datum.items[r].items,v=p.length,B=m.datum.fontSize,G=fA.width(m.datum,m.datum.text),T=[];let V=n?B:0,E=!1,W=!1,x=0,k,F,Y,L,O,Q,X,$,ee,ne,ge,Ae;for(let _=0;_=1;)ge=(ee+ne)/2,cp(e,O,Q,B,G,ge,c,u)?ne=ge:ee=ge;ee>V&&(m.x=O,m.y=Q,V=ee,E=!0)}}!E&&!n&&(Ae=Math.abs(F-k+L-Y),O=(k+F)/2,Q=(Y+L)/2,Ae>=x&&!d_(O,Q,G,B,o,l)&&!cp(e,O,Q,B,G,B,c,null)&&(x=Ae,m.x=O,m.y=Q,W=!0))}return E||W?(O=G/2,Q=B/2,c.setRange(e(m.x-O),e(m.y-Q),e(m.x+O),e(m.y+Q)),m.align="center",m.baseline="middle",!0):!1}}const xSi=["right","center","left"],DSi=["bottom","middle","top"];function MSi(e,i,n,r){const o=e.width,l=e.height,c=i[0],u=i[1],f=r.length;return function(m){const p=m.boundary,v=m.datum.fontSize;if(p[2]<0||p[5]<0||p[0]>o||p[3]>l)return!1;let B=m.textWidth??0,G,T,V,E,W,x,k,F,Y,L,O,Q,X,$,ee;for(let ne=0;ne>>2&3)-1,V=G===0&&T===0||r[ne]<0,E=G&&T?Math.SQRT1_2:1,W=r[ne]<0?-1:1,x=p[1+G]+r[ne]*G*E,O=p[4+T]+W*v*T/2+r[ne]*T*E,F=O-v/2,Y=O+v/2,Q=e(x),$=e(F),ee=e(Y),!B)if(IFe(Q,Q,$,ee,c,u,x,x,F,Y,p,V))B=fA.width(m.datum,m.datum.text);else continue;if(L=x+W*B*G/2,x=L-B/2,k=L+B/2,Q=e(x),X=e(k),IFe(Q,X,$,ee,c,u,x,k,F,Y,p,V))return m.x=G?G*W<0?k:x:L,m.y=T?T*W<0?Y:F:O,m.align=xSi[G*W+1],m.baseline=DSi[T*W+1],c.setRange(Q,$,X,ee),!0}return!1}}function IFe(e,i,n,r,o,l,c,u,f,m,p,v){return!(o.outOfBounds(e,n,i,r)||(v&&l||o).getRange(e,n,i,r))}const Zte=0,Bte=4,Gte=8,Ste=0,wte=1,Tte=2,FSi={"top-left":Zte+Ste,top:Zte+wte,"top-right":Zte+Tte,left:Bte+Ste,middle:Bte+wte,right:Bte+Tte,"bottom-left":Gte+Ste,bottom:Gte+wte,"bottom-right":Gte+Tte},YSi={naive:HSi,"reduced-search":WSi,floodfill:XSi};function KSi(e,i,n,r,o,l,c,u,f,m,p){if(!e.length)return e;const v=Math.max(r.length,o.length),B=_Si(r,v),G=PSi(o,v),T=zSi(e[0].datum),V=T==="group"&&e[0].datum.items[f].marktype,E=V==="area",W=OSi(T,V,u,f),x=m===null||m===1/0,k=E&&p==="naive";let F=-1,Y=-1;const L=e.map($=>{const ee=x?fA.width($,$.text):void 0;return F=Math.max(F,ee),Y=Math.max(Y,$.fontSize),{datum:$,opacity:0,x:void 0,y:void 0,align:void 0,baseline:void 0,boundary:W($),textWidth:ee}});m=m===null||m===1/0?Math.max(F,Y)+Math.max(...r):m;const O=ESi(i[0],i[1],m);let Q;if(!k){n&&L.sort((ne,ge)=>n(ne.datum,ge.datum));let $=!1;for(let ne=0;nene.datum);Q=l.length||ee?TSi(O,ee||[],l,$,E):wSi(O,c&&L)}const X=E?YSi[p](O,Q,c,f):MSi(O,Q,G,B);return L.forEach($=>$.opacity=+X($)),L}function _Si(e,i){const n=new Float64Array(i),r=e.length;for(let o=0;o[l.x,l.x,l.x,l.y,l.y,l.y];return e?e==="line"||e==="area"?l=>o(l.datum):i==="line"?l=>{const c=l.datum.items[r].items;return o(c.length?c[n==="start"?0:c.length-1]:{x:NaN,y:NaN})}:l=>{const c=l.datum.bounds;return[c.x1,(c.x1+c.x2)/2,c.x2,c.y1,(c.y1+c.y2)/2,c.y2]}:o}const xoe=["x","y","opacity","align","baseline"],s$e=["top-left","left","bottom-left","top","bottom","top-right","right","bottom-right"];function HAe(e){Xt.call(this,null,e)}HAe.Definition={type:"Label",metadata:{modifies:!0},params:[{name:"size",type:"number",array:!0,length:2,required:!0},{name:"sort",type:"compare"},{name:"anchor",type:"string",array:!0,default:s$e},{name:"offset",type:"number",array:!0,default:[1]},{name:"padding",type:"number",default:0,null:!0},{name:"lineAnchor",type:"string",values:["start","end"],default:"end"},{name:"markIndex",type:"number",default:0},{name:"avoidBaseMark",type:"boolean",default:!0},{name:"avoidMarks",type:"data",array:!0},{name:"method",type:"string",default:"naive"},{name:"as",type:"string",array:!0,length:xoe.length,default:xoe}]};si(HAe,Xt,{transform(e,i){function n(l){const c=e[l];return Rn(c)&&i.modified(c.fields)}const r=e.modified();if(!(r||i.changed(i.ADD_REM)||n("sort")))return;(!e.size||e.size.length!==2)&&Yt("Size parameter should be specified as a [width, height] array.");const o=e.as||xoe;return KSi(i.materialize(i.SOURCE).source||[],e.size,e.sort,pi(e.offset==null?1:e.offset),pi(e.anchor||s$e),e.avoidMarks||[],e.avoidBaseMark!==!1,e.lineAnchor||"end",e.markIndex||0,e.padding===void 0?0:e.padding,e.method||"naive").forEach(l=>{const c=l.datum;c[o[0]]=l.x,c[o[1]]=l.y,c[o[2]]=l.opacity,c[o[3]]=l.align,c[o[4]]=l.baseline}),i.reflow(r).modifies(o)}});const LSi=Object.freeze(Object.defineProperty({__proto__:null,label:HAe},Symbol.toStringTag,{value:"Module"}));function I$e(e,i){var n=[],r=function(p){return p(u)},o,l,c,u,f,m;if(i==null)n.push(e);else for(o={},l=0,c=e.length;l{p4e(m,e.x,e.y,e.bandwidth||.3).forEach(p=>{const v={};for(let B=0;Be==="poly"?i:e==="quad"?2:1;function NAe(e){Xt.call(this,null,e)}NAe.Definition={type:"Regression",metadata:{generates:!0},params:[{name:"x",type:"field",required:!0},{name:"y",type:"field",required:!0},{name:"groupby",type:"field",array:!0},{name:"method",type:"string",default:"linear",values:Object.keys(Doe)},{name:"order",type:"number",default:3},{name:"extent",type:"number",array:!0,length:2},{name:"params",type:"boolean",default:!1},{name:"as",type:"string",array:!0}]};si(NAe,Xt,{transform(e,i){const n=i.fork(i.NO_SOURCE|i.NO_FIELDS);if(!this.value||i.changed()||e.modified()){const r=i.materialize(i.SOURCE).source,o=I$e(r,e.groupby),l=(e.groupby||[]).map(co),c=e.method||"linear",u=e.order==null?3:e.order,f=JSi(c,u),m=e.as||[co(e.x),co(e.y)],p=Doe[c],v=[];let B=e.extent;Oi(Doe,c)||Yt("Invalid regression method: "+c),B!=null&&c==="log"&&B[0]<=0&&(i.dataflow.warn("Ignoring extent with values <= 0 for log regression."),B=null),o.forEach(G=>{if(G.length<=f){i.dataflow.warn("Skipping regression with more parameters than data points.");return}const V=p(G,e.x,e.y,u);if(e.params){v.push(Vr({keys:G.dims,coef:V.coef,rSquared:V.rSquared}));return}const E=B||Cd(G,e.x),W=x=>{const k={};for(let F=0;FW([x,V.predict(x)])):Az(V.predict,E,25,200).forEach(W)}),this.value&&(n.rem=this.value),this.value=n.add=n.source=v}return n}});const USi=Object.freeze(Object.defineProperty({__proto__:null,loess:WAe,regression:NAe},Symbol.toStringTag,{value:"Module"})),Jh=11102230246251565e-32,fs=134217729,QSi=(3+8*Jh)*Jh;function Rte(e,i,n,r,o){let l,c,u,f,m=i[0],p=r[0],v=0,B=0;p>m==p>-m?(l=m,m=i[++v]):(l=p,p=r[++B]);let G=0;if(vm==p>-m?(c=m+l,u=l-(c-m),m=i[++v]):(c=p+l,u=l-(c-p),p=r[++B]),l=c,u!==0&&(o[G++]=u);vm==p>-m?(c=l+m,f=c-l,u=l-(c-f)+(m-f),m=i[++v]):(c=l+p,f=c-l,u=l-(c-f)+(p-f),p=r[++B]),l=c,u!==0&&(o[G++]=u);for(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W+v)+(v-L),Q=x+W,v=Q-x,iI[2]=x-(Q-v)+(W-v),iI[3]=Q;const Ze=Rte(de,CFe,4,iI,cFe);return cFe[Ze-1]}function xF(e,i,n,r,o,l){const c=(i-l)*(n-o),u=(e-o)*(r-l),f=c-u;if(c===0||u===0||c>0!=u>0)return f;const m=Math.abs(c+u);return Math.abs(f)>=$Si*m?f:-twi(e,i,n,r,o,l,m)}const AFe=Math.pow(2,-52),DF=new Uint32Array(512);class h_{static from(i,n=owi,r=awi){const o=i.length,l=new Float64Array(o*2);for(let c=0;c>1;if(n>0&&typeof i[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=i;const r=Math.max(2*n-5,0);this._triangles=new Uint32Array(r*3),this._halfedges=new Int32Array(r*3),this._hashSize=Math.ceil(Math.sqrt(n)),this._hullPrev=new Uint32Array(n),this._hullNext=new Uint32Array(n),this._hullTri=new Uint32Array(n),this._hullHash=new Int32Array(this._hashSize).fill(-1),this._ids=new Uint32Array(n),this._dists=new Float64Array(n),this.update()}update(){const{coords:i,_hullPrev:n,_hullNext:r,_hullTri:o,_hullHash:l}=this,c=i.length>>1;let u=1/0,f=1/0,m=-1/0,p=-1/0;for(let $=0;$m&&(m=ee),ne>p&&(p=ne),this._ids[$]=$}const v=(u+m)/2,B=(f+p)/2;let G=1/0,T,V,E;for(let $=0;$0&&(V=$,G=ee)}let k=i[2*V],F=i[2*V+1],Y=1/0;for(let $=0;$ge&&($[ee++]=Ae,ge=this._dists[Ae])}this.hull=$.subarray(0,ee),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(xF(W,x,k,F,L,O)<0){const $=V,ee=k,ne=F;V=E,k=L,F=O,E=$,L=ee,O=ne}const Q=gwi(W,x,k,F,L,O);this._cx=Q.x,this._cy=Q.y;for(let $=0;$0&&Math.abs(Ae-ee)<=AFe&&Math.abs(_-ne)<=AFe||(ee=Ae,ne=_,ge===T||ge===V||ge===E))continue;let de=0;for(let Je=0,Ue=this._hashKey(Ae,_);Je=0;)if(Ze=me,Ze===de){Ze=-1;break}if(Ze===-1)continue;let be=this._addTriangle(Ze,ge,r[Ze],-1,-1,o[Ze]);o[ge]=this._legalize(be+2),o[Ze]=be,X++;let Ee=r[Ze];for(;me=r[Ee],xF(Ae,_,i[2*Ee],i[2*Ee+1],i[2*me],i[2*me+1])<0;)be=this._addTriangle(Ee,ge,me,o[ge],-1,o[Ee]),o[ge]=this._legalize(be+2),r[Ee]=Ee,X--,Ee=me;if(Ze===de)for(;me=n[Ze],xF(Ae,_,i[2*me],i[2*me+1],i[2*Ze],i[2*Ze+1])<0;)be=this._addTriangle(me,ge,Ze,-1,o[Ze],o[me]),this._legalize(be+2),o[me]=be,r[Ze]=Ze,X--,Ze=me;this._hullStart=n[ge]=Ze,r[Ze]=n[Ee]=ge,r[ge]=Ee,l[this._hashKey(Ae,_)]=ge,l[this._hashKey(i[2*Ze],i[2*Ze+1])]=Ze}this.hull=new Uint32Array(X);for(let $=0,ee=this._hullStart;$0?3-n:1+n)/4}function Vte(e,i,n,r){const o=e-n,l=i-r;return o*o+l*l}function nwi(e,i,n,r,o,l,c,u){const f=e-c,m=i-u,p=n-c,v=r-u,B=o-c,G=l-u,T=f*f+m*m,V=p*p+v*v,E=B*B+G*G;return f*(v*E-V*G)-m*(p*E-V*B)+T*(p*G-v*B)<0}function rwi(e,i,n,r,o,l){const c=n-e,u=r-i,f=o-e,m=l-i,p=c*c+u*u,v=f*f+m*m,B=.5/(c*m-u*f),G=(m*p-u*v)*B,T=(c*v-f*p)*B;return G*G+T*T}function gwi(e,i,n,r,o,l){const c=n-e,u=r-i,f=o-e,m=l-i,p=c*c+u*u,v=f*f+m*m,B=.5/(c*m-u*f),G=e+(m*p-u*v)*B,T=i+(c*v-f*p)*B;return{x:G,y:T}}function QG(e,i,n,r){if(r-n<=20)for(let o=n+1;o<=r;o++){const l=e[o],c=i[l];let u=o-1;for(;u>=n&&i[e[u]]>c;)e[u+1]=e[u--];e[u+1]=l}else{const o=n+r>>1;let l=n+1,c=r;l9(e,o,l),i[e[n]]>i[e[r]]&&l9(e,n,r),i[e[l]]>i[e[r]]&&l9(e,l,r),i[e[n]]>i[e[l]]&&l9(e,n,l);const u=e[l],f=i[u];for(;;){do l++;while(i[e[l]]f);if(c=c-n?(QG(e,i,l,r),QG(e,i,n,c-1)):(QG(e,i,n,c-1),QG(e,i,l,r))}}function l9(e,i,n){const r=e[i];e[i]=e[n],e[n]=r}function owi(e){return e[0]}function awi(e){return e[1]}const uFe=1e-6;class Wy{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(i,n){this._+=`M${this._x0=this._x1=+i},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(i,n){this._+=`L${this._x1=+i},${this._y1=+n}`}arc(i,n,r){i=+i,n=+n,r=+r;const o=i+r,l=n;if(r<0)throw new Error("negative radius");this._x1===null?this._+=`M${o},${l}`:(Math.abs(this._x1-o)>uFe||Math.abs(this._y1-l)>uFe)&&(this._+="L"+o+","+l),r&&(this._+=`A${r},${r},0,1,1,${i-r},${n}A${r},${r},0,1,1,${this._x1=o},${this._y1=l}`)}rect(i,n,r,o){this._+=`M${this._x0=this._x1=+i},${this._y0=this._y1=+n}h${+r}v${+o}h${-r}Z`}value(){return this._||null}}class Moe{constructor(){this._=[]}moveTo(i,n){this._.push([i,n])}closePath(){this._.push(this._[0].slice())}lineTo(i,n){this._.push([i,n])}value(){return this._.length?this._:null}}let swi=class{constructor(i,[n,r,o,l]=[0,0,960,500]){if(!((o=+o)>=(n=+n))||!((l=+l)>=(r=+r)))throw new Error("invalid bounds");this.delaunay=i,this._circumcenters=new Float64Array(i.points.length*2),this.vectors=new Float64Array(i.points.length*2),this.xmax=o,this.xmin=n,this.ymax=l,this.ymin=r,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:i,hull:n,triangles:r},vectors:o}=this;let l,c;const u=this.circumcenters=this._circumcenters.subarray(0,r.length/3*2);for(let V=0,E=0,W=r.length,x,k;V1;)l-=2;for(let c=2;c0){if(n>=this.ymax)return null;(c=(this.ymax-n)/o)0){if(i>=this.xmax)return null;(c=(this.xmax-i)/r)this.xmax?2:0)|(nthis.ymax?8:0)}_simplify(i){if(i&&i.length>4){for(let n=0;n1e-10)return!1}return!0}function Awi(e,i,n){return[e+Math.sin(e+i)*n,i+Math.cos(e-i)*n]}class kAe{static from(i,n=lwi,r=Cwi,o){return new kAe("length"in i?uwi(i,n,r,o):Float64Array.from(dwi(i,n,r,o)))}constructor(i){this._delaunator=new h_(i),this.inedges=new Int32Array(i.length/2),this._hullIndex=new Int32Array(i.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){const i=this._delaunator,n=this.points;if(i.hull&&i.hull.length>2&&cwi(i)){this.collinear=Int32Array.from({length:n.length/2},(B,G)=>G).sort((B,G)=>n[2*B]-n[2*G]||n[2*B+1]-n[2*G+1]);const f=this.collinear[0],m=this.collinear[this.collinear.length-1],p=[n[2*f],n[2*f+1],n[2*m],n[2*m+1]],v=1e-8*Math.hypot(p[3]-p[1],p[2]-p[0]);for(let B=0,G=n.length/2;B0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=o[0],c[o[0]]=1,o.length===2&&(c[o[1]]=0,this.triangles[1]=o[1],this.triangles[2]=o[1]))}voronoi(i){return new swi(this,i)}*neighbors(i){const{inedges:n,hull:r,_hullIndex:o,halfedges:l,triangles:c,collinear:u}=this;if(u){const v=u.indexOf(i);v>0&&(yield u[v-1]),v=0&&l!==r&&l!==o;)r=l;return l}_step(i,n,r){const{inedges:o,hull:l,_hullIndex:c,halfedges:u,triangles:f,points:m}=this;if(o[i]===-1||!m.length)return(i+1)%(m.length>>1);let p=i,v=pG(n-m[i*2],2)+pG(r-m[i*2+1],2);const B=o[i];let G=B;do{let T=f[G];const V=pG(n-m[T*2],2)+pG(r-m[T*2+1],2);if(V>5,KY=1<<11;function pwi(){var e=[256,256],i,n,r,o,l,c,u,f=l$e,m=[],p=Math.random,v={};v.layout=function(){for(var T=B(Rp()),V=Gwi((e[0]>>5)*e[1]),E=null,W=m.length,x=-1,k=[],F=m.map(L=>({text:i(L),font:n(L),style:o(L),weight:l(L),rotate:c(L),size:~~(r(L)+1e-14),padding:u(L),xoff:0,yoff:0,x1:0,y1:0,x0:0,y0:0,hasText:!1,sprite:null,datum:L})).sort((L,O)=>O.size-L.size);++x>1,Y.y=e[1]*(p()+.5)>>1,bwi(T,Y,F,x),Y.hasText&&G(V,Y,E)&&(k.push(Y),E?vwi(E,Y):E=[{x:Y.x+Y.x0,y:Y.y+Y.y0},{x:Y.x+Y.x1,y:Y.y+Y.y1}],Y.x-=e[0]>>1,Y.y-=e[1]>>1)}return k};function B(T){T.width=T.height=1;var V=Math.sqrt(T.getContext("2d").getImageData(0,0,1,1).data.length>>2);T.width=(tE<<5)/V,T.height=KY/V;var E=T.getContext("2d");return E.fillStyle=E.strokeStyle="red",E.textAlign="center",{context:E,ratio:V}}function G(T,V,E){for(var W=V.x,x=V.y,k=Math.sqrt(e[0]*e[0]+e[1]*e[1]),F=f(e),Y=p()<.5?1:-1,L=-Y,O,Q,X;(O=F(L+=Y))&&(Q=~~O[0],X=~~O[1],!(Math.min(Math.abs(Q),Math.abs(X))>=k));)if(V.x=W+Q,V.y=x+X,!(V.x+V.x0<0||V.y+V.y0<0||V.x+V.x1>e[0]||V.y+V.y1>e[1])&&(!E||!ywi(V,T,e[0]))&&(!E||Zwi(V,E))){for(var $=V.sprite,ee=V.width>>5,ne=e[0]>>5,ge=V.x-(ee<<4),Ae=ge&127,_=32-Ae,de=V.y1-V.y0,Ze=(V.y+V.y0)*ne+(ge>>5),me,be=0;be>>Ae:0);Ze+=ne}return V.sprite=null,!0}return!1}return v.words=function(T){return arguments.length?(m=T,v):m},v.size=function(T){return arguments.length?(e=[+T[0],+T[1]],v):e},v.font=function(T){return arguments.length?(n=Qb(T),v):n},v.fontStyle=function(T){return arguments.length?(o=Qb(T),v):o},v.fontWeight=function(T){return arguments.length?(l=Qb(T),v):l},v.rotate=function(T){return arguments.length?(c=Qb(T),v):c},v.text=function(T){return arguments.length?(i=Qb(T),v):i},v.spiral=function(T){return arguments.length?(f=Swi[T]||T,v):f},v.fontSize=function(T){return arguments.length?(r=Qb(T),v):r},v.padding=function(T){return arguments.length?(u=Qb(T),v):u},v.random=function(T){return arguments.length?(p=T,v):p},v}function bwi(e,i,n,r){if(!i.sprite){var o=e.context,l=e.ratio;o.clearRect(0,0,(tE<<5)/l,KY/l);var c=0,u=0,f=0,m=n.length,p,v,B,G,T;for(--r;++r>5<<5,B=~~Math.max(Math.abs(x+k),Math.abs(x-k))}else p=p+31>>5<<5;if(B>f&&(f=B),c+p>=tE<<5&&(c=0,u+=f,f=0),u+B>=KY)break;o.translate((c+(p>>1))/l,(u+(B>>1))/l),i.rotate&&o.rotate(i.rotate*Ete),o.fillText(i.text,0,0),i.padding&&(o.lineWidth=2*i.padding,o.strokeText(i.text,0,0)),o.restore(),i.width=p,i.height=B,i.xoff=c,i.yoff=u,i.x1=p>>1,i.y1=B>>1,i.x0=-i.x1,i.y0=-i.y1,i.hasText=!0,c+=p}for(var Y=o.getImageData(0,0,(tE<<5)/l,KY/l).data,L=[];--r>=0;)if(i=n[r],!!i.hasText){for(p=i.width,v=p>>5,B=i.y1-i.y0,G=0;G>5),$=Y[(u+T)*(tE<<5)+(c+G)<<2]?1<<31-G%32:0;L[X]|=$,O|=$}O?Q=T:(i.y0++,B--,T--,u++)}i.y1=i.y0+Q,i.sprite=L.slice(0,(i.y1-i.y0)*v)}}}function ywi(e,i,n){n>>=5;for(var r=e.sprite,o=e.width>>5,l=e.x-(o<<4),c=l&127,u=32-c,f=e.y1-e.y0,m=(e.y+e.y0)*n+(l>>5),p,v=0;v>>c:0))&i[m+B])return!0;m+=n}return!1}function vwi(e,i){var n=e[0],r=e[1];i.x+i.x0r.x&&(r.x=i.x+i.x1),i.y+i.y1>r.y&&(r.y=i.y+i.y1)}function Zwi(e,i){return e.x+e.x1>i[0].x&&e.x+e.x0i[0].y&&e.y+e.y0V(T(E))}o.forEach(T=>{T[c[0]]=NaN,T[c[1]]=NaN,T[c[3]]=0});const m=l.words(o).text(e.text).size(e.size||[500,500]).padding(e.padding||1).spiral(e.spiral||"archimedean").rotate(e.rotate||0).font(e.font||"sans-serif").fontStyle(e.fontStyle||"normal").fontWeight(e.fontWeight||"normal").fontSize(u).random(JC).layout(),p=l.size(),v=p[0]>>1,B=p[1]>>1,G=m.length;for(let T=0,V,E;Tnew Uint8Array(e),Vwi=e=>new Uint16Array(e),VE=e=>new Uint32Array(e);function Ewi(){let e=8,i=[],n=VE(0),r=MF(0,e),o=MF(0,e);return{data:()=>i,seen:()=>n=Hwi(n,i.length),add(l){for(let c=0,u=i.length,f=l.length,m;ci.length,curr:()=>r,prev:()=>o,reset:l=>o[l]=r[l],all:()=>e<257?255:e<65537?65535:4294967295,set(l,c){r[l]|=c},clear(l,c){r[l]&=~c},resize(l,c){const u=r.length;(l>u||c>e)&&(e=Math.max(c,e),r=MF(l,e,r),o=MF(l,e))}}}function Hwi(e,i,n){return e.length>=i?e:(n=n||new e.constructor(i),n.set(e),n)}function MF(e,i,n){const r=(i<257?Rwi:i<65537?Vwi:VE)(e);return n&&r.set(n),r}function dFe(e,i,n){const r=1<0)for(E=0;Ee,size:()=>n}}function Wwi(e,i){return e.sort.call(i,(n,r)=>{const o=e[n],l=e[r];return ol?1:0}),Rui(e,i)}function Nwi(e,i,n,r,o,l,c,u,f){let m=0,p=0,v;for(v=0;mi.modified(r.fields));return n?this.reinit(e,i):this.eval(e,i)}else return this.init(e,i)},init(e,i){const n=e.fields,r=e.query,o=this._indices={},l=this._dims=[],c=r.length;let u=0,f,m;for(;u{const l=o.remove(i,n);for(const c in r)r[c].reindex(l)})},update(e,i,n){const r=this._dims,o=e.query,l=i.stamp,c=r.length;let u=0,f,m;for(n.filters=0,m=0;mG)for(E=G,W=Math.min(v,T);ET)for(E=Math.max(v,T),W=B;Ev)for(T=v,V=Math.min(m,B);TB)for(T=Math.max(m,B),V=p;Tu[p]&n?null:c[p];return l.filter(l.MOD,m),o&o-1?(l.filter(l.ADD,p=>{const v=u[p]&n;return!v&&v^f[p]&n?c[p]:null}),l.filter(l.REM,p=>{const v=u[p]&n;return v&&!(v^(v^f[p]&n))?c[p]:null})):(l.filter(l.ADD,m),l.filter(l.REM,p=>(u[p]&n)===o?c[p]:null)),l.filter(l.SOURCE,p=>m(p._index))}});const kwi=Object.freeze(Object.defineProperty({__proto__:null,crossfilter:DAe,resolvefilter:MAe},Symbol.toStringTag,{value:"Module"})),Xwi="RawCode",Tv="Literal",xwi="Property",Dwi="Identifier",Mwi="ArrayExpression",Fwi="BinaryExpression",c$e="CallExpression",Ywi="ConditionalExpression",Kwi="LogicalExpression",_wi="MemberExpression",Pwi="ObjectExpression",zwi="UnaryExpression";function RA(e){this.type=e}RA.prototype.visit=function(e){let i,n,r;if(e(this))return 1;for(i=Owi(this),n=0,r=i.length;n";wd[Rv]="Identifier";wd[c0]="Keyword";wd[Lz]="Null";wd[gZ]="Numeric";wd[_I]="Punctuator";wd[oN]="String";wd[Lwi]="RegularExpression";var Jwi="ArrayExpression",Uwi="BinaryExpression",Qwi="CallExpression",jwi="ConditionalExpression",A$e="Identifier",$wi="Literal",qwi="LogicalExpression",e2i="MemberExpression",t2i="ObjectExpression",i2i="Property",n2i="UnaryExpression",Ca="Unexpected token %0",r2i="Unexpected number",g2i="Unexpected string",o2i="Unexpected identifier",a2i="Unexpected reserved word",s2i="Unexpected end of input",Foe="Invalid regular expression",Hte="Invalid regular expression: missing /",u$e="Octal literals are not allowed in strict mode.",I2i="Duplicate data property in object literal not allowed in strict mode",ka="ILLEGAL",UH="Disabled.",l2i=new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"),C2i=new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B2\\u08E4-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A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7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA69D\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2D\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]");function Jz(e,i){if(!e)throw new Error("ASSERT: "+i)}function Th(e){return e>=48&&e<=57}function FAe(e){return"0123456789abcdefABCDEF".indexOf(e)>=0}function EE(e){return"01234567".indexOf(e)>=0}function c2i(e){return e===32||e===9||e===11||e===12||e===160||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(e)>=0}function QH(e){return e===10||e===13||e===8232||e===8233}function aN(e){return e===36||e===95||e>=65&&e<=90||e>=97&&e<=122||e===92||e>=128&&l2i.test(String.fromCharCode(e))}function f_(e){return e===36||e===95||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===92||e>=128&&C2i.test(String.fromCharCode(e))}const A2i={if:1,in:1,do:1,var:1,for:1,new:1,try:1,let:1,this:1,else:1,case:1,void:1,with:1,enum:1,while:1,break:1,catch:1,throw:1,const:1,yield:1,class:1,super:1,return:1,typeof:1,delete:1,switch:1,export:1,import:1,public:1,static:1,default:1,finally:1,extends:1,package:1,private:1,function:1,continue:1,debugger:1,interface:1,protected:1,instanceof:1,implements:1};function d$e(){for(;Ft1114111||e!=="}")&&br({},Ca,ka),i<=65535?String.fromCharCode(i):(n=(i-65536>>10)+55296,r=(i-65536&1023)+56320,String.fromCharCode(n,r))}function h$e(){var e,i;for(e=Xi.charCodeAt(Ft++),i=String.fromCharCode(e),e===92&&(Xi.charCodeAt(Ft)!==117&&br({},Ca,ka),++Ft,e=Yoe("u"),(!e||e==="\\"||!aN(e.charCodeAt(0)))&&br({},Ca,ka),i=e);Ft>>=")return Ft+=4,{type:_I,value:c,start:e,end:Ft};if(l=c.substr(0,3),l===">>>"||l==="<<="||l===">>=")return Ft+=3,{type:_I,value:l,start:e,end:Ft};if(o=l.substr(0,2),r===o[1]&&"+-<>&|".indexOf(r)>=0||o==="=>")return Ft+=2,{type:_I,value:o,start:e,end:Ft};if(o==="//"&&br({},Ca,ka),"<>=!+-*%&|^/".indexOf(r)>=0)return++Ft,{type:_I,value:r,start:e,end:Ft};br({},Ca,ka)}function f2i(e){let i="";for(;Ft=0&&Ft=0&&(n=n.replace(/\\u\{([0-9a-fA-F]+)\}/g,(r,o)=>{if(parseInt(o,16)<=1114111)return"x";br({},Foe)}).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"x"));try{new RegExp(n)}catch{br({},Foe)}try{return new RegExp(e,i)}catch{return null}}function y2i(){var e,i,n,r,o;for(e=Xi[Ft],Jz(e==="/","Regular expression literal must start with a slash"),i=Xi[Ft++],n=!1,r=!1;Ft=0&&br({},Foe,n),{value:n,literal:i}}function Z2i(){var e,i,n,r;return Yr=null,d$e(),e=Ft,i=y2i(),n=v2i(),r=b2i(i.value,n.value),{literal:i.literal+n.literal,value:r,regex:{pattern:i.value,flags:n.value},start:e,end:Ft}}function B2i(e){return e.type===Rv||e.type===c0||e.type===Oz||e.type===Lz}function f$e(){if(d$e(),Ft>=Rs)return{type:gN,start:Ft,end:Ft};const e=Xi.charCodeAt(Ft);return aN(e)?h2i():e===40||e===41||e===59?Wte():e===39||e===34?p2i():e===46?Th(Xi.charCodeAt(Ft+1))?fFe():Wte():Th(e)?fFe():Wte()}function UI(){const e=Yr;return Ft=e.end,Yr=f$e(),Ft=e.end,e}function m$e(){const e=Ft;Yr=f$e(),Ft=e}function G2i(e){const i=new RA(Jwi);return i.elements=e,i}function mFe(e,i,n){const r=new RA(e==="||"||e==="&&"?qwi:Uwi);return r.operator=e,r.left=i,r.right=n,r}function S2i(e,i){const n=new RA(Qwi);return n.callee=e,n.arguments=i,n}function w2i(e,i,n){const r=new RA(jwi);return r.test=e,r.consequent=i,r.alternate=n,r}function YAe(e){const i=new RA(A$e);return i.name=e,i}function iE(e){const i=new RA($wi);return i.value=e.value,i.raw=Xi.slice(e.start,e.end),e.regex&&(i.raw==="//"&&(i.raw="/(?:)/"),i.regex=e.regex),i}function pFe(e,i,n){const r=new RA(e2i);return r.computed=e==="[",r.object=i,r.property=n,r.computed||(n.member=!0),r}function T2i(e){const i=new RA(t2i);return i.properties=e,i}function bFe(e,i,n){const r=new RA(i2i);return r.key=i,r.value=n,r.kind=e,r}function R2i(e,i){const n=new RA(n2i);return n.operator=e,n.argument=i,n.prefix=!0,n}function br(e,i){var n,r=Array.prototype.slice.call(arguments,2),o=i.replace(/%(\d)/g,(l,c)=>(Jz(c":case"<=":case">=":case"instanceof":case"in":i=7;break;case"<<":case">>":case">>>":i=8;break;case"+":case"-":i=9;break;case"*":case"/":case"%":i=11;break}return i}function Y2i(){var e,i,n,r,o,l,c,u,f,m;if(e=Yr,f=_Y(),r=Yr,o=ZFe(r),o===0)return f;for(r.prec=o,UI(),i=[e,Yr],c=_Y(),l=[f,r,c];(o=ZFe(Yr))>0;){for(;l.length>2&&o<=l[l.length-2].prec;)c=l.pop(),u=l.pop().value,f=l.pop(),i.pop(),n=mFe(u,f,c),l.push(n);r=UI(),r.prec=o,l.push(r),i.push(Yr),n=_Y(),l.push(n)}for(m=l.length-1,n=l[m],i.pop();m>1;)i.pop(),n=mFe(l[m-1].value,l[m-2],n),m-=2;return n}function Vv(){var e,i,n;return e=Y2i(),Bg("?")&&(UI(),i=Vv(),Vs(":"),n=Vv(),e=w2i(e,i,n)),e}function KAe(){const e=Vv();if(Bg(","))throw new Error(UH);return e}function _Ae(e){Xi=e,Ft=0,Rs=Xi.length,Yr=null,m$e();const i=KAe();if(Yr.type!==gN)throw new Error("Unexpect token after expression.");return i}var p$e={NaN:"NaN",E:"Math.E",LN2:"Math.LN2",LN10:"Math.LN10",LOG2E:"Math.LOG2E",LOG10E:"Math.LOG10E",PI:"Math.PI",SQRT1_2:"Math.SQRT1_2",SQRT2:"Math.SQRT2",MIN_VALUE:"Number.MIN_VALUE",MAX_VALUE:"Number.MAX_VALUE"};function b$e(e){function i(c,u,f,m){let p=e(u[0]);return f&&(p=f+"("+p+")",f.lastIndexOf("new ",0)===0&&(p="("+p+")")),p+"."+c+(m<0?"":m===0?"()":"("+u.slice(1).map(e).join(",")+")")}function n(c,u,f){return m=>i(c,m,u,f)}const r="new Date",o="String",l="RegExp";return{isNaN:"Number.isNaN",isFinite:"Number.isFinite",abs:"Math.abs",acos:"Math.acos",asin:"Math.asin",atan:"Math.atan",atan2:"Math.atan2",ceil:"Math.ceil",cos:"Math.cos",exp:"Math.exp",floor:"Math.floor",hypot:"Math.hypot",log:"Math.log",max:"Math.max",min:"Math.min",pow:"Math.pow",random:"Math.random",round:"Math.round",sin:"Math.sin",sqrt:"Math.sqrt",tan:"Math.tan",clamp:function(c){c.length<3&&Yt("Missing arguments to clamp function."),c.length>3&&Yt("Too many arguments to clamp function.");const u=c.map(e);return"Math.max("+u[1]+", Math.min("+u[2]+","+u[0]+"))"},now:"Date.now",utc:"Date.UTC",datetime:r,date:n("getDate",r,0),day:n("getDay",r,0),year:n("getFullYear",r,0),month:n("getMonth",r,0),hours:n("getHours",r,0),minutes:n("getMinutes",r,0),seconds:n("getSeconds",r,0),milliseconds:n("getMilliseconds",r,0),time:n("getTime",r,0),timezoneoffset:n("getTimezoneOffset",r,0),utcdate:n("getUTCDate",r,0),utcday:n("getUTCDay",r,0),utcyear:n("getUTCFullYear",r,0),utcmonth:n("getUTCMonth",r,0),utchours:n("getUTCHours",r,0),utcminutes:n("getUTCMinutes",r,0),utcseconds:n("getUTCSeconds",r,0),utcmilliseconds:n("getUTCMilliseconds",r,0),length:n("length",null,-1),parseFloat:"parseFloat",parseInt:"parseInt",upper:n("toUpperCase",o,0),lower:n("toLowerCase",o,0),substring:n("substring",o),split:n("split",o),trim:n("trim",o,0),regexp:l,test:n("test",l),if:function(c){c.length<3&&Yt("Missing arguments to if function."),c.length>3&&Yt("Too many arguments to if function.");const u=c.map(e);return"("+u[0]+"?"+u[1]+":"+u[2]+")"}}}function K2i(e){const i=e&&e.length-1;return i&&(e[0]==='"'&&e[i]==='"'||e[0]==="'"&&e[i]==="'")?e.slice(1,-1):e}function y$e(e){e=e||{};const i=e.allowed?BA(e.allowed):{},n=e.forbidden?BA(e.forbidden):{},r=e.constants||p$e,o=(e.functions||b$e)(v),l=e.globalvar,c=e.fieldvar,u=Rn(l)?l:T=>`${l}["${T}"]`;let f={},m={},p=0;function v(T){if(fi(T))return T;const V=B[T.type];return V==null&&Yt("Unsupported type: "+T.type),V(T)}const B={Literal:T=>T.raw,Identifier:T=>{const V=T.name;return p>0?V:Oi(n,V)?Yt("Illegal identifier: "+V):Oi(r,V)?r[V]:Oi(i,V)?V:(f[V]=1,u(V))},MemberExpression:T=>{const V=!T.computed,E=v(T.object);V&&(p+=1);const W=v(T.property);return E===c&&(m[K2i(W)]=1),V&&(p-=1),E+(V?"."+W:"["+W+"]")},CallExpression:T=>{T.callee.type!=="Identifier"&&Yt("Illegal callee type: "+T.callee.type);const V=T.callee.name,E=T.arguments,W=Oi(o,V)&&o[V];return W||Yt("Unrecognized function: "+V),Rn(W)?W(E):W+"("+E.map(v).join(",")+")"},ArrayExpression:T=>"["+T.elements.map(v).join(",")+"]",BinaryExpression:T=>"("+v(T.left)+" "+T.operator+" "+v(T.right)+")",UnaryExpression:T=>"("+T.operator+v(T.argument)+")",ConditionalExpression:T=>"("+v(T.test)+"?"+v(T.consequent)+":"+v(T.alternate)+")",LogicalExpression:T=>"("+v(T.left)+T.operator+v(T.right)+")",ObjectExpression:T=>"{"+T.properties.map(v).join(",")+"}",Property:T=>{p+=1;const V=v(T.key);return p-=1,V+":"+v(T.value)}};function G(T){const V={code:v(T),globals:Object.keys(f),fields:Object.keys(m)};return f={},m={},V}return G.functions=o,G.constants=r,G}function sN(e,i,n){e.prototype=i.prototype=n,n.constructor=e}function Qz(e,i){var n=Object.create(e.prototype);for(var r in i)n[r]=i[r];return n}function oZ(){}var jH=.7,m_=1/jH,AS="\\s*([+-]?\\d+)\\s*",$H="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ed="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",_2i=/^#([0-9a-f]{3,8})$/,P2i=new RegExp(`^rgb\\(${AS},${AS},${AS}\\)$`),z2i=new RegExp(`^rgb\\(${ed},${ed},${ed}\\)$`),O2i=new RegExp(`^rgba\\(${AS},${AS},${AS},${$H}\\)$`),L2i=new RegExp(`^rgba\\(${ed},${ed},${ed},${$H}\\)$`),J2i=new RegExp(`^hsl\\(${$H},${ed},${ed}\\)$`),U2i=new RegExp(`^hsla\\(${$H},${ed},${ed},${$H}\\)$`),BFe={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};sN(oZ,PAe,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:GFe,formatHex:GFe,formatHex8:Q2i,formatHsl:j2i,formatRgb:SFe,toString:SFe});function GFe(){return this.rgb().formatHex()}function Q2i(){return this.rgb().formatHex8()}function j2i(){return Z$e(this).formatHsl()}function SFe(){return this.rgb().formatRgb()}function PAe(e){var i,n;return e=(e+"").trim().toLowerCase(),(i=_2i.exec(e))?(n=i[1].length,i=parseInt(i[1],16),n===6?wFe(i):n===3?new Bs(i>>8&15|i>>4&240,i>>4&15|i&240,(i&15)<<4|i&15,1):n===8?FF(i>>24&255,i>>16&255,i>>8&255,(i&255)/255):n===4?FF(i>>12&15|i>>8&240,i>>8&15|i>>4&240,i>>4&15|i&240,((i&15)<<4|i&15)/255):null):(i=P2i.exec(e))?new Bs(i[1],i[2],i[3],1):(i=z2i.exec(e))?new Bs(i[1]*255/100,i[2]*255/100,i[3]*255/100,1):(i=O2i.exec(e))?FF(i[1],i[2],i[3],i[4]):(i=L2i.exec(e))?FF(i[1]*255/100,i[2]*255/100,i[3]*255/100,i[4]):(i=J2i.exec(e))?VFe(i[1],i[2]/100,i[3]/100,1):(i=U2i.exec(e))?VFe(i[1],i[2]/100,i[3]/100,i[4]):BFe.hasOwnProperty(e)?wFe(BFe[e]):e==="transparent"?new Bs(NaN,NaN,NaN,0):null}function wFe(e){return new Bs(e>>16&255,e>>8&255,e&255,1)}function FF(e,i,n,r){return r<=0&&(e=i=n=NaN),new Bs(e,i,n,r)}function v$e(e){return e instanceof oZ||(e=PAe(e)),e?(e=e.rgb(),new Bs(e.r,e.g,e.b,e.opacity)):new Bs}function zAe(e,i,n,r){return arguments.length===1?v$e(e):new Bs(e,i,n,r??1)}function Bs(e,i,n,r){this.r=+e,this.g=+i,this.b=+n,this.opacity=+r}sN(Bs,zAe,Qz(oZ,{brighter(e){return e=e==null?m_:Math.pow(m_,e),new Bs(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?jH:Math.pow(jH,e),new Bs(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Bs(Uy(this.r),Uy(this.g),Uy(this.b),p_(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:TFe,formatHex:TFe,formatHex8:$2i,formatRgb:RFe,toString:RFe}));function TFe(){return`#${Ny(this.r)}${Ny(this.g)}${Ny(this.b)}`}function $2i(){return`#${Ny(this.r)}${Ny(this.g)}${Ny(this.b)}${Ny((isNaN(this.opacity)?1:this.opacity)*255)}`}function RFe(){const e=p_(this.opacity);return`${e===1?"rgb(":"rgba("}${Uy(this.r)}, ${Uy(this.g)}, ${Uy(this.b)}${e===1?")":`, ${e})`}`}function p_(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Uy(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ny(e){return e=Uy(e),(e<16?"0":"")+e.toString(16)}function VFe(e,i,n,r){return r<=0?e=i=n=NaN:n<=0||n>=1?e=i=NaN:i<=0&&(e=NaN),new aA(e,i,n,r)}function Z$e(e){if(e instanceof aA)return new aA(e.h,e.s,e.l,e.opacity);if(e instanceof oZ||(e=PAe(e)),!e)return new aA;if(e instanceof aA)return e;e=e.rgb();var i=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(i,n,r),l=Math.max(i,n,r),c=NaN,u=l-o,f=(l+o)/2;return u?(i===l?c=(n-r)/u+(n0&&f<1?0:c,new aA(c,u,f,e.opacity)}function B$e(e,i,n,r){return arguments.length===1?Z$e(e):new aA(e,i,n,r??1)}function aA(e,i,n,r){this.h=+e,this.s=+i,this.l=+n,this.opacity=+r}sN(aA,B$e,Qz(oZ,{brighter(e){return e=e==null?m_:Math.pow(m_,e),new aA(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?jH:Math.pow(jH,e),new aA(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,i=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*i,o=2*n-r;return new Bs(kte(e>=240?e-240:e+120,o,r),kte(e,o,r),kte(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new aA(EFe(this.h),YF(this.s),YF(this.l),p_(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=p_(this.opacity);return`${e===1?"hsl(":"hsla("}${EFe(this.h)}, ${YF(this.s)*100}%, ${YF(this.l)*100}%${e===1?")":`, ${e})`}`}}));function EFe(e){return e=(e||0)%360,e<0?e+360:e}function YF(e){return Math.max(0,Math.min(1,e||0))}function kte(e,i,n){return(e<60?i+(n-i)*e/60:e<180?n:e<240?i+(n-i)*(240-e)/60:i)*255}const q2i=Math.PI/180,eTi=180/Math.PI,b_=18,G$e=.96422,S$e=1,w$e=.82521,T$e=4/29,uS=6/29,R$e=3*uS*uS,tTi=uS*uS*uS;function V$e(e){if(e instanceof td)return new td(e.l,e.a,e.b,e.opacity);if(e instanceof Yh)return W$e(e);e instanceof Bs||(e=v$e(e));var i=Mte(e.r),n=Mte(e.g),r=Mte(e.b),o=Xte((.2225045*i+.7168786*n+.0606169*r)/S$e),l,c;return i===n&&n===r?l=c=o:(l=Xte((.4360747*i+.3850649*n+.1430804*r)/G$e),c=Xte((.0139322*i+.0971045*n+.7141733*r)/w$e)),new td(116*o-16,500*(l-o),200*(o-c),e.opacity)}function E$e(e,i,n,r){return arguments.length===1?V$e(e):new td(e,i,n,r??1)}function td(e,i,n,r){this.l=+e,this.a=+i,this.b=+n,this.opacity=+r}sN(td,E$e,Qz(oZ,{brighter(e){return new td(this.l+b_*(e??1),this.a,this.b,this.opacity)},darker(e){return new td(this.l-b_*(e??1),this.a,this.b,this.opacity)},rgb(){var e=(this.l+16)/116,i=isNaN(this.a)?e:e+this.a/500,n=isNaN(this.b)?e:e-this.b/200;return i=G$e*xte(i),e=S$e*xte(e),n=w$e*xte(n),new Bs(Dte(3.1338561*i-1.6168667*e-.4906146*n),Dte(-.9787684*i+1.9161415*e+.033454*n),Dte(.0719453*i-.2289914*e+1.4052427*n),this.opacity)}}));function Xte(e){return e>tTi?Math.pow(e,1/3):e/R$e+T$e}function xte(e){return e>uS?e*e*e:R$e*(e-T$e)}function Dte(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Mte(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function iTi(e){if(e instanceof Yh)return new Yh(e.h,e.c,e.l,e.opacity);if(e instanceof td||(e=V$e(e)),e.a===0&&e.b===0)return new Yh(NaN,0i?1:e>=i?0:NaN}function nTi(e,i){return e==null||i==null?NaN:ie?1:i>=e?0:NaN}function rTi(e){let i,n,r;e.length!==2?(i=Fte,n=(u,f)=>Fte(e(u),f),r=(u,f)=>e(u)-f):(i=e===Fte||e===nTi?e:gTi,n=e,r=e);function o(u,f,m=0,p=u.length){if(m>>1;n(u[v],f)<0?m=v+1:p=v}while(m>>1;n(u[v],f)<=0?m=v+1:p=v}while(mm&&r(u[v-1],f)>-r(u[v],f)?v-1:v}return{left:o,center:c,right:l}}function gTi(){return 0}function oTi(e,...i){e=new l3(e),i=i.map(aTi);e:for(const n of e)for(const r of i)if(!r.has(n)){e.delete(n);continue e}return e}function aTi(e){return e instanceof l3?e:new l3(e)}function sTi(...e){const i=new l3;for(const n of e)for(const r of n)i.add(r);return i}const OAe="intersect",HFe="union",ITi="vlMulti",lTi="vlPoint",WFe="or",CTi="and",Wu="_vgsid_",qH=ol(Wu),cTi="E",ATi="R",uTi="R-E",dTi="R-LE",hTi="R-RE",y_="index:unit";function NFe(e,i){for(var n=i.fields,r=i.values,o=n.length,l=0,c,u;lTn(i.fields?{values:i.fields.map(r=>(r.getter||(r.getter=ol(r.field)))(n.datum))}:{[Wu]:qH(n.datum)},i))}function vTi(e,i,n,r){for(var o=this.context.data[e],l=o?o.values.value:[],c={},u={},f={},m,p,v,B,G,T,V,E,W,x,k=l.length,F=0,Y,L;F(O[p[X].field]=Q,O),{})))}else G=Wu,T=qH(m),V=c[G]||(c[G]={}),E=V[B]||(V[B]=[]),E.push(T),n&&(E=u[B]||(u[B]=[]),E.push({[Wu]:T}));if(i=i||HFe,c[Wu]?c[Wu]=Yte[`${Wu}_${i}`](...Object.values(c[Wu])):Object.keys(c).forEach(O=>{c[O]=Object.keys(c[O]).map(Q=>c[O][Q]).reduce((Q,X)=>Q===void 0?X:Yte[`${f[O]}_${i}`](Q,X))}),l=Object.keys(u),n&&l.length){const O=r?lTi:ITi;c[O]=i===HFe?{[WFe]:l.reduce((Q,X)=>(Q.push(...u[X]),Q),[])}:{[CTi]:l.map(Q=>({[WFe]:u[Q]}))}}return c}var Yte={[`${Wu}_union`]:sTi,[`${Wu}_intersect`]:oTi,E_union:function(e,i){if(!e.length)return i;for(var n=0,r=i.length;ni.indexOf(n)>=0):i},R_union:function(e,i){var n=Zs(i[0]),r=Zs(i[1]);return n>r&&(n=i[1],r=i[0]),e.length?(e[0]>n&&(e[0]=n),e[1]r&&(n=i[1],r=i[0]),e.length?rr&&(e[1]=r),e):[n,r]}};const ZTi=":",BTi="@";function LAe(e,i,n,r){i[0].type!==Tv&&Yt("First argument to selection functions must be a string literal.");const o=i[0].value,l=i.length>=2&&sr(i).value,c="unit",u=BTi+c,f=ZTi+o;l===OAe&&!Oi(r,u)&&(r[u]=n.getData(o).indataRef(n,c)),Oi(r,f)||(r[f]=n.getData(o).tuplesRef())}function k$e(e){const i=this.context.data[e];return i?i.values.value:[]}function GTi(e,i,n){const r=this.context.data[e]["index:"+i],o=r?r.value.get(n):void 0;return o&&o.count}function STi(e,i){const n=this.context.dataflow,r=this.context.data[e],o=r.input;return n.pulse(o,n.changeset().remove(OC).insert(i)),1}function wTi(e,i,n){if(e){const r=this.context.dataflow,o=e.mark.source;r.pulse(o,r.changeset().encode(e,i))}return n!==void 0?n:e}const IN=e=>function(i,n){return this.context.dataflow.locale()[e](n)(i)},TTi=IN("format"),X$e=IN("timeFormat"),RTi=IN("utcFormat"),VTi=IN("timeParse"),ETi=IN("utcParse"),KF=new Date(2e3,0,1);function jz(e,i,n){return!Number.isInteger(e)||!Number.isInteger(i)?"":(KF.setYear(2e3),KF.setMonth(e),KF.setDate(i),X$e.call(this,KF,n))}function HTi(e){return jz.call(this,e,1,"%B")}function WTi(e){return jz.call(this,e,1,"%b")}function NTi(e){return jz.call(this,0,2+e,"%A")}function kTi(e){return jz.call(this,0,2+e,"%a")}const XTi=":",xTi="@",Koe="%",x$e="$";function JAe(e,i,n,r){i[0].type!==Tv&&Yt("First argument to data functions must be a string literal.");const o=i[0].value,l=XTi+o;if(!Oi(l,r))try{r[l]=n.getData(o).tuplesRef()}catch{}}function DTi(e,i,n,r){i[0].type!==Tv&&Yt("First argument to indata must be a string literal."),i[1].type!==Tv&&Yt("Second argument to indata must be a string literal.");const o=i[0].value,l=i[1].value,c=xTi+l;Oi(c,r)||(r[c]=n.getData(o).indataRef(n,l))}function il(e,i,n,r){if(i[0].type===Tv)kFe(n,r,i[0].value);else for(e in n.scales)kFe(n,r,e)}function kFe(e,i,n){const r=Koe+n;if(!Oi(i,r))try{i[r]=e.scaleRef(n)}catch{}}function yf(e,i){if(Rn(e))return e;if(fi(e)){const n=i.scales[e];return n&&m0i(n.value)?n.value:void 0}}function MTi(e,i,n){i.__bandwidth=o=>o&&o.bandwidth?o.bandwidth():0,n._bandwidth=il,n._range=il,n._scale=il;const r=o=>"_["+(o.type===Tv?ai(Koe+o.value):ai(Koe)+"+"+e(o))+"]";return{_bandwidth:o=>`this.__bandwidth(${r(o[0])})`,_range:o=>`${r(o[0])}.range()`,_scale:o=>`${r(o[0])}(${e(o[1])})`}}function UAe(e,i){return function(n,r,o){if(n){const l=yf(n,(o||this).context);return l&&l.path[e](r)}else return i(r)}}const FTi=UAe("area",HZi),YTi=UAe("bounds",XZi),KTi=UAe("centroid",KZi);function _Ti(e){const i=this.context.group;let n=!1;if(i)for(;e;){if(e===i){n=!0;break}e=e.mark.group}return n}function QAe(e,i,n){try{e[i].apply(e,["EXPRESSION"].concat([].slice.call(n)))}catch(r){e.warn(r)}return n[n.length-1]}function PTi(){return QAe(this.context.dataflow,"warn",arguments)}function zTi(){return QAe(this.context.dataflow,"info",arguments)}function OTi(){return QAe(this.context.dataflow,"debug",arguments)}function Kte(e){const i=e/255;return i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4)}function _oe(e){const i=zAe(e),n=Kte(i.r),r=Kte(i.g),o=Kte(i.b);return .2126*n+.7152*r+.0722*o}function LTi(e,i){const n=_oe(e),r=_oe(i),o=Math.max(n,r),l=Math.min(n,r);return(o+.05)/(l+.05)}function JTi(){const e=[].slice.call(arguments);return e.unshift({}),Tn(...e)}function D$e(e,i){return e===i||e!==e&&i!==i?!0:Pt(e)?Pt(i)&&e.length===i.length?UTi(e,i):!1:vi(e)&&vi(i)?M$e(e,i):!1}function UTi(e,i){for(let n=0,r=e.length;nM$e(e,i)}function QTi(e,i,n,r,o,l){const c=this.context.dataflow,u=this.context.data[e],f=u.input,m=c.stamp();let p=u.changes,v,B;if(c._trigger===!1||!(f.value.length||i||r))return 0;if((!p||p.stamp{u.modified=!0,c.pulse(f,p).run()},!0,1)),n&&(v=n===!0?OC:Pt(n)||gz(n)?n:XFe(n),p.remove(v)),i&&p.insert(i),r&&(v=XFe(r),f.value.some(v)?p.remove(v):p.insert(r)),o)for(B in l)p.modify(o,B,l[B]);return 1}function jTi(e){const i=e.touches,n=i[0].clientX-i[1].clientX,r=i[0].clientY-i[1].clientY;return Math.hypot(n,r)}function $Ti(e){const i=e.touches;return Math.atan2(i[0].clientY-i[1].clientY,i[0].clientX-i[1].clientX)}const xFe={};function qTi(e,i){const n=xFe[i]||(xFe[i]=ol(i));return Pt(e)?e.map(n):n(e)}function jAe(e){return Pt(e)||ArrayBuffer.isView(e)?e:null}function $Ae(e){return jAe(e)||(fi(e)?e:null)}function eRi(e){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r1?i-1:0),r=1;r1?i-1:0),r=1;r1?i-1:0),r=1;rl.stop(m(p),e(p))),l}function uRi(e,i,n){const r=yf(e,(n||this).context);return function(o){return r?r.path.context(o)(i):""}}function dRi(e){let i=null;return function(n){return n?MH(n,i=i||qS(e)):e}}const F$e=e=>e.data;function Y$e(e,i){const n=k$e.call(i,e);return n.root&&n.root.lookup||{}}function hRi(e,i,n){const r=Y$e(e,this),o=r[i],l=r[n];return o&&l?o.path(l).map(F$e):void 0}function fRi(e,i){const n=Y$e(e,this)[i];return n?n.ancestors().map(F$e):void 0}const K$e=()=>typeof window<"u"&&window||null;function mRi(){const e=K$e();return e?e.screen:{}}function pRi(){const e=K$e();return e?[e.innerWidth,e.innerHeight]:[void 0,void 0]}function bRi(){const e=this.context.dataflow,i=e.container&&e.container();return i?[i.clientWidth,i.clientHeight]:[void 0,void 0]}function _$e(e,i,n){if(!e)return[];const[r,o]=e,l=new Eo().set(r[0],r[1],o[0],o[1]),c=n||this.context.dataflow.scenegraph().root;return A6e(c,l,yRi(i))}function yRi(e){let i=null;if(e){const n=pi(e.marktype),r=pi(e.markname);i=o=>(!n.length||n.some(l=>o.marktype===l))&&(!r.length||r.some(l=>o.name===l))}return i}function vRi(e,i,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:5;e=pi(e);const o=e[e.length-1];return o===void 0||Math.hypot(o[0]-i,o[1]-n)>r?[...e,[i,n]]:e}function ZRi(e){return pi(e).reduce((i,n,r)=>{let[o,l]=n;return i+=r==0?`M ${o},${l} `:r===e.length-1?" Z":`L ${o},${l} `},"")}function BRi(e,i,n){const{x:r,y:o,mark:l}=n,c=new Eo().set(Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER);for(const[f,m]of i)fc.x2&&(c.x2=f),mc.y2&&(c.y2=m);return c.translate(r,o),_$e([[c.x1,c.y1],[c.x2,c.y2]],e,l).filter(f=>GRi(f.x,f.y,i))}function GRi(e,i,n){let r=0;for(let o=0,l=n.length-1;oi!=u>i&&e<(c-f)*(i-m)/(u-m)+f&&r++}return r&1}const eW={random(){return JC()},cumulativeNormal:lz,cumulativeLogNormal:tCe,cumulativeUniform:gCe,densityNormal:Qle,densityLogNormal:eCe,densityUniform:rCe,quantileNormal:Cz,quantileLogNormal:iCe,quantileUniform:oCe,sampleNormal:Iz,sampleLogNormal:qle,sampleUniform:nCe,isArray:Pt,isBoolean:a0,isDate:Sp,isDefined(e){return e!==void 0},isNumber:jr,isObject:vi,isRegExp:_Ue,isString:fi,isTuple:gz,isValid(e){return e!=null&&e===e},toBoolean:Vle,toDate(e){return Ele(e)},toNumber:Zs,toString:Hle,indexof:tRi,join:eRi,lastindexof:iRi,replace:rRi,reverse:gRi,slice:nRi,flush:YUe,lerp:PUe,merge:JTi,pad:LUe,peek:sr,pluck:qTi,span:WW,inrange:OG,truncate:JUe,rgb:zAe,lab:E$e,hcl:H$e,hsl:B$e,luminance:_oe,contrast:LTi,sequence:Yl,format:TTi,utcFormat:RTi,utcParse:ETi,utcOffset:S7e,utcSequence:R7e,timeFormat:X$e,timeParse:VTi,timeOffset:G7e,timeSequence:T7e,timeUnitSpecifier:u7e,monthFormat:HTi,monthAbbrevFormat:WTi,dayFormat:NTi,dayAbbrevFormat:kTi,quarter:xUe,utcquarter:DUe,week:h7e,utcweek:p7e,dayofyear:d7e,utcdayofyear:m7e,warn:PTi,info:zTi,debug:OTi,extent(e){return Cd(e)},inScope:_Ti,intersect:_$e,clampRange:MUe,pinchDistance:jTi,pinchAngle:$Ti,screen:mRi,containerSize:bRi,windowSize:pRi,bandspace:oRi,setdata:STi,pathShape:dRi,panLinear:WUe,panLog:NUe,panPow:kUe,panSymlog:XUe,zoomLinear:Ble,zoomLog:Gle,zoomPow:s3,zoomSymlog:Sle,encode:wTi,modify:QTi,lassoAppend:vRi,lassoPath:ZRi,intersectLasso:BRi},SRi=["view","item","group","xy","x","y"],wRi="event.vega.",P$e="this.",qAe={},z$e={forbidden:["_"],allowed:["datum","event","item"],fieldvar:"datum",globalvar:e=>`_[${ai(x$e+e)}]`,functions:TRi,constants:p$e,visitors:qAe},Poe=y$e(z$e);function TRi(e){const i=b$e(e);SRi.forEach(n=>i[n]=wRi+n);for(const n in eW)i[n]=P$e+n;return Tn(i,MTi(e,eW,qAe)),i}function Wo(e,i,n){return arguments.length===1?eW[e]:(eW[e]=i,n&&(qAe[e]=n),Poe&&(Poe.functions[e]=P$e+e),this)}Wo("bandwidth",aRi,il);Wo("copy",sRi,il);Wo("domain",IRi,il);Wo("range",CRi,il);Wo("invert",lRi,il);Wo("scale",cRi,il);Wo("gradient",ARi,il);Wo("geoArea",FTi,il);Wo("geoBounds",YTi,il);Wo("geoCentroid",KTi,il);Wo("geoShape",uRi,il);Wo("indata",GTi,DTi);Wo("data",k$e,JAe);Wo("treePath",hRi,JAe);Wo("treeAncestors",fRi,JAe);Wo("vlSelectionTest",fTi,LAe);Wo("vlSelectionIdTest",bTi,LAe);Wo("vlSelectionResolve",vTi,LAe);Wo("vlSelectionTuples",yTi);function hd(e,i){const n={};let r;try{e=fi(e)?e:ai(e)+"",r=_Ae(e)}catch{Yt("Expression parse error: "+e)}r.visit(l=>{if(l.type!==c$e)return;const c=l.callee.name,u=z$e.visitors[c];u&&u(c,l.arguments,i,n)});const o=Poe(r);return o.globals.forEach(l=>{const c=x$e+l;!Oi(n,c)&&i.getSignal(l)&&(n[c]=i.signalRef(l))}),{$expr:Tn({code:o.code},i.options.ast?{ast:r}:null),$fields:o.fields,$params:n}}function RRi(e){const i=this,n=e.operators||[];return e.background&&(i.background=e.background),e.eventConfig&&(i.eventConfig=e.eventConfig),e.locale&&(i.locale=e.locale),n.forEach(r=>i.parseOperator(r)),n.forEach(r=>i.parseOperatorParameters(r)),(e.streams||[]).forEach(r=>i.parseStream(r)),(e.updates||[]).forEach(r=>i.parseUpdate(r)),i.resolve()}const VRi=BA(["rule"]),DFe=BA(["group","image","rect"]);function ERi(e,i){let n="";return VRi[i]||(e.x2&&(e.x?(DFe[i]&&(n+="if(o.x>o.x2)$=o.x,o.x=o.x2,o.x2=$;"),n+="o.width=o.x2-o.x;"):n+="o.x=o.x2-(o.width||0);"),e.xc&&(n+="o.x=o.xc-(o.width||0)/2;"),e.y2&&(e.y?(DFe[i]&&(n+="if(o.y>o.y2)$=o.y,o.y=o.y2,o.y2=$;"),n+="o.height=o.y2-o.y;"):n+="o.y=o.y2-(o.height||0);"),e.yc&&(n+="o.y=o.yc-(o.height||0)/2;")),n}function eue(e){return(e+"").toLowerCase()}function HRi(e){return eue(e)==="operator"}function WRi(e){return eue(e)==="collect"}function C9(e,i,n){n.endsWith(";")||(n="return("+n+");");const r=Function(...i.concat(n));return e&&e.functions?r.bind(e.functions):r}function NRi(e,i,n,r){return`((u = ${e}) < (v = ${i}) || u == null) && v != null ? ${n} - : (u > v || v == null) && u != null ? ${r} - : ((v = v instanceof Date ? +v : v), (u = u instanceof Date ? +u : u)) !== u && v === v ? ${n} - : v !== v && u === u ? ${r} : `}var kRi={operator:(e,i)=>C9(e,["_"],i.code),parameter:(e,i)=>C9(e,["datum","_"],i.code),event:(e,i)=>C9(e,["event"],i.code),handler:(e,i)=>{const n=`var datum=event.item&&event.item.datum;return ${i.code};`;return C9(e,["_","event"],n)},encode:(e,i)=>{const{marktype:n,channels:r}=i;let o="var o=item,datum=o.datum,m=0,$;";for(const l in r){const c="o["+ai(l)+"]";o+=`$=${r[l].code};if(${c}!==$)${c}=$,m=1;`}return o+=ERi(r,n),o+="return m;",C9(e,["item","_"],o)},codegen:{get(e){const i=`[${e.map(ai).join("][")}]`,n=Function("_",`return _${i};`);return n.path=i,n},comparator(e,i){let n;const r=(l,c)=>{const u=i[c];let f,m;return l.path?(f=`a${l.path}`,m=`b${l.path}`):((n=n||{})["f"+c]=l,f=`this.f${c}(a)`,m=`this.f${c}(b)`),NRi(f,m,-u,u)},o=Function("a","b","var u, v; return "+e.map(r).join("")+"0;");return n?o.bind(n):o}}};function XRi(e){const i=this;HRi(e.type)||!e.type?i.operator(e,e.update?i.operatorExpression(e.update):null):i.transform(e,e.type)}function xRi(e){const i=this;if(e.params){const n=i.get(e.id);n||Yt("Invalid operator id: "+e.id),i.dataflow.connect(n,n.parameters(i.parseParameters(e.params),e.react,e.initonly))}}function DRi(e,i){i=i||{};const n=this;for(const r in e){const o=e[r];i[r]=Pt(o)?o.map(l=>MFe(l,n,i)):MFe(o,n,i)}return i}function MFe(e,i,n){if(!e||!vi(e))return e;for(let r=0,o=FFe.length,l;ro&&o.$tupleid?Pi:o);return i.fn[n]||(i.fn[n]=wle(r,e.$order,i.expr.codegen))}function PRi(e,i){const n=e.$encode,r={};for(const o in n){const l=n[o];r[o]=dl(i.encodeExpression(l.$expr),l.$fields),r[o].output=l.$output}return r}function zRi(e,i){return i}function ORi(e,i){const n=e.$subflow;return function(r,o,l){const c=i.fork().parse(n),u=c.get(n.operators[0].id),f=c.signals.parent;return f&&f.set(l),u.detachSubflow=()=>i.detach(c),u}}function LRi(){return Pi}function JRi(e){var i=this,n=e.filter!=null?i.eventExpression(e.filter):void 0,r=e.stream!=null?i.get(e.stream):void 0,o;e.source?r=i.events(e.source,e.type,n):e.merge&&(o=e.merge.map(l=>i.get(l)),r=o[0].merge.apply(o[0],o.slice(1))),e.between&&(o=e.between.map(l=>i.get(l)),r=r.between(o[0],o[1])),e.filter&&(r=r.filter(n)),e.throttle!=null&&(r=r.throttle(+e.throttle)),e.debounce!=null&&(r=r.debounce(+e.debounce)),r==null&&Yt("Invalid stream definition: "+JSON.stringify(e)),e.consume&&r.consume(!0),i.stream(e,r)}function URi(e){var i=this,n=vi(n=e.source)?n.$ref:n,r=i.get(n),o=null,l=e.update,c=void 0;r||Yt("Source not defined: "+e.source),o=e.target&&e.target.$expr?i.eventExpression(e.target.$expr):i.get(e.target),l&&l.$expr&&(l.$params&&(c=i.parseParameters(l.$params)),l=i.handlerExpression(l.$expr)),i.update(e,r,o,l,c)}const QRi={skip:!0};function jRi(e){var i=this,n={};if(e.signals){var r=n.signals={};Object.keys(i.signals).forEach(l=>{const c=i.signals[l];e.signals(l,c)&&(r[l]=c.value)})}if(e.data){var o=n.data={};Object.keys(i.data).forEach(l=>{const c=i.data[l];e.data(l,c)&&(o[l]=c.input.value)})}return i.subcontext&&e.recurse!==!1&&(n.subcontext=i.subcontext.map(l=>l.getState(e))),n}function $Ri(e){var i=this,n=i.dataflow,r=e.data,o=e.signals;Object.keys(o||{}).forEach(l=>{n.update(i.signals[l],o[l],QRi)}),Object.keys(r||{}).forEach(l=>{n.pulse(i.data[l].input,n.changeset().remove(OC).insert(r[l]))}),(e.subcontext||[]).forEach((l,c)=>{const u=i.subcontext[c];u&&u.setState(l)})}function O$e(e,i,n,r){return new L$e(e,i,n,r)}function L$e(e,i,n,r){this.dataflow=e,this.transforms=i,this.events=e.events.bind(e),this.expr=r||kRi,this.signals={},this.scales={},this.nodes={},this.data={},this.fn={},n&&(this.functions=Object.create(n),this.functions.context=this)}function YFe(e){this.dataflow=e.dataflow,this.transforms=e.transforms,this.events=e.events,this.expr=e.expr,this.signals=Object.create(e.signals),this.scales=Object.create(e.scales),this.nodes=Object.create(e.nodes),this.data=Object.create(e.data),this.fn=Object.create(e.fn),e.functions&&(this.functions=Object.create(e.functions),this.functions.context=this)}L$e.prototype=YFe.prototype={fork(){const e=new YFe(this);return(this.subcontext||(this.subcontext=[])).push(e),e},detach(e){this.subcontext=this.subcontext.filter(n=>n!==e);const i=Object.keys(e.nodes);for(const n of i)e.nodes[n]._targets=null;for(const n of i)e.nodes[n].detach();e.nodes=null},get(e){return this.nodes[e]},set(e,i){return this.nodes[e]=i},add(e,i){const n=this,r=n.dataflow,o=e.value;if(n.set(e.id,i),WRi(e.type)&&o&&(o.$ingest?r.ingest(i,o.$ingest,o.$format):o.$request?r.preload(i,o.$request,o.$format):r.pulse(i,r.changeset().insert(o))),e.root&&(n.root=i),e.parent){let l=n.get(e.parent.$ref);l?(r.connect(l,[i]),i.targets().add(l)):(n.unresolved=n.unresolved||[]).push(()=>{l=n.get(e.parent.$ref),r.connect(l,[i]),i.targets().add(l)})}if(e.signal&&(n.signals[e.signal]=i),e.scale&&(n.scales[e.scale]=i),e.data)for(const l in e.data){const c=n.data[l]||(n.data[l]={});e.data[l].forEach(u=>c[u]=i)}},resolve(){return(this.unresolved||[]).forEach(e=>e()),delete this.unresolved,this},operator(e,i){this.add(e,this.dataflow.add(e.value,i))},transform(e,i){this.add(e,this.dataflow.add(this.transforms[eue(i)]))},stream(e,i){this.set(e.id,i)},update(e,i,n,r,o){this.dataflow.on(i,n,r,o,e.options)},operatorExpression(e){return this.expr.operator(this,e)},parameterExpression(e){return this.expr.parameter(this,e)},eventExpression(e){return this.expr.event(this,e)},handlerExpression(e){return this.expr.handler(this,e)},encodeExpression(e){return this.expr.encode(this,e)},parse:RRi,parseOperator:XRi,parseOperatorParameters:xRi,parseParameters:DRi,parseStream:JRi,parseUpdate:URi,getState:jRi,setState:$Ri};function qRi(e){const i=e.container();i&&(i.setAttribute("role","graphics-document"),i.setAttribute("aria-roleDescription","visualization"),J$e(i,e.description()))}function J$e(e,i){e&&(i==null?e.removeAttribute("aria-label"):e.setAttribute("aria-label",i))}function eVi(e){e.add(null,i=>(e._background=i.bg,e._resize=1,i.bg),{bg:e._signals.background})}const _te="default";function tVi(e){const i=e._signals.cursor||(e._signals.cursor=e.add({user:_te,item:null}));e.on(e.events("view","mousemove"),i,(n,r)=>{const o=i.value,l=o?fi(o)?o:o.user:_te,c=r.item&&r.item.cursor||null;return o&&l===o.user&&c==o.item?o:{user:l,item:c}}),e.add(null,function(n){let r=n.cursor,o=this.value;return fi(r)||(o=r.item,r=r.user),zoe(e,r&&r!==_te?r:o||r),o},{cursor:i})}function zoe(e,i){const n=e.globalCursor()?typeof document<"u"&&document.body:e.container();if(n)return i==null?n.style.removeProperty("cursor"):n.style.cursor=i}function v_(e,i){var n=e._runtime.data;return Oi(n,i)||Yt("Unrecognized data set: "+i),n[i]}function iVi(e,i){return arguments.length<2?v_(this,e).values.value:$z.call(this,e,iZ().remove(OC).insert(i))}function $z(e,i){i4e(i)||Yt("Second argument to changes must be a changeset.");const n=v_(this,e);return n.modified=!0,this.pulse(n.input,i)}function nVi(e,i){return $z.call(this,e,iZ().insert(i))}function rVi(e,i){return $z.call(this,e,iZ().remove(i))}function U$e(e){var i=e.padding();return Math.max(0,e._viewWidth+i.left+i.right)}function Q$e(e){var i=e.padding();return Math.max(0,e._viewHeight+i.top+i.bottom)}function qz(e){var i=e.padding(),n=e._origin;return[i.left+n[0],i.top+n[1]]}function gVi(e){var i=qz(e),n=U$e(e),r=Q$e(e);e._renderer.background(e.background()),e._renderer.resize(n,r,i),e._handler.origin(i),e._resizeListeners.forEach(o=>{try{o(n,r)}catch(l){e.error(l)}})}function oVi(e,i,n){var r=e._renderer,o=r&&r.canvas(),l,c,u;return o&&(u=qz(e),c=i.changedTouches?i.changedTouches[0]:i,l=Dz(c,o),l[0]-=u[0],l[1]-=u[1]),i.dataflow=e,i.item=n,i.vega=aVi(e,n,l),i}function aVi(e,i,n){const r=i?i.mark.marktype==="group"?i:i.mark.group:null;function o(c){var u=r,f;if(c){for(f=i;f;f=f.mark.group)if(f.mark.name===c){u=f;break}}return u&&u.mark&&u.mark.interactive?u:{}}function l(c){if(!c)return n;fi(c)&&(c=o(c));const u=n.slice();for(;c;)u[0]-=c.x||0,u[1]-=c.y||0,c=c.mark&&c.mark.group;return u}return{view:Ws(e),item:Ws(i||{}),group:o,xy:l,x:c=>l(c)[0],y:c=>l(c)[1]}}const KFe="view",sVi="timer",IVi="window",lVi={trap:!1};function CVi(e){const i=Tn({defaults:{}},e),n=(r,o)=>{o.forEach(l=>{Pt(r[l])&&(r[l]=BA(r[l]))})};return n(i.defaults,["prevent","allow"]),n(i,["view","window","selector"]),i}function j$e(e,i,n,r){e._eventListeners.push({type:n,sources:pi(i),handler:r})}function cVi(e,i){var n=e._eventConfig.defaults,r=n.prevent,o=n.allow;return r===!1||o===!0?!1:r===!0||o===!1?!0:r?r[i]:o?!o[i]:e.preventDefault()}function _F(e,i,n){const r=e._eventConfig&&e._eventConfig[i];return r===!1||vi(r)&&!r[n]?(e.warn(`Blocked ${i} ${n} event listener.`),!1):!0}function AVi(e,i,n){var r=this,o=new sz(n),l=function(m,p){r.runAsync(null,()=>{e===KFe&&cVi(r,i)&&m.preventDefault(),o.receive(oVi(r,m,p))})},c;if(e===sVi)_F(r,"timer",i)&&r.timer(l,i);else if(e===KFe)_F(r,"view",i)&&r.addEventListener(i,l,lVi);else if(e===IVi?_F(r,"window",i)&&typeof window<"u"&&(c=[window]):typeof document<"u"&&_F(r,"selector",i)&&(c=Array.from(document.querySelectorAll(e))),!c)r.warn("Can not resolve event source: "+e);else{for(var u=0,f=c.length;u=0;)i[r].stop();for(r=n.length;--r>=0;)for(l=n[r],o=l.sources.length;--o>=0;)l.sources[o].removeEventListener(l.type,l.handler);return e&&e.call(this,this._handler,null,null,null),this}function _l(e,i,n){const r=document.createElement(e);for(const o in i)r.setAttribute(o,i[o]);return n!=null&&(r.textContent=n),r}const hVi="vega-bind",fVi="vega-bind-name",mVi="vega-bind-radio";function pVi(e,i,n){if(!i)return;const r=n.param;let o=n.state;return o||(o=n.state={elements:null,active:!1,set:null,update:c=>{c!=e.signal(r.signal)&&e.runAsync(null,()=>{o.source=!0,e.signal(r.signal,c)})}},r.debounce&&(o.update=Tle(r.debounce,o.update))),(r.input==null&&r.element?bVi:vVi)(o,i,r,e),o.active||(e.on(e._signals[r.signal],null,()=>{o.source?o.source=!1:o.set(e.signal(r.signal))}),o.active=!0),o}function bVi(e,i,n,r){const o=n.event||"input",l=()=>e.update(i.value);r.signal(n.signal,i.value),i.addEventListener(o,l),j$e(r,i,o,l),e.set=c=>{i.value=c,i.dispatchEvent(yVi(o))}}function yVi(e){return typeof Event<"u"?new Event(e):{type:e}}function vVi(e,i,n,r){const o=r.signal(n.signal),l=_l("div",{class:hVi}),c=n.input==="radio"?l:l.appendChild(_l("label"));c.appendChild(_l("span",{class:fVi},n.name||n.signal)),i.appendChild(l);let u=ZVi;switch(n.input){case"checkbox":u=BVi;break;case"select":u=GVi;break;case"radio":u=SVi;break;case"range":u=wVi;break}u(e,c,n,o)}function ZVi(e,i,n,r){const o=_l("input");for(const l in n)l!=="signal"&&l!=="element"&&o.setAttribute(l==="input"?"type":l,n[l]);o.setAttribute("name",n.signal),o.value=r,i.appendChild(o),o.addEventListener("input",()=>e.update(o.value)),e.elements=[o],e.set=l=>o.value=l}function BVi(e,i,n,r){const o={type:"checkbox",name:n.signal};r&&(o.checked=!0);const l=_l("input",o);i.appendChild(l),l.addEventListener("change",()=>e.update(l.checked)),e.elements=[l],e.set=c=>l.checked=!!c||null}function GVi(e,i,n,r){const o=_l("select",{name:n.signal}),l=n.labels||[];n.options.forEach((c,u)=>{const f={value:c};Z_(c,r)&&(f.selected=!0),o.appendChild(_l("option",f,(l[u]||c)+""))}),i.appendChild(o),o.addEventListener("change",()=>{e.update(n.options[o.selectedIndex])}),e.elements=[o],e.set=c=>{for(let u=0,f=n.options.length;u{const f={type:"radio",name:n.signal,value:c};Z_(c,r)&&(f.checked=!0);const m=_l("input",f);m.addEventListener("change",()=>e.update(c));const p=_l("label",{},(l[u]||c)+"");return p.prepend(m),o.appendChild(p),m}),e.set=c=>{const u=e.elements,f=u.length;for(let m=0;m{f.textContent=u.value,e.update(+u.value)};u.addEventListener("input",m),u.addEventListener("change",m),e.elements=[u],e.set=p=>{u.value=p,f.textContent=p}}function Z_(e,i){return e===i||e+""==i+""}function $$e(e,i,n,r,o,l){return i=i||new r(e.loader()),i.initialize(n,U$e(e),Q$e(e),qz(e),o,l).background(e.background())}function tue(e,i){return i?function(){try{i.apply(this,arguments)}catch(n){e.error(n)}}:null}function TVi(e,i,n,r){const o=new r(e.loader(),tue(e,e.tooltip())).scene(e.scenegraph().root).initialize(n,qz(e),e);return i&&i.handlers().forEach(l=>{o.on(l.type,l.handler)}),o}function RVi(e,i){const n=this,r=n._renderType,o=n._eventConfig.bind,l=Mz(r);e=n._el=e?Pte(n,e,!0):null,qRi(n),l||n.error("Unrecognized renderer type: "+r);const c=l.handler||qW,u=e?l.renderer:l.headless;return n._renderer=u?$$e(n,n._renderer,e,u):null,n._handler=TVi(n,n._handler,e,c),n._redraw=!0,e&&o!=="none"&&(i=i?n._elBind=Pte(n,i,!0):e.appendChild(_l("form",{class:"vega-bindings"})),n._bind.forEach(f=>{f.param.element&&o!=="container"&&(f.element=Pte(n,f.param.element,!!f.param.input))}),n._bind.forEach(f=>{pVi(n,f.element||i,f)})),n}function Pte(e,i,n){if(typeof i=="string")if(typeof document<"u"){if(i=document.querySelector(i),!i)return e.error("Signal bind element not found: "+i),null}else return e.error("DOM document instance not found."),null;if(i&&n)try{i.textContent=""}catch(r){i=null,e.error(r)}return i}const c9=e=>+e||0,VVi=e=>({top:e,bottom:e,left:e,right:e});function OFe(e){return vi(e)?{top:c9(e.top),bottom:c9(e.bottom),left:c9(e.left),right:c9(e.right)}:VVi(c9(e))}async function iue(e,i,n,r){const o=Mz(i),l=o&&o.headless;return l||Yt("Unrecognized renderer type: "+i),await e.runAsync(),$$e(e,null,null,l,n,r).renderAsync(e._scenegraph.root)}async function EVi(e,i){e!==sp.Canvas&&e!==sp.SVG&&e!==sp.PNG&&Yt("Unrecognized image type: "+e);const n=await iue(this,e,i);return e===sp.SVG?HVi(n.svg(),"image/svg+xml"):n.canvas().toDataURL("image/png")}function HVi(e,i){const n=new Blob([e],{type:i});return window.URL.createObjectURL(n)}async function WVi(e,i){return(await iue(this,sp.Canvas,e,i)).canvas()}async function NVi(e){return(await iue(this,sp.SVG,e)).svg()}function kVi(e,i,n){return O$e(e,OS,eW,n).parse(i)}function XVi(e){var i=this._runtime.scales;return Oi(i,e)||Yt("Unrecognized scale or projection: "+e),i[e].value}var q$e="width",eqe="height",nue="padding",LFe={skip:!0};function tqe(e,i){var n=e.autosize(),r=e.padding();return i-(n&&n.contains===nue?r.left+r.right:0)}function iqe(e,i){var n=e.autosize(),r=e.padding();return i-(n&&n.contains===nue?r.top+r.bottom:0)}function xVi(e){var i=e._signals,n=i[q$e],r=i[eqe],o=i[nue];function l(){e._autosize=e._resize=1}e._resizeWidth=e.add(null,u=>{e._width=u.size,e._viewWidth=tqe(e,u.size),l()},{size:n}),e._resizeHeight=e.add(null,u=>{e._height=u.size,e._viewHeight=iqe(e,u.size),l()},{size:r});const c=e.add(null,l,{pad:o});e._resizeWidth.rank=n.rank+1,e._resizeHeight.rank=r.rank+1,c.rank=o.rank+1}function DVi(e,i,n,r,o,l){this.runAfter(c=>{let u=0;c._autosize=0,c.width()!==n&&(u=1,c.signal(q$e,n,LFe),c._resizeWidth.skip(!0)),c.height()!==r&&(u=1,c.signal(eqe,r,LFe),c._resizeHeight.skip(!0)),c._viewWidth!==e&&(c._resize=1,c._viewWidth=e),c._viewHeight!==i&&(c._resize=1,c._viewHeight=i),(c._origin[0]!==o[0]||c._origin[1]!==o[1])&&(c._resize=1,c._origin=o),u&&c.run("enter"),l&&c.runAfter(f=>f.resize())},!1,1)}function MVi(e){return this._runtime.getState(e||{data:FVi,signals:YVi,recurse:!0})}function FVi(e,i){return i.modified&&Pt(i.input.value)&&e.indexOf("_:vega:_")}function YVi(e,i){return!(e==="parent"||i instanceof OS.proxy)}function KVi(e){return this.runAsync(null,i=>{i._trigger=!1,i._runtime.setState(e)},i=>{i._trigger=!0}),this}function _Vi(e,i){function n(r){e({timestamp:Date.now(),elapsed:r})}this._timers.push(iGi(n,i))}function PVi(e,i,n,r){const o=e.element();o&&o.setAttribute("title",zVi(r))}function zVi(e){return e==null?"":Pt(e)?nqe(e):vi(e)&&!Sp(e)?OVi(e):e+""}function OVi(e){return Object.keys(e).map(i=>{const n=e[i];return i+": "+(Pt(n)?nqe(n):rqe(n))}).join(` -`)}function nqe(e){return"["+e.map(rqe).join(", ")+"]"}function rqe(e){return Pt(e)?"[…]":vi(e)&&!Sp(e)?"{…}":e}function gqe(e,i){const n=this;if(i=i||{},sS.call(n),i.loader&&n.loader(i.loader),i.logger&&n.logger(i.logger),i.logLevel!=null&&n.logLevel(i.logLevel),i.locale||e.locale){const l=Tn({},e.locale,i.locale);n.locale(O7e(l.number,l.time))}n._el=null,n._elBind=null,n._renderType=i.renderer||sp.Canvas,n._scenegraph=new Wce;const r=n._scenegraph.root;n._renderer=null,n._tooltip=i.tooltip||PVi,n._redraw=!0,n._handler=new qW().scene(r),n._globalCursor=!1,n._preventDefault=!1,n._timers=[],n._eventListeners=[],n._resizeListeners=[],n._eventConfig=CVi(e.eventConfig),n.globalCursor(n._eventConfig.globalCursor);const o=kVi(n,e,i.expr);n._runtime=o,n._signals=o.signals,n._bind=(e.bindings||[]).map(l=>({state:null,param:Tn({},l)})),o.root&&o.root.set(r),r.source=o.data.root.input,n.pulse(o.data.root.input,n.changeset().insert(r.items)),n._width=n.width(),n._height=n.height(),n._viewWidth=tqe(n,n._width),n._viewHeight=iqe(n,n._height),n._origin=[0,0],n._resize=0,n._autosize=1,xVi(n),eVi(n),tVi(n),n.description(e.description),i.hover&&n.hover(),i.container&&n.initialize(i.container,i.bind)}function PF(e,i){return Oi(e._signals,i)?e._signals[i]:Yt("Unrecognized signal name: "+ai(i))}function oqe(e,i){const n=(e._targets||[]).filter(r=>r._update&&r._update.handler===i);return n.length?n[0]:null}function JFe(e,i,n,r){let o=oqe(n,r);return o||(o=tue(e,()=>r(i,n.value)),o.handler=r,e.on(n,null,o)),e}function UFe(e,i,n){const r=oqe(i,n);return r&&i._targets.remove(r),e}si(gqe,sS,{async evaluate(e,i,n){if(await sS.prototype.evaluate.call(this,e,i),this._redraw||this._resize)try{this._renderer&&(this._resize&&(this._resize=0,gVi(this)),await this._renderer.renderAsync(this._scenegraph.root)),this._redraw=!1}catch(r){this.error(r)}return n&&wY(this,n),this},dirty(e){this._redraw=!0,this._renderer&&this._renderer.dirty(e)},description(e){if(arguments.length){const i=e!=null?e+"":null;return i!==this._desc&&J$e(this._el,this._desc=i),this}return this._desc},container(){return this._el},scenegraph(){return this._scenegraph},origin(){return this._origin.slice()},signal(e,i,n){const r=PF(this,e);return arguments.length===1?r.value:this.update(r,i,n)},width(e){return arguments.length?this.signal("width",e):this.signal("width")},height(e){return arguments.length?this.signal("height",e):this.signal("height")},padding(e){return arguments.length?this.signal("padding",OFe(e)):OFe(this.signal("padding"))},autosize(e){return arguments.length?this.signal("autosize",e):this.signal("autosize")},background(e){return arguments.length?this.signal("background",e):this.signal("background")},renderer(e){return arguments.length?(Mz(e)||Yt("Unrecognized renderer type: "+e),e!==this._renderType&&(this._renderType=e,this._resetRenderer()),this):this._renderType},tooltip(e){return arguments.length?(e!==this._tooltip&&(this._tooltip=e,this._resetRenderer()),this):this._tooltip},loader(e){return arguments.length?(e!==this._loader&&(sS.prototype.loader.call(this,e),this._resetRenderer()),this):this._loader},resize(){return this._autosize=1,this.touch(PF(this,"autosize"))},_resetRenderer(){this._renderer&&(this._renderer=null,this.initialize(this._el,this._elBind))},_resizeView:DVi,addEventListener(e,i,n){let r=i;return n&&n.trap===!1||(r=tue(this,i),r.raw=i),this._handler.on(e,r),this},removeEventListener(e,i){for(var n=this._handler.handlers(e),r=n.length,o,l;--r>=0;)if(l=n[r].type,o=n[r].handler,e===l&&(i===o||i===o.raw)){this._handler.off(l,o);break}return this},addResizeListener(e){const i=this._resizeListeners;return i.indexOf(e)<0&&i.push(e),this},removeResizeListener(e){var i=this._resizeListeners,n=i.indexOf(e);return n>=0&&i.splice(n,1),this},addSignalListener(e,i){return JFe(this,e,PF(this,e),i)},removeSignalListener(e,i){return UFe(this,PF(this,e),i)},addDataListener(e,i){return JFe(this,e,v_(this,e).values,i)},removeDataListener(e,i){return UFe(this,v_(this,e).values,i)},globalCursor(e){if(arguments.length){if(this._globalCursor!==!!e){const i=zoe(this,null);this._globalCursor=!!e,i&&zoe(this,i)}return this}else return this._globalCursor},preventDefault(e){return arguments.length?(this._preventDefault=e,this):this._preventDefault},timer:_Vi,events:AVi,finalize:dVi,hover:uVi,data:iVi,change:$z,insert:nVi,remove:rVi,scale:XVi,initialize:RVi,toImageURL:EVi,toCanvas:WVi,toSVG:NVi,getState:MVi,setState:KVi});const LVi="view",B_="[",G_="]",aqe="{",sqe="}",JVi=":",Iqe=",",UVi="@",QVi=">",jVi=/[[\]{}]/,$Vi={"*":1,arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1};let lqe,Cqe;function A0(e,i,n){return lqe=i||LVi,Cqe=n||$Vi,cqe(e.trim()).map(Ooe)}function qVi(e){return Cqe[e]}function HE(e,i,n,r,o){const l=e.length;let c=0,u;for(;i=0?--c:r&&r.indexOf(u)>=0&&++c}return i}function cqe(e){const i=[],n=e.length;let r=0,o=0;for(;o' after between selector: "+e;r=r.map(Ooe);const o=Ooe(e.slice(1).trim());return o.between?{between:r,stream:o}:(o.between=r,o)}function t9i(e){const i={source:lqe},n=[];let r=[0,0],o=0,l=0,c=e.length,u=0,f,m;if(e[c-1]===sqe){if(u=e.lastIndexOf(aqe),u>=0){try{r=i9i(e.substring(u+1,c-1))}catch{throw"Invalid throttle specification: "+e}e=e.slice(0,u).trim(),c=e.length}else throw"Unmatched right brace: "+e;u=0}if(!c)throw e;if(e[0]===UVi&&(o=++u),f=HE(e,u,JVi),f1?(i.type=n[1],o?i.markname=n[0].slice(1):qVi(n[0])?i.marktype=n[0]:i.source=n[0]):i.type=n[0],i.type.slice(-1)==="!"&&(i.consume=!0,i.type=i.type.slice(0,-1)),m!=null&&(i.filter=m),r[0]&&(i.throttle=r[0]),r[1]&&(i.debounce=r[1]),i}function i9i(e){const i=e.split(Iqe);if(!e.length||i.length>2)throw e;return i.map(n=>{const r=+n;if(r!==r)throw e;return r})}function n9i(e){return vi(e)?e:{type:e||"pad"}}const A9=e=>+e||0,r9i=e=>({top:e,bottom:e,left:e,right:e});function g9i(e){return vi(e)?e.signal?e:{top:A9(e.top),bottom:A9(e.bottom),left:A9(e.left),right:A9(e.right)}:r9i(A9(e))}const ca=e=>vi(e)&&!Pt(e)?Tn({},e):{value:e};function QFe(e,i,n,r){return n!=null?(vi(n)&&!Pt(n)||Pt(n)&&n.length&&vi(n[0])?e.update[i]=n:e[r||"enter"][i]={value:n},1):0}function Fa(e,i,n){for(const r in i)QFe(e,r,i[r]);for(const r in n)QFe(e,r,n[r],"update")}function Jw(e,i,n){for(const r in i)n&&Oi(n,r)||(e[r]=Tn(e[r]||{},i[r]));return e}function RG(e,i){return i&&(i.enter&&i.enter[e]||i.update&&i.update[e])}const rue="mark",gue="frame",oue="scope",o9i="axis",a9i="axis-domain",s9i="axis-grid",I9i="axis-label",l9i="axis-tick",C9i="axis-title",c9i="legend",A9i="legend-band",u9i="legend-entry",d9i="legend-gradient",Aqe="legend-label",h9i="legend-symbol",f9i="legend-title",m9i="title",p9i="title-text",b9i="title-subtitle";function y9i(e,i,n,r,o){const l={},c={};let u,f,m,p;f="lineBreak",i==="text"&&o[f]!=null&&!RG(f,e)&&zte(l,f,o[f]),(n=="legend"||String(n).startsWith("axis"))&&(n=null),p=n===gue?o.group:n===rue?Tn({},o.mark,o[i]):null;for(f in p)m=RG(f,e)||(f==="fill"||f==="stroke")&&(RG("fill",e)||RG("stroke",e)),m||zte(l,f,p[f]);pi(r).forEach(v=>{const B=o.style&&o.style[v];for(const G in B)RG(G,e)||zte(l,G,B[G])}),e=Tn({},e);for(f in l)p=l[f],p.signal?(u=u||{})[f]=p:c[f]=p;return e.enter=Tn(c,e.enter),u&&(e.update=Tn(u,e.update)),e}function zte(e,i,n){e[i]=n&&n.signal?{signal:n.signal}:{value:n}}const uqe=e=>fi(e)?ai(e):e.signal?`(${e.signal})`:dqe(e);function eO(e){if(e.gradient!=null)return Z9i(e);let i=e.signal?`(${e.signal})`:e.color?v9i(e.color):e.field!=null?dqe(e.field):e.value!==void 0?ai(e.value):void 0;return e.scale!=null&&(i=B9i(e,i)),i===void 0&&(i=null),e.exponent!=null&&(i=`pow(${i},${PY(e.exponent)})`),e.mult!=null&&(i+=`*${PY(e.mult)}`),e.offset!=null&&(i+=`+${PY(e.offset)}`),e.round&&(i=`round(${i})`),i}const zF=(e,i,n,r)=>`(${e}(${[i,n,r].map(eO).join(",")})+'')`;function v9i(e){return e.c?zF("hcl",e.h,e.c,e.l):e.h||e.s?zF("hsl",e.h,e.s,e.l):e.l||e.a?zF("lab",e.l,e.a,e.b):e.r||e.g||e.b?zF("rgb",e.r,e.g,e.b):null}function Z9i(e){const i=[e.start,e.stop,e.count].map(n=>n==null?null:ai(n));for(;i.length&&sr(i)==null;)i.pop();return i.unshift(uqe(e.gradient)),`gradient(${i.join(",")})`}function PY(e){return vi(e)?"("+eO(e)+")":e}function dqe(e){return hqe(vi(e)?e:{datum:e})}function hqe(e){let i,n,r;if(e.signal)i="datum",r=e.signal;else if(e.group||e.parent){for(n=Math.max(1,e.level||1),i="item";n-- >0;)i+=".mark.group";e.parent?(r=e.parent,i+=".datum"):r=e.group}else e.datum?(i="datum",r=e.datum):Yt("Invalid field reference: "+ai(e));return e.signal||(r=fi(r)?vd(r).map(ai).join("]["):hqe(r)),i+"["+r+"]"}function B9i(e,i){const n=uqe(e.scale);return e.range!=null?i=`lerp(_range(${n}), ${+e.range})`:(i!==void 0&&(i=`_scale(${n}, ${i})`),e.band&&(i=(i?i+"+":"")+`_bandwidth(${n})`+(+e.band==1?"":"*"+PY(e.band)),e.extra&&(i=`(datum.extra ? _scale(${n}, datum.extra.value) : ${i})`)),i==null&&(i="0")),i}function G9i(e){let i="";return e.forEach(n=>{const r=eO(n);i+=n.test?`(${n.test})?${r}:`:r}),sr(i)===":"&&(i+="null"),i}function fqe(e,i,n,r,o,l){const c={};l=l||{},l.encoders={$encode:c},e=y9i(e,i,n,r,o.config);for(const u in e)c[u]=S9i(e[u],i,l,o);return l}function S9i(e,i,n,r){const o={},l={};for(const c in e)e[c]!=null&&(o[c]=T9i(w9i(e[c]),r,n,l));return{$expr:{marktype:i,channels:o},$fields:Object.keys(l),$output:Object.keys(e)}}function w9i(e){return Pt(e)?G9i(e):eO(e)}function T9i(e,i,n,r){const o=hd(e,i);return o.$fields.forEach(l=>r[l]=1),Tn(n,o.$params),o.$expr}const R9i="outer",V9i=["value","update","init","react","bind"];function jFe(e,i){Yt(e+' for "outer" push: '+ai(i))}function mqe(e,i){const n=e.name;if(e.push===R9i)i.signals[n]||jFe("No prior signal definition",n),V9i.forEach(r=>{e[r]!==void 0&&jFe("Invalid property ",r)});else{const r=i.addSignal(n,e.value);e.react===!1&&(r.react=!1),e.bind&&i.addBinding(n,e.bind)}}function Loe(e,i,n,r){this.id=-1,this.type=e,this.value=i,this.params=n,r&&(this.parent=r)}function tO(e,i,n,r){return new Loe(e,i,n,r)}function S_(e,i){return tO("operator",e,i)}function _i(e){const i={$ref:e.id};return e.id<0&&(e.refs=e.refs||[]).push(i),i}function tW(e,i){return i?{$field:e,$name:i}:{$field:e}}const Joe=tW("key");function $Fe(e,i){return{$compare:e,$order:i}}function E9i(e,i){const n={$key:e};return i&&(n.$flat=!0),n}const H9i="ascending",W9i="descending";function N9i(e){return vi(e)?(e.order===W9i?"-":"+")+iO(e.op,e.field):""}function iO(e,i){return(e&&e.signal?"$"+e.signal:e||"")+(e&&i?"_":"")+(i&&i.signal?"$"+i.signal:i||"")}const aue="scope",Uoe="view";function Uo(e){return e&&e.signal}function k9i(e){return e&&e.expr}function zY(e){if(Uo(e))return!0;if(vi(e)){for(const i in e)if(zY(e[i]))return!0}return!1}function jc(e,i){return e??i}function Qy(e){return e&&e.signal||e}const qFe="timer";function iW(e,i){return(e.merge?x9i:e.stream?D9i:e.type?M9i:Yt("Invalid stream specification: "+ai(e)))(e,i)}function X9i(e){return e===aue?Uoe:e||Uoe}function x9i(e,i){const n=e.merge.map(o=>iW(o,i)),r=sue({merge:n},e,i);return i.addStream(r).id}function D9i(e,i){const n=iW(e.stream,i),r=sue({stream:n},e,i);return i.addStream(r).id}function M9i(e,i){let n;e.type===qFe?(n=i.event(qFe,e.throttle),e={between:e.between,filter:e.filter}):n=i.event(X9i(e.source),e.type);const r=sue({stream:n},e,i);return Object.keys(r).length===1?n:i.addStream(r).id}function sue(e,i,n){let r=i.between;return r&&(r.length!==2&&Yt('Stream "between" parameter must have 2 entries: '+ai(i)),e.between=[iW(r[0],n),iW(r[1],n)]),r=i.filter?[].concat(i.filter):[],(i.marktype||i.markname||i.markrole)&&r.push(F9i(i.marktype,i.markname,i.markrole)),i.source===aue&&r.push("inScope(event.item)"),r.length&&(e.filter=hd("("+r.join(")&&(")+")",n).$expr),(r=i.throttle)!=null&&(e.throttle=+r),(r=i.debounce)!=null&&(e.debounce=+r),i.consume&&(e.consume=!0),e}function F9i(e,i,n){const r="event.item";return r+(e&&e!=="*"?"&&"+r+".mark.marktype==='"+e+"'":"")+(n?"&&"+r+".mark.role==='"+n+"'":"")+(i?"&&"+r+".mark.name==='"+i+"'":"")}const Y9i={code:"_.$value",ast:{type:"Identifier",value:"value"}};function K9i(e,i,n){const r=e.encode,o={target:n};let l=e.events,c=e.update,u=[];l||Yt("Signal update missing events specification."),fi(l)&&(l=A0(l,i.isSubscope()?aue:Uoe)),l=pi(l).filter(f=>f.signal||f.scale?(u.push(f),0):1),u.length>1&&(u=[P9i(u)]),l.length&&u.push(l.length>1?{merge:l}:l[0]),r!=null&&(c&&Yt("Signal encode and update are mutually exclusive."),c="encode(item(),"+ai(r)+")"),o.update=fi(c)?hd(c,i):c.expr!=null?hd(c.expr,i):c.value!=null?c.value:c.signal!=null?{$expr:Y9i,$params:{$value:i.signalRef(c.signal)}}:Yt("Invalid signal update specification."),e.force&&(o.options={force:!0}),u.forEach(f=>i.addUpdate(Tn(_9i(f,i),o)))}function _9i(e,i){return{source:e.signal?i.signalRef(e.signal):e.scale?i.scaleRef(e.scale):iW(e,i)}}function P9i(e){return{signal:"["+e.map(i=>i.scale?'scale("'+i.scale+'")':i.signal)+"]"}}function z9i(e,i){const n=i.getSignal(e.name);let r=e.update;e.init&&(r?Yt("Signals can not include both init and update expressions."):(r=e.init,n.initonly=!0)),r&&(r=hd(r,i),n.update=r.$expr,n.params=r.$params),e.on&&e.on.forEach(o=>K9i(o,i,n.id))}const $r=e=>(i,n,r)=>tO(e,n,i||void 0,r),pqe=$r("aggregate"),O9i=$r("axisticks"),bqe=$r("bound"),VA=$r("collect"),eYe=$r("compare"),L9i=$r("datajoin"),yqe=$r("encode"),J9i=$r("expression"),U9i=$r("facet"),Q9i=$r("field"),j9i=$r("key"),$9i=$r("legendentries"),q9i=$r("load"),eEi=$r("mark"),tEi=$r("multiextent"),iEi=$r("multivalues"),nEi=$r("overlap"),rEi=$r("params"),vqe=$r("prefacet"),gEi=$r("projection"),oEi=$r("proxy"),aEi=$r("relay"),Zqe=$r("render"),sEi=$r("scale"),aZ=$r("sieve"),IEi=$r("sortitems"),Bqe=$r("viewlayout"),lEi=$r("values");let CEi=0;const Gqe={min:"min",max:"max",count:"sum"};function cEi(e,i){const n=e.type||"linear";gje(n)||Yt("Unrecognized scale type: "+ai(n)),i.addScale(e.name,{type:n,domain:void 0})}function AEi(e,i){const n=i.getScale(e.name).params;let r;n.domain=Sqe(e.domain,e,i),e.range!=null&&(n.range=Tqe(e,i,n)),e.interpolate!=null&&ZEi(e.interpolate,n),e.nice!=null&&(n.nice=vEi(e.nice)),e.bins!=null&&(n.bins=yEi(e.bins,i));for(r in e)Oi(n,r)||r==="name"||(n[r]=XC(e[r],i))}function XC(e,i){return vi(e)?e.signal?i.signalRef(e.signal):Yt("Unsupported object: "+ai(e)):e}function OY(e,i){return e.signal?i.signalRef(e.signal):e.map(n=>XC(n,i))}function nO(e){Yt("Can not find data set: "+ai(e))}function Sqe(e,i,n){if(!e){(i.domainMin!=null||i.domainMax!=null)&&Yt("No scale domain defined for domainMin/domainMax to override.");return}return e.signal?n.signalRef(e.signal):(Pt(e)?uEi:e.fields?hEi:dEi)(e,i,n)}function uEi(e,i,n){return e.map(r=>XC(r,n))}function dEi(e,i,n){const r=n.getData(e.data);return r||nO(e.data),$S(i.type)?r.valuesRef(n,e.field,wqe(e.sort,!1)):sje(i.type)?r.domainRef(n,e.field):r.extentRef(n,e.field)}function hEi(e,i,n){const r=e.data,o=e.fields.reduce((l,c)=>(c=fi(c)?{data:r,field:c}:Pt(c)||c.signal?fEi(c,n):c,l.push(c),l),[]);return($S(i.type)?mEi:sje(i.type)?pEi:bEi)(e,n,o)}function fEi(e,i){const n="_:vega:_"+CEi++,r=VA({});if(Pt(e))r.value={$ingest:e};else if(e.signal){const o="setdata("+ai(n)+","+e.signal+")";r.params.input=i.signalRef(o)}return i.addDataPipeline(n,[r,aZ({})]),{data:n,field:"data"}}function mEi(e,i,n){const r=wqe(e.sort,!0);let o,l;const c=n.map(m=>{const p=i.getData(m.data);return p||nO(m.data),p.countsRef(i,m.field,r)}),u={groupby:Joe,pulse:c};r&&(o=r.op||"count",l=r.field?iO(o,r.field):"count",u.ops=[Gqe[o]],u.fields=[i.fieldRef(l)],u.as=[l]),o=i.add(pqe(u));const f=i.add(VA({pulse:_i(o)}));return l=i.add(lEi({field:Joe,sort:i.sortRef(r),pulse:_i(f)})),_i(l)}function wqe(e,i){return e&&(!e.field&&!e.op?vi(e)?e.field="key":e={field:"key"}:!e.field&&e.op!=="count"?Yt("No field provided for sort aggregate op: "+e.op):i&&e.field&&e.op&&!Gqe[e.op]&&Yt("Multiple domain scales can not be sorted using "+e.op)),e}function pEi(e,i,n){const r=n.map(o=>{const l=i.getData(o.data);return l||nO(o.data),l.domainRef(i,o.field)});return _i(i.add(iEi({values:r})))}function bEi(e,i,n){const r=n.map(o=>{const l=i.getData(o.data);return l||nO(o.data),l.extentRef(i,o.field)});return _i(i.add(tEi({extents:r})))}function yEi(e,i){return e.signal||Pt(e)?OY(e,i):i.objectProperty(e)}function vEi(e){return vi(e)?{interval:XC(e.interval),step:XC(e.step)}:XC(e)}function ZEi(e,i){i.interpolate=XC(e.type||e),e.gamma!=null&&(i.interpolateGamma=XC(e.gamma))}function Tqe(e,i,n){const r=i.config.range;let o=e.range;if(o.signal)return i.signalRef(o.signal);if(fi(o)){if(r&&Oi(r,o))return e=Tn({},e,{range:r[o]}),Tqe(e,i,n);o==="width"?o=[0,{signal:"width"}]:o==="height"?o=$S(e.type)?[0,{signal:"height"}]:[{signal:"height"},0]:Yt("Unrecognized scale range value: "+ai(o))}else if(o.scheme){n.scheme=Pt(o.scheme)?OY(o.scheme,i):XC(o.scheme,i),o.extent&&(n.schemeExtent=OY(o.extent,i)),o.count&&(n.schemeCount=XC(o.count,i));return}else if(o.step){n.rangeStep=XC(o.step,i);return}else{if($S(e.type)&&!Pt(o))return Sqe(o,e,i);Pt(o)||Yt("Unsupported range type: "+ai(o))}return o.map(l=>(Pt(l)?OY:XC)(l,i))}function BEi(e,i){const n=i.config.projection||{},r={};for(const o in e)o!=="name"&&(r[o]=Qoe(e[o],o,i));for(const o in n)r[o]==null&&(r[o]=Qoe(n[o],o,i));i.addProjection(e.name,r)}function Qoe(e,i,n){return Pt(e)?e.map(r=>Qoe(r,i,n)):vi(e)?e.signal?n.signalRef(e.signal):i==="fit"?e:Yt("Unsupported parameter object: "+ai(e)):e}const EA="top",Uw="left",Qw="right",Lp="bottom",Rqe="center",GEi="vertical",SEi="start",wEi="middle",TEi="end",joe="index",Iue="label",REi="offset",sw="perc",VEi="perc2",YC="value",lN="guide-label",lue="guide-title",EEi="group-title",HEi="group-subtitle",tYe="symbol",LY="gradient",$oe="discrete",qoe="size",WEi="shape",NEi="fill",kEi="stroke",XEi="strokeWidth",xEi="strokeDash",DEi="opacity",Cue=[qoe,WEi,NEi,kEi,XEi,xEi,DEi],CN={name:1,style:1,interactive:1},Cr={value:0},KC={value:1},rO="group",Vqe="rect",cue="rule",MEi="symbol",sZ="text";function nW(e){return e.type=rO,e.interactive=e.interactive||!1,e}function hl(e,i){const n=(r,o)=>jc(e[r],jc(i[r],o));return n.isVertical=r=>GEi===jc(e.direction,i.direction||(r?i.symbolDirection:i.gradientDirection)),n.gradientLength=()=>jc(e.gradientLength,i.gradientLength||i.gradientWidth),n.gradientThickness=()=>jc(e.gradientThickness,i.gradientThickness||i.gradientHeight),n.entryColumns=()=>jc(e.columns,jc(i.columns,+n.isVertical(!0))),n}function Eqe(e,i){const n=i&&(i.update&&i.update[e]||i.enter&&i.enter[e]);return n&&n.signal?n:n?n.value:null}function FEi(e,i,n){const r=i.config.style[n];return r&&r[e]}function gO(e,i,n){return`item.anchor === '${SEi}' ? ${e} : item.anchor === '${TEi}' ? ${i} : ${n}`}const Aue=gO(ai(Uw),ai(Qw),ai(Rqe));function YEi(e){const i=e("tickBand");let n=e("tickOffset"),r,o;return i?i.signal?(r={signal:`(${i.signal}) === 'extent' ? 1 : 0.5`},o={signal:`(${i.signal}) === 'extent'`},vi(n)||(n={signal:`(${i.signal}) === 'extent' ? 0 : ${n}`})):i==="extent"?(r=1,o=!0,n=0):(r=.5,o=!1):(r=e("bandPosition"),o=e("tickExtra")),{extra:o,band:r,offset:n}}function Hqe(e,i){return i?e?vi(e)?Object.assign({},e,{offset:Hqe(e.offset,i)}):{value:e,offset:i}:i:e}function Jl(e,i){return i?(e.name=i.name,e.style=i.style||e.style,e.interactive=!!i.interactive,e.encode=Jw(e.encode,i,CN)):e.interactive=!1,e}function KEi(e,i,n,r){const o=hl(e,n),l=o.isVertical(),c=o.gradientThickness(),u=o.gradientLength();let f,m,p,v,B;l?(m=[0,1],p=[0,0],v=c,B=u):(m=[0,0],p=[1,0],v=u,B=c);const G={enter:f={opacity:Cr,x:Cr,y:Cr,width:ca(v),height:ca(B)},update:Tn({},f,{opacity:KC,fill:{gradient:i,start:m,stop:p}}),exit:{opacity:Cr}};return Fa(G,{stroke:o("gradientStrokeColor"),strokeWidth:o("gradientStrokeWidth")},{opacity:o("gradientOpacity")}),Jl({type:Vqe,role:d9i,encode:G},r)}function _Ei(e,i,n,r,o){const l=hl(e,n),c=l.isVertical(),u=l.gradientThickness(),f=l.gradientLength();let m,p,v,B,G="";c?(m="y",v="y2",p="x",B="width",G="1-"):(m="x",v="x2",p="y",B="height");const T={opacity:Cr,fill:{scale:i,field:YC}};T[m]={signal:G+"datum."+sw,mult:f},T[p]=Cr,T[v]={signal:G+"datum."+VEi,mult:f},T[B]=ca(u);const V={enter:T,update:Tn({},T,{opacity:KC}),exit:{opacity:Cr}};return Fa(V,{stroke:l("gradientStrokeColor"),strokeWidth:l("gradientStrokeWidth")},{opacity:l("gradientOpacity")}),Jl({type:Vqe,role:A9i,key:YC,from:o,encode:V},r)}const PEi=`datum.${sw}<=0?"${Uw}":datum.${sw}>=1?"${Qw}":"${Rqe}"`,zEi=`datum.${sw}<=0?"${Lp}":datum.${sw}>=1?"${EA}":"${wEi}"`;function iYe(e,i,n,r){const o=hl(e,i),l=o.isVertical(),c=ca(o.gradientThickness()),u=o.gradientLength();let f=o("labelOverlap"),m,p,v,B,G="";const T={enter:m={opacity:Cr},update:p={opacity:KC,text:{field:Iue}},exit:{opacity:Cr}};return Fa(T,{fill:o("labelColor"),fillOpacity:o("labelOpacity"),font:o("labelFont"),fontSize:o("labelFontSize"),fontStyle:o("labelFontStyle"),fontWeight:o("labelFontWeight"),limit:jc(e.labelLimit,i.gradientLabelLimit)}),l?(m.align={value:"left"},m.baseline=p.baseline={signal:zEi},v="y",B="x",G="1-"):(m.align=p.align={signal:PEi},m.baseline={value:"top"},v="x",B="y"),m[v]=p[v]={signal:G+"datum."+sw,mult:u},m[B]=p[B]=c,c.offset=jc(e.labelOffset,i.gradientLabelOffset)||0,f=f?{separation:o("labelSeparation"),method:f,order:"datum."+joe}:void 0,Jl({type:sZ,role:Aqe,style:lN,key:YC,from:r,encode:T,overlap:f},n)}function OEi(e,i,n,r,o){const l=hl(e,i),c=n.entries,u=!!(c&&c.interactive),f=c?c.name:void 0,m=l("clipHeight"),p=l("symbolOffset"),v={data:"value"},B=`(${o}) ? datum.${REi} : datum.${qoe}`,G=m?ca(m):{field:qoe},T=`datum.${joe}`,V=`max(1, ${o})`;let E,W,x,k,F;G.mult=.5,E={enter:W={opacity:Cr,x:{signal:B,mult:.5,offset:p},y:G},update:x={opacity:KC,x:W.x,y:W.y},exit:{opacity:Cr}};let Y=null,L=null;e.fill||(Y=i.symbolBaseFillColor,L=i.symbolBaseStrokeColor),Fa(E,{fill:l("symbolFillColor",Y),shape:l("symbolType"),size:l("symbolSize"),stroke:l("symbolStrokeColor",L),strokeDash:l("symbolDash"),strokeDashOffset:l("symbolDashOffset"),strokeWidth:l("symbolStrokeWidth")},{opacity:l("symbolOpacity")}),Cue.forEach($=>{e[$]&&(x[$]=W[$]={scale:e[$],field:YC})});const O=Jl({type:MEi,role:h9i,key:YC,from:v,clip:m?!0:void 0,encode:E},n.symbols),Q=ca(p);Q.offset=l("labelOffset"),E={enter:W={opacity:Cr,x:{signal:B,offset:Q},y:G},update:x={opacity:KC,text:{field:Iue},x:W.x,y:W.y},exit:{opacity:Cr}},Fa(E,{align:l("labelAlign"),baseline:l("labelBaseline"),fill:l("labelColor"),fillOpacity:l("labelOpacity"),font:l("labelFont"),fontSize:l("labelFontSize"),fontStyle:l("labelFontStyle"),fontWeight:l("labelFontWeight"),limit:l("labelLimit")});const X=Jl({type:sZ,role:Aqe,style:lN,key:YC,from:v,encode:E},n.labels);return E={enter:{noBound:{value:!m},width:Cr,height:m?ca(m):Cr,opacity:Cr},exit:{opacity:Cr},update:x={opacity:KC,row:{signal:null},column:{signal:null}}},l.isVertical(!0)?(k=`ceil(item.mark.items.length / ${V})`,x.row.signal=`${T}%${k}`,x.column.signal=`floor(${T} / ${k})`,F={field:["row",T]}):(x.row.signal=`floor(${T} / ${V})`,x.column.signal=`${T} % ${V}`,F={field:T}),x.column.signal=`(${o})?${x.column.signal}:${T}`,r={facet:{data:r,name:"value",groupby:joe}},nW({role:oue,from:r,encode:Jw(E,c,CN),marks:[O,X],name:f,interactive:u,sort:F})}function LEi(e,i){const n=hl(e,i);return{align:n("gridAlign"),columns:n.entryColumns(),center:{row:!0,column:!1},padding:{row:n("rowPadding"),column:n("columnPadding")}}}const uue='item.orient === "left"',due='item.orient === "right"',oO=`(${uue} || ${due})`,JEi=`datum.vgrad && ${oO}`,UEi=gO('"top"','"bottom"','"middle"'),QEi=gO('"right"','"left"','"center"'),jEi=`datum.vgrad && ${due} ? (${QEi}) : (${oO} && !(datum.vgrad && ${uue})) ? "left" : ${Aue}`,$Ei=`item._anchor || (${oO} ? "middle" : "start")`,qEi=`${JEi} ? (${uue} ? -90 : 90) : 0`,eHi=`${oO} ? (datum.vgrad ? (${due} ? "bottom" : "top") : ${UEi}) : "top"`;function tHi(e,i,n,r){const o=hl(e,i),l={enter:{opacity:Cr},update:{opacity:KC,x:{field:{group:"padding"}},y:{field:{group:"padding"}}},exit:{opacity:Cr}};return Fa(l,{orient:o("titleOrient"),_anchor:o("titleAnchor"),anchor:{signal:$Ei},angle:{signal:qEi},align:{signal:jEi},baseline:{signal:eHi},text:e.title,fill:o("titleColor"),fillOpacity:o("titleOpacity"),font:o("titleFont"),fontSize:o("titleFontSize"),fontStyle:o("titleFontStyle"),fontWeight:o("titleFontWeight"),limit:o("titleLimit"),lineHeight:o("titleLineHeight")},{align:o("titleAlign"),baseline:o("titleBaseline")}),Jl({type:sZ,role:f9i,style:lue,from:r,encode:l},n)}function iHi(e,i){let n;return vi(e)&&(e.signal?n=e.signal:e.path?n="pathShape("+nYe(e.path)+")":e.sphere&&(n="geoShape("+nYe(e.sphere)+', {type: "Sphere"})')),n?i.signalRef(n):!!e}function nYe(e){return vi(e)&&e.signal?e.signal:ai(e)}function Wqe(e){const i=e.role||"";return!i.indexOf("axis")||!i.indexOf("legend")||!i.indexOf("title")?i:e.type===rO?oue:i||rue}function nHi(e){return{marktype:e.type,name:e.name||void 0,role:e.role||Wqe(e),zindex:+e.zindex||void 0,aria:e.aria,description:e.description}}function rHi(e,i){return e&&e.signal?i.signalRef(e.signal):e!==!1}function hue(e,i){const n=g4e(e.type);n||Yt("Unrecognized transform type: "+ai(e.type));const r=tO(n.type.toLowerCase(),null,Nqe(n,e,i));return e.signal&&i.addSignal(e.signal,i.proxy(r)),r.metadata=n.metadata||{},r}function Nqe(e,i,n){const r={},o=e.params.length;for(let l=0;lrYe(e,l,n)):rYe(e,o,n)}function rYe(e,i,n){const r=e.type;if(Uo(i))return oYe(r)?Yt("Expression references can not be signals."):Ote(r)?n.fieldRef(i):aYe(r)?n.compareRef(i):n.signalRef(i.signal);{const o=e.expr||Ote(r);return o&&sHi(i)?n.exprRef(i.expr,i.as):o&&IHi(i)?tW(i.field,i.as):oYe(r)?hd(i,n):lHi(r)?_i(n.getData(i).values):Ote(r)?tW(i):aYe(r)?n.compareRef(i):i}}function oHi(e,i,n){return fi(i.from)||Yt('Lookup "from" parameter must be a string literal.'),n.getData(i.from).lookupRef(n,i.key)}function aHi(e,i,n){const r=i[e.name];return e.array?(Pt(r)||Yt("Expected an array of sub-parameters. Instead: "+ai(r)),r.map(o=>gYe(e,o,n))):gYe(e,r,n)}function gYe(e,i,n){const r=e.params.length;let o;for(let c=0;ce&&e.expr,IHi=e=>e&&e.field,lHi=e=>e==="data",oYe=e=>e==="expr",Ote=e=>e==="field",aYe=e=>e==="compare";function CHi(e,i,n){let r,o,l,c,u;return e?(r=e.facet)&&(i||Yt("Only group marks can be faceted."),r.field!=null?c=u=JY(r,n):(e.data?u=_i(n.getData(e.data).aggregate):(l=hue(Tn({type:"aggregate",groupby:pi(r.groupby)},r.aggregate),n),l.params.key=n.keyRef(r.groupby),l.params.pulse=JY(r,n),c=u=_i(n.add(l))),o=n.keyRef(r.groupby,!0))):c=_i(n.add(VA(null,[{}]))),c||(c=JY(e,n)),{key:o,pulse:c,parent:u}}function JY(e,i){return e.$ref?e:e.data&&e.data.$ref?e.data:_i(i.getData(e.data).output)}function Ev(e,i,n,r,o){this.scope=e,this.input=i,this.output=n,this.values=r,this.aggregate=o,this.index={}}Ev.fromEntries=function(e,i){const n=i.length,r=i[n-1],o=i[n-2];let l=i[0],c=null,u=1;for(l&&l.type==="load"&&(l=i[1]),e.add(i[0]);uv??"null").join(",")+"),0)",p=hd(m,i);f.update=p.$expr,f.params=p.$params}function aO(e,i){const n=Wqe(e),r=e.type===rO,o=e.from&&e.from.facet,l=e.overlap;let c=e.layout||n===oue||n===gue,u,f,m,p,v,B,G;const T=n===rue||c||o,V=CHi(e.from,r,i);f=i.add(L9i({key:V.key||(e.key?tW(e.key):void 0),pulse:V.pulse,clean:!r}));const E=_i(f);f=m=i.add(VA({pulse:E})),f=i.add(eEi({markdef:nHi(e),interactive:rHi(e.interactive,i),clip:iHi(e.clip,i),context:{$context:!0},groups:i.lookup(),parent:i.signals.parent?i.signalRef("parent"):null,index:i.markpath(),pulse:_i(f)}));const W=_i(f);f=p=i.add(yqe(fqe(e.encode,e.type,n,e.style,i,{mod:!1,pulse:W}))),f.params.parent=i.encode(),e.transform&&e.transform.forEach(L=>{const O=hue(L,i),Q=O.metadata;(Q.generates||Q.changes)&&Yt("Mark transforms should not generate new data."),Q.nomod||(p.params.mod=!0),O.params.pulse=_i(f),i.add(f=O)}),e.sort&&(f=i.add(IEi({sort:i.compareRef(e.sort),pulse:_i(f)})));const x=_i(f);(o||c)&&(c=i.add(Bqe({layout:i.objectProperty(e.layout),legends:i.legends,mark:W,pulse:x})),B=_i(c));const k=i.add(bqe({mark:W,pulse:B||x}));G=_i(k),r&&(T&&(u=i.operators,u.pop(),c&&u.pop()),i.pushState(x,B||G,E),o?cHi(e,i,V):T?AHi(e,i,V):i.parse(e),i.popState(),T&&(c&&u.push(c),u.push(k))),l&&(G=uHi(l,G,i));const F=i.add(Zqe({pulse:G})),Y=i.add(aZ({pulse:_i(F)},void 0,i.parent()));e.name!=null&&(v=e.name,i.addData(v,new Ev(i,m,F,Y)),e.on&&e.on.forEach(L=>{(L.insert||L.remove||L.toggle)&&Yt("Marks only support modify triggers."),Xqe(L,i,v)}))}function uHi(e,i,n){const r=e.method,o=e.bound,l=e.separation,c={separation:Uo(l)?n.signalRef(l.signal):l,method:Uo(r)?n.signalRef(r.signal):r,pulse:i};if(e.order&&(c.sort=n.compareRef({field:e.order})),o){const u=o.tolerance;c.boundTolerance=Uo(u)?n.signalRef(u.signal):+u,c.boundScale=n.scaleRef(o.scale),c.boundOrient=o.orient}return _i(n.add(nEi(c)))}function dHi(e,i){const n=i.config.legend,r=e.encode||{},o=hl(e,n),l=r.legend||{},c=l.name||void 0,u=l.interactive,f=l.style,m={};let p=0,v,B,G;Cue.forEach(k=>e[k]?(m[k]=e[k],p=p||e[k]):0),p||Yt("Missing valid scale for legend.");const T=hHi(e,i.scaleType(p)),V={title:e.title!=null,scales:m,type:T,vgrad:T!=="symbol"&&o.isVertical()},E=_i(i.add(VA(null,[V]))),W={enter:{x:{value:0},y:{value:0}}},x=_i(i.add($9i(B={type:T,scale:i.scaleRef(p),count:i.objectProperty(o("tickCount")),limit:i.property(o("symbolLimit")),values:i.objectProperty(e.values),minstep:i.property(e.tickMinStep),formatType:i.property(e.formatType),formatSpecifier:i.property(e.format)})));return T===LY?(G=[KEi(e,p,n,r.gradient),iYe(e,n,r.labels,x)],B.count=B.count||i.signalRef(`max(2,2*floor((${Qy(o.gradientLength())})/100))`)):T===$oe?G=[_Ei(e,p,n,r.gradient,x),iYe(e,n,r.labels,x)]:(v=LEi(e,n),G=[OEi(e,n,r,x,Qy(v.columns))],B.size=pHi(e,i,G[0].marks)),G=[nW({role:u9i,from:E,encode:W,marks:G,layout:v,interactive:u})],V.title&&G.push(tHi(e,n,r.title,E)),aO(nW({role:c9i,from:E,encode:Jw(mHi(o,e,n),l,CN),marks:G,aria:o("aria"),description:o("description"),zindex:o("zindex"),name:c,interactive:u,style:f}),i)}function hHi(e,i){let n=e.type||tYe;return!e.type&&fHi(e)===1&&(e.fill||e.stroke)&&(n=sce(i)?LY:_ge(i)?$oe:tYe),n!==LY?n:_ge(i)?$oe:LY}function fHi(e){return Cue.reduce((i,n)=>i+(e[n]?1:0),0)}function mHi(e,i,n){const r={enter:{},update:{}};return Fa(r,{orient:e("orient"),offset:e("offset"),padding:e("padding"),titlePadding:e("titlePadding"),cornerRadius:e("cornerRadius"),fill:e("fillColor"),stroke:e("strokeColor"),strokeWidth:n.strokeWidth,strokeDash:n.strokeDash,x:e("legendX"),y:e("legendY"),format:i.format,formatType:i.formatType}),r}function pHi(e,i,n){const r=Qy(IYe("size",e,n)),o=Qy(IYe("strokeWidth",e,n)),l=Qy(bHi(n[1].encode,i,lN));return hd(`max(ceil(sqrt(${r})+${o}),${l})`,i)}function IYe(e,i,n){return i[e]?`scale("${i[e]}",datum)`:Eqe(e,n[0].encode)}function bHi(e,i,n){return Eqe("fontSize",e)||FEi("fontSize",i,n)}const yHi=`item.orient==="${Uw}"?-90:item.orient==="${Qw}"?90:0`;function vHi(e,i){e=fi(e)?{text:e}:e;const n=hl(e,i.config.title),r=e.encode||{},o=r.group||{},l=o.name||void 0,c=o.interactive,u=o.style,f=[],m={},p=_i(i.add(VA(null,[m])));return f.push(GHi(e,n,ZHi(e),p)),e.subtitle&&f.push(SHi(e,n,r.subtitle,p)),aO(nW({role:m9i,from:p,encode:BHi(n,o),marks:f,aria:n("aria"),description:n("description"),zindex:n("zindex"),name:l,interactive:c,style:u}),i)}function ZHi(e){const i=e.encode;return i&&i.title||Tn({name:e.name,interactive:e.interactive,style:e.style},i)}function BHi(e,i){const n={enter:{},update:{}};return Fa(n,{orient:e("orient"),anchor:e("anchor"),align:{signal:Aue},angle:{signal:yHi},limit:e("limit"),frame:e("frame"),offset:e("offset")||0,padding:e("subtitlePadding")}),Jw(n,i,CN)}function GHi(e,i,n,r){const o={value:0},l=e.text,c={enter:{opacity:o},update:{opacity:{value:1}},exit:{opacity:o}};return Fa(c,{text:l,align:{signal:"item.mark.group.align"},angle:{signal:"item.mark.group.angle"},limit:{signal:"item.mark.group.limit"},baseline:"top",dx:i("dx"),dy:i("dy"),fill:i("color"),font:i("font"),fontSize:i("fontSize"),fontStyle:i("fontStyle"),fontWeight:i("fontWeight"),lineHeight:i("lineHeight")},{align:i("align"),angle:i("angle"),baseline:i("baseline")}),Jl({type:sZ,role:p9i,style:EEi,from:r,encode:c},n)}function SHi(e,i,n,r){const o={value:0},l=e.subtitle,c={enter:{opacity:o},update:{opacity:{value:1}},exit:{opacity:o}};return Fa(c,{text:l,align:{signal:"item.mark.group.align"},angle:{signal:"item.mark.group.angle"},limit:{signal:"item.mark.group.limit"},baseline:"top",dx:i("dx"),dy:i("dy"),fill:i("subtitleColor"),font:i("subtitleFont"),fontSize:i("subtitleFontSize"),fontStyle:i("subtitleFontStyle"),fontWeight:i("subtitleFontWeight"),lineHeight:i("subtitleLineHeight")},{align:i("align"),angle:i("angle"),baseline:i("baseline")}),Jl({type:sZ,role:b9i,style:HEi,from:r,encode:c},n)}function wHi(e,i){const n=[];e.transform&&e.transform.forEach(r=>{n.push(hue(r,i))}),e.on&&e.on.forEach(r=>{Xqe(r,i,e.name)}),i.addDataPipeline(e.name,THi(e,i,n))}function THi(e,i,n){const r=[];let o=null,l=!1,c=!1,u,f,m,p,v;for(e.values?Uo(e.values)||zY(e.format)?(r.push(lYe(i,e)),r.push(o=jb())):r.push(o=jb({$ingest:e.values,$format:e.format})):e.url?zY(e.url)||zY(e.format)?(r.push(lYe(i,e)),r.push(o=jb())):r.push(o=jb({$request:e.url,$format:e.format})):e.source&&(o=u=pi(e.source).map(B=>_i(i.getData(B).output)),r.push(null)),f=0,m=n.length;fe===Lp||e===EA,sO=(e,i,n)=>Uo(e)?HHi(e.signal,i,n):e===Uw||e===EA?i:n,Aa=(e,i,n)=>Uo(e)?VHi(e.signal,i,n):xqe(e)?i:n,mA=(e,i,n)=>Uo(e)?EHi(e.signal,i,n):xqe(e)?n:i,Dqe=(e,i,n)=>Uo(e)?WHi(e.signal,i,n):e===EA?{value:i}:{value:n},RHi=(e,i,n)=>Uo(e)?NHi(e.signal,i,n):e===Qw?{value:i}:{value:n},VHi=(e,i,n)=>Mqe(`${e} === '${EA}' || ${e} === '${Lp}'`,i,n),EHi=(e,i,n)=>Mqe(`${e} !== '${EA}' && ${e} !== '${Lp}'`,i,n),HHi=(e,i,n)=>fue(`${e} === '${Uw}' || ${e} === '${EA}'`,i,n),WHi=(e,i,n)=>fue(`${e} === '${EA}'`,i,n),NHi=(e,i,n)=>fue(`${e} === '${Qw}'`,i,n),Mqe=(e,i,n)=>(i=i!=null?ca(i):i,n=n!=null?ca(n):n,CYe(i)&&CYe(n)?(i=i?i.signal||ai(i.value):null,n=n?n.signal||ai(n.value):null,{signal:`${e} ? (${i}) : (${n})`}):[Tn({test:e},i)].concat(n||[])),CYe=e=>e==null||Object.keys(e).length===1,fue=(e,i,n)=>({signal:`${e} ? (${jG(i)}) : (${jG(n)})`}),kHi=(e,i,n,r,o)=>({signal:(r!=null?`${e} === '${Uw}' ? (${jG(r)}) : `:"")+(n!=null?`${e} === '${Lp}' ? (${jG(n)}) : `:"")+(o!=null?`${e} === '${Qw}' ? (${jG(o)}) : `:"")+(i!=null?`${e} === '${EA}' ? (${jG(i)}) : `:"")+"(null)"}),jG=e=>Uo(e)?e.signal:e==null?null:ai(e),XHi=(e,i)=>i===0?0:Uo(e)?{signal:`(${e.signal}) * ${i}`}:{value:e*i},dS=(e,i)=>{const n=e.signal;return n&&n.endsWith("(null)")?{signal:n.slice(0,-6)+i.signal}:e};function bG(e,i,n,r){let o;if(i&&Oi(i,e))return i[e];if(Oi(n,e))return n[e];if(e.startsWith("title")){switch(e){case"titleColor":o="fill";break;case"titleFont":case"titleFontSize":case"titleFontWeight":o=e[5].toLowerCase()+e.slice(6)}return r[lue][o]}else if(e.startsWith("label")){switch(e){case"labelColor":o="fill";break;case"labelFont":case"labelFontSize":o=e[5].toLowerCase()+e.slice(6)}return r[lN][o]}return null}function cYe(e){const i={};for(const n of e)if(n)for(const r in n)i[r]=1;return Object.keys(i)}function xHi(e,i){var n=i.config,r=n.style,o=n.axis,l=i.scaleType(e.scale)==="band"&&n.axisBand,c=e.orient,u,f,m;if(Uo(c)){const v=cYe([n.axisX,n.axisY]),B=cYe([n.axisTop,n.axisBottom,n.axisLeft,n.axisRight]);u={};for(m of v)u[m]=Aa(c,bG(m,n.axisX,o,r),bG(m,n.axisY,o,r));f={};for(m of B)f[m]=kHi(c.signal,bG(m,n.axisTop,o,r),bG(m,n.axisBottom,o,r),bG(m,n.axisLeft,o,r),bG(m,n.axisRight,o,r))}else u=c===EA||c===Lp?n.axisX:n.axisY,f=n["axis"+c[0].toUpperCase()+c.slice(1)];return u||f||l?Tn({},o,u,f,l):o}function DHi(e,i,n,r){const o=hl(e,i),l=e.orient;let c,u;const f={enter:c={opacity:Cr},update:u={opacity:KC},exit:{opacity:Cr}};Fa(f,{stroke:o("domainColor"),strokeCap:o("domainCap"),strokeDash:o("domainDash"),strokeDashOffset:o("domainDashOffset"),strokeWidth:o("domainWidth"),strokeOpacity:o("domainOpacity")});const m=AYe(e,0),p=AYe(e,1);return c.x=u.x=Aa(l,m,Cr),c.x2=u.x2=Aa(l,p),c.y=u.y=mA(l,m,Cr),c.y2=u.y2=mA(l,p),Jl({type:cue,role:a9i,from:r,encode:f},n)}function AYe(e,i){return{scale:e.scale,range:i}}function MHi(e,i,n,r,o){const l=hl(e,i),c=e.orient,u=e.gridScale,f=sO(c,1,-1),m=FHi(e.offset,f);let p,v,B;const G={enter:p={opacity:Cr},update:B={opacity:KC},exit:v={opacity:Cr}};Fa(G,{stroke:l("gridColor"),strokeCap:l("gridCap"),strokeDash:l("gridDash"),strokeDashOffset:l("gridDashOffset"),strokeOpacity:l("gridOpacity"),strokeWidth:l("gridWidth")});const T={scale:e.scale,field:YC,band:o.band,extra:o.extra,offset:o.offset,round:l("tickRound")},V=Aa(c,{signal:"height"},{signal:"width"}),E=u?{scale:u,range:0,mult:f,offset:m}:{value:0,offset:m},W=u?{scale:u,range:1,mult:f,offset:m}:Tn(V,{mult:f,offset:m});return p.x=B.x=Aa(c,T,E),p.y=B.y=mA(c,T,E),p.x2=B.x2=mA(c,W),p.y2=B.y2=Aa(c,W),v.x=Aa(c,T),v.y=mA(c,T),Jl({type:cue,role:s9i,key:YC,from:r,encode:G},n)}function FHi(e,i){if(i!==1)if(!vi(e))e=Uo(i)?{signal:`(${i.signal}) * (${e||0})`}:i*(e||0);else{let n=e=Tn({},e);for(;n.mult!=null;)if(vi(n.mult))n=n.mult=Tn({},n.mult);else return n.mult=Uo(i)?{signal:`(${n.mult}) * (${i.signal})`}:n.mult*i,e;n.mult=i}return e}function YHi(e,i,n,r,o,l){const c=hl(e,i),u=e.orient,f=sO(u,-1,1);let m,p,v;const B={enter:m={opacity:Cr},update:v={opacity:KC},exit:p={opacity:Cr}};Fa(B,{stroke:c("tickColor"),strokeCap:c("tickCap"),strokeDash:c("tickDash"),strokeDashOffset:c("tickDashOffset"),strokeOpacity:c("tickOpacity"),strokeWidth:c("tickWidth")});const G=ca(o);G.mult=f;const T={scale:e.scale,field:YC,band:l.band,extra:l.extra,offset:l.offset,round:c("tickRound")};return v.y=m.y=Aa(u,Cr,T),v.y2=m.y2=Aa(u,G),p.x=Aa(u,T),v.x=m.x=mA(u,Cr,T),v.x2=m.x2=mA(u,G),p.y=mA(u,T),Jl({type:cue,role:l9i,key:YC,from:r,encode:B},n)}function Lte(e,i,n,r,o){return{signal:'flush(range("'+e+'"), scale("'+e+'", datum.value), '+i+","+n+","+r+","+o+")"}}function KHi(e,i,n,r,o,l){const c=hl(e,i),u=e.orient,f=e.scale,m=sO(u,-1,1),p=Qy(c("labelFlush")),v=Qy(c("labelFlushOffset")),B=c("labelAlign"),G=c("labelBaseline");let T=p===0||!!p,V;const E=ca(o);E.mult=m,E.offset=ca(c("labelPadding")||0),E.offset.mult=m;const W={scale:f,field:YC,band:.5,offset:Hqe(l.offset,c("labelOffset"))},x=Aa(u,T?Lte(f,p,'"left"','"right"','"center"'):{value:"center"},RHi(u,"left","right")),k=Aa(u,Dqe(u,"bottom","top"),T?Lte(f,p,'"top"','"bottom"','"middle"'):{value:"middle"}),F=Lte(f,p,`-(${v})`,v,0);T=T&&v;const Y={opacity:Cr,x:Aa(u,W,E),y:mA(u,W,E)},L={enter:Y,update:V={opacity:KC,text:{field:Iue},x:Y.x,y:Y.y,align:x,baseline:k},exit:{opacity:Cr,x:Y.x,y:Y.y}};Fa(L,{dx:!B&&T?Aa(u,F):null,dy:!G&&T?mA(u,F):null}),Fa(L,{angle:c("labelAngle"),fill:c("labelColor"),fillOpacity:c("labelOpacity"),font:c("labelFont"),fontSize:c("labelFontSize"),fontWeight:c("labelFontWeight"),fontStyle:c("labelFontStyle"),limit:c("labelLimit"),lineHeight:c("labelLineHeight")},{align:B,baseline:G});const O=c("labelBound");let Q=c("labelOverlap");return Q=Q||O?{separation:c("labelSeparation"),method:Q,order:"datum.index",bound:O?{scale:f,orient:u,tolerance:O}:null}:void 0,V.align!==x&&(V.align=dS(V.align,x)),V.baseline!==k&&(V.baseline=dS(V.baseline,k)),Jl({type:sZ,role:I9i,style:lN,key:YC,from:r,encode:L,overlap:Q},n)}function _Hi(e,i,n,r){const o=hl(e,i),l=e.orient,c=sO(l,-1,1);let u,f;const m={enter:u={opacity:Cr,anchor:ca(o("titleAnchor",null)),align:{signal:Aue}},update:f=Tn({},u,{opacity:KC,text:ca(e.title)}),exit:{opacity:Cr}},p={signal:`lerp(range("${e.scale}"), ${gO(0,1,.5)})`};return f.x=Aa(l,p),f.y=mA(l,p),u.angle=Aa(l,Cr,XHi(c,90)),u.baseline=Aa(l,Dqe(l,Lp,EA),{value:Lp}),f.angle=u.angle,f.baseline=u.baseline,Fa(m,{fill:o("titleColor"),fillOpacity:o("titleOpacity"),font:o("titleFont"),fontSize:o("titleFontSize"),fontStyle:o("titleFontStyle"),fontWeight:o("titleFontWeight"),limit:o("titleLimit"),lineHeight:o("titleLineHeight")},{align:o("titleAlign"),angle:o("titleAngle"),baseline:o("titleBaseline")}),PHi(o,l,m,n),m.update.align=dS(m.update.align,u.align),m.update.angle=dS(m.update.angle,u.angle),m.update.baseline=dS(m.update.baseline,u.baseline),Jl({type:sZ,role:C9i,style:lue,from:r,encode:m},n)}function PHi(e,i,n,r){const o=(u,f)=>u!=null?(n.update[f]=dS(ca(u),n.update[f]),!1):!RG(f,r),l=o(e("titleX"),"x"),c=o(e("titleY"),"y");n.enter.auto=c===l?ca(c):Aa(i,ca(c),ca(l))}function zHi(e,i){const n=xHi(e,i),r=e.encode||{},o=r.axis||{},l=o.name||void 0,c=o.interactive,u=o.style,f=hl(e,n),m=YEi(f),p={scale:e.scale,ticks:!!f("ticks"),labels:!!f("labels"),grid:!!f("grid"),domain:!!f("domain"),title:e.title!=null},v=_i(i.add(VA({},[p]))),B=_i(i.add(O9i({scale:i.scaleRef(e.scale),extra:i.property(m.extra),count:i.objectProperty(e.tickCount),values:i.objectProperty(e.values),minstep:i.property(e.tickMinStep),formatType:i.property(e.formatType),formatSpecifier:i.property(e.format)}))),G=[];let T;return p.grid&&G.push(MHi(e,n,r.grid,B,m)),p.ticks&&(T=f("tickSize"),G.push(YHi(e,n,r.ticks,B,T,m))),p.labels&&(T=p.ticks?T:0,G.push(KHi(e,n,r.labels,B,T,m))),p.domain&&G.push(DHi(e,n,r.domain,v)),p.title&&G.push(_Hi(e,n,r.title,v)),aO(nW({role:o9i,from:v,encode:Jw(OHi(f,e),o,CN),marks:G,aria:f("aria"),description:f("description"),zindex:f("zindex"),name:l,interactive:c,style:u}),i)}function OHi(e,i){const n={enter:{},update:{}};return Fa(n,{orient:e("orient"),offset:e("offset")||0,position:jc(i.position,0),titlePadding:e("titlePadding"),minExtent:e("minExtent"),maxExtent:e("maxExtent"),range:{signal:`abs(span(range("${i.scale}")))`},translate:e("translate"),format:i.format,formatType:i.formatType}),n}function Fqe(e,i,n){const r=pi(e.signals),o=pi(e.scales);return n||r.forEach(l=>mqe(l,i)),pi(e.projections).forEach(l=>BEi(l,i)),o.forEach(l=>cEi(l,i)),pi(e.data).forEach(l=>wHi(l,i)),o.forEach(l=>AEi(l,i)),(n||r).forEach(l=>z9i(l,i)),pi(e.axes).forEach(l=>zHi(l,i)),pi(e.marks).forEach(l=>aO(l,i)),pi(e.legends).forEach(l=>dHi(l,i)),e.title&&vHi(e.title,i),i.parseLambdas(),i}const LHi=e=>Jw({enter:{x:{value:0},y:{value:0}},update:{width:{signal:"width"},height:{signal:"height"}}},e);function JHi(e,i){const n=i.config,r=_i(i.root=i.add(S_())),o=UHi(e,n);o.forEach(m=>mqe(m,i)),i.description=e.description||n.description,i.eventConfig=n.events,i.legends=i.objectProperty(n.legend&&n.legend.layout),i.locale=n.locale;const l=i.add(VA()),c=i.add(yqe(fqe(LHi(e.encode),rO,gue,e.style,i,{pulse:_i(l)}))),u=i.add(Bqe({layout:i.objectProperty(e.layout),legends:i.legends,autosize:i.signalRef("autosize"),mark:r,pulse:_i(c)}));i.operators.pop(),i.pushState(_i(c),_i(u),null),Fqe(e,i,o),i.operators.push(u);let f=i.add(bqe({mark:r,pulse:_i(u)}));return f=i.add(Zqe({pulse:_i(f)})),f=i.add(aZ({pulse:_i(f)})),i.addData("root",new Ev(i,l,l,f)),i}function d9(e,i){return i&&i.signal?{name:e,update:i.signal}:{name:e,value:i}}function UHi(e,i){const n=c=>jc(e[c],i[c]),r=[d9("background",n("background")),d9("autosize",n9i(n("autosize"))),d9("padding",g9i(n("padding"))),d9("width",n("width")||0),d9("height",n("height")||0)],o=r.reduce((c,u)=>(c[u.name]=u,c),{}),l={};return pi(e.signals).forEach(c=>{Oi(o,c.name)?c=Tn(o[c.name],c):r.push(c),l[c.name]=c}),pi(i.signals).forEach(c=>{!Oi(l,c.name)&&!Oi(o,c.name)&&r.push(c)}),r}function Yqe(e,i){this.config=e||{},this.options=i||{},this.bindings=[],this.field={},this.signals={},this.lambdas={},this.scales={},this.events={},this.data={},this.streams=[],this.updates=[],this.operators=[],this.eventConfig=null,this.locale=null,this._id=0,this._subid=0,this._nextsub=[0],this._parent=[],this._encode=[],this._lookup=[],this._markpath=[]}function uYe(e){this.config=e.config,this.options=e.options,this.legends=e.legends,this.field=Object.create(e.field),this.signals=Object.create(e.signals),this.lambdas=Object.create(e.lambdas),this.scales=Object.create(e.scales),this.events=Object.create(e.events),this.data=Object.create(e.data),this.streams=[],this.updates=[],this.operators=[],this._id=0,this._subid=++e._nextsub[0],this._nextsub=e._nextsub,this._parent=e._parent.slice(),this._encode=e._encode.slice(),this._lookup=e._lookup.slice(),this._markpath=e._markpath}Yqe.prototype=uYe.prototype={parse(e){return Fqe(e,this)},fork(){return new uYe(this)},isSubscope(){return this._subid>0},toRuntime(){return this.finish(),{description:this.description,operators:this.operators,streams:this.streams,updates:this.updates,bindings:this.bindings,eventConfig:this.eventConfig,locale:this.locale}},id(){return(this._subid?this._subid+":":0)+this._id++},add(e){return this.operators.push(e),e.id=this.id(),e.refs&&(e.refs.forEach(i=>{i.$ref=e.id}),e.refs=null),e},proxy(e){const i=e instanceof Loe?_i(e):e;return this.add(oEi({value:i}))},addStream(e){return this.streams.push(e),e.id=this.id(),e},addUpdate(e){return this.updates.push(e),e},finish(){let e,i;this.root&&(this.root.root=!0);for(e in this.signals)this.signals[e].signal=e;for(e in this.scales)this.scales[e].scale=e;function n(r,o,l){let c,u;r&&(c=r.data||(r.data={}),u=c[o]||(c[o]=[]),u.push(l))}for(e in this.data){i=this.data[e],n(i.input,e,"input"),n(i.output,e,"output"),n(i.values,e,"values");for(const r in i.index)n(i.index[r],e,"index:"+r)}return this},pushState(e,i,n){this._encode.push(_i(this.add(aZ({pulse:e})))),this._parent.push(i),this._lookup.push(n?_i(this.proxy(n)):null),this._markpath.push(-1)},popState(){this._encode.pop(),this._parent.pop(),this._lookup.pop(),this._markpath.pop()},parent(){return sr(this._parent)},encode(){return sr(this._encode)},lookup(){return sr(this._lookup)},markpath(){const e=this._markpath;return++e[e.length-1]},fieldRef(e,i){if(fi(e))return tW(e,i);e.signal||Yt("Unsupported field reference: "+ai(e));const n=e.signal;let r=this.field[n];if(!r){const o={name:this.signalRef(n)};i&&(o.as=i),this.field[n]=r=_i(this.add(Q9i(o)))}return r},compareRef(e){let i=!1;const n=l=>Uo(l)?(i=!0,this.signalRef(l.signal)):k9i(l)?(i=!0,this.exprRef(l.expr)):l,r=pi(e.field).map(n),o=pi(e.order).map(n);return i?_i(this.add(eYe({fields:r,orders:o}))):$Fe(r,o)},keyRef(e,i){let n=!1;const r=l=>Uo(l)?(n=!0,_i(o[l.signal])):l,o=this.signals;return e=pi(e).map(r),n?_i(this.add(j9i({fields:e,flat:i}))):E9i(e,i)},sortRef(e){if(!e)return e;const i=iO(e.op,e.field),n=e.order||H9i;return n.signal?_i(this.add(eYe({fields:i,orders:this.signalRef(n.signal)}))):$Fe(i,n)},event(e,i){const n=e+":"+i;if(!this.events[n]){const r=this.id();this.streams.push({id:r,source:e,type:i}),this.events[n]=r}return this.events[n]},hasOwnSignal(e){return Oi(this.signals,e)},addSignal(e,i){this.hasOwnSignal(e)&&Yt("Duplicate signal name: "+ai(e));const n=i instanceof Loe?i:this.add(S_(i));return this.signals[e]=n},getSignal(e){return this.signals[e]||Yt("Unrecognized signal name: "+ai(e)),this.signals[e]},signalRef(e){return this.signals[e]?_i(this.signals[e]):(Oi(this.lambdas,e)||(this.lambdas[e]=this.add(S_(null))),_i(this.lambdas[e]))},parseLambdas(){const e=Object.keys(this.lambdas);for(let i=0,n=e.length;i0?",":"")+(vi(o)?o.signal||mue(o):ai(o))}return n+"]"}function jHi(e){let i="{",n=0,r,o;for(r in e)o=e[r],i+=(++n>1?",":"")+ai(r)+":"+(vi(o)?o.signal||mue(o):ai(o));return i+"}"}function $Hi(){const e="sans-serif",r="#4c78a8",o="#000",l="#888",c="#ddd";return{description:"Vega visualization",padding:0,autosize:"pad",background:null,events:{defaults:{allow:["wheel"]}},group:null,mark:null,arc:{fill:r},area:{fill:r},image:null,line:{stroke:r,strokeWidth:2},path:{stroke:r},rect:{fill:r},rule:{stroke:o},shape:{stroke:r},symbol:{fill:r,size:64},text:{fill:o,font:e,fontSize:11},trail:{fill:r,size:2},style:{"guide-label":{fill:o,font:e,fontSize:10},"guide-title":{fill:o,font:e,fontSize:11,fontWeight:"bold"},"group-title":{fill:o,font:e,fontSize:13,fontWeight:"bold"},"group-subtitle":{fill:o,font:e,fontSize:12},point:{size:30,strokeWidth:2,shape:"circle"},circle:{size:30,strokeWidth:2},square:{size:30,strokeWidth:2,shape:"square"},cell:{fill:"transparent",stroke:c},view:{fill:"transparent"}},title:{orient:"top",anchor:"middle",offset:4,subtitlePadding:3},axis:{minExtent:0,maxExtent:200,bandPosition:.5,domain:!0,domainWidth:1,domainColor:l,grid:!1,gridWidth:1,gridColor:c,labels:!0,labelAngle:0,labelLimit:180,labelOffset:0,labelPadding:2,ticks:!0,tickColor:l,tickOffset:0,tickRound:!0,tickSize:5,tickWidth:1,titlePadding:4},axisBand:{tickOffset:-.5},projection:{type:"mercator"},legend:{orient:"right",padding:0,gridAlign:"each",columnPadding:10,rowPadding:2,symbolDirection:"vertical",gradientDirection:"vertical",gradientLength:200,gradientThickness:16,gradientStrokeColor:c,gradientStrokeWidth:0,gradientLabelOffset:2,labelAlign:"left",labelBaseline:"middle",labelLimit:160,labelOffset:4,labelOverlap:!0,symbolLimit:30,symbolType:"circle",symbolSize:100,symbolOffset:0,symbolStrokeWidth:1.5,symbolBaseFillColor:"transparent",symbolBaseStrokeColor:l,titleLimit:180,titleOrient:"top",titlePadding:5,layout:{offset:18,direction:"horizontal",left:{direction:"vertical"},right:{direction:"vertical"}}},range:{category:{scheme:"tableau10"},ordinal:{scheme:"blues"},heatmap:{scheme:"yellowgreenblue"},ramp:{scheme:"blues"},diverging:{scheme:"blueorange",extent:[1,0]},symbol:["circle","square","triangle-up","cross","diamond","triangle-right","triangle-down","triangle-left"]}}}function qHi(e,i,n){return vi(e)||Yt("Input Vega specification must be an object."),i=Xw($Hi(),i,e.config),JHi(e,new Yqe(i,n)).toRuntime()}var eWi="5.25.0";Tn(OS,pmi,Qvi,TZi,SBi,bGi,LSi,SSi,USi,mwi,Twi,kwi);const tWi=Object.freeze(Object.defineProperty({__proto__:null,Bounds:Eo,CanvasHandler:qW,CanvasRenderer:N3,DATE:sl,DAY:vs,DAYOFYEAR:ud,Dataflow:sS,Debug:TUe,Error:yle,EventStream:sz,Gradient:Zje,GroupItem:Ez,HOURS:zl,Handler:zp,Info:wUe,Item:Vz,MILLISECONDS:GA,MINUTES:Ol,MONTH:Ts,Marks:Ll,MultiPulse:zle,None:SUe,Operator:rg,Parameters:az,Pulse:Tp,QUARTER:al,RenderType:sp,Renderer:Gd,ResourceLoader:fce,SECONDS:LC,SVGHandler:kce,SVGRenderer:Yce,SVGStringRenderer:Kce,Scenegraph:Wce,TIME_UNITS:kle,Transform:Xt,View:gqe,WEEK:Lo,Warn:vle,YEAR:xa,accessor:dl,accessorFields:ws,accessorName:co,array:pi,ascending:jP,bandwidthNRD:Ule,bin:s4e,bootstrapCI:I4e,boundClip:f6e,boundContext:UW,boundItem:Qge,boundMark:Kje,boundStroke:pf,changeset:iZ,clampRange:MUe,codegenExpression:y$e,compare:wle,constant:Ws,cumulativeLogNormal:tCe,cumulativeNormal:lz,cumulativeUniform:gCe,dayofyear:d7e,debounce:Tle,defaultLocale:Fle,definition:g4e,densityLogNormal:eCe,densityNormal:Qle,densityUniform:rCe,domChild:JI,domClear:nA,domCreate:op,domFind:Nce,dotbin:l4e,error:Yt,expressionFunction:Wo,extend:Tn,extent:Cd,extentIndex:FUe,falsy:Dm,fastmap:Dw,field:ol,flush:YUe,font:Xz,fontFamily:$W,fontSize:Bd,format:SY,formatLocale:d3,formats:_le,hasOwnProperty:Oi,id:HW,identity:Hs,inferType:J7e,inferTypes:U7e,ingest:Vr,inherits:si,inrange:OG,interpolate:Ice,interpolateColors:Tz,interpolateRange:Ije,intersect:A6e,intersectBoxLine:LG,intersectPath:mce,intersectPoint:pce,intersectRule:Eje,isArray:Pt,isBoolean:a0,isDate:Sp,isFunction:Rn,isIterable:KUe,isNumber:jr,isObject:vi,isRegExp:_Ue,isString:fi,isTuple:gz,key:Rle,lerp:PUe,lineHeight:_p,loader:nz,locale:O7e,logger:Zle,lruCache:zUe,markup:Fce,merge:OUe,mergeConfig:Xw,multiLineOffset:Vce,one:kw,pad:LUe,panLinear:WUe,panLog:NUe,panPow:kUe,panSymlog:XUe,parse:qHi,parseExpression:_Ae,parseSelector:A0,path:dz,pathCurves:uce,pathEqual:m6e,pathParse:qS,pathRectangle:Sje,pathRender:MH,pathSymbols:Gje,pathTrail:wje,peek:sr,point:Dz,projection:aAe,quantileLogNormal:iCe,quantileNormal:Cz,quantileUniform:oCe,quantiles:Lle,quantizeInterpolator:lje,quarter:xUe,quartiles:Jle,get random(){return JC},randomInteger:Zfi,randomKDE:$le,randomLCG:vfi,randomLogNormal:c4e,randomMixture:A4e,randomNormal:jle,randomUniform:u4e,read:$7e,regressionConstant:aCe,regressionExp:h4e,regressionLinear:sCe,regressionLoess:p4e,regressionLog:d4e,regressionPoly:m4e,regressionPow:f4e,regressionQuad:ICe,renderModule:Mz,repeat:x9,resetDefaultLocale:phi,resetSVGClipId:Rje,resetSVGDefIds:uvi,responseType:j7e,runtimeContext:O$e,sampleCurve:Az,sampleLogNormal:qle,sampleNormal:Iz,sampleUniform:nCe,scale:vr,sceneEqual:_ce,sceneFromJSON:Pje,scenePickVisit:T3,sceneToJSON:_je,sceneVisit:SA,sceneZOrder:bce,scheme:lce,serializeXML:g6e,setRandom:bfi,span:WW,splitAccessPath:vd,stringValue:ai,textMetrics:fA,timeBin:H7e,timeFloor:v7e,timeFormatLocale:HH,timeInterval:Yw,timeOffset:G7e,timeSequence:T7e,timeUnitSpecifier:u7e,timeUnits:Xle,toBoolean:Vle,toDate:Ele,toNumber:Zs,toSet:BA,toString:Hle,transform:o4e,transforms:OS,truncate:JUe,truthy:OC,tupleid:Pi,typeParsers:Tge,utcFloor:Z7e,utcInterval:Kw,utcOffset:S7e,utcSequence:R7e,utcdayofyear:m7e,utcquarter:DUe,utcweek:p7e,version:eWi,visitArray:_m,week:h7e,writeConfig:xw,zero:Qm,zoomLinear:Ble,zoomLog:Gle,zoomPow:s3,zoomSymlog:Sle},Symbol.toStringTag,{value:"Module"}));function iWi(e,i,n){let r;i.x2&&(i.x?(n&&e.x>e.x2&&(r=e.x,e.x=e.x2,e.x2=r),e.width=e.x2-e.x):e.x=e.x2-(e.width||0)),i.xc&&(e.x=e.xc-(e.width||0)/2),i.y2&&(i.y?(n&&e.y>e.y2&&(r=e.y,e.y=e.y2,e.y2=r),e.height=e.y2-e.y):e.y=e.y2-(e.height||0)),i.yc&&(e.y=e.yc-(e.height||0)/2)}var nWi={NaN:NaN,E:Math.E,LN2:Math.LN2,LN10:Math.LN10,LOG2E:Math.LOG2E,LOG10E:Math.LOG10E,PI:Math.PI,SQRT1_2:Math.SQRT1_2,SQRT2:Math.SQRT2,MIN_VALUE:Number.MIN_VALUE,MAX_VALUE:Number.MAX_VALUE},rWi={"*":(e,i)=>e*i,"+":(e,i)=>e+i,"-":(e,i)=>e-i,"/":(e,i)=>e/i,"%":(e,i)=>e%i,">":(e,i)=>e>i,"<":(e,i)=>ee<=i,">=":(e,i)=>e>=i,"==":(e,i)=>e==i,"!=":(e,i)=>e!=i,"===":(e,i)=>e===i,"!==":(e,i)=>e!==i,"&":(e,i)=>e&i,"|":(e,i)=>e|i,"^":(e,i)=>e^i,"<<":(e,i)=>e<>":(e,i)=>e>>i,">>>":(e,i)=>e>>>i},gWi={"+":e=>+e,"-":e=>-e,"~":e=>~e,"!":e=>!e};const oWi=Array.prototype.slice,$b=(e,i,n)=>{const r=n?n(i[0]):i[0];return r[e].apply(r,oWi.call(i,1))},aWi=(e,i,n,r,o,l,c)=>new Date(e,i||0,n??1,r||0,o||0,l||0,c||0);var sWi={isNaN:Number.isNaN,isFinite:Number.isFinite,abs:Math.abs,acos:Math.acos,asin:Math.asin,atan:Math.atan,atan2:Math.atan2,ceil:Math.ceil,cos:Math.cos,exp:Math.exp,floor:Math.floor,log:Math.log,max:Math.max,min:Math.min,pow:Math.pow,random:Math.random,round:Math.round,sin:Math.sin,sqrt:Math.sqrt,tan:Math.tan,clamp:(e,i,n)=>Math.max(i,Math.min(n,e)),now:Date.now,utc:Date.UTC,datetime:aWi,date:e=>new Date(e).getDate(),day:e=>new Date(e).getDay(),year:e=>new Date(e).getFullYear(),month:e=>new Date(e).getMonth(),hours:e=>new Date(e).getHours(),minutes:e=>new Date(e).getMinutes(),seconds:e=>new Date(e).getSeconds(),milliseconds:e=>new Date(e).getMilliseconds(),time:e=>new Date(e).getTime(),timezoneoffset:e=>new Date(e).getTimezoneOffset(),utcdate:e=>new Date(e).getUTCDate(),utcday:e=>new Date(e).getUTCDay(),utcyear:e=>new Date(e).getUTCFullYear(),utcmonth:e=>new Date(e).getUTCMonth(),utchours:e=>new Date(e).getUTCHours(),utcminutes:e=>new Date(e).getUTCMinutes(),utcseconds:e=>new Date(e).getUTCSeconds(),utcmilliseconds:e=>new Date(e).getUTCMilliseconds(),length:e=>e.length,join:function(){return $b("join",arguments)},indexof:function(){return $b("indexOf",arguments)},lastindexof:function(){return $b("lastIndexOf",arguments)},slice:function(){return $b("slice",arguments)},reverse:e=>e.slice().reverse(),parseFloat,parseInt,upper:e=>String(e).toUpperCase(),lower:e=>String(e).toLowerCase(),substring:function(){return $b("substring",arguments,String)},split:function(){return $b("split",arguments,String)},replace:function(){return $b("replace",arguments,String)},trim:e=>String(e).trim(),regexp:RegExp,test:(e,i)=>RegExp(e).test(i)};const IWi=["view","item","group","xy","x","y"],eae=new Set([Function,eval,setTimeout,setInterval]);typeof setImmediate=="function"&&eae.add(setImmediate);const lWi={Literal:(e,i)=>i.value,Identifier:(e,i)=>{const n=i.name;return e.memberDepth>0?n:n==="datum"?e.datum:n==="event"?e.event:n==="item"?e.item:nWi[n]||e.params["$"+n]},MemberExpression:(e,i)=>{const n=!i.computed,r=e(i.object);n&&(e.memberDepth+=1);const o=e(i.property);if(n&&(e.memberDepth-=1),eae.has(r[o])){console.error(`Prevented interpretation of member "${o}" which could lead to insecure code execution`);return}return r[o]},CallExpression:(e,i)=>{const n=i.arguments;let r=i.callee.name;return r.startsWith("_")&&(r=r.slice(1)),r==="if"?e(n[0])?e(n[1]):e(n[2]):(e.fn[r]||sWi[r]).apply(e.fn,n.map(e))},ArrayExpression:(e,i)=>i.elements.map(e),BinaryExpression:(e,i)=>rWi[i.operator](e(i.left),e(i.right)),UnaryExpression:(e,i)=>gWi[i.operator](e(i.argument)),ConditionalExpression:(e,i)=>e(i.test)?e(i.consequent):e(i.alternate),LogicalExpression:(e,i)=>i.operator==="&&"?e(i.left)&&e(i.right):e(i.left)||e(i.right),ObjectExpression:(e,i)=>i.properties.reduce((n,r)=>{e.memberDepth+=1;const o=e(r.key);return e.memberDepth-=1,eae.has(e(r.value))?console.error(`Prevented interpretation of property "${o}" which could lead to insecure code execution`):n[o]=e(r.value),n},{})};function h9(e,i,n,r,o,l){const c=u=>lWi[u.type](c,u);return c.memberDepth=0,c.fn=Object.create(i),c.params=n,c.datum=r,c.event=o,c.item=l,IWi.forEach(u=>c.fn[u]=function(){return o.vega[u](...arguments)}),c(e)}var CWi={operator(e,i){const n=i.ast,r=e.functions;return o=>h9(n,r,o)},parameter(e,i){const n=i.ast,r=e.functions;return(o,l)=>h9(n,r,l,o)},event(e,i){const n=i.ast,r=e.functions;return o=>h9(n,r,void 0,void 0,o)},handler(e,i){const n=i.ast,r=e.functions;return(o,l)=>{const c=l.item&&l.item.datum;return h9(n,r,o,c,l)}},encode(e,i){const{marktype:n,channels:r}=i,o=e.functions,l=n==="group"||n==="image"||n==="rect";return(c,u)=>{const f=c.datum;let m=0,p;for(const v in r)p=h9(r[v].ast,o,u,f,void 0,c),c[v]!==p&&(c[v]=p,m=1);return n!=="rule"&&iWi(c,r,l),m}}};const cWi="vega-lite",AWi='Dominik Moritz, Kanit "Ham" Wongsuphasawat, Arvind Satyanarayan, Jeffrey Heer',uWi="5.9.0",dWi=["Kanit Wongsuphasawat (http://kanitw.yellowpigz.com)","Dominik Moritz (https://www.domoritz.de)","Arvind Satyanarayan (https://arvindsatya.com)","Jeffrey Heer (https://jheer.org)"],hWi="https://vega.github.io/vega-lite/",fWi="Vega-Lite is a concise high-level language for interactive visualization.",mWi=["vega","chart","visualization"],pWi="build/vega-lite.js",bWi="build/vega-lite.min.js",yWi="build/vega-lite.min.js",vWi="build/src/index",ZWi="build/src/index.d.ts",BWi={vl2pdf:"./bin/vl2pdf",vl2png:"./bin/vl2png",vl2svg:"./bin/vl2svg",vl2vg:"./bin/vl2vg"},GWi=["bin","build","src","vega-lite*","tsconfig.json"],SWi={changelog:"conventional-changelog -p angular -r 2",prebuild:"yarn clean:build",build:"yarn build:only","build:only":"tsc -p tsconfig.build.json && rollup -c","prebuild:examples":"yarn build:only","build:examples":"yarn data && TZ=America/Los_Angeles scripts/build-examples.sh","prebuild:examples-full":"yarn build:only","build:examples-full":"TZ=America/Los_Angeles scripts/build-examples.sh 1","build:example":"TZ=America/Los_Angeles scripts/build-example.sh","build:toc":"yarn build:jekyll && scripts/generate-toc","build:site":"rollup -c site/rollup.config.mjs","build:jekyll":"pushd site && bundle exec jekyll build -q && popd","build:versions":"scripts/update-version.sh",clean:"yarn clean:build && del-cli 'site/data/*' 'examples/compiled/*.png' && find site/examples ! -name 'index.md' ! -name 'data' -type f -delete","clean:build":"del-cli 'build/*' !build/vega-lite-schema.json",data:"rsync -r node_modules/vega-datasets/data/* site/data",schema:"mkdir -p build && ts-json-schema-generator -f tsconfig.json -p src/index.ts -t TopLevelSpec --no-type-check --no-ref-encode > build/vega-lite-schema.json && yarn renameschema && cp build/vega-lite-schema.json site/_data/",renameschema:"scripts/rename-schema.sh",presite:"yarn data && yarn schema && yarn build:site && yarn build:versions && scripts/create-example-pages.sh",site:"yarn site:only","site:only":"pushd site && bundle exec jekyll serve -I -l && popd",prettierbase:"prettier '**/*.{md,css,yml}'",format:"eslint . --fix && yarn prettierbase --write",lint:"eslint . && yarn prettierbase --check",jest:"NODE_OPTIONS=--experimental-vm-modules npx jest",test:"yarn jest test/ && yarn lint && yarn schema && yarn jest examples/ && yarn test:runtime","test:cover":"yarn jest --collectCoverage test/","test:inspect":"node --inspect-brk --experimental-vm-modules ./node_modules/.bin/jest --runInBand test","test:runtime":"NODE_OPTIONS=--experimental-vm-modules TZ=America/Los_Angeles npx jest test-runtime/ --config test-runtime/jest-config.json","test:runtime:generate":"yarn build:only && del-cli test-runtime/resources && VL_GENERATE_TESTS=true yarn test:runtime",watch:"tsc -p tsconfig.build.json -w","watch:site":"yarn build:site -w","watch:test":"yarn jest --watch test/","watch:test:runtime":"NODE_OPTIONS=--experimental-vm-modules TZ=America/Los_Angeles npx jest --watch test-runtime/ --config test-runtime/jest-config.json",release:"release-it"},wWi={type:"git",url:"https://github.com/vega/vega-lite.git"},TWi="BSD-3-Clause",RWi={url:"https://github.com/vega/vega-lite/issues"},VWi={"@babel/core":"^7.21.4","@babel/preset-env":"^7.21.4","@babel/preset-typescript":"^7.21.4","@release-it/conventional-changelog":"^5.1.1","@rollup/plugin-alias":"^5.0.0","@rollup/plugin-babel":"^6.0.3","@rollup/plugin-commonjs":"^24.1.0","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.0.2","@rollup/plugin-terser":"^0.4.1","@types/chai":"^4.3.4","@types/d3":"^7.4.0","@types/jest":"^27.4.1","@types/pako":"^2.0.0","@typescript-eslint/eslint-plugin":"^5.59.1","@typescript-eslint/parser":"^5.59.1","ajv-formats":"^2.1.1",ajv:"^8.12.0",chai:"^4.3.7",cheerio:"^1.0.0-rc.12","conventional-changelog-cli":"^2.2.2",d3:"^7.8.4","del-cli":"^5.0.0","eslint-config-prettier":"^8.8.0","eslint-plugin-jest":"^27.2.1","eslint-plugin-prettier":"^4.2.1",eslint:"^8.39.0","highlight.js":"^11.7.0","jest-dev-server":"^6.1.1",jest:"^27.5.1",mkdirp:"^3.0.1",pako:"^2.1.0",prettier:"^2.8.8",puppeteer:"^15.0.0","release-it":"^15.10.1","rollup-plugin-bundle-size":"^1.0.3","rollup-plugin-sourcemaps":"^0.6.3",rollup:"^3.21.0",serve:"^14.2.0",terser:"^5.17.1","ts-jest":"^29.1.0","ts-json-schema-generator":"^1.2.0",typescript:"~4.9.5","vega-cli":"^5.25.0","vega-datasets":"^2.7.0","vega-embed":"^6.22.1","vega-tooltip":"^0.32.0","yaml-front-matter":"^4.1.1"},EWi={"@types/clone":"~2.1.1",clone:"~2.1.2","fast-deep-equal":"~3.1.3","fast-json-stable-stringify":"~2.1.0","json-stringify-pretty-compact":"~3.0.0",tslib:"~2.5.0","vega-event-selector":"~3.0.1","vega-expression":"~5.1.0","vega-util":"~1.17.2",yargs:"~17.7.1"},HWi={vega:"^5.24.0"},WWi={node:">=16"},NWi={name:cWi,author:AWi,version:uWi,collaborators:dWi,homepage:hWi,description:fWi,keywords:mWi,main:pWi,unpkg:bWi,jsdelivr:yWi,module:vWi,types:ZWi,bin:BWi,files:GWi,scripts:SWi,repository:wWi,license:TWi,bugs:RWi,devDependencies:VWi,dependencies:EWi,peerDependencies:HWi,engines:WWi};var Kqe={exports:{}};(function(e){var i=function(){function n(B,G){return G!=null&&B instanceof G}var r;try{r=Map}catch{r=function(){}}var o;try{o=Set}catch{o=function(){}}var l;try{l=Promise}catch{l=function(){}}function c(B,G,T,V,E){typeof G=="object"&&(T=G.depth,V=G.prototype,E=G.includeNonEnumerable,G=G.circular);var W=[],x=[],k=typeof Buffer<"u";typeof G>"u"&&(G=!0),typeof T>"u"&&(T=1/0);function F(Y,L){if(Y===null)return null;if(L===0)return Y;var O,Q;if(typeof Y!="object")return Y;if(n(Y,r))O=new r;else if(n(Y,o))O=new o;else if(n(Y,l))O=new l(function(Ze,me){Y.then(function(be){Ze(F(be,L-1))},function(be){me(F(be,L-1))})});else if(c.__isArray(Y))O=[];else if(c.__isRegExp(Y))O=new RegExp(Y.source,v(Y)),Y.lastIndex&&(O.lastIndex=Y.lastIndex);else if(c.__isDate(Y))O=new Date(Y.getTime());else{if(k&&Buffer.isBuffer(Y))return Buffer.allocUnsafe?O=Buffer.allocUnsafe(Y.length):O=new Buffer(Y.length),Y.copy(O),O;n(Y,Error)?O=Object.create(Y):typeof V>"u"?(Q=Object.getPrototypeOf(Y),O=Object.create(Q)):(O=Object.create(V),Q=V)}if(G){var X=W.indexOf(Y);if(X!=-1)return x[X];W.push(Y),x.push(O)}n(Y,r)&&Y.forEach(function(Ze,me){var be=F(me,L-1),Ee=F(Ze,L-1);O.set(be,Ee)}),n(Y,o)&&Y.forEach(function(Ze){var me=F(Ze,L-1);O.add(me)});for(var $ in Y){var ee;Q&&(ee=Object.getOwnPropertyDescriptor(Q,$)),!(ee&&ee.set==null)&&(O[$]=F(Y[$],L-1))}if(Object.getOwnPropertySymbols)for(var ne=Object.getOwnPropertySymbols(Y),$=0;$hS(n,i))}:bue(e)?{or:e.or.map(n=>hS(n,i))}:i(e)}const Ku=_qe,vn=XWi;function Pqe(e){throw new Error(e)}function Iw(e,i){const n={};for(const r of i)Oi(e,r)&&(n[r]=e[r]);return n}function nl(e,i){const n={...e};for(const r of i)delete n[r];return n}Set.prototype.toJSON=function(){return`Set(${[...this].map(e=>pue(e)).join(",")})`};const ug=pue;function Ir(e){if(jr(e))return e;const i=fi(e)?e:pue(e);if(i.length<250)return i;let n=0;for(let r=0;ru===0?c:`[${c}]`),l=o.map((c,u)=>o.slice(0,u+1).join(""));for(const c of l)i.add(c)}return i}function Gue(e,i){return e===void 0||i===void 0?!0:Bue(iae(e),iae(i))}function Qr(e){return ei(e).length===0}const ei=Object.keys,Da=Object.values,Jp=Object.entries;function rW(e){return e===!0||e===!1}function Mg(e){const i=e.replace(/\W/g,"_");return(e.match(/^\d+/)?"_":"")+i}function WE(e,i){return vue(e)?`!(${WE(e.not,i)})`:yue(e)?`(${e.and.map(n=>WE(n,i)).join(") && (")})`:bue(e)?`(${e.or.map(n=>WE(n,i)).join(") || (")})`:i(e)}function w_(e,i){if(i.length===0)return!0;const n=i.shift();return n in e&&w_(e[n],i)&&delete e[n],Qr(e)}function cN(e){return e.charAt(0).toUpperCase()+e.substr(1)}function Sue(e,i="datum"){const n=vd(e),r=[];for(let o=1;o<=n.length;o++){const l=`[${n.slice(0,o).map(ai).join("][")}]`;r.push(`${i}${l}`)}return r.join(" && ")}function Lqe(e,i="datum"){return`${i}[${ai(vd(e).join("."))}]`}function YWi(e){return e.replace(/(\[|\]|\.|'|")/g,"\\$1")}function QC(e){return`${vd(e).map(YWi).join("\\.")}`}function Wv(e,i,n){return e.replace(new RegExp(i.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),"g"),n)}function wue(e){return`${vd(e).join(".")}`}function lw(e){return e?vd(e).length:0}function Ho(...e){for(const i of e)if(i!==void 0)return i}let Jqe=42;function Uqe(e){const i=++Jqe;return e?String(e)+i:i}function KWi(){Jqe=42}function Qqe(e){return jqe(e)?e:`__${e}`}function jqe(e){return e.startsWith("__")}function gW(e){if(e!==void 0)return(e%360+360)%360}function IO(e){return jr(e)?!0:!isNaN(e)&&!isNaN(parseFloat(e))}const Uh="row",Qh="column",lO="facet",Fg="x",da="y",HA="x2",Td="y2",u0="xOffset",jw="yOffset",WA="radius",vf="radius2",qC="theta",Zf="theta2",NA="latitude",kA="longitude",XA="latitude2",jC="longitude2",ll="color",Rd="fill",Vd="stroke",Cl="shape",Bf="size",IZ="angle",Gf="opacity",d0="fillOpacity",h0="strokeOpacity",f0="strokeWidth",m0="strokeDash",AN="text",uN="order",dN="detail",CO="key",Nv="tooltip",cO="href",AO="url",uO="description",_Wi={x:1,y:1,x2:1,y2:1},$qe={theta:1,theta2:1,radius:1,radius2:1};function qqe(e){return e in $qe}const Tue={longitude:1,longitude2:1,latitude:1,latitude2:1};function eet(e){switch(e){case NA:return"y";case XA:return"y2";case kA:return"x";case jC:return"x2"}}function tet(e){return e in Tue}const PWi=ei(Tue),Rue={..._Wi,...$qe,...Tue,xOffset:1,yOffset:1,color:1,fill:1,stroke:1,opacity:1,fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeDash:1,size:1,angle:1,shape:1,order:1,text:1,detail:1,key:1,tooltip:1,href:1,url:1,description:1};function fS(e){return e===ll||e===Rd||e===Vd}const iet={row:1,column:1,facet:1},xC=ei(iet),Vue={...Rue,...iet},zWi=ei(Vue),{order:NPi,detail:kPi,tooltip:XPi,...OWi}=Vue,{row:xPi,column:DPi,facet:MPi,...LWi}=OWi;function JWi(e){return!!LWi[e]}function net(e){return!!Vue[e]}const UWi=[HA,Td,XA,jC,Zf,vf];function ret(e){return lZ(e)!==e}function lZ(e){switch(e){case HA:return Fg;case Td:return da;case XA:return NA;case jC:return kA;case Zf:return qC;case vf:return WA}return e}function Up(e){if(qqe(e))switch(e){case qC:return"startAngle";case Zf:return"endAngle";case WA:return"outerRadius";case vf:return"innerRadius"}return e}function Ed(e){switch(e){case Fg:return HA;case da:return Td;case NA:return XA;case kA:return jC;case qC:return Zf;case WA:return vf}}function cl(e){switch(e){case Fg:case HA:return"width";case da:case Td:return"height"}}function get(e){switch(e){case Fg:return"xOffset";case da:return"yOffset";case HA:return"x2Offset";case Td:return"y2Offset";case qC:return"thetaOffset";case WA:return"radiusOffset";case Zf:return"theta2Offset";case vf:return"radius2Offset"}}function Eue(e){switch(e){case Fg:return"xOffset";case da:return"yOffset"}}function oet(e){switch(e){case"xOffset":return"x";case"yOffset":return"y"}}const QWi=ei(Rue),{x:FPi,y:YPi,x2:KPi,y2:_Pi,xOffset:PPi,yOffset:zPi,latitude:OPi,longitude:LPi,latitude2:JPi,longitude2:UPi,theta:QPi,theta2:jPi,radius:$Pi,radius2:qPi,...Hue}=Rue,jWi=ei(Hue),Wue={x:1,y:1},Hd=ei(Wue);function ha(e){return e in Wue}const Nue={theta:1,radius:1},$Wi=ei(Nue);function dO(e){return e==="width"?Fg:da}const aet={xOffset:1,yOffset:1};function $w(e){return e in aet}const{text:ezi,tooltip:tzi,href:izi,url:nzi,description:rzi,detail:gzi,key:ozi,order:azi,...set}=Hue,qWi=ei(set);function eNi(e){return!!Hue[e]}function tNi(e){switch(e){case ll:case Rd:case Vd:case Bf:case Cl:case Gf:case f0:case m0:return!0;case d0:case h0:case IZ:return!1}}const Iet={...Wue,...Nue,...aet,...set},hO=ei(Iet);function Sf(e){return!!Iet[e]}function iNi(e,i){return rNi(e)[i]}const Cet={arc:"always",area:"always",bar:"always",circle:"always",geoshape:"always",image:"always",line:"always",rule:"always",point:"always",rect:"always",square:"always",trail:"always",text:"always",tick:"always"},{geoshape:szi,...nNi}=Cet;function rNi(e){switch(e){case ll:case Rd:case Vd:case uO:case dN:case CO:case Nv:case cO:case uN:case Gf:case d0:case h0:case f0:case lO:case Uh:case Qh:return Cet;case Fg:case da:case u0:case jw:case NA:case kA:return nNi;case HA:case Td:case XA:case jC:return{area:"always",bar:"always",image:"always",rect:"always",rule:"always",circle:"binned",point:"binned",square:"binned",tick:"binned",line:"binned",trail:"binned"};case Bf:return{point:"always",tick:"always",rule:"always",circle:"always",square:"always",bar:"always",text:"always",line:"always",trail:"always"};case m0:return{line:"always",point:"always",tick:"always",rule:"always",circle:"always",square:"always",bar:"always",geoshape:"always"};case Cl:return{point:"always",geoshape:"always"};case AN:return{text:"always"};case IZ:return{point:"always",square:"always",text:"always"};case AO:return{image:"always"};case qC:return{text:"always",arc:"always"};case WA:return{text:"always",arc:"always"};case Zf:case vf:return{arc:"always"}}}function Jte(e){switch(e){case Fg:case da:case qC:case WA:case u0:case jw:case Bf:case IZ:case f0:case Gf:case d0:case h0:case HA:case Td:case Zf:case vf:return;case lO:case Uh:case Qh:case Cl:case m0:case AN:case Nv:case cO:case AO:case uO:return"discrete";case ll:case Rd:case Vd:return"flexible";case NA:case kA:case XA:case jC:case dN:case CO:case uN:return}}const gNi={argmax:1,argmin:1,average:1,count:1,distinct:1,product:1,max:1,mean:1,median:1,min:1,missing:1,q1:1,q3:1,ci0:1,ci1:1,stderr:1,stdev:1,stdevp:1,sum:1,valid:1,values:1,variance:1,variancep:1},oNi={count:1,min:1,max:1};function Af(e){return!!e&&!!e.argmin}function p0(e){return!!e&&!!e.argmax}function kue(e){return fi(e)&&!!gNi[e]}const aNi=new Set(["count","valid","missing","distinct"]);function cet(e){return fi(e)&&aNi.has(e)}function sNi(e){return fi(e)&&jn(["min","max"],e)}const INi=new Set(["count","sum","distinct","valid","missing"]),lNi=new Set(["mean","average","median","q1","q3","min","max"]);function Aet(e){return a0(e)&&(e=TO(e,void 0)),"bin"+ei(e).map(i=>fO(e[i])?Mg(`_${i}_${Jp(e[i])}`):Mg(`_${i}_${e[i]}`)).join("")}function dg(e){return e===!0||CZ(e)&&!e.binned}function Ha(e){return e==="binned"||CZ(e)&&e.binned===!0}function CZ(e){return vi(e)}function fO(e){return e?.param}function dYe(e){switch(e){case Uh:case Qh:case Bf:case ll:case Rd:case Vd:case f0:case Gf:case d0:case h0:case Cl:return 6;case m0:return 4;default:return 10}}function hN(e){return!!e?.expr}function OI(e){const i=ei(e||{}),n={};for(const r of i)n[r]=Dl(e[r]);return n}function uet(e){const{anchor:i,frame:n,offset:r,orient:o,angle:l,limit:c,color:u,subtitleColor:f,subtitleFont:m,subtitleFontSize:p,subtitleFontStyle:v,subtitleFontWeight:B,subtitleLineHeight:G,subtitlePadding:T,...V}=e,E={...V,...u?{fill:u}:{}},W={...i?{anchor:i}:{},...n?{frame:n}:{},...r?{offset:r}:{},...o?{orient:o}:{},...l!==void 0?{angle:l}:{},...c!==void 0?{limit:c}:{}},x={...f?{subtitleColor:f}:{},...m?{subtitleFont:m}:{},...p?{subtitleFontSize:p}:{},...v?{subtitleFontStyle:v}:{},...B?{subtitleFontWeight:B}:{},...G?{subtitleLineHeight:G}:{},...T?{subtitlePadding:T}:{}},k=Iw(e,["align","baseline","dx","dy","limit"]);return{titleMarkConfig:E,subtitleMarkConfig:k,nonMarkTitleProperties:W,subtitle:x}}function Lm(e){return fi(e)||Pt(e)&&fi(e[0])}function Fi(e){return!!e?.signal}function b0(e){return!!e.step}function CNi(e){return Pt(e)?!1:"fields"in e&&!("data"in e)}function cNi(e){return Pt(e)?!1:"fields"in e&&"data"in e}function Kh(e){return Pt(e)?!1:"field"in e&&"data"in e}const ANi={aria:1,description:1,ariaRole:1,ariaRoleDescription:1,blend:1,opacity:1,fill:1,fillOpacity:1,stroke:1,strokeCap:1,strokeWidth:1,strokeOpacity:1,strokeDash:1,strokeDashOffset:1,strokeJoin:1,strokeOffset:1,strokeMiterLimit:1,startAngle:1,endAngle:1,padAngle:1,innerRadius:1,outerRadius:1,size:1,shape:1,interpolate:1,tension:1,orient:1,align:1,baseline:1,text:1,dir:1,dx:1,dy:1,ellipsis:1,limit:1,radius:1,theta:1,angle:1,font:1,fontSize:1,fontWeight:1,fontStyle:1,lineBreak:1,lineHeight:1,cursor:1,href:1,tooltip:1,cornerRadius:1,cornerRadiusTopLeft:1,cornerRadiusTopRight:1,cornerRadiusBottomLeft:1,cornerRadiusBottomRight:1,aspect:1,width:1,height:1,url:1,smooth:1},uNi=ei(ANi),dNi={arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1},nae=["cornerRadius","cornerRadiusTopLeft","cornerRadiusTopRight","cornerRadiusBottomLeft","cornerRadiusBottomRight"];function det(e){const i=Pt(e.condition)?e.condition.map(hYe):hYe(e.condition);return{...Dl(e),condition:i}}function Dl(e){if(hN(e)){const{expr:i,...n}=e;return{signal:i,...n}}return e}function hYe(e){if(hN(e)){const{expr:i,...n}=e;return{signal:i,...n}}return e}function Gg(e){if(hN(e)){const{expr:i,...n}=e;return{signal:i,...n}}return Fi(e)?e:e!==void 0?{value:e}:void 0}function hNi(e){return Fi(e)?e.signal:ai(e)}function fYe(e){return Fi(e)?e.signal:ai(e.value)}function jh(e){return Fi(e)?e.signal:e==null?null:ai(e)}function fNi(e,i,n){for(const r of n){const o=kv(r,i.markDef,i.config);o!==void 0&&(e[r]=Gg(o))}return e}function het(e){return[].concat(e.type,e.style??[])}function Wr(e,i,n,r={}){const{vgChannel:o,ignoreVgConfig:l}=r;return o&&i[o]!==void 0?i[o]:i[e]!==void 0?i[e]:l&&(!o||o===e)?void 0:kv(e,i,n,r)}function kv(e,i,n,{vgChannel:r}={}){return Ho(r?T_(e,i,n.style):void 0,T_(e,i,n.style),r?n[i.type][r]:void 0,n[i.type][e],r?n.mark[r]:n.mark[e])}function T_(e,i,n){return fet(e,het(i),n)}function fet(e,i,n){i=pi(i);let r;for(const o of i){const l=n[o];l&&l[e]!==void 0&&(r=l[e])}return r}function met(e,i){return pi(e).reduce((n,r)=>(n.field.push(di(r,i)),n.order.push(r.sort??"ascending"),n),{field:[],order:[]})}function pet(e,i){const n=[...e];return i.forEach(r=>{for(const o of n)if(Ku(o,r))return;n.push(r)}),n}function bet(e,i){return Ku(e,i)||!i?e:e?[...pi(e),...pi(i)].join(", "):i}function yet(e,i){const n=e.value,r=i.value;if(n==null||r===null)return{explicit:e.explicit,value:null};if((Lm(n)||Fi(n))&&(Lm(r)||Fi(r)))return{explicit:e.explicit,value:bet(n,r)};if(Lm(n)||Fi(n))return{explicit:e.explicit,value:n};if(Lm(r)||Fi(r))return{explicit:e.explicit,value:r};if(!Lm(n)&&!Fi(n)&&!Lm(r)&&!Fi(r))return{explicit:e.explicit,value:pet(n,r)};throw new Error("It should never reach here")}function Xue(e){return`Invalid specification ${ug(e)}. Make sure the specification includes at least one of the following properties: "mark", "layer", "facet", "hconcat", "vconcat", "concat", or "repeat".`}const mNi='Autosize "fit" only works for single views and layered views.';function mYe(e){return`${e=="width"?"Width":"Height"} "container" only works for single views and layered views.`}function pYe(e){const i=e=="width"?"Width":"Height",n=e=="width"?"x":"y";return`${i} "container" only works well with autosize "fit" or "fit-${n}".`}function bYe(e){return e?`Dropping "fit-${e}" because spec has discrete ${cl(e)}.`:'Dropping "fit" because spec has discrete size.'}function xue(e){return`Unknown field for ${e}. Cannot calculate view size.`}function yYe(e){return`Cannot project a selection on encoding channel "${e}", which has no field.`}function pNi(e,i){return`Cannot project a selection on encoding channel "${e}" as it uses an aggregate function ("${i}").`}function bNi(e){return`The "nearest" transform is not supported for ${e} marks.`}function vet(e){return`Selection not supported for ${e} yet.`}function yNi(e){return`Cannot find a selection named "${e}".`}const vNi="Scale bindings are currently only supported for scales with unbinned, continuous domains.",ZNi="Legend bindings are only supported for selections over an individual field or encoding channel.";function BNi(e){return`Lookups can only be performed on selection parameters. "${e}" is a variable parameter.`}function GNi(e){return`Cannot define and lookup the "${e}" selection in the same view. Try moving the lookup into a second, layered view?`}const SNi="The same selection must be used to override scale domains in a layered view.",wNi='Interval selections should be initialized using "x", "y", "longitude", or "latitude" keys.';function TNi(e){return`Unknown repeated value "${e}".`}function vYe(e){return`The "columns" property cannot be used when "${e}" has nested row/column.`}const RNi="Axes cannot be shared in concatenated or repeated views yet (https://github.com/vega/vega-lite/issues/2415).";function VNi(e){return`Unrecognized parse "${e}".`}function ZYe(e,i,n){return`An ancestor parsed field "${e}" as ${n} but a child wants to parse the field as ${i}.`}const ENi="Attempt to add the same child twice.";function HNi(e){return`Ignoring an invalid transform: ${ug(e)}.`}const WNi='If "from.fields" is not specified, "as" has to be a string that specifies the key to be used for the data from the secondary source.';function BYe(e){return`Config.customFormatTypes is not true, thus custom format type and format for channel ${e} are dropped.`}function NNi(e){const{parentProjection:i,projection:n}=e;return`Layer's shared projection ${ug(i)} is overridden by a child projection ${ug(n)}.`}const kNi="Arc marks uses theta channel rather than angle, replacing angle with theta.";function XNi(e){return`${e}Offset dropped because ${e} is continuous`}function xNi(e){return`There is no ${e} encoding. Replacing ${e}Offset encoding as ${e}.`}function DNi(e,i,n){return`Channel ${e} is a ${i}. Converted to {value: ${ug(n)}}.`}function Zet(e){return`Invalid field type "${e}".`}function MNi(e,i){return`Invalid field type "${e}" for aggregate: "${i}", using "quantitative" instead.`}function FNi(e){return`Invalid aggregation operator "${e}".`}function Bet(e,i){const{fill:n,stroke:r}=i;return`Dropping color ${e} as the plot also has ${n&&r?"fill and stroke":n?"fill":"stroke"}.`}function YNi(e){return`Position range does not support relative band size for ${e}.`}function rae(e,i){return`Dropping ${ug(e)} from channel "${i}" since it does not contain any data field, datum, value, or signal.`}const KNi="Line marks cannot encode size with a non-groupby field. You may want to use trail marks instead.";function mO(e,i,n){return`${e} dropped as it is incompatible with "${i}"${n?` when ${n}`:""}.`}function _Ni(e){return`${e} encoding has no scale, so specified scale is ignored.`}function PNi(e){return`${e}-encoding is dropped as ${e} is not a valid encoding channel.`}function zNi(e){return`${e} encoding should be discrete (ordinal / nominal / binned).`}function ONi(e){return`${e} encoding should be discrete (ordinal / nominal / binned) or use a discretizing scale (e.g. threshold).`}function LNi(e){return`Facet encoding dropped as ${e.join(" and ")} ${e.length>1?"are":"is"} also specified.`}function Ute(e,i){return`Using discrete channel "${e}" to encode "${i}" field can be misleading as it does not encode ${i==="ordinal"?"order":"magnitude"}.`}function JNi(e){return`The ${e} for range marks cannot be an expression`}function UNi(e,i){return`Line mark is for continuous lines and thus cannot be used with ${e&&i?"x2 and y2":e?"x2":"y2"}. We will use the rule mark (line segments) instead.`}function QNi(e,i){return`Specified orient "${e}" overridden with "${i}".`}function jNi(e){return`Cannot use the scale property "${e}" with non-color channel.`}function $Ni(e){return`Cannot use the relative band size with ${e} scale.`}function qNi(e){return`Using unaggregated domain with raw field has no effect (${ug(e)}).`}function eki(e){return`Unaggregated domain not applicable for "${e}" since it produces values outside the origin domain of the source data.`}function tki(e){return`Unaggregated domain is currently unsupported for log scale (${ug(e)}).`}function iki(e){return`Cannot apply size to non-oriented mark "${e}".`}function nki(e,i,n){return`Channel "${e}" does not work with "${i}" scale. We are using "${n}" scale instead.`}function rki(e,i){return`FieldDef does not work with "${e}" scale. We are using "${i}" scale instead.`}function Get(e,i,n){return`${n}-scale's "${i}" is dropped as it does not work with ${e} scale.`}function wet(e){return`The step for "${e}" is dropped because the ${e==="width"?"x":"y"} is continuous.`}function gki(e,i,n,r){return`Conflicting ${i.toString()} property "${e.toString()}" (${ug(n)} and ${ug(r)}). Using ${ug(n)}.`}function oki(e,i,n,r){return`Conflicting ${i.toString()} property "${e.toString()}" (${ug(n)} and ${ug(r)}). Using the union of the two domains.`}function aki(e){return`Setting the scale to be independent for "${e}" means we also have to set the guide (axis or legend) to be independent.`}function ski(e){return`Dropping sort property ${ug(e)} as unioned domains only support boolean or op "count", "min", and "max".`}const GYe="Domains that should be unioned has conflicting sort properties. Sort will be set to true.",Iki="Detected faceted independent scales that union domain of multiple fields from different data sources. We will use the first field. The result view size may be incorrect.",lki="Detected faceted independent scales that union domain of the same fields from different source. We will assume that this is the same field from a different fork of the same data source. However, if this is not the case, the result view size may be incorrect.",Cki="Detected faceted independent scales that union domain of multiple fields from the same data source. We will use the first field. The result view size may be incorrect.";function cki(e){return`Cannot stack "${e}" if there is already "${e}2".`}function Aki(e){return`Cannot stack non-linear scale (${e}).`}function uki(e){return`Stacking is applied even though the aggregate function is non-summative ("${e}").`}function R_(e,i){return`Invalid ${e}: ${ug(i)}.`}function dki(e){return`Dropping day from datetime ${ug(e)} as day cannot be combined with other units.`}function hki(e,i){return`${i?"extent ":""}${i&&e?"and ":""}${e?"center ":""}${i&&e?"are ":"is "}not needed when data are aggregated.`}function fki(e,i,n){return`${e} is not usually used with ${i} for ${n}.`}function mki(e,i){return`Continuous axis should not have customized aggregation function ${e}; ${i} already agregates the axis.`}function SYe(e){return`1D error band does not support ${e}.`}function Tet(e){return`Channel ${e} is required for "binned" bin.`}function pki(e){return`Channel ${e} should not be used with "binned" bin.`}function bki(e){return`Domain for ${e} is required for threshold scale.`}globalThis&&globalThis.__classPrivateFieldSet;globalThis&&globalThis.__classPrivateFieldGet;const Ret=Zle(vle);let Cw=Ret;function yki(e){return Cw=e,Cw}function vki(){return Cw=Ret,Cw}function ni(...e){Cw.warn(...e)}function Zki(...e){Cw.debug(...e)}function cZ(e){if(e&&vi(e)){for(const i of Mue)if(i in e)return!0}return!1}const Vet=["january","february","march","april","may","june","july","august","september","october","november","december"],Bki=Vet.map(e=>e.substr(0,3)),Eet=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],Gki=Eet.map(e=>e.substr(0,3));function Ski(e){if(IO(e)&&(e=+e),jr(e))return e>4&&ni(R_("quarter",e)),e-1;throw new Error(R_("quarter",e))}function wki(e){if(IO(e)&&(e=+e),jr(e))return e-1;{const i=e.toLowerCase(),n=Vet.indexOf(i);if(n!==-1)return n;const r=i.substr(0,3),o=Bki.indexOf(r);if(o!==-1)return o;throw new Error(R_("month",e))}}function Tki(e){if(IO(e)&&(e=+e),jr(e))return e%7;{const i=e.toLowerCase(),n=Eet.indexOf(i);if(n!==-1)return n;const r=i.substr(0,3),o=Gki.indexOf(r);if(o!==-1)return o;throw new Error(R_("day",e))}}function Due(e,i){const n=[];if(i&&e.day!==void 0&&ei(e).length>1&&(ni(dki(e)),e=vn(e),delete e.day),e.year!==void 0?n.push(e.year):n.push(2012),e.month!==void 0){const r=i?wki(e.month):e.month;n.push(r)}else if(e.quarter!==void 0){const r=i?Ski(e.quarter):e.quarter;n.push(jr(r)?r*3:`${r}*3`)}else n.push(0);if(e.date!==void 0)n.push(e.date);else if(e.day!==void 0){const r=i?Tki(e.day):e.day;n.push(jr(r)?r+1:`${r}+1`)}else n.push(1);for(const r of["hours","minutes","seconds","milliseconds"]){const o=e[r];n.push(typeof o>"u"?0:o)}return n}function Xv(e){const n=Due(e,!0).join(", ");return e.utc?`utc(${n})`:`datetime(${n})`}function Rki(e){const n=Due(e,!1).join(", ");return e.utc?`utc(${n})`:`datetime(${n})`}function Vki(e){const i=Due(e,!0);return e.utc?+new Date(Date.UTC(...i)):+new Date(...i)}const Het={year:1,quarter:1,month:1,week:1,day:1,dayofyear:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1},Mue=ei(Het);function Eki(e){return!!Het[e]}function Fue(e){return e.startsWith("utc")}function Hki(e){return e.substr(3)}const Wki={"year-month":"%b %Y ","year-month-date":"%b %d, %Y "};function pO(e){return Mue.filter(i=>Wet(e,i))}function Nki(e){const i=pO(e);return i[i.length-1]}function Wet(e,i){const n=e.indexOf(i);return!(n<0||n>0&&i==="seconds"&&e.charAt(n-1)==="i"||e.length>n+3&&i==="day"&&e.charAt(n+3)==="o"||n>0&&i==="year"&&e.charAt(n-1)==="f")}function kki(e,i,{end:n}={end:!1}){const r=Sue(i),o=Fue(e)?"utc":"";function l(f){return f==="quarter"?`(${o}quarter(${r})-1)`:`${o}${f}(${r})`}let c;const u={};for(const f of Mue)Wet(e,f)&&(u[f]=l(f),c=f);return n&&(u[c]+="+1"),Rki(u)}function Net(e){if(!e)return;const i=pO(e);return`timeUnitSpecifier(${ug(i)}, ${ug(Wki)})`}function Xki(e,i,n){if(!e)return;const r=Net(e);return`${n||Fue(e)?"utc":"time"}Format(${i}, ${r})`}function Ya(e){if(!e)return;let i;return fi(e)?i={unit:e}:vi(e)&&(i={...e,...e.unit?{unit:e.unit}:{}}),Fue(i.unit)&&(i.utc=!0,i.unit=Hki(i.unit)),i}function xki(e){const{utc:i,...n}=Ya(e);return n.unit?(i?"utc":"")+ei(n).map(r=>Mg(`${r==="unit"?"":`_${r}_`}${n[r]}`)).join(""):(i?"utc":"")+"timeunit"+ei(n).map(r=>Mg(`_${r}_${n[r]}`)).join("")}function ket(e,i=n=>n){const n=Ya(e),r=Nki(n.unit);if(r&&r!=="day"){const o={year:2001,month:1,date:1,hours:0,minutes:0,seconds:0,milliseconds:0},l=n.step||1,c={...o,...r==="quarter"?{month:+o.month+l*3}:{[r]:+o[r]+l}};return`${i(Xv(c))} - ${i(Xv(o))}`}}function Dki(e){return e?.param}function Yue(e){return!!e?.field&&e.equal!==void 0}function Kue(e){return!!e?.field&&e.lt!==void 0}function _ue(e){return!!e?.field&&e.lte!==void 0}function Pue(e){return!!e?.field&&e.gt!==void 0}function zue(e){return!!e?.field&&e.gte!==void 0}function Oue(e){if(e?.field){if(Pt(e.range)&&e.range.length===2)return!0;if(Fi(e.range))return!0}return!1}function Lue(e){return!!e?.field&&(Pt(e.oneOf)||Pt(e.in))}function Mki(e){return!!e?.field&&e.valid!==void 0}function Xet(e){return Lue(e)||Yue(e)||Oue(e)||Kue(e)||Pue(e)||_ue(e)||zue(e)}function wu(e,i){return RO(e,{timeUnit:i,wrapTime:!0})}function Fki(e,i){return e.map(n=>wu(n,i))}function xet(e,i=!0){const{field:n}=e,r=Ya(e.timeUnit)?.unit,o=r?`time(${kki(r,n)})`:di(e,{expr:"datum"});if(Yue(e))return`${o}===${wu(e.equal,r)}`;if(Kue(e)){const l=e.lt;return`${o}<${wu(l,r)}`}else if(Pue(e)){const l=e.gt;return`${o}>${wu(l,r)}`}else if(_ue(e)){const l=e.lte;return`${o}<=${wu(l,r)}`}else if(zue(e)){const l=e.gte;return`${o}>=${wu(l,r)}`}else{if(Lue(e))return`indexof([${Fki(e.oneOf,r).join(",")}], ${o}) !== -1`;if(Mki(e))return Jue(o,e.valid);if(Oue(e)){const{range:l}=e,c=Fi(l)?{signal:`${l.signal}[0]`}:l[0],u=Fi(l)?{signal:`${l.signal}[1]`}:l[1];if(c!==null&&u!==null&&i)return"inrange("+o+", ["+wu(c,r)+", "+wu(u,r)+"])";const f=[];return c!==null&&f.push(`${o} >= ${wu(c,r)}`),u!==null&&f.push(`${o} <= ${wu(u,r)}`),f.length>0?f.join(" && "):"true"}}throw new Error(`Invalid field predicate: ${ug(e)}`)}function Jue(e,i=!0){return i?`isValid(${e}) && isFinite(+${e})`:`!isValid(${e}) || !isFinite(+${e})`}function Yki(e){return Xet(e)&&e.timeUnit?{...e,timeUnit:Ya(e.timeUnit)?.unit}:e}const fN={quantitative:"quantitative",ordinal:"ordinal",temporal:"temporal",nominal:"nominal",geojson:"geojson"};function Kki(e){return e==="quantitative"||e==="temporal"}function Det(e){return e==="ordinal"||e==="nominal"}const xv=fN.quantitative,Uue=fN.ordinal,cw=fN.temporal,Que=fN.nominal,qw=fN.geojson;function _ki(e){if(e)switch(e=e.toLowerCase(),e){case"q":case xv:return"quantitative";case"t":case cw:return"temporal";case"o":case Uue:return"ordinal";case"n":case Que:return"nominal";case qw:return"geojson"}}const rl={LINEAR:"linear",LOG:"log",POW:"pow",SQRT:"sqrt",SYMLOG:"symlog",IDENTITY:"identity",SEQUENTIAL:"sequential",TIME:"time",UTC:"utc",QUANTILE:"quantile",QUANTIZE:"quantize",THRESHOLD:"threshold",BIN_ORDINAL:"bin-ordinal",ORDINAL:"ordinal",POINT:"point",BAND:"band"},gae={linear:"numeric",log:"numeric",pow:"numeric",sqrt:"numeric",symlog:"numeric",identity:"numeric",sequential:"numeric",time:"time",utc:"time",ordinal:"ordinal","bin-ordinal":"bin-ordinal",point:"ordinal-position",band:"ordinal-position",quantile:"discretizing",quantize:"discretizing",threshold:"discretizing"};function Pki(e,i){const n=gae[e],r=gae[i];return n===r||n==="ordinal-position"&&r==="time"||r==="ordinal-position"&&n==="time"}const zki={linear:0,log:1,pow:1,sqrt:1,symlog:1,identity:1,sequential:1,time:0,utc:0,point:10,band:11,ordinal:0,"bin-ordinal":0,quantile:0,quantize:0,threshold:0};function wYe(e){return zki[e]}const Met=new Set(["linear","log","pow","sqrt","symlog"]),Fet=new Set([...Met,"time","utc"]);function Yet(e){return Met.has(e)}const Ket=new Set(["quantile","quantize","threshold"]),Oki=new Set([...Fet,...Ket,"sequential","identity"]),Lki=new Set(["ordinal","bin-ordinal","point","band"]);function fa(e){return Lki.has(e)}function Ul(e){return Oki.has(e)}function CA(e){return Fet.has(e)}function Aw(e){return Ket.has(e)}const Jki={pointPadding:.5,barBandPaddingInner:.1,rectBandPaddingInner:0,bandWithNestedOffsetPaddingInner:.2,bandWithNestedOffsetPaddingOuter:.2,minBandSize:2,minFontSize:8,maxFontSize:40,minOpacity:.3,maxOpacity:.8,minSize:9,minStrokeWidth:1,maxStrokeWidth:4,quantileCount:4,quantizeCount:4,zero:!0};function Uki(e){return!fi(e)&&!!e.name}function _et(e){return e?.param}function Qki(e){return e?.unionWith}function jki(e){return vi(e)&&"field"in e}const $ki={type:1,domain:1,domainMax:1,domainMin:1,domainMid:1,align:1,range:1,rangeMax:1,rangeMin:1,scheme:1,bins:1,reverse:1,round:1,clamp:1,nice:1,base:1,exponent:1,constant:1,interpolate:1,zero:1,padding:1,paddingInner:1,paddingOuter:1},{type:Izi,domain:lzi,range:Czi,rangeMax:czi,rangeMin:Azi,scheme:uzi,...qki}=$ki,eXi=ei(qki);function oae(e,i){switch(i){case"type":case"domain":case"reverse":case"range":return!0;case"scheme":case"interpolate":return!["point","band","identity"].includes(e);case"bins":return!["point","band","identity","ordinal"].includes(e);case"round":return CA(e)||e==="band"||e==="point";case"padding":case"rangeMin":case"rangeMax":return CA(e)||["point","band"].includes(e);case"paddingOuter":case"align":return["point","band"].includes(e);case"paddingInner":return e==="band";case"domainMax":case"domainMid":case"domainMin":case"clamp":return CA(e);case"nice":return CA(e)||e==="quantize"||e==="threshold";case"exponent":return e==="pow";case"base":return e==="log";case"constant":return e==="symlog";case"zero":return Ul(e)&&!jn(["log","time","utc","threshold","quantile"],e)}}function Pet(e,i){switch(i){case"interpolate":case"scheme":case"domainMid":return fS(e)?void 0:jNi(i);case"align":case"type":case"bins":case"domain":case"domainMax":case"domainMin":case"range":case"base":case"exponent":case"constant":case"nice":case"padding":case"paddingInner":case"paddingOuter":case"rangeMax":case"rangeMin":case"reverse":case"round":case"clamp":case"zero":return}}function tXi(e,i){return jn([Uue,Que],i)?e===void 0||fa(e):i===cw?jn([rl.TIME,rl.UTC,void 0],e):i===xv?Yet(e)||Aw(e)||e===void 0:!0}function iXi(e,i,n=!1){if(!Sf(e))return!1;switch(e){case Fg:case da:case u0:case jw:case qC:case WA:return CA(i)||i==="band"?!0:i==="point"?!n:!1;case Bf:case f0:case Gf:case d0:case h0:case IZ:return CA(i)||Aw(i)||jn(["band","point","ordinal"],i);case ll:case Rd:case Vd:return i!=="band";case m0:case Cl:return i==="ordinal"||Aw(i)}}const vI={arc:"arc",area:"area",bar:"bar",image:"image",line:"line",point:"point",rect:"rect",rule:"rule",text:"text",tick:"tick",trail:"trail",circle:"circle",square:"square",geoshape:"geoshape"},zet=vI.arc,bO=vI.area,yO=vI.bar,nXi=vI.image,vO=vI.line,ZO=vI.point,rXi=vI.rect,V_=vI.rule,Oet=vI.text,jue=vI.tick,gXi=vI.trail,$ue=vI.circle,que=vI.square,Let=vI.geoshape;function y0(e){return["line","area","trail"].includes(e)}function Jet(e){return["rect","bar","image","arc"].includes(e)}const oXi=new Set(ei(vI));function fd(e){return e.type}const aXi=["stroke","strokeWidth","strokeDash","strokeDashOffset","strokeOpacity","strokeJoin","strokeMiterLimit"],sXi=["fill","fillOpacity"],IXi=[...aXi,...sXi],lXi={color:1,filled:1,invalid:1,order:1,radius2:1,theta2:1,timeUnitBandSize:1,timeUnitBandPosition:1},TYe=ei(lXi),CXi={area:["line","point"],bar:["binSpacing","continuousBandSize","discreteBandSize"],rect:["binSpacing","continuousBandSize","discreteBandSize"],line:["point"],tick:["bandSize","thickness"]},cXi={color:"#4c78a8",invalid:"filter",timeUnitBandSize:1},AXi={mark:1,arc:1,area:1,bar:1,circle:1,image:1,line:1,point:1,rect:1,rule:1,square:1,text:1,tick:1,trail:1,geoshape:1},Uet=ei(AXi);function Dv(e){return e&&e.band!=null}const uXi={horizontal:["cornerRadiusTopRight","cornerRadiusBottomRight"],vertical:["cornerRadiusTopLeft","cornerRadiusTopRight"]},Qet=5,dXi={binSpacing:1,continuousBandSize:Qet,timeUnitBandPosition:.5},hXi={binSpacing:0,continuousBandSize:Qet,timeUnitBandPosition:.5},fXi={thickness:1};function mXi(e){return fd(e)?e.type:e}function ede(e){const{channel:i,channelDef:n,markDef:r,scale:o,config:l}=e,c=ide(e);return gi(n)&&!cet(n.aggregate)&&o&&CA(o.get("type"))?pXi({fieldDef:n,channel:i,markDef:r,ref:c,config:l}):c}function pXi({fieldDef:e,channel:i,markDef:n,ref:r,config:o}){return y0(n.type)?r:Wr("invalid",n,o)===null?[bXi(e,i),r]:r}function bXi(e,i){const n=tde(e,!0),o=lZ(i)==="y"?{field:{group:"height"}}:{value:0};return{test:n,...o}}function tde(e,i=!0){return Jue(fi(e)?e:di(e,{expr:"datum"}),!i)}function yXi(e){const{datum:i}=e;return cZ(i)?Xv(i):`${ug(i)}`}function jy(e,i,n,r){const o={};if(i&&(o.scale=i),Wd(e)){const{datum:l}=e;cZ(l)?o.signal=Xv(l):Fi(l)?o.signal=l.signal:hN(l)?o.signal=l.expr:o.value=l}else o.field=di(e,n);if(r){const{offset:l,band:c}=r;l&&(o.offset=l),c&&(o.band=c)}return o}function E_({scaleName:e,fieldOrDatumDef:i,fieldOrDatumDef2:n,offset:r,startSuffix:o,bandPosition:l=.5}){const c=0{switch(i.fieldTitle){case"plain":return e.field;case"functional":return NXi(e);default:return WXi(e,i)}};let ltt=Itt;function Ctt(e){ltt=e}function kXi(){Ctt(Itt)}function mS(e,i,{allowDisabling:n,includeDefault:r=!0}){const o=ode(e)?.title;if(!gi(e))return o??e.title;const l=e,c=r?ade(l,i):void 0;return n?Ho(o,l.title,c):o??l.title??c}function ode(e){if(dw(e)&&e.axis)return e.axis;if(att(e)&&e.legend)return e.legend;if(rde(e)&&e.header)return e.header}function ade(e,i){return ltt(e,i)}function N_(e){if(stt(e)){const{format:i,formatType:n}=e;return{format:i,formatType:n}}else{const i=ode(e)??{},{format:n,formatType:r}=i;return{format:n,formatType:r}}}function XXi(e,i){switch(i){case"latitude":case"longitude":return"quantitative";case"row":case"column":case"facet":case"shape":case"strokeDash":return"nominal";case"order":return"ordinal"}if(gde(e)&&Pt(e.sort))return"ordinal";const{aggregate:n,bin:r,timeUnit:o}=e;if(o)return"temporal";if(r||n&&!p0(n)&&!Af(n))return"quantitative";if(AZ(e)&&e.scale?.type)switch(gae[e.scale.type]){case"numeric":case"discretizing":return"quantitative";case"time":return"temporal"}return"nominal"}function md(e){if(gi(e))return e;if(wO(e))return e.condition}function Jo(e){if(yn(e))return e;if(bN(e))return e.condition}function ctt(e,i,n,r={}){if(fi(e)||jr(e)||a0(e)){const o=fi(e)?"string":jr(e)?"number":"boolean";return ni(DNi(i,o,e)),{value:e}}return yn(e)?k_(e,i,n,r):bN(e)?{...e,condition:k_(e.condition,i,n,r)}:e}function k_(e,i,n,r){if(stt(e)){const{format:o,formatType:l,...c}=e;if(Mv(l)&&!n.customFormatTypes)return ni(BYe(i)),k_(c,i,n,r)}else{const o=dw(e)?"axis":att(e)?"legend":rde(e)?"header":null;if(o&&e[o]){const{format:l,formatType:c,...u}=e[o];if(Mv(c)&&!n.customFormatTypes)return ni(BYe(i)),k_({...e,[o]:u},i,n,r)}}return gi(e)?sde(e,i,r):xXi(e)}function xXi(e){let i=e.type;if(i)return e;const{datum:n}=e;return i=jr(n)?"quantitative":fi(n)?"nominal":cZ(n)?"temporal":void 0,{...e,type:i}}function sde(e,i,{compositeMark:n=!1}={}){const{aggregate:r,timeUnit:o,bin:l,field:c}=e,u={...e};if(!n&&r&&!kue(r)&&!p0(r)&&!Af(r)&&(ni(FNi(r)),delete u.aggregate),o&&(u.timeUnit=Ya(o)),c&&(u.field=`${c}`),dg(l)&&(u.bin=TO(l,i)),Ha(l)&&!ha(i)&&ni(pki(i)),mI(u)){const{type:f}=u,m=_ki(f);f!==m&&(u.type=m),f!=="quantitative"&&cet(r)&&(ni(MNi(f,r)),u.type="quantitative")}else if(!ret(i)){const f=XXi(u,i);u.type=f}if(mI(u)){const{compatible:f,warning:m}=DXi(u,i)||{};f===!1&&ni(m)}if(gde(u)&&fi(u.sort)){const{sort:f}=u;if(VYe(f))return{...u,sort:{encoding:f}};const m=f.substr(1);if(f.charAt(0)==="-"&&VYe(m))return{...u,sort:{encoding:m,order:"descending"}}}if(rde(u)){const{header:f}=u;if(f){const{orient:m,...p}=f;if(m)return{...u,header:{...p,labelOrient:f.labelOrient||m,titleOrient:f.titleOrient||m}}}}return u}function TO(e,i){return a0(e)?{maxbins:dYe(i)}:e==="binned"?{binned:!0}:!e.maxbins&&!e.step?{...e,maxbins:dYe(i)}:e}const yG={compatible:!0};function DXi(e,i){const n=e.type;if(n==="geojson"&&i!=="shape")return{compatible:!1,warning:`Channel ${i} should not be used with a geojson data.`};switch(i){case Uh:case Qh:case lO:return W_(e)?yG:{compatible:!1,warning:zNi(i)};case Fg:case da:case u0:case jw:case ll:case Rd:case Vd:case AN:case dN:case CO:case Nv:case cO:case AO:case IZ:case qC:case WA:case uO:return yG;case kA:case jC:case NA:case XA:return n!==xv?{compatible:!1,warning:`Channel ${i} should be used with a quantitative field only, not ${e.type} field.`}:yG;case Gf:case d0:case h0:case f0:case Bf:case Zf:case vf:case HA:case Td:return n==="nominal"&&!e.sort?{compatible:!1,warning:`Channel ${i} should not be used with an unsorted discrete field.`}:yG;case Cl:case m0:return!W_(e)&&!EXi(e)?{compatible:!1,warning:ONi(i)}:yG;case uN:return e.type==="nominal"&&!("sort"in e)?{compatible:!1,warning:"Channel order is inappropriate for nominal field, which has no inherent order."}:yG}}function hw(e){const{formatType:i}=N_(e);return i==="time"||!i&&MXi(e)}function MXi(e){return e&&(e.type==="temporal"||gi(e)&&!!e.timeUnit)}function RO(e,{timeUnit:i,type:n,wrapTime:r,undefinedIfExprNotRequired:o}){const l=i&&Ya(i)?.unit;let c=l||n==="temporal",u;return hN(e)?u=e.expr:Fi(e)?u=e.signal:cZ(e)?(c=!0,u=Xv(e)):(fi(e)||jr(e))&&c&&(u=`datetime(${ug(e)})`,Eki(l)&&(jr(e)&&e<1e4||fi(e)&&isNaN(Date.parse(e)))&&(u=Xv({[l]:e}))),u?r&&c?`time(${u})`:u:o?void 0:ug(e)}function Att(e,i){const{type:n}=e;return i.map(r=>{const o=RO(r,{timeUnit:gi(e)?e.timeUnit:void 0,type:n,undefinedIfExprNotRequired:!0});return o!==void 0?{signal:o}:r})}function yN(e,i){return dg(e.bin)?Sf(i)&&["ordinal","nominal"].includes(e.type):(console.warn("Only call this method for binned field defs."),!1)}const WYe={labelAlign:{part:"labels",vgProp:"align"},labelBaseline:{part:"labels",vgProp:"baseline"},labelColor:{part:"labels",vgProp:"fill"},labelFont:{part:"labels",vgProp:"font"},labelFontSize:{part:"labels",vgProp:"fontSize"},labelFontStyle:{part:"labels",vgProp:"fontStyle"},labelFontWeight:{part:"labels",vgProp:"fontWeight"},labelOpacity:{part:"labels",vgProp:"opacity"},labelOffset:null,labelPadding:null,gridColor:{part:"grid",vgProp:"stroke"},gridDash:{part:"grid",vgProp:"strokeDash"},gridDashOffset:{part:"grid",vgProp:"strokeDashOffset"},gridOpacity:{part:"grid",vgProp:"opacity"},gridWidth:{part:"grid",vgProp:"strokeWidth"},tickColor:{part:"ticks",vgProp:"stroke"},tickDash:{part:"ticks",vgProp:"strokeDash"},tickDashOffset:{part:"ticks",vgProp:"strokeDashOffset"},tickOpacity:{part:"ticks",vgProp:"opacity"},tickSize:null,tickWidth:{part:"ticks",vgProp:"strokeWidth"}};function vN(e){return e?.condition}const utt=["domain","grid","labels","ticks","title"],FXi={grid:"grid",gridCap:"grid",gridColor:"grid",gridDash:"grid",gridDashOffset:"grid",gridOpacity:"grid",gridScale:"grid",gridWidth:"grid",orient:"main",bandPosition:"both",aria:"main",description:"main",domain:"main",domainCap:"main",domainColor:"main",domainDash:"main",domainDashOffset:"main",domainOpacity:"main",domainWidth:"main",format:"main",formatType:"main",labelAlign:"main",labelAngle:"main",labelBaseline:"main",labelBound:"main",labelColor:"main",labelFlush:"main",labelFlushOffset:"main",labelFont:"main",labelFontSize:"main",labelFontStyle:"main",labelFontWeight:"main",labelLimit:"main",labelLineHeight:"main",labelOffset:"main",labelOpacity:"main",labelOverlap:"main",labelPadding:"main",labels:"main",labelSeparation:"main",maxExtent:"main",minExtent:"main",offset:"both",position:"main",tickCap:"main",tickColor:"main",tickDash:"main",tickDashOffset:"main",tickMinStep:"both",tickOffset:"both",tickOpacity:"main",tickRound:"both",ticks:"main",tickSize:"main",tickWidth:"both",title:"main",titleAlign:"main",titleAnchor:"main",titleAngle:"main",titleBaseline:"main",titleColor:"main",titleFont:"main",titleFontSize:"main",titleFontStyle:"main",titleFontWeight:"main",titleLimit:"main",titleLineHeight:"main",titleOpacity:"main",titlePadding:"main",titleX:"main",titleY:"main",encode:"both",scale:"both",tickBand:"both",tickCount:"both",tickExtra:"both",translate:"both",values:"both",zindex:"both"},dtt={orient:1,aria:1,bandPosition:1,description:1,domain:1,domainCap:1,domainColor:1,domainDash:1,domainDashOffset:1,domainOpacity:1,domainWidth:1,format:1,formatType:1,grid:1,gridCap:1,gridColor:1,gridDash:1,gridDashOffset:1,gridOpacity:1,gridWidth:1,labelAlign:1,labelAngle:1,labelBaseline:1,labelBound:1,labelColor:1,labelFlush:1,labelFlushOffset:1,labelFont:1,labelFontSize:1,labelFontStyle:1,labelFontWeight:1,labelLimit:1,labelLineHeight:1,labelOffset:1,labelOpacity:1,labelOverlap:1,labelPadding:1,labels:1,labelSeparation:1,maxExtent:1,minExtent:1,offset:1,position:1,tickBand:1,tickCap:1,tickColor:1,tickCount:1,tickDash:1,tickDashOffset:1,tickExtra:1,tickMinStep:1,tickOffset:1,tickOpacity:1,tickRound:1,ticks:1,tickSize:1,tickWidth:1,title:1,titleAlign:1,titleAnchor:1,titleAngle:1,titleBaseline:1,titleColor:1,titleFont:1,titleFontSize:1,titleFontStyle:1,titleFontWeight:1,titleLimit:1,titleLineHeight:1,titleOpacity:1,titlePadding:1,titleX:1,titleY:1,translate:1,values:1,zindex:1},YXi={...dtt,style:1,labelExpr:1,encoding:1};function NYe(e){return!!YXi[e]}const KXi={axis:1,axisBand:1,axisBottom:1,axisDiscrete:1,axisLeft:1,axisPoint:1,axisQuantitative:1,axisRight:1,axisTemporal:1,axisTop:1,axisX:1,axisXBand:1,axisXDiscrete:1,axisXPoint:1,axisXQuantitative:1,axisXTemporal:1,axisY:1,axisYBand:1,axisYDiscrete:1,axisYPoint:1,axisYQuantitative:1,axisYTemporal:1},htt=ei(KXi);function wf(e){return"mark"in e}class VO{constructor(i,n){this.name=i,this.run=n}hasMatchingType(i){return wf(i)?mXi(i.mark)===this.name:!1}}function $y(e,i){const n=e&&e[i];return n?Pt(n)?Hv(n,r=>!!r.field):gi(n)||wO(n):!1}function ftt(e,i){const n=e&&e[i];return n?Pt(n)?Hv(n,r=>!!r.field):gi(n)||Wd(n)||bN(n):!1}function sae(e,i){if(ha(i)){const n=e[i];if((gi(n)||Wd(n))&&(Det(n.type)||gi(n)&&n.timeUnit)){const r=Eue(i);return ftt(e,r)}}return!1}function Ide(e){return Hv(zWi,i=>{if($y(e,i)){const n=e[i];if(Pt(n))return Hv(n,r=>!!r.aggregate);{const r=md(n);return r&&!!r.aggregate}}return!1})}function mtt(e,i){const n=[],r=[],o=[],l=[],c={};return lde(e,(u,f)=>{if(gi(u)){const{field:m,aggregate:p,bin:v,timeUnit:B,...G}=u;if(p||B||v){const V=ode(u)?.title;let E=di(u,{forAs:!0});const W={...V?[]:{title:mS(u,i,{allowDisabling:!0})},...G,field:E};if(p){let x;if(p0(p)?(x="argmax",E=di({op:"argmax",field:p.argmax},{forAs:!0}),W.field=`${E}.${m}`):Af(p)?(x="argmin",E=di({op:"argmin",field:p.argmin},{forAs:!0}),W.field=`${E}.${m}`):p!=="boxplot"&&p!=="errorbar"&&p!=="errorband"&&(x=p),x){const k={op:x,as:E};m&&(k.field=m),l.push(k)}}else if(n.push(E),mI(u)&&dg(v)){if(r.push({bin:v,field:m,as:E}),n.push(di(u,{binSuffix:"end"})),yN(u,f)&&n.push(di(u,{binSuffix:"range"})),ha(f)){const x={field:`${E}_end`};c[`${f}2`]=x}W.bin="binned",ret(f)||(W.type=xv)}else if(B){o.push({timeUnit:B,field:m,as:E});const x=mI(u)&&u.type!==cw&&"time";x&&(f===AN||f===Nv?W.formatType=x:eNi(f)?W.legend={formatType:x,...W.legend}:ha(f)&&(W.axis={formatType:x,...W.axis}))}c[f]=W}else n.push(m),c[f]=e[f]}else c[f]=e[f]}),{bins:r,timeUnits:o,aggregate:l,groupby:n,encoding:c}}function _Xi(e,i,n){const r=iNi(i,n);if(r){if(r==="binned"){const o=e[i===HA?Fg:da];return!!(gi(o)&&gi(e[i])&&Ha(o.bin))}}else return!1;return!0}function PXi(e,i,n,r){const o={};for(const l of ei(e))net(l)||ni(PNi(l));for(let l of QWi){if(!e[l])continue;const c=e[l];if($w(l)){const u=oet(l),f=o[u];if(gi(f)){if(Kki(f.type)&&gi(c)&&!f.timeUnit){ni(XNi(u));continue}}else l=u,ni(xNi(u))}if(l==="angle"&&i==="arc"&&!e.theta&&(ni(kNi),l=qC),!_Xi(e,l,i)){ni(mO(l,i));continue}if(l===Bf&&i==="line"&&md(e[l])?.aggregate){ni(KNi);continue}if(l===ll&&(n?"fill"in e:"stroke"in e)){ni(Bet("encoding",{fill:"fill"in e,stroke:"stroke"in e}));continue}if(l===dN||l===uN&&!Pt(c)&&!wA(c)||l===Nv&&Pt(c))c&&(o[l]=pi(c).reduce((u,f)=>(gi(f)?u.push(sde(f,l)):ni(rae(f,l)),u),[]));else{if(l===Nv&&c===null)o[l]=null;else if(!gi(c)&&!Wd(c)&&!wA(c)&&!SO(c)&&!Fi(c)){ni(rae(c,l));continue}o[l]=ctt(c,l,r)}}return o}function EO(e,i){const n={};for(const r of ei(e)){const o=ctt(e[r],r,i,{compositeMark:!0});n[r]=o}return n}function zXi(e){const i=[];for(const n of ei(e))if($y(e,n)){const r=e[n],o=pi(r);for(const l of o)gi(l)?i.push(l):wO(l)&&i.push(l.condition)}return i}function lde(e,i,n){if(e)for(const r of ei(e)){const o=e[r];if(Pt(o))for(const l of o)i.call(n,l,r);else i.call(n,o,r)}}function OXi(e,i,n,r){return e?ei(e).reduce((o,l)=>{const c=e[l];return Pt(c)?c.reduce((u,f)=>i.call(r,u,f,l),o):i.call(r,o,c,l)},n):n}function ptt(e,i){return ei(i).reduce((n,r)=>{switch(r){case Fg:case da:case cO:case uO:case AO:case HA:case Td:case u0:case jw:case qC:case Zf:case WA:case vf:case NA:case kA:case XA:case jC:case AN:case Cl:case IZ:case Nv:return n;case uN:if(e==="line"||e==="trail")return n;case dN:case CO:{const o=i[r];if(Pt(o)||gi(o))for(const l of pi(o))l.aggregate||n.push(di(l,{}));return n}case Bf:if(e==="trail")return n;case ll:case Rd:case Vd:case Gf:case d0:case h0:case m0:case f0:{const o=md(i[r]);return o&&!o.aggregate&&n.push(di(o,{})),n}}},[])}function LXi(e){const{tooltip:i,...n}=e;if(!i)return{filteredEncoding:n};let r,o;if(Pt(i)){for(const l of i)l.aggregate?(r||(r=[]),r.push(l)):(o||(o=[]),o.push(l));r&&(n.tooltip=r)}else i.aggregate?n.tooltip=i:o=i;return Pt(o)&&o.length===1&&(o=o[0]),{customTooltipWithoutAggregatedField:o,filteredEncoding:n}}function Iae(e,i,n,r=!0){if("tooltip"in n)return{tooltip:n.tooltip};const o=e.map(({fieldPrefix:c,titlePrefix:u})=>{const f=r?` of ${Cde(i)}`:"";return{field:c+i.field,type:i.type,title:Fi(u)?{signal:`${u}"${escape(f)}"`}:u+f}}),l=zXi(n).map(RXi);return{tooltip:[...o,..._u(l,Ir)]}}function Cde(e){const{title:i,field:n}=e;return Ho(i,n)}function cde(e,i,n,r,o){const{scale:l,axis:c}=n;return({partName:u,mark:f,positionPrefix:m,endPositionPrefix:p=void 0,extraEncoding:v={}})=>{const B=Cde(n);return btt(e,u,o,{mark:f,encoding:{[i]:{field:`${m}_${n.field}`,type:n.type,...B!==void 0?{title:B}:{},...l!==void 0?{scale:l}:{},...c!==void 0?{axis:c}:{}},...fi(p)?{[`${i}2`]:{field:`${p}_${n.field}`}}:{},...r,...v}})}}function btt(e,i,n,r){const{clip:o,color:l,opacity:c}=e,u=e.type;return e[i]||e[i]===void 0&&n[i]?[{...r,mark:{...n[i],...o?{clip:o}:{},...l?{color:l}:{},...c?{opacity:c}:{},...fd(r.mark)?r.mark:{type:r.mark},style:`${u}-${String(i)}`,...a0(e[i])?{}:e[i]}}]:[]}function ytt(e,i,n){const{encoding:r}=e,o=i==="vertical"?"y":"x",l=r[o],c=r[`${o}2`],u=r[`${o}Error`],f=r[`${o}Error2`];return{continuousAxisChannelDef:OF(l,n),continuousAxisChannelDef2:OF(c,n),continuousAxisChannelDefError:OF(u,n),continuousAxisChannelDefError2:OF(f,n),continuousAxis:o}}function OF(e,i){if(e?.aggregate){const{aggregate:n,...r}=e;return n!==i&&ni(mki(n,i)),r}else return e}function vtt(e,i){const{mark:n,encoding:r}=e,{x:o,y:l}=r;if(fd(n)&&n.orient)return n.orient;if(Ap(o)){if(Ap(l)){const c=gi(o)&&o.aggregate,u=gi(l)&&l.aggregate;if(!c&&u===i)return"vertical";if(!u&&c===i)return"horizontal";if(c===i&&u===i)throw new Error("Both x and y cannot have aggregate");return hw(l)&&!hw(o)?"horizontal":"vertical"}return"horizontal"}else{if(Ap(l))return"vertical";throw new Error(`Need a valid continuous axis for ${i}s`)}}const X_="boxplot",JXi=["box","median","outliers","rule","ticks"],UXi=new VO(X_,Btt);function Ztt(e){return jr(e)?"tukey":e}function Btt(e,{config:i}){e={...e,encoding:EO(e.encoding,i)};const{mark:n,encoding:r,params:o,projection:l,...c}=e,u=fd(n)?n:{type:n};o&&ni(vet("boxplot"));const f=u.extent??i.boxplot.extent,m=Wr("size",u,i),p=u.invalid,v=Ztt(f),{bins:B,timeUnits:G,transform:T,continuousAxisChannelDef:V,continuousAxis:E,groupby:W,aggregate:x,encodingWithoutContinuousAxis:k,ticksOrient:F,boxOrient:Y,customTooltipWithoutAggregatedField:L}=QXi(e,f,i),{color:O,size:Q,...X}=k,$=Kt=>cde(u,E,V,Kt,i.boxplot),ee=$(X),ne=$(k),ge=$({...X,...Q?{size:Q}:{}}),Ae=Iae([{fieldPrefix:v==="min-max"?"upper_whisker_":"max_",titlePrefix:"Max"},{fieldPrefix:"upper_box_",titlePrefix:"Q3"},{fieldPrefix:"mid_box_",titlePrefix:"Median"},{fieldPrefix:"lower_box_",titlePrefix:"Q1"},{fieldPrefix:v==="min-max"?"lower_whisker_":"min_",titlePrefix:"Min"}],V,k),_={type:"tick",color:"black",opacity:1,orient:F,invalid:p,aria:!1},de=v==="min-max"?Ae:Iae([{fieldPrefix:"upper_whisker_",titlePrefix:"Upper Whisker"},{fieldPrefix:"lower_whisker_",titlePrefix:"Lower Whisker"}],V,k),Ze=[...ee({partName:"rule",mark:{type:"rule",invalid:p,aria:!1},positionPrefix:"lower_whisker",endPositionPrefix:"lower_box",extraEncoding:de}),...ee({partName:"rule",mark:{type:"rule",invalid:p,aria:!1},positionPrefix:"upper_box",endPositionPrefix:"upper_whisker",extraEncoding:de}),...ee({partName:"ticks",mark:_,positionPrefix:"lower_whisker",extraEncoding:de}),...ee({partName:"ticks",mark:_,positionPrefix:"upper_whisker",extraEncoding:de})],me=[...v!=="tukey"?Ze:[],...ne({partName:"box",mark:{type:"bar",...m?{size:m}:{},orient:Y,invalid:p,ariaRoleDescription:"box"},positionPrefix:"lower_box",endPositionPrefix:"upper_box",extraEncoding:Ae}),...ge({partName:"median",mark:{type:"tick",invalid:p,...vi(i.boxplot.median)&&i.boxplot.median.color?{color:i.boxplot.median.color}:{},...m?{size:m}:{},orient:F,aria:!1},positionPrefix:"mid_box",extraEncoding:Ae})];if(v==="min-max")return{...c,transform:(c.transform??[]).concat(T),layer:me};const be=`datum["lower_box_${V.field}"]`,Ee=`datum["upper_box_${V.field}"]`,Je=`(${Ee} - ${be})`,Ue=`${be} - ${f} * ${Je}`,dt=`${Ee} + ${f} * ${Je}`,rt=`datum["${V.field}"]`,ke={joinaggregate:Gtt(V.field),groupby:W},ze={transform:[{filter:`(${Ue} <= ${rt}) && (${rt} <= ${dt})`},{aggregate:[{op:"min",field:V.field,as:`lower_whisker_${V.field}`},{op:"max",field:V.field,as:`upper_whisker_${V.field}`},{op:"min",field:`lower_box_${V.field}`,as:`lower_box_${V.field}`},{op:"max",field:`upper_box_${V.field}`,as:`upper_box_${V.field}`},...x],groupby:W}],layer:Ze},{tooltip:je,...lt}=X,{scale:xe,axis:it}=V,Ct=Cde(V),It=nl(it,["title"]),Et=btt(u,"outliers",i.boxplot,{transform:[{filter:`(${rt} < ${Ue}) || (${rt} > ${dt})`}],mark:"point",encoding:{[E]:{field:V.field,type:V.type,...Ct!==void 0?{title:Ct}:{},...xe!==void 0?{scale:xe}:{},...Qr(It)?{}:{axis:It}},...lt,...O?{color:O}:{},...L?{tooltip:L}:{}}})[0];let Zt;const zt=[...B,...G,ke];return Et?Zt={transform:zt,layer:[Et,ze]}:(Zt=ze,Zt.transform.unshift(...zt)),{...c,layer:[Zt,{transform:T,layer:me}]}}function Gtt(e){return[{op:"q1",field:e,as:`lower_box_${e}`},{op:"q3",field:e,as:`upper_box_${e}`}]}function QXi(e,i,n){const r=vtt(e,X_),{continuousAxisChannelDef:o,continuousAxis:l}=ytt(e,r,X_),c=o.field,u=Ztt(i),f=[...Gtt(c),{op:"median",field:c,as:`mid_box_${c}`},{op:"min",field:c,as:(u==="min-max"?"lower_whisker_":"min_")+c},{op:"max",field:c,as:(u==="min-max"?"upper_whisker_":"max_")+c}],m=u==="min-max"||u==="tukey"?[]:[{calculate:`datum["upper_box_${c}"] - datum["lower_box_${c}"]`,as:`iqr_${c}`},{calculate:`min(datum["upper_box_${c}"] + datum["iqr_${c}"] * ${i}, datum["max_${c}"])`,as:`upper_whisker_${c}`},{calculate:`max(datum["lower_box_${c}"] - datum["iqr_${c}"] * ${i}, datum["min_${c}"])`,as:`lower_whisker_${c}`}],{[l]:p,...v}=e.encoding,{customTooltipWithoutAggregatedField:B,filteredEncoding:G}=LXi(v),{bins:T,timeUnits:V,aggregate:E,groupby:W,encoding:x}=mtt(G,n),k=r==="vertical"?"horizontal":"vertical",F=r,Y=[...T,...V,{aggregate:[...E,...f],groupby:W},...m];return{bins:T,timeUnits:V,transform:Y,groupby:W,aggregate:E,continuousAxisChannelDef:o,continuousAxis:l,encodingWithoutContinuousAxis:x,ticksOrient:k,boxOrient:F,customTooltipWithoutAggregatedField:B}}const Ade="errorbar",jXi=["ticks","rule"],$Xi=new VO(Ade,Stt);function Stt(e,{config:i}){e={...e,encoding:EO(e.encoding,i)};const{transform:n,continuousAxisChannelDef:r,continuousAxis:o,encodingWithoutContinuousAxis:l,ticksOrient:c,markDef:u,outerSpec:f,tooltipEncoding:m}=wtt(e,Ade,i);delete l.size;const p=cde(u,o,r,l,i.errorbar),v=u.thickness,B=u.size,G={type:"tick",orient:c,aria:!1,...v!==void 0?{thickness:v}:{},...B!==void 0?{size:B}:{}},T=[...p({partName:"ticks",mark:G,positionPrefix:"lower",extraEncoding:m}),...p({partName:"ticks",mark:G,positionPrefix:"upper",extraEncoding:m}),...p({partName:"rule",mark:{type:"rule",ariaRoleDescription:"errorbar",...v!==void 0?{size:v}:{}},positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:m})];return{...f,transform:n,...T.length>1?{layer:T}:{...T[0]}}}function qXi(e,i){const{encoding:n}=e;if(exi(n))return{orient:vtt(e,i),inputType:"raw"};const r=txi(n),o=ixi(n),l=n.x,c=n.y;if(r){if(o)throw new Error(`${i} cannot be both type aggregated-upper-lower and aggregated-error`);const u=n.x2,f=n.y2;if(yn(u)&&yn(f))throw new Error(`${i} cannot have both x2 and y2`);if(yn(u)){if(Ap(l))return{orient:"horizontal",inputType:"aggregated-upper-lower"};throw new Error(`Both x and x2 have to be quantitative in ${i}`)}else if(yn(f)){if(Ap(c))return{orient:"vertical",inputType:"aggregated-upper-lower"};throw new Error(`Both y and y2 have to be quantitative in ${i}`)}throw new Error("No ranged axis")}else{const u=n.xError,f=n.xError2,m=n.yError,p=n.yError2;if(yn(f)&&!yn(u))throw new Error(`${i} cannot have xError2 without xError`);if(yn(p)&&!yn(m))throw new Error(`${i} cannot have yError2 without yError`);if(yn(u)&&yn(m))throw new Error(`${i} cannot have both xError and yError with both are quantiative`);if(yn(u)){if(Ap(l))return{orient:"horizontal",inputType:"aggregated-error"};throw new Error("All x, xError, and xError2 (if exist) have to be quantitative")}else if(yn(m)){if(Ap(c))return{orient:"vertical",inputType:"aggregated-error"};throw new Error("All y, yError, and yError2 (if exist) have to be quantitative")}throw new Error("No ranged axis")}}function exi(e){return(yn(e.x)||yn(e.y))&&!yn(e.x2)&&!yn(e.y2)&&!yn(e.xError)&&!yn(e.xError2)&&!yn(e.yError)&&!yn(e.yError2)}function txi(e){return yn(e.x2)||yn(e.y2)}function ixi(e){return yn(e.xError)||yn(e.xError2)||yn(e.yError)||yn(e.yError2)}function wtt(e,i,n){const{mark:r,encoding:o,params:l,projection:c,...u}=e,f=fd(r)?r:{type:r};l&&ni(vet(i));const{orient:m,inputType:p}=qXi(e,i),{continuousAxisChannelDef:v,continuousAxisChannelDef2:B,continuousAxisChannelDefError:G,continuousAxisChannelDefError2:T,continuousAxis:V}=ytt(e,m,i),{errorBarSpecificAggregate:E,postAggregateCalculates:W,tooltipSummary:x,tooltipTitleWithFieldName:k}=nxi(f,v,B,G,T,p,i,n),{[V]:F,[V==="x"?"x2":"y2"]:Y,[V==="x"?"xError":"yError"]:L,[V==="x"?"xError2":"yError2"]:O,...Q}=o,{bins:X,timeUnits:$,aggregate:ee,groupby:ne,encoding:ge}=mtt(Q,n),Ae=[...ee,...E],_=p!=="raw"?[]:ne,de=Iae(x,v,ge,k);return{transform:[...u.transform??[],...X,...$,...Ae.length===0?[]:[{aggregate:Ae,groupby:_}],...W],groupby:_,continuousAxisChannelDef:v,continuousAxis:V,encodingWithoutContinuousAxis:ge,ticksOrient:m==="vertical"?"horizontal":"vertical",markDef:f,outerSpec:u,tooltipEncoding:de}}function nxi(e,i,n,r,o,l,c,u){let f=[],m=[];const p=i.field;let v,B=!1;if(l==="raw"){const G=e.center?e.center:e.extent?e.extent==="iqr"?"median":"mean":u.errorbar.center,T=e.extent?e.extent:G==="mean"?"stderr":"iqr";if(G==="median"!=(T==="iqr")&&ni(fki(G,T,c)),T==="stderr"||T==="stdev")f=[{op:T,field:p,as:`extent_${p}`},{op:G,field:p,as:`center_${p}`}],m=[{calculate:`datum["center_${p}"] + datum["extent_${p}"]`,as:`upper_${p}`},{calculate:`datum["center_${p}"] - datum["extent_${p}"]`,as:`lower_${p}`}],v=[{fieldPrefix:"center_",titlePrefix:cN(G)},{fieldPrefix:"upper_",titlePrefix:kYe(G,T,"+")},{fieldPrefix:"lower_",titlePrefix:kYe(G,T,"-")}],B=!0;else{let V,E,W;T==="ci"?(V="mean",E="ci0",W="ci1"):(V="median",E="q1",W="q3"),f=[{op:E,field:p,as:`lower_${p}`},{op:W,field:p,as:`upper_${p}`},{op:V,field:p,as:`center_${p}`}],v=[{fieldPrefix:"upper_",titlePrefix:mS({field:p,aggregate:W,type:"quantitative"},u,{allowDisabling:!1})},{fieldPrefix:"lower_",titlePrefix:mS({field:p,aggregate:E,type:"quantitative"},u,{allowDisabling:!1})},{fieldPrefix:"center_",titlePrefix:mS({field:p,aggregate:V,type:"quantitative"},u,{allowDisabling:!1})}]}}else{(e.center||e.extent)&&ni(hki(e.center,e.extent)),l==="aggregated-upper-lower"?(v=[],m=[{calculate:`datum["${n.field}"]`,as:`upper_${p}`},{calculate:`datum["${p}"]`,as:`lower_${p}`}]):l==="aggregated-error"&&(v=[{fieldPrefix:"",titlePrefix:p}],m=[{calculate:`datum["${p}"] + datum["${r.field}"]`,as:`upper_${p}`}],o?m.push({calculate:`datum["${p}"] + datum["${o.field}"]`,as:`lower_${p}`}):m.push({calculate:`datum["${p}"] - datum["${r.field}"]`,as:`lower_${p}`}));for(const G of m)v.push({fieldPrefix:G.as.substring(0,6),titlePrefix:Wv(Wv(G.calculate,'datum["',""),'"]',"")})}return{postAggregateCalculates:m,errorBarSpecificAggregate:f,tooltipSummary:v,tooltipTitleWithFieldName:B}}function kYe(e,i,n){return`${cN(e)} ${n} ${i}`}const ude="errorband",rxi=["band","borders"],gxi=new VO(ude,Ttt);function Ttt(e,{config:i}){e={...e,encoding:EO(e.encoding,i)};const{transform:n,continuousAxisChannelDef:r,continuousAxis:o,encodingWithoutContinuousAxis:l,markDef:c,outerSpec:u,tooltipEncoding:f}=wtt(e,ude,i),m=c,p=cde(m,o,r,l,i.errorband),v=e.encoding.x!==void 0&&e.encoding.y!==void 0;let B={type:v?"area":"rect"},G={type:v?"line":"rule"};const T={...m.interpolate?{interpolate:m.interpolate}:{},...m.tension&&m.interpolate?{tension:m.tension}:{}};return v?(B={...B,...T,ariaRoleDescription:"errorband"},G={...G,...T,aria:!1}):m.interpolate?ni(SYe("interpolate")):m.tension&&ni(SYe("tension")),{...u,transform:n,layer:[...p({partName:"band",mark:B,positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:f}),...p({partName:"borders",mark:G,positionPrefix:"lower",extraEncoding:f}),...p({partName:"borders",mark:G,positionPrefix:"upper",extraEncoding:f})]}}const Rtt={};function dde(e,i,n){const r=new VO(e,i);Rtt[e]={normalizer:r,parts:n}}function oxi(){return ei(Rtt)}dde(X_,Btt,JXi);dde(Ade,Stt,jXi);dde(ude,Ttt,rxi);const axi=["gradientHorizontalMaxLength","gradientHorizontalMinLength","gradientVerticalMaxLength","gradientVerticalMinLength","unselectedOpacity"],Vtt={titleAlign:"align",titleAnchor:"anchor",titleAngle:"angle",titleBaseline:"baseline",titleColor:"color",titleFont:"font",titleFontSize:"fontSize",titleFontStyle:"fontStyle",titleFontWeight:"fontWeight",titleLimit:"limit",titleLineHeight:"lineHeight",titleOrient:"orient",titlePadding:"offset"},Ett={labelAlign:"align",labelAnchor:"anchor",labelAngle:"angle",labelBaseline:"baseline",labelColor:"color",labelFont:"font",labelFontSize:"fontSize",labelFontStyle:"fontStyle",labelFontWeight:"fontWeight",labelLimit:"limit",labelLineHeight:"lineHeight",labelOrient:"orient",labelPadding:"offset"},sxi=ei(Vtt),Ixi=ei(Ett),lxi={header:1,headerRow:1,headerColumn:1,headerFacet:1},Htt=ei(lxi),Wtt=["size","shape","fill","stroke","strokeDash","strokeWidth","opacity"],Cxi={gradientHorizontalMaxLength:200,gradientHorizontalMinLength:100,gradientVerticalMaxLength:200,gradientVerticalMinLength:64,unselectedOpacity:.35},cxi={aria:1,clipHeight:1,columnPadding:1,columns:1,cornerRadius:1,description:1,direction:1,fillColor:1,format:1,formatType:1,gradientLength:1,gradientOpacity:1,gradientStrokeColor:1,gradientStrokeWidth:1,gradientThickness:1,gridAlign:1,labelAlign:1,labelBaseline:1,labelColor:1,labelFont:1,labelFontSize:1,labelFontStyle:1,labelFontWeight:1,labelLimit:1,labelOffset:1,labelOpacity:1,labelOverlap:1,labelPadding:1,labelSeparation:1,legendX:1,legendY:1,offset:1,orient:1,padding:1,rowPadding:1,strokeColor:1,symbolDash:1,symbolDashOffset:1,symbolFillColor:1,symbolLimit:1,symbolOffset:1,symbolOpacity:1,symbolSize:1,symbolStrokeColor:1,symbolStrokeWidth:1,symbolType:1,tickCount:1,tickMinStep:1,title:1,titleAlign:1,titleAnchor:1,titleBaseline:1,titleColor:1,titleFont:1,titleFontSize:1,titleFontStyle:1,titleFontWeight:1,titleLimit:1,titleLineHeight:1,titleOpacity:1,titleOrient:1,titlePadding:1,type:1,values:1,zindex:1},TA="_vgsid_",Axi={point:{on:"click",fields:[TA],toggle:"event.shiftKey",resolve:"global",clear:"dblclick"},interval:{on:"[mousedown, window:mouseup] > window:mousemove!",encodings:["x","y"],translate:"[mousedown, window:mouseup] > window:mousemove!",zoom:"wheel!",mark:{fill:"#333",fillOpacity:.125,stroke:"white"},resolve:"global",clear:"dblclick"}};function hde(e){return e==="legend"||!!e?.legend}function Qte(e){return hde(e)&&vi(e)}function fde(e){return!!e?.select}function Ntt(e){const i=[];for(const n of e||[]){if(fde(n))continue;const{expr:r,bind:o,...l}=n;if(o&&r){const c={...l,bind:o,init:r};i.push(c)}else{const c={...l,...r?{update:r}:{},...o?{bind:o}:{}};i.push(c)}}return i}function uxi(e){return HO(e)||pde(e)||mde(e)}function mde(e){return"concat"in e}function HO(e){return"vconcat"in e}function pde(e){return"hconcat"in e}function ktt({step:e,offsetIsDiscrete:i}){return i?e.for??"offset":"position"}function pd(e){return vi(e)&&e.step!==void 0}function XYe(e){return e.view||e.width||e.height}const xYe=20,dxi={align:1,bounds:1,center:1,columns:1,spacing:1},hxi=ei(dxi);function fxi(e,i,n){const r=n[i],o={},{spacing:l,columns:c}=r;l!==void 0&&(o.spacing=l),c!==void 0&&(GO(e)&&!pN(e.facet)||mde(e))&&(o.columns=c),HO(e)&&(o.columns=1);for(const u of hxi)if(e[u]!==void 0)if(u==="spacing"){const f=e[u];o[u]=jr(f)?f:{row:f.row??l,column:f.column??l}}else o[u]=e[u];return o}function lae(e,i){return e[i]??e[i==="width"?"continuousWidth":"continuousHeight"]}function x_(e,i){const n=D_(e,i);return pd(n)?n.step:Xtt}function D_(e,i){const n=e[i]??e[i==="width"?"discreteWidth":"discreteHeight"];return Ho(n,{step:e.step})}const Xtt=20,mxi={continuousWidth:200,continuousHeight:200,step:Xtt},pxi={background:"white",padding:5,timeFormat:"%b %d, %Y",countTitle:"Count of Records",view:mxi,mark:cXi,arc:{},area:{},bar:dXi,circle:{},geoshape:{},image:{},line:{},point:{},rect:hXi,rule:{color:"black"},square:{},text:{color:"black"},tick:fXi,trail:{},boxplot:{size:14,extent:1.5,box:{},median:{color:"white"},outliers:{},rule:{},ticks:null},errorbar:{center:"mean",rule:!0,ticks:!1},errorband:{band:{opacity:.3},borders:!1},scale:Jki,projection:{},legend:Cxi,header:{titlePadding:10,labelPadding:10},headerColumn:{},headerRow:{},headerFacet:{},selection:Axi,style:{},title:{},facet:{spacing:xYe},concat:{spacing:xYe},normalizedNumberFormat:".0%"},bh=["#4c78a8","#f58518","#e45756","#72b7b2","#54a24b","#eeca3b","#b279a2","#ff9da6","#9d755d","#bab0ac"],DYe={text:11,guideLabel:10,guideTitle:11,groupTitle:13,groupSubtitle:12},MYe={blue:bh[0],orange:bh[1],red:bh[2],teal:bh[3],green:bh[4],yellow:bh[5],purple:bh[6],pink:bh[7],brown:bh[8],gray0:"#000",gray1:"#111",gray2:"#222",gray3:"#333",gray4:"#444",gray5:"#555",gray6:"#666",gray7:"#777",gray8:"#888",gray9:"#999",gray10:"#aaa",gray11:"#bbb",gray12:"#ccc",gray13:"#ddd",gray14:"#eee",gray15:"#fff"};function bxi(e={}){return{signals:[{name:"color",value:vi(e)?{...MYe,...e}:MYe}],mark:{color:{signal:"color.blue"}},rule:{color:{signal:"color.gray0"}},text:{color:{signal:"color.gray0"}},style:{"guide-label":{fill:{signal:"color.gray0"}},"guide-title":{fill:{signal:"color.gray0"}},"group-title":{fill:{signal:"color.gray0"}},"group-subtitle":{fill:{signal:"color.gray0"}},cell:{stroke:{signal:"color.gray8"}}},axis:{domainColor:{signal:"color.gray13"},gridColor:{signal:"color.gray8"},tickColor:{signal:"color.gray13"}},range:{category:[{signal:"color.blue"},{signal:"color.orange"},{signal:"color.red"},{signal:"color.teal"},{signal:"color.green"},{signal:"color.yellow"},{signal:"color.purple"},{signal:"color.pink"},{signal:"color.brown"},{signal:"color.grey8"}]}}}function yxi(e){return{signals:[{name:"fontSize",value:vi(e)?{...DYe,...e}:DYe}],text:{fontSize:{signal:"fontSize.text"}},style:{"guide-label":{fontSize:{signal:"fontSize.guideLabel"}},"guide-title":{fontSize:{signal:"fontSize.guideTitle"}},"group-title":{fontSize:{signal:"fontSize.groupTitle"}},"group-subtitle":{fontSize:{signal:"fontSize.groupSubtitle"}}}}}function vxi(e){return{text:{font:e},style:{"guide-label":{font:e},"guide-title":{font:e},"group-title":{font:e},"group-subtitle":{font:e}}}}function xtt(e){const i=ei(e||{}),n={};for(const r of i){const o=e[r];n[r]=vN(o)?det(o):Dl(o)}return n}function Zxi(e){const i=ei(e),n={};for(const r of i)n[r]=xtt(e[r]);return n}const Bxi=[...Uet,...htt,...Htt,"background","padding","legend","lineBreak","scale","style","title","view"];function Dtt(e={}){const{color:i,font:n,fontSize:r,selection:o,...l}=e,c=Xw({},vn(pxi),n?vxi(n):{},i?bxi(i):{},r?yxi(r):{},l||{});o&&xw(c,"selection",o,!0);const u=nl(c,Bxi);for(const f of["background","lineBreak","padding"])c[f]&&(u[f]=Dl(c[f]));for(const f of Uet)c[f]&&(u[f]=OI(c[f]));for(const f of htt)c[f]&&(u[f]=xtt(c[f]));for(const f of Htt)c[f]&&(u[f]=OI(c[f]));return c.legend&&(u.legend=OI(c.legend)),c.scale&&(u.scale=OI(c.scale)),c.style&&(u.style=Zxi(c.style)),c.title&&(u.title=OI(c.title)),c.view&&(u.view=OI(c.view)),u}const Gxi=new Set(["view",...oXi]),Sxi=["color","fontSize","background","padding","facet","concat","numberFormat","numberFormatType","normalizedNumberFormat","normalizedNumberFormatType","timeFormat","countTitle","header","axisQuantitative","axisTemporal","axisDiscrete","axisPoint","axisXBand","axisXPoint","axisXDiscrete","axisXQuantitative","axisXTemporal","axisYBand","axisYPoint","axisYDiscrete","axisYQuantitative","axisYTemporal","scale","selection","overlay"],wxi={view:["continuousWidth","continuousHeight","discreteWidth","discreteHeight","step"],...CXi};function Txi(e){e=vn(e);for(const i of Sxi)delete e[i];if(e.axis)for(const i in e.axis)vN(e.axis[i])&&delete e.axis[i];if(e.legend)for(const i of axi)delete e.legend[i];if(e.mark){for(const i of TYe)delete e.mark[i];e.mark.tooltip&&vi(e.mark.tooltip)&&delete e.mark.tooltip}e.params&&(e.signals=(e.signals||[]).concat(Ntt(e.params)),delete e.params);for(const i of Gxi){for(const r of TYe)delete e[i][r];const n=wxi[i];if(n)for(const r of n)delete e[i][r];Vxi(e,i)}for(const i of oxi())delete e[i];Rxi(e);for(const i in e)vi(e[i])&&Qr(e[i])&&delete e[i];return Qr(e)?void 0:e}function Rxi(e){const{titleMarkConfig:i,subtitleMarkConfig:n,subtitle:r}=uet(e.title);Qr(i)||(e.style["group-title"]={...e.style["group-title"],...i}),Qr(n)||(e.style["group-subtitle"]={...e.style["group-subtitle"],...n}),Qr(r)?delete e.title:e.title=r}function Vxi(e,i,n,r){const o=r?e[i][r]:e[i];i==="view"&&(n="cell");const l={...o,...e.style[n??i]};Qr(l)||(e.style[n??i]=l),r||delete e[i]}function WO(e){return"layer"in e}function Exi(e){return"repeat"in e}function Hxi(e){return!Pt(e.repeat)&&e.repeat.layer}class bde{map(i,n){return GO(i)?this.mapFacet(i,n):Exi(i)?this.mapRepeat(i,n):pde(i)?this.mapHConcat(i,n):HO(i)?this.mapVConcat(i,n):mde(i)?this.mapConcat(i,n):this.mapLayerOrUnit(i,n)}mapLayerOrUnit(i,n){if(WO(i))return this.mapLayer(i,n);if(wf(i))return this.mapUnit(i,n);throw new Error(Xue(i))}mapLayer(i,n){return{...i,layer:i.layer.map(r=>this.mapLayerOrUnit(r,n))}}mapHConcat(i,n){return{...i,hconcat:i.hconcat.map(r=>this.map(r,n))}}mapVConcat(i,n){return{...i,vconcat:i.vconcat.map(r=>this.map(r,n))}}mapConcat(i,n){const{concat:r,...o}=i;return{...o,concat:r.map(l=>this.map(l,n))}}mapFacet(i,n){return{...i,spec:this.map(i.spec,n)}}mapRepeat(i,n){return{...i,spec:this.map(i.spec,n)}}}const Wxi={zero:1,center:1,normalize:1};function Nxi(e){return e in Wxi}const kxi=new Set([zet,yO,bO,V_,ZO,$ue,que,vO,Oet,jue]),Xxi=new Set([yO,bO,zet]);function vG(e){return gi(e)&&uw(e)==="quantitative"&&!e.bin}function FYe(e,i,{orient:n,type:r}){const o=i==="x"?"y":"radius",l=i==="x",c=e[i],u=e[o];if(gi(c)&&gi(u))if(vG(c)&&vG(u)){if(c.stack)return i;if(u.stack)return o;const f=gi(c)&&!!c.aggregate,m=gi(u)&&!!u.aggregate;if(f!==m)return f?i:o;if(l&&r==="bar"){if(n==="vertical")return o;if(n==="horizontal")return i}}else{if(vG(c))return i;if(vG(u))return o}else{if(vG(c))return i;if(vG(u))return o}}function xxi(e){switch(e){case"x":return"y";case"y":return"x";case"theta":return"radius";case"radius":return"theta"}}function Mtt(e,i){const n=fd(e)?e:{type:e},r=n.type;if(!kxi.has(r))return null;const o=FYe(i,"x",n)||FYe(i,"theta",n);if(!o)return null;const l=i[o],c=gi(l)?di(l,{}):void 0,u=xxi(o),f=[],m=new Set;if(i[u]){const B=i[u],G=gi(B)?di(B,{}):void 0;G&&G!==c&&(f.push(u),m.add(G));const T=u==="x"?"xOffset":"yOffset",V=i[T],E=gi(V)?di(V,{}):void 0;E&&E!==c&&(f.push(T),m.add(E))}const p=jWi.reduce((B,G)=>{if(G!=="tooltip"&&$y(i,G)){const T=i[G];for(const V of pi(T)){const E=md(V);if(E.aggregate)continue;const W=di(E,{});(!W||!m.has(W))&&B.push({channel:G,fieldDef:E})}}return B},[]);let v;return l.stack!==void 0?a0(l.stack)?v=l.stack?"zero":null:v=l.stack:Xxi.has(r)&&(v="zero"),!v||!Nxi(v)||Ide(i)&&p.length===0?null:l?.scale?.type&&l?.scale?.type!==rl.LINEAR?(l?.stack&&ni(Aki(l.scale.type)),null):yn(i[Ed(o)])?(l.stack!==void 0&&ni(cki(o)),null):(gi(l)&&l.aggregate&&!INi.has(l.aggregate)&&ni(uki(l.aggregate)),{groupbyChannels:f,groupbyFields:m,fieldChannel:o,impute:l.impute===null?!1:y0(r),stackBy:p,offset:v})}function Dxi(e){const{point:i,line:n,...r}=e;return ei(r).length>1?r:r.type}function Mxi(e){for(const i of["line","area","rule","trail"])e[i]&&(e={...e,[i]:nl(e[i],["point","line"])});return e}function jte(e,i={},n){return e.point==="transparent"?{opacity:0}:e.point?vi(e.point)?e.point:{}:e.point!==void 0?null:i.point||n.shape?vi(i.point)?i.point:{}:void 0}function YYe(e,i={}){return e.line?e.line===!0?{}:e.line:e.line!==void 0?null:i.line?i.line===!0?{}:i.line:void 0}class Fxi{constructor(){this.name="path-overlay"}hasMatchingType(i,n){if(wf(i)){const{mark:r,encoding:o}=i,l=fd(r)?r:{type:r};switch(l.type){case"line":case"rule":case"trail":return!!jte(l,n[l.type],o);case"area":return!!jte(l,n[l.type],o)||!!YYe(l,n[l.type])}}return!1}run(i,n,r){const{config:o}=n,{params:l,projection:c,mark:u,name:f,encoding:m,...p}=i,v=EO(m,o),B=fd(u)?u:{type:u},G=jte(B,o[B.type],v),T=B.type==="area"&&YYe(B,o[B.type]),V=[{name:f,...l?{params:l}:{},mark:Dxi({...B.type==="area"&&B.opacity===void 0&&B.fillOpacity===void 0?{opacity:.7}:{},...B}),encoding:nl(v,["shape"])}],E=Mtt(B,v);let W=v;if(E){const{fieldChannel:x,offset:k}=E;W={...v,[x]:{...v[x],...k?{stack:k}:{}}}}return W=nl(W,["y2","x2"]),T&&V.push({...c?{projection:c}:{},mark:{type:"line",...Iw(B,["clip","interpolate","tension","tooltip"]),...T},encoding:W}),G&&V.push({...c?{projection:c}:{},mark:{type:"point",opacity:1,filled:!0,...Iw(B,["clip","tooltip"]),...G},encoding:W}),r({...p,layer:V},{...n,config:Mxi(o)})}}function Yxi(e,i){return i?pN(e)?Ytt(e,i):Ftt(e,i):e}function $te(e,i){return i?Ytt(e,i):e}function Cae(e,i,n){const r=i[e];if(wXi(r)){if(r.repeat in n)return{...i,[e]:n[r.repeat]};ni(TNi(r.repeat));return}return i}function Ftt(e,i){if(e=Cae("field",e,i),e!==void 0){if(e===null)return null;if(gde(e)&&id(e.sort)){const n=Cae("field",e.sort,i);e={...e,...n?{sort:n}:{}}}return e}}function KYe(e,i){if(gi(e))return Ftt(e,i);{const n=Cae("datum",e,i);return n!==e&&!n.type&&(n.type="nominal"),n}}function _Ye(e,i){if(yn(e)){const n=KYe(e,i);if(n)return n;if(SO(e))return{condition:e.condition}}else{if(bN(e)){const n=KYe(e.condition,i);if(n)return{...e,condition:n};{const{condition:r,...o}=e;return o}}return e}}function Ytt(e,i){const n={};for(const r in e)if(Oi(e,r)){const o=e[r];if(Pt(o))n[r]=o.map(l=>_Ye(l,i)).filter(l=>l);else{const l=_Ye(o,i);l!==void 0&&(n[r]=l)}}return n}class Kxi{constructor(){this.name="RuleForRangedLine"}hasMatchingType(i){if(wf(i)){const{encoding:n,mark:r}=i;if(r==="line"||fd(r)&&r.type==="line")for(const o of UWi){const l=lZ(o),c=n[l];if(n[o]&&(gi(c)&&!Ha(c.bin)||Wd(c)))return!0}}return!1}run(i,n,r){const{encoding:o,mark:l}=i;return ni(UNi(!!o.x2,!!o.y2)),r({...i,mark:vi(l)?{...l,type:"rule"}:"rule"},n)}}class _xi extends bde{constructor(){super(...arguments),this.nonFacetUnitNormalizers=[UXi,$Xi,gxi,new Fxi,new Kxi]}map(i,n){if(wf(i)){const r=$y(i.encoding,Uh),o=$y(i.encoding,Qh),l=$y(i.encoding,lO);if(r||o||l)return this.mapFacetedUnit(i,n)}return super.map(i,n)}mapUnit(i,n){const{parentEncoding:r,parentProjection:o}=n,l=$te(i.encoding,n.repeater),c={...i,...i.name?{name:[n.repeaterPrefix,i.name].filter(f=>f).join("_")}:{},...l?{encoding:l}:{}};if(r||o)return this.mapUnitWithParentEncodingOrProjection(c,n);const u=this.mapLayerOrUnit.bind(this);for(const f of this.nonFacetUnitNormalizers)if(f.hasMatchingType(c,n.config))return f.run(c,n,u);return c}mapRepeat(i,n){return Hxi(i)?this.mapLayerRepeat(i,n):this.mapNonLayerRepeat(i,n)}mapLayerRepeat(i,n){const{repeat:r,spec:o,...l}=i,{row:c,column:u,layer:f}=r,{repeater:m={},repeaterPrefix:p=""}=n;return c||u?this.mapRepeat({...i,repeat:{...c?{row:c}:{},...u?{column:u}:{}},spec:{repeat:{layer:f},spec:o}},n):{...l,layer:f.map(v=>{const B={...m,layer:v},G=`${(o.name?`${o.name}_`:"")+p}child__layer_${Mg(v)}`,T=this.mapLayerOrUnit(o,{...n,repeater:B,repeaterPrefix:G});return T.name=G,T})}}mapNonLayerRepeat(i,n){const{repeat:r,spec:o,data:l,...c}=i;!Pt(r)&&i.columns&&(i=nl(i,["columns"]),ni(vYe("repeat")));const u=[],{repeater:f={},repeaterPrefix:m=""}=n,p=!Pt(r)&&r.row||[f?f.row:null],v=!Pt(r)&&r.column||[f?f.column:null],B=Pt(r)&&r||[f?f.repeat:null];for(const T of B)for(const V of p)for(const E of v){const W={repeat:T,row:V,column:E,layer:f.layer},x=(o.name?`${o.name}_`:"")+m+"child__"+(Pt(r)?`${Mg(T)}`:(r.row?`row_${Mg(V)}`:"")+(r.column?`column_${Mg(E)}`:"")),k=this.map(o,{...n,repeater:W,repeaterPrefix:x});k.name=x,u.push(nl(k,["data"]))}const G=Pt(r)?i.columns:r.column?r.column.length:1;return{data:o.data??l,align:"all",...c,columns:G,concat:u}}mapFacet(i,n){const{facet:r}=i;return pN(r)&&i.columns&&(i=nl(i,["columns"]),ni(vYe("facet"))),super.mapFacet(i,n)}mapUnitWithParentEncodingOrProjection(i,n){const{encoding:r,projection:o}=i,{parentEncoding:l,parentProjection:c,config:u}=n,f=zYe({parentProjection:c,projection:o}),m=PYe({parentEncoding:l,encoding:$te(r,n.repeater)});return this.mapUnit({...i,...f?{projection:f}:{},...m?{encoding:m}:{}},{config:u})}mapFacetedUnit(i,n){const{row:r,column:o,facet:l,...c}=i.encoding,{mark:u,width:f,projection:m,height:p,view:v,params:B,encoding:G,...T}=i,{facetMapping:V,layout:E}=this.getFacetMappingAndLayout({row:r,column:o,facet:l},n),W=$te(c,n.repeater);return this.mapFacet({...T,...E,facet:V,spec:{...f?{width:f}:{},...p?{height:p}:{},...v?{view:v}:{},...m?{projection:m}:{},mark:u,encoding:W,...B?{params:B}:{}}},n)}getFacetMappingAndLayout(i,n){const{row:r,column:o,facet:l}=i;if(r||o){l&&ni(LNi([...r?[Uh]:[],...o?[Qh]:[]]));const c={},u={};for(const f of[Uh,Qh]){const m=i[f];if(m){const{align:p,center:v,spacing:B,columns:G,...T}=m;c[f]=T;for(const V of["align","center","spacing"])m[V]!==void 0&&(u[V]??(u[V]={}),u[V][f]=m[V])}}return{facetMapping:c,layout:u}}else{const{align:c,center:u,spacing:f,columns:m,...p}=l;return{facetMapping:Yxi(p,n.repeater),layout:{...c?{align:c}:{},...u?{center:u}:{},...f?{spacing:f}:{},...m?{columns:m}:{}}}}}mapLayer(i,{parentEncoding:n,parentProjection:r,...o}){const{encoding:l,projection:c,...u}=i,f={...o,parentEncoding:PYe({parentEncoding:n,encoding:l,layer:!0}),parentProjection:zYe({parentProjection:r,projection:c})};return super.mapLayer({...u,...i.name?{name:[f.repeaterPrefix,i.name].filter(m=>m).join("_")}:{}},f)}}function PYe({parentEncoding:e,encoding:i={},layer:n}){let r={};if(e){const o=new Set([...ei(e),...ei(i)]);for(const l of o){const c=i[l],u=e[l];if(yn(c)){const f={...u,...c};r[l]=f}else bN(c)?r[l]={...c,condition:{...u,...c.condition}}:c||c===null?r[l]=c:(n||wA(u)||Fi(u)||yn(u)||Pt(u))&&(r[l]=u)}}else r=i;return!r||Qr(r)?void 0:r}function zYe(e){const{parentProjection:i,projection:n}=e;return i&&n&&ni(NNi({parentProjection:i,projection:n})),n??i}function yde(e){return"filter"in e}function Pxi(e){return e?.stop!==void 0}function Ktt(e){return"lookup"in e}function zxi(e){return"data"in e}function Oxi(e){return"param"in e}function Lxi(e){return"pivot"in e}function Jxi(e){return"density"in e}function Uxi(e){return"quantile"in e}function Qxi(e){return"regression"in e}function jxi(e){return"loess"in e}function $xi(e){return"sample"in e}function qxi(e){return"window"in e}function eDi(e){return"joinaggregate"in e}function tDi(e){return"flatten"in e}function iDi(e){return"calculate"in e}function _tt(e){return"bin"in e}function nDi(e){return"impute"in e}function rDi(e){return"timeUnit"in e}function gDi(e){return"aggregate"in e}function oDi(e){return"stack"in e}function aDi(e){return"fold"in e}function sDi(e){return e.map(i=>yde(i)?{filter:hS(i.filter,Yki)}:i)}class IDi extends bde{map(i,n){return n.emptySelections??(n.emptySelections={}),n.selectionPredicates??(n.selectionPredicates={}),i=OYe(i,n),super.map(i,n)}mapLayerOrUnit(i,n){if(i=OYe(i,n),i.encoding){const r={};for(const[o,l]of Jp(i.encoding))r[o]=Ptt(l,n);i={...i,encoding:r}}return super.mapLayerOrUnit(i,n)}mapUnit(i,n){const{selection:r,...o}=i;return r?{...o,params:Jp(r).map(([l,c])=>{const{init:u,bind:f,empty:m,...p}=c;p.type==="single"?(p.type="point",p.toggle=!1):p.type==="multi"&&(p.type="point"),n.emptySelections[l]=m!=="none";for(const v of Da(n.selectionPredicates[l]??{}))v.empty=m!=="none";return{name:l,value:u,select:p,bind:f}})}:i}}function OYe(e,i){const{transform:n,...r}=e;if(n){const o=n.map(l=>{if(yde(l))return{filter:cae(l,i)};if(_tt(l)&&CZ(l.bin))return{...l,bin:ztt(l.bin)};if(Ktt(l)){const{selection:c,...u}=l.from;return c?{...l,from:{param:c,...u}}:l}return l});return{...r,transform:o}}return e}function Ptt(e,i){const n=vn(e);if(gi(n)&&CZ(n.bin)&&(n.bin=ztt(n.bin)),AZ(n)&&n.scale?.domain?.selection){const{selection:r,...o}=n.scale.domain;n.scale.domain={...o,...r?{param:r}:{}}}if(SO(n))if(Pt(n.condition))n.condition=n.condition.map(r=>{const{selection:o,param:l,test:c,...u}=r;return l?r:{...u,test:cae(r,i)}});else{const{selection:r,param:o,test:l,...c}=Ptt(n.condition,i);n.condition=o?n.condition:{...c,test:cae(n.condition,i)}}return n}function ztt(e){const i=e.extent;if(i?.selection){const{selection:n,...r}=i;return{...e,extent:{...r,param:n}}}return e}function cae(e,i){const n=r=>hS(r,o=>{var l;const c=i.emptySelections[o]??!0,u={param:o,empty:c};return(l=i.selectionPredicates)[o]??(l[o]=[]),i.selectionPredicates[o].push(u),u});return e.selection?n(e.selection):hS(e.test||e.filter,r=>r.selection?n(r.selection):r)}class Aae extends bde{map(i,n){const r=n.selections??[];if(i.params&&!wf(i)){const o=[];for(const l of i.params)fde(l)?r.push(l):o.push(l);i.params=o}return n.selections=r,super.map(i,n)}mapUnit(i,n){const r=n.selections;if(!r||!r.length)return i;const o=(n.path??[]).concat(i.name),l=[];for(const c of r)if(!c.views||!c.views.length)l.push(c);else for(const u of c.views)(fi(u)&&(u===i.name||o.includes(u))||Pt(u)&&u.map(f=>o.indexOf(f)).every((f,m,p)=>f!==-1&&(m===0||f>p[m-1])))&&l.push(c);return l.length&&(i.params=l),i}}for(const e of["mapFacet","mapRepeat","mapHConcat","mapVConcat","mapLayer"]){const i=Aae.prototype[e];Aae.prototype[e]=function(n,r){return i.call(this,n,lDi(n,r))}}function lDi(e,i){return e.name?{...i,path:(i.path??[]).concat(e.name)}:i}function Ott(e,i){i===void 0&&(i=Dtt(e.config));const n=uDi(e,i),{width:r,height:o}=e,l=dDi(n,{width:r,height:o,autosize:e.autosize},i);return{...n,...l?{autosize:l}:{}}}const CDi=new _xi,cDi=new IDi,ADi=new Aae;function uDi(e,i={}){const n={config:i};return ADi.map(CDi.map(cDi.map(e,n),n),n)}function LYe(e){return fi(e)?{type:e}:e??{}}function dDi(e,i,n){let{width:r,height:o}=i;const l=wf(e)||WO(e),c={};l?r=="container"&&o=="container"?(c.type="fit",c.contains="padding"):r=="container"?(c.type="fit-x",c.contains="padding"):o=="container"&&(c.type="fit-y",c.contains="padding"):(r=="container"&&(ni(mYe("width")),r=void 0),o=="container"&&(ni(mYe("height")),o=void 0));const u={type:"pad",...c,...n?LYe(n.autosize):{},...LYe(e.autosize)};if(u.type==="fit"&&!l&&(ni(mNi),u.type="pad"),r=="container"&&!(u.type=="fit"||u.type=="fit-x")&&ni(pYe("width")),o=="container"&&!(u.type=="fit"||u.type=="fit-y")&&ni(pYe("height")),!Ku(u,{type:"pad"}))return u}function hDi(e){return e==="fit"||e==="fit-x"||e==="fit-y"}function fDi(e){return e?`fit-${dO(e)}`:"fit"}const mDi=["background","padding"];function JYe(e,i){const n={};for(const r of mDi)e&&e[r]!==void 0&&(n[r]=Dl(e[r]));return i&&(n.params=e.params),n}class Tf{constructor(i={},n={}){this.explicit=i,this.implicit=n}clone(){return new Tf(vn(this.explicit),vn(this.implicit))}combine(){return{...this.explicit,...this.implicit}}get(i){return Ho(this.explicit[i],this.implicit[i])}getWithExplicit(i){return this.explicit[i]!==void 0?{explicit:!0,value:this.explicit[i]}:this.implicit[i]!==void 0?{explicit:!1,value:this.implicit[i]}:{explicit:!1,value:void 0}}setWithExplicit(i,{value:n,explicit:r}){n!==void 0&&this.set(i,n,r)}set(i,n,r){return delete this[r?"implicit":"explicit"][i],this[r?"explicit":"implicit"][i]=n,this}copyKeyFromSplit(i,{explicit:n,implicit:r}){n[i]!==void 0?this.set(i,n[i],!0):r[i]!==void 0&&this.set(i,r[i],!1)}copyKeyFromObject(i,n){n[i]!==void 0&&this.set(i,n[i],!0)}copyAll(i){for(const n of ei(i.combine())){const r=i.getWithExplicit(n);this.setWithExplicit(n,r)}}}function Eu(e){return{explicit:!0,value:e}}function Nl(e){return{explicit:!1,value:e}}function Ltt(e){return(i,n,r,o)=>{const l=e(i.value,n.value);return l>0?i:l<0?n:NO(i,n,r,o)}}function NO(e,i,n,r){return e.explicit&&i.explicit&&ni(gki(n,r,e.value,i.value)),e}function Qp(e,i,n,r,o=NO){return e===void 0||e.value===void 0?i:e.explicit&&!i.explicit?e:i.explicit&&!e.explicit?i:Ku(e.value,i.value)?e:o(e,i,n,r)}class pDi extends Tf{constructor(i={},n={},r=!1){super(i,n),this.explicit=i,this.implicit=n,this.parseNothing=r}clone(){const i=super.clone();return i.parseNothing=this.parseNothing,i}}function fw(e){return"url"in e}function oW(e){return"values"in e}function Jtt(e){return"name"in e&&!fw(e)&&!oW(e)&&!Ep(e)}function Ep(e){return e&&(Utt(e)||Qtt(e)||vde(e))}function Utt(e){return"sequence"in e}function Qtt(e){return"sphere"in e}function vde(e){return"graticule"in e}var cg;(function(e){e[e.Raw=0]="Raw",e[e.Main=1]="Main",e[e.Row=2]="Row",e[e.Column=3]="Column",e[e.Lookup=4]="Lookup"})(cg||(cg={}));function jtt(e){const{signals:i,hasLegend:n,index:r,...o}=e;return o.field=QC(o.field),o}function Fv(e,i=!0,n=Hs){if(Pt(e)){const r=e.map(o=>Fv(o,i,n));return i?`[${r.join(", ")}]`:r}else if(cZ(e))return n(i?Xv(e):Vki(e));return i?n(ug(e)):e}function bDi(e,i){for(const n of Da(e.component.selection??{})){const r=n.name;let o=`${r}${$p}, ${n.resolve==="global"?"true":`{unit: ${qy(e)}}`}`;for(const l of XO)l.defined(n)&&(l.signals&&(i=l.signals(e,n,i)),l.modifyExpr&&(o=l.modifyExpr(e,n,o)));i.push({name:r+$Di,on:[{events:{signal:n.name+$p},update:`modify(${ai(n.name+Yv)}, ${o})`}]})}return Zde(i)}function yDi(e,i){if(e.component.selection&&ei(e.component.selection).length){const n=ai(e.getName("cell"));i.unshift({name:"facet",value:{},on:[{events:A0("mousemove","scope"),update:`isTuple(facet) ? facet : group(${n}).datum`}]})}return Zde(i)}function vDi(e,i){let n=!1;for(const r of Da(e.component.selection??{})){const o=r.name,l=ai(o+Yv);if(i.filter(u=>u.name===o).length===0){const u=r.resolve==="global"?"union":r.resolve,f=r.type==="point"?", true, true)":")";i.push({name:r.name,update:`${uit}(${l}, ${ai(u)}${f}`})}n=!0;for(const u of XO)u.defined(r)&&u.topLevelSignals&&(i=u.topLevelSignals(e,r,i))}return n&&i.filter(o=>o.name==="unit").length===0&&i.unshift({name:"unit",value:{},on:[{events:"mousemove",update:"isTuple(group()) ? group() : unit"}]}),Zde(i)}function ZDi(e,i){const n=[...i],r=qy(e,{escape:!1});for(const o of Da(e.component.selection??{})){const l={name:o.name+Yv};if(o.project.hasSelectionId&&(l.transform=[{type:"collect",sort:{field:TA}}]),o.init){const u=o.project.items.map(jtt);l.values=o.project.hasSelectionId?o.init.map(f=>({unit:r,[TA]:Fv(f,!1)[0]})):o.init.map(f=>({unit:r,fields:u,values:Fv(f,!1)}))}n.filter(u=>u.name===o.name+Yv).length||n.push(l)}return n}function $tt(e,i){for(const n of Da(e.component.selection??{}))for(const r of XO)r.defined(n)&&r.marks&&(i=r.marks(e,n,i));return i}function BDi(e,i){for(const n of e.children)vo(n)&&(i=$tt(n,i));return i}function GDi(e,i,n,r){const o=pit(e,i.param,i);return{signal:Ul(n.get("type"))&&Pt(r)&&r[0]>r[1]?`isValid(${o}) && reverse(${o})`:o}}function Zde(e){return e.map(i=>(i.on&&!i.on.length&&delete i.on,i))}class qr{constructor(i,n){this.debugName=n,this._children=[],this._parent=null,i&&(this.parent=i)}clone(){throw new Error("Cannot clone node")}get parent(){return this._parent}set parent(i){this._parent=i,i&&i.addChild(this)}get children(){return this._children}numChildren(){return this._children.length}addChild(i,n){if(this._children.includes(i)){ni(ENi);return}n!==void 0?this._children.splice(n,0,i):this._children.push(i)}removeChild(i){const n=this._children.indexOf(i);return this._children.splice(n,1),n}remove(){let i=this._parent.removeChild(this);for(const n of this._children)n._parent=this._parent,this._parent.addChild(n,i++)}insertAsParentOf(i){const n=i.parent;n.removeChild(this),this.parent=n,i.parent=this}swapWithParent(){const i=this._parent,n=i.parent;for(const o of this._children)o.parent=i;this._children=[],i.removeChild(this);const r=i.parent.removeChild(i);this._parent=n,n.addChild(this,r),i.parent=this}}class dI extends qr{clone(){const i=new this.constructor;return i.debugName=`clone_${this.debugName}`,i._source=this._source,i._name=`clone_${this._name}`,i.type=this.type,i.refCounts=this.refCounts,i.refCounts[i._name]=0,i}constructor(i,n,r,o){super(i,n),this.type=r,this.refCounts=o,this._source=this._name=n,this.refCounts&&!(this._name in this.refCounts)&&(this.refCounts[this._name]=0)}dependentFields(){return new Set}producedFields(){return new Set}hash(){return this._hash===void 0&&(this._hash=`Output ${Uqe()}`),this._hash}getSource(){return this.refCounts[this._name]++,this._source}isRequired(){return!!this.refCounts[this._name]}setSource(i){this._source=i}}class nd extends qr{clone(){return new nd(null,vn(this.formula))}constructor(i,n){super(i),this.formula=n}static makeFromEncoding(i,n){const r=n.reduceFieldDef((o,l)=>{const{field:c,timeUnit:u}=l;if(u){const f=di(l,{forAs:!0});o[Ir({as:f,field:c,timeUnit:u})]={as:f,field:c,timeUnit:u}}return o},{});return Qr(r)?null:new nd(i,r)}static makeFromTransform(i,n){const{timeUnit:r,...o}={...n},l=Ya(r),c={...o,timeUnit:l};return new nd(i,{[Ir(c)]:c})}merge(i){this.formula={...this.formula};for(const n in i.formula)this.formula[n]||(this.formula[n]=i.formula[n]);for(const n of i.children)i.removeChild(n),n.parent=this;i.remove()}removeFormulas(i){const n={};for(const[r,o]of Jp(this.formula))i.has(o.as)||(n[r]=o);this.formula=n}producedFields(){return new Set(Da(this.formula).map(i=>i.as))}dependentFields(){return new Set(Da(this.formula).map(i=>i.field))}hash(){return`TimeUnit ${Ir(this.formula)}`}assemble(){const i=[];for(const n of Da(this.formula)){const{field:r,as:o,timeUnit:l}=n,{unit:c,utc:u,...f}=Ya(l);i.push({field:QC(r),type:"timeunit",...c?{units:pO(c)}:{},...u?{timezone:"utc"}:{},...f,as:[o,`${o}_end`]})}return i}}const ZN="_tuple_fields";class SDi{constructor(...i){this.items=i,this.hasChannel={},this.hasField={},this.hasSelectionId=!1}}const wDi={defined:()=>!0,parse:(e,i,n)=>{const r=i.name,o=i.project??(i.project=new SDi),l={},c={},u=new Set,f=(T,V)=>{const E=V==="visual"?T.channel:T.field;let W=Mg(`${r}_${E}`);for(let x=1;u.has(W);x++)W=Mg(`${r}_${E}_${x}`);return u.add(W),{[V]:W}},m=i.type,p=e.config.selection[m],v=n.value!==void 0?pi(n.value):null;let{fields:B,encodings:G}=vi(n.select)?n.select:{};if(!B&&!G&&v){for(const T of v)if(vi(T))for(const V of ei(T))JWi(V)?(G||(G=[])).push(V):m==="interval"?(ni(wNi),G=p.encodings):(B??(B=[])).push(V)}!B&&!G&&(G=p.encodings,"fields"in p&&(B=p.fields));for(const T of G??[]){const V=e.fieldDef(T);if(V){let E=V.field;if(V.aggregate){ni(pNi(T,V.aggregate));continue}else if(!E){ni(yYe(T));continue}if(V.timeUnit){E=e.vgField(T);const W={timeUnit:V.timeUnit,as:E,field:V.field};c[Ir(W)]=W}if(!l[E]){const W=m==="interval"&&Sf(T)&&Ul(e.getScaleComponent(T).get("type"))?"R":V.bin?"R-RE":"E",x={field:E,channel:T,type:W,index:o.items.length};x.signals={...f(x,"data"),...f(x,"visual")},o.items.push(l[E]=x),o.hasField[E]=l[E],o.hasSelectionId=o.hasSelectionId||E===TA,tet(T)?(x.geoChannel=T,x.channel=eet(T),o.hasChannel[x.channel]=l[E]):o.hasChannel[T]=l[E]}}else ni(yYe(T))}for(const T of B??[]){if(o.hasField[T])continue;const V={type:"E",field:T,index:o.items.length};V.signals={...f(V,"data")},o.items.push(V),o.hasField[T]=V,o.hasSelectionId=o.hasSelectionId||T===TA}v&&(i.init=v.map(T=>o.items.map(V=>vi(T)?T[V.geoChannel||V.channel]!==void 0?T[V.geoChannel||V.channel]:T[V.field]:T))),Qr(c)||(o.timeUnit=new nd(null,c))},signals:(e,i,n)=>{const r=i.name+ZN;return n.filter(l=>l.name===r).length>0||i.project.hasSelectionId?n:n.concat({name:r,value:i.project.items.map(jtt)})}},$h={defined:e=>e.type==="interval"&&e.resolve==="global"&&e.bind&&e.bind==="scales",parse:(e,i)=>{const n=i.scales=[];for(const r of i.project.items){const o=r.channel;if(!Sf(o))continue;const l=e.getScaleComponent(o),c=l?l.get("type"):void 0;if(!l||!Ul(c)){ni(vNi);continue}l.set("selectionExtent",{param:i.name,field:r.field},!0),n.push(r)}},topLevelSignals:(e,i,n)=>{const r=i.scales.filter(c=>n.filter(u=>u.name===c.signals.data).length===0);if(!e.parent||UYe(e)||r.length===0)return n;const o=n.filter(c=>c.name===i.name)[0];let l=o.update;if(l.indexOf(uit)>=0)o.update=`{${r.map(c=>`${ai(QC(c.field))}: ${c.signals.data}`).join(", ")}}`;else{for(const c of r){const u=`${ai(QC(c.field))}: ${c.signals.data}`;l.includes(u)||(l=`${l.substring(0,l.length-1)}, ${u}}`)}o.update=l}return n.concat(r.map(c=>({name:c.signals.data})))},signals:(e,i,n)=>{if(e.parent&&!UYe(e))for(const r of i.scales){const o=n.filter(l=>l.name===r.signals.data)[0];o.push="outer",delete o.value,delete o.update}return n}};function uae(e,i){return`domain(${ai(e.scaleName(i))})`}function UYe(e){return e.parent&&r2(e.parent)&&!e.parent.parent}const pS="_brush",qtt="_scale_trigger",f9="geo_interval_init_tick",eit="_init",TDi="_center",RDi={defined:e=>e.type==="interval",parse:(e,i,n)=>{var r;if(e.hasProjection){const o={...vi(n.select)?n.select:{}};o.fields=[TA],o.encodings||(o.encodings=n.value?ei(n.value):[kA,NA]),n.select={type:"interval",...o}}if(i.translate&&!$h.defined(i)){const o=`!event.item || event.item.mark.name !== ${ai(i.name+pS)}`;for(const l of i.events){if(!l.between){ni(`${l} is not an ordered event stream for interval selections.`);continue}const c=pi((r=l.between[0]).filter??(r.filter=[]));c.indexOf(o)<0&&c.push(o)}}},signals:(e,i,n)=>{const r=i.name,o=r+$p,l=Da(i.project.hasChannel).filter(u=>u.channel===Fg||u.channel===da),c=i.init?i.init[0]:null;if(n.push(...l.reduce((u,f)=>u.concat(VDi(e,i,f,c&&c[f.index])),[])),e.hasProjection){const u=ai(e.projectionName()),f=e.projectionName()+TDi,{x:m,y:p}=i.project.hasChannel,v=m&&m.signals.visual,B=p&&p.signals.visual,G=m?c&&c[m.index]:`${f}[0]`,T=p?c&&c[p.index]:`${f}[1]`,V=Y=>e.getSizeSignalRef(Y).signal,E=`[[${v?v+"[0]":"0"}, ${B?B+"[0]":"0"}],[${v?v+"[1]":V("width")}, ${B?B+"[1]":V("height")}]]`;c&&(n.unshift({name:r+eit,init:`[scale(${u}, [${m?G[0]:G}, ${p?T[0]:T}]), scale(${u}, [${m?G[1]:G}, ${p?T[1]:T}])]`}),(!m||!p)&&(n.find(L=>L.name===f)||n.unshift({name:f,update:`invert(${u}, [${V("width")}/2, ${V("height")}/2])`})));const W=`intersect(${E}, {markname: ${ai(e.getName("marks"))}}, unit.mark)`,x=`{unit: ${qy(e)}}`,k=`vlSelectionTuples(${W}, ${x})`,F=l.map(Y=>Y.signals.visual);return n.concat({name:o,on:[{events:[...F.length?[{signal:F.join(" || ")}]:[],...c?[{signal:f9}]:[]],update:k}]})}else{if(!$h.defined(i)){const m=r+qtt,p=l.map(v=>{const B=v.channel,{data:G,visual:T}=v.signals,V=ai(e.scaleName(B)),E=e.getScaleComponent(B).get("type"),W=Ul(E)?"+":"";return`(!isArray(${G}) || (${W}invert(${V}, ${T})[0] === ${W}${G}[0] && ${W}invert(${V}, ${T})[1] === ${W}${G}[1]))`});p.length&&n.push({name:m,value:{},on:[{events:l.map(v=>({scale:e.scaleName(v.channel)})),update:p.join(" && ")+` ? ${m} : {}`}]})}const u=l.map(m=>m.signals.data),f=`unit: ${qy(e)}, fields: ${r+ZN}, values`;return n.concat({name:o,...c?{init:`{${f}: ${Fv(c)}}`}:{},...u.length?{on:[{events:[{signal:u.join(" || ")}],update:`${u.join(" && ")} ? {${f}: [${u}]} : null`}]}:{}})}},topLevelSignals:(e,i,n)=>(vo(e)&&e.hasProjection&&i.init&&(n.filter(o=>o.name===f9).length||n.unshift({name:f9,value:null,on:[{events:"timer{1}",update:`${f9} === null ? {} : ${f9}`}]})),n),marks:(e,i,n)=>{const r=i.name,{x:o,y:l}=i.project.hasChannel,c=o?.signals.visual,u=l?.signals.visual,f=`data(${ai(i.name+Yv)})`;if($h.defined(i)||!o&&!l)return n;const m={x:o!==void 0?{signal:`${c}[0]`}:{value:0},y:l!==void 0?{signal:`${u}[0]`}:{value:0},x2:o!==void 0?{signal:`${c}[1]`}:{field:{group:"width"}},y2:l!==void 0?{signal:`${u}[1]`}:{field:{group:"height"}}};if(i.resolve==="global")for(const V of ei(m))m[V]=[{test:`${f}.length && ${f}[0].unit === ${qy(e)}`,...m[V]},{value:0}];const{fill:p,fillOpacity:v,cursor:B,...G}=i.mark,T=ei(G).reduce((V,E)=>(V[E]=[{test:[o!==void 0&&`${c}[0] !== ${c}[1]`,l!==void 0&&`${u}[0] !== ${u}[1]`].filter(W=>W).join(" && "),value:G[E]},{value:null}],V),{});return[{name:`${r+pS}_bg`,type:"rect",clip:!0,encode:{enter:{fill:{value:p},fillOpacity:{value:v}},update:m}},...n,{name:r+pS,type:"rect",clip:!0,encode:{enter:{...B?{cursor:{value:B}}:{},fill:{value:"transparent"}},update:{...m,...T}}}]}};function VDi(e,i,n,r){const o=!e.hasProjection,l=n.channel,c=n.signals.visual,u=ai(o?e.scaleName(l):e.projectionName()),f=B=>`scale(${u}, ${B})`,m=e.getSizeSignalRef(l===Fg?"width":"height").signal,p=`${l}(unit)`,v=i.events.reduce((B,G)=>[...B,{events:G.between[0],update:`[${p}, ${p}]`},{events:G,update:`[${c}[0], clamp(${p}, 0, ${m})]`}],[]);if(o){const B=n.signals.data,G=$h.defined(i),T=e.getScaleComponent(l),V=T?T.get("type"):void 0,E=r?{init:Fv(r,!0,f)}:{value:[]};return v.push({events:{signal:i.name+qtt},update:Ul(V)?`[${f(`${B}[0]`)}, ${f(`${B}[1]`)}]`:"[0, 0]"}),G?[{name:B,on:[]}]:[{name:c,...E,on:v},{name:B,...r?{init:Fv(r)}:{},on:[{events:{signal:c},update:`${c}[0] === ${c}[1] ? null : invert(${u}, ${c})`}]}]}else{const B=l===Fg?0:1,G=i.name+eit,T=r?{init:`[${G}[0][${B}], ${G}[1][${B}]]`}:{value:[]};return[{name:c,...T,on:v}]}}const EDi={defined:e=>e.type==="point",signals:(e,i,n)=>{const r=i.name,o=r+ZN,l=i.project,c="(item().isVoronoi ? datum.datum : datum)",u=Da(e.component.selection??{}).reduce((v,B)=>B.type==="interval"?v.concat(B.name+pS):v,[]).map(v=>`indexof(item().mark.name, '${v}') < 0`).join(" && "),f=`datum && item().mark.marktype !== 'group' && indexof(item().mark.role, 'legend') < 0${u?` && ${u}`:""}`;let m=`unit: ${qy(e)}, `;if(i.project.hasSelectionId)m+=`${TA}: ${c}[${ai(TA)}]`;else{const v=l.items.map(B=>e.fieldDef(B.channel)?.bin?`[${c}[${ai(e.vgField(B.channel,{}))}], ${c}[${ai(e.vgField(B.channel,{binSuffix:"end"}))}]]`:`${c}[${ai(B.field)}]`).join(", ");m+=`fields: ${o}, values: [${v}]`}const p=i.events;return n.concat([{name:r+$p,on:p?[{events:p,update:`${f} ? {${m}} : null`,force:!0}]:[]}])}};function e2(e,i,n,r){const o=SO(i)&&i.condition,l=r(i);if(o){const u=pi(o).map(f=>{const m=r(f);if(SXi(f)){const{param:p,empty:v}=f;return{test:mit(e,{param:p,empty:v}),...m}}else return{test:Y_(e,f.test),...m}});return{[n]:[...u,...l!==void 0?[l]:[]]}}else return l!==void 0?{[n]:l}:{}}function Bde(e,i="text"){const n=e.encoding[i];return e2(e,n,i,r=>kO(r,e.config))}function kO(e,i,n="datum"){if(e){if(wA(e))return Gg(e.value);if(yn(e)){const{format:r,formatType:o}=N_(e);return nde({fieldOrDatumDef:e,format:r,formatType:o,expr:n,config:i})}}}function tit(e,i={}){const{encoding:n,markDef:r,config:o,stack:l}=e,c=n.tooltip;if(Pt(c))return{tooltip:QYe({tooltip:c},l,o,i)};{const u=i.reactiveGeom?"datum.datum":"datum";return e2(e,c,"tooltip",f=>{const m=kO(f,o,u);if(m)return m;if(f===null)return;let p=Wr("tooltip",r,o);if(p===!0&&(p={content:"encoding"}),fi(p))return{value:p};if(vi(p))return Fi(p)?p:p.content==="encoding"?QYe(n,l,o,i):{signal:u}})}}function iit(e,i,n,{reactiveGeom:r}={}){const o={...n,...n.tooltipFormat},l={},c=r?"datum.datum":"datum",u=[];function f(p,v){const B=lZ(v),G=mI(p)?p:{...p,type:e[B].type},T=G.title||ade(G,o),V=pi(T).join(", ");let E;if(ha(v)){const W=v==="x"?"x2":"y2",x=md(e[W]);if(Ha(G.bin)&&x){const k=di(G,{expr:c}),F=di(x,{expr:c}),{format:Y,formatType:L}=N_(G);E=mN(k,F,Y,L,o),l[W]=!0}}if((ha(v)||v===qC||v===WA)&&i&&i.fieldChannel===v&&i.offset==="normalize"){const{format:W,formatType:x}=N_(G);E=nde({fieldOrDatumDef:G,format:W,formatType:x,expr:c,config:o,normalizeStack:!0}).signal}E??(E=kO(G,o,c).signal),u.push({channel:v,key:V,value:E})}lde(e,(p,v)=>{gi(p)?f(p,v):wO(p)&&f(p.condition,v)});const m={};for(const{channel:p,key:v,value:B}of u)!l[p]&&!m[v]&&(m[v]=B);return m}function QYe(e,i,n,{reactiveGeom:r}={}){const o=iit(e,i,n,{reactiveGeom:r}),l=Jp(o).map(([c,u])=>`"${c}": ${u}`);return l.length>0?{signal:`{${l.join(", ")}}`}:void 0}function HDi(e){const{markDef:i,config:n}=e,r=Wr("aria",i,n);return r===!1?{}:{...r?{aria:r}:{},...WDi(e),...NDi(e)}}function WDi(e){const{mark:i,markDef:n,config:r}=e;if(r.aria===!1)return{};const o=Wr("ariaRoleDescription",n,r);return o!=null?{ariaRoleDescription:{value:o}}:i in dNi?{}:{ariaRoleDescription:{value:i}}}function NDi(e){const{encoding:i,markDef:n,config:r,stack:o}=e,l=i.description;if(l)return e2(e,l,"description",f=>kO(f,e.config));const c=Wr("description",n,r);if(c!=null)return{description:Gg(c)};if(r.aria===!1)return{};const u=iit(i,o,r);if(!Qr(u))return{description:{signal:Jp(u).map(([f,m],p)=>`"${p>0?"; ":""}${f}: " + (${m})`).join(" + ")}}}function sa(e,i,n={}){const{markDef:r,encoding:o,config:l}=i,{vgChannel:c}=n;let{defaultRef:u,defaultValue:f}=n;u===void 0&&(f??(f=Wr(e,r,l,{vgChannel:c,ignoreVgConfig:!0})),f!==void 0&&(u=Gg(f)));const m=o[e];return e2(i,m,c??e,p=>ide({channel:e,channelDef:p,markDef:r,config:l,scaleName:i.scaleName(e),scale:i.getScaleComponent(e),stack:null,defaultRef:u}))}function nit(e,i={filled:void 0}){const{markDef:n,encoding:r,config:o}=e,{type:l}=n,c=i.filled??Wr("filled",n,o),u=jn(["bar","point","circle","square","geoshape"],l)?"transparent":void 0,f=Wr(c===!0?"color":void 0,n,o,{vgChannel:"fill"})??o.mark[c===!0&&"color"]??u,m=Wr(c===!1?"color":void 0,n,o,{vgChannel:"stroke"})??o.mark[c===!1&&"color"],p=c?"fill":"stroke",v={...f?{fill:Gg(f)}:{},...m?{stroke:Gg(m)}:{}};return n.color&&(c?n.fill:n.stroke)&&ni(Bet("property",{fill:"fill"in n,stroke:"stroke"in n})),{...v,...sa("color",e,{vgChannel:p,defaultValue:c?f:m}),...sa("fill",e,{defaultValue:r.fill?f:void 0}),...sa("stroke",e,{defaultValue:r.stroke?m:void 0})}}function kDi(e){const{encoding:i,mark:n}=e,r=i.order;return!y0(n)&&wA(r)?e2(e,r,"zindex",o=>Gg(o.value)):{}}function aW({channel:e,markDef:i,encoding:n={},model:r,bandPosition:o}){const l=`${e}Offset`,c=i[l],u=n[l];if((l==="xOffset"||l==="yOffset")&&u)return{offsetType:"encoding",offset:ide({channel:l,channelDef:u,markDef:i,config:r?.config,scaleName:r.scaleName(l),scale:r.getScaleComponent(l),stack:null,defaultRef:Gg(c),bandPosition:o})};const f=i[l];return f?{offsetType:"visual",offset:f}:{}}function Gs(e,i,{defaultPos:n,vgChannel:r}){const{encoding:o,markDef:l,config:c,stack:u}=i,f=o[e],m=o[Ed(e)],p=i.scaleName(e),v=i.getScaleComponent(e),{offset:B,offsetType:G}=aW({channel:e,markDef:l,encoding:o,model:i,bandPosition:.5}),T=Gde({model:i,defaultPos:n,channel:e,scaleName:p,scale:v}),V=!f&&ha(e)&&(o.latitude||o.longitude)?{field:i.getName(e)}:XDi({channel:e,channelDef:f,channel2Def:m,markDef:l,config:c,scaleName:p,scale:v,stack:u,offset:B,defaultRef:T,bandPosition:G==="encoding"?0:void 0});return V?{[r||e]:V}:void 0}function XDi(e){const{channel:i,channelDef:n,scaleName:r,stack:o,offset:l,markDef:c}=e;if(yn(n)&&o&&i===o.fieldChannel){if(gi(n)){let u=n.bandPosition;if(u===void 0&&c.type==="text"&&(i==="radius"||i==="theta")&&(u=.5),u!==void 0)return E_({scaleName:r,fieldOrDatumDef:n,startSuffix:"start",bandPosition:u,offset:l})}return jy(n,r,{suffix:"end"},{offset:l})}return ede(e)}function Gde({model:e,defaultPos:i,channel:n,scaleName:r,scale:o}){const{markDef:l,config:c}=e;return()=>{const u=lZ(n),f=Up(n),m=Wr(n,l,c,{vgChannel:f});if(m!==void 0)return NE(n,m);switch(i){case"zeroOrMin":case"zeroOrMax":if(r){const p=o.get("type");if(!jn([rl.LOG,rl.TIME,rl.UTC],p)){if(o.domainDefinitelyIncludesZero())return{scale:r,value:0}}}if(i==="zeroOrMin")return u==="y"?{field:{group:"height"}}:{value:0};switch(u){case"radius":return{signal:`min(${e.width.signal},${e.height.signal})/2`};case"theta":return{signal:"2*PI"};case"x":return{field:{group:"width"}};case"y":return{value:0}}break;case"mid":return{...e[cl(n)],mult:.5}}}}const xDi={left:"x",center:"xc",right:"x2"},DDi={top:"y",middle:"yc",bottom:"y2"};function rit(e,i,n,r="middle"){if(e==="radius"||e==="theta")return Up(e);const o=e==="x"?"align":"baseline",l=Wr(o,i,n);let c;return Fi(l)?(ni(JNi(o)),c=void 0):c=l,e==="x"?xDi[c||(r==="top"?"left":"center")]:DDi[c||r]}function M_(e,i,{defaultPos:n,defaultPos2:r,range:o}){return o?git(e,i,{defaultPos:n,defaultPos2:r}):Gs(e,i,{defaultPos:n})}function git(e,i,{defaultPos:n,defaultPos2:r}){const{markDef:o,config:l}=i,c=Ed(e),u=cl(e),f=MDi(i,r,c),m=f[u]?rit(e,o,l):Up(e);return{...Gs(e,i,{defaultPos:n,vgChannel:m}),...f}}function MDi(e,i,n){const{encoding:r,mark:o,markDef:l,stack:c,config:u}=e,f=lZ(n),m=cl(n),p=Up(n),v=r[f],B=e.scaleName(f),G=e.getScaleComponent(f),{offset:T}=n in r||n in l?aW({channel:n,markDef:l,encoding:r,model:e}):aW({channel:f,markDef:l,encoding:r,model:e});if(!v&&(n==="x2"||n==="y2")&&(r.latitude||r.longitude)){const E=cl(n),W=e.markDef[E];return W!=null?{[E]:{value:W}}:{[p]:{field:e.getName(n)}}}const V=FDi({channel:n,channelDef:v,channel2Def:r[n],markDef:l,config:u,scaleName:B,scale:G,stack:c,offset:T,defaultRef:void 0});return V!==void 0?{[p]:V}:LF(n,l)||LF(n,{[n]:T_(n,l,u.style),[m]:T_(m,l,u.style)})||LF(n,u[o])||LF(n,u.mark)||{[p]:Gde({model:e,defaultPos:i,channel:n,scaleName:B,scale:G})()}}function FDi({channel:e,channelDef:i,channel2Def:n,markDef:r,config:o,scaleName:l,scale:c,stack:u,offset:f,defaultRef:m}){return yn(i)&&u&&e.charAt(0)===u.fieldChannel.charAt(0)?jy(i,l,{suffix:"start"},{offset:f}):ede({channel:e,channelDef:n,scaleName:l,scale:c,stack:u,markDef:r,config:o,offset:f,defaultRef:m})}function LF(e,i){const n=cl(e),r=Up(e);if(i[r]!==void 0)return{[r]:NE(e,i[r])};if(i[e]!==void 0)return{[r]:NE(e,i[e])};if(i[n]){const o=i[n];if(Dv(o))ni(YNi(n));else return{[n]:NE(e,o)}}}function jp(e,i){const{config:n,encoding:r,markDef:o}=e,l=o.type,c=Ed(i),u=cl(i),f=r[i],m=r[c],p=e.getScaleComponent(i),v=p?p.get("type"):void 0,B=o.orient,G=r[u]??r.size??Wr("size",o,n,{vgChannel:u}),T=get(i),V=l==="bar"&&(i==="x"?B==="vertical":B==="horizontal");return gi(f)&&(dg(f.bin)||Ha(f.bin)||f.timeUnit&&!m)&&!(G&&!Dv(G))&&!r[T]&&!fa(v)?_Di({fieldDef:f,fieldDef2:m,channel:i,model:e}):(yn(f)&&fa(v)||V)&&!m?KDi(f,i,e):git(i,e,{defaultPos:"zeroOrMax",defaultPos2:"zeroOrMin"})}function YDi(e,i,n,r,o){if(Dv(o))if(n){const c=n.get("type");if(c==="band"){let u=`bandwidth('${i}')`;return o.band!==1&&(u=`${o.band} * ${u}`),{signal:`max(0.25, ${u})`}}else o.band!==1&&(ni($Ni(c)),o=void 0)}else return{mult:o.band,field:{group:e}};else{if(Fi(o))return o;if(o)return{value:o}}if(n){const c=n.get("range");if(b0(c)&&jr(c.step))return{value:c.step-2}}return{value:x_(r.view,e)-2}}function KDi(e,i,n){const{markDef:r,encoding:o,config:l,stack:c}=n,u=r.orient,f=n.scaleName(i),m=n.getScaleComponent(i),p=cl(i),v=Ed(i),B=get(i),G=n.scaleName(B),T=n.getScaleComponent(Eue(i)),V=u==="horizontal"&&i==="y"||u==="vertical"&&i==="x";let E;(o.size||r.size)&&(V?E=sa("size",n,{vgChannel:p,defaultRef:Gg(r.size)}):ni(iki(r.type)));const W=!!E,x=gtt({channel:i,fieldDef:e,markDef:r,config:l,scaleType:m?.get("type"),useVlSizeChannel:V});E=E||{[p]:YDi(p,G||f,T||m,l,x)};const k=m?.get("type")==="band"&&Dv(x)&&!W?"top":"middle",F=rit(i,r,l,k),Y=F==="xc"||F==="yc",{offset:L,offsetType:O}=aW({channel:i,markDef:r,encoding:o,model:n,bandPosition:Y?.5:0}),Q=ede({channel:i,channelDef:e,markDef:r,config:l,scaleName:f,scale:m,stack:c,offset:L,defaultRef:Gde({model:n,defaultPos:"mid",channel:i,scaleName:f,scale:m}),bandPosition:Y?O==="encoding"?0:.5:Fi(x)?{signal:`(1-${x})/2`}:Dv(x)?(1-x.band)/2:0});if(p)return{[F]:Q,...E};{const X=Up(v),$=E[p],ee=L?{...$,offset:L}:$;return{[F]:Q,[X]:Pt(Q)?[Q[0],{...Q[1],offset:ee}]:{...Q,offset:ee}}}}function m9(e,i,n,r,o){if(qqe(e))return 0;const l=e==="x"||e==="y2"?-i/2:i/2;if(Fi(n)||Fi(o)||Fi(r)){const c=jh(n),u=jh(o),f=jh(r),m=f?`${f} + `:"",p=c?`(${c} ? -1 : 1) * `:"",v=u?`(${u} + ${l})`:l;return{signal:m+p+v}}else return o=o||0,r+(n?-o-l:+o+l)}function _Di({fieldDef:e,fieldDef2:i,channel:n,model:r}){const{config:o,markDef:l,encoding:c}=r,u=r.getScaleComponent(n),f=r.scaleName(n),m=u?u.get("type"):void 0,p=u.get("reverse"),v=gtt({channel:n,fieldDef:e,markDef:l,config:o,scaleType:m}),G=r.component.axes[n]?.[0]?.get("translate")??.5,T=ha(n)?Wr("binSpacing",l,o)??0:0,V=Ed(n),E=Up(n),W=Up(V),{offset:x}=aW({channel:n,markDef:l,encoding:c,model:r,bandPosition:0}),k=Fi(v)?{signal:`(1-${v.signal})/2`}:Dv(v)?(1-v.band)/2:.5;if(dg(e.bin)||e.timeUnit)return{[W]:jYe({fieldDef:e,scaleName:f,bandPosition:k,offset:m9(V,T,p,G,x)}),[E]:jYe({fieldDef:e,scaleName:f,bandPosition:Fi(k)?{signal:`1-${k.signal}`}:1-k,offset:m9(n,T,p,G,x)})};if(Ha(e.bin)){const F=jy(e,f,{},{offset:m9(V,T,p,G,x)});if(gi(i))return{[W]:F,[E]:jy(i,f,{},{offset:m9(n,T,p,G,x)})};if(CZ(e.bin)&&e.bin.step)return{[W]:F,[E]:{signal:`scale("${f}", ${di(e,{expr:"datum"})} + ${e.bin.step})`,offset:m9(n,T,p,G,x)}}}ni(Tet(V))}function jYe({fieldDef:e,scaleName:i,bandPosition:n,offset:r}){return E_({scaleName:i,fieldOrDatumDef:e,bandPosition:n,offset:r})}const PDi=new Set(["aria","width","height"]);function ec(e,i){const{fill:n=void 0,stroke:r=void 0}=i.color==="include"?nit(e):{};return{...zDi(e.markDef,i),...$Ye(e,"fill",n),...$Ye(e,"stroke",r),...sa("opacity",e),...sa("fillOpacity",e),...sa("strokeOpacity",e),...sa("strokeWidth",e),...sa("strokeDash",e),...kDi(e),...tit(e),...Bde(e,"href"),...HDi(e)}}function $Ye(e,i,n){const{config:r,mark:o,markDef:l}=e;if(Wr("invalid",l,r)==="hide"&&n&&!y0(o)){const u=ODi(e,{invalid:!0,channels:hO});if(u)return{[i]:[{test:u,value:null},...pi(n)]}}return n?{[i]:n}:{}}function zDi(e,i){return uNi.reduce((n,r)=>(!PDi.has(r)&&e[r]!==void 0&&i[r]!=="ignore"&&(n[r]=Gg(e[r])),n),{})}function ODi(e,{invalid:i=!1,channels:n}){const r=n.reduce((l,c)=>{const u=e.getScaleComponent(c);if(u){const f=u.get("type"),m=e.vgField(c,{expr:"datum"});m&&Ul(f)&&(l[m]=!0)}return l},{}),o=ei(r);if(o.length>0){const l=i?"||":"&&";return o.map(c=>tde(c,i)).join(` ${l} `)}}function Sde(e){const{config:i,markDef:n}=e;if(Wr("invalid",n,i)){const o=LDi(e,{channels:Hd});if(o)return{defined:{signal:o}}}return{}}function LDi(e,{invalid:i=!1,channels:n}){const r=n.reduce((l,c)=>{const u=e.getScaleComponent(c);if(u){const f=u.get("type"),m=e.vgField(c,{expr:"datum",binSuffix:e.stack?.impute?"mid":void 0});m&&Ul(f)&&(l[m]=!0)}return l},{}),o=ei(r);if(o.length>0){const l=i?"||":"&&";return o.map(c=>tde(c,i)).join(` ${l} `)}}function qYe(e,i){if(i!==void 0)return{[e]:Gg(i)}}const qte="voronoi",oit={defined:e=>e.type==="point"&&e.nearest,parse:(e,i)=>{if(i.events)for(const n of i.events)n.markname=e.getName(qte)},marks:(e,i,n)=>{const{x:r,y:o}=i.project.hasChannel,l=e.mark;if(y0(l))return ni(bNi(l)),n;const c={name:e.getName(qte),type:"path",interactive:!0,from:{data:e.getName("marks")},encode:{update:{fill:{value:"transparent"},strokeWidth:{value:.35},stroke:{value:"transparent"},isVoronoi:{value:!0},...tit(e,{reactiveGeom:!0})}},transform:[{type:"voronoi",x:{expr:r||!o?"datum.datum.x || 0":"0"},y:{expr:o||!r?"datum.datum.y || 0":"0"},size:[e.getSizeSignalRef("width"),e.getSizeSignalRef("height")]}]};let u=0,f=!1;return n.forEach((m,p)=>{const v=m.name??"";v===e.component.mark[0].name?u=p:v.indexOf(qte)>=0&&(f=!0)}),f||n.splice(u+1,0,c),n}},ait={defined:e=>e.type==="point"&&e.resolve==="global"&&e.bind&&e.bind!=="scales"&&!hde(e.bind),parse:(e,i,n)=>dit(i,n),topLevelSignals:(e,i,n)=>{const r=i.name,o=i.project,l=i.bind,c=i.init&&i.init[0],u=oit.defined(i)?"(item().isVoronoi ? datum.datum : datum)":"datum";return o.items.forEach((f,m)=>{const p=Mg(`${r}_${f.field}`);n.filter(B=>B.name===p).length||n.unshift({name:p,...c?{init:Fv(c[m])}:{value:null},on:i.events?[{events:i.events,update:`datum && item().mark.marktype !== 'group' ? ${u}[${ai(f.field)}] : null`}]:[],bind:l[f.field]??l[f.channel]??l})}),n},signals:(e,i,n)=>{const r=i.name,o=i.project,l=n.filter(m=>m.name===r+$p)[0],c=r+ZN,u=o.items.map(m=>Mg(`${r}_${m.field}`)),f=u.map(m=>`${m} !== null`).join(" && ");return u.length&&(l.update=`${f} ? {fields: ${c}, values: [${u.join(", ")}]} : null`),delete l.value,delete l.on,n}},F_="_toggle",sit={defined:e=>e.type==="point"&&!!e.toggle,signals:(e,i,n)=>n.concat({name:i.name+F_,value:!1,on:[{events:i.events,update:i.toggle}]}),modifyExpr:(e,i)=>{const n=i.name+$p,r=i.name+F_;return`${r} ? null : ${n}, `+(i.resolve==="global"?`${r} ? null : true, `:`${r} ? null : {unit: ${qy(e)}}, `)+`${r} ? ${n} : null`}},JDi={defined:e=>e.clear!==void 0&&e.clear!==!1,parse:(e,i)=>{i.clear&&(i.clear=fi(i.clear)?A0(i.clear,"view"):i.clear)},topLevelSignals:(e,i,n)=>{if(ait.defined(i))for(const r of i.project.items){const o=n.findIndex(l=>l.name===Mg(`${i.name}_${r.field}`));o!==-1&&n[o].on.push({events:i.clear,update:"null"})}return n},signals:(e,i,n)=>{function r(o,l){o!==-1&&n[o].on&&n[o].on.push({events:i.clear,update:l})}if(i.type==="interval")for(const o of i.project.items){const l=n.findIndex(c=>c.name===o.signals.visual);if(r(l,"[0, 0]"),l===-1){const c=n.findIndex(u=>u.name===o.signals.data);r(c,"null")}}else{let o=n.findIndex(l=>l.name===i.name+$p);r(o,"null"),sit.defined(i)&&(o=n.findIndex(l=>l.name===i.name+F_),r(o,"false"))}return n}},Iit={defined:e=>{const i=e.resolve==="global"&&e.bind&&hde(e.bind),n=e.project.items.length===1&&e.project.items[0].field!==TA;return i&&!n&&ni(ZNi),i&&n},parse:(e,i,n)=>{const r=vn(n);if(r.select=fi(r.select)?{type:r.select,toggle:i.toggle}:{...r.select,toggle:i.toggle},dit(i,r),vi(n.select)&&(n.select.on||n.select.clear)){const c='event.item && indexof(event.item.mark.role, "legend") < 0';for(const u of i.events)u.filter=pi(u.filter??[]),u.filter.includes(c)||u.filter.push(c)}const o=Qte(i.bind)?i.bind.legend:"click",l=fi(o)?A0(o,"view"):pi(o);i.bind={legend:{merge:l}}},topLevelSignals:(e,i,n)=>{const r=i.name,o=Qte(i.bind)&&i.bind.legend,l=c=>u=>{const f=vn(u);return f.markname=c,f};for(const c of i.project.items){if(!c.hasLegend)continue;const u=`${Mg(c.field)}_legend`,f=`${r}_${u}`;if(n.filter(p=>p.name===f).length===0){const p=o.merge.map(l(`${u}_symbols`)).concat(o.merge.map(l(`${u}_labels`))).concat(o.merge.map(l(`${u}_entries`)));n.unshift({name:f,...i.init?{}:{value:null},on:[{events:p,update:"datum.value || item().items[0].items[0].datum.value",force:!0},{events:o.merge,update:`!event.item || !datum ? null : ${f}`,force:!0}]})}}return n},signals:(e,i,n)=>{const r=i.name,o=i.project,l=n.find(B=>B.name===r+$p),c=r+ZN,u=o.items.filter(B=>B.hasLegend).map(B=>Mg(`${r}_${Mg(B.field)}_legend`)),m=`${u.map(B=>`${B} !== null`).join(" && ")} ? {fields: ${c}, values: [${u.join(", ")}]} : null`;i.events&&u.length>0?l.on.push({events:u.map(B=>({signal:B})),update:m}):u.length>0&&(l.update=m,delete l.value,delete l.on);const p=n.find(B=>B.name===r+F_),v=Qte(i.bind)&&i.bind.legend;return p&&(i.events?p.on.push({...p.on[0],events:v}):p.on[0].events=v),n}};function UDi(e,i,n){const r=e.fieldDef(i)?.field;for(const o of Da(e.component.selection??{})){const l=o.project.hasField[r]??o.project.hasChannel[i];if(l&&Iit.defined(o)){const c=n.get("selections")??[];c.push(o.name),n.set("selections",c,!1),l.hasLegend=!0}}}const lit="_translate_anchor",Cit="_translate_delta",QDi={defined:e=>e.type==="interval"&&e.translate,signals:(e,i,n)=>{const r=i.name,o=$h.defined(i),l=r+lit,{x:c,y:u}=i.project.hasChannel;let f=A0(i.translate,"scope");return o||(f=f.map(m=>(m.between[0].markname=r+pS,m))),n.push({name:l,value:{},on:[{events:f.map(m=>m.between[0]),update:"{x: x(unit), y: y(unit)"+(c!==void 0?`, extent_x: ${o?uae(e,Fg):`slice(${c.signals.visual})`}`:"")+(u!==void 0?`, extent_y: ${o?uae(e,da):`slice(${u.signals.visual})`}`:"")+"}"}]},{name:r+Cit,value:{},on:[{events:f,update:`{x: ${l}.x - x(unit), y: ${l}.y - y(unit)}`}]}),c!==void 0&&eKe(e,i,c,"width",n),u!==void 0&&eKe(e,i,u,"height",n),n}};function eKe(e,i,n,r,o){const l=i.name,c=l+lit,u=l+Cit,f=n.channel,m=$h.defined(i),p=o.filter(Y=>Y.name===n.signals[m?"data":"visual"])[0],v=e.getSizeSignalRef(r).signal,B=e.getScaleComponent(f),G=B&&B.get("type"),T=B&&B.get("reverse"),V=m?f===Fg?T?"":"-":T?"-":"":"",E=`${c}.extent_${f}`,W=`${V}${u}.${f} / ${m?`${v}`:`span(${E})`}`,x=!m||!B?"panLinear":G==="log"?"panLog":G==="symlog"?"panSymlog":G==="pow"?"panPow":"panLinear",k=m?G==="pow"?`, ${B.get("exponent")??1}`:G==="symlog"?`, ${B.get("constant")??1}`:"":"",F=`${x}(${E}, ${W}${k})`;p.on.push({events:{signal:u},update:m?F:`clampRange(${F}, 0, ${v})`})}const cit="_zoom_anchor",Ait="_zoom_delta",jDi={defined:e=>e.type==="interval"&&e.zoom,signals:(e,i,n)=>{const r=i.name,o=$h.defined(i),l=r+Ait,{x:c,y:u}=i.project.hasChannel,f=ai(e.scaleName(Fg)),m=ai(e.scaleName(da));let p=A0(i.zoom,"scope");return o||(p=p.map(v=>(v.markname=r+pS,v))),n.push({name:r+cit,on:[{events:p,update:o?"{"+[f?`x: invert(${f}, x(unit))`:"",m?`y: invert(${m}, y(unit))`:""].filter(v=>v).join(", ")+"}":"{x: x(unit), y: y(unit)}"}]},{name:l,on:[{events:p,force:!0,update:"pow(1.001, event.deltaY * pow(16, event.deltaMode))"}]}),c!==void 0&&tKe(e,i,c,"width",n),u!==void 0&&tKe(e,i,u,"height",n),n}};function tKe(e,i,n,r,o){const l=i.name,c=n.channel,u=$h.defined(i),f=o.filter(x=>x.name===n.signals[u?"data":"visual"])[0],m=e.getSizeSignalRef(r).signal,p=e.getScaleComponent(c),v=p&&p.get("type"),B=u?uae(e,c):f.name,G=l+Ait,T=`${l}${cit}.${c}`,V=!u||!p?"zoomLinear":v==="log"?"zoomLog":v==="symlog"?"zoomSymlog":v==="pow"?"zoomPow":"zoomLinear",E=u?v==="pow"?`, ${p.get("exponent")??1}`:v==="symlog"?`, ${p.get("constant")??1}`:"":"",W=`${V}(${B}, ${T}, ${G}${E})`;f.on.push({events:{signal:G},update:u?W:`clampRange(${W}, 0, ${m})`})}const Yv="_store",$p="_tuple",$Di="_modify",uit="vlSelectionResolve",XO=[EDi,RDi,wDi,sit,ait,$h,Iit,JDi,QDi,jDi,oit];function qDi(e){let i=e.parent;for(;i&&!bA(i);)i=i.parent;return i}function qy(e,{escape:i}={escape:!0}){let n=i?ai(e.name):e.name;const r=qDi(e);if(r){const{facet:o}=r;for(const l of xC)o[l]&&(n+=` + '__facet_${l}_' + (facet[${ai(r.vgField(l))}])`)}return n}function wde(e){return Da(e.component.selection??{}).reduce((i,n)=>i||n.project.hasSelectionId,!1)}function dit(e,i){(fi(i.select)||!i.select.on)&&delete e.events,(fi(i.select)||!i.select.clear)&&delete e.clear,(fi(i.select)||!i.select.toggle)&&delete e.toggle}function dae(e){const i=[];return e.type==="Identifier"?[e.name]:e.type==="Literal"?[e.value]:(e.type==="MemberExpression"&&(i.push(...dae(e.object)),i.push(...dae(e.property))),i)}function hit(e){return e.object.type==="MemberExpression"?hit(e.object):e.object.name==="datum"}function fit(e){const i=_Ae(e),n=new Set;return i.visit(r=>{r.type==="MemberExpression"&&hit(r)&&n.add(dae(r).slice(1).join("."))}),n}class t2 extends qr{clone(){return new t2(null,this.model,vn(this.filter))}constructor(i,n,r){super(i),this.model=n,this.filter=r,this.expr=Y_(this.model,this.filter,this),this._dependentFields=fit(this.expr)}dependentFields(){return this._dependentFields}producedFields(){return new Set}assemble(){return{type:"filter",expr:this.expr}}hash(){return`Filter ${this.expr}`}}function e5i(e,i){const n={},r=e.config.selection;if(!i||!i.length)return n;for(const o of i){const l=Mg(o.name),c=o.select,u=fi(c)?c:c.type,f=vi(c)?vn(c):{type:u},m=r[u];for(const B in m)B==="fields"||B==="encodings"||(B==="mark"&&(f[B]={...m[B],...f[B]}),(f[B]===void 0||f[B]===!0)&&(f[B]=vn(m[B]??f[B])));const p=n[l]={...f,name:l,type:u,init:o.value,bind:o.bind,events:fi(f.on)?A0(f.on,"scope"):pi(vn(f.on))},v=vn(o);for(const B of XO)B.defined(p)&&B.parse&&B.parse(e,p,v)}return n}function mit(e,i,n,r="datum"){const o=fi(i)?i:i.param,l=Mg(o),c=ai(l+Yv);let u;try{u=e.getSelectionComponent(l,o)}catch{return`!!${l}`}if(u.project.timeUnit){const B=n??e.component.data.raw,G=u.project.timeUnit.clone();B.parent?G.insertAsParentOf(B):B.parent=G}const f=u.project.hasSelectionId?"vlSelectionIdTest(":"vlSelectionTest(",m=u.resolve==="global"?")":`, ${ai(u.resolve)})`,p=`${f}${c}, ${r}${m}`,v=`length(data(${c}))`;return i.empty===!1?`${v} && ${p}`:`!${v} || ${p}`}function pit(e,i,n){const r=Mg(i),o=n.encoding;let l=n.field,c;try{c=e.getSelectionComponent(r,i)}catch{return r}if(!o&&!l)l=c.project.items[0].field,c.project.items.length>1&&ni(`A "field" or "encoding" must be specified when using a selection as a scale domain. Using "field": ${ai(l)}.`);else if(o&&!l){const u=c.project.items.filter(f=>f.channel===o);!u.length||u.length>1?(l=c.project.items[0].field,ni((u.length?"Multiple ":"No ")+`matching ${ai(o)} encoding found for selection ${ai(n.param)}. Using "field": ${ai(l)}.`)):l=u[0].field}return`${c.name}[${ai(QC(l))}]`}function t5i(e,i){for(const[n,r]of Jp(e.component.selection??{})){const o=e.getName(`lookup_${n}`);e.component.data.outputNodes[o]=r.materialized=new dI(new t2(i,e,{param:n}),o,cg.Lookup,e.component.data.outputNodeRefCounts)}}function Y_(e,i,n){return WE(i,r=>fi(r)?r:Dki(r)?mit(e,r,n):xet(r))}function i5i(e,i){if(e)return Pt(e)&&!Lm(e)?e.map(n=>ade(n,i)).join(", "):e}function eie(e,i,n,r){var o,l;e.encode??(e.encode={}),(o=e.encode)[i]??(o[i]={}),(l=e.encode[i]).update??(l.update={}),e.encode[i].update[n]=r}function nE(e,i,n,r={header:!1}){const{disable:o,orient:l,scale:c,labelExpr:u,title:f,zindex:m,...p}=e.combine();if(!o){for(const v in p){const B=FXi[v],G=p[v];if(B&&B!==i&&B!=="both")delete p[v];else if(vN(G)){const{condition:T,...V}=G,E=pi(T),W=WYe[v];if(W){const{vgProp:x,part:k}=W,F=[...E.map(Y=>{const{test:L,...O}=Y;return{test:Y_(null,L),...O}}),V];eie(p,k,x,F),delete p[v]}else if(W===null){const x={signal:E.map(k=>{const{test:F,...Y}=k;return`${Y_(null,F)} ? ${fYe(Y)} : `}).join("")+fYe(V)};p[v]=x}}else if(Fi(G)){const T=WYe[v];if(T){const{vgProp:V,part:E}=T;eie(p,E,V,G),delete p[v]}}jn(["labelAlign","labelBaseline"],v)&&p[v]===null&&delete p[v]}if(i==="grid"){if(!p.grid)return;if(p.encode){const{grid:v}=p.encode;p.encode={...v?{grid:v}:{}},Qr(p.encode)&&delete p.encode}return{scale:c,orient:l,...p,domain:!1,labels:!1,aria:!1,maxExtent:0,minExtent:0,ticks:!1,zindex:Ho(m,0)}}else{if(!r.header&&e.mainExtracted)return;if(u!==void 0){let B=u;p.encode?.labels?.update&&Fi(p.encode.labels.update.text)&&(B=Wv(u,"datum.label",p.encode.labels.update.text.signal)),eie(p,"labels","text",{signal:B})}if(p.labelAlign===null&&delete p.labelAlign,p.encode){for(const B of utt)e.hasAxisPart(B)||delete p.encode[B];Qr(p.encode)&&delete p.encode}const v=i5i(f,n);return{scale:c,orient:l,grid:!1,...v?{title:v}:{},...p,...n.aria===!1?{aria:!1}:{},zindex:Ho(m,0)}}}}function bit(e){const{axes:i}=e.component,n=[];for(const r of Hd)if(i[r]){for(const o of i[r])if(!o.get("disable")&&!o.get("gridScale")){const l=r==="x"?"height":"width",c=e.getSizeSignalRef(l).signal;l!==c&&n.push({name:l,update:c})}}return n}function n5i(e,i){const{x:n=[],y:r=[]}=e;return[...n.map(o=>nE(o,"grid",i)),...r.map(o=>nE(o,"grid",i)),...n.map(o=>nE(o,"main",i)),...r.map(o=>nE(o,"main",i))].filter(o=>o)}function iKe(e,i,n,r){return Object.assign.apply(null,[{},...e.map(o=>{if(o==="axisOrient"){const l=n==="x"?"bottom":"left",c=i[n==="x"?"axisBottom":"axisLeft"]||{},u=i[n==="x"?"axisTop":"axisRight"]||{},f=new Set([...ei(c),...ei(u)]),m={};for(const p of f.values())m[p]={signal:`${r.signal} === "${l}" ? ${jh(c[p])} : ${jh(u[p])}`};return m}return i[o]})])}function r5i(e,i,n,r){const o=i==="band"?["axisDiscrete","axisBand"]:i==="point"?["axisDiscrete","axisPoint"]:Yet(i)?["axisQuantitative"]:i==="time"||i==="utc"?["axisTemporal"]:[],l=e==="x"?"axisX":"axisY",c=Fi(n)?"axisOrient":`axis${cN(n)}`,u=[...o,...o.map(m=>l+m.substr(4))],f=["axis",c,l];return{vlOnlyAxisConfig:iKe(u,r,e,n),vgAxisConfig:iKe(f,r,e,n),axisConfigStyle:g5i([...f,...u],r)}}function g5i(e,i){const n=[{}];for(const r of e){let o=i[r]?.style;if(o){o=pi(o);for(const l of o)n.push(i.style[l])}}return Object.assign.apply(null,n)}function hae(e,i,n,r={}){const o=fet(e,n,i);if(o!==void 0)return{configFrom:"style",configValue:o};for(const l of["vlOnlyAxisConfig","vgAxisConfig","axisConfigStyle"])if(r[l]?.[e]!==void 0)return{configFrom:l,configValue:r[l][e]};return{}}const nKe={scale:({model:e,channel:i})=>e.scaleName(i),format:({format:e})=>e,formatType:({formatType:e})=>e,grid:({fieldOrDatumDef:e,axis:i,scaleType:n})=>i.grid??o5i(n,e),gridScale:({model:e,channel:i})=>a5i(e,i),labelAlign:({axis:e,labelAngle:i,orient:n,channel:r})=>e.labelAlign||vit(i,n,r),labelAngle:({labelAngle:e})=>e,labelBaseline:({axis:e,labelAngle:i,orient:n,channel:r})=>e.labelBaseline||yit(i,n,r),labelFlush:({axis:e,fieldOrDatumDef:i,channel:n})=>e.labelFlush??I5i(i.type,n),labelOverlap:({axis:e,fieldOrDatumDef:i,scaleType:n})=>e.labelOverlap??l5i(i.type,n,gi(i)&&!!i.timeUnit,gi(i)?i.sort:void 0),orient:({orient:e})=>e,tickCount:({channel:e,model:i,axis:n,fieldOrDatumDef:r,scaleType:o})=>{const l=e==="x"?"width":e==="y"?"height":void 0,c=l?i.getSizeSignalRef(l):void 0;return n.tickCount??c5i({fieldOrDatumDef:r,scaleType:o,size:c,values:n.values})},tickMinStep:A5i,title:({axis:e,model:i,channel:n})=>{if(e.title!==void 0)return e.title;const r=Zit(i,n);if(r!==void 0)return r;const o=i.typedFieldDef(n),l=n==="x"?"x2":"y2",c=i.fieldDef(l);return pet(o?[EYe(o)]:[],gi(c)?[EYe(c)]:[])},values:({axis:e,fieldOrDatumDef:i})=>u5i(e,i),zindex:({axis:e,fieldOrDatumDef:i,mark:n})=>e.zindex??d5i(n,i)};function o5i(e,i){return!fa(e)&&gi(i)&&!dg(i?.bin)&&!Ha(i?.bin)}function a5i(e,i){const n=i==="x"?"y":"x";if(e.getScaleComponent(n))return e.scaleName(n)}function s5i(e,i,n,r,o){const l=i?.labelAngle;if(l!==void 0)return Fi(l)?l:gW(l);{const{configValue:c}=hae("labelAngle",r,i?.style,o);return c!==void 0?gW(c):n===Fg&&jn([Que,Uue],e.type)&&!(gi(e)&&e.timeUnit)?270:void 0}}function fae(e){return`(((${e.signal} % 360) + 360) % 360)`}function yit(e,i,n,r){if(e!==void 0)if(n==="x"){if(Fi(e)){const o=fae(e),l=Fi(i)?`(${i.signal} === "top")`:i==="top";return{signal:`(45 < ${o} && ${o} < 135) || (225 < ${o} && ${o} < 315) ? "middle" :(${o} <= 45 || 315 <= ${o}) === ${l} ? "bottom" : "top"`}}if(45{if(AZ(r)&&ntt(r.sort)){const{field:l,timeUnit:c}=r,u=r.sort,f=u.map((m,p)=>`${xet({field:l,timeUnit:c,equal:m})} ? ${p} : `).join("")+u.length;i=new mw(i,{calculate:f,as:pw(r,o,{forAs:!0})})}}),i}producedFields(){return new Set([this.transform.as])}dependentFields(){return this._dependentFields}assemble(){return{type:"formula",expr:this.transform.calculate,as:this.transform.as}}hash(){return`Calculate ${Ir(this.transform)}`}}function pw(e,i,n){return di(e,{prefix:i,suffix:"sort_index",...n??{}})}function xO(e,i){return jn(["top","bottom"],i)?"column":jn(["left","right"],i)||e==="row"?"row":"column"}function bw(e,i,n,r){const o=r==="row"?n.headerRow:r==="column"?n.headerColumn:n.headerFacet;return Ho((i||{})[e],o[e],n.header[e])}function DO(e,i,n,r){const o={};for(const l of e){const c=bw(l,i||{},n,r);c!==void 0&&(o[l]=c)}return o}const Tde=["row","column"],Rde=["header","footer"];function h5i(e,i){const n=e.component.layoutHeaders[i].title,r=e.config?e.config:void 0,o=e.component.layoutHeaders[i].facetFieldDef?e.component.layoutHeaders[i].facetFieldDef:void 0,{titleAnchor:l,titleAngle:c,titleOrient:u}=DO(["titleAnchor","titleAngle","titleOrient"],o.header,r,i),f=xO(i,u),m=gW(c);return{name:`${i}-title`,type:"group",role:`${f}-title`,title:{text:n,...i==="row"?{orient:"left"}:{},style:"guide-title",...Git(m,f),...Bit(f,m,l),...Sit(r,o,i,sxi,Vtt)}}}function Bit(e,i,n="middle"){switch(n){case"start":return{align:"left"};case"end":return{align:"right"}}const r=vit(i,e==="row"?"left":"top",e==="row"?"y":"x");return r?{align:r}:{}}function Git(e,i){const n=yit(e,i==="row"?"left":"top",i==="row"?"y":"x",!0);return n?{baseline:n}:{}}function f5i(e,i){const n=e.component.layoutHeaders[i],r=[];for(const o of Rde)if(n[o])for(const l of n[o]){const c=p5i(e,i,o,n,l);c!=null&&r.push(c)}return r}function m5i(e,i){const{sort:n}=e;return id(n)?{field:di(n,{expr:"datum"}),order:n.order??"ascending"}:Pt(n)?{field:pw(e,i,{expr:"datum"}),order:"ascending"}:{field:di(e,{expr:"datum"}),order:n??"ascending"}}function mae(e,i,n){const{format:r,formatType:o,labelAngle:l,labelAnchor:c,labelOrient:u,labelExpr:f}=DO(["format","formatType","labelAngle","labelAnchor","labelOrient","labelExpr"],e.header,n,i),m=nde({fieldOrDatumDef:e,format:r,formatType:o,expr:"parent",config:n}).signal,p=xO(i,u);return{text:{signal:f?Wv(Wv(f,"datum.label",m),"datum.value",di(e,{expr:"parent"})):m},...i==="row"?{orient:"left"}:{},style:"guide-label",frame:"group",...Git(l,p),...Bit(p,l,c),...Sit(n,e,i,Ixi,Ett)}}function p5i(e,i,n,r,o){if(o){let l=null;const{facetFieldDef:c}=r,u=e.config?e.config:void 0;if(c&&o.labels){const{labelOrient:v}=DO(["labelOrient"],c.header,u,i);(i==="row"&&!jn(["top","bottom"],v)||i==="column"&&!jn(["left","right"],v))&&(l=mae(c,i,u))}const f=bA(e)&&!pN(e.facet),m=o.axes,p=m?.length>0;if(l||p){const v=i==="row"?"height":"width";return{name:e.getName(`${i}_${n}`),type:"group",role:`${i}-${n}`,...r.facetFieldDef?{from:{data:e.getName(`${i}_domain`)},sort:m5i(c,i)}:{},...p&&f?{from:{data:e.getName(`facet_domain_${i}`)}}:{},...l?{title:l}:{},...o.sizeSignal?{encode:{update:{[v]:o.sizeSignal}}}:{},...p?{axes:m}:{}}}}return null}const b5i={column:{start:0,end:1},row:{start:1,end:0}};function y5i(e,i){return b5i[i][e]}function v5i(e,i){const n={};for(const r of xC){const o=e[r];if(o?.facetFieldDef){const{titleAnchor:l,titleOrient:c}=DO(["titleAnchor","titleOrient"],o.facetFieldDef.header,i,r),u=xO(r,c),f=y5i(l,u);f!==void 0&&(n[u]=f)}}return Qr(n)?void 0:n}function Sit(e,i,n,r,o){const l={};for(const c of r){if(!o[c])continue;const u=bw(c,i?.header,e,n);u!==void 0&&(l[o[c]]=u)}return l}function Vde(e){return[...JF(e,"width"),...JF(e,"height"),...JF(e,"childWidth"),...JF(e,"childHeight")]}function JF(e,i){const n=i==="width"?"x":"y",r=e.component.layoutSize.get(i);if(!r||r==="merged")return[];const o=e.getSizeSignalRef(i).signal;if(r==="step"){const l=e.getScaleComponent(n);if(l){const c=l.get("type"),u=l.get("range");if(fa(c)&&b0(u)){const f=e.scaleName(n);return bA(e.parent)&&e.parent.component.resolve.scale[n]==="independent"?[rKe(f,u)]:[rKe(f,u),{name:o,update:wit(f,l,`domain('${f}').length`)}]}}throw new Error("layout size is step although width/height is not step.")}else if(r=="container"){const l=o.endsWith("width"),c=l?"containerSize()[0]":"containerSize()[1]",u=lae(e.config.view,l?"width":"height"),f=`isFinite(${c}) ? ${c} : ${u}`;return[{name:o,init:f,on:[{update:f,events:"window:resize"}]}]}else return[{name:o,value:r}]}function rKe(e,i){const n=`${e}_step`;return Fi(i.step)?{name:n,update:i.step.signal}:{name:n,value:i.step}}function wit(e,i,n){const r=i.get("type"),o=i.get("padding"),l=Ho(i.get("paddingOuter"),o);let c=i.get("paddingInner");return c=r==="band"?c!==void 0?c:o:1,`bandspace(${n}, ${jh(c)}, ${jh(l)}) * ${e}_step`}function Tit(e){return e==="childWidth"?"width":e==="childHeight"?"height":e}function Rit(e,i){return ei(e).reduce((n,r)=>{const o=e[r];return{...n,...e2(i,o,r,l=>Gg(l.value))}},{})}function Vit(e,i){if(bA(i))return e==="theta"?"independent":"shared";if(r2(i))return"shared";if(xde(i))return ha(e)||e==="theta"||e==="radius"?"independent":"shared";throw new Error("invalid model type for resolve")}function Ede(e,i){const n=e.scale[i],r=ha(i)?"axis":"legend";return n==="independent"?(e[r][i]==="shared"&&ni(aki(i)),"independent"):e[r][i]||"shared"}const Z5i={...cxi,disable:1,labelExpr:1,selections:1,opacity:1,shape:1,stroke:1,fill:1,size:1,strokeWidth:1,strokeDash:1,encode:1},Eit=ei(Z5i);class B5i extends Tf{}const gKe={symbols:G5i,gradient:S5i,labels:w5i,entries:T5i};function G5i(e,{fieldOrDatumDef:i,model:n,channel:r,legendCmpt:o,legendType:l}){if(l!=="symbol")return;const{markDef:c,encoding:u,config:f,mark:m}=n,p=c.filled&&m!=="trail";let v={...fNi({},n,IXi),...nit(n,{filled:p})};const B=o.get("symbolOpacity")??f.legend.symbolOpacity,G=o.get("symbolFillColor")??f.legend.symbolFillColor,T=o.get("symbolStrokeColor")??f.legend.symbolStrokeColor,V=B===void 0?Hit(u.opacity)??c.opacity:void 0;if(v.fill){if(r==="fill"||p&&r===ll)delete v.fill;else if(v.fill.field)G?delete v.fill:(v.fill=Gg(f.legend.symbolBaseFillColor??"black"),v.fillOpacity=Gg(V??1));else if(Pt(v.fill)){const E=pae(u.fill??u.color)??c.fill??(p&&c.color);E&&(v.fill=Gg(E))}}if(v.stroke){if(r==="stroke"||!p&&r===ll)delete v.stroke;else if(v.stroke.field||T)delete v.stroke;else if(Pt(v.stroke)){const E=Ho(pae(u.stroke||u.color),c.stroke,p?c.color:void 0);E&&(v.stroke={value:E})}}if(r!==Gf){const E=gi(i)&&Nit(n,o,i);E?v.opacity=[{test:E,...Gg(V??1)},Gg(f.legend.unselectedOpacity)]:V&&(v.opacity=Gg(V))}return v={...v,...e},Qr(v)?void 0:v}function S5i(e,{model:i,legendType:n,legendCmpt:r}){if(n!=="gradient")return;const{config:o,markDef:l,encoding:c}=i;let u={};const m=(r.get("gradientOpacity")??o.legend.gradientOpacity)===void 0?Hit(c.opacity)||l.opacity:void 0;return m&&(u.opacity=Gg(m)),u={...u,...e},Qr(u)?void 0:u}function w5i(e,{fieldOrDatumDef:i,model:n,channel:r,legendCmpt:o}){const l=n.legend(r)||{},c=n.config,u=gi(i)?Nit(n,o,i):void 0,f=u?[{test:u,value:1},{value:c.legend.unselectedOpacity}]:void 0,{format:m,formatType:p}=l;let v;Mv(p)?v=cA({fieldOrDatumDef:i,field:"datum.value",format:m,formatType:p,config:c}):m===void 0&&p===void 0&&c.customFormatTypes&&(i.type==="quantitative"&&c.numberFormatType?v=cA({fieldOrDatumDef:i,field:"datum.value",format:c.numberFormat,formatType:c.numberFormatType,config:c}):i.type==="temporal"&&c.timeFormatType&&gi(i)&&i.timeUnit===void 0&&(v=cA({fieldOrDatumDef:i,field:"datum.value",format:c.timeFormat,formatType:c.timeFormatType,config:c})));const B={...f?{opacity:f}:{},...v?{text:v}:{},...e};return Qr(B)?void 0:B}function T5i(e,{legendCmpt:i}){return i.get("selections")?.length?{...e,fill:{value:"transparent"}}:e}function Hit(e){return Wit(e,(i,n)=>Math.max(i,n.value))}function pae(e){return Wit(e,(i,n)=>Ho(i,n.value))}function Wit(e,i){if(TXi(e))return pi(e.condition).reduce(i,e.value);if(wA(e))return e.value}function Nit(e,i,n){const r=i.get("selections");if(!r?.length)return;const o=ai(n.field);return r.map(l=>`(!length(data(${ai(Mg(l)+Yv)})) || (${l}[${o}] && indexof(${l}[${o}], datum.value) >= 0))`).join(" || ")}const oKe={direction:({direction:e})=>e,format:({fieldOrDatumDef:e,legend:i,config:n})=>{const{format:r,formatType:o}=i;return qet(e,e.type,r,o,n,!1)},formatType:({legend:e,fieldOrDatumDef:i,scaleType:n})=>{const{formatType:r}=e;return ett(r,i,n)},gradientLength:e=>{const{legend:i,legendConfig:n}=e;return i.gradientLength??n.gradientLength??k5i(e)},labelOverlap:({legend:e,legendConfig:i,scaleType:n})=>e.labelOverlap??i.labelOverlap??X5i(n),symbolType:({legend:e,markDef:i,channel:n,encoding:r})=>e.symbolType??V5i(i.type,n,r.shape,i.shape),title:({fieldOrDatumDef:e,config:i})=>mS(e,i,{allowDisabling:!0}),type:({legendType:e,scaleType:i,channel:n})=>{if(fS(n)&&CA(i)){if(e==="gradient")return}else if(e==="symbol")return;return e},values:({fieldOrDatumDef:e,legend:i})=>R5i(i,e)};function R5i(e,i){const n=e.values;if(Pt(n))return Att(i,n);if(Fi(n))return n}function V5i(e,i,n,r){if(i!=="shape"){const o=pae(n)??r;if(o)return o}switch(e){case"bar":case"rect":case"image":case"square":return"square";case"line":case"trail":case"rule":return"stroke";case"arc":case"point":case"circle":case"tick":case"geoshape":case"area":case"text":return"circle"}}function E5i(e){const{legend:i}=e;return Ho(i.type,H5i(e))}function H5i({channel:e,timeUnit:i,scaleType:n}){if(fS(e)){if(jn(["quarter","month","day"],i))return"symbol";if(CA(n))return"gradient"}return"symbol"}function W5i({legendConfig:e,legendType:i,orient:n,legend:r}){return r.direction??e[i?"gradientDirection":"symbolDirection"]??N5i(n,i)}function N5i(e,i){switch(e){case"top":case"bottom":return"horizontal";case"left":case"right":case"none":case void 0:return;default:return i==="gradient"?"horizontal":void 0}}function k5i({legendConfig:e,model:i,direction:n,orient:r,scaleType:o}){const{gradientHorizontalMaxLength:l,gradientHorizontalMinLength:c,gradientVerticalMaxLength:u,gradientVerticalMinLength:f}=e;if(CA(o))return n==="horizontal"?r==="top"||r==="bottom"?aKe(i,"width",c,l):c:aKe(i,"height",f,u)}function aKe(e,i,n,r){return{signal:`clamp(${e.getSizeSignalRef(i).signal}, ${n}, ${r})`}}function X5i(e){if(jn(["quantile","threshold","log","symlog"],e))return"greedy"}function kit(e){const i=vo(e)?x5i(e):Y5i(e);return e.component.legends=i,i}function x5i(e){const{encoding:i}=e,n={};for(const r of[ll,...Wtt]){const o=Jo(i[r]);!o||!e.getScaleComponent(r)||r===Cl&&gi(o)&&o.type===qw||(n[r]=F5i(e,r))}return n}function D5i(e,i){const n=e.scaleName(i);if(e.mark==="trail"){if(i==="color")return{stroke:n};if(i==="size")return{strokeWidth:n}}return i==="color"?e.markDef.filled?{fill:n}:{stroke:n}:{[i]:n}}function M5i(e,i,n,r){switch(i){case"disable":return n!==void 0;case"values":return!!n?.values;case"title":if(i==="title"&&e===r?.title)return!0}return e===(n||{})[i]}function F5i(e,i){let n=e.legend(i);const{markDef:r,encoding:o,config:l}=e,c=l.legend,u=new B5i({},D5i(e,i));UDi(e,i,u);const f=n!==void 0?!n:c.disable;if(u.set("disable",f,n!==void 0),f)return u;n=n||{};const m=e.getScaleComponent(i).get("type"),p=Jo(o[i]),v=gi(p)?Ya(p.timeUnit)?.unit:void 0,B=n.orient||l.legend.orient||"right",G=E5i({legend:n,channel:i,timeUnit:v,scaleType:m}),T=W5i({legend:n,legendType:G,orient:B,legendConfig:c}),V={legend:n,channel:i,model:e,markDef:r,encoding:o,fieldOrDatumDef:p,legendConfig:c,config:l,scaleType:m,orient:B,legendType:G,direction:T};for(const F of Eit){if(G==="gradient"&&F.startsWith("symbol")||G==="symbol"&&F.startsWith("gradient"))continue;const Y=F in oKe?oKe[F](V):n[F];if(Y!==void 0){const L=M5i(Y,F,n,e.fieldDef(i));(L||l.legend[F]===void 0)&&u.set(F,Y,L)}}const E=n?.encoding??{},W=u.get("selections"),x={},k={fieldOrDatumDef:p,model:e,channel:i,legendCmpt:u,legendType:G};for(const F of["labels","legend","title","symbols","gradient","entries"]){const Y=Rit(E[F]??{},e),L=F in gKe?gKe[F](Y,k):Y;L!==void 0&&!Qr(L)&&(x[F]={...W?.length&&gi(p)?{name:`${Mg(p.field)}_legend_${F}`}:{},...W?.length?{interactive:!!W}:{},update:L})}return Qr(x)||u.set("encode",x,!!n?.encoding),u}function Y5i(e){const{legends:i,resolve:n}=e.component;for(const r of e.children){kit(r);for(const o of ei(r.component.legends))n.legend[o]=Ede(e.component.resolve,o),n.legend[o]==="shared"&&(i[o]=Xit(i[o],r.component.legends[o]),i[o]||(n.legend[o]="independent",delete i[o]))}for(const r of ei(i))for(const o of e.children)o.component.legends[r]&&n.legend[r]==="shared"&&delete o.component.legends[r];return i}function Xit(e,i){if(!e)return i.clone();const n=e.getWithExplicit("orient"),r=i.getWithExplicit("orient");if(n.explicit&&r.explicit&&n.value!==r.value)return;let o=!1;for(const l of Eit){const c=Qp(e.getWithExplicit(l),i.getWithExplicit(l),l,"legend",(u,f)=>{switch(l){case"symbolType":return K5i(u,f);case"title":return yet(u,f);case"type":return o=!0,Nl("symbol")}return NO(u,f,l,"legend")});e.setWithExplicit(l,c)}return o&&(e.implicit?.encode?.gradient&&w_(e.implicit,["encode","gradient"]),e.explicit?.encode?.gradient&&w_(e.explicit,["encode","gradient"])),e}function K5i(e,i){return i.value==="circle"?i:e}function _5i(e,i,n,r){var o,l;e.encode??(e.encode={}),(o=e.encode)[i]??(o[i]={}),(l=e.encode[i]).update??(l.update={}),e.encode[i].update[n]=r}function xit(e){const i=e.component.legends,n={};for(const o of ei(i)){const l=e.getScaleComponent(o),c=ug(l.get("domains"));if(n[c])for(const u of n[c])Xit(u,i[o])||n[c].push(i[o]);else n[c]=[i[o].clone()]}return Da(n).flat().map(o=>P5i(o,e.config)).filter(o=>o!==void 0)}function P5i(e,i){const{disable:n,labelExpr:r,selections:o,...l}=e.combine();if(!n){if(i.aria===!1&&l.aria==null&&(l.aria=!1),l.encode?.symbols){const c=l.encode.symbols.update;c.fill&&c.fill.value!=="transparent"&&!c.stroke&&!l.stroke&&(c.stroke={value:"transparent"});for(const u of Wtt)l[u]&&delete c[u]}if(l.title||delete l.title,r!==void 0){let c=r;l.encode?.labels?.update&&Fi(l.encode.labels.update.text)&&(c=Wv(r,"datum.label",l.encode.labels.update.text.signal)),_5i(l,"labels","text",{signal:c})}return l}}function z5i(e){return r2(e)||xde(e)?O5i(e):Dit(e)}function O5i(e){return e.children.reduce((i,n)=>i.concat(n.assembleProjections()),Dit(e))}function Dit(e){const i=e.component.projection;if(!i||i.merged)return[];const n=i.combine(),{name:r}=n;if(i.data){const o={signal:`[${i.size.map(c=>c.signal).join(", ")}]`},l=i.data.reduce((c,u)=>{const f=Fi(u)?u.signal:`data('${e.lookupDataSource(u)}')`;return jn(c,f)||c.push(f),c},[]);if(l.length<=0)throw new Error("Projection's fit didn't find any data sources");return[{name:r,size:o,fit:{signal:l.length>1?`[${l.join(", ")}]`:l[0]},...n}]}else return[{name:r,translate:{signal:"[width / 2, height / 2]"},...n}]}const L5i=["type","clipAngle","clipExtent","center","rotate","precision","reflectX","reflectY","coefficient","distance","fraction","lobes","parallel","radius","ratio","spacing","tilt"];class Mit extends Tf{constructor(i,n,r,o){super({...n},{name:i}),this.specifiedProjection=n,this.size=r,this.data=o,this.merged=!1}get isFit(){return!!this.data}}function Fit(e){e.component.projection=vo(e)?J5i(e):j5i(e)}function J5i(e){if(e.hasProjection){const i=OI(e.specifiedProjection),n=!(i&&(i.scale!=null||i.translate!=null)),r=n?[e.getSizeSignalRef("width"),e.getSizeSignalRef("height")]:void 0,o=n?U5i(e):void 0,l=new Mit(e.projectionName(!0),{...OI(e.config.projection)??{},...i??{}},r,o);return l.get("type")||l.set("type","equalEarth",!1),l}}function U5i(e){const i=[],{encoding:n}=e;for(const r of[[kA,NA],[jC,XA]])(Jo(n[r[0]])||Jo(n[r[1]]))&&i.push({signal:e.getName(`geojson_${i.length}`)});return e.channelHasField(Cl)&&e.typedFieldDef(Cl).type===qw&&i.push({signal:e.getName(`geojson_${i.length}`)}),i.length===0&&i.push(e.requestDataName(cg.Main)),i}function Q5i(e,i){const n=Zue(L5i,o=>!!(!Oi(e.explicit,o)&&!Oi(i.explicit,o)||Oi(e.explicit,o)&&Oi(i.explicit,o)&&Ku(e.get(o),i.get(o))));if(Ku(e.size,i.size)){if(n)return e;if(Ku(e.explicit,{}))return i;if(Ku(i.explicit,{}))return e}return null}function j5i(e){if(e.children.length===0)return;let i;for(const r of e.children)Fit(r);const n=Zue(e.children,r=>{const o=r.component.projection;if(o)if(i){const l=Q5i(i,o);return l&&(i=l),!!l}else return i=o,!0;else return!0});if(i&&n){const r=e.projectionName(!0),o=new Mit(r,i.specifiedProjection,i.size,vn(i.data));for(const l of e.children){const c=l.component.projection;c&&(c.isFit&&o.data.push(...l.component.projection.data),l.renameProjection(c.get("name"),r),c.merged=!0)}return o}}function $5i(e,i,n,r){if(yN(i,n)){const o=vo(e)?e.axis(n)??e.legend(n)??{}:{},l=di(i,{expr:"datum"}),c=di(i,{expr:"datum",binSuffix:"end"});return{formulaAs:di(i,{binSuffix:"range",forAs:!0}),formula:mN(l,c,o.format,o.formatType,r)}}return{}}function Yit(e,i){return`${Aet(e)}_${i}`}function q5i(e,i){return{signal:e.getName(`${i}_bins`),extentSignal:e.getName(`${i}_extent`)}}function Hde(e,i,n){const r=TO(n,void 0)??{},o=Yit(r,i);return e.getName(`${o}_bins`)}function eMi(e){return"as"in e}function sKe(e,i,n){let r,o;eMi(e)?r=fi(e.as)?[e.as,`${e.as}_end`]:[e.as[0],e.as[1]]:r=[di(e,{forAs:!0}),di(e,{binSuffix:"end",forAs:!0})];const l={...TO(i,void 0)},c=Yit(l,e.field),{signal:u,extentSignal:f}=q5i(n,c);if(fO(l.extent)){const p=l.extent;o=pit(n,p.param,p),delete l.extent}const m={bin:l,field:e.field,as:[r],...u?{signal:u}:{},...f?{extentSignal:f}:{},...o?{span:o}:{}};return{key:c,binComponent:m}}class rd extends qr{clone(){return new rd(null,vn(this.bins))}constructor(i,n){super(i),this.bins=n}static makeFromEncoding(i,n){const r=n.reduceFieldDef((o,l,c)=>{if(mI(l)&&dg(l.bin)){const{key:u,binComponent:f}=sKe(l,l.bin,n);o[u]={...f,...o[u],...$5i(n,l,c,n.config)}}return o},{});return Qr(r)?null:new rd(i,r)}static makeFromTransform(i,n,r){const{key:o,binComponent:l}=sKe(n,n.bin,r);return new rd(i,{[o]:l})}merge(i,n){for(const r of ei(i.bins))r in this.bins?(n(i.bins[r].signal,this.bins[r].signal),this.bins[r].as=_u([...this.bins[r].as,...i.bins[r].as],Ir)):this.bins[r]=i.bins[r];for(const r of i.children)i.removeChild(r),r.parent=this;i.remove()}producedFields(){return new Set(Da(this.bins).map(i=>i.as).flat(2))}dependentFields(){return new Set(Da(this.bins).map(i=>i.field))}hash(){return`Bin ${Ir(this.bins)}`}assemble(){return Da(this.bins).flatMap(i=>{const n=[],[r,...o]=i.as,{extent:l,...c}=i.bin,u={type:"bin",field:QC(i.field),as:r,signal:i.signal,...fO(l)?{extent:null}:{extent:l},...i.span?{span:{signal:`span(${i.span})`}}:{},...c};!l&&i.extentSignal&&(n.push({type:"extent",field:QC(i.field),signal:i.extentSignal}),u.extent={signal:i.extentSignal}),n.push(u);for(const f of o)for(let m=0;m<2;m++)n.push({type:"formula",expr:di({field:r[m]},{expr:"datum"}),as:f[m]});return i.formula&&n.push({type:"formula",expr:i.formula,as:i.formulaAs}),n})}}function tMi(e,i,n,r){const o=vo(r)?r.encoding[Ed(i)]:void 0;if(mI(n)&&vo(r)&&ott(n,o,r.markDef,r.config))e.add(di(n,{})),e.add(di(n,{suffix:"end"})),n.bin&&yN(n,i)&&e.add(di(n,{binSuffix:"range"}));else if(tet(i)){const l=eet(i);e.add(r.getName(l))}else e.add(di(n));return AZ(n)&&jki(n.scale?.range)&&e.add(n.scale.range.field),e}function iMi(e,i){for(const n of ei(i)){const r=i[n];for(const o of ei(r))n in e?e[n][o]=new Set([...e[n][o]??[],...r[o]]):e[n]={[o]:r[o]}}}class pA extends qr{clone(){return new pA(null,new Set(this.dimensions),vn(this.measures))}constructor(i,n,r){super(i),this.dimensions=n,this.measures=r}get groupBy(){return this.dimensions}static makeFromEncoding(i,n){let r=!1;n.forEachFieldDef(c=>{c.aggregate&&(r=!0)});const o={},l=new Set;return!r||(n.forEachFieldDef((c,u)=>{const{aggregate:f,field:m}=c;if(f)if(f==="count")o["*"]??(o["*"]={}),o["*"].count=new Set([di(c,{forAs:!0})]);else{if(Af(f)||p0(f)){const p=Af(f)?"argmin":"argmax",v=f[p];o[v]??(o[v]={}),o[v][p]=new Set([di({op:p,field:v},{forAs:!0})])}else o[m]??(o[m]={}),o[m][f]=new Set([di(c,{forAs:!0})]);Sf(u)&&n.scaleDomain(u)==="unaggregated"&&(o[m]??(o[m]={}),o[m].min=new Set([di({field:m,aggregate:"min"},{forAs:!0})]),o[m].max=new Set([di({field:m,aggregate:"max"},{forAs:!0})]))}else tMi(l,u,c,n)}),l.size+ei(o).length===0)?null:new pA(i,l,o)}static makeFromTransform(i,n){const r=new Set,o={};for(const l of n.aggregate){const{op:c,field:u,as:f}=l;c&&(c==="count"?(o["*"]??(o["*"]={}),o["*"].count=new Set([f||di(l,{forAs:!0})])):(o[u]??(o[u]={}),o[u][c]=new Set([f||di(l,{forAs:!0})])))}for(const l of n.groupby??[])r.add(l);return r.size+ei(o).length===0?null:new pA(i,r,o)}merge(i){return Oqe(this.dimensions,i.dimensions)?(iMi(this.measures,i.measures),!0):(Zki("different dimensions, cannot merge"),!1)}addDimensions(i){i.forEach(this.dimensions.add,this.dimensions)}dependentFields(){return new Set([...this.dimensions,...ei(this.measures)])}producedFields(){const i=new Set;for(const n of ei(this.measures))for(const r of ei(this.measures[n])){const o=this.measures[n][r];o.size===0?i.add(`${r}_${n}`):o.forEach(i.add,i)}return i}hash(){return`Aggregate ${Ir({dimensions:this.dimensions,measures:this.measures})}`}assemble(){const i=[],n=[],r=[];for(const l of ei(this.measures))for(const c of ei(this.measures[l]))for(const u of this.measures[l][c])r.push(u),i.push(c),n.push(l==="*"?null:QC(l));return{type:"aggregate",groupby:[...this.dimensions].map(QC),ops:i,fields:n,as:r}}}class i2 extends qr{constructor(i,n,r,o){super(i),this.model=n,this.name=r,this.data=o;for(const l of xC){const c=n.facet[l];if(c){const{bin:u,sort:f}=c;this[l]={name:n.getName(`${l}_domain`),fields:[di(c),...dg(u)?[di(c,{binSuffix:"end"})]:[]],...id(f)?{sortField:f}:Pt(f)?{sortIndexField:pw(c,l)}:{}}}}this.childModel=n.child}hash(){let i="Facet";for(const n of xC)this[n]&&(i+=` ${n.charAt(0)}:${Ir(this[n])}`);return i}get fields(){const i=[];for(const n of xC)this[n]?.fields&&i.push(...this[n].fields);return i}dependentFields(){const i=new Set(this.fields);for(const n of xC)this[n]&&(this[n].sortField&&i.add(this[n].sortField.field),this[n].sortIndexField&&i.add(this[n].sortIndexField));return i}producedFields(){return new Set}getSource(){return this.name}getChildIndependentFieldsWithStep(){const i={};for(const n of Hd){const r=this.childModel.component.scales[n];if(r&&!r.merged){const o=r.get("type"),l=r.get("range");if(fa(o)&&b0(l)){const c=MO(this.childModel,n),u=Xde(c);u?i[n]=u:ni(xue(n))}}}return i}assembleRowColumnHeaderData(i,n,r){const o={row:"y",column:"x",facet:void 0}[i],l=[],c=[],u=[];o&&r&&r[o]&&(n?(l.push(`distinct_${r[o]}`),c.push("max")):(l.push(r[o]),c.push("distinct")),u.push(`distinct_${r[o]}`));const{sortField:f,sortIndexField:m}=this[i];if(f){const{op:p=BO,field:v}=f;l.push(v),c.push(p),u.push(di(f,{forAs:!0}))}else m&&(l.push(m),c.push("max"),u.push(m));return{name:this[i].name,source:n??this.data,transform:[{type:"aggregate",groupby:this[i].fields,...l.length?{fields:l,ops:c,as:u}:{}}]}}assembleFacetHeaderData(i){const{columns:n}=this.model.layout,{layoutHeaders:r}=this.model.component,o=[],l={};for(const f of Tde){for(const m of Rde){const p=(r[f]&&r[f][m])??[];for(const v of p)if(v.axes?.length>0){l[f]=!0;break}}if(l[f]){const m=`length(data("${this.facet.name}"))`,p=f==="row"?n?{signal:`ceil(${m} / ${n})`}:1:n?{signal:`min(${m}, ${n})`}:{signal:m};o.push({name:`${this.facet.name}_${f}`,transform:[{type:"sequence",start:0,stop:p}]})}}const{row:c,column:u}=l;return(c||u)&&o.unshift(this.assembleRowColumnHeaderData("facet",null,i)),o}assemble(){const i=[];let n=null;const r=this.getChildIndependentFieldsWithStep(),{column:o,row:l,facet:c}=this;if(o&&l&&(r.x||r.y)){n=`cross_${this.column.name}_${this.row.name}`;const u=[].concat(r.x??[],r.y??[]),f=u.map(()=>"distinct");i.push({name:n,source:this.data,transform:[{type:"aggregate",groupby:this.fields,fields:u,ops:f}]})}for(const u of[Qh,Uh])this[u]&&i.push(this.assembleRowColumnHeaderData(u,n,r));if(c){const u=this.assembleFacetHeaderData(r);u&&i.push(...u)}return i}}function IKe(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}function nMi(e,i){const n=Sue(e);if(i==="number")return`toNumber(${n})`;if(i==="boolean")return`toBoolean(${n})`;if(i==="string")return`toString(${n})`;if(i==="date")return`toDate(${n})`;if(i==="flatten")return n;if(i.startsWith("date:")){const r=IKe(i.slice(5,i.length));return`timeParse(${n},'${r}')`}else if(i.startsWith("utc:")){const r=IKe(i.slice(4,i.length));return`utcParse(${n},'${r}')`}else return ni(VNi(i)),null}function rMi(e){const i={};return UY(e.filter,n=>{if(Xet(n)){let r=null;Yue(n)?r=Dl(n.equal):_ue(n)?r=Dl(n.lte):Kue(n)?r=Dl(n.lt):Pue(n)?r=Dl(n.gt):zue(n)?r=Dl(n.gte):Oue(n)?r=n.range[0]:Lue(n)&&(r=(n.oneOf??n.in)[0]),r&&(cZ(r)?i[n.field]="date":jr(r)?i[n.field]="number":fi(r)&&(i[n.field]="string")),n.timeUnit&&(i[n.field]="date")}}),i}function gMi(e){const i={};function n(r){hw(r)?i[r.field]="date":r.type==="quantitative"&&sNi(r.aggregate)?i[r.field]="number":lw(r.field)>1?r.field in i||(i[r.field]="flatten"):AZ(r)&&id(r.sort)&&lw(r.sort.field)>1&&(r.sort.field in i||(i[r.sort.field]="flatten"))}if((vo(e)||bA(e))&&e.forEachFieldDef((r,o)=>{if(mI(r))n(r);else{const l=lZ(o),c=e.fieldDef(l);n({...r,type:c.type})}}),vo(e)){const{mark:r,markDef:o,encoding:l}=e;if(y0(r)&&!e.encoding.order){const c=o.orient==="horizontal"?"y":"x",u=l[c];gi(u)&&u.type==="quantitative"&&!(u.field in i)&&(i[u.field]="number")}}return i}function oMi(e){const i={};if(vo(e)&&e.component.selection)for(const n of ei(e.component.selection)){const r=e.component.selection[n];for(const o of r.project.items)!o.channel&&lw(o.field)>1&&(i[o.field]="flatten")}return i}class Ss extends qr{clone(){return new Ss(null,vn(this._parse))}constructor(i,n){super(i),this._parse=n}hash(){return`Parse ${Ir(this._parse)}`}static makeExplicit(i,n,r){let o={};const l=n.data;return!Ep(l)&&l?.format?.parse&&(o=l.format.parse),this.makeWithAncestors(i,o,{},r)}static makeWithAncestors(i,n,r,o){for(const u of ei(r)){const f=o.getWithExplicit(u);f.value!==void 0&&(f.explicit||f.value===r[u]||f.value==="derived"||r[u]==="flatten"?delete r[u]:ni(ZYe(u,r[u],f.value)))}for(const u of ei(n)){const f=o.get(u);f!==void 0&&(f===n[u]?delete n[u]:ni(ZYe(u,n[u],f)))}const l=new Tf(n,r);o.copyAll(l);const c={};for(const u of ei(l.combine())){const f=l.get(u);f!==null&&(c[u]=f)}return ei(c).length===0||o.parseNothing?null:new Ss(i,c)}get parse(){return this._parse}merge(i){this._parse={...this._parse,...i.parse},i.remove()}assembleFormatParse(){const i={};for(const n of ei(this._parse)){const r=this._parse[n];lw(n)===1&&(i[n]=r)}return i}producedFields(){return new Set(ei(this._parse))}dependentFields(){return new Set(ei(this._parse))}assembleTransforms(i=!1){return ei(this._parse).filter(n=>i?lw(n)>1:!0).map(n=>{const r=nMi(n,this._parse[n]);return r?{type:"formula",expr:r,as:wue(n)}:null}).filter(n=>n!==null)}}class qp extends qr{clone(){return new qp(null)}constructor(i){super(i)}dependentFields(){return new Set}producedFields(){return new Set([TA])}hash(){return"Identifier"}assemble(){return{type:"identifier",as:TA}}}class BN extends qr{clone(){return new BN(null,this.params)}constructor(i,n){super(i),this.params=n}dependentFields(){return new Set}producedFields(){}hash(){return`Graticule ${Ir(this.params)}`}assemble(){return{type:"graticule",...this.params===!0?{}:this.params}}}class GN extends qr{clone(){return new GN(null,this.params)}constructor(i,n){super(i),this.params=n}dependentFields(){return new Set}producedFields(){return new Set([this.params.as??"data"])}hash(){return`Hash ${Ir(this.params)}`}assemble(){return{type:"sequence",...this.params}}}class Kv extends qr{constructor(i){super(null),i??(i={name:"source"});let n;if(Ep(i)||(n=i.format?{...nl(i.format,["parse"])}:{}),oW(i))this._data={values:i.values};else if(fw(i)){if(this._data={url:i.url},!n.type){let r=/(?:\.([^.]+))?$/.exec(i.url)[1];jn(["json","csv","tsv","dsv","topojson"],r)||(r="json"),n.type=r}}else Qtt(i)?this._data={values:[{type:"Sphere"}]}:(Jtt(i)||Ep(i))&&(this._data={});this._generator=Ep(i),i.name&&(this._name=i.name),n&&!Qr(n)&&(this._data.format=n)}dependentFields(){return new Set}producedFields(){}get data(){return this._data}hasName(){return!!this._name}get isGenerator(){return this._generator}get dataName(){return this._name}set dataName(i){this._name=i}set parent(i){throw new Error("Source nodes have to be roots.")}remove(){throw new Error("Source nodes are roots and cannot be removed.")}hash(){throw new Error("Cannot hash sources")}assemble(){return{name:this._name,...this._data,transform:[]}}}var lKe=globalThis&&globalThis.__classPrivateFieldSet||function(e,i,n,r,o){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof i=="function"?e!==i||!o:!i.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?o.call(e,n):o?o.value=n:i.set(e,n),n},aMi=globalThis&&globalThis.__classPrivateFieldGet||function(e,i,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof i=="function"?e!==i||!r:!i.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(e):r?r.value:i.get(e)},rE;function Wde(e){return e instanceof Kv||e instanceof BN||e instanceof GN}class Nde{constructor(){rE.set(this,void 0),lKe(this,rE,!1,"f")}setModified(){lKe(this,rE,!0,"f")}get modifiedFlag(){return aMi(this,rE,"f")}}rE=new WeakMap;class uZ extends Nde{getNodeDepths(i,n,r){r.set(i,n);for(const o of i.children)this.getNodeDepths(o,n+1,r);return r}optimize(i){const r=[...this.getNodeDepths(i,0,new Map).entries()].sort((o,l)=>l[1]-o[1]);for(const o of r)this.run(o[0]);return this.modifiedFlag}}class kde extends Nde{optimize(i){this.run(i);for(const n of i.children)this.optimize(n);return this.modifiedFlag}}class sMi extends kde{mergeNodes(i,n){const r=n.shift();for(const o of n)i.removeChild(o),o.parent=r,o.remove()}run(i){const n=i.children.map(o=>o.hash()),r={};for(let o=0;o1&&(this.setModified(),this.mergeNodes(i,r[o]))}}class IMi extends kde{constructor(i){super(),this.requiresSelectionId=i&&wde(i)}run(i){i instanceof qp&&(this.requiresSelectionId&&(Wde(i.parent)||i.parent instanceof pA||i.parent instanceof Ss)||(this.setModified(),i.remove()))}}class lMi extends Nde{optimize(i){return this.run(i,new Set),this.modifiedFlag}run(i,n){let r=new Set;i instanceof nd&&(r=i.producedFields(),Bue(r,n)&&(this.setModified(),i.removeFormulas(n),i.producedFields.length===0&&i.remove()));for(const o of i.children)this.run(o,new Set([...n,...r]))}}class CMi extends kde{constructor(){super()}run(i){i instanceof dI&&!i.isRequired()&&(this.setModified(),i.remove())}}class cMi extends uZ{run(i){if(!Wde(i)&&!(i.numChildren()>1)){for(const n of i.children)if(n instanceof Ss)if(i instanceof Ss)this.setModified(),i.merge(n);else{if(Gue(i.producedFields(),n.dependentFields()))continue;this.setModified(),n.swapWithParent()}}}}class AMi extends uZ{run(i){const n=[...i.children],r=i.children.filter(o=>o instanceof Ss);if(i.numChildren()>1&&r.length>=1){const o={},l=new Set;for(const c of r){const u=c.parse;for(const f of ei(u))f in o?o[f]!==u[f]&&l.add(f):o[f]=u[f]}for(const c of l)delete o[c];if(!Qr(o)){this.setModified();const c=new Ss(i,o);for(const u of n){if(u instanceof Ss)for(const f of ei(o))delete u.parse[f];i.removeChild(u),u.parent=c,u instanceof Ss&&ei(u.parse).length===0&&u.remove()}}}}}class uMi extends uZ{run(i){i instanceof dI||i.numChildren()>0||i instanceof i2||i instanceof Kv||(this.setModified(),i.remove())}}class dMi extends uZ{run(i){const n=i.children.filter(o=>o instanceof nd),r=n.pop();for(const o of n)this.setModified(),r.merge(o)}}class hMi extends uZ{run(i){const n=i.children.filter(o=>o instanceof pA),r={};for(const o of n){const l=Ir(o.groupBy);l in r||(r[l]=[]),r[l].push(o)}for(const o of ei(r)){const l=r[o];if(l.length>1){const c=l.pop();for(const u of l)c.merge(u)&&(i.removeChild(u),u.parent=c,u.remove(),this.setModified())}}}}class fMi extends uZ{constructor(i){super(),this.model=i}run(i){const n=!(Wde(i)||i instanceof t2||i instanceof Ss||i instanceof qp),r=[],o=[];for(const l of i.children)l instanceof rd&&(n&&!Gue(i.producedFields(),l.dependentFields())?r.push(l):o.push(l));if(r.length>0){const l=r.pop();for(const c of r)l.merge(c,this.model.renameSignal.bind(this.model));this.setModified(),i instanceof rd?i.merge(l,this.model.renameSignal.bind(this.model)):l.swapWithParent()}if(o.length>1){const l=o.pop();for(const c of o)l.merge(c,this.model.renameSignal.bind(this.model));this.setModified()}}}class mMi extends uZ{run(i){const n=[...i.children];if(!Hv(n,c=>c instanceof dI)||i.numChildren()<=1)return;const o=[];let l;for(const c of n)if(c instanceof dI){let u=c;for(;u.numChildren()===1;){const[f]=u.children;if(f instanceof dI)u=f;else break}o.push(...u.children),l?(i.removeChild(c),c.parent=l.parent,l.parent.removeChild(l),l.parent=u,this.setModified()):l=u}else o.push(c);if(o.length){this.setModified();for(const c of o)c.parent.removeChild(c),c.parent=l}}}class dZ extends qr{clone(){return new dZ(null,vn(this.transform))}constructor(i,n){super(i),this.transform=n}addDimensions(i){this.transform.groupby=_u(this.transform.groupby.concat(i),n=>n)}dependentFields(){const i=new Set;return this.transform.groupby&&this.transform.groupby.forEach(i.add,i),this.transform.joinaggregate.map(n=>n.field).filter(n=>n!==void 0).forEach(i.add,i),i}producedFields(){return new Set(this.transform.joinaggregate.map(this.getDefaultName))}getDefaultName(i){return i.as??di(i)}hash(){return`JoinAggregateTransform ${Ir(this.transform)}`}assemble(){const i=[],n=[],r=[];for(const l of this.transform.joinaggregate)n.push(l.op),r.push(this.getDefaultName(l)),i.push(l.field===void 0?null:l.field);const o=this.transform.groupby;return{type:"joinaggregate",as:r,ops:n,fields:i,...o!==void 0?{groupby:o}:{}}}}function pMi(e){return e.stack.stackBy.reduce((i,n)=>{const r=n.fieldDef,o=di(r);return o&&i.push(o),i},[])}function bMi(e){return Pt(e)&&e.every(i=>fi(i))&&e.length>1}class qh extends qr{clone(){return new qh(null,vn(this._stack))}constructor(i,n){super(i),this._stack=n}static makeFromTransform(i,n){const{stack:r,groupby:o,as:l,offset:c="zero"}=n,u=[],f=[];if(n.sort!==void 0)for(const v of n.sort)u.push(v.field),f.push(Ho(v.order,"ascending"));const m={field:u,order:f};let p;return bMi(l)?p=l:fi(l)?p=[l,`${l}_end`]:p=[`${n.stack}_start`,`${n.stack}_end`],new qh(i,{dimensionFieldDefs:[],stackField:r,groupby:o,offset:c,sort:m,facetby:[],as:p})}static makeFromEncoding(i,n){const r=n.stack,{encoding:o}=n;if(!r)return null;const{groupbyChannels:l,fieldChannel:c,offset:u,impute:f}=r,m=l.map(G=>{const T=o[G];return md(T)}).filter(G=>!!G),p=pMi(n),v=n.encoding.order;let B;return Pt(v)||gi(v)?B=met(v):B=p.reduce((G,T)=>(G.field.push(T),G.order.push(c==="y"?"descending":"ascending"),G),{field:[],order:[]}),new qh(i,{dimensionFieldDefs:m,stackField:n.vgField(c),facetby:[],stackby:p,sort:B,offset:u,impute:f,as:[n.vgField(c,{suffix:"start",forAs:!0}),n.vgField(c,{suffix:"end",forAs:!0})]})}get stack(){return this._stack}addDimensions(i){this._stack.facetby.push(...i)}dependentFields(){const i=new Set;return i.add(this._stack.stackField),this.getGroupbyFields().forEach(i.add,i),this._stack.facetby.forEach(i.add,i),this._stack.sort.field.forEach(i.add,i),i}producedFields(){return new Set(this._stack.as)}hash(){return`Stack ${Ir(this._stack)}`}getGroupbyFields(){const{dimensionFieldDefs:i,impute:n,groupby:r}=this._stack;return i.length>0?i.map(o=>o.bin?n?[di(o,{binSuffix:"mid"})]:[di(o,{}),di(o,{binSuffix:"end"})]:[di(o)]).flat():r??[]}assemble(){const i=[],{facetby:n,dimensionFieldDefs:r,stackField:o,stackby:l,sort:c,offset:u,impute:f,as:m}=this._stack;if(f)for(const p of r){const{bandPosition:v=.5,bin:B}=p;if(B){const G=di(p,{expr:"datum"}),T=di(p,{expr:"datum",binSuffix:"end"});i.push({type:"formula",expr:`${v}*${G}+${1-v}*${T}`,as:di(p,{binSuffix:"mid",forAs:!0})})}i.push({type:"impute",field:o,groupby:[...l,...n],key:di(p,{binSuffix:"mid"}),method:"value",value:0})}return i.push({type:"stack",groupby:[...this.getGroupbyFields(),...n],field:o,sort:c,as:m,offset:u}),i}}class n2 extends qr{clone(){return new n2(null,vn(this.transform))}constructor(i,n){super(i),this.transform=n}addDimensions(i){this.transform.groupby=_u(this.transform.groupby.concat(i),n=>n)}dependentFields(){const i=new Set;return(this.transform.groupby??[]).forEach(i.add,i),(this.transform.sort??[]).forEach(n=>i.add(n.field)),this.transform.window.map(n=>n.field).filter(n=>n!==void 0).forEach(i.add,i),i}producedFields(){return new Set(this.transform.window.map(this.getDefaultName))}getDefaultName(i){return i.as??di(i)}hash(){return`WindowTransform ${Ir(this.transform)}`}assemble(){const i=[],n=[],r=[],o=[];for(const v of this.transform.window)n.push(v.op),r.push(this.getDefaultName(v)),o.push(v.param===void 0?null:v.param),i.push(v.field===void 0?null:v.field);const l=this.transform.frame,c=this.transform.groupby;if(l&&l[0]===null&&l[1]===null&&n.every(v=>kue(v)))return{type:"joinaggregate",as:r,ops:n,fields:i,...c!==void 0?{groupby:c}:{}};const u=[],f=[];if(this.transform.sort!==void 0)for(const v of this.transform.sort)u.push(v.field),f.push(v.order??"ascending");const m={field:u,order:f},p=this.transform.ignorePeers;return{type:"window",params:o,as:r,ops:n,fields:i,sort:m,...p!==void 0?{ignorePeers:p}:{},...c!==void 0?{groupby:c}:{},...l!==void 0?{frame:l}:{}}}}function yMi(e){function i(n){if(!(n instanceof i2)){const r=n.clone();if(r instanceof dI){const o=yae+r.getSource();r.setSource(o),e.model.component.data.outputNodes[o]=r}else(r instanceof pA||r instanceof qh||r instanceof n2||r instanceof dZ)&&r.addDimensions(e.fields);for(const o of n.children.flatMap(i))o.parent=r;return[r]}return n.children.flatMap(i)}return i}function bae(e){if(e instanceof i2)if(e.numChildren()===1&&!(e.children[0]instanceof dI)){const i=e.children[0];(i instanceof pA||i instanceof qh||i instanceof n2||i instanceof dZ)&&i.addDimensions(e.fields),i.swapWithParent(),bae(e)}else{const i=e.model.component.data.main;Kit(i);const n=yMi(e),r=e.children.map(n).flat();for(const o of r)o.parent=i}else e.children.map(bae)}function Kit(e){if(e instanceof dI&&e.type===cg.Main&&e.numChildren()===1){const i=e.children[0];i instanceof i2||(i.swapWithParent(),Kit(e))}}const yae="scale_",UF=5;function vae(e){for(const i of e){for(const n of i.children)if(n.parent!==i)return!1;if(!vae(i.children))return!1}return!0}function _c(e,i){let n=!1;for(const r of i)n=e.optimize(r)||n;return n}function CKe(e,i,n){let r=e.sources,o=!1;return o=_c(new CMi,r)||o,o=_c(new IMi(i),r)||o,r=r.filter(l=>l.numChildren()>0),o=_c(new uMi,r)||o,r=r.filter(l=>l.numChildren()>0),n||(o=_c(new cMi,r)||o,o=_c(new fMi(i),r)||o,o=_c(new lMi,r)||o,o=_c(new AMi,r)||o,o=_c(new hMi,r)||o,o=_c(new dMi,r)||o,o=_c(new sMi,r)||o,o=_c(new mMi,r)||o),e.sources=r,o}function vMi(e,i){vae(e.sources);let n=0,r=0;for(let o=0;oi(n))}}function _it(e){vo(e)?ZMi(e):BMi(e)}function ZMi(e){const i=e.component.scales;for(const n of ei(i)){const r=SMi(e,n);if(i[n].setWithExplicit("domains",r),TMi(e,n),e.component.data.isFaceted){let l=e;for(;!bA(l)&&l.parent;)l=l.parent;if(l.component.resolve.scale[n]==="shared")for(const u of r.value)Kh(u)&&(u.data=yae+u.data.replace(yae,""))}}}function BMi(e){for(const n of e.children)_it(n);const i=e.component.scales;for(const n of ei(i)){let r,o=null;for(const l of e.children){const c=l.component.scales[n];if(c){r===void 0?r=c.getWithExplicit("domains"):r=Qp(r,c.getWithExplicit("domains"),"domains","scale",Zae);const u=c.get("selectionExtent");o&&u&&o.param!==u.param&&ni(SNi),o=u}}i[n].setWithExplicit("domains",r),o&&i[n].set("selectionExtent",o,!0)}}function GMi(e,i,n,r){if(e==="unaggregated"){const{valid:o,reason:l}=cKe(i,n);if(!o){ni(l);return}}else if(e===void 0&&r.useUnaggregatedDomain){const{valid:o}=cKe(i,n);if(o)return"unaggregated"}return e}function SMi(e,i){const n=e.getScaleComponent(i).get("type"),{encoding:r}=e,o=GMi(e.scaleDomain(i),e.typedFieldDef(i),n,e.config.scale);return o!==e.scaleDomain(i)&&(e.specifiedScales[i]={...e.specifiedScales[i],domain:o}),i==="x"&&Jo(r.x2)?Jo(r.x)?Qp(Fm(n,o,e,"x"),Fm(n,o,e,"x2"),"domain","scale",Zae):Fm(n,o,e,"x2"):i==="y"&&Jo(r.y2)?Jo(r.y)?Qp(Fm(n,o,e,"y"),Fm(n,o,e,"y2"),"domain","scale",Zae):Fm(n,o,e,"y2"):Fm(n,o,e,i)}function wMi(e,i,n){return e.map(r=>({signal:`{data: ${RO(r,{timeUnit:n,type:i})}}`}))}function tie(e,i,n){const r=Ya(n)?.unit;return i==="temporal"||r?wMi(e,i,r):[e]}function Fm(e,i,n,r){const{encoding:o}=n,l=Jo(o[r]),{type:c}=l,u=l.timeUnit;if(Qki(i)){const v=Fm(e,void 0,n,r),B=tie(i.unionWith,c,u);return Eu([...B,...v.value])}else{if(Fi(i))return Eu([i]);if(i&&i!=="unaggregated"&&!_et(i))return Eu(tie(i,c,u))}const f=n.stack;if(f&&r===f.fieldChannel){if(f.offset==="normalize")return Nl([[0,1]]);const v=n.requestDataName(cg.Main);return Nl([{data:v,field:n.vgField(r,{suffix:"start"})},{data:v,field:n.vgField(r,{suffix:"end"})}])}const m=Sf(r)&&gi(l)?RMi(n,r,e):void 0;if(Wd(l)){const v=tie([l.datum],c,u);return Nl(v)}const p=l;if(i==="unaggregated"){const v=n.requestDataName(cg.Main),{field:B}=l;return Nl([{data:v,field:di({field:B,aggregate:"min"})},{data:v,field:di({field:B,aggregate:"max"})}])}else if(dg(p.bin)){if(fa(e))return Nl(e==="bin-ordinal"?[]:[{data:rW(m)?n.requestDataName(cg.Main):n.requestDataName(cg.Raw),field:n.vgField(r,yN(p,r)?{binSuffix:"range"}:{}),sort:m===!0||!vi(m)?{field:n.vgField(r,{}),op:"min"}:m}]);{const{bin:v}=p;if(dg(v)){const B=Hde(n,p.field,v);return Nl([new gl(()=>{const G=n.getSignalName(B);return`[${G}.start, ${G}.stop]`})])}else return Nl([{data:n.requestDataName(cg.Main),field:n.vgField(r,{})}])}}else if(p.timeUnit&&jn(["time","utc"],e)&&ott(p,vo(n)?n.encoding[Ed(r)]:void 0,n.markDef,n.config)){const v=n.requestDataName(cg.Main);return Nl([{data:v,field:n.vgField(r)},{data:v,field:n.vgField(r,{suffix:"end"})}])}else return Nl(m?[{data:rW(m)?n.requestDataName(cg.Main):n.requestDataName(cg.Raw),field:n.vgField(r),sort:m}]:[{data:n.requestDataName(cg.Main),field:n.vgField(r)}])}function iie(e,i){const{op:n,field:r,order:o}=e;return{op:n??(i?"sum":BO),...r?{field:QC(r)}:{},...o?{order:o}:{}}}function TMi(e,i){const n=e.component.scales[i],r=e.specifiedScales[i].domain,o=e.fieldDef(i)?.bin,l=_et(r)&&r,c=CZ(o)&&fO(o.extent)&&o.extent;(l||c)&&n.set("selectionExtent",l??c,!0)}function RMi(e,i,n){if(!fa(n))return;const r=e.fieldDef(i),o=r.sort;if(ntt(o))return{op:"min",field:pw(r,i),order:"ascending"};const{stack:l}=e,c=l?new Set([...l.groupbyFields,...l.stackBy.map(u=>u.fieldDef.field)]):void 0;if(id(o)){const u=l&&!c.has(o.field);return iie(o,u)}else if(itt(o)){const{encoding:u,order:f}=o,m=e.fieldDef(u),{aggregate:p,field:v}=m,B=l&&!c.has(v);if(Af(p)||p0(p))return iie({field:di(m),order:f},B);if(kue(p)||!p)return iie({op:p,field:v,order:f},B)}else{if(o==="descending")return{op:"min",field:e.vgField(i),order:"descending"};if(jn(["ascending",void 0],o))return!0}}function cKe(e,i){const{aggregate:n,type:r}=e;return n?fi(n)&&!lNi.has(n)?{valid:!1,reason:eki(n)}:r==="quantitative"&&i==="log"?{valid:!1,reason:tki(e)}:{valid:!0}:{valid:!1,reason:qNi(e)}}function Zae(e,i,n,r){return e.explicit&&i.explicit&&ni(oki(n,r,e.value,i.value)),{explicit:e.explicit,value:[...e.value,...i.value]}}function VMi(e){const i=_u(e.map(c=>{if(Kh(c)){const{sort:u,...f}=c;return f}return c}),Ir),n=_u(e.map(c=>{if(Kh(c)){const u=c.sort;return u!==void 0&&!rW(u)&&("op"in u&&u.op==="count"&&delete u.field,u.order==="ascending"&&delete u.order),u}}).filter(c=>c!==void 0),Ir);if(i.length===0)return;if(i.length===1){const c=e[0];if(Kh(c)&&n.length>0){let u=n[0];if(n.length>1){ni(GYe);const f=n.filter(m=>vi(m)&&"op"in m&&m.op!=="min");n.every(m=>vi(m)&&"op"in m)&&f.length===1?u=f[0]:u=!0}else if(vi(u)&&"field"in u){const f=u.field;c.field===f&&(u=u.order?{order:u.order}:!0)}return{...c,sort:u}}return c}const r=_u(n.map(c=>rW(c)||!("op"in c)||fi(c.op)&&c.op in oNi?c:(ni(ski(c)),!0)),Ir);let o;r.length===1?o=r[0]:r.length>1&&(ni(GYe),o=!0);const l=_u(e.map(c=>Kh(c)?c.data:null),c=>c);return l.length===1&&l[0]!==null?{data:l[0],fields:i.map(u=>u.field),...o?{sort:o}:{}}:{fields:i,...o?{sort:o}:{}}}function Xde(e){if(Kh(e)&&fi(e.field))return e.field;if(CNi(e)){let i;for(const n of e.fields)if(Kh(n)&&fi(n.field)){if(!i)i=n.field;else if(i!==n.field)return ni(Iki),i}return ni(lki),i}else if(cNi(e)){ni(Cki);const i=e.fields[0];return fi(i)?i:void 0}}function MO(e,i){const r=e.component.scales[i].get("domains").map(o=>(Kh(o)&&(o.data=e.lookupDataSource(o.data)),o));return VMi(r)}function Pit(e){return r2(e)||xde(e)?e.children.reduce((i,n)=>i.concat(Pit(n)),AKe(e)):AKe(e)}function AKe(e){return ei(e.component.scales).reduce((i,n)=>{const r=e.component.scales[n];if(r.merged)return i;const o=r.combine(),{name:l,type:c,selectionExtent:u,domains:f,range:m,reverse:p,...v}=o,B=EMi(o.range,l,n,e),G=MO(e,n),T=u?GDi(e,u,r,G):null;return i.push({name:l,type:c,...G?{domain:G}:{},...T?{domainRaw:T}:{},range:B,...p!==void 0?{reverse:p}:{},...v}),i},[])}function EMi(e,i,n,r){if(ha(n)){if(b0(e))return{step:{signal:`${i}_step`}}}else if(vi(e)&&Kh(e))return{...e,data:r.lookupDataSource(e.data)};return e}class zit extends Tf{constructor(i,n){super({},{name:i}),this.merged=!1,this.setWithExplicit("type",n)}domainDefinitelyIncludesZero(){return this.get("zero")!==!1?!0:Hv(this.get("domains"),i=>Pt(i)&&i.length===2&&i[0]<=0&&i[1]>=0)}}const HMi=["range","scheme"];function WMi(e){const i=e.component.scales;for(const n of hO){const r=i[n];if(!r)continue;const o=NMi(n,e);r.setWithExplicit("range",o)}}function uKe(e,i){const n=e.fieldDef(i);if(n?.bin){const{bin:r,field:o}=n,l=cl(i),c=e.getName(l);if(vi(r)&&r.binned&&r.step!==void 0)return new gl(()=>{const u=e.scaleName(i),f=`(domain("${u}")[1] - domain("${u}")[0]) / ${r.step}`;return`${e.getSignalName(c)} / (${f})`});if(dg(r)){const u=Hde(e,o,r);return new gl(()=>{const f=e.getSignalName(u),m=`(${f}.stop - ${f}.start) / ${f}.step`;return`${e.getSignalName(c)} / (${m})`})}}}function NMi(e,i){const n=i.specifiedScales[e],{size:r}=i,l=i.getScaleComponent(e).get("type");for(const v of HMi)if(n[v]!==void 0){const B=oae(l,v),G=Pet(e,v);if(!B)ni(Get(l,v,e));else if(G)ni(G);else switch(v){case"range":{const T=n.range;if(Pt(T)){if(ha(e))return Eu(T.map(V=>{if(V==="width"||V==="height"){const E=i.getName(V),W=i.getSignalName.bind(i);return gl.fromName(W,E)}return V}))}else if(vi(T))return Eu({data:i.requestDataName(cg.Main),field:T.field,sort:{op:"min",field:i.vgField(e)}});return Eu(T)}case"scheme":return Eu(kMi(n[v]))}}const c=e===Fg||e==="xOffset"?"width":"height",u=r[c];if(pd(u)){if(ha(e))if(fa(l)){const v=Oit(u,i,e);if(v)return Eu({step:v})}else ni(wet(c));else if($w(e)){const v=e===u0?"x":"y";if(i.getScaleComponent(v).get("type")==="band"){const T=Lit(u,l);if(T)return Eu(T)}}}const{rangeMin:f,rangeMax:m}=n,p=XMi(e,i);return(f!==void 0||m!==void 0)&&oae(l,"rangeMin")&&Pt(p)&&p.length===2?Eu([f??p[0],m??p[1]]):Nl(p)}function kMi(e){return Uki(e)?{scheme:e.name,...nl(e,["name"])}:{scheme:e}}function XMi(e,i){const{size:n,config:r,mark:o,encoding:l}=i,c=i.getSignalName.bind(i),{type:u}=Jo(l[e]),m=i.getScaleComponent(e).get("type"),{domain:p,domainMid:v}=i.specifiedScales[e];switch(e){case Fg:case da:{if(jn(["point","band"],m)){const T=Jit(e,n,r.view);if(pd(T))return{step:Oit(T,i,e)}}const B=cl(e),G=i.getName(B);return e===da&&Ul(m)?[gl.fromName(c,G),0]:[0,gl.fromName(c,G)]}case u0:case jw:return xMi(e,i,m);case Bf:{const B=i.component.scales[e].get("zero"),G=Uit(o,B,r),T=FMi(o,n,i,r);return Aw(m)?MMi(G,T,DMi(m,r,p,e)):[G,T]}case qC:return[0,Math.PI*2];case IZ:return[0,360];case WA:return[0,new gl(()=>{const B=i.getSignalName("width"),G=i.getSignalName("height");return`min(${B},${G})/2`})];case f0:return[r.scale.minStrokeWidth,r.scale.maxStrokeWidth];case m0:return[[1,0],[4,2],[2,1],[1,1],[1,2,4,2]];case Cl:return"symbol";case ll:case Rd:case Vd:return m==="ordinal"?u==="nominal"?"category":"ordinal":v!==void 0?"diverging":o==="rect"||o==="geoshape"?"heatmap":"ramp";case Gf:case d0:case h0:return[r.scale.minOpacity,r.scale.maxOpacity]}}function Oit(e,i,n){const{encoding:r}=i,o=i.getScaleComponent(n),l=Eue(n),c=r[l];if(ktt({step:e,offsetIsDiscrete:yn(c)&&Det(c.type)})==="offset"&&ftt(r,l)){const f=i.getScaleComponent(l);let p=`domain('${i.scaleName(l)}').length`;if(f.get("type")==="band"){const B=f.get("paddingInner")??f.get("padding")??0,G=f.get("paddingOuter")??f.get("padding")??0;p=`bandspace(${p}, ${B}, ${G})`}const v=o.get("paddingInner")??o.get("padding");return{signal:`${e.step} * ${p} / (1-${hNi(v)})`}}else return e.step}function Lit(e,i){if(ktt({step:e,offsetIsDiscrete:fa(i)})==="offset")return{step:e.step}}function xMi(e,i,n){const r=e===u0?"x":"y",l=i.getScaleComponent(r).get("type"),c=i.scaleName(r);if(l==="band"){const u=Jit(r,i.size,i.config.view);if(pd(u)){const f=Lit(u,n);if(f)return f}return[0,{signal:`bandwidth('${c}')`}]}else{const u=i.encoding[r];return gi(u)&&u.timeUnit?[0,{signal:ket(u.timeUnit,m=>`scale('${c}', ${m})`)}]:Pqe(`Cannot use ${e} scale if ${r} scale is not discrete.`)}}function Jit(e,i,n){const r=e===Fg?"width":"height",o=i[r];return o||D_(n,r)}function DMi(e,i,n,r){switch(e){case"quantile":return i.scale.quantileCount;case"quantize":return i.scale.quantizeCount;case"threshold":return n!==void 0&&Pt(n)?n.length+1:(ni(bki(r)),3)}}function MMi(e,i,n){const r=()=>{const o=jh(i),l=jh(e),c=`(${o} - ${l}) / (${n} - 1)`;return`sequence(${l}, ${o} + ${c}, ${c})`};return Fi(i)?new gl(r):{signal:r()}}function Uit(e,i,n){if(i)return Fi(i)?{signal:`${i.signal} ? 0 : ${Uit(e,!1,n)}`}:0;switch(e){case"bar":case"tick":return n.scale.minBandSize;case"line":case"trail":case"rule":return n.scale.minStrokeWidth;case"text":return n.scale.minFontSize;case"point":case"square":case"circle":return n.scale.minSize}throw new Error(mO("size",e))}const dKe=.95;function FMi(e,i,n,r){const o={x:uKe(n,"x"),y:uKe(n,"y")};switch(e){case"bar":case"tick":{if(r.scale.maxBandSize!==void 0)return r.scale.maxBandSize;const l=hKe(i,o,r.view);return jr(l)?l-1:new gl(()=>`${l.signal} - 1`)}case"line":case"trail":case"rule":return r.scale.maxStrokeWidth;case"text":return r.scale.maxFontSize;case"point":case"square":case"circle":{if(r.scale.maxSize)return r.scale.maxSize;const l=hKe(i,o,r.view);return jr(l)?Math.pow(dKe*l,2):new gl(()=>`pow(${dKe} * ${l.signal}, 2)`)}}throw new Error(mO("size",e))}function hKe(e,i,n){const r=pd(e.width)?e.width.step:x_(n,"width"),o=pd(e.height)?e.height.step:x_(n,"height");return i.x||i.y?new gl(()=>`min(${[i.x?i.x.signal:r,i.y?i.y.signal:o].join(", ")})`):Math.min(r,o)}function Qit(e,i){vo(e)?YMi(e,i):$it(e,i)}function YMi(e,i){const n=e.component.scales,{config:r,encoding:o,markDef:l,specifiedScales:c}=e;for(const u of ei(n)){const f=c[u],m=n[u],p=e.getScaleComponent(u),v=Jo(o[u]),B=f[i],G=p.get("type"),T=p.get("padding"),V=p.get("paddingInner"),E=oae(G,i),W=Pet(u,i);if(B!==void 0&&(E?W&&ni(W):ni(Get(G,i,u))),E&&W===void 0)if(B!==void 0){const x=v.timeUnit,k=v.type;switch(i){case"domainMax":case"domainMin":cZ(f[i])||k==="temporal"||x?m.set(i,{signal:RO(f[i],{type:k,timeUnit:x})},!0):m.set(i,f[i],!0);break;default:m.copyKeyFromObject(i,f)}}else{const x=i in fKe?fKe[i]({model:e,channel:u,fieldOrDatumDef:v,scaleType:G,scalePadding:T,scalePaddingInner:V,domain:f.domain,domainMin:f.domainMin,domainMax:f.domainMax,markDef:l,config:r,hasNestedOffsetScale:sae(o,u),hasSecondaryRangeChannel:!!o[Ed(u)]}):r.scale[i];x!==void 0&&m.set(i,x,!1)}}}const fKe={bins:({model:e,fieldOrDatumDef:i})=>gi(i)?KMi(e,i):void 0,interpolate:({channel:e,fieldOrDatumDef:i})=>_Mi(e,i.type),nice:({scaleType:e,channel:i,domain:n,domainMin:r,domainMax:o,fieldOrDatumDef:l})=>PMi(e,i,n,r,o,l),padding:({channel:e,scaleType:i,fieldOrDatumDef:n,markDef:r,config:o})=>zMi(e,i,o.scale,n,r,o.bar),paddingInner:({scalePadding:e,channel:i,markDef:n,scaleType:r,config:o,hasNestedOffsetScale:l})=>OMi(e,i,n.type,r,o.scale,l),paddingOuter:({scalePadding:e,channel:i,scaleType:n,scalePaddingInner:r,config:o,hasNestedOffsetScale:l})=>LMi(e,i,n,r,o.scale,l),reverse:({fieldOrDatumDef:e,scaleType:i,channel:n,config:r})=>{const o=gi(e)?e.sort:void 0;return JMi(i,o,n,r.scale)},zero:({channel:e,fieldOrDatumDef:i,domain:n,markDef:r,scaleType:o,config:l,hasSecondaryRangeChannel:c})=>UMi(e,i,n,r,o,l.scale,c)};function jit(e){vo(e)?WMi(e):$it(e,"range")}function $it(e,i){const n=e.component.scales;for(const r of e.children)i==="range"?jit(r):Qit(r,i);for(const r of ei(n)){let o;for(const l of e.children){const c=l.component.scales[r];if(c){const u=c.getWithExplicit(i);o=Qp(o,u,i,"scale",Ltt((f,m)=>{switch(i){case"range":return f.step&&m.step?f.step-m.step:0}return 0}))}}n[r].setWithExplicit(i,o)}}function KMi(e,i){const n=i.bin;if(dg(n)){const r=Hde(e,i.field,n);return new gl(()=>e.getSignalName(r))}else if(Ha(n)&&CZ(n)&&n.step!==void 0)return{step:n.step}}function _Mi(e,i){if(jn([ll,Rd,Vd],e)&&i!=="nominal")return"hcl"}function PMi(e,i,n,r,o,l){if(!(md(l)?.bin||Pt(n)||o!=null||r!=null||jn([rl.TIME,rl.UTC],e)))return ha(i)?!0:void 0}function zMi(e,i,n,r,o,l){if(ha(e)){if(CA(i)){if(n.continuousPadding!==void 0)return n.continuousPadding;const{type:c,orient:u}=o;if(c==="bar"&&!(gi(r)&&(r.bin||r.timeUnit))&&(u==="vertical"&&e==="x"||u==="horizontal"&&e==="y"))return l.continuousBandSize}if(i===rl.POINT)return n.pointPadding}}function OMi(e,i,n,r,o,l=!1){if(e===void 0){if(ha(i)){const{bandPaddingInner:c,barBandPaddingInner:u,rectBandPaddingInner:f,bandWithNestedOffsetPaddingInner:m}=o;return l?m:Ho(c,n==="bar"?u:f)}else if($w(i)&&r===rl.BAND)return o.offsetBandPaddingInner}}function LMi(e,i,n,r,o,l=!1){if(e===void 0){if(ha(i)){const{bandPaddingOuter:c,bandWithNestedOffsetPaddingOuter:u}=o;if(l)return u;if(n===rl.BAND)return Ho(c,Fi(r)?{signal:`${r.signal}/2`}:r/2)}else if($w(i)){if(n===rl.POINT)return .5;if(n===rl.BAND)return o.offsetBandPaddingOuter}}}function JMi(e,i,n,r){if(n==="x"&&r.xReverse!==void 0)return Ul(e)&&i==="descending"?Fi(r.xReverse)?{signal:`!${r.xReverse.signal}`}:!r.xReverse:r.xReverse;if(Ul(e)&&i==="descending")return!0}function UMi(e,i,n,r,o,l,c){if(!!n&&n!=="unaggregated"&&Ul(o)){if(Pt(n)){const f=n[0],m=n[n.length-1];if(f<=0&&m>=0)return!0}return!1}if(e==="size"&&i.type==="quantitative"&&!Aw(o))return!0;if(!(gi(i)&&i.bin)&&jn([...Hd,...$Wi],e)){const{orient:f,type:m}=r;return jn(["bar","area","line","trail"],m)&&(f==="horizontal"&&e==="y"||f==="vertical"&&e==="x")?!1:jn(["bar","area"],m)&&!c?!0:l?.zero}return!1}function QMi(e,i,n,r,o=!1){const l=jMi(i,n,r,o),{type:c}=e;return Sf(i)?c!==void 0?iXi(i,c)?gi(n)&&!tXi(c,n.type)?(ni(rki(c,l)),l):c:(ni(nki(i,c,l)),l):l:null}function jMi(e,i,n,r){switch(i.type){case"nominal":case"ordinal":{if(fS(e)||Jte(e)==="discrete")return e==="shape"&&i.type==="ordinal"&&ni(Ute(e,"ordinal")),"ordinal";if(ha(e)||$w(e)){if(jn(["rect","bar","image","rule"],n.type)||r)return"band"}else if(n.type==="arc"&&e in Nue)return"band";const o=n[cl(e)];return Dv(o)||dw(i)&&i.axis?.tickBand?"band":"point"}case"temporal":return fS(e)?"time":Jte(e)==="discrete"?(ni(Ute(e,"temporal")),"ordinal"):gi(i)&&i.timeUnit&&Ya(i.timeUnit).utc?"utc":"time";case"quantitative":return fS(e)?gi(i)&&dg(i.bin)?"bin-ordinal":"linear":Jte(e)==="discrete"?(ni(Ute(e,"quantitative")),"ordinal"):"linear";case"geojson":return}throw new Error(Zet(i.type))}function $Mi(e,{ignoreRange:i}={}){qit(e),_it(e);for(const n of eXi)Qit(e,n);i||jit(e)}function qit(e){vo(e)?e.component.scales=qMi(e):e.component.scales=tFi(e)}function qMi(e){const{encoding:i,mark:n,markDef:r}=e,o={};for(const l of hO){const c=Jo(i[l]);if(c&&n===Let&&l===Cl&&c.type===qw)continue;let u=c&&c.scale;if($w(l)){const f=oet(l);if(!sae(i,f)){u&&ni(_Ni(l));continue}}if(c&&u!==null&&u!==!1){u??(u={});const f=sae(i,l),m=QMi(u,l,c,r,f);o[l]=new zit(e.scaleName(`${l}`,!0),{value:m,explicit:u.type===m})}}return o}const eFi=Ltt((e,i)=>wYe(e)-wYe(i));function tFi(e){var i;const n=e.component.scales={},r={},o=e.component.resolve;for(const l of e.children){qit(l);for(const c of ei(l.component.scales))if((i=o.scale)[c]??(i[c]=Vit(c,e)),o.scale[c]==="shared"){const u=r[c],f=l.component.scales[c].getWithExplicit("type");u?Pki(u.value,f.value)?r[c]=Qp(u,f,"type","scale",eFi):(o.scale[c]="independent",delete r[c]):r[c]=f}}for(const l of ei(r)){const c=e.scaleName(l,!0),u=r[l];n[l]=new zit(c,u);for(const f of e.children){const m=f.component.scales[l];m&&(f.renameScale(m.get("name"),c),m.merged=!0)}}return n}class nie{constructor(){this.nameMap={}}rename(i,n){this.nameMap[i]=n}has(i){return this.nameMap[i]!==void 0}get(i){for(;this.nameMap[i]&&i!==this.nameMap[i];)i=this.nameMap[i];return i}}function vo(e){return e?.type==="unit"}function bA(e){return e?.type==="facet"}function xde(e){return e?.type==="concat"}function r2(e){return e?.type==="layer"}class Dde{constructor(i,n,r,o,l,c,u){this.type=n,this.parent=r,this.config=l,this.correctDataNames=f=>(f.from?.data&&(f.from.data=this.lookupDataSource(f.from.data)),f.from?.facet?.data&&(f.from.facet.data=this.lookupDataSource(f.from.facet.data)),f),this.parent=r,this.config=l,this.view=OI(u),this.name=i.name??o,this.title=Lm(i.title)?{text:i.title}:i.title?OI(i.title):void 0,this.scaleNameMap=r?r.scaleNameMap:new nie,this.projectionNameMap=r?r.projectionNameMap:new nie,this.signalNameMap=r?r.signalNameMap:new nie,this.data=i.data,this.description=i.description,this.transforms=sDi(i.transform??[]),this.layout=n==="layer"||n==="unit"?{}:fxi(i,n,l),this.component={data:{sources:r?r.component.data.sources:[],outputNodes:r?r.component.data.outputNodes:{},outputNodeRefCounts:r?r.component.data.outputNodeRefCounts:{},isFaceted:GO(i)||r?.component.data.isFaceted&&i.data===void 0},layoutSize:new Tf,layoutHeaders:{row:{},column:{},facet:{}},mark:null,resolve:{scale:{},axis:{},legend:{},...c?vn(c):{}},selection:null,scales:null,projection:null,axes:{},legends:{}}}get width(){return this.getSizeSignalRef("width")}get height(){return this.getSizeSignalRef("height")}parse(){this.parseScale(),this.parseLayoutSize(),this.renameTopLevelLayoutSizeSignal(),this.parseSelections(),this.parseProjection(),this.parseData(),this.parseAxesAndHeaders(),this.parseLegends(),this.parseMarkGroup()}parseScale(){$Mi(this)}parseProjection(){Fit(this)}renameTopLevelLayoutSizeSignal(){this.getName("width")!=="width"&&this.renameSignal(this.getName("width"),"width"),this.getName("height")!=="height"&&this.renameSignal(this.getName("height"),"height")}parseLegends(){kit(this)}assembleEncodeFromView(i){const{style:n,...r}=i,o={};for(const l of ei(r)){const c=r[l];c!==void 0&&(o[l]=Gg(c))}return o}assembleGroupEncodeEntry(i){let n={};return this.view&&(n=this.assembleEncodeFromView(this.view)),!i&&(this.description&&(n.description=Gg(this.description)),this.type==="unit"||this.type==="layer")?{width:this.getSizeSignalRef("width"),height:this.getSizeSignalRef("height"),...n??{}}:Qr(n)?void 0:n}assembleLayout(){if(!this.layout)return;const{spacing:i,...n}=this.layout,{component:r,config:o}=this,l=v5i(r.layoutHeaders,o);return{padding:i,...this.assembleDefaultLayout(),...n,...l?{titleBand:l}:{}}}assembleDefaultLayout(){return{}}assembleHeaderMarks(){const{layoutHeaders:i}=this.component;let n=[];for(const r of xC)i[r].title&&n.push(h5i(this,r));for(const r of Tde)n=n.concat(f5i(this,r));return n}assembleAxes(){return n5i(this.component.axes,this.config)}assembleLegends(){return xit(this)}assembleProjections(){return z5i(this)}assembleTitle(){const{encoding:i,...n}=this.title??{},r={...uet(this.config.title).nonMarkTitleProperties,...n,...i?{encode:{update:i}}:{}};if(r.text)return jn(["unit","layer"],this.type)?jn(["middle",void 0],r.anchor)&&(r.frame??(r.frame="group")):r.anchor??(r.anchor="start"),Qr(r)?void 0:r}assembleGroup(i=[]){const n={};i=i.concat(this.assembleSignals()),i.length>0&&(n.signals=i);const r=this.assembleLayout();r&&(n.layout=r),n.marks=[].concat(this.assembleHeaderMarks(),this.assembleMarks());const o=!this.parent||bA(this.parent)?Pit(this):[];o.length>0&&(n.scales=o);const l=this.assembleAxes();l.length>0&&(n.axes=l);const c=this.assembleLegends();return c.length>0&&(n.legends=c),n}getName(i){return Mg((this.name?`${this.name}_`:"")+i)}getDataName(i){return this.getName(cg[i].toLowerCase())}requestDataName(i){const n=this.getDataName(i),r=this.component.data.outputNodeRefCounts;return r[n]=(r[n]||0)+1,n}getSizeSignalRef(i){if(bA(this.parent)){const n=Tit(i),r=dO(n),o=this.component.scales[r];if(o&&!o.merged){const l=o.get("type"),c=o.get("range");if(fa(l)&&b0(c)){const u=o.get("name"),f=MO(this,r),m=Xde(f);if(m){const p=di({aggregate:"distinct",field:m},{expr:"datum"});return{signal:wit(u,o,p)}}else return ni(xue(r)),null}}}return{signal:this.signalNameMap.get(this.getName(i))}}lookupDataSource(i){const n=this.component.data.outputNodes[i];return n?n.getSource():i}getSignalName(i){return this.signalNameMap.get(i)}renameSignal(i,n){this.signalNameMap.rename(i,n)}renameScale(i,n){this.scaleNameMap.rename(i,n)}renameProjection(i,n){this.projectionNameMap.rename(i,n)}scaleName(i,n){if(n)return this.getName(i);if(net(i)&&Sf(i)&&this.component.scales[i]||this.scaleNameMap.has(this.getName(i)))return this.scaleNameMap.get(this.getName(i))}projectionName(i){if(i)return this.getName("projection");if(this.component.projection&&!this.component.projection.merged||this.projectionNameMap.has(this.getName("projection")))return this.projectionNameMap.get(this.getName("projection"))}getScaleComponent(i){if(!this.component.scales)throw new Error("getScaleComponent cannot be called before parseScale(). Make sure you have called parseScale or use parseUnitModelWithScale().");const n=this.component.scales[i];return n&&!n.merged?n:this.parent?this.parent.getScaleComponent(i):void 0}getSelectionComponent(i,n){let r=this.component.selection[i];if(!r&&this.parent&&(r=this.parent.getSelectionComponent(i,n)),!r)throw new Error(yNi(n));return r}hasAxisOrientSignalRef(){return this.component.axes.x?.some(i=>i.hasOrientSignalRef())||this.component.axes.y?.some(i=>i.hasOrientSignalRef())}}class ent extends Dde{vgField(i,n={}){const r=this.fieldDef(i);if(r)return di(r,n)}reduceFieldDef(i,n){return OXi(this.getMapping(),(r,o,l)=>{const c=md(o);return c?i(r,c,l):r},n)}forEachFieldDef(i,n){lde(this.getMapping(),(r,o)=>{const l=md(r);l&&i(l,o)},n)}}class FO extends qr{clone(){return new FO(null,vn(this.transform))}constructor(i,n){super(i),this.transform=n,this.transform=vn(n);const r=this.transform.as??[void 0,void 0];this.transform.as=[r[0]??"value",r[1]??"density"],n.groupby&&n.minsteps==null&&n.maxsteps==null&&n.steps==null&&(this.transform.steps=200)}dependentFields(){return new Set([this.transform.density,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`DensityTransform ${Ir(this.transform)}`}assemble(){const{density:i,...n}=this.transform;return{type:"kde",field:i,...n}}}class sW extends qr{clone(){return new sW(null,{...this.filter})}constructor(i,n){super(i),this.filter=n}static make(i,n){const{config:r,mark:o,markDef:l}=n;if(Wr("invalid",l,r)!=="filter")return null;const u=n.reduceFieldDef((f,m,p)=>{const v=Sf(p)&&n.getScaleComponent(p);if(v){const B=v.get("type");Ul(B)&&m.aggregate!=="count"&&!y0(o)&&(f[m.field]=m)}return f},{});return ei(u).length?new sW(i,u):null}dependentFields(){return new Set(ei(this.filter))}producedFields(){return new Set}hash(){return`FilterInvalid ${Ir(this.filter)}`}assemble(){const i=ei(this.filter).reduce((n,r)=>{const o=this.filter[r],l=di(o,{expr:"datum"});return o!==null&&(o.type==="temporal"?n.push(`(isDate(${l}) || (isValid(${l}) && isFinite(+${l})))`):o.type==="quantitative"&&(n.push(`isValid(${l})`),n.push(`isFinite(+${l})`))),n},[]);return i.length>0?{type:"filter",expr:i.join(" && ")}:null}}class YO extends qr{clone(){return new YO(this.parent,vn(this.transform))}constructor(i,n){super(i),this.transform=n,this.transform=vn(n);const{flatten:r,as:o=[]}=this.transform;this.transform.as=r.map((l,c)=>o[c]??l)}dependentFields(){return new Set(this.transform.flatten)}producedFields(){return new Set(this.transform.as)}hash(){return`FlattenTransform ${Ir(this.transform)}`}assemble(){const{flatten:i,as:n}=this.transform;return{type:"flatten",fields:i,as:n}}}class KO extends qr{clone(){return new KO(null,vn(this.transform))}constructor(i,n){super(i),this.transform=n,this.transform=vn(n);const r=this.transform.as??[void 0,void 0];this.transform.as=[r[0]??"key",r[1]??"value"]}dependentFields(){return new Set(this.transform.fold)}producedFields(){return new Set(this.transform.as)}hash(){return`FoldTransform ${Ir(this.transform)}`}assemble(){const{fold:i,as:n}=this.transform;return{type:"fold",fields:i,as:n}}}class bS extends qr{clone(){return new bS(null,vn(this.fields),this.geojson,this.signal)}static parseAll(i,n){if(n.component.projection&&!n.component.projection.isFit)return i;let r=0;for(const o of[[kA,NA],[jC,XA]]){const l=o.map(c=>{const u=Jo(n.encoding[c]);return gi(u)?u.field:Wd(u)?{expr:`${u.datum}`}:wA(u)?{expr:`${u.value}`}:void 0});(l[0]||l[1])&&(i=new bS(i,l,null,n.getName(`geojson_${r++}`)))}if(n.channelHasField(Cl)){const o=n.typedFieldDef(Cl);o.type===qw&&(i=new bS(i,null,o.field,n.getName(`geojson_${r++}`)))}return i}constructor(i,n,r,o){super(i),this.fields=n,this.geojson=r,this.signal=o}dependentFields(){const i=(this.fields??[]).filter(fi);return new Set([...this.geojson?[this.geojson]:[],...i])}producedFields(){return new Set}hash(){return`GeoJSON ${this.geojson} ${this.signal} ${Ir(this.fields)}`}assemble(){return[...this.geojson?[{type:"filter",expr:`isValid(datum["${this.geojson}"])`}]:[],{type:"geojson",...this.fields?{fields:this.fields}:{},...this.geojson?{geojson:this.geojson}:{},signal:this.signal}]}}class IW extends qr{clone(){return new IW(null,this.projection,vn(this.fields),vn(this.as))}constructor(i,n,r,o){super(i),this.projection=n,this.fields=r,this.as=o}static parseAll(i,n){if(!n.projectionName())return i;for(const r of[[kA,NA],[jC,XA]]){const o=r.map(c=>{const u=Jo(n.encoding[c]);return gi(u)?u.field:Wd(u)?{expr:`${u.datum}`}:wA(u)?{expr:`${u.value}`}:void 0}),l=r[0]===jC?"2":"";(o[0]||o[1])&&(i=new IW(i,n.projectionName(),o,[n.getName(`x${l}`),n.getName(`y${l}`)]))}return i}dependentFields(){return new Set(this.fields.filter(fi))}producedFields(){return new Set(this.as)}hash(){return`Geopoint ${this.projection} ${Ir(this.fields)} ${Ir(this.as)}`}assemble(){return{type:"geopoint",projection:this.projection,fields:this.fields,as:this.as}}}class ev extends qr{clone(){return new ev(null,vn(this.transform))}constructor(i,n){super(i),this.transform=n}dependentFields(){return new Set([this.transform.impute,this.transform.key,...this.transform.groupby??[]])}producedFields(){return new Set([this.transform.impute])}processSequence(i){const{start:n=0,stop:r,step:o}=i;return{signal:`sequence(${[n,r,...o?[o]:[]].join(",")})`}}static makeFromTransform(i,n){return new ev(i,n)}static makeFromEncoding(i,n){const r=n.encoding,o=r.x,l=r.y;if(gi(o)&&gi(l)){const c=o.impute?o:l.impute?l:void 0;if(c===void 0)return;const u=o.impute?l:l.impute?o:void 0,{method:f,value:m,frame:p,keyvals:v}=c.impute,B=ptt(n.mark,r);return new ev(i,{impute:c.field,key:u.field,...f?{method:f}:{},...m!==void 0?{value:m}:{},...p?{frame:p}:{},...v!==void 0?{keyvals:v}:{},...B.length?{groupby:B}:{}})}return null}hash(){return`Impute ${Ir(this.transform)}`}assemble(){const{impute:i,key:n,keyvals:r,method:o,groupby:l,value:c,frame:u=[null,null]}=this.transform,f={type:"impute",field:i,key:n,...r?{keyvals:Pxi(r)?this.processSequence(r):r}:{},method:"value",...l?{groupby:l}:{},value:!o||o==="value"?c:null};if(o&&o!=="value"){const m={type:"window",as:[`imputed_${i}_value`],ops:[o],fields:[i],frame:u,ignorePeers:!1,...l?{groupby:l}:{}},p={type:"formula",expr:`datum.${i} === null ? datum.imputed_${i}_value : datum.${i}`,as:i};return[f,m,p]}else return[f]}}class _O extends qr{clone(){return new _O(null,vn(this.transform))}constructor(i,n){super(i),this.transform=n,this.transform=vn(n);const r=this.transform.as??[void 0,void 0];this.transform.as=[r[0]??n.on,r[1]??n.loess]}dependentFields(){return new Set([this.transform.loess,this.transform.on,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`LoessTransform ${Ir(this.transform)}`}assemble(){const{loess:i,on:n,...r}=this.transform;return{type:"loess",x:n,y:i,...r}}}class lW extends qr{clone(){return new lW(null,vn(this.transform),this.secondary)}constructor(i,n,r){super(i),this.transform=n,this.secondary=r}static make(i,n,r,o){const l=n.component.data.sources,{from:c}=r;let u=null;if(zxi(c)){let f=nnt(c.data,l);f||(f=new Kv(c.data),l.push(f));const m=n.getName(`lookup_${o}`);u=new dI(f,m,cg.Lookup,n.component.data.outputNodeRefCounts),n.component.data.outputNodes[m]=u}else if(Oxi(c)){const f=c.param;r={as:f,...r};let m;try{m=n.getSelectionComponent(Mg(f),f)}catch{throw new Error(BNi(f))}if(u=m.materialized,!u)throw new Error(GNi(f))}return new lW(i,r,u.getSource())}dependentFields(){return new Set([this.transform.lookup])}producedFields(){return new Set(this.transform.as?pi(this.transform.as):this.transform.from.fields)}hash(){return`Lookup ${Ir({transform:this.transform,secondary:this.secondary})}`}assemble(){let i;if(this.transform.from.fields)i={values:this.transform.from.fields,...this.transform.as?{as:pi(this.transform.as)}:{}};else{let n=this.transform.as;fi(n)||(ni(WNi),n="_lookup"),i={as:[n]}}return{type:"lookup",from:this.secondary,key:this.transform.from.key,fields:[this.transform.lookup],...i,...this.transform.default?{default:this.transform.default}:{}}}}class PO extends qr{clone(){return new PO(null,vn(this.transform))}constructor(i,n){super(i),this.transform=n,this.transform=vn(n);const r=this.transform.as??[void 0,void 0];this.transform.as=[r[0]??"prob",r[1]??"value"]}dependentFields(){return new Set([this.transform.quantile,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`QuantileTransform ${Ir(this.transform)}`}assemble(){const{quantile:i,...n}=this.transform;return{type:"quantile",field:i,...n}}}class zO extends qr{clone(){return new zO(null,vn(this.transform))}constructor(i,n){super(i),this.transform=n,this.transform=vn(n);const r=this.transform.as??[void 0,void 0];this.transform.as=[r[0]??n.on,r[1]??n.regression]}dependentFields(){return new Set([this.transform.regression,this.transform.on,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`RegressionTransform ${Ir(this.transform)}`}assemble(){const{regression:i,on:n,...r}=this.transform;return{type:"regression",x:n,y:i,...r}}}class OO extends qr{clone(){return new OO(null,vn(this.transform))}constructor(i,n){super(i),this.transform=n}addDimensions(i){this.transform.groupby=_u((this.transform.groupby??[]).concat(i),n=>n)}producedFields(){}dependentFields(){return new Set([this.transform.pivot,this.transform.value,...this.transform.groupby??[]])}hash(){return`PivotTransform ${Ir(this.transform)}`}assemble(){const{pivot:i,value:n,groupby:r,limit:o,op:l}=this.transform;return{type:"pivot",field:i,value:n,...o!==void 0?{limit:o}:{},...l!==void 0?{op:l}:{},...r!==void 0?{groupby:r}:{}}}}class LO extends qr{clone(){return new LO(null,vn(this.transform))}constructor(i,n){super(i),this.transform=n}dependentFields(){return new Set}producedFields(){return new Set}hash(){return`SampleTransform ${Ir(this.transform)}`}assemble(){return{type:"sample",size:this.transform.sample}}}function tnt(e){let i=0;function n(r,o){if(r instanceof Kv&&!r.isGenerator&&!fw(r.data)&&(e.push(o),o={name:null,source:o.name,transform:[]}),r instanceof Ss&&(r.parent instanceof Kv&&!o.source?(o.format={...o.format??{},parse:r.assembleFormatParse()},o.transform.push(...r.assembleTransforms(!0))):o.transform.push(...r.assembleTransforms())),r instanceof i2){o.name||(o.name=`data_${i++}`),!o.source||o.transform.length>0?(e.push(o),r.data=o.name):r.data=o.source,e.push(...r.assemble());return}switch((r instanceof BN||r instanceof GN||r instanceof sW||r instanceof t2||r instanceof mw||r instanceof IW||r instanceof pA||r instanceof lW||r instanceof n2||r instanceof dZ||r instanceof KO||r instanceof YO||r instanceof FO||r instanceof _O||r instanceof PO||r instanceof zO||r instanceof qp||r instanceof LO||r instanceof OO)&&o.transform.push(r.assemble()),(r instanceof rd||r instanceof nd||r instanceof ev||r instanceof qh||r instanceof bS)&&o.transform.push(...r.assemble()),r instanceof dI&&(o.source&&o.transform.length===0?r.setSource(o.source):r.parent instanceof dI?r.setSource(o.name):(o.name||(o.name=`data_${i++}`),r.setSource(o.name),r.numChildren()===1&&(e.push(o),o={name:null,source:o.name,transform:[]}))),r.numChildren()){case 0:r instanceof dI&&(!o.source||o.transform.length>0)&&e.push(o);break;case 1:n(r.children[0],o);break;default:{o.name||(o.name=`data_${i++}`);let l=o.name;!o.source||o.transform.length>0?e.push(o):l=o.source;for(const c of r.children)n(c,{name:null,source:l,transform:[]});break}}}return n}function iFi(e){const i=[],n=tnt(i);for(const r of e.children)n(r,{source:e.name,name:null,transform:[]});return i}function nFi(e,i){const n=[],r=tnt(n);let o=0;for(const c of e.sources){c.hasName()||(c.dataName=`source_${o++}`);const u=c.assemble();r(c,u)}for(const c of n)c.transform.length===0&&delete c.transform;let l=0;for(const[c,u]of n.entries())(u.transform??[]).length===0&&!u.source&&n.splice(l++,0,n.splice(c,1)[0]);for(const c of n)for(const u of c.transform??[])u.type==="lookup"&&(u.from=e.outputNodes[u.from].getSource());for(const c of n)c.name in i&&(c.values=i[c.name]);return n}function rFi(e){return e==="top"||e==="left"||Fi(e)?"header":"footer"}function gFi(e){for(const i of xC)oFi(e,i);mKe(e,"x"),mKe(e,"y")}function oFi(e,i){const{facet:n,config:r,child:o,component:l}=e;if(e.channelHasField(i)){const c=n[i],u=bw("title",null,r,i);let f=mS(c,r,{allowDisabling:!0,includeDefault:u===void 0||!!u});o.component.layoutHeaders[i].title&&(f=Pt(f)?f.join(", "):f,f+=` / ${o.component.layoutHeaders[i].title}`,o.component.layoutHeaders[i].title=null);const m=bw("labelOrient",c.header,r,i),p=c.header!==null?Ho(c.header?.labels,r.header.labels,!0):!1,v=jn(["bottom","right"],m)?"footer":"header";l.layoutHeaders[i]={title:c.header!==null?f:null,facetFieldDef:c,[v]:i==="facet"?[]:[int(e,i,p)]}}}function int(e,i,n){const r=i==="row"?"height":"width";return{labels:n,sizeSignal:e.child.component.layoutSize.get(r)?e.child.getSizeSignalRef(r):void 0,axes:[]}}function mKe(e,i){const{child:n}=e;if(n.component.axes[i]){const{layoutHeaders:r,resolve:o}=e.component;if(o.axis[i]=Ede(o,i),o.axis[i]==="shared"){const l=i==="x"?"column":"row",c=r[l];for(const u of n.component.axes[i]){const f=rFi(u.get("orient"));c[f]??(c[f]=[int(e,l,!1)]);const m=nE(u,"main",e.config,{header:!0});m&&c[f][0].axes.push(m),u.mainExtracted=!0}}}}function aFi(e){Mde(e),K_(e,"width"),K_(e,"height")}function sFi(e){Mde(e);const i=e.layout.columns===1?"width":"childWidth",n=e.layout.columns===void 0?"height":"childHeight";K_(e,i),K_(e,n)}function Mde(e){for(const i of e.children)i.parseLayoutSize()}function K_(e,i){const n=Tit(i),r=dO(n),o=e.component.resolve,l=e.component.layoutSize;let c;for(const u of e.children){const f=u.component.layoutSize.getWithExplicit(n),m=o.scale[r]??Vit(r,e);if(m==="independent"&&f.value==="step"){c=void 0;break}if(c){if(m==="independent"&&c.value!==f.value){c=void 0;break}c=Qp(c,f,n,"")}else c=f}if(c){for(const u of e.children)e.renameSignal(u.getName(n),e.getName(i)),u.component.layoutSize.set(n,"merged",!1);l.setWithExplicit(i,c)}else l.setWithExplicit(i,{explicit:!1,value:void 0})}function IFi(e){const{size:i,component:n}=e;for(const r of Hd){const o=cl(r);if(i[o]){const l=i[o];n.layoutSize.set(o,pd(l)?"step":l,!0)}else{const l=lFi(e,o);n.layoutSize.set(o,l,!1)}}}function lFi(e,i){const n=i==="width"?"x":"y",r=e.config,o=e.getScaleComponent(n);if(o){const l=o.get("type"),c=o.get("range");if(fa(l)){const u=D_(r.view,i);return b0(c)||pd(u)?"step":u}else return lae(r.view,i)}else{if(e.hasProjection||e.mark==="arc")return lae(r.view,i);{const l=D_(r.view,i);return pd(l)?l.step:l}}}function Bae(e,i,n){return di(i,{suffix:`by_${di(e)}`,...n??{}})}class kE extends ent{constructor(i,n,r,o){super(i,"facet",n,r,o,i.resolve),this.child=Pde(i.spec,this,this.getName("child"),void 0,o),this.children=[this.child],this.facet=this.initFacet(i.facet)}initFacet(i){if(!pN(i))return{facet:this.initFacetFieldDef(i,"facet")};const n=ei(i),r={};for(const o of n){if(![Uh,Qh].includes(o)){ni(mO(o,"facet"));break}const l=i[o];if(l.field===void 0){ni(rae(l,o));break}r[o]=this.initFacetFieldDef(l,o)}return r}initFacetFieldDef(i,n){const r=sde(i,n);return r.header?r.header=OI(r.header):r.header===null&&(r.header=null),r}channelHasField(i){return!!this.facet[i]}fieldDef(i){return this.facet[i]}parseData(){this.component.data=JO(this),this.child.parseData()}parseLayoutSize(){Mde(this)}parseSelections(){this.child.parseSelections(),this.component.selection=this.child.component.selection}parseMarkGroup(){this.child.parseMarkGroup()}parseAxesAndHeaders(){this.child.parseAxesAndHeaders(),gFi(this)}assembleSelectionTopLevelSignals(i){return this.child.assembleSelectionTopLevelSignals(i)}assembleSignals(){return this.child.assembleSignals(),[]}assembleSelectionData(i){return this.child.assembleSelectionData(i)}getHeaderLayoutMixins(){const i={};for(const n of xC)for(const r of Rde){const o=this.component.layoutHeaders[n],l=o[r],{facetFieldDef:c}=o;if(c){const u=bw("titleOrient",c.header,this.config,n);if(["right","bottom"].includes(u)){const f=xO(n,u);i.titleAnchor??(i.titleAnchor={}),i.titleAnchor[f]="end"}}if(l?.[0]){const u=n==="row"?"height":"width",f=r==="header"?"headerBand":"footerBand";n!=="facet"&&!this.child.component.layoutSize.get(u)&&(i[f]??(i[f]={}),i[f][n]=.5),o.title&&(i.offset??(i.offset={}),i.offset[n==="row"?"rowTitle":"columnTitle"]=10)}}return i}assembleDefaultLayout(){const{column:i,row:n}=this.facet,r=i?this.columnDistinctSignal():n?1:void 0;let o="all";return(!n&&this.component.resolve.scale.x==="independent"||!i&&this.component.resolve.scale.y==="independent")&&(o="none"),{...this.getHeaderLayoutMixins(),...r?{columns:r}:{},bounds:"full",align:o}}assembleLayoutSignals(){return this.child.assembleLayoutSignals()}columnDistinctSignal(){if(!(this.parent&&this.parent instanceof kE))return{signal:`length(data('${this.getName("column_domain")}'))`}}assembleGroupStyle(){}assembleGroup(i){return this.parent&&this.parent instanceof kE?{...this.channelHasField("column")?{encode:{update:{columns:{field:di(this.facet.column,{prefix:"distinct"})}}}}:{},...super.assembleGroup(i)}:super.assembleGroup(i)}getCardinalityAggregateForChild(){const i=[],n=[],r=[];if(this.child instanceof kE){if(this.child.channelHasField("column")){const o=di(this.child.facet.column);i.push(o),n.push("distinct"),r.push(`distinct_${o}`)}}else for(const o of Hd){const l=this.child.component.scales[o];if(l&&!l.merged){const c=l.get("type"),u=l.get("range");if(fa(c)&&b0(u)){const f=MO(this.child,o),m=Xde(f);m?(i.push(m),n.push("distinct"),r.push(`distinct_${m}`)):ni(xue(o))}}}return{fields:i,ops:n,as:r}}assembleFacet(){const{name:i,data:n}=this.component.data.facetRoot,{row:r,column:o}=this.facet,{fields:l,ops:c,as:u}=this.getCardinalityAggregateForChild(),f=[];for(const p of xC){const v=this.facet[p];if(v){f.push(di(v));const{bin:B,sort:G}=v;if(dg(B)&&f.push(di(v,{binSuffix:"end"})),id(G)){const{field:T,op:V=BO}=G,E=Bae(v,G);r&&o?(l.push(E),c.push("max"),u.push(E)):(l.push(T),c.push(V),u.push(E))}else if(Pt(G)){const T=pw(v,p);l.push(T),c.push("max"),u.push(T)}}}const m=!!r&&!!o;return{name:i,data:n,groupby:f,...m||l.length>0?{aggregate:{...m?{cross:m}:{},...l.length?{fields:l,ops:c,as:u}:{}}}:{}}}facetSortFields(i){const{facet:n}=this,r=n[i];return r?id(r.sort)?[Bae(r,r.sort,{expr:"datum"})]:Pt(r.sort)?[pw(r,i,{expr:"datum"})]:[di(r,{expr:"datum"})]:[]}facetSortOrder(i){const{facet:n}=this,r=n[i];if(r){const{sort:o}=r;return[(id(o)?o.order:!Pt(o)&&o)||"ascending"]}return[]}assembleLabelTitle(){const{facet:i,config:n}=this;if(i.facet)return mae(i.facet,"facet",n);const r={row:["top","bottom"],column:["left","right"]};for(const o of Tde)if(i[o]){const l=bw("labelOrient",i[o]?.header,n,o);if(r[o].includes(l))return mae(i[o],o,n)}}assembleMarks(){const{child:i}=this,n=this.component.data.facetRoot,r=iFi(n),o=i.assembleGroupEncodeEntry(!1),l=this.assembleLabelTitle()||i.assembleTitle(),c=i.assembleGroupStyle();return[{name:this.getName("cell"),type:"group",...l?{title:l}:{},...c?{style:c}:{},from:{facet:this.assembleFacet()},sort:{field:xC.map(f=>this.facetSortFields(f)).flat(),order:xC.map(f=>this.facetSortOrder(f)).flat()},...r.length>0?{data:r}:{},...o?{encode:{update:o}}:{},...i.assembleGroup(yDi(this,[]))}]}getMapping(){return this.facet}}function CFi(e,i){const{row:n,column:r}=i;if(n&&r){let o=null;for(const l of[n,r])if(id(l.sort)){const{field:c,op:u=BO}=l.sort;e=o=new dZ(e,{joinaggregate:[{op:u,field:c,as:Bae(l,l.sort,{forAs:!0})}],groupby:[di(l)]})}return o}return null}function nnt(e,i){for(const n of i){const r=n.data;if(e.name&&n.hasName()&&e.name!==n.dataName)continue;const o=e.format?.mesh,l=r.format?.feature;if(o&&l)continue;const c=e.format?.feature;if((c||l)&&c!==l)continue;const u=r.format?.mesh;if(!((o||u)&&o!==u)){if(oW(e)&&oW(r)){if(Ku(e.values,r.values))return n}else if(fw(e)&&fw(r)){if(e.url===r.url)return n}else if(Jtt(e)&&e.name===n.dataName)return n}}return null}function cFi(e,i){if(e.data||!e.parent){if(e.data===null){const r=new Kv({values:[]});return i.push(r),r}const n=nnt(e.data,i);if(n)return Ep(e.data)||(n.data.format=zqe({},e.data.format,n.data.format)),!n.hasName()&&e.data.name&&(n.dataName=e.data.name),n;{const r=new Kv(e.data);return i.push(r),r}}else return e.parent.component.data.facetRoot?e.parent.component.data.facetRoot:e.parent.component.data.main}function AFi(e,i,n){let r=0;for(const o of i.transforms){let l,c;if(iDi(o))c=e=new mw(e,o),l="derived";else if(yde(o)){const u=rMi(o);c=e=Ss.makeWithAncestors(e,{},u,n)??e,e=new t2(e,i,o.filter)}else if(_tt(o))c=e=rd.makeFromTransform(e,o,i),l="number";else if(rDi(o))l="date",n.getWithExplicit(o.field).value===void 0&&(e=new Ss(e,{[o.field]:l}),n.set(o.field,l,!1)),c=e=nd.makeFromTransform(e,o);else if(gDi(o))c=e=pA.makeFromTransform(e,o),l="number",wde(i)&&(e=new qp(e));else if(Ktt(o))c=e=lW.make(e,i,o,r++),l="derived";else if(qxi(o))c=e=new n2(e,o),l="number";else if(eDi(o))c=e=new dZ(e,o),l="number";else if(oDi(o))c=e=qh.makeFromTransform(e,o),l="derived";else if(aDi(o))c=e=new KO(e,o),l="derived";else if(tDi(o))c=e=new YO(e,o),l="derived";else if(Lxi(o))c=e=new OO(e,o),l="derived";else if($xi(o))e=new LO(e,o);else if(nDi(o))c=e=ev.makeFromTransform(e,o),l="derived";else if(Jxi(o))c=e=new FO(e,o),l="derived";else if(Uxi(o))c=e=new PO(e,o),l="derived";else if(Qxi(o))c=e=new zO(e,o),l="derived";else if(jxi(o))c=e=new _O(e,o),l="derived";else{ni(HNi(o));continue}if(c&&l!==void 0)for(const u of c.producedFields()??[])n.set(u,l,!1)}return e}function JO(e){let i=cFi(e,e.component.data.sources);const{outputNodes:n,outputNodeRefCounts:r}=e.component.data,o=e.data,c=!(o&&(Ep(o)||fw(o)||oW(o)))&&e.parent?e.parent.component.data.ancestorParse.clone():new pDi;Ep(o)?(Utt(o)?i=new GN(i,o.sequence):vde(o)&&(i=new BN(i,o.graticule)),c.parseNothing=!0):o?.format?.parse===null&&(c.parseNothing=!0),i=Ss.makeExplicit(i,e,c)??i,i=new qp(i);const u=e.parent&&r2(e.parent);(vo(e)||bA(e))&&u&&(i=rd.makeFromEncoding(i,e)??i),e.transforms.length>0&&(i=AFi(i,e,c));const f=oMi(e),m=gMi(e);i=Ss.makeWithAncestors(i,{},{...f,...m},c)??i,vo(e)&&(i=bS.parseAll(i,e),i=IW.parseAll(i,e)),(vo(e)||bA(e))&&(u||(i=rd.makeFromEncoding(i,e)??i),i=nd.makeFromEncoding(i,e)??i,i=mw.parseAllForSortIndex(i,e));const p=e.getDataName(cg.Raw),v=new dI(i,p,cg.Raw,r);if(n[p]=v,i=v,vo(e)){const V=pA.makeFromEncoding(i,e);V&&(i=V,wde(e)&&(i=new qp(i))),i=ev.makeFromEncoding(i,e)??i,i=qh.makeFromEncoding(i,e)??i}vo(e)&&(i=sW.make(i,e)??i);const B=e.getDataName(cg.Main),G=new dI(i,B,cg.Main,r);n[B]=G,i=G,vo(e)&&t5i(e,G);let T=null;if(bA(e)){const V=e.getName("facet");i=CFi(i,e.facet)??i,T=new i2(i,e,V,G.getSource()),n[V]=T}return{...e.component.data,outputNodes:n,outputNodeRefCounts:r,raw:v,main:G,facetRoot:T,ancestorParse:c}}class uFi extends Dde{constructor(i,n,r,o){super(i,"concat",n,r,o,i.resolve),(i.resolve?.axis?.x==="shared"||i.resolve?.axis?.y==="shared")&&ni(RNi),this.children=this.getChildren(i).map((l,c)=>Pde(l,this,this.getName(`concat_${c}`),void 0,o))}parseData(){this.component.data=JO(this);for(const i of this.children)i.parseData()}parseSelections(){this.component.selection={};for(const i of this.children){i.parseSelections();for(const n of ei(i.component.selection))this.component.selection[n]=i.component.selection[n]}}parseMarkGroup(){for(const i of this.children)i.parseMarkGroup()}parseAxesAndHeaders(){for(const i of this.children)i.parseAxesAndHeaders()}getChildren(i){return HO(i)?i.vconcat:pde(i)?i.hconcat:i.concat}parseLayoutSize(){sFi(this)}parseAxisGroup(){return null}assembleSelectionTopLevelSignals(i){return this.children.reduce((n,r)=>r.assembleSelectionTopLevelSignals(n),i)}assembleSignals(){return this.children.forEach(i=>i.assembleSignals()),[]}assembleLayoutSignals(){const i=Vde(this);for(const n of this.children)i.push(...n.assembleLayoutSignals());return i}assembleSelectionData(i){return this.children.reduce((n,r)=>r.assembleSelectionData(n),i)}assembleMarks(){return this.children.map(i=>{const n=i.assembleTitle(),r=i.assembleGroupStyle(),o=i.assembleGroupEncodeEntry(!1);return{type:"group",name:i.getName("group"),...n?{title:n}:{},...r?{style:r}:{},...o?{encode:{update:o}}:{},...i.assembleGroup()}})}assembleGroupStyle(){}assembleDefaultLayout(){const i=this.layout.columns;return{...i!=null?{columns:i}:{},bounds:"full",align:"each"}}}function dFi(e){return e===!1||e===null}const hFi={disable:1,gridScale:1,scale:1,...dtt,labelExpr:1,encode:1},rnt=ei(hFi);class Fde extends Tf{constructor(i={},n={},r=!1){super(),this.explicit=i,this.implicit=n,this.mainExtracted=r}clone(){return new Fde(vn(this.explicit),vn(this.implicit),this.mainExtracted)}hasAxisPart(i){return i==="axis"?!0:i==="grid"||i==="title"?!!this.get(i):!dFi(this.get(i))}hasOrientSignalRef(){return Fi(this.explicit.orient)}}function fFi(e,i,n){const{encoding:r,config:o}=e,l=Jo(r[i])??Jo(r[Ed(i)]),c=e.axis(i)||{},{format:u,formatType:f}=c;if(Mv(f))return{text:cA({fieldOrDatumDef:l,field:"datum.value",format:u,formatType:f,config:o}),...n};if(u===void 0&&f===void 0&&o.customFormatTypes){if(uw(l)==="quantitative"){if(dw(l)&&l.stack==="normalize"&&o.normalizedNumberFormatType)return{text:cA({fieldOrDatumDef:l,field:"datum.value",format:o.normalizedNumberFormat,formatType:o.normalizedNumberFormatType,config:o}),...n};if(o.numberFormatType)return{text:cA({fieldOrDatumDef:l,field:"datum.value",format:o.numberFormat,formatType:o.numberFormatType,config:o}),...n}}if(uw(l)==="temporal"&&o.timeFormatType&&gi(l)&&!l.timeUnit)return{text:cA({fieldOrDatumDef:l,field:"datum.value",format:o.timeFormat,formatType:o.timeFormatType,config:o}),...n}}return n}function mFi(e){return Hd.reduce((i,n)=>(e.component.scales[n]&&(i[n]=[GFi(n,e)]),i),{})}const pFi={bottom:"top",top:"bottom",left:"right",right:"left"};function bFi(e){const{axes:i,resolve:n}=e.component,r={top:0,bottom:0,right:0,left:0};for(const o of e.children){o.parseAxesAndHeaders();for(const l of ei(o.component.axes))n.axis[l]=Ede(e.component.resolve,l),n.axis[l]==="shared"&&(i[l]=yFi(i[l],o.component.axes[l]),i[l]||(n.axis[l]="independent",delete i[l]))}for(const o of Hd){for(const l of e.children)if(l.component.axes[o]){if(n.axis[o]==="independent"){i[o]=(i[o]??[]).concat(l.component.axes[o]);for(const c of l.component.axes[o]){const{value:u,explicit:f}=c.getWithExplicit("orient");if(!Fi(u)){if(r[u]>0&&!f){const m=pFi[u];r[u]>r[m]&&c.set("orient",m,!1)}r[u]++}}}delete l.component.axes[o]}if(n.axis[o]==="independent"&&i[o]&&i[o].length>1)for(const l of i[o])l.get("grid")&&!l.explicit.grid&&(l.implicit.grid=!1)}}function yFi(e,i){if(e){if(e.length!==i.length)return;const n=e.length;for(let r=0;rn.clone());return e}function vFi(e,i){for(const n of rnt){const r=Qp(e.getWithExplicit(n),i.getWithExplicit(n),n,"axis",(o,l)=>{switch(n){case"title":return yet(o,l);case"gridScale":return{explicit:o.explicit,value:Ho(o.value,l.value)}}return NO(o,l,n,"axis")});e.setWithExplicit(n,r)}return e}function ZFi(e,i,n,r,o){if(i==="disable")return n!==void 0;switch(n=n||{},i){case"titleAngle":case"labelAngle":return e===(Fi(n.labelAngle)?n.labelAngle:gW(n.labelAngle));case"values":return!!n.values;case"encode":return!!n.encoding||!!n.labelAngle;case"title":if(e===Zit(r,o))return!0}return e===n[i]}const BFi=new Set(["grid","translate","format","formatType","orient","labelExpr","tickCount","position","tickMinStep"]);function GFi(e,i){let n=i.axis(e);const r=new Fde,o=Jo(i.encoding[e]),{mark:l,config:c}=i,u=n?.orient||c[e==="x"?"axisX":"axisY"]?.orient||c.axis?.orient||C5i(e),f=i.getScaleComponent(e).get("type"),m=r5i(e,f,u,i.config),p=n!==void 0?!n:hae("disable",c.style,n?.style,m).configValue;if(r.set("disable",p,n!==void 0),p)return r;n=n||{};const v=s5i(o,n,e,c.style,m),B=ett(n.formatType,o,f),G=qet(o,o.type,n.format,n.formatType,c,!0),T={fieldOrDatumDef:o,axis:n,channel:e,model:i,scaleType:f,orient:u,labelAngle:v,format:G,formatType:B,mark:l,config:c};for(const W of rnt){const x=W in nKe?nKe[W](T):NYe(W)?n[W]:void 0,k=x!==void 0,F=ZFi(x,W,n,i,e);if(k&&F)r.set(W,x,F);else{const{configValue:Y=void 0,configFrom:L=void 0}=NYe(W)&&W!=="values"?hae(W,c.style,n.style,m):{},O=Y!==void 0;k&&!O?r.set(W,x,F):(L!=="vgAxisConfig"||BFi.has(W)&&O||vN(Y)||Fi(Y))&&r.set(W,Y,!1)}}const V=n.encoding??{},E=utt.reduce((W,x)=>{if(!r.hasAxisPart(x))return W;const k=Rit(V[x]??{},i),F=x==="labels"?fFi(i,e,k):k;return F!==void 0&&!Qr(F)&&(W[x]={update:F}),W},{});return Qr(E)||r.set("encode",E,!!n.encoding||n.labelAngle!==void 0),r}function SFi({encoding:e,size:i}){for(const n of Hd){const r=cl(n);pd(i[r])&&Ap(e[n])&&(delete i[r],ni(wet(r)))}return i}function wFi(e,i,n){const r=OI(e),o=Wr("orient",r,n);if(r.orient=EFi(r.type,i,o),o!==void 0&&o!==r.orient&&ni(QNi(r.orient,o)),r.type==="bar"&&r.orient){const u=Wr("cornerRadiusEnd",r,n);if(u!==void 0){const f=r.orient==="horizontal"&&i.x2||r.orient==="vertical"&&i.y2?["cornerRadius"]:uXi[r.orient];for(const m of f)r[m]=u;r.cornerRadiusEnd!==void 0&&delete r.cornerRadiusEnd}}return Wr("opacity",r,n)===void 0&&(r.opacity=RFi(r.type,i)),Wr("cursor",r,n)===void 0&&(r.cursor=TFi(r,i,n)),r}function TFi(e,i,n){return i.href||e.href||Wr("href",e,n)?"pointer":e.cursor}function RFi(e,i){if(jn([ZO,jue,$ue,que],e)&&!Ide(i))return .7}function VFi(e,i,{graticule:n}){if(n)return!1;const r=kv("filled",e,i),o=e.type;return Ho(r,o!==ZO&&o!==vO&&o!==V_)}function EFi(e,i,n){switch(e){case ZO:case $ue:case que:case Oet:case rXi:case nXi:return}const{x:r,y:o,x2:l,y2:c}=i;switch(e){case yO:if(gi(r)&&(Ha(r.bin)||gi(o)&&o.aggregate&&!r.aggregate))return"vertical";if(gi(o)&&(Ha(o.bin)||gi(r)&&r.aggregate&&!o.aggregate))return"horizontal";if(c||l){if(n)return n;if(!l)return(gi(r)&&r.type===xv&&!dg(r.bin)||H_(r))&&gi(o)&&Ha(o.bin)?"horizontal":"vertical";if(!c)return(gi(o)&&o.type===xv&&!dg(o.bin)||H_(o))&&gi(r)&&Ha(r.bin)?"vertical":"horizontal"}case V_:if(l&&!(gi(r)&&Ha(r.bin))&&c&&!(gi(o)&&Ha(o.bin)))return;case bO:if(c)return gi(o)&&Ha(o.bin)?"horizontal":"vertical";if(l)return gi(r)&&Ha(r.bin)?"vertical":"horizontal";if(e===V_){if(r&&!o)return"vertical";if(o&&!r)return"horizontal"}case vO:case jue:{const u=HYe(r),f=HYe(o);if(n)return n;if(u&&!f)return e!=="tick"?"horizontal":"vertical";if(!u&&f)return e!=="tick"?"vertical":"horizontal";if(u&&f)return"vertical";{const m=mI(r)&&r.type===cw,p=mI(o)&&o.type===cw;if(m&&!p)return"vertical";if(!m&&p)return"horizontal"}return}}return"vertical"}const HFi={vgMark:"arc",encodeEntry:e=>({...ec(e,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"}),...Gs("x",e,{defaultPos:"mid"}),...Gs("y",e,{defaultPos:"mid"}),...jp(e,"radius"),...jp(e,"theta")})},WFi={vgMark:"area",encodeEntry:e=>({...ec(e,{align:"ignore",baseline:"ignore",color:"include",orient:"include",size:"ignore",theta:"ignore"}),...M_("x",e,{defaultPos:"zeroOrMin",defaultPos2:"zeroOrMin",range:e.markDef.orient==="horizontal"}),...M_("y",e,{defaultPos:"zeroOrMin",defaultPos2:"zeroOrMin",range:e.markDef.orient==="vertical"}),...Sde(e)})},NFi={vgMark:"rect",encodeEntry:e=>({...ec(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...jp(e,"x"),...jp(e,"y")})},kFi={vgMark:"shape",encodeEntry:e=>({...ec(e,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"})}),postEncodingTransform:e=>{const{encoding:i}=e,n=i.shape;return[{type:"geoshape",projection:e.projectionName(),...n&&gi(n)&&n.type===qw?{field:di(n,{expr:"datum"})}:{}}]}},XFi={vgMark:"image",encodeEntry:e=>({...ec(e,{align:"ignore",baseline:"ignore",color:"ignore",orient:"ignore",size:"ignore",theta:"ignore"}),...jp(e,"x"),...jp(e,"y"),...Bde(e,"url")})},xFi={vgMark:"line",encodeEntry:e=>({...ec(e,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"}),...Gs("x",e,{defaultPos:"mid"}),...Gs("y",e,{defaultPos:"mid"}),...sa("size",e,{vgChannel:"strokeWidth"}),...Sde(e)})},DFi={vgMark:"trail",encodeEntry:e=>({...ec(e,{align:"ignore",baseline:"ignore",color:"include",size:"include",orient:"ignore",theta:"ignore"}),...Gs("x",e,{defaultPos:"mid"}),...Gs("y",e,{defaultPos:"mid"}),...sa("size",e),...Sde(e)})};function Yde(e,i){const{config:n}=e;return{...ec(e,{align:"ignore",baseline:"ignore",color:"include",size:"include",orient:"ignore",theta:"ignore"}),...Gs("x",e,{defaultPos:"mid"}),...Gs("y",e,{defaultPos:"mid"}),...sa("size",e),...sa("angle",e),...MFi(e,n,i)}}function MFi(e,i,n){return n?{shape:{value:n}}:sa("shape",e)}const FFi={vgMark:"symbol",encodeEntry:e=>Yde(e)},YFi={vgMark:"symbol",encodeEntry:e=>Yde(e,"circle")},KFi={vgMark:"symbol",encodeEntry:e=>Yde(e,"square")},_Fi={vgMark:"rect",encodeEntry:e=>({...ec(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...jp(e,"x"),...jp(e,"y")})},PFi={vgMark:"rule",encodeEntry:e=>{const{markDef:i}=e,n=i.orient;return!e.encoding.x&&!e.encoding.y&&!e.encoding.latitude&&!e.encoding.longitude?{}:{...ec(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...M_("x",e,{defaultPos:n==="horizontal"?"zeroOrMax":"mid",defaultPos2:"zeroOrMin",range:n!=="vertical"}),...M_("y",e,{defaultPos:n==="vertical"?"zeroOrMax":"mid",defaultPos2:"zeroOrMin",range:n!=="horizontal"}),...sa("size",e,{vgChannel:"strokeWidth"})}}},zFi={vgMark:"text",encodeEntry:e=>{const{config:i,encoding:n}=e;return{...ec(e,{align:"include",baseline:"include",color:"include",size:"ignore",orient:"ignore",theta:"include"}),...Gs("x",e,{defaultPos:"mid"}),...Gs("y",e,{defaultPos:"mid"}),...Bde(e),...sa("size",e,{vgChannel:"fontSize"}),...sa("angle",e),...qYe("align",OFi(e.markDef,n,i)),...qYe("baseline",LFi(e.markDef,n,i)),...Gs("radius",e,{defaultPos:null}),...Gs("theta",e,{defaultPos:null})}}};function OFi(e,i,n){if(Wr("align",e,n)===void 0)return"center"}function LFi(e,i,n){if(Wr("baseline",e,n)===void 0)return"middle"}const JFi={vgMark:"rect",encodeEntry:e=>{const{config:i,markDef:n}=e,r=n.orient,o=r==="horizontal"?"width":"height",l=r==="horizontal"?"height":"width";return{...ec(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...Gs("x",e,{defaultPos:"mid",vgChannel:"xc"}),...Gs("y",e,{defaultPos:"mid",vgChannel:"yc"}),...sa("size",e,{defaultValue:UFi(e),vgChannel:o}),[l]:Gg(Wr("thickness",n,i))}}};function UFi(e){const{config:i,markDef:n}=e,{orient:r}=n,o=r==="horizontal"?"width":"height",l=e.getScaleComponent(r==="horizontal"?"x":"y"),c=Wr("size",n,i,{vgChannel:o})??i.tick.bandSize;if(c!==void 0)return c;{const u=l?l.get("range"):void 0;return u&&b0(u)&&jr(u.step)?u.step*3/4:x_(i.view,o)*3/4}}const QF={arc:HFi,area:WFi,bar:NFi,circle:YFi,geoshape:kFi,image:XFi,line:xFi,point:FFi,rect:_Fi,rule:PFi,square:KFi,text:zFi,tick:JFi,trail:DFi};function QFi(e){if(jn([vO,bO,gXi],e.mark)){const i=ptt(e.mark,e.encoding);if(i.length>0)return jFi(e,i)}else if(e.mark===yO){const i=nae.some(n=>Wr(n,e.markDef,e.config));if(e.stack&&!e.fieldDef("size")&&i)return $Fi(e)}return Kde(e)}const pKe="faceted_path_";function jFi(e,i){return[{name:e.getName("pathgroup"),type:"group",from:{facet:{name:pKe+e.requestDataName(cg.Main),data:e.requestDataName(cg.Main),groupby:i}},encode:{update:{width:{field:{group:"width"}},height:{field:{group:"height"}}}},marks:Kde(e,{fromPrefix:pKe})}]}const bKe="stack_group_";function $Fi(e){const[i]=Kde(e,{fromPrefix:bKe}),n=e.scaleName(e.stack.fieldChannel),r=(m={})=>e.vgField(e.stack.fieldChannel,m),o=(m,p)=>{const v=[r({prefix:"min",suffix:"start",expr:p}),r({prefix:"max",suffix:"start",expr:p}),r({prefix:"min",suffix:"end",expr:p}),r({prefix:"max",suffix:"end",expr:p})];return`${m}(${v.map(B=>`scale('${n}',${B})`).join(",")})`};let l,c;e.stack.fieldChannel==="x"?(l={...Iw(i.encode.update,["y","yc","y2","height",...nae]),x:{signal:o("min","datum")},x2:{signal:o("max","datum")},clip:{value:!0}},c={x:{field:{group:"x"},mult:-1},height:{field:{group:"height"}}},i.encode.update={...nl(i.encode.update,["y","yc","y2"]),height:{field:{group:"height"}}}):(l={...Iw(i.encode.update,["x","xc","x2","width"]),y:{signal:o("min","datum")},y2:{signal:o("max","datum")},clip:{value:!0}},c={y:{field:{group:"y"},mult:-1},width:{field:{group:"width"}}},i.encode.update={...nl(i.encode.update,["x","xc","x2"]),width:{field:{group:"width"}}});for(const m of nae){const p=kv(m,e.markDef,e.config);i.encode.update[m]?(l[m]=i.encode.update[m],delete i.encode.update[m]):p&&(l[m]=Gg(p)),p&&(i.encode.update[m]={value:0})}const u=[];if(e.stack.groupbyChannels?.length>0)for(const m of e.stack.groupbyChannels){const p=e.fieldDef(m),v=di(p);v&&u.push(v),(p?.bin||p?.timeUnit)&&u.push(di(p,{binSuffix:"end"}))}return l=["stroke","strokeWidth","strokeJoin","strokeCap","strokeDash","strokeDashOffset","strokeMiterLimit","strokeOpacity"].reduce((m,p)=>{if(i.encode.update[p])return{...m,[p]:i.encode.update[p]};{const v=kv(p,e.markDef,e.config);return v!==void 0?{...m,[p]:Gg(v)}:m}},l),l.stroke&&(l.strokeForeground={value:!0},l.strokeOffset={value:0}),[{type:"group",from:{facet:{data:e.requestDataName(cg.Main),name:bKe+e.requestDataName(cg.Main),groupby:u,aggregate:{fields:[r({suffix:"start"}),r({suffix:"start"}),r({suffix:"end"}),r({suffix:"end"})],ops:["min","max","min","max"]}}},encode:{update:l},marks:[{type:"group",encode:{update:c},marks:[i]}]}]}function qFi(e){const{encoding:i,stack:n,mark:r,markDef:o,config:l}=e,c=i.order;if(!(!Pt(c)&&wA(c)&&tae(c.value)||!c&&tae(Wr("order",o,l)))){if((Pt(c)||gi(c))&&!n)return met(c,{expr:"datum"});if(y0(r)){const u=o.orient==="horizontal"?"y":"x",f=i[u];if(gi(f)){const m=f.sort;if(Pt(m))return{field:di(f,{prefix:u,suffix:"sort_index",expr:"datum"})};if(id(m))return{field:di({aggregate:Ide(e.encoding)?m.op:void 0,field:m.field},{expr:"datum"})};if(itt(m)){const p=e.fieldDef(m.encoding);return{field:di(p,{expr:"datum"}),order:m.order}}else return m===null?void 0:{field:di(f,{binSuffix:e.stack?.impute?"mid":void 0,expr:"datum"})}}return}}}function Kde(e,i={fromPrefix:""}){const{mark:n,markDef:r,encoding:o,config:l}=e,c=Ho(r.clip,eYi(e),tYi(e)),u=het(r),f=o.key,m=qFi(e),p=iYi(e),v=Wr("aria",r,l),B=QF[n].postEncodingTransform?QF[n].postEncodingTransform(e):null;return[{name:e.getName("marks"),type:QF[n].vgMark,...c?{clip:!0}:{},...u?{style:u}:{},...f?{key:f.field}:{},...m?{sort:m}:{},...p||{},...v===!1?{aria:v}:{},from:{data:i.fromPrefix+e.requestDataName(cg.Main)},encode:{update:QF[n].encodeEntry(e)},...B?{transform:B}:{}}]}function eYi(e){const i=e.getScaleComponent("x"),n=e.getScaleComponent("y");return i?.get("selectionExtent")||n?.get("selectionExtent")?!0:void 0}function tYi(e){const i=e.component.projection;return i&&!i.isFit?!0:void 0}function iYi(e){if(!e.component.selection)return null;const i=ei(e.component.selection).length;let n=i,r=e.parent;for(;r&&n===0;)n=ei(r.component.selection).length,r=r.parent;return n?{interactive:i>0||e.mark==="geoshape"||!!e.encoding.tooltip}:null}class gnt extends ent{constructor(i,n,r,o={},l){super(i,"unit",n,r,l,void 0,XYe(i)?i.view:void 0),this.specifiedScales={},this.specifiedAxes={},this.specifiedLegends={},this.specifiedProjection={},this.selection=[],this.children=[];const c=fd(i.mark)?{...i.mark}:{type:i.mark},u=c.type;c.filled===void 0&&(c.filled=VFi(c,l,{graticule:i.data&&vde(i.data)}));const f=this.encoding=PXi(i.encoding||{},u,c.filled,l);this.markDef=wFi(c,f,l),this.size=SFi({encoding:f,size:XYe(i)?{...o,...i.width?{width:i.width}:{},...i.height?{height:i.height}:{}}:o}),this.stack=Mtt(this.markDef,f),this.specifiedScales=this.initScales(u,f),this.specifiedAxes=this.initAxes(f),this.specifiedLegends=this.initLegends(f),this.specifiedProjection=i.projection,this.selection=(i.params??[]).filter(m=>fde(m))}get hasProjection(){const{encoding:i}=this,n=this.mark===Let,r=i&&PWi.some(o=>yn(i[o]));return n||r}scaleDomain(i){const n=this.specifiedScales[i];return n?n.domain:void 0}axis(i){return this.specifiedAxes[i]}legend(i){return this.specifiedLegends[i]}initScales(i,n){return hO.reduce((r,o)=>{const l=Jo(n[o]);return l&&(r[o]=this.initScale(l.scale??{})),r},{})}initScale(i){const{domain:n,range:r}=i,o=OI(i);return Pt(n)&&(o.domain=n.map(Dl)),Pt(r)&&(o.range=r.map(Dl)),o}initAxes(i){return Hd.reduce((n,r)=>{const o=i[r];if(yn(o)||r===Fg&&yn(i.x2)||r===da&&yn(i.y2)){const l=yn(o)?o.axis:void 0;n[r]=l&&this.initAxis({...l})}return n},{})}initAxis(i){const n=ei(i),r={};for(const o of n){const l=i[o];r[o]=vN(l)?det(l):Dl(l)}return r}initLegends(i){return qWi.reduce((n,r)=>{const o=Jo(i[r]);if(o&&tNi(r)){const l=o.legend;n[r]=l&&OI(l)}return n},{})}parseData(){this.component.data=JO(this)}parseLayoutSize(){IFi(this)}parseSelections(){this.component.selection=e5i(this,this.selection)}parseMarkGroup(){this.component.mark=QFi(this)}parseAxesAndHeaders(){this.component.axes=mFi(this)}assembleSelectionTopLevelSignals(i){return vDi(this,i)}assembleSignals(){return[...bit(this),...bDi(this,[])]}assembleSelectionData(i){return ZDi(this,i)}assembleLayout(){return null}assembleLayoutSignals(){return Vde(this)}assembleMarks(){let i=this.component.mark??[];return(!this.parent||!r2(this.parent))&&(i=$tt(this,i)),i.map(this.correctDataNames)}assembleGroupStyle(){const{style:i}=this.view||{};return i!==void 0?i:this.encoding.x||this.encoding.y?"cell":"view"}getMapping(){return this.encoding}get mark(){return this.markDef.type}channelHasField(i){return $y(this.encoding,i)}fieldDef(i){const n=this.encoding[i];return md(n)}typedFieldDef(i){const n=this.fieldDef(i);return mI(n)?n:null}}class _de extends Dde{constructor(i,n,r,o,l){super(i,"layer",n,r,l,i.resolve,i.view);const c={...o,...i.width?{width:i.width}:{},...i.height?{height:i.height}:{}};this.children=i.layer.map((u,f)=>{if(WO(u))return new _de(u,this,this.getName(`layer_${f}`),c,l);if(wf(u))return new gnt(u,this,this.getName(`layer_${f}`),c,l);throw new Error(Xue(u))})}parseData(){this.component.data=JO(this);for(const i of this.children)i.parseData()}parseLayoutSize(){aFi(this)}parseSelections(){this.component.selection={};for(const i of this.children){i.parseSelections();for(const n of ei(i.component.selection))this.component.selection[n]=i.component.selection[n]}}parseMarkGroup(){for(const i of this.children)i.parseMarkGroup()}parseAxesAndHeaders(){bFi(this)}assembleSelectionTopLevelSignals(i){return this.children.reduce((n,r)=>r.assembleSelectionTopLevelSignals(n),i)}assembleSignals(){return this.children.reduce((i,n)=>i.concat(n.assembleSignals()),bit(this))}assembleLayoutSignals(){return this.children.reduce((i,n)=>i.concat(n.assembleLayoutSignals()),Vde(this))}assembleSelectionData(i){return this.children.reduce((n,r)=>r.assembleSelectionData(n),i)}assembleGroupStyle(){const i=new Set;for(const r of this.children)for(const o of pi(r.assembleGroupStyle()))i.add(o);const n=Array.from(i);return n.length>1?n:n.length===1?n[0]:void 0}assembleTitle(){let i=super.assembleTitle();if(i)return i;for(const n of this.children)if(i=n.assembleTitle(),i)return i}assembleLayout(){return null}assembleMarks(){return BDi(this,this.children.flatMap(i=>i.assembleMarks()))}assembleLegends(){return this.children.reduce((i,n)=>i.concat(n.assembleLegends()),xit(this))}}function Pde(e,i,n,r,o){if(GO(e))return new kE(e,i,n,o);if(WO(e))return new _de(e,i,n,r,o);if(wf(e))return new gnt(e,i,n,r,o);if(uxi(e))return new uFi(e,i,n,o);throw new Error(Xue(e))}function nYi(e,i={}){i.logger&&yki(i.logger),i.fieldTitle&&Ctt(i.fieldTitle);try{const n=Dtt(Xw(i.config,e.config)),r=Ott(e,n),o=Pde(r,null,"",void 0,n);return o.parse(),vMi(o.component.data,o),{spec:gYi(o,rYi(e,r.autosize,n,o),e.datasets,e.usermeta),normalized:r}}finally{i.logger&&vki(),i.fieldTitle&&kXi()}}function rYi(e,i,n,r){const o=r.component.layoutSize.get("width"),l=r.component.layoutSize.get("height");if(i===void 0?(i={type:"pad"},r.hasAxisOrientSignalRef()&&(i.resize=!0)):fi(i)&&(i={type:i}),o&&l&&hDi(i.type)){if(o==="step"&&l==="step")ni(bYe()),i.type="pad";else if(o==="step"||l==="step"){const c=o==="step"?"width":"height";ni(bYe(dO(c)));const u=c==="width"?"height":"width";i.type=fDi(u)}}return{...ei(i).length===1&&i.type?i.type==="pad"?{}:{autosize:i.type}:{autosize:i},...JYe(n,!1),...JYe(e,!0)}}function gYi(e,i,n={},r){const o=e.config?Txi(e.config):void 0,l=[].concat(e.assembleSelectionData([]),nFi(e.component.data,n)),c=e.assembleProjections(),u=e.assembleTitle(),f=e.assembleGroupStyle(),m=e.assembleGroupEncodeEntry(!0);let p=e.assembleLayoutSignals();p=p.filter(G=>(G.name==="width"||G.name==="height")&&G.value!==void 0?(i[G.name]=+G.value,!1):!0);const{params:v,...B}=i;return{$schema:"https://vega.github.io/schema/vega/v5.json",...e.description?{description:e.description}:{},...B,...u?{title:u}:{},...f?{style:f}:{},...m?{encode:{update:m}}:{},data:l,...c.length>0?{projections:c}:{},...e.assembleGroup([...p,...e.assembleSelectionTopLevelSignals([]),...Ntt(v)]),...o?{config:o}:{},...r?{usermeta:r}:{}}}const oYi=NWi.version,aYi=Object.freeze(Object.defineProperty({__proto__:null,accessPathDepth:lw,accessPathWithDatum:Sue,compile:nYi,contains:jn,deepEqual:Ku,deleteNestedProperty:w_,duplicate:vn,entries:Jp,every:Zue,fieldIntersection:Gue,flatAccessWithDatum:Lqe,getFirstDefined:Ho,hasIntersection:Bue,hash:Ir,internalField:Qqe,isBoolean:rW,isEmpty:Qr,isEqual:FWi,isInternalField:jqe,isNullOrFalse:tae,isNumeric:IO,keys:ei,logicalExpr:WE,mergeDeep:zqe,never:Pqe,normalize:Ott,normalizeAngle:gW,omit:nl,pick:Iw,prefixGenerator:iae,removePathFromField:wue,replaceAll:Wv,replacePathInField:QC,resetIdCounter:KWi,setEqual:Oqe,some:Hv,stringify:ug,titleCase:cN,unique:_u,uniqueId:Uqe,vals:Da,varName:Mg,version:oYi},Symbol.toStringTag,{value:"Module"}));function ont(e){const[i,n]=/schema\/([\w-]+)\/([\w\.\-]+)\.json$/g.exec(e).slice(1,3);return{library:i,version:n}}var sYi="vega-themes",IYi="2.13.0",lYi="Themes for stylized Vega and Vega-Lite visualizations.",CYi=["vega","vega-lite","themes","style"],cYi="BSD-3-Clause",AYi={name:"UW Interactive Data Lab",url:"https://idl.cs.washington.edu"},uYi=[{name:"Emily Gu",url:"https://github.com/emilygu"},{name:"Arvind Satyanarayan",url:"http://arvindsatya.com"},{name:"Jeffrey Heer",url:"https://idl.cs.washington.edu"},{name:"Dominik Moritz",url:"https://www.domoritz.de"}],dYi="build/vega-themes.js",hYi="build/vega-themes.module.js",fYi="build/vega-themes.min.js",mYi="build/vega-themes.min.js",pYi="build/vega-themes.module.d.ts",bYi={type:"git",url:"https://github.com/vega/vega-themes.git"},yYi=["src","build"],vYi={prebuild:"yarn clean",build:"rollup -c",clean:"rimraf build && rimraf examples/build","copy:data":"rsync -r node_modules/vega-datasets/data/* examples/data","copy:build":"rsync -r build/* examples/build","deploy:gh":"yarn build && mkdir -p examples/build && rsync -r build/* examples/build && gh-pages -d examples",preversion:"yarn lint",serve:"browser-sync start -s -f build examples --serveStatic examples",start:"yarn build && concurrently --kill-others -n Server,Rollup 'yarn serve' 'rollup -c -w'",format:"eslint . --fix",lint:"eslint .",release:"release-it"},ZYi={"@babel/core":"^7.21.4","@babel/plugin-transform-runtime":"^7.21.4","@babel/preset-env":"^7.21.4","@babel/preset-typescript":"^7.21.4","@release-it/conventional-changelog":"^5.1.1","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.0.2","@rollup/plugin-terser":"^0.4.1","@typescript-eslint/eslint-plugin":"^5.59.0","@typescript-eslint/parser":"^5.59.0","browser-sync":"^2.29.1",concurrently:"^8.0.1",eslint:"^8.38.0","eslint-config-prettier":"^8.8.0","eslint-plugin-prettier":"^4.2.1","gh-pages":"^5.0.0",prettier:"^2.8.7","release-it":"^15.10.1",rollup:"^3.20.6","rollup-plugin-bundle-size":"^1.0.3","rollup-plugin-ts":"^3.2.0",typescript:"^5.0.4",vega:"^5.24.0","vega-lite":"^5.7.1"},BYi={vega:"*","vega-lite":"*"},GYi={},SYi={name:sYi,version:IYi,description:lYi,keywords:CYi,license:cYi,author:AYi,contributors:uYi,main:dYi,module:hYi,unpkg:fYi,jsdelivr:mYi,types:pYi,repository:bYi,files:yYi,scripts:vYi,devDependencies:ZYi,peerDependencies:BYi,dependencies:GYi};const ZG="#fff",yKe="#888",wYi={background:"#333",view:{stroke:yKe},title:{color:ZG,subtitleColor:ZG},style:{"guide-label":{fill:ZG},"guide-title":{fill:ZG}},axis:{domainColor:ZG,gridColor:yKe,tickColor:ZG}},qb="#4572a7",TYi={background:"#fff",arc:{fill:qb},area:{fill:qb},line:{stroke:qb,strokeWidth:2},path:{stroke:qb},rect:{fill:qb},shape:{stroke:qb},symbol:{fill:qb,strokeWidth:1.5,size:50},axis:{bandPosition:.5,grid:!0,gridColor:"#000000",gridOpacity:1,gridWidth:.5,labelPadding:10,tickSize:5,tickWidth:.5},axisBand:{grid:!1,tickExtra:!0},legend:{labelBaseline:"middle",labelFontSize:11,symbolSize:50,symbolType:"square"},range:{category:["#4572a7","#aa4643","#8aa453","#71598e","#4598ae","#d98445","#94aace","#d09393","#b9cc98","#a99cbc"]}},ey="#30a2da",rie="#cbcbcb",RYi="#999",VYi="#333",vKe="#f0f0f0",ZKe="#333",EYi={arc:{fill:ey},area:{fill:ey},axis:{domainColor:rie,grid:!0,gridColor:rie,gridWidth:1,labelColor:RYi,labelFontSize:10,titleColor:VYi,tickColor:rie,tickSize:10,titleFontSize:14,titlePadding:10,labelPadding:4},axisBand:{grid:!1},background:vKe,group:{fill:vKe},legend:{labelColor:ZKe,labelFontSize:11,padding:1,symbolSize:30,symbolType:"square",titleColor:ZKe,titleFontSize:14,titlePadding:10},line:{stroke:ey,strokeWidth:2},path:{stroke:ey,strokeWidth:.5},rect:{fill:ey},range:{category:["#30a2da","#fc4f30","#e5ae38","#6d904f","#8b8b8b","#b96db8","#ff9e27","#56cc60","#52d2ca","#52689e","#545454","#9fe4f8"],diverging:["#cc0020","#e77866","#f6e7e1","#d6e8ed","#91bfd9","#1d78b5"],heatmap:["#d6e8ed","#cee0e5","#91bfd9","#549cc6","#1d78b5"]},point:{filled:!0,shape:"circle"},shape:{stroke:ey},bar:{binSpacing:2,fill:ey,stroke:null},title:{anchor:"start",fontSize:24,fontWeight:600,offset:20}},ty="#000",HYi={group:{fill:"#e5e5e5"},arc:{fill:ty},area:{fill:ty},line:{stroke:ty},path:{stroke:ty},rect:{fill:ty},shape:{stroke:ty},symbol:{fill:ty,size:40},axis:{domain:!1,grid:!0,gridColor:"#FFFFFF",gridOpacity:1,labelColor:"#7F7F7F",labelPadding:4,tickColor:"#7F7F7F",tickSize:5.67,titleFontSize:16,titleFontWeight:"normal"},legend:{labelBaseline:"middle",labelFontSize:11,symbolSize:40},range:{category:["#000000","#7F7F7F","#1A1A1A","#999999","#333333","#B0B0B0","#4D4D4D","#C9C9C9","#666666","#DCDCDC"]}},WYi=22,NYi="normal",BKe="Benton Gothic, sans-serif",GKe=11.5,kYi="normal",iy="#82c6df",gie="Benton Gothic Bold, sans-serif",SKe="normal",wKe=13,p9={"category-6":["#ec8431","#829eb1","#c89d29","#3580b1","#adc839","#ab7fb4"],"fire-7":["#fbf2c7","#f9e39c","#f8d36e","#f4bb6a","#e68a4f","#d15a40","#ab4232"],"fireandice-6":["#e68a4f","#f4bb6a","#f9e39c","#dadfe2","#a6b7c6","#849eae"],"ice-7":["#edefee","#dadfe2","#c4ccd2","#a6b7c6","#849eae","#607785","#47525d"]},XYi={background:"#ffffff",title:{anchor:"start",color:"#000000",font:gie,fontSize:WYi,fontWeight:NYi},arc:{fill:iy},area:{fill:iy},line:{stroke:iy,strokeWidth:2},path:{stroke:iy},rect:{fill:iy},shape:{stroke:iy},symbol:{fill:iy,size:30},axis:{labelFont:BKe,labelFontSize:GKe,labelFontWeight:kYi,titleFont:gie,titleFontSize:wKe,titleFontWeight:SKe},axisX:{labelAngle:0,labelPadding:4,tickSize:3},axisY:{labelBaseline:"middle",maxExtent:45,minExtent:45,tickSize:2,titleAlign:"left",titleAngle:0,titleX:-45,titleY:-11},legend:{labelFont:BKe,labelFontSize:GKe,symbolType:"square",titleFont:gie,titleFontSize:wKe,titleFontWeight:SKe},range:{category:p9["category-6"],diverging:p9["fireandice-6"],heatmap:p9["fire-7"],ordinal:p9["fire-7"],ramp:p9["fire-7"]}},ny="#ab5787",jF="#979797",xYi={background:"#f9f9f9",arc:{fill:ny},area:{fill:ny},line:{stroke:ny},path:{stroke:ny},rect:{fill:ny},shape:{stroke:ny},symbol:{fill:ny,size:30},axis:{domainColor:jF,domainWidth:.5,gridWidth:.2,labelColor:jF,tickColor:jF,tickWidth:.2,titleColor:jF},axisBand:{grid:!1},axisX:{grid:!0,tickSize:10},axisY:{domain:!1,grid:!0,tickSize:0},legend:{labelFontSize:11,padding:1,symbolSize:30,symbolType:"square"},range:{category:["#ab5787","#51b2e5","#703c5c","#168dd9","#d190b6","#00609f","#d365ba","#154866","#666666","#c4c4c4"]}},ry="#3e5c69",DYi={background:"#fff",arc:{fill:ry},area:{fill:ry},line:{stroke:ry},path:{stroke:ry},rect:{fill:ry},shape:{stroke:ry},symbol:{fill:ry},axis:{domainWidth:.5,grid:!0,labelPadding:2,tickSize:5,tickWidth:.5,titleFontWeight:"normal"},axisBand:{grid:!1},axisX:{gridWidth:.2},axisY:{gridDash:[3],gridWidth:.4},legend:{labelFontSize:11,padding:1,symbolType:"square"},range:{category:["#3e5c69","#6793a6","#182429","#0570b0","#3690c0","#74a9cf","#a6bddb","#e2ddf2"]}},vC="#1696d2",TKe="#000000",MYi="#FFFFFF",$F="Lato",oie="Lato",FYi="Lato",YYi="#DEDDDD",KYi=18,b9={"main-colors":["#1696d2","#d2d2d2","#000000","#fdbf11","#ec008b","#55b748","#5c5859","#db2b27"],"shades-blue":["#CFE8F3","#A2D4EC","#73BFE2","#46ABDB","#1696D2","#12719E","#0A4C6A","#062635"],"shades-gray":["#F5F5F5","#ECECEC","#E3E3E3","#DCDBDB","#D2D2D2","#9D9D9D","#696969","#353535"],"shades-yellow":["#FFF2CF","#FCE39E","#FDD870","#FCCB41","#FDBF11","#E88E2D","#CA5800","#843215"],"shades-magenta":["#F5CBDF","#EB99C2","#E46AA7","#E54096","#EC008B","#AF1F6B","#761548","#351123"],"shades-green":["#DCEDD9","#BCDEB4","#98CF90","#78C26D","#55B748","#408941","#2C5C2D","#1A2E19"],"shades-black":["#D5D5D4","#ADABAC","#848081","#5C5859","#332D2F","#262223","#1A1717","#0E0C0D"],"shades-red":["#F8D5D4","#F1AAA9","#E9807D","#E25552","#DB2B27","#A4201D","#6E1614","#370B0A"],"one-group":["#1696d2","#000000"],"two-groups-cat-1":["#1696d2","#000000"],"two-groups-cat-2":["#1696d2","#fdbf11"],"two-groups-cat-3":["#1696d2","#db2b27"],"two-groups-seq":["#a2d4ec","#1696d2"],"three-groups-cat":["#1696d2","#fdbf11","#000000"],"three-groups-seq":["#a2d4ec","#1696d2","#0a4c6a"],"four-groups-cat-1":["#000000","#d2d2d2","#fdbf11","#1696d2"],"four-groups-cat-2":["#1696d2","#ec0008b","#fdbf11","#5c5859"],"four-groups-seq":["#cfe8f3","#73bf42","#1696d2","#0a4c6a"],"five-groups-cat-1":["#1696d2","#fdbf11","#d2d2d2","#ec008b","#000000"],"five-groups-cat-2":["#1696d2","#0a4c6a","#d2d2d2","#fdbf11","#332d2f"],"five-groups-seq":["#cfe8f3","#73bf42","#1696d2","#0a4c6a","#000000"],"six-groups-cat-1":["#1696d2","#ec008b","#fdbf11","#000000","#d2d2d2","#55b748"],"six-groups-cat-2":["#1696d2","#d2d2d2","#ec008b","#fdbf11","#332d2f","#0a4c6a"],"six-groups-seq":["#cfe8f3","#a2d4ec","#73bfe2","#46abdb","#1696d2","#12719e"],"diverging-colors":["#ca5800","#fdbf11","#fdd870","#fff2cf","#cfe8f3","#73bfe2","#1696d2","#0a4c6a"]},_Yi={background:MYi,title:{anchor:"start",fontSize:KYi,font:$F},axisX:{domain:!0,domainColor:TKe,domainWidth:1,grid:!1,labelFontSize:12,labelFont:oie,labelAngle:0,tickColor:TKe,tickSize:5,titleFontSize:12,titlePadding:10,titleFont:$F},axisY:{domain:!1,domainWidth:1,grid:!0,gridColor:YYi,gridWidth:1,labelFontSize:12,labelFont:oie,labelPadding:8,ticks:!1,titleFontSize:12,titlePadding:10,titleFont:$F,titleAngle:0,titleY:-10,titleX:18},legend:{labelFontSize:12,labelFont:oie,symbolSize:100,titleFontSize:12,titlePadding:10,titleFont:$F,orient:"right",offset:10},view:{stroke:"transparent"},range:{category:b9["six-groups-cat-1"],diverging:b9["diverging-colors"],heatmap:b9["diverging-colors"],ordinal:b9["six-groups-seq"],ramp:b9["shades-blue"]},area:{fill:vC},rect:{fill:vC},line:{color:vC,stroke:vC,strokeWidth:5},trail:{color:vC,stroke:vC,strokeWidth:0,size:1},path:{stroke:vC,strokeWidth:.5},point:{filled:!0},text:{font:FYi,color:vC,fontSize:11,align:"center",fontWeight:400,size:11},style:{bar:{fill:vC,stroke:null}},arc:{fill:vC},shape:{stroke:vC},symbol:{fill:vC,size:30}},gy="#3366CC",RKe="#ccc",qF="Arial, sans-serif",PYi={arc:{fill:gy},area:{fill:gy},path:{stroke:gy},rect:{fill:gy},shape:{stroke:gy},symbol:{stroke:gy},circle:{fill:gy},background:"#fff",padding:{top:10,right:10,bottom:10,left:10},style:{"guide-label":{font:qF,fontSize:12},"guide-title":{font:qF,fontSize:12},"group-title":{font:qF,fontSize:12}},title:{font:qF,fontSize:14,fontWeight:"bold",dy:-3,anchor:"start"},axis:{gridColor:RKe,tickColor:RKe,domain:!1,grid:!0},range:{category:["#4285F4","#DB4437","#F4B400","#0F9D58","#AB47BC","#00ACC1","#FF7043","#9E9D24","#5C6BC0","#F06292","#00796B","#C2185B"],heatmap:["#c6dafc","#5e97f6","#2a56c6"]}},zde=e=>e*(1/3+1),VKe=zde(9),EKe=zde(10),HKe=zde(12),y9="Segoe UI",WKe="wf_standard-font, helvetica, arial, sans-serif",NKe="#252423",v9="#605E5C",kKe="transparent",zYi="#C8C6C4",zc="#118DFF",OYi="#12239E",LYi="#E66C37",JYi="#6B007B",UYi="#E044A7",QYi="#744EC2",jYi="#D9B300",$Yi="#D64550",ant=zc,snt="#DEEFFF",XKe=[snt,ant],qYi=[snt,"#c7e4ff","#b0d9ff","#9aceff","#83c3ff","#6cb9ff","#55aeff","#3fa3ff","#2898ff",ant],eKi={view:{stroke:kKe},background:kKe,font:y9,header:{titleFont:WKe,titleFontSize:HKe,titleColor:NKe,labelFont:y9,labelFontSize:EKe,labelColor:v9},axis:{ticks:!1,grid:!1,domain:!1,labelColor:v9,labelFontSize:VKe,titleFont:WKe,titleColor:NKe,titleFontSize:HKe,titleFontWeight:"normal"},axisQuantitative:{tickCount:3,grid:!0,gridColor:zYi,gridDash:[1,5],labelFlush:!1},axisBand:{tickExtra:!0},axisX:{labelPadding:5},axisY:{labelPadding:10},bar:{fill:zc},line:{stroke:zc,strokeWidth:3,strokeCap:"round",strokeJoin:"round"},text:{font:y9,fontSize:VKe,fill:v9},arc:{fill:zc},area:{fill:zc,line:!0,opacity:.6},path:{stroke:zc},rect:{fill:zc},point:{fill:zc,filled:!0,size:75},shape:{stroke:zc},symbol:{fill:zc,strokeWidth:1.5,size:50},legend:{titleFont:y9,titleFontWeight:"bold",titleColor:v9,labelFont:y9,labelFontSize:EKe,labelColor:v9,symbolType:"circle",symbolSize:75},range:{category:[zc,OYi,LYi,JYi,UYi,QYi,jYi,$Yi],diverging:XKe,heatmap:XKe,ordinal:qYi}},tKi=SYi.version,iKi=Object.freeze(Object.defineProperty({__proto__:null,dark:wYi,excel:TYi,fivethirtyeight:EYi,ggplot2:HYi,googlecharts:PYi,latimes:XYi,powerbi:eKi,quartz:xYi,urbaninstitute:_Yi,version:tKi,vox:DYi},Symbol.toStringTag,{value:"Module"}));function CW(e){return CW=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(i){return typeof i}:function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},CW(e)}function nKi(e,i){if(CW(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,i||"default");if(CW(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(e)}function rKi(e){var i=nKi(e,"string");return CW(i)==="symbol"?i:String(i)}function gKi(e,i,n){return i=rKi(i),i in e?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n,e}function oKi(e,i){if(e==null)return{};var n={},r=Object.keys(e),o,l;for(l=0;l=0)&&(n[o]=e[o]);return n}function aKi(e,i){if(e==null)return{};var n=oKi(e,i),r,o;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(o=0;o=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}const sKi=["title","image"];function IKi(e,i,n){if(Pt(e))return`[${e.map(r=>i(fi(r)?r:xKe(r,n))).join(", ")}]`;if(vi(e)){let r="";const o=e,{title:l,image:c}=o,u=aKi(o,sKi);l&&(r+=`

${i(l)}

`),c&&(r+=``);const f=Object.keys(u);if(f.length>0){r+="";for(const m of f){let p=u[m];p!==void 0&&(vi(p)&&(p=xKe(p,n)),r+=``)}r+="
${i(m)}:${i(p)}
"}return r||"{}"}return i(e)}function lKi(e){const i=[];return function(n,r){if(typeof r!="object"||r===null)return r;const o=i.indexOf(this)+1;return i.length=o,i.length>e?"[Object]":i.indexOf(r)>=0?"[Circular]":(i.push(r),r)}}function xKe(e,i){return JSON.stringify(e,lKi(i))}var CKi=`#vg-tooltip-element { - visibility: hidden; - padding: 8px; - position: fixed; - z-index: 1000; - font-family: sans-serif; - font-size: 11px; - border-radius: 3px; - box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1); - /* The default theme is the light theme. */ - background-color: rgba(255, 255, 255, 0.95); - border: 1px solid #d9d9d9; - color: black; -} -#vg-tooltip-element.visible { - visibility: visible; -} -#vg-tooltip-element h2 { - margin-top: 0; - margin-bottom: 10px; - font-size: 13px; -} -#vg-tooltip-element table { - border-spacing: 0; -} -#vg-tooltip-element table tr { - border: none; -} -#vg-tooltip-element table tr td { - overflow: hidden; - text-overflow: ellipsis; - padding-top: 2px; - padding-bottom: 2px; -} -#vg-tooltip-element table tr td.key { - color: #808080; - max-width: 150px; - text-align: right; - padding-right: 4px; -} -#vg-tooltip-element table tr td.value { - display: block; - max-width: 300px; - max-height: 7em; - text-align: left; -} -#vg-tooltip-element.dark-theme { - background-color: rgba(32, 32, 32, 0.9); - border: 1px solid #f5f5f5; - color: white; -} -#vg-tooltip-element.dark-theme td.key { - color: #bfbfbf; -} -`;const Int="vg-tooltip-element",cKi={offsetX:10,offsetY:10,id:Int,styleId:"vega-tooltip-style",theme:"light",disableDefaultStyle:!1,sanitize:AKi,maxDepth:2,formatTooltip:IKi};function AKi(e){return String(e).replace(/&/g,"&").replace(/window.innerWidth&&(o=+e.clientX-n-i.width);let l=e.clientY+r;return l+i.height>window.innerHeight&&(l=+e.clientY-r-i.height),{x:o,y:l}}function DKe(e,i){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);i&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function MKe(e){for(var i=1;i0?o.insertBefore(r,o.childNodes[0]):o.appendChild(r)}}tooltipHandler(i,n,r,o){if(this.el=document.getElementById(this.options.id),this.el||(this.el=document.createElement("div"),this.el.setAttribute("id",this.options.id),this.el.classList.add("vg-tooltip"),(document.fullscreenElement??document.body).appendChild(this.el)),o==null||o===""){this.el.classList.remove("visible",`${this.options.theme}-theme`);return}this.el.innerHTML=this.options.formatTooltip(o,this.options.sanitize,this.options.maxDepth),this.el.classList.add("visible",`${this.options.theme}-theme`);const{x:l,y:c}=dKi(n,this.el.getBoundingClientRect(),this.options.offsetX,this.options.offsetY);this.el.style.top=`${c}px`,this.el.style.left=`${l}px`}}function cW(e){return cW=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(i){return typeof i}:function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},cW(e)}function fKi(e,i){if(cW(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,i||"default");if(cW(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(e)}function mKi(e){var i=fKi(e,"string");return cW(i)==="symbol"?i:String(i)}function pKi(e,i,n){return i=mKi(i),i in e?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n,e}function bKi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var aie,FKe;function yKi(){return FKe||(FKe=1,aie=function(e){e.prototype[Symbol.iterator]=function*(){for(let i=this.head;i;i=i.next)yield i.value}}),aie}var vKi=Zr;Zr.Node=_v;Zr.create=Zr;function Zr(e){var i=this;if(i instanceof Zr||(i=new Zr),i.tail=null,i.head=null,i.length=0,e&&typeof e.forEach=="function")e.forEach(function(o){i.push(o)});else if(arguments.length>0)for(var n=0,r=arguments.length;n1)n=i;else if(this.head)r=this.head.next,n=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var o=0;r!==null;o++)n=e(n,r.value,o),r=r.next;return n};Zr.prototype.reduceReverse=function(e,i){var n,r=this.tail;if(arguments.length>1)n=i;else if(this.tail)r=this.tail.prev,n=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(var o=this.length-1;r!==null;o--)n=e(n,r.value,o),r=r.prev;return n};Zr.prototype.toArray=function(){for(var e=new Array(this.length),i=0,n=this.head;n!==null;i++)e[i]=n.value,n=n.next;return e};Zr.prototype.toArrayReverse=function(){for(var e=new Array(this.length),i=0,n=this.tail;n!==null;i++)e[i]=n.value,n=n.prev;return e};Zr.prototype.slice=function(e,i){i=i||this.length,i<0&&(i+=this.length),e=e||0,e<0&&(e+=this.length);var n=new Zr;if(ithis.length&&(i=this.length);for(var r=0,o=this.head;o!==null&&rthis.length&&(i=this.length);for(var r=this.length,o=this.tail;o!==null&&r>i;r--)o=o.prev;for(;o!==null&&r>e;r--,o=o.prev)n.push(o.value);return n};Zr.prototype.splice=function(e,i,...n){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var r=0,o=this.head;o!==null&&r1;class wKi{constructor(i){if(typeof i=="number"&&(i={max:i}),i||(i={}),i.max&&(typeof i.max!="number"||i.max<0))throw new TypeError("max must be a non-negative number");this[vy]=i.max||1/0;const n=i.length||sie;if(this[BG]=typeof n!="function"?sie:n,this[XE]=i.stale||!1,i.maxAge&&typeof i.maxAge!="number")throw new TypeError("maxAge must be a number");this[ky]=i.maxAge||0,this[Zh]=i.dispose,this[YKe]=i.noDisposeOnSet||!1,this[lnt]=i.updateAgeOnGet||!1,this.reset()}set max(i){if(typeof i!="number"||i<0)throw new TypeError("max must be a non-negative number");this[vy]=i||1/0,Z9(this)}get max(){return this[vy]}set allowStale(i){this[XE]=!!i}get allowStale(){return this[XE]}set maxAge(i){if(typeof i!="number")throw new TypeError("maxAge must be a non-negative number");this[ky]=i,Z9(this)}get maxAge(){return this[ky]}set lengthCalculator(i){typeof i!="function"&&(i=sie),i!==this[BG]&&(this[BG]=i,this[Rh]=0,this[ra].forEach(n=>{n.length=this[BG](n.value,n.key),this[Rh]+=n.length})),Z9(this)}get lengthCalculator(){return this[BG]}get length(){return this[Rh]}get itemCount(){return this[ra].length}rforEach(i,n){n=n||this;for(let r=this[ra].tail;r!==null;){const o=r.prev;KKe(this,i,r,n),r=o}}forEach(i,n){n=n||this;for(let r=this[ra].head;r!==null;){const o=r.next;KKe(this,i,r,n),r=o}}keys(){return this[ra].toArray().map(i=>i.key)}values(){return this[ra].toArray().map(i=>i.value)}reset(){this[Zh]&&this[ra]&&this[ra].length&&this[ra].forEach(i=>this[Zh](i.key,i.value)),this[Lc]=new Map,this[ra]=new SKi,this[Rh]=0}dump(){return this[ra].map(i=>__(this,i)?!1:{k:i.key,v:i.value,e:i.now+(i.maxAge||0)}).toArray().filter(i=>i)}dumpLru(){return this[ra]}set(i,n,r){if(r=r||this[ky],r&&typeof r!="number")throw new TypeError("maxAge must be a number");const o=r?Date.now():0,l=this[BG](n,i);if(this[Lc].has(i)){if(l>this[vy])return yS(this,this[Lc].get(i)),!1;const f=this[Lc].get(i).value;return this[Zh]&&(this[YKe]||this[Zh](i,f.value)),f.now=o,f.maxAge=r,f.value=n,this[Rh]+=l-f.length,f.length=l,this.get(i),Z9(this),!0}const c=new TKi(i,n,l,o,r);return c.length>this[vy]?(this[Zh]&&this[Zh](i,n),!1):(this[Rh]+=c.length,this[ra].unshift(c),this[Lc].set(i,this[ra].head),Z9(this),!0)}has(i){if(!this[Lc].has(i))return!1;const n=this[Lc].get(i).value;return!__(this,n)}get(i){return Iie(this,i,!0)}peek(i){return Iie(this,i,!1)}pop(){const i=this[ra].tail;return i?(yS(this,i),i.value):null}del(i){yS(this,this[Lc].get(i))}load(i){this.reset();const n=Date.now();for(let r=i.length-1;r>=0;r--){const o=i[r],l=o.e||0;if(l===0)this.set(o.k,o.v);else{const c=l-n;c>0&&this.set(o.k,o.v,c)}}}prune(){this[Lc].forEach((i,n)=>Iie(this,n,!1))}}const Iie=(e,i,n)=>{const r=e[Lc].get(i);if(r){const o=r.value;if(__(e,o)){if(yS(e,r),!e[XE])return}else n&&(e[lnt]&&(r.value.now=Date.now()),e[ra].unshiftNode(r));return o.value}},__=(e,i)=>{if(!i||!i.maxAge&&!e[ky])return!1;const n=Date.now()-i.now;return i.maxAge?n>i.maxAge:e[ky]&&n>e[ky]},Z9=e=>{if(e[Rh]>e[vy])for(let i=e[ra].tail;e[Rh]>e[vy]&&i!==null;){const n=i.prev;yS(e,i),i=n}},yS=(e,i)=>{if(i){const n=i.value;e[Zh]&&e[Zh](n.key,n.value),e[Rh]-=n.length,e[Lc].delete(n.key),e[ra].removeNode(i)}};class TKi{constructor(i,n,r,o,l){this.key=i,this.value=n,this.length=r,this.now=o,this.maxAge=l||0}}const KKe=(e,i,n,r)=>{let o=n.value;__(e,o)&&(yS(e,n),e[XE]||(o=void 0)),o&&i.call(r,o.value,o.key,e)};var RKi=wKi;const VKi=Object.freeze({loose:!0}),EKi=Object.freeze({}),HKi=e=>e?typeof e!="object"?VKi:e:EKi;var Ode=HKi,Gae={exports:{}};const WKi="2.0.0",NKi=256,kKi=Number.MAX_SAFE_INTEGER||9007199254740991,XKi=16,xKi=["major","premajor","minor","preminor","patch","prepatch","prerelease"];var Lde={MAX_LENGTH:NKi,MAX_SAFE_COMPONENT_LENGTH:XKi,MAX_SAFE_INTEGER:kKi,RELEASE_TYPES:xKi,SEMVER_SPEC_VERSION:WKi,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2};const DKi=typeof process=="object"&&process.env&&{}.NODE_DEBUG&&/\bsemver\b/i.test({}.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};var UO=DKi;(function(e,i){const{MAX_SAFE_COMPONENT_LENGTH:n}=Lde,r=UO;i=e.exports={};const o=i.re=[],l=i.src=[],c=i.t={};let u=0;const f=(m,p,v)=>{const B=u++;r(m,B,p),c[m]=B,l[B]=p,o[B]=new RegExp(p,v?"g":void 0)};f("NUMERICIDENTIFIER","0|[1-9]\\d*"),f("NUMERICIDENTIFIERLOOSE","[0-9]+"),f("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),f("MAINVERSION",`(${l[c.NUMERICIDENTIFIER]})\\.(${l[c.NUMERICIDENTIFIER]})\\.(${l[c.NUMERICIDENTIFIER]})`),f("MAINVERSIONLOOSE",`(${l[c.NUMERICIDENTIFIERLOOSE]})\\.(${l[c.NUMERICIDENTIFIERLOOSE]})\\.(${l[c.NUMERICIDENTIFIERLOOSE]})`),f("PRERELEASEIDENTIFIER",`(?:${l[c.NUMERICIDENTIFIER]}|${l[c.NONNUMERICIDENTIFIER]})`),f("PRERELEASEIDENTIFIERLOOSE",`(?:${l[c.NUMERICIDENTIFIERLOOSE]}|${l[c.NONNUMERICIDENTIFIER]})`),f("PRERELEASE",`(?:-(${l[c.PRERELEASEIDENTIFIER]}(?:\\.${l[c.PRERELEASEIDENTIFIER]})*))`),f("PRERELEASELOOSE",`(?:-?(${l[c.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${l[c.PRERELEASEIDENTIFIERLOOSE]})*))`),f("BUILDIDENTIFIER","[0-9A-Za-z-]+"),f("BUILD",`(?:\\+(${l[c.BUILDIDENTIFIER]}(?:\\.${l[c.BUILDIDENTIFIER]})*))`),f("FULLPLAIN",`v?${l[c.MAINVERSION]}${l[c.PRERELEASE]}?${l[c.BUILD]}?`),f("FULL",`^${l[c.FULLPLAIN]}$`),f("LOOSEPLAIN",`[v=\\s]*${l[c.MAINVERSIONLOOSE]}${l[c.PRERELEASELOOSE]}?${l[c.BUILD]}?`),f("LOOSE",`^${l[c.LOOSEPLAIN]}$`),f("GTLT","((?:<|>)?=?)"),f("XRANGEIDENTIFIERLOOSE",`${l[c.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),f("XRANGEIDENTIFIER",`${l[c.NUMERICIDENTIFIER]}|x|X|\\*`),f("XRANGEPLAIN",`[v=\\s]*(${l[c.XRANGEIDENTIFIER]})(?:\\.(${l[c.XRANGEIDENTIFIER]})(?:\\.(${l[c.XRANGEIDENTIFIER]})(?:${l[c.PRERELEASE]})?${l[c.BUILD]}?)?)?`),f("XRANGEPLAINLOOSE",`[v=\\s]*(${l[c.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[c.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[c.XRANGEIDENTIFIERLOOSE]})(?:${l[c.PRERELEASELOOSE]})?${l[c.BUILD]}?)?)?`),f("XRANGE",`^${l[c.GTLT]}\\s*${l[c.XRANGEPLAIN]}$`),f("XRANGELOOSE",`^${l[c.GTLT]}\\s*${l[c.XRANGEPLAINLOOSE]}$`),f("COERCE",`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?(?:$|[^\\d])`),f("COERCERTL",l[c.COERCE],!0),f("LONETILDE","(?:~>?)"),f("TILDETRIM",`(\\s*)${l[c.LONETILDE]}\\s+`,!0),i.tildeTrimReplace="$1~",f("TILDE",`^${l[c.LONETILDE]}${l[c.XRANGEPLAIN]}$`),f("TILDELOOSE",`^${l[c.LONETILDE]}${l[c.XRANGEPLAINLOOSE]}$`),f("LONECARET","(?:\\^)"),f("CARETTRIM",`(\\s*)${l[c.LONECARET]}\\s+`,!0),i.caretTrimReplace="$1^",f("CARET",`^${l[c.LONECARET]}${l[c.XRANGEPLAIN]}$`),f("CARETLOOSE",`^${l[c.LONECARET]}${l[c.XRANGEPLAINLOOSE]}$`),f("COMPARATORLOOSE",`^${l[c.GTLT]}\\s*(${l[c.LOOSEPLAIN]})$|^$`),f("COMPARATOR",`^${l[c.GTLT]}\\s*(${l[c.FULLPLAIN]})$|^$`),f("COMPARATORTRIM",`(\\s*)${l[c.GTLT]}\\s*(${l[c.LOOSEPLAIN]}|${l[c.XRANGEPLAIN]})`,!0),i.comparatorTrimReplace="$1$2$3",f("HYPHENRANGE",`^\\s*(${l[c.XRANGEPLAIN]})\\s+-\\s+(${l[c.XRANGEPLAIN]})\\s*$`),f("HYPHENRANGELOOSE",`^\\s*(${l[c.XRANGEPLAINLOOSE]})\\s+-\\s+(${l[c.XRANGEPLAINLOOSE]})\\s*$`),f("STAR","(<|>)?=?\\s*\\*"),f("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),f("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(Gae,Gae.exports);var Jde=Gae.exports;const _Ke=/^[0-9]+$/,Cnt=(e,i)=>{const n=_Ke.test(e),r=_Ke.test(i);return n&&r&&(e=+e,i=+i),e===i?0:n&&!r?-1:r&&!n?1:eCnt(i,e);var FKi={compareIdentifiers:Cnt,rcompareIdentifiers:MKi};const eY=UO,{MAX_LENGTH:PKe,MAX_SAFE_INTEGER:tY}=Lde,{re:zKe,t:OKe}=Jde,YKi=Ode,{compareIdentifiers:GG}=FKi;let KKi=class Tu{constructor(i,n){if(n=YKi(n),i instanceof Tu){if(i.loose===!!n.loose&&i.includePrerelease===!!n.includePrerelease)return i;i=i.version}else if(typeof i!="string")throw new TypeError(`Invalid Version: ${i}`);if(i.length>PKe)throw new TypeError(`version is longer than ${PKe} characters`);eY("SemVer",i,n),this.options=n,this.loose=!!n.loose,this.includePrerelease=!!n.includePrerelease;const r=i.trim().match(n.loose?zKe[OKe.LOOSE]:zKe[OKe.FULL]);if(!r)throw new TypeError(`Invalid Version: ${i}`);if(this.raw=i,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>tY||this.major<0)throw new TypeError("Invalid major version");if(this.minor>tY||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>tY||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map(o=>{if(/^[0-9]+$/.test(o)){const l=+o;if(l>=0&&l=0;)typeof this.prerelease[o]=="number"&&(this.prerelease[o]++,o=-2);o===-1&&this.prerelease.push(0)}if(n){const o=Number(r)?1:0;GG(this.prerelease[0],n)===0?isNaN(this.prerelease[1])&&(this.prerelease=[n,o]):this.prerelease=[n,o]}break;default:throw new Error(`invalid increment argument: ${i}`)}return this.format(),this.raw=this.version,this}};var Ude=KKi;const LKe=Ude,_Ki=(e,i,n)=>new LKe(e,n).compare(new LKe(i,n));var g2=_Ki;const PKi=g2,zKi=(e,i,n)=>PKi(e,i,n)===0;var OKi=zKi;const LKi=g2,JKi=(e,i,n)=>LKi(e,i,n)!==0;var UKi=JKi;const QKi=g2,jKi=(e,i,n)=>QKi(e,i,n)>0;var $Ki=jKi;const qKi=g2,e3i=(e,i,n)=>qKi(e,i,n)>=0;var t3i=e3i;const i3i=g2,n3i=(e,i,n)=>i3i(e,i,n)<0;var r3i=n3i;const g3i=g2,o3i=(e,i,n)=>g3i(e,i,n)<=0;var a3i=o3i;const s3i=OKi,I3i=UKi,l3i=$Ki,C3i=t3i,c3i=r3i,A3i=a3i,u3i=(e,i,n,r)=>{switch(i){case"===":return typeof e=="object"&&(e=e.version),typeof n=="object"&&(n=n.version),e===n;case"!==":return typeof e=="object"&&(e=e.version),typeof n=="object"&&(n=n.version),e!==n;case"":case"=":case"==":return s3i(e,n,r);case"!=":return I3i(e,n,r);case">":return l3i(e,n,r);case">=":return C3i(e,n,r);case"<":return c3i(e,n,r);case"<=":return A3i(e,n,r);default:throw new TypeError(`Invalid operator: ${i}`)}};var d3i=u3i,lie,JKe;function h3i(){if(JKe)return lie;JKe=1;const e=Symbol("SemVer ANY");class i{static get ANY(){return e}constructor(p,v){if(v=n(v),p instanceof i){if(p.loose===!!v.loose)return p;p=p.value}c("comparator",p,v),this.options=v,this.loose=!!v.loose,this.parse(p),this.semver===e?this.value="":this.value=this.operator+this.semver.version,c("comp",this)}parse(p){const v=this.options.loose?r[o.COMPARATORLOOSE]:r[o.COMPARATOR],B=p.match(v);if(!B)throw new TypeError(`Invalid comparator: ${p}`);this.operator=B[1]!==void 0?B[1]:"",this.operator==="="&&(this.operator=""),B[2]?this.semver=new u(B[2],this.options.loose):this.semver=e}toString(){return this.value}test(p){if(c("Comparator.test",p,this.options.loose),this.semver===e||p===e)return!0;if(typeof p=="string")try{p=new u(p,this.options)}catch{return!1}return l(p,this.operator,this.semver,this.options)}intersects(p,v){if(!(p instanceof i))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new f(p.value,v).test(this.value):p.operator===""?p.value===""?!0:new f(this.value,v).test(p.semver):(v=n(v),v.includePrerelease&&(this.value==="<0.0.0-0"||p.value==="<0.0.0-0")||!v.includePrerelease&&(this.value.startsWith("<0.0.0")||p.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&p.operator.startsWith(">")||this.operator.startsWith("<")&&p.operator.startsWith("<")||this.semver.version===p.semver.version&&this.operator.includes("=")&&p.operator.includes("=")||l(this.semver,"<",p.semver,v)&&this.operator.startsWith(">")&&p.operator.startsWith("<")||l(this.semver,">",p.semver,v)&&this.operator.startsWith("<")&&p.operator.startsWith(">")))}}lie=i;const n=Ode,{re:r,t:o}=Jde,l=d3i,c=UO,u=Ude,f=cnt();return lie}var Cie,UKe;function cnt(){if(UKe)return Cie;UKe=1;class e{constructor(Ae,_){if(_=r(_),Ae instanceof e)return Ae.loose===!!_.loose&&Ae.includePrerelease===!!_.includePrerelease?Ae:new e(Ae.raw,_);if(Ae instanceof o)return this.raw=Ae.value,this.set=[[Ae]],this.format(),this;if(this.options=_,this.loose=!!_.loose,this.includePrerelease=!!_.includePrerelease,this.raw=Ae,this.set=Ae.split("||").map(de=>this.parseRange(de.trim())).filter(de=>de.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${Ae}`);if(this.set.length>1){const de=this.set[0];if(this.set=this.set.filter(Ze=>!T(Ze[0])),this.set.length===0)this.set=[de];else if(this.set.length>1){for(const Ze of this.set)if(Ze.length===1&&V(Ze[0])){this.set=[Ze];break}}}this.format()}format(){return this.range=this.set.map(Ae=>Ae.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(Ae){Ae=Ae.trim();const de=((this.options.includePrerelease&&B)|(this.options.loose&&G))+":"+Ae,Ze=n.get(de);if(Ze)return Ze;const me=this.options.loose,be=me?u[f.HYPHENRANGELOOSE]:u[f.HYPHENRANGE];Ae=Ae.replace(be,ee(this.options.includePrerelease)),l("hyphen replace",Ae),Ae=Ae.replace(u[f.COMPARATORTRIM],m),l("comparator trim",Ae),Ae=Ae.replace(u[f.TILDETRIM],p),Ae=Ae.replace(u[f.CARETTRIM],v),Ae=Ae.split(/\s+/).join(" ");let Ee=Ae.split(" ").map(rt=>W(rt,this.options)).join(" ").split(/\s+/).map(rt=>$(rt,this.options));me&&(Ee=Ee.filter(rt=>(l("loose invalid filter",rt,this.options),!!rt.match(u[f.COMPARATORLOOSE])))),l("range list",Ee);const Je=new Map,Ue=Ee.map(rt=>new o(rt,this.options));for(const rt of Ue){if(T(rt))return[rt];Je.set(rt.value,rt)}Je.size>1&&Je.has("")&&Je.delete("");const dt=[...Je.values()];return n.set(de,dt),dt}intersects(Ae,_){if(!(Ae instanceof e))throw new TypeError("a Range is required");return this.set.some(de=>E(de,_)&&Ae.set.some(Ze=>E(Ze,_)&&de.every(me=>Ze.every(be=>me.intersects(be,_)))))}test(Ae){if(!Ae)return!1;if(typeof Ae=="string")try{Ae=new c(Ae,this.options)}catch{return!1}for(let _=0;_ge.value==="<0.0.0-0",V=ge=>ge.value==="",E=(ge,Ae)=>{let _=!0;const de=ge.slice();let Ze=de.pop();for(;_&&de.length;)_=de.every(me=>Ze.intersects(me,Ae)),Ze=de.pop();return _},W=(ge,Ae)=>(l("comp",ge,Ae),ge=Y(ge,Ae),l("caret",ge),ge=k(ge,Ae),l("tildes",ge),ge=O(ge,Ae),l("xrange",ge),ge=X(ge,Ae),l("stars",ge),ge),x=ge=>!ge||ge.toLowerCase()==="x"||ge==="*",k=(ge,Ae)=>ge.trim().split(/\s+/).map(_=>F(_,Ae)).join(" "),F=(ge,Ae)=>{const _=Ae.loose?u[f.TILDELOOSE]:u[f.TILDE];return ge.replace(_,(de,Ze,me,be,Ee)=>{l("tilde",ge,de,Ze,me,be,Ee);let Je;return x(Ze)?Je="":x(me)?Je=`>=${Ze}.0.0 <${+Ze+1}.0.0-0`:x(be)?Je=`>=${Ze}.${me}.0 <${Ze}.${+me+1}.0-0`:Ee?(l("replaceTilde pr",Ee),Je=`>=${Ze}.${me}.${be}-${Ee} <${Ze}.${+me+1}.0-0`):Je=`>=${Ze}.${me}.${be} <${Ze}.${+me+1}.0-0`,l("tilde return",Je),Je})},Y=(ge,Ae)=>ge.trim().split(/\s+/).map(_=>L(_,Ae)).join(" "),L=(ge,Ae)=>{l("caret",ge,Ae);const _=Ae.loose?u[f.CARETLOOSE]:u[f.CARET],de=Ae.includePrerelease?"-0":"";return ge.replace(_,(Ze,me,be,Ee,Je)=>{l("caret",ge,Ze,me,be,Ee,Je);let Ue;return x(me)?Ue="":x(be)?Ue=`>=${me}.0.0${de} <${+me+1}.0.0-0`:x(Ee)?me==="0"?Ue=`>=${me}.${be}.0${de} <${me}.${+be+1}.0-0`:Ue=`>=${me}.${be}.0${de} <${+me+1}.0.0-0`:Je?(l("replaceCaret pr",Je),me==="0"?be==="0"?Ue=`>=${me}.${be}.${Ee}-${Je} <${me}.${be}.${+Ee+1}-0`:Ue=`>=${me}.${be}.${Ee}-${Je} <${me}.${+be+1}.0-0`:Ue=`>=${me}.${be}.${Ee}-${Je} <${+me+1}.0.0-0`):(l("no pr"),me==="0"?be==="0"?Ue=`>=${me}.${be}.${Ee}${de} <${me}.${be}.${+Ee+1}-0`:Ue=`>=${me}.${be}.${Ee}${de} <${me}.${+be+1}.0-0`:Ue=`>=${me}.${be}.${Ee} <${+me+1}.0.0-0`),l("caret return",Ue),Ue})},O=(ge,Ae)=>(l("replaceXRanges",ge,Ae),ge.split(/\s+/).map(_=>Q(_,Ae)).join(" ")),Q=(ge,Ae)=>{ge=ge.trim();const _=Ae.loose?u[f.XRANGELOOSE]:u[f.XRANGE];return ge.replace(_,(de,Ze,me,be,Ee,Je)=>{l("xRange",ge,de,Ze,me,be,Ee,Je);const Ue=x(me),dt=Ue||x(be),rt=dt||x(Ee),ke=rt;return Ze==="="&&ke&&(Ze=""),Je=Ae.includePrerelease?"-0":"",Ue?Ze===">"||Ze==="<"?de="<0.0.0-0":de="*":Ze&&ke?(dt&&(be=0),Ee=0,Ze===">"?(Ze=">=",dt?(me=+me+1,be=0,Ee=0):(be=+be+1,Ee=0)):Ze==="<="&&(Ze="<",dt?me=+me+1:be=+be+1),Ze==="<"&&(Je="-0"),de=`${Ze+me}.${be}.${Ee}${Je}`):dt?de=`>=${me}.0.0${Je} <${+me+1}.0.0-0`:rt&&(de=`>=${me}.${be}.0${Je} <${me}.${+be+1}.0-0`),l("xRange return",de),de})},X=(ge,Ae)=>(l("replaceStars",ge,Ae),ge.trim().replace(u[f.STAR],"")),$=(ge,Ae)=>(l("replaceGTE0",ge,Ae),ge.trim().replace(u[Ae.includePrerelease?f.GTE0PRE:f.GTE0],"")),ee=ge=>(Ae,_,de,Ze,me,be,Ee,Je,Ue,dt,rt,ke,ze)=>(x(de)?_="":x(Ze)?_=`>=${de}.0.0${ge?"-0":""}`:x(me)?_=`>=${de}.${Ze}.0${ge?"-0":""}`:be?_=`>=${_}`:_=`>=${_}${ge?"-0":""}`,x(Ue)?Je="":x(dt)?Je=`<${+Ue+1}.0.0-0`:x(rt)?Je=`<${Ue}.${+dt+1}.0-0`:ke?Je=`<=${Ue}.${dt}.${rt}-${ke}`:ge?Je=`<${Ue}.${dt}.${+rt+1}-0`:Je=`<=${Je}`,`${_} ${Je}`.trim()),ne=(ge,Ae,_)=>{for(let de=0;de0){const Ze=ge[de].semver;if(Ze.major===Ae.major&&Ze.minor===Ae.minor&&Ze.patch===Ae.patch)return!0}return!1}return!0};return Cie}const f3i=cnt(),m3i=(e,i,n)=>{try{i=new f3i(i,n)}catch{return!1}return i.test(e)};var p3i=m3i,Ant=bKi(p3i);function b3i(e,i,n){const r=e.open(i),o=1e4,l=250,{origin:c}=new URL(i);let u=~~(o/l);function f(p){p.source===r&&(u=0,e.removeEventListener("message",f,!1))}e.addEventListener("message",f,!1);function m(){u<=0||(r.postMessage(n,c),setTimeout(m,l),u-=1)}setTimeout(m,l)}var y3i=`.vega-embed { - position: relative; - display: inline-block; - box-sizing: border-box; -} -.vega-embed.has-actions { - padding-right: 38px; -} -.vega-embed details:not([open]) > :not(summary) { - display: none !important; -} -.vega-embed summary { - list-style: none; - position: absolute; - top: 0; - right: 0; - padding: 6px; - z-index: 1000; - background: white; - box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1); - color: #1b1e23; - border: 1px solid #aaa; - border-radius: 999px; - opacity: 0.2; - transition: opacity 0.4s ease-in; - cursor: pointer; - line-height: 0px; -} -.vega-embed summary::-webkit-details-marker { - display: none; -} -.vega-embed summary:active { - box-shadow: #aaa 0px 0px 0px 1px inset; -} -.vega-embed summary svg { - width: 14px; - height: 14px; -} -.vega-embed details[open] summary { - opacity: 0.7; -} -.vega-embed:hover summary, .vega-embed:focus-within summary { - opacity: 1 !important; - transition: opacity 0.2s ease; -} -.vega-embed .vega-actions { - position: absolute; - z-index: 1001; - top: 35px; - right: -9px; - display: flex; - flex-direction: column; - padding-bottom: 8px; - padding-top: 8px; - border-radius: 4px; - box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.2); - border: 1px solid #d9d9d9; - background: white; - animation-duration: 0.15s; - animation-name: scale-in; - animation-timing-function: cubic-bezier(0.2, 0, 0.13, 1.5); - text-align: left; -} -.vega-embed .vega-actions a { - padding: 8px 16px; - font-family: sans-serif; - font-size: 14px; - font-weight: 600; - white-space: nowrap; - color: #434a56; - text-decoration: none; -} -.vega-embed .vega-actions a:hover, .vega-embed .vega-actions a:focus { - background-color: #f7f7f9; - color: black; -} -.vega-embed .vega-actions::before, .vega-embed .vega-actions::after { - content: ""; - display: inline-block; - position: absolute; -} -.vega-embed .vega-actions::before { - left: auto; - right: 14px; - top: -16px; - border: 8px solid rgba(0, 0, 0, 0); - border-bottom-color: #d9d9d9; -} -.vega-embed .vega-actions::after { - left: auto; - right: 15px; - top: -14px; - border: 7px solid rgba(0, 0, 0, 0); - border-bottom-color: #fff; -} -.vega-embed .chart-wrapper.fit-x { - width: 100%; -} -.vega-embed .chart-wrapper.fit-y { - height: 100%; -} - -.vega-embed-wrapper { - max-width: 100%; - overflow: auto; - padding-right: 14px; -} - -@keyframes scale-in { - from { - opacity: 0; - transform: scale(0.6); - } - to { - opacity: 1; - transform: scale(1); - } -} -`;function unt(e,...i){for(const n of i)v3i(e,n);return e}function v3i(e,i){for(const n of Object.keys(i))xw(e,n,i[n],!0)}function QKe(e,i){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);i&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function Hp(e){for(var i=1;ie,"vega-lite":(e,i)=>AW.compile(e,{config:i}).spec},S3i=` - - - - -`,w3i="chart-wrapper";function T3i(e){return typeof e=="function"}function $Ke(e,i,n,r){const o=`${i}
`,l=`
${n}`,c=window.open("");c.document.write(o+e+l),c.document.title=`${gE[r]} JSON Source`}function R3i(e,i){if(e.$schema){const n=ont(e.$schema);i&&i!==n.library&&console.warn(`The given visualization spec is written in ${gE[n.library]}, but mode argument sets ${gE[i]??i}.`);const r=n.library;return Ant(P_[r],`^${n.version.slice(1)}`)||console.warn(`The input spec uses ${gE[r]} ${n.version}, but the current version of ${gE[r]} is v${P_[r]}.`),r}return"mark"in e||"encoding"in e||"layer"in e||"hconcat"in e||"vconcat"in e||"facet"in e||"repeat"in e?"vega-lite":"marks"in e||"signals"in e||"scales"in e||"axes"in e?"vega":i??"vega"}function V3i(e){return!!(e&&"load"in e)}function qKe(e){return V3i(e)?e:Uc.loader(e)}function E3i(e){const i=e.usermeta?.embedOptions??{};return fi(i.defaultStyle)&&(i.defaultStyle=!1),i}async function H3i(e,i,n={}){let r,o;fi(i)?(o=qKe(n.loader),r=JSON.parse(await o.load(i))):r=i;const l=E3i(r),c=l.loader;(!o||c)&&(o=qKe(n.loader??c));const u=await e3e(l,o),f=await e3e(n,o),m=Hp(Hp({},unt(f,u)),{},{config:Xw(f.config??{},u.config??{})});return await N3i(e,r,m,o)}async function e3e(e,i){const n=fi(e.config)?JSON.parse(await i.load(e.config)):e.config??{},r=fi(e.patch)?JSON.parse(await i.load(e.patch)):e.patch;return Hp(Hp(Hp({},e),r?{patch:r}:{}),n?{config:n}:{})}function W3i(e){const i=e.getRootNode?e.getRootNode():document;return i instanceof ShadowRoot?{root:i,rootContainer:i}:{root:document,rootContainer:document.head??document.body}}async function N3i(e,i,n={},r){const o=n.theme?Xw(iKi[n.theme],n.config??{}):n.config,l=a0(n.actions)?n.actions:unt({},Z3i,n.actions??{}),c=Hp(Hp({},B3i),n.i18n),u=n.renderer??"canvas",f=n.logLevel??Uc.Warn,m=n.downloadFileName??"visualization",p=typeof e=="string"?document.querySelector(e):e;if(!p)throw new Error(`${e} does not exist`);if(n.defaultStyle!==!1){const Y="vega-embed-style",{root:L,rootContainer:O}=W3i(p);if(!L.getElementById(Y)){const Q=document.createElement("style");Q.id=Y,Q.innerHTML=n.defaultStyle===void 0||n.defaultStyle===!0?y3i.toString():n.defaultStyle,O.appendChild(Q)}}const v=R3i(i,n.mode);let B=G3i[v](i,o);if(v==="vega-lite"&&B.$schema){const Y=ont(B.$schema);Ant(P_.vega,`^${Y.version.slice(1)}`)||console.warn(`The compiled spec uses Vega ${Y.version}, but current version is v${P_.vega}.`)}p.classList.add("vega-embed"),l&&p.classList.add("has-actions"),p.innerHTML="";let G=p;if(l){const Y=document.createElement("div");Y.classList.add(w3i),p.appendChild(Y),G=Y}const T=n.patch;if(T&&(B=T instanceof Function?T(B):JP(B,T,!0,!1).newDocument),n.formatLocale&&Uc.formatLocale(n.formatLocale),n.timeFormatLocale&&Uc.timeFormatLocale(n.timeFormatLocale),n.expressionFunctions)for(const Y in n.expressionFunctions){const L=n.expressionFunctions[Y];"fn"in L?Uc.expressionFunction(Y,L.fn,L.visitor):L instanceof Function&&Uc.expressionFunction(Y,L)}const{ast:V}=n,E=Uc.parse(B,v==="vega-lite"?{}:o,{ast:V}),W=new(n.viewClass||Uc.View)(E,Hp({loader:r,logLevel:f,renderer:u},V?{expr:Uc.expressionInterpreter??n.expr??CWi}:{}));if(W.addSignalListener("autosize",(Y,L)=>{const{type:O}=L;O=="fit-x"?(G.classList.add("fit-x"),G.classList.remove("fit-y")):O=="fit-y"?(G.classList.remove("fit-x"),G.classList.add("fit-y")):O=="fit"?G.classList.add("fit-x","fit-y"):G.classList.remove("fit-x","fit-y")}),n.tooltip!==!1){const Y=T3i(n.tooltip)?n.tooltip:new hKi(n.tooltip===!0?{}:n.tooltip).call;W.tooltip(Y)}let{hover:x}=n;if(x===void 0&&(x=v==="vega"),x){const{hoverSet:Y,updateSet:L}=typeof x=="boolean"?{}:x;W.hover(Y,L)}n&&(n.width!=null&&W.width(n.width),n.height!=null&&W.height(n.height),n.padding!=null&&W.padding(n.padding)),await W.initialize(G,n.bind).runAsync();let k;if(l!==!1){let Y=p;if(n.defaultStyle!==!1){const O=document.createElement("details");O.title=c.CLICK_TO_VIEW_ACTIONS,p.append(O),Y=O;const Q=document.createElement("summary");Q.innerHTML=S3i,O.append(Q),k=X=>{O.contains(X.target)||O.removeAttribute("open")},document.addEventListener("click",k)}const L=document.createElement("div");if(Y.append(L),L.classList.add("vega-actions"),l===!0||l.export!==!1){for(const O of["svg","png"])if(l===!0||l.export===!0||l.export[O]){const Q=c[`${O.toUpperCase()}_ACTION`],X=document.createElement("a"),$=vi(n.scaleFactor)?n.scaleFactor[O]:n.scaleFactor;X.text=Q,X.href="#",X.target="_blank",X.download=`${m}.${O}`,X.addEventListener("mousedown",async function(ee){ee.preventDefault();const ne=await W.toImageURL(O,$);this.href=ne}),L.append(X)}}if(l===!0||l.source!==!1){const O=document.createElement("a");O.text=c.SOURCE_ACTION,O.href="#",O.addEventListener("click",function(Q){$Ke(kee(i),n.sourceHeader??"",n.sourceFooter??"",v),Q.preventDefault()}),L.append(O)}if(v==="vega-lite"&&(l===!0||l.compiled!==!1)){const O=document.createElement("a");O.text=c.COMPILED_ACTION,O.href="#",O.addEventListener("click",function(Q){$Ke(kee(B),n.sourceHeader??"",n.sourceFooter??"","vega"),Q.preventDefault()}),L.append(O)}if(l===!0||l.editor!==!1){const O=n.editorUrl??"https://vega.github.io/editor/",Q=document.createElement("a");Q.text=c.EDITOR_ACTION,Q.href="#",Q.addEventListener("click",function(X){b3i(window,O,{config:o,mode:v,renderer:u,spec:kee(i)}),X.preventDefault()}),L.append(Q)}}function F(){k&&document.removeEventListener("click",k),W.finalize()}return{view:W,spec:i,vgSpec:B,finalize:F,embedOptions:n}}function k3i(e){return!!e&&{}.toString.call(e)==="[object Function]"}function X3i(e,i,n){n&&(k3i(n)?n(e.data(i)):e.change(i,Uc.changeset().remove(()=>!0).insert(n)))}function x3i(e,i){Object.keys(i).forEach(n=>{X3i(e,n,i[n])})}function dnt(e){const i=new Set;return e.forEach(n=>{Object.keys(n).forEach(r=>{i.add(r)})}),i}const hnt=()=>{};function cie(e,i){const n=Object.keys(i);return n.forEach(r=>{try{e.addSignalListener(r,i[r])}catch(o){console.warn("Cannot add invalid signal listener.",o)}}),n.length>0}function D3i(e,i){if(e===i)return!1;const n={width:!1,height:!1,isExpensive:!1},r=dnt([e,i]);return r.has("width")&&(!("width"in e)||!("width"in i)||e.width!==i.width)&&("width"in e&&typeof e.width=="number"?n.width=e.width:n.isExpensive=!0),r.has("height")&&(!("height"in e)||!("height"in i)||e.height!==i.height)&&("height"in e&&typeof e.height=="number"?n.height=e.height:n.isExpensive=!0),r.delete("width"),r.delete("height"),[...r].some(o=>!(o in e)||!(o in i)||!_qe(e[o],i[o]))&&(n.isExpensive=!0),n.width!==!1||n.height!==!1||n.isExpensive?n:!1}function t3e(e,i){const n=Object.keys(i);return n.forEach(r=>{try{e.removeSignalListener(r,i[r])}catch(o){console.warn("Cannot remove invalid signal listener.",o)}}),n.length>0}function Aie(e){const{spec:i,width:n,height:r}=e;return typeof n<"u"&&typeof r<"u"?{...i,width:n,height:r}:typeof n<"u"?{...i,width:n}:typeof r<"u"?{...i,height:r}:i}function oE(e,i,n){return i in e?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n,e}class fnt extends yi.PureComponent{constructor(){super(...arguments),oE(this,"containerRef",yi.createRef()),oE(this,"resultPromise",void 0),oE(this,"handleError",i=>{const{onError:n=hnt}=this.props;n(i,this.containerRef.current),console.warn(i)}),oE(this,"modifyView",i=>{this.resultPromise&&this.resultPromise.then(n=>(n&&i(n.view),!0)).catch(this.handleError)})}componentDidMount(){this.createView()}componentDidUpdate(i){const n=dnt([this.props,i]);if(n.delete("className"),n.delete("signalListeners"),n.delete("spec"),n.delete("style"),n.delete("width"),n.delete("height"),Array.from(n).some(r=>this.props[r]!==i[r]))this.clearView(),this.createView();else{const r=D3i(Aie(this.props),Aie(i)),{signalListeners:o}=this.props,{signalListeners:l}=i;if(r)if(r.isExpensive)this.clearView(),this.createView();else{const c=!Ige(o,l);this.modifyView(u=>{r.width!==!1&&u.width(r.width),r.height!==!1&&u.height(r.height),c&&(l&&t3e(u,l),o&&cie(u,o)),u.run()})}else Ige(o,l)||this.modifyView(c=>{l&&t3e(c,l),o&&cie(c,o),c.run()})}}componentWillUnmount(){this.clearView()}createView(){const{spec:i,onNewView:n,signalListeners:r={},width:o,height:l,...c}=this.props;if(this.containerRef.current){const u=Aie(this.props);this.resultPromise=H3i(this.containerRef.current,u,c).then(f=>{if(f){const{view:m}=f;cie(m,r)&&m.run()}return f}).catch(this.handleError),n&&this.modifyView(n)}}clearView(){return this.resultPromise&&this.resultPromise.then(i=>{i&&i.finalize()}).catch(this.handleError),this.resultPromise=void 0,this}render(){const{className:i,style:n}=this.props;return yi.createElement("div",{ref:this.containerRef,className:i,style:n})}}oE(fnt,"propTypes",{className:gDe.string,onError:gDe.func});function Sae(){return Sae=Object.assign||function(e){for(var i=1;i{this.update();const{onNewView:n=hnt}=this.props;n(i)})}componentDidMount(){this.update()}componentDidUpdate(i){Ige(this.props.data,i.data)||this.update()}update(){const{data:i}=this.props;this.vegaEmbed.current&&i&&Object.keys(i).length>0&&this.vegaEmbed.current.modifyView(n=>{x3i(n,i),n.resize().run()})}render(){const{data:i,...n}=this.props;return yi.createElement(fnt,Sae({ref:this.vegaEmbed},n,{onNewView:this.handleNewView}))}}wae(Qde,"defaultProps",{data:M3i});function Tae(){return Tae=Object.assign||function(e){for(var i=1;i{if(!e.current)return;const r=e.current;return r.api.subscribe("rangeSelect",(o,l)=>n(l.data)),()=>r.api.unsubscribe("rangeSelect")},[]),yi.createElement(yi.Fragment,null,yi.createElement(o0,{ref:e,spec:Y3i,experimental:{reactive:!0}}),yi.createElement("div",{style:{marginLeft:80}},yi.createElement(F3i,{spec:K3i,data:{table:i}})))}const P3i=["point","bar","line","area"],z3i=["linear","circular"],O3i=(e,i,n)=>({layout:i,arrangement:"vertical",centerRadius:.4,xDomain:{chromosome:"1"},style:{select:{color:"black",stroke:"black",strokeWidth:6,arrange:"behind",opacity:.1}},views:[{tracks:[{id:"widget-track",data:{url:"https://server.gosling-lang.org/api/v1/tileset_info/?d=cistrome-multivec",type:"multivec",row:"sample",column:"position",value:"peak",categories:Array.from(Array(6)).map((r,o)=>`sample ${o}`),binSize:n===0?1:n},mark:e,x:{field:"start",type:"genomic"},xe:{field:"end",type:"genomic"},row:{field:"sample",type:"nominal",legend:!1},y:{field:"peak",type:"quantitative",axis:"none"},color:{field:"sample",type:"nominal",legend:!0},tooltip:[{field:"start",type:"genomic",alt:"Start Position"},{field:"end",type:"genomic",alt:"End Position"},{field:"peak",type:"quantitative",alt:"Value",format:".2"},{field:"sample",type:"nominal",alt:"Sample"}],width:600,height:230}]}]});function L3i(){const e=Ot.useRef(null),[i,n]=Ot.useState("point"),[r,o]=Ot.useState("linear"),[l,c]=Ot.useState(8);return yi.createElement(yi.Fragment,null,yi.createElement("span",null,yi.createElement("div",{style:{marginTop:30,marginLeft:80}},"Bin Size: ",yi.createElement("input",{type:"range",min:0,max:32,step:4,value:l,className:"slider",id:"bin-slider",style:{width:100,display:"inline",margin:10},onChange:u=>c(+u.currentTarget.value)}),l===0?1:l)),yi.createElement("div",{style:{marginTop:30,marginLeft:80}},"Mark: ",yi.createElement("select",{name:"mark",onChange:u=>n(u.currentTarget.value)},P3i.map(u=>yi.createElement("option",{key:u,value:u},u)))),yi.createElement("div",{style:{marginTop:30,marginLeft:80}},"Layout: ",yi.createElement("select",{name:"layout",onChange:u=>o(u.currentTarget.value)},z3i.map(u=>yi.createElement("option",{key:u,value:u},u)))),yi.createElement(o0,{ref:e,spec:O3i(i,r,l),experimental:{reactive:!0}}))}const J3i=["chr1","chr2","chr3","chr4","chr5","chr6","chr7","chr8","chr9","chr10","chr11","chr12","chr13","chr14","chr15","chr16","chr17","chr18","chr19","chr20","chr21","chr22","chrX","chrY"];function U3i(){const e=Ot.useRef();return yi.createElement(yi.Fragment,null,yi.createElement("div",{style:{marginTop:30,marginLeft:80}},"Zoom To Chromosome: ",yi.createElement("select",{name:"Chromosome",onChange:i=>e.current?.api.zoomTo("navigation-track-id",i.currentTarget.value,0,1e3)},J3i.map(i=>yi.createElement("option",{key:i,value:i},i)))),yi.createElement("div",{style:{marginTop:30,marginLeft:80}},"Zoom To Gene: ",yi.createElement("button",{className:"mr-3 p-1 rounded bg-slate-200",onClick:()=>e.current?.api.zoomToGene("navigation-track-id","MYC",3e3,1e3)},"MYC"),yi.createElement("button",{className:"mr-3 p-1 rounded bg-slate-200",onClick:()=>e.current?.api.zoomToGene("navigation-track-id","CCNK",3e3,1e3)},"CCNK")),yi.createElement("div",{style:{marginTop:30,marginLeft:80}},yi.createElement("button",{className:"mr-3 p-1 rounded bg-slate-200",onClick:()=>e.current?.api.zoomToExtent("navigation-track-id",1e3)},"Zoom To Extent")),yi.createElement(o0,{ref:e,spec:{style:{outlineWidth:0},xDomain:{chromosome:"chr1"},spacing:0,tracks:[{id:"navigation-track-id",template:"gene",data:{url:"https://server.gosling-lang.org/api/v1/tileset_info/?d=gene-annotation",type:"beddb",genomicFields:[{index:1,name:"start"},{index:2,name:"end"}],valueFields:[{index:5,name:"strand",type:"nominal"},{index:3,name:"name",type:"nominal"}],exonIntervalFields:[{index:12,name:"start"},{index:13,name:"end"}]},encoding:{startPosition:{field:"start",axis:"none"},endPosition:{field:"end"},strandColor:{field:"strand",range:["gray"]},strandRow:{field:"strand"},opacity:{value:.4},geneHeight:{value:15},geneLabel:{field:"name"},geneLabelFontSize:{value:30},geneLabelColor:{field:"strand",range:["gray"]},geneLabelStroke:{value:"white"},geneLabelStrokeThickness:{value:4},geneLabelOpacity:{value:1},type:{field:"type"}},width:1e3,height:40},{data:{url:"https://server.gosling-lang.org/api/v1/tileset_info/?d=cistrome-multivec",type:"multivec",row:"sample",column:"position",value:"peak",categories:["sample 1","sample 2","sample 3","sample 4"]},mark:"area",x:{field:"position",type:"genomic"},y:{field:"peak",type:"quantitative",axis:"none"},color:{field:"sample",type:"nominal"},width:1e3,height:30},{alignment:"overlay",data:{url:"https://raw.githubusercontent.com/sehilyi/gemini-datasets/master/data/cytogenetic_band.csv",type:"csv",chromosomeField:"Chr.",genomicFields:["ISCN_start","ISCN_stop","Basepair_start","Basepair_stop"]},tracks:[{mark:"text",dataTransform:[{type:"filter",field:"Stain",oneOf:["acen-1","acen-2"],not:!0}],text:{field:"Band",type:"nominal"},color:{value:"black"},strokeWidth:{value:0},visibility:[{operation:"less-than",measure:"width",threshold:"|xe-x|",transitionPadding:10,target:"mark"}]},{mark:"rect",dataTransform:[{type:"filter",field:"Stain",oneOf:["acen-1","acen-2"],not:!0}],color:{field:"Density",type:"nominal",domain:["","25","50","75","100"],range:["white","#D9D9D9","#979797","#636363","black"]}},{mark:"rect",dataTransform:[{type:"filter",field:"Stain",oneOf:["gvar"]}],color:{value:"#A0A0F2"}},{mark:"triangleRight",dataTransform:[{type:"filter",field:"Stain",oneOf:["acen-1"]}],color:{value:"#B40101"}},{mark:"triangleLeft",dataTransform:[{type:"filter",field:"Stain",oneOf:["acen-2"]}],color:{value:"#B40101"}}],x:{field:"Basepair_start",type:"genomic",axis:"bottom"},xe:{field:"Basepair_stop",type:"genomic"},stroke:{value:"gray"},strokeWidth:{value:1},width:1e3,height:20}]},experimental:{reactive:!0}}))}function Q3i(){const e=Ot.useRef(),[i,n]=Ot.useState(),[r,o]=Ot.useState([]);return Ot.useEffect(()=>{if(!e.current)return;const l=e.current;return l.api.subscribe("click",(c,u)=>{const{genomicPosition:f}=u;n(`${f.chromosome}:${f.position}`),o(u.data)}),l.api.subscribe("rangeSelect",(c,u)=>{if(!u||!u.genomicRange)n("N/A"),o([]);else{const{genomicRange:f}=u;f.length===2&&n(`${f[0].chromosome}:${f[0].position}-${f[1].chromosome}:${f[1].position}`),o(u.data.length>10?u.data.slice(0,10):u.data)}}),()=>{l.api.unsubscribe("click"),l.api.unsubscribe("rangeSelect")}},[]),yi.createElement("div",null,yi.createElement("div",{style:{marginTop:30,marginLeft:80}},"Selected Position: ",i||"N/A"),yi.createElement(o0,{ref:e,spec:{style:{outlineWidth:0,select:{color:"grey"},mouseOver:{stroke:"black",strokeWidth:1}},xDomain:{chromosome:"1",interval:[136750,139450]},spacing:0,tracks:[{title:"Click or mouse drag w/ ALT",experimental:{mouseEvents:!0},data:{type:"bam",url:"https://somatic-browser-test.s3.amazonaws.com/SRR7890905_GAPFI2USVS21.bam",indexUrl:"https://somatic-browser-test.s3.amazonaws.com/SRR7890905_GAPFI2USVS21.bam.bai"},mark:"rect",dataTransform:[{type:"displace",method:"pile",boundingBox:{startField:"start",endField:"end",padding:5,isPaddingBP:!0},newField:"pileup-row"}],x:{field:"start",type:"genomic"},xe:{field:"end",type:"genomic"},color:{value:"lightgrey"},tooltip:[{field:"start",type:"genomic"},{field:"end",type:"genomic"},{field:"strand",type:"nominal"}],row:{field:"pileup-row",type:"nominal",padding:.2},width:500,height:400}]},experimental:{reactive:!0}}),r.length===0?null:yi.createElement("div",{className:"mx-[60px]"},yi.createElement("table",{className:"table-fixed border-collapse border border-slate-400"},yi.createElement("thead",{className:"capitalize"},yi.createElement("tr",{className:"border border-slate-300 bg-slate-100"},Object.keys(r[0]).map(l=>yi.createElement("th",{className:"px-1",key:l},l)))),yi.createElement("tbody",null,r.map(l=>yi.createElement("tr",{className:"border border-slate-300",key:JSON.stringify(l)},Object.entries(l).map(c=>yi.createElement("td",{className:"px-1",key:c[0]},c[1]))))))))}const B9={data:{type:"csv",url:"https://s3.amazonaws.com/gosling-lang.org/data/IslandViewer/NC_004631.1_islands.csv",chromosomeField:"Accession",genomicFields:["Island start","Island end"]},x:{field:"Island start",type:"genomic"},xe:{field:"Island end",type:"genomic"}},Rae="detailedView",i3e=200,j3i=.5,mnt=120,xI=mnt/6,$3i={title:"IslandViewer 4 (Bertelli et al. 2017)",subtitle:"Salmonella enterica subsp. enterica serovar Typhi Ty2, complete genome.",description:"Reimplementation of https://www.pathogenomics.sfu.ca/islandviewer/accession/NC_004631.1/",assembly:[["NC_004631.1",4791961]],spacing:50,views:[{layout:"circular",static:!0,alignment:"overlay",spacing:.1,tracks:[{data:{url:"https://s3.amazonaws.com/gosling-lang.org/data/IslandViewer/NC_004631.1_GCcontent.csv",type:"csv",separator:" ",genomicFields:["Position"]},y:{field:"GCcontent",type:"quantitative",range:[-250,0],axis:"none"},mark:"line",size:{value:.5},x:{field:"Position",type:"genomic"},color:{value:"black"}},{style:{outlineWidth:1,outline:"black"},data:{url:"https://s3.amazonaws.com/gosling-lang.org/data/IslandViewer/NC_004631.1_annotations.csv",type:"csv",genomicFields:["Gene start"]},dataTransform:[{type:"displace",method:"pile",boundingBox:{padding:3.5,startField:"Gene start",endField:"Gene start"},newField:"row"}],y:{field:"row",type:"nominal",flip:!0},mark:"point",x:{field:"Gene start",type:"genomic"},size:{value:3},color:{field:"Type",type:"nominal",domain:["Victors","BLAST","RGI","PAG"],range:["#460B80","#A684EA","#FF9CC1","#FF9CC1"]}},{...B9,row:{field:"Method",domain:["Predicted by at least one method","IslandPath-DIMOB","SIGI-HMM","IslandPick","Islander"],type:"nominal"},color:{field:"Method",type:"nominal",domain:["Predicted by at least one method","IslandPath-DIMOB","SIGI-HMM","IslandPick","Islander"],range:["#B22222","#4169E1","#FF8C00","#008001","#40E0D0"]},mark:"rect"},{mark:"brush",x:{linkingId:"detail"}}],width:i3e*2,centerRadius:j3i},{layout:"linear",xDomain:{chromosome:"NC_004631.1",interval:[1e6,15e5]},linkingId:"detail",alignment:"overlay",tracks:[{data:{url:"https://s3.amazonaws.com/gosling-lang.org/data/IslandViewer/NC_004631.1_genes.csv",type:"csv",chromosomeField:"Accession",genomicFields:["Gene start","Gene end"]},id:Rae,x:{field:"Gene start",type:"genomic"},xe:{field:"Gene end",type:"genomic"},y:{value:5.5*xI},size:{value:xI},mark:"rect",dataTransform:[{type:"filter",field:"Strand",oneOf:["1"]}],color:{value:"#E9967A"},tooltip:[{field:"Gene name",type:"nominal",alt:"Name"}]},{data:{url:"https://s3.amazonaws.com/gosling-lang.org/data/IslandViewer/NC_004631.1_genes.csv",type:"csv",chromosomeField:"Accession",genomicFields:["Gene start","Gene end"]},x:{field:"Gene start",type:"genomic"},xe:{field:"Gene end",type:"genomic"},y:{value:4.5*xI},size:{value:xI},mark:"rect",dataTransform:[{type:"filter",field:"Strand",oneOf:["-1"]}],color:{value:"#87976E"},tooltip:[{field:"Gene name",type:"nominal",alt:"Name"}]},{data:{url:"https://s3.amazonaws.com/gosling-lang.org/data/IslandViewer/NC_004631.1_genes.csv",type:"csv",chromosomeField:"Accession",genomicFields:["Gene start","Gene end"]},x:{field:"Gene start",type:"genomic"},xe:{field:"Gene end",type:"genomic"},y:{value:5.5*xI},mark:"text",text:{field:"Gene name",type:"nominal"},dataTransform:[{type:"filter",field:"Strand",oneOf:["1"]}],color:{value:"#ffffff"},visibility:[{operation:"less-than",measure:"width",threshold:"|xe-x|",transitionPadding:10,target:"mark"}]},{data:{url:"https://s3.amazonaws.com/gosling-lang.org/data/IslandViewer/NC_004631.1_genes.csv",type:"csv",chromosomeField:"Accession",genomicFields:["Gene start","Gene end"]},x:{field:"Gene start",type:"genomic"},xe:{field:"Gene end",type:"genomic"},y:{value:4.5*xI},mark:"text",text:{field:"Gene name",type:"nominal"},dataTransform:[{type:"filter",field:"Strand",oneOf:["-1"]}],color:{value:"#ffffff"},visibility:[{operation:"less-than",measure:"width",threshold:"|xe-x|",transitionPadding:10,target:"mark"}]},{...B9,mark:"rect",dataTransform:[{type:"filter",field:"Method",oneOf:["IslandPath-DIMOB"]}],y:{value:.5*xI},size:{value:xI},color:{value:"#4169E1"}},{...B9,mark:"rect",dataTransform:[{type:"filter",field:"Method",oneOf:["SIGI-HMM"]}],y:{value:1.5*xI},size:{value:xI},color:{value:"#FF8C00"}},{...B9,mark:"rect",dataTransform:[{type:"filter",field:"Method",oneOf:["IslandPick"]}],y:{value:2.5*xI},size:{value:xI},color:{value:"#008001"}},{...B9,mark:"rect",dataTransform:[{type:"filter",field:"Method",oneOf:["Islander"]}],y:{value:3.5*xI},size:{value:xI},color:{value:"#40E0D0"}},{data:{url:"https://s3.amazonaws.com/gosling-lang.org/data/IslandViewer/NC_004631.1_annotations.csv",type:"csv",genomicFields:["Gene start"]},dataTransform:[{type:"displace",method:"pile",boundingBox:{padding:3.5,startField:"Gene start",endField:"Gene start"},newField:"row"}],row:{field:"row",type:"nominal"},mark:"point",x:{field:"Gene start",type:"genomic"},size:{value:3},color:{field:"Type",type:"nominal",domain:["Victors","BLAST","RGI","PAG"],range:["#460B80","#A684EA","#FF9CC1","#FF9CC1"]},tooltip:[{field:"Type",type:"nominal",alt:"Name"}]}],width:i3e*2,height:mnt}]};function q3i(){const e=Ot.useRef(null),[i,n]=Ot.useState([]);Ot.useEffect(()=>{if(!e.current)return;const o=e.current;return o.api.subscribe("rawData",(l,c)=>{const u=o.hgApi.api.getLocation(Rae).xDomain;if(c.data.length>0&&c.id===Rae&&"Accnum"in c.data[0]){const m=c.data.filter(p=>p["Gene start"]>u[0]&&p["Gene start"]u[0]&&p["Gene end"]B.findIndex(G=>G["Gene name"]===p["Gene name"])===v);n(m)}}),()=>{o.api.unsubscribe("rawData")}},[]);const r=["Prediction Method","Gene name","Accnum","Product"];return yi.createElement("div",{style:{display:"flex"}},yi.createElement("div",{style:{display:"inline-block"}},yi.createElement(o0,{padding:0,ref:e,spec:$3i,experimental:{reactive:!0}})),i.length===0?null:yi.createElement("div",{style:{height:window.innerHeight,overflowY:"scroll",display:"inline-block",flexGrow:1,marginLeft:"10px"}},yi.createElement("table",{className:"table-fixed border-collapse border border-slate-400"},yi.createElement("thead",{className:"capitalize"},yi.createElement("tr",{className:"border border-slate-300 bg-slate-100"},r.map(o=>yi.createElement("th",{className:"px-1",key:o},o)))),yi.createElement("tbody",null,i.map(o=>yi.createElement("tr",{className:"border border-slate-300",key:o["Gene name"]},r.map(l=>{let c="";return l==="Prediction Method"?o.Islands.length>0?o.Annotations.length>0?c=o.Islands+"/"+o.Annotations:c=o.Islands:o.Annotations.length>0&&(c=o.Annotations):c=o[l],yi.createElement("td",{className:"px-1",key:l},c)})))))))}const uie=300,n3e=300;function e_i(){const[e,i]=Ot.useState([]),[n,r]=Ot.useState(1),[o,l]=Ot.useState(n3e),c=Ot.useRef(null),u="goslingVis",f=Ot.useCallback(v=>{let B=v.data("leaves").slice();B.sort((G,T)=>G.x-T.x),i(B.map(G=>G.id)),r(Math.max(...B.map(G=>G.distance)))},[]);Ot.useEffect(()=>{if(!c.current)return;c.current.api.subscribe("rawData",()=>{const B=c.current.api.getTracks();l(B[B.map(G=>G.id).indexOf(u)].shape.height)});const v=c.current;return()=>{v.api.unsubscribe("rawData")}},[]);const m=Ot.useMemo(()=>({title:"GeneSpy + iTol",subtitle:"Genomic neighborhood visualization with aligned phylogenetic tree",description:"Idea: https://doi.org/10.1093/bioinformatics/bty459",assembly:[["",11e3]],static:!0,views:[{alignment:"overlay",data:{url:"https://s3.amazonaws.com/gosling-lang.org/data/GeneSpy/gene_spy_example.csv",type:"csv",genomicFields:["Gene start","Gene end"]},dataTransform:[{type:"genomicLength",startField:"Gene start",endField:"Gene end",newField:"Gene length"}],color:{field:"type",type:"nominal",domain:["anchor","conserved","disrupted"],range:["red","gray","yellow"]},id:u,row:{field:"Accession",type:"nominal",domain:e},tracks:[{dataTransform:[{type:"filter",field:"Strand",oneOf:["+"]}],mark:"triangleRight",style:{align:"right"},x:{field:"Gene start",type:"genomic",axis:"none"},xe:{field:"Gene end",type:"genomic"}},{dataTransform:[{type:"filter",field:"Strand",oneOf:["-"]}],mark:"triangleLeft",style:{align:"left"},x:{field:"Gene start",type:"genomic"},xe:{field:"Gene end",type:"genomic"}}],height:n3e}]}),[e]),p=Ot.useMemo(()=>({$schema:"https://vega.github.io/schema/vega/v5.json",description:"An example of Cartesian layouts for a node-link diagram of hierarchical data.",width:uie,height:o,padding:0,data:[{name:"tree",url:"https://s3.amazonaws.com/gosling-lang.org/data/GeneSpy/gene_spy_tree.json",transform:[{type:"stratify",key:"id",parentKey:"parent"},{type:"tree",method:"cluster",field:{field:"distance"},sort:{field:"value",order:"ascending"},size:[{signal:"height"},{signal:"width"}],separation:!1,as:["y","x","depth","children"]},{type:"formula",expr:"width * (datum.distance/"+n+")",as:"x"}]},{name:"leaves",source:"tree",transform:[{type:"filter",expr:"!datum.children"}]},{name:"links",source:"tree",transform:[{type:"treelinks"},{type:"linkpath",orient:"horizontal",shape:"orthogonal"}]}],marks:[{type:"path",from:{data:"links"},encode:{update:{path:{field:"path"},stroke:{value:"#000"}}}},{type:"rule",from:{data:"leaves"},encode:{update:{x:{field:"x"},y:{field:"y"},x2:{value:uie},y2:{field:"y"},stroke:{value:"#eee"}}}},{type:"text",from:{data:"leaves"},encode:{enter:{text:{field:"name"},fontSize:{value:9},baseline:{value:"middle"}},update:{x:{value:uie},y:{field:"y"},dx:{signal:"datum.children ? -7 : 7"},align:"left"}}}]}),[n,o]);return yi.createElement(yi.Fragment,null,yi.createElement("div",{style:{display:"inline-block"}},yi.createElement(Qde,{spec:p,onNewView:f,actions:!1})),yi.createElement("div",{style:{display:"inline-block"}},yi.createElement(o0,{ref:c,padding:0,spec:m,experimental:{reactive:!0}})))}const die={Simple:Ot.createElement(EAi,null),"Widget (Encoding)":Ot.createElement(L3i,null),"Widget (Navigation)":Ot.createElement(U3i,null),"Mouse Events":Ot.createElement(Q3i,null),"Vega-Lite":Ot.createElement(_3i,null),IslandViewer:Ot.createElement(q3i,null),GeneSpy:Ot.createElement(e_i,null)};function t_i(){return Ot.createElement("div",{className:"flex flex-row h-full w-full"},Ot.createElement("div",{className:"flex-none border-r-[1px]"},Ot.createElement("div",{className:"font-bold font-lg m-3"},"Examples"),Ot.createElement("ol",{className:"list-decimal list-inside divide-y divide-solid"},Object.entries(die).map(e=>Ot.createElement("li",{className:"p-3",key:e[0]},Ot.createElement(CLt,{className:"hover:underline",to:`/${e[0].replace(" ","_")}`},e[0]))))),Ot.createElement("div",{className:""},Ot.createElement(nLt,null,Ot.createElement(Cne,{path:"/",element:die.Simple}),Object.entries(die).map(e=>Ot.createElement(Cne,{key:e[0],path:`/${e[0].replace(" ","_")}`,element:e[1]})))))}const i_i=hie.createRoot(document.getElementById("root"));i_i.render(yi.createElement(sLt,null,yi.createElement(t_i,null)));export{dLt as _,Qg as c,Al as g}; diff --git a/assets/index-84a3106f.js b/assets/index-84a3106f.js new file mode 100644 index 0000000..d55a241 --- /dev/null +++ b/assets/index-84a3106f.js @@ -0,0 +1,2270 @@ +(function(){const g=document.createElement("link").relList;if(g&&g.supports&&g.supports("modulepreload"))return;for(const I of document.querySelectorAll('link[rel="modulepreload"]'))n(I);new MutationObserver(I=>{for(const r of I)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function i(I){const r={};return I.integrity&&(r.integrity=I.integrity),I.referrerPolicy&&(r.referrerPolicy=I.referrerPolicy),I.crossOrigin==="use-credentials"?r.credentials="include":I.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function n(I){if(I.ep)return;I.ep=!0;const r=i(I);fetch(I.href,r)}})();var un=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ba(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Bst(e){if(e.__esModule)return e;var g=e.default;if(typeof g=="function"){var i=function n(){if(this instanceof n){var I=[null];I.push.apply(I,arguments);var r=Function.bind.apply(g,I);return new r}return g.apply(this,arguments)};i.prototype=g.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var I=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(i,n,I.get?I:{enumerable:!0,get:function(){return e[n]}})}),i}var hKe={exports:{}},Dg={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var rT=Symbol.for("react.element"),wst=Symbol.for("react.portal"),Sst=Symbol.for("react.fragment"),Rst=Symbol.for("react.strict_mode"),Vst=Symbol.for("react.profiler"),Wst=Symbol.for("react.provider"),Xst=Symbol.for("react.context"),Tst=Symbol.for("react.forward_ref"),Hst=Symbol.for("react.suspense"),Nst=Symbol.for("react.memo"),kst=Symbol.for("react.lazy"),Tme=Symbol.iterator;function Yst(e){return e===null||typeof e!="object"?null:(e=Tme&&e[Tme]||e["@@iterator"],typeof e=="function"?e:null)}var fKe={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},mKe=Object.assign,pKe={};function d1(e,g,i){this.props=e,this.context=g,this.refs=pKe,this.updater=i||fKe}d1.prototype.isReactComponent={};d1.prototype.setState=function(e,g){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,g,"setState")};d1.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function bKe(){}bKe.prototype=d1.prototype;function _Ie(e,g,i){this.props=e,this.context=g,this.refs=pKe,this.updater=i||fKe}var OIe=_Ie.prototype=new bKe;OIe.constructor=_Ie;mKe(OIe,d1.prototype);OIe.isPureReactComponent=!0;var Hme=Array.isArray,yKe=Object.prototype.hasOwnProperty,JIe={current:null},ZKe={key:!0,ref:!0,__self:!0,__source:!0};function GKe(e,g,i){var n,I={},r=null,o=null;if(g!=null)for(n in g.ref!==void 0&&(o=g.ref),g.key!==void 0&&(r=""+g.key),g)yKe.call(g,n)&&!ZKe.hasOwnProperty(n)&&(I[n]=g[n]);var C=arguments.length-2;if(C===1)I.children=i;else if(1>>1,Q=x[$];if(0>>1;$I(ee,F))IeI(fe,ee)?(x[$]=fe,x[Ie]=F,$=Ie):(x[$]=ee,x[j]=F,$=j);else if(IeI(fe,F))x[$]=fe,x[Ie]=F,$=Ie;else break e}}return M}function I(x,M){var F=x.sortIndex-M.sortIndex;return F!==0?F:x.id-M.id}if(typeof performance=="object"&&typeof performance.now=="function"){var r=performance;e.unstable_now=function(){return r.now()}}else{var o=Date,C=o.now();e.unstable_now=function(){return o.now()-C}}var a=[],A=[],s=1,l=null,c=3,u=!1,d=!1,h=!1,f=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,b=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function p(x){for(var M=i(A);M!==null;){if(M.callback===null)n(A);else if(M.startTime<=x)n(A),M.sortIndex=M.expirationTime,g(a,M);else break;M=i(A)}}function y(x){if(h=!1,p(x),!d)if(i(a)!==null)d=!0,N(Z);else{var M=i(A);M!==null&&Y(y,M.startTime-x)}}function Z(x,M){d=!1,h&&(h=!1,m(B),B=-1),u=!0;var F=c;try{for(p(M),l=i(a);l!==null&&(!(l.expirationTime>M)||x&&!w());){var $=l.callback;if(typeof $=="function"){l.callback=null,c=l.priorityLevel;var Q=$(l.expirationTime<=M);M=e.unstable_now(),typeof Q=="function"?l.callback=Q:l===i(a)&&n(a),p(M)}else n(a);l=i(a)}if(l!==null)var U=!0;else{var j=i(A);j!==null&&Y(y,j.startTime-M),U=!1}return U}finally{l=null,c=F,u=!1}}var v=!1,G=null,B=-1,S=5,R=-1;function w(){return!(e.unstable_now()-Rx||125$?(x.sortIndex=F,g(A,x),i(a)===null&&x===i(A)&&(h?(m(B),B=-1):h=!0,Y(y,F-$))):(x.sortIndex=Q,g(a,x),d||u||(d=!0,N(Z))),x},e.unstable_shouldYield=w,e.unstable_wrapCallback=function(x){var M=c;return function(){var F=c;c=M;try{return x.apply(this,arguments)}finally{c=F}}}})(wKe);BKe.exports=wKe;var Dst=BKe.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var SKe=Ue,ma=Dst;function ht(e){for(var g="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),C$=Object.prototype.hasOwnProperty,Mst=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,kme={},Yme={};function zst(e){return C$.call(Yme,e)?!0:C$.call(kme,e)?!1:Mst.test(e)?Yme[e]=!0:(kme[e]=!0,!1)}function Pst(e,g,i,n){if(i!==null&&i.type===0)return!1;switch(typeof g){case"function":case"symbol":return!0;case"boolean":return n?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function _st(e,g,i,n){if(g===null||typeof g>"u"||Pst(e,g,i,n))return!0;if(n)return!1;if(i!==null)switch(i.type){case 3:return!g;case 4:return g===!1;case 5:return isNaN(g);case 6:return isNaN(g)||1>g}return!1}function Oo(e,g,i,n,I,r,o){this.acceptsBooleans=g===2||g===3||g===4,this.attributeName=n,this.attributeNamespace=I,this.mustUseProperty=i,this.propertyName=e,this.type=g,this.sanitizeURL=r,this.removeEmptyString=o}var mr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){mr[e]=new Oo(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var g=e[0];mr[g]=new Oo(g,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){mr[e]=new Oo(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){mr[e]=new Oo(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){mr[e]=new Oo(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){mr[e]=new Oo(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){mr[e]=new Oo(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){mr[e]=new Oo(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){mr[e]=new Oo(e,5,!1,e.toLowerCase(),null,!1,!1)});var UIe=/[\-:]([a-z])/g;function QIe(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var g=e.replace(UIe,QIe);mr[g]=new Oo(g,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var g=e.replace(UIe,QIe);mr[g]=new Oo(g,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var g=e.replace(UIe,QIe);mr[g]=new Oo(g,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){mr[e]=new Oo(e,1,!1,e.toLowerCase(),null,!1,!1)});mr.xlinkHref=new Oo("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){mr[e]=new Oo(e,1,!1,e.toLowerCase(),null,!0,!0)});function jIe(e,g,i,n){var I=mr.hasOwnProperty(g)?mr[g]:null;(I!==null?I.type!==0:n||!(2C||I[o]!==r[C]){var a=` +`+I[o].replace(" at new "," at ");return e.displayName&&a.includes("")&&(a=a.replace("",e.displayName)),a}while(1<=o&&0<=C);break}}}finally{zJ=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?cV(e):""}function Ost(e){switch(e.tag){case 5:return cV(e.type);case 16:return cV("Lazy");case 13:return cV("Suspense");case 19:return cV("SuspenseList");case 0:case 2:case 15:return e=PJ(e.type,!1),e;case 11:return e=PJ(e.type.render,!1),e;case 1:return e=PJ(e.type,!0),e;default:return""}}function l$(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case $G:return"Fragment";case jG:return"Portal";case a$:return"Profiler";case $Ie:return"StrictMode";case s$:return"Suspense";case A$:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case WKe:return(e.displayName||"Context")+".Consumer";case VKe:return(e._context.displayName||"Context")+".Provider";case qIe:var g=e.render;return e=e.displayName,e||(e=g.displayName||g.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ere:return g=e.displayName||null,g!==null?g:l$(e.type)||"Memo";case Lh:g=e._payload,e=e._init;try{return l$(e(g))}catch{}}return null}function Jst(e){var g=e.type;switch(e.tag){case 24:return"Cache";case 9:return(g.displayName||"Context")+".Consumer";case 10:return(g._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=g.render,e=e.displayName||e.name||"",g.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return g;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return l$(g);case 8:return g===$Ie?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof g=="function")return g.displayName||g.name||null;if(typeof g=="string")return g}return null}function Am(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function TKe(e){var g=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(g==="checkbox"||g==="radio")}function Lst(e){var g=TKe(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,g),n=""+e[g];if(!e.hasOwnProperty(g)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var I=i.get,r=i.set;return Object.defineProperty(e,g,{configurable:!0,get:function(){return I.call(this)},set:function(o){n=""+o,r.call(this,o)}}),Object.defineProperty(e,g,{enumerable:i.enumerable}),{getValue:function(){return n},setValue:function(o){n=""+o},stopTracking:function(){e._valueTracker=null,delete e[g]}}}}function GN(e){e._valueTracker||(e._valueTracker=Lst(e))}function HKe(e){if(!e)return!1;var g=e._valueTracker;if(!g)return!0;var i=g.getValue(),n="";return e&&(n=TKe(e)?e.checked?"true":"false":e.value),e=n,e!==i?(g.setValue(e),!0):!1}function ax(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function c$(e,g){var i=g.checked;return Vn({},g,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function xme(e,g){var i=g.defaultValue==null?"":g.defaultValue,n=g.checked!=null?g.checked:g.defaultChecked;i=Am(g.value!=null?g.value:i),e._wrapperState={initialChecked:n,initialValue:i,controlled:g.type==="checkbox"||g.type==="radio"?g.checked!=null:g.value!=null}}function NKe(e,g){g=g.checked,g!=null&&jIe(e,"checked",g,!1)}function u$(e,g){NKe(e,g);var i=Am(g.value),n=g.type;if(i!=null)n==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(n==="submit"||n==="reset"){e.removeAttribute("value");return}g.hasOwnProperty("value")?d$(e,g.type,i):g.hasOwnProperty("defaultValue")&&d$(e,g.type,Am(g.defaultValue)),g.checked==null&&g.defaultChecked!=null&&(e.defaultChecked=!!g.defaultChecked)}function Fme(e,g,i){if(g.hasOwnProperty("value")||g.hasOwnProperty("defaultValue")){var n=g.type;if(!(n!=="submit"&&n!=="reset"||g.value!==void 0&&g.value!==null))return;g=""+e._wrapperState.initialValue,i||g===e.value||(e.value=g),e.defaultValue=g}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function d$(e,g,i){(g!=="number"||ax(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var uV=Array.isArray;function Rv(e,g,i,n){if(e=e.options,g){g={};for(var I=0;I"+g.valueOf().toString()+"",g=vN.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;g.firstChild;)e.appendChild(g.firstChild)}});function UW(e,g){if(g){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=g;return}}e.textContent=g}var w2={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Ust=["Webkit","ms","Moz","O"];Object.keys(w2).forEach(function(e){Ust.forEach(function(g){g=g+e.charAt(0).toUpperCase()+e.substring(1),w2[g]=w2[e]})});function xKe(e,g,i){return g==null||typeof g=="boolean"||g===""?"":i||typeof g!="number"||g===0||w2.hasOwnProperty(e)&&w2[e]?(""+g).trim():g+"px"}function FKe(e,g){e=e.style;for(var i in g)if(g.hasOwnProperty(i)){var n=i.indexOf("--")===0,I=xKe(i,g[i],n);i==="float"&&(i="cssFloat"),n?e.setProperty(i,I):e[i]=I}}var Qst=Vn({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function m$(e,g){if(g){if(Qst[e]&&(g.children!=null||g.dangerouslySetInnerHTML!=null))throw Error(ht(137,e));if(g.dangerouslySetInnerHTML!=null){if(g.children!=null)throw Error(ht(60));if(typeof g.dangerouslySetInnerHTML!="object"||!("__html"in g.dangerouslySetInnerHTML))throw Error(ht(61))}if(g.style!=null&&typeof g.style!="object")throw Error(ht(62))}}function p$(e,g){if(e.indexOf("-")===-1)return typeof g.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var b$=null;function tre(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var y$=null,Vv=null,Wv=null;function Mme(e){if(e=aT(e)){if(typeof y$!="function")throw Error(ht(280));var g=e.stateNode;g&&(g=Y3(g),y$(e.stateNode,e.type,g))}}function EKe(e){Vv?Wv?Wv.push(e):Wv=[e]:Vv=e}function DKe(){if(Vv){var e=Vv,g=Wv;if(Wv=Vv=null,Mme(e),g)for(e=0;e>>=0,e===0?32:31-(oAt(e)/CAt|0)|0}var BN=64,wN=4194304;function dV(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function cx(e,g){var i=e.pendingLanes;if(i===0)return 0;var n=0,I=e.suspendedLanes,r=e.pingedLanes,o=i&268435455;if(o!==0){var C=o&~I;C!==0?n=dV(C):(r&=o,r!==0&&(n=dV(r)))}else o=i&~I,o!==0?n=dV(o):r!==0&&(n=dV(r));if(n===0)return 0;if(g!==0&&g!==n&&!(g&I)&&(I=n&-n,r=g&-g,I>=r||I===16&&(r&4194240)!==0))return g;if(n&4&&(n|=i&16),g=e.entangledLanes,g!==0)for(e=e.entanglements,g&=n;0i;i++)g.push(e);return g}function oT(e,g,i){e.pendingLanes|=g,g!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,g=31-WA(g),e[g]=i}function lAt(e,g){var i=e.pendingLanes&~g;e.pendingLanes=g,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=g,e.mutableReadLanes&=g,e.entangledLanes&=g,g=e.entanglements;var n=e.eventTimes;for(e=e.expirationTimes;0=R2),jme=String.fromCharCode(32),$me=!1;function o5e(e,g){switch(e){case"keyup":return EAt.indexOf(g.keyCode)!==-1;case"keydown":return g.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function C5e(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var qG=!1;function MAt(e,g){switch(e){case"compositionend":return C5e(g);case"keypress":return g.which!==32?null:($me=!0,jme);case"textInput":return e=g.data,e===jme&&$me?null:e;default:return null}}function zAt(e,g){if(qG)return e==="compositionend"||!are&&o5e(e,g)?(e=I5e(),bK=rre=hf=null,qG=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(g.ctrlKey||g.altKey||g.metaKey)||g.ctrlKey&&g.altKey){if(g.char&&1=g)return{node:i,offset:g-e};e=n}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=gpe(i)}}function l5e(e,g){return e&&g?e===g?!0:e&&e.nodeType===3?!1:g&&g.nodeType===3?l5e(e,g.parentNode):"contains"in e?e.contains(g):e.compareDocumentPosition?!!(e.compareDocumentPosition(g)&16):!1:!1}function c5e(){for(var e=window,g=ax();g instanceof e.HTMLIFrameElement;){try{var i=typeof g.contentWindow.location.href=="string"}catch{i=!1}if(i)e=g.contentWindow;else break;g=ax(e.document)}return g}function sre(e){var g=e&&e.nodeName&&e.nodeName.toLowerCase();return g&&(g==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||g==="textarea"||e.contentEditable==="true")}function $At(e){var g=c5e(),i=e.focusedElem,n=e.selectionRange;if(g!==i&&i&&i.ownerDocument&&l5e(i.ownerDocument.documentElement,i)){if(n!==null&&sre(i)){if(g=n.start,e=n.end,e===void 0&&(e=g),"selectionStart"in i)i.selectionStart=g,i.selectionEnd=Math.min(e,i.value.length);else if(e=(g=i.ownerDocument||document)&&g.defaultView||window,e.getSelection){e=e.getSelection();var I=i.textContent.length,r=Math.min(n.start,I);n=n.end===void 0?r:Math.min(n.end,I),!e.extend&&r>n&&(I=n,n=r,r=I),I=ipe(i,r);var o=ipe(i,n);I&&o&&(e.rangeCount!==1||e.anchorNode!==I.node||e.anchorOffset!==I.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(g=g.createRange(),g.setStart(I.node,I.offset),e.removeAllRanges(),r>n?(e.addRange(g),e.extend(o.node,o.offset)):(g.setEnd(o.node,o.offset),e.addRange(g)))}}for(g=[],e=i;e=e.parentNode;)e.nodeType===1&&g.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,ev=null,S$=null,W2=null,R$=!1;function npe(e,g,i){var n=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;R$||ev==null||ev!==ax(n)||(n=ev,"selectionStart"in n&&sre(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}),W2&&tX(W2,n)||(W2=n,n=hx(S$,"onSelect"),0iv||(e.current=N$[iv],N$[iv]=null,iv--)}function Pi(e,g){iv++,N$[iv]=e.current,e.current=g}var lm={},qr=Nm(lm),vC=Nm(!1),lb=lm;function vB(e,g){var i=e.type.contextTypes;if(!i)return lm;var n=e.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===g)return n.__reactInternalMemoizedMaskedChildContext;var I={},r;for(r in i)I[r]=g[r];return n&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=g,e.__reactInternalMemoizedMaskedChildContext=I),I}function BC(e){return e=e.childContextTypes,e!=null}function mx(){rn(vC),rn(qr)}function Ape(e,g,i){if(qr.current!==lm)throw Error(ht(168));Pi(qr,g),Pi(vC,i)}function Z5e(e,g,i){var n=e.stateNode;if(g=g.childContextTypes,typeof n.getChildContext!="function")return i;n=n.getChildContext();for(var I in n)if(!(I in g))throw Error(ht(108,Jst(e)||"Unknown",I));return Vn({},i,n)}function px(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||lm,lb=qr.current,Pi(qr,e),Pi(vC,vC.current),!0}function lpe(e,g,i){var n=e.stateNode;if(!n)throw Error(ht(169));i?(e=Z5e(e,g,lb),n.__reactInternalMemoizedMergedChildContext=e,rn(vC),rn(qr),Pi(qr,e)):rn(vC),Pi(vC,i)}var Hu=null,K3=!1,nL=!1;function G5e(e){Hu===null?Hu=[e]:Hu.push(e)}function slt(e){K3=!0,G5e(e)}function km(){if(!nL&&Hu!==null){nL=!0;var e=0,g=yi;try{var i=Hu;for(yi=1;e>=o,I-=o,Ou=1<<32-WA(g)+I|i<B?(S=G,G=null):S=G.sibling;var R=c(m,G,p[B],y);if(R===null){G===null&&(G=S);break}e&&G&&R.alternate===null&&g(m,G),b=r(R,b,B),v===null?Z=R:v.sibling=R,v=R,G=S}if(B===p.length)return i(m,G),cn&&Op(m,B),Z;if(G===null){for(;BB?(S=G,G=null):S=G.sibling;var w=c(m,G,R.value,y);if(w===null){G===null&&(G=S);break}e&&G&&w.alternate===null&&g(m,G),b=r(w,b,B),v===null?Z=w:v.sibling=w,v=w,G=S}if(R.done)return i(m,G),cn&&Op(m,B),Z;if(G===null){for(;!R.done;B++,R=p.next())R=l(m,R.value,y),R!==null&&(b=r(R,b,B),v===null?Z=R:v.sibling=R,v=R);return cn&&Op(m,B),Z}for(G=n(m,G);!R.done;B++,R=p.next())R=u(G,m,B,R.value,y),R!==null&&(e&&R.alternate!==null&&G.delete(R.key===null?B:R.key),b=r(R,b,B),v===null?Z=R:v.sibling=R,v=R);return e&&G.forEach(function(T){return g(m,T)}),cn&&Op(m,B),Z}function f(m,b,p,y){if(typeof p=="object"&&p!==null&&p.type===$G&&p.key===null&&(p=p.props.children),typeof p=="object"&&p!==null){switch(p.$$typeof){case ZN:e:{for(var Z=p.key,v=b;v!==null;){if(v.key===Z){if(Z=p.type,Z===$G){if(v.tag===7){i(m,v.sibling),b=I(v,p.props.children),b.return=m,m=b;break e}}else if(v.elementType===Z||typeof Z=="object"&&Z!==null&&Z.$$typeof===Lh&&ppe(Z)===v.type){i(m,v.sibling),b=I(v,p.props),b.ref=DS(m,v,p),b.return=m,m=b;break e}i(m,v);break}else g(m,v);v=v.sibling}p.type===$G?(b=F0(p.props.children,m.mode,y,p.key),b.return=m,m=b):(y=RK(p.type,p.key,p.props,null,m.mode,y),y.ref=DS(m,b,p),y.return=m,m=y)}return o(m);case jG:e:{for(v=p.key;b!==null;){if(b.key===v)if(b.tag===4&&b.stateNode.containerInfo===p.containerInfo&&b.stateNode.implementation===p.implementation){i(m,b.sibling),b=I(b,p.children||[]),b.return=m,m=b;break e}else{i(m,b);break}else g(m,b);b=b.sibling}b=lL(p,m.mode,y),b.return=m,m=b}return o(m);case Lh:return v=p._init,f(m,b,v(p._payload),y)}if(uV(p))return d(m,b,p,y);if(YS(p))return h(m,b,p,y);HN(m,p)}return typeof p=="string"&&p!==""||typeof p=="number"?(p=""+p,b!==null&&b.tag===6?(i(m,b.sibling),b=I(b,p),b.return=m,m=b):(i(m,b),b=AL(p,m.mode,y),b.return=m,m=b),o(m)):i(m,b)}return f}var wB=X5e(!0),T5e=X5e(!1),sT={},oc=Nm(sT),IX=Nm(sT),rX=Nm(sT);function m0(e){if(e===sT)throw Error(ht(174));return e}function pre(e,g){switch(Pi(rX,g),Pi(IX,e),Pi(oc,sT),e=g.nodeType,e){case 9:case 11:g=(g=g.documentElement)?g.namespaceURI:f$(null,"");break;default:e=e===8?g.parentNode:g,g=e.namespaceURI||null,e=e.tagName,g=f$(g,e)}rn(oc),Pi(oc,g)}function SB(){rn(oc),rn(IX),rn(rX)}function H5e(e){m0(rX.current);var g=m0(oc.current),i=f$(g,e.type);g!==i&&(Pi(IX,e),Pi(oc,i))}function bre(e){IX.current===e&&(rn(oc),rn(IX))}var Gn=Nm(0);function Bx(e){for(var g=e;g!==null;){if(g.tag===13){var i=g.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||i.data==="$?"||i.data==="$!"))return g}else if(g.tag===19&&g.memoizedProps.revealOrder!==void 0){if(g.flags&128)return g}else if(g.child!==null){g.child.return=g,g=g.child;continue}if(g===e)break;for(;g.sibling===null;){if(g.return===null||g.return===e)return null;g=g.return}g.sibling.return=g.return,g=g.sibling}return null}var IL=[];function yre(){for(var e=0;ei?i:4,e(!0);var n=rL.transition;rL.transition={};try{e(!1),g()}finally{yi=i,rL.transition=n}}function U5e(){return ls().memoizedState}function ult(e,g,i){var n=Pf(e);if(i={lane:n,action:i,hasEagerState:!1,eagerState:null,next:null},Q5e(e))j5e(g,i);else if(i=S5e(e,g,i,n),i!==null){var I=No();XA(i,e,n,I),$5e(i,g,n)}}function dlt(e,g,i){var n=Pf(e),I={lane:n,action:i,hasEagerState:!1,eagerState:null,next:null};if(Q5e(e))j5e(g,I);else{var r=e.alternate;if(e.lanes===0&&(r===null||r.lanes===0)&&(r=g.lastRenderedReducer,r!==null))try{var o=g.lastRenderedState,C=r(o,i);if(I.hasEagerState=!0,I.eagerState=C,MA(C,o)){var a=g.interleaved;a===null?(I.next=I,fre(g)):(I.next=a.next,a.next=I),g.interleaved=I;return}}catch{}finally{}i=S5e(e,g,I,n),i!==null&&(I=No(),XA(i,e,n,I),$5e(i,g,n))}}function Q5e(e){var g=e.alternate;return e===Sn||g!==null&&g===Sn}function j5e(e,g){X2=wx=!0;var i=e.pending;i===null?g.next=g:(g.next=i.next,i.next=g),e.pending=g}function $5e(e,g,i){if(i&4194240){var n=g.lanes;n&=e.pendingLanes,i|=n,g.lanes=i,ire(e,i)}}var Sx={readContext:As,useCallback:wr,useContext:wr,useEffect:wr,useImperativeHandle:wr,useInsertionEffect:wr,useLayoutEffect:wr,useMemo:wr,useReducer:wr,useRef:wr,useState:wr,useDebugValue:wr,useDeferredValue:wr,useTransition:wr,useMutableSource:wr,useSyncExternalStore:wr,useId:wr,unstable_isNewReconciler:!1},hlt={readContext:As,useCallback:function(e,g){return Rl().memoizedState=[e,g===void 0?null:g],e},useContext:As,useEffect:ype,useImperativeHandle:function(e,g,i){return i=i!=null?i.concat([e]):null,vK(4194308,4,P5e.bind(null,g,e),i)},useLayoutEffect:function(e,g){return vK(4194308,4,e,g)},useInsertionEffect:function(e,g){return vK(4,2,e,g)},useMemo:function(e,g){var i=Rl();return g=g===void 0?null:g,e=e(),i.memoizedState=[e,g],e},useReducer:function(e,g,i){var n=Rl();return g=i!==void 0?i(g):g,n.memoizedState=n.baseState=g,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:g},n.queue=e,e=e.dispatch=ult.bind(null,Sn,e),[n.memoizedState,e]},useRef:function(e){var g=Rl();return e={current:e},g.memoizedState=e},useState:bpe,useDebugValue:wre,useDeferredValue:function(e){return Rl().memoizedState=e},useTransition:function(){var e=bpe(!1),g=e[0];return e=clt.bind(null,e[1]),Rl().memoizedState=e,[g,e]},useMutableSource:function(){},useSyncExternalStore:function(e,g,i){var n=Sn,I=Rl();if(cn){if(i===void 0)throw Error(ht(407));i=i()}else{if(i=g(),PI===null)throw Error(ht(349));ub&30||Y5e(n,g,i)}I.memoizedState=i;var r={value:i,getSnapshot:g};return I.queue=r,ype(x5e.bind(null,n,r,e),[e]),n.flags|=2048,aX(9,K5e.bind(null,n,r,i,g),void 0,null),i},useId:function(){var e=Rl(),g=PI.identifierPrefix;if(cn){var i=Ju,n=Ou;i=(n&~(1<<32-WA(n)-1)).toString(32)+i,g=":"+g+"R"+i,i=oX++,0<\/script>",e=e.removeChild(e.firstChild)):typeof n.is=="string"?e=o.createElement(i,{is:n.is}):(e=o.createElement(i),i==="select"&&(o=e,n.multiple?o.multiple=!0:n.size&&(o.size=n.size))):e=o.createElementNS(e,i),e[kl]=g,e[nX]=n,oxe(e,g,!1,!1),g.stateNode=e;e:{switch(o=p$(i,n),i){case"dialog":$i("cancel",e),$i("close",e),I=n;break;case"iframe":case"object":case"embed":$i("load",e),I=n;break;case"video":case"audio":for(I=0;IVB&&(g.flags|=128,n=!0,MS(r,!1),g.lanes=4194304)}else{if(!n)if(e=Bx(o),e!==null){if(g.flags|=128,n=!0,i=e.updateQueue,i!==null&&(g.updateQueue=i,g.flags|=4),MS(r,!0),r.tail===null&&r.tailMode==="hidden"&&!o.alternate&&!cn)return Sr(g),null}else 2*jn()-r.renderingStartTime>VB&&i!==1073741824&&(g.flags|=128,n=!0,MS(r,!1),g.lanes=4194304);r.isBackwards?(o.sibling=g.child,g.child=o):(i=r.last,i!==null?i.sibling=o:g.child=o,r.last=o)}return r.tail!==null?(g=r.tail,r.rendering=g,r.tail=g.sibling,r.renderingStartTime=jn(),g.sibling=null,i=Gn.current,Pi(Gn,n?i&1|2:i&1),g):(Sr(g),null);case 22:case 23:return Tre(),n=g.memoizedState!==null,e!==null&&e.memoizedState!==null!==n&&(g.flags|=8192),n&&g.mode&1?jC&1073741824&&(Sr(g),g.subtreeFlags&6&&(g.flags|=8192)):Sr(g),null;case 24:return null;case 25:return null}throw Error(ht(156,g.tag))}function vlt(e,g){switch(lre(g),g.tag){case 1:return BC(g.type)&&mx(),e=g.flags,e&65536?(g.flags=e&-65537|128,g):null;case 3:return SB(),rn(vC),rn(qr),yre(),e=g.flags,e&65536&&!(e&128)?(g.flags=e&-65537|128,g):null;case 5:return bre(g),null;case 13:if(rn(Gn),e=g.memoizedState,e!==null&&e.dehydrated!==null){if(g.alternate===null)throw Error(ht(340));BB()}return e=g.flags,e&65536?(g.flags=e&-65537|128,g):null;case 19:return rn(Gn),null;case 4:return SB(),null;case 10:return hre(g.type._context),null;case 22:case 23:return Tre(),null;case 24:return null;default:return null}}var kN=!1,Mr=!1,Blt=typeof WeakSet=="function"?WeakSet:Set,xt=null;function ov(e,g){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(n){kn(e,g,n)}else i.current=null}function O$(e,g,i){try{i()}catch(n){kn(e,g,n)}}var Wpe=!1;function wlt(e,g){if(V$=ux,e=c5e(),sre(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var n=i.getSelection&&i.getSelection();if(n&&n.rangeCount!==0){i=n.anchorNode;var I=n.anchorOffset,r=n.focusNode;n=n.focusOffset;try{i.nodeType,r.nodeType}catch{i=null;break e}var o=0,C=-1,a=-1,A=0,s=0,l=e,c=null;t:for(;;){for(var u;l!==i||I!==0&&l.nodeType!==3||(C=o+I),l!==r||n!==0&&l.nodeType!==3||(a=o+n),l.nodeType===3&&(o+=l.nodeValue.length),(u=l.firstChild)!==null;)c=l,l=u;for(;;){if(l===e)break t;if(c===i&&++A===I&&(C=o),c===r&&++s===n&&(a=o),(u=l.nextSibling)!==null)break;l=c,c=l.parentNode}l=u}i=C===-1||a===-1?null:{start:C,end:a}}else i=null}i=i||{start:0,end:0}}else i=null;for(W$={focusedElem:e,selectionRange:i},ux=!1,xt=g;xt!==null;)if(g=xt,e=g.child,(g.subtreeFlags&1028)!==0&&e!==null)e.return=g,xt=e;else for(;xt!==null;){g=xt;try{var d=g.alternate;if(g.flags&1024)switch(g.tag){case 0:case 11:case 15:break;case 1:if(d!==null){var h=d.memoizedProps,f=d.memoizedState,m=g.stateNode,b=m.getSnapshotBeforeUpdate(g.elementType===g.type?h:gA(g.type,h),f);m.__reactInternalSnapshotBeforeUpdate=b}break;case 3:var p=g.stateNode.containerInfo;p.nodeType===1?p.textContent="":p.nodeType===9&&p.documentElement&&p.removeChild(p.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(ht(163))}}catch(y){kn(g,g.return,y)}if(e=g.sibling,e!==null){e.return=g.return,xt=e;break}xt=g.return}return d=Wpe,Wpe=!1,d}function T2(e,g,i){var n=g.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var I=n=n.next;do{if((I.tag&e)===e){var r=I.destroy;I.destroy=void 0,r!==void 0&&O$(g,i,r)}I=I.next}while(I!==n)}}function E3(e,g){if(g=g.updateQueue,g=g!==null?g.lastEffect:null,g!==null){var i=g=g.next;do{if((i.tag&e)===e){var n=i.create;i.destroy=n()}i=i.next}while(i!==g)}}function J$(e){var g=e.ref;if(g!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof g=="function"?g(e):g.current=e}}function sxe(e){var g=e.alternate;g!==null&&(e.alternate=null,sxe(g)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(g=e.stateNode,g!==null&&(delete g[kl],delete g[nX],delete g[H$],delete g[Clt],delete g[alt])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Axe(e){return e.tag===5||e.tag===3||e.tag===4}function Xpe(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Axe(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function L$(e,g,i){var n=e.tag;if(n===5||n===6)e=e.stateNode,g?i.nodeType===8?i.parentNode.insertBefore(e,g):i.insertBefore(e,g):(i.nodeType===8?(g=i.parentNode,g.insertBefore(e,i)):(g=i,g.appendChild(e)),i=i._reactRootContainer,i!=null||g.onclick!==null||(g.onclick=fx));else if(n!==4&&(e=e.child,e!==null))for(L$(e,g,i),e=e.sibling;e!==null;)L$(e,g,i),e=e.sibling}function U$(e,g,i){var n=e.tag;if(n===5||n===6)e=e.stateNode,g?i.insertBefore(e,g):i.appendChild(e);else if(n!==4&&(e=e.child,e!==null))for(U$(e,g,i),e=e.sibling;e!==null;)U$(e,g,i),e=e.sibling}var Ir=null,IA=!1;function bh(e,g,i){for(i=i.child;i!==null;)lxe(e,g,i),i=i.sibling}function lxe(e,g,i){if(rc&&typeof rc.onCommitFiberUnmount=="function")try{rc.onCommitFiberUnmount(T3,i)}catch{}switch(i.tag){case 5:Mr||ov(i,g);case 6:var n=Ir,I=IA;Ir=null,bh(e,g,i),Ir=n,IA=I,Ir!==null&&(IA?(e=Ir,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):Ir.removeChild(i.stateNode));break;case 18:Ir!==null&&(IA?(e=Ir,i=i.stateNode,e.nodeType===8?iL(e.parentNode,i):e.nodeType===1&&iL(e,i),qW(e)):iL(Ir,i.stateNode));break;case 4:n=Ir,I=IA,Ir=i.stateNode.containerInfo,IA=!0,bh(e,g,i),Ir=n,IA=I;break;case 0:case 11:case 14:case 15:if(!Mr&&(n=i.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){I=n=n.next;do{var r=I,o=r.destroy;r=r.tag,o!==void 0&&(r&2||r&4)&&O$(i,g,o),I=I.next}while(I!==n)}bh(e,g,i);break;case 1:if(!Mr&&(ov(i,g),n=i.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=i.memoizedProps,n.state=i.memoizedState,n.componentWillUnmount()}catch(C){kn(i,g,C)}bh(e,g,i);break;case 21:bh(e,g,i);break;case 22:i.mode&1?(Mr=(n=Mr)||i.memoizedState!==null,bh(e,g,i),Mr=n):bh(e,g,i);break;default:bh(e,g,i)}}function Tpe(e){var g=e.updateQueue;if(g!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Blt),g.forEach(function(n){var I=klt.bind(null,e,n);i.has(n)||(i.add(n),n.then(I,I))})}}function Vs(e,g){var i=g.deletions;if(i!==null)for(var n=0;nI&&(I=o),n&=~r}if(n=I,n=jn()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*Rlt(n/1960))-n,10e?16:e,ff===null)var n=!1;else{if(e=ff,ff=null,Wx=0,ni&6)throw Error(ht(331));var I=ni;for(ni|=4,xt=e.current;xt!==null;){var r=xt,o=r.child;if(xt.flags&16){var C=r.deletions;if(C!==null){for(var a=0;ajn()-Wre?x0(e,0):Vre|=i),wC(e,g)}function bxe(e,g){g===0&&(e.mode&1?(g=wN,wN<<=1,!(wN&130023424)&&(wN=4194304)):g=1);var i=No();e=Rd(e,g),e!==null&&(oT(e,g,i),wC(e,i))}function Nlt(e){var g=e.memoizedState,i=0;g!==null&&(i=g.retryLane),bxe(e,i)}function klt(e,g){var i=0;switch(e.tag){case 13:var n=e.stateNode,I=e.memoizedState;I!==null&&(i=I.retryLane);break;case 19:n=e.stateNode;break;default:throw Error(ht(314))}n!==null&&n.delete(g),bxe(e,i)}var yxe;yxe=function(e,g,i){if(e!==null)if(e.memoizedProps!==g.pendingProps||vC.current)bC=!0;else{if(!(e.lanes&i)&&!(g.flags&128))return bC=!1,Zlt(e,g,i);bC=!!(e.flags&131072)}else bC=!1,cn&&g.flags&1048576&&v5e(g,yx,g.index);switch(g.lanes=0,g.tag){case 2:var n=g.type;BK(e,g),e=g.pendingProps;var I=vB(g,qr.current);Tv(g,i),I=Gre(null,g,n,e,I,i);var r=vre();return g.flags|=1,typeof I=="object"&&I!==null&&typeof I.render=="function"&&I.$$typeof===void 0?(g.tag=1,g.memoizedState=null,g.updateQueue=null,BC(n)?(r=!0,px(g)):r=!1,g.memoizedState=I.state!==null&&I.state!==void 0?I.state:null,mre(g),I.updater=x3,g.stateNode=I,I._reactInternals=g,F$(g,n,e,i),g=M$(null,g,n,!0,r,i)):(g.tag=0,cn&&r&&Are(g),uo(null,g,I,i),g=g.child),g;case 16:n=g.elementType;e:{switch(BK(e,g),e=g.pendingProps,I=n._init,n=I(n._payload),g.type=n,I=g.tag=Klt(n),e=gA(n,e),I){case 0:g=D$(null,g,n,e,i);break e;case 1:g=Spe(null,g,n,e,i);break e;case 11:g=Bpe(null,g,n,e,i);break e;case 14:g=wpe(null,g,n,gA(n.type,e),i);break e}throw Error(ht(306,n,""))}return g;case 0:return n=g.type,I=g.pendingProps,I=g.elementType===n?I:gA(n,I),D$(e,g,n,I,i);case 1:return n=g.type,I=g.pendingProps,I=g.elementType===n?I:gA(n,I),Spe(e,g,n,I,i);case 3:e:{if(nxe(g),e===null)throw Error(ht(387));n=g.pendingProps,r=g.memoizedState,I=r.element,R5e(e,g),vx(g,n,null,i);var o=g.memoizedState;if(n=o.element,r.isDehydrated)if(r={element:n,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},g.updateQueue.baseState=r,g.memoizedState=r,g.flags&256){I=RB(Error(ht(423)),g),g=Rpe(e,g,n,i,I);break e}else if(n!==I){I=RB(Error(ht(424)),g),g=Rpe(e,g,n,i,I);break e}else for(aa=Df(g.stateNode.containerInfo.firstChild),ua=g,cn=!0,oA=null,i=T5e(g,null,n,i),g.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(BB(),n===I){g=Vd(e,g,i);break e}uo(e,g,n,i)}g=g.child}return g;case 5:return H5e(g),e===null&&Y$(g),n=g.type,I=g.pendingProps,r=e!==null?e.memoizedProps:null,o=I.children,X$(n,I)?o=null:r!==null&&X$(n,r)&&(g.flags|=32),ixe(e,g),uo(e,g,o,i),g.child;case 6:return e===null&&Y$(g),null;case 13:return Ixe(e,g,i);case 4:return pre(g,g.stateNode.containerInfo),n=g.pendingProps,e===null?g.child=wB(g,null,n,i):uo(e,g,n,i),g.child;case 11:return n=g.type,I=g.pendingProps,I=g.elementType===n?I:gA(n,I),Bpe(e,g,n,I,i);case 7:return uo(e,g,g.pendingProps,i),g.child;case 8:return uo(e,g,g.pendingProps.children,i),g.child;case 12:return uo(e,g,g.pendingProps.children,i),g.child;case 10:e:{if(n=g.type._context,I=g.pendingProps,r=g.memoizedProps,o=I.value,Pi(Zx,n._currentValue),n._currentValue=o,r!==null)if(MA(r.value,o)){if(r.children===I.children&&!vC.current){g=Vd(e,g,i);break e}}else for(r=g.child,r!==null&&(r.return=g);r!==null;){var C=r.dependencies;if(C!==null){o=r.child;for(var a=C.firstContext;a!==null;){if(a.context===n){if(r.tag===1){a=ld(-1,i&-i),a.tag=2;var A=r.updateQueue;if(A!==null){A=A.shared;var s=A.pending;s===null?a.next=a:(a.next=s.next,s.next=a),A.pending=a}}r.lanes|=i,a=r.alternate,a!==null&&(a.lanes|=i),K$(r.return,i,g),C.lanes|=i;break}a=a.next}}else if(r.tag===10)o=r.type===g.type?null:r.child;else if(r.tag===18){if(o=r.return,o===null)throw Error(ht(341));o.lanes|=i,C=o.alternate,C!==null&&(C.lanes|=i),K$(o,i,g),o=r.sibling}else o=r.child;if(o!==null)o.return=r;else for(o=r;o!==null;){if(o===g){o=null;break}if(r=o.sibling,r!==null){r.return=o.return,o=r;break}o=o.return}r=o}uo(e,g,I.children,i),g=g.child}return g;case 9:return I=g.type,n=g.pendingProps.children,Tv(g,i),I=As(I),n=n(I),g.flags|=1,uo(e,g,n,i),g.child;case 14:return n=g.type,I=gA(n,g.pendingProps),I=gA(n.type,I),wpe(e,g,n,I,i);case 15:return txe(e,g,g.type,g.pendingProps,i);case 17:return n=g.type,I=g.pendingProps,I=g.elementType===n?I:gA(n,I),BK(e,g),g.tag=1,BC(n)?(e=!0,px(g)):e=!1,Tv(g,i),W5e(g,n,I),F$(g,n,I,i),M$(null,g,n,!0,e,i);case 19:return rxe(e,g,i);case 22:return gxe(e,g,i)}throw Error(ht(156,g.tag))};function Zxe(e,g){return LKe(e,g)}function Ylt(e,g,i,n){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=g,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ua(e,g,i,n){return new Ylt(e,g,i,n)}function Nre(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Klt(e){if(typeof e=="function")return Nre(e)?1:0;if(e!=null){if(e=e.$$typeof,e===qIe)return 11;if(e===ere)return 14}return 2}function _f(e,g){var i=e.alternate;return i===null?(i=Ua(e.tag,g,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=g,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,g=e.dependencies,i.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function RK(e,g,i,n,I,r){var o=2;if(n=e,typeof e=="function")Nre(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case $G:return F0(i.children,I,r,g);case $Ie:o=8,I|=8;break;case a$:return e=Ua(12,i,g,I|2),e.elementType=a$,e.lanes=r,e;case s$:return e=Ua(13,i,g,I),e.elementType=s$,e.lanes=r,e;case A$:return e=Ua(19,i,g,I),e.elementType=A$,e.lanes=r,e;case XKe:return M3(i,I,r,g);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case VKe:o=10;break e;case WKe:o=9;break e;case qIe:o=11;break e;case ere:o=14;break e;case Lh:o=16,n=null;break e}throw Error(ht(130,e==null?e:typeof e,""))}return g=Ua(o,i,g,I),g.elementType=e,g.type=n,g.lanes=r,g}function F0(e,g,i,n){return e=Ua(7,e,n,g),e.lanes=i,e}function M3(e,g,i,n){return e=Ua(22,e,n,g),e.elementType=XKe,e.lanes=i,e.stateNode={isHidden:!1},e}function AL(e,g,i){return e=Ua(6,e,null,g),e.lanes=i,e}function lL(e,g,i){return g=Ua(4,e.children!==null?e.children:[],e.key,g),g.lanes=i,g.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},g}function xlt(e,g,i,n,I){this.tag=g,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=OJ(0),this.expirationTimes=OJ(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=OJ(0),this.identifierPrefix=n,this.onRecoverableError=I,this.mutableSourceEagerHydrationData=null}function kre(e,g,i,n,I,r,o,C,a){return e=new xlt(e,g,i,C,a),g===1?(g=1,r===!0&&(g|=8)):g=0,r=Ua(3,null,null,g),e.current=r,r.stateNode=e,r.memoizedState={element:n,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},mre(r),e}function Flt(e,g,i){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(wxe)}catch(e){console.error(e)}}wxe(),vKe.exports=wa;var fb=vKe.exports;const _I=Ba(fb);var Epe=fb;o$.createRoot=Epe.createRoot,o$.hydrateRoot=Epe.hydrateRoot;/** + * @remix-run/router v1.6.1 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function AX(){return AX=Object.assign?Object.assign.bind():function(e){for(var g=1;g"u")throw new Error(g)}function J3(e,g){if(!e){typeof console<"u"&&console.warn(g);try{throw new Error(g)}catch{}}}function _lt(){return Math.random().toString(36).substr(2,8)}function Mpe(e,g){return{usr:e.state,key:e.key,idx:g}}function t8(e,g,i,n){return i===void 0&&(i=null),AX({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof g=="string"?ky(g):g,{state:i,key:g&&g.key||n||_lt()})}function Hx(e){let{pathname:g="/",search:i="",hash:n=""}=e;return i&&i!=="?"&&(g+=i.charAt(0)==="?"?i:"?"+i),n&&n!=="#"&&(g+=n.charAt(0)==="#"?n:"#"+n),g}function ky(e){let g={};if(e){let i=e.indexOf("#");i>=0&&(g.hash=e.substr(i),e=e.substr(0,i));let n=e.indexOf("?");n>=0&&(g.search=e.substr(n),e=e.substr(0,n)),e&&(g.pathname=e)}return g}function Olt(e,g,i,n){n===void 0&&(n={});let{window:I=document.defaultView,v5Compat:r=!1}=n,o=I.history,C=mf.Pop,a=null,A=s();A==null&&(A=0,o.replaceState(AX({},o.state,{idx:A}),""));function s(){return(o.state||{idx:null}).idx}function l(){C=mf.Pop;let f=s(),m=f==null?null:f-A;A=f,a&&a({action:C,location:h.location,delta:m})}function c(f,m){C=mf.Push;let b=t8(h.location,f,m);i&&i(b,f),A=s()+1;let p=Mpe(b,A),y=h.createHref(b);try{o.pushState(p,"",y)}catch{I.location.assign(y)}r&&a&&a({action:C,location:h.location,delta:1})}function u(f,m){C=mf.Replace;let b=t8(h.location,f,m);i&&i(b,f),A=s();let p=Mpe(b,A),y=h.createHref(b);o.replaceState(p,"",y),r&&a&&a({action:C,location:h.location,delta:0})}function d(f){let m=I.location.origin!=="null"?I.location.origin:I.location.href,b=typeof f=="string"?f:Hx(f);return nI(m,"No window.location.(origin|href) available to create URL for href: "+b),new URL(b,m)}let h={get action(){return C},get location(){return e(I,o)},listen(f){if(a)throw new Error("A history only accepts one active listener");return I.addEventListener(Dpe,l),a=f,()=>{I.removeEventListener(Dpe,l),a=null}},createHref(f){return g(I,f)},createURL:d,encodeLocation(f){let m=d(f);return{pathname:m.pathname,search:m.search,hash:m.hash}},push:c,replace:u,go(f){return o.go(f)}};return h}var zpe;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(zpe||(zpe={}));function Jlt(e,g,i){i===void 0&&(i="/");let n=typeof g=="string"?ky(g):g,I=Fre(n.pathname||"/",i);if(I==null)return null;let r=Sxe(e);Llt(r);let o=null;for(let C=0;o==null&&C{let a={relativePath:C===void 0?r.path||"":C,caseSensitive:r.caseSensitive===!0,childrenIndex:o,route:r};a.relativePath.startsWith("/")&&(nI(a.relativePath.startsWith(n),'Absolute route path "'+a.relativePath+'" nested under path '+('"'+n+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),a.relativePath=a.relativePath.slice(n.length));let A=Of([n,a.relativePath]),s=i.concat(a);r.children&&r.children.length>0&&(nI(r.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+A+'".')),Sxe(r.children,g,s,A)),!(r.path==null&&!r.index)&&g.push({path:A,score:tct(A,r.index),routesMeta:s})};return e.forEach((r,o)=>{var C;if(r.path===""||!((C=r.path)!=null&&C.includes("?")))I(r,o);else for(let a of Rxe(r.path))I(r,o,a)}),g}function Rxe(e){let g=e.split("/");if(g.length===0)return[];let[i,...n]=g,I=i.endsWith("?"),r=i.replace(/\?$/,"");if(n.length===0)return I?[r,""]:[r];let o=Rxe(n.join("/")),C=[];return C.push(...o.map(a=>a===""?r:[r,a].join("/"))),I&&C.push(...o),C.map(a=>e.startsWith("/")&&a===""?"/":a)}function Llt(e){e.sort((g,i)=>g.score!==i.score?i.score-g.score:gct(g.routesMeta.map(n=>n.childrenIndex),i.routesMeta.map(n=>n.childrenIndex)))}const Ult=/^:\w+$/,Qlt=3,jlt=2,$lt=1,qlt=10,ect=-2,Ppe=e=>e==="*";function tct(e,g){let i=e.split("/"),n=i.length;return i.some(Ppe)&&(n+=ect),g&&(n+=jlt),i.filter(I=>!Ppe(I)).reduce((I,r)=>I+(Ult.test(r)?Qlt:r===""?$lt:qlt),n)}function gct(e,g){return e.length===g.length&&e.slice(0,-1).every((n,I)=>n===g[I])?e[e.length-1]-g[g.length-1]:0}function ict(e,g){let{routesMeta:i}=e,n={},I="/",r=[];for(let o=0;o{if(s==="*"){let c=C[l]||"";o=r.slice(0,r.length-c.length).replace(/(.)\/+$/,"$1")}return A[s]=oct(C[l]||"",s),A},{}),pathname:r,pathnameBase:o,pattern:e}}function Ict(e,g,i){g===void 0&&(g=!1),i===void 0&&(i=!0),J3(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let n=[],I="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^$?{}|()[\]]/g,"\\$&").replace(/\/:(\w+)/g,(o,C)=>(n.push(C),"/([^\\/]+)"));return e.endsWith("*")?(n.push("*"),I+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):i?I+="\\/*$":e!==""&&e!=="/"&&(I+="(?:(?=\\/|$))"),[new RegExp(I,g?void 0:"i"),n]}function rct(e){try{return decodeURI(e)}catch(g){return J3(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+g+").")),e}}function oct(e,g){try{return decodeURIComponent(e)}catch(i){return J3(!1,'The value for the URL param "'+g+'" will not be decoded because'+(' the string "'+e+'" is a malformed URL segment. This is probably')+(" due to a bad percent encoding ("+i+").")),e}}function Fre(e,g){if(g==="/")return e;if(!e.toLowerCase().startsWith(g.toLowerCase()))return null;let i=g.endsWith("/")?g.length-1:g.length,n=e.charAt(i);return n&&n!=="/"?null:e.slice(i)||"/"}function Cct(e,g){g===void 0&&(g="/");let{pathname:i,search:n="",hash:I=""}=typeof e=="string"?ky(e):e;return{pathname:i?i.startsWith("/")?i:act(i,g):g,search:Act(n),hash:lct(I)}}function act(e,g){let i=g.replace(/\/+$/,"").split("/");return e.split("/").forEach(I=>{I===".."?i.length>1&&i.pop():I!=="."&&i.push(I)}),i.length>1?i.join("/"):"/"}function cL(e,g,i,n){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+g+"` field ["+JSON.stringify(n)+"]. Please separate it out to the ")+("`to."+i+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Vxe(e){return e.filter((g,i)=>i===0||g.route.path&&g.route.path.length>0)}function Wxe(e,g,i,n){n===void 0&&(n=!1);let I;typeof e=="string"?I=ky(e):(I=AX({},e),nI(!I.pathname||!I.pathname.includes("?"),cL("?","pathname","search",I)),nI(!I.pathname||!I.pathname.includes("#"),cL("#","pathname","hash",I)),nI(!I.search||!I.search.includes("#"),cL("#","search","hash",I)));let r=e===""||I.pathname==="",o=r?"/":I.pathname,C;if(n||o==null)C=i;else{let l=g.length-1;if(o.startsWith("..")){let c=o.split("/");for(;c[0]==="..";)c.shift(),l-=1;I.pathname=c.join("/")}C=l>=0?g[l]:"/"}let a=Cct(I,C),A=o&&o!=="/"&&o.endsWith("/"),s=(r||o===".")&&i.endsWith("/");return!a.pathname.endsWith("/")&&(A||s)&&(a.pathname+="/"),a}const Of=e=>e.join("/").replace(/\/\/+/g,"/"),sct=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Act=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,lct=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function cct(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const Xxe=["post","put","patch","delete"];new Set(Xxe);const uct=["get",...Xxe];new Set(uct);/** + * React Router v6.11.1 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Nx(){return Nx=Object.assign?Object.assign.bind():function(e){for(var g=1;gC.pathnameBase)),r=Ue.useRef(!1);return Nxe(()=>{r.current=!0}),Ue.useCallback(function(C,a){if(a===void 0&&(a={}),!r.current)return;if(typeof C=="number"){g.go(C);return}let A=Wxe(C,JSON.parse(I),n,a.relative==="path");e!=="/"&&(A.pathname=A.pathname==="/"?e:Of([e,A.pathname])),(a.replace?g.replace:g.push)(A,a.state,a)},[e,g,I,n])}function kxe(e,g){let{relative:i}=g===void 0?{}:g,{matches:n}=Ue.useContext(Yy),{pathname:I}=U3(),r=JSON.stringify(Vxe(n).map(o=>o.pathnameBase));return Ue.useMemo(()=>Wxe(e,JSON.parse(r),I,i==="path"),[e,r,I,i])}function pct(e,g){return bct(e,g)}function bct(e,g,i){AT()||nI(!1);let{navigator:n}=Ue.useContext(m1),{matches:I}=Ue.useContext(Yy),r=I[I.length-1],o=r?r.params:{};r&&r.pathname;let C=r?r.pathnameBase:"/";r&&r.route;let a=U3(),A;if(g){var s;let h=typeof g=="string"?ky(g):g;C==="/"||(s=h.pathname)!=null&&s.startsWith(C)||nI(!1),A=h}else A=a;let l=A.pathname||"/",c=C==="/"?l:l.slice(C.length)||"/",u=Jlt(e,{pathname:c}),d=Bct(u&&u.map(h=>Object.assign({},h,{params:Object.assign({},o,h.params),pathname:Of([C,n.encodeLocation?n.encodeLocation(h.pathname).pathname:h.pathname]),pathnameBase:h.pathnameBase==="/"?C:Of([C,n.encodeLocation?n.encodeLocation(h.pathnameBase).pathname:h.pathnameBase])})),I,i);return g&&d?Ue.createElement(L3.Provider,{value:{location:Nx({pathname:"/",search:"",hash:"",state:null,key:"default"},A),navigationType:mf.Pop}},d):d}function yct(){let e=Vct(),g=cct(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),i=e instanceof Error?e.stack:null,I={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"},r=null;return Ue.createElement(Ue.Fragment,null,Ue.createElement("h2",null,"Unexpected Application Error!"),Ue.createElement("h3",{style:{fontStyle:"italic"}},g),i?Ue.createElement("pre",{style:I},i):null,r)}const Zct=Ue.createElement(yct,null);class Gct extends Ue.Component{constructor(g){super(g),this.state={location:g.location,revalidation:g.revalidation,error:g.error}}static getDerivedStateFromError(g){return{error:g}}static getDerivedStateFromProps(g,i){return i.location!==g.location||i.revalidation!=="idle"&&g.revalidation==="idle"?{error:g.error,location:g.location,revalidation:g.revalidation}:{error:g.error||i.error,location:i.location,revalidation:g.revalidation||i.revalidation}}componentDidCatch(g,i){console.error("React Router caught the following error during render",g,i)}render(){return this.state.error?Ue.createElement(Yy.Provider,{value:this.props.routeContext},Ue.createElement(Hxe.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function vct(e){let{routeContext:g,match:i,children:n}=e,I=Ue.useContext(Txe);return I&&I.static&&I.staticContext&&(i.route.errorElement||i.route.ErrorBoundary)&&(I.staticContext._deepestRenderedBoundaryId=i.route.id),Ue.createElement(Yy.Provider,{value:g},n)}function Bct(e,g,i){var n;if(g===void 0&&(g=[]),i===void 0&&(i=null),e==null){var I;if((I=i)!=null&&I.errors)e=i.matches;else return null}let r=e,o=(n=i)==null?void 0:n.errors;if(o!=null){let C=r.findIndex(a=>a.route.id&&o?.[a.route.id]);C>=0||nI(!1),r=r.slice(0,Math.min(r.length,C+1))}return r.reduceRight((C,a,A)=>{let s=a.route.id?o?.[a.route.id]:null,l=null;i&&(l=a.route.errorElement||Zct);let c=g.concat(r.slice(0,A+1)),u=()=>{let d;return s?d=l:a.route.Component?d=Ue.createElement(a.route.Component,null):a.route.element?d=a.route.element:d=C,Ue.createElement(vct,{match:a,routeContext:{outlet:C,matches:c,isDataRoute:i!=null},children:d})};return i&&(a.route.ErrorBoundary||a.route.errorElement||A===0)?Ue.createElement(Gct,{location:i.location,revalidation:i.revalidation,component:l,error:s,children:u(),routeContext:{outlet:null,matches:c,isDataRoute:!0}}):u()},null)}var g8;(function(e){e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate"})(g8||(g8={}));var lX;(function(e){e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId"})(lX||(lX={}));function wct(e){let g=Ue.useContext(Txe);return g||nI(!1),g}function Sct(e){let g=Ue.useContext(dct);return g||nI(!1),g}function Rct(e){let g=Ue.useContext(Yy);return g||nI(!1),g}function Yxe(e){let g=Rct(),i=g.matches[g.matches.length-1];return i.route.id||nI(!1),i.route.id}function Vct(){var e;let g=Ue.useContext(Hxe),i=Sct(lX.UseRouteError),n=Yxe(lX.UseRouteError);return g||((e=i.errors)==null?void 0:e[n])}function Wct(){let{router:e}=wct(g8.UseNavigateStable),g=Yxe(lX.UseNavigateStable),i=Ue.useRef(!1);return Nxe(()=>{i.current=!0}),Ue.useCallback(function(I,r){r===void 0&&(r={}),i.current&&(typeof I=="number"?e.navigate(I):e.navigate(I,Nx({fromRouteId:g},r)))},[e,g])}function i8(e){nI(!1)}function Xct(e){let{basename:g="/",children:i=null,location:n,navigationType:I=mf.Pop,navigator:r,static:o=!1}=e;AT()&&nI(!1);let C=g.replace(/^\/*/,"/"),a=Ue.useMemo(()=>({basename:C,navigator:r,static:o}),[C,r,o]);typeof n=="string"&&(n=ky(n));let{pathname:A="/",search:s="",hash:l="",state:c=null,key:u="default"}=n,d=Ue.useMemo(()=>{let h=Fre(A,C);return h==null?null:{location:{pathname:h,search:s,hash:l,state:c,key:u},navigationType:I}},[C,A,s,l,c,u,I]);return d==null?null:Ue.createElement(m1.Provider,{value:a},Ue.createElement(L3.Provider,{children:i,value:d}))}function Tct(e){let{children:g,location:i}=e;return pct(n8(g),i)}var _pe;(function(e){e[e.pending=0]="pending",e[e.success=1]="success",e[e.error=2]="error"})(_pe||(_pe={}));new Promise(()=>{});function n8(e,g){g===void 0&&(g=[]);let i=[];return Ue.Children.forEach(e,(n,I)=>{if(!Ue.isValidElement(n))return;let r=[...g,I];if(n.type===Ue.Fragment){i.push.apply(i,n8(n.props.children,r));return}n.type!==i8&&nI(!1),!n.props.index||!n.props.children||nI(!1);let o={id:n.props.id||r.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,loader:n.props.loader,action:n.props.action,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(o.children=n8(n.props.children,r)),i.push(o)}),i}/** + * React Router DOM v6.11.1 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function I8(){return I8=Object.assign?Object.assign.bind():function(e){for(var g=1;g=0)&&(i[I]=e[I]);return i}function Nct(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function kct(e,g){return e.button===0&&(!g||g==="_self")&&!Nct(e)}const Yct=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset"];function Kct(e){let{basename:g,children:i,window:n}=e,I=Ue.useRef();I.current==null&&(I.current=Plt({window:n,v5Compat:!0}));let r=I.current,[o,C]=Ue.useState({action:r.action,location:r.location});return Ue.useLayoutEffect(()=>r.listen(C),[r]),Ue.createElement(Xct,{basename:g,children:i,location:o.location,navigationType:o.action,navigator:r})}const xct=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Fct=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ect=Ue.forwardRef(function(g,i){let{onClick:n,relative:I,reloadDocument:r,replace:o,state:C,target:a,to:A,preventScrollReset:s}=g,l=Hct(g,Yct),{basename:c}=Ue.useContext(m1),u,d=!1;if(typeof A=="string"&&Fct.test(A)&&(u=A,xct))try{let b=new URL(window.location.href),p=A.startsWith("//")?new URL(b.protocol+A):new URL(A),y=Fre(p.pathname,c);p.origin===b.origin&&y!=null?A=y+p.search+p.hash:d=!0}catch{}let h=hct(A,{relative:I}),f=Dct(A,{replace:o,state:C,target:a,preventScrollReset:s,relative:I});function m(b){n&&n(b),b.defaultPrevented||f(b)}return Ue.createElement("a",I8({},l,{href:u||h,onClick:d||r?n:m,ref:i,target:a}))});var Ope;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmitImpl="useSubmitImpl",e.UseFetcher="useFetcher"})(Ope||(Ope={}));var Jpe;(function(e){e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Jpe||(Jpe={}));function Dct(e,g){let{target:i,replace:n,state:I,preventScrollReset:r,relative:o}=g===void 0?{}:g,C=fct(),a=U3(),A=kxe(e,{relative:o});return Ue.useCallback(s=>{if(kct(s,i)){s.preventDefault();let l=n!==void 0?n:Hx(a)===Hx(A);C(e,{replace:l,state:I,preventScrollReset:r,relative:o})}},[a,C,A,n,I,i,e,r,o])}const Mct="modulepreload",zct=function(e){return"/"+e},Lpe={},Pct=function(g,i,n){if(!i||i.length===0)return g();const I=document.getElementsByTagName("link");return Promise.all(i.map(r=>{if(r=zct(r),r in Lpe)return;Lpe[r]=!0;const o=r.endsWith(".css"),C=o?'[rel="stylesheet"]':"";if(!!n)for(let s=I.length-1;s>=0;s--){const l=I[s];if(l.href===r&&(!o||l.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${r}"]${C}`))return;const A=document.createElement("link");if(A.rel=o?"stylesheet":Mct,o||(A.as="script",A.crossOrigin=""),A.href=r,document.head.appendChild(A),o)return new Promise((s,l)=>{A.addEventListener("load",s),A.addEventListener("error",()=>l(new Error(`Unable to preload CSS for ${r}`)))})})).then(()=>g())};function _ct(e){var g=this.constructor;return this.then(function(i){return g.resolve(e()).then(function(){return i})},function(i){return g.resolve(e()).then(function(){return g.reject(i)})})}function Oct(e){var g=this;return new g(function(i,n){if(!(e&&typeof e.length<"u"))return n(new TypeError(typeof e+" "+e+" is not iterable(cannot read property Symbol(Symbol.iterator))"));var I=Array.prototype.slice.call(e);if(I.length===0)return i([]);var r=I.length;function o(a,A){if(A&&(typeof A=="object"||typeof A=="function")){var s=A.then;if(typeof s=="function"){s.call(A,function(l){o(a,l)},function(l){I[a]={status:"rejected",reason:l},--r===0&&i(I)});return}}I[a]={status:"fulfilled",value:A},--r===0&&i(I)}for(var C=0;C"u"&&(typeof self<"u"?self.globalThis=self:typeof global<"u"&&(global.globalThis=global));globalThis.Promise||(globalThis.Promise=Rn);Object.assign||(Object.assign=iut);var nut=16;Date.now&&Date.prototype.getTime||(Date.now=function(){return new Date().getTime()});if(!(globalThis.performance&&globalThis.performance.now)){var Iut=Date.now();globalThis.performance||(globalThis.performance={}),globalThis.performance.now=function(){return Date.now()-Iut}}var uL=Date.now(),Qpe=["ms","moz","webkit","o"];for(var dL=0;dL0?1:-1});Number.isInteger||(Number.isInteger=function(g){return typeof g=="number"&&isFinite(g)&&Math.floor(g)===g});globalThis.ArrayBuffer||(globalThis.ArrayBuffer=Array);globalThis.Float32Array||(globalThis.Float32Array=Array);globalThis.Uint32Array||(globalThis.Uint32Array=Array);globalThis.Uint16Array||(globalThis.Uint16Array=Array);globalThis.Uint8Array||(globalThis.Uint8Array=Array);globalThis.Int32Array||(globalThis.Int32Array=Array);/*! + * @pixi/settings - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/settings is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! + * @pixi/constants - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/constants is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */var jpe;(function(e){e[e.WEBGL_LEGACY=0]="WEBGL_LEGACY",e[e.WEBGL=1]="WEBGL",e[e.WEBGL2=2]="WEBGL2"})(jpe||(jpe={}));var $pe;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.WEBGL=1]="WEBGL",e[e.CANVAS=2]="CANVAS"})($pe||($pe={}));var qpe;(function(e){e[e.COLOR=16384]="COLOR",e[e.DEPTH=256]="DEPTH",e[e.STENCIL=1024]="STENCIL"})(qpe||(qpe={}));var e0e;(function(e){e[e.NORMAL=0]="NORMAL",e[e.ADD=1]="ADD",e[e.MULTIPLY=2]="MULTIPLY",e[e.SCREEN=3]="SCREEN",e[e.OVERLAY=4]="OVERLAY",e[e.DARKEN=5]="DARKEN",e[e.LIGHTEN=6]="LIGHTEN",e[e.COLOR_DODGE=7]="COLOR_DODGE",e[e.COLOR_BURN=8]="COLOR_BURN",e[e.HARD_LIGHT=9]="HARD_LIGHT",e[e.SOFT_LIGHT=10]="SOFT_LIGHT",e[e.DIFFERENCE=11]="DIFFERENCE",e[e.EXCLUSION=12]="EXCLUSION",e[e.HUE=13]="HUE",e[e.SATURATION=14]="SATURATION",e[e.COLOR=15]="COLOR",e[e.LUMINOSITY=16]="LUMINOSITY",e[e.NORMAL_NPM=17]="NORMAL_NPM",e[e.ADD_NPM=18]="ADD_NPM",e[e.SCREEN_NPM=19]="SCREEN_NPM",e[e.NONE=20]="NONE",e[e.SRC_OVER=0]="SRC_OVER",e[e.SRC_IN=21]="SRC_IN",e[e.SRC_OUT=22]="SRC_OUT",e[e.SRC_ATOP=23]="SRC_ATOP",e[e.DST_OVER=24]="DST_OVER",e[e.DST_IN=25]="DST_IN",e[e.DST_OUT=26]="DST_OUT",e[e.DST_ATOP=27]="DST_ATOP",e[e.ERASE=26]="ERASE",e[e.SUBTRACT=28]="SUBTRACT",e[e.XOR=29]="XOR"})(e0e||(e0e={}));var t0e;(function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN"})(t0e||(t0e={}));var g0e;(function(e){e[e.RGBA=6408]="RGBA",e[e.RGB=6407]="RGB",e[e.RG=33319]="RG",e[e.RED=6403]="RED",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.ALPHA=6406]="ALPHA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL"})(g0e||(g0e={}));var i0e;(function(e){e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z"})(i0e||(i0e={}));var n0e;(function(e){e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.BYTE=5120]="BYTE",e[e.SHORT=5122]="SHORT",e[e.INT=5124]="INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.HALF_FLOAT=36193]="HALF_FLOAT"})(n0e||(n0e={}));var I0e;(function(e){e[e.FLOAT=0]="FLOAT",e[e.INT=1]="INT",e[e.UINT=2]="UINT"})(I0e||(I0e={}));var C8;(function(e){e[e.NEAREST=0]="NEAREST",e[e.LINEAR=1]="LINEAR"})(C8||(C8={}));var a8;(function(e){e[e.CLAMP=33071]="CLAMP",e[e.REPEAT=10497]="REPEAT",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"})(a8||(a8={}));var s8;(function(e){e[e.OFF=0]="OFF",e[e.POW2=1]="POW2",e[e.ON=2]="ON",e[e.ON_MANUAL=3]="ON_MANUAL"})(s8||(s8={}));var r0e;(function(e){e[e.NPM=0]="NPM",e[e.UNPACK=1]="UNPACK",e[e.PMA=2]="PMA",e[e.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",e[e.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",e[e.PREMULTIPLY_ALPHA=2]="PREMULTIPLY_ALPHA",e[e.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA"})(r0e||(r0e={}));var o0e;(function(e){e[e.NO=0]="NO",e[e.YES=1]="YES",e[e.AUTO=2]="AUTO",e[e.BLEND=0]="BLEND",e[e.CLEAR=1]="CLEAR",e[e.BLIT=2]="BLIT"})(o0e||(o0e={}));var A8;(function(e){e[e.AUTO=0]="AUTO",e[e.MANUAL=1]="MANUAL"})(A8||(A8={}));var k2;(function(e){e.LOW="lowp",e.MEDIUM="mediump",e.HIGH="highp"})(k2||(k2={}));var C0e;(function(e){e[e.NONE=0]="NONE",e[e.SCISSOR=1]="SCISSOR",e[e.STENCIL=2]="STENCIL",e[e.SPRITE=3]="SPRITE",e[e.COLOR=4]="COLOR"})(C0e||(C0e={}));var a0e;(function(e){e[e.RED=1]="RED",e[e.GREEN=2]="GREEN",e[e.BLUE=4]="BLUE",e[e.ALPHA=8]="ALPHA"})(a0e||(a0e={}));var l8;(function(e){e[e.NONE=0]="NONE",e[e.LOW=2]="LOW",e[e.MEDIUM=4]="MEDIUM",e[e.HIGH=8]="HIGH"})(l8||(l8={}));var s0e;(function(e){e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER"})(s0e||(s0e={}));var Dxe={createCanvas:function(e,g){var i=document.createElement("canvas");return i.width=e,i.height=g,i},getWebGLRenderingContext:function(){return WebGLRenderingContext},getNavigator:function(){return navigator},getBaseUrl:function(){var e;return(e=document.baseURI)!==null&&e!==void 0?e:window.location.href},fetch:function(e,g){return fetch(e,g)}},fL=/iPhone/i,A0e=/iPod/i,l0e=/iPad/i,c0e=/\biOS-universal(?:.+)Mac\b/i,mL=/\bAndroid(?:.+)Mobile\b/i,u0e=/Android/i,TZ=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,xN=/Silk/i,lu=/Windows Phone/i,d0e=/\bWindows(?:.+)ARM\b/i,h0e=/BlackBerry/i,f0e=/BB10/i,m0e=/Opera Mini/i,p0e=/\b(CriOS|Chrome)(?:.+)Mobile/i,b0e=/Mobile(?:.+)Firefox\b/i,y0e=function(e){return typeof e<"u"&&e.platform==="MacIntel"&&typeof e.maxTouchPoints=="number"&&e.maxTouchPoints>1&&typeof MSStream>"u"};function rut(e){return function(g){return g.test(e)}}function out(e){var g={userAgent:"",platform:"",maxTouchPoints:0};!e&&typeof navigator<"u"?g={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof e=="string"?g.userAgent=e:e&&e.userAgent&&(g={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0});var i=g.userAgent,n=i.split("[FBAN");typeof n[1]<"u"&&(i=n[0]),n=i.split("Twitter"),typeof n[1]<"u"&&(i=n[0]);var I=rut(i),r={apple:{phone:I(fL)&&!I(lu),ipod:I(A0e),tablet:!I(fL)&&(I(l0e)||y0e(g))&&!I(lu),universal:I(c0e),device:(I(fL)||I(A0e)||I(l0e)||I(c0e)||y0e(g))&&!I(lu)},amazon:{phone:I(TZ),tablet:!I(TZ)&&I(xN),device:I(TZ)||I(xN)},android:{phone:!I(lu)&&I(TZ)||!I(lu)&&I(mL),tablet:!I(lu)&&!I(TZ)&&!I(mL)&&(I(xN)||I(u0e)),device:!I(lu)&&(I(TZ)||I(xN)||I(mL)||I(u0e))||I(/\bokhttp\b/i)},windows:{phone:I(lu),tablet:I(d0e),device:I(lu)||I(d0e)},other:{blackberry:I(h0e),blackberry10:I(f0e),opera:I(m0e),firefox:I(b0e),chrome:I(p0e),device:I(h0e)||I(f0e)||I(m0e)||I(b0e)||I(p0e)},any:!1,phone:!1,tablet:!1};return r.any=r.apple.device||r.android.device||r.windows.device||r.other.device,r.phone=r.apple.phone||r.android.phone||r.windows.phone,r.tablet=r.apple.tablet||r.android.tablet||r.windows.tablet,r}var Qa=out(globalThis.navigator);function Cut(){return!Qa.apple.device}function aut(e){var g=!0;if(Qa.tablet||Qa.phone){if(Qa.apple.device){var i=navigator.userAgent.match(/OS (\d+)_(\d+)?/);if(i){var n=parseInt(i[1],10);n<11&&(g=!1)}}if(Qa.android.device){var i=navigator.userAgent.match(/Android\s([0-9.]*)/);if(i){var n=parseInt(i[1],10);n<7&&(g=!1)}}}return g?e:4}var Ht={ADAPTER:Dxe,MIPMAP_TEXTURES:s8.POW2,ANISOTROPIC_LEVEL:0,RESOLUTION:1,FILTER_RESOLUTION:1,FILTER_MULTISAMPLE:l8.NONE,SPRITE_MAX_TEXTURES:aut(32),SPRITE_BATCH_SIZE:4096,RENDER_OPTIONS:{view:null,antialias:!1,autoDensity:!1,backgroundColor:0,backgroundAlpha:1,useContextAlpha:!0,clearBeforeRender:!0,preserveDrawingBuffer:!1,width:800,height:600,legacy:!1},GC_MODE:A8.AUTO,GC_MAX_IDLE:60*60,GC_MAX_CHECK_COUNT:60*10,WRAP_MODE:a8.CLAMP,SCALE_MODE:C8.LINEAR,PRECISION_VERTEX:k2.HIGH,PRECISION_FRAGMENT:Qa.apple.device?k2.HIGH:k2.MEDIUM,CAN_UPLOAD_SAME_BUFFER:Cut(),CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1},Mxe={exports:{}};(function(e){var g=Object.prototype.hasOwnProperty,i="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(i=!1));function I(a,A,s){this.fn=a,this.context=A,this.once=s||!1}function r(a,A,s,l,c){if(typeof s!="function")throw new TypeError("The listener must be a function");var u=new I(s,l||a,c),d=i?i+A:A;return a._events[d]?a._events[d].fn?a._events[d]=[a._events[d],u]:a._events[d].push(u):(a._events[d]=u,a._eventsCount++),a}function o(a,A){--a._eventsCount===0?a._events=new n:delete a._events[A]}function C(){this._events=new n,this._eventsCount=0}C.prototype.eventNames=function(){var A=[],s,l;if(this._eventsCount===0)return A;for(l in s=this._events)g.call(s,l)&&A.push(i?l.slice(1):l);return Object.getOwnPropertySymbols?A.concat(Object.getOwnPropertySymbols(s)):A},C.prototype.listeners=function(A){var s=i?i+A:A,l=this._events[s];if(!l)return[];if(l.fn)return[l.fn];for(var c=0,u=l.length,d=new Array(u);c80*i){C=A=e[0],a=s=e[1];for(var d=i;dA&&(A=l),c>s&&(s=c);u=Math.max(A-C,s-a),u=u!==0?32767/u:0}return uX(r,o,i,C,a,u,0),o}function zxe(e,g,i,n,I){var r,o;if(I===d8(e,g,i,n)>0)for(r=g;r=g;r-=n)o=Z0e(r,e[r],e[r+1],o);return o&&j3(o,o.next)&&(hX(o),o=o.next),o}function mb(e,g){if(!e)return e;g||(g=e);var i=e,n;do if(n=!1,!i.steiner&&(j3(i,i.next)||vn(i.prev,i,i.next)===0)){if(hX(i),i=g=i.prev,i===i.next)break;n=!0}else i=i.next;while(n||i!==g);return g}function uX(e,g,i,n,I,r,o){if(e){!o&&r&&but(e,n,I,r);for(var C=e,a,A;e.prev!==e.next;){if(a=e.prev,A=e.next,r?lut(e,n,I,r):Aut(e)){g.push(a.i/i|0),g.push(e.i/i|0),g.push(A.i/i|0),hX(e),e=A.next,C=A.next;continue}if(e=A,e===C){o?o===1?(e=cut(mb(e),g,i),uX(e,g,i,n,I,r,2)):o===2&&uut(e,g,i,n,I,r):uX(mb(e),g,i,n,I,r,1);break}}}}function Aut(e){var g=e.prev,i=e,n=e.next;if(vn(g,i,n)>=0)return!1;for(var I=g.x,r=i.x,o=n.x,C=g.y,a=i.y,A=n.y,s=Ir?I>o?I:o:r>o?r:o,u=C>a?C>A?C:A:a>A?a:A,d=n.next;d!==g;){if(d.x>=s&&d.x<=c&&d.y>=l&&d.y<=u&&av(I,C,r,a,o,A,d.x,d.y)&&vn(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function lut(e,g,i,n){var I=e.prev,r=e,o=e.next;if(vn(I,r,o)>=0)return!1;for(var C=I.x,a=r.x,A=o.x,s=I.y,l=r.y,c=o.y,u=Ca?C>A?C:A:a>A?a:A,f=s>l?s>c?s:c:l>c?l:c,m=c8(u,d,g,i,n),b=c8(h,f,g,i,n),p=e.prevZ,y=e.nextZ;p&&p.z>=m&&y&&y.z<=b;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&p!==I&&p!==o&&av(C,s,a,l,A,c,p.x,p.y)&&vn(p.prev,p,p.next)>=0||(p=p.prevZ,y.x>=u&&y.x<=h&&y.y>=d&&y.y<=f&&y!==I&&y!==o&&av(C,s,a,l,A,c,y.x,y.y)&&vn(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;p&&p.z>=m;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&p!==I&&p!==o&&av(C,s,a,l,A,c,p.x,p.y)&&vn(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;y&&y.z<=b;){if(y.x>=u&&y.x<=h&&y.y>=d&&y.y<=f&&y!==I&&y!==o&&av(C,s,a,l,A,c,y.x,y.y)&&vn(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function cut(e,g,i){var n=e;do{var I=n.prev,r=n.next.next;!j3(I,r)&&Pxe(I,n,n.next,r)&&dX(I,r)&&dX(r,I)&&(g.push(I.i/i|0),g.push(n.i/i|0),g.push(r.i/i|0),hX(n),hX(n.next),n=e=r),n=n.next}while(n!==e);return mb(n)}function uut(e,g,i,n,I,r){var o=e;do{for(var C=o.next.next;C!==o.prev;){if(o.i!==C.i&&Gut(o,C)){var a=_xe(o,C);o=mb(o,o.next),a=mb(a,a.next),uX(o,g,i,n,I,r,0),uX(a,g,i,n,I,r,0);return}C=C.next}o=o.next}while(o!==e)}function dut(e,g,i,n){var I=[],r,o,C,a,A;for(r=0,o=g.length;r=i.next.y&&i.next.y!==i.y){var C=i.x+(I-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(C<=n&&C>r&&(r=C,o=i.x=i.x&&i.x>=A&&n!==i.x&&av(Io.x||i.x===o.x&&put(o,i)))&&(o=i,l=c)),i=i.next;while(i!==a);return o}function put(e,g){return vn(e.prev,e,g.prev)<0&&vn(g.next,e,e.next)<0}function but(e,g,i,n){var I=e;do I.z===0&&(I.z=c8(I.x,I.y,g,i,n)),I.prevZ=I.prev,I.nextZ=I.next,I=I.next;while(I!==e);I.prevZ.nextZ=null,I.prevZ=null,yut(I)}function yut(e){var g,i,n,I,r,o,C,a,A=1;do{for(i=e,e=null,r=null,o=0;i;){for(o++,n=i,C=0,g=0;g0||a>0&&n;)C!==0&&(a===0||!n||i.z<=n.z)?(I=i,i=i.nextZ,C--):(I=n,n=n.nextZ,a--),r?r.nextZ=I:e=I,I.prevZ=r,r=I;i=n}r.nextZ=null,A*=2}while(o>1);return e}function c8(e,g,i,n,I){return e=(e-i)*I|0,g=(g-n)*I|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,g=(g|g<<8)&16711935,g=(g|g<<4)&252645135,g=(g|g<<2)&858993459,g=(g|g<<1)&1431655765,e|g<<1}function Zut(e){var g=e,i=e;do(g.x=(e-o)*(r-C)&&(e-o)*(n-C)>=(i-o)*(g-C)&&(i-o)*(r-C)>=(I-o)*(n-C)}function Gut(e,g){return e.next.i!==g.i&&e.prev.i!==g.i&&!vut(e,g)&&(dX(e,g)&&dX(g,e)&&But(e,g)&&(vn(e.prev,e,g.prev)||vn(e,g.prev,g))||j3(e,g)&&vn(e.prev,e,e.next)>0&&vn(g.prev,g,g.next)>0)}function vn(e,g,i){return(g.y-e.y)*(i.x-g.x)-(g.x-e.x)*(i.y-g.y)}function j3(e,g){return e.x===g.x&&e.y===g.y}function Pxe(e,g,i,n){var I=EN(vn(e,g,i)),r=EN(vn(e,g,n)),o=EN(vn(i,n,e)),C=EN(vn(i,n,g));return!!(I!==r&&o!==C||I===0&&FN(e,i,g)||r===0&&FN(e,n,g)||o===0&&FN(i,e,n)||C===0&&FN(i,g,n))}function FN(e,g,i){return g.x<=Math.max(e.x,i.x)&&g.x>=Math.min(e.x,i.x)&&g.y<=Math.max(e.y,i.y)&&g.y>=Math.min(e.y,i.y)}function EN(e){return e>0?1:e<0?-1:0}function vut(e,g){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==g.i&&i.next.i!==g.i&&Pxe(i,i.next,e,g))return!0;i=i.next}while(i!==e);return!1}function dX(e,g){return vn(e.prev,e,e.next)<0?vn(e,g,e.next)>=0&&vn(e,e.prev,g)>=0:vn(e,g,e.prev)<0||vn(e,e.next,g)<0}function But(e,g){var i=e,n=!1,I=(e.x+g.x)/2,r=(e.y+g.y)/2;do i.y>r!=i.next.y>r&&i.next.y!==i.y&&I<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next;while(i!==e);return n}function _xe(e,g){var i=new u8(e.i,e.x,e.y),n=new u8(g.i,g.x,g.y),I=e.next,r=g.prev;return e.next=g,g.prev=e,i.next=I,I.prev=i,n.next=i,i.prev=n,r.next=n,n.prev=r,n}function Z0e(e,g,i,n){var I=new u8(e,g,i);return n?(I.next=n.next,I.prev=n,n.next.prev=I,n.next=I):(I.prev=I,I.next=I),I}function hX(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function u8(e,g,i){this.i=e,this.x=g,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Q3.deviation=function(e,g,i,n){var I=g&&g.length,r=I?g[0]*i:e.length,o=Math.abs(d8(e,0,r,i));if(I)for(var C=0,a=g.length;C0&&(n+=e[I-1].length,i.holes.push(n))}return i};var wut=Ere.exports;const Dre=Ba(wut);var kx={exports:{}};/*! https://mths.be/punycode v1.3.2 by @mathias */kx.exports;(function(e,g){(function(i){var n=g&&!g.nodeType&&g,I=e&&!e.nodeType&&e,r=typeof un=="object"&&un;(r.global===r||r.window===r||r.self===r)&&(i=r);var o,C=2147483647,a=36,A=1,s=26,l=38,c=700,u=72,d=128,h="-",f=/^xn--/,m=/[^\x20-\x7E]/,b=/[\x2E\u3002\uFF0E\uFF61]/g,p={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},y=a-A,Z=Math.floor,v=String.fromCharCode,G;function B(F){throw RangeError(p[F])}function S(F,$){for(var Q=F.length,U=[];Q--;)U[Q]=$(F[Q]);return U}function R(F,$){var Q=F.split("@"),U="";Q.length>1&&(U=Q[0]+"@",F=Q[1]),F=F.replace(b,".");var j=F.split("."),ee=S(j,$).join(".");return U+ee}function w(F){for(var $=[],Q=0,U=F.length,j,ee;Q=55296&&j<=56319&&Q65535&&($-=65536,Q+=v($>>>10&1023|55296),$=56320|$&1023),Q+=v($),Q}).join("")}function W(F){return F-48<10?F-22:F-65<26?F-65:F-97<26?F-97:a}function V(F,$){return F+22+75*(F<26)-(($!=0)<<5)}function X(F,$,Q){var U=0;for(F=Q?Z(F/c):F>>1,F+=Z(F/$);F>y*s>>1;U+=a)F=Z(F/y);return Z(U+(y+1)*F/(F+l))}function N(F){var $=[],Q=F.length,U,j=0,ee=d,Ie=u,fe,Ve,oe,pe,ae,ie,ye,ue,Ye;for(fe=F.lastIndexOf(h),fe<0&&(fe=0),Ve=0;Ve=128&&B("not-basic"),$.push(F.charCodeAt(Ve));for(oe=fe>0?fe+1:0;oe=Q&&B("invalid-input"),ye=W(F.charCodeAt(oe++)),(ye>=a||ye>Z((C-j)/ae))&&B("overflow"),j+=ye*ae,ue=ie<=Ie?A:ie>=Ie+s?s:ie-Ie,!(yeZ(C/Ye)&&B("overflow"),ae*=Ye;U=$.length+1,Ie=X(j-pe,U,pe==0),Z(j/U)>C-ee&&B("overflow"),ee+=Z(j/U),j%=U,$.splice(j++,0,ee)}return T($)}function Y(F){var $,Q,U,j,ee,Ie,fe,Ve,oe,pe,ae,ie=[],ye,ue,Ye,Be;for(F=w(F),ye=F.length,$=d,Q=0,ee=u,Ie=0;Ie=$&&aeZ((C-Q)/ue)&&B("overflow"),Q+=(fe-$)*ue,$=fe,Ie=0;IeC&&B("overflow"),ae==$){for(Ve=Q,oe=a;pe=oe<=ee?A:oe>=ee+s?s:oe-ee,!(Ve0&&C>o&&(C=o);for(var a=0;a=0?(l=A.substr(0,s),c=A.substr(s+1)):(l=A,c=""),u=decodeURIComponent(l),d=decodeURIComponent(c),Vut(I,u)?Array.isArray(I[u])?I[u].push(d):I[u]=[I[u],d]:I[u]=d}return I},PS=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},Xut=function(e,g,i,n){return g=g||"&",i=i||"=",e===null&&(e=void 0),typeof e=="object"?Object.keys(e).map(function(I){var r=encodeURIComponent(PS(I))+i;return Array.isArray(e[I])?e[I].map(function(o){return r+encodeURIComponent(PS(o))}).join(g):r+encodeURIComponent(PS(e[I]))}).join(g):n?encodeURIComponent(PS(n))+i+encodeURIComponent(PS(e)):""};fX.decode=fX.parse=Wut;fX.encode=fX.stringify=Xut;var Tut=Sut,Tl=Rut,Hut=$3,Nut=_ut,kut=Put;function TA(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var Yut=/^([a-z0-9.+-]+:)/i,Kut=/:[0-9]*$/,xut=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Fut=["<",">",'"',"`"," ","\r",` +`," "],Eut=["{","}","|","\\","^","`"].concat(Fut),h8=["'"].concat(Eut),G0e=["%","/","?",";","#"].concat(h8),v0e=["/","?","#"],Dut=255,B0e=/^[+a-z0-9A-Z_-]{0,63}$/,Mut=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,zut={javascript:!0,"javascript:":!0},f8={javascript:!0,"javascript:":!0},Nv={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},m8=fX;function $3(e,g,i){if(e&&Tl.isObject(e)&&e instanceof TA)return e;var n=new TA;return n.parse(e,g,i),n}TA.prototype.parse=function(e,g,i){if(!Tl.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var n=e.indexOf("?"),I=n!==-1&&n127?Z+="x":Z+=y[v];if(!Z.match(B0e)){var B=b.slice(0,u),S=b.slice(u+1),R=y.match(Mut);R&&(B.push(R[1]),S.unshift(R[2])),S.length&&(C="/"+S.join(".")+C),this.hostname=B.join(".");break}}}this.hostname.length>Dut?this.hostname="":this.hostname=this.hostname.toLowerCase(),m||(this.hostname=Tut.toASCII(this.hostname));var w=this.port?":"+this.port:"",T=this.hostname||"";this.host=T+w,this.href+=this.host,m&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),C[0]!=="/"&&(C="/"+C))}if(!zut[s])for(var u=0,p=h8.length;u0?i.host.split("@"):!1;Z&&(i.auth=Z.shift(),i.host=i.hostname=Z.shift())}return i.search=e.search,i.query=e.query,(!Tl.isNull(i.pathname)||!Tl.isNull(i.search))&&(i.path=(i.pathname?i.pathname:"")+(i.search?i.search:"")),i.href=i.format(),i}if(!b.length)return i.pathname=null,i.search?i.path="/"+i.search:i.path=null,i.href=i.format(),i;for(var v=b.slice(-1)[0],G=(i.host||e.host||b.length>1)&&(v==="."||v==="..")||v==="",B=0,S=b.length;S>=0;S--)v=b[S],v==="."?b.splice(S,1):v===".."?(b.splice(S,1),B++):B&&(b.splice(S,1),B--);if(!f&&!m)for(;B--;B)b.unshift("..");f&&b[0]!==""&&(!b[0]||b[0].charAt(0)!=="/")&&b.unshift(""),G&&b.join("/").substr(-1)!=="/"&&b.push("");var R=b[0]===""||b[0]&&b[0].charAt(0)==="/";if(y){i.hostname=i.host=R?"":b.length?b.shift():"";var Z=i.host&&i.host.indexOf("@")>0?i.host.split("@"):!1;Z&&(i.auth=Z.shift(),i.host=i.hostname=Z.shift())}return f=f||i.host&&b.length,f&&!R&&b.unshift(""),b.length?i.pathname=b.join("/"):(i.pathname=null,i.path=null),(!Tl.isNull(i.pathname)||!Tl.isNull(i.search))&&(i.path=(i.pathname?i.pathname:"")+(i.search?i.search:"")),i.auth=e.auth||i.auth,i.slashes=i.slashes||e.slashes,i.href=i.format(),i};TA.prototype.parseHost=function(){var e=this.host,g=Kut.exec(e);g&&(g=g[0],g!==":"&&(this.port=g.substr(1)),e=e.substr(0,e.length-g.length)),e&&(this.hostname=e)};/*! + * @pixi/constants - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/constants is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */var vc;(function(e){e[e.WEBGL_LEGACY=0]="WEBGL_LEGACY",e[e.WEBGL=1]="WEBGL",e[e.WEBGL2=2]="WEBGL2"})(vc||(vc={}));var WB;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.WEBGL=1]="WEBGL",e[e.CANVAS=2]="CANVAS"})(WB||(WB={}));var mX;(function(e){e[e.COLOR=16384]="COLOR",e[e.DEPTH=256]="DEPTH",e[e.STENCIL=1024]="STENCIL"})(mX||(mX={}));var ag;(function(e){e[e.NORMAL=0]="NORMAL",e[e.ADD=1]="ADD",e[e.MULTIPLY=2]="MULTIPLY",e[e.SCREEN=3]="SCREEN",e[e.OVERLAY=4]="OVERLAY",e[e.DARKEN=5]="DARKEN",e[e.LIGHTEN=6]="LIGHTEN",e[e.COLOR_DODGE=7]="COLOR_DODGE",e[e.COLOR_BURN=8]="COLOR_BURN",e[e.HARD_LIGHT=9]="HARD_LIGHT",e[e.SOFT_LIGHT=10]="SOFT_LIGHT",e[e.DIFFERENCE=11]="DIFFERENCE",e[e.EXCLUSION=12]="EXCLUSION",e[e.HUE=13]="HUE",e[e.SATURATION=14]="SATURATION",e[e.COLOR=15]="COLOR",e[e.LUMINOSITY=16]="LUMINOSITY",e[e.NORMAL_NPM=17]="NORMAL_NPM",e[e.ADD_NPM=18]="ADD_NPM",e[e.SCREEN_NPM=19]="SCREEN_NPM",e[e.NONE=20]="NONE",e[e.SRC_OVER=0]="SRC_OVER",e[e.SRC_IN=21]="SRC_IN",e[e.SRC_OUT=22]="SRC_OUT",e[e.SRC_ATOP=23]="SRC_ATOP",e[e.DST_OVER=24]="DST_OVER",e[e.DST_IN=25]="DST_IN",e[e.DST_OUT=26]="DST_OUT",e[e.DST_ATOP=27]="DST_ATOP",e[e.ERASE=26]="ERASE",e[e.SUBTRACT=28]="SUBTRACT",e[e.XOR=29]="XOR"})(ag||(ag={}));var ja;(function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN"})(ja||(ja={}));var vt;(function(e){e[e.RGBA=6408]="RGBA",e[e.RGB=6407]="RGB",e[e.RG=33319]="RG",e[e.RED=6403]="RED",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.ALPHA=6406]="ALPHA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL"})(vt||(vt={}));var Jf;(function(e){e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z"})(Jf||(Jf={}));var ng;(function(e){e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.BYTE=5120]="BYTE",e[e.SHORT=5122]="SHORT",e[e.INT=5124]="INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.HALF_FLOAT=36193]="HALF_FLOAT"})(ng||(ng={}));var pX;(function(e){e[e.FLOAT=0]="FLOAT",e[e.INT=1]="INT",e[e.UINT=2]="UINT"})(pX||(pX={}));var ql;(function(e){e[e.NEAREST=0]="NEAREST",e[e.LINEAR=1]="LINEAR"})(ql||(ql={}));var Cc;(function(e){e[e.CLAMP=33071]="CLAMP",e[e.REPEAT=10497]="REPEAT",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"})(Cc||(Cc={}));var Bc;(function(e){e[e.OFF=0]="OFF",e[e.POW2=1]="POW2",e[e.ON=2]="ON",e[e.ON_MANUAL=3]="ON_MANUAL"})(Bc||(Bc={}));var cs;(function(e){e[e.NPM=0]="NPM",e[e.UNPACK=1]="UNPACK",e[e.PMA=2]="PMA",e[e.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",e[e.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",e[e.PREMULTIPLY_ALPHA=2]="PREMULTIPLY_ALPHA",e[e.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA"})(cs||(cs={}));var Nu;(function(e){e[e.NO=0]="NO",e[e.YES=1]="YES",e[e.AUTO=2]="AUTO",e[e.BLEND=0]="BLEND",e[e.CLEAR=1]="CLEAR",e[e.BLIT=2]="BLIT"})(Nu||(Nu={}));var Yx;(function(e){e[e.AUTO=0]="AUTO",e[e.MANUAL=1]="MANUAL"})(Yx||(Yx={}));var ZA;(function(e){e.LOW="lowp",e.MEDIUM="mediump",e.HIGH="highp"})(ZA||(ZA={}));var qn;(function(e){e[e.NONE=0]="NONE",e[e.SCISSOR=1]="SCISSOR",e[e.STENCIL=2]="STENCIL",e[e.SPRITE=3]="SPRITE",e[e.COLOR=4]="COLOR"})(qn||(qn={}));var p8;(function(e){e[e.RED=1]="RED",e[e.GREEN=2]="GREEN",e[e.BLUE=4]="BLUE",e[e.ALPHA=8]="ALPHA"})(p8||(p8={}));var Un;(function(e){e[e.NONE=0]="NONE",e[e.LOW=2]="LOW",e[e.MEDIUM=4]="MEDIUM",e[e.HIGH=8]="HIGH"})(Un||(Un={}));var HA;(function(e){e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER"})(HA||(HA={}));/*! + * @pixi/utils - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/utils is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */var p0={parse:Hut,format:kut,resolve:Nut};function Ws(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function Out(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Jut(e,g,i){return e.replace(new RegExp(Out(g),"g"),i)}function Lut(e,g){for(var i="",n=0,I=-1,r=0,o,C=0;C<=e.length;++C){if(C2){var a=i.lastIndexOf("/");if(a!==i.length-1){a===-1?(i="",n=0):(i=i.slice(0,a),n=i.length-1-i.lastIndexOf("/")),I=C,r=0;continue}}else if(i.length===2||i.length===1){i="",n=0,I=C,r=0;continue}}g&&(i.length>0?i+="/..":i="..",n=2)}else i.length>0?i+="/"+e.slice(I+1,C):i=e.slice(I+1,C),n=C-I-1;I=C,r=0}else o===46&&r!==-1?++r:r=-1}return i}var Oxe={toPosix:function(e){return Jut(e,"\\","/")},isUrl:function(e){return/^https?:/.test(this.toPosix(e))},isDataUrl:function(e){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(e)},hasProtocol:function(e){return/^[^/:]+:\//.test(this.toPosix(e))},getProtocol:function(e){Ws(e),e=this.toPosix(e);var g="",i=/^file:\/\/\//.exec(e),n=/^[^/:]+:\/\//.exec(e),I=/^[^/:]+:\//.exec(e);if(i||n||I){var r=i?.[0]||n?.[0]||I?.[0];g=r,e=e.slice(r.length)}return g},toAbsolute:function(e,g,i){if(this.isDataUrl(e))return e;var n=this.toPosix(g??Ht.ADAPTER.getBaseUrl()),I=this.toPosix(i??this.rootname(n));if(Ws(e),e=this.toPosix(e),e.startsWith("/"))return Oxe.join(I,e.slice(1));var r=this.isAbsolute(e)?e:this.join(n,e);return r},normalize:function(e){if(e=this.toPosix(e),Ws(e),e.length===0)return".";var g="",i=e.startsWith("/");this.hasProtocol(e)&&(g=this.rootname(e),e=e.slice(g.length));var n=e.endsWith("/");return e=Lut(e,!1),e.length>0&&n&&(e+="/"),i?"/"+e:g+e},isAbsolute:function(e){return Ws(e),e=this.toPosix(e),this.hasProtocol(e)?!0:e.startsWith("/")},join:function(){for(var e=arguments,g=[],i=0;i0&&(n===void 0?n=r:n+="/"+r)}return n===void 0?".":this.normalize(n)},dirname:function(e){if(Ws(e),e.length===0)return".";e=this.toPosix(e);var g=e.charCodeAt(0),i=g===47,n=-1,I=!0,r=this.getProtocol(e),o=e;e=e.slice(r.length);for(var C=e.length-1;C>=1;--C)if(g=e.charCodeAt(C),g===47){if(!I){n=C;break}}else I=!1;return n===-1?i?"/":this.isUrl(o)?r+e:r:i&&n===1?"//":r+e.slice(0,n)},rootname:function(e){Ws(e),e=this.toPosix(e);var g="";if(e.startsWith("/")?g="/":g=this.getProtocol(e),this.isUrl(e)){var i=e.indexOf("/",g.length);i!==-1?g=e.slice(0,i):g=e,g.endsWith("/")||(g+="/")}return g},basename:function(e,g){Ws(e),g&&Ws(g),e=this.toPosix(e);var i=0,n=-1,I=!0,r;if(g!==void 0&&g.length>0&&g.length<=e.length){if(g.length===e.length&&g===e)return"";var o=g.length-1,C=-1;for(r=e.length-1;r>=0;--r){var a=e.charCodeAt(r);if(a===47){if(!I){i=r+1;break}}else C===-1&&(I=!1,C=r+1),o>=0&&(a===g.charCodeAt(o)?--o===-1&&(n=r):(o=-1,n=C))}return i===n?n=C:n===-1&&(n=e.length),e.slice(i,n)}for(r=e.length-1;r>=0;--r)if(e.charCodeAt(r)===47){if(!I){i=r+1;break}}else n===-1&&(I=!1,n=r+1);return n===-1?"":e.slice(i,n)},extname:function(e){Ws(e),e=this.toPosix(e);for(var g=-1,i=0,n=-1,I=!0,r=0,o=e.length-1;o>=0;--o){var C=e.charCodeAt(o);if(C===47){if(!I){i=o+1;break}continue}n===-1&&(I=!1,n=o+1),C===46?g===-1?g=o:r!==1&&(r=1):g!==-1&&(r=-1)}return g===-1||n===-1||r===0||r===1&&g===n-1&&g===i+1?"":e.slice(g,n)},parse:function(e){Ws(e);var g={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return g;e=this.toPosix(e);var i=e.charCodeAt(0),n=this.isAbsolute(e),I;g.root=this.rootname(e),n||this.hasProtocol(e)?I=1:I=0;for(var r=-1,o=0,C=-1,a=!0,A=e.length-1,s=0;A>=I;--A){if(i=e.charCodeAt(A),i===47){if(!a){o=A+1;break}continue}C===-1&&(a=!1,C=A+1),i===46?r===-1?r=A:s!==1&&(s=1):r!==-1&&(s=-1)}return r===-1||C===-1||s===0||s===1&&r===C-1&&r===o+1?C!==-1&&(o===0&&n?g.base=g.name=e.slice(1,C):g.base=g.name=e.slice(o,C)):(o===0&&n?(g.name=e.slice(1,r),g.base=e.slice(1,C)):(g.name=e.slice(o,r),g.base=e.slice(o,C)),g.ext=e.slice(r,C)),g.dir=this.dirname(e),g},sep:"/",delimiter:":"};Ht.RETINA_PREFIX=/@([0-9\.]+)x/;Ht.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var b8=!1,w0e="6.5.2";function Uut(){b8=!0}function Jxe(e){var g;if(!b8){if(Ht.ADAPTER.getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){var i=[` + %c %c %c PixiJS `+w0e+" - ✰ "+e+` ✰ %c %c http://www.pixijs.com/ %c %c ♥%c♥%c♥ + +`,"background: #ff66a5; padding:5px 0;","background: #ff66a5; padding:5px 0;","color: #ff66a5; background: #030307; padding:5px 0;","background: #ff66a5; padding:5px 0;","background: #ffc3dc; padding:5px 0;","background: #ff66a5; padding:5px 0;","color: #ff2424; background: #fff; padding:5px 0;","color: #ff2424; background: #fff; padding:5px 0;","color: #ff2424; background: #fff; padding:5px 0;"];(g=globalThis.console).log.apply(g,i)}else globalThis.console&&globalThis.console.log("PixiJS "+w0e+" - "+e+" - http://www.pixijs.com/");b8=!0}}var pL;function Lxe(){return typeof pL>"u"&&(pL=function(){var g={stencil:!0,failIfMajorPerformanceCaveat:Ht.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!Ht.ADAPTER.getWebGLRenderingContext())return!1;var i=Ht.ADAPTER.createCanvas(),n=i.getContext("webgl",g)||i.getContext("experimental-webgl",g),I=!!(n&&n.getContextAttributes().stencil);if(n){var r=n.getExtension("WEBGL_lose_context");r&&r.loseContext()}return n=null,I}catch{return!1}}()),pL}var Qut="#f0f8ff",jut="#faebd7",$ut="#00ffff",qut="#7fffd4",edt="#f0ffff",tdt="#f5f5dc",gdt="#ffe4c4",idt="#000000",ndt="#ffebcd",Idt="#0000ff",rdt="#8a2be2",odt="#a52a2a",Cdt="#deb887",adt="#5f9ea0",sdt="#7fff00",Adt="#d2691e",ldt="#ff7f50",cdt="#6495ed",udt="#fff8dc",ddt="#dc143c",hdt="#00ffff",fdt="#00008b",mdt="#008b8b",pdt="#b8860b",bdt="#a9a9a9",ydt="#006400",Zdt="#a9a9a9",Gdt="#bdb76b",vdt="#8b008b",Bdt="#556b2f",wdt="#ff8c00",Sdt="#9932cc",Rdt="#8b0000",Vdt="#e9967a",Wdt="#8fbc8f",Xdt="#483d8b",Tdt="#2f4f4f",Hdt="#2f4f4f",Ndt="#00ced1",kdt="#9400d3",Ydt="#ff1493",Kdt="#00bfff",xdt="#696969",Fdt="#696969",Edt="#1e90ff",Ddt="#b22222",Mdt="#fffaf0",zdt="#228b22",Pdt="#ff00ff",_dt="#dcdcdc",Odt="#f8f8ff",Jdt="#daa520",Ldt="#ffd700",Udt="#808080",Qdt="#008000",jdt="#adff2f",$dt="#808080",qdt="#f0fff0",eht="#ff69b4",tht="#cd5c5c",ght="#4b0082",iht="#fffff0",nht="#f0e68c",Iht="#fff0f5",rht="#e6e6fa",oht="#7cfc00",Cht="#fffacd",aht="#add8e6",sht="#f08080",Aht="#e0ffff",lht="#fafad2",cht="#d3d3d3",uht="#90ee90",dht="#d3d3d3",hht="#ffb6c1",fht="#ffa07a",mht="#20b2aa",pht="#87cefa",bht="#778899",yht="#778899",Zht="#b0c4de",Ght="#ffffe0",vht="#00ff00",Bht="#32cd32",wht="#faf0e6",Sht="#ff00ff",Rht="#800000",Vht="#66cdaa",Wht="#0000cd",Xht="#ba55d3",Tht="#9370db",Hht="#3cb371",Nht="#7b68ee",kht="#00fa9a",Yht="#48d1cc",Kht="#c71585",xht="#191970",Fht="#f5fffa",Eht="#ffe4e1",Dht="#ffe4b5",Mht="#ffdead",zht="#000080",Pht="#fdf5e6",_ht="#808000",Oht="#6b8e23",Jht="#ffa500",Lht="#ff4500",Uht="#da70d6",Qht="#eee8aa",jht="#98fb98",$ht="#afeeee",qht="#db7093",eft="#ffefd5",tft="#ffdab9",gft="#cd853f",ift="#ffc0cb",nft="#dda0dd",Ift="#b0e0e6",rft="#800080",oft="#663399",Cft="#ff0000",aft="#bc8f8f",sft="#4169e1",Aft="#8b4513",lft="#fa8072",cft="#f4a460",uft="#2e8b57",dft="#fff5ee",hft="#a0522d",fft="#c0c0c0",mft="#87ceeb",pft="#6a5acd",bft="#708090",yft="#708090",Zft="#fffafa",Gft="#00ff7f",vft="#4682b4",Bft="#d2b48c",wft="#008080",Sft="#d8bfd8",Rft="#ff6347",Vft="#40e0d0",Wft="#ee82ee",Xft="#f5deb3",Tft="#ffffff",Hft="#f5f5f5",Nft="#ffff00",kft="#9acd32",Yft={aliceblue:Qut,antiquewhite:jut,aqua:$ut,aquamarine:qut,azure:edt,beige:tdt,bisque:gdt,black:idt,blanchedalmond:ndt,blue:Idt,blueviolet:rdt,brown:odt,burlywood:Cdt,cadetblue:adt,chartreuse:sdt,chocolate:Adt,coral:ldt,cornflowerblue:cdt,cornsilk:udt,crimson:ddt,cyan:hdt,darkblue:fdt,darkcyan:mdt,darkgoldenrod:pdt,darkgray:bdt,darkgreen:ydt,darkgrey:Zdt,darkkhaki:Gdt,darkmagenta:vdt,darkolivegreen:Bdt,darkorange:wdt,darkorchid:Sdt,darkred:Rdt,darksalmon:Vdt,darkseagreen:Wdt,darkslateblue:Xdt,darkslategray:Tdt,darkslategrey:Hdt,darkturquoise:Ndt,darkviolet:kdt,deeppink:Ydt,deepskyblue:Kdt,dimgray:xdt,dimgrey:Fdt,dodgerblue:Edt,firebrick:Ddt,floralwhite:Mdt,forestgreen:zdt,fuchsia:Pdt,gainsboro:_dt,ghostwhite:Odt,goldenrod:Jdt,gold:Ldt,gray:Udt,green:Qdt,greenyellow:jdt,grey:$dt,honeydew:qdt,hotpink:eht,indianred:tht,indigo:ght,ivory:iht,khaki:nht,lavenderblush:Iht,lavender:rht,lawngreen:oht,lemonchiffon:Cht,lightblue:aht,lightcoral:sht,lightcyan:Aht,lightgoldenrodyellow:lht,lightgray:cht,lightgreen:uht,lightgrey:dht,lightpink:hht,lightsalmon:fht,lightseagreen:mht,lightskyblue:pht,lightslategray:bht,lightslategrey:yht,lightsteelblue:Zht,lightyellow:Ght,lime:vht,limegreen:Bht,linen:wht,magenta:Sht,maroon:Rht,mediumaquamarine:Vht,mediumblue:Wht,mediumorchid:Xht,mediumpurple:Tht,mediumseagreen:Hht,mediumslateblue:Nht,mediumspringgreen:kht,mediumturquoise:Yht,mediumvioletred:Kht,midnightblue:xht,mintcream:Fht,mistyrose:Eht,moccasin:Dht,navajowhite:Mht,navy:zht,oldlace:Pht,olive:_ht,olivedrab:Oht,orange:Jht,orangered:Lht,orchid:Uht,palegoldenrod:Qht,palegreen:jht,paleturquoise:$ht,palevioletred:qht,papayawhip:eft,peachpuff:tft,peru:gft,pink:ift,plum:nft,powderblue:Ift,purple:rft,rebeccapurple:oft,red:Cft,rosybrown:aft,royalblue:sft,saddlebrown:Aft,salmon:lft,sandybrown:cft,seagreen:uft,seashell:dft,sienna:hft,silver:fft,skyblue:mft,slateblue:pft,slategray:bft,slategrey:yft,snow:Zft,springgreen:Gft,steelblue:vft,tan:Bft,teal:wft,thistle:Sft,tomato:Rft,turquoise:Vft,violet:Wft,wheat:Xft,white:Tft,whitesmoke:Hft,yellow:Nft,yellowgreen:kft};function pb(e,g){return g===void 0&&(g=[]),g[0]=(e>>16&255)/255,g[1]=(e>>8&255)/255,g[2]=(e&255)/255,g}function Mre(e){var g=e.toString(16);return g="000000".substring(0,6-g.length)+g,"#"+g}function zre(e){return typeof e=="string"&&(e=Yft[e.toLowerCase()]||e,e[0]==="#"&&(e=e.slice(1))),parseInt(e,16)}function Uxe(e){return(e[0]*255<<16)+(e[1]*255<<8)+(e[2]*255|0)}function Kft(){for(var e=[],g=[],i=0;i<32;i++)e[i]=i,g[i]=i;e[ag.NORMAL_NPM]=ag.NORMAL,e[ag.ADD_NPM]=ag.ADD,e[ag.SCREEN_NPM]=ag.SCREEN,g[ag.NORMAL]=ag.NORMAL_NPM,g[ag.ADD]=ag.ADD_NPM,g[ag.SCREEN]=ag.SCREEN_NPM;var n=[];return n.push(g),n.push(e),n}var Pre=Kft();function _re(e,g){return Pre[g?1:0][e]}function Qxe(e,g,i,n){return i=i||new Float32Array(4),n||n===void 0?(i[0]=e[0]*g,i[1]=e[1]*g,i[2]=e[2]*g):(i[0]=e[0],i[1]=e[1],i[2]=e[2]),i[3]=g,i}function q3(e,g){if(g===1)return(g*255<<24)+e;if(g===0)return 0;var i=e>>16&255,n=e>>8&255,I=e&255;return i=i*g+.5|0,n=n*g+.5|0,I=I*g+.5|0,(g*255<<24)+(i<<16)+(n<<8)+I}function Ore(e,g,i,n){return i=i||new Float32Array(4),i[0]=(e>>16&255)/255,i[1]=(e>>8&255)/255,i[2]=(e&255)/255,(n||n===void 0)&&(i[0]*=g,i[1]*=g,i[2]*=g),i[3]=g,i}function jxe(e,g){g===void 0&&(g=null);var i=e*6;if(g=g||new Uint16Array(i),g.length!==i)throw new Error("Out buffer length is incorrect, got "+g.length+" and expected "+i);for(var n=0,I=0;n>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e+1}function y8(e){return!(e&e-1)&&!!e}function Z8(e){var g=(e>65535?1:0)<<4;e>>>=g;var i=(e>255?1:0)<<3;return e>>>=i,g|=i,i=(e>15?1:0)<<2,e>>>=i,g|=i,i=(e>3?1:0)<<1,e>>>=i,g|=i,g|e>>1}function E0(e,g,i){var n=e.length,I;if(!(g>=n||i===0)){i=g+i>n?n-g:i;var r=n-i;for(I=g;I"u"?console.warn("PixiJS Deprecation Warning: ",g+` +Deprecated since v`+e):(n=n.split(` +`).splice(i).join(` +`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",g+` +Deprecated since v`+e),console.warn(n),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",g+` +Deprecated since v`+e),console.warn(n))),S0e[g]=!0}}var G8={},aC=Object.create(null),Da=Object.create(null);function Dft(){var e;for(e in aC)aC[e].destroy();for(e in Da)Da[e].destroy()}function Mft(){var e;for(e in aC)delete aC[e];for(e in Da)delete Da[e]}var v8=function(){function e(g,i,n){this.canvas=Ht.ADAPTER.createCanvas(),this.context=this.canvas.getContext("2d"),this.resolution=n||Ht.RESOLUTION,this.resize(g,i)}return e.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height)},e.prototype.resize=function(g,i){this.canvas.width=Math.round(g*this.resolution),this.canvas.height=Math.round(i*this.resolution)},e.prototype.destroy=function(){this.context=null,this.canvas=null},Object.defineProperty(e.prototype,"width",{get:function(){return this.canvas.width},set:function(g){this.canvas.width=Math.round(g)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this.canvas.height},set:function(g){this.canvas.height=Math.round(g)},enumerable:!1,configurable:!0}),e}();function $xe(e){var g=e.width,i=e.height,n=e.getContext("2d"),I=n.getImageData(0,0,g,i),r=I.data,o=r.length,C={top:null,left:null,right:null,bottom:null},a=null,A,s,l;for(A=0;A=this.x&&g=this.y&&ig.right?g.right:this.right;if(I<=n)return!1;var r=this.yg.bottom?g.bottom:this.bottom;return o>r}var C=this.left,a=this.right,A=this.top,s=this.bottom;if(a<=C||s<=A)return!1;var l=MN[0].set(g.left,g.top),c=MN[1].set(g.left,g.bottom),u=MN[2].set(g.right,g.top),d=MN[3].set(g.right,g.bottom);if(u.x<=l.x||c.y<=l.y)return!1;var h=Math.sign(i.a*i.d-i.b*i.c);if(h===0||(i.apply(l,l),i.apply(c,c),i.apply(u,u),i.apply(d,d),Math.max(l.x,c.x,u.x,d.x)<=C||Math.min(l.x,c.x,u.x,d.x)>=a||Math.max(l.y,c.y,u.y,d.y)<=A||Math.min(l.y,c.y,u.y,d.y)>=s))return!1;var f=h*(c.y-l.y),m=h*(l.x-c.x),b=f*C+m*A,p=f*a+m*A,y=f*C+m*s,Z=f*a+m*s;if(Math.max(b,p,y,Z)<=f*l.x+m*l.y||Math.min(b,p,y,Z)>=f*d.x+m*d.y)return!1;var v=h*(l.y-u.y),G=h*(u.x-l.x),B=v*C+G*A,S=v*a+G*A,R=v*C+G*s,w=v*a+G*s;return!(Math.max(B,S,R,w)<=v*l.x+G*l.y||Math.min(B,S,R,w)>=v*d.x+G*d.y)},e.prototype.pad=function(g,i){return g===void 0&&(g=0),i===void 0&&(i=g),this.x-=g,this.y-=i,this.width+=g*2,this.height+=i*2,this},e.prototype.fit=function(g){var i=Math.max(this.x,g.x),n=Math.min(this.x+this.width,g.x+g.width),I=Math.max(this.y,g.y),r=Math.min(this.y+this.height,g.y+g.height);return this.x=i,this.width=Math.max(n-i,0),this.y=I,this.height=Math.max(r-I,0),this},e.prototype.ceil=function(g,i){g===void 0&&(g=1),i===void 0&&(i=.001);var n=Math.ceil((this.x+this.width-i)*g)/g,I=Math.ceil((this.y+this.height-i)*g)/g;return this.x=Math.floor((this.x+i)*g)/g,this.y=Math.floor((this.y+i)*g)/g,this.width=n-this.x,this.height=I-this.y,this},e.prototype.enlarge=function(g){var i=Math.min(this.x,g.x),n=Math.max(this.x+this.width,g.x+g.width),I=Math.min(this.y,g.y),r=Math.max(this.y+this.height,g.y+g.height);return this.x=i,this.width=n-i,this.y=I,this.height=r-I,this},e.prototype.toString=function(){return"[@pixi/math:Rectangle x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+"]"},e}(),iFe=function(){function e(g,i,n){g===void 0&&(g=0),i===void 0&&(i=0),n===void 0&&(n=0),this.x=g,this.y=i,this.radius=n,this.type=hI.CIRC}return e.prototype.clone=function(){return new e(this.x,this.y,this.radius)},e.prototype.contains=function(g,i){if(this.radius<=0)return!1;var n=this.radius*this.radius,I=this.x-g,r=this.y-i;return I*=I,r*=r,I+r<=n},e.prototype.getBounds=function(){return new Lg(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)},e.prototype.toString=function(){return"[@pixi/math:Circle x="+this.x+" y="+this.y+" radius="+this.radius+"]"},e}(),nFe=function(){function e(g,i,n,I){g===void 0&&(g=0),i===void 0&&(i=0),n===void 0&&(n=0),I===void 0&&(I=0),this.x=g,this.y=i,this.width=n,this.height=I,this.type=hI.ELIP}return e.prototype.clone=function(){return new e(this.x,this.y,this.width,this.height)},e.prototype.contains=function(g,i){if(this.width<=0||this.height<=0)return!1;var n=(g-this.x)/this.width,I=(i-this.y)/this.height;return n*=n,I*=I,n+I<=1},e.prototype.getBounds=function(){return new Lg(this.x-this.width,this.y-this.height,this.width,this.height)},e.prototype.toString=function(){return"[@pixi/math:Ellipse x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+"]"},e}(),Y2=function(){function e(){for(var g=arguments,i=[],n=0;ni!=s>i&&g<(A-C)*((i-a)/(s-a))+C;l&&(n=!n)}return n},e.prototype.toString=function(){return"[@pixi/math:Polygon"+("closeStroke="+this.closeStroke)+("points="+this.points.reduce(function(g,i){return g+", "+i},"")+"]")},e}(),IFe=function(){function e(g,i,n,I,r){g===void 0&&(g=0),i===void 0&&(i=0),n===void 0&&(n=0),I===void 0&&(I=0),r===void 0&&(r=20),this.x=g,this.y=i,this.width=n,this.height=I,this.radius=r,this.type=hI.RREC}return e.prototype.clone=function(){return new e(this.x,this.y,this.width,this.height,this.radius)},e.prototype.contains=function(g,i){if(this.width<=0||this.height<=0)return!1;if(g>=this.x&&g<=this.x+this.width&&i>=this.y&&i<=this.y+this.height){var n=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(i>=this.y+n&&i<=this.y+this.height-n||g>=this.x+n&&g<=this.x+this.width-n)return!0;var I=g-(this.x+n),r=i-(this.y+n),o=n*n;if(I*I+r*r<=o||(I=g-(this.x+this.width-n),I*I+r*r<=o)||(r=i-(this.y+this.height-n),I*I+r*r<=o)||(I=g-(this.x+n),I*I+r*r<=o))return!0}return!1},e.prototype.toString=function(){return"[@pixi/math:RoundedRectangle x="+this.x+" y="+this.y+("width="+this.width+" height="+this.height+" radius="+this.radius+"]")},e}(),y0=function(){function e(g,i,n,I){n===void 0&&(n=0),I===void 0&&(I=0),this._x=n,this._y=I,this.cb=g,this.scope=i}return e.prototype.clone=function(g,i){return g===void 0&&(g=this.cb),i===void 0&&(i=this.scope),new e(g,i,this._x,this._y)},e.prototype.set=function(g,i){return g===void 0&&(g=0),i===void 0&&(i=g),(this._x!==g||this._y!==i)&&(this._x=g,this._y=i,this.cb.call(this.scope)),this},e.prototype.copyFrom=function(g){return(this._x!==g.x||this._y!==g.y)&&(this._x=g.x,this._y=g.y,this.cb.call(this.scope)),this},e.prototype.copyTo=function(g){return g.set(this._x,this._y),g},e.prototype.equals=function(g){return g.x===this._x&&g.y===this._y},e.prototype.toString=function(){return"[@pixi/math:ObservablePoint x=0 y=0 scope="+this.scope+"]"},Object.defineProperty(e.prototype,"x",{get:function(){return this._x},set:function(g){this._x!==g&&(this._x=g,this.cb.call(this.scope))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},set:function(g){this._y!==g&&(this._y=g,this.cb.call(this.scope))},enumerable:!1,configurable:!0}),e}(),rI=function(){function e(g,i,n,I,r,o){g===void 0&&(g=1),i===void 0&&(i=0),n===void 0&&(n=0),I===void 0&&(I=1),r===void 0&&(r=0),o===void 0&&(o=0),this.array=null,this.a=g,this.b=i,this.c=n,this.d=I,this.tx=r,this.ty=o}return e.prototype.fromArray=function(g){this.a=g[0],this.b=g[1],this.c=g[3],this.d=g[4],this.tx=g[2],this.ty=g[5]},e.prototype.set=function(g,i,n,I,r,o){return this.a=g,this.b=i,this.c=n,this.d=I,this.tx=r,this.ty=o,this},e.prototype.toArray=function(g,i){this.array||(this.array=new Float32Array(9));var n=i||this.array;return g?(n[0]=this.a,n[1]=this.b,n[2]=0,n[3]=this.c,n[4]=this.d,n[5]=0,n[6]=this.tx,n[7]=this.ty,n[8]=1):(n[0]=this.a,n[1]=this.c,n[2]=this.tx,n[3]=this.b,n[4]=this.d,n[5]=this.ty,n[6]=0,n[7]=0,n[8]=1),n},e.prototype.apply=function(g,i){i=i||new _i;var n=g.x,I=g.y;return i.x=this.a*n+this.c*I+this.tx,i.y=this.b*n+this.d*I+this.ty,i},e.prototype.applyInverse=function(g,i){i=i||new _i;var n=1/(this.a*this.d+this.c*-this.b),I=g.x,r=g.y;return i.x=this.d*n*I+-this.c*n*r+(this.ty*this.c-this.tx*this.d)*n,i.y=this.a*n*r+-this.b*n*I+(-this.ty*this.a+this.tx*this.b)*n,i},e.prototype.translate=function(g,i){return this.tx+=g,this.ty+=i,this},e.prototype.scale=function(g,i){return this.a*=g,this.d*=i,this.c*=g,this.b*=i,this.tx*=g,this.ty*=i,this},e.prototype.rotate=function(g){var i=Math.cos(g),n=Math.sin(g),I=this.a,r=this.c,o=this.tx;return this.a=I*i-this.b*n,this.b=I*n+this.b*i,this.c=r*i-this.d*n,this.d=r*n+this.d*i,this.tx=o*i-this.ty*n,this.ty=o*n+this.ty*i,this},e.prototype.append=function(g){var i=this.a,n=this.b,I=this.c,r=this.d;return this.a=g.a*i+g.b*I,this.b=g.a*n+g.b*r,this.c=g.c*i+g.d*I,this.d=g.c*n+g.d*r,this.tx=g.tx*i+g.ty*I+this.tx,this.ty=g.tx*n+g.ty*r+this.ty,this},e.prototype.setTransform=function(g,i,n,I,r,o,C,a,A){return this.a=Math.cos(C+A)*r,this.b=Math.sin(C+A)*r,this.c=-Math.sin(C-a)*o,this.d=Math.cos(C-a)*o,this.tx=g-(n*this.a+I*this.c),this.ty=i-(n*this.b+I*this.d),this},e.prototype.prepend=function(g){var i=this.tx;if(g.a!==1||g.b!==0||g.c!==0||g.d!==1){var n=this.a,I=this.c;this.a=n*g.a+this.b*g.c,this.b=n*g.b+this.b*g.d,this.c=I*g.a+this.d*g.c,this.d=I*g.b+this.d*g.d}return this.tx=i*g.a+this.ty*g.c+g.tx,this.ty=i*g.b+this.ty*g.d+g.ty,this},e.prototype.decompose=function(g){var i=this.a,n=this.b,I=this.c,r=this.d,o=g.pivot,C=-Math.atan2(-I,r),a=Math.atan2(n,i),A=Math.abs(C+a);return A<1e-5||Math.abs(ZX-A)<1e-5?(g.rotation=a,g.skew.x=g.skew.y=0):(g.rotation=0,g.skew.x=C,g.skew.y=a),g.scale.x=Math.sqrt(i*i+n*n),g.scale.y=Math.sqrt(I*I+r*r),g.position.x=this.tx+(o.x*i+o.y*I),g.position.y=this.ty+(o.x*n+o.y*r),g},e.prototype.invert=function(){var g=this.a,i=this.b,n=this.c,I=this.d,r=this.tx,o=g*I-i*n;return this.a=I/o,this.b=-i/o,this.c=-n/o,this.d=g/o,this.tx=(n*this.ty-I*r)/o,this.ty=-(g*this.ty-i*r)/o,this},e.prototype.identity=function(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this},e.prototype.clone=function(){var g=new e;return g.a=this.a,g.b=this.b,g.c=this.c,g.d=this.d,g.tx=this.tx,g.ty=this.ty,g},e.prototype.copyTo=function(g){return g.a=this.a,g.b=this.b,g.c=this.c,g.d=this.d,g.tx=this.tx,g.ty=this.ty,g},e.prototype.copyFrom=function(g){return this.a=g.a,this.b=g.b,this.c=g.c,this.d=g.d,this.tx=g.tx,this.ty=g.ty,this},e.prototype.toString=function(){return"[@pixi/math:Matrix a="+this.a+" b="+this.b+" c="+this.c+" d="+this.d+" tx="+this.tx+" ty="+this.ty+"]"},Object.defineProperty(e,"IDENTITY",{get:function(){return new e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"TEMP_MATRIX",{get:function(){return new e},enumerable:!1,configurable:!0}),e}(),Lp=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Up=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Qp=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],jp=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],B8=[],rFe=[],zN=Math.sign;function _ft(){for(var e=0;e<16;e++){var g=[];B8.push(g);for(var i=0;i<16;i++)for(var n=zN(Lp[e]*Lp[i]+Qp[e]*Up[i]),I=zN(Up[e]*Lp[i]+jp[e]*Up[i]),r=zN(Lp[e]*Qp[i]+Qp[e]*jp[i]),o=zN(Up[e]*Qp[i]+jp[e]*jp[i]),C=0;C<16;C++)if(Lp[C]===n&&Up[C]===I&&Qp[C]===r&&jp[C]===o){g.push(C);break}}for(var e=0;e<16;e++){var a=new rI;a.set(Lp[e],Up[e],Qp[e],jp[e],0,0),rFe.push(a)}}_ft();var sn={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:function(e){return Lp[e]},uY:function(e){return Up[e]},vX:function(e){return Qp[e]},vY:function(e){return jp[e]},inv:function(e){return e&8?e&15:-e&7},add:function(e,g){return B8[e][g]},sub:function(e,g){return B8[e][sn.inv(g)]},rotate180:function(e){return e^4},isVertical:function(e){return(e&3)===2},byDirection:function(e,g){return Math.abs(e)*2<=Math.abs(g)?g>=0?sn.S:sn.N:Math.abs(g)*2<=Math.abs(e)?e>0?sn.E:sn.W:g>0?e>0?sn.SE:sn.SW:e>0?sn.NE:sn.NW},matrixAppendRotationInv:function(e,g,i,n){i===void 0&&(i=0),n===void 0&&(n=0);var I=rFe[sn.inv(g)];I.tx=i,I.ty=n,e.append(I)}},Jre=function(){function e(){this.worldTransform=new rI,this.localTransform=new rI,this.position=new y0(this.onChange,this,0,0),this.scale=new y0(this.onChange,this,1,1),this.pivot=new y0(this.onChange,this,0,0),this.skew=new y0(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}return e.prototype.onChange=function(){this._localID++},e.prototype.updateSkew=function(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++},e.prototype.toString=function(){return"[@pixi/math:Transform "+("position=("+this.position.x+", "+this.position.y+") ")+("rotation="+this.rotation+" ")+("scale=("+this.scale.x+", "+this.scale.y+") ")+("skew=("+this.skew.x+", "+this.skew.y+") ")+"]"},e.prototype.updateLocalTransform=function(){var g=this.localTransform;this._localID!==this._currentLocalID&&(g.a=this._cx*this.scale.x,g.b=this._sx*this.scale.x,g.c=this._cy*this.scale.y,g.d=this._sy*this.scale.y,g.tx=this.position.x-(this.pivot.x*g.a+this.pivot.y*g.c),g.ty=this.position.y-(this.pivot.x*g.b+this.pivot.y*g.d),this._currentLocalID=this._localID,this._parentID=-1)},e.prototype.updateTransform=function(g){var i=this.localTransform;if(this._localID!==this._currentLocalID&&(i.a=this._cx*this.scale.x,i.b=this._sx*this.scale.x,i.c=this._cy*this.scale.y,i.d=this._sy*this.scale.y,i.tx=this.position.x-(this.pivot.x*i.a+this.pivot.y*i.c),i.ty=this.position.y-(this.pivot.x*i.b+this.pivot.y*i.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==g._worldID){var n=g.worldTransform,I=this.worldTransform;I.a=i.a*n.a+i.b*n.c,I.b=i.a*n.b+i.b*n.d,I.c=i.c*n.a+i.d*n.c,I.d=i.c*n.b+i.d*n.d,I.tx=i.tx*n.a+i.ty*n.c+n.tx,I.ty=i.tx*n.b+i.ty*n.d+n.ty,this._parentID=g._worldID,this._worldID++}},e.prototype.setFromMatrix=function(g){g.decompose(this),this._localID++},Object.defineProperty(e.prototype,"rotation",{get:function(){return this._rotation},set:function(g){this._rotation!==g&&(this._rotation=g,this.updateSkew())},enumerable:!1,configurable:!0}),e.IDENTITY=new e,e}();/*! + * @pixi/display - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/display is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */Ht.SORTABLE_CHILDREN=!1;var GX=function(){function e(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}return e.prototype.isEmpty=function(){return this.minX>this.maxX||this.minY>this.maxY},e.prototype.clear=function(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0},e.prototype.getRectangle=function(g){return this.minX>this.maxX||this.minY>this.maxY?Lg.EMPTY:(g=g||new Lg(0,0,1,1),g.x=this.minX,g.y=this.minY,g.width=this.maxX-this.minX,g.height=this.maxY-this.minY,g)},e.prototype.addPoint=function(g){this.minX=Math.min(this.minX,g.x),this.maxX=Math.max(this.maxX,g.x),this.minY=Math.min(this.minY,g.y),this.maxY=Math.max(this.maxY,g.y)},e.prototype.addPointMatrix=function(g,i){var n=g.a,I=g.b,r=g.c,o=g.d,C=g.tx,a=g.ty,A=n*i.x+r*i.y+C,s=I*i.x+o*i.y+a;this.minX=Math.min(this.minX,A),this.maxX=Math.max(this.maxX,A),this.minY=Math.min(this.minY,s),this.maxY=Math.max(this.maxY,s)},e.prototype.addQuad=function(g){var i=this.minX,n=this.minY,I=this.maxX,r=this.maxY,o=g[0],C=g[1];i=oI?o:I,r=C>r?C:r,o=g[2],C=g[3],i=oI?o:I,r=C>r?C:r,o=g[4],C=g[5],i=oI?o:I,r=C>r?C:r,o=g[6],C=g[7],i=oI?o:I,r=C>r?C:r,this.minX=i,this.minY=n,this.maxX=I,this.maxY=r},e.prototype.addFrame=function(g,i,n,I,r){this.addFrameMatrix(g.worldTransform,i,n,I,r)},e.prototype.addFrameMatrix=function(g,i,n,I,r){var o=g.a,C=g.b,a=g.c,A=g.d,s=g.tx,l=g.ty,c=this.minX,u=this.minY,d=this.maxX,h=this.maxY,f=o*i+a*n+s,m=C*i+A*n+l;c=fd?f:d,h=m>h?m:h,f=o*I+a*n+s,m=C*I+A*n+l,c=fd?f:d,h=m>h?m:h,f=o*i+a*r+s,m=C*i+A*r+l,c=fd?f:d,h=m>h?m:h,f=o*I+a*r+s,m=C*I+A*r+l,c=fd?f:d,h=m>h?m:h,this.minX=c,this.minY=u,this.maxX=d,this.maxY=h},e.prototype.addVertexData=function(g,i,n){for(var I=this.minX,r=this.minY,o=this.maxX,C=this.maxY,a=i;ao?A:o,C=s>C?s:C}this.minX=I,this.minY=r,this.maxX=o,this.maxY=C},e.prototype.addVertices=function(g,i,n,I){this.addVerticesMatrix(g.worldTransform,i,n,I)},e.prototype.addVerticesMatrix=function(g,i,n,I,r,o){r===void 0&&(r=0),o===void 0&&(o=r);for(var C=g.a,a=g.b,A=g.c,s=g.d,l=g.tx,c=g.ty,u=this.minX,d=this.minY,h=this.maxX,f=this.maxY,m=n;mI?g.maxX:I,this.maxY=g.maxY>r?g.maxY:r},e.prototype.addBoundsMask=function(g,i){var n=g.minX>i.minX?g.minX:i.minX,I=g.minY>i.minY?g.minY:i.minY,r=g.maxXA?r:A,this.maxY=o>s?o:s}},e.prototype.addBoundsMatrix=function(g,i){this.addFrameMatrix(i,g.minX,g.minY,g.maxX,g.maxY)},e.prototype.addBoundsArea=function(g,i){var n=g.minX>i.x?g.minX:i.x,I=g.minY>i.y?g.minY:i.y,r=g.maxXA?r:A,this.maxY=o>s?o:s}},e.prototype.pad=function(g,i){g===void 0&&(g=0),i===void 0&&(i=g),this.isEmpty()||(this.minX-=g,this.maxX+=g,this.minY-=i,this.maxY+=i)},e.prototype.addFramePad=function(g,i,n,I,r,o){g-=r,i-=o,n+=r,I+=o,this.minX=this.minXn?this.maxX:n,this.minY=this.minYI?this.maxY:I},e}();/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */var w8=function(e,g){return w8=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var I in n)n.hasOwnProperty(I)&&(i[I]=n[I])},w8(e,g)};function Lre(e,g){w8(e,g);function i(){this.constructor=e}e.prototype=g===null?Object.create(g):(i.prototype=g.prototype,new i)}var Fn=function(e){Lre(g,e);function g(){var i=e.call(this)||this;return i.tempDisplayObjectParent=null,i.transform=new Jre,i.alpha=1,i.visible=!0,i.renderable=!0,i.cullable=!1,i.cullArea=null,i.parent=null,i.worldAlpha=1,i._lastSortedIndex=0,i._zIndex=0,i.filterArea=null,i.filters=null,i._enabledFilters=null,i._bounds=new GX,i._localBounds=null,i._boundsID=0,i._boundsRect=null,i._localBoundsRect=null,i._mask=null,i._maskRefCount=0,i._destroyed=!1,i.isSprite=!1,i.isMask=!1,i}return g.mixin=function(i){for(var n=Object.keys(i),I=0;I1)for(var r=0;rthis.children.length)throw new Error(i+"addChildAt: The index "+n+" supplied is out of bounds "+this.children.length);return i.parent&&i.parent.removeChild(i),i.parent=this,this.sortDirty=!0,i.transform._parentID=-1,this.children.splice(n,0,i),this._boundsID++,this.onChildrenChange(n),i.emit("added",this),this.emit("childAdded",i,this,n),i},g.prototype.swapChildren=function(i,n){if(i!==n){var I=this.getChildIndex(i),r=this.getChildIndex(n);this.children[I]=n,this.children[r]=i,this.onChildrenChange(I=this.children.length)throw new Error("The index "+n+" supplied is out of bounds "+this.children.length);var I=this.getChildIndex(i);E0(this.children,I,1),this.children.splice(n,0,i),this.onChildrenChange(n)},g.prototype.getChildAt=function(i){if(i<0||i>=this.children.length)throw new Error("getChildAt: Index ("+i+") does not exist.");return this.children[i]},g.prototype.removeChild=function(){for(var i=arguments,n=[],I=0;I1)for(var r=0;r0&&o<=r){C=this.children.splice(I,o);for(var a=0;a1&&this.children.sort(Oft),this.sortDirty=!1},g.prototype.updateTransform=function(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(var i=0,n=this.children.length;i0&&n.height>0){var I,r;if(this.cullArea?(I=this.cullArea,r=this.worldTransform):this._render!==g.prototype._render&&(I=this.getBounds(!0)),I&&n.intersects(I,r))this._render(i);else if(this.cullArea)return;for(var o=0,C=this.children.length;o8)throw new Error("max arguments reached");var A=this,s=A.name,l=A.items;this._aliasCount++;for(var c=0,u=l.length;c0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))},e.prototype.add=function(g){return g[this._name]&&(this.ensureNonAliasedItems(),this.remove(g),this.items.push(g)),this},e.prototype.remove=function(g){var i=this.items.indexOf(g);return i!==-1&&(this.ensureNonAliasedItems(),this.items.splice(i,1)),this},e.prototype.contains=function(g){return this.items.indexOf(g)!==-1},e.prototype.removeAll=function(){return this.ensureNonAliasedItems(),this.items.length=0,this},e.prototype.destroy=function(){this.removeAll(),this.items=null,this._name=null},Object.defineProperty(e.prototype,"empty",{get:function(){return this.items.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),e}();Object.defineProperties(Cr.prototype,{dispatch:{value:Cr.prototype.emit},run:{value:Cr.prototype.emit}});/*! + * @pixi/ticker - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/ticker is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */Ht.TARGET_FPMS=.06;var wc;(function(e){e[e.INTERACTION=50]="INTERACTION",e[e.HIGH=25]="HIGH",e[e.NORMAL=0]="NORMAL",e[e.LOW=-25]="LOW",e[e.UTILITY=-50]="UTILITY"})(wc||(wc={}));var bL=function(){function e(g,i,n,I){i===void 0&&(i=null),n===void 0&&(n=0),I===void 0&&(I=!1),this.next=null,this.previous=null,this._destroyed=!1,this.fn=g,this.context=i,this.priority=n,this.once=I}return e.prototype.match=function(g,i){return i===void 0&&(i=null),this.fn===g&&this.context===i},e.prototype.emit=function(g){this.fn&&(this.context?this.fn.call(this.context,g):this.fn(g));var i=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),i},e.prototype.connect=function(g){this.previous=g,g.next&&(g.next.previous=this),this.next=g.next,g.next=this},e.prototype.destroy=function(g){g===void 0&&(g=!1),this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);var i=this.next;return this.next=g?null:i,this.previous=null,i},e}(),KI=function(){function e(){var g=this;this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new bL(null,null,1/0),this.deltaMS=1/Ht.TARGET_FPMS,this.elapsedMS=1/Ht.TARGET_FPMS,this._tick=function(i){g._requestId=null,g.started&&(g.update(i),g.started&&g._requestId===null&&g._head.next&&(g._requestId=requestAnimationFrame(g._tick)))}}return e.prototype._requestIfNeeded=function(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))},e.prototype._cancelIfNeeded=function(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)},e.prototype._startIfPossible=function(){this.started?this._requestIfNeeded():this.autoStart&&this.start()},e.prototype.add=function(g,i,n){return n===void 0&&(n=wc.NORMAL),this._addListener(new bL(g,i,n))},e.prototype.addOnce=function(g,i,n){return n===void 0&&(n=wc.NORMAL),this._addListener(new bL(g,i,n,!0))},e.prototype._addListener=function(g){var i=this._head.next,n=this._head;if(!i)g.connect(n);else{for(;i;){if(g.priority>i.priority){g.connect(n);break}n=i,i=i.next}g.previous||g.connect(n)}return this._startIfPossible(),this},e.prototype.remove=function(g,i){for(var n=this._head.next;n;)n.match(g,i)?n=n.destroy():n=n.next;return this._head.next||this._cancelIfNeeded(),this},Object.defineProperty(e.prototype,"count",{get:function(){if(!this._head)return 0;for(var g=0,i=this._head;i=i.next;)g++;return g},enumerable:!1,configurable:!0}),e.prototype.start=function(){this.started||(this.started=!0,this._requestIfNeeded())},e.prototype.stop=function(){this.started&&(this.started=!1,this._cancelIfNeeded())},e.prototype.destroy=function(){if(!this._protected){this.stop();for(var g=this._head.next;g;)g=g.destroy(!0);this._head.destroy(),this._head=null}},e.prototype.update=function(g){g===void 0&&(g=performance.now());var i;if(g>this.lastTime){if(i=this.elapsedMS=g-this.lastTime,i>this._maxElapsedMS&&(i=this._maxElapsedMS),i*=this.speed,this._minElapsedMS){var n=g-this._lastFrame|0;if(n=0;--I){var r=vX[I];if(r.test&&r.test(e,i))return new r(e,g)}throw new Error("Unrecognized source type to auto-detect Resource")}/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */var R8=function(e,g){return R8=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var I in n)n.hasOwnProperty(I)&&(i[I]=n[I])},R8(e,g)};function Li(e,g){R8(e,g);function i(){this.constructor=e}e.prototype=g===null?Object.create(g):(i.prototype=g.prototype,new i)}var V8=function(){return V8=Object.assign||function(g){for(var i=arguments,n,I=1,r=arguments.length;I0&&s>0,I.textureCacheIds=[],I.destroyed=!1,I.resource=null,I._batchEnabled=0,I._batchLocation=0,I.parentTextureArray=null,I.setResource(i),I}return Object.defineProperty(g.prototype,"realWidth",{get:function(){return Math.round(this.width*this.resolution)},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"realHeight",{get:function(){return Math.round(this.height*this.resolution)},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"mipmap",{get:function(){return this._mipmap},set:function(i){this._mipmap!==i&&(this._mipmap=i,this.dirtyStyleId++)},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"scaleMode",{get:function(){return this._scaleMode},set:function(i){this._scaleMode!==i&&(this._scaleMode=i,this.dirtyStyleId++)},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"wrapMode",{get:function(){return this._wrapMode},set:function(i){this._wrapMode!==i&&(this._wrapMode=i,this.dirtyStyleId++)},enumerable:!1,configurable:!0}),g.prototype.setStyle=function(i,n){var I;return i!==void 0&&i!==this.scaleMode&&(this.scaleMode=i,I=!0),n!==void 0&&n!==this.mipmap&&(this.mipmap=n,I=!0),I&&this.dirtyStyleId++,this},g.prototype.setSize=function(i,n,I){return I=I||this.resolution,this.setRealSize(i*I,n*I,I)},g.prototype.setRealSize=function(i,n,I){return this.resolution=I||this.resolution,this.width=Math.round(i)/this.resolution,this.height=Math.round(n)/this.resolution,this._refreshPOT(),this.update(),this},g.prototype._refreshPOT=function(){this.isPowerOfTwo=y8(this.realWidth)&&y8(this.realHeight)},g.prototype.setResolution=function(i){var n=this.resolution;return n===i?this:(this.resolution=i,this.valid&&(this.width=Math.round(this.width*n)/i,this.height=Math.round(this.height*n)/i,this.emit("update",this)),this._refreshPOT(),this)},g.prototype.setResource=function(i){if(this.resource===i)return this;if(this.resource)throw new Error("Resource can be set only once");return i.bind(this),this.resource=i,this},g.prototype.update=function(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))},g.prototype.onError=function(i){this.emit("error",this,i)},g.prototype.destroy=function(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete Da[this.cacheId],delete aC[this.cacheId],this.cacheId=null),this.dispose(),g.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0},g.prototype.dispose=function(){this.emit("dispose",this)},g.prototype.castToBaseTexture=function(){return this},g.from=function(i,n,I){I===void 0&&(I=Ht.STRICT_TEXTURE_CACHE);var r=typeof i=="string",o=null;if(r)o=i;else{if(!i._pixiId){var C=n&&n.pixiIdPrefix||"pixiid";i._pixiId=C+"_"+cm()}o=i._pixiId}var a=Da[o];if(r&&I&&!a)throw new Error('The cacheId "'+o+'" does not exist in BaseTextureCache.');return a||(a=new g(i,n),a.cacheId=o,g.addToCache(a,o)),a},g.fromBuffer=function(i,n,I,r){i=i||new Float32Array(n*I*4);var o=new Ky(i,{width:n,height:I}),C=i instanceof Float32Array?ng.FLOAT:ng.UNSIGNED_BYTE;return new g(o,Object.assign(Lft,r||{width:n,height:I,type:C}))},g.addToCache=function(i,n){n&&(i.textureCacheIds.indexOf(n)===-1&&i.textureCacheIds.push(n),Da[n]&&console.warn("BaseTexture added to the cache with an id ["+n+"] that already had an entry"),Da[n]=i)},g.removeFromCache=function(i){if(typeof i=="string"){var n=Da[i];if(n){var I=n.textureCacheIds.indexOf(i);return I>-1&&n.textureCacheIds.splice(I,1),delete Da[i],n}}else if(i&&i.textureCacheIds){for(var r=0;r0)if(i.resource)this.addResourceAt(i.resource,n);else throw new Error("CubeResource does not support copying of renderTexture.");else i.target=Jf.TEXTURE_CUBE_MAP_POSITIVE_X+n,i.parentTextureArray=this.baseTexture,this.items[n]=i;return i.valid&&!this.valid&&this.resize(i.realWidth,i.realHeight),this.items[n]=i,this},g.prototype.upload=function(i,n,I){for(var r=this.itemDirtyIds,o=0;o)?\s*()]*-->)?\s*\]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i,g}(Sc),eoe=function(e){Li(g,e);function g(i,n){var I=this;if(n=n||{},!(i instanceof HTMLVideoElement)){var r=document.createElement("video");r.setAttribute("preload","auto"),r.setAttribute("webkit-playsinline",""),r.setAttribute("playsinline",""),typeof i=="string"&&(i=[i]);var o=i[0].src||i[0];Sc.crossOrigin(r,o,n.crossorigin);for(var C=0;C0&&i.paused===!1&&i.ended===!1&&i.readyState>2},g.prototype._isSourceReady=function(){var i=this.source;return i.readyState===3||i.readyState===4},g.prototype._onPlayStart=function(){this.valid||this._onCanPlay(),this.autoUpdate&&!this._isConnectedToTicker&&(KI.shared.add(this.update,this),this._isConnectedToTicker=!0)},g.prototype._onPlayStop=function(){this._isConnectedToTicker&&(KI.shared.remove(this.update,this),this._isConnectedToTicker=!1)},g.prototype._onCanPlay=function(){var i=this.source;i.removeEventListener("canplay",this._onCanPlay),i.removeEventListener("canplaythrough",this._onCanPlay);var n=this.valid;this.resize(i.videoWidth,i.videoHeight),!n&&this._resolve&&(this._resolve(this),this._resolve=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&i.play()},g.prototype.dispose=function(){this._isConnectedToTicker&&(KI.shared.remove(this.update,this),this._isConnectedToTicker=!1);var i=this.source;i&&(i.removeEventListener("error",this._onError,!0),i.pause(),i.src="",i.load()),e.prototype.dispose.call(this)},Object.defineProperty(g.prototype,"autoUpdate",{get:function(){return this._autoUpdate},set:function(i){i!==this._autoUpdate&&(this._autoUpdate=i,!this._autoUpdate&&this._isConnectedToTicker?(KI.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._isSourcePlaying()&&(KI.shared.add(this.update,this),this._isConnectedToTicker=!0))},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"updateFPS",{get:function(){return this._updateFPS},set:function(i){i!==this._updateFPS&&(this._updateFPS=i)},enumerable:!1,configurable:!0}),g.test=function(i,n){return globalThis.HTMLVideoElement&&i instanceof HTMLVideoElement||g.TYPES.indexOf(n)>-1},g.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],g.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"},g}(Sc),toe=function(e){Li(g,e);function g(i){return e.call(this,i)||this}return g.test=function(i){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&i instanceof ImageBitmap},g}(Sc);vX.push(iz,toe,jre,eoe,qre,Ky,$re,Qre);var CFe={__proto__:null,Resource:bb,BaseImageResource:Sc,INSTALLED:vX,autoDetectResource:tz,AbstractMultiResource:gz,ArrayResource:Qre,BufferResource:Ky,CanvasResource:jre,CubeResource:$re,ImageResource:iz,SVGResource:qre,VideoResource:eoe,ImageBitmapResource:toe},Uft=function(e){Li(g,e);function g(){return e!==null&&e.apply(this,arguments)||this}return g.prototype.upload=function(i,n,I){var r=i.gl;r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.alphaMode===cs.UNPACK);var o=n.realWidth,C=n.realHeight;return I.width===o&&I.height===C?r.texSubImage2D(n.target,0,0,0,o,C,n.format,I.type,this.data):(I.width=o,I.height=C,r.texImage2D(n.target,0,I.internalFormat,o,C,0,n.format,I.type,this.data)),!0},g}(Ky),Kx=function(){function e(g,i){this.width=Math.round(g||100),this.height=Math.round(i||100),this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new Cr("disposeFramebuffer"),this.multisample=Un.NONE}return Object.defineProperty(e.prototype,"colorTexture",{get:function(){return this.colorTextures[0]},enumerable:!1,configurable:!0}),e.prototype.addColorTexture=function(g,i){return g===void 0&&(g=0),this.colorTextures[g]=i||new _g(null,{scaleMode:ql.NEAREST,resolution:1,mipmap:Bc.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this},e.prototype.addDepthTexture=function(g){return this.depthTexture=g||new _g(new Uft(null,{width:this.width,height:this.height}),{scaleMode:ql.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:Bc.OFF,format:vt.DEPTH_COMPONENT,type:ng.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this},e.prototype.enableDepth=function(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this},e.prototype.enableStencil=function(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this},e.prototype.resize=function(g,i){if(g=Math.round(g),i=Math.round(i),!(g===this.width&&i===this.height)){this.width=g,this.height=i,this.dirtyId++,this.dirtySize++;for(var n=0;n-1&&n.textureCacheIds.splice(I,1),delete aC[i],n}}else if(i&&i.textureCacheIds){for(var r=0;rthis.baseTexture.width,a=I+o>this.baseTexture.height;if(C||a){var A=C&&a?"and":"or",s="X: "+n+" + "+r+" = "+(n+r)+" > "+this.baseTexture.width,l="Y: "+I+" + "+o+" = "+(I+o)+" > "+this.baseTexture.height;throw new Error("Texture Error: frame does not fit inside the base Texture dimensions: "+(s+" "+A+" "+l))}this.valid=r&&o&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=i),this.valid&&this.updateUvs()},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"rotate",{get:function(){return this._rotate},set:function(i){this._rotate=i,this.valid&&this.updateUvs()},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"width",{get:function(){return this.orig.width},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"height",{get:function(){return this.orig.height},enumerable:!1,configurable:!0}),g.prototype.castToBaseTexture=function(){return this.baseTexture},Object.defineProperty(g,"EMPTY",{get:function(){return g._EMPTY||(g._EMPTY=new g(new _g),PN(g._EMPTY),PN(g._EMPTY.baseTexture)),g._EMPTY},enumerable:!1,configurable:!0}),Object.defineProperty(g,"WHITE",{get:function(){if(!g._WHITE){var i=Ht.ADAPTER.createCanvas(16,16),n=i.getContext("2d");i.width=16,i.height=16,n.fillStyle="white",n.fillRect(0,0,16,16),g._WHITE=new g(_g.from(i)),PN(g._WHITE),PN(g._WHITE.baseTexture)}return g._WHITE},enumerable:!1,configurable:!0}),g}(p1),Wd=function(e){Li(g,e);function g(i,n){var I=e.call(this,i,n)||this;return I.valid=!0,I.filterFrame=null,I.filterPoolKey=null,I.updateUvs(),I}return Object.defineProperty(g.prototype,"framebuffer",{get:function(){return this.baseTexture.framebuffer},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"multisample",{get:function(){return this.framebuffer.multisample},set:function(i){this.framebuffer.multisample=i},enumerable:!1,configurable:!0}),g.prototype.resize=function(i,n,I){I===void 0&&(I=!0);var r=this.baseTexture.resolution,o=Math.round(i*r)/r,C=Math.round(n*r)/r;this.valid=o>0&&C>0,this._frame.width=this.orig.width=o,this._frame.height=this.orig.height=C,I&&this.baseTexture.resize(o,C),this.updateUvs()},g.prototype.setResolution=function(i){var n=this.baseTexture;n.resolution!==i&&(n.setResolution(i),this.resize(n.width,n.height,!1))},g.create=function(i){for(var n=arguments,I=[],r=1;r>>0,I>1&&(r+=I*4294967296)):r=I>1?-I:-1,this.texturePool[r]||(this.texturePool[r]=[]);var o=this.texturePool[r].pop();return o||(o=this.createTexture(g,i,I)),o.filterPoolKey=r,o.setResolution(n),o},e.prototype.getFilterTexture=function(g,i,n){var I=this.getOptimalTexture(g.width,g.height,i||g.resolution,n||Un.NONE);return I.filterFrame=g.filterFrame,I},e.prototype.returnTexture=function(g){var i=g.filterPoolKey;g.filterFrame=null,this.texturePool[i].push(g)},e.prototype.returnFilterTexture=function(g){this.returnTexture(g)},e.prototype.clear=function(g){if(g=g!==!1,g)for(var i in this.texturePool){var n=this.texturePool[i];if(n)for(var I=0;I0&&g.height>0;for(var i in this.texturePool)if(Number(i)<0){var n=this.texturePool[i];if(n)for(var I=0;I1){for(var s=0;s1&&(l=this.getOptimalFilterTexture(s.width,s.height,i.resolution),l.filterFrame=s.filterFrame),n[c].apply(this,s,l,Nu.CLEAR,i);var u=s;s=l,l=u}n[c].apply(this,s,A.renderTexture,Nu.BLEND,i),c>1&&i.multisample>1&&this.returnFilterTexture(i.renderTexture),this.returnFilterTexture(s),this.returnFilterTexture(l)}i.clear(),this.statePool.push(i)},e.prototype.bindAndClear=function(g,i){i===void 0&&(i=Nu.CLEAR);var n=this.renderer,I=n.renderTexture,r=n.state;if(g===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,g&&g.filterFrame){var o=this.tempRect;o.x=0,o.y=0,o.width=g.filterFrame.width,o.height=g.filterFrame.height,I.bind(g,g.filterFrame,o)}else g!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?I.bind(g):this.renderer.renderTexture.bind(g,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);var C=r.stateId&1||this.forceClear;(i===Nu.CLEAR||i===Nu.BLIT&&C)&&this.renderer.framebuffer.clear(0,0,0,0)},e.prototype.applyFilter=function(g,i,n,I){var r=this.renderer;r.state.set(g.state),this.bindAndClear(n,I),g.uniforms.uSampler=i,g.uniforms.filterGlobals=this.globalUniforms,r.shader.bind(g),g.legacy=!!g.program.attributeData.aTextureCoord,g.legacy?(this.quadUv.map(i._frame,i.filterFrame),r.geometry.bind(this.quadUv),r.geometry.draw(ja.TRIANGLES)):(r.geometry.bind(this.quad),r.geometry.draw(ja.TRIANGLE_STRIP))},e.prototype.calculateSpriteMatrix=function(g,i){var n=this.activeState,I=n.sourceFrame,r=n.destinationFrame,o=i._texture.orig,C=g.set(r.width,0,0,r.height,I.x,I.y),a=i.worldTransform.copyTo(rI.TEMP_MATRIX);return a.invert(),C.prepend(a),C.scale(1/o.width,1/o.height),C.translate(i.anchor.x,i.anchor.y),C},e.prototype.destroy=function(){this.renderer=null,this.texturePool.clear(!1)},e.prototype.getOptimalFilterTexture=function(g,i,n,I){return n===void 0&&(n=1),I===void 0&&(I=Un.NONE),this.texturePool.getOptimalTexture(g,i,n,I)},e.prototype.getFilterTexture=function(g,i,n){if(typeof g=="number"){var I=g;g=i,i=I}g=g||this.activeState.renderTexture;var r=this.texturePool.getOptimalTexture(g.width,g.height,i||g.resolution,n||Un.NONE);return r.filterFrame=g.filterFrame,r},e.prototype.returnFilterTexture=function(g){this.texturePool.returnTexture(g)},e.prototype.emptyPool=function(){this.texturePool.clear(!0)},e.prototype.resize=function(){this.texturePool.setScreenSize(this.renderer.view)},e.prototype.transformAABB=function(g,i){var n=_N[0],I=_N[1],r=_N[2],o=_N[3];n.set(i.left,i.top),I.set(i.left,i.bottom),r.set(i.right,i.top),o.set(i.right,i.bottom),g.apply(n,n),g.apply(I,I),g.apply(r,r),g.apply(o,o);var C=Math.min(n.x,I.x,r.x,o.x),a=Math.min(n.y,I.y,r.y,o.y),A=Math.max(n.x,I.x,r.x,o.x),s=Math.max(n.y,I.y,r.y,o.y);i.x=C,i.y=a,i.width=A-C,i.height=s-a},e.prototype.roundFrame=function(g,i,n,I,r){if(!(g.width<=0||g.height<=0||n.width<=0||n.height<=0)){if(r){var o=r.a,C=r.b,a=r.c,A=r.d;if((Math.abs(C)>1e-4||Math.abs(a)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(A)>1e-4))return}r=r?yL.copyFrom(r):yL.identity(),r.translate(-n.x,-n.y).scale(I.width/n.width,I.height/n.height).translate(I.x,I.y),this.transformAABB(r,g),g.ceil(i),this.transformAABB(r.invert(),g)}},e}(),lT=function(){function e(g){this.renderer=g}return e.prototype.flush=function(){},e.prototype.destroy=function(){this.renderer=null},e.prototype.start=function(){},e.prototype.stop=function(){this.flush()},e.prototype.render=function(g){},e}(),roe=function(){function e(g){this.renderer=g,this.emptyRenderer=new lT(g),this.currentRenderer=this.emptyRenderer}return e.prototype.setObjectRenderer=function(g){this.currentRenderer!==g&&(this.currentRenderer.stop(),this.currentRenderer=g,this.currentRenderer.start())},e.prototype.flush=function(){this.setObjectRenderer(this.emptyRenderer)},e.prototype.reset=function(){this.setObjectRenderer(this.emptyRenderer)},e.prototype.copyBoundTextures=function(g,i){for(var n=this.renderer.texture.boundTextures,I=i-1;I>=0;--I)g[I]=n[I]||null,g[I]&&(g[I]._batchLocation=I)},e.prototype.boundArray=function(g,i,n,I){for(var r=g.elements,o=g.ids,C=g.count,a=0,A=0;A=0&&l=vc.WEBGL2&&(n=g.getContext("webgl2",i)),n)this.webGLVersion=2;else if(this.webGLVersion=1,n=g.getContext("webgl",i)||g.getContext("experimental-webgl",i),!n)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=n,this.getExtensions(),this.gl},e.prototype.getExtensions=function(){var g=this.gl,i={anisotropicFiltering:g.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:g.getExtension("OES_texture_float_linear"),s3tc:g.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:g.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:g.getExtension("WEBGL_compressed_texture_etc"),etc1:g.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:g.getExtension("WEBGL_compressed_texture_pvrtc")||g.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:g.getExtension("WEBGL_compressed_texture_atc"),astc:g.getExtension("WEBGL_compressed_texture_astc")};this.webGLVersion===1?Object.assign(this.extensions,i,{drawBuffers:g.getExtension("WEBGL_draw_buffers"),depthTexture:g.getExtension("WEBGL_depth_texture"),loseContext:g.getExtension("WEBGL_lose_context"),vertexArrayObject:g.getExtension("OES_vertex_array_object")||g.getExtension("MOZ_OES_vertex_array_object")||g.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:g.getExtension("OES_element_index_uint"),floatTexture:g.getExtension("OES_texture_float"),floatTextureLinear:g.getExtension("OES_texture_float_linear"),textureHalfFloat:g.getExtension("OES_texture_half_float"),textureHalfFloatLinear:g.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,i,{colorBufferFloat:g.getExtension("EXT_color_buffer_float")})},e.prototype.handleContextLost=function(g){g.preventDefault()},e.prototype.handleContextRestored=function(){this.renderer.runners.contextChange.emit(this.gl)},e.prototype.destroy=function(){var g=this.renderer.view;this.renderer=null,g.removeEventListener("webglcontextlost",this.handleContextLost),g.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()},e.prototype.postrender=function(){this.renderer.renderingToScreen&&this.gl.flush()},e.prototype.validateContext=function(g){var i=g.getContextAttributes(),n="WebGL2RenderingContext"in globalThis&&g instanceof globalThis.WebGL2RenderingContext;n&&(this.webGLVersion=2),i&&!i.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");var I=n||!!g.getExtension("OES_element_index_uint");this.supports.uint32Indices=I,I||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")},e}(),lFe=function(){function e(g){this.framebuffer=g,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=Un.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}return e}(),gmt=new Lg,Coe=function(){function e(g){this.renderer=g,this.managedFramebuffers=[],this.unknownFramebuffer=new Kx(10,10),this.msaaSamples=null}return e.prototype.contextChange=function(){var g=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new Lg,this.hasMRT=!0,this.writeDepthTexture=!0,this.disposeAll(!0),this.renderer.context.webGLVersion===1){var i=this.renderer.context.extensions.drawBuffers,n=this.renderer.context.extensions.depthTexture;Ht.PREFER_ENV===vc.WEBGL_LEGACY&&(i=null,n=null),i?g.drawBuffers=function(I){return i.drawBuffersWEBGL(I)}:(this.hasMRT=!1,g.drawBuffers=function(){}),n||(this.writeDepthTexture=!1)}else this.msaaSamples=g.getInternalformatParameter(g.RENDERBUFFER,g.RGBA8,g.SAMPLES)},e.prototype.bind=function(g,i,n){n===void 0&&(n=0);var I=this.gl;if(g){var r=g.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(g);this.current!==g&&(this.current=g,I.bindFramebuffer(I.FRAMEBUFFER,r.framebuffer)),r.mipLevel!==n&&(g.dirtyId++,g.dirtyFormat++,r.mipLevel=n),r.dirtyId!==g.dirtyId&&(r.dirtyId=g.dirtyId,r.dirtyFormat!==g.dirtyFormat?(r.dirtyFormat=g.dirtyFormat,r.dirtySize=g.dirtySize,this.updateFramebuffer(g,n)):r.dirtySize!==g.dirtySize&&(r.dirtySize=g.dirtySize,this.resizeFramebuffer(g)));for(var o=0;o>n,A=i.height>>n,s=a/i.width;this.setViewport(i.x*s,i.y*s,a,A)}else{var a=g.width>>n,A=g.height>>n;this.setViewport(0,0,a,A)}}else this.current&&(this.current=null,I.bindFramebuffer(I.FRAMEBUFFER,null)),i?this.setViewport(i.x,i.y,i.width,i.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)},e.prototype.setViewport=function(g,i,n,I){var r=this.viewport;g=Math.round(g),i=Math.round(i),n=Math.round(n),I=Math.round(I),(r.width!==n||r.height!==I||r.x!==g||r.y!==i)&&(r.x=g,r.y=i,r.width=n,r.height=I,this.gl.viewport(g,i,n,I))},Object.defineProperty(e.prototype,"size",{get:function(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}},enumerable:!1,configurable:!0}),e.prototype.clear=function(g,i,n,I,r){r===void 0&&(r=mX.COLOR|mX.DEPTH);var o=this.gl;o.clearColor(g,i,n,I),o.clear(r)},e.prototype.initFramebuffer=function(g){var i=this.gl,n=new lFe(i.createFramebuffer());return n.multisample=this.detectSamples(g.multisample),g.glFramebuffers[this.CONTEXT_UID]=n,this.managedFramebuffers.push(g),g.disposeRunner.add(this),n},e.prototype.resizeFramebuffer=function(g){var i=this.gl,n=g.glFramebuffers[this.CONTEXT_UID];n.msaaBuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,n.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,n.multisample,i.RGBA8,g.width,g.height)),n.stencil&&(i.bindRenderbuffer(i.RENDERBUFFER,n.stencil),n.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,n.multisample,i.DEPTH24_STENCIL8,g.width,g.height):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,g.width,g.height));var I=g.colorTextures,r=I.length;i.drawBuffers||(r=Math.min(r,1));for(var o=0;o1&&this.canMultisampleFramebuffer(g)?(I.msaaBuffer=I.msaaBuffer||n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,I.msaaBuffer),n.renderbufferStorageMultisample(n.RENDERBUFFER,I.multisample,n.RGBA8,g.width,g.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,I.msaaBuffer)):I.msaaBuffer&&(n.deleteRenderbuffer(I.msaaBuffer),I.msaaBuffer=null,I.blitFramebuffer&&(I.blitFramebuffer.dispose(),I.blitFramebuffer=null));for(var C=[],a=0;a1&&n.drawBuffers(C),g.depthTexture){var l=this.writeDepthTexture;if(l){var c=g.depthTexture;this.renderer.texture.bind(c,0),n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,c._glTextures[this.CONTEXT_UID].texture,i)}}(g.stencil||g.depth)&&!(g.depthTexture&&this.writeDepthTexture)?(I.stencil=I.stencil||n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,I.stencil),I.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,I.multisample,n.DEPTH24_STENCIL8,g.width,g.height):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,g.width,g.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,I.stencil)):I.stencil&&(n.deleteRenderbuffer(I.stencil),I.stencil=null)},e.prototype.canMultisampleFramebuffer=function(g){return this.renderer.context.webGLVersion!==1&&g.colorTextures.length<=1&&!g.depthTexture},e.prototype.detectSamples=function(g){var i=this.msaaSamples,n=Un.NONE;if(g<=1||i===null)return n;for(var I=0;I=0&&this.managedFramebuffers.splice(r,1),g.disposeRunner.remove(this),i||(I.deleteFramebuffer(n.framebuffer),n.msaaBuffer&&I.deleteRenderbuffer(n.msaaBuffer),n.stencil&&I.deleteRenderbuffer(n.stencil)),n.blitFramebuffer&&n.blitFramebuffer.dispose()}},e.prototype.disposeAll=function(g){var i=this.managedFramebuffers;this.managedFramebuffers=[];for(var n=0;n=vc.WEBGL2&&(g=e.getContext("webgl2",{})),g||(g=e.getContext("webgl",{})||e.getContext("experimental-webgl",{}),g?g.getExtension("WEBGL_draw_buffers"):g=null),_S=g}return _S}var ON;function nmt(){if(!ON){ON=ZA.MEDIUM;var e=hFe();if(e&&e.getShaderPrecisionFormat){var g=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT);ON=g.precision?ZA.HIGH:ZA.MEDIUM}}return ON}function q0e(e,g,i){if(e.substring(0,9)!=="precision"){var n=g;return g===ZA.HIGH&&i!==ZA.HIGH&&(n=ZA.MEDIUM),"precision "+n+` float; +`+e}else if(i!==ZA.HIGH&&e.substring(0,15)==="precision highp")return e.replace("precision highp","precision mediump");return e}var Imt={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function fFe(e){return Imt[e]}var JN=null,ebe={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"};function mFe(e,g){if(!JN){var i=Object.keys(ebe);JN={};for(var n=0;n0&&(g+=` +else `),i"u"?.5:i,this.isSimple=!1}return Object.defineProperty(e.prototype,"texture",{get:function(){return this._texture},set:function(g){this._texture=g,this._textureID=-1},enumerable:!1,configurable:!0}),e.prototype.multiplyUvs=function(g,i){i===void 0&&(i=g);for(var n=this.mapCoord,I=0;I0?this.maskStack[this.maskStack.length-1]._colorMask:15;n!==i&&this.renderer.gl.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)},e.prototype.destroy=function(){this.renderer=null},e}(),yFe=function(){function e(g){this.renderer=g,this.maskStack=[],this.glConst=0}return e.prototype.getStackLength=function(){return this.maskStack.length},e.prototype.setMaskStack=function(g){var i=this.renderer.gl,n=this.getStackLength();this.maskStack=g;var I=this.getStackLength();I!==n&&(I===0?i.disable(this.glConst):(i.enable(this.glConst),this._useCurrent()))},e.prototype._useCurrent=function(){},e.prototype.destroy=function(){this.renderer=null,this.maskStack=null},e}(),gbe=new rI,ibe=[],Aoe=function(e){Li(g,e);function g(i){var n=e.call(this,i)||this;return n.glConst=Ht.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST,n}return g.prototype.getStackLength=function(){var i=this.maskStack[this.maskStack.length-1];return i?i._scissorCounter:0},g.prototype.calcScissorRect=function(i){var n;if(!i._scissorRectLocal){var I=i._scissorRect,r=i.maskObject,o=this.renderer,C=o.renderTexture,a=r.getBounds(!0,(n=ibe.pop())!==null&&n!==void 0?n:new Lg);this.roundFrameToPixels(a,C.current?C.current.resolution:o.resolution,C.sourceFrame,C.destinationFrame,o.projection.transform),I&&a.fit(I),i._scissorRectLocal=a}},g.isMatrixRotated=function(i){if(!i)return!1;var n=i.a,I=i.b,r=i.c,o=i.d;return(Math.abs(I)>1e-4||Math.abs(r)>1e-4)&&(Math.abs(n)>1e-4||Math.abs(o)>1e-4)},g.prototype.testScissor=function(i){var n=i.maskObject;if(!n.isFastRect||!n.isFastRect()||g.isMatrixRotated(n.worldTransform)||g.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(i);var I=i._scissorRectLocal;return I.width>0&&I.height>0},g.prototype.roundFrameToPixels=function(i,n,I,r,o){g.isMatrixRotated(o)||(o=o?gbe.copyFrom(o):gbe.identity(),o.translate(-I.x,-I.y).scale(r.width/I.width,r.height/I.height).translate(r.x,r.y),this.renderer.filter.transformAABB(o,i),i.fit(r),i.x=Math.round(i.x*n),i.y=Math.round(i.y*n),i.width=Math.round(i.width*n),i.height=Math.round(i.height*n))},g.prototype.push=function(i){i._scissorRectLocal||this.calcScissorRect(i);var n=this.renderer.gl;i._scissorRect||n.enable(n.SCISSOR_TEST),i._scissorCounter++,i._scissorRect=i._scissorRectLocal,this._useCurrent()},g.prototype.pop=function(i){var n=this.renderer.gl;i&&ibe.push(i._scissorRectLocal),this.getStackLength()>0?this._useCurrent():n.disable(n.SCISSOR_TEST)},g.prototype._useCurrent=function(){var i=this.maskStack[this.maskStack.length-1]._scissorRect,n;this.renderer.renderTexture.current?n=i.y:n=this.renderer.height-i.height-i.y,this.renderer.gl.scissor(i.x,n,i.width,i.height)},g}(yFe),loe=function(e){Li(g,e);function g(i){var n=e.call(this,i)||this;return n.glConst=Ht.ADAPTER.getWebGLRenderingContext().STENCIL_TEST,n}return g.prototype.getStackLength=function(){var i=this.maskStack[this.maskStack.length-1];return i?i._stencilCounter:0},g.prototype.push=function(i){var n=i.maskObject,I=this.renderer.gl,r=i._stencilCounter;r===0&&(this.renderer.framebuffer.forceStencil(),I.clearStencil(0),I.clear(I.STENCIL_BUFFER_BIT),I.enable(I.STENCIL_TEST)),i._stencilCounter++;var o=i._colorMask;o!==0&&(i._colorMask=0,I.colorMask(!1,!1,!1,!1)),I.stencilFunc(I.EQUAL,r,4294967295),I.stencilOp(I.KEEP,I.KEEP,I.INCR),n.renderable=!0,n.render(this.renderer),this.renderer.batch.flush(),n.renderable=!1,o!==0&&(i._colorMask=o,I.colorMask((o&1)!==0,(o&2)!==0,(o&4)!==0,(o&8)!==0)),this._useCurrent()},g.prototype.pop=function(i){var n=this.renderer.gl;if(this.getStackLength()===0)n.disable(n.STENCIL_TEST);else{var I=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,r=I?I._colorMask:15;r!==0&&(I._colorMask=0,n.colorMask(!1,!1,!1,!1)),n.stencilOp(n.KEEP,n.KEEP,n.DECR),i.renderable=!0,i.render(this.renderer),this.renderer.batch.flush(),i.renderable=!1,r!==0&&(I._colorMask=r,n.colorMask((r&1)!==0,(r&2)!==0,(r&4)!==0,(r&8)!==0)),this._useCurrent()}},g.prototype._useCurrent=function(){var i=this.renderer.gl;i.stencilFunc(i.EQUAL,this.getStackLength(),4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP)},g}(yFe),coe=function(){function e(g){this.renderer=g,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new rI,this.transform=null}return e.prototype.update=function(g,i,n,I){this.destinationFrame=g||this.destinationFrame||this.defaultFrame,this.sourceFrame=i||this.sourceFrame||g,this.calculateProjection(this.destinationFrame,this.sourceFrame,n,I),this.transform&&this.projectionMatrix.append(this.transform);var r=this.renderer;r.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,r.globalUniforms.update(),r.shader.shader&&r.shader.syncUniformGroup(r.shader.shader.uniforms.globals)},e.prototype.calculateProjection=function(g,i,n,I){var r=this.projectionMatrix,o=I?-1:1;r.identity(),r.a=1/i.width*2,r.d=o*(1/i.height*2),r.tx=-1-i.x*r.a,r.ty=-o-i.y*r.d},e.prototype.setTransform=function(g){},e.prototype.destroy=function(){this.renderer=null},e}(),pp=new Lg,JS=new Lg,uoe=function(){function e(g){this.renderer=g,this.clearColor=g._backgroundColorRgba,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new Lg,this.destinationFrame=new Lg,this.viewportFrame=new Lg}return e.prototype.bind=function(g,i,n){g===void 0&&(g=null);var I=this.renderer;this.current=g;var r,o,C;g?(r=g.baseTexture,C=r.resolution,i||(pp.width=g.frame.width,pp.height=g.frame.height,i=pp),n||(JS.x=g.frame.x,JS.y=g.frame.y,JS.width=i.width,JS.height=i.height,n=JS),o=r.framebuffer):(C=I.resolution,i||(pp.width=I.screen.width,pp.height=I.screen.height,i=pp),n||(n=pp,n.width=i.width,n.height=i.height));var a=this.viewportFrame;a.x=n.x*C,a.y=n.y*C,a.width=n.width*C,a.height=n.height*C,g||(a.y=I.view.height-(a.y+a.height)),a.ceil(),this.renderer.framebuffer.bind(o,a),this.renderer.projection.update(n,i,C,!o),g?this.renderer.mask.setMaskStack(r.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(i),this.destinationFrame.copyFrom(n)},e.prototype.clear=function(g,i){this.current?g=g||this.current.baseTexture.clearColor:g=g||this.clearColor;var n=this.destinationFrame,I=this.current?this.current.baseTexture:this.renderer.screen,r=n.width!==I.width||n.height!==I.height;if(r){var o=this.viewportFrame,C=o.x,a=o.y,A=o.width,s=o.height;C=Math.round(C),a=Math.round(a),A=Math.round(A),s=Math.round(s),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(C,a,A,s)}this.renderer.framebuffer.clear(g[0],g[1],g[2],g[3],i),r&&this.renderer.scissor.pop()},e.prototype.resize=function(){this.bind(null)},e.prototype.reset=function(){this.bind(null)},e.prototype.destroy=function(){this.renderer=null},e}();function pmt(e,g,i,n,I){i.buffer.update(I)}var bmt={float:` + data[offset] = v; + `,vec2:` + data[offset] = v[0]; + data[offset+1] = v[1]; + `,vec3:` + data[offset] = v[0]; + data[offset+1] = v[1]; + data[offset+2] = v[2]; + + `,vec4:` + data[offset] = v[0]; + data[offset+1] = v[1]; + data[offset+2] = v[2]; + data[offset+3] = v[3]; + `,mat2:` + data[offset] = v[0]; + data[offset+1] = v[1]; + + data[offset+4] = v[2]; + data[offset+5] = v[3]; + `,mat3:` + data[offset] = v[0]; + data[offset+1] = v[1]; + data[offset+2] = v[2]; + + data[offset + 4] = v[3]; + data[offset + 5] = v[4]; + data[offset + 6] = v[5]; + + data[offset + 8] = v[6]; + data[offset + 9] = v[7]; + data[offset + 10] = v[8]; + `,mat4:` + for(var i = 0; i < 16; i++) + { + data[offset + i] = v[i]; + } + `},ZFe={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:16*2,mat3:16*3,mat4:16*4};function GFe(e){for(var g=e.map(function(a){return{data:a,offset:0,dataLen:0,dirty:0}}),i=0,n=0,I=0,r=0;r1&&(i=Math.max(i,16)*o.data.size),o.dataLen=i,n%i!==0&&n<16){var C=n%i%16;n+=C,I+=C}n+i>16?(I=Math.ceil(I/16)*16,o.offset=I,I+=i,n=i):(o.offset=I,n+=i,I+=i)}return I=Math.ceil(I/16)*16,{uboElements:g,size:I}}function vFe(e,g){var i=[];for(var n in e)g[n]&&i.push(g[n]);return i.sort(function(I,r){return I.index-r.index}),i}function BFe(e,g){if(!e.autoManage)return{size:0,syncFunc:pmt};for(var i=vFe(e.uniforms,g),n=GFe(i),I=n.uboElements,r=n.size,o=[` + var v = null; + var v2 = null; + var cv = null; + var t = 0; + var gl = renderer.gl + var index = 0; + var data = buffer.data; + `],C=0;C1){var d=fFe(a.data.type),h=Math.max(ZFe[a.data.type]/16,1),f=d/h,m=(4-f%4)%4;o.push(` + cv = ud.`+s+`.value; + v = uv.`+s+`; + offset = `+a.offset/4+`; + + t = 0; + + for(var i=0; i < `+a.data.size*h+`; i++) + { + for(var j = 0; j < `+f+`; j++) + { + data[offset++] = v[t++]; + } + offset += `+m+`; + } + + `)}else{var b=bmt[a.data.type];o.push(` + cv = ud.`+s+`.value; + v = uv.`+s+`; + offset = `+a.offset/4+`; + `+b+`; + `)}}return o.push(` + renderer.buffer.update(buffer); + `),{size:r,syncFunc:new Function("ud","uv","renderer","syncData","buffer",o.join(` +`))}}var ymt=function(){function e(){}return e}(),wFe=function(){function e(g,i){this.program=g,this.uniformData=i,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}return e.prototype.destroy=function(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null},e}();function Zmt(e,g){for(var i={},n=g.getProgramParameter(e,g.ACTIVE_ATTRIBUTES),I=0;Il?1:-1});for(var o=0;o>1,n++;this.stateId=g.data}for(var n=0;nthis.checkCountMax&&(this.checkCount=0,this.run())))},e.prototype.run=function(){for(var g=this.renderer.texture,i=g.managedTextures,n=!1,I=0;Ithis.maxIdle&&(g.destroyTexture(r,!0),i[I]=null,n=!0)}if(n){for(var o=0,I=0;I=0;I--)this.unload(g.children[I])},e.prototype.destroy=function(){this.renderer=null},e}();function Tmt(e){var g,i,n,I,r,o,C,a,A,s,l,c,u,d,h,f,m,b,p,y,Z,v,G;return"WebGL2RenderingContext"in globalThis&&e instanceof globalThis.WebGL2RenderingContext?G=(g={},g[ng.UNSIGNED_BYTE]=(i={},i[vt.RGBA]=e.RGBA8,i[vt.RGB]=e.RGB8,i[vt.RG]=e.RG8,i[vt.RED]=e.R8,i[vt.RGBA_INTEGER]=e.RGBA8UI,i[vt.RGB_INTEGER]=e.RGB8UI,i[vt.RG_INTEGER]=e.RG8UI,i[vt.RED_INTEGER]=e.R8UI,i[vt.ALPHA]=e.ALPHA,i[vt.LUMINANCE]=e.LUMINANCE,i[vt.LUMINANCE_ALPHA]=e.LUMINANCE_ALPHA,i),g[ng.BYTE]=(n={},n[vt.RGBA]=e.RGBA8_SNORM,n[vt.RGB]=e.RGB8_SNORM,n[vt.RG]=e.RG8_SNORM,n[vt.RED]=e.R8_SNORM,n[vt.RGBA_INTEGER]=e.RGBA8I,n[vt.RGB_INTEGER]=e.RGB8I,n[vt.RG_INTEGER]=e.RG8I,n[vt.RED_INTEGER]=e.R8I,n),g[ng.UNSIGNED_SHORT]=(I={},I[vt.RGBA_INTEGER]=e.RGBA16UI,I[vt.RGB_INTEGER]=e.RGB16UI,I[vt.RG_INTEGER]=e.RG16UI,I[vt.RED_INTEGER]=e.R16UI,I[vt.DEPTH_COMPONENT]=e.DEPTH_COMPONENT16,I),g[ng.SHORT]=(r={},r[vt.RGBA_INTEGER]=e.RGBA16I,r[vt.RGB_INTEGER]=e.RGB16I,r[vt.RG_INTEGER]=e.RG16I,r[vt.RED_INTEGER]=e.R16I,r),g[ng.UNSIGNED_INT]=(o={},o[vt.RGBA_INTEGER]=e.RGBA32UI,o[vt.RGB_INTEGER]=e.RGB32UI,o[vt.RG_INTEGER]=e.RG32UI,o[vt.RED_INTEGER]=e.R32UI,o[vt.DEPTH_COMPONENT]=e.DEPTH_COMPONENT24,o),g[ng.INT]=(C={},C[vt.RGBA_INTEGER]=e.RGBA32I,C[vt.RGB_INTEGER]=e.RGB32I,C[vt.RG_INTEGER]=e.RG32I,C[vt.RED_INTEGER]=e.R32I,C),g[ng.FLOAT]=(a={},a[vt.RGBA]=e.RGBA32F,a[vt.RGB]=e.RGB32F,a[vt.RG]=e.RG32F,a[vt.RED]=e.R32F,a[vt.DEPTH_COMPONENT]=e.DEPTH_COMPONENT32F,a),g[ng.HALF_FLOAT]=(A={},A[vt.RGBA]=e.RGBA16F,A[vt.RGB]=e.RGB16F,A[vt.RG]=e.RG16F,A[vt.RED]=e.R16F,A),g[ng.UNSIGNED_SHORT_5_6_5]=(s={},s[vt.RGB]=e.RGB565,s),g[ng.UNSIGNED_SHORT_4_4_4_4]=(l={},l[vt.RGBA]=e.RGBA4,l),g[ng.UNSIGNED_SHORT_5_5_5_1]=(c={},c[vt.RGBA]=e.RGB5_A1,c),g[ng.UNSIGNED_INT_2_10_10_10_REV]=(u={},u[vt.RGBA]=e.RGB10_A2,u[vt.RGBA_INTEGER]=e.RGB10_A2UI,u),g[ng.UNSIGNED_INT_10F_11F_11F_REV]=(d={},d[vt.RGB]=e.R11F_G11F_B10F,d),g[ng.UNSIGNED_INT_5_9_9_9_REV]=(h={},h[vt.RGB]=e.RGB9_E5,h),g[ng.UNSIGNED_INT_24_8]=(f={},f[vt.DEPTH_STENCIL]=e.DEPTH24_STENCIL8,f),g[ng.FLOAT_32_UNSIGNED_INT_24_8_REV]=(m={},m[vt.DEPTH_STENCIL]=e.DEPTH32F_STENCIL8,m),g):G=(b={},b[ng.UNSIGNED_BYTE]=(p={},p[vt.RGBA]=e.RGBA,p[vt.RGB]=e.RGB,p[vt.ALPHA]=e.ALPHA,p[vt.LUMINANCE]=e.LUMINANCE,p[vt.LUMINANCE_ALPHA]=e.LUMINANCE_ALPHA,p),b[ng.UNSIGNED_SHORT_5_6_5]=(y={},y[vt.RGB]=e.RGB,y),b[ng.UNSIGNED_SHORT_4_4_4_4]=(Z={},Z[vt.RGBA]=e.RGBA,Z),b[ng.UNSIGNED_SHORT_5_5_5_1]=(v={},v[vt.RGBA]=e.RGBA,v),b),G}var VK=function(){function e(g){this.texture=g,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=ng.UNSIGNED_BYTE,this.internalFormat=vt.RGBA,this.samplerType=0}return e}(),moe=function(){function e(g){this.renderer=g,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new _g,this.hasIntegerTextures=!1}return e.prototype.contextChange=function(){var g=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=Tmt(g);var i=g.getParameter(g.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=i;for(var n=0;n=0;--o){var C=n[o];if(C){var a=C._glTextures[r];a.samplerType!==pX.FLOAT&&this.renderer.texture.unbind(C)}}},e.prototype.initTexture=function(g){var i=new VK(this.gl.createTexture());return i.dirtyId=-1,g._glTextures[this.CONTEXT_UID]=i,this.managedTextures.push(g),g.on("dispose",this.destroyTexture,this),i},e.prototype.initTextureType=function(g,i){var n,I;i.internalFormat=(I=(n=this.internalFormats[g.type])===null||n===void 0?void 0:n[g.format])!==null&&I!==void 0?I:g.format,this.webGLVersion===2&&g.type===ng.HALF_FLOAT?i.type=this.gl.HALF_FLOAT:i.type=g.type},e.prototype.updateTexture=function(g){var i=g._glTextures[this.CONTEXT_UID];if(i){var n=this.renderer;if(this.initTextureType(g,i),g.resource&&g.resource.upload(n,g,i))i.samplerType!==pX.FLOAT&&(this.hasIntegerTextures=!0);else{var I=g.realWidth,r=g.realHeight,o=n.gl;(i.width!==I||i.height!==r||i.dirtyId<0)&&(i.width=I,i.height=r,o.texImage2D(g.target,0,i.internalFormat,I,r,0,g.format,i.type,null))}g.dirtyStyleId!==i.dirtyStyleId&&this.updateTextureStyle(g),i.dirtyId=g.dirtyId}},e.prototype.destroyTexture=function(g,i){var n=this.gl;if(g=g.castToBaseTexture(),g._glTextures[this.CONTEXT_UID]&&(this.unbind(g),n.deleteTexture(g._glTextures[this.CONTEXT_UID].texture),g.off("dispose",this.destroyTexture,this),delete g._glTextures[this.CONTEXT_UID],!i)){var I=this.managedTextures.indexOf(g);I!==-1&&E0(this.managedTextures,I,1)}},e.prototype.updateTextureStyle=function(g){var i=g._glTextures[this.CONTEXT_UID];i&&((g.mipmap===Bc.POW2||this.webGLVersion!==2)&&!g.isPowerOfTwo?i.mipmap=!1:i.mipmap=g.mipmap>=1,this.webGLVersion!==2&&!g.isPowerOfTwo?i.wrapMode=Cc.CLAMP:i.wrapMode=g.wrapMode,g.resource&&g.resource.style(this.renderer,g,i)||this.setStyle(g,i),i.dirtyStyleId=g.dirtyStyleId)},e.prototype.setStyle=function(g,i){var n=this.gl;if(i.mipmap&&g.mipmap!==Bc.ON_MANUAL&&n.generateMipmap(g.target),n.texParameteri(g.target,n.TEXTURE_WRAP_S,i.wrapMode),n.texParameteri(g.target,n.TEXTURE_WRAP_T,i.wrapMode),i.mipmap){n.texParameteri(g.target,n.TEXTURE_MIN_FILTER,g.scaleMode===ql.LINEAR?n.LINEAR_MIPMAP_LINEAR:n.NEAREST_MIPMAP_NEAREST);var I=this.renderer.context.extensions.anisotropicFiltering;if(I&&g.anisotropicLevel>0&&g.scaleMode===ql.LINEAR){var r=Math.min(g.anisotropicLevel,n.getParameter(I.MAX_TEXTURE_MAX_ANISOTROPY_EXT));n.texParameterf(g.target,I.TEXTURE_MAX_ANISOTROPY_EXT,r)}}else n.texParameteri(g.target,n.TEXTURE_MIN_FILTER,g.scaleMode===ql.LINEAR?n.LINEAR:n.NEAREST);n.texParameteri(g.target,n.TEXTURE_MAG_FILTER,g.scaleMode===ql.LINEAR?n.LINEAR:n.NEAREST)},e.prototype.destroy=function(){this.renderer=null},e}(),RFe={__proto__:null,FilterSystem:Ioe,BatchSystem:roe,ContextSystem:ooe,FramebufferSystem:Coe,GeometrySystem:aoe,MaskSystem:soe,ScissorSystem:Aoe,StencilSystem:loe,ProjectionSystem:coe,RenderTextureSystem:uoe,ShaderSystem:doe,StateSystem:hoe,TextureGCSystem:foe,TextureSystem:moe},WL=new rI,VFe=function(e){Li(g,e);function g(i,n){i===void 0&&(i=WB.UNKNOWN);var I=e.call(this)||this;return n=Object.assign({},Ht.RENDER_OPTIONS,n),I.options=n,I.type=i,I.screen=new Lg(0,0,n.width,n.height),I.view=n.view||Ht.ADAPTER.createCanvas(),I.resolution=n.resolution||Ht.RESOLUTION,I.useContextAlpha=n.useContextAlpha,I.autoDensity=!!n.autoDensity,I.preserveDrawingBuffer=n.preserveDrawingBuffer,I.clearBeforeRender=n.clearBeforeRender,I._backgroundColor=0,I._backgroundColorRgba=[0,0,0,1],I._backgroundColorString="#000000",I.backgroundColor=n.backgroundColor||I._backgroundColor,I.backgroundAlpha=n.backgroundAlpha,n.transparent!==void 0&&(SC("6.0.0","Option transparent is deprecated, please use backgroundAlpha instead."),I.useContextAlpha=n.transparent,I.backgroundAlpha=n.transparent?0:1),I._lastObjectRendered=null,I.plugins={},I}return g.prototype.initPlugins=function(i){for(var n in i)this.plugins[n]=new i[n](this)},Object.defineProperty(g.prototype,"width",{get:function(){return this.view.width},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"height",{get:function(){return this.view.height},enumerable:!1,configurable:!0}),g.prototype.resize=function(i,n){this.view.width=Math.round(i*this.resolution),this.view.height=Math.round(n*this.resolution);var I=this.view.width/this.resolution,r=this.view.height/this.resolution;this.screen.width=I,this.screen.height=r,this.autoDensity&&(this.view.style.width=I+"px",this.view.style.height=r+"px"),this.emit("resize",I,r)},g.prototype.generateTexture=function(i,n,I,r){n===void 0&&(n={}),typeof n=="number"&&(SC("6.1.0","generateTexture options (scaleMode, resolution, region) are now object options."),n={scaleMode:n,resolution:I,region:r});var o=n.region,C=Jft(n,["region"]);r=o||i.getLocalBounds(null,!0),r.width===0&&(r.width=1),r.height===0&&(r.height=1);var a=Wd.create(V8({width:r.width,height:r.height},C));return WL.tx=-r.x,WL.ty=-r.y,this.render(i,{renderTexture:a,clear:!1,transform:WL,skipUpdateTransform:!!i.parent}),a},g.prototype.destroy=function(i){for(var n in this.plugins)this.plugins[n].destroy(),this.plugins[n]=null;i&&this.view.parentNode&&this.view.parentNode.removeChild(this.view);var I=this;I.plugins=null,I.type=WB.UNKNOWN,I.view=null,I.screen=null,I._tempDisplayObjectParent=null,I.options=null,this._backgroundColorRgba=null,this._backgroundColorString=null,this._lastObjectRendered=null},Object.defineProperty(g.prototype,"backgroundColor",{get:function(){return this._backgroundColor},set:function(i){this._backgroundColor=i,this._backgroundColorString=Mre(i),pb(i,this._backgroundColorRgba)},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"backgroundAlpha",{get:function(){return this._backgroundColorRgba[3]},set:function(i){this._backgroundColorRgba[3]=i},enumerable:!1,configurable:!0}),g}(p1),Hmt=function(){function e(g){this.buffer=g||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}return e}(),Nmt=function(){function e(g){this.renderer=g,this.managedBuffers={},this.boundBufferBases={}}return e.prototype.destroy=function(){this.renderer=null},e.prototype.contextChange=function(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID},e.prototype.bind=function(g){var i=this,n=i.gl,I=i.CONTEXT_UID,r=g._glBuffers[I]||this.createGLBuffer(g);n.bindBuffer(g.type,r.buffer)},e.prototype.bindBufferBase=function(g,i){var n=this,I=n.gl,r=n.CONTEXT_UID;if(this.boundBufferBases[i]!==g){var o=g._glBuffers[r]||this.createGLBuffer(g);this.boundBufferBases[i]=g,I.bindBufferBase(I.UNIFORM_BUFFER,i,o.buffer)}},e.prototype.bindBufferRange=function(g,i,n){var I=this,r=I.gl,o=I.CONTEXT_UID;n=n||0;var C=g._glBuffers[o]||this.createGLBuffer(g);r.bindBufferRange(r.UNIFORM_BUFFER,i||0,C.buffer,n*256,256)},e.prototype.update=function(g){var i=this,n=i.gl,I=i.CONTEXT_UID,r=g._glBuffers[I];if(g._updateID!==r.updateID)if(r.updateID=g._updateID,n.bindBuffer(g.type,r.buffer),r.byteLength>=g.data.byteLength)n.bufferSubData(g.type,0,g.data);else{var o=g.static?n.STATIC_DRAW:n.DYNAMIC_DRAW;r.byteLength=g.data.byteLength,n.bufferData(g.type,g.data,o)}},e.prototype.dispose=function(g,i){if(this.managedBuffers[g.id]){delete this.managedBuffers[g.id];var n=g._glBuffers[this.CONTEXT_UID],I=this.gl;g.disposeRunner.remove(this),n&&(i||I.deleteBuffer(n.buffer),delete g._glBuffers[this.CONTEXT_UID])}},e.prototype.disposeAll=function(g){for(var i=Object.keys(this.managedBuffers),n=0;n=Un.HIGH?this.multisample=Un.HIGH:n>=Un.MEDIUM?this.multisample=Un.MEDIUM:n>=Un.LOW?this.multisample=Un.LOW:this.multisample=Un.NONE},g.prototype.addSystem=function(i,n){var I=new i(this);if(this[n])throw new Error('Whoops! The name "'+n+'" is already in use');this[n]=I;for(var r in this.runners)this.runners[r].add(I);return this},g.prototype.render=function(i,n){var I,r,o,C;if(n&&(n instanceof Wd?(SC("6.0.0","Renderer#render arguments changed, use options instead."),I=n,r=arguments[2],o=arguments[3],C=arguments[4]):(I=n.renderTexture,r=n.clear,o=n.transform,C=n.skipUpdateTransform)),this.renderingToScreen=!I,this.runners.prerender.emit(),this.emit("prerender"),this.projection.transform=o,!this.context.isLost){if(I||(this._lastObjectRendered=i),!C){var a=i.enableTempParent();i.updateTransform(),i.disableTempParent(a)}this.renderTexture.bind(I),this.batch.currentRenderer.start(),(r!==void 0?r:this.clearBeforeRender)&&this.renderTexture.clear(),i.render(this),this.batch.currentRenderer.flush(),I&&I.baseTexture.update(),this.runners.postrender.emit(),this.projection.transform=null,this.emit("postrender")}},g.prototype.generateTexture=function(i,n,I,r){n===void 0&&(n={});var o=e.prototype.generateTexture.call(this,i,n,I,r);return this.framebuffer.blit(),o},g.prototype.resize=function(i,n){e.prototype.resize.call(this,i,n),this.runners.resize.emit(this.screen.height,this.screen.width)},g.prototype.reset=function(){return this.runners.reset.emit(),this},g.prototype.clear=function(){this.renderTexture.bind(),this.renderTexture.clear()},g.prototype.destroy=function(i){this.runners.destroy.emit();for(var n in this.runners)this.runners[n].destroy();e.prototype.destroy.call(this,i),this.gl=null},Object.defineProperty(g.prototype,"extract",{get:function(){return SC("6.0.0","Renderer#extract has been deprecated, please use Renderer#plugins.extract instead."),this.plugins.extract},enumerable:!1,configurable:!0}),g.registerPlugin=function(i,n){SC("6.5.0","Renderer.registerPlugin() has been deprecated, please use extensions.add() instead."),Pc.add({name:i,type:Zi.RendererPlugin,ref:n})},g.__plugins={},g}(VFe);Pc.handleByMap(Zi.RendererPlugin,poe.__plugins);function WFe(e){return poe.create(e)}var kmt=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,Ymt=`attribute vec2 aVertexPosition; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +uniform vec4 inputSize; +uniform vec4 outputFrame; + +vec4 filterVertexPosition( void ) +{ + vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; + + return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); +} + +vec2 filterTextureCoord( void ) +{ + return aVertexPosition * (outputFrame.zw * inputSize.zw); +} + +void main(void) +{ + gl_Position = filterVertexPosition(); + vTextureCoord = filterTextureCoord(); +} +`,XFe=kmt,boe=Ymt,Kmt=function(){function e(g){SC("6.1.0","System class is deprecated, implemement ISystem interface instead."),this.renderer=g}return e.prototype.destroy=function(){this.renderer=null},e}(),xx=function(){function e(){this.texArray=null,this.blend=0,this.type=ja.TRIANGLES,this.start=0,this.size=0,this.data=null}return e}(),Fx=function(){function e(){this.elements=[],this.ids=[],this.count=0}return e.prototype.clear=function(){for(var g=0;gthis.size&&this.flush(),this._vertexCount+=i.vertexData.length/2,this._indexCount+=i.indices.length,this._bufferedTextures[this._bufferSize]=i._texture.baseTexture,this._bufferedElements[this._bufferSize++]=i)},g.prototype.buildTexturesAndDrawCalls=function(){var i=this,n=i._bufferedTextures,I=i.MAX_TEXTURES,r=g._textureArrayPool,o=this.renderer.batch,C=this._tempBoundTextures,a=this.renderer.textureGC.count,A=++_g._globalBatch,s=0,l=r[0],c=0;o.copyBoundTextures(C,I);for(var u=0;u=I&&(o.boundArray(l,C,A,I),this.buildDrawCalls(l,c,u),c=u,l=r[++s],++A),d._batchEnabled=A,d.touched=a,l.elements[l.count++]=d)}l.count>0&&(o.boundArray(l,C,A,I),this.buildDrawCalls(l,c,this._bufferSize),++s,++A);for(var u=0;u0&&(i+=` +else `),n title : "+g.title+"
tabIndex: "+g.tabIndex},e.prototype.capHitArea=function(g){g.x<0&&(g.width+=g.x,g.x=0),g.y<0&&(g.height+=g.y,g.y=0);var i=this.renderer,n=i.width,I=i.height;g.x+g.width>n&&(g.width=n-g.x),g.y+g.height>I&&(g.height=I-g.y)},e.prototype.addChild=function(g){var i=this.pool.pop();i||(i=document.createElement("button"),i.style.width=QN+"px",i.style.height=QN+"px",i.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",i.style.position="absolute",i.style.zIndex=rbe.toString(),i.style.borderStyle="none",navigator.userAgent.toLowerCase().indexOf("chrome")>-1?i.setAttribute("aria-live","off"):i.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?i.setAttribute("aria-relevant","additions"):i.setAttribute("aria-relevant","text"),i.addEventListener("click",this._onClick.bind(this)),i.addEventListener("focus",this._onFocus.bind(this)),i.addEventListener("focusout",this._onFocusOut.bind(this))),i.style.pointerEvents=g.accessiblePointerEvents,i.type=g.accessibleType,g.accessibleTitle&&g.accessibleTitle!==null?i.title=g.accessibleTitle:(!g.accessibleHint||g.accessibleHint===null)&&(i.title="displayObject "+g.tabIndex),g.accessibleHint&&g.accessibleHint!==null&&i.setAttribute("aria-label",g.accessibleHint),this.debug&&this.updateDebugHTML(i),g._accessibleActive=!0,g._accessibleDiv=i,i.displayObject=g,this.children.push(g),this.div.appendChild(g._accessibleDiv),g._accessibleDiv.tabIndex=g.tabIndex},e.prototype._onClick=function(g){var i=this.renderer.plugins.interaction,n=g.target.displayObject,I=i.eventData;i.dispatchEvent(n,"click",I),i.dispatchEvent(n,"pointertap",I),i.dispatchEvent(n,"tap",I)},e.prototype._onFocus=function(g){g.target.getAttribute("aria-live")||g.target.setAttribute("aria-live","assertive");var i=this.renderer.plugins.interaction,n=g.target.displayObject,I=i.eventData;i.dispatchEvent(n,"mouseover",I)},e.prototype._onFocusOut=function(g){g.target.getAttribute("aria-live")||g.target.setAttribute("aria-live","polite");var i=this.renderer.plugins.interaction,n=g.target.displayObject,I=i.eventData;i.dispatchEvent(n,"mouseout",I)},e.prototype._onKeyDown=function(g){g.keyCode===Emt&&this.activate()},e.prototype._onMouseMove=function(g){g.movementX===0&&g.movementY===0||this.deactivate()},e.prototype.destroy=function(){this.destroyTouchHook(),this.div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this.pool=null,this.children=null,this.renderer=null},e.extension={name:"accessibility",type:[Zi.RendererPlugin,Zi.CanvasRendererPlugin]},e}();/*! + * @pixi/interaction - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/interaction is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */var X8=function(){function e(){this.pressure=0,this.rotationAngle=0,this.twist=0,this.tangentialPressure=0,this.global=new _i,this.target=null,this.originalEvent=null,this.identifier=null,this.isPrimary=!1,this.button=0,this.buttons=0,this.width=0,this.height=0,this.tiltX=0,this.tiltY=0,this.pointerType=null,this.pressure=0,this.rotationAngle=0,this.twist=0,this.tangentialPressure=0}return Object.defineProperty(e.prototype,"pointerId",{get:function(){return this.identifier},enumerable:!1,configurable:!0}),e.prototype.getLocalPosition=function(g,i,n){return g.worldTransform.applyInverse(n||this.global,i)},e.prototype.copyEvent=function(g){"isPrimary"in g&&g.isPrimary&&(this.isPrimary=!0),this.button="button"in g&&g.button;var i="buttons"in g&&g.buttons;this.buttons=Number.isInteger(i)?i:"which"in g&&g.which,this.width="width"in g&&g.width,this.height="height"in g&&g.height,this.tiltX="tiltX"in g&&g.tiltX,this.tiltY="tiltY"in g&&g.tiltY,this.pointerType="pointerType"in g&&g.pointerType,this.pressure="pressure"in g&&g.pressure,this.rotationAngle="rotationAngle"in g&&g.rotationAngle,this.twist="twist"in g&&g.twist||0,this.tangentialPressure="tangentialPressure"in g&&g.tangentialPressure||0},e.prototype.reset=function(){this.isPrimary=!1},e}();/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */var T8=function(e,g){return T8=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var I in n)n.hasOwnProperty(I)&&(i[I]=n[I])},T8(e,g)};function Omt(e,g){T8(e,g);function i(){this.constructor=e}e.prototype=g===null?Object.create(g):(i.prototype=g.prototype,new i)}var EFe=function(){function e(){this.stopped=!1,this.stopsPropagatingAt=null,this.stopPropagationHint=!1,this.target=null,this.currentTarget=null,this.type=null,this.data=null}return e.prototype.stopPropagation=function(){this.stopped=!0,this.stopPropagationHint=!0,this.stopsPropagatingAt=this.currentTarget},e.prototype.reset=function(){this.stopped=!1,this.stopsPropagatingAt=null,this.stopPropagationHint=!1,this.currentTarget=null,this.target=null},e}(),WK=function(){function e(g){this._pointerId=g,this._flags=e.FLAGS.NONE}return e.prototype._doSet=function(g,i){i?this._flags=this._flags|g:this._flags=this._flags&~g},Object.defineProperty(e.prototype,"pointerId",{get:function(){return this._pointerId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"flags",{get:function(){return this._flags},set:function(g){this._flags=g},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"none",{get:function(){return this._flags===e.FLAGS.NONE},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"over",{get:function(){return(this._flags&e.FLAGS.OVER)!==0},set:function(g){this._doSet(e.FLAGS.OVER,g)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightDown",{get:function(){return(this._flags&e.FLAGS.RIGHT_DOWN)!==0},set:function(g){this._doSet(e.FLAGS.RIGHT_DOWN,g)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftDown",{get:function(){return(this._flags&e.FLAGS.LEFT_DOWN)!==0},set:function(g){this._doSet(e.FLAGS.LEFT_DOWN,g)},enumerable:!1,configurable:!0}),e.FLAGS=Object.freeze({NONE:0,OVER:1<<0,LEFT_DOWN:1<<1,RIGHT_DOWN:1<<2}),e}(),Jmt=function(){function e(){this._tempPoint=new _i}return e.prototype.recursiveFindHit=function(g,i,n,I,r){var o;if(!i||!i.visible)return!1;var C=g.data.global;r=i.interactive||r;var a=!1,A=r,s=!0;if(i.hitArea)I&&(i.worldTransform.applyInverse(C,this._tempPoint),i.hitArea.contains(this._tempPoint.x,this._tempPoint.y)?a=!0:(I=!1,s=!1)),A=!1;else if(i._mask&&I){var l=i._mask.isMaskData?i._mask.maskObject:i._mask;l&&!(!((o=l.containsPoint)===null||o===void 0)&&o.call(l,C))&&(I=!1)}if(s&&i.interactiveChildren&&i.children)for(var c=i.children,u=c.length-1;u>=0;u--){var d=c[u],h=this.recursiveFindHit(g,d,n,I,A);if(h){if(!d.parent)continue;A=!1,h&&(g.target&&(I=!1),a=!0)}}return r&&(I&&!g.target&&!i.hitArea&&i.containsPoint&&i.containsPoint(C)&&(a=!0),i.interactive&&(a&&!g.target&&(g.target=i),n&&n(g,i,!!a))),a},e.prototype.findHit=function(g,i,n,I){this.recursiveFindHit(g,i,n,I,!1)},e}(),DFe={interactive:!1,interactiveChildren:!0,hitArea:null,get buttonMode(){return this.cursor==="pointer"},set buttonMode(e){e?this.cursor="pointer":this.cursor==="pointer"&&(this.cursor=null)},cursor:null,get trackedPointers(){return this._trackedPointers===void 0&&(this._trackedPointers={}),this._trackedPointers},_trackedPointers:void 0};Fn.mixin(DFe);var jN=1,$N={target:null,data:{global:null}},MFe=function(e){Omt(g,e);function g(i,n){var I=e.call(this)||this;return n=n||{},I.renderer=i,I.autoPreventDefault=n.autoPreventDefault!==void 0?n.autoPreventDefault:!0,I.interactionFrequency=n.interactionFrequency||10,I.mouse=new X8,I.mouse.identifier=jN,I.mouse.global.set(-999999),I.activeInteractionData={},I.activeInteractionData[jN]=I.mouse,I.interactionDataPool=[],I.eventData=new EFe,I.interactionDOMElement=null,I.moveWhenInside=!1,I.eventsAdded=!1,I.tickerAdded=!1,I.mouseOverRenderer=!("PointerEvent"in globalThis),I.supportsTouchEvents="ontouchstart"in globalThis,I.supportsPointerEvents=!!globalThis.PointerEvent,I.onPointerUp=I.onPointerUp.bind(I),I.processPointerUp=I.processPointerUp.bind(I),I.onPointerCancel=I.onPointerCancel.bind(I),I.processPointerCancel=I.processPointerCancel.bind(I),I.onPointerDown=I.onPointerDown.bind(I),I.processPointerDown=I.processPointerDown.bind(I),I.onPointerMove=I.onPointerMove.bind(I),I.processPointerMove=I.processPointerMove.bind(I),I.onPointerOut=I.onPointerOut.bind(I),I.processPointerOverOut=I.processPointerOverOut.bind(I),I.onPointerOver=I.onPointerOver.bind(I),I.cursorStyles={default:"inherit",pointer:"pointer"},I.currentCursorMode=null,I.cursor=null,I.resolution=1,I.delayedEvents=[],I.search=new Jmt,I._tempDisplayObject=new Ure,I._eventListenerOptions={capture:!0,passive:!1},I._useSystemTicker=n.useSystemTicker!==void 0?n.useSystemTicker:!0,I.setTargetElement(I.renderer.view,I.renderer.resolution),I}return Object.defineProperty(g.prototype,"useSystemTicker",{get:function(){return this._useSystemTicker},set:function(i){this._useSystemTicker=i,i?this.addTickerListener():this.removeTickerListener()},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"lastObjectRendered",{get:function(){return this.renderer._lastObjectRendered||this._tempDisplayObject},enumerable:!1,configurable:!0}),g.prototype.hitTest=function(i,n){return $N.target=null,$N.data.global=i,n||(n=this.lastObjectRendered),this.processInteractive($N,n,null,!0),$N.target},g.prototype.setTargetElement=function(i,n){n===void 0&&(n=1),this.removeTickerListener(),this.removeEvents(),this.interactionDOMElement=i,this.resolution=n,this.addEvents(),this.addTickerListener()},g.prototype.addTickerListener=function(){this.tickerAdded||!this.interactionDOMElement||!this._useSystemTicker||(KI.system.add(this.tickerUpdate,this,wc.INTERACTION),this.tickerAdded=!0)},g.prototype.removeTickerListener=function(){this.tickerAdded&&(KI.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)},g.prototype.addEvents=function(){if(!(this.eventsAdded||!this.interactionDOMElement)){var i=this.interactionDOMElement.style;globalThis.navigator.msPointerEnabled?(i.msContentZooming="none",i.msTouchAction="none"):this.supportsPointerEvents&&(i.touchAction="none"),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.addEventListener("pointerdown",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.addEventListener("pointerleave",this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.addEventListener("pointerover",this.onPointerOver,this._eventListenerOptions),globalThis.addEventListener("pointercancel",this.onPointerCancel,this._eventListenerOptions),globalThis.addEventListener("pointerup",this.onPointerUp,this._eventListenerOptions)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.addEventListener("mousedown",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.addEventListener("mouseout",this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.addEventListener("mouseover",this.onPointerOver,this._eventListenerOptions),globalThis.addEventListener("mouseup",this.onPointerUp,this._eventListenerOptions)),this.supportsTouchEvents&&(this.interactionDOMElement.addEventListener("touchstart",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.addEventListener("touchcancel",this.onPointerCancel,this._eventListenerOptions),this.interactionDOMElement.addEventListener("touchend",this.onPointerUp,this._eventListenerOptions),this.interactionDOMElement.addEventListener("touchmove",this.onPointerMove,this._eventListenerOptions)),this.eventsAdded=!0}},g.prototype.removeEvents=function(){if(!(!this.eventsAdded||!this.interactionDOMElement)){var i=this.interactionDOMElement.style;globalThis.navigator.msPointerEnabled?(i.msContentZooming="",i.msTouchAction=""):this.supportsPointerEvents&&(i.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("pointerdown",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("pointerleave",this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("pointerover",this.onPointerOver,this._eventListenerOptions),globalThis.removeEventListener("pointercancel",this.onPointerCancel,this._eventListenerOptions),globalThis.removeEventListener("pointerup",this.onPointerUp,this._eventListenerOptions)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("mousedown",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("mouseout",this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("mouseover",this.onPointerOver,this._eventListenerOptions),globalThis.removeEventListener("mouseup",this.onPointerUp,this._eventListenerOptions)),this.supportsTouchEvents&&(this.interactionDOMElement.removeEventListener("touchstart",this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("touchcancel",this.onPointerCancel,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("touchend",this.onPointerUp,this._eventListenerOptions),this.interactionDOMElement.removeEventListener("touchmove",this.onPointerMove,this._eventListenerOptions)),this.interactionDOMElement=null,this.eventsAdded=!1}},g.prototype.tickerUpdate=function(i){this._deltaTime+=i,!(this._deltaTime0&&(C=i.composedPath()[0]);for(var a=C!==this.interactionDOMElement?"outside":"",A=0;A"u"&&(o.button=i.touches.length?1:0),typeof o.buttons>"u"&&(o.buttons=i.touches.length?1:0),typeof o.isPrimary>"u"&&(o.isPrimary=i.touches.length===1&&i.type==="touchstart"),typeof o.width>"u"&&(o.width=o.radiusX||1),typeof o.height>"u"&&(o.height=o.radiusY||1),typeof o.tiltX>"u"&&(o.tiltX=0),typeof o.tiltY>"u"&&(o.tiltY=0),typeof o.pointerType>"u"&&(o.pointerType="touch"),typeof o.pointerId>"u"&&(o.pointerId=o.identifier||0),typeof o.pressure>"u"&&(o.pressure=o.force||.5),typeof o.twist>"u"&&(o.twist=0),typeof o.tangentialPressure>"u"&&(o.tangentialPressure=0),typeof o.layerX>"u"&&(o.layerX=o.offsetX=o.clientX),typeof o.layerY>"u"&&(o.layerY=o.offsetY=o.clientY),o.isNormalized=!0,n.push(o)}else if(!globalThis.MouseEvent||i instanceof MouseEvent&&(!this.supportsPointerEvents||!(i instanceof globalThis.PointerEvent))){var C=i;typeof C.isPrimary>"u"&&(C.isPrimary=!0),typeof C.width>"u"&&(C.width=1),typeof C.height>"u"&&(C.height=1),typeof C.tiltX>"u"&&(C.tiltX=0),typeof C.tiltY>"u"&&(C.tiltY=0),typeof C.pointerType>"u"&&(C.pointerType="mouse"),typeof C.pointerId>"u"&&(C.pointerId=jN),typeof C.pressure>"u"&&(C.pressure=.5),typeof C.twist>"u"&&(C.twist=0),typeof C.tangentialPressure>"u"&&(C.tangentialPressure=0),C.isNormalized=!0,n.push(C)}else n.push(i);return n},g.prototype.destroy=function(){this.removeEvents(),this.removeTickerListener(),this.removeAllListeners(),this.renderer=null,this.mouse=null,this.eventData=null,this.interactionDOMElement=null,this.onPointerDown=null,this.processPointerDown=null,this.onPointerUp=null,this.processPointerUp=null,this.onPointerCancel=null,this.processPointerCancel=null,this.onPointerMove=null,this.processPointerMove=null,this.onPointerOut=null,this.processPointerOverOut=null,this.onPointerOver=null,this.search=null},g.extension={name:"interaction",type:[Zi.RendererPlugin,Zi.CanvasRendererPlugin]},g}(p1);/*! + * @pixi/extract - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/extract is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */var Cbe=new Lg,abe=4,zFe=function(){function e(g){this.renderer=g}return e.prototype.image=function(g,i,n){var I=new Image;return I.src=this.base64(g,i,n),I},e.prototype.base64=function(g,i,n){return this.canvas(g).toDataURL(i,n)},e.prototype.canvas=function(g,i){var n=this.renderer,I,r=!1,o,C=!1;g&&(g instanceof Wd?o=g:(o=this.renderer.generateTexture(g),C=!0)),o?(I=o.baseTexture.resolution,i=i??o.frame,r=!1,n.renderTexture.bind(o)):(I=n.resolution,i||(i=Cbe,i.width=n.width,i.height=n.height),r=!0,n.renderTexture.bind(null));var a=Math.round(i.width*I),A=Math.round(i.height*I),s=new v8(a,A,1),l=new Uint8Array(abe*a*A),c=n.gl;c.readPixels(Math.round(i.x*I),Math.round(i.y*I),a,A,c.RGBA,c.UNSIGNED_BYTE,l);var u=s.context.getImageData(0,0,a,A);if(e.arrayPostDivide(l,u.data),s.context.putImageData(u,0,0),r){var d=new v8(s.width,s.height,1);d.context.scale(1,-1),d.context.drawImage(s.canvas,0,-A),s.destroy(),s=d}return C&&o.destroy(!0),s.canvas},e.prototype.pixels=function(g,i){var n=this.renderer,I,r,o=!1;g&&(g instanceof Wd?r=g:(r=this.renderer.generateTexture(g),o=!0)),r?(I=r.baseTexture.resolution,i=i??r.frame,n.renderTexture.bind(r)):(I=n.resolution,i||(i=Cbe,i.width=n.width,i.height=n.height),n.renderTexture.bind(null));var C=Math.round(i.width*I),a=Math.round(i.height*I),A=new Uint8Array(abe*C*a),s=n.gl;return s.readPixels(Math.round(i.x*I),Math.round(i.y*I),C,a,s.RGBA,s.UNSIGNED_BYTE,A),o&&r.destroy(!0),e.arrayPostDivide(A,A),A},e.prototype.destroy=function(){this.renderer=null},e.arrayPostDivide=function(g,i){for(var n=0;n"u"&&(XL=!!(globalThis.XDomainRequest&&!("withCredentials"in new XMLHttpRequest))),XL&&this.crossOrigin?this._loadXdr():this._loadXhr();break}}},e.prototype._hasFlag=function(g){return(this._flags&g)!==0},e.prototype._setFlag=function(g,i){this._flags=i?this._flags|g:this._flags&~g},e.prototype._clearEvents=function(){clearTimeout(this._elementTimer),this.data&&this.data.removeEventListener&&(this.data.removeEventListener("error",this._boundOnError,!1),this.data.removeEventListener("load",this._boundComplete,!1),this.data.removeEventListener("progress",this._boundOnProgress,!1),this.data.removeEventListener("canplaythrough",this._boundComplete,!1)),this.xhr&&(this.xhr.removeEventListener?(this.xhr.removeEventListener("error",this._boundXhrOnError,!1),this.xhr.removeEventListener("timeout",this._boundXhrOnTimeout,!1),this.xhr.removeEventListener("abort",this._boundXhrOnAbort,!1),this.xhr.removeEventListener("progress",this._boundOnProgress,!1),this.xhr.removeEventListener("load",this._boundXhrOnLoad,!1)):(this.xhr.onerror=null,this.xhr.ontimeout=null,this.xhr.onprogress=null,this.xhr.onload=null))},e.prototype._finish=function(){if(this.isComplete)throw new Error("Complete called again for an already completed resource.");this._setFlag(e.STATUS_FLAGS.COMPLETE,!0),this._setFlag(e.STATUS_FLAGS.LOADING,!1),this.onComplete.dispatch(this)},e.prototype._loadElement=function(g){this.metadata.loadElement?this.data=this.metadata.loadElement:g==="image"&&typeof globalThis.Image<"u"?this.data=new Image:this.data=document.createElement(g),this.crossOrigin&&(this.data.crossOrigin=this.crossOrigin),this.metadata.skipSource||(this.data.src=this.url),this.data.addEventListener("error",this._boundOnError,!1),this.data.addEventListener("load",this._boundComplete,!1),this.data.addEventListener("progress",this._boundOnProgress,!1),this.timeout&&(this._elementTimer=setTimeout(this._boundOnTimeout,this.timeout))},e.prototype._loadSourceElement=function(g){if(this.metadata.loadElement?this.data=this.metadata.loadElement:g==="audio"&&typeof globalThis.Audio<"u"?this.data=new Audio:this.data=document.createElement(g),this.data===null){this.abort("Unsupported element: "+g);return}if(this.crossOrigin&&(this.data.crossOrigin=this.crossOrigin),!this.metadata.skipSource)if(navigator.isCocoonJS)this.data.src=Array.isArray(this.url)?this.url[0]:this.url;else if(Array.isArray(this.url))for(var i=this.metadata.mimeType,n=0;n"u"?Abe:g.status;(g.responseType===""||g.responseType==="text"||typeof g.responseType>"u")&&(i=g.responseText),n===Lmt&&(i.length>0||g.responseType===e.XHR_RESPONSE_TYPE.BUFFER)?n=Abe:n===Qmt&&(n=Umt);var I=n/100|0;if(I===jmt)if(this.xhrType===e.XHR_RESPONSE_TYPE.TEXT)this.data=i,this.type=e.TYPE.TEXT;else if(this.xhrType===e.XHR_RESPONSE_TYPE.JSON)try{this.data=JSON.parse(i),this.type=e.TYPE.JSON}catch(C){this.abort("Error trying to parse loaded json: "+C);return}else if(this.xhrType===e.XHR_RESPONSE_TYPE.DOCUMENT)try{if(globalThis.DOMParser){var r=new DOMParser;this.data=r.parseFromString(i,"text/xml")}else{var o=document.createElement("div");o.innerHTML=i,this.data=o}this.type=e.TYPE.XML}catch(C){this.abort("Error trying to parse loaded xml: "+C);return}else this.data=g.response||i;else{this.abort("["+g.status+"] "+g.statusText+": "+g.responseURL);return}this.complete()},e.prototype._determineCrossOrigin=function(g,i){if(g.indexOf("data:")===0)return"";if(globalThis.origin!==globalThis.location.origin)return"anonymous";i=i||globalThis.location,ek||(ek=document.createElement("a")),ek.href=g;var n=PFe(ek.href,{strictMode:!0}),I=!n.port&&i.port===""||n.port===i.port,r=n.protocol?n.protocol+":":"";return n.host!==i.hostname||!I||r!==i.protocol?"anonymous":""},e.prototype._determineXhrType=function(){return e._xhrTypeMap[this.extension]||e.XHR_RESPONSE_TYPE.TEXT},e.prototype._determineLoadType=function(){return e._loadTypeMap[this.extension]||e.LOAD_TYPE.XHR},e.prototype._getExtension=function(g){g===void 0&&(g=this.url);var i="";if(this.isDataUrl){var n=g.indexOf("/");i=g.substring(n+1,g.indexOf(";",n))}else{var I=g.indexOf("?"),r=g.indexOf("#"),o=Math.min(I>-1?I:g.length,r>-1?r:g.length);g=g.substring(0,o),i=g.substring(g.lastIndexOf(".")+1)}return i.toLowerCase()},e.prototype._getMimeFromXhrType=function(g){switch(g){case e.XHR_RESPONSE_TYPE.BUFFER:return"application/octet-binary";case e.XHR_RESPONSE_TYPE.BLOB:return"application/blob";case e.XHR_RESPONSE_TYPE.DOCUMENT:return"application/xml";case e.XHR_RESPONSE_TYPE.JSON:return"application/json";case e.XHR_RESPONSE_TYPE.DEFAULT:case e.XHR_RESPONSE_TYPE.TEXT:default:return"text/plain"}},e}();(function(e){(function(g){g[g.NONE=0]="NONE",g[g.DATA_URL=1]="DATA_URL",g[g.COMPLETE=2]="COMPLETE",g[g.LOADING=4]="LOADING"})(e.STATUS_FLAGS||(e.STATUS_FLAGS={})),function(g){g[g.UNKNOWN=0]="UNKNOWN",g[g.JSON=1]="JSON",g[g.XML=2]="XML",g[g.IMAGE=3]="IMAGE",g[g.AUDIO=4]="AUDIO",g[g.VIDEO=5]="VIDEO",g[g.TEXT=6]="TEXT"}(e.TYPE||(e.TYPE={})),function(g){g[g.XHR=1]="XHR",g[g.IMAGE=2]="IMAGE",g[g.AUDIO=3]="AUDIO",g[g.VIDEO=4]="VIDEO"}(e.LOAD_TYPE||(e.LOAD_TYPE={})),function(g){g.DEFAULT="text",g.BUFFER="arraybuffer",g.BLOB="blob",g.DOCUMENT="document",g.JSON="json",g.TEXT="text"}(e.XHR_RESPONSE_TYPE||(e.XHR_RESPONSE_TYPE={})),e._loadTypeMap={gif:e.LOAD_TYPE.IMAGE,png:e.LOAD_TYPE.IMAGE,bmp:e.LOAD_TYPE.IMAGE,jpg:e.LOAD_TYPE.IMAGE,jpeg:e.LOAD_TYPE.IMAGE,tif:e.LOAD_TYPE.IMAGE,tiff:e.LOAD_TYPE.IMAGE,webp:e.LOAD_TYPE.IMAGE,tga:e.LOAD_TYPE.IMAGE,svg:e.LOAD_TYPE.IMAGE,"svg+xml":e.LOAD_TYPE.IMAGE,mp3:e.LOAD_TYPE.AUDIO,ogg:e.LOAD_TYPE.AUDIO,wav:e.LOAD_TYPE.AUDIO,mp4:e.LOAD_TYPE.VIDEO,webm:e.LOAD_TYPE.VIDEO},e._xhrTypeMap={xhtml:e.XHR_RESPONSE_TYPE.DOCUMENT,html:e.XHR_RESPONSE_TYPE.DOCUMENT,htm:e.XHR_RESPONSE_TYPE.DOCUMENT,xml:e.XHR_RESPONSE_TYPE.DOCUMENT,tmx:e.XHR_RESPONSE_TYPE.DOCUMENT,svg:e.XHR_RESPONSE_TYPE.DOCUMENT,tsx:e.XHR_RESPONSE_TYPE.DOCUMENT,gif:e.XHR_RESPONSE_TYPE.BLOB,png:e.XHR_RESPONSE_TYPE.BLOB,bmp:e.XHR_RESPONSE_TYPE.BLOB,jpg:e.XHR_RESPONSE_TYPE.BLOB,jpeg:e.XHR_RESPONSE_TYPE.BLOB,tif:e.XHR_RESPONSE_TYPE.BLOB,tiff:e.XHR_RESPONSE_TYPE.BLOB,webp:e.XHR_RESPONSE_TYPE.BLOB,tga:e.XHR_RESPONSE_TYPE.BLOB,json:e.XHR_RESPONSE_TYPE.JSON,text:e.XHR_RESPONSE_TYPE.TEXT,txt:e.XHR_RESPONSE_TYPE.TEXT,ttf:e.XHR_RESPONSE_TYPE.BUFFER,otf:e.XHR_RESPONSE_TYPE.BUFFER},e.EMPTY_GIF="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="})(Bn||(Bn={}));function bp(){}function $mt(e){return function(){for(var i=arguments,n=[],I=0;I>2,I[1]=(n[0]&3)<<4|n[1]>>4,I[2]=(n[1]&15)<<2|n[2]>>6,I[3]=n[2]&63;var o=i-(e.length-1);switch(o){case 2:I[3]=64,I[2]=64;break;case 1:I[3]=64;break}for(var r=0;r0&&r[r.length-1])&&(A[0]===6||A[0]===2)){i=0;continue}if(A[0]===3&&(!r||A[1]>r[0]&&A[1]=33776&&i<=33779)return"s3tc";if(i>=37488&&i<=37497)return"etc";if(i>=35840&&i<=35843)return"pvrtc";if(i>=36196)return"etc1";if(i>=35986&&i<=34798)return"atc";throw new Error("Invalid (compressed) texture format given!")},g._createLevelBuffers=function(i,n,I,r,o,C,a){for(var A=new Array(I),s=i.byteOffset,l=C,c=a,u=l+r-1&~(r-1),d=c+o-1&~(o-1),h=u*d*wX[n],f=0;f1?l:u,levelHeight:I>1?c:d,levelBuffer:new Uint8Array(i.buffer,s,h)},s+=h,l=l>>1||1,c=c>>1||1,u=l+r-1&~(r-1),d=c+o-1&~(o-1),h=u*d*wX[n];return A},g}(LFe),UFe=function(){function e(){}return e.use=function(g,i){var n=g.data,I=this;if(g.type===Bn.TYPE.JSON&&n&&n.cacheID&&n.textures){for(var r=n.textures,o=void 0,C=void 0,a=0,A=r.length;a>>1,R=R>>>1}for(var X=v,w=0;w1||r!==0?S:w,levelHeight:u>1||r!==0?R:T,levelBuffer:new Uint8Array(g,N,B)},N+=B}W+=X+4,W=W%4!==0?W+4-W%4:W,S=S>>1||1,R=R>>1||1,w=S+h-1&~(h-1),T=R+f-1&~(f-1),B=w*T*Z}return r!==0?{uncompressed:p.map(function(M){var F=M[0].levelBuffer,$=!1;return r===ng.FLOAT?F=new Float32Array(M[0].levelBuffer.buffer,M[0].levelBuffer.byteOffset,M[0].levelBuffer.byteLength/4):r===ng.UNSIGNED_INT?($=!0,F=new Uint32Array(M[0].levelBuffer.buffer,M[0].levelBuffer.byteOffset,M[0].levelBuffer.byteLength/4)):r===ng.INT&&($=!0,F=new Int32Array(M[0].levelBuffer.buffer,M[0].levelBuffer.byteOffset,M[0].levelBuffer.byteLength/4)),{resource:new Ky(F,{width:M[0].levelWidth,height:M[0].levelHeight}),type:r,format:$?Bpt(o):o}}),kvData:v}:{compressed:p.map(function(M){return new Dx(null,{format:C,width:a,height:A,levels:u,levelBuffers:M})}),kvData:v}}function vpt(e,g){for(var i=0;ig-I){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}for(var a=0;aC&&(I=C),o._properties=[!1,!0,!1,!1,!1],o._maxSize=i,o._batchSize=I,o._buffers=null,o._bufferUpdateIDs=[],o._updateID=0,o.interactiveChildren=!1,o.blendMode=ag.NORMAL,o.autoResize=r,o.roundPixels=!0,o.baseTexture=null,o.setProperties(n),o._tint=0,o.tintRgb=new Float32Array(4),o.tint=16777215,o}return g.prototype.setProperties=function(i){i&&(this._properties[0]="vertices"in i||"scale"in i?!!i.vertices||!!i.scale:this._properties[0],this._properties[1]="position"in i?!!i.position:this._properties[1],this._properties[2]="rotation"in i?!!i.rotation:this._properties[2],this._properties[3]="uvs"in i?!!i.uvs:this._properties[3],this._properties[4]="tint"in i||"alpha"in i?!!i.tint||!!i.alpha:this._properties[4])},g.prototype.updateTransform=function(){this.displayObjectUpdateTransform()},Object.defineProperty(g.prototype,"tint",{get:function(){return this._tint},set:function(i){this._tint=i,pb(i,this.tintRgb)},enumerable:!1,configurable:!0}),g.prototype.render=function(i){var n=this;!this.visible||this.worldAlpha<=0||!this.children.length||!this.renderable||(this.baseTexture||(this.baseTexture=this.children[0]._texture.baseTexture,this.baseTexture.valid||this.baseTexture.once("update",function(){return n.onChildrenChange(0)})),i.batch.setObjectRenderer(i.plugins.particle),i.plugins.particle.render(this))},g.prototype.onChildrenChange=function(i){for(var n=Math.floor(i/this._batchSize);this._bufferUpdateIDs.lengthI&&!i.autoResize&&(C=I);var a=i._buffers;a||(a=i._buffers=this.generateBuffers(i));var A=n[0]._texture.baseTexture,s=A.alphaMode>0;this.state.blendMode=_re(i.blendMode,s),o.state.set(this.state);var l=o.gl,c=i.worldTransform.copyTo(this.tempMatrix);c.prepend(o.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=c.toArray(!0),this.shader.uniforms.uColor=Qxe(i.tintRgb,i.worldAlpha,this.shader.uniforms.uColor,s),this.shader.uniforms.uSampler=A,this.renderer.shader.bind(this.shader);for(var u=!1,d=0,h=0;dr&&(f=r),h>=a.length&&a.push(this._generateOneMoreBuffer(i));var m=a[h];m.uploadDynamic(n,d,f);var b=i._bufferUpdateIDs[h]||0;u=u||m._updateID0,l=A.alpha,c=l<1&&s?q3(A._tintRGB,l):A._tintRGB+(l*255<<24);r[C]=c,r[C+o]=c,r[C+o*2]=c,r[C+o*3]=c,C+=o*4}},g.prototype.destroy=function(){e.prototype.destroy.call(this),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null},g.extension={name:"particle",type:Zi.RendererPlugin},g}(lT);/*! + * @pixi/graphics - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/graphics is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */var Lu;(function(e){e.MITER="miter",e.BEVEL="bevel",e.ROUND="round"})(Lu||(Lu={}));var Uu;(function(e){e.BUTT="butt",e.ROUND="round",e.SQUARE="square"})(Uu||(Uu={}));var XB={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount:function(e,g){if(g===void 0&&(g=20),!this.adaptive||!e||isNaN(e))return g;var i=Math.ceil(e/this.maxLength);return ithis.maxSegments&&(i=this.maxSegments),i}},voe=function(){function e(){this.color=16777215,this.alpha=1,this.texture=Zg.WHITE,this.matrix=null,this.visible=!1,this.reset()}return e.prototype.clone=function(){var g=new e;return g.color=this.color,g.alpha=this.alpha,g.texture=this.texture,g.matrix=this.matrix,g.visible=this.visible,g},e.prototype.reset=function(){this.color=16777215,this.alpha=1,this.texture=Zg.WHITE,this.matrix=null,this.visible=!1},e.prototype.destroy=function(){this.texture=null,this.matrix=null},e}();/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */var x8=function(e,g){return x8=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var I in n)n.hasOwnProperty(I)&&(i[I]=n[I])},x8(e,g)};function Boe(e,g){x8(e,g);function i(){this.constructor=e}e.prototype=g===null?Object.create(g):(i.prototype=g.prototype,new i)}function fbe(e,g){var i,n;g===void 0&&(g=!1);var I=e.length;if(!(I<6)){for(var r=0,o=0,C=e[I-2],a=e[I-1];o0||g&&r<=0)for(var l=I/2,o=l+l%2;o=6){fbe(i,!1);for(var o=[],C=0;C=0&&C>=0&&I>=0&&r>=0)){g.length=0;return}var u=Math.ceil(2.3*Math.sqrt(o+C)),d=u*8+(I?4:0)+(r?4:0);if(g.length=d,d!==0){if(u===0){g.length=8,g[0]=g[6]=i+I,g[1]=g[3]=n+r,g[2]=g[4]=i-I,g[5]=g[7]=n-r;return}var h=0,f=u*4+(I?2:0)+2,m=f,b=d;{var p=I+o,y=r,Z=i+p,v=i-p,G=n+y;if(g[h++]=Z,g[h++]=G,g[--f]=G,g[--f]=v,r){var B=n-y;g[m++]=v,g[m++]=B,g[--b]=B,g[--b]=Z}}for(var S=1;Sl&&(l+=Math.PI*2);var c=s,u=l-s,d=Math.abs(u),h=Math.sqrt(a*a+A*A),f=(15*d*Math.sqrt(h)/Math.PI>>0)+1,m=u/f;if(c+=m,C){o.push(e,g),o.push(i,n);for(var b=1,p=c;bb?(U?(c.push(oe,pe),c.push(Z+S*N,v+R*N),c.push(oe,pe),c.push(Z+w*N,v+T*N)):(c.push(Z-S*X,v-R*X),c.push(ae,ie),c.push(Z-w*X,v-T*X),c.push(ae,ie)),d+=2):r.join===Lu.ROUND?U?(c.push(oe,pe),c.push(Z+S*N,v+R*N),d+=NZ(Z,v,Z+S*N,v+R*N,Z+w*N,v+T*N,c,!0)+4,c.push(oe,pe),c.push(Z+w*N,v+T*N)):(c.push(Z-S*X,v-R*X),c.push(ae,ie),d+=NZ(Z,v,Z-S*X,v-R*X,Z-w*X,v-T*X,c,!1)+4,c.push(Z-w*X,v-T*X),c.push(ae,ie)):(c.push(oe,pe),c.push(ae,ie)):(c.push(Z-S*X,v-R*X),c.push(Z+S*N,v+R*N),r.join===Lu.ROUND?U?d+=NZ(Z,v,Z+S*N,v+R*N,Z+w*N,v+T*N,c,!0)+2:d+=NZ(Z,v,Z-S*X,v-R*X,Z-w*X,v-T*X,c,!1)+2:r.join===Lu.MITER&&Ve/m<=b&&(U?(c.push(ae,ie),c.push(ae,ie)):(c.push(oe,pe),c.push(oe,pe)),d+=2),c.push(Z-w*X,v-T*X),c.push(Z+w*N,v+T*N),d+=2)}p=n[(u-2)*2],y=n[(u-2)*2+1],Z=n[(u-1)*2],v=n[(u-1)*2+1],S=-(y-v),R=p-Z,W=Math.sqrt(S*S+R*R),S/=W,R/=W,S*=f,R*=f,c.push(Z-S*X,v-R*X),c.push(Z+S*N,v+R*N),a||(r.cap===Uu.ROUND?d+=NZ(Z-S*(X-N)*.5,v-R*(X-N)*.5,Z-S*X,v-R*X,Z+S*N,v+R*N,c,!1)+2:r.cap===Uu.SQUARE&&(d+=mbe(Z,v,S,R,X,N,!1,c)));for(var ke=g.indices,_e=XB.epsilon*XB.epsilon,Y=h;Yc*A}},e.arc=function(g,i,n,I,r,o,C,a,A){for(var s=C-o,l=XB._segmentsCount(Math.abs(s)*r,Math.ceil(Math.abs(s)/ZX)*40),c=s/(l*2),u=c*2,d=Math.cos(c),h=Math.sin(c),f=l-1,m=f%1/f,b=0;b<=f;++b){var p=b+m*b,y=c+o+u*p,Z=Math.cos(y),v=-Math.sin(y);A.push((d*Z+h*v)*r+n,(d*-v+h*Z)*r+I)}},e}(),oEe=function(){function e(){}return e.curveLength=function(g,i,n,I,r,o,C,a){for(var A=10,s=0,l=0,c=0,u=0,d=0,h=0,f=0,m=0,b=0,p=0,y=0,Z=g,v=i,G=1;G<=A;++G)l=G/A,c=l*l,u=c*l,d=1-l,h=d*d,f=h*d,m=f*g+3*h*l*n+3*d*c*r+u*C,b=f*i+3*h*l*I+3*d*c*o+u*a,p=Z-m,y=v-b,Z=m,v=b,s+=Math.sqrt(p*p+y*y);return s},e.curveTo=function(g,i,n,I,r,o,C){var a=C[C.length-2],A=C[C.length-1];C.length-=2;var s=XB._segmentsCount(e.curveLength(a,A,g,i,n,I,r,o)),l=0,c=0,u=0,d=0,h=0;C.push(a,A);for(var f=1,m=0;f<=s;++f)m=f/s,l=1-m,c=l*l,u=c*l,d=m*m,h=d*m,C.push(u*a+3*c*m*g+3*l*d*n+h*r,u*A+3*c*m*i+3*l*d*I+h*o)},e}(),CEe=function(){function e(){}return e.curveLength=function(g,i,n,I,r,o){var C=g-2*n+r,a=i-2*I+o,A=2*n-2*g,s=2*I-2*i,l=4*(C*C+a*a),c=4*(C*A+a*s),u=A*A+s*s,d=2*Math.sqrt(l+c+u),h=Math.sqrt(l),f=2*l*h,m=2*Math.sqrt(u),b=c/h;return(f*d+h*c*(d-m)+(4*u*l-c*c)*Math.log((2*h+b+d)/(b+m)))/(4*f)},e.curveTo=function(g,i,n,I,r){for(var o=r[r.length-2],C=r[r.length-1],a=XB._segmentsCount(e.curveLength(o,C,g,i,n,I)),A=0,s=0,l=1;l<=a;++l){var c=l/a;A=o+(g-o)*c,s=C+(i-C)*c,r.push(A+(g+(n-g)*c-A)*c,s+(i+(I-i)*c-s)*c)}},e}(),aEe=function(){function e(){this.reset()}return e.prototype.begin=function(g,i,n){this.reset(),this.style=g,this.start=i,this.attribStart=n},e.prototype.end=function(g,i){this.attribSize=i-this.attribStart,this.size=g-this.start},e.prototype.reset=function(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0},e}(),yp,XK=(yp={},yp[hI.POLY]=woe,yp[hI.CIRC]=SX,yp[hI.ELIP]=SX,yp[hI.RECT]=IEe,yp[hI.RREC]=rEe,yp),D8=[],fV=[],M8=function(){function e(g,i,n,I){i===void 0&&(i=null),n===void 0&&(n=null),I===void 0&&(I=null),this.points=[],this.holes=[],this.shape=g,this.lineStyle=n,this.fillStyle=i,this.matrix=I,this.type=g.type}return e.prototype.clone=function(){return new e(this.shape,this.fillStyle,this.lineStyle,this.matrix)},e.prototype.destroy=function(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null},e}(),kZ=new _i,sEe=function(e){Boe(g,e);function g(){var i=e.call(this)||this;return i.closePointEps=1e-4,i.boundsPadding=0,i.uvsFloat32=null,i.indicesUint16=null,i.batchable=!1,i.points=[],i.colors=[],i.uvs=[],i.indices=[],i.textureIds=[],i.graphicsData=[],i.drawCalls=[],i.batchDirty=-1,i.batches=[],i.dirty=0,i.cacheDirty=-1,i.clearDirty=0,i.shapeIndex=0,i._bounds=new GX,i.boundsDirty=-1,i}return Object.defineProperty(g.prototype,"bounds",{get:function(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds},enumerable:!1,configurable:!0}),g.prototype.invalidate=function(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(var i=0;i0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this},g.prototype.drawShape=function(i,n,I,r){n===void 0&&(n=null),I===void 0&&(I=null),r===void 0&&(r=null);var o=new M8(i,n,I,r);return this.graphicsData.push(o),this.dirty++,this},g.prototype.drawHole=function(i,n){if(n===void 0&&(n=null),!this.graphicsData.length)return null;var I=new M8(i,null,null,n),r=this.graphicsData[this.graphicsData.length-1];return I.lineStyle=r.lineStyle,r.holes.push(I),this.dirty++,this},g.prototype.destroy=function(){e.prototype.destroy.call(this);for(var i=0;i0&&(I=this.batches[this.batches.length-1],r=I.style);for(var o=this.shapeIndex;o65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&p===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=p?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}},g.prototype._compareStyles=function(i,n){return!(!i||!n||i.texture.baseTexture!==n.texture.baseTexture||i.color+i.alpha!==n.color+n.alpha||!!i.native!=!!n.native)},g.prototype.validateBatching=function(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(var i=0,n=this.graphicsData.length;i65535*2)return!1;for(var i=this.batches,n=0;n0&&(o=fV.pop(),o||(o=new xx,o.texArray=new Fx),this.drawCalls.push(o)),o.start=c,o.size=0,o.texArray.count=0,o.type=l),f.touched=1,f._batchEnabled=i,f._batchLocation=C,f.wrapMode=Cc.REPEAT,o.texArray.elements[o.texArray.count++]=f,C++)),o.size+=u.size,c+=u.size,A=f._batchLocation,this.addColors(I,h.color,h.alpha,u.attribSize,u.attribStart),this.addTextureIds(r,A,u.attribSize,u.attribStart)}_g._globalBatch=i,this.packAttributes()},g.prototype.packAttributes=function(){for(var i=this.points,n=this.uvs,I=this.colors,r=this.textureIds,o=new ArrayBuffer(i.length*3*4),C=new Float32Array(o),a=new Uint32Array(o),A=0,s=0;s>16)+(n&65280)+((n&255)<<16),a=q3(C,I);i.length=Math.max(i.length,o+r);for(var A=0;A0&&i.alpha>0;return n?(i.matrix&&(i.matrix=i.matrix.clone(),i.matrix.invert()),Object.assign(this._lineStyle,{visible:n},i)):this._lineStyle.reset(),this},g.prototype.startPoly=function(){if(this.currentPath){var i=this.currentPath.points,n=this.currentPath.points.length;n>2&&(this.drawShape(this.currentPath),this.currentPath=new Y2,this.currentPath.closeStroke=!1,this.currentPath.points.push(i[n-2],i[n-1]))}else this.currentPath=new Y2,this.currentPath.closeStroke=!1},g.prototype.finishPoly=function(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)},g.prototype.moveTo=function(i,n){return this.startPoly(),this.currentPath.points[0]=i,this.currentPath.points[1]=n,this},g.prototype.lineTo=function(i,n){this.currentPath||this.moveTo(0,0);var I=this.currentPath.points,r=I[I.length-2],o=I[I.length-1];return(r!==i||o!==n)&&I.push(i,n),this},g.prototype._initCurve=function(i,n){i===void 0&&(i=0),n===void 0&&(n=0),this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[i,n]):this.moveTo(i,n)},g.prototype.quadraticCurveTo=function(i,n,I,r){this._initCurve();var o=this.currentPath.points;return o.length===0&&this.moveTo(0,0),CEe.curveTo(i,n,I,r,o),this},g.prototype.bezierCurveTo=function(i,n,I,r,o,C){return this._initCurve(),oEe.curveTo(i,n,I,r,o,C,this.currentPath.points),this},g.prototype.arcTo=function(i,n,I,r,o){this._initCurve(i,n);var C=this.currentPath.points,a=E8.curveTo(i,n,I,r,o,C);if(a){var A=a.cx,s=a.cy,l=a.radius,c=a.startAngle,u=a.endAngle,d=a.anticlockwise;this.arc(A,s,l,c,u,d)}return this},g.prototype.arc=function(i,n,I,r,o,C){if(C===void 0&&(C=!1),r===o)return this;!C&&o<=r?o+=ZX:C&&r<=o&&(r+=ZX);var a=o-r;if(a===0)return this;var A=i+Math.cos(r)*I,s=n+Math.sin(r)*I,l=this._geometry.closePointEps,c=this.currentPath?this.currentPath.points:null;if(c){var u=Math.abs(c[c.length-2]-A),d=Math.abs(c[c.length-1]-s);u0;return n?(i.matrix&&(i.matrix=i.matrix.clone(),i.matrix.invert()),Object.assign(this._fillStyle,{visible:n},i)):this._fillStyle.reset(),this},g.prototype.endFill=function(){return this.finishPoly(),this._fillStyle.reset(),this},g.prototype.drawRect=function(i,n,I,r){return this.drawShape(new Lg(i,n,I,r))},g.prototype.drawRoundedRect=function(i,n,I,r,o){return this.drawShape(new IFe(i,n,I,r,o))},g.prototype.drawCircle=function(i,n,I){return this.drawShape(new iFe(i,n,I))},g.prototype.drawEllipse=function(i,n,I,r){return this.drawShape(new nFe(i,n,I,r))},g.prototype.drawPolygon=function(){for(var i=arguments,n=[],I=0;I>16&255)/255*o,C.tint[1]=(r>>8&255)/255*o,C.tint[2]=(r&255)/255*o,C.tint[3]=o,i.shader.bind(n),i.geometry.bind(I,n),i.state.set(this.state);for(var A=0,s=a.length;A>16)+(A&65280)+((A&255)<<16)}}},g.prototype.calculateVertices=function(){var i=this.transform._worldID;if(this._transformID!==i){this._transformID=i;for(var n=this.transform.worldTransform,I=n.a,r=n.b,o=n.c,C=n.d,a=n.tx,A=n.ty,s=this._geometry.points,l=this.vertexData,c=0,u=0;u=r&&QS.x=o&&QS.y>16)+(i&65280)+((i&255)<<16)},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"texture",{get:function(){return this._texture},set:function(i){this._texture!==i&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=i||Zg.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,i&&(i.baseTexture.valid?this._onTextureUpdate():i.once("update",this._onTextureUpdate,this)))},enumerable:!1,configurable:!0}),g}(zA);/*! + * @pixi/text - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/text is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */var P8=function(e,g){return P8=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var I in n)n.hasOwnProperty(I)&&(i[I]=n[I])},P8(e,g)};function Ypt(e,g){P8(e,g);function i(){this.constructor=e}e.prototype=g===null?Object.create(g):(i.prototype=g.prototype,new i)}var TB;(function(e){e[e.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",e[e.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL"})(TB||(TB={}));var KL={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:TB.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100,leading:0},Kpt=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],yb=function(){function e(g){this.styleID=0,this.reset(),FL(this,g,g)}return e.prototype.clone=function(){var g={};return FL(g,this,KL),new e(g)},e.prototype.reset=function(){FL(this,KL,KL)},Object.defineProperty(e.prototype,"align",{get:function(){return this._align},set:function(g){this._align!==g&&(this._align=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"breakWords",{get:function(){return this._breakWords},set:function(g){this._breakWords!==g&&(this._breakWords=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dropShadow",{get:function(){return this._dropShadow},set:function(g){this._dropShadow!==g&&(this._dropShadow=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dropShadowAlpha",{get:function(){return this._dropShadowAlpha},set:function(g){this._dropShadowAlpha!==g&&(this._dropShadowAlpha=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dropShadowAngle",{get:function(){return this._dropShadowAngle},set:function(g){this._dropShadowAngle!==g&&(this._dropShadowAngle=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dropShadowBlur",{get:function(){return this._dropShadowBlur},set:function(g){this._dropShadowBlur!==g&&(this._dropShadowBlur=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dropShadowColor",{get:function(){return this._dropShadowColor},set:function(g){var i=xL(g);this._dropShadowColor!==i&&(this._dropShadowColor=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dropShadowDistance",{get:function(){return this._dropShadowDistance},set:function(g){this._dropShadowDistance!==g&&(this._dropShadowDistance=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fill",{get:function(){return this._fill},set:function(g){var i=xL(g);this._fill!==i&&(this._fill=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fillGradientType",{get:function(){return this._fillGradientType},set:function(g){this._fillGradientType!==g&&(this._fillGradientType=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fillGradientStops",{get:function(){return this._fillGradientStops},set:function(g){xpt(this._fillGradientStops,g)||(this._fillGradientStops=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fontFamily",{get:function(){return this._fontFamily},set:function(g){this.fontFamily!==g&&(this._fontFamily=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fontSize",{get:function(){return this._fontSize},set:function(g){this._fontSize!==g&&(this._fontSize=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fontStyle",{get:function(){return this._fontStyle},set:function(g){this._fontStyle!==g&&(this._fontStyle=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fontVariant",{get:function(){return this._fontVariant},set:function(g){this._fontVariant!==g&&(this._fontVariant=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fontWeight",{get:function(){return this._fontWeight},set:function(g){this._fontWeight!==g&&(this._fontWeight=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"letterSpacing",{get:function(){return this._letterSpacing},set:function(g){this._letterSpacing!==g&&(this._letterSpacing=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineHeight",{get:function(){return this._lineHeight},set:function(g){this._lineHeight!==g&&(this._lineHeight=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leading",{get:function(){return this._leading},set:function(g){this._leading!==g&&(this._leading=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineJoin",{get:function(){return this._lineJoin},set:function(g){this._lineJoin!==g&&(this._lineJoin=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"miterLimit",{get:function(){return this._miterLimit},set:function(g){this._miterLimit!==g&&(this._miterLimit=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"padding",{get:function(){return this._padding},set:function(g){this._padding!==g&&(this._padding=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stroke",{get:function(){return this._stroke},set:function(g){var i=xL(g);this._stroke!==i&&(this._stroke=i,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"strokeThickness",{get:function(){return this._strokeThickness},set:function(g){this._strokeThickness!==g&&(this._strokeThickness=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textBaseline",{get:function(){return this._textBaseline},set:function(g){this._textBaseline!==g&&(this._textBaseline=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"trim",{get:function(){return this._trim},set:function(g){this._trim!==g&&(this._trim=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"whiteSpace",{get:function(){return this._whiteSpace},set:function(g){this._whiteSpace!==g&&(this._whiteSpace=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"wordWrap",{get:function(){return this._wordWrap},set:function(g){this._wordWrap!==g&&(this._wordWrap=g,this.styleID++)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"wordWrapWidth",{get:function(){return this._wordWrapWidth},set:function(g){this._wordWrapWidth!==g&&(this._wordWrapWidth=g,this.styleID++)},enumerable:!1,configurable:!0}),e.prototype.toFontString=function(){var g=typeof this.fontSize=="number"?this.fontSize+"px":this.fontSize,i=this.fontFamily;Array.isArray(this.fontFamily)||(i=this.fontFamily.split(","));for(var n=i.length-1;n>=0;n--){var I=i[n].trim();!/([\"\'])[^\'\"]+\1/.test(I)&&Kpt.indexOf(I)<0&&(I='"'+I+'"'),i[n]=I}return this.fontStyle+" "+this.fontVariant+" "+this.fontWeight+" "+g+" "+i.join(",")},e}();function pbe(e){return typeof e=="number"?Mre(e):(typeof e=="string"&&e.indexOf("0x")===0&&(e=e.replace("0x","#")),e)}function xL(e){if(Array.isArray(e)){for(var g=0;gd)if(o!==""&&(C+=e.addLine(o),o="",r=0),e.canBreakWords(m,i.breakWords))for(var Z=e.wordWrapSplit(m),v=0;vd&&(C+=e.addLine(o),u=!1,o="",r=0),o+=G,r+=w}else{o.length>0&&(C+=e.addLine(o),o="",r=0);var T=f===h.length-1;C+=e.addLine(m,!T),u=!1,o="",r=0}else y+r>d&&(u=!1,C+=e.addLine(o),o="",r=0),(o.length>0||!e.isBreakingSpace(m)||u)&&(o+=m,r+=y)}return C+=e.addLine(o,!1),C},e.addLine=function(g,i){return i===void 0&&(i=!0),g=e.trimRight(g),g=i?g+` +`:g,g},e.getFromCache=function(g,i,n,I){var r=n[g];if(typeof r!="number"){var o=g.length*i;r=I.measureText(g).width+o,n[g]=r}return r},e.collapseSpaces=function(g){return g==="normal"||g==="pre-line"},e.collapseNewlines=function(g){return g==="normal"},e.trimRight=function(g){if(typeof g!="string")return"";for(var i=g.length-1;i>=0;i--){var n=g[i];if(!e.isBreakingSpace(n))break;g=g.slice(0,-1)}return g},e.isNewline=function(g){return typeof g!="string"?!1:e._newlines.indexOf(g.charCodeAt(0))>=0},e.isBreakingSpace=function(g,i){return typeof g!="string"?!1:e._breakingSpaces.indexOf(g.charCodeAt(0))>=0},e.tokenize=function(g){var i=[],n="";if(typeof g!="string")return i;for(var I=0;IC;--c){for(var h=0;h0&&f>m&&(b=(m+f)/2);var p=m+h,y=I.lineHeight*(d+1),Z=p;d+10},e}();function Dpt(e,g){var i=!1;if(e&&e._textures&&e._textures.length){for(var n=0;n=0;i--)this.add(g.children[i]);return this},e.prototype.destroy=function(){this.ticking&&KI.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null},e}();function uEe(e,g){return g instanceof _g?(g._glTextures[e.CONTEXT_UID]||e.texture.bind(g),!0):!1}function Lpt(e,g){if(!(g instanceof RX))return!1;var i=g.geometry;g.finishPoly(),i.updateBatches();for(var n=i.batches,I=0;I=r&&jS.x=o&&jS.y1?cd.from(e0t,t0t,n):cd.from(bbe,qpt,n)},g.prototype.render=function(i){var n=this.renderer,I=this.quad,r=I.vertices;r[0]=r[6]=i._width*-i.anchor.x,r[1]=r[3]=i._height*-i.anchor.y,r[2]=r[4]=i._width*(1-i.anchor.x),r[5]=r[7]=i._height*(1-i.anchor.y);var o=i.uvRespectAnchor?i.anchor.x:0,C=i.uvRespectAnchor?i.anchor.y:0;r=I.uvs,r[0]=r[6]=-o,r[1]=r[3]=-C,r[2]=r[4]=1-o,r[5]=r[7]=1-C,I.invalidate();var a=i._texture,A=a.baseTexture,s=A.alphaMode>0,l=i.tileTransform.localTransform,c=i.uvMatrix,u=A.isPowerOfTwo&&a.frame.width===A.width&&a.frame.height===A.height;u&&(A._glTextures[n.CONTEXT_UID]?u=A.wrapMode!==Cc.CLAMP:A.wrapMode===Cc.CLAMP&&(A.wrapMode=Cc.REPEAT));var d=u?this.simpleShader:this.shader,h=a.width,f=a.height,m=i._width,b=i._height;Ik.set(l.a*h/m,l.b*h/b,l.c*f/m,l.d*f/b,l.tx/m,l.ty/b),Ik.invert(),u?Ik.prepend(c.mapCoord):(d.uniforms.uMapCoord=c.mapCoord.toArray(!0),d.uniforms.uClampFrame=c.uClampFrame,d.uniforms.uClampOffset=c.uClampOffset),d.uniforms.uTransform=Ik.toArray(!0),d.uniforms.uColor=Ore(i.tint,i.worldAlpha,d.uniforms.uColor,s),d.uniforms.translationMatrix=i.transform.worldTransform.toArray(!0),d.uniforms.uSampler=a,n.shader.bind(d),n.geometry.bind(I),this.state.blendMode=_re(i.blendMode,s),n.state.set(this.state),n.geometry.draw(this.renderer.gl.TRIANGLES,6,0)},g.extension={name:"tilingSprite",type:Zi.RendererPlugin},g}(lT);/*! + * @pixi/mesh - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/mesh is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */var J8=function(e,g){return J8=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var I in n)n.hasOwnProperty(I)&&(i[I]=n[I])},J8(e,g)};function Roe(e,g){J8(e,g);function i(){this.constructor=e}e.prototype=g===null?Object.create(g):(i.prototype=g.prototype,new i)}var bEe=function(){function e(g,i){this.uvBuffer=g,this.uvMatrix=i,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}return e.prototype.update=function(g){if(!(!g&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)){this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;var i=this.uvBuffer.data;(!this.data||this.data.length!==i.length)&&(this.data=new Float32Array(i.length)),this.uvMatrix.multiplyUvs(i,this.data),this._updateID++}},e}(),EL=new _i,ybe=new Y2,HB=function(e){Roe(g,e);function g(i,n,I,r){r===void 0&&(r=ja.TRIANGLES);var o=e.call(this)||this;return o.geometry=i,o.shader=n,o.state=I||Ym.for2d(),o.drawMode=r,o.start=0,o.size=0,o.uvs=null,o.indices=null,o.vertexData=new Float32Array(1),o.vertexDirty=-1,o._transformID=-1,o._roundPixels=Ht.ROUND_PIXELS,o.batchUvs=null,o}return Object.defineProperty(g.prototype,"geometry",{get:function(){return this._geometry},set:function(i){this._geometry!==i&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=i,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"uvBuffer",{get:function(){return this.geometry.buffers[1]},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"verticesBuffer",{get:function(){return this.geometry.buffers[0]},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"material",{get:function(){return this.shader},set:function(i){this.shader=i},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"blendMode",{get:function(){return this.state.blendMode},set:function(i){this.state.blendMode=i},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"roundPixels",{get:function(){return this._roundPixels},set:function(i){this._roundPixels!==i&&(this._transformID=-1),this._roundPixels=i},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"tint",{get:function(){return"tint"in this.shader?this.shader.tint:null},set:function(i){this.shader.tint=i},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"texture",{get:function(){return"texture"in this.shader?this.shader.texture:null},set:function(i){this.shader.texture=i},enumerable:!1,configurable:!0}),g.prototype._render=function(i){var n=this.geometry.buffers[0].data,I=this.shader;I.batchable&&this.drawMode===ja.TRIANGLES&&n.length>16)+(i&65280)+((i&255)<<16),this._colorDirty=!0)},enumerable:!1,configurable:!0}),g.prototype.update=function(){if(this._colorDirty){this._colorDirty=!1;var i=this.texture.baseTexture;Ore(this._tint,this._alpha,this.uniforms.uColor,i.alphaMode)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)},g}(cd),cT=function(e){Roe(g,e);function g(i,n,I){var r=e.call(this)||this,o=new gI(i),C=new gI(n,!0),a=new gI(I,!0,!0);return r.addAttribute("aVertexPosition",o,2,!1,ng.FLOAT).addAttribute("aTextureCoord",C,2,!1,ng.FLOAT).addIndex(a),r._updateId=-1,r}return Object.defineProperty(g.prototype,"vertexDirtyId",{get:function(){return this.buffers[0]._updateID},enumerable:!1,configurable:!0}),g}(b1);/*! + * @pixi/text-bitmap - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/text-bitmap is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */var L8=function(e,g){return L8=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var I in n)n.hasOwnProperty(I)&&(i[I]=n[I])},L8(e,g)};function n0t(e,g){L8(e,g);function i(){this.constructor=e}e.prototype=g===null?Object.create(g):(i.prototype=g.prototype,new i)}var VX=function(){function e(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}return e}(),yEe=function(){function e(){}return e.test=function(g){return typeof g=="string"&&g.indexOf("info face=")===0},e.parse=function(g){var i=g.match(/^[a-z]+\s+.+$/gm),n={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(var I in i){var r=i[I].match(/^[a-z]+/gm)[0],o=i[I].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),C={};for(var a in o){var A=o[a].split("="),s=A[0],l=A[1].replace(/"/gm,""),c=parseFloat(l),u=isNaN(c)?l:c;C[s]=u}n[r].push(C)}var d=new VX;return n.info.forEach(function(h){return d.info.push({face:h.face,size:parseInt(h.size,10)})}),n.common.forEach(function(h){return d.common.push({lineHeight:parseInt(h.lineHeight,10)})}),n.page.forEach(function(h){return d.page.push({id:parseInt(h.id,10),file:h.file})}),n.char.forEach(function(h){return d.char.push({id:parseInt(h.id,10),page:parseInt(h.page,10),x:parseInt(h.x,10),y:parseInt(h.y,10),width:parseInt(h.width,10),height:parseInt(h.height,10),xoffset:parseInt(h.xoffset,10),yoffset:parseInt(h.yoffset,10),xadvance:parseInt(h.xadvance,10)})}),n.kerning.forEach(function(h){return d.kerning.push({first:parseInt(h.first,10),second:parseInt(h.second,10),amount:parseInt(h.amount,10)})}),n.distanceField.forEach(function(h){return d.distanceField.push({distanceRange:parseInt(h.distanceRange,10),fieldType:h.fieldType})}),d},e}(),Mx=function(){function e(){}return e.test=function(g){return g instanceof XMLDocument&&g.getElementsByTagName("page").length&&g.getElementsByTagName("info")[0].getAttribute("face")!==null},e.parse=function(g){for(var i=new VX,n=g.getElementsByTagName("info"),I=g.getElementsByTagName("common"),r=g.getElementsByTagName("page"),o=g.getElementsByTagName("char"),C=g.getElementsByTagName("kerning"),a=g.getElementsByTagName("distanceField"),A=0;A")>-1){var i=new globalThis.DOMParser().parseFromString(g,"text/xml");return Mx.test(i)}return!1},e.parse=function(g){var i=new globalThis.DOMParser().parseFromString(g,"text/xml");return Mx.parse(i)},e}(),DL=[yEe,Mx,ZEe];function Voe(e){for(var g=0;g=A-B*C){if(h===0)throw new Error("[BitmapFont] textureHeight "+A+"px is "+("too small for "+l.fontSize+"px fonts"));--Z,f=null,m=null,b=null,h=0,d=0,p=0;continue}if(p=Math.max(B+v.fontProperties.descent,p),S*C+d>=c){--Z,h+=p*C,h=Math.ceil(h),d=0,p=0;continue}r0t(f,m,v,d,h,C,l);var R=TK(v.text);u.char.push({id:R,page:y.length-1,x:d/C,y:h/C,width:S,height:B,xoffset:0,yoffset:0,xadvance:Math.ceil(G-(l.dropShadow?l.dropShadowDistance:0)-(l.stroke?l.strokeThickness:0))}),d+=(S+2*o)*C,d=Math.ceil(d)}for(var Z=0,w=s.length;Z0&&r.x>l&&(++p,E0(o,1+m-p,1+v-m),v=m,m=-1,C.push(b),a.push(o.length>0?o[o.length-1].prevSpaces:0),h=Math.max(h,b),f++,r.x=0,r.y+=n.lineHeight,u=null,Z=0)}}var w=s[s.length-1];w!=="\r"&&w!==` +`&&(/(?:\s)/.test(w)&&(d=b),C.push(d),h=Math.max(h,d),a.push(-1));for(var T=[],v=0;v<=f;v++){var W=0;this._align==="right"?W=h-C[v]:this._align==="center"?W=(h-C[v])/2:this._align==="justify"&&(W=a[v]<0?0:(h-C[v])/a[v]),T.push(W)}for(var V=o.length,X={},N=[],Y=this._activePagesMeshData,v=0;v6*Ie)||F.vertices.length=i&&(o=e-C-1),a=a.replace("%value%",g[o].toString()),I+=a,I+=` +`}return n=n.replace("%blur%",I),n=n.replace("%size%",e.toString()),n}/*! + * @pixi/constants - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/constants is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */var Gbe;(function(e){e[e.WEBGL_LEGACY=0]="WEBGL_LEGACY",e[e.WEBGL=1]="WEBGL",e[e.WEBGL2=2]="WEBGL2"})(Gbe||(Gbe={}));var vbe;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.WEBGL=1]="WEBGL",e[e.CANVAS=2]="CANVAS"})(vbe||(vbe={}));var Bbe;(function(e){e[e.COLOR=16384]="COLOR",e[e.DEPTH=256]="DEPTH",e[e.STENCIL=1024]="STENCIL"})(Bbe||(Bbe={}));var wbe;(function(e){e[e.NORMAL=0]="NORMAL",e[e.ADD=1]="ADD",e[e.MULTIPLY=2]="MULTIPLY",e[e.SCREEN=3]="SCREEN",e[e.OVERLAY=4]="OVERLAY",e[e.DARKEN=5]="DARKEN",e[e.LIGHTEN=6]="LIGHTEN",e[e.COLOR_DODGE=7]="COLOR_DODGE",e[e.COLOR_BURN=8]="COLOR_BURN",e[e.HARD_LIGHT=9]="HARD_LIGHT",e[e.SOFT_LIGHT=10]="SOFT_LIGHT",e[e.DIFFERENCE=11]="DIFFERENCE",e[e.EXCLUSION=12]="EXCLUSION",e[e.HUE=13]="HUE",e[e.SATURATION=14]="SATURATION",e[e.COLOR=15]="COLOR",e[e.LUMINOSITY=16]="LUMINOSITY",e[e.NORMAL_NPM=17]="NORMAL_NPM",e[e.ADD_NPM=18]="ADD_NPM",e[e.SCREEN_NPM=19]="SCREEN_NPM",e[e.NONE=20]="NONE",e[e.SRC_OVER=0]="SRC_OVER",e[e.SRC_IN=21]="SRC_IN",e[e.SRC_OUT=22]="SRC_OUT",e[e.SRC_ATOP=23]="SRC_ATOP",e[e.DST_OVER=24]="DST_OVER",e[e.DST_IN=25]="DST_IN",e[e.DST_OUT=26]="DST_OUT",e[e.DST_ATOP=27]="DST_ATOP",e[e.ERASE=26]="ERASE",e[e.SUBTRACT=28]="SUBTRACT",e[e.XOR=29]="XOR"})(wbe||(wbe={}));var Sbe;(function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN"})(Sbe||(Sbe={}));var Rbe;(function(e){e[e.RGBA=6408]="RGBA",e[e.RGB=6407]="RGB",e[e.RG=33319]="RG",e[e.RED=6403]="RED",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.ALPHA=6406]="ALPHA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL"})(Rbe||(Rbe={}));var Vbe;(function(e){e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z"})(Vbe||(Vbe={}));var Wbe;(function(e){e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.BYTE=5120]="BYTE",e[e.SHORT=5122]="SHORT",e[e.INT=5124]="INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.HALF_FLOAT=36193]="HALF_FLOAT"})(Wbe||(Wbe={}));var Xbe;(function(e){e[e.FLOAT=0]="FLOAT",e[e.INT=1]="INT",e[e.UINT=2]="UINT"})(Xbe||(Xbe={}));var Tbe;(function(e){e[e.NEAREST=0]="NEAREST",e[e.LINEAR=1]="LINEAR"})(Tbe||(Tbe={}));var Hbe;(function(e){e[e.CLAMP=33071]="CLAMP",e[e.REPEAT=10497]="REPEAT",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"})(Hbe||(Hbe={}));var Nbe;(function(e){e[e.OFF=0]="OFF",e[e.POW2=1]="POW2",e[e.ON=2]="ON",e[e.ON_MANUAL=3]="ON_MANUAL"})(Nbe||(Nbe={}));var kbe;(function(e){e[e.NPM=0]="NPM",e[e.UNPACK=1]="UNPACK",e[e.PMA=2]="PMA",e[e.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",e[e.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",e[e.PREMULTIPLY_ALPHA=2]="PREMULTIPLY_ALPHA",e[e.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA"})(kbe||(kbe={}));var WX;(function(e){e[e.NO=0]="NO",e[e.YES=1]="YES",e[e.AUTO=2]="AUTO",e[e.BLEND=0]="BLEND",e[e.CLEAR=1]="CLEAR",e[e.BLIT=2]="BLIT"})(WX||(WX={}));var Ybe;(function(e){e[e.AUTO=0]="AUTO",e[e.MANUAL=1]="MANUAL"})(Ybe||(Ybe={}));var Kbe;(function(e){e.LOW="lowp",e.MEDIUM="mediump",e.HIGH="highp"})(Kbe||(Kbe={}));var xbe;(function(e){e[e.NONE=0]="NONE",e[e.SCISSOR=1]="SCISSOR",e[e.STENCIL=2]="STENCIL",e[e.SPRITE=3]="SPRITE",e[e.COLOR=4]="COLOR"})(xbe||(xbe={}));var Fbe;(function(e){e[e.RED=1]="RED",e[e.GREEN=2]="GREEN",e[e.BLUE=4]="BLUE",e[e.ALPHA=8]="ALPHA"})(Fbe||(Fbe={}));var Ebe;(function(e){e[e.NONE=0]="NONE",e[e.LOW=2]="LOW",e[e.MEDIUM=4]="MEDIUM",e[e.HIGH=8]="HIGH"})(Ebe||(Ebe={}));var Dbe;(function(e){e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER"})(Dbe||(Dbe={}));var j8=function(e){BEe(g,e);function g(i,n,I,r,o){n===void 0&&(n=8),I===void 0&&(I=4),r===void 0&&(r=Ht.FILTER_RESOLUTION),o===void 0&&(o=5);var C=this,a=f0t(o,i),A=b0t(o);return C=e.call(this,a,A)||this,C.horizontal=i,C.resolution=r,C._quality=0,C.quality=I,C.blur=n,C}return g.prototype.apply=function(i,n,I,r){if(I?this.horizontal?this.uniforms.strength=1/I.width*(I.width/n.width):this.uniforms.strength=1/I.height*(I.height/n.height):this.horizontal?this.uniforms.strength=1/i.renderer.width*(i.renderer.width/n.width):this.uniforms.strength=1/i.renderer.height*(i.renderer.height/n.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)i.applyFilter(this,n,I,r);else{var o=i.getFilterTexture(),C=i.renderer,a=n,A=o;this.state.blend=!1,i.applyFilter(this,a,A,WX.CLEAR);for(var s=1;s 0.0) { + c.rgb /= c.a; + } + + vec4 result; + + result.r = (m[0] * c.r); + result.r += (m[1] * c.g); + result.r += (m[2] * c.b); + result.r += (m[3] * c.a); + result.r += m[4]; + + result.g = (m[5] * c.r); + result.g += (m[6] * c.g); + result.g += (m[7] * c.b); + result.g += (m[8] * c.a); + result.g += m[9]; + + result.b = (m[10] * c.r); + result.b += (m[11] * c.g); + result.b += (m[12] * c.b); + result.b += (m[13] * c.a); + result.b += m[14]; + + result.a = (m[15] * c.r); + result.a += (m[16] * c.g); + result.a += (m[17] * c.b); + result.a += (m[18] * c.a); + result.a += m[19]; + + vec3 rgb = mix(c.rgb, result.rgb, uAlpha); + + // Premultiply alpha again. + rgb *= result.a; + + gl_FragColor = vec4(rgb, result.a); +} +`,q8=function(e){Z0t(g,e);function g(){var i=this,n={m:new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),uAlpha:1};return i=e.call(this,boe,G0t,n)||this,i.alpha=1,i}return g.prototype._loadMatrix=function(i,n){n===void 0&&(n=!1);var I=i;n&&(this._multiply(I,this.uniforms.m,i),I=this._colorMatrix(I)),this.uniforms.m=I},g.prototype._multiply=function(i,n,I){return i[0]=n[0]*I[0]+n[1]*I[5]+n[2]*I[10]+n[3]*I[15],i[1]=n[0]*I[1]+n[1]*I[6]+n[2]*I[11]+n[3]*I[16],i[2]=n[0]*I[2]+n[1]*I[7]+n[2]*I[12]+n[3]*I[17],i[3]=n[0]*I[3]+n[1]*I[8]+n[2]*I[13]+n[3]*I[18],i[4]=n[0]*I[4]+n[1]*I[9]+n[2]*I[14]+n[3]*I[19]+n[4],i[5]=n[5]*I[0]+n[6]*I[5]+n[7]*I[10]+n[8]*I[15],i[6]=n[5]*I[1]+n[6]*I[6]+n[7]*I[11]+n[8]*I[16],i[7]=n[5]*I[2]+n[6]*I[7]+n[7]*I[12]+n[8]*I[17],i[8]=n[5]*I[3]+n[6]*I[8]+n[7]*I[13]+n[8]*I[18],i[9]=n[5]*I[4]+n[6]*I[9]+n[7]*I[14]+n[8]*I[19]+n[9],i[10]=n[10]*I[0]+n[11]*I[5]+n[12]*I[10]+n[13]*I[15],i[11]=n[10]*I[1]+n[11]*I[6]+n[12]*I[11]+n[13]*I[16],i[12]=n[10]*I[2]+n[11]*I[7]+n[12]*I[12]+n[13]*I[17],i[13]=n[10]*I[3]+n[11]*I[8]+n[12]*I[13]+n[13]*I[18],i[14]=n[10]*I[4]+n[11]*I[9]+n[12]*I[14]+n[13]*I[19]+n[14],i[15]=n[15]*I[0]+n[16]*I[5]+n[17]*I[10]+n[18]*I[15],i[16]=n[15]*I[1]+n[16]*I[6]+n[17]*I[11]+n[18]*I[16],i[17]=n[15]*I[2]+n[16]*I[7]+n[17]*I[12]+n[18]*I[17],i[18]=n[15]*I[3]+n[16]*I[8]+n[17]*I[13]+n[18]*I[18],i[19]=n[15]*I[4]+n[16]*I[9]+n[17]*I[14]+n[18]*I[19]+n[19],i},g.prototype._colorMatrix=function(i){var n=new Float32Array(i);return n[4]/=255,n[9]/=255,n[14]/=255,n[19]/=255,n},g.prototype.brightness=function(i,n){var I=[i,0,0,0,0,0,i,0,0,0,0,0,i,0,0,0,0,0,1,0];this._loadMatrix(I,n)},g.prototype.tint=function(i,n){var I=i>>16&255,r=i>>8&255,o=i&255,C=[I/255,0,0,0,0,0,r/255,0,0,0,0,0,o/255,0,0,0,0,0,1,0];this._loadMatrix(C,n)},g.prototype.greyscale=function(i,n){var I=[i,i,i,0,0,i,i,i,0,0,i,i,i,0,0,0,0,0,1,0];this._loadMatrix(I,n)},g.prototype.blackAndWhite=function(i){var n=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(n,i)},g.prototype.hue=function(i,n){i=(i||0)/180*Math.PI;var I=Math.cos(i),r=Math.sin(i),o=Math.sqrt,C=1/3,a=o(C),A=I+(1-I)*C,s=C*(1-I)-a*r,l=C*(1-I)+a*r,c=C*(1-I)+a*r,u=I+C*(1-I),d=C*(1-I)-a*r,h=C*(1-I)-a*r,f=C*(1-I)+a*r,m=I+C*(1-I),b=[A,s,l,0,0,c,u,d,0,0,h,f,m,0,0,0,0,0,1,0];this._loadMatrix(b,n)},g.prototype.contrast=function(i,n){var I=(i||0)+1,r=-.5*(I-1),o=[I,0,0,0,r,0,I,0,0,r,0,0,I,0,r,0,0,0,1,0];this._loadMatrix(o,n)},g.prototype.saturate=function(i,n){i===void 0&&(i=0);var I=i*2/3+1,r=(I-1)*-.5,o=[I,r,r,0,0,r,I,r,0,0,r,r,I,0,0,0,0,0,1,0];this._loadMatrix(o,n)},g.prototype.desaturate=function(){this.saturate(-1)},g.prototype.negative=function(i){var n=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(n,i)},g.prototype.sepia=function(i){var n=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(n,i)},g.prototype.technicolor=function(i){var n=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(n,i)},g.prototype.polaroid=function(i){var n=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(n,i)},g.prototype.toBGR=function(i){var n=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(n,i)},g.prototype.kodachrome=function(i){var n=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(n,i)},g.prototype.browni=function(i){var n=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(n,i)},g.prototype.vintage=function(i){var n=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(n,i)},g.prototype.colorTone=function(i,n,I,r,o){i=i||.2,n=n||.15,I=I||16770432,r=r||3375104;var C=(I>>16&255)/255,a=(I>>8&255)/255,A=(I&255)/255,s=(r>>16&255)/255,l=(r>>8&255)/255,c=(r&255)/255,u=[.3,.59,.11,0,0,C,a,A,i,0,s,l,c,n,0,C-s,a-l,A-c,0,0];this._loadMatrix(u,o)},g.prototype.night=function(i,n){i=i||.1;var I=[i*-2,-i,0,0,0,-i,0,i,0,0,0,i,i*2,0,0,0,0,0,1,0];this._loadMatrix(I,n)},g.prototype.predator=function(i,n){var I=[11.224130630493164*i,-4.794486999511719*i,-2.8746118545532227*i,0*i,.40342438220977783*i,-3.6330697536468506*i,9.193157196044922*i,-2.951810836791992*i,0*i,-1.316135048866272*i,-3.2184197902679443*i,-4.2375030517578125*i,7.476448059082031*i,0*i,.8044459223747253*i,0,0,0,1,0];this._loadMatrix(I,n)},g.prototype.lsd=function(i){var n=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(n,i)},g.prototype.reset=function(){var i=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(i,!1)},Object.defineProperty(g.prototype,"matrix",{get:function(){return this.uniforms.m},set:function(i){this.uniforms.m=i},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"alpha",{get:function(){return this.uniforms.uAlpha},set:function(i){this.uniforms.uAlpha=i},enumerable:!1,configurable:!0}),g}(Od);q8.prototype.grayscale=q8.prototype.greyscale;/*! + * @pixi/filter-displacement - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/filter-displacement is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */var e6=function(e,g){return e6=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var I in n)n.hasOwnProperty(I)&&(i[I]=n[I])},e6(e,g)};function v0t(e,g){e6(e,g);function i(){this.constructor=e}e.prototype=g===null?Object.create(g):(i.prototype=g.prototype,new i)}var B0t=`varying vec2 vFilterCoord; +varying vec2 vTextureCoord; + +uniform vec2 scale; +uniform mat2 rotation; +uniform sampler2D uSampler; +uniform sampler2D mapSampler; + +uniform highp vec4 inputSize; +uniform vec4 inputClamp; + +void main(void) +{ + vec4 map = texture2D(mapSampler, vFilterCoord); + + map -= 0.5; + map.xy = scale * inputSize.zw * (rotation * map.xy); + + gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw)); +} +`,w0t=`attribute vec2 aVertexPosition; + +uniform mat3 projectionMatrix; +uniform mat3 filterMatrix; + +varying vec2 vTextureCoord; +varying vec2 vFilterCoord; + +uniform vec4 inputSize; +uniform vec4 outputFrame; + +vec4 filterVertexPosition( void ) +{ + vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; + + return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); +} + +vec2 filterTextureCoord( void ) +{ + return aVertexPosition * (outputFrame.zw * inputSize.zw); +} + +void main(void) +{ + gl_Position = filterVertexPosition(); + vTextureCoord = filterTextureCoord(); + vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy; +} +`,S0t=function(e){v0t(g,e);function g(i,n){var I=this,r=new rI;return i.renderable=!1,I=e.call(this,w0t,B0t,{mapSampler:i._texture,filterMatrix:r,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])})||this,I.maskSprite=i,I.maskMatrix=r,n==null&&(n=20),I.scale=new _i(n,n),I}return g.prototype.apply=function(i,n,I,r){this.uniforms.filterMatrix=i.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;var o=this.maskSprite.worldTransform,C=Math.sqrt(o.a*o.a+o.b*o.b),a=Math.sqrt(o.c*o.c+o.d*o.d);C!==0&&a!==0&&(this.uniforms.rotation[0]=o.a/C,this.uniforms.rotation[1]=o.b/C,this.uniforms.rotation[2]=o.c/a,this.uniforms.rotation[3]=o.d/a),i.applyFilter(this,n,I,r)},Object.defineProperty(g.prototype,"map",{get:function(){return this.uniforms.mapSampler},set:function(i){this.uniforms.mapSampler=i},enumerable:!1,configurable:!0}),g}(Od);/*! + * @pixi/filter-fxaa - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/filter-fxaa is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */var t6=function(e,g){return t6=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var I in n)n.hasOwnProperty(I)&&(i[I]=n[I])},t6(e,g)};function R0t(e,g){t6(e,g);function i(){this.constructor=e}e.prototype=g===null?Object.create(g):(i.prototype=g.prototype,new i)}var V0t=` +attribute vec2 aVertexPosition; + +uniform mat3 projectionMatrix; + +varying vec2 v_rgbNW; +varying vec2 v_rgbNE; +varying vec2 v_rgbSW; +varying vec2 v_rgbSE; +varying vec2 v_rgbM; + +varying vec2 vFragCoord; + +uniform vec4 inputSize; +uniform vec4 outputFrame; + +vec4 filterVertexPosition( void ) +{ + vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; + + return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); +} + +void texcoords(vec2 fragCoord, vec2 inverseVP, + out vec2 v_rgbNW, out vec2 v_rgbNE, + out vec2 v_rgbSW, out vec2 v_rgbSE, + out vec2 v_rgbM) { + v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP; + v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP; + v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP; + v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP; + v_rgbM = vec2(fragCoord * inverseVP); +} + +void main(void) { + + gl_Position = filterVertexPosition(); + + vFragCoord = aVertexPosition * outputFrame.zw; + + texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM); +} +`,W0t=`varying vec2 v_rgbNW; +varying vec2 v_rgbNE; +varying vec2 v_rgbSW; +varying vec2 v_rgbSE; +varying vec2 v_rgbM; + +varying vec2 vFragCoord; +uniform sampler2D uSampler; +uniform highp vec4 inputSize; + + +/** + Basic FXAA implementation based on the code on geeks3d.com with the + modification that the texture2DLod stuff was removed since it's + unsupported by WebGL. + + -- + + From: + https://github.com/mitsuhiko/webgl-meincraft + + Copyright (c) 2011 by Armin Ronacher. + + Some rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * The names of the contributors may not be used to endorse or + promote products derived from this software without specific + prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FXAA_REDUCE_MIN +#define FXAA_REDUCE_MIN (1.0/ 128.0) +#endif +#ifndef FXAA_REDUCE_MUL +#define FXAA_REDUCE_MUL (1.0 / 8.0) +#endif +#ifndef FXAA_SPAN_MAX +#define FXAA_SPAN_MAX 8.0 +#endif + +//optimized version for mobile, where dependent +//texture reads can be a bottleneck +vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inverseVP, + vec2 v_rgbNW, vec2 v_rgbNE, + vec2 v_rgbSW, vec2 v_rgbSE, + vec2 v_rgbM) { + vec4 color; + vec3 rgbNW = texture2D(tex, v_rgbNW).xyz; + vec3 rgbNE = texture2D(tex, v_rgbNE).xyz; + vec3 rgbSW = texture2D(tex, v_rgbSW).xyz; + vec3 rgbSE = texture2D(tex, v_rgbSE).xyz; + vec4 texColor = texture2D(tex, v_rgbM); + vec3 rgbM = texColor.xyz; + vec3 luma = vec3(0.299, 0.587, 0.114); + float lumaNW = dot(rgbNW, luma); + float lumaNE = dot(rgbNE, luma); + float lumaSW = dot(rgbSW, luma); + float lumaSE = dot(rgbSE, luma); + float lumaM = dot(rgbM, luma); + float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); + float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); + + mediump vec2 dir; + dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); + dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); + + float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * + (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); + + float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce); + dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), + max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), + dir * rcpDirMin)) * inverseVP; + + vec3 rgbA = 0.5 * ( + texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz + + texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz); + vec3 rgbB = rgbA * 0.5 + 0.25 * ( + texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz + + texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz); + + float lumaB = dot(rgbB, luma); + if ((lumaB < lumaMin) || (lumaB > lumaMax)) + color = vec4(rgbA, texColor.a); + else + color = vec4(rgbB, texColor.a); + return color; +} + +void main() { + + vec4 color; + + color = fxaa(uSampler, vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM); + + gl_FragColor = color; +} +`,X0t=function(e){R0t(g,e);function g(){return e.call(this,V0t,W0t)||this}return g}(Od);/*! + * @pixi/filter-noise - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/filter-noise is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */var g6=function(e,g){return g6=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var I in n)n.hasOwnProperty(I)&&(i[I]=n[I])},g6(e,g)};function T0t(e,g){g6(e,g);function i(){this.constructor=e}e.prototype=g===null?Object.create(g):(i.prototype=g.prototype,new i)}var H0t=`precision highp float; + +varying vec2 vTextureCoord; +varying vec4 vColor; + +uniform float uNoise; +uniform float uSeed; +uniform sampler2D uSampler; + +float rand(vec2 co) +{ + return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); +} + +void main() +{ + vec4 color = texture2D(uSampler, vTextureCoord); + float randomValue = rand(gl_FragCoord.xy * uSeed); + float diff = (randomValue - 0.5) * uNoise; + + // Un-premultiply alpha before applying the color matrix. See issue #3539. + if (color.a > 0.0) { + color.rgb /= color.a; + } + + color.r += diff; + color.g += diff; + color.b += diff; + + // Premultiply alpha again. + color.rgb *= color.a; + + gl_FragColor = color; +} +`,N0t=function(e){T0t(g,e);function g(i,n){i===void 0&&(i=.5),n===void 0&&(n=Math.random());var I=e.call(this,boe,H0t,{uNoise:0,uSeed:0})||this;return I.noise=i,I.seed=n,I}return Object.defineProperty(g.prototype,"noise",{get:function(){return this.uniforms.uNoise},set:function(i){this.uniforms.uNoise=i},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"seed",{get:function(){return this.uniforms.uSeed},set:function(i){this.uniforms.uSeed=i},enumerable:!1,configurable:!0}),g}(Od);/*! + * @pixi/mixin-cache-as-bitmap - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/mixin-cache-as-bitmap is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! + * @pixi/constants - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/constants is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */var Mbe;(function(e){e[e.WEBGL_LEGACY=0]="WEBGL_LEGACY",e[e.WEBGL=1]="WEBGL",e[e.WEBGL2=2]="WEBGL2"})(Mbe||(Mbe={}));var zbe;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.WEBGL=1]="WEBGL",e[e.CANVAS=2]="CANVAS"})(zbe||(zbe={}));var Pbe;(function(e){e[e.COLOR=16384]="COLOR",e[e.DEPTH=256]="DEPTH",e[e.STENCIL=1024]="STENCIL"})(Pbe||(Pbe={}));var _be;(function(e){e[e.NORMAL=0]="NORMAL",e[e.ADD=1]="ADD",e[e.MULTIPLY=2]="MULTIPLY",e[e.SCREEN=3]="SCREEN",e[e.OVERLAY=4]="OVERLAY",e[e.DARKEN=5]="DARKEN",e[e.LIGHTEN=6]="LIGHTEN",e[e.COLOR_DODGE=7]="COLOR_DODGE",e[e.COLOR_BURN=8]="COLOR_BURN",e[e.HARD_LIGHT=9]="HARD_LIGHT",e[e.SOFT_LIGHT=10]="SOFT_LIGHT",e[e.DIFFERENCE=11]="DIFFERENCE",e[e.EXCLUSION=12]="EXCLUSION",e[e.HUE=13]="HUE",e[e.SATURATION=14]="SATURATION",e[e.COLOR=15]="COLOR",e[e.LUMINOSITY=16]="LUMINOSITY",e[e.NORMAL_NPM=17]="NORMAL_NPM",e[e.ADD_NPM=18]="ADD_NPM",e[e.SCREEN_NPM=19]="SCREEN_NPM",e[e.NONE=20]="NONE",e[e.SRC_OVER=0]="SRC_OVER",e[e.SRC_IN=21]="SRC_IN",e[e.SRC_OUT=22]="SRC_OUT",e[e.SRC_ATOP=23]="SRC_ATOP",e[e.DST_OVER=24]="DST_OVER",e[e.DST_IN=25]="DST_IN",e[e.DST_OUT=26]="DST_OUT",e[e.DST_ATOP=27]="DST_ATOP",e[e.ERASE=26]="ERASE",e[e.SUBTRACT=28]="SUBTRACT",e[e.XOR=29]="XOR"})(_be||(_be={}));var Obe;(function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN"})(Obe||(Obe={}));var Jbe;(function(e){e[e.RGBA=6408]="RGBA",e[e.RGB=6407]="RGB",e[e.RG=33319]="RG",e[e.RED=6403]="RED",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.ALPHA=6406]="ALPHA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL"})(Jbe||(Jbe={}));var Lbe;(function(e){e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z"})(Lbe||(Lbe={}));var Ube;(function(e){e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.BYTE=5120]="BYTE",e[e.SHORT=5122]="SHORT",e[e.INT=5124]="INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.HALF_FLOAT=36193]="HALF_FLOAT"})(Ube||(Ube={}));var Qbe;(function(e){e[e.FLOAT=0]="FLOAT",e[e.INT=1]="INT",e[e.UINT=2]="UINT"})(Qbe||(Qbe={}));var jbe;(function(e){e[e.NEAREST=0]="NEAREST",e[e.LINEAR=1]="LINEAR"})(jbe||(jbe={}));var $be;(function(e){e[e.CLAMP=33071]="CLAMP",e[e.REPEAT=10497]="REPEAT",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"})($be||($be={}));var qbe;(function(e){e[e.OFF=0]="OFF",e[e.POW2=1]="POW2",e[e.ON=2]="ON",e[e.ON_MANUAL=3]="ON_MANUAL"})(qbe||(qbe={}));var eye;(function(e){e[e.NPM=0]="NPM",e[e.UNPACK=1]="UNPACK",e[e.PMA=2]="PMA",e[e.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",e[e.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",e[e.PREMULTIPLY_ALPHA=2]="PREMULTIPLY_ALPHA",e[e.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA"})(eye||(eye={}));var tye;(function(e){e[e.NO=0]="NO",e[e.YES=1]="YES",e[e.AUTO=2]="AUTO",e[e.BLEND=0]="BLEND",e[e.CLEAR=1]="CLEAR",e[e.BLIT=2]="BLIT"})(tye||(tye={}));var gye;(function(e){e[e.AUTO=0]="AUTO",e[e.MANUAL=1]="MANUAL"})(gye||(gye={}));var iye;(function(e){e.LOW="lowp",e.MEDIUM="mediump",e.HIGH="highp"})(iye||(iye={}));var nye;(function(e){e[e.NONE=0]="NONE",e[e.SCISSOR=1]="SCISSOR",e[e.STENCIL=2]="STENCIL",e[e.SPRITE=3]="SPRITE",e[e.COLOR=4]="COLOR"})(nye||(nye={}));var Iye;(function(e){e[e.RED=1]="RED",e[e.GREEN=2]="GREEN",e[e.BLUE=4]="BLUE",e[e.ALPHA=8]="ALPHA"})(Iye||(Iye={}));var i6;(function(e){e[e.NONE=0]="NONE",e[e.LOW=2]="LOW",e[e.MEDIUM=4]="MEDIUM",e[e.HIGH=8]="HIGH"})(i6||(i6={}));var rye;(function(e){e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER"})(rye||(rye={}));var wEe=new rI;Fn.prototype._cacheAsBitmap=!1;Fn.prototype._cacheData=null;Fn.prototype._cacheAsBitmapResolution=null;Fn.prototype._cacheAsBitmapMultisample=i6.NONE;var k0t=function(){function e(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}return e}();Object.defineProperties(Fn.prototype,{cacheAsBitmapResolution:{get:function(){return this._cacheAsBitmapResolution},set:function(e){e!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=e,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get:function(){return this._cacheAsBitmapMultisample},set:function(e){e!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=e,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get:function(){return this._cacheAsBitmap},set:function(e){if(this._cacheAsBitmap!==e){this._cacheAsBitmap=e;var g;e?(this._cacheData||(this._cacheData=new k0t),g=this._cacheData,g.originalRender=this.render,g.originalRenderCanvas=this.renderCanvas,g.originalUpdateTransform=this.updateTransform,g.originalCalculateBounds=this.calculateBounds,g.originalGetLocalBounds=this.getLocalBounds,g.originalDestroy=this.destroy,g.originalContainsPoint=this.containsPoint,g.originalMask=this._mask,g.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(g=this._cacheData,g.sprite&&this._destroyCachedDisplayObject(),this.render=g.originalRender,this.renderCanvas=g.originalRenderCanvas,this.calculateBounds=g.originalCalculateBounds,this.getLocalBounds=g.originalGetLocalBounds,this.destroy=g.originalDestroy,this.updateTransform=g.originalUpdateTransform,this.containsPoint=g.originalContainsPoint,this._mask=g.originalMask,this.filterArea=g.originalFilterArea)}}}});Fn.prototype._renderCached=function(g){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(g),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(g))};Fn.prototype._initCachedDisplayObject=function(g){var i;if(!(this._cacheData&&this._cacheData.sprite)){var n=this.alpha;this.alpha=1,g.batch.flush();var I=this.getLocalBounds(null,!0).clone();if(this.filters&&this.filters.length){var r=this.filters[0].padding;I.pad(r)}I.ceil(Ht.RESOLUTION);var o=g.renderTexture.current,C=g.renderTexture.sourceFrame.clone(),a=g.renderTexture.destinationFrame.clone(),A=g.projection.transform,s=Wd.create({width:I.width,height:I.height,resolution:this.cacheAsBitmapResolution||g.resolution,multisample:(i=this.cacheAsBitmapMultisample)!==null&&i!==void 0?i:g.multisample}),l="cacheAsBitmap_"+cm();this._cacheData.textureCacheId=l,_g.addToCache(s.baseTexture,l),Zg.addToCache(s,l);var c=this.transform.localTransform.copyTo(wEe).invert().translate(-I.x,-I.y);this.render=this._cacheData.originalRender,g.render(this,{renderTexture:s,clear:!0,transform:c,skipUpdateTransform:!1}),g.framebuffer.blit(),g.projection.transform=A,g.renderTexture.bind(o,C,a),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=n;var u=new Z1(s);u.transform.worldTransform=this.transform.worldTransform,u.anchor.x=-(I.x/I.width),u.anchor.y=-(I.y/I.height),u.alpha=n,u._bounds=this._bounds,this._cacheData.sprite=u,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=u.containsPoint.bind(u)}};Fn.prototype._renderCachedCanvas=function(g){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(g),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(g))};Fn.prototype._initCachedDisplayObjectCanvas=function(g){if(!(this._cacheData&&this._cacheData.sprite)){var i=this.getLocalBounds(null,!0),n=this.alpha;this.alpha=1;var I=g.context,r=g._projTransform;i.ceil(Ht.RESOLUTION);var o=Wd.create({width:i.width,height:i.height}),C="cacheAsBitmap_"+cm();this._cacheData.textureCacheId=C,_g.addToCache(o.baseTexture,C),Zg.addToCache(o,C);var a=wEe;this.transform.localTransform.copyTo(a),a.invert(),a.tx-=i.x,a.ty-=i.y,this.renderCanvas=this._cacheData.originalRenderCanvas,g.render(this,{renderTexture:o,clear:!0,transform:a,skipUpdateTransform:!1}),g.context=I,g._projTransform=r,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=n;var A=new Z1(o);A.transform.worldTransform=this.transform.worldTransform,A.anchor.x=-(i.x/i.width),A.anchor.y=-(i.y/i.height),A.alpha=n,A._bounds=this._bounds,this._cacheData.sprite=A,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=g._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=A.containsPoint.bind(A)}};Fn.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID};Fn.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)};Fn.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,_g.removeFromCache(this._cacheData.textureCacheId),Zg.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null};Fn.prototype._cacheAsBitmapDestroy=function(g){this.cacheAsBitmap=!1,this.destroy(g)};/*! + * @pixi/mixin-get-child-by-name - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/mixin-get-child-by-name is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */Fn.prototype.name=null;zA.prototype.getChildByName=function(g,i){for(var n=0,I=this.children.length;n1&&typeof MSStream>"u"};function K0t(e){return function(g){return g.test(e)}}function x0t(e){var g={userAgent:"",platform:"",maxTouchPoints:0};!e&&typeof navigator<"u"?g={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof e=="string"?g.userAgent=e:e&&e.userAgent&&(g={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0});var i=g.userAgent,n=i.split("[FBAN");typeof n[1]<"u"&&(i=n[0]),n=i.split("Twitter"),typeof n[1]<"u"&&(i=n[0]);var I=K0t(i),r={apple:{phone:I(ML)&&!I(uu),ipod:I(yye),tablet:!I(ML)&&(I(Zye)||Xye(g))&&!I(uu),universal:I(Gye),device:(I(ML)||I(yye)||I(Zye)||I(Gye)||Xye(g))&&!I(uu)},amazon:{phone:I(YZ),tablet:!I(YZ)&&I(rk),device:I(YZ)||I(rk)},android:{phone:!I(uu)&&I(YZ)||!I(uu)&&I(zL),tablet:!I(uu)&&!I(YZ)&&!I(zL)&&(I(rk)||I(vye)),device:!I(uu)&&(I(YZ)||I(rk)||I(zL)||I(vye))||I(/\bokhttp\b/i)},windows:{phone:I(uu),tablet:I(Bye),device:I(uu)||I(Bye)},other:{blackberry:I(wye),blackberry10:I(Sye),opera:I(Rye),firefox:I(Wye),chrome:I(Vye),device:I(wye)||I(Sye)||I(Rye)||I(Wye)||I(Vye)},any:!1,phone:!1,tablet:!1};return r.any=r.apple.device||r.android.device||r.windows.device||r.other.device,r.phone=r.apple.phone||r.android.phone||r.windows.phone,r.tablet=r.apple.tablet||r.android.tablet||r.windows.tablet,r}var sv=x0t(globalThis.navigator);function F0t(){return!sv.apple.device}function E0t(e){var g=!0;if(sv.tablet||sv.phone){if(sv.apple.device){var i=navigator.userAgent.match(/OS (\d+)_(\d+)?/);if(i){var n=parseInt(i[1],10);n<11&&(g=!1)}}if(sv.android.device){var i=navigator.userAgent.match(/Android\s([0-9.]*)/);if(i){var n=parseInt(i[1],10);n<7&&(g=!1)}}}return g?e:4}var zx={ADAPTER:Y0t,MIPMAP_TEXTURES:r6.POW2,ANISOTROPIC_LEVEL:0,RESOLUTION:1,FILTER_RESOLUTION:1,FILTER_MULTISAMPLE:C6.NONE,SPRITE_MAX_TEXTURES:E0t(32),SPRITE_BATCH_SIZE:4096,RENDER_OPTIONS:{view:null,antialias:!1,autoDensity:!1,backgroundColor:0,backgroundAlpha:1,useContextAlpha:!0,clearBeforeRender:!0,preserveDrawingBuffer:!1,width:800,height:600,legacy:!1},GC_MODE:o6.AUTO,GC_MAX_IDLE:60*60,GC_MAX_CHECK_COUNT:60*10,WRAP_MODE:I6.CLAMP,SCALE_MODE:n6.LINEAR,PRECISION_VERTEX:x2.HIGH,PRECISION_FRAGMENT:sv.apple.device?x2.HIGH:x2.MEDIUM,CAN_UPLOAD_SAME_BUFFER:F0t(),CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1},PL=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Woe(e,g,i){return i={path:g,exports:{},require:function(n,I){return D0t(n,I??i.path)}},e(i,i.exports),i.exports}function D0t(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}Woe(function(e){var g=Object.prototype.hasOwnProperty,i="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(i=!1));function I(a,A,s){this.fn=a,this.context=A,this.once=s||!1}function r(a,A,s,l,c){if(typeof s!="function")throw new TypeError("The listener must be a function");var u=new I(s,l||a,c),d=i?i+A:A;return a._events[d]?a._events[d].fn?a._events[d]=[a._events[d],u]:a._events[d].push(u):(a._events[d]=u,a._eventsCount++),a}function o(a,A){--a._eventsCount===0?a._events=new n:delete a._events[A]}function C(){this._events=new n,this._eventsCount=0}C.prototype.eventNames=function(){var A=[],s,l;if(this._eventsCount===0)return A;for(l in s=this._events)g.call(s,l)&&A.push(i?l.slice(1):l);return Object.getOwnPropertySymbols?A.concat(Object.getOwnPropertySymbols(s)):A},C.prototype.listeners=function(A){var s=i?i+A:A,l=this._events[s];if(!l)return[];if(l.fn)return[l.fn];for(var c=0,u=l.length,d=new Array(u);c= 0x80 (not a basic code point)","invalid-input":"Invalid input"},y=a-A,Z=Math.floor,v=String.fromCharCode,G;function B(F){throw RangeError(p[F])}function S(F,$){for(var Q=F.length,U=[];Q--;)U[Q]=$(F[Q]);return U}function R(F,$){var Q=F.split("@"),U="";Q.length>1&&(U=Q[0]+"@",F=Q[1]),F=F.replace(b,".");var j=F.split("."),ee=S(j,$).join(".");return U+ee}function w(F){for(var $=[],Q=0,U=F.length,j,ee;Q=55296&&j<=56319&&Q65535&&($-=65536,Q+=v($>>>10&1023|55296),$=56320|$&1023),Q+=v($),Q}).join("")}function W(F){return F-48<10?F-22:F-65<26?F-65:F-97<26?F-97:a}function V(F,$){return F+22+75*(F<26)-(($!=0)<<5)}function X(F,$,Q){var U=0;for(F=Q?Z(F/c):F>>1,F+=Z(F/$);F>y*s>>1;U+=a)F=Z(F/y);return Z(U+(y+1)*F/(F+l))}function N(F){var $=[],Q=F.length,U,j=0,ee=d,Ie=u,fe,Ve,oe,pe,ae,ie,ye,ue,Ye;for(fe=F.lastIndexOf(h),fe<0&&(fe=0),Ve=0;Ve=128&&B("not-basic"),$.push(F.charCodeAt(Ve));for(oe=fe>0?fe+1:0;oe=Q&&B("invalid-input"),ye=W(F.charCodeAt(oe++)),(ye>=a||ye>Z((C-j)/ae))&&B("overflow"),j+=ye*ae,ue=ie<=Ie?A:ie>=Ie+s?s:ie-Ie,!(yeZ(C/Ye)&&B("overflow"),ae*=Ye;U=$.length+1,Ie=X(j-pe,U,pe==0),Z(j/U)>C-ee&&B("overflow"),ee+=Z(j/U),j%=U,$.splice(j++,0,ee)}return T($)}function Y(F){var $,Q,U,j,ee,Ie,fe,Ve,oe,pe,ae,ie=[],ye,ue,Ye,Be;for(F=w(F),ye=F.length,$=d,Q=0,ee=u,Ie=0;Ie=$&&aeZ((C-Q)/ue)&&B("overflow"),Q+=(fe-$)*ue,$=fe,Ie=0;IeC&&B("overflow"),ae==$){for(Ve=Q,oe=a;pe=oe<=ee?A:oe>=ee+s?s:oe-ee,!(Ve0&&C>o&&(C=o);for(var a=0;a=0?(l=A.substr(0,s),c=A.substr(s+1)):(l=A,c=""),u=decodeURIComponent(l),d=decodeURIComponent(c),M0t(I,u)?Array.isArray(I[u])?I[u].push(d):I[u]=[I[u],d]:I[u]=d}return I},$S=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},P0t=function(e,g,i,n){return g=g||"&",i=i||"=",e===null&&(e=void 0),typeof e=="object"?Object.keys(e).map(function(I){var r=encodeURIComponent($S(I))+i;return Array.isArray(e[I])?e[I].map(function(o){return r+encodeURIComponent($S(o))}).join(g):r+encodeURIComponent($S(e[I]))}).join(g):n?encodeURIComponent($S(n))+i+encodeURIComponent($S(e)):""};Woe(function(e,g){g.decode=g.parse=z0t,g.encode=g.stringify=P0t});/*! + * @pixi/constants - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/constants is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */var Tye;(function(e){e[e.WEBGL_LEGACY=0]="WEBGL_LEGACY",e[e.WEBGL=1]="WEBGL",e[e.WEBGL2=2]="WEBGL2"})(Tye||(Tye={}));var Hye;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.WEBGL=1]="WEBGL",e[e.CANVAS=2]="CANVAS"})(Hye||(Hye={}));var Nye;(function(e){e[e.COLOR=16384]="COLOR",e[e.DEPTH=256]="DEPTH",e[e.STENCIL=1024]="STENCIL"})(Nye||(Nye={}));var nC;(function(e){e[e.NORMAL=0]="NORMAL",e[e.ADD=1]="ADD",e[e.MULTIPLY=2]="MULTIPLY",e[e.SCREEN=3]="SCREEN",e[e.OVERLAY=4]="OVERLAY",e[e.DARKEN=5]="DARKEN",e[e.LIGHTEN=6]="LIGHTEN",e[e.COLOR_DODGE=7]="COLOR_DODGE",e[e.COLOR_BURN=8]="COLOR_BURN",e[e.HARD_LIGHT=9]="HARD_LIGHT",e[e.SOFT_LIGHT=10]="SOFT_LIGHT",e[e.DIFFERENCE=11]="DIFFERENCE",e[e.EXCLUSION=12]="EXCLUSION",e[e.HUE=13]="HUE",e[e.SATURATION=14]="SATURATION",e[e.COLOR=15]="COLOR",e[e.LUMINOSITY=16]="LUMINOSITY",e[e.NORMAL_NPM=17]="NORMAL_NPM",e[e.ADD_NPM=18]="ADD_NPM",e[e.SCREEN_NPM=19]="SCREEN_NPM",e[e.NONE=20]="NONE",e[e.SRC_OVER=0]="SRC_OVER",e[e.SRC_IN=21]="SRC_IN",e[e.SRC_OUT=22]="SRC_OUT",e[e.SRC_ATOP=23]="SRC_ATOP",e[e.DST_OVER=24]="DST_OVER",e[e.DST_IN=25]="DST_IN",e[e.DST_OUT=26]="DST_OUT",e[e.DST_ATOP=27]="DST_ATOP",e[e.ERASE=26]="ERASE",e[e.SUBTRACT=28]="SUBTRACT",e[e.XOR=29]="XOR"})(nC||(nC={}));var kye;(function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN"})(kye||(kye={}));var Yye;(function(e){e[e.RGBA=6408]="RGBA",e[e.RGB=6407]="RGB",e[e.RG=33319]="RG",e[e.RED=6403]="RED",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.ALPHA=6406]="ALPHA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL"})(Yye||(Yye={}));var Kye;(function(e){e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z"})(Kye||(Kye={}));var xye;(function(e){e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.BYTE=5120]="BYTE",e[e.SHORT=5122]="SHORT",e[e.INT=5124]="INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.HALF_FLOAT=36193]="HALF_FLOAT"})(xye||(xye={}));var Fye;(function(e){e[e.FLOAT=0]="FLOAT",e[e.INT=1]="INT",e[e.UINT=2]="UINT"})(Fye||(Fye={}));var Eye;(function(e){e[e.NEAREST=0]="NEAREST",e[e.LINEAR=1]="LINEAR"})(Eye||(Eye={}));var Dye;(function(e){e[e.CLAMP=33071]="CLAMP",e[e.REPEAT=10497]="REPEAT",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"})(Dye||(Dye={}));var Mye;(function(e){e[e.OFF=0]="OFF",e[e.POW2=1]="POW2",e[e.ON=2]="ON",e[e.ON_MANUAL=3]="ON_MANUAL"})(Mye||(Mye={}));var zye;(function(e){e[e.NPM=0]="NPM",e[e.UNPACK=1]="UNPACK",e[e.PMA=2]="PMA",e[e.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",e[e.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",e[e.PREMULTIPLY_ALPHA=2]="PREMULTIPLY_ALPHA",e[e.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA"})(zye||(zye={}));var Pye;(function(e){e[e.NO=0]="NO",e[e.YES=1]="YES",e[e.AUTO=2]="AUTO",e[e.BLEND=0]="BLEND",e[e.CLEAR=1]="CLEAR",e[e.BLIT=2]="BLIT"})(Pye||(Pye={}));var _ye;(function(e){e[e.AUTO=0]="AUTO",e[e.MANUAL=1]="MANUAL"})(_ye||(_ye={}));var Oye;(function(e){e.LOW="lowp",e.MEDIUM="mediump",e.HIGH="highp"})(Oye||(Oye={}));var Jye;(function(e){e[e.NONE=0]="NONE",e[e.SCISSOR=1]="SCISSOR",e[e.STENCIL=2]="STENCIL",e[e.SPRITE=3]="SPRITE",e[e.COLOR=4]="COLOR"})(Jye||(Jye={}));var Lye;(function(e){e[e.RED=1]="RED",e[e.GREEN=2]="GREEN",e[e.BLUE=4]="BLUE",e[e.ALPHA=8]="ALPHA"})(Lye||(Lye={}));var Uye;(function(e){e[e.NONE=0]="NONE",e[e.LOW=2]="LOW",e[e.MEDIUM=4]="MEDIUM",e[e.HIGH=8]="HIGH"})(Uye||(Uye={}));var Qye;(function(e){e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER"})(Qye||(Qye={}));/*! + * @pixi/utils - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/utils is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */zx.RETINA_PREFIX=/@([0-9\.]+)x/;zx.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;function _0t(){for(var e=[],g=[],i=0;i<32;i++)e[i]=i,g[i]=i;e[nC.NORMAL_NPM]=nC.NORMAL,e[nC.ADD_NPM]=nC.ADD,e[nC.SCREEN_NPM]=nC.SCREEN,g[nC.NORMAL]=nC.NORMAL_NPM,g[nC.ADD]=nC.ADD_NPM,g[nC.SCREEN]=nC.SCREEN_NPM;var n=[];return n.push(g),n.push(e),n}_0t();var jye={};function O0t(e,g,i){if(i===void 0&&(i=3),!jye[g]){var n=new Error().stack;typeof n>"u"?console.warn("PixiJS Deprecation Warning: ",g+` +Deprecated since v`+e):(n=n.split(` +`).splice(i).join(` +`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",g+` +Deprecated since v`+e),console.warn(n),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",g+` +Deprecated since v`+e),console.warn(n))),jye[g]=!0}}(function(){function e(g,i,n){this.canvas=zx.ADAPTER.createCanvas(),this.context=this.canvas.getContext("2d"),this.resolution=n||zx.RESOLUTION,this.resize(g,i)}return e.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height)},e.prototype.resize=function(g,i){this.canvas.width=Math.round(g*this.resolution),this.canvas.height=Math.round(i*this.resolution)},e.prototype.destroy=function(){this.context=null,this.canvas=null},Object.defineProperty(e.prototype,"width",{get:function(){return this.canvas.width},set:function(g){this.canvas.width=Math.round(g)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this.canvas.height},set:function(g){this.canvas.height=Math.round(g)},enumerable:!1,configurable:!0}),e})();var REe=function(){function e(g){var i=this;this.stage=new zA,g=Object.assign({forceCanvas:!1},g),this.renderer=WFe(g),e._plugins.forEach(function(n){n.init.call(i,g)})}return e.registerPlugin=function(g){O0t("6.5.0","Application.registerPlugin() is deprecated, use extensions.add()"),Pc.add({type:Zi.Application,ref:g})},e.prototype.render=function(){this.renderer.render(this.stage)},Object.defineProperty(e.prototype,"view",{get:function(){return this.renderer.view},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"screen",{get:function(){return this.renderer.screen},enumerable:!1,configurable:!0}),e.prototype.destroy=function(g,i){var n=this,I=e._plugins.slice(0);I.reverse(),I.forEach(function(r){r.destroy.call(n)}),this.stage.destroy(i),this.stage=null,this.renderer.destroy(g),this.renderer=null},e._plugins=[],e}();Pc.handleByList(Zi.Application,REe._plugins);Pc.add(SEe);/*! + * @pixi/mesh-extras - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/mesh-extras is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */var a6=function(e,g){return a6=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var I in n)n.hasOwnProperty(I)&&(i[I]=n[I])},a6(e,g)};function G1(e,g){a6(e,g);function i(){this.constructor=e}e.prototype=g===null?Object.create(g):(i.prototype=g.prototype,new i)}var VEe=function(e){G1(g,e);function g(i,n,I,r){i===void 0&&(i=100),n===void 0&&(n=100),I===void 0&&(I=10),r===void 0&&(r=10);var o=e.call(this)||this;return o.segWidth=I,o.segHeight=r,o.width=i,o.height=n,o.build(),o}return g.prototype.build=function(){for(var i=this.segWidth*this.segHeight,n=[],I=[],r=[],o=this.segWidth-1,C=this.segHeight-1,a=this.width/o,A=this.height/C,s=0;s0){var d=A.x-i[c].x,h=A.y-i[c].y,f=Math.sqrt(d*d+h*h);A=i[c],a+=f/s}else a=c/(l-1);o[u]=a,o[u+1]=0,o[u+2]=a,o[u+3]=1}for(var m=0,c=0;c0?this.textureScale*this._width/2:this._width/2;r/=c,o/=c,r*=u,o*=u,C[l]=s.x+r,C[l+1]=s.y+o,C[l+2]=s.x-r,C[l+3]=s.y-o,n=s}this.buffers[0].update()}},g.prototype.update=function(){this.textureScale>0?this.build():this.updateVertices()},g}(cT),J0t=function(e){G1(g,e);function g(i,n,I){I===void 0&&(I=0);var r=this,o=new WEe(i.height,n,I),C=new NB(i);return I>0&&(i.baseTexture.wrapMode=Cc.REPEAT),r=e.call(this,o,C)||this,r.autoUpdate=!0,r}return g.prototype._render=function(i){var n=this.geometry;(this.autoUpdate||n._width!==this.shader.texture.height)&&(n._width=this.shader.texture.height,n.update()),e.prototype._render.call(this,i)},g}(HB),XEe=function(e){G1(g,e);function g(i,n,I){var r=this,o=new VEe(i.width,i.height,n,I),C=new NB(Zg.WHITE);return r=e.call(this,o,C)||this,r.texture=i,r.autoResize=!0,r}return g.prototype.textureUpdated=function(){this._textureID=this.shader.texture._updateID;var i=this.geometry,n=this.shader.texture,I=n.width,r=n.height;this.autoResize&&(i.width!==I||i.height!==r)&&(i.width=this.shader.texture.width,i.height=this.shader.texture.height,i.build())},Object.defineProperty(g.prototype,"texture",{get:function(){return this.shader.texture},set:function(i){this.shader.texture!==i&&(this.shader.texture=i,this._textureID=-1,i.baseTexture.valid?this.textureUpdated():i.once("update",this.textureUpdated,this))},enumerable:!1,configurable:!0}),g.prototype._render=function(i){this._textureID!==this.shader.texture._updateID&&this.textureUpdated(),e.prototype._render.call(this,i)},g.prototype.destroy=function(i){this.shader.texture.off("update",this.textureUpdated,this),e.prototype.destroy.call(this,i)},g}(HB),L0t=function(e){G1(g,e);function g(i,n,I,r,o){i===void 0&&(i=Zg.EMPTY);var C=this,a=new cT(n,I,r);a.getBuffer("aVertexPosition").static=!1;var A=new NB(i);return C=e.call(this,a,A,null,o)||this,C.autoUpdate=!0,C}return Object.defineProperty(g.prototype,"vertices",{get:function(){return this.geometry.getBuffer("aVertexPosition").data},set:function(i){this.geometry.getBuffer("aVertexPosition").data=i},enumerable:!1,configurable:!0}),g.prototype._render=function(i){this.autoUpdate&&this.geometry.getBuffer("aVertexPosition").update(),e.prototype._render.call(this,i)},g}(HB),ok=10,U0t=function(e){G1(g,e);function g(i,n,I,r,o){n===void 0&&(n=ok),I===void 0&&(I=ok),r===void 0&&(r=ok),o===void 0&&(o=ok);var C=e.call(this,Zg.WHITE,4,4)||this;return C._origWidth=i.orig.width,C._origHeight=i.orig.height,C._width=C._origWidth,C._height=C._origHeight,C._leftWidth=n,C._rightWidth=r,C._topHeight=I,C._bottomHeight=o,C.texture=i,C}return g.prototype.textureUpdated=function(){this._textureID=this.shader.texture._updateID,this._refresh()},Object.defineProperty(g.prototype,"vertices",{get:function(){return this.geometry.getBuffer("aVertexPosition").data},set:function(i){this.geometry.getBuffer("aVertexPosition").data=i},enumerable:!1,configurable:!0}),g.prototype.updateHorizontalVertices=function(){var i=this.vertices,n=this._getMinScale();i[9]=i[11]=i[13]=i[15]=this._topHeight*n,i[17]=i[19]=i[21]=i[23]=this._height-this._bottomHeight*n,i[25]=i[27]=i[29]=i[31]=this._height},g.prototype.updateVerticalVertices=function(){var i=this.vertices,n=this._getMinScale();i[2]=i[10]=i[18]=i[26]=this._leftWidth*n,i[4]=i[12]=i[20]=i[28]=this._width-this._rightWidth*n,i[6]=i[14]=i[22]=i[30]=this._width},g.prototype._getMinScale=function(){var i=this._leftWidth+this._rightWidth,n=this._width>i?1:this._width/i,I=this._topHeight+this._bottomHeight,r=this._height>I?1:this._height/I,o=Math.min(n,r);return o},Object.defineProperty(g.prototype,"width",{get:function(){return this._width},set:function(i){this._width=i,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"height",{get:function(){return this._height},set:function(i){this._height=i,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"leftWidth",{get:function(){return this._leftWidth},set:function(i){this._leftWidth=i,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"rightWidth",{get:function(){return this._rightWidth},set:function(i){this._rightWidth=i,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"topHeight",{get:function(){return this._topHeight},set:function(i){this._topHeight=i,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"bottomHeight",{get:function(){return this._bottomHeight},set:function(i){this._bottomHeight=i,this._refresh()},enumerable:!1,configurable:!0}),g.prototype._refresh=function(){var i=this.texture,n=this.geometry.buffers[1].data;this._origWidth=i.orig.width,this._origHeight=i.orig.height;var I=1/this._origWidth,r=1/this._origHeight;n[0]=n[8]=n[16]=n[24]=0,n[1]=n[3]=n[5]=n[7]=0,n[6]=n[14]=n[22]=n[30]=1,n[25]=n[27]=n[29]=n[31]=1,n[2]=n[10]=n[18]=n[26]=I*this._leftWidth,n[4]=n[12]=n[20]=n[28]=1-I*this._rightWidth,n[9]=n[11]=n[13]=n[15]=r*this._topHeight,n[17]=n[19]=n[21]=n[23]=1-r*this._bottomHeight,this.updateHorizontalVertices(),this.updateVerticalVertices(),this.geometry.buffers[0].update(),this.geometry.buffers[1].update()},g}(XEe);/*! + * @pixi/sprite-animated - v6.5.2 + * Compiled Wed, 24 Aug 2022 13:51:19 UTC + * + * @pixi/sprite-animated is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + *//*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */var s6=function(e,g){return s6=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var I in n)n.hasOwnProperty(I)&&(i[I]=n[I])},s6(e,g)};function Q0t(e,g){s6(e,g);function i(){this.constructor=e}e.prototype=g===null?Object.create(g):(i.prototype=g.prototype,new i)}var j0t=function(e){Q0t(g,e);function g(i,n){n===void 0&&(n=!0);var I=e.call(this,i[0]instanceof Zg?i[0]:i[0].texture)||this;return I._textures=null,I._durations=null,I._autoUpdate=n,I._isConnectedToTicker=!1,I.animationSpeed=1,I.loop=!0,I.updateAnchor=!1,I.onComplete=null,I.onFrameChange=null,I.onLoop=null,I._currentTime=0,I._playing=!1,I._previousFrame=null,I.textures=i,I}return g.prototype.stop=function(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(KI.shared.remove(this.update,this),this._isConnectedToTicker=!1))},g.prototype.play=function(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(KI.shared.add(this.update,this,wc.HIGH),this._isConnectedToTicker=!0))},g.prototype.gotoAndStop=function(i){this.stop();var n=this.currentFrame;this._currentTime=i,n!==this.currentFrame&&this.updateTexture()},g.prototype.gotoAndPlay=function(i){var n=this.currentFrame;this._currentTime=i,n!==this.currentFrame&&this.updateTexture(),this.play()},g.prototype.update=function(i){if(this._playing){var n=this.animationSpeed*i,I=this.currentFrame;if(this._durations!==null){var r=this._currentTime%1*this._durations[this.currentFrame];for(r+=n/60*1e3;r<0;)this._currentTime--,r+=this._durations[this.currentFrame];var o=Math.sign(this.animationSpeed*i);for(this._currentTime=Math.floor(this._currentTime);r>=this._durations[this.currentFrame];)r-=this._durations[this.currentFrame]*o,this._currentTime+=o;this._currentTime+=r/this._durations[this.currentFrame]}else this._currentTime+=n;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):I!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrameI&&this.onLoop()),this.updateTexture())}},g.prototype.updateTexture=function(){var i=this.currentFrame;this._previousFrame!==i&&(this._previousFrame=i,this._texture=this._textures[i],this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this.uvs=this._texture._uvs.uvsFloat32,this.updateAnchor&&this._anchor.copyFrom(this._texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))},g.prototype.destroy=function(i){this.stop(),e.prototype.destroy.call(this,i),this.onComplete=null,this.onFrameChange=null,this.onLoop=null},g.fromFrames=function(i){for(var n=[],I=0;I>8&15|g>>4&240,g>>4&15|g&240,(g&15)<<4|g&15,1):i===8?Ck(g>>24&255,g>>16&255,g>>8&255,(g&255)/255):i===4?Ck(g>>12&15|g>>8&240,g>>8&15|g>>4&240,g>>4&15|g&240,((g&15)<<4|g&15)/255):null):(g=ebt.exec(e))?new Wo(g[1],g[2],g[3],1):(g=tbt.exec(e))?new Wo(g[1]*255/100,g[2]*255/100,g[3]*255/100,1):(g=gbt.exec(e))?Ck(g[1],g[2],g[3],g[4]):(g=ibt.exec(e))?Ck(g[1]*255/100,g[2]*255/100,g[3]*255/100,g[4]):(g=nbt.exec(e))?nZe(g[1],g[2]/100,g[3]/100,1):(g=Ibt.exec(e))?nZe(g[1],g[2]/100,g[3]/100,g[4]):$ye.hasOwnProperty(e)?tZe($ye[e]):e==="transparent"?new Wo(NaN,NaN,NaN,0):null}function tZe(e){return new Wo(e>>16&255,e>>8&255,e&255,1)}function Ck(e,g,i,n){return n<=0&&(e=g=i=NaN),new Wo(e,g,i,n)}function HEe(e){return e instanceof v1||(e=Gb(e)),e?(e=e.rgb(),new Wo(e.r,e.g,e.b,e.opacity)):new Wo}function YB(e,g,i,n){return arguments.length===1?HEe(e):new Wo(e,g,i,n??1)}function Wo(e,g,i,n){this.r=+e,this.g=+g,this.b=+i,this.opacity=+n}Iz(Wo,YB,Xoe(v1,{brighter:function(e){return e=e==null?kB:Math.pow(kB,e),new Wo(this.r*e,this.g*e,this.b*e,this.opacity)},darker:function(e){return e=e==null?Zb:Math.pow(Zb,e),new Wo(this.r*e,this.g*e,this.b*e,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:gZe,formatHex:gZe,formatRgb:iZe,toString:iZe}));function gZe(){return"#"+_L(this.r)+_L(this.g)+_L(this.b)}function iZe(){var e=this.opacity;return e=isNaN(e)?1:Math.max(0,Math.min(1,e)),(e===1?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(e===1?")":", "+e+")")}function _L(e){return e=Math.max(0,Math.min(255,Math.round(e)||0)),(e<16?"0":"")+e.toString(16)}function nZe(e,g,i,n){return n<=0?e=g=i=NaN:i<=0||i>=1?e=g=NaN:g<=0&&(e=NaN),new Yl(e,g,i,n)}function NEe(e){if(e instanceof Yl)return new Yl(e.h,e.s,e.l,e.opacity);if(e instanceof v1||(e=Gb(e)),!e)return new Yl;if(e instanceof Yl)return e;e=e.rgb();var g=e.r/255,i=e.g/255,n=e.b/255,I=Math.min(g,i,n),r=Math.max(g,i,n),o=NaN,C=r-I,a=(r+I)/2;return C?(g===r?o=(i-n)/C+(i0&&a<1?0:o,new Yl(o,C,a,e.opacity)}function obt(e,g,i,n){return arguments.length===1?NEe(e):new Yl(e,g,i,n??1)}function Yl(e,g,i,n){this.h=+e,this.s=+g,this.l=+i,this.opacity=+n}Iz(Yl,obt,Xoe(v1,{brighter:function(e){return e=e==null?kB:Math.pow(kB,e),new Yl(this.h,this.s,this.l*e,this.opacity)},darker:function(e){return e=e==null?Zb:Math.pow(Zb,e),new Yl(this.h,this.s,this.l*e,this.opacity)},rgb:function(){var e=this.h%360+(this.h<0)*360,g=isNaN(e)||isNaN(this.s)?0:this.s,i=this.l,n=i+(i<.5?i:1-i)*g,I=2*i-n;return new Wo(OL(e>=240?e-240:e+120,I,n),OL(e,I,n),OL(e<120?e+240:e-120,I,n),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var e=this.opacity;return e=isNaN(e)?1:Math.max(0,Math.min(1,e)),(e===1?"hsl(":"hsla(")+(this.h||0)+", "+(this.s||0)*100+"%, "+(this.l||0)*100+"%"+(e===1?")":", "+e+")")}}));function OL(e,g,i){return(e<60?g+(i-g)*e/60:e<180?i:e<240?g+(i-g)*(240-e)/60:g)*255}const Cbt=Math.PI/180,abt=180/Math.PI;var kEe=-.14861,Toe=1.78277,Hoe=-.29227,rz=-.90649,TX=1.97294,IZe=TX*rz,rZe=TX*Toe,oZe=Toe*Hoe-rz*kEe;function sbt(e){if(e instanceof M0)return new M0(e.h,e.s,e.l,e.opacity);e instanceof Wo||(e=HEe(e));var g=e.r/255,i=e.g/255,n=e.b/255,I=(oZe*n+IZe*g-rZe*i)/(oZe+IZe-rZe),r=n-I,o=(TX*(i-I)-Hoe*r)/rz,C=Math.sqrt(o*o+r*r)/(TX*I*(1-I)),a=C?Math.atan2(o,r)*abt-120:NaN;return new M0(a<0?a+360:a,C,I,e.opacity)}function um(e,g,i,n){return arguments.length===1?sbt(e):new M0(e,g,i,n??1)}function M0(e,g,i,n){this.h=+e,this.s=+g,this.l=+i,this.opacity=+n}Iz(M0,um,Xoe(v1,{brighter:function(e){return e=e==null?kB:Math.pow(kB,e),new M0(this.h,this.s,this.l*e,this.opacity)},darker:function(e){return e=e==null?Zb:Math.pow(Zb,e),new M0(this.h,this.s,this.l*e,this.opacity)},rgb:function(){var e=isNaN(this.h)?0:(this.h+120)*Cbt,g=+this.l,i=isNaN(this.s)?0:this.s*g*(1-g),n=Math.cos(e),I=Math.sin(e);return new Wo(255*(g+i*(kEe*n+Toe*I)),255*(g+i*(Hoe*n+rz*I)),255*(g+i*(TX*n)),this.opacity)}}));function YEe(e,g){return eg?1:e>=g?0:NaN}function Noe(e){let g=e,i=e;e.length===1&&(g=(o,C)=>e(o)-C,i=Abt(e));function n(o,C,a,A){for(a==null&&(a=0),A==null&&(A=o.length);a>>1;i(o[s],C)<0?a=s+1:A=s}return a}function I(o,C,a,A){for(a==null&&(a=0),A==null&&(A=o.length);a>>1;i(o[s],C)>0?A=s:a=s+1}return a}function r(o,C,a,A){a==null&&(a=0),A==null&&(A=o.length);const s=n(o,C,a,A-1);return s>a&&g(o[s-1],C)>-g(o[s],C)?s-1:s}return{left:n,center:r,right:I}}function Abt(e){return(g,i)=>YEe(e(g),i)}function lbt(e){return e===null?NaN:+e}const cbt=Noe(YEe),ubt=cbt.right;Noe(lbt).center;const dbt=ubt;let hbt=class extends Map{constructor(g,i=pbt){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:i}}),g!=null)for(const[n,I]of g)this.set(n,I)}get(g){return super.get(CZe(this,g))}has(g){return super.has(CZe(this,g))}set(g,i){return super.set(fbt(this,g),i)}delete(g){return super.delete(mbt(this,g))}};function CZe({_intern:e,_key:g},i){const n=g(i);return e.has(n)?e.get(n):i}function fbt({_intern:e,_key:g},i){const n=g(i);return e.has(n)?e.get(n):(e.set(n,i),i)}function mbt({_intern:e,_key:g},i){const n=g(i);return e.has(n)&&(i=e.get(i),e.delete(n)),i}function pbt(e){return e!==null&&typeof e=="object"?e.valueOf():e}function aZe(e){return e}function oz(e,...g){return bbt(e,aZe,aZe,g)}function bbt(e,g,i,n){return function I(r,o){if(o>=n.length)return i(r);const C=new hbt,a=n[o++];let A=-1;for(const s of r){const l=a(s,++A,r),c=C.get(l);c?c.push(s):C.set(l,[s])}for(const[s,l]of C)C.set(s,I(l,o));return g(C)}(e,0)}var A6=Math.sqrt(50),l6=Math.sqrt(10),c6=Math.sqrt(2);function ybt(e,g,i){var n,I=-1,r,o,C;if(g=+g,e=+e,i=+i,e===g&&i>0)return[e];if((n=g0){let a=Math.round(e/C),A=Math.round(g/C);for(a*Cg&&--A,o=new Array(r=A-a+1);++Ig&&--A,o=new Array(r=A-a+1);++I=0?(r>=A6?10:r>=l6?5:r>=c6?2:1)*Math.pow(10,I):-Math.pow(10,-I)/(r>=A6?10:r>=l6?5:r>=c6?2:1)}function Zbt(e,g,i){var n=Math.abs(g-e)/Math.max(0,i),I=Math.pow(10,Math.floor(Math.log(n)/Math.LN10)),r=n/I;return r>=A6?I*=10:r>=l6?I*=5:r>=c6&&(I*=2),g=n)&&(i=n);else{let n=-1;for(let I of e)(I=g(I,++n,e))!=null&&(i=I)&&(i=I)}return i}function HK(e,g){let i;if(g===void 0)for(const n of e)n!=null&&(i>n||i===void 0&&n>=n)&&(i=n);else{let n=-1;for(let I of e)(I=g(I,++n,e))!=null&&(i>I||i===void 0&&I>=I)&&(i=I)}return i}function Gbt(e,g,i){e=+e,g=+g,i=(I=arguments.length)<2?(g=e,e=0,1):I<3?1:+i;for(var n=-1,I=Math.max(0,Math.ceil((g-e)/i))|0,r=new Array(I);++n1;){for(let C=0;C1;I--,r--){const o=[];for(let C=0,a;C"u")e=.5;else if(e===0||e===1)return e;const i=Na(e,g)+Na(1-e,g),n=i-1;return qS(n/i)},projectionratio:function(e,g){if(g!==2&&g!==3)return!1;if(typeof e>"u")e=.5;else if(e===0||e===1)return e;const i=Na(1-e,g),n=Na(e,g)+i;return i/n},lli8:function(e,g,i,n,I,r,o,C){const a=(e*n-g*i)*(I-o)-(e-i)*(I*C-r*o),A=(e*n-g*i)*(r-C)-(g-n)*(I*C-r*o),s=(e-i)*(r-C)-(g-n)*(I-o);return s==0?!1:{x:a/s,y:A/s}},lli4:function(e,g,i,n){const I=e.x,r=e.y,o=g.x,C=g.y,a=i.x,A=i.y,s=n.x,l=n.y;return Gt.lli8(I,r,o,C,a,A,s,l)},lli:function(e,g){return Gt.lli4(e,e.c,g,g.c)},makeline:function(e,g){const i=e.x,n=e.y,I=g.x,r=g.y,o=(I-i)/3,C=(r-n)/3;return new zn(i,n,i+o,n+C,i+2*o,n+2*C,I,r)},findbbox:function(e){let g=JL,i=JL,n=LL,I=LL;return e.forEach(function(r){const o=r.bbox();g>o.x.min&&(g=o.x.min),i>o.y.min&&(i=o.y.min),n0&&(s.c1=a,s.c2=A,s.s1=e,s.s2=i,r.push(s))})}),r},makeshape:function(e,g,i){const n=g.points.length,I=e.points.length,r=Gt.makeline(g.points[n-1],e.points[0]),o=Gt.makeline(e.points[I-1],g.points[0]),C={startcap:r,forward:e,back:g,endcap:o,bbox:Gt.findbbox([r,e,g,o])};return C.intersections=function(a){return Gt.shapeintersections(C,C.bbox,a,a.bbox,i)},C},getminmax:function(e,g,i){if(!i)return{min:0,max:0};let n=JL,I=LL,r,o;i.indexOf(0)===-1&&(i=[0].concat(i)),i.indexOf(1)===-1&&i.push(1);for(let C=0,a=i.length;CI&&(I=o[g]);return{min:n,mid:(n+I)/2,max:I,size:I-n}},align:function(e,g){const i=g.p1.x,n=g.p1.y,I=-eR(g.p2.y-n,g.p2.x-i),r=function(o){return{x:(o.x-i)*du(I)-(o.y-n)*KZ(I),y:(o.x-i)*KZ(I)+(o.y-n)*du(I)}};return e.map(r)},roots:function(e,g){g=g||{p1:{x:0,y:0},p2:{x:1,y:0}};const i=e.length-1,n=Gt.align(e,g),I=function(G){return 0<=G&&G<=1};if(i===2){const G=n[0].y,B=n[1].y,S=n[2].y,R=G-2*B+S;if(R!==0){const w=-Zh(B*B-G*S),T=-G+B,W=-(w+T)/R,V=-(-w+T)/R;return[W,V].filter(I)}else if(B!==S&&R===0)return[(2*B-S)/(2*B-2*S)].filter(I);return[]}const r=n[0].y,o=n[1].y,C=n[2].y,a=n[3].y;let A=-r+3*o-3*C+a,s=3*r-6*o+3*C,l=-3*r+3*o,c=r;if(Gt.approximately(A,0)){if(Gt.approximately(s,0))return Gt.approximately(l,0)?[]:[-c/l].filter(I);const G=Zh(l*l-4*s*c),B=2*s;return[(G-l)/B,(-l-G)/B].filter(I)}s/=A,l/=A,c/=A;const u=(3*l-s*s)/3,d=u/3,h=(2*s*s*s-9*s*l+27*c)/27,f=h/2,m=f*f+d*d*d;let b,p,y,Z,v;if(m<0){const G=-u/3,B=G*G*G,S=Zh(B),R=-h/(2*S),w=R<-1?-1:R>1?1:R,T=vbt(w),W=tR(S),V=2*W;return y=V*du(T/3)-s/3,Z=V*du((T+ak)/3)-s/3,v=V*du((T+2*ak)/3)-s/3,[y,Z,v].filter(I)}else{if(m===0)return b=f<0?tR(-f):-tR(f),y=2*b-s/3,Z=-b-s/3,[y,Z].filter(I);{const G=Zh(m);return b=tR(-f+G),p=tR(f+G),[b-p-s/3].filter(I)}}},droots:function(e){if(e.length===3){const g=e[0],i=e[1],n=e[2],I=g-2*i+n;if(I!==0){const r=-Zh(i*i-g*n),o=-g+i,C=-(r+o)/I,a=-(-r+o)/I;return[C,a]}else if(i!==n&&I===0)return[(2*i-n)/(2*(i-n))];return[]}if(e.length===2){const g=e[0],i=e[1];return g!==i?[g/(g-i)]:[]}return[]},curvature:function(e,g,i,n,I){let r,o,C,a,A=0,s=0;const l=Gt.compute(e,g),c=Gt.compute(e,i),u=l.x*l.x+l.y*l.y;if(n?(r=Zh(Na(l.y*c.z-c.y*l.z,2)+Na(l.z*c.x-c.z*l.x,2)+Na(l.x*c.y-c.x*l.y,2)),o=Na(u+l.z*l.z,3/2)):(r=l.x*c.y-l.y*c.x,o=Na(u,3/2)),r===0||o===0)return{k:0,r:0};if(A=r/o,s=o/r,!I){const d=Gt.curvature(e-.001,g,i,n,!0).k,h=Gt.curvature(e+.001,g,i,n,!0).k;a=(h-A+(A-d))/2,C=(qS(h-A)+qS(A-d))/2}return{k:A,r:s,dk:a,adk:C}},inflections:function(e){if(e.length<4)return[];const g=Gt.align(e,{p1:e[0],p2:e.slice(-1)[0]}),i=g[2].x*g[1].y,n=g[3].x*g[1].y,I=g[1].x*g[2].y,r=g[3].x*g[2].y,o=18*(-3*i+2*n+3*I-r),C=18*(3*i-n-3*I),a=18*(I-i);if(Gt.approximately(o,0)){if(!Gt.approximately(C,0)){let c=-a/C;if(0<=c&&c<=1)return[c]}return[]}const A=C*C-4*o*a,s=Math.sqrt(A),l=2*o;return Gt.approximately(l,0)?[]:[(s-C)/l,-(C+s)/l].filter(function(c){return 0<=c&&c<=1})},bboxoverlap:function(e,g){const i=["x","y"],n=i.length;for(let I=0,r,o,C,a;I=a)return!1;return!0},expandbox:function(e,g){g.x.mine.x.max&&(e.x.max=g.x.max),g.y.max>e.y.max&&(e.y.max=g.y.max),g.z&&g.z.max>e.z.max&&(e.z.max=g.z.max),e.x.mid=(e.x.min+e.x.max)/2,e.y.mid=(e.y.min+e.y.max)/2,e.z&&(e.z.mid=(e.z.min+e.z.max)/2),e.x.size=e.x.max-e.x.min,e.y.size=e.y.max-e.y.min,e.z&&(e.z.size=e.z.max-e.z.min)},pairiteration:function(e,g,i){const n=e.bbox(),I=g.bbox(),r=1e5,o=i||.5;if(n.x.size+n.y.sizev||v>G)&&(Z+=ak),Z>G&&(B=G,G=Z,Z=B)):G4){if(arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");I=!0}}else if(r!==6&&r!==8&&r!==9&&r!==12&&arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const o=this._3d=!I&&(r===9||r===12)||g&&g[0]&&typeof g[0].z<"u",C=this.points=[];for(let c=0,u=o?3:2;cgR(c.y)>1e-4),this._lut=[],this._t1=0,this._t2=1,this.update()}static quadraticFromPoints(g,i,n,I){if(typeof I>"u"&&(I=.5),I===0)return new zn(i,i,n);if(I===1)return new zn(g,i,i);const r=zn.getABC(2,g,i,n,I);return new zn(g,r.A,n)}static cubicFromPoints(g,i,n,I,r){typeof I>"u"&&(I=.5);const o=zn.getABC(3,g,i,n,I);typeof r>"u"&&(r=Gt.dist(i,o.C));const C=r*(1-I)/I,a=Gt.dist(g,n),A=(n.x-g.x)/a,s=(n.y-g.y)/a,l=r*A,c=r*s,u=C*A,d=C*s,h={x:i.x-l,y:i.y-c},f={x:i.x+u,y:i.y+d},m=o.A,b={x:m.x+(h.x-m.x)/(1-I),y:m.y+(h.y-m.y)/(1-I)},p={x:m.x+(f.x-m.x)/I,y:m.y+(f.y-m.y)/I},y={x:g.x+(b.x-g.x)/I,y:g.y+(b.y-g.y)/I},Z={x:n.x+(p.x-n.x)/(1-I),y:n.y+(p.y-n.y)/(1-I)};return new zn(g,y,Z,n)}static getUtils(){return Gt}getUtils(){return zn.getUtils()}static get PolyBezier(){return Px}valueOf(){return this.toString()}toString(){return Gt.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const g=this.points,i=g[0].x,n=g[0].y,I=["M",i,n,this.order===2?"Q":"C"];for(let r=1,o=g.length;r0}length(){return Gt.length(this.derivative.bind(this))}static getABC(g=2,i,n,I,r=.5){const o=Gt.projectionratio(r,g),C=1-o,a={x:o*i.x+C*I.x,y:o*i.y+C*I.y},A=Gt.abcratio(r,g);return{A:{x:n.x+(n.x-a.x)/A,y:n.y+(n.y-a.y)/A},B:n,C:a,S:i,E:I}}getABC(g,i){i=i||this.get(g);let n=this.points[0],I=this.points[this.order];return zn.getABC(this.order,n,i,I,g)}getLUT(g){if(this.verify(),g=g||100,this._lut.length===g)return this._lut;this._lut=[],g--;for(let i=0,n,I;i1?1:l,c=this.compute(l),c.t=l,c.d=A,c}get(g){return this.compute(g)}point(g){return this.points[g]}compute(g){return this.ratios?Gt.computeWithRatios(g,this.points,this.ratios,this._3d):Gt.compute(g,this.points,this._3d,this.ratios)}raise(){const g=this.points,i=[g[0]],n=g.length;for(let I=1,r,o;I1;){n=[];for(let o=0,C,a=i.length-1;o=0&&o<=1}),i=i.concat(g[n].sort(Gt.numberSort))}.bind(this)),g.values=i.sort(Gt.numberSort).filter(function(n,I){return i.indexOf(n)===I}),g}bbox(){const g=this.extrema(),i={};return this.dims.forEach(function(n){i[n]=Gt.getminmax(this,n,g[n])}.bind(this)),i}overlaps(g){const i=this.bbox(),n=g.bbox();return Gt.bboxoverlap(i,n)}offset(g,i){if(typeof i<"u"){const n=this.get(g),I=this.normal(g),r={c:n,n:I,x:n.x+I.x*i,y:n.y+I.y*i};return this._3d&&(r.z=n.z+I.z*i),r}if(this._linear){const n=this.normal(0),I=this.points.map(function(r){const o={x:r.x+g*n.x,y:r.y+g*n.y};return r.z&&n.z&&(o.z=r.z+g*n.z),o});return[new zn(I)]}return this.reduce().map(function(n){return n._linear?n.offset(g)[0]:n.scale(g)})}simple(){if(this.order===3){const I=Gt.angle(this.points[0],this.points[3],this.points[1]),r=Gt.angle(this.points[0],this.points[3],this.points[2]);if(I>0&&r<0||I<0&&r>0)return!1}const g=this.normal(0),i=this.normal(1);let n=g.x*i.x+g.y*i.y;return this._3d&&(n+=g.z*i.z),gR(Vbt(n)){if(i===2&&l)return;const c=A[l*i],u=this.derivative(l),d={x:c.x+u.x,y:c.y+u.y};A[l+1]=Gt.lli4(c,d,s,a[l+1])}),new zn(A))}outline(g,i,n,I){i=typeof i>"u"?g:i;const r=this.reduce(),o=r.length,C=[];let a=[],A,s=0,l=this.length();const c=typeof n<"u"&&typeof I<"u";function u(Z,v,G,B,S){return function(R){const w=B/G,T=(B+S)/G,W=v-Z;return Gt.map(R,0,1,Z+w*W,Z+T*W)}}r.forEach(function(Z){const v=Z.length();c?(C.push(Z.scale(u(g,n,l,s,v))),a.push(Z.scale(u(-i,-I,l,s,v)))):(C.push(Z.scale(g)),a.push(Z.scale(-i))),s+=v}),a=a.map(function(Z){return A=Z.points,A[3]?Z.points=[A[3],A[2],A[1],A[0]]:Z.points=[A[2],A[1],A[0]],Z}).reverse();const d=C[0].points[0],h=C[o-1].points[C[o-1].points.length-1],f=a[o-1].points[a[o-1].points.length-1],m=a[0].points[0],b=Gt.makeline(f,d),p=Gt.makeline(h,m),y=[b].concat(C).concat([p]).concat(a);return y.length,new Px(y)}outlineshapes(g,i,n){i=i||g;const I=this.outline(g,i).curves,r=[];for(let o=1,C=I.length;o1,a.endcap.virtual=o{var C=this.get(o);return Gt.between(C.x,i,I)&&Gt.between(C.y,n,r)})}selfintersects(g){const i=this.reduce(),n=i.length-2,I=[];for(let r=0,o,C,a;r0&&(r=r.concat(C))}),r}arcs(g){return g=g||.5,this._iterate(g,[])}_error(g,i,n,I){const r=(I-n)/4,o=this.get(n+r),C=this.get(I-r),a=Gt.dist(g,i),A=Gt.dist(g,o),s=Gt.dist(g,C);return gR(A-a)+gR(s-a)}_iterate(g,i){let n=0,I=1,r;do{r=0,I=1;let o=this.get(n),C,a,A,s,l=!1,c=!1,u,d=I,h=1;do if(c=l,s=A,d=(n+I)/2,C=this.get(d),a=this.get(I),A=Gt.getccenter(o,C,a),A.interval={start:n,end:I},l=this._error(A,o,n,I)<=g,u=c&&!l,u||(h=I),l){if(I>=1){if(A.interval.end=h=1,s=A,I>1){let m={x:A.x+A.r*Sbt(A.e),y:A.y+A.r*Rbt(A.e)};A.e+=Gt.angle({x:A.x,y:A.y},m,this.get(1))}break}I=I+(I-n)/2}else I=d;while(!u&&r++<100);if(r>=100)break;s=s||A,i.push(s),n=h}while(I<1);return i}}function koe(e,g){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(g).domain(e);break}return this}function Xbt(e,g){switch(arguments.length){case 0:break;case 1:{typeof e=="function"?this.interpolator(e):this.range(e);break}default:{this.domain(e),typeof g=="function"?this.interpolator(g):this.range(g);break}}return this}const cZe=Symbol("implicit");function _x(){var e=new Map,g=[],i=[],n=cZe;function I(r){var o=r+"",C=e.get(o);if(!C){if(n!==cZe)return n;e.set(o,C=g.push(r))}return i[(C-1)%i.length]}return I.domain=function(r){if(!arguments.length)return g.slice();g=[],e=new Map;for(const o of r){const C=o+"";e.has(C)||e.set(C,g.push(o))}return I},I.range=function(r){return arguments.length?(i=Array.from(r),I):i.slice()},I.unknown=function(r){return arguments.length?(n=r,I):n},I.copy=function(){return _x(g,i).unknown(n)},koe.apply(I,arguments),I}function FEe(){var e=_x().unknown(void 0),g=e.domain,i=e.range,n=0,I=1,r,o,C=!1,a=0,A=0,s=.5;delete e.unknown;function l(){var c=g().length,u=I()=>e;function Tbt(e,g){return function(i){return e+i*g}}function Hbt(e,g,i){return e=Math.pow(e,i),g=Math.pow(g,i)-e,i=1/i,function(n){return Math.pow(e+n*g,i)}}function Nbt(e){return(e=+e)==1?EEe:function(g,i){return i-g?Hbt(g,i,e):Yoe(isNaN(g)?i:g)}}function EEe(e,g){var i=g-e;return i?Tbt(e,i):Yoe(isNaN(e)?g:e)}const uZe=function e(g){var i=Nbt(g);function n(I,r){var o=i((I=YB(I)).r,(r=YB(r)).r),C=i(I.g,r.g),a=i(I.b,r.b),A=EEe(I.opacity,r.opacity);return function(s){return I.r=o(s),I.g=C(s),I.b=a(s),I.opacity=A(s),I+""}}return n.gamma=e,n}(1);function kbt(e,g){g||(g=[]);var i=e?Math.min(g.length,e.length):0,n=g.slice(),I;return function(r){for(I=0;Ii&&(r=g.slice(i,r),C[o]?C[o]+=r:C[++o]=r),(n=n[0])===(I=I[0])?C[o]?C[o]+=I:C[++o]=I:(C[++o]=null,a.push({i:o,x:Ox(n,I)})),i=UL.lastIndex;return ig&&(i=e,e=g,g=i),function(n){return Math.max(e,Math.min(g,n))}}function Obt(e,g,i){var n=e[0],I=e[1],r=g[0],o=g[1];return I2?Jbt:Obt,a=A=null,l}function l(c){return c==null||isNaN(c=+c)?r:(a||(a=C(e.map(n),g,i)))(n(o(c)))}return l.invert=function(c){return o(I((A||(A=C(g,e.map(n),Ox)))(c)))},l.domain=function(c){return arguments.length?(e=Array.from(c,Pbt),s()):e.slice()},l.range=function(c){return arguments.length?(g=Array.from(c),s()):g.slice()},l.rangeRound=function(c){return g=Array.from(c),i=DEe,s()},l.clamp=function(c){return arguments.length?(o=c?!0:pf,s()):o!==pf},l.interpolate=function(c){return arguments.length?(i=c,s()):i},l.unknown=function(c){return arguments.length?(r=c,l):r},function(c,u){return n=c,I=u,s()}}function Qbt(){return Ubt()(pf,pf)}function jbt(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function Jx(e,g){if((i=(e=g?e.toExponential(g-1):e.toExponential()).indexOf("e"))<0)return null;var i,n=e.slice(0,i);return[n.length>1?n[0]+n.slice(2):n,+e.slice(i+1)]}function KB(e){return e=Jx(Math.abs(e)),e?e[1]:NaN}function $bt(e,g){return function(i,n){for(var I=i.length,r=[],o=0,C=e[0],a=0;I>0&&C>0&&(a+C+1>n&&(C=Math.max(1,n-a)),r.push(i.substring(I-=C,I+C)),!((a+=C+1)>n));)C=e[o=(o+1)%e.length];return r.reverse().join(g)}}function qbt(e){return function(g){return g.replace(/[0-9]/g,function(i){return e[+i]})}}var eyt=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Lx(e){if(!(g=eyt.exec(e)))throw new Error("invalid format: "+e);var g;return new Koe({fill:g[1],align:g[2],sign:g[3],symbol:g[4],zero:g[5],width:g[6],comma:g[7],precision:g[8]&&g[8].slice(1),trim:g[9],type:g[10]})}Lx.prototype=Koe.prototype;function Koe(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}Koe.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function tyt(e){e:for(var g=e.length,i=1,n=-1,I;i0&&(n=0);break}return n>0?e.slice(0,n)+e.slice(I+1):e}var MEe;function gyt(e,g){var i=Jx(e,g);if(!i)return e+"";var n=i[0],I=i[1],r=I-(MEe=Math.max(-8,Math.min(8,Math.floor(I/3)))*3)+1,o=n.length;return r===o?n:r>o?n+new Array(r-o+1).join("0"):r>0?n.slice(0,r)+"."+n.slice(r):"0."+new Array(1-r).join("0")+Jx(e,Math.max(0,g+r-1))[0]}function hZe(e,g){var i=Jx(e,g);if(!i)return e+"";var n=i[0],I=i[1];return I<0?"0."+new Array(-I).join("0")+n:n.length>I+1?n.slice(0,I+1)+"."+n.slice(I+1):n+new Array(I-n.length+2).join("0")}const fZe={"%":(e,g)=>(e*100).toFixed(g),b:e=>Math.round(e).toString(2),c:e=>e+"",d:jbt,e:(e,g)=>e.toExponential(g),f:(e,g)=>e.toFixed(g),g:(e,g)=>e.toPrecision(g),o:e=>Math.round(e).toString(8),p:(e,g)=>hZe(e*100,g),r:hZe,s:gyt,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function mZe(e){return e}var pZe=Array.prototype.map,bZe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function iyt(e){var g=e.grouping===void 0||e.thousands===void 0?mZe:$bt(pZe.call(e.grouping,Number),e.thousands+""),i=e.currency===void 0?"":e.currency[0]+"",n=e.currency===void 0?"":e.currency[1]+"",I=e.decimal===void 0?".":e.decimal+"",r=e.numerals===void 0?mZe:qbt(pZe.call(e.numerals,String)),o=e.percent===void 0?"%":e.percent+"",C=e.minus===void 0?"−":e.minus+"",a=e.nan===void 0?"NaN":e.nan+"";function A(l){l=Lx(l);var c=l.fill,u=l.align,d=l.sign,h=l.symbol,f=l.zero,m=l.width,b=l.comma,p=l.precision,y=l.trim,Z=l.type;Z==="n"?(b=!0,Z="g"):fZe[Z]||(p===void 0&&(p=12),y=!0,Z="g"),(f||c==="0"&&u==="=")&&(f=!0,c="0",u="=");var v=h==="$"?i:h==="#"&&/[boxX]/.test(Z)?"0"+Z.toLowerCase():"",G=h==="$"?n:/[%p]/.test(Z)?o:"",B=fZe[Z],S=/[defgprs%]/.test(Z);p=p===void 0?6:/[gprs]/.test(Z)?Math.max(1,Math.min(21,p)):Math.max(0,Math.min(20,p));function R(w){var T=v,W=G,V,X,N;if(Z==="c")W=B(w)+W,w="";else{w=+w;var Y=w<0||1/w<0;if(w=isNaN(w)?a:B(Math.abs(w),p),y&&(w=tyt(w)),Y&&+w==0&&d!=="+"&&(Y=!1),T=(Y?d==="("?d:C:d==="-"||d==="("?"":d)+T,W=(Z==="s"?bZe[8+MEe/3]:"")+W+(Y&&d==="("?")":""),S){for(V=-1,X=w.length;++VN||N>57){W=(N===46?I+w.slice(V+1):w.slice(V))+W,w=w.slice(0,V);break}}}b&&!f&&(w=g(w,1/0));var x=T.length+w.length+W.length,M=x>1)+T+w+W+M.slice(x);break;default:w=M+T+w+W;break}return r(w)}return R.toString=function(){return l+""},R}function s(l,c){var u=A((l=Lx(l),l.type="f",l)),d=Math.max(-8,Math.min(8,Math.floor(KB(c)/3)))*3,h=Math.pow(10,-d),f=bZe[8+d/3];return function(m){return u(h*m)+f}}return{format:A,formatPrefix:s}}var sk,zEe,PEe;nyt({thousands:",",grouping:[3],currency:["$",""]});function nyt(e){return sk=iyt(e),zEe=sk.format,PEe=sk.formatPrefix,sk}function Iyt(e){return Math.max(0,-KB(Math.abs(e)))}function ryt(e,g){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(KB(g)/3)))*3-KB(Math.abs(e)))}function oyt(e,g){return e=Math.abs(e),g=Math.abs(g)-e,Math.max(0,KB(g)-KB(e))+1}function Cyt(e,g,i,n){var I=Zbt(e,g,i),r;switch(n=Lx(n??",f"),n.type){case"s":{var o=Math.max(Math.abs(e),Math.abs(g));return n.precision==null&&!isNaN(r=ryt(I,o))&&(n.precision=r),PEe(n,o)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(r=oyt(I,Math.max(Math.abs(e),Math.abs(g))))&&(n.precision=r-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(r=Iyt(I))&&(n.precision=r-(n.type==="%")*2);break}}return zEe(n)}function _Ee(e){var g=e.domain;return e.ticks=function(i){var n=g();return ybt(n[0],n[n.length-1],i??10)},e.tickFormat=function(i,n){var I=g();return Cyt(I[0],I[I.length-1],i??10,n)},e.nice=function(i){i==null&&(i=10);var n=g(),I=0,r=n.length-1,o=n[I],C=n[r],a,A,s=10;for(C0;){if(A=KEe(o,C,i),A===a)return n[I]=o,n[r]=C,g(n);if(A>0)o=Math.floor(o/A)*A,C=Math.ceil(C/A)*A;else if(A<0)o=Math.ceil(o*A)/A,C=Math.floor(C*A)/A;else break;a=A}return e},e}function vb(){var e=Qbt();return e.copy=function(){return Lbt(e,vb())},koe.apply(e,arguments),_Ee(e)}function ayt(){var e=0,g=1,i,n,I,r,o=pf,C=!1,a;function A(l){return l==null||isNaN(l=+l)?a:o(I===0?.5:(l=(r(l)-i)*I,C?Math.max(0,Math.min(1,l)):l))}A.domain=function(l){return arguments.length?([e,g]=l,i=r(e=+e),n=r(g=+g),I=i===n?0:1/(n-i),A):[e,g]},A.clamp=function(l){return arguments.length?(C=!!l,A):C},A.interpolator=function(l){return arguments.length?(o=l,A):o};function s(l){return function(c){var u,d;return arguments.length?([u,d]=c,o=l(u,d),A):[o(0),o(1)]}}return A.range=s(Cz),A.rangeRound=s(DEe),A.unknown=function(l){return arguments.length?(a=l,A):a},function(l){return r=l,i=l(e),n=l(g),I=i===n?0:1/(n-i),A}}function syt(e,g){return g.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown())}function OEe(){var e=_Ee(ayt()(pf));return e.copy=function(){return syt(e,OEe())},Xbt.apply(e,arguments)}var Ayt=typeof global=="object"&&global&&global.Object===Object&&global;const JEe=Ayt;var lyt=typeof self=="object"&&self&&self.Object===Object&&self,cyt=JEe||lyt||Function("return this")();const _c=cyt;var uyt=_c.Symbol;const Rc=uyt;var LEe=Object.prototype,dyt=LEe.hasOwnProperty,hyt=LEe.toString,nR=Rc?Rc.toStringTag:void 0;function fyt(e){var g=dyt.call(e,nR),i=e[nR];try{e[nR]=void 0;var n=!0}catch{}var I=hyt.call(e);return n&&(g?e[nR]=i:delete e[nR]),I}var myt=Object.prototype,pyt=myt.toString;function byt(e){return pyt.call(e)}var yyt="[object Null]",Zyt="[object Undefined]",yZe=Rc?Rc.toStringTag:void 0;function B1(e){return e==null?e===void 0?Zyt:yyt:yZe&&yZe in Object(e)?fyt(e):byt(e)}function dm(e){return e!=null&&typeof e=="object"}var Gyt="[object Symbol]";function az(e){return typeof e=="symbol"||dm(e)&&B1(e)==Gyt}function UEe(e,g){for(var i=-1,n=e==null?0:e.length,I=Array(n);++i-1}var cZt=9007199254740991,uZt=/^(?:0|[1-9]\d*)$/;function xoe(e,g){var i=typeof e;return g=g??cZt,!!g&&(i=="number"||i!="symbol"&&uZt.test(e))&&e>-1&&e%1==0&&e-1&&e%1==0&&e<=fZt}function Eoe(e){return e!=null&&Foe(e.length)&&!jEe(e)}function mZt(e,g,i){if(!Xd(i))return!1;var n=typeof g;return(n=="number"?Eoe(i)&&xoe(g,i.length):n=="string"&&g in i)?sz(i[g],e):!1}var pZt=Object.prototype;function Doe(e){var g=e&&e.constructor,i=typeof g=="function"&&g.prototype||pZt;return e===i}function bZt(e,g){for(var i=-1,n=Array(e);++i-1}function NGt(e,g){var i=this.__data__,n=lz(i,e);return n<0?(++this.size,i.push([e,g])):i[n][1]=g,this}function Jd(e){var g=-1,i=e==null?0:e.length;for(this.clear();++g=g?e:g)),e}function qGt(){this.__data__=new Jd,this.size=0}function evt(e){var g=this.__data__,i=g.delete(e);return this.size=g.size,i}function tvt(e){return this.__data__.get(e)}function gvt(e){return this.__data__.has(e)}var ivt=200;function nvt(e,g){var i=this.__data__;if(i instanceof Jd){var n=i.__data__;if(!NX||n.lengthC))return!1;var A=r.get(e),s=r.get(g);if(A&&s)return A==g&&s==e;var l=-1,c=!0,u=i&_Bt?new YX:void 0;for(r.set(e,g),r.set(g,e);++l=Ewt){var A=g?null:Fwt(e);if(A)return Loe(A);o=!1,I=bDe,a=new YX}else a=g?[]:C;e:for(;++n=1?(i=1,g-1):Math.floor(i*g),I=e[n],r=e[n+1],o=n>0?e[n-1]:2*I-r,C=n()=>e;function wDe(e,g){return function(i){return e+i*g}}function _wt(e,g,i){return e=Math.pow(e,i),g=Math.pow(g,i)-e,i=1/i,function(n){return Math.pow(e+n*g,i)}}function Owt(e,g){var i=g-e;return i?wDe(e,i>180||i<-180?i-360*Math.round(i/360):i):Qoe(isNaN(e)?g:e)}function Jwt(e){return(e=+e)==1?Kv:function(g,i){return i-g?_wt(g,i,e):Qoe(isNaN(g)?i:g)}}function Kv(e,g){var i=g-e;return i?wDe(e,i):Qoe(isNaN(e)?g:e)}(function e(g){var i=Jwt(g);function n(I,r){var o=i((I=YB(I)).r,(r=YB(r)).r),C=i(I.g,r.g),a=i(I.b,r.b),A=Kv(I.opacity,r.opacity);return function(s){return I.r=o(s),I.g=C(s),I.b=a(s),I.opacity=A(s),I+""}}return n.gamma=e,n})(1);function Lwt(e){return function(g){var i=g.length,n=new Array(i),I=new Array(i),r=new Array(i),o,C;for(o=0;oUwt(e[e.length-1]);var Qwt=new Array(3).concat("ef8a62f7f7f767a9cf","ca0020f4a58292c5de0571b0","ca0020f4a582f7f7f792c5de0571b0","b2182bef8a62fddbc7d1e5f067a9cf2166ac","b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac","b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac","b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac","67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061","67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061").map(Oc);const jwt=w1(Qwt);var $wt=new Array(3).concat("fc8d59ffffbf99d594","d7191cfdae61abdda42b83ba","d7191cfdae61ffffbfabdda42b83ba","d53e4ffc8d59fee08be6f59899d5943288bd","d53e4ffc8d59fee08bffffbfe6f59899d5943288bd","d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd","d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd","9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2","9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2").map(Oc);const qwt=w1($wt);var e1t=new Array(3).concat("e0ecf49ebcda8856a7","edf8fbb3cde38c96c688419d","edf8fbb3cde38c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b").map(Oc);const t1t=w1(e1t);var g1t=new Array(3).concat("fde0ddfa9fb5c51b8a","feebe2fbb4b9f768a1ae017e","feebe2fbb4b9f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a").map(Oc);const i1t=w1(g1t);var n1t=new Array(3).concat("fff7bcfec44fd95f0e","ffffd4fed98efe9929cc4c02","ffffd4fed98efe9929d95f0e993404","ffffd4fee391fec44ffe9929d95f0e993404","ffffd4fee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506").map(Oc);const I1t=w1(n1t);var r1t=new Array(3).concat("f0f0f0bdbdbd636363","f7f7f7cccccc969696525252","f7f7f7cccccc969696636363252525","f7f7f7d9d9d9bdbdbd969696636363252525","f7f7f7d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000").map(Oc);const o1t=w1(r1t);function C1t(e){return e=Math.max(0,Math.min(1,e)),"rgb("+Math.max(0,Math.min(255,Math.round(-4.54-e*(35.34-e*(2381.73-e*(6402.7-e*(7024.72-e*2710.57)))))))+", "+Math.max(0,Math.min(255,Math.round(32.49+e*(170.73+e*(52.82-e*(131.46-e*(176.58-e*67.37)))))))+", "+Math.max(0,Math.min(255,Math.round(81.24+e*(442.36-e*(2482.43-e*(6167.24-e*(6614.94-e*2475.67)))))))+")"}var a1t=RDe(um(-100,.75,.35),um(80,1.5,.8));RDe(um(260,.75,.35),um(80,1.5,.8));um();function hz(e){var g=e.length;return function(i){return e[Math.max(0,Math.min(g-1,Math.floor(i*g)))]}}const VDe=hz(Oc("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));hz(Oc("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf"));hz(Oc("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4"));hz(Oc("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));const s1t={};var wb={},fz={};fz.byteLength=c1t;fz.toByteArray=d1t;fz.fromByteArray=m1t;var Kl=[],Ka=[],A1t=typeof Uint8Array<"u"?Uint8Array:Array,qL="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var xZ=0,l1t=qL.length;xZ0)throw new Error("Invalid string. Length must be a multiple of 4");var i=e.indexOf("=");i===-1&&(i=g);var n=i===g?0:4-i%4;return[i,n]}function c1t(e){var g=WDe(e),i=g[0],n=g[1];return(i+n)*3/4-n}function u1t(e,g,i){return(g+i)*3/4-i}function d1t(e){var g,i=WDe(e),n=i[0],I=i[1],r=new A1t(u1t(e,n,I)),o=0,C=I>0?n-4:n,a;for(a=0;a>16&255,r[o++]=g>>8&255,r[o++]=g&255;return I===2&&(g=Ka[e.charCodeAt(a)]<<2|Ka[e.charCodeAt(a+1)]>>4,r[o++]=g&255),I===1&&(g=Ka[e.charCodeAt(a)]<<10|Ka[e.charCodeAt(a+1)]<<4|Ka[e.charCodeAt(a+2)]>>2,r[o++]=g>>8&255,r[o++]=g&255),r}function h1t(e){return Kl[e>>18&63]+Kl[e>>12&63]+Kl[e>>6&63]+Kl[e&63]}function f1t(e,g,i){for(var n,I=[],r=g;rC?C:o+r));return n===1?(g=e[i-1],I.push(Kl[g>>2]+Kl[g<<4&63]+"==")):n===2&&(g=(e[i-2]<<8)+e[i-1],I.push(Kl[g>>10]+Kl[g>>4&63]+Kl[g<<2&63]+"=")),I.join("")}var joe={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */joe.read=function(e,g,i,n,I){var r,o,C=I*8-n-1,a=(1<>1,s=-7,l=i?I-1:0,c=i?-1:1,u=e[g+l];for(l+=c,r=u&(1<<-s)-1,u>>=-s,s+=C;s>0;r=r*256+e[g+l],l+=c,s-=8);for(o=r&(1<<-s)-1,r>>=-s,s+=n;s>0;o=o*256+e[g+l],l+=c,s-=8);if(r===0)r=1-A;else{if(r===a)return o?NaN:(u?-1:1)*(1/0);o=o+Math.pow(2,n),r=r-A}return(u?-1:1)*o*Math.pow(2,r-n)};joe.write=function(e,g,i,n,I,r){var o,C,a,A=r*8-I-1,s=(1<>1,c=I===23?Math.pow(2,-24)-Math.pow(2,-77):0,u=n?0:r-1,d=n?1:-1,h=g<0||g===0&&1/g<0?1:0;for(g=Math.abs(g),isNaN(g)||g===1/0?(C=isNaN(g)?1:0,o=s):(o=Math.floor(Math.log(g)/Math.LN2),g*(a=Math.pow(2,-o))<1&&(o--,a*=2),o+l>=1?g+=c/a:g+=c*Math.pow(2,1-l),g*a>=2&&(o++,a/=2),o+l>=s?(C=0,o=s):o+l>=1?(C=(g*a-1)*Math.pow(2,I),o=o+l):(C=g*Math.pow(2,l-1)*Math.pow(2,I),o=0));I>=8;e[i+u]=C&255,u+=d,C/=256,I-=8);for(o=o<0;e[i+u]=o&255,u+=d,o/=256,A-=8);e[i+u-d]|=h*128};/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */(function(e){const g=fz,i=joe,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=C,e.SlowBuffer=b,e.INSPECT_MAX_BYTES=50;const I=2147483647;e.kMaxLength=I,C.TYPED_ARRAY_SUPPORT=r(),!C.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function r(){try{const E=new Uint8Array(1),H={foo:function(){return 42}};return Object.setPrototypeOf(H,Uint8Array.prototype),Object.setPrototypeOf(E,H),E.foo()===42}catch{return!1}}Object.defineProperty(C.prototype,"parent",{enumerable:!0,get:function(){if(C.isBuffer(this))return this.buffer}}),Object.defineProperty(C.prototype,"offset",{enumerable:!0,get:function(){if(C.isBuffer(this))return this.byteOffset}});function o(E){if(E>I)throw new RangeError('The value "'+E+'" is invalid for option "size"');const H=new Uint8Array(E);return Object.setPrototypeOf(H,C.prototype),H}function C(E,H,K){if(typeof E=="number"){if(typeof H=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return l(E)}return a(E,H,K)}C.poolSize=8192;function a(E,H,K){if(typeof E=="string")return c(E,H);if(ArrayBuffer.isView(E))return d(E);if(E==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof E);if(je(E,ArrayBuffer)||E&&je(E.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(je(E,SharedArrayBuffer)||E&&je(E.buffer,SharedArrayBuffer)))return h(E,H,K);if(typeof E=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const te=E.valueOf&&E.valueOf();if(te!=null&&te!==E)return C.from(te,H,K);const me=f(E);if(me)return me;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof E[Symbol.toPrimitive]=="function")return C.from(E[Symbol.toPrimitive]("string"),H,K);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof E)}C.from=function(E,H,K){return a(E,H,K)},Object.setPrototypeOf(C.prototype,Uint8Array.prototype),Object.setPrototypeOf(C,Uint8Array);function A(E){if(typeof E!="number")throw new TypeError('"size" argument must be of type number');if(E<0)throw new RangeError('The value "'+E+'" is invalid for option "size"')}function s(E,H,K){return A(E),E<=0?o(E):H!==void 0?typeof K=="string"?o(E).fill(H,K):o(E).fill(H):o(E)}C.alloc=function(E,H,K){return s(E,H,K)};function l(E){return A(E),o(E<0?0:m(E)|0)}C.allocUnsafe=function(E){return l(E)},C.allocUnsafeSlow=function(E){return l(E)};function c(E,H){if((typeof H!="string"||H==="")&&(H="utf8"),!C.isEncoding(H))throw new TypeError("Unknown encoding: "+H);const K=p(E,H)|0;let te=o(K);const me=te.write(E,H);return me!==K&&(te=te.slice(0,me)),te}function u(E){const H=E.length<0?0:m(E.length)|0,K=o(H);for(let te=0;te=I)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I.toString(16)+" bytes");return E|0}function b(E){return+E!=E&&(E=0),C.alloc(+E)}C.isBuffer=function(H){return H!=null&&H._isBuffer===!0&&H!==C.prototype},C.compare=function(H,K){if(je(H,Uint8Array)&&(H=C.from(H,H.offset,H.byteLength)),je(K,Uint8Array)&&(K=C.from(K,K.offset,K.byteLength)),!C.isBuffer(H)||!C.isBuffer(K))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(H===K)return 0;let te=H.length,me=K.length;for(let Re=0,Ee=Math.min(te,me);Reme.length?(C.isBuffer(Ee)||(Ee=C.from(Ee)),Ee.copy(me,Re)):Uint8Array.prototype.set.call(me,Ee,Re);else if(C.isBuffer(Ee))Ee.copy(me,Re);else throw new TypeError('"list" argument must be an Array of Buffers');Re+=Ee.length}return me};function p(E,H){if(C.isBuffer(E))return E.length;if(ArrayBuffer.isView(E)||je(E,ArrayBuffer))return E.byteLength;if(typeof E!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof E);const K=E.length,te=arguments.length>2&&arguments[2]===!0;if(!te&&K===0)return 0;let me=!1;for(;;)switch(H){case"ascii":case"latin1":case"binary":return K;case"utf8":case"utf-8":return ke(E).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return K*2;case"hex":return K>>>1;case"base64":return it(E).length;default:if(me)return te?-1:ke(E).length;H=(""+H).toLowerCase(),me=!0}}C.byteLength=p;function y(E,H,K){let te=!1;if((H===void 0||H<0)&&(H=0),H>this.length||((K===void 0||K>this.length)&&(K=this.length),K<=0)||(K>>>=0,H>>>=0,K<=H))return"";for(E||(E="utf8");;)switch(E){case"hex":return M(this,H,K);case"utf8":case"utf-8":return V(this,H,K);case"ascii":return Y(this,H,K);case"latin1":case"binary":return x(this,H,K);case"base64":return W(this,H,K);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return F(this,H,K);default:if(te)throw new TypeError("Unknown encoding: "+E);E=(E+"").toLowerCase(),te=!0}}C.prototype._isBuffer=!0;function Z(E,H,K){const te=E[H];E[H]=E[K],E[K]=te}C.prototype.swap16=function(){const H=this.length;if(H%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let K=0;KK&&(H+=" ... "),""},n&&(C.prototype[n]=C.prototype.inspect),C.prototype.compare=function(H,K,te,me,Re){if(je(H,Uint8Array)&&(H=C.from(H,H.offset,H.byteLength)),!C.isBuffer(H))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof H);if(K===void 0&&(K=0),te===void 0&&(te=H?H.length:0),me===void 0&&(me=0),Re===void 0&&(Re=this.length),K<0||te>H.length||me<0||Re>this.length)throw new RangeError("out of range index");if(me>=Re&&K>=te)return 0;if(me>=Re)return-1;if(K>=te)return 1;if(K>>>=0,te>>>=0,me>>>=0,Re>>>=0,this===H)return 0;let Ee=Re-me,nt=te-K;const wt=Math.min(Ee,nt),kt=this.slice(me,Re),yt=H.slice(K,te);for(let Pt=0;Pt2147483647?K=2147483647:K<-2147483648&&(K=-2147483648),K=+K,He(K)&&(K=me?0:E.length-1),K<0&&(K=E.length+K),K>=E.length){if(me)return-1;K=E.length-1}else if(K<0)if(me)K=0;else return-1;if(typeof H=="string"&&(H=C.from(H,te)),C.isBuffer(H))return H.length===0?-1:G(E,H,K,te,me);if(typeof H=="number")return H=H&255,typeof Uint8Array.prototype.indexOf=="function"?me?Uint8Array.prototype.indexOf.call(E,H,K):Uint8Array.prototype.lastIndexOf.call(E,H,K):G(E,[H],K,te,me);throw new TypeError("val must be string, number or Buffer")}function G(E,H,K,te,me){let Re=1,Ee=E.length,nt=H.length;if(te!==void 0&&(te=String(te).toLowerCase(),te==="ucs2"||te==="ucs-2"||te==="utf16le"||te==="utf-16le")){if(E.length<2||H.length<2)return-1;Re=2,Ee/=2,nt/=2,K/=2}function wt(yt,Pt){return Re===1?yt[Pt]:yt.readUInt16BE(Pt*Re)}let kt;if(me){let yt=-1;for(kt=K;ktEe&&(K=Ee-nt),kt=K;kt>=0;kt--){let yt=!0;for(let Pt=0;Ptme&&(te=me)):te=me;const Re=H.length;te>Re/2&&(te=Re/2);let Ee;for(Ee=0;Ee>>0,isFinite(te)?(te=te>>>0,me===void 0&&(me="utf8")):(me=te,te=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const Re=this.length-K;if((te===void 0||te>Re)&&(te=Re),H.length>0&&(te<0||K<0)||K>this.length)throw new RangeError("Attempt to write outside buffer bounds");me||(me="utf8");let Ee=!1;for(;;)switch(me){case"hex":return B(this,H,K,te);case"utf8":case"utf-8":return S(this,H,K,te);case"ascii":case"latin1":case"binary":return R(this,H,K,te);case"base64":return w(this,H,K,te);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,H,K,te);default:if(Ee)throw new TypeError("Unknown encoding: "+me);me=(""+me).toLowerCase(),Ee=!0}},C.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function W(E,H,K){return H===0&&K===E.length?g.fromByteArray(E):g.fromByteArray(E.slice(H,K))}function V(E,H,K){K=Math.min(E.length,K);const te=[];let me=H;for(;me239?4:Re>223?3:Re>191?2:1;if(me+nt<=K){let wt,kt,yt,Pt;switch(nt){case 1:Re<128&&(Ee=Re);break;case 2:wt=E[me+1],(wt&192)===128&&(Pt=(Re&31)<<6|wt&63,Pt>127&&(Ee=Pt));break;case 3:wt=E[me+1],kt=E[me+2],(wt&192)===128&&(kt&192)===128&&(Pt=(Re&15)<<12|(wt&63)<<6|kt&63,Pt>2047&&(Pt<55296||Pt>57343)&&(Ee=Pt));break;case 4:wt=E[me+1],kt=E[me+2],yt=E[me+3],(wt&192)===128&&(kt&192)===128&&(yt&192)===128&&(Pt=(Re&15)<<18|(wt&63)<<12|(kt&63)<<6|yt&63,Pt>65535&&Pt<1114112&&(Ee=Pt))}}Ee===null?(Ee=65533,nt=1):Ee>65535&&(Ee-=65536,te.push(Ee>>>10&1023|55296),Ee=56320|Ee&1023),te.push(Ee),me+=nt}return N(te)}const X=4096;function N(E){const H=E.length;if(H<=X)return String.fromCharCode.apply(String,E);let K="",te=0;for(;tete)&&(K=te);let me="";for(let Re=H;Rete&&(H=te),K<0?(K+=te,K<0&&(K=0)):K>te&&(K=te),KK)throw new RangeError("Trying to access beyond buffer length")}C.prototype.readUintLE=C.prototype.readUIntLE=function(H,K,te){H=H>>>0,K=K>>>0,te||$(H,K,this.length);let me=this[H],Re=1,Ee=0;for(;++Ee>>0,K=K>>>0,te||$(H,K,this.length);let me=this[H+--K],Re=1;for(;K>0&&(Re*=256);)me+=this[H+--K]*Re;return me},C.prototype.readUint8=C.prototype.readUInt8=function(H,K){return H=H>>>0,K||$(H,1,this.length),this[H]},C.prototype.readUint16LE=C.prototype.readUInt16LE=function(H,K){return H=H>>>0,K||$(H,2,this.length),this[H]|this[H+1]<<8},C.prototype.readUint16BE=C.prototype.readUInt16BE=function(H,K){return H=H>>>0,K||$(H,2,this.length),this[H]<<8|this[H+1]},C.prototype.readUint32LE=C.prototype.readUInt32LE=function(H,K){return H=H>>>0,K||$(H,4,this.length),(this[H]|this[H+1]<<8|this[H+2]<<16)+this[H+3]*16777216},C.prototype.readUint32BE=C.prototype.readUInt32BE=function(H,K){return H=H>>>0,K||$(H,4,this.length),this[H]*16777216+(this[H+1]<<16|this[H+2]<<8|this[H+3])},C.prototype.readBigUInt64LE=Ze(function(H){H=H>>>0,ye(H,"offset");const K=this[H],te=this[H+7];(K===void 0||te===void 0)&&ue(H,this.length-8);const me=K+this[++H]*2**8+this[++H]*2**16+this[++H]*2**24,Re=this[++H]+this[++H]*2**8+this[++H]*2**16+te*2**24;return BigInt(me)+(BigInt(Re)<>>0,ye(H,"offset");const K=this[H],te=this[H+7];(K===void 0||te===void 0)&&ue(H,this.length-8);const me=K*2**24+this[++H]*2**16+this[++H]*2**8+this[++H],Re=this[++H]*2**24+this[++H]*2**16+this[++H]*2**8+te;return(BigInt(me)<>>0,K=K>>>0,te||$(H,K,this.length);let me=this[H],Re=1,Ee=0;for(;++Ee=Re&&(me-=Math.pow(2,8*K)),me},C.prototype.readIntBE=function(H,K,te){H=H>>>0,K=K>>>0,te||$(H,K,this.length);let me=K,Re=1,Ee=this[H+--me];for(;me>0&&(Re*=256);)Ee+=this[H+--me]*Re;return Re*=128,Ee>=Re&&(Ee-=Math.pow(2,8*K)),Ee},C.prototype.readInt8=function(H,K){return H=H>>>0,K||$(H,1,this.length),this[H]&128?(255-this[H]+1)*-1:this[H]},C.prototype.readInt16LE=function(H,K){H=H>>>0,K||$(H,2,this.length);const te=this[H]|this[H+1]<<8;return te&32768?te|4294901760:te},C.prototype.readInt16BE=function(H,K){H=H>>>0,K||$(H,2,this.length);const te=this[H+1]|this[H]<<8;return te&32768?te|4294901760:te},C.prototype.readInt32LE=function(H,K){return H=H>>>0,K||$(H,4,this.length),this[H]|this[H+1]<<8|this[H+2]<<16|this[H+3]<<24},C.prototype.readInt32BE=function(H,K){return H=H>>>0,K||$(H,4,this.length),this[H]<<24|this[H+1]<<16|this[H+2]<<8|this[H+3]},C.prototype.readBigInt64LE=Ze(function(H){H=H>>>0,ye(H,"offset");const K=this[H],te=this[H+7];(K===void 0||te===void 0)&&ue(H,this.length-8);const me=this[H+4]+this[H+5]*2**8+this[H+6]*2**16+(te<<24);return(BigInt(me)<>>0,ye(H,"offset");const K=this[H],te=this[H+7];(K===void 0||te===void 0)&&ue(H,this.length-8);const me=(K<<24)+this[++H]*2**16+this[++H]*2**8+this[++H];return(BigInt(me)<>>0,K||$(H,4,this.length),i.read(this,H,!0,23,4)},C.prototype.readFloatBE=function(H,K){return H=H>>>0,K||$(H,4,this.length),i.read(this,H,!1,23,4)},C.prototype.readDoubleLE=function(H,K){return H=H>>>0,K||$(H,8,this.length),i.read(this,H,!0,52,8)},C.prototype.readDoubleBE=function(H,K){return H=H>>>0,K||$(H,8,this.length),i.read(this,H,!1,52,8)};function Q(E,H,K,te,me,Re){if(!C.isBuffer(E))throw new TypeError('"buffer" argument must be a Buffer instance');if(H>me||HE.length)throw new RangeError("Index out of range")}C.prototype.writeUintLE=C.prototype.writeUIntLE=function(H,K,te,me){if(H=+H,K=K>>>0,te=te>>>0,!me){const nt=Math.pow(2,8*te)-1;Q(this,H,K,te,nt,0)}let Re=1,Ee=0;for(this[K]=H&255;++Ee>>0,te=te>>>0,!me){const nt=Math.pow(2,8*te)-1;Q(this,H,K,te,nt,0)}let Re=te-1,Ee=1;for(this[K+Re]=H&255;--Re>=0&&(Ee*=256);)this[K+Re]=H/Ee&255;return K+te},C.prototype.writeUint8=C.prototype.writeUInt8=function(H,K,te){return H=+H,K=K>>>0,te||Q(this,H,K,1,255,0),this[K]=H&255,K+1},C.prototype.writeUint16LE=C.prototype.writeUInt16LE=function(H,K,te){return H=+H,K=K>>>0,te||Q(this,H,K,2,65535,0),this[K]=H&255,this[K+1]=H>>>8,K+2},C.prototype.writeUint16BE=C.prototype.writeUInt16BE=function(H,K,te){return H=+H,K=K>>>0,te||Q(this,H,K,2,65535,0),this[K]=H>>>8,this[K+1]=H&255,K+2},C.prototype.writeUint32LE=C.prototype.writeUInt32LE=function(H,K,te){return H=+H,K=K>>>0,te||Q(this,H,K,4,4294967295,0),this[K+3]=H>>>24,this[K+2]=H>>>16,this[K+1]=H>>>8,this[K]=H&255,K+4},C.prototype.writeUint32BE=C.prototype.writeUInt32BE=function(H,K,te){return H=+H,K=K>>>0,te||Q(this,H,K,4,4294967295,0),this[K]=H>>>24,this[K+1]=H>>>16,this[K+2]=H>>>8,this[K+3]=H&255,K+4};function U(E,H,K,te,me){ie(H,te,me,E,K,7);let Re=Number(H&BigInt(4294967295));E[K++]=Re,Re=Re>>8,E[K++]=Re,Re=Re>>8,E[K++]=Re,Re=Re>>8,E[K++]=Re;let Ee=Number(H>>BigInt(32)&BigInt(4294967295));return E[K++]=Ee,Ee=Ee>>8,E[K++]=Ee,Ee=Ee>>8,E[K++]=Ee,Ee=Ee>>8,E[K++]=Ee,K}function j(E,H,K,te,me){ie(H,te,me,E,K,7);let Re=Number(H&BigInt(4294967295));E[K+7]=Re,Re=Re>>8,E[K+6]=Re,Re=Re>>8,E[K+5]=Re,Re=Re>>8,E[K+4]=Re;let Ee=Number(H>>BigInt(32)&BigInt(4294967295));return E[K+3]=Ee,Ee=Ee>>8,E[K+2]=Ee,Ee=Ee>>8,E[K+1]=Ee,Ee=Ee>>8,E[K]=Ee,K+8}C.prototype.writeBigUInt64LE=Ze(function(H,K=0){return U(this,H,K,BigInt(0),BigInt("0xffffffffffffffff"))}),C.prototype.writeBigUInt64BE=Ze(function(H,K=0){return j(this,H,K,BigInt(0),BigInt("0xffffffffffffffff"))}),C.prototype.writeIntLE=function(H,K,te,me){if(H=+H,K=K>>>0,!me){const wt=Math.pow(2,8*te-1);Q(this,H,K,te,wt-1,-wt)}let Re=0,Ee=1,nt=0;for(this[K]=H&255;++Re>0)-nt&255;return K+te},C.prototype.writeIntBE=function(H,K,te,me){if(H=+H,K=K>>>0,!me){const wt=Math.pow(2,8*te-1);Q(this,H,K,te,wt-1,-wt)}let Re=te-1,Ee=1,nt=0;for(this[K+Re]=H&255;--Re>=0&&(Ee*=256);)H<0&&nt===0&&this[K+Re+1]!==0&&(nt=1),this[K+Re]=(H/Ee>>0)-nt&255;return K+te},C.prototype.writeInt8=function(H,K,te){return H=+H,K=K>>>0,te||Q(this,H,K,1,127,-128),H<0&&(H=255+H+1),this[K]=H&255,K+1},C.prototype.writeInt16LE=function(H,K,te){return H=+H,K=K>>>0,te||Q(this,H,K,2,32767,-32768),this[K]=H&255,this[K+1]=H>>>8,K+2},C.prototype.writeInt16BE=function(H,K,te){return H=+H,K=K>>>0,te||Q(this,H,K,2,32767,-32768),this[K]=H>>>8,this[K+1]=H&255,K+2},C.prototype.writeInt32LE=function(H,K,te){return H=+H,K=K>>>0,te||Q(this,H,K,4,2147483647,-2147483648),this[K]=H&255,this[K+1]=H>>>8,this[K+2]=H>>>16,this[K+3]=H>>>24,K+4},C.prototype.writeInt32BE=function(H,K,te){return H=+H,K=K>>>0,te||Q(this,H,K,4,2147483647,-2147483648),H<0&&(H=4294967295+H+1),this[K]=H>>>24,this[K+1]=H>>>16,this[K+2]=H>>>8,this[K+3]=H&255,K+4},C.prototype.writeBigInt64LE=Ze(function(H,K=0){return U(this,H,K,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),C.prototype.writeBigInt64BE=Ze(function(H,K=0){return j(this,H,K,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ee(E,H,K,te,me,Re){if(K+te>E.length)throw new RangeError("Index out of range");if(K<0)throw new RangeError("Index out of range")}function Ie(E,H,K,te,me){return H=+H,K=K>>>0,me||ee(E,H,K,4),i.write(E,H,K,te,23,4),K+4}C.prototype.writeFloatLE=function(H,K,te){return Ie(this,H,K,!0,te)},C.prototype.writeFloatBE=function(H,K,te){return Ie(this,H,K,!1,te)};function fe(E,H,K,te,me){return H=+H,K=K>>>0,me||ee(E,H,K,8),i.write(E,H,K,te,52,8),K+8}C.prototype.writeDoubleLE=function(H,K,te){return fe(this,H,K,!0,te)},C.prototype.writeDoubleBE=function(H,K,te){return fe(this,H,K,!1,te)},C.prototype.copy=function(H,K,te,me){if(!C.isBuffer(H))throw new TypeError("argument should be a Buffer");if(te||(te=0),!me&&me!==0&&(me=this.length),K>=H.length&&(K=H.length),K||(K=0),me>0&&me=this.length)throw new RangeError("Index out of range");if(me<0)throw new RangeError("sourceEnd out of bounds");me>this.length&&(me=this.length),H.length-K>>0,te=te===void 0?this.length:te>>>0,H||(H=0);let Re;if(typeof H=="number")for(Re=K;Re2**32?me=pe(String(K)):typeof K=="bigint"&&(me=String(K),(K>BigInt(2)**BigInt(32)||K<-(BigInt(2)**BigInt(32)))&&(me=pe(me)),me+="n"),te+=` It must be ${H}. Received ${me}`,te},RangeError);function pe(E){let H="",K=E.length;const te=E[0]==="-"?1:0;for(;K>=te+4;K-=3)H=`_${E.slice(K-3,K)}${H}`;return`${E.slice(0,K)}${H}`}function ae(E,H,K){ye(H,"offset"),(E[H]===void 0||E[H+K]===void 0)&&ue(H,E.length-(K+1))}function ie(E,H,K,te,me,Re){if(E>K||E3?H===0||H===BigInt(0)?nt=`>= 0${Ee} and < 2${Ee} ** ${(Re+1)*8}${Ee}`:nt=`>= -(2${Ee} ** ${(Re+1)*8-1}${Ee}) and < 2 ** ${(Re+1)*8-1}${Ee}`:nt=`>= ${H}${Ee} and <= ${K}${Ee}`,new Ve.ERR_OUT_OF_RANGE("value",nt,E)}ae(te,me,Re)}function ye(E,H){if(typeof E!="number")throw new Ve.ERR_INVALID_ARG_TYPE(H,"number",E)}function ue(E,H,K){throw Math.floor(E)!==E?(ye(E,K),new Ve.ERR_OUT_OF_RANGE(K||"offset","an integer",E)):H<0?new Ve.ERR_BUFFER_OUT_OF_BOUNDS:new Ve.ERR_OUT_OF_RANGE(K||"offset",`>= ${K?1:0} and <= ${H}`,E)}const Ye=/[^+/0-9A-Za-z-_]/g;function Be(E){if(E=E.split("=")[0],E=E.trim().replace(Ye,""),E.length<2)return"";for(;E.length%4!==0;)E=E+"=";return E}function ke(E,H){H=H||1/0;let K;const te=E.length;let me=null;const Re=[];for(let Ee=0;Ee55295&&K<57344){if(!me){if(K>56319){(H-=3)>-1&&Re.push(239,191,189);continue}else if(Ee+1===te){(H-=3)>-1&&Re.push(239,191,189);continue}me=K;continue}if(K<56320){(H-=3)>-1&&Re.push(239,191,189),me=K;continue}K=(me-55296<<10|K-56320)+65536}else me&&(H-=3)>-1&&Re.push(239,191,189);if(me=null,K<128){if((H-=1)<0)break;Re.push(K)}else if(K<2048){if((H-=2)<0)break;Re.push(K>>6|192,K&63|128)}else if(K<65536){if((H-=3)<0)break;Re.push(K>>12|224,K>>6&63|128,K&63|128)}else if(K<1114112){if((H-=4)<0)break;Re.push(K>>18|240,K>>12&63|128,K>>6&63|128,K&63|128)}else throw new Error("Invalid code point")}return Re}function _e(E){const H=[];for(let K=0;K>8,me=K%256,Re.push(me),Re.push(te);return Re}function it(E){return g.toByteArray(Be(E))}function lt(E,H,K,te){let me;for(me=0;me=H.length||me>=E.length);++me)H[me+K]=E[me];return me}function je(E,H){return E instanceof H||E!=null&&E.constructor!=null&&E.constructor.name!=null&&E.constructor.name===H.name}function He(E){return E!==E}const Ce=function(){const E="0123456789abcdef",H=new Array(256);for(let K=0;K<16;++K){const te=K*16;for(let me=0;me<16;++me)H[te+me]=E[K]+E[me]}return H}();function Ze(E){return typeof BigInt>"u"?Te:E}function Te(){throw new Error("BigInt not supported")}})(wb);const eU=typeof window<"u"?window:typeof self<"u"?self:{fetch:void 0};let XDe=class{async getBufferFromResponse(g){if(typeof g.buffer=="function")return g.buffer();if(typeof g.arrayBuffer=="function"){const i=await g.arrayBuffer();return wb.Buffer.from(i)}else throw new TypeError("invalid HTTP response object, has no buffer method, and no arrayBuffer method")}constructor(g,i={}){this.baseOverrides={},this.url=g;const n=i.fetch||eU.fetch&&eU.fetch.bind(eU);if(!n)throw new TypeError("no fetch function supplied, and none found in global environment");i.overrides&&(this.baseOverrides=i.overrides),this.fetchImplementation=n}async fetch(g,i){let n;try{n=await this.fetchImplementation(g,i)}catch(I){if(`${I}`.includes("Failed to fetch"))console.warn(`generic-filehandle: refetching ${g} to attempt to work around chrome CORS header caching bug`),n=await this.fetchImplementation(g,{...i,cache:"reload"});else throw I}return n}async read(g,i=0,n,I=0,r={}){const{headers:o={},signal:C,overrides:a={}}=r;n<1/0?o.range=`bytes=${I}-${I+n}`:n===1/0&&I!==0&&(o.range=`bytes=${I}-`);const A={...this.baseOverrides,...a,headers:{...o,...a.headers,...this.baseOverrides.headers},method:"GET",redirect:"follow",mode:"cors",signal:C},s=await this.fetch(this.url,A);if(!s.ok)throw new Error(`HTTP ${s.status} ${s.statusText} ${this.url}`);if(s.status===200&&I===0||s.status===206){const l=await this.getBufferFromResponse(s),c=l.copy(g,i,0,Math.min(n,l.length)),u=s.headers.get("content-range"),d=/\/(\d+)$/.exec(u||"");return d&&d[1]&&(this._stat={size:parseInt(d[1],10)}),{bytesRead:c,buffer:g}}throw s.status===200?new Error("${this.url} fetch returned status 200, expected 206"):new Error(`HTTP ${s.status} fetching ${this.url}`)}async readFile(g={}){let i,n;typeof g=="string"?(i=g,n={}):(i=g.encoding,n=g,delete n.encoding);const{headers:I={},signal:r,overrides:o={}}=n,C={headers:I,method:"GET",redirect:"follow",mode:"cors",signal:r,...this.baseOverrides,...o},a=await this.fetch(this.url,C);if(!a)throw new Error("generic-filehandle failed to fetch");if(a.status!==200)throw Object.assign(new Error(`HTTP ${a.status} fetching ${this.url}`),{status:a.status});if(i==="utf8")return a.text();if(i)throw new Error(`unsupported encoding: ${i}`);return this.getBufferFromResponse(a)}async stat(){if(!this._stat){const g=wb.Buffer.allocUnsafe(10);if(await this.read(g,0,10,0),!this._stat)throw new Error(`unable to determine size of file at ${this.url}`)}return this._stat}async close(){}};var p1t=Object.defineProperty,b1t=(e,g,i)=>g in e?p1t(e,g,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[g]=i,y1t=(e,g,i)=>(b1t(e,typeof g!="symbol"?g+"":g,i),i);const jx=6,Z1t=130,G1t=600,jZe=600,kK=10,TDe=.3,v1t=0,B1t="gray",St=e=>{let g=Gb(e);return g||(g=Gb(B1t)),Uxe([g.rgb().r/255,g.rgb().g/255,g.rgb().b/255])},er=0;function Si(e,g,i,n,I){const r=Math.max(Math.min(g,e),0),o=I??er,C=(n-i)/360*Math.PI*2-o*2;return-(i/360*Math.PI*2+r/g*C)-Math.PI/2-o}function Ig(e,g,i,n,I,r,o){return{x:n+i*Math.cos(Si(e,g,r,o)),y:I+i*Math.sin(Si(e,g,r,o))}}function bf(e,g,i,n){return i<=e?Math.atan((g-n)/(e-i)):Math.atan((g-n)/(e-i))-Math.PI}function w1t(e,g,i,n){return(Math.atan2(-(g-n),e-i)/Math.PI*180+270)%360}function S1t(e,g,i){var n,I,r,o,C;const a=i.spec();if(!a.width||!a.height){console.warn("Size of a track is not properly determined, so visual mark cannot be rendered");return}const A=i.data(),[s,l]=e.dimensions,c=i.getChannelScale("x").invert(s)-i.getChannelScale("x").invert(0),u=a.layout==="circular",d=(n=a.innerRadius)!=null?n:220,h=(I=a.outerRadius)!=null?I:300,f=(r=a.startAngle)!=null?r:0,m=(o=a.endAngle)!=null?o:360,b=h-d,p=s/2,y=l/2,Z=(C=i.getChannelDomainArray("row"))!=null?C:["___SINGLE_ROW___"],v=l/Z.length;Z.forEach(G=>{const B=i.encodedValue("row",G);A.filter(S=>!tn(S,a.row)||tn(S,a.row)===G).forEach(S=>{const R=i.encodedPIXIProperty("x-center",S),w=i.encodedPIXIProperty("y-center",S),T=i.encodedPIXIProperty("color",S),W=i.encodedPIXIProperty("p-size",S),V=i.encodedPIXIProperty("strokeWidth",S),X=i.encodedPIXIProperty("stroke",S),N=i.encodedPIXIProperty("opacity",S),Y=i.markVisibility(S,{width:W,zoomLevel:c}),x=Math.min(Y,N);if(!(W<=.1||x===0||R+W<0||R-W>s))if(g.lineStyle(V,St(X),x,1),u){const M=h-(B+v-w)/l*b,F=Ig(R,s,M,p,y,f,m);g.beginFill(St(T),x),g.drawCircle(F.x,F.y,W),i.getMouseEventModel().addPointBasedEvent(S,[F.x,F.y,W])}else g.beginFill(St(T),x),g.drawCircle(R,B+v-w,W),i.getMouseEventModel().addPointBasedEvent(S,[R,B+v-w,W])})})}function R1t(e,g,i){const n=e.visualPropertyByChannel("xe",i),I=e.visualPropertyByChannel("x",i),r=e.visualPropertyByChannel("size",i);switch(g){case"x-center":return n?(n+I)/2:I;case"y-center":{const o=e.visualPropertyByChannel("ye",i),C=e.visualPropertyByChannel("y",i);return o?(o+C)/2:C}case"p-size":return n&&e.spec().stretch?(n-I)/2:r;default:return}}function V1t(e,g,i,n){var I,r,o,C,a,A;const s=g.spec();if(!s.width||!s.height){console.warn("Size of a track is not properly determined, so visual mark cannot be rendered");return}const l=g.data(),c=s.layout==="circular",u=(I=s.innerRadius)!=null?I:220,d=(r=s.outerRadius)!=null?r:300,h=(o=s.startAngle)!=null?o:0,f=(C=s.endAngle)!=null?C:360,m=d-u,b=i/2,p=n/2,y=(a=g.getChannelDomainArray("row"))!=null?a:["___SINGLE_ROW___"],Z=n/y.length,v=(A=g.getChannelDomainArray("color"))!=null?A:["___SINGLE_COLOR___"];y.forEach(G=>{const B=g.encodedValue("row",G);v.forEach(S=>{l.filter(R=>(!tn(R,s.row)||tn(R,s.row)===G)&&(!tn(R,s.color)||tn(R,s.color)===S)).sort((R,w)=>tn(R,s.x)-tn(w,s.x)).forEach((R,w)=>{const T=g.encodedPIXIProperty("x",R),W=g.encodedPIXIProperty("y",R),V=g.encodedPIXIProperty("size",R),X=g.encodedPIXIProperty("color",R),N=g.encodedPIXIProperty("opacity",R);if(e.lineStyle(V,St(X),N,.5),c){const Y=d-(B+Z-W)/n*m,x=Ig(T,i,Y,b,p,h,f);w===0?e.moveTo(x.x,x.y):e.lineTo(x.x,x.y),g.getMouseEventModel().addPointBasedEvent(R,[x.x,x.y,1])}else w===0?e.moveTo(T,B+Z-W):e.lineTo(T,B+Z-W),g.getMouseEventModel().addPointBasedEvent(R,[T,B+Z-W,1])})})})}function W1t(e,g,i){var n,I,r,o,C,a,A;const s=i.spec();if(!s.width||!s.height){console.warn("Size of a track is not properly determined, so visual mark cannot be rendered");return}const l=i.data(),[c,u]=e.dimensions,d=e.tilesetInfo.tile_size,h=i.getChannelScale("x").invert(c)-i.getChannelScale("x").invert(0),f=s.layout==="circular",m=(n=s.innerRadius)!=null?n:220,b=(I=s.outerRadius)!=null?I:300,p=(r=s.startAngle)!=null?r:0,y=(o=s.endAngle)!=null?o:360,Z=b-m,v=c/2,G=u/2,B=i.getChannelScale("x");let S;if(g.tileData.tilePos){const{tileX:N,tileWidth:Y}=e.getTilePosAndDimensions(g.tileData.zoomLevel,g.tileData.tilePos,d);S=B(N+Y/d)-B(N)}const R=(C=i.getChannelDomainArray("row"))!=null?C:["___SINGLE_ROW___"],w=u/R.length,T=!pt(s.row)||pt(s.row)&&typeof s.row.clip>"u"||s.row.clip,W=pt(s.y)?(a=s.y)==null?void 0:a.baseline:void 0,V=(A=i.encodedValue("y",W))!=null?A:0,X=g.graphics;if(mz(s)){const N=i.getGenomicChannel();if(!N||!N.field){console.warn("Genomic field is not provided in the specification");return}const Y=oz(l,F=>F[N.field]),x=[...Y.keys()],M=pt(s.y)&&s.y.flip||s.flipY;x.forEach(F=>{var $;let Q=0;($=Y.get(F))==null||$.forEach(U=>{const j=i.encodedPIXIProperty("color",U),ee=i.encodedPIXIProperty("stroke",U),Ie=i.encodedPIXIProperty("strokeWidth",U),fe=i.encodedPIXIProperty("opacity",U),Ve=i.encodedPIXIProperty("y",U),oe=i.encodedPIXIProperty("width",U,{tileUnitWidth:S}),pe=i.encodedPIXIProperty("x-start",U,{markWidth:oe}),ae=pe+oe,ie=i.markVisibility(U,{width:oe,zoomLevel:h}),ye=Math.min(ie,fe);if(ye===0||oe<=0||M&&Ve-w>=0||!M&&Ve<=0)return;X.lineStyle(Ie,St(ee),ye,0);let ue=[];const Ye=M?w-Ve:Ve;if(f){const Be=M?Q:w-Q,ke=b-Be/u*Z,_e=M?Ye+Q:w-Ve-Q,Pe=b-_e/u*Z,it=Ig(pe,c,Pe,v,G,p,y),lt=Si(pe,c,p,y),je=Si(pe+oe,c,p,y);X.beginFill(St(j),j==="none"?0:ye),X.moveTo(it.x,it.y),X.arc(v,G,Pe,lt,je,!0),X.arc(v,G,ke,je,lt,!1),ue=Array.from(X.currentPath.points),X.closePath()}else{X.beginFill(St(j),j==="none"?0:ye);const Be=M?Q:w-Ve-Q;X.drawRect(pe,Be,oe,Ye);const ke=Be+Ve;ue=[pe,Be,pe,ke,ae,ke,ae,Be]}i.getMouseEventModel().addPolygonBasedEvent(U,ue),Q+=Ye})})}else R.forEach(N=>{const Y=i.encodedValue("row",N);l.filter(x=>{const M=tn(x,s.row);return!M||M===N}).forEach(x=>{const M=i.encodedPIXIProperty("color",x),F=i.encodedPIXIProperty("stroke",x),$=i.encodedPIXIProperty("strokeWidth",x),Q=i.encodedPIXIProperty("opacity");let U=i.encodedPIXIProperty("y",x),j=i.encodedPIXIProperty("ye",x);typeof j<"u"&&U>j&&([U,j]=[j,U]);const ee=i.encodedPIXIProperty("width",x,{tileUnitWidth:S}),Ie=i.encodedPIXIProperty("x-start",x,{markWidth:ee}),fe=Ie+ee;let Ve;typeof j>"u"?(Ve=Y+w-V-U,j=Y+w-V,(pt(s.y)&&s.y.flip||s.flipY)&&(j=Ve,Ve=Y)):(Ve=Y+w-j,j=Y+w-U),T&&(Ve=Math.max(Y,Ve),Ve=Math.min(Ve,Y+w),j=Math.max(Y,j),j=Math.min(j,Y+w));const oe=i.markVisibility(x,{width:ee,zoomLevel:h}),pe=Math.min(oe,Q);if(pe===0||ee===0||j-Ve===0)return;X.lineStyle($,St(F),pe,0);let ae=[];if(f){const ie=b-Ve/u*Z,ye=b-j/u*Z,ue=Ig(Ie,c,ye,v,G,p,y),Ye=Si(Ie,c,p,y),Be=Si(Ie+ee,c,p,y);X.beginFill(St(M),M==="none"?0:pe),X.moveTo(ue.x,ue.y),X.arc(v,G,ye,Ye,Be,!0),X.arc(v,G,ie,Be,Ye,!1),ae=Array.from(X.currentPath.points),X.closePath()}else X.beginFill(St(M),M==="none"?0:pe),X.drawRect(Ie,Ve,ee,j-Ve),ae=[Ie,Ve,Ie,j,fe,j,fe,Ve];i.getMouseEventModel().addPolygonBasedEvent(x,ae)})})}function X1t(e,g,i,n){const I=e.visualPropertyByChannel("x",i),r=e.visualPropertyByChannel("xe",i),o=e.visualPropertyByChannel("size",i);switch(g){case"width":return o??(r?r-I:n?.tileUnitWidth);case"x-start":return n?.markWidth?r?(I+r-n?.markWidth)/2:I-n?.markWidth/2:void 0;default:return}}function T1t(e,g,i,n){var I,r,o,C,a,A;const s=n.spec(),l=n.data(),[c,u]=g.dimensions,d=s.layout==="circular",h=(I=s.innerRadius)!=null?I:220,f=(r=s.outerRadius)!=null?r:300,m=(o=s.startAngle)!=null?o:0,b=(C=s.endAngle)!=null?C:360,p=f-h,y=c/2,Z=u/2,v=g._xScale,G=(a=n.getChannelDomainArray("row"))!=null?a:["___SINGLE_ROW___"],B=u/G.length,S=(A=n.getChannelDomainArray("color"))!=null?A:["___SINGLE_COLOR___"],R=n.encodedPIXIProperty("opacity"),w=n.encodedPIXIProperty("strokeWidth"),T=n.encodedPIXIProperty("stroke"),W=i.graphics;if(mz(s)){const V=n.getGenomicChannel();if(!V||!V.field){console.warn("Genomic field is not provided in the specification");return}const X=oz(l,x=>x[V.field]),N=[...X.keys()];W.lineStyle(w,St(T),R,1);const Y={};S.forEach(x=>{const M=[],F=[];N.forEach((Q,U,j)=>{var ee,Ie;(Ie=(ee=X.get(Q))==null?void 0:ee.filter(fe=>tn(fe,s.color)===x))==null||Ie.forEach(fe=>{const Ve=+Q,oe=v(Ve),pe=F2([n.encodedPIXIProperty("y",fe),0]);typeof Y[Q]>"u"&&(Y[Q]=0);const ae=B-pe-Y[Q],ie=B-Y[Q];if(d){if(U===0){const ke=f-B/u*p,_e=Ig(oe,c,ke,y,Z,m,b);M.push([_e.x,_e.y]),F.push([_e.x,_e.y])}const ye=f-ae/u*p,ue=Ig(oe,c,ye,y,Z,m,b);M.push([ue.x,ue.y]);const Ye=f-ie/u*p,Be=Ig(oe,c,Ye,y,Z,m,b);if(F.push([Be.x,Be.y]),U===j.length-1){const ke=f-B/u*p,_e=Ig(oe,c,ke,y,Z,m,b);M.push([_e.x,_e.y]),F.push([_e.x,_e.y])}n.getMouseEventModel().addPointBasedEvent(fe,[Be.x,Be.y,1])}else U===0&&(M.push([oe,B]),F.push([oe,B])),M.push([oe,ae]),F.push([oe,ie]),U===j.length-1&&(M.push([oe,B]),F.push([oe,B])),n.getMouseEventModel().addPointBasedEvent(fe,[oe,ae,1]);Y[Q]+=pe})});const $=n.encodedValue("color",x);W.beginFill(St($),R),W.drawPolygon([...M.reduce((Q,U)=>Q.concat(U)),...F.reverse().reduce((Q,U)=>Q.concat(U))]),W.endFill()})}else G.forEach(V=>{const X=n.encodedValue("row",V);W.lineStyle(w,St(T),R,0),S.forEach(N=>{const Y=[],x=[],M=f-(X+B)/u*p;let F=0;l.filter(Q=>(typeof tn(Q,s.row)>"u"||tn(Q,s.row)===V)&&(typeof tn(Q,s.color)>"u"||tn(Q,s.color)===N)).sort((Q,U)=>n.encodedPIXIProperty("x",Q)-n.encodedPIXIProperty("x",U)).forEach((Q,U,j)=>{const ee=HK([F2([n.encodedPIXIProperty("y",Q),0]),B]),Ie=n.encodedPIXIProperty("x",Q);if(d){const fe=Ig(Ie,c,M,y,Z,m,b);Y.push([fe.x,fe.y]),U===0&&x.push(fe.x,fe.y);const Ve=f-(X+B-ee)/u*p,oe=Ig(Ie,c,Ve,y,Z,m,b);if(x.push(oe.x,oe.y),U===j.length-1){const pe=f-(X+B)/u*p,ae=Ig(Ie,c,pe,y,Z,m,b);x.push(ae.x,ae.y)}n.getMouseEventModel().addPointBasedEvent(Q,[oe.x,oe.y,1])}else U===0&&(x.push(Ie,X+B),F=Ie),x.push(Ie,X+B-ee),U===j.length-1&&(x.push(Ie,X+B),x.push(F,X+B)),n.getMouseEventModel().addPointBasedEvent(Q,[Ie,X+B-ee,1])}),d&&Y.length!==0&&x.push(...Y.reverse().reduce((Q,U)=>Q.concat(U)));const $=n.encodedValue("color",N);W.beginFill(St($),R),W.drawPolygon(x),W.endFill()})})}function H1t(e,g,i,n){var I,r,o,C,a,A;const s=n.spec(),l=n.data(),[c,u]=g.dimensions,d=s.layout==="circular",h=(I=s.innerRadius)!=null?I:220,f=(r=s.outerRadius)!=null?r:300,m=(o=s.startAngle)!=null?o:0,b=(C=s.endAngle)!=null?C:360,p=f-h,y=c/2,Z=u/2,v=g._xScale;let G;if(i.tileData.tilePos){const V=g.tilesetInfo.tile_size,{tileX:X,tileWidth:N}=g.getTilePosAndDimensions(i.tileData.zoomLevel,i.tileData.tilePos,V);G=v(X+N/V)-v(X)}const B=(a=n.getChannelDomainArray("row"))!=null?a:["___SINGLE_ROW___"],S=u/B.length,R=pt(s.row)&&s.row.padding?s.row.padding:0,w=(A=n.getChannelDomainArray("y"))!=null?A:["___SINGLE_Y_POSITION___"],T=S/w.length-R*2,W=i.graphics;l.forEach(V=>{var X;const N=n.encodedPIXIProperty("row",V)+R,Y=n.encodedPIXIProperty("x",V),x=n.encodedPIXIProperty("color",V),M=n.encodedPIXIProperty("stroke",V),F=n.encodedPIXIProperty("strokeWidth",V),$=n.encodedPIXIProperty("opacity",V),Q=n.encodedPIXIProperty("width",V,{markWidth:G}),U=n.encodedPIXIProperty("height",V,{markHeight:T}),j=n.encodedPIXIProperty("y",V),ee=n.markVisibility(V,{width:Q,zoomLevel:g._xScale.invert(c)-g._xScale.invert(0)}),Ie=Math.min(ee,$);if(Ie===0||U===0||Q<=1e-4)return;const[fe,Ve,oe,pe]=[Y,Y+Q,N+S-j-U/2,N+S-j+U/2],ae=(X=n.visualPropertyByChannel("size",V))!=null?X:void 0;W.lineStyle(F,St(M),Ie,.5);let ie=[];if(d){if(Ve<0||c{const w=g.encodedValue("row",R);c.filter(T=>!tn(T,l.row)||tn(T,l.row)===R).forEach(T=>{var W,V,X;const N=g.encodedPIXIProperty("x",T),Y=g.encodedPIXIProperty("xe",T),x=(W=g.encodedPIXIProperty("size",T))!=null?W:Y===void 0?S:Y-N,M=g.encodedPIXIProperty("y",T),F=g.encodedPIXIProperty("strokeWidth",T),$=g.encodedPIXIProperty("stroke",T),Q=g.encodedPIXIProperty("color",T),U=g.encodedPIXIProperty("opacity",T);let j=[];if(d){let ee=N||Y-x,Ie=Y||N+x,fe=(ee+Ie)/2;const Ve=f-(w+G-M)/n*p,oe=Ve-S/2,pe=Ve+S/2;if(((V=l.style)==null?void 0:V.align)==="right"&&!Y&&(ee-=x,Ie-=x,fe-=x),l.mark==="triangleLeft"){const ye=Ig(Ie,i,oe,y,Z,m,b),ue=Ig(ee,i,Ve,y,Z,m,b),Ye=Ig(Ie,i,pe,y,Z,m,b),Be=Ig(Ie,i,oe,y,Z,m,b);j=[ye.x,ye.y,ue.x,ue.y,Ye.x,Ye.y,Be.x,Be.y]}else if(l.mark==="triangleRight"){const ye=Ig(ee,i,oe,y,Z,m,b),ue=Ig(Ie,i,Ve,y,Z,m,b),Ye=Ig(ee,i,pe,y,Z,m,b),Be=Ig(ee,i,oe,y,Z,m,b);j=[ye.x,ye.y,ue.x,ue.y,Ye.x,Ye.y,Be.x,Be.y]}else if(l.mark==="triangleBottom"){ee=fe-x/2,Ie=fe+x/2;const ye=Ig(ee,i,pe,y,Z,m,b),ue=Ig(Ie,i,pe,y,Z,m,b),Ye=Ig(fe,i,oe,y,Z,m,b),Be=Ig(ee,i,pe,y,Z,m,b);j=[ye.x,ye.y,ue.x,ue.y,Ye.x,Ye.y,Be.x,Be.y]}const ae=g.markVisibility(T,{width:Ie-ee,zoomLevel:u}),ie=Math.min(ae,U);e.lineStyle(F,St($),Ie-ee>2?ie:0,0),e.beginFill(St(Q),ie),e.drawPolygon(j),e.endFill()}else{let ee=N||Y-x,Ie=Y||N+x,fe=ee+(Ie-ee)/2;const Ve=w+G-M,oe=w+G-M-S/2,pe=w+G-M+S/2;((X=l.style)==null?void 0:X.align)==="right"&&!Y&&(ee-=x,Ie-=x,fe-=x),j={triangleLeft:[Ie,oe,ee,Ve,Ie,pe,Ie,oe],triangleRight:[ee,oe,Ie,Ve,ee,pe,ee,oe],triangleBottom:[ee,oe,Ie,oe,fe,pe,ee,oe]}[l.mark];const ae=g.markVisibility(T,{width:Ie-ee,zoomLevel:u}),ie=Math.min(ae,U);e.lineStyle(F,St($),Ie-ee>2?ie:0,.5),e.beginFill(St(Q),ie),e.drawPolygon(j),e.endFill()}g.getMouseEventModel().addPolygonBasedEvent(T,j)})})}const hl={fontSize:"12px",fontFamily:"sans-serif",fontWeight:"normal",fill:"black",background:"white",lineJoin:"round",stroke:"#ffffff",strokeThickness:0};function Y1t(e,g,i,n){var I,r,o,C,a,A,s,l,c,u;const d=n.spec(),h=n.data(),[f,m]=g.dimensions,b=d.layout==="circular",p=(I=d.innerRadius)!=null?I:220,y=(r=d.outerRadius)!=null?r:300,Z=(o=d.startAngle)!=null?o:0,v=(C=d.endAngle)!=null?C:360,G=y-p,B=f/2,S=m/2,R=(a=n.getChannelDomainArray("row"))!=null?a:["___SINGLE_ROW___"],w=m/R.length,T=(s=(A=d.style)==null?void 0:A.dx)!=null?s:0,W=(c=(l=d.style)==null?void 0:l.dy)!=null?c:0,V=(u=d.style)!=null&&u.textAnchor?d.style.textAnchor:"middle";if(mz(d)){if(b)return;const X=i.graphics,N=n.getGenomicChannel();if(!N||!N.field){console.warn("Genomic field is not provided in the specification");return}const Y=oz(h,M=>M[N.field]);[...Y.keys()].forEach(M=>{var F;let $=0;(F=Y.get(M))==null||F.forEach(Q=>{var U,j,ee,Ie,fe,Ve,oe,pe;const ae=n.encodedPIXIProperty("text",Q),ie=n.encodedPIXIProperty("color",Q),ye=n.encodedPIXIProperty("x",Q)+T,ue=n.encodedPIXIProperty("xe",Q)+T,Ye=n.encodedPIXIProperty("x-center",Q)+T,Be=n.encodedPIXIProperty("y",Q)+W,ke=n.encodedPIXIProperty("size",Q),_e=n.encodedPIXIProperty("stroke",Q),Pe=n.encodedPIXIProperty("strokeWidth",Q),it=n.encodedPIXIProperty("opacity",Q);if(Ye<0||Ye>f||g.textsBeingUsed>1e3)return;const lt={...hl,fontSize:ke??((U=d.style)!=null&&U.textFontSize?`${(j=d.style)==null?void 0:j.textFontSize}px`:hl.fontSize),stroke:(Ie=_e??((ee=d.style)==null?void 0:ee.textStroke))!=null?Ie:hl.stroke,strokeThickness:(Ve=Pe??((fe=d.style)==null?void 0:fe.textStrokeWidth))!=null?Ve:hl.strokeThickness,fontWeight:(pe=(oe=d.style)==null?void 0:oe.textFontWeight)!=null?pe:hl.fontWeight},je=new e.libraries.PIXI.TextStyle(lt);let He;g.textGraphics.length>g.textsBeingUsed?(He=g.textGraphics[g.textsBeingUsed],He.style.fill=ie,He.visible=!0,He.text=ae,He.alpha=1):(He=new e.libraries.PIXI.Text(ae,{...lt,fill:ie}),g.textGraphics.push(He));const Ce=e.libraries.PIXI.TextMetrics.measureText(ae,je);g.textsBeingUsed++;const Ze=n.markVisibility(Q,{...Ce,zoomLevel:g._xScale.invert(f)-g._xScale.invert(0)}),Te=Math.min(Ze,it);if(!ae||Te===0){g.textsBeingUsed--,He.visible=!1;return}He.alpha=Te,He.resolution=8,He.updateText(),He.texture.baseTexture.scaleMode=e.libraries.PIXI.SCALE_MODES.LINEAR;const E=new e.libraries.PIXI.Sprite(He.texture);E.x=ye,E.y=w-Be-$,E.width=ue-ye,E.height=Be,X.addChild(E),$+=Be})})}else R.forEach(X=>{const N=i.graphics,Y=n.encodedValue("row",X);h.filter(x=>!tn(x,d.row)||tn(x,d.row)===X).forEach(x=>{var M,F,$,Q,U,j,ee,Ie;const fe=n.encodedPIXIProperty("text",x),Ve=n.encodedPIXIProperty("color",x),oe=n.encodedPIXIProperty("x-center",x)+T,pe=n.encodedPIXIProperty("y",x)+W,ae=n.encodedPIXIProperty("size",x),ie=n.encodedPIXIProperty("stroke",x),ye=n.encodedPIXIProperty("strokeWidth",x),ue=n.encodedPIXIProperty("opacity",x);if(oe<0||oe>f||g.textsBeingUsed>1e3)return;const Ye={...hl,fontSize:ae??((M=d.style)!=null&&M.textFontSize?`${(F=d.style)==null?void 0:F.textFontSize}px`:hl.fontSize),stroke:(Q=ie??(($=d.style)==null?void 0:$.textStroke))!=null?Q:hl.stroke,strokeThickness:(j=ye??((U=d.style)==null?void 0:U.textStrokeWidth))!=null?j:hl.strokeThickness,fontWeight:(Ie=(ee=d.style)==null?void 0:ee.textFontWeight)!=null?Ie:hl.fontWeight},Be=new e.libraries.PIXI.TextStyle(Ye);let ke;g.textGraphics.length>g.textsBeingUsed?(ke=g.textGraphics[g.textsBeingUsed],ke.style.fill=Ve,ke.visible=!0,ke.text=fe,ke.alpha=1):(ke=new e.libraries.PIXI.Text(fe,{...Ye,fill:Ve}),g.textGraphics.push(ke));const _e=e.libraries.PIXI.TextMetrics.measureText(fe,Be);g.textsBeingUsed++;const Pe=n.markVisibility(x,{..._e,zoomLevel:g._xScale.invert(f)-g._xScale.invert(0)}),it=Math.min(Pe,ue);if(!fe||it===0){g.textsBeingUsed--,ke.visible=!1;return}ke.alpha=it,ke.anchor.y=.5,ke.anchor.x=V==="middle"?.5:V==="start"?0:1;let lt=[];if(b){const je=y-(Y+w-pe)/m*G,He=Ig(oe,f,je,B,S,Z,v);ke.x=He.x,ke.y=He.y,ke.resolution=4;const Ce=_e.width/(2*je*Math.PI)*f;let[Ze,Te]=[oe-Ce/2,oe+Ce/2];if(Ze<0){const me=-Ze;Ze=0,Te+=me}else if(Te>f){const me=Te-f;Te=f,Ze-=me}const E=[],H=[],K=[];for(let me=Te;me>=Ze;me-=Ce/10){const Re=Ig(me,f,je,B,S,Z,v);E.push(new e.libraries.PIXI.Point(Re.x,Re.y));const Ee=Ig(me,f,je+_e.height/2,B,S,Z,v),nt=Ig(me,f,je-_e.height/2,B,S,Z,v);H.push(Ee.x,Ee.y),me===Te&&K.push(Ee.y,Ee.x),K.push(nt.y,nt.x)}ke.updateText();const te=new e.libraries.PIXI.SimpleRope(ke.texture,E);te.alpha=it,N.addChild(te),K.reverse(),lt=H.concat(K)}else{ke.position.x=oe,ke.position.y=Y+w-pe,N.addChild(ke);const{height:je,width:He}=_e,Ce=ke.position.y-je/2,Ze=Ce+je;let Te=0,E=0;V==="start"?(Te=oe,E=oe+He):V==="middle"?(Te=oe-He/2,E=oe+He/2):(Te=oe-He,E=oe),lt=[Te,Ce,Te,Ze,E,Ze,E,Ce]}n.getMouseEventModel().addPolygonBasedEvent(x,lt)})})}function K1t(e,g,i,n){var I,r,o,C,a,A,s,l;const c=n.spec(),u=n.data(),[d,h]=g.dimensions,f=c.layout==="circular",m=(I=c.innerRadius)!=null?I:220,b=(r=c.outerRadius)!=null?r:300,p=(o=c.startAngle)!=null?o:0,y=(C=c.endAngle)!=null?C:360,Z=b-m,v=d/2,G=h/2,B=(a=n.getChannelDomainArray("row"))!=null?a:["___SINGLE_ROW___"],S=h/B.length,R=(A=c.style)==null?void 0:A.dashed,w=(s=c.style)==null?void 0:s.linePattern,T=(l=c.style)==null?void 0:l.curve,W=i.graphics;B.forEach(V=>{const X=n.encodedValue("row",V);u.filter(N=>!tn(N,c.row)||tn(N,c.row)===V).forEach(N=>{const Y=n.encodedPIXIProperty("x",N),x=n.encodedPIXIProperty("xe",N),M=n.encodedPIXIProperty("y",N),F=n.encodedPIXIProperty("color",N),$=n.encodedPIXIProperty("strokeWidth",N),Q=n.encodedPIXIProperty("opacity",N),U=n.markVisibility(N,{width:x-Y,zoomLevel:g._xScale.invert(d)-g._xScale.invert(0)}),j=Math.min(U,Q);if(W.lineStyle($,St(F),j,.5),!x&&(!c.y||!("field"in c.y))){if(f)return;if(R){const[ee,Ie]=R;let fe=0;do W.moveTo(Y,fe),W.lineTo(Y,fe+ee),fe+=ee+Ie;while(fe{const X=i.encodedValue("row",V);d.filter(N=>!tn(N,u.row)||tn(N,u.row)===V).forEach(N=>{var Y,x,M,F,$;let Q=i.encodedPIXIProperty("x",N),U=i.encodedPIXIProperty("xe",N),j=i.encodedPIXIProperty("x1",N),ee=i.encodedPIXIProperty("x1e",N);const Ie=i.encodedPIXIProperty("y",N),fe=i.encodedPIXIProperty("ye",N),Ve=i.encodedPIXIProperty("stroke",N),oe=i.encodedPIXIProperty("strokeWidth",N),pe=i.encodedPIXIProperty("color",N),ae=i.encodedPIXIProperty("opacity",N);typeof U<"u"&&([Q,U]=[Q,U].sort((Be,ke)=>Be-ke)),typeof j<"u"&&typeof ee<"u"&&([j,ee]=[j,ee].sort((Be,ke)=>Be-ke));const ie=typeof U<"u"&&typeof j<"u"&&typeof ee<"u"&&Math.abs(Q-U)>.1&&Math.abs(j-ee)>.1;if(!ie&&U===void 0&&!Pr(u)){if(j===void 0&&ee===void 0)return;U=j!==void 0?j:ee}!ie&&Math.abs(Q-U)<=.1&&Math.abs(j-ee)<=.1&&(Q=(Q+U)/2,U=(j+ee)/2),e.lineStyle(oe,St(Ve),ae,.5);const ye=pt(u.y)&&u.y.flip||u.flipY,ue=(Y=u.baselineY)!=null?Y:X+(ye?0:R);let Ye=[];if(ie){e.beginFill(St(pe==="none"?"white":pe),pe==="none"?0:ae);let[Be,ke,_e,Pe]=[Q,U,j,ee];if([Be,ke,_e,Pe]=[Be,ke,_e,Pe].sort((it,lt)=>it-lt),Be>h||Pe<0||Math.abs(Pe-Be)<.5)return;if(m){if(Be<0||Pe>h)return;const it=p-X/f*v,lt=Ig(Be,h,it,G,B,y,Z),je=Ig(ke,h,it,G,B,y,Z),He=Ig(_e,h,it,G,B,y,Z),Ce=Ig(Pe,h,it,G,B,y,Z);e.moveTo(lt.x,lt.y),e.bezierCurveTo(G,B,G,B,Ce.x,Ce.y),e.arc(G,B,p,bf(Ce.x,Ce.y,G,B),bf(He.x,He.y,G,B),!1),e.bezierCurveTo(G,B,G,B,je.x,je.y),e.arc(G,B,p,bf(je.x,je.y,G,B),bf(lt.x,lt.y,G,B),!1),Ye=Array.from(e.currentPath.points),e.endFill()}else e.moveTo(Be,ue),!((x=u.style)!=null&&x.linkStyle)||((M=u.style)==null?void 0:M.linkStyle)==="circular"?(e.arc((Be+Pe)/2,ue,(Pe-Be)/2,-Math.PI,Math.PI,!1),e.arc((ke+_e)/2,ue,(_e-ke)/2,Math.PI,-Math.PI,!0),Ye=Array.from(e.currentPath.points),e.closePath()):(e.lineTo(_e,X+R),e.bezierCurveTo(_e+(ke-_e)/3,X+R-(ke-_e)/2,_e+(ke-_e)/3*2,X+R-(ke-_e)/2,ke,X+R),e.lineTo(Pe,X+R),e.bezierCurveTo(Be+(Pe-Be)/3*2,X+R-(Pe-Be)/2,Be+(Pe-Be)/3,X+R-(Pe-Be)/2,Be,X+R),Ye=Array.from(e.currentPath.points),e.endFill());i.getMouseEventModel().addPolygonBasedEvent(N,Ye)}else{const Be=(Q+U)/2;if(e.beginFill(St("white"),0),m){if(Q<0||U>h)return;if(((F=u.style)==null?void 0:F.linkStyle)==="straight"){const ke=p-X/f*v,_e=Ig(Q,h,ke,G,B,y,Z),Pe=Ig(U,h,ke,G,B,y,Z),it=_e.x,lt=_e.y,je=Pe.x,He=Pe.y;e.moveTo(it,lt),e.lineTo(je,He);const Ce=100;Ye=Array.from({length:Ce},(Te,E)=>({x:(je-it)/(Ce-1)*E+it,y:(He-lt)/(Ce-1)*E+lt})).flatMap(Te=>[Te.x,Te.y])}else{const ke=p-X/f*v,_e=Ig(Q,h,ke,G,B,y,Z),Pe=Ig(U,h,ke,G,B,y,Z),it=_e.x,lt=_e.y,je=_e.x,He=_e.y,Ce=h/2,Ze=f/2,Te=Pe.x,E=Pe.y;e.moveTo(it,lt);const H=new zn(it,lt,je,He,Ce,Ze,Te,E);H.getLUT(14).forEach(me=>e.lineTo(me.x,me.y)),Ye=H.getLUT(1e3).flatMap(me=>[me.x,me.y])}}else if((($=u.style)==null?void 0:$.linkStyle)==="elliptical"){if(!(0<=Q&&Q<=h)&&!(0<=U&&U<=h))return;const ke=[],_e=pt(u.y);for(let Pe=0;Pe<=T;Pe++){const it=Math.PI*(Pe/T),lt=(U-Q)/2*Math.cos(it)+(Q+U)/2;let je=ue-Ie*Math.sin(it)*(_e?1:Math.min(U-Q+h*w,h)/h)*(ye?-1:1);if(typeof Ie<"u"&&typeof fe<"u"){const He=Math.abs(fe-Ie),Ce=fe>Ie;je=Ie-He*Math.sin(it)*(Ce?-1:1)}if(Pe===0)if(W){const He=ye?ue-f:ue;e.moveTo(lt,He),ke.push({x:lt,y:He}),e.lineTo(lt,je)}else e.moveTo(lt,je);else e.lineTo(lt,je);if(ke.push({x:lt,y:je}),Pe===T&&W){const He=ye?ue-f:ue;e.lineTo(lt,He),ke.push({x:lt,y:He})}}Ye=ke.flatMap(Pe=>[Pe.x,Pe.y])}else{if(U<0||Q>h)return;e.arc(Be,ue,(U-Q)/2,-Math.PI,Math.PI),Ye=Array.from(e.currentPath.points),e.closePath()}i.getMouseEventModel().addLineBasedEvent(N,Ye)}})})}function F1t(e,g,i){return[...e.slice(0,g),i,...e.slice(g)]}function E1t(e){const g=[];for(let i=0;itypeof g=="number")}function NDe(e){return HDe(e,g=>typeof g=="string")}function D1t(e,g,i){z1t(e,g,i),M1t(e,g,i)}function M1t(e,g,i){var n,I,r,o;const C=g.spec();if(!pt(C.row)||C.row.grid!==!0)return;const[a,A]=e.position,[s,l]=e.dimensions,c=g.spec().layout==="circular",u=(n=C.innerRadius)!=null?n:220,d=(I=C.outerRadius)!=null?I:300,h=(r=C.startAngle)!=null?r:0,f=(o=C.endAngle)!=null?o:360,m=d-u,b=s/2,p=l/2,y=g.getChannelDomainArray("row");if(!y)return;const Z=l/y.length;if(c&&m<=20||!c&&Z<=20)return;const v=e.pBackground,G=i.axis.gridStrokeWidth;y.forEach(B=>{const S=g.encodedValue("row",B);if(c){const R=S+Z/2,w=d-R/l*m,T=w+G/2,W=w-G/2,V=Ig(0,s,W,b,p,h,f),X=Si(0,s,h,f),N=Si(s,s,h,f);v.lineStyle(G,St("black"),0,.5),v.beginFill(St(i.axis.gridColor),1),v.moveTo(a+V.x,A+V.y),v.arc(a+b,A+p,W,X,N,!0),v.arc(a+b,A+p,T,N,X,!1),v.closePath()}else{v.lineStyle(G,St(i.axis.gridColor),1,.5);const R=A+S+Z/2;v.moveTo(a,R),v.lineTo(a+s,R)}})}function z1t(e,g,i){var n,I,r,o,C;const a=g.spec();if(!pt(a.y)||a.y.grid!==!0)return;const[A,s]=e.position,[l,c]=e.dimensions,u=A,d=A+l,h=g.spec().layout==="circular",f=(n=a.innerRadius)!=null?n:220,m=(I=a.outerRadius)!=null?I:300,b=(r=a.startAngle)!=null?r:0,p=(o=a.endAngle)!=null?o:360,y=m-f,Z=l/2,v=c/2,G=(C=g.getChannelDomainArray("row"))!=null?C:["___SINGLE_ROW___"],B=c/G.length;if(!NDe(G))return;const S=g.getChannelScale("y"),R=g.getChannelDomainArray("y");if(!S||!R||!$oe(R)||h&&B/c*y<=20||!h&&B<=20)return;const w=e.pBackground,T=i.axis.gridStrokeWidth;G.forEach(W=>{const V=g.encodedValue("row",W),X=h?B/c*y:B,N=Math.max(Math.ceil(X/40),1);let Y=S.ticks(N).filter(x=>R[0]<=x&&x<=R[1]);Y.length===1&&(Y=S.ticks(N+1).filter(x=>R[0]<=x&&x<=R[1])),h?Y.forEach(x=>{const M=S(x),F=m-(V+B-M)/c*y,$=F+T/2,Q=F-T/2,U=Ig(0,l,Q,Z,v,b,p),j=Si(0,l,b,p),ee=Si(l,l,b,p);w.lineStyle(T,St("black"),0,.5),w.beginFill(St(i.axis.gridColor),1),w.moveTo(A+U.x,s+U.y),w.arc(A+Z,s+v,Q,j,ee,!0),w.arc(A+Z,s+v,$,ee,j,!1),w.closePath()}):(w.lineStyle(T,St(i.axis.gridColor),1,.5),Y.forEach(x=>{var M;const F=s+V+B-S(x);if(i.axis.gridStrokeType==="solid")w.moveTo(u,F),w.lineTo(d,F);else if(i.axis.gridStrokeType==="dashed"){const[$,Q]=(M=i.axis.gridStrokeDash)!=null?M:[1,1];for(let U=u;U=R;N-=S/10){const Y=Ig(N,s,b-B.height/2,h,f,u,d);T.push(new e.libraries.PIXI.Point(Y.x,Y.y))}const W=Si(R,s,u,d),V=Si(w+p,s,u,d);m.lineStyle(1,St("red"),0,.5),m.beginFill(St(I.track.titleBackground),.5),m.moveTo(y.x,y.y),m.arc(h,f,b-B.height,W,V,!0),m.arc(h,f,b,V,W,!1),m.closePath(),v.updateText();const X=new e.libraries.PIXI.SimpleRope(v.texture,T);m.addChild(X)}function _1t(e,g,i){var n,I,r,o;const C=e.pBorder,[a,A]=e.position,[s,l]=e.dimensions;C.lineStyle((I=(n=g.spec().style)==null?void 0:n.outlineWidth)!=null?I:1,St((o=(r=g.spec().style)==null?void 0:r.outline)!=null?o:i.track.outline),1,.5),C.beginFill(St("white"),0),C.drawRect(a,A,s,l);const c=g.spec().x;C.lineStyle(1,St(i.axis.baselineColor),1,.5),pt(c)&&c.axis==="top"?(C.moveTo(a,A),C.lineTo(a+s,A)):pt(c)&&c.axis==="bottom"&&(C.moveTo(a,A+l),C.lineTo(a+s,A+l))}function O1t(e,g,i,n,I){if(!g.gLegend)return;g.gLegend.selectAll(".brush").remove();const r=n.spec(),o={offsetRight:0};if(pt(r.color)&&r.color.legend)switch(r.color.type){case"nominal":J1t(e,g,i,n,I);break;case"quantitative":$Ze(e,g,i,n,I,"color",o);break}if(pt(r.stroke)&&r.stroke.legend)switch(r.stroke.type){case"quantitative":$Ze(e,g,i,n,I,"stroke",o);break}}function $Ze(e,g,i,n,I,r,o){const C=n.spec(),a=C[r];if(!pt(a)||a.type!=="quantitative"||!a.legend)return;const[A,s]=g.position,[l,c]=g.dimensions,u=80,d=c-2>110?110:Math.max(c-2,40-2),h={top:10,left:55,width:20,height:d-20},f=A+l-u-1-o.offsetRight,m=s+1,b=n.getChannelScale(r),p=n.getChannelDomainArray(r);if(!b||!p)return;const y=g.pBorder;if(y.beginFill(St(I.legend.background),I.legend.backgroundOpacity),y.lineStyle(1,St(I.legend.backgroundStroke),I.legend.backgroundOpacity,0),y.drawRect(f,m,u,d),a.title){const X=a.title,N=Td({color:I.legend.labelColor,size:I.legend.labelFontSize,fontWeight:I.legend.labelFontWeight,fontFamily:I.legend.labelFontFamily}),Y=new e.libraries.PIXI.Text(X,{...N,fontWeight:"bold"});Y.anchor.x=0,Y.anchor.y=0,Y.position.x=f+10,Y.position.y=m+10;const x=new e.libraries.PIXI.TextStyle({...N,fontWeight:"bold"}),M=e.libraries.PIXI.TextMetrics.measureText(X,x);y.addChild(Y),h.top+=M.height+4,h.height-=M.height+4}const[Z,v]=p,G=v-Z,B=pt(a)&&a.scaleOffset?a.scaleOffset:[0,1];[...Array(h.height).keys()].forEach(X=>{let N;const Y=Array.from(B).sort();if(X/h.height>=Y[1])N=v;else if(X/h.height<=Y[0])N=Z;else{const x=vb().domain([h.height*Y[0],h.height*Y[1]]).range([0,h.height]);N=vb().domain([0,h.height]).range([Z,v])(x(X))}y.beginFill(St(b(N)),1),y.lineStyle(1,St(I.legend.backgroundStroke),0,.5),y.drawRect(f+h.left,m+h.top+h.height-X,h.width,1)});const S=4;g.colorBrushes=g.gLegend.append("g").attr("class",r).selectAll(".brush").data(B.map((X,N)=>({y:X,id:N}))).enter().append("rect").attr("class","brush").attr("pointer-events","all").attr("cursor","ns-resize").attr("transform",X=>`translate(${f+h.left}, ${m+h.top-S/2+h.height-h.height*X.y})`).attr("width",`${h.width}px`).attr("height",`${S}px`).attr("fill","lightgrey").attr("stroke","black").attr("stroke-width","0.5px").call(e.libraries.d3Drag.drag().on("start",X=>{g.startEvent=X.sourceEvent}).on("drag",(X,N)=>{if(a&&a.scaleOffset){const Y=X.sourceEvent,x=g.startEvent.clientY-Y.clientY,M=[a.scaleOffset[0],a.scaleOffset[1]];N.id===0?M[0]+=x/h.height:M[1]+=x/h.height,M[0]=Math.min(1,Math.max(0,M[0])),M[1]=Math.min(1,Math.max(0,M[1])),g.updateScaleOffsetFromOriginalSpec(C._renderingId,M,r),g.shareScaleOffsetAcrossTracksAndTiles(M,r),g.draw(),g.startEvent=X.sourceEvent}}));const R=Math.max(Math.ceil(h.height/30),2);let w=b.ticks(R).filter(X=>p[0]<=X&&X<=p[1]);w.length===1&&(w=b.ticks(R+1).filter(X=>p[0]<=X&&X<=p[1]));const T=1;y.lineStyle(T,St(I.legend.tickColor),1,.5);const W=Td({color:I.legend.labelColor,size:I.legend.labelFontSize,fontWeight:I.legend.labelFontWeight,fontFamily:I.legend.labelFontFamily}),V=f+h.left;w.forEach(X=>{let N=m+h.top+h.height-(X-Z)/G*h.height;N===m+h.top?N+=T/2:N===m+h.top+h.height&&(N-=T/2),y.moveTo(V-3,N),y.lineTo(V,N);const Y=new e.libraries.PIXI.Text(X,W);Y.anchor.x=1,Y.anchor.y=.5,Y.position.x=V-6,Y.position.y=N,y.addChild(Y)}),o.offsetRight=l-f}function J1t(e,g,i,n,I){var r,o,C,a,A;const s=n.spec();if(!pt(s.color)||s.color.type!=="nominal"||!s.color.legend)return;const l=(r=n.getChannelDomainArray("color"))!=null?r:["___SINGLE_COLOR___"];if(l.length===0)return;const c=s.color.domain,u=s.color.range,d=g.displayedLegends,h=G=>typeof G=="string"?G:G.join();if(d.find(G=>h(G.domain)===h(c)&&h(G.range)===h(u)))return;d.push({domain:c,range:u});const f=g.pBorder,m=10,b=4;let p=b,y=0;const Z=[],v=Td({color:I.legend.labelColor,size:I.legend.labelFontSize,fontWeight:I.legend.labelFontWeight,fontFamily:I.legend.labelFontFamily});if((o=s.style)!=null&&o.inlineLegend)l.map(G=>G).reverse().forEach(G=>{if(y>g.dimensions[0])return;const B=n.encodedValue("color",G),S=new e.libraries.PIXI.Text(G,v);S.anchor.x=1,S.anchor.y=0,S.position.x=g.position[0]+g.dimensions[0]-y-m,S.position.y=g.position[1]+b,f.addChild(S);const R=new e.libraries.PIXI.TextStyle(v),w=e.libraries.PIXI.TextMetrics.measureText(G,R);p{if(p>g.dimensions[1])return;const B=n.encodedValue("color",G),S=new e.libraries.PIXI.Text(G,v);S.anchor.x=1,S.anchor.y=0,S.position.x=g.position[0]+g.dimensions[0]-m,S.position.y=g.position[1]+p,f.addChild(S);const R=new e.libraries.PIXI.TextStyle(v),w=e.libraries.PIXI.TextMetrics.measureText(G,R);y{f.lineStyle(1,St("black"),0,0),f.beginFill(St(G.color),1),f.drawCircle(G.x,G.y,4)})}function L1t(e,g,i,n,I){var r;const o=n.spec();if(!pt(o.row)||o.row.type!=="nominal"||!o.row.legend)return;const C=(r=n.getChannelDomainArray("row"))!=null?r:["___SINGLE_ROW___"];if(C.length===0)return;const a=g.pBorder,A=4,s=2,l=Td({color:I.legend.labelColor,size:I.legend.labelFontSize,fontWeight:I.legend.labelFontWeight,fontFamily:I.legend.labelFontFamily});C.forEach(c=>{const u=n.encodedValue("row",c),d=new e.libraries.PIXI.Text(c,l);d.anchor.x=0,d.anchor.y=0,d.position.x=g.position[0]+A,d.position.y=g.position[1]+u+s,a.addChild(d);const h=new e.libraries.PIXI.TextStyle(l),f=e.libraries.PIXI.TextMetrics.measureText(c,h);a.beginFill(St(I.legend.background),I.legend.backgroundOpacity),a.lineStyle(1,St(I.legend.backgroundStroke),0,0),a.drawRect(g.position[0]+1,g.position[1]+u+1,f.width+A*2,f.height+s*2)})}const y6=8,mV=6;function U1t(e,g,i,n,I){var r;const o=n.spec(),C=o.layout==="circular",a=n.getChannelDomainArray("y"),A=n.getChannelRangeArray("y");if(C||!n.isShowYAxis()||!a||!A||!$oe(a))return;const[s,l]=g.dimensions,[c,u]=g.position,d=(r=n.getChannelDomainArray("row"))!=null?r:["___SINGLE_ROW___"];if(!NDe(d))return;const h=l/d.length;if(h<=20)return;const f=n.spec().y,m=!(pt(f)&&"axis"in f&&f.axis==="right"),b=vb().domain(a).range(A),p=g.pBorder;d.forEach(y=>{const Z=n.encodedValue("row",y),v=m?c:c+s,G=u+Z;p.lineStyle(1,St(I.axis.baselineColor),1,.5),p.moveTo(v,G),p.lineTo(v,G+h);const B=Math.max(Math.ceil(h/40),1);let S=b.ticks(B).filter(T=>a[0]<=T&&T<=a[1]);S.length===1&&(S=b.ticks(B+1).filter(T=>a[0]<=T&&T<=a[1])),p.lineStyle(1,St(I.axis.tickColor),1,.5);let R=m?v+mV:v-mV;S.forEach(T=>{const W=b(T);p.moveTo(v,G+h-W),p.lineTo(R,G+h-W)}),R=m?v+y6:v-y6,p.moveTo(v,G),p.lineTo(R,G),p.moveTo(v,G+h),p.lineTo(R,G+h);const w=Td({color:I.axis.labelColor,size:I.axis.labelFontSize,fontFamily:I.axis.labelFontFamily,fontWeight:I.axis.labelFontWeight});S.forEach(T=>{const W=b(T);R=m?v+mV*2:v-mV*2;const V=new e.libraries.PIXI.Text(T,w);V.anchor.x=m?0:1,V.anchor.y=W===0?.9:.5,V.position.x=R,V.position.y=G+h-W,o.orientation==="vertical"&&(V.anchor.x=m?1:0,V.scale.x*=-1),p.addChild(V)})})}function Q1t(e,g,i,n,I){var r,o,C,a,A;const s=n.spec(),l=s.layout==="circular",c=n.getChannelDomainArray("y"),u=n.getChannelRangeArray("y");if(!l||!n.isShowYAxis()||!c||!u||!$oe(c))return;const[d,h]=g.dimensions,f=(r=s.innerRadius)!=null?r:220,m=(o=s.outerRadius)!=null?o:300,b=m-f,p=(C=s.startAngle)!=null?C:0,y=(a=s.endAngle)!=null?a:360,Z=d/2,v=h/2,G=(A=n.getChannelDomainArray("row"))!=null?A:["___SINGLE_ROW___"],B=h/G.length;if(B/h*b<=20)return;const S=n.spec().y,R=!(pt(S)&&"axis"in S&&S.axis==="right"),w=vb().domain(c).range(u),T=i.graphics;G.forEach(W=>{const V=n.encodedValue("row",W),X=m-(V+B)/h*b,N=m-V/h*b,Y=Ig(R?0:d,d,X,Z,v,p,y),x=Ig(R?0:d,d,N,Z,v,p,y);T.lineStyle(1,St(I.axis.baselineColor),1,.5),T.moveTo(Y.x,Y.y),T.lineTo(x.x,x.y);const M=j=>mV*d/2/Math.PI/j,F=j=>y6*d/2/Math.PI/j,$=B/h*b,Q=Math.max(Math.ceil($/40),1);let U=w.ticks(Q).filter(j=>c[0]<=j&&j<=c[1]);U.length===1&&(U=w.ticks(Q+1).filter(j=>c[0]<=j&&j<=c[1])),T.lineStyle(1,St(I.axis.tickColor),1,.5),U.forEach(j=>{const ee=w(j),Ie=m-(V+B-ee)/h*b,fe=R?0:d-M(Ie),Ve=R?M(Ie):d,oe=Ig(fe,d,Ie,Z,v,p,y),pe=Si(fe,d,p,y),ae=Si(Ve,d,p,y);T.moveTo(oe.x,oe.y),T.arc(Z,v,Ie,pe,ae,!0),T.arc(Z,v,Ie,ae,pe,!1),T.closePath()});{const j=R?0:d-F(f),ee=R?F(f):d,Ie=Si(j,d,p,y),fe=Si(ee,d,p,y);T.moveTo(Y.x,Y.y),T.arc(Z,v,f,Ie,fe,!0),T.arc(Z,v,f,fe,Ie,!1),T.closePath()}{const j=R?0:d-F(m),ee=R?F(m):d,Ie=Si(j,d,p,y),fe=Si(ee,d,p,y);T.moveTo(x.x,x.y),T.arc(Z,v,m,Ie,fe,!0),T.arc(Z,v,m,fe,Ie,!1),T.closePath()}U.forEach(j=>{const ee=w(j),Ie=m-(V+B-ee)/h*b,fe=Ig(M(Ie)*2,d,Ie,Z,v,p,y),Ve=Td({color:I.axis.labelColor,size:I.axis.labelFontSize,fontFamily:I.axis.labelFontFamily,fontWeight:I.axis.labelFontWeight}),oe=new e.libraries.PIXI.Text(j,Ve);oe.anchor.x=R?1:0,oe.anchor.y=.5,oe.position.x=fe.x,oe.position.y=fe.y,oe.resolution=4;const pe=new e.libraries.PIXI.TextStyle(Ve),ie=e.libraries.PIXI.TextMetrics.measureText(oe.text,pe).width/(2*Ie*Math.PI)*d*360/(y-p),ye=R?M(Ie)*2:d-M(Ie)*2-ie,ue=R?M(Ie)*2+ie:d-M(Ie)*2,Ye=[];for(let ke=ue;ke>=ye;ke-=ie/10){const _e=Ig(ke,d,Ie,Z,v,p,y);Ye.push(new e.libraries.PIXI.Point(_e.x,_e.y))}oe.updateText();const Be=new e.libraries.PIXI.SimpleRope(oe.texture,Ye);T.addChild(Be)})})}function j1t(e,g,i){var n,I,r,o,C,a,A,s,l,c,u,d;const h=g.spec(),[f,m]=e.position,[b,p]=e.dimensions,y=(n=h.innerRadius)!=null?n:220,Z=(I=h.outerRadius)!=null?I:300,v=(r=h.startAngle)!=null?r:0,G=(o=h.endAngle)!=null?o:360,B=f+b/2,S=m+p/2,R=Ig(0,b,y,B,S,v,G),w=Si(0,b,v,G),T=Si(b,b,v,G),W=e.pBackground;h.layout==="circular"&&h.mark==="withinLink"||(W.lineStyle((C=h.style)!=null&&C.outlineWidth?((a=h.style)==null?void 0:a.outlineWidth)/2.5:0,St((s=(A=h.style)==null?void 0:A.outline)!=null?s:"#DBDBDB"),1,1),W.beginFill(St((c=(l=g.spec().style)==null?void 0:l.background)!=null?c:i.track.background),(d=(u=g.spec().style)==null?void 0:u.backgroundOpacity)!=null?d:!i.track.background||i.track.background==="transparent"?0:1),W.moveTo(R.x,R.y),W.arc(B,S,y,w,T,!0),W.arc(B,S,Z,T,w,!1),W.closePath()),pt(h.x)&&h.x.axis==="top"&&(W.lineStyle(.5,St("black"),0,.5),W.beginFill(St("white"),0),W.moveTo(R.x,R.y),W.arc(B,S,Z-.5,w,T,!0),W.arc(B,S,Z,T,w,!1),W.closePath()),W.lineStyle(.5,St("black"),0,.5),W.beginFill(St("white"),0),W.moveTo(B,S),W.arc(B,S,Z+3,w,T,!1),W.closePath(),W.lineStyle(1,St("#DBDBDB"),0,0),W.beginFill(St("white"),0),W.drawCircle(B,S,y-1)}function $1t(e,g,i){var n,I,r,o,C,a;const[A,s]=e.position,[l,c]=e.dimensions,u=e.pBackground;if((n=g.spec().style)!=null&&n.background||i.track.background&&i.track.background!=="transparent"){u.clear();const d=(r=(I=g.spec().style)==null?void 0:I.background)!=null?r:i.track.background,h=QZe((o=g.spec().style)==null?void 0:o.backgroundOpacity)?1:(C=g.spec().style)==null?void 0:C.backgroundOpacity;u.lineStyle(1,St("white"),0,0),u.beginFill(St(d),h),u.drawRect(A,s,l,c)}if(i.track.alternatingBackground&&i.track.alternatingBackground!=="transparent"){const d=g.spec();if(!pt(d.row)||d.row.type!=="nominal")return;const h=(a=g.getChannelDomainArray("row"))!=null?a:["___SINGLE_ROW___"];if(h.length===0)return;h.forEach((f,m)=>{var b,p,y,Z;if(m%2===0)return;const v=g.encodedValue("row",f),G=(p=(b=g.spec().style)==null?void 0:b.background)!=null?p:i.track.alternatingBackground,B=QZe((y=g.spec().style)==null?void 0:y.backgroundOpacity)?1:(Z=g.spec().style)==null?void 0:Z.backgroundOpacity;u.lineStyle(1,St("white"),0,0),u.beginFill(St(G),B),u.drawRect(e.position[0],e.position[1]+v,l,c/h.length)})}}function q1t(e,g,i){var n,I,r,o,C;const a=i.spec();if(!a.width||!a.height){console.warn("Size of a track is not properly determined, so visual mark cannot be rendered");return}const A=i.data(),[s,l]=g.dimensions,c=a.layout==="circular",u=(n=a.innerRadius)!=null?n:220,d=(I=a.outerRadius)!=null?I:300,h=(r=a.startAngle)!=null?r:0,f=(o=a.endAngle)!=null?o:360,m=d-u,b=s/2,p=l/2,y=(C=i.getChannelDomainArray("row"))!=null?C:["___SINGLE_ROW___"],Z=l/y.length;y.forEach(v=>{const G=i.encodedValue("row",v);A.filter(B=>!tn(B,a.row)||tn(B,a.row)===v).forEach(B=>{var S,R;let w=i.encodedPIXIProperty("x",B),T=i.encodedPIXIProperty("xe",B),W=i.encodedPIXIProperty("x1",B),V=i.encodedPIXIProperty("x1e",B);const X=i.encodedPIXIProperty("y",B),N=i.encodedPIXIProperty("stroke",B),Y=i.encodedPIXIProperty("strokeWidth",B),x=i.encodedPIXIProperty("color",B),M=i.encodedPIXIProperty("opacity",B);typeof T<"u"&&([w,T]=[w,T].sort(($,Q)=>$-Q)),typeof W<"u"&&typeof V<"u"&&([W,V]=[W,V].sort(($,Q)=>$-Q));const F=typeof T<"u"&&typeof W<"u"&&typeof V<"u"&&Math.abs(w-T)>.1&&Math.abs(W-V)>.1;if(!F&&T===void 0&&!Pr(a)){if(W===void 0&&V===void 0)return;T=W!==void 0?W:V}if(!F&&Math.abs(w-T)<=.1&&Math.abs(W-V)<=.1&&(w=(w+T)/2,T=(W+V)/2),e.lineStyle(Y,St(N),M,.5),F){e.beginFill(St(x==="none"?"white":x),x==="none"?0:M);let[$,Q,U,j]=[w,T,W,V];if([$,Q]=[$,Q].sort((ee,Ie)=>ee-Ie),[U,j]=[U,j].sort((ee,Ie)=>ee-Ie),$>s||j<0||Math.abs(j-$)<.5)return;if(c){if($<0||j>s)return;const ee=d-G/l*m,Ie=Ig($,s,ee,b,p,h,f),fe=Ig(Q,s,ee,b,p,h,f),Ve=Ig(U,s,ee,b,p,h,f),oe=Ig(j,s,ee,b,p,h,f);e.moveTo(Ie.x,Ie.y),e.bezierCurveTo(b,p,b,p,oe.x,oe.y),e.arc(b,p,d,bf(oe.x,oe.y,b,p),bf(Ve.x,Ve.y,b,p),!1),e.bezierCurveTo(b,p,b,p,fe.x,fe.y),e.arc(b,p,d,bf(fe.x,fe.y,b,p),bf(Ie.x,Ie.y,b,p),!1),e.endFill()}else e.moveTo($,G),e.lineTo(Q,G),e.lineTo(j,G+Z),e.lineTo(U,G+Z),e.lineTo($,G),e.closePath()}else{if(Pr(a)){((S=a.style)==null?void 0:S.linkConnectionType)==="curve"?(e.moveTo(w,0),e.bezierCurveTo(w/5*4,(G+Z-X)/2,w/2,(G+Z-X)/5*4,0,G+Z-X)):((R=a.style)==null?void 0:R.linkConnectionType)==="straight"?(e.moveTo(w,0),e.lineTo(0,G+Z-X)):(e.moveTo(w,0),e.lineTo(w,G+Z-X),e.lineTo(0,G+Z-X));return}if(c){let $,Q;for(let U=0;U<=1;U+=.02){const j=oe=>Math.log(oe/(1-oe)),ee=oe=>d-1/(1+Math.exp(j(oe)))*m+3,Ie=(oe,pe,ae)=>((ae-pe)*oe+pe)/s,fe=b+ee(U)*Math.cos(-Ie(U,w,T)*2*Math.PI-Math.PI/2),Ve=p+ee(U)*Math.sin(-Ie(U,w,T)*2*Math.PI-Math.PI/2);$&&Q&&(e.lineStyle(Y,St(N),M,.5),e.moveTo($,Q),e.lineTo(fe,Ve)),$=fe,Q=Ve}return}e.moveTo(T,G+Z),e.lineTo(w,G)}})})}const z0=["x","xe","x1","x1e","y","ye","y1","y1e","color","size","row","stroke","strokeWidth","opacity","text"];function eSt(e,g,i,n){if(!e||!g||!i||n.spec().mark==="brush")return;if(["x","x1","x1e","xe"].forEach(o=>{n.setChannelScale(o,g._xScale)}),Pr(n.spec())||cSt(n.spec())){const o=g._yScale.copy();o.range([o.range()[1],o.range()[0]]),["y","y1","y1e","ye"].forEach(C=>{n.setChannelScale(C,o)})}const[I,r]=g.dimensions;switch(n.spec().mark){case"point":S1t(g,i.graphics,n);break;case"bar":W1t(g,i,n);break;case"line":V1t(i.graphics,n,I,r);break;case"area":T1t(e,g,i,n);break;case"rect":H1t(e,g,i,n);break;case"triangleLeft":case"triangleRight":case"triangleBottom":k1t(i.graphics,n,I,r);break;case"text":Y1t(e,g,i,n);break;case"rule":K1t(e,g,i,n);break;case"betweenLink":q1t(i.graphics,g,n);break;case"withinLink":x1t(i.graphics,g,n);break;default:console.warn("Unsupported mark type");break}}function tSt(e,g,i,n,I){if(!e||!g||!i||n.spec().mark==="brush")return;["x","x1","x1e","xe"].forEach(o=>{n.setChannelScale(o,g._xScale)}),n.spec().layout==="circular"?j1t(g,n,I):($1t(g,n,I),_1t(g,n,I)),D1t(g,n,I)}function gSt(e,g,i,n,I){if(!e||!g||!i||n.spec().mark==="brush")return;["x","x1","x1e","xe"].forEach(o=>{n.setChannelScale(o,g._xScale)}),n.spec().layout==="circular"?(Q1t(e,g,i,n,I),P1t(e,g,i,n,I)):(U1t(e,g,i,n,I),L1t(e,g,i,n,I)),O1t(e,g,i,n,I)}function S1(e){if(YDe(e)||dT(e))return[];if(!eI(e))return[e];if(e._overlay.length===0)return[{...e,superpose:void 0}];const g=JSON.parse(JSON.stringify(e));delete g._overlay;const i=[];e._overlay.forEach((r,o)=>{const C=Object.assign(JSON.parse(JSON.stringify(g)),r);C.title&&o!==0&&delete C.title,i.push(C)});let n;return i.forEach(r=>{pt(r.x)&&r.x.axis&&!n&&(n=r.x.axis)}),i.map(r=>({...r,x:{...r.x,axis:n}}))}function iSt(e){return[].concat(...e.map(g=>{if(YDe(g)||!eI(g)||g._overlay.length<=1)return[g];if(g._overlay.filter(o=>o.data).length===0)return[g];if(qZe([g.data,...g._overlay.map(o=>o.data)]))return[g];const i={...g,id:void 0,_overlay:void 0},n=[],I=JSON.parse(JSON.stringify(i));return I._overlay=[],g._overlay.forEach(o=>{if(I.data||(I.data=o.data),I.id||(I.id=o.id),!o.data||qZe([I.data,o.data])){I._overlay.push(o);return}const C=Object.assign(JSON.parse(JSON.stringify(i)),o);n.push(C)}),(I._overlay.length>0?[I,...n]:n).map((o,C,a)=>{const A=C!==0,s=_a(o)&&pt(o.y)&&!o.y.axis&&A?{...o.y,axis:C===1?"right":"none"}:_a(o)?o.y:void 0;return o.title&&C!==a.length-1&&a.length!==1&&delete o.title,{...o,overlayOnPreviousTrack:A,y:s}})}))}function qZe(e){if(e.length===0)return!1;const g=e.filter(I=>I);if(g.length!==e.length)return!1;const i=Object.keys(g[0]).sort();let n=!0;return i.forEach(I=>{if(Array.from(new Set(g.map(o=>JSON.stringify(o[I])))).length!==1){n=!1;return}}),n}const $x={viridis:VDe,grey:o1t,warm:a1t,spectral:qwt,cividis:C1t,bupu:t1t,rdbu:jwt,hot:I1t,pink:i1t};function qoe(e){return typeof e=="object"&&e!==null}function lk(e){return qoe(e)&&"getTabularData"in e}function nSt(e,g){var i;return((i=e.dataTransform)!=null?i:[]).some(n=>n.type===g)}function ISt(e="viridis",g=100){var i;const n=(i=$x[e])!=null?i:$x.viridis;return[...Array(g)].map((I,r)=>n(1/g*r))}function kDe(e){return!("alignment"in e)&&!e.tracks.find(g=>g.alignment==="overlay"||"tracks"in g)}function rSt(e){return"alignment"in e&&e.alignment==="overlay"}function oSt(e){return!kDe(e)&&!rSt(e)}function YDe(e){return!eI(e)&&"data"in e&&!("mark"in e)}function dT(e){return"type"in e&&e.type=="dummy-track"}function CSt(e){return!!("data"in e&&"overrideTemplate"in e&&e.overrideTemplate)}function eGe(e){return typeof e=="object"}function aSt(e){return"chromosome"in e&&!("interval"in e)}function sSt(e){return!("chromosome"in e)&&"interval"in e}function ASt(e){return"chromosome"in e&&"interval"in e}function _a(e){return!("_overlay"in e)}function eI(e){return"_overlay"in e}function lSt(e){return"template"in e}function cSt(e){return _a(e)&&!pt(e.x)&&pt(e.y)&&e.y.type==="genomic"}function Pr(e){const g=_a(e)?e:S1(e)[0];return pt(g.x)&&g.x.type==="genomic"&&pt(g.y)&&g.y.type==="genomic"}function uSt(e){return Pr(e)&&e.data.type==="matrix"&&(e.mark==="bar"||e.mark==="rect")&&e.xe&&e.ye}function YK(e){return e!==null&&typeof e=="object"&&"value"in e}function eCe(e){return e!==void 0&&(e.type==="vector"||e.type==="beddb"||e.type==="multivec"||e.type==="bigwig"||e.type==="matrix"||e.type==="bam"||e.type==="vcf"||e.type==="gff"||e.type==="bed")}function pt(e){return qoe(e)&&!("value"in e)}function dSt(e){return"oneOf"in e}function hSt(e){return"inRange"in e}function fSt(e){return"include"in e}function tGe(e){return Array.isArray(e)}function mSt(e){return Array.isArray(e)}function mz(e){return(e.mark==="bar"||e.mark==="area"||e.mark==="text")&&pt(e.color)&&e.color.type==="nominal"&&(!e.row||YK(e.row))&&pt(e.y)&&e.y.type==="quantitative"&&!pt(e.ye)}function pSt(e,g){const i=e[g];return mz(e)&&(g==="x"||g==="y")&&pt(i)&&i.type==="quantitative"}function tn(e,g){if(pt(g)&&g.field)return e[g?.field]}function bSt(e){const g=[];return z0.forEach(i=>{const n=e[i];pt(n)&&"aggregate"in n&&g.push(i)}),g}function tU(e,g){const i=[];return z0.forEach(n=>{const I=e[n];pt(I)&&I.type===g&&i.push(n)}),i}function qx(e){if((_a(e)||eI(e))&&pt(e.x)&&e.x.axis&&e.x.axis!=="none")return!0;if(eI(e)){let g=!1;return e._overlay.forEach(i=>{g||pt(i.x)&&i.x.axis&&i.x.axis!=="none"&&(g=!0)}),g}return!1}function ySt(e){if((_a(e)||eI(e))&&pt(e.y)&&e.y.axis&&e.y.axis!=="none")return!0;if(eI(e)){let g=!1;return e._overlay.forEach(i=>{g||pt(i.y)&&i.y.axis&&i.y.axis!=="none"&&(g=!0)}),g}return!1}function FZ(e){return typeof e=="object"}var Sb=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ZSt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Z6={exports:{}};/** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */(function(e,g){(function(i,n){n(g)})(Sb,function(i){function n(){for(var O=arguments.length,D=Array(O),q=0;q1){D[0]=D[0].slice(0,-1);for(var ce=D.length-1,he=1;he= 0x80 (not a basic code point)","invalid-input":"Invalid input"},w=h-f,T=Math.floor,W=String.fromCharCode;function V(O){throw new RangeError(R[O])}function X(O,D){for(var q=[],ce=O.length;ce--;)q[ce]=D(O[ce]);return q}function N(O,D){var q=O.split("@"),ce="";q.length>1&&(ce=q[0]+"@",O=q[1]),O=O.replace(S,".");var he=O.split("."),Oe=X(he,D).join(".");return ce+Oe}function Y(O){for(var D=[],q=0,ce=O.length;q=55296&&he<=56319&&q>1,D+=T(D/q);D>w*m>>1;he+=h)D=T(D/w);return T(he+(w+1)*D/(D+b))},Q=function(D){var q=[],ce=D.length,he=0,Oe=Z,Je=y,bt=D.lastIndexOf(v);bt<0&&(bt=0);for(var Xt=0;Xt=128&&V("not-basic"),q.push(D.charCodeAt(Xt));for(var Jt=bt>0?bt+1:0;Jt=ce&&V("invalid-input");var ct=M(D.charCodeAt(Jt++));(ct>=h||ct>T((d-he)/Ft))&&V("overflow"),he+=ct*Ft;var Mt=ig<=Je?f:ig>=Je+m?m:ig-Je;if(ctT(d/Cg)&&V("overflow"),Ft*=Cg}var $t=q.length+1;Je=$(he-Zt,$t,Zt==0),T(he/$t)>d-Oe&&V("overflow"),Oe+=T(he/$t),he%=$t,q.splice(he++,0,Oe)}return String.fromCodePoint.apply(String,q)},U=function(D){var q=[];D=Y(D);var ce=D.length,he=Z,Oe=0,Je=y,bt=!0,Xt=!1,Jt=void 0;try{for(var Zt=D[Symbol.iterator](),Ft;!(bt=(Ft=Zt.next()).done);bt=!0){var ig=Ft.value;ig<128&&q.push(W(ig))}}catch(jo){Xt=!0,Jt=jo}finally{try{!bt&&Zt.return&&Zt.return()}finally{if(Xt)throw Jt}}var ct=q.length,Mt=ct;for(ct&&q.push(v);Mt=he&&cgT((d-Oe)/Lt)&&V("overflow"),Oe+=(Cg-he)*Lt,he=Cg;var Dt=!0,pg=!1,lg=void 0;try{for(var hg=D[Symbol.iterator](),Tg;!(Dt=(Tg=hg.next()).done);Dt=!0){var ei=Tg.value;if(eid&&V("overflow"),ei==he){for(var Fg=Oe,Wn=h;;Wn+=h){var $I=Wn<=Je?f:Wn>=Je+m?m:Wn-Je;if(Fg<$I)break;var Ss=Fg-$I,fh=h-$I;q.push(W(F($I+Ss%fh,0))),Fg=T(Ss/fh)}q.push(W(F(Fg,0))),Je=$(Oe,Lt,Mt==ct),Oe=0,++Mt}}}catch(jo){pg=!0,lg=jo}finally{try{!Dt&&hg.return&&hg.return()}finally{if(pg)throw lg}}++Oe,++he}return q.join("")},j=function(D){return N(D,function(q){return G.test(q)?Q(q.slice(4).toLowerCase()):q})},ee=function(D){return N(D,function(q){return B.test(q)?"xn--"+U(q):q})},Ie={version:"2.1.0",ucs2:{decode:Y,encode:x},decode:Q,encode:U,toASCII:ee,toUnicode:j},fe={};function Ve(O){var D=O.charCodeAt(0),q=void 0;return D<16?q="%0"+D.toString(16).toUpperCase():D<128?q="%"+D.toString(16).toUpperCase():D<2048?q="%"+(D>>6|192).toString(16).toUpperCase()+"%"+(D&63|128).toString(16).toUpperCase():q="%"+(D>>12|224).toString(16).toUpperCase()+"%"+(D>>6&63|128).toString(16).toUpperCase()+"%"+(D&63|128).toString(16).toUpperCase(),q}function oe(O){for(var D="",q=0,ce=O.length;q=194&&he<224){if(ce-q>=6){var Oe=parseInt(O.substr(q+4,2),16);D+=String.fromCharCode((he&31)<<6|Oe&63)}else D+=O.substr(q,6);q+=6}else if(he>=224){if(ce-q>=9){var Je=parseInt(O.substr(q+4,2),16),bt=parseInt(O.substr(q+7,2),16);D+=String.fromCharCode((he&15)<<12|(Je&63)<<6|bt&63)}else D+=O.substr(q,9);q+=9}else D+=O.substr(q,3),q+=3}return D}function pe(O,D){function q(ce){var he=oe(ce);return he.match(D.UNRESERVED)?he:ce}return O.scheme&&(O.scheme=String(O.scheme).replace(D.PCT_ENCODED,q).toLowerCase().replace(D.NOT_SCHEME,"")),O.userinfo!==void 0&&(O.userinfo=String(O.userinfo).replace(D.PCT_ENCODED,q).replace(D.NOT_USERINFO,Ve).replace(D.PCT_ENCODED,o)),O.host!==void 0&&(O.host=String(O.host).replace(D.PCT_ENCODED,q).toLowerCase().replace(D.NOT_HOST,Ve).replace(D.PCT_ENCODED,o)),O.path!==void 0&&(O.path=String(O.path).replace(D.PCT_ENCODED,q).replace(O.scheme?D.NOT_PATH:D.NOT_PATH_NOSCHEME,Ve).replace(D.PCT_ENCODED,o)),O.query!==void 0&&(O.query=String(O.query).replace(D.PCT_ENCODED,q).replace(D.NOT_QUERY,Ve).replace(D.PCT_ENCODED,o)),O.fragment!==void 0&&(O.fragment=String(O.fragment).replace(D.PCT_ENCODED,q).replace(D.NOT_FRAGMENT,Ve).replace(D.PCT_ENCODED,o)),O}function ae(O){return O.replace(/^0*(.*)/,"$1")||"0"}function ie(O,D){var q=O.match(D.IPV4ADDRESS)||[],ce=c(q,2),he=ce[1];return he?he.split(".").map(ae).join("."):O}function ye(O,D){var q=O.match(D.IPV6ADDRESS)||[],ce=c(q,3),he=ce[1],Oe=ce[2];if(he){for(var Je=he.toLowerCase().split("::").reverse(),bt=c(Je,2),Xt=bt[0],Jt=bt[1],Zt=Jt?Jt.split(":").map(ae):[],Ft=Xt.split(":").map(ae),ig=D.IPV4ADDRESS.test(Ft[Ft.length-1]),ct=ig?7:8,Mt=Ft.length-ct,Cg=Array(ct),$t=0;$t1){var Tt=Cg.slice(0,Ti.index),cg=Cg.slice(Ti.index+Ti.length);It=Tt.join(":")+"::"+cg.join(":")}else It=Cg.join(":");return Oe&&(It+="%"+Oe),It}else return O}var ue=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,Ye="".match(/(){0}/)[1]===void 0;function Be(O){var D=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},q={},ce=D.iri!==!1?l:s;D.reference==="suffix"&&(O=(D.scheme?D.scheme+":":"")+"//"+O);var he=O.match(ue);if(he){Ye?(q.scheme=he[1],q.userinfo=he[3],q.host=he[4],q.port=parseInt(he[5],10),q.path=he[6]||"",q.query=he[7],q.fragment=he[8],isNaN(q.port)&&(q.port=he[5])):(q.scheme=he[1]||void 0,q.userinfo=O.indexOf("@")!==-1?he[3]:void 0,q.host=O.indexOf("//")!==-1?he[4]:void 0,q.port=parseInt(he[5],10),q.path=he[6]||"",q.query=O.indexOf("?")!==-1?he[7]:void 0,q.fragment=O.indexOf("#")!==-1?he[8]:void 0,isNaN(q.port)&&(q.port=O.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?he[4]:void 0)),q.host&&(q.host=ye(ie(q.host,ce),ce)),q.scheme===void 0&&q.userinfo===void 0&&q.host===void 0&&q.port===void 0&&!q.path&&q.query===void 0?q.reference="same-document":q.scheme===void 0?q.reference="relative":q.fragment===void 0?q.reference="absolute":q.reference="uri",D.reference&&D.reference!=="suffix"&&D.reference!==q.reference&&(q.error=q.error||"URI is not a "+D.reference+" reference.");var Oe=fe[(D.scheme||q.scheme||"").toLowerCase()];if(!D.unicodeSupport&&(!Oe||!Oe.unicodeSupport)){if(q.host&&(D.domainHost||Oe&&Oe.domainHost))try{q.host=Ie.toASCII(q.host.replace(ce.PCT_ENCODED,oe).toLowerCase())}catch(Je){q.error=q.error||"Host's domain name can not be converted to ASCII via punycode: "+Je}pe(q,s)}else pe(q,ce);Oe&&Oe.parse&&Oe.parse(q,D)}else q.error=q.error||"URI can not be parsed.";return q}function ke(O,D){var q=D.iri!==!1?l:s,ce=[];return O.userinfo!==void 0&&(ce.push(O.userinfo),ce.push("@")),O.host!==void 0&&ce.push(ye(ie(String(O.host),q),q).replace(q.IPV6ADDRESS,function(he,Oe,Je){return"["+Oe+(Je?"%25"+Je:"")+"]"})),(typeof O.port=="number"||typeof O.port=="string")&&(ce.push(":"),ce.push(String(O.port))),ce.length?ce.join(""):void 0}var _e=/^\.\.?\//,Pe=/^\/\.(\/|$)/,it=/^\/\.\.(\/|$)/,lt=/^\/?(?:.|\n)*?(?=\/|$)/;function je(O){for(var D=[];O.length;)if(O.match(_e))O=O.replace(_e,"");else if(O.match(Pe))O=O.replace(Pe,"/");else if(O.match(it))O=O.replace(it,"/"),D.pop();else if(O==="."||O==="..")O="";else{var q=O.match(lt);if(q){var ce=q[0];O=O.slice(ce.length),D.push(ce)}else throw new Error("Unexpected dot segment condition")}return D.join("")}function He(O){var D=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},q=D.iri?l:s,ce=[],he=fe[(D.scheme||O.scheme||"").toLowerCase()];if(he&&he.serialize&&he.serialize(O,D),O.host&&!q.IPV6ADDRESS.test(O.host)){if(D.domainHost||he&&he.domainHost)try{O.host=D.iri?Ie.toUnicode(O.host):Ie.toASCII(O.host.replace(q.PCT_ENCODED,oe).toLowerCase())}catch(bt){O.error=O.error||"Host's domain name can not be converted to "+(D.iri?"Unicode":"ASCII")+" via punycode: "+bt}}pe(O,q),D.reference!=="suffix"&&O.scheme&&(ce.push(O.scheme),ce.push(":"));var Oe=ke(O,D);if(Oe!==void 0&&(D.reference!=="suffix"&&ce.push("//"),ce.push(Oe),O.path&&O.path.charAt(0)!=="/"&&ce.push("/")),O.path!==void 0){var Je=O.path;!D.absolutePath&&(!he||!he.absolutePath)&&(Je=je(Je)),Oe===void 0&&(Je=Je.replace(/^\/\//,"/%2F")),ce.push(Je)}return O.query!==void 0&&(ce.push("?"),ce.push(O.query)),O.fragment!==void 0&&(ce.push("#"),ce.push(O.fragment)),ce.join("")}function Ce(O,D){var q=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},ce=arguments[3],he={};return ce||(O=Be(He(O,q),q),D=Be(He(D,q),q)),q=q||{},!q.tolerant&&D.scheme?(he.scheme=D.scheme,he.userinfo=D.userinfo,he.host=D.host,he.port=D.port,he.path=je(D.path||""),he.query=D.query):(D.userinfo!==void 0||D.host!==void 0||D.port!==void 0?(he.userinfo=D.userinfo,he.host=D.host,he.port=D.port,he.path=je(D.path||""),he.query=D.query):(D.path?(D.path.charAt(0)==="/"?he.path=je(D.path):((O.userinfo!==void 0||O.host!==void 0||O.port!==void 0)&&!O.path?he.path="/"+D.path:O.path?he.path=O.path.slice(0,O.path.lastIndexOf("/")+1)+D.path:he.path=D.path,he.path=je(he.path)),he.query=D.query):(he.path=O.path,D.query!==void 0?he.query=D.query:he.query=O.query),he.userinfo=O.userinfo,he.host=O.host,he.port=O.port),he.scheme=O.scheme),he.fragment=D.fragment,he}function Ze(O,D,q){var ce=a({scheme:"null"},q);return He(Ce(Be(O,ce),Be(D,ce),ce,!0),ce)}function Te(O,D){return typeof O=="string"?O=He(Be(O,D),D):r(O)==="object"&&(O=Be(He(O,D),D)),O}function E(O,D,q){return typeof O=="string"?O=He(Be(O,q),q):r(O)==="object"&&(O=He(O,q)),typeof D=="string"?D=He(Be(D,q),q):r(D)==="object"&&(D=He(D,q)),O===D}function H(O,D){return O&&O.toString().replace(!D||!D.iri?s.ESCAPE:l.ESCAPE,Ve)}function K(O,D){return O&&O.toString().replace(!D||!D.iri?s.PCT_ENCODED:l.PCT_ENCODED,oe)}var te={scheme:"http",domainHost:!0,parse:function(D,q){return D.host||(D.error=D.error||"HTTP URIs must have a host."),D},serialize:function(D,q){var ce=String(D.scheme).toLowerCase()==="https";return(D.port===(ce?443:80)||D.port==="")&&(D.port=void 0),D.path||(D.path="/"),D}},me={scheme:"https",domainHost:te.domainHost,parse:te.parse,serialize:te.serialize};function Re(O){return typeof O.secure=="boolean"?O.secure:String(O.scheme).toLowerCase()==="wss"}var Ee={scheme:"ws",domainHost:!0,parse:function(D,q){var ce=D;return ce.secure=Re(ce),ce.resourceName=(ce.path||"/")+(ce.query?"?"+ce.query:""),ce.path=void 0,ce.query=void 0,ce},serialize:function(D,q){if((D.port===(Re(D)?443:80)||D.port==="")&&(D.port=void 0),typeof D.secure=="boolean"&&(D.scheme=D.secure?"wss":"ws",D.secure=void 0),D.resourceName){var ce=D.resourceName.split("?"),he=c(ce,2),Oe=he[0],Je=he[1];D.path=Oe&&Oe!=="/"?Oe:void 0,D.query=Je,D.resourceName=void 0}return D.fragment=void 0,D}},nt={scheme:"wss",domainHost:Ee.domainHost,parse:Ee.parse,serialize:Ee.serialize},wt={},kt="[A-Za-z0-9\\-\\.\\_\\~\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]",yt="[0-9A-Fa-f]",Pt=I(I("%[EFef]"+yt+"%"+yt+yt+"%"+yt+yt)+"|"+I("%[89A-Fa-f]"+yt+"%"+yt+yt)+"|"+I("%"+yt+yt)),ge="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",z="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",J=n(z,'[\\"\\\\]'),be="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",Ke=new RegExp(kt,"g"),de=new RegExp(Pt,"g"),le=new RegExp(n("[^]",ge,"[\\.]",'[\\"]',J),"g"),ne=new RegExp(n("[^]",kt,be),"g"),re=ne;function Se(O){var D=oe(O);return D.match(Ke)?D:O}var Fe={scheme:"mailto",parse:function(D,q){var ce=D,he=ce.to=ce.path?ce.path.split(","):[];if(ce.path=void 0,ce.query){for(var Oe=!1,Je={},bt=ce.query.split("&"),Xt=0,Jt=bt.length;Xt=55296&&r<=56319&&I=g)throw new Error("Cannot access property/index "+n+" levels up, current level is "+g);return i[g-n]}if(n>g)throw new Error("Cannot access data "+n+" levels up, current level is "+g);if(r="data"+(g-n||""),!I)return r}for(var C=r,a=I.split("/"),A=0;A=0?{index:n,compiling:!0}:(n=this._compilations.length,this._compilations[n]={schema:e,root:g,baseId:i},{index:n,compiling:!1})}function IRt(e,g,i){var n=_De.call(this,e,g,i);n>=0&&this._compilations.splice(n,1)}function _De(e,g,i){for(var n=0;n%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,UDe=/^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i,QDe=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,jDe=/^(?:\/(?:[^~/]|~0|~1)*)*$/,$De=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,qDe=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,fRt=Zz;function Zz(e){return e=e=="full"?"full":"fast",ARt.copy(Zz[e])}Zz.fast={date:/^\d\d\d\d-[0-1]\d-[0-3]\d$/,time:/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,"date-time":/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(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[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:gMe,uuid:QDe,"json-pointer":jDe,"json-pointer-uri-fragment":$De,"relative-json-pointer":qDe};Zz.full={date:eMe,time:tMe,"date-time":bRt,uri:ZRt,"uri-reference":hRt,"uri-template":LDe,url:UDe,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:JDe,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:gMe,uuid:QDe,"json-pointer":jDe,"json-pointer-uri-fragment":$De,"relative-json-pointer":qDe};function mRt(e){return e%4===0&&(e%100!==0||e%400===0)}function eMe(e){var g=e.match(lRt);if(!g)return!1;var i=+g[1],n=+g[2],I=+g[3];return n>=1&&n<=12&&I>=1&&I<=(n==2&&mRt(i)?29:cRt[n])}function tMe(e,g){var i=e.match(uRt);if(!i)return!1;var n=i[1],I=i[2],r=i[3],o=i[5];return(n<=23&&I<=59&&r<=59||n==23&&I==59&&r==60)&&(!g||o)}var pRt=/t|\s/i;function bRt(e){var g=e.split(pRt);return g.length==2&&eMe(g[0])&&tMe(g[1],!0)}var yRt=/\/|:/;function ZRt(e){return yRt.test(e)&&dRt.test(e)}var GRt=/[^\\]\\Z/;function gMe(e){if(GRt.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}var vRt=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.errSchemaPath+"/"+i,A=!g.opts.allErrors,s="data"+(o||""),l="valid"+r,c,u;if(C=="#"||C=="#/")g.isRoot?(c=g.async,u="validate"):(c=g.root.schema.$async===!0,u="root.refVal[0]");else{var d=g.resolveRef(g.baseId,C,g.isRoot);if(d===void 0){var h=g.MissingRefError.message(g.baseId,C);if(g.opts.missingRefs=="fail"){g.logger.error(h);var f=f||[];f.push(I),I="",g.createErrors!==!1?(I+=" { keyword: '$ref' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(a)+" , params: { ref: '"+g.util.escapeQuotes(C)+"' } ",g.opts.messages!==!1&&(I+=" , message: 'can\\'t resolve reference "+g.util.escapeQuotes(C)+"' "),g.opts.verbose&&(I+=" , schema: "+g.util.toQuotedString(C)+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+s+" "),I+=" } "):I+=" {} ";var m=I;I=f.pop(),!g.compositeRule&&A?g.async?I+=" throw new ValidationError(["+m+"]); ":I+=" validate.errors = ["+m+"]; return false; ":I+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",A&&(I+=" if (false) { ")}else if(g.opts.missingRefs=="ignore")g.logger.warn(h),A&&(I+=" if (true) { ");else throw new g.MissingRefError(g.baseId,C,h)}else if(d.inline){var b=g.util.copy(g);b.level++;var p="valid"+b.level;b.schema=d.schema,b.schemaPath="",b.errSchemaPath=C;var y=g.validate(b).replace(/validate\.schema/g,d.code);I+=" "+y+" ",A&&(I+=" if ("+p+") { ")}else c=d.$async===!0||g.async&&d.$async!==!1,u=d.code}if(u){var f=f||[];f.push(I),I="",g.opts.passContext?I+=" "+u+".call(this, ":I+=" "+u+"( ",I+=" "+s+", (dataPath || '')",g.errorPath!='""'&&(I+=" + "+g.errorPath);var Z=o?"data"+(o-1||""):"parentData",v=o?g.dataPathArr[o]:"parentDataProperty";I+=" , "+Z+" , "+v+", rootData) ";var G=I;if(I=f.pop(),c){if(!g.async)throw new Error("async schema referenced by sync schema");A&&(I+=" var "+l+"; "),I+=" try { await "+G+"; ",A&&(I+=" "+l+" = true; "),I+=" } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ",A&&(I+=" "+l+" = false; "),I+=" } ",A&&(I+=" if ("+l+") { ")}else I+=" if (!"+G+") { if (vErrors === null) vErrors = "+u+".errors; else vErrors = vErrors.concat("+u+".errors); errors = vErrors.length; } ",A&&(I+=" else { ")}return I},BRt=function(g,i,n){var I=" ",r=g.schema[i],o=g.schemaPath+g.util.getProperty(i),C=g.errSchemaPath+"/"+i,a=!g.opts.allErrors,A=g.util.copy(g),s="";A.level++;var l="valid"+A.level,c=A.baseId,u=!0,d=r;if(d)for(var h,f=-1,m=d.length-1;f0||h===!1:g.util.schemaHasRules(h,g.RULES.all))&&(u=!1,A.schema=h,A.schemaPath=o+"["+f+"]",A.errSchemaPath=C+"/"+f,I+=" "+g.validate(A)+" ",A.baseId=c,a&&(I+=" if ("+l+") { ",s+="}"));return a&&(u?I+=" if (true) { ":I+=" "+s.slice(0,-1)+" "),I},wRt=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c="valid"+r,u="errs__"+r,d=g.util.copy(g),h="";d.level++;var f="valid"+d.level,m=C.every(function(B){return g.opts.strictKeywords?typeof B=="object"&&Object.keys(B).length>0||B===!1:g.util.schemaHasRules(B,g.RULES.all)});if(m){var b=d.baseId;I+=" var "+u+" = errors; var "+c+" = false; ";var p=g.compositeRule;g.compositeRule=d.compositeRule=!0;var y=C;if(y)for(var Z,v=-1,G=y.length-1;v0||C===!1:g.util.schemaHasRules(C,g.RULES.all);if(I+="var "+u+" = errors;var "+c+";",Z){var v=g.compositeRule;g.compositeRule=d.compositeRule=!0,d.schema=C,d.schemaPath=a,d.errSchemaPath=A,I+=" var "+f+" = false; for (var "+m+" = 0; "+m+" < "+l+".length; "+m+"++) { ",d.errorPath=g.util.getPathExpr(g.errorPath,m,g.opts.jsonPointers,!0);var G=l+"["+m+"]";d.dataPathArr[b]=m;var B=g.validate(d);d.baseId=y,g.util.varOccurences(B,p)<2?I+=" "+g.util.varReplace(B,p,G)+" ":I+=" var "+p+" = "+G+"; "+B+" ",I+=" if ("+f+") break; } ",g.compositeRule=d.compositeRule=v,I+=" "+h+" if (!"+f+") {"}else I+=" if ("+l+".length == 0) {";var S=S||[];S.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'contains' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: {} ",g.opts.messages!==!1&&(I+=" , message: 'should contain a valid item' "),g.opts.verbose&&(I+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var R=I;return I=S.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+R+"]); ":I+=" validate.errors = ["+R+"]; return false; ":I+=" var err = "+R+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } else { ",Z&&(I+=" errors = "+u+"; if (vErrors !== null) { if ("+u+") vErrors.length = "+u+"; else vErrors = null; } "),g.opts.allErrors&&(I+=" } "),I},WRt=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c="errs__"+r,u=g.util.copy(g),d="";u.level++;var h="valid"+u.level,f={},m={},b=g.opts.ownProperties;for(v in C)if(v!="__proto__"){var p=C[v],y=Array.isArray(p)?m:f;y[v]=p}I+="var "+c+" = errors;";var Z=g.errorPath;I+="var missing"+r+";";for(var v in m)if(y=m[v],y.length){if(I+=" if ( "+l+g.util.getProperty(v)+" !== undefined ",b&&(I+=" && Object.prototype.hasOwnProperty.call("+l+", '"+g.util.escapeQuotes(v)+"') "),s){I+=" && ( ";var G=y;if(G)for(var B,S=-1,R=G.length-1;S0||p===!1:g.util.schemaHasRules(p,g.RULES.all))&&(I+=" "+h+" = true; if ( "+l+g.util.getProperty(v)+" !== undefined ",b&&(I+=" && Object.prototype.hasOwnProperty.call("+l+", '"+g.util.escapeQuotes(v)+"') "),I+=") { ",u.schema=p,u.schemaPath=a+g.util.getProperty(v),u.errSchemaPath=A+"/"+g.util.escapeFragment(v),I+=" "+g.validate(u)+" ",u.baseId=F,I+=" } ",s&&(I+=" if ("+h+") { ",d+="}"))}return s&&(I+=" "+d+" if ("+c+" == errors) {"),I},XRt=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c="valid"+r,u=g.opts.$data&&C&&C.$data;u&&(I+=" var schema"+r+" = "+g.util.getData(C.$data,o,g.dataPathArr)+"; ");var d="i"+r,h="schema"+r;u||(I+=" var "+h+" = validate.schema"+a+";"),I+="var "+c+";",u&&(I+=" if (schema"+r+" === undefined) "+c+" = true; else if (!Array.isArray(schema"+r+")) "+c+" = false; else {"),I+=""+c+" = false;for (var "+d+"=0; "+d+"<"+h+".length; "+d+"++) if (equal("+l+", "+h+"["+d+"])) { "+c+" = true; break; }",u&&(I+=" } "),I+=" if (!"+c+") { ";var f=f||[];f.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'enum' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { allowedValues: schema"+r+" } ",g.opts.messages!==!1&&(I+=" , message: 'should be equal to one of the allowed values' "),g.opts.verbose&&(I+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var m=I;return I=f.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+m+"]); ":I+=" validate.errors = ["+m+"]; return false; ":I+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" }",s&&(I+=" else { "),I},TRt=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||"");if(g.opts.format===!1)return s&&(I+=" if (true) { "),I;var c=g.opts.$data&&C&&C.$data,u;c?(I+=" var schema"+r+" = "+g.util.getData(C.$data,o,g.dataPathArr)+"; ",u="schema"+r):u=C;var d=g.opts.unknownFormats,h=Array.isArray(d);if(c){var f="format"+r,m="isObject"+r,b="formatType"+r;I+=" var "+f+" = formats["+u+"]; var "+m+" = typeof "+f+" == 'object' && !("+f+" instanceof RegExp) && "+f+".validate; var "+b+" = "+m+" && "+f+".type || 'string'; if ("+m+") { ",g.async&&(I+=" var async"+r+" = "+f+".async; "),I+=" "+f+" = "+f+".validate; } if ( ",c&&(I+=" ("+u+" !== undefined && typeof "+u+" != 'string') || "),I+=" (",d!="ignore"&&(I+=" ("+u+" && !"+f+" ",h&&(I+=" && self._opts.unknownFormats.indexOf("+u+") == -1 "),I+=") || "),I+=" ("+f+" && "+b+" == '"+n+"' && !(typeof "+f+" == 'function' ? ",g.async?I+=" (async"+r+" ? await "+f+"("+l+") : "+f+"("+l+")) ":I+=" "+f+"("+l+") ",I+=" : "+f+".test("+l+"))))) {"}else{var f=g.formats[C];if(!f){if(d=="ignore")return g.logger.warn('unknown format "'+C+'" ignored in schema at path "'+g.errSchemaPath+'"'),s&&(I+=" if (true) { "),I;if(h&&d.indexOf(C)>=0)return s&&(I+=" if (true) { "),I;throw new Error('unknown format "'+C+'" is used in schema at path "'+g.errSchemaPath+'"')}var m=typeof f=="object"&&!(f instanceof RegExp)&&f.validate,b=m&&f.type||"string";if(m){var p=f.async===!0;f=f.validate}if(b!=n)return s&&(I+=" if (true) { "),I;if(p){if(!g.async)throw new Error("async format in sync schema");var y="formats"+g.util.getProperty(C)+".validate";I+=" if (!(await "+y+"("+l+"))) { "}else{I+=" if (! ";var y="formats"+g.util.getProperty(C);m&&(y+=".validate"),typeof f=="function"?I+=" "+y+"("+l+") ":I+=" "+y+".test("+l+") ",I+=") { "}}var Z=Z||[];Z.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'format' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { format: ",c?I+=""+u:I+=""+g.util.toQuotedString(C),I+=" } ",g.opts.messages!==!1&&(I+=` , message: 'should match format "`,c?I+="' + "+u+" + '":I+=""+g.util.escapeQuotes(C),I+=`"' `),g.opts.verbose&&(I+=" , schema: ",c?I+="validate.schema"+a:I+=""+g.util.toQuotedString(C),I+=" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var v=I;return I=Z.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+v+"]); ":I+=" validate.errors = ["+v+"]; return false; ":I+=" var err = "+v+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } ",s&&(I+=" else { "),I},HRt=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c="valid"+r,u="errs__"+r,d=g.util.copy(g);d.level++;var h="valid"+d.level,f=g.schema.then,m=g.schema.else,b=f!==void 0&&(g.opts.strictKeywords?typeof f=="object"&&Object.keys(f).length>0||f===!1:g.util.schemaHasRules(f,g.RULES.all)),p=m!==void 0&&(g.opts.strictKeywords?typeof m=="object"&&Object.keys(m).length>0||m===!1:g.util.schemaHasRules(m,g.RULES.all)),y=d.baseId;if(b||p){var Z;d.createErrors=!1,d.schema=C,d.schemaPath=a,d.errSchemaPath=A,I+=" var "+u+" = errors; var "+c+" = true; ";var v=g.compositeRule;g.compositeRule=d.compositeRule=!0,I+=" "+g.validate(d)+" ",d.baseId=y,d.createErrors=!0,I+=" errors = "+u+"; if (vErrors !== null) { if ("+u+") vErrors.length = "+u+"; else vErrors = null; } ",g.compositeRule=d.compositeRule=v,b?(I+=" if ("+h+") { ",d.schema=g.schema.then,d.schemaPath=g.schemaPath+".then",d.errSchemaPath=g.errSchemaPath+"/then",I+=" "+g.validate(d)+" ",d.baseId=y,I+=" "+c+" = "+h+"; ",b&&p?(Z="ifClause"+r,I+=" var "+Z+" = 'then'; "):Z="'then'",I+=" } ",p&&(I+=" else { ")):I+=" if (!"+h+") { ",p&&(d.schema=g.schema.else,d.schemaPath=g.schemaPath+".else",d.errSchemaPath=g.errSchemaPath+"/else",I+=" "+g.validate(d)+" ",d.baseId=y,I+=" "+c+" = "+h+"; ",b&&p?(Z="ifClause"+r,I+=" var "+Z+" = 'else'; "):Z="'else'",I+=" } "),I+=" if (!"+c+") { var err = ",g.createErrors!==!1?(I+=" { keyword: 'if' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { failingKeyword: "+Z+" } ",g.opts.messages!==!1&&(I+=` , message: 'should match "' + `+Z+` + '" schema' `),g.opts.verbose&&(I+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ",I+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!g.compositeRule&&s&&(g.async?I+=" throw new ValidationError(vErrors); ":I+=" validate.errors = vErrors; return false; "),I+=" } ",s&&(I+=" else { ")}else s&&(I+=" if (true) { ");return I},NRt=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c="valid"+r,u="errs__"+r,d=g.util.copy(g),h="";d.level++;var f="valid"+d.level,m="i"+r,b=d.dataLevel=g.dataLevel+1,p="data"+b,y=g.baseId;if(I+="var "+u+" = errors;var "+c+";",Array.isArray(C)){var Z=g.schema.additionalItems;if(Z===!1){I+=" "+c+" = "+l+".length <= "+C.length+"; ";var v=A;A=g.errSchemaPath+"/additionalItems",I+=" if (!"+c+") { ";var G=G||[];G.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'additionalItems' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { limit: "+C.length+" } ",g.opts.messages!==!1&&(I+=" , message: 'should NOT have more than "+C.length+" items' "),g.opts.verbose&&(I+=" , schema: false , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var B=I;I=G.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+B+"]); ":I+=" validate.errors = ["+B+"]; return false; ":I+=" var err = "+B+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } ",A=v,s&&(h+="}",I+=" else { ")}var S=C;if(S){for(var R,w=-1,T=S.length-1;w0||R===!1:g.util.schemaHasRules(R,g.RULES.all)){I+=" "+f+" = true; if ("+l+".length > "+w+") { ";var W=l+"["+w+"]";d.schema=R,d.schemaPath=a+"["+w+"]",d.errSchemaPath=A+"/"+w,d.errorPath=g.util.getPathExpr(g.errorPath,w,g.opts.jsonPointers,!0),d.dataPathArr[b]=w;var V=g.validate(d);d.baseId=y,g.util.varOccurences(V,p)<2?I+=" "+g.util.varReplace(V,p,W)+" ":I+=" var "+p+" = "+W+"; "+V+" ",I+=" } ",s&&(I+=" if ("+f+") { ",h+="}")}}if(typeof Z=="object"&&(g.opts.strictKeywords?typeof Z=="object"&&Object.keys(Z).length>0||Z===!1:g.util.schemaHasRules(Z,g.RULES.all))){d.schema=Z,d.schemaPath=g.schemaPath+".additionalItems",d.errSchemaPath=g.errSchemaPath+"/additionalItems",I+=" "+f+" = true; if ("+l+".length > "+C.length+") { for (var "+m+" = "+C.length+"; "+m+" < "+l+".length; "+m+"++) { ",d.errorPath=g.util.getPathExpr(g.errorPath,m,g.opts.jsonPointers,!0);var W=l+"["+m+"]";d.dataPathArr[b]=m;var V=g.validate(d);d.baseId=y,g.util.varOccurences(V,p)<2?I+=" "+g.util.varReplace(V,p,W)+" ":I+=" var "+p+" = "+W+"; "+V+" ",s&&(I+=" if (!"+f+") break; "),I+=" } } ",s&&(I+=" if ("+f+") { ",h+="}")}}else if(g.opts.strictKeywords?typeof C=="object"&&Object.keys(C).length>0||C===!1:g.util.schemaHasRules(C,g.RULES.all)){d.schema=C,d.schemaPath=a,d.errSchemaPath=A,I+=" for (var "+m+" = 0; "+m+" < "+l+".length; "+m+"++) { ",d.errorPath=g.util.getPathExpr(g.errorPath,m,g.opts.jsonPointers,!0);var W=l+"["+m+"]";d.dataPathArr[b]=m;var V=g.validate(d);d.baseId=y,g.util.varOccurences(V,p)<2?I+=" "+g.util.varReplace(V,p,W)+" ":I+=" var "+p+" = "+W+"; "+V+" ",s&&(I+=" if (!"+f+") break; "),I+=" }"}return s&&(I+=" "+h+" if ("+u+" == errors) {"),I},rGe=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,y,l="data"+(o||""),c=g.opts.$data&&C&&C.$data,u;c?(I+=" var schema"+r+" = "+g.util.getData(C.$data,o,g.dataPathArr)+"; ",u="schema"+r):u=C;var d=i=="maximum",h=d?"exclusiveMaximum":"exclusiveMinimum",f=g.schema[h],m=g.opts.$data&&f&&f.$data,b=d?"<":">",p=d?">":"<",y=void 0;if(!(c||typeof C=="number"||C===void 0))throw new Error(i+" must be number");if(!(m||f===void 0||typeof f=="number"||typeof f=="boolean"))throw new Error(h+" must be number or boolean");if(m){var Z=g.util.getData(f.$data,o,g.dataPathArr),v="exclusive"+r,G="exclType"+r,B="exclIsNumber"+r,S="op"+r,R="' + "+S+" + '";I+=" var schemaExcl"+r+" = "+Z+"; ",Z="schemaExcl"+r,I+=" var "+v+"; var "+G+" = typeof "+Z+"; if ("+G+" != 'boolean' && "+G+" != 'undefined' && "+G+" != 'number') { ";var y=h,w=w||[];w.push(I),I="",g.createErrors!==!1?(I+=" { keyword: '"+(y||"_exclusiveLimit")+"' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: {} ",g.opts.messages!==!1&&(I+=" , message: '"+h+" should be boolean' "),g.opts.verbose&&(I+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var T=I;I=w.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+T+"]); ":I+=" validate.errors = ["+T+"]; return false; ":I+=" var err = "+T+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } else if ( ",c&&(I+=" ("+u+" !== undefined && typeof "+u+" != 'number') || "),I+=" "+G+" == 'number' ? ( ("+v+" = "+u+" === undefined || "+Z+" "+b+"= "+u+") ? "+l+" "+p+"= "+Z+" : "+l+" "+p+" "+u+" ) : ( ("+v+" = "+Z+" === true) ? "+l+" "+p+"= "+u+" : "+l+" "+p+" "+u+" ) || "+l+" !== "+l+") { var op"+r+" = "+v+" ? '"+b+"' : '"+b+"='; ",C===void 0&&(y=h,A=g.errSchemaPath+"/"+h,u=Z,c=m)}else{var B=typeof f=="number",R=b;if(B&&c){var S="'"+R+"'";I+=" if ( ",c&&(I+=" ("+u+" !== undefined && typeof "+u+" != 'number') || "),I+=" ( "+u+" === undefined || "+f+" "+b+"= "+u+" ? "+l+" "+p+"= "+f+" : "+l+" "+p+" "+u+" ) || "+l+" !== "+l+") { "}else{B&&C===void 0?(v=!0,y=h,A=g.errSchemaPath+"/"+h,u=f,p+="="):(B&&(u=Math[d?"min":"max"](f,C)),f===(B?u:!0)?(v=!0,y=h,A=g.errSchemaPath+"/"+h,p+="="):(v=!1,R+="="));var S="'"+R+"'";I+=" if ( ",c&&(I+=" ("+u+" !== undefined && typeof "+u+" != 'number') || "),I+=" "+l+" "+p+" "+u+" || "+l+" !== "+l+") { "}}y=y||i;var w=w||[];w.push(I),I="",g.createErrors!==!1?(I+=" { keyword: '"+(y||"_limit")+"' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { comparison: "+S+", limit: "+u+", exclusive: "+v+" } ",g.opts.messages!==!1&&(I+=" , message: 'should be "+R+" ",c?I+="' + "+u:I+=""+u+"'"),g.opts.verbose&&(I+=" , schema: ",c?I+="validate.schema"+a:I+=""+C,I+=" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var T=I;return I=w.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+T+"]); ":I+=" validate.errors = ["+T+"]; return false; ":I+=" var err = "+T+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } ",s&&(I+=" else { "),I},oGe=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,h,l="data"+(o||""),c=g.opts.$data&&C&&C.$data,u;if(c?(I+=" var schema"+r+" = "+g.util.getData(C.$data,o,g.dataPathArr)+"; ",u="schema"+r):u=C,!(c||typeof C=="number"))throw new Error(i+" must be number");var d=i=="maxItems"?">":"<";I+="if ( ",c&&(I+=" ("+u+" !== undefined && typeof "+u+" != 'number') || "),I+=" "+l+".length "+d+" "+u+") { ";var h=i,f=f||[];f.push(I),I="",g.createErrors!==!1?(I+=" { keyword: '"+(h||"_limitItems")+"' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { limit: "+u+" } ",g.opts.messages!==!1&&(I+=" , message: 'should NOT have ",i=="maxItems"?I+="more":I+="fewer",I+=" than ",c?I+="' + "+u+" + '":I+=""+C,I+=" items' "),g.opts.verbose&&(I+=" , schema: ",c?I+="validate.schema"+a:I+=""+C,I+=" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var m=I;return I=f.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+m+"]); ":I+=" validate.errors = ["+m+"]; return false; ":I+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+="} ",s&&(I+=" else { "),I},CGe=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,h,l="data"+(o||""),c=g.opts.$data&&C&&C.$data,u;if(c?(I+=" var schema"+r+" = "+g.util.getData(C.$data,o,g.dataPathArr)+"; ",u="schema"+r):u=C,!(c||typeof C=="number"))throw new Error(i+" must be number");var d=i=="maxLength"?">":"<";I+="if ( ",c&&(I+=" ("+u+" !== undefined && typeof "+u+" != 'number') || "),g.opts.unicode===!1?I+=" "+l+".length ":I+=" ucs2length("+l+") ",I+=" "+d+" "+u+") { ";var h=i,f=f||[];f.push(I),I="",g.createErrors!==!1?(I+=" { keyword: '"+(h||"_limitLength")+"' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { limit: "+u+" } ",g.opts.messages!==!1&&(I+=" , message: 'should NOT be ",i=="maxLength"?I+="longer":I+="shorter",I+=" than ",c?I+="' + "+u+" + '":I+=""+C,I+=" characters' "),g.opts.verbose&&(I+=" , schema: ",c?I+="validate.schema"+a:I+=""+C,I+=" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var m=I;return I=f.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+m+"]); ":I+=" validate.errors = ["+m+"]; return false; ":I+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+="} ",s&&(I+=" else { "),I},aGe=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,h,l="data"+(o||""),c=g.opts.$data&&C&&C.$data,u;if(c?(I+=" var schema"+r+" = "+g.util.getData(C.$data,o,g.dataPathArr)+"; ",u="schema"+r):u=C,!(c||typeof C=="number"))throw new Error(i+" must be number");var d=i=="maxProperties"?">":"<";I+="if ( ",c&&(I+=" ("+u+" !== undefined && typeof "+u+" != 'number') || "),I+=" Object.keys("+l+").length "+d+" "+u+") { ";var h=i,f=f||[];f.push(I),I="",g.createErrors!==!1?(I+=" { keyword: '"+(h||"_limitProperties")+"' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { limit: "+u+" } ",g.opts.messages!==!1&&(I+=" , message: 'should NOT have ",i=="maxProperties"?I+="more":I+="fewer",I+=" than ",c?I+="' + "+u+" + '":I+=""+C,I+=" properties' "),g.opts.verbose&&(I+=" , schema: ",c?I+="validate.schema"+a:I+=""+C,I+=" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var m=I;return I=f.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+m+"]); ":I+=" validate.errors = ["+m+"]; return false; ":I+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+="} ",s&&(I+=" else { "),I},kRt=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c=g.opts.$data&&C&&C.$data,u;if(c?(I+=" var schema"+r+" = "+g.util.getData(C.$data,o,g.dataPathArr)+"; ",u="schema"+r):u=C,!(c||typeof C=="number"))throw new Error(i+" must be number");I+="var division"+r+";if (",c&&(I+=" "+u+" !== undefined && ( typeof "+u+" != 'number' || "),I+=" (division"+r+" = "+l+" / "+u+", ",g.opts.multipleOfPrecision?I+=" Math.abs(Math.round(division"+r+") - division"+r+") > 1e-"+g.opts.multipleOfPrecision+" ":I+=" division"+r+" !== parseInt(division"+r+") ",I+=" ) ",c&&(I+=" ) "),I+=" ) { ";var d=d||[];d.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'multipleOf' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { multipleOf: "+u+" } ",g.opts.messages!==!1&&(I+=" , message: 'should be multiple of ",c?I+="' + "+u:I+=""+u+"'"),g.opts.verbose&&(I+=" , schema: ",c?I+="validate.schema"+a:I+=""+C,I+=" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var h=I;return I=d.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+h+"]); ":I+=" validate.errors = ["+h+"]; return false; ":I+=" var err = "+h+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+="} ",s&&(I+=" else { "),I},YRt=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c="errs__"+r,u=g.util.copy(g);u.level++;var d="valid"+u.level;if(g.opts.strictKeywords?typeof C=="object"&&Object.keys(C).length>0||C===!1:g.util.schemaHasRules(C,g.RULES.all)){u.schema=C,u.schemaPath=a,u.errSchemaPath=A,I+=" var "+c+" = errors; ";var h=g.compositeRule;g.compositeRule=u.compositeRule=!0,u.createErrors=!1;var f;u.opts.allErrors&&(f=u.opts.allErrors,u.opts.allErrors=!1),I+=" "+g.validate(u)+" ",u.createErrors=!0,f&&(u.opts.allErrors=f),g.compositeRule=u.compositeRule=h,I+=" if ("+d+") { ";var m=m||[];m.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'not' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: {} ",g.opts.messages!==!1&&(I+=" , message: 'should NOT be valid' "),g.opts.verbose&&(I+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var b=I;I=m.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+b+"]); ":I+=" validate.errors = ["+b+"]; return false; ":I+=" var err = "+b+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } else { errors = "+c+"; if (vErrors !== null) { if ("+c+") vErrors.length = "+c+"; else vErrors = null; } ",g.opts.allErrors&&(I+=" } ")}else I+=" var err = ",g.createErrors!==!1?(I+=" { keyword: 'not' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: {} ",g.opts.messages!==!1&&(I+=" , message: 'should NOT be valid' "),g.opts.verbose&&(I+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ",I+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s&&(I+=" if (false) { ");return I},KRt=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c="valid"+r,u="errs__"+r,d=g.util.copy(g),h="";d.level++;var f="valid"+d.level,m=d.baseId,b="prevValid"+r,p="passingSchemas"+r;I+="var "+u+" = errors , "+b+" = false , "+c+" = false , "+p+" = null; ";var y=g.compositeRule;g.compositeRule=d.compositeRule=!0;var Z=C;if(Z)for(var v,G=-1,B=Z.length-1;G0||v===!1:g.util.schemaHasRules(v,g.RULES.all))?(d.schema=v,d.schemaPath=a+"["+G+"]",d.errSchemaPath=A+"/"+G,I+=" "+g.validate(d)+" ",d.baseId=m):I+=" var "+f+" = true; ",G&&(I+=" if ("+f+" && "+b+") { "+c+" = false; "+p+" = ["+p+", "+G+"]; } else { ",h+="}"),I+=" if ("+f+") { "+c+" = "+b+" = true; "+p+" = "+G+"; }";return g.compositeRule=d.compositeRule=y,I+=""+h+"if (!"+c+") { var err = ",g.createErrors!==!1?(I+=" { keyword: 'oneOf' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { passingSchemas: "+p+" } ",g.opts.messages!==!1&&(I+=" , message: 'should match exactly one schema in oneOf' "),g.opts.verbose&&(I+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ",I+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!g.compositeRule&&s&&(g.async?I+=" throw new ValidationError(vErrors); ":I+=" validate.errors = vErrors; return false; "),I+="} else { errors = "+u+"; if (vErrors !== null) { if ("+u+") vErrors.length = "+u+"; else vErrors = null; }",g.opts.allErrors&&(I+=" } "),I},xRt=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c=g.opts.$data&&C&&C.$data,u;c?(I+=" var schema"+r+" = "+g.util.getData(C.$data,o,g.dataPathArr)+"; ",u="schema"+r):u=C;var d=c?"(new RegExp("+u+"))":g.usePattern(C);I+="if ( ",c&&(I+=" ("+u+" !== undefined && typeof "+u+" != 'string') || "),I+=" !"+d+".test("+l+") ) { ";var h=h||[];h.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'pattern' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { pattern: ",c?I+=""+u:I+=""+g.util.toQuotedString(C),I+=" } ",g.opts.messages!==!1&&(I+=` , message: 'should match pattern "`,c?I+="' + "+u+" + '":I+=""+g.util.escapeQuotes(C),I+=`"' `),g.opts.verbose&&(I+=" , schema: ",c?I+="validate.schema"+a:I+=""+g.util.toQuotedString(C),I+=" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var f=I;return I=h.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+f+"]); ":I+=" validate.errors = ["+f+"]; return false; ":I+=" var err = "+f+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+="} ",s&&(I+=" else { "),I},FRt=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c="errs__"+r,u=g.util.copy(g),d="";u.level++;var h="valid"+u.level,f="key"+r,m="idx"+r,b=u.dataLevel=g.dataLevel+1,p="data"+b,y="dataProperties"+r,Z=Object.keys(C||{}).filter(x),v=g.schema.patternProperties||{},G=Object.keys(v).filter(x),B=g.schema.additionalProperties,S=Z.length||G.length,R=B===!1,w=typeof B=="object"&&Object.keys(B).length,T=g.opts.removeAdditional,W=R||w||T,V=g.opts.ownProperties,X=g.baseId,N=g.schema.required;if(N&&!(g.opts.$data&&N.$data)&&N.length8)I+=" || validate.schema"+a+".hasOwnProperty("+f+") ";else{var M=Z;if(M)for(var F,$=-1,Q=M.length-1;$0||Pe===!1:g.util.schemaHasRules(Pe,g.RULES.all)){var it=g.util.getProperty(F),ye=l+it,lt=Ye&&Pe.default!==void 0;u.schema=Pe,u.schemaPath=a+it,u.errSchemaPath=A+"/"+g.util.escapeFragment(F),u.errorPath=g.util.getPath(g.errorPath,F,g.opts.jsonPointers),u.dataPathArr[b]=g.util.toQuotedString(F);var ue=g.validate(u);if(u.baseId=X,g.util.varOccurences(ue,p)<2){ue=g.util.varReplace(ue,p,ye);var je=ye}else{var je=p;I+=" var "+p+" = "+ye+"; "}if(lt)I+=" "+ue+" ";else{if(Y&&Y[F]){I+=" if ( "+je+" === undefined ",V&&(I+=" || ! Object.prototype.hasOwnProperty.call("+l+", '"+g.util.escapeQuotes(F)+"') "),I+=") { "+h+" = false; ";var fe=g.errorPath,oe=A,He=g.util.escapeQuotes(F);g.opts._errorDataPathProperty&&(g.errorPath=g.util.getPath(fe,F,g.opts.jsonPointers)),A=g.errSchemaPath+"/required";var pe=pe||[];pe.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'required' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { missingProperty: '"+He+"' } ",g.opts.messages!==!1&&(I+=" , message: '",g.opts._errorDataPathProperty?I+="is a required property":I+="should have required property \\'"+He+"\\'",I+="' "),g.opts.verbose&&(I+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var ae=I;I=pe.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+ae+"]); ":I+=" validate.errors = ["+ae+"]; return false; ":I+=" var err = "+ae+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",A=oe,g.errorPath=fe,I+=" } else { "}else s?(I+=" if ( "+je+" === undefined ",V&&(I+=" || ! Object.prototype.hasOwnProperty.call("+l+", '"+g.util.escapeQuotes(F)+"') "),I+=") { "+h+" = true; } else { "):(I+=" if ("+je+" !== undefined ",V&&(I+=" && Object.prototype.hasOwnProperty.call("+l+", '"+g.util.escapeQuotes(F)+"') "),I+=" ) { ");I+=" "+ue+" } "}}s&&(I+=" if ("+h+") { ",d+="}")}}if(G.length){var Ce=G;if(Ce)for(var j,Ze=-1,Te=Ce.length-1;Ze0||Pe===!1:g.util.schemaHasRules(Pe,g.RULES.all)){u.schema=Pe,u.schemaPath=g.schemaPath+".patternProperties"+g.util.getProperty(j),u.errSchemaPath=g.errSchemaPath+"/patternProperties/"+g.util.escapeFragment(j),V?I+=" "+y+" = "+y+" || Object.keys("+l+"); for (var "+m+"=0; "+m+"<"+y+".length; "+m+"++) { var "+f+" = "+y+"["+m+"]; ":I+=" for (var "+f+" in "+l+") { ",I+=" if ("+g.usePattern(j)+".test("+f+")) { ",u.errorPath=g.util.getPathExpr(g.errorPath,f,g.opts.jsonPointers);var ye=l+"["+f+"]";u.dataPathArr[b]=f;var ue=g.validate(u);u.baseId=X,g.util.varOccurences(ue,p)<2?I+=" "+g.util.varReplace(ue,p,ye)+" ":I+=" var "+p+" = "+ye+"; "+ue+" ",s&&(I+=" if (!"+h+") break; "),I+=" } ",s&&(I+=" else "+h+" = true; "),I+=" } ",s&&(I+=" if ("+h+") { ",d+="}")}}}return s&&(I+=" "+d+" if ("+c+" == errors) {"),I},ERt=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c="errs__"+r,u=g.util.copy(g),d="";u.level++;var h="valid"+u.level;if(I+="var "+c+" = errors;",g.opts.strictKeywords?typeof C=="object"&&Object.keys(C).length>0||C===!1:g.util.schemaHasRules(C,g.RULES.all)){u.schema=C,u.schemaPath=a,u.errSchemaPath=A;var f="key"+r,m="idx"+r,b="i"+r,p="' + "+f+" + '",y=u.dataLevel=g.dataLevel+1,Z="data"+y,v="dataProperties"+r,G=g.opts.ownProperties,B=g.baseId;G&&(I+=" var "+v+" = undefined; "),G?I+=" "+v+" = "+v+" || Object.keys("+l+"); for (var "+m+"=0; "+m+"<"+v+".length; "+m+"++) { var "+f+" = "+v+"["+m+"]; ":I+=" for (var "+f+" in "+l+") { ",I+=" var startErrs"+r+" = errors; ";var S=f,R=g.compositeRule;g.compositeRule=u.compositeRule=!0;var w=g.validate(u);u.baseId=B,g.util.varOccurences(w,Z)<2?I+=" "+g.util.varReplace(w,Z,S)+" ":I+=" var "+Z+" = "+S+"; "+w+" ",g.compositeRule=u.compositeRule=R,I+=" if (!"+h+") { for (var "+b+"=startErrs"+r+"; "+b+"0||y===!1:g.util.schemaHasRules(y,g.RULES.all))||(h[h.length]=m)}}else var h=C;if(u||h.length){var Z=g.errorPath,v=u||h.length>=g.opts.loopRequired,G=g.opts.ownProperties;if(s)if(I+=" var missing"+r+"; ",v){u||(I+=" var "+d+" = validate.schema"+a+"; ");var B="i"+r,S="schema"+r+"["+B+"]",R="' + "+S+" + '";g.opts._errorDataPathProperty&&(g.errorPath=g.util.getPathExpr(Z,S,g.opts.jsonPointers)),I+=" var "+c+" = true; ",u&&(I+=" if (schema"+r+" === undefined) "+c+" = true; else if (!Array.isArray(schema"+r+")) "+c+" = false; else {"),I+=" for (var "+B+" = 0; "+B+" < "+d+".length; "+B+"++) { "+c+" = "+l+"["+d+"["+B+"]] !== undefined ",G&&(I+=" && Object.prototype.hasOwnProperty.call("+l+", "+d+"["+B+"]) "),I+="; if (!"+c+") break; } ",u&&(I+=" } "),I+=" if (!"+c+") { ";var w=w||[];w.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'required' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { missingProperty: '"+R+"' } ",g.opts.messages!==!1&&(I+=" , message: '",g.opts._errorDataPathProperty?I+="is a required property":I+="should have required property \\'"+R+"\\'",I+="' "),g.opts.verbose&&(I+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var T=I;I=w.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+T+"]); ":I+=" validate.errors = ["+T+"]; return false; ":I+=" var err = "+T+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } else { "}else{I+=" if ( ";var W=h;if(W)for(var V,B=-1,X=W.length-1;B 1) { ";var h=g.schema.items&&g.schema.items.type,f=Array.isArray(h);if(!h||h=="object"||h=="array"||f&&(h.indexOf("object")>=0||h.indexOf("array")>=0))I+=" outer: for (;i--;) { for (j = i; j--;) { if (equal("+l+"[i], "+l+"[j])) { "+c+" = false; break outer; } } } ";else{I+=" var itemIndices = {}, item; for (;i--;) { var item = "+l+"[i]; ";var m="checkDataType"+(f?"s":"");I+=" if ("+g.util[m](h,"item",g.opts.strictNumbers,!0)+") continue; ",f&&(I+=` if (typeof item == 'string') item = '"' + item; `),I+=" if (typeof itemIndices[item] == 'number') { "+c+" = false; j = itemIndices[item]; break; } itemIndices[item] = i; } "}I+=" } ",u&&(I+=" } "),I+=" if (!"+c+") { ";var b=b||[];b.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'uniqueItems' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { i: i, j: j } ",g.opts.messages!==!1&&(I+=" , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' "),g.opts.verbose&&(I+=" , schema: ",u?I+="validate.schema"+a:I+=""+C,I+=" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var p=I;I=b.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+p+"]); ":I+=" validate.errors = ["+p+"]; return false; ":I+=" var err = "+p+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } ",s&&(I+=" else { ")}else s&&(I+=" if (true) { ");return I},zRt={$ref:vRt,allOf:BRt,anyOf:wRt,$comment:SRt,const:RRt,contains:VRt,dependencies:WRt,enum:XRt,format:TRt,if:HRt,items:NRt,maximum:rGe,minimum:rGe,maxItems:oGe,minItems:oGe,maxLength:CGe,minLength:CGe,maxProperties:aGe,minProperties:aGe,multipleOf:kRt,not:YRt,oneOf:KRt,pattern:xRt,properties:FRt,propertyNames:ERt,required:DRt,uniqueItems:MRt,validate:zDe},sGe=zRt,iU=R1.toHash,PRt=function(){var g=[{type:"number",rules:[{maximum:["exclusiveMaximum"]},{minimum:["exclusiveMinimum"]},"multipleOf","format"]},{type:"string",rules:["maxLength","minLength","pattern","format"]},{type:"array",rules:["maxItems","minItems","items","contains","uniqueItems"]},{type:"object",rules:["maxProperties","minProperties","required","dependencies","propertyNames",{properties:["additionalProperties","patternProperties"]}]},{rules:["$ref","const","enum","not","anyOf","oneOf","allOf","if"]}],i=["type","$comment"],n=["$schema","$id","id","$data","$async","title","description","default","definitions","examples","readOnly","writeOnly","contentMediaType","contentEncoding","additionalItems","then","else"],I=["number","integer","string","array","object","boolean","null"];return g.all=iU(i),g.types=iU(I),g.forEach(function(r){r.rules=r.rules.map(function(o){var C;if(typeof o=="object"){var a=Object.keys(o)[0];C=o[a],o=a,C.forEach(function(s){i.push(s),g.all[s]=!0})}i.push(o);var A=g.all[o]={keyword:o,code:sGe[o],implements:C};return A}),g.all.$comment={keyword:"$comment",code:sGe.$comment},r.type&&(g.types[r.type]=r)}),g.keywords=iU(i.concat(n)),g.custom={},g},AGe=["multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","additionalItems","maxItems","minItems","uniqueItems","maxProperties","minProperties","required","additionalProperties","enum","format","const"],_Rt=function(e,g){for(var i=0;i{g(i,n,I),IF(i,g)}):"views"in e&&e.views.forEach(i=>IF(i,g))}function FB(e,g){"tracks"in e?e.tracks.forEach(i=>{g(i),FB(i,g)}):"views"in e&&e.views.forEach(i=>{g(i),FB(i,g)})}function lMe(e,g){"tracks"in e||(g(e),e.views.forEach(i=>{lMe(i,g)}))}function LVt(e){if(kDe(e)){const i={...e,tracks:void 0,id:void 0};return e.tracks.filter(n=>!n._invalidTrack).map(n=>Object.assign(JSON.parse(JSON.stringify(i)),n))}const g=[];return oSt(e)?e.tracks.filter(i=>!i._invalidTrack).map(i=>{if("alignment"in i)g.push({...i,_overlay:[...i.tracks],tracks:void 0,alignment:void 0});else{const n={...e,tracks:void 0,id:void 0},I=Object.assign(JSON.parse(JSON.stringify(n)),i);g.push(I)}}):g.push({...e,_overlay:[...e.tracks.filter(i=>!i._invalidTrack)],tracks:void 0,alignment:void 0}),JSON.parse(JSON.stringify(g))}function W6(e,g){if(g?(e.assembly===void 0&&(e.assembly=g.assembly),e.layout===void 0&&(e.layout=g.layout),e.orientation===void 0&&(e.orientation=g.orientation),e.static===void 0&&(e.static=g.static!==void 0?g.static:!1),e.zoomLimits===void 0&&(e.zoomLimits=g.zoomLimits),e.xDomain===void 0&&(e.xDomain=g.xDomain),e.yDomain===void 0&&(e.yDomain=g.yDomain),e.linkingId===void 0&&(e.linkingId=g.linkingId),e.centerRadius===void 0&&(e.centerRadius=g.centerRadius),e.spacing===void 0&&!("tracks"in e)&&(e.spacing=g.spacing),e.xOffset===void 0&&(e.xOffset=g.xOffset),e.yOffset===void 0&&(e.yOffset=g.yOffset),"views"in e&&"arrangement"in g&&e.arrangement===void 0&&(e.arrangement=g.arrangement),e.style=IU(g.style,e.style)):(e.assembly===void 0&&(e.assembly="hg38"),e.layout===void 0&&(e.layout="linear"),e.orientation===void 0&&(e.orientation="horizontal"),e.static===void 0&&(e.static=!1),e.zoomLimits===void 0&&(e.zoomLimits=[1,null]),e.centerRadius===void 0&&(e.centerRadius=TDe),e.spacing===void 0&&(e.spacing=kK),"views"in e&&e.arrangement===void 0&&(e.arrangement="vertical"),e.xOffset===void 0&&(e.xOffset=0),e.yOffset===void 0&&(e.yOffset=0)),e.id||(e.id=sr()),"tracks"in e){let i=LVt(e);i=iSt(i);const n=sr();i.forEach((I,r,o)=>{var C,a,A;if(I.id||(I.id=sr()),I.width||(I.width=Pr(I)?jZe:G1t),I.height||(I.height=Pr(I)?jZe:Z1t),"displacement"in I)if(((C=I.displacement)==null?void 0:C.type)==="pile"&&I.row===void 0&&pt(I.x)&&I.x.field&&pt(I.xe)&&I.xe.field){const s=sr(),l=I.x.field,c=I.xe.field,u=I.displacement.padding,d={type:"displace",newField:s,boundingBox:{startField:l,endField:c,padding:u},method:"pile"};I.dataTransform||(I.dataTransform=[]),I.dataTransform=[...I.dataTransform,d],I.row={field:s,type:"nominal"}}else(a=I.displacement)==null||a.type;if(I.layout&&(I.layout=void 0),I.zoomLimits&&(I.zoomLimits=void 0),I.assembly||(I.assembly=e.assembly),I.layout||(I.layout=e.layout),I.orientation||(I.orientation=e.orientation),I.static===void 0&&(I.static=e.static!==void 0?e.static:!1),I.zoomLimits||(I.zoomLimits=e.zoomLimits),I.layout=="circular"&&dT(I)){I._invalidTrack=!0;return}if(I.style=IU(e.style,I.style),eI(I)&&(I._overlay=I._overlay.filter(s=>!("type"in s&&s.type=="dummy-track")),I._overlay.forEach(s=>{s.style=IU(I.style,s.style)})),(I.layout==="circular"||Pr(I))&&I.orientation==="vertical"&&(I.orientation="horizontal"),Pr(I)&&(I.layout="linear",(_a(I)||eI(I))&&pt(I.y)&&!I.y.domain?I.y.domain=e.yDomain:eI(I)&&I._overlay.forEach(s=>{pt(s.y)&&!s.y.domain&&(s.y.domain=e.yDomain)})),(_a(I)||eI(I))&&pt(I.x)&&!I.x.domain?I.x.domain=e.xDomain:eI(I)&&I._overlay.forEach(s=>{pt(s.x)&&!s.x.domain&&(s.x.domain=e.xDomain)}),(_a(I)||eI(I))&&pt(I.x)&&!I.x.linkingId)I.x.linkingId=(A=e.linkingId)!=null?A:n;else if(eI(I)){let s=!1;I._overlay.forEach(l=>{var c;s||pt(l.x)&&!l.x.linkingId&&(l.x.linkingId=(c=e.linkingId)!=null?c:n,s=!0)})}r===0&&(I.overlayOnPreviousTrack=!1),(r===0||r!==0&&i.slice(0,r).filter(s=>!s.overlayOnPreviousTrack).length===1&&I.overlayOnPreviousTrack===!0)&&((_a(I)||eI(I))&&pt(I.x)&&!I.x.axis?I.orientation==="vertical"?I.x.axis="left":I.x.axis="top":eI(I)&&I._overlay.forEach(s=>{pt(s.x)&&!s.x.axis&&(I.orientation==="vertical"?s.x.axis="left":s.x.axis="top")})),(_a(I)||eI(I))&&pt(I.x)&&I.x.axis&&I.x.axis!=="none"?I.orientation==="vertical"?I.x.axis==="top"?I.x.axis="left":I.x.axis==="bottom"&&(I.x.axis="right"):I.x.axis==="left"?I.x.axis="top":I.x.axis==="right"&&(I.x.axis="bottom"):eI(I)&&I._overlay.forEach(s=>{pt(s.x)&&s.x.axis&&s.x.axis!=="none"&&(I.orientation==="vertical"?s.x.axis==="top"?s.x.axis="left":s.x.axis==="bottom"&&(s.x.axis="right"):s.x.axis==="left"?s.x.axis="top":s.x.axis==="right"&&(s.x.axis="bottom"))}),r!==0&&(r===o.length-1&&o.slice(0,r+1).filter(s=>s.overlayOnPreviousTrack).lengths.overlayOnPreviousTrack).length===o.length-r-1&&o.slice(0,r+1).filter(s=>s.overlayOnPreviousTrack).length{s.mark==="withinLink"&&s.flipY===void 0&&(s.flipY=!0)}))),I.overlayOnPreviousTrack&&o[r-1]&&(I.width=o[r-1].width,I.height=o[r-1].height,I.layout=o[r-1].layout,I.assembly=o[r-1].assembly)}),i=i.filter(I=>!I._invalidTrack),e.tracks=i}else e.views.forEach(i=>{W6(i,e)})}function UVt(e,g){return{data:{type:"vector",url:"",column:e,value:g},mark:"bar",x:{field:e,type:"genomic",axis:"top"},y:{field:g,type:"quantitative"},width:400,height:100}}function QVt(e,g,i,n){return n&&n.length<10?{data:{type:"multivec",url:"",row:e,column:g,value:i,categories:n},mark:"bar",x:{field:g,type:"genomic",axis:"top"},y:{field:i,type:"quantitative"},row:{field:e,type:"nominal",legend:!0},color:{field:e,type:"nominal"},width:400,height:100}:{data:{type:"multivec",url:"",row:e,column:g,value:i,categories:n},mark:"rect",x:{field:g,type:"genomic",axis:"top"},row:{field:e,type:"nominal",legend:!0},color:{field:i,type:"quantitative"},width:400,height:100}}function jVt(e){IF(e,(g,i,n)=>{var I,r,o,C,a;if(!(!("data"in g)||!g.data||!eCe(g.data))&&!("alignment"in g)&&CSt(g))switch(g.data.type){case"vector":case"bigwig":n[i]=Object.assign(UVt((I=g.data.column)!=null?I:"position",(r=g.data.value)!=null?r:"value"),g);break;case"multivec":n[i]=Object.assign(QVt((o=g.data.row)!=null?o:"category",(C=g.data.column)!=null?C:"position",(a=g.data.value)!=null?a:"value",g.data.categories),g);break}})}const rU={chr1:248956422,chr2:242193529,chr3:198295559,chr4:190214555,chr5:181538259,chr6:170805979,chr7:159345973,chr8:145138636,chr9:138394717,chr10:133797422,chr11:135086622,chr12:133275309,chr13:114364328,chr14:107043718,chr15:101991189,chr16:90338345,chr17:83257441,chr18:80373285,chr19:58617616,chr20:64444167,chr21:46709983,chr22:50818468,chrX:156040895,chrY:57227415},oU={chr1:249250621,chr2:243199373,chr3:198022430,chr4:191154276,chr5:180915260,chr6:171115067,chr7:159138663,chr8:146364022,chr9:141213431,chr10:135534747,chr11:135006516,chr12:133851895,chr13:115169878,chr14:107349540,chr15:102531392,chr16:90354753,chr17:81195210,chr18:78077248,chr19:59128983,chr20:63025520,chr21:48129895,chr22:51304566,chrX:155270560,chrY:59373566,chrM:16571},CU={chr1:247249719,chr2:242951149,chr3:199501827,chr4:191273063,chr5:180857866,chr6:170899992,chr7:158821424,chr8:146274826,chr9:140273252,chr10:135374737,chr11:134452384,chr12:132349534,chr13:114142980,chr14:106368585,chr15:100338915,chr16:88827254,chr17:78774742,chr18:76117153,chr19:63811651,chr20:62435964,chr21:46944323,chr22:49691432,chrX:154913754,chrY:57772954,chrM:16571},aU={chr1:245522847,chr2:243018229,chr3:199505740,chr4:191411218,chr5:180857866,chr6:170975699,chr7:158628139,chr8:146274826,chr9:138429268,chr10:135413628,chr11:134452384,chr12:132449811,chr13:114142980,chr14:106368585,chr15:100338915,chr16:88827254,chr17:78774742,chr18:76117153,chr19:63811651,chr20:62435964,chr21:46944323,chr22:49554710,chrX:154824264,chrY:57701691,chrM:16571},sU={chr1:246127941,chr2:243615958,chr3:199344050,chr4:191731959,chr5:181034922,chr6:170914576,chr7:158545518,chr8:146308819,chr9:136372045,chr10:135037215,chr11:134482954,chr12:132078379,chr13:113042980,chr14:105311216,chr15:100256656,chr16:90041932,chr17:81860266,chr18:76115139,chr19:63811651,chr20:63741868,chr21:46976097,chr22:49396972,chrX:153692391,chrY:50286555,chrM:16571},AU={chr1:195471971,chr2:182113224,chr3:160039680,chr4:156508116,chr5:151834684,chr6:149736546,chr7:145441459,chr8:129401213,chr9:124595110,chr10:130694993,chr11:122082543,chr12:120129022,chr13:120421639,chr14:124902244,chr15:104043685,chr16:98207768,chr17:94987271,chr18:90702639,chr19:61431566,chrX:171031299,chrY:91744698,chrM:16299},lU={chr1:197195432,chr2:181748087,chr3:159599783,chr4:155630120,chr5:152537259,chr6:149517037,chr7:152524553,chr8:131738871,chr9:124076172,chr10:129993255,chr11:121843856,chr12:121257530,chr13:120284312,chr14:125194864,chr15:103494974,chr16:98319150,chr17:95272651,chr18:90772031,chr19:61342430,chrX:166650296,chrY:15902555,chrM:16299};function EZ(e,g,i=!1){const n=Object.entries(In(g).interval),I={chromosome:"unknown",position:1/0},r={chromosome:"unknown",position:0};for(const o of n){const[C,a]=o,[A,s]=a;if(A<=e&&er.position&&(r.chromosome=C,r.position=s)}return i?en.join(" ")).join(` +`),i=new Blob([g],{type:"text/tsv"});return URL.createObjectURL(i)}function In(e){if(e&&typeof e=="string"&&e in cU)return cU[e];if(Array.isArray(e)&&e.length!==0){const g=Object.fromEntries(e);return{size:g,interval:Nh(g),total:kh(g),path:$Vt(e)}}else return cU.hg38}const vh=e=>`https://s3.amazonaws.com/gosling-lang.org/data/${e}.chrom.sizes`,cU=Object.freeze({hg38:{size:rU,interval:Nh(rU),total:kh(rU),path:vh("hg38")},hg19:{size:oU,interval:Nh(oU),total:kh(oU),path:vh("hg19")},hg18:{size:CU,interval:Nh(CU),total:kh(CU),path:vh("hg18")},hg17:{size:aU,interval:Nh(aU),total:kh(aU),path:vh("hg17")},hg16:{size:sU,interval:Nh(sU),total:kh(sU),path:vh("hg16")},mm10:{size:AU,interval:Nh(AU),total:kh(AU),path:vh("mm10")},mm9:{size:lU,interval:Nh(lU),total:kh(lU),path:vh("mm9")},unknown:{size:{chr:Number.MAX_VALUE},interval:{chr:[0,Number.MAX_VALUE]},total:Number.MAX_VALUE,path:vh("hg38")}});function qVt(e="hg38"){const g={autocompleteServer:"https://server.gosling-lang.org/api/v1",chromInfoServer:"https://server.gosling-lang.org/api/v1",chromInfoId:e};switch(e){case"hg19":return{...g,autocompleteId:"gene-annotation-hg19"};case"mm10":return{...g,autocompleteId:"gene-annotation-mm10"};case"mm9":return{...g,autocompleteServer:"https://higlass.io/api/v1",chromInfoServer:"https://higlass.io/api/v1",autocompleteId:"GUm5aBiLRCyz2PsBea7Yzg"};case"hg38":default:return{...g,autocompleteId:"gene-annotation"}}}function Nh(e){const g={};return Object.keys(e).reduce((i,n)=>(g[n]=[i,i+e[n]],i+e[n]),0),g}function kh(e){return Object.values(e).reduce((g,i)=>g+i,0)}function e2t(e){const[g,i]=e.split(":");if(i){const[n,I]=i.split("-").map(r=>+r.replace(/,/g,""));if(!Number.isNaN(n)&&!Number.isNaN(I))return{chromosome:g,start:n,end:I}}return{chromosome:g}}class sCe{constructor(g,i,n){this.chromosome=g,this.start=i,this.end=n}static fromString(g){const i=e2t(g);return new sCe(i.chromosome,i.start,i.end)}toAbsoluteCoordinates(g,i=0){const n=In(g),I=n.size[this.chromosome],r=n.interval[this.chromosome];if(I===void 0||r===void 0)throw new Error(`Chromosome name ${this.chromosome} is not valid`);let{start:o,end:C}=this;(o===void 0||C===void 0)&&([o,C]=[1,I]);const a=r[0];return[o+a-i,C+a+i]}}function cMe(e,[g,i],n){const{x:I,xe:r,x1:o,x1e:C}=n,a=[I,r,o,C].filter(A=>A);return e.filter(A=>{if(a.length===0)return!0;if(a.length===1){const s=+A[a[0]];return typeof s=="number"&&g+A[u]).filter(u=>!isNaN(u)),l=Math.min(...s),c=Math.max(...s);return g<=c&&l<=i}})}Noe(e=>e.pos).left;function X6(e,g,i){return Array.isArray(g)||(i?e=e.replace(i,"chr"):e.includes("chr")||(e=`chr${e}`)),e}class uMe extends XDe{constructor(){super(...arguments),y1t(this,"read",async(g,i=0,n,I=0,r={})=>{const{headers:o={},signal:C,overrides:a={}}=r;n<1/0?o.range=`bytes=${I}-${I+n}`:n===1/0&&I!==0&&(o.range=`bytes=${I}-`);const A={...this.baseOverrides,...a,headers:{...o,...a.headers,...this.baseOverrides.headers},method:"GET",redirect:"follow",mode:"cors",signal:C},s=await this.fetch(this.url,A);if(!s.ok)throw new Error(`HTTP ${s.status} ${s.statusText} ${this.url}`);if(s.status===200||s.status===206){const l=await this.getBufferFromResponse(s),c=l.copy(g,i,0,Math.min(n,l.length)),u=s.headers.get("content-range"),d=/\/(\d+)$/.exec(u||"");return d&&d[1]&&(this._stat={size:parseInt(d[1],10)}),{bytesRead:c,buffer:g}}throw new Error(`HTTP ${s.status} fetching ${this.url}`)})}}window.higlassTracks=window.higlassTracks||{};window.higlassTracksByType=window.higlassTracksByType||{};window.higlassDataFetchersByType=window.higlassDataFetchersByType||{};const uGe=()=>Math.random().toString(36).substring(2,8),t2t=(e,{force:g=!1}={})=>{let i=uGe();for(;window.higlassTracks[i];)i=uGe();e.name=i,window.higlassTracks[e.name]=e,window.higlassTracksByType[e.config.type]&&!g?console.warn(`A track with the same type (${e.config.type}) was already registered. To override it, set force to true.`):window.higlassTracksByType[e.config.type]=e},g2t=(e,{force:g=!1}={})=>{window.higlassDataFetchersByType[e.config.type]&&!g?console.warn(`A data fetcher with the same type (${e.config.type}) was already registered. To override it, set force to true.`):window.higlassDataFetchersByType[e.config.type]=e},Zp=(e,g={})=>{const{pluginType:i="track"}=g;i==="track"?t2t(e,g):i==="dataFetcher"&&g2t(e,g)};var fT={},T6={exports:{}},dGe=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(dGe){var hGe=new Uint8Array(16);T6.exports=function(){return dGe(hGe),hGe}}else{var fGe=new Array(16);T6.exports=function(){for(var g=0,i;g<16;g++)g&3||(i=Math.random()*4294967296),fGe[g]=i>>>((g&3)<<3)&255;return fGe}}var i2t=T6.exports,dMe=[];for(var hk=0;hk<256;++hk)dMe[hk]=(hk+256).toString(16).substr(1);function n2t(e,g){var i=g||0,n=dMe;return[n[e[i++]],n[e[i++]],n[e[i++]],n[e[i++]],"-",n[e[i++]],n[e[i++]],"-",n[e[i++]],n[e[i++]],"-",n[e[i++]],n[e[i++]],"-",n[e[i++]],n[e[i++]],n[e[i++]],n[e[i++]],n[e[i++]],n[e[i++]]].join("")}var I2t=n2t,r2t=i2t,o2t=I2t;function C2t(e,g,i){var n=g&&i||0;typeof e=="string"&&(g=e==="binary"?new Array(16):null,e=null),e=e||{};var I=e.random||(e.rng||r2t)();if(I[6]=I[6]&15|64,I[8]=I[8]&63|128,g)for(var r=0;r<16;++r)g[n+r]=I[r];return g||o2t(I)}var a2t=C2t,H6=[],hMe={};for(var DZ=0;DZ<256;DZ++)H6[DZ]=(DZ+256).toString(16).substr(1),hMe[H6[DZ]]=DZ;function s2t(e,g,i){var n=g&&i||0,I=0;for(g=g||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(r){I<16&&(g[n+I++]=hMe[r])});I<16;)g[n+I++]=0;return g}function A2t(e,g){var i=g||0,n=H6;return n[e[i++]]+n[e[i++]]+n[e[i++]]+n[e[i++]]+"-"+n[e[i++]]+n[e[i++]]+"-"+n[e[i++]]+n[e[i++]]+"-"+n[e[i++]]+n[e[i++]]+"-"+n[e[i++]]+n[e[i++]]+n[e[i++]]+n[e[i++]]+n[e[i++]]+n[e[i++]]}var l2t={parse:s2t,unparse:A2t},fMe=a2t,mMe=l2t;fT.encode=function(e){var g=mMe.parse(e),i=new Buffer(g).toString("base64"),n=i.replace(/\+/g,"-").replace(/\//g,"_").substring(0,22);return n};fT.decode=function(e){var g=e.replace(/-/g,"+").replace(/_/g,"/")+"==";return mMe.unparse(new Buffer(g,"base64"))};fT.v4=function(){var e=fMe(null,new Buffer(16)),g=e.toString("base64"),i=g.replace(/\+/g,"-").replace(/\//g,"_").substring(0,22);return i};fT.nice=function(){var e=fMe(null,new Buffer(16));e[0]=e[0]&127;var g=e.toString("base64"),i=g.replace(/\+/g,"-").replace(/\//g,"_").substring(0,22);return i};var c2t=fT;const u2t=Ba(c2t);var d2t=function(){function e(g,i){for(var n=0;n1?i-1:0),I=1;Ii;){if(n-i>600){var r=n-i+1,o=g-i+1,C=Math.log(r),a=.5*Math.exp(2*C/3),A=.5*Math.sqrt(C*a*(r-a)/r)*(o-r/2<0?-1:1),s=Math.max(i,Math.floor(g-o*a/r+A)),l=Math.min(n,Math.floor(g+(r-o)*a/r+A));pMe(e,g,s,l,I)}var c=e[g],u=i,d=n;for(IR(e,i,g),I(e[n],c)>0&&IR(e,i,n);u0;)d--}I(e[i],c)===0?IR(e,i,d):(d++,IR(e,d,n)),d<=g&&(i=d+1),g<=d&&(n=d-1)}}function IR(e,g,i){var n=e[g];e[g]=e[i],e[i]=n}function B2t(e,g){return eg?1:0}class w2t{constructor(g=9){this._maxEntries=Math.max(4,g),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(g){let i=this.data;const n=[];if(!mk(g,i))return n;const I=this.toBBox,r=[];for(;i;){for(let o=0;o=0&&r[i].children.length>this._maxEntries;)this._split(r,i),i--;this._adjustParentBBoxes(I,r,i)}_split(g,i){const n=g[i],I=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,I);const o=this._chooseSplitIndex(n,r,I),C=wG(n.children.splice(o,n.children.length-o));C.height=n.height,C.leaf=n.leaf,MZ(n,this.toBBox),MZ(C,this.toBBox),i?g[i-1].children.push(C):this._splitRoot(n,C)}_splitRoot(g,i){this.data=wG([g,i]),this.data.height=g.height+1,this.data.leaf=!1,MZ(this.data,this.toBBox)}_chooseSplitIndex(g,i,n){let I,r=1/0,o=1/0;for(let C=i;C<=n-i;C++){const a=pV(g,0,C,this.toBBox),A=pV(g,C,n,this.toBBox),s=X2t(a,A),l=uU(a)+uU(A);s=i;A--){const s=g.children[A];bV(C,g.leaf?r(s):s),a+=fk(C)}return a}_adjustParentBBoxes(g,i,n){for(let I=n;I>=0;I--)bV(i[I],g)}_condense(g){for(let i=g.length-1,n;i>=0;i--)g[i].children.length===0?i>0?(n=g[i-1].children,n.splice(n.indexOf(g[i]),1)):this.clear():MZ(g[i],this.toBBox)}}function S2t(e,g,i){if(!i)return g.indexOf(e);for(let n=0;n=e.minX&&g.maxY>=e.minY}function wG(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function mGe(e,g,i,n,I){const r=[g,i];for(;r.length;){if(i=r.pop(),g=r.pop(),i-g<=n)continue;const o=g+Math.ceil((i-g)/n/2)*n;v2t(e,o,g,i,I),r.push(g,o,o,i)}}function T2t(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function rF(e,g){if((i=(e=g?e.toExponential(g-1):e.toExponential()).indexOf("e"))<0)return null;var i,n=e.slice(0,i);return[n.length>1?n[0]+n.slice(2):n,+e.slice(i+1)]}function EB(e){return e=rF(Math.abs(e)),e?e[1]:NaN}function H2t(e,g){return function(i,n){for(var I=i.length,r=[],o=0,C=e[0],a=0;I>0&&C>0&&(a+C+1>n&&(C=Math.max(1,n-a)),r.push(i.substring(I-=C,I+C)),!((a+=C+1)>n));)C=e[o=(o+1)%e.length];return r.reverse().join(g)}}function N2t(e){return function(g){return g.replace(/[0-9]/g,function(i){return e[+i]})}}var k2t=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Rb(e){if(!(g=k2t.exec(e)))throw new Error("invalid format: "+e);var g;return new ACe({fill:g[1],align:g[2],sign:g[3],symbol:g[4],zero:g[5],width:g[6],comma:g[7],precision:g[8]&&g[8].slice(1),trim:g[9],type:g[10]})}Rb.prototype=ACe.prototype;function ACe(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}ACe.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Y2t(e){e:for(var g=e.length,i=1,n=-1,I;i0&&(n=0);break}return n>0?e.slice(0,n)+e.slice(I+1):e}var bMe;function K2t(e,g){var i=rF(e,g);if(!i)return e+"";var n=i[0],I=i[1],r=I-(bMe=Math.max(-8,Math.min(8,Math.floor(I/3)))*3)+1,o=n.length;return r===o?n:r>o?n+new Array(r-o+1).join("0"):r>0?n.slice(0,r)+"."+n.slice(r):"0."+new Array(1-r).join("0")+rF(e,Math.max(0,g+r-1))[0]}function pGe(e,g){var i=rF(e,g);if(!i)return e+"";var n=i[0],I=i[1];return I<0?"0."+new Array(-I).join("0")+n:n.length>I+1?n.slice(0,I+1)+"."+n.slice(I+1):n+new Array(I-n.length+2).join("0")}const bGe={"%":(e,g)=>(e*100).toFixed(g),b:e=>Math.round(e).toString(2),c:e=>e+"",d:T2t,e:(e,g)=>e.toExponential(g),f:(e,g)=>e.toFixed(g),g:(e,g)=>e.toPrecision(g),o:e=>Math.round(e).toString(8),p:(e,g)=>pGe(e*100,g),r:pGe,s:K2t,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function yGe(e){return e}var ZGe=Array.prototype.map,GGe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function yMe(e){var g=e.grouping===void 0||e.thousands===void 0?yGe:H2t(ZGe.call(e.grouping,Number),e.thousands+""),i=e.currency===void 0?"":e.currency[0]+"",n=e.currency===void 0?"":e.currency[1]+"",I=e.decimal===void 0?".":e.decimal+"",r=e.numerals===void 0?yGe:N2t(ZGe.call(e.numerals,String)),o=e.percent===void 0?"%":e.percent+"",C=e.minus===void 0?"−":e.minus+"",a=e.nan===void 0?"NaN":e.nan+"";function A(l){l=Rb(l);var c=l.fill,u=l.align,d=l.sign,h=l.symbol,f=l.zero,m=l.width,b=l.comma,p=l.precision,y=l.trim,Z=l.type;Z==="n"?(b=!0,Z="g"):bGe[Z]||(p===void 0&&(p=12),y=!0,Z="g"),(f||c==="0"&&u==="=")&&(f=!0,c="0",u="=");var v=h==="$"?i:h==="#"&&/[boxX]/.test(Z)?"0"+Z.toLowerCase():"",G=h==="$"?n:/[%p]/.test(Z)?o:"",B=bGe[Z],S=/[defgprs%]/.test(Z);p=p===void 0?6:/[gprs]/.test(Z)?Math.max(1,Math.min(21,p)):Math.max(0,Math.min(20,p));function R(w){var T=v,W=G,V,X,N;if(Z==="c")W=B(w)+W,w="";else{w=+w;var Y=w<0||1/w<0;if(w=isNaN(w)?a:B(Math.abs(w),p),y&&(w=Y2t(w)),Y&&+w==0&&d!=="+"&&(Y=!1),T=(Y?d==="("?d:C:d==="-"||d==="("?"":d)+T,W=(Z==="s"?GGe[8+bMe/3]:"")+W+(Y&&d==="("?")":""),S){for(V=-1,X=w.length;++VN||N>57){W=(N===46?I+w.slice(V+1):w.slice(V))+W,w=w.slice(0,V);break}}}b&&!f&&(w=g(w,1/0));var x=T.length+w.length+W.length,M=x>1)+T+w+W+M.slice(x);break;default:w=M+T+w+W;break}return r(w)}return R.toString=function(){return l+""},R}function s(l,c){var u=A((l=Rb(l),l.type="f",l)),d=Math.max(-8,Math.min(8,Math.floor(EB(c)/3)))*3,h=Math.pow(10,-d),f=GGe[8+d/3];return function(m){return u(h*m)+f}}return{format:A,formatPrefix:s}}var pk,mT,vz;x2t({thousands:",",grouping:[3],currency:["$",""]});function x2t(e){return pk=yMe(e),mT=pk.format,vz=pk.formatPrefix,pk}function ZMe(e){return Math.max(0,-EB(Math.abs(e)))}function lCe(e,g){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(EB(g)/3)))*3-EB(Math.abs(e)))}function GMe(e,g){return e=Math.abs(e),g=Math.abs(g)-e,Math.max(0,EB(g)-EB(e))+1}const k6=Math.PI,Y6=2*k6,qp=1e-6,F2t=Y6-qp;function K6(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function vMe(){return new K6}K6.prototype=vMe.prototype={constructor:K6,moveTo:function(e,g){this._+="M"+(this._x0=this._x1=+e)+","+(this._y0=this._y1=+g)},closePath:function(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(e,g){this._+="L"+(this._x1=+e)+","+(this._y1=+g)},quadraticCurveTo:function(e,g,i,n){this._+="Q"+ +e+","+ +g+","+(this._x1=+i)+","+(this._y1=+n)},bezierCurveTo:function(e,g,i,n,I,r){this._+="C"+ +e+","+ +g+","+ +i+","+ +n+","+(this._x1=+I)+","+(this._y1=+r)},arcTo:function(e,g,i,n,I){e=+e,g=+g,i=+i,n=+n,I=+I;var r=this._x1,o=this._y1,C=i-e,a=n-g,A=r-e,s=o-g,l=A*A+s*s;if(I<0)throw new Error("negative radius: "+I);if(this._x1===null)this._+="M"+(this._x1=e)+","+(this._y1=g);else if(l>qp)if(!(Math.abs(s*C-a*A)>qp)||!I)this._+="L"+(this._x1=e)+","+(this._y1=g);else{var c=i-r,u=n-o,d=C*C+a*a,h=c*c+u*u,f=Math.sqrt(d),m=Math.sqrt(l),b=I*Math.tan((k6-Math.acos((d+l-h)/(2*f*m)))/2),p=b/m,y=b/f;Math.abs(p-1)>qp&&(this._+="L"+(e+p*A)+","+(g+p*s)),this._+="A"+I+","+I+",0,0,"+ +(s*c>A*u)+","+(this._x1=e+y*C)+","+(this._y1=g+y*a)}},arc:function(e,g,i,n,I,r){e=+e,g=+g,i=+i,r=!!r;var o=i*Math.cos(n),C=i*Math.sin(n),a=e+o,A=g+C,s=1^r,l=r?n-I:I-n;if(i<0)throw new Error("negative radius: "+i);this._x1===null?this._+="M"+a+","+A:(Math.abs(this._x1-a)>qp||Math.abs(this._y1-A)>qp)&&(this._+="L"+a+","+A),i&&(l<0&&(l=l%Y6+Y6),l>F2t?this._+="A"+i+","+i+",0,1,"+s+","+(e-o)+","+(g-C)+"A"+i+","+i+",0,1,"+s+","+(this._x1=a)+","+(this._y1=A):l>qp&&(this._+="A"+i+","+i+",0,"+ +(l>=k6)+","+s+","+(this._x1=e+i*Math.cos(I))+","+(this._y1=g+i*Math.sin(I))))},rect:function(e,g,i,n){this._+="M"+(this._x0=this._x1=+e)+","+(this._y0=this._y1=+g)+"h"+ +i+"v"+ +n+"h"+-i+"Z"},toString:function(){return this._}};function Bh(e){return function(){return e}}var vGe=Math.abs,Rr=Math.atan2,Gp=Math.cos,E2t=Math.max,hU=Math.min,fl=Math.sin,Av=Math.sqrt,iC=1e-12,KX=Math.PI,oF=KX/2,D2t=2*KX;function M2t(e){return e>1?0:e<-1?KX:Math.acos(e)}function BGe(e){return e>=1?oF:e<=-1?-oF:Math.asin(e)}function z2t(e){return e.innerRadius}function P2t(e){return e.outerRadius}function _2t(e){return e.startAngle}function O2t(e){return e.endAngle}function J2t(e){return e&&e.padAngle}function L2t(e,g,i,n,I,r,o,C){var a=i-e,A=n-g,s=o-I,l=C-r,c=l*a-s*A;if(!(c*cV*V+X*X&&(B=R,S=w),{cx:B,cy:S,x01:-s,y01:-l,x11:B*(I/Z-1),y11:S*(I/Z-1)}}function U2t(){var e=z2t,g=P2t,i=Bh(0),n=null,I=_2t,r=O2t,o=J2t,C=null;function a(){var A,s,l=+e.apply(this,arguments),c=+g.apply(this,arguments),u=I.apply(this,arguments)-oF,d=r.apply(this,arguments)-oF,h=vGe(d-u),f=d>u;if(C||(C=A=vMe()),ciC))C.moveTo(0,0);else if(h>D2t-iC)C.moveTo(c*Gp(u),c*fl(u)),C.arc(0,0,c,u,d,!f),l>iC&&(C.moveTo(l*Gp(d),l*fl(d)),C.arc(0,0,l,d,u,f));else{var m=u,b=d,p=u,y=d,Z=h,v=h,G=o.apply(this,arguments)/2,B=G>iC&&(n?+n.apply(this,arguments):Av(l*l+c*c)),S=hU(vGe(c-l)/2,+i.apply(this,arguments)),R=S,w=S,T,W;if(B>iC){var V=BGe(B/l*fl(G)),X=BGe(B/c*fl(G));(Z-=V*2)>iC?(V*=f?1:-1,p+=V,y-=V):(Z=0,p=y=(u+d)/2),(v-=X*2)>iC?(X*=f?1:-1,m+=X,b-=X):(v=0,m=b=(u+d)/2)}var N=c*Gp(m),Y=c*fl(m),x=l*Gp(y),M=l*fl(y);if(S>iC){var F=c*Gp(b),$=c*fl(b),Q=l*Gp(p),U=l*fl(p),j;if(hiC?w>iC?(T=bk(Q,U,N,Y,c,w,f),W=bk(F,$,x,M,c,w,f),C.moveTo(T.cx+T.x01,T.cy+T.y01),wiC)||!(Z>iC)?C.lineTo(x,M):R>iC?(T=bk(x,M,F,$,l,-R,f),W=bk(N,Y,Q,U,l,-R,f),C.lineTo(T.cx+T.x01,T.cy+T.y01),R({events:{},emit(e,...g){let i=this.events[e]||[];for(let n=0,I=i.length;n{this.events[e]=this.events[e]?.filter(i=>g!==i)}}});var BMe={},rs={},Vb={};Object.defineProperty(Vb,"__esModule",{value:!0});Vb.DefaultSerializer=Vb.extendSerializer=void 0;function j2t(e,g){const i=e.deserialize.bind(e),n=e.serialize.bind(e);return{deserialize(I){return g.deserialize(I,i)},serialize(I){return g.serialize(I,n)}}}Vb.extendSerializer=j2t;const wGe={deserialize(e){return Object.assign(Error(e.message),{name:e.name,stack:e.stack})},serialize(e){return{__error_marker:"$$error",message:e.message,name:e.name,stack:e.stack}}},$2t=e=>e&&typeof e=="object"&&"__error_marker"in e&&e.__error_marker==="$$error";Vb.DefaultSerializer={deserialize(e){return $2t(e)?wGe.deserialize(e):e},serialize(e){return e instanceof Error?wGe.serialize(e):e}};Object.defineProperty(rs,"__esModule",{value:!0});rs.serialize=rs.deserialize=rs.registerSerializer=void 0;const wMe=Vb;let CF=wMe.DefaultSerializer;function q2t(e){CF=wMe.extendSerializer(CF,e)}rs.registerSerializer=q2t;function eWt(e){return CF.deserialize(e)}rs.deserialize=eWt;function tWt(e){return CF.serialize(e)}rs.serialize=tWt;var SMe={},ud={},DB={};Object.defineProperty(DB,"__esModule",{value:!0});DB.getBundleURL=DB.getBaseURL=void 0;let fU;function gWt(){return fU||(fU=iWt()),fU}DB.getBundleURL=gWt;function iWt(){try{throw new Error}catch(e){const g=(""+e.stack).match(/(https?|file|ftp|chrome-extension|moz-extension):\/\/[^)\n]+/g);if(g)return RMe(g[0])}return"/"}function RMe(e){return(""+e).replace(/^((?:https?|file|ftp|chrome-extension|moz-extension):\/\/.+)?\/[^/]+(?:\?.*)?$/,"$1")+"/"}DB.getBaseURL=RMe;Object.defineProperty(ud,"__esModule",{value:!0});ud.isWorkerRuntime=ud.getWorkerImplementation=ud.defaultPoolSize=void 0;const SGe=DB;ud.defaultPoolSize=typeof navigator<"u"&&navigator.hardwareConcurrency?navigator.hardwareConcurrency:4;const RGe=e=>/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(e);function VGe(e){const g=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(g)}function nWt(){if(typeof Worker>"u")return class{constructor(){throw Error("No web worker implementation available. You might have tried to spawn a worker within a worker in a browser that doesn't support workers in workers.")}};class e extends Worker{constructor(n,I){var r,o;typeof n=="string"&&I&&I._baseURL?n=new URL(n,I._baseURL):typeof n=="string"&&!RGe(n)&&SGe.getBundleURL().match(/^file:\/\//i)&&(n=new URL(n,SGe.getBundleURL().replace(/\/[^\/]+$/,"/")),(!((r=I?.CORSWorkaround)!==null&&r!==void 0)||r)&&(n=VGe(`importScripts(${JSON.stringify(n)});`))),typeof n=="string"&&RGe(n)&&(!((o=I?.CORSWorkaround)!==null&&o!==void 0)||o)&&(n=VGe(`importScripts(${JSON.stringify(n)});`)),super(n,I)}}class g extends e{constructor(n,I){const r=window.URL.createObjectURL(n);super(r,I)}static fromText(n,I){const r=new window.Blob([n],{type:"text/javascript"});return new g(r,I)}}return{blob:g,default:e}}let mU;function IWt(){return mU||(mU=nWt()),mU}ud.getWorkerImplementation=IWt;function rWt(){const e=typeof self<"u"&&typeof Window<"u"&&self instanceof Window;return!!(typeof self<"u"&&self.postMessage&&!e)}ud.isWorkerRuntime=rWt;var VMe={},x6={exports:{}},pU,WGe;function oWt(){if(WGe)return pU;WGe=1;var e=1e3,g=e*60,i=g*60,n=i*24,I=n*7,r=n*365.25;pU=function(s,l){l=l||{};var c=typeof s;if(c==="string"&&s.length>0)return o(s);if(c==="number"&&isFinite(s))return l.long?a(s):C(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))};function o(s){if(s=String(s),!(s.length>100)){var l=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(l){var c=parseFloat(l[1]),u=(l[2]||"ms").toLowerCase();switch(u){case"years":case"year":case"yrs":case"yr":case"y":return c*r;case"weeks":case"week":case"w":return c*I;case"days":case"day":case"d":return c*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*i;case"minutes":case"minute":case"mins":case"min":case"m":return c*g;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}}}function C(s){var l=Math.abs(s);return l>=n?Math.round(s/n)+"d":l>=i?Math.round(s/i)+"h":l>=g?Math.round(s/g)+"m":l>=e?Math.round(s/e)+"s":s+"ms"}function a(s){var l=Math.abs(s);return l>=n?A(s,l,n,"day"):l>=i?A(s,l,i,"hour"):l>=g?A(s,l,g,"minute"):l>=e?A(s,l,e,"second"):s+" ms"}function A(s,l,c,u){var d=l>=c*1.5;return Math.round(s/c)+" "+u+(d?"s":"")}return pU}function CWt(e){i.debug=i,i.default=i,i.coerce=a,i.disable=r,i.enable=I,i.enabled=o,i.humanize=oWt(),i.destroy=A,Object.keys(e).forEach(s=>{i[s]=e[s]}),i.names=[],i.skips=[],i.formatters={};function g(s){let l=0;for(let c=0;c{if(v==="%%")return"%";y++;const B=i.formatters[G];if(typeof B=="function"){const S=f[y];v=B.call(m,S),f.splice(y,1),y--}return v}),i.formatArgs.call(m,f),(m.log||i.log).apply(m,f)}return h.namespace=s,h.useColors=i.useColors(),h.color=i.selectColor(s),h.extend=n,h.destroy=i.destroy,Object.defineProperty(h,"enabled",{enumerable:!0,configurable:!1,get:()=>c!==null?c:(u!==i.namespaces&&(u=i.namespaces,d=i.enabled(s)),d),set:f=>{c=f}}),typeof i.init=="function"&&i.init(h),h}function n(s,l){const c=i(this.namespace+(typeof l>"u"?":":l)+s);return c.log=this.log,c}function I(s){i.save(s),i.namespaces=s,i.names=[],i.skips=[];let l;const c=(typeof s=="string"?s:"").split(/[\s,]+/),u=c.length;for(l=0;l"-"+l)].join(",");return i.enable(""),s}function o(s){if(s[s.length-1]==="*")return!0;let l,c;for(l=0,c=i.skips.length;l{let a=!1;return()=>{a||(a=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),g.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function i(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const A="color: "+this.color;a.splice(1,0,A,"color: inherit");let s=0,l=0;a[0].replace(/%[a-zA-Z%]/g,c=>{c!=="%%"&&(s++,c==="%c"&&(l=s))}),a.splice(l,0,A)}g.log=console.debug||console.log||(()=>{});function I(a){try{a?g.storage.setItem("debug",a):g.storage.removeItem("debug")}catch{}}function r(){let a;try{a=g.storage.getItem("debug")}catch{}return!a&&typeof process<"u"&&"env"in process&&(a={}.DEBUG),a}function o(){try{return localStorage}catch{}}e.exports=aWt(g);const{formatters:C}=e.exports;C.j=function(a){try{return JSON.stringify(a)}catch(A){return"[UnexpectedJSONParseError]: "+A.message}}})(x6,x6.exports);var cCe=x6.exports,sWt=globalThis&&globalThis.__awaiter||function(e,g,i,n){function I(r){return r instanceof i?r:new i(function(o){o(r)})}return new(i||(i=Promise))(function(r,o){function C(s){try{A(n.next(s))}catch(l){o(l)}}function a(s){try{A(n.throw(s))}catch(l){o(l)}}function A(s){s.done?r(s.value):I(s.value).then(C,a)}A((n=n.apply(e,g||[])).next())})};class Bz{constructor(g){this._baseObserver=g,this._pendingPromises=new Set}complete(){Promise.all(this._pendingPromises).then(()=>this._baseObserver.complete()).catch(g=>this._baseObserver.error(g))}error(g){this._baseObserver.error(g)}schedule(g){const i=Promise.all(this._pendingPromises),n=[],I=o=>n.push(o),r=Promise.resolve().then(()=>sWt(this,void 0,void 0,function*(){yield i,yield g(I),this._pendingPromises.delete(r);for(const o of n)this._baseObserver.next(o)})).catch(o=>{this._pendingPromises.delete(r),this._baseObserver.error(o)});this._pendingPromises.add(r)}}const WMe=()=>typeof Symbol=="function",pT=e=>WMe()&&!!Symbol[e],uCe=e=>pT(e)?Symbol[e]:"@@"+e;pT("asyncIterator")||(Symbol.asyncIterator=Symbol.asyncIterator||Symbol.for("Symbol.asyncIterator"));const AWt=uCe("iterator"),F6=uCe("observable"),XMe=uCe("species");function aF(e,g){const i=e[g];if(i!=null){if(typeof i!="function")throw new TypeError(i+" is not a function");return i}}function rR(e){let g=e.constructor;return g!==void 0&&(g=g[XMe],g===null&&(g=void 0)),g!==void 0?g:Wb}function lWt(e){return e instanceof Wb}function MB(e){MB.log?MB.log(e):setTimeout(()=>{throw e},0)}function xK(e){Promise.resolve().then(()=>{try{e()}catch(g){MB(g)}})}function TMe(e){const g=e._cleanup;if(g!==void 0&&(e._cleanup=void 0,!!g))try{if(typeof g=="function")g();else{const i=aF(g,"unsubscribe");i&&i.call(g)}}catch(i){MB(i)}}function E6(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function cWt(e){const g=e._queue;if(g){e._queue=void 0,e._state="ready";for(const i of g)if(HMe(e,i.type,i.value),e._state==="closed")break}}function HMe(e,g,i){e._state="running";const n=e._observer;try{const I=n?aF(n,g):void 0;switch(g){case"next":I&&I.call(n,i);break;case"error":if(E6(e),I)I.call(n,i);else throw i;break;case"complete":E6(e),I&&I.call(n);break}}catch(I){MB(I)}e._state==="closed"?TMe(e):e._state==="running"&&(e._state="ready")}function bU(e,g,i){if(e._state!=="closed"){if(e._state==="buffering"){e._queue=e._queue||[],e._queue.push({type:g,value:i});return}if(e._state!=="ready"){e._state="buffering",e._queue=[{type:g,value:i}],xK(()=>cWt(e));return}HMe(e,g,i)}}let uWt=class{constructor(g,i){this._cleanup=void 0,this._observer=g,this._queue=void 0,this._state="initializing";const n=new dWt(this);try{this._cleanup=i.call(void 0,n)}catch(I){n.error(I)}this._state==="initializing"&&(this._state="ready")}get closed(){return this._state==="closed"}unsubscribe(){this._state!=="closed"&&(E6(this),TMe(this))}};class dWt{constructor(g){this._subscription=g}get closed(){return this._subscription._state==="closed"}next(g){bU(this._subscription,"next",g)}error(g){bU(this._subscription,"error",g)}complete(){bU(this._subscription,"complete")}}let Wb=class yV{constructor(g){if(!(this instanceof yV))throw new TypeError("Observable cannot be called as a function");if(typeof g!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=g}subscribe(g,i,n){return(typeof g!="object"||g===null)&&(g={next:g,error:i,complete:n}),new uWt(g,this._subscriber)}pipe(g,...i){let n=this;for(const I of[g,...i])n=I(n);return n}tap(g,i,n){const I=typeof g!="object"||g===null?{next:g,error:i,complete:n}:g;return new yV(r=>this.subscribe({next(o){I.next&&I.next(o),r.next(o)},error(o){I.error&&I.error(o),r.error(o)},complete(){I.complete&&I.complete(),r.complete()},start(o){I.start&&I.start(o)}}))}forEach(g){return new Promise((i,n)=>{if(typeof g!="function"){n(new TypeError(g+" is not a function"));return}function I(){r.unsubscribe(),i(void 0)}const r=this.subscribe({next(o){try{g(o,I)}catch(C){n(C),r.unsubscribe()}},error(o){n(o)},complete(){i(void 0)}})})}map(g){if(typeof g!="function")throw new TypeError(g+" is not a function");const i=rR(this);return new i(n=>this.subscribe({next(I){let r=I;try{r=g(I)}catch(o){return n.error(o)}n.next(r)},error(I){n.error(I)},complete(){n.complete()}}))}filter(g){if(typeof g!="function")throw new TypeError(g+" is not a function");const i=rR(this);return new i(n=>this.subscribe({next(I){try{if(!g(I))return}catch(r){return n.error(r)}n.next(I)},error(I){n.error(I)},complete(){n.complete()}}))}reduce(g,i){if(typeof g!="function")throw new TypeError(g+" is not a function");const n=rR(this),I=arguments.length>1;let r=!1,o=i;return new n(C=>this.subscribe({next(a){const A=!r;if(r=!0,!A||I)try{o=g(o,a)}catch(s){return C.error(s)}else o=a},error(a){C.error(a)},complete(){if(!r&&!I)return C.error(new TypeError("Cannot reduce an empty sequence"));C.next(o),C.complete()}}))}concat(...g){const i=rR(this);return new i(n=>{let I,r=0;function o(C){I=C.subscribe({next(a){n.next(a)},error(a){n.error(a)},complete(){r===g.length?(I=void 0,n.complete()):o(i.from(g[r++]))}})}return o(this),()=>{I&&(I.unsubscribe(),I=void 0)}})}flatMap(g){if(typeof g!="function")throw new TypeError(g+" is not a function");const i=rR(this);return new i(n=>{const I=[],r=this.subscribe({next(C){let a;if(g)try{a=g(C)}catch(s){return n.error(s)}else a=C;const A=i.from(a).subscribe({next(s){n.next(s)},error(s){n.error(s)},complete(){const s=I.indexOf(A);s>=0&&I.splice(s,1),o()}});I.push(A)},error(C){n.error(C)},complete(){o()}});function o(){r.closed&&I.length===0&&n.complete()}return()=>{I.forEach(C=>C.unsubscribe()),r.unsubscribe()}})}[F6](){return this}static from(g){const i=typeof this=="function"?this:yV;if(g==null)throw new TypeError(g+" is not an object");const n=aF(g,F6);if(n){const I=n.call(g);if(Object(I)!==I)throw new TypeError(I+" is not an object");return lWt(I)&&I.constructor===i?I:new i(r=>I.subscribe(r))}if(pT("iterator")){const I=aF(g,AWt);if(I)return new i(r=>{xK(()=>{if(!r.closed){for(const o of I.call(g))if(r.next(o),r.closed)return;r.complete()}})})}if(Array.isArray(g))return new i(I=>{xK(()=>{if(!I.closed){for(const r of g)if(I.next(r),I.closed)return;I.complete()}})});throw new TypeError(g+" is not observable")}static of(...g){const i=typeof this=="function"?this:yV;return new i(n=>{xK(()=>{if(!n.closed){for(const I of g)if(n.next(I),n.closed)return;n.complete()}})})}static get[XMe](){return this}};WMe()&&Object.defineProperty(Wb,Symbol("extensions"),{value:{symbol:F6,hostReportError:MB},configurable:!0});const Ey=Wb;function Dy(e){typeof e=="function"?e():e&&typeof e.unsubscribe=="function"&&e.unsubscribe()}var hWt=globalThis&&globalThis.__awaiter||function(e,g,i,n){function I(r){return r instanceof i?r:new i(function(o){o(r)})}return new(i||(i=Promise))(function(r,o){function C(s){try{A(n.next(s))}catch(l){o(l)}}function a(s){try{A(n.throw(s))}catch(l){o(l)}}function A(s){s.done?r(s.value):I(s.value).then(C,a)}A((n=n.apply(e,g||[])).next())})};function fWt(e){return g=>new Ey(i=>{const n=new Bz(i),I=g.subscribe({complete(){n.complete()},error(r){n.error(r)},next(r){n.schedule(o=>hWt(this,void 0,void 0,function*(){(yield e(r))&&o(r)}))}});return()=>Dy(I)})}function mWt(e){return e&&pT("asyncIterator")&&e[Symbol.asyncIterator]}function pWt(e){return e&&pT("iterator")&&e[Symbol.iterator]}var bWt=globalThis&&globalThis.__awaiter||function(e,g,i,n){function I(r){return r instanceof i?r:new i(function(o){o(r)})}return new(i||(i=Promise))(function(r,o){function C(s){try{A(n.next(s))}catch(l){o(l)}}function a(s){try{A(n.throw(s))}catch(l){o(l)}}function A(s){s.done?r(s.value):I(s.value).then(C,a)}A((n=n.apply(e,g||[])).next())})},yWt=globalThis&&globalThis.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var g=e[Symbol.asyncIterator],i;return g?g.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i);function n(r){i[r]=e[r]&&function(o){return new Promise(function(C,a){o=e[r](o),I(C,a,o.done,o.value)})}}function I(r,o,C,a){Promise.resolve(a).then(function(A){r({value:A,done:C})},o)}};function ZWt(e){return g=>new Ey(i=>{const n=new Bz(i),I=g.subscribe({complete(){n.complete()},error(r){n.error(r)},next(r){n.schedule(o=>bWt(this,void 0,void 0,function*(){var C,a;const A=yield e(r);if(pWt(A)||mWt(A))try{for(var s=yWt(A),l;l=yield s.next(),!l.done;){const c=l.value;o(c)}}catch(c){C={error:c}}finally{try{l&&!l.done&&(a=s.return)&&(yield a.call(s))}finally{if(C)throw C.error}}else A.map(c=>o(c))}))}});return()=>Dy(I)})}function GWt(e){return new Wb(g=>{let i=0;const n=setInterval(()=>{g.next(i++)},e);return()=>clearInterval(n)})}var vWt=globalThis&&globalThis.__awaiter||function(e,g,i,n){function I(r){return r instanceof i?r:new i(function(o){o(r)})}return new(i||(i=Promise))(function(r,o){function C(s){try{A(n.next(s))}catch(l){o(l)}}function a(s){try{A(n.throw(s))}catch(l){o(l)}}function A(s){s.done?r(s.value):I(s.value).then(C,a)}A((n=n.apply(e,g||[])).next())})};function BWt(e){return g=>new Ey(i=>{const n=new Bz(i),I=g.subscribe({complete(){n.complete()},error(r){n.error(r)},next(r){n.schedule(o=>vWt(this,void 0,void 0,function*(){const C=yield e(r);o(C)}))}});return()=>Dy(I)})}function wWt(...e){return e.length===0?Wb.from([]):new Wb(g=>{let i=0;const n=e.map(r=>r.subscribe({error(o){g.error(o),I()},next(o){g.next(o)},complete(){++i===e.length&&(g.complete(),I())}})),I=()=>{n.forEach(r=>Dy(r))};return I})}class SWt extends Ey{constructor(){super(g=>(this._observers.add(g),()=>this._observers.delete(g))),this._observers=new Set}next(g){for(const i of this._observers)i.next(g)}error(g){for(const i of this._observers)i.error(g)}complete(){for(const g of this._observers)g.complete()}}const NMe=SWt;function RWt(e){const g=new NMe;let i,n=0;return new Ey(I=>{i||(i=e.subscribe(g));const r=g.subscribe(I);return n++,()=>{n--,r.unsubscribe(),n===0&&(Dy(i),i=void 0)}})}var VWt=globalThis&&globalThis.__awaiter||function(e,g,i,n){function I(r){return r instanceof i?r:new i(function(o){o(r)})}return new(i||(i=Promise))(function(r,o){function C(s){try{A(n.next(s))}catch(l){o(l)}}function a(s){try{A(n.throw(s))}catch(l){o(l)}}function A(s){s.done?r(s.value):I(s.value).then(C,a)}A((n=n.apply(e,g||[])).next())})};function WWt(e,g){return i=>new Ey(n=>{let I,r=0;const o=new Bz(n),C=i.subscribe({complete(){o.complete()},error(a){o.error(a)},next(a){o.schedule(A=>VWt(this,void 0,void 0,function*(){I=yield e(r===0?typeof g>"u"?a:g:I,a,r++),A(I)}))}});return()=>Dy(C)})}const XWt=Object.freeze(Object.defineProperty({__proto__:null,Observable:Ey,Subject:NMe,filter:fWt,flatMap:ZWt,interval:GWt,map:BWt,merge:wWt,multicast:RWt,scan:WWt,unsubscribe:Dy},Symbol.toStringTag,{value:"Module"})),wz=Bst(XWt);var Sz={};Object.defineProperty(Sz,"__esModule",{value:!0});Sz.allSettled=void 0;function TWt(e){return Promise.all(e.map(g=>{const i=r=>({status:"fulfilled",value:r}),n=r=>({status:"rejected",reason:r}),I=Promise.resolve(g);try{return I.then(i,n)}catch(r){return Promise.reject(r)}}))}Sz.allSettled=TWt;var kMe={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.PoolEventType=void 0,function(g){g.initialized="initialized",g.taskCanceled="taskCanceled",g.taskCompleted="taskCompleted",g.taskFailed="taskFailed",g.taskQueued="taskQueued",g.taskQueueDrained="taskQueueDrained",g.taskStart="taskStart",g.terminated="terminated"}(e.PoolEventType||(e.PoolEventType={}))})(kMe);var bT={},fC={};Object.defineProperty(fC,"__esModule",{value:!0});fC.$worker=fC.$transferable=fC.$terminate=fC.$events=fC.$errors=void 0;fC.$errors=Symbol("thread.errors");fC.$events=Symbol("thread.events");fC.$terminate=Symbol("thread.terminate");fC.$transferable=Symbol("thread.transferable");fC.$worker=Symbol("thread.worker");Object.defineProperty(bT,"__esModule",{value:!0});bT.Thread=void 0;const yU=fC;function XGe(e){throw Error(e)}bT.Thread={errors(e){return e[yU.$errors]||XGe("Error observable not found. Make sure to pass a thread instance as returned by the spawn() promise.")},events(e){return e[yU.$events]||XGe("Events observable not found. Make sure to pass a thread instance as returned by the spawn() promise.")},terminate(e){return e[yU.$terminate]()}};(function(e){var g=un&&un.__awaiter||function(m,b,p,y){function Z(v){return v instanceof p?v:new p(function(G){G(v)})}return new(p||(p=Promise))(function(v,G){function B(w){try{R(y.next(w))}catch(T){G(T)}}function S(w){try{R(y.throw(w))}catch(T){G(T)}}function R(w){w.done?v(w.value):Z(w.value).then(B,S)}R((y=y.apply(m,b||[])).next())})},i=un&&un.__importDefault||function(m){return m&&m.__esModule?m:{default:m}};Object.defineProperty(e,"__esModule",{value:!0}),e.Pool=e.Thread=e.PoolEventType=void 0;const n=i(cCe),I=wz,r=Sz,o=ud,C=kMe;Object.defineProperty(e,"PoolEventType",{enumerable:!0,get:function(){return C.PoolEventType}});const a=bT;Object.defineProperty(e,"Thread",{enumerable:!0,get:function(){return a.Thread}});let A=1;function s(m){const b=[];for(let p=0;psetTimeout(b,m))}function c(m,b){return m.reduce((p,y)=>[...p,...b(y)],[])}function u(m){return m.replace(/\W/g," ").trim().replace(/\s+/g,"-")}function d(m,b){return s(b).map(()=>({init:m(),runningTasks:[]}))}class h{constructor(b,p){this.eventSubject=new I.Subject,this.initErrors=[],this.isClosing=!1,this.nextTaskID=1,this.taskQueue=[];const y=typeof p=="number"?{size:p}:p||{},{size:Z=o.defaultPoolSize}=y;this.debug=n.default(`threads:pool:${u(y.name||String(A++))}`),this.options=y,this.workers=d(b,Z),this.eventObservable=I.multicast(I.Observable.from(this.eventSubject)),Promise.all(this.workers.map(v=>v.init)).then(()=>this.eventSubject.next({type:C.PoolEventType.initialized,size:this.workers.length}),v=>{this.debug("Error while initializing pool worker:",v),this.eventSubject.error(v),this.initErrors.push(v)})}findIdlingWorker(){const{concurrency:b=1}=this.options;return this.workers.find(p=>p.runningTasks.lengthg(this,void 0,void 0,function*(){const Z=()=>{b.runningTasks=b.runningTasks.filter(v=>v!==y)};yield l(0);try{yield this.runPoolTask(b,p)}finally{Z(),this.isClosing||this.scheduleWork()}}))();b.runningTasks.push(y)})}scheduleWork(){this.debug("Attempt de-queueing a task in order to run it...");const b=this.findIdlingWorker();if(!b)return;const p=this.taskQueue.shift();if(!p){this.debug("Task queue is empty"),this.eventSubject.next({type:C.PoolEventType.taskQueueDrained});return}this.run(b,p)}taskCompletion(b){return new Promise((p,y)=>{const Z=this.events().subscribe(v=>{v.type===C.PoolEventType.taskCompleted&&v.taskID===b?(Z.unsubscribe(),p(v.returnValue)):v.type===C.PoolEventType.taskFailed&&v.taskID===b?(Z.unsubscribe(),y(v.error)):v.type===C.PoolEventType.terminated&&(Z.unsubscribe(),y(Error("Pool has been terminated before task was run.")))})})}settled(b=!1){return g(this,void 0,void 0,function*(){const p=()=>c(this.workers,v=>v.runningTasks),y=[],Z=this.eventObservable.subscribe(v=>{v.type===C.PoolEventType.taskFailed&&y.push(v.error)});return this.initErrors.length>0?Promise.reject(this.initErrors[0]):b&&this.taskQueue.length===0?(yield r.allSettled(p()),y):(yield new Promise((v,G)=>{const B=this.eventObservable.subscribe({next(S){S.type===C.PoolEventType.taskQueueDrained&&(B.unsubscribe(),v(void 0))},error:G})}),yield r.allSettled(p()),Z.unsubscribe(),y)})}completed(b=!1){return g(this,void 0,void 0,function*(){const p=this.settled(b),y=new Promise((v,G)=>{const B=this.eventObservable.subscribe({next(S){S.type===C.PoolEventType.taskQueueDrained?(B.unsubscribe(),v(p)):S.type===C.PoolEventType.taskFailed&&(B.unsubscribe(),G(S.error))},error:G})}),Z=yield Promise.race([p,y]);if(Z.length>0)throw Z[0]})}events(){return this.eventObservable}queue(b){const{maxQueuedJobs:p=1/0}=this.options;if(this.isClosing)throw Error("Cannot schedule pool tasks after terminate() has been called.");if(this.initErrors.length>0)throw this.initErrors[0];const y=this.nextTaskID++,Z=this.taskCompletion(y);Z.catch(G=>{this.debug(`Task #${y} errored:`,G)});const v={id:y,run:b,cancel:()=>{this.taskQueue.indexOf(v)!==-1&&(this.taskQueue=this.taskQueue.filter(G=>G!==v),this.eventSubject.next({type:C.PoolEventType.taskCanceled,taskID:v.id}))},then:Z.then.bind(Z)};if(this.taskQueue.length>=p)throw Error(`Maximum number of pool tasks queued. Refusing to queue another one. +This usually happens for one of two reasons: We are either at peak workload right now or some tasks just won't finish, thus blocking the pool.`);return this.debug(`Queueing task #${v.id}...`),this.taskQueue.push(v),this.eventSubject.next({type:C.PoolEventType.taskQueued,taskID:v.id}),this.scheduleWork(),v}terminate(b){return g(this,void 0,void 0,function*(){this.isClosing=!0,b||(yield this.completed(!0)),this.eventSubject.next({type:C.PoolEventType.terminated,remainingQueue:[...this.taskQueue]}),this.eventSubject.complete(),yield Promise.all(this.workers.map(p=>g(this,void 0,void 0,function*(){return a.Thread.terminate(yield p.init)})))})}}h.EventType=C.PoolEventType;function f(m,b){return new h(m,b)}f.EventType=C.PoolEventType,e.Pool=f})(VMe);var Rz={},Vz={};Object.defineProperty(Vz,"__esModule",{value:!0});Vz.createPromiseWithResolver=void 0;const HWt=()=>{};function NWt(){let e=!1,g,i=HWt;return[new Promise(r=>{e?r(g):i=r}),r=>{e=!0,g=r,i(g)}]}Vz.createPromiseWithResolver=NWt;var YMe={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.WorkerEventType=void 0,function(g){g.internalError="internalError",g.message="message",g.termination="termination"}(e.WorkerEventType||(e.WorkerEventType={}))})(YMe);var zB={},Wz={};Object.defineProperty(Wz,"__esModule",{value:!0});Wz.ObservablePromise=void 0;const kWt=wz,YWt=()=>{},KWt=e=>e,TGe=e=>Promise.resolve().then(e);function xWt(e){throw e}function FWt(e){return e&&typeof e.then=="function"}class dCe extends kWt.Observable{constructor(g){super(i=>{const n=this,I=Object.assign(Object.assign({},i),{complete(){i.complete(),n.onCompletion()},error(r){i.error(r),n.onError(r)},next(r){i.next(r),n.onNext(r)}});try{return this.initHasRun=!0,g(I)}catch(r){I.error(r)}}),this.initHasRun=!1,this.fulfillmentCallbacks=[],this.rejectionCallbacks=[],this.firstValueSet=!1,this.state="pending"}onNext(g){this.firstValueSet||(this.firstValue=g,this.firstValueSet=!0)}onError(g){this.state="rejected",this.rejection=g;for(const i of this.rejectionCallbacks)TGe(()=>i(g))}onCompletion(){this.state="fulfilled";for(const g of this.fulfillmentCallbacks)TGe(()=>g(this.firstValue))}then(g,i){const n=g||KWt,I=i||xWt;let r=!1;return new Promise((o,C)=>{const a=s=>{if(!r){r=!0;try{o(I(s))}catch(l){C(l)}}},A=s=>{try{o(n(s))}catch(l){a(l)}};if(this.initHasRun||this.subscribe({error:a}),this.state==="fulfilled")return o(n(this.firstValue));if(this.state==="rejected")return r=!0,o(I(this.rejection));this.fulfillmentCallbacks.push(A),this.rejectionCallbacks.push(a)})}catch(g){return this.then(void 0,g)}finally(g){const i=g||YWt;return this.then(n=>(i(),n),()=>i())}static from(g){return FWt(g)?new dCe(i=>{const n=r=>{i.next(r),i.complete()},I=r=>{i.error(r)};g.then(n,I)}):super.from(g)}}Wz.ObservablePromise=dCe;var Hd={};Object.defineProperty(Hd,"__esModule",{value:!0});Hd.Transfer=Hd.isTransferDescriptor=void 0;const KMe=fC;function EWt(e){return!(!e||typeof e!="object")}function DWt(e){return e&&typeof e=="object"&&e[KMe.$transferable]}Hd.isTransferDescriptor=DWt;function MWt(e,g){if(!g){if(!EWt(e))throw Error();g=[e]}return{[KMe.$transferable]:!0,send:e,transferables:g}}Hd.Transfer=MWt;var hCe={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.WorkerMessageType=e.MasterMessageType=void 0,function(g){g.cancel="cancel",g.run="run"}(e.MasterMessageType||(e.MasterMessageType={})),function(g){g.error="error",g.init="init",g.result="result",g.running="running",g.uncaughtError="uncaughtError"}(e.WorkerMessageType||(e.WorkerMessageType={}))})(hCe);var zWt=un&&un.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(zB,"__esModule",{value:!0});zB.createProxyModule=zB.createProxyFunction=void 0;const PWt=zWt(cCe),xMe=wz,D2=rs,HGe=Wz,_Wt=Hd,yT=hCe,FMe=PWt.default("threads:master:messages");let OWt=1;const JWt=e=>Array.from(new Set(e)),LWt=e=>e&&e.type===yT.WorkerMessageType.error,UWt=e=>e&&e.type===yT.WorkerMessageType.result,QWt=e=>e&&e.type===yT.WorkerMessageType.running;function jWt(e,g){return new xMe.Observable(i=>{let n;const I=r=>{if(FMe("Message from worker:",r.data),!(!r.data||r.data.uid!==g)){if(QWt(r.data))n=r.data.resultType;else if(UWt(r.data))n==="promise"?(typeof r.data.payload<"u"&&i.next(D2.deserialize(r.data.payload)),i.complete(),e.removeEventListener("message",I)):(r.data.payload&&i.next(D2.deserialize(r.data.payload)),r.data.complete&&(i.complete(),e.removeEventListener("message",I)));else if(LWt(r.data)){const o=D2.deserialize(r.data.error);i.error(o),e.removeEventListener("message",I)}}};return e.addEventListener("message",I),()=>{if(n==="observable"||!n){const r={type:yT.MasterMessageType.cancel,uid:g};e.postMessage(r)}e.removeEventListener("message",I)}})}function $Wt(e){if(e.length===0)return{args:[],transferables:[]};const g=[],i=[];for(const n of e)_Wt.isTransferDescriptor(n)?(g.push(D2.serialize(n.send)),i.push(...n.transferables)):g.push(D2.serialize(n));return{args:g,transferables:i.length===0?i:JWt(i)}}function EMe(e,g){return(...i)=>{const n=OWt++,{args:I,transferables:r}=$Wt(i),o={type:yT.MasterMessageType.run,uid:n,method:g,args:I};FMe("Sending command to run function to worker:",o);try{e.postMessage(o,r)}catch(C){return HGe.ObservablePromise.from(Promise.reject(C))}return HGe.ObservablePromise.from(xMe.multicast(jWt(e,n)))}}zB.createProxyFunction=EMe;function qWt(e,g){const i={};for(const n of g)i[n]=EMe(e,n);return i}zB.createProxyModule=qWt;var fCe=un&&un.__awaiter||function(e,g,i,n){function I(r){return r instanceof i?r:new i(function(o){o(r)})}return new(i||(i=Promise))(function(r,o){function C(s){try{A(n.next(s))}catch(l){o(l)}}function a(s){try{A(n.throw(s))}catch(l){o(l)}}function A(s){s.done?r(s.value):I(s.value).then(C,a)}A((n=n.apply(e,g||[])).next())})},eXt=un&&un.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Rz,"__esModule",{value:!0});Rz.spawn=void 0;const mCe=eXt(cCe),tXt=wz,gXt=rs,iXt=Vz,yk=fC,FK=YMe,NGe=zB,nXt=mCe.default("threads:master:messages"),IXt=mCe.default("threads:master:spawn"),DMe=mCe.default("threads:master:thread-utils"),rXt=e=>e&&e.type==="init",oXt=e=>e&&e.type==="uncaughtError",CXt=typeof process<"u"&&{}.THREADS_WORKER_INIT_TIMEOUT?Number.parseInt({}.THREADS_WORKER_INIT_TIMEOUT,10):1e4;function aXt(e,g,i){return fCe(this,void 0,void 0,function*(){let n;const I=new Promise((o,C)=>{n=setTimeout(()=>C(Error(i)),g)}),r=yield Promise.race([e,I]);return clearTimeout(n),r})}function sXt(e){return new Promise((g,i)=>{const n=I=>{nXt("Message from worker before finishing initialization:",I.data),rXt(I.data)?(e.removeEventListener("message",n),g(I.data)):oXt(I.data)&&(e.removeEventListener("message",n),i(gXt.deserialize(I.data.error)))};e.addEventListener("message",n)})}function AXt(e,g){return new tXt.Observable(i=>{const n=r=>{const o={type:FK.WorkerEventType.message,data:r.data};i.next(o)},I=r=>{DMe("Unhandled promise rejection event in thread:",r);const o={type:FK.WorkerEventType.internalError,error:Error(r.reason)};i.next(o)};e.addEventListener("message",n),e.addEventListener("unhandledrejection",I),g.then(()=>{const r={type:FK.WorkerEventType.termination};e.removeEventListener("message",n),e.removeEventListener("unhandledrejection",I),i.next(r),i.complete()})})}function lXt(e){const[g,i]=iXt.createPromiseWithResolver();return{terminate:()=>fCe(this,void 0,void 0,function*(){DMe("Terminating worker"),yield e.terminate(),i()}),termination:g}}function kGe(e,g,i,n){const I=i.filter(r=>r.type===FK.WorkerEventType.internalError).map(r=>r.error);return Object.assign(e,{[yk.$errors]:I,[yk.$events]:i,[yk.$terminate]:n,[yk.$worker]:g})}function cXt(e,g){return fCe(this,void 0,void 0,function*(){IXt("Initializing new thread");const i=g&&g.timeout?g.timeout:CXt,I=(yield aXt(sXt(e),i,`Timeout: Did not receive an init message from worker after ${i}ms. Make sure the worker calls expose().`)).exposed,{termination:r,terminate:o}=lXt(e),C=AXt(e,r);if(I.type==="function"){const a=NGe.createProxyFunction(e);return kGe(a,e,C,o)}else if(I.type==="module"){const a=NGe.createProxyModule(e,I.methods);return kGe(a,e,C,o)}else{const a=I.type;throw Error(`Worker init message states unexpected type of expose(): ${a}`)}})}Rz.spawn=cXt;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Worker=e.BlobWorker=e.isWorkerRuntime=e.Thread=e.spawn=e.Pool=void 0;const g=ud;Object.defineProperty(e,"isWorkerRuntime",{enumerable:!0,get:function(){return g.isWorkerRuntime}});var i=VMe;Object.defineProperty(e,"Pool",{enumerable:!0,get:function(){return i.Pool}});var n=Rz;Object.defineProperty(e,"spawn",{enumerable:!0,get:function(){return n.spawn}});var I=bT;Object.defineProperty(e,"Thread",{enumerable:!0,get:function(){return I.Thread}}),e.BlobWorker=g.getWorkerImplementation().blob,e.Worker=g.getWorkerImplementation().default})(SMe);var MMe={},uXt=e=>e?typeof Symbol.observable=="symbol"&&typeof e[Symbol.observable]=="function"?e===e[Symbol.observable]():typeof e["@@observable"]=="function"?e===e["@@observable"]():!1:!1,pCe={};Object.defineProperty(pCe,"__esModule",{value:!0});const dXt=function(){const g=typeof self<"u"&&typeof Window<"u"&&self instanceof Window;return!!(typeof self<"u"&&self.postMessage&&!g)},hXt=function(g,i){self.postMessage(g,i)},fXt=function(g){const i=I=>{g(I.data)},n=()=>{self.removeEventListener("message",i)};return self.addEventListener("message",i),n};pCe.default={isWorkerRuntime:dXt,postMessageToMaster:hXt,subscribeToMasterMessages:fXt};(function(e){var g=un&&un.__awaiter||function(S,R,w,T){function W(V){return V instanceof w?V:new w(function(X){X(V)})}return new(w||(w=Promise))(function(V,X){function N(M){try{x(T.next(M))}catch(F){X(F)}}function Y(M){try{x(T.throw(M))}catch(F){X(F)}}function x(M){M.done?V(M.value):W(M.value).then(N,Y)}x((T=T.apply(S,R||[])).next())})},i=un&&un.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(e,"__esModule",{value:!0}),e.expose=e.isWorkerRuntime=e.Transfer=e.registerSerializer=void 0;const n=i(uXt),I=rs,r=Hd,o=hCe,C=i(pCe);var a=rs;Object.defineProperty(e,"registerSerializer",{enumerable:!0,get:function(){return a.registerSerializer}});var A=Hd;Object.defineProperty(e,"Transfer",{enumerable:!0,get:function(){return A.Transfer}}),e.isWorkerRuntime=C.default.isWorkerRuntime;let s=!1;const l=new Map,c=S=>S&&S.type===o.MasterMessageType.cancel,u=S=>S&&S.type===o.MasterMessageType.run,d=S=>n.default(S)||h(S);function h(S){return S&&typeof S=="object"&&typeof S.subscribe=="function"}function f(S){return r.isTransferDescriptor(S)?{payload:S.send,transferables:S.transferables}:{payload:S,transferables:void 0}}function m(){const S={type:o.WorkerMessageType.init,exposed:{type:"function"}};C.default.postMessageToMaster(S)}function b(S){const R={type:o.WorkerMessageType.init,exposed:{type:"module",methods:S}};C.default.postMessageToMaster(R)}function p(S,R){const{payload:w,transferables:T}=f(R),W={type:o.WorkerMessageType.error,uid:S,error:I.serialize(w)};C.default.postMessageToMaster(W,T)}function y(S,R,w){const{payload:T,transferables:W}=f(w),V={type:o.WorkerMessageType.result,uid:S,complete:R?!0:void 0,payload:T};C.default.postMessageToMaster(V,W)}function Z(S,R){const w={type:o.WorkerMessageType.running,uid:S,resultType:R};C.default.postMessageToMaster(w)}function v(S){try{const R={type:o.WorkerMessageType.uncaughtError,error:I.serialize(S)};C.default.postMessageToMaster(R)}catch(R){console.error(`Not reporting uncaught error back to master thread as it occured while reporting an uncaught error already. +Latest error:`,R,` +Original error:`,S)}}function G(S,R,w){return g(this,void 0,void 0,function*(){let T;try{T=R(...w)}catch(V){return p(S,V)}const W=d(T)?"observable":"promise";if(Z(S,W),d(T)){const V=T.subscribe(X=>y(S,!1,I.serialize(X)),X=>{p(S,I.serialize(X)),l.delete(S)},()=>{y(S,!0),l.delete(S)});l.set(S,V)}else try{const V=yield T;y(S,!0,I.serialize(V))}catch(V){p(S,I.serialize(V))}})}function B(S){if(!C.default.isWorkerRuntime())throw Error("expose() called in the master thread.");if(s)throw Error("expose() called more than once. This is not possible. Pass an object to expose() if you want to expose multiple functions.");if(s=!0,typeof S=="function")C.default.subscribeToMasterMessages(R=>{u(R)&&!R.method&&G(R.uid,S,R.args.map(I.deserialize))}),m();else if(typeof S=="object"&&S){C.default.subscribeToMasterMessages(w=>{u(w)&&w.method&&G(w.uid,S[w.method],w.args.map(I.deserialize))});const R=Object.keys(S).filter(w=>typeof S[w]=="function");b(R)}else throw Error(`Invalid argument passed to expose(). Expected a function or an object, got: ${S}`);C.default.subscribeToMasterMessages(R=>{if(c(R)){const w=R.uid,T=l.get(w);T&&(T.unsubscribe(),l.delete(w))}})}e.expose=B,typeof self<"u"&&typeof self.addEventListener=="function"&&C.default.isWorkerRuntime()&&(self.addEventListener("error",S=>{setTimeout(()=>v(S.error||S),250)}),self.addEventListener("unhandledrejection",S=>{const R=S.reason;R&&typeof R.message=="string"&&setTimeout(()=>v(R),250)})),typeof process<"u"&&typeof process.on=="function"&&C.default.isWorkerRuntime()&&(process.on("uncaughtException",S=>{setTimeout(()=>v(S),250)}),process.on("unhandledRejection",S=>{S&&typeof S.message=="string"&&setTimeout(()=>v(S),250)}))})(MMe);(function(e){var g=un&&un.__createBinding||(Object.create?function(C,a,A,s){s===void 0&&(s=A),Object.defineProperty(C,s,{enumerable:!0,get:function(){return a[A]}})}:function(C,a,A,s){s===void 0&&(s=A),C[s]=a[A]}),i=un&&un.__exportStar||function(C,a){for(var A in C)A!=="default"&&!Object.prototype.hasOwnProperty.call(a,A)&&g(a,C,A)};Object.defineProperty(e,"__esModule",{value:!0}),e.Transfer=e.DefaultSerializer=e.expose=e.registerSerializer=void 0;var n=rs;Object.defineProperty(e,"registerSerializer",{enumerable:!0,get:function(){return n.registerSerializer}}),i(SMe,e);var I=MMe;Object.defineProperty(e,"expose",{enumerable:!0,get:function(){return I.expose}});var r=Vb;Object.defineProperty(e,"DefaultSerializer",{enumerable:!0,get:function(){return r.DefaultSerializer}});var o=Hd;Object.defineProperty(e,"Transfer",{enumerable:!0,get:function(){return o.Transfer}})})(BMe);const xm=Ba(BMe);xm.registerSerializer;const Xz=xm.spawn;xm.BlobWorker;xm.DefaultSerializer;xm.Pool;xm.Thread;xm.Transfer;xm.Worker;class mXt extends Map{constructor(g={}){if(super(),!(g.maxSize&&g.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if(typeof g.maxAge=="number"&&g.maxAge===0)throw new TypeError("`maxAge` must be a number greater than 0");this.maxSize=g.maxSize,this.maxAge=g.maxAge||Number.POSITIVE_INFINITY,this.onEviction=g.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(g){if(typeof this.onEviction=="function")for(const[i,n]of g)this.onEviction(i,n.value)}_deleteIfExpired(g,i){return typeof i.expiry=="number"&&i.expiry<=Date.now()?(typeof this.onEviction=="function"&&this.onEviction(g,i.value),this.delete(g)):!1}_getOrDeleteIfExpired(g,i){if(this._deleteIfExpired(g,i)===!1)return i.value}_getItemValue(g,i){return i.expiry?this._getOrDeleteIfExpired(g,i):i.value}_peek(g,i){const n=i.get(g);return this._getItemValue(g,n)}_set(g,i){this.cache.set(g,i),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(g,i){this.oldCache.delete(g),this._set(g,i)}*_entriesAscending(){for(const g of this.oldCache){const[i,n]=g;this.cache.has(i)||this._deleteIfExpired(i,n)===!1&&(yield g)}for(const g of this.cache){const[i,n]=g;this._deleteIfExpired(i,n)===!1&&(yield g)}}get(g){if(this.cache.has(g)){const i=this.cache.get(g);return this._getItemValue(g,i)}if(this.oldCache.has(g)){const i=this.oldCache.get(g);if(this._deleteIfExpired(g,i)===!1)return this._moveToRecent(g,i),i.value}}set(g,i,{maxAge:n=this.maxAge}={}){const I=typeof n=="number"&&n!==Number.POSITIVE_INFINITY?Date.now()+n:void 0;this.cache.has(g)?this.cache.set(g,{value:i,expiry:I}):this._set(g,{value:i,expiry:I})}has(g){return this.cache.has(g)?!this._deleteIfExpired(g,this.cache.get(g)):this.oldCache.has(g)?!this._deleteIfExpired(g,this.oldCache.get(g)):!1}peek(g){if(this.cache.has(g))return this._peek(g,this.cache);if(this.oldCache.has(g))return this._peek(g,this.oldCache)}delete(g){const i=this.cache.delete(g);return i&&this._size--,this.oldCache.delete(g)||i}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(g){if(!(g&&g>0))throw new TypeError("`maxSize` must be a number greater than 0");const i=[...this._entriesAscending()],n=i.length-g;n<0?(this.cache=new Map(i),this.oldCache=new Map,this._size=i.length):(n>0&&this._emitEvictions(i.slice(0,n)),this.oldCache=new Map(i.slice(n)),this.cache=new Map,this._size=0),this.maxSize=g}*keys(){for(const[g]of this)yield g}*values(){for(const[,g]of this)yield g}*[Symbol.iterator](){for(const g of this.cache){const[i,n]=g;this._deleteIfExpired(i,n)===!1&&(yield[i,n.value])}for(const g of this.oldCache){const[i,n]=g;this.cache.has(i)||this._deleteIfExpired(i,n)===!1&&(yield[i,n.value])}}*entriesDescending(){let g=[...this.cache];for(let i=g.length-1;i>=0;--i){const n=g[i],[I,r]=n;this._deleteIfExpired(I,r)===!1&&(yield[I,r.value])}g=[...this.oldCache];for(let i=g.length-1;i>=0;--i){const n=g[i],[I,r]=n;this.cache.has(I)||this._deleteIfExpired(I,r)===!1&&(yield[I,r.value])}}*entriesAscending(){for(const[g,i]of this._entriesAscending())yield[g,i.value]}get size(){if(!this._size)return this.oldCache.size;let g=0;for(const i of this.oldCache.keys())this.cache.has(i)||g++;return Math.min(this._size+g,this.maxSize)}entries(){return this.entriesAscending()}forEach(g,i=this){for(const[n,I]of this.entriesAscending())g.call(i,I,n,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}}var YGe={},ZU={},GU=34,oR=10,vU=13;function zMe(e){return new Function("d","return {"+e.map(function(g,i){return JSON.stringify(g)+": d["+i+'] || ""'}).join(",")+"}")}function pXt(e,g){var i=zMe(e);return function(n,I){return g(i(n),I,e)}}function KGe(e){var g=Object.create(null),i=[];return e.forEach(function(n){for(var I in n)I in g||i.push(g[I]=I)}),i}function IC(e,g){var i=e+"",n=i.length;return n9999?"+"+IC(e,6):IC(e,4)}function yXt(e){var g=e.getUTCHours(),i=e.getUTCMinutes(),n=e.getUTCSeconds(),I=e.getUTCMilliseconds();return isNaN(e)?"Invalid Date":bXt(e.getUTCFullYear())+"-"+IC(e.getUTCMonth()+1,2)+"-"+IC(e.getUTCDate(),2)+(I?"T"+IC(g,2)+":"+IC(i,2)+":"+IC(n,2)+"."+IC(I,3)+"Z":n?"T"+IC(g,2)+":"+IC(i,2)+":"+IC(n,2)+"Z":i||g?"T"+IC(g,2)+":"+IC(i,2)+"Z":"")}function ZXt(e){var g=new RegExp('["'+e+` +\r]`),i=e.charCodeAt(0);function n(l,c){var u,d,h=I(l,function(f,m){if(u)return u(f,m-1);d=f,u=c?pXt(f,c):zMe(f)});return h.columns=d||[],h}function I(l,c){var u=[],d=l.length,h=0,f=0,m,b=d<=0,p=!1;l.charCodeAt(d-1)===oR&&--d,l.charCodeAt(d-1)===vU&&--d;function y(){if(b)return ZU;if(p)return p=!1,YGe;var v,G=h,B;if(l.charCodeAt(G)===GU){for(;h++=d?b=!0:(B=l.charCodeAt(h++))===oR?p=!0:B===vU&&(p=!0,l.charCodeAt(h)===oR&&++h),l.slice(G+1,v-1).replace(/""/g,'"')}for(;hsvg{width:30px;height:20px}._context-menu-item_18ock_27{padding:2px;white-space:nowrap;border-radius:2px;transition:background .15s cubic-bezier(.25,.1,.25,1),color .15s cubic-bezier(.25,.1,.25,1)}._context-menu-item_18ock_27:hover{background:#337ab7;color:#fff}._context-menu-hr_18ock_38{margin-top:5px;margin-bottom:5px;border:0;border-top:1px solid rgba(0,0,0,.1)}._play-icon_18ock_45{width:12px;height:12px;position:absolute;right:5px}._context-menu-span_18ock_52{margin-right:20px;vertical-align:middle;display:inline-block;line-height:normal;white-space:nowrap}._context-menu-thumbnail_18ock_60{margin-right:10px;border:1px solid #888888}._context-menu-thumbnail-inline_18ock_65{display:inline-block;margin-right:10px;vertical-align:middle}._multitrack-header_1yz7l_1,._multitrack-header-focus_1yz7l_2,._multitrack-header-squeazed_1yz7l_3{position:relative;display:flex;justify-content:space-between;height:24px;margin-top:4px;margin-bottom:4px;color:#999;font-size:12px;line-height:24px;vertical-align:middle;border:0;border-radius:3px;background:#e5e5e5;transition:height .15s cubic-bezier(.25,.1,.25,1),margin .15s cubic-bezier(.25,.1,.25,1)}._multitrack-header-dark_1yz7l_20{background:#222}._multitrack-header-focus_1yz7l_2{height:32px;margin-top:0;margin-bottom:0}._multitrack-header-id_1yz7l_30{padding-left:3px}._multitrack-header-id_1yz7l_30:before{content:"ID:";font-weight:700;padding-right:5px}._multitrack-header-left_1yz7l_39{display:flex;flex-grow:1}._multitrack-header-grabber_1yz7l_44,._multitrack-header-grabber-squeazed_1yz7l_45{display:flex;align-items:center;justify-content:center;width:24px;height:100%;cursor:move;border-radius:3px 0 0 3px;transition:background .15s cubic-bezier(.25,.1,.25,1)}._multitrack-header-grabber_1yz7l_44:hover,._multitrack-header-grabber-squeazed_1yz7l_45:hover{background:#999}._multitrack-header-grabber_1yz7l_44:hover div,._multitrack-header-grabber-squeazed_1yz7l_45:hover div{background:#fff}._multitrack-header-grabber_1yz7l_44 div,._multitrack-header-grabber-squeazed_1yz7l_45 div{width:1px;height:50%;margin:1px;background:#999;transition:background .15s cubic-bezier(.25,.1,.25,1)}._multitrack-header-dark_1yz7l_20 ._multitrack-header-grabber_1yz7l_44 div{background:#666}._multitrack-header-grabber-squeazed_1yz7l_45{width:19.2px}._multitrack-header-search_1yz7l_80{position:relative;flex-grow:1;height:100%;margin-right:12px}._multitrack-header-search_1yz7l_80:after{position:absolute;top:3px;bottom:3px;right:-12px;display:block;content:"";width:1px;margin:0 6px;background:#cccccc}._multitrack-header-dark_1yz7l_20 ._multitrack-header-search_1yz7l_80:after{background:#666}._multitrack-header-nav-list_1yz7l_102,._multitrack-header_1yz7l_1>nav{display:flex}._multitrack-header-icon_1yz7l_107,._multitrack-header-icon-squeazed_1yz7l_108{width:24px;height:100%;padding:6px;transition:background .15s cubic-bezier(.25,.1,.25,1),color .15s cubic-bezier(.25,.1,.25,1)}._multitrack-header-icon_1yz7l_107 g,._multitrack-header-icon-squeazed_1yz7l_108 g{stroke:#999}._multitrack-header-icon_1yz7l_107:hover,._multitrack-header-icon_1yz7l_107:active,._multitrack-header-icon_1yz7l_107:focus,._multitrack-header-icon-squeazed_1yz7l_108:hover,._multitrack-header-icon-squeazed_1yz7l_108:active,._multitrack-header-icon-squeazed_1yz7l_108:focus{color:#fff;background:#337ab7}._multitrack-header-icon_1yz7l_107:hover g,._multitrack-header-icon_1yz7l_107:active g,._multitrack-header-icon_1yz7l_107:focus g,._multitrack-header-icon-squeazed_1yz7l_108:hover g,._multitrack-header-icon-squeazed_1yz7l_108:active g,._multitrack-header-icon-squeazed_1yz7l_108:focus g{stroke:#fff}._multitrack-header-icon_1yz7l_107:last-child,._multitrack-header-icon-squeazed_1yz7l_108:last-child{border-radius:0 3px 3px 0}._mouse-tool-selection_1yz7l_136{color:#fff;border-radius:3px 0 0 3px;background:#337ab7}._multitrack-header-icon-squeazed_1yz7l_108{width:20px 5;padding-left:3px;padding-right:3px}._track-control_w7hx2_1,._track-control-vertical_w7hx2_2{position:absolute;z-index:1;display:flex;background:rgba(255,255,255,.75);right:2px;top:2px;border-radius:2.5px;box-shadow:0 0 0 1px #0000000d,0 0 3px #0000001a;opacity:0;transition:opacity .15s cubic-bezier(.25,.1,.25,1),background .15s cubic-bezier(.25,.1,.25,1),box-shadow .15s cubic-bezier(.25,.1,.25,1)}._track-control-dark_w7hx2_15,._track-control-dark_w7hx2_15 ._track-control-active_w7hx2_16{background:rgba(40,40,40,.85)}._track-control-vertical_w7hx2_2{flex-direction:column-reverse}._track-control-left_w7hx2_24{left:2px;right:auto}._track-control-active_w7hx2_16,._track-control-vertical-active_w7hx2_30{opacity:1;z-index:1}._track-control-active_w7hx2_16:hover,._track-control-vertical-active_w7hx2_30:hover{background:rgb(255,255,255);box-shadow:0 0 0 1px #0000001a,0 0 3px #0003}._track-control-dark_w7hx2_15._track-control-active_w7hx2_16:hover{background:rgba(34,34,34,.95)}._track-control-padding-right_w7hx2_48{right:80px}._track-control-button_w7hx2_52{width:20px;height:20px;padding:4px;cursor:pointer;opacity:.66;transition:background .15s cubic-bezier(.25,.1,.25,1),color .15s cubic-bezier(.25,.1,.25,1),opacity .15s cubic-bezier(.25,.1,.25,1)}._track-control-button_w7hx2_52:hover{color:#fff;background:#337ab7;opacity:1}._track-control-button_w7hx2_52:first-child{border-radius:2.5px 0 0 2.5px}._track-control-button_w7hx2_52:last-child{border-radius:0 2.5px 2.5px 0}._track-control-dark_w7hx2_15 ._track-control-button_w7hx2_52{color:#ccc}._track-control-dark_w7hx2_15 ._track-control-button_w7hx2_52:hover{color:#fff;background:#337ab7;opacity:1}._track-control-button-vertical_w7hx2_81:first-child{border-radius:0 0 2.5px 2.5px}._track-control-button-vertical_w7hx2_81:last-child{border-radius:2.5px 2.5px 0 0}._center-track_fiu64_1{position:relative;background:transparent}._center-track-container_fiu64_6{position:absolute;z-index:1}._track-range-selection_5bcsr_1{position:absolute;z-index:-1;opacity:0;transition:opacity .15s cubic-bezier(.25,.1,.25,1)}._track-range-selection-active_5bcsr_8{z-index:1;opacity:1}._track-range-selection-group-inactive_5bcsr_22{display:none}._track-range-selection-group-brush-selection_5bcsr_26{outline:2px solid rgba(0,0,0,.33);fill:#000;fill-opacity:.1}._drag-listening-div-active_19gkt_1{z-index:10;box-shadow:inset 0 0 3px red}._gallery-tracks_fbxxi_1{position:relative;top:0;left:0;width:100%;height:100%}._gallery-track_fbxxi_1{position:absolute;box-sizing:border-box;top:0;right:0;bottom:0;left:0}._gallery-sub-track_fbxxi_18,._gallery-invisible-track_fbxxi_19{position:absolute}._tiled-plot_1y7td_1{position:relative;flex:1;overflow:hidden}._horizontalList_1y7td_7{display:flex;width:600px;height:300px;white-space:nowrap}._list_1y7td_14{width:400px;height:600px;overflow:hidden;-webkit-overflow-scrolling:touch}._stylizedList_1y7td_21{position:relative;z-index:0;background-color:#f3f3f3;outline:none}._stylizedItem_1y7td_28{position:relative;display:flex;align-items:center;width:100%;background-color:transparent;-webkit-user-select:none;user-select:none;color:#333;font-weight:400}._stylizedHelper_1y7td_39{box-shadow:0 5px 5px -5px #0003,0 -5px 5px -5px #0003;background-color:#fffc;cursor:row-resize}._stylizedHelper_1y7td_39._horizontalItem_1y7td_44{cursor:col-resize}._horizontalItem_1y7td_44{display:flex;flex-shrink:0;align-items:center;justify-content:center}._resizable-track_1y7td_55{width:100%;height:100%}path._domain_1y7td_60{stroke-width:0px}._top-right-handle_cizw2_1,._bottom-right-handle_cizw2_2{border-right:black solid;border-top:black solid}._top-left-handle_cizw2_7,._bottom-left-handle_cizw2_8{border-left:black solid;border-top:black solid}._top-draggable-handle_cizw2_13,._bottom-draggable-handle_cizw2_14,._left-draggable-handle_cizw2_15,._right-draggable-handle_cizw2_16{position:absolute;opacity:0;transition:transform .15s cubic-bezier(.25,.1,.25,1),opacity .15s cubic-bezier(.25,.1,.25,1)}._draggable-div_cizw2_22{background-color:transparent;box-sizing:border-box}._top-draggable-handle-grabber_cizw2_27,._bottom-draggable-handle-grabber_cizw2_28{width:10px;height:4px;border-top:1px solid black;border-bottom:1px solid black}._top-draggable-handle-grabber_cizw2_27,._bottom-draggable-handle-grabber_cizw2_28{margin:4px 7px}._left-draggable-handle-grabber_cizw2_43,._right-draggable-handle-grabber_cizw2_44{width:4px;height:10px;border-left:1px solid black;border-right:1px solid black}._left-draggable-handle-grabber_cizw2_43,._right-draggable-handle-grabber_cizw2_44{margin:7px 4px}._draggable-div_cizw2_22:hover ._top-draggable-handle_cizw2_13,._draggable-div_cizw2_22:hover ._bottom-draggable-handle_cizw2_14,._draggable-div_cizw2_22:hover ._left-draggable-handle_cizw2_15,._draggable-div_cizw2_22:hover ._right-draggable-handle_cizw2_16{opacity:.5;background:rgba(255,255,255,.75);box-shadow:0 0 3px 1px #ffffffbf;border-radius:3px}._top-draggable-handle_cizw2_13:hover,._top-draggable-handle_cizw2_13:active,._bottom-draggable-handle_cizw2_14:hover,._bottom-draggable-handle_cizw2_14:active,._left-draggable-handle_cizw2_15:hover,._left-draggable-handle_cizw2_15:active,._right-draggable-handle_cizw2_16:hover,._right-draggable-handle_cizw2_16:active{opacity:1!important;transform:scale(2)}._top-draggable-handle_cizw2_13:hover ._top-draggable-handle-grabber_cizw2_27,._top-draggable-handle_cizw2_13:hover ._bottom-draggable-handle-grabber_cizw2_28,._top-draggable-handle_cizw2_13:hover ._left-draggable-handle-grabber_cizw2_43,._top-draggable-handle_cizw2_13:hover ._right-draggable-handle-grabber_cizw2_44,._top-draggable-handle_cizw2_13:active ._top-draggable-handle-grabber_cizw2_27,._top-draggable-handle_cizw2_13:active ._bottom-draggable-handle-grabber_cizw2_28,._top-draggable-handle_cizw2_13:active ._left-draggable-handle-grabber_cizw2_43,._top-draggable-handle_cizw2_13:active ._right-draggable-handle-grabber_cizw2_44,._bottom-draggable-handle_cizw2_14:hover ._top-draggable-handle-grabber_cizw2_27,._bottom-draggable-handle_cizw2_14:hover ._bottom-draggable-handle-grabber_cizw2_28,._bottom-draggable-handle_cizw2_14:hover ._left-draggable-handle-grabber_cizw2_43,._bottom-draggable-handle_cizw2_14:hover ._right-draggable-handle-grabber_cizw2_44,._bottom-draggable-handle_cizw2_14:active ._top-draggable-handle-grabber_cizw2_27,._bottom-draggable-handle_cizw2_14:active ._bottom-draggable-handle-grabber_cizw2_28,._bottom-draggable-handle_cizw2_14:active ._left-draggable-handle-grabber_cizw2_43,._bottom-draggable-handle_cizw2_14:active ._right-draggable-handle-grabber_cizw2_44,._left-draggable-handle_cizw2_15:hover ._top-draggable-handle-grabber_cizw2_27,._left-draggable-handle_cizw2_15:hover ._bottom-draggable-handle-grabber_cizw2_28,._left-draggable-handle_cizw2_15:hover ._left-draggable-handle-grabber_cizw2_43,._left-draggable-handle_cizw2_15:hover ._right-draggable-handle-grabber_cizw2_44,._left-draggable-handle_cizw2_15:active ._top-draggable-handle-grabber_cizw2_27,._left-draggable-handle_cizw2_15:active ._bottom-draggable-handle-grabber_cizw2_28,._left-draggable-handle_cizw2_15:active ._left-draggable-handle-grabber_cizw2_43,._left-draggable-handle_cizw2_15:active ._right-draggable-handle-grabber_cizw2_44,._right-draggable-handle_cizw2_16:hover ._top-draggable-handle-grabber_cizw2_27,._right-draggable-handle_cizw2_16:hover ._bottom-draggable-handle-grabber_cizw2_28,._right-draggable-handle_cizw2_16:hover ._left-draggable-handle-grabber_cizw2_43,._right-draggable-handle_cizw2_16:hover ._right-draggable-handle-grabber_cizw2_44,._right-draggable-handle_cizw2_16:active ._top-draggable-handle-grabber_cizw2_27,._right-draggable-handle_cizw2_16:active ._bottom-draggable-handle-grabber_cizw2_28,._right-draggable-handle_cizw2_16:active ._left-draggable-handle-grabber_cizw2_43,._right-draggable-handle_cizw2_16:active ._right-draggable-handle-grabber_cizw2_44{box-shadow:0 0 3px 1px #0089ff;background:#0089ff}._top-draggable-handle_cizw2_13,._bottom-draggable-handle_cizw2_14{height:12px;cursor:row-resize}._left-draggable-handle_cizw2_15,._right-draggable-handle_cizw2_16{width:12px;cursor:col-resize}._horizontal-tiled-plot_1bqkg_1{position:relative}._button_1wnjn_1{display:flex;align-items:center;box-sizing:border-box;padding:.5em;color:#000;font-size:1em;line-height:1em;border:0;border-radius:2.5px;background:#fff;box-shadow:0 0 0 1px #ccc;transition:transform .15s cubic-bezier(.25,.1,.25,1),box-shadow .15s cubic-bezier(.25,.1,.25,1),background .15s cubic-bezier(.25,.1,.25,1);-webkit-appearance:none}._button_1wnjn_1:hover{background:#f2f2f2;box-shadow:0 0 0 1px #ccc}._button_1wnjn_1:focus{box-shadow:0 0 0 2px #0089ff}._button_1wnjn_1:active{transform:scale(.9)}._button_1wnjn_1:hover,._button_1wnjn_1:focus,._button_1wnjn_1:active{cursor:pointer;outline:none}._button-shortcut_1wnjn_35{padding:.1em 5px;color:#999;font-size:.8em;transition:color .15s cubic-bezier(.25,.1,.25,1)}._cross_2ke8w_1{position:relative;width:1em;height:1em}._cross_2ke8w_1:before,._cross_2ke8w_1:after{content:"";display:block;position:absolute;top:50%;left:0;width:1em;height:1px;background:black;transform-origin:center}._cross_2ke8w_1:before{-webkit-transform:translate(0,-50%) rotate(45deg);-moz-transform:translate(0,-50%) rotate(45deg);transform:translateY(-50%) rotate(45deg)}._cross_2ke8w_1:after{-webkit-transform:translate(0,-50%) rotate(-45deg);-moz-transform:translate(0,-50%) rotate(-45deg);transform:translateY(-50%) rotate(-45deg)}._modal-background_zzhoe_1{position:absolute;z-index:1000;top:0;right:0;bottom:0;left:0;background:rgba(0,0,0,.666);animation:_fade-in_zzhoe_1 .2s cubic-bezier(.25,.1,.25,1) 1;transition:opacity .2s cubic-bezier(.25,.1,.25,1)}._modal-hide_zzhoe_13{opacity:0}._modal-wrap_zzhoe_17{position:absolute;top:20px;right:20px;bottom:20px;left:20px}._modal-window_zzhoe_25{position:relative;width:100%;max-width:640px;max-height:100%;margin-left:auto;margin-right:auto;color:#000;border-radius:5px;background:#fff;animation:_fade-scale-in_zzhoe_1 .2s cubic-bezier(.25,.1,.25,1) 1}._modal-window-max-height_zzhoe_38{height:100%}._modal-content_zzhoe_42{padding:10px}@keyframes _fade-in_zzhoe_1{0%{opacity:0}to{opacity:1}}@keyframes _fade-scale-in_zzhoe_1{0%{opacity:0;transform:scale(.5)}to{opacity:1;transform:scale(1)}}._dialog-header_wp50s_1{position:relative;z-index:2;display:flex;justify-content:space-between;margin:0 -10px 10px;padding:0 10px 10px;border-bottom:1px solid #cccccc}._dialog-header_wp50s_1 h3{margin:0;padding:0;font-size:20px;line-height:1em}._dialog-header_wp50s_1 button{font-size:10px}._dialog-main-max-height_wp50s_20{position:absolute;z-index:1;top:40px;right:0;bottom:50px;left:0;padding:10px;overflow:auto}._dialog-footer_wp50s_31,._dialog-footer-max-height_wp50s_31{display:flex;justify-content:space-between;margin:10px -10px 0;padding:10px 10px 0;border-top:1px solid #cccccc}._dialog-footer_wp50s_31 button,._dialog-footer-max-height_wp50s_31 button{font-size:14px}._dialog-footer-max-height_wp50s_31{position:absolute;z-index:2;left:10px;right:10px;bottom:10px}table.table-track-options{border-collapse:collapse;margin-left:auto;margin-right:auto}td.td-track-options{border:1px solid #fff;outline:none;padding:3px;position:relative;font-family:Roboto,sans-serif;font-size:14px;color:#666}.cell-label{position:absolute;left:0;top:0;margin-left:5px;color:#777}.modal-dialog{position:relative;display:table;overflow-y:auto;overflow-x:auto;width:auto;min-width:300px;margin:auto}._track-renderer_11dwb_1{position:relative}._track-renderer-element_11dwb_5,._track-renderer-events_11dwb_6{position:absolute;top:0;right:0;bottom:0;left:0;z-index:-1}._track-renderer-events_11dwb_6{z-index:1}.tileset-finder-label{font-weight:700}.tileset-finder-search-box{margin-left:10px}.tileset-finder-search-bar{display:flex;margin-left:5px;justify-content:space-between;align-items:center}.tileset-finder-checkbox-tree{margin:5px;padding:3px;border:1px solid #aaaaaa;border-radius:5px}.react-checkbox-tree{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:reverse;-ms-flex-direction:row-reverse;flex-direction:row-reverse;font-size:16px}.react-checkbox-tree>ol{-webkit-box-flex:1;-ms-flex:1 1 auto;flex:1 1 auto}.react-checkbox-tree ol{margin:0;padding-left:0;list-style-type:none}.react-checkbox-tree ol ol{padding-left:24px}.react-checkbox-tree button{line-height:normal;color:inherit}.react-checkbox-tree button:disabled{cursor:not-allowed}.react-checkbox-tree .rct-bare-label{cursor:default}.react-checkbox-tree label{margin-bottom:0;cursor:pointer}.react-checkbox-tree label:hover{background:rgba(51,51,204,.1)}.react-checkbox-tree label:active,.react-checkbox-tree label:focus{background:rgba(51,51,204,.15)}.react-checkbox-tree:not(.rct-native-display) input{display:none}.react-checkbox-tree.rct-native-display input{margin:0 5px}.react-checkbox-tree .rct-icon{display:inline-block;text-align:center;text-rendering:auto;font-family:"Font Awesome 5 Free",FontAwesome,sans-serif;font-weight:400;font-variant:normal;font-style:normal}.rct-disabled>.rct-text>label{opacity:.75;cursor:not-allowed}.rct-disabled>.rct-text>label:hover{background:transparent}.rct-disabled>.rct-text>label:active{background:transparent}.rct-text{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.rct-options{-webkit-box-flex:0;-ms-flex:0 0 auto;flex:0 0 auto;margin-left:.5rem;text-align:right}.rct-option{opacity:.75;border:0;background:none;cursor:pointer;padding:0 4px;font-size:18px}.rct-option:hover{opacity:1}.rct-option+.rct-option{margin-left:2px}.rct-collapse,.rct-checkbox,.rct-node-icon{padding:0 5px}.rct-collapse *,.rct-checkbox *,.rct-node-icon *{display:inline-block;margin:0;width:14px}.rct-collapse{-ms-flex-item-align:stretch;align-self:stretch;border:0;background:none;line-height:normal;color:inherit;font-size:12px}.rct-collapse.rct-collapse-btn{cursor:pointer}.rct-collapse>.rct-icon-expand-close{opacity:.5}.rct-collapse>.rct-icon-expand-close:hover{opacity:1}.rct-native-display .rct-checkbox{display:none}.rct-node-clickable{cursor:pointer}.rct-node-clickable:hover{background:rgba(51,51,204,.1)}.rct-node-clickable:focus{outline:0;background:rgba(51,51,204,.2)}.rct-node-icon{color:#33c}.rct-title{padding:0 5px}.rct-icons-fa4 .rct-icon-expand-close:before{content:""}.rct-icons-fa4 .rct-icon-expand-open:before{content:""}.rct-icons-fa4 .rct-icon-uncheck:before{content:""}.rct-icons-fa4 .rct-icon-check:before{content:""}.rct-icons-fa4 .rct-icon-half-check:before{opacity:.5;content:""}.rct-icons-fa4 .rct-icon-leaf:before{content:""}.rct-icons-fa4 .rct-icon-parent-open:before{content:""}.rct-icons-fa4 .rct-icon-parent-close:before{content:""}.rct-icons-fa4 .rct-icon-expand-all:before{content:""}.rct-icons-fa4 .rct-icon-collapse-all:before{content:""}.rct-icons-fa5 .rct-icon-expand-close:before{font-weight:900;content:""}.rct-icons-fa5 .rct-icon-expand-open:before{font-weight:900;content:""}.rct-icons-fa5 .rct-icon-uncheck:before{content:""}.rct-icons-fa5 .rct-icon-check:before{content:""}.rct-icons-fa5 .rct-icon-half-check:before{opacity:.5;content:""}.rct-icons-fa5 .rct-icon-leaf:before{content:""}.rct-icons-fa5 .rct-icon-parent-open:before{content:""}.rct-icons-fa5 .rct-icon-parent-close:before{content:""}.rct-icons-fa5 .rct-icon-expand-all:before{content:""}.rct-icons-fa5 .rct-icon-collapse-all:before{content:""}.rct-direction-rtl{direction:rtl}.rct-direction-rtl ol ol{padding-right:24px;padding-left:0}.rct-direction-rtl.rct-icons-fa4 .rct-icon-expand-close:before{content:""}.rct-direction-rtl.rct-icons-fa5 .rct-icon-expand-close:before{content:""}.plot-type-selected{background-color:#0000ff4d}.plot-type-container{overflow-y:scroll;margin:5px;padding:3px;border:1px solid #aaaaaa;border-radius:5px;max-height:15vh}.plot-type-container-empty{margin:5px;padding:3px 8px;border:1px solid #aaaaaa;background-color:#e8e8e8;border-radius:5px}.plot-type-item{cursor:pointer}.plot-type-item:not(.plot-type-selected):hover{background-color:#3333cc1a}.track-thumbnail{width:30px;height:20px;display:inline-block;margin-right:10;vertical-align:middle}.track-thumbnail>svg{width:20px;height:20px}._collapse-toggle-icon_ub7s6_1:before{font-family:Glyphicons Halflings;content:"";float:left;padding-right:3px}._collapse-toggle-icon_ub7s6_1._collapsed_ub7s6_9:before{content:""}._modal-title_ub7s6_14{font-family:Roboto;font-weight:700}._modal-container_ub7s6_19{position:relative}._modal-container_ub7s6_19 ._modal_ub7s6_14,._modal-container_ub7s6_19 ._modal-backdrop_ub7s6_23{position:absolute}._modal-dialog_ub7s6_27{position:relative;display:table;overflow-y:auto;overflow-x:auto;width:600px;min-width:300px;margin:auto}._vertical-tiled-plot_f3ho8_1{position:relative}._genome-position-search_1l2sx_1,._genome-position-search-focus_1l2sx_2{position:relative;display:flex;align-items:stretch;height:100%;margin-bottom:0;font-size:13.7142857143px;transition:box-shadow .15s cubic-bezier(.25,.1,.25,1),font-size .15s cubic-bezier(.25,.1,.25,1)}._genome-position-search-focus_1l2sx_2{box-shadow:0 0 0 1px #337ab7,0 0 3px 1px #337ab7}._genome-position-search-bar_1l2sx_16{position:relative;box-sizing:border-box;width:100%;height:100%;padding:3px;color:#666;font-size:inherit;line-height:24px;border:0;border-radius:3px 0 0 3px;background:transparent}._genome-position-search-bar_1l2sx_16:focus{outline:none;color:#000}._genome-position-search-dark_1l2sx_34 ._genome-position-search-bar_1l2sx_16:focus{color:#e5e5e5}._genome-position-search-bar-button_1l2sx_38,._genome-position-search-bar-button-focus_1l2sx_39{display:block;height:100%;padding:0 8px!important;color:#999;border:0!important;border-radius:0!important;background:transparent;transition:background .15s cubic-bezier(.25,.1,.25,1),color .15s cubic-bezier(.25,.1,.25,1)}._genome-position-search-bar-button_1l2sx_38:active,._genome-position-search-bar-button_1l2sx_38:focus,._genome-position-search-bar-button_1l2sx_38:hover,._genome-position-search-bar-button-focus_1l2sx_39:active,._genome-position-search-bar-button-focus_1l2sx_39:focus,._genome-position-search-bar-button-focus_1l2sx_39:hover{color:#fff;background:#337ab7}._genome-position-search-bar-button-focus_1l2sx_39{color:#fff;background:#337ab7}._genome-position-search-bar-icon_1l2sx_62,._genome-position-search-bar-icon-focus_1l2sx_63{display:flex;align-items:center;transition:color .15s cubic-bezier(.25,.1,.25,1)}._genome-position-search-bar-icon_1l2sx_62:first-child,._genome-position-search-bar-icon-focus_1l2sx_63:first-child{margin-left:6px;margin-right:2px}._genome-position-search-bar-icon_1l2sx_62 span,._genome-position-search-bar-icon-focus_1l2sx_63 span{display:block;margin-top:-2px}._genome-position-search-bar-icon-focus_1l2sx_63{color:#337ab7}._genome-position-search-bar-suggestions_1l2sx_83{position:fixed;border-radius:3px;box-shadow:0 0 3px #0000001a,0 1px 5px #0000000d;background-color:#fffffff2;border:1px solid rgba(0,0,0,.1);padding:2px 0;font-size:90%;overflow:auto;max-height:50%}._btn_1l2sx_95{display:inline-block;margin-bottom:0;font-size:13.7142857143px;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;-ms-touch-action:manipulation;touch-action:manipulation;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:none;border:1px solid transparent;border-radius:4px}._btn-sm_1l2sx_116{font-size:12px;line-height:1.5;border-radius:3px}._btn-default_1l2sx_122{color:#666;background-color:#fff;border-color:#ccc}._btn-default_1l2sx_122:hover{color:#000;background:#ccc}._btn-default_1l2sx_122:active,._btn-default_1l2sx_122:focus{color:#fff;border-color:#000;background:#000}._genome-position-search_1l2sx_1 ._btn_1l2sx_95{border-radius:0 3px 3px 0}._export-link-dialog-wrapper_p9gxw_1{display:flex}._export-link-dialog-wrapper_p9gxw_1 input{flex-grow:1}._add-track-position-table_wdy5w_1{border-collapse:collapse;margin:5px;color:#666}._add-track-position-table-dark_wdy5w_7{color:#ccc}._add-track-position-other_wdy5w_11{outline:none}._add-track-position-top-center_wdy5w_15{min-width:80px;min-height:20px;text-align:center;outline:none;border-top:1px solid #999;border-left:1px solid #999;border-right:1px solid #999;border-radius:2px 2px 0 0}._add-track-position-top-center_wdy5w_15:hover{color:#fff;background-color:#337ab7}._add-track-position-middle-left_wdy5w_30{min-width:40px;text-align:center;outline:none;border-top:1px solid #999;border-left:1px solid #999;border-bottom:1px solid #999;border-radius:2px 0 0 2px}._add-track-position-middle-left_wdy5w_30:hover{background-color:#337ab7;color:#fff}._add-track-position-middle-right_wdy5w_45{min-width:40px;text-align:center;outline:none;border-top:1px solid #999;border-right:1px solid #999;border-bottom:1px solid #999;border-radius:0 2px 2px 0}._add-track-position-middle-right_wdy5w_45:hover{background-color:#337ab7;color:#fff}._add-track-position-middle-middle_wdy5w_60{text-align:center;outline:none;border:1px solid #999}._add-track-position-middle-middle_wdy5w_60:hover{background-color:#337ab7;color:#fff}._add-track-position-bottom-middle_wdy5w_71{min-height:20px;text-align:center;outline:none;border-left:1px solid #999;border-right:1px solid #999;border-bottom:1px solid #999;border-radius:0 0 2px 2px}._add-track-position-bottom-middle_wdy5w_71:hover{background-color:#337ab7;color:#fff}._add-track-position-span_wdy5w_86{margin:5px}._view-config-editor-header_1hlm6_1{margin:-10px -10px 0;padding:10px;display:flex;justify-content:space-between;background:#f2f2f2}._view-config-editor-header_1hlm6_1 button{display:flex;align-items:center;font-size:14px;background:#f2f2f2}._view-config-editor-header_1hlm6_1 button:hover{background:#e5e5e5}._view-config-editor-header_1hlm6_1 button:hover span{color:#666}._view-config-editor_1hlm6_1{position:absolute;top:50px;right:0;bottom:0;left:0;margin:1px 0 0;padding:0;overflow:auto;font-size:12.5px;height:calc(100% - 80px)}._view-config-log_1hlm6_34{position:absolute;right:0;bottom:0;left:0;margin:1px 0 0;padding:0;min-height:30px;background:#f2f2f2;transition:height .15s cubic-bezier(.25,.1,.25,1)}._view-config-log-header_1hlm6_46{background:#f2f2f2;border-top:1px solid #cccccc;border-bottom:1px solid #cccccc;padding-left:10px;height:30px;display:flex;align-items:center;cursor:pointer;position:sticky;position:-webkit-sticky;top:0}._view-config-log-msg_1hlm6_60{background:#f2f2f2;overflow:auto;height:calc(100% - 30px)}._view-config-log-msg_1hlm6_60 tr,._view-config-log-msg_1hlm6_60 td{outline:none;vertical-align:top}._view-config-log-msg_1hlm6_60 ._title_1hlm6_70{font-weight:700;padding-left:8px;padding-top:8px;width:100px}._view-config-log-msg_1hlm6_60 ._Warning_1hlm6_76{color:orange}._view-config-log-msg_1hlm6_60 ._Success_1hlm6_79{color:green}._view-config-log-msg_1hlm6_60 ._Error_1hlm6_82{color:red}._view-config-log-msg_1hlm6_60 pre{background:white;white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word}._higlass_1uoq8_1{position:relative}._higlass-dark-theme_1uoq8_5{background:black}._higlass-container-overflow_1uoq8_9,._higlass-scroll-container-overflow_1uoq8_10,._higlass-scroll-container-scroll_1uoq8_11{position:absolute;top:0;right:0;bottom:0;left:0}._higlass-scroll-container-overflow_1uoq8_10{overflow:hidden}._higlass-scroll-container-scroll_1uoq8_11{overflow-x:hidden;overflow-y:auto}._higlass-canvas_1uoq8_28{position:absolute;width:100%;height:100%}._higlass-drawing-surface_1uoq8_34{position:relative}._higlass-svg_1uoq8_38{position:absolute;width:100%;height:100%;left:0;top:0;pointer-events:none}._tiled-area_1uoq8_47{display:flex;flex-direction:column}._track-mouseover-menu_1uoq8_52{position:fixed;z-index:1;margin:17px 0 0 9px;padding:0 .25rem;max-width:50vw;word-wrap:break-word;font-size:.8em;pointer-events:none;background:white;border-radius:.25rem;box-shadow:0 0 0 1px #0000001a,0 0 3px #00000013,0 0 7px #0000000d}.react-grid-layout{position:relative;transition:height .2s ease}.react-grid-item{transition:all .2s ease;transition-property:left,top}.react-grid-item.cssTransforms{transition-property:transform}.react-grid-item.resizing{z-index:1;will-change:width,height}.react-grid-item.react-draggable-dragging{transition:none;z-index:3;will-change:transform}.react-grid-item.react-grid-placeholder{background:red;opacity:.2;transition-duration:.1s;z-index:2;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.react-grid-item>.react-resizable-handle{position:absolute;width:20px;height:20px;bottom:0;right:0;cursor:se-resize}.react-grid-item>.react-resizable-handle:after{content:"";position:absolute;right:3px;bottom:3px;width:5px;height:5px;border-right:2px solid rgba(0,0,0,.4);border-bottom:2px solid rgba(0,0,0,.4)}.react-resizable{position:relative}.react-resizable-handle{position:absolute;width:20px;height:20px;background-repeat:no-repeat;background-origin:content-box;box-sizing:border-box;background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2IDYiIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNmZmZmZmYwMCIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iNnB4Ij48ZyBvcGFjaXR5PSIwLjMwMiI+PHBhdGggZD0iTSA2IDYgTCAwIDYgTCAwIDQuMiBMIDQgNC4yIEwgNC4yIDQuMiBMIDQuMiAwIEwgNiAwIEwgNiA2IEwgNiA2IFoiIGZpbGw9IiMwMDAwMDAiLz48L2c+PC9zdmc+);background-position:bottom right;padding:0 3px 3px 0}.react-resizable-handle-sw{bottom:0;left:0;cursor:sw-resize;transform:rotate(90deg)}.react-resizable-handle-se{bottom:0;right:0;cursor:se-resize}.react-resizable-handle-nw{top:0;left:0;cursor:nw-resize;transform:rotate(180deg)}.react-resizable-handle-ne{top:0;right:0;cursor:ne-resize;transform:rotate(270deg)}.react-resizable-handle-w,.react-resizable-handle-e{top:50%;margin-top:-10px;cursor:ew-resize}.react-resizable-handle-w{left:0;transform:rotate(135deg)}.react-resizable-handle-e{right:0;transform:rotate(315deg)}.react-resizable-handle-n,.react-resizable-handle-s{left:50%;margin-left:-10px;cursor:ns-resize}.react-resizable-handle-n{top:0;transform:rotate(225deg)}.react-resizable-handle-s{bottom:0;transform:rotate(45deg)}code[class*=language-],pre[class*=language-]{color:#393a34;font-family:Consolas,Bitstream Vera Sans Mono,Courier New,Courier,monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;font-size:.95em;line-height:1.2em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]::-moz-selection,pre[class*=language-] ::-moz-selection,code[class*=language-]::-moz-selection,code[class*=language-] ::-moz-selection{background:#b3d4fc}pre[class*=language-]::selection,pre[class*=language-] ::selection,code[class*=language-]::selection,code[class*=language-] ::selection{background:#b3d4fc}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto;border:1px solid #dddddd;background-color:#fff}:not(pre)>code[class*=language-]{padding:1px .2em;background:#f8f8f8;border:1px solid #dddddd}.token.comment,.token.prolog,.token.doctype,.token.cdata{color:#998;font-style:italic}.token.namespace{opacity:.7}.token.string,.token.attr-value{color:#e3116c}.token.punctuation,.token.operator{color:#393a34}.token.entity,.token.url,.token.symbol,.token.number,.token.boolean,.token.variable,.token.constant,.token.property,.token.regex,.token.inserted{color:#36acaa}.token.atrule,.token.keyword,.token.attr-name,.language-autohotkey .token.selector{color:#00a4db}.token.function,.token.deleted,.language-autohotkey .token.tag{color:#9a050f}.token.tag,.token.selector,.language-autohotkey .token.keyword{color:#00009f}.token.important,.token.function,.token.bold{font-weight:700}.token.italic{font-style:italic}.higlass *{box-sizing:border-box}.higlass .react-resizable-handle{z-index:1}')),document.head.appendChild(e)}}catch(g){console.error("vite-plugin-css-injected-by-js",g)}})();var Qe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};function EC(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ud(e){if(e.__esModule)return e;var g=e.default;if(typeof g=="function"){var i=function n(){return this instanceof n?Reflect.construct(g,arguments,this.constructor):g.apply(this,arguments)};i.prototype=g.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var I=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(i,n,I.get?I:{enumerable:!0,get:function(){return e[n]}})}),i}var PMe={exports:{}},vXt="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",BXt=vXt,wXt=BXt;function _Me(){}function OMe(){}OMe.resetWarningCache=_Me;var SXt=function(){function e(n,I,r,o,C,a){if(a!==wXt){var A=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw A.name="Invariant Violation",A}}e.isRequired=e;function g(){return e}var i={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:g,element:e,elementType:e,instanceOf:g,node:e,objectOf:g,oneOf:g,oneOfType:g,shape:g,exact:g,checkPropTypes:OMe,resetWarningCache:_Me};return i.PropTypes=i,i};PMe.exports=SXt();var Qd=PMe.exports;const L=EC(Qd);var D6="http://www.w3.org/1999/xhtml";const M6={svg:"http://www.w3.org/2000/svg",xhtml:D6,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function My(e){var g=e+="",i=g.indexOf(":");return i>=0&&(g=e.slice(0,i))!=="xmlns"&&(e=e.slice(i+1)),M6.hasOwnProperty(g)?{space:M6[g],local:e}:e}function RXt(e){return function(){var g=this.ownerDocument,i=this.namespaceURI;return i===D6&&g.documentElement.namespaceURI===D6?g.createElement(e):g.createElementNS(i,e)}}function VXt(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Tz(e){var g=My(e);return(g.local?VXt:RXt)(g)}function WXt(){}function ZT(e){return e==null?WXt:function(){return this.querySelector(e)}}function XXt(e){typeof e!="function"&&(e=ZT(e));for(var g=this._groups,i=g.length,n=new Array(i),I=0;I=p&&(p=b+1);!(Z=f[p])&&++p=0;)(o=n[I])&&(r&&o.compareDocumentPosition(r)^4&&r.parentNode.insertBefore(o,r),r=o);return this}function e9t(e){e||(e=t9t);function g(l,c){return l&&c?e(l.__data__,c.__data__):!l-!c}for(var i=this._groups,n=i.length,I=new Array(n),r=0;rg?1:e>=g?0:NaN}function g9t(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function i9t(){return Array.from(this)}function n9t(){for(var e=this._groups,g=0,i=e.length;g1?this.each((g==null?d9t:typeof g=="function"?f9t:h9t)(e,g,i??"")):us(this.node(),e)}function us(e,g){return e.style.getPropertyValue(g)||ZCe(e).getComputedStyle(e,null).getPropertyValue(g)}function p9t(e){return function(){delete this[e]}}function b9t(e,g){return function(){this[e]=g}}function y9t(e,g){return function(){var i=g.apply(this,arguments);i==null?delete this[e]:this[e]=i}}function Z9t(e,g){return arguments.length>1?this.each((g==null?p9t:typeof g=="function"?y9t:b9t)(e,g)):this.node()[e]}function UMe(e){return e.trim().split(/^|\s+/)}function GCe(e){return e.classList||new QMe(e)}function QMe(e){this._node=e,this._names=UMe(e.getAttribute("class")||"")}QMe.prototype={add:function(e){var g=this._names.indexOf(e);g<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var g=this._names.indexOf(e);g>=0&&(this._names.splice(g,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function jMe(e,g){for(var i=GCe(e),n=-1,I=g.length;++n=0&&(i=g.slice(n+1),g=g.slice(0,n)),{type:g,name:i}})}function Q9t(e){return function(){var g=this.__on;if(g){for(var i=0,n=-1,I=g.length,r;imi(i,g))}function oTt(e){return typeof e=="string"?new eo([document.querySelectorAll(e)],[document.documentElement]):new eo([e==null?[]:yCe(e)],vCe)}const CTt=Object.freeze(Object.defineProperty({__proto__:null,create:nTt,creator:Tz,local:e3e,matcher:Nz,namespace:My,namespaces:M6,pointer:mi,pointers:rTt,select:xg,selectAll:oTt,selection:qA,selector:ZT,selectorAll:Hz,style:us,window:ZCe},Symbol.toStringTag,{value:"Module"}));function II(e,g){return eg?1:e>=g?0:NaN}function V1(e){let g=e,i=e;e.length===1&&(g=(o,C)=>e(o)-C,i=aTt(e));function n(o,C,a,A){for(a==null&&(a=0),A==null&&(A=o.length);a>>1;i(o[s],C)<0?a=s+1:A=s}return a}function I(o,C,a,A){for(a==null&&(a=0),A==null&&(A=o.length);a>>1;i(o[s],C)>0?A=s:a=s+1}return a}function r(o,C,a,A){a==null&&(a=0),A==null&&(A=o.length);const s=n(o,C,a,A-1);return s>a&&g(o[s-1],C)>-g(o[s],C)?s-1:s}return{left:n,center:r,right:I}}function aTt(e){return(g,i)=>II(e(g),i)}function g3e(e){return e===null?NaN:+e}function*sTt(e,g){if(g===void 0)for(let i of e)i!=null&&(i=+i)>=i&&(yield i);else{let i=-1;for(let n of e)(n=g(n,++i,e))!=null&&(n=+n)>=n&&(yield n)}}const i3e=V1(II),n3e=i3e.right,ATt=i3e.left,lTt=V1(g3e).center,zy=n3e;function kz(e,g){let i=0;if(g===void 0)for(let n of e)n!=null&&(n=+n)>=n&&++i;else{let n=-1;for(let I of e)(I=g(I,++n,e))!=null&&(I=+I)>=I&&++i}return i}function cTt(e){return e.length|0}function uTt(e){return!(e>0)}function dTt(e){return typeof e!="object"||"length"in e?e:Array.from(e)}function hTt(e){return g=>e(...g)}function fTt(...e){const g=typeof e[e.length-1]=="function"&&hTt(e.pop());e=e.map(dTt);const i=e.map(cTt),n=e.length-1,I=new Array(n+1).fill(0),r=[];if(n<0||i.some(uTt))return r;for(;;){r.push(I.map((C,a)=>e[a][C]));let o=n;for(;++I[o]===i[o];){if(o===0)return g?r.map(g):r;I[o--]=0}}}function mTt(e,g){var i=0,n=0;return Float64Array.from(e,g===void 0?I=>i+=+I||0:I=>i+=+g(I,n++,e)||0)}function pTt(e,g){return ge?1:g>=e?0:NaN}function BCe(e,g){let i=0,n,I=0,r=0;if(g===void 0)for(let o of e)o!=null&&(o=+o)>=o&&(n=o-I,I+=n/++i,r+=n*(o-I));else{let o=-1;for(let C of e)(C=g(C,++o,e))!=null&&(C=+C)>=C&&(n=C-I,I+=n/++i,r+=n*(C-I))}if(i>1)return r/(i-1)}function wCe(e,g){const i=BCe(e,g);return i&&Math.sqrt(i)}function EK(e,g){let i,n;if(g===void 0)for(const I of e)I!=null&&(i===void 0?I>=I&&(i=n=I):(i>I&&(i=I),n=r&&(i=n=r):(i>r&&(i=r),n0){for(C=i[--n];n>0&&(I=C,r=i[--n],C=I+r,o=r-(C-I),!o););n>0&&(o<0&&i[n-1]<0||o>0&&i[n-1]>0)&&(r=o*2,I=C+r,r==I-C&&(C=I))}return C}}]),e}();function vTt(e,g){const i=new GI;if(g===void 0)for(let n of e)(n=+n)&&i.add(n);else{let n=-1;for(let I of e)(I=+g(I,++n,e))&&i.add(I)}return+i}function BTt(e,g){const i=new GI;let n=-1;return Float64Array.from(e,g===void 0?I=>i.add(+I||0):I=>i.add(+g(I,++n,e)||0))}function I3e(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function FGe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function WTt(e){try{return Function.toString.call(e).indexOf("[native code]")!==-1}catch{return typeof e=="function"}}function xX(e,g){return xX=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,I){return n.__proto__=I,n},xX(e,g)}function sa(e){return sa=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},sa(e)}let cF=function(e){o3e(i,e);var g=C3e(i);function i(n,I=l3e){var r;if(I3e(this,i),r=g.call(this),Object.defineProperties(SCe(r),{_intern:{value:new Map},_key:{value:I}}),n!=null)for(const[o,C]of n)r.set(o,C);return r}return r3e(i,[{key:"get",value:function(I){return ec(sa(i.prototype),"get",this).call(this,P6(this,I))}},{key:"has",value:function(I){return ec(sa(i.prototype),"has",this).call(this,P6(this,I))}},{key:"set",value:function(I,r){return ec(sa(i.prototype),"set",this).call(this,s3e(this,I),r)}},{key:"delete",value:function(I){return ec(sa(i.prototype),"delete",this).call(this,A3e(this,I))}}]),i}(lF(Map)),XTt=function(e){o3e(i,e);var g=C3e(i);function i(n,I=l3e){var r;if(I3e(this,i),r=g.call(this),Object.defineProperties(SCe(r),{_intern:{value:new Map},_key:{value:I}}),n!=null)for(const o of n)r.add(o);return r}return r3e(i,[{key:"has",value:function(I){return ec(sa(i.prototype),"has",this).call(this,P6(this,I))}},{key:"add",value:function(I){return ec(sa(i.prototype),"add",this).call(this,s3e(this,I))}},{key:"delete",value:function(I){return ec(sa(i.prototype),"delete",this).call(this,A3e(this,I))}}]),i}(lF(Set));function P6({_intern:e,_key:g},i){const n=g(i);return e.has(n)?e.get(n):i}function s3e({_intern:e,_key:g},i){const n=g(i);return e.has(n)?e.get(n):(e.set(n,i),i)}function A3e({_intern:e,_key:g},i){const n=g(i);return e.has(n)&&(i=e.get(i),e.delete(n)),i}function l3e(e){return e!==null&&typeof e=="object"?e.valueOf():e}function PB(e){return e}function c3e(e,...g){return W1(e,PB,PB,g)}function TTt(e,...g){return W1(e,Array.from,PB,g)}function u3e(e,g,...i){return W1(e,PB,g,i)}function HTt(e,g,...i){return W1(e,Array.from,g,i)}function NTt(e,...g){return W1(e,PB,d3e,g)}function kTt(e,...g){return W1(e,Array.from,d3e,g)}function d3e(e){if(e.length!==1)throw new Error("duplicate key");return e[0]}function W1(e,g,i,n){return function I(r,o){if(o>=n.length)return i(r);const C=new cF,a=n[o++];let A=-1;for(const s of r){const l=a(s,++A,r),c=C.get(l);c?c.push(s):C.set(l,[s])}for(const[s,l]of C)C.set(s,I(l,o));return g(C)}(e,0)}function h3e(e,g){return Array.from(g,i=>e[i])}function _6(e,...g){if(typeof e[Symbol.iterator]!="function")throw new TypeError("values is not iterable");e=Array.from(e);let[i=II]=g;if(i.length===1||g.length>1){const n=Uint32Array.from(e,(I,r)=>r);return g.length>1?(g=g.map(I=>e.map(I)),n.sort((I,r)=>{for(const o of g){const C=II(o[I],o[r]);if(C)return C}})):(i=e.map(i),n.sort((I,r)=>II(i[I],i[r]))),h3e(e,n)}return e.sort(i)}function YTt(e,g,i){return(g.length===1?_6(u3e(e,g,i),([n,I],[r,o])=>II(I,o)||II(n,r)):_6(c3e(e,i),([n,I],[r,o])=>g(I,o)||II(n,r))).map(([n])=>n)}var KTt=Array.prototype,xTt=KTt.slice;function Zk(e){return function(){return e}}var O6=Math.sqrt(50),J6=Math.sqrt(10),L6=Math.sqrt(2);function Xb(e,g,i){var n,I=-1,r,o,C;if(g=+g,e=+e,i=+i,e===g&&i>0)return[e];if((n=g0){let a=Math.round(e/C),A=Math.round(g/C);for(a*Cg&&--A,o=new Array(r=A-a+1);++Ig&&--A,o=new Array(r=A-a+1);++I=0?(r>=O6?10:r>=J6?5:r>=L6?2:1)*Math.pow(10,I):-Math.pow(10,-I)/(r>=O6?10:r>=J6?5:r>=L6?2:1)}function uF(e,g,i){var n=Math.abs(g-e)/Math.max(0,i),I=Math.pow(10,Math.floor(Math.log(n)/Math.LN10)),r=n/I;return r>=O6?I*=10:r>=J6?I*=5:r>=L6&&(I*=2),g0?(e=Math.floor(e/I)*I,g=Math.ceil(g/I)*I):I<0&&(e=Math.ceil(e*I)/I,g=Math.floor(g*I)/I),n=I}}function m3e(e){return Math.ceil(Math.log(kz(e))/Math.LN2)+1}function EGe(){var e=PB,g=EK,i=m3e;function n(I){Array.isArray(I)||(I=Array.from(I));var r,o=I.length,C,a=new Array(o);for(r=0;r=l)if(f>=l&&g===EK){const b=GT(s,l,m);isFinite(b)&&(b>0?l=(Math.floor(l/b)+1)*b:b<0&&(l=(Math.ceil(l*-b)+1)/-b))}else c.pop()}for(var u=c.length;c[0]<=s;)c.shift(),--u;for(;c[u-1]>l;)c.pop(),--u;var d=new Array(u+1),h;for(r=0;r<=u;++r)h=d[r]=[],h.x0=r>0?c[r-1]:s,h.x1=r=n)&&(i=n);else{let n=-1;for(let I of e)(I=g(I,++n,e))!=null&&(i=I)&&(i=I)}return i}function dF(e,g){let i;if(g===void 0)for(const n of e)n!=null&&(i>n||i===void 0&&n>=n)&&(i=n);else{let n=-1;for(let I of e)(I=g(I,++n,e))!=null&&(i>I||i===void 0&&I>=I)&&(i=I)}return i}function RCe(e,g,i=0,n=e.length-1,I=II){for(;n>i;){if(n-i>600){const a=n-i+1,A=g-i+1,s=Math.log(a),l=.5*Math.exp(2*s/3),c=.5*Math.sqrt(s*l*(a-l)/a)*(A-a/2<0?-1:1),u=Math.max(i,Math.floor(g-A*l/a+c)),d=Math.min(n,Math.floor(g+(a-A)*l/a+c));RCe(e,g,u,d,I)}const r=e[g];let o=i,C=n;for(CR(e,i,g),I(e[n],r)>0&&CR(e,i,n);o0;)--C}I(e[i],r)===0?CR(e,i,C):(++C,CR(e,C,n)),C<=g&&(i=C+1),g<=C&&(n=C-1)}return e}function CR(e,g,i){const n=e[g];e[g]=e[i],e[i]=n}function FX(e,g,i){if(e=Float64Array.from(sTt(e,i)),!!(n=e.length)){if((g=+g)<=0||n<2)return dF(e);if(g>=1)return U6(e);var n,I=(n-1)*g,r=Math.floor(I),o=U6(RCe(e,r).subarray(0,r+1)),C=dF(e.subarray(r+1));return o+(C-o)*(I-r)}}function p3e(e,g,i=g3e){if(n=e.length){if((g=+g)<=0||n<2)return+i(e[0],0,e);if(g>=1)return+i(e[n-1],n-1,e);var n,I=(n-1)*g,r=Math.floor(I),o=+i(e[r],r,e),C=+i(e[r+1],r+1,e);return o+(C-o)*(I-r)}}function FTt(e,g,i){return Math.ceil((i-g)/(2*(FX(e,.75)-FX(e,.25))*Math.pow(kz(e),-1/3)))}function ETt(e,g,i){return Math.ceil((i-g)/(3.5*wCe(e)*Math.pow(kz(e),-1/3)))}function b3e(e,g){let i,n=-1,I=-1;if(g===void 0)for(const r of e)++I,r!=null&&(i=r)&&(i=r,n=I);else for(let r of e)(r=g(r,++I,e))!=null&&(i=r)&&(i=r,n=I);return n}function Q6(e,g){let i=0,n=0;if(g===void 0)for(let I of e)I!=null&&(I=+I)>=I&&(++i,n+=I);else{let I=-1;for(let r of e)(r=g(r,++I,e))!=null&&(r=+r)>=r&&(++i,n+=r)}if(i)return n/i}function VCe(e,g){return FX(e,.5,g)}function*DTt(e){for(const g of e)yield*g}function WCe(e){return Array.from(DTt(e))}function y3e(e,g){let i,n=-1,I=-1;if(g===void 0)for(const r of e)++I,r!=null&&(i>r||i===void 0&&r>=r)&&(i=r,n=I);else for(let r of e)(r=g(r,++I,e))!=null&&(i>r||i===void 0&&r>=r)&&(i=r,n=I);return n}function MTt(e,g=zTt){const i=[];let n,I=!1;for(const r of e)I&&i.push(g(n,r)),n=r,I=!0;return i}function zTt(e,g){return[e,g]}function Xo(e,g,i){e=+e,g=+g,i=(I=arguments.length)<2?(g=e,e=0,1):I<3?1:+i;for(var n=-1,I=Math.max(0,Math.ceil((g-e)/i))|0,r=new Array(I);++n0:II(o,o)===0)&&(i=r,I=o,n=!0)}}else for(const I of e)(n?g(I,i)>0:g(I,I)===0)&&(i=I,n=!0);return i}function OTt(e,g=II){if(g.length===1)return b3e(e,g);let i,n=-1,I=-1;for(const r of e)++I,(n<0?g(r,r)===0:g(r,i)>0)&&(i=r,n=I);return n}function JTt(e,g){const i=Z3e(e,g);return i<0?void 0:i}const LTt=G3e(Math.random);function G3e(e){return function(i,n=0,I=i.length){let r=I-(n=+n);for(;r;){const o=e()*r--|0,C=i[r+n];i[r+n]=i[o+n],i[o+n]=C}return i}}function v3e(e,g){let i=0;if(g===void 0)for(let n of e)(n=+n)&&(i+=n);else{let n=-1;for(let I of e)(I=+g(I,++n,e))&&(i+=I)}return i}function B3e(e){if(!(r=e.length))return[];for(var g=-1,i=dF(e,UTt),n=new Array(i);++gg(i,n,e))}function tHt(e,g,i){if(typeof g!="function")throw new TypeError("reducer is not a function");const n=e[Symbol.iterator]();let I,r,o=-1;if(arguments.length<3){if({done:I,value:i}=n.next(),I)return;++o}for(;{done:I,value:r}=n.next(),!I;)i=g(i,r,++o,e);return i}function gHt(e){if(typeof e[Symbol.iterator]!="function")throw new TypeError("values is not iterable");return Array.from(e).reverse()}function iHt(e,...g){e=new Set(e);for(const i of g)for(const n of i)e.delete(n);return e}function nHt(e,g){const i=g[Symbol.iterator](),n=new Set;for(const I of e){if(n.has(I))return!1;let r,o;for(;({value:r,done:o}=i.next())&&!o;){if(Object.is(I,r))return!1;n.add(r)}}return!0}function IHt(e){return e instanceof Set?e:new Set(e)}function rHt(e,...g){e=new Set(e),g=g.map(IHt);e:for(const i of e)for(const n of g)if(!n.has(i)){e.delete(i);continue e}return e}function w3e(e,g){const i=e[Symbol.iterator](),n=new Set;for(const I of g){if(n.has(I))continue;let r,o;for(;{value:r,done:o}=i.next();){if(o)return!1;if(n.add(r),Object.is(I,r))break}}return!0}function oHt(e,g){return w3e(g,e)}function CHt(...e){const g=new Set;for(const i of e)for(const n of i)g.add(n);return g}const aHt=Object.freeze(Object.defineProperty({__proto__:null,Adder:GI,InternMap:cF,InternSet:XTt,ascending:II,bin:EGe,bisect:zy,bisectCenter:lTt,bisectLeft:ATt,bisectRight:n3e,bisector:V1,count:kz,cross:fTt,cumsum:mTt,descending:pTt,deviation:wCe,difference:iHt,disjoint:nHt,every:jTt,extent:EK,fcumsum:BTt,filter:qTt,fsum:vTt,greatest:_Tt,greatestIndex:OTt,group:c3e,groupSort:YTt,groups:TTt,histogram:EGe,index:NTt,indexes:kTt,intersection:rHt,least:PTt,leastIndex:Z3e,map:eHt,max:U6,maxIndex:b3e,mean:Q6,median:VCe,merge:WCe,min:dF,minIndex:y3e,nice:f3e,pairs:MTt,permute:h3e,quantile:FX,quantileSorted:p3e,quickselect:RCe,range:Xo,reduce:tHt,reverse:gHt,rollup:u3e,rollups:HTt,scan:JTt,shuffle:LTt,shuffler:G3e,some:$Tt,sort:_6,subset:oHt,sum:v3e,superset:w3e,thresholdFreedmanDiaconis:FTt,thresholdScott:ETt,thresholdSturges:m3e,tickIncrement:GT,tickStep:uF,ticks:Xb,transpose:B3e,union:CHt,variance:BCe,zip:QTt},Symbol.toStringTag,{value:"Module"}));function Gs(e,g){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(g).domain(e);break}return this}function jd(e,g){switch(arguments.length){case 0:break;case 1:{typeof e=="function"?this.interpolator(e):this.range(e);break}default:{this.domain(e),typeof g=="function"?this.interpolator(g):this.range(g);break}}return this}const j6=Symbol("implicit");function XCe(){var e=new cF,g=[],i=[],n=j6;function I(r){let o=e.get(r);if(o===void 0){if(n!==j6)return n;e.set(r,o=g.push(r)-1)}return i[o%i.length]}return I.domain=function(r){if(!arguments.length)return g.slice();g=[],e=new cF;for(const o of r)e.has(o)||e.set(o,g.push(o)-1);return I},I.range=function(r){return arguments.length?(i=Array.from(r),I):i.slice()},I.unknown=function(r){return arguments.length?(n=r,I):n},I.copy=function(){return XCe(g,i).unknown(n)},Gs.apply(I,arguments),I}function vT(){var e=XCe().unknown(void 0),g=e.domain,i=e.range,n=0,I=1,r,o,C=!1,a=0,A=0,s=.5;delete e.unknown;function l(){var c=g().length,u=I>8&15|g>>4&240,g>>4&15|g&240,(g&15)<<4|g&15,1):i===8?Gk(g>>24&255,g>>16&255,g>>8&255,(g&255)/255):i===4?Gk(g>>12&15|g>>8&240,g>>8&15|g>>4&240,g>>4&15|g&240,((g&15)<<4|g&15)/255):null):(g=lHt.exec(e))?new Ar(g[1],g[2],g[3],1):(g=cHt.exec(e))?new Ar(g[1]*255/100,g[2]*255/100,g[3]*255/100,1):(g=uHt.exec(e))?Gk(g[1],g[2],g[3],g[4]):(g=dHt.exec(e))?Gk(g[1]*255/100,g[2]*255/100,g[3]*255/100,g[4]):(g=hHt.exec(e))?JGe(g[1],g[2]/100,g[3]/100,1):(g=fHt.exec(e))?JGe(g[1],g[2]/100,g[3]/100,g[4]):DGe.hasOwnProperty(e)?PGe(DGe[e]):e==="transparent"?new Ar(NaN,NaN,NaN,0):null}function PGe(e){return new Ar(e>>16&255,e>>8&255,e&255,1)}function Gk(e,g,i,n){return n<=0&&(e=g=i=NaN),new Ar(e,g,i,n)}function TCe(e){return e instanceof Fm||(e=fI(e)),e?(e=e.rgb(),new Ar(e.r,e.g,e.b,e.opacity)):new Ar}function OB(e,g,i,n){return arguments.length===1?TCe(e):new Ar(e,g,i,n??1)}function Ar(e,g,i,n){this.r=+e,this.g=+g,this.b=+i,this.opacity=+n}X1(Ar,OB,BT(Fm,{brighter:function(e){return e=e==null?_B:Math.pow(_B,e),new Ar(this.r*e,this.g*e,this.b*e,this.opacity)},darker:function(e){return e=e==null?Tb:Math.pow(Tb,e),new Ar(this.r*e,this.g*e,this.b*e,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:_Ge,formatHex:_Ge,formatRgb:OGe,toString:OGe}));function _Ge(){return"#"+BU(this.r)+BU(this.g)+BU(this.b)}function OGe(){var e=this.opacity;return e=isNaN(e)?1:Math.max(0,Math.min(1,e)),(e===1?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(e===1?")":", "+e+")")}function BU(e){return e=Math.max(0,Math.min(255,Math.round(e)||0)),(e<16?"0":"")+e.toString(16)}function JGe(e,g,i,n){return n<=0?e=g=i=NaN:i<=0||i>=1?e=g=NaN:g<=0&&(e=NaN),new xl(e,g,i,n)}function R3e(e){if(e instanceof xl)return new xl(e.h,e.s,e.l,e.opacity);if(e instanceof Fm||(e=fI(e)),!e)return new xl;if(e instanceof xl)return e;e=e.rgb();var g=e.r/255,i=e.g/255,n=e.b/255,I=Math.min(g,i,n),r=Math.max(g,i,n),o=NaN,C=r-I,a=(r+I)/2;return C?(g===r?o=(i-n)/C+(i0&&a<1?0:o,new xl(o,C,a,e.opacity)}function V3e(e,g,i,n){return arguments.length===1?R3e(e):new xl(e,g,i,n??1)}function xl(e,g,i,n){this.h=+e,this.s=+g,this.l=+i,this.opacity=+n}X1(xl,V3e,BT(Fm,{brighter:function(e){return e=e==null?_B:Math.pow(_B,e),new xl(this.h,this.s,this.l*e,this.opacity)},darker:function(e){return e=e==null?Tb:Math.pow(Tb,e),new xl(this.h,this.s,this.l*e,this.opacity)},rgb:function(){var e=this.h%360+(this.h<0)*360,g=isNaN(e)||isNaN(this.s)?0:this.s,i=this.l,n=i+(i<.5?i:1-i)*g,I=2*i-n;return new Ar(wU(e>=240?e-240:e+120,I,n),wU(e,I,n),wU(e<120?e+240:e-120,I,n),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var e=this.opacity;return e=isNaN(e)?1:Math.max(0,Math.min(1,e)),(e===1?"hsl(":"hsla(")+(this.h||0)+", "+(this.s||0)*100+"%, "+(this.l||0)*100+"%"+(e===1?")":", "+e+")")}}));function wU(e,g,i){return(e<60?g+(i-g)*e/60:e<180?i:e<240?g+(i-g)*(240-e)/60:g)*255}const W3e=Math.PI/180,X3e=180/Math.PI,hF=18,T3e=.96422,H3e=1,N3e=.82521,k3e=4/29,Fv=6/29,Y3e=3*Fv*Fv,pHt=Fv*Fv*Fv;function K3e(e){if(e instanceof NA)return new NA(e.l,e.a,e.b,e.opacity);if(e instanceof tc)return D3e(e);e instanceof Ar||(e=TCe(e));var g=WU(e.r),i=WU(e.g),n=WU(e.b),I=SU((.2225045*g+.7168786*i+.0606169*n)/H3e),r,o;return g===i&&i===n?r=o=I:(r=SU((.4360747*g+.3850649*i+.1430804*n)/T3e),o=SU((.0139322*g+.0971045*i+.7141733*n)/N3e)),new NA(116*I-16,500*(r-I),200*(I-o),e.opacity)}function bHt(e,g){return new NA(e,0,0,g??1)}function x3e(e,g,i,n){return arguments.length===1?K3e(e):new NA(e,g,i,n??1)}function NA(e,g,i,n){this.l=+e,this.a=+g,this.b=+i,this.opacity=+n}X1(NA,x3e,BT(Fm,{brighter:function(e){return new NA(this.l+hF*(e??1),this.a,this.b,this.opacity)},darker:function(e){return new NA(this.l-hF*(e??1),this.a,this.b,this.opacity)},rgb:function(){var e=(this.l+16)/116,g=isNaN(this.a)?e:e+this.a/500,i=isNaN(this.b)?e:e-this.b/200;return g=T3e*RU(g),e=H3e*RU(e),i=N3e*RU(i),new Ar(VU(3.1338561*g-1.6168667*e-.4906146*i),VU(-.9787684*g+1.9161415*e+.033454*i),VU(.0719453*g-.2289914*e+1.4052427*i),this.opacity)}}));function SU(e){return e>pHt?Math.pow(e,1/3):e/Y3e+k3e}function RU(e){return e>Fv?e*e*e:Y3e*(e-k3e)}function VU(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function WU(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function F3e(e){if(e instanceof tc)return new tc(e.h,e.c,e.l,e.opacity);if(e instanceof NA||(e=K3e(e)),e.a===0&&e.b===0)return new tc(NaN,0()=>e;function vHt(e,g){return function(i){return e+i*g}}function BHt(e,g,i){return e=Math.pow(e,i),g=Math.pow(g,i)-e,i=1/i,function(n){return Math.pow(e+n*g,i)}}function wHt(e){return(e=+e)==1?P3e:function(g,i){return i-g?BHt(g,i,e):kCe(isNaN(g)?i:g)}}function P3e(e,g){var i=g-e;return i?vHt(e,i):kCe(isNaN(e)?g:e)}const JB=function e(g){var i=wHt(g);function n(I,r){var o=i((I=OB(I)).r,(r=OB(r)).r),C=i(I.g,r.g),a=i(I.b,r.b),A=P3e(I.opacity,r.opacity);return function(s){return I.r=o(s),I.g=C(s),I.b=a(s),I.opacity=A(s),I+""}}return n.gamma=e,n}(1);function SHt(e,g){g||(g=[]);var i=e?Math.min(g.length,e.length):0,n=g.slice(),I;return function(r){for(I=0;Ii&&(r=g.slice(i,r),C[o]?C[o]+=r:C[++o]=r),(n=n[0])===(I=I[0])?C[o]?C[o]+=I:C[++o]=I:(C[++o]=null,a.push({i:o,x:Oa(n,I)})),i=XU.lastIndex;return i180?s+=360:s-A>180&&(A+=360),c.push({i:l.push(I(l)+"rotate(",null,n)-2,x:Oa(A,s)})):s&&l.push(I(l)+"rotate("+s+n)}function C(A,s,l,c){A!==s?c.push({i:l.push(I(l)+"skewX(",null,n)-2,x:Oa(A,s)}):s&&l.push(I(l)+"skewX("+s+n)}function a(A,s,l,c,u,d){if(A!==l||s!==c){var h=u.push(I(u)+"scale(",null,",",null,")");d.push({i:h-4,x:Oa(A,l)},{i:h-2,x:Oa(s,c)})}else(l!==1||c!==1)&&u.push(I(u)+"scale("+l+","+c+")")}return function(A,s){var l=[],c=[];return A=e(A),s=e(s),r(A.translateX,A.translateY,s.translateX,s.translateY,l,c),o(A.rotate,s.rotate,l,c),C(A.skewX,s.skewX,l,c),a(A.scaleX,A.scaleY,s.scaleX,s.scaleY,l,c),A=s=null,function(u){for(var d=-1,h=c.length,f;++dg&&(i=e,e=g,g=i),function(n){return Math.max(e,Math.min(g,n))}}function zHt(e,g,i){var n=e[0],I=e[1],r=g[0],o=g[1];return I2?PHt:zHt,a=A=null,l}function l(c){return c==null||isNaN(c=+c)?r:(a||(a=C(e.map(n),g,i)))(n(o(c)))}return l.invert=function(c){return o(I((A||(A=C(g,e.map(n),Oa)))(c)))},l.domain=function(c){return arguments.length?(e=Array.from(c,fF),s()):e.slice()},l.range=function(c){return arguments.length?(g=Array.from(c),s()):g.slice()},l.rangeRound=function(c){return g=Array.from(c),i=KCe,s()},l.clamp=function(c){return arguments.length?(o=c?!0:To,s()):o!==To},l.interpolate=function(c){return arguments.length?(i=c,s()):i},l.unknown=function(c){return arguments.length?(r=c,l):r},function(c,u){return n=c,I=u,s()}}function xCe(){return Kz()(To,To)}function _Ht(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function mF(e,g){if((i=(e=g?e.toExponential(g-1):e.toExponential()).indexOf("e"))<0)return null;var i,n=e.slice(0,i);return[n.length>1?n[0]+n.slice(2):n,+e.slice(i+1)]}function LB(e){return e=mF(Math.abs(e)),e?e[1]:NaN}function OHt(e,g){return function(i,n){for(var I=i.length,r=[],o=0,C=e[0],a=0;I>0&&C>0&&(a+C+1>n&&(C=Math.max(1,n-a)),r.push(i.substring(I-=C,I+C)),!((a+=C+1)>n));)C=e[o=(o+1)%e.length];return r.reverse().join(g)}}function JHt(e){return function(g){return g.replace(/[0-9]/g,function(i){return e[+i]})}}var LHt=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function UB(e){if(!(g=LHt.exec(e)))throw new Error("invalid format: "+e);var g;return new xz({fill:g[1],align:g[2],sign:g[3],symbol:g[4],zero:g[5],width:g[6],comma:g[7],precision:g[8]&&g[8].slice(1),trim:g[9],type:g[10]})}UB.prototype=xz.prototype;function xz(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}xz.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function UHt(e){e:for(var g=e.length,i=1,n=-1,I;i0&&(n=0);break}return n>0?e.slice(0,n)+e.slice(I+1):e}var U3e;function QHt(e,g){var i=mF(e,g);if(!i)return e+"";var n=i[0],I=i[1],r=I-(U3e=Math.max(-8,Math.min(8,Math.floor(I/3)))*3)+1,o=n.length;return r===o?n:r>o?n+new Array(r-o+1).join("0"):r>0?n.slice(0,r)+"."+n.slice(r):"0."+new Array(1-r).join("0")+mF(e,Math.max(0,g+r-1))[0]}function eve(e,g){var i=mF(e,g);if(!i)return e+"";var n=i[0],I=i[1];return I<0?"0."+new Array(-I).join("0")+n:n.length>I+1?n.slice(0,I+1)+"."+n.slice(I+1):n+new Array(I-n.length+2).join("0")}const tve={"%":(e,g)=>(e*100).toFixed(g),b:e=>Math.round(e).toString(2),c:e=>e+"",d:_Ht,e:(e,g)=>e.toExponential(g),f:(e,g)=>e.toFixed(g),g:(e,g)=>e.toPrecision(g),o:e=>Math.round(e).toString(8),p:(e,g)=>eve(e*100,g),r:eve,s:QHt,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function gve(e){return e}var ive=Array.prototype.map,nve=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Q3e(e){var g=e.grouping===void 0||e.thousands===void 0?gve:OHt(ive.call(e.grouping,Number),e.thousands+""),i=e.currency===void 0?"":e.currency[0]+"",n=e.currency===void 0?"":e.currency[1]+"",I=e.decimal===void 0?".":e.decimal+"",r=e.numerals===void 0?gve:JHt(ive.call(e.numerals,String)),o=e.percent===void 0?"%":e.percent+"",C=e.minus===void 0?"−":e.minus+"",a=e.nan===void 0?"NaN":e.nan+"";function A(l){l=UB(l);var c=l.fill,u=l.align,d=l.sign,h=l.symbol,f=l.zero,m=l.width,b=l.comma,p=l.precision,y=l.trim,Z=l.type;Z==="n"?(b=!0,Z="g"):tve[Z]||(p===void 0&&(p=12),y=!0,Z="g"),(f||c==="0"&&u==="=")&&(f=!0,c="0",u="=");var v=h==="$"?i:h==="#"&&/[boxX]/.test(Z)?"0"+Z.toLowerCase():"",G=h==="$"?n:/[%p]/.test(Z)?o:"",B=tve[Z],S=/[defgprs%]/.test(Z);p=p===void 0?6:/[gprs]/.test(Z)?Math.max(1,Math.min(21,p)):Math.max(0,Math.min(20,p));function R(w){var T=v,W=G,V,X,N;if(Z==="c")W=B(w)+W,w="";else{w=+w;var Y=w<0||1/w<0;if(w=isNaN(w)?a:B(Math.abs(w),p),y&&(w=UHt(w)),Y&&+w==0&&d!=="+"&&(Y=!1),T=(Y?d==="("?d:C:d==="-"||d==="("?"":d)+T,W=(Z==="s"?nve[8+U3e/3]:"")+W+(Y&&d==="("?")":""),S){for(V=-1,X=w.length;++VN||N>57){W=(N===46?I+w.slice(V+1):w.slice(V))+W,w=w.slice(0,V);break}}}b&&!f&&(w=g(w,1/0));var x=T.length+w.length+W.length,M=x>1)+T+w+W+M.slice(x);break;default:w=M+T+w+W;break}return r(w)}return R.toString=function(){return l+""},R}function s(l,c){var u=A((l=UB(l),l.type="f",l)),d=Math.max(-8,Math.min(8,Math.floor(LB(c)/3)))*3,h=Math.pow(10,-d),f=nve[8+d/3];return function(m){return u(h*m)+f}}return{format:A,formatPrefix:s}}var Bk,da,_y;j3e({thousands:",",grouping:[3],currency:["$",""]});function j3e(e){return Bk=Q3e(e),da=Bk.format,_y=Bk.formatPrefix,Bk}function $3e(e){return Math.max(0,-LB(Math.abs(e)))}function T1(e,g){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(LB(g)/3)))*3-LB(Math.abs(e)))}function q3e(e,g){return e=Math.abs(e),g=Math.abs(g)-e,Math.max(0,LB(g)-LB(e))+1}const jHt=Object.freeze(Object.defineProperty({__proto__:null,FormatSpecifier:xz,get format(){return da},formatDefaultLocale:j3e,formatLocale:Q3e,get formatPrefix(){return _y},formatSpecifier:UB,precisionFixed:$3e,precisionPrefix:T1,precisionRound:q3e},Symbol.toStringTag,{value:"Module"}));function eze(e,g,i,n){var I=uF(e,g,i),r;switch(n=UB(n??",f"),n.type){case"s":{var o=Math.max(Math.abs(e),Math.abs(g));return n.precision==null&&!isNaN(r=T1(I,o))&&(n.precision=r),_y(n,o)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(r=q3e(I,Math.max(Math.abs(e),Math.abs(g))))&&(n.precision=r-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(r=$3e(I))&&(n.precision=r-(n.type==="%")*2);break}}return da(n)}function Em(e){var g=e.domain;return e.ticks=function(i){var n=g();return Xb(n[0],n[n.length-1],i??10)},e.tickFormat=function(i,n){var I=g();return eze(I[0],I[I.length-1],i??10,n)},e.nice=function(i){i==null&&(i=10);var n=g(),I=0,r=n.length-1,o=n[I],C=n[r],a,A,s=10;for(C0;){if(A=GT(o,C,i),A===a)return n[I]=o,n[r]=C,g(n);if(A>0)o=Math.floor(o/A)*A,C=Math.ceil(C/A)*A;else if(A<0)o=Math.ceil(o*A)/A,C=Math.floor(C*A)/A;else break;a=A}return e},e}function bg(){var e=xCe();return e.copy=function(){return wT(e,bg())},Gs.apply(e,arguments),Em(e)}function tze(e){var g;function i(n){return n==null||isNaN(n=+n)?g:n}return i.invert=i,i.domain=i.range=function(n){return arguments.length?(e=Array.from(n,fF),i):e.slice()},i.unknown=function(n){return arguments.length?(g=n,i):g},i.copy=function(){return tze(e).unknown(g)},e=arguments.length?Array.from(e,fF):[0,1],Em(i)}function gze(e,g){e=e.slice();var i=0,n=e.length-1,I=e[i],r=e[n],o;return rMath.pow(e,g)}function gNt(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),g=>Math.log(g)/e)}function ove(e){return(g,i)=>-e(-g,i)}function FCe(e){const g=e(Ive,rve),i=g.domain;let n=10,I,r;function o(){return I=gNt(n),r=tNt(n),i()[0]<0?(I=ove(I),r=ove(r),e($Ht,qHt)):e(Ive,rve),g}return g.base=function(C){return arguments.length?(n=+C,o()):n},g.domain=function(C){return arguments.length?(i(C),o()):i()},g.ticks=C=>{const a=i();let A=a[0],s=a[a.length-1];const l=s0){for(;c<=u;++c)for(d=1;ds)break;m.push(h)}}else for(;c<=u;++c)for(d=n-1;d>=1;--d)if(h=c>0?d/r(-c):d*r(c),!(hs)break;m.push(h)}m.length*2{if(C==null&&(C=10),a==null&&(a=n===10?"s":","),typeof a!="function"&&(!(n%1)&&(a=UB(a)).precision==null&&(a.trim=!0),a=da(a)),C===1/0)return a;const A=Math.max(1,n*C/g.ticks().length);return s=>{let l=s/r(Math.round(I(s)));return l*ni(gze(i(),{floor:C=>r(Math.floor(I(C))),ceil:C=>r(Math.ceil(I(C)))})),g}function Dm(){const e=FCe(Kz()).domain([1,10]);return e.copy=()=>wT(e,Dm()).base(e.base()),Gs.apply(e,arguments),e}function Cve(e){return function(g){return Math.sign(g)*Math.log1p(Math.abs(g/e))}}function ave(e){return function(g){return Math.sign(g)*Math.expm1(Math.abs(g))*e}}function ECe(e){var g=1,i=e(Cve(g),ave(g));return i.constant=function(n){return arguments.length?e(Cve(g=+n),ave(g)):g},Em(i)}function ize(){var e=ECe(Kz());return e.copy=function(){return wT(e,ize()).constant(e.constant())},Gs.apply(e,arguments)}function sve(e){return function(g){return g<0?-Math.pow(-g,e):Math.pow(g,e)}}function iNt(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function nNt(e){return e<0?-e*e:e*e}function DCe(e){var g=e(To,To),i=1;function n(){return i===1?e(To,To):i===.5?e(iNt,nNt):e(sve(i),sve(1/i))}return g.exponent=function(I){return arguments.length?(i=+I,n()):i},Em(g)}function MCe(){var e=DCe(Kz());return e.copy=function(){return wT(e,MCe()).exponent(e.exponent())},Gs.apply(e,arguments),e}function INt(){return MCe.apply(null,arguments).exponent(.5)}function Ave(e){return Math.sign(e)*e*e}function rNt(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function nze(){var e=xCe(),g=[0,1],i=!1,n;function I(r){var o=rNt(e(r));return isNaN(o)?n:i?Math.round(o):o}return I.invert=function(r){return e.invert(Ave(r))},I.domain=function(r){return arguments.length?(e.domain(r),I):e.domain()},I.range=function(r){return arguments.length?(e.range((g=Array.from(r,fF)).map(Ave)),I):g.slice()},I.rangeRound=function(r){return I.range(r).round(!0)},I.round=function(r){return arguments.length?(i=!!r,I):i},I.clamp=function(r){return arguments.length?(e.clamp(r),I):e.clamp()},I.unknown=function(r){return arguments.length?(n=r,I):n},I.copy=function(){return nze(e.domain(),g).round(i).clamp(e.clamp()).unknown(n)},Gs.apply(I,arguments),Em(I)}function pF(){var e=[],g=[],i=[],n;function I(){var o=0,C=Math.max(1,g.length);for(i=new Array(C-1);++o0?i[C-1]:e[0],C=i?[n[i-1],g]:[n[A-1],n[A]]},o.unknown=function(a){return arguments.length&&(r=a),o},o.thresholds=function(){return n.slice()},o.copy=function(){return Ize().domain([e,g]).range(I).unknown(r)},Gs.apply(Em(o),arguments)}function rze(){var e=[.5],g=[0,1],i,n=1;function I(r){return r!=null&&r<=r?g[zy(e,r,0,n)]:i}return I.domain=function(r){return arguments.length?(e=Array.from(r),n=Math.min(e.length,g.length-1),I):e.slice()},I.range=function(r){return arguments.length?(g=Array.from(r),n=Math.min(e.length,g.length-1),I):g.slice()},I.invertExtent=function(r){var o=g.indexOf(r);return[e[o-1],e[o]]},I.unknown=function(r){return arguments.length?(i=r,I):i},I.copy=function(){return rze().domain(e).range(g).unknown(i)},Gs.apply(I,arguments)}const TU=new Date,HU=new Date;function wI(e,g,i,n){function I(r){return e(r=arguments.length===0?new Date:new Date(+r)),r}return I.floor=r=>(e(r=new Date(+r)),r),I.ceil=r=>(e(r=new Date(r-1)),g(r,1),e(r),r),I.round=r=>{const o=I(r),C=I.ceil(r);return r-o(g(r=new Date(+r),o==null?1:Math.floor(o)),r),I.range=(r,o,C)=>{const a=[];if(r=I.ceil(r),C=C==null?1:Math.floor(C),!(r0))return a;let A;do a.push(A=new Date(+r)),g(r,C),e(r);while(AwI(o=>{if(o>=o)for(;e(o),!r(o);)o.setTime(o-1)},(o,C)=>{if(o>=o)if(C<0)for(;++C<=0;)for(;g(o,-1),!r(o););else for(;--C>=0;)for(;g(o,1),!r(o););}),i&&(I.count=(r,o)=>(TU.setTime(+r),HU.setTime(+o),e(TU),e(HU),Math.floor(i(TU,HU))),I.every=r=>(r=Math.floor(r),!isFinite(r)||!(r>0)?null:r>1?I.filter(n?o=>n(o)%r===0:o=>I.count(0,o)%r===0):I)),I}const bF=wI(()=>{},(e,g)=>{e.setTime(+e+g)},(e,g)=>g-e);bF.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?wI(g=>{g.setTime(Math.floor(g/e)*e)},(g,i)=>{g.setTime(+g+i*e)},(g,i)=>(i-g)/e):bF);bF.range;const Qu=1e3,$a=Qu*60,ju=$a*60,Nd=ju*24,zCe=Nd*7,lve=Nd*30,NU=Nd*365,Z0=wI(e=>{e.setTime(e-e.getMilliseconds())},(e,g)=>{e.setTime(+e+g*Qu)},(e,g)=>(g-e)/Qu,e=>e.getUTCSeconds());Z0.range;const PCe=wI(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Qu)},(e,g)=>{e.setTime(+e+g*$a)},(e,g)=>(g-e)/$a,e=>e.getMinutes());PCe.range;const _Ce=wI(e=>{e.setUTCSeconds(0,0)},(e,g)=>{e.setTime(+e+g*$a)},(e,g)=>(g-e)/$a,e=>e.getUTCMinutes());_Ce.range;const OCe=wI(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Qu-e.getMinutes()*$a)},(e,g)=>{e.setTime(+e+g*ju)},(e,g)=>(g-e)/ju,e=>e.getHours());OCe.range;const JCe=wI(e=>{e.setUTCMinutes(0,0,0)},(e,g)=>{e.setTime(+e+g*ju)},(e,g)=>(g-e)/ju,e=>e.getUTCHours());JCe.range;const ST=wI(e=>e.setHours(0,0,0,0),(e,g)=>e.setDate(e.getDate()+g),(e,g)=>(g-e-(g.getTimezoneOffset()-e.getTimezoneOffset())*$a)/Nd,e=>e.getDate()-1);ST.range;const Fz=wI(e=>{e.setUTCHours(0,0,0,0)},(e,g)=>{e.setUTCDate(e.getUTCDate()+g)},(e,g)=>(g-e)/Nd,e=>e.getUTCDate()-1);Fz.range;const oze=wI(e=>{e.setUTCHours(0,0,0,0)},(e,g)=>{e.setUTCDate(e.getUTCDate()+g)},(e,g)=>(g-e)/Nd,e=>Math.floor(e/Nd));oze.range;function Oy(e){return wI(g=>{g.setDate(g.getDate()-(g.getDay()+7-e)%7),g.setHours(0,0,0,0)},(g,i)=>{g.setDate(g.getDate()+i*7)},(g,i)=>(i-g-(i.getTimezoneOffset()-g.getTimezoneOffset())*$a)/zCe)}const Ez=Oy(0),yF=Oy(1),oNt=Oy(2),CNt=Oy(3),QB=Oy(4),aNt=Oy(5),sNt=Oy(6);Ez.range;yF.range;oNt.range;CNt.range;QB.range;aNt.range;sNt.range;function Jy(e){return wI(g=>{g.setUTCDate(g.getUTCDate()-(g.getUTCDay()+7-e)%7),g.setUTCHours(0,0,0,0)},(g,i)=>{g.setUTCDate(g.getUTCDate()+i*7)},(g,i)=>(i-g)/zCe)}const Dz=Jy(0),ZF=Jy(1),ANt=Jy(2),lNt=Jy(3),jB=Jy(4),cNt=Jy(5),uNt=Jy(6);Dz.range;ZF.range;ANt.range;lNt.range;jB.range;cNt.range;uNt.range;const LCe=wI(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,g)=>{e.setMonth(e.getMonth()+g)},(e,g)=>g.getMonth()-e.getMonth()+(g.getFullYear()-e.getFullYear())*12,e=>e.getMonth());LCe.range;const UCe=wI(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,g)=>{e.setUTCMonth(e.getUTCMonth()+g)},(e,g)=>g.getUTCMonth()-e.getUTCMonth()+(g.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());UCe.range;const kd=wI(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,g)=>{e.setFullYear(e.getFullYear()+g)},(e,g)=>g.getFullYear()-e.getFullYear(),e=>e.getFullYear());kd.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:wI(g=>{g.setFullYear(Math.floor(g.getFullYear()/e)*e),g.setMonth(0,1),g.setHours(0,0,0,0)},(g,i)=>{g.setFullYear(g.getFullYear()+i*e)});kd.range;const Yd=wI(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,g)=>{e.setUTCFullYear(e.getUTCFullYear()+g)},(e,g)=>g.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());Yd.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:wI(g=>{g.setUTCFullYear(Math.floor(g.getUTCFullYear()/e)*e),g.setUTCMonth(0,1),g.setUTCHours(0,0,0,0)},(g,i)=>{g.setUTCFullYear(g.getUTCFullYear()+i*e)});Yd.range;function Cze(e,g,i,n,I,r){const o=[[Z0,1,Qu],[Z0,5,5*Qu],[Z0,15,15*Qu],[Z0,30,30*Qu],[r,1,$a],[r,5,5*$a],[r,15,15*$a],[r,30,30*$a],[I,1,ju],[I,3,3*ju],[I,6,6*ju],[I,12,12*ju],[n,1,Nd],[n,2,2*Nd],[i,1,zCe],[g,1,lve],[g,3,3*lve],[e,1,NU]];function C(A,s,l){const c=sf).right(o,c);if(u===o.length)return e.every(uF(A/NU,s/NU,l));if(u===0)return bF.every(Math.max(uF(A,s,l),1));const[d,h]=o[c/o[u-1][2]53)return null;"w"in ie||(ie.w=1),"Z"in ie?(ue=YU(aR(ie.y,0,1)),Ye=ue.getUTCDay(),ue=Ye>4||Ye===0?ZF.ceil(ue):ZF(ue),ue=Fz.offset(ue,(ie.V-1)*7),ie.y=ue.getUTCFullYear(),ie.m=ue.getUTCMonth(),ie.d=ue.getUTCDate()+(ie.w+6)%7):(ue=kU(aR(ie.y,0,1)),Ye=ue.getDay(),ue=Ye>4||Ye===0?yF.ceil(ue):yF(ue),ue=ST.offset(ue,(ie.V-1)*7),ie.y=ue.getFullYear(),ie.m=ue.getMonth(),ie.d=ue.getDate()+(ie.w+6)%7)}else("W"in ie||"U"in ie)&&("w"in ie||(ie.w="u"in ie?ie.u%7:"W"in ie?1:0),Ye="Z"in ie?YU(aR(ie.y,0,1)).getUTCDay():kU(aR(ie.y,0,1)).getDay(),ie.m=0,ie.d="W"in ie?(ie.w+6)%7+ie.W*7-(Ye+5)%7:ie.w+ie.U*7-(Ye+6)%7);return"Z"in ie?(ie.H+=ie.Z/100|0,ie.M+=ie.Z%100,YU(ie)):kU(ie)}}function B(oe,pe,ae,ie){for(var ye=0,ue=pe.length,Ye=ae.length,Be,ke;ye=Ye)return-1;if(Be=pe.charCodeAt(ye++),Be===37){if(Be=pe.charAt(ye++),ke=Z[Be in cve?pe.charAt(ye++):Be],!ke||(ie=ke(oe,ae,ie))<0)return-1}else if(Be!=ae.charCodeAt(ie++))return-1}return ie}function S(oe,pe,ae){var ie=A.exec(pe.slice(ae));return ie?(oe.p=s.get(ie[0].toLowerCase()),ae+ie[0].length):-1}function R(oe,pe,ae){var ie=u.exec(pe.slice(ae));return ie?(oe.w=d.get(ie[0].toLowerCase()),ae+ie[0].length):-1}function w(oe,pe,ae){var ie=l.exec(pe.slice(ae));return ie?(oe.w=c.get(ie[0].toLowerCase()),ae+ie[0].length):-1}function T(oe,pe,ae){var ie=m.exec(pe.slice(ae));return ie?(oe.m=b.get(ie[0].toLowerCase()),ae+ie[0].length):-1}function W(oe,pe,ae){var ie=h.exec(pe.slice(ae));return ie?(oe.m=f.get(ie[0].toLowerCase()),ae+ie[0].length):-1}function V(oe,pe,ae){return B(oe,g,pe,ae)}function X(oe,pe,ae){return B(oe,i,pe,ae)}function N(oe,pe,ae){return B(oe,n,pe,ae)}function Y(oe){return o[oe.getDay()]}function x(oe){return r[oe.getDay()]}function M(oe){return a[oe.getMonth()]}function F(oe){return C[oe.getMonth()]}function $(oe){return I[+(oe.getHours()>=12)]}function Q(oe){return 1+~~(oe.getMonth()/3)}function U(oe){return o[oe.getUTCDay()]}function j(oe){return r[oe.getUTCDay()]}function ee(oe){return a[oe.getUTCMonth()]}function Ie(oe){return C[oe.getUTCMonth()]}function fe(oe){return I[+(oe.getUTCHours()>=12)]}function Ve(oe){return 1+~~(oe.getUTCMonth()/3)}return{format:function(oe){var pe=v(oe+="",p);return pe.toString=function(){return oe},pe},parse:function(oe){var pe=G(oe+="",!1);return pe.toString=function(){return oe},pe},utcFormat:function(oe){var pe=v(oe+="",y);return pe.toString=function(){return oe},pe},utcParse:function(oe){var pe=G(oe+="",!0);return pe.toString=function(){return oe},pe}}}var cve={"-":"",_:" ",0:"0"},QI=/^\s*\d+/,bNt=/^%/,yNt=/[\\^$*+?|[\]().{}]/g;function Ci(e,g,i){var n=e<0?"-":"",I=(n?-e:e)+"",r=I.length;return n+(r[g.toLowerCase(),i]))}function GNt(e,g,i){var n=QI.exec(g.slice(i,i+1));return n?(e.w=+n[0],i+n[0].length):-1}function vNt(e,g,i){var n=QI.exec(g.slice(i,i+1));return n?(e.u=+n[0],i+n[0].length):-1}function BNt(e,g,i){var n=QI.exec(g.slice(i,i+2));return n?(e.U=+n[0],i+n[0].length):-1}function wNt(e,g,i){var n=QI.exec(g.slice(i,i+2));return n?(e.V=+n[0],i+n[0].length):-1}function SNt(e,g,i){var n=QI.exec(g.slice(i,i+2));return n?(e.W=+n[0],i+n[0].length):-1}function uve(e,g,i){var n=QI.exec(g.slice(i,i+4));return n?(e.y=+n[0],i+n[0].length):-1}function dve(e,g,i){var n=QI.exec(g.slice(i,i+2));return n?(e.y=+n[0]+(+n[0]>68?1900:2e3),i+n[0].length):-1}function RNt(e,g,i){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(g.slice(i,i+6));return n?(e.Z=n[1]?0:-(n[2]+(n[3]||"00")),i+n[0].length):-1}function VNt(e,g,i){var n=QI.exec(g.slice(i,i+1));return n?(e.q=n[0]*3-3,i+n[0].length):-1}function WNt(e,g,i){var n=QI.exec(g.slice(i,i+2));return n?(e.m=n[0]-1,i+n[0].length):-1}function hve(e,g,i){var n=QI.exec(g.slice(i,i+2));return n?(e.d=+n[0],i+n[0].length):-1}function XNt(e,g,i){var n=QI.exec(g.slice(i,i+3));return n?(e.m=0,e.d=+n[0],i+n[0].length):-1}function fve(e,g,i){var n=QI.exec(g.slice(i,i+2));return n?(e.H=+n[0],i+n[0].length):-1}function TNt(e,g,i){var n=QI.exec(g.slice(i,i+2));return n?(e.M=+n[0],i+n[0].length):-1}function HNt(e,g,i){var n=QI.exec(g.slice(i,i+2));return n?(e.S=+n[0],i+n[0].length):-1}function NNt(e,g,i){var n=QI.exec(g.slice(i,i+3));return n?(e.L=+n[0],i+n[0].length):-1}function kNt(e,g,i){var n=QI.exec(g.slice(i,i+6));return n?(e.L=Math.floor(n[0]/1e3),i+n[0].length):-1}function YNt(e,g,i){var n=bNt.exec(g.slice(i,i+1));return n?i+n[0].length:-1}function KNt(e,g,i){var n=QI.exec(g.slice(i));return n?(e.Q=+n[0],i+n[0].length):-1}function xNt(e,g,i){var n=QI.exec(g.slice(i));return n?(e.s=+n[0],i+n[0].length):-1}function mve(e,g){return Ci(e.getDate(),g,2)}function FNt(e,g){return Ci(e.getHours(),g,2)}function ENt(e,g){return Ci(e.getHours()%12||12,g,2)}function DNt(e,g){return Ci(1+ST.count(kd(e),e),g,3)}function aze(e,g){return Ci(e.getMilliseconds(),g,3)}function MNt(e,g){return aze(e,g)+"000"}function zNt(e,g){return Ci(e.getMonth()+1,g,2)}function PNt(e,g){return Ci(e.getMinutes(),g,2)}function _Nt(e,g){return Ci(e.getSeconds(),g,2)}function ONt(e){var g=e.getDay();return g===0?7:g}function JNt(e,g){return Ci(Ez.count(kd(e)-1,e),g,2)}function sze(e){var g=e.getDay();return g>=4||g===0?QB(e):QB.ceil(e)}function LNt(e,g){return e=sze(e),Ci(QB.count(kd(e),e)+(kd(e).getDay()===4),g,2)}function UNt(e){return e.getDay()}function QNt(e,g){return Ci(yF.count(kd(e)-1,e),g,2)}function jNt(e,g){return Ci(e.getFullYear()%100,g,2)}function $Nt(e,g){return e=sze(e),Ci(e.getFullYear()%100,g,2)}function qNt(e,g){return Ci(e.getFullYear()%1e4,g,4)}function ekt(e,g){var i=e.getDay();return e=i>=4||i===0?QB(e):QB.ceil(e),Ci(e.getFullYear()%1e4,g,4)}function tkt(e){var g=e.getTimezoneOffset();return(g>0?"-":(g*=-1,"+"))+Ci(g/60|0,"0",2)+Ci(g%60,"0",2)}function pve(e,g){return Ci(e.getUTCDate(),g,2)}function gkt(e,g){return Ci(e.getUTCHours(),g,2)}function ikt(e,g){return Ci(e.getUTCHours()%12||12,g,2)}function nkt(e,g){return Ci(1+Fz.count(Yd(e),e),g,3)}function Aze(e,g){return Ci(e.getUTCMilliseconds(),g,3)}function Ikt(e,g){return Aze(e,g)+"000"}function rkt(e,g){return Ci(e.getUTCMonth()+1,g,2)}function okt(e,g){return Ci(e.getUTCMinutes(),g,2)}function Ckt(e,g){return Ci(e.getUTCSeconds(),g,2)}function akt(e){var g=e.getUTCDay();return g===0?7:g}function skt(e,g){return Ci(Dz.count(Yd(e)-1,e),g,2)}function lze(e){var g=e.getUTCDay();return g>=4||g===0?jB(e):jB.ceil(e)}function Akt(e,g){return e=lze(e),Ci(jB.count(Yd(e),e)+(Yd(e).getUTCDay()===4),g,2)}function lkt(e){return e.getUTCDay()}function ckt(e,g){return Ci(ZF.count(Yd(e)-1,e),g,2)}function ukt(e,g){return Ci(e.getUTCFullYear()%100,g,2)}function dkt(e,g){return e=lze(e),Ci(e.getUTCFullYear()%100,g,2)}function hkt(e,g){return Ci(e.getUTCFullYear()%1e4,g,4)}function fkt(e,g){var i=e.getUTCDay();return e=i>=4||i===0?jB(e):jB.ceil(e),Ci(e.getUTCFullYear()%1e4,g,4)}function mkt(){return"+0000"}function bve(){return"%"}function yve(e){return+e}function Zve(e){return Math.floor(+e/1e3)}var zZ,cze,uze;pkt({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function pkt(e){return zZ=pNt(e),cze=zZ.format,zZ.parse,uze=zZ.utcFormat,zZ.utcParse,zZ}function bkt(e){return new Date(e)}function ykt(e){return e instanceof Date?+e:+new Date(+e)}function QCe(e,g,i,n,I,r,o,C,a,A){var s=xCe(),l=s.invert,c=s.domain,u=A(".%L"),d=A(":%S"),h=A("%I:%M"),f=A("%I %p"),m=A("%a %d"),b=A("%b %d"),p=A("%B"),y=A("%Y");function Z(v){return(a(v)g(I/(e.length-1)))},i.quantiles=function(n){return Array.from({length:n+1},(I,r)=>FX(e,r/n))},i.copy=function(){return mze(g).domain(e)},jd.apply(i,arguments)}function zz(){var e=0,g=.5,i=1,n=1,I,r,o,C,a,A=To,s,l=!1,c;function u(h){return isNaN(h=+h)?c:(h=.5+((h=+s(h))-r)*(n*h1&&arguments[1]!==void 0?arguments[1]:0,i=(tr[e[g+0]]+tr[e[g+1]]+tr[e[g+2]]+tr[e[g+3]]+"-"+tr[e[g+4]]+tr[e[g+5]]+"-"+tr[e[g+6]]+tr[e[g+7]]+"-"+tr[e[g+8]]+tr[e[g+9]]+"-"+tr[e[g+10]]+tr[e[g+11]]+tr[e[g+12]]+tr[e[g+13]]+tr[e[g+14]]+tr[e[g+15]]).toLowerCase();if(!Pz(i))throw TypeError("Stringified UUID is invalid");return i}var Gve,xU,FU=0,EU=0;function Vkt(e,g,i){var n=g&&i||0,I=g||new Array(16);e=e||{};var r=e.node||Gve,o=e.clockseq!==void 0?e.clockseq:xU;if(r==null||o==null){var C=e.random||(e.rng||Zze)();r==null&&(r=Gve=[C[0]|1,C[1],C[2],C[3],C[4],C[5]]),o==null&&(o=xU=(C[6]<<8|C[7])&16383)}var a=e.msecs!==void 0?e.msecs:Date.now(),A=e.nsecs!==void 0?e.nsecs:EU+1,s=a-FU+(A-EU)/1e4;if(s<0&&e.clockseq===void 0&&(o=o+1&16383),(s<0||a>FU)&&e.nsecs===void 0&&(A=0),A>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");FU=a,EU=A,xU=o,a+=122192928e5;var l=((a&268435455)*1e4+A)%4294967296;I[n++]=l>>>24&255,I[n++]=l>>>16&255,I[n++]=l>>>8&255,I[n++]=l&255;var c=a/4294967296*1e4&268435455;I[n++]=c>>>8&255,I[n++]=c&255,I[n++]=c>>>24&15|16,I[n++]=c>>>16&255,I[n++]=o>>>8|128,I[n++]=o&255;for(var u=0;u<6;++u)I[n+u]=r[u];return g||_z(I)}function Gze(e){if(!Pz(e))throw TypeError("Invalid UUID");var g,i=new Uint8Array(16);return i[0]=(g=parseInt(e.slice(0,8),16))>>>24,i[1]=g>>>16&255,i[2]=g>>>8&255,i[3]=g&255,i[4]=(g=parseInt(e.slice(9,13),16))>>>8,i[5]=g&255,i[6]=(g=parseInt(e.slice(14,18),16))>>>8,i[7]=g&255,i[8]=(g=parseInt(e.slice(19,23),16))>>>8,i[9]=g&255,i[10]=(g=parseInt(e.slice(24,36),16))/1099511627776&255,i[11]=g/4294967296&255,i[12]=g>>>24&255,i[13]=g>>>16&255,i[14]=g>>>8&255,i[15]=g&255,i}function Wkt(e){e=unescape(encodeURIComponent(e));for(var g=[],i=0;i>5]>>>I%32&255,o=parseInt(n.charAt(r>>>4&15)+n.charAt(r&15),16);g.push(o)}return g}function Bze(e){return(e+64>>>9<<4)+14+1}function kkt(e,g){e[g>>5]|=128<>5]|=(e[n/8]&255)<>16)+(g>>16)+(i>>16);return n<<16|i&65535}function Kkt(e,g){return e<>>32-g}function Oz(e,g,i,n,I,r){return Zf(Kkt(Zf(Zf(g,e),Zf(n,r)),I),i)}function Vr(e,g,i,n,I,r,o){return Oz(g&i|~g&n,e,g,I,r,o)}function Wr(e,g,i,n,I,r,o){return Oz(g&n|i&~n,e,g,I,r,o)}function Xr(e,g,i,n,I,r,o){return Oz(g^i^n,e,g,I,r,o)}function Tr(e,g,i,n,I,r,o){return Oz(i^(g|~n),e,g,I,r,o)}var xkt=vze("v3",48,Hkt);const Fkt=xkt;function Ekt(e,g,i){e=e||{};var n=e.random||(e.rng||Zze)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,g){i=i||0;for(var I=0;I<16;++I)g[i+I]=n[I];return g}return _z(n)}function Dkt(e,g,i,n){switch(e){case 0:return g&i^~g&n;case 1:return g^i^n;case 2:return g&i^g&n^i&n;case 3:return g^i^n}}function DU(e,g){return e<>>32-g}function Mkt(e){var g=[1518500249,1859775393,2400959708,3395469782],i=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){var n=unescape(encodeURIComponent(e));e=[];for(var I=0;I>>0;p=b,b=m,m=DU(f,30)>>>0,f=h,h=v}i[0]=i[0]+h>>>0,i[1]=i[1]+f>>>0,i[2]=i[2]+m>>>0,i[3]=i[3]+b>>>0,i[4]=i[4]+p>>>0}return[i[0]>>24&255,i[0]>>16&255,i[0]>>8&255,i[0]&255,i[1]>>24&255,i[1]>>16&255,i[1]>>8&255,i[1]&255,i[2]>>24&255,i[2]>>16&255,i[2]>>8&255,i[2]&255,i[3]>>24&255,i[3]>>16&255,i[3]>>8&255,i[3]&255,i[4]>>24&255,i[4]>>16&255,i[4]>>8&255,i[4]&255]}var zkt=vze("v5",80,Mkt);const Pkt=zkt,_kt="00000000-0000-0000-0000-000000000000";function Okt(e){if(!Pz(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)}const Jkt=Object.freeze(Object.defineProperty({__proto__:null,NIL:_kt,parse:Gze,stringify:_z,v1:Vkt,v3:Fkt,v4:Ekt,v5:Pkt,validate:Pz,version:Okt},Symbol.toStringTag,{value:"Module"})),Lkt=Ud(Jkt);var Jz=Lkt,qCe=(()=>typeof Buffer<"u"?e=>Buffer.from(e).toString("base64"):e=>btoa(String.fromCharCode(...e)))(),Ukt=(()=>typeof Buffer<"u"?e=>Buffer.from(e,"base64"):e=>Uint8Array.from(atob(e),g=>g.charCodeAt(0)))();RT.encode=function(e){var g=Jz.parse(e),i=qCe(g),n=i.replace(/\+/g,"-").replace(/\//g,"_").substring(0,22);return n};RT.decode=function(e){var g=e.replace(/-/g,"+").replace(/_/g,"/")+"==";return Jz.stringify(Ukt(g))};RT.v4=function(){var e=Jz.v4(null,new Uint8Array(16)),g=qCe(e),i=g.replace(/\+/g,"-").replace(/\//g,"_").substring(0,22);return i};RT.nice=function(){var e=Jz.v4(null,new Uint8Array(16));e[0]=e[0]&127;var g=qCe(e),i=g.replace(/\+/g,"-").replace(/\//g,"_").substring(0,22);return i};var Qkt=RT;const Ng=EC(Qkt);var wze={exports:{}},Lz={},GF={exports:{}};GF.exports;(function(e,g){var i=200,n="__lodash_hash_undefined__",I=1,r=2,o=9007199254740991,C="[object Arguments]",a="[object Array]",A="[object AsyncFunction]",s="[object Boolean]",l="[object Date]",c="[object Error]",u="[object Function]",d="[object GeneratorFunction]",h="[object Map]",f="[object Number]",m="[object Null]",b="[object Object]",p="[object Promise]",y="[object Proxy]",Z="[object RegExp]",v="[object Set]",G="[object String]",B="[object Symbol]",S="[object Undefined]",R="[object WeakMap]",w="[object ArrayBuffer]",T="[object DataView]",W="[object Float32Array]",V="[object Float64Array]",X="[object Int8Array]",N="[object Int16Array]",Y="[object Int32Array]",x="[object Uint8Array]",M="[object Uint8ClampedArray]",F="[object Uint16Array]",$="[object Uint32Array]",Q=/[\\^$.*+?()[\]{}|]/g,U=/^\[object .+?Constructor\]$/,j=/^(?:0|[1-9]\d*)$/,ee={};ee[W]=ee[V]=ee[X]=ee[N]=ee[Y]=ee[x]=ee[M]=ee[F]=ee[$]=!0,ee[C]=ee[a]=ee[w]=ee[s]=ee[T]=ee[l]=ee[c]=ee[u]=ee[h]=ee[f]=ee[b]=ee[Z]=ee[v]=ee[G]=ee[R]=!1;var Ie=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis,fe=typeof self=="object"&&self&&self.Object===Object&&self,Ve=Ie||fe||Function("return this")(),oe=g&&!g.nodeType&&g,pe=oe&&!0&&e&&!e.nodeType&&e,ae=pe&&pe.exports===oe,ie=ae&&Ie.process,ye=function(){try{return ie&&ie.binding&&ie.binding("util")}catch{}}(),ue=ye&&ye.isTypedArray;function Ye(we,ze){for(var Ct=-1,Kt=we==null?0:we.length,Ui=0,wg=[];++Ct-1}function ct(we,ze){var Ct=this.__data__,Kt=Wn(Ct,we);return Kt<0?(++this.size,Ct.push([we,ze])):Ct[Kt][1]=ze,this}Xt.prototype.clear=Jt,Xt.prototype.delete=Zt,Xt.prototype.get=Ft,Xt.prototype.has=ig,Xt.prototype.set=ct;function Mt(we){var ze=-1,Ct=we==null?0:we.length;for(this.clear();++zeWI))return!1;var mn=wg.get(we);if(mn&&wg.get(ze))return mn==ze;var OC=-1,Rs=!0,Br=Ct&r?new Tt:void 0;for(wg.set(we,ze),wg.set(ze,we);++OC-1&&we%1==0&&we-1&&we%1==0&&we<=o}function Vme(we){var ze=typeof we;return we!=null&&(ze=="object"||ze=="function")}function kS(we){return we!=null&&typeof we=="object"}var Wme=ue?Pe(ue):Cst;function Zst(we){return bst(we)?Fg(we):ast(we)}function Gst(){return[]}function vst(){return!1}e.exports=yst})(GF,GF.exports);var Uz=GF.exports,Sze={exports:{}};/*! + Copyright (c) 2018 Jed Watson. + Licensed under the MIT License (MIT), see + http://jedwatson.github.io/classnames +*/(function(e){(function(){var g={}.hasOwnProperty;function i(){for(var n=[],I=0;Ig&&(g=i);return g}function tYt(e){for(var g=Array(e.length),i=0,n=e.length;i=g.x+g.w||e.y+e.h<=g.y||e.y>=g.y+g.h)}function Wze(e,g,i){for(var n=eae(e),I=tae(e,g),r=Array(e.length),o=0,C=I.length;og.y+g.h)break;Qz(g,C)&&gq(e,C,i+g[I],n)}}g[n]=i}function Xze(e,g,i,n,I){var r=i==="vertical",o=i==="horizontal";if(r)for(g.y=Math.min(vF(e),g.y);g.y>0&&!Dv(e,g);)g.y--;else if(o)for(g.y=Math.min(vF(e),g.y);g.x>0&&!Dv(e,g);)g.x--;for(var C=void 0;C=Dv(e,g);)o?gq(I,g,C.x+C.w,"x"):gq(I,g,C.y+C.h,"y"),o&&g.x+g.w>n&&(g.x=n-g.w,g.y++);return g}function Tze(e,g){for(var i=eae(e),n=0,I=e.length;ng.cols&&(r.x=g.cols-r.w),r.x<0&&(r.x=0,r.w=g.cols),!r.static)i.push(r);else for(;Dv(i,r);)r.y++}return e}function Hze(e,g){for(var i=0,n=e.length;i=n:o==="horizontal"&&typeof i=="number"?a>=i:!1;l&&(s=s.reverse());var c=Nze(s,g);if(r&&c.length)return""+g.i,g.x=a,g.y=A,g.moved=!1,e;for(var u=0,d=c.length;ui.y||g.y===i.y&&g.x>i.x?1:g.y===i.y&&g.x===i.x?0:-1})}function Yze(e){return[].concat(e).sort(function(g,i){return g.x>i.x||g.x===i.x&&g.y>i.y?1:-1})}function oYt(e,g,i,n){e=e||[];var I=[];return tq.default.Children.forEach(g,function(r,o){var C=Hze(e,String(r.key));if(C)I[o]=Ev(C);else{var a=r.props["data-grid"]||r.props._grid;a?I[o]=Ev(jkt({},a,{i:r.key})):I[o]=Ev({w:1,h:1,x:0,y:vF(I),i:String(r.key)})}}),I=Tze(I,{cols:i}),I=Wze(I,n,i),I}function CYt(e){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Layout",i=["x","y","w","h"];if(!Array.isArray(e))throw new Error(g+" must be an array!");for(var n=0,I=e.length;n1?Se-1:0),xe=1;xe2?Fe-2:0),Me=2;Me"u"||It===null)return""+It;var Tt=Cg(It);if(Tt==="object"){if(It instanceof Date)return"date";if(It instanceof RegExp)return"regexp"}return Tt}function qg(It){var Tt=$t(It);switch(Tt){case"array":case"object":return"an "+Tt;case"boolean":case"date":case"regexp":return"a "+Tt;default:return Tt}}function Ti(It){return!It.constructor||!It.constructor.name?Me:It.constructor.name}return Ne.checkPropTypes=w,Ne.PropTypes=Ne,Ne},W=I(function(ne){{var re=typeof Symbol=="function"&&Symbol.for&&Symbol.for("react.element")||60103,Se=function(xe){return typeof xe=="object"&&xe!==null&&xe.$$typeof===re},Fe=!0;ne.exports=T(Se,Fe)}}),V=I(function(ne){/*! + Copyright (c) 2016 Jed Watson. + Licensed under the MIT License (MIT), see + http://jedwatson.github.io/classnames +*/(function(){var re={}.hasOwnProperty;function Se(){for(var Fe=[],xe=0;xe0&&arguments[0]!==void 0?arguments[0]:"transform";if(typeof window>"u"||typeof window.document>"u")return"";var re=window.document.documentElement.style;if(ne in re)return"";for(var Se=0;Se0&&arguments[0]!==void 0?arguments[0]:{};return Ve({touchAction:"none"},ne)}function te(ne,re){ne.classList?ne.classList.add(re):ne.className.match(new RegExp("(?:^|\\s)"+re+"(?!\\S)"))||(ne.className+=" "+re)}function me(ne,re){ne.classList?ne.classList.remove(re):ne.className=ne.className.replace(new RegExp("(?:^|\\s)"+re+"(?!\\S)","g"),"")}function Re(ne,re,Se){if(!ne.props.bounds)return[re,Se];var Fe=ne.props.bounds;Fe=typeof Fe=="string"?Fe:ge(Fe);var xe=z(ne);if(typeof Fe=="string"){var Me=xe.ownerDocument,Ne=Me.defaultView,De=void 0;if(Fe==="parent"?De=xe.parentNode:De=Me.querySelector(Fe),!(De instanceof Ne.HTMLElement))throw new Error('Bounds selector "'+Fe+'" could not find an element.');var O=Ne.getComputedStyle(xe),D=Ne.getComputedStyle(De);Fe={left:-xe.offsetLeft+x(D.paddingLeft)+x(O.marginLeft),top:-xe.offsetTop+x(D.paddingTop)+x(O.marginTop),right:it(De)-_e(xe)-xe.offsetLeft+x(D.paddingRight)-x(O.marginRight),bottom:Pe(De)-ke(xe)-xe.offsetTop+x(D.paddingBottom)-x(O.marginBottom)}}return Y(Fe.right)&&(re=Math.min(re,Fe.right)),Y(Fe.bottom)&&(Se=Math.min(Se,Fe.bottom)),Y(Fe.left)&&(re=Math.max(re,Fe.left)),Y(Fe.top)&&(Se=Math.max(Se,Fe.top)),[re,Se]}function Ee(ne,re,Se){var Fe=Math.round(re/ne[0])*ne[0],xe=Math.round(Se/ne[1])*ne[1];return[Fe,xe]}function nt(ne){return ne.props.axis==="both"||ne.props.axis==="x"}function wt(ne){return ne.props.axis==="both"||ne.props.axis==="y"}function kt(ne,re,Se){var Fe=typeof re=="number"?Ze(ne,re):null;if(typeof re=="number"&&!Fe)return null;var xe=z(Se),Me=Se.props.offsetParent||xe.offsetParent||xe.ownerDocument.body;return lt(Fe||ne,Me)}function yt(ne,re,Se){var Fe=ne.state,xe=!Y(Fe.lastX),Me=z(ne);return xe?{node:Me,deltaX:0,deltaY:0,lastX:re,lastY:Se,x:re,y:Se}:{node:Me,deltaX:re-Fe.lastX,deltaY:Se-Fe.lastY,lastX:Fe.lastX,lastY:Fe.lastY,x:re,y:Se}}function Pt(ne,re){var Se=ne.props.scale;return{node:re.node,x:ne.state.x+re.deltaX/Se,y:ne.state.y+re.deltaY/Se,deltaX:re.deltaX/Se,deltaY:re.deltaY/Se,lastX:ne.state.x,lastY:ne.state.y}}function ge(ne){return{left:ne.left,top:ne.top,right:ne.right,bottom:ne.bottom}}function z(ne){var re=i.findDOMNode(ne);if(!re)throw new Error(": Unmounted during event!");return re}function J(){}var be={touch:{start:"touchstart",move:"touchmove",stop:"touchend"},mouse:{start:"mousedown",move:"mousemove",stop:"mouseup"}},Ke=be.mouse,de=function(ne){oe(re,ne);function re(){var Se,Fe,xe,Me;ee(this,re);for(var Ne=arguments.length,De=Array(Ne),O=0;O not mounted on DragStart!");var ce=q.ownerDocument;if(!(xe.props.disabled||!(D.target instanceof ce.defaultView.Node)||xe.props.handle&&!ue(D.target,xe.props.handle,q)||xe.props.cancel&&ue(D.target,xe.props.cancel,q))){var he=Te(D);xe.setState({touchIdentifier:he});var Oe=kt(D,he,xe);if(Oe!=null){var Je=Oe.x,bt=Oe.y,Xt=yt(xe,Je,bt);xe.props.onStart;var Jt=xe.props.onStart(D,Xt);Jt!==!1&&(xe.props.enableUserSelectHack&&E(ce),xe.setState({dragging:!0,lastX:Je,lastY:bt}),Ye(ce,Ke.move,xe.handleDrag),Ye(ce,Ke.stop,xe.handleDragStop))}}},xe.handleDrag=function(D){D.type==="touchmove"&&D.preventDefault();var q=kt(D,xe.state.touchIdentifier,xe);if(q!=null){var ce=q.x,he=q.y;if(Array.isArray(xe.props.grid)){var Oe=ce-xe.state.lastX,Je=he-xe.state.lastY,bt=Ee(xe.props.grid,Oe,Je),Xt=ae(bt,2);if(Oe=Xt[0],Je=Xt[1],!Oe&&!Je)return;ce=xe.state.lastX+Oe,he=xe.state.lastY+Je}var Jt=yt(xe,ce,he),Zt=xe.props.onDrag(D,Jt);if(Zt===!1){try{xe.handleDragStop(new MouseEvent("mouseup"))}catch{var Ft=document.createEvent("MouseEvents");Ft.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),xe.handleDragStop(Ft)}return}xe.setState({lastX:ce,lastY:he})}},xe.handleDragStop=function(D){if(xe.state.dragging){var q=kt(D,xe.state.touchIdentifier,xe);if(q!=null){var ce=q.x,he=q.y,Oe=yt(xe,ce,he),Je=i.findDOMNode(xe);Je&&xe.props.enableUserSelectHack&&H(Je.ownerDocument),xe.setState({dragging:!1,lastX:NaN,lastY:NaN}),xe.props.onStop(D,Oe),Je&&(Be(Je.ownerDocument,Ke.move,xe.handleDrag),Be(Je.ownerDocument,Ke.stop,xe.handleDragStop))}}},xe.onMouseDown=function(D){return Ke=be.mouse,xe.handleDragStart(D)},xe.onMouseUp=function(D){return Ke=be.mouse,xe.handleDragStop(D)},xe.onTouchStart=function(D){return Ke=be.touch,xe.handleDragStart(D)},xe.onTouchEnd=function(D){return Ke=be.touch,xe.handleDragStop(D)},Fe),pe(xe,Me)}return Ie(re,[{key:"componentWillUnmount",value:function(){var Fe=i.findDOMNode(this);if(Fe){var xe=Fe.ownerDocument;Be(xe,be.mouse.move,this.handleDrag),Be(xe,be.touch.move,this.handleDrag),Be(xe,be.mouse.stop,this.handleDragStop),Be(xe,be.touch.stop,this.handleDragStop),this.props.enableUserSelectHack&&H(xe)}}},{key:"render",value:function(){return n.cloneElement(n.Children.only(this.props.children),{style:K(this.props.children.props.style),onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}}]),re}(n.Component);de.displayName="DraggableCore",de.propTypes={allowAnyClick:W.bool,disabled:W.bool,enableUserSelectHack:W.bool,offsetParent:function(re,Se){if(re[Se]&&re[Se].nodeType!==1)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:W.arrayOf(W.number),scale:W.number,handle:W.string,cancel:W.string,onStart:W.func,onDrag:W.func,onStop:W.func,onMouseDown:W.func,className:M,style:M,transform:M},de.defaultProps={allowAnyClick:!1,cancel:null,disabled:!1,enableUserSelectHack:!0,offsetParent:null,handle:null,grid:null,transform:null,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){}};var le=function(ne){oe(re,ne);function re(Se){ee(this,re);var Fe=pe(this,(re.__proto__||Object.getPrototypeOf(re)).call(this,Se));return Fe.onDragStart=function(xe,Me){var Ne=Fe.props.onStart(xe,Pt(Fe,Me));if(Ne===!1)return!1;Fe.setState({dragging:!0,dragged:!0})},Fe.onDrag=function(xe,Me){if(!Fe.state.dragging)return!1;var Ne=Pt(Fe,Me),De={x:Ne.x,y:Ne.y};if(Fe.props.bounds){var O=De.x,D=De.y;De.x+=Fe.state.slackX,De.y+=Fe.state.slackY;var q=Re(Fe,De.x,De.y),ce=ae(q,2),he=ce[0],Oe=ce[1];De.x=he,De.y=Oe,De.slackX=Fe.state.slackX+(O-De.x),De.slackY=Fe.state.slackY+(D-De.y),Ne.x=De.x,Ne.y=De.y,Ne.deltaX=De.x-Fe.state.x,Ne.deltaY=De.y-Fe.state.y}var Je=Fe.props.onDrag(xe,Ne);if(Je===!1)return!1;Fe.setState(De)},Fe.onDragStop=function(xe,Me){if(!Fe.state.dragging)return!1;var Ne=Fe.props.onStop(xe,Pt(Fe,Me));if(Ne===!1)return!1;var De={dragging:!1,slackX:0,slackY:0},O=!!Fe.props.position;if(O){var D=Fe.props.position,q=D.x,ce=D.y;De.x=q,De.y=ce}Fe.setState(De)},Fe.state={dragging:!1,dragged:!1,x:Se.position?Se.position.x:Se.defaultPosition.x,y:Se.position?Se.position.y:Se.defaultPosition.y,slackX:0,slackY:0,isElementSVG:!1},Se.position&&!(Se.onDrag||Se.onStop)&&console.warn("A `position` was applied to this , without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element."),Fe}return Ie(re,[{key:"componentDidMount",value:function(){typeof window.SVGElement<"u"&&i.findDOMNode(this)instanceof window.SVGElement&&this.setState({isElementSVG:!0})}},{key:"componentWillReceiveProps",value:function(Fe){Fe.position&&(!this.props.position||Fe.position.x!==this.props.position.x||Fe.position.y!==this.props.position.y)&&this.setState({x:Fe.position.x,y:Fe.position.y})}},{key:"componentWillUnmount",value:function(){this.setState({dragging:!1})}},{key:"render",value:function(){var Fe,xe={},Me=null,Ne=!!this.props.position,De=!Ne||this.state.dragging,O=this.props.position||this.props.defaultPosition,D={x:nt(this)&&De?this.state.x:O.x,y:wt(this)&&De?this.state.y:O.y};this.state.isElementSVG?Me=He(D,this.props.positionOffset):xe=je(D,this.props.positionOffset);var q=this.props,ce=q.defaultClassName,he=q.defaultClassNameDragging,Oe=q.defaultClassNameDragged,Je=n.Children.only(this.props.children),bt=V(Je.props.className||"",ce,(Fe={},fe(Fe,he,this.state.dragging),fe(Fe,Oe,this.state.dragged),Fe));return n.createElement(de,Ve({},this.props,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),n.cloneElement(Je,{className:bt,style:Ve({},Je.props.style,xe),transform:Me}))}}]),re}(n.Component);return le.displayName="Draggable",le.propTypes=Ve({},de.propTypes,{axis:W.oneOf(["both","x","y","none"]),bounds:W.oneOfType([W.shape({left:W.number,right:W.number,top:W.number,bottom:W.number}),W.string,W.oneOf([!1])]),defaultClassName:W.string,defaultClassNameDragging:W.string,defaultClassNameDragged:W.string,defaultPosition:W.shape({x:W.number,y:W.number}),positionOffset:W.shape({x:W.oneOfType([W.number,W.string]),y:W.oneOfType([W.number,W.string])}),position:W.shape({x:W.number,y:W.number}),className:M,style:M,transform:M}),le.defaultProps=Ve({},de.defaultProps,{axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},position:null,scale:1}),le.default=le,le.DraggableCore=de,le})})(Kze);var sYt=Kze.exports,jz={exports:{}},VT={},$z={exports:{}},xze={};function Fze(e){var g,i,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e))for(g=0;g0&&arguments[0]!==void 0?arguments[0]:"transform";if(typeof window>"u")return"";const i=(e=window.document)===null||e===void 0||(e=e.documentElement)===null||e===void 0?void 0:e.style;if(!i||g in i)return"";for(let n=0;ng===i.identifier)||e.changedTouches&&(0,ha.findInArray)(e.changedTouches,i=>g===i.identifier)}function TYt(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier}function HYt(e){if(!e)return;let g=e.getElementById("react-draggable-style-el");g||(g=e.createElement("style"),g.type="text/css",g.id="react-draggable-style-el",g.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;} +`,g.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;} +`,e.getElementsByTagName("head")[0].appendChild(g)),e.body&&Pze(e.body,"react-draggable-transparent-selection")}function NYt(e){if(e)try{if(e.body&&_ze(e.body,"react-draggable-transparent-selection"),e.selection)e.selection.empty();else{const g=(e.defaultView||window).getSelection();g&&g.type!=="Caret"&&g.removeAllRanges()}}catch{}}function Pze(e,g){e.classList?e.classList.add(g):e.className.match(new RegExp("(?:^|\\s)".concat(g,"(?!\\S)")))||(e.className+=" ".concat(g))}function _ze(e,g){e.classList?e.classList.remove(g):e.className=e.className.replace(new RegExp("(?:^|\\s)".concat(g,"(?!\\S)"),"g"),"")}var Lc={};Object.defineProperty(Lc,"__esModule",{value:!0});Lc.canDragX=KYt;Lc.canDragY=xYt;Lc.createCoreData=EYt;Lc.createDraggableData=DYt;Lc.getBoundPosition=kYt;Lc.getControlPosition=FYt;Lc.snapToGrid=YYt;var LC=Jc,lv=Mn;function kYt(e,g,i){if(!e.props.bounds)return[g,i];let{bounds:n}=e.props;n=typeof n=="string"?n:MYt(n);const I=nae(e);if(typeof n=="string"){const{ownerDocument:r}=I,o=r.defaultView;let C;if(n==="parent"?C=I.parentNode:C=r.querySelector(n),!(C instanceof o.HTMLElement))throw new Error('Bounds selector "'+n+'" could not find an element.');const a=C,A=o.getComputedStyle(I),s=o.getComputedStyle(a);n={left:-I.offsetLeft+(0,LC.int)(s.paddingLeft)+(0,LC.int)(A.marginLeft),top:-I.offsetTop+(0,LC.int)(s.paddingTop)+(0,LC.int)(A.marginTop),right:(0,lv.innerWidth)(a)-(0,lv.outerWidth)(I)-I.offsetLeft+(0,LC.int)(s.paddingRight)-(0,LC.int)(A.marginRight),bottom:(0,lv.innerHeight)(a)-(0,lv.outerHeight)(I)-I.offsetTop+(0,LC.int)(s.paddingBottom)-(0,LC.int)(A.marginBottom)}}return(0,LC.isNum)(n.right)&&(g=Math.min(g,n.right)),(0,LC.isNum)(n.bottom)&&(i=Math.min(i,n.bottom)),(0,LC.isNum)(n.left)&&(g=Math.max(g,n.left)),(0,LC.isNum)(n.top)&&(i=Math.max(i,n.top)),[g,i]}function YYt(e,g,i){const n=Math.round(g/e[0])*e[0],I=Math.round(i/e[1])*e[1];return[n,I]}function KYt(e){return e.props.axis==="both"||e.props.axis==="x"}function xYt(e){return e.props.axis==="both"||e.props.axis==="y"}function FYt(e,g,i){const n=typeof g=="number"?(0,lv.getTouch)(e,g):null;if(typeof g=="number"&&!n)return null;const I=nae(i),r=i.props.offsetParent||I.offsetParent||I.ownerDocument.body;return(0,lv.offsetXYFromParent)(n||e,r,i.props.scale)}function EYt(e,g,i){const n=!(0,LC.isNum)(e.lastX),I=nae(e);return n?{node:I,deltaX:0,deltaY:0,lastX:g,lastY:i,x:g,y:i}:{node:I,deltaX:g-e.lastX,deltaY:i-e.lastY,lastX:e.lastX,lastY:e.lastY,x:g,y:i}}function DYt(e,g){const i=e.props.scale;return{node:g.node,x:e.state.x+g.deltaX/i,y:e.state.y+g.deltaY/i,deltaX:g.deltaX/i,deltaY:g.deltaY/i,lastX:e.state.x,lastY:e.state.y}}function MYt(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function nae(e){const g=e.findDOMNode();if(!g)throw new Error(": Unmounted during event!");return g}var qz={},eP={};Object.defineProperty(eP,"__esModule",{value:!0});eP.default=zYt;function zYt(){}function PYt(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function Bve(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function BF(e){return BF=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},BF(e)}Object.defineProperty(qz,"__esModule",{value:!0});qz.default=void 0;var zU=qYt(k),$o=Iae(Qd),$Yt=Iae(_I),Hr=Mn,wh=Lc,PU=Jc,lR=Iae(eP);function Iae(e){return e&&e.__esModule?e:{default:e}}function Oze(e){if(typeof WeakMap!="function")return null;var g=new WeakMap,i=new WeakMap;return(Oze=function(n){return n?i:g})(e)}function qYt(e,g){if(!g&&e&&e.__esModule)return e;if(e===null||typeof e!="object"&&typeof e!="function")return{default:e};var i=Oze(g);if(i&&i.has(e))return i.get(e);var n={},I=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)){var o=I?Object.getOwnPropertyDescriptor(e,r):null;o&&(o.get||o.set)?Object.defineProperty(n,r,o):n[r]=e[r]}return n.default=e,i&&i.set(e,n),n}function lo(e,g,i){return g=eKt(g),g in e?Object.defineProperty(e,g,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[g]=i,e}function eKt(e){var g=tKt(e,"string");return typeof g=="symbol"?g:String(g)}function tKt(e,g){if(typeof e!="object"||e===null)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var n=i.call(e,g||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(g==="string"?String:Number)(e)}const Us={touch:{start:"touchstart",move:"touchmove",stop:"touchend"},mouse:{start:"mousedown",move:"mousemove",stop:"mouseup"}};let Sh=Us.mouse,tP=function(e){LYt(i,e);var g=UYt(i);function i(){var n;return PYt(this,i),n=g.apply(this,arguments),lo(sI(n),"dragging",!1),lo(sI(n),"lastX",NaN),lo(sI(n),"lastY",NaN),lo(sI(n),"touchIdentifier",null),lo(sI(n),"mounted",!1),lo(sI(n),"handleDragStart",I=>{if(n.props.onMouseDown(I),!n.props.allowAnyClick&&typeof I.button=="number"&&I.button!==0)return!1;const r=n.findDOMNode();if(!r||!r.ownerDocument||!r.ownerDocument.body)throw new Error(" not mounted on DragStart!");const{ownerDocument:o}=r;if(n.props.disabled||!(I.target instanceof o.defaultView.Node)||n.props.handle&&!(0,Hr.matchesSelectorAndParentsTo)(I.target,n.props.handle,r)||n.props.cancel&&(0,Hr.matchesSelectorAndParentsTo)(I.target,n.props.cancel,r))return;I.type==="touchstart"&&I.preventDefault();const C=(0,Hr.getTouchIdentifier)(I);n.touchIdentifier=C;const a=(0,wh.getControlPosition)(I,C,sI(n));if(a==null)return;const{x:A,y:s}=a,l=(0,wh.createCoreData)(sI(n),A,s);(0,lR.default)("DraggableCore: handleDragStart: %j",l),(0,lR.default)("calling",n.props.onStart),!(n.props.onStart(I,l)===!1||n.mounted===!1)&&(n.props.enableUserSelectHack&&(0,Hr.addUserSelectStyles)(o),n.dragging=!0,n.lastX=A,n.lastY=s,(0,Hr.addEvent)(o,Sh.move,n.handleDrag),(0,Hr.addEvent)(o,Sh.stop,n.handleDragStop))}),lo(sI(n),"handleDrag",I=>{const r=(0,wh.getControlPosition)(I,n.touchIdentifier,sI(n));if(r==null)return;let{x:o,y:C}=r;if(Array.isArray(n.props.grid)){let s=o-n.lastX,l=C-n.lastY;if([s,l]=(0,wh.snapToGrid)(n.props.grid,s,l),!s&&!l)return;o=n.lastX+s,C=n.lastY+l}const a=(0,wh.createCoreData)(sI(n),o,C);if((0,lR.default)("DraggableCore: handleDrag: %j",a),n.props.onDrag(I,a)===!1||n.mounted===!1){try{n.handleDragStop(new MouseEvent("mouseup"))}catch{const l=document.createEvent("MouseEvents");l.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),n.handleDragStop(l)}return}n.lastX=o,n.lastY=C}),lo(sI(n),"handleDragStop",I=>{if(!n.dragging)return;const r=(0,wh.getControlPosition)(I,n.touchIdentifier,sI(n));if(r==null)return;let{x:o,y:C}=r;if(Array.isArray(n.props.grid)){let l=o-n.lastX||0,c=C-n.lastY||0;[l,c]=(0,wh.snapToGrid)(n.props.grid,l,c),o=n.lastX+l,C=n.lastY+c}const a=(0,wh.createCoreData)(sI(n),o,C);if(n.props.onStop(I,a)===!1||n.mounted===!1)return!1;const s=n.findDOMNode();s&&n.props.enableUserSelectHack&&(0,Hr.removeUserSelectStyles)(s.ownerDocument),(0,lR.default)("DraggableCore: handleDragStop: %j",a),n.dragging=!1,n.lastX=NaN,n.lastY=NaN,s&&((0,lR.default)("DraggableCore: Removing handlers"),(0,Hr.removeEvent)(s.ownerDocument,Sh.move,n.handleDrag),(0,Hr.removeEvent)(s.ownerDocument,Sh.stop,n.handleDragStop))}),lo(sI(n),"onMouseDown",I=>(Sh=Us.mouse,n.handleDragStart(I))),lo(sI(n),"onMouseUp",I=>(Sh=Us.mouse,n.handleDragStop(I))),lo(sI(n),"onTouchStart",I=>(Sh=Us.touch,n.handleDragStart(I))),lo(sI(n),"onTouchEnd",I=>(Sh=Us.touch,n.handleDragStop(I))),n}return _Yt(i,[{key:"componentDidMount",value:function(){this.mounted=!0;const I=this.findDOMNode();I&&(0,Hr.addEvent)(I,Us.touch.start,this.onTouchStart,{passive:!1})}},{key:"componentWillUnmount",value:function(){this.mounted=!1;const I=this.findDOMNode();if(I){const{ownerDocument:r}=I;(0,Hr.removeEvent)(r,Us.mouse.move,this.handleDrag),(0,Hr.removeEvent)(r,Us.touch.move,this.handleDrag),(0,Hr.removeEvent)(r,Us.mouse.stop,this.handleDragStop),(0,Hr.removeEvent)(r,Us.touch.stop,this.handleDragStop),(0,Hr.removeEvent)(I,Us.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,Hr.removeUserSelectStyles)(r)}}},{key:"findDOMNode",value:function(){var I,r;return(I=this.props)!==null&&I!==void 0&&I.nodeRef?(r=this.props)===null||r===void 0||(r=r.nodeRef)===null||r===void 0?void 0:r.current:$Yt.default.findDOMNode(this)}},{key:"render",value:function(){return zU.cloneElement(zU.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}}]),i}(zU.Component);qz.default=tP;lo(tP,"displayName","DraggableCore");lo(tP,"propTypes",{allowAnyClick:$o.default.bool,children:$o.default.node.isRequired,disabled:$o.default.bool,enableUserSelectHack:$o.default.bool,offsetParent:function(e,g){if(e[g]&&e[g].nodeType!==1)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:$o.default.arrayOf($o.default.number),handle:$o.default.string,cancel:$o.default.string,nodeRef:$o.default.object,onStart:$o.default.func,onDrag:$o.default.func,onStop:$o.default.func,onMouseDown:$o.default.func,scale:$o.default.number,className:PU.dontSetMe,style:PU.dontSetMe,transform:PU.dontSetMe});lo(tP,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1});(function(e){function g(V,X){if(!(V instanceof X))throw new TypeError("Cannot call a class as a function")}function i(V,X){for(var N=0;N"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function c(V){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(N){return N.__proto__||Object.getPrototypeOf(N)},c(V)}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"DraggableCore",{enumerable:!0,get:function(){return y.default}}),e.default=void 0;var u=B(k),d=v(Qd),h=v(_I),f=v(lYt),m=Mn,b=Lc,p=Jc,y=v(qz),Z=v(eP);function v(V){return V&&V.__esModule?V:{default:V}}function G(V){if(typeof WeakMap!="function")return null;var X=new WeakMap,N=new WeakMap;return(G=function(Y){return Y?N:X})(V)}function B(V,X){if(!X&&V&&V.__esModule)return V;if(V===null||typeof V!="object"&&typeof V!="function")return{default:V};var N=G(X);if(N&&N.has(V))return N.get(V);var Y={},x=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var M in V)if(M!=="default"&&Object.prototype.hasOwnProperty.call(V,M)){var F=x?Object.getOwnPropertyDescriptor(V,M):null;F&&(F.get||F.set)?Object.defineProperty(Y,M,F):Y[M]=V[M]}return Y.default=V,N&&N.set(V,Y),Y}function S(){return S=Object.assign?Object.assign.bind():function(V){for(var X=1;X{if((0,Z.default)("Draggable: onDragStart: %j",F),x.props.onStart(M,(0,b.createDraggableData)(s(x),F))===!1)return!1;x.setState({dragging:!0,dragged:!0})}),R(s(x),"onDrag",(M,F)=>{if(!x.state.dragging)return!1;(0,Z.default)("Draggable: onDrag: %j",F);const $=(0,b.createDraggableData)(s(x),F),Q={x:$.x,y:$.y,slackX:0,slackY:0};if(x.props.bounds){const{x:j,y:ee}=Q;Q.x+=x.state.slackX,Q.y+=x.state.slackY;const[Ie,fe]=(0,b.getBoundPosition)(s(x),Q.x,Q.y);Q.x=Ie,Q.y=fe,Q.slackX=x.state.slackX+(j-Q.x),Q.slackY=x.state.slackY+(ee-Q.y),$.x=Q.x,$.y=Q.y,$.deltaX=Q.x-x.state.x,$.deltaY=Q.y-x.state.y}if(x.props.onDrag(M,$)===!1)return!1;x.setState(Q)}),R(s(x),"onDragStop",(M,F)=>{if(!x.state.dragging||x.props.onStop(M,(0,b.createDraggableData)(s(x),F))===!1)return!1;(0,Z.default)("Draggable: onDragStop: %j",F);const Q={dragging:!1,slackX:0,slackY:0};if(!!x.props.position){const{x:j,y:ee}=x.props.position;Q.x=j,Q.y=ee}x.setState(Q)}),x.state={dragging:!1,dragged:!1,x:Y.position?Y.position.x:Y.defaultPosition.x,y:Y.position?Y.position.y:Y.defaultPosition.y,prevPropsPosition:{...Y.position},slackX:0,slackY:0,isElementSVG:!1},Y.position&&!(Y.onDrag||Y.onStop)&&console.warn("A `position` was applied to this , without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element."),x}return n(N,[{key:"componentDidMount",value:function(){typeof window.SVGElement<"u"&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}},{key:"componentWillUnmount",value:function(){this.setState({dragging:!1})}},{key:"findDOMNode",value:function(){var x,M;return(x=(M=this.props)===null||M===void 0||(M=M.nodeRef)===null||M===void 0?void 0:M.current)!==null&&x!==void 0?x:h.default.findDOMNode(this)}},{key:"render",value:function(){const{axis:x,bounds:M,children:F,defaultPosition:$,defaultClassName:Q,defaultClassNameDragging:U,defaultClassNameDragged:j,position:ee,positionOffset:Ie,scale:fe,...Ve}=this.props;let oe={},pe=null;const ie=!!!ee||this.state.dragging,ye=ee||$,ue={x:(0,b.canDragX)(this)&&ie?this.state.x:ye.x,y:(0,b.canDragY)(this)&&ie?this.state.y:ye.y};this.state.isElementSVG?pe=(0,m.createSVGTransform)(ue,Ie):oe=(0,m.createCSSTransform)(ue,Ie);const Ye=(0,f.default)(F.props.className||"",Q,{[U]:this.state.dragging,[j]:this.state.dragged});return u.createElement(y.default,S({},Ve,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),u.cloneElement(u.Children.only(F),{className:Ye,style:{...F.props.style,...oe},transform:pe}))}}],[{key:"getDerivedStateFromProps",value:function(x,M){let{position:F}=x,{prevPropsPosition:$}=M;return F&&(!$||F.x!==$.x||F.y!==$.y)?((0,Z.default)("Draggable: getDerivedStateFromProps %j",{position:F,prevPropsPosition:$}),{x:F.x,y:F.y,prevPropsPosition:{...F}}):null}}]),N}(u.Component);e.default=W,R(W,"displayName","Draggable"),R(W,"propTypes",{...y.default.propTypes,axis:d.default.oneOf(["both","x","y","none"]),bounds:d.default.oneOfType([d.default.shape({left:d.default.number,right:d.default.number,top:d.default.number,bottom:d.default.number}),d.default.string,d.default.oneOf([!1])]),defaultClassName:d.default.string,defaultClassNameDragging:d.default.string,defaultClassNameDragged:d.default.string,defaultPosition:d.default.shape({x:d.default.number,y:d.default.number}),positionOffset:d.default.shape({x:d.default.oneOfType([d.default.number,d.default.string]),y:d.default.oneOfType([d.default.number,d.default.string])}),position:d.default.shape({x:d.default.number,y:d.default.number}),className:p.dontSetMe,style:p.dontSetMe,transform:p.dontSetMe}),R(W,"defaultProps",{...y.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})})(xze);const{default:Jze,DraggableCore:gKt}=xze;$z.exports=Jze;$z.exports.default=Jze;$z.exports.DraggableCore=gKt;var iKt=$z.exports,rae={};rae.__esModule=!0;rae.cloneElement=oKt;var nKt=IKt(k);function IKt(e){return e&&e.__esModule?e:{default:e}}function wve(e,g){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);g&&(n=n.filter(function(I){return Object.getOwnPropertyDescriptor(e,I).enumerable})),i.push.apply(i,n)}return i}function Sve(e){for(var g=1;g=0)&&(i[I]=e[I]);return i}function OU(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function dKt(e,g){e.prototype=Object.create(g.prototype),e.prototype.constructor=e,e.__proto__=g}function Mv(e,g,i){return g in e?Object.defineProperty(e,g,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[g]=i,e}var oae=function(e){dKt(g,e);function g(){for(var n,I=arguments.length,r=new Array(I),o=0;o=0)&&(i[I]=e[I]);return i}function Xve(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function yKt(e,g){e.prototype=Object.create(g.prototype),e.prototype.constructor=e,e.__proto__=g}function SF(e,g,i){return g in e?Object.defineProperty(e,g,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[g]=i,e}var Qze=function(e){yKt(g,e);function g(){for(var n,I=arguments.length,r=new Array(I),o=0;og.w||n>g.maxW)return new Error("minWidth larger than item width/maxWidth")},maxW:function(g,i){var n=g[i];if(typeof n!="number")return new Error("maxWidth not Number");if(ng.h||n>g.maxH)return new Error("minHeight larger than item height/maxHeight")},maxH:function(g,i){var n=g[i];if(typeof n!="number")return new Error("maxHeight not Number");if(n0,f){var b=1/0,p=1/0;m.forEach(function(Z){Z.x>h.x&&(b=Math.min(b,Z.x)),Z.y>h.y&&(p=Math.min(p,Z.y))}),Number.isFinite(b)&&(h.w=b-h.x),Number.isFinite(p)&&(h.h=p-h.y)}}f||(h.w=I,h.h=r);var y={w:h.w,h:h.h,x:h.x,y:h.y,static:!0,i:n};this.props.onResize(s,l,h,y,C,a),this.setState({layout:(0,fi.compact)(s,this.compactType(),u),activeDrag:y})}},g.prototype.onResizeStop=function(n,I,r,o){var C=o.e,a=o.node,A=this.state,s=A.layout,l=A.oldResizeItem,c=this.props.cols,u=(0,fi.getLayoutItem)(s,n);this.props.onResizeStop(s,l,u,null,C,a);var d=(0,fi.compact)(s,this.compactType(),c),h=this.state.oldLayout;this.setState({activeDrag:null,layout:d,oldResizeItem:null,oldLayout:null}),this.onLayoutMaybeChanged(d,h)},g.prototype.placeholder=function(){var n=this.state.activeDrag;if(!n)return null;var I=this.props,r=I.width,o=I.cols,C=I.margin,a=I.containerPadding,A=I.rowHeight,s=I.maxRows,l=I.useCSSTransforms;return e0.default.createElement(kve.default,{w:n.w,h:n.h,x:n.x,y:n.y,i:n.i,className:"react-grid-placeholder",containerWidth:r,cols:o,margin:C,containerPadding:a||C,maxRows:s,rowHeight:A,isDraggable:!1,isResizable:!1,useCSSTransforms:l},e0.default.createElement("div",null))},g.prototype.processGridItem=function(n){if(!(!n||!n.key)){var I=(0,fi.getLayoutItem)(this.state.layout,String(n.key));if(!I)return null;var r=this.props,o=r.width,C=r.cols,a=r.margin,A=r.containerPadding,s=r.rowHeight,l=r.maxRows,c=r.isDraggable,u=r.isResizable,d=r.useCSSTransforms,h=r.draggableCancel,f=r.draggableHandle,m=this.state.mounted,b=!!(!I.static&&c&&(I.isDraggable||I.isDraggable==null)),p=!!(!I.static&&u&&(I.isResizable||I.isResizable==null));return e0.default.createElement(kve.default,{containerWidth:o,cols:C,margin:a,containerPadding:A||a,maxRows:l,rowHeight:s,cancel:h,handle:f,onDragStop:this.onDragStop,onDragStart:this.onDragStart,onDrag:this.onDrag,onResizeStart:this.onResizeStart,onResize:this.onResize,onResizeStop:this.onResizeStop,isDraggable:b,isResizable:p,useCSSTransforms:d&&m,usePercentages:!m,w:I.w,h:I.h,x:I.x,y:I.y,i:I.i,minH:I.minH,minW:I.minW,maxH:I.maxH,maxW:I.maxW,static:I.static},n)}},g.prototype.render=function(){var n=this,I=this.props,r=I.className,o=I.style,C=(0,YKt.default)("react-grid-layout",r),a=Hve({height:this.containerHeight()},o);return e0.default.createElement("div",{className:C,style:a},e0.default.Children.map(this.props.children,function(A){return n.processGridItem(A)}),this.placeholder())},g}(e0.default.Component);iP.displayName="ReactGridLayout";iP.propTypes={className:ji.default.string,style:ji.default.object,width:ji.default.number,autoSize:ji.default.bool,cols:ji.default.number,draggableCancel:ji.default.string,draggableHandle:ji.default.string,verticalCompact:function(g){g.verticalCompact},compactType:ji.default.oneOf(["vertical","horizontal"]),layout:function(g){var i=g.layout;i!==void 0&&(0,fi.validateLayout)(i,"layout")},margin:ji.default.arrayOf(ji.default.number),containerPadding:ji.default.arrayOf(ji.default.number),rowHeight:ji.default.number,maxRows:ji.default.number,isDraggable:ji.default.bool,isResizable:ji.default.bool,preventCollision:ji.default.bool,useCSSTransforms:ji.default.bool,onLayoutChange:ji.default.func,onDragStart:ji.default.func,onDrag:ji.default.func,onDragStop:ji.default.func,onResizeStart:ji.default.func,onResize:ji.default.func,onResizeStop:ji.default.func,children:function(g,i){var n=g[i],I={};e0.default.Children.forEach(n,function(r){if(I[r.key])throw new Error('Duplicate child key "'+r.key+'" found! This will cause problems in ReactGridLayout.');I[r.key]=!0})}};iP.defaultProps={autoSize:!0,cols:12,className:"",style:{},draggableHandle:"",draggableCancel:"",containerPadding:null,rowHeight:150,maxRows:1/0,layout:[],margin:[10,10],isDraggable:!0,isResizable:!0,useCSSTransforms:!0,verticalCompact:!0,compactType:"vertical",preventCollision:!1,onLayoutChange:fi.noop,onDragStart:fi.noop,onDrag:fi.noop,onDragStop:fi.noop,onResizeStart:fi.noop,onResize:fi.noop,onResizeStop:fi.noop};var DKt=function(){this.state={activeDrag:null,layout:(0,fi.synchronizeLayoutWithChildren)(this.props.layout,this.props.children,this.props.cols,this.compactType()),mounted:!1,oldDragItem:null,oldLayout:null,oldResizeItem:null}};Lz.default=iP;var sae={},Uy={};Uy.__esModule=!0;Uy.getBreakpointFromWidth=MKt;Uy.getColsFromBreakpoint=zKt;Uy.findOrGenerateResponsiveLayout=PKt;Uy.sortBreakpoints=Aae;var Vk=ci;function MKt(e,g){for(var i=Aae(e),n=i[0],I=1,r=i.length;Ie[o]&&(n=o)}return n}function zKt(e,g){if(!g[e])throw new Error("ResponsiveReactGridLayout: `cols` entry for breakpoint "+e+" is missing!");return g[e]}function PKt(e,g,i,n,I,r){if(e[i])return(0,Vk.cloneLayout)(e[i]);for(var o=e[n],C=Aae(g),a=C.slice(C.indexOf(i)),A=0,s=a.length;A=0||Object.prototype.hasOwnProperty.call(e,n)&&(i[n]=e[n]);return i}function jKt(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function xve(e,g){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g&&(typeof g=="object"||typeof g=="function")?g:e}function $Kt(e,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);e.prototype=Object.create(g&&g.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(e,g):e.__proto__=g)}var Fve=function(g){return Object.prototype.toString.call(g)},lae=function(e){$Kt(g,e);function g(){var i,n,I;jKt(this,g);for(var r=arguments.length,o=Array(r),C=0;C=0||Object.prototype.hasOwnProperty.call(e,n)&&(i[n]=e[n]);return i}function r5t(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function Eve(e,g){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g&&(typeof g=="object"||typeof g=="function")?g:e}function o5t(e,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);e.prototype=Object.create(g&&g.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(e,g):e.__proto__=g)}function C5t(e){var g,i;return i=g=function(n){o5t(I,n);function I(){var r,o,C;r5t(this,I);for(var a=arguments.length,A=Array(a),s=0;s"u")return null;var i=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")(),n=i.requestAnimationFrame||i.mozRequestAnimationFrame||i.webkitRequestAnimationFrame||function(s){return i.setTimeout(s,20)},I=i.cancelAnimationFrame||i.mozCancelAnimationFrame||i.webkitCancelAnimationFrame||function(s){i.clearTimeout(s)};function r(s,l){var c=Object.prototype.toString.call(s),u=c==="[object Array]"||c==="[object NodeList]"||c==="[object HTMLCollection]"||c==="[object Object]"||typeof jQuery<"u"&&s instanceof jQuery||typeof Elements<"u"&&s instanceof Elements,d=0,h=s.length;if(u)for(;d=T&&(X+=R.value),R.mode==="max"&&W<=T&&(X+=R.value),V[N]||(V[N]=""),X&&(" "+V[N]+" ").indexOf(" "+X+" ")===-1&&(V[N]+=" "+X));for(var x in Y)Y.hasOwnProperty(x)&&(V[Y[x]]?this.element.setAttribute(Y[x],V[Y[x]].substr(1)):this.element.removeAttribute(Y[x]))}}function c(G,B){G.elementQueriesSetupInformation||(G.elementQueriesSetupInformation=new l(G,B)),G.elementQueriesSensor||(G.elementQueriesSensor=new i(G,function(){G.elementQueriesSetupInformation.call()}))}function u(G,B,S,R){if(typeof o[G]>"u"){o[G]=[];var w=C.length;r.innerHTML+=` +`+G+" {animation: 0.1s element-queries;}",r.innerHTML+=` +`+G+" > .resize-sensor {min-width: "+w+"px;}",C.push(G)}o[G].push({mode:B,property:S,value:R})}function d(G){var B;if(document.querySelectorAll&&(B=G?G.querySelectorAll.bind(G):document.querySelectorAll.bind(document)),!B&&typeof $$<"u"&&(B=$$),!B&&typeof jQuery<"u"&&(B=jQuery),!B)throw"No document.querySelectorAll, jQuery or Mootools's $$ found.";return B}function h(G){var B=d(G);for(var S in o)if(o.hasOwnProperty(S))for(var R=B(S,G),w=0,T=R.length;wS[F].minWidth&&(M=F);if(M||(M=w),T!==M)if(W[M])B[T].style.display="none",B[M].style.display="block",T=M;else{var $=new Image;$.onload=function(){B[M].src=R[M],B[T].style.display="none",B[M].style.display="block",W[M]=!0,T=M},$.src=R[M]}else B[M].src=R[M]}G.resizeSensorInstance=new i(G,x),x()}function m(){for(var G=d(),B=G("[data-responsive-image],[responsive-image]"),S=0,R=B.length;S img, [data-responsive-image] {overflow: hidden; padding: 0; } [responsive-image] > img, [data-responsive-image] > img {width: 100%;}",r.innerHTML+=` +@keyframes element-queries { 0% { visibility: inherit; } }`,document.getElementsByTagName("head")[0].appendChild(r),v=!0);for(var B=0,S=document.styleSheets.length;B\s{0,}<").replace(/-1?(o+=a[r]+i[C],I=!0,(i[C].search(/-->/)>-1||i[C].search(/\]>/)>-1||i[C].search(/!DOCTYPE/)>-1)&&(I=!1)):i[C].search(/-->/)>-1||i[C].search(/\]>/)>-1?(o+=i[C],I=!1):/^<\w/.exec(i[C-1])&&/^<\/\w/.exec(i[C])&&/^<[\w:\-\.\,]+/.exec(i[C-1])==/^<\/[\w:\-\.\,]+/.exec(i[C])[0].replace("/","")?(o+=i[C],I||r--):i[C].search(/<\w/)>-1&&i[C].search(/<\//)==-1&&i[C].search(/\/>/)==-1?o=I?o+=i[C]:o+=a[r++]+i[C]:i[C].search(/<\w/)>-1&&i[C].search(/<\//)>-1?o=I?o+=i[C]:o+=a[r]+i[C]:i[C].search(/<\//)>-1?o=I?o+=i[C]:o+=a[--r]+i[C]:i[C].search(/\/>/)>-1?o=I?o+=i[C]:o+=a[r]+i[C]:i[C].search(/<\?/)>-1||i[C].search(/xmlns\:/)>-1||i[C].search(/xmlns\=/)>-1?o+=a[r]+i[C]:o+=i[C];return o[0]==` +`?o.slice(1):o};$d.prototype.json=function(e,i){var i=i||this.step;return typeof JSON>"u"?e:typeof e=="string"?JSON.stringify(JSON.parse(e),null,i):typeof e=="object"?JSON.stringify(e,null,i):e};$d.prototype.css=function(e,g){var i=e.replace(/\s{1,}/g," ").replace(/\{/g,"{~::~").replace(/\}/g,"~::~}~::~").replace(/\;/g,";~::~").replace(/\/\*/g,"~::~/*").replace(/\*\//g,"*/~::~").replace(/~::~\s{0,}~::~/g,"~::~").split("~::~"),n=i.length,I=0,r="",o=0,C=g?IP(g):this.shift;for(o=0;o/g,"").replace(/[ \r\n\t]{1,}xmlns/g," xmlns");return i.replace(/>\s{0,}<")};$d.prototype.jsonmin=function(e){return typeof JSON>"u"?e:JSON.stringify(JSON.parse(e),null,0)};$d.prototype.cssmin=function(e,g){var i=g?e:e.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\//g,"");return i.replace(/\s{1,}/g," ").replace(/\{\s{1,}/g,"{").replace(/\}\s{1,}/g,"}").replace(/\;\s{1,}/g,";").replace(/\/\*\s{1,}/g,"/*").replace(/\*\/\s{1,}/g,"*/")};$d.prototype.sqlmin=function(e){return e.replace(/\s{1,}/g," ").replace(/\s{1,}\(/,"(").replace(/\s{1,}\)/,")")};var u5t=new $d;const d5t=EC(u5t);var h5t=function(g,i){if(i=i.split(":")[0],g=+g,!g)return!1;switch(i){case"http":case"ws":return g!==80;case"https":case"wss":return g!==443;case"ftp":return g!==21;case"gopher":return g!==70;case"file":return!1}return g!==0},dae={},f5t=Object.prototype.hasOwnProperty,m5t;function Dve(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return null}}function Mve(e){try{return encodeURIComponent(e)}catch{return null}}function p5t(e){for(var g=/([^=?#&]+)=?([^&]*)/g,i={},n;n=g.exec(e);){var I=Dve(n[1]),r=Dve(n[2]);I===null||r===null||I in i||(i[I]=r)}return i}function b5t(e,g){g=g||"";var i=[],n,I;typeof g!="string"&&(g="?");for(I in e)if(f5t.call(e,I)){if(n=e[I],!n&&(n===null||n===m5t||isNaN(n))&&(n=""),I=Mve(I),n=Mve(n),I===null||n===null)continue;i.push(I+"="+n)}return i.length?g+i.join("&"):""}dae.stringify=b5t;dae.parse=p5t;var ePe=h5t,rP=dae,y5t=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,tPe=/[\n\r\t]/g,Z5t=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,gPe=/:\d+$/,G5t=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,v5t=/^[a-zA-Z]:/;function hae(e){return(e||"").toString().replace(y5t,"")}var Cq=[["#","hash"],["?","query"],function(g,i){return lc(i.protocol)?g.replace(/\\/g,"/"):g},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],zve={hash:1,query:1};function iPe(e){var g;typeof window<"u"?g=window:typeof globalThis<"u"?g=globalThis:typeof self<"u"?g=self:g={};var i=g.location||{};e=e||i;var n={},I=typeof e,r;if(e.protocol==="blob:")n=new Vc(unescape(e.pathname),{});else if(I==="string"){n=new Vc(e,{});for(r in zve)delete n[r]}else if(I==="object"){for(r in e)r in zve||(n[r]=e[r]);n.slashes===void 0&&(n.slashes=Z5t.test(e.href))}return n}function lc(e){return e==="file:"||e==="ftp:"||e==="http:"||e==="https:"||e==="ws:"||e==="wss:"}function nPe(e,g){e=hae(e),e=e.replace(tPe,""),g=g||{};var i=G5t.exec(e),n=i[1]?i[1].toLowerCase():"",I=!!i[2],r=!!i[3],o=0,C;return I?r?(C=i[2]+i[3]+i[4],o=i[2].length+i[3].length):(C=i[2]+i[4],o=i[2].length):r?(C=i[3]+i[4],o=i[3].length):C=i[4],n==="file:"?o>=2&&(C=C.slice(2)):lc(n)?C=i[4]:n?I&&(C=C.slice(2)):o>=2&&lc(g.protocol)&&(C=i[4]),{protocol:n,slashes:I||lc(n),slashesCount:o,rest:C}}function B5t(e,g){if(e==="")return g;for(var i=(g||"/").split("/").slice(0,-1).concat(e.split("/")),n=i.length,I=i[n-1],r=!1,o=0;n--;)i[n]==="."?i.splice(n,1):i[n]===".."?(i.splice(n,1),o++):o&&(n===0&&(r=!0),i.splice(n,1),o--);return r&&i.unshift(""),(I==="."||I==="..")&&i.push(""),i.join("/")}function Vc(e,g,i){if(e=hae(e),e=e.replace(tPe,""),!(this instanceof Vc))return new Vc(e,g,i);var n,I,r,o,C,a,A=Cq.slice(),s=typeof g,l=this,c=0;for(s!=="object"&&s!=="string"&&(i=g,g=null),i&&typeof i!="function"&&(i=rP.parse),g=iPe(g),I=nPe(e||"",g),n=!I.protocol&&!I.slashes,l.slashes=I.slashes||n&&g.slashes,l.protocol=I.protocol||g.protocol||"",e=I.rest,(I.protocol==="file:"&&(I.slashesCount!==2||v5t.test(e))||!I.slashes&&(I.protocol||I.slashesCount<2||!lc(l.protocol)))&&(A[3]=[/(.*)/,"pathname"]);c{try{return new window.BroadcastChannel("pub-sub-es")}catch{return{postMessage:()=>{}}}})(),fae=(e,g)=>g?e.toLowerCase():e,rPe=(e,{caseInsensitive:g}={})=>(i,n,I=1/0)=>{const r=fae(i,g);return e[r]||(e[r]=[],e.__times__[r]=[]),e[r].push(n),e.__times__[r].push(+I||1/0),{event:r,handler:n}},mae=(e,{caseInsensitive:g}={})=>(i,n)=>{typeof i=="object"&&(n=i.handler,i=i.event);const I=fae(i,g);if(!e[I])return;const r=e[I].indexOf(n);r===-1||r>=e[I].length||(e[I].splice(r,1),e.__times__[I].splice(r,1))},Pve=(e,g)=>()=>{e.forEach(i=>i(g))},oPe=(e,{isGlobal:g,caseInsensitive:i,async:n}={})=>{const I=mae(e);return(r,o,C={})=>{const a=fae(r,i);if(!e[a])return;const A=[...e[a]];if(A.forEach((s,l)=>{--e.__times__[a][l]<1&&I(a,s)}),n||C.async?setTimeout(Pve(A,o),0):Pve(A,o)(),g&&!C.isNoGlobalBroadcast)try{IPe.postMessage({event:a,news:o})}catch(s){if(s instanceof DOMException)console.warn(`Could not broadcast '${a}' globally. Payload is not clonable.`);else throw s}}},CPe=e=>()=>{Object.keys(e).filter(g=>g[0]!=="_").forEach(g=>{e[g]=void 0,e.__times__[g]=void 0,delete e[g],delete e.__times__[g]})},aPe=()=>({__times__:{}}),oP=(e={})=>{const g=e.async||!1,i=e.caseInsensitive||!1,n=e.stack||aPe();return n.__times__||(n.__times__={}),{publish:oPe(n,{async:g,caseInsensitive:i}),subscribe:rPe(n,{caseInsensitive:i}),unsubscribe:mae(n,{caseInsensitive:i}),clear:CPe(n),stack:n}},uR=aPe(),M2={publish:oPe(uR,{isGlobal:!0}),subscribe:rPe(uR),unsubscribe:mae(uR),clear:CPe(uR),stack:uR};IPe.onmessage=({data:{event:e,news:g}})=>M2.publish(e,g,{isNoGlobalBroadcast:!0});const ug={"context-menu":"_context-menu_18ock_1","context-menu-dark":"_context-menu-dark_18ock_12","context-menu-icon":"_context-menu-icon_18ock_17","context-menu-item":"_context-menu-item_18ock_27","context-menu-hr":"_context-menu-hr_18ock_38","play-icon":"_play-icon_18ock_45","context-menu-span":"_context-menu-span_18ock_52","context-menu-thumbnail":"_context-menu-thumbnail_18ock_60","context-menu-thumbnail-inline":"_context-menu-thumbnail-inline_18ock_65"};function yg(e){return k.createElement("div",{"data-menu-item-for":typeof e.children=="string"?e.children:null,className:ug["context-menu-item"],onClick:g=>e.onClick(g),onMouseEnter:g=>e.onMouseEnter(g),onMouseLeave:g=>e.onMouseLeave(g),role:"button",tabIndex:0},k.createElement("span",{className:ug["context-menu-span"]},e.children))}yg.defaultProps={onMouseEnter:()=>{},onMouseLeave:()=>{}};yg.propTypes={children:L.node.isRequired,onClick:L.func.isRequired,onMouseEnter:L.func,onMouseLeave:L.func};var W5t={value:()=>{}};function H1(){for(var e=0,g=arguments.length,i={},n;e=0&&(n=i.slice(I+1),i=i.slice(0,I)),i&&!g.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:n}})}MK.prototype=H1.prototype={constructor:MK,on:function(e,g){var i=this._,n=X5t(e+"",i),I,r=-1,o=n.length;if(arguments.length<2){for(;++r0)for(var i=new Array(I),n=0,I,r;n()=>e;function aq(e,{sourceEvent:g,subject:i,target:n,identifier:I,active:r,x:o,y:C,dx:a,dy:A,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:g,enumerable:!0,configurable:!0},subject:{value:i,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},identifier:{value:I,enumerable:!0,configurable:!0},active:{value:r,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:C,enumerable:!0,configurable:!0},dx:{value:a,enumerable:!0,configurable:!0},dy:{value:A,enumerable:!0,configurable:!0},_:{value:s}})}aq.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function H5t(e){return!e.ctrlKey&&!e.button}function N5t(){return this.parentNode}function k5t(e,g){return g??{x:e.x,y:e.y}}function Y5t(){return navigator.maxTouchPoints||"ontouchstart"in this}function Su(){var e=H5t,g=N5t,i=k5t,n=Y5t,I={},r=H1("start","drag","end"),o=0,C,a,A,s,l=0;function c(y){y.on("mousedown.drag",u).filter(n).on("touchstart.drag",f).on("touchmove.drag",m).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function u(y,Z){if(!(s||!e.call(this,y,Z))){var v=p(this,g.call(this,y,Z),y,Z,"mouse");v&&(xg(y.view).on("mousemove.drag",d,!0).on("mouseup.drag",h,!0),CP(y.view),QU(y),A=!1,C=y.clientX,a=y.clientY,v("start",y))}}function d(y){if(Pv(y),!A){var Z=y.clientX-C,v=y.clientY-a;A=Z*Z+v*v>l}I.mouse("drag",y)}function h(y){xg(y.view).on("mousemove.drag mouseup.drag",null),aP(y.view,A),Pv(y),I.mouse("end",y)}function f(y,Z){if(e.call(this,y,Z)){var v=y.changedTouches,G=g.call(this,y,Z),B=v.length,S,R;for(S=0;S=0&&e._call.call(null,g),e=e._next;--$B}function Ove(){Hb=(WF=MX.now())+sP,$B=ZV=0;try{F5t()}finally{$B=0,D5t(),Hb=0}}function E5t(){var e=MX.now(),g=e-WF;g>sPe&&(sP-=g,WF=e)}function D5t(){for(var e,g=VF,i,n=1/0;g;)g._call?(n>g._time&&(n=g._time),e=g,g=g._next):(i=g._next,g._next=null,g=e?e._next=i:VF=i);GV=e,sq(n)}function sq(e){if(!$B){ZV&&(ZV=clearTimeout(ZV));var g=e-Hb;g>24?(e<1/0&&(ZV=setTimeout(Ove,e-MX.now()-sP)),dR&&(dR=clearInterval(dR))):(dR||(WF=MX.now(),dR=setInterval(E5t,sPe)),$B=1,APe(Ove))}}function Jve(e,g,i){var n=new XF;return g=g==null?0:+g,n.restart(I=>{n.stop(),e(I+g)},g,i),n}var M5t=H1("start","end","cancel","interrupt"),z5t=[],cPe=0,Lve=1,Aq=2,zK=3,Uve=4,lq=5,PK=6;function AP(e,g,i,n,I,r){var o=e.__transition;if(!o)e.__transition={};else if(i in o)return;P5t(e,i,{name:g,index:n,group:I,on:M5t,tween:z5t,time:r.time,delay:r.delay,duration:r.duration,ease:r.ease,timer:null,state:cPe})}function bae(e,g){var i=el(e,g);if(i.state>cPe)throw new Error("too late; already scheduled");return i}function Uc(e,g){var i=el(e,g);if(i.state>zK)throw new Error("too late; already running");return i}function el(e,g){var i=e.__transition;if(!i||!(i=i[g]))throw new Error("transition not found");return i}function P5t(e,g,i){var n=e.__transition,I;n[g]=i,i.timer=lPe(r,0,i.time);function r(A){i.state=Lve,i.timer.restart(o,i.delay,i.time),i.delay<=A&&o(A-i.delay)}function o(A){var s,l,c,u;if(i.state!==Lve)return a();for(s in n)if(u=n[s],u.name===i.name){if(u.state===zK)return Jve(o);u.state===Uve?(u.state=PK,u.timer.stop(),u.on.call("interrupt",e,e.__data__,u.index,u.group),delete n[s]):+sAq&&n.state=0&&(g=g.slice(0,i)),!g||g==="start"})}function bxt(e,g,i){var n,I,r=pxt(g)?bae:Uc;return function(){var o=r(this,e),C=o.on;C!==n&&(I=(n=C).copy()).on(g,i),o.on=I}}function yxt(e,g){var i=this._id;return arguments.length<2?el(this.node(),i).on.on(e):this.each(bxt(i,e,g))}function Zxt(e){return function(){var g=this.parentNode;for(var i in this.__transition)if(+i!==e)return;g&&g.removeChild(this)}}function Gxt(){return this.on("end.remove",Zxt(this._id))}function vxt(e){var g=this._name,i=this._id;typeof e!="function"&&(e=ZT(e));for(var n=this._groups,I=n.length,r=new Array(I),o=0;o()=>e;function Uxt(e,{sourceEvent:g,target:i,selection:n,mode:I,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:g,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},selection:{value:n,enumerable:!0,configurable:!0},mode:{value:I,enumerable:!0,configurable:!0},_:{value:r}})}function Qxt(e){e.stopImmediatePropagation()}function $U(e){e.preventDefault(),e.stopImmediatePropagation()}var Qve={name:"drag"},qU={name:"space"},PZ={name:"handle"},_Z={name:"center"};const{abs:jve,max:Nr,min:kr}=Math;function $ve(e){return[+e[0],+e[1]]}function uq(e){return[$ve(e[0]),$ve(e[1])]}var _K={name:"x",handles:["w","e"].map(zX),input:function(e,g){return e==null?null:[[+e[0],g[0][1]],[+e[1],g[1][1]]]},output:function(e){return e&&[e[0][0],e[1][0]]}},OK={name:"y",handles:["n","s"].map(zX),input:function(e,g){return e==null?null:[[g[0][0],+e[0]],[g[1][0],+e[1]]]},output:function(e){return e&&[e[0][1],e[1][1]]}},jxt={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(zX),input:function(e){return e==null?null:uq(e)},output:function(e){return e}},hu={overlay:"crosshair",selection:"move",n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},qve={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},eBe={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},$xt={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},qxt={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function zX(e){return{type:e}}function eFt(e){return!e.ctrlKey&&!e.button}function tFt(){var e=this.ownerSVGElement||this;return e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]}function gFt(){return navigator.maxTouchPoints||"ontouchstart"in this}function e7(e){for(;!e.__brush;)if(!(e=e.parentNode))return;return e.__brush}function iFt(e){return e[0][0]===e[1][0]||e[0][1]===e[1][1]}function nFt(e){var g=e.__brush;return g?g.dim.output(g.selection):null}function lP(){return Gae(_K)}function TT(){return Gae(OK)}function Zae(){return Gae(jxt)}function Gae(e){var g=tFt,i=eFt,n=gFt,I=!0,r=H1("start","brush","end"),o=6,C;function a(f){var m=f.property("__brush",h).selectAll(".overlay").data([zX("overlay")]);m.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",hu.overlay).merge(m).each(function(){var p=e7(this).extent;xg(this).attr("x",p[0][0]).attr("y",p[0][1]).attr("width",p[1][0]-p[0][0]).attr("height",p[1][1]-p[0][1])}),f.selectAll(".selection").data([zX("selection")]).enter().append("rect").attr("class","selection").attr("cursor",hu.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var b=f.selectAll(".handle").data(e.handles,function(p){return p.type});b.exit().remove(),b.enter().append("rect").attr("class",function(p){return"handle handle--"+p.type}).attr("cursor",function(p){return hu[p.type]}),f.each(A).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",c).filter(n).on("touchstart.brush",c).on("touchmove.brush",u).on("touchend.brush touchcancel.brush",d).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}a.move=function(f,m){f.tween?f.on("start.brush",function(b){s(this,arguments).beforestart().start(b)}).on("interrupt.brush end.brush",function(b){s(this,arguments).end(b)}).tween("brush",function(){var b=this,p=b.__brush,y=s(b,arguments),Z=p.selection,v=e.input(typeof m=="function"?m.apply(this,arguments):m,p.extent),G=Py(Z,v);function B(S){p.selection=S===1&&v===null?null:G(S),A.call(b),y.brush()}return Z!==null&&v!==null?B:B(1)}):f.each(function(){var b=this,p=arguments,y=b.__brush,Z=e.input(typeof m=="function"?m.apply(b,p):m,y.extent),v=s(b,p).beforestart();cq(b),y.selection=Z===null?null:Z,A.call(b),v.start().brush().end()})},a.clear=function(f){a.move(f,null)};function A(){var f=xg(this),m=e7(this).selection;m?(f.selectAll(".selection").style("display",null).attr("x",m[0][0]).attr("y",m[0][1]).attr("width",m[1][0]-m[0][0]).attr("height",m[1][1]-m[0][1]),f.selectAll(".handle").style("display",null).attr("x",function(b){return b.type[b.type.length-1]==="e"?m[1][0]-o/2:m[0][0]-o/2}).attr("y",function(b){return b.type[0]==="s"?m[1][1]-o/2:m[0][1]-o/2}).attr("width",function(b){return b.type==="n"||b.type==="s"?m[1][0]-m[0][0]+o:o}).attr("height",function(b){return b.type==="e"||b.type==="w"?m[1][1]-m[0][1]+o:o})):f.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function s(f,m,b){var p=f.__brush.emitter;return p&&(!b||!p.clean)?p:new l(f,m,b)}function l(f,m,b){this.that=f,this.args=m,this.state=f.__brush,this.active=0,this.clean=b}l.prototype={beforestart:function(){return++this.active===1&&(this.state.emitter=this,this.starting=!0),this},start:function(f,m){return this.starting?(this.starting=!1,this.emit("start",f,m)):this.emit("brush",f),this},brush:function(f,m){return this.emit("brush",f,m),this},end:function(f,m){return--this.active===0&&(delete this.state.emitter,this.emit("end",f,m)),this},emit:function(f,m,b){var p=xg(this.that).datum();r.call(f,this.that,new Uxt(f,{sourceEvent:m,target:a,selection:e.output(this.state.selection),mode:b,dispatch:r}),p)}};function c(f){if(C&&!f.touches||!i.apply(this,arguments))return;var m=this,b=f.target.__data__.type,p=(I&&f.metaKey?b="overlay":b)==="selection"?Qve:I&&f.altKey?_Z:PZ,y=e===OK?null:$xt[b],Z=e===_K?null:qxt[b],v=e7(m),G=v.extent,B=v.selection,S=G[0][0],R,w,T=G[0][1],W,V,X=G[1][0],N,Y,x=G[1][1],M,F,$=0,Q=0,U,j=y&&Z&&I&&f.shiftKey,ee,Ie,fe=Array.from(f.touches||[f],ke=>{const _e=ke.identifier;return ke=mi(ke,m),ke.point0=ke.slice(),ke.identifier=_e,ke});if(b==="overlay"){B&&(U=!0);const ke=[fe[0],fe[1]||fe[0]];v.selection=B=[[R=e===OK?S:kr(ke[0][0],ke[1][0]),W=e===_K?T:kr(ke[0][1],ke[1][1])],[N=e===OK?X:Nr(ke[0][0],ke[1][0]),M=e===_K?x:Nr(ke[0][1],ke[1][1])]],fe.length>1&&ye()}else R=B[0][0],W=B[0][1],N=B[1][0],M=B[1][1];w=R,V=W,Y=N,F=M;var Ve=xg(m).attr("pointer-events","none"),oe=Ve.selectAll(".overlay").attr("cursor",hu[b]);cq(m);var pe=s(m,arguments,!0).beforestart();if(f.touches)pe.moved=ie,pe.ended=ue;else{var ae=xg(f.view).on("mousemove.brush",ie,!0).on("mouseup.brush",ue,!0);I&&ae.on("keydown.brush",Ye,!0).on("keyup.brush",Be,!0),CP(f.view)}A.call(m),pe.start(f,p.name);function ie(ke){for(const _e of ke.changedTouches||[ke])for(const Pe of fe)Pe.identifier===_e.identifier&&(Pe.cur=mi(_e,m));if(j&&!ee&&!Ie&&fe.length===1){const _e=fe[0];jve(_e.cur[0]-_e[0])>jve(_e.cur[1]-_e[1])?Ie=!0:ee=!0}for(const _e of fe)_e.cur&&(_e[0]=_e.cur[0],_e[1]=_e.cur[1]);U=!0,$U(ke),ye(ke)}function ye(ke){const _e=fe[0],Pe=_e.point0;var it;switch($=_e[0]-Pe[0],Q=_e[1]-Pe[1],p){case qU:case Qve:{y&&($=Nr(S-R,kr(X-N,$)),w=R+$,Y=N+$),Z&&(Q=Nr(T-W,kr(x-M,Q)),V=W+Q,F=M+Q);break}case PZ:{fe[1]?(y&&(w=Nr(S,kr(X,fe[0][0])),Y=Nr(S,kr(X,fe[1][0])),y=1),Z&&(V=Nr(T,kr(x,fe[0][1])),F=Nr(T,kr(x,fe[1][1])),Z=1)):(y<0?($=Nr(S-R,kr(X-R,$)),w=R+$,Y=N):y>0&&($=Nr(S-N,kr(X-N,$)),w=R,Y=N+$),Z<0?(Q=Nr(T-W,kr(x-W,Q)),V=W+Q,F=M):Z>0&&(Q=Nr(T-M,kr(x-M,Q)),V=W,F=M+Q));break}case _Z:{y&&(w=Nr(S,kr(X,R-$*y)),Y=Nr(S,kr(X,N+$*y))),Z&&(V=Nr(T,kr(x,W-Q*Z)),F=Nr(T,kr(x,M+Q*Z)));break}}Y0&&(R=w-$),Z<0?M=F-Q:Z>0&&(W=V-Q),p=qU,oe.attr("cursor",hu.selection),ye());break}default:return}$U(ke)}function Be(ke){switch(ke.keyCode){case 16:{j&&(ee=Ie=j=!1,ye());break}case 18:{p===_Z&&(y<0?N=Y:y>0&&(R=w),Z<0?M=F:Z>0&&(W=V),p=PZ,ye());break}case 32:{p===qU&&(ke.altKey?(y&&(N=Y-$*y,R=w+$*y),Z&&(M=F-Q*Z,W=V+Q*Z),p=_Z):(y<0?N=Y:y>0&&(R=w),Z<0?M=F:Z>0&&(W=V),p=PZ),oe.attr("cursor",hu[b]),ye());break}default:return}$U(ke)}}function u(f){s(this,arguments).moved(f)}function d(f){s(this,arguments).ended(f)}function h(){var f=this.__brush||{selection:null};return f.extent=uq(g.apply(this,arguments)),f.dim=e,f}return a.extent=function(f){return arguments.length?(g=typeof f=="function"?f:jU(uq(f)),a):g},a.filter=function(f){return arguments.length?(i=typeof f=="function"?f:jU(!!f),a):i},a.touchable=function(f){return arguments.length?(n=typeof f=="function"?f:jU(!!f),a):n},a.handleSize=function(f){return arguments.length?(o=+f,a):o},a.keyModifiers=function(f){return arguments.length?(I=!!f,a):I},a.on=function(){var f=r.on.apply(r,arguments);return f===r?a:f},a}const IFt=Object.freeze(Object.defineProperty({__proto__:null,brush:Zae,brushSelection:nFt,brushX:lP,brushY:TT},Symbol.toStringTag,{value:"Module"}));function PX(){return PX=Object.assign?Object.assign.bind():function(e){for(var g=1;ge.length)&&(g=e.length);for(var i=0,n=new Array(g);i0&&arguments[0]!==void 0?arguments[0]:this.active.collection;return this.refs[i].sort(fFt)}}]),e}();function fFt(e,g){var i=e.node.sortableInfo.index,n=g.node.sortableInfo.index;return i-n}function mFt(e,g,i){return e=e.slice(),e.splice(i<0?e.length+i:i,0,e.splice(g,1)[0]),e}function bPe(e,g){return Object.keys(e).reduce(function(i,n){return g.indexOf(n)===-1&&(i[n]=e[n]),i},{})}var OZ={end:["touchend","touchcancel","mouseup"],move:["touchmove","mousemove"],start:["touchstart","mousedown"]},yPe=function(){if(typeof window>"u"||typeof document>"u")return"";var e=window.getComputedStyle(document.documentElement,"")||["-moz-hidden-iframe"],g=(Array.prototype.slice.call(e).join("").match(/-(moz|webkit|ms)-/)||e.OLink===""&&["","o"])[1];switch(g){case"ms":return"ms";default:return g&&g.length?g[0].toUpperCase()+g.substr(1):""}}();function Xk(e,g){Object.keys(g).forEach(function(i){e.style[i]=g[i]})}function Tk(e,g){e.style["".concat(yPe,"Transform")]=g==null?"":"translate3d(".concat(g.x,"px,").concat(g.y,"px,0)")}function g7(e,g){e.style["".concat(yPe,"TransitionDuration")]=g==null?"":"".concat(g,"ms")}function vV(e,g){for(;e;){if(g(e))return e;e=e.parentNode}return null}function gBe(e,g,i){return Math.max(e,Math.min(i,g))}function cv(e){return e.substr(-2)==="px"?parseFloat(e):0}function pFt(e){var g=window.getComputedStyle(e);return{bottom:cv(g.marginBottom),left:cv(g.marginLeft),right:cv(g.marginRight),top:cv(g.marginTop)}}function wae(e,g){var i=g.displayName||g.name;return i?"".concat(e,"(").concat(i,")"):e}function i7(e,g){var i=e.getBoundingClientRect();return{top:i.top+g.top,left:i.left+g.left}}function hR(e){return e.touches&&e.touches.length?{x:e.touches[0].pageX,y:e.touches[0].pageY}:e.changedTouches&&e.changedTouches.length?{x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY}:{x:e.pageX,y:e.pageY}}function bFt(e){return e.touches&&e.touches.length||e.changedTouches&&e.changedTouches.length}function JK(e,g){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{left:0,top:0};if(e){var n={left:i.left+e.offsetLeft,top:i.top+e.offsetTop};return e.parentNode===g?n:JK(e.parentNode,g,n)}}function yFt(e,g,i){return eg?e-1:e>i&&e0&&i[o].height>0){var C=r.getContext("2d");C.drawImage(i[o],0,0)}}),n}function fq(e){var g,i,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{withRef:!1};return i=g=function(I){Bae(r,I);function r(){return HT(this,r),vae(this,_X(r).apply(this,arguments))}return NT(r,[{key:"componentDidMount",value:function(){var C=fb.findDOMNode(this);C.sortableHandle=!0}},{key:"getWrappedInstance",value:function(){return Nb(n.withRef,"To access the wrapped instance, you need to pass in {withRef: true} as the second argument of the SortableHandle() call"),this.refs.wrappedInstance}},{key:"render",value:function(){var C=n.withRef?"wrappedInstance":null;return Ue.createElement(e,PX({ref:C},this.props))}}]),r}(Ue.Component),Bi(g,"displayName",wae("sortableHandle",e)),i}function nBe(e){return e.sortableHandle!=null}var wFt=function(){function e(g,i){HT(this,e),this.container=g,this.onScrollCallback=i}return NT(e,[{key:"clear",value:function(){this.interval!=null&&(clearInterval(this.interval),this.interval=null)}},{key:"update",value:function(i){var n=this,I=i.translate,r=i.minTranslate,o=i.maxTranslate,C=i.width,a=i.height,A={x:0,y:0},s={x:1,y:1},l={x:10,y:10},c=this.container,u=c.scrollTop,d=c.scrollLeft,h=c.scrollHeight,f=c.scrollWidth,m=c.clientHeight,b=c.clientWidth,p=u===0,y=h-u-m===0,Z=d===0,v=f-d-b===0;I.y>=o.y-a/2&&!y?(A.y=1,s.y=l.y*Math.abs((o.y-a/2-I.y)/a)):I.x>=o.x-C/2&&!v?(A.x=1,s.x=l.x*Math.abs((o.x-C/2-I.x)/C)):I.y<=r.y+a/2&&!p?(A.y=-1,s.y=l.y*Math.abs((I.y-a/2-r.y)/a)):I.x<=r.x+C/2&&!Z&&(A.x=-1,s.x=l.x*Math.abs((I.x-C/2-r.x)/C)),this.interval&&(this.clear(),this.isAutoScrolling=!1),(A.x!==0||A.y!==0)&&(this.interval=setInterval(function(){n.isAutoScrolling=!0;var G={left:s.x*A.x,top:s.y*A.y};n.container.scrollTop+=G.top,n.container.scrollLeft+=G.left,n.onScrollCallback(G)},5))}}]),e}();function SFt(e){var g=e.node;return{height:g.offsetHeight,width:g.offsetWidth}}function RFt(e){var g=[C0.Input,C0.Textarea,C0.Select,C0.Option,C0.Button];return!!(g.indexOf(e.target.tagName)!==-1||vV(e.target,function(i){return i.contentEditable==="true"}))}var GPe={axis:L.oneOf(["x","y","xy"]),contentWindow:L.any,disableAutoscroll:L.bool,distance:L.number,getContainer:L.func,getHelperDimensions:L.func,helperClass:L.string,helperContainer:L.oneOfType([L.func,typeof HTMLElement>"u"?L.any:L.instanceOf(HTMLElement)]),hideSortableGhost:L.bool,keyboardSortingTransitionDuration:L.number,lockAxis:L.string,lockOffset:L.oneOfType([L.number,L.string,L.arrayOf(L.oneOfType([L.number,L.string]))]),lockToContainerEdges:L.bool,onSortEnd:L.func,onSortMove:L.func,onSortOver:L.func,onSortStart:L.func,pressDelay:L.number,pressThreshold:L.number,keyCodes:L.shape({lift:L.arrayOf(L.number),drop:L.arrayOf(L.number),cancel:L.arrayOf(L.number),up:L.arrayOf(L.number),down:L.arrayOf(L.number)}),shouldCancelStart:L.func,transitionDuration:L.number,updateBeforeSortStart:L.func,useDragHandle:L.bool,useWindowAsScrollContainer:L.bool},vPe={lift:[Sp.SPACE],drop:[Sp.SPACE],cancel:[Sp.ESC],up:[Sp.UP,Sp.LEFT],down:[Sp.DOWN,Sp.RIGHT]},VFt={axis:"y",disableAutoscroll:!1,distance:0,getHelperDimensions:SFt,hideSortableGhost:!0,lockOffset:"50%",lockToContainerEdges:!1,pressDelay:0,pressThreshold:5,keyCodes:vPe,shouldCancelStart:RFt,transitionDuration:300,useWindowAsScrollContainer:!1},WFt=Object.keys(GPe);function XFt(e){Nb(!(e.distance&&e.pressDelay),"Attempted to set both `pressDelay` and `distance` on SortableContainer, you may only use one or the other, not both at the same time.")}function TFt(e,g){try{var i=e()}catch(n){return g(!0,n)}return i&&i.then?i.then(g.bind(null,!1),g.bind(null,!0)):g(!1,value)}function HFt(e){var g,i,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{withRef:!1};return i=g=function(I){Bae(r,I);function r(o){var C;return HT(this,r),C=vae(this,_X(r).call(this,o)),Bi(Mg(Mg(C)),"state",{}),Bi(Mg(Mg(C)),"handleStart",function(a){var A=C.props,s=A.distance,l=A.shouldCancelStart;if(!(a.button===2||l(a))){C.touched=!0,C.position=hR(a);var c=vV(a.target,function(b){return b.sortableInfo!=null});if(c&&c.sortableInfo&&C.nodeIsChild(c)&&!C.state.sorting){var u=C.props.useDragHandle,d=c.sortableInfo,h=d.index,f=d.collection,m=d.disabled;if(m||u&&!vV(a.target,nBe))return;C.manager.active={collection:f,index:h},!bFt(a)&&a.target.tagName===C0.Anchor&&a.preventDefault(),s||(C.props.pressDelay===0?C.handlePress(a):C.pressTimer=setTimeout(function(){return C.handlePress(a)},C.props.pressDelay))}}}),Bi(Mg(Mg(C)),"nodeIsChild",function(a){return a.sortableInfo.manager===C.manager}),Bi(Mg(Mg(C)),"handleMove",function(a){var A=C.props,s=A.distance,l=A.pressThreshold;if(!C.state.sorting&&C.touched&&!C._awaitingUpdateBeforeSortStart){var c=hR(a),u={x:C.position.x-c.x,y:C.position.y-c.y},d=Math.abs(u.x)+Math.abs(u.y);C.delta=u,!s&&(!l||d>=l)?(clearTimeout(C.cancelTimer),C.cancelTimer=setTimeout(C.cancel,0)):s&&d>=s&&C.manager.isActive()&&C.handlePress(a)}}),Bi(Mg(Mg(C)),"handleEnd",function(){C.touched=!1,C.cancel()}),Bi(Mg(Mg(C)),"cancel",function(){var a=C.props.distance,A=C.state.sorting;A||(a||clearTimeout(C.pressTimer),C.manager.active=null)}),Bi(Mg(Mg(C)),"handlePress",function(a){try{var A=C.manager.getActive(),s=function(){if(A){var l=function(){var S=y.sortableInfo.index,R=pFt(y),w=vFt(C.container),T=C.scrollContainer.getBoundingClientRect(),W=d({index:S,node:y,collection:Z});if(C.node=y,C.margin=R,C.gridGap=w,C.width=W.width,C.height=W.height,C.marginOffset={x:C.margin.left+C.margin.right+C.gridGap.x,y:Math.max(C.margin.top,C.margin.bottom,C.gridGap.y)},C.boundingClientRect=y.getBoundingClientRect(),C.containerBoundingRect=T,C.index=S,C.newIndex=S,C.axis={x:u.indexOf("x")>=0,y:u.indexOf("y")>=0},C.offsetEdge=JK(y,C.container),v?C.initialOffset=hR(t7({},a,{pageX:C.boundingClientRect.left,pageY:C.boundingClientRect.top})):C.initialOffset=hR(a),C.initialScroll={left:C.scrollContainer.scrollLeft,top:C.scrollContainer.scrollTop},C.initialWindowScroll={left:window.pageXOffset,top:window.pageYOffset},C.helper=C.helperContainer.appendChild(BFt(y)),Xk(C.helper,{boxSizing:"border-box",height:"".concat(C.height,"px"),left:"".concat(C.boundingClientRect.left-R.left,"px"),pointerEvents:"none",position:"fixed",top:"".concat(C.boundingClientRect.top-R.top,"px"),width:"".concat(C.width,"px")}),v&&C.helper.focus(),f&&(C.sortableGhost=y,Xk(y,{opacity:0,visibility:"hidden"})),C.minTranslate={},C.maxTranslate={},v){var V=p?{top:0,left:0,width:C.contentWindow.innerWidth,height:C.contentWindow.innerHeight}:C.containerBoundingRect,X=V.top,N=V.left,Y=V.width,x=V.height,M=X+x,F=N+Y;C.axis.x&&(C.minTranslate.x=N-C.boundingClientRect.left,C.maxTranslate.x=F-(C.boundingClientRect.left+C.width)),C.axis.y&&(C.minTranslate.y=X-C.boundingClientRect.top,C.maxTranslate.y=M-(C.boundingClientRect.top+C.height))}else C.axis.x&&(C.minTranslate.x=(p?0:T.left)-C.boundingClientRect.left-C.width/2,C.maxTranslate.x=(p?C.contentWindow.innerWidth:T.left+T.width)-C.boundingClientRect.left-C.width/2),C.axis.y&&(C.minTranslate.y=(p?0:T.top)-C.boundingClientRect.top-C.height/2,C.maxTranslate.y=(p?C.contentWindow.innerHeight:T.top+T.height)-C.boundingClientRect.top-C.height/2);h&&h.split(" ").forEach(function($){return C.helper.classList.add($)}),C.listenerNode=a.touches?y:C.contentWindow,v?(C.listenerNode.addEventListener("wheel",C.handleKeyEnd,!0),C.listenerNode.addEventListener("mousedown",C.handleKeyEnd,!0),C.listenerNode.addEventListener("keydown",C.handleKeyDown)):(OZ.move.forEach(function($){return C.listenerNode.addEventListener($,C.handleSortMove,!1)}),OZ.end.forEach(function($){return C.listenerNode.addEventListener($,C.handleSortEnd,!1)})),C.setState({sorting:!0,sortingIndex:S}),b&&b({node:y,index:S,collection:Z,isKeySorting:v,nodes:C.manager.getOrderedRefs(),helper:C.helper},a),v&&C.keyMove(0)},c=C.props,u=c.axis,d=c.getHelperDimensions,h=c.helperClass,f=c.hideSortableGhost,m=c.updateBeforeSortStart,b=c.onSortStart,p=c.useWindowAsScrollContainer,y=A.node,Z=A.collection,v=C.manager.isKeySorting,G=function(){if(typeof m=="function"){C._awaitingUpdateBeforeSortStart=!0;var B=TFt(function(){var S=y.sortableInfo.index;return Promise.resolve(m({collection:Z,index:S,node:y,isKeySorting:v},a)).then(function(){})},function(S,R){if(C._awaitingUpdateBeforeSortStart=!1,S)throw R;return R});if(B&&B.then)return B.then(function(){})}}();return G&&G.then?G.then(l):l(G)}}();return Promise.resolve(s&&s.then?s.then(function(){}):void 0)}catch(l){return Promise.reject(l)}}),Bi(Mg(Mg(C)),"handleSortMove",function(a){var A=C.props.onSortMove;typeof a.preventDefault=="function"&&a.preventDefault(),C.updateHelperPosition(a),C.animateNodes(),C.autoscroll(),A&&A(a)}),Bi(Mg(Mg(C)),"handleSortEnd",function(a){var A=C.props,s=A.hideSortableGhost,l=A.onSortEnd,c=C.manager,u=c.active.collection,d=c.isKeySorting,h=C.manager.getOrderedRefs();C.listenerNode&&(d?(C.listenerNode.removeEventListener("wheel",C.handleKeyEnd,!0),C.listenerNode.removeEventListener("mousedown",C.handleKeyEnd,!0),C.listenerNode.removeEventListener("keydown",C.handleKeyDown)):(OZ.move.forEach(function(y){return C.listenerNode.removeEventListener(y,C.handleSortMove)}),OZ.end.forEach(function(y){return C.listenerNode.removeEventListener(y,C.handleSortEnd)}))),C.helper.parentNode.removeChild(C.helper),s&&C.sortableGhost&&Xk(C.sortableGhost,{opacity:"",visibility:""});for(var f=0,m=h.length;fs)){C.prevIndex=c,C.newIndex=l;var u=yFt(C.newIndex,C.prevIndex,C.index),d=A.find(function(v){var G=v.node;return G.sortableInfo.index===u}),h=d.node,f=C.containerScrollDelta,m=d.boundingClientRect||i7(h,f),b=d.translate||{x:0,y:0},p={top:m.top+b.y-f.top,left:m.left+b.x-f.left},y=cv?v/2:this.height/2,width:this.width>Z?Z/2:this.width/2},B=h&&y>this.index&&y<=f,S=h&&y=f,R={x:0,y:0},w=u[m].edgeOffset;w||(w=JK(p,this.container),u[m].edgeOffset=w,h&&(u[m].boundingClientRect=i7(p,l)));var T=m0&&u[m-1];if(T&&!T.edgeOffset&&(T.edgeOffset=JK(T.node,this.container),h&&(T.boundingClientRect=i7(T.node,l))),y===this.index){A&&(this.sortableGhost=p,Xk(p,{opacity:0,visibility:"hidden"}));continue}a&&g7(p,a),this.axis.x?this.axis.y?S||ythis.containerBoundingRect.width-G.width&&T&&(R.x=T.edgeOffset.left-w.left,R.y=T.edgeOffset.top-w.top),this.newIndex===null&&(this.newIndex=y)):(B||y>this.index&&(d.left+c.left+G.width>=w.left&&d.top+c.top+G.height>=w.top||d.top+c.top+G.height>=w.top+v))&&(R.x=-(this.width+this.marginOffset.x),w.left+R.xthis.index&&d.left+c.left+G.width>=w.left?(R.x=-(this.width+this.marginOffset.x),this.newIndex=y):(S||ythis.index&&d.top+c.top+G.height>=w.top?(R.y=-(this.height+this.marginOffset.y),this.newIndex=y):(S||y1&&arguments[1]!==void 0?arguments[1]:{withRef:!1};return i=g=function(I){Bae(r,I);function r(){return HT(this,r),vae(this,_X(r).apply(this,arguments))}return NT(r,[{key:"componentDidMount",value:function(){this.register()}},{key:"componentDidUpdate",value:function(C){this.node&&(C.index!==this.props.index&&(this.node.sortableInfo.index=this.props.index),C.disabled!==this.props.disabled&&(this.node.sortableInfo.disabled=this.props.disabled)),C.collection!==this.props.collection&&(this.unregister(C.collection),this.register())}},{key:"componentWillUnmount",value:function(){this.unregister()}},{key:"register",value:function(){var C=this.props,a=C.collection,A=C.disabled,s=C.index,l=fb.findDOMNode(this);l.sortableInfo={collection:a,disabled:A,index:s,manager:this.context.manager},this.node=l,this.ref={node:l},this.context.manager.add(a,this.ref)}},{key:"unregister",value:function(){var C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props.collection;this.context.manager.remove(C,this.ref)}},{key:"getWrappedInstance",value:function(){return Nb(n.withRef,"To access the wrapped instance, you need to pass in {withRef: true} as the second argument of the SortableElement() call"),this.refs.wrappedInstance}},{key:"render",value:function(){var C=n.withRef?"wrappedInstance":null;return Ue.createElement(e,PX({ref:C},bPe(this.props,NFt)))}}]),r}(Ue.Component),Bi(g,"displayName",wae("sortableElement",e)),Bi(g,"contextTypes",{manager:L.object.isRequired}),Bi(g,"propTypes",BPe),Bi(g,"defaultProps",{collection:0}),i}const SPe=V1(e=>e.pos).left,mI=(e,g)=>{if(!g||!g.cumPositions||!g.cumPositions.length)return null;let i=SPe(g.cumPositions,e);const n=g.cumPositions[g.cumPositions.length-1].chr,I=g.chromLengths[n];i>0&&(i-=1);let r=Math.floor(e-g.cumPositions[i].pos),o=0;return r<0&&(o=r-1,r=1),i===g.cumPositions.length-1&&r>I&&(o=r-I,r=I),[g.cumPositions[i].chr,r,o,i]},RPe=(e,g)=>i=>i%e*g+Math.floor(i/e),kFt=e=>e,VPe=(e,g,i=kFt)=>e.map((n,I)=>n+g[i(I)]),YFt="http://www.w3.org/2000/svg",TF=(e,g)=>{if(e.namespaceURI===YFt){const i=e.getAttribute("class");return!!i&&!!i.match(new RegExp(`(\\s|^)${g}(\\s|$)`))}return e.classList?e.classList.contains(g):!!e.className.match(new RegExp(`(\\s|^)${g}(\\s|$)`))},KFt="http://www.w3.org/2000/svg",xFt=(e,g)=>{if(e.namespaceURI===KFt){if(!TF(e,g)){const i=e.getAttribute("class")||"";e.setAttribute("class",`${i} ${g}`)}}else e.classList?e.classList.add(g):TF(e,g)||(e.className+=` ${g}`)},FFt=(e,g,i)=>{const n=document.createElement("canvas");return new Promise((I,r)=>{const o=new window.Image;o.onload=()=>{n.width=g||o.width,n.height=i||o.height;const C=n.getContext("2d");if(!C){r(new Error("Could not get canvas context"));return}C.drawImage(o,0,0),I(n)},o.onerror=()=>{r(new Error("Could not convert base64 to canvas"))},o.src=`data:image/png;base64,${e}`})},HF=(e,g,i)=>i.chrPositions[e].pos+g,WPe=e=>{if(!(e instanceof Event))throw new Error("Event must be an instance of Event");const g=new e.constructor(e.type,e);return g.sourceUid=e.sourceUid,g.forwarded=e.forwarded,g},hm=(e,g=!1)=>{const i=e.map((o,C)=>C*(255/(e.length-1))),n=bg().domain(i).range(e),r=Xo(g?255:254,-1,-1).map(n).map(o=>{const C=OB(o);return[C.r,C.g,C.b,C.opacity*255]});return r.length<256&&r.push([255,255,255,0]),r},BV=0,wV=5,XPe=10,TPe=10,HPe=300,NF="move",Ja="select",mq=100,kF=10,NPe=110,SV=3e3,RV="locationListenerPrefix",kPe=1e3,pq="http://higlass.io/api/v1",YPe=400,KPe=300,bq=["top","left","right","bottom","center","whole","gallery"],xPe=20,FPe=20,YF=Symbol("Light theme"),ki=Symbol("Dark theme"),EFt=YF,st={PIXI:TEe},ka={"multitrack-header":"_multitrack-header_1yz7l_1","multitrack-header-focus":"_multitrack-header-focus_1yz7l_2","multitrack-header-squeazed":"_multitrack-header-squeazed_1yz7l_3","multitrack-header-dark":"_multitrack-header-dark_1yz7l_20","multitrack-header-id":"_multitrack-header-id_1yz7l_30","multitrack-header-left":"_multitrack-header-left_1yz7l_39","multitrack-header-grabber":"_multitrack-header-grabber_1yz7l_44","multitrack-header-grabber-squeazed":"_multitrack-header-grabber-squeazed_1yz7l_45","multitrack-header-search":"_multitrack-header-search_1yz7l_80","multitrack-header-nav-list":"_multitrack-header-nav-list_1yz7l_102","multitrack-header-icon":"_multitrack-header-icon_1yz7l_107","multitrack-header-icon-squeazed":"_multitrack-header-icon-squeazed_1yz7l_108","mouse-tool-selection":"_mouse-tool-selection_1yz7l_136"},DFt={id:"cog",paths:["M466.895 305.125c-26.863-46.527-10.708-106.152 36.076-133.244l-50.313-87.146c-14.375 8.427-31.088 13.259-48.923 13.259-53.768 0-97.354-43.873-97.354-97.995h-100.629c0.133 16.705-4.037 33.641-12.979 49.126-26.862 46.528-86.578 62.351-133.431 35.379l-50.312 87.146c14.485 8.236 27.025 20.294 35.943 35.739 26.819 46.454 10.756 105.96-35.854 133.112l50.313 87.146c14.325-8.348 30.958-13.127 48.7-13.127 53.598 0 97.072 43.596 97.35 97.479h100.627c-0.043-16.537 4.136-33.285 12.983-48.609 26.818-46.453 86.388-62.297 133.207-35.506l50.313-87.145c-14.39-8.233-26.846-20.249-35.717-35.614zM256 359.666c-57.254 0-103.668-46.412-103.668-103.667 0-57.254 46.413-103.667 103.668-103.667s103.666 46.413 103.666 103.667c-0.001 57.255-46.412 103.667-103.666 103.667z"],viewBox:"0 0 512 512"},MFt={id:"cross",paths:["M507.331 411.33c-0.002-0.002-0.004-0.004-0.006-0.005l-155.322-155.325 155.322-155.325c0.002-0.002 0.004-0.003 0.006-0.005 1.672-1.673 2.881-3.627 3.656-5.708 2.123-5.688 0.912-12.341-3.662-16.915l-73.373-73.373c-4.574-4.573-11.225-5.783-16.914-3.66-2.080 0.775-4.035 1.984-5.709 3.655 0 0.002-0.002 0.003-0.004 0.005l-155.324 155.326-155.324-155.325c-0.002-0.002-0.003-0.003-0.005-0.005-1.673-1.671-3.627-2.88-5.707-3.655-5.69-2.124-12.341-0.913-16.915 3.66l-73.374 73.374c-4.574 4.574-5.784 11.226-3.661 16.914 0.776 2.080 1.985 4.036 3.656 5.708 0.002 0.001 0.003 0.003 0.005 0.005l155.325 155.324-155.325 155.326c-0.001 0.002-0.003 0.003-0.004 0.005-1.671 1.673-2.88 3.627-3.657 5.707-2.124 5.688-0.913 12.341 3.661 16.915l73.374 73.373c4.575 4.574 11.226 5.784 16.915 3.661 2.080-0.776 4.035-1.985 5.708-3.656 0.001-0.002 0.003-0.003 0.005-0.005l155.324-155.325 155.324 155.325c0.002 0.001 0.004 0.003 0.006 0.004 1.674 1.672 3.627 2.881 5.707 3.657 5.689 2.123 12.342 0.913 16.914-3.661l73.373-73.374c4.574-4.574 5.785-11.227 3.662-16.915-0.776-2.080-1.985-4.034-3.657-5.707z"],viewBox:"0 0 512 512"},zFt={id:"enlarge",paths:["M512 0h-208l80 80-96 96 48 48 96-96 80 80z","M512 512v-208l-80 80-96-96-48 48 96 96-80 80z","M0 512h208l-80-80 96-96-48-48-96 96-80-80z","M0 0v208l80-80 96 96 48-48-96-96 80-80z"],viewBox:"0 0 512 512"},PFt={id:"minus",paths:["M0 208v96c0 8.836 7.164 16 16 16h480c8.836 0 16-7.164 16-16v-96c0-8.836-7.164-16-16-16h-480c-8.836 0-16 7.164-16 16z"],viewBox:"0 0 512 512"},_Ft={id:"move",paths:["M512,260.096L405.5,161.79v49.155H301.061v-104.45h49.149L251.904,0L160.77,106.495h49.15v104.45H106.495V161.79L0,260.096l106.495,91.135v-49.149h104.45v104.45H161.79L251.904,512l98.306-106.5h-49.149V301.061H405.5v49.149L512,260.096z"],viewBox:"0 0 512 512"},OFt={id:"play",paths:["M96 64l320 192-320 192z"],viewBox:"0 0 512 512"},JFt={id:"plus",paths:["M496 192h-176v-176c0-8.836-7.164-16-16-16h-96c-8.836 0-16 7.164-16 16v176h-176c-8.836 0-16 7.164-16 16v96c0 8.836 7.164 16 16 16h176v176c0 8.836 7.164 16 16 16h96c8.836 0 16-7.164 16-16v-176h176c8.836 0 16-7.164 16-16v-96c0-8.836-7.164-16-16-16z"],viewBox:"0 0 512 512"},LFt={id:"copy",paths:["M607.5 672v-448.5h-351v448.5h351zM607.5 160.5c34.5 0 64.5 28.5 64.5 63v448.5c0 34.5-30 64.5-64.5 64.5h-351c-34.5 0-64.5-30-64.5-64.5v-448.5c0-34.5 30-63 64.5-63h351zM511.5 31.5v64.5h-384v448.5h-63v-448.5c0-34.5 28.5-64.5 63-64.5h384z"],viewBox:"0 0 712 712"},UFt={id:"select",viewBox:"0 0 16 16",paths:["M2 14h2v1H1v-3h1v2zm8 1H6v-1h4v1zm5 0h-3v-1h2v-2h1v3zm0-5h-1V6h1v4zM2 10H1V6h1v4zm13-6h-1V2h-2V1h3v3zM4 2H2v2H1V1h3v1zm6 0H6V1h4.03L10 2z"]},QFt={id:"check_square_o",viewBox:"0 0 1792 1792",paths:["M1472 930v318q0 119-84.5 203.5t-203.5 84.5h-832q-119 0-203.5-84.5t-84.5-203.5v-832q0-119 84.5-203.5t203.5-84.5h832q63 0 117 25 15 7 18 23 3 17-9 29l-49 49q-10 10-23 10-3 0-9-2-23-6-45-6h-832q-66 0-113 47t-47 113v832q0 66 47 113t113 47h832q66 0 113-47t47-113v-254q0-13 9-22l64-64q10-10 23-10 6 0 12 3 20 8 20 29zm231-489l-814 814q-24 24-57 24t-57-24l-430-430q-24-24-24-57t24-57l110-110q24-24 57-24t57 24l263 263 647-647q24-24 57-24t57 24l110 110q24 24 24 57t-24 57z"]},jFt={id:"square_o",viewBox:"0 0 1792 1792",paths:["M1312 256h-832q-66 0-113 47t-47 113v832q0 66 47 113t113 47h832q66 0 113-47t47-113v-832q0-66-47-113t-113-47zm288 160v832q0 119-84.5 203.5t-203.5 84.5h-832q-119 0-203.5-84.5t-84.5-203.5v-832q0-119 84.5-203.5t203.5-84.5h832q119 0 203.5 84.5t84.5 203.5z"]},$Ft={id:"file_o",viewBox:"0 0 1792 1792",paths:["M1596 380q28 28 48 76t20 88v1152q0 40-28 68t-68 28h-1344q-40 0-68-28t-28-68v-1600q0-40 28-68t68-28h896q40 0 88 20t76 48zm-444-244v376h376q-10-29-22-41l-313-313q-12-12-41-22zm384 1528v-1024h-416q-40 0-68-28t-28-68v-416h-768v1536h1280z"]},qFt={id:"chevron_right",viewBox:"0 0 1792 1792",paths:["M1363 877l-742 742q-19 19-45 19t-45-19l-166-166q-19-19-19-45t19-45l531-531-531-531q-19-19-19-45t19-45l166-166q19-19 45-19t45 19l742 742q19 19 19 45t-19 45z"]},eEt={id:"chevron_down",viewBox:"0 0 1792 1792",paths:["M1683 808l-742 741q-19 19-45 19t-45-19l-742-741q-19-19-19-45.5t19-45.5l166-165q19-19 45-19t45 19l531 531 531-531q19-19 45-19t45 19l166 165q19 19 19 45.5t-19 45.5z"]},tEt={id:"folder_o",viewBox:"0 0 1792 1792",paths:["M1600 1312v-704q0-40-28-68t-68-28h-704q-40 0-68-28t-28-68v-64q0-40-28-68t-68-28h-320q-40 0-68 28t-28 68v960q0 40 28 68t68 28h1216q40 0 68-28t28-68zm128-704v704q0 92-66 158t-158 66h-1216q-92 0-158-66t-66-158v-960q0-92 66-158t158-66h320q92 0 158 66t66 158v32h672q92 0 158 66t66 158z"]},gEt={id:"folder_open_o",viewBox:"0 0 1792 1792",paths:["M1845 931q0-35-53-35h-1088q-40 0-85.5 21.5t-71.5 52.5l-294 363q-18 24-18 40 0 35 53 35h1088q40 0 86-22t71-53l294-363q18-22 18-39zm-1141-163h768v-160q0-40-28-68t-68-28h-576q-40 0-68-28t-28-68v-64q0-40-28-68t-68-28h-320q-40 0-68 28t-28 68v853l256-315q44-53 116-87.5t140-34.5zm1269 163q0 62-46 120l-295 363q-43 53-116 87.5t-140 34.5h-1088q-92 0-158-66t-66-158v-960q0-92 66-158t158-66h320q92 0 158 66t66 158v32h544q92 0 158 66t66 158v160h192q54 0 99 24.5t67 70.5q15 32 15 68z"]},iEt=[DFt,MFt,zFt,PFt,_Ft,OFt,JFt,LFt,UFt,QFt,jFt,$Ft,tEt,gEt,qFt,eEt],tl=new DOMParser,nEt='',Sae=tl.parseFromString(nEt,"text/xml").documentElement,IEt=` + + + + + + + + +`,rEt=tl.parseFromString(IEt,"text/xml").documentElement,oEt=` + + line + + + + + +`,CEt=tl.parseFromString(oEt,"text/xml").documentElement,aEt=` + + + 2d-tiles-icon + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + + +`,IBe=tl.parseFromString(aEt,"text/xml").documentElement,sEt=` + + + 2d-heatmap + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + +`,rBe=tl.parseFromString(sEt,"text/xml").documentElement,EPe=` + + + axis-1d + Created with Sketch. + + + + + +`,AEt=tl.parseFromString(EPe,"text/xml").documentElement,lEt=xg(tl.parseFromString(EPe,"text/xml").documentElement).style("transform","rotate(90deg)").node(),cEt=` + + + gene-annotations + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + +`,uEt=tl.parseFromString(cEt,"text/xml").documentElement,DPe=` + + + 1d-tiles-icon + Created with Sketch. + + + + + + + + + + + + + + + +`,dEt=tl.parseFromString(DPe,"text/xml").documentElement,hEt=xg(tl.parseFromString(DPe,"text/xml").documentElement).style("transform","rotate(90deg)").node(),fEt=` + + + arrowhead-domains + Created with Sketch. + + + + + + + + + + + + + + + +`,fR=tl.parseFromString(fEt,"text/xml").documentElement;function MPe({theStyle:e,onClick:g}){return k.createElement("svg",{className:ka[e],viewBox:"0 0 12 13",onClick:g,xmlns:"http://www.w3.org/2000/svg"},k.createElement("g",{fill:"none",stroke:"#6c6c6c",strokeWidth:"2"},k.createElement("path",{d:"M11.29 11.71l-4-4"}),k.createElement("circle",{cx:"5",cy:"5",r:"4"})))}MPe.propTypes={theStyle:L.string,onClick:L.func};const oBe={type:"osm-tiles",datatype:["map-tiles"],local:!0,orientation:"2d",hidden:!0,name:"OSM Tiles",thumbnail:Sae,availableOptions:["minPos","maxPos","maxZoom","labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","name"],defaultOptions:{minPos:-180,maxPos:180,maxZoom:19,labelPosition:"bottomRight",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0}},CBe={type:"mapbox-tiles",datatype:["map-tiles"],local:!0,orientation:"2d",hidden:!0,name:"Mapbox Tiles",thumbnail:Sae,availableOptions:["style","labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","name"],defaultOptions:{style:"mapbox.streets",labelPosition:"bottomRight",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0}},kb=[oBe,{...oBe,type:"osm"},CBe,{...CBe,type:"mapbox"},{type:"left-axis",datatype:["axis"],local:!0,orientation:"1d-vertical",name:"Left Axis",thumbnail:lEt,availableOptions:["minWidth"],defaultOptions:{minWidth:100}},{type:"top-axis",datatype:["axis"],local:!0,orientation:"1d-horizontal",name:"Top Axis",thumbnail:AEt,defaultOptions:{}},{type:"horizontal-rule",datatype:["x-coord"],local:!0,orientation:"whole",name:"Horizontal Rule",thumbnail:null,availableOptions:["color"],defaultOptions:{color:"black"}},{type:"vertical-rule",datatype:["y-coord"],local:!0,orientation:"whole",name:"Vertical Rule",thumbnail:null,availableOptions:["color"],defaultOptions:{color:"black"}},{type:"cross-rule",datatype:["xy-coord"],local:!0,orientation:"whole",name:"Cross Rule",thumbnail:null,availableOptions:["color"],defaultOptions:{color:"black"}},{type:"simple-svg",datatype:[],local:!1,orientation:"2d",exportable:!0,availableOptions:["minWidth","minHeight"],defaultOptions:{minWidth:100,minHeight:100}},{type:"heatmap",datatype:["matrix"],local:!1,orientation:"2d",thumbnail:rBe,exportable:!0,availableOptions:["backgroundColor","labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelShowResolution","labelShowAssembly","labelColor","labelTextOpacity","labelBackgroundOpacity","colorRange","colorbarBackgroundColor","maxZoom","minWidth","minHeight","dataTransform","colorbarPosition","trackBorderWidth","trackBorderColor","heatmapValueScaling","showMousePosition","mousePositionColor","showTooltip","extent","zeroValueColor"],defaultOptions:{backgroundColor:"#eeeeee",labelPosition:"bottomRight",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,labelShowResolution:!0,labelShowAssembly:!0,colorRange:["white","rgba(245,166,35,1.0)","rgba(208,2,27,1.0)","black"],colorbarBackgroundColor:"#ffffff",maxZoom:null,minWidth:100,minHeight:100,colorbarPosition:"topRight",trackBorderWidth:0,trackBorderColor:"black",heatmapValueScaling:"log",showMousePosition:!1,mousePositionColor:"#000000",showTooltip:!1,extent:"full",zeroValueColor:null},defaultOptionsByTheme:{[ki]:{backgroundColor:"#000000",colorRange:["black","rgba(208,2,27,1.0)","rgba(245,166,35,1.0)","white"],colorbarBackgroundColor:"#000000",labelColor:"#ffffff",labelBackgroundColor:"#000000",trackBorderColor:"#ffffff",mousePositionColor:"#ffffff"}}},{type:"linear-heatmap",aliases:["horizontal-heatmap","vertical-heatmap"],datatype:["matrix"],local:!1,orientation:"1d-horizontal",rotatable:!0,thumbnail:rBe,defaultOptions:{backgroundColor:"#eeeeee",labelPosition:"bottomRight",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,labelShowResolution:!0,labelShowAssembly:!0,labelColor:"black",colorRange:["white","rgba(245,166,35,1.0)","rgba(208,2,27,1.0)","black"],maxZoom:null,minWidth:100,minHeight:40,trackBorderWidth:0,trackBorderColor:"black"},availableOptions:["backgroundColor","labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelShowResolution","labelShowAssembly","labelColor","labelTextOpacity","labelBackgroundOpacity","colorRange","maxZoom","minWidth","minHeight","dataTransform","oneDHeatmapFlipped","colorbarPosition","trackBorderWidth","trackBorderColor","heatmapValueScaling"]},{type:"line",aliases:["horizontal-line","vertical-line"],datatype:["vector"],local:!1,orientation:"1d-horizontal",rotatable:!0,thumbnail:CEt,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelShowResolution","labelShowAssembly","labelColor","labelTextOpacity","labelBackgroundColor","labelBackgroundOpacity","axisLabelFormatting","axisPositionHorizontal","axisMargin","lineStrokeWidth","lineStrokeColor","valueScaling","valueScaleMin","valueScaleMax","trackBorderWidth","trackBorderColor","trackType","showMousePosition","showTooltip","mousePositionColor","aggregationMode","minHeight"],defaultOptions:{labelColor:"black",labelPosition:"topLeft",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,labelBackgroundColor:"white",labelShowResolution:!1,labelShowAssembly:!0,axisLabelFormatting:"scientific",axisPositionHorizontal:"right",lineStrokeColor:"blue",lineStrokeWidth:1,valueScaling:"linear",trackBorderWidth:0,trackBorderColor:"black",labelTextOpacity:.4,showMousePosition:!1,minHeight:20,mousePositionColor:"#000000",showTooltip:!1},defaultOptionsByTheme:{[ki]:{labelColor:"#ffffff",labelBackgroundColor:"#000000",trackBorderColor:"#ffffff",mousePositionColor:"#ffffff"}}},{type:"1d-heatmap",aliases:["horizontal-1d-heatmap","vertical-1d-heatmap"],datatype:["vector"],local:!1,orientation:"1d-horizontal",rotatable:!0,thumbnail:rEt,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelShowResolution","labelShowAssembly","labelColor","labelTextOpacity","labelBackgroundOpacity","axisPositionHorizontal","axisMargin","colorRange","valueScaling","trackBorderWidth","trackBorderColor","trackType","showMousePosition","showTooltip","mousePositionColor","aggregationMode"],defaultOptions:{labelColor:"black",labelPosition:"topLeft",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,labelShowResolution:!1,labelShowAssembly:!0,axisPositionHorizontal:"right",colorRange:["white","rgba(245,166,35,1.0)","rgba(208,2,27,1.0)","black"],valueScaling:"linear",trackBorderWidth:0,trackBorderColor:"black",labelTextOpacity:.4,showMousePosition:!1,mousePositionColor:"#000000",showTooltip:!1}},{type:"vector-heatmap",aliases:["horizontal-vector-heatmap","vertical-vector-heatmap"],datatype:["vector"],local:!1,orientation:"1d-horizontal",rotatable:!0,minHeight:1,thumbnail:null,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelShowResolution","labelShowAssembly","labelColor","valueScaling","labelTextOpacity","labelBackgroundOpacity","colorRange","trackBorderWidth","trackBorderColor","trackType","heatmapValueScaling"],defaultOptions:{labelPosition:"topLeft",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,labelShowResolution:!1,labelShowAssembly:!0,labelColor:"black",labelTextOpacity:.4,valueScaling:"linear",trackBorderWidth:0,trackBorderColor:"black",heatmapValueScaling:"log"}},{type:"multivec",aliases:["horizontal-multivec","vertical-multivec"],datatype:["multivec"],local:!1,orientation:"1d-horizontal",rotatable:!0,thumbnail:null,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelShowResolution","labelShowAssembly","labelColor","minHeight","valueScaling","labelTextOpacity","labelBackgroundOpacity","colorRange","trackBorderWidth","trackBorderColor","trackType","heatmapValueScaling","selectRows","selectRowsAggregationMode","selectRowsAggregationWithRelativeHeight","selectRowsAggregationMethod","colorbarBackgroundColor","colorbarPosition","zeroValueColor"],defaultOptions:{labelPosition:"topLeft",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,labelShowResolution:!0,labelShowAssembly:!0,labelColor:"black",labelTextOpacity:.4,minHeight:100,valueScaling:"linear",trackBorderWidth:0,trackBorderColor:"black",heatmapValueScaling:"log",selectRows:null,selectRowsAggregationMode:"mean",selectRowsAggregationWithRelativeHeight:!0,selectRowsAggregationMethod:"client",colorbarBackgroundColor:"#ffffff",colorbarPosition:"topRight",zeroValueColor:null},defaultOptionsByTheme:{[ki]:{colorbarBackgroundColor:"#000000"}}},{type:"point",aliases:["horizontal-point","vertical-point"],datatype:["vector"],local:!1,orientation:"1d-horizontal",rotatable:!0,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelShowResolution","labelShowAssembly","labelColor","labelTextOpacity","labelBackgroundOpacity","axisLabelFormatting","axisPositionHorizontal","axisMargin","pointColor","pointSize","valueScaling","trackBorderWidth","trackBorderColor"],defaultOptions:{labelColor:"black",labelPosition:"topLeft",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,labelShowResolution:!1,labelShowAssembly:!0,axisLabelFormatting:"scientific",axisPositionHorizontal:"right",pointColor:"red",pointSize:3,valueScaling:"linear",trackBorderWidth:0,trackBorderColor:"black",labelTextOpacity:.4}},{type:"divergent-bar",aliases:["horizontal-divergent-bar","vertical-divergent-bar"],datatype:["vector"],local:!1,orientation:"1d-horizontal",rotatable:!0,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelShowResolution","labelShowAssembly","labelColor","labelTextOpacity","labelBackgroundOpacity","axisLabelFormatting","axisPositionHorizontal","axisMargin","barFillColorTop","barFillColorBottom","valueScaling","trackBorderWidth","trackBorderColor","barOpacity"],defaultOptions:{labelColor:"black",labelPosition:"topLeft",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,labelShowResolution:!1,labelShowAssembly:!0,axisPositionHorizontal:"right",axisLabelFormatting:"scientific",barFillColorBottom:"red",barFillColorTop:"green",valueScaling:"linear",trackBorderWidth:0,trackBorderColor:"black",labelTextOpacity:.4,barOpacity:1}},{type:"bar",aliases:["horizontal-bar","vertical-bar"],datatype:["vector"],local:!1,orientation:"1d-horizontal",rotatable:!0,availableOptions:["align","labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelShowResolution","labelShowAssembly","labelColor","labelTextOpacity","labelBackgroundOpacity","axisLabelFormatting","axisPositionHorizontal","axisMargin","barFillColor","colorRange","colorRangeGradient","valueScaling","valueScaleMin","valueScaleMax","trackBorderWidth","trackBorderColor","barOpacity","showMousePosition","showTooltip","aggregationMode","zeroLineVisible","zeroLineColor","zeroLineOpacity"],defaultOptions:{align:"bottom",labelColor:"[glyph-color]",labelPosition:"topLeft",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,labelShowResolution:!1,labelShowAssembly:!0,axisLabelFormatting:"scientific",axisPositionHorizontal:"right",barFillColor:"darkgreen",valueScaling:"linear",trackBorderWidth:0,trackBorderColor:"black",labelTextOpacity:.4,barOpacity:1}},{type:"2d-tiles",datatype:["matrix"],local:!1,orientation:"2d",name:"2D Tile Outlines",thumbnail:IBe},{type:"1d-value-interval",aliases:["horizontal-1d-value-interval","vertical-1d-value-interval"],datatype:["bed-value"],local:!1,orientation:"1d-horizontal",rotatable:!0,name:"1D Rectangles",availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelColor","labelTextOpacity","labelBackgroundOpacity","axisPositionHorizontal","axisMargin"],defaultOptions:{labelColor:"black",labelPosition:"bottomLeft",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,axisPositionHorizontal:"left",lineStrokeColor:"blue",valueScaling:"linear"}},{type:"stacked-interval",aliases:["top-stacked-interval","left-stacked-interval"],datatype:["stacked-interval"],local:!1,orientation:"1d-horizontal",rotatable:!0,thumbnail:"horizontal-stacked-interval.png",availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelColor","labelTextOpacity","labelBackgroundOpacity"]},{type:"viewport-projection-vertical",datatype:["1d-projection"],local:!0,hidden:!0,projection:!0,orientation:"1d-vertical",name:"Viewport Projection",thumbnail:"viewport-projection-center.png",availableOptions:["projectionFillColor","projectionStrokeColor","strokeWidth"],defaultOptions:{projectionFillColor:"#777",projectionStrokeColor:"#777",projectionFillOpacity:.3,projectionStrokeOpacity:.7,strokeWidth:1}},{type:"viewport-projection-horizontal",datatype:["1d-projection"],local:!0,hidden:!0,projection:!0,orientation:"1d-horizontal",name:"Viewport Projection",thumbnail:"viewport-projection-center.png",availableOptions:["projectionFillColor","projectionStrokeColor","strokeWidth"],defaultOptions:{projectionFillColor:"#777",projectionStrokeColor:"#777",projectionFillOpacity:.3,projectionStrokeOpacity:.7,strokeWidth:1}},{type:"viewport-projection-center",datatype:["2d-projection"],local:!0,hidden:!0,projection:!0,orientation:"2d",name:"Viewport Projection",thumbnail:"viewport-projection-center.png",availableOptions:["projectionFillColor","projectionStrokeColor","strokeWidth"],defaultOptions:{projectionFillColor:"#777",projectionStrokeColor:"#777",projectionFillOpacity:.3,projectionStrokeOpacity:.7,strokeWidth:1}},{type:"gene-annotations",aliases:["horizontal-gene-annotations","vertical-gene-annotations"],datatype:["gene-annotation"],local:!1,defaultHeight:90,defaultWidth:90,rotatable:!0,orientation:"1d-horizontal",name:"Gene Annotations",thumbnail:uEt,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelColor","labelTextOpacity","labelBackgroundColor","labelBackgroundOpacity","minHeight","plusStrandColor","minusStrandColor","trackBorderWidth","trackBorderColor","showMousePosition","mousePositionColor","fontSize","geneAnnotationHeight","geneLabelPosition","geneStrandSpacing"],defaultOptions:{fontSize:10,labelColor:"black",labelBackgroundColor:"#ffffff",labelPosition:"hidden",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,minHeight:24,plusStrandColor:"blue",minusStrandColor:"red",trackBorderWidth:0,trackBorderColor:"black",showMousePosition:!1,mousePositionColor:"#000000",geneAnnotationHeight:16,geneLabelPosition:"outside",geneStrandSpacing:4},defaultOptionsByTheme:{[ki]:{labelColor:"#ffffff",labelBackgroundColor:"#000000",trackBorderColor:"#ffffff",mousePositionColor:"#ffffff",plusStrandColor:"#40a0ff"}}},{type:"arrowhead-domains",datatype:["arrowhead-domains"],local:!1,orientation:"2d",name:"Arrowhead Domains",thumbnail:fR,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelColor","labelTextOpacity","labelBackgroundOpacity","trackBorderWidth","trackBorderColor"],defaultOptions:{labelColor:"black",labelPosition:"hidden",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,trackBorderWidth:0,trackBorderColor:"black"}},{type:"linear-2d-rectangle-domains",aliases:["horizontal-2d-rectangle-domains","vertical-2d-rectangle-domains"],datatype:["2d-rectangle-domains"],local:!1,orientation:"1d-horizontal",rotatable:!0,name:"Horizontal 2D Rectangle Domains",thumbnail:fR,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelColor","labelTextOpacity","labelBackgroundOpacity","trackBorderWidth","trackBorderColor","rectangleDomainFillColor","rectangleDomainStrokeColor","rectangleDomainOpacity","minSquareSize"],defaultOptions:{labelColor:"black",labelPosition:"bottomLeft",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,trackBorderWidth:0,trackBorderColor:"black",rectangleDomainFillColor:"grey",rectangleDomainStrokeColor:"black",rectangleDomainOpacity:.6,minSquareSize:"none"}},{type:"2d-rectangle-domains",datatype:["2d-rectangle-domains"],local:!1,orientation:"2d",name:"2D Rectangle Domains",thumbnail:fR,availableOptions:["flipDiagonal","labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelColor","labelTextOpacity","labelBackgroundOpacity","trackBorderWidth","trackBorderColor","rectangleDomainFillColor","rectangleDomainFillOpacity","rectangleDomainStrokeColor","rectangleDomainOpacity","minSquareSize"],defaultOptions:{flipDiagonal:"none",labelColor:"black",labelPosition:"hidden",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,trackBorderWidth:0,trackBorderColor:"black",rectangleDomainFillColor:"grey",rectangleDomainFillOpacity:.4,rectangleDomainStrokeColor:"black",rectangleDomainOpacity:.6,minSquareSize:"none"}},{type:"horizontal-1d-annotations",datatype:["nothing"],local:!1,orientation:"1d-horizontal",name:"Horizontal 1D Annotations",thumbnail:null,availableOptions:["fill","fillOpacity","stroke","strokeOpacity","strokeWidth","strokePos","regions"],defaultOptions:{fill:"red",fillOpacity:.2,stroke:"red",strokeOpacity:0,strokeWidth:1,regions:[],strokePos:[]}},{type:"vertical-1d-annotations",datatype:["nothing"],local:!1,orientation:"1d-vertical",name:"Vertical 1D Annotations",thumbnail:null,availableOptions:["fill","fillOpacity","stroke","strokeOpacity","regions"],defaultOptions:{fill:"red",fillOpacity:"0.2",stroke:"red",strokeOpacity:"0",regions:[]}},{type:"2d-annotations",datatype:["2d-annotations"],local:!1,orientation:"2d",name:"2D Annotations",thumbnail:fR,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelColor","labelTextOpacity","labelBackgroundOpacity","trackBorderWidth","trackBorderColor","rectangleDomainFillColor","rectangleDomainStrokeColor","rectangleDomainOpacity","minSquareSize","isClickable","hoverColor","selectColor","exclude","trackBorderBgWidth","trackBorderBgColor","trackBorderBgAlpha"],defaultOptions:{labelColor:"black",labelPosition:"hidden",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,trackBorderWidth:0,trackBorderColor:"black",rectangleDomainFillColor:"grey",rectangleDomainStrokeColor:"black",rectangleDomainOpacity:.6,minSquareSize:"none",isClickable:!1,hoverColor:"orange",selectColor:"fuchsia",exclude:[],trackBorderBgWidth:0,trackBorderBgColor:"black",trackBorderBgAlpha:.33}},{type:"square-markers",datatype:["bedpe"],local:!1,orientation:"2d",name:"Square Markers",thumbnail:fR,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","labelColor"],defaultOptions:{labelColor:"black",labelPosition:"hidden",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,trackBorderWidth:0,trackBorderColor:"black"}},{type:"combined",datatype:"any",local:!0,orientation:"any"},{type:"horizontal-chromosome-grid",datatype:["chromsizes"],local:!1,orientation:"1d-horizontal",name:"Chromosome Grid",chromInfoPath:"//s3.amazonaws.com/pkerp/data/hg19/chromSizes.tsv",thumbnail:null,availableOptions:["lineStrokeWidth","lineStrokeColor","showMousePosition"],defaultOptions:{lineStrokeWidth:1,lineStrokeColor:"grey",showMousePosition:!1}},{type:"vertical-chromosome-grid",datatype:["chromsizes"],local:!1,orientation:"1d-vertical",name:"Chromosome Grid",chromInfoPath:"//s3.amazonaws.com/pkerp/data/hg19/chromSizes.tsv",thumbnail:null,availableOptions:["lineStrokeWidth","lineStrokeColor","showMousePosition"],defaultOptions:{lineStrokeWidth:1,lineStrokeColor:"grey",showMousePosition:!1}},{type:"2d-chromosome-grid",datatype:["chromsizes"],local:!1,orientation:"2d",name:"Chromosome Grid",chromInfoPath:"//s3.amazonaws.com/pkerp/data/hg19/chromSizes.tsv",thumbnail:null,availableOptions:["lineStrokeWidth","lineStrokeColor"],defaultOptions:{lineStrokeWidth:1,lineStrokeColor:"grey"}},{type:"2d-chromosome-annotations",datatype:["chromsizes"],local:!0,orientation:"2d",name:"2D Chromosome Annotations",thumbnail:null,hidden:!0},{type:"2d-chromosome-labels",datatype:["chromsizes"],local:!0,orientation:"2d",name:"Pairwise Chromosome Labels",thumbnail:null},{type:"chromosome-labels",aliases:["horizontal-chromosome-labels","vertical-chromosome-labels"],datatype:["chromsizes"],orientation:"1d-horizontal",rotatable:!0,minHeight:35,defaultHeight:30,name:"Chromosome Axis",thumbnail:null,availableOptions:["color","stroke","fontSize","fontIsLeftAligned","showMousePosition","mousePositionColor","tickPositions","tickFormat","reverseOrientation"],defaultOptions:{color:"#808080",stroke:"#ffffff",fontSize:12,fontIsLeftAligned:!1,showMousePosition:!1,mousePositionColor:"#000000",reverseOrientation:!1},defaultOptionsByTheme:{[ki]:{color:"#808080",stroke:"#000000",mousePositionColor:"#ffffff"}}},{type:"vertical-1d-tiles",datatype:["1d-tiles"],local:!1,orientation:"1d-vertical",name:"Vertical 1D Tile Outlines",thumbnail:hEt},{type:"horizontal-1d-tiles",datatype:["vector","stacked-interval","gene-annotation"],local:!1,orientation:"1d-horizontal",name:"Horizontal 1D Tile Outlines",thumbnail:dEt},{type:"osm-2d-tile-ids",datatype:["map-tiles"],local:!1,orientation:"2d",name:"OSM Tile Outlines",thumbnail:IBe,availableOptions:["minPos","maxPos","maxZoom","labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","name"],defaultOptions:{minPos:-180,maxPos:180,maxZoom:19,labelPosition:"bottomRight",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0}},{type:"raster-tiles",datatype:["map-tiles"],local:!0,orientation:"2d",hidden:!0,name:"Raster Tiles",thumbnail:Sae,availableOptions:["labelPosition","labelLeftMargin","labelRightMargin","labelTopMargin","labelBottomMargin","name"],defaultOptions:{labelPosition:"bottomRight",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0}},{type:"image-tiles",datatype:["image-tiles"],local:!0,orientation:"2d",hidden:!0,name:"Image Tiles",thumbnail:null},{type:"bedlike",datatype:["bedlike"],aliases:["vertical-bedlike"],local:!1,orientation:"1d-horizontal",rotatable:!0,name:"BED-like track",thumbnail:null,availableOptions:["alternating","annotationHeight","annotationStyle","fillColor","fillOpacity","fontColor","fontSize","minusStrandColor","plusStrandColor","labelBottomMargin","labelColor","labelLeftMargin","labelPosition","labelRightMargin","labelTopMargin","labelTextOpacity","labelBackgroundOpacity","maxAnnotationHeight","minHeight","trackBorderWidth","trackBorderColor","valueColumn","colorEncoding","colorRange","colorEncodingRange","separatePlusMinusStrands","showTexts","axisPositionHorizontal","axisMargin"],defaultOptions:{alternating:!1,annotationStyle:"box",fillColor:"blue",fillOpacity:.3,fontSize:"10",axisPositionHorizontal:"right",labelColor:"black",labelPosition:"hidden",labelLeftMargin:0,labelRightMargin:0,labelTopMargin:0,labelBottomMargin:0,minHeight:20,maxAnnotationHeight:null,trackBorderWidth:0,trackBorderColor:"black",valueColumn:null,colorEncoding:"itemRgb",showTexts:!1,colorRange:["#000000","#652537","#bf5458","#fba273","#ffffe0"],colorEncodingRange:!1,separatePlusMinusStrands:!0,annotationHeight:16}},{type:"empty",datatype:[],orientation:"1d-horizontal",name:"Empty track",thumbnail:null,availableOptions:[],defaultOptions:{}}],Rae=e=>{const g={},i=n=>!!(n.orientation===e||e==="1d-vertical"&&n.orientation==="1d-horizontal"&&n.rotatable);return kb.filter(i).forEach(n=>{let I=n.datatype;Array.isArray(n.datatype)||(I=[I]),I.forEach(r=>{r in g||(g[r]=[]),g[r].push(n)})}),g.none=[],g},ew=[[0,0,0,255],[35,0,0,255],[52,0,0,255],[60,0,0,255],[63,1,0,255],[64,2,0,255],[68,5,0,255],[69,6,0,255],[72,8,0,255],[74,10,0,255],[77,12,0,255],[78,14,0,255],[81,16,0,255],[83,17,0,255],[85,19,0,255],[86,20,0,255],[89,22,0,255],[91,24,0,255],[92,25,0,255],[94,26,0,255],[95,28,0,255],[98,30,0,255],[100,31,0,255],[102,33,0,255],[103,34,0,255],[105,35,0,255],[106,36,0,255],[108,38,0,255],[109,39,0,255],[111,40,0,255],[112,42,0,255],[114,43,0,255],[115,44,0,255],[117,45,0,255],[119,47,0,255],[119,47,0,255],[120,48,0,255],[122,49,0,255],[123,51,0,255],[125,52,0,255],[125,52,0,255],[126,53,0,255],[128,54,0,255],[129,56,0,255],[129,56,0,255],[131,57,0,255],[132,58,0,255],[134,59,0,255],[134,59,0,255],[136,61,0,255],[137,62,0,255],[137,62,0,255],[139,63,0,255],[139,63,0,255],[140,65,0,255],[142,66,0,255],[142,66,0,255],[143,67,0,255],[143,67,0,255],[145,68,0,255],[145,68,0,255],[146,70,0,255],[146,70,0,255],[148,71,0,255],[148,71,0,255],[149,72,0,255],[149,72,0,255],[151,73,0,255],[151,73,0,255],[153,75,0,255],[153,75,0,255],[154,76,0,255],[154,76,0,255],[154,76,0,255],[156,77,0,255],[156,77,0,255],[157,79,0,255],[157,79,0,255],[159,80,0,255],[159,80,0,255],[159,80,0,255],[160,81,0,255],[160,81,0,255],[162,82,0,255],[162,82,0,255],[163,84,0,255],[163,84,0,255],[165,85,0,255],[165,85,0,255],[166,86,0,255],[166,86,0,255],[166,86,0,255],[168,87,0,255],[168,87,0,255],[170,89,0,255],[170,89,0,255],[171,90,0,255],[171,90,0,255],[173,91,0,255],[173,91,0,255],[174,93,0,255],[174,93,0,255],[176,94,0,255],[176,94,0,255],[177,95,0,255],[177,95,0,255],[179,96,0,255],[179,96,0,255],[180,98,0,255],[182,99,0,255],[182,99,0,255],[183,100,0,255],[183,100,0,255],[185,102,0,255],[185,102,0,255],[187,103,0,255],[187,103,0,255],[188,104,0,255],[188,104,0,255],[190,105,0,255],[191,107,0,255],[191,107,0,255],[193,108,0,255],[193,108,0,255],[194,109,0,255],[196,110,0,255],[196,110,0,255],[197,112,0,255],[197,112,0,255],[199,113,0,255],[200,114,0,255],[200,114,0,255],[202,116,0,255],[202,116,0,255],[204,117,0,255],[205,118,0,255],[205,118,0,255],[207,119,0,255],[208,121,0,255],[208,121,0,255],[210,122,0,255],[211,123,0,255],[211,123,0,255],[213,124,0,255],[214,126,0,255],[214,126,0,255],[216,127,0,255],[217,128,0,255],[217,128,0,255],[219,130,0,255],[221,131,0,255],[221,131,0,255],[222,132,0,255],[224,133,0,255],[224,133,0,255],[225,135,0,255],[227,136,0,255],[227,136,0,255],[228,137,0,255],[230,138,0,255],[230,138,0,255],[231,140,0,255],[233,141,0,255],[233,141,0,255],[234,142,0,255],[236,144,0,255],[236,144,0,255],[238,145,0,255],[239,146,0,255],[241,147,0,255],[241,147,0,255],[242,149,0,255],[244,150,0,255],[244,150,0,255],[245,151,0,255],[247,153,0,255],[247,153,0,255],[248,154,0,255],[250,155,0,255],[251,156,0,255],[251,156,0,255],[253,158,0,255],[255,159,0,255],[255,159,0,255],[255,160,0,255],[255,161,0,255],[255,163,0,255],[255,163,0,255],[255,164,0,255],[255,165,0,255],[255,167,0,255],[255,167,0,255],[255,168,0,255],[255,169,0,255],[255,169,0,255],[255,170,0,255],[255,172,0,255],[255,173,0,255],[255,173,0,255],[255,174,0,255],[255,175,0,255],[255,177,0,255],[255,178,0,255],[255,179,0,255],[255,181,0,255],[255,181,0,255],[255,182,0,255],[255,183,0,255],[255,184,0,255],[255,187,7,255],[255,188,10,255],[255,189,14,255],[255,191,18,255],[255,192,21,255],[255,193,25,255],[255,195,29,255],[255,197,36,255],[255,198,40,255],[255,200,43,255],[255,202,51,255],[255,204,54,255],[255,206,61,255],[255,207,65,255],[255,210,72,255],[255,211,76,255],[255,214,83,255],[255,216,91,255],[255,219,98,255],[255,221,105,255],[255,223,109,255],[255,225,116,255],[255,228,123,255],[255,232,134,255],[255,234,142,255],[255,237,149,255],[255,239,156,255],[255,240,160,255],[255,243,167,255],[255,246,174,255],[255,248,182,255],[255,249,185,255],[255,252,193,255],[255,253,196,255],[255,255,204,255],[255,255,207,255],[255,255,211,255],[255,255,218,255],[255,255,222,255],[255,255,225,255],[255,255,229,255],[255,255,233,255],[255,255,236,255],[255,255,240,255],[255,255,244,255],[255,255,247,255],[255,255,255,0]],wi=kb.reduce((e,g)=>{if(e[g.type]=g,g.aliases)for(const i of g.aliases)e[i]=g;return e},{}),mEt=kb.reduce((e,g)=>{for(let i=0;i{const i=Rae(g);let n=new Set(Object.values(i).flatMap(I=>I));for(const I of e){const r=new Set(I);n=new Set([...n].filter(o=>o.datatype.filter(C=>r.has(C)).length>0))}return[...n]},zPe=8,Vae=8,pEt=Object.freeze(Object.defineProperty({__proto__:null,AVAILABLE_TRACK_TYPES:KF,DATATYPE_TO_TRACK_TYPE:Rae,DEFAULT_CONTAINER_PADDING_X:XPe,DEFAULT_CONTAINER_PADDING_Y:TPe,DEFAULT_SERVER:pq,DEFAULT_TRACKS_FOR_DATATYPE:OX,DEFAULT_VIEW_MARGIN:BV,DEFAULT_VIEW_PADDING:wV,GLOBALS:st,HEATED_OBJECT_MAP:ew,LOCATION_LISTENER_PREFIX:RV,LONG_DRAG_TIMEOUT:SV,MAX_CLICK_DELAY:HPe,MIN_HORIZONTAL_HEIGHT:xPe,MIN_VERTICAL_WIDTH:FPe,MOUSE_TOOL_MOVE:NF,MOUSE_TOOL_SELECT:Ja,NUM_PRECOMP_SUBSETS_PER_1D_TTILE:zPe,NUM_PRECOMP_SUBSETS_PER_2D_TTILE:Vae,POSITIONS_BY_DATATYPE:mEt,SHORT_DRAG_TIMEOUT:NPe,THEME_DARK:ki,THEME_DEFAULT:EFt,THEME_LIGHT:YF,TILE_FETCH_DEBOUNCE:mq,TRACKS_INFO:kb,TRACKS_INFO_BY_TYPE:wi,TRACK_LOCATIONS:bq,VIEW_HEADER_MED_WIDTH_SEARCH_BAR:YPe,VIEW_HEADER_MIN_WIDTH_SEARCH_BAR:KPe,ZOOM_DEBOUNCE:kF,ZOOM_TRANSITION_DURATION:kPe},Symbol.toStringTag,{value:"Module"})),jt=e=>{const g=fI(e);return st.PIXI.utils.rgb2hex([g.r/255,g.g/255,g.b/255])},PPe=e=>{if(e==="transparent")return[255,255,255,0];const g=fI(e);return[g.r,g.g,g.b,255]},xF=(e,g,i)=>{const n=mI(e,i),I=mI(g,i);if(!n||!I)throw new Error("Couldn't convert data to genomic coordinates");return[n[0],Math.round(n[1]),I[0],Math.round(I[1])]},Wae=(e,g,i)=>{let n;const I=(...r)=>{const o=()=>{n=void 0,i||e(...r)},C=i&&!n;clearTimeout(n),n=setTimeout(o,g),C&&e(...r)};return I.cancel=()=>{clearTimeout(n),n=void 0},I},yq=e=>(e+16**6).toString(16).substr(-6),_Pe=e=>{const g={};return e.forEach(i=>{g[i[0]]=i[1]}),g},Ea=e=>{const g=[];for(const i in e)e.hasOwnProperty(i)&&g.push([i,e[i]]);return g};function Ya(e){const g=[];for(const i in e)e.hasOwnProperty(i)&&g.push(i);return g}function hi(e){const g=[];for(const i in e)e.hasOwnProperty(i)&&g.push(e[i]);return g}function z2(e,g){const i=typeof g=="string"?new Blob([g],{type:"application/octet-stream"}):g,n=window.document.createElement("a");n.href=window.URL.createObjectURL(i),n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(n.href)}const OPe=e=>{const g=["top","bottom","gallery"],i=["left","right","gallery"];return e.center=e.center||[],e.left=e.left||[],e.right=e.right||[],e.top=e.top||[],e.bottom=e.bottom||[],e.whole=e.whole||[],e.gallery=e.gallery||[],g.map(n=>e[n]).forEach(n=>n.forEach(I=>{const r=wi[I.type],o=r&&r.defaultOptions||{},C=I.options?{...o,...I.options}:o;C.minHeight!==void 0&&I.height===void 0&&(I.height=C.minHeight),I.height===void 0&&(I.height=r&&r.defaultHeight||xPe)})),i.map(n=>e[n]).forEach(n=>n.forEach(I=>{const r=wi[I.type],o=r&&r.defaultOptions||{},C=I.options?{...o,...I.options}:o;C.minWidth!==void 0&&I.width===void 0&&(I.width=C.minWidth),I.width===void 0&&(I.width=r&&r.defaultWidth||FPe)})),e},JPe=e=>g=>Array.prototype.reduce.call(g,e),bEt=JPe((e,g)=>e.concat(g)),yEt=e=>g=>Array.prototype.forEach.call(g,e),FF=(e,g)=>{g.dispatchEvent(WPe(e))},ZEt=(e,g)=>[HF(e[0],e[1],g),HF(e[2],e[3],g)];function GEt(e,g,i,n,I){const{chr:r,pos:o}=g,{chr:C,pos:a}=i,A=[];if(r===C){const s=r,l=Math.floor(o/n),c=Math.min(l+I,Math.ceil(a/n));A.push([s,l,c])}else{let s=I;const l=e.findIndex(([u])=>u===r),c=e.findIndex(([u])=>u===C);for(let u=l;u<=c;u++){let d,h;const[f,m]=e[u];u{if(i.length===0)return;if(i.length===1)return i[0];let n=i[0];const I=OX[e]!==void 0?OX[e][g]:void 0;return I!==void 0&&(n=i.find(r=>r.type===I)||n),n};var aBe={},n7={},I7=34,mR=10,r7=13;function LPe(e){return new Function("d","return {"+e.map(function(g,i){return JSON.stringify(g)+": d["+i+'] || ""'}).join(",")+"}")}function vEt(e,g){var i=LPe(e);return function(n,I){return g(i(n),I,e)}}function sBe(e){var g=Object.create(null),i=[];return e.forEach(function(n){for(var I in n)I in g||i.push(g[I]=I)}),i}function rC(e,g){var i=e+"",n=i.length;return n9999?"+"+rC(e,6):rC(e,4)}function wEt(e){var g=e.getUTCHours(),i=e.getUTCMinutes(),n=e.getUTCSeconds(),I=e.getUTCMilliseconds();return isNaN(e)?"Invalid Date":BEt(e.getUTCFullYear())+"-"+rC(e.getUTCMonth()+1,2)+"-"+rC(e.getUTCDate(),2)+(I?"T"+rC(g,2)+":"+rC(i,2)+":"+rC(n,2)+"."+rC(I,3)+"Z":n?"T"+rC(g,2)+":"+rC(i,2)+":"+rC(n,2)+"Z":i||g?"T"+rC(g,2)+":"+rC(i,2)+"Z":"")}function Tae(e){var g=new RegExp('["'+e+` +\r]`),i=e.charCodeAt(0);function n(l,c){var u,d,h=I(l,function(f,m){if(u)return u(f,m-1);d=f,u=c?vEt(f,c):LPe(f)});return h.columns=d||[],h}function I(l,c){var u=[],d=l.length,h=0,f=0,m,b=d<=0,p=!1;l.charCodeAt(d-1)===mR&&--d,l.charCodeAt(d-1)===r7&&--d;function y(){if(b)return n7;if(p)return p=!1,aBe;var v,G=h,B;if(l.charCodeAt(G)===I7){for(;h++=d?b=!0:(B=l.charCodeAt(h++))===mR?p=!0:B===r7&&(p=!0,l.charCodeAt(h)===mR&&++h),l.slice(G+1,v-1).replace(/""/g,'"')}for(;hEF[e]?Promise.resolve(EF[e]):g(e),PEt=e=>{if(e.length===0)return null;const g=Hae(e);return uP(g)},_Et=e=>fetch(e,{credentials:"same-origin"}).then(g=>g.text()).then(g=>PEt(g)).catch(g=>{console.error("Could not retrieve or parse chrom info.",g)}),OEt=(e,g,i)=>g(e,i).then(n=>(EF[e]=n,EF[e])),JEt=e=>OEt(e,zEt,_Et),Nae={get:JEt};function LEt(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function ABe(e,g){for(var i=0;ithis.pubSub.publish(i,n)}},{key:"unregister",value:function(i,n){!this.registeredEls[i]&&this.registeredEls[i]!==n||(this.registeredEls[i].removeEventListener(i,this.registeredEls[i].__handler__),this.registeredEls[i]=void 0,delete this.registeredEls[i])}},{key:"register",value:function(i,n,I=!1){!n||this.registeredEls[i]===n||(this.registeredEls[i]&&this.unregister(this.registeredEls[i]),this.registeredEls[i]=n,this.registeredEls[i].__handler__=this.getEventHandler(i),this.registeredEls[i].addEventListener(i,this.registeredEls[i].__handler__,{capture:I,passive:!1}))}}]),e}();const UPe=e=>new $Et(e);let lBe=!1;const qEt=()=>{if(lBe)return;const[e,g]=t_e(),i="102117110099116105111110040041123115101108102046099111110115111108101046108111103040039",n="072",I="105",r="071",o="108097115115",C="032118",a="058032104116116112058047047104105103108097115115046105111039041125",A=[String.fromCharCode(...i.match(/.{1,3}/g).map(G=>+G)).toLowerCase(),String.fromCharCode(...n.match(/.{1,3}/g).map(G=>+G)),String.fromCharCode(...I.match(/.{1,3}/g).map(G=>+G)).toLowerCase(),String.fromCharCode(...r.match(/.{1,3}/g).map(G=>+G)),String.fromCharCode(...o.match(/.{1,3}/g).map(G=>+G)).toLowerCase(),String.fromCharCode(...C.match(/.{1,3}/g).map(G=>+G)).toLowerCase(),String.fromCharCode(...g.match(/.{1,3}/g).map(G=>+G)).toLowerCase(),String.fromCharCode(...a.match(/.{1,3}/g).map(G=>+G)).toLowerCase()].join(""),s="085082076",l="066076079066",c="087111114107101114",u="099114101097116101079098106101099116085082076",d="114101118111107101079098106101099116085082076",h=G=>G.charAt(0).toUpperCase()+G.slice(1),f=G=>G.slice(0,6)+G.charAt(6).toUpperCase()+G.slice(7,12)+G.slice(12).toUpperCase(),m=e[String.fromCharCode(...s.match(/.{1,3}/g).map(G=>+G))],b=e[h(String.fromCharCode(...l.match(/.{1,3}/g).map(G=>+G)).toLowerCase())],p=e[h(String.fromCharCode(...c.match(/.{1,3}/g).map(G=>+G)).toLowerCase())],y=f(String.fromCharCode(...u.match(/.{1,3}/g).map(G=>+G)).toLowerCase()),Z=f(String.fromCharCode(...d.match(/.{1,3}/g).map(G=>+G)).toLowerCase()),v=m[y](new b([`(${A})()`],{type:"application/javascript"}));new p(v),m[Z](v),lBe=!0},QPe={listen:qEt};function eDt(e,g,i,n,I,r,o){let C,a;if(I){const h=zae(I);C=h,a=(f,m)=>h(m.map(b=>e[b*g[1]+f]))??0}let A,s,l,c,u,d;for(l=0;l{const S=l(B);return Number.isNaN(S)?254:Math.max(0,Math.min(254,Math.floor(S)))},v=(B,S)=>{b=255,!(o&&Math.floor(B/p)B%p)&&!Number.isNaN(+S)&&(b=Z(S+I)),(b<0||b>255)&&console.warn("out of bounds rgbIdx:",b," (should be 0 <= rgbIdx <= 255)"),A&&!Number.isNaN(+S)&&+S==0?m=A:m=r[b],y[B*4]=m[0],y[B*4+1]=m[1],y[B*4+2]=m[2],y[B*4+3]=m[3]};let G;try{if(c&&a)eDt(g,a,v,c,u,d,h);else for(let B=0;B+a).filter(a=>!Number.isNaN(a));if(n[r].tilePos=C,n[r].tilesetUid=o[0],"dense"in n[r]){const a=n[r].dense,A=iDt(a);let s;if(n[r].dtype==="float16"){const c=new Uint16Array(A);s=nDt(c)}else s=new Float32Array(A);const l=C.length===2?new Mae(s):new PF(s);n[r].dense=s,n[r].denseDataExtrema=l,n[r].minNonZero=l.minNonZeroInTile,n[r].maxNonZero=l.maxNonZeroInTile}}return n}function IDt(e,g,i,n,I,r){const o={"content-type":"application/json"};n&&(o.Authorization=n),fetch(e,{credentials:"same-origin",headers:o,...r&&Object.keys(r).length>0?{method:"POST",body:JSON.stringify(r)}:{}}).then(C=>C.json()).then(C=>{I(kae(C,g,i))}).catch(C=>console.warn("err:",C))}const cBe=15,DF=Ng.nice();let JX=0,tw=null;const rDt=(e,g,i)=>{let n,I=[],r={},o=0;const C=u=>{const d=r[u.id];d&&I[d]?I[d].ids=I[d].ids.concat(u.ids):(r[u.id]=I.length,I.push(u))},a=()=>{n=null,I=[],r={}},A=(u,...d)=>{e({sessionId:DF,requests:I},...d),a()},s=(u,...d)=>{const h=()=>{o>0&&(A(u,...d),o=0)};clearTimeout(n),n=setTimeout(h,i)};s.cancel=()=>{clearTimeout(n),a()},s.immediate=()=>{e({sessionId:DF,requests:I})};let l=!1;return(u,...d)=>{C(u),l?o++:(A(u,...d),s(u,...d),l=!0,o=0,setTimeout(()=>{l=!1},g))}},LX=e=>{tw=e},oDt=()=>tw;function CDt(e,g){const i=e.requests,n=[],I={},r={};for(const C of i){I[C.server]||(I[C.server]={},r[C.server]=[]);for(const a of C.ids)if(I[C.server][a]=!0,C.options){const A=a.indexOf("."),s=a.substring(0,A),l=a.substring(A+1),c=r[C.server].find(u=>u.tilesetUid===s);c?c.tileIds.push(l):r[C.server].push({tilesetUid:s,tileIds:[l],options:C.options})}}const o=Object.keys(I);for(const C of o){const a=Object.keys(I[C]),A=r[C];for(let s=0;s`d=${h}`).join("&"),u=`${C}/tiles/?${c}&s=${DF}`,d=new Promise((h,f)=>{g.publish("requestSent",u);const m={};m.outUrl=u,m.server=C,m.theseTileIds=l,m.authHeader=tw,IDt(m.outUrl,m.server,m.theseTileIds,m.authHeader,h,A),g.publish("requestReceived",u)});n.push(d)}}Promise.all(n).then(C=>{const a={};for(const A of C){const s=Object.keys(A);for(const l of s)a[`${A[l].server}/${l}`]=A[l]}for(const A of i){const s={},{server:l}=A;for(const c of A.ids)s[c]=a[`${l}/${c}`];A.done(s)}})}const aDt=rDt(CDt,mq,mq),sDt=(e,g)=>{const i=e.map(C=>+C).sort((C,a)=>a-C),n=g.range()[1]-g.range()[0],r=i.map(C=>(g.domain()[1]-g.domain()[0])/C).map(C=>C/n),o=r.filter(C=>C<1);return o.length===0?0:r.indexOf(o[o.length-1])},ADt=(e,g)=>{if(e.resolutions)return e.resolutions.map(C=>+C).sort((C,a)=>a-C)[g];const i=e.max_width,n=+e.bins_per_dimension;return i/(2**g*n)},lDt=(e,g,i,n)=>{const I=e.range()[1]-e.range()[0],r=Math.max((i-g)/(e.domain()[1]-e.domain()[0]),1),C=Math.max(0,Math.ceil(Math.log(I/384)/Math.LN2));let a=Math.round(Math.log(r)/Math.LN2)+C,A=0;return n&&(A=Math.floor(Math.log(256)/Math.log(2)-Math.log(n)/Math.log(2))),a+=A,a};function cDt(e,g,i,n,I){let r=null;const o=e.bins_per_dimension||256;e.resolutions?r=e.resolutions[n]*o:r=g/2**n;const C=Math.floor((I-i)/r),a=Math.floor(o*(I-C*r)/r);return[C,a]}const uDt=(e,g,i,n,I,r)=>{const o=Math.min(e,I),C=r/2**o,a=1e-7;return Xo(Math.max(0,Math.floor((g.domain()[0]-i)/C)),Math.min(2**o,Math.ceil((g.domain()[1]-i-a)/C)))},dDt=(e,g,i)=>e.resolutions?e.resolutions.map(I=>+I).sort((I,r)=>r-I)[g]*i:e.max_width/2**g,hDt=(e,g,i,n,I)=>{const C=e*(I||256),a=20;n||(n=Number.MAX_VALUE);const A=Math.max(0,Math.floor((g.domain()[0]-i)/C)),s=Math.ceil(Math.min(n,g.domain()[1]-i-1e-7)/C);let l=Xo(A,s);return l.length>a&&(console.warn(`Too many visible tiles: ${l.length} truncating to ${a}`),l=l.slice(0,a)),l},fDt=(e,g,i,n,I,r,o,C,a,A)=>{const{tileData:s}=e;if(!s.dense){r(null);return}if(e.mirrored&&!e.isMirrored&&e.tileData.tilePos.length>0&&e.tileData.tilePos[0]===e.tileData.tilePos[1]){e.tileData.dense=e.tileData.dense.slice();const c=Math.floor(Math.sqrt(e.tileData.dense.length));for(let u=0;u{if(!o.ok)throw Error(o.statusText);return o[i]()}).then(o=>(g(void 0,o),o)).catch(o=>(console.error(`Could not fetch ${e}`,o),g(o,void 0),o)).finally(()=>{n.publish("requestReceived",e),JX-=1})}function mDt(e,g,i){return jPe(e,g,"text",i)}async function $Pe(e,g,i){return e.indexOf("hg19")>=0&&await Eae(1),jPe(e,g,"json",i)}const pDt=(e,g,i,n,I)=>{const r=`${dP(e)}/tileset_info/?d=${g}&s=${DF}`;I.publish("requestSent",r),$Pe(r,(o,C)=>{I.publish("requestReceived",r),o?n?n(`Error retrieving tilesetInfo from: ${e}`):console.warn("Error retrieving: ",r):i(C)},I)},Nt={calculateResolution:ADt,calculateTileAndPosInTile:cDt,calculateTiles:uDt,calculateTilesFromResolution:hDt,calculateTileWidth:dDt,calculateZoomLevel:lDt,calculateZoomLevelFromResolutions:sDt,fetchTilesDebounced:aDt,json:$Pe,text:mDt,tileDataToPixData:fDt,trackInfo:pDt},bDt=Object.freeze(Object.defineProperty({__proto__:null,ElementResizeListener:QPe,get authHeader(){return tw},chromInfo:Nae,createDomEvent:UPe,getTileProxyAuthHeader:oDt,get requestsInFlight(){return JX},setTileProxyAuthHeader:LX,tileProxy:Nt,tileResponseToData:kae},Symbol.toStringTag,{value:"Module"})),qPe=e=>(QPe.listen(),[e.clientWidth,e.clientHeight]),ta=(e,g)=>{let i=null;const n=I=>(I.uid===g&&(i=I),I.type.substr(0,8)==="combined"&&I.contents.forEach(n),null);return Object.keys(e).map(I=>e[I]).filter(I=>I.filter).reduce((I,r)=>I.concat(r),[]).forEach(n),i},yDt=(e,g,i)=>{const I=e.state.views[g];if(!I)return null;let r=null;const o=a=>(a.uid===i&&(r=a),a.type.substr(0,8)==="combined"&&a.contents.forEach(o),null),C=I.tracks;return Object.keys(C).map(a=>C[a]).filter(a=>a.filter).reduce((a,A)=>a.concat(A),[]).forEach(o),r},VV=(e,g,i)=>{const n=g?e[g]:Object.values(e)[0];if(!n){console.warn(g?`Could't find view with id "${g}"`:"No views available.");return}let I=n.trackRenderer.trackDefObjects[i];return I?I=I.trackObject:Object.values(n.trackRenderer.trackDefObjects).map(r=>r.trackObject).filter(r=>r.childTracks).forEach(r=>{r.createdTracks[i]&&(I=r.createdTracks[i])}),I};function LK(e){return e.type==="combined"}function ZDt(e){return"deltaY"in e&&"deltaMode"in e}function e_e(e){return e!==null&&typeof e=="object"}function GDt(e){return e_e(e)&&"max_width"in e}function vDt(e){return e_e(e)&&"resolutions"in e}const Yae=(e,g,i=!0,n=null)=>e.forEach(I=>{i&&LK(I)&&Yae(I.contents,g,i,n),g(I,n)}),ku=(e,g,i=!0)=>{const n=[];for(const[I,r]of Object.entries(e))Yae(r,g,i,I),n.push(...r);return n},P2=(e,g)=>{let i=null;return ku(e,(n,I)=>{n.uid===g&&(i=I)}),i},Kae=e=>g=>Array.prototype.map.call(g,e),t_e=()=>[window,Kae(e=>e.charCodeAt(0))("1.13.4").map(e=>e<=999?`00${e}`.slice(-3):e).join("")],g_e=(e,g=1,i=100,n=0,I=0,r=0,o=100)=>{const C=document.createElement("canvas");C.width=g,C.height=i;const a=C.getContext("2d");if(!a)throw new Error("Could not get canvas context");const A=a.createLinearGradient(n,I,r,o);return e.forEach(s=>{A.addColorStop(s.from,s.color)}),a.fillStyle=A,a.fillRect(0,0,g,i),C},i_e=(e,g)=>{let i=e;for(;i&&i!==g&&i.tagName!=="HTML";)i=i.parentNode;return i===g},n_e=e=>parseInt(e.replace(/^#/,""),16),I_e=()=>{};function BDt(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function uBe(e,g){for(var i=0;i{this.createdTracks[i[r].uid]=I});for(let I=0;I{if(r.add(a.uid),a.uid in this.createdTracks)I.push(this.createdTracks[a.uid]);else{const A=n(a);A.setPosition(this.position),A.setDimensions(this.dimensions),I.push(A),A.zoomed(this._xScale,this._yScale),this.createdTracks[a.uid]=A}}),this.childTracks=I;const o=new Set(Object.keys(this.createdTracks));return[...new Set([...o].filter(a=>!r.has(a)))].forEach(a=>{this.createdTracks[a].remove(),delete this.createdTracks[a]}),this}},{key:"setPosition",value:function(i){this.position=i;for(let n=0;nI.minValue).map(I=>I.minValue()).filter(I=>I);return Math.min(...n)}for(const n of this.childTracks)n.minValue&&n.minValue(i)}},{key:"maxValue",value:function(i){if(arguments.length===0){const n=this.childTracks.filter(I=>I.maxValue).map(I=>I.maxValue()).filter(I=>I);return Math.max(...n)}for(const n of this.childTracks)n.maxValue&&n.maxValue(i)}},{key:"respondsToPosition",value:function(i,n){return i>=this.position[0]&&i<=this.dimensions[0]+this.position[0]&&n>=this.position[1]&&n<=this.dimensions[1]+this.position[1]}},{key:"stopHover",value:function(){for(const i of this.childTracks)i.stopHover&&i.stopHover()}},{key:"getMouseOverHtml",value:function(i,n){let I="";for(const r of this.childTracks)if(r.getMouseOverHtml){const o=r.getMouseOverHtml(i,n);o&&o.length&&(I+=o,I+="

")}return I}}]),e}();const r_e=(e,g)=>g===e?!0:g instanceof xae?Object.keys(g.createdTracks).map(i=>g.createdTracks[i]).some(i=>r_e(e,i)):!1,Fae=(e,g,i,n,I,r,o=!1)=>o?e>=i&&e<=n||g>=I&&g<=r:e>=i&&e<=n&&g>=I&&g<=r,VDt=e=>Math.log(Math.tan((e+Math.PI/2)/2)),WDt=(e,g)=>{let i=e*Math.PI/180;return i=VDt(i),2**g*(Math.PI-i)/(2*Math.PI)},cP=e=>Kae(g=>e[g])(Object.keys(e)),XDt=e=>cP(e).map(g=>g.chromInfoPath).forEach(g=>Nae.get(g)),TDt=(e,g)=>2**g*(e+180)/360,Zq=(e,g)=>e>g?e:g,dBe=1e-7;function Gq(e){let g=Number.MIN_SAFE_INTEGER;for(let i=0;i-dBe||n>g&&(g=n)}return g}const o_e=(e,g)=>e-hBe||n(e%g+g)%g,C_e=(e,g)=>{const i=+g;if(!Number.isNaN(i))if(e.dimension===1)for(let I=0;I + * @license MIT + */var YDt=function(e){return e!=null&&(a_e(e)||KDt(e)||!!e._isBuffer)};function a_e(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function KDt(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&a_e(e.slice(0,0))}var xDt=kDt,FDt=YDt,EDt=typeof Float64Array<"u";function DDt(e,g){return e[0]-g[0]}function MDt(){var e=this.stride,g=new Array(e.length),i;for(i=0;iMath.abs(this.stride[1]))?[1,0]:[0,1]}})"):g===3&&I.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):I.push("ORDER})")),I.push("proto.set=function "+i+"_set("+o.join(",")+",v){"),n?I.push("return this.data.set("+C+",v)}"):I.push("return this.data["+C+"]=v}"),I.push("proto.get=function "+i+"_get("+o.join(",")+"){"),n?I.push("return this.data.get("+C+")}"):I.push("return this.data["+C+"]}"),I.push("proto.index=function "+i+"_index(",o.join(),"){return "+C+"}"),I.push("proto.hi=function "+i+"_hi("+o.join(",")+"){return new "+i+"(this.data,"+r.map(function(f){return["(typeof i",f,"!=='number'||i",f,"<0)?this.shape[",f,"]:i",f,"|0"].join("")}).join(",")+","+r.map(function(f){return"this.stride["+f+"]"}).join(",")+",this.offset)}");var s=r.map(function(f){return"a"+f+"=this.shape["+f+"]"}),l=r.map(function(f){return"c"+f+"=this.stride["+f+"]"});I.push("proto.lo=function "+i+"_lo("+o.join(",")+"){var b=this.offset,d=0,"+s.join(",")+","+l.join(","));for(var c=0;c=0){d=i"+c+"|0;b+=c"+c+"*d;a"+c+"-=d}");I.push("return new "+i+"(this.data,"+r.map(function(f){return"a"+f}).join(",")+","+r.map(function(f){return"c"+f}).join(",")+",b)}"),I.push("proto.step=function "+i+"_step("+o.join(",")+"){var "+r.map(function(f){return"a"+f+"=this.shape["+f+"]"}).join(",")+","+r.map(function(f){return"b"+f+"=this.stride["+f+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var c=0;c=0){c=(c+this.stride["+c+"]*i"+c+")|0}else{a.push(this.shape["+c+"]);b.push(this.stride["+c+"])}");I.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),I.push("return function construct_"+i+"(data,shape,stride,offset){return new "+i+"(data,"+r.map(function(f){return"shape["+f+"]"}).join(",")+","+r.map(function(f){return"stride["+f+"]"}).join(",")+",offset)}");var h=new Function("CTOR_LIST","ORDER",I.join(` +`));return h(MF[e],MDt)}function PDt(e){if(FDt(e))return"buffer";if(EDt)switch(Object.prototype.toString.call(e)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}return Array.isArray(e)?"array":"generic"}var MF={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function _Dt(e,g,i,n){if(e===void 0){var A=MF.array[0];return A([])}else typeof e=="number"&&(e=[e]);g===void 0&&(g=[e.length]);var I=g.length;if(i===void 0){i=new Array(I);for(var r=I-1,o=1;r>=0;--r)i[r]=o,o*=g[r]}if(n===void 0){n=0;for(var r=0;r{const g=e.shape.reduce((n,I)=>n*I,1),i=new Array(g);if(e.dimension===1){let n=0;for(let I=0;Ie.shape.length===1?e:_v(s_e(e)),l_e=e=>{const g=e.split("."),i=g.slice(1).join("").length;return+g.join("")/10**i},kT=(e,g)=>e||g;function uP(e){const g=[],i={},n={};let I=0;for(let r=0;r{const g=document.createElement("g"),i=document.createElement("text");return e.anchor.x===0?i.setAttribute("text-anchor","start"):e.anchor.x===1?i.setAttribute("text-anchor","end"):i.setAttribute("text-anchor","middle"),i.setAttribute("font-family",e.style.fontFamily),i.setAttribute("font-size",e.style.fontSize),g.setAttribute("transform",`scale(${e.scale.x},1)`),i.setAttribute("fill",e.style.fill),i.innerHTML=e.text,g.appendChild(i),g.setAttribute("transform",`translate(${e.x},${e.y})scale(${e.scale.x},1)`),g},JDt=e=>{try{const g=e.split(".");return i=>{let n=i;return g.forEach(I=>{n=n[I]}),n}}catch{return}},LDt=(e,g,i,n,I,r,o=0,C=0,a)=>{const A=r?I:n,s=r?n:I,l=r?C:o,c=r?o:C,u=Math.max(0,+A[0]||0),d=Math.max(0,+A[1]||0),h=Math.max(0,+s[0]||0),f=Math.max(0,+s[1]||0);let m=[];ArrayBuffer.isView(a)||console.warn("Not supported yet");try{const b=new a.constructor(a.length);let p=0+c;for(let Z=h;Z[n.chrPositions[e].pos+ +g,n.chrPositions[e].pos+ +i],QDt="http://www.w3.org/2000/svg",jDt=(e,g)=>{const i=new RegExp(`(\\s|^)${g}(\\s|$)`);if(e.namespaceURI===QDt){const n=e.getAttribute("class")||"";e.setAttribute("class",n.replace(i," "))}else e.classList?e.classList.remove(g):TF(e,g)&&(e.className=e.className.replace(i," "))},Ov=(e,g)=>{e.select(".selection").attr("fill",null).attr("fill-opacity",null).attr("stroke",null).classed(g,!0)},o7=e=>{const g=e.toString(16);return g.length===1?`0${g}`:g},$Dt=(e,g,i)=>`#${o7(e)}${o7(g)}${o7(i)}`,AI=(e,g)=>{const i=e.invert((e.range()[0]+e.range()[1])/2),n=g.invert((g.range()[0]+g.range()[1])/2),I=e.invert(1)-e.invert(0);return[i,n,I]},c_e=(e,g,i)=>{if(i===null||!e||!g)return;const n=e.domain()[0],I=e.domain()[1],r=g.domain()[0],o=g.domain()[1];return[...xF(n,I,i),...xF(r,o,i)]},qDt=11184810,eMt=1,tMt=(e,g,i,n,I,r,o,C,a)=>{e.publish("app.animateOnMouseMove",!0);const A=i.mousePositionColor?n_e(i.mousePositionColor):qDt,s=i.mousePositionAlpha||eMt,l=new st.PIXI.Graphics,c=()=>{l.clear()},u=(h,f,m)=>{if(m||c(),l.lineStyle(1,A,s),f){const b=C?I()[0]:0;l.moveTo(0,h),l.lineTo(r()[0]+b,h)}else{const b=C?I()[1]:0;l.moveTo(h,0),l.lineTo(h,r()[1]+b)}},d=h=>{if(h.noHoveredTracks)return c(),l;let f,m;h.isFromVerticalTrack?(f=h.dataY,m=h.dataY):(f=h.dataX,m=h.isFrom2dTrack?h.dataY:h.dataX);const b=C?I():[0,0],p=o()?n()[0](m)+b[1]:n()[0](f)+b[0];return u(p),C&&u(n()[1](m)+b[1],!0,!0),l};return g.push(e.subscribe("app.mouseMove",d)),g.push(e.subscribe("app.mouseLeave",c)),g.push(e.subscribe("blur",c)),a&&g.push(M2.subscribe("higlass.mouseMove",d)),l},Yb=(e,g=!1,i=!1)=>{const n=g?e.pMasked:e.pForeground||e.pMain;if(!n)throw new Error("setupShowMousePosition: No scene found. Please make sure to call this method after the scene has been initialized.");const I=()=>[e.xScale(),e.yScale()],r=tMt(e.pubSub,e.pubSubs,e.options,I,e.getPosition.bind(e),e.getDimensions.bind(e),e.getProp("flipText"),g,i);return n.addChild(r),()=>{n.removeChild(r)}},gMt=e=>g=>Array.prototype.some.call(g,e),of=(e,g)=>e+g,u_e=(e,g,i,n,I,r)=>{const o=document.createElement("line");return o.setAttribute("x1",e),o.setAttribute("x2",i),o.setAttribute("y1",g),o.setAttribute("y2",n),I&&o.setAttribute("stroke-width",I),r&&o.setAttribute("stroke",r),o},d_e=(e,g,i)=>{let n,I=0;const r=()=>{n=void 0},o=(...A)=>{const s=()=>{I>0&&(e(...A),I=0)};clearTimeout(n),n=setTimeout(s,i)};o.cancel=()=>{clearTimeout(n),r()},o.immediate=(...A)=>{e(...A)};let C=!1;return(A,...s)=>{C?I++:(e(...s),o(...s),C=!0,I=0,setTimeout(()=>{C=!1},g))}},iMt=(e,g=256,i=256)=>{const n=document.createElement("canvas");n.width=g,n.height=i;const I=n.getContext("2d");if(!I)throw new Error("Could not get canvas context");I.fillStyle="transparent",I.fillRect(0,0,n.width,n.height);const r=new ImageData(e,n.width,n.height);return I.putImageData(r,0,0),n},Eae=e=>new Promise(g=>{setTimeout(g,e)}),nMt=e=>{if(!e.tracks)return 0;let g=0;return e.tracks.top&&(g+=e.tracks.top.map(i=>i.height).reduce((i,n)=>i+n,0)),e.tracks.center&&(g+=e.tracks.center.map(i=>i.height).reduce((i,n)=>i+n,0)),e.tracks.bottom&&(g+=e.tracks.bottom.map(i=>i.height).reduce((i,n)=>i+n,0)),g},GA=()=>{},dP=e=>(e||"").replace(/\/$/,""),Dae=(e,g,i=0,n=1e-6)=>I=>{let r=255;return I>n&&(r=Math.max(0,Math.min(255,Math.floor(e(I+i))))),g[r]},UK=e=>{let g=[];for(let i=0;ig[0]?e.left?wq(e.left,g):fBe(e,"left",g):e.right?wq(e.right,g):fBe(e,"right",g)}xd.prototype.add=function(g){if(!this.root){this.root=new h_e(g[0],g[1]),this.root.max=g[1];return}wq(this.root,g)};function f_e(e,g){if(!g)return!1;if(g.interval[0]<=e&&g.interval[1]>=e)return!0;let i=!1,n;return["left","right"].forEach(I=>{n=g[I],n&&n.max>e&&(i=i||f_e(e,n))}),i}xd.prototype.contains=function(g){return f_e(g,this.root)};function IMt(e,g){return e[0]===g[0]&&e[1]===g[1]||e[0]g[0]||e[0]g[1]||g[0]e[0]||g[0]e[1]}function m_e(e,g){if(!g)return!1;if(IMt(g.interval,e))return!0;let i=!1,n;return["left","right"].forEach(I=>{n=g[I],n&&n.max>=e[0]&&(i=i||m_e(e,n))}),i}xd.prototype.intersects=function(g){return m_e(g,this.root)};function Sq(e){return e?1+Math.max(Sq(e.left),Sq(e.right)):0}xd.prototype.height=function(){return Sq(this.root)};xd.prototype.findMax=function(g){const i=[g];let n,I=-1/0,r;for(;i.length;)n=i.pop(),n.left&&i.push(n.left),n.right&&i.push(n.right),n.interval[1]>I&&(I=n.interval[1],r=n);return r};xd.prototype._removeHelper=function(g,i){if(i)if(i.interval[0]===g[0]&&i.interval[1]===g[1]){if(i.left&&i.right){let I=i.left;for(;I.left;)I=I.left;const r=I.interval;I.interval=i.interval,i.interval=r,this._removeHelper(I.interval,i)}else{let I="left";i.right&&(I="right");const r=i.parentNode;r?(r.left===i?r.left=i[I]:r.right=i[I],i[I]&&(i[I].parentNode=r)):(this.root=i[I],this.root&&(this.root.parentNode=null))}const n=i.parentNode;if(n){let I=this.findMax(n);const r=I.interval[1];for(;I;)I.max===i.interval[1]?(I.max=r,I=I.parentNode):I=!1}}else this._removeHelper(g,i.left),this._removeHelper(g,i.right)};xd.prototype.remove=function(g){return this._removeHelper(g,this.root)};function zF(e){e.sort((n,I)=>I.to-I.from-(n.to-n.from));const g=[[]],i=[new xd];for(let n=0;n=C?this.minNonZero(this.data,n,I):(nC*this.subsetSize&&(r=Math.min(r,this.minNonZero(this.data,C*this.subsetSize,I))),r)}},{key:"getMaxNonZeroInSubset",value:function(i){const n=i[0],I=i[1];let r=Number.MIN_SAFE_INTEGER;if(n===0&&I===this.tileSize)return this.maxNonZeroInTile;const o=Math.ceil(n/this.subsetSize),C=Math.floor((I-1)/this.subsetSize);return o>=C?this.maxNonZero(this.data,n,I):(nC*this.subsetSize&&(r=Math.max(r,this.maxNonZero(this.data,C*this.subsetSize,I))),r)}},{key:"computeSubsetNonZeroMinimums",value:function(){const i=[];for(let n=0;n-this.epsilon||o-this.epsilon||o>I&&(I=o))}i.push(I)}return i}},{key:"getMinNonZeroInTile",value:function(){return Math.min(...this.subsetMinimums)}},{key:"getMaxNonZeroInTile",value:function(){return Math.max(...this.subsetMaximums)}},{key:"minNonZero",value:function(i,n,I){let r=Number.MAX_SAFE_INTEGER;for(let o=n;o-this.epsilon||C-this.epsilon||C>r&&(r=C)}return r}}]),e}();function sMt(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function pBe(e,g){for(var i=0;i-this.epsilon||s-this.epsilon||s>C&&(C=s)}return C}},{key:"mirrorPrecomputedExtrema",value:function(){for(let i=1;i{let g;switch(e&&e.toLowerCase()){case"mean":g=Q6;break;case"sum":g=v3e;break;case"variance":g=BCe;break;case"deviation":g=wCe;break;default:g=Q6,console.warn("Encountered an unsupported selectedRowsAggregationMode option.")}return g},UX=(e,g)=>e.reduce((i,n)=>i+(Array.isArray(n)&&g?n.length:1),0),N1=e=>{switch(e.type){case"heatmap":case"horizontal-1d-heatmap":case"horizontal-bar":case"horizontal-line":case"horizontal-point":case"vertical-1d-heatmap":case"vertical-bar":case"vertical-line":case"vertical-point":case"horizontal-1d-tiles":case"vertical-1d-tiles":case"2d-tiles":case"horizontal-gene-annotations":case"vertical-gene-annotations":case"horizontal-heatmap":case"vertical-heatmap":case"osm-tiles":case"mapbox-tiles":case"horizontal-multivec":return!0;case"combined":return e.contents.map(i=>N1(i)).reduce(kT,!1);default:return!1}},Pae=(e,g,i)=>{let n=g,I=i;return i||(I=g,n=Object.values(e.state.views)[0].uid),e.tiledPlots[n].trackRenderer.getTrackObject(I)},p_e=(e,g)=>e.tiledPlots[g].trackRenderer,uMt=(e,g)=>e.tiledPlots[g];var _ae={},bBe=Object.prototype.toString,b_e=function(g){var i=bBe.call(g),n=i==="[object Arguments]";return n||(n=i!=="[object Array]"&&g!==null&&typeof g=="object"&&typeof g.length=="number"&&g.length>=0&&bBe.call(g.callee)==="[object Function]"),n},C7,yBe;function dMt(){if(yBe)return C7;yBe=1;var e;if(!Object.keys){var g=Object.prototype.hasOwnProperty,i=Object.prototype.toString,n=b_e,I=Object.prototype.propertyIsEnumerable,r=!I.call({toString:null},"toString"),o=I.call(function(){},"prototype"),C=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],a=function(c){var u=c.constructor;return u&&u.prototype===c},A={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},s=function(){if(typeof window>"u")return!1;for(var c in window)try{if(!A["$"+c]&&g.call(window,c)&&window[c]!==null&&typeof window[c]=="object")try{a(window[c])}catch{return!0}}catch{return!0}return!1}(),l=function(c){if(typeof window>"u"||!s)return a(c);try{return a(c)}catch{return!1}};e=function(u){var d=u!==null&&typeof u=="object",h=i.call(u)==="[object Function]",f=n(u),m=d&&i.call(u)==="[object String]",b=[];if(!d&&!h&&!f)throw new TypeError("Object.keys called on a non-object");var p=o&&h;if(m&&u.length>0&&!g.call(u,0))for(var y=0;y0)for(var Z=0;Z"u"||!HI?zg:HI(Uint8Array),J0={"%AggregateError%":typeof AggregateError>"u"?zg:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?zg:ArrayBuffer,"%ArrayIteratorPrototype%":JZ&&HI?HI([][Symbol.iterator]()):zg,"%AsyncFromSyncIteratorPrototype%":zg,"%AsyncFunction%":SG,"%AsyncGenerator%":SG,"%AsyncGeneratorFunction%":SG,"%AsyncIteratorPrototype%":SG,"%Atomics%":typeof Atomics>"u"?zg:Atomics,"%BigInt%":typeof BigInt>"u"?zg:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?zg:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?zg:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?zg:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?zg:Float32Array,"%Float64Array%":typeof Float64Array>"u"?zg:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?zg:FinalizationRegistry,"%Function%":v_e,"%GeneratorFunction%":SG,"%Int8Array%":typeof Int8Array>"u"?zg:Int8Array,"%Int16Array%":typeof Int16Array>"u"?zg:Int16Array,"%Int32Array%":typeof Int32Array>"u"?zg:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":JZ&&HI?HI(HI([][Symbol.iterator]())):zg,"%JSON%":typeof JSON=="object"?JSON:zg,"%Map%":typeof Map>"u"?zg:Map,"%MapIteratorPrototype%":typeof Map>"u"||!JZ||!HI?zg:HI(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?zg:Promise,"%Proxy%":typeof Proxy>"u"?zg:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?zg:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?zg:Set,"%SetIteratorPrototype%":typeof Set>"u"||!JZ||!HI?zg:HI(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?zg:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":JZ&&HI?HI(""[Symbol.iterator]()):zg,"%Symbol%":JZ?Symbol:zg,"%SyntaxError%":gw,"%ThrowTypeError%":XMt,"%TypedArray%":HMt,"%TypeError%":Jv,"%Uint8Array%":typeof Uint8Array>"u"?zg:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?zg:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?zg:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?zg:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?zg:WeakMap,"%WeakRef%":typeof WeakRef>"u"?zg:WeakRef,"%WeakSet%":typeof WeakSet>"u"?zg:WeakSet};if(HI)try{null.error}catch(e){var NMt=HI(HI(e));J0["%Error.prototype%"]=NMt}var kMt=function e(g){var i;if(g==="%AsyncFunction%")i=a7("async function () {}");else if(g==="%GeneratorFunction%")i=a7("function* () {}");else if(g==="%AsyncGeneratorFunction%")i=a7("async function* () {}");else if(g==="%AsyncGenerator%"){var n=e("%AsyncGeneratorFunction%");n&&(i=n.prototype)}else if(g==="%AsyncIteratorPrototype%"){var I=e("%AsyncGenerator%");I&&HI&&(i=HI(I.prototype))}return J0[g]=i,i},SBe={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},YT=Jae,_F=qd,YMt=YT.call(Function.call,Array.prototype.concat),KMt=YT.call(Function.apply,Array.prototype.splice),RBe=YT.call(Function.call,String.prototype.replace),OF=YT.call(Function.call,String.prototype.slice),xMt=YT.call(Function.call,RegExp.prototype.exec),FMt=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,EMt=/\\(\\)?/g,DMt=function(g){var i=OF(g,0,1),n=OF(g,-1);if(i==="%"&&n!=="%")throw new gw("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&i!=="%")throw new gw("invalid intrinsic syntax, expected opening `%`");var I=[];return RBe(g,FMt,function(r,o,C,a){I[I.length]=C?RBe(a,EMt,"$1"):o||r}),I},MMt=function(g,i){var n=g,I;if(_F(SBe,n)&&(I=SBe[n],n="%"+I[0]+"%"),_F(J0,n)){var r=J0[n];if(r===SG&&(r=kMt(n)),typeof r>"u"&&!i)throw new Jv("intrinsic "+g+" exists, but is not available. Please file an issue!");return{alias:I,name:n,value:r}}throw new gw("intrinsic "+g+" does not exist!")},ii=function(g,i){if(typeof g!="string"||g.length===0)throw new Jv("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof i!="boolean")throw new Jv('"allowMissing" argument must be a boolean');if(xMt(/^%?[^%]*%?$/,g)===null)throw new gw("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=DMt(g),I=n.length>0?n[0]:"",r=MMt("%"+I+"%",i),o=r.name,C=r.value,a=!1,A=r.alias;A&&(I=A[0],KMt(n,YMt([0,1],A)));for(var s=1,l=!0;s=n.length){var h=O0(C,c);l=!!h,l&&"get"in h&&!("originalValue"in h.get)?C=h.get:C=C[c]}else l=_F(C,c),C=C[c];l&&!a&&(J0[o]=C)}}return C},zMt=ii,Rq=zMt("%Object.defineProperty%",!0),Vq=function(){if(Rq)try{return Rq({},"a",{value:1}),!0}catch{return!1}return!1};Vq.hasArrayLengthDefineBug=function(){if(!Vq())return null;try{return Rq([],"length",{value:1}).length!==1}catch{return!0}};var hP=Vq,PMt=ii,jK=PMt("%Object.getOwnPropertyDescriptor%",!0);if(jK)try{jK([],"length")}catch{jK=null}var Lae=jK,_Mt=hP(),Uae=ii,_2=_Mt&&Uae("%Object.defineProperty%",!0);if(_2)try{_2({},"a",{value:1})}catch{_2=!1}var OMt=Uae("%SyntaxError%"),LZ=Uae("%TypeError%"),VBe=Lae,B_e=function(g,i,n){if(!g||typeof g!="object"&&typeof g!="function")throw new LZ("`obj` must be an object or a function`");if(typeof i!="string"&&typeof i!="symbol")throw new LZ("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new LZ("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new LZ("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new LZ("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new LZ("`loose`, if provided, must be a boolean");var I=arguments.length>3?arguments[3]:null,r=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,C=arguments.length>6?arguments[6]:!1,a=!!VBe&&VBe(g,i);if(_2)_2(g,i,{configurable:o===null&&a?a.configurable:!o,enumerable:I===null&&a?a.enumerable:!I,value:n,writable:r===null&&a?a.writable:!r});else if(C||!I&&!r&&!o)g[i]=n;else throw new OMt("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},JMt=y_e,LMt=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",UMt=Object.prototype.toString,QMt=Array.prototype.concat,WBe=B_e,jMt=function(e){return typeof e=="function"&&UMt.call(e)==="[object Function]"},w_e=hP(),$Mt=function(e,g,i,n){if(g in e){if(n===!0){if(e[g]===i)return}else if(!jMt(n)||!n())return}w_e?WBe(e,g,i,!0):WBe(e,g,i)},S_e=function(e,g){var i=arguments.length>2?arguments[2]:{},n=JMt(g);LMt&&(n=QMt.call(n,Object.getOwnPropertySymbols(g)));for(var I=0;I4294967295||e3t(i)!==i)throw new HBe("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],I=!0,r=!0;if("length"in g&&TBe){var o=TBe(g,"length");o&&!o.configurable&&(I=!1),o&&!o.writable&&(r=!1)}return(I||r||!n)&&(qMt?XBe(g,"length",i,!0,!0):XBe(g,"length",i)),g};(function(e){var g=Jae,i=ii,n=t3t,I=i("%TypeError%"),r=i("%Function.prototype.apply%"),o=i("%Function.prototype.call%"),C=i("%Reflect.apply%",!0)||g.call(o,r),a=i("%Object.defineProperty%",!0),A=i("%Math.max%");if(a)try{a({},"a",{value:1})}catch{a=null}e.exports=function(c){if(typeof c!="function")throw new I("a function is required");var u=C(g,o,arguments);return n(u,1+A(0,c.length-(arguments.length-1)),!0)};var s=function(){return C(g,r,arguments)};a?a(e.exports,"apply",{value:s}):e.exports.apply=s})(R_e);var eh=R_e.exports,W_e=ii,X_e=eh,g3t=X_e(W_e("String.prototype.indexOf")),Jo=function(g,i){var n=W_e(g,!!i);return typeof n=="function"&&g3t(g,".prototype.")>-1?X_e(n):n},i3t=y_e,T_e=Oae(),H_e=Jo,NBe=Object,n3t=H_e("Array.prototype.push"),kBe=H_e("Object.prototype.propertyIsEnumerable"),I3t=T_e?Object.getOwnPropertySymbols:null,N_e=function(g,i){if(g==null)throw new TypeError("target must be an object");var n=NBe(g);if(arguments.length===1)return n;for(var I=1;I= 0");if(s>o)throw new i("length is greater than (2**32 - 1)");var l=arguments.length>1?arguments[1]:g,c=[];if(l!==g){if(!a)throw new n("ArrayCreate: a `proto` argument that is not `Array.prototype` is not supported in an environment that does not support setting the [[Prototype]]");a(c,l)}return s!==0&&(c.length=s),c},c7}const m3t={},p3t=Object.freeze(Object.defineProperty({__proto__:null,default:m3t},Symbol.toStringTag,{value:"Module"})),b3t=Ud(p3t);var jae=typeof Map=="function"&&Map.prototype,u7=Object.getOwnPropertyDescriptor&&jae?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,JF=jae&&u7&&typeof u7.get=="function"?u7.get:null,xBe=jae&&Map.prototype.forEach,$ae=typeof Set=="function"&&Set.prototype,d7=Object.getOwnPropertyDescriptor&&$ae?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,LF=$ae&&d7&&typeof d7.get=="function"?d7.get:null,FBe=$ae&&Set.prototype.forEach,y3t=typeof WeakMap=="function"&&WeakMap.prototype,O2=y3t?WeakMap.prototype.has:null,Z3t=typeof WeakSet=="function"&&WeakSet.prototype,J2=Z3t?WeakSet.prototype.has:null,G3t=typeof WeakRef=="function"&&WeakRef.prototype,EBe=G3t?WeakRef.prototype.deref:null,v3t=Boolean.prototype.valueOf,B3t=Object.prototype.toString,w3t=Function.prototype.toString,S3t=String.prototype.match,qae=String.prototype.slice,Gf=String.prototype.replace,R3t=String.prototype.toUpperCase,DBe=String.prototype.toLowerCase,F_e=RegExp.prototype.test,MBe=Array.prototype.concat,Hl=Array.prototype.join,V3t=Array.prototype.slice,zBe=Math.floor,Wq=typeof BigInt=="function"?BigInt.prototype.valueOf:null,h7=Object.getOwnPropertySymbols,Xq=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,iw=typeof Symbol=="function"&&typeof Symbol.iterator=="object",to=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===iw||"symbol")?Symbol.toStringTag:null,E_e=Object.prototype.propertyIsEnumerable,PBe=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function _Be(e,g){if(e===1/0||e===-1/0||e!==e||e&&e>-1e3&&e<1e3||F_e.call(/e/,g))return g;var i=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof e=="number"){var n=e<0?-zBe(-e):zBe(e);if(n!==e){var I=String(n),r=qae.call(g,I.length+1);return Gf.call(I,i,"$&_")+"."+Gf.call(Gf.call(r,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Gf.call(g,i,"$&_")}var Tq=b3t,OBe=Tq.custom,JBe=z_e(OBe)?OBe:null,D_e=function e(g,i,n,I){var r=i||{};if(Qh(r,"quoteStyle")&&r.quoteStyle!=="single"&&r.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Qh(r,"maxStringLength")&&(typeof r.maxStringLength=="number"?r.maxStringLength<0&&r.maxStringLength!==1/0:r.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=Qh(r,"customInspect")?r.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Qh(r,"indent")&&r.indent!==null&&r.indent!==" "&&!(parseInt(r.indent,10)===r.indent&&r.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Qh(r,"numericSeparator")&&typeof r.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var C=r.numericSeparator;if(typeof g>"u")return"undefined";if(g===null)return"null";if(typeof g=="boolean")return g?"true":"false";if(typeof g=="string")return __e(g,r);if(typeof g=="number"){if(g===0)return 1/0/g>0?"0":"-0";var a=String(g);return C?_Be(g,a):a}if(typeof g=="bigint"){var A=String(g)+"n";return C?_Be(g,A):A}var s=typeof r.depth>"u"?5:r.depth;if(typeof n>"u"&&(n=0),n>=s&&s>0&&typeof g=="object")return Hq(g)?"[Array]":"[Object]";var l=J3t(r,n);if(typeof I>"u")I=[];else if(P_e(I,g)>=0)return"[Circular]";function c(W,V,X){if(V&&(I=V3t.call(I),I.push(V)),X){var N={depth:r.depth};return Qh(r,"quoteStyle")&&(N.quoteStyle=r.quoteStyle),e(W,N,n+1,I)}return e(W,r,n+1,I)}if(typeof g=="function"&&!LBe(g)){var u=x3t(g),d=Hk(g,c);return"[Function"+(u?": "+u:" (anonymous)")+"]"+(d.length>0?" { "+Hl.call(d,", ")+" }":"")}if(z_e(g)){var h=iw?Gf.call(String(g),/^(Symbol\(.*\))_[^)]*$/,"$1"):Xq.call(g);return typeof g=="object"&&!iw?pR(h):h}if(P3t(g)){for(var f="<"+DBe.call(String(g.nodeName)),m=g.attributes||[],b=0;b",f}if(Hq(g)){if(g.length===0)return"[]";var p=Hk(g,c);return l&&!O3t(p)?"["+Nq(p,l)+"]":"[ "+Hl.call(p,", ")+" ]"}if(T3t(g)){var y=Hk(g,c);return!("cause"in Error.prototype)&&"cause"in g&&!E_e.call(g,"cause")?"{ ["+String(g)+"] "+Hl.call(MBe.call("[cause]: "+c(g.cause),y),", ")+" }":y.length===0?"["+String(g)+"]":"{ ["+String(g)+"] "+Hl.call(y,", ")+" }"}if(typeof g=="object"&&o){if(JBe&&typeof g[JBe]=="function"&&Tq)return Tq(g,{depth:s-n});if(o!=="symbol"&&typeof g.inspect=="function")return g.inspect()}if(F3t(g)){var Z=[];return xBe&&xBe.call(g,function(W,V){Z.push(c(V,g,!0)+" => "+c(W,g))}),UBe("Map",JF.call(g),Z,l)}if(M3t(g)){var v=[];return FBe&&FBe.call(g,function(W){v.push(c(W,g))}),UBe("Set",LF.call(g),v,l)}if(E3t(g))return f7("WeakMap");if(z3t(g))return f7("WeakSet");if(D3t(g))return f7("WeakRef");if(N3t(g))return pR(c(Number(g)));if(Y3t(g))return pR(c(Wq.call(g)));if(k3t(g))return pR(v3t.call(g));if(H3t(g))return pR(c(String(g)));if(typeof window<"u"&&g===window)return"{ [object Window] }";if(g===globalThis)return"{ [object globalThis] }";if(!X3t(g)&&!LBe(g)){var G=Hk(g,c),B=PBe?PBe(g)===Object.prototype:g instanceof Object||g.constructor===Object,S=g instanceof Object?"":"null prototype",R=!B&&to&&Object(g)===g&&to in g?qae.call(zm(g),8,-1):S?"Object":"",w=B||typeof g.constructor!="function"?"":g.constructor.name?g.constructor.name+" ":"",T=w+(R||S?"["+Hl.call(MBe.call([],R||[],S||[]),": ")+"] ":"");return G.length===0?T+"{}":l?T+"{"+Nq(G,l)+"}":T+"{ "+Hl.call(G,", ")+" }"}return String(g)};function M_e(e,g,i){var n=(i.quoteStyle||g)==="double"?'"':"'";return n+e+n}function W3t(e){return Gf.call(String(e),/"/g,""")}function Hq(e){return zm(e)==="[object Array]"&&(!to||!(typeof e=="object"&&to in e))}function X3t(e){return zm(e)==="[object Date]"&&(!to||!(typeof e=="object"&&to in e))}function LBe(e){return zm(e)==="[object RegExp]"&&(!to||!(typeof e=="object"&&to in e))}function T3t(e){return zm(e)==="[object Error]"&&(!to||!(typeof e=="object"&&to in e))}function H3t(e){return zm(e)==="[object String]"&&(!to||!(typeof e=="object"&&to in e))}function N3t(e){return zm(e)==="[object Number]"&&(!to||!(typeof e=="object"&&to in e))}function k3t(e){return zm(e)==="[object Boolean]"&&(!to||!(typeof e=="object"&&to in e))}function z_e(e){if(iw)return e&&typeof e=="object"&&e instanceof Symbol;if(typeof e=="symbol")return!0;if(!e||typeof e!="object"||!Xq)return!1;try{return Xq.call(e),!0}catch{}return!1}function Y3t(e){if(!e||typeof e!="object"||!Wq)return!1;try{return Wq.call(e),!0}catch{}return!1}var K3t=Object.prototype.hasOwnProperty||function(e){return e in this};function Qh(e,g){return K3t.call(e,g)}function zm(e){return B3t.call(e)}function x3t(e){if(e.name)return e.name;var g=S3t.call(w3t.call(e),/^function\s*([\w$]+)/);return g?g[1]:null}function P_e(e,g){if(e.indexOf)return e.indexOf(g);for(var i=0,n=e.length;ig.maxStringLength){var i=e.length-g.maxStringLength,n="... "+i+" more character"+(i>1?"s":"");return __e(qae.call(e,0,g.maxStringLength),g)+n}var I=Gf.call(Gf.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,_3t);return M_e(I,"single",g)}function _3t(e){var g=e.charCodeAt(0),i={8:"b",9:"t",10:"n",12:"f",13:"r"}[g];return i?"\\"+i:"\\x"+(g<16?"0":"")+R3t.call(g.toString(16))}function pR(e){return"Object("+e+")"}function f7(e){return e+" { ? }"}function UBe(e,g,i,n){var I=n?Nq(i,n):Hl.call(i,", ");return e+" ("+g+") {"+I+"}"}function O3t(e){for(var g=0;g=0)return!1;return!0}function J3t(e,g){var i;if(e.indent===" ")i=" ";else if(typeof e.indent=="number"&&e.indent>0)i=Hl.call(Array(e.indent+1)," ");else return null;return{base:i,prev:Hl.call(Array(g+1),i)}}function Nq(e,g){if(e.length===0)return"";var i=` +`+g.prev+g.base;return i+Hl.call(e,","+i)+` +`+g.prev}function Hk(e,g){var i=Hq(e),n=[];if(i){n.length=e.length;for(var I=0;I"u")return"Undefined";if(typeof g=="function"||typeof g=="object")return"Object";if(typeof g=="number")return"Number";if(typeof g=="boolean")return"Boolean";if(typeof g=="string")return"String"}),p7}var b7,$Be;function Gr(){if($Be)return b7;$Be=1;var e=L3t();return b7=function(i){return typeof i=="symbol"?"Symbol":typeof i=="bigint"?"BigInt":e(i)},b7}var U3t=ii,qBe=U3t("%TypeError%"),Q3t=D_e,j3t=Pm(),$3t=Gr(),KT=function(g,i){if($3t(g)!=="Object")throw new qBe("Assertion failed: Type(O) is not Object");if(!j3t(i))throw new qBe("Assertion failed: IsPropertyKey(P) is not true, got "+Q3t(i));return g[i]},y7,ewe;function O_e(){if(ewe)return y7;ewe=1;var e=ii,g=e("%Array%"),i=!g.isArray&&Jo("Object.prototype.toString");return y7=g.isArray||function(I){return i(I)==="[object Array]"},y7}var Z7,twe;function ese(){return twe||(twe=1,Z7=O_e()),Z7}var Nk={exports:{}},G7,gwe;function q3t(){return gwe||(gwe=1,G7=ii),G7}var v7,iwe;function tse(){if(iwe)return v7;iwe=1;var e=ii,g=qd,i=e("%TypeError%");return v7=function(I,r){if(I.Type(r)!=="Object")return!1;var o={"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0};for(var C in r)if(g(r,C)&&!o[C])return!1;if(I.IsDataDescriptor(r)&&I.IsAccessorDescriptor(r))throw new i("Property Descriptors may not be both accessor and data descriptors");return!0},v7}var B7,nwe;function J_e(){if(nwe)return B7;nwe=1;var e=hP,g=ii,i=e()&&g("%Object.defineProperty%",!0),n=e.hasArrayLengthDefineBug(),I=n&&O_e(),r=Jo,o=r("Object.prototype.propertyIsEnumerable");return B7=function(a,A,s,l,c,u){if(!i){if(!a(u)||!u["[[Configurable]]"]||!u["[[Writable]]"]||c in l&&o(l,c)!==!!u["[[Enumerable]]"])return!1;var d=u["[[Value]]"];return l[c]=d,A(l[c],d)}return n&&c==="length"&&"[[Value]]"in u&&I(l)&&l.length!==u["[[Value]]"]?(l.length=u["[[Value]]"],l.length===u["[[Value]]"]):(i(l,c,s(u)),!0)},B7}var w7,Iwe;function ezt(){if(Iwe)return w7;Iwe=1;var e=qd;return w7=function(i){return e(i,"[[StartIndex]]")&&e(i,"[[EndIndex]]")&&i["[[StartIndex]]"]>=0&&i["[[EndIndex]]"]>=i["[[StartIndex]]"]&&String(parseInt(i["[[StartIndex]]"],10))===String(i["[[StartIndex]]"])&&String(parseInt(i["[[EndIndex]]"],10))===String(i["[[EndIndex]]"])},w7}var S7,rwe;function mP(){if(rwe)return S7;rwe=1;var e=ii,g=e("%TypeError%"),i=e("%SyntaxError%"),n=qd,I=Qae(),r=ezt(),o={"Property Descriptor":function(a){var A={"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0};if(!a)return!1;for(var s in a)if(n(a,s)&&!A[s])return!1;var l=n(a,"[[Value]]"),c=n(a,"[[Get]]")||n(a,"[[Set]]");if(l&&c)throw new g("Property Descriptors may not be both accessor and data descriptors");return!0},"Match Record":r,"Iterator Record":function(a){return n(a,"[[Iterator]]")&&n(a,"[[NextMethod]]")&&n(a,"[[Done]]")},"PromiseCapability Record":function(a){return!!a&&n(a,"[[Resolve]]")&&typeof a["[[Resolve]]"]=="function"&&n(a,"[[Reject]]")&&typeof a["[[Reject]]"]=="function"&&n(a,"[[Promise]]")&&a["[[Promise]]"]&&typeof a["[[Promise]]"].then=="function"},"AsyncGeneratorRequest Record":function(a){return!!a&&n(a,"[[Completion]]")&&n(a,"[[Capability]]")&&o["PromiseCapability Record"](a["[[Capability]]"])},"RegExp Record":function(a){return a&&n(a,"[[IgnoreCase]]")&&typeof a["[[IgnoreCase]]"]=="boolean"&&n(a,"[[Multiline]]")&&typeof a["[[Multiline]]"]=="boolean"&&n(a,"[[DotAll]]")&&typeof a["[[DotAll]]"]=="boolean"&&n(a,"[[Unicode]]")&&typeof a["[[Unicode]]"]=="boolean"&&n(a,"[[CapturingGroupsCount]]")&&typeof a["[[CapturingGroupsCount]]"]=="number"&&I(a["[[CapturingGroupsCount]]"])&&a["[[CapturingGroupsCount]]"]>=0}};return S7=function(a,A,s,l){var c=o[A];if(typeof c!="function")throw new i("unknown record type: "+A);if(a(l)!=="Object"||!c(l))throw new g(s+" must be a "+A)},S7}var R7,owe;function tzt(){return owe||(owe=1,R7=function(g){if(typeof g>"u")return g;var i={};return"[[Value]]"in g&&(i.value=g["[[Value]]"]),"[[Writable]]"in g&&(i.writable=!!g["[[Writable]]"]),"[[Get]]"in g&&(i.get=g["[[Get]]"]),"[[Set]]"in g&&(i.set=g["[[Set]]"]),"[[Enumerable]]"in g&&(i.enumerable=!!g["[[Enumerable]]"]),"[[Configurable]]"in g&&(i.configurable=!!g["[[Configurable]]"]),i}),R7}var V7,Cwe;function L_e(){if(Cwe)return V7;Cwe=1;var e=mP(),g=tzt(),i=Gr();return V7=function(I){return typeof I<"u"&&e(i,"Property Descriptor","Desc",I),g(I)},V7}var W7,awe;function pP(){if(awe)return W7;awe=1;var e=qd,g=Gr(),i=mP();return W7=function(I){return!(typeof I>"u"||(i(g,"Property Descriptor","Desc",I),!e(I,"[[Get]]")&&!e(I,"[[Set]]")))},W7}var X7,swe;function bP(){if(swe)return X7;swe=1;var e=qd,g=Gr(),i=mP();return X7=function(I){return!(typeof I>"u"||(i(g,"Property Descriptor","Desc",I),!e(I,"[[Value]]")&&!e(I,"[[Writable]]")))},X7}var T7,Awe;function gse(){if(Awe)return T7;Awe=1;var e=fP;return T7=function(i,n){return i===n?i===0?1/i===1/n:!0:e(i)&&e(n)},T7}var U_e=function(g){return!!g},Q_e=Function.prototype.toString,uv=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,kq,$K;if(typeof uv=="function"&&typeof Object.defineProperty=="function")try{kq=Object.defineProperty({},"length",{get:function(){throw $K}}),$K={},uv(function(){throw 42},null,kq)}catch(e){e!==$K&&(uv=null)}else uv=null;var gzt=/^\s*class\b/,Yq=function(g){try{var i=Q_e.call(g);return gzt.test(i)}catch{return!1}},H7=function(g){try{return Yq(g)?!1:(Q_e.call(g),!0)}catch{return!1}},qK=Object.prototype.toString,izt="[object Object]",nzt="[object Function]",Izt="[object GeneratorFunction]",rzt="[object HTMLAllCollection]",ozt="[object HTML document.all class]",Czt="[object HTMLCollection]",azt=typeof Symbol=="function"&&!!Symbol.toStringTag,szt=!(0 in[,]),Kq=function(){return!1};if(typeof document=="object"){var Azt=document.all;qK.call(Azt)===qK.call(document.all)&&(Kq=function(g){if((szt||!g)&&(typeof g>"u"||typeof g=="object"))try{var i=qK.call(g);return(i===rzt||i===ozt||i===Czt||i===izt)&&g("")==null}catch{}return!1})}var ise=uv?function(g){if(Kq(g))return!0;if(!g||typeof g!="function"&&typeof g!="object")return!1;try{uv(g,null,kq)}catch(i){if(i!==$K)return!1}return!Yq(g)&&H7(g)}:function(g){if(Kq(g))return!0;if(!g||typeof g!="function"&&typeof g!="object")return!1;if(azt)return H7(g);if(Yq(g))return!1;var i=qK.call(g);return i!==nzt&&i!==Izt&&!/^\[object HTML/.test(i)?!1:H7(g)},nse=ise,N7,lwe;function j_e(){if(lwe)return N7;lwe=1;var e=qd,g=ii,i=g("%TypeError%"),n=Gr(),I=U_e,r=nse;return N7=function(C){if(n(C)!=="Object")throw new i("ToPropertyDescriptor requires an object");var a={};if(e(C,"enumerable")&&(a["[[Enumerable]]"]=I(C.enumerable)),e(C,"configurable")&&(a["[[Configurable]]"]=I(C.configurable)),e(C,"value")&&(a["[[Value]]"]=C.value),e(C,"writable")&&(a["[[Writable]]"]=I(C.writable)),e(C,"get")){var A=C.get;if(typeof A<"u"&&!r(A))throw new i("getter must be a function");a["[[Get]]"]=A}if(e(C,"set")){var s=C.set;if(typeof s<"u"&&!r(s))throw new i("setter must be a function");a["[[Set]]"]=s}if((e(a,"[[Get]]")||e(a,"[[Set]]"))&&(e(a,"[[Value]]")||e(a,"[[Writable]]")))throw new i("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return a},N7}var k7,cwe;function lzt(){if(cwe)return k7;cwe=1;var e=ii,g=e("%TypeError%"),i=tse(),n=J_e(),I=L_e(),r=pP(),o=bP(),C=Pm(),a=gse(),A=j_e(),s=Gr();return k7=function(c,u,d){if(s(c)!=="Object")throw new g("Assertion failed: Type(O) is not Object");if(!C(u))throw new g("Assertion failed: IsPropertyKey(P) is not true");var h=i({Type:s,IsDataDescriptor:o,IsAccessorDescriptor:r},d)?d:A(d);if(!i({Type:s,IsDataDescriptor:o,IsAccessorDescriptor:r},h))throw new g("Assertion failed: Desc is not a valid Property Descriptor");return n(o,a,I,c,u,h)},k7}var uwe;function czt(){if(uwe)return Nk.exports;uwe=1;var e=q3t(),g=e("%Reflect.construct%",!0),i=lzt();try{i({},"",{"[[Get]]":function(){}})}catch{i=null}if(i&&g){var n={},I={};i(I,"length",{"[[Get]]":function(){throw n},"[[Enumerable]]":!0}),Nk.exports=function(o){try{g(o,I)}catch(C){return C===n}}}else Nk.exports=function(o){return typeof o=="function"&&!!o.prototype};return Nk.exports}var $_e=ii,dwe=$_e("%Symbol.species%",!0),hwe=$_e("%TypeError%"),fwe=f3t(),mwe=KT,uzt=ese(),dzt=czt(),hzt=Gr(),fzt=Qae(),q_e=function(g,i){if(!fzt(i)||i<0)throw new hwe("Assertion failed: length must be an integer >= 0");var n=uzt(g);if(!n)return fwe(i);var I=mwe(g,"constructor");if(dwe&&hzt(I)==="Object"&&(I=mwe(I,dwe),I===null&&(I=void 0)),typeof I>"u")return fwe(i);if(!dzt(I))throw new hwe("C must be a constructor");return new I(i)},eOe=Number.MAX_SAFE_INTEGER||9007199254740991,Y7,pwe;function tOe(){if(pwe)return Y7;pwe=1;var e=ii,g=Jo,i=e("%TypeError%"),n=ese(),I=e("%Reflect.apply%",!0)||g("Function.prototype.apply");return Y7=function(o,C){var a=arguments.length>2?arguments[2]:[];if(!n(a))throw new i("Assertion failed: optional `argumentsList`, if provided, must be a List");return I(o,C,a)},Y7}var K7,bwe;function gOe(){return bwe||(bwe=1,K7=function(g){return g===null||typeof g!="function"&&typeof g!="object"}),K7}var x7,ywe;function mzt(){if(ywe)return x7;ywe=1;var e=ii,g=e("%Object.preventExtensions%",!0),i=e("%Object.isExtensible%",!0),n=gOe();return x7=g?function(r){return!n(r)&&i(r)}:function(r){return!n(r)},x7}var F7,Zwe;function pzt(){return Zwe||(Zwe=1,F7=function(g,i){return!!i&&typeof i=="object"&&"[[Enumerable]]"in i&&"[[Configurable]]"in i&&(g.IsAccessorDescriptor(i)||g.IsDataDescriptor(i))}),F7}var E7,Gwe;function bzt(){if(Gwe)return E7;Gwe=1;var e=mP(),g=pP(),i=bP(),n=Gr();return E7=function(r){return typeof r>"u"?!1:(e(n,"Property Descriptor","Desc",r),!g(r)&&!i(r))},E7}var D7,vwe;function yzt(){if(vwe)return D7;vwe=1;var e=ii,g=e("%TypeError%"),i=J_e(),n=pzt(),I=tse(),r=L_e(),o=pP(),C=bP(),a=bzt(),A=Pm(),s=gse(),l=Gr();return D7=function(u,d,h,f,m){var b=l(u);if(b!=="Undefined"&&b!=="Object")throw new g("Assertion failed: O must be undefined or an Object");if(!A(d))throw new g("Assertion failed: P must be a Property Key");if(l(h)!=="Boolean")throw new g("Assertion failed: extensible must be a Boolean");if(!I({Type:l,IsDataDescriptor:C,IsAccessorDescriptor:o},f))throw new g("Assertion failed: Desc must be a Property Descriptor");if(l(m)!=="Undefined"&&!I({Type:l,IsDataDescriptor:C,IsAccessorDescriptor:o},m))throw new g("Assertion failed: current must be a Property Descriptor, or undefined");if(l(m)==="Undefined")return h?b==="Undefined"?!0:o(f)?i(C,s,r,u,d,f):i(C,s,r,u,d,{"[[Configurable]]":!!f["[[Configurable]]"],"[[Enumerable]]":!!f["[[Enumerable]]"],"[[Value]]":f["[[Value]]"],"[[Writable]]":!!f["[[Writable]]"]}):!1;if(!n({IsAccessorDescriptor:o,IsDataDescriptor:C},m))throw new g("`current`, when present, must be a fully populated and valid Property Descriptor");if(!m["[[Configurable]]"]){if("[[Configurable]]"in f&&f["[[Configurable]]"]||"[[Enumerable]]"in f&&!s(f["[[Enumerable]]"],m["[[Enumerable]]"])||!a(f)&&!s(o(f),o(m)))return!1;if(o(m)){if("[[Get]]"in f&&!s(f["[[Get]]"],m["[[Get]]"])||"[[Set]]"in f&&!s(f["[[Set]]"],m["[[Set]]"]))return!1}else if(!m["[[Writable]]"]&&("[[Writable]]"in f&&f["[[Writable]]"]||"[[Value]]"in f&&!s(f["[[Value]]"],m["[[Value]]"])))return!1}if(b!=="Undefined"){var p,y;return C(m)&&o(f)?(p=("[[Configurable]]"in f?f:m)["[[Configurable]]"],y=("[[Enumerable]]"in f?f:m)["[[Enumerable]]"],i(C,s,r,u,d,{"[[Configurable]]":!!p,"[[Enumerable]]":!!y,"[[Get]]":("[[Get]]"in f?f:m)["[[Get]]"],"[[Set]]":("[[Set]]"in f?f:m)["[[Set]]"]})):o(m)&&C(f)?(p=("[[Configurable]]"in f?f:m)["[[Configurable]]"],y=("[[Enumerable]]"in f?f:m)["[[Enumerable]]"],i(C,s,r,u,d,{"[[Configurable]]":!!p,"[[Enumerable]]":!!y,"[[Value]]":("[[Value]]"in f?f:m)["[[Value]]"],"[[Writable]]":!!("[[Writable]]"in f?f:m)["[[Writable]]"]})):i(C,s,r,u,d,f)}return!0},D7}var M7,Bwe;function Zzt(){if(Bwe)return M7;Bwe=1;var e=ii,g=Lae,i=e("%SyntaxError%"),n=e("%TypeError%"),I=tse(),r=pP(),o=bP(),C=mzt(),a=Pm(),A=j_e(),s=gse(),l=Gr(),c=yzt();return M7=function(d,h,f){if(l(d)!=="Object")throw new n("Assertion failed: O must be an Object");if(!a(h))throw new n("Assertion failed: P must be a Property Key");if(!I({Type:l,IsDataDescriptor:o,IsAccessorDescriptor:r},f))throw new n("Assertion failed: Desc must be a Property Descriptor");if(!g){if(r(f))throw new i("This environment does not support accessor property descriptors.");var m=!(h in d)&&f["[[Writable]]"]&&f["[[Enumerable]]"]&&f["[[Configurable]]"]&&"[[Value]]"in f,b=h in d&&(!("[[Configurable]]"in f)||f["[[Configurable]]"])&&(!("[[Enumerable]]"in f)||f["[[Enumerable]]"])&&(!("[[Writable]]"in f)||f["[[Writable]]"])&&"[[Value]]"in f;if(m||b)return d[h]=f["[[Value]]"],s(d[h],f["[[Value]]"]);throw new i("This environment does not support defining non-writable, non-enumerable, or non-configurable properties")}var p=g(d,h),y=p&&A(p),Z=C(d);return c(d,h,Z,f,y)},M7}var z7,wwe;function Gzt(){if(wwe)return z7;wwe=1;var e=ii,g=e("%TypeError%"),i=Pm(),n=Zzt(),I=Gr();return z7=function(o,C,a){if(I(o)!=="Object")throw new g("Assertion failed: Type(O) is not Object");if(!i(C))throw new g("Assertion failed: IsPropertyKey(P) is not true");var A={"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Value]]":a,"[[Writable]]":!0};return n(o,C,A)},z7}var P7,Swe;function iOe(){if(Swe)return P7;Swe=1;var e=ii,g=e("%TypeError%"),i=Gzt(),n=Pm(),I=Gr();return P7=function(o,C,a){if(I(o)!=="Object")throw new g("Assertion failed: Type(O) is not Object");if(!n(C))throw new g("Assertion failed: IsPropertyKey(P) is not true");var A=i(o,C,a);if(!A)throw new g("unable to create data property")},P7}var _7,Rwe;function nOe(){if(Rwe)return _7;Rwe=1;var e=ii,g=e("%TypeError%"),i=Pm(),n=Gr();return _7=function(r,o){if(n(r)!=="Object")throw new g("Assertion failed: `O` must be an Object");if(!i(o))throw new g("Assertion failed: `P` must be a Property Key");return o in r},_7}var O7,Vwe;function vzt(){return Vwe||(Vwe=1,O7=function(g){return g===null||typeof g!="function"&&typeof g!="object"}),O7}var Bzt=Oae,xT=function(){return Bzt()&&!!Symbol.toStringTag},J7,Wwe;function wzt(){if(Wwe)return J7;Wwe=1;var e=Date.prototype.getDay,g=function(o){try{return e.call(o),!0}catch{return!1}},i=Object.prototype.toString,n="[object Date]",I=xT();return J7=function(o){return typeof o!="object"||o===null?!1:I?g(o):i.call(o)===n},J7}var kk={exports:{}},Xwe;function Szt(){if(Xwe)return kk.exports;Xwe=1;var e=Object.prototype.toString,g=Z_e();if(g){var i=Symbol.prototype.toString,n=/^Symbol\(.*\)$/,I=function(o){return typeof o.valueOf()!="symbol"?!1:n.test(i.call(o))};kk.exports=function(o){if(typeof o=="symbol")return!0;if(e.call(o)!=="[object Symbol]")return!1;try{return I(o)}catch{return!1}}}else kk.exports=function(o){return!1};return kk.exports}var L7,Twe;function Rzt(){if(Twe)return L7;Twe=1;var e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol",g=vzt(),i=ise,n=wzt(),I=Szt(),r=function(a,A){if(typeof a>"u"||a===null)throw new TypeError("Cannot call method on "+a);if(typeof A!="string"||A!=="number"&&A!=="string")throw new TypeError('hint must be "string" or "number"');var s=A==="string"?["toString","valueOf"]:["valueOf","toString"],l,c,u;for(u=0;u1&&(arguments[1]===String?A="string":arguments[1]===Number&&(A="number"));var s;if(e&&(Symbol.toPrimitive?s=o(a,Symbol.toPrimitive):I(a)&&(s=Symbol.prototype.valueOf)),typeof s<"u"){var l=s.call(a,A);if(g(l))return l;throw new TypeError("unable to convert exotic object to primitive")}return A==="default"&&(n(a)||I(a))&&(A="string"),r(a,A==="default"?"number":A)},L7}var U7,Hwe;function Vzt(){if(Hwe)return U7;Hwe=1;var e=Rzt();return U7=function(i){return arguments.length>1?e(i,arguments[1]):e(i)},U7}var xq=Jo,IOe=xT(),rOe,oOe,Fq,Eq;if(IOe){rOe=xq("Object.prototype.hasOwnProperty"),oOe=xq("RegExp.prototype.exec"),Fq={};var Q7=function(){throw Fq};Eq={toString:Q7,valueOf:Q7},typeof Symbol.toPrimitive=="symbol"&&(Eq[Symbol.toPrimitive]=Q7)}var Wzt=xq("Object.prototype.toString"),Xzt=Object.getOwnPropertyDescriptor,Tzt="[object RegExp]",COe=IOe?function(g){if(!g||typeof g!="object")return!1;var i=Xzt(g,"lastIndex"),n=i&&rOe(i,"value");if(!n)return!1;try{oOe(g,Eq)}catch(I){return I===Fq}}:function(g){return!g||typeof g!="object"&&typeof g!="function"?!1:Wzt(g)===Tzt},j7,Nwe;function Hzt(){if(Nwe)return j7;Nwe=1;var e=Jo,g=ii,i=COe,n=e("RegExp.prototype.exec"),I=g("%TypeError%");return j7=function(o){if(!i(o))throw new I("`regex` must be a RegExp");return function(a){return n(o,a)!==null}},j7}var Nzt=ii,kzt=Nzt("%TypeError%"),Yzt=function(g,i){if(g==null)throw new kzt(i||"Cannot call method on "+g);return g},Y1=Yzt,aOe=ii,Kzt=aOe("%String%"),xzt=aOe("%TypeError%"),Ise=function(g){if(typeof g=="symbol")throw new xzt("Cannot convert a Symbol value to a string");return Kzt(g)},Fzt=Y1,Ezt=Ise,Dzt=Jo,kwe=Dzt("String.prototype.replace"),sOe=/^\s$/.test("᠎"),Mzt=sOe?/^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/:/^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/,zzt=sOe?/[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+$/:/[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+$/,AOe=function(){var g=Ezt(Fzt(this));return kwe(kwe(g,Mzt,""),zzt,"")},Pzt=AOe,Ywe="​",UZ="᠎",lOe=function(){return String.prototype.trim&&Ywe.trim()===Ywe&&UZ.trim()===UZ&&("_"+UZ).trim()==="_"+UZ&&(UZ+"_").trim()===UZ+"_"?String.prototype.trim:Pzt},_zt=Io,Ozt=lOe,Jzt=function(){var g=Ozt();return _zt(String.prototype,{trim:g},{trim:function(){return String.prototype.trim!==g}}),g},Lzt=eh,Uzt=Io,Qzt=Y1,jzt=AOe,cOe=lOe,$zt=Jzt,qzt=Lzt(cOe()),uOe=function(g){return Qzt(g),qzt(g)};Uzt(uOe,{getPolyfill:cOe,implementation:jzt,shim:$zt});var dOe=uOe,$7,Kwe;function ePt(){if(Kwe)return $7;Kwe=1;var e=ii,g=e("%Number%"),i=e("%RegExp%"),n=e("%TypeError%"),I=e("%parseInt%"),r=Jo,o=Hzt(),C=r("String.prototype.slice"),a=o(/^0b[01]+$/i),A=o(/^0o[0-7]+$/i),s=o(/^[-+]0x[0-9a-f]+$/i),l=["…","​","￾"].join(""),c=new i("["+l+"]","g"),u=o(c),d=dOe,h=Gr();return $7=function f(m){if(h(m)!=="String")throw new n("Assertion failed: `argument` is not a String");if(a(m))return g(I(C(m,2),2));if(A(m))return g(I(C(m,2),8));if(u(m)||s(m))return NaN;var b=d(m);return b!==m?f(b):g(m)},$7}var hOe=ii,xwe=hOe("%TypeError%"),Fwe=hOe("%Number%"),tPt=gOe(),gPt=Vzt(),iPt=ePt(),nPt=function(g){var i=tPt(g)?g:gPt(g,Fwe);if(typeof i=="symbol")throw new xwe("Cannot convert a Symbol value to a number");if(typeof i=="bigint")throw new xwe("Conversion from 'BigInt' to 'number' is not allowed.");return typeof i=="string"?iPt(i):Fwe(i)},IPt=Gr(),rPt=Math.floor,oPt=function(g){return IPt(g)==="BigInt"?g:rPt(g)},CPt=ii,Ewe=oPt,aPt=CPt("%TypeError%"),sPt=function(g){if(typeof g!="number"&&typeof g!="bigint")throw new aPt("argument must be a Number or a BigInt");var i=g<0?-Ewe(-g):Ewe(g);return i===0?0:i},APt=nPt,lPt=sPt,cPt=fP,uPt=x_e,fOe=function(g){var i=APt(g);return cPt(i)||i===0?0:uPt(i)?lPt(i):i},Dwe=eOe,dPt=fOe,mOe=function(g){var i=dPt(g);return i<=0?0:i>Dwe?Dwe:i},q7,Mwe;function pOe(){if(Mwe)return q7;Mwe=1;var e=ii,g=e("%TypeError%"),i=KT,n=mOe,I=Gr();return q7=function(o){if(I(o)!=="Object")throw new g("Assertion failed: `obj` must be an Object");return n(i(o,"length"))},q7}var hPt=ii,zwe=hPt("%TypeError%"),fPt=eOe,mPt=tOe(),pPt=iOe(),bPt=KT,yPt=nOe(),ZPt=ese(),GPt=pOe(),Pwe=Ise,vPt=function e(g,i,n,I,r){var o;arguments.length>5&&(o=arguments[5]);for(var C=I,a=0;a0&&(c=ZPt(l)),c){var u=GPt(l);C=e(g,l,u,C,r-1)}else{if(C>=fPt)throw new zwe("index too large");pPt(g,Pwe(C),l),C+=1}}a+=1}return C},BPt=ii,wPt=BPt("%Object%"),SPt=Y1,bOe=function(g){return SPt(g),wPt(g)},RPt=q_e,VPt=vPt,WPt=KT,XPt=fOe,TPt=mOe,HPt=bOe,yOe=function(){var g=HPt(this),i=TPt(WPt(g,"length")),n=1;arguments.length>0&&typeof arguments[0]<"u"&&(n=XPt(arguments[0]));var I=RPt(g,0);return VPt(I,g,i,0,n),I},NPt=yOe,ZOe=function(){return Array.prototype.flat||NPt},eQ,_we;function kPt(){if(_we)return eQ;_we=1;var e=qd,g=typeof Symbol=="function"&&typeof Symbol.unscopables=="symbol",i=g&&Array.prototype[Symbol.unscopables],n=TypeError;return eQ=function(r){if(typeof r!="string"||!r)throw new n("method must be a non-empty string");if(!e(Array.prototype,r))throw new n("method must be on Array.prototype");g&&(i[r]=!0)},eQ}var tQ,Owe;function YPt(){if(Owe)return tQ;Owe=1;var e=Io,g=kPt(),i=ZOe;return tQ=function(){var I=i();return e(Array.prototype,{flat:I},{flat:function(){return Array.prototype.flat!==I}}),g("flat"),I},tQ}var KPt=Io,xPt=eh,FPt=yOe,GOe=ZOe,EPt=GOe(),DPt=YPt(),vOe=xPt(EPt);KPt(vOe,{getPolyfill:GOe,implementation:FPt,shim:DPt});var FT=vOe,Jwe={}.hasOwnProperty,gQ=Function.prototype.call,K1=gQ.bind?gQ.bind(Jwe):function(e,g){return gQ.call(Jwe,e,g)},ET={},Dq={exports:{}},Lwe=function(e){return e!==e},BOe=function(g,i){return g===0&&i===0?1/g===1/i:!!(g===i||Lwe(g)&&Lwe(i))},MPt=BOe,wOe=function(){return typeof Object.is=="function"?Object.is:MPt},zPt=wOe,PPt=Io,_Pt=function(){var g=zPt();return PPt(Object,{is:g},{is:function(){return Object.is!==g}}),g},OPt=Io,JPt=eh,LPt=BOe,SOe=wOe,UPt=_Pt,ROe=JPt(SOe(),Object);OPt(ROe,{getPolyfill:SOe,implementation:LPt,shim:UPt});var rse=ROe;(function(e,g){Object.defineProperty(g,"__esModule",{value:!0}),g.default=o;var i=I(rse),n=I(K1);function I(C){return C&&C.__esModule?C:{default:C}}function r(C){return r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},r(C)}function o(C,a){if((0,i.default)(C,a))return!0;if(!C||!a||r(C)!=="object"||r(a)!=="object")return!1;var A=Object.keys(C),s=Object.keys(a);if(A.length!==s.length)return!1;A.sort(),s.sort();for(var l=0;l"u"||typeof g=="object"))try{var i=iQ(g);return(i===b_t||i===p_t)&&g("")==null}catch{}return!1})}var DOe=function(){if(EOe(this)||!h_t(this)&&!KOe(this))throw new TypeError("Function.prototype.name sham getter called on non-function");if(u_t&&c_t(this,"name"))return this.name;if(this===y_t)return"";var g=xOe(this),i=FOe(g,f_t),n=i&&i[1];return n},G_t=DOe,MOe=function(){return G_t},v_t=Io.supportsDescriptors,B_t=YOe(),w_t=MOe,Qwe=Object.defineProperty,S_t=TypeError,R_t=function(){var g=w_t();if(B_t)return g;if(!v_t)throw new S_t("Shimming Function.prototype.name support requires ES5 property descriptor support.");var i=Function.prototype;return Qwe(i,"name",{configurable:!0,enumerable:!1,get:function(){var n=g.call(this);return this!==i&&Qwe(this,"name",{configurable:!0,enumerable:!1,value:n,writable:!1}),n}}),g},V_t=Io,W_t=eh,zOe=DOe,X_t=MOe,T_t=R_t,POe=W_t(zOe);V_t(POe,{getPolyfill:X_t,implementation:zOe,shim:T_t});var Cse=POe,_Oe={},OOe={};Object.defineProperty(OOe,"__esModule",{value:!0});var yP={},x1={},UF=Qe&&Qe.__assign||function(){return UF=Object.assign||function(e){for(var g,i=1,n=arguments.length;i0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"childNodes",{get:function(){return this.children},set:function(i){this.children=i},enumerable:!1,configurable:!0}),g}(ase);Kg.NodeWithChildren=GP;var QOe=function(e){_m(g,e);function g(){var i=e!==null&&e.apply(this,arguments)||this;return i.type=RC.ElementType.CDATA,i}return Object.defineProperty(g.prototype,"nodeType",{get:function(){return 4},enumerable:!1,configurable:!0}),g}(GP);Kg.CDATA=QOe;var jOe=function(e){_m(g,e);function g(){var i=e!==null&&e.apply(this,arguments)||this;return i.type=RC.ElementType.Root,i}return Object.defineProperty(g.prototype,"nodeType",{get:function(){return 9},enumerable:!1,configurable:!0}),g}(GP);Kg.Document=jOe;var $Oe=function(e){_m(g,e);function g(i,n,I,r){I===void 0&&(I=[]),r===void 0&&(r=i==="script"?RC.ElementType.Script:i==="style"?RC.ElementType.Style:RC.ElementType.Tag);var o=e.call(this,I)||this;return o.name=i,o.attribs=n,o.type=r,o}return Object.defineProperty(g.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"tagName",{get:function(){return this.name},set:function(i){this.name=i},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"attributes",{get:function(){var i=this;return Object.keys(this.attribs).map(function(n){var I,r;return{name:n,value:i.attribs[n],namespace:(I=i["x-attribsNamespace"])===null||I===void 0?void 0:I[n],prefix:(r=i["x-attribsPrefix"])===null||r===void 0?void 0:r[n]}})},enumerable:!1,configurable:!0}),g}(GP);Kg.Element=$Oe;function qOe(e){return(0,RC.isTag)(e)}Kg.isTag=qOe;function eJe(e){return e.type===RC.ElementType.CDATA}Kg.isCDATA=eJe;function tJe(e){return e.type===RC.ElementType.Text}Kg.isText=tJe;function gJe(e){return e.type===RC.ElementType.Comment}Kg.isComment=gJe;function iJe(e){return e.type===RC.ElementType.Directive}Kg.isDirective=iJe;function nJe(e){return e.type===RC.ElementType.Root}Kg.isDocument=nJe;function k_t(e){return Object.prototype.hasOwnProperty.call(e,"children")}Kg.hasChildren=k_t;function sse(e,g){g===void 0&&(g=!1);var i;if(tJe(e))i=new JOe(e.data);else if(gJe(e))i=new LOe(e.data);else if(qOe(e)){var n=g?nQ(e.children):[],I=new $Oe(e.name,U2({},e.attribs),n);n.forEach(function(a){return a.parent=I}),e.namespace!=null&&(I.namespace=e.namespace),e["x-attribsNamespace"]&&(I["x-attribsNamespace"]=U2({},e["x-attribsNamespace"])),e["x-attribsPrefix"]&&(I["x-attribsPrefix"]=U2({},e["x-attribsPrefix"])),i=I}else if(eJe(e)){var n=g?nQ(e.children):[],r=new QOe(n);n.forEach(function(A){return A.parent=r}),i=r}else if(nJe(e)){var n=g?nQ(e.children):[],o=new jOe(n);n.forEach(function(A){return A.parent=o}),e["x-mode"]&&(o["x-mode"]=e["x-mode"]),i=o}else if(iJe(e)){var C=new UOe(e.name,e.data);e["x-name"]!=null&&(C["x-name"]=e["x-name"],C["x-publicId"]=e["x-publicId"],C["x-systemId"]=e["x-systemId"]),i=C}else throw new Error("Not implemented yet: ".concat(e.type));return i.startIndex=e.startIndex,i.endIndex=e.endIndex,e.sourceCodeLocation!=null&&(i.sourceCodeLocation=e.sourceCodeLocation),i}Kg.cloneNode=sse;function nQ(e){for(var g=e.map(function(n){return sse(n,!0)}),i=1;i䀾mmaĀ;d׷׸䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇܎ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ޷޼߂ߐĀiyޱ޵rc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄΀HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶߻dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣ঳সে্਷ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗ࡜ࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४Ānrࢃ࢏gleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpw৔ਖਛgȀLRlr৞৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼੝੠੷੼અઋ઎p;椅y;䐜Ādl੥੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑ඗ඞcy;䐊cute;䅃ƀaey઴હાron;䅇dil;䅅;䐝ƀgswે૰଎ativeƀMTV૓૟૨ediumSpace;怋hiĀcn૦૘ë૙eryThiî૙tedĀGL૸ଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷ଺reak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪୼஡௫ఄ౞಄ದ೘ൡඅ櫬Āou୛୤ngruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊ஛ement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater΀;EFGLSTஶஷ஽௉௓௘௥扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲௽ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ೒拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨೹setĀ;E೰ೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂ෉෕ෛ෠෧෼ขภยา฿ไlig;䅒cute耻Ó䃓Āiy෎ීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲ෶cr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬื฼de耻Õ䃕es;樷ml耻Ö䃖erĀBP๋๠Āar๐๓r;怾acĀek๚๜;揞et;掴arenthesis;揜Ҁacfhilors๿ງຊຏຒດຝະ໼rtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ໠໤檻cedesȀ;EST່້໏໚扺qual;檯lantEqual;扼ilde;找me;怳Ādp໩໮uct;戏ortionĀ;aȥ໹l;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬؀BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁࿫࿳ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL࿜࿝࿡憒ar;懥eftArrow;懄eiling;按oǵ࿹\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»࿝pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄ቉ቕ቞ቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHc቎ቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗Āeiቻ኉Dzኀ\0ኇefore;戴a;䎘Ācn኎ኘkSpace;쀀  Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0᏿ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0጖y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻፿on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtè૙a;䎖r;愨pf;愤cr;쀀𝒵௡ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚΀;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒΀;Eaeiop዁ᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;e዁ᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;e዁ᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰ᜼ᝃᝈ᝸᝽០៦ᠹᡐᜍ᤽᥈ᥰot;櫭Ācrᛶ᜞kȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e᜚᜛戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;t፜᜷brk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓ᝛ᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯ᝱ᝳ;䎲;愶een;扬r;쀀𝔟g΀costuvwឍឝឳេ៕៛៞ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀako៭ᠦᠵĀcn៲ᠣkƀlst៺֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘᠝斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈؀DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬ᣿ᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教΀;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ᣷᣹᣻᣽;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ᤟;敛;敘;攘;攔΀;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģ᥂bar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;e᜚᜜lƀ;bhᥨᥩᥫ䁜;槅sub;柈Ŭᥴ᥾lĀ;e᥹᥺怢t»᥺pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭍᭒\0᯽\0ᰌƀcpr᦭ᦲ᧝ute;䄇̀;abcdsᦿᧀᧄ᧊᧕᧙戩nd;橄rcup;橉Āau᧏᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r΀;Ecefms᩟᩠ᩢᩫ᪤᪪᪮旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖᪚᪟»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇᫔᫺\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ᫙\0\0᫢aĀ;t᫞᫟䀬;䁀ƀ;fl᫨᫩᫫戁îᅠeĀmx᫱᫶ent»᫩eóɍǧ᫾\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯΀delprvw᭠᭬᭷ᮂᮬᯔ᯹arrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;p᭿ᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰸᰻᰿ᱝᱩᱵᲊᲞᲬᲷ᳻᳿ᴍᵻᶑᶫᶻ᷆᷍rò΁ar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂͸᳖᳜᳠mƀ;oș᳊᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄ὎὚ĀDoḆᴴoôᲉĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»Ṻƀaeiἒ἖Ἒls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙ῜ῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao‌⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧‪‬\0‮耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₟₥₰₴⃰⃵⃺⃿℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕ₝ute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽⃉ƀ;qsؾٌ⃄lanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqr׮ⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0↎proø₞r;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢␧␭␱␵␻ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀஀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼rò৆òΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonó྘quigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d྘➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ᠛旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐௏쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop඄⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roø඄urĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓΀;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨í஘istĀ;s஠டr;쀀𝔫ȀEest௅⩦⩹⩼ƀ;qs஼⩭௡ƀ;qs஼௅⩴lanô௢ií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚΀AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs఻⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs఻⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast୻⭕⭚⭟lleì୻l;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖ΀chimpqu⮽⯍⯙⬄୸⯤⯯Ȁ;cerല⯆ഷ⯉uå൅;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭å೸åഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñ೗Ā;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰⳴ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥ⵲ⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;c᪞ⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācr⵩⵭ir;榿;쀀𝔬ͯ⵹\0\0⵼\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕ⶘ⶥⶨrò᪀Āir⶝ⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔ⷗ǒr;榷rp;榹΀;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ⹞\0⹽\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ⹧⹲຅脀¶;l⹭⹮䂶leìЃɩ⹸\0\0⹻m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳⻴ᤈ⻹⻽⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp໬⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t໻⾴ï໻rel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⿚⋢⿟⿥⿫⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei⿾々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔઀ABHabcdefhilmnoprstux぀けさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤΀cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstw࿜ガクシスゼゾダッデナp;極Ā;f࿠ゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes㄂㄄;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ì࿲âヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘㇤㇮rrowĀ;t࿜ㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowó࿪arpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓rò࿪aòՑ;怏oustĀ;a㈞㈟掱che»㈟mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦΀Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼਴t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì⹯耻­䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;q኱ኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫ਩war;椪lig耻ß䃟௡㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rë๟ƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproø዁im»ኬsðኞĀas㚺㚮ð዁rn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈ΀adempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xô᝷headĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜΀eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roð໻tré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚΀cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜ៟tré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map(function(e){return e.charCodeAt(0)}));var lse={};Object.defineProperty(lse,"__esModule",{value:!0});lse.default=new Uint16Array("Ȁaglq \x1Bɭ\0\0p;䀦os;䀧t;䀾t;䀼uot;䀢".split("").map(function(e){return e.charCodeAt(0)}));var Mq={};(function(e){var g;Object.defineProperty(e,"__esModule",{value:!0}),e.replaceCodePoint=e.fromCodePoint=void 0;var i=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]);e.fromCodePoint=(g=String.fromCodePoint)!==null&&g!==void 0?g:function(r){var o="";return r>65535&&(r-=65536,o+=String.fromCharCode(r>>>10&1023|55296),r=56320|r&1023),o+=String.fromCharCode(r),o};function n(r){var o;return r>=55296&&r<=57343||r>1114111?65533:(o=i.get(r))!==null&&o!==void 0?o:r}e.replaceCodePoint=n;function I(r){return(0,e.fromCodePoint)(n(r))}e.default=I})(Mq);(function(e){var g=Qe&&Qe.__createBinding||(Object.create?function(w,T,W,V){V===void 0&&(V=W);var X=Object.getOwnPropertyDescriptor(T,W);(!X||("get"in X?!T.__esModule:X.writable||X.configurable))&&(X={enumerable:!0,get:function(){return T[W]}}),Object.defineProperty(w,V,X)}:function(w,T,W,V){V===void 0&&(V=W),w[V]=T[W]}),i=Qe&&Qe.__setModuleDefault||(Object.create?function(w,T){Object.defineProperty(w,"default",{enumerable:!0,value:T})}:function(w,T){w.default=T}),n=Qe&&Qe.__importStar||function(w){if(w&&w.__esModule)return w;var T={};if(w!=null)for(var W in w)W!=="default"&&Object.prototype.hasOwnProperty.call(w,W)&&g(T,w,W);return i(T,w),T},I=Qe&&Qe.__importDefault||function(w){return w&&w.__esModule?w:{default:w}};Object.defineProperty(e,"__esModule",{value:!0}),e.decodeXML=e.decodeHTMLStrict=e.decodeHTMLAttribute=e.decodeHTML=e.determineBranch=e.EntityDecoder=e.DecodingMode=e.BinTrieFlags=e.fromCodePoint=e.replaceCodePoint=e.decodeCodePoint=e.xmlDecodeTree=e.htmlDecodeTree=void 0;var r=I(Ase);e.htmlDecodeTree=r.default;var o=I(lse);e.xmlDecodeTree=o.default;var C=n(Mq);e.decodeCodePoint=C.default;var a=Mq;Object.defineProperty(e,"replaceCodePoint",{enumerable:!0,get:function(){return a.replaceCodePoint}}),Object.defineProperty(e,"fromCodePoint",{enumerable:!0,get:function(){return a.fromCodePoint}});var A;(function(w){w[w.NUM=35]="NUM",w[w.SEMI=59]="SEMI",w[w.EQUALS=61]="EQUALS",w[w.ZERO=48]="ZERO",w[w.NINE=57]="NINE",w[w.LOWER_A=97]="LOWER_A",w[w.LOWER_F=102]="LOWER_F",w[w.LOWER_X=120]="LOWER_X",w[w.LOWER_Z=122]="LOWER_Z",w[w.UPPER_A=65]="UPPER_A",w[w.UPPER_F=70]="UPPER_F",w[w.UPPER_Z=90]="UPPER_Z"})(A||(A={}));var s=32,l;(function(w){w[w.VALUE_LENGTH=49152]="VALUE_LENGTH",w[w.BRANCH_LENGTH=16256]="BRANCH_LENGTH",w[w.JUMP_TABLE=127]="JUMP_TABLE"})(l=e.BinTrieFlags||(e.BinTrieFlags={}));function c(w){return w>=A.ZERO&&w<=A.NINE}function u(w){return w>=A.UPPER_A&&w<=A.UPPER_F||w>=A.LOWER_A&&w<=A.LOWER_F}function d(w){return w>=A.UPPER_A&&w<=A.UPPER_Z||w>=A.LOWER_A&&w<=A.LOWER_Z||c(w)}function h(w){return w===A.EQUALS||d(w)}var f;(function(w){w[w.EntityStart=0]="EntityStart",w[w.NumericStart=1]="NumericStart",w[w.NumericDecimal=2]="NumericDecimal",w[w.NumericHex=3]="NumericHex",w[w.NamedEntity=4]="NamedEntity"})(f||(f={}));var m;(function(w){w[w.Legacy=0]="Legacy",w[w.Strict=1]="Strict",w[w.Attribute=2]="Attribute"})(m=e.DecodingMode||(e.DecodingMode={}));var b=function(){function w(T,W,V){this.decodeTree=T,this.emitCodePoint=W,this.errors=V,this.state=f.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=m.Strict}return w.prototype.startEntity=function(T){this.decodeMode=T,this.state=f.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1},w.prototype.write=function(T,W){switch(this.state){case f.EntityStart:return T.charCodeAt(W)===A.NUM?(this.state=f.NumericStart,this.consumed+=1,this.stateNumericStart(T,W+1)):(this.state=f.NamedEntity,this.stateNamedEntity(T,W));case f.NumericStart:return this.stateNumericStart(T,W);case f.NumericDecimal:return this.stateNumericDecimal(T,W);case f.NumericHex:return this.stateNumericHex(T,W);case f.NamedEntity:return this.stateNamedEntity(T,W)}},w.prototype.stateNumericStart=function(T,W){return W>=T.length?-1:(T.charCodeAt(W)|s)===A.LOWER_X?(this.state=f.NumericHex,this.consumed+=1,this.stateNumericHex(T,W+1)):(this.state=f.NumericDecimal,this.stateNumericDecimal(T,W))},w.prototype.addToNumericResult=function(T,W,V,X){if(W!==V){var N=V-W;this.result=this.result*Math.pow(X,N)+parseInt(T.substr(W,N),X),this.consumed+=N}},w.prototype.stateNumericHex=function(T,W){for(var V=W;W>14;W>14,N!==0){if(Y===A.SEMI)return this.emitNamedEntityData(this.treeIndex,N,this.consumed+this.excess);this.decodeMode!==m.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1},w.prototype.emitNotTerminatedNamedEntity=function(){var T,W=this,V=W.result,X=W.decodeTree,N=(X[V]&l.VALUE_LENGTH)>>14;return this.emitNamedEntityData(V,N,this.consumed),(T=this.errors)===null||T===void 0||T.missingSemicolonAfterCharacterReference(),this.consumed},w.prototype.emitNamedEntityData=function(T,W,V){var X=this.decodeTree;return this.emitCodePoint(W===1?X[T]&~l.VALUE_LENGTH:X[T+1],V),W===3&&this.emitCodePoint(X[T+2],V),V},w.prototype.end=function(){var T;switch(this.state){case f.NamedEntity:return this.result!==0&&(this.decodeMode!==m.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case f.NumericDecimal:return this.emitNumericEntity(0,2);case f.NumericHex:return this.emitNumericEntity(0,3);case f.NumericStart:return(T=this.errors)===null||T===void 0||T.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case f.EntityStart:return 0}},w}();e.EntityDecoder=b;function p(w){var T="",W=new b(w,function(V){return T+=(0,C.fromCodePoint)(V)});return function(X,N){for(var Y=0,x=0;(x=X.indexOf("&",x))>=0;){T+=X.slice(Y,x),W.startEntity(N);var M=W.write(X,x+1);if(M<0){Y=x+W.end();break}Y=x+M,x=M===0?Y+1:Y}var F=T+X.slice(Y);return T="",F}}function y(w,T,W,V){var X=(T&l.BRANCH_LENGTH)>>7,N=T&l.JUMP_TABLE;if(X===0)return N!==0&&V===N?W:-1;if(N){var Y=V-N;return Y<0||Y>=X?-1:w[W+Y]-1}for(var x=W,M=x+X-1;x<=M;){var F=x+M>>>1,$=w[F];if($V)M=F-1;else return w[F+X]}return-1}e.determineBranch=y;var Z=p(r.default),v=p(o.default);function G(w,T){return T===void 0&&(T=m.Legacy),Z(w,T)}e.decodeHTML=G;function B(w){return Z(w,m.Attribute)}e.decodeHTMLAttribute=B;function S(w){return Z(w,m.Strict)}e.decodeHTMLStrict=S;function R(w){return v(w,m.Strict)}e.decodeXML=R})(Kb);var xb={},cse={};Object.defineProperty(cse,"__esModule",{value:!0});function Yk(e){for(var g=1;g$\x80-\uFFFF]/g;var g=new Map([[34,"""],[38,"&"],[39,"'"],[60,"<"],[62,">"]]);e.getCodePoint=String.prototype.codePointAt!=null?function(I,r){return I.codePointAt(r)}:function(I,r){return(I.charCodeAt(r)&64512)===55296?(I.charCodeAt(r)-55296)*1024+I.charCodeAt(r+1)-56320+65536:I.charCodeAt(r)};function i(I){for(var r="",o=0,C;(C=e.xmlReplacer.exec(I))!==null;){var a=C.index,A=I.charCodeAt(a),s=g.get(A);s!==void 0?(r+=I.substring(o,a)+s,o=a+1):(r+="".concat(I.substring(o,a),"&#x").concat((0,e.getCodePoint)(I,a).toString(16),";"),o=e.xmlReplacer.lastIndex+=+((A&64512)===55296))}return r+I.substr(o)}e.encodeXML=i,e.escape=i;function n(I,r){return function(C){for(var a,A=0,s="";a=I.exec(C);)A!==a.index&&(s+=C.substring(A,a.index)),s+=r.get(a[0].charCodeAt(0)),A=a.index+1;return s+C.substring(A)}}e.escapeUTF8=n(/[&<>'"]/g,g),e.escapeAttribute=n(/["&\u00A0]/g,new Map([[34,"""],[38,"&"],[160," "]])),e.escapeText=n(/[&<>\u00A0]/g,new Map([[38,"&"],[60,"<"],[62,">"],[160," "]]))})(nw);var Y_t=Qe&&Qe.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(xb,"__esModule",{value:!0});xb.encodeNonAsciiHTML=xb.encodeHTML=void 0;var K_t=Y_t(cse),rJe=nw,x_t=/[\t\n!-,./:-@[-`\f{-}$\x80-\uFFFF]/g;function F_t(e){return oJe(x_t,e)}xb.encodeHTML=F_t;function E_t(e){return oJe(rJe.xmlReplacer,e)}xb.encodeNonAsciiHTML=E_t;function oJe(e,g){for(var i="",n=0,I;(I=e.exec(g))!==null;){var r=I.index;i+=g.substring(n,r);var o=g.charCodeAt(r),C=K_t.default.get(o);if(typeof C=="object"){if(r+10&&(n+=vP(e.children,g)),(g.xmlMode||!$we.has(e.name))&&(n+=""))),n}function j_t(e){return"<".concat(e.data,">")}function $_t(e,g){var i,n=e.data||"";return((i=g.encodeEntities)!==null&&i!==void 0?i:g.decodeEntities)!==!1&&!(!g.xmlMode&&e.parent&&P_t.has(e.parent.name))&&(n=g.xmlMode||g.encodeEntities!=="utf8"?(0,QF.encodeXML)(n):(0,QF.escapeText)(n)),n}function q_t(e){return"")}function eOt(e){return"")}var tOt=Qe&&Qe.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ia,"__esModule",{value:!0});Ia.innerText=Ia.textContent=Ia.getText=Ia.getInnerHTML=Ia.getOuterHTML=void 0;var cc=go,gOt=tOt(E1),iOt=F1;function aJe(e,g){return(0,gOt.default)(e,g)}Ia.getOuterHTML=aJe;function nOt(e,g){return(0,cc.hasChildren)(e)?e.children.map(function(i){return aJe(i,g)}).join(""):""}Ia.getInnerHTML=nOt;function e5(e){return Array.isArray(e)?e.map(e5).join(""):(0,cc.isTag)(e)?e.name==="br"?` +`:e5(e.children):(0,cc.isCDATA)(e)?e5(e.children):(0,cc.isText)(e)?e.data:""}Ia.getText=e5;function zq(e){return Array.isArray(e)?e.map(zq).join(""):(0,cc.hasChildren)(e)&&!(0,cc.isComment)(e)?zq(e.children):(0,cc.isText)(e)?e.data:""}Ia.textContent=zq;function Pq(e){return Array.isArray(e)?e.map(Pq).join(""):(0,cc.hasChildren)(e)&&(e.type===iOt.ElementType.Tag||(0,cc.isCDATA)(e))?Pq(e.children):(0,cc.isText)(e)?e.data:""}Ia.innerText=Pq;var YI={};Object.defineProperty(YI,"__esModule",{value:!0});YI.prevElementSibling=YI.nextElementSibling=YI.getName=YI.hasAttrib=YI.getAttributeValue=YI.getSiblings=YI.getParent=YI.getChildren=void 0;var use=go;function sJe(e){return(0,use.hasChildren)(e)?e.children:[]}YI.getChildren=sJe;function AJe(e){return e.parent||null}YI.getParent=AJe;function IOt(e){var g,i,n=AJe(e);if(n!=null)return sJe(n);for(var I=[e],r=e.prev,o=e.next;r!=null;)I.unshift(r),g=r,r=g.prev;for(;o!=null;)I.push(o),i=o,o=i.next;return I}YI.getSiblings=IOt;function rOt(e,g){var i;return(i=e.attribs)===null||i===void 0?void 0:i[g]}YI.getAttributeValue=rOt;function oOt(e,g){return e.attribs!=null&&Object.prototype.hasOwnProperty.call(e.attribs,g)&&e.attribs[g]!=null}YI.hasAttrib=oOt;function COt(e){return e.name}YI.getName=COt;function aOt(e){for(var g,i=e.next;i!==null&&!(0,use.isTag)(i);)g=i,i=g.next;return i}YI.nextElementSibling=aOt;function sOt(e){for(var g,i=e.prev;i!==null&&!(0,use.isTag)(i);)g=i,i=g.prev;return i}YI.prevElementSibling=sOt;var cC={};Object.defineProperty(cC,"__esModule",{value:!0});cC.prepend=cC.prependChild=cC.append=cC.appendChild=cC.replaceElement=cC.removeElement=void 0;function DT(e){if(e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),e.parent){var g=e.parent.children,i=g.lastIndexOf(e);i>=0&&g.splice(i,1)}e.next=null,e.prev=null,e.parent=null}cC.removeElement=DT;function AOt(e,g){var i=g.prev=e.prev;i&&(i.next=g);var n=g.next=e.next;n&&(n.prev=g);var I=g.parent=e.parent;if(I){var r=I.children;r[r.lastIndexOf(e)]=g,e.parent=null}}cC.replaceElement=AOt;function lOt(e,g){if(DT(g),g.next=null,g.parent=e,e.children.push(g)>1){var i=e.children[e.children.length-2];i.next=g,g.prev=i}else g.prev=null}cC.appendChild=lOt;function cOt(e,g){DT(g);var i=e.parent,n=e.next;if(g.next=n,g.prev=e,e.next=g,g.parent=i,n){if(n.prev=g,i){var I=i.children;I.splice(I.lastIndexOf(n),0,g)}}else i&&i.children.push(g)}cC.append=cOt;function uOt(e,g){if(DT(g),g.parent=e,g.prev=null,e.children.unshift(g)!==1){var i=e.children[1];i.prev=g,g.next=i}else g.next=null}cC.prependChild=uOt;function dOt(e,g){DT(g);var i=e.parent;if(i){var n=i.children;n.splice(n.indexOf(e),0,g)}e.prev&&(e.prev.next=g),g.parent=i,g.prev=e.prev,g.next=e,e.prev=g}cC.prepend=dOt;var mo={};Object.defineProperty(mo,"__esModule",{value:!0});mo.findAll=mo.existsOne=mo.findOne=mo.findOneChild=mo.find=mo.filter=void 0;var BP=go;function hOt(e,g,i,n){return i===void 0&&(i=!0),n===void 0&&(n=1/0),lJe(e,Array.isArray(g)?g:[g],i,n)}mo.filter=hOt;function lJe(e,g,i,n){for(var I=[],r=[g],o=[0];;){if(o[0]>=r[0].length){if(o.length===1)return I;r.shift(),o.shift();continue}var C=r[0][o[0]++];if(e(C)&&(I.push(C),--n<=0))return I;i&&(0,BP.hasChildren)(C)&&C.children.length>0&&(o.unshift(0),r.unshift(C.children))}}mo.find=lJe;function fOt(e,g){return g.find(e)}mo.findOneChild=fOt;function cJe(e,g,i){i===void 0&&(i=!0);for(var n=null,I=0;I0&&(n=cJe(e,r.children,!0));else continue}return n}mo.findOne=cJe;function uJe(e,g){return g.some(function(i){return(0,BP.isTag)(i)&&(e(i)||uJe(e,i.children))})}mo.existsOne=uJe;function mOt(e,g){for(var i=[],n=[g],I=[0];;){if(I[0]>=n[0].length){if(n.length===1)return i;n.shift(),I.shift();continue}var r=n[0][I[0]++];(0,BP.isTag)(r)&&(e(r)&&i.push(r),r.children.length>0&&(I.unshift(0),n.unshift(r.children)))}}mo.findAll=mOt;var ra={};Object.defineProperty(ra,"__esModule",{value:!0});ra.getElementsByTagType=ra.getElementsByTagName=ra.getElementById=ra.getElements=ra.testElement=void 0;var a0=go,wP=mo,jF={tag_name:function(e){return typeof e=="function"?function(g){return(0,a0.isTag)(g)&&e(g.name)}:e==="*"?a0.isTag:function(g){return(0,a0.isTag)(g)&&g.name===e}},tag_type:function(e){return typeof e=="function"?function(g){return e(g.type)}:function(g){return g.type===e}},tag_contains:function(e){return typeof e=="function"?function(g){return(0,a0.isText)(g)&&e(g.data)}:function(g){return(0,a0.isText)(g)&&g.data===e}}};function dJe(e,g){return typeof g=="function"?function(i){return(0,a0.isTag)(i)&&g(i.attribs[e])}:function(i){return(0,a0.isTag)(i)&&i.attribs[e]===g}}function pOt(e,g){return function(i){return e(i)||g(i)}}function hJe(e){var g=Object.keys(e).map(function(i){var n=e[i];return Object.prototype.hasOwnProperty.call(jF,i)?jF[i](n):dJe(i,n)});return g.length===0?null:g.reduce(pOt)}function bOt(e,g){var i=hJe(e);return i?i(g):!0}ra.testElement=bOt;function yOt(e,g,i,n){n===void 0&&(n=1/0);var I=hJe(e);return I?(0,wP.filter)(I,g,i,n):[]}ra.getElements=yOt;function ZOt(e,g,i){return i===void 0&&(i=!0),Array.isArray(g)||(g=[g]),(0,wP.findOne)(dJe("id",e),g,i)}ra.getElementById=ZOt;function GOt(e,g,i,n){return i===void 0&&(i=!0),n===void 0&&(n=1/0),(0,wP.filter)(jF.tag_name(e),g,i,n)}ra.getElementsByTagName=GOt;function vOt(e,g,i,n){return i===void 0&&(i=!0),n===void 0&&(n=1/0),(0,wP.filter)(jF.tag_type(e),g,i,n)}ra.getElementsByTagType=vOt;var fJe={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.uniqueSort=e.compareDocumentPosition=e.DocumentPosition=e.removeSubsets=void 0;var g=go;function i(o){for(var C=o.length;--C>=0;){var a=o[C];if(C>0&&o.lastIndexOf(a,C-1)>=0){o.splice(C,1);continue}for(var A=a.parent;A;A=A.parent)if(o.includes(A)){o.splice(C,1);break}}return o}e.removeSubsets=i;var n;(function(o){o[o.DISCONNECTED=1]="DISCONNECTED",o[o.PRECEDING=2]="PRECEDING",o[o.FOLLOWING=4]="FOLLOWING",o[o.CONTAINS=8]="CONTAINS",o[o.CONTAINED_BY=16]="CONTAINED_BY"})(n=e.DocumentPosition||(e.DocumentPosition={}));function I(o,C){var a=[],A=[];if(o===C)return 0;for(var s=(0,g.hasChildren)(o)?o:o.parent;s;)a.unshift(s),s=s.parent;for(s=(0,g.hasChildren)(C)?C:C.parent;s;)A.unshift(s),s=s.parent;for(var l=Math.min(a.length,A.length),c=0;cd.indexOf(f)?u===C?n.FOLLOWING|n.CONTAINED_BY:n.FOLLOWING:u===o?n.PRECEDING|n.CONTAINS:n.PRECEDING}e.compareDocumentPosition=I;function r(o){return o=o.filter(function(C,a,A){return!A.includes(C,a+1)}),o.sort(function(C,a){var A=I(C,a);return A&n.PRECEDING?-1:A&n.FOLLOWING?1:0}),o}e.uniqueSort=r})(fJe);var SP={};Object.defineProperty(SP,"__esModule",{value:!0});SP.getFeed=void 0;var BOt=Ia,MT=ra;function wOt(e){var g=$F(XOt,e);return g?g.name==="feed"?SOt(g):ROt(g):null}SP.getFeed=wOt;function SOt(e){var g,i=e.children,n={type:"atom",items:(0,MT.getElementsByTagName)("entry",i).map(function(o){var C,a=o.children,A={media:mJe(a)};sC(A,"id","id",a),sC(A,"title","title",a);var s=(C=$F("link",a))===null||C===void 0?void 0:C.attribs.href;s&&(A.link=s);var l=vf("summary",a)||vf("content",a);l&&(A.description=l);var c=vf("updated",a);return c&&(A.pubDate=new Date(c)),A})};sC(n,"id","id",i),sC(n,"title","title",i);var I=(g=$F("link",i))===null||g===void 0?void 0:g.attribs.href;I&&(n.link=I),sC(n,"description","subtitle",i);var r=vf("updated",i);return r&&(n.updated=new Date(r)),sC(n,"author","email",i,!0),n}function ROt(e){var g,i,n=(i=(g=$F("channel",e.children))===null||g===void 0?void 0:g.children)!==null&&i!==void 0?i:[],I={type:e.name.substr(0,3),id:"",items:(0,MT.getElementsByTagName)("item",e.children).map(function(o){var C=o.children,a={media:mJe(C)};sC(a,"id","guid",C),sC(a,"title","title",C),sC(a,"link","link",C),sC(a,"description","description",C);var A=vf("pubDate",C)||vf("dc:date",C);return A&&(a.pubDate=new Date(A)),a})};sC(I,"title","title",n),sC(I,"link","link",n),sC(I,"description","description",n);var r=vf("lastBuildDate",n);return r&&(I.updated=new Date(r)),sC(I,"author","managingEditor",n,!0),I}var VOt=["url","type","lang"],WOt=["fileSize","bitrate","framerate","samplingrate","channels","duration","height","width"];function mJe(e){return(0,MT.getElementsByTagName)("media:content",e).map(function(g){for(var i=g.attribs,n={medium:i.medium,isDefault:!!i.isDefault},I=0,r=VOt;Is.length-3)return!1;var c=s.charCodeAt(l+1);return(c>=a.LowerA&&c<=a.LowerZ||c>=a.UpperA&&c<=a.UpperZ||c===a.Exclamation)&&s.includes(">",l+2)}e.isHtml=A})(Om);Object.defineProperty(tI,"__esModule",{value:!0});tI.toggleClass=tI.removeClass=tI.addClass=tI.hasClass=tI.removeAttr=tI.val=tI.data=tI.prop=tI.attr=void 0;var bJe=Qn,pi=Om,e1e=kA,Lv=Object.prototype.hasOwnProperty,jX=/\s+/,IQ="data-",t1e={null:null,true:!0,false:!1},dse=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,POt=/^{[^]*}$|^\[[^]*]$/;function qF(e,g,i){var n;if(!(!e||!(0,pi.isTag)(e))){if((n=e.attribs)!==null&&n!==void 0||(e.attribs={}),!g)return e.attribs;if(Lv.call(e.attribs,g))return!i&&dse.test(g)?g:e.attribs[g];if(e.name==="option"&&g==="value")return(0,bJe.text)(e.children);if(e.name==="input"&&(e.attribs.type==="radio"||e.attribs.type==="checkbox")&&g==="value")return"on"}}function Uv(e,g,i){i===null?yJe(e,g):e.attribs[g]="".concat(i)}function _Ot(e,g){if(typeof e=="object"||g!==void 0){if(typeof g=="function"){if(typeof e!="string")throw new Error("Bad combination of arguments.");return(0,pi.domEach)(this,function(i,n){(0,pi.isTag)(i)&&Uv(i,e,g.call(i,n,i.attribs[e]))})}return(0,pi.domEach)(this,function(i){(0,pi.isTag)(i)&&(typeof e=="object"?Object.keys(e).forEach(function(n){var I=e[n];Uv(i,n,I)}):Uv(i,e,g))})}return arguments.length>1?this:qF(this[0],e,this.options.xmlMode)}tI.attr=_Ot;function g1e(e,g,i){return g in e?e[g]:!i&&dse.test(g)?qF(e,g,!1)!==void 0:qF(e,g,i)}function rQ(e,g,i,n){g in e?e[g]=i:Uv(e,g,!n&&dse.test(g)?i?"":null:"".concat(i))}function OOt(e,g){var i=this,n;if(typeof e=="string"&&g===void 0){var I=this[0];if(!I||!(0,pi.isTag)(I))return;switch(e){case"style":{var r=this.css(),o=Object.keys(r);return o.forEach(function(a,A){r[A]=a}),r.length=o.length,r}case"tagName":case"nodeName":return I.name.toUpperCase();case"href":case"src":{var C=(n=I.attribs)===null||n===void 0?void 0:n[e];return typeof URL<"u"&&(e==="href"&&(I.tagName==="a"||I.name==="link")||e==="src"&&(I.tagName==="img"||I.tagName==="iframe"||I.tagName==="audio"||I.tagName==="video"||I.tagName==="source"))&&C!==void 0&&this.options.baseURI?new URL(C,this.options.baseURI).href:C}case"innerText":return(0,e1e.innerText)(I);case"textContent":return(0,e1e.textContent)(I);case"outerHTML":return this.clone().wrap("").parent().html();case"innerHTML":return this.html();default:return g1e(I,e,this.options.xmlMode)}}if(typeof e=="object"||g!==void 0){if(typeof g=="function"){if(typeof e=="object")throw new Error("Bad combination of arguments.");return(0,pi.domEach)(this,function(a,A){(0,pi.isTag)(a)&&rQ(a,e,g.call(a,A,g1e(a,e,i.options.xmlMode)),i.options.xmlMode)})}return(0,pi.domEach)(this,function(a){(0,pi.isTag)(a)&&(typeof e=="object"?Object.keys(e).forEach(function(A){var s=e[A];rQ(a,A,s,i.options.xmlMode)}):rQ(a,e,g,i.options.xmlMode))})}}tI.prop=OOt;function i1e(e,g,i){var n,I=e;(n=I.data)!==null&&n!==void 0||(I.data={}),typeof g=="object"?Object.assign(I.data,g):typeof g=="string"&&i!==void 0&&(I.data[g]=i)}function n1e(e,g){var i,n,I;g==null?(i=Object.keys(e.attribs).filter(function(a){return a.startsWith(IQ)}),n=i.map(function(a){return(0,pi.camelCase)(a.slice(IQ.length))})):(i=[IQ+(0,pi.cssCase)(g)],n=[g]);for(var r=0;r-1;){var I=n+e.length;if((n===0||jX.test(i[n-1]))&&(I===i.length||jX.test(i[I])))return!0}return!1})}tI.hasClass=QOt;function ZJe(e){if(typeof e=="function")return(0,pi.domEach)(this,function(A,s){if((0,pi.isTag)(A)){var l=A.attribs.class||"";ZJe.call([A],e.call(A,s,l))}});if(!e||typeof e!="string")return this;for(var g=e.split(jX),i=this.length,n=0;n=0&&(r.splice(a,1),o=!0,C--)}o&&(I.attribs.class=r.join(" "))}})}tI.removeClass=GJe;function vJe(e,g){if(typeof e=="function")return(0,pi.domEach)(this,function(l,c){(0,pi.isTag)(l)&&vJe.call([l],e.call(l,c,l.attribs.class||"",g),g)});if(!e||typeof e!="string")return this;for(var i=e.split(jX),n=i.length,I=typeof g=="boolean"?g?1:-1:0,r=this.length,o=0;o=0&&s<0?a.push(i[A]):I<=0&&s>=0&&a.splice(s,1)}C.attribs.class=a.join(" ")}}return this}tI.toggleClass=vJe;var Et={},BJe={},Pg;(function(e){e.Attribute="attribute",e.Pseudo="pseudo",e.PseudoElement="pseudo-element",e.Tag="tag",e.Universal="universal",e.Adjacent="adjacent",e.Child="child",e.Descendant="descendant",e.Parent="parent",e.Sibling="sibling",e.ColumnCombinator="column-combinator"})(Pg||(Pg={}));const jOt={Unknown:null,QuirksMode:"quirks",IgnoreCase:!0,CaseSensitive:!1};var ln;(function(e){e.Any="any",e.Element="element",e.End="end",e.Equals="equals",e.Exists="exists",e.Hyphen="hyphen",e.Not="not",e.Start="start"})(ln||(ln={}));const I1e=/^[^\\#]?(?:\\(?:[\da-f]{1,6}\s?|.)|[\w\-\u00b0-\uFFFF])+/,$Ot=/\\([\da-f]{1,6}\s?|(\s)|.)/gi,qOt=new Map([[126,ln.Element],[94,ln.Start],[36,ln.End],[42,ln.Any],[33,ln.Not],[124,ln.Hyphen]]),eJt=new Set(["has","not","matches","is","where","host","host-context"]);function wJe(e){switch(e.type){case Pg.Adjacent:case Pg.Child:case Pg.Descendant:case Pg.Parent:case Pg.Sibling:case Pg.ColumnCombinator:return!0;default:return!1}}const tJt=new Set(["contains","icontains"]);function gJt(e,g,i){const n=parseInt(g,16)-65536;return n!==n||i?g:n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,n&1023|56320)}function bR(e){return e.replace($Ot,gJt)}function oQ(e){return e===39||e===34}function r1e(e){return e===32||e===9||e===10||e===12||e===13}function iJt(e){const g=[],i=SJe(g,`${e}`,0);if(i0&&i0&&wJe(n[n.length-1]))throw new Error("Did not expect successive traversals.")}function A(c){if(n.length>0&&n[n.length-1].type===Pg.Descendant){n[n.length-1].type=c;return}a(),n.push({type:c})}function s(c,u){n.push({type:Pg.Attribute,name:c,action:u,value:I(1),namespace:null,ignoreCase:"quirks"})}function l(){if(n.length&&n[n.length-1].type===Pg.Descendant&&n.pop(),n.length===0)throw new Error("Empty sub-selector");e.push(n)}if(r(0),g.length===i)return i;e:for(;ie.charCodeAt(0))),o1e=new Set(VJe.map(e=>e.charCodeAt(0))),hv=new Set([...VJe,"~","^","$","*","+","!","|",":","[","]"," ","."].map(e=>e.charCodeAt(0)));function WJe(e){return e.map(g=>g.map(IJt).join("")).join(", ")}function IJt(e,g,i){switch(e.type){case Pg.Child:return g===0?"> ":" > ";case Pg.Parent:return g===0?"< ":" < ";case Pg.Sibling:return g===0?"~ ":" ~ ";case Pg.Adjacent:return g===0?"+ ":" + ";case Pg.Descendant:return" ";case Pg.ColumnCombinator:return g===0?"|| ":" || ";case Pg.Universal:return e.namespace==="*"&&g+10?n+e.slice(i):e}const oJt=Object.freeze(Object.defineProperty({__proto__:null,get AttributeAction(){return ln},IgnoreCaseMode:jOt,get SelectorType(){return Pg},isTraversal:wJe,parse:iJt,stringify:WJe},Symbol.toStringTag,{value:"Module"})),zT=Ud(oJt);var Oq={},$y={trueFunc:function(){return!0},falseFunc:function(){return!1}},Qf={},D1={};Object.defineProperty(D1,"__esModule",{value:!0});D1.isTraversal=void 0;var ga=zT,TJe=new Map([[ga.SelectorType.Universal,50],[ga.SelectorType.Tag,30],[ga.SelectorType.Attribute,1],[ga.SelectorType.Pseudo,0]]);function CJt(e){return!TJe.has(e.type)}D1.isTraversal=CJt;var aJt=new Map([[ga.AttributeAction.Exists,10],[ga.AttributeAction.Equals,8],[ga.AttributeAction.Not,7],[ga.AttributeAction.Start,6],[ga.AttributeAction.End,6],[ga.AttributeAction.Any,5]]);function sJt(e){for(var g=e.map(HJe),i=1;i=0&&n>=1)):e.type===ga.SelectorType.Pseudo&&(e.data?e.name==="has"||e.name==="contains"?n=0:Array.isArray(e.data)?(n=Math.min.apply(Math,e.data.map(function(I){return Math.min.apply(Math,I.map(HJe))})),n<0&&(n=0)):n=2:n=3),n}var VP={},WP={},AJt=Qe&&Qe.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(WP,"__esModule",{value:!0});WP.attributeRules=void 0;var Kk=AJt($y),lJt=/[-[\]{}()*+?.,\\^$|#\s]/g;function a1e(e){return e.replace(lJt,"\\$&")}var cJt=new Set(["accept","accept-charset","align","alink","axis","bgcolor","charset","checked","clear","codetype","color","compact","declare","defer","dir","direction","disabled","enctype","face","frame","hreflang","http-equiv","lang","language","link","media","method","multiple","nohref","noresize","noshade","nowrap","readonly","rel","rev","rules","scope","scrolling","selected","shape","target","text","type","valign","valuetype","vlink"]);function Rp(e,g){return typeof e.ignoreCase=="boolean"?e.ignoreCase:e.ignoreCase==="quirks"?!!g.quirksMode:!g.xmlMode&&cJt.has(e.name)}WP.attributeRules={equals:function(e,g,i){var n=i.adapter,I=g.name,r=g.value;return Rp(g,i)?(r=r.toLowerCase(),function(o){var C=n.getAttributeValue(o,I);return C!=null&&C.length===r.length&&C.toLowerCase()===r&&e(o)}):function(o){return n.getAttributeValue(o,I)===r&&e(o)}},hyphen:function(e,g,i){var n=i.adapter,I=g.name,r=g.value,o=r.length;return Rp(g,i)?(r=r.toLowerCase(),function(a){var A=n.getAttributeValue(a,I);return A!=null&&(A.length===o||A.charAt(o)==="-")&&A.substr(0,o).toLowerCase()===r&&e(a)}):function(a){var A=n.getAttributeValue(a,I);return A!=null&&(A.length===o||A.charAt(o)==="-")&&A.substr(0,o)===r&&e(a)}},element:function(e,g,i){var n=i.adapter,I=g.name,r=g.value;if(/\s/.test(r))return Kk.default.falseFunc;var o=new RegExp("(?:^|\\s)".concat(a1e(r),"(?:$|\\s)"),Rp(g,i)?"i":"");return function(a){var A=n.getAttributeValue(a,I);return A!=null&&A.length>=r.length&&o.test(A)&&e(a)}},exists:function(e,g,i){var n=g.name,I=i.adapter;return function(r){return I.hasAttrib(r,n)&&e(r)}},start:function(e,g,i){var n=i.adapter,I=g.name,r=g.value,o=r.length;return o===0?Kk.default.falseFunc:Rp(g,i)?(r=r.toLowerCase(),function(C){var a=n.getAttributeValue(C,I);return a!=null&&a.length>=o&&a.substr(0,o).toLowerCase()===r&&e(C)}):function(C){var a;return!!(!((a=n.getAttributeValue(C,I))===null||a===void 0)&&a.startsWith(r))&&e(C)}},end:function(e,g,i){var n=i.adapter,I=g.name,r=g.value,o=-r.length;return o===0?Kk.default.falseFunc:Rp(g,i)?(r=r.toLowerCase(),function(C){var a;return((a=n.getAttributeValue(C,I))===null||a===void 0?void 0:a.substr(o).toLowerCase())===r&&e(C)}):function(C){var a;return!!(!((a=n.getAttributeValue(C,I))===null||a===void 0)&&a.endsWith(r))&&e(C)}},any:function(e,g,i){var n=i.adapter,I=g.name,r=g.value;if(r==="")return Kk.default.falseFunc;if(Rp(g,i)){var o=new RegExp(a1e(r),"i");return function(a){var A=n.getAttributeValue(a,I);return A!=null&&A.length>=r.length&&o.test(A)&&e(a)}}return function(C){var a;return!!(!((a=n.getAttributeValue(C,I))===null||a===void 0)&&a.includes(r))&&e(C)}},not:function(e,g,i){var n=i.adapter,I=g.name,r=g.value;return r===""?function(o){return!!n.getAttributeValue(o,I)&&e(o)}:Rp(g,i)?(r=r.toLowerCase(),function(o){var C=n.getAttributeValue(o,I);return(C==null||C.length!==r.length||C.toLowerCase()!==r)&&e(o)}):function(o){return n.getAttributeValue(o,I)!==r&&e(o)}}};var hse={},NJe={},kJe={},XP={};Object.defineProperty(XP,"__esModule",{value:!0});XP.parse=void 0;var uJt=new Set([9,10,12,13,32]),s1e="0".charCodeAt(0),dJt="9".charCodeAt(0);function hJt(e){if(e=e.trim().toLowerCase(),e==="even")return[2,0];if(e==="odd")return[2,1];var g=0,i=0,n=r(),I=o();if(g=s1e&&e.charCodeAt(g)<=dJt;)A=A*10+(e.charCodeAt(g)-s1e),g++;return g===a?null:A}function C(){for(;g=i};var n=Math.abs(g),I=(i%n+n)%n;return g>1?function(r){return r>=i&&r%n===I}:function(r){return r<=i&&r%n===I}}rw.compile=mJt;function pJt(e){var g=e[0],i=e[1]-1,n=0;if(g<0){var I=-g,r=(i%I+I)%I;return function(){var o=r+I*n++;return o>i?null:o}}return g===0?i<0?function(){return null}:function(){return n++===0?i:null}:(i<0&&(i+=g*Math.ceil(-i/g)),function(){return g*n+++i})}rw.generate=pJt;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.sequence=e.generate=e.compile=e.parse=void 0;var g=XP;Object.defineProperty(e,"parse",{enumerable:!0,get:function(){return g.parse}});var i=rw;Object.defineProperty(e,"compile",{enumerable:!0,get:function(){return i.compile}}),Object.defineProperty(e,"generate",{enumerable:!0,get:function(){return i.generate}});function n(r){return(0,i.compile)((0,g.parse)(r))}e.default=n;function I(r){return(0,i.generate)((0,g.parse)(r))}e.sequence=I})(kJe);(function(e){var g=Qe&&Qe.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(e,"__esModule",{value:!0}),e.filters=void 0;var i=g(kJe),n=g($y);function I(o,C){return function(a){var A=C.getParent(a);return A!=null&&C.isTag(A)&&o(a)}}e.filters={contains:function(o,C,a){var A=a.adapter;return function(l){return o(l)&&A.getText(l).includes(C)}},icontains:function(o,C,a){var A=a.adapter,s=C.toLowerCase();return function(c){return o(c)&&A.getText(c).toLowerCase().includes(s)}},"nth-child":function(o,C,a){var A=a.adapter,s=a.equals,l=(0,i.default)(C);return l===n.default.falseFunc?n.default.falseFunc:l===n.default.trueFunc?I(o,A):function(u){for(var d=A.getSiblings(u),h=0,f=0;f=0&&!s(u,d[f]);f--)A.isTag(d[f])&&h++;return l(h)&&o(u)}},"nth-of-type":function(o,C,a){var A=a.adapter,s=a.equals,l=(0,i.default)(C);return l===n.default.falseFunc?n.default.falseFunc:l===n.default.trueFunc?I(o,A):function(u){for(var d=A.getSiblings(u),h=0,f=0;f=0;f--){var m=d[f];if(s(u,m))break;A.isTag(m)&&A.getName(m)===A.getName(u)&&h++}return l(h)&&o(u)}},root:function(o,C,a){var A=a.adapter;return function(s){var l=A.getParent(s);return(l==null||!A.isTag(l))&&o(s)}},scope:function(o,C,a,A){var s=a.equals;return!A||A.length===0?e.filters.root(o,C,a):A.length===1?function(l){return s(A[0],l)&&o(l)}:function(l){return A.includes(l)&&o(l)}},hover:r("isHovered"),visited:r("isVisited"),active:r("isActive")};function r(o){return function(a,A,s){var l=s.adapter,c=l[o];return typeof c!="function"?n.default.falseFunc:function(d){return c(d)&&a(d)}}}})(NJe);var ow={};Object.defineProperty(ow,"__esModule",{value:!0});ow.verifyPseudoArgs=ow.pseudos=void 0;ow.pseudos={empty:function(e,g){var i=g.adapter;return!i.getChildren(e).some(function(n){return i.isTag(n)||i.getText(n)!==""})},"first-child":function(e,g){var i=g.adapter,n=g.equals;if(i.prevElementSibling)return i.prevElementSibling(e)==null;var I=i.getSiblings(e).find(function(r){return i.isTag(r)});return I!=null&&n(e,I)},"last-child":function(e,g){for(var i=g.adapter,n=g.equals,I=i.getSiblings(e),r=I.length-1;r>=0;r--){if(n(e,I[r]))return!0;if(i.isTag(I[r]))break}return!1},"first-of-type":function(e,g){for(var i=g.adapter,n=g.equals,I=i.getSiblings(e),r=i.getName(e),o=0;o=0;o--){var C=I[o];if(n(e,C))return!0;if(i.isTag(C)&&i.getName(C)===r)break}return!1},"only-of-type":function(e,g){var i=g.adapter,n=g.equals,I=i.getName(e);return i.getSiblings(e).every(function(r){return n(e,r)||!i.isTag(r)||i.getName(r)!==I})},"only-child":function(e,g){var i=g.adapter,n=g.equals;return i.getSiblings(e).every(function(I){return n(e,I)||!i.isTag(I)})}};function bJt(e,g,i,n){if(i===null){if(e.length>n)throw new Error("Pseudo-class :".concat(g," requires an argument"))}else if(e.length===n)throw new Error("Pseudo-class :".concat(g," doesn't have any arguments"))}ow.verifyPseudoArgs=bJt;var TP={};Object.defineProperty(TP,"__esModule",{value:!0});TP.aliases=void 0;TP.aliases={"any-link":":is(a, area, link)[href]",link:":any-link:not(:visited)",disabled:`:is( + :is(button, input, select, textarea, optgroup, option)[disabled], + optgroup[disabled] > option, + fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *) + )`,enabled:":not(:disabled)",checked:":is(:is(input[type=radio], input[type=checkbox])[checked], option:selected)",required:":is(input, select, textarea)[required]",optional:":is(input, select, textarea):not([required])",selected:"option:is([selected], select:not([multiple]):not(:has(> option[selected])) > :first-of-type)",checkbox:"[type=checkbox]",file:"[type=file]",password:"[type=password]",radio:"[type=radio]",reset:"[type=reset]",image:"[type=image]",submit:"[type=submit]",parent:":not(:empty)",header:":is(h1, h2, h3, h4, h5, h6)",button:":is(button, input[type=button])",input:":is(input, textarea, select, button)",text:"input:is(:not([type!='']), [type=text])"};var HP={};(function(e){var g=Qe&&Qe.__spreadArray||function(A,s,l){if(l||arguments.length===2)for(var c=0,u=s.length,d;c"u")return function(s){for(var l=s;l=CQ(l,r);)if(e(l))return!0;return!1};var a=new WeakSet;return function(s){for(var l=s;l=CQ(l,r);)if(!a.has(l)){if(r.isTag(l)&&e(l))return!0;a.add(l)}return!1}}case"_flexibleDescendant":return function(s){var l=s;do if(e(l))return!0;while(l=CQ(l,r));return!1};case Hs.SelectorType.Parent:return function(s){return r.getChildren(s).some(function(l){return r.isTag(l)&&e(l)})};case Hs.SelectorType.Child:return function(s){var l=r.getParent(s);return l!=null&&r.isTag(l)&&e(l)};case Hs.SelectorType.Sibling:return function(s){for(var l=r.getSiblings(s),c=0;c0&&(0,Jq.isTraversal)(C[0])&&C[0].type!==$u.SelectorType.Descendant))if(I&&!C.some(xJe))C.unshift(WJt);else continue;C.unshift(TJt)}}function fse(e,g,i){var n;e.forEach(Jq.default),i=(n=g.context)!==null&&n!==void 0?n:i;var I=Array.isArray(i),r=i&&(Array.isArray(i)?i:[i]);if(g.relativeSelector!==!1)HJt(e,g,r);else if(e.some(function(a){return a.length>0&&(0,Jq.isTraversal)(a[0])}))throw new Error("Relative selectors are not allowed when the `relativeSelector` option is disabled");var o=!1,C=e.map(function(a){if(a.length>=2){var A=a[0],s=a[1];A.type!==$u.SelectorType.Pseudo||A.name!=="scope"||(I&&s.type===$u.SelectorType.Descendant?a[1]=XJt:(s.type===$u.SelectorType.Adjacent||s.type===$u.SelectorType.Sibling)&&(o=!0))}return NJt(a,g,r)}).reduce(kJt,Bf.default.falseFunc);return C.shouldTestNextSiblings=o,C}Qf.compileToken=fse;function NJt(e,g,i){var n;return e.reduce(function(I,r){return I===Bf.default.falseFunc?Bf.default.falseFunc:(0,RJt.compileGeneralSelector)(I,r,g,i,fse)},(n=g.rootFunc)!==null&&n!==void 0?n:Bf.default.trueFunc)}function kJt(e,g){return g===Bf.default.falseFunc||e===Bf.default.trueFunc?e:e===Bf.default.falseFunc||g===Bf.default.trueFunc?g:function(n){return e(n)||g(n)}}(function(e){var g=Qe&&Qe.__createBinding||(Object.create?function(b,p,y,Z){Z===void 0&&(Z=y);var v=Object.getOwnPropertyDescriptor(p,y);(!v||("get"in v?!p.__esModule:v.writable||v.configurable))&&(v={enumerable:!0,get:function(){return p[y]}}),Object.defineProperty(b,Z,v)}:function(b,p,y,Z){Z===void 0&&(Z=y),b[Z]=p[y]}),i=Qe&&Qe.__setModuleDefault||(Object.create?function(b,p){Object.defineProperty(b,"default",{enumerable:!0,value:p})}:function(b,p){b.default=p}),n=Qe&&Qe.__importStar||function(b){if(b&&b.__esModule)return b;var p={};if(b!=null)for(var y in b)y!=="default"&&Object.prototype.hasOwnProperty.call(b,y)&&g(p,b,y);return i(p,b),p},I=Qe&&Qe.__importDefault||function(b){return b&&b.__esModule?b:{default:b}};Object.defineProperty(e,"__esModule",{value:!0}),e.aliases=e.pseudos=e.filters=e.is=e.selectOne=e.selectAll=e.prepareContext=e._compileToken=e._compileUnsafe=e.compile=void 0;var r=n(kA),o=I($y),C=Qf,a=HP,A=function(b,p){return b===p},s={adapter:r,equals:A};function l(b){var p,y,Z,v,G=b??s;return(p=G.adapter)!==null&&p!==void 0||(G.adapter=r),(y=G.equals)!==null&&y!==void 0||(G.equals=(v=(Z=G.adapter)===null||Z===void 0?void 0:Z.equals)!==null&&v!==void 0?v:A),G}function c(b){return function(y,Z,v){var G=l(Z);return b(y,G,v)}}e.compile=c(C.compile),e._compileUnsafe=c(C.compileUnsafe),e._compileToken=c(C.compileToken);function u(b){return function(y,Z,v){var G=l(v);typeof y!="function"&&(y=(0,C.compileUnsafe)(y,G,Z));var B=d(Z,G.adapter,y.shouldTestNextSiblings);return b(y,B,G)}}function d(b,p,y){return y===void 0&&(y=!1),y&&(b=h(b,p)),Array.isArray(b)?p.removeSubsets(b):p.getChildren(b)}e.prepareContext=d;function h(b,p){for(var y=Array.isArray(b)?b.slice(0):[b],Z=y.length,v=0;v=0?o+1:1/0:0;case"lt":return isFinite(o)?o>=0?Math.min(o,r):1/0:0;case"gt":return isFinite(o)?1/0:0;case"odd":return 2*r;case"even":return 2*r-1;case"last":case"not":return 1/0}}e.getLimit=i})(mse);Object.defineProperty(Cw,"__esModule",{value:!0});Cw.groupSelectors=Cw.getDocumentRoot=void 0;var YJt=mse;function KJt(e){for(;e.parent;)e=e.parent;return e}Cw.getDocumentRoot=KJt;function xJt(e){for(var g=[],i=[],n=0,I=e;n0&&R.some((0,C._compileToken)(V,T))||X.some(function(N){return y(N,R,T).length>0})}e.some=f;function m(R,w,T,W){var V=typeof T=="string"?parseInt(T,10):NaN;switch(R){case"first":case"lt":return w;case"last":return w.length>0?[w[w.length-1]]:w;case"nth":case"eq":return isFinite(V)&&Math.abs(V)1&&o.length>1?i.reduce(function(C,a){return a(C)},o):o)}}}var PT=pse(function(e,g){for(var i,n=[],I=0;I0})}Et.has=$Jt;function qJt(){return this.length>1?this._make(this[0]):this}Et.first=qJt;function eLt(){return this.length>0?this._make(this[this.length-1]):this}Et.last=eLt;function tLt(e){var g;return e=+e,e===0&&this.length<=1?this:(e<0&&(e=this.length+e),this._make((g=this[e])!==null&&g!==void 0?g:[]))}Et.eq=tLt;function gLt(e){return e==null?this.toArray():this[e<0?this.length+e:e]}Et.get=gLt;function iLt(){return Array.prototype.slice.call(this)}Et.toArray=iLt;function nLt(e){var g,i;return e==null?(g=this.parent().children(),i=this[0]):typeof e=="string"?(g=this._make(e),i=this[0]):(g=this,i=(0,_A.isCheerio)(e)?e[0]:e),Array.prototype.indexOf.call(g,i)}Et.index=nLt;function ILt(e,g){return this._make(Array.prototype.slice.call(this,e,g))}Et.slice=ILt;function rLt(){var e;return(e=this.prevObject)!==null&&e!==void 0?e:this._make([])}Et.end=rLt;function oLt(e,g){var i=this._make(e,g),n=(0,Wc.uniqueSort)(Lq(Lq([],this.get(),!0),i.get(),!0));return this._make(n)}Et.add=oLt;function CLt(e){return this.prevObject?this.add(e?this.prevObject.filter(e):this.prevObject):this}Et.addBack=CLt;var Gg={},Fb={};Object.defineProperty(Fb,"__esModule",{value:!0});Fb.update=Fb.getParse=void 0;var aLt=kA,l1e=go;function sLt(e){return function(i,n,I,r){if(typeof Buffer<"u"&&Buffer.isBuffer(i)&&(i=i.toString()),typeof i=="string")return e(i,n,I,r);var o=i;if(!Array.isArray(o)&&(0,l1e.isDocument)(o))return o;var C=new l1e.Document([]);return FJe(o,C),C}}Fb.getParse=sLt;function FJe(e,g){var i=Array.isArray(e)?e:[e];g?g.children=i:g=null;for(var n=0;n=e.length?null:e[g+i],s=0;s-1&&(c.children.splice(d,1),I===c&&g>d&&C[0]--)}l.parent=I,l.prev&&(l.prev.next=(r=l.next)!==null&&r!==void 0?r:null),l.next&&(l.next.prev=(o=l.prev)!==null&&o!==void 0?o:null),l.prev=s===0?a:n[s-1],l.next=s===n.length-1?A:n[s+1]}return a&&(a.next=n[0]),A&&(A.prev=n[n.length-1]),e.splice.apply(e,C)}function uLt(e){var g=(0,vI.isCheerio)(e)?e:this._make(e);return g.append(this),this}Gg.appendTo=uLt;function dLt(e){var g=(0,vI.isCheerio)(e)?e:this._make(e);return g.prepend(this),this}Gg.prependTo=dLt;Gg.append=EJe(function(e,g,i){Jm(g,g.length,0,e,i)});Gg.prepend=EJe(function(e,g,i){Jm(g,0,0,e,i)});function DJe(e){return function(g){for(var i=this.length-1,n=this.parents().last(),I=0;I0&&i!==void 0&&(g[i]+=";".concat(C))}else i=r.slice(0,o).trim(),g[i]=r.slice(o+1).trim()}return g}var sw={};Object.defineProperty(sw,"__esModule",{value:!0});sw.serializeArray=sw.serialize=void 0;var TLt=Om,u1e="input,select,textarea,keygen",HLt=/%20/g,d1e=/\r?\n/g;function NLt(){var e=this.serializeArray(),g=e.map(function(i){return"".concat(encodeURIComponent(i.name),"=").concat(encodeURIComponent(i.value))});return g.join("&").replace(HLt,"+")}sw.serialize=NLt;function kLt(){var e=this;return this.map(function(g,i){var n=e._make(i);return(0,TLt.isTag)(i)&&i.name==="form"?n.find(u1e).toArray():n.filter(u1e).toArray()}).filter('[name!=""]:enabled:not(:submit, :button, :image, :reset, :file):matches([checked], :not(:checkbox, :radio))').map(function(g,i){var n,I=e._make(i),r=I.attr("name"),o=(n=I.val())!==null&&n!==void 0?n:"";return Array.isArray(o)?o.map(function(C){return{name:r,value:C.replace(d1e,`\r +`)}}):{name:r,value:o.replace(d1e,`\r +`)}}).toArray()}sw.serializeArray=kLt;var YLt=Qe&&Qe.__createBinding||(Object.create?function(e,g,i,n){n===void 0&&(n=i);var I=Object.getOwnPropertyDescriptor(g,i);(!I||("get"in I?!g.__esModule:I.writable||I.configurable))&&(I={enumerable:!0,get:function(){return g[i]}}),Object.defineProperty(e,n,I)}:function(e,g,i,n){n===void 0&&(n=i),e[n]=g[i]}),KLt=Qe&&Qe.__setModuleDefault||(Object.create?function(e,g){Object.defineProperty(e,"default",{enumerable:!0,value:g})}:function(e,g){e.default=g}),OT=Qe&&Qe.__importStar||function(e){if(e&&e.__esModule)return e;var g={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&YLt(g,e,i);return KLt(g,e),g};Object.defineProperty(RP,"__esModule",{value:!0});RP.Cheerio=void 0;var xLt=OT(tI),FLt=OT(Et),ELt=OT(Gg),DLt=OT(kP),MLt=OT(sw),JT=function(){function e(g,i,n){if(this.length=0,this.options=n,this._root=i,g){for(var I=0;I=55296&&C<=57343}e.isSurrogate=i;function n(C){return C>=56320&&C<=57343}e.isSurrogatePair=n;function I(C,a){return(C-55296)*1024+9216+a}e.getSurrogatePairCodePoint=I;function r(C){return C!==32&&C!==10&&C!==13&&C!==9&&C!==12&&C>=1&&C<=31||C>=127&&C<=159}e.isControlCodePoint=r;function o(C){return C>=64976&&C<=65007||g.has(C)}e.isUndefinedCodePoint=o})(KP);var LT={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ERR=void 0,function(g){g.controlCharacterInInputStream="control-character-in-input-stream",g.noncharacterInInputStream="noncharacter-in-input-stream",g.surrogateInInputStream="surrogate-in-input-stream",g.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",g.endTagWithAttributes="end-tag-with-attributes",g.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",g.unexpectedSolidusInTag="unexpected-solidus-in-tag",g.unexpectedNullCharacter="unexpected-null-character",g.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",g.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",g.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",g.missingEndTagName="missing-end-tag-name",g.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",g.unknownNamedCharacterReference="unknown-named-character-reference",g.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",g.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",g.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",g.eofBeforeTagName="eof-before-tag-name",g.eofInTag="eof-in-tag",g.missingAttributeValue="missing-attribute-value",g.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",g.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",g.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",g.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",g.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",g.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",g.missingDoctypePublicIdentifier="missing-doctype-public-identifier",g.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",g.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",g.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",g.cdataInHtmlContent="cdata-in-html-content",g.incorrectlyOpenedComment="incorrectly-opened-comment",g.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",g.eofInDoctype="eof-in-doctype",g.nestedComment="nested-comment",g.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",g.eofInComment="eof-in-comment",g.incorrectlyClosedComment="incorrectly-closed-comment",g.eofInCdata="eof-in-cdata",g.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",g.nullCharacterReference="null-character-reference",g.surrogateCharacterReference="surrogate-character-reference",g.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",g.controlCharacterReference="control-character-reference",g.noncharacterCharacterReference="noncharacter-character-reference",g.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",g.missingDoctypeName="missing-doctype-name",g.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",g.duplicateAttribute="duplicate-attribute",g.nonConformingDoctype="non-conforming-doctype",g.missingDoctype="missing-doctype",g.misplacedDoctype="misplaced-doctype",g.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",g.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",g.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",g.openElementsLeftAfterEof="open-elements-left-after-eof",g.abandonedHeadElementChild="abandoned-head-element-child",g.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",g.nestedNoscriptInHead="nested-noscript-in-head",g.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"}(e.ERR||(e.ERR={}))})(LT);function QLt(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function h1e(e,g){for(var i=0;ithis.bufferWaterline}},{key:"dropParsedChunk",value:function(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}},{key:"write",value:function(i,n){this.html.length>0?this.html+=i:this.html=i,this.endOfChunkHit=!1,this.lastChunkWritten=n}},{key:"insertHtmlAtCurrentPos",value:function(i){this.html=this.html.substring(0,this.pos+1)+i+this.html.substring(this.pos+1),this.endOfChunkHit=!1}},{key:"startsWith",value:function(i,n){if(this.pos+i.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(n)return this.html.startsWith(i,this.pos);for(let I=0;I=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,Co.CODE_POINTS.EOF;const I=this.html.charCodeAt(n);return I===Co.CODE_POINTS.CARRIAGE_RETURN?Co.CODE_POINTS.LINE_FEED:I}},{key:"advance",value:function(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,Co.CODE_POINTS.EOF;let i=this.html.charCodeAt(this.pos);return i===Co.CODE_POINTS.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,Co.CODE_POINTS.LINE_FEED):i===Co.CODE_POINTS.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,(0,Co.isSurrogate)(i)&&(i=this._processSurrogate(i)),this.handler.onParseError===null||i>31&&i<127||i===Co.CODE_POINTS.LINE_FEED||i===Co.CODE_POINTS.CARRIAGE_RETURN||i>159&&i<64976||this._checkForProblematicCharacters(i),i)}},{key:"_checkForProblematicCharacters",value:function(i){(0,Co.isControlCodePoint)(i)?this._err(sQ.ERR.controlCharacterInInputStream):(0,Co.isUndefinedCodePoint)(i)&&this._err(sQ.ERR.noncharacterInInputStream)}},{key:"retreat",value:function(i){for(this.pos-=i;this.pos=0;I--)if(i.attrs[I].name===n)return i.attrs[I].value;return null}e.getTokenAttr=g})(xP);var th={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hasUnescapedText=e.isNumberedHeader=e.SPECIAL_ELEMENTS=e.getTagID=e.TAG_ID=e.TAG_NAMES=e.DOCUMENT_MODE=e.ATTRS=e.NS=void 0;var g;(function(s){s.HTML="http://www.w3.org/1999/xhtml",s.MATHML="http://www.w3.org/1998/Math/MathML",s.SVG="http://www.w3.org/2000/svg",s.XLINK="http://www.w3.org/1999/xlink",s.XML="http://www.w3.org/XML/1998/namespace",s.XMLNS="http://www.w3.org/2000/xmlns/"})(g=e.NS||(e.NS={})),function(s){s.TYPE="type",s.ACTION="action",s.ENCODING="encoding",s.PROMPT="prompt",s.NAME="name",s.COLOR="color",s.FACE="face",s.SIZE="size"}(e.ATTRS||(e.ATTRS={})),function(s){s.NO_QUIRKS="no-quirks",s.QUIRKS="quirks",s.LIMITED_QUIRKS="limited-quirks"}(e.DOCUMENT_MODE||(e.DOCUMENT_MODE={}));var i;(function(s){s.A="a",s.ADDRESS="address",s.ANNOTATION_XML="annotation-xml",s.APPLET="applet",s.AREA="area",s.ARTICLE="article",s.ASIDE="aside",s.B="b",s.BASE="base",s.BASEFONT="basefont",s.BGSOUND="bgsound",s.BIG="big",s.BLOCKQUOTE="blockquote",s.BODY="body",s.BR="br",s.BUTTON="button",s.CAPTION="caption",s.CENTER="center",s.CODE="code",s.COL="col",s.COLGROUP="colgroup",s.DD="dd",s.DESC="desc",s.DETAILS="details",s.DIALOG="dialog",s.DIR="dir",s.DIV="div",s.DL="dl",s.DT="dt",s.EM="em",s.EMBED="embed",s.FIELDSET="fieldset",s.FIGCAPTION="figcaption",s.FIGURE="figure",s.FONT="font",s.FOOTER="footer",s.FOREIGN_OBJECT="foreignObject",s.FORM="form",s.FRAME="frame",s.FRAMESET="frameset",s.H1="h1",s.H2="h2",s.H3="h3",s.H4="h4",s.H5="h5",s.H6="h6",s.HEAD="head",s.HEADER="header",s.HGROUP="hgroup",s.HR="hr",s.HTML="html",s.I="i",s.IMG="img",s.IMAGE="image",s.INPUT="input",s.IFRAME="iframe",s.KEYGEN="keygen",s.LABEL="label",s.LI="li",s.LINK="link",s.LISTING="listing",s.MAIN="main",s.MALIGNMARK="malignmark",s.MARQUEE="marquee",s.MATH="math",s.MENU="menu",s.META="meta",s.MGLYPH="mglyph",s.MI="mi",s.MO="mo",s.MN="mn",s.MS="ms",s.MTEXT="mtext",s.NAV="nav",s.NOBR="nobr",s.NOFRAMES="noframes",s.NOEMBED="noembed",s.NOSCRIPT="noscript",s.OBJECT="object",s.OL="ol",s.OPTGROUP="optgroup",s.OPTION="option",s.P="p",s.PARAM="param",s.PLAINTEXT="plaintext",s.PRE="pre",s.RB="rb",s.RP="rp",s.RT="rt",s.RTC="rtc",s.RUBY="ruby",s.S="s",s.SCRIPT="script",s.SECTION="section",s.SELECT="select",s.SOURCE="source",s.SMALL="small",s.SPAN="span",s.STRIKE="strike",s.STRONG="strong",s.STYLE="style",s.SUB="sub",s.SUMMARY="summary",s.SUP="sup",s.TABLE="table",s.TBODY="tbody",s.TEMPLATE="template",s.TEXTAREA="textarea",s.TFOOT="tfoot",s.TD="td",s.TH="th",s.THEAD="thead",s.TITLE="title",s.TR="tr",s.TRACK="track",s.TT="tt",s.U="u",s.UL="ul",s.SVG="svg",s.VAR="var",s.WBR="wbr",s.XMP="xmp"})(i=e.TAG_NAMES||(e.TAG_NAMES={}));var n;(function(s){s[s.UNKNOWN=0]="UNKNOWN",s[s.A=1]="A",s[s.ADDRESS=2]="ADDRESS",s[s.ANNOTATION_XML=3]="ANNOTATION_XML",s[s.APPLET=4]="APPLET",s[s.AREA=5]="AREA",s[s.ARTICLE=6]="ARTICLE",s[s.ASIDE=7]="ASIDE",s[s.B=8]="B",s[s.BASE=9]="BASE",s[s.BASEFONT=10]="BASEFONT",s[s.BGSOUND=11]="BGSOUND",s[s.BIG=12]="BIG",s[s.BLOCKQUOTE=13]="BLOCKQUOTE",s[s.BODY=14]="BODY",s[s.BR=15]="BR",s[s.BUTTON=16]="BUTTON",s[s.CAPTION=17]="CAPTION",s[s.CENTER=18]="CENTER",s[s.CODE=19]="CODE",s[s.COL=20]="COL",s[s.COLGROUP=21]="COLGROUP",s[s.DD=22]="DD",s[s.DESC=23]="DESC",s[s.DETAILS=24]="DETAILS",s[s.DIALOG=25]="DIALOG",s[s.DIR=26]="DIR",s[s.DIV=27]="DIV",s[s.DL=28]="DL",s[s.DT=29]="DT",s[s.EM=30]="EM",s[s.EMBED=31]="EMBED",s[s.FIELDSET=32]="FIELDSET",s[s.FIGCAPTION=33]="FIGCAPTION",s[s.FIGURE=34]="FIGURE",s[s.FONT=35]="FONT",s[s.FOOTER=36]="FOOTER",s[s.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",s[s.FORM=38]="FORM",s[s.FRAME=39]="FRAME",s[s.FRAMESET=40]="FRAMESET",s[s.H1=41]="H1",s[s.H2=42]="H2",s[s.H3=43]="H3",s[s.H4=44]="H4",s[s.H5=45]="H5",s[s.H6=46]="H6",s[s.HEAD=47]="HEAD",s[s.HEADER=48]="HEADER",s[s.HGROUP=49]="HGROUP",s[s.HR=50]="HR",s[s.HTML=51]="HTML",s[s.I=52]="I",s[s.IMG=53]="IMG",s[s.IMAGE=54]="IMAGE",s[s.INPUT=55]="INPUT",s[s.IFRAME=56]="IFRAME",s[s.KEYGEN=57]="KEYGEN",s[s.LABEL=58]="LABEL",s[s.LI=59]="LI",s[s.LINK=60]="LINK",s[s.LISTING=61]="LISTING",s[s.MAIN=62]="MAIN",s[s.MALIGNMARK=63]="MALIGNMARK",s[s.MARQUEE=64]="MARQUEE",s[s.MATH=65]="MATH",s[s.MENU=66]="MENU",s[s.META=67]="META",s[s.MGLYPH=68]="MGLYPH",s[s.MI=69]="MI",s[s.MO=70]="MO",s[s.MN=71]="MN",s[s.MS=72]="MS",s[s.MTEXT=73]="MTEXT",s[s.NAV=74]="NAV",s[s.NOBR=75]="NOBR",s[s.NOFRAMES=76]="NOFRAMES",s[s.NOEMBED=77]="NOEMBED",s[s.NOSCRIPT=78]="NOSCRIPT",s[s.OBJECT=79]="OBJECT",s[s.OL=80]="OL",s[s.OPTGROUP=81]="OPTGROUP",s[s.OPTION=82]="OPTION",s[s.P=83]="P",s[s.PARAM=84]="PARAM",s[s.PLAINTEXT=85]="PLAINTEXT",s[s.PRE=86]="PRE",s[s.RB=87]="RB",s[s.RP=88]="RP",s[s.RT=89]="RT",s[s.RTC=90]="RTC",s[s.RUBY=91]="RUBY",s[s.S=92]="S",s[s.SCRIPT=93]="SCRIPT",s[s.SECTION=94]="SECTION",s[s.SELECT=95]="SELECT",s[s.SOURCE=96]="SOURCE",s[s.SMALL=97]="SMALL",s[s.SPAN=98]="SPAN",s[s.STRIKE=99]="STRIKE",s[s.STRONG=100]="STRONG",s[s.STYLE=101]="STYLE",s[s.SUB=102]="SUB",s[s.SUMMARY=103]="SUMMARY",s[s.SUP=104]="SUP",s[s.TABLE=105]="TABLE",s[s.TBODY=106]="TBODY",s[s.TEMPLATE=107]="TEMPLATE",s[s.TEXTAREA=108]="TEXTAREA",s[s.TFOOT=109]="TFOOT",s[s.TD=110]="TD",s[s.TH=111]="TH",s[s.THEAD=112]="THEAD",s[s.TITLE=113]="TITLE",s[s.TR=114]="TR",s[s.TRACK=115]="TRACK",s[s.TT=116]="TT",s[s.U=117]="U",s[s.UL=118]="UL",s[s.SVG=119]="SVG",s[s.VAR=120]="VAR",s[s.WBR=121]="WBR",s[s.XMP=122]="XMP"})(n=e.TAG_ID||(e.TAG_ID={}));const I=new Map([[i.A,n.A],[i.ADDRESS,n.ADDRESS],[i.ANNOTATION_XML,n.ANNOTATION_XML],[i.APPLET,n.APPLET],[i.AREA,n.AREA],[i.ARTICLE,n.ARTICLE],[i.ASIDE,n.ASIDE],[i.B,n.B],[i.BASE,n.BASE],[i.BASEFONT,n.BASEFONT],[i.BGSOUND,n.BGSOUND],[i.BIG,n.BIG],[i.BLOCKQUOTE,n.BLOCKQUOTE],[i.BODY,n.BODY],[i.BR,n.BR],[i.BUTTON,n.BUTTON],[i.CAPTION,n.CAPTION],[i.CENTER,n.CENTER],[i.CODE,n.CODE],[i.COL,n.COL],[i.COLGROUP,n.COLGROUP],[i.DD,n.DD],[i.DESC,n.DESC],[i.DETAILS,n.DETAILS],[i.DIALOG,n.DIALOG],[i.DIR,n.DIR],[i.DIV,n.DIV],[i.DL,n.DL],[i.DT,n.DT],[i.EM,n.EM],[i.EMBED,n.EMBED],[i.FIELDSET,n.FIELDSET],[i.FIGCAPTION,n.FIGCAPTION],[i.FIGURE,n.FIGURE],[i.FONT,n.FONT],[i.FOOTER,n.FOOTER],[i.FOREIGN_OBJECT,n.FOREIGN_OBJECT],[i.FORM,n.FORM],[i.FRAME,n.FRAME],[i.FRAMESET,n.FRAMESET],[i.H1,n.H1],[i.H2,n.H2],[i.H3,n.H3],[i.H4,n.H4],[i.H5,n.H5],[i.H6,n.H6],[i.HEAD,n.HEAD],[i.HEADER,n.HEADER],[i.HGROUP,n.HGROUP],[i.HR,n.HR],[i.HTML,n.HTML],[i.I,n.I],[i.IMG,n.IMG],[i.IMAGE,n.IMAGE],[i.INPUT,n.INPUT],[i.IFRAME,n.IFRAME],[i.KEYGEN,n.KEYGEN],[i.LABEL,n.LABEL],[i.LI,n.LI],[i.LINK,n.LINK],[i.LISTING,n.LISTING],[i.MAIN,n.MAIN],[i.MALIGNMARK,n.MALIGNMARK],[i.MARQUEE,n.MARQUEE],[i.MATH,n.MATH],[i.MENU,n.MENU],[i.META,n.META],[i.MGLYPH,n.MGLYPH],[i.MI,n.MI],[i.MO,n.MO],[i.MN,n.MN],[i.MS,n.MS],[i.MTEXT,n.MTEXT],[i.NAV,n.NAV],[i.NOBR,n.NOBR],[i.NOFRAMES,n.NOFRAMES],[i.NOEMBED,n.NOEMBED],[i.NOSCRIPT,n.NOSCRIPT],[i.OBJECT,n.OBJECT],[i.OL,n.OL],[i.OPTGROUP,n.OPTGROUP],[i.OPTION,n.OPTION],[i.P,n.P],[i.PARAM,n.PARAM],[i.PLAINTEXT,n.PLAINTEXT],[i.PRE,n.PRE],[i.RB,n.RB],[i.RP,n.RP],[i.RT,n.RT],[i.RTC,n.RTC],[i.RUBY,n.RUBY],[i.S,n.S],[i.SCRIPT,n.SCRIPT],[i.SECTION,n.SECTION],[i.SELECT,n.SELECT],[i.SOURCE,n.SOURCE],[i.SMALL,n.SMALL],[i.SPAN,n.SPAN],[i.STRIKE,n.STRIKE],[i.STRONG,n.STRONG],[i.STYLE,n.STYLE],[i.SUB,n.SUB],[i.SUMMARY,n.SUMMARY],[i.SUP,n.SUP],[i.TABLE,n.TABLE],[i.TBODY,n.TBODY],[i.TEMPLATE,n.TEMPLATE],[i.TEXTAREA,n.TEXTAREA],[i.TFOOT,n.TFOOT],[i.TD,n.TD],[i.TH,n.TH],[i.THEAD,n.THEAD],[i.TITLE,n.TITLE],[i.TR,n.TR],[i.TRACK,n.TRACK],[i.TT,n.TT],[i.U,n.U],[i.UL,n.UL],[i.SVG,n.SVG],[i.VAR,n.VAR],[i.WBR,n.WBR],[i.XMP,n.XMP]]);function r(s){var l;return(l=I.get(s))!==null&&l!==void 0?l:n.UNKNOWN}e.getTagID=r;const o=n;e.SPECIAL_ELEMENTS={[g.HTML]:new Set([o.ADDRESS,o.APPLET,o.AREA,o.ARTICLE,o.ASIDE,o.BASE,o.BASEFONT,o.BGSOUND,o.BLOCKQUOTE,o.BODY,o.BR,o.BUTTON,o.CAPTION,o.CENTER,o.COL,o.COLGROUP,o.DD,o.DETAILS,o.DIR,o.DIV,o.DL,o.DT,o.EMBED,o.FIELDSET,o.FIGCAPTION,o.FIGURE,o.FOOTER,o.FORM,o.FRAME,o.FRAMESET,o.H1,o.H2,o.H3,o.H4,o.H5,o.H6,o.HEAD,o.HEADER,o.HGROUP,o.HR,o.HTML,o.IFRAME,o.IMG,o.INPUT,o.LI,o.LINK,o.LISTING,o.MAIN,o.MARQUEE,o.MENU,o.META,o.NAV,o.NOEMBED,o.NOFRAMES,o.NOSCRIPT,o.OBJECT,o.OL,o.P,o.PARAM,o.PLAINTEXT,o.PRE,o.SCRIPT,o.SECTION,o.SELECT,o.SOURCE,o.STYLE,o.SUMMARY,o.TABLE,o.TBODY,o.TD,o.TEMPLATE,o.TEXTAREA,o.TFOOT,o.TH,o.THEAD,o.TITLE,o.TR,o.TRACK,o.UL,o.WBR,o.XMP]),[g.MATHML]:new Set([o.MI,o.MO,o.MN,o.MS,o.MTEXT,o.ANNOTATION_XML]),[g.SVG]:new Set([o.TITLE,o.FOREIGN_OBJECT,o.DESC]),[g.XLINK]:new Set,[g.XML]:new Set,[g.XMLNS]:new Set};function C(s){return s===o.H1||s===o.H2||s===o.H3||s===o.H4||s===o.H5||s===o.H6}e.isNumberedHeader=C;const a=new Set([i.STYLE,i.SCRIPT,i.XMP,i.IFRAME,i.NOEMBED,i.NOFRAMES,i.PLAINTEXT]);function A(s,l){return a.has(s)||l&&s===i.NOSCRIPT}e.hasUnescapedText=A})(th);function gUt(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function f1e(e,g){for(var i=0;i=se.CODE_POINTS.DIGIT_0&&e<=se.CODE_POINTS.DIGIT_9}function WV(e){return e>=se.CODE_POINTS.LATIN_CAPITAL_A&&e<=se.CODE_POINTS.LATIN_CAPITAL_Z}function CUt(e){return e>=se.CODE_POINTS.LATIN_SMALL_A&&e<=se.CODE_POINTS.LATIN_SMALL_Z}function Yh(e){return CUt(e)||WV(e)}function Qq(e){return Yh(e)||Q2(e)}function OJe(e){return e>=se.CODE_POINTS.LATIN_CAPITAL_A&&e<=se.CODE_POINTS.LATIN_CAPITAL_F}function JJe(e){return e>=se.CODE_POINTS.LATIN_SMALL_A&&e<=se.CODE_POINTS.LATIN_SMALL_F}function aUt(e){return Q2(e)||OJe(e)||JJe(e)}function xk(e){return e+32}function LJe(e){return e===se.CODE_POINTS.SPACE||e===se.CODE_POINTS.LINE_FEED||e===se.CODE_POINTS.TABULATION||e===se.CODE_POINTS.FORM_FEED}function sUt(e){return e===se.CODE_POINTS.EQUALS_SIGN||Qq(e)}function m1e(e){return LJe(e)||e===se.CODE_POINTS.SOLIDUS||e===se.CODE_POINTS.GREATER_THAN_SIGN}let AUt=function(){function e(g,i){gUt(this,e),this.options=g,this.handler=i,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=Ge.DATA,this.returnState=Ge.DATA,this.charRefCode=-1,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new rUt.Preprocessor(i),this.currentLocation=this.getCurrentLocation(-1)}return iUt(e,[{key:"_err",value:function(i){var n,I;(I=(n=this.handler).onParseError)===null||I===void 0||I.call(n,this.preprocessor.getError(i))}},{key:"getCurrentLocation",value:function(i){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-i,startOffset:this.preprocessor.offset-i,endLine:-1,endCol:-1,endOffset:-1}:null}},{key:"_runParsingLoop",value:function(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;const i=this._consume();this._ensureHibernation()||this._callState(i)}this.inLoop=!1}}},{key:"pause",value:function(){this.paused=!0}},{key:"resume",value:function(i){if(!this.paused)throw new Error("Parser was already resumed");this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||i?.())}},{key:"write",value:function(i,n,I){this.active=!0,this.preprocessor.write(i,n),this._runParsingLoop(),this.paused||I?.()}},{key:"insertHtmlAtCurrentPos",value:function(i){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(i),this._runParsingLoop()}},{key:"_ensureHibernation",value:function(){return this.preprocessor.endOfChunkHit?(this._unconsume(this.consumedAfterSnapshot),this.active=!1,!0):!1}},{key:"_consume",value:function(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}},{key:"_unconsume",value:function(i){this.consumedAfterSnapshot-=i,this.preprocessor.retreat(i)}},{key:"_reconsumeInState",value:function(i,n){this.state=i,this._callState(n)}},{key:"_advanceBy",value:function(i){this.consumedAfterSnapshot+=i;for(let n=0;n0&&this._err(tt.ERR.endTagWithAttributes),i.selfClosing&&this._err(tt.ERR.endTagWithTrailingSolidus),this.handler.onEndTag(i)),this.preprocessor.dropParsedChunk()}},{key:"emitCurrentComment",value:function(i){this.prepareToken(i),this.handler.onComment(i),this.preprocessor.dropParsedChunk()}},{key:"emitCurrentDoctype",value:function(i){this.prepareToken(i),this.handler.onDoctype(i),this.preprocessor.dropParsedChunk()}},{key:"_emitCurrentCharacterToken",value:function(i){if(this.currentCharacterToken){switch(i&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=i.startLine,this.currentCharacterToken.location.endCol=i.startCol,this.currentCharacterToken.location.endOffset=i.startOffset),this.currentCharacterToken.type){case qo.TokenType.CHARACTER:{this.handler.onCharacter(this.currentCharacterToken);break}case qo.TokenType.NULL_CHARACTER:{this.handler.onNullCharacter(this.currentCharacterToken);break}case qo.TokenType.WHITESPACE_CHARACTER:{this.handler.onWhitespaceCharacter(this.currentCharacterToken);break}}this.currentCharacterToken=null}}},{key:"_emitEOFToken",value:function(){const i=this.getCurrentLocation(0);i&&(i.endLine=i.startLine,i.endCol=i.startCol,i.endOffset=i.startOffset),this._emitCurrentCharacterToken(i),this.handler.onEof({type:qo.TokenType.EOF,location:i}),this.active=!1}},{key:"_appendCharToCurrentCharacterToken",value:function(i,n){if(this.currentCharacterToken)if(this.currentCharacterToken.type!==i)this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk();else{this.currentCharacterToken.chars+=n;return}this._createCharacterToken(i,n)}},{key:"_emitCodePoint",value:function(i){const n=LJe(i)?qo.TokenType.WHITESPACE_CHARACTER:i===se.CODE_POINTS.NULL?qo.TokenType.NULL_CHARACTER:qo.TokenType.CHARACTER;this._appendCharToCurrentCharacterToken(n,String.fromCodePoint(i))}},{key:"_emitChars",value:function(i){this._appendCharToCurrentCharacterToken(qo.TokenType.CHARACTER,i)}},{key:"_matchNamedCharacterReference",value:function(i){let n=null,I=0,r=!1;for(let o=0,C=ml.htmlDecodeTree[0];o>=0&&(o=(0,ml.determineBranch)(ml.htmlDecodeTree,C,o+1,i),!(o<0));i=this._consume()){I+=1,C=ml.htmlDecodeTree[o];const a=C&ml.BinTrieFlags.VALUE_LENGTH;if(a){const A=(a>>14)-1;if(i!==se.CODE_POINTS.SEMICOLON&&this._isCharacterReferenceInAttribute()&&sUt(this.preprocessor.peek(1))?(n=[se.CODE_POINTS.AMPERSAND],o+=A):(n=A===0?[ml.htmlDecodeTree[o]&~ml.BinTrieFlags.VALUE_LENGTH]:A===1?[ml.htmlDecodeTree[++o]]:[ml.htmlDecodeTree[++o],ml.htmlDecodeTree[++o]],I=0,r=i!==se.CODE_POINTS.SEMICOLON),A===0){this._consume();break}}}return this._unconsume(I),r&&!this.preprocessor.endOfChunkHit&&this._err(tt.ERR.missingSemicolonAfterCharacterReference),this._unconsume(1),n}},{key:"_isCharacterReferenceInAttribute",value:function(){return this.returnState===Ge.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===Ge.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===Ge.ATTRIBUTE_VALUE_UNQUOTED}},{key:"_flushCodePointConsumedAsCharacterReference",value:function(i){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(i):this._emitCodePoint(i)}},{key:"_callState",value:function(i){switch(this.state){case Ge.DATA:{this._stateData(i);break}case Ge.RCDATA:{this._stateRcdata(i);break}case Ge.RAWTEXT:{this._stateRawtext(i);break}case Ge.SCRIPT_DATA:{this._stateScriptData(i);break}case Ge.PLAINTEXT:{this._statePlaintext(i);break}case Ge.TAG_OPEN:{this._stateTagOpen(i);break}case Ge.END_TAG_OPEN:{this._stateEndTagOpen(i);break}case Ge.TAG_NAME:{this._stateTagName(i);break}case Ge.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(i);break}case Ge.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(i);break}case Ge.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(i);break}case Ge.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(i);break}case Ge.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(i);break}case Ge.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(i);break}case Ge.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(i);break}case Ge.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(i);break}case Ge.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(i);break}case Ge.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(i);break}case Ge.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(i);break}case Ge.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(i);break}case Ge.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(i);break}case Ge.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(i);break}case Ge.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(i);break}case Ge.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(i);break}case Ge.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(i);break}case Ge.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(i);break}case Ge.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(i);break}case Ge.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(i);break}case Ge.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(i);break}case Ge.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(i);break}case Ge.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(i);break}case Ge.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(i);break}case Ge.ATTRIBUTE_NAME:{this._stateAttributeName(i);break}case Ge.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(i);break}case Ge.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(i);break}case Ge.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(i);break}case Ge.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(i);break}case Ge.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(i);break}case Ge.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(i);break}case Ge.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(i);break}case Ge.BOGUS_COMMENT:{this._stateBogusComment(i);break}case Ge.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(i);break}case Ge.COMMENT_START:{this._stateCommentStart(i);break}case Ge.COMMENT_START_DASH:{this._stateCommentStartDash(i);break}case Ge.COMMENT:{this._stateComment(i);break}case Ge.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(i);break}case Ge.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(i);break}case Ge.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(i);break}case Ge.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(i);break}case Ge.COMMENT_END_DASH:{this._stateCommentEndDash(i);break}case Ge.COMMENT_END:{this._stateCommentEnd(i);break}case Ge.COMMENT_END_BANG:{this._stateCommentEndBang(i);break}case Ge.DOCTYPE:{this._stateDoctype(i);break}case Ge.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(i);break}case Ge.DOCTYPE_NAME:{this._stateDoctypeName(i);break}case Ge.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(i);break}case Ge.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(i);break}case Ge.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(i);break}case Ge.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(i);break}case Ge.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(i);break}case Ge.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(i);break}case Ge.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(i);break}case Ge.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(i);break}case Ge.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(i);break}case Ge.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(i);break}case Ge.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(i);break}case Ge.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(i);break}case Ge.BOGUS_DOCTYPE:{this._stateBogusDoctype(i);break}case Ge.CDATA_SECTION:{this._stateCdataSection(i);break}case Ge.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(i);break}case Ge.CDATA_SECTION_END:{this._stateCdataSectionEnd(i);break}case Ge.CHARACTER_REFERENCE:{this._stateCharacterReference(i);break}case Ge.NAMED_CHARACTER_REFERENCE:{this._stateNamedCharacterReference(i);break}case Ge.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(i);break}case Ge.NUMERIC_CHARACTER_REFERENCE:{this._stateNumericCharacterReference(i);break}case Ge.HEXADEMICAL_CHARACTER_REFERENCE_START:{this._stateHexademicalCharacterReferenceStart(i);break}case Ge.HEXADEMICAL_CHARACTER_REFERENCE:{this._stateHexademicalCharacterReference(i);break}case Ge.DECIMAL_CHARACTER_REFERENCE:{this._stateDecimalCharacterReference(i);break}case Ge.NUMERIC_CHARACTER_REFERENCE_END:{this._stateNumericCharacterReferenceEnd(i);break}default:throw new Error("Unknown state")}}},{key:"_stateData",value:function(i){switch(i){case se.CODE_POINTS.LESS_THAN_SIGN:{this.state=Ge.TAG_OPEN;break}case se.CODE_POINTS.AMPERSAND:{this.returnState=Ge.DATA,this.state=Ge.CHARACTER_REFERENCE;break}case se.CODE_POINTS.NULL:{this._err(tt.ERR.unexpectedNullCharacter),this._emitCodePoint(i);break}case se.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(i)}}},{key:"_stateRcdata",value:function(i){switch(i){case se.CODE_POINTS.AMPERSAND:{this.returnState=Ge.RCDATA,this.state=Ge.CHARACTER_REFERENCE;break}case se.CODE_POINTS.LESS_THAN_SIGN:{this.state=Ge.RCDATA_LESS_THAN_SIGN;break}case se.CODE_POINTS.NULL:{this._err(tt.ERR.unexpectedNullCharacter),this._emitChars(se.REPLACEMENT_CHARACTER);break}case se.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(i)}}},{key:"_stateRawtext",value:function(i){switch(i){case se.CODE_POINTS.LESS_THAN_SIGN:{this.state=Ge.RAWTEXT_LESS_THAN_SIGN;break}case se.CODE_POINTS.NULL:{this._err(tt.ERR.unexpectedNullCharacter),this._emitChars(se.REPLACEMENT_CHARACTER);break}case se.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(i)}}},{key:"_stateScriptData",value:function(i){switch(i){case se.CODE_POINTS.LESS_THAN_SIGN:{this.state=Ge.SCRIPT_DATA_LESS_THAN_SIGN;break}case se.CODE_POINTS.NULL:{this._err(tt.ERR.unexpectedNullCharacter),this._emitChars(se.REPLACEMENT_CHARACTER);break}case se.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(i)}}},{key:"_statePlaintext",value:function(i){switch(i){case se.CODE_POINTS.NULL:{this._err(tt.ERR.unexpectedNullCharacter),this._emitChars(se.REPLACEMENT_CHARACTER);break}case se.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(i)}}},{key:"_stateTagOpen",value:function(i){if(Yh(i))this._createStartTagToken(),this.state=Ge.TAG_NAME,this._stateTagName(i);else switch(i){case se.CODE_POINTS.EXCLAMATION_MARK:{this.state=Ge.MARKUP_DECLARATION_OPEN;break}case se.CODE_POINTS.SOLIDUS:{this.state=Ge.END_TAG_OPEN;break}case se.CODE_POINTS.QUESTION_MARK:{this._err(tt.ERR.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=Ge.BOGUS_COMMENT,this._stateBogusComment(i);break}case se.CODE_POINTS.EOF:{this._err(tt.ERR.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(tt.ERR.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=Ge.DATA,this._stateData(i)}}},{key:"_stateEndTagOpen",value:function(i){if(Yh(i))this._createEndTagToken(),this.state=Ge.TAG_NAME,this._stateTagName(i);else switch(i){case se.CODE_POINTS.GREATER_THAN_SIGN:{this._err(tt.ERR.missingEndTagName),this.state=Ge.DATA;break}case se.CODE_POINTS.EOF:{this._err(tt.ERR.eofBeforeTagName),this._emitChars("");break}case se.CODE_POINTS.NULL:{this._err(tt.ERR.unexpectedNullCharacter),this.state=Ge.SCRIPT_DATA_ESCAPED,this._emitChars(se.REPLACEMENT_CHARACTER);break}case se.CODE_POINTS.EOF:{this._err(tt.ERR.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=Ge.SCRIPT_DATA_ESCAPED,this._emitCodePoint(i)}}},{key:"_stateScriptDataEscapedLessThanSign",value:function(i){i===se.CODE_POINTS.SOLIDUS?this.state=Ge.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:Yh(i)?(this._emitChars("<"),this.state=Ge.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(i)):(this._emitChars("<"),this.state=Ge.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(i))}},{key:"_stateScriptDataEscapedEndTagOpen",value:function(i){Yh(i)?(this.state=Ge.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(i)):(this._emitChars("");break}case se.CODE_POINTS.NULL:{this._err(tt.ERR.unexpectedNullCharacter),this.state=Ge.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(se.REPLACEMENT_CHARACTER);break}case se.CODE_POINTS.EOF:{this._err(tt.ERR.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=Ge.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(i)}}},{key:"_stateScriptDataDoubleEscapedLessThanSign",value:function(i){i===se.CODE_POINTS.SOLIDUS?(this.state=Ge.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=Ge.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(i))}},{key:"_stateScriptDataDoubleEscapeEnd",value:function(i){if(this.preprocessor.startsWith(se.SEQUENCES.SCRIPT,!1)&&m1e(this.preprocessor.peek(se.SEQUENCES.SCRIPT.length))){this._emitCodePoint(i);for(let n=0;n1114111)this._err(tt.ERR.characterReferenceOutsideUnicodeRange),this.charRefCode=se.CODE_POINTS.REPLACEMENT_CHARACTER;else if((0,se.isSurrogate)(this.charRefCode))this._err(tt.ERR.surrogateCharacterReference),this.charRefCode=se.CODE_POINTS.REPLACEMENT_CHARACTER;else if((0,se.isUndefinedCodePoint)(this.charRefCode))this._err(tt.ERR.noncharacterCharacterReference);else if((0,se.isControlCodePoint)(this.charRefCode)||this.charRefCode===se.CODE_POINTS.CARRIAGE_RETURN){this._err(tt.ERR.controlCharacterReference);const n=oUt.get(this.charRefCode);n!==void 0&&(this.charRefCode=n)}this._flushCodePointConsumedAsCharacterReference(this.charRefCode),this._reconsumeInState(this.returnState,i)}}]),e}();Eb.Tokenizer=AUt;var FP={};function lUt(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function p1e(e,g){for(var i=0;i0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(i,!0)}},{key:"replace",value:function(i,n){const I=this._indexOf(i);this.items[I]=n,I===this.stackTop&&(this.current=n)}},{key:"insertAfter",value:function(i,n,I){const r=this._indexOf(i)+1;this.items.splice(r,0,n),this.tagIDs.splice(r,0,I),this.stackTop++,r===this.stackTop&&this._updateCurrentElement(),this.handler.onItemPush(this.current,this.currentTagId,r===this.stackTop)}},{key:"popUntilTagNamePopped",value:function(i){let n=this.stackTop+1;do n=this.tagIDs.lastIndexOf(i,n-1);while(n>0&&this.treeAdapter.getNamespaceURI(this.items[n])!==rt.NS.HTML);this.shortenToLength(n<0?0:n)}},{key:"shortenToLength",value:function(i){for(;this.stackTop>=i;){const n=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(n,this.stackTop=0;I--)if(i.includes(this.tagIDs[I])&&this.treeAdapter.getNamespaceURI(this.items[I])===n)return I;return-1}},{key:"clearBackTo",value:function(i,n){const I=this._indexOfTagNames(i,n);this.shortenToLength(I+1)}},{key:"clearBackToTableContext",value:function(){this.clearBackTo(pUt,rt.NS.HTML)}},{key:"clearBackToTableBodyContext",value:function(){this.clearBackTo(mUt,rt.NS.HTML)}},{key:"clearBackToTableRowContext",value:function(){this.clearBackTo(fUt,rt.NS.HTML)}},{key:"remove",value:function(i){const n=this._indexOf(i);n>=0&&(n===this.stackTop?this.pop():(this.items.splice(n,1),this.tagIDs.splice(n,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(i,!1)))}},{key:"tryPeekProperlyNestedBodyElement",value:function(){return this.stackTop>=1&&this.tagIDs[1]===rt.TAG_ID.BODY?this.items[1]:null}},{key:"contains",value:function(i){return this._indexOf(i)>-1}},{key:"getCommonAncestor",value:function(i){const n=this._indexOf(i)-1;return n>=0?this.items[n]:null}},{key:"isRootHtmlElementCurrent",value:function(){return this.stackTop===0&&this.tagIDs[0]===rt.TAG_ID.HTML}},{key:"hasInScope",value:function(i){for(let n=this.stackTop;n>=0;n--){const I=this.tagIDs[n],r=this.treeAdapter.getNamespaceURI(this.items[n]);if(I===i&&r===rt.NS.HTML)return!0;if(Fk.get(I)===r)return!1}return!0}},{key:"hasNumberedHeaderInScope",value:function(){for(let i=this.stackTop;i>=0;i--){const n=this.tagIDs[i],I=this.treeAdapter.getNamespaceURI(this.items[i]);if((0,rt.isNumberedHeader)(n)&&I===rt.NS.HTML)return!0;if(Fk.get(n)===I)return!1}return!0}},{key:"hasInListItemScope",value:function(i){for(let n=this.stackTop;n>=0;n--){const I=this.tagIDs[n],r=this.treeAdapter.getNamespaceURI(this.items[n]);if(I===i&&r===rt.NS.HTML)return!0;if((I===rt.TAG_ID.UL||I===rt.TAG_ID.OL)&&r===rt.NS.HTML||Fk.get(I)===r)return!1}return!0}},{key:"hasInButtonScope",value:function(i){for(let n=this.stackTop;n>=0;n--){const I=this.tagIDs[n],r=this.treeAdapter.getNamespaceURI(this.items[n]);if(I===i&&r===rt.NS.HTML)return!0;if(I===rt.TAG_ID.BUTTON&&r===rt.NS.HTML||Fk.get(I)===r)return!1}return!0}},{key:"hasInTableScope",value:function(i){for(let n=this.stackTop;n>=0;n--){const I=this.tagIDs[n];if(this.treeAdapter.getNamespaceURI(this.items[n])===rt.NS.HTML){if(I===i)return!0;if(I===rt.TAG_ID.TABLE||I===rt.TAG_ID.TEMPLATE||I===rt.TAG_ID.HTML)return!1}}return!0}},{key:"hasTableBodyContextInTableScope",value:function(){for(let i=this.stackTop;i>=0;i--){const n=this.tagIDs[i];if(this.treeAdapter.getNamespaceURI(this.items[i])===rt.NS.HTML){if(n===rt.TAG_ID.TBODY||n===rt.TAG_ID.THEAD||n===rt.TAG_ID.TFOOT)return!0;if(n===rt.TAG_ID.TABLE||n===rt.TAG_ID.HTML)return!1}}return!0}},{key:"hasInSelectScope",value:function(i){for(let n=this.stackTop;n>=0;n--){const I=this.tagIDs[n];if(this.treeAdapter.getNamespaceURI(this.items[n])===rt.NS.HTML){if(I===i)return!0;if(I!==rt.TAG_ID.OPTION&&I!==rt.TAG_ID.OPTGROUP)return!1}}return!0}},{key:"generateImpliedEndTags",value:function(){for(;UJe.has(this.currentTagId);)this.pop()}},{key:"generateImpliedEndTagsThoroughly",value:function(){for(;b1e.has(this.currentTagId);)this.pop()}},{key:"generateImpliedEndTagsWithExclusion",value:function(i){for(;this.currentTagId!==i&&b1e.has(this.currentTagId);)this.pop()}}]),e}();FP.OpenElementStack=yUt;var QJe={};(function(e){function g(s,l){if(!(s instanceof l))throw new TypeError("Cannot call a class as a function")}function i(s,l){for(var c=0;c[m.name,m.value]));let f=0;for(let m=0;mh.get(p.name)===p.value)&&(f+=1,f>=o&&this.entries.splice(b.idx,1))}}},{key:"insertMarker",value:function(){this.entries.unshift(a)}},{key:"pushElement",value:function(c,u){this._ensureNoahArkCondition(c),this.entries.unshift({type:C.Element,element:c,token:u})}},{key:"insertElementAfterBookmark",value:function(c,u){const d=this.entries.indexOf(this.bookmark);this.entries.splice(d,0,{type:C.Element,element:c,token:u})}},{key:"removeEntry",value:function(c){const u=this.entries.indexOf(c);u>=0&&this.entries.splice(u,1)}},{key:"clearToLastMarker",value:function(){const c=this.entries.indexOf(a);c>=0?this.entries.splice(0,c+1):this.entries.length=0}},{key:"getElementEntryInScopeWithTagName",value:function(c){const u=this.entries.find(d=>d.type===C.Marker||this.treeAdapter.getTagName(d.element)===c);return u&&u.type===C.Element?u:null}},{key:"getElementEntry",value:function(c){return this.entries.find(u=>u.type===C.Element&&u.element===c)}}]),s}();e.FormattingElementList=A})(QJe);var EP={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.defaultTreeAdapter=void 0;const g=th;function i(n){return{nodeName:"#text",value:n,parentNode:null}}e.defaultTreeAdapter={createDocument(){return{nodeName:"#document",mode:g.DOCUMENT_MODE.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:"#document-fragment",childNodes:[]}},createElement(n,I,r){return{nodeName:n,tagName:n,attrs:r,namespaceURI:I,childNodes:[],parentNode:null}},createCommentNode(n){return{nodeName:"#comment",data:n,parentNode:null}},appendChild(n,I){n.childNodes.push(I),I.parentNode=n},insertBefore(n,I,r){const o=n.childNodes.indexOf(r);n.childNodes.splice(o,0,I),I.parentNode=n},setTemplateContent(n,I){n.content=I},getTemplateContent(n){return n.content},setDocumentType(n,I,r,o){const C=n.childNodes.find(a=>a.nodeName==="#documentType");if(C)C.name=I,C.publicId=r,C.systemId=o;else{const a={nodeName:"#documentType",name:I,publicId:r,systemId:o,parentNode:null};e.defaultTreeAdapter.appendChild(n,a)}},setDocumentMode(n,I){n.mode=I},getDocumentMode(n){return n.mode},detachNode(n){if(n.parentNode){const I=n.parentNode.childNodes.indexOf(n);n.parentNode.childNodes.splice(I,1),n.parentNode=null}},insertText(n,I){if(n.childNodes.length>0){const r=n.childNodes[n.childNodes.length-1];if(e.defaultTreeAdapter.isTextNode(r)){r.value+=I;return}}e.defaultTreeAdapter.appendChild(n,i(I))},insertTextBefore(n,I,r){const o=n.childNodes[n.childNodes.indexOf(r)-1];o&&e.defaultTreeAdapter.isTextNode(o)?o.value+=I:e.defaultTreeAdapter.insertBefore(n,i(I),r)},adoptAttributes(n,I){const r=new Set(n.attrs.map(o=>o.name));for(let o=0;oe.startsWith(i))}function SUt(e){return e.name===jJe&&e.publicId===null&&(e.systemId===null||e.systemId===ZUt)}lw.isConforming=SUt;function RUt(e){if(e.name!==jJe)return QZ.DOCUMENT_MODE.QUIRKS;const{systemId:g}=e;if(g&&g.toLowerCase()===GUt)return QZ.DOCUMENT_MODE.QUIRKS;let{publicId:i}=e;if(i!==null){if(i=i.toLowerCase(),BUt.has(i))return QZ.DOCUMENT_MODE.QUIRKS;let n=g===null?vUt:$Je;if(y1e(i,n))return QZ.DOCUMENT_MODE.QUIRKS;if(n=g===null?qJe:wUt,y1e(i,n))return QZ.DOCUMENT_MODE.LIMITED_QUIRKS}return QZ.DOCUMENT_MODE.NO_QUIRKS}lw.getDocumentMode=RUt;var Gse={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isIntegrationPoint=e.adjustTokenSVGTagName=e.adjustTokenXMLAttrs=e.adjustTokenSVGAttrs=e.adjustTokenMathMLAttrs=e.causesExit=e.SVG_TAG_NAMES_ADJUSTMENT_MAP=void 0;const g=th,i={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},n="definitionurl",I="definitionURL",r=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map(f=>[f.toLowerCase(),f])),o=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:g.NS.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:g.NS.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:g.NS.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:g.NS.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:g.NS.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:g.NS.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:g.NS.XLINK}],["xml:base",{prefix:"xml",name:"base",namespace:g.NS.XML}],["xml:lang",{prefix:"xml",name:"lang",namespace:g.NS.XML}],["xml:space",{prefix:"xml",name:"space",namespace:g.NS.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:g.NS.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:g.NS.XMLNS}]]);e.SVG_TAG_NAMES_ADJUSTMENT_MAP=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map(f=>[f.toLowerCase(),f]));const C=new Set([g.TAG_ID.B,g.TAG_ID.BIG,g.TAG_ID.BLOCKQUOTE,g.TAG_ID.BODY,g.TAG_ID.BR,g.TAG_ID.CENTER,g.TAG_ID.CODE,g.TAG_ID.DD,g.TAG_ID.DIV,g.TAG_ID.DL,g.TAG_ID.DT,g.TAG_ID.EM,g.TAG_ID.EMBED,g.TAG_ID.H1,g.TAG_ID.H2,g.TAG_ID.H3,g.TAG_ID.H4,g.TAG_ID.H5,g.TAG_ID.H6,g.TAG_ID.HEAD,g.TAG_ID.HR,g.TAG_ID.I,g.TAG_ID.IMG,g.TAG_ID.LI,g.TAG_ID.LISTING,g.TAG_ID.MENU,g.TAG_ID.META,g.TAG_ID.NOBR,g.TAG_ID.OL,g.TAG_ID.P,g.TAG_ID.PRE,g.TAG_ID.RUBY,g.TAG_ID.S,g.TAG_ID.SMALL,g.TAG_ID.SPAN,g.TAG_ID.STRONG,g.TAG_ID.STRIKE,g.TAG_ID.SUB,g.TAG_ID.SUP,g.TAG_ID.TABLE,g.TAG_ID.TT,g.TAG_ID.U,g.TAG_ID.UL,g.TAG_ID.VAR]);function a(f){const m=f.tagID;return m===g.TAG_ID.FONT&&f.attrs.some(({name:p})=>p===g.ATTRS.COLOR||p===g.ATTRS.SIZE||p===g.ATTRS.FACE)||C.has(m)}e.causesExit=a;function A(f){for(let m=0;m0&&this._setContextModes(i,n)}},{key:"onItemPop",value:function(i,n){var I,r;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(i,this.currentToken),(r=(I=this.treeAdapter).onItemPop)===null||r===void 0||r.call(I,i,this.openElements.current),n){let o,C;this.openElements.stackTop===0&&this.fragmentContext?(o=this.fragmentContext,C=this.fragmentContextID):{current:o,currentTagId:C}=this.openElements,this._setContextModes(o,C)}}},{key:"_setContextModes",value:function(i,n){const I=i===this.document||this.treeAdapter.getNamespaceURI(i)===P.NS.HTML;this.currentNotInHTML=!I,this.tokenizer.inForeignNode=!I&&!this._isIntegrationPoint(n,i)}},{key:"_switchToTextParsing",value:function(i,n){this._insertElement(i,P.NS.HTML),this.tokenizer.state=n,this.originalInsertionMode=this.insertionMode,this.insertionMode=We.TEXT}},{key:"switchToPlaintextParsing",value:function(){this.insertionMode=We.TEXT,this.originalInsertionMode=We.IN_BODY,this.tokenizer.state=po.TokenizerMode.PLAINTEXT}},{key:"_getAdjustedCurrentElement",value:function(){return this.openElements.stackTop===0&&this.fragmentContext?this.fragmentContext:this.openElements.current}},{key:"_findFormInFragmentContext",value:function(){let i=this.fragmentContext;for(;i;){if(this.treeAdapter.getTagName(i)===P.TAG_NAMES.FORM){this.formElement=i;break}i=this.treeAdapter.getParentNode(i)}}},{key:"_initTokenizerForFragmentParsing",value:function(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==P.NS.HTML))switch(this.fragmentContextID){case P.TAG_ID.TITLE:case P.TAG_ID.TEXTAREA:{this.tokenizer.state=po.TokenizerMode.RCDATA;break}case P.TAG_ID.STYLE:case P.TAG_ID.XMP:case P.TAG_ID.IFRAME:case P.TAG_ID.NOEMBED:case P.TAG_ID.NOFRAMES:case P.TAG_ID.NOSCRIPT:{this.tokenizer.state=po.TokenizerMode.RAWTEXT;break}case P.TAG_ID.SCRIPT:{this.tokenizer.state=po.TokenizerMode.SCRIPT_DATA;break}case P.TAG_ID.PLAINTEXT:{this.tokenizer.state=po.TokenizerMode.PLAINTEXT;break}}}},{key:"_setDocumentType",value:function(i){const n=i.name||"",I=i.publicId||"",r=i.systemId||"";if(this.treeAdapter.setDocumentType(this.document,n,I,r),i.location){const C=this.treeAdapter.getChildNodes(this.document).find(a=>this.treeAdapter.isDocumentTypeNode(a));C&&this.treeAdapter.setNodeSourceCodeLocation(C,i.location)}}},{key:"_attachElementToTree",value:function(i,n){if(this.options.sourceCodeLocationInfo){const I=n&&Object.assign(Object.assign({},n),{startTag:n});this.treeAdapter.setNodeSourceCodeLocation(i,I)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(i);else{const I=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(I,i)}}},{key:"_appendElement",value:function(i,n){const I=this.treeAdapter.createElement(i.tagName,n,i.attrs);this._attachElementToTree(I,i.location)}},{key:"_insertElement",value:function(i,n){const I=this.treeAdapter.createElement(i.tagName,n,i.attrs);this._attachElementToTree(I,i.location),this.openElements.push(I,i.tagID)}},{key:"_insertFakeElement",value:function(i,n){const I=this.treeAdapter.createElement(i,P.NS.HTML,[]);this._attachElementToTree(I,null),this.openElements.push(I,n)}},{key:"_insertTemplate",value:function(i){const n=this.treeAdapter.createElement(i.tagName,P.NS.HTML,i.attrs),I=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(n,I),this._attachElementToTree(n,i.location),this.openElements.push(n,i.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(I,null)}},{key:"_insertFakeRootElement",value:function(){const i=this.treeAdapter.createElement(P.TAG_NAMES.HTML,P.NS.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(i,null),this.treeAdapter.appendChild(this.openElements.current,i),this.openElements.push(i,P.TAG_ID.HTML)}},{key:"_appendCommentNode",value:function(i,n){const I=this.treeAdapter.createCommentNode(i.data);this.treeAdapter.appendChild(n,I),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(I,i.location)}},{key:"_insertCharacters",value:function(i){let n,I;if(this._shouldFosterParentOnInsertion()?({parent:n,beforeElement:I}=this._findFosterParentingLocation(),I?this.treeAdapter.insertTextBefore(n,i.chars,I):this.treeAdapter.insertText(n,i.chars)):(n=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(n,i.chars)),!i.location)return;const r=this.treeAdapter.getChildNodes(n),o=I?r.lastIndexOf(I):r.length,C=r[o-1];if(this.treeAdapter.getNodeSourceCodeLocation(C)){const{endLine:A,endCol:s,endOffset:l}=i.location;this.treeAdapter.updateNodeSourceCodeLocation(C,{endLine:A,endCol:s,endOffset:l})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(C,i.location)}},{key:"_adoptNodes",value:function(i,n){for(let I=this.treeAdapter.getFirstChild(i);I;I=this.treeAdapter.getFirstChild(i))this.treeAdapter.detachNode(I),this.treeAdapter.appendChild(n,I)}},{key:"_setEndLocation",value:function(i,n){if(this.treeAdapter.getNodeSourceCodeLocation(i)&&n.location){const I=n.location,r=this.treeAdapter.getTagName(i),o=n.type===lI.TokenType.END_TAG&&r===n.tagName?{endTag:Object.assign({},I),endLine:I.endLine,endCol:I.endCol,endOffset:I.endOffset}:{endLine:I.startLine,endCol:I.startCol,endOffset:I.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(i,o)}}},{key:"shouldProcessStartTagTokenInForeignContent",value:function(i){if(!this.currentNotInHTML)return!1;let n,I;return this.openElements.stackTop===0&&this.fragmentContext?(n=this.fragmentContext,I=this.fragmentContextID):{current:n,currentTagId:I}=this.openElements,i.tagID===P.TAG_ID.SVG&&this.treeAdapter.getTagName(n)===P.TAG_NAMES.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(n)===P.NS.MATHML?!1:this.tokenizer.inForeignNode||(i.tagID===P.TAG_ID.MGLYPH||i.tagID===P.TAG_ID.MALIGNMARK)&&!this._isIntegrationPoint(I,n,P.NS.HTML)}},{key:"_processToken",value:function(i){switch(i.type){case lI.TokenType.CHARACTER:{this.onCharacter(i);break}case lI.TokenType.NULL_CHARACTER:{this.onNullCharacter(i);break}case lI.TokenType.COMMENT:{this.onComment(i);break}case lI.TokenType.DOCTYPE:{this.onDoctype(i);break}case lI.TokenType.START_TAG:{this._processStartTag(i);break}case lI.TokenType.END_TAG:{this.onEndTag(i);break}case lI.TokenType.EOF:{this.onEof(i);break}case lI.TokenType.WHITESPACE_CHARACTER:{this.onWhitespaceCharacter(i);break}}}},{key:"_isIntegrationPoint",value:function(i,n,I){const r=this.treeAdapter.getNamespaceURI(n),o=this.treeAdapter.getAttrList(n);return Fl.isIntegrationPoint(i,r,o,I)}},{key:"_reconstructActiveFormattingElements",value:function(){const i=this.activeFormattingElements.entries.length;if(i){const n=this.activeFormattingElements.entries.findIndex(r=>r.type===G1e.EntryType.Marker||this.openElements.contains(r.element)),I=n<0?i-1:n-1;for(let r=I;r>=0;r--){const o=this.activeFormattingElements.entries[r];this._insertElement(o.token,this.treeAdapter.getNamespaceURI(o.element)),o.element=this.openElements.current}}}},{key:"_closeTableCell",value:function(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=We.IN_ROW}},{key:"_closePElement",value:function(){this.openElements.generateImpliedEndTagsWithExclusion(P.TAG_ID.P),this.openElements.popUntilTagNamePopped(P.TAG_ID.P)}},{key:"_resetInsertionMode",value:function(){for(let i=this.openElements.stackTop;i>=0;i--)switch(i===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[i]){case P.TAG_ID.TR:{this.insertionMode=We.IN_ROW;return}case P.TAG_ID.TBODY:case P.TAG_ID.THEAD:case P.TAG_ID.TFOOT:{this.insertionMode=We.IN_TABLE_BODY;return}case P.TAG_ID.CAPTION:{this.insertionMode=We.IN_CAPTION;return}case P.TAG_ID.COLGROUP:{this.insertionMode=We.IN_COLUMN_GROUP;return}case P.TAG_ID.TABLE:{this.insertionMode=We.IN_TABLE;return}case P.TAG_ID.BODY:{this.insertionMode=We.IN_BODY;return}case P.TAG_ID.FRAMESET:{this.insertionMode=We.IN_FRAMESET;return}case P.TAG_ID.SELECT:{this._resetInsertionModeForSelect(i);return}case P.TAG_ID.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case P.TAG_ID.HTML:{this.insertionMode=this.headElement?We.AFTER_HEAD:We.BEFORE_HEAD;return}case P.TAG_ID.TD:case P.TAG_ID.TH:{if(i>0){this.insertionMode=We.IN_CELL;return}break}case P.TAG_ID.HEAD:{if(i>0){this.insertionMode=We.IN_HEAD;return}break}}this.insertionMode=We.IN_BODY}},{key:"_resetInsertionModeForSelect",value:function(i){if(i>0)for(let n=i-1;n>0;n--){const I=this.openElements.tagIDs[n];if(I===P.TAG_ID.TEMPLATE)break;if(I===P.TAG_ID.TABLE){this.insertionMode=We.IN_SELECT_IN_TABLE;return}}this.insertionMode=We.IN_SELECT}},{key:"_isElementCausesFosterParenting",value:function(i){return tLe.has(i)}},{key:"_shouldFosterParentOnInsertion",value:function(){return this.fosterParentingEnabled&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}},{key:"_findFosterParentingLocation",value:function(){for(let i=this.openElements.stackTop;i>=0;i--){const n=this.openElements.items[i];switch(this.openElements.tagIDs[i]){case P.TAG_ID.TEMPLATE:{if(this.treeAdapter.getNamespaceURI(n)===P.NS.HTML)return{parent:this.treeAdapter.getTemplateContent(n),beforeElement:null};break}case P.TAG_ID.TABLE:{const I=this.treeAdapter.getParentNode(n);return I?{parent:I,beforeElement:n}:{parent:this.openElements.items[i-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}},{key:"_fosterParentElement",value:function(i){const n=this._findFosterParentingLocation();n.beforeElement?this.treeAdapter.insertBefore(n.parent,i,n.beforeElement):this.treeAdapter.appendChild(n.parent,i)}},{key:"_isSpecialElement",value:function(i,n){const I=this.treeAdapter.getNamespaceURI(i);return P.SPECIAL_ELEMENTS[I].has(n)}},{key:"onCharacter",value:function(i){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){dQt(this,i);return}switch(this.insertionMode){case We.INITIAL:{ZR(this,i);break}case We.BEFORE_HTML:{j2(this,i);break}case We.BEFORE_HEAD:{$2(this,i);break}case We.IN_HEAD:{q2(this,i);break}case We.IN_HEAD_NO_SCRIPT:{eW(this,i);break}case We.AFTER_HEAD:{tW(this,i);break}case We.IN_BODY:case We.IN_CAPTION:case We.IN_CELL:case We.IN_TEMPLATE:{iLe(this,i);break}case We.TEXT:case We.IN_SELECT:case We.IN_SELECT_IN_TABLE:{this._insertCharacters(i);break}case We.IN_TABLE:case We.IN_TABLE_BODY:case We.IN_ROW:{lQ(this,i);break}case We.IN_TABLE_TEXT:{aLe(this,i);break}case We.IN_COLUMN_GROUP:{tE(this,i);break}case We.AFTER_BODY:{gE(this,i);break}case We.AFTER_AFTER_BODY:{t5(this,i);break}}}},{key:"onNullCharacter",value:function(i){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){uQt(this,i);return}switch(this.insertionMode){case We.INITIAL:{ZR(this,i);break}case We.BEFORE_HTML:{j2(this,i);break}case We.BEFORE_HEAD:{$2(this,i);break}case We.IN_HEAD:{q2(this,i);break}case We.IN_HEAD_NO_SCRIPT:{eW(this,i);break}case We.AFTER_HEAD:{tW(this,i);break}case We.TEXT:{this._insertCharacters(i);break}case We.IN_TABLE:case We.IN_TABLE_BODY:case We.IN_ROW:{lQ(this,i);break}case We.IN_COLUMN_GROUP:{tE(this,i);break}case We.AFTER_BODY:{gE(this,i);break}case We.AFTER_AFTER_BODY:{t5(this,i);break}}}},{key:"onComment",value:function(i){if(this.skipNextNewLine=!1,this.currentNotInHTML){jq(this,i);return}switch(this.insertionMode){case We.INITIAL:case We.BEFORE_HTML:case We.BEFORE_HEAD:case We.IN_HEAD:case We.IN_HEAD_NO_SCRIPT:case We.AFTER_HEAD:case We.IN_BODY:case We.IN_TABLE:case We.IN_CAPTION:case We.IN_COLUMN_GROUP:case We.IN_TABLE_BODY:case We.IN_ROW:case We.IN_CELL:case We.IN_SELECT:case We.IN_SELECT_IN_TABLE:case We.IN_TEMPLATE:case We.IN_FRAMESET:case We.AFTER_FRAMESET:{jq(this,i);break}case We.IN_TABLE_TEXT:{GR(this,i);break}case We.AFTER_BODY:{OUt(this,i);break}case We.AFTER_AFTER_BODY:case We.AFTER_AFTER_FRAMESET:{JUt(this,i);break}}}},{key:"onDoctype",value:function(i){switch(this.skipNextNewLine=!1,this.insertionMode){case We.INITIAL:{LUt(this,i);break}case We.BEFORE_HEAD:case We.IN_HEAD:case We.IN_HEAD_NO_SCRIPT:case We.AFTER_HEAD:{this._err(i,pr.ERR.misplacedDoctype);break}case We.IN_TABLE_TEXT:{GR(this,i);break}}}},{key:"onStartTag",value:function(i){this.skipNextNewLine=!1,this.currentToken=i,this._processStartTag(i),i.selfClosing&&!i.ackSelfClosing&&this._err(i,pr.ERR.nonVoidHtmlElementStartTagWithTrailingSolidus)}},{key:"_processStartTag",value:function(i){this.shouldProcessStartTagTokenInForeignContent(i)?hQt(this,i):this._startTagOutsideForeignContent(i)}},{key:"_startTagOutsideForeignContent",value:function(i){switch(this.insertionMode){case We.INITIAL:{ZR(this,i);break}case We.BEFORE_HTML:{UUt(this,i);break}case We.BEFORE_HEAD:{jUt(this,i);break}case We.IN_HEAD:{gl(this,i);break}case We.IN_HEAD_NO_SCRIPT:{e7t(this,i);break}case We.AFTER_HEAD:{g7t(this,i);break}case We.IN_BODY:{ro(this,i);break}case We.IN_TABLE:{cw(this,i);break}case We.IN_TABLE_TEXT:{GR(this,i);break}case We.IN_CAPTION:{$7t(this,i);break}case We.IN_COLUMN_GROUP:{wse(this,i);break}case We.IN_TABLE_BODY:{zP(this,i);break}case We.IN_ROW:{PP(this,i);break}case We.IN_CELL:{tQt(this,i);break}case We.IN_SELECT:{lLe(this,i);break}case We.IN_SELECT_IN_TABLE:{iQt(this,i);break}case We.IN_TEMPLATE:{IQt(this,i);break}case We.AFTER_BODY:{oQt(this,i);break}case We.IN_FRAMESET:{CQt(this,i);break}case We.AFTER_FRAMESET:{sQt(this,i);break}case We.AFTER_AFTER_BODY:{lQt(this,i);break}case We.AFTER_AFTER_FRAMESET:{cQt(this,i);break}}}},{key:"onEndTag",value:function(i){this.skipNextNewLine=!1,this.currentToken=i,this.currentNotInHTML?fQt(this,i):this._endTagOutsideForeignContent(i)}},{key:"_endTagOutsideForeignContent",value:function(i){switch(this.insertionMode){case We.INITIAL:{ZR(this,i);break}case We.BEFORE_HTML:{QUt(this,i);break}case We.BEFORE_HEAD:{$Ut(this,i);break}case We.IN_HEAD:{qUt(this,i);break}case We.IN_HEAD_NO_SCRIPT:{t7t(this,i);break}case We.AFTER_HEAD:{i7t(this,i);break}case We.IN_BODY:{MP(this,i);break}case We.TEXT:{M7t(this,i);break}case We.IN_TABLE:{qX(this,i);break}case We.IN_TABLE_TEXT:{GR(this,i);break}case We.IN_CAPTION:{q7t(this,i);break}case We.IN_COLUMN_GROUP:{eQt(this,i);break}case We.IN_TABLE_BODY:{$q(this,i);break}case We.IN_ROW:{ALe(this,i);break}case We.IN_CELL:{gQt(this,i);break}case We.IN_SELECT:{cLe(this,i);break}case We.IN_SELECT_IN_TABLE:{nQt(this,i);break}case We.IN_TEMPLATE:{rQt(this,i);break}case We.AFTER_BODY:{dLe(this,i);break}case We.IN_FRAMESET:{aQt(this,i);break}case We.AFTER_FRAMESET:{AQt(this,i);break}case We.AFTER_AFTER_BODY:{t5(this,i);break}}}},{key:"onEof",value:function(i){switch(this.insertionMode){case We.INITIAL:{ZR(this,i);break}case We.BEFORE_HTML:{j2(this,i);break}case We.BEFORE_HEAD:{$2(this,i);break}case We.IN_HEAD:{q2(this,i);break}case We.IN_HEAD_NO_SCRIPT:{eW(this,i);break}case We.AFTER_HEAD:{tW(this,i);break}case We.IN_BODY:case We.IN_TABLE:case We.IN_CAPTION:case We.IN_COLUMN_GROUP:case We.IN_TABLE_BODY:case We.IN_ROW:case We.IN_CELL:case We.IN_SELECT:case We.IN_SELECT_IN_TABLE:{oLe(this,i);break}case We.TEXT:{z7t(this,i);break}case We.IN_TABLE_TEXT:{GR(this,i);break}case We.IN_TEMPLATE:{uLe(this,i);break}case We.AFTER_BODY:case We.IN_FRAMESET:case We.AFTER_FRAMESET:case We.AFTER_AFTER_BODY:case We.AFTER_AFTER_FRAMESET:{Bse(this,i);break}}}},{key:"onWhitespaceCharacter",value:function(i){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,i.chars.charCodeAt(0)===eLe.CODE_POINTS.LINE_FEED)){if(i.chars.length===1)return;i.chars=i.chars.substr(1)}if(this.tokenizer.inForeignNode){this._insertCharacters(i);return}switch(this.insertionMode){case We.IN_HEAD:case We.IN_HEAD_NO_SCRIPT:case We.AFTER_HEAD:case We.TEXT:case We.IN_COLUMN_GROUP:case We.IN_SELECT:case We.IN_SELECT_IN_TABLE:case We.IN_FRAMESET:case We.AFTER_FRAMESET:{this._insertCharacters(i);break}case We.IN_BODY:case We.IN_CAPTION:case We.IN_CELL:case We.IN_TEMPLATE:case We.AFTER_BODY:case We.AFTER_AFTER_BODY:case We.AFTER_AFTER_FRAMESET:{gLe(this,i);break}case We.IN_TABLE:case We.IN_TABLE_BODY:case We.IN_ROW:{lQ(this,i);break}case We.IN_TABLE_TEXT:{CLe(this,i);break}}}}],[{key:"parse",value:function(i,n){const I=new this(n);return I.tokenizer.write(i,!0),I.document}},{key:"getFragmentParser",value:function(i,n){const I=Object.assign(Object.assign({},B1e),n);i??(i=I.treeAdapter.createElement(P.TAG_NAMES.TEMPLATE,P.NS.HTML,[]));const r=I.treeAdapter.createElement("documentmock",P.NS.HTML,[]),o=new this(I,r,i);return o.fragmentContextID===P.TAG_ID.TEMPLATE&&o.tmplInsertionModeStack.unshift(We.IN_TEMPLATE),o._initTokenizerForFragmentParsing(),o._insertFakeRootElement(),o._resetInsertionMode(),o._findFormInFragmentContext(),o}}]),e}();$X.Parser=FUt;function EUt(e,g){let i=e.activeFormattingElements.getElementEntryInScopeWithTagName(g.tagName);return i?e.openElements.contains(i.element)?e.openElements.hasInScope(g.tagID)||(i=null):(e.activeFormattingElements.removeEntry(i),i=null):rLe(e,g),i}function DUt(e,g){let i=null,n=e.openElements.stackTop;for(;n>=0;n--){const I=e.openElements.items[n];if(I===g.element)break;e._isSpecialElement(I,e.openElements.tagIDs[n])&&(i=I)}return i||(e.openElements.shortenToLength(n<0?0:n),e.activeFormattingElements.removeEntry(g)),i}function MUt(e,g,i){let n=g,I=e.openElements.getCommonAncestor(g);for(let r=0,o=I;o!==i;r++,o=I){I=e.openElements.getCommonAncestor(o);const C=e.activeFormattingElements.getElementEntry(o),a=C&&r>=KUt;!C||a?(a&&e.activeFormattingElements.removeEntry(C),e.openElements.remove(o)):(o=zUt(e,C),n===g&&(e.activeFormattingElements.bookmark=C),e.treeAdapter.detachNode(n),e.treeAdapter.appendChild(o,n),n=o)}return n}function zUt(e,g){const i=e.treeAdapter.getNamespaceURI(g.element),n=e.treeAdapter.createElement(g.token.tagName,i,g.token.attrs);return e.openElements.replace(g.element,n),g.element=n,n}function PUt(e,g,i){const n=e.treeAdapter.getTagName(g),I=(0,P.getTagID)(n);if(e._isElementCausesFosterParenting(I))e._fosterParentElement(i);else{const r=e.treeAdapter.getNamespaceURI(g);I===P.TAG_ID.TEMPLATE&&r===P.NS.HTML&&(g=e.treeAdapter.getTemplateContent(g)),e.treeAdapter.appendChild(g,i)}}function _Ut(e,g,i){const n=e.treeAdapter.getNamespaceURI(i.element),{token:I}=i,r=e.treeAdapter.createElement(I.tagName,n,I.attrs);e._adoptNodes(g,r),e.treeAdapter.appendChild(g,r),e.activeFormattingElements.insertElementAfterBookmark(r,I),e.activeFormattingElements.removeEntry(i),e.openElements.remove(i.element),e.openElements.insertAfter(g,r,I.tagID)}function vse(e,g){for(let i=0;i=i;n--)e._setEndLocation(e.openElements.items[n],g);if(!e.fragmentContext&&e.openElements.stackTop>=0){const n=e.openElements.items[0],I=e.treeAdapter.getNodeSourceCodeLocation(n);if(I&&!I.endTag&&(e._setEndLocation(n,g),e.openElements.stackTop>=1)){const r=e.openElements.items[1],o=e.treeAdapter.getNodeSourceCodeLocation(r);o&&!o.endTag&&e._setEndLocation(r,g)}}}}function LUt(e,g){e._setDocumentType(g);const i=g.forceQuirks?P.DOCUMENT_MODE.QUIRKS:v1e.getDocumentMode(g);v1e.isConforming(g)||e._err(g,pr.ERR.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,i),e.insertionMode=We.BEFORE_HTML}function ZR(e,g){e._err(g,pr.ERR.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,P.DOCUMENT_MODE.QUIRKS),e.insertionMode=We.BEFORE_HTML,e._processToken(g)}function UUt(e,g){g.tagID===P.TAG_ID.HTML?(e._insertElement(g,P.NS.HTML),e.insertionMode=We.BEFORE_HEAD):j2(e,g)}function QUt(e,g){const i=g.tagID;(i===P.TAG_ID.HTML||i===P.TAG_ID.HEAD||i===P.TAG_ID.BODY||i===P.TAG_ID.BR)&&j2(e,g)}function j2(e,g){e._insertFakeRootElement(),e.insertionMode=We.BEFORE_HEAD,e._processToken(g)}function jUt(e,g){switch(g.tagID){case P.TAG_ID.HTML:{ro(e,g);break}case P.TAG_ID.HEAD:{e._insertElement(g,P.NS.HTML),e.headElement=e.openElements.current,e.insertionMode=We.IN_HEAD;break}default:$2(e,g)}}function $Ut(e,g){const i=g.tagID;i===P.TAG_ID.HEAD||i===P.TAG_ID.BODY||i===P.TAG_ID.HTML||i===P.TAG_ID.BR?$2(e,g):e._err(g,pr.ERR.endTagWithoutMatchingOpenElement)}function $2(e,g){e._insertFakeElement(P.TAG_NAMES.HEAD,P.TAG_ID.HEAD),e.headElement=e.openElements.current,e.insertionMode=We.IN_HEAD,e._processToken(g)}function gl(e,g){switch(g.tagID){case P.TAG_ID.HTML:{ro(e,g);break}case P.TAG_ID.BASE:case P.TAG_ID.BASEFONT:case P.TAG_ID.BGSOUND:case P.TAG_ID.LINK:case P.TAG_ID.META:{e._appendElement(g,P.NS.HTML),g.ackSelfClosing=!0;break}case P.TAG_ID.TITLE:{e._switchToTextParsing(g,po.TokenizerMode.RCDATA);break}case P.TAG_ID.NOSCRIPT:{e.options.scriptingEnabled?e._switchToTextParsing(g,po.TokenizerMode.RAWTEXT):(e._insertElement(g,P.NS.HTML),e.insertionMode=We.IN_HEAD_NO_SCRIPT);break}case P.TAG_ID.NOFRAMES:case P.TAG_ID.STYLE:{e._switchToTextParsing(g,po.TokenizerMode.RAWTEXT);break}case P.TAG_ID.SCRIPT:{e._switchToTextParsing(g,po.TokenizerMode.SCRIPT_DATA);break}case P.TAG_ID.TEMPLATE:{e._insertTemplate(g),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=We.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(We.IN_TEMPLATE);break}case P.TAG_ID.HEAD:{e._err(g,pr.ERR.misplacedStartTagForHeadElement);break}default:q2(e,g)}}function qUt(e,g){switch(g.tagID){case P.TAG_ID.HEAD:{e.openElements.pop(),e.insertionMode=We.AFTER_HEAD;break}case P.TAG_ID.BODY:case P.TAG_ID.BR:case P.TAG_ID.HTML:{q2(e,g);break}case P.TAG_ID.TEMPLATE:{qy(e,g);break}default:e._err(g,pr.ERR.endTagWithoutMatchingOpenElement)}}function qy(e,g){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==P.TAG_ID.TEMPLATE&&e._err(g,pr.ERR.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(P.TAG_ID.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(g,pr.ERR.endTagWithoutMatchingOpenElement)}function q2(e,g){e.openElements.pop(),e.insertionMode=We.AFTER_HEAD,e._processToken(g)}function e7t(e,g){switch(g.tagID){case P.TAG_ID.HTML:{ro(e,g);break}case P.TAG_ID.BASEFONT:case P.TAG_ID.BGSOUND:case P.TAG_ID.HEAD:case P.TAG_ID.LINK:case P.TAG_ID.META:case P.TAG_ID.NOFRAMES:case P.TAG_ID.STYLE:{gl(e,g);break}case P.TAG_ID.NOSCRIPT:{e._err(g,pr.ERR.nestedNoscriptInHead);break}default:eW(e,g)}}function t7t(e,g){switch(g.tagID){case P.TAG_ID.NOSCRIPT:{e.openElements.pop(),e.insertionMode=We.IN_HEAD;break}case P.TAG_ID.BR:{eW(e,g);break}default:e._err(g,pr.ERR.endTagWithoutMatchingOpenElement)}}function eW(e,g){const i=g.type===lI.TokenType.EOF?pr.ERR.openElementsLeftAfterEof:pr.ERR.disallowedContentInNoscriptInHead;e._err(g,i),e.openElements.pop(),e.insertionMode=We.IN_HEAD,e._processToken(g)}function g7t(e,g){switch(g.tagID){case P.TAG_ID.HTML:{ro(e,g);break}case P.TAG_ID.BODY:{e._insertElement(g,P.NS.HTML),e.framesetOk=!1,e.insertionMode=We.IN_BODY;break}case P.TAG_ID.FRAMESET:{e._insertElement(g,P.NS.HTML),e.insertionMode=We.IN_FRAMESET;break}case P.TAG_ID.BASE:case P.TAG_ID.BASEFONT:case P.TAG_ID.BGSOUND:case P.TAG_ID.LINK:case P.TAG_ID.META:case P.TAG_ID.NOFRAMES:case P.TAG_ID.SCRIPT:case P.TAG_ID.STYLE:case P.TAG_ID.TEMPLATE:case P.TAG_ID.TITLE:{e._err(g,pr.ERR.abandonedHeadElementChild),e.openElements.push(e.headElement,P.TAG_ID.HEAD),gl(e,g),e.openElements.remove(e.headElement);break}case P.TAG_ID.HEAD:{e._err(g,pr.ERR.misplacedStartTagForHeadElement);break}default:tW(e,g)}}function i7t(e,g){switch(g.tagID){case P.TAG_ID.BODY:case P.TAG_ID.HTML:case P.TAG_ID.BR:{tW(e,g);break}case P.TAG_ID.TEMPLATE:{qy(e,g);break}default:e._err(g,pr.ERR.endTagWithoutMatchingOpenElement)}}function tW(e,g){e._insertFakeElement(P.TAG_NAMES.BODY,P.TAG_ID.BODY),e.insertionMode=We.IN_BODY,DP(e,g)}function DP(e,g){switch(g.type){case lI.TokenType.CHARACTER:{iLe(e,g);break}case lI.TokenType.WHITESPACE_CHARACTER:{gLe(e,g);break}case lI.TokenType.COMMENT:{jq(e,g);break}case lI.TokenType.START_TAG:{ro(e,g);break}case lI.TokenType.END_TAG:{MP(e,g);break}case lI.TokenType.EOF:{oLe(e,g);break}}}function gLe(e,g){e._reconstructActiveFormattingElements(),e._insertCharacters(g)}function iLe(e,g){e._reconstructActiveFormattingElements(),e._insertCharacters(g),e.framesetOk=!1}function n7t(e,g){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],g.attrs)}function I7t(e,g){const i=e.openElements.tryPeekProperlyNestedBodyElement();i&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(i,g.attrs))}function r7t(e,g){const i=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&i&&(e.treeAdapter.detachNode(i),e.openElements.popAllUpToHtmlElement(),e._insertElement(g,P.NS.HTML),e.insertionMode=We.IN_FRAMESET)}function o7t(e,g){e.openElements.hasInButtonScope(P.TAG_ID.P)&&e._closePElement(),e._insertElement(g,P.NS.HTML)}function C7t(e,g){e.openElements.hasInButtonScope(P.TAG_ID.P)&&e._closePElement(),(0,P.isNumberedHeader)(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(g,P.NS.HTML)}function a7t(e,g){e.openElements.hasInButtonScope(P.TAG_ID.P)&&e._closePElement(),e._insertElement(g,P.NS.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function s7t(e,g){const i=e.openElements.tmplCount>0;(!e.formElement||i)&&(e.openElements.hasInButtonScope(P.TAG_ID.P)&&e._closePElement(),e._insertElement(g,P.NS.HTML),i||(e.formElement=e.openElements.current))}function A7t(e,g){e.framesetOk=!1;const i=g.tagID;for(let n=e.openElements.stackTop;n>=0;n--){const I=e.openElements.tagIDs[n];if(i===P.TAG_ID.LI&&I===P.TAG_ID.LI||(i===P.TAG_ID.DD||i===P.TAG_ID.DT)&&(I===P.TAG_ID.DD||I===P.TAG_ID.DT)){e.openElements.generateImpliedEndTagsWithExclusion(I),e.openElements.popUntilTagNamePopped(I);break}if(I!==P.TAG_ID.ADDRESS&&I!==P.TAG_ID.DIV&&I!==P.TAG_ID.P&&e._isSpecialElement(e.openElements.items[n],I))break}e.openElements.hasInButtonScope(P.TAG_ID.P)&&e._closePElement(),e._insertElement(g,P.NS.HTML)}function l7t(e,g){e.openElements.hasInButtonScope(P.TAG_ID.P)&&e._closePElement(),e._insertElement(g,P.NS.HTML),e.tokenizer.state=po.TokenizerMode.PLAINTEXT}function c7t(e,g){e.openElements.hasInScope(P.TAG_ID.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(P.TAG_ID.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(g,P.NS.HTML),e.framesetOk=!1}function u7t(e,g){const i=e.activeFormattingElements.getElementEntryInScopeWithTagName(P.TAG_NAMES.A);i&&(vse(e,g),e.openElements.remove(i.element),e.activeFormattingElements.removeEntry(i)),e._reconstructActiveFormattingElements(),e._insertElement(g,P.NS.HTML),e.activeFormattingElements.pushElement(e.openElements.current,g)}function d7t(e,g){e._reconstructActiveFormattingElements(),e._insertElement(g,P.NS.HTML),e.activeFormattingElements.pushElement(e.openElements.current,g)}function h7t(e,g){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(P.TAG_ID.NOBR)&&(vse(e,g),e._reconstructActiveFormattingElements()),e._insertElement(g,P.NS.HTML),e.activeFormattingElements.pushElement(e.openElements.current,g)}function f7t(e,g){e._reconstructActiveFormattingElements(),e._insertElement(g,P.NS.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function m7t(e,g){e.treeAdapter.getDocumentMode(e.document)!==P.DOCUMENT_MODE.QUIRKS&&e.openElements.hasInButtonScope(P.TAG_ID.P)&&e._closePElement(),e._insertElement(g,P.NS.HTML),e.framesetOk=!1,e.insertionMode=We.IN_TABLE}function nLe(e,g){e._reconstructActiveFormattingElements(),e._appendElement(g,P.NS.HTML),e.framesetOk=!1,g.ackSelfClosing=!0}function ILe(e){const g=(0,lI.getTokenAttr)(e,P.ATTRS.TYPE);return g!=null&&g.toLowerCase()===kUt}function p7t(e,g){e._reconstructActiveFormattingElements(),e._appendElement(g,P.NS.HTML),ILe(g)||(e.framesetOk=!1),g.ackSelfClosing=!0}function b7t(e,g){e._appendElement(g,P.NS.HTML),g.ackSelfClosing=!0}function y7t(e,g){e.openElements.hasInButtonScope(P.TAG_ID.P)&&e._closePElement(),e._appendElement(g,P.NS.HTML),e.framesetOk=!1,g.ackSelfClosing=!0}function Z7t(e,g){g.tagName=P.TAG_NAMES.IMG,g.tagID=P.TAG_ID.IMG,nLe(e,g)}function G7t(e,g){e._insertElement(g,P.NS.HTML),e.skipNextNewLine=!0,e.tokenizer.state=po.TokenizerMode.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=We.TEXT}function v7t(e,g){e.openElements.hasInButtonScope(P.TAG_ID.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(g,po.TokenizerMode.RAWTEXT)}function B7t(e,g){e.framesetOk=!1,e._switchToTextParsing(g,po.TokenizerMode.RAWTEXT)}function w1e(e,g){e._switchToTextParsing(g,po.TokenizerMode.RAWTEXT)}function w7t(e,g){e._reconstructActiveFormattingElements(),e._insertElement(g,P.NS.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===We.IN_TABLE||e.insertionMode===We.IN_CAPTION||e.insertionMode===We.IN_TABLE_BODY||e.insertionMode===We.IN_ROW||e.insertionMode===We.IN_CELL?We.IN_SELECT_IN_TABLE:We.IN_SELECT}function S7t(e,g){e.openElements.currentTagId===P.TAG_ID.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(g,P.NS.HTML)}function R7t(e,g){e.openElements.hasInScope(P.TAG_ID.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(g,P.NS.HTML)}function V7t(e,g){e.openElements.hasInScope(P.TAG_ID.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(P.TAG_ID.RTC),e._insertElement(g,P.NS.HTML)}function W7t(e,g){e._reconstructActiveFormattingElements(),Fl.adjustTokenMathMLAttrs(g),Fl.adjustTokenXMLAttrs(g),g.selfClosing?e._appendElement(g,P.NS.MATHML):e._insertElement(g,P.NS.MATHML),g.ackSelfClosing=!0}function X7t(e,g){e._reconstructActiveFormattingElements(),Fl.adjustTokenSVGAttrs(g),Fl.adjustTokenXMLAttrs(g),g.selfClosing?e._appendElement(g,P.NS.SVG):e._insertElement(g,P.NS.SVG),g.ackSelfClosing=!0}function S1e(e,g){e._reconstructActiveFormattingElements(),e._insertElement(g,P.NS.HTML)}function ro(e,g){switch(g.tagID){case P.TAG_ID.I:case P.TAG_ID.S:case P.TAG_ID.B:case P.TAG_ID.U:case P.TAG_ID.EM:case P.TAG_ID.TT:case P.TAG_ID.BIG:case P.TAG_ID.CODE:case P.TAG_ID.FONT:case P.TAG_ID.SMALL:case P.TAG_ID.STRIKE:case P.TAG_ID.STRONG:{d7t(e,g);break}case P.TAG_ID.A:{u7t(e,g);break}case P.TAG_ID.H1:case P.TAG_ID.H2:case P.TAG_ID.H3:case P.TAG_ID.H4:case P.TAG_ID.H5:case P.TAG_ID.H6:{C7t(e,g);break}case P.TAG_ID.P:case P.TAG_ID.DL:case P.TAG_ID.OL:case P.TAG_ID.UL:case P.TAG_ID.DIV:case P.TAG_ID.DIR:case P.TAG_ID.NAV:case P.TAG_ID.MAIN:case P.TAG_ID.MENU:case P.TAG_ID.ASIDE:case P.TAG_ID.CENTER:case P.TAG_ID.FIGURE:case P.TAG_ID.FOOTER:case P.TAG_ID.HEADER:case P.TAG_ID.HGROUP:case P.TAG_ID.DIALOG:case P.TAG_ID.DETAILS:case P.TAG_ID.ADDRESS:case P.TAG_ID.ARTICLE:case P.TAG_ID.SECTION:case P.TAG_ID.SUMMARY:case P.TAG_ID.FIELDSET:case P.TAG_ID.BLOCKQUOTE:case P.TAG_ID.FIGCAPTION:{o7t(e,g);break}case P.TAG_ID.LI:case P.TAG_ID.DD:case P.TAG_ID.DT:{A7t(e,g);break}case P.TAG_ID.BR:case P.TAG_ID.IMG:case P.TAG_ID.WBR:case P.TAG_ID.AREA:case P.TAG_ID.EMBED:case P.TAG_ID.KEYGEN:{nLe(e,g);break}case P.TAG_ID.HR:{y7t(e,g);break}case P.TAG_ID.RB:case P.TAG_ID.RTC:{R7t(e,g);break}case P.TAG_ID.RT:case P.TAG_ID.RP:{V7t(e,g);break}case P.TAG_ID.PRE:case P.TAG_ID.LISTING:{a7t(e,g);break}case P.TAG_ID.XMP:{v7t(e,g);break}case P.TAG_ID.SVG:{X7t(e,g);break}case P.TAG_ID.HTML:{n7t(e,g);break}case P.TAG_ID.BASE:case P.TAG_ID.LINK:case P.TAG_ID.META:case P.TAG_ID.STYLE:case P.TAG_ID.TITLE:case P.TAG_ID.SCRIPT:case P.TAG_ID.BGSOUND:case P.TAG_ID.BASEFONT:case P.TAG_ID.TEMPLATE:{gl(e,g);break}case P.TAG_ID.BODY:{I7t(e,g);break}case P.TAG_ID.FORM:{s7t(e,g);break}case P.TAG_ID.NOBR:{h7t(e,g);break}case P.TAG_ID.MATH:{W7t(e,g);break}case P.TAG_ID.TABLE:{m7t(e,g);break}case P.TAG_ID.INPUT:{p7t(e,g);break}case P.TAG_ID.PARAM:case P.TAG_ID.TRACK:case P.TAG_ID.SOURCE:{b7t(e,g);break}case P.TAG_ID.IMAGE:{Z7t(e,g);break}case P.TAG_ID.BUTTON:{c7t(e,g);break}case P.TAG_ID.APPLET:case P.TAG_ID.OBJECT:case P.TAG_ID.MARQUEE:{f7t(e,g);break}case P.TAG_ID.IFRAME:{B7t(e,g);break}case P.TAG_ID.SELECT:{w7t(e,g);break}case P.TAG_ID.OPTION:case P.TAG_ID.OPTGROUP:{S7t(e,g);break}case P.TAG_ID.NOEMBED:{w1e(e,g);break}case P.TAG_ID.FRAMESET:{r7t(e,g);break}case P.TAG_ID.TEXTAREA:{G7t(e,g);break}case P.TAG_ID.NOSCRIPT:{e.options.scriptingEnabled?w1e(e,g):S1e(e,g);break}case P.TAG_ID.PLAINTEXT:{l7t(e,g);break}case P.TAG_ID.COL:case P.TAG_ID.TH:case P.TAG_ID.TD:case P.TAG_ID.TR:case P.TAG_ID.HEAD:case P.TAG_ID.FRAME:case P.TAG_ID.TBODY:case P.TAG_ID.TFOOT:case P.TAG_ID.THEAD:case P.TAG_ID.CAPTION:case P.TAG_ID.COLGROUP:break;default:S1e(e,g)}}function T7t(e,g){if(e.openElements.hasInScope(P.TAG_ID.BODY)&&(e.insertionMode=We.AFTER_BODY,e.options.sourceCodeLocationInfo)){const i=e.openElements.tryPeekProperlyNestedBodyElement();i&&e._setEndLocation(i,g)}}function H7t(e,g){e.openElements.hasInScope(P.TAG_ID.BODY)&&(e.insertionMode=We.AFTER_BODY,dLe(e,g))}function N7t(e,g){const i=g.tagID;e.openElements.hasInScope(i)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(i))}function k7t(e){const g=e.openElements.tmplCount>0,{formElement:i}=e;g||(e.formElement=null),(i||g)&&e.openElements.hasInScope(P.TAG_ID.FORM)&&(e.openElements.generateImpliedEndTags(),g?e.openElements.popUntilTagNamePopped(P.TAG_ID.FORM):i&&e.openElements.remove(i))}function Y7t(e){e.openElements.hasInButtonScope(P.TAG_ID.P)||e._insertFakeElement(P.TAG_NAMES.P,P.TAG_ID.P),e._closePElement()}function K7t(e){e.openElements.hasInListItemScope(P.TAG_ID.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(P.TAG_ID.LI),e.openElements.popUntilTagNamePopped(P.TAG_ID.LI))}function x7t(e,g){const i=g.tagID;e.openElements.hasInScope(i)&&(e.openElements.generateImpliedEndTagsWithExclusion(i),e.openElements.popUntilTagNamePopped(i))}function F7t(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function E7t(e,g){const i=g.tagID;e.openElements.hasInScope(i)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(i),e.activeFormattingElements.clearToLastMarker())}function D7t(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(P.TAG_NAMES.BR,P.TAG_ID.BR),e.openElements.pop(),e.framesetOk=!1}function rLe(e,g){const i=g.tagName,n=g.tagID;for(let I=e.openElements.stackTop;I>0;I--){const r=e.openElements.items[I],o=e.openElements.tagIDs[I];if(n===o&&(n!==P.TAG_ID.UNKNOWN||e.treeAdapter.getTagName(r)===i)){e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.stackTop>=I&&e.openElements.shortenToLength(I);break}if(e._isSpecialElement(r,o))break}}function MP(e,g){switch(g.tagID){case P.TAG_ID.A:case P.TAG_ID.B:case P.TAG_ID.I:case P.TAG_ID.S:case P.TAG_ID.U:case P.TAG_ID.EM:case P.TAG_ID.TT:case P.TAG_ID.BIG:case P.TAG_ID.CODE:case P.TAG_ID.FONT:case P.TAG_ID.NOBR:case P.TAG_ID.SMALL:case P.TAG_ID.STRIKE:case P.TAG_ID.STRONG:{vse(e,g);break}case P.TAG_ID.P:{Y7t(e);break}case P.TAG_ID.DL:case P.TAG_ID.UL:case P.TAG_ID.OL:case P.TAG_ID.DIR:case P.TAG_ID.DIV:case P.TAG_ID.NAV:case P.TAG_ID.PRE:case P.TAG_ID.MAIN:case P.TAG_ID.MENU:case P.TAG_ID.ASIDE:case P.TAG_ID.BUTTON:case P.TAG_ID.CENTER:case P.TAG_ID.FIGURE:case P.TAG_ID.FOOTER:case P.TAG_ID.HEADER:case P.TAG_ID.HGROUP:case P.TAG_ID.DIALOG:case P.TAG_ID.ADDRESS:case P.TAG_ID.ARTICLE:case P.TAG_ID.DETAILS:case P.TAG_ID.SECTION:case P.TAG_ID.SUMMARY:case P.TAG_ID.LISTING:case P.TAG_ID.FIELDSET:case P.TAG_ID.BLOCKQUOTE:case P.TAG_ID.FIGCAPTION:{N7t(e,g);break}case P.TAG_ID.LI:{K7t(e);break}case P.TAG_ID.DD:case P.TAG_ID.DT:{x7t(e,g);break}case P.TAG_ID.H1:case P.TAG_ID.H2:case P.TAG_ID.H3:case P.TAG_ID.H4:case P.TAG_ID.H5:case P.TAG_ID.H6:{F7t(e);break}case P.TAG_ID.BR:{D7t(e);break}case P.TAG_ID.BODY:{T7t(e,g);break}case P.TAG_ID.HTML:{H7t(e,g);break}case P.TAG_ID.FORM:{k7t(e);break}case P.TAG_ID.APPLET:case P.TAG_ID.OBJECT:case P.TAG_ID.MARQUEE:{E7t(e,g);break}case P.TAG_ID.TEMPLATE:{qy(e,g);break}default:rLe(e,g)}}function oLe(e,g){e.tmplInsertionModeStack.length>0?uLe(e,g):Bse(e,g)}function M7t(e,g){var i;g.tagID===P.TAG_ID.SCRIPT&&((i=e.scriptHandler)===null||i===void 0||i.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function z7t(e,g){e._err(g,pr.ERR.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(g)}function lQ(e,g){if(tLe.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=We.IN_TABLE_TEXT,g.type){case lI.TokenType.CHARACTER:{aLe(e,g);break}case lI.TokenType.WHITESPACE_CHARACTER:{CLe(e,g);break}}else UT(e,g)}function P7t(e,g){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(g,P.NS.HTML),e.insertionMode=We.IN_CAPTION}function _7t(e,g){e.openElements.clearBackToTableContext(),e._insertElement(g,P.NS.HTML),e.insertionMode=We.IN_COLUMN_GROUP}function O7t(e,g){e.openElements.clearBackToTableContext(),e._insertFakeElement(P.TAG_NAMES.COLGROUP,P.TAG_ID.COLGROUP),e.insertionMode=We.IN_COLUMN_GROUP,wse(e,g)}function J7t(e,g){e.openElements.clearBackToTableContext(),e._insertElement(g,P.NS.HTML),e.insertionMode=We.IN_TABLE_BODY}function L7t(e,g){e.openElements.clearBackToTableContext(),e._insertFakeElement(P.TAG_NAMES.TBODY,P.TAG_ID.TBODY),e.insertionMode=We.IN_TABLE_BODY,zP(e,g)}function U7t(e,g){e.openElements.hasInTableScope(P.TAG_ID.TABLE)&&(e.openElements.popUntilTagNamePopped(P.TAG_ID.TABLE),e._resetInsertionMode(),e._processStartTag(g))}function Q7t(e,g){ILe(g)?e._appendElement(g,P.NS.HTML):UT(e,g),g.ackSelfClosing=!0}function j7t(e,g){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(g,P.NS.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function cw(e,g){switch(g.tagID){case P.TAG_ID.TD:case P.TAG_ID.TH:case P.TAG_ID.TR:{L7t(e,g);break}case P.TAG_ID.STYLE:case P.TAG_ID.SCRIPT:case P.TAG_ID.TEMPLATE:{gl(e,g);break}case P.TAG_ID.COL:{O7t(e,g);break}case P.TAG_ID.FORM:{j7t(e,g);break}case P.TAG_ID.TABLE:{U7t(e,g);break}case P.TAG_ID.TBODY:case P.TAG_ID.TFOOT:case P.TAG_ID.THEAD:{J7t(e,g);break}case P.TAG_ID.INPUT:{Q7t(e,g);break}case P.TAG_ID.CAPTION:{P7t(e,g);break}case P.TAG_ID.COLGROUP:{_7t(e,g);break}default:UT(e,g)}}function qX(e,g){switch(g.tagID){case P.TAG_ID.TABLE:{e.openElements.hasInTableScope(P.TAG_ID.TABLE)&&(e.openElements.popUntilTagNamePopped(P.TAG_ID.TABLE),e._resetInsertionMode());break}case P.TAG_ID.TEMPLATE:{qy(e,g);break}case P.TAG_ID.BODY:case P.TAG_ID.CAPTION:case P.TAG_ID.COL:case P.TAG_ID.COLGROUP:case P.TAG_ID.HTML:case P.TAG_ID.TBODY:case P.TAG_ID.TD:case P.TAG_ID.TFOOT:case P.TAG_ID.TH:case P.TAG_ID.THEAD:case P.TAG_ID.TR:break;default:UT(e,g)}}function UT(e,g){const i=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,DP(e,g),e.fosterParentingEnabled=i}function CLe(e,g){e.pendingCharacterTokens.push(g)}function aLe(e,g){e.pendingCharacterTokens.push(g),e.hasNonWhitespacePendingCharacterToken=!0}function GR(e,g){let i=0;if(e.hasNonWhitespacePendingCharacterToken)for(;i0&&e.openElements.currentTagId===P.TAG_ID.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===P.TAG_ID.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===P.TAG_ID.OPTGROUP&&e.openElements.pop();break}case P.TAG_ID.OPTION:{e.openElements.currentTagId===P.TAG_ID.OPTION&&e.openElements.pop();break}case P.TAG_ID.SELECT:{e.openElements.hasInSelectScope(P.TAG_ID.SELECT)&&(e.openElements.popUntilTagNamePopped(P.TAG_ID.SELECT),e._resetInsertionMode());break}case P.TAG_ID.TEMPLATE:{qy(e,g);break}}}function iQt(e,g){const i=g.tagID;i===P.TAG_ID.CAPTION||i===P.TAG_ID.TABLE||i===P.TAG_ID.TBODY||i===P.TAG_ID.TFOOT||i===P.TAG_ID.THEAD||i===P.TAG_ID.TR||i===P.TAG_ID.TD||i===P.TAG_ID.TH?(e.openElements.popUntilTagNamePopped(P.TAG_ID.SELECT),e._resetInsertionMode(),e._processStartTag(g)):lLe(e,g)}function nQt(e,g){const i=g.tagID;i===P.TAG_ID.CAPTION||i===P.TAG_ID.TABLE||i===P.TAG_ID.TBODY||i===P.TAG_ID.TFOOT||i===P.TAG_ID.THEAD||i===P.TAG_ID.TR||i===P.TAG_ID.TD||i===P.TAG_ID.TH?e.openElements.hasInTableScope(i)&&(e.openElements.popUntilTagNamePopped(P.TAG_ID.SELECT),e._resetInsertionMode(),e.onEndTag(g)):cLe(e,g)}function IQt(e,g){switch(g.tagID){case P.TAG_ID.BASE:case P.TAG_ID.BASEFONT:case P.TAG_ID.BGSOUND:case P.TAG_ID.LINK:case P.TAG_ID.META:case P.TAG_ID.NOFRAMES:case P.TAG_ID.SCRIPT:case P.TAG_ID.STYLE:case P.TAG_ID.TEMPLATE:case P.TAG_ID.TITLE:{gl(e,g);break}case P.TAG_ID.CAPTION:case P.TAG_ID.COLGROUP:case P.TAG_ID.TBODY:case P.TAG_ID.TFOOT:case P.TAG_ID.THEAD:{e.tmplInsertionModeStack[0]=We.IN_TABLE,e.insertionMode=We.IN_TABLE,cw(e,g);break}case P.TAG_ID.COL:{e.tmplInsertionModeStack[0]=We.IN_COLUMN_GROUP,e.insertionMode=We.IN_COLUMN_GROUP,wse(e,g);break}case P.TAG_ID.TR:{e.tmplInsertionModeStack[0]=We.IN_TABLE_BODY,e.insertionMode=We.IN_TABLE_BODY,zP(e,g);break}case P.TAG_ID.TD:case P.TAG_ID.TH:{e.tmplInsertionModeStack[0]=We.IN_ROW,e.insertionMode=We.IN_ROW,PP(e,g);break}default:e.tmplInsertionModeStack[0]=We.IN_BODY,e.insertionMode=We.IN_BODY,ro(e,g)}}function rQt(e,g){g.tagID===P.TAG_ID.TEMPLATE&&qy(e,g)}function uLe(e,g){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(P.TAG_ID.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(g)):Bse(e,g)}function oQt(e,g){g.tagID===P.TAG_ID.HTML?ro(e,g):gE(e,g)}function dLe(e,g){var i;if(g.tagID===P.TAG_ID.HTML){if(e.fragmentContext||(e.insertionMode=We.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===P.TAG_ID.HTML){e._setEndLocation(e.openElements.items[0],g);const n=e.openElements.items[1];n&&!(!((i=e.treeAdapter.getNodeSourceCodeLocation(n))===null||i===void 0)&&i.endTag)&&e._setEndLocation(n,g)}}else gE(e,g)}function gE(e,g){e.insertionMode=We.IN_BODY,DP(e,g)}function CQt(e,g){switch(g.tagID){case P.TAG_ID.HTML:{ro(e,g);break}case P.TAG_ID.FRAMESET:{e._insertElement(g,P.NS.HTML);break}case P.TAG_ID.FRAME:{e._appendElement(g,P.NS.HTML),g.ackSelfClosing=!0;break}case P.TAG_ID.NOFRAMES:{gl(e,g);break}}}function aQt(e,g){g.tagID===P.TAG_ID.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==P.TAG_ID.FRAMESET&&(e.insertionMode=We.AFTER_FRAMESET))}function sQt(e,g){switch(g.tagID){case P.TAG_ID.HTML:{ro(e,g);break}case P.TAG_ID.NOFRAMES:{gl(e,g);break}}}function AQt(e,g){g.tagID===P.TAG_ID.HTML&&(e.insertionMode=We.AFTER_AFTER_FRAMESET)}function lQt(e,g){g.tagID===P.TAG_ID.HTML?ro(e,g):t5(e,g)}function t5(e,g){e.insertionMode=We.IN_BODY,DP(e,g)}function cQt(e,g){switch(g.tagID){case P.TAG_ID.HTML:{ro(e,g);break}case P.TAG_ID.NOFRAMES:{gl(e,g);break}}}function uQt(e,g){g.chars=eLe.REPLACEMENT_CHARACTER,e._insertCharacters(g)}function dQt(e,g){e._insertCharacters(g),e.framesetOk=!1}function hLe(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==P.NS.HTML&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function hQt(e,g){if(Fl.causesExit(g))hLe(e),e._startTagOutsideForeignContent(g);else{const i=e._getAdjustedCurrentElement(),n=e.treeAdapter.getNamespaceURI(i);n===P.NS.MATHML?Fl.adjustTokenMathMLAttrs(g):n===P.NS.SVG&&(Fl.adjustTokenSVGTagName(g),Fl.adjustTokenSVGAttrs(g)),Fl.adjustTokenXMLAttrs(g),g.selfClosing?e._appendElement(g,n):e._insertElement(g,n),g.ackSelfClosing=!0}}function fQt(e,g){if(g.tagID===P.TAG_ID.P||g.tagID===P.TAG_ID.BR){hLe(e),e._endTagOutsideForeignContent(g);return}for(let i=e.openElements.stackTop;i>0;i--){const n=e.openElements.items[i];if(e.treeAdapter.getNamespaceURI(n)===P.NS.HTML){e._endTagOutsideForeignContent(g);break}const I=e.treeAdapter.getTagName(n);if(I.toLowerCase()===g.tagName){g.tagName=I,e.openElements.shortenToLength(i);break}}}var uw={};Object.defineProperty(uw,"__esModule",{value:!0});uw.serializeOuter=uw.serialize=void 0;const Ei=th,fLe=nw,mQt=EP,pQt=new Set([Ei.TAG_NAMES.AREA,Ei.TAG_NAMES.BASE,Ei.TAG_NAMES.BASEFONT,Ei.TAG_NAMES.BGSOUND,Ei.TAG_NAMES.BR,Ei.TAG_NAMES.COL,Ei.TAG_NAMES.EMBED,Ei.TAG_NAMES.FRAME,Ei.TAG_NAMES.HR,Ei.TAG_NAMES.IMG,Ei.TAG_NAMES.INPUT,Ei.TAG_NAMES.KEYGEN,Ei.TAG_NAMES.LINK,Ei.TAG_NAMES.META,Ei.TAG_NAMES.PARAM,Ei.TAG_NAMES.SOURCE,Ei.TAG_NAMES.TRACK,Ei.TAG_NAMES.WBR]);function mLe(e,g){return g.treeAdapter.isElementNode(e)&&g.treeAdapter.getNamespaceURI(e)===Ei.NS.HTML&&pQt.has(g.treeAdapter.getTagName(e))}const pLe={treeAdapter:mQt.defaultTreeAdapter,scriptingEnabled:!0};function bQt(e,g){const i=Object.assign(Object.assign({},pLe),g);return mLe(e,i)?"":bLe(e,i)}uw.serialize=bQt;function yQt(e,g){const i=Object.assign(Object.assign({},pLe),g);return yLe(e,i)}uw.serializeOuter=yQt;function bLe(e,g){let i="";const n=g.treeAdapter.isElementNode(e)&&g.treeAdapter.getTagName(e)===Ei.TAG_NAMES.TEMPLATE&&g.treeAdapter.getNamespaceURI(e)===Ei.NS.HTML?g.treeAdapter.getTemplateContent(e):e,I=g.treeAdapter.getChildNodes(n);if(I)for(const r of I)i+=yLe(r,g);return i}function yLe(e,g){return g.treeAdapter.isElementNode(e)?ZQt(e,g):g.treeAdapter.isTextNode(e)?vQt(e,g):g.treeAdapter.isCommentNode(e)?BQt(e,g):g.treeAdapter.isDocumentTypeNode(e)?wQt(e,g):""}function ZQt(e,g){const i=g.treeAdapter.getTagName(e);return`<${i}${GQt(e,g)}>${mLe(e,g)?"":`${bLe(e,g)}`}`}function GQt(e,{treeAdapter:g}){let i="";for(const n of g.getAttrList(e)){if(i+=" ",!n.namespace)i+=n.name;else switch(n.namespace){case Ei.NS.XML:{i+=`xml:${n.name}`;break}case Ei.NS.XMLNS:{n.name!=="xmlns"&&(i+="xmlns:"),i+=n.name;break}case Ei.NS.XLINK:{i+=`xlink:${n.name}`;break}default:i+=`${n.prefix}:${n.name}`}i+=`="${(0,fLe.escapeAttribute)(n.value)}"`}return i}function vQt(e,g){const{treeAdapter:i}=g,n=i.getTextNodeContent(e),I=i.getParentNode(e),r=I&&i.isElementNode(I)&&i.getTagName(I);return r&&i.getNamespaceURI(I)===Ei.NS.HTML&&(0,Ei.hasUnescapedText)(r,g.scriptingEnabled)?n:(0,fLe.escapeText)(n)}function BQt(e,{treeAdapter:g}){return``}function wQt(e,{treeAdapter:g}){return``}(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.parseFragment=e.parse=e.TokenizerMode=e.Tokenizer=e.Token=e.html=e.foreignContent=e.ErrorCodes=e.serializeOuter=e.serialize=e.Parser=e.defaultTreeAdapter=void 0;const g=$X;var i=EP;Object.defineProperty(e,"defaultTreeAdapter",{enumerable:!0,get:function(){return i.defaultTreeAdapter}});var n=$X;Object.defineProperty(e,"Parser",{enumerable:!0,get:function(){return n.Parser}});var I=uw;Object.defineProperty(e,"serialize",{enumerable:!0,get:function(){return I.serialize}}),Object.defineProperty(e,"serializeOuter",{enumerable:!0,get:function(){return I.serializeOuter}});var r=LT;Object.defineProperty(e,"ErrorCodes",{enumerable:!0,get:function(){return r.ERR}}),e.foreignContent=Gse,e.html=th,e.Token=xP;var o=Eb;Object.defineProperty(e,"Tokenizer",{enumerable:!0,get:function(){return o.Tokenizer}}),Object.defineProperty(e,"TokenizerMode",{enumerable:!0,get:function(){return o.TokenizerMode}});function C(A,s){return g.Parser.parse(A,s)}e.parse=C;function a(A,s,l){typeof A=="string"&&(l=s,s=A,A=null);const c=g.Parser.getFragmentParser(A,l);return c.tokenizer.write(s,!0),c.getFragment()}e.parseFragment=a})(_Je);var ZLe={},GLe={},e9={},Db={},_P={},OP={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isUndefinedCodePoint=e.isControlCodePoint=e.getSurrogatePairCodePoint=e.isSurrogatePair=e.isSurrogate=e.SEQUENCES=e.CODE_POINTS=e.REPLACEMENT_CHARACTER=void 0;const g=new Set([65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111]);e.REPLACEMENT_CHARACTER="�",function(C){C[C.EOF=-1]="EOF",C[C.NULL=0]="NULL",C[C.TABULATION=9]="TABULATION",C[C.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",C[C.LINE_FEED=10]="LINE_FEED",C[C.FORM_FEED=12]="FORM_FEED",C[C.SPACE=32]="SPACE",C[C.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",C[C.QUOTATION_MARK=34]="QUOTATION_MARK",C[C.NUMBER_SIGN=35]="NUMBER_SIGN",C[C.AMPERSAND=38]="AMPERSAND",C[C.APOSTROPHE=39]="APOSTROPHE",C[C.HYPHEN_MINUS=45]="HYPHEN_MINUS",C[C.SOLIDUS=47]="SOLIDUS",C[C.DIGIT_0=48]="DIGIT_0",C[C.DIGIT_9=57]="DIGIT_9",C[C.SEMICOLON=59]="SEMICOLON",C[C.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",C[C.EQUALS_SIGN=61]="EQUALS_SIGN",C[C.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",C[C.QUESTION_MARK=63]="QUESTION_MARK",C[C.LATIN_CAPITAL_A=65]="LATIN_CAPITAL_A",C[C.LATIN_CAPITAL_F=70]="LATIN_CAPITAL_F",C[C.LATIN_CAPITAL_X=88]="LATIN_CAPITAL_X",C[C.LATIN_CAPITAL_Z=90]="LATIN_CAPITAL_Z",C[C.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",C[C.GRAVE_ACCENT=96]="GRAVE_ACCENT",C[C.LATIN_SMALL_A=97]="LATIN_SMALL_A",C[C.LATIN_SMALL_F=102]="LATIN_SMALL_F",C[C.LATIN_SMALL_X=120]="LATIN_SMALL_X",C[C.LATIN_SMALL_Z=122]="LATIN_SMALL_Z",C[C.REPLACEMENT_CHARACTER=65533]="REPLACEMENT_CHARACTER"}(e.CODE_POINTS||(e.CODE_POINTS={})),e.SEQUENCES={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"};function i(C){return C>=55296&&C<=57343}e.isSurrogate=i;function n(C){return C>=56320&&C<=57343}e.isSurrogatePair=n;function I(C,a){return(C-55296)*1024+9216+a}e.getSurrogatePairCodePoint=I;function r(C){return C!==32&&C!==10&&C!==13&&C!==9&&C!==12&&C>=1&&C<=31||C>=127&&C<=159}e.isControlCodePoint=r;function o(C){return C>=64976&&C<=65007||g.has(C)}e.isUndefinedCodePoint=o})(OP);var QT={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ERR=void 0,function(g){g.controlCharacterInInputStream="control-character-in-input-stream",g.noncharacterInInputStream="noncharacter-in-input-stream",g.surrogateInInputStream="surrogate-in-input-stream",g.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",g.endTagWithAttributes="end-tag-with-attributes",g.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",g.unexpectedSolidusInTag="unexpected-solidus-in-tag",g.unexpectedNullCharacter="unexpected-null-character",g.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",g.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",g.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",g.missingEndTagName="missing-end-tag-name",g.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",g.unknownNamedCharacterReference="unknown-named-character-reference",g.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",g.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",g.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",g.eofBeforeTagName="eof-before-tag-name",g.eofInTag="eof-in-tag",g.missingAttributeValue="missing-attribute-value",g.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",g.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",g.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",g.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",g.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",g.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",g.missingDoctypePublicIdentifier="missing-doctype-public-identifier",g.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",g.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",g.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",g.cdataInHtmlContent="cdata-in-html-content",g.incorrectlyOpenedComment="incorrectly-opened-comment",g.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",g.eofInDoctype="eof-in-doctype",g.nestedComment="nested-comment",g.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",g.eofInComment="eof-in-comment",g.incorrectlyClosedComment="incorrectly-closed-comment",g.eofInCdata="eof-in-cdata",g.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",g.nullCharacterReference="null-character-reference",g.surrogateCharacterReference="surrogate-character-reference",g.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",g.controlCharacterReference="control-character-reference",g.noncharacterCharacterReference="noncharacter-character-reference",g.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",g.missingDoctypeName="missing-doctype-name",g.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",g.duplicateAttribute="duplicate-attribute",g.nonConformingDoctype="non-conforming-doctype",g.missingDoctype="missing-doctype",g.misplacedDoctype="misplaced-doctype",g.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",g.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",g.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",g.openElementsLeftAfterEof="open-elements-left-after-eof",g.abandonedHeadElementChild="abandoned-head-element-child",g.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",g.nestedNoscriptInHead="nested-noscript-in-head",g.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"}(e.ERR||(e.ERR={}))})(QT);function SQt(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function R1e(e,g){for(var i=0;ithis.bufferWaterline}},{key:"dropParsedChunk",value:function(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}},{key:"write",value:function(i,n){this.html.length>0?this.html+=i:this.html=i,this.endOfChunkHit=!1,this.lastChunkWritten=n}},{key:"insertHtmlAtCurrentPos",value:function(i){this.html=this.html.substring(0,this.pos+1)+i+this.html.substring(this.pos+1),this.endOfChunkHit=!1}},{key:"startsWith",value:function(i,n){if(this.pos+i.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(n)return this.html.startsWith(i,this.pos);for(let I=0;I=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,ao.CODE_POINTS.EOF;const I=this.html.charCodeAt(n);return I===ao.CODE_POINTS.CARRIAGE_RETURN?ao.CODE_POINTS.LINE_FEED:I}},{key:"advance",value:function(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,ao.CODE_POINTS.EOF;let i=this.html.charCodeAt(this.pos);return i===ao.CODE_POINTS.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,ao.CODE_POINTS.LINE_FEED):i===ao.CODE_POINTS.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,(0,ao.isSurrogate)(i)&&(i=this._processSurrogate(i)),this.handler.onParseError===null||i>31&&i<127||i===ao.CODE_POINTS.LINE_FEED||i===ao.CODE_POINTS.CARRIAGE_RETURN||i>159&&i<64976||this._checkForProblematicCharacters(i),i)}},{key:"_checkForProblematicCharacters",value:function(i){(0,ao.isControlCodePoint)(i)?this._err(cQ.ERR.controlCharacterInInputStream):(0,ao.isUndefinedCodePoint)(i)&&this._err(cQ.ERR.noncharacterInInputStream)}},{key:"retreat",value:function(i){for(this.pos-=i;this.pos=0;I--)if(i.attrs[I].name===n)return i.attrs[I].value;return null}e.getTokenAttr=g})(JP);var gh={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hasUnescapedText=e.isNumberedHeader=e.SPECIAL_ELEMENTS=e.getTagID=e.TAG_ID=e.TAG_NAMES=e.DOCUMENT_MODE=e.ATTRS=e.NS=void 0;var g;(function(s){s.HTML="http://www.w3.org/1999/xhtml",s.MATHML="http://www.w3.org/1998/Math/MathML",s.SVG="http://www.w3.org/2000/svg",s.XLINK="http://www.w3.org/1999/xlink",s.XML="http://www.w3.org/XML/1998/namespace",s.XMLNS="http://www.w3.org/2000/xmlns/"})(g=e.NS||(e.NS={})),function(s){s.TYPE="type",s.ACTION="action",s.ENCODING="encoding",s.PROMPT="prompt",s.NAME="name",s.COLOR="color",s.FACE="face",s.SIZE="size"}(e.ATTRS||(e.ATTRS={})),function(s){s.NO_QUIRKS="no-quirks",s.QUIRKS="quirks",s.LIMITED_QUIRKS="limited-quirks"}(e.DOCUMENT_MODE||(e.DOCUMENT_MODE={}));var i;(function(s){s.A="a",s.ADDRESS="address",s.ANNOTATION_XML="annotation-xml",s.APPLET="applet",s.AREA="area",s.ARTICLE="article",s.ASIDE="aside",s.B="b",s.BASE="base",s.BASEFONT="basefont",s.BGSOUND="bgsound",s.BIG="big",s.BLOCKQUOTE="blockquote",s.BODY="body",s.BR="br",s.BUTTON="button",s.CAPTION="caption",s.CENTER="center",s.CODE="code",s.COL="col",s.COLGROUP="colgroup",s.DD="dd",s.DESC="desc",s.DETAILS="details",s.DIALOG="dialog",s.DIR="dir",s.DIV="div",s.DL="dl",s.DT="dt",s.EM="em",s.EMBED="embed",s.FIELDSET="fieldset",s.FIGCAPTION="figcaption",s.FIGURE="figure",s.FONT="font",s.FOOTER="footer",s.FOREIGN_OBJECT="foreignObject",s.FORM="form",s.FRAME="frame",s.FRAMESET="frameset",s.H1="h1",s.H2="h2",s.H3="h3",s.H4="h4",s.H5="h5",s.H6="h6",s.HEAD="head",s.HEADER="header",s.HGROUP="hgroup",s.HR="hr",s.HTML="html",s.I="i",s.IMG="img",s.IMAGE="image",s.INPUT="input",s.IFRAME="iframe",s.KEYGEN="keygen",s.LABEL="label",s.LI="li",s.LINK="link",s.LISTING="listing",s.MAIN="main",s.MALIGNMARK="malignmark",s.MARQUEE="marquee",s.MATH="math",s.MENU="menu",s.META="meta",s.MGLYPH="mglyph",s.MI="mi",s.MO="mo",s.MN="mn",s.MS="ms",s.MTEXT="mtext",s.NAV="nav",s.NOBR="nobr",s.NOFRAMES="noframes",s.NOEMBED="noembed",s.NOSCRIPT="noscript",s.OBJECT="object",s.OL="ol",s.OPTGROUP="optgroup",s.OPTION="option",s.P="p",s.PARAM="param",s.PLAINTEXT="plaintext",s.PRE="pre",s.RB="rb",s.RP="rp",s.RT="rt",s.RTC="rtc",s.RUBY="ruby",s.S="s",s.SCRIPT="script",s.SECTION="section",s.SELECT="select",s.SOURCE="source",s.SMALL="small",s.SPAN="span",s.STRIKE="strike",s.STRONG="strong",s.STYLE="style",s.SUB="sub",s.SUMMARY="summary",s.SUP="sup",s.TABLE="table",s.TBODY="tbody",s.TEMPLATE="template",s.TEXTAREA="textarea",s.TFOOT="tfoot",s.TD="td",s.TH="th",s.THEAD="thead",s.TITLE="title",s.TR="tr",s.TRACK="track",s.TT="tt",s.U="u",s.UL="ul",s.SVG="svg",s.VAR="var",s.WBR="wbr",s.XMP="xmp"})(i=e.TAG_NAMES||(e.TAG_NAMES={}));var n;(function(s){s[s.UNKNOWN=0]="UNKNOWN",s[s.A=1]="A",s[s.ADDRESS=2]="ADDRESS",s[s.ANNOTATION_XML=3]="ANNOTATION_XML",s[s.APPLET=4]="APPLET",s[s.AREA=5]="AREA",s[s.ARTICLE=6]="ARTICLE",s[s.ASIDE=7]="ASIDE",s[s.B=8]="B",s[s.BASE=9]="BASE",s[s.BASEFONT=10]="BASEFONT",s[s.BGSOUND=11]="BGSOUND",s[s.BIG=12]="BIG",s[s.BLOCKQUOTE=13]="BLOCKQUOTE",s[s.BODY=14]="BODY",s[s.BR=15]="BR",s[s.BUTTON=16]="BUTTON",s[s.CAPTION=17]="CAPTION",s[s.CENTER=18]="CENTER",s[s.CODE=19]="CODE",s[s.COL=20]="COL",s[s.COLGROUP=21]="COLGROUP",s[s.DD=22]="DD",s[s.DESC=23]="DESC",s[s.DETAILS=24]="DETAILS",s[s.DIALOG=25]="DIALOG",s[s.DIR=26]="DIR",s[s.DIV=27]="DIV",s[s.DL=28]="DL",s[s.DT=29]="DT",s[s.EM=30]="EM",s[s.EMBED=31]="EMBED",s[s.FIELDSET=32]="FIELDSET",s[s.FIGCAPTION=33]="FIGCAPTION",s[s.FIGURE=34]="FIGURE",s[s.FONT=35]="FONT",s[s.FOOTER=36]="FOOTER",s[s.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",s[s.FORM=38]="FORM",s[s.FRAME=39]="FRAME",s[s.FRAMESET=40]="FRAMESET",s[s.H1=41]="H1",s[s.H2=42]="H2",s[s.H3=43]="H3",s[s.H4=44]="H4",s[s.H5=45]="H5",s[s.H6=46]="H6",s[s.HEAD=47]="HEAD",s[s.HEADER=48]="HEADER",s[s.HGROUP=49]="HGROUP",s[s.HR=50]="HR",s[s.HTML=51]="HTML",s[s.I=52]="I",s[s.IMG=53]="IMG",s[s.IMAGE=54]="IMAGE",s[s.INPUT=55]="INPUT",s[s.IFRAME=56]="IFRAME",s[s.KEYGEN=57]="KEYGEN",s[s.LABEL=58]="LABEL",s[s.LI=59]="LI",s[s.LINK=60]="LINK",s[s.LISTING=61]="LISTING",s[s.MAIN=62]="MAIN",s[s.MALIGNMARK=63]="MALIGNMARK",s[s.MARQUEE=64]="MARQUEE",s[s.MATH=65]="MATH",s[s.MENU=66]="MENU",s[s.META=67]="META",s[s.MGLYPH=68]="MGLYPH",s[s.MI=69]="MI",s[s.MO=70]="MO",s[s.MN=71]="MN",s[s.MS=72]="MS",s[s.MTEXT=73]="MTEXT",s[s.NAV=74]="NAV",s[s.NOBR=75]="NOBR",s[s.NOFRAMES=76]="NOFRAMES",s[s.NOEMBED=77]="NOEMBED",s[s.NOSCRIPT=78]="NOSCRIPT",s[s.OBJECT=79]="OBJECT",s[s.OL=80]="OL",s[s.OPTGROUP=81]="OPTGROUP",s[s.OPTION=82]="OPTION",s[s.P=83]="P",s[s.PARAM=84]="PARAM",s[s.PLAINTEXT=85]="PLAINTEXT",s[s.PRE=86]="PRE",s[s.RB=87]="RB",s[s.RP=88]="RP",s[s.RT=89]="RT",s[s.RTC=90]="RTC",s[s.RUBY=91]="RUBY",s[s.S=92]="S",s[s.SCRIPT=93]="SCRIPT",s[s.SECTION=94]="SECTION",s[s.SELECT=95]="SELECT",s[s.SOURCE=96]="SOURCE",s[s.SMALL=97]="SMALL",s[s.SPAN=98]="SPAN",s[s.STRIKE=99]="STRIKE",s[s.STRONG=100]="STRONG",s[s.STYLE=101]="STYLE",s[s.SUB=102]="SUB",s[s.SUMMARY=103]="SUMMARY",s[s.SUP=104]="SUP",s[s.TABLE=105]="TABLE",s[s.TBODY=106]="TBODY",s[s.TEMPLATE=107]="TEMPLATE",s[s.TEXTAREA=108]="TEXTAREA",s[s.TFOOT=109]="TFOOT",s[s.TD=110]="TD",s[s.TH=111]="TH",s[s.THEAD=112]="THEAD",s[s.TITLE=113]="TITLE",s[s.TR=114]="TR",s[s.TRACK=115]="TRACK",s[s.TT=116]="TT",s[s.U=117]="U",s[s.UL=118]="UL",s[s.SVG=119]="SVG",s[s.VAR=120]="VAR",s[s.WBR=121]="WBR",s[s.XMP=122]="XMP"})(n=e.TAG_ID||(e.TAG_ID={}));const I=new Map([[i.A,n.A],[i.ADDRESS,n.ADDRESS],[i.ANNOTATION_XML,n.ANNOTATION_XML],[i.APPLET,n.APPLET],[i.AREA,n.AREA],[i.ARTICLE,n.ARTICLE],[i.ASIDE,n.ASIDE],[i.B,n.B],[i.BASE,n.BASE],[i.BASEFONT,n.BASEFONT],[i.BGSOUND,n.BGSOUND],[i.BIG,n.BIG],[i.BLOCKQUOTE,n.BLOCKQUOTE],[i.BODY,n.BODY],[i.BR,n.BR],[i.BUTTON,n.BUTTON],[i.CAPTION,n.CAPTION],[i.CENTER,n.CENTER],[i.CODE,n.CODE],[i.COL,n.COL],[i.COLGROUP,n.COLGROUP],[i.DD,n.DD],[i.DESC,n.DESC],[i.DETAILS,n.DETAILS],[i.DIALOG,n.DIALOG],[i.DIR,n.DIR],[i.DIV,n.DIV],[i.DL,n.DL],[i.DT,n.DT],[i.EM,n.EM],[i.EMBED,n.EMBED],[i.FIELDSET,n.FIELDSET],[i.FIGCAPTION,n.FIGCAPTION],[i.FIGURE,n.FIGURE],[i.FONT,n.FONT],[i.FOOTER,n.FOOTER],[i.FOREIGN_OBJECT,n.FOREIGN_OBJECT],[i.FORM,n.FORM],[i.FRAME,n.FRAME],[i.FRAMESET,n.FRAMESET],[i.H1,n.H1],[i.H2,n.H2],[i.H3,n.H3],[i.H4,n.H4],[i.H5,n.H5],[i.H6,n.H6],[i.HEAD,n.HEAD],[i.HEADER,n.HEADER],[i.HGROUP,n.HGROUP],[i.HR,n.HR],[i.HTML,n.HTML],[i.I,n.I],[i.IMG,n.IMG],[i.IMAGE,n.IMAGE],[i.INPUT,n.INPUT],[i.IFRAME,n.IFRAME],[i.KEYGEN,n.KEYGEN],[i.LABEL,n.LABEL],[i.LI,n.LI],[i.LINK,n.LINK],[i.LISTING,n.LISTING],[i.MAIN,n.MAIN],[i.MALIGNMARK,n.MALIGNMARK],[i.MARQUEE,n.MARQUEE],[i.MATH,n.MATH],[i.MENU,n.MENU],[i.META,n.META],[i.MGLYPH,n.MGLYPH],[i.MI,n.MI],[i.MO,n.MO],[i.MN,n.MN],[i.MS,n.MS],[i.MTEXT,n.MTEXT],[i.NAV,n.NAV],[i.NOBR,n.NOBR],[i.NOFRAMES,n.NOFRAMES],[i.NOEMBED,n.NOEMBED],[i.NOSCRIPT,n.NOSCRIPT],[i.OBJECT,n.OBJECT],[i.OL,n.OL],[i.OPTGROUP,n.OPTGROUP],[i.OPTION,n.OPTION],[i.P,n.P],[i.PARAM,n.PARAM],[i.PLAINTEXT,n.PLAINTEXT],[i.PRE,n.PRE],[i.RB,n.RB],[i.RP,n.RP],[i.RT,n.RT],[i.RTC,n.RTC],[i.RUBY,n.RUBY],[i.S,n.S],[i.SCRIPT,n.SCRIPT],[i.SECTION,n.SECTION],[i.SELECT,n.SELECT],[i.SOURCE,n.SOURCE],[i.SMALL,n.SMALL],[i.SPAN,n.SPAN],[i.STRIKE,n.STRIKE],[i.STRONG,n.STRONG],[i.STYLE,n.STYLE],[i.SUB,n.SUB],[i.SUMMARY,n.SUMMARY],[i.SUP,n.SUP],[i.TABLE,n.TABLE],[i.TBODY,n.TBODY],[i.TEMPLATE,n.TEMPLATE],[i.TEXTAREA,n.TEXTAREA],[i.TFOOT,n.TFOOT],[i.TD,n.TD],[i.TH,n.TH],[i.THEAD,n.THEAD],[i.TITLE,n.TITLE],[i.TR,n.TR],[i.TRACK,n.TRACK],[i.TT,n.TT],[i.U,n.U],[i.UL,n.UL],[i.SVG,n.SVG],[i.VAR,n.VAR],[i.WBR,n.WBR],[i.XMP,n.XMP]]);function r(s){var l;return(l=I.get(s))!==null&&l!==void 0?l:n.UNKNOWN}e.getTagID=r;const o=n;e.SPECIAL_ELEMENTS={[g.HTML]:new Set([o.ADDRESS,o.APPLET,o.AREA,o.ARTICLE,o.ASIDE,o.BASE,o.BASEFONT,o.BGSOUND,o.BLOCKQUOTE,o.BODY,o.BR,o.BUTTON,o.CAPTION,o.CENTER,o.COL,o.COLGROUP,o.DD,o.DETAILS,o.DIR,o.DIV,o.DL,o.DT,o.EMBED,o.FIELDSET,o.FIGCAPTION,o.FIGURE,o.FOOTER,o.FORM,o.FRAME,o.FRAMESET,o.H1,o.H2,o.H3,o.H4,o.H5,o.H6,o.HEAD,o.HEADER,o.HGROUP,o.HR,o.HTML,o.IFRAME,o.IMG,o.INPUT,o.LI,o.LINK,o.LISTING,o.MAIN,o.MARQUEE,o.MENU,o.META,o.NAV,o.NOEMBED,o.NOFRAMES,o.NOSCRIPT,o.OBJECT,o.OL,o.P,o.PARAM,o.PLAINTEXT,o.PRE,o.SCRIPT,o.SECTION,o.SELECT,o.SOURCE,o.STYLE,o.SUMMARY,o.TABLE,o.TBODY,o.TD,o.TEMPLATE,o.TEXTAREA,o.TFOOT,o.TH,o.THEAD,o.TITLE,o.TR,o.TRACK,o.UL,o.WBR,o.XMP]),[g.MATHML]:new Set([o.MI,o.MO,o.MN,o.MS,o.MTEXT,o.ANNOTATION_XML]),[g.SVG]:new Set([o.TITLE,o.FOREIGN_OBJECT,o.DESC]),[g.XLINK]:new Set,[g.XML]:new Set,[g.XMLNS]:new Set};function C(s){return s===o.H1||s===o.H2||s===o.H3||s===o.H4||s===o.H5||s===o.H6}e.isNumberedHeader=C;const a=new Set([i.STYLE,i.SCRIPT,i.XMP,i.IFRAME,i.NOEMBED,i.NOFRAMES,i.PLAINTEXT]);function A(s,l){return a.has(s)||l&&s===i.NOSCRIPT}e.hasUnescapedText=A})(gh);function HQt(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function V1e(e,g){for(var i=0;i=Ae.CODE_POINTS.DIGIT_0&&e<=Ae.CODE_POINTS.DIGIT_9}function XV(e){return e>=Ae.CODE_POINTS.LATIN_CAPITAL_A&&e<=Ae.CODE_POINTS.LATIN_CAPITAL_Z}function FQt(e){return e>=Ae.CODE_POINTS.LATIN_SMALL_A&&e<=Ae.CODE_POINTS.LATIN_SMALL_Z}function Kh(e){return FQt(e)||XV(e)}function qq(e){return Kh(e)||gW(e)}function vLe(e){return e>=Ae.CODE_POINTS.LATIN_CAPITAL_A&&e<=Ae.CODE_POINTS.LATIN_CAPITAL_F}function BLe(e){return e>=Ae.CODE_POINTS.LATIN_SMALL_A&&e<=Ae.CODE_POINTS.LATIN_SMALL_F}function EQt(e){return gW(e)||vLe(e)||BLe(e)}function Ek(e){return e+32}function wLe(e){return e===Ae.CODE_POINTS.SPACE||e===Ae.CODE_POINTS.LINE_FEED||e===Ae.CODE_POINTS.TABULATION||e===Ae.CODE_POINTS.FORM_FEED}function DQt(e){return e===Ae.CODE_POINTS.EQUALS_SIGN||qq(e)}function W1e(e){return wLe(e)||e===Ae.CODE_POINTS.SOLIDUS||e===Ae.CODE_POINTS.GREATER_THAN_SIGN}let MQt=function(){function e(g,i){HQt(this,e),this.options=g,this.handler=i,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=ve.DATA,this.returnState=ve.DATA,this.charRefCode=-1,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new KQt.Preprocessor(i),this.currentLocation=this.getCurrentLocation(-1)}return NQt(e,[{key:"_err",value:function(i){var n,I;(I=(n=this.handler).onParseError)===null||I===void 0||I.call(n,this.preprocessor.getError(i))}},{key:"getCurrentLocation",value:function(i){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-i,startOffset:this.preprocessor.offset-i,endLine:-1,endCol:-1,endOffset:-1}:null}},{key:"_runParsingLoop",value:function(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;const i=this._consume();this._ensureHibernation()||this._callState(i)}this.inLoop=!1}}},{key:"pause",value:function(){this.paused=!0}},{key:"resume",value:function(i){if(!this.paused)throw new Error("Parser was already resumed");this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||i?.())}},{key:"write",value:function(i,n,I){this.active=!0,this.preprocessor.write(i,n),this._runParsingLoop(),this.paused||I?.()}},{key:"insertHtmlAtCurrentPos",value:function(i){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(i),this._runParsingLoop()}},{key:"_ensureHibernation",value:function(){return this.preprocessor.endOfChunkHit?(this._unconsume(this.consumedAfterSnapshot),this.active=!1,!0):!1}},{key:"_consume",value:function(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}},{key:"_unconsume",value:function(i){this.consumedAfterSnapshot-=i,this.preprocessor.retreat(i)}},{key:"_reconsumeInState",value:function(i,n){this.state=i,this._callState(n)}},{key:"_advanceBy",value:function(i){this.consumedAfterSnapshot+=i;for(let n=0;n0&&this._err(gt.ERR.endTagWithAttributes),i.selfClosing&&this._err(gt.ERR.endTagWithTrailingSolidus),this.handler.onEndTag(i)),this.preprocessor.dropParsedChunk()}},{key:"emitCurrentComment",value:function(i){this.prepareToken(i),this.handler.onComment(i),this.preprocessor.dropParsedChunk()}},{key:"emitCurrentDoctype",value:function(i){this.prepareToken(i),this.handler.onDoctype(i),this.preprocessor.dropParsedChunk()}},{key:"_emitCurrentCharacterToken",value:function(i){if(this.currentCharacterToken){switch(i&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=i.startLine,this.currentCharacterToken.location.endCol=i.startCol,this.currentCharacterToken.location.endOffset=i.startOffset),this.currentCharacterToken.type){case eC.TokenType.CHARACTER:{this.handler.onCharacter(this.currentCharacterToken);break}case eC.TokenType.NULL_CHARACTER:{this.handler.onNullCharacter(this.currentCharacterToken);break}case eC.TokenType.WHITESPACE_CHARACTER:{this.handler.onWhitespaceCharacter(this.currentCharacterToken);break}}this.currentCharacterToken=null}}},{key:"_emitEOFToken",value:function(){const i=this.getCurrentLocation(0);i&&(i.endLine=i.startLine,i.endCol=i.startCol,i.endOffset=i.startOffset),this._emitCurrentCharacterToken(i),this.handler.onEof({type:eC.TokenType.EOF,location:i}),this.active=!1}},{key:"_appendCharToCurrentCharacterToken",value:function(i,n){if(this.currentCharacterToken)if(this.currentCharacterToken.type!==i)this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk();else{this.currentCharacterToken.chars+=n;return}this._createCharacterToken(i,n)}},{key:"_emitCodePoint",value:function(i){const n=wLe(i)?eC.TokenType.WHITESPACE_CHARACTER:i===Ae.CODE_POINTS.NULL?eC.TokenType.NULL_CHARACTER:eC.TokenType.CHARACTER;this._appendCharToCurrentCharacterToken(n,String.fromCodePoint(i))}},{key:"_emitChars",value:function(i){this._appendCharToCurrentCharacterToken(eC.TokenType.CHARACTER,i)}},{key:"_matchNamedCharacterReference",value:function(i){let n=null,I=0,r=!1;for(let o=0,C=pl.htmlDecodeTree[0];o>=0&&(o=(0,pl.determineBranch)(pl.htmlDecodeTree,C,o+1,i),!(o<0));i=this._consume()){I+=1,C=pl.htmlDecodeTree[o];const a=C&pl.BinTrieFlags.VALUE_LENGTH;if(a){const A=(a>>14)-1;if(i!==Ae.CODE_POINTS.SEMICOLON&&this._isCharacterReferenceInAttribute()&&DQt(this.preprocessor.peek(1))?(n=[Ae.CODE_POINTS.AMPERSAND],o+=A):(n=A===0?[pl.htmlDecodeTree[o]&~pl.BinTrieFlags.VALUE_LENGTH]:A===1?[pl.htmlDecodeTree[++o]]:[pl.htmlDecodeTree[++o],pl.htmlDecodeTree[++o]],I=0,r=i!==Ae.CODE_POINTS.SEMICOLON),A===0){this._consume();break}}}return this._unconsume(I),r&&!this.preprocessor.endOfChunkHit&&this._err(gt.ERR.missingSemicolonAfterCharacterReference),this._unconsume(1),n}},{key:"_isCharacterReferenceInAttribute",value:function(){return this.returnState===ve.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===ve.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===ve.ATTRIBUTE_VALUE_UNQUOTED}},{key:"_flushCodePointConsumedAsCharacterReference",value:function(i){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(i):this._emitCodePoint(i)}},{key:"_callState",value:function(i){switch(this.state){case ve.DATA:{this._stateData(i);break}case ve.RCDATA:{this._stateRcdata(i);break}case ve.RAWTEXT:{this._stateRawtext(i);break}case ve.SCRIPT_DATA:{this._stateScriptData(i);break}case ve.PLAINTEXT:{this._statePlaintext(i);break}case ve.TAG_OPEN:{this._stateTagOpen(i);break}case ve.END_TAG_OPEN:{this._stateEndTagOpen(i);break}case ve.TAG_NAME:{this._stateTagName(i);break}case ve.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(i);break}case ve.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(i);break}case ve.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(i);break}case ve.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(i);break}case ve.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(i);break}case ve.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(i);break}case ve.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(i);break}case ve.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(i);break}case ve.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(i);break}case ve.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(i);break}case ve.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(i);break}case ve.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(i);break}case ve.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(i);break}case ve.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(i);break}case ve.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(i);break}case ve.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(i);break}case ve.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(i);break}case ve.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(i);break}case ve.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(i);break}case ve.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(i);break}case ve.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(i);break}case ve.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(i);break}case ve.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(i);break}case ve.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(i);break}case ve.ATTRIBUTE_NAME:{this._stateAttributeName(i);break}case ve.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(i);break}case ve.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(i);break}case ve.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(i);break}case ve.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(i);break}case ve.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(i);break}case ve.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(i);break}case ve.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(i);break}case ve.BOGUS_COMMENT:{this._stateBogusComment(i);break}case ve.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(i);break}case ve.COMMENT_START:{this._stateCommentStart(i);break}case ve.COMMENT_START_DASH:{this._stateCommentStartDash(i);break}case ve.COMMENT:{this._stateComment(i);break}case ve.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(i);break}case ve.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(i);break}case ve.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(i);break}case ve.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(i);break}case ve.COMMENT_END_DASH:{this._stateCommentEndDash(i);break}case ve.COMMENT_END:{this._stateCommentEnd(i);break}case ve.COMMENT_END_BANG:{this._stateCommentEndBang(i);break}case ve.DOCTYPE:{this._stateDoctype(i);break}case ve.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(i);break}case ve.DOCTYPE_NAME:{this._stateDoctypeName(i);break}case ve.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(i);break}case ve.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(i);break}case ve.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(i);break}case ve.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(i);break}case ve.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(i);break}case ve.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(i);break}case ve.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(i);break}case ve.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(i);break}case ve.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(i);break}case ve.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(i);break}case ve.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(i);break}case ve.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(i);break}case ve.BOGUS_DOCTYPE:{this._stateBogusDoctype(i);break}case ve.CDATA_SECTION:{this._stateCdataSection(i);break}case ve.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(i);break}case ve.CDATA_SECTION_END:{this._stateCdataSectionEnd(i);break}case ve.CHARACTER_REFERENCE:{this._stateCharacterReference(i);break}case ve.NAMED_CHARACTER_REFERENCE:{this._stateNamedCharacterReference(i);break}case ve.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(i);break}case ve.NUMERIC_CHARACTER_REFERENCE:{this._stateNumericCharacterReference(i);break}case ve.HEXADEMICAL_CHARACTER_REFERENCE_START:{this._stateHexademicalCharacterReferenceStart(i);break}case ve.HEXADEMICAL_CHARACTER_REFERENCE:{this._stateHexademicalCharacterReference(i);break}case ve.DECIMAL_CHARACTER_REFERENCE:{this._stateDecimalCharacterReference(i);break}case ve.NUMERIC_CHARACTER_REFERENCE_END:{this._stateNumericCharacterReferenceEnd(i);break}default:throw new Error("Unknown state")}}},{key:"_stateData",value:function(i){switch(i){case Ae.CODE_POINTS.LESS_THAN_SIGN:{this.state=ve.TAG_OPEN;break}case Ae.CODE_POINTS.AMPERSAND:{this.returnState=ve.DATA,this.state=ve.CHARACTER_REFERENCE;break}case Ae.CODE_POINTS.NULL:{this._err(gt.ERR.unexpectedNullCharacter),this._emitCodePoint(i);break}case Ae.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(i)}}},{key:"_stateRcdata",value:function(i){switch(i){case Ae.CODE_POINTS.AMPERSAND:{this.returnState=ve.RCDATA,this.state=ve.CHARACTER_REFERENCE;break}case Ae.CODE_POINTS.LESS_THAN_SIGN:{this.state=ve.RCDATA_LESS_THAN_SIGN;break}case Ae.CODE_POINTS.NULL:{this._err(gt.ERR.unexpectedNullCharacter),this._emitChars(Ae.REPLACEMENT_CHARACTER);break}case Ae.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(i)}}},{key:"_stateRawtext",value:function(i){switch(i){case Ae.CODE_POINTS.LESS_THAN_SIGN:{this.state=ve.RAWTEXT_LESS_THAN_SIGN;break}case Ae.CODE_POINTS.NULL:{this._err(gt.ERR.unexpectedNullCharacter),this._emitChars(Ae.REPLACEMENT_CHARACTER);break}case Ae.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(i)}}},{key:"_stateScriptData",value:function(i){switch(i){case Ae.CODE_POINTS.LESS_THAN_SIGN:{this.state=ve.SCRIPT_DATA_LESS_THAN_SIGN;break}case Ae.CODE_POINTS.NULL:{this._err(gt.ERR.unexpectedNullCharacter),this._emitChars(Ae.REPLACEMENT_CHARACTER);break}case Ae.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(i)}}},{key:"_statePlaintext",value:function(i){switch(i){case Ae.CODE_POINTS.NULL:{this._err(gt.ERR.unexpectedNullCharacter),this._emitChars(Ae.REPLACEMENT_CHARACTER);break}case Ae.CODE_POINTS.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(i)}}},{key:"_stateTagOpen",value:function(i){if(Kh(i))this._createStartTagToken(),this.state=ve.TAG_NAME,this._stateTagName(i);else switch(i){case Ae.CODE_POINTS.EXCLAMATION_MARK:{this.state=ve.MARKUP_DECLARATION_OPEN;break}case Ae.CODE_POINTS.SOLIDUS:{this.state=ve.END_TAG_OPEN;break}case Ae.CODE_POINTS.QUESTION_MARK:{this._err(gt.ERR.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=ve.BOGUS_COMMENT,this._stateBogusComment(i);break}case Ae.CODE_POINTS.EOF:{this._err(gt.ERR.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(gt.ERR.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=ve.DATA,this._stateData(i)}}},{key:"_stateEndTagOpen",value:function(i){if(Kh(i))this._createEndTagToken(),this.state=ve.TAG_NAME,this._stateTagName(i);else switch(i){case Ae.CODE_POINTS.GREATER_THAN_SIGN:{this._err(gt.ERR.missingEndTagName),this.state=ve.DATA;break}case Ae.CODE_POINTS.EOF:{this._err(gt.ERR.eofBeforeTagName),this._emitChars("");break}case Ae.CODE_POINTS.NULL:{this._err(gt.ERR.unexpectedNullCharacter),this.state=ve.SCRIPT_DATA_ESCAPED,this._emitChars(Ae.REPLACEMENT_CHARACTER);break}case Ae.CODE_POINTS.EOF:{this._err(gt.ERR.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=ve.SCRIPT_DATA_ESCAPED,this._emitCodePoint(i)}}},{key:"_stateScriptDataEscapedLessThanSign",value:function(i){i===Ae.CODE_POINTS.SOLIDUS?this.state=ve.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:Kh(i)?(this._emitChars("<"),this.state=ve.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(i)):(this._emitChars("<"),this.state=ve.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(i))}},{key:"_stateScriptDataEscapedEndTagOpen",value:function(i){Kh(i)?(this.state=ve.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(i)):(this._emitChars("");break}case Ae.CODE_POINTS.NULL:{this._err(gt.ERR.unexpectedNullCharacter),this.state=ve.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(Ae.REPLACEMENT_CHARACTER);break}case Ae.CODE_POINTS.EOF:{this._err(gt.ERR.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=ve.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(i)}}},{key:"_stateScriptDataDoubleEscapedLessThanSign",value:function(i){i===Ae.CODE_POINTS.SOLIDUS?(this.state=ve.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=ve.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(i))}},{key:"_stateScriptDataDoubleEscapeEnd",value:function(i){if(this.preprocessor.startsWith(Ae.SEQUENCES.SCRIPT,!1)&&W1e(this.preprocessor.peek(Ae.SEQUENCES.SCRIPT.length))){this._emitCodePoint(i);for(let n=0;n1114111)this._err(gt.ERR.characterReferenceOutsideUnicodeRange),this.charRefCode=Ae.CODE_POINTS.REPLACEMENT_CHARACTER;else if((0,Ae.isSurrogate)(this.charRefCode))this._err(gt.ERR.surrogateCharacterReference),this.charRefCode=Ae.CODE_POINTS.REPLACEMENT_CHARACTER;else if((0,Ae.isUndefinedCodePoint)(this.charRefCode))this._err(gt.ERR.noncharacterCharacterReference);else if((0,Ae.isControlCodePoint)(this.charRefCode)||this.charRefCode===Ae.CODE_POINTS.CARRIAGE_RETURN){this._err(gt.ERR.controlCharacterReference);const n=xQt.get(this.charRefCode);n!==void 0&&(this.charRefCode=n)}this._flushCodePointConsumedAsCharacterReference(this.charRefCode),this._reconsumeInState(this.returnState,i)}}]),e}();Db.Tokenizer=MQt;var LP={};function zQt(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function X1e(e,g){for(var i=0;i0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(i,!0)}},{key:"replace",value:function(i,n){const I=this._indexOf(i);this.items[I]=n,I===this.stackTop&&(this.current=n)}},{key:"insertAfter",value:function(i,n,I){const r=this._indexOf(i)+1;this.items.splice(r,0,n),this.tagIDs.splice(r,0,I),this.stackTop++,r===this.stackTop&&this._updateCurrentElement(),this.handler.onItemPush(this.current,this.currentTagId,r===this.stackTop)}},{key:"popUntilTagNamePopped",value:function(i){let n=this.stackTop+1;do n=this.tagIDs.lastIndexOf(i,n-1);while(n>0&&this.treeAdapter.getNamespaceURI(this.items[n])!==ot.NS.HTML);this.shortenToLength(n<0?0:n)}},{key:"shortenToLength",value:function(i){for(;this.stackTop>=i;){const n=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(n,this.stackTop=0;I--)if(i.includes(this.tagIDs[I])&&this.treeAdapter.getNamespaceURI(this.items[I])===n)return I;return-1}},{key:"clearBackTo",value:function(i,n){const I=this._indexOfTagNames(i,n);this.shortenToLength(I+1)}},{key:"clearBackToTableContext",value:function(){this.clearBackTo(QQt,ot.NS.HTML)}},{key:"clearBackToTableBodyContext",value:function(){this.clearBackTo(UQt,ot.NS.HTML)}},{key:"clearBackToTableRowContext",value:function(){this.clearBackTo(LQt,ot.NS.HTML)}},{key:"remove",value:function(i){const n=this._indexOf(i);n>=0&&(n===this.stackTop?this.pop():(this.items.splice(n,1),this.tagIDs.splice(n,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(i,!1)))}},{key:"tryPeekProperlyNestedBodyElement",value:function(){return this.stackTop>=1&&this.tagIDs[1]===ot.TAG_ID.BODY?this.items[1]:null}},{key:"contains",value:function(i){return this._indexOf(i)>-1}},{key:"getCommonAncestor",value:function(i){const n=this._indexOf(i)-1;return n>=0?this.items[n]:null}},{key:"isRootHtmlElementCurrent",value:function(){return this.stackTop===0&&this.tagIDs[0]===ot.TAG_ID.HTML}},{key:"hasInScope",value:function(i){for(let n=this.stackTop;n>=0;n--){const I=this.tagIDs[n],r=this.treeAdapter.getNamespaceURI(this.items[n]);if(I===i&&r===ot.NS.HTML)return!0;if(Dk.get(I)===r)return!1}return!0}},{key:"hasNumberedHeaderInScope",value:function(){for(let i=this.stackTop;i>=0;i--){const n=this.tagIDs[i],I=this.treeAdapter.getNamespaceURI(this.items[i]);if((0,ot.isNumberedHeader)(n)&&I===ot.NS.HTML)return!0;if(Dk.get(n)===I)return!1}return!0}},{key:"hasInListItemScope",value:function(i){for(let n=this.stackTop;n>=0;n--){const I=this.tagIDs[n],r=this.treeAdapter.getNamespaceURI(this.items[n]);if(I===i&&r===ot.NS.HTML)return!0;if((I===ot.TAG_ID.UL||I===ot.TAG_ID.OL)&&r===ot.NS.HTML||Dk.get(I)===r)return!1}return!0}},{key:"hasInButtonScope",value:function(i){for(let n=this.stackTop;n>=0;n--){const I=this.tagIDs[n],r=this.treeAdapter.getNamespaceURI(this.items[n]);if(I===i&&r===ot.NS.HTML)return!0;if(I===ot.TAG_ID.BUTTON&&r===ot.NS.HTML||Dk.get(I)===r)return!1}return!0}},{key:"hasInTableScope",value:function(i){for(let n=this.stackTop;n>=0;n--){const I=this.tagIDs[n];if(this.treeAdapter.getNamespaceURI(this.items[n])===ot.NS.HTML){if(I===i)return!0;if(I===ot.TAG_ID.TABLE||I===ot.TAG_ID.TEMPLATE||I===ot.TAG_ID.HTML)return!1}}return!0}},{key:"hasTableBodyContextInTableScope",value:function(){for(let i=this.stackTop;i>=0;i--){const n=this.tagIDs[i];if(this.treeAdapter.getNamespaceURI(this.items[i])===ot.NS.HTML){if(n===ot.TAG_ID.TBODY||n===ot.TAG_ID.THEAD||n===ot.TAG_ID.TFOOT)return!0;if(n===ot.TAG_ID.TABLE||n===ot.TAG_ID.HTML)return!1}}return!0}},{key:"hasInSelectScope",value:function(i){for(let n=this.stackTop;n>=0;n--){const I=this.tagIDs[n];if(this.treeAdapter.getNamespaceURI(this.items[n])===ot.NS.HTML){if(I===i)return!0;if(I!==ot.TAG_ID.OPTION&&I!==ot.TAG_ID.OPTGROUP)return!1}}return!0}},{key:"generateImpliedEndTags",value:function(){for(;SLe.has(this.currentTagId);)this.pop()}},{key:"generateImpliedEndTagsThoroughly",value:function(){for(;T1e.has(this.currentTagId);)this.pop()}},{key:"generateImpliedEndTagsWithExclusion",value:function(i){for(;this.currentTagId!==i&&T1e.has(this.currentTagId);)this.pop()}}]),e}();LP.OpenElementStack=$Qt;var RLe={};(function(e){function g(s,l){if(!(s instanceof l))throw new TypeError("Cannot call a class as a function")}function i(s,l){for(var c=0;c[m.name,m.value]));let f=0;for(let m=0;mh.get(p.name)===p.value)&&(f+=1,f>=o&&this.entries.splice(b.idx,1))}}},{key:"insertMarker",value:function(){this.entries.unshift(a)}},{key:"pushElement",value:function(c,u){this._ensureNoahArkCondition(c),this.entries.unshift({type:C.Element,element:c,token:u})}},{key:"insertElementAfterBookmark",value:function(c,u){const d=this.entries.indexOf(this.bookmark);this.entries.splice(d,0,{type:C.Element,element:c,token:u})}},{key:"removeEntry",value:function(c){const u=this.entries.indexOf(c);u>=0&&this.entries.splice(u,1)}},{key:"clearToLastMarker",value:function(){const c=this.entries.indexOf(a);c>=0?this.entries.splice(0,c+1):this.entries.length=0}},{key:"getElementEntryInScopeWithTagName",value:function(c){const u=this.entries.find(d=>d.type===C.Marker||this.treeAdapter.getTagName(d.element)===c);return u&&u.type===C.Element?u:null}},{key:"getElementEntry",value:function(c){return this.entries.find(u=>u.type===C.Element&&u.element===c)}}]),s}();e.FormattingElementList=A})(RLe);var UP={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.defaultTreeAdapter=void 0;const g=gh;function i(n){return{nodeName:"#text",value:n,parentNode:null}}e.defaultTreeAdapter={createDocument(){return{nodeName:"#document",mode:g.DOCUMENT_MODE.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:"#document-fragment",childNodes:[]}},createElement(n,I,r){return{nodeName:n,tagName:n,attrs:r,namespaceURI:I,childNodes:[],parentNode:null}},createCommentNode(n){return{nodeName:"#comment",data:n,parentNode:null}},appendChild(n,I){n.childNodes.push(I),I.parentNode=n},insertBefore(n,I,r){const o=n.childNodes.indexOf(r);n.childNodes.splice(o,0,I),I.parentNode=n},setTemplateContent(n,I){n.content=I},getTemplateContent(n){return n.content},setDocumentType(n,I,r,o){const C=n.childNodes.find(a=>a.nodeName==="#documentType");if(C)C.name=I,C.publicId=r,C.systemId=o;else{const a={nodeName:"#documentType",name:I,publicId:r,systemId:o,parentNode:null};e.defaultTreeAdapter.appendChild(n,a)}},setDocumentMode(n,I){n.mode=I},getDocumentMode(n){return n.mode},detachNode(n){if(n.parentNode){const I=n.parentNode.childNodes.indexOf(n);n.parentNode.childNodes.splice(I,1),n.parentNode=null}},insertText(n,I){if(n.childNodes.length>0){const r=n.childNodes[n.childNodes.length-1];if(e.defaultTreeAdapter.isTextNode(r)){r.value+=I;return}}e.defaultTreeAdapter.appendChild(n,i(I))},insertTextBefore(n,I,r){const o=n.childNodes[n.childNodes.indexOf(r)-1];o&&e.defaultTreeAdapter.isTextNode(o)?o.value+=I:e.defaultTreeAdapter.insertBefore(n,i(I),r)},adoptAttributes(n,I){const r=new Set(n.attrs.map(o=>o.name));for(let o=0;oe.startsWith(i))}function njt(e){return e.name===VLe&&e.publicId===null&&(e.systemId===null||e.systemId===qQt)}dw.isConforming=njt;function Ijt(e){if(e.name!==VLe)return jZ.DOCUMENT_MODE.QUIRKS;const{systemId:g}=e;if(g&&g.toLowerCase()===ejt)return jZ.DOCUMENT_MODE.QUIRKS;let{publicId:i}=e;if(i!==null){if(i=i.toLowerCase(),gjt.has(i))return jZ.DOCUMENT_MODE.QUIRKS;let n=g===null?tjt:WLe;if(H1e(i,n))return jZ.DOCUMENT_MODE.QUIRKS;if(n=g===null?XLe:ijt,H1e(i,n))return jZ.DOCUMENT_MODE.LIMITED_QUIRKS}return jZ.DOCUMENT_MODE.NO_QUIRKS}dw.getDocumentMode=Ijt;var Sse={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isIntegrationPoint=e.adjustTokenSVGTagName=e.adjustTokenXMLAttrs=e.adjustTokenSVGAttrs=e.adjustTokenMathMLAttrs=e.causesExit=e.SVG_TAG_NAMES_ADJUSTMENT_MAP=void 0;const g=gh,i={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},n="definitionurl",I="definitionURL",r=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map(f=>[f.toLowerCase(),f])),o=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:g.NS.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:g.NS.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:g.NS.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:g.NS.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:g.NS.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:g.NS.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:g.NS.XLINK}],["xml:base",{prefix:"xml",name:"base",namespace:g.NS.XML}],["xml:lang",{prefix:"xml",name:"lang",namespace:g.NS.XML}],["xml:space",{prefix:"xml",name:"space",namespace:g.NS.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:g.NS.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:g.NS.XMLNS}]]);e.SVG_TAG_NAMES_ADJUSTMENT_MAP=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map(f=>[f.toLowerCase(),f]));const C=new Set([g.TAG_ID.B,g.TAG_ID.BIG,g.TAG_ID.BLOCKQUOTE,g.TAG_ID.BODY,g.TAG_ID.BR,g.TAG_ID.CENTER,g.TAG_ID.CODE,g.TAG_ID.DD,g.TAG_ID.DIV,g.TAG_ID.DL,g.TAG_ID.DT,g.TAG_ID.EM,g.TAG_ID.EMBED,g.TAG_ID.H1,g.TAG_ID.H2,g.TAG_ID.H3,g.TAG_ID.H4,g.TAG_ID.H5,g.TAG_ID.H6,g.TAG_ID.HEAD,g.TAG_ID.HR,g.TAG_ID.I,g.TAG_ID.IMG,g.TAG_ID.LI,g.TAG_ID.LISTING,g.TAG_ID.MENU,g.TAG_ID.META,g.TAG_ID.NOBR,g.TAG_ID.OL,g.TAG_ID.P,g.TAG_ID.PRE,g.TAG_ID.RUBY,g.TAG_ID.S,g.TAG_ID.SMALL,g.TAG_ID.SPAN,g.TAG_ID.STRONG,g.TAG_ID.STRIKE,g.TAG_ID.SUB,g.TAG_ID.SUP,g.TAG_ID.TABLE,g.TAG_ID.TT,g.TAG_ID.U,g.TAG_ID.UL,g.TAG_ID.VAR]);function a(f){const m=f.tagID;return m===g.TAG_ID.FONT&&f.attrs.some(({name:p})=>p===g.ATTRS.COLOR||p===g.ATTRS.SIZE||p===g.ATTRS.FACE)||C.has(m)}e.causesExit=a;function A(f){for(let m=0;m0&&this._setContextModes(i,n)}},{key:"onItemPop",value:function(i,n){var I,r;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(i,this.currentToken),(r=(I=this.treeAdapter).onItemPop)===null||r===void 0||r.call(I,i,this.openElements.current),n){let o,C;this.openElements.stackTop===0&&this.fragmentContext?(o=this.fragmentContext,C=this.fragmentContextID):{current:o,currentTagId:C}=this.openElements,this._setContextModes(o,C)}}},{key:"_setContextModes",value:function(i,n){const I=i===this.document||this.treeAdapter.getNamespaceURI(i)===_.NS.HTML;this.currentNotInHTML=!I,this.tokenizer.inForeignNode=!I&&!this._isIntegrationPoint(n,i)}},{key:"_switchToTextParsing",value:function(i,n){this._insertElement(i,_.NS.HTML),this.tokenizer.state=n,this.originalInsertionMode=this.insertionMode,this.insertionMode=Xe.TEXT}},{key:"switchToPlaintextParsing",value:function(){this.insertionMode=Xe.TEXT,this.originalInsertionMode=Xe.IN_BODY,this.tokenizer.state=bo.TokenizerMode.PLAINTEXT}},{key:"_getAdjustedCurrentElement",value:function(){return this.openElements.stackTop===0&&this.fragmentContext?this.fragmentContext:this.openElements.current}},{key:"_findFormInFragmentContext",value:function(){let i=this.fragmentContext;for(;i;){if(this.treeAdapter.getTagName(i)===_.TAG_NAMES.FORM){this.formElement=i;break}i=this.treeAdapter.getParentNode(i)}}},{key:"_initTokenizerForFragmentParsing",value:function(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==_.NS.HTML))switch(this.fragmentContextID){case _.TAG_ID.TITLE:case _.TAG_ID.TEXTAREA:{this.tokenizer.state=bo.TokenizerMode.RCDATA;break}case _.TAG_ID.STYLE:case _.TAG_ID.XMP:case _.TAG_ID.IFRAME:case _.TAG_ID.NOEMBED:case _.TAG_ID.NOFRAMES:case _.TAG_ID.NOSCRIPT:{this.tokenizer.state=bo.TokenizerMode.RAWTEXT;break}case _.TAG_ID.SCRIPT:{this.tokenizer.state=bo.TokenizerMode.SCRIPT_DATA;break}case _.TAG_ID.PLAINTEXT:{this.tokenizer.state=bo.TokenizerMode.PLAINTEXT;break}}}},{key:"_setDocumentType",value:function(i){const n=i.name||"",I=i.publicId||"",r=i.systemId||"";if(this.treeAdapter.setDocumentType(this.document,n,I,r),i.location){const C=this.treeAdapter.getChildNodes(this.document).find(a=>this.treeAdapter.isDocumentTypeNode(a));C&&this.treeAdapter.setNodeSourceCodeLocation(C,i.location)}}},{key:"_attachElementToTree",value:function(i,n){if(this.options.sourceCodeLocationInfo){const I=n&&Object.assign(Object.assign({},n),{startTag:n});this.treeAdapter.setNodeSourceCodeLocation(i,I)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(i);else{const I=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(I,i)}}},{key:"_appendElement",value:function(i,n){const I=this.treeAdapter.createElement(i.tagName,n,i.attrs);this._attachElementToTree(I,i.location)}},{key:"_insertElement",value:function(i,n){const I=this.treeAdapter.createElement(i.tagName,n,i.attrs);this._attachElementToTree(I,i.location),this.openElements.push(I,i.tagID)}},{key:"_insertFakeElement",value:function(i,n){const I=this.treeAdapter.createElement(i,_.NS.HTML,[]);this._attachElementToTree(I,null),this.openElements.push(I,n)}},{key:"_insertTemplate",value:function(i){const n=this.treeAdapter.createElement(i.tagName,_.NS.HTML,i.attrs),I=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(n,I),this._attachElementToTree(n,i.location),this.openElements.push(n,i.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(I,null)}},{key:"_insertFakeRootElement",value:function(){const i=this.treeAdapter.createElement(_.TAG_NAMES.HTML,_.NS.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(i,null),this.treeAdapter.appendChild(this.openElements.current,i),this.openElements.push(i,_.TAG_ID.HTML)}},{key:"_appendCommentNode",value:function(i,n){const I=this.treeAdapter.createCommentNode(i.data);this.treeAdapter.appendChild(n,I),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(I,i.location)}},{key:"_insertCharacters",value:function(i){let n,I;if(this._shouldFosterParentOnInsertion()?({parent:n,beforeElement:I}=this._findFosterParentingLocation(),I?this.treeAdapter.insertTextBefore(n,i.chars,I):this.treeAdapter.insertText(n,i.chars)):(n=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(n,i.chars)),!i.location)return;const r=this.treeAdapter.getChildNodes(n),o=I?r.lastIndexOf(I):r.length,C=r[o-1];if(this.treeAdapter.getNodeSourceCodeLocation(C)){const{endLine:A,endCol:s,endOffset:l}=i.location;this.treeAdapter.updateNodeSourceCodeLocation(C,{endLine:A,endCol:s,endOffset:l})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(C,i.location)}},{key:"_adoptNodes",value:function(i,n){for(let I=this.treeAdapter.getFirstChild(i);I;I=this.treeAdapter.getFirstChild(i))this.treeAdapter.detachNode(I),this.treeAdapter.appendChild(n,I)}},{key:"_setEndLocation",value:function(i,n){if(this.treeAdapter.getNodeSourceCodeLocation(i)&&n.location){const I=n.location,r=this.treeAdapter.getTagName(i),o=n.type===cI.TokenType.END_TAG&&r===n.tagName?{endTag:Object.assign({},I),endLine:I.endLine,endCol:I.endCol,endOffset:I.endOffset}:{endLine:I.startLine,endCol:I.startCol,endOffset:I.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(i,o)}}},{key:"shouldProcessStartTagTokenInForeignContent",value:function(i){if(!this.currentNotInHTML)return!1;let n,I;return this.openElements.stackTop===0&&this.fragmentContext?(n=this.fragmentContext,I=this.fragmentContextID):{current:n,currentTagId:I}=this.openElements,i.tagID===_.TAG_ID.SVG&&this.treeAdapter.getTagName(n)===_.TAG_NAMES.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(n)===_.NS.MATHML?!1:this.tokenizer.inForeignNode||(i.tagID===_.TAG_ID.MGLYPH||i.tagID===_.TAG_ID.MALIGNMARK)&&!this._isIntegrationPoint(I,n,_.NS.HTML)}},{key:"_processToken",value:function(i){switch(i.type){case cI.TokenType.CHARACTER:{this.onCharacter(i);break}case cI.TokenType.NULL_CHARACTER:{this.onNullCharacter(i);break}case cI.TokenType.COMMENT:{this.onComment(i);break}case cI.TokenType.DOCTYPE:{this.onDoctype(i);break}case cI.TokenType.START_TAG:{this._processStartTag(i);break}case cI.TokenType.END_TAG:{this.onEndTag(i);break}case cI.TokenType.EOF:{this.onEof(i);break}case cI.TokenType.WHITESPACE_CHARACTER:{this.onWhitespaceCharacter(i);break}}}},{key:"_isIntegrationPoint",value:function(i,n,I){const r=this.treeAdapter.getNamespaceURI(n),o=this.treeAdapter.getAttrList(n);return El.isIntegrationPoint(i,r,o,I)}},{key:"_reconstructActiveFormattingElements",value:function(){const i=this.activeFormattingElements.entries.length;if(i){const n=this.activeFormattingElements.entries.findIndex(r=>r.type===k1e.EntryType.Marker||this.openElements.contains(r.element)),I=n<0?i-1:n-1;for(let r=I;r>=0;r--){const o=this.activeFormattingElements.entries[r];this._insertElement(o.token,this.treeAdapter.getNamespaceURI(o.element)),o.element=this.openElements.current}}}},{key:"_closeTableCell",value:function(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=Xe.IN_ROW}},{key:"_closePElement",value:function(){this.openElements.generateImpliedEndTagsWithExclusion(_.TAG_ID.P),this.openElements.popUntilTagNamePopped(_.TAG_ID.P)}},{key:"_resetInsertionMode",value:function(){for(let i=this.openElements.stackTop;i>=0;i--)switch(i===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[i]){case _.TAG_ID.TR:{this.insertionMode=Xe.IN_ROW;return}case _.TAG_ID.TBODY:case _.TAG_ID.THEAD:case _.TAG_ID.TFOOT:{this.insertionMode=Xe.IN_TABLE_BODY;return}case _.TAG_ID.CAPTION:{this.insertionMode=Xe.IN_CAPTION;return}case _.TAG_ID.COLGROUP:{this.insertionMode=Xe.IN_COLUMN_GROUP;return}case _.TAG_ID.TABLE:{this.insertionMode=Xe.IN_TABLE;return}case _.TAG_ID.BODY:{this.insertionMode=Xe.IN_BODY;return}case _.TAG_ID.FRAMESET:{this.insertionMode=Xe.IN_FRAMESET;return}case _.TAG_ID.SELECT:{this._resetInsertionModeForSelect(i);return}case _.TAG_ID.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case _.TAG_ID.HTML:{this.insertionMode=this.headElement?Xe.AFTER_HEAD:Xe.BEFORE_HEAD;return}case _.TAG_ID.TD:case _.TAG_ID.TH:{if(i>0){this.insertionMode=Xe.IN_CELL;return}break}case _.TAG_ID.HEAD:{if(i>0){this.insertionMode=Xe.IN_HEAD;return}break}}this.insertionMode=Xe.IN_BODY}},{key:"_resetInsertionModeForSelect",value:function(i){if(i>0)for(let n=i-1;n>0;n--){const I=this.openElements.tagIDs[n];if(I===_.TAG_ID.TEMPLATE)break;if(I===_.TAG_ID.TABLE){this.insertionMode=Xe.IN_SELECT_IN_TABLE;return}}this.insertionMode=Xe.IN_SELECT}},{key:"_isElementCausesFosterParenting",value:function(i){return HLe.has(i)}},{key:"_shouldFosterParentOnInsertion",value:function(){return this.fosterParentingEnabled&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}},{key:"_findFosterParentingLocation",value:function(){for(let i=this.openElements.stackTop;i>=0;i--){const n=this.openElements.items[i];switch(this.openElements.tagIDs[i]){case _.TAG_ID.TEMPLATE:{if(this.treeAdapter.getNamespaceURI(n)===_.NS.HTML)return{parent:this.treeAdapter.getTemplateContent(n),beforeElement:null};break}case _.TAG_ID.TABLE:{const I=this.treeAdapter.getParentNode(n);return I?{parent:I,beforeElement:n}:{parent:this.openElements.items[i-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}},{key:"_fosterParentElement",value:function(i){const n=this._findFosterParentingLocation();n.beforeElement?this.treeAdapter.insertBefore(n.parent,i,n.beforeElement):this.treeAdapter.appendChild(n.parent,i)}},{key:"_isSpecialElement",value:function(i,n){const I=this.treeAdapter.getNamespaceURI(i);return _.SPECIAL_ELEMENTS[I].has(n)}},{key:"onCharacter",value:function(i){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){O4t(this,i);return}switch(this.insertionMode){case Xe.INITIAL:{vR(this,i);break}case Xe.BEFORE_HTML:{iW(this,i);break}case Xe.BEFORE_HEAD:{nW(this,i);break}case Xe.IN_HEAD:{IW(this,i);break}case Xe.IN_HEAD_NO_SCRIPT:{rW(this,i);break}case Xe.AFTER_HEAD:{oW(this,i);break}case Xe.IN_BODY:case Xe.IN_CAPTION:case Xe.IN_CELL:case Xe.IN_TEMPLATE:{kLe(this,i);break}case Xe.TEXT:case Xe.IN_SELECT:case Xe.IN_SELECT_IN_TABLE:{this._insertCharacters(i);break}case Xe.IN_TABLE:case Xe.IN_TABLE_BODY:case Xe.IN_ROW:{dQ(this,i);break}case Xe.IN_TABLE_TEXT:{DLe(this,i);break}case Xe.IN_COLUMN_GROUP:{iE(this,i);break}case Xe.AFTER_BODY:{nE(this,i);break}case Xe.AFTER_AFTER_BODY:{g5(this,i);break}}}},{key:"onNullCharacter",value:function(i){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){_4t(this,i);return}switch(this.insertionMode){case Xe.INITIAL:{vR(this,i);break}case Xe.BEFORE_HTML:{iW(this,i);break}case Xe.BEFORE_HEAD:{nW(this,i);break}case Xe.IN_HEAD:{IW(this,i);break}case Xe.IN_HEAD_NO_SCRIPT:{rW(this,i);break}case Xe.AFTER_HEAD:{oW(this,i);break}case Xe.TEXT:{this._insertCharacters(i);break}case Xe.IN_TABLE:case Xe.IN_TABLE_BODY:case Xe.IN_ROW:{dQ(this,i);break}case Xe.IN_COLUMN_GROUP:{iE(this,i);break}case Xe.AFTER_BODY:{nE(this,i);break}case Xe.AFTER_AFTER_BODY:{g5(this,i);break}}}},{key:"onComment",value:function(i){if(this.skipNextNewLine=!1,this.currentNotInHTML){eee(this,i);return}switch(this.insertionMode){case Xe.INITIAL:case Xe.BEFORE_HTML:case Xe.BEFORE_HEAD:case Xe.IN_HEAD:case Xe.IN_HEAD_NO_SCRIPT:case Xe.AFTER_HEAD:case Xe.IN_BODY:case Xe.IN_TABLE:case Xe.IN_CAPTION:case Xe.IN_COLUMN_GROUP:case Xe.IN_TABLE_BODY:case Xe.IN_ROW:case Xe.IN_CELL:case Xe.IN_SELECT:case Xe.IN_SELECT_IN_TABLE:case Xe.IN_TEMPLATE:case Xe.IN_FRAMESET:case Xe.AFTER_FRAMESET:{eee(this,i);break}case Xe.IN_TABLE_TEXT:{BR(this,i);break}case Xe.AFTER_BODY:{Gjt(this,i);break}case Xe.AFTER_AFTER_BODY:case Xe.AFTER_AFTER_FRAMESET:{vjt(this,i);break}}}},{key:"onDoctype",value:function(i){switch(this.skipNextNewLine=!1,this.insertionMode){case Xe.INITIAL:{Bjt(this,i);break}case Xe.BEFORE_HEAD:case Xe.IN_HEAD:case Xe.IN_HEAD_NO_SCRIPT:case Xe.AFTER_HEAD:{this._err(i,br.ERR.misplacedDoctype);break}case Xe.IN_TABLE_TEXT:{BR(this,i);break}}}},{key:"onStartTag",value:function(i){this.skipNextNewLine=!1,this.currentToken=i,this._processStartTag(i),i.selfClosing&&!i.ackSelfClosing&&this._err(i,br.ERR.nonVoidHtmlElementStartTagWithTrailingSolidus)}},{key:"_processStartTag",value:function(i){this.shouldProcessStartTagTokenInForeignContent(i)?J4t(this,i):this._startTagOutsideForeignContent(i)}},{key:"_startTagOutsideForeignContent",value:function(i){switch(this.insertionMode){case Xe.INITIAL:{vR(this,i);break}case Xe.BEFORE_HTML:{wjt(this,i);break}case Xe.BEFORE_HEAD:{Rjt(this,i);break}case Xe.IN_HEAD:{il(this,i);break}case Xe.IN_HEAD_NO_SCRIPT:{Xjt(this,i);break}case Xe.AFTER_HEAD:{Hjt(this,i);break}case Xe.IN_BODY:{oo(this,i);break}case Xe.IN_TABLE:{hw(this,i);break}case Xe.IN_TABLE_TEXT:{BR(this,i);break}case Xe.IN_CAPTION:{V4t(this,i);break}case Xe.IN_COLUMN_GROUP:{Wse(this,i);break}case Xe.IN_TABLE_BODY:{$P(this,i);break}case Xe.IN_ROW:{qP(this,i);break}case Xe.IN_CELL:{T4t(this,i);break}case Xe.IN_SELECT:{PLe(this,i);break}case Xe.IN_SELECT_IN_TABLE:{N4t(this,i);break}case Xe.IN_TEMPLATE:{Y4t(this,i);break}case Xe.AFTER_BODY:{x4t(this,i);break}case Xe.IN_FRAMESET:{F4t(this,i);break}case Xe.AFTER_FRAMESET:{D4t(this,i);break}case Xe.AFTER_AFTER_BODY:{z4t(this,i);break}case Xe.AFTER_AFTER_FRAMESET:{P4t(this,i);break}}}},{key:"onEndTag",value:function(i){this.skipNextNewLine=!1,this.currentToken=i,this.currentNotInHTML?L4t(this,i):this._endTagOutsideForeignContent(i)}},{key:"_endTagOutsideForeignContent",value:function(i){switch(this.insertionMode){case Xe.INITIAL:{vR(this,i);break}case Xe.BEFORE_HTML:{Sjt(this,i);break}case Xe.BEFORE_HEAD:{Vjt(this,i);break}case Xe.IN_HEAD:{Wjt(this,i);break}case Xe.IN_HEAD_NO_SCRIPT:{Tjt(this,i);break}case Xe.AFTER_HEAD:{Njt(this,i);break}case Xe.IN_BODY:{jP(this,i);break}case Xe.TEXT:{p4t(this,i);break}case Xe.IN_TABLE:{t9(this,i);break}case Xe.IN_TABLE_TEXT:{BR(this,i);break}case Xe.IN_CAPTION:{W4t(this,i);break}case Xe.IN_COLUMN_GROUP:{X4t(this,i);break}case Xe.IN_TABLE_BODY:{tee(this,i);break}case Xe.IN_ROW:{zLe(this,i);break}case Xe.IN_CELL:{H4t(this,i);break}case Xe.IN_SELECT:{_Le(this,i);break}case Xe.IN_SELECT_IN_TABLE:{k4t(this,i);break}case Xe.IN_TEMPLATE:{K4t(this,i);break}case Xe.AFTER_BODY:{JLe(this,i);break}case Xe.IN_FRAMESET:{E4t(this,i);break}case Xe.AFTER_FRAMESET:{M4t(this,i);break}case Xe.AFTER_AFTER_BODY:{g5(this,i);break}}}},{key:"onEof",value:function(i){switch(this.insertionMode){case Xe.INITIAL:{vR(this,i);break}case Xe.BEFORE_HTML:{iW(this,i);break}case Xe.BEFORE_HEAD:{nW(this,i);break}case Xe.IN_HEAD:{IW(this,i);break}case Xe.IN_HEAD_NO_SCRIPT:{rW(this,i);break}case Xe.AFTER_HEAD:{oW(this,i);break}case Xe.IN_BODY:case Xe.IN_TABLE:case Xe.IN_CAPTION:case Xe.IN_COLUMN_GROUP:case Xe.IN_TABLE_BODY:case Xe.IN_ROW:case Xe.IN_CELL:case Xe.IN_SELECT:case Xe.IN_SELECT_IN_TABLE:{FLe(this,i);break}case Xe.TEXT:{b4t(this,i);break}case Xe.IN_TABLE_TEXT:{BR(this,i);break}case Xe.IN_TEMPLATE:{OLe(this,i);break}case Xe.AFTER_BODY:case Xe.IN_FRAMESET:case Xe.AFTER_FRAMESET:case Xe.AFTER_AFTER_BODY:case Xe.AFTER_AFTER_FRAMESET:{Vse(this,i);break}}}},{key:"onWhitespaceCharacter",value:function(i){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,i.chars.charCodeAt(0)===TLe.CODE_POINTS.LINE_FEED)){if(i.chars.length===1)return;i.chars=i.chars.substr(1)}if(this.tokenizer.inForeignNode){this._insertCharacters(i);return}switch(this.insertionMode){case Xe.IN_HEAD:case Xe.IN_HEAD_NO_SCRIPT:case Xe.AFTER_HEAD:case Xe.TEXT:case Xe.IN_COLUMN_GROUP:case Xe.IN_SELECT:case Xe.IN_SELECT_IN_TABLE:case Xe.IN_FRAMESET:case Xe.AFTER_FRAMESET:{this._insertCharacters(i);break}case Xe.IN_BODY:case Xe.IN_CAPTION:case Xe.IN_CELL:case Xe.IN_TEMPLATE:case Xe.AFTER_BODY:case Xe.AFTER_AFTER_BODY:case Xe.AFTER_AFTER_FRAMESET:{NLe(this,i);break}case Xe.IN_TABLE:case Xe.IN_TABLE_BODY:case Xe.IN_ROW:{dQ(this,i);break}case Xe.IN_TABLE_TEXT:{ELe(this,i);break}}}}],[{key:"parse",value:function(i,n){const I=new this(n);return I.tokenizer.write(i,!0),I.document}},{key:"getFragmentParser",value:function(i,n){const I=Object.assign(Object.assign({},K1e),n);i??(i=I.treeAdapter.createElement(_.TAG_NAMES.TEMPLATE,_.NS.HTML,[]));const r=I.treeAdapter.createElement("documentmock",_.NS.HTML,[]),o=new this(I,r,i);return o.fragmentContextID===_.TAG_ID.TEMPLATE&&o.tmplInsertionModeStack.unshift(Xe.IN_TEMPLATE),o._initTokenizerForFragmentParsing(),o._insertFakeRootElement(),o._resetInsertionMode(),o._findFormInFragmentContext(),o}}]),e}();e9.Parser=hjt;function fjt(e,g){let i=e.activeFormattingElements.getElementEntryInScopeWithTagName(g.tagName);return i?e.openElements.contains(i.element)?e.openElements.hasInScope(g.tagID)||(i=null):(e.activeFormattingElements.removeEntry(i),i=null):xLe(e,g),i}function mjt(e,g){let i=null,n=e.openElements.stackTop;for(;n>=0;n--){const I=e.openElements.items[n];if(I===g.element)break;e._isSpecialElement(I,e.openElements.tagIDs[n])&&(i=I)}return i||(e.openElements.shortenToLength(n<0?0:n),e.activeFormattingElements.removeEntry(g)),i}function pjt(e,g,i){let n=g,I=e.openElements.getCommonAncestor(g);for(let r=0,o=I;o!==i;r++,o=I){I=e.openElements.getCommonAncestor(o);const C=e.activeFormattingElements.getElementEntry(o),a=C&&r>=ujt;!C||a?(a&&e.activeFormattingElements.removeEntry(C),e.openElements.remove(o)):(o=bjt(e,C),n===g&&(e.activeFormattingElements.bookmark=C),e.treeAdapter.detachNode(n),e.treeAdapter.appendChild(o,n),n=o)}return n}function bjt(e,g){const i=e.treeAdapter.getNamespaceURI(g.element),n=e.treeAdapter.createElement(g.token.tagName,i,g.token.attrs);return e.openElements.replace(g.element,n),g.element=n,n}function yjt(e,g,i){const n=e.treeAdapter.getTagName(g),I=(0,_.getTagID)(n);if(e._isElementCausesFosterParenting(I))e._fosterParentElement(i);else{const r=e.treeAdapter.getNamespaceURI(g);I===_.TAG_ID.TEMPLATE&&r===_.NS.HTML&&(g=e.treeAdapter.getTemplateContent(g)),e.treeAdapter.appendChild(g,i)}}function Zjt(e,g,i){const n=e.treeAdapter.getNamespaceURI(i.element),{token:I}=i,r=e.treeAdapter.createElement(I.tagName,n,I.attrs);e._adoptNodes(g,r),e.treeAdapter.appendChild(g,r),e.activeFormattingElements.insertElementAfterBookmark(r,I),e.activeFormattingElements.removeEntry(i),e.openElements.remove(i.element),e.openElements.insertAfter(g,r,I.tagID)}function Rse(e,g){for(let i=0;i=i;n--)e._setEndLocation(e.openElements.items[n],g);if(!e.fragmentContext&&e.openElements.stackTop>=0){const n=e.openElements.items[0],I=e.treeAdapter.getNodeSourceCodeLocation(n);if(I&&!I.endTag&&(e._setEndLocation(n,g),e.openElements.stackTop>=1)){const r=e.openElements.items[1],o=e.treeAdapter.getNodeSourceCodeLocation(r);o&&!o.endTag&&e._setEndLocation(r,g)}}}}function Bjt(e,g){e._setDocumentType(g);const i=g.forceQuirks?_.DOCUMENT_MODE.QUIRKS:Y1e.getDocumentMode(g);Y1e.isConforming(g)||e._err(g,br.ERR.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,i),e.insertionMode=Xe.BEFORE_HTML}function vR(e,g){e._err(g,br.ERR.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,_.DOCUMENT_MODE.QUIRKS),e.insertionMode=Xe.BEFORE_HTML,e._processToken(g)}function wjt(e,g){g.tagID===_.TAG_ID.HTML?(e._insertElement(g,_.NS.HTML),e.insertionMode=Xe.BEFORE_HEAD):iW(e,g)}function Sjt(e,g){const i=g.tagID;(i===_.TAG_ID.HTML||i===_.TAG_ID.HEAD||i===_.TAG_ID.BODY||i===_.TAG_ID.BR)&&iW(e,g)}function iW(e,g){e._insertFakeRootElement(),e.insertionMode=Xe.BEFORE_HEAD,e._processToken(g)}function Rjt(e,g){switch(g.tagID){case _.TAG_ID.HTML:{oo(e,g);break}case _.TAG_ID.HEAD:{e._insertElement(g,_.NS.HTML),e.headElement=e.openElements.current,e.insertionMode=Xe.IN_HEAD;break}default:nW(e,g)}}function Vjt(e,g){const i=g.tagID;i===_.TAG_ID.HEAD||i===_.TAG_ID.BODY||i===_.TAG_ID.HTML||i===_.TAG_ID.BR?nW(e,g):e._err(g,br.ERR.endTagWithoutMatchingOpenElement)}function nW(e,g){e._insertFakeElement(_.TAG_NAMES.HEAD,_.TAG_ID.HEAD),e.headElement=e.openElements.current,e.insertionMode=Xe.IN_HEAD,e._processToken(g)}function il(e,g){switch(g.tagID){case _.TAG_ID.HTML:{oo(e,g);break}case _.TAG_ID.BASE:case _.TAG_ID.BASEFONT:case _.TAG_ID.BGSOUND:case _.TAG_ID.LINK:case _.TAG_ID.META:{e._appendElement(g,_.NS.HTML),g.ackSelfClosing=!0;break}case _.TAG_ID.TITLE:{e._switchToTextParsing(g,bo.TokenizerMode.RCDATA);break}case _.TAG_ID.NOSCRIPT:{e.options.scriptingEnabled?e._switchToTextParsing(g,bo.TokenizerMode.RAWTEXT):(e._insertElement(g,_.NS.HTML),e.insertionMode=Xe.IN_HEAD_NO_SCRIPT);break}case _.TAG_ID.NOFRAMES:case _.TAG_ID.STYLE:{e._switchToTextParsing(g,bo.TokenizerMode.RAWTEXT);break}case _.TAG_ID.SCRIPT:{e._switchToTextParsing(g,bo.TokenizerMode.SCRIPT_DATA);break}case _.TAG_ID.TEMPLATE:{e._insertTemplate(g),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=Xe.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(Xe.IN_TEMPLATE);break}case _.TAG_ID.HEAD:{e._err(g,br.ERR.misplacedStartTagForHeadElement);break}default:IW(e,g)}}function Wjt(e,g){switch(g.tagID){case _.TAG_ID.HEAD:{e.openElements.pop(),e.insertionMode=Xe.AFTER_HEAD;break}case _.TAG_ID.BODY:case _.TAG_ID.BR:case _.TAG_ID.HTML:{IW(e,g);break}case _.TAG_ID.TEMPLATE:{eZ(e,g);break}default:e._err(g,br.ERR.endTagWithoutMatchingOpenElement)}}function eZ(e,g){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==_.TAG_ID.TEMPLATE&&e._err(g,br.ERR.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(_.TAG_ID.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(g,br.ERR.endTagWithoutMatchingOpenElement)}function IW(e,g){e.openElements.pop(),e.insertionMode=Xe.AFTER_HEAD,e._processToken(g)}function Xjt(e,g){switch(g.tagID){case _.TAG_ID.HTML:{oo(e,g);break}case _.TAG_ID.BASEFONT:case _.TAG_ID.BGSOUND:case _.TAG_ID.HEAD:case _.TAG_ID.LINK:case _.TAG_ID.META:case _.TAG_ID.NOFRAMES:case _.TAG_ID.STYLE:{il(e,g);break}case _.TAG_ID.NOSCRIPT:{e._err(g,br.ERR.nestedNoscriptInHead);break}default:rW(e,g)}}function Tjt(e,g){switch(g.tagID){case _.TAG_ID.NOSCRIPT:{e.openElements.pop(),e.insertionMode=Xe.IN_HEAD;break}case _.TAG_ID.BR:{rW(e,g);break}default:e._err(g,br.ERR.endTagWithoutMatchingOpenElement)}}function rW(e,g){const i=g.type===cI.TokenType.EOF?br.ERR.openElementsLeftAfterEof:br.ERR.disallowedContentInNoscriptInHead;e._err(g,i),e.openElements.pop(),e.insertionMode=Xe.IN_HEAD,e._processToken(g)}function Hjt(e,g){switch(g.tagID){case _.TAG_ID.HTML:{oo(e,g);break}case _.TAG_ID.BODY:{e._insertElement(g,_.NS.HTML),e.framesetOk=!1,e.insertionMode=Xe.IN_BODY;break}case _.TAG_ID.FRAMESET:{e._insertElement(g,_.NS.HTML),e.insertionMode=Xe.IN_FRAMESET;break}case _.TAG_ID.BASE:case _.TAG_ID.BASEFONT:case _.TAG_ID.BGSOUND:case _.TAG_ID.LINK:case _.TAG_ID.META:case _.TAG_ID.NOFRAMES:case _.TAG_ID.SCRIPT:case _.TAG_ID.STYLE:case _.TAG_ID.TEMPLATE:case _.TAG_ID.TITLE:{e._err(g,br.ERR.abandonedHeadElementChild),e.openElements.push(e.headElement,_.TAG_ID.HEAD),il(e,g),e.openElements.remove(e.headElement);break}case _.TAG_ID.HEAD:{e._err(g,br.ERR.misplacedStartTagForHeadElement);break}default:oW(e,g)}}function Njt(e,g){switch(g.tagID){case _.TAG_ID.BODY:case _.TAG_ID.HTML:case _.TAG_ID.BR:{oW(e,g);break}case _.TAG_ID.TEMPLATE:{eZ(e,g);break}default:e._err(g,br.ERR.endTagWithoutMatchingOpenElement)}}function oW(e,g){e._insertFakeElement(_.TAG_NAMES.BODY,_.TAG_ID.BODY),e.insertionMode=Xe.IN_BODY,QP(e,g)}function QP(e,g){switch(g.type){case cI.TokenType.CHARACTER:{kLe(e,g);break}case cI.TokenType.WHITESPACE_CHARACTER:{NLe(e,g);break}case cI.TokenType.COMMENT:{eee(e,g);break}case cI.TokenType.START_TAG:{oo(e,g);break}case cI.TokenType.END_TAG:{jP(e,g);break}case cI.TokenType.EOF:{FLe(e,g);break}}}function NLe(e,g){e._reconstructActiveFormattingElements(),e._insertCharacters(g)}function kLe(e,g){e._reconstructActiveFormattingElements(),e._insertCharacters(g),e.framesetOk=!1}function kjt(e,g){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],g.attrs)}function Yjt(e,g){const i=e.openElements.tryPeekProperlyNestedBodyElement();i&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(i,g.attrs))}function Kjt(e,g){const i=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&i&&(e.treeAdapter.detachNode(i),e.openElements.popAllUpToHtmlElement(),e._insertElement(g,_.NS.HTML),e.insertionMode=Xe.IN_FRAMESET)}function xjt(e,g){e.openElements.hasInButtonScope(_.TAG_ID.P)&&e._closePElement(),e._insertElement(g,_.NS.HTML)}function Fjt(e,g){e.openElements.hasInButtonScope(_.TAG_ID.P)&&e._closePElement(),(0,_.isNumberedHeader)(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(g,_.NS.HTML)}function Ejt(e,g){e.openElements.hasInButtonScope(_.TAG_ID.P)&&e._closePElement(),e._insertElement(g,_.NS.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function Djt(e,g){const i=e.openElements.tmplCount>0;(!e.formElement||i)&&(e.openElements.hasInButtonScope(_.TAG_ID.P)&&e._closePElement(),e._insertElement(g,_.NS.HTML),i||(e.formElement=e.openElements.current))}function Mjt(e,g){e.framesetOk=!1;const i=g.tagID;for(let n=e.openElements.stackTop;n>=0;n--){const I=e.openElements.tagIDs[n];if(i===_.TAG_ID.LI&&I===_.TAG_ID.LI||(i===_.TAG_ID.DD||i===_.TAG_ID.DT)&&(I===_.TAG_ID.DD||I===_.TAG_ID.DT)){e.openElements.generateImpliedEndTagsWithExclusion(I),e.openElements.popUntilTagNamePopped(I);break}if(I!==_.TAG_ID.ADDRESS&&I!==_.TAG_ID.DIV&&I!==_.TAG_ID.P&&e._isSpecialElement(e.openElements.items[n],I))break}e.openElements.hasInButtonScope(_.TAG_ID.P)&&e._closePElement(),e._insertElement(g,_.NS.HTML)}function zjt(e,g){e.openElements.hasInButtonScope(_.TAG_ID.P)&&e._closePElement(),e._insertElement(g,_.NS.HTML),e.tokenizer.state=bo.TokenizerMode.PLAINTEXT}function Pjt(e,g){e.openElements.hasInScope(_.TAG_ID.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(_.TAG_ID.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(g,_.NS.HTML),e.framesetOk=!1}function _jt(e,g){const i=e.activeFormattingElements.getElementEntryInScopeWithTagName(_.TAG_NAMES.A);i&&(Rse(e,g),e.openElements.remove(i.element),e.activeFormattingElements.removeEntry(i)),e._reconstructActiveFormattingElements(),e._insertElement(g,_.NS.HTML),e.activeFormattingElements.pushElement(e.openElements.current,g)}function Ojt(e,g){e._reconstructActiveFormattingElements(),e._insertElement(g,_.NS.HTML),e.activeFormattingElements.pushElement(e.openElements.current,g)}function Jjt(e,g){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(_.TAG_ID.NOBR)&&(Rse(e,g),e._reconstructActiveFormattingElements()),e._insertElement(g,_.NS.HTML),e.activeFormattingElements.pushElement(e.openElements.current,g)}function Ljt(e,g){e._reconstructActiveFormattingElements(),e._insertElement(g,_.NS.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function Ujt(e,g){e.treeAdapter.getDocumentMode(e.document)!==_.DOCUMENT_MODE.QUIRKS&&e.openElements.hasInButtonScope(_.TAG_ID.P)&&e._closePElement(),e._insertElement(g,_.NS.HTML),e.framesetOk=!1,e.insertionMode=Xe.IN_TABLE}function YLe(e,g){e._reconstructActiveFormattingElements(),e._appendElement(g,_.NS.HTML),e.framesetOk=!1,g.ackSelfClosing=!0}function KLe(e){const g=(0,cI.getTokenAttr)(e,_.ATTRS.TYPE);return g!=null&&g.toLowerCase()===ljt}function Qjt(e,g){e._reconstructActiveFormattingElements(),e._appendElement(g,_.NS.HTML),KLe(g)||(e.framesetOk=!1),g.ackSelfClosing=!0}function jjt(e,g){e._appendElement(g,_.NS.HTML),g.ackSelfClosing=!0}function $jt(e,g){e.openElements.hasInButtonScope(_.TAG_ID.P)&&e._closePElement(),e._appendElement(g,_.NS.HTML),e.framesetOk=!1,g.ackSelfClosing=!0}function qjt(e,g){g.tagName=_.TAG_NAMES.IMG,g.tagID=_.TAG_ID.IMG,YLe(e,g)}function e4t(e,g){e._insertElement(g,_.NS.HTML),e.skipNextNewLine=!0,e.tokenizer.state=bo.TokenizerMode.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=Xe.TEXT}function t4t(e,g){e.openElements.hasInButtonScope(_.TAG_ID.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(g,bo.TokenizerMode.RAWTEXT)}function g4t(e,g){e.framesetOk=!1,e._switchToTextParsing(g,bo.TokenizerMode.RAWTEXT)}function x1e(e,g){e._switchToTextParsing(g,bo.TokenizerMode.RAWTEXT)}function i4t(e,g){e._reconstructActiveFormattingElements(),e._insertElement(g,_.NS.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===Xe.IN_TABLE||e.insertionMode===Xe.IN_CAPTION||e.insertionMode===Xe.IN_TABLE_BODY||e.insertionMode===Xe.IN_ROW||e.insertionMode===Xe.IN_CELL?Xe.IN_SELECT_IN_TABLE:Xe.IN_SELECT}function n4t(e,g){e.openElements.currentTagId===_.TAG_ID.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(g,_.NS.HTML)}function I4t(e,g){e.openElements.hasInScope(_.TAG_ID.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(g,_.NS.HTML)}function r4t(e,g){e.openElements.hasInScope(_.TAG_ID.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(_.TAG_ID.RTC),e._insertElement(g,_.NS.HTML)}function o4t(e,g){e._reconstructActiveFormattingElements(),El.adjustTokenMathMLAttrs(g),El.adjustTokenXMLAttrs(g),g.selfClosing?e._appendElement(g,_.NS.MATHML):e._insertElement(g,_.NS.MATHML),g.ackSelfClosing=!0}function C4t(e,g){e._reconstructActiveFormattingElements(),El.adjustTokenSVGAttrs(g),El.adjustTokenXMLAttrs(g),g.selfClosing?e._appendElement(g,_.NS.SVG):e._insertElement(g,_.NS.SVG),g.ackSelfClosing=!0}function F1e(e,g){e._reconstructActiveFormattingElements(),e._insertElement(g,_.NS.HTML)}function oo(e,g){switch(g.tagID){case _.TAG_ID.I:case _.TAG_ID.S:case _.TAG_ID.B:case _.TAG_ID.U:case _.TAG_ID.EM:case _.TAG_ID.TT:case _.TAG_ID.BIG:case _.TAG_ID.CODE:case _.TAG_ID.FONT:case _.TAG_ID.SMALL:case _.TAG_ID.STRIKE:case _.TAG_ID.STRONG:{Ojt(e,g);break}case _.TAG_ID.A:{_jt(e,g);break}case _.TAG_ID.H1:case _.TAG_ID.H2:case _.TAG_ID.H3:case _.TAG_ID.H4:case _.TAG_ID.H5:case _.TAG_ID.H6:{Fjt(e,g);break}case _.TAG_ID.P:case _.TAG_ID.DL:case _.TAG_ID.OL:case _.TAG_ID.UL:case _.TAG_ID.DIV:case _.TAG_ID.DIR:case _.TAG_ID.NAV:case _.TAG_ID.MAIN:case _.TAG_ID.MENU:case _.TAG_ID.ASIDE:case _.TAG_ID.CENTER:case _.TAG_ID.FIGURE:case _.TAG_ID.FOOTER:case _.TAG_ID.HEADER:case _.TAG_ID.HGROUP:case _.TAG_ID.DIALOG:case _.TAG_ID.DETAILS:case _.TAG_ID.ADDRESS:case _.TAG_ID.ARTICLE:case _.TAG_ID.SECTION:case _.TAG_ID.SUMMARY:case _.TAG_ID.FIELDSET:case _.TAG_ID.BLOCKQUOTE:case _.TAG_ID.FIGCAPTION:{xjt(e,g);break}case _.TAG_ID.LI:case _.TAG_ID.DD:case _.TAG_ID.DT:{Mjt(e,g);break}case _.TAG_ID.BR:case _.TAG_ID.IMG:case _.TAG_ID.WBR:case _.TAG_ID.AREA:case _.TAG_ID.EMBED:case _.TAG_ID.KEYGEN:{YLe(e,g);break}case _.TAG_ID.HR:{$jt(e,g);break}case _.TAG_ID.RB:case _.TAG_ID.RTC:{I4t(e,g);break}case _.TAG_ID.RT:case _.TAG_ID.RP:{r4t(e,g);break}case _.TAG_ID.PRE:case _.TAG_ID.LISTING:{Ejt(e,g);break}case _.TAG_ID.XMP:{t4t(e,g);break}case _.TAG_ID.SVG:{C4t(e,g);break}case _.TAG_ID.HTML:{kjt(e,g);break}case _.TAG_ID.BASE:case _.TAG_ID.LINK:case _.TAG_ID.META:case _.TAG_ID.STYLE:case _.TAG_ID.TITLE:case _.TAG_ID.SCRIPT:case _.TAG_ID.BGSOUND:case _.TAG_ID.BASEFONT:case _.TAG_ID.TEMPLATE:{il(e,g);break}case _.TAG_ID.BODY:{Yjt(e,g);break}case _.TAG_ID.FORM:{Djt(e,g);break}case _.TAG_ID.NOBR:{Jjt(e,g);break}case _.TAG_ID.MATH:{o4t(e,g);break}case _.TAG_ID.TABLE:{Ujt(e,g);break}case _.TAG_ID.INPUT:{Qjt(e,g);break}case _.TAG_ID.PARAM:case _.TAG_ID.TRACK:case _.TAG_ID.SOURCE:{jjt(e,g);break}case _.TAG_ID.IMAGE:{qjt(e,g);break}case _.TAG_ID.BUTTON:{Pjt(e,g);break}case _.TAG_ID.APPLET:case _.TAG_ID.OBJECT:case _.TAG_ID.MARQUEE:{Ljt(e,g);break}case _.TAG_ID.IFRAME:{g4t(e,g);break}case _.TAG_ID.SELECT:{i4t(e,g);break}case _.TAG_ID.OPTION:case _.TAG_ID.OPTGROUP:{n4t(e,g);break}case _.TAG_ID.NOEMBED:{x1e(e,g);break}case _.TAG_ID.FRAMESET:{Kjt(e,g);break}case _.TAG_ID.TEXTAREA:{e4t(e,g);break}case _.TAG_ID.NOSCRIPT:{e.options.scriptingEnabled?x1e(e,g):F1e(e,g);break}case _.TAG_ID.PLAINTEXT:{zjt(e,g);break}case _.TAG_ID.COL:case _.TAG_ID.TH:case _.TAG_ID.TD:case _.TAG_ID.TR:case _.TAG_ID.HEAD:case _.TAG_ID.FRAME:case _.TAG_ID.TBODY:case _.TAG_ID.TFOOT:case _.TAG_ID.THEAD:case _.TAG_ID.CAPTION:case _.TAG_ID.COLGROUP:break;default:F1e(e,g)}}function a4t(e,g){if(e.openElements.hasInScope(_.TAG_ID.BODY)&&(e.insertionMode=Xe.AFTER_BODY,e.options.sourceCodeLocationInfo)){const i=e.openElements.tryPeekProperlyNestedBodyElement();i&&e._setEndLocation(i,g)}}function s4t(e,g){e.openElements.hasInScope(_.TAG_ID.BODY)&&(e.insertionMode=Xe.AFTER_BODY,JLe(e,g))}function A4t(e,g){const i=g.tagID;e.openElements.hasInScope(i)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(i))}function l4t(e){const g=e.openElements.tmplCount>0,{formElement:i}=e;g||(e.formElement=null),(i||g)&&e.openElements.hasInScope(_.TAG_ID.FORM)&&(e.openElements.generateImpliedEndTags(),g?e.openElements.popUntilTagNamePopped(_.TAG_ID.FORM):i&&e.openElements.remove(i))}function c4t(e){e.openElements.hasInButtonScope(_.TAG_ID.P)||e._insertFakeElement(_.TAG_NAMES.P,_.TAG_ID.P),e._closePElement()}function u4t(e){e.openElements.hasInListItemScope(_.TAG_ID.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(_.TAG_ID.LI),e.openElements.popUntilTagNamePopped(_.TAG_ID.LI))}function d4t(e,g){const i=g.tagID;e.openElements.hasInScope(i)&&(e.openElements.generateImpliedEndTagsWithExclusion(i),e.openElements.popUntilTagNamePopped(i))}function h4t(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function f4t(e,g){const i=g.tagID;e.openElements.hasInScope(i)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(i),e.activeFormattingElements.clearToLastMarker())}function m4t(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(_.TAG_NAMES.BR,_.TAG_ID.BR),e.openElements.pop(),e.framesetOk=!1}function xLe(e,g){const i=g.tagName,n=g.tagID;for(let I=e.openElements.stackTop;I>0;I--){const r=e.openElements.items[I],o=e.openElements.tagIDs[I];if(n===o&&(n!==_.TAG_ID.UNKNOWN||e.treeAdapter.getTagName(r)===i)){e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.stackTop>=I&&e.openElements.shortenToLength(I);break}if(e._isSpecialElement(r,o))break}}function jP(e,g){switch(g.tagID){case _.TAG_ID.A:case _.TAG_ID.B:case _.TAG_ID.I:case _.TAG_ID.S:case _.TAG_ID.U:case _.TAG_ID.EM:case _.TAG_ID.TT:case _.TAG_ID.BIG:case _.TAG_ID.CODE:case _.TAG_ID.FONT:case _.TAG_ID.NOBR:case _.TAG_ID.SMALL:case _.TAG_ID.STRIKE:case _.TAG_ID.STRONG:{Rse(e,g);break}case _.TAG_ID.P:{c4t(e);break}case _.TAG_ID.DL:case _.TAG_ID.UL:case _.TAG_ID.OL:case _.TAG_ID.DIR:case _.TAG_ID.DIV:case _.TAG_ID.NAV:case _.TAG_ID.PRE:case _.TAG_ID.MAIN:case _.TAG_ID.MENU:case _.TAG_ID.ASIDE:case _.TAG_ID.BUTTON:case _.TAG_ID.CENTER:case _.TAG_ID.FIGURE:case _.TAG_ID.FOOTER:case _.TAG_ID.HEADER:case _.TAG_ID.HGROUP:case _.TAG_ID.DIALOG:case _.TAG_ID.ADDRESS:case _.TAG_ID.ARTICLE:case _.TAG_ID.DETAILS:case _.TAG_ID.SECTION:case _.TAG_ID.SUMMARY:case _.TAG_ID.LISTING:case _.TAG_ID.FIELDSET:case _.TAG_ID.BLOCKQUOTE:case _.TAG_ID.FIGCAPTION:{A4t(e,g);break}case _.TAG_ID.LI:{u4t(e);break}case _.TAG_ID.DD:case _.TAG_ID.DT:{d4t(e,g);break}case _.TAG_ID.H1:case _.TAG_ID.H2:case _.TAG_ID.H3:case _.TAG_ID.H4:case _.TAG_ID.H5:case _.TAG_ID.H6:{h4t(e);break}case _.TAG_ID.BR:{m4t(e);break}case _.TAG_ID.BODY:{a4t(e,g);break}case _.TAG_ID.HTML:{s4t(e,g);break}case _.TAG_ID.FORM:{l4t(e);break}case _.TAG_ID.APPLET:case _.TAG_ID.OBJECT:case _.TAG_ID.MARQUEE:{f4t(e,g);break}case _.TAG_ID.TEMPLATE:{eZ(e,g);break}default:xLe(e,g)}}function FLe(e,g){e.tmplInsertionModeStack.length>0?OLe(e,g):Vse(e,g)}function p4t(e,g){var i;g.tagID===_.TAG_ID.SCRIPT&&((i=e.scriptHandler)===null||i===void 0||i.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function b4t(e,g){e._err(g,br.ERR.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(g)}function dQ(e,g){if(HLe.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=Xe.IN_TABLE_TEXT,g.type){case cI.TokenType.CHARACTER:{DLe(e,g);break}case cI.TokenType.WHITESPACE_CHARACTER:{ELe(e,g);break}}else jT(e,g)}function y4t(e,g){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(g,_.NS.HTML),e.insertionMode=Xe.IN_CAPTION}function Z4t(e,g){e.openElements.clearBackToTableContext(),e._insertElement(g,_.NS.HTML),e.insertionMode=Xe.IN_COLUMN_GROUP}function G4t(e,g){e.openElements.clearBackToTableContext(),e._insertFakeElement(_.TAG_NAMES.COLGROUP,_.TAG_ID.COLGROUP),e.insertionMode=Xe.IN_COLUMN_GROUP,Wse(e,g)}function v4t(e,g){e.openElements.clearBackToTableContext(),e._insertElement(g,_.NS.HTML),e.insertionMode=Xe.IN_TABLE_BODY}function B4t(e,g){e.openElements.clearBackToTableContext(),e._insertFakeElement(_.TAG_NAMES.TBODY,_.TAG_ID.TBODY),e.insertionMode=Xe.IN_TABLE_BODY,$P(e,g)}function w4t(e,g){e.openElements.hasInTableScope(_.TAG_ID.TABLE)&&(e.openElements.popUntilTagNamePopped(_.TAG_ID.TABLE),e._resetInsertionMode(),e._processStartTag(g))}function S4t(e,g){KLe(g)?e._appendElement(g,_.NS.HTML):jT(e,g),g.ackSelfClosing=!0}function R4t(e,g){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(g,_.NS.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function hw(e,g){switch(g.tagID){case _.TAG_ID.TD:case _.TAG_ID.TH:case _.TAG_ID.TR:{B4t(e,g);break}case _.TAG_ID.STYLE:case _.TAG_ID.SCRIPT:case _.TAG_ID.TEMPLATE:{il(e,g);break}case _.TAG_ID.COL:{G4t(e,g);break}case _.TAG_ID.FORM:{R4t(e,g);break}case _.TAG_ID.TABLE:{w4t(e,g);break}case _.TAG_ID.TBODY:case _.TAG_ID.TFOOT:case _.TAG_ID.THEAD:{v4t(e,g);break}case _.TAG_ID.INPUT:{S4t(e,g);break}case _.TAG_ID.CAPTION:{y4t(e,g);break}case _.TAG_ID.COLGROUP:{Z4t(e,g);break}default:jT(e,g)}}function t9(e,g){switch(g.tagID){case _.TAG_ID.TABLE:{e.openElements.hasInTableScope(_.TAG_ID.TABLE)&&(e.openElements.popUntilTagNamePopped(_.TAG_ID.TABLE),e._resetInsertionMode());break}case _.TAG_ID.TEMPLATE:{eZ(e,g);break}case _.TAG_ID.BODY:case _.TAG_ID.CAPTION:case _.TAG_ID.COL:case _.TAG_ID.COLGROUP:case _.TAG_ID.HTML:case _.TAG_ID.TBODY:case _.TAG_ID.TD:case _.TAG_ID.TFOOT:case _.TAG_ID.TH:case _.TAG_ID.THEAD:case _.TAG_ID.TR:break;default:jT(e,g)}}function jT(e,g){const i=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,QP(e,g),e.fosterParentingEnabled=i}function ELe(e,g){e.pendingCharacterTokens.push(g)}function DLe(e,g){e.pendingCharacterTokens.push(g),e.hasNonWhitespacePendingCharacterToken=!0}function BR(e,g){let i=0;if(e.hasNonWhitespacePendingCharacterToken)for(;i0&&e.openElements.currentTagId===_.TAG_ID.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===_.TAG_ID.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===_.TAG_ID.OPTGROUP&&e.openElements.pop();break}case _.TAG_ID.OPTION:{e.openElements.currentTagId===_.TAG_ID.OPTION&&e.openElements.pop();break}case _.TAG_ID.SELECT:{e.openElements.hasInSelectScope(_.TAG_ID.SELECT)&&(e.openElements.popUntilTagNamePopped(_.TAG_ID.SELECT),e._resetInsertionMode());break}case _.TAG_ID.TEMPLATE:{eZ(e,g);break}}}function N4t(e,g){const i=g.tagID;i===_.TAG_ID.CAPTION||i===_.TAG_ID.TABLE||i===_.TAG_ID.TBODY||i===_.TAG_ID.TFOOT||i===_.TAG_ID.THEAD||i===_.TAG_ID.TR||i===_.TAG_ID.TD||i===_.TAG_ID.TH?(e.openElements.popUntilTagNamePopped(_.TAG_ID.SELECT),e._resetInsertionMode(),e._processStartTag(g)):PLe(e,g)}function k4t(e,g){const i=g.tagID;i===_.TAG_ID.CAPTION||i===_.TAG_ID.TABLE||i===_.TAG_ID.TBODY||i===_.TAG_ID.TFOOT||i===_.TAG_ID.THEAD||i===_.TAG_ID.TR||i===_.TAG_ID.TD||i===_.TAG_ID.TH?e.openElements.hasInTableScope(i)&&(e.openElements.popUntilTagNamePopped(_.TAG_ID.SELECT),e._resetInsertionMode(),e.onEndTag(g)):_Le(e,g)}function Y4t(e,g){switch(g.tagID){case _.TAG_ID.BASE:case _.TAG_ID.BASEFONT:case _.TAG_ID.BGSOUND:case _.TAG_ID.LINK:case _.TAG_ID.META:case _.TAG_ID.NOFRAMES:case _.TAG_ID.SCRIPT:case _.TAG_ID.STYLE:case _.TAG_ID.TEMPLATE:case _.TAG_ID.TITLE:{il(e,g);break}case _.TAG_ID.CAPTION:case _.TAG_ID.COLGROUP:case _.TAG_ID.TBODY:case _.TAG_ID.TFOOT:case _.TAG_ID.THEAD:{e.tmplInsertionModeStack[0]=Xe.IN_TABLE,e.insertionMode=Xe.IN_TABLE,hw(e,g);break}case _.TAG_ID.COL:{e.tmplInsertionModeStack[0]=Xe.IN_COLUMN_GROUP,e.insertionMode=Xe.IN_COLUMN_GROUP,Wse(e,g);break}case _.TAG_ID.TR:{e.tmplInsertionModeStack[0]=Xe.IN_TABLE_BODY,e.insertionMode=Xe.IN_TABLE_BODY,$P(e,g);break}case _.TAG_ID.TD:case _.TAG_ID.TH:{e.tmplInsertionModeStack[0]=Xe.IN_ROW,e.insertionMode=Xe.IN_ROW,qP(e,g);break}default:e.tmplInsertionModeStack[0]=Xe.IN_BODY,e.insertionMode=Xe.IN_BODY,oo(e,g)}}function K4t(e,g){g.tagID===_.TAG_ID.TEMPLATE&&eZ(e,g)}function OLe(e,g){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(_.TAG_ID.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(g)):Vse(e,g)}function x4t(e,g){g.tagID===_.TAG_ID.HTML?oo(e,g):nE(e,g)}function JLe(e,g){var i;if(g.tagID===_.TAG_ID.HTML){if(e.fragmentContext||(e.insertionMode=Xe.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===_.TAG_ID.HTML){e._setEndLocation(e.openElements.items[0],g);const n=e.openElements.items[1];n&&!(!((i=e.treeAdapter.getNodeSourceCodeLocation(n))===null||i===void 0)&&i.endTag)&&e._setEndLocation(n,g)}}else nE(e,g)}function nE(e,g){e.insertionMode=Xe.IN_BODY,QP(e,g)}function F4t(e,g){switch(g.tagID){case _.TAG_ID.HTML:{oo(e,g);break}case _.TAG_ID.FRAMESET:{e._insertElement(g,_.NS.HTML);break}case _.TAG_ID.FRAME:{e._appendElement(g,_.NS.HTML),g.ackSelfClosing=!0;break}case _.TAG_ID.NOFRAMES:{il(e,g);break}}}function E4t(e,g){g.tagID===_.TAG_ID.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==_.TAG_ID.FRAMESET&&(e.insertionMode=Xe.AFTER_FRAMESET))}function D4t(e,g){switch(g.tagID){case _.TAG_ID.HTML:{oo(e,g);break}case _.TAG_ID.NOFRAMES:{il(e,g);break}}}function M4t(e,g){g.tagID===_.TAG_ID.HTML&&(e.insertionMode=Xe.AFTER_AFTER_FRAMESET)}function z4t(e,g){g.tagID===_.TAG_ID.HTML?oo(e,g):g5(e,g)}function g5(e,g){e.insertionMode=Xe.IN_BODY,QP(e,g)}function P4t(e,g){switch(g.tagID){case _.TAG_ID.HTML:{oo(e,g);break}case _.TAG_ID.NOFRAMES:{il(e,g);break}}}function _4t(e,g){g.chars=TLe.REPLACEMENT_CHARACTER,e._insertCharacters(g)}function O4t(e,g){e._insertCharacters(g),e.framesetOk=!1}function LLe(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==_.NS.HTML&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function J4t(e,g){if(El.causesExit(g))LLe(e),e._startTagOutsideForeignContent(g);else{const i=e._getAdjustedCurrentElement(),n=e.treeAdapter.getNamespaceURI(i);n===_.NS.MATHML?El.adjustTokenMathMLAttrs(g):n===_.NS.SVG&&(El.adjustTokenSVGTagName(g),El.adjustTokenSVGAttrs(g)),El.adjustTokenXMLAttrs(g),g.selfClosing?e._appendElement(g,n):e._insertElement(g,n),g.ackSelfClosing=!0}}function L4t(e,g){if(g.tagID===_.TAG_ID.P||g.tagID===_.TAG_ID.BR){LLe(e),e._endTagOutsideForeignContent(g);return}for(let i=e.openElements.stackTop;i>0;i--){const n=e.openElements.items[i];if(e.treeAdapter.getNamespaceURI(n)===_.NS.HTML){e._endTagOutsideForeignContent(g);break}const I=e.treeAdapter.getTagName(n);if(I.toLowerCase()===g.tagName){g.tagName=I,e.openElements.shortenToLength(i);break}}}var fw={};Object.defineProperty(fw,"__esModule",{value:!0});fw.serializeOuter=fw.serialize=void 0;const Di=gh,ULe=nw,U4t=UP,Q4t=new Set([Di.TAG_NAMES.AREA,Di.TAG_NAMES.BASE,Di.TAG_NAMES.BASEFONT,Di.TAG_NAMES.BGSOUND,Di.TAG_NAMES.BR,Di.TAG_NAMES.COL,Di.TAG_NAMES.EMBED,Di.TAG_NAMES.FRAME,Di.TAG_NAMES.HR,Di.TAG_NAMES.IMG,Di.TAG_NAMES.INPUT,Di.TAG_NAMES.KEYGEN,Di.TAG_NAMES.LINK,Di.TAG_NAMES.META,Di.TAG_NAMES.PARAM,Di.TAG_NAMES.SOURCE,Di.TAG_NAMES.TRACK,Di.TAG_NAMES.WBR]);function QLe(e,g){return g.treeAdapter.isElementNode(e)&&g.treeAdapter.getNamespaceURI(e)===Di.NS.HTML&&Q4t.has(g.treeAdapter.getTagName(e))}const jLe={treeAdapter:U4t.defaultTreeAdapter,scriptingEnabled:!0};function j4t(e,g){const i=Object.assign(Object.assign({},jLe),g);return QLe(e,i)?"":$Le(e,i)}fw.serialize=j4t;function $4t(e,g){const i=Object.assign(Object.assign({},jLe),g);return qLe(e,i)}fw.serializeOuter=$4t;function $Le(e,g){let i="";const n=g.treeAdapter.isElementNode(e)&&g.treeAdapter.getTagName(e)===Di.TAG_NAMES.TEMPLATE&&g.treeAdapter.getNamespaceURI(e)===Di.NS.HTML?g.treeAdapter.getTemplateContent(e):e,I=g.treeAdapter.getChildNodes(n);if(I)for(const r of I)i+=qLe(r,g);return i}function qLe(e,g){return g.treeAdapter.isElementNode(e)?q4t(e,g):g.treeAdapter.isTextNode(e)?t$t(e,g):g.treeAdapter.isCommentNode(e)?g$t(e,g):g.treeAdapter.isDocumentTypeNode(e)?i$t(e,g):""}function q4t(e,g){const i=g.treeAdapter.getTagName(e);return`<${i}${e$t(e,g)}>${QLe(e,g)?"":`${$Le(e,g)}`}`}function e$t(e,{treeAdapter:g}){let i="";for(const n of g.getAttrList(e)){if(i+=" ",!n.namespace)i+=n.name;else switch(n.namespace){case Di.NS.XML:{i+=`xml:${n.name}`;break}case Di.NS.XMLNS:{n.name!=="xmlns"&&(i+="xmlns:"),i+=n.name;break}case Di.NS.XLINK:{i+=`xlink:${n.name}`;break}default:i+=`${n.prefix}:${n.name}`}i+=`="${(0,ULe.escapeAttribute)(n.value)}"`}return i}function t$t(e,g){const{treeAdapter:i}=g,n=i.getTextNodeContent(e),I=i.getParentNode(e),r=I&&i.isElementNode(I)&&i.getTagName(I);return r&&i.getNamespaceURI(I)===Di.NS.HTML&&(0,Di.hasUnescapedText)(r,g.scriptingEnabled)?n:(0,ULe.escapeText)(n)}function g$t(e,{treeAdapter:g}){return``}function i$t(e,{treeAdapter:g}){return``}(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.parseFragment=e.parse=e.TokenizerMode=e.Tokenizer=e.Token=e.html=e.foreignContent=e.ErrorCodes=e.serializeOuter=e.serialize=e.Parser=e.defaultTreeAdapter=void 0;const g=e9;var i=UP;Object.defineProperty(e,"defaultTreeAdapter",{enumerable:!0,get:function(){return i.defaultTreeAdapter}});var n=e9;Object.defineProperty(e,"Parser",{enumerable:!0,get:function(){return n.Parser}});var I=fw;Object.defineProperty(e,"serialize",{enumerable:!0,get:function(){return I.serialize}}),Object.defineProperty(e,"serializeOuter",{enumerable:!0,get:function(){return I.serializeOuter}});var r=QT;Object.defineProperty(e,"ErrorCodes",{enumerable:!0,get:function(){return r.ERR}}),e.foreignContent=Sse,e.html=gh,e.Token=JP;var o=Db;Object.defineProperty(e,"Tokenizer",{enumerable:!0,get:function(){return o.Tokenizer}}),Object.defineProperty(e,"TokenizerMode",{enumerable:!0,get:function(){return o.TokenizerMode}});function C(A,s){return g.Parser.parse(A,s)}e.parse=C;function a(A,s,l){typeof A=="string"&&(l=s,s=A,A=null);const c=g.Parser.getFragmentParser(A,l);return c.tokenizer.write(s,!0),c.getFragment()}e.parseFragment=a})(GLe);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.adapter=e.serializeDoctypeContent=void 0;const g=GLe,i=go;function n(o){return new i.Text(o)}function I(o){const C=o.includes('"')?"'":'"';return C+o+C}function r(o,C,a){let A="!DOCTYPE ";return o&&(A+=o),C?A+=` PUBLIC ${I(C)}`:a&&(A+=" SYSTEM"),a&&(A+=` ${I(a)}`),A}e.serializeDoctypeContent=r,e.adapter={isCommentNode:i.isComment,isElementNode:i.isTag,isTextNode:i.isText,createDocument(){const o=new i.Document([]);return o["x-mode"]=g.html.DOCUMENT_MODE.NO_QUIRKS,o},createDocumentFragment(){return new i.Document([])},createElement(o,C,a){const A=Object.create(null),s=Object.create(null),l=Object.create(null);for(let u=0;u(0,i.isDirective)(c)&&c.name==="!doctype");l?l.data=s??null:(l=new i.ProcessingInstruction("!doctype",s),e.adapter.appendChild(o,l)),l["x-name"]=C??void 0,l["x-publicId"]=a??void 0,l["x-systemId"]=A??void 0},setDocumentMode(o,C){o["x-mode"]=C},getDocumentMode(o){return o["x-mode"]},detachNode(o){if(o.parent){const C=o.parent.children.indexOf(o),{prev:a,next:A}=o;o.prev=null,o.next=null,a&&(a.next=A),A&&(A.prev=a),o.parent.children.splice(C,1),o.parent=null}},insertText(o,C){const a=o.children[o.children.length-1];a&&(0,i.isText)(a)?a.data+=C:e.adapter.appendChild(o,n(C))},insertTextBefore(o,C,a){const A=o.children[o.children.indexOf(a)-1];A&&(0,i.isText)(A)?A.data+=C:e.adapter.insertBefore(o,n(C),a)},adoptAttributes(o,C){for(let a=0;a"u"&&(o.attribs[A]=C[a].value,o["x-attribsNamespace"][A]=C[a].namespace,o["x-attribsPrefix"][A]=C[a].prefix)}},getFirstChild(o){return o.children[0]},getChildNodes(o){return o.children},getParentNode(o){return o.parent},getAttrList(o){return o.attributes},getTagName(o){return o.name},getNamespaceURI(o){return o.namespace},getTextNodeContent(o){return o.data},getCommentNodeContent(o){return o.data},getDocumentTypeNodeName(o){var C;return(C=o["x-name"])!==null&&C!==void 0?C:""},getDocumentTypeNodePublicId(o){var C;return(C=o["x-publicId"])!==null&&C!==void 0?C:""},getDocumentTypeNodeSystemId(o){var C;return(C=o["x-systemId"])!==null&&C!==void 0?C:""},isDocumentTypeNode(o){return(0,i.isDirective)(o)&&o.name==="!doctype"},setNodeSourceCodeLocation(o,C){C&&(o.startIndex=C.startOffset,o.endIndex=C.endOffset),o.sourceCodeLocation=C},getNodeSourceCodeLocation(o){return o.sourceCodeLocation},updateNodeSourceCodeLocation(o,C){C.endOffset!=null&&(o.endIndex=C.endOffset),o.sourceCodeLocation=Object.assign(Object.assign({},o.sourceCodeLocation),C)}}})(ZLe);var n$t=Qe&&Qe.__spreadArray||function(e,g,i){if(i||arguments.length===2)for(var n=0,I=g.length,r;n=i.Zero&&c<=i.Nine}function C(c){return c>=i.LowerA&&c<=i.LowerZ||c>=i.UpperA&&c<=i.UpperZ}function a(c){return c>=i.UpperA&&c<=i.UpperF||c>=i.LowerA&&c<=i.LowerF}var A;(function(c){c[c.NoValue=0]="NoValue",c[c.Unquoted=1]="Unquoted",c[c.Single=2]="Single",c[c.Double=3]="Double"})(A=e.QuoteType||(e.QuoteType={}));var s={Cdata:new Uint8Array([67,68,65,84,65,91]),CdataEnd:new Uint8Array([93,93,62]),CommentEnd:new Uint8Array([45,45,62]),ScriptEnd:new Uint8Array([60,47,115,99,114,105,112,116]),StyleEnd:new Uint8Array([60,47,115,116,121,108,101]),TitleEnd:new Uint8Array([60,47,116,105,116,108,101])},l=function(){function c(u,d){var h=u.xmlMode,f=h===void 0?!1:h,m=u.decodeEntities,b=m===void 0?!0:m;this.cbs=d,this.state=n.Text,this.buffer="",this.sectionStart=0,this.index=0,this.baseState=n.Text,this.isSpecial=!1,this.running=!0,this.offset=0,this.currentSequence=void 0,this.sequenceIndex=0,this.trieIndex=0,this.trieCurrent=0,this.entityResult=0,this.entityExcess=0,this.xmlMode=f,this.decodeEntities=b,this.entityTrie=f?g.xmlDecodeTree:g.htmlDecodeTree}return c.prototype.reset=function(){this.state=n.Text,this.buffer="",this.sectionStart=0,this.index=0,this.baseState=n.Text,this.currentSequence=void 0,this.running=!0,this.offset=0},c.prototype.write=function(u){this.offset+=this.buffer.length,this.buffer=u,this.parse()},c.prototype.end=function(){this.running&&this.finish()},c.prototype.pause=function(){this.running=!1},c.prototype.resume=function(){this.running=!0,this.indexthis.sectionStart&&this.cbs.ontext(this.sectionStart,this.index),this.state=n.BeforeTagName,this.sectionStart=this.index):this.decodeEntities&&u===i.Amp&&(this.state=n.BeforeEntity)},c.prototype.stateSpecialStartSequence=function(u){var d=this.sequenceIndex===this.currentSequence.length,h=d?r(u):(u|32)===this.currentSequence[this.sequenceIndex];if(!h)this.isSpecial=!1;else if(!d){this.sequenceIndex++;return}this.sequenceIndex=0,this.state=n.InTagName,this.stateInTagName(u)},c.prototype.stateInSpecialTag=function(u){if(this.sequenceIndex===this.currentSequence.length){if(u===i.Gt||I(u)){var d=this.index-this.currentSequence.length;if(this.sectionStart>14)-1;if(!this.allowLegacyEntity()&&u!==i.Semi)this.trieIndex+=h;else{var f=this.index-this.entityExcess+1;f>this.sectionStart&&this.emitPartial(this.sectionStart,f),this.entityResult=this.trieIndex,this.trieIndex+=h,this.entityExcess=0,this.sectionStart=this.index+1,h===0&&this.emitNamedEntity()}}},c.prototype.emitNamedEntity=function(){if(this.state=this.baseState,this.entityResult!==0){var u=(this.entityTrie[this.entityResult]&g.BinTrieFlags.VALUE_LENGTH)>>14;switch(u){case 1:{this.emitCodePoint(this.entityTrie[this.entityResult]&~g.BinTrieFlags.VALUE_LENGTH);break}case 2:{this.emitCodePoint(this.entityTrie[this.entityResult+1]);break}case 3:this.emitCodePoint(this.entityTrie[this.entityResult+1]),this.emitCodePoint(this.entityTrie[this.entityResult+2])}}},c.prototype.stateBeforeNumericEntity=function(u){(u|32)===i.LowerX?(this.entityExcess++,this.state=n.InHexEntity):(this.state=n.InNumericEntity,this.stateInNumericEntity(u))},c.prototype.emitNumericEntity=function(u){var d=this.index-this.entityExcess-1,h=d+2+ +(this.state===n.InHexEntity);h!==this.index&&(d>this.sectionStart&&this.emitPartial(this.sectionStart,d),this.sectionStart=this.index+Number(u),this.emitCodePoint((0,g.replaceCodePoint)(this.entityResult))),this.state=this.baseState},c.prototype.stateInNumericEntity=function(u){u===i.Semi?this.emitNumericEntity(!0):o(u)?(this.entityResult=this.entityResult*10+(u-i.Zero),this.entityExcess++):(this.allowLegacyEntity()?this.emitNumericEntity(!1):this.state=this.baseState,this.index--)},c.prototype.stateInHexEntity=function(u){u===i.Semi?this.emitNumericEntity(!0):o(u)?(this.entityResult=this.entityResult*16+(u-i.Zero),this.entityExcess++):a(u)?(this.entityResult=this.entityResult*16+((u|32)-i.LowerA+10),this.entityExcess++):(this.allowLegacyEntity()?this.emitNumericEntity(!1):this.state=this.baseState,this.index--)},c.prototype.allowLegacyEntity=function(){return!this.xmlMode&&(this.baseState===n.Text||this.baseState===n.InSpecialTag)},c.prototype.cleanup=function(){this.running&&this.sectionStart!==this.index&&(this.state===n.Text||this.state===n.InSpecialTag&&this.sequenceIndex===0?(this.cbs.ontext(this.sectionStart,this.index),this.sectionStart=this.index):(this.state===n.InAttributeValueDq||this.state===n.InAttributeValueSq||this.state===n.InAttributeValueNq)&&(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=this.index))},c.prototype.shouldContinue=function(){return this.index0&&o.has(this.stack[this.stack.length-1]);){var C=this.stack.pop();(n=(i=this.cbs).onclosetag)===null||n===void 0||n.call(i,C,!0)}this.isVoidElement(g)||(this.stack.push(g),P1e.has(g)?this.foreignContext.push(!0):_1e.has(g)&&this.foreignContext.push(!1)),(r=(I=this.cbs).onopentagname)===null||r===void 0||r.call(I,g),this.cbs.onopentag&&(this.attribs={})},e.prototype.endOpenTag=function(g){var i,n;this.startIndex=this.openTagStart,this.attribs&&((n=(i=this.cbs).onopentag)===null||n===void 0||n.call(i,this.tagname,this.attribs,g),this.attribs=null),this.cbs.onclosetag&&this.isVoidElement(this.tagname)&&this.cbs.onclosetag(this.tagname,!0),this.tagname=""},e.prototype.onopentagend=function(g){this.endIndex=g,this.endOpenTag(!1),this.startIndex=g+1},e.prototype.onclosetag=function(g,i){var n,I,r,o,C,a;this.endIndex=i;var A=this.getSlice(g,i);if(this.lowerCaseTagNames&&(A=A.toLowerCase()),(P1e.has(A)||_1e.has(A))&&this.foreignContext.pop(),this.isVoidElement(A))!this.options.xmlMode&&A==="br"&&((I=(n=this.cbs).onopentagname)===null||I===void 0||I.call(n,"br"),(o=(r=this.cbs).onopentag)===null||o===void 0||o.call(r,"br",{},!0),(a=(C=this.cbs).onclosetag)===null||a===void 0||a.call(C,"br",!1));else{var s=this.stack.lastIndexOf(A);if(s!==-1)if(this.cbs.onclosetag)for(var l=this.stack.length-s;l--;)this.cbs.onclosetag(this.stack.pop(),l!==0);else this.stack.length=s;else!this.options.xmlMode&&A==="p"&&(this.emitOpenTag("p"),this.closeCurrentTag(!0))}this.startIndex=i+1},e.prototype.onselfclosingtag=function(g){this.endIndex=g,this.options.xmlMode||this.options.recognizeSelfClosing||this.foreignContext[this.foreignContext.length-1]?(this.closeCurrentTag(!1),this.startIndex=g+1):this.onopentagend(g)},e.prototype.closeCurrentTag=function(g){var i,n,I=this.tagname;this.endOpenTag(g),this.stack[this.stack.length-1]===I&&((n=(i=this.cbs).onclosetag)===null||n===void 0||n.call(i,I,!g),this.stack.pop())},e.prototype.onattribname=function(g,i){this.startIndex=g;var n=this.getSlice(g,i);this.attribname=this.lowerCaseAttributeNames?n.toLowerCase():n},e.prototype.onattribdata=function(g,i){this.attribvalue+=this.getSlice(g,i)},e.prototype.onattribentity=function(g){this.attribvalue+=(0,E1e.fromCodePoint)(g)},e.prototype.onattribend=function(g,i){var n,I;this.endIndex=i,(I=(n=this.cbs).onattribute)===null||I===void 0||I.call(n,this.attribname,this.attribvalue,g===Mk.QuoteType.Double?'"':g===Mk.QuoteType.Single?"'":g===Mk.QuoteType.NoValue?void 0:null),this.attribs&&!Object.prototype.hasOwnProperty.call(this.attribs,this.attribname)&&(this.attribs[this.attribname]=this.attribvalue),this.attribvalue=""},e.prototype.getInstructionName=function(g){var i=g.search(u$t),n=i<0?g:g.substr(0,i);return this.lowerCaseTagNames&&(n=n.toLowerCase()),n},e.prototype.ondeclaration=function(g,i){this.endIndex=i;var n=this.getSlice(g,i);if(this.cbs.onprocessinginstruction){var I=this.getInstructionName(n);this.cbs.onprocessinginstruction("!".concat(I),"!".concat(n))}this.startIndex=i+1},e.prototype.onprocessinginstruction=function(g,i){this.endIndex=i;var n=this.getSlice(g,i);if(this.cbs.onprocessinginstruction){var I=this.getInstructionName(n);this.cbs.onprocessinginstruction("?".concat(I),"?".concat(n))}this.startIndex=i+1},e.prototype.oncomment=function(g,i,n){var I,r,o,C;this.endIndex=i,(r=(I=this.cbs).oncomment)===null||r===void 0||r.call(I,this.getSlice(g,i-n)),(C=(o=this.cbs).oncommentend)===null||C===void 0||C.call(o),this.startIndex=i+1},e.prototype.oncdata=function(g,i,n){var I,r,o,C,a,A,s,l,c,u;this.endIndex=i;var d=this.getSlice(g,i-n);this.options.xmlMode||this.options.recognizeCDATA?((r=(I=this.cbs).oncdatastart)===null||r===void 0||r.call(I),(C=(o=this.cbs).ontext)===null||C===void 0||C.call(o,d),(A=(a=this.cbs).oncdataend)===null||A===void 0||A.call(a)):((l=(s=this.cbs).oncomment)===null||l===void 0||l.call(s,"[CDATA[".concat(d,"]]")),(u=(c=this.cbs).oncommentend)===null||u===void 0||u.call(c)),this.startIndex=i+1},e.prototype.onend=function(){var g,i;if(this.cbs.onclosetag){this.endIndex=this.startIndex;for(var n=this.stack.length;n>0;this.cbs.onclosetag(this.stack[--n],!0));}(i=(g=this.cbs).onend)===null||i===void 0||i.call(g)},e.prototype.reset=function(){var g,i,n,I;(i=(g=this.cbs).onreset)===null||i===void 0||i.call(g),this.tokenizer.reset(),this.tagname="",this.attribname="",this.attribs=null,this.stack.length=0,this.startIndex=0,this.endIndex=0,(I=(n=this.cbs).onparserinit)===null||I===void 0||I.call(n,this),this.buffers.length=0,this.bufferOffset=0,this.writeIndex=0,this.ended=!1},e.prototype.parseComplete=function(g){this.reset(),this.end(g)},e.prototype.getSlice=function(g,i){for(;g-this.bufferOffset>=this.buffers[0].length;)this.shiftBuffer();for(var n=this.buffers[0].slice(g-this.bufferOffset,i-this.bufferOffset);i-this.bufferOffset>this.buffers[0].length;)this.shiftBuffer(),n+=this.buffers[0].slice(0,i-this.bufferOffset);return n},e.prototype.shiftBuffer=function(){this.bufferOffset+=this.buffers[0].length,this.writeIndex--,this.buffers.shift()},e.prototype.write=function(g){var i,n;if(this.ended){(n=(i=this.cbs).onerror)===null||n===void 0||n.call(i,new Error(".write() after done!"));return}this.buffers.push(g),this.tokenizer.running&&(this.tokenizer.write(g),this.writeIndex++)},e.prototype.end=function(g){var i,n;if(this.ended){(n=(i=this.cbs).onerror)===null||n===void 0||n.call(i,new Error(".end() after done!"));return}g&&this.write(g),this.ended=!0,this.tokenizer.end()},e.prototype.pause=function(){this.tokenizer.pause()},e.prototype.resume=function(){for(this.tokenizer.resume();this.tokenizer.running&&this.writeIndex0&&arguments[0]!==void 0?arguments[0]:{};Tse={},rUe(e)}var SI={},iee={exports:{}};(function(e,g){Object.defineProperty(g,"__esModule",{value:!0});var i=function(n){function I(r,o){return n.apply(this,arguments)}return I.toString=function(){return n.toString()},I}(function(n,I){return typeof n!="object"||n===null||typeof I!="object"||I===null?!1:Object.keys(I).every(function(r){if(!n.propertyIsEnumerable(r))return!1;var o=I[r],C=n[r];return!(typeof o=="object"&&o!==null?!i(C,o):C!==o)})});g.default=i,e.exports=g.default})(iee,iee.exports);var G$t=iee.exports,Lm={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var g=e_,i=I(g),n=tZ;function I(o){return o&&o.__esModule?o:{default:o}}function r(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(o.adapter)return(0,i.default)(o.adapter),o.adapter;var C=(0,n.get)(),a=C.adapter;return(0,i.default)(a),a}})(Lm);Object.defineProperty(SI,"__esModule",{value:!0});var v$t=function(){function e(g,i){var n=[],I=!0,r=!1,o=void 0;try{for(var C=g[Symbol.iterator](),a;!(I=(a=C.next()).done)&&(n.push(a.value),!(i&&n.length===i));I=!0);}catch(A){r=!0,o=A}finally{try{!I&&C.return&&C.return()}finally{if(r)throw o}}return n}return function(g,i){if(Array.isArray(g))return g;if(Symbol.iterator in Object(g))return e(g,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();SI.propsOfNode=t_;SI.childrenOfNode=P1;SI.hasClassName=E$t;SI.treeForEach=Hse;SI.treeFilter=Nse;SI.findParentNode=D$t;SI.pathToNode=oUe;SI.parentsOfNode=z$t;SI.nodeHasId=P$t;SI.nodeMatchesObjectProps=L$t;SI.getTextFromNode=CUe;SI.getTextFromHostNodes=aUe;SI.getHTMLFromHostNodes=sUe;var B$t=k1,w$t=gZ(B$t),S$t=FT,O1e=gZ(S$t),R$t=kOe,V$t=gZ(R$t),W$t=G$t,X$t=gZ(W$t),T$t=Cse,H$t=gZ(T$t),N$t=COe,k$t=gZ(N$t),Y$t=Lm,K$t=gZ(Y$t);function gZ(e){return e&&e.__esModule?e:{default:e}}function x$t(e,g,i){return g in e?Object.defineProperty(e,g,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[g]=i,e}function F$t(e){if(Array.isArray(e)){for(var g=0,i=Array(e.length);g-1}function Hse(e,g){e&&g(e),P1(e).forEach(function(i){return Hse(i,g)})}function Nse(e,g){var i=[];return Hse(e,function(n){g(n)&&i.push(n)}),i}function D$t(e,g){var i=Nse(e,function(n){return n.rendered?P1(n).indexOf(g)!==-1:!1});return i[0]||null}function M$t(e,g){return e.filter(function(i){return Nse(i,g).length!==0})}function oUe(e,g){for(var i=[g],n=[],I=function(a){return e===a};i.length;){var r=i.pop(),o=P1(r);if(r===e)return M$t(n,I);n.push(r),o.length===0&&n.pop(),i.push.apply(i,F$t(o))}return null}function z$t(e,g){return(oUe(e,g)||[]).reverse()}function P$t(e,g){return t_(e).id===g}var _$t={};function O$t(e){return typeof e<"u"?e:_$t}function J$t(e){return(0,V$t.default)(e).reduce(function(g,i){var n=v$t(i,2),I=n[0],r=n[1];return(0,w$t.default)({},g,x$t({},I,O$t(r)))},{})}function L$t(e,g){return(0,X$t.default)(t_(e),J$t(g))}function U$t(e){return typeof e=="string"?String(e||""):e&&e.textContent||""}function kse(e,g){var i=g.getCustom,n=g.handleHostNodes,I=g.recurse,r=g.nullRenderReturnsNull,o=r===void 0?!1:r;return e==null?"":typeof e=="string"||typeof e=="number"?String(e):i&&e.type&&typeof e.type=="function"?i(e):n&&e.nodeType==="host"?n(e):e.rendered==null&&o?null:P1(e).map(I).join("")}function CUe(e){return kse(e,{recurse:CUe,getCustom:function(){function g(i){var n=i.type;return"<"+String(n.displayName||(0,H$t.default)(n))+" />"}return g}()})}function aUe(e,g){return kse(e,{recurse:function(){function i(n){return aUe(n,g)}return i}(),handleHostNodes:function(){function i(n){var I=[].concat(g.nodeToHostNode(n,!0));return I.map(U$t).join("")}return i}()})}function Q$t(e){return e==null?null:e.outerHTML.replace(/\sdata-(reactid|reactroot)+="([^"]*)+"/g,"")}function sUe(e,g){return kse(e,{recurse:function(){function i(n){return sUe(n,g)}return i}(),handleHostNodes:function(){function i(n){var I=[].concat(g.nodeToHostNode(n,!0));return I.map(Q$t).join("")}return i}(),nullRenderReturnsNull:!0})}(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.shallowEqual=e.ITERATOR_SYMBOL=void 0;var g=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(E){return typeof E}:function(E){return E&&typeof Symbol=="function"&&E.constructor===Symbol&&E!==Symbol.prototype?"symbol":typeof E},i=function(){function E(H,K){var te=[],me=!0,Re=!1,Ee=void 0;try{for(var nt=H[Symbol.iterator](),wt;!(me=(wt=nt.next()).done)&&(te.push(wt.value),!(K&&te.length===K));me=!0);}catch(kt){Re=!0,Ee=kt}finally{try{!me&&nt.return&&nt.return()}finally{if(Re)throw Ee}}return te}return function(H,K){if(Array.isArray(H))return H;if(Symbol.iterator in Object(H))return E(H,K);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();e.getAdapter=N,e.makeOptions=x,e.isCustomComponent=M,e.isCustomComponentElement=F,e.propsOfNode=$,e.typeOfNode=Q,e.nodeHasType=U,e.nodeMatches=oe,e.nodeEqual=pe,e.containsChildrenSubArray=ae,e.childrenToSimplifiedArray=ue,e.isReactElementAlike=Be,e.withSetStateAllowed=ke,e.AND=_e,e.displayNameOfNode=Pe,e.sym=it,e.privateSet=lt,e.cloneElement=je,e.spyMethod=He;var n=VOe;Object.defineProperty(e,"shallowEqual",{enumerable:!0,get:function(){function E(){return W(n).default}return E}()}),e.isEmptyValue=Ce,e.renderedDive=Ze,e.loadCheerioRoot=Te;var I=k1,r=W(I),o=Uz,C=W(o),a=rse,A=W(a),s=kOe,l=W(s),c=Cse,u=W(c),d=K1,h=W(d),f=FT,m=W(f),b=dOe,p=W(b),y=_Oe,Z=W(y),v=Om,G=tZ,B=SI,S=Lm,R=W(S),w=e_,T=W(w);function W(E){return E&&E.__esModule?E:{default:E}}function V(E,H,K){return H in E?Object.defineProperty(E,H,{value:K,enumerable:!0,configurable:!0,writable:!0}):E[H]=K,E}function X(E,H){var K={};for(var te in E)H.indexOf(te)>=0||Object.prototype.hasOwnProperty.call(E,te)&&(K[te]=E[te]);return K}e.ITERATOR_SYMBOL=typeof Symbol=="function"&&Symbol.iterator;function N(){var E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return console.warn("getAdapter from Utils is deprecated; please use ./getAdapter instead"),(0,R.default)(E)}function Y(E,H){if(E&&H&&E!==H)throw new TypeError("If both the `attachTo` and `hydrateIn` options are provided, they must be === (for backwards compatibility)")}function x(E){var H=(0,G.get)(),K=H.attachTo,te=H.hydrateIn,me=X(H,["attachTo","hydrateIn"]);Y(K,te);var Re=E.attachTo,Ee=E.hydrateIn;Y(Re,Ee);var nt=Ee||te||K||Re||void 0,wt=Ee||te||void 0,kt=(0,r.default)({},nt&&{attachTo:nt},wt&&{hydrateIn:wt});return(0,r.default)({},me,E,kt)}function M(E,H){return(0,T.default)(H),H.isCustomComponent?!!H.isCustomComponent(E):typeof E=="function"}function F(E,H){return H.isCustomComponentElement?!!H.isCustomComponentElement(E):!!E&&H.isValidElement(E)&&typeof E.type=="function"}function $(E){return(0,l.default)(E&&E.props||{}).filter(function(H){var K=i(H,2),te=K[1];return typeof te<"u"}).reduce(function(H,K){var te=i(K,2),me=te[0],Re=te[1];return(0,r.default)(H,V({},me,Re))},{})}function Q(E){return E?E.type:null}function U(E,H){if(!H||!E)return!1;var K=(0,R.default)();if(K.displayNameOfNode){var te=K.displayNameOfNode(E);return te===H}return E.type?typeof E.type=="string"?E.type===H:(typeof E.type=="function"?(0,u.default)(E.type)===H:E.type.name===H)||E.type.displayName===H:!1}function j(E,H,K,te){var me=te?oe:pe;if(E===H)return!0;if(!Array.isArray(E)&&!Array.isArray(H))return me(E,H,K);var Re=(0,m.default)(E,1/0),Ee=(0,m.default)(H,1/0);if(Re.length!==Ee.length)return!1;if(Re.length===0&&Ee.length===0)return!0;for(var nt=0;nt2&&arguments[2]!==void 0?arguments[2]:A.default;return Ve(E,H,K,!0)}function pe(E,H){var K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:A.default;return Ve(E,H,K,!1)}function ae(E,H,K){var te=(0,B.childrenOfNode)(H),me=function(Ee,nt){return ie(E,te.slice(nt,nt+K.length),K)};return te.some(me)}function ie(E,H,K){return H.length===K.length&&H.every(function(te,me){return E(te,K[me])})}function ye(E){var H=[],K=function(me){me===null||me===!1||typeof me>"u"||H.push(me)};return Array.isArray(E)?E.forEach(K):K(E),H}function ue(E){for(var H=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,K=ye(E),te=[],me=0;me"u"?te.push(Re):Ye(Re)&&Ye(Ee)?te.push(Ee+Re):(te.push(Ee),te.push(Re))}return H?te.map(function(nt){return typeof nt=="string"?(0,p.default)(nt):nt}):te}function Ye(E){return typeof E=="string"||typeof E=="number"}function Be(E,H){return H.isValidElement(E)||Ye(E)||Array.isArray(E)}function ke(E){var H=!1;typeof globalThis.document>"u"&&(H=!0,globalThis.document={}),E(),H&&(globalThis.document=void 0,delete globalThis.document)}function _e(E){var H=E.slice().reverse();return function(K){return H.every(function(te){return te(K)})}}function Pe(E){if(!E)return null;var H=E.type;return H?H.displayName||(typeof H=="function"?(0,u.default)(H):H.name||H):null}function it(E){return typeof Symbol=="function"?Symbol.for("enzyme."+String(E)):E}function lt(E,H,K){Object.defineProperty(E,H,{value:K,enumerable:!1,writable:!0})}function je(E,H,K){return E.createElement(H.type,(0,r.default)({},H.props,K))}function He(E,H){var K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){},te=void 0,me=E[H],Re=(0,h.default)(E,H),Ee=void 0;return Re&&(Ee=Object.getOwnPropertyDescriptor(E,H)),Object.defineProperty(E,H,{configurable:!0,enumerable:!Ee||!!Ee.enumerable,value:K(me)||function(){function nt(){for(var wt=arguments.length,kt=Array(wt),yt=0;yt"'`]/g,q$t=RegExp(AUe.source),e8t={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},t8t=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis,g8t=typeof self=="object"&&self&&self.Object===Object&&self,i8t=t8t||g8t||Function("return this")();function n8t(e){return function(g){return e?.[g]}}var I8t=n8t(e8t),r8t=Object.prototype,o8t=r8t.toString,J1e=i8t.Symbol,L1e=J1e?J1e.prototype:void 0,U1e=L1e?L1e.toString:void 0;function C8t(e){if(typeof e=="string")return e;if(s8t(e))return U1e?U1e.call(e):"";var g=e+"";return g=="0"&&1/e==-j$t?"-0":g}function a8t(e){return!!e&&typeof e=="object"}function s8t(e){return typeof e=="symbol"||a8t(e)&&o8t.call(e)==$$t}function A8t(e){return e==null?"":C8t(e)}function l8t(e){return e=A8t(e),e&&q$t.test(e)?e.replace(AUe,I8t):e}var c8t=l8t,u8t=String.prototype.valueOf,d8t=function(g){try{return u8t.call(g),!0}catch{return!1}},h8t=Object.prototype.toString,f8t="[object String]",m8t=xT(),lUe=function(g){return typeof g=="string"?!0:typeof g!="object"?!1:m8t?d8t(g):h8t.call(g)===f8t},p8t=Number.prototype.toString,b8t=function(g){try{return p8t.call(g),!0}catch{return!1}},y8t=Object.prototype.toString,Z8t="[object Number]",G8t=xT(),v8t=function(g){return typeof g=="number"?!0:typeof g!="object"?!1:G8t?b8t(g):y8t.call(g)===Z8t},cUe=Jo,B8t=cUe("Boolean.prototype.toString"),w8t=cUe("Object.prototype.toString"),S8t=function(g){try{return B8t(g),!0}catch{return!1}},R8t="[object Boolean]",V8t=xT(),W8t=function(g){return typeof g=="boolean"?!0:g===null||typeof g!="object"?!1:V8t&&Symbol.toStringTag in g?S8t(g):w8t(g)===R8t};Object.defineProperty(Um,"__esModule",{value:!0});var Q1e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Um.typeName=hUe;Um.spaces=fUe;Um.indent=mUe;Um.debugNode=Yse;Um.debugNodes=Q8t;var X8t=c8t,T8t=ih(X8t),H8t=Cse,uUe=ih(H8t),N8t=lUe,k8t=ih(N8t),Y8t=v8t,K8t=ih(Y8t),x8t=ise,F8t=ih(x8t),E8t=W8t,D8t=ih(E8t),M8t=D_e,RG=ih(M8t),z8t=K1,qZ=ih(z8t),dUe=SI,P8t=Lm,nee=ih(P8t);function ih(e){return e&&e.__esModule?e:{default:e}}var _8t=Function.bind.call(Function.call,Boolean.prototype.valueOf);function hUe(e){var g=(0,nee.default)();return g.displayNameOfNode?(0,nee.default)().displayNameOfNode(e)||"Component":typeof e.type=="function"?e.type.displayName||(0,uUe.default)(e.type)||"Component":e.type}function fUe(e){return Array(e+1).join(" ")}function mUe(e,g){return g.split(` +`).map(function(i){return""+String(fUe(e))+String(i)}).join(` +`)}function O8t(e,g){return(0,k8t.default)(e)?(0,RG.default)(String(e),{quoteStyle:"double"}):(0,K8t.default)(e)?"{"+String((0,RG.default)(Number(e)))+"}":(0,D8t.default)(e)?"{"+String((0,RG.default)(_8t(e)))+"}":(0,F8t.default)(e)?"{"+String((0,RG.default)(e))+"}":(typeof e>"u"?"undefined":Q1e(e))==="object"?g.verbose?"{"+String((0,RG.default)(e))+"}":"{{...}}":"{["+(typeof e>"u"?"undefined":Q1e(e))+"]}"}function J8t(e,g){var i=(0,dUe.propsOfNode)(e),n=Object.keys(i).filter(function(I){return I!=="children"});return n.map(function(I){return String(I)+"="+String(O8t(i[I],g))}).join(" ")}function L8t(e,g){return e.length?` +`+String(e.map(function(i){return mUe(g,i)}).join(` +`))+` +`:""}function U8t(e){return(0,qZ.default)(e,"nodeType")&&typeof e.nodeType=="string"&&(0,qZ.default)(e,"type")&&(0,qZ.default)(e,"key")&&(0,qZ.default)(e,"ref")&&(0,qZ.default)(e,"instance")&&(0,qZ.default)(e,"rendered")}function Yse(e){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(typeof e=="string"||typeof e=="number")return(0,T8t.default)(e);if(typeof e=="function"){var n=(0,uUe.default)(e);return"[function"+(n?" "+String(n):"")+"]"}if(!e)return"";var I=(0,nee.default)();if(!I.isValidElement(e)&&!U8t(e))return"{"+String((0,RG.default)(e))+"}";var r=(0,dUe.childrenOfNode)(e).map(function(c){return Yse(c,g,i)}).filter(Boolean),o=hUe(e),C=i.ignoreProps?"":J8t(e,i),a=C?" ":"",A=r.length?">":" ",s=L8t(r,g),l=r.length?"":"/>";return"<"+String(o)+a+String(C)+A+String(s)+l}function Q8t(e){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e.map(function(i){return Yse(i,void 0,g)}).join(` + + +`)}var _1={},mw={},Kse={};Object.defineProperty(Kse,"__esModule",{value:!0});var j1e=function(g){return JSON.stringify(g)},j8t=function(g){var i=g.body,n=[],I=!0,r=!1,o=void 0;try{for(var C=i[Symbol.iterator](),a;!(I=(a=C.next()).done);I=!0){var A=a.value,s=void 0;if(A.type==="universalSelector")s="*";else if(A.type==="typeSelector")s=A.name;else if(A.type==="idSelector")s="#"+A.name;else if(A.type==="classSelector")s="."+A.name;else if(A.type==="attributePresenceSelector")s="["+A.name+"]";else if(A.type==="attributeValueSelector")s="["+A.name+A.operator+j1e(A.value)+"]";else if(A.type==="pseudoClassSelector")s=":"+A.name,A.parameters.length&&(s+="("+A.parameters.map(j1e).join(", ")+")");else if(A.type==="pseudoElementSelector")s="::"+A.name;else throw new Error("Unknown token.");n.push(s)}}catch(l){r=!0,o=l}finally{try{!I&&C.return&&C.return()}finally{if(r)throw o}}return n.join("")};Kse.default=function(){var e=function(i){var n=[],I=!0,r=!1,o=void 0;try{for(var C=i[Symbol.iterator](),a;!(I=(a=C.next()).done);I=!0){var A=a.value;if(A.type==="selector")n.push(j8t(A));else if(A.type==="descendantCombinator")n.push(" ");else if(A.type==="childCombinator")n.push(" > ");else if(A.type==="adjacentSiblingCombinator")n.push(" + ");else if(A.type==="generalSiblingCombinator")n.push(" ~ ");else throw new Error("Unknown token.")}}catch(s){r=!0,o=s}finally{try{!I&&C.return&&C.return()}finally{if(r)throw o}}return n.join("")};return{generate:e}};var xse={},pUe={exports:{}};(function(e){(function(g,i){e.exports?e.exports=i():g.nearley=i()})(Qe,function(){function g(A,s,l){return this.id=++g.highestId,this.name=A,this.symbols=s,this.postprocess=l,this}g.highestId=0,g.prototype.toString=function(A){var s=typeof A>"u"?this.symbols.map(a).join(" "):this.symbols.slice(0,A).map(a).join(" ")+" ● "+this.symbols.slice(A).map(a).join(" ");return this.name+" → "+s};function i(A,s,l,c){this.rule=A,this.dot=s,this.reference=l,this.data=[],this.wantedBy=c,this.isComplete=this.dot===A.symbols.length}i.prototype.toString=function(){return"{"+this.rule.toString(this.dot)+"}, from: "+(this.reference||0)},i.prototype.nextState=function(A){var s=new i(this.rule,this.dot+1,this.reference,this.wantedBy);return s.left=this,s.right=A,s.isComplete&&(s.data=s.build(),s.right=void 0),s},i.prototype.build=function(){var A=[],s=this;do A.push(s.right.data),s=s.left;while(s.left);return A.reverse(),A},i.prototype.finish=function(){this.rule.postprocess&&(this.data=this.rule.postprocess(this.data,this.reference,o.fail))};function n(A,s){this.grammar=A,this.index=s,this.states=[],this.wants={},this.scannable=[],this.completed={}}n.prototype.process=function(A){for(var s=this.states,l=this.wants,c=this.completed,u=0;u0&&s.push(" ^ "+c+" more lines identical to this"),c=0,s.push(" "+h)),l=h}},o.prototype.getSymbolDisplay=function(A){return C(A)},o.prototype.buildFirstStateStack=function(A,s){if(s.indexOf(A)!==-1)return null;if(A.wantedBy.length===0)return[A];var l=A.wantedBy[0],c=[A].concat(s),u=this.buildFirstStateStack(l,c);return u===null?null:[A].concat(u)},o.prototype.save=function(){var A=this.table[this.current];return A.lexerState=this.lexerState,A},o.prototype.restore=function(A){var s=A.index;this.current=s,this.table[s]=A,this.table.splice(s+1),this.lexerState=A.lexerState,this.results=this.finish()},o.prototype.rewind=function(A){if(!this.options.keepHistory)throw new Error("set option `keepHistory` to enable rewinding");this.restore(this.table[A])},o.prototype.finish=function(){var A=[],s=this.grammar.start,l=this.table[this.table.length-1];return l.states.forEach(function(c){c.rule.name===s&&c.dot===c.rule.symbols.length&&c.reference===0&&c.data!==o.fail&&A.push(c)}),A.map(function(c){return c.data})};function C(A){var s=typeof A;if(s==="string")return A;if(s==="object"){if(A.literal)return JSON.stringify(A.literal);if(A instanceof RegExp)return"character matching "+A;if(A.type)return A.type+" token";if(A.test)return"token matching "+String(A.test);throw new Error("Unknown symbol type: "+A)}}function a(A){var s=typeof A;if(s==="string")return A;if(s==="object"){if(A.literal)return JSON.stringify(A.literal);if(A instanceof RegExp)return A.toString();if(A.type)return"%"+A.type;if(A.test)return"<"+String(A.test)+">";throw new Error("Unknown symbol type: "+A)}}return{Parser:o,Grammar:I,Rule:g}})})(pUe);var $8t=pUe.exports,bUe={exports:{}},q8t=1/0,e6t=9007199254740991,t6t="[object Arguments]",g6t="[object Function]",i6t="[object GeneratorFunction]",n6t=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis,I6t=typeof self=="object"&&self&&self.Object===Object&&self,r6t=n6t||I6t||Function("return this")();function o6t(e,g){for(var i=-1,n=g.length,I=e.length;++i0&&i(C)?g>1?ZUe(C,g-1,i,n,I):o6t(I,C):n||(I[I.length]=C)}return I}function s6t(e){return c6t(e)||l6t(e)||!!(q1e&&e&&e[q1e])}function A6t(e){var g=e?e.length:0;return g?ZUe(e,q8t):[]}function l6t(e){return d6t(e)&&C6t.call(e,"callee")&&(!a6t.call(e,"callee")||yUe.call(e)==t6t)}var c6t=Array.isArray;function u6t(e){return e!=null&&f6t(e.length)&&!h6t(e)}function d6t(e){return p6t(e)&&u6t(e)}function h6t(e){var g=m6t(e)?yUe.call(e):"";return g==g6t||g==i6t}function f6t(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=e6t}function m6t(e){var g=typeof e;return!!e&&(g=="object"||g=="function")}function p6t(e){return!!e&&typeof e=="object"}var b6t=A6t;(function(e){(function(){function g(l){return l[0]}var i=b6t,n=function(c,u){return function(d){return d[c].concat([d[u]])}},I=function(c){return c=c.filter(function(u){return u!==null}),i(c)},r={" ":"descendantCombinator","+":"adjacentSiblingCombinator",">":"childCombinator","~":"generalSiblingCombinator"},o=function(c){return(Array.isArray(c[0])?c[0]:[c[0]]).concat({type:r[c[2]]}).concat(c[4])},C=function(c,u,d){var h=i(c).join(""),f=parseFloat(h);return isNaN(f)?d:f},a=function(c,u,d){return c[0]==="true"?!0:c[0]==="false"?!1:d},A=function(c,u,d){if(c[0]==="NaN")return NaN;if(c[0]!=="undefined")return c[0]==="null"?null:d},s={Lexer:void 0,ParserRules:[{name:"combinator",symbols:["selector"]},{name:"combinator",symbols:["combinator","_",/[>+~ ]/,"_","selector"],postprocess:o},{name:"selector",symbols:["selectorBody"],postprocess:function(c){return{type:"selector",body:c[0]}}},{name:"selectorBody$ebnf$1",symbols:["typeSelector"],postprocess:g},{name:"selectorBody$ebnf$1",symbols:[],postprocess:function(c){return null}},{name:"selectorBody$ebnf$2",symbols:[]},{name:"selectorBody$ebnf$2",symbols:["selectorBody$ebnf$2","simpleSelector"],postprocess:function(c){return c[0].concat([c[1]])}},{name:"selectorBody",symbols:["selectorBody$ebnf$1","selectorBody$ebnf$2"],postprocess:function(c,u,d){var h=I(c);return h.length?h:d}},{name:"selectorBody$ebnf$3",symbols:[]},{name:"selectorBody$ebnf$3",symbols:["selectorBody$ebnf$3","simpleSelector"],postprocess:function(c){return c[0].concat([c[1]])}},{name:"selectorBody",symbols:["universalSelector","selectorBody$ebnf$3"],postprocess:I},{name:"simpleSelector",symbols:["idSelector"]},{name:"simpleSelector",symbols:["classSelector"]},{name:"simpleSelector",symbols:["attributeValueSelector"]},{name:"simpleSelector",symbols:["attributePresenceSelector"]},{name:"simpleSelector",symbols:["pseudoClassSelector"]},{name:"simpleSelector",symbols:["pseudoElementSelector"]},{name:"typeSelector",symbols:["attributeName"],postprocess:function(c){return{type:"typeSelector",name:c[0]}}},{name:"className$ebnf$1",symbols:[{literal:"-"}],postprocess:g},{name:"className$ebnf$1",symbols:[],postprocess:function(c){return null}},{name:"className$ebnf$2",symbols:[]},{name:"className$ebnf$2",symbols:["className$ebnf$2",/[_a-zA-Z0-9-]/],postprocess:function(c){return c[0].concat([c[1]])}},{name:"className",symbols:["className$ebnf$1",/[_a-zA-Z]/,"className$ebnf$2"],postprocess:function(c){return(c[0]||"")+c[1]+c[2].join("")}},{name:"attributeName$ebnf$1",symbols:[]},{name:"attributeName$ebnf$1",symbols:["attributeName$ebnf$1",/[_a-zA-Z()0-9-]/],postprocess:function(c){return c[0].concat([c[1]])}},{name:"attributeName",symbols:[/[_a-z()A-Z]/,"attributeName$ebnf$1"],postprocess:function(c){return c[0]+c[1].join("")}},{name:"classSelector",symbols:[{literal:"."},"className"],postprocess:function(c){return{type:"classSelector",name:c[1]}}},{name:"idSelector",symbols:[{literal:"#"},"attributeName"],postprocess:function(c){return{type:"idSelector",name:c[1]}}},{name:"universalSelector",symbols:[{literal:"*"}],postprocess:function(c){return{type:"universalSelector"}}},{name:"attributePresenceSelector",symbols:[{literal:"["},"attributeName",{literal:"]"}],postprocess:function(c){return{type:"attributePresenceSelector",name:c[1]}}},{name:"attributeOperator",symbols:[{literal:"="}]},{name:"attributeOperator$string$1",symbols:[{literal:"~"},{literal:"="}],postprocess:function(c){return c.join("")}},{name:"attributeOperator",symbols:["attributeOperator$string$1"]},{name:"attributeOperator$string$2",symbols:[{literal:"|"},{literal:"="}],postprocess:function(c){return c.join("")}},{name:"attributeOperator",symbols:["attributeOperator$string$2"]},{name:"attributeOperator$string$3",symbols:[{literal:"^"},{literal:"="}],postprocess:function(c){return c.join("")}},{name:"attributeOperator",symbols:["attributeOperator$string$3"]},{name:"attributeOperator$string$4",symbols:[{literal:"$"},{literal:"="}],postprocess:function(c){return c.join("")}},{name:"attributeOperator",symbols:["attributeOperator$string$4"]},{name:"attributeOperator$string$5",symbols:[{literal:"*"},{literal:"="}],postprocess:function(c){return c.join("")}},{name:"attributeOperator",symbols:["attributeOperator$string$5"]},{name:"attributeValueSelector",symbols:[{literal:"["},"attributeName","attributeOperator","attributeValue",{literal:"]"}],postprocess:function(c){return{type:"attributeValueSelector",name:c[1],value:c[3],operator:c[2][0]}}},{name:"attributeValue",symbols:["falsyPrimitiveStrings"],postprocess:g},{name:"attributeValue",symbols:["numericValue"],postprocess:g},{name:"attributeValue",symbols:["sqstring"],postprocess:g},{name:"attributeValue",symbols:["dqstring"],postprocess:g},{name:"falsyPrimitiveStrings$string$1",symbols:[{literal:"f"},{literal:"a"},{literal:"l"},{literal:"s"},{literal:"e"}],postprocess:function(c){return c.join("")}},{name:"falsyPrimitiveStrings",symbols:["falsyPrimitiveStrings$string$1"],postprocess:a},{name:"falsyPrimitiveStrings$string$2",symbols:[{literal:"t"},{literal:"r"},{literal:"u"},{literal:"e"}],postprocess:function(c){return c.join("")}},{name:"falsyPrimitiveStrings",symbols:["falsyPrimitiveStrings$string$2"],postprocess:a},{name:"falsyPrimitiveStrings$string$3",symbols:[{literal:"N"},{literal:"a"},{literal:"N"}],postprocess:function(c){return c.join("")}},{name:"falsyPrimitiveStrings",symbols:["falsyPrimitiveStrings$string$3"],postprocess:A},{name:"falsyPrimitiveStrings$string$4",symbols:[{literal:"n"},{literal:"u"},{literal:"l"},{literal:"l"}],postprocess:function(c){return c.join("")}},{name:"falsyPrimitiveStrings",symbols:["falsyPrimitiveStrings$string$4"],postprocess:A},{name:"falsyPrimitiveStrings$string$5",symbols:[{literal:"u"},{literal:"n"},{literal:"d"},{literal:"e"},{literal:"f"},{literal:"i"},{literal:"n"},{literal:"e"},{literal:"d"}],postprocess:function(c){return c.join("")}},{name:"falsyPrimitiveStrings",symbols:["falsyPrimitiveStrings$string$5"],postprocess:A},{name:"numericValue",symbols:["int",{literal:"."},"int"],postprocess:C},{name:"numericValue",symbols:[{literal:"+"},"int",{literal:"."},"int"],postprocess:C},{name:"numericValue",symbols:[{literal:"-"},"int",{literal:"."},"int"],postprocess:C},{name:"numericValue",symbols:[{literal:"-"},"int"],postprocess:C},{name:"numericValue",symbols:["int"],postprocess:C},{name:"numericValue",symbols:[{literal:"+"},"int"],postprocess:C},{name:"numericValue$string$1",symbols:[{literal:"I"},{literal:"n"},{literal:"f"},{literal:"i"},{literal:"n"},{literal:"i"},{literal:"t"},{literal:"y"}],postprocess:function(c){return c.join("")}},{name:"numericValue",symbols:["numericValue$string$1"],postprocess:C},{name:"numericValue$string$2",symbols:[{literal:"+"},{literal:"I"},{literal:"n"},{literal:"f"},{literal:"i"},{literal:"n"},{literal:"i"},{literal:"t"},{literal:"y"}],postprocess:function(c){return c.join("")}},{name:"numericValue",symbols:["numericValue$string$2"],postprocess:C},{name:"numericValue$string$3",symbols:[{literal:"-"},{literal:"I"},{literal:"n"},{literal:"f"},{literal:"i"},{literal:"n"},{literal:"i"},{literal:"t"},{literal:"y"}],postprocess:function(c){return c.join("")}},{name:"numericValue",symbols:["numericValue$string$3"],postprocess:C},{name:"int$ebnf$1",symbols:[/[0-9]/]},{name:"int$ebnf$1",symbols:["int$ebnf$1",/[0-9]/],postprocess:function(c){return c[0].concat([c[1]])}},{name:"int",symbols:["int$ebnf$1"]},{name:"classParameters",symbols:[]},{name:"classParameters",symbols:["classParameter"]},{name:"classParameters",symbols:["classParameters",{literal:","},"_","classParameter"],postprocess:n(0,3)},{name:"classParameter$ebnf$1",symbols:[/[^()"', ]/]},{name:"classParameter$ebnf$1",symbols:["classParameter$ebnf$1",/[^()"', ]/],postprocess:function(c){return c[0].concat([c[1]])}},{name:"classParameter",symbols:["classParameter$ebnf$1"],postprocess:function(c){return c[0].join("")}},{name:"classParameter",symbols:["sqstring"],postprocess:g},{name:"classParameter",symbols:["dqstring"],postprocess:g},{name:"pseudoElementSelector$string$1",symbols:[{literal:":"},{literal:":"}],postprocess:function(c){return c.join("")}},{name:"pseudoElementSelector",symbols:["pseudoElementSelector$string$1","pseudoClassSelectorName"],postprocess:function(c){return{type:"pseudoElementSelector",name:c[1]}}},{name:"pseudoClassSelector",symbols:[{literal:":"},"pseudoClassSelectorName"],postprocess:function(c){return{type:"pseudoClassSelector",name:c[1]}}},{name:"pseudoClassSelector",symbols:[{literal:":"},"pseudoClassSelectorName",{literal:"("},"classParameters",{literal:")"}],postprocess:function(c){return{type:"pseudoClassSelector",name:c[1],parameters:c[3]}}},{name:"pseudoClassSelectorName$ebnf$1",symbols:[/[a-zA-Z0-9-_]/]},{name:"pseudoClassSelectorName$ebnf$1",symbols:["pseudoClassSelectorName$ebnf$1",/[a-zA-Z0-9-_]/],postprocess:function(c){return c[0].concat([c[1]])}},{name:"pseudoClassSelectorName",symbols:[/[a-zA-Z]/,"pseudoClassSelectorName$ebnf$1"],postprocess:function(c){return c[0]+c[1].join("")}},{name:"dqstring$ebnf$1",symbols:[]},{name:"dqstring$ebnf$1",symbols:["dqstring$ebnf$1","dstrchar"],postprocess:function(c){return c[0].concat([c[1]])}},{name:"dqstring",symbols:[{literal:'"'},"dqstring$ebnf$1",{literal:'"'}],postprocess:function(c){return c[1].join("")}},{name:"dstrchar",symbols:[/[^"]/],postprocess:g},{name:"dstrchar$string$1",symbols:[{literal:"\\"},{literal:'"'}],postprocess:function(c){return c.join("")}},{name:"dstrchar",symbols:["dstrchar$string$1"],postprocess:function(c){return'"'}},{name:"sqstring$ebnf$1",symbols:[]},{name:"sqstring$ebnf$1",symbols:["sqstring$ebnf$1","sstrchar"],postprocess:function(c){return c[0].concat([c[1]])}},{name:"sqstring",symbols:[{literal:"'"},"sqstring$ebnf$1",{literal:"'"}],postprocess:function(c){return c[1].join("")}},{name:"sstrchar",symbols:[/[^']/],postprocess:g},{name:"sstrchar$string$1",symbols:[{literal:"\\"},{literal:"'"}],postprocess:function(c){return c.join("")}},{name:"sstrchar",symbols:["sstrchar$string$1"],postprocess:function(c){return"'"}},{name:"_$ebnf$1",symbols:[]},{name:"_$ebnf$1",symbols:["_$ebnf$1",/[ ]/],postprocess:function(c){return c[0].concat([c[1]])}},{name:"_",symbols:["_$ebnf$1"],postprocess:function(c){return null}}],ParserStart:"combinator"};e.exports=s})()})(bUe);var y6t=bUe.exports;Object.defineProperty(xse,"__esModule",{value:!0});var Z6t=$8t,G6t=y6t,eSe=v6t(G6t);function v6t(e){return e&&e.__esModule?e:{default:e}}xse.default=function(){var e=function(i){var n=new Z6t.Parser(eSe.default.ParserRules,eSe.default.ParserStart),I=n.feed(i).results;if(I.length===0)throw new Error("Found no parsings.");if(I.length>1)throw new Error("Ambiguous results.");return I[0]};return{parse:e}};Object.defineProperty(mw,"__esModule",{value:!0});mw.createParser=mw.createGenerator=void 0;var B6t=Kse,w6t=GUe(B6t),S6t=xse,R6t=GUe(S6t);function GUe(e){return e&&e.__esModule?e:{default:e}}mw.createGenerator=w6t.default;mw.createParser=R6t.default;var V6t=Y1,vUe=Jo,W6t=vUe("Object.prototype.propertyIsEnumerable"),X6t=vUe("Array.prototype.push"),BUe=function(g){var i=V6t(g),n=[];for(var I in i)W6t(i,I)&&X6t(n,i[I]);return n},T6t=BUe,wUe=function(){return typeof Object.values=="function"?Object.values:T6t},H6t=wUe,N6t=Io,k6t=function(){var g=H6t();return N6t(Object,{values:g},{values:function(){return Object.values!==g}}),g},Y6t=Io,K6t=eh,x6t=BUe,SUe=wUe,F6t=k6t,RUe=K6t(SUe(),Object);Y6t(RUe,{getPolyfill:SUe,implementation:x6t,shim:F6t});var E6t=RUe,D6t=q_e,M6t=tOe(),z6t=iOe(),P6t=KT,_6t=nOe(),O6t=nse,J6t=pOe(),L6t=U_e,U6t=bOe,tSe=Ise,Q6t=Jo,j6t=lUe,gSe=Object("a"),$6t=gSe[0]!=="a"||!(0 in gSe),q6t=Q6t("String.prototype.split"),VUe=function(g){var i=U6t(this),n=$6t&&j6t(i)?q6t(i,""):i,I=J6t(n);if(!O6t(g))throw new TypeError("Array.prototype.filter callback must be a function");var r;arguments.length>1&&(r=arguments[1]);for(var o=D6t(i,0),C=0,a=0;C"u")return!1;if(g.type===KUe)return(0,Wqt.default)(r,g.name);if((typeof C!="string"||typeof n!="string")&&i!==nSe)return!1;switch(i){case nSe:return(0,Rqt.default)(C,n);case Jqt:return C.split(" ").indexOf(n)!==-1;case Lqt:return C===n||C.startsWith(String(n)+"-");case Uqt:return n===""?!1:C.slice(0,n.length)===n;case Qqt:return n===""?!1:C.slice(-n.length)===n;case jqt:return n===""?!1:C.indexOf(n)!==-1;default:throw new Error('Enzyme::Selector: Unknown attribute selector operator "'+String(i)+'"')}}function $qt(e,g,i){var n=g.name,I=g.parameters;if(n==="not")return I.every(function(c){return g_(c,e).length===0});if(n==="empty")return(0,ko.treeFilter)(e,function(c){return c!==e}).length===0;if(n==="first-child"){var r=(0,ko.findParentNode)(i,e),o=r.rendered,C=Zqt(o,1),a=C[0];return a===e}if(n==="last-child"){var A=(0,ko.findParentNode)(i,e),s=A.rendered;return s[s.length-1]===e}if(n==="focus"){if(typeof document>"u")throw new Error('Enzyme::Selector does not support the ":focus" pseudo-element without a global `document`.');var l=(0,kUe.default)();return document.activeElement&&l.nodeToHostNode(e)===document.activeElement}throw new TypeError('Enzyme::Selector does not support the "'+String(g.name)+'" pseudo-element or pseudo-class selectors.')}function qqt(e,g,i){if(e===null||typeof e=="string")return!1;switch(g.type){case zqt:return!0;case Dqt:return(0,ko.hasClassName)(e,g.name);case Eqt:return(0,NUe.nodeHasType)(e,g.name);case Mqt:return(0,ko.nodeHasId)(e,g.name);case KUe:return ISe(e,g);case Pqt:return ISe(e,g);case Oqt:case _qt:return $qt(e,g,i);default:throw new Error("Unknown token type: "+String(g.type))}}function Iee(e,g){return function(i){return e.body.every(function(n){return qqt(i,n,g)})}}function eeg(e){return e.some(function(g){return g.type!==YUe})}function EUe(e){if(typeof e=="string"){var g=FUe(e);if(eeg(g))throw new TypeError("This method does not support complex CSS selectors");return Iee(g[0])}var i=(0,kUe.default)(),n=i.isValidElementType?i.isValidElementType(e):typeof e=="function";if(n)return function(r){return i.matchesElementType(r,e)};if((typeof e>"u"?"undefined":HUe(e))==="object"){if(!Array.isArray(e)&&e!==null&&Object.keys(e).length>0){var I=(0,Bqt.default)(e).some(function(r){return typeof r>"u"});if(I)throw new TypeError("Enzyme::Props can’t have `undefined` values. Try using ‘findWhere()’ instead.");return function(r){return(0,ko.nodeMatchesObjectProps)(r,e)}}throw new TypeError("Enzyme::Selector does not support an array, null, or empty object as a selector")}throw new TypeError("Enzyme::Selector expects a string, object, or valid element type (Component Constructor)")}function teg(e,g,i){return e.reduce(function(n,I){var r=(0,ko.findParentNode)(i,I);if(!r)return n;var o=(0,ko.childrenOfNode)(r),C=o.indexOf(I),a=o[C+1];return a&&g(a)&&n.push(a),n},[])}function geg(e,g,i){return Dse(function(n,I){var r=(0,ko.findParentNode)(i,I);if(!r)return n;var o=(0,ko.childrenOfNode)(r),C=o.indexOf(I),a=o.slice(C+1);return n.concat(a.filter(g))},e)}function ieg(e,g){return Dse(function(i,n){return i.concat((0,ko.childrenOfNode)(n).filter(g))},e)}function neg(e,g){return Dse(function(i,n){return i.concat((0,ko.treeFilter)(n,g))},(0,Ese.default)(e.map(ko.childrenOfNode)))}function g_(e,g){if(typeof e!="string"){var i=(0,Tqt.default)(e);if(i.length>0)return(0,Ese.default)(i.map(function(s){return g_(s.tag,g)}))}if(typeof e=="function"||(typeof e>"u"?"undefined":HUe(e))==="object")return(0,ko.treeFilter)(g,EUe(e));var n=[];if(typeof e=="string")for(var I=FUe(e),r=0;r2&&arguments[2]!==void 0?arguments[2]:u.treeFilter;return Q.flatMap(function(ee){return j(ee.getNodeInternal(),U)})}function X(Q,U){return Q.wrap(Q.getNodesInternal().filter(U).filter(Boolean))}function N(Q){if(Q[B].length!==1)throw new Error("getRootNodeInternal(wrapper) can only be called when wrapper wraps one node");return Q[B]!==Q?Q[R][0]:Q[B][y]}function Y(Q,U){return(0,u.parentsOfNode)(U,N(Q))}function x(Q,U){U?Array.isArray(U)?((0,A.privateSet)(Q,y,U[0]),(0,A.privateSet)(Q,Z,U)):((0,A.privateSet)(Q,y,U),(0,A.privateSet)(Q,Z,[U])):((0,A.privateSet)(Q,y,null),(0,A.privateSet)(Q,Z,[])),(0,A.privateSet)(Q,"length",Q[Z].length)}var M=function(){function Q(U,j){var ee=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(p(this,Q),!globalThis.window&&!globalThis.document)throw new Error("It looks like you called `mount()` without a global document being loaded.");var Ie=(0,A.makeOptions)(ee);if(j)(0,A.privateSet)(this,v,j[v]),(0,A.privateSet)(this,B,j),x(this,U),(0,A.privateSet)(this,R,j[Z]),(0,A.privateSet)(this,S,j[S]),(0,A.privateSet)(this,T,[]);else{var fe=(0,l.default)(Ie);if(!fe.isValidElement(U))throw new TypeError("ReactWrapper can only wrap valid elements");var Ve=fe.createRenderer((0,I.default)({mode:"mount"},Ie));if((0,A.privateSet)(this,v,Ve),Ve.render(U,Ie.context),(0,A.privateSet)(this,B,this),x(this,this[v].getNode()),(0,A.privateSet)(this,S,Ie),(0,A.privateSet)(this,T,[]),(0,A.isCustomComponent)(Ie.wrappingComponent,fe)){if(typeof this[v].getWrappingComponentRenderer!="function")throw new TypeError("your adapter does not support `wrappingComponent`. Try upgrading it!");(0,A.privateSet)(this,w,new F(this,this[v].getWrappingComponentRenderer())),this[T].push(this[w])}}(0,A.privateSet)(this,G,U),(0,A.privateSet)(this,W,null)}return i(Q,[{key:"root",value:function(){function U(){return this[B]}return U}()},{key:"getNodeInternal",value:function(){function U(){if(this.length!==1)throw new Error("ReactWrapper::getNode() can only be called when wrapping one node");return this[Z][0]}return U}()},{key:"getNodesInternal",value:function(){function U(){return this[Z]}return U}()},{key:"getElement",value:function(){function U(){var j=this;return this.single("getElement",function(){return(0,l.default)(j[S]).nodeToElement(j[y])})}return U}()},{key:"getElements",value:function(){function U(){var j=this;return this[Z].map(function(ee){return(0,l.default)(j[S]).nodeToElement(ee)})}return U}()},{key:"getNode",value:function(){function U(){throw new Error("ReactWrapper::getNode() is no longer supported. Use ReactWrapper::instance() instead")}return U}()},{key:"getNodes",value:function(){function U(){throw new Error("ReactWrapper::getNodes() is no longer supported.")}return U}()},{key:"getDOMNode",value:function(){function U(){var j=(0,l.default)(this[S]);return this.single("getDOMNode",function(ee){return j.nodeToHostNode(ee,!0)})}return U}()},{key:"ref",value:function(){function U(j){if(this[B]!==this)throw new Error("ReactWrapper::ref(refname) can only be called on the root");return this.instance().refs[j]}return U}()},{key:"instance",value:function(){function U(){var j=this;return this.single("instance",function(){return j[y].instance})}return U}()},{key:"getWrappingComponent",value:function(){function U(){if(this[B]!==this)throw new Error("ReactWrapper::getWrappingComponent() can only be called on the root");if(!this[S].wrappingComponent)throw new Error("ReactWrapper::getWrappingComponent() can only be called on a wrapper that was originally passed a `wrappingComponent` option");return this[w]}return U}()},{key:"update",value:function(){function U(){var j=this,ee=this[B];return this!==ee?ee.update():(x(this,this[v].getNode()),this[T].forEach(function(Ie){if(Ie!==j[W]){Ie[W]=j;try{Ie.update()}finally{Ie[W]=null}}}),this)}return U}()},{key:"unmount",value:function(){function U(){var j=this;if(this[B]!==this)throw new Error("ReactWrapper::unmount() can only be called on the root");return this.single("unmount",function(){j[v].unmount(),j.update()}),this}return U}()},{key:"mount",value:function(){function U(){var j=this;if(this[B]!==this)throw new Error("ReactWrapper::mount() can only be called on the root");return this[v].render(this[G],this[S].context,function(){return j.update()}),this}return U}()},{key:"setProps",value:function(){function U(j){var ee=this,Ie=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;if(this[B]!==this)throw new Error("ReactWrapper::setProps() can only be called on the root");if(arguments.length>1&&typeof Ie!="function")throw new TypeError("ReactWrapper::setProps() expects a function as its second argument");var fe=(0,l.default)(this[S]);return this[G]=(0,A.cloneElement)(fe,this[G],j),this[v].render(this[G],null,function(){ee.update(),Ie&&Ie()}),this}return U}()},{key:"setState",value:function(){function U(j){var ee=this,Ie=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;if(this.instance()===null||this.getNodeInternal().nodeType!=="class")throw new Error("ReactWrapper::setState() can only be called on class components");if(arguments.length>1&&typeof Ie!="function")throw new TypeError("ReactWrapper::setState() expects a function as its second argument");return this.instance().setState(j,function(){if(ee.update(),Ie){var fe=(0,l.default)(ee[S]),Ve=ee.instance();fe.invokeSetStateCallback?fe.invokeSetStateCallback(Ve,Ie):Ie.call(Ve)}}),this}return U}()},{key:"setContext",value:function(){function U(j){var ee=this;if(this[B]!==this)throw new Error("ReactWrapper::setContext() can only be called on the root");if(!this[S].context)throw new Error("ReactWrapper::setContext() can only be called on a wrapper that was originally passed a context option");return this[v].render(this[G],j,function(){return ee.update()}),this}return U}()},{key:"contains",value:function(){function U(j){var ee=(0,l.default)(this[S]),Ie=Array.isArray(j)?function(fe){return(0,A.containsChildrenSubArray)(A.nodeEqual,fe,j.map(function(Ve){return ee.elementToNode(Ve)}))}:function(fe){return(0,A.nodeEqual)(ee.elementToNode(j),fe)};return V(this,Ie).length>0}return U}()},{key:"containsMatchingElement",value:function(){function U(j){var ee=(0,l.default)(this[S]).elementToNode(j),Ie=function(){function fe(Ve){return(0,A.nodeMatches)(ee,Ve,function(oe,pe){return oe<=pe})}return fe}();return V(this,Ie).length>0}return U}()},{key:"containsAllMatchingElements",value:function(){function U(j){var ee=this;if(!Array.isArray(j))throw new TypeError("nodes should be an Array");return j.every(function(Ie){return ee.containsMatchingElement(Ie)})}return U}()},{key:"containsAnyMatchingElements",value:function(){function U(j){var ee=this;return Array.isArray(j)&&j.some(function(Ie){return ee.containsMatchingElement(Ie)})}return U}()},{key:"equals",value:function(){function U(j){var ee=this;return this.single("equals",function(){return(0,A.nodeEqual)(ee.getNodeInternal(),j)})}return U}()},{key:"matchesElement",value:function(){function U(j){var ee=this;return this.single("matchesElement",function(){var Ie=(0,l.default)(ee[S]),fe=Ie.elementToNode(j);return(0,A.nodeMatches)(fe,ee.getNodeInternal(),function(Ve,oe){return Ve<=oe})})}return U}()},{key:"find",value:function(){function U(j){return this.wrap((0,d.reduceTreesBySelector)(j,this.getNodesInternal()))}return U}()},{key:"is",value:function(){function U(j){var ee=(0,d.buildPredicate)(j);return this.single("is",function(Ie){return ee(Ie)})}return U}()},{key:"isEmptyRender",value:function(){function U(){var j=this.getNodeInternal();return(0,A.renderedDive)(j)}return U}()},{key:"filterWhere",value:function(){function U(j){var ee=this;return X(this,function(Ie){return j(ee.wrap(Ie))})}return U}()},{key:"filter",value:function(){function U(j){var ee=(0,d.buildPredicate)(j);return X(this,ee)}return U}()},{key:"not",value:function(){function U(j){var ee=(0,d.buildPredicate)(j);return X(this,function(Ie){return!ee(Ie)})}return U}()},{key:"text",value:function(){function U(){var j=(0,l.default)(this[S]);return this.single("text",function(ee){return(0,u.getTextFromHostNodes)(ee,j)})}return U}()},{key:"html",value:function(){function U(){var j=(0,l.default)(this[S]);return this.single("html",function(ee){return(0,u.getHTMLFromHostNodes)(ee,j)})}return U}()},{key:"render",value:function(){function U(){var j=this.html();return(0,A.loadCheerioRoot)(j)}return U}()},{key:"simulate",value:function(){function U(j){var ee=this,Ie=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.single("simulate",function(fe){return ee[v].simulateEvent(fe,j,Ie),ee[B].update(),ee})}return U}()},{key:"simulateError",value:function(){function U(j){var ee=this;if(this[B]===this)throw new Error("ReactWrapper::simulateError() may not be called on the root");return this.single("simulateError",function(Ie){if(Ie.nodeType==="host")throw new Error("ReactWrapper::simulateError() can only be called on custom components");var fe=ee[v];if(typeof fe.simulateError!="function")throw new TypeError("your adapter does not support `simulateError`. Try upgrading it!");var Ve=N(ee),oe=[Ie].concat(Y(ee,Ie));return fe.simulateError(oe,Ve,j),ee[B].update(),ee})}return U}()},{key:"props",value:function(){function U(){return this.single("props",u.propsOfNode)}return U}()},{key:"state",value:function(){function U(j){var ee=this,Ie=this[B]===this?this[v].getNode():this.getNodeInternal();if(this.instance()===null||Ie.nodeType!=="class")throw new Error("ReactWrapper::state() can only be called on class components");var fe=this.single("state",function(){return ee.instance().state});if(typeof j<"u"){if(fe==null)throw new TypeError('ReactWrapper::state("'+String(j)+'") requires that `state` not be `null` or `undefined`');return fe[j]}return fe}return U}()},{key:"context",value:function(){function U(j){var ee=this;if(this[B]!==this)throw new Error("ReactWrapper::context() can only be called on the root");var Ie=this.single("context",function(){return ee.instance()});if(Ie===null)throw new Error("ReactWrapper::context() can only be called on components with instances");var fe=Ie.context;return typeof j<"u"?fe[j]:fe}return U}()},{key:"children",value:function(){function U(j){var ee=this.flatMap(function(Ie){return(0,u.childrenOfNode)(Ie.getNodeInternal())});return j?ee.filter(j):ee}return U}()},{key:"childAt",value:function(){function U(j){var ee=this;return this.single("childAt",function(){return ee.children().at(j)})}return U}()},{key:"parents",value:function(){function U(j){var ee=this;return this.single("parents",function(Ie){var fe=ee.wrap(Y(ee,Ie));return j?fe.filter(j):fe})}return U}()},{key:"parent",value:function(){function U(){return this.flatMap(function(j){return[j.parents().get(0)]})}return U}()},{key:"closest",value:function(){function U(j){if(this.is(j))return this;var ee=this.parents().filter(j);return ee.length>0?ee.first():this.findWhere(function(){return!1})}return U}()},{key:"prop",value:function(){function U(j){return this.props()[j]}return U}()},{key:"invoke",value:function(){function U(j){var ee=this;return this.single("invoke",function(){var Ie=ee.prop(j);if(typeof Ie!="function")throw new TypeError("ReactWrapper::invoke() requires the name of a prop whose value is a function");return function(){for(var fe=arguments.length,Ve=Array(fe),oe=0;oe"u"?"undefined":g(oe))+"“");return function(){var pe=oe.apply(void 0,arguments),ae=Ie.wrap(pe);return ee.wrap(ae,null,ee[S])}})}return U}()},{key:"key",value:function(){function U(){return this.single("key",function(j){return j.key===void 0?null:j.key})}return U}()},{key:"type",value:function(){function U(){return this.single("type",function(j){return(0,A.typeOfNode)(j)})}return U}()},{key:"name",value:function(){function U(){var j=(0,l.default)(this[S]);return this.single("name",function(ee){return j.displayNameOfNode?j.displayNameOfNode(ee):(0,A.displayNameOfNode)(ee)})}return U}()},{key:"hasClass",value:function(){function U(j){return typeof j=="string"&&j.indexOf(".")!==-1&&console.warn("It looks like you're calling `ReactWrapper::hasClass()` with a CSS selector. hasClass() expects a class name, not a CSS selector."),this.single("hasClass",function(ee){return(0,u.hasClassName)(ee,j)})}return U}()},{key:"forEach",value:function(){function U(j){var ee=this;return this.getNodesInternal().forEach(function(Ie,fe){return j.call(ee,ee.wrap(Ie),fe)}),this}return U}()},{key:"map",value:function(){function U(j){var ee=this;return this.getNodesInternal().map(function(Ie,fe){return j.call(ee,ee.wrap(Ie),fe)})}return U}()},{key:"reduce",value:function(){function U(j){var ee=this,Ie=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;return arguments.length>1?this.getNodesInternal().reduce(function(fe,Ve,oe){return j.call(ee,fe,ee.wrap(Ve),oe)},Ie):this.getNodesInternal().reduce(function(fe,Ve,oe){return j.call(ee,oe===1?ee.wrap(fe):fe,ee.wrap(Ve),oe)})}return U}()},{key:"reduceRight",value:function(){function U(j){var ee=this,Ie=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;return arguments.length>1?this.getNodesInternal().reduceRight(function(fe,Ve,oe){return j.call(ee,fe,ee.wrap(Ve),oe)},Ie):this.getNodesInternal().reduceRight(function(fe,Ve,oe){return j.call(ee,oe===1?ee.wrap(fe):fe,ee.wrap(Ve),oe)})}return U}()},{key:"slice",value:function(){function U(j,ee){return this.wrap(this.getNodesInternal().slice(j,ee))}return U}()},{key:"some",value:function(){function U(j){if(this[B]===this)throw new Error("ReactWrapper::some() can not be called on the root");var ee=(0,d.buildPredicate)(j);return this.getNodesInternal().some(ee)}return U}()},{key:"someWhere",value:function(){function U(j){var ee=this;return this.getNodesInternal().some(function(Ie,fe){return j.call(ee,ee.wrap(Ie),fe)})}return U}()},{key:"every",value:function(){function U(j){var ee=(0,d.buildPredicate)(j);return this.getNodesInternal().every(ee)}return U}()},{key:"everyWhere",value:function(){function U(j){var ee=this;return this.getNodesInternal().every(function(Ie,fe){return j.call(ee,ee.wrap(Ie),fe)})}return U}()},{key:"flatMap",value:function(){function U(j){var ee=this,Ie=this.getNodesInternal().map(function(Ve,oe){return j.call(ee,ee.wrap(Ve),oe)}),fe=(0,o.default)(Ie,1);return this.wrap(fe.filter(Boolean))}return U}()},{key:"findWhere",value:function(){function U(j){var ee=this;return V(this,function(Ie){var fe=ee.wrap(Ie);return fe.length>0&&j(fe)})}return U}()},{key:"get",value:function(){function U(j){return this.getElements()[j]}return U}()},{key:"at",value:function(){function U(j){var ee=this.getNodesInternal();return j0&&arguments[0]!==void 0?arguments[0]:null;return arguments.length>0?this.find(j).exists():this.length>0}return U}()},{key:"single",value:function(){function U(j,ee){var Ie=typeof j=="string"?j:"unknown",fe=typeof ee=="function"?ee:j;if(this.length!==1)throw new Error("Method “"+Ie+"” is meant to be run on 1 node. "+String(this.length)+" found instead.");return fe.call(this,this.getNodeInternal())}return U}()},{key:"wrap",value:function(){function U(j){var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this[B];if(j instanceof Q)return j;for(var Ie=arguments.length,fe=Array(Ie>2?Ie-2:0),Ve=2;Ve0&&arguments[0]!==void 0?arguments[0]:{};return(0,c.debugNodes)(this.getNodesInternal(),j)}return U}()},{key:"tap",value:function(){function U(j){return j(this),this}return U}()},{key:"detach",value:function(){function U(){if(this[B]!==this)throw new Error("ReactWrapper::detach() can only be called on the root");if(!this[S].attachTo)throw new Error("ReactWrapper::detach() can only be called on when the `attachTo` option was passed into `mount()`.");this[v].unmount()}return U}()},{key:"hostNodes",value:function(){function U(){return this.filterWhere(function(j){return typeof j.type()=="string"})}return U}()}]),Q}(),F=function(Q){b(U,Q);function U(j,ee){p(this,U);var Ie=m(this,(U.__proto__||Object.getPrototypeOf(U)).call(this,ee.getNode(),j));return(0,A.privateSet)(Ie,B,Ie),(0,A.privateSet)(Ie,v,ee),Ie[T].push(j),Ie}return i(U,[{key:"getWrappingComponent",value:function(){function j(){throw new TypeError("ReactWrapper::getWrappingComponent() can only be called on the root")}return j}()}]),U}(M);A.ITERATOR_SYMBOL&&Object.defineProperty(M.prototype,A.ITERATOR_SYMBOL,{configurable:!0,value:function(){function Q(){var U,j=this[Z][A.ITERATOR_SYMBOL](),ee=(0,l.default)(this[S]);return U={},f(U,A.ITERATOR_SYMBOL,function(){return this}),f(U,"next",function(){function Ie(){var fe=j.next();return fe.done?{done:!0}:{done:!1,value:ee.nodeToElement(fe.value)}}return Ie}()),U}return Q}()});function $(Q,U){Object.defineProperty(M.prototype,Q,{get:function(){function j(){throw new Error(` + Attempted to access ReactWrapper::`+String(Q)+`, which was previously a private property on + Enzyme ReactWrapper instances, but is no longer and should not be relied upon. + `+String(U)+` + `)}return j}(),enumerable:!1,configurable:!1})}$("node","Consider using the getElement() method instead."),$("nodes","Consider using the getElements() method instead."),$("renderer",""),$("options",""),$("complexSelector",""),e.default=M})(_ae);var Mse={};(function(e){Object.defineProperty(e,"__esModule",{value:!0});var g=function(){function He(Ce,Ze,Te){Ce===null&&(Ce=Function.prototype);var E=Object.getOwnPropertyDescriptor(Ce,Ze);if(E===void 0){var H=Object.getPrototypeOf(Ce);return H===null?void 0:He(H,Ze,Te)}else{if("value"in E)return E.value;var K=E.get;return K===void 0?void 0:K.call(Te)}}return He}(),i=function(){function He(Ce,Ze){for(var Te=0;Te2&&arguments[2]!==void 0?arguments[2]:f.treeFilter;return He.flatMap(function(Te){return Ze(Te.getNodeInternal(),Ce)})}function Q(He,Ce){return He.wrap(He.getNodesInternal().filter(Ce).filter(Boolean))}function U(He){var Ce=He.lifecycleExperimental,Ze=He.disableLifecycleMethods,Te=He.enableComponentDidUpdateOnSetState,E=He.supportPrevContextArgumentOfComponentDidUpdate,H=He.lifecycles;if(typeof Ce<"u"&&typeof Ce!="boolean")throw new Error("lifecycleExperimental must be either true or false if provided");if(typeof Ze<"u"&&typeof Ze!="boolean")throw new Error("disableLifecycleMethods must be either true or false if provided");if(Ce!=null&&Ze!=null&&Ce===Ze)throw new Error("lifecycleExperimental and disableLifecycleMethods cannot be set to the same value");if(typeof Te<"u"&&H.componentDidUpdate&&H.componentDidUpdate.onSetState!==Te)throw new TypeError("the legacy enableComponentDidUpdateOnSetState option should be matched by `lifecycles: { componentDidUpdate: { onSetState: true } }`, for compatibility");if(typeof E<"u"&&H.componentDidUpdate&&H.componentDidUpdate.prevContext!==E)throw new TypeError("the legacy supportPrevContextArgumentOfComponentDidUpdate option should be matched by `lifecycles: { componentDidUpdate: { prevContext: true } }`, for compatibility")}function j(He){var Ce=He.options,Ze=Ce.lifecycles,Te=Ze===void 0?{}:Ze,E=Ce.enableComponentDidUpdateOnSetState,H=Ce.supportPrevContextArgumentOfComponentDidUpdate,K=typeof E<"u",te=typeof H<"u",me=K||te?(0,r.default)({},K&&{onSetState:!!E},te&&{prevContext:!!H}):null,Re=Te.getDerivedStateFromProps,Ee=Re?{hasShouldComponentUpdateBug:!!Re.hasShouldComponentUpdateBug}:!1;return(0,r.default)({},Te,{setState:(0,r.default)({},Te.setState),getChildContext:(0,r.default)({calledByRenderer:!0},Te.getChildContext)},me&&{componentDidUpdate:me},{getDerivedStateFromProps:Ee})}function ee(He){return He.nodeType==="host"?He:He.rendered}function Ie(He){if(He[T].length!==1)throw new Error("getRootNodeInternal(wrapper) can only be called when wrapper wraps one node");return He[T]!==He?He[X][0]:He[T][B]}function fe(He,Ce){return(0,f.parentsOfNode)(Ce,Ie(He))}function Ve(He,Ce){Array.isArray(Ce)?((0,c.privateSet)(He,B,Ce[0]),(0,c.privateSet)(He,S,Ce)):((0,c.privateSet)(He,B,Ce),(0,c.privateSet)(He,S,[Ce])),(0,c.privateSet)(He,"length",He[S].length)}function oe(He,Ce,Ze,Te){return!(0,l.default)(He,Ce)||!(0,l.default)(Ze,Te)}function pe(He){return He&&He.isPureReactComponent}function ae(He,Ce,Ze){var Te=He.instance,E=He.type,H=(0,c.displayNameOfNode)(He);if(n(E.childContextTypes)!=="object")return console.warn(String(H)+".getChildContext(): childContextTypes must be defined in order to use getChildContext()."),{};var K=Te.getChildContext();return Object.keys(K).forEach(function(te){if(!(te in E.childContextTypes))throw new Error(String(H)+'.getChildContext(): key "'+String(te)+'" is not defined in childContextTypes.')}),typeof Ze.checkPropTypes=="function"&&Ze.checkPropTypes(E.childContextTypes,K,"child context",Ce),K}function ie(He,Ce){return!(0,c.isCustomComponentElement)(He,Ce)||!He.type.prototype||typeof He.type.prototype.getChildContext!="function"?null:(0,c.spyMethod)(He.type.prototype,"getChildContext")}function ye(He,Ce,Ze,Te,E){var H=Ce[R];if(He.options.legacyContextMode==="parent")if(E)(0,c.privateSet)(Ce,N,E.getLastReturnValue()),E.restore();else if(typeof Ze.getChildContext=="function"){var K=[Ce[B]].concat(fe(Ce,Ce[B])),te=ae(Te,K,H);(0,c.privateSet)(Ce,N,te)}else(0,c.privateSet)(Ce,N,null)}function ue(He,Ce){var Ze=He.type.getDerivedStateFromProps;if(typeof Ze=="function")var Te=He.instance,E=(0,c.spyMethod)(Te,"shouldComponentUpdate",function(K){return function(){function te(){Te.state=Ce;for(var me=arguments.length,Re=Array(me),Ee=0;Ee1&&arguments[1]!==void 0?arguments[1]:{},Ze=(0,r.default)({},He[W],Ce,{context:Ce.context||(0,r.default)({},He[W].context,He[T][N])});return(0,c.privateSet)(Ze,F,He[T][F]),Ze}var Pe=function(){function He(Ce,Ze){var Te=this,E=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};v(this,He),U(E);var H=ke(Ce,Ze,E,this),K=(0,d.default)(H),te=j(K);if(Ze)(0,c.privateSet)(this,T,Ze),(0,c.privateSet)(this,w,null),(0,c.privateSet)(this,R,Ze[R]),Ve(this,Ce),(0,c.privateSet)(this,W,Ze[W]),(0,c.privateSet)(this,X,Ze[S]),(0,c.privateSet)(this,F,null);else{if(!K.isValidElement(Ce))throw new TypeError("ShallowWrapper can only wrap valid elements");var me=te.getChildContext.calledByRenderer?ie(Ce,K):null;(0,c.privateSet)(this,T,this),(0,c.privateSet)(this,w,Ce);var Re=K.createRenderer((0,r.default)({mode:"shallow"},H));(0,c.privateSet)(this,R,Re);var Ee=new Map(H[F]||[]);this[R].render(Ce,H.context,{providerValues:Ee});var nt=this[R].getNode();Ve(this,ee(nt)),(0,c.privateSet)(this,W,H),(0,c.privateSet)(this,F,Ee);var wt=nt.instance;wt&&!H.disableLifecycleMethods&&(te.componentDidUpdate.onSetState&&!wt[V]&&((0,c.privateSet)(wt,V,wt.setState),wt.setState=function(kt){var yt=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;return Te.setState.apply(Te,Z(yt==null?[kt]:[kt,yt]))}),typeof wt.componentDidMount=="function"&&this[R].batchedUpdates(function(){wt.componentDidMount()}),ye(K,this,wt,nt,me))}}return i(He,[{key:"root",value:function(){function Ce(){return this[T]}return Ce}()},{key:"getNodeInternal",value:function(){function Ce(){if(this.length!==1)throw new Error("ShallowWrapper::getNode() can only be called when wrapping one node");return this[T]===this&&this.update(),this[B]}return Ce}()},{key:"getNodesInternal",value:function(){function Ce(){return this[T]===this&&this.length===1&&this.update(),this[S]}return Ce}()},{key:"getElement",value:function(){function Ce(){var Ze=this;return this.single("getElement",function(Te){return(0,d.default)(Ze[W]).nodeToElement(Te)})}return Ce}()},{key:"getElements",value:function(){function Ce(){var Ze=this;return this.getNodesInternal().map(function(Te){return(0,d.default)(Ze[W]).nodeToElement(Te)})}return Ce}()},{key:"getNode",value:function(){function Ce(){throw new Error("ShallowWrapper::getNode() is no longer supported. Use ShallowWrapper::getElement() instead")}return Ce}()},{key:"getNodes",value:function(){function Ce(){throw new Error("ShallowWrapper::getNodes() is no longer supported. Use ShallowWrapper::getElements() instead")}return Ce}()},{key:"instance",value:function(){function Ce(){if(this[T]!==this)throw new Error("ShallowWrapper::instance() can only be called on the root");return this[R].getNode().instance}return Ce}()},{key:"getWrappingComponent",value:function(){function Ce(){if(this[T]!==this)throw new Error("ShallowWrapper::getWrappingComponent() can only be called on the root");if(!this[W].wrappingComponent)throw new Error("ShallowWrapper::getWrappingComponent() can only be called on a wrapper that was originally passed a `wrappingComponent` option");return this[Y]}return Ce}()},{key:"update",value:function(){function Ce(){if(this[T]!==this)throw new Error("ShallowWrapper::update() can only be called on the root");if(this.length!==1)throw new Error("ShallowWrapper::update() can only be called when wrapping one node");return Ve(this,ee(this[R].getNode())),this}return Ce}()},{key:"unmount",value:function(){function Ce(){return this[R].unmount(),this[T][Y]&&this[T][Y].unmount(),this}return Ce}()},{key:"rerender",value:function(){function Ce(Ze,Te){var E=this,H=(0,d.default)(this[W]);return this.single("rerender",function(){(0,c.withSetStateAllowed)(function(){var K=E[R].getNode(),te=K.instance||{},me=K.type||{},Re=te.state,Ee=te.props||E[w].props,nt=te.context||E[W].context,wt=Te||nt;Te&&(E[W]=(0,r.default)({},E[W],{context:wt})),E[R].batchedUpdates(function(){var kt=j(H),yt=!0,Pt=void 0,ge=void 0;if(!E[W].disableLifecycleMethods&&te){if(typeof te.shouldComponentUpdate=="function"){var z=kt.getDerivedStateFromProps;z&&z.hasShouldComponentUpdateBug&&ue(K,Re),Pt=(0,c.spyMethod)(te,"shouldComponentUpdate")}kt.getChildContext.calledByRenderer&&typeof te.getChildContext=="function"&&(ge=(0,c.spyMethod)(te,"getChildContext"))}if(!Pt&&pe(te)&&(yt=oe(Ee,Ze,Re,te.state)),Ze&&(E[w]=(0,c.cloneElement)(H,E[w],Ze)),E[R].render(E[w],wt,{providerValues:E[F]}),Pt&&(yt=Pt.getLastReturnValue(),Pt.restore()),yt&&!E[W].disableLifecycleMethods&&te)if(ye(H,E,te,K,ge),kt.getSnapshotBeforeUpdate){var J=void 0;typeof te.getSnapshotBeforeUpdate=="function"&&(J=te.getSnapshotBeforeUpdate(Ee,Re)),kt.componentDidUpdate&&typeof te.componentDidUpdate=="function"&&(!Re||(0,l.default)(Re,E.instance().state)||typeof me.getDerivedStateFromProps=="function")&&te.componentDidUpdate(Ee,Re,J)}else kt.componentDidUpdate&&typeof te.componentDidUpdate=="function"&&(kt.componentDidUpdate.prevContext?te.componentDidUpdate(Ee,Re,nt):(!Re||(0,l.default)(E.instance().state,Re))&&te.componentDidUpdate(Ee,Re));else(0,l.default)(Ze,te.props)||(te.props=(Object.freeze||Object)((0,r.default)({},te.props,Ze)));E.update()})})}),this}return Ce}()},{key:"setProps",value:function(){function Ce(Ze){var Te=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;if(this[T]!==this)throw new Error("ShallowWrapper::setProps() can only be called on the root");if(arguments.length>1&&typeof Te!="function")throw new TypeError("ReactWrapper::setProps() expects a function as its second argument");return this.rerender(Ze),Te&&Te(),this}return Ce}()},{key:"setState",value:function(){function Ce(Ze){var Te=this,E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;if(this[T]!==this)throw new Error("ShallowWrapper::setState() can only be called on the root");if(this.instance()===null||this[R].getNode().nodeType!=="class")throw new Error("ShallowWrapper::setState() can only be called on class components");if(arguments.length>1&&typeof E!="function")throw new TypeError("ReactWrapper::setState() expects a function as its second argument");return this.single("setState",function(){(0,c.withSetStateAllowed)(function(){var H=(0,d.default)(Te[W]),K=j(H),te=Te[R].getNode(),me=te.instance,Re=me.props,Ee=me.state,nt=me.context,wt=typeof Ze=="function"?Ze.call(me,Ee,Re):Ze,kt=!K.setState.skipsComponentDidUpdateOnNullish||wt!=null,yt=void 0,Pt=void 0,ge=!0;if(!Te[W].disableLifecycleMethods&&me){if(K.componentDidUpdate&&K.componentDidUpdate.onSetState&&typeof me.shouldComponentUpdate=="function"){var z=K.getDerivedStateFromProps;z&&z.hasShouldComponentUpdateBug&&ue(te,Ze),yt=(0,c.spyMethod)(me,"shouldComponentUpdate")}K.getChildContext.calledByRenderer&&typeof me.getChildContext=="function"&&(Pt=(0,c.spyMethod)(me,"getChildContext"))}if(!yt&&pe(me)&&(ge=oe(Re,me.props,Ee,(0,r.default)({},Ee,wt))),me[V]?me[V](wt):me.setState(wt),yt&&(ge=yt.getLastReturnValue(),yt.restore()),kt&&ge&&!Te[W].disableLifecycleMethods&&(ye(H,Te,me,te,Pt),K.componentDidUpdate&&K.componentDidUpdate.onSetState))if(K.getSnapshotBeforeUpdate&&typeof me.getSnapshotBeforeUpdate=="function"){var J=me.getSnapshotBeforeUpdate(Re,Ee);typeof me.componentDidUpdate=="function"&&me.componentDidUpdate(Re,Ee,J)}else typeof me.componentDidUpdate=="function"&&(K.componentDidUpdate.prevContext?me.componentDidUpdate(Re,Ee,nt):me.componentDidUpdate(Re,Ee));Te.update(),E&&(H.invokeSetStateCallback?H.invokeSetStateCallback(me,E):E.call(me))})}),this}return Ce}()},{key:"setContext",value:function(){function Ce(Ze){if(this[T]!==this)throw new Error("ShallowWrapper::setContext() can only be called on the root");if(!this[W].context)throw new Error("ShallowWrapper::setContext() can only be called on a wrapper that was originally passed a context option");return this.rerender(null,Ze)}return Ce}()},{key:"contains",value:function(){function Ce(Ze){var Te=(0,d.default)(this[W]);if(!(0,c.isReactElementAlike)(Ze,Te))throw new Error("ShallowWrapper::contains() can only be called with a ReactElement (or an array of them), a string, or a number as an argument.");var E=Array.isArray(Ze)?function(H){return(0,c.containsChildrenSubArray)(c.nodeEqual,H,Ze.map(function(K){return Te.elementToNode(K)}))}:function(H){return(0,c.nodeEqual)(Te.elementToNode(Ze),H)};return $(this,E).length>0}return Ce}()},{key:"containsMatchingElement",value:function(){function Ce(Ze){var Te=(0,d.default)(this[W]),E=Te.elementToNode(Ze),H=function(){function K(te){return(0,c.nodeMatches)(E,te,function(me,Re){return me<=Re})}return K}();return $(this,H).length>0}return Ce}()},{key:"containsAllMatchingElements",value:function(){function Ce(Ze){var Te=this;if(!Array.isArray(Ze))throw new TypeError("nodes should be an Array");return Ze.every(function(E){return Te.containsMatchingElement(E)})}return Ce}()},{key:"containsAnyMatchingElements",value:function(){function Ce(Ze){var Te=this;return Array.isArray(Ze)&&Ze.some(function(E){return Te.containsMatchingElement(E)})}return Ce}()},{key:"equals",value:function(){function Ce(Ze){var Te=this;return this.single("equals",function(){return(0,c.nodeEqual)(Te.getNodeInternal(),Ze)})}return Ce}()},{key:"matchesElement",value:function(){function Ce(Ze){var Te=this;return this.single("matchesElement",function(){var E=(0,d.default)(Te[W]),H=E.elementToNode(Ze);return(0,c.nodeMatches)(H,Te.getNodeInternal(),function(K,te){return K<=te})})}return Ce}()},{key:"find",value:function(){function Ce(Ze){return this.wrap((0,m.reduceTreesBySelector)(Ze,this.getNodesInternal()))}return Ce}()},{key:"is",value:function(){function Ce(Ze){var Te=(0,m.buildPredicate)(Ze);return this.single("is",function(E){return Te(E)})}return Ce}()},{key:"isEmptyRender",value:function(){function Ce(){var Ze=this.getNodesInternal();return Ze.every(function(Te){return(0,c.isEmptyValue)(Te)})}return Ce}()},{key:"filterWhere",value:function(){function Ce(Ze){var Te=this;return Q(this,function(E){return Ze(Te.wrap(E))})}return Ce}()},{key:"filter",value:function(){function Ce(Ze){var Te=(0,m.buildPredicate)(Ze);return Q(this,Te)}return Ce}()},{key:"not",value:function(){function Ce(Ze){var Te=(0,m.buildPredicate)(Ze);return Q(this,function(E){return!Te(E)})}return Ce}()},{key:"text",value:function(){function Ce(){return this.single("text",f.getTextFromNode)}return Ce}()},{key:"html",value:function(){function Ce(){var Ze=this;return this.single("html",function(Te){if(Ze.type()===null)return null;var E=(0,d.default)(Ze[W]),H=E.createRenderer((0,r.default)({},Ze[W],{mode:"string"}));return H.render(E.nodeToElement(Te))})}return Ce}()},{key:"render",value:function(){function Ce(){var Ze=this.html();return(0,c.loadCheerioRoot)(Ze)}return Ce}()},{key:"simulate",value:function(){function Ce(Ze){for(var Te=this,E=arguments.length,H=Array(E>1?E-1:0),K=1;K0?Te.first():this.findWhere(function(){return!1})}return Ce}()},{key:"shallow",value:function(){function Ce(){var Ze=this,Te=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return this.single("shallow",function(E){var H=_e(Ze,Te);return Ze.wrap((0,d.default)(Ze[W]).nodeToElement(E),null,H)})}return Ce}()},{key:"prop",value:function(){function Ce(Ze){return this.props()[Ze]}return Ce}()},{key:"invoke",value:function(){function Ce(Ze){var Te=this;return this.single("invoke",function(){var E=Te.prop(Ze);if(typeof E!="function")throw new TypeError("ShallowWrapper::invoke() requires the name of a prop whose value is a function");return function(){var H=E.apply(void 0,arguments);return Te[T].update(),H}})}return Ce}()},{key:"renderProp",value:function(){function Ce(Ze){var Te=this,E=(0,d.default)(this[W]);if(typeof E.wrap!="function")throw new RangeError("your adapter does not support `wrap`. Try upgrading it!");return this.single("renderProp",function(H){if(H.nodeType==="host")throw new TypeError("ShallowWrapper::renderProp() can only be called on custom components");if(typeof Ze!="string")throw new TypeError("ShallowWrapper::renderProp(): `propName` must be a string");var K=Te.props();if(!(0,A.default)(K,Ze))throw new Error("ShallowWrapper::renderProp(): no prop called “"+String(Ze)+"“ found");var te=K[Ze];if(typeof te!="function")throw new TypeError("ShallowWrapper::renderProp(): expected prop “"+String(Ze)+"“ to contain a function, but it holds “"+(typeof te>"u"?"undefined":n(te))+"“");return function(){var me=te.apply(void 0,arguments),Re=E.wrap(me);return Te.wrap(Re,null,Te[W])}})}return Ce}()},{key:"key",value:function(){function Ce(){return this.single("key",function(Ze){return Ze.key===void 0?null:Ze.key})}return Ce}()},{key:"type",value:function(){function Ce(){return this.single("type",function(Ze){return(0,c.typeOfNode)(Ze)})}return Ce}()},{key:"name",value:function(){function Ce(){var Ze=(0,d.default)(this[W]);return this.single("name",function(Te){return Ze.displayNameOfNode?Ze.displayNameOfNode(Te):(0,c.displayNameOfNode)(Te)})}return Ce}()},{key:"hasClass",value:function(){function Ce(Ze){return typeof Ze=="string"&&Ze.indexOf(".")!==-1&&console.warn("It looks like you're calling `ShallowWrapper::hasClass()` with a CSS selector. hasClass() expects a class name, not a CSS selector."),this.single("hasClass",function(Te){return(0,f.hasClassName)(Te,Ze)})}return Ce}()},{key:"forEach",value:function(){function Ce(Ze){var Te=this;return this.getNodesInternal().forEach(function(E,H){return Ze.call(Te,Te.wrap(E),H)}),this}return Ce}()},{key:"map",value:function(){function Ce(Ze){var Te=this;return this.getNodesInternal().map(function(E,H){return Ze.call(Te,Te.wrap(E),H)})}return Ce}()},{key:"reduce",value:function(){function Ce(Ze){var Te=this,E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;return arguments.length>1?this.getNodesInternal().reduce(function(H,K,te){return Ze.call(Te,H,Te.wrap(K),te)},E):this.getNodesInternal().reduce(function(H,K,te){return Ze.call(Te,te===1?Te.wrap(H):H,Te.wrap(K),te)})}return Ce}()},{key:"reduceRight",value:function(){function Ce(Ze){var Te=this,E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;return arguments.length>1?this.getNodesInternal().reduceRight(function(H,K,te){return Ze.call(Te,H,Te.wrap(K),te)},E):this.getNodesInternal().reduceRight(function(H,K,te){return Ze.call(Te,te===1?Te.wrap(H):H,Te.wrap(K),te)})}return Ce}()},{key:"slice",value:function(){function Ce(Ze,Te){return this.wrap(this.getNodesInternal().slice(Ze,Te))}return Ce}()},{key:"some",value:function(){function Ce(Ze){if(this[T]===this)throw new Error("ShallowWrapper::some() can not be called on the root");var Te=(0,m.buildPredicate)(Ze);return this.getNodesInternal().some(Te)}return Ce}()},{key:"someWhere",value:function(){function Ce(Ze){var Te=this;return this.getNodesInternal().some(function(E,H){return Ze.call(Te,Te.wrap(E),H)})}return Ce}()},{key:"every",value:function(){function Ce(Ze){var Te=(0,m.buildPredicate)(Ze);return this.getNodesInternal().every(Te)}return Ce}()},{key:"everyWhere",value:function(){function Ce(Ze){var Te=this;return this.getNodesInternal().every(function(E,H){return Ze.call(Te,Te.wrap(E),H)})}return Ce}()},{key:"flatMap",value:function(){function Ce(Ze){var Te=this,E=this.getNodesInternal().map(function(K,te){return Ze.call(Te,Te.wrap(K),te)}),H=(0,C.default)(E,1);return this.wrap(H.filter(Boolean))}return Ce}()},{key:"findWhere",value:function(){function Ce(Ze){var Te=this;return $(this,function(E){var H=Te.wrap(E);return H.length>0&&Ze(H)})}return Ce}()},{key:"get",value:function(){function Ce(Ze){return this.getElements()[Ze]}return Ce}()},{key:"at",value:function(){function Ce(Ze){var Te=this.getNodesInternal();return Ze0&&arguments[0]!==void 0?arguments[0]:null;return arguments.length>0?this.find(Ze).exists():this.length>0}return Ce}()},{key:"single",value:function(){function Ce(Ze,Te){var E=typeof Ze=="string"?Ze:"unknown",H=typeof Te=="function"?Te:Ze;if(this.length!==1)throw new Error("Method “"+E+"” is meant to be run on 1 node. "+String(this.length)+" found instead.");return H.call(this,this.getNodeInternal())}return Ce}()},{key:"wrap",value:function(){function Ce(Ze){var Te=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this[T];if(Ze instanceof He)return Ze;for(var E=arguments.length,H=Array(E>2?E-2:0),K=2;K0&&arguments[0]!==void 0?arguments[0]:{};return(0,h.debugNodes)(this.getNodesInternal(),Ze)}return Ce}()},{key:"tap",value:function(){function Ce(Ze){return Ze(this),this}return Ce}()},{key:"dive",value:function(){function Ce(){var Ze=this,Te=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},E=(0,d.default)(this[W]),H="dive";return this.single(H,function(K){if(K&&K.nodeType==="host")throw new TypeError("ShallowWrapper::"+H+"() can not be called on Host Components");var te=(0,d.default)(Ze[W]).nodeToElement(K);if(!(0,c.isCustomComponentElement)(te,E))throw new TypeError("ShallowWrapper::"+H+"() can only be called on components");var me=_e(Ze,Te);return Ze.wrap(te,null,me)})}return Ce}()},{key:"hostNodes",value:function(){function Ce(){return this.filterWhere(function(Ze){return typeof Ze.type()=="string"})}return Ce}()}]),He}();function it(He){var Ce=(0,d.default)(He[W]),Ze=He[x],Te=Ze[R],E=Te.getNode(),H=Be(He,Ce),K=H.legacyContext,te=H.providerValues,me=Ze[F];if(Ze.setContext((0,r.default)({},He[x][W].context,K)),Ze[F]=new Map([].concat(Z(me),Z(te))),typeof Ce.isContextConsumer=="function"&&Ce.isContextConsumer(E.type)){var Re=E.type,Ee=Ce.getProviderFromConsumer(Re),nt=te.get(Ee),wt=me.get(Ee);nt!==wt&&Ze.rerender()}}var lt=function(He){y(Ce,He);function Ce(Ze,Te,E){v(this,Ce);var H=p(this,(Ce.__proto__||Object.getPrototypeOf(Ce)).call(this,Ze));return(0,c.privateSet)(H,x,Te),(0,c.privateSet)(H,M,E),H}return i(Ce,[{key:"rerender",value:function(){function Ze(){for(var Te,E=arguments.length,H=Array(E),K=0;K1&&arguments[1]!==void 0?arguments[1]:{},s=(0,I.default)(A),l=s.createRenderer((0,i.default)({mode:"string"},A)),c=l.render(a,A.context);return(0,r.loadCheerioRoot)(c)}})(zUe);var reg=_ae,oeg=J1(reg),Ceg=Mse,aeg=J1(Ceg),seg=iUe,Aeg=J1(seg),leg=DUe,ceg=J1(leg),ueg=MUe,deg=J1(ueg),heg=zUe,feg=J1(heg),meg=tZ;function J1(e){return e&&e.__esModule?e:{default:e}}var peg={render:feg.default,shallow:deg.default,mount:ceg.default,ShallowWrapper:aeg.default,ReactWrapper:oeg.default,configure:meg.merge,EnzymeAdapter:Aeg.default};const zse=100,beg=(e,g,i,n)=>{for(const{viewId:I,trackId:r,track:o}of e.instance().iterateOverTracks())I===g&&r===i&&(o.options={...o.options,...n});e.setState(e.instance().state)},yeg=e=>{for(const g of e.iterateOverTracks())if(p_e(e,g.viewId,g.trackId).activeTransitions>0)return!0;return!1},PUe=(e,g)=>{yeg(e)?setTimeout(()=>{PUe(e,g)},zse):g()},Pse=e=>{JX>0?setTimeout(()=>Pse(e),zse):e()},Zeg=e=>{for(const g of e.iterateOverTracks()){let i=Pae(e,g.viewId,g.trackId);if(!(!g.track.server&&!g.track.tilesetUid&&!(g.track.data&&g.track.data.type==="divided")))if(g.track.data&&g.track.data.type==="divided"||g.track.server&&g.track.tilesetUid){if(i.originalTrack&&(i=i.originalTrack),!(i.tilesetInfo||i.chromInfo)||i.fetching&&i.fetching.size)return!0}else throw Error('"server" and "tilesetUid" belong together')}return!1},IE=(e,g)=>{Zeg(e)?setTimeout(()=>{IE(e,g)},zse):g()},_Ue=(e,g,i,n,I={})=>{const{style:r="width:800px; background-color: lightgreen;",bounded:o=!1,extendedDelay:C=!1}=I;g&&(g.unmount(),g.detach()),e&&globalThis.document.body.removeChild(e);const a=globalThis.document.createElement("div");globalThis.document.body.appendChild(a),a.setAttribute("style",r),a.setAttribute("id","simple-hg-component");const A=peg.mount(k.createElement(CS,{options:{bounded:o},viewConfig:i}),{attachTo:a});return A.update(),Pse(()=>{if(C){const s=()=>setTimeout(()=>{n()},1e3);IE(A.instance(),s)}else IE(A.instance(),n)}),[a,A]},Geg=e=>{e&&(_I.unmountComponentAtNode(e),document.body.removeChild(e))};async function veg(e,g,i,n){let I;return await new Promise(r=>{I=_Ue(e,g,i,r,n)}),I}var pw=0,TV=0,wR=0,OUe=1e3,rE,HV,oE=0,Mb=0,i_=0,i9=typeof performance=="object"&&performance.now?performance:Date,JUe=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function _se(){return Mb||(JUe(Beg),Mb=i9.now()+i_)}function Beg(){Mb=0}function CE(){this._call=this._time=this._next=null}CE.prototype=LUe.prototype={constructor:CE,restart:function(e,g,i){if(typeof e!="function")throw new TypeError("callback is not a function");i=(i==null?_se():+i)+(g==null?0:+g),!this._next&&HV!==this&&(HV?HV._next=this:rE=this,HV=this),this._call=e,this._time=i,ree()},stop:function(){this._call&&(this._call=null,this._time=1/0,ree())}};function LUe(e,g,i){var n=new CE;return n.restart(e,g,i),n}function weg(){_se(),++pw;for(var e=rE,g;e;)(g=Mb-e._time)>=0&&e._call.call(void 0,g),e=e._next;--pw}function rSe(){Mb=(oE=i9.now())+i_,pw=TV=0;try{weg()}finally{pw=0,Reg(),Mb=0}}function Seg(){var e=i9.now(),g=e-oE;g>OUe&&(i_-=g,oE=e)}function Reg(){for(var e,g=rE,i,n=1/0;g;)g._call?(n>g._time&&(n=g._time),e=g,g=g._next):(i=g._next,g._next=null,g=e?e._next=i:rE=i);HV=e,ree(n)}function ree(e){if(!pw){TV&&(TV=clearTimeout(TV));var g=e-Mb;g>24?(e<1/0&&(TV=setTimeout(rSe,e-i9.now()-i_)),wR&&(wR=clearInterval(wR))):(wR||(oE=i9.now(),wR=setInterval(Seg,OUe)),pw=1,JUe(rSe))}}function oSe(e,g,i){var n=new CE;return g=g==null?0:+g,n.restart(I=>{n.stop(),e(I+g)},g,i),n}var Veg=H1("start","end","cancel","interrupt"),Weg=[],UUe=0,oee=1,Cee=2,i5=3,CSe=4,aee=5,n5=6;function n_(e,g,i,n,I,r){var o=e.__transition;if(!o)e.__transition={};else if(i in o)return;Xeg(e,i,{name:g,index:n,group:I,on:Veg,tween:Weg,time:r.time,delay:r.delay,duration:r.duration,ease:r.ease,timer:null,state:UUe})}function Ose(e,g){var i=nl(e,g);if(i.state>UUe)throw new Error("too late; already scheduled");return i}function Qc(e,g){var i=nl(e,g);if(i.state>i5)throw new Error("too late; already running");return i}function nl(e,g){var i=e.__transition;if(!i||!(i=i[g]))throw new Error("transition not found");return i}function Xeg(e,g,i){var n=e.__transition,I;n[g]=i,i.timer=LUe(r,0,i.time);function r(A){i.state=oee,i.timer.restart(o,i.delay,i.time),i.delay<=A&&o(A-i.delay)}function o(A){var s,l,c,u;if(i.state!==oee)return a();for(s in n)if(u=n[s],u.name===i.name){if(u.state===i5)return oSe(o);u.state===CSe?(u.state=n5,u.timer.stop(),u.on.call("interrupt",e,e.__data__,u.index,u.group),delete n[s]):+sCee&&n.state=0&&(g=g.slice(0,i)),!g||g==="start"})}function otg(e,g,i){var n,I,r=rtg(g)?Ose:Qc;return function(){var o=r(this,e),C=o.on;C!==n&&(I=(n=C).copy()).on(g,i),o.on=I}}function Ctg(e,g){var i=this._id;return arguments.length<2?nl(this.node(),i).on.on(e):this.each(otg(i,e,g))}function atg(e){return function(){var g=this.parentNode;for(var i in this.__transition)if(+i!==e)return;g&&g.removeChild(this)}}function stg(){return this.on("end.remove",atg(this._id))}function Atg(e){var g=this._name,i=this._id;typeof e!="function"&&(e=ZT(e));for(var n=this._groups,I=n.length,r=new Array(I),o=0;ooee&&n.name===g)return new Tc([[e]],Ytg,g,+I)}return null}const xtg=Object.freeze(Object.defineProperty({__proto__:null,active:Ktg,interrupt:CW,transition:$Ue},Symbol.toStringTag,{value:"Module"})),Pk=e=>()=>e;function Ftg(e,{sourceEvent:g,target:i,transform:n,dispatch:I}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:g,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:I}})}function gc(e,g,i){this.k=e,this.x=g,this.y=i}gc.prototype={constructor:gc,scale:function(e){return e===1?this:new gc(this.k*e,this.x,this.y)},translate:function(e,g){return e===0&g===0?this:new gc(this.k,this.x+this.k*e,this.y+this.k*g)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var NI=new gc(1,0,0);e7e.prototype=gc.prototype;function e7e(e){for(;!e.__zoom;)if(!(e=e.parentNode))return NI;return e.__zoom}function fQ(e){e.stopImmediatePropagation()}function SR(e){e.preventDefault(),e.stopImmediatePropagation()}function Etg(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Dtg(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function aSe(){return this.__zoom||NI}function Mtg(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function ztg(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ptg(e,g,i){var n=e.invertX(g[0][0])-i[0][0],I=e.invertX(g[1][0])-i[1][0],r=e.invertY(g[0][1])-i[0][1],o=e.invertY(g[1][1])-i[1][1];return e.translate(I>n?(n+I)/2:Math.min(0,n)||Math.max(0,I),o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o))}function see(){var e=Etg,g=Dtg,i=Ptg,n=Mtg,I=ztg,r=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],C=250,a=FHt,A=H1("start","zoom","end"),s,l,c,u=500,d=150,h=0,f=10;function m(V){V.property("__zoom",aSe).on("wheel.zoom",B,{passive:!1}).on("mousedown.zoom",S).on("dblclick.zoom",R).filter(I).on("touchstart.zoom",w).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",W).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(V,X,N,Y){var x=V.selection?V.selection():V;x.property("__zoom",aSe),V!==x?Z(V,X,N,Y):x.interrupt().each(function(){v(this,arguments).event(Y).start().zoom(null,typeof X=="function"?X.apply(this,arguments):X).end()})},m.scaleBy=function(V,X,N,Y){m.scaleTo(V,function(){var x=this.__zoom.k,M=typeof X=="function"?X.apply(this,arguments):X;return x*M},N,Y)},m.scaleTo=function(V,X,N,Y){m.transform(V,function(){var x=g.apply(this,arguments),M=this.__zoom,F=N==null?y(x):typeof N=="function"?N.apply(this,arguments):N,$=M.invert(F),Q=typeof X=="function"?X.apply(this,arguments):X;return i(p(b(M,Q),F,$),x,o)},N,Y)},m.translateBy=function(V,X,N,Y){m.transform(V,function(){return i(this.__zoom.translate(typeof X=="function"?X.apply(this,arguments):X,typeof N=="function"?N.apply(this,arguments):N),g.apply(this,arguments),o)},null,Y)},m.translateTo=function(V,X,N,Y,x){m.transform(V,function(){var M=g.apply(this,arguments),F=this.__zoom,$=Y==null?y(M):typeof Y=="function"?Y.apply(this,arguments):Y;return i(NI.translate($[0],$[1]).scale(F.k).translate(typeof X=="function"?-X.apply(this,arguments):-X,typeof N=="function"?-N.apply(this,arguments):-N),M,o)},Y,x)};function b(V,X){return X=Math.max(r[0],Math.min(r[1],X)),X===V.k?V:new gc(X,V.x,V.y)}function p(V,X,N){var Y=X[0]-N[0]*V.k,x=X[1]-N[1]*V.k;return Y===V.x&&x===V.y?V:new gc(V.k,Y,x)}function y(V){return[(+V[0][0]+ +V[1][0])/2,(+V[0][1]+ +V[1][1])/2]}function Z(V,X,N,Y){V.on("start.zoom",function(){v(this,arguments).event(Y).start()}).on("interrupt.zoom end.zoom",function(){v(this,arguments).event(Y).end()}).tween("zoom",function(){var x=this,M=arguments,F=v(x,M).event(Y),$=g.apply(x,M),Q=N==null?y($):typeof N=="function"?N.apply(x,M):N,U=Math.max($[1][0]-$[0][0],$[1][1]-$[0][1]),j=x.__zoom,ee=typeof X=="function"?X.apply(x,M):X,Ie=a(j.invert(Q).concat(U/j.k),ee.invert(Q).concat(U/ee.k));return function(fe){if(fe===1)fe=ee;else{var Ve=Ie(fe),oe=U/Ve[2];fe=new gc(oe,Q[0]-Ve[0]*oe,Q[1]-Ve[1]*oe)}F.zoom(null,fe)}})}function v(V,X,N){return!N&&V.__zooming||new G(V,X)}function G(V,X){this.that=V,this.args=X,this.active=0,this.sourceEvent=null,this.extent=g.apply(V,X),this.taps=0}G.prototype={event:function(V){return V&&(this.sourceEvent=V),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(V,X){return this.mouse&&V!=="mouse"&&(this.mouse[1]=X.invert(this.mouse[0])),this.touch0&&V!=="touch"&&(this.touch0[1]=X.invert(this.touch0[0])),this.touch1&&V!=="touch"&&(this.touch1[1]=X.invert(this.touch1[0])),this.that.__zoom=X,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(V){var X=xg(this.that).datum();A.call(V,this.that,new Ftg(V,{sourceEvent:this.sourceEvent,target:m,type:V,transform:this.that.__zoom,dispatch:A}),X)}};function B(V,...X){if(!e.apply(this,arguments))return;var N=v(this,X).event(V),Y=this.__zoom,x=Math.max(r[0],Math.min(r[1],Y.k*Math.pow(2,n.apply(this,arguments)))),M=mi(V);if(N.wheel)(N.mouse[0][0]!==M[0]||N.mouse[0][1]!==M[1])&&(N.mouse[1]=Y.invert(N.mouse[0]=M)),clearTimeout(N.wheel);else{if(Y.k===x)return;N.mouse=[M,Y.invert(M)],CW(this),N.start()}SR(V),N.wheel=setTimeout(F,d),N.zoom("mouse",i(p(b(Y,x),N.mouse[0],N.mouse[1]),N.extent,o));function F(){N.wheel=null,N.end()}}function S(V,...X){if(c||!e.apply(this,arguments))return;var N=V.currentTarget,Y=v(this,X,!0).event(V),x=xg(V.view).on("mousemove.zoom",Q,!0).on("mouseup.zoom",U,!0),M=mi(V,N),F=V.clientX,$=V.clientY;CP(V.view),fQ(V),Y.mouse=[M,this.__zoom.invert(M)],CW(this),Y.start();function Q(j){if(SR(j),!Y.moved){var ee=j.clientX-F,Ie=j.clientY-$;Y.moved=ee*ee+Ie*Ie>h}Y.event(j).zoom("mouse",i(p(Y.that.__zoom,Y.mouse[0]=mi(j,N),Y.mouse[1]),Y.extent,o))}function U(j){x.on("mousemove.zoom mouseup.zoom",null),aP(j.view,Y.moved),SR(j),Y.event(j).end()}}function R(V,...X){if(e.apply(this,arguments)){var N=this.__zoom,Y=mi(V.changedTouches?V.changedTouches[0]:V,this),x=N.invert(Y),M=N.k*(V.shiftKey?.5:2),F=i(p(b(N,M),Y,x),g.apply(this,X),o);SR(V),C>0?xg(this).transition().duration(C).call(Z,F,Y,V):xg(this).call(m.transform,F,Y,V)}}function w(V,...X){if(e.apply(this,arguments)){var N=V.touches,Y=N.length,x=v(this,X,V.changedTouches.length===Y).event(V),M,F,$,Q;for(fQ(V),F=0;Fo;Ithis.tickValues.length;){const o=this.axisTexts.pop();this.pAxis.removeChild(o),o.destroy(!0)}}},{key:"calculateAxisTickValues",value:function(i,n){const I=Math.max(Math.ceil(n/Qtg),1);let r=i.ticks(I);return r.length<1&&(r=i.ticks(I+1),r.length>1&&(r=[r[0]])),r}},{key:"drawAxisLeft",value:function(i,n){this.startAxis(n),this.createAxisTexts(i,n);const I=this.pAxis;this.track.getTheme()===ki&&I.lineStyle(I.lineWidth||I._lineStyle.width,jt("#ffffff")),I.moveTo(0,0),I.lineTo(-(XI+tC),0),I.moveTo(0,n),I.lineTo(-(XI+tC),n);for(let r=0;r=0;i--)this.axisTexts[i].visible=!0;for(let i=this.axisTexts.length-1;i>=0;i--){if(!this.axisTexts[i].visible)continue;let n=i-1;for(;n>=0&&this.axisTexts[i].y+this.axisTexts[i].height/2>this.axisTexts[n].y-this.axisTexts[n].height/2;){this.axisTexts[n].visible=!1;n-=1}}}},{key:"exportVerticalAxis",value:function(i){const n=document.createElement("g");n.setAttribute("class","axis-vertical");let I="black";this.track&&this.track.options.lineStrokeColor&&(I=this.track.options.lineStrokeColor),this.track.getTheme()===ki&&(I="#cccccc");const r=document.createElement("path");return r.setAttribute("fill","transparent"),r.setAttribute("stroke",I),r.setAttribute("id","axis-line"),r.setAttribute("d",`M0,0 L0,${i}`),n.appendChild(r),n}},{key:"createAxisSVGLine",value:function(){let i="black";this.track&&this.track.options.lineStrokeColor&&(i=this.track.options.lineStrokeColor),this.track.getTheme()===ki&&(i="#cccccc");const n=document.createElement("path");return n.setAttribute("id","tick-mark"),n.setAttribute("fill","transparent"),n.setAttribute("stroke",i),n}},{key:"createAxisSVGText",value:function(i){const n=document.createElement("text");return n.innerHTML=i,n.setAttribute("id","axis-text"),n.setAttribute("text-anchor","middle"),n.setAttribute("font-family",this.axisTextFontFamily),n.setAttribute("font-size",this.axisTextFontSize),n.setAttribute("dy",this.axisTextFontSize/2-2),n}},{key:"exportAxisLeftSVG",value:function(i,n){const I=this.exportVerticalAxis(n),r=this.createAxisSVGLine();I.appendChild(r),r.setAttribute("d",`M0,0 L${+(XI+tC)},0`);const o=this.createAxisSVGLine();I.appendChild(o),o.setAttribute("d",`M0,${n} L${+(XI+tC)},${n}`);for(let C=0;C{const i=[];for(let n=e;n{const i=e.map(C=>+C).sort((C,a)=>a-C),n=g.range()[1]-g.range()[0],r=i.map(C=>(g.domain()[1]-g.domain()[0])/C).map(C=>C/n),o=r.filter(C=>C<1);return o.length===0?0:r.indexOf(o[o.length-1])},$tg=(e,g,i,n)=>{const I=e.range()[1]-e.range()[0],r=Math.max((i-g)/(e.domain()[1]-e.domain()[0]),1),C=Math.max(0,Math.ceil(Math.log(I/384)/Math.LN2));let a=Math.round(Math.log(r)/Math.LN2)+C,A=0;return n&&(A=Math.floor(Math.log(256)/Math.log(2)-Math.log(n)/Math.log(2))),a+=A,a},g7e=(e,g,i)=>{if(typeof i>"u"&&(i=Number.MAX_SAFE_INTEGER),e.resolutions)return jtg(e.resolutions,g,e.min_pos[0],e.max_pos[0]-2);const n=$tg(g,e.min_pos[0],e.max_pos[0],e.bins_per_dimension||e.tile_size),I=Math.min(n,i);return Math.max(I,0)},qtg=(e,g,i,n,I,r)=>{const o=Math.min(e,I),C=r/2**o,a=1e-7;return t7e(Math.max(0,Math.floor((g.domain()[0]-i)/C)),Math.min(2**o,Math.ceil((g.domain()[1]-i-a)/C)))},egg=(e,g,i,n=Number.MAX_VALUE,I=256)=>{const o=e*I,C=20,a=Math.max(0,Math.floor((g.domain()[0]-i)/o)),A=Math.ceil(Math.min(n,g.domain()[1]-i-1e-7)/o);let s=t7e(a,A);return s.length>C&&(console.warn(`Too many visible tiles: ${s.length} truncating to ${C}`),s=s.slice(0,C)),s},tgg=(e,g)=>{if(!e)return[];const i=g7e(e,g,e.max_zoom);if(e.resolutions){const r=e.resolutions.map(a=>+a).sort((a,A)=>A-a);return egg(r[i],g,e.min_pos[0],e.max_pos[0]).map(a=>[i,a])}return qtg(i,g,e.min_pos[0],e.max_pos[0],e.max_zoom,e.max_width).map(r=>[i,r])},ggg=(e,g)=>{if(e.axis||(e.axis=new I_(e),e.pBase.addChild(e.axis.pAxis)),!e.options.axisPositionVertical&&!e.options.axisPositionHorizontal){e.axis.clearAxis();return}if(e.options.axisPositionVertical&&e.options.axisPositionVertical==="hidden"){e.axis.clearAxis();return}if(e.options.axisPositionHorizontal&&e.options.axisPositionHorizontal==="hidden"){e.axis.clearAxis();return}const i=e.options.axisMargin||0;e.options.axisPositionHorizontal==="left"||e.options.axisPositionVertical==="top"?(e.axis.pAxis.position.x=e.position[0]+i,e.axis.pAxis.position.y=e.position[1],e.axis.drawAxisRight(g,e.dimensions[1])):e.options.axisPositionHorizontal==="outsideLeft"||e.options.axisPositionVertical==="outsideTop"?(e.axis.pAxis.position.x=e.position[0]+i,e.axis.pAxis.position.y=e.position[1],e.axis.drawAxisLeft(g,e.dimensions[1])):e.options.axisPositionHorizontal==="right"||e.options.axisPositionVertical==="bottom"?(e.axis.pAxis.position.x=e.position[0]+e.dimensions[0]-i,e.axis.pAxis.position.y=e.position[1],e.axis.drawAxisLeft(g,e.dimensions[1])):(e.options.axisPositionHorizontal==="outsideRight"||e.options.axisPositionVertical==="outsideBottom")&&(e.axis.pAxis.position.x=e.position[0]+e.dimensions[0]-i,e.axis.pAxis.position.y=e.position[1],e.axis.drawAxisRight(g,e.dimensions[1]))},igg=(e,g)=>{const i=e.valueScaleTransform,{y:n,k:I}=i,r=e.dimensions[1];n+g/I>-(I-1)*r&&n+g/I<0&&(e.valueScaleTransform=i.translate(0,g/I)),Object.values(e.fetchedTiles).forEach(o=>{o.graphics.position.y=e.valueScaleTransform.y}),e.animate()},ngg=(e,g,i,n)=>{const I=i.k,r=i.y,o=(e-r)/I,C=Math.max(I/g,1);let a=I*o+r-C*o;return a=Math.max(a,-(C-1)*n),a=Math.min(a,0),NI.translate(0,a).scale(C)},Igg=(e,g)=>{const i=+g.split(".")[0],n=+g.split(".")[1],I=e.max_width,r=e.min_pos[0],o=I/2**i;return{tileX:r+n*o,tileWidth:o}};function rgg(e,g){Object.values(e.fetchedTiles).forEach(i=>{if(!i.drawnAtScale)return;const n=i.drawnAtScale.range(),I=e._xScale.range();if(n[0]!==I[0]||n[1]!==I[1]){e.renderTile(i);return}const r=(i.drawnAtScale.domain()[1]-i.drawnAtScale.domain()[0])/(e._xScale.domain()[1]-e._xScale.domain()[0]);if(r>2||r<.5)e.renderTile(i);else{const C=e._xScale.domain().map(i.drawnAtScale)[0];for(const a of g)a(i).scale.x=r,a(i).x=-C*r}})}const U0={calculate1DVisibleTiles:tgg,calculate1DZoomLevel:g7e,drawAxis:ggg,movedY:igg,getTilePosAndDimensions:Igg,stretchRects:rgg,zoomedY:ngg},ogg=Object.freeze(Object.defineProperty({__proto__:null,DenseDataExtrema1D:PF,DenseDataExtrema2D:Mae,IS_TRACK_RANGE_SELECTABLE:N1,absToChr:mI,accessorTransposition:RPe,addArrays:VPe,addClass:xFt,base64ToCanvas:FFt,changeOptions:beg,chrToAbs:HF,chromInfoBisector:SPe,cloneEvent:WPe,colorDomainToRgbaArray:hm,colorToHex:jt,colorToRgba:PPe,dataToGenomicLoci:xF,debounce:Wae,decToHexStr:yq,dictFromTuples:_Pe,dictItems:Ea,dictKeys:Ya,dictValues:hi,download:z2,expandCombinedTracks:UK,fillInMinWidths:OPe,flatten:bEt,forEach:yEt,forwardEvent:FF,genomeLociToPixels:ZEt,genomicRangeToChromosomeChunks:GEt,getAggregationFunction:zae,getDefaultTrackForDatatype:Xae,getElementDim:qPe,getTiledPlot:uMt,getTrackByUid:ta,getTrackConfFromHGC:yDt,getTrackObjById:VV,getTrackObjectFromHGC:Pae,getTrackPositionByUid:P2,getTrackRenderer:p_e,getXylofon:t_e,gradient:g_e,hasClass:TF,hasParent:i_e,hexStrToInt:n_e,intoTheVoid:I_e,isTrackOrChildTrack:r_e,isWithin:Fae,latToY:WDt,lngToX:TDt,loadChromInfos:XDt,map:Kae,max:Zq,maxNonZero:Gq,min:o_e,minNonZero:vq,mod:HDt,mountHGComponent:_Ue,mountHGComponentAsync:veg,ndarrayAssign:C_e,ndarrayFlatten:A_e,ndarrayToList:s_e,numericifyVersion:l_e,objVals:cP,or:kT,parseChromsizesRows:uP,pixiTextToSvg:Bq,q:JDt,rangeQuery2d:LDt,reduce:JPe,relToAbsChromPos:UDt,removeClass:jDt,removeHGComponent:Geg,resetD3BrushStyle:Ov,rgbToHex:$Dt,scalesCenterAndK:AI,scalesToGenomeLoci:c_e,segmentsToRows:zF,selectedItemsToSize:UX,showMousePosition:Yb,some:gMt,sum:of,svgLine:u_e,throttleAndDebounce:d_e,tileToCanvas:iMt,timeout:Eae,toVoid:GA,totalTrackPixelHeight:nMt,trackUtils:U0,trimTrailingSlash:dP,valueToColor:Dae,visitPositionedTracks:ku,visitTracks:Yae,waitForJsonComplete:Pse,waitForTilesLoaded:IE,waitForTransitionsFinished:PUe},Symbol.toStringTag,{value:"Module"}));function Aee(){return Aee=Object.assign?Object.assign.bind():function(e){for(var g=1;gk.forwardRef((g,i)=>k.createElement(agg,null,n=>k.createElement(e,Aee({ref:i},g,{theme:n})))),jh={"track-control":"_track-control_w7hx2_1","track-control-vertical":"_track-control-vertical_w7hx2_2","track-control-dark":"_track-control-dark_w7hx2_15","track-control-active":"_track-control-active_w7hx2_16 _track-control_w7hx2_1","track-control-left":"_track-control-left_w7hx2_24","track-control-vertical-active":"_track-control-vertical-active_w7hx2_30","track-control-padding-right":"_track-control-padding-right_w7hx2_48","track-control-button":"_track-control-button_w7hx2_52","track-control-button-vertical":"_track-control-button-vertical_w7hx2_81"},sgg=e=>gi({[jh["track-control-active"]]:e.isVisible,[jh["track-control"]]:!e.isVisible,[jh["track-control-left"]]:e.isAlignLeft,[jh["track-control-vertical"]]:e.isVertical,[jh["track-control-padding-right"]]:e.paddingRight,[jh["track-control-dark"]]:e.theme===ki}),_k=e=>gi("no-zoom",jh["track-control-button"],{[jh["track-control-button-vertical"]]:e.isVertical});let mQ=null,lSe=null;function i7e(e){(!e||!mQ||Object.keys(e).some(n=>mQ[n]!==e[n]))&&(mQ=e,lSe=fq(()=>k.createElement("svg",{className:_k(e),style:{height:"20px",width:"20px",...e.imgStyleMove}},k.createElement("title",null,"Move track"),k.createElement("use",{xlinkHref:"#move"}))));let g,i;return k.createElement("div",{className:sgg(e)},e.isMoveable&&k.createElement(lSe,null),k.createElement("svg",{ref:n=>{g=n},className:_k(e),onClick:()=>{e.onConfigTrackMenuOpened(e.uid,g.getBoundingClientRect())},style:{height:"20px",width:"20px",...e.imgStyleSettings}},k.createElement("title",null,"Configure track"),k.createElement("use",{xlinkHref:"#cog"})),e.onAddSeries&&k.createElement("svg",{className:_k(e),onClick:()=>e.onAddSeries(e.uid),style:{height:"20px",width:"20px",...e.imgStyleAdd}},k.createElement("title",null,"Add series"),k.createElement("use",{xlinkHref:"#plus"})),k.createElement("svg",{ref:n=>{i=n},className:_k(e),onClick:()=>{e.onCloseTrackMenuOpened(e.uid,i.getBoundingClientRect())},style:{height:"20px",width:"20px",...e.imgStyleClose}},k.createElement("title",null,"Close track"),k.createElement("use",{xlinkHref:"#cross"})))}i7e.propTypes={imgStyleAdd:L.object,imgStyleClose:L.object,imgStyleMove:L.object,imgStyleSettings:L.object,isAlignLeft:L.bool,isMoveable:L.bool,isVertical:L.bool,isVisible:L.bool,onConfigTrackMenuOpened:L.func,onCloseTrackMenuOpened:L.func,onAddSeries:L.func,paddingRight:L.bool,theme:L.symbol.isRequired,uid:L.string};const r_=iZ(i7e),lee={"center-track":"_center-track_fiu64_1","center-track-container":"_center-track-container_fiu64_6"},CA={"track-range-selection":"_track-range-selection_5bcsr_1","track-range-selection-active":"_track-range-selection-active_5bcsr_8 _track-range-selection_5bcsr_1","track-range-selection-active-primary":"_track-range-selection-active-primary_5bcsr_14 _track-range-selection-active_5bcsr_8 _track-range-selection_5bcsr_1","track-range-selection-active-secondary":"_track-range-selection-active-secondary_5bcsr_18 _track-range-selection-active_5bcsr_8 _track-range-selection_5bcsr_1","track-range-selection-group-inactive":"_track-range-selection-group-inactive_5bcsr_22","track-range-selection-group-brush-selection":"_track-range-selection-group-brush-selection_5bcsr_26"};function Agg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function cSe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function aE(e){return aE=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},aE(e)}const Ok={pointerEvents:"all"};function eG(e){return e&&e.sourceEvent}let Lse=function(e){dgg(i,e);var g=hgg(i);function i(n){var I;return Agg(this,i),I=g.call(this,n),I.state={isVisible:!1},I.brushBehaviorX=lP().on("brush",I.brushedX.bind(xh(I))).on("end",I.brushedXEnded.bind(xh(I))),I.brushBehaviorY=TT().on("brush",I.brushedY.bind(xh(I))).on("end",I.brushedYEnded.bind(xh(I))),I.brushBehaviorXY=Zae().on("start",I.brushStarted.bind(xh(I))).on("brush",I.brushedXY.bind(xh(I))).on("end",I.brushedXYEnded.bind(xh(I))),I}return lgg(i,[{key:"componentDidMount",value:function(){this.props.isRangeSelectionActive&&this.addBrush2d()}},{key:"shouldComponentUpdate",value:function(I,r){if(this.rangeSelectionTriggeredXY){if(this.rangeSelectionTriggeredXY=!1,this.rangeSelectionTriggeredXYEnd){const o=I.rangeSelection[0]||null;this.moveBrushXY([o,I.rangeSelection[1]],!0),this.rangeSelectionTriggeredXYEnd=!1}return this.state!==r}if(this.props.rangeSelection!==I.rangeSelection){const o=I.rangeSelection[0]||null;this.props.is1dRangeSelection?(this.rangeSelectionTriggeredX||this.moveBrushX(o,I.rangeSelectionEnd),this.rangeSelectionTriggeredXEnd&&this.moveBrushX(o,I.rangeSelectionEnd,!0),this.rangeSelectionTriggeredY||this.moveBrushY(o,I.rangeSelectionEnd),this.rangeSelectionTriggeredYEnd&&this.moveBrushY(o,I.rangeSelectionEnd,!0),this.rangeSelectionTriggeredX=!1,this.rangeSelectionTriggeredXEnd=!1,this.rangeSelectionTriggeredY=!1,this.rangeSelectionTriggeredYEnd=!1):this.moveBrushXY([o,I.rangeSelection[1]],I.rangeSelectionEnd);const C=this.props.is1dRangeSelection&&!I.is1dRangeSelection&&o===null;return this.state!==r||C}return!0}},{key:"componentDidUpdate",value:function(){this.props.isRangeSelectionActive?this.addBrush2d():(this.removeBrush1d(),this.removeBrush2d())}},{key:"addBrush1d",value:function(){!this.brushElX||!this.brushElY||this.brushElXOld===this.brushElX&&this.brushElYOld===this.brushElY||(this.brushElXOld&&this.brushElXOld.on(".brush",null),this.brushElYOld&&this.brushElYOld.on(".brush",null),this.brushElX.call(this.brushBehaviorX),this.brushElY.call(this.brushBehaviorY),Ov(this.brushElX,CA["track-range-selection-group-brush-selection"]),Ov(this.brushElY,CA["track-range-selection-group-brush-selection"]),this.brushElXOld=this.brushElX,this.brushElYOld=this.brushElY,this.brushIs1dBound=!0)}},{key:"addBrush2d",value:function(){!this.brushElXY||this.brushElXYOld===this.brushElXY||(this.brushElXYOld&&this.brushElXYOld.on(".brush",null),this.brushElXY.call(this.brushBehaviorXY),this.brushElXYOld=this.brushElXY,this.brushIs2dBound=!0,Ov(this.brushElXY,CA["track-range-selection-group-brush-selection"]))}},{key:"brushedX",value:function(I){const r=this.rangeSelectionMoved;this.rangeSelectionMoved=!1,!(!eG(I)||!this.props.onRangeSelectionX||!this.props.is1dRangeSelection||r)&&(this.rangeSelectionTriggeredX=!0,this.props.onRangeSelectionX(I.selection))}},{key:"brushedXEnded",value:function(I){const r=this.rangeSelectionMovedEnd;this.rangeSelectionMovedEnd=!1,!(!eG(I)||!this.props.onRangeSelectionX||!this.props.is1dRangeSelection||r)&&(this.rangeSelectionTriggeredX=!0,this.rangeSelectionTriggeredXEnd=!0,this.props.onRangeSelectionXEnd(I.selection))}},{key:"brushedY",value:function(I){const r=this.rangeSelectionMoved;this.rangeSelectionMoved=!1,!(!eG(I)||!this.props.onRangeSelectionY||!this.props.is1dRangeSelection||r)&&(this.rangeSelectionTriggeredY=!0,this.props.onRangeSelectionY(I.selection))}},{key:"brushedYEnded",value:function(I){const r=this.rangeSelectionMovedEnd;this.rangeSelectionMovedEnd=!1,!(!eG(I)||!this.props.onRangeSelectionY||!this.props.is1dRangeSelection||r)&&(this.rangeSelectionTriggeredY=!0,this.rangeSelectionTriggeredYEnd=!0,this.props.onRangeSelectionYEnd(I.selection))}},{key:"brushedXY",value:function(I){const r=this.rangeSelectionMoved;this.rangeSelectionMoved=!1,!(!eG(I)||!this.props.onRangeSelectionXY||r||this.props.is1dRangeSelection)&&(this.rangeSelectionTriggeredXY=!0,this.props.onRangeSelectionXY([[I.selection[0][0],I.selection[1][0]],[I.selection[0][1],I.selection[1][1]]]))}},{key:"brushedXYEnded",value:function(I){if(this.props.is1dRangeSelection)return;const r=this.rangeSelectionMovedEnd;this.rangeSelectionMovedEnd=!1,I.selection&&I.sourceEvent&&this.props.onRangeSelectionXY&&!r&&(this.rangeSelectionTriggeredXY=!0,this.rangeSelectionTriggeredXYEnd=!0,this.props.onRangeSelectionXYEnd([[I.selection[0][0],I.selection[1][0]],[I.selection[0][1],I.selection[1][1]]])),I.selection||(this.rangeSelectionTriggeredXY=!0,this.props.onRangeSelectionReset())}},{key:"brushStarted",value:function(I){eG(I)&&this.props.onRangeSelectionStart()}},{key:"moveBrushX",value:function(I,r=!1){if(!this.brushEl)return;this.brushIs2dBound&&(this.removeBrush2d(),this.addBrush1d());const o=I?[this.props.scaleX(I[0]),this.props.scaleX(I[1])]:null;this.rangeSelectionMoved=!0,this.rangeSelectionMovedEnd=!0,r?this.brushElX.transition().call(this.brushBehaviorX.move,o):this.brushElX.call(this.brushBehaviorX.move,o)}},{key:"moveBrushY",value:function(I,r=!1){if(!this.brushEl)return;this.brushIs2dBound&&(this.removeBrush2d(),this.addBrush1d());const o=I?[this.props.scaleY(I[0]),this.props.scaleY(I[1])]:null;this.rangeSelectionMoved=!0,this.rangeSelectionMovedEnd=!0,r?this.brushElY.transition().call(this.brushBehaviorY.move,o):this.brushElY.call(this.brushBehaviorY.move,o)}},{key:"moveBrushXY",value:function(I,r=!1){if(!this.brushEl)return;const o=[[this.props.scaleX(I[0][0]),this.props.scaleY(I[1][0])],[this.props.scaleX(I[0][1]),this.props.scaleY(I[1][1])]];this.rangeSelectionMoved=!0,this.rangeSelectionMovedEnd=!0,r?this.brushElXY.transition().call(this.brushBehaviorXY.move,o):this.brushElXY.call(this.brushBehaviorXY.move,o)}},{key:"mouseEnterHandler",value:function(){this.props.isRangeSelectionActive||this.setState({isVisible:!0})}},{key:"mouseLeaveHandler",value:function(){this.setState({isVisible:!1})}},{key:"removeBrush1d",value:function(){this.brushIs1dBound&&(this.brushElX&&(this.brushElX.call(this.brushBehaviorX.move,null),this.brushElX.on(".brush",null)),this.brushElY&&(this.brushElY.call(this.brushBehaviorY.move,null),this.brushElY.on(".brush",null)),this.brushIs1dBound=!1)}},{key:"removeBrush2d",value:function(){this.brushIs2dBound&&this.brushElXY&&(this.brushElXY.call(this.brushBehaviorXY.move,null),this.brushElXY.on(".brush",null),this.brushElXYOld=void 0,this.brushIs2dBound=!1,this.props.is1dRangeSelection||this.props.onRangeSelectionReset())}},{key:"render",value:function(){const I=this.props.tracks.map(A=>N1(A)).reduce(kT,!1),r=this.props.tracks.some(A=>A.contents?A.contents.some(s=>s.type==="heatmap"?s.options.colorbarPosition==="topRight":!1):A.type==="heatmap"?A.options.colorbarPosition==="topRight":!1);let o="track-range-selection";this.props.isRangeSelectionActive&&(o+=this.props.is1dRangeSelection?"-active-secondary":"-active-primary");const C=gi(!this.props.is1dRangeSelection&&CA["track-range-selection-group-inactive"]),a=gi(this.props.is1dRangeSelection&&CA["track-range-selection-group-inactive"]);return k.createElement("div",{className:gi(this.props.className,lee["center-track"]),onMouseEnter:this.mouseEnterHandler.bind(this),onMouseLeave:this.mouseLeaveHandler.bind(this),style:{height:this.props.height,width:this.props.width}},I&&k.createElement("svg",{className:CA[o],style:{height:this.props.height,width:this.props.width},xmlns:"http://www.w3.org/2000/svg"},k.createElement("g",{ref:A=>{this.brushElX=xg(A)},className:C}),k.createElement("g",{ref:A=>{this.brushElY=xg(A)},className:C}),k.createElement("g",{ref:A=>{this.brushElXY=xg(A)},className:a})),this.props.editable&&k.createElement(r_,{imgStyleAdd:Ok,imgStyleClose:Ok,imgStyleMove:Ok,imgStyleSettings:Ok,isMoveable:!1,isVisible:this.state.isVisible||this.props.uid===this.props.configTrackMenuId,onAddSeries:this.props.onAddSeries,onCloseTrackMenuOpened:this.props.onCloseTrackMenuOpened,onConfigTrackMenuOpened:this.props.onConfigTrackMenuOpened,paddingRight:r,uid:this.props.uid}))}}]),i}(k.Component);Lse.defaultProps={className:"center-track",configTrackMenuId:null,is1dRangeSelection:!1,rangeSelectionEnd:L.bool,isRangeSelectionActive:!1,scaleX:e=>e,scaleY:e=>e};Lse.propTypes={className:L.string,configTrackMenuId:L.string,editable:L.bool,height:L.number.isRequired,is1dRangeSelection:L.bool,isRangeSelectionActive:L.bool,onAddSeries:L.func.isRequired,onCloseTrackMenuOpened:L.func.isRequired,onConfigTrackMenuOpened:L.func.isRequired,onRangeSelectionX:L.func.isRequired,onRangeSelectionXEnd:L.func.isRequired,onRangeSelectionY:L.func.isRequired,onRangeSelectionYEnd:L.func.isRequired,onRangeSelectionXY:L.func.isRequired,onRangeSelectionXYEnd:L.func.isRequired,onRangeSelectionReset:L.func.isRequired,onRangeSelectionStart:L.func.isRequired,rangeSelection:L.array.isRequired,rangeSelectionEnd:L.bool,scaleX:L.func,scaleY:L.func,tracks:L.array.isRequired,uid:L.string.isRequired,width:L.number.isRequired};function uee(){return uee=Object.assign?Object.assign.bind():function(e){for(var g=1;g({event:"fake",handler:GA}),unsubscribe:GA,clear:GA},{Provider:pgg,Consumer:bgg}=k.createContext(Use),L1=e=>k.forwardRef((g,i)=>k.createElement(bgg,null,n=>k.createElement(e,uee({ref:i},g,{pubSub:n})))),ygg={"drag-listening-div-active":"_drag-listening-div-active_19gkt_1"};function Zgg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function uSe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function sE(e){return sE=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},sE(e)}let Qse=function(e){wgg(i,e);var g=Sgg(i);function i(n){var I;return Zgg(this,i),I=g.call(this,n),I.state={dragOnTop:!1},I}return Ggg(i,[{key:"render",value:function(){let I="red";return this.props.enabled&&this.state.dragOnTop?I="green":this.props.enabled&&(I="blue"),k.createElement("div",{className:gi("DragListeningDiv",{[ygg["drag-listening-div-active"]]:this.props.enabled}),onDragEnter:()=>{this.setState({dragOnTop:!0})},onDragLeave:()=>{this.setState({dragOnTop:!1})},onDragOver:r=>{r.preventDefault()},onDrop:()=>{if(!this.props.enabled)return;const r=this.props.draggingHappening,o={type:this.props.defaultTrackType,uid:Ng.nice(),tilesetUid:r.tilesetUid,server:r.server};this.props.onTrackDropped(o),this.props.pubSub.publish("trackDropped",o)},style:{background:I,opacity:.6,...this.props.style}})}}]),i}(k.Component);Qse.defaultProps={enabled:!1,style:{},draggingHappening:{},onTrackDropped:()=>{}};Qse.propTypes={enabled:L.bool,style:L.object,defaultTrackType:L.object,draggingHappening:L.object,onTrackDropped:L.func,position:L.string.isRequired,pubSub:L.object.isRequired};const Jk=L1(Qse),Vp={"gallery-tracks":"_gallery-tracks_fbxxi_1","gallery-track":"_gallery-track_fbxxi_1","gallery-sub-track":"_gallery-sub-track_fbxxi_18","gallery-invisible-track":"_gallery-invisible-track_fbxxi_19"},Xgg="_horizontalList_1y7td_7",Tgg="_list_1y7td_14",Hgg="_stylizedList_1y7td_21",Ngg="_stylizedItem_1y7td_28",kgg="_stylizedHelper_1y7td_39",Ygg="_horizontalItem_1y7td_44",Kgg="_domain_1y7td_60",aA={"tiled-plot":"_tiled-plot_1y7td_1",horizontalList:Xgg,list:Tgg,stylizedList:Hgg,stylizedItem:Ngg,stylizedHelper:kgg,horizontalItem:Ygg,"resizable-track":"_resizable-track_1y7td_55",domain:Kgg};function xgg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function dSe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function AE(e){return AE=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},AE(e)}const Lk={pointerEvents:"all"};let n7e=function(e){Mgg(i,e);var g=zgg(i);function i(n){var I;return xgg(this,i),I=g.call(this,n),I.state={hovering:!1},I}return Fgg(i,[{key:"mouseEnterHandler",value:function(){this.setState({hovering:!0})}},{key:"mouseLeaveHandler",value:function(){this.setState({hovering:!1})}},{key:"render",value:function(){return k.createElement("div",{className:gi("gallery-tracks",Vp["gallery-tracks"])},this.props.tracks&&this.props.tracks.map((I,r)=>k.createElement("div",{key:I.uid||r,className:Vp["gallery-track"],onMouseLeave:this.mouseLeaveHandler.bind(this),style:{top:I.height*r,right:I.height*r,bottom:I.height*r,left:I.height*r}},k.createElement("div",{className:Vp["gallery-sub-track"],onMouseEnter:this.mouseEnterHandler.bind(this),style:{top:0,right:0,left:0,height:I.height}}),k.createElement("div",{className:Vp["gallery-sub-track"],onMouseEnter:this.mouseEnterHandler.bind(this),style:{top:0,right:0,bottom:0,width:I.height}}),k.createElement("div",{className:Vp["gallery-sub-track"],onMouseEnter:this.mouseEnterHandler.bind(this),style:{right:0,bottom:0,left:0,height:I.height}}),k.createElement("div",{className:Vp["gallery-sub-track"],onMouseEnter:this.mouseEnterHandler.bind(this),style:{top:0,bottom:0,left:0,width:I.height}}),k.createElement("div",{className:Vp["gallery-invisible-track"],onMouseLeave:this.mouseLeaveHandler.bind(this),style:{top:I.height,right:I.height,bottom:I.height,left:I.height}}),this.props.editable&&k.createElement(r_,{configMenuVisible:!0,imgStyleAdd:Lk,imgStyleClose:Lk,imgStyleMove:Lk,imgStyleSettings:Lk,isMoveable:!1,isVisible:this.state.hovering,onCloseTrackMenuOpened:this.props.onCloseTrackMenuOpened,onConfigTrackMenuOpened:this.props.onConfigTrackMenuOpened,uid:I.uid||r}))))}}]),i}(k.Component);n7e.propTypes={editable:L.bool,onCloseTrackMenuOpened:L.func.isRequired,onConfigTrackMenuOpened:L.func.isRequired,tracks:L.array};function Jgg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function hSe(e,g){for(var i=0;i{}),this.pubSubs.push(this.pubSub.subscribe("app.mouseMove",this.defaultMouseMoveHandler.bind(this))),this.isLeftModified=!1}return Lgg(e,[{key:"isWithin",value:function(i,n){let I=i,r=n,o=this.position[0],C=this.position[1];return this.isLeftModified&&(I=n,r=i,o=this.position[1],C=this.position[0]),Fae(I,r,o,this.dimensions[0]+o,C,this.dimensions[1]+C)}},{key:"getProp",value:function(i){return()=>this[i]}},{key:"getData",value:function(){}},{key:"click",value:function(i,n,I){return{type:"generic",event:I,payload:null}}},{key:"clickOutside",value:function(){}},{key:"getDimensions",value:function(){return this.dimensions}},{key:"setDimensions",value:function(i){this.dimensions=i,this._xScale.range([0,this.dimensions[0]]),this._yScale.range([0,this.dimensions[1]])}},{key:"refXScale",value:function(i){return i?(this._refXScale=i,this):this._refXScale}},{key:"refYScale",value:function(i){return i?(this._refYScale=i,this):this._refYScale}},{key:"xScale",value:function(i){return i?(this._xScale=i,this):this._xScale}},{key:"yScale",value:function(i){return i?(this._yScale=i,this):this._yScale}},{key:"zoomed",value:function(i,n){this.xScale(i),this.yScale(n)}},{key:"refScalesChanged",value:function(i,n){this._refXScale=i,this._refYScale=n}},{key:"draw",value:function(){}},{key:"getPosition",value:function(){return this.position}},{key:"setPosition",value:function(i){this.position=i}},{key:"defaultMouseMoveHandler",value:function(i){}},{key:"remove",value:function(){this.pubSubs.forEach(i=>this.pubSub.unsubscribe(i)),this.pubSubs=[]}},{key:"rerender",value:function(i){}},{key:"respondsToPosition",value:function(i,n){return this.isWithin(i,n)}},{key:"zoomedY",value:function(i,n){}},{key:"movedY",value:function(i){}}]),e}();function jgg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function fSe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function bw(e){return bw=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},bw(e)}function oig(e,g){const i=T1(g,e);return _y(`.${i}`,e)(e)}function Cig(e,g){const i=e.map(r=>+r).sort((r,o)=>o-r),n=i[g],I=i[i.length-1];return oig(n,I)}function aig(e,g,i,n){const I=g/(2**e*i);if(!Number.isNaN(I)){const r=g/(2**n*i),o=T1(r,I);return _y(`.${o}`,I)(I)}return console.warn("NaN resolution, screen is probably too small."),""}let Lo=function(e){gig(i,e);var g=iig(i);function i(n,I){var r;jgg(this,i),r=g.call(this,n,I);const{scene:o}=n;r.scene=o,r.delayDrawing=!1,r.pBase=new st.PIXI.Graphics,r.pMasked=new st.PIXI.Graphics,r.pMask=new st.PIXI.Graphics,r.pMain=new st.PIXI.Graphics,r.pBorder=new st.PIXI.Graphics,r.pBackground=new st.PIXI.Graphics,r.pForeground=new st.PIXI.Graphics,r.pLabel=new st.PIXI.Graphics,r.pMobile=new st.PIXI.Graphics,r.pAxis=new st.PIXI.Graphics,r.pMouseOver=new st.PIXI.Graphics,r.scene.addChild(r.pBase),r.pBase.addChild(r.pMasked),r.pMasked.addChild(r.pBackground),r.pMasked.addChild(r.pMain),r.pMasked.addChild(r.pMask),r.pMasked.addChild(r.pMobile),r.pMasked.addChild(r.pBorder),r.pMasked.addChild(r.pLabel),r.pMasked.addChild(r.pForeground),r.pMasked.addChild(r.pMouseOver),r.pBase.addChild(r.pAxis),r.pMasked.mask=r.pMask,r.prevOptions="",r.options=Object.assign(r.options,I);const C=r.getName();return r.labelTextFontFamily="Arial",r.labelTextFontSize=12,r.labelXOffset=0,r.labelText=new st.PIXI.Text(C,{fontSize:`${r.labelTextFontSize}px`,fontFamily:r.labelTextFontFamily,fill:"black"}),r.pLabel.addChild(r.labelText),r.errorText=new st.PIXI.Text("",{fontSize:"12px",fontFamily:"Arial",fill:"red"}),r.errorText.anchor.x=.5,r.errorText.anchor.y=.5,r.pLabel.addChild(r.errorText),r.errorTextText="",r.flipText=!1,r.tilesetInfo=void 0,r}return $gg(i,[{key:"setLabelText",value:function(){}},{key:"setPosition",value:function(I){this.position=I,this.drawBorder(),this.drawLabel(),this.drawBackground(),this.setMask(this.position,this.dimensions),this.setForeground()}},{key:"setDimensions",value:function(I){I5(bw(i.prototype),"setDimensions",this).call(this,I),this.drawBorder(),this.drawLabel(),this.drawBackground(),this.setMask(this.position,this.dimensions),this.setForeground()}},{key:"setMask",value:function(I,r){this.pMask.clear(),this.pMask.beginFill(),this.pMask.drawRect(I[0],I[1],r[0],r[1]),this.pMask.endFill()}},{key:"setForeground",value:function(){this.pForeground.position.y=this.position[1],this.pForeground.position.x=this.position[0]}},{key:"remove",value:function(){this.pBase.clear(),this.scene.removeChild(this.pBase)}},{key:"drawBorder",value:function(){const I=this.pBorder;if(I.clear(),!this.options||!this.options.trackBorderWidth)return;const r=jt(this.options.trackBorderColor?this.options.trackBorderColor:"white");I.lineStyle(this.options.trackBorderWidth,r),I.drawRect(this.position[0],this.position[1],this.dimensions[0],this.dimensions[1])}},{key:"drawError",value:function(){if(this.errorText.x=this.position[0]+this.dimensions[0]/2,this.errorText.y=this.position[1]+this.dimensions[1]/2,this.errorText.text=this.errorTextText,this.errorTextText&&this.errorTextText.length){const I=this.pBorder;I.clear(),I.lineStyle(1,jt("red")),I.drawRect(this.position[0],this.position[1],this.dimensions[0],this.dimensions[1])}}},{key:"drawBackground",value:function(){const I=this.pBackground;if(I.clear(),!this.options||!this.options.backgroundColor)return;let r=1,o=this.options.backgroundColor;this.options.backgroundColor==="transparent"&&(r=0,o="white");const C=jt(o);I.beginFill(C,r),I.drawRect(this.position[0],this.position[1],this.dimensions[0],this.dimensions[1])}},{key:"getLabelColor",value:function(){return this.options.labelColor&&this.options.labelColor!=="[glyph-color]"?this.options.labelColor:this.options.lineStrokeColor||this.options.barFillColor||"black"}},{key:"getName",value:function(){return this.options.name?this.options.name:this.tilesetInfo&&this.tilesetInfo.name||""}},{key:"drawLabel",value:function(){if(!this.labelText)return;const I=this.pLabel;if(I.clear(),!this.options||!this.options.labelPosition||this.options.labelPosition==="hidden"){this.labelText.alpha=0;return}const{labelBackgroundColor:r="white",labelBackgroundOpacity:o=.5}=this.options;I.beginFill(jt(r),+o);const C=jt(this.getLabelColor()),a=2;if(this.dimensions[0]<0)return;let A=this.options.labelShowAssembly&&this.tilesetInfo&&this.tilesetInfo.coordSystem?`${this.tilesetInfo.coordSystem} | `:"";if(A+=this.getName(),this.options.labelShowResolution&&GDt(this.tilesetInfo)&&this.tilesetInfo.bins_per_dimension){const d=aig(this.calculateZoomLevel(),this.tilesetInfo.max_width,this.tilesetInfo.bins_per_dimension,this.tilesetInfo.max_zoom);A+=` +[Current data resolution: ${d}]`}else if(this.options.labelShowResolution&&vDt(this.tilesetInfo)){const d=Cig(this.tilesetInfo.resolutions,this.calculateZoomLevel());A+=` +[Current data resolution: ${d}]`}if(this.options&&this.options.dataTransform){let d=null;if(this.tilesetInfo&&this.tilesetInfo.transforms)for(const h of this.tilesetInfo.transforms)h.value===this.options.dataTransform&&(d=h);d?A+=` +[Transform: ${d.name}]`:this.options.dataTransform==="None"?A+=` +[Transform: None ]`:A+=` +[Transform: Default ]`}this.labelText.text=A,this.labelText.style={fontSize:`${this.labelTextFontSize}px`,fontFamily:this.labelTextFontFamily,fill:C},this.labelText.alpha=typeof this.options.labelTextOpacity<"u"?this.options.labelTextOpacity:1,this.labelText.visible=!0,this.flipText&&(this.labelText.scale.x=-1);const{labelLeftMargin:s=0,labelRightMargin:l=0,labelTopMargin:c=0,labelBottomMargin:u=0}=this.options;this.options.labelPosition==="topLeft"?(this.labelText.x=this.position[0]+s+this.labelXOffset,this.labelText.y=this.position[1]+c,this.labelText.anchor.x=.5,this.labelText.anchor.y=0,this.labelText.x+=this.labelText.width/2,I.drawRect(this.position[0]+s+this.labelXOffset,this.position[1]+c,this.labelText.width+a,this.labelText.height+a)):this.options.labelPosition==="bottomLeft"&&!this.flipText||this.options.labelPosition==="topRight"&&this.flipText?(this.labelText.x=this.position[0]+(s||c),this.labelText.y=this.position[1]+this.dimensions[1]-(u||l),this.labelText.anchor.x=.5,this.labelText.anchor.y=1,this.labelText.x+=this.labelText.width/2+this.labelXOffset,I.drawRect(this.position[0]+(s||c)+this.labelXOffset,this.position[1]+this.dimensions[1]-this.labelText.height-a-(u||l),this.labelText.width+a,this.labelText.height+a)):this.options.labelPosition==="topRight"&&!this.flipText||this.options.labelPosition==="bottomLeft"&&this.flipText?(this.labelText.x=this.position[0]+this.dimensions[0]-(l||u),this.labelText.y=this.position[1]+(c||s),this.labelText.anchor.x=.5,this.labelText.anchor.y=0,this.labelText.x-=this.labelText.width/2+this.labelXOffset,I.drawRect(this.position[0]+this.dimensions[0]-this.labelText.width-a-(l||u)-this.labelXOffset,this.position[1]+(c||s),this.labelText.width+a,this.labelText.height+a)):this.options.labelPosition==="bottomRight"?(this.labelText.x=this.position[0]+this.dimensions[0]-l,this.labelText.y=this.position[1]+this.dimensions[1]-u,this.labelText.anchor.x=.5,this.labelText.anchor.y=1,this.labelText.x-=this.labelText.width/2+this.labelXOffset,I.drawRect(this.position[0]+this.dimensions[0]-this.labelText.width-a-l-this.labelXOffset,this.position[1]+this.dimensions[1]-this.labelText.height-a-u,this.labelText.width+a,this.labelText.height+a)):this.options.labelPosition==="outerLeft"&&!this.flipText||this.options.labelPosition==="outerTop"&&this.flipText?(this.labelText.x=this.position[0],this.labelText.y=this.position[1]+this.dimensions[1]/2,this.labelText.anchor.x=.5,this.labelText.anchor.y=.5,this.labelText.x-=this.labelText.width/2+3):this.options.labelPosition==="outerTop"&&!this.flipText||this.options.labelPosition==="outerLeft"&&this.flipText?(this.labelText.x=this.position[0]+this.dimensions[0]/2,this.labelText.y=this.position[1],this.labelText.anchor.x=.5,this.labelText.anchor.y=.5,this.labelText.y-=this.labelText.height/2+3):this.options.labelPosition==="outerBottom"&&!this.flipText||this.options.labelPosition==="outerRight"&&this.flipText?(this.labelText.x=this.position[0]+this.dimensions[0]/2,this.labelText.y=this.position[1]+this.dimensions[1],this.labelText.anchor.x=.5,this.labelText.anchor.y=.5,this.labelText.y+=this.labelText.height/2+3):this.options.labelPosition==="outerRight"&&!this.flipText||this.options.labelPosition==="outerBottom"&&this.flipText?(this.labelText.x=this.position[0]+this.dimensions[0],this.labelText.y=this.position[1]+this.dimensions[1]/2,this.labelText.anchor.x=.5,this.labelText.anchor.y=.5,this.labelText.x+=this.labelText.width/2+3):this.labelText.visible=!1,this.options.labelPosition==="outerLeft"||this.options.labelPosition==="outerRight"||this.options.labelPosition==="outerTop"||this.options.labelPosition==="outerBottom"?this.pLabel.setParent(this.pBase):this.pLabel.setParent(this.pMasked)}},{key:"rerender",value:function(I){this.options=I,this.draw(),this.drawBackground(),this.drawLabel(),this.drawError(),this.drawBorder()}},{key:"draw",value:function(){this.drawError()}},{key:"exportSVG",value:function(){const I=document.createElement("g"),r=document.createElement("rect");r.setAttribute("x",`${this.position[0]}`),r.setAttribute("y",`${this.position[1]}`),r.setAttribute("width",`${this.dimensions[0]}`),r.setAttribute("height",`${this.dimensions[1]}`),this.options&&this.options.backgroundColor?r.setAttribute("fill",this.options.backgroundColor):r.setAttribute("fill-opacity","0");const o=document.createElement("g");o.setAttribute("class","g-clipped"),I.appendChild(o),o.appendChild(r);const C=document.createElement("g");o.setAttribute("class","g-track"),o.appendChild(C);const a=document.createElement("g");o.setAttribute("class","g-labels"),o.appendChild(a);const A=document.createElementNS("http://www.w3.org/2000/svg","clipPath");I.appendChild(A);const s=document.createElementNS("http://www.w3.org/2000/svg","polygon");A.appendChild(s),s.setAttribute("points",`${this.position[0]},${this.position[1]} ${this.position[0]+this.dimensions[0]},${this.position[1]} ${this.position[0]+this.dimensions[0]},${this.position[1]+this.dimensions[1]} ${this.position[0]},${this.position[1]+this.dimensions[1]} `);const l=Ng.nice();A.setAttribute("id",l),o.setAttribute("style",`clip-path:url(#${l});`);const c=this.labelText.text.split(` +`);let u=0;const d=3,h=(this.labelTextFontSize+2)*c.length+d;this.labelText.anchor.y===.5?u=h/2:this.labelText.anchor.y===1&&(u=-h);for(let f=0;fnew e(n,i)))}return Aig(e,[{key:"registerFileUrl",value:async function({server:i,url:n,filetype:I,coordSystem:r}){const o=`${dP(i)}/register_url/`;return fetch(o,{method:"POST",body:JSON.stringify({fileurl:n,filetype:I,coordSystem:r}),headers:{"Content-Type":"application/json; charset=utf-8"}})}},{key:"tilesetInfo",value:function(i){const{server:n,url:I,filetype:r,coordSystem:o}=this.dataConfig;return n&&I&&r?this.registerFileUrl({server:n,url:I,filetype:r,coordSystem:o}).then(C=>C.json()).then(C=>{this.dataConfig.tilesetUid=C.uid,this.tilesetInfoAfterRegister(i)}).catch(C=>{console.error("Error registering url",C)}):new Promise(()=>{this.tilesetInfoAfterRegister(i)})}},{key:"tilesetInfoAfterRegister",value:function(i){if(this.dataConfig.children){const n=this.dataConfig.children.map(I=>new Promise(r=>{I.tilesetInfo(r)}));Promise.all(n).then(I=>{i(I[0])})}else{const{server:n,tilesetUid:I}=this.dataConfig;!n||!I?(console.warn("No dataConfig children, server or tilesetUid:",this.dataConfig),i(null)):Nt.trackInfo(n,I,r=>{this.dataConfig.tilesetInfo=r[I],i(r[I],I)},r=>{this.tilesetInfoLoading=!1,i({error:r})},this.pubSub)}}},{key:"fullTileId",value:function(i,n){return`${i}.${n}`}},{key:"fetchTilesDebounced",value:function(i,n){var I;if(this.dataConfig.type==="horizontal-section")return this.fetchHorizontalSection(i,n);if(this.dataConfig.type==="vertical-section")return this.fetchHorizontalSection(i,n,!0);if(!this.dataConfig.children&&this.dataConfig.tilesetUid)return new Promise(C=>{Nt.fetchTilesDebounced({id:Ng.nice(),server:this.dataConfig.server,done:C,ids:n.map(a=>`${this.dataConfig.tilesetUid}.${a}`),options:this.dataConfig.options},this.pubSub,!0)}).then(C=>{const a=hi(C)[0].tilesetUid,A={};for(let s=0;snew Promise(C=>{o.fetchTilesDebounced(C,n)})))??[];return Promise.all(r).then(o=>{if(this.dataConfig.type==="divided"&&uig(o)){const C=this.makeDivided(o,n);return i(C),C}return console.warn("Unimplemented dataConfig type. Returning first data source.",this.dataConfig),i(o[0]),o[0]})}},{key:"divideData",value:function(i,n){const I=new Float32Array(i.length);for(let r=0;r+p).sort((p,y)=>y-p);h=Nt.calculateTilesFromResolution(b[c],d,a.min_pos[I?1:0],a.max_pos[I?1:0])}else h=Nt.calculateTiles(c,d,a.min_pos[I?1:0],a.max_pos[I?1:0],a.max_zoom,a.max_width);const f=[u,h[0]].sort((b,p)=>b-p);f[0]===u?o.push(!1):o.push(!0);const m=`${c}.${f[0]}.${f[1]}`;r.push(m)}return new Promise(s=>{Nt.fetchTilesDebounced({id:Ng.nice(),server:this.dataConfig.server,done:s,ids:r.map(l=>`${this.dataConfig.tilesetUid}.${l}`)},this.pubSub,!0)}).then(s=>{const l=hi(s)[0].tilesetUid,c={};for(let u=0;u=0;)e[g]=0}var mig=0,I7e=1,pig=2,big=3,yig=258,jse=29,qT=256,n9=qT+1+jse,jv=30,$se=19,r7e=2*n9+1,G0=15,pQ=16,Zig=7,qse=256,o7e=16,C7e=17,a7e=18,mee=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],r5=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Gig=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],s7e=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],vig=512,Yu=new Array((n9+2)*2);Q1(Yu);var aW=new Array(jv*2);Q1(aW);var I9=new Array(vig);Q1(I9);var r9=new Array(yig-big+1);Q1(r9);var eAe=new Array(jse);Q1(eAe);var lE=new Array(jv);Q1(lE);function bQ(e,g,i,n,I){this.static_tree=e,this.extra_bits=g,this.extra_base=i,this.elems=n,this.max_length=I,this.has_stree=e&&e.length}var A7e,l7e,c7e;function yQ(e,g){this.dyn_tree=e,this.max_code=0,this.stat_desc=g}function u7e(e){return e<256?I9[e]:I9[256+(e>>>7)]}function o9(e,g){e.pending_buf[e.pending++]=g&255,e.pending_buf[e.pending++]=g>>>8&255}function yC(e,g,i){e.bi_valid>pQ-i?(e.bi_buf|=g<>pQ-e.bi_valid,e.bi_valid+=i-pQ):(e.bi_buf|=g<>>=1,i<<=1;while(--g>0);return i>>>1}function Big(e){e.bi_valid===16?(o9(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function wig(e,g){var i=g.dyn_tree,n=g.max_code,I=g.stat_desc.static_tree,r=g.stat_desc.has_stree,o=g.stat_desc.extra_bits,C=g.stat_desc.extra_base,a=g.stat_desc.max_length,A,s,l,c,u,d,h=0;for(c=0;c<=G0;c++)e.bl_count[c]=0;for(i[e.heap[e.heap_max]*2+1]=0,A=e.heap_max+1;Aa&&(c=a,h++),i[s*2+1]=c,!(s>n)&&(e.bl_count[c]++,u=0,s>=C&&(u=o[s-C]),d=i[s*2],e.opt_len+=d*(c+u),r&&(e.static_len+=d*(I[s*2+1]+u)));if(h!==0){do{for(c=a-1;e.bl_count[c]===0;)c--;e.bl_count[c]--,e.bl_count[c+1]+=2,e.bl_count[a]--,h-=2}while(h>0);for(c=a;c!==0;c--)for(s=e.bl_count[c];s!==0;)l=e.heap[--A],!(l>n)&&(i[l*2+1]!==c&&(e.opt_len+=(c-i[l*2+1])*i[l*2],i[l*2+1]=c),s--)}}function h7e(e,g,i){var n=new Array(G0+1),I=0,r,o;for(r=1;r<=G0;r++)n[r]=I=I+i[r-1]<<1;for(o=0;o<=g;o++){var C=e[o*2+1];C!==0&&(e[o*2]=d7e(n[C]++,C))}}function Sig(){var e,g,i,n,I,r=new Array(G0+1);for(i=0,n=0;n>=7;n8?o9(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function Rig(e,g,i,n){m7e(e),n&&(o9(e,i),o9(e,~i)),dig.arraySet(e.pending_buf,e.window,g,i,e.pending),e.pending+=i}function ySe(e,g,i,n){var I=g*2,r=i*2;return e[I]>1;o>=1;o--)ZQ(e,i,o);A=r;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ZQ(e,i,1),C=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=C,i[A*2]=i[o*2]+i[C*2],e.depth[A]=(e.depth[o]>=e.depth[C]?e.depth[o]:e.depth[C])+1,i[o*2+1]=i[C*2+1]=A,e.heap[1]=A++,ZQ(e,i,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],wig(e,g),h7e(i,a,e.bl_count)}function GSe(e,g,i){var n,I=-1,r,o=g[0*2+1],C=0,a=7,A=4;for(o===0&&(a=138,A=3),g[(i+1)*2+1]=65535,n=0;n<=i;n++)r=o,o=g[(n+1)*2+1],!(++C=3&&e.bl_tree[s7e[g]*2+1]===0;g--);return e.opt_len+=3*(g+1)+5+5+4,g}function Wig(e,g,i,n){var I;for(yC(e,g-257,5),yC(e,i-1,5),yC(e,n-4,4),I=0;I>>=1)if(g&1&&e.dyn_ltree[i*2]!==0)return pSe;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return bSe;for(i=32;i0?(e.strm.data_type===fig&&(e.strm.data_type=Xig(e)),pee(e,e.l_desc),pee(e,e.d_desc),o=Vig(e),I=e.opt_len+3+7>>>3,r=e.static_len+3+7>>>3,r<=I&&(I=r)):I=r=i+5,i+4<=I&&g!==-1?p7e(e,g,i,n):e.strategy===hig||r===I?(yC(e,(I7e<<1)+(n?1:0),3),ZSe(e,Yu,aW)):(yC(e,(pig<<1)+(n?1:0),3),Wig(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),ZSe(e,e.dyn_ltree,e.dyn_dtree)),f7e(e),n&&m7e(e)}function kig(e,g,i){return e.pending_buf[e.d_buf+e.last_lit*2]=g>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=g&255,e.pending_buf[e.l_buf+e.last_lit]=i&255,e.last_lit++,g===0?e.dyn_ltree[i*2]++:(e.matches++,g--,e.dyn_ltree[(r9[i]+qT+1)*2]++,e.dyn_dtree[u7e(g)*2]++),e.last_lit===e.lit_bufsize-1}U1._tr_init=Tig;U1._tr_stored_block=p7e;U1._tr_flush_block=Nig;U1._tr_tally=kig;U1._tr_align=Hig;function Yig(e,g,i,n){for(var I=e&65535|0,r=e>>>16&65535|0,o=0;i!==0;){o=i>2e3?2e3:i,i-=o;do I=I+g[n++]|0,r=r+I|0;while(--o);I%=65521,r%=65521}return I|r<<16|0}var b7e=Yig;function Kig(){for(var e,g=[],i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;g[i]=e}return g}var xig=Kig();function Fig(e,g,i,n){var I=xig,r=n+i;e^=-1;for(var o=n;o>>8^I[(e^g[o])&255];return e^-1}var y7e=Fig,tAe={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},yo=nh,os=U1,Z7e=b7e,Fh=y7e,Eig=tAe,nZ=0,Dig=1,Mig=3,jf=4,wSe=5,Ml=0,SSe=1,Cs=-2,zig=-3,GQ=-5,Pig=-1,_ig=1,Uk=2,Oig=3,Jig=4,Lig=0,Uig=2,C_=8,Qig=9,jig=15,$ig=8,qig=29,eng=256,bee=eng+1+qig,tng=30,gng=19,ing=2*bee+1,nng=15,Og=3,wf=258,YA=wf+Og+1,Ing=32,a_=42,yee=69,o5=73,C5=91,a5=103,v0=113,NV=666,pI=1,eH=2,zb=3,j1=4,rng=3;function Sf(e,g){return e.msg=Eig[g],g}function RSe(e){return(e<<1)-(e>4?9:0)}function Cf(e){for(var g=e.length;--g>=0;)e[g]=0}function Eh(e){var g=e.state,i=g.pending;i>e.avail_out&&(i=e.avail_out),i!==0&&(yo.arraySet(e.output,g.pending_buf,g.pending_out,i,e.next_out),e.next_out+=i,g.pending_out+=i,e.total_out+=i,e.avail_out-=i,g.pending-=i,g.pending===0&&(g.pending_out=0))}function lr(e,g){os._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,g),e.block_start=e.strstart,Eh(e.strm)}function Ii(e,g){e.pending_buf[e.pending++]=g}function RR(e,g){e.pending_buf[e.pending++]=g>>>8&255,e.pending_buf[e.pending++]=g&255}function ong(e,g,i,n){var I=e.avail_in;return I>n&&(I=n),I===0?0:(e.avail_in-=I,yo.arraySet(g,e.input,e.next_in,I,i),e.state.wrap===1?e.adler=Z7e(e.adler,g,I,i):e.state.wrap===2&&(e.adler=Fh(e.adler,g,I,i)),e.next_in+=I,e.total_in+=I,I)}function G7e(e,g){var i=e.max_chain_length,n=e.strstart,I,r,o=e.prev_length,C=e.nice_match,a=e.strstart>e.w_size-YA?e.strstart-(e.w_size-YA):0,A=e.window,s=e.w_mask,l=e.prev,c=e.strstart+wf,u=A[n+o-1],d=A[n+o];e.prev_length>=e.good_match&&(i>>=2),C>e.lookahead&&(C=e.lookahead);do if(I=g,!(A[I+o]!==d||A[I+o-1]!==u||A[I]!==A[n]||A[++I]!==A[n+1])){n+=2,I++;do;while(A[++n]===A[++I]&&A[++n]===A[++I]&&A[++n]===A[++I]&&A[++n]===A[++I]&&A[++n]===A[++I]&&A[++n]===A[++I]&&A[++n]===A[++I]&&A[++n]===A[++I]&&no){if(e.match_start=g,o=r,r>=C)break;u=A[n+o-1],d=A[n+o]}}while((g=l[g&s])>a&&--i!==0);return o<=e.lookahead?o:e.lookahead}function Pb(e){var g=e.w_size,i,n,I,r,o;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=g+(g-YA)){yo.arraySet(e.window,e.window,g,g,0),e.match_start-=g,e.strstart-=g,e.block_start-=g,n=e.hash_size,i=n;do I=e.head[--i],e.head[i]=I>=g?I-g:0;while(--n);n=g,i=n;do I=e.prev[--i],e.prev[i]=I>=g?I-g:0;while(--n);r+=g}if(e.strm.avail_in===0)break;if(n=ong(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=Og)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Pb(e),e.lookahead===0&&g===nZ)return pI;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+i;if((e.strstart===0||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,lr(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-YA&&(lr(e,!1),e.strm.avail_out===0))return pI}return e.insert=0,g===jf?(lr(e,!0),e.strm.avail_out===0?zb:j1):(e.strstart>e.block_start&&(lr(e,!1),e.strm.avail_out===0),pI)}function vQ(e,g){for(var i,n;;){if(e.lookahead=Og&&(e.ins_h=(e.ins_h<=Og)if(n=os._tr_tally(e,e.strstart-e.match_start,e.match_length-Og),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Og){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<=Og&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=Og-1)),e.prev_length>=Og&&e.match_length<=e.prev_length){I=e.strstart+e.lookahead-Og,n=os._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-Og),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=I&&(e.ins_h=(e.ins_h<=Og&&e.strstart>0&&(I=e.strstart-1,n=o[I],n===o[++I]&&n===o[++I]&&n===o[++I])){r=e.strstart+wf;do;while(n===o[++I]&&n===o[++I]&&n===o[++I]&&n===o[++I]&&n===o[++I]&&n===o[++I]&&n===o[++I]&&n===o[++I]&&Ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Og?(i=os._tr_tally(e,1,e.match_length-Og),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=os._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(lr(e,!1),e.strm.avail_out===0))return pI}return e.insert=0,g===jf?(lr(e,!0),e.strm.avail_out===0?zb:j1):e.last_lit&&(lr(e,!1),e.strm.avail_out===0)?pI:eH}function sng(e,g){for(var i;;){if(e.lookahead===0&&(Pb(e),e.lookahead===0)){if(g===nZ)return pI;break}if(e.match_length=0,i=os._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(lr(e,!1),e.strm.avail_out===0))return pI}return e.insert=0,g===jf?(lr(e,!0),e.strm.avail_out===0?zb:j1):e.last_lit&&(lr(e,!1),e.strm.avail_out===0)?pI:eH}function bl(e,g,i,n,I){this.good_length=e,this.max_lazy=g,this.nice_length=i,this.max_chain=n,this.func=I}var mv;mv=[new bl(0,0,0,0,Cng),new bl(4,4,8,4,vQ),new bl(4,5,16,8,vQ),new bl(4,6,32,32,vQ),new bl(4,4,16,16,tG),new bl(8,16,32,32,tG),new bl(8,16,128,128,tG),new bl(8,32,128,256,tG),new bl(32,128,258,1024,tG),new bl(32,258,258,4096,tG)];function Ang(e){e.window_size=2*e.w_size,Cf(e.head),e.max_lazy_match=mv[e.level].max_lazy,e.good_match=mv[e.level].good_length,e.nice_match=mv[e.level].nice_length,e.max_chain_length=mv[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=Og-1,e.match_available=0,e.ins_h=0}function lng(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=C_,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new yo.Buf16(ing*2),this.dyn_dtree=new yo.Buf16((2*tng+1)*2),this.bl_tree=new yo.Buf16((2*gng+1)*2),Cf(this.dyn_ltree),Cf(this.dyn_dtree),Cf(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new yo.Buf16(nng+1),this.heap=new yo.Buf16(2*bee+1),Cf(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new yo.Buf16(2*bee+1),Cf(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function v7e(e){var g;return!e||!e.state?Sf(e,Cs):(e.total_in=e.total_out=0,e.data_type=Uig,g=e.state,g.pending=0,g.pending_out=0,g.wrap<0&&(g.wrap=-g.wrap),g.status=g.wrap?a_:v0,e.adler=g.wrap===2?0:1,g.last_flush=nZ,os._tr_init(g),Ml)}function B7e(e){var g=v7e(e);return g===Ml&&Ang(e.state),g}function cng(e,g){return!e||!e.state||e.state.wrap!==2?Cs:(e.state.gzhead=g,Ml)}function w7e(e,g,i,n,I,r){if(!e)return Cs;var o=1;if(g===Pig&&(g=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),I<1||I>Qig||i!==C_||n<8||n>15||g<0||g>9||r<0||r>Jig)return Sf(e,Cs);n===8&&(n=9);var C=new lng;return e.state=C,C.strm=e,C.wrap=o,C.gzhead=null,C.w_bits=n,C.w_size=1<wSe||g<0)return e?Sf(e,Cs):Cs;if(n=e.state,!e.output||!e.input&&e.avail_in!==0||n.status===NV&&g!==jf)return Sf(e,e.avail_out===0?GQ:Cs);if(n.strm=e,i=n.last_flush,n.last_flush=g,n.status===a_)if(n.wrap===2)e.adler=0,Ii(n,31),Ii(n,139),Ii(n,8),n.gzhead?(Ii(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),Ii(n,n.gzhead.time&255),Ii(n,n.gzhead.time>>8&255),Ii(n,n.gzhead.time>>16&255),Ii(n,n.gzhead.time>>24&255),Ii(n,n.level===9?2:n.strategy>=Uk||n.level<2?4:0),Ii(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(Ii(n,n.gzhead.extra.length&255),Ii(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Fh(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=yee):(Ii(n,0),Ii(n,0),Ii(n,0),Ii(n,0),Ii(n,0),Ii(n,n.level===9?2:n.strategy>=Uk||n.level<2?4:0),Ii(n,rng),n.status=v0);else{var o=C_+(n.w_bits-8<<4)<<8,C=-1;n.strategy>=Uk||n.level<2?C=0:n.level<6?C=1:n.level===6?C=2:C=3,o|=C<<6,n.strstart!==0&&(o|=Ing),o+=31-o%31,n.status=v0,RR(n,o),n.strstart!==0&&(RR(n,e.adler>>>16),RR(n,e.adler&65535)),e.adler=1}if(n.status===yee)if(n.gzhead.extra){for(I=n.pending;n.gzindex<(n.gzhead.extra.length&65535)&&!(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>I&&(e.adler=Fh(e.adler,n.pending_buf,n.pending-I,I)),Eh(e),I=n.pending,n.pending===n.pending_buf_size));)Ii(n,n.gzhead.extra[n.gzindex]&255),n.gzindex++;n.gzhead.hcrc&&n.pending>I&&(e.adler=Fh(e.adler,n.pending_buf,n.pending-I,I)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=o5)}else n.status=o5;if(n.status===o5)if(n.gzhead.name){I=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>I&&(e.adler=Fh(e.adler,n.pending_buf,n.pending-I,I)),Eh(e),I=n.pending,n.pending===n.pending_buf_size)){r=1;break}n.gzindexI&&(e.adler=Fh(e.adler,n.pending_buf,n.pending-I,I)),r===0&&(n.gzindex=0,n.status=C5)}else n.status=C5;if(n.status===C5)if(n.gzhead.comment){I=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>I&&(e.adler=Fh(e.adler,n.pending_buf,n.pending-I,I)),Eh(e),I=n.pending,n.pending===n.pending_buf_size)){r=1;break}n.gzindexI&&(e.adler=Fh(e.adler,n.pending_buf,n.pending-I,I)),r===0&&(n.status=a5)}else n.status=a5;if(n.status===a5&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&Eh(e),n.pending+2<=n.pending_buf_size&&(Ii(n,e.adler&255),Ii(n,e.adler>>8&255),e.adler=0,n.status=v0)):n.status=v0),n.pending!==0){if(Eh(e),e.avail_out===0)return n.last_flush=-1,Ml}else if(e.avail_in===0&&RSe(g)<=RSe(i)&&g!==jf)return Sf(e,GQ);if(n.status===NV&&e.avail_in!==0)return Sf(e,GQ);if(e.avail_in!==0||n.lookahead!==0||g!==nZ&&n.status!==NV){var a=n.strategy===Uk?sng(n,g):n.strategy===Oig?ang(n,g):mv[n.level].func(n,g);if((a===zb||a===j1)&&(n.status=NV),a===pI||a===zb)return e.avail_out===0&&(n.last_flush=-1),Ml;if(a===eH&&(g===Dig?os._tr_align(n):g!==wSe&&(os._tr_stored_block(n,0,0,!1),g===Mig&&(Cf(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),Eh(e),e.avail_out===0))return n.last_flush=-1,Ml}return g!==jf?Ml:n.wrap<=0?SSe:(n.wrap===2?(Ii(n,e.adler&255),Ii(n,e.adler>>8&255),Ii(n,e.adler>>16&255),Ii(n,e.adler>>24&255),Ii(n,e.total_in&255),Ii(n,e.total_in>>8&255),Ii(n,e.total_in>>16&255),Ii(n,e.total_in>>24&255)):(RR(n,e.adler>>>16),RR(n,e.adler&65535)),Eh(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?Ml:SSe)}function hng(e){var g;return!e||!e.state?Cs:(g=e.state.status,g!==a_&&g!==yee&&g!==o5&&g!==C5&&g!==a5&&g!==v0&&g!==NV?Sf(e,Cs):(e.state=null,g===v0?Sf(e,zig):Ml))}function fng(e,g){var i=g.length,n,I,r,o,C,a,A,s;if(!e||!e.state||(n=e.state,o=n.wrap,o===2||o===1&&n.status!==a_||n.lookahead))return Cs;for(o===1&&(e.adler=Z7e(e.adler,g,i,0)),n.wrap=0,i>=n.w_size&&(o===0&&(Cf(n.head),n.strstart=0,n.block_start=0,n.insert=0),s=new yo.Buf8(n.w_size),yo.arraySet(s,g,i-n.w_size,n.w_size,0),g=s,i=n.w_size),C=e.avail_in,a=e.next_in,A=e.input,e.avail_in=i,e.next_in=0,e.input=g,Pb(n);n.lookahead>=Og;){I=n.strstart,r=n.lookahead-(Og-1);do n.ins_h=(n.ins_h<=252?6:Rh>=248?5:Rh>=240?4:Rh>=224?3:Rh>=192?2:1;C9[254]=C9[254]=1;IZ.string2buf=function(e){var g,i,n,I,r,o=e.length,C=0;for(I=0;I>>6,g[r++]=128|i&63):i<65536?(g[r++]=224|i>>>12,g[r++]=128|i>>>6&63,g[r++]=128|i&63):(g[r++]=240|i>>>18,g[r++]=128|i>>>12&63,g[r++]=128|i>>>6&63,g[r++]=128|i&63);return g};function V7e(e,g){if(g<65534&&(e.subarray&&R7e||!e.subarray&&S7e))return String.fromCharCode.apply(null,s_.shrinkBuf(e,g));for(var i="",n=0;n4){C[n++]=65533,i+=r-1;continue}for(I&=r===2?31:r===3?15:7;r>1&&i1){C[n++]=65533;continue}I<65536?C[n++]=I:(I-=65536,C[n++]=55296|I>>10&1023,C[n++]=56320|I&1023)}return V7e(C,n)};IZ.utf8border=function(e,g){var i;for(g=g||e.length,g>e.length&&(g=e.length),i=g-1;i>=0&&(e[i]&192)===128;)i--;return i<0||i===0?g:i+C9[e[i]]>g?i:g};function mng(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var W7e=mng,sW=jc,AW=nh,Zee=IZ,Gee=tAe,png=W7e,X7e=Object.prototype.toString,bng=0,BQ=4,$v=0,VSe=1,WSe=2,yng=-1,Zng=0,Gng=8;function _b(e){if(!(this instanceof _b))return new _b(e);this.options=AW.assign({level:yng,method:Gng,chunkSize:16384,windowBits:15,memLevel:8,strategy:Zng,to:""},e||{});var g=this.options;g.raw&&g.windowBits>0?g.windowBits=-g.windowBits:g.gzip&&g.windowBits>0&&g.windowBits<16&&(g.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new png,this.strm.avail_out=0;var i=sW.deflateInit2(this.strm,g.level,g.method,g.windowBits,g.memLevel,g.strategy);if(i!==$v)throw new Error(Gee[i]);if(g.header&&sW.deflateSetHeader(this.strm,g.header),g.dictionary){var n;if(typeof g.dictionary=="string"?n=Zee.string2buf(g.dictionary):X7e.call(g.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(g.dictionary):n=g.dictionary,i=sW.deflateSetDictionary(this.strm,n),i!==$v)throw new Error(Gee[i]);this._dict_set=!0}}_b.prototype.push=function(e,g){var i=this.strm,n=this.options.chunkSize,I,r;if(this.ended)return!1;r=g===~~g?g:g===!0?BQ:bng,typeof e=="string"?i.input=Zee.string2buf(e):X7e.call(e)==="[object ArrayBuffer]"?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(i.avail_out===0&&(i.output=new AW.Buf8(n),i.next_out=0,i.avail_out=n),I=sW.deflate(i,r),I!==VSe&&I!==$v)return this.onEnd(I),this.ended=!0,!1;(i.avail_out===0||i.avail_in===0&&(r===BQ||r===WSe))&&(this.options.to==="string"?this.onData(Zee.buf2binstring(AW.shrinkBuf(i.output,i.next_out))):this.onData(AW.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||i.avail_out===0)&&I!==VSe);return r===BQ?(I=sW.deflateEnd(this.strm),this.onEnd(I),this.ended=!0,I===$v):(r===WSe&&(this.onEnd($v),i.avail_out=0),!0)};_b.prototype.onData=function(e){this.chunks.push(e)};_b.prototype.onEnd=function(e){e===$v&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=AW.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function gAe(e,g){var i=new _b(g);if(i.push(e,!0),i.err)throw i.msg||Gee[i.err];return i.result}function vng(e,g){return g=g||{},g.raw=!0,gAe(e,g)}function Bng(e,g){return g=g||{},g.gzip=!0,gAe(e,g)}$T.Deflate=_b;$T.deflate=gAe;$T.deflateRaw=vng;$T.gzip=Bng;var tH={},Il={},Qk=30,wng=12,Sng=function(g,i){var n,I,r,o,C,a,A,s,l,c,u,d,h,f,m,b,p,y,Z,v,G,B,S,R,w;n=g.state,I=g.next_in,R=g.input,r=I+(g.avail_in-5),o=g.next_out,w=g.output,C=o-(i-g.avail_out),a=o+(g.avail_out-257),A=n.dmax,s=n.wsize,l=n.whave,c=n.wnext,u=n.window,d=n.hold,h=n.bits,f=n.lencode,m=n.distcode,b=(1<>>24,d>>>=Z,h-=Z,Z=y>>>16&255,Z===0)w[o++]=y&65535;else if(Z&16){v=y&65535,Z&=15,Z&&(h>>=Z,h-=Z),h<15&&(d+=R[I++]<>>24,d>>>=Z,h-=Z,Z=y>>>16&255,Z&16){if(G=y&65535,Z&=15,hA){g.msg="invalid distance too far back",n.mode=Qk;break e}if(d>>>=Z,h-=Z,Z=o-C,G>Z){if(Z=G-Z,Z>l&&n.sane){g.msg="invalid distance too far back",n.mode=Qk;break e}if(B=0,S=u,c===0){if(B+=s-Z,Z2;)w[o++]=S[B++],w[o++]=S[B++],w[o++]=S[B++],v-=3;v&&(w[o++]=S[B++],v>1&&(w[o++]=S[B++]))}else{B=o-G;do w[o++]=w[B++],w[o++]=w[B++],w[o++]=w[B++],v-=3;while(v>2);v&&(w[o++]=w[B++],v>1&&(w[o++]=w[B++]))}}else if(Z&64){g.msg="invalid distance code",n.mode=Qk;break e}else{y=m[(y&65535)+(d&(1<>3,I-=v,h-=v<<3,d&=(1<=1&&T[u]===0;u--);if(d>u&&(d=u),u===0)return r[o++]=1<<24|64<<16|0,r[o++]=1<<24|64<<16|0,a.bits=1,0;for(c=1;c0&&(g===NSe||u!==1))return-1;for(W[1]=0,s=1;sTSe||g===kSe&&b>HSe)return 1;for(;;){N=s-f,C[l]w?(Y=V[X+C[l]],x=S[R+C[l]]):(Y=32+64,x=0),y=1<>f)+Z]=N<<24|Y<<16|x|0;while(Z!==0);for(y=1<>=1;if(y!==0?(p&=y-1,p+=y):p=0,l++,--T[s]===0){if(s===u)break;s=i[n+C[l]]}if(s>d&&(p&G)!==v){for(f===0&&(f=d),B+=c,h=s-f,m=1<TSe||g===kSe&&b>HSe)return 1;v=p&G,r[v]=d<<24|h<<16|B-o|0}}return p!==0&&(r[B+p]=s-f<<24|64<<16|0),a.bits=d,0},Aa=nh,vee=b7e,yl=y7e,Hng=Sng,lW=Tng,Nng=0,T7e=1,H7e=2,YSe=4,kng=5,jk=6,Ob=0,Yng=1,Kng=2,ds=-2,N7e=-3,k7e=-4,xng=-5,KSe=8,Y7e=1,xSe=2,FSe=3,ESe=4,DSe=5,MSe=6,zSe=7,PSe=8,_Se=9,OSe=10,cE=11,pu=12,SQ=13,JSe=14,RQ=15,LSe=16,USe=17,QSe=18,jSe=19,$k=20,qk=21,$Se=22,qSe=23,eRe=24,tRe=25,gRe=26,VQ=27,iRe=28,nRe=29,on=30,K7e=31,Fng=32,Eng=852,Dng=592,Mng=15,zng=Mng;function IRe(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function Png(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Aa.Buf16(320),this.work=new Aa.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function x7e(e){var g;return!e||!e.state?ds:(g=e.state,e.total_in=e.total_out=g.total=0,e.msg="",g.wrap&&(e.adler=g.wrap&1),g.mode=Y7e,g.last=0,g.havedict=0,g.dmax=32768,g.head=null,g.hold=0,g.bits=0,g.lencode=g.lendyn=new Aa.Buf32(Eng),g.distcode=g.distdyn=new Aa.Buf32(Dng),g.sane=1,g.back=-1,Ob)}function F7e(e){var g;return!e||!e.state?ds:(g=e.state,g.wsize=0,g.whave=0,g.wnext=0,x7e(e))}function E7e(e,g){var i,n;return!e||!e.state||(n=e.state,g<0?(i=0,g=-g):(i=(g>>4)+1,g<48&&(g&=15)),g&&(g<8||g>15))?ds:(n.window!==null&&n.wbits!==g&&(n.window=null),n.wrap=i,n.wbits=g,F7e(e))}function D7e(e,g){var i,n;return e?(n=new Png,e.state=n,n.window=null,i=E7e(e,g),i!==Ob&&(e.state=null),i):ds}function _ng(e){return D7e(e,zng)}var rRe=!0,WQ,XQ;function Ong(e){if(rRe){var g;for(WQ=new Aa.Buf32(512),XQ=new Aa.Buf32(32),g=0;g<144;)e.lens[g++]=8;for(;g<256;)e.lens[g++]=9;for(;g<280;)e.lens[g++]=7;for(;g<288;)e.lens[g++]=8;for(lW(T7e,e.lens,0,288,WQ,0,e.work,{bits:9}),g=0;g<32;)e.lens[g++]=5;lW(H7e,e.lens,0,32,XQ,0,e.work,{bits:5}),rRe=!1}e.lencode=WQ,e.lenbits=9,e.distcode=XQ,e.distbits=5}function M7e(e,g,i,n){var I,r=e.state;return r.window===null&&(r.wsize=1<=r.wsize?(Aa.arraySet(r.window,g,i-r.wsize,r.wsize,0),r.wnext=0,r.whave=r.wsize):(I=r.wsize-r.wnext,I>n&&(I=n),Aa.arraySet(r.window,g,i-n,I,r.wnext),n-=I,n?(Aa.arraySet(r.window,g,i-n,n,0),r.wnext=n,r.whave=r.wsize):(r.wnext+=I,r.wnext===r.wsize&&(r.wnext=0),r.whave>>8&255,i.check=yl(i.check,S,2,0),A=0,s=0,i.mode=xSe;break}if(i.flags=0,i.head&&(i.head.done=!1),!(i.wrap&1)||(((A&255)<<8)+(A>>8))%31){e.msg="incorrect header check",i.mode=on;break}if((A&15)!==KSe){e.msg="unknown compression method",i.mode=on;break}if(A>>>=4,s-=4,G=(A&15)+8,i.wbits===0)i.wbits=G;else if(G>i.wbits){e.msg="invalid window size",i.mode=on;break}i.dmax=1<>8&1),i.flags&512&&(S[0]=A&255,S[1]=A>>>8&255,i.check=yl(i.check,S,2,0)),A=0,s=0,i.mode=FSe;case FSe:for(;s<32;){if(C===0)break e;C--,A+=n[r++]<>>8&255,S[2]=A>>>16&255,S[3]=A>>>24&255,i.check=yl(i.check,S,4,0)),A=0,s=0,i.mode=ESe;case ESe:for(;s<16;){if(C===0)break e;C--,A+=n[r++]<>8),i.flags&512&&(S[0]=A&255,S[1]=A>>>8&255,i.check=yl(i.check,S,2,0)),A=0,s=0,i.mode=DSe;case DSe:if(i.flags&1024){for(;s<16;){if(C===0)break e;C--,A+=n[r++]<>>8&255,i.check=yl(i.check,S,2,0)),A=0,s=0}else i.head&&(i.head.extra=null);i.mode=MSe;case MSe:if(i.flags&1024&&(u=i.length,u>C&&(u=C),u&&(i.head&&(G=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),Aa.arraySet(i.head.extra,n,r,u,G)),i.flags&512&&(i.check=yl(i.check,n,u,r)),C-=u,r+=u,i.length-=u),i.length))break e;i.length=0,i.mode=zSe;case zSe:if(i.flags&2048){if(C===0)break e;u=0;do G=n[r+u++],i.head&&G&&i.length<65536&&(i.head.name+=String.fromCharCode(G));while(G&&u>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=pu;break;case OSe:for(;s<32;){if(C===0)break e;C--,A+=n[r++]<>>=s&7,s-=s&7,i.mode=VQ;break}for(;s<3;){if(C===0)break e;C--,A+=n[r++]<>>=1,s-=1,A&3){case 0:i.mode=JSe;break;case 1:if(Ong(i),i.mode=$k,g===jk){A>>>=2,s-=2;break e}break;case 2:i.mode=USe;break;case 3:e.msg="invalid block type",i.mode=on}A>>>=2,s-=2;break;case JSe:for(A>>>=s&7,s-=s&7;s<32;){if(C===0)break e;C--,A+=n[r++]<>>16^65535)){e.msg="invalid stored block lengths",i.mode=on;break}if(i.length=A&65535,A=0,s=0,i.mode=RQ,g===jk)break e;case RQ:i.mode=LSe;case LSe:if(u=i.length,u){if(u>C&&(u=C),u>a&&(u=a),u===0)break e;Aa.arraySet(I,n,r,u,o),C-=u,r+=u,a-=u,o+=u,i.length-=u;break}i.mode=pu;break;case USe:for(;s<14;){if(C===0)break e;C--,A+=n[r++]<>>=5,s-=5,i.ndist=(A&31)+1,A>>>=5,s-=5,i.ncode=(A&15)+4,A>>>=4,s-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=on;break}i.have=0,i.mode=QSe;case QSe:for(;i.have>>=3,s-=3}for(;i.have<19;)i.lens[T[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,R={bits:i.lenbits},B=lW(Nng,i.lens,0,19,i.lencode,0,i.work,R),i.lenbits=R.bits,B){e.msg="invalid code lengths set",i.mode=on;break}i.have=0,i.mode=jSe;case jSe:for(;i.have>>24,b=f>>>16&255,p=f&65535,!(m<=s);){if(C===0)break e;C--,A+=n[r++]<>>=m,s-=m,i.lens[i.have++]=p;else{if(p===16){for(w=m+2;s>>=m,s-=m,i.have===0){e.msg="invalid bit length repeat",i.mode=on;break}G=i.lens[i.have-1],u=3+(A&3),A>>>=2,s-=2}else if(p===17){for(w=m+3;s>>=m,s-=m,G=0,u=3+(A&7),A>>>=3,s-=3}else{for(w=m+7;s>>=m,s-=m,G=0,u=11+(A&127),A>>>=7,s-=7}if(i.have+u>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=on;break}for(;u--;)i.lens[i.have++]=G}}if(i.mode===on)break;if(i.lens[256]===0){e.msg="invalid code -- missing end-of-block",i.mode=on;break}if(i.lenbits=9,R={bits:i.lenbits},B=lW(T7e,i.lens,0,i.nlen,i.lencode,0,i.work,R),i.lenbits=R.bits,B){e.msg="invalid literal/lengths set",i.mode=on;break}if(i.distbits=6,i.distcode=i.distdyn,R={bits:i.distbits},B=lW(H7e,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,R),i.distbits=R.bits,B){e.msg="invalid distances set",i.mode=on;break}if(i.mode=$k,g===jk)break e;case $k:i.mode=qk;case qk:if(C>=6&&a>=258){e.next_out=o,e.avail_out=a,e.next_in=r,e.avail_in=C,i.hold=A,i.bits=s,Hng(e,c),o=e.next_out,I=e.output,a=e.avail_out,r=e.next_in,n=e.input,C=e.avail_in,A=i.hold,s=i.bits,i.mode===pu&&(i.back=-1);break}for(i.back=0;f=i.lencode[A&(1<>>24,b=f>>>16&255,p=f&65535,!(m<=s);){if(C===0)break e;C--,A+=n[r++]<>y)],m=f>>>24,b=f>>>16&255,p=f&65535,!(y+m<=s);){if(C===0)break e;C--,A+=n[r++]<>>=y,s-=y,i.back+=y}if(A>>>=m,s-=m,i.back+=m,i.length=p,b===0){i.mode=gRe;break}if(b&32){i.back=-1,i.mode=pu;break}if(b&64){e.msg="invalid literal/length code",i.mode=on;break}i.extra=b&15,i.mode=$Se;case $Se:if(i.extra){for(w=i.extra;s>>=i.extra,s-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=qSe;case qSe:for(;f=i.distcode[A&(1<>>24,b=f>>>16&255,p=f&65535,!(m<=s);){if(C===0)break e;C--,A+=n[r++]<>y)],m=f>>>24,b=f>>>16&255,p=f&65535,!(y+m<=s);){if(C===0)break e;C--,A+=n[r++]<>>=y,s-=y,i.back+=y}if(A>>>=m,s-=m,i.back+=m,b&64){e.msg="invalid distance code",i.mode=on;break}i.offset=p,i.extra=b&15,i.mode=eRe;case eRe:if(i.extra){for(w=i.extra;s>>=i.extra,s-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=on;break}i.mode=tRe;case tRe:if(a===0)break e;if(u=c-a,i.offset>u){if(u=i.offset-u,u>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=on;break}u>i.wnext?(u-=i.wnext,d=i.wsize-u):d=i.wnext-u,u>i.length&&(u=i.length),h=i.window}else h=I,d=o-i.offset,u=i.length;u>a&&(u=a),a-=u,i.length-=u;do I[o++]=h[d++];while(--u);i.length===0&&(i.mode=qk);break;case gRe:if(a===0)break e;I[o++]=i.length,a--,i.mode=qk;break;case VQ:if(i.wrap){for(;s<32;){if(C===0)break e;C--,A|=n[r++]<=0&&g.windowBits<16&&(g.windowBits=-g.windowBits,g.windowBits===0&&(g.windowBits=-15)),g.windowBits>=0&&g.windowBits<16&&!(e&&e.windowBits)&&(g.windowBits+=32),g.windowBits>15&&g.windowBits<48&&(g.windowBits&15||(g.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new qng,this.strm.avail_out=0;var i=qv.inflateInit2(this.strm,g.windowBits);if(i!==Pn.Z_OK)throw new Error(Bee[i]);if(this.header=new eIg,qv.inflateGetHeader(this.strm,this.header),g.dictionary&&(typeof g.dictionary=="string"?g.dictionary=s5.string2buf(g.dictionary):P7e.call(g.dictionary)==="[object ArrayBuffer]"&&(g.dictionary=new Uint8Array(g.dictionary)),g.raw&&(i=qv.inflateSetDictionary(this.strm,g.dictionary),i!==Pn.Z_OK)))throw new Error(Bee[i])}Jb.prototype.push=function(e,g){var i=this.strm,n=this.options.chunkSize,I=this.options.dictionary,r,o,C,a,A,s=!1;if(this.ended)return!1;o=g===~~g?g:g===!0?Pn.Z_FINISH:Pn.Z_NO_FLUSH,typeof e=="string"?i.input=s5.binstring2buf(e):P7e.call(e)==="[object ArrayBuffer]"?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(i.avail_out===0&&(i.output=new cW.Buf8(n),i.next_out=0,i.avail_out=n),r=qv.inflate(i,Pn.Z_NO_FLUSH),r===Pn.Z_NEED_DICT&&I&&(r=qv.inflateSetDictionary(this.strm,I)),r===Pn.Z_BUF_ERROR&&s===!0&&(r=Pn.Z_OK,s=!1),r!==Pn.Z_STREAM_END&&r!==Pn.Z_OK)return this.onEnd(r),this.ended=!0,!1;i.next_out&&(i.avail_out===0||r===Pn.Z_STREAM_END||i.avail_in===0&&(o===Pn.Z_FINISH||o===Pn.Z_SYNC_FLUSH))&&(this.options.to==="string"?(C=s5.utf8border(i.output,i.next_out),a=i.next_out-C,A=s5.buf2string(i.output,C),i.next_out=a,i.avail_out=n-a,a&&cW.arraySet(i.output,i.output,C,a,0),this.onData(A)):this.onData(cW.shrinkBuf(i.output,i.next_out))),i.avail_in===0&&i.avail_out===0&&(s=!0)}while((i.avail_in>0||i.avail_out===0)&&r!==Pn.Z_STREAM_END);return r===Pn.Z_STREAM_END&&(o=Pn.Z_FINISH),o===Pn.Z_FINISH?(r=qv.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Pn.Z_OK):(o===Pn.Z_SYNC_FLUSH&&(this.onEnd(Pn.Z_OK),i.avail_out=0),!0)};Jb.prototype.onData=function(e){this.chunks.push(e)};Jb.prototype.onEnd=function(e){e===Pn.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=cW.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function iAe(e,g){var i=new Jb(g);if(i.push(e,!0),i.err)throw i.msg||Bee[i.err];return i.result}function tIg(e,g){return g=g||{},g.raw=!0,iAe(e,g)}tH.Inflate=Jb;tH.inflate=iAe;tH.inflateRaw=tIg;tH.ungzip=iAe;var gIg=nh.assign,iIg=$T,nIg=tH,IIg=z7e,_7e={};gIg(_7e,iIg,nIg,IIg);var rIg=_7e;const oIg=EC(rIg);var CIg=["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"];const aIg=CIg;function sIg(e){if(typeof e!="string")throw new TypeError("input must be a string");let g=[],i,n,I={LOCUS_TAG:"LOCUS",DEFINITION_TAG:"DEFINITION",ACCESSION_TAG:"ACCESSION",VERSION_TAG:"VERSION",KEYWORDS_TAG:"KEYWORDS",SOURCE_TAG:"SOURCE",ORGANISM_TAG:"ORGANISM",REFERENCE_TAG:"REFERENCE",AUTHORS_TAG:"AUTHORS",CONSORTIUM_TAG:"CONSRTM",TITLE_TAG:"TITLE",JOURNAL_TAG:"JOURNAL",PUBMED_TAG:"PUBMED",REMARK_TAG:"REMARK",FEATURES_TAG:"FEATURES",BASE_COUNT_TAG:"BASE COUNT",ORIGIN_TAG:"ORIGIN",END_SEQUENCE_TAG:"//"},r=e.split(/\r?\n/),o,C,a,A,s,l=!1;for(let V of r){if(V===null)break;let X=B(V),N=R(V),Y=T(V),x=w(V);if(X===I.END_SEQUENCE_TAG||x?(o=X,C=null):Y&&(C=X),!(V.trim()===""||X===";")){if(!l&&o!==I.LOCUS_TAG)break;switch(o){case I.LOCUS_TAG:l=!0,f(V);break;case I.FEATURES_TAG:p(V,X,N);break;case I.ORIGIN_TAG:h(V,X);break;case I.DEFINITION_TAG:case I.ACCESSION_TAG:case I.VERSION_TAG:case I.KEYWORDS_TAG:S(o,V,o.toLowerCase());break;case I.SOURCE_TAG:C===I.ORGANISM_TAG?S(C,V,"organism"):S(X,V,"source");break;case I.REFERENCE_TAG:if(X===I.REFERENCE_TAG){const M=i.references||[];i.references=M,M.push({})}b(V,C);break;case I.END_SEQUENCE_TAG:c();break}}}return g[g.length-1]!==i&&c(),g;function c(){d(),g.push(i)}function u(){return i.features[i.features.length-1]}function d(){if(i&&i.features)for(let V=0;V0;g--){const i=Math.floor(Math.random()*(g+1)),n=e[g];e[g]=e[i],e[i]=n}return e}function pIg(e){return e.type==="filler"}function bIg(e){const g=e.end-e.start,i=e.strand===1?"+":"-",n=Ng.nice();return pIg(e)?{xStart:e.start,xEnd:e.end,strand:e.strand,fields:[],type:"filler",uid:n}:{xStart:e.start,xEnd:e.end,strand:i,chrOffset:0,importance:e.end-e.start,uid:n,type:e.type,fields:["chrom",e.start,e.end,e.name,g,i,"","",e.type,e.name,e.start.toString(),e.end.toString(),e.start.toString(),e.end.toString()]}}function yIg(e){const g=cIg(e),i=mIg(g[0].features.filter(n=>n.type!=="source").sort((n,I)=>n.start-I.start));return{json:g,features:i}}async function ZIg(e,{gzipped:g}){if(!g)return e.text();const i=await e.arrayBuffer();return oIg.inflate(i,{to:"string"})}let J7e=function(){function e(g){uIg(this,e),this.dataConfig=g,this.trackUid=Ng.nice(),this.errorTxt="";let i;if(g.url){const n=g.url.slice(g.url.length-3);i=fetch(g.url,{mode:"cors",redirect:"follow",method:"GET"}).then(I=>ZIg(I,{gzipped:n===".gz"}))}else if(g.text)i=Promise.resolve(g.text);else throw new Error("No data or URL specified");this.gbDataPromise=i.then(n=>yIg(n))}return dIg(e,[{key:"tilesetInfo",value:function(i){return this.tilesetInfoLoading=!0,this.gbDataPromise.then(n=>{this.tilesetInfoLoading=!1;const I=1024,r={name:`genbank-${this.trackUid}`,tile_size:I,max_zoom:Math.ceil(Math.log(n.json[0].size/I)/Math.log(2)),max_width:n.json[0].size,min_pos:[0],max_pos:[n.json[0].size]};return i&&i(r),r}).catch(n=>{this.tilesetInfoLoading=!1,i&&i({error:`Error parsing genbank: ${n}`})})}},{key:"fetchTilesDebounced",value:async function(i,n){const I={},r=[],o=[];for(const a of n){const A=a.split("."),s=parseInt(A[0],10),l=parseInt(A[1],10);if(Number.isNaN(l)||Number.isNaN(s)){console.warn("Invalid tile zoom or position:",s,l);continue}r.push(a),o.push(this.tile(s,l))}const C=await Promise.all(o);for(let a=0;ah.end>C&&h.starth.strand===1),s,"+"),c=CRe(A.filter(h=>h.strand!==1),s,"-"),u=[],d=20;for(let h=0;h=d);h++)r.features[h].end>=C&&r.features[h].start<=a&&u.push(r.features[h]);return[u,l,c].flatMap(h=>h.map(bIg))}}]),e}();function GIg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function aRe(e,g){for(var i=0;i`localtile.${o}`);kae(this.tilesData,"",r);for(const o of n)I[o]=this.tilesData[`localtile.${o}`];return i(I),I}},{key:"tile",value:function(i,n){}}]),e}();function SIg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function sRe(e,g){for(var i=0;ir.trackId!==I),this.taskList.push({handler:i,data:n,trackId:I})),this.taskHandle||(this.taskHandle=requestIdleCallback(this.runTaskQueue.bind(this),{timeout:this.requestIdleCallbackTimeout}))}},{key:"runTaskQueue",value:function(i){for(;(i.timeRemaining()>0||i.didTimeout)&&this.taskList.length;){const n=this.taskList.shift();n&&XIg(n)?n.handler():n&&n.handler(n.data)}this.taskList.length?this.taskHandle=requestIdleCallback(this.runTaskQueue.bind(this),{timeout:this.requestIdleCallbackTimeout}):this.taskHandle=0}}]),e}();const HIg=new TIg;function NIg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function ARe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function qu(e){return qu=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},qu(e)}function zIg(e,g,i,n,I){const r=e||I,o=0;return r==="log"&&g>0?["log",Dm().range([254,0]).domain([g+o,n+o])]:["linear",bg().range([254,0]).domain([g,n])]}let rZ=function(e){FIg(i,e);var g=EIg(i);function i(n,I){var r;NIg(this,i),r=g.call(this,n,I);const{pubSub:o,dataConfig:C,handleTilesetInfoReceived:a,animate:A,onValueScaleChanged:s}=n;return r.renderVersion=1,r.visibleTiles=new Set,r.visibleTileIds=new Set,r.renderingTiles=new Set,r.fetching=new Set,r.scale={},r.fetchedTiles={},r.tileGraphics={},r.maxZoom=0,r.medianVisibleValue=null,r.backgroundTaskScheduler=HIg,r.continuousScaling="requestIdleCallback"in window,r.valueScaleMin=null,r.fixedValueScaleMin=null,r.valueScaleMax=null,r.fixedValueScaleMax=null,r.listeners={},r.pubSub=o,r.animate=A,r.onValueScaleChanged=s,r.prevValueScale=null,n.dataFetcher?r.dataFetcher=n.dataFetcher:r.dataFetcher=new o_(C,r.pubSub),r.tilesetInfo=null,r.uuid=Ng.nice(),r.trackNotFoundText=new st.PIXI.Text("",{fontSize:"12px",fontFamily:"Arial",fill:"black"}),r.pLabel.addChild(r.trackNotFoundText),r.refreshTilesDebounced=d_e(r.refreshTiles.bind(See(r)),kF,kF),r.dataFetcher.tilesetInfo((l,c)=>{if(l){if(r.tilesetInfo=l,r.dataFetcher.dataConfig.tilesetUid||(r.dataFetcher.dataConfig.tilesetUid=c),r.tilesetUid=r.dataFetcher.dataConfig.tilesetUid,r.server=r.dataFetcher.dataConfig.server||"unknown",r.tilesetInfo&&r.tilesetInfo.chromsizes&&(r.chromInfo=uP(r.tilesetInfo.chromsizes)),"error"in r.tilesetInfo){console.warn("Error retrieving tilesetInfo:",C,r.tilesetInfo.error),r.tilesetInfo=null,r.setError(r.tilesetInfo.error);return}r.tilesetInfo.resolutions?r.maxZoom=r.tilesetInfo.resolutions.length:r.maxZoom=+r.tilesetInfo.max_zoom,r.options&&r.options.maxZoom&&(r.options.maxZoom>=0?r.maxZoom=Math.min(r.options.maxZoom,r.maxZoom):console.error("Invalid maxZoom on track:",See(r))),r.refreshTiles(),a&&a(l),r.options||(r.options={}),r.options.name=r.options.name||l.name,r.checkValueScaleLimits(),r.draw(),r.drawLabel(),r.animate()}}),r}return kIg(i,[{key:"setError",value:function(I){this.errorTextText=I,this.draw(),this.animate()}},{key:"setFixedValueScaleMin",value:function(I){Number.isNaN(+I)?this.fixedValueScaleMin=null:this.fixedValueScaleMin=+I}},{key:"setFixedValueScaleMax",value:function(I){Number.isNaN(+I)?this.fixedValueScaleMax=null:this.fixedValueScaleMax=+I}},{key:"checkValueScaleLimits",value:function(){this.valueScaleMin=typeof this.options.valueScaleMin<"u"?+this.options.valueScaleMin:null,this.fixedValueScaleMin!==null&&(this.valueScaleMin=this.fixedValueScaleMin),this.valueScaleMax=typeof this.options.valueScaleMax<"u"?+this.options.valueScaleMax:null,this.fixedValueScaleMax!==null&&(this.valueScaleMax=this.fixedValueScaleMax)}},{key:"on",value:function(I,r){this.listeners[I]||(this.listeners[I]=[]),this.listeners[I].push(r)}},{key:"off",value:function(I,r){const o=this.listeners[I].indexOf(r);o===-1||o>=this.listeners[I].length||this.listeners[I].splice(o,1)}},{key:"rerender",value:function(I){B0(qu(i.prototype),"rerender",this).call(this,I),this.renderVersion+=1,this.tilesetInfo&&(this.checkValueScaleLimits(),this.tilesetInfo.resolutions?this.maxZoom=this.tilesetInfo.resolutions.length:this.maxZoom=+this.tilesetInfo.max_zoom,this.options&&this.options.maxZoom&&(this.options.maxZoom>=0?this.maxZoom=Math.min(this.options.maxZoom,this.maxZoom):console.error("Invalid maxZoom on track:",this)))}},{key:"visibleAndFetchedIds",value:function(){return Object.keys(this.fetchedTiles).filter(I=>this.visibleTileIds.has(I))}},{key:"visibleAndFetchedTiles",value:function(){return this.visibleAndFetchedIds().map(I=>this.fetchedTiles[I])}},{key:"setVisibleTiles",value:function(I){this.visibleTiles=I.map(r=>({tileId:this.tileToLocalId(r),remoteId:this.tileToRemoteId(r),mirrored:r.mirrored})),this.visibleTileIds=new Set(this.visibleTiles.map(r=>r.tileId))}},{key:"removeOldTiles",value:function(){this.calculateVisibleTiles();const r=[...new Set(Object.keys(this.fetchedTiles))].filter(o=>!this.visibleTileIds.has(o));this.removeTiles(r)}},{key:"refreshTiles",value:function(){if(!this.tilesetInfo)return;this.calculateVisibleTiles();const I=new Set(Object.keys(this.fetchedTiles)),r=[...this.visibleTiles].filter(o=>!this.fetching.has(o.remoteId)&&!I.has(o.tileId));for(let o=0;o0;)if(o-=1,C=C.map(A=>Math.floor(A/2)),`${r}.${o}.${C.join(".")}`in this.fetchedTiles)return!0;return!1}},{key:"parentTileId",value:function(I){const r=I.tileData.zoomLevel-1,o=I.tileData.tilePos.map(a=>Math.floor(a/2));return`${I.tileData.tilesetUid}.${r}.${o.join(".")}`}},{key:"removeTiles",value:function(I){!I.length||!this.areAllVisibleTilesLoaded()||this.renderingTiles.size||(I.forEach(r=>{const o=r;this.destroyTile(this.fetchedTiles[o]),o in this.tileGraphics&&(this.pMain.removeChild(this.tileGraphics[o]),delete this.tileGraphics[o]),delete this.fetchedTiles[o]}),this.synchronizeTilesAndGraphics(),this.draw())}},{key:"zoomed",value:function(I,r,o=1,C=0,a=0){this.xScale(I),this.yScale(r),this.refreshTilesDebounced(),this.pMobile.position.x=C,this.pMobile.position.y=this.position[1],this.pMobile.scale.x=o,this.pMobile.scale.y=1}},{key:"setPosition",value:function(I){B0(qu(i.prototype),"setPosition",this).call(this,I)}},{key:"setDimensions",value:function(I){B0(qu(i.prototype),"setDimensions",this).call(this,I)}},{key:"areAllVisibleTilesLoaded",value:function(){const I=new Set(Object.keys(this.fetchedTiles)),r=[...this.visibleTileIds];for(let o=0;or.tileData))}},{key:"loadTileData",value:function(I,r){let o=this.lruCache.get(I.tileId);return o||(o=r(I.data,I.type),this.lruCache.put(I.tileId,o)),o}},{key:"fetchNewTiles",value:function(I){if(I.length>0){const r=[...new Set(I.map(o=>o.remoteId))];this.dataFetcher.fetchTilesDebounced(this.receivedTiles.bind(this),r)}}},{key:"receivedTiles",value:function(I){for(let r=0;rNumber.isNaN(+a)).forEach(a=>{this.fetchedTiles[o].tileData[a]=C[a]})}else this.fetchedTiles[o].tileData={...I[this.visibleTiles[r].remoteId]};this.fetchedTiles[o].tileData.error&&console.warn("Error in loaded tile",o,this.fetchedTiles[o].tileData)}}for(const r in I)if(I[r]){const o=I[r].tilePositionId;this.fetching.has(o)&&this.fetching.delete(o)}this.synchronizeTilesAndGraphics(),this.draw(),this.drawLabel(),this.valueScale&&(!this.prevValueScale||JSON.stringify(this.valueScale.domain())!==JSON.stringify(this.prevValueScale.domain()))&&(this.prevValueScale=this.valueScale.copy(),this.onValueScaleChanged&&this.onValueScaleChanged()),this.animate(),this.areAllVisibleTilesLoaded()&&this.pubSub&&this.pubSub.publish("TiledPixiTrack.tilesLoaded",{uuid:this.uuid})}},{key:"draw",value:function(){if(this.delayDrawing)return;this.tilesetInfo?this.trackNotFoundText.visible=!1:(this.dataFetcher.tilesetInfoLoading?this.trackNotFoundText.text="Loading...":this.trackNotFoundText.text=`Tileset info not found. Server: [${this.server}] tilesetUid: [${this.tilesetUid}]`,[this.trackNotFoundText.x,this.trackNotFoundText.y]=this.position,this.flipText&&(this.trackNotFoundText.anchor.x=1,this.trackNotFoundText.scale.x=-1),this.trackNotFoundText.visible=!0),this.pubSub&&this.pubSub.publish("TiledPixiTrack.tilesDrawnStart",{uuid:this.uuid});const I=Object.values(this.fetchedTiles).map(r=>r.tileData&&r.tileData.error&&`${r.tileId}: ${r.tileData.error}`).filter(r=>r);I.length?this.errorTextText=I.join(` +`):this.errorTextText="",B0(qu(i.prototype),"draw",this).call(this),Object.keys(this.fetchedTiles).forEach(r=>{this.drawTile(this.fetchedTiles[r])}),this.pubSub&&this.pubSub.publish("TiledPixiTrack.tilesDrawnEnd",{uuid:this.uuid})}},{key:"drawTile",value:function(){}},{key:"calculateMedianVisibleValue",value:function(){this.areAllVisibleTilesLoaded()&&this.allTilesLoaded();let I=this.visibleAndFetchedIds();I.length===0&&(I=Object.keys(this.fetchedTiles));const r=[].concat(...I.filter(o=>this.fetchedTiles[o].tileData.dense).map(o=>Array.from(this.fetchedTiles[o].tileData.dense))).filter(o=>o>0);return this.medianVisibleValue=VCe(r),this.medianVisibleValue}},{key:"allVisibleValues",value:function(){return[].concat(...this.visibleAndFetchedIds().map(I=>Array.from(this.fetchedTiles[I].tileData.dense)))}},{key:"minVisibleValue",value:function(I=!1){return this.minVisibleValueInTiles(I)}},{key:"minVisibleValueInTiles",value:function(I=!1){let r=this.visibleAndFetchedIds();r.length===0&&(r=Object.keys(this.fetchedTiles));let o=Math.min(...r.map(C=>this.fetchedTiles[C].tileData.minNonZero));return o===Number.MAX_SAFE_INTEGER&&(o=null),I?o:this.valueScaleMin!==null?this.valueScaleMin:o}},{key:"maxVisibleValue",value:function(I=!1){return this.maxVisibleValueInTiles(I)}},{key:"maxVisibleValueInTiles",value:function(I=!1){let r=this.visibleAndFetchedIds();r.length===0&&(r=Object.keys(this.fetchedTiles));let o=Math.max(...r.map(C=>this.fetchedTiles[C].tileData.maxNonZero));return o===Number.MIN_SAFE_INTEGER&&(o=null),I?o:this.valueScaleMax!==null?this.valueScaleMax:o}},{key:"makeValueScale",value:function(I,r,o,C){let a=null,A=0,s=C;(s===null||typeof s>"u")&&(s=6);let l=Math.min(this.dimensions[1]-s,s),c=Math.max(this.dimensions[1]-s,s);if(this.dimensions[1]-sXb(u,d,f),[h,0]}else if(this.options.valueScaling==="setquantile"){const u=this.dimensions[1]-s,d=s,h=new Set(this.allVisibleValues()),f=pF().domain([...h]).range(Xo(u,d,(d-u)/256));return f.ticks=m=>Xb(u,d,m),[f,0]}else a=bg().domain([I,o]).range([c,l]);return[a,A]}}]),i}(Lo);function PIg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function lRe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function bn(e){return bn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},bn(e)}const cRe=200,Dh=10,kV=40,xr=10,Mh=xr,uRe=4,VG=1,zh=4,dRe=5,qIg=256,VR=Dh+kV+xr+VG+Mh+zh;let gH=function(e){UIg(i,e);var g=QIg(i);function i(n,I){var r;PIg(this,i);const o={...n};o.onValueScaleChanged=()=>{n.onValueScaleChanged(),r.drawColorbar()},r=g.call(this,o,I);const{pubSub:C,animate:a,svgElement:A,onTrackOptionsChanged:s,onMouseMoveZoom:l,isShowGlobalMousePosition:c,isValueScaleLocked:u}=n;return r.pubSub=C,r.is2d=!0,r.animate=a,r.uid=Ng.nice(),r.scaleBrush=TT(),r.onTrackOptionsChanged=s,r.isShowGlobalMousePosition=c,r.isValueScaleLocked=u,r.pColorbarArea=new st.PIXI.Graphics,r.pMasked.addChild(r.pColorbarArea),r.pColorbar=new st.PIXI.Graphics,r.pColorbarArea.addChild(r.pColorbar),r.axis=new I_(A5(r)),r.pColorbarArea.addChild(r.axis.pAxis),r.colorScale=ew,I&&I.colorRange&&(r.colorScale=hm(I.colorRange)),r.gBase=xg(A).append("g"),r.gMain=r.gBase.append("g"),r.gColorscaleBrush=r.gMain.append("g"),r.brushing=!1,r.prevOptions="",r.prevIndUpperLeftTile="",r.onMouseMoveZoom=l,r.setDataLensSize(11),r.dataLens=new Float32Array(r.dataLensSize**2),r.mouseMoveHandlerBound=r.mouseMoveHandler.bind(A5(r)),r.onMouseMoveZoom&&r.pubSubs.push(r.pubSub.subscribe("app.mouseMove",r.mouseMoveHandlerBound)),r.options&&r.options.showMousePosition&&!r.hideMousePosition&&(r.hideMousePosition=Yb(A5(r),r.is2d,r.isShowGlobalMousePosition())),r.prevOptions=JSON.stringify(I),r}return _Ig(i,[{key:"mouseMoveHandler",value:function(I){this.isWithin(I.x,I.y)&&(this.mouseX=I.x,this.mouseY=I.y,this.mouseMoveZoomHandler())}},{key:"mouseMoveZoomHandler",value:function(I=this.mouseX,r=this.mouseY){if(typeof I>"u"||typeof r>"u"||!this.areAllVisibleTilesLoaded()||!this.tilesetInfo)return;const o=I-this.position[0],C=r-this.position[1];let a,A;try{A=this.getVisibleRectangleData(o-this.dataLensPadding,C-this.dataLensPadding,this.dataLensSize,this.dataLensSize),a=A.get(this.dataLensPadding,this.dataLensPadding)}catch{return}const s=this.dataLensSize;let l;try{l=Dae(this.limitedValueScale,this.colorScale,this.valueScale.domain()[0])}catch{return}if(!l)return;const c=Math.round(this._xScale.invert(o)),u=Math.round(this._yScale.invert(C));let d=[c,u],h=[Math.round(this._xScale.invert(o-this.dataLensPadding)),Math.round(this._xScale.invert(o+this.dataLensPadding))],f=[Math.round(this._yScale.invert(C-this.dataLensPadding)),Math.round(this._yScale.invert(C+this.dataLensPadding))];this.chromInfo&&(d=d.map(m=>mI(m,this.chromInfo).slice(0,2)),h=h.map(m=>mI(m,this.chromInfo).slice(0,2)),f=f.map(m=>mI(m,this.chromInfo).slice(0,2))),this.onMouseMoveZoom({trackId:this.id,data:a,absX:I,absY:r,relX:o,relY:C,dataX:c,dataY:u,orientation:"2d",dataLens:A,dim:s,toRgb:l,center:d,xRange:h,yRange:f,isGenomicCoords:!!this.chromInfo})}},{key:"scheduleRerender",value:function(){this.backgroundTaskScheduler.enqueueTask(this.handleRerender.bind(this),null,this.uuid)}},{key:"handleRerender",value:function(){this.rerender(this.options,!0)}},{key:"getAbsTileDim",value:function(I,r,o){const{tileX:C,tileY:a,tileWidth:A,tileHeight:s}=this.getTilePosAndDimensions(I,r),l={};return l.width=this._refXScale(C+A)-this._refXScale(C),l.height=this._refYScale(a+s)-this._refYScale(a),o?(l.x=this._refXScale(a),l.y=this._refYScale(C)):(l.x=this._refXScale(C),l.y=this._refYScale(a)),l}},{key:"updateValueScale",value:function(){let I=this.minValue(),r=this.maxValue();const o=1e-6;I!=null&&r!==void 0&&r!==null&&Math.abs(I-r)this.renderTile(C)),this.hideMousePosition&&(this.hideMousePosition(),this.hideMousePosition=void 0),this.options&&this.options.showMousePosition&&!this.hideMousePosition&&(this.hideMousePosition=Yb(this,this.is2d,this.isShowGlobalMousePosition())))}},{key:"drawLabel",value:function(){this.options.labelPosition===this.options.colorbarPosition?this.labelXOffset=VR:this.labelXOffset=0,_n(bn(i.prototype),"drawLabel",this).call(this)}},{key:"tileDataToCanvas",value:function(I){const r=document.createElement("canvas");r.width=this.binsPerTile(),r.height=this.binsPerTile();const o=r.getContext("2d");o.fillStyle="transparent",o.fillRect(0,0,r.width,r.height);const C=new ImageData(I,r.width,r.height);return o.putImageData(C,0,0),r}},{key:"exportData",value:function(){if(this.tilesetInfo){const I=this.getVisibleRectangleData(0,0,this.dimensions[0],this.dimensions[1]),r={bounds:[this._xScale.domain(),this._yScale.domain()],dimensions:I.shape,data:A_e(I)};z2("data.json",JSON.stringify(r))}}},{key:"setSpriteProperties",value:function(I,r,o,C){const a=this.getAbsTileDim(r,o,C);I.width=a.width,I.height=a.height,I.x=a.x,I.y=a.y,C&&o[0]!==o[1]&&(I.rotation=-Math.PI/2,I.scale.x=Math.abs(I.scale.x)*-1)}},{key:"refXScale",value:function(I){_n(bn(i.prototype),"refXScale",this).call(this,I),this.draw()}},{key:"refYScale",value:function(I){_n(bn(i.prototype),"refYScale",this).call(this,I),this.draw()}},{key:"draw",value:function(){_n(bn(i.prototype),"draw",this).call(this)}},{key:"newBrushOptions",value:function(I){const r=JSON.parse(JSON.stringify(this.options)),o=this.valueScale.copy().range([this.colorbarHeight,0]),C=o.invert(I[0]),A=(o.invert(I[1])-o.domain()[0])/(o.domain()[1]-o.domain()[0]),s=(C-o.domain()[0])/(o.domain()[1]-o.domain()[0]);return r.scaleStartPercent=A.toFixed(dRe),r.scaleEndPercent=s.toFixed(dRe),r}},{key:"brushStart",value:function(){this.brushing=!0}},{key:"brushMoved",value:function(I){if(!I.selection)return;const r=this.newBrushOptions(I.selection),o=JSON.stringify(r);this.gColorscaleBrush.selectAll(".handle--custom").attr("y",C=>C.type==="n"?I.selection[0]:I.selection[1]-uRe/2),o!==this.prevOptions&&(this.prevOptions=o,this.rerender(r,!0),this.onTrackOptionsChanged(r),this.isValueScaleLocked()&&this.onValueScaleChanged())}},{key:"brushEnd",value:function(){this.brushing=!1}},{key:"setPosition",value:function(I){_n(bn(i.prototype),"setPosition",this).call(this,I),this.drawColorbar()}},{key:"setDimensions",value:function(I){_n(bn(i.prototype),"setDimensions",this).call(this,I),this.drawColorbar()}},{key:"removeColorbar",value:function(){this.pColorbarArea.visible=!1,this.scaleBrush.on(".brush")&&this.gColorscaleBrush.call(this.scaleBrush.move,null),this.gColorscaleBrush.on(".brush",null),this.gColorscaleBrush.selectAll("rect").remove()}},{key:"drawColorbar",value:function(){if(this.pColorbar.clear(),!this.options||!this.options.colorbarPosition||this.options.colorbarPosition==="hidden"){this.removeColorbar();return}if(this.pColorbarArea.visible=!0,!this.valueScale||Number.isNaN(+this.valueScale.domain()[0])||Number.isNaN(+this.valueScale.domain()[1]))return;const I=Math.min(this.dimensions[1]/2,cRe);if(this.colorbarHeight=I-2*xr,this.colorbarHeight<0){this.removeColorbar();return}if(this.valueScale.domain()[1]===this.valueScale.domain()[0]){this.removeColorbar();return}const r=this.valueScale.copy().range([this.colorbarHeight,0]);this.options.colorbarPosition==="topLeft"||this.options.colorbarPosition==="bottomLeft"?this.scaleBrush.extent([[zh,0],[Mh,this.colorbarHeight]]):this.scaleBrush.extent([[0,0],[Mh-zh,this.colorbarHeight]]),this.options.colorbarPosition==="topLeft"&&([this.pColorbarArea.x,this.pColorbarArea.y]=this.position,this.pColorbar.y=xr,this.axis.pAxis.y=xr,this.axis.pAxis.x=zh+Mh+VG+Dh,this.pColorbar.x=zh+Mh+VG,this.gColorscaleBrush.attr("transform",`translate(${this.pColorbarArea.x+zh},${this.pColorbarArea.y+this.pColorbar.y-1})`)),this.options.colorbarPosition==="topRight"&&(this.pColorbarArea.x=this.position[0]+this.dimensions[0]-VR,this.pColorbarArea.y=this.position[1],this.pColorbar.y=xr,this.axis.pAxis.y=xr,this.axis.pAxis.x=kV+xr,this.pColorbar.x=kV+xr,this.gColorscaleBrush.attr("transform",`translate(${this.pColorbarArea.x+this.pColorbar.x+Dh+2},${this.pColorbarArea.y+this.pColorbar.y-1})`)),this.options.colorbarPosition==="bottomRight"&&(this.pColorbarArea.x=this.position[0]+this.dimensions[0]-VR,this.pColorbarArea.y=this.position[1]+this.dimensions[1]-I,this.pColorbar.y=xr,this.axis.pAxis.y=xr,this.axis.pAxis.x=kV+xr,this.pColorbar.x=kV+xr,this.gColorscaleBrush.attr("transform",`translate(${this.pColorbarArea.x+this.pColorbar.x+Dh+VG},${this.pColorbarArea.y+this.pColorbar.y-1})`)),this.options.colorbarPosition==="bottomLeft"&&(this.pColorbarArea.x=this.position[0],this.pColorbarArea.y=this.position[1]+this.dimensions[1]-I,this.pColorbar.y=xr,this.axis.pAxis.y=xr,this.axis.pAxis.x=zh+Mh+VG+Dh,this.pColorbar.x=zh+Mh+VG,this.gColorscaleBrush.attr("transform",`translate(${this.pColorbarArea.x+2},${this.pColorbarArea.y+this.pColorbar.y-1})`)),this.pColorbarArea.clear(),this.pColorbarArea.beginFill(jt(this.options.colorbarBackgroundColor||"white"),+this.options.colorbarBackgroundOpacity>=0?+this.options.colorbarBackgroundOpacity:.6),this.pColorbarArea.drawRect(0,0,VR,I),this.options?(this.options.scaleStartPercent||(this.options.scaleStartPercent=0),this.options.scaleEndPercent||(this.options.scaleEndPercent=1)):this.options={scaleStartPercent:0,scaleEndPercent:1};const o=r.domain()[1]-r.domain()[0],C=r(this.options.scaleStartPercent*o+r.domain()[0]),a=r(this.options.scaleEndPercent*o+r.domain()[0]);this.brushing||(this.scaleBrush.on("start",this.brushStart.bind(this)).on("brush",this.brushMoved.bind(this)).on("end",this.brushEnd.bind(this)).handleSize(0),this.gColorscaleBrush.on(".brush",null),this.gColorscaleBrush.call(this.scaleBrush),this.northHandle=this.gColorscaleBrush.selectAll(".handle--custom").data([{type:"n"},{type:"s"}]).enter().append("rect").classed("handle--custom",!0).attr("cursor","ns-resize").attr("width",Mh).attr("height",uRe).style("fill","#666").style("stroke","white"),this.flipText&&this.northHandle.attr("cursor","ew-resize"),this.gColorscaleBrush.call(this.scaleBrush.move,[a,C]));const A=bg().domain([0,255]).range([0,this.colorbarHeight]);for(let s=0;s{const Z=y.mirrored?[y.tileData.tilePos[1],y.tileData.tilePos[0]]:y.tileData.tilePos,{tileX:v,tileY:G,tileWidth:B,tileHeight:S}=this.getTilePosAndDimensions(y.tileData.zoomLevel,Z,this.binsPerTile()),R=Math.floor(v/s),w=Math.floor((v+B)/s),T=Math.floor(G/s),W=Math.floor((G+S)/s);let V=Math.max(h,R)-R,X=Math.max(f,T)-T;const N=Math.min(h+m,w)-R,Y=Math.min(f+b,W)-T,x=Math.max(R-h,0),M=Math.max(T-f,0),F=N-V,$=Y-X;if(!(F<0||$<0)){if(y.mirrored&&V>X){const Q=V;V=X,X=Q}C_e(p.hi(M+$,x+F).lo(M,x),y.dataArray.hi(X+$,V+F).lo(X,V))}}),p}},{key:"initTile",value:function(I){_n(bn(i.prototype),"initTile",this).call(this,I),I.tileData.dense.length===this.binsPerTile()**2&&(I.dataArray=_v(Array.from(I.tileData.dense),[this.binsPerTile(),this.binsPerTile()]),this.continuousScaling&&I.tileData.tilePos[0]===I.tileData.tilePos[1]&&I.mirrored&&(I.tileData.denseDataExtrema.mirrorPrecomputedExtrema(),_n(bn(i.prototype),"initTile",this).call(this,I))),!(this.scale.minValue===null||this.scale.maxValue===null)&&this.renderTile(I)}},{key:"updateTile",value:function(I){I.scale&&this.scale&&this.scale.minValue===I.scale.minValue&&this.scale.maxValue===I.scale.maxValue||(this.renderTile(I),this.drawColorbar())}},{key:"destroyTile",value:function(I){I.sprite.destroy(!0),I.canvas=null,I.sprite=null,I.texture=null}},{key:"pixDataFunction",value:function(I,r){if(r){const{graphics:o}=I,C=this.tileDataToCanvas(r.pixData);I.sprite&&I.sprite.destroy(!0);const a=st.PIXI.VERSION[0]==="4"?st.PIXI.Texture.fromCanvas(C,st.PIXI.SCALE_MODES.NEAREST):st.PIXI.Texture.from(C,{scaleMode:st.PIXI.SCALE_MODES.NEAREST}),A=new st.PIXI.Sprite(a);I.sprite=A,I.texture=a,I.canvas=C,this.setSpriteProperties(I.sprite,I.tileData.zoomLevel,I.tileData.tilePos,I.mirrored),o.removeChildren(),o.addChild(I.sprite)}this.renderingTiles.delete(I.tileId)}},{key:"renderTile",value:function(I){const[r]=this.updateValueScale(),o=0;if(this.renderingTiles.add(I.tileId),this.tilesetInfo.tile_size&&I.tileData.dense.lengththis.pixDataFunction(I,C),this.mirrorTiles()&&!I.mirrored&&I.tileData.tilePos[0]===I.tileData.tilePos[1],this.options.extent==="upper-right"&&I.tileData.tilePos[0]===I.tileData.tilePos[1],this.options.zeroValueColor?PPe(this.options.zeroValueColor):void 0,{selectedRows:this.options.selectRows,selectedRowsAggregationMode:this.options.selectRowsAggregationMode,selectedRowsAggregationWithRelativeHeight:this.options.selectRowsAggregationWithRelativeHeight,selectedRowsAggregationMethod:this.options.selectRowsAggregationMethod})}},{key:"remove",value:function(){this.gMain.remove(),this.gMain=null,_n(bn(i.prototype),"remove",this).call(this)}},{key:"refScalesChanged",value:function(I,r){_n(bn(i.prototype),"refScalesChanged",this).call(this,I,r),cP(this.fetchedTiles).filter(o=>o.sprite).forEach(o=>this.setSpriteProperties(o.sprite,o.tileData.zoomLevel,o.tileData.tilePos,o.mirrored))}},{key:"superSVG",value:function(){return _n(bn(i.prototype),"exportSVG",this).call(this)}},{key:"exportSVG",value:function(){let I=null,r=null;_n(bn(i.prototype),"exportSVG",this)?[r,I]=_n(bn(i.prototype),"exportSVG",this).call(this):(r=document.createElement("g"),I=r);const o=document.createElement("g");I.appendChild(o),o.setAttribute("transform",`translate(${this.pMain.position.x},${this.pMain.position.y}) scale(${this.pMain.scale.x},${this.pMain.scale.y})`);for(const a of this.visibleAndFetchedTiles()){const A=a.sprite.rotation*180/Math.PI,s=document.createElement("g");s.setAttribute("transform",`translate(${a.sprite.x},${a.sprite.y}) rotate(${A}) scale(${a.sprite.scale.x},${a.sprite.scale.y})`);const l=document.createElement("image");l.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.canvas.toDataURL()),l.setAttribute("width",a.canvas.width),l.setAttribute("height",a.canvas.height),l.setAttribute("style","image-rendering: pixelated"),s.appendChild(l),o.appendChild(s)}const C=this.exportColorBarSVG();return I.appendChild(C),[r,r]}},{key:"getVisiblePartOfUppLeftTile",value:function(){const I=this.visibleAndFetchedTiles().map(d=>{const h=d.mirrored?[d.tileData.tilePos[1],d.tileData.tilePos[0]]:d.tileData.tilePos;return[h[0],h[1],d.tileId]});if(I.length===0)return null;let r=I[0];for(let d=0;dd.tileId===r[2])[0],A=this.getIndicesOfVisibleDataInTile(a),s=A[0],l=A[1],c=s-s%C,u=l-l%C;return[a.tileId,c,u]}},{key:"getIndicesOfVisibleDataInTile",value:function(I){const r=this._xScale.range(),o=this._yScale.range(),C=I.mirrored?[I.tileData.tilePos[1],I.tileData.tilePos[0]]:I.tileData.tilePos,{tileX:a,tileY:A,tileWidth:s,tileHeight:l}=this.getTilePosAndDimensions(I.tileData.zoomLevel,C,this.binsPerTile()),c=bg().domain([0,this.binsPerTile()]).range([a,a+s]),u=Math.max(0,Math.round(c.invert(this._xScale.invert(r[0])))-1),d=Math.min(this.binsPerTile(),Math.round(c.invert(this._xScale.invert(r[1])))),h=bg().domain([0,this.binsPerTile()]).range([A,A+l]),f=Math.max(0,Math.round(h.invert(this._yScale.invert(o[0])))-1),m=Math.min(this.binsPerTile(),Math.round(h.invert(this._yScale.invert(o[1]))));return I.mirrored&&C[0]!==C[1]?[f,u,m,d]:[u,f,d,m]}},{key:"minVisibleValue",value:function(I=!1){const r=this.visibleAndFetchedTiles().map(C=>{if(C.tileData.denseDataExtrema===void 0)return null;const a=this.getIndicesOfVisibleDataInTile(C);return C.tileData.denseDataExtrema.getMinNonZeroInSubset(a)});if(r.length===0&&this.valueScaleMax===null)return null;const o=Math.min.apply(null,r);return o===Number.MAX_SAFE_INTEGER?_n(bn(i.prototype),"minVisibleValue",this).call(this,I):I?o:this.valueScaleMin!==null?this.valueScaleMin:o}},{key:"maxVisibleValue",value:function(I=!1){const r=this.visibleAndFetchedTiles().map(C=>{if(C.tileData.denseDataExtrema===void 0)return null;const a=this.getIndicesOfVisibleDataInTile(C);return C.tileData.denseDataExtrema.getMaxNonZeroInSubset(a)});if(r.length===0&&this.valueScaleMax===null)return null;const o=Math.max.apply(null,r);return o===Number.MIN_SAFE_INTEGER?_n(bn(i.prototype),"maxVisibleValue",this).call(this,I):I?o:this.valueScaleMax!==null?this.valueScaleMax:o}},{key:"zoomed",value:function(I,r,o,C,a){if(this.brushing)return;_n(bn(i.prototype),"zoomed",this).call(this,I,r),this.pMain.position.x=C,this.pMain.position.y=a,this.pMain.scale.x=o,this.pMain.scale.y=o;const A=this.isValueScaleLocked();if(this.continuousScaling&&this.minValue()!==void 0&&this.maxValue()!==void 0){const s=JSON.stringify(this.getVisiblePartOfUppLeftTile());if(this.valueScaleMin===null&&this.valueScaleMax===null&&!A&&s!==this.prevIndUpperLeftTile){const l=this.minVisibleValue(),c=this.maxVisibleValue(),u=1e-6;l!==null&&c!==null&&(Math.abs(this.minValue()-l)>u||Math.abs(this.maxValue()-c)>u)&&(this.minValue(l),this.maxValue(c),this.scheduleRerender()),this.prevIndUpperLeftTile=s}A&&this.onValueScaleChanged()}this.mouseMoveZoomHandler()}},{key:"addTileId",value:function(I,r,o,C,a,A=!1){const s=[r,o,C];s.mirrored=A,s.dataTransform=a,I.push(s)}},{key:"tilesToId",value:function(I,r,o){const C=I,a=r,A=this.options&&this.options.dataTransform||"default",s=[];for(let l=0;l=a[c]?this.options.extent!=="lower-left"&&this.addTileId(s,o,a[c],C[l],A,!0):this.options.extent!=="upper-right"&&this.addTileId(s,o,C[l],a[c],A),C[l]===a[c]&&this.options.extent==="lower-left"&&this.addTileId(s,o,C[l],a[c],A)):this.addTileId(s,o,C[l],a[c],A);return s}},{key:"calculateVisibleTiles",value:function(){if(this.tilesetInfo){if(this.zoomLevel=this.calculateZoomLevel(),this.tilesetInfo.resolutions){const I=this.tilesetInfo.resolutions.map(r=>+r).sort((r,o)=>o-r);this.xTiles=Nt.calculateTilesFromResolution(I[this.zoomLevel],this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]),this.yTiles=Nt.calculateTilesFromResolution(I[this.zoomLevel],this._yScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0])}else this.xTiles=Nt.calculateTiles(this.zoomLevel,this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width),this.yTiles=Nt.calculateTiles(this.zoomLevel,this._yScale,this.options.reverseYAxis?-this.tilesetInfo.max_pos[1]:this.tilesetInfo.min_pos[1],this.options.reverseYAxis?-this.tilesetInfo.min_pos[1]:this.tilesetInfo.max_pos[1],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width1||this.tilesetInfo.max_width);this.setVisibleTiles(this.tilesToId(this.xTiles,this.yTiles,this.zoomLevel))}}},{key:"mirrorTiles",value:function(){return!(this.tilesetInfo.mirror_tiles&&(this.tilesetInfo.mirror_tiles===!1||this.tilesetInfo.mirror_tiles==="false"))}},{key:"getMouseOverHtml",value:function(I,r){if(!this.options||!this.options.showTooltip||!this.tilesetInfo)return"";const o=Nt.calculateResolution(this.tilesetInfo,this.zoomLevel),C=Math.max(this.tilesetInfo.max_pos[1]-this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[0]-this.tilesetInfo.min_pos[0]),a=Math.ceil(Math.log(C/o)/Math.log(10));this.setDataLensSize(1);const A=this._xScale.invert(I),s=this._yScale.invert(r);let l="Position: ";if(this.chromInfo){const u=mI(A,this.chromInfo),d=mI(s,this.chromInfo),h=f=>da(`.${a}s`)(f);l+=`${u[0]}:${h(u[1])} & ${d[0]}:${h(d[1])}`,l+="
"}let c=null;try{c=this.getVisibleRectangleData(I,r,1,1).get(0,0)}catch{return""}return this.options&&this.options.heatmapValueScaling==="log"?c>0?`${l}Value: 1e${da(".3f")(Math.log(c)/Math.log(10))}`:c===0?`${l}Value: 0`:`${l}Value: N/A`:`${l}Value: ${da(".3f")(c)}`}},{key:"getTilePosAndDimensions",value:function(I,r,o){const C=o||this.binsPerTile();if(this.tilesetInfo.resolutions){const m=this.tilesetInfo.resolutions.map(v=>+v).sort((v,G)=>G-v)[I],b=m*C,p=b,y=m*C*r[0],Z=m*C*r[1];return{tileX:y,tileY:Z,tileWidth:b,tileHeight:p}}const a=r[0],A=r[1],s=this.tilesetInfo.min_pos[0],l=this.options.reverseYAxis?-this.tilesetInfo.max_pos[1]:this.tilesetInfo.min_pos[1],c=this.tilesetInfo.max_width/2**I,u=this.tilesetInfo.max_width/2**I,d=s+a*c,h=l+A*u;return{tileX:d,tileY:h,tileWidth:c,tileHeight:u}}},{key:"calculateZoomLevel",value:function(){const I=this.tilesetInfo.min_pos[0],r=this.tilesetInfo.max_pos[0],o=this.tilesetInfo.min_pos[1],C=this.tilesetInfo.max_pos[1];let a=null;if(this.tilesetInfo.resolutions){const A=Nt.calculateZoomLevelFromResolutions(this.tilesetInfo.resolutions,this._xScale,I,r),s=Nt.calculateZoomLevelFromResolutions(this.tilesetInfo.resolutions,this._yScale,o,C);a=Math.min(A,s)}else{const A=Nt.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.binsPerTile()),s=Nt.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[1],this.binsPerTile());a=Math.max(A,s),a=Math.min(a,this.maxZoom)}return this.options&&this.options.maxZoom&&(this.options.maxZoom>=0?a=Math.min(this.options.maxZoom,a):console.error("Invalid maxZoom on track:",this)),a}},{key:"tileToLocalId",value:function(I){return I.dataTransform&&I.dataTransform!=="default"?`${I.join(".")}.${I.mirrored}.${I.dataTransform}`:`${I.join(".")}.${I.mirrored}`}},{key:"tileToRemoteId",value:function(I){return I.dataTransform&&I.dataTransform!=="default"?`${I.join(".")}.${I.dataTransform}`:`${I.join(".")}`}},{key:"localToRemoteId",value:function(I){const r=I.split(".");return r.slice(0,r.length-1).join(".")}}]),i}(rZ);function erg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function hRe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function uE(e){return uE=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},uE(e)}function U7e(e){if(!e.graphics)return;const g=e.graphics,{tileX:i,tileY:n,tileWidth:I}=this.getTilePosAndDimensions(e.tileData.zoomLevel,e.tileData.tilePos);e.drawnAtScale=this._xScale.copy();const r=1/((this._xScale(1)-this._xScale(0))/(this._refXScale(1)-this._refXScale(0))),o=1/((this._yScale(1)-this._yScale(0))/(this._refYScale(1)-this._refYScale(0)));e.text.scale.x=r,e.text.scale.y=o;const C=this._xScale(I)-this._xScale(0);if(e.textGraphics.scale.x=C/256,e.textGraphics.scale.y=C/256,g.clear(),g.lineStyle(4*r,255,1),g.beginFill(16740363,.4),g.alpha=.5,e.mirrored){const a=this._refXScale(n+I)-this._refXScale(n),A=this._refYScale(i+I)-this._refYScale(i);e.textGraphics.position.x=this._refXScale(n)+a/2,e.textGraphics.position.y=this._refYScale(i)+A/2,g.drawRect(this._refXScale(n),this._refYScale(i),a,A)}else{const a=this._refXScale(i+I)-this._refXScale(i),A=this._refYScale(n+I)-this._refYScale(n);e.textGraphics.position.x=this._refXScale(i)+a/2,e.textGraphics.position.y=this._refYScale(n)+A/2,g.drawRect(this._refXScale(i),this._refYScale(n),a,A)}}function Q7e(e){const g=e.graphics;e.textGraphics=new st.PIXI.Graphics,e.mirrored?e.text=new st.PIXI.Text(`${e.tileData.zoomLevel}/${[e.tileData.tilePos[1],e.tileData.tilePos[0]].join("/")}`,{fontFamily:"Arial",fontSize:24,fill:16715792,align:"center"}):e.text=new st.PIXI.Text(`${e.tileData.zoomLevel}/${e.tileData.tilePos.join("/")}`,{fontFamily:"Arial",fontSize:24,fill:16715792,align:"center"}),e.textGraphics.addChild(e.text),e.text.anchor.x=.5,e.text.anchor.y=.5,g.addChild(e.textGraphics)}let j7e=function(e){nrg(i,e);var g=Irg(i);function i(){return erg(this,i),g.apply(this,arguments)}return trg(i,[{key:"areAllVisibleTilesLoaded",value:function(){return!0}},{key:"initTile",value:function(I){Q7e.bind(this)(I),this.drawTile(I)}},{key:"destroyTile",value:function(I,r){}},{key:"drawTile",value:function(I){U7e.bind(this)(I)}},{key:"fetchNewTiles",value:function(I){I.forEach(r=>{const C=r.remoteId.split("."),a={zoomLevel:C[0],tilePos:C.slice(1,C.length).map(A=>+A)};this.fetchedTiles[r.tileId]=r,this.fetchedTiles[r.tileId].tileData=a,this.fetching.has(r.remoteId)&&this.fetching.delete(r.remoteId)}),this.synchronizeTilesAndGraphics()}}]),i}(gH);function arg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function fRe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Lb(e){return Lb=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},Lb(e)}const mrg=1024;let nAe=function(e){urg(i,e);var g=drg(i);function i(n,I){var r;arg(this,i),r=g.call(this,n,I);const{onMouseMoveZoom:o,isValueScaleLocked:C,getLockGroupExtrema:a}=n;return r.onMouseMoveZoom=o,r.isValueScaleLocked=C,r.getLockGroupExtrema=a,r.onMouseMoveZoom&&r.pubSubs.push(r.pubSub.subscribe("app.mouseMove",r.mouseMoveHandler.bind($7e(r)))),r}return srg(i,[{key:"initTile",value:function(I){uW(Lb(i.prototype),"initTile",this).call(this,I)}},{key:"tileToLocalId",value:function(I){return`${I.join(".")}`}},{key:"tileToRemoteId",value:function(I){return`${I.join(".")}`}},{key:"relevantScale",value:function(){return null}},{key:"setVisibleTiles",value:function(I){this.visibleTiles=I.map(r=>({tileId:this.tileToLocalId(r),remoteId:this.tileToRemoteId(r)})),this.visibleTileIds=new Set(this.visibleTiles.map(r=>r.tileId))}},{key:"calculateVisibleTiles",value:function(){if(!this.tilesetInfo)return;if(this.zoomLevel=this.calculateZoomLevel(),this.tilesetInfo.resolutions){const o=this.tilesetInfo.resolutions.map(A=>+A).sort((A,s)=>s-A),a=Nt.calculateTilesFromResolution(o[this.zoomLevel],this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]).map(A=>[this.zoomLevel,A]);this.setVisibleTiles(a);return}const r=Nt.calculateTiles(this.zoomLevel,this.relevantScale(),this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width).map(o=>[this.zoomLevel,o]);this.setVisibleTiles(r)}},{key:"getTilePosAndDimensions",value:function(I,r,o){const C=r[0],a=r[0];if(this.tilesetInfo.resolutions){const m=o||mrg,p=this.tilesetInfo.resolutions.map(B=>+B).sort((B,S)=>S-B)[I],y=p*m,Z=y,v=p*m*r[0],G=p*m*r[1];return{tileX:v,tileY:G,tileWidth:y,tileHeight:Z}}const A=this.tilesetInfo.max_width,s=this.tilesetInfo.max_width,l=this.tilesetInfo.min_pos[0],c=this.tilesetInfo.min_pos[1],u=A/2**I,d=s/2**I,h=l+C*u,f=c+a*d;return{tileX:h,tileY:f,tileWidth:u,tileHeight:d}}},{key:"updateTile",value:function(I){}},{key:"scheduleRerender",value:function(){this.backgroundTaskScheduler.enqueueTask(this.handleRerender.bind(this),null,this.uuid)}},{key:"handleRerender",value:function(){this.rerender(this.options,!1)}},{key:"getIndicesOfVisibleDataInTile",value:function(I){const r=this._xScale.range();if(!this.tilesetInfo)return[null,null];const{tileX:o,tileWidth:C}=this.getTilePosAndDimensions(I.tileData.zoomLevel,I.tileData.tilePos,this.tilesetInfo.bins_per_dimension||this.tilesetInfo.tile_size),a=bg().domain([0,this.tilesetInfo.tile_size||this.tilesetInfo.bins_per_dimension]).range([o,o+C]),A=Math.max(0,Math.round(a.invert(this._xScale.invert(r[0])))),s=Math.min(I.tileData.dense.length,Math.round(a.invert(this._xScale.invert(r[1]))));return[A,s]}},{key:"minVisibleValue",value:function(I=!1){let r=this.visibleAndFetchedIds();r.length===0&&(r=Object.keys(this.fetchedTiles));const o=r.map(a=>this.fetchedTiles[a]).map(a=>{const A=this.getIndicesOfVisibleDataInTile(a);return a.tileData.denseDataExtrema.getMinNonZeroInSubset(A)}),C=Math.min(...o);return I?C:this.valueScaleMin!==null?this.valueScaleMin:C}},{key:"maxVisibleValue",value:function(I=!1){let r=this.visibleAndFetchedIds();r.length===0&&(r=Object.keys(this.fetchedTiles));const o=r.map(a=>this.fetchedTiles[a]).map(a=>{const A=this.getIndicesOfVisibleDataInTile(a);return a.tileData.denseDataExtrema.getMaxNonZeroInSubset(A)}),C=Math.max(...o);return I?C:this.valueScaleMax!==null?this.valueScaleMax:C}},{key:"getAggregatedVisibleValue",value:function(I="max"){const r=I==="min"?Math.min:Math.max,o=I==="min"?1/0:-1/0;let C=this.visibleAndFetchedIds();C.length===0&&(C=Object.keys(this.fetchedTiles));const a=this._xScale.range();return C.map(A=>this.fetchedTiles[A]).map(A=>{if(!A.tileData.tilePos)return I==="min"?this.minVisibleValue():this.maxVisibleValue();const{tileX:s,tileWidth:l}=this.getTilePosAndDimensions(A.tileData.zoomLevel,A.tileData.tilePos,this.tilesetInfo.bins_per_dimension||this.tilesetInfo.tile_size),c=bg().domain([0,this.tilesetInfo.tile_size||this.tilesetInfo.bins_per_dimension]).range([s,s+l]),u=Math.max(0,Math.round(c.invert(this._xScale.invert(a[0])))),d=Math.min(A.tileData.dense.length,Math.round(c.invert(this._xScale.invert(a[1]))));return A.tileData.dense.slice(u,d)}).reduce((A,s)=>r(A,...s),o)}},{key:"getDataAtPos",value:function(I){let r;if(!this.tilesetInfo)return r;const o=this.calculateZoomLevel(),C=Nt.calculateTileWidth(this.tilesetInfo,o,this.tilesetInfo.tile_size),a=this._xScale.invert(I)/C,A=this.tileToLocalId([o,Math.floor(a)]),s=this.fetchedTiles[A];if(!s)return r;const l=this.tilesetInfo.tile_size*(a-Math.floor(a));return s.tileData.dense?s.tileData.dense[Math.floor(l)]:null}},{key:"mouseMoveHandler",value:function({x:I,y:r}={}){this.isWithin(I,r)&&(this.mouseX=I,this.mouseY=r,this.mouseMoveZoomHandler())}},{key:"mouseMoveZoomHandler",value:function(){}},{key:"zoomed",value:function(...I){uW(Lb(i.prototype),"zoomed",this).call(this,...I),this.mouseMoveZoomHandler()}}]),i}(rZ);function prg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function mRe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ed(e){return ed=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},ed(e)}let $1=function(e){vrg(i,e);var g=Brg(i);function i(n,I){var r;prg(this,i),r=g.call(this,n,I);const{animate:o,isShowGlobalMousePosition:C}=n;return r.constIndicator=new st.PIXI.Graphics,r.pMain.addChild(r.constIndicator),r.axis=new I_(Tee(r)),r.pBase.addChild(r.axis.pAxis),r.animate=o,r.options=I,r.isShowGlobalMousePosition=C,r.pubSubs=[],r.options.showMousePosition&&!r.hideMousePosition&&(r.hideMousePosition=Yb(Tee(r),r.is2d,r.isShowGlobalMousePosition())),r}return brg(i,[{key:"rerender",value:function(I,r){const o=JSON.stringify(I);!r&&o===this.prevOptions||(w0(ed(i.prototype),"rerender",this).call(this,I,r),this.prevOptions=o,this.options=I,this.options.showMousePosition&&!this.hideMousePosition&&(this.hideMousePosition=Yb(this,this.is2d,this.isShowGlobalMousePosition())),!this.options.showMousePosition&&this.hideMousePosition&&(this.hideMousePosition(),this.hideMousePosition=void 0))}},{key:"calculateZoomLevel",value:function(){if(this.tilesetInfo.resolutions)return Nt.calculateZoomLevelFromResolutions(this.tilesetInfo.resolutions,this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]-2);const I=Nt.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.bins_per_dimension||this.tilesetInfo.tile_size);let r=Math.min(I,this.maxZoom);return r=Math.max(r,0),r}},{key:"relevantScale",value:function(){return this._xScale}},{key:"draw",value:function(){w0(ed(i.prototype),"draw",this).call(this),this.drawConstIndicator()}},{key:"drawAxis",value:function(I){if(!this.options.axisPositionVertical&&!this.options.axisPositionHorizontal){this.axis.clearAxis();return}if(this.options.axisPositionVertical&&this.options.axisPositionVertical==="hidden"){this.axis.clearAxis();return}if(this.options.axisPositionHorizontal&&this.options.axisPositionHorizontal==="hidden"){this.axis.clearAxis();return}const r=this.options.axisMargin||0;this.options.axisPositionHorizontal==="left"||this.options.axisPositionVertical==="top"?(this.axis.pAxis.position.x=this.position[0]+r,this.axis.pAxis.position.y=this.position[1],this.axis.drawAxisRight(I,this.dimensions[1])):this.options.axisPositionHorizontal==="outsideLeft"||this.options.axisPositionVertical==="outsideTop"?(this.axis.pAxis.position.x=this.position[0]+r,this.axis.pAxis.position.y=this.position[1],this.axis.drawAxisLeft(I,this.dimensions[1])):this.options.axisPositionHorizontal==="right"||this.options.axisPositionVertical==="bottom"?(this.axis.pAxis.position.x=this.position[0]+this.dimensions[0]-r,this.axis.pAxis.position.y=this.position[1],this.axis.drawAxisLeft(I,this.dimensions[1])):(this.options.axisPositionHorizontal==="outsideRight"||this.options.axisPositionVertical==="outsideBottom")&&(this.axis.pAxis.position.x=this.position[0]+this.dimensions[0]-r,this.axis.pAxis.position.y=this.position[1],this.axis.drawAxisRight(I,this.dimensions[1]))}},{key:"mouseMoveZoomHandler",value:function(I=this.mouseX,r=this.mouseY){if(typeof I>"u"||!this.areAllVisibleTilesLoaded()||!this.tilesetInfo)return;let o=0,C=0,a="1d-horizontal";this.isLeftModified?(o=r-this.position[1],C=I-this.position[0],a="1d-vertical"):(o=I-this.position[0],C=r-this.position[1]);const A=I-this.position[0],s=r-this.position[1],l=this._xScale.invert(o),c=this._yScale.invert(C),u=this.getDataAtPos(o);u&&this.onMouseMoveZoom({trackId:this.id,data:u,absX:I,absY:r,relX:A,relY:s,dataX:l,dataY:c,orientation:a})}},{key:"drawConstIndicator",value:function(){if(this.constIndicator){for(this.constIndicator.clear();this.constIndicator.children[0];)this.constIndicator.removeChild(this.constIndicator.children[0]);!this.options.constIndicators||!this.valueScale||this.options.constIndicators.forEach(({color:I="black",opacity:r=1,label:o=null,labelColor:C="black",labelOpacity:a=1,labelPosition:A="leftTop",labelSize:s=12,value:l=0}={})=>{const c=jt(I),u=jt(C);this.constIndicator.beginFill(c,r);const d=this.valueScale(l);let h=0,f=0;if(o){const m=new st.PIXI.Text(o,{fontFamily:"Arial",fontSize:s,fill:u});switch(m.alpha=a,A){case"right":m.anchor.x=1,m.anchor.y=.5,m.x=this.position[0]+this.dimensions[0]-6,m.y=d,f=m.width+8;break;case"rightBottom":m.anchor.x=1,m.anchor.y=0,m.x=this.position[0]+this.dimensions[0]-6,m.y=d;break;case"rightTop":m.anchor.x=1,m.anchor.y=1,m.x=this.position[0]+this.dimensions[0]-6,m.y=d;break;case"left":m.anchor.x=0,m.anchor.y=.5,m.x=this.position[0]+2,m.y=d,h=m.width+4;break;case"leftBottom":m.anchor.x=0,m.anchor.y=0,m.x=this.position[0]+2,m.y=d;break;case"leftTop":default:m.anchor.x=0,m.anchor.y=1,m.x=this.position[0]+2,m.y=d;break}this.constIndicator.addChild(m)}this.constIndicator.drawRect(this.position[0]+h,d,this.dimensions[0]-f,1)})}}},{key:"exportSVG",value:function(){let I=null,r=null;w0(ed(i.prototype),"exportSVG",this)?[r,I]=w0(ed(i.prototype),"exportSVG",this).call(this):(r=document.createElement("g"),I=r),r.setAttribute("class","horizontal-tiled-1d-track");const o=document.createElement("g");return I.appendChild(o),this.options.constIndicators&&this.options.constIndicators.forEach(({color:C="black",opacity:a=1,label:A=null,labelColor:s="black",labelOpacity:l=1,labelPosition:c="leftTop",labelSize:u=12,value:d=0}={})=>{const h=this.valueScale(d);if(A){const m=document.createElement("text");switch(m.textContent=A,m.setAttribute("x",this.position[0]),m.setAttribute("y",h),m.setAttribute("style",`font-family: 'Arial'; font-size: ${u}px; fill: ${s}; fill-opacity: ${l};`),c){case"rightBottom":m.setAttribute("x",this.position[0]+this.dimensions[0]-6),m.setAttribute("y",h+u+2),m.setAttribute("text-anchor","end");break;case"right":case"rightTop":m.setAttribute("x",this.position[0]+this.dimensions[0]-6),m.setAttribute("y",h-2),m.setAttribute("text-anchor","end");break;case"leftBottom":m.setAttribute("x",this.position[0]+2),m.setAttribute("y",h+u+2);break;case"left":case"leftTop":default:m.setAttribute("x",this.position[0]+2),m.setAttribute("y",h-2);break}o.appendChild(m)}const f=document.createElement("line");f.setAttribute("x1",this.position[0]),f.setAttribute("y1",h),f.setAttribute("x2",this.dimensions[0]),f.setAttribute("y2",h),f.setAttribute("stroke",C),f.setAttribute("stroke-opacity",a),o.appendChild(f)}),[r,I]}}]),i}(nAe);function Rrg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function pRe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function yw(e){return yw=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},yw(e)}let q7e=function(e){Hrg(i,e);var g=Nrg(i);function i(n,I){var r;return Rrg(this,i),r=g.call(this,n,I),r.pMain=r.pMobile,r}return Vrg(i,[{key:"areAllVisibleTilesLoaded",value:function(){return!0}},{key:"initTile",value:function(I){const r=I.graphics;I.textGraphics=new st.PIXI.Graphics,I.text=new st.PIXI.Text(`${I.tileData.zoomLevel}/${I.tileData.tilePos.join("/")}`,{fontFamily:"Arial",fontSize:32,fill:16715792,align:"center"}),I.textGraphics.addChild(I.text),I.text.anchor.x=.5,I.text.anchor.y=.5,r.addChild(I.textGraphics),this.drawTile(I)}},{key:"destroyTile",value:function(I){}},{key:"drawTile",value:function(I){if(l5(yw(i.prototype),"drawTile",this).call(this,I),!I.graphics)return;const r=I.graphics,{tileX:o,tileWidth:C}=this.getTilePosAndDimensions(I.tileData.zoomLevel,I.tileData.tilePos),a=1/((this._xScale(1)-this._xScale(0))/(this._refXScale(1)-this._refXScale(0)));I.text.scale.x=a,r.clear();const A=this.dimensions[1],s=this._refXScale(o+C)-this._refXScale(o);I.textGraphics.position.x=this._refXScale(o)+s/2,I.textGraphics.position.y=A/2;const l=this._refXScale(o);r.lineStyle(4*a,255,1),r.beginFill(16740363,.4),r.alpha=.5,r.moveTo(l,0),r.lineTo(l,A),r.moveTo(l+s,0),r.lineTo(l+s,A),r.lineStyle(0,255,1),r.drawRect(l,0,s,A)}}]),i}($1);function xrg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function bRe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Zw(e){return Zw=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},Zw(e)}let eQe=function(e){zrg(i,e);var g=Prg(i);function i(){return xrg(this,i),g.apply(this,arguments)}return Frg(i,[{key:"calculateZoomLevel",value:function(){const I=Nt.calculateZoomLevel(this._yScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]);return Math.min(I,this.maxZoom)}},{key:"relevantScale",value:function(){return this._yScale}},{key:"zoomed",value:function(I,r){c5(Zw(i.prototype),"zoomed",this).call(this,I,r);const o=1,C=(r(1)-r(0))/(this._refYScale(1)-this._refYScale(0)),a=this.position[0],A=r(0)+this.position[1]-this._refYScale(1)*C;this.pMain.position.x=a,this.pMain.position.y=A,this.pMain.scale.x=o,this.pMain.scale.y=C}}]),i}(nAe);function Lrg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function yRe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Gw(e){return Gw=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},Gw(e)}let tQe=function(e){qrg(i,e);var g=eog(i);function i(){return Lrg(this,i),g.apply(this,arguments)}return Urg(i,[{key:"areAllVisibleTilesLoaded",value:function(){return!0}},{key:"initTile",value:function(I){const r=I.graphics;I.textGraphics=new st.PIXI.Graphics,I.text=new st.PIXI.Text(`${I.tileData.zoomLevel}/${I.tileData.tilePos.join("/")}`,{fontFamily:"Arial",fontSize:32,fill:16715792,align:"center"}),I.textGraphics.addChild(I.text),I.text.anchor.x=.5,I.text.anchor.y=.5,I.text.rotation=-Math.PI/2,r.addChild(I.textGraphics),this.drawTile(I,r)}},{key:"destroyTile",value:function(I,r){}},{key:"drawTile",value:function(I){if(u5(Gw(i.prototype),"drawTile",this).call(this,I),!I.graphics)return;const r=I.graphics,{tileY:o,tileHeight:C}=this.getTilePosAndDimensions(I.tileData.zoomLevel,I.tileData.tilePos),a=1/((this._yScale(1)-this._yScale(0))/(this._refYScale(1)-this._refYScale(0)));I.text.scale.x=a,r.clear(),r.lineStyle(4*a,255,1),r.beginFill(16740363,.4),r.alpha=.5;const A=this.dimensions[0],s=this._refYScale(o+C)-this._refYScale(o);I.textGraphics.position.x=A/2,I.textGraphics.position.y=this._refYScale(o)+s/2,r.drawRect(0,this._refYScale(o),A,s)}},{key:"fetchNewTiles",value:function(I){I.forEach(r=>{const C=r.remoteId.split("."),a={zoomLevel:C[1],tilePos:C.slice(2,C.length).map(A=>+A)};this.fetchedTiles[r.tileId]=r,this.fetchedTiles[r.tileId].tileData=a,this.fetching.has(r.remoteId)&&this.fetching.delete(r.remoteId)}),this.synchronizeTilesAndGraphics()}}]),i}(eQe);var TQ=Array.prototype.slice;function nog(e){return e}var d5=1,h5=2,Yee=3,YV=4,ZRe=1e-6;function Iog(e){return"translate("+e+",0)"}function rog(e){return"translate(0,"+e+")"}function oog(e){return g=>+e(g)}function Cog(e,g){return g=Math.max(0,e.bandwidth()-g*2)/2,e.round()&&(g=Math.round(g)),i=>+e(i)+g}function aog(){return!this.__axis}function A_(e,g){var i=[],n=null,I=null,r=6,o=6,C=3,a=typeof window<"u"&&window.devicePixelRatio>1?0:.5,A=e===d5||e===YV?-1:1,s=e===YV||e===h5?"x":"y",l=e===d5||e===Yee?Iog:rog;function c(u){var d=n??(g.ticks?g.ticks.apply(g,i):g.domain()),h=I??(g.tickFormat?g.tickFormat.apply(g,i):nog),f=Math.max(r,0)+C,m=g.range(),b=+m[0]+a,p=+m[m.length-1]+a,y=(g.bandwidth?Cog:oog)(g.copy(),a),Z=u.selection?u.selection():u,v=Z.selectAll(".domain").data([null]),G=Z.selectAll(".tick").data(d,g).order(),B=G.exit(),S=G.enter().append("g").attr("class","tick"),R=G.select("line"),w=G.select("text");v=v.merge(v.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),G=G.merge(S),R=R.merge(S.append("line").attr("stroke","currentColor").attr(s+"2",A*r)),w=w.merge(S.append("text").attr("fill","currentColor").attr(s,A*f).attr("dy",e===d5?"0em":e===Yee?"0.71em":"0.32em")),u!==Z&&(v=v.transition(u),G=G.transition(u),R=R.transition(u),w=w.transition(u),B=B.transition(u).attr("opacity",ZRe).attr("transform",function(T){return isFinite(T=y(T))?l(T+a):this.getAttribute("transform")}),S.attr("opacity",ZRe).attr("transform",function(T){var W=this.parentNode.__axis;return l((W&&isFinite(W=W(T))?W:y(T))+a)})),B.remove(),v.attr("d",e===YV||e===h5?o?"M"+A*o+","+b+"H"+a+"V"+p+"H"+A*o:"M"+a+","+b+"V"+p:o?"M"+b+","+A*o+"V"+a+"H"+p+"V"+A*o:"M"+b+","+a+"H"+p),G.attr("opacity",1).attr("transform",function(T){return l(y(T)+a)}),R.attr(s+"2",A*r),w.attr(s,A*f).text(h),Z.filter(aog).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",e===h5?"start":e===YV?"end":"middle"),Z.each(function(){this.__axis=y})}return c.scale=function(u){return arguments.length?(g=u,c):g},c.ticks=function(){return i=TQ.call(arguments),c},c.tickArguments=function(u){return arguments.length?(i=u==null?[]:TQ.call(u),c):i.slice()},c.tickValues=function(u){return arguments.length?(n=u==null?null:TQ.call(u),c):n&&n.slice()},c.tickFormat=function(u){return arguments.length?(I=u,c):I},c.tickSize=function(u){return arguments.length?(r=o=+u,c):r},c.tickSizeInner=function(u){return arguments.length?(r=+u,c):r},c.tickSizeOuter=function(u){return arguments.length?(o=+u,c):o},c.tickPadding=function(u){return arguments.length?(C=+u,c):C},c.offset=function(u){return arguments.length?(a=+u,c):a},c}function gQe(e){return A_(d5,e)}function sog(e){return A_(h5,e)}function Aog(e){return A_(Yee,e)}function iQe(e){return A_(YV,e)}const log=Object.freeze(Object.defineProperty({__proto__:null,axisBottom:Aog,axisLeft:iQe,axisRight:sog,axisTop:gQe},Symbol.toStringTag,{value:"Module"}));function cog(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function GRe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function dE(e){return dE=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},dE(e)}let oZ=function(e){fog(i,e);var g=mog(i);function i(n,I){var r;cog(this,i),r=g.call(this,n,I);const{svgElement:o}=n;return r.gMain=xg(o).append("g"),r.clipUid=Ng.nice(),r.clipRect=r.gMain.append("clipPath").attr("id",`track-bounds-${r.clipUid}`).append("rect"),r.gMain.attr("clip-path",`url(#track-bounds-${r.clipUid})`),r}return uog(i,[{key:"setPosition",value:function(I){this.position=I,this.gMain.attr("transform",`translate(${this.position[0]},${this.position[1]})`),this.draw()}},{key:"setDimensions",value:function(I){this.dimensions=I,this._xScale.range([0,this.dimensions[0]]),this._yScale.range([0,this.dimensions[1]]),I[0]>=0&&I[1]>=0?(this.clipRect.attr("width",I[0]),this.clipRect.attr("height",I[1])):(this.clipRect.attr("width",0),this.clipRect.attr("height",0)),this.draw()}},{key:"remove",value:function(){this.gMain.remove(),this.gMain=null}},{key:"draw",value:function(){return this}}]),i}(Qv);function Zog(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function vRe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Ub(e){return Ub=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},Ub(e)}let nQe=function(e){Sog(i,e);var g=Rog(i);function i(n,I){var r;return Zog(this,i),r=g.call(this,n,I),r.axis=gQe(r._xScale),r.gAxis=r.gMain.append("g"),r.tilesetInfo=!0,r}return Gog(i,[{key:"setDimensions",value:function(I){dW(Ub(i.prototype),"setDimensions",this).call(this,I),this.axis.ticks(Math.ceil(this.dimensions[0]/150)),this.gAxis.attr("transform",`translate(0,${I[1]})`)}},{key:"draw",value:function(){return this.axis.scale(this._xScale),this.gAxis.call(this.axis),this}},{key:"zoomed",value:function(I,r){dW(Ub(i.prototype),"zoomed",this).call(this,I,r),this.draw()}}]),i}(oZ);function Tog(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function BRe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Qb(e){return Qb=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},Qb(e)}let IQe=function(e){Kog(i,e);var g=xog(i);function i(n,I){var r;return Tog(this,i),r=g.call(this,n,I),r.axis=iQe(r._yScale),r.gAxis=r.gMain.append("g"),r.tilesetInfo=!0,r}return Hog(i,[{key:"setDimensions",value:function(I){hW(Qb(i.prototype),"setDimensions",this).call(this,I),this.axis.ticks(Math.ceil(this.dimensions[1]/150)),this.gAxis.attr("transform",`translate(${I[0]},0)`)}},{key:"draw",value:function(){return this.axis.scale(this._yScale),this.gAxis.call(this.axis),this}},{key:"zoomed",value:function(I,r){hW(Qb(i.prototype),"zoomed",this).call(this,I,r),this.draw()}}]),i}(oZ);var Hg={},fn={},IAe=32;fn.INT_BITS=IAe;fn.INT_MAX=2147483647;fn.INT_MIN=-1<0)-(e<0)};fn.abs=function(e){var g=e>>IAe-1;return(e^g)-g};fn.min=function(e,g){return g^(e^g)&-(e65535)<<4,e>>>=g,i=(e>255)<<3,e>>>=i,g|=i,i=(e>15)<<2,e>>>=i,g|=i,i=(e>3)<<1,e>>>=i,g|=i,g|e>>1};fn.log10=function(e){return e>=1e9?9:e>=1e8?8:e>=1e7?7:e>=1e6?6:e>=1e5?5:e>=1e4?4:e>=1e3?3:e>=100?2:e>=10?1:0};fn.popCount=function(e){return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24};function rQe(e){var g=32;return e&=-e,e&&g--,e&65535&&(g-=16),e&16711935&&(g-=8),e&252645135&&(g-=4),e&858993459&&(g-=2),e&1431655765&&(g-=1),g}fn.countTrailingZeros=rQe;fn.nextPow2=function(e){return e+=e===0,--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e+1};fn.prevPow2=function(e){return e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e-(e>>>1)};fn.parity=function(e){return e^=e>>>16,e^=e>>>8,e^=e>>>4,e&=15,27030>>>e&1};var KV=new Array(256);(function(e){for(var g=0;g<256;++g){var i=g,n=g,I=7;for(i>>>=1;i;i>>>=1)n<<=1,n|=i&1,--I;e[g]=n<>>8&255]<<16|KV[e>>>16&255]<<8|KV[e>>>24&255]};fn.interleave2=function(e,g){return e&=65535,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,g&=65535,g=(g|g<<8)&16711935,g=(g|g<<4)&252645135,g=(g|g<<2)&858993459,g=(g|g<<1)&1431655765,e|g<<1};fn.deinterleave2=function(e,g){return e=e>>>g&1431655765,e=(e|e>>>1)&858993459,e=(e|e>>>2)&252645135,e=(e|e>>>4)&16711935,e=(e|e>>>16)&65535,e<<16>>16};fn.interleave3=function(e,g,i){return e&=1023,e=(e|e<<16)&4278190335,e=(e|e<<8)&251719695,e=(e|e<<4)&3272356035,e=(e|e<<2)&1227133513,g&=1023,g=(g|g<<16)&4278190335,g=(g|g<<8)&251719695,g=(g|g<<4)&3272356035,g=(g|g<<2)&1227133513,e|=g<<1,i&=1023,i=(i|i<<16)&4278190335,i=(i|i<<8)&251719695,i=(i|i<<4)&3272356035,i=(i|i<<2)&1227133513,e|i<<2};fn.deinterleave3=function(e,g){return e=e>>>g&1227133513,e=(e|e>>>2)&3272356035,e=(e|e>>>4)&251719695,e=(e|e>>>8)&4278190335,e=(e|e>>>16)&1023,e<<22>>22};fn.nextCombination=function(e){var g=e|e-1;return g+1|(~g&-~g)-1>>>rQe(e)+1};function oQe(e,g,i){var n=e[i]|0;if(n<=0)return[];var I=new Array(n),r;if(i===e.length-1)for(r=0;r"u"&&(g=0),typeof e){case"number":if(e>0)return Mog(e|0,g);break;case"object":if(typeof e.length=="number")return oQe(e,g,0);break}return[]}var Pog=zog,CQe={},l_={};l_.byteLength=Jog;l_.toByteArray=Uog;l_.fromByteArray=$og;var zl=[],xa=[],_og=typeof Uint8Array<"u"?Uint8Array:Array,HQ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var iG=0,Oog=HQ.length;iG0)throw new Error("Invalid string. Length must be a multiple of 4");var i=e.indexOf("=");i===-1&&(i=g);var n=i===g?0:4-i%4;return[i,n]}function Jog(e){var g=aQe(e),i=g[0],n=g[1];return(i+n)*3/4-n}function Log(e,g,i){return(g+i)*3/4-i}function Uog(e){var g,i=aQe(e),n=i[0],I=i[1],r=new _og(Log(e,n,I)),o=0,C=I>0?n-4:n,a;for(a=0;a>16&255,r[o++]=g>>8&255,r[o++]=g&255;return I===2&&(g=xa[e.charCodeAt(a)]<<2|xa[e.charCodeAt(a+1)]>>4,r[o++]=g&255),I===1&&(g=xa[e.charCodeAt(a)]<<10|xa[e.charCodeAt(a+1)]<<4|xa[e.charCodeAt(a+2)]>>2,r[o++]=g>>8&255,r[o++]=g&255),r}function Qog(e){return zl[e>>18&63]+zl[e>>12&63]+zl[e>>6&63]+zl[e&63]}function jog(e,g,i){for(var n,I=[],r=g;rC?C:o+r));return n===1?(g=e[i-1],I.push(zl[g>>2]+zl[g<<4&63]+"==")):n===2&&(g=(e[i-2]<<8)+e[i-1],I.push(zl[g>>10]+zl[g>>4&63]+zl[g<<2&63]+"=")),I.join("")}var rAe={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */rAe.read=function(e,g,i,n,I){var r,o,C=I*8-n-1,a=(1<>1,s=-7,l=i?I-1:0,c=i?-1:1,u=e[g+l];for(l+=c,r=u&(1<<-s)-1,u>>=-s,s+=C;s>0;r=r*256+e[g+l],l+=c,s-=8);for(o=r&(1<<-s)-1,r>>=-s,s+=n;s>0;o=o*256+e[g+l],l+=c,s-=8);if(r===0)r=1-A;else{if(r===a)return o?NaN:(u?-1:1)*(1/0);o=o+Math.pow(2,n),r=r-A}return(u?-1:1)*o*Math.pow(2,r-n)};rAe.write=function(e,g,i,n,I,r){var o,C,a,A=r*8-I-1,s=(1<>1,c=I===23?Math.pow(2,-24)-Math.pow(2,-77):0,u=n?0:r-1,d=n?1:-1,h=g<0||g===0&&1/g<0?1:0;for(g=Math.abs(g),isNaN(g)||g===1/0?(C=isNaN(g)?1:0,o=s):(o=Math.floor(Math.log(g)/Math.LN2),g*(a=Math.pow(2,-o))<1&&(o--,a*=2),o+l>=1?g+=c/a:g+=c*Math.pow(2,1-l),g*a>=2&&(o++,a/=2),o+l>=s?(C=0,o=s):o+l>=1?(C=(g*a-1)*Math.pow(2,I),o=o+l):(C=g*Math.pow(2,l-1)*Math.pow(2,I),o=0));I>=8;e[i+u]=C&255,u+=d,C/=256,I-=8);for(o=o<0;e[i+u]=o&255,u+=d,o/=256,A-=8);e[i+u-d]|=h*128};/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */(function(e){function g(ge,z){if(!(ge instanceof z))throw new TypeError("Cannot call a class as a function")}function i(ge,z){for(var J=0;J"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function c(ge){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(J){return J.__proto__||Object.getPrototypeOf(J)},c(ge)}const u=l_,d=rAe,h=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=p,e.SlowBuffer=V,e.INSPECT_MAX_BYTES=50;const f=2147483647;e.kMaxLength=f,p.TYPED_ARRAY_SUPPORT=m(),!p.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function m(){try{const ge=new Uint8Array(1),z={foo:function(){return 42}};return Object.setPrototypeOf(z,Uint8Array.prototype),Object.setPrototypeOf(ge,z),ge.foo()===42}catch{return!1}}Object.defineProperty(p.prototype,"parent",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.buffer}}),Object.defineProperty(p.prototype,"offset",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.byteOffset}});function b(ge){if(ge>f)throw new RangeError('The value "'+ge+'" is invalid for option "size"');const z=new Uint8Array(ge);return Object.setPrototypeOf(z,p.prototype),z}function p(ge,z,J){if(typeof ge=="number"){if(typeof z=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return G(ge)}return y(ge,z,J)}p.poolSize=8192;function y(ge,z,J){if(typeof ge=="string")return B(ge,z);if(ArrayBuffer.isView(ge))return R(ge);if(ge==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof ge);if(nt(ge,ArrayBuffer)||ge&&nt(ge.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(nt(ge,SharedArrayBuffer)||ge&&nt(ge.buffer,SharedArrayBuffer)))return w(ge,z,J);if(typeof ge=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const be=ge.valueOf&&ge.valueOf();if(be!=null&&be!==ge)return p.from(be,z,J);const Ke=T(ge);if(Ke)return Ke;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof ge[Symbol.toPrimitive]=="function")return p.from(ge[Symbol.toPrimitive]("string"),z,J);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof ge)}p.from=function(ge,z,J){return y(ge,z,J)},Object.setPrototypeOf(p.prototype,Uint8Array.prototype),Object.setPrototypeOf(p,Uint8Array);function Z(ge){if(typeof ge!="number")throw new TypeError('"size" argument must be of type number');if(ge<0)throw new RangeError('The value "'+ge+'" is invalid for option "size"')}function v(ge,z,J){return Z(ge),ge<=0?b(ge):z!==void 0?typeof J=="string"?b(ge).fill(z,J):b(ge).fill(z):b(ge)}p.alloc=function(ge,z,J){return v(ge,z,J)};function G(ge){return Z(ge),b(ge<0?0:W(ge)|0)}p.allocUnsafe=function(ge){return G(ge)},p.allocUnsafeSlow=function(ge){return G(ge)};function B(ge,z){if((typeof z!="string"||z==="")&&(z="utf8"),!p.isEncoding(z))throw new TypeError("Unknown encoding: "+z);const J=X(ge,z)|0;let be=b(J);const Ke=be.write(ge,z);return Ke!==J&&(be=be.slice(0,Ke)),be}function S(ge){const z=ge.length<0?0:W(ge.length)|0,J=b(z);for(let be=0;be=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return ge|0}function V(ge){return+ge!=ge&&(ge=0),p.alloc(+ge)}p.isBuffer=function(z){return z!=null&&z._isBuffer===!0&&z!==p.prototype},p.compare=function(z,J){if(nt(z,Uint8Array)&&(z=p.from(z,z.offset,z.byteLength)),nt(J,Uint8Array)&&(J=p.from(J,J.offset,J.byteLength)),!p.isBuffer(z)||!p.isBuffer(J))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(z===J)return 0;let be=z.length,Ke=J.length;for(let de=0,le=Math.min(be,Ke);deKe.length?(p.isBuffer(le)||(le=p.from(le)),le.copy(Ke,de)):Uint8Array.prototype.set.call(Ke,le,de);else if(p.isBuffer(le))le.copy(Ke,de);else throw new TypeError('"list" argument must be an Array of Buffers');de+=le.length}return Ke};function X(ge,z){if(p.isBuffer(ge))return ge.length;if(ArrayBuffer.isView(ge)||nt(ge,ArrayBuffer))return ge.byteLength;if(typeof ge!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof ge);const J=ge.length,be=arguments.length>2&&arguments[2]===!0;if(!be&&J===0)return 0;let Ke=!1;for(;;)switch(z){case"ascii":case"latin1":case"binary":return J;case"utf8":case"utf-8":return K(ge).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return J*2;case"hex":return J>>>1;case"base64":return Re(ge).length;default:if(Ke)return be?-1:K(ge).length;z=(""+z).toLowerCase(),Ke=!0}}p.byteLength=X;function N(ge,z,J){let be=!1;if((z===void 0||z<0)&&(z=0),z>this.length||((J===void 0||J>this.length)&&(J=this.length),J<=0)||(J>>>=0,z>>>=0,J<=z))return"";for(ge||(ge="utf8");;)switch(ge){case"hex":return ae(this,z,J);case"utf8":case"utf-8":return Ie(this,z,J);case"ascii":return oe(this,z,J);case"latin1":case"binary":return pe(this,z,J);case"base64":return ee(this,z,J);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,z,J);default:if(be)throw new TypeError("Unknown encoding: "+ge);ge=(ge+"").toLowerCase(),be=!0}}p.prototype._isBuffer=!0;function Y(ge,z,J){const be=ge[z];ge[z]=ge[J],ge[J]=be}p.prototype.swap16=function(){const z=this.length;if(z%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let J=0;JJ&&(z+=" ... "),""},h&&(p.prototype[h]=p.prototype.inspect),p.prototype.compare=function(z,J,be,Ke,de){if(nt(z,Uint8Array)&&(z=p.from(z,z.offset,z.byteLength)),!p.isBuffer(z))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof z);if(J===void 0&&(J=0),be===void 0&&(be=z?z.length:0),Ke===void 0&&(Ke=0),de===void 0&&(de=this.length),J<0||be>z.length||Ke<0||de>this.length)throw new RangeError("out of range index");if(Ke>=de&&J>=be)return 0;if(Ke>=de)return-1;if(J>=be)return 1;if(J>>>=0,be>>>=0,Ke>>>=0,de>>>=0,this===z)return 0;let le=de-Ke,ne=be-J;const re=Math.min(le,ne),Se=this.slice(Ke,de),Fe=z.slice(J,be);for(let xe=0;xe2147483647?J=2147483647:J<-2147483648&&(J=-2147483648),J=+J,wt(J)&&(J=Ke?0:ge.length-1),J<0&&(J=ge.length+J),J>=ge.length){if(Ke)return-1;J=ge.length-1}else if(J<0)if(Ke)J=0;else return-1;if(typeof z=="string"&&(z=p.from(z,be)),p.isBuffer(z))return z.length===0?-1:M(ge,z,J,be,Ke);if(typeof z=="number")return z=z&255,typeof Uint8Array.prototype.indexOf=="function"?Ke?Uint8Array.prototype.indexOf.call(ge,z,J):Uint8Array.prototype.lastIndexOf.call(ge,z,J):M(ge,[z],J,be,Ke);throw new TypeError("val must be string, number or Buffer")}function M(ge,z,J,be,Ke){let de=1,le=ge.length,ne=z.length;if(be!==void 0&&(be=String(be).toLowerCase(),be==="ucs2"||be==="ucs-2"||be==="utf16le"||be==="utf-16le")){if(ge.length<2||z.length<2)return-1;de=2,le/=2,ne/=2,J/=2}function re(Fe,xe){return de===1?Fe[xe]:Fe.readUInt16BE(xe*de)}let Se;if(Ke){let Fe=-1;for(Se=J;Sele&&(J=le-ne),Se=J;Se>=0;Se--){let Fe=!0;for(let xe=0;xeKe&&(be=Ke)):be=Ke;const de=z.length;be>de/2&&(be=de/2);let le;for(le=0;le>>0,isFinite(be)?(be=be>>>0,Ke===void 0&&(Ke="utf8")):(Ke=be,be=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const de=this.length-J;if((be===void 0||be>de)&&(be=de),z.length>0&&(be<0||J<0)||J>this.length)throw new RangeError("Attempt to write outside buffer bounds");Ke||(Ke="utf8");let le=!1;for(;;)switch(Ke){case"hex":return F(this,z,J,be);case"utf8":case"utf-8":return $(this,z,J,be);case"ascii":case"latin1":case"binary":return Q(this,z,J,be);case"base64":return U(this,z,J,be);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,z,J,be);default:if(le)throw new TypeError("Unknown encoding: "+Ke);Ke=(""+Ke).toLowerCase(),le=!0}},p.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ee(ge,z,J){return z===0&&J===ge.length?u.fromByteArray(ge):u.fromByteArray(ge.slice(z,J))}function Ie(ge,z,J){J=Math.min(ge.length,J);const be=[];let Ke=z;for(;Ke239?4:de>223?3:de>191?2:1;if(Ke+ne<=J){let re,Se,Fe,xe;switch(ne){case 1:de<128&&(le=de);break;case 2:re=ge[Ke+1],(re&192)===128&&(xe=(de&31)<<6|re&63,xe>127&&(le=xe));break;case 3:re=ge[Ke+1],Se=ge[Ke+2],(re&192)===128&&(Se&192)===128&&(xe=(de&15)<<12|(re&63)<<6|Se&63,xe>2047&&(xe<55296||xe>57343)&&(le=xe));break;case 4:re=ge[Ke+1],Se=ge[Ke+2],Fe=ge[Ke+3],(re&192)===128&&(Se&192)===128&&(Fe&192)===128&&(xe=(de&15)<<18|(re&63)<<12|(Se&63)<<6|Fe&63,xe>65535&&xe<1114112&&(le=xe))}}le===null?(le=65533,ne=1):le>65535&&(le-=65536,be.push(le>>>10&1023|55296),le=56320|le&1023),be.push(le),Ke+=ne}return Ve(be)}const fe=4096;function Ve(ge){const z=ge.length;if(z<=fe)return String.fromCharCode.apply(String,ge);let J="",be=0;for(;bebe)&&(J=be);let Ke="";for(let de=z;debe&&(z=be),J<0?(J+=be,J<0&&(J=0)):J>be&&(J=be),JJ)throw new RangeError("Trying to access beyond buffer length")}p.prototype.readUintLE=p.prototype.readUIntLE=function(z,J,be){z=z>>>0,J=J>>>0,be||ye(z,J,this.length);let Ke=this[z],de=1,le=0;for(;++le>>0,J=J>>>0,be||ye(z,J,this.length);let Ke=this[z+--J],de=1;for(;J>0&&(de*=256);)Ke+=this[z+--J]*de;return Ke},p.prototype.readUint8=p.prototype.readUInt8=function(z,J){return z=z>>>0,J||ye(z,1,this.length),this[z]},p.prototype.readUint16LE=p.prototype.readUInt16LE=function(z,J){return z=z>>>0,J||ye(z,2,this.length),this[z]|this[z+1]<<8},p.prototype.readUint16BE=p.prototype.readUInt16BE=function(z,J){return z=z>>>0,J||ye(z,2,this.length),this[z]<<8|this[z+1]},p.prototype.readUint32LE=p.prototype.readUInt32LE=function(z,J){return z=z>>>0,J||ye(z,4,this.length),(this[z]|this[z+1]<<8|this[z+2]<<16)+this[z+3]*16777216},p.prototype.readUint32BE=p.prototype.readUInt32BE=function(z,J){return z=z>>>0,J||ye(z,4,this.length),this[z]*16777216+(this[z+1]<<16|this[z+2]<<8|this[z+3])},p.prototype.readBigUInt64LE=yt(function(z){z=z>>>0,Ze(z,"offset");const J=this[z],be=this[z+7];(J===void 0||be===void 0)&&Te(z,this.length-8);const Ke=J+this[++z]*2**8+this[++z]*2**16+this[++z]*2**24,de=this[++z]+this[++z]*2**8+this[++z]*2**16+be*2**24;return BigInt(Ke)+(BigInt(de)<>>0,Ze(z,"offset");const J=this[z],be=this[z+7];(J===void 0||be===void 0)&&Te(z,this.length-8);const Ke=J*2**24+this[++z]*2**16+this[++z]*2**8+this[++z],de=this[++z]*2**24+this[++z]*2**16+this[++z]*2**8+be;return(BigInt(Ke)<>>0,J=J>>>0,be||ye(z,J,this.length);let Ke=this[z],de=1,le=0;for(;++le=de&&(Ke-=Math.pow(2,8*J)),Ke},p.prototype.readIntBE=function(z,J,be){z=z>>>0,J=J>>>0,be||ye(z,J,this.length);let Ke=J,de=1,le=this[z+--Ke];for(;Ke>0&&(de*=256);)le+=this[z+--Ke]*de;return de*=128,le>=de&&(le-=Math.pow(2,8*J)),le},p.prototype.readInt8=function(z,J){return z=z>>>0,J||ye(z,1,this.length),this[z]&128?(255-this[z]+1)*-1:this[z]},p.prototype.readInt16LE=function(z,J){z=z>>>0,J||ye(z,2,this.length);const be=this[z]|this[z+1]<<8;return be&32768?be|4294901760:be},p.prototype.readInt16BE=function(z,J){z=z>>>0,J||ye(z,2,this.length);const be=this[z+1]|this[z]<<8;return be&32768?be|4294901760:be},p.prototype.readInt32LE=function(z,J){return z=z>>>0,J||ye(z,4,this.length),this[z]|this[z+1]<<8|this[z+2]<<16|this[z+3]<<24},p.prototype.readInt32BE=function(z,J){return z=z>>>0,J||ye(z,4,this.length),this[z]<<24|this[z+1]<<16|this[z+2]<<8|this[z+3]},p.prototype.readBigInt64LE=yt(function(z){z=z>>>0,Ze(z,"offset");const J=this[z],be=this[z+7];(J===void 0||be===void 0)&&Te(z,this.length-8);const Ke=this[z+4]+this[z+5]*2**8+this[z+6]*2**16+(be<<24);return(BigInt(Ke)<>>0,Ze(z,"offset");const J=this[z],be=this[z+7];(J===void 0||be===void 0)&&Te(z,this.length-8);const Ke=(J<<24)+this[++z]*2**16+this[++z]*2**8+this[++z];return(BigInt(Ke)<>>0,J||ye(z,4,this.length),d.read(this,z,!0,23,4)},p.prototype.readFloatBE=function(z,J){return z=z>>>0,J||ye(z,4,this.length),d.read(this,z,!1,23,4)},p.prototype.readDoubleLE=function(z,J){return z=z>>>0,J||ye(z,8,this.length),d.read(this,z,!0,52,8)},p.prototype.readDoubleBE=function(z,J){return z=z>>>0,J||ye(z,8,this.length),d.read(this,z,!1,52,8)};function ue(ge,z,J,be,Ke,de){if(!p.isBuffer(ge))throw new TypeError('"buffer" argument must be a Buffer instance');if(z>Ke||zge.length)throw new RangeError("Index out of range")}p.prototype.writeUintLE=p.prototype.writeUIntLE=function(z,J,be,Ke){if(z=+z,J=J>>>0,be=be>>>0,!Ke){const ne=Math.pow(2,8*be)-1;ue(this,z,J,be,ne,0)}let de=1,le=0;for(this[J]=z&255;++le>>0,be=be>>>0,!Ke){const ne=Math.pow(2,8*be)-1;ue(this,z,J,be,ne,0)}let de=be-1,le=1;for(this[J+de]=z&255;--de>=0&&(le*=256);)this[J+de]=z/le&255;return J+be},p.prototype.writeUint8=p.prototype.writeUInt8=function(z,J,be){return z=+z,J=J>>>0,be||ue(this,z,J,1,255,0),this[J]=z&255,J+1},p.prototype.writeUint16LE=p.prototype.writeUInt16LE=function(z,J,be){return z=+z,J=J>>>0,be||ue(this,z,J,2,65535,0),this[J]=z&255,this[J+1]=z>>>8,J+2},p.prototype.writeUint16BE=p.prototype.writeUInt16BE=function(z,J,be){return z=+z,J=J>>>0,be||ue(this,z,J,2,65535,0),this[J]=z>>>8,this[J+1]=z&255,J+2},p.prototype.writeUint32LE=p.prototype.writeUInt32LE=function(z,J,be){return z=+z,J=J>>>0,be||ue(this,z,J,4,4294967295,0),this[J+3]=z>>>24,this[J+2]=z>>>16,this[J+1]=z>>>8,this[J]=z&255,J+4},p.prototype.writeUint32BE=p.prototype.writeUInt32BE=function(z,J,be){return z=+z,J=J>>>0,be||ue(this,z,J,4,4294967295,0),this[J]=z>>>24,this[J+1]=z>>>16,this[J+2]=z>>>8,this[J+3]=z&255,J+4};function Ye(ge,z,J,be,Ke){Ce(z,be,Ke,ge,J,7);let de=Number(z&BigInt(4294967295));ge[J++]=de,de=de>>8,ge[J++]=de,de=de>>8,ge[J++]=de,de=de>>8,ge[J++]=de;let le=Number(z>>BigInt(32)&BigInt(4294967295));return ge[J++]=le,le=le>>8,ge[J++]=le,le=le>>8,ge[J++]=le,le=le>>8,ge[J++]=le,J}function Be(ge,z,J,be,Ke){Ce(z,be,Ke,ge,J,7);let de=Number(z&BigInt(4294967295));ge[J+7]=de,de=de>>8,ge[J+6]=de,de=de>>8,ge[J+5]=de,de=de>>8,ge[J+4]=de;let le=Number(z>>BigInt(32)&BigInt(4294967295));return ge[J+3]=le,le=le>>8,ge[J+2]=le,le=le>>8,ge[J+1]=le,le=le>>8,ge[J]=le,J+8}p.prototype.writeBigUInt64LE=yt(function(z,J=0){return Ye(this,z,J,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeBigUInt64BE=yt(function(z,J=0){return Be(this,z,J,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeIntLE=function(z,J,be,Ke){if(z=+z,J=J>>>0,!Ke){const re=Math.pow(2,8*be-1);ue(this,z,J,be,re-1,-re)}let de=0,le=1,ne=0;for(this[J]=z&255;++de>0)-ne&255;return J+be},p.prototype.writeIntBE=function(z,J,be,Ke){if(z=+z,J=J>>>0,!Ke){const re=Math.pow(2,8*be-1);ue(this,z,J,be,re-1,-re)}let de=be-1,le=1,ne=0;for(this[J+de]=z&255;--de>=0&&(le*=256);)z<0&&ne===0&&this[J+de+1]!==0&&(ne=1),this[J+de]=(z/le>>0)-ne&255;return J+be},p.prototype.writeInt8=function(z,J,be){return z=+z,J=J>>>0,be||ue(this,z,J,1,127,-128),z<0&&(z=255+z+1),this[J]=z&255,J+1},p.prototype.writeInt16LE=function(z,J,be){return z=+z,J=J>>>0,be||ue(this,z,J,2,32767,-32768),this[J]=z&255,this[J+1]=z>>>8,J+2},p.prototype.writeInt16BE=function(z,J,be){return z=+z,J=J>>>0,be||ue(this,z,J,2,32767,-32768),this[J]=z>>>8,this[J+1]=z&255,J+2},p.prototype.writeInt32LE=function(z,J,be){return z=+z,J=J>>>0,be||ue(this,z,J,4,2147483647,-2147483648),this[J]=z&255,this[J+1]=z>>>8,this[J+2]=z>>>16,this[J+3]=z>>>24,J+4},p.prototype.writeInt32BE=function(z,J,be){return z=+z,J=J>>>0,be||ue(this,z,J,4,2147483647,-2147483648),z<0&&(z=4294967295+z+1),this[J]=z>>>24,this[J+1]=z>>>16,this[J+2]=z>>>8,this[J+3]=z&255,J+4},p.prototype.writeBigInt64LE=yt(function(z,J=0){return Ye(this,z,J,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),p.prototype.writeBigInt64BE=yt(function(z,J=0){return Be(this,z,J,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ke(ge,z,J,be,Ke,de){if(J+be>ge.length)throw new RangeError("Index out of range");if(J<0)throw new RangeError("Index out of range")}function _e(ge,z,J,be,Ke){return z=+z,J=J>>>0,Ke||ke(ge,z,J,4),d.write(ge,z,J,be,23,4),J+4}p.prototype.writeFloatLE=function(z,J,be){return _e(this,z,J,!0,be)},p.prototype.writeFloatBE=function(z,J,be){return _e(this,z,J,!1,be)};function Pe(ge,z,J,be,Ke){return z=+z,J=J>>>0,Ke||ke(ge,z,J,8),d.write(ge,z,J,be,52,8),J+8}p.prototype.writeDoubleLE=function(z,J,be){return Pe(this,z,J,!0,be)},p.prototype.writeDoubleBE=function(z,J,be){return Pe(this,z,J,!1,be)},p.prototype.copy=function(z,J,be,Ke){if(!p.isBuffer(z))throw new TypeError("argument should be a Buffer");if(be||(be=0),!Ke&&Ke!==0&&(Ke=this.length),J>=z.length&&(J=z.length),J||(J=0),Ke>0&&Ke=this.length)throw new RangeError("Index out of range");if(Ke<0)throw new RangeError("sourceEnd out of bounds");Ke>this.length&&(Ke=this.length),z.length-J>>0,be=be===void 0?this.length:be>>>0,z||(z=0);let de;if(typeof z=="number")for(de=J;de2**32?Ke=je(String(J)):typeof J=="bigint"&&(Ke=String(J),(J>BigInt(2)**BigInt(32)||J<-(BigInt(2)**BigInt(32)))&&(Ke=je(Ke)),Ke+="n"),be+=` It must be ${z}. Received ${Ke}`,be},RangeError);function je(ge){let z="",J=ge.length;const be=ge[0]==="-"?1:0;for(;J>=be+4;J-=3)z=`_${ge.slice(J-3,J)}${z}`;return`${ge.slice(0,J)}${z}`}function He(ge,z,J){Ze(z,"offset"),(ge[z]===void 0||ge[z+J]===void 0)&&Te(z,ge.length-(J+1))}function Ce(ge,z,J,be,Ke,de){if(ge>J||ge3?z===0||z===BigInt(0)?ne=`>= 0${le} and < 2${le} ** ${(de+1)*8}${le}`:ne=`>= -(2${le} ** ${(de+1)*8-1}${le}) and < 2 ** ${(de+1)*8-1}${le}`:ne=`>= ${z}${le} and <= ${J}${le}`,new it.ERR_OUT_OF_RANGE("value",ne,ge)}He(be,Ke,de)}function Ze(ge,z){if(typeof ge!="number")throw new it.ERR_INVALID_ARG_TYPE(z,"number",ge)}function Te(ge,z,J){throw Math.floor(ge)!==ge?(Ze(ge,J),new it.ERR_OUT_OF_RANGE(J||"offset","an integer",ge)):z<0?new it.ERR_BUFFER_OUT_OF_BOUNDS:new it.ERR_OUT_OF_RANGE(J||"offset",`>= ${J?1:0} and <= ${z}`,ge)}const E=/[^+/0-9A-Za-z-_]/g;function H(ge){if(ge=ge.split("=")[0],ge=ge.trim().replace(E,""),ge.length<2)return"";for(;ge.length%4!==0;)ge=ge+"=";return ge}function K(ge,z){z=z||1/0;let J;const be=ge.length;let Ke=null;const de=[];for(let le=0;le55295&&J<57344){if(!Ke){if(J>56319){(z-=3)>-1&&de.push(239,191,189);continue}else if(le+1===be){(z-=3)>-1&&de.push(239,191,189);continue}Ke=J;continue}if(J<56320){(z-=3)>-1&&de.push(239,191,189),Ke=J;continue}J=(Ke-55296<<10|J-56320)+65536}else Ke&&(z-=3)>-1&&de.push(239,191,189);if(Ke=null,J<128){if((z-=1)<0)break;de.push(J)}else if(J<2048){if((z-=2)<0)break;de.push(J>>6|192,J&63|128)}else if(J<65536){if((z-=3)<0)break;de.push(J>>12|224,J>>6&63|128,J&63|128)}else if(J<1114112){if((z-=4)<0)break;de.push(J>>18|240,J>>12&63|128,J>>6&63|128,J&63|128)}else throw new Error("Invalid code point")}return de}function te(ge){const z=[];for(let J=0;J>8,Ke=J%256,de.push(Ke),de.push(be);return de}function Re(ge){return u.toByteArray(H(ge))}function Ee(ge,z,J,be){let Ke;for(Ke=0;Ke=z.length||Ke>=ge.length);++Ke)z[Ke+J]=ge[Ke];return Ke}function nt(ge,z){return ge instanceof z||ge!=null&&ge.constructor!=null&&ge.constructor.name!=null&&ge.constructor.name===z.name}function wt(ge){return ge!==ge}const kt=function(){const ge="0123456789abcdef",z=new Array(256);for(let J=0;J<16;++J){const be=J*16;for(let Ke=0;Ke<16;++Ke)z[be+Ke]=ge[J]+ge[Ke]}return z}();function yt(ge){return typeof BigInt>"u"?Pt:ge}function Pt(){throw new Error("BigInt not supported")}})(CQe);var fm=fn,nr=Pog,sQe=CQe.Buffer;globalThis.__TYPEDARRAY_POOL||(globalThis.__TYPEDARRAY_POOL={UINT8:nr([32,0]),UINT16:nr([32,0]),UINT32:nr([32,0]),BIGUINT64:nr([32,0]),INT8:nr([32,0]),INT16:nr([32,0]),INT32:nr([32,0]),BIGINT64:nr([32,0]),FLOAT:nr([32,0]),DOUBLE:nr([32,0]),DATA:nr([32,0]),UINT8C:nr([32,0]),BUFFER:nr([32,0])});var qog=typeof Uint8ClampedArray<"u",eCg=typeof BigUint64Array<"u",tCg=typeof BigInt64Array<"u",Jn=globalThis.__TYPEDARRAY_POOL;Jn.UINT8C||(Jn.UINT8C=nr([32,0]));Jn.BIGUINT64||(Jn.BIGUINT64=nr([32,0]));Jn.BIGINT64||(Jn.BIGINT64=nr([32,0]));Jn.BUFFER||(Jn.BUFFER=nr([32,0]));var c_=Jn.DATA,u_=Jn.BUFFER;Hg.free=function(g){if(sQe.isBuffer(g))u_[fm.log2(g.length)].push(g);else{if(Object.prototype.toString.call(g)!=="[object ArrayBuffer]"&&(g=g.buffer),!g)return;var i=g.length||g.byteLength,n=fm.log2(i)|0;c_[n].push(g)}};function AQe(e){if(e){var g=e.length||e.byteLength,i=fm.log2(g);c_[i].push(e)}}function gCg(e){AQe(e.buffer)}Hg.freeUint8=Hg.freeUint16=Hg.freeUint32=Hg.freeBigUint64=Hg.freeInt8=Hg.freeInt16=Hg.freeInt32=Hg.freeBigInt64=Hg.freeFloat32=Hg.freeFloat=Hg.freeFloat64=Hg.freeDouble=Hg.freeUint8Clamped=Hg.freeDataView=gCg;Hg.freeArrayBuffer=AQe;Hg.freeBuffer=function(g){u_[fm.log2(g.length)].push(g)};Hg.malloc=function(g,i){if(i===void 0||i==="arraybuffer")return DC(g);switch(i){case"uint8":return oAe(g);case"uint16":return lQe(g);case"uint32":return cQe(g);case"int8":return uQe(g);case"int16":return dQe(g);case"int32":return hQe(g);case"float":case"float32":return fQe(g);case"double":case"float64":return mQe(g);case"uint8_clamped":return pQe(g);case"bigint64":return yQe(g);case"biguint64":return bQe(g);case"buffer":return GQe(g);case"data":case"dataview":return ZQe(g);default:return null}return null};function DC(g){var g=fm.nextPow2(g),i=fm.log2(g),n=c_[i];return n.length>0?n.pop():new ArrayBuffer(g)}Hg.mallocArrayBuffer=DC;function oAe(e){return new Uint8Array(DC(e),0,e)}Hg.mallocUint8=oAe;function lQe(e){return new Uint16Array(DC(2*e),0,e)}Hg.mallocUint16=lQe;function cQe(e){return new Uint32Array(DC(4*e),0,e)}Hg.mallocUint32=cQe;function uQe(e){return new Int8Array(DC(e),0,e)}Hg.mallocInt8=uQe;function dQe(e){return new Int16Array(DC(2*e),0,e)}Hg.mallocInt16=dQe;function hQe(e){return new Int32Array(DC(4*e),0,e)}Hg.mallocInt32=hQe;function fQe(e){return new Float32Array(DC(4*e),0,e)}Hg.mallocFloat32=Hg.mallocFloat=fQe;function mQe(e){return new Float64Array(DC(8*e),0,e)}Hg.mallocFloat64=Hg.mallocDouble=mQe;function pQe(e){return qog?new Uint8ClampedArray(DC(e),0,e):oAe(e)}Hg.mallocUint8Clamped=pQe;function bQe(e){return eCg?new BigUint64Array(DC(8*e),0,e):null}Hg.mallocBigUint64=bQe;function yQe(e){return tCg?new BigInt64Array(DC(8*e),0,e):null}Hg.mallocBigInt64=yQe;function ZQe(e){return new DataView(DC(e),0,e)}Hg.mallocDataView=ZQe;function GQe(e){e=fm.nextPow2(e);var g=fm.log2(e),i=u_[g];return i.length>0?i.pop():new sQe(e)}Hg.mallocBuffer=GQe;Hg.clearCache=function(){for(var g=0;g<32;++g)Jn.UINT8[g].length=0,Jn.UINT16[g].length=0,Jn.UINT32[g].length=0,Jn.INT8[g].length=0,Jn.INT16[g].length=0,Jn.INT32[g].length=0,Jn.FLOAT[g].length=0,Jn.DOUBLE[g].length=0,Jn.BIGUINT64[g].length=0,Jn.BIGINT64[g].length=0,Jn.UINT8C[g].length=0,c_[g].length=0,u_[g].length=0};var iCg=nCg,f5=32;function nCg(e,g){g<=4*f5?m5(0,g-1,e):p5(0,g-1,e)}function m5(e,g,i){for(var n=2*(e+1),I=e+1;I<=g;++I){for(var r=i[n++],o=i[n++],C=I,a=n-2;C-- >e;){var A=i[a-2],s=i[a-1];if(Ai[g+1]:!0}function eY(e,g,i,n){e*=2;var I=n[e];return I>1,C=o-n,a=o+n,A=I,s=C,l=o,c=a,u=r,d=e+1,h=g-1,f=0;bu(A,s,i)&&(f=A,A=s,s=f),bu(c,u,i)&&(f=c,c=u,u=f),bu(A,l,i)&&(f=A,A=l,l=f),bu(s,l,i)&&(f=s,s=l,l=f),bu(A,c,i)&&(f=A,A=c,c=f),bu(l,c,i)&&(f=l,l=c,c=f),bu(s,u,i)&&(f=s,s=u,u=f),bu(s,l,i)&&(f=s,s=l,l=f),bu(c,u,i)&&(f=c,c=u,u=f);for(var m=i[2*s],b=i[2*s+1],p=i[2*c],y=i[2*c+1],Z=2*A,v=2*l,G=2*u,B=2*I,S=2*o,R=2*r,w=0;w<2;++w){var T=i[Z+w],W=i[v+w],V=i[G+w];i[B+w]=T,i[S+w]=W,i[R+w]=V}SRe(C,e,i),SRe(a,g,i);for(var X=d;X<=h;++X)if(eY(X,m,b,i))X!==d&&wRe(X,d,i),++d;else if(!eY(X,p,y,i))for(;;)if(eY(h,p,y,i)){eY(h,m,b,i)?(ICg(X,d,h,i),++d,--h):(wRe(X,h,i),--h);break}else{if(--h>>1;d_(Rg,b);for(var p=0,y=0,d=0;d=oa)Z=Z-oa|0,tB(hd,Q0,y--,Z);else if(Z>=0)tB(ar,dd,p--,Z);else if(Z<=-oa){Z=-Z-oa|0;for(var v=0;v>>1;d_(Rg,b);for(var p=0,y=0,Z=0,d=0;d>1===Rg[2*d+3]>>1&&(G=2,d+=1),v<0){for(var B=-(v>>1)-1,S=0;S>1)-1;G===0?tB(ar,dd,p--,B):G===1?tB(hd,Q0,y--,B):G===2&&tB(eB,fW,Z--,B)}}}function sCg(e,g,i,n,I,r,o,C,a,A,s,l){var c=0,u=2*e,d=g,h=g+e,f=1,m=1;n?m=oa:f=oa;for(var b=I;b>>1;d_(Rg,v);for(var G=0,b=0;b=oa?(S=!n,p-=oa):(S=!!n,p-=1),S)gB(ar,dd,G++,p);else{var R=l[p],w=u*p,T=s[w+g+1],W=s[w+g+1+e];e:for(var V=0;V>>1;d_(Rg,p);for(var y=0,h=0;h=oa)ar[y++]=f-oa;else{f-=1;var v=s[f],G=c*f,B=A[G+g+1],S=A[G+g+1+e];e:for(var R=0;R=0;--R)if(ar[R]===f){for(var V=R+1;V"+sAe+"-"+fE+"){"),e?(r(!0,!1),I.push("}else{"),r(!1,!1)):(I.push("if("+NQ+"){"),r(!0,!0),I.push("}else{"),r(!0,!1),I.push("}}else{if("+NQ+"){"),r(!1,!0),I.push("}else{"),r(!1,!1),I.push("}")),I.push("}}return "+g);var o=i.join("")+I.join(""),C=new Function(o);return C()}CAe.partial=RQe(!1);CAe.full=RQe(!0);var VQe=uCg,cCg="for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var _;if($)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t}var u=f[p];f[p]=f[m],f[m++]=u}}return m";function uCg(e,g){var i="abcdef".split("").concat(g),n=[];return e.indexOf("lo")>=0&&n.push("lo=e[k+n]"),e.indexOf("hi")>=0&&n.push("hi=e[k+o]"),i.push(cCg.replace("_",n.join()).replace("$",e)),Function.apply(void 0,i)}var dCg=pCg,hCg=VQe,VRe=hCg("loi&&I[l+g]>A;--s,l-=o){for(var c=l,u=l+o,d=0;d>>1,A=2*e,s=a,l=I[A*a+g];o=f?(s=h,l=f):d>=b?(s=u,l=d):(s=m,l=b):f>=b?(s=h,l=f):b>=d?(s=u,l=d):(s=m,l=b);for(var Z=A*(C-1),v=A*s,p=0;p=p0)&&!(p1>=hi)",["p0","p1"]),XRe=q1("lo===p0",["p0"]),SCg=q1("lo0;){A-=1;var c=A*AAe,u=Zo[c],d=Zo[c+1],h=Zo[c+2],f=Zo[c+3],m=Zo[c+4],b=Zo[c+5],p=A*lAe,y=j0[p],Z=j0[p+1],v=b&1,G=!!(b&16),B=I,S=r,R=C,w=a;if(v&&(B=C,S=a,R=I,w=r),!(b&2&&(h=SCg(e,u,d,h,B,S,Z),d>=h))&&!(b&4&&(d=RCg(e,u,d,h,B,S,y),d>=h))){var T=h-d,W=m-f;if(G){if(e*T*(T+W)>>1;if(!(o<=0)){var C,a=Wh.mallocDouble(2*o*I),A=Wh.mallocInt32(I);if(I=HRe(e,o,a,A),I>0){if(o===1&&n)tY.init(I),C=tY.sweepComplete(o,i,0,I,a,A,0,I,a,A);else{var s=Wh.mallocDouble(2*o*r),l=Wh.mallocInt32(r);r=HRe(g,o,s,l),r>0&&(tY.init(I+r),o===1?C=tY.sweepBipartite(o,i,0,I,a,A,0,r,s,l):C=kCg(o,i,n,I,a,A,r,s,l),Wh.free(s),Wh.free(l))}Wh.free(a),Wh.free(A)}return C}}}var a9;function TQe(e,g){a9.push([e,g])}function KCg(e){return a9=[],mE(e,e,TQe,!0),a9}function xCg(e,g){return a9=[],mE(e,g,TQe,!1),a9}function FCg(e,g,i){switch(arguments.length){case 1:return KCg(e);case 2:return typeof g=="function"?mE(e,e,g,!0):xCg(e,g);case 3:return mE(e,g,i,!1);default:throw new Error("box-intersect: Invalid arguments")}}const iH=EC(NCg);var HQe={exports:{}},NQe=ECg,NRe=+(Math.pow(2,27)+1);function ECg(e,g,i){var n=e*g,I=NRe*e,r=I-e,o=I-r,C=e-o,a=NRe*g,A=a-g,s=a-A,l=g-s,c=n-o*s,u=c-C*s,d=u-o*l,h=C*l-d;return i?(i[0]=h,i[1]=n,i):[h,n]}var DCg=zCg;function MCg(e,g){var i=e+g,n=i-e,I=i-n,r=g-n,o=e-I,C=o+r;return C?[C,i]:[i]}function zCg(e,g){var i=e.length|0,n=g.length|0;if(i===1&&n===1)return MCg(e[0],g[0]);var I=i+n,r=new Array(I),o=0,C=0,a=0,A=Math.abs,s=e[C],l=A(s),c=g[a],u=A(c),d,h;l=n?(d=s,C+=1,C=n?(d=s,C+=1,C0){if(B<=0)return S;R=G+B}else if(G<0){if(B>=0)return S;R=-(G+B)}else return S;var w=C*R;return S>=w||S<=-w?S:u(y,Z,v)},function(y,Z,v,G){var B=y[0]-G[0],S=Z[0]-G[0],R=v[0]-G[0],w=y[1]-G[1],T=Z[1]-G[1],W=v[1]-G[1],V=y[2]-G[2],X=Z[2]-G[2],N=v[2]-G[2],Y=S*W,x=R*T,M=R*w,F=B*W,$=B*T,Q=S*w,U=V*(Y-x)+X*(M-F)+N*($-Q),j=(Math.abs(Y)+Math.abs(x))*Math.abs(V)+(Math.abs(M)+Math.abs(F))*Math.abs(X)+(Math.abs($)+Math.abs(Q))*Math.abs(N),ee=a*j;return U>ee||-U>ee?U:d(y,Z,v,G)}];function f(p){var y=h[p.length];return y||(y=h[p.length]=c(p.length)),y.apply(void 0,p)}function m(p,y,Z,v,G,B,S){return function(w,T,W,V,X){switch(arguments.length){case 0:case 1:return 0;case 2:return v(w,T);case 3:return G(w,T,W);case 4:return B(w,T,W,V);case 5:return S(w,T,W,V,X)}for(var N=new Array(arguments.length),Y=0;Y0;){var b=(a+I-1)%I,p=e[b];if(p[1]!==n)break;var y=p[0];f=Math.min(f,y),m=Math.max(m,y),a=b}if(a===0)return f<=i&&i<=m?0:1;o=a+1}for(var Z=e[(a+I-1)%I][1];C+1"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Ma(e){return Ma=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},Ma(e)}const YRe=16,KRe=50,FQ=5e3,xRe=5,Aag=14,Wp={fontSize:`${Aag}px`,fontFamily:"Arial",stroke:"white",strokeThickness:2,fontWeight:400,dropShadow:!0,dropShadowColor:"white",dropShadowDistance:0,dropShadowBlur:2};let YQe=function(e){rag(i,e);var g=oag(i);function i(n,I){var r;return tag(this,i),r=g.call(this,n,I),r.valueScaleTransform=NI,r}return gag(i,[{key:"initialize",value:function(){this.initialized||([this.prevK,this.vertK,this.vertY]=[1,1,0],this.drawnRects||(this.drawnRects={}),this.colorScale||(this.options.colorRange?this.colorScale=hm(this.options.colorRange):this.colorScale=ew),this.initialized=!0)}},{key:"initTile",value:function(I){I.texts={},I.rectGraphics=new st.PIXI.Graphics,I.textGraphics=new st.PIXI.Graphics,I.graphics.addChild(I.rectGraphics),I.graphics.addChild(I.textGraphics);let r=[],o=[];if(I.tileData&&I.tileData.length){if(I.tileData.sort((C,a)=>a.importance-C.importance),!this.options||!this.options.valueColumn){const C=I.tileData.map(a=>{const A=+a.chrOffset;return{from:+a.fields[1]+A,to:+a.fields[2]+A,value:a,text:a.fields[3],strand:a.fields.length>=6&&a.fields[5]==="-"?"-":"+"}});r=zF(C.filter(a=>a.strand==="+")),o=zF(C.filter(a=>a.strand==="-"))}else r=[I.tileData.map(C=>({value:C}))];I.plusStrandRows=r,I.minusStrandRows=o,this.options.showTexts&&I.tileData.forEach((C,a)=>{const A=C.fields;if(C.importance||(C.importance=Math.random()),I.textWidths={},I.textHeights={},a>=(+this.options.maxTexts||KRe))return;const s=new st.PIXI.Text(A[3],{...Wp,fontSize:+this.options.fontSize||Wp.fontSize});this.flipText&&(s.scale.x=-1),s.anchor.x=.5,s.anchor.y=.5,I.texts[C.uid]=s,I.textGraphics.addChild(s)})}I.initialized=!0}},{key:"removeTileRects",value:function(I){const r=+I.tileId.split(".")[0];I.rectGraphics.clear(),I.rendered=!1,I.tileData&&I.tileData.length&&I.tileData.forEach((o,C)=>{this.drawnRects[r]&&this.drawnRects[r][o.uid]&&this.drawnRects[r][o.uid][2]===I.tileId&&delete this.drawnRects[r][o.uid]})}},{key:"destroyTile",value:function(I){this.removeTileRects(I),I.graphics.removeChild(I.textGraphics),I.graphics.removeChild(I.rectGraphics)}},{key:"removeTiles",value:function(I){Vl(Ma(i.prototype),"removeTiles",this).call(this,I)}},{key:"drawTile",value:function(I){this.options&&this.options.valueColumn&&this.valueScale&&this.drawAxis(this.valueScale)}},{key:"rerender",value:function(I,r){Vl(Ma(i.prototype),"rerender",this).call(this,I,r),this.valueScale=null,this.drawnRects={},this.options.colorRange?this.colorScale=hm(this.options.colorRange):this.colorScale=ew;for(const o of this.visibleAndFetchedTiles())this.destroyTile(o),this.initTile(o),this.renderTile(o)}},{key:"updateTile",value:function(I){this.areAllVisibleTilesLoaded()&&this.renderTile(I)}},{key:"allVisibleRects",value:function(){const I={};Object.values(this.fetchedTiles).forEach(a=>{if(a.plusStrandRows)for(const A of a.plusStrandRows[0])I[A.value.uid]||(I[A.value.uid]=A)});const r=Object.values(I).sort((a,A)=>a.from-A.from);let o=0,C=0;for(let a=0;a=0&&r.length;a--)r[a].staggeredStartPosition=(C+o-a)%2;return I}},{key:"drawSegmentStyle",value:function(I,r,o,C,a,A){const l=C+a/2,c=[r,C,r+2*.1,C,r+2*.1,l-.1,o-2*.1,l-.1,o-2*.1,C,o,C,o,C+a,o-2*.1,C+a,o-2*.1,l+.1,r+2*.1,l+.1,r+2*.1,C+a,r,C+a];return I.rectGraphics.drawPolygon(c),c}},{key:"drawPoly",value:function(I,r,o,C,a,A){let s=null;return this.options.annotationStyle==="segment"?this.drawSegmentStyle(I,r,o,C,a,A):((A==="+"||A==="-")&&o-r=(+this.options.maxTexts||KRe)||!I.texts[h.uid])continue;const T=I.texts[h.uid];T.position.x=this._xScale(y),T.position.y=B+v/2,T.nominalY=B+v/2,w&&(T.alreadyDrawn=!0);const W=this.options.fontColor!==void 0?jt(this.options.fontColor):A;if(T.style={...Wp,fill:W,fontSize:+this.options.fontSize||Wp.fontSize},!(f[3]in I.textWidths)){T.updateTransform();const V=T.getBounds().width,X=T.getBounds().height,N=5;I.textWidths[f[3]]=V,I.textHeights[f[3]]=X-N}}}},{key:"renderTile",value:function(I){let r=I.plusStrandRows?I.plusStrandRows.length:1,o=I.minusStrandRows?I.minusStrandRows.length:1;for(const C of this.visibleAndFetchedTiles()){if(!C.initialized)return;!C.plusStrandRows&&!C.minusStrandRows||(r=Math.max(C.plusStrandRows.length,r),o=Math.max(C.minusStrandRows.length,o))}if(I.rendered&&this.removeTileRects(I),I.drawnAtScale=this._xScale.copy(),I.rendered=!0,this.setValueScale(),this.setColorValueScale(),I.tileData&&I.tileData.length){const C=this.options.plusStrandColor||this.options.fillColor||"blue",a=this.options.minusStrandColor||this.options.fillColor||"purple",A=0;let s=0;this.options.separatePlusMinusStrands?s=r*this.dimensions[1]/(r+o)-A/2:s=this.dimensions[1],this.renderRows(I,I.plusStrandRows,r,0,s,C),this.renderRows(I,I.minusStrandRows,o,this.options.separatePlusMinusStrands?s+A/2:0,this.dimensions[1],a)}U0.stretchRects(this,[C=>C.rectGraphics])}},{key:"calculateZoomLevel",value:function(){const I=Nt.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]);let r=Math.min(I,this.maxZoom);return r=Math.max(r,0),r}},{key:"minVisibleValueInTiles",value:function(I){let r=this.visibleAndFetchedIds();r.length===0&&(r=Object.keys(this.fetchedTiles));let o=Math.min.apply(null,r.map(C=>this.fetchedTiles[C]).filter(C=>C.tileData&&C.tileData.length).map(C=>Math.min.apply(null,C.tileData.sort((a,A)=>A.importance-a.importance).slice(0,FQ).map(a=>+a.fields[I-1]).filter(a=>!Number.isNaN(a)))));return o===Number.MAX_SAFE_INTEGER&&(o=null),o}},{key:"maxVisibleValueInTiles",value:function(I){let r=this.visibleAndFetchedIds();r.length===0&&(r=Object.keys(this.fetchedTiles));let o=Math.max.apply(null,r.map(C=>this.fetchedTiles[C]).filter(C=>C.tileData&&C.tileData.length).map(C=>Math.max.apply(null,C.tileData.sort((a,A)=>A.importance-a.importance).slice(0,FQ).map(a=>+a.fields[I-1]).filter(a=>!Number.isNaN(a)))));return o===Number.MIN_SAFE_INTEGER&&(o=null),o}},{key:"calculateMedianVisibleValue",value:function(I){this.areAllVisibleTilesLoaded()&&this.allTilesLoaded();let r=this.visibleAndFetchedIds();r.length===0&&(r=Object.keys(this.fetchedTiles));const o=[].concat(...r.map(C=>this.fetchedTiles[C]).filter(C=>C.tileData&&C.tileData.length).map(C=>C.tileData.sort((a,A)=>A.importance-a.importance).slice(0,FQ).map(a=>+a.fields[I-1]))).filter(C=>C>0);this.medianVisibleValue=VCe(o)}},{key:"draw",value:function(){Vl(Ma(i.prototype),"draw",this).call(this),this.allTexts=[],this.allBoxes=[];for(const I in this.fetchedTiles){const r=this.fetchedTiles[I];if(r.rectGraphics.scale.y=this.vertK,r.rectGraphics.position.y=this.vertY,!r.drawnAtScale)return;U0.stretchRects(this,[C=>C.rectGraphics]);const o=this.parentInFetched(r);r.initialized&&r.tileData&&r.tileData.length&&r.tileData.forEach(C=>{if(!r.texts)return;const a=C.fields,A=a[3],s=r.texts[C.uid];if(!s)return;const l=+C.chrOffset,c=+a[1]+l,u=+a[2]+l,d=(c+u)/2;if(s.position.x=this._xScale(d),s.position.y=s.nominalY*(this.vertK*this.prevK)+this.vertY,!o&&!s.alreadyDrawn){s.visible=!0;const h=3;this.allBoxes.push([s.position.x-h,s.position.y-r.textHeights[a[3]]/2,s.position.x+r.textWidths[a[3]]+h,s.position.y+r.textHeights[a[3]]/2]),this.allTexts.push({importance:C.importance,text:s,caption:A,strand:a[5]})}else s.visible=!1})}this.hideOverlaps(this.allBoxes,this.allTexts)}},{key:"hideOverlaps",value:function(I,r){iH(I,(o,C)=>{r[o].importance>r[C].importance?r[o].text.visible&&(r[C].text.visible=!1):r[C].text.visible&&(r[o].text.visible=!1)})}},{key:"setPosition",value:function(I){Vl(Ma(i.prototype),"setPosition",this).call(this,I),[this.pMain.position.x,this.pMain.position.y]=this.position}},{key:"setDimensions",value:function(I){Vl(Ma(i.prototype),"setDimensions",this).call(this,I)}},{key:"zoomed",value:function(I,r){this.xScale(I),this.yScale(r),this.refreshTiles(),this.draw()}},{key:"exportSVG",value:function(){let I=null,r=null;Vl(Ma(i.prototype),"exportSVG",this)?[r,I]=Vl(Ma(i.prototype),"exportSVG",this).call(this):(r=document.createElement("g"),I=r);const o=document.createElement("g");o.setAttribute("transform",`translate(${this.position[0]},${this.position[1]})`),I.appendChild(o);const C=document.createElement("g"),a=document.createElement("g");o.appendChild(C),o.appendChild(a);for(const A of this.visibleAndFetchedTiles())A.tileData.length&&A.tileData.forEach(s=>{const l=+A.tileId.split(".")[0],c=document.createElement("g");if(c.setAttribute("transform",`translate(${A.rectGraphics.position.x},${A.rectGraphics.position.y})scale(${A.rectGraphics.scale.x},${A.rectGraphics.scale.y})`),C.appendChild(c),this.drawnRects[l]&&s.uid in this.drawnRects[l]){const u=this.drawnRects[l][s.uid][0],d=document.createElement("path");let h=`M ${u[0]} ${u[1]}`;for(let b=2;b{const o=this.valueScaleTransform,{y:C,k:a}=o,A=this.dimensions[1];C+I/a>-(a-1)*A&&C+I/a<0&&(this.valueScaleTransform=o.translate(0,I/a)),r.rectGraphics.position.y=this.valueScaleTransform.y,this.vertY=this.valueScaleTransform.y}),this.animate()}},{key:"zoomedY",value:function(I,r){const o=U0.zoomedY(I,r,this.valueScaleTransform,this.dimensions[1]);this.valueScaleTransform=o;let C=o.k;const a=o.y;let A=!1;C/=this.prevK,(C>1.5||C<1/1.5)&&(this.prevK*=C,C=1,A=!0),this.vertK=C,this.vertY=a,Object.values(this.fetchedTiles).forEach(s=>{A&&this.renderTile(s),s.rectGraphics.scale.y=C,s.rectGraphics.position.y=a}),this.draw(),this.animate()}},{key:"getMouseOverHtml",value:function(I,r){if(!this.tilesetInfo)return"";const o=this.calculateZoomLevel(),C=[I,r];if(this.drawnRects[o]){const a=Object.values(this.drawnRects[o]);for(let A=0;A"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Pl(e){return Pl=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},Pl(e)}const Zag=(e,g,i,n,I)=>{I.drawRect(e,g,i,n)},Gag=(e,g,i,n,I,{fill:r=0,fillOpacity:o=0,stroke:C=0,strokeWidth:a=0,strokeOpacity:A=0}={})=>{const s=document.createElement("rect");s.setAttribute("x",e),s.setAttribute("y",g),s.setAttribute("width",i),s.setAttribute("height",n),s.setAttribute("fill",`#${yq(r)}`),s.setAttribute("fill-opacity",o),s.setAttribute("stroke",`#${yq(C)}`),s.setAttribute("stroke-opacity",A),s.setAttribute("stroke-width",a),I.appendChild(s)},Zl=(e,g,i,n,I,r)=>{I instanceof HTMLElement?Gag(e,g,i,n,I,r):Zag(e,g,i,n,I)},ERe=(e,g,i,n,I,r,o,C,{isVertical:a=!1,svg:A=null}={})=>{let s=g,l=i,c=n,u=I;const d=C.width*2>n?n/2:C.width,h=C.width*2>I?I/2:C.width,f=A||e,m={fill:0,fillOpacity:0,stroke:0,strokeOpacity:0,strokeWidth:1};if(C.positions&&C.positions.length?(e.lineStyle(1,0,0),e.beginFill(C.color,C.opacity),m.fill=C.color,m.fillOpacity=C.opacity,m.stroke=0,m.strokeOpacity=0,m.strokeWidth=1,C.positions.forEach(b=>{b==="top"&&!a||b==="left"&&a?Zl(g-d,i-h,n+d*2,h,f,m):b==="bottom"&&!a||b==="right"&&a?Zl(g-d,i+I,n+d*2,h,f,m):b==="left"&&!a||b==="top"&&a?Zl(g-d,i-h,d,I+h*2,f,m):(b==="right"&&!a||b==="bottom"&&a)&&Zl(g+n,i-h,d,I+h*2,f,m)})):C.width>0&&C.opacity>0&&(e.lineStyle(C.width,C.color,C.opacity),e.beginFill(0,0),m.fill=0,m.fillOpacity=0,m.stroke=C.color,m.strokeOpacity=C.opacity,m.strokeWidth=C.width,Zl(g-d,i-h,n+d*2,I+h*2,f,m)),o.positions&&o.positions.length){e.lineStyle(1,0,0),e.beginFill(o.color,o.opacity);const b=o.width*2>n?n/2:o.width,p=o.width*2>I?I/2:o.width;m.fill=o.color,m.fillOpacity=o.opacity,m.stroke=0,m.strokeOpacity=0,m.strokeWidth=1,o.positions.forEach(y=>{y==="top"&&!a||y==="left"&&a?(Zl(g,i,n,p,f,m),l+=p,u-=p):y==="bottom"&&!a||y==="right"&&a?(Zl(g,i+I-p,n,p,f,m),u-=p):y==="left"&&!a||y==="top"&&a?(Zl(g,i,b,I,f,m),s+=b,c-=b):(y==="right"&&!a||y==="bottom"&&a)&&(Zl(g+n-b,i,b,I,f,m),c-=b)})}else e.lineStyle(o.width,o.color,o.opacity),m.stroke=o.color,m.strokeOpacity=o.opacity,m.strokeWidth=o.width;e.beginFill(r.color,r.opacity),m.fill=r.color,m.fillOpacity=r.opacity,Zl(s,l,c,u,f,m)};let KQe=function(e){fag(i,e);var g=mag(i);function i(n,I){var r;return lag(this,i),r=g.call(this,n,I),r.options=I||{},r.drawnRects={},r}return cag(i,[{key:"drawHorizontalOverlay",value:function(I,r,o,C=0,a,A,s,l){if(!o||o.length<2)return;let c=this.position[0]+r.left+this._xScale(o[0]);const u=this.position[1]+r.top,d=r.height;let h=this._xScale(o[1])-this._xScale(o[0]);h=4?o[2]:o[0]);const d=this.position[1]+r.top,h=this.position[1]+r.top+r.height;if(u>h)return;u=4?o[3]:o[1])-u+r.top+this.position[1];m<0||(u+m>h&&(m+=h-(u+m)),m{(l.orientation==="1d-horizontal"||l.orientation==="2d")&&this.options.extent.forEach(c=>this.drawHorizontalOverlay(r,l.position,c,A,o,C,a,I)),(l.orientation==="1d-vertical"||l.orientation==="2d")&&this.options.extent.forEach(c=>this.drawVerticalOverlay(r,l.position,c,s,o,C,a,I))})}},{key:"zoomed",value:function(I,r){this.xScale(I),this.yScale(r),this.draw()}},{key:"setPosition",value:function(I){af(Pl(i.prototype),"setPosition",this).call(this,I),this.draw()}},{key:"setDimensions",value:function(I){af(Pl(i.prototype),"setDimensions",this).call(this,I),this.draw()}},{key:"exportSVG",value:function(){let I=null,r=null;af(Pl(i.prototype),"exportSVG",this)?[r,I]=af(Pl(i.prototype),"exportSVG",this).call(this):(r=document.createElement("g"),I=r);const o=document.createElement("g");return I.appendChild(o),this.draw({svg:o}),[r,I]}}]),i}(Lo);function vag(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function DRe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function $C(e){return $C=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},$C(e)}let eS=function(e){Vag(i,e);var g=Wag(i);function i(){return vag(this,i),g.apply(this,arguments)}return Bag(i,[{key:"stopHover",value:function(){this.pMouseOver.clear(),this.animate()}},{key:"getMouseOverHtml",value:function(I){if(!this.tilesetInfo||!this.options.showTooltip||!this.valueScale)return"";const r=this.getDataAtPos(I);let o="";r&&(o=da(".3f")(r));const C=this.pMouseOver,a=0,A=this.valueScale(r);C.clear(),C.beginFill(a,.5),C.lineStyle(1,a,1);const s=4;return C.drawRect(I-s/2,A-s/2,s,s),this.animate(),`${o}`}},{key:"initTile",value:function(I){if(iA($C(i.prototype),"initTile",this).call(this,I),!I.tileData||!I.tileData.dense){console.warn("emptyTile:",I);return}if(I.xValues=new Array(I.tileData.dense.length),I.yValues=new Array(I.tileData.dense.length),this.isValueScaleLocked()){const r=this.getLockGroupExtrema();r!==null&&(this.minValue(r[0]),this.maxValue(r[1]))}this.drawTile(I)}},{key:"rerender",value:function(I,r){iA($C(i.prototype),"rerender",this).call(this,I,r),this.options=I,iA($C(i.prototype),"draw",this).call(this),this.visibleAndFetchedTiles().forEach(o=>{this.renderTile(o)})}},{key:"renderTile",value:function(I){this.drawTile(I),this.drawAxis(this.valueScale)}},{key:"drawTile",value:function(I){if(iA($C(i.prototype),"drawTile",this).call(this,I),!I.graphics||!I.tileData||!I.tileData.dense)return;const r=I.graphics,{tileX:o,tileWidth:C}=this.getTilePosAndDimensions(I.tileData.zoomLevel,I.tileData.tilePos),a=I.tileData.dense;if(a.length===0)return;const[A,s]=this.makeValueScale(this.minValue(),this.medianVisibleValue,this.maxValue());if(this.valueScale=A,r.clear(),this.drawAxis(this.valueScale),this.options.valueScaling==="log"&&this.valueScale.domain()[1]<0){console.warn("Negative values present when using a log scale",this.valueScale.domain());return}const l=jt(this.options.lineStrokeColor?this.options.lineStrokeColor:"blue");!this.tilesetInfo.tile_size&&!this.tilesetInfo.bins_per_dimension&&console.warn("No tileset_info.tile_size or tileset_info.bins_per_dimension",this.tilesetInfo);const c=this.tilesetInfo.tile_size||this.tilesetInfo.bins_per_dimension,u=bg().domain([0,c]).range([o,o+C]),d=this.options.lineStrokeWidth?this.options.lineStrokeWidth:1;r.lineStyle(d,l,1),I.segments=[];let h=[];for(let f=0;f1&&I.segments.push(h),h=[];continue}if(u(f)>this.tilesetInfo.max_pos[0])break;h.push([m,b])}h.length>1&&I.segments.push(h);for(const f of I.segments){const m=f[0],b=f.slice(1);r.moveTo(m[0],m[1]);for(const p of b)r.lineTo(p[0],p[1])}}},{key:"setPosition",value:function(I){iA($C(i.prototype),"setPosition",this).call(this,I),this.pMain.position.y=this.position[1],this.pMain.position.x=this.position[0],this.pMouseOver.position.y=this.position[1],this.pMouseOver.position.x=this.position[0]}},{key:"zoomed",value:function(I,r){this.xScale(I),this.yScale(r),this.refreshTiles(),this.draw();const o=this.isValueScaleLocked();if(this.continuousScaling&&this.minValue()!==void 0&&this.maxValue()!==void 0){if(this.valueScaleMin===null&&this.valueScaleMax===null&&!o){const C=this.minVisibleValue(),a=this.maxVisibleValue(),A=1e-6;C!==null&&a!==null&&(Math.abs(this.minValue()-C)>A||Math.abs(this.maxValue()-a)>A)&&(this.minValue(C),this.maxValue(a),this.scheduleRerender())}o&&this.onValueScaleChanged()}}},{key:"superSVG",value:function(){return iA($C(i.prototype),"exportSVG",this).call(this)}},{key:"exportSVG",value:function(){let I=null,r=null;iA($C(i.prototype),"exportSVG",this)?[r,I]=iA($C(i.prototype),"exportSVG",this).call(this):(r=document.createElement("g"),I=r),r.setAttribute("class","exported-line-track");const o=document.createElement("g");I.appendChild(o),o.setAttribute("transform",`translate(${this.position[0]},${this.position[1]})`);const C=this.options.lineStrokeColor?this.options.lineStrokeColor:"blue";this.visibleAndFetchedTiles().forEach(A=>{const s=document.createElement("path");s.setAttribute("fill","transparent"),s.setAttribute("stroke",C);let l="";for(const c of A.segments){const u=c[0],d=c.slice(1);l+=`M${u[0]} ${u[1]}`;for(const h of d)l+=`L${h[0]} ${h[1]}`}s.setAttribute("d",l),o.appendChild(s)});const a=document.createElement("g");if(a.setAttribute("id","axis"),r.appendChild(a),a.setAttribute("transform",`translate(${this.axis.pAxis.position.x}, ${this.axis.pAxis.position.y})`),this.options.axisPositionHorizontal==="left"||this.options.axisPositionVertical==="top"){const A=this.axis.exportAxisLeftSVG(this.valueScale,this.dimensions[1]);a.appendChild(A)}else if(this.options.axisPositionHorizontal==="right"||this.options.axisPositionVertical==="bottom"){const A=this.axis.exportAxisRightSVG(this.valueScale,this.dimensions[1]);a.appendChild(A)}return[r,I]}},{key:"tileToLocalId",value:function(I){return this.options.aggregationMode&&this.options.aggregationMode!=="mean"?`${I.join(".")}.${this.options.aggregationMode}`:`${I.join(".")}`}},{key:"tileToRemoteId",value:function(I){return this.tileToLocalId(I)}}]),i}($1);function Nag(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function MRe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function td(e){return td=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},td(e)}let xQe=function(e){Fag(i,e);var g=Eag(i);function i(){return Nag(this,i),g.apply(this,arguments)}return kag(i,[{key:"initTile",value:function(I){I.barXValues=new Array(I.tileData.dense.length),I.barYValues=new Array(I.tileData.dense.length),I.barWidths=new Array(I.tileData.dense.length),I.barHeights=new Array(I.tileData.dense.length),S0(td(i.prototype),"initTile",this).call(this,I)}},{key:"drawTile",value:function(I){if(!I.graphics||!I.tileData||!I.tileData.dense)return;const r=I.graphics,{tileX:o,tileWidth:C}=this.getTilePosAndDimensions(I.tileData.zoomLevel,I.tileData.tilePos),a=I.tileData.dense;if(a.length===0)return;let A=0;if(this.valueScale=null,this.options.valueScaling==="log"){let h=this.medianVisibleValue;this.medianVisibleValue||(h=this.minValue()),this.valueScale=Dm().domain([h,this.maxValue()+h]).range([this.dimensions[1],0]),A=h}else this.valueScale=bg().domain([this.minValue(),this.maxValue()]).range([this.dimensions[1],0]);if(r.clear(),this.drawAxis(this.valueScale),this.options.valueScaling==="log"&&this.valueScale.domain()[1]<0){console.warn("Negative values present when using a log scale",this.valueScale.domain());return}const s=jt(this.options.lineStrokeColor?this.options.lineStrokeColor:"blue"),l=bg().domain([0,this.tilesetInfo.tile_size]).range([o,o+C]),c=0;r.lineStyle(c,s,1);const u=this.options.pointSize?this.options.pointSize:3,d=jt(this.options.pointColor?this.options.pointColor:"red");r.beginFill(d,1),I.drawnAtScale=this._xScale.copy();for(let h=0;hthis.tilesetInfo.max_pos[0])break;r.drawRect(f-u/2/this.pMain.scale.x,m-u/2/this.pMain.scale.y,u/this.pMain.scale.x,u/this.pMain.scale.y)}}},{key:"draw",value:function(){S0(td(i.prototype),"draw",this).call(this);for(const I of hi(this.fetchedTiles)){const r=(I.drawnAtScale.domain()[1]-I.drawnAtScale.domain()[0])/(this._xScale.domain()[1]-this._xScale.domain()[0]),C=this._xScale.domain().map(I.drawnAtScale)[0];I.graphics.scale.x=r,I.graphics.position.x=-C*r}}},{key:"zoomed",value:function(I,r,o,C,a){S0(td(i.prototype),"zoomed",this).call(this,I,r)}},{key:"exportSVG",value:function(){let I=null,r=null;[r,I]=S0(td(i.prototype),"superSVG",this).call(this),r.setAttribute("class","exported-line-track");const o=document.createElement("g");I.appendChild(o),o.setAttribute("transform",`translate(${this.position[0]},${this.position[1]})`);for(const a of this.visibleAndFetchedTiles())for(let A=0;A{g+=+n||0,i.push(g)}),Float64Array.from(i)}const _ag=(e,g)=>{const i=UX(e,g);return Pag(e.map(n=>(Array.isArray(n)&&g?n.length:1)/i))};function Oag(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function zRe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function jb(e){return jb=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},jb(e)}let FQe=function(e){jag(i,e);var g=$ag(i);function i(n,I){var r;return Oag(this,i),r=g.call(this,n,I),r.pMain=r.pMobile,r.continuousScaling=!1,r.updateDataFetcher(I),r}return Jag(i,[{key:"updateDataFetcher",value:function(I){if(I&&I.selectRows&&I.selectRowsAggregationMethod==="server"){const{pubSub:r,dataFetcher:o}=this,C=o.dataConfig.options,a={aggGroups:I.selectRows,aggFunc:I.selectRowsAggregationMode};if(JSON.stringify(C)!==JSON.stringify(a)){const A={...o.dataConfig,options:a};this.dataFetcher=new o.constructor(A,r),this.dataFetcher.dataConfig.tilesetUid&&this.fetchNewTiles(Object.keys(this.fetchedTiles).map(s=>({tileId:s,remoteId:s})))}}}},{key:"rerender",value:function(I,r){this.updateDataFetcher(I),mW(jb(i.prototype),"rerender",this).call(this,I,r),I.selectRows&&(this.selectRowsCumWeights=_ag(I.selectRows,I.selectRowsAggregationWithRelativeHeight))}},{key:"tileDataToCanvas",value:function(I){const r=document.createElement("canvas");this.options.selectRows&&this.tilesetInfo.shape?(r.width=this.tilesetInfo.shape[0],r.height=UX(this.options.selectRows,this.options.selectRowsAggregationWithRelativeHeight)):this.tilesetInfo.shape?(r.width=this.tilesetInfo.shape[0],r.height=this.tilesetInfo.shape[1]):(r.width=this.tilesetInfo.tile_size,r.height=1);const o=r.getContext("2d");if(o.fillStyle="transparent",o.fillRect(0,0,r.width,r.height),I.length!==0&&I.length===4*r.width*r.height){const C=new ImageData(I,r.width,r.height);o.putImageData(C,0,0)}else console.warn("HorizontalMultivecTrack: pixData has an incorrect length.");return r}},{key:"setSpriteProperties",value:function(I,r,o){const{tileX:C,tileWidth:a}=this.getTilePosAndDimensions(r,o,this.tilesetInfo.tile_size),A=C+a;I.width=this._refXScale(A)-this._refXScale(C),I.height=this.dimensions[1],I.x=this._refXScale(C),I.y=0}},{key:"leftTrackZoomed",value:function(I,r,o,C,a){const A=this._xScale(0)-o*this._refXScale(0);this.pMobile.position.x=A+this.position[0],this.pMobile.position.y=this.position[1],this.pMobile.scale.x=o,this.pMobile.scale.y=1}},{key:"zoomed",value:function(I,r,o,C){mW(jb(i.prototype),"zoomed",this).call(this,I,r),this.pMain.position.x=C,this.pMain.position.y=this.position[1],this.pMain.scale.x=o,this.pMain.scale.y=1,this.drawColorbar()}},{key:"calculateVisibleTiles",value:function(){if(!this.tilesetInfo)return;if(this.zoomLevel=this.calculateZoomLevel(),this.tilesetInfo.resolutions){const r=this.tilesetInfo.resolutions.map(o=>+o).sort((o,C)=>C-o);this.xTiles=Nt.calculateTilesFromResolution(r[this.zoomLevel],this._xScale,this.tilesetInfo.min_pos[0],null,this.tilesetInfo.tile_size)}else this.xTiles=Nt.calculateTiles(this.zoomLevel,this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width);const I=this.xTiles.map(r=>[this.zoomLevel,r]);this.setVisibleTiles(I)}},{key:"calculateZoomLevel",value:function(){if(!this.tilesetInfo)return;const I=this.tilesetInfo.min_pos[0];let r=null;return this.tilesetInfo.resolutions?r=Nt.calculateZoomLevelFromResolutions(this.tilesetInfo.resolutions,this._xScale,I):r=Nt.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]),r}},{key:"tileToLocalId",value:function(I){return I.join(".")}},{key:"tileToRemoteId",value:function(I){return I.join(".")}},{key:"getTilePosAtPosition",value:function(I,r){if(!this.tilesetInfo)return;const o=this.calculateZoomLevel(),C=Nt.calculateTileWidth(this.tilesetInfo,o,this.tilesetInfo.tile_size),a=this._xScale.invert(I)/C;return[o,Math.floor(a)]}},{key:"getVisibleData",value:function(I,r){const o=this.calculateZoomLevel(),C=Nt.calculateTileWidth(this.tilesetInfo,o,this.tilesetInfo.tile_size),a=this._xScale.invert(I)/C;let A=this.tilesetInfo.shape?this.tilesetInfo.shape[1]:1;this.options.selectRows&&(A=UX(this.options.selectRows,this.options.selectRowsAggregationWithRelativeHeight));let s=this.tilesetInfo.tile_size*(a-Math.floor(a));const l=r/this.dimensions[1],c=l*A;let u=Math.floor(c),d;this.options.selectRows&&(this.options.selectRowsAggregationWithRelativeHeight&&(u=this.selectRowsCumWeights.findIndex((b,p)=>l<=b&&(p===this.selectRowsCumWeights.length-1||this.selectRowsCumWeights[p+1]>=l))),d=this.options.selectRows[u]);const h=this.tileToLocalId([o,Math.floor(a)]),f=this.fetchedTiles[h];let m="";if(f){this.tilesetInfo.shape||(s=f.tileData.dense.length*(a-Math.floor(a)));let b=null;if(this.tilesetInfo.shape?Array.isArray(d)&&this.options.selectRowsAggregationMethod==="client"?b=d.map(p=>this.tilesetInfo.shape[0]*p+Math.floor(s)):d&&this.options.selectRowsAggregationMethod==="client"?b=this.tilesetInfo.shape[0]*d+Math.floor(s):b=this.tilesetInfo.shape[0]*u+Math.floor(s):b=f.tileData.dense.length*u+Math.floor(s),Array.isArray(b)){const p=zae(this.options.selectRowsAggregationMode),y=b.map(Z=>f.tileData.dense[Z]);m=da(".3f")(p(y)),m+="
",m+=`${b.length}-item ${this.options.selectRowsAggregationMode}`}else m=da(".3f")(f.tileData.dense[b]),Array.isArray(d)&&(m+="
",m+=`${d.length}-item ${this.options.selectRowsAggregationMode}`)}if(this.tilesetInfo.row_infos){m+="
";let b="";this.options.selectRows&&!Array.isArray(d)?b=this.tilesetInfo.row_infos[d]:u>=0&&u"),s=this.options.colorRange[parseInt(A[0],10)-1],l=A[1];if(Number.isNaN(s)||s==="NaN"||typeof s>"u"||s==="undefined")return"";C=` ${l}`}else C+=`Data value: ${this.getVisibleData(I,r)}
`,C+=`Zoom level: ${o[0]} tile position: ${o[1]}`;return C}}]),i}(gH);function gsg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function PRe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function sA(e){return sA=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},sA(e)}const lsg=jt("#FFFFFF");let cAe=function(e){osg(i,e);var g=Csg(i);function i(...n){var I;return gsg(this,i),I=g.call(this,...n),I.zeroLine=new st.PIXI.Graphics,I.pMain.addChild(I.zeroLine),I.valueScaleTransform=NI,I.options&&I.options.colorRange&&(I.options.colorRangeGradient?I.setColorGradient(I.options.colorRange):I.setColorScale(I.options.colorRange)),I.initialized=!0,I}return isg(i,[{key:"setColorScale",value:function(I){I&&(this.colorScale=hm(I),this.colorScale=this.colorScale.map(r=>r.map(o=>o/255)))}},{key:"setColorGradient",value:function(I){if(!I)return;const r=I.length-1;this.colorGradientColors=this.options.align==="bottom"?I.slice().reverse().map((o,C)=>({from:C/r,color:o})):I.map((o,C)=>({from:C/r,color:o}))}},{key:"initTile",value:function(I){this.initialized&&Ku(sA(i.prototype),"initTile",this).call(this,I)}},{key:"updateTile",value:function(I){(!I.valueScale||!this.scale||this.scale.minValue!==I.scale.minValue||this.scale.maxValue!==I.scale.maxValue)&&this.renderTile(I)}},{key:"renderTile",value:function(I){this.initialized&&Ku(sA(i.prototype),"renderTile",this).call(this,I)}},{key:"drawTile",value:function(I){if(!I.graphics||!I.tileData||!I.tileData.dense)return;const{graphics:r}=I;I.svgData=void 0;const{tileX:o,tileWidth:C}=this.getTilePosAndDimensions(I.tileData.zoomLevel,I.tileData.tilePos,this.tilesetInfo.bins_per_dimension||this.tilesetInfo.tile_size),a=I.tileData.dense;if(a.length===0)return;const[A,s]=this.makeValueScale(this.minValue(),this.medianVisibleValue,this.maxValue(),0);A.clamp(!0),this.valueScale=A;const l=A.copy();if(l.range([254,0]).clamp(!0),r.clear(),this.drawAxis(this.valueScale),this.options.valueScaling==="log"&&this.valueScale.domain()[1]<0){console.warn("Negative values present when using a log scale",this.valueScale.domain());return}const c=jt(this.options.lineStrokeColor||"blue"),u=bg().domain([0,this.tilesetInfo.tile_size||this.tilesetInfo.bins_per_dimension]).range([o,o+C]),d=0;r.lineStyle(d,c,1);const h=this.options.barFillColor||"grey",f=jt(h),m="barOpacity"in this.options?this.options.barOpacity:1;r.beginFill(f,m),I.drawnAtScale=this._xScale.copy();const b=this.options.align==="top";let p,y,Z,v,G,B;if(this.colorGradientColors){G=new st.PIXI.Graphics,G.beginFill(lsg,1);const S=g_e(this.colorGradientColors,1,this.dimensions[1],0,0,0,this.dimensions[1]);B=new st.PIXI.Sprite(st.PIXI.Texture.fromCanvas(S,st.PIXI.SCALE_MODES.NEAREST)),B.x=this._xScale(o),B.width=this._xScale(o+C)-B.x}for(let S=0;Sthis.tilesetInfo.max_pos[0])break;if(this.colorScale&&!this.options.colorRangeGradient){const R=Math.round(l(a[S]+s)),w=this.colorScale[R],T=st.PIXI.utils.rgb2hex(w);r.beginFill(T,m)}(G||r).drawRect(p,Z,y,v)}this.colorGradientColors&&(B.mask=G,r.removeChildren(),r.addChild(B,G))}},{key:"rerender",value:function(I,r){I&&I.colorRange&&(I.colorRangeGradient?this.setColorGradient(I.colorRange):this.setColorScale(I.colorRange)),Ku(sA(i.prototype),"rerender",this).call(this,I,r)}},{key:"drawZeroLine",value:function(){this.zeroLine.clear();const I=jt(this.options.barFillColor||"grey"),r=+this.options.barOpacity||1,o=this.options.zeroLineColor?jt(this.options.zeroLineColor):I,C=Number.isNaN(+this.options.zeroLineOpacity)?r:+this.options.zeroLineOpacity;this.zeroLine.beginFill(o,C),this.zeroLine.drawRect(0,this.dimensions[1]-1,this.dimensions[0],1)}},{key:"drawZeroLineSvg",value:function(I){const r=document.createElement("rect");r.setAttribute("id","zero-line"),r.setAttribute("x",0),r.setAttribute("y",this.dimensions[1]-1),r.setAttribute("height",1),r.setAttribute("width",this.dimensions[0]),r.setAttribute("fill",this.options.zeroLineColor||this.options.barFillColor),r.setAttribute("fill-opacity",this.options.zeroLineOpacity||this.options.barOpacity),I.appendChild(r)}},{key:"getXScaleAndOffset",value:function(I){const r=I.domain(),o=this._xScale.domain(),C=(r[1]-r[0])/(o[1]-o[0]),A=this._xScale.domain().map(I)[0];return[C,-A*C]}},{key:"draw",value:function(){this.initialized&&(Ku(sA(i.prototype),"draw",this).call(this),this.options.zeroLineVisible?this.drawZeroLine():this.zeroLine.clear(),Object.values(this.fetchedTiles).forEach(I=>{const[r,o]=this.getXScaleAndOffset(I.drawnAtScale);I.graphics.scale.x=r,I.graphics.position.x=o}))}},{key:"zoomed",value:function(I,r){Ku(sA(i.prototype),"zoomed",this).call(this,I,r)}},{key:"movedY",value:function(I){}},{key:"zoomedY",value:function(I,r){}},{key:"addSVGInfo",value:function(I,r,o,C,a,A){I.svgData?(I.svgData.barXValues.push(r),I.svgData.barYValues.push(o),I.svgData.barWidths.push(C),I.svgData.barHeights.push(a),I.svgData.barColors.push(A)):I.svgData={barXValues:[r],barYValues:[o],barWidths:[C],barHeights:[a],barColors:[A]}}},{key:"exportSVG",value:function(){let I=null,r=null;[r,I]=Ku(sA(i.prototype),"superSVG",this).call(this),r.setAttribute("class","exported-line-track");const o=document.createElement("g");I.appendChild(o),o.setAttribute("transform",`translate(${this.position[0]},${this.position[1]})`),this.options.zeroLine&&this.drawZeroLineSvg(o),this.visibleAndFetchedTiles().filter(a=>a.svgData&&a.svgData.barXValues).forEach(a=>{const A=a.svgData;for(let s=0;s"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function pE(e){return pE=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},pE(e)}let EQe=function(e){fsg(i,e);var g=msg(i);function i(){return csg(this,i),g.apply(this,arguments)}return usg(i,[{key:"drawTile",value:function(I){this.renderTile(I)}},{key:"renderTile",value:function(I){if(!I.graphics)return;const r=I.graphics,{tileX:o,tileWidth:C}=this.getTilePosAndDimensions(I.tileData.zoomLevel,I.tileData.tilePos,this.tilesetInfo.tile_size||this.tilesetInfo.bins_per_dimension),a=I.tileData.dense;if(a.length===0)return;let A=0;if(this.valueScale=null,this.options.valueScaling==="log"){let p=this.medianVisibleValue;this.medianVisibleValue||(p=this.minValue()),this.valueScale=Dm().domain([p,this.maxValue()+p]).range([this.dimensions[1],0]),A=p}else this.valueScale=bg().domain([this.minValue(),this.maxValue()]).range([this.dimensions[1],0]);if(r.clear(),this.drawAxis(this.valueScale),this.options.valueScaling==="log"&&this.valueScale.domain()[1]<0){console.warn("Negative values present when using a log scale",this.valueScale.domain());return}const s=jt(this.options.lineStrokeColor?this.options.lineStrokeColor:"blue"),l=bg().domain([0,this.tilesetInfo.tile_size]).range([o,o+C]),c=0;r.lineStyle(c,s,1);const u=this.options.barFillColorTop?this.options.barFillColorTop:"green",d=this.options.barFillColorBottom?this.options.barFillColorBottom:"red",h=jt(u),f=jt(d),m="barOpacity"in this.options?this.options.barOpacity:1;I.drawnAtScale=this._xScale.copy();let b=0;this.options.valueScaling==="log"?b=this.valueScale(1):b=this.valueScale(0),delete I.svgData;for(let p=0;pb?(r.beginFill(f,m),this.addSVGInfo(I,y,b,v,Z-b,d)):(r.beginFill(h,m),this.addSVGInfo(I,y,Z,v,b-Z,u)),l(p)>this.tilesetInfo.max_pos[0])break;r.drawRect(y,I.svgData.barYValues[p],v,I.svgData.barHeights[p])}}}]),i}(cAe);function Zsg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function ORe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function vw(e){return vw=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},vw(e)}let DQe=function(e){Ssg(i,e);var g=Rsg(i);function i(n,I){var r;return Zsg(this,i),r=g.call(this,n,I),r.setColorScale(I.colorRange),r.opacity=I.opacity||1,r}return Gsg(i,[{key:"setColorScale",value:function(I){this.colorScale=I?hm(I):ew,this.colorScale=this.colorScale.map(r=>r.map(o=>o/255))}},{key:"rerender",value:function(I){I&&I.colorRange&&this.setColorScale(I.colorRange),this.opacity=I.opacity||1,b5(vw(i.prototype),"rerender",this).call(this,I)}},{key:"drawAxis",value:function(){}},{key:"drawTile",value:function(I){if(!I.graphics||!I.tileData||!I.tileData.dense)return;const r=I.graphics,{tileX:o,tileWidth:C}=this.getTilePosAndDimensions(I.tileData.zoomLevel,I.tileData.tilePos),a=I.tileData.dense;if(a.length===0)return;const[A,s]=this.makeValueScale(this.minValue(),this.medianVisibleValue,this.maxValue());if(A.range([254,0]).clamp(!0),this.valueScale=A,r.clear(),this.options.valueScaling==="log"&&this.valueScale.domain()[1]<0){console.warn("Negative values present when using a log scale",this.valueScale.domain());return}const l=bg().domain([0,this.tilesetInfo.tile_size]).range([o,o+C]);r.lineStyle(0,0,0);for(let c=0;cthis.tilesetInfo.max_pos[0])break;a[c]!==0&&r.drawRect(d,0,h,f)}}}}]),i}(eS);function Tsg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function JRe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function bE(e){return bE=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},bE(e)}let MQe=function(e){Ysg(i,e);var g=Ksg(i);function i(n,I){var r;return Tsg(this,i),r=g.call(this,n,I),r.seen=new Set,r.pMain=r.pMobile,r.rows=[],r}return Hsg(i,[{key:"uid",value:function(I){return I[I.length-2]}},{key:"segmentOverlap",value:function(I,r){}},{key:"drawAll",value:function(I){this.pMain.clear();const r=new Set,o=I.map(a=>r.has(this.uid(a))?null:(r.add(this.uid(a)),{from:+a[1],to:+a[2],type:a[4],uid:this.uid(a)})).filter(a=>a),C=zF(o);this.rows=C,this.draw()}},{key:"draw",value:function(){const I=this.rows;if(!I)return;const r=vT().range([0,this.dimensions[1]]).padding(.1).domain(Xo(0,this.maxRows())),o=this.pMain;o.clear(),o.lineStyle(1,255,0),o.beginFill(16740363,.8);for(let C=0;Cthis.fetchedTiles[C].tileData.discrete),o=[].concat(...r);this.drawAll(o)}},{key:"initTile",value:function(I){}},{key:"maxRows",value:function(){return this.rows.length}},{key:"updateTile",value:function(I){}},{key:"destroyTile",value:function(I){I.tileData.discrete.forEach(r=>{const o=r[r.length-2];this.seen.has(o)&&this.seen.delete(o)})}},{key:"drawTile",value:function(I){}}]),i}($1);function Dsg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function LRe(e,g){for(var i=0;i=this.position[0]&&i<=this.dimensions[0]+this.position[0]&&n>=this.position[1]&&n<=this.dimensions[1]+this.position[1]}}]),e}();function _sg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function QRe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function AA(e){return AA=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},AA(e)}const jRe=11,EQ="Arial",$Re="outside",jee=10,tAg=4,gAg=20,iAg=jt("#ffffff"),iY=2,nAg=2*jee/3,rG=2*nAg/3,IAg=50,rAg=5e3,$ee="blue",qee="red",uAe=(e,g,i)=>{i.type!=="filler"&&g.pubSub.publish("app.click",{type:"gene-annotation",event:e,payload:i})},qRe=(e,g)=>{const i=e.concat(g),n=i.map(I=>[I.xStart,1,I.xEnd,1]);iH(n,(I,r)=>{let o=null,C=null;if(i[I].type==="filler"?o=i[I]:C=i[I],i[r].type==="filler"){if(o)return;o=i[r]}else{if(!o)return;C=i[r]}o.xStart>=C.xStart&&o.xEnd<=C.xEnd&&(o.hide=!0)})};function oAg(e,g,i){const{flipText:n,fontSize:I,fontFamily:r,plusStrandColor:o,minusStrandColor:C,maxGeneEntries:a,maxFillerEntries:A,maxTexts:s}=i;if(g.texts={},g.rectGraphics=new st.PIXI.Graphics,g.textBgGraphics=new st.PIXI.Graphics,g.textGraphics=new st.PIXI.Graphics,g.rectMaskGraphics=new st.PIXI.Graphics,g.graphics.addChild(g.rectGraphics),g.graphics.addChild(g.textBgGraphics),g.graphics.addChild(g.textGraphics),g.graphics.addChild(g.rectMaskGraphics),g.rectGraphics.mask=g.rectMaskGraphics,!g.tileData.sort)return;g.tileData.sort((u,d)=>d.importance-u.importance);const l=g.tileData.filter(u=>u.type!=="filler").slice(0,a),c=g.tileData.filter(u=>u.type==="filler").slice(0,A);g.tileData=l.concat(c),g.tileData.forEach((u,d)=>{if(u.type==="filler")return;const h=u.fields,f=h[3],m=e.geneId(h,u.type),b=u.strand||h[5];u.strand=u.strand||b;let p=o||$ee;if(b==="-"&&(p=C||qee),g.textWidths={},g.textHeights={},d>=s)return;const y=new st.PIXI.Text(f,{fontSize:`${I}px`,fontFamily:r,fill:jt(p)});y.interactive=!0,n&&(y.scale.x=-1),y.anchor.x=.5,y.anchor.y=1,g.texts[m]=y,g.texts[m].strand=b,g.textGraphics.addChild(y)}),g.initialized=!0}function eVe(e,g,i,n,I,r,o,C,a){const A=C-a/2,s=0;e.forEach(l=>{const c=new st.PIXI.Graphics;i.rectGraphics.addChild(c),c.beginFill(r,.1),c.lineStyle(0,r);const u=[I(l.xStart)-s,A,I(l.xEnd)+s,A,I(l.xEnd)+s,A+a,I(l.xStart)-s,A+a,I(l.xStart)-s,A];c.interactive=!0,c.buttonMode=!0,c.mouseup=d=>uAe(d,g,l),c.drawPolygon(u),i.allRects.push([u,l.strand,l])})}function CAg(e,g,i,n,I,r,o,C,a,A){const s=C-a/2,l=I.split(",").map(y=>+y+o),c=r.split(",").map(y=>+y+o),u=e._xScale(i),d=e._xScale(n),h=d-u,f=C,m=[];let b=[u,f-iY/2,u+h,f-iY/2,u+h,f+iY/2,u,f+iY/2];g.drawPolygon(b),m.push(b);const p=2*a;for(let y=Math.max(e.position[0],u)+p;y{const l=g._xScale(s.xStart),c=g._xScale(s.xEnd),u=new st.PIXI.Graphics;i.rectGraphics.addChild(u),u.beginFill(r,o),u.interactive=!0,u.buttonMode=!0,u.mouseup=f=>uAe(f,g,s);const d=g.geneRectHeight/2;let h=[];if(s.strand==="+"||s.fields[5]==="+"){const f=Math.max(l,c-d),m=f+d;h=[f,A,m,A+g.geneRectHeight/2,f,A+g.geneRectHeight]}else{const f=Math.min(c,l+d),m=f-d;h=[f,A,m,A+g.geneRectHeight/2,f,A+g.geneRectHeight]}u.drawPolygon(h),i.allRects.push([h,s.strand,s])})}function sAg(e,g,i,n,I,r,o,C,a){e.forEach(A=>{const s=A.fields,l=+A.chrOffset,c=s[12],u=s[13],d=new st.PIXI.Graphics;i.rectGraphics.addChild(d),d.beginFill(r,o),d.interactive=!0,d.buttonMode=!0,d.mouseup=h=>uAe(h,g,A),i.allRects=i.allRects.concat(CAg(g,d,A.xStart,A.xEnd,c,u,l,C,a,A.strand||A.fields[5]).map(h=>[h,A.strand,A]))})}function tVe(e,g,i,n,I,r,o,C,a){aAg(e,g,i,n,I,r,o,C,a),sAg(e,g,i,n,I,r,o,C,a)}function AAg(e,g){const{tileX:i,tileWidth:n}=U0.getTilePosAndDimensions(e.tilesetInfo,g.tileId);g.rectMaskGraphics.clear();const I=Math.floor(Math.random()*16**6);g.rectMaskGraphics.beginFill(I,.3);const r=e._xScale(i),o=0,C=e._xScale(i+n)-e._xScale(i),a=e.dimensions[1];g.rectMaskGraphics.drawRect(r,o,C,a)}let zQe=function(e){Qsg(i,e);var g=jsg(i);function i(n,I){var r;_sg(this,i),r=g.call(this,n,I);const{animate:o}=n;return r.animate=o,r.options=I,r.fontSize=+r.options.fontSize||jRe,r.geneLabelPos=r.options.geneLabelPosition||$Re,r.geneRectHeight=+r.options.geneAnnotationHeight||jee,r.geneRectHeight-=2,r.geneStrandSpacing=+r.options.geneStrandSpacing||tAg,r.geneStrandHSpacing=r.geneStrandSpacing/2,r.geneRectHHeight=r.geneRectHeight/2,r}return Osg(i,[{key:"initTile",value:function(I){oAg(this,I,{flipText:this.flipText,fontSize:this.fontSize,fontFamily:EQ,plusStrandColor:this.options.plusStrandColor,minusStrandColor:this.options.minusStrandColor,maxGeneEntries:IAg,maxFillerEntries:rAg,maxTexts:gAg}),this.renderTile(I)}},{key:"destroyTile",value:function(I){I.rectGraphics.destroy(),I.rectMaskGraphics.destroy(),I.textGraphics.destroy(),I.textBgGraphics.destroy(),I.graphics.destroy()}},{key:"rerender",value:function(I,r){const o=JSON.stringify(I);!r&&o===this.prevOptions||(xu(AA(i.prototype),"rerender",this).call(this,I,r),this.fontSize=+this.options.fontSize||jRe,this.geneLabelPos=this.options.geneLabelPosition||$Re,this.geneRectHeight=+this.options.geneAnnotationHeight||jee,this.geneStrandHSpacing=this.geneStrandSpacing/2,this.geneRectHHeight=this.geneRectHeight/2,this.prevOptions=o,this.visibleAndFetchedTiles().forEach(C=>{this.renderTile(C)}))}},{key:"drawTile",value:function(){}},{key:"geneId",value:function(I,r){return`${r}_${I[0]}_${I[1]}_${I[2]}_${I[3]}`}},{key:"renderTile",value:function(I){if(!I.initialized)return;I.allRects=[],I.drawnAtScale=this._xScale.copy(),I.rectGraphics.removeChildren(),I.rectGraphics.clear(),I.textBgGraphics.clear();const r={},o=.3,C=.3;r["+"]=jt(this.options.plusStrandColor||$ee),r["-"]=jt(this.options.minusStrandColor||qee);let a=I.tileData.filter(m=>m.type==="filler"&&m.strand==="+"),A=I.tileData.filter(m=>m.type==="filler"&&m.strand==="-");const s=I.tileData.filter(m=>m.type!=="filler"&&(m.strand==="+"||m.fields[5]==="+")),l=I.tileData.filter(m=>m.type!=="filler"&&(m.strand==="-"||m.fields[5]==="-"));qRe(s,a),qRe(l,A),a=a.filter(m=>!m.hide),A=A.filter(m=>!m.hide);const c=this.dimensions[1]/2,u=c-this.geneRectHeight/2-this.geneStrandSpacing/2,d=c+this.geneRectHeight/2+this.geneStrandSpacing/2,h=[this,I,I.rectGraphics,this._xScale,r["+"],o,u,this.geneRectHeight],f=[this,I,I.rectGraphics,this._xScale,r["-"],o,d,this.geneRectHeight];eVe(a,...h),eVe(A,...f),h[5]=C,f[5]=C,tVe(s,...h),tVe(l,...f),AAg(this,I),U0.stretchRects(this,[m=>m.rectGraphics,m=>m.rectMaskGraphics]);for(const m of Object.values(I.texts))m.style={fontSize:`${this.fontSize}px`,FONT_FAMILY:EQ,fill:jt(m.strand==="-"?this.options.minusStrandColor||qee:this.options.plusStrandColor||$ee)}}},{key:"calculateZoomLevel",value:function(){const I=Nt.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]);let r=Math.min(I,this.maxZoom);return r=Math.max(r,0),r}},{key:"draw",value:function(){xu(AA(i.prototype),"draw",this).call(this),this.allTexts=[],this.allBoxes=[];const I=[];this.geneAreaHeight=this.geneRectHeight;const r=this.fontSize/2;U0.stretchRects(this,[o=>o.rectGraphics,o=>o.rectMaskGraphics]),Object.values(this.fetchedTiles).filter(o=>o.drawnAtScale).forEach(o=>{o.textBgGraphics.clear(),o.textBgGraphics.beginFill(typeof this.options.labelBackgroundColor<"u"?jt(this.options.labelBackgroundColor):iAg);const C=this.parentInFetched(o);o.initialized&&o.tileData.forEach(a=>{if(!o.texts||a.type==="filler")return;const A=a.fields,s=A[3],l=this.geneId(A,a.type),c=o.texts[l];if(!c)return;const u=+a.chrOffset,d=+A[1]+u,h=+A[2]+u,f=(d+h)/2;let m=this.dimensions[1]/2;const b=(this.geneAreaHeight-this.fontSize)/2;if(A[5]==="+"?m-=this.geneLabelPos==="inside"?b+this.geneStrandSpacing-2:this.fontSize/2+this.geneAreaHeight-2:m+=this.geneLabelPos==="inside"?this.fontSize+this.geneStrandSpacing/2+b+1:1.5*this.fontSize+this.geneAreaHeight+2,c.position.x=this._xScale(f),c.position.y=m,!o.textWidths[l]){const p=c.getBounds().width,y=c.getBounds().height;o.textHeights[l]=y,o.textWidths[l]=p}if(C)c.visible=!1;else{c.visible=!0;const p=2;this.flipText?this.allBoxes.push([c.position.x-o.textHeights[l]/2-p,m-r-1,c.position.x+o.textHeights[l]/2+p,m+r-1,s]):this.allBoxes.push([c.position.x-o.textWidths[l]/2-p,m-r-1,c.position.x+o.textWidths[l]/2+p,m+r-1,s]),this.allTexts.push({importance:+A[4],text:c,caption:s,strand:A[5]}),I.push(o.textBgGraphics)}})}),this.hideOverlaps(this.allBoxes,this.allTexts),this.renderTextBg(this.allBoxes,this.allTexts,I)}},{key:"renderTextBg",value:function(I,r,o){r.forEach((C,a)=>{if(C.text.visible&&I[a]&&o[a]){const[A,s,l,c]=I[a],u=l-A,d=c-s;o[a].drawRect(A-u/2,s-d/2,u,d)}})}},{key:"hideOverlaps",value:function(I,r){iH(I,(o,C)=>{r[o].importance>r[C].importance?r[C].text.visible=!1:r[o].text.visible=!1})}},{key:"setPosition",value:function(I){xu(AA(i.prototype),"setPosition",this).call(this,I),[this.pMain.position.x,this.pMain.position.y]=this.position}},{key:"setDimensions",value:function(I){xu(AA(i.prototype),"setDimensions",this).call(this,I),this.halfRectHHeight=this.dimensions[1]/2,this.visibleAndFetchedTiles().forEach(r=>{this.renderTile(r)})}},{key:"zoomed",value:function(I,r){this.xScale(I),this.yScale(r),this.refreshTiles(),this.draw()}},{key:"getMouseOverHtml",value:function(I,r){if(!this.tilesetInfo)return"";const o=[I,r];for(const C of this.visibleAndFetchedTiles())for(let a=0;a + ${c.fields[3]}
+ Position: ${c.fields[0]}:${c.fields[1]}-${c.fields[2]}
+ Strand: ${c.fields[5]} + + `}}return""}},{key:"exportSVG",value:function(){let I=null,r=null;xu(AA(i.prototype),"exportSVG",this)?[r,I]=xu(AA(i.prototype),"exportSVG",this).call(this):(r=document.createElement("g"),I=r);const o=document.createElement("g");return o.setAttribute("transform",`translate(${this.position[0]},${this.position[1]})`),I.appendChild(o),this.visibleAndFetchedTiles().filter(C=>C.allRects).forEach(C=>{const a=document.createElement("g");a.setAttribute("transform",`translate(${C.rectGraphics.position.x}, + ${C.rectGraphics.position.y}) + scale(${C.rectGraphics.scale.x}, + ${C.rectGraphics.scale.y})`),C.allRects.forEach(A=>{const s=document.createElement("path"),l=A[0];let c=`M ${l[0]} ${l[1]}`;for(let u=2;uC.text.visible).forEach(C=>{const a=document.createElement("g"),A=document.createElement("text");A.setAttribute("text-anchor","middle"),A.setAttribute("font-family",EQ),A.setAttribute("font-size",`${this.fontSize}px`),A.setAttribute("dy","-.2em"),a.setAttribute("transform",`scale(${C.text.scale.x},1)`),C.strand==="+"?A.setAttribute("fill",this.options.plusStrandColor):A.setAttribute("fill",this.options.minusStrandColor),A.innerHTML=C.text.text,a.appendChild(A),a.setAttribute("transform",`translate(${C.text.x},${C.text.y})scale(${C.text.scale.x},1)`),o.appendChild(a)}),[r,r]}}]),i}($1);function lAg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function gVe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function gd(e){return gd=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},gd(e)}function iVe(e,g,i,n,I,r,o,C,a,A){const s=A?e._xScale(i.yStart):e._xScale(i.xStart),l=A?e._xScale(i.yEnd):e._xScale(i.xEnd),c=A?e._yScale(i.xStart):e._yScale(i.yStart),u=A?e._yScale(i.xEnd):e._yScale(i.yEnd),d=i.uid+A,h=l-s,f=u-c;let m={x:s,y:c,width:h,height:f};n&&(hI&&m.xI&&bo&&m.yo&&pa||m.height>a)&&(g.drawRect(m.x,m.y,m.width,m.height),e.publish("annotationDrawn",{trackUuid:e.uuid,annotationUuid:d,viewPos:[m.x,m.y,m.width,m.height],dataPos:[i.xStart,i.xEnd,i.yStart,i.yEnd],importance:i.importance,info:{patternType:e.options.patternType}}))}let PQe=function(e){fAg(i,e);var g=mAg(i);function i(...n){var I;lAg(this,i),I=g.call(this,...n),I.drawnRects={};const{publish:r,subscribe:o,unsubscribe:C}=oP();return I.publish=r,I.subscribe=o,I.unsubscribe=C,I}return cAg(i,[{key:"tileToLocalId",value:function(I){return`${I.join(".")}`}},{key:"tileToRemoteId",value:function(I){return`${I.join(".")}`}},{key:"localToRemoteId",value:function(I){const r=I.split(".");return r.slice(0,r.length-1).join(".")}},{key:"calculateZoomLevel",value:function(){const I=Nt.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]),r=Nt.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[1]);let o=Math.max(I,r);return o=Math.min(o,this.maxZoom),o}},{key:"setVisibleTiles",value:function(I){this.visibleTiles=I.map(r=>({tileId:this.tileToLocalId(r),remoteId:this.tileToRemoteId(r)})),this.visibleTileIds=new Set(this.visibleTiles.map(r=>r.remoteId))}},{key:"calculateVisibleTiles",value:function(){if(!this.tilesetInfo)return;this.zoomLevel=this.calculateZoomLevel(),this.xTiles=Nt.calculateTiles(this.zoomLevel,this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width),this.yTiles=Nt.calculateTiles(this.zoomLevel,this._yScale,this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[1],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width);const I=this.xTiles,r=this.yTiles,o=this.zoomLevel,C=[];for(let a=0;a!(d.uid in this.drawnRects)).forEach(d=>{iVe(this,r,d,a,s,l,c,u,A,this.options.flipDiagonal==="yes"),this.options.flipDiagonal&&this.options.flipDiagonal==="copy"&&iVe(this,r,d,a,s,l,c,u,A,!0)})}},{key:"exportSVG",value:function(){let I=null,r=null;R0(gd(i.prototype),"exportSVG",this)?[r,I]=R0(gd(i.prototype),"exportSVG",this).call(this):(r=document.createElement("g"),I=r);const o=document.createElement("g");o.setAttribute("transform",`translate(${this.position[0]},${this.position[1]})`),I.appendChild(o);for(const C of[!0,!1])for(const a of this.visibleAndFetchedTiles())!a.tileData||!a.tileData.length||a.tileData.forEach(A=>{const s=A.uid+C,l=document.createElement("g");if(l.setAttribute("transform",`translate(${a.graphics.position.x},${a.graphics.position.y})scale(${a.graphics.scale.x},${a.graphics.scale.y})`),o.appendChild(l),s in this.drawnRects){const c=this.drawnRects[s],u=document.createElement("rect");u.setAttribute("x",c.x),u.setAttribute("y",c.y),u.setAttribute("width",c.width),u.setAttribute("height",c.height),u.setAttribute("fill",this.options.rectangleDomainFillColor?this.options.rectangleDomainFillColor:"grey"),u.setAttribute("opacity",.3),u.style.stroke="black",u.style.strokeWidth="1px",l.appendChild(u)}});return[r,r]}},{key:"setPosition",value:function(I){R0(gd(i.prototype),"setPosition",this).call(this,I),this.pMain.position.y=this.position[1],this.pMain.position.x=this.position[0]}},{key:"zoomed",value:function(I,r){this.xScale().domain()[0]===I.domain()[0]&&this.xScale().domain()[1]===I.domain()[1]&&this.yScale().domain()[0]===r.domain()[0]&&this.yScale().domain()[1]===r.domain()[1]||(this.xScale(I),this.yScale(r),this.refreshTiles(),this.draw())}},{key:"leftTrackDraw",value:function(){this.draw()}}]),i}(rZ);function ZAg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function nVe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function id(e){return id=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},id(e)}const XAg=250;let OQe=function(e){SAg(i,e);var g=RAg(i);function i(n,I){var r;ZAg(this,i),r=g.call(this,n,I);const{pubSub:o}=n;r.drawnAnnotations={},r.drawnAnnoGfx={},r.selectedAnno=null,r.options.minSquareSize=+r.options.minSquareSize;const{publish:C,subscribe:a,unsubscribe:A}=oP();return r.publish=C,r.subscribe=a,r.unsubscribe=A,r.sT=0,r.annoSelectedBound=r.annoSelected.bind(_Qe(r)),r.pubSubs.push(o.subscribe("annoSelected",r.annoSelectedBound)),r}return GAg(i,[{key:"minX",get:function(){return this.tilesetInfo&&this.tilesetInfo.min_pos?this.tilesetInfo.min_pos[0]:0}},{key:"maxX",get:function(){return this.tilesetInfo&&this.tilesetInfo.max_pos?this.tilesetInfo.max_pos[0]:this.tilesetInfo.max_width||this.tilesetInfo.max_size}},{key:"minY",get:function(){return this.minX}},{key:"maxY",get:function(){return this.maxX}},{key:"maxSize",get:function(){const n=this.tilesetInfo.max_pos&&Math.max(this.tilesetInfo.max_pos[0]-this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[1]-this.tilesetInfo.min_pos[1]);return n||(this.tilesetInfo.max_size?this.tilesetInfo.max_size:0)}},{key:"projection",value:function([I,r]){return[this._xScale(I),this._yScale(r)]}},{key:"tileToLocalId",value:function(I){return`${I.join(".")}`}},{key:"tileToRemoteId",value:function(I){return`${I.join(".")}`}},{key:"localToRemoteId",value:function(I){const r=I.split(".");return r.slice(0,r.length-1).join(".")}},{key:"calculateZoomLevel",value:function(){const I=Nt.calculateZoomLevel(this._xScale,this.minX,this.maxX),r=Nt.calculateZoomLevel(this._yScale,this.minY,this.maxY);return o_e(Zq(I,r),this.maxZoom)}},{key:"setVisibleTiles",value:function(I){this.visibleTiles=I.map(r=>({tileId:this.tileToLocalId(r),remoteId:this.tileToRemoteId(r)})),this.visibleTileIds=new Set(this.visibleTiles.map(r=>r.tileId))}},{key:"calculateVisibleTiles",value:function(){if(!this.tilesetInfo)return;this.zoomLevel=this.calculateZoomLevel(),this.xTiles=Nt.calculateTiles(this.zoomLevel,this._xScale,this.minX,this.maxX,this.tilesetInfo.max_zoom,this.maxSize),this.yTiles=Nt.calculateTiles(this.zoomLevel,this._yScale,this.minY,this.maxY,this.tilesetInfo.max_zoom,this.maxSize);const I=this.zoomLevel,r=[];for(let o=0;o!(a.uid in this.drawnAnnotations)||r).forEach(a=>{const[A,s]=this.projection([a.xStart,a.yStart]),[l,c]=this.projection([a.xEnd,a.yEnd]);this.options.exclude&&this.options.exclude.indexOf(a.uid)>=0||this.drawAnnotation(this.prepAnnotation(C,a.uid,A,s,l-A,c-s,a),o)})}},{key:"prepAnnotation",value:function(I,r,o,C,a,A,s){let l;try{l=JSON.parse(s.fields)}catch{}return{graphics:I,id:s.id,uid:r,annotation:{x:o,y:C,width:a,height:A},dataPos:[s.xStart,s.xEnd,s.yStart,s.yEnd],importance:s.importance,info:l}}},{key:"drawAnnotation",value:function({graphics:I,id:r,uid:o,annotation:C,dataPos:a,importance:A,info:s},l){this.options.minSquareSize&&(C.widththis.hover(u,c,o),u.mouseout=()=>this.blur(u,c,o),u.mousedown=()=>this.mouseDown(),u.mouseup=h=>this.mouseUp(u,c,o,h,d),l||this.publish("annotationDrawn",{trackUuids:this.uuid,annotationUuid:o,annotationId:r,viewPos:c,dataPos:a,importance:A,info:s})}},{key:"_drawRect",value:function(I,r,o){let C=this.options.rectangleDomainStrokeColor,a=this.options.rectangleDomainStrokeWidth,A=this.options.rectangleDomainStrokeOpacity,s=this.options.rectangleDomainFillColor,l=this.options.rectangleDomainFillOpacity;this.hoveredAnno===o&&(C=this.options.hoverColor,a=this.options.rectangleDomainStrokeWidth+1||2,A=1,s=this.options.hoverColor,l=this.options.rectangleDomainFillOpacity),this.selectedAnno&&this.selectedAnno.uid===o&&(C=this.options.selectColor,a=this.options.rectangleDomainStrokeWidth+1||2,A=1,s=this.options.selectColor,l=Zq(.33,this.options.rectangleDomainFillOpacity)),I.clear(),this.options.trackBorderBgWidth&&(this.setBorderStyle(I,this.options.trackBorderBgColor,this.options.trackBorderBgWidth,this.options.trackBorderBgAlpha),this.setFill(I,s,0),I.drawRect(...r)),this.setBorderStyle(I,C,a,A),this.setFill(I,s,l),I.drawRect(...r),I.__viewPos__=r}},{key:"context",value:function(I,r,o){return C=>C(I,r,o)}},{key:"click",value:function(I,r,o,C,a){this.select(I,r,o),this.pubSub.publish("app.click",{type:"annotation",event:C,payload:a})}},{key:"mouseDown",value:function(){this.sT=performance.now()}},{key:"mouseUp",value:function(I,r,o,C,a){performance.now()-this.sT<=XAg&&this.click(I,r,o,C,a)}},{key:"hover",value:function(I,r,o){this.hoveredAnno=o,this._drawRect(I,r,o),this.animate()}},{key:"focus",value:function(I,r,o){this._drawRect(I,r,o),this.animate()}},{key:"blur",value:function(I,r,o){this.hoveredAnno=null,this._drawRect(I,r,o),this.animate()}},{key:"select",value:function(I,r,o,C=!1){let a=null,A=null;this.selectedAnno&&(a=this.selectedAnno.graphics,A=this.selectedAnno.uid),this.selectedAnno={graphics:I,uid:o},this.focus(I,r,o),this.options.onSelect&&!C&&(window[this.options.onSelect](o),this.pubSub.publish("annoSelected",o)),a&&A&&this.blur(a,a.__viewPos__,A)}},{key:"unselect",value:function(){const I=this.selectedAnno.graphics,r=this.selectedAnno.uid;this.selectedAnno=null,this.blur(I,I.__viewPos__,r)}},{key:"annoSelected",value:function(I){if(!this.selectedAnno||this.selectedAnno.uid!==I){this.selectedAnno&&this.unselect();const r=this.drawnAnnoGfx[I];r&&this.select(r,r.__viewPos__,I,!0)}}},{key:"exportSVG",value:function(){let I=null,r=null;V0(id(i.prototype),"exportSVG",this)?[r,I]=V0(id(i.prototype),"exportSVG",this).call(this):(r=document.createElement("g"),I=r);const o=document.createElement("g");return o.setAttribute("transform",`translate(${this.position[0]},${this.position[1]})`),I.appendChild(o),this.visibleAndFetchedTiles().filter(C=>C.tileData&&C.tileData.length).map(C=>({graphics:C.graphics,td:C.tileData})).forEach(({td:C,graphics:a})=>{const A=document.createElement("g");if(A.setAttribute("transform",`translate(${a.position.x},${a.position.y})scale(${a.scale.x},${a.scale.y})`),o.appendChild(A),C.uid in this.drawnAnnotations){const s=this.drawnAnnotations[C.uid],l=document.createElement("rect");l.setAttribute("x",s.x),l.setAttribute("y",s.y),l.setAttribute("width",s.width),l.setAttribute("height",s.height),l.setAttribute("fill",this.options.fillColor||"grey"),l.setAttribute("opacity",.3),l.style.stroke=this.options.fillColor||"grey",l.style.strokeWidth="1px",A.appendChild(l)}}),[r,r]}},{key:"setBorderStyle",value:function(I,r=this.options.rectangleDomainStrokeColor,o=this.options.rectangleDomainStrokeWidth,C=this.options.rectangleDomainStrokeOpacity){I.lineStyle(typeof o<"u"?o:1,jt(r||"black"),typeof C<"u"?C:1)}},{key:"setFill",value:function(I,r=this.options.rectangleDomainFillColor,o=this.options.rectangleDomainFillOpacity){I.beginFill(jt(r||"grey"),typeof o<"u"?o:.4)}},{key:"setPosition",value:function(I){V0(id(i.prototype),"setPosition",this).call(this,I),this.pMain.position.y=this.position[1],this.pMain.position.x=this.position[0]}},{key:"zoomed",value:function(I,r){this.xScale(I),this.yScale(r),this.refreshTiles(),this.draw()}}]),i}(rZ);function TAg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function IVe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function $b(e){return $b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},$b(e)}let ite=function(e){KAg(i,e);var g=xAg(i);function i(n,I,r){var o;return TAg(this,i),o=g.call(this,n,I),o.pubSub=n.pubSub,o.options=I,o.isVertical=r,o.rects={},o.defaultColor=fI("red"),o}return HAg(i,[{key:"draw",value:function(){const I=typeof this.options.minRectWidth<"u"?this.options.minRectWidth:10,r=typeof this.options.fill<"u"?fI(this.options.fill):this.defaultColor,o=typeof this.options.fillOpacity<"u"?+this.options.fillOpacity:.2,C=typeof this.options.stroke<"u"?fI(this.options.stroke):this.defaultColor,a=typeof this.options.strokeWidth<"u"?+this.options.strokeWidth:1,A=typeof this.options.strokeOpacity<"u"?+this.options.strokeOpacity:0;let s;this.options.strokePos&&this.options.strokePos.length&&(s=Array.isArray(this.options.strokePos)?this.options.strokePos:[this.options.strokePos]),pW($b(i.prototype),"draw",this).call(this);const l=this.pMain;l.clear();const c=performance.now();this.options.regions.forEach(u=>{const d=`${u[0]}-${u[1]}`;this.rects[d]||(this.rects[d]={graphics:new st.PIXI.Graphics},l.addChild(this.rects[d].graphics)),this.rects[d].timeStamp=c;const h=fI(u[2])||r;let f=fI(u[3])||C;f||(f=h);const m=st.PIXI.utils.rgb2hex([h.r/255,h.g/255,h.b/255]),b=st.PIXI.utils.rgb2hex([f.r/255,f.g/255,f.b/255]);s?(l.lineStyle(1,b,0),l.beginFill(b,+u[5]||A)):(l.lineStyle(a,b,+u[5]||A),l.beginFill(m,+u[4]||o));const p=this.isVertical?this._yScale:this._xScale;let y=p(+u[0]);const Z=p(+u[1]);let v=Z-y;const G=typeof u[6]<"u"?u[6]:I;v{(B==="top"||B==="around")&&(this.isVertical?l.drawRect(0,y,a,v):l.drawRect(y,0,v,a)),(B==="right"||B==="around")&&(this.isVertical?l.drawRect(0,y,this.dimensions[0],a):l.drawRect(y,0,a,this.dimensions[1])),(B==="bottom"||B==="around")&&(this.isVertical?l.drawRect(this.dimensions[0]-a,y,a,v):l.drawRect(y,this.dimensions[1]-a,v,a)),(B==="left"||B==="around")&&(this.isVertical?l.drawRect(0,y+v-a,this.dimensions[0],a):l.drawRect(y+v-a,0,a,this.dimensions[1]))})):l.lineStyle(a,b,+u[5]||A),this.rects[d].graphics.clear(),this.rects[d].graphics.interactive=!0,this.rects[d].graphics.buttonMode=!0,l.beginFill(m,+u[4]||o),this.isVertical?(l.drawRect(0,y,this.dimensions[0],v),this.rects[d].graphics.hitArea=new st.PIXI.Rectangle(0,y,this.dimensions[0],v)):(l.drawRect(y,0,v,this.dimensions[1]),this.rects[d].graphics.hitArea=new st.PIXI.Rectangle(y,0,v,this.dimensions[1])),this.rects[d].graphics.mousedown=()=>{this.rects[d].mouseDownTime=performance.now()},this.rects[d].graphics.mouseup=B=>{performance.now()-this.rects[d].mouseDownTimeu.timeStamp!==c).forEach(u=>l.removeChild(u.graphics))}},{key:"setPosition",value:function(I){pW($b(i.prototype),"setPosition",this).call(this,I),this.pMain.position.y=this.position[1],this.pMain.position.x=this.position[0]}},{key:"zoomed",value:function(I,r){this.xScale(I),this.yScale(r),this.draw()}}]),i}(Lo);function MAg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function rVe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function _l(e){return _l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},_l(e)}let JQe=function(e){JAg(i,e);var g=LAg(i);function i(n,I){var r;return MAg(this,i),r=g.call(this,n,I),r.drawnRects=new Set,r.pMain=r.pMobile,r}return zAg(i,[{key:"tileToLocalId",value:function(I){return`${I.join(".")}`}},{key:"tileToRemoteId",value:function(I){return`${I.join(".")}`}},{key:"localToRemoteId",value:function(I){const r=I.split(".");return r.slice(0,r.length-1).join(".")}},{key:"calculateZoomLevel",value:function(){const I=Nt.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]),r=Nt.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[1]);let o=Math.max(I,r);return o=Math.min(o,this.maxZoom),this.options&&this.options.maxZoom&&(this.options.maxZoom>=0?o=Math.min(this.options.maxZoom,o):console.error("Invalid maxZoom on track:",this)),o}},{key:"setVisibleTiles",value:function(I){this.visibleTiles=I.map(r=>({tileId:this.tileToLocalId(r),remoteId:this.tileToRemoteId(r)})),this.visibleTileIds=new Set(this.visibleTiles.map(r=>r.tileId))}},{key:"calculateVisibleTiles",value:function(){if(!this.tilesetInfo)return;this.zoomLevel=this.calculateZoomLevel();const I=this._xScale.copy();I.domain([this._xScale.invert(this._xScale.range()[0]-this.dimensions[1]*Math.sqrt(2)),this._xScale.invert(this._xScale.range()[1]+this.dimensions[1]*Math.sqrt(2))]),this.xTiles=Nt.calculateTiles(this.zoomLevel,I,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width),this.yTiles=Nt.calculateTiles(this.zoomLevel,I,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width);const r=this.xTiles,o=this.yTiles,C=this.zoomLevel,A=this.tilesetInfo.max_width/2**C,s=[];for(let l=0;lthis.dimensions[1])continue;const d=[C,r[l],o[c]];d.mirrored=!1,s.push(d)}this.setVisibleTiles(s)}},{key:"initTile",value:function(I){sf(_l(i.prototype),"initTile",this).call(this,I),this.drawTile(I)}},{key:"destroyTile",value:function(I,r){}},{key:"draw",value:function(){this.delayDrawing||this.drawnRects.clear(),sf(_l(i.prototype),"draw",this).call(this)}},{key:"drawTile",value:function(I){if(!I.graphics)return;const r=I.graphics;r.clear();const o=jt(this.options.rectangleDomainStrokeColor?this.options.rectangleDomainStrokeColor:"black"),C=jt(this.options.rectangleDomainFillColor?this.options.rectangleDomainFillColor:"grey");if(r.lineStyle(1/this.pMain.scale.x,o,1),r.beginFill(C,.4),r.alpha=this.options.rectangleDomainOpacity?this.options.rectangleDomainOpacity:.5,!!I.tileData.sort)for(const a of I.tileData){const A=this._refXScale(a.xStart),s=this._refXScale(a.xEnd),l=this._refYScale(a.yStart),c=this._refYScale(a.yEnd),u=a.uid;this.drawnRects.has(u)||(this.drawnRects.add(u),r.drawRect(A,l,s-A,c-l),r.pivot.x=this._refXScale(0),r.pivot.y=this._refYScale(0),r.scale.x=-1/Math.sqrt(2),r.rotation=-3*Math.PI/4,r.scale.y=1/Math.sqrt(2),r.position.x=this._refXScale(0),r.position.y=0)}}},{key:"setPosition",value:function(I){sf(_l(i.prototype),"setPosition",this).call(this,I),this.pMain.position.y=this.position[1],this.pMain.position.x=this.position[0]}},{key:"refScalesChanged",value:function(I,r){sf(_l(i.prototype),"refScalesChanged",this).call(this,I,r);for(const o in this.fetchedTiles){const C=this.fetchedTiles[o];if(C.sprite){const a=C.graphics;a.pivot.x=this._refXScale(0),a.pivot.y=this._refYScale(0),a.scale.x=-1/Math.sqrt(2),a.rotation=-3*Math.PI/4,a.scale.y=1/Math.sqrt(2),a.position.x=this._refXScale(0),a.position.y=0}}}},{key:"zoomed",value:function(I,r,o,C,a){sf(_l(i.prototype),"zoomed",this).call(this,I,r,o,C,a),this.pMain.position.x=C,this.pMain.position.y=this.position[1]+this.dimensions[1],this.pMain.scale.x=o,this.pMain.scale.y=o,this.options.oneDHeatmapFlipped&&(this.pMain.scale.y=-o,this.pMain.position.y=this.position[1]),this.draw()}},{key:"leftTrackDraw",value:function(){this.draw()}}]),i}(rZ);function $Ag(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function oVe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function qb(e){return qb=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},qb(e)}let LQe=function(e){ilg(i,e);var g=nlg(i);function i(n,I){var r;return $Ag(this,i),r=g.call(this,n,I),r.drawnRects=new Set,r}return qAg(i,[{key:"tileToLocalId",value:function(I){return`${I.join(".")}`}},{key:"tileToRemoteId",value:function(I){return`${I.join(".")}`}},{key:"localToRemoteId",value:function(I){const r=I.split(".");return r.slice(0,r.length-1).join(".")}},{key:"calculateZoomLevel",value:function(){const I=Nt.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]),r=Nt.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[1]);let o=Math.max(I,r);return o=Math.min(o,this.maxZoom),o}},{key:"setVisibleTiles",value:function(I){this.visibleTiles=I.map(r=>({tileId:this.tileToLocalId(r),remoteId:this.tileToRemoteId(r)})),this.visibleTileIds=new Set(this.visibleTiles.map(r=>r.tileId))}},{key:"calculateVisibleTiles",value:function(I=!0){if(!this.tilesetInfo)return;this.zoomLevel=this.calculateZoomLevel(),this.xTiles=Nt.calculateTiles(this.zoomLevel,this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width),this.yTiles=Nt.calculateTiles(this.zoomLevel,this._yScale,this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[1],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width);const r=this.xTiles,o=this.yTiles,C=this.zoomLevel,a=[];for(let A=0;An.chrPositions?mI(I,n):null,n.chrToAbs=([I,r]=[])=>n.chrPositions?HF(I,r,n):null,Nt.text(e,(I,r)=>{if(I)g&&g(null);else{const o=Hae(r),C=uP(o);Object.keys(C).forEach(a=>{n[a]=C[a]}),g&&g(n)}},i).then(()=>n)}function Clg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function CVe(e,g){for(var i=0;ii.pos).left}return alg(e,[{key:"scalesToPositionText",value:function(i,n,I=!1){if(this.chromInfo===null||!i||!n)return"";const r=mI(i.domain()[0],this.chromInfo),o=mI(i.domain()[1],this.chromInfo),C=mI(n.domain()[0],this.chromInfo),a=mI(n.domain()[1],this.chromInfo);let A=null;const s=da(",d");return r[0]!==o[0]?A=`${r[0]}:${s(Math.floor(r[1]))}-${o[0]}:${s(Math.ceil(o[1]))}`:A=`${r[0]}:${s(Math.floor(r[1]))}-${s(Math.ceil(o[1]))}`,I&&(C[0]!==a[0]?A+=` & ${C[0]}:${s(Math.floor(C[1]))}-${a[0]}:${s(Math.ceil(a[1]))}`:A+=` & ${C[0]}:${s(Math.floor(C[1]))}-${s(Math.ceil(a[1]))}`),(r[2]<=0||o[2]>0||I&&(C[2]<=0||a[2]>0))&&(A+=` [offset ${r[2]},${o[2]}`,I&&(A+=`:${C[2]},${a[2]}`),A+="]"),A}},{key:"convertNumberNotation",value:function(i){let n=i;if(!n.includes("M",n.length-1)&&!n.includes("K",n.length-1))return n;let I=0,r=0;if(n.includes("M",n.length-1)?(I=6,n=n.replace("M","")):(I=3,n=n.replace("K","")),Number.isNaN(+n))return i;n=(+n).toString(),n.includes(".")&&(r=n.length-1-n.indexOf("."),n=(+n.replace(".","")).toString());const o=I-r;return o<0?i:(n+="0".repeat(o),n)}},{key:"parsePosition",value:function(i,n=null){const I=i.split(":");let r=null,o=0;I.length>1?(r=I[0],o=+this.convertNumberNotation(I[1].replace(/,/g,""))):I[0]in this.chromInfo.chrPositions?(r=I[0],o=0,n!==null&&(o=+this.chromInfo.chromLengths[r])):(o=+this.convertNumberNotation(I[0].replace(/,/g,"")),r=null,n&&(r=n));let C=null;return r===null?(r=n,C=o):r in this.chromInfo.chrPositions&&(C=this.chromInfo.chrPositions[r].pos+o),[r,o,C]}},{key:"matchRangesToLarger",value:function(i,n){if(i[1]-i[0]r.length>0);let I=null;if(n[0].indexOf("-")===0&&(n[0]=n[0].slice(3,n[0].length)),n.length>1){let[r,o,C]=this.parsePosition(n[0]),[a,A,s]=this.parsePosition(n[1],r);const l=[C,s];[r,o,C]=this.parsePosition(n[1]),[a,A,s]=this.parsePosition(n[0],r),r===null&&a!==null&&([r,o,C]=this.parsePosition(n[1],a));const c=[C,s];return c[1]-c[0]>l[1]-l[0]?c:l}if(n[0]in this.chromInfo.chrPositions){const r=+this.chromInfo.chrPositions[n[0]].pos;I=[r,r+ +this.chromInfo.chromLengths[n[0]]]}else{const[r,o,C]=this.parsePosition(n[0]);I=[C-8e6,C+8e6]}return I[0]>I[1]?[I[1],I[0]]:I}},{key:"parseOffset",value:function(i){const n=i.split(":");if(n.length===0)return[[0,0],[0,0]];if(n.length===1){const o=n[0].split(",");return[[+o[0],+o[1]],[0,0]]}const I=n[0].split(","),r=n[1].split(",");return[[+I[0],+I[1]],[+r[0],+r[1]]]}},{key:"searchPosition",value:function(i){let n=null,I=null;i=i.trim();const r=/\[offset (.+?)\]/.exec(i);let o=[[0,0],[0,0]];r&&(i=i.replace(r[0],""),o=this.parseOffset(r[1]));const C=i.split(" & ");return C.length>1?(n=this.getSearchRange(C[0].split(" ")[0]),I=this.getSearchRange(C[1].split(" ")[0])):n=this.getSearchRange(C[0]),n!==null&&I!==null&&([n,I]=this.matchRangesToLarger(n,I)),n&&(n[0]+=o[0][0],n[1]+=o[0][1]),I&&(I[0]+=o[1][0],I[1]+=o[1][1]),[n,I]}}]),e}();function llg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function aVe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ww(e){return ww=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},ww(e)}let UQe=function(e){flg(i,e);var g=mlg(i);function i(n,I){var r;llg(this,i),r=g.call(this,n,I);const{dataConfig:o,animate:C,pubSub:a}=n;r.searchField=null,r.chromInfo=null,r.animate=C;const A=o.server,s=o.tilesetUid,l=`${A}/chrom-sizes/?id=${s}`;return Fd(l,c=>{r.chromInfo=c,r.searchField=new Bw(r.chromInfo),r.draw(),r.texts=[];for(let u=0;uthis.dimensions[0]?m.x-=h+p-this.dimensions[0]:h-p<0&&(m.x-=h-p),f+y>this.dimensions[1]?m.y-=f+y-this.dimensions[1]:f-y<0&&(m.y-=f-y),m.visible=!0,I.push({importance:this.texts[A][s].hashValue,text:this.texts[A][s],caption:null})}this.hideOverlaps(I)}},{key:"hideOverlaps",value:function(I){let r=[];r=I.map(o=>{const C=o.text;C.updateTransform();const a=C.getBounds();return[a.x,a.y,a.x+a.width,a.y+a.height]}),iH(r,(o,C)=>{I[o].importance>I[C].importance?I[C].text.visible=0:I[o].text.visible=0})}},{key:"setPosition",value:function(I){y5(ww(i.prototype),"setPosition",this).call(this,I),this.pMain.position.y=this.position[1],this.pMain.position.x=this.position[0]}},{key:"zoomed",value:function(I,r){this.xScale(I),this.yScale(r),this.draw()}}]),i}(Lo);function Zlg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function sVe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function $f(e){return $f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},$f(e)}let EV=function(e){Slg(i,e);var g=Rlg(i);function i(n,I){var r;Zlg(this,i),r=g.call(this,n,I);const{chromInfoPath:o,dataConfig:C,animate:a,pubSub:A,orientation:s="2d",isOverlay:l=!1}=n;r.searchField=null,r.chromInfo=null,r.animate=a,r.orientation=s,r.isOverlay=l;let c=o;return c||(c=`${C.server}/chrom-sizes/?id=${C.tilesetUid}`),Fd(c,u=>{r.chromInfo=u,r.searchField=new Bw(r.chromInfo),r.texts=[],r.lineGraphics=new st.PIXI.Graphics,r.lineGraphics1dH=new st.PIXI.Graphics,r.lineGraphics1dV=new st.PIXI.Graphics,r.lineGraphics2d=new st.PIXI.Graphics,r.mask1dH=new st.PIXI.Graphics,r.mask1dV=new st.PIXI.Graphics,r.mask2d=new st.PIXI.Graphics,r.lineGraphics.addChild(r.lineGraphics1dH),r.lineGraphics1dH.addChild(r.mask1dH),r.lineGraphics.addChild(r.lineGraphics1dV),r.lineGraphics1dV.addChild(r.mask1dV),r.lineGraphics.addChild(r.lineGraphics2d),r.lineGraphics2d.addChild(r.mask2d),r.pMain.addChild(r.lineGraphics),r.draw(),r.animate()},A),r}return Glg(i,[{key:"drawLines",value:function(I=this.orientation,r=0,o=0){let C=this.lineGraphics;this.isOverlay&&I==="1d-horizontal"&&(C=this.lineGraphics1dH),this.isOverlay&&I==="1d-vertical"&&(C=this.lineGraphics1dV),this.isOverlay&&I==="2d"&&(C=this.lineGraphics2d);const a=jt(this.options.lineStrokeColor?this.options.lineStrokeColor:"blue"),A=this.options.lineStrokeWidth?this.options.lineStrokeWidth:1;C.lineStyle(A,a,1),(I==="2d"||I==="1d-horizontal")&&(C.moveTo(this._xScale(0)+r,o),C.lineTo(this._xScale(0)+r,this.dimensions[1]+o)),(I==="2d"||I==="1d-vertical")&&(C.moveTo(r,this._yScale(0)+o),C.lineTo(this.dimensions[0]+r,this._yScale(0)+o));for(let s=0;s0&&c0&&c0&&h0&&h"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ey(e){return ey=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},ey(e)}const Mlg=300;let QQe=function(e){Klg(i,e);var g=xlg(i);function i(n,I){var r;Tlg(this,i),r=g.call(this,n,I);const{chromInfoPath:o,pubSub:C}=n;return r.pubSub=C,r.rects={},Fd(o,a=>{r.chromInfo=a,r.draw()},r.pubSub),r}return Hlg(i,[{key:"draw",value:function(){if(!this.chromInfo)return;const I=this.options.minRectWidth?this.options.minRectWidth:10,r=this.options.minRectWidth?this.options.minRectHeight:10;yW(ey(i.prototype),"draw",this).call(this);const o=this.pMain;o.clear();const C=performance.now();this.options.regions.forEach(a=>{const A=a.slice(0,6).join("-");this.rects[A]||(this.rects[A]={graphics:new st.PIXI.Graphics},o.addChild(this.rects[A].graphics)),this.rects[A].timeStamp=C;const s=fI(a[6]);let l=fI(a[7]);l||(l=s);const c=st.PIXI.utils.rgb2hex([s.r/255,s.g/255,s.b/255]),u=st.PIXI.utils.rgb2hex([l.r/255,l.g/255,l.b/255]);o.lineStyle(1,u,l.opacity),o.beginFill(c,s.opacity);let d=this._xScale(this.chromInfo.chrPositions[a[0]].pos+ +a[1]);const h=this._xScale(this.chromInfo.chrPositions[a[0]].pos+ +a[2]);let f=this._yScale(this.chromInfo.chrPositions[a[3]].pos+ +a[4]);const m=this._yScale(this.chromInfo.chrPositions[a[3]].pos+ +a[5]);let b=h-d,p=m-f;const y=typeof a[8]<"u"?a[8]:I,Z=typeof a[9]<"u"?a[9]:r;b{this.rects[A].mouseDownTime=performance.now()},this.rects[A].graphics.mouseup=v=>{performance.now()-this.rects[A].mouseDownTime"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function nd(e){return nd=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},nd(e)}const $lg=200,qlg=6,ecg=2,cVe=7829367;let $Qe=function(e){Llg(i,e);var g=Ulg(i);function i(n,I){var r;zlg(this,i),r=g.call(this,n,I);const{dataConfig:o,animate:C,chromInfoPath:a,isShowGlobalMousePosition:A}=n;r.searchField=null,r.chromInfo=null,r.dataConfig=o,r.pTicks=new st.PIXI.Graphics,r.pMain.addChild(r.pTicks),r.gTicks={},r.tickTexts={},r.options=I,r.isShowGlobalMousePosition=A,r.textFontSize=12,r.textFontFamily="Arial",r.textFontColor="#808080",r.textStrokeColor=r.getTheme()===ki?"#000000":"#ffffff",r.pixiTextConfig={fontSize:+r.options.fontSize?`${+r.options.fontSize}px`:`${r.textFontSize}px`,fontFamily:r.textFontFamily,fill:r.options.color||r.textFontColor,lineJoin:"round",stroke:r.options.stroke||r.textStrokeColor,strokeThickness:2},r.stroke=jt(r.pixiTextConfig.stroke),r.tickWidth=$lg,r.tickHeight=qlg,r.tickTextSeparation=ecg,r.tickColor=r.options.tickColor?jt(r.options.tickColor):cVe,r.animate=C,r.pubSubs=[],r.options.showMousePosition&&!r.hideMousePosition&&(r.hideMousePosition=Yb(jQe(r),r.is2d,r.isShowGlobalMousePosition()));let s=a;return s||(s=`${o.server}/chrom-sizes/?id=${o.tilesetUid}`),Fd(s,l=>{r.chromInfo=l,r.searchField=new Bw(r.chromInfo),r.rerender(r.options,!0),r.draw(),r.animate()},r.pubSub),r}return Plg(i,[{key:"initBoundsTicks",value:function(){this.pTicks&&(this.pMain.removeChild(this.pTicks),this.pTicks=null),this.gBoundTicks||(this.gBoundTicks=new st.PIXI.Graphics,this.leftBoundTick=new st.PIXI.Text("",this.pixiTextConfig),this.rightBoundTick=new st.PIXI.Text("",this.pixiTextConfig),this.gBoundTicks.addChild(this.leftBoundTick),this.gBoundTicks.addChild(this.rightBoundTick),this.pMain.addChild(this.gBoundTicks)),this.texts=[]}},{key:"initChromLabels",value:function(){if(this.chromInfo){this.gBoundTicks&&(this.pMain.removeChild(this.gBoundTicks),this.gBoundTicks=null),this.pTicks||(this.pTicks=new st.PIXI.Graphics,this.pMain.addChild(this.pTicks)),this.texts=[],this.pTicks.removeChildren();for(let I=0;INumber.isInteger(b)),c=this.tickTexts[I.chr],u=this.options.fontIsLeftAligned?(+this.options.fontSize||this.textFontSize)/2:this.tickHeight,d=this.flipText?-1:1,h=this.options.fontIsLeftAligned?d*4:0;let f=this.options.fontIsLeftAligned?0:u+this.tickTextSeparation;for(this.options.reverseOrientation&&(f=this.dimensions[1]-f);c.lengthl.length;){const b=c.pop();this.gTicks[I.chr].removeChild(b)}let m=0;for(;m{if(this.tickTexts[C])for(let a=0;a{o.updateTransform();const a=o.getBounds();return[a.x,a.y,a.x+a.width,a.y+a.height]}),iH(r,(o,C)=>{I[o].importance>I[C].importance?I[C].text.visible=!1:I[o].text.visible=!1})}},{key:"setPosition",value:function(I){W0(nd(i.prototype),"setPosition",this).call(this,I),[this.pMain.position.x,this.pMain.position.y]=this.position}},{key:"zoomed",value:function(I,r){this.xScale(I),this.yScale(r),this.draw()}},{key:"exportSVG",value:function(){let I=null,r=null;W0(nd(i.prototype),"exportSVG",this)?[r,I]=W0(nd(i.prototype),"exportSVG",this).call(this):(r=document.createElement("g"),I=r),r.setAttribute("class","chromosome-labels");const o=document.createElement("g");return I.appendChild(o),o.setAttribute("transform",`translate(${this.position[0]},${this.position[1]})`),this.allTexts.filter(C=>C.text.visible).forEach(C=>{const a=Bq(C.text);o.appendChild(a)}),Object.values(this.tickTexts).forEach(C=>{C.filter(a=>a.visible).forEach(a=>{let A=Bq(a);o.appendChild(A),A=u_e(a.x,this.options.reverseOrientation?0:this.dimensions[1],a.x,this.options.reverseOrientation?this.tickHeight:this.dimensions[1]-this.tickHeight,1,this.tickColor);const s=document.createElement("line");s.setAttribute("x1",a.tickLine[0]),s.setAttribute("y1",a.tickLine[1]),s.setAttribute("x2",a.tickLine[2]),s.setAttribute("y2",a.tickLine[3]),s.setAttribute("style","stroke: grey"),o.appendChild(A),o.appendChild(s)})}),[r,I]}}]),i}(Lo);function tcg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function uVe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Ol(e){return Ol=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},Ol(e)}let qQe=function(e){rcg(i,e);var g=ocg(i);function i(n,I){var r;tcg(this,i),r=g.call(this,n,I);const{animate:o}=n;return r.pMain=r.pMobile,r.colorScale=ew,r.continuousScaling=!1,I&&I.colorRange&&(r.colorScale=hm(I.colorRange)),r.animate=o,r.options=I,r.pubSubs=[],r}return gcg(i,[{key:"rerender",value:function(I,r){Af(Ol(i.prototype),"rerender",this).call(this,I,r),this.zoomed(this.xScale(),this.yScale(),this.pMain.scale.x,this.pMain.position.x,this.pMain.position.y)}},{key:"calculateZoomLevel",value:function(){let I=null;if(this.tilesetInfo.resolutions){const r=Nt.calculateZoomLevelFromResolutions(this.tilesetInfo.resolutions,this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]),o=Nt.calculateZoomLevelFromResolutions(this.tilesetInfo.resolutions,this._xScale,this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[1]);I=Math.min(r,o)}else{const r=Nt.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]),o=Nt.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[1]);I=Math.max(r,o),I=Math.min(I,this.maxZoom)}return this.options&&this.options.maxZoom&&(this.options.maxZoom>=0?I=Math.min(this.options.maxZoom,I):console.error("Invalid maxZoom on track:",this)),I}},{key:"calculateVisibleTiles",value:function(){if(!this.tilesetInfo)return;this.zoomLevel=this.calculateZoomLevel();const I=this._xScale.copy();if(I.domain([this._xScale.invert(this._xScale.range()[0]-this.dimensions[1]*Math.sqrt(2)),this._xScale.invert(this._xScale.range()[1]+this.dimensions[1]*Math.sqrt(2))]),this.tilesetInfo.resolutions){const l=this.tilesetInfo.resolutions.map(c=>+c).sort((c,u)=>u-c);this.xTiles=Nt.calculateTilesFromResolution(l[this.zoomLevel],I,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]),this.yTiles=Nt.calculateTilesFromResolution(l[this.zoomLevel],I,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0])}else this.xTiles=Nt.calculateTiles(this.zoomLevel,I,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width),this.yTiles=Nt.calculateTiles(this.zoomLevel,I,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width);const r=this.xTiles,o=this.yTiles,C=this.zoomLevel,A=this.tilesetInfo.max_width/2**C,s=[];for(let l=0;lthis.dimensions[1])continue;const d=[C,r[l],o[c]];d.mirrored=!1,d.dataTransform=this.options.dataTransform?this.options.dataTransform:"default",s.push(d)}this.setVisibleTiles(s)}},{key:"tileDataToCanvas",value:function(I){const r=document.createElement("canvas");r.width=256,r.height=256;const o=r.getContext("2d");o.fillStyle="transparent",o.fillRect(0,0,r.width,r.height);const C=new ImageData(I,r.width,r.height);return o.putImageData(C,0,0),r}},{key:"setSpriteProperties",value:function(I,r,o,C){const{tileX:a,tileY:A,tileWidth:s,tileHeight:l}=this.getTilePosAndDimensions(r,o),c=a+s,u=A+l;I.width=this._refXScale(c)-this._refXScale(a),I.height=this._refYScale(u)-this._refYScale(A),I.x=this._refXScale(a),I.y=this._refYScale(A)}},{key:"pixDataFunction",value:function(I,r){if(r){const o=I.graphics,C=this.tileDataToCanvas(r.pixData),a=st.PIXI.VERSION[0]==="4"?st.PIXI.Texture.fromCanvas(C,st.PIXI.SCALE_MODES.NEAREST):st.PIXI.Texture.from(C,{scaleMode:st.PIXI.SCALE_MODES.NEAREST});I.sprite=new st.PIXI.Sprite(a),I.canvas=C,this.setSpriteProperties(I.sprite,I.tileData.zoomLevel,I.tileData.tilePos,I.mirrored),o.pivot.x=this._refXScale(0),o.pivot.y=this._refYScale(0),o.scale.x=-1/Math.sqrt(2),o.rotation=-3*Math.PI/4,o.scale.y=1/Math.sqrt(2),o.position.x=this._refXScale(0),o.position.y=0,o.removeChildren(),o.addChild(I.sprite)}this.renderingTiles.delete(I.tileId)}},{key:"refScalesChanged",value:function(I,r){Af(Ol(i.prototype),"refScalesChanged",this).call(this,I,r);for(const o in this.fetchedTiles){const C=this.fetchedTiles[o];if(C.sprite){this.setSpriteProperties(C.sprite,C.tileData.zoomLevel,C.tileData.tilePos,C.mirrored);const a=C.graphics;a.pivot.x=this._refXScale(0),a.pivot.y=this._refYScale(0),a.scale.x=-1/Math.sqrt(2),a.rotation=-3*Math.PI/4,a.scale.y=1/Math.sqrt(2),a.position.x=this._refXScale(0),a.position.y=0}}}},{key:"zoomed",value:function(I,r,o,C,a){Af(Ol(i.prototype),"zoomed",this).call(this,I,r,o,C,a),Af(Ol(i.prototype),"draw",this).call(this),this.pMain.position.x=C,this.pMain.position.y=this.position[1]+this.dimensions[1],this.pMain.scale.x=o,this.pMain.scale.y=o,this.options.oneDHeatmapFlipped&&(this.pMain.scale.y=-o,this.pMain.position.y=this.position[1])}},{key:"leftTrackDraw",value:function(){this.draw()}},{key:"exportSVG",value:function(){let I=null,r=null;[r,I]=Af(Ol(i.prototype),"superSVG",this).call(this);const o=document.createElement("g");I.appendChild(o),o.setAttribute("transform",`translate(${this.pMain.position.x},${this.pMain.position.y}) scale(${this.pMain.scale.x},${this.pMain.scale.y})`);for(const a of this.visibleAndFetchedTiles()){const A=document.createElement("g"),s=a.graphics,l=s.rotation*180/Math.PI,c=`translate(${s.position.x},${s.position.y}) rotate(${l}) scale(${s.scale.x},${s.scale.y}) translate(${-s.pivot.x},${-s.pivot.y})`;A.setAttribute("transform",c);const u=a.sprite.rotation*180/Math.PI,d=document.createElement("g");d.setAttribute("transform",`translate(${a.sprite.x},${a.sprite.y}) rotate(${u}) scale(${a.sprite.scale.x},${a.sprite.scale.y})`);const h=document.createElement("image");h.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.canvas.toDataURL()),h.setAttribute("width",256),h.setAttribute("height",256),d.appendChild(h),A.appendChild(d),o.appendChild(A)}const C=this.exportColorBarSVG();return I.appendChild(C),[r,r]}}]),i}(gH);function Acg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function dVe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function yE(e){return yE=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},yE(e)}let hVe=function(e){dcg(i,e);var g=hcg(i);function i(n,I){var r;return Acg(this,i),r=g.call(this,n,I),r.tilesetInfo={},r.errorTextText=`Unknown track type: ${I.type}`,r}return lcg(i,[{key:"zoomed",value:function(){this.draw()}}]),i}(Lo);function bcg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function fVe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ZE(e){return ZE=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},ZE(e)}let tje=function(e){vcg(i,e);var g=Bcg(i);function i(n,I){var r;return bcg(this,i),r=g.call(this,n,I),r.axis=new I_(eje(r)),r.pBase.addChild(r.axis.pAxis),r}return ycg(i,[{key:"initTile",value:function(I){this.scale.minRawValue=this.minVisibleValueInTiles(),this.scale.maxRawValue=this.minVisibleValueInTiles(),this.scale.minValue=this.scale.minRawValue,this.scale.maxValue=this.scale.maxRawValue,this.drawTile(I)}},{key:"drawTile",value:function(I){if(!I.graphics)return;const r=I.graphics,o=6,C=4;r.clear(),this.valueScale=Dm().domain([this.minValue()+.01,this.maxValue()]).range([this.dimensions[1]-o/2,o/2]);const a=jt("black");r.lineStyle(1,a,.3),r.beginFill(a,.3),this.drawAxis(this.valueScale),I.tileData.forEach(A=>{const s=A.fields,l=+A.chrOffset,c=+s[1]+l,u=+s[2]+l,d=+s[3],h=this._xScale(c),f=this._xScale(u),m=Math.max(f-h,C),b=this.valueScale(d),p=(f+h)/2;r.drawRect(p-m/2,b-o/2,m,o)})}},{key:"minVisibleValueInTiles",value:function(){let I=this.visibleAndFetchedIds();return I.length===0&&(I=Object.keys(this.fetchedTiles)),Math.min.apply(null,I.map(o=>+Math.min(...this.fetchedTiles[o].tileData.filter(C=>!Number.isNaN(C.fields[3])).map(C=>+C.fields[3]))))}},{key:"maxVisibleValueInTiles",value:function(){let I=this.visibleAndFetchedIds();return I.length===0&&(I=Object.keys(this.fetchedTiles)),Math.max.apply(null,I.map(o=>+Math.max(...this.fetchedTiles[o].tileData.filter(C=>!Number.isNaN(C.fields[3])).map(C=>+C.fields[3]))))}}]),i}(eS);function Rcg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function mVe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function qf(e){return qf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},qf(e)}let gje=function(e){Hcg(i,e);var g=Ncg(i);function i(n,I){var r;Rcg(this,i),r=g.call(this,n,I);const{registerViewportChanged:o,removeViewportChanged:C,setDomainsCallback:a}=n,A=Ng.nice();return r.uid=A,r.options=I,r.hasFromView=!n.projectionXDomain||!n.projectionYDomain,r.removeViewportChanged=C,r.setDomainsCallback=a,r.viewportXDomain=r.hasFromView?null:n.projectionXDomain,r.viewportYDomain=r.hasFromView?null:n.projectionYDomain,r.brush=Zae().on("brush",r.brushed.bind(ute(r))),r.gBrush=r.gMain.append("g").attr("id",`brush-${r.uid}`).call(r.brush),r.gBrush.selectAll(".overlay").style("pointer-events","none"),r.gBrush.selectAll(".handle--n").style("pointer-events","none"),r.gBrush.selectAll(".handle--s").style("pointer-events","none"),r.gBrush.selectAll(".handle--w").style("pointer-events","none"),r.gBrush.selectAll(".handle--e").style("pointer-events","none"),o(A,r.viewportChanged.bind(ute(r))),r.rerender(),r.draw(),r}return Vcg(i,[{key:"brushed",value:function(I){const r=I.selection;if(!this._xScale||!this._yScale)return;const o=[this._xScale.invert(r[0][0]),this._xScale.invert(r[1][0])],C=[this._yScale.invert(r[0][1]),this._yScale.invert(r[1][1])];this.hasFromView||(this.viewportXDomain=o,this.viewportYDomain=C),this.setDomainsCallback(o,C)}},{key:"viewportChanged",value:function(I,r){const o=I.domain(),C=r.domain();this.viewportXDomain=o,this.viewportYDomain=C,this.draw()}},{key:"remove",value:function(){this.removeViewportChanged(this.uid),nB(qf(i.prototype),"remove",this).call(this)}},{key:"rerender",value:function(){this.gBrush.selectAll(".selection").attr("fill",this.options.projectionFillColor).attr("stroke",this.options.projectionStrokeColor).attr("fill-opacity",this.options.projectionFillOpacity).attr("stroke-opacity",this.options.projectionStrokeOpacity).attr("stroke-width",this.options.strokeWidth)}},{key:"draw",value:function(){if(!this._xScale||!this.yScale||!this.viewportXDomain||!this.viewportYDomain)return;const I=this._xScale(this.viewportXDomain[0]),r=this._yScale(this.viewportYDomain[0]),o=this._xScale(this.viewportXDomain[1]),C=this._yScale(this.viewportYDomain[1]),a=[[I,r],[o,C]];this.brush.on("brush",null),this.gBrush.call(this.brush.move,a),this.brush.on("brush",this.brushed.bind(this))}},{key:"zoomed",value:function(I,r){this.xScale(I),this.yScale(r),this.draw()}},{key:"setPosition",value:function(I){nB(qf(i.prototype),"setPosition",this).call(this,I),this.draw()}},{key:"setDimensions",value:function(I){nB(qf(i.prototype),"setDimensions",this).call(this,I);const r=this._xScale.range(),o=this._yScale.range(),C=r[1]-r[0],a=o[1]-o[0];this.brush.extent([[r[0]-C,o[0]-a],[r[1]+C,o[1]+a]]),this.gBrush.call(this.brush),this.draw()}}]),i}(oZ);function Kcg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function pVe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function em(e){return em=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},em(e)}let ije=function(e){Mcg(i,e);var g=zcg(i);function i(n,I){var r;Kcg(this,i),r=g.call(this,n,I);const{registerViewportChanged:o,removeViewportChanged:C,setDomainsCallback:a}=n,A=Ng.nice();return r.uid=A,r.options=I,r.hasFromView=!n.projectionXDomain,r.removeViewportChanged=C,r.setDomainsCallback=a,r.viewportXDomain=r.hasFromView?null:n.projectionXDomain,r.viewportYDomain=r.hasFromView?null:[0,0],r.brush=lP().on("brush",r.brushed.bind(hte(r))),r.gBrush=r.gMain.append("g").attr("id",`brush-${r.uid}`).call(r.brush),r.gBrush.selectAll(".overlay").style("pointer-events","none"),r.gBrush.selectAll(".handle--ne").style("pointer-events","none"),r.gBrush.selectAll(".handle--nw").style("pointer-events","none"),r.gBrush.selectAll(".handle--sw").style("pointer-events","none"),r.gBrush.selectAll(".handle--se").style("pointer-events","none"),r.gBrush.selectAll(".handle--n").style("pointer-events","none"),r.gBrush.selectAll(".handle--s").style("pointer-events","none"),o(A,r.viewportChanged.bind(hte(r))),r.rerender(),r.draw(),r}return xcg(i,[{key:"brushed",value:function(I){const r=I.selection;if(!this._xScale||!this._yScale)return;const o=[this._xScale.invert(r[0]),this._xScale.invert(r[1])],C=this.viewportYDomain;this.hasFromView||(this.viewportXDomain=o),this.setDomainsCallback(o,C)}},{key:"viewportChanged",value:function(I,r,o=!0){const C=I.domain(),a=r.domain();this.viewportXDomain=C,this.viewportYDomain=a,this.draw()}},{key:"remove",value:function(){this.removeViewportChanged(this.uid),IB(em(i.prototype),"remove",this).call(this)}},{key:"rerender",value:function(){this.gBrush.selectAll(".selection").attr("fill",this.options.projectionFillColor).attr("stroke",this.options.projectionStrokeColor).attr("fill-opacity",this.options.projectionFillOpacity).attr("stroke-opacity",this.options.projectionStrokeOpacity).attr("stroke-width",this.options.strokeWidth)}},{key:"draw",value:function(){if(!this._xScale||!this.yScale||!this.viewportXDomain||!this.viewportYDomain)return;const I=this._xScale(this.viewportXDomain[0]),r=this._xScale(this.viewportXDomain[1]),o=[I,r];this.brush.on("brush",null),this.gBrush.call(this.brush.move,o),this.brush.on("brush",this.brushed.bind(this))}},{key:"zoomed",value:function(I,r){this.xScale(I),this.yScale(r),this.draw()}},{key:"setPosition",value:function(I){IB(em(i.prototype),"setPosition",this).call(this,I),this.draw()}},{key:"setDimensions",value:function(I){IB(em(i.prototype),"setDimensions",this).call(this,I);const r=this._xScale.range(),o=this._yScale.range(),C=r[1]-r[0];this.brush.extent([[r[0]-C,o[0]],[r[1]+C,o[1]]]),this.gBrush.call(this.brush),this.draw()}}]),i}(oZ);function Ocg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function bVe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function tm(e){return tm=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},tm(e)}let nje=function(e){jcg(i,e);var g=$cg(i);function i(n,I){var r;Ocg(this,i),r=g.call(this,n,I);const{registerViewportChanged:o,removeViewportChanged:C,setDomainsCallback:a}=n,A=Ng.nice();return r.uid=A,r.options=I,r.hasFromView=!n.projectionYDomain,r.removeViewportChanged=C,r.setDomainsCallback=a,r.viewportXDomain=r.hasFromView?null:[0,0],r.viewportYDomain=r.hasFromView?null:n.projectionYDomain,r.brush=TT().on("brush",r.brushed.bind(mte(r))),r.gBrush=r.gMain.append("g").attr("id",`brush-${r.uid}`).call(r.brush),r.gBrush.selectAll(".overlay").style("pointer-events","none"),r.gBrush.selectAll(".handle--ne").style("pointer-events","none"),r.gBrush.selectAll(".handle--nw").style("pointer-events","none"),r.gBrush.selectAll(".handle--sw").style("pointer-events","none"),r.gBrush.selectAll(".handle--se").style("pointer-events","none"),r.gBrush.selectAll(".handle--e").style("pointer-events","none"),r.gBrush.selectAll(".handle--w").style("pointer-events","none"),o(A,r.viewportChanged.bind(mte(r))),r.rerender(),r.draw(),r}return Jcg(i,[{key:"brushed",value:function(I){const r=I.selection;if(!this._xScale||!this._yScale)return;const o=this.viewportXDomain,C=[this._yScale.invert(r[0]),this._yScale.invert(r[1])];this.hasFromView||(this.viewportYDomain=C),this.setDomainsCallback(o,C)}},{key:"viewportChanged",value:function(I,r,o=!0){const C=I.domain(),a=r.domain();this.viewportXDomain=C,this.viewportYDomain=a,this.draw()}},{key:"remove",value:function(){this.removeViewportChanged(this.uid),rB(tm(i.prototype),"remove",this).call(this)}},{key:"rerender",value:function(){this.gBrush.selectAll(".selection").attr("fill",this.options.projectionFillColor).attr("stroke",this.options.projectionStrokeColor).attr("fill-opacity",this.options.projectionFillOpacity).attr("stroke-opacity",this.options.projectionStrokeOpacity).attr("stroke-width",this.options.strokeWidth)}},{key:"draw",value:function(){if(!this._xScale||!this.yScale||!this.viewportXDomain||!this.viewportYDomain)return;const I=this._yScale(this.viewportYDomain[0]),r=this._yScale(this.viewportYDomain[1]),o=[I,r];this.brush.on("brush",null),this.gBrush.call(this.brush.move,o),this.brush.on("brush",this.brushed.bind(this))}},{key:"zoomed",value:function(I,r){this.xScale(I),this.yScale(r),this.draw()}},{key:"setPosition",value:function(I){rB(tm(i.prototype),"setPosition",this).call(this,I),this.draw()}},{key:"setDimensions",value:function(I){rB(tm(i.prototype),"setDimensions",this).call(this,I);const r=this._xScale.range(),o=this._yScale.range(),C=o[1]-o[0];this.brush.extent([[r[0],o[0]-C],[r[1],o[1]+C]]),this.gBrush.call(this.brush),this.draw()}}]),i}(oZ);function yVe(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function ZVe(e,g){for(var i=0;ie[bte]||e,iug=(e,g)=>{const i=g(e);return i.prototype[pte]=Ije(g),i},nug=(e,g)=>e.hasOwnProperty(pte)&&e[pte]===Ije(g),Iug=(e,g)=>{for(;e!==null;){if(nug(e,g))return!0;e=Object.getPrototypeOf(e)}return!1},dAe=(e,g)=>(Object.setPrototypeOf(g,e),e[bte]||(e[bte]=e),g),DQ="__mixwith_cachedApplications",rug=e=>dAe(e,g=>{let i=g[DQ];i||(g[DQ]=new Map,i=g[DQ]);let n=i.get(e);return n||(n=e(g),i.set(e,n)),n}),oug=e=>dAe(e,g=>Iug(g.prototype,e)?g:e(g)),Cug=e=>dAe(e,g=>iug(g,e)),h_=e=>oug(rug(Cug(e)));let aug=function(){function e(g){yVe(this,e),this.superclass=g||function(){function i(){yVe(this,i)}return GVe(i)}()}return GVe(e,[{key:"with",value:function(...i){return i.reduce((n,I)=>I(n),this.superclass)}}]),e}();const tS=e=>new aug(e);function sug(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function vVe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ty(e){return ty=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},ty(e)}const hAe=h_(e=>function(g){dug(n,g);var i=hug(n);function n(I,r){var o;sug(this,n),o=i.call(this,I,r);const{animate:C}=I;return o.highlighted=!1,o.animate=C,o.MOUSEOVER_RADIUS=4,o.pubSub=I.pubSub,o.pubSubs.push(o.pubSub.subscribe("app.mouseMove",o.mouseMoveHandler.bind(rje(o)))),o}return Aug(n,[{key:"setPosition",value:function(r){ZW(ty(n.prototype),"setPosition",this).call(this,r),this.pMain.position.x=this.position[0],this.pMain.position.y=this.position[1]}},{key:"zoomed",value:function(r,o){ZW(ty(n.prototype),"zoomed",this).call(this,r,o),this.draw()}},{key:"respondsToPosition",value:function(){return this.highlighted}}]),n}(e));function GW(){return typeof Reflect<"u"&&Reflect.get?GW=Reflect.get.bind():GW=function(g,i,n){var I=pug(g,i);if(I){var r=Object.getOwnPropertyDescriptor(I,i);return r.get?r.get.call(arguments.length<3?g:n):r.value}},GW.apply(this,arguments)}function pug(e,g){for(;!Object.prototype.hasOwnProperty.call(e,g)&&(e=gy(e),e!==null););return e}function oje(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function BVe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function gy(e){return gy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},gy(e)}const Bug=h_(e=>function(g){aje(n,g);var i=sje(n);function n(){return oje(this,n),i.apply(this,arguments)}return Cje(n,[{key:"drawHorizontalRule",value:function(r){let o=jt(this.options.color||"black");this.highlighted&&(o=jt("red")),r.lineStyle(this.strokeWidth,o,this.strokeOpacity);let C=0;for(;C"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function iy(e){return iy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},iy(e)}const hje=h_(e=>function(g){uje(n,g);var i=dje(n);function n(){return lje(this,n),i.apply(this,arguments)}return cje(n,[{key:"drawVerticalRule",value:function(r){let o=jt(this.options.color||"black");this.highlighted&&(o=jt("red")),r.lineStyle(this.strokeWidth,o,this.strokeOpacity);let C=0;for(;C"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ny(e){return ny=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},ny(e)}let mje=function(e){Kug(i,e);var g=xug(i);function i(n,I){var r;Tug(this,i),r=g.call(this,n,I);const{x:o,y:C}=n;return r.xPosition=o,r.yPosition=C,r.strokeWidth=2,r.strokeOpacity=1,r.dashLength=5,r.dashGap=3,r}return Hug(i,[{key:"draw",value:function(){const I=this.pMain;I.clear(),this.drawHorizontalRule(I),this.drawVerticalRule(I)}},{key:"mouseMoveHandler",value:function(I){this.highlighted=this.isWithin(I.x,I.y)&&(this.isMouseOverHorizontalLine(I)||this.isMouseOverVerticalLine(I)),this.draw()}},{key:"drawHorizontalRule",value:function(I){let r=jt(this.options.color||"black");this.highlighted&&(r=jt("red")),I.lineStyle(this.strokeWidth,r,this.strokeOpacity);let o=0;for(;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Jl(e){return Jl=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},Jl(e)}let nH=function(e){Jug(i,e);var g=Lug(i);function i(n,I){var r;Mug(this,i),r=g.call(this,n,I);const{animate:o}=n;return r.visibleTiles=new Set,r.visibleTileIds=new Set,r.fetching=new Set,r.fetchedTiles={},r.tileGraphics={},r.minX=typeof r.options.minPos<"u"&&!Number.isNaN(+r.options.minPos)?+r.options.minPos:-180,r.maxX=+r.options.maxPos||180,r.maxX=typeof r.options.maxPos<"u"&&!Number.isNaN(+r.options.maxPos)?+r.options.maxPos:180,r.minY=r.options.minY||r.minX,r.maxY=r.options.maxY||r.maxX,r.maxZoom=19,r.maxWidth=r.maxX-r.minX,r.animate=o,r.uuid=Ng.nice(),r.refreshTilesDebounced=Wae(r.refreshTiles.bind(pje(r)),kF),r}return zug(i,[{key:"visibleAndFetchedIds",value:function(){return Object.keys(this.fetchedTiles).filter(I=>this.visibleTileIds.has(I))}},{key:"visibleAndFetchedTiles",value:function(){return this.visibleAndFetchedIds().map(I=>this.fetchedTiles[I])}},{key:"setVisibleTiles",value:function(I){this.visibleTiles=I.map(r=>({tileId:this.tileToLocalId(r),remoteId:this.tileToRemoteId(r),mirrored:r.mirrored})),this.visibleTileIds=new Set(this.visibleTiles.map(r=>r.tileId))}},{key:"removeAllTiles",value:function(){const I=new Set(Object.keys(this.fetchedTiles));this.removeTiles([...I])}},{key:"refreshTiles",value:function(){this.calculateVisibleTiles();const I=new Set(Object.keys(this.fetchedTiles)),r=[...this.visibleTiles].filter(C=>!this.fetching.has(C.remoteId)&&!I.has(C.tileId));for(let C=0;C!this.visibleTileIds.has(C));this.removeTiles(o),this.fetchNewTiles(r)}},{key:"removeTiles",value:function(I){I.length&&this.areAllVisibleTilesLoaded()&&(I.forEach(r=>{const o=r;this.destroyTile(this.fetchedTiles[o]),o in this.tileGraphics&&(this.pMain.removeChild(this.tileGraphics[o]),delete this.tileGraphics[o]),delete this.fetchedTiles[o]}),this.synchronizeTilesAndGraphics(),this.draw())}},{key:"tileToLocalId",value:function(I){return I.join(".")}},{key:"tileToRemoteId",value:function(I){return I.join(".")}},{key:"localToRemoteId",value:function(I){const r=I.split(".");return r.slice(0,r.length-1).join(".")}},{key:"calculateZoomLevel",value:function(){const I=Nt.calculateZoomLevel(this._xScale,this.minX,this.maxX),r=Nt.calculateZoomLevel(this._xScale,this.minY,this.maxY);let o=Math.min(Math.max(I,r),this.maxZoom);return this.options.maxZoom&&(this.options.maxZoom>=0?o=Math.min(this.options.maxZoom,o):console.error("Invalid maxZoom on track:",this)),o}},{key:"calculateVisibleTiles",value:function(){this.zoomLevel=this.calculateZoomLevel(),this.xTiles=Nt.calculateTiles(this.zoomLevel,this._xScale,this.minX,this.maxX,this.maxZoom,this.maxWidth),this.yTiles=Nt.calculateTiles(this.zoomLevel,this._yScale,this.minY,this.maxY,this.maxZoom,this.maxWidth);const I=this.xTiles,r=this.yTiles,o=this.zoomLevel,C=[];for(let a=0;a0){const r=[...new Set(I.map(o=>o.remoteId))];for(const o of r){const C=o.split("."),a=this.getTileUrl(C),A=new Image;A.crossOrigin="Anonymous",A.src=a,A.onload=()=>{const s={};s[o]={tileId:o,img:A,zoomLevel:+C[0],tilePos:[+C[1],+C[2]],tileSrc:a},this.receivedTiles(s)}}}}},{key:"receivedTiles",value:function(I){for(let r=0;r"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Sw(e){return Sw=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},Sw(e)}let bje=function(e){gdg(i,e);var g=idg(i);function i(){return jug(this,i),g.apply(this,arguments)}return $ug(i,[{key:"initTile",value:function(I){Q7e.bind(this)(I),this.drawTile(I)}},{key:"drawTile",value:function(I){U7e.bind(this)(I)}},{key:"areAllVisibleTilesLoaded",value:function(){return!0}},{key:"fetchNewTiles",value:function(I){I.forEach(r=>{const C=r.remoteId.split("."),a={zoomLevel:C[0],tilePos:C.slice(1,C.length).map(A=>+A)};this.fetchedTiles[r.tileId]=r,this.fetchedTiles[r.tileId].tileData=a,this.fetching.has(r.remoteId)&&this.fetching.delete(r.remoteId)}),this.synchronizeTilesAndGraphics(),this.draw(),this.animate()}},{key:"draw",value:function(){Z5(Sw(i.prototype),"draw",this).call(this)}}]),i}(nH);function odg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function WVe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Rw(e){return Rw=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},Rw(e)}let yje=function(e){ldg(i,e);var g=cdg(i);function i(n,I){var r;return odg(this,i),r=g.call(this,n,I),r.style=I.style,r.options.accessToken||(r.errorTextText="No access token provided in the viewconf's track options ('accessToken' option).",r.drawError()),r}return Cdg(i,[{key:"rerender",value:function(I){G5(Rw(i.prototype),"rerender",this).call(this,I),I.style!==this.style&&(this.style=I.style,this.removeAllTiles(),this.refreshTiles())}},{key:"getTileUrl",value:function(I){const r=this.options&&this.options.style?this.options.style:"streets-v10",o=this.options&&+this.options.tileSize?+this.options.tileSize:256;return`https://api.mapbox.com/styles/v1/mapbox/${r}/tiles/${o}/${I[0]}/${I[1]}/${I[2]}?access_token=${this.options.accessToken}`}}]),i}(nH);function fdg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function XVe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function GE(e){return GE=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},GE(e)}let Zje=function(e){ydg(i,e);var g=Zdg(i);function i(n,I){var r;return fdg(this,i),r=g.call(this,n,I),r.style=I.style,r.options.tileSource||(r.errorTextText="No tile source string provided in the options. It should be in the form of http://a.com/{z}/{x}/{y}",r.drawError()),r}return mdg(i,[{key:"getTileUrl",value:function(I){let r=this.options.tileSource.replace("{z}",I[0]);return r=r.replace("{x}",I[1]),r=r.replace("{y}",I[2]),r}}]),i}(nH);const wdg=(e,g,i,n=AD)=>{const I=i[e.type];return I?new I.dataFetcher(n,e,g):e.type==="genbank"?new J7e(e,g):e.type==="local-tiles"?new L7e(e,g):new o_(e,g)};var rg=1e-6,s9=1e-12,Wg=Math.PI,Yn=Wg/2,vE=Wg/4,xo=Wg*2,Ni=180/Wg,sg=Wg/180,Ug=Math.abs,gS=Math.atan,Fo=Math.atan2,_t=Math.cos,nY=Math.ceil,Gje=Math.exp,Vte=Math.hypot,BE=Math.log,MQ=Math.pow,Yt=Math.sin,qa=Math.sign||function(e){return e>0?1:e<0?-1:0},OI=Math.sqrt,fAe=Math.tan;function vje(e){return e>1?0:e<-1?Wg:Math.acos(e)}function Eo(e){return e>1?Yn:e<-1?-Yn:Math.asin(e)}function TVe(e){return(e=Yt(e/2))*e}function wn(){}function wE(e,g){e&&NVe.hasOwnProperty(e.type)&&NVe[e.type](e,g)}var HVe={Feature:function(e,g){wE(e.geometry,g)},FeatureCollection:function(e,g){for(var i=e.features,n=-1,I=i.length;++n=0?1:-1,I=n*i,r=_t(g),o=Yt(g),C=Hte*o,a=Tte*r+C*_t(I),A=C*n*Yt(I);SE.add(Fo(A,a)),Xte=e,Tte=r,Hte=o}function Wdg(e){return RE=new GI,uA(e,Hc),RE*2}function VE(e){return[Fo(e[1],e[0]),Eo(e[2])]}function Iy(e){var g=e[0],i=e[1],n=_t(i);return[n*_t(g),n*Yt(g),Yt(i)]}function IY(e,g){return e[0]*g[0]+e[1]*g[1]+e[2]*g[2]}function Vw(e,g){return[e[1]*g[2]-e[2]*g[1],e[2]*g[0]-e[0]*g[2],e[0]*g[1]-e[1]*g[0]]}function zQ(e,g){e[0]+=g[0],e[1]+=g[1],e[2]+=g[2]}function rY(e,g){return[e[0]*g,e[1]*g,e[2]*g]}function WE(e){var g=OI(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=g,e[1]/=g,e[2]/=g}var yn,uC,Tn,ia,g0,Rje,Vje,oB,wW,$h,Ed,Fu={point:Nte,lineStart:YVe,lineEnd:KVe,polygonStart:function(){Fu.point=Xje,Fu.lineStart=Xdg,Fu.lineEnd=Tdg,wW=new GI,Hc.polygonStart()},polygonEnd:function(){Hc.polygonEnd(),Fu.point=Nte,Fu.lineStart=YVe,Fu.lineEnd=KVe,SE<0?(yn=-(Tn=180),uC=-(ia=90)):wW>rg?ia=90:wW<-rg&&(uC=-90),Ed[0]=yn,Ed[1]=Tn},sphere:function(){yn=-(Tn=180),uC=-(ia=90)}};function Nte(e,g){$h.push(Ed=[yn=e,Tn=e]),gia&&(ia=g)}function Wje(e,g){var i=Iy([e*sg,g*sg]);if(oB){var n=Vw(oB,i),I=[n[1],-n[0],0],r=Vw(I,n);WE(r),r=VE(r);var o=e-g0,C=o>0?1:-1,a=r[0]*Ni*C,A,s=Ug(o)>180;s^(C*g0ia&&(ia=A)):(a=(a+360)%360-180,s^(C*g0ia&&(ia=g))),s?eqC(yn,Tn)&&(Tn=e):qC(e,Tn)>qC(yn,Tn)&&(yn=e):Tn>=yn?(eTn&&(Tn=e)):e>g0?qC(yn,e)>qC(yn,Tn)&&(Tn=e):qC(e,Tn)>qC(yn,Tn)&&(yn=e)}else $h.push(Ed=[yn=e,Tn=e]);gia&&(ia=g),oB=i,g0=e}function YVe(){Fu.point=Wje}function KVe(){Ed[0]=yn,Ed[1]=Tn,Fu.point=Nte,oB=null}function Xje(e,g){if(oB){var i=e-g0;wW.add(Ug(i)>180?i+(i>0?360:-360):i)}else Rje=e,Vje=g;Hc.point(e,g),Wje(e,g)}function Xdg(){Hc.lineStart()}function Tdg(){Xje(Rje,Vje),Hc.lineEnd(),Ug(wW)>rg&&(yn=-(Tn=180)),Ed[0]=yn,Ed[1]=Tn,oB=null}function qC(e,g){return(g-=e)<0?g+360:g}function Hdg(e,g){return e[0]-g[0]}function xVe(e,g){return e[0]<=e[1]?e[0]<=g&&g<=e[1]:gqC(n[0],n[1])&&(n[1]=I[1]),qC(I[0],n[1])>qC(n[0],n[1])&&(n[0]=I[0])):r.push(n=I);for(o=-1/0,i=r.length-1,g=0,n=r[i];g<=i;n=I,++g)I=r[g],(C=qC(n[1],I[0]))>o&&(o=C,yn=I[0],Tn=n[1])}return $h=Ed=null,yn===1/0||uC===1/0?[[NaN,NaN],[NaN,NaN]]:[[yn,uC],[Tn,ia]]}var DV,XE,TE,HE,NE,kE,YE,KE,kte,Yte,Kte,Tje,Hje,Go,vo,Bo,vA={sphere:wn,point:mAe,lineStart:FVe,lineEnd:EVe,polygonStart:function(){vA.lineStart=Kdg,vA.lineEnd=xdg},polygonEnd:function(){vA.lineStart=FVe,vA.lineEnd=EVe}};function mAe(e,g){e*=sg,g*=sg;var i=_t(g);IH(i*_t(e),i*Yt(e),Yt(g))}function IH(e,g,i){++DV,TE+=(e-TE)/DV,HE+=(g-HE)/DV,NE+=(i-NE)/DV}function FVe(){vA.point=kdg}function kdg(e,g){e*=sg,g*=sg;var i=_t(g);Go=i*_t(e),vo=i*Yt(e),Bo=Yt(g),vA.point=Ydg,IH(Go,vo,Bo)}function Ydg(e,g){e*=sg,g*=sg;var i=_t(g),n=i*_t(e),I=i*Yt(e),r=Yt(g),o=Fo(OI((o=vo*r-Bo*I)*o+(o=Bo*n-Go*r)*o+(o=Go*I-vo*n)*o),Go*n+vo*I+Bo*r);XE+=o,kE+=o*(Go+(Go=n)),YE+=o*(vo+(vo=I)),KE+=o*(Bo+(Bo=r)),IH(Go,vo,Bo)}function EVe(){vA.point=mAe}function Kdg(){vA.point=Fdg}function xdg(){Nje(Tje,Hje),vA.point=mAe}function Fdg(e,g){Tje=e,Hje=g,e*=sg,g*=sg,vA.point=Nje;var i=_t(g);Go=i*_t(e),vo=i*Yt(e),Bo=Yt(g),IH(Go,vo,Bo)}function Nje(e,g){e*=sg,g*=sg;var i=_t(g),n=i*_t(e),I=i*Yt(e),r=Yt(g),o=vo*r-Bo*I,C=Bo*n-Go*r,a=Go*I-vo*n,A=Vte(o,C,a),s=Eo(A),l=A&&-s/A;kte.add(l*o),Yte.add(l*C),Kte.add(l*a),XE+=s,kE+=s*(Go+(Go=n)),YE+=s*(vo+(vo=I)),KE+=s*(Bo+(Bo=r)),IH(Go,vo,Bo)}function Edg(e){DV=XE=TE=HE=NE=kE=YE=KE=0,kte=new GI,Yte=new GI,Kte=new GI,uA(e,vA);var g=+kte,i=+Yte,n=+Kte,I=Vte(g,i,n);return IWg?e+Math.round(-e/xo)*xo:e,g]}Fte.invert=Fte;function pAe(e,g,i){return(e%=xo)?g||i?xte(MVe(e),zVe(g,i)):MVe(e):g||i?zVe(g,i):Fte}function DVe(e){return function(g,i){return g+=e,[g>Wg?g-xo:g<-Wg?g+xo:g,i]}}function MVe(e){var g=DVe(e);return g.invert=DVe(-e),g}function zVe(e,g){var i=_t(e),n=Yt(e),I=_t(g),r=Yt(g);function o(C,a){var A=_t(a),s=_t(C)*A,l=Yt(C)*A,c=Yt(a),u=c*i+s*n;return[Fo(l*I-u*r,s*i-c*n),Eo(u*I+l*r)]}return o.invert=function(C,a){var A=_t(a),s=_t(C)*A,l=Yt(C)*A,c=Yt(a),u=c*I-l*r;return[Fo(l*I+c*r,s*i+u*n),Eo(u*i-s*n)]},o}function kje(e){e=pAe(e[0]*sg,e[1]*sg,e.length>2?e[2]*sg:0);function g(i){return i=e(i[0]*sg,i[1]*sg),i[0]*=Ni,i[1]*=Ni,i}return g.invert=function(i){return i=e.invert(i[0]*sg,i[1]*sg),i[0]*=Ni,i[1]*=Ni,i},g}function Yje(e,g,i,n,I,r){if(i){var o=_t(g),C=Yt(g),a=n*i;I==null?(I=g+n*xo,r=g-a/2):(I=PVe(o,I),r=PVe(o,r),(n>0?Ir)&&(I+=n*xo));for(var A,s=I;n>0?s>r:s1&&e.push(e.pop().concat(e.shift()))},result:function(){var i=e;return e=[],g=null,i}}}function v5(e,g){return Ug(e[0]-g[0])=0;--C)I.point((l=s[C])[0],l[1]);else n(c.x,c.p.x,-1,I);c=c.p}c=c.o,s=c.z,u=!u}while(!c.v);I.lineEnd()}}}function _Ve(e){if(g=e.length){for(var g,i=0,n=e[0],I;++i=0?1:-1,R=S*B,w=R>Wg,T=f*v;if(a.add(Fo(T*S*Yt(R),m*G+T*_t(R))),o+=w?B+S*xo:B,w^d>=i^y>=i){var W=Vw(Iy(u),Iy(p));WE(W);var V=Vw(r,W);WE(V);var X=(w^B>=0?-1:1)*Eo(V[2]);(n>X||n===X&&(W[0]||W[1]))&&(C+=w^B>=0?1:-1)}}return(o<-rg||o0){for(a||(I.polygonStart(),a=!0),I.lineStart(),v=0;v1&&y&2&&Z.push(Z.pop().concat(Z.shift())),s.push(Z.filter(Mdg))}}return c}}function Mdg(e){return e.length>1}function zdg(e,g){return((e=e.x)[0]<0?e[1]-Yn-rg:Yn-e[1])-((g=g.x)[0]<0?g[1]-Yn-rg:Yn-g[1])}const Ete=Eje(function(){return!0},Pdg,Odg,[-Wg,-Yn]);function Pdg(e){var g=NaN,i=NaN,n=NaN,I;return{lineStart:function(){e.lineStart(),I=1},point:function(r,o){var C=r>0?Wg:-Wg,a=Ug(r-g);Ug(a-Wg)0?Yn:-Yn),e.point(n,i),e.lineEnd(),e.lineStart(),e.point(C,i),e.point(r,i),I=0):n!==C&&a>=Wg&&(Ug(g-n)rg?gS((Yt(g)*(r=_t(n))*Yt(i)-Yt(n)*(I=_t(g))*Yt(e))/(I*r*o)):(g+n)/2}function Odg(e,g,i,n){var I;if(e==null)I=i*Yn,n.point(-Wg,I),n.point(0,I),n.point(Wg,I),n.point(Wg,0),n.point(Wg,-I),n.point(0,-I),n.point(-Wg,-I),n.point(-Wg,0),n.point(-Wg,I);else if(Ug(e[0]-g[0])>rg){var r=e[0]0,I=Ug(g)>rg;function r(s,l,c,u){Yje(u,e,i,c,s,l)}function o(s,l){return _t(s)*_t(l)>g}function C(s){var l,c,u,d,h;return{lineStart:function(){d=u=!1,h=1},point:function(f,m){var b=[f,m],p,y=o(f,m),Z=n?y?0:A(f,m):y?A(f+(f<0?Wg:-Wg),m):0;if(!l&&(d=u=y)&&s.lineStart(),y!==u&&(p=a(l,b),(!p||v5(l,p)||v5(b,p))&&(b[2]=1)),y!==u)h=0,y?(s.lineStart(),p=a(b,l),s.point(p[0],p[1])):(p=a(l,b),s.point(p[0],p[1],2),s.lineEnd()),l=p;else if(I&&l&&n^y){var v;!(Z&c)&&(v=a(b,l,!0))&&(h=0,n?(s.lineStart(),s.point(v[0][0],v[0][1]),s.point(v[1][0],v[1][1]),s.lineEnd()):(s.point(v[1][0],v[1][1]),s.lineEnd(),s.lineStart(),s.point(v[0][0],v[0][1],3)))}y&&(!l||!v5(l,b))&&s.point(b[0],b[1]),l=b,u=y,c=Z},lineEnd:function(){u&&s.lineEnd(),l=null},clean:function(){return h|(d&&u)<<1}}}function a(s,l,c){var u=Iy(s),d=Iy(l),h=[1,0,0],f=Vw(u,d),m=IY(f,f),b=f[0],p=m-b*b;if(!p)return!c&&s;var y=g*m/p,Z=-g*b/p,v=Vw(h,f),G=rY(h,y),B=rY(f,Z);zQ(G,B);var S=v,R=IY(G,S),w=IY(S,S),T=R*R-w*(IY(G,G)-1);if(!(T<0)){var W=OI(T),V=rY(S,(-R-W)/w);if(zQ(V,G),V=VE(V),!c)return V;var X=s[0],N=l[0],Y=s[1],x=l[1],M;N0^V[1]<(Ug(V[0]-X)Wg^(X<=V[0]&&V[0]<=N)){var U=rY(S,(-R+W)/w);return zQ(U,G),[V,VE(U)]}}}function A(s,l){var c=n?e:Wg-e,u=0;return s<-c?u|=1:s>c&&(u|=2),l<-c?u|=4:l>c&&(u|=8),u}return Eje(o,C,r,n?[0,-e]:[-Wg,e-Wg])}function Jdg(e,g,i,n,I,r){var o=e[0],C=e[1],a=g[0],A=g[1],s=0,l=1,c=a-o,u=A-C,d;if(d=i-o,!(!c&&d>0)){if(d/=c,c<0){if(d0){if(d>l)return;d>s&&(s=d)}if(d=I-o,!(!c&&d<0)){if(d/=c,c<0){if(d>l)return;d>s&&(s=d)}else if(c>0){if(d0)){if(d/=u,u<0){if(d0){if(d>l)return;d>s&&(s=d)}if(d=r-C,!(!u&&d<0)){if(d/=u,u<0){if(d>l)return;d>s&&(s=d)}else if(u>0){if(d0&&(e[0]=o+s*c,e[1]=C+s*u),l<1&&(g[0]=o+l*c,g[1]=C+l*u),!0}}}}}var MV=1e9,CY=-MV;function f_(e,g,i,n){function I(A,s){return e<=A&&A<=i&&g<=s&&s<=n}function r(A,s,l,c){var u=0,d=0;if(A==null||(u=o(A,l))!==(d=o(s,l))||a(A,s)<0^l>0)do c.point(u===0||u===3?e:i,u>1?n:g);while((u=(u+l+4)%4)!==d);else c.point(s[0],s[1])}function o(A,s){return Ug(A[0]-e)0?0:3:Ug(A[0]-i)0?2:1:Ug(A[1]-g)0?1:0:s>0?3:2}function C(A,s){return a(A.x,s.x)}function a(A,s){var l=o(A,1),c=o(s,1);return l!==c?l-c:l===0?s[1]-A[1]:l===1?A[0]-s[0]:l===2?A[1]-s[1]:s[0]-A[0]}return function(A){var s=A,l=Kje(),c,u,d,h,f,m,b,p,y,Z,v,G={point:B,lineStart:T,lineEnd:W,polygonStart:R,polygonEnd:w};function B(X,N){I(X,N)&&s.point(X,N)}function S(){for(var X=0,N=0,Y=u.length;Nn&&(j-Q)*(n-U)>(ee-U)*(e-Q)&&++X:ee<=n&&(j-Q)*(n-U)<(ee-U)*(e-Q)&&--X;return X}function R(){s=l,c=[],u=[],v=!0}function w(){var X=S(),N=v&&X,Y=(c=WCe(c)).length;(N||Y)&&(A.polygonStart(),N&&(A.lineStart(),r(null,null,1,A),A.lineEnd()),Y&&xje(c,C,X,r,A),A.polygonEnd()),s=A,c=u=d=null}function T(){G.point=V,u&&u.push(d=[]),Z=!0,y=!1,b=p=NaN}function W(){c&&(V(h,f),m&&y&&l.rejoin(),c.push(l.result())),G.point=B,y&&s.lineEnd()}function V(X,N){var Y=I(X,N);if(u&&d.push([X,N]),Z)h=X,f=N,m=Y,Z=!1,Y&&(s.lineStart(),s.point(X,N));else if(Y&&y)s.point(X,N);else{var x=[b=Math.max(CY,Math.min(MV,b)),p=Math.max(CY,Math.min(MV,p))],M=[X=Math.max(CY,Math.min(MV,X)),N=Math.max(CY,Math.min(MV,N))];Jdg(x,M,e,g,i,n)?(y||(s.lineStart(),s.point(x[0],x[1])),s.point(M[0],M[1]),Y||s.lineEnd(),v=!1):Y&&(s.lineStart(),s.point(X,N),v=!1)}b=X,p=N,y=Y}return G}}function Ldg(){var e=0,g=0,i=960,n=500,I,r,o;return o={stream:function(C){return I&&r===C?I:I=f_(e,g,i,n)(r=C)},extent:function(C){return arguments.length?(e=+C[0][0],g=+C[0][1],i=+C[1][0],n=+C[1][1],I=r=null,o):[[e,g],[i,n]]}}}var Dte,Mte,B5,w5,Ww={sphere:wn,point:wn,lineStart:Udg,lineEnd:wn,polygonStart:wn,polygonEnd:wn};function Udg(){Ww.point=jdg,Ww.lineEnd=Qdg}function Qdg(){Ww.point=Ww.lineEnd=wn}function jdg(e,g){e*=sg,g*=sg,Mte=e,B5=Yt(g),w5=_t(g),Ww.point=$dg}function $dg(e,g){e*=sg,g*=sg;var i=Yt(g),n=_t(g),I=Ug(e-Mte),r=_t(I),o=Yt(I),C=n*o,a=w5*i-B5*n*r,A=B5*i+w5*n*r;Dte.add(Fo(OI(C*C+a*a),A)),Mte=e,B5=i,w5=n}function Mje(e){return Dte=new GI,uA(e,Ww),+Dte}var zte=[null,null],qdg={type:"LineString",coordinates:zte};function xE(e,g){return zte[0]=e,zte[1]=g,Mje(qdg)}var OVe={Feature:function(e,g){return FE(e.geometry,g)},FeatureCollection:function(e,g){for(var i=e.features,n=-1,I=i.length;++n0&&(I=xE(e[r],e[r-1]),I>0&&i<=I&&n<=I&&(i+n-I)*(1-Math.pow((i-n)/I,2))rg}).map(c)).concat(Xo(nY(r/A)*A,I,A).filter(function(p){return Ug(p%l)>rg}).map(u))}return m.lines=function(){return b().map(function(p){return{type:"LineString",coordinates:p}})},m.outline=function(){return{type:"Polygon",coordinates:[d(n).concat(h(o).slice(1),d(i).reverse().slice(1),h(C).reverse().slice(1))]}},m.extent=function(p){return arguments.length?m.extentMajor(p).extentMinor(p):m.extentMinor()},m.extentMajor=function(p){return arguments.length?(n=+p[0][0],i=+p[1][0],C=+p[0][1],o=+p[1][1],n>i&&(p=n,n=i,i=p),C>o&&(p=C,C=o,o=p),m.precision(f)):[[n,C],[i,o]]},m.extentMinor=function(p){return arguments.length?(g=+p[0][0],e=+p[1][0],r=+p[0][1],I=+p[1][1],g>e&&(p=g,g=e,e=p),r>I&&(p=r,r=I,I=p),m.precision(f)):[[g,r],[e,I]]},m.step=function(p){return arguments.length?m.stepMajor(p).stepMinor(p):m.stepMinor()},m.stepMajor=function(p){return arguments.length?(s=+p[0],l=+p[1],m):[s,l]},m.stepMinor=function(p){return arguments.length?(a=+p[0],A=+p[1],m):[a,A]},m.precision=function(p){return arguments.length?(f=+p,c=jVe(r,I,90),u=$Ve(g,e,f),d=jVe(C,o,90),h=$Ve(n,i,f),m):f},m.extentMajor([[-180,-90+rg],[180,90-rg]]).extentMinor([[-180,-80-rg],[180,80+rg]])}function ghg(){return Pje()()}function ihg(e,g){var i=e[0]*sg,n=e[1]*sg,I=g[0]*sg,r=g[1]*sg,o=_t(n),C=Yt(n),a=_t(r),A=Yt(r),s=o*_t(i),l=o*Yt(i),c=a*_t(I),u=a*Yt(I),d=2*Eo(OI(TVe(r-n)+o*a*TVe(I-i))),h=Yt(d),f=d?function(m){var b=Yt(m*=d)/h,p=Yt(d-m)/h,y=p*s+b*c,Z=p*l+b*u,v=p*C+b*A;return[Fo(Z,y)*Ni,Fo(v,OI(y*y+Z*Z))*Ni]}:function(){return[i*Ni,n*Ni]};return f.distance=d,f}const A9=e=>e;var _Q=new GI,Pte=new GI,_je,Oje,_te,Ote,cf={point:wn,lineStart:wn,lineEnd:wn,polygonStart:function(){cf.lineStart=nhg,cf.lineEnd=rhg},polygonEnd:function(){cf.lineStart=cf.lineEnd=cf.point=wn,_Q.add(Ug(Pte)),Pte=new GI},result:function(){var e=_Q/2;return _Q=new GI,e}};function nhg(){cf.point=Ihg}function Ihg(e,g){cf.point=Jje,_je=_te=e,Oje=Ote=g}function Jje(e,g){Pte.add(Ote*e-_te*g),_te=e,Ote=g}function rhg(){Jje(_je,Oje)}const qVe=cf;var Xw=1/0,EE=Xw,l9=-Xw,DE=l9,ohg={point:Chg,lineStart:wn,lineEnd:wn,polygonStart:wn,polygonEnd:wn,result:function(){var e=[[Xw,EE],[l9,DE]];return l9=DE=-(EE=Xw=1/0),e}};function Chg(e,g){el9&&(l9=e),gDE&&(DE=g)}const ME=ohg;var Jte=0,Lte=0,zV=0,zE=0,PE=0,bv=0,Ute=0,Qte=0,PV=0,Lje,Uje,Ll,Ul,dA={point:ry,lineStart:e2e,lineEnd:t2e,polygonStart:function(){dA.lineStart=Ahg,dA.lineEnd=lhg},polygonEnd:function(){dA.point=ry,dA.lineStart=e2e,dA.lineEnd=t2e},result:function(){var e=PV?[Ute/PV,Qte/PV]:bv?[zE/bv,PE/bv]:zV?[Jte/zV,Lte/zV]:[NaN,NaN];return Jte=Lte=zV=zE=PE=bv=Ute=Qte=PV=0,e}};function ry(e,g){Jte+=e,Lte+=g,++zV}function e2e(){dA.point=ahg}function ahg(e,g){dA.point=shg,ry(Ll=e,Ul=g)}function shg(e,g){var i=e-Ll,n=g-Ul,I=OI(i*i+n*n);zE+=I*(Ll+e)/2,PE+=I*(Ul+g)/2,bv+=I,ry(Ll=e,Ul=g)}function t2e(){dA.point=ry}function Ahg(){dA.point=chg}function lhg(){Qje(Lje,Uje)}function chg(e,g){dA.point=Qje,ry(Lje=Ll=e,Uje=Ul=g)}function Qje(e,g){var i=e-Ll,n=g-Ul,I=OI(i*i+n*n);zE+=I*(Ll+e)/2,PE+=I*(Ul+g)/2,bv+=I,I=Ul*e-Ll*g,Ute+=I*(Ll+e),Qte+=I*(Ul+g),PV+=I*3,ry(Ll=e,Ul=g)}const g2e=dA;function jje(e){this._context=e}jje.prototype={_radius:4.5,pointRadius:function(e){return this._radius=e,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(e,g){switch(this._point){case 0:{this._context.moveTo(e,g),this._point=1;break}case 1:{this._context.lineTo(e,g);break}default:{this._context.moveTo(e+this._radius,g),this._context.arc(e,g,this._radius,0,xo);break}}},result:wn};var jte=new GI,OQ,$je,qje,_V,OV,_E={point:wn,lineStart:function(){_E.point=uhg},lineEnd:function(){OQ&&e4e($je,qje),_E.point=wn},polygonStart:function(){OQ=!0},polygonEnd:function(){OQ=null},result:function(){var e=+jte;return jte=new GI,e}};function uhg(e,g){_E.point=e4e,$je=_V=e,qje=OV=g}function e4e(e,g){_V-=e,OV-=g,jte.add(OI(_V*_V+OV*OV)),_V=e,OV=g}const i2e=_E;function t4e(){this._string=[]}t4e.prototype={_radius:4.5,_circle:n2e(4.5),pointRadius:function(e){return(e=+e)!==this._radius&&(this._radius=e,this._circle=null),this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._string.push("Z"),this._point=NaN},point:function(e,g){switch(this._point){case 0:{this._string.push("M",e,",",g),this._point=1;break}case 1:{this._string.push("L",e,",",g);break}default:{this._circle==null&&(this._circle=n2e(this._radius)),this._string.push("M",e,",",g,this._circle);break}}},result:function(){if(this._string.length){var e=this._string.join("");return this._string=[],e}else return null}};function n2e(e){return"m0,"+e+"a"+e+","+e+" 0 1,1 0,"+-2*e+"a"+e+","+e+" 0 1,1 0,"+2*e+"z"}function dhg(e,g){var i=4.5,n,I;function r(o){return o&&(typeof i=="function"&&I.pointRadius(+i.apply(this,arguments)),uA(o,n(I))),I.result()}return r.area=function(o){return uA(o,n(qVe)),qVe.result()},r.measure=function(o){return uA(o,n(i2e)),i2e.result()},r.bounds=function(o){return uA(o,n(ME)),ME.result()},r.centroid=function(o){return uA(o,n(g2e)),g2e.result()},r.projection=function(o){return arguments.length?(n=o==null?(e=null,A9):(e=o).stream,r):e},r.context=function(o){return arguments.length?(I=o==null?(g=null,new t4e):new jje(g=o),typeof i!="function"&&I.pointRadius(i),r):g},r.pointRadius=function(o){return arguments.length?(i=typeof o=="function"?o:(I.pointRadius(+o),+o),r):i},r.projection(e).context(g)}function hhg(e){return{stream:rH(e)}}function rH(e){return function(g){var i=new $te;for(var n in e)i[n]=e[n];return i.stream=g,i}}function $te(){}$te.prototype={constructor:$te,point:function(e,g){this.stream.point(e,g)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function bAe(e,g,i){var n=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),n!=null&&e.clipExtent(null),uA(i,e.stream(ME)),g(ME.result()),n!=null&&e.clipExtent(n),e}function m_(e,g,i){return bAe(e,function(n){var I=g[1][0]-g[0][0],r=g[1][1]-g[0][1],o=Math.min(I/(n[1][0]-n[0][0]),r/(n[1][1]-n[0][1])),C=+g[0][0]+(I-o*(n[1][0]+n[0][0]))/2,a=+g[0][1]+(r-o*(n[1][1]+n[0][1]))/2;e.scale(150*o).translate([C,a])},i)}function yAe(e,g,i){return m_(e,[[0,0],g],i)}function ZAe(e,g,i){return bAe(e,function(n){var I=+g,r=I/(n[1][0]-n[0][0]),o=(I-r*(n[1][0]+n[0][0]))/2,C=-r*n[0][1];e.scale(150*r).translate([o,C])},i)}function GAe(e,g,i){return bAe(e,function(n){var I=+g,r=I/(n[1][1]-n[0][1]),o=-r*n[0][0],C=(I-r*(n[1][1]+n[0][1]))/2;e.scale(150*r).translate([o,C])},i)}var I2e=16,fhg=_t(30*sg);function r2e(e,g){return+g?phg(e,g):mhg(e)}function mhg(e){return rH({point:function(g,i){g=e(g,i),this.stream.point(g[0],g[1])}})}function phg(e,g){function i(n,I,r,o,C,a,A,s,l,c,u,d,h,f){var m=A-n,b=s-I,p=m*m+b*b;if(p>4*g&&h--){var y=o+c,Z=C+u,v=a+d,G=OI(y*y+Z*Z+v*v),B=Eo(v/=G),S=Ug(Ug(v)-1)g||Ug((m*W+b*V)/p-.5)>.3||o*c+C*u+a*d2?X[2]%360*sg:0,W()):[C*Ni,a*Ni,A*Ni]},w.angle=function(X){return arguments.length?(l=X%360*sg,W()):l*Ni},w.reflectX=function(X){return arguments.length?(c=X?-1:1,W()):c<0},w.reflectY=function(X){return arguments.length?(u=X?-1:1,W()):u<0},w.precision=function(X){return arguments.length?(v=r2e(G,Z=X*X),V()):OI(Z)},w.fitExtent=function(X,N){return m_(w,X,N)},w.fitSize=function(X,N){return yAe(w,X,N)},w.fitWidth=function(X,N){return ZAe(w,X,N)},w.fitHeight=function(X,N){return GAe(w,X,N)};function W(){var X=o2e(i,0,0,c,u,l).apply(null,g(r,o)),N=o2e(i,n-X[0],I-X[1],c,u,l);return s=pAe(C,a,A),G=xte(g,N),B=xte(s,G),v=r2e(G,Z),V()}function V(){return S=R=null,w}return function(){return g=e.apply(this,arguments),w.invert=g.invert&&T,W()}}function BAe(e){var g=0,i=Wg/3,n=vAe(e),I=n(g,i);return I.parallels=function(r){return arguments.length?n(g=r[0]*sg,i=r[1]*sg):[g*Ni,i*Ni]},I}function Ghg(e){var g=_t(e);function i(n,I){return[n*g,Yt(I)/g]}return i.invert=function(n,I){return[n/g,Eo(I*g)]},i}function g4e(e,g){var i=Yt(e),n=(i+Yt(g))/2;if(Ug(n)=.12&&f<.234&&h>=-.425&&h<-.214?I:f>=.166&&f<.234&&h>=-.214&&h<-.115?o:i).invert(c)},s.stream=function(c){return e&&g===c?e:e=vhg([i.stream(g=c),I.stream(c),o.stream(c)])},s.precision=function(c){return arguments.length?(i.precision(c),I.precision(c),o.precision(c),l()):i.precision()},s.scale=function(c){return arguments.length?(i.scale(c),I.scale(c*.35),o.scale(c),s.translate(i.translate())):i.scale()},s.translate=function(c){if(!arguments.length)return i.translate();var u=i.scale(),d=+c[0],h=+c[1];return n=i.translate(c).clipExtent([[d-.455*u,h-.238*u],[d+.455*u,h+.238*u]]).stream(A),r=I.translate([d-.307*u,h+.201*u]).clipExtent([[d-.425*u+rg,h+.12*u+rg],[d-.214*u-rg,h+.234*u-rg]]).stream(A),C=o.translate([d-.205*u,h+.212*u]).clipExtent([[d-.214*u+rg,h+.166*u+rg],[d-.115*u-rg,h+.234*u-rg]]).stream(A),l()},s.fitExtent=function(c,u){return m_(s,c,u)},s.fitSize=function(c,u){return yAe(s,c,u)},s.fitWidth=function(c,u){return ZAe(s,c,u)},s.fitHeight=function(c,u){return GAe(s,c,u)};function l(){return e=g=null,s}return s.scale(1070)}function n4e(e){return function(g,i){var n=_t(g),I=_t(i),r=e(n*I);return r===1/0?[2,0]:[r*I*Yt(g),r*Yt(i)]}}function oH(e){return function(g,i){var n=OI(g*g+i*i),I=e(n),r=Yt(I),o=_t(I);return[Fo(g*r,n*o),Eo(n&&i*r/n)]}}var wAe=n4e(function(e){return OI(2/(1+e))});wAe.invert=oH(function(e){return 2*Eo(e/2)});function whg(){return $c(wAe).scale(124.75).clipAngle(180-.001)}var SAe=n4e(function(e){return(e=vje(e))&&e/Yt(e)});SAe.invert=oH(function(e){return e});function Shg(){return $c(SAe).scale(79.4188).clipAngle(180-.001)}function CH(e,g){return[e,BE(fAe((Yn+g)/2))]}CH.invert=function(e,g){return[e,2*gS(Gje(g))-Yn]};function Rhg(){return I4e(CH).scale(961/xo)}function I4e(e){var g=$c(e),i=g.center,n=g.scale,I=g.translate,r=g.clipExtent,o=null,C,a,A;g.scale=function(l){return arguments.length?(n(l),s()):n()},g.translate=function(l){return arguments.length?(I(l),s()):I()},g.center=function(l){return arguments.length?(i(l),s()):i()},g.clipExtent=function(l){return arguments.length?(l==null?o=C=a=A=null:(o=+l[0][0],C=+l[0][1],a=+l[1][0],A=+l[1][1]),s()):o==null?null:[[o,C],[a,A]]};function s(){var l=Wg*n(),c=g(kje(g.rotate()).invert([0,0]));return r(o==null?[[c[0]-l,c[1]-l],[c[0]+l,c[1]+l]]:e===CH?[[Math.max(c[0]-l,o),C],[Math.min(c[0]+l,a),A]]:[[o,Math.max(c[1]-l,C)],[a,Math.min(c[1]+l,A)]])}return s()}function aY(e){return fAe((Yn+e)/2)}function r4e(e,g){var i=_t(e),n=e===g?Yt(e):BE(i/_t(g))/BE(aY(g)/aY(e)),I=i*MQ(aY(e),n)/n;if(!n)return CH;function r(o,C){I>0?C<-Yn+rg&&(C=-Yn+rg):C>Yn-rg&&(C=Yn-rg);var a=I/MQ(aY(C),n);return[a*Yt(n*o),I-a*_t(n*o)]}return r.invert=function(o,C){var a=I-C,A=qa(n)*OI(o*o+a*a),s=Fo(o,Ug(a))*qa(a);return a*n<0&&(s-=Wg*qa(o)*qa(a)),[s/n,2*gS(MQ(I/A,1/n))-Yn]},r}function Vhg(){return BAe(r4e).scale(109.5).parallels([30,30])}function c9(e,g){return[e,g]}c9.invert=c9;function Whg(){return $c(c9).scale(152.63)}function o4e(e,g){var i=_t(e),n=e===g?Yt(e):(i-_t(g))/(g-e),I=i/n+e;if(Ug(n)rg&&--n>0);return[e/(.8707+(r=i*i)*(-.131979+r*(-.013791+r*r*r*(.003971-.001529*r)))),i]};function Yhg(){return $c(WAe).scale(175.295)}function XAe(e,g){return[_t(g)*Yt(e),Yt(g)]}XAe.invert=oH(Eo);function Khg(){return $c(XAe).scale(249.5).clipAngle(90+rg)}function TAe(e,g){var i=_t(g),n=1+_t(e)*i;return[i*Yt(e)/n,Yt(g)/n]}TAe.invert=oH(function(e){return 2*gS(e)});function xhg(){return $c(TAe).scale(250).clipAngle(142)}function HAe(e,g){return[BE(fAe((Yn+g)/2)),-e]}HAe.invert=function(e,g){return[-g,2*gS(Gje(e))-Yn]};function Fhg(){var e=I4e(HAe),g=e.center,i=e.rotate;return e.center=function(n){return arguments.length?g([-n[1],n[0]]):(n=g(),[n[1],-n[0]])},e.rotate=function(n){return arguments.length?i([n[0],n[1],n.length>2?n[2]+90:90]):(n=i(),[n[0],n[1],n[2]-90])},i([0,0,90]).scale(159.155)}const Ehg=Object.freeze(Object.defineProperty({__proto__:null,geoAlbers:i4e,geoAlbersUsa:Bhg,geoArea:Wdg,geoAzimuthalEqualArea:whg,geoAzimuthalEqualAreaRaw:wAe,geoAzimuthalEquidistant:Shg,geoAzimuthalEquidistantRaw:SAe,geoBounds:Ndg,geoCentroid:Edg,geoCircle:Ddg,geoClipAntimeridian:Ete,geoClipCircle:Dje,geoClipExtent:Ldg,geoClipRectangle:f_,geoConicConformal:Vhg,geoConicConformalRaw:r4e,geoConicEqualArea:OE,geoConicEqualAreaRaw:g4e,geoConicEquidistant:Xhg,geoConicEquidistantRaw:o4e,geoContains:thg,geoDistance:xE,geoEqualEarth:Hhg,geoEqualEarthRaw:RAe,geoEquirectangular:Whg,geoEquirectangularRaw:c9,geoGnomonic:Nhg,geoGnomonicRaw:VAe,geoGraticule:Pje,geoGraticule10:ghg,geoIdentity:khg,geoInterpolate:ihg,geoLength:Mje,geoMercator:Rhg,geoMercatorRaw:CH,geoNaturalEarth1:Yhg,geoNaturalEarth1Raw:WAe,geoOrthographic:Khg,geoOrthographicRaw:XAe,geoPath:dhg,geoProjection:$c,geoProjectionMutator:vAe,geoRotation:kje,geoStereographic:xhg,geoStereographicRaw:TAe,geoStream:uA,geoTransform:hhg,geoTransverseMercator:Fhg,geoTransverseMercatorRaw:HAe},Symbol.toStringTag,{value:"Module"}));var Dhg=[].slice,Mhg={};function qte(e){this._size=e,this._call=this._error=null,this._tasks=[],this._data=[],this._waiting=this._active=this._ended=this._start=0}qte.prototype=a4e.prototype={constructor:qte,defer:function(e){if(typeof e!="function")throw new Error("invalid callback");if(this._call)throw new Error("defer after await");if(this._error!=null)return this;var g=Dhg.call(arguments,1);return g.push(e),++this._waiting,this._tasks.push(g),C4e(this),this},abort:function(){return this._error==null&&NAe(this,new Error("abort")),this},await:function(e){if(typeof e!="function")throw new Error("invalid callback");if(this._call)throw new Error("multiple await");return this._call=function(g,i){e.apply(null,[g].concat(i))},LE(this),this},awaitAll:function(e){if(typeof e!="function")throw new Error("invalid callback");if(this._call)throw new Error("multiple await");return this._call=e,LE(this),this}};function C4e(e){if(!e._start)try{zhg(e)}catch(g){if(e._tasks[e._ended+e._active-1])NAe(e,g);else if(!e._data)throw g}}function zhg(e){for(;e._start=e._waiting&&e._active=0;)if((n=e._tasks[i])&&(e._tasks[i]=null,n.abort))try{n.abort()}catch{}e._active=NaN,LE(e)}function LE(e){if(!e._active&&e._call){var g=e._data;e._data=void 0,e._call(e._error,g)}}function a4e(e){if(e==null)e=1/0;else if(!((e=+e)>=1))throw new Error("invalid concurrency");return new qte(e)}const _hg=Object.freeze(Object.defineProperty({__proto__:null,queue:a4e},Symbol.toStringTag,{value:"Module"}));var Ha="$";function UE(){}UE.prototype=kAe.prototype={constructor:UE,has:function(e){return Ha+e in this},get:function(e){return this[Ha+e]},set:function(e,g){return this[Ha+e]=g,this},remove:function(e){var g=Ha+e;return g in this&&delete this[g]},clear:function(){for(var e in this)e[0]===Ha&&delete this[e]},keys:function(){var e=[];for(var g in this)g[0]===Ha&&e.push(g.slice(1));return e},values:function(){var e=[];for(var g in this)g[0]===Ha&&e.push(this[g]);return e},entries:function(){var e=[];for(var g in this)g[0]===Ha&&e.push({key:g.slice(1),value:this[g]});return e},size:function(){var e=0;for(var g in this)g[0]===Ha&&++e;return e},empty:function(){for(var e in this)if(e[0]===Ha)return!1;return!0},each:function(e){for(var g in this)g[0]===Ha&&e(this[g],g.slice(1),this)}};function kAe(e,g){var i=new UE;if(e instanceof UE)e.each(function(C,a){i.set(a,C)});else if(Array.isArray(e)){var n=-1,I=e.length,r;if(g==null)for(;++n=0&&(n=i.slice(I+1),i=i.slice(0,I)),i&&!g.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:n}})}S5.prototype=s4e.prototype={constructor:S5,on:function(e,g){var i=this._,n=Jhg(e+"",i),I,r=-1,o=n.length;if(arguments.length<2){for(;++r0)for(var i=new Array(I),n=0,I,r;n3&&c(u)};function c(u){var d=o.status,h;if(!d&&Qhg(o)||d>=200&&d<300||d===304){if(A)try{h=A.call(i,o)}catch(f){n.call("error",i,f);return}else h=o;n.call("load",i,h)}else n.call("error",i,u)}if(o.onprogress=function(u){n.call("progress",i,u)},i={header:function(u,d){return u=(u+"").toLowerCase(),arguments.length<2?r.get(u):(d==null?r.remove(u):r.set(u,d+""),i)},mimeType:function(u){return arguments.length?(I=u==null?null:u+"",i):I},responseType:function(u){return arguments.length?(s=u,i):s},timeout:function(u){return arguments.length?(l=+u,i):l},user:function(u){return arguments.length<1?C:(C=u==null?null:u+"",i)},password:function(u){return arguments.length<1?a:(a=u==null?null:u+"",i)},response:function(u){return A=u,i},get:function(u,d){return i.send("GET",u,d)},post:function(u,d){return i.send("POST",u,d)},send:function(u,d,h){return o.open(u,e,!0,C,a),I!=null&&!r.has("accept")&&r.set("accept",I+",*/*"),o.setRequestHeader&&r.each(function(f,m){o.setRequestHeader(m,f)}),I!=null&&o.overrideMimeType&&o.overrideMimeType(I),s!=null&&(o.responseType=s),l>0&&(o.timeout=l),h==null&&typeof d=="function"&&(h=d,d=null),h!=null&&h.length===1&&(h=Uhg(h)),h!=null&&i.on("error",h).on("load",function(f){h(null,f)}),n.call("beforesend",i,o),o.send(d??null),i},abort:function(){return o.abort(),i},on:function(){var u=n.on.apply(n,arguments);return u===n?i:u}},g!=null){if(typeof g!="function")throw new Error("invalid callback: "+g);return i.get(g)}return i}function Uhg(e){return function(g,i){e(g==null?i:null)}}function Qhg(e){var g=e.responseType;return g&&g!=="text"?e.response:e.responseText}function p_(e,g){return function(i,n){var I=YAe(i).mimeType(e).response(g);if(n!=null){if(typeof n!="function")throw new Error("invalid callback: "+n);return I.get(n)}return I}}const jhg=p_("text/html",function(e){return document.createRange().createContextualFragment(e.responseText)}),$hg=p_("application/json",function(e){return JSON.parse(e.responseText)}),qhg=p_("text/plain",function(e){return e.responseText}),efg=p_("application/xml",function(e){var g=e.responseXML;if(!g)throw new Error("parse error");return g});var s2e={},JQ={},LQ=34,XR=10,UQ=13;function A4e(e){return new Function("d","return {"+e.map(function(g,i){return JSON.stringify(g)+": d["+i+'] || ""'}).join(",")+"}")}function tfg(e,g){var i=A4e(e);return function(n,I){return g(i(n),I,e)}}function A2e(e){var g=Object.create(null),i=[];return e.forEach(function(n){for(var I in n)I in g||i.push(g[I]=I)}),i}function oC(e,g){var i=e+"",n=i.length;return n9999?"+"+oC(e,6):oC(e,4)}function ifg(e){var g=e.getUTCHours(),i=e.getUTCMinutes(),n=e.getUTCSeconds(),I=e.getUTCMilliseconds();return isNaN(e)?"Invalid Date":gfg(e.getUTCFullYear())+"-"+oC(e.getUTCMonth()+1,2)+"-"+oC(e.getUTCDate(),2)+(I?"T"+oC(g,2)+":"+oC(i,2)+":"+oC(n,2)+"."+oC(I,3)+"Z":n?"T"+oC(g,2)+":"+oC(i,2)+":"+oC(n,2)+"Z":i||g?"T"+oC(g,2)+":"+oC(i,2)+"Z":"")}function l4e(e){var g=new RegExp('["'+e+` +\r]`),i=e.charCodeAt(0);function n(l,c){var u,d,h=I(l,function(f,m){if(u)return u(f,m-1);d=f,u=c?tfg(f,c):A4e(f)});return h.columns=d||[],h}function I(l,c){var u=[],d=l.length,h=0,f=0,m,b=d<=0,p=!1;l.charCodeAt(d-1)===XR&&--d,l.charCodeAt(d-1)===UQ&&--d;function y(){if(b)return JQ;if(p)return p=!1,s2e;var v,G=h,B;if(l.charCodeAt(G)===LQ){for(;h++=d?b=!0:(B=l.charCodeAt(h++))===XR?p=!0:B===UQ&&(p=!0,l.charCodeAt(h)===XR&&++h),l.slice(G+1,v-1).replace(/""/g,'"')}for(;h"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function QE(e){return QE=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},QE(e)}let b_=function(e){hfg(i,e);var g=ffg(i);function i({items:n}){var I;return lfg(this,i),I=g.call(this),I.state={items:n,isSorting:!1},I}return cfg(i,[{key:"UNSAFE_componentWillReceiveProps",value:function(I){this.setState({items:I.items})}},{key:"onSortStart",value:function({node:I,index:r,collection:o},C){C.stopImmediatePropagation();const{onSortStart:a}=this.props;this.setState({isSorting:!0}),a&&a(this.ref),this.sortingIndex=r,this.sortStartTop=C.offsetTop,this.sortStartLeft=C.offsetLeft}},{key:"onSortMove",value:function(){}},{key:"onSortEnd",value:function({oldIndex:I,newIndex:r}){const{onSortEnd:o}=this.props,{items:C}=this.state;this.setState({items:mFt(C,I,r),isSorting:!1}),o&&o(this.state.items),this.sortingIndex=null}},{key:"render",value:function(){const I=this.props.component,{items:r,isSorting:o}=this.state,C={isSorting:o,items:r,onSortEnd:this.onSortEnd.bind(this),onSortStart:this.onSortStart.bind(this),onSortMove:this.onSortMove.bind(this)};return k.createElement(I,ege({},this.props,C,{ref:a=>{this.ref=a}}))}}]),i}(k.Component);b_.propTypes={axis:L.string,className:L.string,component:L.func,editable:L.bool,handleConfigTrack:L.func,handleResizeTrack:L.func,height:L.number,helperClass:L.string,itemClass:L.string,itemControlAlignLeft:L.bool,itemReactClass:L.func,items:L.array,onAddSeries:L.func,onCloseTrack:L.func,onCloseTrackMenuOpened:L.func,onConfigTrackMenuOpened:L.func,onSortEnd:L.func,onSortStart:L.func,referenceAncestor:L.string,resizeHandles:L.object,useDragHandle:L.bool,width:L.number};b_.defaultProps={className:"list stylizedList",itemClass:"item stylizedItem",width:400,height:600};const QQ={"top-right-handle":"_top-right-handle_cizw2_1","bottom-right-handle":"_bottom-right-handle_cizw2_2","top-left-handle":"_top-left-handle_cizw2_7","bottom-left-handle":"_bottom-left-handle_cizw2_8","top-draggable-handle":"_top-draggable-handle_cizw2_13","bottom-draggable-handle":"_bottom-draggable-handle_cizw2_14","left-draggable-handle":"_left-draggable-handle_cizw2_15","right-draggable-handle":"_right-draggable-handle_cizw2_16","draggable-div":"_draggable-div_cizw2_22","top-draggable-handle-grabber":"_top-draggable-handle-grabber_cizw2_27","bottom-draggable-handle-grabber":"_bottom-draggable-handle-grabber_cizw2_28","left-draggable-handle-grabber":"_left-draggable-handle-grabber_cizw2_43","right-draggable-handle-grabber":"_right-draggable-handle-grabber_cizw2_44"};function yfg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function c2e(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function jE(e){return jE=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},jE(e)}let u4e=function(e){Bfg(i,e);var g=wfg(i);function i(n){var I;return yfg(this,i),I=g.call(this,n),I.dragTopRight=Su().on("start",I.dragStart.bind(gr(I))).on("drag",I.dragTopRightFunc.bind(gr(I))),I.dragTopLeft=Su().on("start",I.dragStart.bind(gr(I))).on("drag",I.dragTopLeftFunc.bind(gr(I))),I.dragBottomRight=Su().on("start",I.dragStart.bind(gr(I))).on("drag",I.dragBottomRightFunc.bind(gr(I))),I.dragBottomLeft=Su().on("start",I.dragStart.bind(gr(I))).on("drag",I.dragBottomLeftFunc.bind(gr(I))),I.dragBottom=Su().on("start",I.dragStart.bind(gr(I))).on("drag",I.dragBottomFunc.bind(gr(I))),I.dragTop=Su().on("start",I.dragStart.bind(gr(I))).on("drag",I.dragTopFunc.bind(gr(I))),I.dragLeft=Su().on("start",I.dragStart.bind(gr(I))).on("drag",I.dragLeftFunc.bind(gr(I))),I.dragRight=Su().on("start",I.dragStart.bind(gr(I))).on("drag",I.dragRightFunc.bind(gr(I))),I.minWidth=10,I.minHeight=10,I.bottomHandleWidth=20,I.state={uid:I.props.uid,width:I.props.width,height:I.props.height,top:I.props.top,left:I.props.left},I.domBody=xg("body").node(),I}return Zfg(i,[{key:"componentDidMount",value:function(){xg(this.bottomHandle).call(this.dragBottom),xg(this.topHandle).call(this.dragTop),xg(this.leftHandle).call(this.dragLeft),xg(this.rightHandle).call(this.dragRight)}},{key:"UNSAFE_componentWillReceiveProps",value:function(I){"width"in I&&this.setState({width:I.width}),"height"in I&&this.setState({height:I.height})}},{key:"dragBottomFunc",value:function(I){const r=mi(I,this.domBody);let o=this.dragStartHeight+(r[1]-this.dragStartMousePos[1]);o=o>this.minHeight?o:this.minHeight,this.setState({height:o}),I.sourceEvent.stopPropagation(),this.sizeChanged()}},{key:"dragLeftFunc",value:function(I){const r=mi(I,this.domBody);let o=this.dragStartWidth-(r[0]-this.dragStartMousePos[0]);o=o>this.minWidth?o:this.minWidth;let C=this.dragStartLeft+r[0]-this.dragStartMousePos[0];C=o>this.minWidth?C:this.dragStartLeft+this.dragStartWidth-this.minWidth,this.setState({left:C,width:o}),I.sourceEvent.stopPropagation(),this.sizeChanged()}},{key:"dragTopFunc",value:function(I){const r=mi(I,this.domBody);let o=this.dragStartHeight-(r[1]-this.dragStartMousePos[1]);o=o>this.minHeight?o:this.minHeight;let C=this.dragStartTop+r[1]-this.dragStartMousePos[1];C=o>this.minHeight?C:this.dragStartTop+this.dragStartHeight-this.minHeight,this.setState({top:C,height:o}),I.sourceEvent.stopPropagation(),this.sizeChanged()}},{key:"dragRightFunc",value:function(I){const r=mi(I,this.domBody);let o=this.dragStartWidth+(r[0]-this.dragStartMousePos[0]);o=o>this.minWidth?o:this.minWidth,this.setState({width:o}),I.sourceEvent.stopPropagation(),this.sizeChanged()}},{key:"dragBottomLeftFunc",value:function(I){const r=mi(I,this.domBody);let o=this.dragStartHeight+(r[1]-this.dragStartMousePos[1]);o=o>this.minHeight?o:this.minHeight;let C=this.dragStartWidth-(r[0]-this.dragStartMousePos[0]);C=C>this.minWidth?C:this.minWidth;let a=this.dragStartLeft+r[0]-this.dragStartMousePos[0];a=C>this.minWidth?a:this.dragStartLeft+this.dragStartWidth-this.minWidth,this.setState({left:a,width:C,height:o}),I.sourceEvent.stopPropagation(),this.sizeChanged()}},{key:"dragBottomRightFunc",value:function(I){const r=mi(I,this.domBody);let o=this.dragStartWidth+(r[0]-this.dragStartMousePos[0]);o=o>this.minWidth?o:this.minWidth;let C=this.dragStartHeight+(r[1]-this.dragStartMousePos[1]);C=C>this.minHeight?C:this.minHeight,this.setState({width:o,height:C}),I.sourceEvent.stopPropagation(),this.sizeChanged()}},{key:"dragTopRightFunc",value:function(I){const r=mi(I,this.domBody);let o=this.dragStartHeight-(r[1]-this.dragStartMousePos[1]);o=o>this.minHeight?o:this.minHeight;let C=this.dragStartTop+r[1]-this.dragStartMousePos[1];C=o>this.minHeight?C:this.dragStartTop+this.dragStartHeight-this.minHeight;let a=this.dragStartWidth+(r[0]-this.dragStartMousePos[0]);a=a>this.minWidth?a:this.minWidth,this.setState({top:C,width:a,height:o}),I.sourceEvent.stopPropagation(),this.sizeChanged()}},{key:"dragTopLeftFunc",value:function(I){const r=mi(I,this.domBody);let o=this.dragStartWidth-(r[0]-this.dragStartMousePos[0]);o=o>this.minWidth?o:this.minWidth;let C=this.dragStartLeft+r[0]-this.dragStartMousePos[0];C=o>this.minWidth?C:this.dragStartLeft+this.dragStartWidth-this.minWidth;let a=this.dragStartHeight-(r[1]-this.dragStartMousePos[1]);a=a>this.minHeight?a:this.minHeight;let A=this.dragStartTop+r[1]-this.dragStartMousePos[1];A=a>this.minHeight?A:this.dragStartTop+this.dragStartHeight-this.minHeight,this.setState({top:A,left:C,width:o,height:a}),I.sourceEvent.stopPropagation(),this.sizeChanged()}},{key:"dragStart",value:function(I){this.dragStartMousePos=mi(I,this.domBody),this.dragStartWidth=this.state.width,this.dragStartHeight=this.state.height,this.dragStartTop=this.state.top,this.dragStartLeft=this.state.left,I.sourceEvent.stopPropagation()}},{key:"sizeChanged",value:function(){this.props.sizeChanged&&this.props.sizeChanged(this.state)}},{key:"rotateClicked",value:function(){this.props.trackRotated(this.state.uid)}},{key:"closeClicked",value:function(){this.props.trackClosed(this.state.uid)}},{key:"render",value:function(){const I=this.props.theme===ki?"white":"black",r={top:this.state.top,left:this.state.left,width:this.state.width,height:this.state.height,opacity:this.props.opacity},o=24,C=24,a={left:this.state.width/2-o/2,width:o},A={top:this.state.height/2-C/2,height:C},s={bottom:{...a,bottom:1},top:{...a,top:1},left:{...A,left:1},right:{...A,right:1}},l=[...this.props.resizeHandles].map(c=>k.createElement("div",{key:c,ref:u=>{this[`${c}Handle`]=u},className:QQ[`${c}-draggable-handle`],style:s[c],title:"Resize track"},k.createElement("div",{className:QQ[`${c}-draggable-handle-grabber`],style:{borderColor:I}})));return k.createElement("div",{ref:c=>{this.divContainer=c},className:gi(this.props.className,QQ["draggable-div"]),style:r},l)}}]),i}(k.Component);u4e.propTypes={className:L.string,height:L.number,left:L.number,opacity:L.number,resizeHandles:L.object,sizeChanged:L.func,top:L.number,trackClosed:L.func,trackRotated:L.func,uid:L.string,width:L.number,theme:L.symbol};const Vfg=iZ(u4e);function Wfg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function u2e(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function $E(e){return $E=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},$E(e)}let d4e=function(e){Nfg(i,e);var g=kfg(i);function i(n){var I;return Wfg(this,i),I=g.call(this,n),I.state={controlsVisible:!1},I}return Xfg(i,[{key:"shouldComponentUpdate",value:function(){return!this.resizing}},{key:"handleMouseEnter",value:function(){this.setState({controlsVisible:!0})}},{key:"handleMouseLeave",value:function(){this.setState({controlsVisible:!1})}},{key:"handleMouseMove",value:function(){this.setState({controlsVisible:!0})}},{key:"getControls",value:function(){let I=null;return this.moveable?I=fq(()=>k.createElement("svg",{className:"no-zoom",height:"10px",onClick:()=>{},style:this.getMoveImgStyle(),width:"10px"},k.createElement("use",{xlinkHref:"#move"}))):I=fq(()=>k.createElement("div",null)),k.createElement("div",{style:{position:"absolute",backgroundColor:"rgba(255,255,255,0.7)",right:"3px",top:"3px",pointerEvents:"none",paddingLeft:"5px",paddingRight:"5px",borderRadius:"5px",border:"1px solid #dddddd"}},k.createElement(I,null),k.createElement("svg",{ref:r=>{this.imgConfig=r},className:"no-zoom",height:"10px",onClick:()=>{const o=_I.findDOMNode(this.imgConfig).getBoundingClientRect();this.props.onConfigTrackMenuOpened(this.props.uid,o)},style:this.getSettingsImgStyle(),width:"10px"},k.createElement("use",{xlinkHref:"#cog"})),k.createElement("svg",{ref:r=>{this.imgAdd=r},className:"no-zoom",height:"10px",onClick:()=>this.props.onAddSeries(this.props.uid),style:this.getAddImgStyle(),width:"10px"},k.createElement("use",{xlinkHref:"#plus"})),k.createElement("svg",{ref:r=>{this.imgClose=r},className:"no-zoom",height:"10px",onClick:()=>{const o=_I.findDOMNode(this.imgClose).getBoundingClientRect();this.props.onCloseTrackMenuOpened(this.props.uid,o)},style:this.getCloseImgStyle(),width:"10px"},k.createElement("use",{xlinkHref:"#cross"})))}}]),i}(k.Component);d4e.propTypes={configMenuOpen:L.bool,onConfigTrackMenuOpened:L.func,onCloseTrackMenuOpened:L.func,onAddSeries:L.func,uid:L.string};function Ffg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function d2e(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function qE(e){return qE=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},qE(e)}let y_=function(e){zfg(i,e);var g=Pfg(i);function i(n){var I;return Ffg(this,i),I=g.call(this,n),I.moveable=!0,I}return Efg(i,[{key:"render",value:function(){return k.createElement("div",{ref:I=>{this.el=I},className:this.props.className,onMouseEnter:this.handleMouseEnter.bind(this),onMouseLeave:()=>{this.handleMouseLeave()},style:{height:this.props.height,width:this.props.width}},k.createElement(Vfg,{key:this.props.uid,height:this.props.height,resizeHandles:this.props.editable?this.props.resizeHandles:new Set,sizeChanged:I=>this.props.handleResizeTrack(this.props.uid,I.width,I.height),style:{background:"transparent"},uid:this.props.uid,width:this.props.width}),this.props.editable&&this.getControls(this.state.controlsVisible||this.props.item.configMenuVisible))}}]),i}(d4e);y_.propTypes={className:L.string,uid:L.string,item:L.object,height:L.number,width:L.number};function Lfg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function h2e(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function eD(e){return eD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},eD(e)}const sY={pointerEvents:"all"};let h4e=function(e){$fg(i,e);var g=qfg(i);function i(){return Lfg(this,i),g.apply(this,arguments)}return Ufg(i,[{key:"getControls",value:function(I){return k.createElement(r_,{configMenuVisible:this.props.item.configMenuVisible,imgStyleAdd:sY,imgStyleClose:sY,imgStyleMove:sY,imgStyleSettings:sY,isMoveable:this.moveable,isVisible:I,onAddSeries:this.props.onAddSeries,onCloseTrackMenuOpened:this.props.onCloseTrackMenuOpened,onConfigTrackMenuOpened:this.props.onConfigTrackMenuOpened,uid:this.props.uid})}}]),i}(y_);const img=wPe(e=>k.createElement(h4e,{className:e.className,editable:e.editable,handleConfigTrack:e.handleConfigTrack,handleResizeTrack:e.handleResizeTrack,height:e.height,item:e.item,onAddSeries:e.onAddSeries,onCloseTrack:e.onCloseTrack,onCloseTrackMenuOpened:e.onCloseTrackMenuOpened,onConfigTrackMenuOpened:e.onConfigTrackMenuOpened,resizeHandles:e.resizeHandles,uid:e.uid,width:e.width}));function rge(){return rge=Object.assign?Object.assign.bind():function(e){for(var g=1;g{const b=g.map((p,y)=>k.createElement(h,{key:`sci-${p.uid}`,className:i,controlAlignLeft:n,sortingIndex:I,index:y,uid:p.uid,height:p.height,width:p.width,item:p,useDragHandle:r,onCloseTrack:A,onCloseTrackMenuOpened:s,onConfigTrackMenuOpened:l,onAddSeries:c,handleConfigTrack:u,editable:d,handleResizeTrack:f,resizeHandles:m}));return k.createElement("div",rge({className:e,style:{height:C,width:a,background:"transparent"}},o),b)}),nmg={"horizontal-tiled-plot":"_horizontal-tiled-plot_1bqkg_1"};function Img(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function f2e(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function tD(e){return tD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},tD(e)}function m2e(e){return e&&e.sourceEvent}let gD=function(e){amg(i,e);var g=smg(i);function i(n){var I;return Img(this,i),I=g.call(this,n),I.brushBehavior=lP().on("start",I.brushStarted.bind(R5(I))).on("brush",I.brushed.bind(R5(I))).on("end",I.brushedEnded.bind(R5(I))),I}return rmg(i,[{key:"componentDidMount",value:function(){this.props.isRangeSelectionActive&&this.addBrush()}},{key:"shouldComponentUpdate",value:function(I,r){return this.rangeSelectionTriggered?(this.rangeSelectionTriggered=!1,this.rangeSelectionTriggeredEnd&&this.props.rangeSelection!==I.rangeSelection&&this.moveBrush(I.rangeSelection[0]?I.rangeSelection[0]:null,!0),this.rangeSelectionTriggeredEnd=!1,this.state!==r):this.props.rangeSelection!==I.rangeSelection?(this.moveBrush(I.rangeSelection[0]?I.rangeSelection[0]:null,I.rangeSelectionEnd),this.state!==r):!0}},{key:"componentDidUpdate",value:function(){this.props.isRangeSelectionActive?this.addBrush():this.removeBrush()}},{key:"addBrush",value:function(){!this.brushEl||this.brushElAddedBefore===this.brushEl||(this.brushElAddedBefore&&this.brushElAddedBefore.on(".brush",null),this.brushEl.call(this.brushBehavior),this.brushElAddedBefore=this.brushEl,Ov(this.brushEl,CA["track-range-selection-group-brush-selection"]))}},{key:"brushed",value:function(I){const r=this.rangeSelectionMoved;this.rangeSelectionMoved=!1,!(!m2e(I)||!this.props.onRangeSelection||r)&&(this.rangeSelectionTriggered=!0,this.props.onRangeSelection(I.selection))}},{key:"brushStarted",value:function(I){!m2e(I)||!I.selection||this.props.onRangeSelectionStart()}},{key:"brushedEnded",value:function(I){if(!this.props.is1dRangeSelection)return;const r=this.rangeSelectionMovedEnd;this.rangeSelectionMovedEnd=!1,I.selection&&I.sourceEvent&&this.props.onRangeSelection&&!r&&(this.rangeSelectionTriggered=!0,this.rangeSelectionTriggeredEnd=!0,this.props.onRangeSelectionEnd(I.selection)),I.selection||(this.rangeSelectionTriggered=!0,this.props.onRangeSelectionReset())}},{key:"moveBrush",value:function(I,r=!1){if(!this.brushEl)return;const o=I?[this.props.scale(I[0]),this.props.scale(I[1])]:null;this.rangeSelectionMoved=!0,this.rangeSelectionMovedEnd=!0,r?this.brushEl.transition().call(this.brushBehavior.move,o):this.brushEl.call(this.brushBehavior.move,o)}},{key:"removeBrush",value:function(){this.brushElAddedBefore&&(this.brushElAddedBefore.call(this.brushBehavior.move,null),this.brushElAddedBefore.on(".brush",null),this.brushElAddedBefore=void 0,this.props.onRangeSelectionReset())}},{key:"render",value:function(){const I=this.props.tracks.map(C=>C.height).reduce(of,0),r=this.props.tracks.map(C=>N1(C)).reduce(kT,!1),o=this.props.isRangeSelectionActive?CA["track-range-selection-active"]:CA["track-range-selection"];return k.createElement("div",{className:gi("horizontal-tiled-plot",nmg["horizontal-tiled-plot"])},r&&k.createElement("svg",{ref:C=>{this.brushEl=xg(C)},className:o,style:{height:I,width:this.props.width},xmlns:"http://www.w3.org/2000/svg"}),k.createElement(b_,{className:gi(aA.list,aA.stylizedList),component:f4e,editable:this.props.editable,handleConfigTrack:this.props.handleConfigTrack,handleResizeTrack:this.props.handleResizeTrack,height:I,helperClass:aA.stylizedHelper,itemClass:aA.stylizedItem,itemReactClass:img,items:this.props.tracks.map(C=>({configMenuVisible:C.uid===this.props.configTrackMenuId,uid:C.uid||Ng.nice(),width:this.props.width,height:C.height,value:C.value})),onAddSeries:this.props.onAddSeries,onCloseTrack:this.props.onCloseTrack,onCloseTrackMenuOpened:this.props.onCloseTrackMenuOpened,onConfigTrackMenuOpened:this.props.onConfigTrackMenuOpened,onSortEnd:this.props.handleSortEnd,referenceAncestor:this.props.referenceAncestor,resizeHandles:this.props.resizeHandles,useDragHandle:!0,width:this.props.width}))}}]),i}(k.Component);gD.propTypes={configTrackMenuId:L.string,editable:L.bool,handleConfigTrack:L.func,handleResizeTrack:L.func,handleSortEnd:L.func,is1dRangeSelection:L.bool,isRangeSelectionActive:L.bool,onAddSeries:L.func,onCloseTrack:L.func,onCloseTrackMenuOpened:L.func,onConfigTrackMenuOpened:L.func,onRangeSelection:L.func,onRangeSelectionEnd:L.func,onRangeSelectionReset:L.func,onRangeSelectionStart:L.func,rangeSelection:L.array,rangeSelectionEnd:L.bool,referenceAncestor:L.func,resizeHandles:L.object,scale:L.func,tracks:L.array,width:L.number};function cmg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function p2e(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function iD(e){return iD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},iD(e)}const AY={pointerEvents:"all"};let m4e=function(e){fmg(i,e);var g=mmg(i);function i(){return cmg(this,i),g.apply(this,arguments)}return umg(i,[{key:"getControls",value:function(I){return k.createElement(r_,{imgStyleAdd:AY,imgStyleClose:AY,imgStyleMove:AY,imgStyleSettings:AY,isAlignLeft:this.props.controlAlignLeft,isMoveable:this.moveable,isVertical:!0,isVisible:I,onAddSeries:this.props.onAddSeries,onCloseTrackMenuOpened:this.props.onCloseTrackMenuOpened,onConfigTrackMenuOpened:this.props.onConfigTrackMenuOpened,uid:this.props.uid})}}]),i}(y_);function Zmg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function b2e(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Tw(e){return Tw=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},Tw(e)}let Xmg=function(e){Smg(i,e);var g=Rmg(i);function i(n,I){var r;Zmg(this,i),r=g.call(this,n,I);const{registerViewportChanged:o,removeViewportChanged:C}=n,a=Ng.nice();return r.uid=a,r.removeViewportChanged=C,r.viewportXDomain=null,r.viewportYDomain=null,o(a,r.viewportChanged.bind(p4e(r))),r}return Gmg(i,[{key:"viewportChanged",value:function(I,r){const o=I.domain(),C=r.domain();this.viewportXDomain=o,this.viewportYDomain=C,this.draw()}},{key:"draw",value:function(){const I=this.pMain;if(!this.viewportXDomain||!this.viewportYDomain)return;I.clear(),I.lineStyle(1,255,1),I.beginFill(16740363,1);const r=this._xScale(this.viewportXDomain[0]),o=this._yScale(this.viewportYDomain[0]),C=this._xScale(this.viewportXDomain[1])-this._xScale(this.viewportXDomain[0]),a=this._yScale(this.viewportYDomain[1])-this._yScale(this.viewportYDomain[0]);this.pMain.drawRect(r,o,C,a)}},{key:"zoomed",value:function(I,r){this.xScale(I),this.yScale(r),this.draw()}},{key:"setPosition",value:function(I){V5(Tw(i.prototype),"setPosition",this).call(this,I),this.pMain.position.y=this.position[1],this.pMain.position.x=this.position[0],this.draw()}}]),i}(Lo);function b4e(e){this.size=0,this.limit=e,this._keymap={}}function Tmg(e,g){const i={key:e,value:g};if(this._keymap[e]=i,this.tail?(this.tail.newer=i,i.older=this.tail):this.head=i,this.tail=i,this.size===this.limit)return this.shift();this.size+=1}function Hmg(){const e=this.head;return e&&(this.head.newer?(this.head=this.head.newer,this.head.older=void 0):(this.head=void 0,this.tail=void 0),e.newer=void 0,e.older=void 0,delete this._keymap[e.key],this.size-=1),e}function Nmg(e,g){const i=this._keymap[e];if(i!==void 0)return i===this.tail||(i.newer&&(i===this.head&&(this.head=i.newer),i.newer.older=i.older),i.older&&(i.older.newer=i.newer),i.newer=void 0,i.older=this.tail,this.tail&&(this.tail.newer=i),this.tail=i),g?i:i.value}function kmg(e){return this._keymap[e]}function Ymg(e,g){const i=this.get(e,!0);let n;return i?(n=i.value,i.value=g):(n=this.put(e,g),n&&(n=n.value)),n}function Kmg(e){const g=this._keymap[e];if(g)return delete this._keymap[g.key],g.newer&&g.older?(g.older.newer=g.newer,g.newer.older=g.older):g.newer?(g.newer.older=void 0,this.head=g.newer):g.older?(g.older.newer=void 0,this.tail=g.older):(this.head=void 0,this.tail=void 0),this.size-=1,g.value}function xmg(){this.head=void 0,this.tail=void 0,this.size=0,this._keymap={}}function Fmg(){return Object.keys(this._keymap)}function Emg(e,g,i){let n;if(g===!0?(i=!0,g=void 0):typeof g!="object"&&(g=this),i)for(n=this.tail;n;)e.call(g,n.key,n.value,this),n=n.older;else for(n=this.head;n;)e.call(g,n.key,n.value,this),n=n.newer}function Dmg(){const e=[];let g=this.head;for(;g;)e.push({key:g.key.toJSON(),value:g.value.toJSON()}),g=g.newer;return e}function Mmg(){let e="",g=this.head;for(;g;)e+=`${String(g.key)}:${g.value}`,g=g.newer,g&&(e+=" < ");return e}Object.assign(b4e.prototype,{put:Tmg,get:Nmg,find:kmg,keys:Fmg,set:Ymg,shift:Hmg,remove:Kmg,removeAll:xmg,forEach:Emg,toJSON:Dmg,toString:Mmg});const y4e="1.13.4",zmg="_button_1wnjn_1",jQ={button:zmg,"button-shortcut":"_button-shortcut_1wnjn_35"},fd=k.forwardRef((e,g)=>k.createElement("button",{ref:g,className:jQ[e.styleName]??jQ.button,disabled:e.disable,onBlur:e.onBlur,onClick:e.onClick,onMouseDown:e.onMouseDown,onMouseOut:e.onMouseOut,onMouseUp:e.onMouseUp,type:"button"},e.children,e.shortcut&&k.createElement("span",{className:jQ["button-shortcut"]},e.shortcut)));fd.defaultProps={onClick:()=>{},styleName:"",type:"button"};fd.propTypes={children:L.any,disable:L.bool,onBlur:L.func,onClick:L.func,onMouseDown:L.func,onMouseOut:L.func,onMouseUp:L.func,shortcut:L.string,type:L.string,styleName:L.string};const Pmg="_cross_2ke8w_1",_mg={cross:Pmg};function Z4e(){return k.createElement("div",{className:_mg.cross})}function sge(){return sge=Object.assign?Object.assign.bind():function(e){for(var g=1;gk.forwardRef((g,i)=>k.createElement(Jmg,null,n=>k.createElement(e,sge({ref:i},g,{modal:n})))),CG={"modal-background":"_modal-background_zzhoe_1","fade-in":"_fade-in_zzhoe_1","modal-hide":"_modal-hide_zzhoe_13","modal-wrap":"_modal-wrap_zzhoe_17","modal-window":"_modal-window_zzhoe_25","fade-scale-in":"_fade-scale-in_zzhoe_1","modal-window-max-height":"_modal-window-max-height_zzhoe_38","modal-content":"_modal-content_zzhoe_42"};function KAe(e){const g=()=>{e.modal.close(),e.onClose&&e.onClose()};return k.createElement("div",{className:gi(CG["modal-background"],{[CG["modal-hide"]]:e.hide})},k.createElement("div",{className:CG["modal-wrap"]},k.createElement("div",{className:gi(CG["modal-window"],{[CG["modal-window-max-height"]]:e.maxHeight})},e.closeButton&&k.createElement(fd,{onClick:g},k.createElement(Z4e,null)),k.createElement("div",{className:CG["modal-content"]},e.children))))}KAe.defaultProps={closeButton:!0,hide:!1,maxHeight:!1};KAe.propTypes={children:L.element.isRequired,closeButton:L.bool,hide:L.bool,maxHeight:L.bool,modal:L.object.isRequired,onClose:L.func};const Lmg=Z_(KAe),$Q={"dialog-header":"_dialog-header_wp50s_1","dialog-main-max-height":"_dialog-main-max-height_wp50s_20","dialog-footer":"_dialog-footer_wp50s_31","dialog-footer-max-height":"_dialog-footer-max-height_wp50s_31"};function xAe(e){const g=()=>{e.modal.close(),e.onCancel&&e.onCancel()},i=()=>{e.modal.close(),e.onOkay&&e.onOkay()};return k.createElement(Lmg,{closeButton:!1,hide:e.hide,maxHeight:e.maxHeight},k.createElement(k.Fragment,null,k.createElement("header",{className:$Q["dialog-header"]},k.createElement("h3",null,e.title),k.createElement(fd,{onClick:g},k.createElement(Z4e,null))),e.maxHeight?k.createElement("main",{className:gi(e.maxHeight&&$Q["dialog-main-max-height"])},e.children):k.createElement("main",null,e.children),k.createElement("footer",{className:$Q[e.maxHeight?"dialog-footer-max-height":"dialog-footer"]},e.okayOnly?k.createElement("div",null):k.createElement(fd,{onClick:g,shortcut:e.cancelShortcut},e.cancelTitle),k.createElement(fd,{onClick:i,shortcut:e.okayShortcut},e.okayTitle))))}xAe.defaultProps={cancelTitle:"Cancel",hide:!1,maxHeight:!1,okayOnly:!1,okayTitle:"Ok"};xAe.propTypes={cancelShortcut:L.string,cancelTitle:L.string,children:L.object,hide:L.bool,maxHeight:L.bool,modal:L.object.isRequired,okayShortcut:L.string,okayTitle:L.string,okayOnly:L.bool,onCancel:L.func.isRequired,onOkay:L.func.isRequired,title:L.string.isRequired};const aH=Z_(xAe);var La={},sH={},Umg=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis;const G4e=Umg;var Qmg=typeof self=="object"&&self&&self.Object===Object&&self,jmg=G4e||Qmg||Function("return this")();const rl=jmg;var $mg=rl.Symbol;const Nc=$mg;var v4e=Object.prototype,qmg=v4e.hasOwnProperty,epg=v4e.toString,TR=Nc?Nc.toStringTag:void 0;function tpg(e){var g=qmg.call(e,TR),i=e[TR];try{e[TR]=void 0;var n=!0}catch{}var I=epg.call(e);return n&&(g?e[TR]=i:delete e[TR]),I}var gpg=Object.prototype,ipg=gpg.toString;function npg(e){return ipg.call(e)}var Ipg="[object Null]",rpg="[object Undefined]",y2e=Nc?Nc.toStringTag:void 0;function Qm(e){return e==null?e===void 0?rpg:Ipg:y2e&&y2e in Object(e)?tpg(e):npg(e)}var opg=Array.isArray;const Do=opg;function OA(e){return e!=null&&typeof e=="object"}var Cpg="[object String]";function apg(e){return typeof e=="string"||!Do(e)&&OA(e)&&Qm(e)==Cpg}const spg=Object.freeze(Object.defineProperty({__proto__:null,default:apg},Symbol.toStringTag,{value:"Module"})),Apg=Ud(spg);function lpg(e){return function(g,i,n){for(var I=-1,r=Object(g),o=n(g),C=o.length;C--;){var a=o[e?C:++I];if(i(r[a],a,r)===!1)break}return g}}var cpg=lpg();const B4e=cpg;function upg(e,g){for(var i=-1,n=Array(e);++i-1&&e%1==0&&e-1&&e%1==0&&e<=Bpg}var wpg="[object Arguments]",Spg="[object Array]",Rpg="[object Boolean]",Vpg="[object Date]",Wpg="[object Error]",Xpg="[object Function]",Tpg="[object Map]",Hpg="[object Number]",Npg="[object Object]",kpg="[object RegExp]",Ypg="[object Set]",Kpg="[object String]",xpg="[object WeakMap]",Fpg="[object ArrayBuffer]",Epg="[object DataView]",Dpg="[object Float32Array]",Mpg="[object Float64Array]",zpg="[object Int8Array]",Ppg="[object Int16Array]",_pg="[object Int32Array]",Opg="[object Uint8Array]",Jpg="[object Uint8ClampedArray]",Lpg="[object Uint16Array]",Upg="[object Uint32Array]",en={};en[Dpg]=en[Mpg]=en[zpg]=en[Ppg]=en[_pg]=en[Opg]=en[Jpg]=en[Lpg]=en[Upg]=!0;en[wpg]=en[Spg]=en[Fpg]=en[Rpg]=en[Epg]=en[Vpg]=en[Wpg]=en[Xpg]=en[Tpg]=en[Hpg]=en[Npg]=en[kpg]=en[Ypg]=en[Kpg]=en[xpg]=!1;function Qpg(e){return OA(e)&&EAe(e.length)&&!!en[Qm(e)]}function DAe(e){return function(g){return e(g)}}var R4e=typeof exports=="object"&&exports&&!exports.nodeType&&exports,XW=R4e&&typeof module=="object"&&module&&!module.nodeType&&module,jpg=XW&&XW.exports===R4e,qQ=jpg&&G4e.process,$pg=function(){try{var e=XW&&XW.require&&XW.require("util").types;return e||qQ&&qQ.binding&&qQ.binding("util")}catch{}}();const Hw=$pg;var B2e=Hw&&Hw.isTypedArray,qpg=B2e?DAe(B2e):Qpg;const MAe=qpg;var e0g=Object.prototype,t0g=e0g.hasOwnProperty;function V4e(e,g){var i=Do(e),n=!i&&nD(e),I=!i&&!n&&u9(e),r=!i&&!n&&!I&&MAe(e),o=i||n||I||r,C=o?upg(e.length,String):[],a=C.length;for(var A in e)(g||t0g.call(e,A))&&!(o&&(A=="length"||I&&(A=="offset"||A=="parent")||r&&(A=="buffer"||A=="byteLength"||A=="byteOffset")||FAe(A,a)))&&C.push(A);return C}var g0g=Object.prototype;function zAe(e){var g=e&&e.constructor,i=typeof g=="function"&&g.prototype||g0g;return e===i}function W4e(e,g){return function(i){return e(g(i))}}var i0g=W4e(Object.keys,Object);const n0g=i0g;var I0g=Object.prototype,r0g=I0g.hasOwnProperty;function o0g(e){if(!zAe(e))return n0g(e);var g=[];for(var i in Object(e))r0g.call(e,i)&&i!="constructor"&&g.push(i);return g}function pa(e){var g=typeof e;return e!=null&&(g=="object"||g=="function")}var C0g="[object AsyncFunction]",a0g="[object Function]",s0g="[object GeneratorFunction]",A0g="[object Proxy]";function PAe(e){if(!pa(e))return!1;var g=Qm(e);return g==a0g||g==s0g||g==C0g||g==A0g}function iS(e){return e!=null&&EAe(e.length)&&!PAe(e)}function AH(e){return iS(e)?V4e(e):o0g(e)}function X4e(e,g){return e&&B4e(e,g,AH)}function G_(e){return e}function T4e(e){return typeof e=="function"?e:G_}function l0g(e,g){return e&&X4e(e,T4e(g))}const c0g=Object.freeze(Object.defineProperty({__proto__:null,default:l0g},Symbol.toStringTag,{value:"Module"})),_Ae=Ud(c0g);var u0g=W4e(Object.getPrototypeOf,Object);const OAe=u0g;var d0g="[object Object]",h0g=Function.prototype,f0g=Object.prototype,H4e=h0g.toString,m0g=f0g.hasOwnProperty,p0g=H4e.call(Object);function N4e(e){if(!OA(e)||Qm(e)!=d0g)return!1;var g=OAe(e);if(g===null)return!0;var i=m0g.call(g,"constructor")&&g.constructor;return typeof i=="function"&&i instanceof i&&H4e.call(i)==p0g}const b0g=Object.freeze(Object.defineProperty({__proto__:null,default:N4e},Symbol.toStringTag,{value:"Module"})),y0g=Ud(b0g);function k4e(e,g){for(var i=-1,n=e==null?0:e.length,I=Array(n);++i-1}function R0g(e,g){var i=this.__data__,n=v_(i,e);return n<0?(++this.size,i.push([e,g])):i[n][1]=g,this}function Ih(e){var g=-1,i=e==null?0:e.length;for(this.clear();++gC))return!1;var A=r.get(e),s=r.get(g);if(A&&s)return A==g&&s==e;var l=-1,c=!0,u=i&pbg?new ID:void 0;for(r.set(e,g),r.set(g,e);++l0&&arguments[0]!==void 0?arguments[0]:[],i=[];return(0,_yg.default)(g,function(n){Array.isArray(n)?e(n).map(function(I){return i.push(I)}):(0,zyg.default)(n)?(0,Dyg.default)(n,function(I,r){I===!0&&i.push(r),i.push(r+"-"+I)}):(0,Fyg.default)(n)&&i.push(n)}),i};sH.default=Oyg;var cH={};function O4e(e,g){for(var i=-1,n=e==null?0:e.length;++i1&&arguments[1]!==void 0?arguments[1]:[],n=g.default&&(0,BGg.default)(g.default)||{};return i.map(function(I){var r=g[I];return r&&(0,GGg.default)(r,function(o,C){n[C]||(n[C]={}),n[C]=wGg({},n[C],r[C])}),I}),n};cH.default=SGg;var hH={};Object.defineProperty(hH,"__esModule",{value:!0});hH.autoprefix=void 0;var RGg=_Ae,J2e=WGg(RGg),VGg=Object.assign||function(e){for(var g=1;g1&&arguments[1]!==void 0?arguments[1]:"span";return function(n){KGg(I,n);function I(){var r,o,C,a;YGg(this,I);for(var A=arguments.length,s=Array(A),l=0;l1&&arguments[1]!==void 0?arguments[1]:"span";return function(n){zGg(I,n);function I(){var r,o,C,a;MGg(this,I);for(var A=arguments.length,s=Array(A),l=0;l1&&arguments[1]!==void 0?arguments[1]:!0;n[o]=C};return g===0&&I("first-child"),g===i-1&&I("last-child"),(g===0||g%2===0)&&I("even"),Math.abs(g%2)===1&&I("odd"),I("nth-child",g),n};qAe.default=_Gg;Object.defineProperty(La,"__esModule",{value:!0});La.ReactCSS=La.loop=La.handleActive=ele=La.handleHover=La.hover=void 0;var OGg=sH,JGg=nS(OGg),LGg=cH,UGg=nS(LGg),QGg=hH,jGg=nS(QGg),$Gg=fH,n$e=nS($Gg),qGg=mH,evg=nS(qGg),tvg=qAe,gvg=nS(tvg);function nS(e){return e&&e.__esModule?e:{default:e}}La.hover=n$e.default;var ele=La.handleHover=n$e.default;La.handleActive=evg.default;La.loop=gvg.default;var ivg=La.ReactCSS=function(g){for(var i=arguments.length,n=Array(i>1?i-1:0),I=1;IC?c=1:c=Math.round(l*100/C)/100,i.a!==c)return{h:i.h,s:i.s,l:i.l,a:c,source:"rgb"}}else{var u=void 0;if(s<0?u=0:s>o?u=1:u=Math.round(s*100/o)/100,I!==u)return{h:i.h,s:i.s,l:i.l,a:u,source:"rgb"}}return null},nj={},Ivg=function(g,i,n,I){if(typeof document>"u"&&!I)return null;var r=I?new I:document.createElement("canvas");r.width=n*2,r.height=n*2;var o=r.getContext("2d");return o?(o.fillStyle=g,o.fillRect(0,0,r.width,r.height),o.fillStyle=i,o.fillRect(0,0,n,n),o.translate(n,n),o.fillRect(0,0,n,n),r.toDataURL()):null},rvg=function(g,i,n,I){var r=g+"-"+i+"-"+n+(I?"-server":"");if(nj[r])return nj[r];var o=Ivg(g,i,n,I);return nj[r]=o,o},Q2e=Object.assign||function(e){for(var g=1;g-1},bvg=function(g){return Number(String(g).replace(/%/g,""))},yvg=1,Jg=function(e){dvg(g,e);function g(i){cvg(this,g);var n=uvg(this,(g.__proto__||Object.getPrototypeOf(g)).call(this));return n.handleBlur=function(){n.state.blurValue&&n.setState({value:n.state.blurValue,blurValue:null})},n.handleChange=function(I){n.setUpdatedValue(I.target.value,I)},n.handleKeyDown=function(I){var r=bvg(I.target.value);if(!isNaN(r)&&pvg(I.keyCode)){var o=n.getArrowOffset(),C=I.keyCode===I$e?r+o:r-o;n.setUpdatedValue(C,I)}},n.handleDrag=function(I){if(n.props.dragLabel){var r=Math.round(n.props.value+I.movementX);r>=0&&r<=n.props.dragMax&&n.props.onChange&&n.props.onChange(n.getValueObjectWithLabel(r),I)}},n.handleMouseDown=function(I){n.props.dragLabel&&(I.preventDefault(),n.handleDrag(I),window.addEventListener("mousemove",n.handleDrag),window.addEventListener("mouseup",n.handleMouseUp))},n.handleMouseUp=function(){n.unbindEventListeners()},n.unbindEventListeners=function(){window.removeEventListener("mousemove",n.handleDrag),window.removeEventListener("mouseup",n.handleMouseUp)},n.state={value:String(i.value).toUpperCase(),blurValue:String(i.value).toUpperCase()},n.inputId="rc-editable-input-"+yvg++,n}return Avg(g,[{key:"componentDidUpdate",value:function(n,I){this.props.value!==this.state.value&&(n.value!==this.props.value||I.value!==this.state.value)&&(this.input===document.activeElement?this.setState({blurValue:String(this.props.value).toUpperCase()}):this.setState({value:String(this.props.value).toUpperCase(),blurValue:!this.state.blurValue&&String(this.props.value).toUpperCase()}))}},{key:"componentWillUnmount",value:function(){this.unbindEventListeners()}},{key:"getValueObjectWithLabel",value:function(n){return lvg({},this.props.label,n)}},{key:"getArrowOffset",value:function(){return this.props.arrowOffset||hvg}},{key:"setUpdatedValue",value:function(n,I){var r=this.props.label?this.getValueObjectWithLabel(n):n;this.props.onChange&&this.props.onChange(r,I),this.setState({value:n})}},{key:"render",value:function(){var n=this,I=dg({default:{wrap:{position:"relative"}},"user-override":{wrap:this.props.style&&this.props.style.wrap?this.props.style.wrap:{},input:this.props.style&&this.props.style.input?this.props.style.input:{},label:this.props.style&&this.props.style.label?this.props.style.label:{}},"dragLabel-true":{label:{cursor:"ew-resize"}}},{"user-override":!0},this.props);return k.createElement("div",{style:I.wrap},k.createElement("input",{id:this.inputId,style:I.input,ref:function(o){return n.input=o},value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,onBlur:this.handleBlur,placeholder:this.props.placeholder,spellCheck:"false"}),this.props.label&&!this.props.hideLabel?k.createElement("label",{htmlFor:this.inputId,style:I.label,onMouseDown:this.handleMouseDown},this.props.label):null)}}]),g}(Ue.PureComponent||Ue.Component),Zvg=function(g,i,n,I){var r=I.clientWidth,o=I.clientHeight,C=typeof g.pageX=="number"?g.pageX:g.touches[0].pageX,a=typeof g.pageY=="number"?g.pageY:g.touches[0].pageY,A=C-(I.getBoundingClientRect().left+window.pageXOffset),s=a-(I.getBoundingClientRect().top+window.pageYOffset);if(i==="vertical"){var l=void 0;if(s<0)l=359;else if(s>o)l=0;else{var c=-(s*100/o)+100;l=360*c/100}if(n.h!==l)return{h:l,s:n.s,l:n.l,a:n.a,source:"hsl"}}else{var u=void 0;if(A<0)u=0;else if(A>r)u=359;else{var d=A*100/r;u=360*d/100}if(n.h!==u)return{h:u,s:n.s,l:n.l,a:n.a,source:"hsl"}}return null},Gvg=function(){function e(g,i){for(var n=0;n0){if(++g>=Nvg)return arguments[0]}else g=0;return e.apply(void 0,arguments)}}var xvg=Kvg(Hvg);const Fvg=xvg;function Evg(e,g){return Fvg(Wvg(e,g,G_),e+"")}function Dvg(e,g,i){if(!pa(i))return!1;var n=typeof g;return(n=="number"?iS(i)&&FAe(g,i.length):n=="string"&&g in i)?lH(i[g],e):!1}function Mvg(e){return Evg(function(g,i){var n=-1,I=i.length,r=I>1?i[I-1]:void 0,o=I>2?i[2]:void 0;for(r=e.length>3&&typeof r=="function"?(I--,r):void 0,o&&Dvg(i[0],i[1],o)&&(r=I<3?void 0:r,I=1),g=Object(g);++n=g||G<0||l&&B>=r}function m(){var v=Ij();if(f(v))return b(v);C=setTimeout(m,h(v))}function b(v){return C=void 0,c&&n?u(v):(n=I=void 0,o)}function p(){C!==void 0&&clearTimeout(C),A=0,n=a=I=C=void 0}function y(){return C===void 0?o:b(Ij())}function Z(){var v=Ij(),G=f(v);if(n=arguments,I=this,a=v,G){if(C===void 0)return d(a);if(l)return clearTimeout(C),C=setTimeout(m,g),u(a)}return C===void 0&&(C=setTimeout(m,g)),o}return Z.cancel=p,Z.flush=y,Z}var gBg="Expected a function";function iBg(e,g,i){var n=!0,I=!0;if(typeof e!="function")throw new TypeError(gBg);return pa(i)&&(n="leading"in i?!!i.leading:n,I="trailing"in i?!!i.trailing:I),o$e(e,g,{leading:n,maxWait:g,trailing:I})}var nBg=function(g,i,n){var I=n.getBoundingClientRect(),r=I.width,o=I.height,C=typeof g.pageX=="number"?g.pageX:g.touches[0].pageX,a=typeof g.pageY=="number"?g.pageY:g.touches[0].pageY,A=C-(n.getBoundingClientRect().left+window.pageXOffset),s=a-(n.getBoundingClientRect().top+window.pageYOffset);A<0?A=0:A>r&&(A=r),s<0?s=0:s>o&&(s=o);var l=A/r,c=1-s/o;return{h:i.h,s:l,v:c,a:i.a,source:"hsv"}},IBg=function(){function e(g,i){for(var n=0;n=0,r=!i&&I&&(g==="hex"||g==="hex6"||g==="hex3"||g==="hex4"||g==="hex8"||g==="name");return r?g==="name"&&this._a===0?this.toName():this.toRgbString():(g==="rgb"&&(n=this.toRgbString()),g==="prgb"&&(n=this.toPercentageRgbString()),(g==="hex"||g==="hex6")&&(n=this.toHexString()),g==="hex3"&&(n=this.toHexString(!0)),g==="hex4"&&(n=this.toHex8String(!0)),g==="hex8"&&(n=this.toHex8String()),g==="name"&&(n=this.toName()),g==="hsl"&&(n=this.toHslString()),g==="hsv"&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return Ot(this.toString())},_applyModification:function(g,i){var n=g.apply(null,[this].concat([].slice.call(i)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(bBg,arguments)},brighten:function(){return this._applyModification(yBg,arguments)},darken:function(){return this._applyModification(ZBg,arguments)},desaturate:function(){return this._applyModification(fBg,arguments)},saturate:function(){return this._applyModification(mBg,arguments)},greyscale:function(){return this._applyModification(pBg,arguments)},spin:function(){return this._applyModification(GBg,arguments)},_applyCombination:function(g,i){return g.apply(null,[this].concat([].slice.call(i)))},analogous:function(){return this._applyCombination(wBg,arguments)},complement:function(){return this._applyCombination(vBg,arguments)},monochromatic:function(){return this._applyCombination(SBg,arguments)},splitcomplement:function(){return this._applyCombination(BBg,arguments)},triad:function(){return this._applyCombination(rWe,[3])},tetrad:function(){return this._applyCombination(rWe,[4])}};Ot.fromRatio=function(e,g){if(CD(e)=="object"){var i={};for(var n in e)e.hasOwnProperty(n)&&(n==="a"?i[n]=e[n]:i[n]=JV(e[n]));e=i}return Ot(e,g)};function lBg(e){var g={r:0,g:0,b:0},i=1,n=null,I=null,r=null,o=!1,C=!1;return typeof e=="string"&&(e=TBg(e)),CD(e)=="object"&&(yu(e.r)&&yu(e.g)&&yu(e.b)?(g=cBg(e.r,e.g,e.b),o=!0,C=String(e.r).substr(-1)==="%"?"prgb":"rgb"):yu(e.h)&&yu(e.s)&&yu(e.v)?(n=JV(e.s),I=JV(e.v),g=dBg(e.h,n,I),o=!0,C="hsv"):yu(e.h)&&yu(e.s)&&yu(e.l)&&(n=JV(e.s),r=JV(e.l),g=uBg(e.h,n,r),o=!0,C="hsl"),e.hasOwnProperty("a")&&(i=e.a)),i=C$e(i),{ok:o,format:e.format||C,r:Math.min(255,Math.max(g.r,0)),g:Math.min(255,Math.max(g.g,0)),b:Math.min(255,Math.max(g.b,0)),a:i}}function cBg(e,g,i){return{r:An(e,255)*255,g:An(g,255)*255,b:An(i,255)*255}}function gWe(e,g,i){e=An(e,255),g=An(g,255),i=An(i,255);var n=Math.max(e,g,i),I=Math.min(e,g,i),r,o,C=(n+I)/2;if(n==I)r=o=0;else{var a=n-I;switch(o=C>.5?a/(2-n-I):a/(n+I),n){case e:r=(g-i)/a+(g1&&(l-=1),l<1/6?A+(s-A)*6*l:l<1/2?s:l<2/3?A+(s-A)*(2/3-l)*6:A}if(g===0)n=I=r=i;else{var C=i<.5?i*(1+g):i+g-i*g,a=2*i-C;n=o(a,C,e+1/3),I=o(a,C,e),r=o(a,C,e-1/3)}return{r:n*255,g:I*255,b:r*255}}function iWe(e,g,i){e=An(e,255),g=An(g,255),i=An(i,255);var n=Math.max(e,g,i),I=Math.min(e,g,i),r,o,C=n,a=n-I;if(o=n===0?0:a/n,n==I)r=0;else{switch(n){case e:r=(g-i)/a+(g>1)+720)%360;--g;)n.h=(n.h+I)%360,r.push(Ot(n));return r}function SBg(e,g){g=g||6;for(var i=Ot(e).toHsv(),n=i.h,I=i.s,r=i.v,o=[],C=1/g;g--;)o.push(Ot({h:n,s:I,v:r})),r=(r+C)%1;return o}Ot.mix=function(e,g,i){i=i===0?0:i||50;var n=Ot(e).toRgb(),I=Ot(g).toRgb(),r=i/100,o={r:(I.r-n.r)*r+n.r,g:(I.g-n.g)*r+n.g,b:(I.b-n.b)*r+n.b,a:(I.a-n.a)*r+n.a};return Ot(o)};Ot.readability=function(e,g){var i=Ot(e),n=Ot(g);return(Math.max(i.getLuminance(),n.getLuminance())+.05)/(Math.min(i.getLuminance(),n.getLuminance())+.05)};Ot.isReadable=function(e,g,i){var n=Ot.readability(e,g),I,r;switch(r=!1,I=HBg(i),I.level+I.size){case"AAsmall":case"AAAlarge":r=n>=4.5;break;case"AAlarge":r=n>=3;break;case"AAAsmall":r=n>=7;break}return r};Ot.mostReadable=function(e,g,i){var n=null,I=0,r,o,C,a;i=i||{},o=i.includeFallbackColors,C=i.level,a=i.size;for(var A=0;AI&&(I=r,n=Ot(g[A]));return Ot.isReadable(e,n,{level:C,size:a})||!o?n:(i.includeFallbackColors=!1,Ot.mostReadable(e,["#fff","#000"],i))};var mge=Ot.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},RBg=Ot.hexNames=VBg(mge);function VBg(e){var g={};for(var i in e)e.hasOwnProperty(i)&&(g[e[i]]=i);return g}function C$e(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function An(e,g){WBg(e)&&(e="100%");var i=XBg(e);return e=Math.min(g,Math.max(0,parseFloat(e))),i&&(e=parseInt(e*g,10)/100),Math.abs(e-g)<1e-6?1:e%g/parseFloat(g)}function W_(e){return Math.min(1,Math.max(0,e))}function UC(e){return parseInt(e,16)}function WBg(e){return typeof e=="string"&&e.indexOf(".")!=-1&&parseFloat(e)===1}function XBg(e){return typeof e=="string"&&e.indexOf("%")!=-1}function BA(e){return e.length==1?"0"+e:""+e}function JV(e){return e<=1&&(e=e*100+"%"),e}function a$e(e){return Math.round(parseFloat(e)*255).toString(16)}function oWe(e){return UC(e)/255}var Qs=function(){var e="[-\\+]?\\d+%?",g="[-\\+]?\\d*\\.\\d+%?",i="(?:"+g+")|(?:"+e+")",n="[\\s|\\(]+("+i+")[,|\\s]+("+i+")[,|\\s]+("+i+")\\s*\\)?",I="[\\s|\\(]+("+i+")[,|\\s]+("+i+")[,|\\s]+("+i+")[,|\\s]+("+i+")\\s*\\)?";return{CSS_UNIT:new RegExp(i),rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+I),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+I),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+I),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function yu(e){return!!Qs.CSS_UNIT.exec(e)}function TBg(e){e=e.replace(sBg,"").replace(ABg,"").toLowerCase();var g=!1;if(mge[e])e=mge[e],g=!0;else if(e=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var i;return(i=Qs.rgb.exec(e))?{r:i[1],g:i[2],b:i[3]}:(i=Qs.rgba.exec(e))?{r:i[1],g:i[2],b:i[3],a:i[4]}:(i=Qs.hsl.exec(e))?{h:i[1],s:i[2],l:i[3]}:(i=Qs.hsla.exec(e))?{h:i[1],s:i[2],l:i[3],a:i[4]}:(i=Qs.hsv.exec(e))?{h:i[1],s:i[2],v:i[3]}:(i=Qs.hsva.exec(e))?{h:i[1],s:i[2],v:i[3],a:i[4]}:(i=Qs.hex8.exec(e))?{r:UC(i[1]),g:UC(i[2]),b:UC(i[3]),a:oWe(i[4]),format:g?"name":"hex8"}:(i=Qs.hex6.exec(e))?{r:UC(i[1]),g:UC(i[2]),b:UC(i[3]),format:g?"name":"hex"}:(i=Qs.hex4.exec(e))?{r:UC(i[1]+""+i[1]),g:UC(i[2]+""+i[2]),b:UC(i[3]+""+i[3]),a:oWe(i[4]+""+i[4]),format:g?"name":"hex8"}:(i=Qs.hex3.exec(e))?{r:UC(i[1]+""+i[1]),g:UC(i[2]+""+i[2]),b:UC(i[3]+""+i[3]),format:g?"name":"hex"}:!1}function HBg(e){var g,i;return e=e||{level:"AA",size:"small"},g=(e.level||"AA").toUpperCase(),i=(e.size||"small").toLowerCase(),g!=="AA"&&g!=="AAA"&&(g="AA"),i!=="small"&&i!=="large"&&(i="small"),{level:g,size:i}}var CWe=function(g){var i=["r","g","b","a","h","s","l","v"],n=0,I=0;return aBg(i,function(r){if(g[r]&&(n+=1,isNaN(g[r])||(I+=1),r==="s"||r==="l")){var o=/^\d+%$/;o.test(g[r])&&(I+=1)}}),n===I?g:!1},LV=function(g,i){var n=g.hex?Ot(g.hex):Ot(g),I=n.toHsl(),r=n.toHsv(),o=n.toRgb(),C=n.toHex();I.s===0&&(I.h=i||0,r.h=i||0);var a=C==="000000"&&o.a===0;return{hsl:I,hex:a?"transparent":"#"+C,rgb:o,hsv:r,oldHue:g.h||i||I.h,source:g.source}},$m=function(g){if(g==="transparent")return!0;var i=String(g).charAt(0)==="#"?1:0;return g.length!==4+i&&g.length<7+i&&Ot(g).isValid()},gle=function(g){if(!g)return"#fff";var i=LV(g);if(i.hex==="transparent")return"rgba(0,0,0,0.4)";var n=(i.rgb.r*299+i.rgb.g*587+i.rgb.b*114)/1e3;return n>=128?"#000":"#fff"},rj=function(g,i){var n=g.replace("°","");return Ot(i+" ("+n+")")._ok},HR=Object.assign||function(e){for(var g=1;g1&&arguments[1]!==void 0?arguments[1]:"span";return function(n){DBg(I,n);function I(){var r,o,C,a;EBg(this,I);for(var A=arguments.length,s=Array(A),l=0;l=0||Object.prototype.hasOwnProperty.call(e,n)&&(i[n]=e[n]);return i}var cY=24,$Bg=l$e.default=function(e){var g=e.fill,i=g===void 0?"currentColor":g,n=e.width,I=n===void 0?cY:n,r=e.height,o=r===void 0?cY:r,C=e.style,a=C===void 0?{}:C,A=jBg(e,["fill","width","height","style"]);return cWe.default.createElement("svg",lWe({viewBox:"0 0 "+cY+" "+cY,style:lWe({fill:i,width:I,height:o},a)},A),cWe.default.createElement("path",{d:"M12,18.17L8.83,15L7.42,16.41L12,21L16.59,16.41L15.17,15M12,5.83L15.17,9L16.58,7.59L12,3L7.41,7.59L8.83,9L12,5.83Z"}))},qBg=function(){function e(g,i){for(var n=0;n1&&(I.a=1),n.props.onChange({h:n.props.hsl.h,s:n.props.hsl.s,l:n.props.hsl.l,a:Math.round(I.a*100)/100,source:"rgb"},r)):(I.h||I.s||I.l)&&(typeof I.s=="string"&&I.s.includes("%")&&(I.s=I.s.replace("%","")),typeof I.l=="string"&&I.l.includes("%")&&(I.l=I.l.replace("%","")),I.s==1?I.s=.01:I.l==1&&(I.l=.01),n.props.onChange({h:I.h||n.props.hsl.h,s:Number(AWe(I.s)?n.props.hsl.s:I.s),l:Number(AWe(I.l)?n.props.hsl.l:I.l),source:"hsl"},r))},n.showHighlight=function(I){I.currentTarget.style.background="#eee"},n.hideHighlight=function(I){I.currentTarget.style.background="transparent"},i.hsl.a!==1&&i.view==="hex"?n.state={view:"rgb"}:n.state={view:i.view},n}return qBg(g,[{key:"render",value:function(){var n=this,I=dg({default:{wrap:{paddingTop:"16px",display:"flex"},fields:{flex:"1",display:"flex",marginLeft:"-6px"},field:{paddingLeft:"6px",width:"100%"},alpha:{paddingLeft:"6px",width:"100%"},toggle:{width:"32px",textAlign:"right",position:"relative"},icon:{marginRight:"-4px",marginTop:"12px",cursor:"pointer",position:"relative"},iconHighlight:{position:"absolute",width:"24px",height:"28px",background:"#eee",borderRadius:"4px",top:"10px",left:"12px",display:"none"},input:{fontSize:"11px",color:"#333",width:"100%",borderRadius:"2px",border:"none",boxShadow:"inset 0 0 0 1px #dadada",height:"21px",textAlign:"center"},label:{textTransform:"uppercase",fontSize:"11px",lineHeight:"11px",color:"#969696",textAlign:"center",display:"block",marginTop:"12px"},svg:{fill:"#333",width:"24px",height:"24px",border:"1px transparent solid",borderRadius:"5px"}},disableAlpha:{alpha:{display:"none"}}},this.props,this.state),r=void 0;return this.state.view==="hex"?r=k.createElement("div",{style:I.fields,className:"flexbox-fix"},k.createElement("div",{style:I.field},k.createElement(Jg,{style:{input:I.input,label:I.label},label:"hex",value:this.props.hex,onChange:this.handleChange}))):this.state.view==="rgb"?r=k.createElement("div",{style:I.fields,className:"flexbox-fix"},k.createElement("div",{style:I.field},k.createElement(Jg,{style:{input:I.input,label:I.label},label:"r",value:this.props.rgb.r,onChange:this.handleChange})),k.createElement("div",{style:I.field},k.createElement(Jg,{style:{input:I.input,label:I.label},label:"g",value:this.props.rgb.g,onChange:this.handleChange})),k.createElement("div",{style:I.field},k.createElement(Jg,{style:{input:I.input,label:I.label},label:"b",value:this.props.rgb.b,onChange:this.handleChange})),k.createElement("div",{style:I.alpha},k.createElement(Jg,{style:{input:I.input,label:I.label},label:"a",value:this.props.rgb.a,arrowOffset:.01,onChange:this.handleChange}))):this.state.view==="hsl"&&(r=k.createElement("div",{style:I.fields,className:"flexbox-fix"},k.createElement("div",{style:I.field},k.createElement(Jg,{style:{input:I.input,label:I.label},label:"h",value:Math.round(this.props.hsl.h),onChange:this.handleChange})),k.createElement("div",{style:I.field},k.createElement(Jg,{style:{input:I.input,label:I.label},label:"s",value:Math.round(this.props.hsl.s*100)+"%",onChange:this.handleChange})),k.createElement("div",{style:I.field},k.createElement(Jg,{style:{input:I.input,label:I.label},label:"l",value:Math.round(this.props.hsl.l*100)+"%",onChange:this.handleChange})),k.createElement("div",{style:I.alpha},k.createElement(Jg,{style:{input:I.input,label:I.label},label:"a",value:this.props.hsl.a,arrowOffset:.01,onChange:this.handleChange})))),k.createElement("div",{style:I.wrap,className:"flexbox-fix"},r,k.createElement("div",{style:I.toggle},k.createElement("div",{style:I.icon,onClick:this.toggleViews,ref:function(C){return n.icon=C}},k.createElement($Bg,{style:I.svg,onMouseOver:this.showHighlight,onMouseEnter:this.showHighlight,onMouseOut:this.hideHighlight}))))}}],[{key:"getDerivedStateFromProps",value:function(n,I){return n.hsl.a!==1&&I.view==="hex"?{view:"rgb"}:null}}]),g}(k.Component);c$e.defaultProps={view:"hex"};var uWe=function(){var g=dg({default:{picker:{width:"12px",height:"12px",borderRadius:"6px",transform:"translate(-6px, -1px)",backgroundColor:"rgb(248, 248, 248)",boxShadow:"0 1px 4px 0 rgba(0, 0, 0, 0.37)"}}});return k.createElement("div",{style:g.picker})},iwg=function(){var g=dg({default:{picker:{width:"12px",height:"12px",borderRadius:"6px",boxShadow:"inset 0 0 0 1px #fff",transform:"translate(-6px, -6px)"}}});return k.createElement("div",{style:g.picker})},Ile=function(g){var i=g.width,n=g.onChange,I=g.disableAlpha,r=g.rgb,o=g.hsl,C=g.hsv,a=g.hex,A=g.renderers,s=g.styles,l=s===void 0?{}:s,c=g.className,u=c===void 0?"":c,d=g.defaultView,h=dg(MC({default:{picker:{width:i,background:"#fff",borderRadius:"2px",boxShadow:"0 0 2px rgba(0,0,0,.3), 0 4px 8px rgba(0,0,0,.3)",boxSizing:"initial",fontFamily:"Menlo"},saturation:{width:"100%",paddingBottom:"55%",position:"relative",borderRadius:"2px 2px 0 0",overflow:"hidden"},Saturation:{radius:"2px 2px 0 0"},body:{padding:"16px 16px 12px"},controls:{display:"flex"},color:{width:"32px"},swatch:{marginTop:"6px",width:"16px",height:"16px",borderRadius:"8px",position:"relative",overflow:"hidden"},active:{absolute:"0px 0px 0px 0px",borderRadius:"8px",boxShadow:"inset 0 0 0 1px rgba(0,0,0,.1)",background:"rgba("+r.r+", "+r.g+", "+r.b+", "+r.a+")",zIndex:"2"},toggles:{flex:"1"},hue:{height:"10px",position:"relative",marginBottom:"8px"},Hue:{radius:"2px"},alpha:{height:"10px",position:"relative"},Alpha:{radius:"2px"}},disableAlpha:{color:{width:"22px"},alpha:{display:"none"},hue:{marginBottom:"0px"},swatch:{width:"10px",height:"10px",marginTop:"0px"}}},l),{disableAlpha:I});return k.createElement("div",{style:h.picker,className:"chrome-picker "+u},k.createElement("div",{style:h.saturation},k.createElement(V_,{style:h.Saturation,hsl:o,hsv:C,pointer:iwg,onChange:n})),k.createElement("div",{style:h.body},k.createElement("div",{style:h.controls,className:"flexbox-fix"},k.createElement("div",{style:h.color},k.createElement("div",{style:h.swatch},k.createElement("div",{style:h.active}),k.createElement(IS,{renderers:A}))),k.createElement("div",{style:h.toggles},k.createElement("div",{style:h.hue},k.createElement(rS,{style:h.Hue,hsl:o,pointer:uWe,onChange:n})),k.createElement("div",{style:h.alpha},k.createElement(tle,{style:h.Alpha,rgb:r,hsl:o,pointer:uWe,renderers:A,onChange:n})))),k.createElement(c$e,{rgb:r,hsl:o,hex:a,view:d,onChange:n,disableAlpha:I})))};Ile.propTypes={width:L.oneOfType([L.string,L.number]),disableAlpha:L.bool,styles:L.object,defaultView:L.oneOf(["hex","rgb","hsl"])};Ile.defaultProps={width:225,disableAlpha:!1,styles:{}};zC(Ile);var nwg=function(g){var i=g.color,n=g.onClick,I=n===void 0?function(){}:n,r=g.onSwatchHover,o=g.active,C=dg({default:{color:{background:i,width:"15px",height:"15px",float:"left",marginRight:"5px",marginBottom:"5px",position:"relative",cursor:"pointer"},dot:{absolute:"5px 5px 5px 5px",background:gle(i),borderRadius:"50%",opacity:"0"}},active:{dot:{opacity:"1"}},"color-#FFFFFF":{color:{boxShadow:"inset 0 0 0 1px #ddd"},dot:{background:"#000"}},transparent:{dot:{background:"#000"}}},{active:o,"color-#FFFFFF":i==="#FFFFFF",transparent:i==="transparent"});return k.createElement(AZ,{style:C.color,color:i,onClick:I,onHover:r,focusStyle:{boxShadow:"0 0 4px "+i}},k.createElement("div",{style:C.dot}))},Iwg=function(g){var i=g.hex,n=g.rgb,I=g.onChange,r=dg({default:{fields:{display:"flex",paddingBottom:"6px",paddingRight:"5px",position:"relative"},active:{position:"absolute",top:"6px",left:"5px",height:"9px",width:"9px",background:i},HEXwrap:{flex:"6",position:"relative"},HEXinput:{width:"80%",padding:"0px",paddingLeft:"20%",border:"none",outline:"none",background:"none",fontSize:"12px",color:"#333",height:"16px"},HEXlabel:{display:"none"},RGBwrap:{flex:"3",position:"relative"},RGBinput:{width:"70%",padding:"0px",paddingLeft:"30%",border:"none",outline:"none",background:"none",fontSize:"12px",color:"#333",height:"16px"},RGBlabel:{position:"absolute",top:"3px",left:"0px",lineHeight:"16px",textTransform:"uppercase",fontSize:"12px",color:"#999"}}}),o=function(a,A){a.r||a.g||a.b?I({r:a.r||n.r,g:a.g||n.g,b:a.b||n.b,source:"rgb"},A):I({hex:a.hex,source:"hex"},A)};return k.createElement("div",{style:r.fields,className:"flexbox-fix"},k.createElement("div",{style:r.active}),k.createElement(Jg,{style:{wrap:r.HEXwrap,input:r.HEXinput,label:r.HEXlabel},label:"hex",value:i,onChange:o}),k.createElement(Jg,{style:{wrap:r.RGBwrap,input:r.RGBinput,label:r.RGBlabel},label:"r",value:n.r,onChange:o}),k.createElement(Jg,{style:{wrap:r.RGBwrap,input:r.RGBinput,label:r.RGBlabel},label:"g",value:n.g,onChange:o}),k.createElement(Jg,{style:{wrap:r.RGBwrap,input:r.RGBinput,label:r.RGBlabel},label:"b",value:n.b,onChange:o}))},rle=function(g){var i=g.onChange,n=g.onSwatchHover,I=g.colors,r=g.hex,o=g.rgb,C=g.styles,a=C===void 0?{}:C,A=g.className,s=A===void 0?"":A,l=dg(MC({default:{Compact:{background:"#f6f6f6",radius:"4px"},compact:{paddingTop:"5px",paddingLeft:"5px",boxSizing:"initial",width:"240px"},clear:{clear:"both"}}},a)),c=function(d,h){d.hex?$m(d.hex)&&i({hex:d.hex,source:"hex"},h):i(d,h)};return k.createElement(pH,{style:l.Compact,styles:a},k.createElement("div",{style:l.compact,className:"compact-picker "+s},k.createElement("div",null,jm(I,function(u){return k.createElement(nwg,{key:u,color:u,active:u.toLowerCase()===r,onClick:c,onSwatchHover:n})}),k.createElement("div",{style:l.clear})),k.createElement(Iwg,{hex:r,rgb:o,onChange:c})))};rle.propTypes={colors:L.arrayOf(L.string),styles:L.object};rle.defaultProps={colors:["#4D4D4D","#999999","#FFFFFF","#F44E3B","#FE9200","#FCDC00","#DBDF00","#A4DD00","#68CCCA","#73D8FF","#AEA1FF","#FDA1FF","#333333","#808080","#cccccc","#D33115","#E27300","#FCC400","#B0BC00","#68BC00","#16A5A5","#009CE0","#7B64FF","#FA28FF","#000000","#666666","#B3B3B3","#9F0500","#C45100","#FB9E00","#808900","#194D33","#0C797D","#0062B1","#653294","#AB149E"],styles:{}};zC(rle);var rwg=function(g){var i=g.hover,n=g.color,I=g.onClick,r=g.onSwatchHover,o={position:"relative",zIndex:"2",outline:"2px solid #fff",boxShadow:"0 0 5px 2px rgba(0,0,0,0.25)"},C=dg({default:{swatch:{width:"25px",height:"25px",fontSize:"0"}},hover:{swatch:o}},{hover:i});return k.createElement("div",{style:C.swatch},k.createElement(AZ,{color:n,onClick:I,onHover:r,focusStyle:o}))};const owg=ele(rwg);var ole=function(g){var i=g.width,n=g.colors,I=g.onChange,r=g.onSwatchHover,o=g.triangle,C=g.styles,a=C===void 0?{}:C,A=g.className,s=A===void 0?"":A,l=dg(MC({default:{card:{width:i,background:"#fff",border:"1px solid rgba(0,0,0,0.2)",boxShadow:"0 3px 12px rgba(0,0,0,0.15)",borderRadius:"4px",position:"relative",padding:"5px",display:"flex",flexWrap:"wrap"},triangle:{position:"absolute",border:"7px solid transparent",borderBottomColor:"#fff"},triangleShadow:{position:"absolute",border:"8px solid transparent",borderBottomColor:"rgba(0,0,0,0.15)"}},"hide-triangle":{triangle:{display:"none"},triangleShadow:{display:"none"}},"top-left-triangle":{triangle:{top:"-14px",left:"10px"},triangleShadow:{top:"-16px",left:"9px"}},"top-right-triangle":{triangle:{top:"-14px",right:"10px"},triangleShadow:{top:"-16px",right:"9px"}},"bottom-left-triangle":{triangle:{top:"35px",left:"10px",transform:"rotate(180deg)"},triangleShadow:{top:"37px",left:"9px",transform:"rotate(180deg)"}},"bottom-right-triangle":{triangle:{top:"35px",right:"10px",transform:"rotate(180deg)"},triangleShadow:{top:"37px",right:"9px",transform:"rotate(180deg)"}}},a),{"hide-triangle":o==="hide","top-left-triangle":o==="top-left","top-right-triangle":o==="top-right","bottom-left-triangle":o==="bottom-left","bottom-right-triangle":o==="bottom-right"}),c=function(d,h){return I({hex:d,source:"hex"},h)};return k.createElement("div",{style:l.card,className:"github-picker "+s},k.createElement("div",{style:l.triangleShadow}),k.createElement("div",{style:l.triangle}),jm(n,function(u){return k.createElement(owg,{color:u,key:u,onClick:c,onSwatchHover:r})}))};ole.propTypes={width:L.oneOfType([L.string,L.number]),colors:L.arrayOf(L.string),triangle:L.oneOf(["hide","top-left","top-right","bottom-left","bottom-right"]),styles:L.object};ole.defaultProps={width:200,colors:["#B80000","#DB3E00","#FCCB00","#008B02","#006B76","#1273DE","#004DCF","#5300EB","#EB9694","#FAD0C3","#FEF3BD","#C1E1C5","#BEDADC","#C4DEF6","#BED3F3","#D4C4FB"],triangle:"top-left",styles:{}};zC(ole);var Cwg=function(g){var i=g.direction,n=dg({default:{picker:{width:"18px",height:"18px",borderRadius:"50%",transform:"translate(-9px, -1px)",backgroundColor:"rgb(248, 248, 248)",boxShadow:"0 1px 4px 0 rgba(0, 0, 0, 0.37)"}},vertical:{picker:{transform:"translate(-3px, -9px)"}}},{vertical:i==="vertical"});return k.createElement("div",{style:n.picker})},awg=Object.assign||function(e){for(var g=1;g.5});return k.createElement("div",{style:n.picker})},cwg=function(){var g=dg({default:{triangle:{width:0,height:0,borderStyle:"solid",borderWidth:"4px 0 4px 6px",borderColor:"transparent transparent transparent #fff",position:"absolute",top:"1px",left:"1px"},triangleBorder:{width:0,height:0,borderStyle:"solid",borderWidth:"5px 0 5px 8px",borderColor:"transparent transparent transparent #555"},left:{Extend:"triangleBorder",transform:"translate(-13px, -4px)"},leftInside:{Extend:"triangle",transform:"translate(-8px, -5px)"},right:{Extend:"triangleBorder",transform:"translate(20px, -14px) rotate(180deg)"},rightInside:{Extend:"triangle",transform:"translate(-8px, -5px)"}}});return k.createElement("div",{style:g.pointer},k.createElement("div",{style:g.left},k.createElement("div",{style:g.leftInside})),k.createElement("div",{style:g.right},k.createElement("div",{style:g.rightInside})))},dWe=function(g){var i=g.onClick,n=g.label,I=g.children,r=g.active,o=dg({default:{button:{backgroundImage:"linear-gradient(-180deg, #FFFFFF 0%, #E6E6E6 100%)",border:"1px solid #878787",borderRadius:"2px",height:"20px",boxShadow:"0 1px 0 0 #EAEAEA",fontSize:"14px",color:"#000",lineHeight:"20px",textAlign:"center",marginBottom:"10px",cursor:"pointer"}},active:{button:{boxShadow:"0 0 0 1px #878787"}}},{active:r});return k.createElement("div",{style:o.button,onClick:i},n||I)},uwg=function(g){var i=g.rgb,n=g.currentColor,I=dg({default:{swatches:{border:"1px solid #B3B3B3",borderBottom:"1px solid #F0F0F0",marginBottom:"2px",marginTop:"1px"},new:{height:"34px",background:"rgb("+i.r+","+i.g+", "+i.b+")",boxShadow:"inset 1px 0 0 #000, inset -1px 0 0 #000, inset 0 1px 0 #000"},current:{height:"34px",background:n,boxShadow:"inset 1px 0 0 #000, inset -1px 0 0 #000, inset 0 -1px 0 #000"},label:{fontSize:"14px",color:"#000",textAlign:"center"}}});return k.createElement("div",null,k.createElement("div",{style:I.label},"new"),k.createElement("div",{style:I.swatches},k.createElement("div",{style:I.new}),k.createElement("div",{style:I.current})),k.createElement("div",{style:I.label},"current"))},dwg=function(){function e(g,i){for(var n=0;n100&&(s.a=100),s.a/=100,i({h:I.h,s:I.s,l:I.l,a:s.a,source:"rgb"},l))};return k.createElement("div",{style:C.fields,className:"flexbox-fix"},k.createElement("div",{style:C.double},k.createElement(Jg,{style:{input:C.input,label:C.label},label:"hex",value:r.replace("#",""),onChange:a})),k.createElement("div",{style:C.single},k.createElement(Jg,{style:{input:C.input,label:C.label},label:"r",value:n.r,onChange:a,dragLabel:"true",dragMax:"255"})),k.createElement("div",{style:C.single},k.createElement(Jg,{style:{input:C.input,label:C.label},label:"g",value:n.g,onChange:a,dragLabel:"true",dragMax:"255"})),k.createElement("div",{style:C.single},k.createElement(Jg,{style:{input:C.input,label:C.label},label:"b",value:n.b,onChange:a,dragLabel:"true",dragMax:"255"})),k.createElement("div",{style:C.alpha},k.createElement(Jg,{style:{input:C.input,label:C.label},label:"a",value:Math.round(n.a*100),onChange:a,dragLabel:"true",dragMax:"100"})))},bwg=Object.assign||function(e){for(var g=1;g=0||Object.prototype.hasOwnProperty.call(e,n)&&(i[n]=e[n]);return i}var uY=24,Rwg=d$e.default=function(e){var g=e.fill,i=g===void 0?"currentColor":g,n=e.width,I=n===void 0?uY:n,r=e.height,o=r===void 0?uY:r,C=e.style,a=C===void 0?{}:C,A=Swg(e,["fill","width","height","style"]);return fWe.default.createElement("svg",hWe({viewBox:"0 0 "+uY+" "+uY,style:hWe({fill:i,width:I,height:o},a)},A),fWe.default.createElement("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"}))},Vwg=function(g){var i=g.color,n=g.onClick,I=n===void 0?function(){}:n,r=g.onSwatchHover,o=g.first,C=g.last,a=g.active,A=dg({default:{color:{width:"40px",height:"24px",cursor:"pointer",background:i,marginBottom:"1px"},check:{color:gle(i),marginLeft:"8px",display:"none"}},first:{color:{overflow:"hidden",borderRadius:"2px 2px 0 0"}},last:{color:{overflow:"hidden",borderRadius:"0 0 2px 2px"}},active:{check:{display:"block"}},"color-#FFFFFF":{color:{boxShadow:"inset 0 0 0 1px #ddd"},check:{color:"#333"}},transparent:{check:{color:"#333"}}},{first:o,last:C,active:a,"color-#FFFFFF":i==="#FFFFFF",transparent:i==="transparent"});return k.createElement(AZ,{color:i,style:A.color,onClick:I,onHover:r,focusStyle:{boxShadow:"0 0 4px "+i}},k.createElement("div",{style:A.check},k.createElement(Rwg,null)))},Wwg=function(g){var i=g.onClick,n=g.onSwatchHover,I=g.group,r=g.active,o=dg({default:{group:{paddingBottom:"10px",width:"40px",float:"left",marginRight:"10px"}}});return k.createElement("div",{style:o.group},jm(I,function(C,a){return k.createElement(Vwg,{key:C,color:C,active:C.toLowerCase()===r,first:a===0,last:a===I.length-1,onClick:i,onSwatchHover:n})}))},lle=function(g){var i=g.width,n=g.height,I=g.onChange,r=g.onSwatchHover,o=g.colors,C=g.hex,a=g.styles,A=a===void 0?{}:a,s=g.className,l=s===void 0?"":s,c=dg(MC({default:{picker:{width:i,height:n},overflow:{height:n,overflowY:"scroll"},body:{padding:"16px 0 6px 16px"},clear:{clear:"both"}}},A)),u=function(h,f){return I({hex:h,source:"hex"},f)};return k.createElement("div",{style:c.picker,className:"swatches-picker "+l},k.createElement(pH,null,k.createElement("div",{style:c.overflow},k.createElement("div",{style:c.body},jm(o,function(d){return k.createElement(Wwg,{key:d.toString(),group:d,active:C,onClick:u,onSwatchHover:r})}),k.createElement("div",{style:c.clear})))))};lle.propTypes={width:L.oneOfType([L.string,L.number]),height:L.oneOfType([L.string,L.number]),colors:L.arrayOf(L.arrayOf(L.string)),styles:L.object};lle.defaultProps={width:320,height:240,colors:[[XG[900],XG[700],XG[500],XG[300],XG[100]],[TG[900],TG[700],TG[500],TG[300],TG[100]],[HG[900],HG[700],HG[500],HG[300],HG[100]],[NG[900],NG[700],NG[500],NG[300],NG[100]],[kG[900],kG[700],kG[500],kG[300],kG[100]],[YG[900],YG[700],YG[500],YG[300],YG[100]],[KG[900],KG[700],KG[500],KG[300],KG[100]],[xG[900],xG[700],xG[500],xG[300],xG[100]],[FG[900],FG[700],FG[500],FG[300],FG[100]],["#194D33",UV[700],UV[500],UV[300],UV[100]],[EG[900],EG[700],EG[500],EG[300],EG[100]],[DG[900],DG[700],DG[500],DG[300],DG[100]],[MG[900],MG[700],MG[500],MG[300],MG[100]],[zG[900],zG[700],zG[500],zG[300],zG[100]],[PG[900],PG[700],PG[500],PG[300],PG[100]],[_G[900],_G[700],_G[500],_G[300],_G[100]],[OG[900],OG[700],OG[500],OG[300],OG[100]],[JG[900],JG[700],JG[500],JG[300],JG[100]],["#000000","#525252","#969696","#D9D9D9","#FFFFFF"]],styles:{}};zC(lle);var cle=function(g){var i=g.onChange,n=g.onSwatchHover,I=g.hex,r=g.colors,o=g.width,C=g.triangle,a=g.styles,A=a===void 0?{}:a,s=g.className,l=s===void 0?"":s,c=dg(MC({default:{card:{width:o,background:"#fff",border:"0 solid rgba(0,0,0,0.25)",boxShadow:"0 1px 4px rgba(0,0,0,0.25)",borderRadius:"4px",position:"relative"},body:{padding:"15px 9px 9px 15px"},label:{fontSize:"18px",color:"#fff"},triangle:{width:"0px",height:"0px",borderStyle:"solid",borderWidth:"0 9px 10px 9px",borderColor:"transparent transparent #fff transparent",position:"absolute"},triangleShadow:{width:"0px",height:"0px",borderStyle:"solid",borderWidth:"0 9px 10px 9px",borderColor:"transparent transparent rgba(0,0,0,.1) transparent",position:"absolute"},hash:{background:"#F0F0F0",height:"30px",width:"30px",borderRadius:"4px 0 0 4px",float:"left",color:"#98A1A4",display:"flex",alignItems:"center",justifyContent:"center"},input:{width:"100px",fontSize:"14px",color:"#666",border:"0px",outline:"none",height:"28px",boxShadow:"inset 0 0 0 1px #F0F0F0",boxSizing:"content-box",borderRadius:"0 4px 4px 0",float:"left",paddingLeft:"8px"},swatch:{width:"30px",height:"30px",float:"left",borderRadius:"4px",margin:"0 6px 6px 0"},clear:{clear:"both"}},"hide-triangle":{triangle:{display:"none"},triangleShadow:{display:"none"}},"top-left-triangle":{triangle:{top:"-10px",left:"12px"},triangleShadow:{top:"-11px",left:"12px"}},"top-right-triangle":{triangle:{top:"-10px",right:"12px"},triangleShadow:{top:"-11px",right:"12px"}}},A),{"hide-triangle":C==="hide","top-left-triangle":C==="top-left","top-right-triangle":C==="top-right"}),u=function(h,f){$m(h)&&i({hex:h,source:"hex"},f)};return k.createElement("div",{style:c.card,className:"twitter-picker "+l},k.createElement("div",{style:c.triangleShadow}),k.createElement("div",{style:c.triangle}),k.createElement("div",{style:c.body},jm(r,function(d,h){return k.createElement(AZ,{key:h,color:d,hex:d,style:c.swatch,onClick:u,onHover:n,focusStyle:{boxShadow:"0 0 4px "+d}})}),k.createElement("div",{style:c.hash},"#"),k.createElement(Jg,{label:null,style:{input:c.input},value:I.replace("#",""),onChange:u}),k.createElement("div",{style:c.clear})))};cle.propTypes={width:L.oneOfType([L.string,L.number]),triangle:L.oneOf(["hide","top-left","top-right"]),colors:L.arrayOf(L.string),styles:L.object};cle.defaultProps={width:276,colors:["#FF6900","#FCB900","#7BDCB5","#00D084","#8ED1FC","#0693E3","#ABB8C3","#EB144C","#F78DA7","#9900EF"],triangle:"top-left",styles:{}};zC(cle);var ule=function(g){var i=dg({default:{picker:{width:"20px",height:"20px",borderRadius:"22px",border:"2px #fff solid",transform:"translate(-12px, -13px)",background:"hsl("+Math.round(g.hsl.h)+", "+Math.round(g.hsl.s*100)+"%, "+Math.round(g.hsl.l*100)+"%)"}}});return k.createElement("div",{style:i.picker})};ule.propTypes={hsl:L.shape({h:L.number,s:L.number,l:L.number,a:L.number})};ule.defaultProps={hsl:{a:1,h:249.94,l:.2,s:.5}};var dle=function(g){var i=dg({default:{picker:{width:"20px",height:"20px",borderRadius:"22px",transform:"translate(-10px, -7px)",background:"hsl("+Math.round(g.hsl.h)+", 100%, 50%)",border:"2px white solid"}}});return k.createElement("div",{style:i.picker})};dle.propTypes={hsl:L.shape({h:L.number,s:L.number,l:L.number,a:L.number})};dle.defaultProps={hsl:{a:1,h:249.94,l:.2,s:.5}};var Xwg=function(g){var i=g.onChange,n=g.rgb,I=g.hsl,r=g.hex,o=g.hsv,C=function(u,d){if(u.hex)$m(u.hex)&&i({hex:u.hex,source:"hex"},d);else if(u.rgb){var h=u.rgb.split(",");rj(u.rgb,"rgb")&&i({r:h[0],g:h[1],b:h[2],a:1,source:"rgb"},d)}else if(u.hsv){var f=u.hsv.split(",");rj(u.hsv,"hsv")&&(f[2]=f[2].replace("%",""),f[1]=f[1].replace("%",""),f[0]=f[0].replace("°",""),f[1]==1?f[1]=.01:f[2]==1&&(f[2]=.01),i({h:Number(f[0]),s:Number(f[1]),v:Number(f[2]),source:"hsv"},d))}else if(u.hsl){var m=u.hsl.split(",");rj(u.hsl,"hsl")&&(m[2]=m[2].replace("%",""),m[1]=m[1].replace("%",""),m[0]=m[0].replace("°",""),l[1]==1?l[1]=.01:l[2]==1&&(l[2]=.01),i({h:Number(m[0]),s:Number(m[1]),v:Number(m[2]),source:"hsl"},d))}},a=dg({default:{wrap:{display:"flex",height:"100px",marginTop:"4px"},fields:{width:"100%"},column:{paddingTop:"10px",display:"flex",justifyContent:"space-between"},double:{padding:"0px 4.4px",boxSizing:"border-box"},input:{width:"100%",height:"38px",boxSizing:"border-box",padding:"4px 10% 3px",textAlign:"center",border:"1px solid #dadce0",fontSize:"11px",textTransform:"lowercase",borderRadius:"5px",outline:"none",fontFamily:"Roboto,Arial,sans-serif"},input2:{height:"38px",width:"100%",border:"1px solid #dadce0",boxSizing:"border-box",fontSize:"11px",textTransform:"lowercase",borderRadius:"5px",outline:"none",paddingLeft:"10px",fontFamily:"Roboto,Arial,sans-serif"},label:{textAlign:"center",fontSize:"12px",background:"#fff",position:"absolute",textTransform:"uppercase",color:"#3c4043",width:"35px",top:"-6px",left:"0",right:"0",marginLeft:"auto",marginRight:"auto",fontFamily:"Roboto,Arial,sans-serif"},label2:{left:"10px",textAlign:"center",fontSize:"12px",background:"#fff",position:"absolute",textTransform:"uppercase",color:"#3c4043",width:"32px",top:"-6px",fontFamily:"Roboto,Arial,sans-serif"},single:{flexGrow:"1",margin:"0px 4.4px"}}}),A=n.r+", "+n.g+", "+n.b,s=Math.round(I.h)+"°, "+Math.round(I.s*100)+"%, "+Math.round(I.l*100)+"%",l=Math.round(o.h)+"°, "+Math.round(o.s*100)+"%, "+Math.round(o.v*100)+"%";return k.createElement("div",{style:a.wrap,className:"flexbox-fix"},k.createElement("div",{style:a.fields},k.createElement("div",{style:a.double},k.createElement(Jg,{style:{input:a.input,label:a.label},label:"hex",value:r,onChange:C})),k.createElement("div",{style:a.column},k.createElement("div",{style:a.single},k.createElement(Jg,{style:{input:a.input2,label:a.label2},label:"rgb",value:A,onChange:C})),k.createElement("div",{style:a.single},k.createElement(Jg,{style:{input:a.input2,label:a.label2},label:"hsv",value:l,onChange:C})),k.createElement("div",{style:a.single},k.createElement(Jg,{style:{input:a.input2,label:a.label2},label:"hsl",value:s,onChange:C})))))},hle=function(g){var i=g.width,n=g.onChange,I=g.rgb,r=g.hsl,o=g.hsv,C=g.hex,a=g.header,A=g.styles,s=A===void 0?{}:A,l=g.className,c=l===void 0?"":l,u=dg(MC({default:{picker:{width:i,background:"#fff",border:"1px solid #dfe1e5",boxSizing:"initial",display:"flex",flexWrap:"wrap",borderRadius:"8px 8px 0px 0px"},head:{height:"57px",width:"100%",paddingTop:"16px",paddingBottom:"16px",paddingLeft:"16px",fontSize:"20px",boxSizing:"border-box",fontFamily:"Roboto-Regular,HelveticaNeue,Arial,sans-serif"},saturation:{width:"70%",padding:"0px",position:"relative",overflow:"hidden"},swatch:{width:"30%",height:"228px",padding:"0px",background:"rgba("+I.r+", "+I.g+", "+I.b+", 1)",position:"relative",overflow:"hidden"},body:{margin:"auto",width:"95%"},controls:{display:"flex",boxSizing:"border-box",height:"52px",paddingTop:"22px"},color:{width:"32px"},hue:{height:"8px",position:"relative",margin:"0px 16px 0px 16px",width:"100%"},Hue:{radius:"2px"}}},s));return k.createElement("div",{style:u.picker,className:"google-picker "+c},k.createElement("div",{style:u.head},a),k.createElement("div",{style:u.swatch}),k.createElement("div",{style:u.saturation},k.createElement(V_,{hsl:r,hsv:o,pointer:ule,onChange:n})),k.createElement("div",{style:u.body},k.createElement("div",{style:u.controls,className:"flexbox-fix"},k.createElement("div",{style:u.hue},k.createElement(rS,{style:u.Hue,hsl:r,radius:"4px",pointer:dle,onChange:n}))),k.createElement(Xwg,{rgb:I,hsl:r,hex:C,hsv:o,onChange:n})))};hle.propTypes={width:L.oneOfType([L.string,L.number]),styles:L.object,header:L.string};hle.defaultProps={width:652,styles:{},header:"Color picker"};zC(hle);function Twg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function mWe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function aD(e){return aD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},aD(e)}let h$e=function(e){Ywg(i,e);var g=Kwg(i);function i(n){var I;Twg(this,i),I=g.call(this,n);const r=OB(n.color);return I.state={displayColorPicker:!1,color:{r:r.r,g:r.g,b:r.b,a:r.opacity}},I}return Hwg(i,[{key:"handleClick",value:function(){this.setState(I=>({displayColorPicker:!I.displayColorPicker}))}},{key:"handleClose",value:function(){this.setState({displayColorPicker:!1})}},{key:"handleChange",value:function(I){const r=I.rgb,o=`rgba(${r.r},${r.g},${r.b},${r.a})`;this.props.onChange(o),this.setState({color:I.rgb})}},{key:"render",value:function(){const I=dg({default:{color:{width:"32px",height:"14px",borderRadius:"2px",background:`rgba(${this.state.color.r}, ${this.state.color.g}, ${this.state.color.b}, ${this.state.color.a})`},swatch:{padding:"5px",background:"#fff",cursor:"pointer",borderRadius:"1px"},popover:{position:"absolute",zIndex:"2"},cover:{position:"fixed",top:"0px",right:"0px",bottom:"0px",left:"0px"}}});return k.createElement("div",null,k.createElement("div",{onClick:this.handleClick.bind(this),style:I.swatch},k.createElement("div",{style:I.color})),this.state.displayColorPicker?k.createElement("div",{style:I.popover},k.createElement("div",{onClick:this.handleClose.bind(this),style:I.cover}),k.createElement(Zwg,{color:this.state.color,onChange:this.handleChange.bind(this)})):null)}}]),i}(k.Component);h$e.propTypes={color:L.string,onChange:L.func};function Dwg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function pWe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function sD(e){return sD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},sD(e)}let yge=function(e){_wg(i,e);var g=Owg(i);function i(n){var I;return Dwg(this,i),I=g.call(this,n),I.state={colors:n.track.options.colorRange.slice()},I}return Mwg(i,[{key:"handleColorsChanged",value:function(I){this.setState({colors:I})}},{key:"handleSubmit",value:function(){const I=this.props.track.options;I.colorRange=this.state.colors,this.props.onSubmit(this.props.track.options)}},{key:"handleAddColor",value:function(){this.setState(I=>({colors:I.colors.concat(I.colors[I.colors.length-1])}))}},{key:"handleRemoveColor",value:function(I){this.setState(r=>({colors:r.colors.slice(0,I).concat(r.colors.slice(I+1))}))}},{key:"render",value:function(){const I=JSON.parse(JSON.stringify(this.props.track)),r=Object.assign(I,{options:{colorRange:this.state.colors}}),o={editable:!1,zoomFixed:!0,views:[{uid:`hmo-${this.props.track.uid}`,initialXDomain:this.props.xScale?this.props.xScale.domain():[0,1],initialYDomain:this.props.yScale?this.props.yScale.domain():[0,1],tracks:{center:[r]},layout:{x:0,y:0,h:12,w:12,i:`hmo-${this.props.track.id}`}}]},C=this.state.colors.map((A,s)=>{const l=this.state.colors.length>2&&s===this.state.colors.length-1?k.createElement("div",{onClick:()=>this.handleRemoveColor(s),style:{background:"white",position:"absolute",top:0,right:0,opacity:1,width:14,height:14,borderRadius:2,cursor:"pointer"}},k.createElement("svg",{height:"10px",style:{position:"absolute",top:2,right:2,opacity:.5,width:10,height:10}},k.createElement("use",{xlinkHref:"#cross"}))):null;return k.createElement("div",{key:`l${s}`,style:{borderRadius:"1px",boxShadow:"0 0 0 1px #E5E5E5",position:"relative",outline:"none"}},l,k.createElement(h$e,{key:s,color:this.state.colors[s],onChange:c=>{this.setState(u=>{const d=u.colors.slice();return d[s]=c,{colors:d}},()=>{this.handleColorsChanged(this.state.colors)})}}))}).reverse(),a=this.state.colors.length<10?k.createElement("div",{onClick:this.handleAddColor.bind(this),style:{position:"relative",outline:"none",height:"25px",padding:"5px",background:"#fff",borderRadius:"1px",boxShadow:"0 0 0 1px #E5E5E5",cursor:"pointer"}},k.createElement("div",{style:{textAlign:"center",width:"32px",height:"14px"}},k.createElement("svg",{height:"100%",style:{opacity:.5,margin:"auto",display:"block"},width:"10px"},k.createElement("use",{xlinkHref:"#plus"})))):null;return k.createElement(aH,{okayTitle:"Submit",onCancel:this.props.onCancel,onOkay:this.handleSubmit.bind(this),title:"Custom Color Map"},k.createElement("table",{className:"table-track-options"},k.createElement("thead",null),k.createElement("tbody",{style:{verticalAlign:"top"}},k.createElement("tr",null,k.createElement("td",{className:"td-track-options"},k.createElement("table",null,k.createElement("tbody",null,k.createElement("tr",null,k.createElement("td",{className:"td-track-options"},"Preview")),k.createElement("tr",null,k.createElement("td",{className:"td-track-options"},k.createElement("div",{style:{width:200}},k.createElement(CS,{options:{bounded:!1},viewConfig:o}))))))),k.createElement("td",{className:"td-track-options"},k.createElement("table",null,k.createElement("tbody",null,k.createElement("tr",null,k.createElement("td",{className:"td-track-options"},"Colors")),k.createElement("tr",null,k.createElement("td",{className:"td-track-options"},a,k.createElement("div",{style:{position:"relative"}},C))))))))))}}]),i}(k.Component);yge.propTypes={handleCancel:L.func,onCancel:L.func,onSubmit:L.func,track:L.object,xScale:L.object,yScale:L.object};const bWe=e=>{if(!e.header)return[];const g=e.header.split(" "),i=[];for(let n=0;ne.reduce((n,I)=>(n[I]={name:`${I*i}${g}`,value:I},n),{}),JC={yes:{name:"Yes",value:!0},no:{name:"No",value:!1}},pn={black:{name:"Black",value:"black"},blue:{name:"Blue",value:"blue"},brown:{name:"Brown",value:"brown"},cyan:{name:"Cyan",value:"cyan"},green:{name:"Green",value:"green"},grey:{name:"Grey",value:"grey"},orange:{name:"Orange",value:"orange"},purple:{name:"Purple",value:"purple"},turquoise:{name:"Turquoise",value:"turquoise"},red:{name:"Red",value:"red"},white:{name:"White",value:"white"}},Qwg={use_stroke:{name:"Glyph color",value:"[glyph-color]"}},QV=Nw([1,2,3,5,8,13,21]),jwg=Object.assign(QV,{none:{name:"none",value:"none"}}),dY=Nw([0,2,4,8,16,32,64,128,256]),Xh=Nw([0,.2,.4,.6,.8,1],"%",100),$wg=Nw([.2,.4,.6,.8,1],"%",100),rr={axisLabelFormatting:{name:"Axis Label Formatting",inlineOptions:{normal:{name:"normal",value:"normal"},scientific:{name:"scientific",value:"scientific"}}},flipDiagonal:{name:"Flip Across Diagonal",inlineOptions:{none:{name:"No",value:"none"},yes:{name:"Yes",value:"yes"},copy:{name:"Copy",value:"copy"}}},heatmapValueScaling:{name:"Value Scaling",inlineOptions:{linear:{name:"Linear",value:"linear"},log:{name:"Log",value:"log"}}},valueScaling:{name:"Value Scaling",inlineOptions:{linear:{name:"Linear",value:"linear"},log:{name:"Log",value:"log"}}},extent:{name:"Extent",inlineOptions:{full:{name:"Full",value:"full"},upperRight:{name:"Upper Right",value:"upper-right"},lowerLeft:{name:"Lower Left",value:"lower-left"}}},labelLeftMargin:{name:"Label Left Margin",inlineOptions:dY},labelRightMargin:{name:"Label Right Margin",inlineOptions:dY},labelTopMargin:{name:"Label Top Margin",inlineOptions:dY},labelBottomMargin:{name:"Label Bottom Margin",inlineOptions:dY},labelShowResolution:{name:"Label Show Resolution",inlineOptions:JC},labelShowAssembly:{name:"Label Show Assembly",inlineOptions:JC},lineStrokeWidth:{name:"Stroke Width",inlineOptions:QV},strokeWidth:{name:"Stroke Width",inlineOptions:QV},trackBorderWidth:{name:"Track Border Width",inlineOptions:QV},separatePlusMinusStrands:{name:"Separate +/- strands",inlineOptions:JC},sortLargestOnTop:{name:"Sort Largest On Top",inlineOptions:JC},showTexts:{name:"Show texts",inlineOptions:JC},staggered:{name:"Staggered",inlineOptions:JC},minSquareSize:{name:"Minimum size",inlineOptions:jwg},pointSize:{name:"Point Size",inlineOptions:QV},pointColor:{name:"Point Color",inlineOptions:pn},trackBorderColor:{name:"Track Border Color",inlineOptions:pn},backgroundColor:{name:"Background Color",inlineOptions:{white:{name:"White",value:"white"},lightGrey:{name:"Light Grey",value:"#eeeeee"},grey:{name:"Grey",value:"#cccccc"},black:{name:"Black",value:"black"},transparent:{name:"Transparent",value:"transparent"}}},colorScale:{name:"Color Scale",inlineOptions:{epilogos:{name:"Epilogos",values:["#FF0000","#FF4500","#32CD32","#008000","#006400","#C2E105","#FFFF00","#66CDAA","#8A91D0","#CD5C5C","#E9967A","#BDB76B","#808080","#C0C0C0","#FFFFFF"]},category10:{name:"D3 Category10",values:["#1F77B4","#FF7F0E","#2CA02C","#D62728","#9467BD","#8C564B","#E377C2","#7F7F7F","#BCBD22","#17BECF"]}}},minusStrandColor:{name:"- Strand Color",inlineOptions:pn},plusStrandColor:{name:"+ Strand Color",inlineOptions:pn},lineStrokeColor:{name:"Stroke color",inlineOptions:pn},projectionStrokeColor:{name:"Stroke color",inlineOptions:pn},projectionFillColor:{name:"Fill color",inlineOptions:pn},stroke:{name:"Stroke Color",inlineOptions:pn},strokeColor:{name:"Stroke color",inlineOptions:pn},fill:{name:"Fill Color",inlineOptions:pn},color:{name:"Color",inlineOptions:pn},fontColor:{name:"Font color",inlineOptions:pn},fillColor:{name:"Fill color",inlineOptions:pn},barFillColor:{name:"Fill color",inlineOptions:pn},barFillColorTop:{name:"Top Fill color",inlineOptions:pn},barFillColorBottom:{name:"Bottom Fill color",inlineOptions:pn},barOpacity:{name:"Bar opacity",inlineOptions:Xh},zeroLineVisible:{name:"Zero line visible",inlineOptions:JC},zeroLineColor:{name:"Zero line color",inlineOptions:pn},zeroLineOpacity:{name:"Zero line opacity",inlineOptions:$wg},fillOpacity:{name:"Fill Opacity",inlineOptions:Xh},strokeOpacity:{name:"Stroke Opacity",inlineOptions:Xh},strokePos:{name:"Stroke Position",inlineOptions:{aroundInner:{name:"Around Inner",value:"around"},aroundCenter:{name:"Around Center",value:null},hidden:{name:"Hidden",value:"hidden"},top:{name:"Top",value:"top"},right:{name:"Right",value:"right"},bottom:{name:"Bottom",value:"bottom"},left:{name:"Left",value:"left"}}},barBorder:{name:"Bar border",inlineOptions:JC},scaledHeight:{name:"Scaled height",inlineOptions:JC},rectangleDomainStrokeColor:{name:"Stroke color",inlineOptions:pn},rectangleDomainFillColor:{name:"Fill color",inlineOptions:pn},rectangleDomainFillOpacity:{name:"Fill opacity",inlineOptions:Xh},rectangleDomainOpacity:{name:"Opacity",inlineOptions:Xh},mapboxStyle:{name:"Map style",inlineOptions:{streets:{name:"streets",value:"mapbox.streets"},light:{name:"light",value:"mapbox.light"},dark:{name:"dark",value:"mapbox.dark"},satellite:{name:"satellite",value:"mapbox.satellite"},"streets-satellite":{name:"streets-satellite",value:"mapbox.streets-satellite"},wheatpaste:{name:"wheatpaste",value:"mapbox.wheatpaste"},"streets-basic":{name:"streets-basic",value:"mapbox.streets-basic"},comic:{name:"comic",value:"mapbox.comic"},outdoors:{name:"outdoors",value:"mapbox.outdoors"},"run-bike-hike":{name:"run-bike-hike",value:"mapbox.run-bike-hike"},pencil:{name:"pencil",value:"mapbox.pencil"},pirates:{name:"pirates",value:"mapbox.pirates"},emerald:{name:"emerald",value:"mapbox.emerald"},"high-contrast":{name:"high-contrast",value:"mapbox.high-contrast"}}},oneDHeatmapFlipped:{name:"Flip Heatmap",inlineOptions:{yes:{name:"Yes",value:"yes"},no:{name:"No",value:null}}},showMousePosition:{name:"Show Mouse Position",inlineOptions:JC},showTooltip:{name:"Show Tooltip",inlineOptions:JC},fontSize:{name:"Font Size",inlineOptions:Nw([8,9,10,11,12,14,16,18,24],"px")},tickPositions:{name:"Tick Positions",inlineOptions:{even:{name:"Even",value:"even"},ends:{name:"Ends",value:"ends"}}},tickFormat:{name:"Tick Format",inlineOptions:{plain:{name:"Plain",value:"plain"},si:{name:"SI",value:"si"}}},colorEncoding:{name:"Color Encode Annotations",inlineOptions:{none:{name:"None",value:null},itemRgb:{name:"itemRgb",value:"itemRgb"}},generateOptions:bWe},fontIsAligned:{name:"Left-Align Font",inlineOptions:JC},axisPositionHorizontal:{name:"Axis Position",inlineOptions:{left:{name:"Left",value:"left"},outsideLeft:{name:"Outside left",value:"outsideLeft"},right:{name:"Right",value:"right"},outsideRight:{name:"Outside right",value:"outsideRight"},hidden:{name:"Hidden",value:null}}},axisPositionVertical:{name:"Axis Position",inlineOptions:{top:{name:"Top",value:"top"},outsideTop:{name:"Outside top",value:"outsideTop"},bottom:{name:"Bottom",value:"bottom"},outsideBottom:{name:"Outside bottom",value:"outsideBottom"},hidden:{name:"Hidden",value:null}}},axisMargin:{name:"Axis Margin",inlineOptions:Nw([0,10,20,30,40,50,100,200,400],"px")},colorbarPosition:{name:"Colorbar Position",inlineOptions:{topLeft:{name:"Top Left",value:"topLeft"},topRight:{name:"Top Right",value:"topRight"},bottomLeft:{name:"Bottom Left",value:"bottomLeft"},bottomRight:{name:"Bottom Right",value:"bottomRight"},hidden:{name:"Hidden",value:null}}},colorbarBackgroundColor:{name:"Colorbar Background Color",inlineOptions:pn},colorbarBackgroundOpacity:{name:"Colorbar Background Opacity",inlineOptions:Xh},colorbarLabelsPosition:{name:"Colorbar Labels Position",inlineOptions:{inside:{name:"Inside",value:"inside"},outside:{name:"Outside",value:"outside"}}},labelColor:{name:"Label Color",inlineOptions:{...pn,...Qwg}},labelPosition:{name:"Label Position",inlineOptions:{ol:{name:"Outer left",value:"outerLeft"},or:{name:"Outer right",value:"outerRight"},ot:{name:"Outer top",value:"outerTop"},ob:{name:"Outer bottom",value:"outerBottom"},tl:{name:"Top left",value:"topLeft"},tr:{name:"Top right",value:"topRight"},bl:{name:"Bottom left",value:"bottomLeft"},br:{name:"Bottom right",value:"bottomRight"},hidden:{name:"Hidden",value:"hidden"}}},labelTextOpacity:{name:"Label Text Opacity",inlineOptions:Xh},geneAnnotationHeight:{name:"Gene Annotation Height",inlineOptions:{8:{name:"8px",value:8},10:{name:"10px",value:10},12:{name:"12px",value:12},16:{name:"16px",value:16}}},annotationHeight:{name:"Annotation Height",inlineOptions:{5:{name:"5px",value:5},8:{name:"8px",value:8},10:{name:"10px",value:10},12:{name:"12px",value:12},16:{name:"16px",value:16},20:{name:"20px",value:20},scaled:{name:"scaled",value:"scaled"}}},maxAnnotationHeight:{name:"Max Annotation Height",inlineOptions:{5:{name:"5px",value:5},8:{name:"8px",value:8},10:{name:"10px",value:10},12:{name:"12px",value:12},16:{name:"16px",value:16},20:{name:"20px",value:20},none:{name:"none",value:null}}},annotationStyle:{name:"Annotation Style",inlineOptions:{box:{name:"Box",value:"box"},segment:{name:"Segment",value:"segment"}}},geneLabelPosition:{name:"Gene Label Position",inlineOptions:{inside:{name:"Inside",value:"inside"},outside:{name:"Outside",value:"outside"}}},geneStrandSpacing:{name:"Gene Strand Spacing",inlineOptions:{2:{name:"2px",value:2},4:{name:"4px",value:4},8:{name:"8px",value:8}}},labelBackgroundColor:{name:"Label Background Color",inlineOptions:pn},labelBackgroundOpacity:{name:"Label Background Opacity",inlineOptions:Xh},viewResolution:{name:"View Resolution",inlineOptions:{high:{name:"High",value:384},medium:{name:"Medium",value:1024},low:{name:"Low",value:2048}}},colorRange:{name:"Color map",inlineOptions:{afmhot:{name:"afmhot",value:["rgba(0,0,0,1.0)","rgba(128,0,0,1.0)","rgba(256,129,1,1.0)","rgba(256,256,129,1.0)","rgba(256,256,256,1.0)"]},fall:{name:"fall",value:["white","rgba(245,166,35,1.0)","rgba(208,2,27,1.0)","black"]},hot:{name:"hot",value:["rgba(10,0,0,1.0)","rgba(179,0,0,1.0)","rgba(256,91,0,1.0)","rgba(256,256,6,1.0)","rgba(256,256,256,1.0)"]},jet:{name:"jet",value:["rgba(0,0,128,1.0)","rgba(0,129,256,1.0)","rgba(125,256,122,1.0)","rgba(256,148,0,1.0)","rgba(128,0,0,1.0)"]},bwr:{name:"bwr",value:["rgba(0,0,256,1.0)","rgba(128,128,256,1.0)","rgba(256,254,254,1.0)","rgba(256,126,126,1.0)","rgba(256,0,0,1.0)"]},cubehelix:{name:"cubehelix",value:["rgba(0,0,0,1.0)","rgba(21,83,76,1.0)","rgba(162,121,74,1.0)","rgba(199,180,238,1.0)","rgba(256,256,256,1.0)"]},rainbow:{name:"rainbow",value:["rgba(128,0,256,1.0)","rgba(0,181,236,1.0)","rgba(129,255,180,1.0)","rgba(256,179,96,1.0)","rgba(256,0,0,1.0)"]},gray:{name:"greys",value:["rgba(255,255,255,1)","rgba(0,0,0,1)"]},red:{name:"White to red",value:["rgba(255,255,255,1)","rgba(255,0,0,1)"]},green:{name:"White to green",value:["rgba(255,255,255,1)","rgba(0,255,0,1)"]},blue:{name:"White to blue",value:["rgba(255,255,255,1)","rgba(0,0,255,1)"]},custard:{name:"custard",value:["#FFFFFF","#F8E71C","rgba(245,166,35,1)","rgba(0,0,0,1)"]},magma:{name:"magma",value:["rgba(0,0,3,1)","rgba(0,0,4,1)","rgba(0,0,6,1)","rgba(1,0,7,1)","rgba(1,1,9,1)","rgba(1,1,11,1)","rgba(2,2,13,1)","rgba(2,2,15,1)","rgba(3,3,17,1)","rgba(4,3,19,1)","rgba(4,4,21,1)","rgba(5,4,23,1)","rgba(6,5,25,1)","rgba(7,5,27,1)","rgba(8,6,29,1)","rgba(9,7,32,1)","rgba(10,7,34,1)","rgba(11,8,36,1)","rgba(12,9,38,1)","rgba(13,10,40,1)","rgba(14,10,42,1)","rgba(15,11,45,1)","rgba(16,12,47,1)","rgba(17,12,49,1)","rgba(19,13,51,1)","rgba(20,13,54,1)","rgba(21,14,56,1)","rgba(22,14,58,1)","rgba(23,15,61,1)","rgba(25,15,63,1)","rgba(26,16,66,1)","rgba(27,16,68,1)","rgba(28,16,70,1)","rgba(30,17,73,1)","rgba(31,17,75,1)","rgba(33,17,78,1)","rgba(34,17,80,1)","rgba(36,17,83,1)","rgba(37,17,85,1)","rgba(39,17,87,1)","rgba(40,17,90,1)","rgba(42,17,92,1)","rgba(43,17,94,1)","rgba(45,17,97,1)","rgba(47,16,99,1)","rgba(49,16,101,1)","rgba(50,16,103,1)","rgba(52,16,105,1)","rgba(54,15,107,1)","rgba(55,15,108,1)","rgba(57,15,110,1)","rgba(59,15,112,1)","rgba(61,15,113,1)","rgba(62,15,114,1)","rgba(64,15,116,1)","rgba(66,15,117,1)","rgba(67,15,118,1)","rgba(69,15,119,1)","rgba(71,15,120,1)","rgba(72,16,120,1)","rgba(74,16,121,1)","rgba(76,16,122,1)","rgba(77,17,123,1)","rgba(79,17,123,1)","rgba(81,18,124,1)","rgba(82,18,124,1)","rgba(84,19,125,1)","rgba(85,20,125,1)","rgba(87,20,126,1)","rgba(88,21,126,1)","rgba(90,21,126,1)","rgba(92,22,127,1)","rgba(93,23,127,1)","rgba(95,23,127,1)","rgba(96,24,128,1)","rgba(98,25,128,1)","rgba(99,25,128,1)","rgba(101,26,128,1)","rgba(103,26,128,1)","rgba(104,27,129,1)","rgba(106,28,129,1)","rgba(107,28,129,1)","rgba(109,29,129,1)","rgba(110,30,129,1)","rgba(112,30,129,1)","rgba(113,31,129,1)","rgba(115,32,129,1)","rgba(117,32,129,1)","rgba(118,33,129,1)","rgba(120,33,129,1)","rgba(121,34,130,1)","rgba(123,35,130,1)","rgba(124,35,130,1)","rgba(126,36,130,1)","rgba(128,36,130,1)","rgba(129,37,129,1)","rgba(131,37,129,1)","rgba(132,38,129,1)","rgba(134,39,129,1)","rgba(136,39,129,1)","rgba(137,40,129,1)","rgba(139,40,129,1)","rgba(140,41,129,1)","rgba(142,41,129,1)","rgba(144,42,129,1)","rgba(145,42,129,1)","rgba(147,43,128,1)","rgba(148,43,128,1)","rgba(150,44,128,1)","rgba(152,44,128,1)","rgba(153,45,128,1)","rgba(155,46,127,1)","rgba(157,46,127,1)","rgba(158,47,127,1)","rgba(160,47,127,1)","rgba(161,48,126,1)","rgba(163,48,126,1)","rgba(165,49,126,1)","rgba(166,49,125,1)","rgba(168,50,125,1)","rgba(170,50,125,1)","rgba(171,51,124,1)","rgba(173,51,124,1)","rgba(175,52,123,1)","rgba(176,52,123,1)","rgba(178,53,123,1)","rgba(180,53,122,1)","rgba(181,54,122,1)","rgba(183,55,121,1)","rgba(185,55,121,1)","rgba(186,56,120,1)","rgba(188,56,120,1)","rgba(189,57,119,1)","rgba(191,57,118,1)","rgba(193,58,118,1)","rgba(194,59,117,1)","rgba(196,59,117,1)","rgba(198,60,116,1)","rgba(199,61,115,1)","rgba(201,61,115,1)","rgba(202,62,114,1)","rgba(204,63,113,1)","rgba(206,63,113,1)","rgba(207,64,112,1)","rgba(209,65,111,1)","rgba(210,66,110,1)","rgba(212,67,110,1)","rgba(213,67,109,1)","rgba(215,68,108,1)","rgba(216,69,107,1)","rgba(218,70,107,1)","rgba(219,71,106,1)","rgba(221,72,105,1)","rgba(222,73,104,1)","rgba(223,74,103,1)","rgba(225,75,103,1)","rgba(226,76,102,1)","rgba(227,78,101,1)","rgba(229,79,100,1)","rgba(230,80,100,1)","rgba(231,81,99,1)","rgba(232,83,98,1)","rgba(233,84,97,1)","rgba(234,85,97,1)","rgba(236,87,96,1)","rgba(237,88,95,1)","rgba(238,90,95,1)","rgba(239,91,94,1)","rgba(239,93,94,1)","rgba(240,95,93,1)","rgba(241,96,93,1)","rgba(242,98,93,1)","rgba(243,100,92,1)","rgba(243,101,92,1)","rgba(244,103,92,1)","rgba(245,105,92,1)","rgba(246,107,92,1)","rgba(246,108,92,1)","rgba(247,110,92,1)","rgba(247,112,92,1)","rgba(248,114,92,1)","rgba(248,116,92,1)","rgba(249,118,92,1)","rgba(249,120,92,1)","rgba(250,121,93,1)","rgba(250,123,93,1)","rgba(250,125,94,1)","rgba(251,127,94,1)","rgba(251,129,95,1)","rgba(251,131,95,1)","rgba(252,133,96,1)","rgba(252,135,97,1)","rgba(252,137,97,1)","rgba(252,139,98,1)","rgba(253,140,99,1)","rgba(253,142,100,1)","rgba(253,144,101,1)","rgba(253,146,102,1)","rgba(253,148,103,1)","rgba(254,150,104,1)","rgba(254,152,105,1)","rgba(254,154,106,1)","rgba(254,156,107,1)","rgba(254,157,108,1)","rgba(254,159,109,1)","rgba(254,161,110,1)","rgba(254,163,111,1)","rgba(254,165,112,1)","rgba(255,167,114,1)","rgba(255,169,115,1)","rgba(255,171,116,1)","rgba(255,172,118,1)","rgba(255,174,119,1)","rgba(255,176,120,1)","rgba(255,178,122,1)","rgba(255,180,123,1)","rgba(255,182,124,1)","rgba(255,184,126,1)","rgba(255,185,127,1)","rgba(255,187,129,1)","rgba(255,189,130,1)","rgba(255,191,132,1)","rgba(255,193,133,1)","rgba(255,195,135,1)","rgba(255,197,136,1)","rgba(255,198,138,1)","rgba(255,200,140,1)","rgba(255,202,141,1)","rgba(255,204,143,1)","rgba(254,206,144,1)","rgba(254,208,146,1)","rgba(254,209,148,1)","rgba(254,211,149,1)","rgba(254,213,151,1)","rgba(254,215,153,1)","rgba(254,217,155,1)","rgba(254,219,156,1)","rgba(254,220,158,1)","rgba(254,222,160,1)","rgba(254,224,162,1)","rgba(254,226,163,1)","rgba(253,228,165,1)","rgba(253,230,167,1)","rgba(253,231,169,1)","rgba(253,233,171,1)","rgba(253,235,172,1)","rgba(253,237,174,1)","rgba(253,239,176,1)","rgba(253,241,178,1)","rgba(253,242,180,1)","rgba(253,244,182,1)","rgba(253,246,184,1)","rgba(252,248,186,1)","rgba(252,250,188,1)","rgba(252,251,189,1)","rgba(252,253,191,1)"]},viridis:{name:"viridis",value:["rgba(68,1,84,1)","rgba(68,2,85,1)","rgba(69,3,87,1)","rgba(69,5,88,1)","rgba(69,6,90,1)","rgba(70,8,91,1)","rgba(70,9,93,1)","rgba(70,11,94,1)","rgba(70,12,96,1)","rgba(71,14,97,1)","rgba(71,15,98,1)","rgba(71,17,100,1)","rgba(71,18,101,1)","rgba(71,20,102,1)","rgba(72,21,104,1)","rgba(72,22,105,1)","rgba(72,24,106,1)","rgba(72,25,108,1)","rgba(72,26,109,1)","rgba(72,28,110,1)","rgba(72,29,111,1)","rgba(72,30,112,1)","rgba(72,32,113,1)","rgba(72,33,115,1)","rgba(72,34,116,1)","rgba(72,36,117,1)","rgba(72,37,118,1)","rgba(72,38,119,1)","rgba(72,39,120,1)","rgba(71,41,121,1)","rgba(71,42,121,1)","rgba(71,43,122,1)","rgba(71,44,123,1)","rgba(71,46,124,1)","rgba(70,47,125,1)","rgba(70,48,126,1)","rgba(70,49,126,1)","rgba(70,51,127,1)","rgba(69,52,128,1)","rgba(69,53,129,1)","rgba(69,54,129,1)","rgba(68,56,130,1)","rgba(68,57,131,1)","rgba(68,58,131,1)","rgba(67,59,132,1)","rgba(67,60,132,1)","rgba(67,62,133,1)","rgba(66,63,133,1)","rgba(66,64,134,1)","rgba(65,65,134,1)","rgba(65,66,135,1)","rgba(65,67,135,1)","rgba(64,69,136,1)","rgba(64,70,136,1)","rgba(63,71,136,1)","rgba(63,72,137,1)","rgba(62,73,137,1)","rgba(62,74,137,1)","rgba(61,75,138,1)","rgba(61,77,138,1)","rgba(60,78,138,1)","rgba(60,79,138,1)","rgba(59,80,139,1)","rgba(59,81,139,1)","rgba(58,82,139,1)","rgba(58,83,139,1)","rgba(57,84,140,1)","rgba(57,85,140,1)","rgba(56,86,140,1)","rgba(56,87,140,1)","rgba(55,88,140,1)","rgba(55,89,140,1)","rgba(54,91,141,1)","rgba(54,92,141,1)","rgba(53,93,141,1)","rgba(53,94,141,1)","rgba(52,95,141,1)","rgba(52,96,141,1)","rgba(51,97,141,1)","rgba(51,98,141,1)","rgba(51,99,141,1)","rgba(50,100,142,1)","rgba(50,101,142,1)","rgba(49,102,142,1)","rgba(49,103,142,1)","rgba(48,104,142,1)","rgba(48,105,142,1)","rgba(47,106,142,1)","rgba(47,107,142,1)","rgba(47,108,142,1)","rgba(46,109,142,1)","rgba(46,110,142,1)","rgba(45,111,142,1)","rgba(45,112,142,1)","rgba(45,112,142,1)","rgba(44,113,142,1)","rgba(44,114,142,1)","rgba(43,115,142,1)","rgba(43,116,142,1)","rgba(43,117,142,1)","rgba(42,118,142,1)","rgba(42,119,142,1)","rgba(41,120,142,1)","rgba(41,121,142,1)","rgba(41,122,142,1)","rgba(40,123,142,1)","rgba(40,124,142,1)","rgba(40,125,142,1)","rgba(39,126,142,1)","rgba(39,127,142,1)","rgba(38,128,142,1)","rgba(38,129,142,1)","rgba(38,130,142,1)","rgba(37,131,142,1)","rgba(37,131,142,1)","rgba(37,132,142,1)","rgba(36,133,142,1)","rgba(36,134,142,1)","rgba(35,135,142,1)","rgba(35,136,142,1)","rgba(35,137,142,1)","rgba(34,138,141,1)","rgba(34,139,141,1)","rgba(34,140,141,1)","rgba(33,141,141,1)","rgba(33,142,141,1)","rgba(33,143,141,1)","rgba(32,144,141,1)","rgba(32,145,140,1)","rgba(32,146,140,1)","rgba(32,147,140,1)","rgba(31,147,140,1)","rgba(31,148,140,1)","rgba(31,149,139,1)","rgba(31,150,139,1)","rgba(31,151,139,1)","rgba(30,152,139,1)","rgba(30,153,138,1)","rgba(30,154,138,1)","rgba(30,155,138,1)","rgba(30,156,137,1)","rgba(30,157,137,1)","rgba(30,158,137,1)","rgba(30,159,136,1)","rgba(30,160,136,1)","rgba(31,161,136,1)","rgba(31,162,135,1)","rgba(31,163,135,1)","rgba(31,163,134,1)","rgba(32,164,134,1)","rgba(32,165,134,1)","rgba(33,166,133,1)","rgba(33,167,133,1)","rgba(34,168,132,1)","rgba(35,169,131,1)","rgba(35,170,131,1)","rgba(36,171,130,1)","rgba(37,172,130,1)","rgba(38,173,129,1)","rgba(39,174,129,1)","rgba(40,175,128,1)","rgba(41,175,127,1)","rgba(42,176,127,1)","rgba(43,177,126,1)","rgba(44,178,125,1)","rgba(46,179,124,1)","rgba(47,180,124,1)","rgba(48,181,123,1)","rgba(50,182,122,1)","rgba(51,183,121,1)","rgba(53,183,121,1)","rgba(54,184,120,1)","rgba(56,185,119,1)","rgba(57,186,118,1)","rgba(59,187,117,1)","rgba(61,188,116,1)","rgba(62,189,115,1)","rgba(64,190,114,1)","rgba(66,190,113,1)","rgba(68,191,112,1)","rgba(70,192,111,1)","rgba(72,193,110,1)","rgba(73,194,109,1)","rgba(75,194,108,1)","rgba(77,195,107,1)","rgba(79,196,106,1)","rgba(81,197,105,1)","rgba(83,198,104,1)","rgba(85,198,102,1)","rgba(88,199,101,1)","rgba(90,200,100,1)","rgba(92,201,99,1)","rgba(94,201,98,1)","rgba(96,202,96,1)","rgba(98,203,95,1)","rgba(101,204,94,1)","rgba(103,204,92,1)","rgba(105,205,91,1)","rgba(108,206,90,1)","rgba(110,206,88,1)","rgba(112,207,87,1)","rgba(115,208,85,1)","rgba(117,208,84,1)","rgba(119,209,82,1)","rgba(122,210,81,1)","rgba(124,210,79,1)","rgba(127,211,78,1)","rgba(129,212,76,1)","rgba(132,212,75,1)","rgba(134,213,73,1)","rgba(137,213,72,1)","rgba(139,214,70,1)","rgba(142,215,68,1)","rgba(144,215,67,1)","rgba(147,216,65,1)","rgba(149,216,63,1)","rgba(152,217,62,1)","rgba(155,217,60,1)","rgba(157,218,58,1)","rgba(160,218,57,1)","rgba(163,219,55,1)","rgba(165,219,53,1)","rgba(168,220,51,1)","rgba(171,220,50,1)","rgba(173,221,48,1)","rgba(176,221,46,1)","rgba(179,221,45,1)","rgba(181,222,43,1)","rgba(184,222,41,1)","rgba(187,223,39,1)","rgba(189,223,38,1)","rgba(192,223,36,1)","rgba(195,224,35,1)","rgba(197,224,33,1)","rgba(200,225,32,1)","rgba(203,225,30,1)","rgba(205,225,29,1)","rgba(208,226,28,1)","rgba(211,226,27,1)","rgba(213,226,26,1)","rgba(216,227,25,1)","rgba(219,227,24,1)","rgba(221,227,24,1)","rgba(224,228,24,1)","rgba(226,228,24,1)","rgba(229,228,24,1)","rgba(232,229,25,1)","rgba(234,229,25,1)","rgba(237,229,26,1)","rgba(239,230,27,1)","rgba(242,230,28,1)","rgba(244,230,30,1)","rgba(247,230,31,1)","rgba(249,231,33,1)","rgba(251,231,35,1)","rgba(254,231,36,1)"]},custom:{name:"Custom...",componentPickers:{heatmap:yge,"horizontal-heatmap":yge}}}},align:{name:"Align",inlineOptions:{white:{name:"Top",value:"top"},lightGrey:{name:"Bottom",value:"bottom"}}},colorRangeGradient:{name:"Color Gradient",inlineOptions:JC},dataTransform:{name:"Transforms",inlineOptions:{default:{name:"Default",value:"default"},None:{name:"None",value:"None"}},generateOptions:e=>{const g=[];if(e.transforms)for(const i of e.transforms)g.push({name:i.name,value:i.value});return g}},aggregationMode:{name:"Aggregation Mode",inlineOptions:{},generateOptions:e=>{const g=[];return e.aggregationModes?Object.values(e.aggregationModes).forEach(({name:i,value:n})=>{g.push({name:i,value:n})}):g.push({name:"Default",value:"default"}),g}},maxZoom:{name:"Zoom limit",inlineOptions:{none:{name:"None",value:null}},generateOptions:e=>{if(e.maxZoom){const g=[];for(let i=0;i<=e.maxZoom;i++){const{maxWidth:n,binsPerDimension:I,maxZoom:r}=e;let o=1,C=1;if(e.resolutions){const l=e.resolutions.map(c=>+c).sort((c,u)=>u-c);[o]=l,C=l[i]}else C=e.maxWidth/(2**i*e.binsPerDimension),o=n/(2**r*I);const a=T1(o,C),s=_y(`.${a}`,C)(C);g.push({name:s,value:i.toString()})}return g}return[]}},valueColumn:{name:"Value column",inlineOptions:{none:{name:"None",value:null}},generateOptions:bWe},zeroValueColor:{name:"Zero Value Color",inlineOptions:pn}},f$e={...pEt,IS_TRACK_RANGE_SELECTABLE:N1,OPTIONS_INFO:rr},qwg={d3Array:aHt,d3Axis:log,d3Brush:IFt,d3Color:GHt,d3Drag:K5t,d3Dsv:MEt,d3Format:jHt,d3Geo:Ehg,d3Queue:_hg,d3Request:Afg,d3Scale:wkt,d3Selection:CTt,d3Transition:xtg,d3Zoom:_tg,PIXI:f$e.GLOBALS.PIXI,mix:tS,slugid:Ng},e1g={Annotations1dTrack:ite,Annotations2dTrack:OQe,ArrowheadDomainsTrack:PQe,BarTrack:cAe,BedLikeTrack:YQe,CNVIntervalTrack:MQe,Chromosome2DAnnotations:QQe,Chromosome2DLabels:UQe,ChromosomeGrid:EV,CombinedTrack:xae,CrossRule:mje,DivergentBarTrack:EQe,HeatmapTiledPixiTrack:gH,Horizontal1dHeatmapTrack:DQe,Horizontal2DDomainsTrack:JQe,HorizontalChromosomeLabels:$Qe,HorizontalGeneAnnotationsTrack:zQe,HorizontalHeatmapTrack:qQe,HorizontalLine1DPixiTrack:eS,HorizontalMultivecTrack:FQe,HorizontalPoint1DPixiTrack:xQe,HorizontalRule:Aje,HorizontalTiled1DPixiTrack:$1,HorizontalTiledPlot:gD,HorizontalTrack:h4e,Id2DTiledPixiTrack:j7e,IdHorizontal1DTiledPixiTrack:q7e,IdVertical1DTiledPixiTrack:tQe,LeftAxisTrack:IQe,MapboxTilesTrack:yje,MoveableTrack:y_,OSMTileIdsTrack:bje,OSMTilesTrack:nH,OverlayTrack:KQe,PixiTrack:Lo,RasterTilesTrack:Zje,SVGTrack:oZ,SquareMarkersTrack:LQe,Tiled1DPixiTrack:nAe,TiledPixiTrack:rZ,TopAxisTrack:nQe,Track:Qv,ValueIntervalTrack:tje,VerticalRule:fje,VerticalTiled1DPixiTrack:eQe,VerticalTrack:m4e,ViewportTracker2D:gje,ViewportTracker2DPixi:Xmg,ViewportTrackerHorizontal:ije,ViewportTrackerVertical:nje},t1g={ContextMenuItem:yg,DataFetcher:o_,LruCache:b4e},g1g={ChromosomeInfo:Fd,SearchField:Bw},i1g={DataFetcher:o_,GBKDataFetcher:J7e,LocalDataFetcher:L7e,getDataFetcher:wdg},AD={chromosomes:g1g,libraries:qwg,tracks:e1g,dataFetchers:i1g,factories:t1g,services:bDt,utils:ogg,configs:f$e,VERSION:y4e},oj={"track-renderer":"_track-renderer_11dwb_1","track-renderer-element":"_track-renderer-element_11dwb_5","track-renderer-events":"_track-renderer-events_11dwb_6"};function n1g(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function yWe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function lD(e){return lD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},lD(e)}const{getDataFetcher:l1g}=AD.dataFetchers,c1g=100;let fle=function(e){C1g(i,e);var g=a1g(i);function i(n){var I;if(n1g(this,i),I=g.call(this,n),I.dragging=!1,I.element=null,I.eventTracker=null,I.eventTrackerOld=null,I.closing=!1,I.yPositionOffset=0,I.xPositionOffset=0,I.scrollTop=0,I.scrollTimeout=null,I.activeTransitions=0,I.zoomTransform=NI,I.windowScrolledBound=I.windowScrolled.bind(js(I)),I.zoomStartedBound=I.zoomStarted.bind(js(I)),I.zoomedBound=I.zoomed.bind(js(I)),I.zoomEndedBound=I.zoomEnded.bind(js(I)),I.uid=Ng.nice(),I.viewUid=I.props.uid,I.availableForPlugins={...AD,services:{...AD.services,pubSub:I.props.pubSub,pixiRenderer:I.props.pixiRenderer}},I.mounted=!1,I.emptyZoomBehavior=see(),I.currentProps=n,I.prevPropsStr="",I.zoomBehavior=see().filter(r=>!(r.target.classList.contains("no-zoom")||r.target.classList.contains("react-resizable-handle"))).on("start",I.zoomStartedBound).on("zoom",I.zoomedBound).on("end",I.zoomEndedBound),I.zoomTransform=NI,I.prevZoomTransform=NI,I.initialXDomain=[0,1],I.initialYDomain=[0,1],I.xDomainLimits=[-Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],I.yDomainLimits=[-Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],I.zoomLimits=[0,Number.MAX_SAFE_INTEGER],I.prevCenterX=I.currentProps.paddingLeft+I.currentProps.leftWidth+I.currentProps.centerWidth/2,I.prevCenterY=I.currentProps.paddingTop+I.currentProps.topHeight+I.currentProps.centerHeight/2,I.cumCenterXOffset=0,I.cumCenterYOffset=0,I.setUpInitialScales(I.currentProps.initialXDomain,I.currentProps.initialYDomain,I.currentProps.xDomainLimits,I.currentProps.yDomainLimits,I.currentProps.zoomLimits),I.setUpScales(),I.trackDefObjects={},I.metaTracks={},I.pubSubs=[],window.higlassTracksByType)for(const r in window.higlassTracksByType)wi[r]=window.higlassTracksByType[r].config;return I.boundForwardEvent=I.forwardEvent.bind(js(I)),I.boundScrollEvent=I.scrollEvent.bind(js(I)),I.boundForwardContextMenu=I.forwardContextMenu.bind(js(I)),I.dispatchEventBound=I.dispatchEvent.bind(js(I)),I.zoomToDataPosHandlerBound=I.zoomToDataPosHandler.bind(js(I)),I.onScrollHandlerBound=I.onScrollHandler.bind(js(I)),I.elementPos={height:0,width:0,left:0,top:0},I.elementSelection=null,I}return I1g(i,[{key:"xScale",get:function(){if(!this._xScale)throw new Error("xScale is not defined");return this._xScale}},{key:"yScale",get:function(){if(!this._yScale)throw new Error("yScale is not defined");return this._yScale}},{key:"UNSAFE_componentWillMount",value:function(){this.pubSubs=[],this.pubSubs.push(this.props.pubSub.subscribe("scroll",this.windowScrolledBound)),this.pubSubs.push(this.props.pubSub.subscribe("app.event",this.dispatchEventBound)),this.pubSubs.push(this.props.pubSub.subscribe("zoomToDataPos",this.zoomToDataPosHandlerBound)),this.pubSubs.push(this.props.pubSub.subscribe("app.scroll",this.onScrollHandlerBound))}},{key:"componentDidMount",value:function(){if(!this.element)throw new Error("Component did not mount, this.element is not defined.");if(this.elementPos=this.element.getBoundingClientRect(),this.elementSelection=xg(this.element),this.pStage=new st.PIXI.Graphics,this.pMask=new st.PIXI.Graphics,this.pOutline=new st.PIXI.Graphics,this.pBackground=new st.PIXI.Graphics,this.pStage.addChild(this.pMask),this.pStage.addChild(this.pOutline),this.currentProps.pixiStage.addChild(this.pStage),this.pStage.mask=this.pMask,this.props.isRangeSelection||this.addZoom(),!this.currentProps.svgElement||!this.currentProps.canvasElement)return;this.svgElement=this.currentProps.svgElement,this.syncTrackObjects(this.currentProps.positionedTracks),this.syncMetaTracks(this.currentProps.metaTracks),this.currentProps.setCentersFunction(this.setCenter.bind(this)),this.currentProps.registerDraggingChangedListener(this.draggingChanged.bind(this)),this.draggingChanged(!0),this.addEventTracker();const I=[[this.xScale(this.xDomainLimits[0]),this.yScale(this.yDomainLimits[0])],[this.xScale(this.xDomainLimits[1]),this.yScale(this.yDomainLimits[1])]],r=this.svgElement.getBoundingClientRect(),o=[[Math.max(I[0][0],0),Math.max(I[0][1],0)],[Math.min(I[1][0],r.width),Math.min(I[1][1],r.height)]];this.zoomBehavior.extent(o).translateExtent(I).scaleExtent(this.zoomLimits)}},{key:"UNSAFE_componentWillReceiveProps",value:function(I){if(!I.svgElement||!I.canvasElement)return;const r=this.updatablePropsToString(I);if(this.currentProps=I,this.prevPropsStr===r)return;this.setBackground();for(const A in this.trackDefObjects){const s=this.trackDefObjects[A].trackObject;s.delayDrawing=!0}this.prevPropsStr=r,this.setUpInitialScales(I.initialXDomain,I.initialYDomain,I.xDomainLimits,I.yDomainLimits,I.zoomLimits),this.setUpScales(I.width!==this.props.width||I.height!==this.props.height),this.svgElement=I.svgElement;const o=[[this.xScale(this.xDomainLimits[0]),this.yScale(this.yDomainLimits[0])],[this.xScale(this.xDomainLimits[1]),this.yScale(this.yDomainLimits[1])]],C=this.svgElement.getBoundingClientRect(),a=[[Math.max(o[0][0],0),Math.max(o[0][1],0)],[Math.min(o[1][0],C.width),Math.min(o[1][1],C.height)]];this.zoomBehavior.extent(a).translateExtent(o).scaleExtent(this.zoomLimits),this.syncTrackObjects(I.positionedTracks),this.syncMetaTracks(I.metaTracks);for(const A of I.positionedTracks){const s=A.track.options,l=this.trackDefObjects[A.track.uid].trackObject;if(l.rerender(s),LK(A.track)){const c={};for(const u of A.track.contents)c[u.uid]=u;for(const u in l.createdTracks)l.createdTracks[u].rerender(c[u].options)}}this.props.onNewTilesLoaded();for(const A in this.trackDefObjects){const s=this.trackDefObjects[A].trackObject;s.delayDrawing=!1,s.draw()}}},{key:"componentDidUpdate",value:function(I){(this.props.initialXDomain[0]!==I.initialXDomain[0]||this.props.initialXDomain[1]!==I.initialXDomain[1]||this.props.initialYDomain[0]!==I.initialYDomain[0]||this.props.initialYDomain[1]!==I.initialYDomain[1])&&this.element&&(this.element.__zoom=NI),I.isRangeSelection!==this.props.isRangeSelection&&(this.props.isRangeSelection?this.removeZoom():this.addZoom()),I.zoomable!==this.props.zoomable&&(this.props.zoomable?this.addZoom():this.removeZoom()),this.addEventTracker()}},{key:"componentWillUnmount",value:function(){var I,r;this.mounted=!1,this.removeTracks(Object.keys(this.trackDefObjects)),this.removeMetaTracks(Object.keys(this.metaTracks)),this.currentProps.removeDraggingChangedListener(this.draggingChanged),this.pStage&&this.currentProps.pixiStage.removeChild(this.pStage),(I=this.pMask)==null||I.destroy(!0),(r=this.pStage)==null||r.destroy(!0),this.pubSubs.forEach(o=>this.props.pubSub.unsubscribe(o)),this.pubSubs=[],this.removeEventTracker()}},{key:"dispatchEvent",value:function(I){I.sourceUid===this.uid&&I.type!=="contextmenu"&&this.element&&FF(I,this.element)}},{key:"isWithin",value:function(I,r){const o=I>=this.elementPos.left&&I<=this.elementPos.width+this.elementPos.left,C=r>=this.elementPos.top&&r<=this.elementPos.height+this.elementPos.top;return o&&C}},{key:"zoomToDataPosHandler",value:function({pos:I,animateTime:r}){this.zoomToDataPos(...I,r)}},{key:"addZoom",value:function(){!this.elementSelection||!this.currentProps.zoomable||(this.elementSelection.call(this.zoomBehavior),this.zoomBehavior.transform(this.elementSelection,this.zoomTransform))}},{key:"removeZoom",value:function(){this.elementSelection&&(this.zoomEnded(),this.elementSelection.on(".zoom",null))}},{key:"setMask",value:function(){var I,r,o,C;(I=this.pMask)==null||I.clear(),(r=this.pMask)==null||r.beginFill(),(o=this.pMask)==null||o.drawRect(this.xPositionOffset,this.yPositionOffset,this.currentProps.width,this.currentProps.height),(C=this.pMask)==null||C.endFill()}},{key:"setBackground",value:function(){var I,r,o,C,a;const A=this.props.theme===ki?"black":"white",s=jt(((I=this.currentProps.viewOptions)==null?void 0:I.backgroundColor)??A);(r=this.pBackground)==null||r.clear(),(o=this.pBackground)==null||o.beginFill(s),(C=this.pBackground)==null||C.drawRect(this.xPositionOffset,this.yPositionOffset,this.currentProps.width,this.currentProps.height),(a=this.pBackground)==null||a.endFill()}},{key:"windowScrolled",value:function(){this.removeZoom(),this.scrollTimeout&&clearTimeout(this.scrollTimeout),this.scrollTimeout=setTimeout(()=>{this.addZoom()},c1g)}},{key:"setUpInitialScales",value:function(I=[0,1],r=[0,1],o=[-Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],C=[-Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],a=[0,Number.MAX_SAFE_INTEGER]){a[0]=a[0]===null?0:a[0],a[1]=a[1]===null?1/0:a[1];const A=I[1]-I[0],s=(r[0]+r[1])/2;if(r[0]=s-A/2,r[1]=s+A/2,I[0]===this.initialXDomain[0]&&I[1]===this.initialXDomain[1]&&r[0]===this.initialYDomain[0]&&r[1]===this.initialYDomain[1]&&o[0]===this.xDomainLimits[0]&&o[1]===this.xDomainLimits[1]&&C[0]===this.yDomainLimits[0]&&C[1]===this.yDomainLimits[1]&&a[0]===this.zoomLimits[0]&&a[1]===this.zoomLimits[1])return;this.initialXDomain=I,this.initialYDomain=r,this.xDomainLimits=o,this.yDomainLimits=C,this.zoomLimits=a,this.zoomTransform=NI,this.prevZoomTransform=NI,this.cumCenterYOffset=0,this.cumCenterXOffset=0,this.drawableToDomainX=bg().domain([this.currentProps.paddingLeft+this.currentProps.leftWidth,this.currentProps.paddingLeft+this.currentProps.leftWidth+this.currentProps.centerWidth]).range([I[0],I[1]]);let l,c;this.currentProps.centerWidth===0?(l=this.currentProps.paddingTop+this.currentProps.topHeight,c=this.currentProps.paddingTop+this.currentProps.topHeight+this.currentProps.centerHeight):(l=this.currentProps.paddingTop+this.currentProps.topHeight+this.currentProps.centerHeight/2-this.currentProps.centerWidth/2,c=this.currentProps.paddingTop+this.currentProps.topHeight+this.currentProps.centerHeight/2+this.currentProps.centerWidth/2),this.drawableToDomainY=bg().domain([l,c]).range([r[0],r[1]]),this.prevCenterX=this.currentProps.paddingLeft+this.currentProps.leftWidth+this.currentProps.centerWidth/2,this.prevCenterY=this.currentProps.paddingTop+this.currentProps.topHeight+this.currentProps.centerHeight/2}},{key:"updatablePropsToString",value:function(I){return JSON.stringify({positionedTracks:I.positionedTracks,initialXDomain:I.initialXDomain,initialYDomain:I.initialYDomain,width:I.width,height:I.height,paddingLeft:I.paddingLeft,paddingTop:I.paddingTop,leftWidth:I.leftWidth,topHeight:I.topHeight,dragging:I.dragging,viewOptions:I.viewOptions})}},{key:"draggingChanged",value:function(I){this.dragging=I,this.timedUpdatePositionAndDimensions()}},{key:"setUpScales",value:function(I=!1){const r=this.currentProps.paddingLeft+this.currentProps.leftWidth+this.currentProps.centerWidth/2,o=this.currentProps.paddingTop+this.currentProps.topHeight+this.currentProps.centerHeight/2;if(!this.drawableToDomainX||!this.drawableToDomainY)return;const C=(this.drawableToDomainX(r)-this.drawableToDomainX(this.prevCenterX))/this.zoomTransform.k,a=(this.drawableToDomainY(o)-this.drawableToDomainY(this.prevCenterY))/this.zoomTransform.k;this.cumCenterYOffset+=a,this.cumCenterXOffset+=C,this.prevCenterY=o,this.prevCenterX=r;const A=[this.drawableToDomainX(0)-this.cumCenterXOffset,this.drawableToDomainX(this.currentProps.width)-this.cumCenterXOffset],s=[this.drawableToDomainY(0)-this.cumCenterYOffset,this.drawableToDomainY(this.currentProps.height)-this.cumCenterYOffset];this._xScale=bg().domain(A).range([0,this.currentProps.width]),this._yScale=bg().domain(s).range([0,this.currentProps.height]);for(const l in this.trackDefObjects)this.trackDefObjects[l].trackObject.refScalesChanged(this.xScale,this.yScale);this.applyZoomTransform(I)}},{key:"getTrackDef",value:function(I){const r=Ea(this.trackDefObjects);for(const[,{trackDef:o,trackObject:C}]of r){if(C===I)return o.track;if(LK(o.track)){for(const a of o.track.contents)if(C.createdTracks[a.uid]===I)return a}}return null}},{key:"getTrackObject",value:function(I){const r=Ea(this.trackDefObjects);for(let o=0;oC.uid));this.addMetaTracks(I.filter(C=>!this.metaTracks[C.uid])),this.updateMetaTracks(I.filter(C=>this.metaTracks[C.uid])),this.removeMetaTracks(r.filter(C=>!o.has(C)))}},{key:"syncTrackObjects",value:function(I){this.prevTrackDefinitions=JSON.stringify(I);const r={};for(let l=0;l!o.has(l))),A=new Set([...o].filter(l=>!C.has(l))),s=new Set([...C].filter(l=>o.has(l)));this.updateExistingTrackDefs([...s].map(l=>r[l])),this.addNewTracks([...a].map(l=>r[l])),this.updateExistingTrackDefs([...a].map(l=>r[l])),this.removeTracks([...A])}},{key:"addMetaTracks",value:function(I){I.filter(r=>!this.metaTracks[r.uid]).forEach(r=>{this.metaTracks[r.uid]={trackDef:r,trackObject:this.createMetaTrack(r)}})}},{key:"addNewTracks",value:function(I){if(this.currentProps.pixiStage){for(let r=0;r{this.metaTracks[r].trackObject.remove(),this.metaTracks[r]=void 0,delete this.metaTracks[r]})}},{key:"removeTracks",value:function(I){for(let r=0;r{const p=NI.translate(h,f).scale(c);this.zoomTransform=p,this.elementSelection&&this.emptyZoomBehavior.transform(this.elementSelection,p),m=this.applyZoomTransform(C)};if(a&&this.elementSelection){let p=this.elementSelection;this.activeTransitions+=1,document.hidden||(p=p.transition().duration(a)),p.call(this.zoomBehavior.transform,NI.translate(h,f).scale(c)).on("end",()=>{b(),this.activeTransitions-=1})}else b();return m}},{key:"valueScaleMove",value:function(I){if(this.zoomStartPos){for(const r of this.getTracksAtPosition(...this.zoomStartPos))r.movedY(I);this.zoomStartTransform&&(this.zoomTransform=this.zoomStartTransform)}}},{key:"valueScaleZoom",value:function(I,r){if(!ZDt(I.sourceEvent))return;const o=I.sourceEvent.deltaY,C=I.sourceEvent.deltaMode,A=((l,c)=>l*(c?120:1)/500)(o,C),s=mi(I.sourceEvent,this.props.canvasElement);for(const l of this.getTracksAtPosition(...s)){const c=r==="1d-horizontal"?s[1]-l.position[1]:s[0]-l.position[0];l.zoomedY(c,2**A)}this.zoomStartTransform&&(this.zoomTransform=this.zoomStartTransform)}},{key:"zoomed",value:function(I){var r;let o=null;if(this.zoomStartPos){const a=this.getTracksAtPosition(...this.zoomStartPos);if(a.length){const A=a[0],s=this.getTrackDef(A);if(!s)return;(r=wi[s.type])!=null&&r.orientation&&(o=wi[s.type].orientation),A instanceof URe&&(o="1d-vertical")}}if(o&&I.sourceEvent){if(I.shiftKey||this.valueScaleZooming){if(I.sourceEvent.deltaY!==void 0){this.valueScaleZoom(I,o);return}o==="1d-horizontal"?this.valueScaleMove(I.sourceEvent.movementY):o==="1d-vertical"&&this.valueScaleMove(I.sourceEvent.movementX)}o==="1d-horizontal"&&I.sourceEvent.movementY?this.valueScaleMove(I.sourceEvent.movementY):o==="1d-vertical"&&I.sourceEvent.movementX&&this.valueScaleMove(I.sourceEvent.movementX)}this.zoomTransform=this.currentProps.zoomable?I.transform:NI,this.prevZoomTransform.k!==this.zoomTransform.k||(o==="1d-horizontal"?this.zoomTransform=NI.translate(this.zoomTransform.x,this.prevZoomTransform.y).scale(this.zoomTransform.k):o==="1d-vertical"&&(this.zoomTransform=NI.translate(this.prevZoomTransform.x,this.zoomTransform.y).scale(this.zoomTransform.k)),this.element&&(this.element.__zoom=this.zoomTransform)),this.applyZoomTransform(!0),this.prevZoomTransform=this.zoomTransform,this.props.pubSub.publish("app.zoom",I),I.sourceEvent&&(I.sourceEvent.stopPropagation(),I.sourceEvent.preventDefault())}},{key:"getTracksAtPosition",value:function(I,r){const o=[];let C=[];for(const a in this.trackDefObjects){const A=this.trackDefObjects[a].trackObject;A.childTracks?C=C.concat(A.childTracks):C.push(A)}for(const a of C){const A=a.position[0]<=I&&I<=a.position[0]+a.dimensions[0],s=a.position[1]<=r&&r<=a.position[1]+a.dimensions[1];A&&s&&o.push(a)}return o}},{key:"zoomStarted",value:function(I){this.zooming=!0,I&&I.sourceEvent&&(this.zoomStartPos=mi(I.sourceEvent,this.props.canvasElement),I.sourceEvent.shiftKey&&(this.valueScaleZooming=!0)),this.zoomStartTransform=this.zoomTransform,this.props.pubSub.publish("app.zoomStart")}},{key:"zoomEnded",value:function(){this.zooming=!1,this.zoomStartPos=null,this.valueScaleZooming&&(this.valueScaleZooming=!1,this.element&&(this.element.__zoom=this.zoomStartTransform)),this.props.pubSub.publish("app.zoomEnd")}},{key:"applyZoomTransform",value:function(I=!0){const r=this.currentProps,o=r.paddingLeft+r.leftWidth,C=r.paddingTop+r.topHeight;if(!this.xScale||!this.yScale)return;this.zoomedXScale=this.zoomTransform.rescaleX(this.xScale),this.zoomedYScale=this.zoomTransform.rescaleY(this.yScale);const a=bg().domain([o,o+r.centerWidth].map(this.zoomedXScale.invert)).range([0,r.centerWidth]),A=bg().domain([C,C+r.centerHeight].map(this.zoomedYScale.invert)).range([0,r.centerHeight]);for(const s in this.trackDefObjects){const l=this.trackDefObjects[s].trackObject,c=this.trackDefObjects[s].trackDef;let u="unknown";if(wi[c.track.type]&&(u=wi[c.track.type].orientation),u==="whole"){const d=bg().domain([r.paddingLeft,r.width-r.paddingLeft].map(this.zoomedXScale.invert)).range([0,r.width-2*r.paddingLeft]),h=bg().domain([r.paddingTop,r.height-r.paddingTop].map(this.zoomedYScale.invert)).range([0,r.height-2*r.paddingTop]);l.zoomed(d,h);continue}if(this.trackDefObjects[s].trackDef.track.position==="gallery"){const d=bg().domain([r.paddingLeft+r.leftWidthNoGallery,r.paddingLeft+r.leftWidth+r.centerWidth+r.galleryDim].map(this.zoomedXScale.invert)).range([0,r.centerWidth+2*r.galleryDim]),h=bg().domain([r.paddingTop+r.topHeightNoGallery,r.paddingTop+r.topHeight+r.centerHeight+r.galleryDim].map(this.zoomedYScale.invert)).range([0,r.centerHeight-2*r.galleryDim]);l.zoomed(d.copy(),h.copy(),this.zoomTransform.k);continue}l.zoomed(a.copy(),A.copy(),this.zoomTransform.k,this.zoomTransform.x+this.xPositionOffset,this.zoomTransform.y+this.yPositionOffset,r.paddingLeft+r.leftWidth,r.paddingTop+r.topHeight)}return this.currentXScale=a,this.currentYScale=A,I&&this.currentProps.onScalesChanged(a,A),[a,A]}},{key:"createMetaTrack",value:function(I){switch(I.type){default:{const r=this.props.pluginTracks[I.type];if(r?.isMetaTrack){const o={getTrackObject:this.getTrackObject.bind(this),onNewTilesLoaded:()=>{this.currentProps.onNewTilesLoaded(I.uid)},definition:I};try{return new r.track(this.availableForPlugins,o,I.options)}catch(C){console.error("Plugin meta track",I.type,"failed to instantiate.",C)}}return console.warn(`Unknown meta track of type: ${I.type}`),new hVe(this.pStage,{name:"Unknown Track Type",type:I.type})}}}},{key:"createTrackObject",value:function(I){const r=this.createLocationAgnosticTrackObject(I);return(I.position==="left"||I.position==="right")&&wi[I.type].orientation==="1d-horizontal"?new URe(r):r}},{key:"createLocationAgnosticTrackObject",value:function(I){let r=I.data;r||(r={server:dP(I.server),tilesetUid:I.tilesetUid}),I.coordSystem&&(r.coordSystem=I.coordSystem);const o=l1g(r,this.props.pubSub,this.props.pluginDataFetchers,this.availableForPlugins);if(!this.pStage||!this.svgElement)throw new Error("No PIXI stage or svg element");const C={id:I.uid,trackUid:I.uid,trackType:I.type,viewUid:this.viewUid,pubSub:this.props.pubSub,scene:this.pStage,dataConfig:r,dataFetcher:o,getLockGroupExtrema:()=>this.currentProps.getLockGroupExtrema(I.uid),handleTilesetInfoReceived:a=>{this.currentProps.onTilesetInfoReceived(I.uid,a)},animate:()=>{this.currentProps.onNewTilesLoaded(I.uid)},svgElement:this.svgElement,isValueScaleLocked:()=>this.currentProps.isValueScaleLocked(I.uid),onValueScaleChanged:()=>{this.currentProps.onValueScaleChanged(I.uid)},onTrackOptionsChanged:a=>{this.currentProps.onTrackOptionsChanged(I.uid,a)},onMouseMoveZoom:this.props.onMouseMoveZoom,chromInfoPath:I.chromInfoPath,isShowGlobalMousePosition:()=>this.props.isShowGlobalMousePosition,getTheme:()=>this.props.theme};switch(I.y&&(C.yPosition=I.y),I.x&&(C.xPosition=I.x),I.projectionXDomain&&(C.projectionXDomain=I.projectionXDomain),I.projectionYDomain&&(C.projectionYDomain=I.projectionYDomain),I.type){case"left-axis":return new IQe(C,I.options);case"top-axis":return new nQe(C,I.options);case"heatmap":return new gH(C,I.options);case"multivec":case"vector-heatmap":case"horizontal-multivec":case"horizontal-vector-heatmap":case"vertical-multivec":case"vertical-vector-heatmap":return new FQe(C,I.options);case"1d-heatmap":case"horizontal-1d-heatmap":case"vertical-1d-heatmap":return new DQe(C,I.options);case"line":case"horizontal-line":case"vertical-line":return new eS(C,I.options);case"point":case"horizontal-point":case"vertical-point":return new xQe(C,I.options);case"bar":case"horizontal-bar":case"vertical-bar":return new cAe(C,I.options);case"divergent-bar":case"horizontal-divergent-bar":case"vertical-divergent-bar":return new EQe(C,I.options);case"horizontal-1d-tiles":return new q7e(C,I.options);case"vertical-1d-tiles":return new tQe(C,I.options);case"2d-tiles":return new j7e(C,I.options);case"stacked-interval":case"top-stacked-interval":case"left-stacked-interval":return new MQe(C,I.options);case"viewport-projection-center":return I.registerViewportChanged&&I.removeViewportChanged&&I.setDomainsCallback?(C.registerViewportChanged=I.registerViewportChanged,C.removeViewportChanged=I.removeViewportChanged,C.setDomainsCallback=I.setDomainsCallback,new gje(C,I.options)):new Qv(C,{});case"viewport-projection-horizontal":return I.registerViewportChanged&&I.removeViewportChanged&&I.setDomainsCallback?(C.registerViewportChanged=I.registerViewportChanged,C.removeViewportChanged=I.removeViewportChanged,C.setDomainsCallback=I.setDomainsCallback,new ije(C,I.options)):new Qv(C,{});case"viewport-projection-vertical":return I.registerViewportChanged&&I.removeViewportChanged&&I.setDomainsCallback?(C.registerViewportChanged=I.registerViewportChanged,C.removeViewportChanged=I.removeViewportChanged,C.setDomainsCallback=I.setDomainsCallback,new nje(C,I.options)):new Qv(C,{});case"gene-annotations":case"horizontal-gene-annotations":case"vertical-gene-annotations":return new zQe(C,I.options);case"2d-rectangle-domains":case"arrowhead-domains":return new PQe(C,I.options);case"horizontal-1d-annotations":return new ite(C,I.options);case"vertical-1d-annotations":return new ite(C,I.options,!0);case"2d-annotations":return new OQe(C,I.options);case"linear-2d-rectangle-domains":case"horizontal-2d-rectangle-domains":case"vertical-2d-rectangle-domains":return new JQe(C,I.options);case"square-markers":return new LQe(C,I.options);case"combined":return C.tracks=I.contents,C.createTrackObject=this.createTrackObject.bind(this),new xae(C);case"2d-chromosome-labels":return new UQe(C,I.options);case"horizontal-chromosome-grid":return C.orientation="1d-horizontal",new EV(C,I.options);case"vertical-chromosome-grid":return C.orientation="1d-vertical",new EV(C,I.options);case"2d-chromosome-grid":return new EV(C,I.options);case"chromosome-labels":case"horizontal-chromosome-labels":case"vertical-chromosome-labels":return new $Qe(C,I.options);case"linear-heatmap":case"horizontal-heatmap":case"vertical-heatmap":return new qQe(C,I.options);case"2d-chromosome-annotations":return new QQe(C,I.options);case"1d-value-interval":case"horizontal-1d-value-interval":case"vertical-1d-value-interval":return new tje(C,I.options);case"osm":case"osm-tiles":return new nH(C,I.options);case"osm-2d-tile-ids":return new bje(C,I.options);case"mapbox":case"mapbox-tiles":return new yje(C,I.options);case"raster-tiles":return new Zje(C,I.options);case"bedlike":case"vertical-bedlike":return new YQe(C,I.options);case"overlay-track":return new KQe(C,I.options);case"overlay-chromosome-grid-track":return C.isOverlay=!0,new EV(C,I.options);case"horizontal-rule":return new Aje(C,I.options);case"vertical-rule":return new fje(C,I.options);case"cross-rule":return C.x=I.x,C.y=I.y,new mje(C,I.options);case"simple-svg":return new oZ(C,I.options);case"empty":{const a=I.options;return new Lo(C,a)}default:{const a=this.props.pluginTracks[I.type];if(a&&!a.isMetaTrack){C.AVAILABLE_FOR_PLUGINS=this.availableForPlugins,C.baseEl=this.baseEl,C.definition=I,I.registerViewportChanged&&I.removeViewportChanged&&I.setDomainsCallback&&(C.registerViewportChanged=I.registerViewportChanged,C.removeViewportChanged=I.removeViewportChanged,C.setDomainsCallback=I.setDomainsCallback);try{return new a.track(this.availableForPlugins,C,I.options)}catch(A){console.error("Plugin track",I.type,"failed to instantiate.",A)}}return console.warn("Unknown track type:",I.type),new hVe(C,{name:"Unknown Track Type",type:I.type})}}}},{key:"zoomToDataPos",value:function(I,r,o,C,a=3e3,A=null){const[s,l,c]=AI(this.xScale.copy().domain([I,r]),this.yScale.copy().domain([o,C])),u=A?A(this.xScale,this.yScale):[this.xScale,this.yScale];this.setCenter(s,l,c,!1,a,u[0],u[1])}},{key:"forwardContextMenu",value:function(I){this.props.disableTrackMenu||I.altKey||(I.preventDefault(),setTimeout(()=>{this.props.pubSub.publish("contextmenu",I)},0))}},{key:"addEventTracker",value:function(){!this.eventTracker||this.eventTracker===this.eventTrackerOld||(this.eventTrackerOld||(this.eventTrackerOld=this.eventTracker),this.eventTracker=this.eventTrackerOld,this.eventTracker.addEventListener("click",this.boundForwardEvent),this.eventTracker.addEventListener("contextmenu",this.boundForwardContextMenu),this.eventTracker.addEventListener("dblclick",this.boundForwardEvent),this.eventTracker.addEventListener("wheel",this.boundForwardEvent),this.eventTracker.addEventListener("dragstart",this.boundForwardEvent),this.eventTracker.addEventListener("selectstart",this.boundForwardEvent),this.eventTracker.addEventListener("mouseover",this.boundForwardEvent),this.eventTracker.addEventListener("mouseenter",this.boundForwardEvent),this.eventTracker.addEventListener("mousedown",this.boundForwardEvent),this.eventTracker.addEventListener("mouseup",this.boundForwardEvent),this.eventTracker.addEventListener("mouseout",this.boundForwardEvent),this.eventTracker.addEventListener("mouseleave",this.boundForwardEvent),this.eventTracker.addEventListener("touchstart",this.boundForwardEvent),this.eventTracker.addEventListener("touchend",this.boundForwardEvent),this.eventTracker.addEventListener("touchmove",this.boundForwardEvent),this.eventTracker.addEventListener("touchcancel",this.boundForwardEvent),this.eventTracker.addEventListener("pointerover",this.boundForwardEvent),this.eventTracker.addEventListener("pointerenter",this.boundForwardEvent),this.eventTracker.addEventListener("pointerdown",this.boundForwardEvent),this.eventTracker.addEventListener("pointerup",this.boundForwardEvent),this.eventTracker.addEventListener("pointercancel",this.boundForwardEvent),this.eventTracker.addEventListener("pointerout",this.boundForwardEvent),this.eventTracker.addEventListener("pointerleave",this.boundForwardEvent),window.addEventListener("scroll",this.boundScrollEvent))}},{key:"removeEventTracker",value:function(){this.eventTracker&&(this.eventTracker.removeEventListener("click",this.boundForwardEvent),this.eventTracker.removeEventListener("contextmenu",this.boundForwardContextMenu),this.eventTracker.removeEventListener("dblclick",this.boundForwardEvent),this.eventTracker.removeEventListener("wheel",this.boundForwardEvent),this.eventTracker.removeEventListener("dragstart",this.boundForwardEvent),this.eventTracker.removeEventListener("selectstart",this.boundForwardEvent),this.eventTracker.removeEventListener("mouseover",this.boundForwardEvent),this.eventTracker.removeEventListener("mouseenter",this.boundForwardEvent),this.eventTracker.removeEventListener("mousedown",this.boundForwardEvent),this.eventTracker.removeEventListener("mouseup",this.boundForwardEvent),this.eventTracker.removeEventListener("mouseout",this.boundForwardEvent),this.eventTracker.removeEventListener("mouseleave",this.boundForwardEvent),this.eventTracker.removeEventListener("touchstart",this.boundForwardEvent),this.eventTracker.removeEventListener("touchend",this.boundForwardEvent),this.eventTracker.removeEventListener("touchcancel",this.boundForwardEvent),this.eventTracker.removeEventListener("pointerover",this.boundForwardEvent),this.eventTracker.removeEventListener("pointerenter",this.boundForwardEvent),this.eventTracker.removeEventListener("pointerdown",this.boundForwardEvent),this.eventTracker.removeEventListener("pointerup",this.boundForwardEvent),this.eventTracker.removeEventListener("pointercancel",this.boundForwardEvent),this.eventTracker.removeEventListener("pointerout",this.boundForwardEvent),this.eventTracker.removeEventListener("pointerleave",this.boundForwardEvent),window.removeEventListener("scroll",this.boundScrollEvent))}},{key:"scrollEvent",value:function(){this.element&&(this.elementPos=this.element.getBoundingClientRect())}},{key:"forwardEvent",value:function(I){I.sourceUid=this.uid,I.forwarded=!0,this.props.pubSub.publish("app.event",I)}},{key:"onScrollHandler",value:function(I){this.scrollTop=I}},{key:"render",value:function(){return k.createElement("div",{ref:I=>{this.baseEl=I},className:gi("track-renderer-div",oj["track-renderer"]),style:{height:this.currentProps.height,width:this.currentProps.width}},k.createElement("div",{ref:I=>{this.element=I},className:gi("track-renderer-element",oj["track-renderer-element"])}),k.createElement("div",{ref:I=>{this.eventTracker=I},className:gi("track-renderer-events",oj["track-renderer-events"])},this.currentProps.children))}}]),i}(k.Component);fle.defaultProps={pluginDataFetchers:{},pluginTracks:{},canvasElement:null,centerHeight:0,centerWidth:0,children:[],galleryDim:0,height:0,initialXDomain:[],initialYDomain:[],isShowGlobalMousePosition:!1,isRangeSelection:!1,leftWidth:0,leftWidthNoGallery:0,paddingLeft:0,paddingTop:0,positionedTracks:[],topHeight:0,topHeightNoGallery:0,width:0,metaTracks:[]};fle.propTypes={canvasElement:L.object,centerHeight:L.number,centerWidth:L.number,children:L.array,disableTrackMenu:L.bool,galleryDim:L.number,height:L.number,initialXDomain:L.array,initialYDomain:L.array,isShowGlobalMousePosition:L.bool,isRangeSelection:L.bool,leftWidth:L.number,leftWidthNoGallery:L.number,paddingLeft:L.number,paddingTop:L.number,metaTracks:L.array,onMouseMoveZoom:L.func,onNewTilesLoaded:L.func.isRequired,onScalesChanged:L.func.isRequired,pixiRenderer:L.object.isRequired,pixiStage:L.object.isRequired,pluginDataFetchers:L.object,pluginTracks:L.object,positionedTracks:L.array,pubSub:L.object.isRequired,setCentersFunction:L.func,svgElement:L.object.isRequired,theme:L.symbol.isRequired,topHeight:L.number,topHeightNoGallery:L.number,viewOptions:L.object,width:L.number,xDomainLimits:L.array,yDomainLimits:L.array,valueScaleZoom:L.bool,zoomable:L.bool.isRequired,zoomDomain:L.array,uid:L.string,zoomLimits:L.array};const u1g=L1(iZ(fle));var m$e={exports:{}};/*! react-checkbox-tree - v1.8.0 | 2022 */(function(e,g){/*! For license information please see index.browser.js.LICENSE.txt */(function(i,n){e.exports=n(k)})(self,i=>(()=>{var n={4184:(C,a)=>{var A;(function(){var s={}.hasOwnProperty;function l(){for(var c=[],u=0;u{var s=A(852)(A(5639),"DataView");C.exports=s},1989:(C,a,A)=>{var s=A(1789),l=A(401),c=A(7667),u=A(1327),d=A(1866);function h(f){var m=-1,b=f==null?0:f.length;for(this.clear();++m{var s=A(7040),l=A(4125),c=A(2117),u=A(7518),d=A(4705);function h(f){var m=-1,b=f==null?0:f.length;for(this.clear();++m{var s=A(852)(A(5639),"Map");C.exports=s},3369:(C,a,A)=>{var s=A(4785),l=A(1285),c=A(6e3),u=A(9916),d=A(5265);function h(f){var m=-1,b=f==null?0:f.length;for(this.clear();++m{var s=A(852)(A(5639),"Promise");C.exports=s},8525:(C,a,A)=>{var s=A(852)(A(5639),"Set");C.exports=s},8668:(C,a,A)=>{var s=A(3369),l=A(619),c=A(2385);function u(d){var h=-1,f=d==null?0:d.length;for(this.__data__=new s;++h{var s=A(8407),l=A(7465),c=A(3779),u=A(7599),d=A(4758),h=A(4309);function f(m){var b=this.__data__=new s(m);this.size=b.size}f.prototype.clear=l,f.prototype.delete=c,f.prototype.get=u,f.prototype.has=d,f.prototype.set=h,C.exports=f},2705:(C,a,A)=>{var s=A(5639).Symbol;C.exports=s},1149:(C,a,A)=>{var s=A(5639).Uint8Array;C.exports=s},577:(C,a,A)=>{var s=A(852)(A(5639),"WeakMap");C.exports=s},4963:C=>{C.exports=function(a,A){for(var s=-1,l=a==null?0:a.length,c=0,u=[];++s{var s=A(2545),l=A(5694),c=A(1469),u=A(4144),d=A(5776),h=A(6719),f=Object.prototype.hasOwnProperty;C.exports=function(m,b){var p=c(m),y=!p&&l(m),Z=!p&&!y&&u(m),v=!p&&!y&&!Z&&h(m),G=p||y||Z||v,B=G?s(m.length,String):[],S=B.length;for(var R in m)!b&&!f.call(m,R)||G&&(R=="length"||Z&&(R=="offset"||R=="parent")||v&&(R=="buffer"||R=="byteLength"||R=="byteOffset")||d(R,S))||B.push(R);return B}},2488:C=>{C.exports=function(a,A){for(var s=-1,l=A.length,c=a.length;++s{C.exports=function(a,A){for(var s=-1,l=a==null?0:a.length;++s{var s=A(7813);C.exports=function(l,c){for(var u=l.length;u--;)if(s(l[u][0],c))return u;return-1}},8866:(C,a,A)=>{var s=A(2488),l=A(1469);C.exports=function(c,u,d){var h=u(c);return l(c)?h:s(h,d(c))}},4239:(C,a,A)=>{var s=A(2705),l=A(9607),c=A(2333),u=s?s.toStringTag:void 0;C.exports=function(d){return d==null?d===void 0?"[object Undefined]":"[object Null]":u&&u in Object(d)?l(d):c(d)}},9454:(C,a,A)=>{var s=A(4239),l=A(7005);C.exports=function(c){return l(c)&&s(c)=="[object Arguments]"}},939:(C,a,A)=>{var s=A(2492),l=A(7005);C.exports=function c(u,d,h,f,m){return u===d||(u==null||d==null||!l(u)&&!l(d)?u!=u&&d!=d:s(u,d,h,f,c,m))}},2492:(C,a,A)=>{var s=A(6384),l=A(7114),c=A(8351),u=A(6096),d=A(4160),h=A(1469),f=A(4144),m=A(6719),b="[object Arguments]",p="[object Array]",y="[object Object]",Z=Object.prototype.hasOwnProperty;C.exports=function(v,G,B,S,R,w){var T=h(v),W=h(G),V=T?p:d(v),X=W?p:d(G),N=(V=V==b?y:V)==y,Y=(X=X==b?y:X)==y,x=V==X;if(x&&f(v)){if(!f(G))return!1;T=!0,N=!1}if(x&&!N)return w||(w=new s),T||m(v)?l(v,G,B,S,R,w):c(v,G,V,B,S,R,w);if(!(1&B)){var M=N&&Z.call(v,"__wrapped__"),F=Y&&Z.call(G,"__wrapped__");if(M||F){var $=M?v.value():v,Q=F?G.value():G;return w||(w=new s),R($,Q,B,S,w)}}return!!x&&(w||(w=new s),u(v,G,B,S,R,w))}},8458:(C,a,A)=>{var s=A(3560),l=A(5346),c=A(3218),u=A(346),d=/^\[object .+?Constructor\]$/,h=Function.prototype,f=Object.prototype,m=h.toString,b=f.hasOwnProperty,p=RegExp("^"+m.call(b).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");C.exports=function(y){return!(!c(y)||l(y))&&(s(y)?p:d).test(u(y))}},8749:(C,a,A)=>{var s=A(4239),l=A(1780),c=A(7005),u={};u["[object Float32Array]"]=u["[object Float64Array]"]=u["[object Int8Array]"]=u["[object Int16Array]"]=u["[object Int32Array]"]=u["[object Uint8Array]"]=u["[object Uint8ClampedArray]"]=u["[object Uint16Array]"]=u["[object Uint32Array]"]=!0,u["[object Arguments]"]=u["[object Array]"]=u["[object ArrayBuffer]"]=u["[object Boolean]"]=u["[object DataView]"]=u["[object Date]"]=u["[object Error]"]=u["[object Function]"]=u["[object Map]"]=u["[object Number]"]=u["[object Object]"]=u["[object RegExp]"]=u["[object Set]"]=u["[object String]"]=u["[object WeakMap]"]=!1,C.exports=function(d){return c(d)&&l(d.length)&&!!u[s(d)]}},280:(C,a,A)=>{var s=A(5726),l=A(6916),c=Object.prototype.hasOwnProperty;C.exports=function(u){if(!s(u))return l(u);var d=[];for(var h in Object(u))c.call(u,h)&&h!="constructor"&&d.push(h);return d}},2545:C=>{C.exports=function(a,A){for(var s=-1,l=Array(a);++s{C.exports=function(a){return function(A){return a(A)}}},4757:C=>{C.exports=function(a,A){return a.has(A)}},4429:(C,a,A)=>{var s=A(5639)["__core-js_shared__"];C.exports=s},7114:(C,a,A)=>{var s=A(8668),l=A(2908),c=A(4757);C.exports=function(u,d,h,f,m,b){var p=1&h,y=u.length,Z=d.length;if(y!=Z&&!(p&&Z>y))return!1;var v=b.get(u),G=b.get(d);if(v&&G)return v==d&&G==u;var B=-1,S=!0,R=2&h?new s:void 0;for(b.set(u,d),b.set(d,u);++B{var s=A(2705),l=A(1149),c=A(7813),u=A(7114),d=A(8776),h=A(1814),f=s?s.prototype:void 0,m=f?f.valueOf:void 0;C.exports=function(b,p,y,Z,v,G,B){switch(y){case"[object DataView]":if(b.byteLength!=p.byteLength||b.byteOffset!=p.byteOffset)return!1;b=b.buffer,p=p.buffer;case"[object ArrayBuffer]":return!(b.byteLength!=p.byteLength||!G(new l(b),new l(p)));case"[object Boolean]":case"[object Date]":case"[object Number]":return c(+b,+p);case"[object Error]":return b.name==p.name&&b.message==p.message;case"[object RegExp]":case"[object String]":return b==p+"";case"[object Map]":var S=d;case"[object Set]":var R=1&Z;if(S||(S=h),b.size!=p.size&&!R)return!1;var w=B.get(b);if(w)return w==p;Z|=2,B.set(b,p);var T=u(S(b),S(p),Z,v,G,B);return B.delete(b),T;case"[object Symbol]":if(m)return m.call(b)==m.call(p)}return!1}},6096:(C,a,A)=>{var s=A(8234),l=Object.prototype.hasOwnProperty;C.exports=function(c,u,d,h,f,m){var b=1&d,p=s(c),y=p.length;if(y!=s(u).length&&!b)return!1;for(var Z=y;Z--;){var v=p[Z];if(!(b?v in u:l.call(u,v)))return!1}var G=m.get(c),B=m.get(u);if(G&&B)return G==u&&B==c;var S=!0;m.set(c,u),m.set(u,c);for(var R=b;++Z{var s=typeof A.g=="object"&&A.g&&A.g.Object===Object&&A.g;C.exports=s},8234:(C,a,A)=>{var s=A(8866),l=A(9551),c=A(3674);C.exports=function(u){return s(u,c,l)}},5050:(C,a,A)=>{var s=A(7019);C.exports=function(l,c){var u=l.__data__;return s(c)?u[typeof c=="string"?"string":"hash"]:u.map}},852:(C,a,A)=>{var s=A(8458),l=A(7801);C.exports=function(c,u){var d=l(c,u);return s(d)?d:void 0}},9607:(C,a,A)=>{var s=A(2705),l=Object.prototype,c=l.hasOwnProperty,u=l.toString,d=s?s.toStringTag:void 0;C.exports=function(h){var f=c.call(h,d),m=h[d];try{h[d]=void 0;var b=!0}catch{}var p=u.call(h);return b&&(f?h[d]=m:delete h[d]),p}},9551:(C,a,A)=>{var s=A(4963),l=A(479),c=Object.prototype.propertyIsEnumerable,u=Object.getOwnPropertySymbols,d=u?function(h){return h==null?[]:(h=Object(h),s(u(h),function(f){return c.call(h,f)}))}:l;C.exports=d},4160:(C,a,A)=>{var s=A(8552),l=A(7071),c=A(3818),u=A(8525),d=A(577),h=A(4239),f=A(346),m="[object Map]",b="[object Promise]",p="[object Set]",y="[object WeakMap]",Z="[object DataView]",v=f(s),G=f(l),B=f(c),S=f(u),R=f(d),w=h;(s&&w(new s(new ArrayBuffer(1)))!=Z||l&&w(new l)!=m||c&&w(c.resolve())!=b||u&&w(new u)!=p||d&&w(new d)!=y)&&(w=function(T){var W=h(T),V=W=="[object Object]"?T.constructor:void 0,X=V?f(V):"";if(X)switch(X){case v:return Z;case G:return m;case B:return b;case S:return p;case R:return y}return W}),C.exports=w},7801:C=>{C.exports=function(a,A){return a?.[A]}},1789:(C,a,A)=>{var s=A(4536);C.exports=function(){this.__data__=s?s(null):{},this.size=0}},401:C=>{C.exports=function(a){var A=this.has(a)&&delete this.__data__[a];return this.size-=A?1:0,A}},7667:(C,a,A)=>{var s=A(4536),l=Object.prototype.hasOwnProperty;C.exports=function(c){var u=this.__data__;if(s){var d=u[c];return d==="__lodash_hash_undefined__"?void 0:d}return l.call(u,c)?u[c]:void 0}},1327:(C,a,A)=>{var s=A(4536),l=Object.prototype.hasOwnProperty;C.exports=function(c){var u=this.__data__;return s?u[c]!==void 0:l.call(u,c)}},1866:(C,a,A)=>{var s=A(4536);C.exports=function(l,c){var u=this.__data__;return this.size+=this.has(l)?0:1,u[l]=s&&c===void 0?"__lodash_hash_undefined__":c,this}},5776:C=>{var a=/^(?:0|[1-9]\d*)$/;C.exports=function(A,s){var l=typeof A;return!!(s=s??9007199254740991)&&(l=="number"||l!="symbol"&&a.test(A))&&A>-1&&A%1==0&&A{C.exports=function(a){var A=typeof a;return A=="string"||A=="number"||A=="symbol"||A=="boolean"?a!=="__proto__":a===null}},5346:(C,a,A)=>{var s,l=A(4429),c=(s=/[^.]+$/.exec(l&&l.keys&&l.keys.IE_PROTO||""))?"Symbol(src)_1."+s:"";C.exports=function(u){return!!c&&c in u}},5726:C=>{var a=Object.prototype;C.exports=function(A){var s=A&&A.constructor;return A===(typeof s=="function"&&s.prototype||a)}},7040:C=>{C.exports=function(){this.__data__=[],this.size=0}},4125:(C,a,A)=>{var s=A(8470),l=Array.prototype.splice;C.exports=function(c){var u=this.__data__,d=s(u,c);return!(d<0||(d==u.length-1?u.pop():l.call(u,d,1),--this.size,0))}},2117:(C,a,A)=>{var s=A(8470);C.exports=function(l){var c=this.__data__,u=s(c,l);return u<0?void 0:c[u][1]}},7518:(C,a,A)=>{var s=A(8470);C.exports=function(l){return s(this.__data__,l)>-1}},4705:(C,a,A)=>{var s=A(8470);C.exports=function(l,c){var u=this.__data__,d=s(u,l);return d<0?(++this.size,u.push([l,c])):u[d][1]=c,this}},4785:(C,a,A)=>{var s=A(1989),l=A(8407),c=A(7071);C.exports=function(){this.size=0,this.__data__={hash:new s,map:new(c||l),string:new s}}},1285:(C,a,A)=>{var s=A(5050);C.exports=function(l){var c=s(this,l).delete(l);return this.size-=c?1:0,c}},6e3:(C,a,A)=>{var s=A(5050);C.exports=function(l){return s(this,l).get(l)}},9916:(C,a,A)=>{var s=A(5050);C.exports=function(l){return s(this,l).has(l)}},5265:(C,a,A)=>{var s=A(5050);C.exports=function(l,c){var u=s(this,l),d=u.size;return u.set(l,c),this.size+=u.size==d?0:1,this}},8776:C=>{C.exports=function(a){var A=-1,s=Array(a.size);return a.forEach(function(l,c){s[++A]=[c,l]}),s}},4536:(C,a,A)=>{var s=A(852)(Object,"create");C.exports=s},6916:(C,a,A)=>{var s=A(5569)(Object.keys,Object);C.exports=s},1167:(C,a,A)=>{C=A.nmd(C);var s=A(1957),l=a&&!a.nodeType&&a,c=l&&C&&!C.nodeType&&C,u=c&&c.exports===l&&s.process,d=function(){try{return c&&c.require&&c.require("util").types||u&&u.binding&&u.binding("util")}catch{}}();C.exports=d},2333:C=>{var a=Object.prototype.toString;C.exports=function(A){return a.call(A)}},5569:C=>{C.exports=function(a,A){return function(s){return a(A(s))}}},5639:(C,a,A)=>{var s=A(1957),l=typeof self=="object"&&self&&self.Object===Object&&self,c=s||l||Function("return this")();C.exports=c},619:C=>{C.exports=function(a){return this.__data__.set(a,"__lodash_hash_undefined__"),this}},2385:C=>{C.exports=function(a){return this.__data__.has(a)}},1814:C=>{C.exports=function(a){var A=-1,s=Array(a.size);return a.forEach(function(l){s[++A]=l}),s}},7465:(C,a,A)=>{var s=A(8407);C.exports=function(){this.__data__=new s,this.size=0}},3779:C=>{C.exports=function(a){var A=this.__data__,s=A.delete(a);return this.size=A.size,s}},7599:C=>{C.exports=function(a){return this.__data__.get(a)}},4758:C=>{C.exports=function(a){return this.__data__.has(a)}},4309:(C,a,A)=>{var s=A(8407),l=A(7071),c=A(3369);C.exports=function(u,d){var h=this.__data__;if(h instanceof s){var f=h.__data__;if(!l||f.length<199)return f.push([u,d]),this.size=++h.size,this;h=this.__data__=new c(f)}return h.set(u,d),this.size=h.size,this}},346:C=>{var a=Function.prototype.toString;C.exports=function(A){if(A!=null){try{return a.call(A)}catch{}try{return A+""}catch{}}return""}},7813:C=>{C.exports=function(a,A){return a===A||a!=a&&A!=A}},5694:(C,a,A)=>{var s=A(9454),l=A(7005),c=Object.prototype,u=c.hasOwnProperty,d=c.propertyIsEnumerable,h=s(function(){return arguments}())?s:function(f){return l(f)&&u.call(f,"callee")&&!d.call(f,"callee")};C.exports=h},1469:C=>{var a=Array.isArray;C.exports=a},8612:(C,a,A)=>{var s=A(3560),l=A(1780);C.exports=function(c){return c!=null&&l(c.length)&&!s(c)}},4144:(C,a,A)=>{C=A.nmd(C);var s=A(5639),l=A(5062),c=a&&!a.nodeType&&a,u=c&&C&&!C.nodeType&&C,d=u&&u.exports===c?s.Buffer:void 0,h=(d?d.isBuffer:void 0)||l;C.exports=h},8446:(C,a,A)=>{var s=A(939);C.exports=function(l,c){return s(l,c)}},3560:(C,a,A)=>{var s=A(4239),l=A(3218);C.exports=function(c){if(!l(c))return!1;var u=s(c);return u=="[object Function]"||u=="[object GeneratorFunction]"||u=="[object AsyncFunction]"||u=="[object Proxy]"}},1780:C=>{C.exports=function(a){return typeof a=="number"&&a>-1&&a%1==0&&a<=9007199254740991}},3218:C=>{C.exports=function(a){var A=typeof a;return a!=null&&(A=="object"||A=="function")}},7005:C=>{C.exports=function(a){return a!=null&&typeof a=="object"}},6719:(C,a,A)=>{var s=A(8749),l=A(1717),c=A(1167),u=c&&c.isTypedArray,d=u?l(u):s;C.exports=d},3674:(C,a,A)=>{var s=A(4636),l=A(280),c=A(8612);C.exports=function(u){return c(u)?s(u):l(u)}},8306:(C,a,A)=>{var s=A(3369);function l(c,u){if(typeof c!="function"||u!=null&&typeof u!="function")throw new TypeError("Expected a function");var d=function(){var h=arguments,f=u?u.apply(this,h):h[0],m=d.cache;if(m.has(f))return m.get(f);var b=c.apply(this,h);return d.cache=m.set(f,b)||m,b};return d.cache=new(l.Cache||s),d}l.Cache=s,C.exports=l},479:C=>{C.exports=function(){return[]}},5062:C=>{C.exports=function(){return!1}},2703:(C,a,A)=>{var s=A(414);function l(){}function c(){}c.resetWarningCache=l,C.exports=function(){function u(f,m,b,p,y,Z){if(Z!==s){var v=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw v.name="Invariant Violation",v}}function d(){return u}u.isRequired=u;var h={array:u,bigint:u,bool:u,func:u,number:u,object:u,string:u,symbol:u,any:u,arrayOf:d,element:u,elementType:u,instanceOf:d,node:u,objectOf:d,oneOf:d,oneOfType:d,shape:d,exact:d,checkPropTypes:c,resetWarningCache:l};return h.PropTypes=h,h}},5697:(C,a,A)=>{C.exports=A(2703)()},414:C=>{C.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},9787:C=>{C.exports=i}},I={};function r(C){var a=I[C];if(a!==void 0)return a.exports;var A=I[C]={id:C,loaded:!1,exports:{}};return n[C](A,A.exports,r),A.loaded=!0,A.exports}r.n=C=>{var a=C&&C.__esModule?()=>C.default:()=>C;return r.d(a,{a}),a},r.d=(C,a)=>{for(var A in a)r.o(a,A)&&!r.o(C,A)&&Object.defineProperty(C,A,{enumerable:!0,get:a[A]})},r.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),r.o=(C,a)=>Object.prototype.hasOwnProperty.call(C,a),r.r=C=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(C,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(C,"__esModule",{value:!0})},r.nmd=C=>(C.paths=[],C.children||(C.children=[]),C);var o={};return(()=>{r.r(o),r.d(o,{default:()=>Ke,expandNodesToLevel:()=>be});var C=r(4184),a=r.n(C),A=r(8446),s=r.n(A),l=r(8306),c=r.n(l);let u=(de=21)=>crypto.getRandomValues(new Uint8Array(de)).reduce((le,ne)=>le+((ne&=63)<36?ne.toString(36):ne<62?(ne-26).toString(36).toUpperCase():ne>62?"-":"_"),"");var d=r(5697),h=r.n(d),f=r(9787),m=r.n(f);function b(de){return b=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(le){return typeof le}:function(le){return le&&typeof Symbol=="function"&&le.constructor===Symbol&&le!==Symbol.prototype?"symbol":typeof le},b(de)}var p=["children","title"];function y(){return y=Object.assign?Object.assign.bind():function(de){for(var le=1;le"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var Me,Ne=S(re);if(Se){var De=S(this).constructor;Me=Reflect.construct(Ne,arguments,De)}else Me=Ne.apply(this,arguments);return B(this,Me)});function xe(){return Z(this,xe),Fe.apply(this,arguments)}return le=xe,(ne=[{key:"render",value:function(){var Me=this.props,Ne=Me.children,De=Me.title,O=function(D,q){if(D==null)return{};var ce,he,Oe=function(bt,Xt){if(bt==null)return{};var Jt,Zt,Ft={},ig=Object.keys(bt);for(Zt=0;Zt=0||(Ft[Jt]=bt[Jt]);return Ft}(D,q);if(Object.getOwnPropertySymbols){var Je=Object.getOwnPropertySymbols(D);for(he=0;he=0||Object.prototype.propertyIsEnumerable.call(D,ce)&&(Oe[ce]=D[ce])}return Oe}(Me,p);return m().createElement("button",y({"aria-label":De,title:De,type:"button"},O),Ne)}}])&&v(le.prototype,ne),Object.defineProperty(le,"prototype",{writable:!1}),xe}(m().PureComponent);R(w,"propTypes",{children:h().node.isRequired,title:h().string}),R(w,"defaultProps",{title:null});const T=w,W={ALL:"all",PARENT:"parent",LEAF:"leaf"};function V(de){this.message=de,this.stack=Error().stack}V.prototype=Object.create(Error.prototype),V.prototype.name="CheckboxTreeError";const X=V;function N(de,le){var ne=Object.keys(de);if(Object.getOwnPropertySymbols){var re=Object.getOwnPropertySymbols(de);le&&(re=re.filter(function(Se){return Object.getOwnPropertyDescriptor(de,Se).enumerable})),ne.push.apply(ne,re)}return ne}function Y(de,le,ne){return le in de?Object.defineProperty(de,le,{value:ne,enumerable:!0,configurable:!0,writable:!0}):de[le]=ne,de}function x(de,le){if(!(de instanceof le))throw new TypeError("Cannot call a class as a function")}function M(de,le){for(var ne=0;ne1&&arguments[1]!==void 0?arguments[1]:{};x(this,de),this.props=re,this.flatNodes=Se}var le,ne;return le=de,ne=[{key:"setProps",value:function(re){this.props=re}},{key:"clone",value:function(){var re=this,Se={};return Object.keys(this.flatNodes).forEach(function(Fe){var xe=re.flatNodes[Fe];Se[Fe]=function(Me){for(var Ne=1;Ne1&&arguments[1]!==void 0?arguments[1]:{},xe=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(Array.isArray(re)&&re.length!==0){var Me=this.props,Ne=Me.disabled,De=Me.noCascade;re.forEach(function(O,D){var q=Se.nodeHasChildren(O);if(Se.flatNodes[O.value]!==void 0)throw new X("Duplicate value '".concat(O.value,"' detected. All node values must be unique."));Se.flatNodes[O.value]={label:O.label,value:O.value,children:O.children,parent:Fe,isChild:Fe.value!==void 0,isParent:q,isLeaf:!q,showCheckbox:O.showCheckbox===void 0||O.showCheckbox,disabled:Se.getDisabledState(O,Fe,Ne,De),treeDepth:xe,index:D},Se.flattenNodes(O.children,O,xe+1)})}}},{key:"nodeHasChildren",value:function(re){return Array.isArray(re.children)}},{key:"getDisabledState",value:function(re,Se,Fe,xe){return!!Fe||!(xe||!Se.disabled)||!!re.disabled}},{key:"deserializeLists",value:function(re){var Se=this,Fe=["checked","expanded"];Object.keys(this.flatNodes).forEach(function(xe){Fe.forEach(function(Me){Se.flatNodes[xe][Me]=!1})}),Fe.forEach(function(xe){re[xe].forEach(function(Me){Se.flatNodes[Me]!==void 0&&(Se.flatNodes[Me][xe]=!0)})})}},{key:"serializeList",value:function(re){var Se=this,Fe=[];return Object.keys(this.flatNodes).forEach(function(xe){Se.flatNodes[xe][re]&&Fe.push(xe)}),Fe}},{key:"expandAllNodes",value:function(re){var Se=this;return Object.keys(this.flatNodes).forEach(function(Fe){Se.flatNodes[Fe].isParent&&(Se.flatNodes[Fe].expanded=re)}),this}},{key:"toggleChecked",value:function(re,Se,Fe,xe){var Me=this,Ne=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],De=this.flatNodes[re.value],O=[F.PARENT,F.ALL].indexOf(Fe)>-1,D=[F.LEAF,F.ALL].indexOf(Fe)>-1;if(De.isLeaf||xe){if(re.disabled)return this;this.toggleNode(re.value,"checked",Se)}else(O||De.children.length===0)&&this.toggleNode(re.value,"checked",Se),D&&De.children.forEach(function(q){Me.toggleChecked(q,Se,Fe,xe,!1)});return Ne&&!xe&&De.isChild&&O&&this.toggleParentStatus(De.parent,Fe),this}},{key:"toggleParentStatus",value:function(re,Se){var Fe=this.flatNodes[re.value];Fe.isChild?(Se===F.ALL&&this.toggleNode(re.value,"checked",this.isEveryChildChecked(Fe)),this.toggleParentStatus(Fe.parent,Se)):this.toggleNode(re.value,"checked",this.isEveryChildChecked(Fe))}},{key:"isEveryChildChecked",value:function(re){var Se=this;return re.children.every(function(Fe){return Se.getNode(Fe.value).checked})}},{key:"toggleNode",value:function(re,Se,Fe){return this.flatNodes[re][Se]=Fe,this}}],ne&&M(le.prototype,ne),Object.defineProperty(le,"prototype",{writable:!1}),de}();function Q(de){return Q=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(le){return typeof le}:function(le){return le&&typeof Symbol=="function"&&le.constructor===Symbol&&le!==Symbol.prototype?"symbol":typeof le},Q(de)}function U(){return U=Object.assign?Object.assign.bind():function(de){for(var le=1;le"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var Me,Ne=oe(re);if(Se){var De=oe(this).constructor;Me=Reflect.construct(Ne,arguments,De)}else Me=Ne.apply(this,arguments);return Ve(this,Me)});function xe(){return ee(this,xe),Fe.apply(this,arguments)}return le=xe,ne=[{key:"componentDidMount",value:function(){this.updateDeterminateProperty()}},{key:"componentDidUpdate",value:function(){this.updateDeterminateProperty()}},{key:"updateDeterminateProperty",value:function(){var Me=this.props.indeterminate;this.checkbox.indeterminate=Me}},{key:"render",value:function(){var Me=this,Ne=function(De){for(var O=1;O"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var Me,Ne=it(re);if(Se){var De=it(this).constructor;Me=Reflect.construct(Ne,arguments,De)}else Me=Ne.apply(this,arguments);return _e(this,Me)});function xe(Me){var Ne;return function(De,O){if(!(De instanceof O))throw new TypeError("Cannot call a class as a function")}(this,xe),(Ne=Fe.call(this,Me)).onCheck=Ne.onCheck.bind(Pe(Ne)),Ne.onCheckboxKeyPress=Ne.onCheckboxKeyPress.bind(Pe(Ne)),Ne.onCheckboxKeyUp=Ne.onCheckboxKeyUp.bind(Pe(Ne)),Ne.onClick=Ne.onClick.bind(Pe(Ne)),Ne.onExpand=Ne.onExpand.bind(Pe(Ne)),Ne}return le=xe,(ne=[{key:"onCheck",value:function(){var Me=this.props,Ne=Me.value;(0,Me.onCheck)({value:Ne,checked:this.getCheckState({toggle:!0})})}},{key:"onCheckboxKeyPress",value:function(Me){Me.which===32&&Me.preventDefault()}},{key:"onCheckboxKeyUp",value:function(Me){var Ne=Me.keyCode;[13,32].includes(Ne)&&this.onCheck()}},{key:"onClick",value:function(){var Me=this.props,Ne=Me.expandOnClick,De=Me.isParent,O=Me.value,D=Me.onClick;De&&Ne&&this.onExpand(),D({value:O,checked:this.getCheckState({toggle:!1})})}},{key:"onExpand",value:function(){var Me=this.props,Ne=Me.expanded,De=Me.value;(0,Me.onExpand)({value:De,expanded:!Ne})}},{key:"getCheckState",value:function(Me){var Ne=Me.toggle,De=this.props,O=De.checked,D=De.optimisticToggle;return!(O!==0||!Ne)||O===1&&!Ne||O===2&&D}},{key:"renderCollapseButton",value:function(){var Me=this.props,Ne=Me.expandDisabled,De=Me.isLeaf,O=Me.lang;return De?m().createElement("span",{className:"rct-collapse"},m().createElement("span",{className:"rct-icon"})):m().createElement(T,{className:"rct-collapse rct-collapse-btn",disabled:Ne,title:O.toggle,onClick:this.onExpand},this.renderCollapseIcon())}},{key:"renderCollapseIcon",value:function(){var Me=this.props,Ne=Me.expanded,De=Me.icons,O=De.expandClose,D=De.expandOpen;return Ne?D:O}},{key:"renderCheckboxIcon",value:function(){var Me=this.props,Ne=Me.checked,De=Me.icons,O=De.uncheck,D=De.check,q=De.halfCheck;return Ne===0?O:Ne===1?D:q}},{key:"renderNodeIcon",value:function(){var Me=this.props,Ne=Me.expanded,De=Me.icon,O=Me.icons,D=O.leaf,q=O.parentClose,ce=O.parentOpen,he=Me.isLeaf;return De!==null?De:he?D:Ne?ce:q}},{key:"renderBareLabel",value:function(Me){var Ne=this.props,De=Ne.onClick,O=Ne.title,D=De!==null;return m().createElement("span",{className:"rct-bare-label",title:O},D?m().createElement("span",{className:"rct-node-clickable",onClick:this.onClick,onKeyPress:this.onClick,role:"button",tabIndex:0},Me):Me)}},{key:"renderCheckboxLabel",value:function(Me){var Ne=this.props,De=Ne.checked,O=Ne.disabled,D=Ne.title,q=Ne.treeId,ce=Ne.value,he=Ne.onClick!==null,Oe="".concat(q,"-").concat(String(ce).split(" ").join("_")),Je=[m().createElement("label",{key:0,htmlFor:Oe,title:D},m().createElement(ie,{checked:De===1,disabled:O,id:Oe,indeterminate:De===2,onClick:this.onCheck,onChange:function(){}}),m().createElement("span",{"aria-checked":De===1,"aria-disabled":O,className:"rct-checkbox",role:"checkbox",tabIndex:0,onKeyPress:this.onCheckboxKeyPress,onKeyUp:this.onCheckboxKeyUp},this.renderCheckboxIcon()),he?null:Me)];return he&&Je.push(m().createElement("span",{key:1,className:"rct-node-clickable",onClick:this.onClick,onKeyPress:this.onClick,role:"link",tabIndex:0},Me)),Je}},{key:"renderLabel",value:function(){var Me=this.props,Ne=Me.label,De=Me.showCheckbox,O=[Me.showNodeIcon?m().createElement("span",{key:0,className:"rct-node-icon"},this.renderNodeIcon()):null,m().createElement("span",{key:1,className:"rct-title"},Ne)];return De?this.renderCheckboxLabel(O):this.renderBareLabel(O)}},{key:"renderChildren",value:function(){return this.props.expanded?this.props.children:null}},{key:"render",value:function(){var Me=this.props,Ne=Me.className,De=Me.disabled,O=Me.expanded,D=Me.isLeaf,q=a()({"rct-node":!0,"rct-node-leaf":D,"rct-node-parent":!D,"rct-node-expanded":!D&&O,"rct-node-collapsed":!D&&!O,"rct-disabled":De},Ne);return m().createElement("li",{className:q},m().createElement("span",{className:"rct-text"},this.renderCollapseButton(),this.renderLabel()),this.renderChildren())}}])&&Be(le.prototype,ne),Object.defineProperty(le,"prototype",{writable:!1}),xe}(m().PureComponent);lt(je,"propTypes",{checked:h().number.isRequired,disabled:h().bool.isRequired,expandDisabled:h().bool.isRequired,expanded:h().bool.isRequired,icons:ye.isRequired,isLeaf:h().bool.isRequired,isParent:h().bool.isRequired,label:h().node.isRequired,lang:ue.isRequired,optimisticToggle:h().bool.isRequired,showNodeIcon:h().bool.isRequired,treeId:h().string.isRequired,value:h().oneOfType([h().string,h().number]).isRequired,onCheck:h().func.isRequired,onExpand:h().func.isRequired,children:h().node,className:h().string,expandOnClick:h().bool,icon:h().node,showCheckbox:h().bool,title:h().string,onClick:h().func}),lt(je,"defaultProps",{children:null,className:null,expandOnClick:!1,icon:null,showCheckbox:!0,title:null,onClick:function(){}});const He=je,Ce=h().oneOfType([h().arrayOf(h().string),h().arrayOf(h().number)]);function Ze(de,le){var ne=Object.keys(de);if(Object.getOwnPropertySymbols){var re=Object.getOwnPropertySymbols(de);le&&(re=re.filter(function(Se){return Object.getOwnPropertyDescriptor(de,Se).enumerable})),ne.push.apply(ne,re)}return ne}function Te(de){for(var le=1;le"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var Ne,De=yt(Se);if(Fe){var O=yt(this).constructor;Ne=Reflect.construct(De,arguments,O)}else Ne=De.apply(this,arguments);return wt(this,Ne)});function Me(Ne){var De;(function(D,q){if(!(D instanceof q))throw new TypeError("Cannot call a class as a function")})(this,Me),De=xe.call(this,Ne);var O=new $(Ne);return O.flattenNodes(Ne.nodes),O.deserializeLists({checked:Ne.checked,expanded:Ne.expanded}),De.state={id:Ne.id||"rct-".concat(u()),model:O,prevProps:Ne},De.onCheck=De.onCheck.bind(kt(De)),De.onExpand=De.onExpand.bind(kt(De)),De.onNodeClick=De.onNodeClick.bind(kt(De)),De.onExpandAll=De.onExpandAll.bind(kt(De)),De.onCollapseAll=De.onCollapseAll.bind(kt(De)),De.combineMemorized=c()(function(D,q){return Re(Re({},D),q)}).bind(kt(De)),De}return le=Me,ne=[{key:"onCheck",value:function(Ne){var De=this.props,O=De.checkModel,D=De.noCascade,q=De.onCheck,ce=this.state.model.clone(),he=ce.getNode(Ne.value);ce.toggleChecked(Ne,Ne.checked,O,D),q(ce.serializeList("checked"),Re(Re({},he),Ne))}},{key:"onExpand",value:function(Ne){var De=this.props.onExpand,O=this.state.model.clone(),D=O.getNode(Ne.value);O.toggleNode(Ne.value,"expanded",Ne.expanded),De(O.serializeList("expanded"),Re(Re({},D),Ne))}},{key:"onNodeClick",value:function(Ne){(0,this.props.onClick)(Re(Re({},this.state.model.getNode(Ne.value)),Ne))}},{key:"onExpandAll",value:function(){this.expandAllNodes()}},{key:"onCollapseAll",value:function(){this.expandAllNodes(!1)}},{key:"expandAllNodes",value:function(){var Ne=!(arguments.length>0&&arguments[0]!==void 0)||arguments[0],De=this.props.onExpand;De(this.state.model.clone().expandAllNodes(Ne).serializeList("expanded"))}},{key:"determineShallowCheckState",value:function(Ne,De){var O=this.state.model.getNode(Ne.value);return O.isLeaf||De||Ne.children.length===0?O.checked?1:0:this.isEveryChildChecked(Ne)?1:this.isSomeChildChecked(Ne)?2:0}},{key:"isEveryChildChecked",value:function(Ne){var De=this;return Ne.children.every(function(O){return De.state.model.getNode(O.value).checkState===1})}},{key:"isSomeChildChecked",value:function(Ne){var De=this;return Ne.children.some(function(O){return De.state.model.getNode(O.value).checkState>0})}},{key:"renderTreeNodes",value:function(Ne){var De=this,O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},D=this.props,q=D.expandDisabled,ce=D.expandOnClick,he=D.icons,Oe=D.lang,Je=D.noCascade,bt=D.onClick,Xt=D.onlyLeafCheckboxes,Jt=D.optimisticToggle,Zt=D.showNodeTitle,Ft=D.showNodeIcon,ig=this.state,ct=ig.id,Mt=ig.model,Cg=Me.defaultProps.icons,$t=Ne.map(function(qg){var Ti=qg.value,It=Mt.getNode(qg.value),Tt=It.isParent?De.renderTreeNodes(qg.children,qg):null;It.checkState=De.determineShallowCheckState(qg,Je);var cg=Xt?It.isLeaf:It.showCheckbox;return!O.value||Mt.getNode(O.value).expanded?m().createElement(He,{key:Ti,checked:It.checkState,className:qg.className,disabled:It.disabled,expandDisabled:q,expandOnClick:ce,expanded:It.expanded,icon:qg.icon,icons:De.combineMemorized(Cg,he),label:qg.label,lang:Oe,optimisticToggle:Jt,isLeaf:It.isLeaf,isParent:It.isParent,showCheckbox:cg,showNodeIcon:Ft,title:Zt?qg.title||qg.label:qg.title,treeId:ct,value:qg.value,onCheck:De.onCheck,onClick:bt&&De.onNodeClick,onExpand:De.onExpand},Tt):null});return m().createElement("ol",null,$t)}},{key:"renderExpandAll",value:function(){var Ne=this.props,De=Ne.icons,O=De.expandAll,D=De.collapseAll,q=Ne.lang;return Ne.showExpandAll?m().createElement("div",{className:"rct-options"},m().createElement(T,{className:"rct-option rct-option-expand-all",title:q.expandAll,onClick:this.onExpandAll},O),m().createElement(T,{className:"rct-option rct-option-collapse-all",title:q.collapseAll,onClick:this.onCollapseAll},D)):null}},{key:"renderHiddenInput",value:function(){var Ne=this.props,De=Ne.name,O=Ne.nameAsArray;return De===void 0?null:O?this.renderArrayHiddenInput():this.renderJoinedHiddenInput()}},{key:"renderArrayHiddenInput",value:function(){var Ne=this.props,De=Ne.checked,O=Ne.name;return De.map(function(D){var q="".concat(O,"[]");return m().createElement("input",{key:D,name:q,type:"hidden",value:D})})}},{key:"renderJoinedHiddenInput",value:function(){var Ne=this.props,De=Ne.checked,O=Ne.name,D=De.join(",");return m().createElement("input",{name:O,type:"hidden",value:D})}},{key:"render",value:function(){var Ne,De=this.props,O=De.direction,D=De.disabled,q=De.iconsClass,ce=De.nodes,he=De.nativeCheckboxes,Oe=this.state.id,Je=this.renderTreeNodes(ce),bt=a()((Pt(Ne={"react-checkbox-tree":!0,"rct-disabled":D},"rct-icons-".concat(q),!0),Pt(Ne,"rct-native-display",he),Pt(Ne,"rct-direction-rtl",O==="rtl"),Ne));return m().createElement("div",{className:bt,id:Oe},this.renderExpandAll(),this.renderHiddenInput(),Je)}}],re=[{key:"getDerivedStateFromProps",value:function(Ne,De){var O=De.model,D=De.prevProps,q=Ne.disabled,ce=Ne.id,he=Ne.nodes,Oe=Re(Re({},De),{},{prevProps:Ne});return O.setProps(Ne),s()(D.nodes,he)&&D.disabled===q||(O.reset(),O.flattenNodes(he)),ce!==null&&(Oe=Re(Re({},Oe),{},{id:ce})),O.deserializeLists({checked:Ne.checked,expanded:Ne.expanded}),Oe}}],ne&&Ee(le.prototype,ne),re&&Ee(le,re),Object.defineProperty(le,"prototype",{writable:!1}),Me}(m().Component);function z(de){return function(le){if(Array.isArray(le))return J(le)}(de)||function(le){if(typeof Symbol<"u"&&le[Symbol.iterator]!=null||le["@@iterator"]!=null)return Array.from(le)}(de)||function(le,ne){if(le){if(typeof le=="string")return J(le,ne);var re=Object.prototype.toString.call(le).slice(8,-1);return re==="Object"&&le.constructor&&(re=le.constructor.name),re==="Map"||re==="Set"?Array.from(le):re==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(re)?J(le,ne):void 0}}(de)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function J(de,le){(le==null||le>de.length)&&(le=de.length);for(var ne=0,re=new Array(le);ne2&&arguments[2]!==void 0?arguments[2]:0;if(ne>le)return[];var re=[];return de.forEach(function(Se){Se.children&&(re=[].concat(z(re),[Se.value],z(be(Se.children,le,ne+1))))}),re}Pt(ge,"propTypes",{nodes:h().arrayOf(K).isRequired,checkModel:h().oneOf([W.LEAF,W.ALL]),checked:Ce,direction:h().string,disabled:h().bool,expandDisabled:h().bool,expandOnClick:h().bool,expanded:Ce,icons:ye,iconsClass:h().string,id:h().string,lang:ue,name:h().string,nameAsArray:h().bool,nativeCheckboxes:h().bool,noCascade:h().bool,onlyLeafCheckboxes:h().bool,optimisticToggle:h().bool,showExpandAll:h().bool,showNodeIcon:h().bool,showNodeTitle:h().bool,onCheck:h().func,onClick:h().func,onExpand:h().func}),Pt(ge,"defaultProps",{checkModel:W.LEAF,checked:[],direction:"ltr",disabled:!1,expandDisabled:!1,expandOnClick:!1,expanded:[],icons:{check:m().createElement("span",{className:"rct-icon rct-icon-check"}),uncheck:m().createElement("span",{className:"rct-icon rct-icon-uncheck"}),halfCheck:m().createElement("span",{className:"rct-icon rct-icon-half-check"}),expandClose:m().createElement("span",{className:"rct-icon rct-icon-expand-close"}),expandOpen:m().createElement("span",{className:"rct-icon rct-icon-expand-open"}),expandAll:m().createElement("span",{className:"rct-icon rct-icon-expand-all"}),collapseAll:m().createElement("span",{className:"rct-icon rct-icon-collapse-all"}),parentClose:m().createElement("span",{className:"rct-icon rct-icon-parent-close"}),parentOpen:m().createElement("span",{className:"rct-icon rct-icon-parent-open"}),leaf:m().createElement("span",{className:"rct-icon rct-icon-leaf"})},iconsClass:"fa4",id:null,lang:{collapseAll:"Collapse all",expandAll:"Expand all",toggle:"Toggle"},name:void 0,nameAsArray:!1,nativeCheckboxes:!1,noCascade:!1,onlyLeafCheckboxes:!1,optimisticToggle:!0,showExpandAll:!1,showNodeIcon:!0,showNodeTitle:!1,onCheck:function(){},onClick:null,onExpand:function(){}});const Ke=ge})(),o})())})(m$e);var d1g=m$e.exports;const h1g=EC(d1g);function f1g(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function ZWe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function cD(e){return cD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},cD(e)}let p$e=function(e){y1g(i,e);var g=Z1g(i);function i(n){var I;f1g(this,i),I=g.call(this,n),I.localTracks=kb.filter(a=>a.local&&!a.hidden).map(a=>{const A={...a};return A.datatype=a.datatype[0],A}),I.augmentedTracksInfo=kb,window.higlassTracksByType&&Object.keys(window.higlassTracksByType).forEach(a=>{I.augmentedTracksInfo.push(window.higlassTracksByType[a].config)}),n.datatype?I.localTracks=I.localTracks.filter(a=>a.datatype[0]===n.datatype):I.localTracks=I.localTracks.filter(a=>a.orientation===I.props.orientation),I.localTracks.forEach(a=>{a.uuid=Ng.nice()});const r=I.prepareNewEntries("",I.localTracks,{}),o=Object.keys(r),C=o.length?[o[0]]:null;return I.mounted=!1,I.state={selectedUuid:C,options:r,filter:"",checked:[],expanded:[]},I.requestTilesetLists(),I}return m1g(i,[{key:"componentDidMount",value:function(){this.mounted=!0,this.requestTilesetLists(),this.searchBox.focus()}},{key:"componentWillUnmount",value:function(){this.mounted=!1}},{key:"prepareNewEntries",value:function(I,r,o){const C=o;return r.map(A=>({...A,server:I,tilesetUid:A.uuid,serverUidKey:this.serverUidKey(I,A.uuid),datatype:A.datatype,name:A.name,uid:Ng.nice()})).forEach(A=>{C[A.serverUidKey]=A}),C}},{key:"serverUidKey",value:function(I,r){return`${I}/${r}`}},{key:"requestTilesetLists",value:function(){let I=null;if(this.props.datatype?I=`dt=${this.props.datatype}`:I=[...new Set([].concat(...this.augmentedTracksInfo.filter(o=>o.datatype).filter(o=>o.orientation===this.props.orientation||this.props.orientation==="1d-vertical"&&o.orientation==="1d-horizontal").map(o=>o.datatype)))].map(o=>`dt=${o}`).join("&"),!this.props.trackSourceServers){console.warn("No track source servers specified in the viewconf");return}this.props.trackSourceServers.forEach(r=>{Nt.json(`${r}/tilesets/?limit=10000&${I}`,(o,C)=>{if(o)console.error("ERROR:",o);else{const a=this.prepareNewEntries(r,C.results,this.state.options),A=Object.keys(a);let{selectedUuid:s}=this.state;if(!s){s=A.length?[A[0]]:null;const l=this.state.options[s[0]];this.props.selectedTilesetChanged([l])}this.mounted&&this.setState({selectedUuid:s,options:a})}},this.props.pubSub)})}},{key:"handleOptionDoubleClick",value:function(I){const r=this.state.options[I.target.value];this.props.onDoubleClick(r)}},{key:"handleSelectedOptions",value:function(I){const r=[],o=[];for(let C=0;CA.label.toLowerCase().localeCompare(s.label.toLowerCase(),"en")),C.push(o[a]));return C.sort((a,A)=>a.label.toLowerCase().localeCompare(A.label.toLowerCase(),"en")),C}},{key:"handleChecked",value:function(I){this.handleSelectedOptions(I),this.setState({checked:I})}},{key:"handleExpanded",value:function(I){this.setState({expanded:I})}},{key:"render",value:function(){const I=[];for(const A in this.state.options)I.push(this.state.options[A]);const r=this.partitionByGroup(this.state.options,this.state.filter),o={width:15,height:15,top:2,right:2,position:"relative"},C=JSON.parse(JSON.stringify(o));C.opacity=.5;const a=k.createElement("form",{onSubmit:A=>{A.preventDefault()}},k.createElement("div",{className:"tileset-finder-search-bar"},k.createElement("span",{className:"tileset-finder-label"},"Select tileset:"),k.createElement("input",{ref:A=>{this.searchBox=A},className:"tileset-finder-search-box",onChange:this.handleSearchChange.bind(this),placeholder:"Search Term",type:"text"})),k.createElement("div",{className:"tileset-finder-checkbox-tree"},k.createElement(h1g,{checked:this.state.checked,expanded:this.state.expanded,icons:{uncheck:k.createElement("svg",{style:o},k.createElement("use",{xlinkHref:"#square_o"})),check:k.createElement("svg",{style:o},k.createElement("use",{xlinkHref:"#check_square_o"})),halfCheck:k.createElement("svg",{style:C},k.createElement("use",{xlinkHref:"#check_square_o"})),leaf:k.createElement("svg",{style:o},k.createElement("use",{xlinkHref:"#file_o"})),expandClose:k.createElement("svg",{style:o},k.createElement("use",{xlinkHref:"#chevron_right"})),expandOpen:k.createElement("svg",{style:o},k.createElement("use",{xlinkHref:"#chevron_down"})),parentClose:k.createElement("svg",{style:o},k.createElement("use",{xlinkHref:"#folder_o"})),parentOpen:k.createElement("svg",{style:o},k.createElement("use",{xlinkHref:"#folder_open_o"}))},nodes:r,onCheck:this.handleChecked.bind(this),onExpand:this.handleExpanded.bind(this)})));return k.createElement("div",null,a)}}]),i}(k.Component);p$e.propTypes={datatype:L.string,orientation:L.string,onDoubleClick:L.func,pubSub:L.object.isRequired,selectedTilesetChanged:L.func,trackSourceServers:L.array};const w1g=L1(p$e);function S1g(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function GWe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function uD(e){return uD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},uD(e)}let b$e=function(e){X1g(i,e);var g=T1g(i);function i(n){var I;return S1g(this,i),I=g.call(this,n),I.DATATYPE_TO_TRACK_TYPE=Rae(I.props.orientation),I.AVAILABLE_TRACK_TYPES=KF(I.props.datatypes,I.props.orientation),I.state={selectedPlotType:I.AVAILABLE_TRACK_TYPES[0]},I}return R1g(i,[{key:"UNSAFE_componentWillReceiveProps",value:function(I){if(this.AVAILABLE_TRACK_TYPES=KF(I.datatypes,this.props.orientation),!!this.AVAILABLE_TRACK_TYPES&&I.allTracksSameDatatype&&this.AVAILABLE_TRACK_TYPES.length>0&&!this.AVAILABLE_TRACK_TYPES.includes(this.state.selectedPlotType)){const r=Xae(I.datatypes[0][0],this.props.position,this.AVAILABLE_TRACK_TYPES);this.handlePlotTypeSelected(r)}}},{key:"handlePlotTypeSelected",value:function(I){this.setState({selectedPlotType:I}),this.props.onPlotTypeSelected(I.type)}},{key:"render",value:function(){let I="No plot types available for track";const r={};return kb.forEach(o=>{r[o.type]=o}),this.AVAILABLE_TRACK_TYPES&&(I=this.AVAILABLE_TRACK_TYPES.sort((o,C)=>o.type{const C=r[o.type].thumbnail,a=this.state.selectedPlotType.type===o.type?"plot-type-item plot-type-selected":"plot-type-item",A=r[o.type].thumbnail?k.createElement("div",{className:"track-thumbnail",dangerouslySetInnerHTML:{__html:C.outerHTML}}):k.createElement("div",{className:"track-thumbnail"},k.createElement("svg",{height:20,width:30}));return k.createElement("li",{key:o.type,className:a,onClick:s=>{this.setState({selectedPlotType:o}),this.props.onPlotTypeSelected(o.type)},style:{listStyle:"none",paddingLeft:5,paddingBottom:0}},A,k.createElement("span",{style:{verticalAlign:"middle"}},o.type))})),k.createElement("div",null,I.length>0&&this.props.allTracksSameDatatype&&k.createElement("div",{className:"plot-type-container"},I),!this.props.allTracksSameDatatype&&k.createElement("div",{className:"plot-type-container-empty"},"Datasets with multiple datatypes chosen. They will be added with their default track types."))}}]),i}(k.Component);b$e.propTypes={allTracksSameDatatype:L.bool,datatypes:L.array,orientation:L.string,onPlotTypeSelected:L.func,position:L.string};function Y1g(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function vWe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function dD(e){return dD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},dD(e)}let hD=function(e){E1g(i,e);var g=D1g(i);function i(n){var I;return Y1g(this,i),I=g.call(this,n),I.options={},I.state={selectedTilesets:[{datatype:"none"}],allTracksSameDatatype:!0},I.handleSubmitBound=I.handleSubmit.bind(X5(I)),I.handleTilesetPickerDoubleClickBound=I.handleTilesetPickerDoubleClick.bind(X5(I)),I.selectedTilesetsChangedBound=I.selectedTilesetsChanged.bind(X5(I)),I}return K1g(i,[{key:"getOrientation",value:function(I){let r=null;return I==="top"||I==="bottom"?r="1d-horizontal":I==="left"||I==="right"?r="1d-vertical":r="2d",r}},{key:"handleSubmit",value:function(I){I&&I.preventDefault(),this.props.onTracksChosen(this.state.selectedTilesets,this.props.position,this.props.host)}},{key:"handleTilesetPickerDoubleClick",value:function(I){this.selectedTilesetsChanged([I]),this.props.onTracksChosen(this.state.selectedTilesets,this.props.position,this.props.host)}},{key:"handleOptionsChanged",value:function(I){this.options=I}},{key:"handlePlotTypeSelected",value:function(I){const{selectedTilesets:r}=this.state;for(const o of r)o.type=I;this.selectedPlotType=I,this.setState({selectedTilesets:r})}},{key:"selectedTilesetsChanged",value:function(I){let r=null;I.length===0?r=[{datatype:"none"}]:r=I;let o=!0;const C=r[0].datatype;for(const a of r)a.datatype!==C&&(o=!1);if(o)for(const a of r)a.type=this.selectedPlotType;else for(const a of r){let A=[a.datatype];const s=this.getOrientation(this.props.position);a.filetype==="cooler"&&(A=[a.datatype,"chromsizes"]);const l=KF([A],s),c=Xae(A[0],this.props.position,l);a.type=c.type}this.setState({selectedTilesets:r,allTracksSameDatatype:o})}},{key:"render",value:function(){const I=this.getOrientation(this.props.position),r=k.createElement("div",null,k.createElement(w1g,{ref:o=>{this.tilesetFinder=o},datatype:this.props.datatype,onDoubleClick:this.handleTilesetPickerDoubleClick.bind(this),onTracksChosen:o=>this.props.onTracksChosen(o,this.props.position),orientation:I,selectedTilesetChanged:this.selectedTilesetsChanged.bind(this),trackSourceServers:this.props.trackSourceServers}));return k.createElement(aH,{maxHeight:!0,okayTitle:"Submit",onCancel:this.props.onCancel,onOkay:this.handleSubmitBound,title:"Add Track"},k.createElement(k.Fragment,null,r,k.createElement(b$e,{ref:o=>{this.plotTypeChooser=o},allTracksSameDatatype:this.state.allTracksSameDatatype,datatypes:this.state.selectedTilesets.map(o=>o.filetype==="cooler"?[o.datatype,"chromsizes"]:[o.datatype]),onPlotTypeSelected:this.handlePlotTypeSelected.bind(this),orientation:I,position:this.props.position})))}}]),i}(k.Component);hD.defaultProps={position:"top"};hD.propTypes={datatype:L.string,host:L.string,onCancel:L.func.isRequired,onTracksChosen:L.func.isRequired,position:L.string,trackSourceServers:L.array.isRequired};function wge(){return wge=Object.assign?Object.assign.bind():function(e){for(var g=1;g"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function fD(e){return fD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},fD(e)}let mle=function(e){L1g(i,e);var g=U1g(i);function i(){return P1g(this,i),g.apply(this,arguments)}return _1g(i,[{key:"render",value:function(){const I=[];return this.props.children.forEach((r,o)=>{const C=`customTrackDialog_${o}`;I.push(k.createElement(r,wge({key:C},this.props.bodyProps[o])))}),k.createElement(aH,{maxHeight:!0,okayOnly:!0,okayTitle:"Close",onCancel:this.props.onCancel,onOkay:this.props.onCancel,title:this.props.title},I)}}]),i}(k.PureComponent);mle.defaultProps={};mle.propTypes={onCancel:L.func.isRequired,title:L.string,bodyProps:L.array,children:L.array};function q1g(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function wWe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function mD(e){return mD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},mD(e)}const SWe=20;let qm=function(e){iSg(i,e);var g=nSg(i);function i(n){var I;return q1g(this,i),I=g.call(this,n),I.adjusted=!1,I.state={orientation:I.props.orientation?I.props.orientation:"right",left:I.props.position.left,top:I.props.position.top,submenuShown:null},I}return eSg(i,[{key:"componentDidMount",value:function(){this.updateOrientation()}},{key:"UNSAFE_componentWillReceiveProps",value:function(I){this.adjusted=!1,this.setState({left:I.position.left,top:I.position.top})}},{key:"componentDidUpdate",value:function(){this.updateOrientation()}},{key:"handleItemMouseEnterWithRect",value:function(I,r){this.setState({submenuShown:r,submenuSourceBbox:I})}},{key:"handleItemMouseEnter",value:function(I,r){this.handleItemMouseEnterWithRect(I.currentTarget.getBoundingClientRect(),r)}},{key:"handleMouseLeave",value:function(){}},{key:"handleOtherMouseEnter",value:function(){this.setState({submenuShown:null})}},{key:"updateOrientation",value:function(){if(this.adjusted)return;this.adjusted=!0,this.divDom=_I.findDOMNode(this.div);const I=this.divDom.getBoundingClientRect(),r=this.props.parentBbox?this.props.parentBbox:{top:this.props.position.top,left:this.props.position.left,width:0,height:0};let o=this.state.orientation,C=r.top;if(r.top+I.height>window.innerHeight&&(r.top-I.height>0?C=r.top-I.height+SWe:(C=r.top-I.height+SWe,C-=C+I.height-window.innerHeight)),this.state.orientation==="left"){let a=r.left-I.width;a<0&&(r.left+r.width+I.width>window.innerWidth?a=0:(a=r.left+r.width,o="right")),this.setState({left:a,top:C,orientation:o})}else{let a=r.left+r.width;r.left+r.width+I.width>window.innerWidth&&(r.left-I.width<0?(a=0,o="right"):(a=r.left-I.width,o="left")),this.setState({left:a,top:C,orientation:o})}}},{key:"render",value:function(){const I=this.state.left?{left:this.state.left}:{right:this.state.right},r={top:this.state.top},o=Object.assign(I,r);return k.createElement("div",{ref:C=>{this.div=C},className:gi("context-menu-item",ug["context-menu"],{[ug["context-menu-dark"]]:this.props.theme===ki}),style:o},this.props.children)}}]),i}(k.Component);qm.propTypes={children:L.node,orientation:L.string,parentBbox:L.object,position:L.object,theme:L.symbol.isRequired};function CSg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function RWe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function pD(e){return pD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},pD(e)}let Wge=function(e){lSg(i,e);var g=cSg(i);function i(){return CSg(this,i),g.apply(this,arguments)}return aSg(i,[{key:"getSubmenu",value:function(){if(this.state.submenuShown){const I=this.state.submenuSourceBbox,r=this.state.orientation==="left"?{left:this.state.left,top:I.top}:{left:this.state.left+I.width+7,top:I.top},o=this.state.submenuShown;return k.createElement(i,{menuItems:o.children,orientation:this.state.orientation,parentBbox:I,position:r,theme:this.props.theme})}return k.createElement("div",null)}},{key:"componentWillUnmount",value:function(){}},{key:"render",value:function(){const I=[];for(const r in this.props.menuItems){const o=this.props.menuItems[r];I.push(k.createElement(yg,{key:r,onClick:o.handler?o.handler:()=>null,onMouseEnter:o.children?C=>this.handleItemMouseEnter(C,o):this.handleOtherMouseEnter.bind(this),onMouseLeave:this.handleMouseLeave},o.name,o.children&&k.createElement("svg",{className:ug["play-icon"]},k.createElement("use",{xlinkHref:"#play"}))))}return k.createElement("div",{ref:r=>{this.div=r},className:gi(ug["context-menu"],{[ug["context-menu-dark"]]:this.props.theme===ki}),style:{left:this.state.left,top:this.state.top}},I,this.getSubmenu())}}]),i}(qm);function fSg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function VWe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function bD(e){return bD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},bD(e)}let wSg=function(e){ySg(i,e);var g=ZSg(i);function i(){return fSg(this,i),g.apply(this,arguments)}return mSg(i,[{key:"getConfigureSeriesMenu",value:function(I,r,o){const C={},a=window.higlassTracksByType&&window.higlassTracksByType[o.type]&&window.higlassTracksByType[o.type].config&&window.higlassTracksByType[o.type].config.optionsInfo;if(a)for(const A of Object.keys(a))rr[A]=a[A];if(!wi[o.type]||!wi[o.type].availableOptions)return null;for(const A of wi[o.type].availableOptions)if(A in rr){if(C[A]={name:rr[A].name},rr[A].generateOptions){const s=rr[A].generateOptions(o);C[A].children||(C[A].children={});for(const l of s){const c={name:l.name,value:l.value,handler:()=>{o.options[A]=l.value,this.props.onTrackOptionsChanged(o.uid,o.options),this.props.closeMenu()}};C[A].children[l.value]=c}}if(rr[A].inlineOptions)for(const s in rr[A].inlineOptions){const l=rr[A].inlineOptions[s];C[A].children||(C[A].children={});const c={name:l.name,value:l.value};l.componentPickers&&l.componentPickers[o.type]?c.handler=()=>{this.props.onConfigureTrack(o,l.componentPickers[o.type]),this.props.closeMenu()}:c.handler=()=>{o.options[A]=l.value,this.props.onTrackOptionsChanged(o.uid,o.options),this.props.closeMenu()},C[A].children[s]=c}else rr[A].componentPickers&&rr[A].componentPickers[o.type]&&(C[A].handler=()=>{this.props.onConfigureTrack(o,rr[A].componentPickers[o.type]),this.props.closeMenu()})}return k.createElement(Wge,{key:"config-series-menu",closeMenu:this.props.closeMenu,menuItems:C,orientation:this.state.orientation,parentBbox:r,position:I,theme:this.props.theme})}},{key:"getTrackTypeItems",value:function(I,r,o){window.higlassTracksByType&&Object.keys(window.higlassTracksByType).forEach(l=>{wi[l]=window.higlassTracksByType[l].config});let{datatype:C}=o,a=null;o.type in wi&&(C||(C=wi[o.type].datatype[0]),{orientation:a}=wi[o.type]);const A=Object.values(wi).filter(l=>l.datatype).filter(l=>l.orientation).filter(l=>l.datatype.includes(C)).filter(l=>l.orientation===a).map(l=>l.type),s={};for(let l=0;l{this.props.onChangeTrackType(o.uid,A[l])}};return k.createElement(Wge,{key:"track-type-items",closeMenu:this.props.closeMenu,menuItems:s,orientation:this.state.orientation,parentBbox:r,position:I,theme:this.props.theme})}},{key:"getSubmenu",value:function(){if(this.state.submenuShown){const I=this.state.submenuSourceBbox,r=this.state.orientation==="left"?{left:this.state.left,top:I.top}:{left:this.state.left+I.width+7,top:I.top},o=this.state.submenuShown,C=o.value;return o.option==="track-type"?this.getTrackTypeItems(r,I,C):this.getConfigureSeriesMenu(r,I,C)}return k.createElement("div",null)}},{key:"getDivideByMenuItem",value:function(){if(this.props.series.data&&this.props.series.data.type==="divided"){const I={tilesetUid:this.props.series.data.children[0].tilesetUid,server:this.props.series.data.children[0].server};return k.createElement(yg,{className:ug["context-menu-item"],onClick:()=>this.props.onChangeTrackData(this.props.series.uid,I),onMouseEnter:r=>this.handleOtherMouseEnter(r)},k.createElement("span",{className:ug["context-menu-span"]},"Remove divisor"))}return k.createElement(yg,{className:ug["context-menu-item"],onClick:()=>this.props.onAddDivisor(this.props.series),onMouseEnter:I=>this.handleOtherMouseEnter(I)},k.createElement("span",{className:ug["context-menu-span"]},"Divide by"))}},{key:"componentWillUnmount",value:function(){}},{key:"render",value:function(){let I=null;wi[this.props.series.type]&&wi[this.props.series.type].exportable&&(I=k.createElement(yg,{className:ug["context-menu-item"],onClick:()=>this.props.onExportData(this.props.hostTrack.uid,this.props.track.uid),onMouseEnter:o=>this.handleOtherMouseEnter(o)},k.createElement("span",{className:ug["context-menu-span"]},"Export Data")));const r=this.props.onAddSeries?k.createElement(yg,{className:ug["context-menu-item"],onClick:()=>{this.props.onCloseTrack(this.props.series.uid),this.props.onAddSeries(this.props.hostTrack.uid)},onMouseEnter:o=>this.handleOtherMouseEnter(o)},k.createElement("span",{className:ug["context-menu-span"]},"Replace Series")):null;return k.createElement("div",{ref:o=>{this.div=o},className:gi(ug["context-menu"],{[ug["context-menu-dark"]]:this.props.theme===ki}),"data-menu-type":"SeriesListMenu",onMouseLeave:this.props.handleMouseLeave,style:{left:this.state.left,top:this.state.top}},k.createElement(yg,{onClick:()=>{},onMouseEnter:o=>this.handleItemMouseEnter(o,{option:"configure-series",value:this.props.track}),onMouseLeave:o=>this.handleMouseLeave(o)},"Configure Series",k.createElement("svg",{className:ug["play-icon"]},k.createElement("use",{xlinkHref:"#play"}))),k.createElement(yg,{className:ug["context-menu-item"],onClick:()=>{},onMouseEnter:o=>this.handleItemMouseEnter(o,{option:"track-type",value:this.props.track}),onMouseLeave:o=>this.handleMouseLeave(o)},k.createElement("span",{className:ug["context-menu-span"]},"Track Type",k.createElement("svg",{className:ug["play-icon"]},k.createElement("use",{xlinkHref:"#play"})))),I,this.getDivideByMenuItem(),k.createElement(yg,{className:ug["context-menu-item"],onClick:this.props.onCloseTrack,onMouseEnter:o=>this.handleOtherMouseEnter(o)},k.createElement("span",{className:ug["context-menu-span"]},"Close Series")),r,this.getSubmenu())}}]),i}(qm);const y$e=e=>{let g=[];for(const i of e)i.contents?g=g.concat(i.contents):g.push(i);return g},ple=(e,g,i,n)=>e?(window.higlassTracksByType&&Object.keys(window.higlassTracksByType).forEach(I=>{wi[I]=window.higlassTracksByType[I].config}),y$e(e).map(I=>{const r=wi[I.type]?wi[I.type].thumbnail:null,o=r?k.createElement("div",{className:ug["context-menu-icon"],dangerouslySetInnerHTML:{__html:r.outerHTML}}):k.createElement("div",{className:ug["context-menu-icon"]},k.createElement("svg",null));return k.createElement(yg,{key:I.uid,className:ug["context-menu-item"],onClick:()=>{n&&n(I.uid)},onMouseEnter:C=>{g&&g(C,I)},onMouseLeave:C=>{i&&i(C)}},o,k.createElement("span",{className:ug["context-menu-span"]},I.options&&I.options.name&&I.options.name.length?I.options.name:I.type,g&&i?k.createElement("svg",{className:ug["play-icon"]},k.createElement("use",{xlinkHref:"#play"})):null))})):null;function SSg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function WWe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function yD(e){return yD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},yD(e)}const Z$e=h_(e=>function(g){XSg(n,g);var i=TSg(n);function n(){return SSg(this,n),i.apply(this,arguments)}return RSg(n,[{key:"getSubmenu",value:function(){if(this.state.submenuShown){const r=this.state.submenuSourceBbox;let o=null;this.state.orientation==="left"?o={left:this.state.left,top:r.top}:o={left:this.state.left+r.width+7,top:r.top};const a=y$e(this.props.tracks).filter(s=>s.uid===this.state.submenuShown.uid)[0],A=a&&a.position!=="whole";return k.createElement(wSg,{key:`series-list-menu-${a.uid}`,ref:s=>{this.seriesListMenu=s},closeMenu:this.props.closeMenu,hostTrack:this.props.tracks[0],onAddDivisor:this.props.onAddDivisor,onAddSeries:A?this.props.onAddSeries:null,onChangeTrackData:this.props.onChangeTrackData,onChangeTrackType:this.props.onChangeTrackType,onCloseTrack:()=>this.props.onCloseTrack(this.state.submenuShown.uid),onConfigureTrack:this.props.onConfigureTrack,onDivideSeries:this.props.onDivideSeries,onExportData:this.props.onExportData,onLockScales:this.props.onLockScales,onTrackOptionsChanged:this.props.onTrackOptionsChanged,orientation:this.state.orientation,parentBbox:r,position:o,series:this.state.submenuShown,theme:this.props.theme,track:a,trackOrientation:this.props.trackOrientation,trackSourceServers:this.props.trackSourceServers})}return k.createElement("div",null)}}]),n}(e));function YSg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function XWe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function kw(e){return kw=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},kw(e)}let OSg=function(e){DSg(i,e);var g=MSg(i);function i(n){var I;return YSg(this,i),I=g.call(this,n),I.seriesRefs={},I.seriesListMenu=null,I}return KSg(i,[{key:"componentDidMount",value:function(){T5(kw(i.prototype),"componentDidMount",this).call(this)}},{key:"render",value:function(){return k.createElement("div",{ref:I=>{this.div=I},className:gi(ug["context-menu"],{[ug["context-menu-dark"]]:this.props.theme===ki}),"data-menu-type":"ConfigTrackMenu",style:{left:this.state.left,top:this.state.top}},ple(this.props.tracks,this.handleItemMouseEnter.bind(this),this.handleMouseLeave.bind(this),null),k.createElement("hr",{className:ug["context-menu-hr"]}),k.createElement(yg,{contextMenu:this,onClick:()=>this.props.onLockValueScale(this.props.tracks[0].uid),onMouseEnter:I=>this.handleOtherMouseEnter(I)},"Lock Value Scale With"),k.createElement(yg,{contextMenu:this,onClick:()=>this.props.onUnlockValueScale(this.props.tracks[0].uid),onMouseEnter:I=>this.handleOtherMouseEnter(I)},"Unlock Value Scale"),k.createElement("hr",{className:ug["context-menu-hr"]}),k.createElement(yg,{contextMenu:this,onClick:()=>this.props.onAddSeries(this.props.tracks[0].uid),onMouseEnter:I=>this.handleOtherMouseEnter(I)},"Add Series"),k.createElement(yg,{onClick:()=>this.props.onCloseTrack(this.props.tracks[0].uid)},"Close Track"),k.createElement(yg,{onClick:()=>{this.props.onReplaceTrack(this.props.tracks[0].uid,this.props.trackOrientation)}},"Replace Track"),this.getSubmenu())}}]),i}(tS(qm).with(Z$e));function G$e(e){return k.createElement("div",null,ple(e.tracks,null,null,e.onCloseTrack),k.createElement("hr",{className:ug["context-menu-hr"]}),k.createElement(yg,{onClick:()=>e.onCloseTrack(e.tracks[0].uid)},"Close all series"))}G$e.propTypes={onCloseTrack:L.func.isRequired,tracks:L.array.isRequired};function JSg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function TWe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ZD(e){return ZD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},ZD(e)}let gm=function(e){jSg(i,e);var g=$Sg(i);function i(n){var I;return JSg(this,i),I=g.call(this,n),I.clickHandlerBound=I.clickHandler.bind(H5(I)),I.contextMenuHandlerBound=I.contextMenuHandler.bind(H5(I)),I.resizeHandlerBound=I.resizeHandler.bind(H5(I)),I}return LSg(i,[{key:"componentDidMount",value:function(){this.popup=document.createElement("div"),document.body.appendChild(this.popup),this.popup.style.zIndex=99,this.popup.style.position="absolute",this.popup.className="hg-popup",document.addEventListener("click",this.clickHandlerBound,!0),document.addEventListener("contextmenu",this.contextMenuHandlerBound,!0),window.addEventListener("resize",this.resizeHandlerBound,!0),this._renderLayer()}},{key:"componentDidUpdate",value:function(){this._renderLayer()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("click",this.clickHandlerBound,!0),document.removeEventListener("contextmenu",this.contextMenuHandlerBound,!0),window.removeEventListener("resize",this.resizeHandlerBound,!0),_I.unmountComponentAtNode(this.popup),document.body.removeChild(this.popup)}},{key:"_renderLayer",value:function(){_I.render(this.props.children,this.popup)}},{key:"clickHandler",value:function(I){this.popup.contains(I.target)||this.props.onMenuClosed&&this.props.onMenuClosed(I)}},{key:"contextMenuHandler",value:function(I){I.altKey||(I.preventDefault(),this.clickHandler(I))}},{key:"resizeHandler",value:function(){this.props.onMenuClosed(null)}},{key:"render",value:function(){return k.createElement("div",null)}}]),i}(k.Component);gm.defaultProps={onMenuClosed:I_e};gm.propTypes={children:L.node.isRequired,onMenuClosed:L.func};const tRg=wPe(e=>k.createElement(m4e,{className:e.className,controlAlignLeft:e.controlAlignLeft,editable:e.editable,handleConfigTrack:e.handleConfigTrack,handleResizeTrack:e.handleResizeTrack,height:e.height,item:e.item,onAddSeries:e.onAddSeries,onCloseTrack:e.onCloseTrack,onCloseTrackMenuOpened:e.onCloseTrackMenuOpened,onConfigTrackMenuOpened:e.onConfigTrackMenuOpened,resizeHandles:e.resizeHandles,uid:e.uid,width:e.width})),gRg={"vertical-tiled-plot":"_vertical-tiled-plot_f3ho8_1"};function iRg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function HWe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function GD(e){return GD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},GD(e)}function NWe(e){return e&&e.sourceEvent}let Yge=function(e){oRg(i,e);var g=CRg(i);function i(n){var I;return iRg(this,i),I=g.call(this,n),I.brushBehavior=TT().on("start",I.brushStarted.bind(N5(I))).on("brush",I.brushed.bind(N5(I))).on("end",I.brushedEnded.bind(N5(I))),I}return nRg(i,[{key:"componentDidMount",value:function(){this.props.isRangeSelectionActive&&this.addBrush()}},{key:"shouldComponentUpdate",value:function(I,r){if(this.rangeSelectionTriggered)return this.rangeSelectionTriggered=!1,this.rangeSelectionTriggeredEnd&&this.props.rangeSelection!==I.rangeSelection&&this.moveBrush(I.rangeSelection[0]?I.rangeSelection[0]:null,!0),this.rangeSelectionTriggeredEnd=!1,this.state!==r;if(this.props.rangeSelection!==I.rangeSelection){const o=this.props.is1dRangeSelection?0:1;return this.moveBrush(I.rangeSelection[o]?I.rangeSelection[o]:null,I.rangeSelectionEnd),this.state!==r}return!0}},{key:"componentDidUpdate",value:function(){this.props.isRangeSelectionActive?this.addBrush():this.removeBrush()}},{key:"addBrush",value:function(){!this.brushEl||this.brushElAddedBefore===this.brushEl||(this.brushElAddedBefore&&this.brushElAddedBefore.on(".brush",null),this.brushEl.call(this.brushBehavior),this.brushElAddedBefore=this.brushEl,Ov(this.brushEl,CA["track-range-selection-group-brush-selection"]))}},{key:"brushed",value:function(I){const r=this.rangeSelectionMoved;this.rangeSelectionMoved=!1,!(!NWe(I)||!this.props.onRangeSelection||r)&&(this.rangeSelectionTriggered=!0,this.props.onRangeSelection(I.selection))}},{key:"brushStarted",value:function(I){!NWe(I)||!I.selection||this.props.onRangeSelectionStart()}},{key:"brushedEnded",value:function(I){if(!this.props.is1dRangeSelection)return;const r=this.rangeSelectionMovedEnd;this.rangeSelectionMovedEnd=!1,I.selection&&I.sourceEvent&&this.props.onRangeSelection&&!r&&(this.rangeSelectionTriggered=!0,this.rangeSelectionTriggeredEnd=!0,this.props.onRangeSelectionEnd(I.selection)),I.selection||(this.rangeSelectionTriggered=!0,this.props.onRangeSelectionReset())}},{key:"moveBrush",value:function(I,r=!1){if(!this.brushEl)return;const o=I?[this.props.scale(I[0]),this.props.scale(I[1])]:null;this.rangeSelectionMoved=!0,this.rangeSelectionMovedEnd=!0,r?this.brushEl.transition().call(this.brushBehavior.move,o):this.brushEl.call(this.brushBehavior.move,o)}},{key:"removeBrush",value:function(){this.brushElAddedBefore&&(this.brushElAddedBefore.call(this.brushBehavior.move,null),this.brushElAddedBefore.on(".brush",null),this.brushElAddedBefore=void 0,this.props.onRangeSelectionReset())}},{key:"render",value:function(){const I=this.props.tracks.map(C=>C.width).reduce(of,0),r=this.props.tracks.map(C=>N1(C)).reduce(kT,!1),o=CA[this.props.isRangeSelectionActive?"track-range-selection-active":"track-range-selection"];return k.createElement("div",{className:gRg["vertical-tiled-plot"]},r&&k.createElement("svg",{ref:C=>{this.brushEl=xg(C)},className:o,style:{height:this.props.height,width:I},xmlns:"http://www.w3.org/2000/svg"}),k.createElement(b_,{axis:"x",className:gi(aA.list,aA.stylizedList,aA.horizontalList),component:f4e,editable:this.props.editable,handleConfigTrack:this.props.handleConfigTrack,handleResizeTrack:this.props.handleResizeTrack,height:this.props.height,helperClass:aA.stylizedHelper,itemClass:gi(aA.stylizedItem,aA.horizontalItem),itemControlAlignLeft:this.props.tracksControlAlignLeft,itemReactClass:tRg,items:this.props.tracks.map(C=>({configMenuVisible:C.uid===this.props.configTrackMenuId,uid:C.uid||Ng.nice(),height:this.props.height,width:C.width,value:C.value})),onAddSeries:this.props.onAddSeries,onCloseTrack:this.props.onCloseTrack,onCloseTrackMenuOpened:this.props.onCloseTrackMenuOpened,onConfigTrackMenuOpened:this.props.onConfigTrackMenuOpened,onSortEnd:this.props.handleSortEnd,referenceAncestor:this.props.referenceAncestor,resizeHandles:this.props.resizeHandles,useDragHandle:!0,width:I}))}}]),i}(k.Component);Yge.propTypes={configTrackMenuId:L.string,editable:L.bool,handleConfigTrack:L.func,handleResizeTrack:L.func,handleSortEnd:L.func,is1dRangeSelection:L.bool,isRangeSelectionActive:L.bool,height:L.number,onAddSeries:L.func,onCloseTrack:L.func,onCloseTrackMenuOpened:L.func,onConfigTrackMenuOpened:L.func,onRangeSelection:L.func,onRangeSelectionEnd:L.func,onRangeSelectionReset:L.func,onRangeSelectionStart:L.func,rangeSelection:L.array,rangeSelectionEnd:L.bool,referenceAncestor:L.func,resizeHandles:L.object,scale:L.func,tracks:L.array,tracksControlAlignLeft:L.bool};function ARg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function kWe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function vD(e){return vD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},vD(e)}let v$e=function(e){dRg(i,e);var g=hRg(i);function i(){return ARg(this,i),g.apply(this,arguments)}return lRg(i,[{key:"render",value:function(){const I=ple(this.props.tracks,this.handleItemMouseEnter.bind(this),this.handleMouseLeave.bind(this)),r=this.props.customItems?k.Children.map(this.props.customItems,o=>k.cloneElement(o,{onMouseEnter:C=>{this.handleOtherMouseEnter(C)}})):null;return k.createElement("div",{ref:o=>{this.div=o},className:gi(ug["context-menu"],{[ug["context-menu-dark"]]:this.props.theme===ki}),"data-menu-type":"ViewContextMenu",style:{left:this.state.left,top:this.state.top}},r,r&&k.createElement("hr",{className:ug["context-menu-hr"]}),I,I&&k.createElement("hr",{className:ug["context-menu-hr"]}),k.createElement(yg,{onClick:()=>this.props.onAddTrack({type:"horizontal-rule",y:this.props.coords[1],position:"whole"}),onMouseEnter:o=>this.handleOtherMouseEnter(o)},"Add Horizontal Rule"),k.createElement(yg,{onClick:()=>this.props.onAddTrack({type:"vertical-rule",x:this.props.coords[0],position:"whole"}),onMouseEnter:o=>this.handleOtherMouseEnter(o)},"Add Vertical Rule"),k.createElement(yg,{onClick:()=>this.props.onAddTrack({type:"cross-rule",x:this.props.coords[0],y:this.props.coords[1],position:"whole"}),onMouseEnter:o=>this.handleOtherMouseEnter(o)},"Add Cross Rule"),k.createElement("hr",{className:ug["context-menu-hr"]}),this.hasMatrixTrack(this.props.tracks)&&k.createElement(yg,{onClick:this.handleAddHorizontalSection.bind(this),onMouseEnter:o=>this.handleOtherMouseEnter(o)},"Add Horizontal Cross Section"),this.hasMatrixTrack(this.props.tracks)&&k.createElement(yg,{onClick:this.handleAddVerticalSection.bind(this),onMouseEnter:o=>this.handleOtherMouseEnter(o)},"Add Vertical Cross Section"),this.getSubmenu())}},{key:"hasMatrixTrack",value:function(I){return UK(this.props.tracks).filter(o=>o.type==="heatmap").length>0}},{key:"handleAddHorizontalSection",value:function(){const r=UK(this.props.tracks).filter(o=>o.type==="heatmap")[0];this.props.onAddTrack({type:"horizontal-rule",y:this.props.coords[1],position:"whole"}),this.props.onAddTrack({data:{type:"horizontal-section",server:r.server,tilesetUid:r.tilesetUid,slicePos:this.props.coords[1]},options:{valueScaling:"log"},type:"horizontal-bar",height:30,position:"top"})}},{key:"handleAddVerticalSection",value:function(){const r=UK(this.props.tracks).filter(o=>o.type==="heatmap")[0];this.props.onAddTrack({type:"vertical-rule",x:this.props.coords[0],position:"whole"}),this.props.onAddTrack({data:{type:"vertical-section",server:r.server,tilesetUid:r.tilesetUid,slicePos:this.props.coords[0]},options:{valueScaling:"log"},type:"vertical-bar",height:30,position:"left"})}}]),i}(tS(qm).with(Z$e));v$e.propTypes={coords:L.array,customItems:L.array};function bRg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function YWe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function BD(e){return BD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},BD(e)}let ble=function(e){vRg(i,e);var g=BRg(i);function i(n){var I;bRg(this,i),I=g.call(this,n),I.closing=!1;const{tracks:r}=I.props;return I.canvasElement=null,I.tracksByUidInit={},[...I.props.tracks.top||[],...I.props.tracks.right||[],...I.props.tracks.bottom||[],...I.props.tracks.left||[],...I.props.tracks.gallery||[],...I.props.tracks.center||[]].forEach(o=>{o.type==="combined"?o.contents.forEach(C=>{I.tracksByUidInit[C.uid]=!1}):I.tracksByUidInit[o.uid]=!1}),I.xScale=null,I.yScale=null,I.addUidsToTracks(r),I.trackToReplace=null,I.trackRenderer=null,I.configTrackMenu=null,I.state={sizeMeasured:!1,height:10,width:10,tracks:r,init:!1,addTrackPosition:null,customDialog:null,mouseOverOverlayUid:null,forceUpdate:0,rangeSelection:[null,null],rangeSelectionEnd:!1,chromInfo:null,defaultChromSizes:null,contextMenuCustomItems:null,contextMenuPosition:null,addDivisorDialog:null},I.reset=!0,window.higlassTracksByType&&Object.keys(window.higlassTracksByType).forEach(o=>{wi[o]=window.higlassTracksByType[o].config}),I.topHeight=0,I.bottomHeight=0,I.leftWidth=0,I.rightWidth=0,I.centerHeight=0,I.centerWidth=0,I.dragTimeout=null,I.previousPropsStr="",I.contextMenuHandlerBound=I.contextMenuHandler.bind(ir(I)),I.handleNoTrackAddedBound=I.handleNoTrackAdded.bind(ir(I)),I.handleTracksAddedBound=I.handleTracksAdded.bind(ir(I)),I.closeMenusBound=I.closeMenus.bind(ir(I)),I.handleAddDivisorBound=I.handleAddDivisor.bind(ir(I)),I.handleAddSeriesBound=I.handleAddSeries.bind(ir(I)),I.handleChangeTrackDataBound=I.handleChangeTrackData.bind(ir(I)),I.handleChangeTrackTypeBound=I.handleChangeTrackType.bind(ir(I)),I.handleCloseTrackBound=I.handleCloseTrack.bind(ir(I)),I.handleConfigureTrackBound=I.handleConfigureTrack.bind(ir(I)),I.handleExportTrackDataBound=I.handleExportTrackData.bind(ir(I)),I.handleLockValueScaleBound=I.handleLockValueScale.bind(ir(I)),I.handleReplaceTrackBound=I.handleReplaceTrack.bind(ir(I)),I.handleTrackOptionsChangedBound=I.handleTrackOptionsChanged.bind(ir(I)),I.handleUnlockValueScaleBound=I.handleUnlockValueScale.bind(ir(I)),I.onAddTrack=I.handleAddTrack.bind(ir(I)),I}return yRg(i,[{key:"waitForDOMAttachment",value:function(I){if(!this.mounted)return;const r=_I.findDOMNode(this);document.body.contains(r)?I():requestAnimationFrame(()=>this.waitForDOMAttachment(I))}},{key:"componentDidMount",value:function(){this.mounted=!0,this.element=_I.findDOMNode(this),this.canvasElement=_I.findDOMNode(this.props.canvasElement),this.waitForDOMAttachment(()=>{RF.ElementQueries.listen(),this.resizeSensor=new RF.ResizeSensor(this.element.parentNode,this.measureSize.bind(this)),this.measureSize()}),this.addEventListeners(),this.pubSubs=[],this.pubSubs.push(this.props.pubSub.subscribe("contextmenu",this.contextMenuHandlerBound))}},{key:"UNSAFE_componentWillReceiveProps",value:function(I){this.addUidsToTracks(I.tracks),this.setState({tracks:I.tracks})}},{key:"shouldComponentUpdate",value:function(I,r){const o=this.previousPropsStr,C=this.updatablePropsToString(I),a=JSON.stringify(this.state),A=JSON.stringify(r),s=o!==C||a!==A||this.props.chooseTrackHandler!==I.chooseTrackHandler||this.props.customDialog!==I.customDialog;s&&(this.previousPropsStr=C);const l=this.numTracks;return this.numTracks=0,ku(this.props.tracks,()=>this.numTracks++),this.reset=this.reset||l===0&&this.numTracks>0,this.numTracks||(this.tracksByUidInit={}),s}},{key:"UNSAFE_componentWillUpdate",value:function(){}},{key:"componentDidUpdate",value:function(I,r){if(r.rangeSelection!==this.state.rangeSelection){let o=[null,null];this.state.defaultChromSizes&&this.state.rangeSelection.every(C=>C&&C.length)&&(o=this.state.rangeSelection.map(C=>xF(...C,this.state.defaultChromSizes))),this.props.onRangeSelection({dataRange:this.state.rangeSelection,genomicRange:o})}if(this.state.customDialog||this.props.customDialog){const o=this.state.customDialog||this.props.customDialog;if(o.length>0){const C=[],a=[];o.forEach(A=>{C.push(A.bodyComponent),a.push(A.bodyProps)}),this.props.modal.open(k.createElement(mle,{children:C,bodyProps:a,onCancel:this.props.closeCustomDialog,title:o[0].title}))}}if(I.tracks.center,this.props.tracks.center,(this.state.addTrackPosition||this.props.addTrackPosition)&&this.props.modal.open(k.createElement(hD,{host:this.state.addTrackHost,onCancel:this.handleNoTrackAddedBound,onTracksChosen:this.handleTracksAddedBound,position:this.state.addTrackPosition||this.props.addTrackPosition,trackSourceServers:this.props.trackSourceServers})),this.state.addDivisorDialog){const o=this.state.addDivisorDialog;this.props.modal.open(k.createElement(hD,{datatype:wi[o.type].datatype[0],host:this.state.addTrackHost,onCancel:()=>{this.setState({addDivisorDialog:null})},onTracksChosen:C=>{this.handleDivisorChosen(o,C)},trackSourceServers:this.props.trackSourceServers}))}}},{key:"componentWillUnmount",value:function(){this.closing=!0,this.removeEventListeners(),this.pubSubs.forEach(I=>this.props.pubSub.unsubscribe(I))}},{key:"addUidsToTracks",value:function(I){Object.keys(I).forEach(r=>{I[r].forEach(o=>{o.uid=o.uid||Ng.nice()})})}},{key:"contextMenuHandler",value:function(I){if(!this.divTiledPlot)return;const r=this.divTiledPlot.getBoundingClientRect();if(!Fae(I.clientX,I.clientY,r.left,r.left+r.width,r.top,r.top+r.height))return;const C=[I.clientX,I.clientY],a=mi(I,this.divTiledPlot),A=this.trackRenderer.zoomedXScale.invert(a[0]),s=this.trackRenderer.zoomedYScale.invert(a[1]);let l=null;I.hgCustomItems&&(l=I.hgCustomItems.map(c=>k.createElement(yg,{key:c.key,onClick:c.onClick},c.text))),this.setState({contextMenuCustomItems:l,contextMenuPosition:{left:C[0],top:C[1],canvasLeft:a[0]+this.trackRenderer.xPositionOffset,canvasTop:a[1]+this.trackRenderer.yPositionOffset},contextMenuDataX:A,contextMenuDataY:s})}},{key:"measureSize",value:function(){this.element.clientWidth>0&&this.element.clientHeight>0&&this.setState({sizeMeasured:!0,width:this.element.clientWidth,height:this.element.clientHeight})}},{key:"handleTrackOptionsChanged",value:function(I,r){return this.props.onTrackOptionsChanged(I,r)}},{key:"handleScalesChanged",value:function(I,r){this.xScale=I,this.yScale=r,this.props.onScalesChanged(I,r)}},{key:"handleTilesetInfoReceived",value:function(I,r){const o=ta(this.props.tracks,I);if(!o){console.warn("Strange, track not found:",I);return}this.tracksByUidInit[o.uid]=!0,this.checkAllTilesetInfoReceived(),o.options||(o.options={}),o.name=r.name,o.maxWidth=r.max_width,o.transforms=r.transforms,o.aggregationModes=r.aggregation_modes,o.header=r.header,o.binsPerDimension=r.bins_per_dimension,r.resolutions?(o.maxZoom=r.resolutions.length-1,o.resolutions=r.resolutions):o.maxZoom=r.max_zoom,o.coordSystem=r.coordSystem,o.datatype=r.datatype}},{key:"checkAllTilesetInfoReceived",value:function(){if(this.state.init&&!this.reset||!this.trackRenderer||!this.props.zoomToDataExtentOnInit())return;const I=Object.keys(this.trackRenderer.trackDefObjects).map(o=>{const C=this.trackRenderer.trackDefObjects[o].trackObject;return C.childTracks?C.childTracks:C}).reduce((o,C)=>o.concat(C),[]).filter(({tilesetInfo:o})=>typeof o<"u"&&o!==!0),r=Object.values(this.tracksByUidInit).filter(o=>o).length;I.length===r&&(this.setState({init:!0}),this.reset=!1,this.handleZoomToData())}},{key:"handleOverlayMouseEnter",value:function(I){this.setState({mouseOverOverlayUid:I})}},{key:"handleOverlayMouseLeave",value:function(I){I===this.state.mouseOverOverlayUid&&this.setState({mouseOverOverlayUid:null})}},{key:"handleTrackPositionChosen",value:function(I){this.setState({mouseOverOverlayUid:null}),this.props.chooseTrackHandler(I.track.uid)}},{key:"handleNoTrackAdded",value:function(){this.trackToReplace=null,this.props.onNoTrackAdded(),this.setState({addTrackPosition:null,addTrackHost:null})}},{key:"handleAddDivisor",value:function(I){this.setState({addDivisorDialog:I})}},{key:"handleDivisorChosen",value:function(I,r){this.setState({addDivisorDialog:null});const o=I.data?{server:I.data.server,tilesetUid:I.data.tilesetUid}:{server:I.server,tilesetUid:I.tilesetUid},C={server:r[0].server,tilesetUid:r[0].uuid};this.handleChangeTrackData(I.uid,{type:"divided",children:[o,C]})}},{key:"handleDivideSeries",value:function(I){}},{key:"handleAddSeries",value:function(I){const r=P2(this.props.tracks,I),o=ta(this.props.tracks,I);this.setState({addTrackPosition:r,addTrackHost:o})}},{key:"handleReplaceTrack",value:function(I,r){this.trackToReplace=I,this.handleAddTrack(r)}},{key:"handleAddTrack",value:function(I){this.setState({addTrackPosition:I,addTrackHost:null})}},{key:"handleResizeTrack",value:function(I,r,o){const{tracks:C}=this.state;for(const a in C){const s=C[a].filter(l=>l.uid===I);s.length>0&&(s[0].width=r,s[0].height=o)}this.setState({tracks:C,forceUpdate:Math.random()}),this.props.onResizeTrack()}},{key:"closeMenus",value:function(){this.setState({closeTrackMenuId:null,configTrackMenuId:null,contextMenuPosition:null,contextMenuCustomItems:null})}},{key:"handleLockValueScale",value:function(I){this.closeMenus(),this.props.onLockValueScale(I)}},{key:"handleUnlockValueScale",value:function(I){this.closeMenus(),this.props.onUnlockValueScale(I)}},{key:"handleCloseTrack",value:function(I){this.closeMenus(),this.props.onCloseTrack(I)}},{key:"handleChangeTrackType",value:function(I,r){this.closeMenus(),this.props.onChangeTrackType(I,r)}},{key:"handleChangeTrackData",value:function(I,r){this.closeMenus(),this.props.onChangeTrackData(I,r)}},{key:"handleTracksAdded",value:function(I,r,o){return this.trackToReplace&&(this.handleCloseTrack(this.trackToReplace),this.trackToReplace=null),this.props.onTracksAdded(I,r,o),this.setState({addTrackPosition:null,addTrackHost:null}),I}},{key:"handleCloseTrackMenuOpened",value:function(I,r){this.setState({closeTrackMenuId:I,closeTrackMenuLocation:r})}},{key:"handleCloseContextMenu",value:function(){this.setState({contextMenuCustomItems:null,contextMenuPosition:null,contextMenuDataX:null,contextMenuDataY:null})}},{key:"handleCloseTrackMenuClosed",value:function(){this.setState({closeTrackMenuId:null})}},{key:"handleConfigTrackMenuOpened",value:function(I,r){this.closeMenus(),this.setState({configTrackMenuId:I,configTrackMenuLocation:r})}},{key:"handleConfigureTrack",value:function(I,r){this.setState({configTrackMenuId:null,trackOptions:{track:I,configComponent:r}}),this.closeMenus()}},{key:"handleSortEnd",value:function(I){this.setState(r=>{const o=r.tracks,C={};for(let a=0;a{r[o]&&r[o].forEach(C=>{C.contents&&C.contents.forEach(a=>{a.position=o}),C.position=o,I.push({track:C,location:o})})}),I}},{key:"calculateTrackPosition",value:function(I,r){let o=this.props.paddingTop,C=this.props.paddingBottom,a=this.props.paddingLeft,A=this.props.paddingRight,s=this.centerWidth,l=I.height,c=0,u=0;switch(r){case"top":a+=this.leftWidth;for(let d=0;do.includes&&o.includes.length).map(o=>{const C=o.type?`overlay-${o.type}-track`:"overlay-track",a={...o,uid:o.uid||Ng.nice(),includes:o.includes,type:C,options:Object.assign(o.options,{orientationsAndPositions:o.includes.map(A=>{const s=ta(this.props.tracks,A);if(!s)return console.warn(`OverlayTrack included uid (${A}) not found in the track list`),null;const l=P2(this.props.tracks,s.uid);let c;if((l==="top"||l==="bottom")&&(c="1d-horizontal"),(l==="left"||l==="right")&&(c="1d-vertical"),l==="center"&&(c="2d"),!c)return console.warn("Only top, bottom, left, right, or center tracks can be overlaid at the moment"),null;const u=I.filter(h=>h.track.uid===A);if(!u.length)return null;const d={left:u[0].left-this.props.paddingLeft,top:u[0].top-this.props.paddingTop,width:u[0].width,height:u[0].height};return{orientation:c,position:d}}).filter(A=>A)})};return{top:this.props.paddingTop,left:this.props.paddingLeft,width:this.leftWidth+this.centerWidth+this.rightWidth,height:this.topHeight+this.centerHeight+this.bottomHeight+this.props.marginTop+this.props.marginBottom,track:a}}):[]}},{key:"positionedTracks",value:function(){return this.createTracksAndLocations().map(({track:r,location:o})=>this.calculateTrackPosition(r,o))}},{key:"createTrackPositionTexts",value:function(){const I=this.positionedTracks();return this.createTracksAndLocations(),I.map(o=>{const{track:C}=o;return k.createElement("div",{key:C.uid,style:{left:o.left,top:o.top,width:o.width,height:o.height,position:"absolute"}},C.uid.slice(0,2))})}},{key:"handleExportTrackData",value:function(I,r){const o=ta(this.props.tracks,r);let C=null;I!==r?C=this.trackRenderer.trackDefObjects[I].trackObject.createdTracks[o.uid]:{trackObject:C}=this.trackRenderer.trackDefObjects[I],C.exportData(),this.closeMenus()}},{key:"listTracksAtPosition",value:function(I,r,o=!1){const C=[];if(!this.trackRenderer)return[];for(const a in this.trackRenderer.trackDefObjects){const A=this.trackRenderer.trackDefObjects[a].trackObject;if(A.respondsToPosition(I,r))if(o){if(this.props.tracks.center)if(this.props.tracks.center.contents)for(let s=0;sC[d]&&(C[d]=u.tilesetInfo.max_pos[d]);const A=this.trackRenderer.currentProps.paddingLeft+this.trackRenderer.currentProps.leftWidth;let s=[A,A+this.trackRenderer.currentProps.centerWidth].map(this.trackRenderer.zoomTransform.rescaleX(this.trackRenderer.xScale).invert);const l=this.trackRenderer.currentProps.paddingTop+this.trackRenderer.currentProps.topHeight;let c=[l,l+this.trackRenderer.currentProps.centerHeight].map(this.trackRenderer.zoomTransform.rescaleY(this.trackRenderer.yScale).invert);this.trackRenderer.zoomTransform.k=1,this.trackRenderer.zoomTransform.x=0,this.trackRenderer.zoomTransform.y=0,this.trackRenderer.applyZoomTransform(),o[0]Number.MIN_SAFE_INTEGER&&(s=[o[0],C[0]]),o[1]Number.MIN_SAFE_INTEGER&&(c=[o[1],C[1]]),this.props.onDataDomainChanged(s,c)}},{key:"resetViewport",value:function(){this.trackRenderer.zoomTransform.k=1,this.trackRenderer.zoomTransform.x=0,this.trackRenderer.zoomTransform.y=0,this.trackRenderer.applyZoomTransform(),this.props.onDataDomainChanged(this.props.initialXDomain,this.props.initialYDomain)}},{key:"updatablePropsToString",value:function(I){return JSON.stringify({tracks:I.tracks,overlays:I.overlays,viewOptions:I.viewOptions,uid:I.uid,addTrackPosition:I.addTrackPosition,editable:I.editable,marginTop:I.marginTop,marginBottom:I.marginBottom,marginLeft:I.marginLeft,marginRight:I.marginRight,paddingTop:I.paddingTop,paddingBottom:I.paddingBottom,paddingLeft:I.paddingLeft,paddingRight:I.paddingRight,mouseTool:I.mouseTool,initialXDomain:I.initialXDomain,initialYDomain:I.initialYDomain,trackSourceServers:I.trackSourceServers,zoomable:I.zoomable,draggingHappening:I.draggingHappening})}},{key:"getXYScales",value:function(){this.trackRenderer&&(this.xScale=this.trackRenderer.currentXScale,this.yScale=this.trackRenderer.currentYScale)}},{key:"rangeViewToDataLoci",value:function(I,r){return r?[parseInt(r.invert(I[0]),10),parseInt(r.invert(I[1]),10)]:[null,null]}},{key:"rangeSelectionResetHandler",value:function(){this.state.rangeSelectionMaster&&this.setState({is1dRangeSelection:null,rangeSelection:[null,null],rangeSelectionMaster:null,rangeSelectionEnd:!1})}},{key:"rangeSelection1dEndHandler",value:function(I){(!this.xScale||!this.yScale)&&this.getXYScales();const r=I==="x"?this.xScale:this.yScale;return o=>{this.setState(C=>{const a=C.is1dRangeSelection?[null,null]:C.rangeSelection.slice(),A=!this.state.is1dRangeSelection&&I==="y"?1:0;let s=this.rangeViewToDataLoci(o,r);const l=s[1]-s[0];if(this.props.rangeSelection1dSize[0]>l){const c=s[0]+l/2;s=[c-this.props.rangeSelection1dSize[0]/2,c+this.props.rangeSelection1dSize[0]/2]}else if(this.props.rangeSelection1dSize[1]Math.round(c))),{rangeSelection:a,rangeSelectionEnd:!0}})}}},{key:"rangeSelection1dHandler",value:function(I){(!this.xScale||!this.yScale)&&this.getXYScales();const r=I==="x"?this.xScale:this.yScale;return o=>{this.setState(C=>{const a=C.is1dRangeSelection?[null,null]:C.rangeSelection.slice(),A=!C.is1dRangeSelection&&I==="y"?1:0;return a[A]=this.rangeViewToDataLoci(o,r),{rangeSelection:a,rangeSelectionEnd:!1}})}}},{key:"rangeSelection1dStartHandler",value:function(){this.state.rangeSelectionMaster||this.setState({is1dRangeSelection:!0,rangeSelectionMaster:!0,rangeSelectionEnd:!1})}},{key:"rangeSelection2dHandler",value:function(I){(!this.xScale||!this.yScale)&&this.getXYScales(),this.setState({rangeSelection:[this.rangeViewToDataLoci(I[0],this.xScale),this.rangeViewToDataLoci(I[1],this.yScale)],rangeSelectionEnd:!1})}},{key:"rangeSelection2dStartHandler",value:function(){this.state.rangeSelectionMaster||this.setState({is1dRangeSelection:!1,rangeSelectionMaster:!0,rangeSelectionEnd:!1})}},{key:"rangeSelection2dEndHandler",value:function(I){(!this.xScale||!this.yScale)&&this.getXYScales();const r=this.rangeViewToDataLoci(I[0],this.xScale),o=this.rangeViewToDataLoci(I[1],this.yScale);let C=[r,o];const a=r[1]-r[0],A=o[1]-o[0],s=[a,A];C.forEach((l,c)=>{if(this.props.rangeSelection1dSize[0]>s[c]){const u=l[0]+Math.round(s[c]/2);l[0]=u-this.props.rangeSelection1dSize[0]/2,l[1]=u+this.props.rangeSelection1dSize[0]/2}else if(this.props.rangeSelection1dSize[1]l.map(c=>Math.round(c)))),this.setState({rangeSelection:C,rangeSelectionEnd:!0})}},{key:"getContextMenu",value:function(){if(this.state.contextMenuPosition){const I=this.listTracksAtPosition(this.state.contextMenuPosition.canvasLeft,this.state.contextMenuPosition.canvasTop);return k.createElement(gm,{onMenuClosed:this.closeMenusBound},k.createElement(v$e,{closeMenu:this.closeMenusBound,coords:[this.state.contextMenuDataX,this.state.contextMenuDataY],customItems:this.state.contextMenuCustomItems,onAddDivisor:this.handleAddDivisorBound,onAddSeries:this.handleAddSeriesBound,onAddTrack:r=>{this.props.onTracksAdded([r],r.position,null),this.handleCloseContextMenu()},onChangeTrackData:this.handleChangeTrackDataBound,onChangeTrackType:this.handleChangeTrackTypeBound,onCloseTrack:this.handleCloseTrackBound,onConfigureTrack:this.handleConfigureTrackBound,onExportData:this.handleExportTrackDataBound,onLockValueScale:this.handleLockValueScaleBound,onReplaceTrack:this.handleReplaceTrackBound,onTrackOptionsChanged:this.handleTrackOptionsChangedBound,onUnlockValueScale:this.handleUnlockValueScaleBound,orientation:"right",position:this.state.contextMenuPosition,theme:this.props.theme,tracks:I,trackSourceServers:this.props.trackSourceServers}))}return null}},{key:"getIdealizedTrackPositionsOverlay",value:function(){const I=this.props.draggingHappening;if(typeof I=="boolean")return;const r=I.datatype;if(!(r in OX)&&!I.defaultTracks){console.warn("unknown data type:",I.higlassTrack);return}const o={"1d-horizontal":["top","bottom","left","right"],"2d":["center"],"1d-vertical":["left","right"]},C=OX[r]||{};if(I.defaultTracks)for(const w of I.defaultTracks)if(!wi[w])console.warn("unknown track type",w);else for(const T of o[wi[w].orientation])C[T]=w;const a=new Set(["top","left","right","center","bottom"].filter(w=>w in this.state.tracks&&this.state.tracks[w].length)),A="top"in C,s="left"in C,l="right"in C,c="bottom"in C,u="center"in C,d="center"in C||a.has("left")||a.has("right")||a.has("center"),h="top"in C,f="bottom"in C&&d,m="left"in C&&d,b="right"in C&&d,p=Object.keys(C).length&&("center"in C||d),y=k.createElement("div",{style:{flexGrow:1}}),Z=k.cloneElement(y),v=k.createElement("div",{style:{display:"flex",flexGrow:1}},h&&(p||m)?y:null,k.createElement(Jk,{defaultTrackType:C.top,draggingHappening:this.props.draggingHappening,enabled:A,onTrackDropped:w=>this.handleTracksAdded([w],"top"),style:{border:"1px solid black",flexGrow:1}}),h&&(p||m)?Z:null),G=k.createElement("div",{style:{display:"flex",flexGrow:1}},h&&(p||m)?y:null,k.createElement(Jk,{defaultTrackType:C.bottom,draggingHappening:this.props.draggingHappening,enabled:c,onTrackDropped:w=>this.handleTracksAdded([w],"bottom"),style:{border:"1px solid black",flexGrow:1}}),h&&(p||m)?Z:null),B=k.createElement(Jk,{defaultTrackType:C.left,draggingHappening:this.props.draggingHappening,enabled:s,onTrackDropped:w=>this.handleTracksAdded([w],"left"),style:{border:"1px solid black",flexGrow:1}}),S=k.createElement(Jk,{defaultTrackType:C.center,draggingHappening:this.props.draggingHappening,enabled:u,onTrackDropped:w=>this.handleTracksAdded([w],"center"),position:"center",style:{border:"1px solid black",flexGrow:1}}),R=k.cloneElement(B,{defaultTrackType:C.right,enabled:l,onTrackDropped:w=>this.handleTracksAdded([w],"right")});return k.createElement("div",{style:{position:"absolute",left:"0px",top:"0px",width:this.state.width,height:this.state.height}},k.createElement("div",{style:{position:"absolute",width:this.state.width,height:this.state.height,background:"white",opacity:.4}}),k.createElement("div",{style:{width:this.state.width,height:this.state.height,position:"absolute",display:"flex",flexDirection:"column"}},h?v:null,d&&k.createElement("div",{style:{display:"flex",height:h||f?"40%":"100%",width:"100%"}},m?B:null,p?S:null,b?R:null),f?G:null))}},{key:"render",value:function(){this.galleryDim=this.props.tracks.gallery?this.props.tracks.gallery.map(p=>p.height).reduce(of,0):0,this.topHeightNoGallery=this.props.tracks.top.map(p=>p.height).reduce(of,0),this.topHeight=this.topHeightNoGallery+this.galleryDim,this.bottomHeightNoGallery=this.props.tracks.bottom.map(p=>p.height).reduce(of,0),this.bottomHeight=this.bottomHeightNoGallery+this.galleryDim,this.leftWidthNoGallery=this.props.tracks.left.map(p=>p.width).reduce(of,0),this.leftWidth=this.leftWidthNoGallery+this.galleryDim,this.rightWidthNoGallery=this.props.tracks.right.map(p=>p.width).reduce(of,0),this.rightWidth=this.rightWidthNoGallery+this.galleryDim;const I=this.props.paddingTop+this.props.paddingBottom,r=this.props.paddingLeft+this.props.paddingRight;this.centerHeight=Math.max(0,this.state.height-this.topHeight-this.bottomHeight-I),this.centerWidth=Math.max(0,this.state.width-this.leftWidth-this.rightWidth-r);const o="none",C=k.createElement("div",{className:"top-track-container",style:{left:this.leftWidth+this.props.paddingLeft,top:this.props.paddingTop,width:this.centerWidth,height:this.topHeightNoGallery,outline:o,position:"absolute"}},k.createElement(gD,{configTrackMenuId:this.state.configTrackMenuId,editable:this.props.editable,handleConfigTrack:this.handleConfigTrackMenuOpened.bind(this),handleResizeTrack:this.handleResizeTrack.bind(this),handleSortEnd:this.handleSortEnd.bind(this),is1dRangeSelection:this.state.is1dRangeSelection,isRangeSelectionActive:this.props.mouseTool===Ja,onAddSeries:this.handleAddSeries.bind(this),onCloseTrack:this.handleCloseTrack.bind(this),onCloseTrackMenuOpened:this.handleCloseTrackMenuOpened.bind(this),onConfigTrackMenuOpened:this.handleConfigTrackMenuOpened.bind(this),onRangeSelection:this.rangeSelection1dHandler("x").bind(this),onRangeSelectionEnd:this.rangeSelection1dEndHandler("x").bind(this),onRangeSelectionReset:this.rangeSelectionResetHandler.bind(this),onRangeSelectionStart:this.rangeSelection1dStartHandler.bind(this),rangeSelection:this.state.rangeSelection,rangeSelectionEnd:this.state.rangeSelectionEnd,resizeHandles:new Set(["bottom"]),scale:this.xScale,tracks:this.props.tracks.top,width:this.centerWidth})),a=k.createElement("div",{className:"left-track-container",style:{left:this.props.paddingLeft,top:this.topHeight+this.props.paddingTop,width:this.leftWidthNoGallery,height:this.centerHeight,outline:o,position:"absolute"}},k.createElement(Yge,{configTrackMenuId:this.state.configTrackMenuId,editable:this.props.editable,handleConfigTrack:this.handleConfigTrackMenuOpened.bind(this),handleResizeTrack:this.handleResizeTrack.bind(this),handleSortEnd:this.handleSortEnd.bind(this),height:this.centerHeight,is1dRangeSelection:this.state.is1dRangeSelection,isRangeSelectionActive:this.props.mouseTool===Ja,onAddSeries:this.handleAddSeries.bind(this),onCloseTrack:this.handleCloseTrack.bind(this),onCloseTrackMenuOpened:this.handleCloseTrackMenuOpened.bind(this),onConfigTrackMenuOpened:this.handleConfigTrackMenuOpened.bind(this),onRangeSelection:this.rangeSelection1dHandler("y").bind(this),onRangeSelectionEnd:this.rangeSelection1dEndHandler("y").bind(this),onRangeSelectionReset:this.rangeSelectionResetHandler.bind(this),onRangeSelectionStart:this.rangeSelection1dStartHandler.bind(this),rangeSelection:this.state.rangeSelection,rangeSelectionEnd:this.state.rangeSelectionEnd,resizeHandles:new Set(["right"]),scale:this.yScale,tracks:this.props.tracks.left})),A=k.createElement("div",{className:"right-track-container",style:{right:this.props.paddingRight,top:this.topHeight+this.props.paddingTop,width:this.rightWidthNoGallery,height:this.centerHeight,outline:o,position:"absolute"}},k.createElement(Yge,{configTrackMenuId:this.state.configTrackMenuId,editable:this.props.editable,handleConfigTrack:this.handleConfigTrackMenuOpened.bind(this),handleResizeTrack:this.handleResizeTrack.bind(this),handleSortEnd:this.handleSortEnd.bind(this),height:this.centerHeight,is1dRangeSelection:this.state.is1dRangeSelection,isRangeSelectionActive:this.props.mouseTool===Ja,onAddSeries:this.handleAddSeries.bind(this),onCloseTrack:this.handleCloseTrack.bind(this),onCloseTrackMenuOpened:this.handleCloseTrackMenuOpened.bind(this),onConfigTrackMenuOpened:this.handleConfigTrackMenuOpened.bind(this),onRangeSelection:this.rangeSelection1dHandler("y").bind(this),onRangeSelectionEnd:this.rangeSelection1dEndHandler("y").bind(this),onRangeSelectionReset:this.rangeSelectionResetHandler.bind(this),onRangeSelectionStart:this.rangeSelection1dStartHandler.bind(this),rangeSelection:this.state.rangeSelection,rangeSelectionEnd:this.state.rangeSelectionEnd,resizeHandles:new Set(["left"]),scale:this.yScale,tracks:this.props.tracks.right,tracksControlAlignLeft:!0})),s=k.createElement("div",{className:"bottom-track-container",style:{left:this.leftWidth+this.props.paddingLeft,bottom:this.props.paddingBottom,width:this.centerWidth,height:this.bottomHeightNoGallery,outline:o,position:"absolute"}},k.createElement(gD,{configTrackMenuId:this.state.configTrackMenuId,editable:this.props.editable,handleConfigTrack:this.handleConfigTrackMenuOpened.bind(this),handleResizeTrack:this.handleResizeTrack.bind(this),handleSortEnd:this.handleSortEnd.bind(this),is1dRangeSelection:this.state.is1dRangeSelection,isRangeSelectionActive:this.props.mouseTool===Ja,onAddSeries:this.handleAddSeries.bind(this),onCloseTrack:this.handleCloseTrack.bind(this),onCloseTrackMenuOpened:this.handleCloseTrackMenuOpened.bind(this),onConfigTrackMenuOpened:this.handleConfigTrackMenuOpened.bind(this),onRangeSelection:this.rangeSelection1dHandler("x").bind(this),onRangeSelectionEnd:this.rangeSelection1dEndHandler("x").bind(this),onRangeSelectionReset:this.rangeSelectionResetHandler.bind(this),onRangeSelectionStart:this.rangeSelection1dStartHandler.bind(this),rangeSelection:this.state.rangeSelection,rangeSelectionEnd:this.state.rangeSelectionEnd,resizeHandles:new Set(["top"]),scale:this.xScale,tracks:this.props.tracks.bottom,width:this.centerWidth})),l=k.createElement("div",{key:"galleryTracksDiv",className:"gallery-track-container",style:{left:this.leftWidthNoGallery+this.props.paddingLeft,top:this.topHeightNoGallery+this.props.paddingTop,width:this.centerWidth+2*this.galleryDim,height:this.centerHeight+2*this.galleryDim,outline:o,position:"absolute"}},k.createElement(n7e,{configTrackMenuId:this.state.configTrackMenuId,editable:this.props.editable,height:this.centerHeight+2*this.galleryDim,onAddSeries:this.handleAddSeries.bind(this),onCloseTrack:this.handleCloseTrack.bind(this),onCloseTrackMenuOpened:this.handleCloseTrackMenuOpened.bind(this),onConfigTrackMenuOpened:this.handleConfigTrackMenuOpened.bind(this),tracks:this.props.tracks.gallery,width:this.centerWidth+2*this.galleryDim}));let c=k.createElement("div",{className:["center-track-container",lee["center-track-container"]].join(" "),style:{left:this.leftWidth+this.props.paddingLeft,top:this.topHeight+this.props.paddingTop,width:this.centerWidth,height:this.bottomHeight,outline:o}});this.props.tracks.center.length&&(c=k.createElement("div",{className:["center-track-container",lee["center-track-container"]].join(" "),style:{left:this.leftWidth+this.props.paddingLeft,top:this.topHeight+this.props.paddingTop,width:this.centerWidth,height:this.centerHeight,outline:o}},k.createElement(Lse,{configTrackMenuId:this.state.configTrackMenuId,editable:this.props.editable,height:this.centerHeight,is1dRangeSelection:this.state.is1dRangeSelection,isRangeSelectionActive:this.props.mouseTool===Ja,onAddSeries:this.handleAddSeries.bind(this),onCloseTrackMenuOpened:this.handleCloseTrackMenuOpened.bind(this),onConfigTrackMenuOpened:this.handleConfigTrackMenuOpened.bind(this),onRangeSelectionReset:this.rangeSelectionResetHandler.bind(this),onRangeSelectionStart:this.rangeSelection2dStartHandler.bind(this),onRangeSelectionX:this.rangeSelection1dHandler("x").bind(this),onRangeSelectionXEnd:this.rangeSelection1dEndHandler("x").bind(this),onRangeSelectionXY:this.rangeSelection2dHandler.bind(this),onRangeSelectionXYEnd:this.rangeSelection2dEndHandler.bind(this),onRangeSelectionY:this.rangeSelection1dHandler("y").bind(this),onRangeSelectionYEnd:this.rangeSelection1dEndHandler("y").bind(this),rangeSelection:this.state.rangeSelection,rangeSelectionEnd:this.state.rangeSelectionEnd,scaleX:this.xScale,scaleY:this.yScale,tracks:this.props.tracks.center,uid:this.props.tracks.center[0].uid,width:this.centerWidth}))),this.createTrackPositionTexts();let u=this.positionedTracks();u=u.concat(this.overlayTracks(u));let d=null;this.state.sizeMeasured&&(d=k.createElement(u1g,{ref:p=>{this.trackRenderer=p,this.checkAllTilesetInfoReceived()},canvasElement:this.canvasElement,centerHeight:this.centerHeight,centerWidth:this.centerWidth,disableTrackMenu:this.props.disableTrackMenu,dragging:this.props.dragging,galleryDim:this.galleryDim,getLockGroupExtrema:this.props.getLockGroupExtrema,height:this.state.height,initialXDomain:this.props.initialXDomain,initialYDomain:this.props.initialYDomain,isRangeSelection:this.props.mouseTool===Ja,isShowGlobalMousePosition:this.props.isShowGlobalMousePosition,isValueScaleLocked:this.props.isValueScaleLocked,leftWidth:this.leftWidth,leftWidthNoGallery:this.leftWidthNoGallery,metaTracks:this.props.metaTracks,onMouseMoveZoom:this.props.onMouseMoveZoom,onNewTilesLoaded:this.props.onNewTilesLoaded,onScalesChanged:this.handleScalesChanged.bind(this),onTilesetInfoReceived:this.handleTilesetInfoReceived.bind(this),onTrackOptionsChanged:this.handleTrackOptionsChanged.bind(this),onValueScaleChanged:this.props.onValueScaleChanged,paddingLeft:this.props.paddingLeft,paddingTop:this.props.paddingTop,pixiRenderer:this.props.pixiRenderer,pixiStage:this.props.pixiStage,pluginDataFetchers:this.props.pluginDataFetchers,pluginTracks:this.props.pluginTracks,positionedTracks:u,registerDraggingChangedListener:this.props.registerDraggingChangedListener,removeDraggingChangedListener:this.props.removeDraggingChangedListener,setCentersFunction:this.props.setCentersFunction,svgElement:this.props.svgElement,topHeight:this.topHeight,topHeightNoGallery:this.topHeightNoGallery,uid:this.props.uid,viewOptions:this.props.viewOptions,width:this.state.width,xDomainLimits:this.props.xDomainLimits,yDomainLimits:this.props.yDomainLimits,zoomable:this.props.zoomable,zoomLimits:this.props.zoomLimits},C,a,A,s,l,c));let h=null,f=null;this.state.configTrackMenuId&&(h=k.createElement(gm,{onMenuClosed:this.closeMenusBound},k.createElement(OSg,{ref:p=>{this.configTrackMenu=p},closeMenu:this.closeMenusBound,onAddDivisor:this.handleAddDivisorBound,onAddSeries:this.handleAddSeriesBound,onAddTrack:this.handleAddTrackBound,onChangeTrackType:this.handleChangeTrackTypeBound,onCloseTrack:this.handleCloseTrackBound,onConfigureTrack:this.handleConfigureTrackBound,onExportData:this.handleExportTrackDataBound,onLockValueScale:this.handleLockValueScaleBound,onReplaceTrack:this.handleReplaceTrackBound,onTrackOptionsChanged:this.handleTrackOptionsChangedBound,onUnlockValueScale:this.handleUnlockValueScaleBound,position:this.state.configTrackMenuLocation,theme:this.props.theme,trackOrientation:P2(this.props.tracks,this.state.configTrackMenuId),tracks:[ta(this.props.tracks,this.state.configTrackMenuId)]}))),this.state.closeTrackMenuId&&(f=k.createElement(gm,{onMenuClosed:this.handleCloseTrackMenuClosed.bind(this)},k.createElement(qm,{position:this.state.closeTrackMenuLocation,theme:this.props.theme},k.createElement(G$e,{onCloseTrack:this.handleCloseTrack.bind(this),tracks:[ta(this.props.tracks,this.state.closeTrackMenuId)]}))));let m=null;this.props.chooseTrackHandler&&(m=u.filter(p=>p.track.position!=="whole").map(p=>{let y="transparent",Z="none";return this.state.mouseOverOverlayUid===p.track.uid&&(y="yellow",Z="1px solid black"),k.createElement("div",{key:p.track.uid,className:"tiled-plot-track-overlay",onClick:()=>this.handleTrackPositionChosen(p),onDragEnter:v=>{this.handleOverlayMouseEnter(p.track.uid),v.preventDefault()},onDragLeave:()=>this.handleOverlayMouseLeave(p.track.uid),onDragOver:v=>v.preventDefault(),onDrop:()=>this.handleTrackPositionChosen(p),onMouseEnter:()=>this.handleOverlayMouseEnter(p.track.uid),onMouseLeave:()=>this.handleOverlayMouseLeave(p.track.uid),style:{position:"absolute",left:p.left,top:p.top,width:p.width,height:p.height,background:y,opacity:.4,border:Z,zIndex:1}})}));let b=null;if(this.xScale&&this.yScale&&this.props.editable&&this.state.trackOptions){const p=this.state.trackOptions.configComponent,y=this.state.trackOptions.track;b=k.createElement(p,{track:y,xScale:this.xScale,yScale:this.yScale,onCancel:()=>{this.setState({trackOptions:null})},onTrackOptionsChanged:Z=>Z,onSubmit:Z=>{this.handleTrackOptionsChanged(this.state.trackOptions.track.uid,Z),this.setState({trackOptions:null})}})}return k.createElement("div",{ref:p=>{this.divTiledPlot=p},className:["tiled-plot-div",aA["tiled-plot"]].join(" "),style:{marginBottom:this.props.marginBottom,marginLeft:this.props.marginLeft,marginRight:this.props.marginRight,marginTop:this.props.marginTop}},d,m,h,f,b,this.getContextMenu(),this.props.draggingHappening&&this.getIdealizedTrackPositionsOverlay())}},{key:"addEventListeners",value:function(){this.eventListeners=[],this.eventListeners.forEach(I=>document.addEventListener(I.name,I.callback,!1))}},{key:"removeEventListeners",value:function(){this.eventListeners.forEach(I=>document.removeEventListener(I.name,I.callback))}}]),i}(k.Component);ble.defaultProps={isShowGlobalMousePosition:!1,pluginDataFetchers:{},pluginTracks:{},metaTracks:[],zoomable:!0};ble.propTypes={addTrackPosition:L.string,canvasElement:L.object,chooseTrackHandler:L.func,chromInfoPath:L.string,customDialog:L.array,closeCustomDialog:L.func,disableTrackMenu:L.bool,dragging:L.bool,draggingHappening:L.bool,editable:L.bool,getLockGroupExtrema:L.func,initialXDomain:L.array,initialYDomain:L.array,isShowGlobalMousePosition:L.bool,isValueScaleLocked:L.func,marginBottom:L.number.isRequired,marginLeft:L.number.isRequired,marginRight:L.number.isRequired,marginTop:L.number.isRequired,paddingBottom:L.number.isRequired,paddingLeft:L.number.isRequired,paddingRight:L.number.isRequired,paddingTop:L.number.isRequired,metaTracks:L.array,modal:L.object,mouseTool:L.string,onCloseTrack:L.func,onChangeTrackData:L.func,onChangeTrackType:L.func,onDataDomainChanged:L.func,onLockValueScale:L.func,onMouseMoveZoom:L.func,onNewTilesLoaded:L.func,onNoTrackAdded:L.func,onRangeSelection:L.func.isRequired,onScalesChanged:L.func,onTrackOptionsChanged:L.func,onTrackPositionChosen:L.func,onTracksAdded:L.func,onUnlockValueScale:L.func,onValueScaleChanged:L.func,onResizeTrack:L.func,overlays:L.array,openModal:L.func,pixiRenderer:L.object,pixiStage:L.object,pluginDataFetchers:L.object,pluginTracks:L.object,pubSub:L.object.isRequired,rangeSelection1dSize:L.array,rangeSelectionToInt:L.bool,registerDraggingChangedListener:L.func,removeDraggingChangedListener:L.func,setCentersFunction:L.func,svgElement:L.object,theme:L.symbol.isRequired,tracks:L.object,trackSourceServers:L.array,uid:L.string,viewOptions:L.object,xDomainLimits:L.array,yDomainLimits:L.array,zoomable:L.bool,zoomLimits:L.array,zoomToDataExtentOnInit:L.func};const RRg=L1(Z_(iZ(ble)));var VRg=Object.assign||function(e){for(var g=1;g"u"?"undefined":WRg(g))==="object"){for(var I in g)g.hasOwnProperty(I)&&CB(e,I,g[I]);return}if(typeof n<"u"){typeof n=="number"&&(n+="px"),e.style[g]=n;return}return Cy(e,g)}yle(["width","height"],function(e){var g=e.charAt(0).toUpperCase()+e.slice(1);ic["outer"+g]=function(n,I){return n&&xWe(n,e,I?ERg:Mge)};var i=e==="width"?["Left","Right"]:["Top","Bottom"];ic[e]=function(n,I){if(I!==void 0){if(n){Cy(n);var r=S$e(n);return r&&(I+=jV(n,["padding","border"],i)),CB(n,e,I)}return}return n&&xWe(n,e,Dge)}});function zRg(e,g){CB(e,"position")==="static"&&(e.style.position="relative");var i=w$e(e),n={},I=void 0,r=void 0;for(r in g)g.hasOwnProperty(r)&&(I=parseFloat(CB(e,r))||0,n[r]=I+g[r]-i[r]);CB(e,n)}var PRg=VRg({getWindow:function(g){var i=g.ownerDocument||g;return i.defaultView||i.parentWindow},offset:function(g,i){if(typeof i<"u")zRg(g,i);else return w$e(g)},isWindow:k5,each:yle,css:CB,clone:function(g){var i={};for(var n in g)g.hasOwnProperty(n)&&(i[n]=g[n]);var I=g.overflow;if(I)for(var n in g)g.hasOwnProperty(n)&&(i.overflow[n]=g.overflow[n]);return i},scrollLeft:function(g,i){if(k5(g)){if(i===void 0)return Fge(g);window.scrollTo(i,Ege(g))}else{if(i===void 0)return g.scrollLeft;g.scrollLeft=i}},scrollTop:function(g,i){if(k5(g)){if(i===void 0)return Ege(g);window.scrollTo(Fge(g),i)}else{if(i===void 0)return g.scrollTop;g.scrollTop=i}},viewportWidth:0,viewportHeight:0},ic),Ki=PRg;function _Rg(e,g,i){i=i||{},g.nodeType===9&&(g=Ki.getWindow(g));var n=i.allowHorizontalScroll,I=i.onlyScrollIfNeeded,r=i.alignWithTop,o=i.alignWithLeft,C=i.offsetTop||0,a=i.offsetLeft||0,A=i.offsetBottom||0,s=i.offsetRight||0;n=n===void 0?!0:n;var l=Ki.isWindow(g),c=Ki.offset(e),u=Ki.outerHeight(e),d=Ki.outerWidth(e),h=void 0,f=void 0,m=void 0,b=void 0,p=void 0,y=void 0,Z=void 0,v=void 0,G=void 0,B=void 0;l?(Z=g,B=Ki.height(Z),G=Ki.width(Z),v={left:Ki.scrollLeft(Z),top:Ki.scrollTop(Z)},p={left:c.left-v.left-a,top:c.top-v.top-C},y={left:c.left+d-(v.left+G)+s,top:c.top+u-(v.top+B)+A},b=v):(h=Ki.offset(g),f=g.clientHeight,m=g.clientWidth,b={left:g.scrollLeft,top:g.scrollTop},p={left:c.left-(h.left+(parseFloat(Ki.css(g,"borderLeftWidth"))||0))-a,top:c.top-(h.top+(parseFloat(Ki.css(g,"borderTopWidth"))||0))-C},y={left:c.left+d-(h.left+m+(parseFloat(Ki.css(g,"borderRightWidth"))||0))+s,top:c.top+u-(h.top+f+(parseFloat(Ki.css(g,"borderBottomWidth"))||0))+A}),p.top<0||y.top>0?r===!0?Ki.scrollTop(g,b.top+p.top):r===!1?Ki.scrollTop(g,b.top+y.top):p.top<0?Ki.scrollTop(g,b.top+p.top):Ki.scrollTop(g,b.top+y.top):I||(r=r===void 0?!0:!!r,r?Ki.scrollTop(g,b.top+p.top):Ki.scrollTop(g,b.top+y.top)),n&&(p.left<0||y.left>0?o===!0?Ki.scrollLeft(g,b.left+p.left):o===!1?Ki.scrollLeft(g,b.left+y.left):p.left<0?Ki.scrollLeft(g,b.left+p.left):Ki.scrollLeft(g,b.left+y.left):I||(o=o===void 0?!0:!!o,o?Ki.scrollLeft(g,b.left+p.left):Ki.scrollLeft(g,b.left+y.left)))}var ORg=_Rg,JRg=ORg;const LRg=EC(JRg);function wD(){return wD=Object.assign?Object.assign.bind():function(e){for(var g=1;g"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function SD(e){return SD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},SD(e)}const kR=[];let Zle=function(e){qRg(i,e);var g=eVg(i);function i(n){var I;return URg(this,i),I=g.call(this,n),I.state={highlightedIndex:null,menuTop:0,menuLeft:0,menuWidth:0,isOpen:!1},I.keyDownHandlers={ArrowDown(r){r.preventDefault();const o=this.getFilteredItems().length;if(!o)return;const{highlightedIndex:C}=this.state,a=C===null||C===o-1?0:C+1;this._performAutoCompleteOnKeyUp=!0,this.setState({highlightedIndex:a,isOpen:!0})},ArrowUp(r){r.preventDefault();const o=this.getFilteredItems().length;if(!o)return;const{highlightedIndex:C}=this.state,a=C===0||C===null?o-1:C-1;this._performAutoCompleteOnKeyUp=!0,this.setState({highlightedIndex:a,isOpen:!0})},Enter(r){if(this.state.isOpen!==!1)if(this.state.highlightedIndex===null)this.setState({isOpen:!1},()=>{this.inputEl.select()});else{r.preventDefault();const o=this.getFilteredItems()[this.state.highlightedIndex],C=this.props.getItemValue(o);this.setState({isOpen:!1,highlightedIndex:null},()=>{this.inputEl.setSelectionRange(C.length,C.length),this.props.onSelect(C,o)})}},Escape(){this.setState({highlightedIndex:null,isOpen:!1})}},I}return QRg(i,[{key:"getInitialState",value:function(){return{isOpen:!1,highlightedIndex:null}}},{key:"UNSAFE_componentWillMount",value:function(){this._ignoreBlur=!1,this._performAutoCompleteOnUpdate=!1,this._performAutoCompleteOnKeyUp=!1}},{key:"UNSAFE_componentWillReceiveProps",value:function(I){this._performAutoCompleteOnUpdate=!0,(this.props.items!==I.items||this.state.highlightedIndex>=I.items.length)&&this.setState({highlightedIndex:null})}},{key:"componentDidUpdate",value:function(I,r){this.state.isOpen===!0&&r.isOpen===!1&&this.setMenuPositions(),this.state.isOpen&&this._performAutoCompleteOnUpdate&&(this._performAutoCompleteOnUpdate=!1,this.maybeAutoCompleteText()),this.maybeScrollItemIntoView(),r.isOpen!==this.state.isOpen&&this.props.onMenuVisibilityChange(this.state.isOpen,this.inputEl)}},{key:"maybeScrollItemIntoView",value:function(){if(this.state.isOpen===!0&&this.state.highlightedIndex!==null){const I=this.refs[`item-${this.state.highlightedIndex}`],r=this.refs.menu;I&&LRg(fb.findDOMNode(I),fb.findDOMNode(r),{onlyScrollIfNeeded:!0})}}},{key:"handleKeyDown",value:function(I){this.keyDownHandlers[I.key]?this.keyDownHandlers[I.key].call(this,I):this.setState({highlightedIndex:null,isOpen:!0})}},{key:"handleChange",value:function(I){this._performAutoCompleteOnKeyUp=!0,this.props.onChange(I,I.target.value)}},{key:"handleKeyUp",value:function(){this._performAutoCompleteOnKeyUp&&(this._performAutoCompleteOnKeyUp=!1,this.maybeAutoCompleteText())}},{key:"getFilteredItems",value:function(){let I=this.props.items;return this.props.shouldItemRender&&(I=I.filter(r=>this.props.shouldItemRender(r,this.props.value))),this.props.sortItems&&I.sort((r,o)=>this.props.sortItems(r,o,this.props.value)),I}},{key:"maybeAutoCompleteText",value:function(){if(!this.props.autoHighlight||this.props.value==="")return;const{highlightedIndex:I}=this.state,r=this.getFilteredItems();if(r.length===0)return;const o=I!==null?r[I]:r[0];this.props.getItemValue(o).toLowerCase().indexOf(this.props.value.toLowerCase())===0&&I===null&&this.setState({highlightedIndex:0})}},{key:"setMenuPositions",value:function(){const I=this.inputEl,r=I.getBoundingClientRect(),o=globalThis.window.getComputedStyle(I),C=parseInt(o.marginBottom,10)||0,a=parseInt(o.marginLeft,10)||0,A=parseInt(o.marginRight,10)||0;this.setState({menuTop:r.bottom+C,menuLeft:r.left+a,menuWidth:r.width+a+A})}},{key:"highlightItemFromMouse",value:function(I){this.setState({highlightedIndex:I})}},{key:"selectItemFromMouse",value:function(I){const r=this.props.getItemValue(I);this.setState({isOpen:!1,highlightedIndex:null},()=>{this.props.onSelect(r,I),this.inputEl.focus()})}},{key:"setIgnoreBlur",value:function(I){this._ignoreBlur=I}},{key:"renderMenu",value:function(){const I=this.getFilteredItems().map((C,a)=>{const A=this.props.renderItem(C,this.state.highlightedIndex===a,{cursor:"default"});return k.cloneElement(A,{onMouseDown:()=>this.setIgnoreBlur(!0),onMouseEnter:()=>this.highlightItemFromMouse(a),onClick:()=>this.selectItemFromMouse(C),ref:`item-${a}`})}),r={left:this.state.menuLeft,top:this.state.menuTop,minWidth:this.state.menuWidth};if(!I.length)return null;const o=this.props.renderMenu(I,this.props.value,r);return k.cloneElement(o,{ref:"menu"})}},{key:"handleInputBlur",value:function(){this.props.onFocus&&this.props.onFocus(),!this._ignoreBlur&&this.setState({isOpen:!1,highlightedIndex:null})}},{key:"handleInputFocus",value:function(){if(this.props.onFocus&&this.props.onFocus(!0),this._ignoreBlur){this.setIgnoreBlur(!1);return}this._ignoreClick=!0,this.setState({isOpen:!0})}},{key:"isInputFocused",value:function(){return this.inputEl.ownerDocument&&this.inputEl===this.inputEl.ownerDocument.activeElement}},{key:"handleInputClick",value:function(){this.isInputFocused()&&this.state.isOpen===!1?this.setState({isOpen:!0}):this.state.highlightedIndex!==null&&!this._ignoreClick&&this.selectItemFromMouse(this.getFilteredItems()[this.state.highlightedIndex]),this._ignoreClick=!1}},{key:"composeEventHandlers",value:function(I,r){return r?o=>{I(o),r(o)}:I}},{key:"render",value:function(){this.props.debug&&kR.push({id:kR.length,state:this.state});const{inputProps:I}=this.props;return k.createElement("div",wD({style:{...this.props.wrapperStyle}},this.props.wrapperProps),k.createElement("input",wD({},I,{ref:r=>{this.inputEl=r},"aria-autocomplete":"list",autoComplete:"off",onBlur:this.composeEventHandlers(this.handleInputBlur.bind(this),I.onBlur&&I.onBlur.bind(this)),onChange:this.handleChange.bind(this),onClick:this.composeEventHandlers(this.handleInputClick.bind(this),I.onClick&&I.onClick.bind(this)),onFocus:this.composeEventHandlers(this.handleInputFocus.bind(this),I.onFocus&&I.onFocus.bind(this)),onKeyDown:this.composeEventHandlers(this.handleKeyDown.bind(this),I.onKeyDown&&I.onKeyDown.bind(this)),onKeyUp:this.composeEventHandlers(this.handleKeyUp.bind(this),I.onKeyUp&&I.onKeyUp.bind(this)),role:"combobox",value:this.props.value})),("open"in this.props?this.props.open:this.state.isOpen)&&this.renderMenu(),this.props.debug&&k.createElement("pre",{style:{marginLeft:300}},JSON.stringify(kR.slice(kR.length-5,kR.length),null,2)))}}]),i}(k.Component);Zle.defaultProps={value:"",wrapperProps:{},wrapperStyle:{display:"inline-block"},inputProps:{},onChange(){},onSelect(){},renderMenu(e,g,i){return k.createElement("div",{style:{...i,...this.menuStyle}},e)},shouldItemRender(){return!0},menuStyle:{borderRadius:"3px",boxShadow:"0 2px 12px rgba(0, 0, 0, 0.1)",background:"rgba(255, 255, 255, 0.9)",padding:"2px 0",fontSize:"90%",position:"fixed",overflow:"auto",maxHeight:"50%"},autoHighlight:!0,onMenuVisibilityChange(){}};Zle.propTypes={autoHighlight:L.bool,debug:L.bool,getItemValue:L.func.isRequired,inputProps:L.object,items:L.array,menuStyle:L.object,onChange:L.func,onFocus:L.func,onMenuVisibilityChange:L.func,onSelect:L.func,open:L.bool,renderItem:L.func.isRequired,renderMenu:L.func,shouldItemRender:L.func,sortItems:L.func,value:L.any,wrapperProps:L.object,wrapperStyle:L.object};const nVg="_btn_1l2sx_95",aG={"genome-position-search":"_genome-position-search_1l2sx_1","genome-position-search-focus":"_genome-position-search-focus_1l2sx_2","genome-position-search-bar":"_genome-position-search-bar_1l2sx_16","genome-position-search-dark":"_genome-position-search-dark_1l2sx_34","genome-position-search-bar-button":"_genome-position-search-bar-button_1l2sx_38","genome-position-search-bar-button-focus":"_genome-position-search-bar-button-focus_1l2sx_39","genome-position-search-bar-icon":"_genome-position-search-bar-icon_1l2sx_62","genome-position-search-bar-icon-focus":"_genome-position-search-bar-icon-focus_1l2sx_63","genome-position-search-bar-suggestions":"_genome-position-search-bar-suggestions_1l2sx_83",btn:nVg,"btn-sm":"_btn-sm_1l2sx_116","btn-default":"_btn-default_1l2sx_122"};function IVg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function EWe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function RD(e){return RD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},RD(e)}let V$e=function(e){aVg(i,e);var g=sVg(i);function i(n){var I;return IVg(this,i),I=g.call(this,n),I.mounted=!1,I.uid=Ng.nice(),I.chromInfo=null,I.searchField=null,I.autocompleteMenu=null,I.xScale=null,I.yScale=null,I.prevParts=[],I.props.registerViewportChangedListener(I.scalesChanged.bind(R$e(I))),I.menuPosition={left:0,top:0},I.positionText="chr4:190,998,876-191,000,255",I.state={genes:[],isFocused:!1,autocompleteServer:I.props.autocompleteServer,autocompleteId:I.props.autocompleteId,availableAssemblies:[],selectedAssembly:null},I.styles={item:{padding:"2px 6px",cursor:"default"},highlightedItem:{color:"white",background:"hsl(200, 50%, 50%)",padding:"2px 6px",cursor:"default"},menu:{border:"solid 1px #ccc"}},I.availableAutocompletes={},I.props.autocompleteId&&(I.availableAutocompletes[I.props.chromInfoId]=new Set([{server:I.props.autocompleteServer,acId:I.props.autocompleteId}])),I.availableChromSizes={},I}return rVg(i,[{key:"componentDidMount",value:function(){this.mounted=!0,xg(this.autocompleteMenu.inputEl).on("keypress",this.autocompleteKeyPress.bind(this)),this.findAvailableAutocompleteSources(),this.findAvailableChromSizes(),this.props.chromInfoPath&&(this.searchPosition=!0,Fd(this.props.chromInfoPath,I=>{if(!I){this.searchPosition=null;return}this.chromInfo=I,this.searchField=new Bw(this.chromInfo),this.setPositionText()})),this.setPositionText()}},{key:"componentWillUnmount",value:function(){this.mounted=!1,this.props.removeViewportChangedListener()}},{key:"onAutocompleteChange",value:function(I,r){this.positionText=r,this.setState({value:r,loading:!0}),this.changedPart=null;const o=r.split(/ /);let C=0;const a=[];let A=!1;for(let s=0;s{if(l)this.setState({loading:!1,genes:[]});else if(this.changedPart>0&&!A){const u=`${this.state.autocompleteServer}/suggest/?d=${this.state.autocompleteId}&ac=${a[this.changedPart-1].toLowerCase()}-${a[this.changedPart].toLowerCase()}`;Nt.json(u,(d,h)=>{d?this.setState({loading:!1,genes:c}):this.setState({loading:!1,genes:h.concat(c)})},this.props.pubSub)}else this.setState({loading:!1,genes:c})},this.props.pubSub)}}},{key:"setAvailableAssemblies",value:function(){const I=new Set(Ya(this.availableChromSizes)),r=new Set([...I]);this.gpsbForm&&this.setState({availableAssemblies:[...r]})}},{key:"setSelectedAssembly",value:function(I){if(!this.mounted||!this.availableChromSizes[I])return;const r=[...this.availableChromSizes[I]][0];this.setState({autocompleteServer:r.server});const{server:o}=r;if(this.availableAutocompletes[I]){const C=[...this.availableAutocompletes[I]][0].acId;this.props.onSelectedAssemblyChanged(I,C,o),this.gpsbForm&&this.setState({autocompleteId:C})}else this.props.onSelectedAssemblyChanged(I,null,o),this.gpsbForm&&this.setState({autocompleteId:null});this.fetchChromInfo(r.uuid,r.server)}},{key:"setPositionText",value:function(){if(!this.mounted||!this.searchField)return;const I=this.searchField.scalesToPositionText(this.xScale,this.yScale,this.props.twoD);this.prevParts=I.split(/[ -]/),this.gpsbForm&&(this.positionText=I,this.origPositionText=I,this.autocompleteMenu.inputEl.value=I)}},{key:"scalesChanged",value:function(I,r){this.xScale=I,this.yScale=r,this.setPositionText()}},{key:"findAvailableChromSizes",value:function(){this.props.trackSourceServers&&this.props.trackSourceServers.forEach(I=>{Nt.json(`${I}/available-chrom-sizes/`,(r,o)=>{r?console.error(r):(o.results.forEach(C=>{C.coordSystem in this.availableChromSizes||(this.availableChromSizes[C.coordSystem]=new Set),this.availableChromSizes[C.coordSystem].add({server:I,uuid:C.uuid}),this.setAvailableAssemblies()}),this.searchField||this.fetchChromInfo(this.props.chromInfoId in this.availableChromSizes?[...this.availableChromSizes[this.props.chromInfoId]][0].uuid:this.props.chromInfoId,this.props.chromInfoId in this.availableChromSizes?[...this.availableChromSizes[this.props.chromInfoId]][0].server:this.props.chromInfoServer))},this.props.pubSub)})}},{key:"findAvailableAutocompleteSources",value:function(){this.props.trackSourceServers&&this.props.trackSourceServers.forEach(I=>{Nt.json(`${I}/tilesets/?limit=100&dt=gene-annotation`,(r,o)=>{r?console.error(r):(o.results.forEach(C=>{C.coordSystem in this.availableAutocompletes||(this.availableAutocompletes[C.coordSystem]=new Set),this.availableAutocompletes[C.coordSystem].add({server:I,acId:C.uuid}),this.setAvailableAssemblies()}),this.state.autocompleteId||this.gpsbForm&&this.availableAutocompletes[this.props.chromInfoId]&&this.setState({autocompleteId:[...this.availableAutocompletes[this.props.chromInfoId]][0].acId}))},this.props.pubSub)})}},{key:"fetchChromInfo",value:function(I,r){Fd(`${r}/chrom-sizes/?id=${I}`,o=>{o&&(Nt.json(`${r}/tileset_info/?d=${I}`,(C,a)=>{C||this.gpsbForm&&this.setState({selectedAssembly:a[I].coordSystem})},this.props.pubSub),this.chromInfo=o,this.searchField=new Bw(this.chromInfo),this.setPositionText())},this.props.pubSub)}},{key:"autocompleteKeyPress",value:function(I){I.keyCode===13&&this.buttonClick()}},{key:"genePositionToSearchBarText",value:function(I){}},{key:"replaceGenesWithLoadedPositions",value:function(I){const r=this.positionText,o=r.split(" ");let C=!1;for(let A=0;Al;){const d=s.slice(l,c).join("-");if(I[d.toLowerCase()]){const h=I[d.toLowerCase()],f=Math.floor((h.txEnd-h.txStart)/4);l===0&&c{if(C){const a={};for(let s=0;sconsole.error(C))}},{key:"buttonClick",value:function(){this.setState({genes:[]}),this.replaceGenesWithPositions(I=>{const r=this.positionText;if(this.searchField!==null){const o=this.searchField.searchPosition(r),C=o[0];let a=o[1];if(!C){this.setPositionText();return}if(C&&(Number.isNaN(+C[0])||Number.isNaN(+C[1]))||a&&(Number.isNaN(+a[0])||Number.isNaN(+a[1])))return;a||(a=C);const A=this.xScale.copy().domain(C),s=this.yScale.copy().domain(a),[l,c,u]=AI(A,s);I&&this.props.onGeneSearch({geneSymbol:I,range:C,centerX:l,centerY:c}),this.props.setCenters(l,c,u,kPe)}})}},{key:"searchFieldSubmit",value:function(){this.buttonClick()}},{key:"pathJoin",value:function(I,r){const o=r||"/",C=new RegExp(`${o}{1,}`,"g");return I.join(o).replace(C,o)}},{key:"geneSelected",value:function(I,r){const o=this.positionText.split(" ");let C=this.changedPart;for(let a=0;aA.length-1)C-=A.length;else{if(A[C]=r.geneName,s.length===2&&C>0&&A[C-1].toLowerCase()===s[0].toLowerCase()){const l=A.slice(0,C-1);l.push(s.join("-")),Ck.createElement("option",{key:r,value:r},r));return k.createElement("div",{ref:r=>{this.gpsbForm=r},className:gi({[aG["genome-position-search-focus"]]:this.state.isFocused,[aG["genome-position-search"]]:!this.state.isFocused,[aG["genome-position-search-dark"]]:this.props.theme===ki})},!this.props.hideAvailableAssemblies&&k.createElement("select",{ref:r=>{this.assemblyPickButton=r},className:aG["genome-position-search-bar-button"],id:this.uid,onChange:this.handleAssemblySelectEvt.bind(this),value:this.state.selectedAssembly||void 0},I),k.createElement(Zle,{ref:r=>{this.autocompleteMenu=r},getItemValue:r=>r.geneName,inputProps:{className:aG["genome-position-search-bar"],title:"Current location: enter a symbol or location to change the position of the current view"},items:this.state.genes,menuStyle:{position:"absolute",left:this.menuPosition.left,top:this.menuPosition.top,border:"1px solid black"},onChange:this.onAutocompleteChange.bind(this),onFocus:this.focusHandler.bind(this),onMenuVisibilityChange:this.handleMenuVisibilityChange.bind(this),onSelect:(r,o)=>this.geneSelected(r,o),onSubmit:this.searchFieldSubmit.bind(this),renderItem:(r,o)=>k.createElement("div",{key:r.refseqid,id:r.refseqid,style:o?this.styles.highlightedItem:this.styles.item},r.geneName),renderMenu:this.handleRenderMenu.bind(this),value:this.state.selectedAssembly?this.positionText:"No valid assembly selected",wrapperStyle:{width:"100%"}}),k.createElement(MPe,{onClick:this.buttonClick.bind(this),theStyle:"multitrack-header-icon"}))}}]),i}(k.Component);V$e.propTypes={autocompleteId:L.string,autocompleteServer:L.string,chromInfoId:L.string,chromInfoServer:L.string,chromInfoPath:L.string,hideAvailableAssemblies:L.bool,isFocused:L.bool,pubSub:L.object,onFocus:L.func,onGeneSearch:L.func,onSelectedAssemblyChanged:L.func,registerViewportChangedListener:L.func,removeViewportChangedListener:L.func,setCenters:L.func,theme:L.symbol.isRequired,trackSourceServers:L.array,twoD:L.bool};const cVg=L1(iZ(V$e)),uVg={"export-link-dialog-wrapper":"_export-link-dialog-wrapper_p9gxw_1"};function dVg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function DWe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function VD(e){return VD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},VD(e)}let Gle=function(e){pVg(i,e);var g=bVg(i);function i(){return dVg(this,i),g.apply(this,arguments)}return hVg(i,[{key:"render",value:function(){return k.createElement(aH,{okayOnly:!0,okayTitle:"Done",onOkay:this.props.onDone,title:"Share view link"},k.createElement("div",{className:uVg["export-link-dialog-wrapper"]},k.createElement("input",{ref:I=>{I&&(this.input=I,I.focus(),I.select())},onClick:I=>{I.target.select()},placeholder:"Generating the link...",readOnly:!0,value:this.props.url}),k.createElement(fd,{onClick:I=>{this.input.select(),document.execCommand("copy")}},"Copy")))}}]),i}(k.Component);Gle.defaultProps={onDone:()=>{},url:""};Gle.propTypes={onDone:L.func,url:L.string};function vVg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function MWe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function WD(e){return WD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},WD(e)}let W$e=function(e){RVg(i,e);var g=VVg(i);function i(n){var I;return vVg(this,i),I=g.call(this,n),I.state={submenuShown:!1},I}return BVg(i,[{key:"getConfigureViewMenu",value:function(I,r){const o=["backgroundColor"],C={},a={};for(const A of o)if(A in Object.keys(rr)&&(C[A]={name:rr[A].name},rr[A].inlineOptions))for(const s in rr[A].inlineOptions){const l=rr[A].inlineOptions[s];C[A].children||(C[A].children={});const c={name:l.name,value:l.value};c.handler=()=>{a[A]=l.value,this.props.onOptionsChanged(a)},C[A].children[s]=c}return k.createElement(Wge,{key:"config-series-menu",closeMenu:this.props.closeMenu,menuItems:C,orientation:this.state.orientation,parentBbox:r,position:I,theme:this.props.theme})}},{key:"getSubmenu",value:function(){if(this.state.submenuShown){const I=this.state.submenuSourceBbox,r=this.state.orientation==="left"?{left:this.state.left,top:I.top}:{left:this.state.left+I.width+7,top:I.top};return this.state.submenuShown.option==="options"?this.getConfigureViewMenu(r,I):k.createElement("div",null)}return k.createElement("div",null)}},{key:"render",value:function(){return k.createElement("div",{ref:I=>{this.div=I},className:gi(ug["context-menu"],{[ug["context-menu-dark"]]:this.props.theme===ki}),"data-menu-type":"ConfigViewMenu",style:{left:this.state.left,top:this.state.top}},k.createElement(yg,{onClick:I=>this.props.onTogglePositionSearchBox(I)},"Toggle position search box"),k.createElement("hr",{className:ug["context-menu-hr"]}),k.createElement(yg,{onClick:I=>this.props.onZoomToData(I)},"Zoom to data extent"),k.createElement(yg,{onClick:I=>this.props.onClearView(I)},"Clear View"),k.createElement("hr",{className:ug["context-menu-hr"]}),k.createElement(yg,{onClick:I=>this.props.onYankZoom(I)},"Take zoom from"),k.createElement(yg,{onClick:I=>this.props.onYankLocation(I)},"Take location from"),k.createElement(yg,{onClick:I=>this.props.onYankZoomAndLocation(I)},"Take zoom and location from"),k.createElement("hr",{className:ug["context-menu-hr"]}),k.createElement(yg,{onClick:this.props.onLockZoom},"Lock zoom with"),k.createElement(yg,{onClick:this.props.onLockLocation},"Lock location with"),k.createElement(yg,{onClick:this.props.onLockZoomAndLocation},"Lock zoom and location with"),k.createElement("hr",{className:ug["context-menu-hr"]}),k.createElement(yg,{onClick:this.props.onTakeAndLockZoomAndLocation},"Take and lock zoom and location with"),k.createElement("hr",{className:ug["context-menu-hr"]}),k.createElement(yg,{onClick:I=>this.props.onUnlockZoom(I)},"Unlock zoom"),k.createElement(yg,{onClick:I=>this.props.onUnlockLocation(I)},"Unlock location"),k.createElement(yg,{onClick:I=>this.props.onUnlockZoomAndLocation(I)},"Unlock zoom and location"),k.createElement("hr",{className:ug["context-menu-hr"]}),k.createElement(yg,{onClick:I=>this.props.onProjectViewport(I)},"Show this viewport on"),k.createElement("hr",{className:ug["context-menu-hr"]}),k.createElement(yg,{onClick:I=>this.props.onEditViewConfig(I)},"Edit view config"),k.createElement("hr",{className:ug["context-menu-hr"]}),k.createElement(yg,{onClick:()=>this.props.onExportSVG()},"Export views as SVG"),k.createElement(yg,{onClick:()=>this.props.onExportPNG()},"Export views as PNG"),k.createElement(yg,{onClick:()=>this.props.onExportViewAsJSON()},"Export views as JSON"),k.createElement(yg,{onClick:()=>this.props.onExportViewAsLink()},"Export views as Link"),this.getSubmenu())}}]),i}(qm);W$e.propTypes={onEditViewConfig:L.func.isRequired,onExportSVG:L.func,onExportPNG:L.func,onExportViewAsJSON:L.func,onExportViewAsLink:L.func,onLockLocation:L.func,onLockZoom:L.func,onLockZoomAndLocation:L.func,onProjectViewport:L.func,onTakeAndLockZoomAndLocation:L.func,onTogglePositionSearchBox:L.func,onUnlockLocation:L.func,onUnlockZoom:L.func,onUnlockZoomAndLocation:L.func,onYankLocation:L.func,onYankZoom:L.func,onYankZoomAndLocation:L.func,onZoomToData:L.func,theme:L.symbol};const Wa={"add-track-position-table":"_add-track-position-table_wdy5w_1","add-track-position-table-dark":"_add-track-position-table-dark_wdy5w_7","add-track-position-other":"_add-track-position-other_wdy5w_11","add-track-position-top-center":"_add-track-position-top-center_wdy5w_15","add-track-position-middle-left":"_add-track-position-middle-left_wdy5w_30","add-track-position-middle-right":"_add-track-position-middle-right_wdy5w_45","add-track-position-middle-middle":"_add-track-position-middle-middle_wdy5w_60","add-track-position-bottom-middle":"_add-track-position-bottom-middle_wdy5w_71","add-track-position-span":"_add-track-position-span_wdy5w_86"};function X$e(e){return k.createElement("div",null,k.createElement("div",{className:Wa["add-track-position-span"]},"Add Track..."),k.createElement("table",{className:gi(Wa["add-track-position-table"],{[Wa["add-track-position-table-dark"]]:e.theme===ki})},k.createElement("tbody",null,k.createElement("tr",{style:{height:"30px"}},k.createElement("td",{"aria-hidden":"true",className:Wa["add-track-position-other"]}),k.createElement("td",{className:Wa["add-track-position-top-center"],onClick:()=>e.onTrackPositionChosen("top")},"top"),k.createElement("td",{"aria-hidden":"true",className:Wa["add-track-position-other"]})),k.createElement("tr",{style:{height:"80px"}},k.createElement("td",{className:Wa["add-track-position-middle-left"],onClick:()=>e.onTrackPositionChosen("left")},"left"),k.createElement("td",{className:Wa["add-track-position-middle-middle"],onClick:()=>e.onTrackPositionChosen("center")},"center"),k.createElement("td",{className:Wa["add-track-position-middle-right"],onClick:()=>e.onTrackPositionChosen("right")},"right")),k.createElement("tr",{style:{height:"30px"}},k.createElement("td",{"aria-hidden":"true",className:Wa["add-track-position-other"]}),k.createElement("td",{className:Wa["add-track-position-bottom-middle"],onClick:()=>e.onTrackPositionChosen("bottom")},"bottom"),k.createElement("td",{"aria-hidden":"true",className:Wa["add-track-position-other"]})))))}X$e.propTypes={onTrackPositionChosen:L.func.isRequired,theme:L.symbol.isRequired};const HVg=iZ(X$e);function NVg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function zWe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function XD(e){return XD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},XD(e)}let vle=function(e){xVg(i,e);var g=FVg(i);function i(n){var I;return NVg(this,i),I=g.call(this,n),I.configImg=null,I.plusImg=null,I.state={addTrackPositionMenuUid:null,addTrackPositionMenuPosition:null,configMenuUid:null,configMenuPosition:null,isFocused:!1,width:-1},I.handleTrackPositionChosenBound=I.handleTrackPositionChosen.bind(T$e(I)),I}return kVg(i,[{key:"componentDidMount",value:function(){this.setState({width:this.el.clientWidth})}},{key:"checkWidth",value:function(){const I=this.el.clientWidth;I!==this.state.width&&this.setState({width:I})}},{key:"handleConfigMenuOpened",value:function(I){this.setState({configMenuUid:I,configMenuPosition:this.configImg.getBoundingClientRect()})}},{key:"handleAddTrackPositionMenuOpened",value:function(I){this.setState({addTrackPositionMenuUid:I,addTrackPositionMenuPosition:this.plusImg.getBoundingClientRect()})}},{key:"handleTrackPositionChosen",value:function(I){this.props.onTrackPositionChosen(I),this.setState({addTrackPositionMenuUid:null,addTrackPositionMenuPosition:null})}},{key:"render",value:function(){let I=null,r=null;this.state.addTrackPositionMenuPosition&&(r=k.createElement(gm,{onMenuClosed:()=>{this.setState({addTrackPositionMenuUid:null,addTrackPositionMenuPosition:null})}},k.createElement(qm,{orientation:"left",position:this.state.addTrackPositionMenuPosition,theme:this.props.theme},k.createElement(HVg,{onTrackPositionChosen:this.handleTrackPositionChosenBound})))),this.state.configMenuUid&&(I=k.createElement(gm,{onMenuClosed:()=>this.setState({configMenuUid:null})},k.createElement(W$e,{onClearView:()=>{this.setState({configMenuUid:null}),this.props.onClearView()},onEditViewConfig:()=>{this.setState({configMenuUid:null}),this.props.onEditViewConfig(this.state.configMenuUid)},onExportPNG:()=>{this.setState({configMenuUid:null}),this.props.onExportPNG()},onExportSVG:()=>{this.setState({configMenuUid:null}),this.props.onExportSVG()},onExportViewAsJSON:()=>{this.setState({configMenuUid:null}),this.props.onExportViewsAsJSON()},onExportViewAsLink:()=>{this.setState({configMenuUid:null}),this.props.onExportViewsAsLink()},onLockLocation:()=>{this.setState({configMenuUid:null}),this.props.onLockLocation(this.state.configMenuUid)},onLockZoom:()=>{this.setState({configMenuUid:null}),this.props.onLockZoom(this.state.configMenuUid)},onLockZoomAndLocation:()=>{this.setState({configMenuUid:null}),this.props.onLockZoomAndLocation(this.state.configMenuUid)},onOptionsChanged:A=>{this.props.onViewOptionsChanged(A),this.setState({configMenuUid:null})},onProjectViewport:()=>{this.setState({configMenuUid:null}),this.props.onProjectViewport(this.state.configMenuUid)},onTakeAndLockZoomAndLocation:()=>{this.setState({configMenuUid:null}),this.props.onTakeAndLockZoomAndLocation(this.state.configMenuUid)},onTogglePositionSearchBox:()=>{this.setState({configMenuUid:null}),this.props.onTogglePositionSearchBox(this.state.configMenuUid)},onUnlockLocation:()=>{this.setState({configMenuUid:null}),this.props.onUnlockLocation(this.state.configMenuUid)},onUnlockZoom:()=>{this.setState({configMenuUid:null}),this.props.onUnlockZoom(this.state.configMenuUid)},onUnlockZoomAndLocation:()=>{this.setState({configMenuUid:null}),this.props.onUnlockZoomAndLocation(this.state.configMenuUid)},onYankLocation:()=>{this.setState({configMenuUid:null}),this.props.onYankLocation(this.state.configMenuUid)},onYankZoom:()=>{this.setState({configMenuUid:null}),this.props.onYankZoom(this.state.configMenuUid)},onYankZoomAndLocation:()=>{this.setState({configMenuUid:null}),this.props.onYankZoomAndLocation(this.state.configMenuUid)},onZoomToData:()=>{this.setState({configMenuUid:null}),this.props.onZoomToData(this.state.configMenuUid)},orientation:"left",position:this.state.configMenuPosition,theme:this.props.theme})));const o=this.props.getGenomePositionSearchBox(this.state.isFocused,A=>{this.setState({isFocused:A})}),C=gi(this.state.isFocused?ka["multitrack-header-focus"]:ka["multitrack-header"],{[ka["multitrack-header-dark"]]:this.props.theme===ki}),a=this.state.width<=YPe?ka["multitrack-header-icon-squeazed"]:ka["multitrack-header-icon"];return k.createElement("div",{ref:A=>{this.el=A},className:C},k.createElement("div",{className:ka["multitrack-header-left"]},this.props.mouseTool===Ja&&k.createElement("svg",{className:gi(ka["mouse-tool-selection"],a),title:"Selection tool active"},k.createElement("use",{xlinkHref:"#select"})),k.createElement("div",{className:ka["multitrack-header-grabber"],title:"Drag to move the view"},k.createElement("div",null),k.createElement("div",null),k.createElement("div",null)),this.state.width>KPe&&k.createElement("div",{className:ka["multitrack-header-search"]},this.props.isGenomePositionSearchBoxVisible&&o)),k.createElement("nav",{className:ka["multitrack-header-nav-list"]},k.createElement("svg",{className:a,onClick:this.props.onAddView},k.createElement("title",null,"Add new view (clone this view)"),k.createElement("use",{xlinkHref:"#copy"})),k.createElement("svg",{ref:A=>{this.configImg=A},className:a,onClick:()=>this.handleConfigMenuOpened(this.props.viewUid)},k.createElement("title",null,"Configure this view"),k.createElement("use",{xlinkHref:"#cog"})),k.createElement("svg",{ref:A=>{this.plusImg=A},className:a,onClick:()=>this.handleAddTrackPositionMenuOpened(this.props.viewUid)},k.createElement("title",null,"Add Track"),k.createElement("use",{xlinkHref:"#plus"})),k.createElement("svg",{className:a,onClick:this.props.onCloseView},k.createElement("title",null,"Close View"),k.createElement("use",{xlinkHref:"#cross"}))),I,r)}}]),i}(k.Component);vle.defaultProps={isGenomePositionSearchBoxVisible:!1};vle.propTypes={getGenomePositionSearchBox:L.func.isRequired,isGenomePositionSearchBoxVisible:L.bool,mouseTool:L.string.isRequired,onAddView:L.func.isRequired,onClearView:L.func.isRequired,onCloseView:L.func.isRequired,onEditViewConfig:L.func.isRequired,onExportSVG:L.func.isRequired,onExportPNG:L.func.isRequired,onExportViewsAsJSON:L.func.isRequired,onExportViewsAsLink:L.func.isRequired,onLockLocation:L.func.isRequired,onLockZoom:L.func.isRequired,onLockZoomAndLocation:L.func.isRequired,onProjectViewport:L.func.isRequired,onTakeAndLockZoomAndLocation:L.func.isRequired,onTogglePositionSearchBox:L.func.isRequired,onTrackPositionChosen:L.func.isRequired,onUnlockLocation:L.func.isRequired,onUnlockZoom:L.func.isRequired,onUnlockZoomAndLocation:L.func.isRequired,onViewOptionsChanged:L.func.isRequired,onYankLocation:L.func.isRequired,onYankZoom:L.func.isRequired,onYankZoomAndLocation:L.func.isRequired,onZoomToData:L.func.isRequired,theme:L.symbol.isRequired,viewUid:L.string.isRequired};const MVg=iZ(vle);var H$e={};Object.defineProperty(H$e,"__esModule",{value:!0});var Th=Object.assign||function(e){for(var g=1;g=0||Object.prototype.hasOwnProperty.call(e,n)&&(i[n]=e[n]);return i}function JVg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function PWe(e,g){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g&&(typeof g=="object"||typeof g=="function")?g:e}function LVg(e,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);e.prototype=Object.create(g&&g.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(e,g):e.__proto__=g)}var UVg=13,QVg=9,jVg=8,$Vg=89,hY=90,qVg=77,_We=57,OWe=219,JWe=222,LWe=192,e2g=27,UWe=100,t2g=3e3,g2g="navigator"in globalThis&&/Win/i.test(navigator.platform),sj="navigator"in globalThis&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),Y5="npm__react-simple-code-editor__textarea",i2g=` +/** + * Reset the text fill color so that placeholder is visible + */ +.`+Y5+`:empty { + -webkit-text-fill-color: inherit !important; +} + +/** + * Hack to apply on some CSS on IE10 and IE11 + */ +@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) { + /** + * IE doesn't support '-webkit-text-fill-color' + * So we use 'color: transparent' to make the text transparent on IE + * Unlike other browsers, it doesn't affect caret color in IE + */ + .`+Y5+` { + color: transparent !important; + } + + .`+Y5+`::selection { + background-color: #accef7 !important; + color: transparent !important; + } +} +`,N$e=function(e){LVg(g,e);function g(){var i,n,I,r;JVg(this,g);for(var o=arguments.length,C=Array(o),a=0;a1&&arguments[1]!==void 0?arguments[1]:!1,l=I._history,c=l.stack,u=l.offset;if(c.length&&u>-1){I._history.stack=c.slice(0,u+1);var d=I._history.stack.length;if(d>UWe){var h=d-UWe;I._history.stack=c.slice(h,d),I._history.offset=Math.max(I._history.offset-h,0)}}var f=Date.now();if(s){var m=I._history.stack[I._history.offset];if(m&&f-m.timestamp=Z&&U<=v&&Q.startsWith(p)?Q.substring(p.length):Q}).join(` +`);if(f!==G){var B=y[Z];I._applyEdits({value:G,selectionStart:B.startsWith(p)?m-p.length:m,selectionEnd:b-(f.length-G.length)})}}else if(m!==b){var S=I._getLines(f,m),R=S.length-1,w=I._getLines(f,b).length-1,T=S[R];I._applyEdits({value:f.split(` +`).map(function(Q,U){return U>=R&&U<=w?p+Q:Q}).join(` +`),selectionStart:/\S/.test(T)?m+p.length:m,selectionEnd:b+p.length*(w-R+1)})}else{var W=m+p.length;I._applyEdits({value:f.substring(0,m)+p+f.substring(b),selectionStart:W,selectionEnd:W})}else if(A.keyCode===jVg){var V=m!==b,X=f.substring(0,m);if(X.endsWith(p)&&!V){A.preventDefault();var N=m-p.length;I._applyEdits({value:f.substring(0,m-p.length)+f.substring(b),selectionStart:N,selectionEnd:N})}}else if(A.keyCode===UVg){if(m===b){var Y=I._getLines(f,m).pop(),x=Y.match(/^\s+/);if(x&&x[0]){A.preventDefault();var M=` +`+x[0],F=m+M.length;I._applyEdits({value:f.substring(0,m)+M+f.substring(b),selectionStart:F,selectionEnd:F})}}}else if(A.keyCode===_We||A.keyCode===OWe||A.keyCode===JWe||A.keyCode===LWe){var $=void 0;A.keyCode===_We&&A.shiftKey?$=["(",")"]:A.keyCode===OWe?A.shiftKey?$=["{","}"]:$=["[","]"]:A.keyCode===JWe?A.shiftKey?$=['"','"']:$=["'","'"]:A.keyCode===LWe&&!A.shiftKey&&($=["`","`"]),m!==b&&$&&(A.preventDefault(),I._applyEdits({value:f.substring(0,m)+$[0]+f.substring(m,b)+$[1]+f.substring(b),selectionStart:m,selectionEnd:b+2}))}else(sj?A.metaKey&&A.keyCode===hY:A.ctrlKey&&A.keyCode===hY)&&!A.shiftKey&&!A.altKey?(A.preventDefault(),I._undoEdit()):(sj?A.metaKey&&A.keyCode===hY&&A.shiftKey:g2g?A.ctrlKey&&A.keyCode===$Vg:A.ctrlKey&&A.keyCode===hY&&A.shiftKey)&&!A.altKey?(A.preventDefault(),I._redoEdit()):A.keyCode===qVg&&A.ctrlKey&&(!sj||A.shiftKey)&&(A.preventDefault(),I.setState(function(Q){return{capture:!Q.capture}}))}},I._handleChange=function(A){var s=A.target,l=s.value,c=s.selectionStart,u=s.selectionEnd;I._recordChange({value:l,selectionStart:c,selectionEnd:u},!0),I.props.onValueChange(l)},I._history={stack:[],offset:-1},n),PWe(I,r)}return zVg(g,[{key:"componentDidMount",value:function(){this._recordCurrentState()}},{key:"render",value:function(){var n=this,I=this.props,r=I.value,o=I.style,C=I.padding,a=I.highlight,A=I.textareaId,s=I.autoFocus,l=I.disabled,c=I.form,u=I.maxLength,d=I.minLength,h=I.name,f=I.placeholder,m=I.readOnly,b=I.required,p=I.onClick,y=I.onFocus,Z=I.onBlur,v=I.onKeyUp;I.onKeyDown,I.onValueChange,I.tabSize,I.insertSpaces,I.ignoreTabKey;var G=OVg(I,["value","style","padding","highlight","textareaId","autoFocus","disabled","form","maxLength","minLength","name","placeholder","readOnly","required","onClick","onFocus","onBlur","onKeyUp","onKeyDown","onValueChange","tabSize","insertSpaces","ignoreTabKey"]),B={paddingTop:C,paddingRight:C,paddingBottom:C,paddingLeft:C},S=a(r);return YR.createElement("div",Th({},G,{style:Th({},KR.container,o)}),YR.createElement("textarea",{ref:function(w){return n._input=w},style:Th({},KR.editor,KR.textarea,B),className:Y5,id:A,value:r,onChange:this._handleChange,onKeyDown:this._handleKeyDown,onClick:p,onKeyUp:v,onFocus:y,onBlur:Z,disabled:l,form:c,maxLength:u,minLength:d,name:h,placeholder:f,readOnly:m,required:b,autoFocus:s,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"data-gramm":!1}),YR.createElement("pre",Th({"aria-hidden":"true",style:Th({},KR.editor,KR.highlight,B)},typeof S=="string"?{dangerouslySetInnerHTML:{__html:S+"
"}}:{children:S})),YR.createElement("style",{type:"text/css",dangerouslySetInnerHTML:{__html:i2g}}))}},{key:"session",get:function(){return{history:this._history}},set:function(n){this._history=n.history}}]),g}(YR.Component);N$e.defaultProps={tabSize:2,insertSpaces:!0,ignoreTabKey:!1,padding:0};var n2g=H$e.default=N$e,KR={container:{position:"relative",textAlign:"left",boxSizing:"border-box",padding:0,overflow:"hidden"},textarea:{position:"absolute",top:0,left:0,height:"100%",width:"100%",resize:"none",color:"inherit",overflow:"hidden",MozOsxFontSmoothing:"grayscale",WebkitFontSmoothing:"antialiased",WebkitTextFillColor:"transparent"},highlight:{position:"relative",pointerEvents:"none"},editor:{margin:0,border:0,background:"none",boxSizing:"inherit",display:"inherit",fontFamily:"inherit",fontSize:"inherit",fontStyle:"inherit",fontVariantLigatures:"inherit",fontWeight:"inherit",letterSpacing:"inherit",lineHeight:"inherit",tabSize:"inherit",textIndent:"inherit",textRendering:"inherit",textTransform:"inherit",whiteSpace:"pre-wrap",wordBreak:"keep-all",overflowWrap:"break-word"}},k$e={exports:{}};(function(e){var g=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};/** + * Prism: Lightweight, robust, elegant syntax highlighting + * + * @license MIT + * @author Lea Verou + * @namespace + * @public + */var i=function(n){var I=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,r=0,o={},C={manual:n.Prism&&n.Prism.manual,disableWorkerMessageHandler:n.Prism&&n.Prism.disableWorkerMessageHandler,util:{encode:function b(p){return p instanceof a?new a(p.type,b(p.content),p.alias):Array.isArray(p)?p.map(b):p.replace(/&/g,"&").replace(/"u")return null;if("currentScript"in document&&1<2)return document.currentScript;try{throw new Error}catch(Z){var b=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(Z.stack)||[])[1];if(b){var p=document.getElementsByTagName("script");for(var y in p)if(p[y].src==b)return p[y]}return null}},isActive:function(b,p,y){for(var Z="no-"+p;b;){var v=b.classList;if(v.contains(p))return!0;if(v.contains(Z))return!1;b=b.parentElement}return!!y}},languages:{plain:o,plaintext:o,text:o,txt:o,extend:function(b,p){var y=C.util.clone(C.languages[b]);for(var Z in p)y[Z]=p[Z];return y},insertBefore:function(b,p,y,Z){Z=Z||C.languages;var v=Z[b],G={};for(var B in v)if(v.hasOwnProperty(B)){if(B==p)for(var S in y)y.hasOwnProperty(S)&&(G[S]=y[S]);y.hasOwnProperty(B)||(G[B]=v[B])}var R=Z[b];return Z[b]=G,C.languages.DFS(C.languages,function(w,T){T===R&&w!=b&&(this[w]=G)}),G},DFS:function b(p,y,Z,v){v=v||{};var G=C.util.objId;for(var B in p)if(p.hasOwnProperty(B)){y.call(p,B,p[B],Z||B);var S=p[B],R=C.util.type(S);R==="Object"&&!v[G(S)]?(v[G(S)]=!0,b(S,y,null,v)):R==="Array"&&!v[G(S)]&&(v[G(S)]=!0,b(S,y,B,v))}}},plugins:{},highlightAll:function(b,p){C.highlightAllUnder(document,b,p)},highlightAllUnder:function(b,p,y){var Z={callback:y,container:b,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};C.hooks.run("before-highlightall",Z),Z.elements=Array.prototype.slice.apply(Z.container.querySelectorAll(Z.selector)),C.hooks.run("before-all-elements-highlight",Z);for(var v=0,G;G=Z.elements[v++];)C.highlightElement(G,p===!0,Z.callback)},highlightElement:function(b,p,y){var Z=C.util.getLanguage(b),v=C.languages[Z];C.util.setLanguage(b,Z);var G=b.parentElement;G&&G.nodeName.toLowerCase()==="pre"&&C.util.setLanguage(G,Z);var B=b.textContent,S={element:b,language:Z,grammar:v,code:B};function R(T){S.highlightedCode=T,C.hooks.run("before-insert",S),S.element.innerHTML=S.highlightedCode,C.hooks.run("after-highlight",S),C.hooks.run("complete",S),y&&y.call(S.element)}if(C.hooks.run("before-sanity-check",S),G=S.element.parentElement,G&&G.nodeName.toLowerCase()==="pre"&&!G.hasAttribute("tabindex")&&G.setAttribute("tabindex","0"),!S.code){C.hooks.run("complete",S),y&&y.call(S.element);return}if(C.hooks.run("before-highlight",S),!S.grammar){R(C.util.encode(S.code));return}if(p&&n.Worker){var w=new Worker(C.filename);w.onmessage=function(T){R(T.data)},w.postMessage(JSON.stringify({language:S.language,code:S.code,immediateClose:!0}))}else R(C.highlight(S.code,S.grammar,S.language))},highlight:function(b,p,y){var Z={code:b,grammar:p,language:y};if(C.hooks.run("before-tokenize",Z),!Z.grammar)throw new Error('The language "'+Z.language+'" has no grammar.');return Z.tokens=C.tokenize(Z.code,Z.grammar),C.hooks.run("after-tokenize",Z),a.stringify(C.util.encode(Z.tokens),Z.language)},tokenize:function(b,p){var y=p.rest;if(y){for(var Z in y)p[Z]=y[Z];delete p.rest}var v=new l;return c(v,v.head,b),s(b,v,p,v.head,0),d(v)},hooks:{all:{},add:function(b,p){var y=C.hooks.all;y[b]=y[b]||[],y[b].push(p)},run:function(b,p){var y=C.hooks.all[b];if(!(!y||!y.length))for(var Z=0,v;v=y[Z++];)v(p)}},Token:a};n.Prism=C;function a(b,p,y,Z){this.type=b,this.content=p,this.alias=y,this.length=(Z||"").length|0}a.stringify=function b(p,y){if(typeof p=="string")return p;if(Array.isArray(p)){var Z="";return p.forEach(function(R){Z+=b(R,y)}),Z}var v={type:p.type,content:b(p.content,y),tag:"span",classes:["token",p.type],attributes:{},language:y},G=p.alias;G&&(Array.isArray(G)?Array.prototype.push.apply(v.classes,G):v.classes.push(G)),C.hooks.run("wrap",v);var B="";for(var S in v.attributes)B+=" "+S+'="'+(v.attributes[S]||"").replace(/"/g,""")+'"';return"<"+v.tag+' class="'+v.classes.join(" ")+'"'+B+">"+v.content+""};function A(b,p,y,Z){b.lastIndex=p;var v=b.exec(y);if(v&&Z&&v[1]){var G=v[1].length;v.index+=G,v[0]=v[0].slice(G)}return v}function s(b,p,y,Z,v,G){for(var B in y)if(!(!y.hasOwnProperty(B)||!y[B])){var S=y[B];S=Array.isArray(S)?S:[S];for(var R=0;R=G.reach);M+=x.value.length,x=x.next){var F=x.value;if(p.length>b.length)return;if(!(F instanceof a)){var $=1,Q;if(V){if(Q=A(Y,M,b,W),!Q||Q.index>=b.length)break;var Ie=Q.index,U=Q.index+Q[0].length,j=M;for(j+=x.value.length;Ie>=j;)x=x.next,j+=x.value.length;if(j-=x.value.length,M=j,x.value instanceof a)continue;for(var ee=x;ee!==p.tail&&(jG.reach&&(G.reach=pe);var ae=x.prev;Ve&&(ae=c(p,ae,Ve),M+=Ve.length),u(p,ae,$);var ie=new a(B,T?C.tokenize(fe,T):fe,X,fe);if(x=c(p,ae,ie),oe&&c(p,x,oe),$>1){var ye={cause:B+","+R,reach:pe};s(b,p,y,x.prev,M,ye),G&&ye.reach>G.reach&&(G.reach=ye.reach)}}}}}}function l(){var b={value:null,prev:null,next:null},p={value:null,prev:b,next:null};b.next=p,this.head=b,this.tail=p,this.length=0}function c(b,p,y){var Z=p.next,v={value:y,prev:p,next:Z};return p.next=v,Z.prev=v,b.length++,v}function u(b,p,y){for(var Z=p.next,v=0;v1){D[0]=D[0].slice(0,-1);for(var ce=D.length-1,he=1;he= 0x80 (not a basic code point)","invalid-input":"Invalid input"},w=h-f,T=Math.floor,W=String.fromCharCode;function V(O){throw new RangeError(R[O])}function X(O,D){for(var q=[],ce=O.length;ce--;)q[ce]=D(O[ce]);return q}function N(O,D){var q=O.split("@"),ce="";q.length>1&&(ce=q[0]+"@",O=q[1]),O=O.replace(S,".");var he=O.split("."),Oe=X(he,D).join(".");return ce+Oe}function Y(O){for(var D=[],q=0,ce=O.length;q=55296&&he<=56319&&q>1,D+=T(D/q);D>w*m>>1;he+=h)D=T(D/w);return T(he+(w+1)*D/(D+b))},Q=function(D){var q=[],ce=D.length,he=0,Oe=Z,Je=y,bt=D.lastIndexOf(v);bt<0&&(bt=0);for(var Xt=0;Xt=128&&V("not-basic"),q.push(D.charCodeAt(Xt));for(var Jt=bt>0?bt+1:0;Jt=ce&&V("invalid-input");var ct=M(D.charCodeAt(Jt++));(ct>=h||ct>T((d-he)/Ft))&&V("overflow"),he+=ct*Ft;var Mt=ig<=Je?f:ig>=Je+m?m:ig-Je;if(ctT(d/Cg)&&V("overflow"),Ft*=Cg}var $t=q.length+1;Je=$(he-Zt,$t,Zt==0),T(he/$t)>d-Oe&&V("overflow"),Oe+=T(he/$t),he%=$t,q.splice(he++,0,Oe)}return String.fromCodePoint.apply(String,q)},U=function(D){var q=[];D=Y(D);var ce=D.length,he=Z,Oe=0,Je=y,bt=!0,Xt=!1,Jt=void 0;try{for(var Zt=D[Symbol.iterator](),Ft;!(bt=(Ft=Zt.next()).done);bt=!0){var ig=Ft.value;ig<128&&q.push(W(ig))}}catch(jo){Xt=!0,Jt=jo}finally{try{!bt&&Zt.return&&Zt.return()}finally{if(Xt)throw Jt}}var ct=q.length,Mt=ct;for(ct&&q.push(v);Mt=he&&cgT((d-Oe)/Lt)&&V("overflow"),Oe+=(Cg-he)*Lt,he=Cg;var Dt=!0,pg=!1,lg=void 0;try{for(var hg=D[Symbol.iterator](),Tg;!(Dt=(Tg=hg.next()).done);Dt=!0){var ei=Tg.value;if(eid&&V("overflow"),ei==he){for(var Fg=Oe,Wn=h;;Wn+=h){var $I=Wn<=Je?f:Wn>=Je+m?m:Wn-Je;if(Fg<$I)break;var Ss=Fg-$I,fh=h-$I;q.push(W(F($I+Ss%fh,0))),Fg=T(Ss/fh)}q.push(W(F(Fg,0))),Je=$(Oe,Lt,Mt==ct),Oe=0,++Mt}}}catch(jo){pg=!0,lg=jo}finally{try{!Dt&&hg.return&&hg.return()}finally{if(pg)throw lg}}++Oe,++he}return q.join("")},j=function(D){return N(D,function(q){return G.test(q)?Q(q.slice(4).toLowerCase()):q})},ee=function(D){return N(D,function(q){return B.test(q)?"xn--"+U(q):q})},Ie={version:"2.1.0",ucs2:{decode:Y,encode:x},decode:Q,encode:U,toASCII:ee,toUnicode:j},fe={};function Ve(O){var D=O.charCodeAt(0),q=void 0;return D<16?q="%0"+D.toString(16).toUpperCase():D<128?q="%"+D.toString(16).toUpperCase():D<2048?q="%"+(D>>6|192).toString(16).toUpperCase()+"%"+(D&63|128).toString(16).toUpperCase():q="%"+(D>>12|224).toString(16).toUpperCase()+"%"+(D>>6&63|128).toString(16).toUpperCase()+"%"+(D&63|128).toString(16).toUpperCase(),q}function oe(O){for(var D="",q=0,ce=O.length;q=194&&he<224){if(ce-q>=6){var Oe=parseInt(O.substr(q+4,2),16);D+=String.fromCharCode((he&31)<<6|Oe&63)}else D+=O.substr(q,6);q+=6}else if(he>=224){if(ce-q>=9){var Je=parseInt(O.substr(q+4,2),16),bt=parseInt(O.substr(q+7,2),16);D+=String.fromCharCode((he&15)<<12|(Je&63)<<6|bt&63)}else D+=O.substr(q,9);q+=9}else D+=O.substr(q,3),q+=3}return D}function pe(O,D){function q(ce){var he=oe(ce);return he.match(D.UNRESERVED)?he:ce}return O.scheme&&(O.scheme=String(O.scheme).replace(D.PCT_ENCODED,q).toLowerCase().replace(D.NOT_SCHEME,"")),O.userinfo!==void 0&&(O.userinfo=String(O.userinfo).replace(D.PCT_ENCODED,q).replace(D.NOT_USERINFO,Ve).replace(D.PCT_ENCODED,o)),O.host!==void 0&&(O.host=String(O.host).replace(D.PCT_ENCODED,q).toLowerCase().replace(D.NOT_HOST,Ve).replace(D.PCT_ENCODED,o)),O.path!==void 0&&(O.path=String(O.path).replace(D.PCT_ENCODED,q).replace(O.scheme?D.NOT_PATH:D.NOT_PATH_NOSCHEME,Ve).replace(D.PCT_ENCODED,o)),O.query!==void 0&&(O.query=String(O.query).replace(D.PCT_ENCODED,q).replace(D.NOT_QUERY,Ve).replace(D.PCT_ENCODED,o)),O.fragment!==void 0&&(O.fragment=String(O.fragment).replace(D.PCT_ENCODED,q).replace(D.NOT_FRAGMENT,Ve).replace(D.PCT_ENCODED,o)),O}function ae(O){return O.replace(/^0*(.*)/,"$1")||"0"}function ie(O,D){var q=O.match(D.IPV4ADDRESS)||[],ce=c(q,2),he=ce[1];return he?he.split(".").map(ae).join("."):O}function ye(O,D){var q=O.match(D.IPV6ADDRESS)||[],ce=c(q,3),he=ce[1],Oe=ce[2];if(he){for(var Je=he.toLowerCase().split("::").reverse(),bt=c(Je,2),Xt=bt[0],Jt=bt[1],Zt=Jt?Jt.split(":").map(ae):[],Ft=Xt.split(":").map(ae),ig=D.IPV4ADDRESS.test(Ft[Ft.length-1]),ct=ig?7:8,Mt=Ft.length-ct,Cg=Array(ct),$t=0;$t1){var Tt=Cg.slice(0,Ti.index),cg=Cg.slice(Ti.index+Ti.length);It=Tt.join(":")+"::"+cg.join(":")}else It=Cg.join(":");return Oe&&(It+="%"+Oe),It}else return O}var ue=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,Ye="".match(/(){0}/)[1]===void 0;function Be(O){var D=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},q={},ce=D.iri!==!1?l:s;D.reference==="suffix"&&(O=(D.scheme?D.scheme+":":"")+"//"+O);var he=O.match(ue);if(he){Ye?(q.scheme=he[1],q.userinfo=he[3],q.host=he[4],q.port=parseInt(he[5],10),q.path=he[6]||"",q.query=he[7],q.fragment=he[8],isNaN(q.port)&&(q.port=he[5])):(q.scheme=he[1]||void 0,q.userinfo=O.indexOf("@")!==-1?he[3]:void 0,q.host=O.indexOf("//")!==-1?he[4]:void 0,q.port=parseInt(he[5],10),q.path=he[6]||"",q.query=O.indexOf("?")!==-1?he[7]:void 0,q.fragment=O.indexOf("#")!==-1?he[8]:void 0,isNaN(q.port)&&(q.port=O.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?he[4]:void 0)),q.host&&(q.host=ye(ie(q.host,ce),ce)),q.scheme===void 0&&q.userinfo===void 0&&q.host===void 0&&q.port===void 0&&!q.path&&q.query===void 0?q.reference="same-document":q.scheme===void 0?q.reference="relative":q.fragment===void 0?q.reference="absolute":q.reference="uri",D.reference&&D.reference!=="suffix"&&D.reference!==q.reference&&(q.error=q.error||"URI is not a "+D.reference+" reference.");var Oe=fe[(D.scheme||q.scheme||"").toLowerCase()];if(!D.unicodeSupport&&(!Oe||!Oe.unicodeSupport)){if(q.host&&(D.domainHost||Oe&&Oe.domainHost))try{q.host=Ie.toASCII(q.host.replace(ce.PCT_ENCODED,oe).toLowerCase())}catch(Je){q.error=q.error||"Host's domain name can not be converted to ASCII via punycode: "+Je}pe(q,s)}else pe(q,ce);Oe&&Oe.parse&&Oe.parse(q,D)}else q.error=q.error||"URI can not be parsed.";return q}function ke(O,D){var q=D.iri!==!1?l:s,ce=[];return O.userinfo!==void 0&&(ce.push(O.userinfo),ce.push("@")),O.host!==void 0&&ce.push(ye(ie(String(O.host),q),q).replace(q.IPV6ADDRESS,function(he,Oe,Je){return"["+Oe+(Je?"%25"+Je:"")+"]"})),(typeof O.port=="number"||typeof O.port=="string")&&(ce.push(":"),ce.push(String(O.port))),ce.length?ce.join(""):void 0}var _e=/^\.\.?\//,Pe=/^\/\.(\/|$)/,it=/^\/\.\.(\/|$)/,lt=/^\/?(?:.|\n)*?(?=\/|$)/;function je(O){for(var D=[];O.length;)if(O.match(_e))O=O.replace(_e,"");else if(O.match(Pe))O=O.replace(Pe,"/");else if(O.match(it))O=O.replace(it,"/"),D.pop();else if(O==="."||O==="..")O="";else{var q=O.match(lt);if(q){var ce=q[0];O=O.slice(ce.length),D.push(ce)}else throw new Error("Unexpected dot segment condition")}return D.join("")}function He(O){var D=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},q=D.iri?l:s,ce=[],he=fe[(D.scheme||O.scheme||"").toLowerCase()];if(he&&he.serialize&&he.serialize(O,D),O.host&&!q.IPV6ADDRESS.test(O.host)){if(D.domainHost||he&&he.domainHost)try{O.host=D.iri?Ie.toUnicode(O.host):Ie.toASCII(O.host.replace(q.PCT_ENCODED,oe).toLowerCase())}catch(bt){O.error=O.error||"Host's domain name can not be converted to "+(D.iri?"Unicode":"ASCII")+" via punycode: "+bt}}pe(O,q),D.reference!=="suffix"&&O.scheme&&(ce.push(O.scheme),ce.push(":"));var Oe=ke(O,D);if(Oe!==void 0&&(D.reference!=="suffix"&&ce.push("//"),ce.push(Oe),O.path&&O.path.charAt(0)!=="/"&&ce.push("/")),O.path!==void 0){var Je=O.path;!D.absolutePath&&(!he||!he.absolutePath)&&(Je=je(Je)),Oe===void 0&&(Je=Je.replace(/^\/\//,"/%2F")),ce.push(Je)}return O.query!==void 0&&(ce.push("?"),ce.push(O.query)),O.fragment!==void 0&&(ce.push("#"),ce.push(O.fragment)),ce.join("")}function Ce(O,D){var q=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},ce=arguments[3],he={};return ce||(O=Be(He(O,q),q),D=Be(He(D,q),q)),q=q||{},!q.tolerant&&D.scheme?(he.scheme=D.scheme,he.userinfo=D.userinfo,he.host=D.host,he.port=D.port,he.path=je(D.path||""),he.query=D.query):(D.userinfo!==void 0||D.host!==void 0||D.port!==void 0?(he.userinfo=D.userinfo,he.host=D.host,he.port=D.port,he.path=je(D.path||""),he.query=D.query):(D.path?(D.path.charAt(0)==="/"?he.path=je(D.path):((O.userinfo!==void 0||O.host!==void 0||O.port!==void 0)&&!O.path?he.path="/"+D.path:O.path?he.path=O.path.slice(0,O.path.lastIndexOf("/")+1)+D.path:he.path=D.path,he.path=je(he.path)),he.query=D.query):(he.path=O.path,D.query!==void 0?he.query=D.query:he.query=O.query),he.userinfo=O.userinfo,he.host=O.host,he.port=O.port),he.scheme=O.scheme),he.fragment=D.fragment,he}function Ze(O,D,q){var ce=a({scheme:"null"},q);return He(Ce(Be(O,ce),Be(D,ce),ce,!0),ce)}function Te(O,D){return typeof O=="string"?O=He(Be(O,D),D):r(O)==="object"&&(O=Be(He(O,D),D)),O}function E(O,D,q){return typeof O=="string"?O=He(Be(O,q),q):r(O)==="object"&&(O=He(O,q)),typeof D=="string"?D=He(Be(D,q),q):r(D)==="object"&&(D=He(D,q)),O===D}function H(O,D){return O&&O.toString().replace(!D||!D.iri?s.ESCAPE:l.ESCAPE,Ve)}function K(O,D){return O&&O.toString().replace(!D||!D.iri?s.PCT_ENCODED:l.PCT_ENCODED,oe)}var te={scheme:"http",domainHost:!0,parse:function(D,q){return D.host||(D.error=D.error||"HTTP URIs must have a host."),D},serialize:function(D,q){var ce=String(D.scheme).toLowerCase()==="https";return(D.port===(ce?443:80)||D.port==="")&&(D.port=void 0),D.path||(D.path="/"),D}},me={scheme:"https",domainHost:te.domainHost,parse:te.parse,serialize:te.serialize};function Re(O){return typeof O.secure=="boolean"?O.secure:String(O.scheme).toLowerCase()==="wss"}var Ee={scheme:"ws",domainHost:!0,parse:function(D,q){var ce=D;return ce.secure=Re(ce),ce.resourceName=(ce.path||"/")+(ce.query?"?"+ce.query:""),ce.path=void 0,ce.query=void 0,ce},serialize:function(D,q){if((D.port===(Re(D)?443:80)||D.port==="")&&(D.port=void 0),typeof D.secure=="boolean"&&(D.scheme=D.secure?"wss":"ws",D.secure=void 0),D.resourceName){var ce=D.resourceName.split("?"),he=c(ce,2),Oe=he[0],Je=he[1];D.path=Oe&&Oe!=="/"?Oe:void 0,D.query=Je,D.resourceName=void 0}return D.fragment=void 0,D}},nt={scheme:"wss",domainHost:Ee.domainHost,parse:Ee.parse,serialize:Ee.serialize},wt={},kt="[A-Za-z0-9\\-\\.\\_\\~\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]",yt="[0-9A-Fa-f]",Pt=I(I("%[EFef]"+yt+"%"+yt+yt+"%"+yt+yt)+"|"+I("%[89A-Fa-f]"+yt+"%"+yt+yt)+"|"+I("%"+yt+yt)),ge="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",z="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",J=n(z,'[\\"\\\\]'),be="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",Ke=new RegExp(kt,"g"),de=new RegExp(Pt,"g"),le=new RegExp(n("[^]",ge,"[\\.]",'[\\"]',J),"g"),ne=new RegExp(n("[^]",kt,be),"g"),re=ne;function Se(O){var D=oe(O);return D.match(Ke)?D:O}var Fe={scheme:"mailto",parse:function(D,q){var ce=D,he=ce.to=ce.path?ce.path.split(","):[];if(ce.path=void 0,ce.query){for(var Oe=!1,Je={},bt=ce.query.split("&"),Xt=0,Jt=bt.length;Xt=55296&&r<=56319&&I=g)throw new Error("Cannot access property/index "+n+" levels up, current level is "+g);return i[g-n]}if(n>g)throw new Error("Cannot access data "+n+" levels up, current level is "+g);if(r="data"+(g-n||""),!I)return r}for(var C=r,a=I.split("/"),A=0;A=0?{index:n,compiling:!0}:(n=this._compilations.length,this._compilations[n]={schema:e,root:g,baseId:i},{index:n,compiling:!1})}function D2g(e,g,i){var n=P$e.call(this,e,g,i);n>=0&&this._compilations.splice(n,1)}function P$e(e,g,i){for(var n=0;n%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,L$e=/^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i,U$e=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Q$e=/^(?:\/(?:[^~/]|~0|~1)*)*$/,j$e=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,$$e=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,q2g=N_;function N_(e){return e=e=="full"?"full":"fast",J2g.copy(N_[e])}N_.fast={date:/^\d\d\d\d-[0-1]\d-[0-3]\d$/,time:/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,"date-time":/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,"uri-template":J$e,url:L$e,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,hostname:O$e,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[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,"relative-json-pointer":$$e};N_.full={date:q$e,time:e8e,"date-time":gWg,uri:nWg,"uri-reference":$2g,"uri-template":J$e,url:L$e,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:O$e,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:t8e,uuid:U$e,"json-pointer":Q$e,"json-pointer-uri-fragment":j$e,"relative-json-pointer":$$e};function eWg(e){return e%4===0&&(e%100!==0||e%400===0)}function q$e(e){var g=e.match(L2g);if(!g)return!1;var i=+g[1],n=+g[2],I=+g[3];return n>=1&&n<=12&&I>=1&&I<=(n==2&&eWg(i)?29:U2g[n])}function e8e(e,g){var i=e.match(Q2g);if(!i)return!1;var n=i[1],I=i[2],r=i[3],o=i[5];return(n<=23&&I<=59&&r<=59||n==23&&I==59&&r==60)&&(!g||o)}var tWg=/t|\s/i;function gWg(e){var g=e.split(tWg);return g.length==2&&q$e(g[0])&&e8e(g[1],!0)}var iWg=/\/|:/;function nWg(e){return iWg.test(e)&&j2g.test(e)}var IWg=/[^\\]\\Z/;function t8e(e){if(IWg.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}var rWg=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.errSchemaPath+"/"+i,A=!g.opts.allErrors,s="data"+(o||""),l="valid"+r,c,u;if(C=="#"||C=="#/")g.isRoot?(c=g.async,u="validate"):(c=g.root.schema.$async===!0,u="root.refVal[0]");else{var d=g.resolveRef(g.baseId,C,g.isRoot);if(d===void 0){var h=g.MissingRefError.message(g.baseId,C);if(g.opts.missingRefs=="fail"){g.logger.error(h);var f=f||[];f.push(I),I="",g.createErrors!==!1?(I+=" { keyword: '$ref' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(a)+" , params: { ref: '"+g.util.escapeQuotes(C)+"' } ",g.opts.messages!==!1&&(I+=" , message: 'can\\'t resolve reference "+g.util.escapeQuotes(C)+"' "),g.opts.verbose&&(I+=" , schema: "+g.util.toQuotedString(C)+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+s+" "),I+=" } "):I+=" {} ";var m=I;I=f.pop(),!g.compositeRule&&A?g.async?I+=" throw new ValidationError(["+m+"]); ":I+=" validate.errors = ["+m+"]; return false; ":I+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",A&&(I+=" if (false) { ")}else if(g.opts.missingRefs=="ignore")g.logger.warn(h),A&&(I+=" if (true) { ");else throw new g.MissingRefError(g.baseId,C,h)}else if(d.inline){var b=g.util.copy(g);b.level++;var p="valid"+b.level;b.schema=d.schema,b.schemaPath="",b.errSchemaPath=C;var y=g.validate(b).replace(/validate\.schema/g,d.code);I+=" "+y+" ",A&&(I+=" if ("+p+") { ")}else c=d.$async===!0||g.async&&d.$async!==!1,u=d.code}if(u){var f=f||[];f.push(I),I="",g.opts.passContext?I+=" "+u+".call(this, ":I+=" "+u+"( ",I+=" "+s+", (dataPath || '')",g.errorPath!='""'&&(I+=" + "+g.errorPath);var Z=o?"data"+(o-1||""):"parentData",v=o?g.dataPathArr[o]:"parentDataProperty";I+=" , "+Z+" , "+v+", rootData) ";var G=I;if(I=f.pop(),c){if(!g.async)throw new Error("async schema referenced by sync schema");A&&(I+=" var "+l+"; "),I+=" try { await "+G+"; ",A&&(I+=" "+l+" = true; "),I+=" } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ",A&&(I+=" "+l+" = false; "),I+=" } ",A&&(I+=" if ("+l+") { ")}else I+=" if (!"+G+") { if (vErrors === null) vErrors = "+u+".errors; else vErrors = vErrors.concat("+u+".errors); errors = vErrors.length; } ",A&&(I+=" else { ")}return I},oWg=function(g,i,n){var I=" ",r=g.schema[i],o=g.schemaPath+g.util.getProperty(i),C=g.errSchemaPath+"/"+i,a=!g.opts.allErrors,A=g.util.copy(g),s="";A.level++;var l="valid"+A.level,c=A.baseId,u=!0,d=r;if(d)for(var h,f=-1,m=d.length-1;f0||h===!1:g.util.schemaHasRules(h,g.RULES.all))&&(u=!1,A.schema=h,A.schemaPath=o+"["+f+"]",A.errSchemaPath=C+"/"+f,I+=" "+g.validate(A)+" ",A.baseId=c,a&&(I+=" if ("+l+") { ",s+="}"));return a&&(u?I+=" if (true) { ":I+=" "+s.slice(0,-1)+" "),I},CWg=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c="valid"+r,u="errs__"+r,d=g.util.copy(g),h="";d.level++;var f="valid"+d.level,m=C.every(function(B){return g.opts.strictKeywords?typeof B=="object"&&Object.keys(B).length>0||B===!1:g.util.schemaHasRules(B,g.RULES.all)});if(m){var b=d.baseId;I+=" var "+u+" = errors; var "+c+" = false; ";var p=g.compositeRule;g.compositeRule=d.compositeRule=!0;var y=C;if(y)for(var Z,v=-1,G=y.length-1;v0||C===!1:g.util.schemaHasRules(C,g.RULES.all);if(I+="var "+u+" = errors;var "+c+";",Z){var v=g.compositeRule;g.compositeRule=d.compositeRule=!0,d.schema=C,d.schemaPath=a,d.errSchemaPath=A,I+=" var "+f+" = false; for (var "+m+" = 0; "+m+" < "+l+".length; "+m+"++) { ",d.errorPath=g.util.getPathExpr(g.errorPath,m,g.opts.jsonPointers,!0);var G=l+"["+m+"]";d.dataPathArr[b]=m;var B=g.validate(d);d.baseId=y,g.util.varOccurences(B,p)<2?I+=" "+g.util.varReplace(B,p,G)+" ":I+=" var "+p+" = "+G+"; "+B+" ",I+=" if ("+f+") break; } ",g.compositeRule=d.compositeRule=v,I+=" "+h+" if (!"+f+") {"}else I+=" if ("+l+".length == 0) {";var S=S||[];S.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'contains' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: {} ",g.opts.messages!==!1&&(I+=" , message: 'should contain a valid item' "),g.opts.verbose&&(I+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var R=I;return I=S.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+R+"]); ":I+=" validate.errors = ["+R+"]; return false; ":I+=" var err = "+R+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } else { ",Z&&(I+=" errors = "+u+"; if (vErrors !== null) { if ("+u+") vErrors.length = "+u+"; else vErrors = null; } "),g.opts.allErrors&&(I+=" } "),I},lWg=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c="errs__"+r,u=g.util.copy(g),d="";u.level++;var h="valid"+u.level,f={},m={},b=g.opts.ownProperties;for(v in C)if(v!="__proto__"){var p=C[v],y=Array.isArray(p)?m:f;y[v]=p}I+="var "+c+" = errors;";var Z=g.errorPath;I+="var missing"+r+";";for(var v in m)if(y=m[v],y.length){if(I+=" if ( "+l+g.util.getProperty(v)+" !== undefined ",b&&(I+=" && Object.prototype.hasOwnProperty.call("+l+", '"+g.util.escapeQuotes(v)+"') "),s){I+=" && ( ";var G=y;if(G)for(var B,S=-1,R=G.length-1;S0||p===!1:g.util.schemaHasRules(p,g.RULES.all))&&(I+=" "+h+" = true; if ( "+l+g.util.getProperty(v)+" !== undefined ",b&&(I+=" && Object.prototype.hasOwnProperty.call("+l+", '"+g.util.escapeQuotes(v)+"') "),I+=") { ",u.schema=p,u.schemaPath=a+g.util.getProperty(v),u.errSchemaPath=A+"/"+g.util.escapeFragment(v),I+=" "+g.validate(u)+" ",u.baseId=F,I+=" } ",s&&(I+=" if ("+h+") { ",d+="}"))}return s&&(I+=" "+d+" if ("+c+" == errors) {"),I},cWg=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c="valid"+r,u=g.opts.$data&&C&&C.$data;u&&(I+=" var schema"+r+" = "+g.util.getData(C.$data,o,g.dataPathArr)+"; ");var d="i"+r,h="schema"+r;u||(I+=" var "+h+" = validate.schema"+a+";"),I+="var "+c+";",u&&(I+=" if (schema"+r+" === undefined) "+c+" = true; else if (!Array.isArray(schema"+r+")) "+c+" = false; else {"),I+=""+c+" = false;for (var "+d+"=0; "+d+"<"+h+".length; "+d+"++) if (equal("+l+", "+h+"["+d+"])) { "+c+" = true; break; }",u&&(I+=" } "),I+=" if (!"+c+") { ";var f=f||[];f.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'enum' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { allowedValues: schema"+r+" } ",g.opts.messages!==!1&&(I+=" , message: 'should be equal to one of the allowed values' "),g.opts.verbose&&(I+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var m=I;return I=f.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+m+"]); ":I+=" validate.errors = ["+m+"]; return false; ":I+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" }",s&&(I+=" else { "),I},uWg=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||"");if(g.opts.format===!1)return s&&(I+=" if (true) { "),I;var c=g.opts.$data&&C&&C.$data,u;c?(I+=" var schema"+r+" = "+g.util.getData(C.$data,o,g.dataPathArr)+"; ",u="schema"+r):u=C;var d=g.opts.unknownFormats,h=Array.isArray(d);if(c){var f="format"+r,m="isObject"+r,b="formatType"+r;I+=" var "+f+" = formats["+u+"]; var "+m+" = typeof "+f+" == 'object' && !("+f+" instanceof RegExp) && "+f+".validate; var "+b+" = "+m+" && "+f+".type || 'string'; if ("+m+") { ",g.async&&(I+=" var async"+r+" = "+f+".async; "),I+=" "+f+" = "+f+".validate; } if ( ",c&&(I+=" ("+u+" !== undefined && typeof "+u+" != 'string') || "),I+=" (",d!="ignore"&&(I+=" ("+u+" && !"+f+" ",h&&(I+=" && self._opts.unknownFormats.indexOf("+u+") == -1 "),I+=") || "),I+=" ("+f+" && "+b+" == '"+n+"' && !(typeof "+f+" == 'function' ? ",g.async?I+=" (async"+r+" ? await "+f+"("+l+") : "+f+"("+l+")) ":I+=" "+f+"("+l+") ",I+=" : "+f+".test("+l+"))))) {"}else{var f=g.formats[C];if(!f){if(d=="ignore")return g.logger.warn('unknown format "'+C+'" ignored in schema at path "'+g.errSchemaPath+'"'),s&&(I+=" if (true) { "),I;if(h&&d.indexOf(C)>=0)return s&&(I+=" if (true) { "),I;throw new Error('unknown format "'+C+'" is used in schema at path "'+g.errSchemaPath+'"')}var m=typeof f=="object"&&!(f instanceof RegExp)&&f.validate,b=m&&f.type||"string";if(m){var p=f.async===!0;f=f.validate}if(b!=n)return s&&(I+=" if (true) { "),I;if(p){if(!g.async)throw new Error("async format in sync schema");var y="formats"+g.util.getProperty(C)+".validate";I+=" if (!(await "+y+"("+l+"))) { "}else{I+=" if (! ";var y="formats"+g.util.getProperty(C);m&&(y+=".validate"),typeof f=="function"?I+=" "+y+"("+l+") ":I+=" "+y+".test("+l+") ",I+=") { "}}var Z=Z||[];Z.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'format' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { format: ",c?I+=""+u:I+=""+g.util.toQuotedString(C),I+=" } ",g.opts.messages!==!1&&(I+=` , message: 'should match format "`,c?I+="' + "+u+" + '":I+=""+g.util.escapeQuotes(C),I+=`"' `),g.opts.verbose&&(I+=" , schema: ",c?I+="validate.schema"+a:I+=""+g.util.toQuotedString(C),I+=" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var v=I;return I=Z.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+v+"]); ":I+=" validate.errors = ["+v+"]; return false; ":I+=" var err = "+v+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } ",s&&(I+=" else { "),I},dWg=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c="valid"+r,u="errs__"+r,d=g.util.copy(g);d.level++;var h="valid"+d.level,f=g.schema.then,m=g.schema.else,b=f!==void 0&&(g.opts.strictKeywords?typeof f=="object"&&Object.keys(f).length>0||f===!1:g.util.schemaHasRules(f,g.RULES.all)),p=m!==void 0&&(g.opts.strictKeywords?typeof m=="object"&&Object.keys(m).length>0||m===!1:g.util.schemaHasRules(m,g.RULES.all)),y=d.baseId;if(b||p){var Z;d.createErrors=!1,d.schema=C,d.schemaPath=a,d.errSchemaPath=A,I+=" var "+u+" = errors; var "+c+" = true; ";var v=g.compositeRule;g.compositeRule=d.compositeRule=!0,I+=" "+g.validate(d)+" ",d.baseId=y,d.createErrors=!0,I+=" errors = "+u+"; if (vErrors !== null) { if ("+u+") vErrors.length = "+u+"; else vErrors = null; } ",g.compositeRule=d.compositeRule=v,b?(I+=" if ("+h+") { ",d.schema=g.schema.then,d.schemaPath=g.schemaPath+".then",d.errSchemaPath=g.errSchemaPath+"/then",I+=" "+g.validate(d)+" ",d.baseId=y,I+=" "+c+" = "+h+"; ",b&&p?(Z="ifClause"+r,I+=" var "+Z+" = 'then'; "):Z="'then'",I+=" } ",p&&(I+=" else { ")):I+=" if (!"+h+") { ",p&&(d.schema=g.schema.else,d.schemaPath=g.schemaPath+".else",d.errSchemaPath=g.errSchemaPath+"/else",I+=" "+g.validate(d)+" ",d.baseId=y,I+=" "+c+" = "+h+"; ",b&&p?(Z="ifClause"+r,I+=" var "+Z+" = 'else'; "):Z="'else'",I+=" } "),I+=" if (!"+c+") { var err = ",g.createErrors!==!1?(I+=" { keyword: 'if' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { failingKeyword: "+Z+" } ",g.opts.messages!==!1&&(I+=` , message: 'should match "' + `+Z+` + '" schema' `),g.opts.verbose&&(I+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ",I+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!g.compositeRule&&s&&(g.async?I+=" throw new ValidationError(vErrors); ":I+=" validate.errors = vErrors; return false; "),I+=" } ",s&&(I+=" else { ")}else s&&(I+=" if (true) { ");return I},hWg=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c="valid"+r,u="errs__"+r,d=g.util.copy(g),h="";d.level++;var f="valid"+d.level,m="i"+r,b=d.dataLevel=g.dataLevel+1,p="data"+b,y=g.baseId;if(I+="var "+u+" = errors;var "+c+";",Array.isArray(C)){var Z=g.schema.additionalItems;if(Z===!1){I+=" "+c+" = "+l+".length <= "+C.length+"; ";var v=A;A=g.errSchemaPath+"/additionalItems",I+=" if (!"+c+") { ";var G=G||[];G.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'additionalItems' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { limit: "+C.length+" } ",g.opts.messages!==!1&&(I+=" , message: 'should NOT have more than "+C.length+" items' "),g.opts.verbose&&(I+=" , schema: false , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var B=I;I=G.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+B+"]); ":I+=" validate.errors = ["+B+"]; return false; ":I+=" var err = "+B+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } ",A=v,s&&(h+="}",I+=" else { ")}var S=C;if(S){for(var R,w=-1,T=S.length-1;w0||R===!1:g.util.schemaHasRules(R,g.RULES.all)){I+=" "+f+" = true; if ("+l+".length > "+w+") { ";var W=l+"["+w+"]";d.schema=R,d.schemaPath=a+"["+w+"]",d.errSchemaPath=A+"/"+w,d.errorPath=g.util.getPathExpr(g.errorPath,w,g.opts.jsonPointers,!0),d.dataPathArr[b]=w;var V=g.validate(d);d.baseId=y,g.util.varOccurences(V,p)<2?I+=" "+g.util.varReplace(V,p,W)+" ":I+=" var "+p+" = "+W+"; "+V+" ",I+=" } ",s&&(I+=" if ("+f+") { ",h+="}")}}if(typeof Z=="object"&&(g.opts.strictKeywords?typeof Z=="object"&&Object.keys(Z).length>0||Z===!1:g.util.schemaHasRules(Z,g.RULES.all))){d.schema=Z,d.schemaPath=g.schemaPath+".additionalItems",d.errSchemaPath=g.errSchemaPath+"/additionalItems",I+=" "+f+" = true; if ("+l+".length > "+C.length+") { for (var "+m+" = "+C.length+"; "+m+" < "+l+".length; "+m+"++) { ",d.errorPath=g.util.getPathExpr(g.errorPath,m,g.opts.jsonPointers,!0);var W=l+"["+m+"]";d.dataPathArr[b]=m;var V=g.validate(d);d.baseId=y,g.util.varOccurences(V,p)<2?I+=" "+g.util.varReplace(V,p,W)+" ":I+=" var "+p+" = "+W+"; "+V+" ",s&&(I+=" if (!"+f+") break; "),I+=" } } ",s&&(I+=" if ("+f+") { ",h+="}")}}else if(g.opts.strictKeywords?typeof C=="object"&&Object.keys(C).length>0||C===!1:g.util.schemaHasRules(C,g.RULES.all)){d.schema=C,d.schemaPath=a,d.errSchemaPath=A,I+=" for (var "+m+" = 0; "+m+" < "+l+".length; "+m+"++) { ",d.errorPath=g.util.getPathExpr(g.errorPath,m,g.opts.jsonPointers,!0);var W=l+"["+m+"]";d.dataPathArr[b]=m;var V=g.validate(d);d.baseId=y,g.util.varOccurences(V,p)<2?I+=" "+g.util.varReplace(V,p,W)+" ":I+=" var "+p+" = "+W+"; "+V+" ",s&&(I+=" if (!"+f+") break; "),I+=" }"}return s&&(I+=" "+h+" if ("+u+" == errors) {"),I},tXe=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,y,l="data"+(o||""),c=g.opts.$data&&C&&C.$data,u;c?(I+=" var schema"+r+" = "+g.util.getData(C.$data,o,g.dataPathArr)+"; ",u="schema"+r):u=C;var d=i=="maximum",h=d?"exclusiveMaximum":"exclusiveMinimum",f=g.schema[h],m=g.opts.$data&&f&&f.$data,b=d?"<":">",p=d?">":"<",y=void 0;if(!(c||typeof C=="number"||C===void 0))throw new Error(i+" must be number");if(!(m||f===void 0||typeof f=="number"||typeof f=="boolean"))throw new Error(h+" must be number or boolean");if(m){var Z=g.util.getData(f.$data,o,g.dataPathArr),v="exclusive"+r,G="exclType"+r,B="exclIsNumber"+r,S="op"+r,R="' + "+S+" + '";I+=" var schemaExcl"+r+" = "+Z+"; ",Z="schemaExcl"+r,I+=" var "+v+"; var "+G+" = typeof "+Z+"; if ("+G+" != 'boolean' && "+G+" != 'undefined' && "+G+" != 'number') { ";var y=h,w=w||[];w.push(I),I="",g.createErrors!==!1?(I+=" { keyword: '"+(y||"_exclusiveLimit")+"' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: {} ",g.opts.messages!==!1&&(I+=" , message: '"+h+" should be boolean' "),g.opts.verbose&&(I+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var T=I;I=w.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+T+"]); ":I+=" validate.errors = ["+T+"]; return false; ":I+=" var err = "+T+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } else if ( ",c&&(I+=" ("+u+" !== undefined && typeof "+u+" != 'number') || "),I+=" "+G+" == 'number' ? ( ("+v+" = "+u+" === undefined || "+Z+" "+b+"= "+u+") ? "+l+" "+p+"= "+Z+" : "+l+" "+p+" "+u+" ) : ( ("+v+" = "+Z+" === true) ? "+l+" "+p+"= "+u+" : "+l+" "+p+" "+u+" ) || "+l+" !== "+l+") { var op"+r+" = "+v+" ? '"+b+"' : '"+b+"='; ",C===void 0&&(y=h,A=g.errSchemaPath+"/"+h,u=Z,c=m)}else{var B=typeof f=="number",R=b;if(B&&c){var S="'"+R+"'";I+=" if ( ",c&&(I+=" ("+u+" !== undefined && typeof "+u+" != 'number') || "),I+=" ( "+u+" === undefined || "+f+" "+b+"= "+u+" ? "+l+" "+p+"= "+f+" : "+l+" "+p+" "+u+" ) || "+l+" !== "+l+") { "}else{B&&C===void 0?(v=!0,y=h,A=g.errSchemaPath+"/"+h,u=f,p+="="):(B&&(u=Math[d?"min":"max"](f,C)),f===(B?u:!0)?(v=!0,y=h,A=g.errSchemaPath+"/"+h,p+="="):(v=!1,R+="="));var S="'"+R+"'";I+=" if ( ",c&&(I+=" ("+u+" !== undefined && typeof "+u+" != 'number') || "),I+=" "+l+" "+p+" "+u+" || "+l+" !== "+l+") { "}}y=y||i;var w=w||[];w.push(I),I="",g.createErrors!==!1?(I+=" { keyword: '"+(y||"_limit")+"' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { comparison: "+S+", limit: "+u+", exclusive: "+v+" } ",g.opts.messages!==!1&&(I+=" , message: 'should be "+R+" ",c?I+="' + "+u:I+=""+u+"'"),g.opts.verbose&&(I+=" , schema: ",c?I+="validate.schema"+a:I+=""+C,I+=" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var T=I;return I=w.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+T+"]); ":I+=" validate.errors = ["+T+"]; return false; ":I+=" var err = "+T+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } ",s&&(I+=" else { "),I},gXe=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,h,l="data"+(o||""),c=g.opts.$data&&C&&C.$data,u;if(c?(I+=" var schema"+r+" = "+g.util.getData(C.$data,o,g.dataPathArr)+"; ",u="schema"+r):u=C,!(c||typeof C=="number"))throw new Error(i+" must be number");var d=i=="maxItems"?">":"<";I+="if ( ",c&&(I+=" ("+u+" !== undefined && typeof "+u+" != 'number') || "),I+=" "+l+".length "+d+" "+u+") { ";var h=i,f=f||[];f.push(I),I="",g.createErrors!==!1?(I+=" { keyword: '"+(h||"_limitItems")+"' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { limit: "+u+" } ",g.opts.messages!==!1&&(I+=" , message: 'should NOT have ",i=="maxItems"?I+="more":I+="fewer",I+=" than ",c?I+="' + "+u+" + '":I+=""+C,I+=" items' "),g.opts.verbose&&(I+=" , schema: ",c?I+="validate.schema"+a:I+=""+C,I+=" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var m=I;return I=f.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+m+"]); ":I+=" validate.errors = ["+m+"]; return false; ":I+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+="} ",s&&(I+=" else { "),I},iXe=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,h,l="data"+(o||""),c=g.opts.$data&&C&&C.$data,u;if(c?(I+=" var schema"+r+" = "+g.util.getData(C.$data,o,g.dataPathArr)+"; ",u="schema"+r):u=C,!(c||typeof C=="number"))throw new Error(i+" must be number");var d=i=="maxLength"?">":"<";I+="if ( ",c&&(I+=" ("+u+" !== undefined && typeof "+u+" != 'number') || "),g.opts.unicode===!1?I+=" "+l+".length ":I+=" ucs2length("+l+") ",I+=" "+d+" "+u+") { ";var h=i,f=f||[];f.push(I),I="",g.createErrors!==!1?(I+=" { keyword: '"+(h||"_limitLength")+"' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { limit: "+u+" } ",g.opts.messages!==!1&&(I+=" , message: 'should NOT be ",i=="maxLength"?I+="longer":I+="shorter",I+=" than ",c?I+="' + "+u+" + '":I+=""+C,I+=" characters' "),g.opts.verbose&&(I+=" , schema: ",c?I+="validate.schema"+a:I+=""+C,I+=" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var m=I;return I=f.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+m+"]); ":I+=" validate.errors = ["+m+"]; return false; ":I+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+="} ",s&&(I+=" else { "),I},nXe=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,h,l="data"+(o||""),c=g.opts.$data&&C&&C.$data,u;if(c?(I+=" var schema"+r+" = "+g.util.getData(C.$data,o,g.dataPathArr)+"; ",u="schema"+r):u=C,!(c||typeof C=="number"))throw new Error(i+" must be number");var d=i=="maxProperties"?">":"<";I+="if ( ",c&&(I+=" ("+u+" !== undefined && typeof "+u+" != 'number') || "),I+=" Object.keys("+l+").length "+d+" "+u+") { ";var h=i,f=f||[];f.push(I),I="",g.createErrors!==!1?(I+=" { keyword: '"+(h||"_limitProperties")+"' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { limit: "+u+" } ",g.opts.messages!==!1&&(I+=" , message: 'should NOT have ",i=="maxProperties"?I+="more":I+="fewer",I+=" than ",c?I+="' + "+u+" + '":I+=""+C,I+=" properties' "),g.opts.verbose&&(I+=" , schema: ",c?I+="validate.schema"+a:I+=""+C,I+=" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var m=I;return I=f.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+m+"]); ":I+=" validate.errors = ["+m+"]; return false; ":I+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+="} ",s&&(I+=" else { "),I},fWg=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c=g.opts.$data&&C&&C.$data,u;if(c?(I+=" var schema"+r+" = "+g.util.getData(C.$data,o,g.dataPathArr)+"; ",u="schema"+r):u=C,!(c||typeof C=="number"))throw new Error(i+" must be number");I+="var division"+r+";if (",c&&(I+=" "+u+" !== undefined && ( typeof "+u+" != 'number' || "),I+=" (division"+r+" = "+l+" / "+u+", ",g.opts.multipleOfPrecision?I+=" Math.abs(Math.round(division"+r+") - division"+r+") > 1e-"+g.opts.multipleOfPrecision+" ":I+=" division"+r+" !== parseInt(division"+r+") ",I+=" ) ",c&&(I+=" ) "),I+=" ) { ";var d=d||[];d.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'multipleOf' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { multipleOf: "+u+" } ",g.opts.messages!==!1&&(I+=" , message: 'should be multiple of ",c?I+="' + "+u:I+=""+u+"'"),g.opts.verbose&&(I+=" , schema: ",c?I+="validate.schema"+a:I+=""+C,I+=" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var h=I;return I=d.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+h+"]); ":I+=" validate.errors = ["+h+"]; return false; ":I+=" var err = "+h+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+="} ",s&&(I+=" else { "),I},mWg=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c="errs__"+r,u=g.util.copy(g);u.level++;var d="valid"+u.level;if(g.opts.strictKeywords?typeof C=="object"&&Object.keys(C).length>0||C===!1:g.util.schemaHasRules(C,g.RULES.all)){u.schema=C,u.schemaPath=a,u.errSchemaPath=A,I+=" var "+c+" = errors; ";var h=g.compositeRule;g.compositeRule=u.compositeRule=!0,u.createErrors=!1;var f;u.opts.allErrors&&(f=u.opts.allErrors,u.opts.allErrors=!1),I+=" "+g.validate(u)+" ",u.createErrors=!0,f&&(u.opts.allErrors=f),g.compositeRule=u.compositeRule=h,I+=" if ("+d+") { ";var m=m||[];m.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'not' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: {} ",g.opts.messages!==!1&&(I+=" , message: 'should NOT be valid' "),g.opts.verbose&&(I+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var b=I;I=m.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+b+"]); ":I+=" validate.errors = ["+b+"]; return false; ":I+=" var err = "+b+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } else { errors = "+c+"; if (vErrors !== null) { if ("+c+") vErrors.length = "+c+"; else vErrors = null; } ",g.opts.allErrors&&(I+=" } ")}else I+=" var err = ",g.createErrors!==!1?(I+=" { keyword: 'not' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: {} ",g.opts.messages!==!1&&(I+=" , message: 'should NOT be valid' "),g.opts.verbose&&(I+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ",I+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s&&(I+=" if (false) { ");return I},pWg=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c="valid"+r,u="errs__"+r,d=g.util.copy(g),h="";d.level++;var f="valid"+d.level,m=d.baseId,b="prevValid"+r,p="passingSchemas"+r;I+="var "+u+" = errors , "+b+" = false , "+c+" = false , "+p+" = null; ";var y=g.compositeRule;g.compositeRule=d.compositeRule=!0;var Z=C;if(Z)for(var v,G=-1,B=Z.length-1;G0||v===!1:g.util.schemaHasRules(v,g.RULES.all))?(d.schema=v,d.schemaPath=a+"["+G+"]",d.errSchemaPath=A+"/"+G,I+=" "+g.validate(d)+" ",d.baseId=m):I+=" var "+f+" = true; ",G&&(I+=" if ("+f+" && "+b+") { "+c+" = false; "+p+" = ["+p+", "+G+"]; } else { ",h+="}"),I+=" if ("+f+") { "+c+" = "+b+" = true; "+p+" = "+G+"; }";return g.compositeRule=d.compositeRule=y,I+=""+h+"if (!"+c+") { var err = ",g.createErrors!==!1?(I+=" { keyword: 'oneOf' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { passingSchemas: "+p+" } ",g.opts.messages!==!1&&(I+=" , message: 'should match exactly one schema in oneOf' "),g.opts.verbose&&(I+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ",I+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!g.compositeRule&&s&&(g.async?I+=" throw new ValidationError(vErrors); ":I+=" validate.errors = vErrors; return false; "),I+="} else { errors = "+u+"; if (vErrors !== null) { if ("+u+") vErrors.length = "+u+"; else vErrors = null; }",g.opts.allErrors&&(I+=" } "),I},bWg=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c=g.opts.$data&&C&&C.$data,u;c?(I+=" var schema"+r+" = "+g.util.getData(C.$data,o,g.dataPathArr)+"; ",u="schema"+r):u=C;var d=c?"(new RegExp("+u+"))":g.usePattern(C);I+="if ( ",c&&(I+=" ("+u+" !== undefined && typeof "+u+" != 'string') || "),I+=" !"+d+".test("+l+") ) { ";var h=h||[];h.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'pattern' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { pattern: ",c?I+=""+u:I+=""+g.util.toQuotedString(C),I+=" } ",g.opts.messages!==!1&&(I+=` , message: 'should match pattern "`,c?I+="' + "+u+" + '":I+=""+g.util.escapeQuotes(C),I+=`"' `),g.opts.verbose&&(I+=" , schema: ",c?I+="validate.schema"+a:I+=""+g.util.toQuotedString(C),I+=" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var f=I;return I=h.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+f+"]); ":I+=" validate.errors = ["+f+"]; return false; ":I+=" var err = "+f+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+="} ",s&&(I+=" else { "),I},yWg=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c="errs__"+r,u=g.util.copy(g),d="";u.level++;var h="valid"+u.level,f="key"+r,m="idx"+r,b=u.dataLevel=g.dataLevel+1,p="data"+b,y="dataProperties"+r,Z=Object.keys(C||{}).filter(x),v=g.schema.patternProperties||{},G=Object.keys(v).filter(x),B=g.schema.additionalProperties,S=Z.length||G.length,R=B===!1,w=typeof B=="object"&&Object.keys(B).length,T=g.opts.removeAdditional,W=R||w||T,V=g.opts.ownProperties,X=g.baseId,N=g.schema.required;if(N&&!(g.opts.$data&&N.$data)&&N.length8)I+=" || validate.schema"+a+".hasOwnProperty("+f+") ";else{var M=Z;if(M)for(var F,$=-1,Q=M.length-1;$0||Pe===!1:g.util.schemaHasRules(Pe,g.RULES.all)){var it=g.util.getProperty(F),ye=l+it,lt=Ye&&Pe.default!==void 0;u.schema=Pe,u.schemaPath=a+it,u.errSchemaPath=A+"/"+g.util.escapeFragment(F),u.errorPath=g.util.getPath(g.errorPath,F,g.opts.jsonPointers),u.dataPathArr[b]=g.util.toQuotedString(F);var ue=g.validate(u);if(u.baseId=X,g.util.varOccurences(ue,p)<2){ue=g.util.varReplace(ue,p,ye);var je=ye}else{var je=p;I+=" var "+p+" = "+ye+"; "}if(lt)I+=" "+ue+" ";else{if(Y&&Y[F]){I+=" if ( "+je+" === undefined ",V&&(I+=" || ! Object.prototype.hasOwnProperty.call("+l+", '"+g.util.escapeQuotes(F)+"') "),I+=") { "+h+" = false; ";var fe=g.errorPath,oe=A,He=g.util.escapeQuotes(F);g.opts._errorDataPathProperty&&(g.errorPath=g.util.getPath(fe,F,g.opts.jsonPointers)),A=g.errSchemaPath+"/required";var pe=pe||[];pe.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'required' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { missingProperty: '"+He+"' } ",g.opts.messages!==!1&&(I+=" , message: '",g.opts._errorDataPathProperty?I+="is a required property":I+="should have required property \\'"+He+"\\'",I+="' "),g.opts.verbose&&(I+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var ae=I;I=pe.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+ae+"]); ":I+=" validate.errors = ["+ae+"]; return false; ":I+=" var err = "+ae+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",A=oe,g.errorPath=fe,I+=" } else { "}else s?(I+=" if ( "+je+" === undefined ",V&&(I+=" || ! Object.prototype.hasOwnProperty.call("+l+", '"+g.util.escapeQuotes(F)+"') "),I+=") { "+h+" = true; } else { "):(I+=" if ("+je+" !== undefined ",V&&(I+=" && Object.prototype.hasOwnProperty.call("+l+", '"+g.util.escapeQuotes(F)+"') "),I+=" ) { ");I+=" "+ue+" } "}}s&&(I+=" if ("+h+") { ",d+="}")}}if(G.length){var Ce=G;if(Ce)for(var j,Ze=-1,Te=Ce.length-1;Ze0||Pe===!1:g.util.schemaHasRules(Pe,g.RULES.all)){u.schema=Pe,u.schemaPath=g.schemaPath+".patternProperties"+g.util.getProperty(j),u.errSchemaPath=g.errSchemaPath+"/patternProperties/"+g.util.escapeFragment(j),V?I+=" "+y+" = "+y+" || Object.keys("+l+"); for (var "+m+"=0; "+m+"<"+y+".length; "+m+"++) { var "+f+" = "+y+"["+m+"]; ":I+=" for (var "+f+" in "+l+") { ",I+=" if ("+g.usePattern(j)+".test("+f+")) { ",u.errorPath=g.util.getPathExpr(g.errorPath,f,g.opts.jsonPointers);var ye=l+"["+f+"]";u.dataPathArr[b]=f;var ue=g.validate(u);u.baseId=X,g.util.varOccurences(ue,p)<2?I+=" "+g.util.varReplace(ue,p,ye)+" ":I+=" var "+p+" = "+ye+"; "+ue+" ",s&&(I+=" if (!"+h+") break; "),I+=" } ",s&&(I+=" else "+h+" = true; "),I+=" } ",s&&(I+=" if ("+h+") { ",d+="}")}}}return s&&(I+=" "+d+" if ("+c+" == errors) {"),I},ZWg=function(g,i,n){var I=" ",r=g.level,o=g.dataLevel,C=g.schema[i],a=g.schemaPath+g.util.getProperty(i),A=g.errSchemaPath+"/"+i,s=!g.opts.allErrors,l="data"+(o||""),c="errs__"+r,u=g.util.copy(g),d="";u.level++;var h="valid"+u.level;if(I+="var "+c+" = errors;",g.opts.strictKeywords?typeof C=="object"&&Object.keys(C).length>0||C===!1:g.util.schemaHasRules(C,g.RULES.all)){u.schema=C,u.schemaPath=a,u.errSchemaPath=A;var f="key"+r,m="idx"+r,b="i"+r,p="' + "+f+" + '",y=u.dataLevel=g.dataLevel+1,Z="data"+y,v="dataProperties"+r,G=g.opts.ownProperties,B=g.baseId;G&&(I+=" var "+v+" = undefined; "),G?I+=" "+v+" = "+v+" || Object.keys("+l+"); for (var "+m+"=0; "+m+"<"+v+".length; "+m+"++) { var "+f+" = "+v+"["+m+"]; ":I+=" for (var "+f+" in "+l+") { ",I+=" var startErrs"+r+" = errors; ";var S=f,R=g.compositeRule;g.compositeRule=u.compositeRule=!0;var w=g.validate(u);u.baseId=B,g.util.varOccurences(w,Z)<2?I+=" "+g.util.varReplace(w,Z,S)+" ":I+=" var "+Z+" = "+S+"; "+w+" ",g.compositeRule=u.compositeRule=R,I+=" if (!"+h+") { for (var "+b+"=startErrs"+r+"; "+b+"0||y===!1:g.util.schemaHasRules(y,g.RULES.all))||(h[h.length]=m)}}else var h=C;if(u||h.length){var Z=g.errorPath,v=u||h.length>=g.opts.loopRequired,G=g.opts.ownProperties;if(s)if(I+=" var missing"+r+"; ",v){u||(I+=" var "+d+" = validate.schema"+a+"; ");var B="i"+r,S="schema"+r+"["+B+"]",R="' + "+S+" + '";g.opts._errorDataPathProperty&&(g.errorPath=g.util.getPathExpr(Z,S,g.opts.jsonPointers)),I+=" var "+c+" = true; ",u&&(I+=" if (schema"+r+" === undefined) "+c+" = true; else if (!Array.isArray(schema"+r+")) "+c+" = false; else {"),I+=" for (var "+B+" = 0; "+B+" < "+d+".length; "+B+"++) { "+c+" = "+l+"["+d+"["+B+"]] !== undefined ",G&&(I+=" && Object.prototype.hasOwnProperty.call("+l+", "+d+"["+B+"]) "),I+="; if (!"+c+") break; } ",u&&(I+=" } "),I+=" if (!"+c+") { ";var w=w||[];w.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'required' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { missingProperty: '"+R+"' } ",g.opts.messages!==!1&&(I+=" , message: '",g.opts._errorDataPathProperty?I+="is a required property":I+="should have required property \\'"+R+"\\'",I+="' "),g.opts.verbose&&(I+=" , schema: validate.schema"+a+" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var T=I;I=w.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+T+"]); ":I+=" validate.errors = ["+T+"]; return false; ":I+=" var err = "+T+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } else { "}else{I+=" if ( ";var W=h;if(W)for(var V,B=-1,X=W.length-1;B 1) { ";var h=g.schema.items&&g.schema.items.type,f=Array.isArray(h);if(!h||h=="object"||h=="array"||f&&(h.indexOf("object")>=0||h.indexOf("array")>=0))I+=" outer: for (;i--;) { for (j = i; j--;) { if (equal("+l+"[i], "+l+"[j])) { "+c+" = false; break outer; } } } ";else{I+=" var itemIndices = {}, item; for (;i--;) { var item = "+l+"[i]; ";var m="checkDataType"+(f?"s":"");I+=" if ("+g.util[m](h,"item",g.opts.strictNumbers,!0)+") continue; ",f&&(I+=` if (typeof item == 'string') item = '"' + item; `),I+=" if (typeof itemIndices[item] == 'number') { "+c+" = false; j = itemIndices[item]; break; } itemIndices[item] = i; } "}I+=" } ",u&&(I+=" } "),I+=" if (!"+c+") { ";var b=b||[];b.push(I),I="",g.createErrors!==!1?(I+=" { keyword: 'uniqueItems' , dataPath: (dataPath || '') + "+g.errorPath+" , schemaPath: "+g.util.toQuotedString(A)+" , params: { i: i, j: j } ",g.opts.messages!==!1&&(I+=" , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' "),g.opts.verbose&&(I+=" , schema: ",u?I+="validate.schema"+a:I+=""+C,I+=" , parentSchema: validate.schema"+g.schemaPath+" , data: "+l+" "),I+=" } "):I+=" {} ";var p=I;I=b.pop(),!g.compositeRule&&s?g.async?I+=" throw new ValidationError(["+p+"]); ":I+=" validate.errors = ["+p+"]; return false; ":I+=" var err = "+p+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",I+=" } ",s&&(I+=" else { ")}else s&&(I+=" if (true) { ");return I},BWg={$ref:rWg,allOf:oWg,anyOf:CWg,$comment:aWg,const:sWg,contains:AWg,dependencies:lWg,enum:cWg,format:uWg,if:dWg,items:hWg,maximum:tXe,minimum:tXe,maxItems:gXe,minItems:gXe,maxLength:iXe,minLength:iXe,maxProperties:nXe,minProperties:nXe,multipleOf:fWg,not:mWg,oneOf:pWg,pattern:bWg,properties:yWg,propertyNames:ZWg,required:GWg,uniqueItems:vWg,validate:M$e},IXe=BWg,lj=oS.toHash,wWg=function(){var g=[{type:"number",rules:[{maximum:["exclusiveMaximum"]},{minimum:["exclusiveMinimum"]},"multipleOf","format"]},{type:"string",rules:["maxLength","minLength","pattern","format"]},{type:"array",rules:["maxItems","minItems","items","contains","uniqueItems"]},{type:"object",rules:["maxProperties","minProperties","required","dependencies","propertyNames",{properties:["additionalProperties","patternProperties"]}]},{rules:["$ref","const","enum","not","anyOf","oneOf","allOf","if"]}],i=["type","$comment"],n=["$schema","$id","id","$data","$async","title","description","default","definitions","examples","readOnly","writeOnly","contentMediaType","contentEncoding","additionalItems","then","else"],I=["number","integer","string","array","object","boolean","null"];return g.all=lj(i),g.types=lj(I),g.forEach(function(r){r.rules=r.rules.map(function(o){var C;if(typeof o=="object"){var a=Object.keys(o)[0];C=o[a],o=a,C.forEach(function(s){i.push(s),g.all[s]=!0})}i.push(o);var A=g.all[o]={keyword:o,code:IXe[o],implements:C};return A}),g.all.$comment={keyword:"$comment",code:IXe.$comment},r.type&&(g.types[r.type]=r)}),g.keywords=lj(i.concat(n)),g.custom={},g},rXe=["multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","additionalItems","maxItems","minItems","uniqueItems","maxProperties","minProperties","required","additionalProperties","enum","format","const"],SWg=function(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function KD(e){return KD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},KD(e)}let c8e=function(e){zXg(i,e);var g=PXg(i);function i(n){var I;return FXg(this,i),I=g.call(this,n),I.state={code:n.viewConfig,hide:!1,showLog:!1,logMsgs:I.getLogMsgs(n.viewConfig)},I.handleChangeBound=I.handleChange.bind(Ph(I)),I.handleKeyDownBound=I.handleKeyDown.bind(Ph(I)),I.handleKeyUpBound=I.handleKeyUp.bind(Ph(I)),I.handleSubmitBound=I.handleSubmit.bind(Ph(I)),I.hideBound=I.hide.bind(Ph(I)),I.showBound=I.show.bind(Ph(I)),I.toggleLogBound=I.toggleLog.bind(Ph(I)),I.pubSubs=[],I.pubSubs.push(I.props.pubSub.subscribe("keydown",I.handleKeyDownBound)),I.pubSubs.push(I.props.pubSub.subscribe("keyup",I.handleKeyUpBound)),I}return EXg(i,[{key:"componentDidMount",value:async function(){this.editor&&(this.editor._input.focus(),this.editor._input.setSelectionRange(0,0),await Eae(0),this.editorWrap&&(this.editorWrap.scrollTop=0))}},{key:"componentWillUnmount",value:function(){this.pubSubs.forEach(I=>this.props.pubSub.unsubscribe(I)),this.pubSubs=[]}},{key:"handleChange",value:function(I){const r=this.getLogMsgs(I);this.setState({code:I,logMsgs:r})}},{key:"handleKeyDown",value:function(I){I.key==="s"&&(I.ctrlKey||I.metaKey)&&(I.preventDefault(),this.props.onChange(this.state.code)),I.key==="Enter"&&(I.ctrlKey||I.metaKey)&&(I.preventDefault(),this.props.onChange(this.state.code),this.props.modal.close())}},{key:"handleKeyUp",value:function(I){this.setState({hide:!1}),I.key==="Escape"&&(I.preventDefault(),this.props.modal.close(),this.props.onCancel())}},{key:"handleSubmit",value:function(I){I&&I.preventDefault(),this.props.onSave(this.state.code)}},{key:"getLogMsgs",value:function(I){const r=[];let o;try{o=JSON.parse(I)}catch(A){return console.warn(A),r.push({type:"Error",msg:A.toString()}),r}const C=new A8e().compile(l8e);return C(o)||(console.warn("Invalid viewconf"),r.push({type:"Warning",msg:"Invalid viewconf"})),C.errors&&(console.warn(JSON.stringify(C.errors,null,2)),C.errors.forEach(A=>{r.push({type:"Warning",msg:JSON.stringify(A,null,2)})})),r.length===0&&r.push({type:"Success",msg:"No error or warnings"}),r}},{key:"hide",value:function(){this.setState({hide:!0})}},{key:"show",value:function(){this.setState({hide:!1})}},{key:"hideLog",value:function(){this.setState({showLog:!1})}},{key:"showLog",value:function(){this.setState({showLog:!0})}},{key:"toggleLog",value:function(){this.state.showLog?this.hideLog():this.showLog()}},{key:"render",value:function(){const I=this.state.logMsgs.map((r,o)=>{const C=`${o}-${r.msg}`;return k.createElement("tr",{key:C},k.createElement("td",{className:gi(Hp.title,Hp[r.type])},`[${o}] ${r.type}`),k.createElement("td",null,k.createElement("pre",null,r.msg)))});return k.createElement(aH,{cancelShortcut:"ESC",cancelTitle:"Discard Changes",hide:this.state.hide,maxHeight:!0,okayShortcut:"⌘+Enter",okayTitle:"Save and Close",onCancel:this.props.onCancel,onOkay:this.handleSubmitBound,title:"Edit View Config"},k.createElement(k.Fragment,null,k.createElement("header",{className:Hp["view-config-editor-header"]},k.createElement(fd,{onBlur:this.showBound,onMouseDown:this.hideBound,onMouseOut:this.showBound,onMouseUp:this.showBound},"Hide While Mousedown"),k.createElement(fd,{onClick:()=>{this.props.onChange(this.state.code)},shortcut:"⌘+S"},"Save")),k.createElement("div",{ref:r=>{this.editorWrap=r},className:Hp["view-config-editor"]},k.createElement(n2g,{ref:r=>{this.editor=r},highlight:r=>QWe.highlight(r,QWe.languages.json),onValueChange:this.handleChangeBound,padding:10,style:{fontFamily:'"Fira code", "Fira Mono", monospace',fontSize:"inherit"},value:this.state.code})),k.createElement("div",{className:Hp["view-config-log"],style:{height:this.state.showLog?"50%":"30px"}},k.createElement("div",{className:Hp["view-config-log-header"],onClick:()=>this.toggleLogBound()},`Log Messages (${this.state.logMsgs.filter(r=>r.type!=="Success").length})`),k.createElement("div",{className:Hp["view-config-log-msg"],style:{padding:this.state.showLog?"10px":0}},k.createElement("table",null,k.createElement("tbody",null,I))))))}}]),i}(k.Component);c8e.propTypes={modal:L.object.isRequired,onCancel:L.func.isRequired,onChange:L.func.isRequired,onSave:L.func.isRequired,pubSub:L.object.isRequired,viewConfig:L.string.isRequired};const JXg=L1(Z_(c8e));function LXg(e,g,i,n){const I=e.append("symbol").attr("id",g).attr("viewBox",n);i.forEach(r=>I.append("path").attr("d",r).attr("fill","currentColor"))}const UXg=e=>{e.setState(e.state)},QXg=function(g,i){const n=g;let I=[];const r=oP(),o=()=>{I.forEach(C=>i.unsubscribe(C)),I=[]};return{destroy:o,publish:r.publish,stack:r.stack,public:{get version(){return y4e},setBroadcastMousePositionGlobally(C=!1){n.setBroadcastMousePositionGlobally(C)},setShowGlobalMousePosition(C=!1){n.setShowGlobalMousePosition(C)},setGlobalMousePosition(C=!1){n.setBroadcastMousePositionGlobally(C),n.setShowGlobalMousePosition(C)},setAuthHeader(C){LX(C),n.reload()},getAuthHeader(){return LX()},getComponent(){return n},reload(C){let a;C?a=C.flatMap(A=>typeof A=="string"?n.iterateOverTracksInView(A):A):a=n.iterateOverTracks();for(const{viewId:A,trackId:s}of a){const l=n.getTrackObject(A,s);for(const c of l.childTracks||[l])c.fetchedTiles&&(c.removeTiles(Object.keys(c.fetchedTiles)),c.fetching.clear(),c.refreshTiles()),c.rerender(c.options,!0)}},destroy(){o(),_I.unmountComponentAtNode(n.topDiv.parentNode)},setRangeSelectionToInt(){n.setState({rangeSelectionToInt:!0})},setRangeSelectionToFloat(){n.setState({rangeSelectionToInt:!1})},setRangeSelection1dSize(C=0,a=1/0){n.setState({rangeSelection1dSize:[C,a]})},setViewConfig(C,a=!1){const A=n.processViewConfig(C);return new Promise(l=>{this.requestsInFlight=0,I.push(i.subscribe("requestSent",()=>{this.requestsInFlight+=1})),I.push(i.subscribe("requestReceived",()=>{this.requestsInFlight-=1,this.requestsInFlight===0&&l()})),n.setState({viewConfig:C,views:A},()=>{a&&l()})})},getViewConfig(){return n.getViewsAsJson()},validateViewConfig(C,{verbose:a=!1}={}){const A=new A8e().compile(l8e),s=A(C);return a&&A.errors&&console.warn(JSON.stringify(A.errors,null,2)),s},getMinMaxValue(C,a,A=!1,s=!1){return n.getMinMaxValue(C,a,A,s)},shareViewConfigAsLink(C){return n.handleExportViewsAsLink(C,!0)},showAvailableTrackPositions(C){n.setState({draggingHappening:C})},hideAvailableTrackPositions(){n.setState({draggingHappening:null})},showTrackChooser(C){n.setState({chooseTrackHandler:(...a)=>{n.setState({chooseTrackHandler:null}),C(...a)}})},hideTrackChooser(){this.setState({chooseTrackHandler:null})},setTrackValueScaleLimits(C,a,A,s){n.setTrackValueScaleLimits(C,a,A,s)},setDarkTheme(C){console.warn('`setDarkTheme(true)` is deprecated. Please use `setTheme("dark")`.');const a=C?"dark":"light";n.setTheme(a)},setTheme(C){console.warn("Please note that theming is still in beta!"),n.setTheme(C)},zoomTo(C,a,A,s,l,c=0){n.zoomTo(C,a,A,s,l,c)},zoomToGene(C,a,A=0,s=0){n.zoomToGene(C,a,A,s)},suggestGene(C,a,A){return n.suggestGene(C,a,A)},zoomToDataExtent(C){n.handleZoomToData(C)},resetViewport(C){n.resetViewport(C)},activateTool(C){switch(C){case"select":n.setMouseTool(Ja);break;default:n.setMouseTool(NF);break}},exportAsPngBlobPromise(){return n.createPNGBlobPromise()},exportAsSvg(){return n.createSVGString()},exportAsViewConfString(){return n.getViewsAsString()},getRangeSelection(){return n.rangeSelection},getLocation(C){const a=C?n.xScales[C]&&n.yScales[C]&&C:Object.values(n.tiledPlots)[0]&&Object.values(n.tiledPlots)[0].props.uid;return a?{xDomain:n.xScales[a].domain(),yDomain:n.yScales[a].domain(),xRange:n.xScales[a].range(),yRange:n.yScales[a].range()}:"Please provide a valid view UUID sweetheart 😙"},getTrackObject(C,a){let A=C,s=a;return a||(A=Object.values(n.state.views)[0].uid,s=C),Pae(n,A,s)},option(C,a){if(typeof a>"u")return n.props.options[C];switch(C){case"sizeMode":n.props.options[C]=a,UXg(n);break;default:console.warn(`This option "${C}" is either unknown or not settable.`)}},off(C,a,A){const s=typeof a=="object"?a.callback:a;switch(C){case"click":r.unsubscribe("click",s);break;case"cursorLocation":r.unsubscribe("cursorLocation",s);break;case"location":n.offLocationChange(A,a);break;case"mouseMoveZoom":r.unsubscribe("mouseMoveZoom",s);break;case"wheel":r.unsubscribe("wheel",s);break;case"rangeSelection":r.unsubscribe("rangeSelection",s);break;case"viewConfig":n.offViewChange(a);break;case"createSVG":n.offPostCreateSVG();break;case"geneSearch":r.unsubscribe("geneSearch",s);break}},on(C,a,A,s){switch(C){case"click":return r.subscribe("click",a);case"cursorLocation":return r.subscribe("cursorLocation",a);case"location":return n.onLocationChange(A,a,s);case"mouseMoveZoom":return r.subscribe("mouseMoveZoom",a);case"wheel":return r.subscribe("wheel",a);case"rangeSelection":return r.subscribe("rangeSelection",a);case"viewConfig":return n.onViewChange(a);case"createSVG":return n.onPostCreateSVG(a);case"geneSearch":return r.subscribe("geneSearch",a);default:return}}}}},jXg="_higlass_1uoq8_1",sG={higlass:jXg,"higlass-dark-theme":"_higlass-dark-theme_1uoq8_5","higlass-container-overflow":"_higlass-container-overflow_1uoq8_9","higlass-scroll-container-overflow":"_higlass-scroll-container-overflow_1uoq8_10","higlass-scroll-container-scroll":"_higlass-scroll-container-scroll_1uoq8_11","higlass-canvas":"_higlass-canvas_1uoq8_28","higlass-drawing-surface":"_higlass-drawing-surface_1uoq8_34","higlass-svg":"_higlass-svg_1uoq8_38","tiled-area":"_tiled-area_1uoq8_47","track-mouseover-menu":"_track-mouseover-menu_1uoq8_52"};function $Xg(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function sXe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function xD(e){return xD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},xD(e)}const AXe=12,r9g=12,o9g=20,C9g="default",lXe="bounded",cXe="overflow",xR="scroll";let CS=function(e){g9g(i,e);var g=i9g(i);function i(n){var I;$Xg(this,i),I=g.call(this,n),l_e(k.version)<15.6&&console.warn("HiGlass requires React v15.6 or higher. Current version: ",k.version),I.pubSub=oP(),I.domEvent=UPe(I.pubSub),I.pubSubs=[],I.minHorizontalHeight=20,I.minVerticalWidth=20,I.resizeSensor=null,I.uid=Ng.nice(),I.tiledPlots={},I.genomePositionSearchBoxes={},I.xScales={},I.yScales={},I.projectionXDomains={},I.projectionYDomains={},I.topDiv=null,I.zoomToDataExtentOnInit=new Set,I.viewTrackUidsToCombinedUid={},I.combinedUidToViewTrack={},I.scalesChangedListeners={},I.draggingChangedListeners={},I.valueScalesChangedListeners={},I.zoomLocks={},I.locationLocks={},I.locationLocksAxisWise={x:{},y:{}},I.valueScaleLocks={},I.prevAuthToken=n.options.authToken,I.setCenters={},I.plusImg={},I.configImg={},st.PIXI=n.options&&n.options.PIXI||TEe,I.viewMarginTop=+n.options.viewMarginTop>=0?+n.options.viewMarginTop:BV,I.viewMarginBottom=+n.options.viewMarginBottom>=0?+n.options.viewMarginBottom:BV,I.viewMarginLeft=+n.options.viewMarginLeft>=0?+n.options.viewMarginLeft:BV,I.viewMarginRight=+n.options.viewMarginRight>=0?+n.options.viewMarginRight:BV,I.viewPaddingTop=+n.options.viewPaddingTop>=0?+n.options.viewPaddingTop:wV,I.viewPaddingBottom=+n.options.viewPaddingBottom>=0?+n.options.viewPaddingBottom:wV,I.viewPaddingLeft=+n.options.viewPaddingLeft>=0?+n.options.viewPaddingLeft:wV,I.viewPaddingRight=+n.options.viewPaddingRight>=0?+n.options.viewPaddingRight:wV,I.genomePositionSearchBox=null,I.viewHeaders={},I.boundRefreshView=()=>{I.refreshView(SV)},I.unsetOnLocationChange=[],I.setTheme(n.options.theme,n.options.isDarkTheme),I.viewconfLoaded=!1;const{viewConfig:r}=I.props,o=I.loadIfRemoteViewConfig(I.props.viewConfig);n.options.authToken&&LX(n.options.authToken),I.pixiRoot=new st.PIXI.Container,I.pixiRoot.interactive=!0,I.pixiStage=new st.PIXI.Container,I.pixiStage.interactive=!0,I.pixiRoot.addChild(I.pixiStage),I.pixiMask=new st.PIXI.Graphics,I.pixiRoot.addChild(I.pixiMask),I.pixiStage.mask=I.pixiMask,I.element=null,I.scrollTop=0;let C=NF;if(I.props.options)switch(I.props.options.mouseTool){case Ja:C=Ja;break}I.props.options.pluginTracks&&(window.higlassTracksByType=Object.assign(window.higlassTracksByType||{},I.props.options.pluginTracks));const a={};try{window.higlassTracksByType&&Object.entries(window.higlassTracksByType).forEach(([h,f])=>{a[h]=f})}catch{console.warn("Broken config of a plugin track")}I.props.options.pluginDataFetchers&&(window.higlassDataFetchersByType=Object.assign(window.higlassDataFetchersByType||{},I.props.options.pluginDataFetchers));const A=window.higlassDataFetchersByType,s=I.props.options.pixelPreciseMarginPadding?1:30;I.mounted=!1,I.pluginTracks=a,I.pluginDataFetchers=A,I.state={currentBreakpoint:"lg",width:0,height:0,rowHeight:s,svgElement:null,canvasElement:null,customDialog:null,views:o,viewConfig:r,addTrackPositionMenuPosition:null,typedEditable:void 0,mouseOverOverlayUid:null,mouseTool:C,isDarkTheme:!1,rangeSelection1dSize:[0,1/0],rangeSelectionToInt:!1,modal:null},I.attachedToDOM=!1;const{public:l,destroy:c,publish:u,stack:d}=QXg(Hi(I),I.pubSub);return I.api=l,I.apiDestroy=c,I.apiPublish=u,I.apiStack=d,I.viewChangeListener=[],I.triggerViewChangeDb=Wae(I.triggerViewChange.bind(Hi(I)),250),I.pubSubs=[],I.rangeSelection=[null,null],I.prevMouseHoverTrack=null,I.zooming=!1,I.appClickHandlerBound=I.appClickHandler.bind(Hi(I)),I.canvasClickHandlerBound=I.canvasClickHandler.bind(Hi(I)),I.keyDownHandlerBound=I.keyDownHandler.bind(Hi(I)),I.keyUpHandlerBound=I.keyUpHandler.bind(Hi(I)),I.resizeHandlerBound=I.resizeHandler.bind(Hi(I)),I.resizeHandlerBound=I.resizeHandler.bind(Hi(I)),I.dispatchEventBound=I.dispatchEvent.bind(Hi(I)),I.animateOnMouseMoveHandlerBound=I.animateOnMouseMoveHandler.bind(Hi(I)),I.zoomStartHandlerBound=I.zoomStartHandler.bind(Hi(I)),I.zoomEndHandlerBound=I.zoomEndHandler.bind(Hi(I)),I.zoomHandlerBound=I.zoomHandler.bind(Hi(I)),I.trackDroppedHandlerBound=I.trackDroppedHandler.bind(Hi(I)),I.trackDimensionsModifiedHandlerBound=I.trackDimensionsModifiedHandler.bind(Hi(I)),I.animateBound=I.animate.bind(Hi(I)),I.animateOnGlobalEventBound=I.animateOnGlobalEvent.bind(Hi(I)),I.requestReceivedHandlerBound=I.requestReceivedHandler.bind(Hi(I)),I.wheelHandlerBound=I.wheelHandler.bind(Hi(I)),I.mouseMoveHandlerBound=I.mouseMoveHandler.bind(Hi(I)),I.onMouseLeaveHandlerBound=I.onMouseLeaveHandler.bind(Hi(I)),I.onBlurHandlerBound=I.onBlurHandler.bind(Hi(I)),I.openModalBound=I.openModal.bind(Hi(I)),I.closeModalBound=I.closeModal.bind(Hi(I)),I.handleEditViewConfigBound=I.handleEditViewConfig.bind(Hi(I)),I.onScrollHandlerBound=I.onScrollHandler.bind(Hi(I)),I.typedText="",I.typedTextTimeout=null,I.modal={open:I.openModalBound,close:I.closeModalBound},I.setBroadcastMousePositionGlobally(I.props.options.broadcastMousePositionGlobally||I.props.options.globalMousePosition),I.setShowGlobalMousePosition(I.props.options.showGlobalMousePosition||I.props.options.globalMousePosition),I}return qXg(i,[{key:"UNSAFE_componentWillMount",value:function(){this.domEvent.register("keydown",document),this.domEvent.register("keyup",document),this.domEvent.register("scroll",document),this.domEvent.register("resize",window),this.domEvent.register("orientationchange",window),this.domEvent.register("wheel",window),this.domEvent.register("mousedown",window,!0),this.domEvent.register("mouseup",window,!0),this.domEvent.register("click",window,!0),this.domEvent.register("mousemove",window),this.domEvent.register("touchmove",window),this.domEvent.register("touchstart",window),this.domEvent.register("touchend",window),this.domEvent.register("touchcancel",window),this.domEvent.register("blur",window),this.pubSubs.push(this.pubSub.subscribe("app.click",this.appClickHandlerBound),this.pubSub.subscribe("blur",this.onBlurHandlerBound),this.pubSub.subscribe("keydown",this.keyDownHandlerBound),this.pubSub.subscribe("keyup",this.keyUpHandlerBound),this.pubSub.subscribe("resize",this.resizeHandlerBound),this.pubSub.subscribe("wheel",this.wheelHandlerBound),this.pubSub.subscribe("orientationchange",this.resizeHandlerBound),this.pubSub.subscribe("app.event",this.dispatchEventBound),this.pubSub.subscribe("app.animateOnMouseMove",this.animateOnMouseMoveHandlerBound),this.pubSub.subscribe("trackDropped",this.trackDroppedHandlerBound),this.pubSub.subscribe("trackDimensionsModified",this.trackDimensionsModifiedHandlerBound),this.pubSub.subscribe("app.zoomStart",this.zoomStartHandlerBound),this.pubSub.subscribe("app.zoomEnd",this.zoomEndHandlerBound),this.pubSub.subscribe("app.zoom",this.zoomHandlerBound),this.pubSub.subscribe("requestReceived",this.requestReceivedHandlerBound)),this.props.getApi&&this.props.getApi(this.api)}},{key:"sizeMode",get:function(){return typeof this.props.options.sizeMode>"u"?this.props.options.bounded?"bounded":C9g:this.props.options.sizeMode}},{key:"setBroadcastMousePositionGlobally",value:function(I=!1){this.isBroadcastMousePositionGlobally=I}},{key:"setShowGlobalMousePosition",value:function(I=!1){if(this.isShowGlobalMousePosition=I,this.isShowGlobalMousePosition&&!this.globalMousePositionListener&&(this.globalMousePositionListener=M2.subscribe("higlass.mouseMove",this.animateOnGlobalEventBound),this.pubSubs.push(this.globalMousePositionListener)),this.isShowGlobalMousePosition&&!this.globalMousePositionListener){const r=this.pubSubs.findIndex(o=>o===this.globalMousePositionListener);M2.unsubscribe(this.globalMousePositionListener),r>=0&&this.pubSubs.splice(r,1),this.globalMousePositionListener=void 0}}},{key:"zoomStartHandler",value:function(){this.hideHoverMenu(),this.zooming=!0}},{key:"zoomEndHandler",value:function(){this.zooming=!1}},{key:"zoomHandler",value:function(I){I.sourceEvent&&this.mouseMoveHandler(I.sourceEvent)}},{key:"waitForDOMAttachment",value:function(I){if(!this.mounted)return;const r=_I.findDOMNode(this);document.body.contains(r)?I():requestAnimationFrame(()=>this.waitForDOMAttachment(I))}},{key:"componentDidMount",value:function(){this.mounted=!0,this.element=_I.findDOMNode(this),window.addEventListener("focus",this.boundRefreshView),Object.values(this.state.views).forEach(C=>{this.adjustLayoutToTrackSizes(C),C.layout?C.layout.i=C.uid:C.layout=this.generateViewLayout(C)});const I={width:this.state.width,height:this.state.height,view:this.canvasElement,antialias:!0,transparent:!0,resolution:2,autoResize:!0},r=parseInt(KFe[0],10);r===4?(console.warn("Deprecation warning: please update Pixi.js to version 5 or above!"),this.props.options.renderer==="canvas"?this.pixiRenderer=new st.PIXI.CanvasRenderer(I):this.pixiRenderer=new st.PIXI.WebGLRenderer(I)):(r<4&&console.warn("Deprecation warning: please update Pixi.js to version 5 or above! This version of Pixi.js is unsupported. Good luck 🤞"),this.props.options.renderer==="canvas"?this.pixiRenderer=new st.PIXI.CanvasRenderer(I):this.pixiRenderer=new st.PIXI.Renderer(I)),this.fitPixiToParentContainer(),this.setState({svgElement:this.svgElement,canvasElement:this.canvasElement}),this.waitForDOMAttachment(()=>{RF.ElementQueries.listen(),this.resizeSensor=new RF.ResizeSensor(this.element.parentNode,this.updateAfterResize.bind(this)),this.updateAfterResize()}),this.handleDragStart(),this.handleDragStop(),this.animate();const o=xg(this.element).append("svg").style("display","none");iEt.forEach(C=>LXg(o,C.id,C.paths,C.viewBox))}},{key:"getTrackObject",value:function(I,r){return this.tiledPlots[I].trackRenderer.getTrackObject(r)}},{key:"getTrackRenderer",value:function(I){return this.tiledPlots[I].trackRenderer}},{key:"loadIfRemoteViewConfig",value:function(I){let r={};return typeof I=="string"?Nt.json(I,(o,C)=>{I=C,this.setState({views:this.processViewConfig(JSON.parse(JSON.stringify(C))),viewConfig:C}),this.unsetOnLocationChange.forEach(({viewId:a,callback:A,callbackId:s})=>{this.onLocationChange(a,A,s)})},this.pubSub):(r=this.processViewConfig(JSON.parse(JSON.stringify(I))),this.mounted&&this.setState({viewConfig:I})),r}},{key:"UNSAFE_componentWillReceiveProps",value:function(I){const r=this.loadIfRemoteViewConfig(I.viewConfig);if(I.options.authToken!==this.prevAuthToken){LX(I.options.authToken);for(const o of this.iterateOverViews()){const C=this.getTrackRenderer(o),a=JSON.parse(C.prevTrackDefinitions);C.syncTrackObjects([]),C.syncTrackObjects(a)}this.prevAuthToken=I.options.authToken}for(const o of hi(r))this.adjustLayoutToTrackSizes(o);this.setState({views:r})}},{key:"UNSAFE_componentWillUpdate",value:function(){this.pixiRenderer.render(this.pixiRoot)}},{key:"componentDidUpdate",value:function(){this.setTheme(this.props.options.theme,this.props.options.isDarkTheme),this.animate(),this.triggerViewChangeDb()}},{key:"componentWillUnmount",value:function(){this.mounted=!1,this.pixiStage.destroy(!1),this.pixiStage=null,this.pixiRenderer.destroy(!0),this.pixiRenderer=null,window.removeEventListener("focus",this.boundRefreshView),this.resizeSensor&&this.resizeSensor.detach(),this.domEvent.unregister("keydown",document),this.domEvent.unregister("keyup",document),this.domEvent.unregister("scroll",document),this.domEvent.unregister("wheel",window),this.domEvent.unregister("mousedown",window),this.domEvent.unregister("mouseup",window),this.domEvent.unregister("click",window),this.domEvent.unregister("mousemove",window),this.domEvent.unregister("touchmove",window),this.domEvent.unregister("touchstart",window),this.domEvent.unregister("touchend",window),this.domEvent.unregister("touchcancel",window),this.pubSubs.forEach(I=>this.pubSub.unsubscribe(I)),this.pubSubs=[],this.apiDestroy()}},{key:"setTheme",value:function(I=this.props.options.theme,r=this.props.options.isDarkTheme){if(typeof r<"u")console.warn("The option `isDarkTheme` is deprecated. Please use `theme` instead."),this.theme=r?"dark":"light";else switch(I){case"dark":this.theme=ki;break;case"light":case void 0:this.theme=YF;break;default:console.warn(`Unknown theme "${I}". Using light theme.`),this.theme=YF;break}}},{key:"dispatchEvent",value:function(I){this.canvasElement&&FF(I,this.canvasElement)}},{key:"trackDroppedHandler",value:function(){this.setState({draggingHappening:null})}},{key:"requestReceivedHandler",value:function(){!this.viewconfLoaded&&JX===0&&(this.viewconfLoaded=!0,this.props.options.onViewConfLoaded&&this.props.options.onViewConfLoaded())}},{key:"animateOnMouseMoveHandler",value:function(I){I&&!this.animateOnMouseMove&&this.pubSubs.push(this.pubSub.subscribe("app.mouseMove",this.animateBound)),this.animateOnMouseMove=I}},{key:"fitPixiToParentContainer",value:function(){if(!this.element||!this.element.parentNode){console.warn("No parentNode:",this.element);return}const I=this.element.parentNode.clientWidth,r=this.element.parentNode.clientHeight;this.pixiMask.beginFill(16777215).drawRect(0,0,I,r).endFill(),this.pixiRenderer.resize(I,r),this.pixiRenderer.view.style.width=`${I}px`,this.pixiRenderer.view.style.height=`${r}px`,this.pixiRenderer.render(this.pixiRoot)}},{key:"addDefaultTrackOptions",value:function(I){const r=this.getTrackInfo(I.type);if(!r)return;typeof I.options>"u"&&(I.options={});const o=I.options?I.options:{};if(this.props.options.defaultTrackOptions){if(this.props.options.defaultTrackOptions.trackSpecific&&this.props.options.defaultTrackOptions.trackSpecific[I.type]){const C=this.props.options.defaultTrackOptions.trackSpecific[I.type];for(const a in C)I.options[a]=typeof I.options[a]<"u"?I.options[a]:JSON.parse(JSON.stringify(C[a]))}if(this.props.options.defaultTrackOptions.all){const C=this.props.options.defaultTrackOptions.all;for(const a in C)I.options[a]=typeof I.options[a]<"u"?I.options[a]:JSON.parse(JSON.stringify(C[a]))}}if(r.defaultOptions){const C=r.defaultOptionsByTheme&&r.defaultOptionsByTheme[this.theme]?r.defaultOptionsByTheme[this.theme]:{},a={...r.defaultOptions,...C};if(!I.options)I.options=JSON.parse(JSON.stringify(a));else for(const A in a)I.options[A]=typeof I.options[A]<"u"?I.options[A]:JSON.parse(JSON.stringify(a[A]))}else I.options=o}},{key:"toggleTypedEditable",value:function(){this.setState({typedEditable:!this.isEditable()})}},{key:"typedTextHandler",value:function(I){if(!this.props.options.cheatCodesEnabled)return;this.typedText=this.typedText.concat(I.key),this.typedText.endsWith("hgedit")&&(this.toggleTypedEditable(),this.typedText="");const r=750;this.typedTextTimeout&&clearTimeout(this.typedTextTimeout),this.typedTextTimeout=setTimeout(()=>{this.typedText=""},r)}},{key:"keyDownHandler",value:function(I){this.typedTextHandler(I),this.props.options.rangeSelectionOnAlt&&I.key==="Alt"&&this.setState({mouseTool:Ja})}},{key:"keyUpHandler",value:function(I){this.props.options.rangeSelectionOnAlt&&I.key==="Alt"&&this.setState({mouseTool:NF})}},{key:"openModal",value:function(I){this.setState({modal:k.cloneElement(I,{ref:r=>{this.modalRef=r}})})}},{key:"closeModal",value:function(){this.modalRef=null,this.setState({modal:null})}},{key:"handleEditViewConfig",value:function(){const{viewConfig:I}=this.state;this.setState({viewConfigTmp:I}),this.openModal(k.createElement(JXg,{onCancel:()=>{const{viewConfigTmp:r}=this.state,o=this.processViewConfig(r);for(const C of hi(o))this.adjustLayoutToTrackSizes(C);this.setState({views:o,viewConfig:r,viewConfigTmp:null})},onChange:r=>{const o=JSON.parse(r),C=this.processViewConfig(o);for(const a of hi(C))this.adjustLayoutToTrackSizes(a);this.setState({views:C,viewConfig:o})},onSave:r=>{const o=JSON.parse(r),C=this.processViewConfig(o);for(const a of hi(C))this.adjustLayoutToTrackSizes(a);this.setState({views:C,viewConfig:o,viewConfigTmp:null})},viewConfig:this.getViewsAsString()}))}},{key:"animate",value:function(){this.isRequestingAnimationFrame||(this.isRequestingAnimationFrame=!0,requestAnimationFrame(()=>{this.pixiRenderer&&(this.pixiRenderer.render(this.pixiRoot),this.isRequestingAnimationFrame=!1)}))}},{key:"animateOnGlobalEvent",value:function({sourceUid:I}={}){I!==this.uid&&this.animateOnMouseMove&&this.animate()}},{key:"measureSize",value:function(){const[I,r]=qPe(this.element);I>0&&r>0&&this.setState({sizeMeasured:!0,width:I,height:r})}},{key:"updateAfterResize",value:function(){this.measureSize(),this.updateRowHeight(),this.fitPixiToParentContainer(),this.refreshView(SV),this.resizeHandler()}},{key:"onBreakpointChange",value:function(I){this.setState({currentBreakpoint:I})}},{key:"handleOverlayMouseEnter",value:function(I){this.setState({mouseOverOverlayUid:I})}},{key:"handleOverlayMouseLeave",value:function(){this.setState({mouseOverOverlayUid:null})}},{key:"handleLockLocation",value:function(I){this.setState({chooseViewHandler:r=>this.handleLocationLockChosen(I,r),mouseOverOverlayUid:I})}},{key:"isEditable",value:function(){return this.state.typedEditable!==void 0?this.state.typedEditable:!this.props.options||!("editable"in this.props.options)?this.state.viewConfig.editable:this.props.options.editable&&this.state.viewConfig.editable}},{key:"isTrackMenuDisabled",value:function(){return this.props.options&&(this.props.options.editable===!1||this.props.options.tracksEditable===!1)?!0:this.state.viewConfig&&(this.state.viewConfig.tracksEditable===!1||this.state.viewConfig.editable===!1)}},{key:"isViewHeaderDisabled",value:function(){return this.props.options&&(this.props.options.editable===!1||this.props.options.viewEditable===!1)?!0:this.state.viewConfig&&(this.state.viewConfig.viewEditable===!1||this.state.viewConfig.editable===!1)}},{key:"iterateOverViews",value:function(){const I=[];for(const r in Object.keys(this.state.views))I.push(r);return I}},{key:"iterateOverTracksInView",value:function(I){const r=[],{tracks:o}=this.state.views[I];for(const C in o)for(const a of o[C])if(a.type==="combined"&&a.contents)for(const A of a.contents)r.push({viewId:I,trackId:A.uid,track:A});else r.push({viewId:I,trackId:a.uid,track:a});return r}},{key:"iterateOverTracks",value:function(){const I=[];for(const r in this.state.views){const{tracks:o}=this.state.views[r];for(const C in o)for(const a of o[C])if(a.type==="combined"&&a.contents)for(const A of a.contents)I.push({viewId:r,trackId:A.uid,track:A});else I.push({viewId:r,trackId:a.uid,track:a})}return I}},{key:"setMouseTool",value:function(I){this.setState({mouseTool:I})}},{key:"isValueScaleLocked",value:function(I,r){const o=this.combineViewAndTrackUid(I,r);return this.state.views[I]?!!this.valueScaleLocks[o]:!1}},{key:"getLockGroupExtrema",value:function(I,r){const o=this.combineViewAndTrackUid(I,r);if(!this.state.views[I]||!this.valueScaleLocks[o])return null;const C=this.valueScaleLocks[o],a=Object.values(C).filter(u=>this.tiledPlots[u.view]).map(u=>this.tiledPlots[u.view].trackRenderer.getTrackObject(u.track)).filter(u=>u).map(u=>u.originalTrack===void 0?u:u.originalTrack),A=a.filter(u=>u.minRawValue&&u.maxRawValue).map(u=>C.ignoreOffScreenValues?u.minVisibleValue(!0):u.minVisibleValueInTiles(!0)),s=a.filter(u=>u.minRawValue&&u.maxRawValue).map(u=>C.ignoreOffScreenValues?u.maxVisibleValue(!0):u.maxVisibleValueInTiles(!0));if(A.length===0||A.filter(u=>u===null||u===1/0).length>0||s.length===0||s.filter(u=>u===null||u===-1/0).length>0)return null;const l=Math.min(...A),c=Math.max(...s);return[l,c]}},{key:"syncValueScales",value:function(I,r){const o=this.combineViewAndTrackUid(I,r);if(!this.state.views[I])return;const C=ta(this.state.views[I].tracks,r);if(this.valueScaleLocks[o]){const a=this.valueScaleLocks[o],A=Object.values(a).filter(d=>this.tiledPlots[d.view]).map(d=>this.tiledPlots[d.view].trackRenderer.getTrackObject(d.track)).filter(d=>d).map(d=>d.originalTrack===void 0?d:d.originalTrack),s=this.getLockGroupExtrema(I,r);if(s===null)return;const l=s[0],c=s[1],u=1e-6;for(const d of A){if(d.minValue&&d.minValue(l),d.maxValue&&d.maxValue(c),!d.valueScale)continue;const h=Math.abs(d.minValue()-d.valueScale.domain()[0])>u||Math.abs(d.maxValue()-d.valueScale.domain()[1])>u,f=C.options&&d.options&&typeof C.options.scaleStartPercent<"u"&&typeof C.options.scaleEndPercent<"u"&&(Math.abs(d.options.scaleStartPercent-C.options.scaleStartPercent)>u||Math.abs(d.options.scaleEndPercent-C.options.scaleEndPercent)>u);d.continuousScaling&&!h&&!f||(d.valueScale.domain([l,c]),d.prevValueScale=d.valueScale.copy(),f&&(d.options.scaleStartPercent=C.options.scaleStartPercent,d.options.scaleEndPercent=C.options.scaleEndPercent),d.rerender(d.options,!0))}}}},{key:"handleNewTilesLoaded",value:function(I,r){this.animate()}},{key:"notifyDragChangedListeners",value:function(I){hi(this.draggingChangedListeners).forEach(r=>{hi(r).forEach(o=>o(I))})}},{key:"addDraggingChangedListener",value:function(I,r,o){this.draggingChangedListeners.hasOwnProperty(I)||(this.draggingChangedListeners[I]={}),this.draggingChangedListeners[I][r]=o,o(!0),o(!1)}},{key:"removeDraggingChangedListener",value:function(I,r){if(this.draggingChangedListeners.hasOwnProperty(I)){const o=this.draggingChangedListeners[I];o.hasOwnProperty(r)&&(o[r](!1),delete o[r])}}},{key:"addScalesChangedListener",value:function(I,r,o){this.scalesChangedListeners[I]||(this.scalesChangedListeners[I]={}),this.scalesChangedListeners[I][r]=o,!(!this.xScales[I]||!this.yScales[I])&&o(this.xScales[I],this.yScales[I])}},{key:"removeScalesChangedListener",value:function(I,r){if(this.scalesChangedListeners[I]){const o=this.scalesChangedListeners[I];o[r]&&delete o[r]}}},{key:"createSVG",value:function(){const I=document.createElement("svg");I.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),I.setAttribute("xmlns","http://www.w3.org/2000/svg"),I.setAttribute("version","1.1");for(const r of hi(this.tiledPlots))if(r){for(const o of hi(r.trackRenderer.trackDefObjects))if(o.trackObject.exportSVG){const C=o.trackObject.exportSVG();C&&I.appendChild(C[0])}}return I.setAttribute("width",this.canvasElement.style.width),I.setAttribute("height",this.canvasElement.style.height),this.postCreateSVGCallback?this.postCreateSVGCallback(I):I}},{key:"createSVGString",value:function(){const I=this.createSVG();let r=d5t.xml(new window.XMLSerializer().serializeToString(I));return r=r.replace(/ + +${r}`}},{key:"handleExportSVG",value:function(){z2("export.svg",new Blob([this.createSVGString()],{type:"image/svg+xml"}))}},{key:"offPostCreateSVG",value:function(){this.postCreateSVGCallback=null}},{key:"onPostCreateSVG",value:function(I){this.postCreateSVGCallback=I}},{key:"createPNGBlobPromise",value:function(){return new Promise(I=>{const r=this.createSVGString(),o=new Image(this.canvasElement.width,this.canvasElement.height);o.src=`data:image/svg+xml;base64,${btoa(r)}`,o.onload=()=>{const C=document.createElement("canvas");C.width=this.canvasElement.width/2,C.height=this.canvasElement.height/2,C.getContext("2d").drawImage(o,0,0),C.toBlob(a=>{I(a)})}})}},{key:"handleExportPNG",value:function(){this.createPNGBlobPromise().then(I=>{z2("export.png",I)})}},{key:"handleScalesChanged",value:function(I,r,o,C=!0){if(this.xScales[I]=r,this.yScales[I]=o,C&&I in this.scalesChangedListeners&&hi(this.scalesChangedListeners[I]).forEach(a=>{a(r,o)}),this.zoomLocks[I]){const a=this.zoomLocks[I],A=Ea(a),[s,l,c]=AI(this.xScales[I],this.yScales[I]);for(let u=0;u{G(Z,v)})}}if(this.locationLocks[I]){const a=this.locationLocks[I],A=Ea(a),[s,l,c]=AI(this.xScales[I],this.yScales[I]);for(let u=0;u{S(G,B)})}}if(this.locationLocksAxisWise.x[I]){const a=this.locationLocksAxisWise.x[I].lock,A=Ea(a),s=this.locationLocksAxisWise.x[I].axis!=="x",[l,c,u]=AI(this.xScales[I],this.yScales[I]);for(let d=0;d{B(v,G)})}}if(this.locationLocksAxisWise.y[I]){const a=this.locationLocksAxisWise.y[I].lock,A=Ea(a),s=this.locationLocksAxisWise.y[I].axis!=="y",[l,c,u]=AI(this.xScales[I],this.yScales[I]);for(let d=0;d{B(v,G)})}}this.animate(),this.triggerViewChangeDb()}},{key:"handleProjectViewport",value:function(I){this.setState({chooseTrackHandler:(r,o)=>this.handleViewportProjected(I,r,o)})}},{key:"handleZoomToData",value:function(I){if(I&&!this.tiledPlots[I])throw new Error(`View uid ${I} does not exist in the current viewConfig`);I?this.tiledPlots[I].handleZoomToData():Object.values(this.tiledPlots).forEach(r=>r.handleZoomToData())}},{key:"resetViewport",value:function(I){if(I&&!this.tiledPlots[I])throw new Error(`View uid ${I} does not exist in the current viewConfig`);I?this.tiledPlots[I].resetViewport():Object.values(this.tiledPlots).forEach(r=>r.resetViewport())}},{key:"handleYankFunction",value:function(I,r){this.setState({chooseViewHandler:o=>r(I,o),mouseOverOverlayUid:I})}},{key:"handleUnlock",value:function(I,r){const o=r[I],C=Ya(o);if(C.length===2){delete r[C[0]],delete r[C[1]];return}r[I]&&r[I][I]&&delete r[I][I],r[I]&&delete r[I]}},{key:"viewScalesLockData",value:function(I){return!this.xScales[I]||!this.yScales[I]?(console.warn("View scale lock doesn't correspond to existing uid: ",I),null):AI(this.xScales[I],this.yScales[I])}},{key:"addLock",value:function(I,r,o,C){let a=[],A=[];o[I]?a=Ea(o[I]).filter(c=>C(c[0])).map(c=>[c[0],C(c[0])]):a=[[I,C.bind(this)(I)]],o[r]?A=Ea(o[r]).filter(c=>C.bind(this)(c[0])).map(c=>[c[0],C.bind(this)(c[0])]):A=[[r,C.bind(this)(r)]];const s=a.concat(A),l=_Pe(s);s.forEach(c=>{o[c[0]]=l})}},{key:"handleLocationLockChosen",value:function(I,r){if(I===r){this.setState({chooseViewHandler:null});return}this.addLock(I,r,this.locationLocks,this.viewScalesLockData.bind(this)),this.setState({chooseViewHandler:null})}},{key:"handleZoomLockChosen",value:function(I,r){if(I===r){this.setState({chooseViewHandler:null});return}this.addLock(I,r,this.zoomLocks,this.viewScalesLockData.bind(this)),this.setState({chooseViewHandler:null})}},{key:"handleViewportProjected",value:function(I,r,o){let C=null;if(I===r)console.warn("A view can not show its own viewport.");else{const a=ta(this.state.views[r].tracks,o),A=P2(this.state.views[r].tracks,o);C=Ng.nice();const l={uid:C,type:`viewport-projection-${{top:"horizontal",bottom:"horizontal",center:"center",left:"vertical",right:"vertical"}[A]}`,fromViewUid:I};this.addCallbacks(r,l),this.handleTrackAdded(r,l,A,a)}return this.setState({chooseTrackHandler:null}),C}},{key:"handleLocationYanked",value:function(I,r){const o=this.xScales[r],C=this.yScales[r],a=this.xScales[I],A=this.yScales[I],[s,l,c]=AI(a,A),[u,d,h]=AI(o,C);this.setCenters[I](u,d,c,!0),this.setState({chooseViewHandler:null})}},{key:"handleZoomYanked",value:function(I,r){const o=this.xScales[r],C=this.yScales[r],a=this.xScales[I],A=this.yScales[I],[s,l,c]=AI(a,A),[u,d,h]=AI(o,C);this.setCenters[I](s,l,h,!0),this.setState({chooseViewHandler:null})}},{key:"handleTrackPositionChosen",value:function(I,r){this.setState({addTrackPosition:r,addTrackPositionView:I})}},{key:"updateRowHeight",value:function(){if(!this.props.options||this.sizeMode!==lXe||this.props.options.pixelPreciseMarginPadding)return;const I=this.element.parentNode.clientHeight;let r=0;for(const l of hi(this.state.views))r=Math.max(r,l.layout.y+l.layout.h);this.handleDragStart(),this.handleDragStop();const C=(this.isEditable()?10:0)*r-1,A=(I-C)/r,s=Math.floor(A);this.setState({rowHeight:s})}},{key:"handleLayoutChange",value:function(I){this.element&&(I.forEach(r=>{const o=this.state.views[r.i];o&&(o.layout.x=r.x,o.layout.y=r.y,o.layout.w=r.w,o.layout.h=r.h,o.layout.i=r.i)}),this.updateRowHeight(),this.refreshView(SV))}},{key:"clearDragTimeout",value:function(){this.dragTimeout&&(clearTimeout(this.dragTimeout),this.dragTimeout=null)}},{key:"getTrackInfo",value:function(I){if(wi[I])return wi[I];if(this.pluginTracks&&this.pluginTracks[I])return this.pluginTracks[I].config;if(window.higlassTracksByType&&window.higlassTracksByType[I])return window.higlassTracksByType[I].config;console.warn("Track type not found:",I,"(check app/scripts/config/ for a list of defined track types)")}},{key:"forceRefreshView",value:function(){this.setState(this.state)}},{key:"refreshView",value:function(I=NPe){this.clearDragTimeout(),this.notifyDragChangedListeners(!0),this.clearDragTimeout(),this.dragTimeout=setTimeout(()=>{this.notifyDragChangedListeners(!1)},I)}},{key:"handleDragStart",value:function(){this.clearDragTimeout(),this.notifyDragChangedListeners(!0)}},{key:"handleDragStop",value:function(){this.clearDragTimeout(),this.dragTimeout=setTimeout(()=>{this.notifyDragChangedListeners(!1)},SV)}},{key:"resizeHandler",value:function(){cP(this.viewHeaders).filter(I=>I).forEach(I=>I.checkWidth())}},{key:"calculateViewDimensions",value:function(I){let A=this.viewMarginTop+this.viewMarginBottom+this.viewPaddingTop+this.viewPaddingBottom,s=this.viewMarginLeft+this.viewMarginRight+this.viewPaddingLeft+this.viewPaddingRight,l=0;l+=10;const c=20;if(I.tracks.top)for(let v=0;v0||I.tracks.right&&I.tracks.right.length>0||I.tracks.center&&I.tracks.center.length>0)&&(l+=c);let u=0;if(I.tracks.left)for(let v=0;v0){if(!I.tracks.center[0].contents||I.tracks.center[0].contents.length>0){let v=null,G=null;if(I.tracks.center[0].contents)for(const B of I.tracks.center[0].contents)v=Math.max(v,B.height?B.height:100),G=Math.max(G,B.width?B.width:100);else v=I.tracks.center[0].height?I.tracks.center[0].height:100,G=I.tracks.center[0].width?I.tracks.center[0].width:100;A+=v,s+=G}}else(I.tracks.top&&hi(I.tracks.top).length>1||I.tracks.bottom&&hi(I.tracks.bottom).length>1)&&(I.tracks.left&&hi(I.tracks.left).length||I.tracks.right&&hi(I.tracks.right).length)&&(m=100,f=100);h>f?A+=h:A+=f;let b=0,p=0,y=0,Z=0;return"top"in I.tracks&&(b=I.tracks.top.map(v=>v.height?v.height:20).reduce((v,G)=>v+G,0)),"bottom"in I.tracks&&(p=I.tracks.bottom.map(v=>v.height?v.height:20).reduce((v,G)=>v+G,0)),"left"in I.tracks&&(y=I.tracks.left.map(v=>v.width?v.width:0).reduce((v,G)=>v+G,0)),"right"in I.tracks&&(Z=I.tracks.right.map(v=>v.width?v.width:0).reduce((v,G)=>v+G,0)),{totalWidth:s,totalHeight:A,topHeight:b,bottomHeight:p,leftWidth:y,rightWidth:Z,centerWidth:m,centerHeight:f,minNecessaryHeight:l}}},{key:"calculateZoomLimits",value:function(I,r){const o=[0,1/0],C=I.zoomLimits||[1,null],a=r[1]-r[0];if(C.length!==2)return o;if(C[0]!==null&&C[0]>0){const A=a/C[0];o[1]=Math.max(A,1),A<1&&console.warn(`Invalid zoom limits. Lower limit set to ${a}`)}if(C[1]!==null&&C[1]>C[0]){const A=a/C[1];o[0]=Math.min(A,1),A>1&&console.warn(`Invalid zoom limits. Upper limit set to ${a}`)}return o}},{key:"generateViewLayout",value:function(I){let r=null;return"layout"in I?{layout:r}=I.layout:r={x:0,y:0,w:AXe,h:r9g},r}},{key:"handleClearView",value:function(I){const{views:r}=this.state;r[I].tracks.top=[],r[I].tracks.bottom=[],r[I].tracks.center=[],r[I].tracks.left=[],r[I].tracks.right=[],r[I].tracks.whole=[],this.setState({views:r})}},{key:"handleCloseView",value:function(I){hi(this.state.views).length!==1&&(this.handleUnlock(I,this.zoomLocks),this.setState(r=>(delete r.views[I],{views:this.removeInvalidTracks(r.views)})))}},{key:"handleSeriesAdded",value:function(I,r,o,C){const{tracks:a}=this.state.views[I];if(C.type==="combined")C.contents.push(r),r.type==="heatmap"&&this.compatibilityfyStackedHeatmaps(r,C);else{const A={type:"combined",uid:Ng.nice(),height:C.height,width:C.width,contents:[C,r]},s=a[o];for(let l=0;l({views:A.views}))}},{key:"handleNoTrackAdded",value:function(){this.state.addTrackPosition&&this.setState({addTrackPosition:null})}},{key:"handleTracksAdded",value:function(I,r,o,C){this.storeTrackSizes(I);for(const a of r)this.handleTrackAdded(I,a,o,C)}},{key:"handleChangeTrackType",value:function(I,r,o){const C=this.state.views[I],a=ta(C.tracks,r),A=a.uid;a.uid=Ng.nice(),a.type=o;const s=a.uid;this.updateTrackLocks(I,A,s),this.setState(l=>({views:l.views}))}},{key:"handleChangeTrackData",value:function(I,r,o){const C=this.state.views[I],a=ta(C.tracks,r);a.uid=Ng.nice(),a.data=o,this.setState(A=>({views:A.views}))}},{key:"handleTrackAdded",value:function(I,r,o,C=null){if(this.addDefaultTrackOptions(r),r.uid||(r.uid=Ng.nice()),r.contents)for(const l of r.contents)this.addDefaultTrackOptions(l);if(this.state.addTrackPosition&&this.setState({addTrackPosition:null}),C)return this.handleSeriesAdded(I,r,o,C),null;r.position=o;const a=this.getTrackInfo(r.type);r.width=a.defaultWidth||a.defaultOptions&&a.defaultOptions.minWidth||this.minVerticalWidth,r.height=a.defaultHeight||a.defaultOptions&&a.defaultOptions.minHeight||this.minHorizontalHeight;const{tracks:A}=this.state.views[I];let s=0;if(ku(A,()=>s++),o==="left"||o==="top")A[o].unshift(r);else if(o==="center")if(A.center.length===0){const l={uid:Ng.nice(),type:"combined",contents:[r]};A.center=[l]}else if(A.center[0].type==="combined")A.center[0].contents.push(r),r.type==="heatmap"&&this.compatibilityfyStackedHeatmaps(r,A.center[0]);else{const l={uid:Ng.nice(),type:"combined",contents:[A.center[0],r]};A.center=[l],r.type==="heatmap"&&this.compatibilityfyStackedHeatmaps(r,l)}else A[o]||(A[o]=[]),A[o].push(r);return this.adjustLayoutToTrackSizes(this.state.views[I]),Object.keys(this.state.views).length===1&&s===0&&(this.handleZoomToData(I),this.zoomToDataExtentOnInit.add(I)),r}},{key:"compatibilityfyStackedHeatmaps",value:function(I,r){let o;r.contents.some(a=>(o=a,a.type==="heatmap"))&&(I.options.backgroundColor="transparent",I.options.showTooltip=o.options.showTooltip,I.options.showMousePosition=o.options.showMousePosition,I.options.mousePositionColor=o.options.mousePositionColor)}},{key:"storeTrackSizes",value:function(I){ku(this.state.views[I].tracks,r=>{const o=this.tiledPlots[I].trackRenderer.getTrackObject(r.uid);o&&([r.width,r.height]=o.dimensions)})}},{key:"adjustLayoutToTrackSizes",value:function(I){if(!I.layout)return;const r=this.isEditable();let o=0;r&&(o+=o9g);const{totalHeight:C}=this.calculateViewDimensions(I);o+=C;const a=this.isEditable()?10:0;o+=a;const A=this.state.rowHeight+a;this.sizeMode!==lXe&&(I.layout.h=Math.ceil(o/A))}},{key:"handleCloseTrack",value:function(I,r){const{tracks:o}=this.state.views[I];this.handleUnlockValueScale(I,r);for(const C in o){const a=o[C],A=a.filter(s=>s.uid!==r);A.length===a.length?A.filter(l=>l.type==="combined").forEach(l=>{l.contents=l.contents.filter(c=>c.uid!==r)}):o[C]=A}return this.storeTrackSizes(I),this.adjustLayoutToTrackSizes(this.state.views[I]),this.setState(C=>({views:C.views})),this.state.views}},{key:"handleLockValueScale",value:function(I,r){this.setState({chooseTrackHandler:(o,C)=>this.handleValueScaleLocked(I,r,o,C)})}},{key:"combineViewAndTrackUid",value:function(I,r){const o=`${I}.${r}`;if(this.combinedUidToViewTrack[o]={view:I,track:r},this.viewTrackUidsToCombinedUid[I]){if(this.viewTrackUidsToCombinedUid[r])return this.viewTrackUidsToCombinedUid[I][r];this.viewTrackUidsToCombinedUid[I][r]=o}else this.viewTrackUidsToCombinedUid[I]={},this.viewTrackUidsToCombinedUid[I][r]=o;return o}},{key:"updateTrackLocks",value:function(I,r,o){const C=this.combineViewAndTrackUid(I,r),a=this.combineViewAndTrackUid(I,o);if(this.valueScaleLocks[C]){const A=this.valueScaleLocks[C];this.valueScaleLocks[a]=A,delete this.valueScaleLocks[C]}for(const A in this.valueScaleLocks)if(this.valueScaleLocks[A][C]){const s=this.valueScaleLocks[A][C];this.valueScaleLocks[A][a]=s,s.track=o,delete this.valueScaleLocks[A][C]}}},{key:"handleUnlockValueScale",value:function(I,r){if(this.tiledPlots[I].trackRenderer.getTrackObject(r).createdTracks){const o=Ya(this.tiledPlots[I].trackRenderer.getTrackObject(r).createdTracks);for(const C of o)this.handleUnlock(this.combineViewAndTrackUid(I,C),this.valueScaleLocks)}else this.handleUnlock(this.combineViewAndTrackUid(I,r),this.valueScaleLocks)}},{key:"handleValueScaleLocked",value:function(I,r,o,C){if(this.tiledPlots[I].trackRenderer.getTrackObject(r).createdTracks){const s=Ya(this.tiledPlots[I].trackRenderer.getTrackObject(r).createdTracks);for(const l of s)this.handleValueScaleLocked(I,l,o,C);return}if(this.tiledPlots[o].trackRenderer.getTrackObject(C).createdTracks){const s=Ya(this.tiledPlots[o].trackRenderer.getTrackObject(C).createdTracks);for(const l of s)this.handleValueScaleLocked(I,r,o,l);return}const a=this.combineViewAndTrackUid(I,r),A=this.combineViewAndTrackUid(o,C);this.addLock(a,A,this.valueScaleLocks,s=>this.combinedUidToViewTrack[s]),this.syncValueScales(I,r),this.setState({chooseTrackHandler:null})}},{key:"addCallbacks",value:function(I,r){const o=this.getTrackInfo(r.type);if(r.type==="viewport-projection-center"||r.type==="viewport-projection-horizontal"||r.type==="viewport-projection-vertical"||o&&o.projection){const C=r.fromViewUid;r.registerViewportChanged=(a,A)=>this.addScalesChangedListener(C,a,A),r.removeViewportChanged=a=>this.removeScalesChangedListener(C,a),r.setDomainsCallback=(a,A)=>{if(!C){this.projectionXDomains[I]||(this.projectionXDomains[I]={}),this.projectionYDomains[I]||(this.projectionYDomains[I]={}),(r.type==="viewport-projection-horizontal"||r.type==="viewport-projection-center")&&(this.projectionXDomains[I][r.uid]=a),(r.type==="viewport-projection-vertical"||r.type==="viewport-projection-center")&&(this.projectionYDomains[I][r.uid]=A),this.triggerViewChangeDb();return}const s=bg().domain(a).range(this.xScales[C].range()),l=bg().domain(A).range(this.yScales[C].range()),[c,u,d]=AI(s,l);this.setCenters[C](c,u,d,!1);let h=!1,f=!1;I in this.zoomLocks&&(h=C in this.zoomLocks[I]),h&&this.handleUnlock(I,this.zoomLocks),I in this.locationLocks&&(f=C in this.locationLocks[I]),f&&this.handleUnlock(I,this.locationLocks),this.handleScalesChanged(C,s,l,!0),h&&this.addLock(I,C,this.zoomLocks,this.viewScalesLockData),f&&this.addLock(I,C,this.locationLocks,this.viewScalesLockData)}}}},{key:"validateLocks",value:function(I){const r=[];for(const o of Ya(I))(!I[o]||!I[o][o])&&r.push(o);for(const o of r)I[o]&&(console.warn(`View ${o} not present in lock group. Removing...`),this.handleUnlock(o,I),delete I[o])}},{key:"deserializeLocationLocks",value:function(I){if(this.locationLocks={},I.locationLocks)for(const r of Ya(I.locationLocks.locksByViewUid))if(typeof I.locationLocks.locksByViewUid[r]!="object")this.locationLocks[r]=I.locationLocks.locksDict[I.locationLocks.locksByViewUid[r]];else{if("x"in I.locationLocks.locksByViewUid[r]){const o=I.locationLocks.locksDict[I.locationLocks.locksByViewUid[r].x.lock];this.locationLocksAxisWise.x[r]={lock:o,axis:I.locationLocks.locksByViewUid[r].x.axis}}if("y"in I.locationLocks.locksByViewUid[r]){const o=I.locationLocks.locksDict[I.locationLocks.locksByViewUid[r].y.lock];this.locationLocksAxisWise.y[r]={lock:o,axis:I.locationLocks.locksByViewUid[r].y.axis}}}this.validateLocks(this.locationLocks)}},{key:"deserializeZoomLocks",value:function(I){if(this.zoomLocks={},I.zoomLocks)for(const r of Ya(I.zoomLocks.locksByViewUid))this.zoomLocks[r]=I.zoomLocks.locksDict[I.zoomLocks.locksByViewUid[r]];this.validateLocks(this.zoomLocks)}},{key:"deserializeValueScaleLocks",value:function(I){if(this.valueScaleLocks={},I.valueScaleLocks)for(const r of Ya(I.valueScaleLocks.locksByViewUid))this.valueScaleLocks[r]=I.valueScaleLocks.locksDict[I.valueScaleLocks.locksByViewUid[r]]}},{key:"serializeLocks",value:function(I){const r={},o={};for(const C of Ya(I)){let a=I[C]&&I[C].uid;a||(a=Ng.nice()),I[C].uid=a,r[a]=I[C],o[C]=I[C].uid}return{locksByViewUid:o,locksDict:r}}},{key:"getViewsAsJson",value:function(){const I=JSON.parse(JSON.stringify(this.state.viewConfig));return I.views=Object.values(this.state.views).map(r=>{const o=JSON.parse(JSON.stringify(r));return ku(o.tracks,C=>{if(C.server){const a=V5t(C.server,{});if(!a.hostname.length){const A=window.location.host,{protocol:s}=window.location,l=`${s}//${A}${a.pathname}`;C.server=l}}(C.type==="viewport-projection-center"||C.type==="viewport-projection-horizontal")&&this.projectionXDomains[r.uid]&&this.projectionXDomains[r.uid][C.uid]&&(C.projectionXDomain=this.projectionXDomains[r.uid][C.uid]),(C.type==="viewport-projection-center"||C.type==="viewport-projection-vertical")&&this.projectionYDomains[r.uid]&&this.projectionYDomains[r.uid][C.uid]&&(C.projectionYDomain=this.projectionYDomains[r.uid][C.uid]),delete C.name,delete C.position,delete C.header,delete C.description,delete C.created,delete C.project,delete C.project_name,delete C.serverUidKey,delete C.uuid,delete C.private,delete C.maxZoom,delete C.coordSystem,delete C.coordSystem2,delete C.datatype,delete C.maxWidth,delete C.datafile,delete C.binsPerDimension,delete C.resolutions,delete C.aggregationModes}),o.uid=r.uid,o.initialXDomain=this.xScales[r.uid].domain(),o.initialYDomain=this.yScales[r.uid].domain(),delete o.layout.i,o}),I.zoomLocks=this.serializeLocks(this.zoomLocks),I.locationLocks=this.serializeLocks(this.locationLocks),I.valueScaleLocks=this.serializeLocks(this.valueScaleLocks),I}},{key:"getViewsAsString",value:function(){return JSON.stringify(this.getViewsAsJson(),null,2)}},{key:"handleExportViewAsJSON",value:function(){const I=this.getViewsAsString();z2("viewconf.json",I)}},{key:"handleExportViewsAsLink",value:function(I=this.state.viewConfig.exportViewUrl,r=!1){const o=new URL(I,window.location.origin),C=fetch(I,{method:"POST",headers:{Accept:"application/json, text/plain, */*","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},body:`{"viewconf":${this.getViewsAsString()}}`,credentials:"same-origin"}).then(a=>{if(!a.ok)throw a;return a.json()}).catch(a=>{console.warn("err:",a)}).then(a=>({id:a.uid,url:`${o.origin}/l/?d=${a.uid}`}));return r||C.then(a=>{this.openModal(k.createElement(Gle,{onDone:()=>{this.closeModalBound()},url:a.url}))}).catch(a=>console.error("Exporting view config as link failed:",a)),C}},{key:"handleDataDomainChanged",value:function(I,r,o){const{views:C}=this.state;if(C[I].initialXDomain=r,C[I].initialYDomain=o,this.xScales[I]=bg().domain(r),this.yScales[I]=bg().domain(o),this.zoomLocks[I]){const a=this.zoomLocks[I],A=Ea(a);for(let s=0;sAXe)return!1;const s=hi(this.state.views);for(let l=0;lc&&ru)return!1}return!0}},{key:"handleAddView",value:function(I){const r=hi(this.state.views),o=I,C=[];I.layout.w===12&&(I.layout.w=6);for(let s=0;s{const c=s[1]-l[1];return c===0?s[0]-l[0]:c});const a=JSON.stringify(o),A=JSON.parse(a);A.initialXDomain=this.xScales[A.uid].domain(),A.initialYDomain=this.yScales[A.uid].domain(),[[A.layout.x,A.layout.y]]=C,A.uid=Ng.nice(),A.layout.i=A.uid,ku(A.tracks,s=>{this.addCallbacks(A.uid,s)}),this.setState(s=>{const l=JSON.parse(JSON.stringify(s.views));return l[A.uid]=A,{views:l}})}},{key:"handleSelectedAssemblyChanged",value:function(I,r,o,C){const{views:a}=this.state;a[I].genomePositionSearchBox.chromInfoId=r,a[I].genomePositionSearchBox.autocompleteId=o,a[I].genomePositionSearchBox.autocompleteServer=C}},{key:"createGenomePostionSearchBoxEntry",value:function(I,r){let o=I;const C={autocompleteServer:pq,chromInfoServer:pq,visible:!1};return o||(o=JSON.parse(JSON.stringify(C))),o.autocompleteServer||(o.autocompleteServer=C.autocompleteServer),o.chromInfoId||(o.chromInfoId=r),o.chromInfoServer||(o.chromInfoServer=C.chromInfoServer),o.visible||(o.visible=!1),o}},{key:"handleTogglePositionSearchBox",value:function(I){const r=this.state.views[I];r.genomePositionSearchBoxVisible=!r.genomePositionSearchBoxVisible;const o={};ku(r.tracks,A=>{A.coordSystem&&(o[A.coordSystem]||(o[A.coordSystem]=0),o[A.coordSystem]+=1)});const C=Ea(o).sort((A,s)=>s[1]-A[1]);let a="hg19";C.length&&(a=C[0][0]),r.genomePositionSearchBox=this.createGenomePostionSearchBoxEntry(r.genomePositionSearchBox,a),r.genomePositionSearchBox.visible=!r.genomePositionSearchBox.visible,this.refreshView(),this.setState({configMenuUid:null})}},{key:"handleTrackOptionsChanged",value:function(I,r,o){const C=this.state.views[I],a=ta(C.tracks,r);a&&(a.options=Object.assign(a.options,o),this.mounted&&(this.setState(A=>({views:A.views})),this.adjustSplitHeatmapTrackOptions(a,o,C.tracks,I)))}},{key:"adjustSplitHeatmapTrackOptions",value:function(I,r,o,C){I.type==="heatmap"&&(r.extent==="upper-right"&&o.center[0].type==="combined"&&o.center[0].contents.length>1&&o.center[0].contents.some(a=>{if(a.type==="heatmap"&&a.uid!==I.uid&&a.options.extent!=="lower-left"){const A={...a.options,extent:"lower-left",labelPosition:"bottomLeft",colorbarPosition:"bottomLeft"},s={...r,labelPosition:"topRight",colorbarPosition:"topRight"};return this.handleTrackOptionsChanged(C,a.uid,A),this.handleTrackOptionsChanged(C,I.uid,s),!0}return!1}),r.extent==="lower-left"&&r.extent==="lower-left"&&o.center[0].type==="combined"&&o.center[0].contents.length>1&&o.center[0].contents.some(a=>{if(a.type==="heatmap"&&a.uid!==I.uid&&a.options.extent!=="upper-right"){const A={...a.options,extent:"upper-right",labelPosition:"topRight",colorbarPosition:"topRight"},s={...r,labelPosition:"bottomLeft",colorbarPosition:"bottomLeft"};return this.handleTrackOptionsChanged(C,a.uid,A),this.handleTrackOptionsChanged(C,I.uid,s),!0}return!1}))}},{key:"handleViewOptionsChanged",value:function(I,r){const o=this.state.views[I];o&&(o.options=Object.assign(o.options||{},r),this.mounted&&this.setState(C=>({views:C.views})))}},{key:"isTrackValid",value:function(I,r){return!(I.type==="viewport-projection-center"&&!r.has(I.fromViewUid))}},{key:"removeInvalidTracks",value:function(I){const r=new Set(Ya(I));for(const o of hi(I))for(const C of["left","top","center","right","bottom"])o.tracks&&o.tracks.hasOwnProperty(C)&&(o.tracks[C]=o.tracks[C].filter(a=>this.isTrackValid(a,r)),o.tracks[C].forEach(a=>{a.type==="combined"&&(a.contents=a.contents.filter(A=>this.isTrackValid(A,r)))}));return I}},{key:"processViewConfig",value:function(I){let{views:r}=I,o={};return(!I.views||I.views.length===0)&&(console.warn("No views provided in viewConfig"),r=[{editable:!0,tracks:{}}]),r.forEach(C=>{C.tracks&&OPe(C.tracks),C.uid||(C.uid=Ng.nice()),o[C.uid]=C,this.zoomToDataExtentOnInit.has(C.uid)&&this.zoomToDataExtentOnInit.delete(C.uid),C.initialXDomain?(C.initialXDomain[0]=+C.initialXDomain[0],C.initialXDomain[1]=+C.initialXDomain[1]):(C.initialXDomain=[0,100],this.zoomToDataExtentOnInit.add(C.uid)),C.initialYDomain?(C.initialXDomain[0]=+C.initialXDomain[0],C.initialXDomain[1]=+C.initialXDomain[1]):C.initialYDomain=[C.initialXDomain[0],C.initialXDomain[1]],this.xScales[C.uid]||(this.xScales[C.uid]=bg().domain(C.initialXDomain)),this.yScales[C.uid]||(this.yScales[C.uid]=bg().domain(C.initialYDomain)),ku(C.tracks,a=>{if(a.uid||(a.uid=Ng.nice()),this.addCallbacks(C.uid,a),this.addDefaultTrackOptions(a),a.contents)for(const A of a.contents)this.addDefaultTrackOptions(A)}),C.layout?C.layout.i=C.uid:C.layout=this.generateViewLayout(C)}),this.deserializeZoomLocks(I),this.deserializeLocationLocks(I),this.deserializeValueScaleLocks(I),o=this.removeInvalidTracks(o),o}},{key:"handleWindowFocused",value:function(){}},{key:"rangeSelectionHandler",value:function(I){this.rangeSelection=I,this.apiPublish("rangeSelection",I)}},{key:"offViewChange",value:function(I){this.viewChangeListener.splice(I,1)}},{key:"onViewChange",value:function(I){return this.viewChangeListener.push(I)-1}},{key:"triggerViewChange",value:function(){this.viewChangeListener.forEach(I=>I(this.getViewsAsString()))}},{key:"getGenomeLocation",value:function(I){return Nae.get(this.state.views[I].chromInfoPath).then(r=>c_e(this.xScales[I],this.yScales[I],r))}},{key:"offLocationChange",value:function(I,r){this.removeScalesChangedListener(I,r)}},{key:"zoomTo",value:function(I,r,o,C,a,A){if(!(I in this.setCenters))throw Error(`Invalid viewUid. Current uuids: ${Object.keys(this.setCenters).join(",")}`);if(Number.isNaN(+r)||Number.isNaN(+o)){const u=[r,o].join(", ");console.warn([`Invalid coordinates (${u}). All coordinates need to be numbers + and should represent absolute coordinates (not chromosome + coordinates).`].join(" "));return}(Number.isNaN(+C)||Number.isNaN(+a)||C===null||a===null)&&(C=r,a=o);const[s,l,c]=AI(this.xScales[I].copy().domain([r,o]),this.yScales[I].copy().domain([C,a]));this.setCenters[I](s,l,c,!1,A)}},{key:"zoomToGene",value:function(I,r,o,C){if(!(I in this.setCenters))throw Error(`Invalid viewUid. Current uuids: ${Object.keys(this.setCenters).join(",")}`);if(!this.state.views[I].genomePositionSearchBox||!this.state.views[I].genomePositionSearchBox.autocompleteServer||!this.state.views[I].genomePositionSearchBox.autocompleteId||!this.state.views[I].chromInfoPath){console.warn("Please set chromInfoPath, autocompleteServer, and autocompleteId to use the zoomToGene API");return}this.suggestGene(I,r,a=>{if(a){const A=a.find(s=>s.geneName.toLowerCase()===r.toLowerCase());if(A){const{chr:s,txStart:l,txEnd:c}=A;Fd(this.state.views[I].chromInfoPath,u=>{const d=u.chrToAbs([s,l])-o,h=u.chrToAbs([s,c])+o,[f,m,b]=AI(this.xScales[I].copy().domain([d,h]),this.yScales[I].copy().domain([d,h]));this.setCenters[I](f,m,b,!1,C)},this.pubSub)}else console.warn(`Couldn't find the gene symbol: ${r}`)}})}},{key:"suggestGene",value:function(I,r,o){if(!(I in this.setCenters))throw Error(`Invalid viewUid. Current uuids: ${Object.keys(this.setCenters).join(",")}`);if(!this.state.views[I].genomePositionSearchBox||!this.state.views[I].genomePositionSearchBox.autocompleteServer||!this.state.views[I].genomePositionSearchBox.autocompleteId){console.warn("Please set autocompleteServer and autocompleteId to use the suggestGene API");return}const C=this.state.views[I].genomePositionSearchBox.autocompleteServer,a=this.state.views[I].genomePositionSearchBox.autocompleteId,A=`${C}/suggest/?d=${a}&ac=${r.toLowerCase()}`;Nt.json(A,GA,this.pubSub).then(s=>{o(s)}).catch(s=>console.error(s))}},{key:"onLocationChange",value:function(I,r,o){const C=Object.keys(this.state.views);if(!C.length)return this.unsetOnLocationChange.push({viewId:I,callback:r,callbackId:o}),null;if(I=typeof I>"u"&&C.length===1?C[0]:I,typeof I>"u"||C.indexOf(I)===-1)return console.error("onLocationChange either missing a viewId or passed an invalid viewId: ",I),null;const a=this.state.views[I],A=(l,c)=>{r({xDomain:l.domain(),yDomain:c.domain(),xRange:l.range(),yRange:c.range()})};let s=1;return this.scalesChangedListeners[a.uid]&&(s=Object.keys(this.scalesChangedListeners[a.uid]).filter(l=>l.indexOf(RV)===0).map(l=>parseInt(l.slice(RV.length+1),10)).reduce((l,c)=>Math.max(l,c),0)+1),this.addScalesChangedListener(a.uid,`${RV}.${s}`,A),o&&o(`${RV}.${s}`),s}},{key:"getTiledPlotAtPosition",value:function(I,r){let o;const C=hi(this.state.views);for(let a=0;a=c&&I<=d,f=r>=l&&r<=u;if(h&&f){o=A;break}}return o}},{key:"mouseMoveHandler",value:function(I){if(!this.topDiv||this.state.modal)return;const r=I.clientX,o=I.clientY,C=mi(I,this.topDiv);C[1]+=this.scrollTop;const a=this.getTiledPlotAtPosition(r,o),A=a?a.listTracksAtPosition(C[0],C[1],!0).map(h=>h.originalTrack||h):[],s=A.find(h=>!h.isAugmentationTrack),l=s?[C[0]-s.position[0],C[1]-s.position[1]]:C;let c=-1,u=-1;s&&(c=s.flipText?s._xScale.invert(l[1]):s._xScale.invert(l[0]),u=s.is2d?s._yScale.invert(l[1]):c);const d={x:C[0],y:C[1],relTrackX:s&&s.flipText?l[1]:l[0],relTrackY:s&&s.flipText?l[0]:l[1],dataX:c,dataY:u,isFrom2dTrack:!!(s&&s.is2d),isFromVerticalTrack:!!(s&&s.flipText),track:s,origEvt:I,sourceUid:this.uid,hoveredTracks:A,noHoveredTracks:A.length===0};if(this.pubSub.publish("app.mouseMove",d),this.isBroadcastMousePositionGlobally){const h={...d};h.origEvt=void 0,h.track=void 0,h.hoveredTracks=void 0,delete h.origEvt,delete h.track,delete h.hoveredTracks,M2.publish("higlass.mouseMove",h)}this.apiPublish("cursorLocation",{absX:r,absY:o,relX:d.x,relY:d.y,relTrackX:d.relTrackX,relTrackY:d.relTrackY,dataX:d.dataX,dataY:d.dataY,isFrom2dTrack:d.isFrom2dTrack,isFromVerticalTrack:d.isFromVerticalTrack}),this.showHoverMenu(d)}},{key:"getMinMaxValue",value:function(I,r,o,C){const a=VV(this.tiledPlots,I,r);if(!a){console.warn(`Track with ID: ${r} not found!`);return}if(!a.minVisibleValueInTiles||!a.maxVisibleValueInTiles){console.warn(`Track ${r} doesn't support the retrieval of min or max values.`);return}return o&&a.getAggregatedVisibleValue?[a.getAggregatedVisibleValue("min"),a.getAggregatedVisibleValue("max")]:[a.minVisibleValueInTiles(C),a.maxVisibleValueInTiles(C)]}},{key:"showHoverMenu",value:function(I){const r=I.track&&I.track.getMouseOverHtml?I.track.getMouseOverHtml(I.relTrackX,I.relTrackY):"";if(I.track!==this.prevMouseHoverTrack&&this.prevMouseHoverTrack&&this.prevMouseHoverTrack.stopHover&&this.prevMouseHoverTrack.stopHover(),this.prevMouseHoverTrack=I.track,this.zooming)return;const o=r&&r.length?[1]:[];let C=xg("body").selectAll(".track-mouseover-menu").data(o);C.exit().remove(),C.enter().append("div").classed("track-mouseover-menu",!0).classed(sG["track-mouseover-menu"],!0),C=xg("body").selectAll(".track-mouseover-menu");const a=mi(I.origEvt,xg("body").node()),A=[a[0]-window.scrollX,a[1]-window.scrollY];if(C.style("left",`${A[0]}px`).style("top",`${A[1]}px`),!C.node())return;const s=C.node().getBoundingClientRect();s.x+s.width>window.innerWidth&&C.style("left",`${A[0]-s.width}px`),s.y+s.height>window.innerHeight&&C.style("top",`${A[1]-s.height}px`),C.html(r)}},{key:"hideHoverMenu",value:function(){xg("body").selectAll(".track-mouseover-menu").remove()}},{key:"closeCustomDialog",value:function(){this.setState(I=>({customDialog:null}))}},{key:"appClickHandler",value:function(I){this.apiPublish("click",I)}},{key:"canvasClickHandler",value:function(I){const r=I.nativeEvent||I,o=r.clientX,C=r.clientY,a=this.getTiledPlotAtPosition(o,C),A=mi(r,this.topDiv);A[1]+=this.scrollTop;const s=a?a.listTracksAtPosition(A[0],A[1],!0).map(m=>m.originalTrack||m):[],l=s.find(m=>!m.isAugmentationTrack),c=l?[A[0]-l.position[0],A[1]-l.position[1]]:A,u=l&&l.flipText?c[1]:c[0],d=l&&l.flipText?c[0]:c[1];for(const m of this.iterateOverTracks()){const b=VV(this.tiledPlots,m.viewId,m.trackId);b.respondsToPosition(A[0],A[1])||b.clickOutside()}const h=[];for(const m of s)if(m.childTracks){for(const b of m.childTracks)h.push({trackUid:b.context.trackUid,viewUid:b.context.viewUid,trackType:b.context.trackType,data:b.click(u,d,I)});h.push({trackUid:m.context.trackUid,viewUid:m.context.viewUid,trackType:m.context.trackType,data:{type:"generic",event:I}})}else h.push({trackUid:m.context.trackUid,viewUid:m.context.viewUid,trackType:m.context.trackType,data:m.click(u,d,I)});const f=[];h.forEach((m,b)=>{const p=VV(this.tiledPlots,m.viewUid,m.trackUid);if(typeof p.clickDialog=="function"){const y=p.clickDialog();y&&f.push(y)}}),f.length>0&&this.setState(m=>({customDialog:f})),this.pubSub.publish("app.click",h)}},{key:"mouseMoveZoomHandler",value:function(I){this.apiPublish("mouseMoveZoom",I)}},{key:"geneSearchHandler",value:function(I){this.apiPublish("geneSearch",I)}},{key:"mouseDownHandler",value:function(I){}},{key:"onScrollHandler",value:function(){this.props.options.sizeMode===xR&&(this.scrollTop=this.scrollContainer.scrollTop,this.pixiStage.y=-this.scrollTop,this.pubSub.publish("app.scroll",this.scrollTop),this.animate())}},{key:"setTrackValueScaleLimits",value:function(I,r,o,C){const a=VV(this.tiledPlots,I,r);if(!a){console.warn(`Could't find track: ${r}`);return}a.setFixedValueScaleMin&&a.setFixedValueScaleMax?(a.setFixedValueScaleMin(o),a.setFixedValueScaleMax(C),a.rerender(a.options,!0),a.animate()):console.warn("Track doesn't support fixed value scales.")}},{key:"setChromInfo",value:function(I,r){Fd(I,o=>{this.chromInfo=o,r()},this.pubSub)}},{key:"onMouseLeaveHandler",value:function(){this.pubSub.publish("app.mouseLeave"),this.hideHoverMenu(),this.animate()}},{key:"onBlurHandler",value:function(){this.animate()}},{key:"isZoomFixed",value:function(I){return this.props.zoomFixed||this.props.options.zoomFixed||this.state.viewConfig.zoomFixed||this.props.options.sizeMode===xR||I&&I.zoomFixed}},{key:"trackDimensionsModifiedHandler",value:function(I){const r=this.state.views[I.viewId];if(!r)return;const o=ta(r.tracks,I.trackId);o&&(I.height!==void 0&&(o.height=I.height),I.width!==void 0&&(o.width=I.width),this.adjustLayoutToTrackSizes(r),this.setState(C=>({views:C.views})))}},{key:"wheelHandler",value:function(I){if(this.state.modal||this.props.options.sizeMode===xR)return;const r=I.nativeEvent||I,o=I.target===this.canvasElement;if(!i_e(r.target,this.topDiv)||this.isZoomFixed())return;const C=r.clientX,a=r.clientY,A=this.getTiledPlotAtPosition(C,a);if(this.apiStack.wheel&&this.apiStack.wheel.length>0){const s=mi(r,this.topDiv);s[1]+=this.scrollTop;const l=A?A.listTracksAtPosition(s[0],s[1],!0).map(h=>h.originalTrack||h):[],c=l.find(h=>!h.isAugmentationTrack),u=c?[s[0]-c.position[0],s[1]-c.position[1]]:s,d={x:s[0],y:s[1],relTrackX:c&&c.flipText?u[1]:u[0],relTrackY:c&&c.flipText?u[0]:u[1],track:c,origEvt:r,sourceUid:this.uid,hoveredTracks:l,noHoveredTracks:l.length===0};this.apiPublish("wheel",d)}if(r.forwarded||o){I.stopPropagation(),I.preventDefault();return}if(I.preventDefault(),A){const{trackRenderer:s}=A;r.forwarded=!0,r&&(FF(r,s.eventTracker),r.preventDefault())}}},{key:"render",value:function(){this.tiledAreasDivs={},this.tiledAreas=k.createElement("div",{className:sG["tiled-area"]}),this.mounted&&(this.tiledAreas=hi(this.state.views).map(s=>{const l=s.uid===this.state.addTrackPositionMenuUid?this.state.addTrackPositionMenuPosition:null;let c=null;if(this.state.chooseViewHandler){let f="transparent";this.state.mouseOverOverlayUid===s.uid&&(f="green"),c=k.createElement("div",{className:"tiled-plot-overlay",onClick:()=>this.state.chooseViewHandler(s.uid),onMouseEnter:()=>this.handleOverlayMouseEnter(s.uid),onMouseLeave:()=>this.handleOverlayMouseLeave(s.uid),onMouseMove:()=>this.handleOverlayMouseEnter(s.uid),style:{position:"absolute",width:"100%",height:"100%",background:f,opacity:.3,zIndex:1}})}const u=k.createElement(RRg,{key:`tp${s.uid}`,ref:f=>{this.tiledPlots[s.uid]=f},addTrackPosition:this.state.addTrackPositionView===s.uid?this.state.addTrackPosition:null,addTrackPositionMenuPosition:l,canvasElement:this.state.canvasElement,chooseTrackHandler:this.state.chooseTrackHandler?f=>this.state.chooseTrackHandler(s.uid,f):null,customDialog:this.state.customDialog,closeCustomDialog:()=>this.closeCustomDialog(),chromInfoPath:s.chromInfoPath,disableTrackMenu:this.isTrackMenuDisabled(),draggingHappening:this.state.draggingHappening!==null,editable:this.isEditable(),getLockGroupExtrema:f=>this.getLockGroupExtrema(s.uid,f),initialXDomain:s.initialXDomain,initialYDomain:s.initialYDomain,isShowGlobalMousePosition:this.isShowGlobalMousePosition,isValueScaleLocked:f=>this.isValueScaleLocked(s.uid,f),marginBottom:this.viewMarginBottom,marginLeft:this.viewMarginLeft,marginRight:this.viewMarginRight,marginTop:this.viewMarginTop,metaTracks:s.metaTracks,mouseTool:this.state.mouseTool,onChangeTrackData:(f,m)=>this.handleChangeTrackData(s.uid,f,m),onChangeTrackType:(f,m)=>this.handleChangeTrackType(s.uid,f,m),onCloseTrack:f=>this.handleCloseTrack(s.uid,f),onDataDomainChanged:(f,m)=>this.handleDataDomainChanged(s.uid,f,m),onLockValueScale:f=>this.handleLockValueScale(s.uid,f),onMouseMoveZoom:this.mouseMoveZoomHandler.bind(this),onNewTilesLoaded:f=>this.handleNewTilesLoaded(s.uid,f),onNoTrackAdded:this.handleNoTrackAdded.bind(this),onRangeSelection:this.rangeSelectionHandler.bind(this),onResizeTrack:this.triggerViewChangeDb,onScalesChanged:(f,m)=>this.handleScalesChanged(s.uid,f,m),onTrackOptionsChanged:(f,m)=>this.handleTrackOptionsChanged(s.uid,f,m),onTrackPositionChosen:this.handleTrackPositionChosen.bind(this),onTracksAdded:(f,m,b)=>this.handleTracksAdded(s.uid,f,m,b),onUnlockValueScale:f=>this.handleUnlockValueScale(s.uid,f),onValueScaleChanged:f=>this.syncValueScales(s.uid,f),overlays:s.overlays,paddingBottom:this.viewPaddingBottom,paddingLeft:this.viewPaddingLeft,paddingRight:this.viewPaddingRight,paddingTop:this.viewPaddingTop,pixiRenderer:this.pixiRenderer,pixiStage:this.pixiStage,pluginDataFetchers:this.pluginDataFetchers,pluginTracks:this.pluginTracks,rangeSelection1dSize:this.state.rangeSelection1dSize,rangeSelectionToInt:this.state.rangeSelectionToInt,registerDraggingChangedListener:f=>this.addDraggingChangedListener(s.uid,s.uid,f),removeDraggingChangedListener:f=>this.removeDraggingChangedListener(s.uid,s.uid,f),setCentersFunction:f=>{this.setCenters[s.uid]=f},svgElement:this.state.svgElement,tracks:s.tracks,trackSourceServers:this.state.viewConfig.trackSourceServers,uid:s.uid,verticalMargin:this.verticalMargin,viewOptions:s.options,xDomainLimits:s.xDomainLimits,yDomainLimits:s.yDomainLimits,zoomable:!this.isZoomFixed(s),zoomLimits:this.calculateZoomLimits(s,s.initialXDomain),zoomToDataExtentOnInit:()=>this.zoomToDataExtentOnInit.has(s.uid)}),d=(f,m)=>s.genomePositionSearchBox?k.createElement(cVg,{key:`gpsb${s.uid}`,ref:b=>{this.genomePositionSearchBoxes[s.uid]=b},autocompleteId:s.genomePositionSearchBox.autocompleteId,autocompleteServer:s.genomePositionSearchBox.autocompleteServer,chromInfoId:s.genomePositionSearchBox.chromInfoId,chromInfoPath:s.genomePositionSearchBox.chromInfoPath,chromInfoServer:s.genomePositionSearchBox.chromInfoServer,hideAvailableAssemblies:s.genomePositionSearchBox.hideAvailableAssemblies,isFocused:f,onFocus:m,onGeneSearch:this.geneSearchHandler.bind(this),onSelectedAssemblyChanged:(b,p,y)=>this.handleSelectedAssemblyChanged(s.uid,b,p,y),registerViewportChangedListener:b=>this.addScalesChangedListener(s.uid,s.uid,b),removeViewportChangedListener:()=>this.removeScalesChangedListener(s.uid,s.uid),setCenters:(b,p,y,Z)=>this.setCenters[s.uid](b,p,y,!1,Z),trackSourceServers:this.state.viewConfig.trackSourceServers,twoD:!!(s.tracks.left.length||s.tracks.right.length||s.tracks.center.length)}):null,h=this.isEditable()&&!this.isViewHeaderDisabled()&&!this.state.viewConfig.hideHeader?k.createElement(MVg,{ref:f=>{this.viewHeaders[s.uid]=f},getGenomePositionSearchBox:d,isGenomePositionSearchBoxVisible:s.genomePositionSearchBox&&s.genomePositionSearchBox.visible,mouseTool:this.state.mouseTool,onAddView:()=>this.handleAddView(s),onClearView:()=>this.handleClearView(s.uid),onCloseView:()=>this.handleCloseView(s.uid),onEditViewConfig:this.handleEditViewConfigBound,onExportPNG:this.handleExportPNG.bind(this),onExportSVG:this.handleExportSVG.bind(this),onExportViewsAsJSON:this.handleExportViewAsJSON.bind(this),onExportViewsAsLink:this.handleExportViewsAsLink.bind(this),onLockLocation:f=>this.handleYankFunction(f,this.handleLocationLockChosen.bind(this)),onLockZoom:f=>this.handleYankFunction(f,this.handleZoomLockChosen.bind(this)),onLockZoomAndLocation:f=>this.handleYankFunction(f,(m,b)=>{this.handleZoomLockChosen(m,b),this.handleLocationLockChosen(m,b)}),onProjectViewport:this.handleProjectViewport.bind(this),onTakeAndLockZoomAndLocation:f=>{this.handleYankFunction(f,(m,b)=>{this.handleZoomYanked(m,b),this.handleLocationYanked(m,b),this.handleZoomLockChosen(m,b),this.handleLocationLockChosen(m,b)})},onTogglePositionSearchBox:this.handleTogglePositionSearchBox.bind(this),onTrackPositionChosen:f=>this.handleTrackPositionChosen(s.uid,f),onUnlockLocation:f=>this.handleUnlock(f,this.locationLocks),onUnlockZoom:f=>this.handleUnlock(f,this.zoomLocks),onUnlockZoomAndLocation:f=>{this.handleUnlock(f,this.zoomLocks),this.handleUnlock(f,this.locationLocks)},onViewOptionsChanged:f=>this.handleViewOptionsChanged(s.uid,f),onYankLocation:f=>this.handleYankFunction(f,this.handleLocationYanked.bind(this)),onYankZoom:f=>this.handleYankFunction(f,this.handleZoomYanked.bind(this)),onYankZoomAndLocation:f=>this.handleYankFunction(f,(m,b)=>{this.handleZoomYanked(m,b),this.handleLocationYanked(m,b)}),onZoomToData:f=>this.handleZoomToData(f),viewUid:s.uid}):null;return k.createElement("div",{key:s.uid,ref:f=>{this.tiledAreasDivs[s.uid]=f},className:sG["tiled-area"]},h,u,c)}));let I=this.mounted?Object.values(this.state.views).filter(s=>s.layout).map(s=>s.layout):[];I=JSON.parse(JSON.stringify(I));const r=this.isEditable()?XPe:0,o=this.isEditable()?TPe:0,C=+this.props.options.containerPaddingX>=0?+this.props.options.containerPaddingX:r,a=+this.props.options.containerPaddingY>=0?+this.props.options.containerPaddingY:o,A=k.createElement(s5t,{ref:s=>{this.gridLayout=s},cols:12,containerPadding:[C,a],draggableHandle:`.${ka["multitrack-header-grabber"]}`,isDraggable:this.isEditable(),isResizable:this.isEditable(),layout:I,margin:this.isEditable()?[10,10]:[0,0],measureBeforeMount:!1,onBreakpointChange:this.onBreakpointChange.bind(this),onDragStart:this.handleDragStart.bind(this),onDragStop:this.handleDragStop.bind(this),onLayoutChange:this.handleLayoutChange.bind(this),onResize:this.resizeHandler.bind(this),rowHeight:this.state.rowHeight,useCSSTransforms:this.mounted,verticalCompact:this.state.viewConfig.compactLayout,width:this.state.width},this.tiledAreas);return k.createElement("div",{key:this.uid,ref:s=>{this.topDiv=s},className:gi("higlass",{"higlass-dark-theme":this.theme===ki,"higlass-container-overflow":this.props.options.sizeMode===cXe||this.props.options.sizeMode===xR}),onMouseLeave:this.onMouseLeaveHandlerBound,onMouseMove:this.mouseMoveHandlerBound},k.createElement(pgg,{value:this.pubSub},k.createElement(Omg,{value:this.modal},k.createElement(Cgg,{value:this.theme},this.state.modal,k.createElement("canvas",{key:this.uid,ref:s=>{this.canvasElement=s},onClick:this.canvasClickHandlerBound,className:sG["higlass-canvas"]}),k.createElement("div",{ref:s=>{this.scrollContainer=s},className:gi("higlass-scroll-container",{"higlass-scroll-container-overflow":this.props.options.sizeMode===cXe,"higlass-scroll-container-scroll":this.props.options.sizeMode===xR}),onScroll:this.onScrollHandlerBound},k.createElement("div",{ref:s=>{this.divDrawingSurface=s},className:gi("higlass-drawing-surface",sG["higlass-drawing-surface"])},A),k.createElement("svg",{ref:s=>{this.svgElement=s},className:sG["higlass-svg"],style:{position:"absolute",width:"100%",height:"100%",left:0,top:0,pointerEvents:"none"}}))))))}}]),i}(k.Component);CS.defaultProps={options:{},zoomFixed:!1,compactLayout:!0};CS.propTypes={getApi:L.func,options:L.object,viewConfig:L.oneOfType([L.string,L.object]).isRequired,zoomFixed:L.bool,compactLayout:L.bool};function a9g(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function uXe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function FD(e){return FD=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},FD(e)}const m9g=(e,[g,i,n,I],r)=>{r.options.colorbarPosition||(r.options.colorbarPosition="hidden"),r.options.labelPosition||(r.options.labelPosition="hidden");const o="arbitary-id",a=y9g(e,{editable:!1,zoomFixed:!1,views:[{uid:o,initialXDomain:[g,i],initialYDomain:[n,I],tracks:{center:[r]},layout:{w:12,h:12,x:0,y:0,moved:!1,static:!1}}]},{sizeMode:"bounded"});return{id:o,hgApi:a}};let p9g=function(e){c9g(i,e);var g=u9g(i);function i(n){var I;return a9g(this,i),I=g.call(this,n),I.id=`id-${Math.random()}`,I}return s9g(i,[{key:"componentDidMount",value:function(){this.initTrackViewer()}},{key:"shouldComponentUpdate",value:function(I){const{x:r,y:o,width:C,height:a}=I;return this.zoomTo(r,o,C,a),!1}},{key:"initTrackViewer",value:function(){const{trackConfig:I,x:r,y:o,width:C,height:a}=this.props,A=document.getElementById(this.id),{id:s,hgApi:l}=m9g(A,[r,r+C,o,o+a],I);this.viewUid=s,this.viewer=l}},{key:"zoomTo",value:function(I,r,o,C){this.viewer.zoomTo(this.viewUid,I,I+o,r,r+C)}},{key:"render",value:function(){return k.createElement("div",{id:this.id,style:{height:"100%",width:"100%"}})}}]),i}(k.Component);p9g.propTypes={trackConfig:L.object,width:L.number,height:L.number,x:L.number,y:L.number};const b9g=(e,g,i)=>{const n=k.createRef();return _I.render(k.createElement(CS,{ref:n,options:i||{},viewConfig:g}),e),n.current},y9g=(e,g,i)=>b9g(e,g,i).api;var u8e={exports:{}};(function(e,g){(function(i,n){e.exports=n()})(typeof window<"u"?window:un,function(){if(typeof window>"u")return null;var i=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")(),n=i.requestAnimationFrame||i.mozRequestAnimationFrame||i.webkitRequestAnimationFrame||function(s){return i.setTimeout(s,20)},I=i.cancelAnimationFrame||i.mozCancelAnimationFrame||i.webkitCancelAnimationFrame||function(s){i.clearTimeout(s)};function r(s,l){var c=Object.prototype.toString.call(s),u=c==="[object Array]"||c==="[object NodeList]"||c==="[object HTMLCollection]"||c==="[object Object]"||typeof jQuery<"u"&&s instanceof jQuery||typeof Elements<"u"&&s instanceof Elements,d=0,h=s.length;if(u)for(;d=T&&(X+=R.value),R.mode==="max"&&W<=T&&(X+=R.value),V[N]||(V[N]=""),X&&(" "+V[N]+" ").indexOf(" "+X+" ")===-1&&(V[N]+=" "+X));for(var x in Y)Y.hasOwnProperty(x)&&(V[Y[x]]?this.element.setAttribute(Y[x],V[Y[x]].substr(1)):this.element.removeAttribute(Y[x]))}}function c(G,B){G.elementQueriesSetupInformation||(G.elementQueriesSetupInformation=new l(G,B)),G.elementQueriesSensor||(G.elementQueriesSensor=new i(G,function(){G.elementQueriesSetupInformation.call()}))}function u(G,B,S,R){if(typeof o[G]>"u"){o[G]=[];var w=C.length;r.innerHTML+=` +`+G+" {animation: 0.1s element-queries;}",r.innerHTML+=` +`+G+" > .resize-sensor {min-width: "+w+"px;}",C.push(G)}o[G].push({mode:B,property:S,value:R})}function d(G){var B;if(document.querySelectorAll&&(B=G?G.querySelectorAll.bind(G):document.querySelectorAll.bind(document)),!B&&typeof $$<"u"&&(B=$$),!B&&typeof jQuery<"u"&&(B=jQuery),!B)throw"No document.querySelectorAll, jQuery or Mootools's $$ found.";return B}function h(G){var B=d(G);for(var S in o)if(o.hasOwnProperty(S))for(var R=B(S,G),w=0,T=R.length;wS[F].minWidth&&(M=F);if(M||(M=w),T!==M)if(W[M])B[T].style.display="none",B[M].style.display="block",T=M;else{var $=new Image;$.onload=function(){B[M].src=R[M],B[T].style.display="none",B[M].style.display="block",W[M]=!0,T=M},$.src=R[M]}else B[M].src=R[M]}G.resizeSensorInstance=new i(G,x),x()}function m(){for(var G=d(),B=G("[data-responsive-image],[responsive-image]"),S=0,R=B.length;S img, [data-responsive-image] {overflow: hidden; padding: 0; } [responsive-image] > img, [data-responsive-image] > img {width: 100%;}",r.innerHTML+=` +@keyframes element-queries { 0% { visibility: inherit; } }`,document.getElementsByTagName("head")[0].appendChild(r),v=!0);for(var B=0,S=document.styleSheets.length;Bg in e?G9g(e,g,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[g]=i,at=(e,g,i)=>(v9g(e,typeof g!="symbol"?g+"":g,i),i),Nle=(e,g,i)=>{if(!g.has(e))throw TypeError("Cannot "+i)},Ut=(e,g,i)=>(Nle(e,g,"read from private field"),i?i.call(e):g.get(e)),Vg=(e,g,i)=>{if(g.has(e))throw TypeError("Cannot add the same private member more than once");g instanceof WeakSet?g.add(e):g.set(e,i)},ho=(e,g,i,n)=>(Nle(e,g,"write to private field"),n?n.call(e,i):g.set(e,i),i),Mi=(e,g,i)=>(Nle(e,g,"access private method"),i),$V,m9,p9,q0,ED,DD,Iie,f8e,kle,m8e,MD,rie,oie,p8e,Cie,b8e,aie,y8e,Ru;const B9g="#/definitions/GoslingSpec",w9g="http://json-schema.org/draft-07/schema#",S9g={Aggregate:{enum:["max","min","mean","bin","count"],type:"string"},Assembly:{anyOf:[{const:"hg38",type:"string"},{const:"hg19",type:"string"},{const:"hg18",type:"string"},{const:"hg17",type:"string"},{const:"hg16",type:"string"},{const:"mm10",type:"string"},{const:"mm9",type:"string"},{const:"unknown",type:"string"},{$ref:"#/definitions/ChromSizes"}]},AxisPosition:{enum:["none","top","bottom","left","right"],type:"string"},BamData:{additionalProperties:!1,description:"Binary Alignment Map (BAM) is the comprehensive raw data of genome sequencing; it consists of the lossless, compressed binary representation of the Sequence Alignment Map-files.",properties:{extractJunction:{description:"Determine whether to extract exon-to-exon junctions. __Default__: `false`",type:"boolean"},indexUrl:{description:"URL link to the index file of the BAM file",type:"string"},junctionMinCoverage:{description:"Determine the threshold of coverage when extracting exon-to-exon junctions. __Default__: `1`",type:"number"},loadMates:{description:"Load mates that are located in the same chromosome. __Default__: `false`",type:"boolean"},maxInsertSize:{description:"Determines the threshold of insert sizes for determining the structural variants. __Default__: `5000`",type:"number"},type:{const:"bam",type:"string"},url:{description:"URL link to the BAM data file",type:"string"}},required:["type","url","indexUrl"],type:"object"},BedData:{additionalProperties:!1,description:"BED file format",properties:{customFields:{description:"An array of strings, where each string is the name of a non-standard field in the BED file. If there are `n` custom fields, we assume that the last `n` columns of the BED file correspond to the custom fields.",items:{type:"string"},type:"array"},indexUrl:{description:"Specify the URL address of the data file index.",type:"string"},sampleLength:{description:"Specify the number of rows loaded from the URL.\n\n__Default:__ `1000`",type:"number"},type:{const:"bed",type:"string"},url:{description:"Specify the URL address of the data file.",type:"string"}},required:["type","url","indexUrl"],type:"object"},BeddbData:{additionalProperties:!1,description:"Regular BED or similar files can be pre-aggregated for the scalable data exploration. Find our more about this format at [HiGlass Docs](https://docs.higlass.io/data_preparation.html#bed-files).",properties:{exonIntervalFields:{description:"experimental",items:[{additionalProperties:!1,properties:{index:{type:"number"},name:{type:"string"}},required:["index","name"],type:"object"},{additionalProperties:!1,properties:{index:{type:"number"},name:{type:"string"}},required:["index","name"],type:"object"}],maxItems:2,minItems:2,type:"array"},genomicFields:{description:"Specify the name of genomic data fields.",items:{additionalProperties:!1,properties:{index:{type:"number"},name:{type:"string"}},required:["index","name"],type:"object"},type:"array"},type:{const:"beddb",type:"string"},url:{description:"Specify the URL address of the data file.",type:"string"},valueFields:{description:"Specify the column indexes, field names, and field types.",items:{additionalProperties:!1,properties:{index:{type:"number"},name:{type:"string"},type:{enum:["nominal","quantitative"],type:"string"}},required:["index","name","type"],type:"object"},type:"array"}},required:["type","url","genomicFields"],type:"object"},BigWigData:{additionalProperties:!1,properties:{aggregation:{$ref:"#/definitions/BinAggregate",description:'Determine aggregation function to apply within bins. __Default__: `"mean"`'},binSize:{description:"Binning the genomic interval in tiles (unit size: 256).",type:"number"},column:{description:'Assign a field name of the middle position of genomic intervals. __Default__: `"position"`',type:"string"},end:{description:'Assign a field name of the end position of genomic intervals. __Default__: `"end"`',type:"string"},start:{description:'Assign a field name of the start position of genomic intervals. __Default__: `"start"`',type:"string"},type:{const:"bigwig",type:"string"},url:{description:"Specify the URL address of the data file.",type:"string"},value:{description:'Assign a field name of quantitative values. __Default__: `"value"`',type:"string"}},required:["type","url"],type:"object"},BinAggregate:{enum:["mean","sum"],type:"string"},Channel:{anyOf:[{$ref:"#/definitions/ChannelDeep"},{$ref:"#/definitions/ChannelValue"}]},ChannelDeep:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/Y"},{$ref:"#/definitions/Row"},{$ref:"#/definitions/Color"},{$ref:"#/definitions/Size"},{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/Text"}]},ChannelValue:{additionalProperties:!1,properties:{value:{description:"Assign a constant value for a visual channel.",type:["number","string"]}},required:["value"],type:"object"},ChromSizes:{description:'Custom chromosome sizes, e.g., [["foo", 1000], ["bar", 300], ["baz", 240]]',items:{items:[{type:"string"},{type:"number"}],maxItems:2,minItems:2,type:"array"},type:"array"},Color:{additionalProperties:!1,properties:{domain:{$ref:"#/definitions/ValueExtent",description:"Values of the data"},field:{description:"Name of the data field",type:"string"},legend:{description:"Whether to display legend. __Default__: `false`",type:"boolean"},range:{$ref:"#/definitions/Range",description:"Determine the colors that should be bound to data value. Default properties are determined considering the field type."},scale:{enum:["linear","log"],type:"string"},scaleOffset:{description:"Whether to use offset of the domain proportionally. This is bound to brushes on the color legend. __Default__: `[0, 1]`",items:{type:"number"},maxItems:2,minItems:2,type:"array"},title:{description:"Title of the legend. __Default__: `undefined`",type:"string"},type:{description:"Specify the data type",enum:["quantitative","nominal"],type:"string"}},type:"object"},CoverageTransform:{additionalProperties:!1,description:"Aggregate rows and calculate coverage",properties:{endField:{type:"string"},groupField:{description:"The name of a nominal field to group rows by in prior to piling-up",type:"string"},newField:{type:"string"},startField:{type:"string"},type:{const:"coverage",type:"string"}},required:["type","startField","endField"],type:"object"},CsvData:{additionalProperties:!1,description:'Any small enough tabular data files, such as tsv, csv, BED, BEDPE, and GFF, can be loaded using "csv" data specification.',properties:{chromosomeField:{description:"Specify the name of chromosome data fields.",type:"string"},chromosomePrefix:{description:'Specify the chromosome prefix if chromosomes are denoted using a prefix besides "chr" or a number',type:"string"},genomicFields:{description:"Specify the name of genomic data fields.",items:{type:"string"},type:"array"},genomicFieldsToConvert:{description:"experimental",items:{additionalProperties:!1,properties:{chromosomeField:{type:"string"},genomicFields:{items:{type:"string"},type:"array"}},required:["chromosomeField","genomicFields"],type:"object"},type:"array"},headerNames:{description:"Specify the names of data fields if a CSV file does not contain a header.",items:{type:"string"},type:"array"},longToWideId:{description:"experimental",type:"string"},sampleLength:{description:"Specify the number of rows loaded from the URL.\n\n__Default:__ `1000`",type:"number"},separator:{description:"Specify file separator, __Default:__ ','",type:"string"},type:{const:"csv",type:"string"},url:{description:"Specify the URL address of the data file.",type:"string"}},required:["type","url"],type:"object"},DataDeep:{anyOf:[{$ref:"#/definitions/JsonData"},{$ref:"#/definitions/CsvData"},{$ref:"#/definitions/BedData"},{$ref:"#/definitions/BigWigData"},{$ref:"#/definitions/MultivecData"},{$ref:"#/definitions/BeddbData"},{$ref:"#/definitions/VectorData"},{$ref:"#/definitions/MatrixData"},{$ref:"#/definitions/BamData"},{$ref:"#/definitions/VcfData"},{$ref:"#/definitions/GffData"}]},DataTrack:{additionalProperties:!1,description:"Partial specification of `BasicSingleTrack` to use default visual encoding predefined by data type.",properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},data:{$ref:"#/definitions/DataDeep"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},height:{description:"Specify the track height in pixels.",type:"number"},id:{description:"Assigned to `uid` in a HiGlass view config, used for API and caching.",type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},width:{description:"Specify the track width in pixels.",type:"number"},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["data"],type:"object"},DataTransform:{anyOf:[{$ref:"#/definitions/FilterTransform"},{$ref:"#/definitions/StrConcatTransform"},{$ref:"#/definitions/StrReplaceTransform"},{$ref:"#/definitions/LogTransform"},{$ref:"#/definitions/DisplaceTransform"},{$ref:"#/definitions/ExonSplitTransform"},{$ref:"#/definitions/GenomicLengthTransform"},{$ref:"#/definitions/SvTypeTransform"},{$ref:"#/definitions/CoverageTransform"},{$ref:"#/definitions/JsonParseTransform"}]},Datum:{additionalProperties:{type:["number","string"]},description:"Values in the form of JSON.",type:"object"},DisplaceTransform:{additionalProperties:!1,properties:{boundingBox:{additionalProperties:!1,properties:{endField:{description:"The name of a quantitative field that represents the end position.",type:"string"},groupField:{description:"The name of a nominal field to group rows by in prior to piling-up.",type:"string"},isPaddingBP:{description:"Whether to consider `padding` as the bp length.",type:"boolean"},padding:{description:"The padding around visual lements. Either px or bp",type:"number"},startField:{description:"The name of a quantitative field that represents the start position.",type:"string"}},required:["startField","endField"],type:"object"},maxRows:{description:"Specify maximum rows to be generated (default has no limit).",type:"number"},method:{$ref:"#/definitions/DisplacementType",description:"A string that specifies the type of displacement."},newField:{type:"string"},type:{const:"displace",type:"string"}},required:["type","boundingBox","method","newField"],type:"object"},Displacement:{additionalProperties:!1,properties:{padding:{type:"number"},type:{$ref:"#/definitions/DisplacementType"}},required:["type"],type:"object"},DisplacementType:{enum:["pile","spread"],type:"string"},DomainChr:{additionalProperties:!1,properties:{chromosome:{type:"string"}},required:["chromosome"],type:"object"},DomainChrInterval:{additionalProperties:!1,properties:{chromosome:{description:"If specified, only showing a certain interval in a chromosome.",type:"string"},interval:{items:{type:"number"},maxItems:2,minItems:2,type:"array"}},required:["chromosome","interval"],type:"object"},DomainInterval:{additionalProperties:!1,properties:{interval:{description:"Show a certain interval within entire chromosome",items:{type:"number"},maxItems:2,minItems:2,type:"array"}},required:["interval"],type:"object"},DummyTrack:{additionalProperties:!1,description:"A placeholder track. In contrast to other tracks, this track does not display any data. Instead it provides empty space for third party tools to display their data on top of.",properties:{_invalidTrack:{description:"internal",type:"boolean"},assembly:{const:"unknown",description:"No assemblies can be associated with a dummy track",type:"string"},height:{description:"Specify the track height in pixels.",type:"number"},id:{description:"Assigned to `uid` in a HiGlass view config, used for API and caching.",type:"string"},layout:{const:"linear",description:"Only linear layout are supported at this time",type:"string"},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},overlayOnPreviousTrack:{type:"boolean"},static:{const:!0,description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},style:{$ref:"#/definitions/DummyTrackStyle",description:"Defines how the track is styled"},title:{description:"Text that gets shown on the DummyTrack",type:"string"},type:{const:"dummy-track",description:"Used to specify the dummy track",type:"string"},width:{description:"Specify the track width in pixels.",type:"number"},zoomLimits:{description:"Unused property for DummyTrack",items:{type:"null"},maxItems:2,minItems:2,type:"array"}},required:["type"],type:"object"},DummyTrackStyle:{additionalProperties:!1,properties:{background:{description:"Background color of the track",type:"string"},outline:{description:"Color of the outline of the track",type:"string"},textFontSize:{description:"Specify the font size of the title",type:"number"},textFontWeight:{description:"Specify the font weight of the title.",enum:["bold","normal"],type:"string"},textStroke:{description:"Specify the stroke color of title.",type:"string"},textStrokeWidth:{description:"Specify the stroke width of the title.",type:"number"}},type:"object"},EventStyle:{additionalProperties:!1,description:"The styles defined here will be applied to the target marks of mouse events, such as a point mark after the user clicks on it.",properties:{arrange:{description:"Show event effects behind or in front of marks.",enum:["behind","front"],type:"string"},color:{description:"color of the marks when mouse events are triggered",type:"string"},opacity:{description:"opacity of the marks when mouse events are triggered",type:"number"},stroke:{description:"stroke color of the marks when mouse events are triggered",type:"string"},strokeOpacity:{type:"number"},strokeWidth:{description:"stroke width of the marks when mouse events are triggered",type:"number"}},type:"object"},ExonSplitTransform:{additionalProperties:!1,properties:{fields:{items:{additionalProperties:!1,properties:{chrField:{type:"string"},field:{type:"string"},newField:{type:"string"},type:{$ref:"#/definitions/FieldType"}},required:["field","type","newField","chrField"],type:"object"},type:"array"},flag:{additionalProperties:!1,properties:{field:{type:"string"},value:{type:["number","string"]}},required:["field","value"],type:"object"},separator:{type:"string"},type:{const:"exonSplit",type:"string"}},required:["type","separator","flag","fields"],type:"object"},FieldType:{enum:["genomic","nominal","quantitative"],type:"string"},FilterTransform:{anyOf:[{$ref:"#/definitions/OneOfFilter"},{$ref:"#/definitions/RangeFilter"},{$ref:"#/definitions/IncludeFilter"}]},GenomicDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}]},GenomicLengthTransform:{additionalProperties:!1,description:"Calculate genomic length using two genomic fields",properties:{endField:{type:"string"},newField:{type:"string"},startField:{type:"string"},type:{const:"genomicLength",type:"string"}},required:["type","startField","endField","newField"],type:"object"},GffData:{additionalProperties:!1,description:"Generic Feature Format Version 3 (GFF3) format data. It parses files that follow the [GFF3 specification](https://github.com/The-Sequence-Ontology/Specifications/blob/master/gff3.md).",properties:{attributesToFields:{description:'Specifies which attributes to include as a fields. GFF files have an "attributes" column which contains a list of attributes which are each tag-value pairs (`tag=value`). This option allows for specific attributes to be accessible as a field. For example, if you have an attribute called "gene_name" and you want label features on your track using those values, you can use this option so that you can use `"field": "gene_name"` in the schema.\n\nIf there is a single `value` corresponding to the `tag`, Gosling will parse that value as a string. If there are multiple `value`s corresponding to a `tag`, Gosling will parse it as a comma-separated list string. If a feature does not have a particular attribute, then the attribute value will be set to the `defaultValue`.',items:{additionalProperties:!1,properties:{attribute:{type:"string"},defaultValue:{type:"string"}},required:["attribute","defaultValue"],type:"object"},type:"array"},indexUrl:{description:"URL link to the tabix index file",type:"string"},sampleLength:{description:"The maximum number of samples to be shown on the track. Samples are uniformly randomly selected so that this threshold is not exceeded. __Default:__ `1000`",type:"number"},type:{const:"gff",type:"string"},url:{description:"URL link to the GFF file",type:"string"}},required:["type","url","indexUrl"],type:"object"},GoslingSpec:{anyOf:[{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{const:"overlay",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},description:{type:"string"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"},stretchGraphics:{description:`Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts. + +When this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.`,type:"boolean"},stretchGraphicsThreshold:{default:1.5,description:"Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.",type:"number"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{description:"The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view",type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},responsiveSize:{$ref:"#/definitions/ResponsiveSize",description:"Determine whether to make the size of `GoslingComponent` bound to its parent element. __Default__: `false`"},responsiveSpec:{items:{additionalProperties:!1,properties:{selectivity:{items:{$ref:"#/definitions/SelectivityCondition"},type:"array"},spec:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{enum:["overlay","stack"],type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"},stretchGraphics:{description:`Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts. + +When this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.`,type:"boolean"},stretchGraphicsThreshold:{default:1.5,description:"Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.",type:"number"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{description:"The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view",type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{anyOf:[{items:{$ref:"#/definitions/PartialTrack"},type:"array"},{items:{anyOf:[{$ref:"#/definitions/PartialTrack"},{$ref:"#/definitions/OverlaidTracks"}]},type:"array"}]},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},type:"object"}},required:["spec","selectivity"],type:"object"},type:"array"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{items:{$ref:"#/definitions/PartialTrack"},type:"array"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["alignment","tracks"],type:"object"},{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{const:"stack",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},description:{type:"string"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"},stretchGraphics:{description:`Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts. + +When this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.`,type:"boolean"},stretchGraphicsThreshold:{default:1.5,description:"Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.",type:"number"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{description:"The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view",type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},responsiveSize:{$ref:"#/definitions/ResponsiveSize",description:"Determine whether to make the size of `GoslingComponent` bound to its parent element. __Default__: `false`"},responsiveSpec:{items:{additionalProperties:!1,properties:{selectivity:{items:{$ref:"#/definitions/SelectivityCondition"},type:"array"},spec:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{enum:["overlay","stack"],type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"},stretchGraphics:{description:`Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts. + +When this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.`,type:"boolean"},stretchGraphicsThreshold:{default:1.5,description:"Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.",type:"number"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{description:"The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view",type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{anyOf:[{items:{$ref:"#/definitions/PartialTrack"},type:"array"},{items:{anyOf:[{$ref:"#/definitions/PartialTrack"},{$ref:"#/definitions/OverlaidTracks"}]},type:"array"}]},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},type:"object"}},required:["spec","selectivity"],type:"object"},type:"array"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{items:{anyOf:[{$ref:"#/definitions/PartialTrack"},{$ref:"#/definitions/OverlaidTracks"}]},type:"array"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["tracks"],type:"object"},{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},description:{type:"string"},id:{description:"The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view",type:"string"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},responsiveSize:{$ref:"#/definitions/ResponsiveSize",description:"Determine whether to make the size of `GoslingComponent` bound to its parent element. __Default__: `false`"},responsiveSpec:{items:{additionalProperties:!1,properties:{selectivity:{items:{$ref:"#/definitions/SelectivityCondition"},type:"array"},spec:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{enum:["overlay","stack"],type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"},stretchGraphics:{description:`Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts. + +When this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.`,type:"boolean"},stretchGraphicsThreshold:{default:1.5,description:"Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.",type:"number"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{description:"The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view",type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{anyOf:[{items:{$ref:"#/definitions/PartialTrack"},type:"array"},{items:{anyOf:[{$ref:"#/definitions/PartialTrack"},{$ref:"#/definitions/OverlaidTracks"}]},type:"array"}]},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},type:"object"}},required:["spec","selectivity"],type:"object"},type:"array"},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},title:{type:"string"},tracks:{items:{$ref:"#/definitions/Track"},type:"array"},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["tracks"],type:"object"},{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},arrangement:{description:"Specify how multiple views are arranged.",enum:["parallel","serial","horizontal","vertical"],type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},description:{type:"string"},id:{description:"The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view",type:"string"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},responsiveSize:{$ref:"#/definitions/ResponsiveSize",description:"Determine whether to make the size of `GoslingComponent` bound to its parent element. __Default__: `false`"},responsiveSpec:{items:{additionalProperties:!1,properties:{selectivity:{items:{$ref:"#/definitions/SelectivityCondition"},type:"array"},spec:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},arrangement:{description:"Specify how multiple views are arranged.",enum:["parallel","serial","horizontal","vertical"],type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},id:{description:"The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view",type:"string"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},views:{description:"An array of view specifications",items:{anyOf:[{$ref:"#/definitions/SingleView"},{$ref:"#/definitions/MultipleViews"}]},type:"array"},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},type:"object"}},required:["spec","selectivity"],type:"object"},type:"array"},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},title:{type:"string"},views:{description:"An array of view specifications",items:{anyOf:[{$ref:"#/definitions/SingleView"},{$ref:"#/definitions/MultipleViews"}]},type:"array"},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["views"],type:"object"}]},IncludeFilter:{additionalProperties:!1,properties:{field:{description:"A filter is applied based on the values of the specified data field",type:"string"},include:{description:"Check whether the value includes a substring.",type:"string"},not:{description:'when `{"not": true}`, apply a NOT logical operation to the filter.\n\n__Default:__ `false`',type:"boolean"},type:{const:"filter",type:"string"}},required:["field","include","type"],type:"object"},JsonData:{additionalProperties:!1,description:"The JSON data format allows users to include data directly in the Gosling's JSON specification.",properties:{chromosomeField:{description:"Specify the name of chromosome data fields.",type:"string"},genomicFields:{description:"Specify the name of genomic data fields.",items:{type:"string"},type:"array"},genomicFieldsToConvert:{description:"experimental",items:{additionalProperties:!1,properties:{chromosomeField:{type:"string"},genomicFields:{items:{type:"string"},type:"array"}},required:["chromosomeField","genomicFields"],type:"object"},type:"array"},sampleLength:{description:"Specify the number of rows loaded from the URL.\n\n__Default:__ `1000`",type:"number"},type:{const:"json",description:"Define data type.",type:"string"},values:{description:"Values in the form of JSON.",items:{$ref:"#/definitions/Datum"},type:"array"}},required:["type","values"],type:"object"},JsonParseTransform:{additionalProperties:!1,description:"Parse JSON Object Array and append vertically",properties:{baseGenomicField:{description:"Base genomic position when parsing relative position.",type:"string"},field:{description:"The field that contains the JSON object array.",type:"string"},genomicField:{description:"Relative genomic position to parse.",type:"string"},genomicLengthField:{description:"Length of genomic interval.",type:"string"},type:{const:"subjson",type:"string"}},required:["type","field","baseGenomicField","genomicField","genomicLengthField"],type:"object"},Layout:{enum:["linear","circular"],type:"string"},LogBase:{anyOf:[{type:"number"},{const:"e",type:"string"}]},LogTransform:{additionalProperties:!1,properties:{base:{$ref:"#/definitions/LogBase",description:"If not specified, 10 is used."},field:{type:"string"},newField:{description:"If specified, store transformed values in a new field.",type:"string"},type:{const:"log",type:"string"}},required:["type","field"],type:"object"},LogicalOperation:{enum:["less-than","lt","LT","greater-than","gt","GT","less-than-or-equal-to","ltet","LTET","greater-than-or-equal-to","gtet","GTET"],type:"string"},Mark:{enum:["point","line","area","bar","rect","text","withinLink","betweenLink","rule","triangleLeft","triangleRight","triangleBottom","brush","header"],type:"string"},MatrixData:{additionalProperties:!1,properties:{binSize:{description:"Determine the number of nearby cells to aggregate. __Default__: `1`",type:"number"},column:{description:"The name of the first genomic field. __Default__: `x`",type:"string"},row:{description:"The name of the first genomic field. __Default__: `y`",type:"string"},type:{const:"matrix",type:"string"},url:{description:"URL link to the matrix data file",type:"string"},value:{description:"The name of the value field. __Default__: `value`",type:"string"}},required:["type","url"],type:"object"},MouseEventsDeep:{additionalProperties:!1,description:"Options for determining mouse events in detail, e.g., turning on specific events only",properties:{click:{description:"Whether to enable click events.",type:"boolean"},enableMouseOverOnMultipleMarks:{description:"Determine whether all marks underneath the mouse point should be affected by mouse over. __Default__: `false`",type:"boolean"},groupMarksByField:{description:"Group marks using keys in a data field. This affects how a set of marks are highlighted/selected by interaction. __Default__: `undefined`",type:"string"},mouseOver:{description:"Whether to enable mouseover events.",type:"boolean"},rangeSelect:{description:"Whether to send range selection events.",type:"boolean"}},type:"object"},MultipleViews:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},arrangement:{description:"Specify how multiple views are arranged.",enum:["parallel","serial","horizontal","vertical"],type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},id:{description:"The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view",type:"string"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},views:{description:"An array of view specifications",items:{anyOf:[{$ref:"#/definitions/SingleView"},{$ref:"#/definitions/MultipleViews"}]},type:"array"},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["views"],type:"object"},MultivecData:{additionalProperties:!1,description:'Two-dimensional quantitative values, one axis for genomic coordinate and the other for different samples, can be converted into HiGlass\' `"multivec"` data. For example, multiple BigWig files can be converted into a single multivec file. You can also convert sequence data (FASTA) into this format where rows will be different nucleotide bases (e.g., A, T, G, C) and quantitative values represent the frequency. Find out more about this format at [HiGlass Docs](https://docs.higlass.io/data_preparation.html#multivec-files).',properties:{aggregation:{$ref:"#/definitions/BinAggregate",description:'Determine aggregation function to apply within bins. __Default__: `"mean"`'},binSize:{description:"Binning the genomic interval in tiles (unit size: 256).",type:"number"},categories:{description:"assign names of individual samples.",items:{type:"string"},type:"array"},column:{description:'Assign a field name of the middle position of genomic intervals. __Default__: `"position"`',type:"string"},end:{description:'Assign a field name of the end position of genomic intervals. __Default__: `"end"`',type:"string"},row:{description:'Assign a field name of samples. __Default__: `"category"`',type:"string"},start:{description:'Assign a field name of the start position of genomic intervals. __Default__: `"start"`',type:"string"},type:{const:"multivec",type:"string"},url:{description:"Specify the URL address of the data file.",type:"string"},value:{description:'Assign a field name of quantitative values. __Default__: `"value"`',type:"string"}},required:["type","url"],type:"object"},OneOfFilter:{additionalProperties:!1,properties:{field:{description:"A filter is applied based on the values of the specified data field",type:"string"},not:{description:'when `{"not": true}`, apply a NOT logical operation to the filter.\n\n__Default:__ `false`',type:"boolean"},oneOf:{description:"Check whether the value is an element in the provided list.",items:{type:["string","number","null"]},type:"array"},type:{const:"filter",type:"string"}},required:["field","oneOf","type"],type:"object"},Opacity:{additionalProperties:!1,properties:{domain:{$ref:"#/definitions/ValueExtent",description:"Values of the data"},field:{description:"Name of the data field",type:"string"},range:{$ref:"#/definitions/ValueExtent",description:"Ranges of visual channel values"},type:{description:"Specify the data type",enum:["quantitative","nominal"],type:"string"}},type:"object"},Orientation:{enum:["horizontal","vertical"],type:"string"},OverlaidTrack:{additionalProperties:!1,description:"Superposing multiple tracks.",properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_overlay:{items:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"},stretchGraphics:{description:`Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts. + +When this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.`,type:"boolean"},stretchGraphicsThreshold:{default:1.5,description:"Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.",type:"number"}},type:"object"},flipY:{type:"boolean"},id:{description:"Assigned to `uid` in a HiGlass view config, used for API and caching.",type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},type:"object"},type:"array"},_renderingId:{description:"internal",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"},stretchGraphics:{description:`Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts. + +When this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.`,type:"boolean"},stretchGraphicsThreshold:{default:1.5,description:"Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.",type:"number"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{description:"Assigned to `uid` in a HiGlass view config, used for API and caching.",type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["_overlay"],type:"object"},OverlaidTracks:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{const:"overlay",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"},stretchGraphics:{description:`Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts. + +When this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.`,type:"boolean"},stretchGraphicsThreshold:{default:1.5,description:"Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.",type:"number"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{description:"The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view",type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{items:{$ref:"#/definitions/PartialTrack"},type:"array"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["alignment","tracks"],type:"object"},PartialTrack:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_overlay:{items:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"},stretchGraphics:{description:`Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts. + +When this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.`,type:"boolean"},stretchGraphicsThreshold:{default:1.5,description:"Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.",type:"number"}},type:"object"},flipY:{type:"boolean"},id:{description:"Assigned to `uid` in a HiGlass view config, used for API and caching.",type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},type:"object"},type:"array"},_renderingId:{description:"internal",type:"string"},assembly:{anyOf:[{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},{const:"unknown",description:"No assemblies can be associated with a dummy track",type:"string"}],description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},encoding:{additionalProperties:{$ref:"#/definitions/Channel"},type:"object"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"},stretchGraphics:{description:`Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts. + +When this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.`,type:"boolean"},stretchGraphicsThreshold:{default:1.5,description:"Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.",type:"number"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{description:"Assigned to `uid` in a HiGlass view config, used for API and caching.",type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{anyOf:[{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},{const:"linear",description:"Only linear layout are supported at this time",type:"string"}],description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{anyOf:[{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},{const:!0,description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"}],description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`."},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{anyOf:[{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},{$ref:"#/definitions/DummyTrackStyle",description:"Defines how the track is styled"}],description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},template:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},type:{const:"dummy-track",description:"Used to specify the dummy track",type:"string"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{anyOf:[{$ref:"#/definitions/ZoomLimits"},{description:"Unused property for DummyTrack",items:{type:"null"},maxItems:2,minItems:2,type:"array"}]}},type:"object"},PredefinedColors:{enum:["viridis","grey","spectral","warm","cividis","bupu","rdbu","hot","pink"],type:"string"},Range:{anyOf:[{$ref:"#/definitions/ValueExtent"},{$ref:"#/definitions/PredefinedColors"}]},RangeFilter:{additionalProperties:!1,properties:{field:{description:"A filter is applied based on the values of the specified data field",type:"string"},inRange:{description:"Check whether the value is in a number range.",items:{type:"number"},type:"array"},not:{description:'when `{"not": true}`, apply a NOT logical operation to the filter.\n\n__Default:__ `false`',type:"boolean"},type:{const:"filter",type:"string"}},required:["field","inRange","type"],type:"object"},ResponsiveSize:{anyOf:[{type:"boolean"},{additionalProperties:!1,properties:{height:{type:"boolean"},width:{type:"boolean"}},type:"object"}]},Row:{additionalProperties:!1,properties:{clip:{description:"Clip row when the actual y value exceeds the max value of the y scale. Used only for bar marks at the moment. __Default__: `true`",type:"boolean"},domain:{$ref:"#/definitions/ValueExtent",description:"Values of the data"},field:{description:"Name of the data field",type:"string"},grid:{description:"Whether to display grid. __Default__: `false`",type:"boolean"},legend:{description:"Whether to display legend. __Default__: `false`",type:"boolean"},padding:{description:"Determines the size of inner white spaces on the top and bottom of individiual rows. __Default__: `0`",type:"number"},range:{$ref:"#/definitions/ValueExtent",description:"Determine the start and end position of rendering area of this track along vertical axis. __Default__: `[0, height]`"},type:{const:"nominal",description:"Specify the data type",type:"string"}},type:"object"},SelectivityCondition:{additionalProperties:!1,properties:{measure:{enum:["width","height","aspectRatio"],type:"string"},operation:{$ref:"#/definitions/LogicalOperation"},target:{description:"Does the condition applied to the visualization itself or its container? __Default__: `'self'`",enum:["self","container"],type:"string"},threshold:{description:"Threshold in the unit of pixels.",type:"number"}},required:["operation","measure","threshold"],type:"object"},SingleTrack:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"},stretchGraphics:{description:`Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts. + +When this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.`,type:"boolean"},stretchGraphicsThreshold:{default:1.5,description:"Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.",type:"number"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{description:"Assigned to `uid` in a HiGlass view config, used for API and caching.",type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["data","mark"],type:"object"},SingleView:{anyOf:[{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{const:"overlay",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"},stretchGraphics:{description:`Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts. + +When this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.`,type:"boolean"},stretchGraphicsThreshold:{default:1.5,description:"Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.",type:"number"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{description:"The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view",type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},responsiveSpec:{items:{additionalProperties:!1,properties:{selectivity:{items:{$ref:"#/definitions/SelectivityCondition"},type:"array"},spec:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{enum:["overlay","stack"],type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"},stretchGraphics:{description:`Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts. + +When this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.`,type:"boolean"},stretchGraphicsThreshold:{default:1.5,description:"Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.",type:"number"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{description:"The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view",type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{anyOf:[{items:{$ref:"#/definitions/PartialTrack"},type:"array"},{items:{anyOf:[{$ref:"#/definitions/PartialTrack"},{$ref:"#/definitions/OverlaidTracks"}]},type:"array"}]},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},type:"object"}},required:["spec","selectivity"],type:"object"},type:"array"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{items:{$ref:"#/definitions/PartialTrack"},type:"array"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["alignment","tracks"],type:"object"},{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{const:"stack",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"},stretchGraphics:{description:`Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts. + +When this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.`,type:"boolean"},stretchGraphicsThreshold:{default:1.5,description:"Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.",type:"number"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{description:"The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view",type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},responsiveSpec:{items:{additionalProperties:!1,properties:{selectivity:{items:{$ref:"#/definitions/SelectivityCondition"},type:"array"},spec:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{enum:["overlay","stack"],type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"},stretchGraphics:{description:`Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts. + +When this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.`,type:"boolean"},stretchGraphicsThreshold:{default:1.5,description:"Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.",type:"number"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{description:"The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view",type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{anyOf:[{items:{$ref:"#/definitions/PartialTrack"},type:"array"},{items:{anyOf:[{$ref:"#/definitions/PartialTrack"},{$ref:"#/definitions/OverlaidTracks"}]},type:"array"}]},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},type:"object"}},required:["spec","selectivity"],type:"object"},type:"array"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{items:{anyOf:[{$ref:"#/definitions/PartialTrack"},{$ref:"#/definitions/OverlaidTracks"}]},type:"array"},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["tracks"],type:"object"},{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},id:{description:"The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view",type:"string"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},responsiveSpec:{items:{additionalProperties:!1,properties:{selectivity:{items:{$ref:"#/definitions/SelectivityCondition"},type:"array"},spec:{additionalProperties:!1,properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},alignment:{enum:["overlay","stack"],type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},baselineY:{type:"number"},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},color:{anyOf:[{$ref:"#/definitions/Color"},{$ref:"#/definitions/ChannelValue"}]},data:{$ref:"#/definitions/DataDeep"},dataTransform:{items:{$ref:"#/definitions/DataTransform"},type:"array"},displacement:{$ref:"#/definitions/Displacement"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},experimental:{additionalProperties:!1,properties:{mouseEvents:{anyOf:[{type:"boolean"},{$ref:"#/definitions/MouseEventsDeep"}]},performanceMode:{default:!1,description:"Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.",type:"boolean"},stretchGraphics:{description:`Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts. + +When this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.`,type:"boolean"},stretchGraphicsThreshold:{default:1.5,description:"Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.",type:"number"}},type:"object"},flipY:{type:"boolean"},height:{description:"Specify the track height in pixels.",type:"number"},id:{description:"The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view",type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},mark:{$ref:"#/definitions/Mark"},opacity:{anyOf:[{$ref:"#/definitions/Opacity"},{$ref:"#/definitions/ChannelValue"}]},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},overrideTemplate:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},row:{anyOf:[{$ref:"#/definitions/Row"},{$ref:"#/definitions/ChannelValue"}]},size:{anyOf:[{$ref:"#/definitions/Size"},{$ref:"#/definitions/ChannelValue"}]},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},stretch:{type:"boolean"},stroke:{anyOf:[{$ref:"#/definitions/Stroke"},{$ref:"#/definitions/ChannelValue"}]},strokeWidth:{anyOf:[{$ref:"#/definitions/StrokeWidth"},{$ref:"#/definitions/ChannelValue"}]},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},text:{anyOf:[{$ref:"#/definitions/Text"},{$ref:"#/definitions/ChannelValue"}]},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},tooltip:{items:{$ref:"#/definitions/Tooltip"},type:"array"},tracks:{anyOf:[{items:{$ref:"#/definitions/PartialTrack"},type:"array"},{items:{anyOf:[{$ref:"#/definitions/PartialTrack"},{$ref:"#/definitions/OverlaidTracks"}]},type:"array"}]},visibility:{items:{$ref:"#/definitions/VisibilityCondition"},type:"array"},width:{description:"Specify the track width in pixels.",type:"number"},x:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},x1e:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},xe:{anyOf:[{$ref:"#/definitions/X"},{$ref:"#/definitions/ChannelValue"}]},y:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},y1e:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},ye:{anyOf:[{$ref:"#/definitions/Y"},{$ref:"#/definitions/ChannelValue"}]},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},type:"object"}},required:["spec","selectivity"],type:"object"},type:"array"},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},tracks:{items:{$ref:"#/definitions/Track"},type:"array"},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["tracks"],type:"object"}]},Size:{additionalProperties:!1,properties:{domain:{$ref:"#/definitions/ValueExtent",description:"Values of the data"},field:{description:"Name of the data field",type:"string"},legend:{description:"not supported: Whether to display legend. __Default__: `false`",type:"boolean"},range:{$ref:"#/definitions/ValueExtent",description:"Ranges of visual channel values"},type:{description:"Specify the data type",enum:["quantitative","nominal"],type:"string"}},type:"object"},SizeVisibilityCondition:{additionalProperties:!1,properties:{conditionPadding:{description:"Specify the buffer size (in pixel) of width or height when calculating the visibility.\n\n__Default__: `0`",type:"number"},measure:{description:"Specify which aspect of the `target` will be compared to the `threshold`.",enum:["width","height"],type:"string"},operation:{$ref:"#/definitions/LogicalOperation",description:`A string that specifies the logical operation to conduct between \`threshold\` and the \`measure\` of \`target\`. Support + +- greater than : "greater-than", "gt", "GT" + +- less than : "less-than", "lt", "LT" + +- greater than or equal to : "greater-than-or-equal-to", "gtet", "GTET" + +- less than or equal to : "less-than-or-equal-to", "ltet", "LTET"`},target:{description:"Target specifies the object that you want to compare with the threshold.",enum:["track","mark"],type:"string"},threshold:{anyOf:[{type:"number"},{const:"|xe-x|",type:"string"}],description:'Specify the threshold as one of:\n\n- A number representing a fixed threshold in the unit of pixels;\n\n- `"|xe-x|"`, using the distance between `xe` and `x` as threshold'},transitionPadding:{description:"Specify the buffer size (in pixel) of width or height for smooth transition.\n\n__Default__: `0`",type:"number"}},required:["measure","operation","target","threshold"],type:"object"},StrConcatTransform:{additionalProperties:!1,properties:{fields:{items:{type:"string"},type:"array"},newField:{type:"string"},separator:{type:"string"},type:{const:"concat",type:"string"}},required:["type","fields","newField","separator"],type:"object"},StrReplaceTransform:{additionalProperties:!1,properties:{field:{type:"string"},newField:{type:"string"},replace:{items:{additionalProperties:!1,properties:{from:{type:"string"},to:{type:"string"}},required:["from","to"],type:"object"},type:"array"},type:{const:"replace",type:"string"}},required:["type","field","newField","replace"],type:"object"},Stroke:{additionalProperties:!1,properties:{domain:{$ref:"#/definitions/ValueExtent",description:"Values of the data"},field:{description:"Name of the data field",type:"string"},legend:{description:"Whether to display legend. __Default__: `false`",type:"boolean"},range:{$ref:"#/definitions/Range",description:"Ranges of visual channel values"},scaleOffset:{description:"Whether to use offset of the domain proportionally. This is bound to brushes on the color legend. __Default__: `[0, 1]`",items:{type:"number"},maxItems:2,minItems:2,type:"array"},title:{description:"Title of the legend. __Default__: `undefined`",type:"string"},type:{description:"Specify the data type",enum:["quantitative","nominal"],type:"string"}},type:"object"},StrokeWidth:{additionalProperties:!1,properties:{domain:{$ref:"#/definitions/ValueExtent",description:"Values of the data"},field:{description:"Name of the data field",type:"string"},range:{$ref:"#/definitions/ValueExtent",description:"Ranges of visual channel values"},type:{description:"Specify the data type",enum:["quantitative","nominal"],type:"string"}},type:"object"},Style:{additionalProperties:!1,properties:{align:{description:"Specify the alignment of marks. This property is currently only supported for `triangle` marks.",enum:["left","right"],type:"string"},background:{type:"string"},backgroundOpacity:{type:"number"},brush:{additionalProperties:!1,description:"Customize the style of the brush mark in the `rangeSelect` mouse event.",properties:{color:{description:"color of the marks when mouse events are triggered",type:"string"},opacity:{description:"opacity of the marks when mouse events are triggered",type:"number"},stroke:{description:"stroke color of the marks when mouse events are triggered",type:"string"},strokeOpacity:{type:"number"},strokeWidth:{description:"stroke width of the marks when mouse events are triggered",type:"number"}},type:"object"},curve:{description:"Specify the curve of `rule` marks.",enum:["top","bottom","left","right"],type:"string"},dashed:{description:"Specify the pattern of dashes and gaps for `rule` marks.",items:{type:"number"},maxItems:2,minItems:2,type:"array"},dx:{description:"Offset the position of marks in x direction. This property is currently only supported for `text` marks",type:"number"},dy:{description:"Offset the position of marks in y direction. This property is currently only supported for `text` marks.",type:"number"},enableSmoothPath:{description:"Whether to enable smooth paths when drawing curves.\n\n__Default__: `false`",type:"boolean"},inlineLegend:{description:"Specify whether to show legend in a single horizontal line?",type:"boolean"},legendTitle:{description:"If defined, show legend title on the top or left",type:"string"},linePattern:{additionalProperties:!1,description:"Specify the pattern of dashes and gaps for `rule` marks.",properties:{size:{type:"number"},type:{enum:["triangleLeft","triangleRight"],type:"string"}},required:["type","size"],type:"object"},linkConnectionType:{description:'Specify the connetion type of `betweenLink` marks.\n\n__Default__: `"corner"`',enum:["straight","curve","corner"],type:"string"},linkMinHeight:{description:"The minimum height of `withinLink` and `betweenLink` marks. Unit is a percentagle. __Default__: `0.5`",type:"number"},linkStyle:{description:"The style of `withinLink` and `betweenLink` marks. __Default__: `'circular'` `'elliptical'` will be used as a default option.",enum:["elliptical","circular","straight"],type:"string"},matrixExtent:{description:'Determine to show only one side of the diagonal in a HiGlass matrix. __Default__: `"full"`',enum:["full","upper-right","lower-left"],type:"string"},mouseOver:{$ref:"#/definitions/EventStyle",description:"Customize visual effects of `mouseOver` events on marks."},outline:{type:"string"},outlineWidth:{type:"number"},select:{$ref:"#/definitions/EventStyle",description:"Customize visual effects of `rangeSelect` events on marks ."},textAnchor:{description:"Specify the alignment of `text` marks to a given point.",enum:["start","middle","end"],type:"string"},textFontSize:{description:"Specify the font size of `text` marks. Can also be specified using the `size` channel option of `text` marks.",type:"number"},textFontWeight:{description:"Specify the font weight of `text` marks.",enum:["bold","normal"],type:"string"},textStroke:{description:"Specify the stroke of `text` marks. Can also be specified using the `stroke` channel option of `text` marks.",type:"string"},textStrokeWidth:{description:"Specify the stroke width of `text` marks. Can also be specified using the `strokeWidth` channel option of `text` marks.",type:"number"},withinLinkVerticalLines:{description:"Whether to show vertical lines that connect to the baseline (axis) when `y` and `ye` are both used. __Default__: `false`",type:"boolean"}},type:"object"},SvTypeTransform:{additionalProperties:!1,properties:{firstBp:{additionalProperties:!1,description:"Based on the BEDPE, infer SV types. SV types are specified as one of the following strings: DUP, TRA, DEL, t2tINV, h2hINV.",properties:{chrField:{type:"string"},posField:{type:"string"},strandField:{type:"string"}},required:["chrField","posField","strandField"],type:"object"},newField:{type:"string"},secondBp:{additionalProperties:!1,description:"Based on the BEDPE, infer SV types. SV types are specified as one of the following strings: DUP, TRA, DEL, t2tINV, h2hINV.",properties:{chrField:{type:"string"},posField:{type:"string"},strandField:{type:"string"}},required:["chrField","posField","strandField"],type:"object"},type:{const:"svType",type:"string"}},required:["type","firstBp","secondBp","newField"],type:"object"},TemplateTrack:{additionalProperties:!1,description:"Template specification that will be internally converted into `SingleTrack` for rendering.",properties:{_assignedHeight:{type:"number"},_assignedWidth:{description:"Internal: Used for responsive spec",type:"number"},_invalidTrack:{description:"internal",type:"boolean"},_renderingId:{description:"internal",type:"string"},assembly:{$ref:"#/definitions/Assembly",description:'A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`.\n\n__Note:__: with `"unknown"` assembly, genomic axes do not show chrN: in labels.'},centerRadius:{description:"Proportion of the radius of the center white space.\n\n__Default:__ `0.3`",type:"number"},data:{$ref:"#/definitions/DataDeep"},encoding:{additionalProperties:{$ref:"#/definitions/Channel"},type:"object"},endAngle:{description:'Specify the end angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},height:{description:"Specify the track height in pixels.",type:"number"},id:{description:"Assigned to `uid` in a HiGlass view config, used for API and caching.",type:"string"},innerRadius:{description:'Specify the inner radius of tracks when (`{"layout": "circular"}`).',type:"number"},layout:{$ref:"#/definitions/Layout",description:"Specify the layout type of all tracks."},linkingId:{description:"Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)",type:"string"},orientation:{$ref:"#/definitions/Orientation",description:"Specify the orientation."},outerRadius:{description:'Specify the outer radius of tracks when `{"layout": "circular"}`.',type:"number"},overlayOnPreviousTrack:{type:"boolean"},prerelease:{additionalProperties:!1,description:"internal",type:"object"},spacing:{description:"The size of the gap (1) between tracks, (2) between views, and (3) of the origin of circular tracks. The effect of this property depends on where on the spec you specify the `spacing`.\n\nIn a linear layout, this value is used in pixels, while in a circular layout, this value is used relative to the height of the tracks or views.",type:"number"},startAngle:{description:'Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`).',type:"number"},static:{description:"Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.",type:"boolean"},style:{$ref:"#/definitions/Style",description:"Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)."},subtitle:{type:"string"},template:{type:"string"},title:{description:"If defined, will show the textual label on the left-top corner of a track.",type:"string"},width:{description:"Specify the track width in pixels.",type:"number"},xAxis:{$ref:"#/definitions/AxisPosition",description:"not supported"},xDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic x-axis"},xOffset:{description:"Specify the x offset of views in the unit of pixels",type:"number"},yDomain:{anyOf:[{$ref:"#/definitions/DomainInterval"},{$ref:"#/definitions/DomainChrInterval"},{$ref:"#/definitions/DomainChr"}],description:"Specify the visible region of genomic y-axis"},yOffset:{description:"Specify the y offset of views in the unit of pixels",type:"number"},zoomLimits:{$ref:"#/definitions/ZoomLimits"}},required:["template","data"],type:"object"},Text:{additionalProperties:!1,properties:{domain:{description:"Values of the data",items:{type:"string"},type:"array"},field:{description:"Name of the data field",type:"string"},range:{description:"Ranges of visual channel values",items:{type:"string"},type:"array"},type:{description:"Specify the data type",enum:["quantitative","nominal"],type:"string"}},type:"object"},Tooltip:{additionalProperties:!1,properties:{alt:{description:"Name of the data field for showing in the tooltip. Will use the field name if not specified.",type:"string"},field:{description:"Specifiy a data field whose value will show in the tooltip.",type:"string"},format:{description:"format of the data value.",type:"string"},type:{$ref:"#/definitions/FieldType",description:"Type of the data field."}},required:["field","type"],type:"object"},Track:{anyOf:[{$ref:"#/definitions/SingleTrack"},{$ref:"#/definitions/OverlaidTrack"},{$ref:"#/definitions/DataTrack"},{$ref:"#/definitions/TemplateTrack"},{$ref:"#/definitions/DummyTrack"}]},ValueExtent:{anyOf:[{items:{type:"string"},type:"array"},{items:{type:"number"},type:"array"}]},VcfData:{additionalProperties:!1,description:"The Variant Call Format (VCF).",properties:{indexUrl:{description:"URL link to the tabix index file",type:"string"},sampleLength:{description:"The maximum number of rows to be loaded from the URL. __Default:__ `1000`",type:"number"},type:{const:"vcf",type:"string"},url:{description:"URL link to the VCF file",type:"string"}},required:["type","url","indexUrl"],type:"object"},VectorData:{additionalProperties:!1,description:'One-dimensional quantitative values along genomic position (e.g., bigwig) can be converted into HiGlass\' `"vector"` format data. Find out more about this format at [HiGlass Docs](https://docs.higlass.io/data_preparation.html#bigwig-files).',properties:{aggregation:{$ref:"#/definitions/BinAggregate",description:'Determine aggregation function to apply within bins. __Default__: `"mean"`'},binSize:{description:"Binning the genomic interval in tiles (unit size: 256).",type:"number"},column:{description:'Assign a field name of the middle position of genomic intervals. __Default__: `"position"`',type:"string"},end:{description:'Assign a field name of the end position of genomic intervals. __Default__: `"end"`',type:"string"},start:{description:'Assign a field name of the start position of genomic intervals. __Default__: `"start"`',type:"string"},type:{const:"vector",type:"string"},url:{description:"Specify the URL address of the data file.",type:"string"},value:{description:'Assign a field name of quantitative values. __Default__: `"value"`',type:"string"}},required:["type","url"],type:"object"},VisibilityCondition:{anyOf:[{$ref:"#/definitions/SizeVisibilityCondition"},{$ref:"#/definitions/ZoomLevelVisibilityCondition"}]},X:{additionalProperties:!1,properties:{aggregate:{$ref:"#/definitions/Aggregate",description:"Specify how to aggregate data. __Default__: `undefined`"},axis:{$ref:"#/definitions/AxisPosition",description:"Specify where should the axis be put"},domain:{$ref:"#/definitions/GenomicDomain",description:"Values of the data"},field:{description:"Name of the data field.",type:"string"},grid:{description:"Whether to display grid. __Default__: `false`",type:"boolean"},legend:{description:"Whether to display legend. __Default__: `false`",type:"boolean"},linkingId:{description:"Users need to assign a unique linkingId for [linking views](/docs/user-interaction#linking-views) and [Brushing and Linking](/docs/user-interaction#brushing-and-linking)",type:"string"},range:{$ref:"#/definitions/ValueExtent",description:"Values of the visual channel."},type:{const:"genomic",description:"Specify the data type.",type:"string"}},type:"object"},Y:{additionalProperties:!1,properties:{aggregate:{$ref:"#/definitions/Aggregate",description:"Specify how to aggregate data. __Default__: `undefined`"},axis:{$ref:"#/definitions/AxisPosition",description:"Specify where should the axis be put"},baseline:{description:"Custom baseline of the y-axis. __Default__: `0`",type:["string","number"]},domain:{anyOf:[{$ref:"#/definitions/ValueExtent"},{$ref:"#/definitions/GenomicDomain"}],description:"Values of the data"},field:{description:"Name of the data field.",type:"string"},flip:{description:"Whether to flip the y-axis. This is done by inverting the `range` property. __Default__: `false`",type:"boolean"},grid:{description:"Whether to display grid. __Default__: `false`",type:"boolean"},legend:{description:"Whether to display legend. __Default__: `false`",type:"boolean"},linkingId:{description:"Users need to assign a unique linkingId for [linking views](/docs/user-interaction#linking-views) and [Brushing and Linking](/docs/user-interaction#brushing-and-linking)",type:"string"},range:{$ref:"#/definitions/ValueExtent",description:"Values of the visual channel."},type:{description:"Specify the data type.",enum:["quantitative","nominal","genomic"],type:"string"},zeroBaseline:{description:"Specify whether to use zero baseline. __Default__: `true`",type:"boolean"}},type:"object"},ZoomLevelVisibilityCondition:{additionalProperties:!1,properties:{conditionPadding:{description:"Specify the buffer size (in pixel) of width or height when calculating the visibility.\n\n__Default__: `0`",type:"number"},measure:{const:"zoomLevel",description:"Specify which aspect of the `target` will be compared to the `threshold`.",type:"string"},operation:{$ref:"#/definitions/LogicalOperation",description:`A string that specifies the logical operation to conduct between \`threshold\` and the \`measure\` of \`target\`. Support + +- greater than : "greater-than", "gt", "GT" + +- less than : "less-than", "lt", "LT" + +- greater than or equal to : "greater-than-or-equal-to", "gtet", "GTET" + +- less than or equal to : "less-than-or-equal-to", "ltet", "LTET"`},target:{description:"Target specifies the object that you want to compare with the threshold.",enum:["track","mark"],type:"string"},threshold:{description:"Set a threshold in the unit of base pairs (bp)",type:"number"},transitionPadding:{description:"Specify the buffer size (in pixel) of width or height for smooth transition.\n\n__Default__: `0`",type:"number"}},required:["measure","operation","target","threshold"],type:"object"},ZoomLimits:{items:{type:["number","null"]},maxItems:2,minItems:2,type:"array"}},R9g={$ref:B9g,$schema:w9g,definitions:S9g};function V9g(e){return Z8e(R9g,e)}function Z8e(e,g,i=!1){const n=new OVt({extendRefs:!0}).compile(e),I=n(g);let r="",o="";return n.errors&&(o=JSON.stringify(n.errors,null,2),i||console.warn(o),r="⚠️ Some properties are incorrectly used."),{state:I?"success":"warn",message:r,details:o}}function G8e(e){let g=!0;const i=[];return S1(e).forEach(I=>{!Yle(I)&&I.mark!=="brush"&&I.mark!=="rule"&&(i.push("genomic type is not encoded to either a x- or y- axis"),g=!1);const r=I.color;I.mark==="line"&&pt(r)&&r.type==="quantitative"&&(i.push("`line` mark cannot be used with `quantitative` value"),g=!1)}),{valid:g,errorMessages:i}}function Yle(e){let g;return["x","y","xe","ye","x1","y1","x1e","y1e"].reverse().forEach(i=>{const n=e[i];pt(n)&&n.type==="genomic"&&(g=n)}),g}function v8e(e){let g;return["x","xe","y","ye","x1","y1","x1e","y1e"].reverse().forEach(i=>{const n=e[i];pt(n)&&n.type==="genomic"&&(g=i)}),g}const W9g=[{name:"gene",channels:[{name:"startPosition",type:"genomic",required:!0},{name:"endPosition",type:"genomic",required:!0},{name:"strandColor",type:"nominal",required:!0},{name:"strandRow",type:"nominal",required:!0},{name:"opacity",type:"value",required:!1},{name:"geneHeight",type:"value",required:!1},{name:"geneLabel",type:"nominal",required:!0},{name:"geneLabelColor",type:"nominal",required:!0},{name:"geneLabelFontSize",type:"value",required:!1},{name:"geneLabelStroke",type:"value",required:!1},{name:"geneLabelStrokeThickness",type:"value",required:!1},{name:"geneLabelOpacity",type:"value",required:!1},{name:"type",type:"nominal",required:!0}],mapping:[{dataTransform:[{type:"filter",base:"type",oneOf:["gene"]},{type:"filter",base:"strandColor",oneOf:["-"]}],mark:"triangleLeft",x:{base:"startPosition",type:"genomic"},size:{base:"geneHeight",value:12},row:{base:"strandRow",type:"nominal",domain:["+","-"]},color:{base:"strandColor",type:"nominal",domain:["+","-"],range:["blue","red"]},opacity:{base:"opacity",value:.4},style:{align:"right"}},{dataTransform:[{type:"filter",base:"type",oneOf:["gene"]},{type:"filter",base:"strandColor",oneOf:["+"]}],mark:"triangleRight",x:{base:"endPosition",type:"genomic"},size:{base:"geneHeight",value:12},row:{base:"strandRow",type:"nominal",domain:["+","-"]},color:{base:"strandColor",type:"nominal",domain:["+","-"],range:["blue","red"]},opacity:{base:"opacity",value:.4},style:{align:"left"}},{dataTransform:[{type:"filter",base:"type",oneOf:["exon"]}],mark:"rect",x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},size:{base:"geneHeight",value:12},row:{base:"strandRow",type:"nominal",domain:["+","-"]},color:{base:"strandColor",type:"nominal",domain:["+","-"],range:["blue","red"]},opacity:{base:"opacity",value:.4}},{dataTransform:[{type:"filter",base:"type",oneOf:["gene"]},{type:"filter",base:"strandColor",oneOf:["+"]}],mark:"rect",x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},row:{base:"strandRow",type:"nominal",domain:["+","-"]},color:{base:"strandColor",type:"nominal",domain:["+","-"],range:["blue","red"]},opacity:{base:"opacity",value:.4},size:{value:3}},{dataTransform:[{type:"filter",base:"type",oneOf:["gene"]},{type:"filter",base:"strandColor",oneOf:["-"]}],mark:"rect",x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},row:{base:"strandRow",type:"nominal",domain:["+","-"]},color:{base:"strandColor",type:"nominal",domain:["+","-"],range:["blue","red"]},opacity:{base:"opacity",value:.4},size:{value:3}},{dataTransform:[{type:"filter",base:"type",oneOf:["gene"]}],mark:"text",text:{base:"geneLabel",type:"nominal"},x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},row:{base:"strandRow",type:"nominal",domain:["+","-"]},color:{base:"geneLabelColor",type:"nominal",domain:["+","-"],range:["blue","red"]},opacity:{base:"opacity",value:1},size:{base:"geneLabelFontSize",value:18},stroke:{base:"geneLabelStroke",value:"white"},strokeWidth:{base:"geneLabelStrokeThickness",value:2},visibility:[{operation:"less-than",measure:"width",threshold:"|xe-x|",transitionPadding:10,target:"mark"}]}]},{name:"ideogram",channels:[{name:"startPosition",type:"genomic",required:!0},{name:"endPosition",type:"genomic",required:!0},{name:"chrHeight",type:"value",required:!1},{name:"name",type:"nominal",required:!0},{name:"stainBackgroundColor",type:"nominal",required:!0},{name:"stainLabelColor",type:"nominal",required:!0},{name:"stainStroke",type:"value",required:!1},{name:"stainStrokeWidth",type:"value",required:!1}],mapping:[{mark:"rect",dataTransform:[{type:"filter",base:"stainBackgroundColor",oneOf:["acen"],not:!0}],color:{base:"stainBackgroundColor",type:"nominal",domain:["gneg","gpos25","gpos50","gpos75","gpos100","gvar","acen"],range:["white","lightgray","gray","gray","black","#7B9CC8","#DC4542"]},size:{base:"chrHeight",value:18},x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},stroke:{base:"stainStroke",value:"gray"},strokeWidth:{base:"stainStrokeWidth",value:.3}},{mark:"triangleRight",dataTransform:[{type:"filter",base:"stainBackgroundColor",oneOf:["acen"]},{type:"filter",base:"name",include:"q"}],color:{base:"stainBackgroundColor",type:"nominal",domain:["gneg","gpos25","gpos50","gpos75","gpos100","gvar","acen"],range:["white","lightgray","gray","gray","black","#7B9CC8","#DC4542"]},size:{base:"chrHeight",value:18},x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},stroke:{base:"stainStroke",value:"gray"},strokeWidth:{base:"stainStrokeWidth",value:.3}},{mark:"triangleLeft",dataTransform:[{type:"filter",base:"stainBackgroundColor",oneOf:["acen"]},{type:"filter",base:"name",include:"p"}],color:{base:"stainBackgroundColor",type:"nominal",domain:["gneg","gpos25","gpos50","gpos75","gpos100","gvar","acen"],range:["white","lightgray","gray","gray","black","#7B9CC8","#DC4542"]},size:{base:"chrHeight",value:18},x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},stroke:{base:"stainStroke",value:"gray"},strokeWidth:{base:"stainStrokeWidth",value:.3}},{mark:"text",dataTransform:[{type:"filter",base:"stainLabelColor",oneOf:["acen"],not:!0}],color:{base:"stainLabelColor",type:"nominal",domain:["gneg","gpos25","gpos50","gpos75","gpos100","gvar"],range:["black","black","black","black","white","black"]},text:{base:"name",type:"nominal"},x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},visibility:[{operation:"less-than",measure:"width",threshold:"|xe-x|",transitionPadding:10,target:"mark"}]}]},{name:"sequence",channels:[{name:"startPosition",type:"genomic",required:!0},{name:"endPosition",type:"genomic",required:!0},{name:"barLength",type:"quantitative",required:!0},{name:"baseBackground",type:"nominal",required:!0},{name:"baseLabelColor",type:"nominal",required:!0},{name:"baseLabelFontSize",type:"value",required:!1}],mapping:[{mark:"bar",x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},y:{base:"barLength",type:"quantitative",axis:"none"},color:{base:"baseBackground",type:"nominal",domain:["A","T","G","C"]}},{dataTransform:[{type:"filter",base:"barLength",oneOf:[0],not:!0}],mark:"text",x:{base:"startPosition",type:"genomic"},xe:{base:"endPosition",type:"genomic"},color:{base:"baseLabelColor",type:"nominal",domain:["A","T","G","C"],range:["white"]},text:{base:"baseBackground",type:"nominal"},size:{base:"baseLabelFontSize",value:18},visibility:[{operation:"less-than",measure:"width",threshold:"|xe-x|",transitionPadding:30,target:"mark"},{operation:"LT",measure:"zoomLevel",threshold:10,target:"track"}]}]}];function X9g(e,g){IF(e,(i,n,I)=>{var r,o;if(!lSt(i))return;const{template:C}=i,a=g.find(c=>c.name===C);if(!a){i._invalidTrack=!0,console.warn(`There is no track template named '${C}'`);return}let A=!0;if(a.channels.forEach(c=>{c.required&&(!i.encoding||!(c.name in i.encoding))&&(A=!1,console.warn(`A template spec ('${C}') does not contain a required channel, ${c.name}`))}),!A){i._invalidTrack=!0;return}const s=JSON.parse(JSON.stringify(i));"encoding"in s&&delete s.encoding;const l={...s,alignment:"overlay",tracks:[],width:(r=i.width)!=null?r:100,height:(o=i.height)!=null?o:100};a.mapping.forEach(c=>{const u={data:i.data,mark:c.mark},{dataTransform:d}=c;d&&d.map(f=>{const m=f.base;m&&i.encoding&&m in i.encoding&&"field"in i.encoding[m]&&(delete f.base,f.field=i.encoding[m].field)});const h=i.encoding;h?Object.keys(c).filter(f=>f!=="mark").forEach(f=>{const m=JSON.parse(JSON.stringify(c[f]));if("base"in m){const b=m.base;if(b in h){const p=JSON.parse(JSON.stringify(h[b]));delete m.base;const y=Object.assign(m,JSON.parse(JSON.stringify(p)));u[f]=y}else delete m.base,u[f]=m}else u[f]=m}):Object.keys(c).filter(f=>f!=="mark").forEach(f=>{const m=JSON.parse(JSON.stringify(c[f]));"base"in m&&delete m.base,u[f]=m}),l.tracks.push(u)}),I[n]=l})}const hXe=["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],ks={color:hXe[0],size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:hXe,quantitativeSizeRange:[2,6]},T9g={base:"light",root:{background:"white",titleColor:"black",titleBackgroundColor:"transparent",titleFontSize:18,titleFontFamily:"Arial",titleAlign:"left",titleFontWeight:"bold",subtitleColor:"gray",subtitleBackgroundColor:"transparent",subtitleFontSize:16,subtitleFontFamily:"Arial",subtitleFontWeight:"normal",subtitleAlign:"left",showMousePosition:!0,mousePositionColor:"#000000"},track:{background:"transparent",alternatingBackground:"transparent",titleColor:"black",titleBackground:"white",titleFontSize:24,titleAlign:"left",outline:"black",outlineWidth:1},legend:{position:"top",background:"white",backgroundOpacity:.7,labelColor:"black",labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",backgroundStroke:"#DBDBDB",tickColor:"black"},axis:{tickColor:"black",labelColor:"black",labelMargin:5,labelExcludeChrPrefix:!1,labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",baselineColor:"black",gridColor:"#E3E3E3",gridStrokeWidth:1,gridStrokeType:"solid",gridStrokeDash:[4,4]},markCommon:{...ks},point:{...ks,size:3},rect:{...ks},triangle:{...ks},area:{...ks},line:{...ks},bar:{...ks},rule:{...ks,strokeWidth:1},link:{...ks,strokeWidth:1},text:{...ks,textAnchor:"middle",textFontWeight:"normal"},brush:{...ks,color:"gray",opacity:.3,stroke:"black",strokeWidth:1}},fXe=["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],H9g={color:fXe[0],size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:fXe,quantitativeSizeRange:[2,6]},Ys={...H9g,stroke:"white"},N9g={base:"dark",root:{background:"black",titleColor:"white",titleBackgroundColor:"transparent",titleFontSize:18,titleFontFamily:"Arial",titleAlign:"middle",titleFontWeight:"bold",subtitleColor:"lightgray",subtitleBackgroundColor:"transparent",subtitleFontSize:16,subtitleFontFamily:"Arial",subtitleAlign:"middle",subtitleFontWeight:"normal",showMousePosition:!0,mousePositionColor:"#FFFFFF"},track:{background:"transparent",alternatingBackground:"transparent",titleColor:"white",titleBackground:"black",titleFontSize:18,titleAlign:"left",outline:"white",outlineWidth:1},legend:{position:"right",background:"black",backgroundOpacity:.7,labelColor:"white",labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",backgroundStroke:"#DBDBDB",tickColor:"white"},axis:{tickColor:"white",labelMargin:5,labelExcludeChrPrefix:!1,labelColor:"white",labelFontSize:10,labelFontWeight:"normal",labelFontFamily:"Arial",baselineColor:"white",gridColor:"gray",gridStrokeWidth:1,gridStrokeType:"solid",gridStrokeDash:[4,4]},markCommon:{...Ys},point:{...Ys,size:3},rect:{...Ys},triangle:{...Ys},area:{...Ys},line:{...Ys},bar:{...Ys},rule:{...Ys,strokeWidth:1},link:{...Ys,strokeWidth:1},text:{...Ys,textAnchor:"middle",textFontWeight:"normal"},brush:{...Ys,color:"lightgray",opacity:.3,stroke:"white",strokeWidth:1}},mXe=["#D19000","#008F67","#005F96","#B86E97","#B55100","#4793BF","#C9C03"],Ks={color:mXe[0],size:1,stroke:"#3C3C3C",strokeWidth:0,opacity:1,nominalColorRange:mXe,quantitativeSizeRange:[2,6]},k9g={base:"warm",root:{background:"#FFF8E8",titleColor:"#3C3C3C",subtitleColor:"gray",showMousePosition:!0,mousePositionColor:"#3C3C3C"},track:{titleColor:"#3C3C3C",titleBackground:"#FFF8E8",outline:"#3C3C3C",outlineWidth:1},legend:{background:"#FFF8E8",backgroundOpacity:.7,labelColor:"#3C3C3C",backgroundStroke:"#3C3C3C",tickColor:"3C3C3C"},axis:{tickColor:"#3C3C3C",labelColor:"#3C3C3C",baselineColor:"#3C3C3C",gridColor:"#E3E3E3",gridStrokeWidth:1},markCommon:{...Ks},point:{...Ks,size:3},rect:{...Ks},triangle:{...Ks},area:{...Ks},line:{...Ks},bar:{...Ks},rule:{...Ks,strokeWidth:1},link:{...Ks,strokeWidth:1},text:{...Ks,textAnchor:"middle",textFontWeight:"normal"},brush:{...Ks,color:"lightgray",opacity:.3,stroke:"#3C3C3C",strokeWidth:1}},pXe=["#F66A62","#05B230","#5692FF","#D764D6","#86E9D4","#6E6AD7","#FFFB00"],xs={color:pXe[0],size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:pXe,quantitativeSizeRange:[2,6]},Y9g={base:"ggplot",root:{background:"white",titleColor:"black",titleFontSize:18,titleFontFamily:"Helvetica",titleAlign:"middle",titleFontWeight:"bold",titleBackgroundColor:"white",subtitleColor:"gray",subtitleFontSize:14,subtitleFontFamily:"Helvetica",subtitleAlign:"middle",subtitleFontWeight:"light",subtitleBackgroundColor:"white",showMousePosition:!0,mousePositionColor:"black"},track:{background:"#e8e8e8",alternatingBackground:"#d1d1d1",titleColor:"black",titleBackground:"white",outline:"black",outlineWidth:2},legend:{position:"right",background:"#e8e8e8",backgroundOpacity:1,labelColor:"black",backgroundStroke:"#e8e8e8",tickColor:"white"},axis:{tickColor:"white",labelColor:"black",baselineColor:"#e8e8e8",gridColor:"white",gridStrokeWidth:2},markCommon:{...xs},point:{...xs,size:3},rect:{...xs},triangle:{...xs},area:{...xs},line:{...xs},bar:{...xs},rule:{...xs,strokeWidth:1},link:{...xs,strokeWidth:1},text:{...xs,textAnchor:"middle",textFontWeight:"bold"},brush:{...xs,color:"black",opacity:.3,stroke:"black",strokeWidth:1}},bXe=["#37E649","#ED2D44","#AEAFEA","#EBAEAE","#CE7B3D","#8743E0","#5233F0"],Fs={color:bXe[0],size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:bXe,quantitativeSizeRange:[2,6]},K9g={base:"igv",root:{background:"white",titleColor:"white",titleAlign:"left",titleFontWeight:"bold",titleBackgroundColor:"#5f5f5f",subtitleColor:"#3b3b3b",subtitleAlign:"left",subtitleFontWeight:"bold",subtitleBackgroundColor:"#c4c4c4",showMousePosition:!0,mousePositionColor:"black"},track:{background:"white",alternatingBackground:"#e8e8e8",titleColor:"white",titleBackground:"#5F5F5F",outline:"#5F5F5F",outlineWidth:1},legend:{position:"top",background:"white",backgroundOpacity:1,labelColor:"black",backgroundStroke:"black",tickColor:"black"},axis:{tickColor:"black",labelColor:"black",baselineColor:"white",gridColor:"transparent",gridStrokeWidth:0},markCommon:{...Fs},point:{...Fs,size:3},rect:{...Fs},triangle:{...Fs},area:{...Fs},line:{...Fs},bar:{...Fs},rule:{...Fs,strokeWidth:1},link:{...Fs,strokeWidth:1},text:{...Fs,textAnchor:"middle",textFontWeight:"bold"},brush:{...Fs,color:"white",opacity:.3,stroke:"black",strokeWidth:1}},yXe=["#CD9B1D","#8A668B","#40E0D0","#FF6969","#666666","#FAC902","#FE0000","#CC96CD","#D9D9D9"],Es={color:yXe[0],size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:yXe,quantitativeSizeRange:[2,6]},x9g={base:"ensembl",root:{background:"white",titleColor:"#494949",titleFontSize:24,titleFontFamily:"GGX88",titleAlign:"left",titleFontWeight:"bold",titleBackgroundColor:"white",subtitleColor:"white",subtitleFontSize:19,subtitleFontFamily:"GGX88",subtitleAlign:"left",subtitleFontWeight:"normal",subtitleBackgroundColor:"#7B8BAF",mousePositionColor:"#FE0000",showMousePosition:!0},track:{background:"white",alternatingBackground:"#fffdf7",titleColor:"black",titleBackground:"white",titleAlign:"left",outline:"#7B8BAF",outlineWidth:2},legend:{tickColor:"black",labelColor:"black",labelFontWeight:"normal",labelFontFamily:"GGX88",background:"white",backgroundOpacity:2,backgroundStroke:"lightgray"},axis:{tickColor:"black",labelColor:"black",labelFontFamily:"GGX88",baselineColor:"black",gridColor:"#7B8BAF",gridStrokeWidth:2},markCommon:{...Es},point:{...Es,size:3},rect:{...Es},triangle:{...Es},area:{...Es},line:{...Es},bar:{...Es},rule:{...Es,strokeWidth:1},link:{...Es,strokeWidth:1},text:{...Es,textAnchor:"middle",textFontWeight:"normal"},brush:{...Es,color:"gray",opacity:.3,stroke:"black",strokeWidth:1}},ZXe=["#3A62FE","#F85353","#3A62FE","#F85353","#DCA326","#03BF06","#BABABA"],Ds={color:ZXe[0],size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:ZXe,quantitativeSizeRange:[2,6]},F9g={base:"jbrowse",root:{background:"white",titleColor:"white",titleFontSize:20,titleFontFamily:"Roboto",titleAlign:"middle",titleFontWeight:"normal",titleBackgroundColor:"#0b243f",subtitleColor:"white",subtitleFontSize:18,subtitleFontFamily:"Roboto",subtitleAlign:"middle",subtitleFontWeight:"normal",subtitleBackgroundColor:"#732162",showMousePosition:!0,mousePositionColor:"#000000"},track:{background:"white",alternatingBackground:"white",titleAlign:"middle",titleColor:"white",titleBackground:"#0B243F",outline:"black",outlineWidth:1},legend:{position:"top",background:"white",backgroundOpacity:.7,labelColor:"#DCA326",labelFontWeight:"bold",labelFontFamily:"Roboto",backgroundStroke:"#black",tickColor:"black"},axis:{tickColor:"black",labelColor:"#DCA326",labelFontWeight:"bold",labelFontFamily:"Roboto",baselineColor:"black",gridColor:"#c5d5d9",gridStrokeWidth:1},markCommon:{...Ds},point:{...Ds,size:3},rect:{...Ds},triangle:{...Ds},area:{...Ds},line:{...Ds},bar:{...Ds},rule:{...Ds,strokeWidth:1},link:{...Ds,strokeWidth:1},text:{...Ds,textAnchor:"middle",textFontWeight:"normal"},brush:{...Ds,color:"#c5d5d9",opacity:.3,stroke:"black",strokeWidth:1}},GXe=["#3A5FCD","#FFA54E","#8FBC8F","#B6709B","#EE6A50","#CCB79E","#DADA8F","#00CDCC","#EED5D2","#CD8EDD","#9ACD31","#D1BEA8","#FFB6C0"],Ms={color:GXe[0],size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:GXe,quantitativeSizeRange:[2,6]},E9g={base:"ucsc",root:{background:"white",titleColor:"white",titleFontSize:22,titleAlign:"middle",titleFontWeight:"bold",titleBackgroundColor:"#00457c",subtitleColor:"black",subtitleAlign:"middle",subtitleFontWeight:"bold",subtitleBackgroundColor:"white",showMousePosition:!0,mousePositionColor:"#FE0000"},track:{background:"white",alternatingBackground:"#e3f7fc",titleColor:"#3A5FCD",titleBackground:"white",outline:"black",outlineWidth:1},legend:{position:"top",background:"white",backgroundOpacity:.7,labelColor:"black",labelFontWeight:"bold",backgroundStroke:"#DBDBDB",tickColor:"black"},axis:{tickColor:"black",labelColor:"#3A5FCD",labelFontWeight:"bold",baselineColor:"black",gridColor:"#E3E3E3",gridStrokeWidth:1},markCommon:{...Ms},point:{...Ms,size:3},rect:{...Ms},triangle:{...Ms},area:{...Ms},line:{...Ms},bar:{...Ms},rule:{...Ms,strokeWidth:1},link:{...Ms,strokeWidth:1},text:{...Ms,textAnchor:"middle",textFontWeight:"normal"},brush:{...Ms,color:"gray",opacity:.3,stroke:"black",strokeWidth:1}},vXe=["#6E12AC","#15C250","#E70FB1","#FF8E55","#A3B8F3","#DE5E59","#77AAAA","#F5CCCA"],zs={color:vXe[0],size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:vXe,quantitativeSizeRange:[2,6]},D9g={base:"washu",root:{background:"white",titleColor:"gray",titleAlign:"left",titleFontWeight:"normal",titleBackgroundColor:"white",subtitleColor:"lightgray",subtitleAlign:"left",subtitleFontWeight:"light",subtitleBackgroundColor:"white",showMousePosition:!0,mousePositionColor:"#000000"},track:{background:"white",titleColor:"gray",titleBackground:"white",titleAlign:"left",outline:"gray",outlineWidth:1},legend:{background:"white",backgroundOpacity:.5,labelColor:"gray",labelFontWeight:"light",backgroundStroke:"#DBDBDB",tickColor:"gray"},axis:{tickColor:"lightgray",labelColor:"gray",labelFontWeight:"light",baselineColor:"gray",gridColor:"transparent",gridStrokeWidth:0},markCommon:{...zs},point:{...zs,size:3},rect:{...zs},triangle:{...zs},area:{...zs},line:{...zs},bar:{...zs},rule:{...zs,strokeWidth:1},link:{...zs,strokeWidth:1},text:{...zs,textAnchor:"middle",textFontWeight:"normal"},brush:{...zs,color:"gray",opacity:.3,stroke:"gray",strokeWidth:1}},BXe=["#ED7D31","#4472C4","#FFC207","#76AE4F","#9E480E","#A5A5A5","#4472C4","#264378","#76AE4F","#5B9CD5"],Ps={color:BXe[0],size:1,stroke:"#5A5A5A",strokeWidth:0,opacity:1,nominalColorRange:BXe,quantitativeSizeRange:[2,6]},M9g={base:"excel",root:{background:"white",titleColor:"#5A5A5A",titleFontSize:30,titleFontFamily:"Calibri",titleAlign:"middle",titleFontWeight:"bold",titleBackgroundColor:"white",subtitleColor:"#5A5A5A",subtitleFontSize:22,subtitleFontFamily:"Calibri",subtitleAlign:"middle",subtitleFontWeight:"bold",subtitleBackgroundColor:"white",showMousePosition:!0,mousePositionColor:"#000000"},track:{background:"white",alternatingBackground:"#f5f5f5",titleColor:"#5A5A5A",titleBackground:"white",outline:"#5A5A5A",outlineWidth:1},legend:{position:"right",tickColor:"#5A5A5A",labelColor:"#5A5A5A",labelFontSize:12,labelFontWeight:"bold",labelFontFamily:"Calibri",background:"white",backgroundOpacity:.7,backgroundStroke:"#5A5A5A"},axis:{tickColor:"#5A5A5A",labelColor:"#5A5A5A",labelFontFamily:"Calibri",baselineColor:"#5A5A5A",gridColor:"#5A5A5A",gridStrokeWidth:1},markCommon:{...Ps},point:{...Ps,size:3},rect:{...Ps},triangle:{...Ps},area:{...Ps},line:{...Ps},bar:{...Ps},rule:{...Ps,strokeWidth:1},link:{...Ps,strokeWidth:1},text:{...Ps,textAnchor:"middle",textFontWeight:"normal"},brush:{...Ps,color:"#5A5A5A",opacity:.3,stroke:"#5A5A5A",strokeWidth:1}},wXe=["#4185f4","#DB4437","#F4B400","#0D9D58","#AA30C3","#FF6E02","#CBC74C"],_s={color:wXe[0],size:2,stroke:"black",strokeWidth:.3,opacity:1,nominalColorRange:wXe,quantitativeSizeRange:[2,6]},z9g={base:"google",root:{background:"white",titleColor:"#454545",titleFontSize:20,titleFontFamily:"Arial",titleAlign:"left",titleFontWeight:"normal",titleBackgroundColor:"white",subtitleColor:"#7d7d7d",subtitleFontSize:16,subtitleFontFamily:"Arial",subtitleAlign:"left",subtitleFontWeight:"light",subtitleBackgroundColor:"white",showMousePosition:!0,mousePositionColor:"#000000"},track:{background:"white",alternatingBackground:"#f5f5f5",titleColor:"#e8e8e8",titleBackground:"white",titleFontSize:12,titleAlign:"left",outline:"black",outlineWidth:1},legend:{position:"right",background:"white",backgroundOpacity:1,labelColor:"black",labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",backgroundStroke:"black",tickColor:"black"},axis:{labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",tickColor:"black",labelColor:"black",baselineColor:"black",gridColor:"black",gridStrokeWidth:1},markCommon:{..._s},point:{..._s,size:3},rect:{..._s},triangle:{..._s},area:{..._s},line:{..._s},bar:{..._s},rule:{..._s,strokeWidth:1},link:{..._s,strokeWidth:1},text:{..._s,textAnchor:"middle",textFontWeight:"normal"},brush:{..._s,color:"#999999",opacity:.3,stroke:"black",strokeWidth:.7}},sie={light:T9g,dark:N9g,warm:k9g,ggplot:Y9g,igv:K9g,ensembl:x9g,jbrowse:F9g,ucsc:E9g,washu:D9g,excel:M9g,google:z9g};function Aie(e){return Object.keys(sie).indexOf(e)!==-1}function qV(e){return Aie(e)?sie[e]:sie.light}function Kle(e,g){var i;function n(...I){if(!new.target)throw new Error('Uncaught TypeError: Class constructor cannot be invoked without "new"');return g(...I)}return n.config={...e,availableOptions:Object.keys((i=e.defaultOptions)!=null?i:{})},n}const P9g=200,_9g=6,O9g=2,B8e=7829367,J9g=' ',L9g={type:"axis-track",datatype:["multivec","epilogos"],local:!1,orientation:"1d-horizontal",thumbnail:new DOMParser().parseFromString(J9g,"text/xml").documentElement,defaultOptions:{innerRadius:340,outerRadius:310,startAngle:0,endAngle:360,width:700,height:700,layout:"linear",labelMargin:5,excludeChrPrefix:!1,labelPosition:"none",labelColor:"black",labelTextOpacity:.4,trackBorderWidth:0,trackBorderColor:"black",tickPositions:"even",fontSize:12,fontFamily:"sans-serif",fontWeight:"normal",color:"#808080",stroke:"#ffffff",backgroundColor:"transparent",showMousePosition:!1,tickColor:B8e}},U9g=(e,g,i)=>{const{absToChr:n,colorToHex:I,pixiTextToSvg:r,svgLine:o,showMousePosition:C}=e.utils;function a(s,l){return Object.assign(new e.libraries.PIXI.Text(s,l),{hashValue:Math.random()})}class A extends e.tracks.PixiTrack{constructor(){super(g,i),at(this,"allTexts"),at(this,"searchField"),at(this,"chromInfo"),at(this,"dataConfig"),at(this,"pTicksCircular"),at(this,"pTicks"),at(this,"gTicks"),at(this,"tickTexts"),at(this,"isShowGlobalMousePosition"),at(this,"pixiTextConfig"),at(this,"stroke"),at(this,"tickWidth"),at(this,"tickHeight"),at(this,"tickTextSeparation"),at(this,"tickColor"),at(this,"animate"),at(this,"hideMousePosition"),at(this,"gBoundTicks"),at(this,"leftBoundTick"),at(this,"rightBoundTick"),at(this,"is2d"),at(this,"texts");const{dataConfig:l,animate:c,chromInfoPath:u,isShowGlobalMousePosition:d}=g;this.searchField=null,this.dataConfig=l,this.allTexts=[],this.pTicksCircular=new e.libraries.PIXI.Graphics,this.pTicks=new e.libraries.PIXI.Graphics,this.pMain.addChild(this.pTicks),this.pMain.addChild(this.pTicksCircular),this.gTicks={},this.tickTexts={},this.options=i,this.isShowGlobalMousePosition=d,this.pixiTextConfig=Td({size:+this.options.fontSize,fontFamily:this.options.fontFamily,fontWeight:this.options.fontWeight,color:this.options.color,stroke:this.options.stroke,strokeThickness:2}),this.stroke=I(this.pixiTextConfig.stroke),this.tickWidth=P9g,this.tickHeight=_9g,this.tickTextSeparation=O9g,this.tickColor=I(this.options.tickColor),this.animate=c,this.pubSubs=[],this.options.showMousePosition&&!this.hideMousePosition&&(this.hideMousePosition=C(this,this.is2d,this.isShowGlobalMousePosition()));let h=u;h||(h=`${l.server}/chrom-sizes/?id=${l.tilesetUid}`);const f=this.options.assembly,m={},b={...In(f).size},p=[];Object.keys(In(f).size).forEach(y=>{m[y]={chr:y,pos:In(f).size[y]}}),Object.keys(In(f).interval).forEach(y=>{p.push({chr:y,pos:In(f).interval[y][0]})}),this.chromInfo={chrPositions:m,chromLengths:b,cumPositions:p},this.rerender(this.options,!0),this.draw(),this.animate()}initBoundsTicks(){this.pTicks&&(this.pMain.removeChild(this.pTicks),this.pTicks=null),this.gBoundTicks||(this.gBoundTicks=new e.libraries.PIXI.Graphics,this.leftBoundTick=a("",this.pixiTextConfig),this.rightBoundTick=a("",this.pixiTextConfig),this.gBoundTicks.addChild(this.leftBoundTick),this.gBoundTicks.addChild(this.rightBoundTick),this.pMain.addChild(this.gBoundTicks)),this.texts=[]}initChromLabels(){this.chromInfo&&(this.gBoundTicks&&(this.pMain.removeChild(this.gBoundTicks),this.gBoundTicks=void 0),this.pTicks||(this.pTicks=new e.libraries.PIXI.Graphics,this.pMain.addChild(this.pTicks)),this.texts=[],this.pTicks.removeChildren(),this.chromInfo.cumPositions.forEach(l=>{var c,u,d;const h=l.chr;this.gTicks[h]=new e.libraries.PIXI.Graphics,this.tickTexts[h]||(this.tickTexts[h]=[]);const f=this.options.excludeChrPrefix?h.replace("chr",""):h,m=a(f,this.pixiTextConfig);(c=this.pTicks)==null||c.addChild(m),(u=this.pTicks)==null||u.addChild(this.gTicks[h]),(d=this.texts)==null||d.push(m)}))}rerender(l,c){const u=JSON.stringify(l);!c&&u===this.prevOptions||(this.prevOptions=u,this.options=l,this.pixiTextConfig.fontSize=+this.options.fontSize?`${+this.options.fontSize}px`:this.pixiTextConfig.fontSize,this.pixiTextConfig.fill=this.options.color||this.pixiTextConfig.fill,this.pixiTextConfig.stroke=this.options.stroke||this.pixiTextConfig.stroke,this.stroke=I(this.pixiTextConfig.stroke),this.tickColor=this.options.tickColor?I(this.options.tickColor):B8e,this.options.tickPositions==="ends"&&this.options.layout!=="circular"?this.initBoundsTicks():this.initChromLabels(),super.rerender(l,c),this.options.showMousePosition&&!this.hideMousePosition&&(this.hideMousePosition=C(this,this.is2d,this.isShowGlobalMousePosition())),!this.options.showMousePosition&&this.hideMousePosition&&(this.hideMousePosition(),this.hideMousePosition=void 0))}formatTick(l){if(isNaN(l))return"null";const c=this._xScale.domain(),u=c[1]-c[0],d=lCe(l,u),h=mT(","),f=vz(`,.${d}`,u);let m=h;return this.options.tickFormat==="si"?m=f:this.options.tickFormat==="plain"?m=h:this.options.tickPositions==="ends"&&(m=f),m(l)}drawBoundsTicks(l,c){if(!this.gBoundTicks||!this.leftBoundTick||!this.rightBoundTick)return;const u=this.gBoundTicks;u.clear(),u.lineStyle(1,0);const d=this.options.reverseOrientation?0:this.dimensions[1],h=this.options.reverseOrientation?this.tickHeight:this.dimensions[1]-this.tickHeight;u.moveTo(1,d),u.lineTo(1,h),u.moveTo(this.dimensions[0]-1,d),u.lineTo(this.dimensions[0]-1,h),this.leftBoundTick.x=0,this.leftBoundTick.y=this.options.reverseOrientation?h+this.tickTextSeparation:h-this.tickTextSeparation,this.leftBoundTick.text=this.options.assembly==="unknown"?`${this.formatTick(l[1])}`:`${l[0]}: ${this.formatTick(l[1])}`,this.leftBoundTick.anchor.y=this.options.reverseOrientation?0:1,this.rightBoundTick.x=this.dimensions[0],this.rightBoundTick.text=this.options.assembly==="unknown"?`${this.formatTick(c[1])}`:`${c[0]}: ${this.formatTick(c[1])}`,this.rightBoundTick.y=this.options.reverseOrientation?h+this.tickTextSeparation:h-this.tickTextSeparation,this.rightBoundTick.anchor.y=this.options.reverseOrientation?0:1,this.rightBoundTick.anchor.x=1,this.flipText&&(this.leftBoundTick.scale.x=-1,this.leftBoundTick.anchor.x=1,this.rightBoundTick.scale.x=-1,this.rightBoundTick.anchor.x=0),this.leftBoundTick.tickLine=[1,this.dimensions[1],1,this.dimensions[1]-this.tickHeight],this.rightBoundTick.tickLine=[this.dimensions[0]-1,this.dimensions[1],this.dimensions[0]-1,this.dimensions[1]-this.tickHeight],this.tickTexts={},this.tickTexts.all=[this.leftBoundTick,this.rightBoundTick]}drawTicks(l){const c=this.gTicks[l.chr];c.visible=!0,c.clear();const u=+this.chromInfo.chromLengths[l.chr],d=Math.max(this._xScale(l.pos),0),h=Math.min(this._xScale(l.pos+u),this.dimensions[0]),f=(h-d)/this.tickWidth,b=vb().domain([Math.max(1,this._xScale.invert(0)-l.pos),Math.min(u,this._xScale.invert(this.dimensions[0])-l.pos)]).range([d,h]).ticks(f).filter(B=>Number.isInteger(B)),p=this.tickTexts[l.chr],y=this.tickHeight,Z=0;let v=y+this.tickTextSeparation;for(this.options.reverseOrientation&&(v=this.dimensions[1]-v);p.lengthb.length;){const B=p.pop();this.gTicks[l.chr].removeChild(B)}let G=0;for(;Gu){const V=R-u;R=u,S-=V}const w=[],T=b+G.height/2+3;for(let V=R;V>=S;V-=B/10){const X=Ig(V,u,T,u/2,d/2,h,f);w.push(new e.libraries.PIXI.Point(X.x,X.y))}return w.length===0?void 0:(l.updateText(),new e.libraries.PIXI.SimpleRope(l.texture,w))}draw(){if(this.allTexts=[],!this.texts)return;const l=n(this._xScale.domain()[0],this.chromInfo),c=n(this._xScale.domain()[1],this.chromInfo);if(!l||!c){console.warn("Empty chromInfo:",this.dataConfig,this.chromInfo);return}if(this.options.tickPositions==="ends"&&this.options.layout!=="circular"){if(!this.gBoundTicks)return;this.gBoundTicks.visible=!0,this.drawBoundsTicks(l,c);return}if(!this.pTicks)return;const u=this.options.layout==="circular";for(let h=0;h{this.tickTexts[h]&&this.tickTexts[h].forEach(f=>{f.visible=!1})}),this.pTicksCircular.removeChildren();for(let h=l[3];h<=c[3];h++){const f=this.chromInfo.cumPositions[h],m=f.pos+this.chromInfo.chromLengths[f.chr]/2,b=this._xScale(m),p=this.texts[h];p.anchor.x=.5,p.anchor.y=u?.5:this.options.reverseOrientation?0:1;let y;u?(y=this.addCurvedText(p,b),y&&this.pTicksCircular.addChild(y)):(p.x=b,p.y=this.dimensions[1]-d),p.updateTransform(),this.flipText&&(p.scale.x=-1);const Z=this.drawTicks(f);u?Z>0&&y&&this.pTicksCircular.removeChild(y):p.visible=Z<=0,this.allTexts.push({importance:p.hashValue,text:p,rope:y})}this.hideOverlaps(this.allTexts)}hideOverlaps(l){const c=new w2t;l.sort((u,d)=>d.importance-u.importance).forEach(({text:u,rope:d})=>{u.updateTransform();const h=u.getBounds(),f=this.options.labelMargin,m={minX:h.x-f,minY:h.y-f,maxX:h.x+h.width+f*2,maxY:h.y+h.height+f*2};f<0||!c.collides(m)?c.insert(m):(u.visible=!1,this.options.layout==="circular"&&d&&this.pTicksCircular.removeChild(d))})}setPosition(l){super.setPosition(l),[this.pMain.position.x,this.pMain.position.y]=this.position}zoomed(l,c){[...l.domain(),...c.domain()].filter(d=>isNaN(d)).length===0&&(this.xScale(l),this.yScale(c),this.draw())}exportSVG(){let l=null,c=null;super.exportSVG?[c,l]=super.exportSVG():(c=document.createElement("g"),l=c),c.setAttribute("class","chromosome-labels");const u=document.createElement("g");return l.appendChild(u),u.setAttribute("transform",`translate(${this.position[0]},${this.position[1]})`),this.allTexts.filter(d=>d.text.visible).forEach(d=>{const h=r(d.text);u.appendChild(h)}),Object.values(this.tickTexts).forEach(d=>{d.filter(h=>h.visible).forEach(h=>{if(!h.tickLine)return;let f=r(h);u.appendChild(f),f=o(h.x,this.options.reverseOrientation?0:this.dimensions[1],h.x,this.options.reverseOrientation?this.tickHeight:this.dimensions[1]-this.tickHeight,1,this.tickColor);const m=document.createElement("line");m.setAttribute("x1",String(h.tickLine[0])),m.setAttribute("y1",String(h.tickLine[1])),m.setAttribute("x2",String(h.tickLine[2])),m.setAttribute("y2",String(h.tickLine[3])),m.setAttribute("style","stroke: grey"),u.appendChild(f),u.appendChild(m)})}),[c,l]}}return new A},SXe=Kle(L9g,U9g);function lie(e,...g){if(!new.target)throw new Error('Uncaught TypeError: Class constructor cannot be invoked without "new"');class i extends e.tracks.SVGTrack{constructor(I){var r,o;super(...I),at(this,"circularBrushData"),at(this,"prevExtent");const[C,a]=I,{registerViewportChanged:A,removeViewportChanged:s,setDomainsCallback:l}=C;this.uid=sr(),this.options=a,this.hasFromView=!C.projectionXDomain,this.removeViewportChanged=s,this.setDomainsCallback=l,this.viewportXDomain=this.hasFromView?null:C.projectionXDomain,this.viewportYDomain=this.hasFromView?null:[0,0],this.prevExtent=[0,0],this.RR=.02;const c=[0,Math.PI*1.7];this.circularBrushData=this.getBrushData(c),this.brush=U2t().innerRadius((r=this.options.innerRadius)!=null?r:100).outerRadius((o=this.options.outerRadius)!=null?o:200),this.gBrush=this.gMain.append("g").attr("id",`brush-${this.uid}`).selectAll(".brush").data(this.circularBrushData).enter().append("path").attr("class","brush").attr("d",this.brush).attr("fill",this.options.projectionFillColor).attr("stroke",this.options.projectionStrokeColor).attr("fill-opacity",u=>u.type==="brush"?this.options.projectionFillOpacity:0).attr("stroke-opacity",u=>u.type==="brush"?this.options.projectionStrokeOpacity:0).attr("stroke-width",this.options.strokeWidth).style("pointer-events","all").style("cursor",u=>u.cursor).call(this.dragged()),A(this.uid,this.viewportChanged.bind(this)),this.draw()}getBrushData(I){return[{type:"brush",startAngle:I[0],endAngle:I[1],cursor:"grab"},{type:"start",startAngle:I[0],endAngle:I[0]+this.RR,cursor:"move"},{type:"end",startAngle:I[1]-this.RR,endAngle:I[1],cursor:"move"}]}cropExtent(I){let[r,o]=I,C=0;for(;(r>Math.PI*2||o>Math.PI*2||r<0||o<0)&&!(C++>10);)r>Math.PI*2||o>Math.PI*2?(r-=Math.PI*2,o-=Math.PI*2):(r<0||o<0)&&(r+=Math.PI*2,o+=Math.PI*2);return[r,o].sort((a,A)=>a-A)}updateBrush(I){let[r,o]=I;if(r<=er&&o<=er||r>=Math.PI*2-er&&o>=Math.PI*2-er){this.gBrush.attr("visibility","hidden");return}rMath.PI*2-er&&(r=Math.PI*2-er),oMath.PI*2-er&&(o=Math.PI*2-er),this.circularBrushData=this.getBrushData(I),this.gBrush.data(this.circularBrushData).attr("d",this.brush).attr("visibility","visible")}dragged(){const I=o=>{this.startEvent=o.sourceEvent,this.prevExtent=[this.circularBrushData[0].startAngle,this.circularBrushData[0].endAngle]},r=(o,C)=>{const[a,A]=this.position,[s,l]=this.dimensions,c=o.sourceEvent,u=this.startEvent.layerX-a,d=this.startEvent.layerY-A,h=c.layerX-a,f=c.layerY-A,m=Math.atan2(u-s/2,d-l/2)-Math.atan2(h-s/2,f-l/2);let[b,p]=this.prevExtent;if(C.type==="brush"){if(b=b+m,p=p+m,bR?(p+=S,b+=S):(b-=R,p-=R)}}else C.type==="start"?b=b+m:C.type==="end"&&(p=p+m);if([b,p]=this.cropExtent([b,p]),!this._xScale||!this._yScale)return;const y=(this.options.endAngle-this.options.startAngle)/360,Z=b-this.options.startAngle/360*Math.PI*2,v=p-this.options.startAngle/360*Math.PI*2,G=[this._xScale.invert(s-s*v/(Math.PI*2*y)),this._xScale.invert(s-s*Z/(Math.PI*2*y))],B=this.viewportYDomain;this.hasFromView||(this.viewportXDomain=G),this.setDomainsCallback(G,B),this.updateBrush([b,p])};return e.libraries.d3Drag.drag().on("start",I).on("drag",r)}draw(){if(!this._xScale||!this.yScale||!this.viewportXDomain||!this.viewportYDomain)return;const I=this._xScale(this.viewportXDomain[0]),r=this._xScale(this.viewportXDomain[1]),[o]=this.dimensions;let C=Si(I,o,this.options.startAngle,this.options.endAngle)+Math.PI/2,a=Si(r,o,this.options.startAngle,this.options.endAngle)+Math.PI/2;[a,C]=this.cropExtent([a,C]),this.updateBrush([a,C])}viewportChanged(I,r){const o=I.domain(),C=r.domain();this.viewportXDomain=o,this.viewportYDomain=C,this.draw()}remove(){this.removeViewportChanged(this.uid),super.remove()}rerender(){}zoomed(I,r){this.xScale(I),this.yScale(r),this.draw()}setPosition(I){super.setPosition(I),this.draw()}setDimensions(I){super.setDimensions(I),this.gBrush.attr("transform",`translate(${I[0]/2},${I[1]/2})`),this.draw()}}return new i(g)}const Q9g=' ';lie.config={type:"brush-track",datatype:["projection"],local:!1,projection:!0,orientation:"2d",thumbnail:new DOMParser().parseFromString(Q9g,"text/xml").documentElement,availableOptions:["innerRadius","outerRadius","startAngle","endAngle","axisPositionHorizontal","projectionFillColor","projectionStrokeColor","projectionFillOpacity","projectionStrokeOpacity","strokeWidth"],defaultOptions:{innerRadius:100,outerRadius:200,startAngle:0,endAngle:360,axisPositionHorizontal:"left",projectionFillColor:"#777",projectionStrokeColor:"#777",projectionFillOpacity:.3,projectionStrokeOpacity:.7,strokeWidth:1}};const RXe=3,j9g={color:"#777",stroke:"#777",strokeWidth:1,strokeOpacity:.7,opacity:.3};class $9g{constructor(g,i,n={}){at(this,"brushSelection"),at(this,"style"),at(this,"range"),at(this,"data"),at(this,"startEvent"),at(this,"prevExtent"),at(this,"offset"),at(this,"size"),at(this,"externals"),at(this,"emitter"),this.emitter=Q2t(),this.range=null,this.prevExtent=[0,0],this.data=this.rangeToData(0,0),this.offset=[0,0],this.size=0,this.externals={d3Selection:i.d3Selection,d3Drag:i.d3Drag},this.style=Object.assign({},j9g,n),this.brushSelection=g.selectAll(".genomic-range-brush").data(this.data).enter().append("rect").attr("class","genomic-range-brush").call(this.onDrag())}getRange(){return this.range}setSize(g){return this.size=g,this}setOffset(g,i){return this.offset=[g,i],this}updateRange(g){return g?(this.range=[Math.min(...g),Math.max(...g)],this.data=this.rangeToData(...this.range)):this.range=null,this}drawBrush(g=!1){const[i,n]=this.offset,I=this.size,r=o=>Math.abs(o.end-o.start);return this.brushSelection.data(this.data).attr("transform",o=>`translate(${i+o.start}, ${n+1})`).attr("width",o=>`${r(o)}px`).attr("height",`${I-2}px`).attr("fill",this.style.color).attr("stroke",this.style.stroke).attr("stroke-width",`${this.style.strokeWidth}px`).attr("fill-opacity",o=>o.type==="body"?this.style.opacity:0).attr("stroke-opacity",o=>o.type==="body"?this.style.strokeOpacity:0).attr("cursor",o=>o.cursor),this.emitter.emit("brush",this.getRange(),g),this}enable(){return this.brushSelection.attr("pointer-events","all"),this}disable(){return this.brushSelection.attr("pointer-events","none"),this}visible(){return this.brushSelection.attr("visibility","visible"),this}hidden(){return this.brushSelection.attr("visibility","hidden"),this}clear(){return this.updateRange(null).drawBrush().hidden().disable(),this}remove(){return this.brushSelection.remove(),this}rangeToData(g,i){return[{type:"body",cursor:"grab",start:g,end:i},{type:"start",cursor:"ew-resize",start:g-RXe,end:g},{type:"end",cursor:"ew-resize",start:i,end:i+RXe}]}onDrag(){const g=n=>{this.startEvent=n.sourceEvent,this.prevExtent=this.range},i=(n,I)=>{var r;const o=n.sourceEvent.layerX-this.startEvent.layerX;let[C,a]=(r=this.prevExtent)!=null?r:[0,0];I.type==="body"?(C+=o,a+=o):I.type==="start"?C+=o:I.type==="end"&&(a+=o),this.updateRange([C,a]).drawBrush()};return this.externals.d3Drag.drag().on("start",g).on("drag",i)}on(g,i){this.emitter.on(g,i)}}const q9g=([e,g],[i,n],[I,r],[o,C])=>{const a=Math.sqrt((e-i)**2+(g-n)**2);if(aMath.sqrt((e-i)**2+(g-n)**2)e<=i&&i<=g,tTg=(e,g,i=5)=>cie(e,g-i)&&cie(e,g+i),gTg=(e,g)=>g.filter((i,n)=>n%2===0).every(i=>cie(e,i)),iTg=([e,g],i,n=5)=>{let I,r,o,C,a=!1;for(let A=0;A0?h=Math.sqrt((g-C)**2+(e-o)**2):d<0?h=Math.sqrt((g-r)**2+(e-I)**2):h=Math.abs(s[0]*c[1]-s[1]*c[0])/Math.sqrt(s[0]**2+s[1]**2),h{let n,I,r,o,C=!1;for(let a=0,A=i.length-2;ag!=o>g&&e<(r-n)*(g-I)/(o-I)+n&&(C=!C),A=a;return C};class ITg{constructor(){at(this,"data"),this.data=[]}size(){return this.data.length}addPolygonBasedEvent(g,i){this.data.push({uid:sr(),type:"polygon",value:g,polygon:i})}addPointBasedEvent(g,i){this.data.push({uid:sr(),type:"point",value:g,polygon:i})}addLineBasedEvent(g,i){this.data.push({uid:sr(),type:"line",value:g,polygon:i})}clear(){this.data=[]}find(g,i,n=!1){const I=Array.from(this.data);return n&&I.reverse(),I.find(r=>this.isMouseWithin(r,g,i))}findAll(g,i,n=!1){const I=Array.from(this.data);return n&&I.reverse(),I.filter(r=>this.isMouseWithin(r,g,i))}getSiblings(g,i){const n=[],I=Array.from(new Set(g.map(r=>r.uid)));return g.forEach(r=>{const o=r.value[i];o&&n.push(...this.data.filter(C=>C.value[i]===o&&I.indexOf(C.uid)===-1))}),n}isMouseWithin(g,i,n){switch(g.type){case"point":return eTg([i,n],g.polygon);case"line":return iTg([i,n],g.polygon);case"polygon":default:return nTg([i,n],g.polygon)}}findAllWithinRange(g,i,n=!1){const I=Array.from(this.data);return n&&I.reverse(),I.filter(r=>this.isWithinRange(r,g,i))}isWithinRange(g,i,n){switch(g.type){case"point":return tTg([i,n],g.polygon[0],g.polygon[2]);case"line":case"polygon":default:return gTg([i,n],g.polygon)}}}const w8e="KCgpID0+IHsKICB2YXIgX19jcmVhdGUgPSBPYmplY3QuY3JlYXRlOwogIHZhciBfX2RlZlByb3AgPSBPYmplY3QuZGVmaW5lUHJvcGVydHk7CiAgdmFyIF9fZ2V0T3duUHJvcERlc2MgPSBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yOwogIHZhciBfX2dldE93blByb3BOYW1lcyA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eU5hbWVzOwogIHZhciBfX2dldFByb3RvT2YgPSBPYmplY3QuZ2V0UHJvdG90eXBlT2Y7CiAgdmFyIF9faGFzT3duUHJvcCA9IE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHk7CiAgdmFyIF9fbWFya0FzTW9kdWxlID0gKHRhcmdldCkgPT4gX19kZWZQcm9wKHRhcmdldCwgIl9fZXNNb2R1bGUiLCB7IHZhbHVlOiB0cnVlIH0pOwogIHZhciBfX2VzbSA9IChmbiwgcmVzKSA9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2RlQXQoaTIgKyAxKV0gPj4gNDsKICAgICAgICAgIGFycltjdXJCeXRlKytdID0gdG1wICYgMjU1OwogICAgICAgIH0KICAgICAgICBpZiAocGxhY2VIb2xkZXJzTGVuID09PSAxKSB7CiAgICAgICAgICB0bXAgPSByZXZMb29rdXBbYjY0LmNoYXJDb2RlQXQoaTIpXSA8PCAxMCB8IHJldkxvb2t1cFtiNjQuY2hhckNvZGVBdChpMiArIDEpXSA8PCA0IHwgcmV2TG9va3VwW2I2NC5jaGFyQ29kZUF0KGkyICsgMildID4+IDI7CiAgICAgICAgICBhcnJbY3VyQnl0ZSsrXSA9IHRtcCA+PiA4ICYgMjU1OwogICAgICAgICAgYXJyW2N1ckJ5dGUrK10gPSB0bXAgJiAyNTU7CiAgICAgICAgfQogICAgICAgIHJldHVybiBhcnI7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gdHJpcGxldFRvQmFzZTY0KG51bSkgewogICAgICAgIHJldHVybiBsb29rdXBbbnVtID4+IDE4ICYgNjNdICsgbG9va3VwW251bSA+PiAxMiAmIDYzXSArIGxvb2t1cFtudW0gPj4gNiAmIDYzXSArIGxvb2t1cFtudW0gJiA2M107CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZW5jb2RlQ2h1bmsodWludDgsIHN0YXJ0LCBlbmQpIHsKICAgICAgICB2YXIgdG1wOwogICAgICAgIHZhciBvdXRwdXQgPSBbXTsKICAgICAgICBmb3IgKHZhciBpMiA9IHN0YXJ0OyBpMiA8IGVuZDsgaTIgKz0gMykgewogICAgICAgICAgdG1wID0gKHVpbnQ4W2kyXSA8PCAxNiAmIDE2NzExNjgwKSArICh1aW50OFtpMiArIDFdIDw8IDggJiA2NTI4MCkgKyAodWludDhbaTIgKyAyXSAmIDI1NSk7CiAgICAgICAgICBvdXRwdXQucHVzaCh0cmlwbGV0VG9CYXNlNjQodG1wKSk7CiAgICAgICAgfQogICAgICAgIHJldHVybiBvdXRwdXQuam9pbigiIik7CiAgICAgIH0KICAgICA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zU0L2luZGV4LmpzCiAgdmFyIHJlcXVpcmVfaWVlZTc1NCA9IF9fY29tbW9uSlMoewogICAgIm5vZGVfbW9kdWxlcy8ucG5wbS9pZWVlNzU0QDEuMi4xL25vZGVfbW9kdWxlcy9pZWVlNzU0L2luZGV4LmpzIihleHBvcnRzKSB7CiAgICAgIGluaXRfYnVmZmVyX3NoaW0oKTsKICAgICAgZXhwb3J0cy5yZWFkID0gZnVuY3Rpb24oYnVmZmVyLCBvZmZzZXQsIGlzTEUsIG1MZW4sIG5CeXRlcykgewogICAgICAgIHZhciBlLCBtOwogICAgICAgIHZhciBlTGVuID0gbkJ5dGVzICogOCAtIG1MZW4gLSAxOwogICAgICAgIHZhciBlTWF4ID0gKDEgPDwgZUxlbikgLSAxOwogICAgICAgIHZhciBlQmlhcyA9IGVNYXggPj4gMTsKICAgICAgICB2YXIgbkJpdHMgPSAtNzsKICAgICAgICB2YXIgaSA9IGlzTEUgPyBuQnl0ZXMgLSAxIDogMDsKICAgICAgICB2YXIgZCA9IGlzTEUgPyAtMSA6IDE7CiAgICAgICAgdmFyIHMgPSBidWZmZXJbb2Zmc2V0ICsgaV07CiAgICAgICAgaSArPSBkOwogICAgICAgIGUgPSBzICYgKDEgPDwgLW5CaXRzKSAtIDE7CiAgICAgICAgcyA+Pj0gLW5CaXRzOwogICAgICAgIG5CaXRzICs9IGVMZW47CiAgICAgICAgZm9yICg7IG5CaXRzID4gMDsgZSA9IGUgKiAyNTYgKyBidWZmZXJbb2Zmc2V0ICsgaV0sIGkgKz0gZCwgbkJpdHMgLT0gOCkgewogICAgICAgIH0KICAgICAgICBtID0gZSAmICgxIDw8IC1uQml0cykgLSAxOwogICAgICAgIGUgPj49IC1uQml0czsKICAgICAgICBuQml0cyArPSBtTGVuOwogICAgICAgIGZvciAoOyBuQml0cyA+IDA7IG0gPSBtICogMjU2ICsgYnVmZmVyW29mZnNldCArIGldLCBpICs9IGQsIG5CaXRzIC09IDgpIHsKICAgICAgICB9CiAgICAgICAgaWYgKGUgPT09IDApIHsKICAgICAgICAgIGUgPSAxIC0gZUJpYXM7CiAgICAgICAgfSBlbHNlIGlmIChlID09PSBlTWF4KSB7CiAgICAgICAgICByZXR1cm4gbSA/IE5hTiA6IChzID8gLTEgOiAxKSAqIEluZmluaXR5OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBtID0gbSArIE1hdGgucG93KDIsIG1MZW4pOwogICAgICAgICAgZSA9IGUgLSBlQmlhczsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIChzID8gLTEgOiAxKSAqIG0gKiBNYXRoLnBvdygyLCBlIC0gbUxlbik7CiAgICAgIH07CiAgICAgIGV4cG9ydHMud3JpdGUgPSBmdW5jdGlvbihidWZmZXIsIHZhbHVlLCBvZmZzZXQsIGlzTEUsIG1MZW4sIG5CeXRlcykgewogICAgICAgIHZhciBlLCBtLCBjOwogICAgICAgIHZhciBlTGVuID0gbkJ5dGVzICogOCAtIG1MZW4gLSAxOwogICAgICAgIHZhciBlTWF4ID0gKDEgPDwgZUxlbikgLSAxOwogICAgICAgIHZhciBlQmlhcyA9IGVNYXggPj4gMTsKICAgICAgICB2YXIgcnQgPSBtTGVuID09PSAyMyA/IE1hdGgucG93KDIsIC0yNCkgLSBNYXRoLnBvdygyLCAtNzcpIDogMDsKICAgICAgICB2YXIgaSA9IGlzTEUgPyAwIDogbkJ5dGVzIC0gMTsKICAgICAgICB2YXIgZCA9IGlzTEUgPyAxIDogLTE7CiAgICAgICAgdmFyIHMgPSB2YWx1ZSA8IDAgfHwgdmFsdWUgPT09IDAgJiYgMSAvIHZhbHVlIDwgMCA/IDEgOiAwOwogICAgICAgIHZhbHVlID0gTWF0aC5hYnModmFsdWUpOwogICAgICAgIGlmIChpc05hTih2YWx1ZSkgfHwgdmFsdWUgPT09IEluZmluaXR5KSB7CiAgICAgICAgICBtID0gaXNOYU4odmFsdWUpID8gMSA6IDA7CiAgICAgICAgICBlID0gZU1heDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZSA9IE1hdGguZmxvb3IoTWF0aC5sb2codmFsdWUpIC8gTWF0aC5MTjIpOwogICAgICAgICAgaWYgKHZhbHVlICogKGMgPSBNYXRoLnBvdygyLCAtZSkpIDwgMSkgewogICAgICAgICAgICBlLS07CiAgICAgICAgICAgIGMgKj0gMjsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChlICsgZUJpYXMgPj0gMSkgewogICAgICAgICAgICB2YWx1ZSArPSBydCAvIGM7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICB2YWx1ZSArPSBydCAqIE1hdGgucG93KDIsIDEgLSBlQmlhcyk7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAodmFsdWUgKiBjID49IDIpIHsKICAgICAgICAgICAgZSsrOwogICAgICAgICAgICBjIC89IDI7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoZSArIGVCaWFzID49IGVNYXgpIHsKICAgICAgICAgICAgbSA9IDA7CiAgICAgICAgICAgIGUgPSBlTWF4OwogICAgICAgICAgfSBlbHNlIGlmIChlICsgZUJpYXMgPj0gMSkgewogICAgICAgICAgICBtID0gKHZhbHVlICogYyAtIDEpICogTWF0aC5wb3coMiwgbUxlbik7CiAgICAgICAgICAgIGUgPSBlICsgZUJpYXM7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBtID0gdmFsdWUgKiBNYXRoLnBvdygyLCBlQmlhcyAtIDEpICogTWF0aC5wb3coMiwgbUxlbik7CiAgICAgICAgICAgIGUgPSAwOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBmb3IgKDsgbUxlbiA+PSA4OyBidWZmZXJbb2Zmc2V0ICsgaV0gPSBtICYgMjU1LCBpICs9IGQsIG0gLz0gMjU2LCBtTGVuIC09IDgpIHsKICAgICAgICB9CiAgICAgICAgZSA9IGUgPDwgbUxlbiB8IG07CiAgICAgICAgZUxlbiArPSBtTGVuOwogICAgICAgIGZvciAoOyBlTGVuID4gMDsgYnVmZmVyW29mZnNldCArIGldID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CiAgICAgICAgICByZXR1cm4gdGhpcy5idWZmZXI7CiAgICAgICAgfQogICAgICB9KTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KEJ1ZmZlcjgucHJvdG90eXBlLCAib2Zmc2V0IiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHsKICAgICAgICAgIGlmICghQnVmZmVyOC5pc0J1ZmZlcih0aGlzKSkKICAgICAgICAgICAgcmV0dXJuIHZvaWQgMDsKICAgICAgICAgIHJldHVybiB0aGlzLmJ5dGVPZmZzZXQ7CiAgICAgICAgfQogICAgICB9KTsKICAgICAgZnVuY3Rpb24gY3JlYXRlQnVmZmVyKGxlbmd0aCkgewogICAgICAgIGlmIChsZW5ndGggPiBLX01BWF9MRU5HVEgpIHsKICAgICAgICAgIHRocm93IG5ldyBSYW5nZUVycm9yKCdUaGUgdmFsdWUgIicgKyBsZW5ndGggKyAnIiBpcyBpbnZhbGlkIGZvciBvcHRpb24gInNpemUiJyk7CiAgICAgICAgfQogICAgICAgIGNvbnN0IGJ1ZiA9IG5ldyBVaW50OEFycmF5KGxlbmd0aCk7CiAgICAgICAgT2JqZWN0LnNldFByb3RvdHlwZU9mKGJ1ZiwgQnVmZmVyOC5wcm90b3R5cGUpOwogICAgICAgIHJldHVybiBidWY7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gQnVmZmVyOChhcmcsIGVuY29kaW5nT3JPZmZzZXQsIGxlbmd0aCkgewogICAgICAgIGlmICh0eXBlb2YgYXJnID09PSAibnVtYmVyIikgewogICAgICAgICAgaWYgKHR5cGVvZiBlbmNvZGluZ09yT2Zmc2V0ID09PSAic3RyaW5nIikgewogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCdUaGUgInN0cmluZyIgYXJndW1lbnQgbXVzdCBiZSBvZiB0eXBlIHN0cmluZy4gUmVjZWl2ZWQgdHlwZSBudW1iZXInKTsKICAgICAgICAgIH0KICAgIC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oZWNrZWQob2JqLmxlbmd0aCkgfCAwOwogICAgICAgICAgY29uc3QgYnVmID0gY3JlYXRlQnVmZmVyKGxlbik7CiAgICAgICAgICBpZiAoYnVmLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICByZXR1cm4gYnVmOwogICAgICAgICAgfQogICAgICAgICAgb2JqLmNvcHkoYnVmLCAwLCAwLCBsZW4pOwogICAgICAgICAgcmV0dXJuIGJ1ZjsKICAgICAgICB9CiAgICAgICAgaWYgKG9iai5sZW5ndGggIT09IHZvaWQgMCkgewogICAgICAgICAgaWYgKHR5cGVvZiBvYmoubGVuZ3RoICE9PSAibnVtYmVyIiB8fCBudW1iZXJJc05hTihvYmoubGVuZ3RoKSkgewogICAgICAgICAgICByZXR1cm4gY3JlYXRlQnVmZmVyKDApOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIGZyb21BcnJheUxpa2Uob2JqKTsKICAgICAgICB9CiAgICAgICAgaWYgKG9iai50eXBlID09PSAiQnVmZmVyIiAmJiBBcnJheS5pc0FycmF5KG9iai5kYXRhKSkgewogICAgICAgICAgcmV0dXJuIGZyb21BcnJheUxpa2Uob2JqLmRhdGEpOwogICAgICAgIH0KICAgICAgfQogICAgICBmdW5jdGlvbiBjaGVja2VkKGxlbmd0aCkgewogICAgICAgIGlmIChsZW5ndGggPj0gS19NQVhfTEVOR1RIKSB7CiAgICAgICAgICB0aHJvdyBuZXcgUmFuZ2VFcnJvcigiQXR0ZW1wdCB0byBhbGxvY2F0ZSBCdWZmZXIgbGFyZ2VyIHRoYW4gbWF4aW11bSBzaXplOiAweCIgKyBLX01BWF9MRU5HVEgudG9TdHJpbmcoMTYpICsgIiBieXRlcyIpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gbGVuZ3RoIHwgMDsKICAgICAgfQogICAgICBmdW5jdGlvbiBTbG93QnVmZmVyKGxlbmd0aCkgewogICAgICAgIGlmICgrbGVuZ3RoICE9IGxlbmd0aCkgewogICAgICAgICAgbGVuZ3R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AgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoeCA8IHkpCiAgICAgICAgICByZXR1cm4gLTE7CiAgICAgICAgaWYgKHkgPCB4KQogICAgICAgICAgcmV0dXJuIDE7CiAgICAgICAgcmV0dXJuIDA7CiAgICAgIH07CiAgICAgIEJ1ZmZlcjguaXNFbmNvZGluZyA9IGZ1bmN0aW9uIGlzRW5jb2RpbmcoZW5jb2RpbmcpIHsKICAgICAgICBzd2l0Y2ggKFN0cmluZyhlbmNvZGluZykudG9Mb3dlckNhc2UoKSkgewogICAgICAgICAgY2FzZSAiaGV4IjoKICAgICAgICAgIGNhc2UgInV0ZjgiOgogICAgICAgICAgY2FzZSAidXRmLTgiOgogICAgICAgICAgY2FzZSAiYXNjaWkiOgogICAgICAgICAgY2FzZSAibGF0aW4xIjoKICAgICAgICAgIGNhc2UgImJpbmFyeSI6CiAgICAgICAgICBjYXNlICJiYXNlNjQiOgogICAgICAgICAgY2FzZSAidWNzMiI6CiAgICAgICAgICBjYXNlICJ1Y3MtMiI6CiAgICAgICAgICBjYXNlICJ1dGYxNmxlIjoKICAgICAgICAgIGNhc2UgInV0Zi0xNmxlIjoKICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfQogICAgICB9OwogICAgICBCdWZmZXI4LmNvbmNhdCA9IGZ1bmN0aW9uIGNvbmNhdChsaXN0LCBsZW5ndGgpIHsKICAgICAgICBpZiAoIUFycmF5LmlzQXJyYXkobGlzdCkpIHsKICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoJyJsaXN0IiBhcmd1bWVudCBtdXN0IGJlIGFuIEFycmF5IG9mIEJ1ZmZlcnMnKTsKICAgICAgICB9CiAgICAgICAgaWYgKGxpc3QubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICByZXR1cm4gQnVmZmVyOC5hbGxvYygwKTsKICAgICAgICB9CiAgICAgICAgbGV0IGk7CiAgICAgICAgaWYgKGxlbmd0aCA9PT0gdm9pZCAwKSB7CiAgICAgICAgICBsZW5ndGggPSAwOwogICAgICAgICAgZm9yIChpID0gMDsgaSA8IGxpc3QubGVuZ3RoOyArK2kpIHsKICAgICAgICAgICAgbGVuZ3RoICs9IGxpc3RbaV0ubGVuZ3RoOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjb25zdCBidWZmZXIgPSBCdWZmZXI4LmFsbG9jVW5zYWZlKGxlbmd0aCk7CiAgICAgICAgbGV0IHBvcyA9IDA7CiAgICAgICAgZm9yIChpID0gMDsgaSA8IGxpc3QubGVuZ3RoOyArK2kpIHsKICAgICAgICAgIGxldCBidWYgPSBsaXN0W2ldOwogICAgICAgICAgaWYgKGlzSW5zdGFuY2UoYnVmLCBVaW50OEFycmF5KSkgewogICAgICAgICAgICBpZiAocG9zICsgYnVmLmxlbmd0aCA+IGJ1ZmZlci5sZW5ndGgpIHsKICAgICAgICAgICAgICBpZiAoIUJ1ZmZlcjguaXNCdWZmZXIoYnVmKSkKICAgICAgICAgICAgICAgIGJ1ZiA9IEJ1ZmZlcjguZnJvbShidWYpOwogICAgICAgICAgICAgIGJ1Zi5jb3B5KGJ1ZmZlciwgcG9zKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBVaW50OEFycmF5LnByb3RvdHlwZS5zZXQuY2FsbChidWZmZXIsIGJ1ZiwgcG9zKTsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIGlmICghQnVmZmVyOC5pc0J1ZmZlcihidWYpKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoJyJsaXN0IiBhcmd1bWVudCBtdXN0IGJlIGFuIEFycmF5IG9mIEJ1ZmZlcnMnKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGJ1Zi5jb3B5KGJ1ZmZlciwgcG9zKTsKICAgICAgICAgIH0KICAgIC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gICAgICAgIHJldHVybiBsZW47CiAgICAgICAgICAgIGNhc2UgInV0ZjgiOgogICAgICAgICAgICBjYXNlICJ1dGYtOCI6CiAgICAgICAgICAgICAgcmV0dXJuIHV0ZjhUb0J5dGVzKHN0cmluZykubGVuZ3RoOwogICAgICAgICAgICBjYXNlICJ1Y3MyIjoKICAgICAgICAgICAgY2FzZSAidWNzLTIiOgogICAgICAgICAgICBjYXNlICJ1dGYxNmxlIjoKICAgICAgICAgICAgY2FzZSAidXRmLTE2bGUiOgogICAgICAgICAgICAgIHJldHVybiBsZW4gKiAyOwogICAgICAgICAgICBjYXNlICJoZXgiOgogICAgICAgICAgICAgIHJldHVybiBsZW4gPj4+IDE7CiAgICAgICAgICAgIGNhc2UgImJhc2U2NCI6CiAgICAgICAgICAgICAgcmV0dXJuIGJhc2U2NFRvQnl0ZXMoc3RyaW5nKS5sZW5ndGg7CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgaWYgKGxvd2VyZWRDYXNlKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gbXVzdE1hdGNoID8gLTEgOiB1dGY4VG9CeXRlcyhzdHJpbmcpLmxlbmd0aDsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgZW5jb2RpbmcgPSAoIiIgKyBlbmNvZGluZykudG9Mb3dlckNhc2UoKTsKICAgICAgICAgICAgICBsb3dlcmVkQ2FzZSA9IHRydWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIEJ1ZmZlcjguYnl0ZUxlbmd0aCA9IGJ5dGVMZW5ndGg7CiAgICAgIGZ1bmN0aW9uIHNsb3dUb1N0cmluZyhlbmNvZGluZywgc3RhcnQsIGVuZCkgewogICAgICAgIGxldCBsb3dlcmVkQ2FzZSA9IGZhbHNlOwogICAgICAgIGlmIChzdGFydCA9PT0gdm9pZCAwIHx8IHN0YXJ0IDwgMCkgewogICAgICAgICAgc3RhcnQgPSAwOwogICAgICAgIH0KICAgICAgICBpZiAoc3RhcnQgPiB0aGlzLmxlbmd0aCkgewogICAgICAgICAgcmV0dXJuICIiOwogICAgICAgIH0KICAgICAgICBpZiAoZW5kID09PSB2b2lkIDAgfHwgZW5kID4gdGhpcy5sZW5ndGgpIHsKICAgICAgICAgIGVuZCA9IHRoaXMubGVuZ3RoOwogICAgICAgIH0KICAgICAgICBpZiAoZW5kIDw9IDApIHsKICAgICAgICAgIHJldHVybiAiIjsKICAgICAgICB9CiAgICAgICAgZW5kID4+Pj0gMDsKICAgICAgICBzdGFydCA+Pj49IDA7CiAgICAgICAgaWYgKGVuZCA8PSBzdGFydCkgewogICAgICAgICAgcmV0dXJuICIiOwogICAgICAgIH0KICAgICAgICBpZiAoIWVuY29kaW5nKQogICAgICAgICAgZW5jb2RpbmcgPSAidXRmOCI7CiAgICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICAgIHN3aXRjaCAoZW5jb2RpbmcpIHsKICAgICAgICAgICAgY2FzZSAiaGV4IjoKICAgICAgICAgICAgICByZXR1cm4gaGV4U2xpY2UodGhpcywgc3RhcnQsIGVuZCk7CiAgICAgICAgICAgIGNhc2UgInV0ZjgiOgogICAgICAgICAgICBjYXNlICJ1dGYtOCI6CiAgICAgICAgICAgICAgcmV0dXJuIHV0ZjhTbGljZSh0aGlzLCBzdGFydCwgZW5kKTsKICAgICAgICAgICAgY2FzZSAiYXNjaWkiOgogICAgICAgICAgICAgIHJldHVybiBhc2NpaVNsaWNlKHRoaXMsIHN0YXJ0LCBlbmQpOwogICAgICAgICAgICBjYXNlICJsYXRpbjEiOgogICAgICAgICAgICBjYXNlICJiaW5hcnkiOgogICAgICAgICAgICAgIHJldHVybiBsYXRpbjFTbGljZSh0aGlzLCBzdGFydCwgZW5kKTsKICAgICAgICAgICAgY2FzZSAiYmFzZTY0IjoKICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0U2xpY2UodGhpcywgc3RhcnQsIGVuZCk7CiAgICAgICAgICAgIGNhc2UgInVjczIiOgogICAgICAgICAgICBjYXNlICJ1Y3MtMiI6CiAgICAgICAgICAgIGNhc2UgInV0ZjE2bGUiOgogICAgICAgICAgICBjYXNlICJ1dGYtMTZsZSI6CiAgICAgICAgICAgICAgcmV0dXJuIHV0ZjE2bGVTbGljZSh0aGlzLCBzdGFydCwgZW5kKTsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICBpZiAobG93ZXJlZENhc2UpCiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCJVbmtub3duIGVuY29kaW5nOiAiICsgZW5jb2RpbmcpOwogICAgICAgICAgICAgIGVuY29kaW5nID0gKGVuY29kaW5nICsgIiIpLnRvTG93ZXJDYXNlKCk7CiAgICAgICAgICAgICAgbG93ZXJlZENhc2UgPSB0cnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBCdWZmZXI4LnByb3RvdHlwZS5faXNCdWZmZXIgPSB0cnVlOwogICAgICBmdW5jdGlvbiBzd2FwKGIsIG4sIG0pIHsKICAgICAgICBjb25zdCBpID0gYltuXTsKICAgICAgICBiW25dID0gYlttXTsKICAgICAgICBiW21dID0gaTsKICAgICAgfQogICAgICBCdWZmZXI4LnByb3RvdHlwZS5zd2FwMTYgPSBmdW5jdGlvbiBzd2FwMTYoKSB7CiAgICAgICAgY29uc3QgbGVuID0gdGhpcy5sZW5ndGg7CiAgICAgICAgaWYgKGxlbiAlIDIgIT09IDApIHsKICAgICAgICAgIHRocm93IG5ldyBSYW5nZUVycm9yKCJCdWZmZXIgc2l6ZSBtdXN0IGJlIGEgbXVsdGlwbGUgb2YgMTYtYml0cyIpOwogICAgICAgIH0KICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbjsgaSArPSAyKSB7CiAgICAgICAgICBzd2FwKHRoaXMsIGksIGkgKyAxKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgIH07CiAgICAgIEJ1ZmZlcjgucHJvdG90eXBlLnN3YXAzMiA9IGZ1bmN0aW9uIHN3YXAzMigpIHsKICAgICAgICBjb25zdCBsZW4gPSB0aGlzLmxlbmd0aDsKICAgICAgICBpZiAobGVuICUgNCAhPT0gMCkgewogICAgICAgICAgdGhyb3cgbmV3IFJhbmdlRXJyb3IoIkJ1ZmZlciBzaXplIG11c3QgYmUgYSBtdWx0aXBsZSBvZiAzMi1iaXRzIik7CiAgICAgICAgfQogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGVuOyBpICs9IDQpIHsKICAgICAgICAgIHN3YXAodGhpcywgaSwgaSArIDMpOwogICAgICAgICAgc3dhcCh0aGlzLCBpICsgMSwgaSArIDIpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gdGhpczsKICAgICAgfTsKICAgICAgQnVmZmVyOC5wcm90b3R5cGUuc3dhcDY0ID0gZnVuY3Rpb24gc3dhcDY0KCkgewogICAgICAgIGNvbnN0IGxlbiA9IHRoaXMubGVuZ3RoOwogICAgICAgIGlmIChsZW4gJSA4ICE9PSAwKSB7CiAgICAgICAgICB0aHJvdyBuZXcgUmFuZ2VFcnJvcigiQnVmZmVyIHNpemUgbXVzdCBiZSBhIG11bHRpcGxlIG9mIDY0LWJpdHMiKTsKICAgICAgICB9CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsZW47IGkgKz0gOCkgewogICAgICAgICAgc3dhcCh0aGlzLCBpLCBpICsgNyk7CiAgICAgICAgICBzd2FwKHRoaXMsIGkgKyAxLCBpICsgNik7CiAgICAgICAgICBzd2FwKHRoaXMsIGkgKyAyLCBpICsgNSk7CiAgICAgICAgICBzd2FwKHRoaXMsIGkgKyAzLCBpICsgNCk7CiAgICAgICAgfQogICAgICAgIHJldHVybiB0aGlzOwogICAgICB9OwogICAgICBCdWZmZXI4LnByb3RvdHlwZS50b1N0cmluZyA9IGZ1bmN0aW9uIHRvU3RyaW5nKCkgewogICAgICAgIGNvbnN0IGxlbmd0aCA9IHRoaXMubGVuZ3RoOwogICAgICAgIGlmIChsZW5ndGggPT09IDApCiAgICAgICAgICByZXR1cm4gIiI7CiAgICAgICAgaWYgKGFyZ3VtZW50cy5sZW5ndGggPT09IDApCiAgICAgICAgICByZXR1cm4gdXRmOFNsaWNlKHRoaXMsIDAsIGxlbmd0aCk7CiAgICAgICAgcmV0dXJuIHNsb3dUb1N0cmluZy5hcHBseSh0aGlzLCBhcmd1bWVudHMpOwogICAgICB9OwogICAgICBCdWZmZXI4LnByb3RvdHlwZS50b0xvY2FsZVN0cmluZyA9IEJ1ZmZlcjgucHJvdG90eXBlLnRvU3RyaW5nOwogICAgICBCdWZmZXI4LnByb3RvdHlwZS5lcXVhbHMgPSBmdW5jdGlvbiBlcXVhbHMoYikgewogICAgICAgIGlmICghQnVmZmVyOC5pc0J1ZmZlcihiKSkKICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoIkFyZ3VtZW50IG11c3QgYmUgYSBCdWZmZXIiKTsKICAgICAgICBpZiAodGhpcyA9PT0gYikKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIHJldHVybiBCdWZmZXI4LmNvbXBhcmUodGhpcywgYikgPT09IDA7CiAgICAgIH07CiAgICAgIEJ1ZmZlcjgucHJvdG90eXBlLmluc3BlY3QgPSBmdW5jdGlvbiBpbnNwZWN0KCkgewogICAgICAgIGxldCBzdHIgPSAiIjsKICAgICAgICBjb25zdCBtYXggPSBleHBvcnRzLklOU1BFQ1RfTUFYX0JZVEVTOwogICAgICAgIHN0ciA9IHRoaXMudG9TdHJpbmcoImhleCIsIDAsIG1heCkucmVwbGFjZSgvKC57Mn0pL2csICIkMSAiKS50cmltKCk7CiAgICAgICAgaWYgKHRoaXMubGVuZ3RoID4gbWF4KQogICAgICAgICAgc3RyICs9ICIgLi4uICI7CiAgICAgICAgcmV0dXJuICI8QnVmZmVyICIgKyBzdHIgKyAiPiI7CiAgICAgIH07CiAgICAgIGlmIChjdXN0b21JbnNwZWN0U3ltYm9sKSB7CiAgICAgICAgQnVmZmV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AgfHwgdGhpc0VuZCA+IHRoaXMubGVuZ3RoKSB7CiAgICAgICAgICB0aHJvdyBuZXcgUmFuZ2VFcnJvcigib3V0IG9mIHJhbmdlIGluZGV4Iik7CiAgICAgICAgfQogICAgICAgIGlmICh0aGlzU3RhcnQgPj0gdGhpc0VuZCAmJiBzdGFydCA+PSBlbmQpIHsKICAgICAgICAgIHJldHVybiAwOwogICAgICAgIH0KICAgICAgICBpZiAodGhpc1N0YXJ0ID49IHRoaXNFbmQpIHsKICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICB9CiAgICAgICAgaWYgKHN0YXJ0ID49IGVuZCkgewogICAgICAgICAgcmV0dXJuIDE7CiAgICAgICAgfQogICAgICAgIHN0YXJ0ID4+Pj0gMDsKICAgICAgICBlbmQgPj4+PSAwOwogICAgICAgIHRoaXNTdGFydCA+Pj49IDA7CiAgICAgICAgdGhpc0VuZCA+Pj49IDA7CiAgICAgICAgaWYgKHRoaXMgPT09IHRhcmdldCkKICAgICAgICAgIHJldHVybiAwOwogICAgICAgIGxldCB4ID0gdGhpc0VuZCAtIHRoaXNTdGFydDsKICAgICAgICBsZXQgeSA9IGVuZCAtIHN0YXJ0OwogICAgICAgIGNvbnN0IGxlbiA9IE1hdGgubWluKHgsIHkpOwogICAgICAgIGNvbnN0IHRoaXNDb3B5ID0gdGhpcy5zbGljZSh0aGlzU3RhcnQsIHRoaXNFbmQpOwogICAgICAgIGNvbnN0IHRhcmdldENvcHkgPSB0YXJnZXQuc2xpY2Uoc3RhcnQsIGVuZCk7CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsZW47ICsraSkgewogICAgICAgICAgaWYgKHRoaXNDb3B5W2ldICE9PSB0YXJnZXRDb3B5W2ldKSB7CiAgICAgICAgICAgIHggPSB0aGlzQ29weVtpXTsKICAgICAgICAgICAgeSA9IHRhcmdldENvcHlbaV07CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoeC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9IGJ1ZmZlci5sZW5ndGggLSAxOwogICAgICAgIH0gZWxzZSBpZiAoYnl0ZU9mZnNldCA8IDApIHsKICAgICAgICAgIGlmIChkaXIpCiAgICAgICAgICAgIGJ5dGVPZmZzZXQgPSAwOwogICAgICAgICAgZWxzZQogICAgICAgICAgICByZXR1cm4gLTE7CiAgICAgICAgfQogICAgICAgIGlmICh0eXBlb2YgdmFsID09PSAic3RyaW5nIikgewogICAgICAgICAgdmFsID0gQnVmZmVyOC5mcm9tKHZhbCwgZW5jb2RpbmcpOwogICAgICAgIH0KICAgICAgICBpZiAoQnVmZmVyOC5pc0J1ZmZlcih2YWwpKSB7CiAgICAgICAgICBpZiAodmFsLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICByZXR1cm4gLTE7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gYXJyYXlJbmRleE9mKGJ1ZmZlciwgdmFsLCBieXRlT2Zmc2V0LCBlbmNvZGluZywgZGlyKTsKICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiB2YWwgPT09ICJudW1iZXIiKSB7CiAgICAgICAgICB2YWwgPSB2YWwgJiAyNTU7CiAgICAgICAgICBpZiAodHlwZW9mIFVpbnQ4QXJyYXkucHJvdG90eXBlLmluZGV4T2YgPT09ICJmdW5jdGlvbiIpIHsKICAgICAgICAgICAgaWYgKGRpcikgewogICAgICAgICAgICAgIHJldHVybiBVaW50OEFycmF5LnByb3RvdHlwZS5pbmRleE9mLmNhbGwoYnVmZmVyLCB2YWwsIGJ5dGVPZmZzZXQpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHJldHVybiBVaW50OEFycmF5LnByb3RvdHlwZS5sYXN0SW5kZXhPZi5jYWxsKGJ1ZmZlciwgdmFsLCBieXRlT2Zmc2V0KTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIGFycmF5SW5kZXhPZihidWZmZXIsIFt2YWxdLCBieXRlT2Zmc2V0LCBlbmNvZGluZywgZGlyKTsKICAgICAgICB9CiAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcigidmFsIG11c3QgYmUgc3RyaW5nLCBudW1iZXIgb3IgQnVmZmVyIik7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gYXJyYXlJbmRleE9mKGFyciwgdmFsLCBieXRlT2Zmc2V0LCBlbmNvZGluZywgZGlyKSB7CiAgICAgICAgbGV0IGluZGV4U2l6ZSA9IDE7CiAgICAgICAgbGV0IGFyckxlbmd0aCA9IGFyci5sZW5ndGg7CiAgICAgICAgbGV0IHZhbExlbmd0aCA9IHZhbC5sZW5ndGg7CiAgICAgICAgaWYgKGVuY29kaW5nICE9PSB2b2lkIDApIHsKICAgICAgICAgIGVuY29kaW5nID0gU3RyaW5nKGVuY29kaW5nKS50b0xvd2VyQ2FzZSgpOwogICAgICAgICAgaWYgKGVuY29kaW5nID09PSAidWNzMiIgfHwgZW5jb2RpbmcgPT09ICJ1Y3MtMiIgfHwgZW5jb2RpbmcgPT09ICJ1dGYxNmxlIiB8fCBlbmNvZGluZyA9PT0gInV0Zi0xNmxlIikgewogICAgICAgICAgICBpZiAoYXJyLmxlbmd0aCA8IDIgfHwgdmFsLmxlbmd0aCA8IDIpIHsKICAgICAgICAgICAgICByZXR1cm4gLTE7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaW5kZXhTaXplID0gMjsKICAgICAgICAgICAgYXJyTGVuZ3RoIC89IDI7CiAgICAgICAgICAgIHZhbExlbmd0aCAvPSAyOwogICAgICAgICAgICBieXRlT2Zmc2V0IC89IDI7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGZ1bmN0aW9uIHJlYWQoYnVmLCBpMikgewogICAgICAgICAgaWYgKGluZGV4U2l6ZSA9PT0gMSkgewogICAgICAgICAgICByZXR1cm4gYnVmW2kyXTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHJldHVybiBidWYucmVhZFVJbnQxNkJFKGkyICogaW5kZXhTaXplKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgbGV0IGk7CiAgICAgICAgaWYgKGRpcikgewogICAgICAgICAgbGV0IGZvdW5kSW5kZXggPSAtMTsKICAgICAgICAgIGZvciAoaSA9IGJ5dGVPZmZzZXQ7IGkgPCBhcnJMZW5ndGg7IGkrKykgewogICAgICAgICAgICBpZiAocmVhZChhcnIsIGkpID09PSByZWFkKHZhbCwgZm91bmRJbmRleCA9PT0gLTEgPyAwIDogaSAtIGZvdW5kSW5kZXgpKSB7CiAgICAgICAgICAgICAgaWYgKGZvdW5kSW5kZXggPT09IC0xKQogICAgICAgICAgICAgICAgZm91bmRJbmRleCA9IGk7CiAgICAgICAgICAgICAgaWYgKGkgLSBmb3VuZEluZGV4ICsgMSA9PT0gdmFsTGVuZ3RoKQogICAgICAgICAgICAgICAgcmV0dXJuIGZvdW5kSW5kZXggKiBpbmRleFNpemU7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgaWYgKGZvdW5kSW5kZXggIT09IC0xKQogICAgICAgICAgICAgICAgaSAtPSBpIC0gZm91bmRJbmRleDsKICAgICAgICAgICAgICBmb3VuZEluZGV4ID0gLTE7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgaWYgKGJ5dGVPZmZzZXQgKyB2YWxMZW5ndGggPiBhcnJMZW5ndGgpCiAgICAgICAgICAgIGJ5dGVPZmZzZXQgPSBhcnJMZW5ndGggLSB2YWxMZW5ndGg7CiAgICAgICAgICBmb3IgKGkgPSBieXRlT2Zmc2V0OyBpID49IDA7IGktLSkgewogICAgICAgICAgICBsZXQgZm91bmQgPSB0cnVlOwogICAgICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IHZhbExlbmd0aDsgaisrKSB7CiAgICAgICAgICAgICAgaWYgKHJlYWQoYXJyLCBpICsgaikgIT09IHJlYWQodmFsLCBqKSkgewogICAgICAgICAgICAgICAgZm91bmQgPSBmY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7CiAgICAgICAgICAgIGVuY29kaW5nID0gbGVuZ3RoOwogICAgICAgICAgICBsZW5ndGggPSB2b2lkIDA7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiQnVmZmVyLndyaXRlKHN0cmluZywgZW5jb2RpbmcsIG9mZnNldFssIGxlbmd0aF0pIGlzIG5vIGxvbmdlciBzdXBwb3J0ZWQiKTsKICAgICAgICB9CiAgICAgICAgY29uc3QgcmVtYWluaW5nID0gdGhpcy5sZW5ndGggLSBvZmZzZXQ7CiAgICAgICAgaWYgKGxlbmd0aCA9PT0gdm9pZCAwIHx8IGxlbmd0aCA+IHJlbWFpbmluZykKICAgICAgICAgIGxlbmd0aCA9IHJlbWFpbmluZzsKICAgICAgICBpZiAoc3RyaW5nLmxlbmd0aCA+IDAgJiYgKGxlbmd0aCA8IDAgfHwgb2Zmc2V0IDwgMCkgfHwgb2Zmc2V0ID4gdGhpcy5sZW5ndGgpIHsKICAgICAgICAgIHRocm93IG5ldyBSYW5nZUVycm9yKCJBdHRlbXB0IHRvIHdyaXRlIG91dHNpZGUgYnVmZmVyIGJvdW5kcyIpOwogICAgICAgIH0KICAgICAgICBpZiAoIWVuY29kaW5nKQogICAgICAgICAgZW5jb2RpbmcgPSAidXRmOCI7CiAgICAgICAgbGV0IGxvd2VyZWRDYXNlID0gZmFsc2U7CiAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICBzd2l0Y2ggKGVuY29kaW5nKSB7CiAgICAgICAgICAgIGNhc2UgImhleCI6CiAgICAgICAgICAgICAgcmV0dXJuIGhleFdyaXRlKHRoaXMsIHN0cmluZywgb2Zmc2V0LCBsZW5ndGgpOwogICAgICAgICAgICBjYXNlICJ1dGY4IjoKICAgICAgICAgICAgY2FzZSAidXRmLTgiOgogICAgICAgICAgICAgIHJldHVybiB1dGY4V3JpdGUodGhpcywgc3RyaW5nLCBvZmZzZXQsIGxlbmd0aCk7CiAgICAgICAgICAgIGNhc2UgImFzY2lpIjoKICAgICAgICAgICAgY2FzZSAibGF0aW4xIjoKICAgICAgICAgICAgY2FzZSAiYmluYXJ5IjoKICAgICAgICAgICAgICByZXR1cm4gYXNjaWlXcml0ZSh0aGlzLCBzdHJpbmcsIG9mZnNldCwgbGVuZ3RoKTsKICAgICAgICAgICAgY2FzZSAiYmFzZTY0IjoKICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0V3JpdGUodGhpcywgc3RyaW5nLCBvZmZzZXQsIGxlbmd0aCk7CiAgICAgICAgICAgIGNhc2UgInVjczIiOgogICAgICAgICAgICBjYXNlICJ1Y3MtMiI6CiAgICAgICAgICAgIGNhc2UgInV0ZjE2bGUiOgogICAgICAgICAgICBjYXNlICJ1dGYtMTZsZSI6CiAgICAgICAgICAgICAgcmV0dXJuIHVjczJXcml0ZSh0aGlzLCBzdHJpbmcsIG9mZnNldCwgbGVuZ3RoKTsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICBpZiAobG93ZXJlZENhc2UpCiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCJVbmtub3duIGVuY29kaW5nOiAiICsgZW5jb2RpbmcpOwogICAgICAgICAgICAgIGVuY29kaW5nID0gKCIiICsgZW5jb2RpbmcpLnRvTG93ZXJDYXNlKCk7CiAgICAgICAgICAgICAgbG93ZXJlZENhc2UgPSB0cnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfTsKICAgICAgQnVmZmVyOC5wcm90b3R5cGUudG9KU09OID0gZnVuY3Rpb24gdG9KU09OKCkgewogICAgICAgIHJldHVybiB7CiAgICAgICAgICB0eXBlOiAiQnVmZmVyIiwKICAgICAgICAgIGRhdGE6IEFycmF5LnByb3RvdHlwZS5zbGljZS5jYWxsKHRoaXMuX2FyciB8fCB0aGlzLCAwKQogICAgICAgIH07CiAgICAgIH07CiAgICAgIGZ1bmN0aW9uIGJhc2U2NFNsaWNlKGJ1Ziwgc3RhcnQ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ZSAyOgogICAgICAgICAgICAgICAgc2Vjb25kQnl0ZSA9IGJ1ZltpICsgMV07CiAgICAgICAgICAgICAgICBpZiAoKHNlY29uZEJ5dGUgJiAxOTIpID09PSAxMjgpIHsKICAgICAgICAgICAgICAgICAgdGVtcENvZGVQb2ludCA9IChmaXJzdEJ5dGUgJiAzMSkgPDwgNiB8IHNlY29uZEJ5dGUgJiA2MzsKICAgICAgICAgICAgICAgICAgaWYgKHRlbXBDb2RlUG9pbnQgPiAxMjcpIHsKICAgICAgICAgICAgICAgICAgICBjb2RlUG9pbnQgPSB0ZW1wQ29kZVBvaW50OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgICAgICBzZWNvbmRCeXRlID0gYnVmW2kgKyAxXTsKICAgICAgICAgICAgICAgIHRoaXJkQnl0ZSA9IGJ1ZltpICsgMl07CiAgICAgICAgICAgICAgICBpZiAoKHNlY29uZEJ5dGUgJiAxOTIpID09PSAxMjggJiYgKHRoaXJkQnl0ZSAmIDE5MikgPT09IDEyOCkgewogICAgICAgICAgICAgICAgICB0ZW1wQ29kZVBvaW50ID0gKGZpcnN0Qnl0ZSAmIDE1KSA8PCAxMiB8IChzZWNvbmRCeXRlICYgNjMpIDw8IDYgfCB0aGlyZEJ5dGUgJiA2MzsKICAgICAgICAgICAgICAgICAgaWYgKHRlbXBDb2RlUG9pbnQgPiAyMDQ3ICYmICh0ZW1wQ29kZVBvaW50IDwgNTUyOTYgfHwgdGVtcENvZGVQb2ludCA+IDU3MzQzKSkgewogICAgICAgICAgICAgICAgICAgIGNvZGVQb2ludCA9IHRlbXBDb2RlUG9pbnQ7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGNhc2UgNDoKICAgICAgICAgICAgICAgIHNlY29uZEJ5dGUgPSBidWZbaSArIDFdOwogICAgICAgICAgICAgICAgdGhpcmRCeXRlID0gYnVmW2kgKyAyXTsKICAgICAgICAgICAgICAgIGZvdXJ0aEJ5dGUgPSBidWZbaSArIDNdOwogICAgICAgICAgICAgICAgaWYgKChzZWNvbmRCeXRlICYgMTkyKSA9PT0gMTI4ICYmICh0aGlyZEJ5dGUgJiAxOTIpID09PSAxMjggJiYgKGZvdXJ0aEJ5dGUgJiAxOTIpID09PSAxMjgpIHsKICAgICAgICAgICAgICAgICAgdGVtcENvZGVQb2ludCA9IChmaXJzdEJ5dGUgJiAxNSkgPDwgMTggfCAoc2Vjb25kQnl0ZSAmIDYzKSA8PCAxMiB8ICh0aGlyZEJ5dGUgJiA2MykgPDwgNiB8IGZvdXJ0aEJ5dGUgJiA2MzsKICAgICAgICAgICAgICAgICAgaWYgKHRlbXBDb2RlUG9pbnQgPiA2NTUzNSAmJiB0ZW1wQ29kZVBvaW50IDwgMTExNDExMikgewogICAgICAgICAgICAgICAgICAgIGNvZGVQb2ludCA9IHRlbXBDb2RlUG9pbnQ7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKGNvZGVQb2ludCA9PT0gbnVsbCkgewogICAgICAgICAgICBjb2RlUG9pbnQgPSA2NTUzMzsKICAgICAgICAgICAgYnl0ZXNQZXJTZXF1ZW5jZSA9IDE7CiAgICAgICAgICB9IGVsc2UgaWYgKGNvZGVQb2ludCA+IDY1NTM1KSB7CiAgICAgICAgICAgIGNvZGVQb2ludCAtPSA2NTUzNjsKICAgICAgICAgICAgcmVzLnB1c2goY29kZVBvaW50ID4+PiAxMCAmIDEwMjMgfCA1NTI5Nik7CiAgICAgICAgICAgIGNvZGVQb2ludCA9IDU2MzIwIHwgY29kZVBvaW50ICYgMTAyMzsKICAgICAgICAgIH0KICAgICAgICAgIHJlcy5wdXNoKGNvZGVQb2ludCk7CiAgICAgICAgICBpICs9IGJ5dGVzUGVyU2VxdWVuY2U7CiAgICAgICAgfQogICAgICAgIHJldHVybiBkZWNvZGVDb2RlUG9pbnRzQXJyYXkocmVzKTsKICAgICAgfQogICAgICB2YXIgTUFYX0FSR1VNRU5UU19MRU5HVEggPSA0MDk2OwogICAgICBmdW5jdGlvbiBkZWNvZGVDb2RlUG9pbnRzQXJyYXkoY29kZVBvaW50cykgewogICAgICAgIGNvbnN0IGxlbiA9IGNvZGVQb2ludHMubGVuZ3RoOwogICAgICAgIGlmIChsZW4gPD0gTUFYX0FSR1VNRU5UU19MRU5HVEgpIHsKICAgICAgICAgIHJldHVybiBTdHJpbmcuZnJvbUNoYXJDb2RlLmFwcGx5KFN0cmluZywgY29kZVBvaW50cyk7CiAgICAgICAgfQogICAgICAgIGxldCByZXMgPSAiIjsKICAgICAgICBsZXQgaSA9IDA7CiAgICAgICAgd2hpbGUgKGkgPCBsZW4pIHsKICAgICAgICAgIHJlcyArPSBTdHJpbmcuZnJvbUNoYXJDb2RlLmFwcGx5KFN0cmluZywgY29kZVBvaW50cy5zbGljZShpLCBpICs9IE1BWF9BUkdVTUVOVFNfTEVOR1RIKSk7CiAgICAgICAgfQogICAgICAgIHJldHVybiByZXM7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gYXNjaWlTbGljZShidWYsIHN0YXJ0LCBlbmQpIHsKICAgICAgICBsZXQgcmV0ID0gIiI7CiAgICAgICAgZW5kID0gTWF0aC5taW4oYnVmLmxlbmd0aCwgZW5kKTsKICAgICAgICBmb3IgKGxldCBpID0gc3RhcnQ7IGkgPCBlbmQ7ICsraSkgewogICAgICAgICAgcmV0ICs9IFN0cmluZy5mcm9tQ2hhckNvZGUoYnVmW2ldICYgMTI3KTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHJldDsKICAgICAgfQogICAgICBmdW5jdGlvbiBsYXRpbjFTbGljZShidWYsIHN0YXJ0LCBlbmQpIHsKICAgICAgICBsZXQgcmV0ID0gIiI7CiAgICAgICAgZW5kID0gTWF0aC5taW4oYnVmLmxlbmd0aCwgZW5kKTsKICAgICAgICBmb3IgKGxldCBpID0gc3RhcnQ7IGkgPCBlbmQ7ICsraSkgewogICAgICAgICAgcmV0ICs9IFN0cmluZy5mcm9tQ2hhckNvZGUoYnVmW2ldKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHJldDsKICAgICAgfQogICAgICBmdW5jdGlvbiBoZXhTbGljZShidWYsIHN0YXJ0LCBlbmQpIHsKICAgICAgICBjb25zdCBsZW4gPSBidWYubGVuZ3RoOwogICAgICAgIGlmICghc3RhcnQgfHwgc3RhcnQgPCAwKQogICAgICAgICAgc3RhcnQgPSAwOwogICAgICAgIGlmICghZW5kIHx8IGVuZCA8IDAgfHwgZW5kID4gbGVuKQogICAgICAgICAgZW5kID0gbGVuOwogICAgICAgIGxldCBvdXQgPSAiIjsKICAgICAgICBmb3IgKGxldCBpID0gc3RhcnQ7IGkgPCBlbmQ7ICsraSkgewogICAgICAgICAgb3V0ICs9IGhleFNsaWNlTG9va3VwVGFibGVbYnVmW2ldXTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIG91dDsKICAgICAgfQogICAgICBmdW5jdGlvbiB1dGYxNmxlU2xpY2UoYnVmLCBzdGFydCwgZW5kKSB7CiAgICAgICAgY29uc3QgYnl0ZXMgPSBidWYuc2xpY2Uoc3RhcnQsIGVuZCk7CiAgICAgICAgbGV0IHJlcyA9ICIiOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYnl0ZXMubGVuZ3RoIC0gMTsgaSArPSAyKSB7CiAgICAgICAgICByZXMgKz0gU3RyaW5nLmZyb21DaGFyQ29kZShieXRlc1tpXSArIGJ5dGVzW2kgKyAxXSAqIDI1Nik7CiAgICAgICAgfQogICAgICAgIHJldHVybiByZXM7CiAgICAgIH0KICAgICAgQnVmZmVyOC5wcm90b3R5cGUuc2xpY2UgPSBmdW5jdGlvbiBzbGljZShzdGFydCwgZW5kKSB7CiAgICAgICAgY29uc3Qg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VuY29kaW5nID0gc3RhcnQ7CiAgICAgICAgICAgIHN0YXJ0ID0gMDsKICAgICAgICAgICAgZW5kID0gdGhpcy5sZW5ndGg7CiAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBlbmQgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgIGVuY29kaW5nID0gZW5kOwogICAgICAgICAgICBlbmQgPSB0aGlzLmxlbmd0aDsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChlbmNvZGluZyAhPT0gdm9pZCAwICYmIHR5cGVvZiBlbmNvZGluZyAhPT0gInN0cmluZyIpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcigiZW5jb2RpbmcgbXVzdCBiZSBhIHN0cmluZyIpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHR5cGVvZiBlbmNvZGluZyA9PT0gInN0cmluZyIgJiYgIUJ1ZmZlcjguaXNFbmNvZGluZyhlbmNvZGluZykpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcigiVW5rbm93biBlbmNvZGluZzogIiArIGVuY29kaW5nKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh2YWwubGVuZ3RoID09PSAxKSB7CiAgICAgICAgICAgIGNvbnN0IGNvZGUgPSB2YWwuY2hhckNvZGVBdCgwKTsKICAgICAgICAgICAgaWYgKGVuY29kaW5nID09PSAidXRmOCIgJiYgY29kZSA8IDEyOCB8fCBlbmNvZGluZyA9PT0gImxhdGluMSIpIHsKICAgICAgICAgICAgICB2YWwgPSBjb2RlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgdmFsID09PSAibnVtYmVyIikgewogICAgICAgICAgdmFsID0gdmFsICYgMjU1OwogICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIHZhbCA9PT0gImJvb2xlYW4iKSB7CiAgICAgICAgICB2YWwgPSBOdW1iZXIodmFsKTsKICAgICAgICB9CiAgICAgICAgaWYgKHN0YXJ0IDwgMCB8fCB0aGlzLmxlbmd0aCA8IHN0YXJ0IHx8IHRoaXMubGVuZ3RoIDwgZW5kKSB7CiAgICAgICAgICB0aHJvdyBuZXcgUmFuZ2VFcnJvcigiT3V0IG9mIHJhbmdlIGluZGV4Iik7CiAgICAgICAgfQogICAgICAgIGlmIChlbmQgPD0gc3RhcnQpIHsKICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgIH0KICAgICAgICBzdGFydCA9IHN0YXJ0ID4+PiAwOwogICAgICAgIGVuZCA9IGVuZCA9PT0gdm9pZCAwID8gdGhpcy5sZW5ndGggOiBlbmQgPj4+IDA7CiAgICAgICAgaWYgKCF2YWwpCiAgICAgICAgICB2YWwgPSAwOwogICAgICAgIGxldCBpOwogICAgICAgIGlmICh0eXBlb2YgdmFsID09PSAibnVtYmVyIikgewogICAgICAgICAgZm9yIChpID0gc3RhcnQ7IGkgPCBlbmQ7ICsraSkgewogICAgICAgICAgICB0aGlzW2ldID0gdmFsOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb25zdCBieXRlcyA9IEJ1ZmZlcjguaXNCdWZmZXIodmFsKSA/IHZhbCA6IEJ1ZmZlcjguZnJvbSh2YWwsIGVuY29kaW5nKTsKICAgICAgICAgIGNvbnN0IGxlbiA9IGJ5dGVzLmxlbmd0aDsKICAgICAgICAgIGlmIChsZW4gPT09IDApIHsKICAgICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcignVGhlIHZhbHVlICInICsgdmFsICsgJyIgaXMgaW52YWxpZCBmb3IgYXJndW1lbnQgInZhbHVlIicpOwogICAgICAgICAgfQogICAgICAgICAgZm9yIChpID0gMDsgaSA8IGVuZCAtIHN0YXJ0OyArK2kpIHsKICAgICAgICAgICAgdGhpc1tpICsgc3RhcnRdID0gYnl0ZXNbaSAlIGxlbl07CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiB0aGlzOwogICAgICB9OwogICAgICB2YXIgZXJyb3JzID0ge307CiAgICAgIGZ1bmN0aW9uIEUoc3ltLCBnZXRNZXNzYWdlLCBCYXNlKSB7CiAgICAgICAgZXJyb3JzW3N5bV0gPSBjbGFzcyBOb2RlRXJyb3IgZXh0ZW5kcyBCYXNlIHsKICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICBzdXBlcigpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIm1lc3NhZ2UiLCB7CiAgICAgICAgICAgICAgdmFsdWU6IGdldE1lc3NhZ2UuYXBwbHkodGhpcywgYXJndW1lbnRzKSwKICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIHRoaXMubmFtZSA9IGAke3RoaXMubmFtZX0gWyR7c3ltfV1gOwogICAgICAgICAgICB0aGlzLnN0YWNrOwogICAgICAgICAgICBkZWxldGUgdGhpcy5uYW1lOwogICAgICAgICAgfQogICAgICAgICAgZ2V0IGNvZGUoKSB7CiAgICAgICAgICAgIHJldHVybiBzeW07CiAgICAgICAgICB9CiAgICAgICAgICBzZXQgY29kZSh2YWx1ZSkgewogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImNvZGUiLCB7CiAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgdmFsdWUsCiAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9CiAgICAgICAgICB0b1N0cmluZygpIHsKICAgICAgICAgICAgcmV0dXJuIGAke3RoaXMubmFtZX0gWyR7c3ltfV06ICR7dGhpcy5tZXNzYWdlfWA7CiAgICAgICAgICB9CiAgICAgICAgfTsKICAgICAgfQogICAgICBFKCJFUlJfQlVGRkVS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ludDsKICAgICAgICBjb25zdCBsZW5ndGggPSBzdHJpbmcubGVuZ3RoOwogICAgICAgIGxldCBsZWFkU3Vycm9nYXRlID0gbnVsbDsKICAgICAgICBjb25zdCBieXRlcyA9IFtdOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGVuZ3RoOyArK2kpIHsKICAgICAgICAgIGNvZGVQb2ludCA9IHN0cmluZy5jaGFyQ29kZUF0KGkpOwogICAgICAgICAgaWYgKGNvZGVQb2ludCA+IDU1Mjk1ICYmIGNvZGVQb2ludCA8IDU3MzQ0KSB7CiAgICAgICAgICAgIGlmICghbGVhZFN1cnJvZ2F0ZSkgewogICAgICAgICAgICAgIGlmIChjb2RlUG9pbnQgPiA1NjMxOSkgewogICAgICAgICAgICAgICAgaWYgKCh1bml0cyAtPSAzKSA+IC0xKQogICAgICAgICAgICAgICAgICBieXRlcy5wdXNoKDIzOSwgMTkxLCAxODkpOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgfSBlbHNlIGlmIChpICsgMSA9PT0gbGVuZ3RoKSB7CiAgICAgICAgICAgICAgICBpZiAoKHVuaXRzIC09IDMpID4gLTEpCiAgICAgICAgICAgICAgICAgIGJ5dGVzLnB1c2goMjM5LCAxOTEsIDE4OSk7CiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgbGVhZFN1cnJvZ2F0ZSA9IGNvZGVQb2ludDsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoY29kZVBvaW50IDwgNTYzMjApIHsKICAgICAgICAgICAgICBpZiAoKHVuaXRzIC09IDMpID4gLTEpCiAgICAgICAgICAgICAgICBieXRlcy5wdXNoKDIzOSwgMTkxLCAxODkpOwogICAgICAgICAgICAgIGxlYWRTdXJyb2dhdGUgPSBjb2RlUG9pbnQ7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29kZVBvaW50ID0gKGxlYWRTdXJyb2dhdGUgLSA1NTI5NiA8PCAxMCB8IGNvZGVQb2ludCAtIDU2MzIwKSArIDY1NTM2OwogICAgICAgICAgfSBlbHNlIGlmIChsZWFkU3Vycm9nYXRlKSB7CiAgICAgICAgICAgIGlmICgodW5pdHMgLT0gMykgPiAtMSkKICAgICAgICAgICAgICBieXRlcy5wdXNoKDIzOSwgMTkxLCAxODkpOwogICAgICAgICAgfQogICAgICAgICAgbGVhZFN1cnJvZ2F0ZSA9IG51bGw7CiAgICAgICAgICBpZiAoY29kZVBvaW50IDwgMTI4KSB7CiAgICAgICAgICAgIGlmICgodW5pdHMgLT0gMSkgPCAwKQogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBieXRlcy5wdXNoKGNvZGVQb2ludCk7CiAgICAgICAgICB9IGVsc2UgaWYgKGNvZGVQb2ludCA8IDIwNDgpIHsKICAgICAgICAgICAgaWYgKCh1bml0cyAtPSAyKSA8IDApCiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGJ5dGVzLnB1c2goY29kZVBvaW50ID4+IDYgfCAxOTIsIGNvZGVQb2ludCAmIDYzIHwgMTI4KTsKICAgICAgICAgIH0gZWxzZSBpZiAoY29kZVBvaW50IDwgNjU1MzYpIHsKICAgICAgICAgICAgaWYgKCh1bml0cyAtPSAzKSA8IDApCiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGJ5dGVzLnB1c2goY29kZVBvaW50ID4+IDEyIHwgMjI0LCBjb2RlUG9pbnQgPj4gNiAmIDYzIHwgMTI4LCBjb2RlUG9pbnQgJiA2MyB8IDEyOCk7CiAgICAgICAgICB9IGVsc2UgaWYgKGNvZGVQb2ludCA8IDExMTQxMTIpIHsKICAgICAgICAgICAgaWYgKCh1bml0cyAtPSA0KSA8IDApCiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGJ5dGVzLnB1c2goY29kZVBvaW50ID4+IDE4IHwgMjQwLCBjb2RlUG9pbnQgPj4gMTIgJiA2MyB8IDEyOCwgY29kZVBvaW50ID4+IDYgJiA2MyB8IDEyOCwgY29kZVBvaW50ICYgNjMgfCAxMjgpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJJbnZhbGlkIGNvZGUgcG9pbnQiKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJ5dGVzOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGFzY2lpVG9CeXRlcyhzdHIpIHsKICAgICAgICBjb25zdCBieXRlQXJyYXkgPSBbXTsKICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHN0ci5sZW5ndGg7ICsraSkgewogICAgICAgICAgYnl0ZUFycmF5LnB1c2goc3RyLmNoYXJDb2RlQXQoaSkgJiAyNTUpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gYnl0ZUFycmF5OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIHV0ZjE2bGVUb0J5dGVzKHN0ciwgdW5pdHMpIHsKICAgICAgICBsZXQgYywgaGksIGxvOwogICAgICAgIGNvbnN0IGJ5dGVBcnJheSA9IFtdOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgc3RyLmxlbmd0aDsgKytpKSB7CiAgICAgICAgICBpZiAoKHVuaXRzIC09IDIpIDwgMCkKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjID0gc3RyLmNoYXJDb2RlQXQoaSk7CiAgICAgICAgICBoaSA9IGMgPj4gODsKICAgICAgICAgIGxvID0gYyAlIDI1NjsKICAgICAgICAgIGJ5dGVBcnJheS5wdXNoKGxvKTsKICAgICAgICAgIGJ5dGVBcnJheS5wdXNoKGhpKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJ5dGVBcnJheTsKICAgICAgfQogICAgICBmdW5jdGlvbiBiYXNlNjRUb0J5dGVzKHN0cikgewogICAgICAgIHJldHVybiBiYX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xsYmFja0Rlc2VyaWFsaXplciA9IGV4dGVuZC5kZXNlcmlhbGl6ZS5iaW5kKGV4dGVuZCk7CiAgICAgICAgY29uc3QgZmFsbGJhY2tTZXJpYWxpemVyID0gZXh0ZW5kLnNlcmlhbGl6ZS5iaW5kKGV4dGVuZCk7CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGRlc2VyaWFsaXplKG1lc3NhZ2UpIHsKICAgICAgICAgICAgcmV0dXJuIGltcGxlbWVudGF0aW9uLmRlc2VyaWFsaXplKG1lc3NhZ2UsIGZhbGxiYWNrRGVzZXJpYWxpemVyKTsKICAgICAgICAgIH0sCiAgICAgICAgICBzZXJpYWxpemUoaW5wdXQpIHsKICAgICAgICAgICAgcmV0dXJuIGltcGxlbWVudGF0aW9uLnNlcmlhbGl6ZShpbnB1dCwgZmFsbGJhY2tTZXJpYWxpemVyKTsKICAgICAgICAgIH0KICAgICAgICB9OwogICAgICB9CiAgICAgIGV4cG9ydHMuZXh0ZW5kU2VyaWFsaXplciA9IGV4dGVuZFNlcmlhbGl6ZXI7CiAgICAgIHZhciBEZWZhdWx0RXJyb3JTZXJpYWxpemVyID0gewogICAgICAgIGRlc2VyaWFsaXplKG1lc3NhZ2UpIHsKICAgICAgICAgIHJldHVybiBPYmplY3QuYXNzaWduKEVycm9yKG1lc3NhZ2UubWVzc2FnZSksIHsKICAgICAgICAgICAgbmFtZTogbWVzc2FnZS5uYW1lLAogICAgICAgICAgICBzdGFjazogbWVzc2FnZS5zdGFjawogICAgICAgICAgfSk7CiAgICAgICAgfSwKICAgICAgICBzZXJpYWxpemUoZXJyb3IpIHsKICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgIF9fZXJyb3JfbWFya2VyOiAiJCRlcnJvciIsCiAgICAgICAgICAgIG1lc3NhZ2U6IGVycm9yLm1lc3NhZ2UsCiAgICAgICAgICAgIG5hbWU6IGVycm9yLm5hbWUsCiAgICAgICAgICAgIHN0YWNrOiBlcnJvci5zdGFjawogICAgIC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oZSkgewogICAgICAgICAgICAgIHJlamVjdChlKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgZnVuY3Rpb24gcmVqZWN0ZWQodmFsdWUpIHsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOwogICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgcmVqZWN0KGUpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgewogICAgICAgICAgICByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsKICAgICAgICAgIH0KICAgICAgICAgIHN0ZXAoKGdlbmVyYXRvciA9IGdlbmVyYXRvci5hcHBseSh0aGlzQXJnLCBfYXJndW1lbnRzIHx8IFtdKSkubmV4dCgpKTsKICAgICAgICB9KTsKICAgICAgfTsKICAgICAgdmFyIF9faW1wb3J0RGVmYXVsdCA9IGV4cG9ydHMgJiYgZXhwb3J0cy5fX2ltcG9ydERlZmF1bHQgfHwgZnVuY3Rpb24obW9kKSB7CiAgICAgICAgcmV0dXJuIG1vZCAmJiBtb2QuX19lc01vZHVsZSA/IG1vZCA6IHsgImRlZmF1bHQiOiBtb2QgfTsKICAgICAgfTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgeyB2YWx1ZTogdHJ1ZSB9KTsKICAgICAgZXhwb3J0cy5leHBvc2UgPSBleHBvcnRzLmlzV29ya2VyUnVudGltZSA9IGV4cG9ydHMuVHJhbnNmZXIgPSBleHBvcnRzLnJlZ2lzdGVyU2VyaWFsaXplciA9IHZvaWQgMDsKICAgICAgdmFyIGlzX29ic2VydmFibGVfMSA9IF9faW1wb3J0RG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lc3VsdE1lc3NhZ2Uoam9iVUlELCBmYWxzZSwgY29tbW9uXzEuc2VyaWFsaXplKHZhbHVlKSksIChlcnJvcikgPT4gewogICAgICAgICAgICAgIHBvc3RKb2JFcnJvck1lc3NhZ2Uoam9iVUlELCBjb21tb25fMS5zZXJpYWxpemUoZXJyb3IpKTsKICAgICAgICAgICAgICBhY3RpdmVTdWJzY3JpcHRpb25zLmRlbGV0ZShqb2JVSUQpOwogICAgICAgICAgICB9LCAoKSA9PiB7CiAgICAgICAgICAgICAgcG9zdEpvYlJlc3VsdE1lc3NhZ2Uoam9iVUlELCB0cnVlKTsKICAgICAgICAgICAgICBhY3RpdmVTdWJzY3JpcHRpb25zLmRlbGV0ZShqb2JVSUQpOwogICAgICAgICAgICB9KTsKICAgICAgICAgICAgYWN0aXZlU3Vic2NyaXB0aW9ucy5zZXQoam9iVUlELCBzdWJzY3JpcHRpb24pOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBjb25zdCByZXN1bHQgPSB5aWVsZCBzeW5jUmVzdWx0OwogICAgICAgICAgICAgIHBvc3RKb2JSZXN1bHRNZXNzYWdlKGpvYlVJRCwgdHJ1ZSwgY29tbW9uXzEuc2VyaWFsaXplKHJlc3VsdCkpOwogICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgIHBvc3RKb2JFcnJvck1lc3NhZ2Uoam9iVUlELCBjb21tb25fMS5zZXJpYWxpemUoZXJyb3IpKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0pOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGV4cG9zZTIoZXhwb3NlZCkgewogICAgICAgIGlmICghaW1wbGVtZW50YXRpb25fMS5kZWZhdWx0LmlzV29ya2VyUnVudGltZSgpKSB7CiAgICAgICAgICB0aHJvdyBFcnJvcigiZXhwb3NlKCkgY2FsbGVkIGluIHRoZSBtYXN0ZXIgdGhyZWFkLiIpOwogIC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5vbigidW5oYW5kbGVkUmVqZWN0aW9uIiwgKGVycm9yKSA9PiB7CiAgICAgICAgICBpZiAoZXJyb3IgJiYgdHlwZW9mIGVycm9yLm1lc3NhZ2UgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgIHNldFRpbWVvdXQoKCkgPT4gcG9zdFVuY2F1Z2h0RXJyb3JNZXNzYWdlKGVycm9yKSwgMjUwKTsKICAgICAgICAgIH0KICAgICAgICB9KTsKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLnBucG0vbG9uZ0A0LjAuMC9ub2RlX21vZHVsZXMvbG9uZy9zcmMvbG9uZy5qcwogIHZhciByZXF1aXJlX2xvbmcgPSBfX2NvbW1vbkpTKHsKICAgICJub2RlX21vZHVsZXMvLnBucG0vbG9uZ0A0LjAuMC9ub2RlX21vZHVsZXMvbG9uZy9zcmMvbG9uZy5qcyIoZXhwb3J0cywgbW9kdWxlKSB7CiAgICAgIGluaXRfYnVmZmVyX3NoaW0oKTsKICAgICAgbW9kdWxlLmV4cG9ydHMgPSBMb25nNDsKICAgICAgdmFyIHdhc20gPSBudWxsOwogICAgICB0cnkgewogICAgICAgIHdhc20gPSBuZXcgV2ViQXNzZW1ibHkuSW5zdGFuY2UobmV3IFdlYkFzc2VtYmx5Lk1vZHVsZShuZXcgVWludDhBcnJheShbCiAgICAgICAgICAwLAogICAgICAgICAgOTcsCiAgICAgICAgICAxMTUsCiAgICAgICAgICAxMDksCiAgICAgICAgICAxLAogICAgICAgICAgMCwKICAgICAgICAgIDAsCiAgICAgICAgICAwLAogICAgICAgICAgMSwKICAgICAgICAgIDEzLAogICAgICAgICAgMiwKICAgICAgICAgIDk2LAogICAgICAgICAgMCwKICAgICAgICAgIDEsCiAgICAgICAgICAxMjcsCiAgICAgICAgICA5NiwKICAgICAgICAgIDQsCiAgICAgICAgICAxMjcsCiAgICAgICAgICAxMjcsCiAgICAgICAgICAxMjcsCiAgICAgICAgICAxMjcsCiAgICAgICAgICAxLAogICAgICAgICAgMTI3LAogICAgICAgICAgMywKICAgICAgICAgIDcsCiAgICAgICAgICA2LAogICAgICAgICAgMCwKICAgICAgICAgIDEsCiAgICAgICAgICAxLAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICAxLAogICAgICAgICAgNiwKICAgICAgICAgIDYsCiAgICAgICAgICAxLAogICAgICAgICAgMTI3LAogICAgICAgICAgMSwKICAgICAgICAgIDY1LAogICAgICAgICAgMCwKICAgICAgICAgIDExLAogICAgICAgICAgNywKICAgICAgICAgIDUwLAogICAgICAgICAgNiwKICAgICAgICAgIDMsCiAgICAgICAgICAxMDksCiAgICAgICAgICAxMTcsCiAgICAgICAgICAxMDgsCiAgICAgICAgICAwLAogICAgICAgICAgMSwKICAgICAgICAgIDUsCiAgICAgICAgICAxMDAsCiAgICAgICAgICAxMDUsCiAgICAgICAgICAxMTgsCiAgICAgICAgICA5NSwKICAgICAgICAgIDExNSwKICAgICAgICAgIDAsCiAgICAgICAgICAyLAogICAgICAgICAgNSwKICAgICAgICAgIDEwMCwKICAgICAgICAgIDEwNSwKICAgICAgICAgIDExOCwKICAgICAgICAgIDk1LAogICAgICAgICAgMTE3LAogICAgICAgICAgMCwKICAgICAgICAgIDMsCiAgICAgICAgICA1LAogICAgICAgICAgMTE0LAogICAgICAgICAgMTAxLAogICAgICAgICAgMTA5LAogICAgICAgICAgOTUsCiAgICAgICAgICAxMTUsCiAgICAgICAgICAwLAogICAgICAgICAgNCwKICAgICAgICAgIDUsCiAgICAgICAgICAxMTQsCiAgICAgICAgICAxMDEsCiAgICAgICAgICAxMDksCiAgICAgICAgICA5NSwKICAgICAgICAgIDExNywKICAgICAgICAgIDAsCiAgICAgICAgICA1LAogICAgICAgICAgOCwKICAgICAgICAgIDEwMywKICAgICAgICAgIDEwMSwKICAgICAgICAgIDExNiwKICAgICAgICAgIDk1LAogICAgICAgICAgMTA0LAogICAgICAgICAgMTA1LAogICAgICAgICAgMTAzLAogICAgICAgICAgMTA0LAogICAgICAgICAgMCwKICAgICAgICAgIDAsCiAgICAgICAgICAxMCwKICAgICAgICAgIDE5MSwKICAgICAgICAgIDEsCiAgICAgICAgICA2LAogICAgICAgICAgNCwKICAgICAgICAgIDAsCiAgICAgICAgICAzNSwKICAgICAgICAgIDAsCiAgICAgICAgICAxMSwKICAgICAgICAgIDM2LAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICAxMjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDAsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMzIsCiAgICAgICAgICAyLAogICAgICAgICAgMTczLAogICAgICAgICAgMzIsCiAgICAgICAgICAzLAogICAgICAgICAgMTczLAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNCwKICAgICAgICAgIDEzMiwKICAgICAgICAgIDEyNiwKICAgICAgICAgIDM0LAogICAgICAgICAgNCwKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzUsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAzNiwKICAgICAgICAgIDAsCiAgICAgICAgICAzMiwKICAgICAgICAgIDQsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAxMSwKICAgICAgICAgIDM2LAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICAxMjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDAsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMzIsCiAgICAgICAgICAyLAogICAgICAgICAgMTczLAogICAgICAgICAgMzIsCiAgICAgICAgICAzLAogICAgICAgICAgMTczLAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNCwKICAgICAgICAgIDEzMiwKICAgICAgICAgIDEyNywKICAgICAgICAgIDM0LAogICAgICAgICAgNCwKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzUsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAzNiwKICAgICAgICAgIDAsCiAgICAgICAgICAzMiwKICAgICAgICAgIDQsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAxMSwKICAgICAgICAgIDM2LAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICAxMjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDAsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMzIsCiAgICAgICAgICAyLAogICAgICAgICAgMTczLAogICAgICAgICAgMzIsCiAgICAgICAgICAzLAogICAgICAgICAgMTczLAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNCwKICAgICAgICAgIDEzMiwKICAgICAgICAgIDEyOCwKICAgICAgICAgIDM0LAogICAgICAgICAgNCwKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzUsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAzNiwKICAgICAgICAgIDAsCiAgICAgICAgICAzMiwKICAgICAgICAgIDQsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAxMSwKICAgICAgICAgIDM2LAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICAxMjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDAsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMzIsCiAgICAgICAgICAyLAogICAgICAgICAgMTczLAogICAgICAgICAgMzIsCiAgICAgICAgICAzLAogICAgICAgICAgMTczLAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNCwKICAgICAgICAgIDEzMiwKICAgICAgICAgIDEyOSwKICAgICAgICAgIDM0LAogICAgICAgICAgNCwKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzUsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAzNiwKICAgICAgICAgIDAsCiAgICAgICAgICAzMiwKICAgICAgICAgIDQsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAxMSwKICAgICAgICAgIDM2LAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICAxMjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDAsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMzIsCiAgICAgICAgICAyLAogICAgICAgICAgMTczLAogICAgICAgICAgMzIsCiAgICAgICAgICAzLAogICAgICAgICAgMTczLAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNCwKICAgICAgICAgIDEzMiwKICAgICAgICAgIDEzMCwKICAgICAgICAgIDM0LAogICAgICAgICAgNCwKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzUsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAzNiwKICAgICAgICAgIDAsCiAgICAgICAgICAzMiwKICAgICAgICAgIDQsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAxMQogICAgICAgIF0pKSwge30pLmV4cG9ydHM7CiAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgfQogICAgICBmdW5jdGlvbiBMb25nNChsb3csIGhpZ2gsIHVuc2lnbmVkKSB7CiAgICAgICAgdGhpcy5sb3cgPSBsb3cgfCAwOwogICAgICAgIHRoaXMuaGlnaCA9IGhpZ2ggfCAwOwogICAgICAgIHRoaXMudW5zaWduZWQgPSAhIXVuc2lnbmVkOwogICAgICB9CiAgICAgIExvbmc0LnByb3RvdHlwZS5fX2lzTG9uZ19fOwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoTG9uZzQucHJvdG90eXBlLCAiX19pc0xvbmdfXyIsIHsgdmFsdWU6IHRydWUgfSk7CiAgICAgIGZ1bmN0aW9uIGlzTG9uZyhvYmopIHsKICAgICAgICByZXR1cm4gKG9iaiAmJiBvYmpbIl9faXNMb25nX18iXSkgPT09IHRydWU7CiAgICAgIH0KICAgICAgTG9uZzQuaXNMb25nID0gaXNMb25nOwogICAgICB2YXIgSU5UX0NBQ0hFID0ge307CiAgICAgIHZhciBVSU5UX0NBQ0hFID0ge307CiAgICAgIGZ1bmN0aW9uIGZyb21JbnQodmFsdWUsIHVuc2lnbmVkKSB7CiAgICAgICAgdmFyIG9iaiwgY2FjaGVkT2JqLCBjYWNoZTsKICAgICAgICBpZiAodW5zaWduZWQpIHsKICAgICAgICAgIHZhbHVlID4+Pj0gMDsKICAgICAgICAgIGlmIChjYWNoZSA9IDAgPD0gdmFsdWUgJiYgdmFsdWUgPCAyNTYpIHsKICAgICAgICAgICAgY2FjaGVkT2JqID0gVUlOVF9DQUNIRVt2YWx1ZV07CiAgICAgICAgICAgIGlmIChjYWNoZWRPYmopCiAgICAgICAgICAgICAgcmV0dXJuIGNhY2hlZE9iajsKICAgICAgICAgIH0KICAgICAgICAgIG9iaiA9IGZyb21CaXRzKHZhbHVlLCAodmFsdWUgfCAwKSA8IDAgPyAtMSA6IDAsIHRydWUpOwogICAgICAgICAgaWYgKGNhY2hlKQogICAgICAgICAgICBVSU5UX0NBQ0hFW3ZhbHVlXSA9IG9iajsKICAgICAgICAgIHJldHVybiBvYmo7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHZhbHVlIHw9IDA7CiAgICAgICAgICBpZiAoY2FjaGUgPSAtMTI4IDw9IHZhbHVlICYmIHZhbHVlIDwgMTI4KSB7CiAgICAgICAgICAgIGNhY2hlZE9iaiA9IElOVF9DQUNIRVt2YWx1ZV07CiAgICAgICAgICAgIGlmIChjYWNoZWRPYmopCiAgICAgICAgICAgICAgcmV0dXJuIGNhY2hlZE9iajsKICAgICAgICAgIH0KICAgICAgICAgIG9iaiA9IGZyb21CaXRzKHZhbHVlLCB2YWx1ZSA8IDAgPyAtMSA6IDAsIGZhbHNlKTsKICAgICAgICAgIGlmIChjYWNoZSkKICAgICAgICAgICAgSU5UX0NBQ0hFW3ZhbHVlXSA9IG9iajsKICAgICAgICAgIHJldHVybiBvYmo7CiAgICAgICAgfQogICAgICB9CiAgICAgIExvbmc0LmZyb21JbnQgPSBmcm9tSW50OwogICAgICBmdW5jdGlvbiBmcm9tTnVtYmVyKHZhbHVlLCB1bnNpZ25lZCkgewogICAgICAgIGlmIChpc05hTih2YWx1ZSkpCiAgICAgICAgICByZXR1cm4gdW5zaWduZWQgPyBVWkVSTyA6IFpFUk87CiAgICAgICAgaWYgKHVuc2lnbmVkKSB7CiAgICAgICAgICBpZiAodmFsdWUgPCAwKQogICAgICAgICAgICByZXR1cm4gVVpFUk87CiAgICAgICAgICBpZiAodmFsdWUgPj0gVFdPX1BXUl82NF9EQkwpCiAgICAgICAgICAgIHJldHVybiBNQVhfVU5TSUdORURfVkFMVUU7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGlmICh2YWx1ZSA8PSAtVFdPX1BXUl82M19EQkwpCiAgICAgICAgICAgIHJldHVybiBNSU5fVkFMVUU7CiAgICAgICAgICBpZiAodmFsdWUgKyAxID49IFRXT19QV1JfNjNfREJMKQogICAgICAgICAgICByZXR1cm4gTUFYX1ZBTFVFOwogICAgICAgIH0KICAgICAgICBpZiAodmFsdWUgPCAwKQogICAgICAgICAgcmV0dXJuIGZyb21OdW1iZXIoLXZhbHVlLCB1bnNpZ25lZCkubmVnKCk7CiAgICAgICAgcmV0dXJuIGZyb21CaXRzKHZhbHVlICUgVFdPX1BXUl8zMl9EQkwgfCAwLCB2YWx1ZSAvIFRXT19QV1JfMzJfREJMIHwgMCwgdW5zaWduZWQpOwogICAgICB9CiAgICAgIExvbmc0LmZyb21OdW1iZXIgPSBmcm9tTnVtYmVyOwogICAgICBmdW5jdGlvbiBmcm9tQml0cyhsb3dCaXRzLCBoaWdoQml0cywgdW5zaWduZWQpIHsKICAgICAgICByZXR1cm4gbmV3IExvbmc0KGxvd0JpdHMsIGhpZ2hCaXRzLCB1bnNpZ25lZCk7CiAgICAgIH0KICAgICAgTG9uZzQuZnJvbUJpdHMgPSBmcm9tQml0czsKICAgICAgdmFyIHBvd19kYmwgPSBNYXRoLnBvdzsKICAgICAgZnVuY3Rpb24gZnJvbVN0cmluZyhzdHIsIHVuc2lnbmVkLCByYWRpeCkgewogICAgICAgIGlmIChzdHIubGVuZ3RoID09PSAwKQogICAgICAgICAgdGhyb3cgRXJyb3IoImVtcHR5IHN0cmluZyIpOwogICAgICAgIGlmIChzdHIgPT09ICJOYU4iIHx8IHN0ciA9PT0gIkluZmluaXR5IiB8fCBzdHIgPT09ICIrSW5maW5pdHkiIHx8IHN0ciA9PT0gIi1JbmZpbml0eSIpCiAgICAgICAgICByZXR1cm4gWkVSTzsKICAgICAgICBpZiAodHlwZW9mIHVuc2lnbmVkID09PSAibnVtYmVyIikgewogICAgICAgICAgcmFkaXggPSB1bnNpZ25lZCwgdW5zaWduZWQgPSBmYWxzZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgdW5zaWduZWQgPSAhIXVuc2lnbmVkOwogICAgICAgIH0KICAgICAgICByYWRpeCA9IHJhZGl4IHx8IDEwOwogICAgICAgIGlmIChyYWRpeCA8IDIgfHwgMzYgPCByYWRpeCkKICAgICAgICAgIHRocm93IFJhbmdlRXJyb3IoInJhZGl4Iik7CiAgICAgICAgdmFyIHA7CiAgICAgICAgaWYgKChwID0gc3RyLmluZGV4T2YoIi0iKSkgPiAwKQogICAgICAgICAgdGhyb3cgRXJyb3IoImludGVyaW9yIGh5cGhlbiIpOwogICAgICAgIGVsc2UgaWYgKHAgPT09IDApIHsKICAgICAgICAgIHJldHVybiBmcm9tU3RyaW5nKHN0ci5zdWJzdHJpbmcoMSksIHVuc2lnbmVkLCByYWRpeCkubmVnKCk7CiAgICAgICAgfQogICAgICAgIHZhciByYWRpeFRvUG93ZXIgPSBmcm9tTnVtYmVyKHBvd19kYmwocmFkaXgsIDgpKTsKICAgICAgICB2YXIgcmVzdWx0ID0gWkVSTzsKICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHN0ci5sZW5ndGg7IGkgKz0gOCkgewogICAgICAgICAgdmFyIHNpemUgPSBNYXRoLm1pbig4LCBzdHIubGVuZ3RoIC0gaSksIHZhbHVlID0gcGFyc2VJbnQoc3RyLnN1YnN0cmluZyhpLCBpICsgc2l6ZSksIHJhZGl4KTsKICAgICAgICAgIGlmIChzaXplIDwgOCkgewogICAgICAgICAgICB2YXIgcG93ZXIgPSBmcm9tTnVtYmVyKHBvd19kYmwocmFkaXgsIHNpemUpKTsKICAgICAgICAgICAgcmVzdWx0ID0gcmVzdWx0Lm11bChwb3dlcikuYWRkKGZyb21OdW1iZXIodmFsdWUpKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHJlc3VsdCA9IHJlc3VsdC5tdWwocmFkaXhUb1Bvd2VyKTsKICAgICAgICAgICAgcmVzdWx0ID0gcmVzdWx0LmFkZChmcm9tTnVtYmVyKHZhbHVlKSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJlc3VsdC51bnNpZ25lZCA9IHVuc2lnbmVkOwogICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgIH0KICAgICAgTG9uZzQuZ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Ck7CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUudG9TdHJpbmcgPSBmdW5jdGlvbiB0b1N0cmluZyhyYWRpeCkgewogICAgICAgIHJhZGl4ID0gcmFkaXggfHwgMTA7CiAgICAgICAgaWYgKHJhZGl4IDwgMiB8fCAzNiA8IHJhZGl4KQogICAgICAgICAgdGhyb3cgUmFuZ2VFcnJvcigicmFkaXgiKTsKICAgICAgICBpZiAodGhpcy5pc1plcm8oKSkKICAgICAgICAgIHJldHVybiAiMCI7CiAgICAgICAgaWYgKHRoaXMuaXNOZWdhdGl2ZSgpKSB7CiAgICAgICAgICBpZiAodGhpcy5lcShNSU5fVkFMVUUpKSB7CiAgICAgICAgICAgIHZhciByYWRpeExvbmcgPSBmcm9tTnVtYmVyKHJhZGl4KSwgZGl2ID0gdGhpcy5kaXYocmFkaXhMb25nKSwgcmVtMSA9IGRpdi5tdWwocmFkaXhMb25nKS5zdWIodGhpcyk7CiAgICAgICAgICAgIHJldHVybiBkaXYudG9TdHJpbmcocmFkaXgpICsgcmVtMS50b0ludCgpLnRvU3RyaW5nKHJhZGl4KTsKICAgICAgICAgIH0gZWxzZQogICAgICAgICAgICByZXR1cm4gIi0iICsgdGhpcy5uZWcoKS50b1N0cmluZyhyYWRpeCk7CiAgICAgICAgfQogICAgICAgIHZhciByYWRpeFRvUG93ZXIgPSBmcm9tTnVtYmVyKHBvd19kYmwocmFkaXgsIDYpLCB0aGlzLnVuc2lnbmVkKSwgcmVtID0gdGhpczsKICAgICAgICB2YXIgcmVzdWx0ID0gIiI7CiAgICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICAgIHZhciByZW1EaXYgPSByZW0uZGl2KHJhZGl4VG9Qb3dlciksIGludHZhbCA9IHJlbS5zdWIocmVtRGl2Lm11bChyYWRpeFRvUG93ZXIpKS50b0ludCgpID4+PiAwLCBkaWdpdHMgPSBpbnR2YWwudG9TdHJpbmcocmFkaXgpOwogICAgICAgICAgcmVtID0gcmVtRGl2Owog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Ghpcy5oaWdoIDogdGhpcy5sb3c7CiAgICAgICAgZm9yICh2YXIgYml0ID0gMzE7IGJpdCA+IDA7IGJpdC0tKQogICAgICAgICAgaWYgKCh2YWwgJiAxIDw8IGJpdCkgIT0gMCkKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgcmV0dXJuIHRoaXMuaGlnaCAhPSAwID8gYml0ICsgMzMgOiBiaXQgKyAxOwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlLmlzWmVybyA9IGZ1bmN0aW9uIGlzWmVybygpIHsKICAgICAgICByZXR1cm4gdGhpcy5oaWdoID09PSAwICYmIHRoaXMubG93ID09PSAwOwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlLmVxeiA9IExvbmdQcm90b3R5cGUuaXNaZXJvOwogICAgICBMb25nUHJvdG90eXBlLmlzTmVnYXRpdmUgPSBmdW5jdGlvbiBpc05lZ2F0aXZlKCkgewogICAgICAgIHJldHVybiAhdGhpcy51bnNpZ25lZCAmJiB0aGlzLmhpZ2ggPCAwOwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlLmlzUG9zaXRpdmUgPSBmdW5jdGlvbiBpc1Bvc2l0aXZlKCkgewogICAgICAgIHJldHVybiB0aGlzLnVuc2lnbmVkIHx8IHRoaXMuaGlnaCA+PSAwOwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlLmlzT2RkID0gZnVuY3Rpb24gaXNPZGQoKSB7CiAgICAgICAgcmV0dXJuICh0aGlzLmxvdyAmIDEpID09PSAxOwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlLmlzRXZlbiA9IGZ1bmN0aW9uIGlzRXZlbigpIHsKICAgICAgICByZXR1cm4gKHRoaXMubG93ICYgMSkgPT09IDA7CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUuZXF1YWxzID0gZnVuY3Rpb24gZXF1YWxzKG90aGVyKSB7CiAgICAgICAgaWYgKCFpc0xvbmcob3RoZXIpKQogICAgICAgICAgb3RoZXIgPSB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IGlmICh3YXNtKSB7CiAgICAgICAgICB2YXIgbG93ID0gd2FzbS5tdWwodGhpcy5sb3csIHRoaXMuaGlnaCwgbXVsdGlwbGllci5sb3csIG11bHRpcGxpZXIuaGlnaCk7CiAgICAgICAgICByZXR1cm4gZnJvbUJpdHMobG93LCB3YXNtLmdldF9oaWdoKCksIHRoaXMudW5zaWduZWQpOwogICAgICAgIH0KICAgICAgICBpZiAobXVsdGlwbGllci5pc1plcm8oKSkKICAgICAgICAgIHJldHVybiBaRVJPOwogICAgICAgIGlmICh0aGlzLmVxKE1JTl9WQUxVRSkpCiAgICAgICAgICByZXR1cm4gbXVsdGlwbGllci5pc09kZCgpID8gTUlOX1ZBTFVFIDogWkVSTzsKICAgICAgICBpZiAobXVsdGlwbGllci5lcShNSU5fVkFMVUUpKQogICAgICAgICAgcmV0dXJuIHRoaXMuaXNPZGQoKSA/IE1JTl9WQUxVRSA6IFpFUk87CiAgICAgICAgaWYgKHRoaXMuaXNOZWdhdGl2ZSgpKSB7CiAgICAgICAgICBpZiAobXVsdGlwbGllci5pc05lZ2F0aXZlKCkpCiAgICAgICAgICAgIHJldHVybiB0aGlzLm5lZygpLm11bChtdWx0aXBsaWVyLm5lZygpKTsKICAgICAgICAgIGVsc2UKICAgICAgICAgICAgcmV0dXJuIHRoaXMubmVnKCkubXVsKG11bHRpcGxpZXIpLm5lZygpOwogICAgICAgIH0gZWxzZSBpZiAobXVsdGlwbGllci5pc05lZ2F0aXZlKCkpCiAgICAgICAgICByZXR1cm4gdGhpcy5tdWwobXVsdGlwbGllci5uZWcoKSkubmVnKCk7CiAgICAgICAgaWYgKHRoaXMubHQoVFdPX1BXUl8yNCkgJiYgbXVsdGlwbGllci5sdChUV09fUFdSXzI0KSkKICAgICAgICAgIHJldHVybiBmcm9tTnVtYmVyKHRoaXMudG9OdW1iZXIoKSAqIG11bHRpcGxpZXIudG9OdW1iZXIoKSwgdGhpcy51bnNpZ25lZCk7CiAgICAgICAgdmFyIGE0OCA9IHR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qIGIzMiArIGEwMCAqIGI0ODsKICAgICAgICBjNDggJj0gNjU1MzU7CiAgICAgICAgcmV0dXJuIGZyb21CaXRzKGMxNiA8PCAxNiB8IGMwMCwgYzQ4IDw8IDE2IHwgYzMyLCB0aGlzLnVuc2lnbmVkKTsKICAgICAgfTsKICAgICAgTG9uZ1Byb3RvdHlwZS5tdWwgPSBMb25nUHJvdG90eXBlLm11bHRpcGx5OwogICAgICBMb25nUHJvdG90eXBlLmRpdmlkZSA9IGZ1bmN0aW9uIGRpdmlkZShkaXZpc29yKSB7CiAgICAgICAgaWYgKCFpc0xvbmcoZGl2aXNvcikpCiAgICAgICAgICBkaXZpc29yID0gZnJvbVZhbHVlKGRpdmlzb3IpOwogICAgICAgIGlmIChkaXZpc29yLmlzWmVybygpKQogICAgICAgICAgdGhyb3cgRXJyb3IoImRpdmlzaW9uIGJ5IHplcm8iKTsKICAgICAgICBpZiAod2FzbSkgewogICAgICAgICAgaWYgKCF0aGlzLnVuc2lnbmVkICYmIHRoaXMuaGlnaCA9PT0gLTIxNDc0ODM2NDggJiYgZGl2aXNvci5sb3cgPT09IC0xICYmIGRpdmlzb3IuaGlnaCA9PT0gLTEpIHsKICAgICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgICB9CiAgICAgICAgICB2YXIgbG93ID0gKHRoaXMudW5zaWduZWQgPyB3YXNtLmRpdl91IDogd2FzbS5kaXZfcykodGhpcy5sb3csIHRoaXMuaGlnaCwgZGl2aXNvci5sb3csIGRpdmlzb3IuaGlnaCk7CiAgICAgICAgICByZXR1cm4gZnJvbUJpdHMobG93LCB3YXNtLmdldF9oaWdoKCksIHRoaXMudW5zaWduZWQpOwogICAgICAgIH0KICAgICAgICBpZiAodGhpcy5pc1plcm8oKSkKICAgICAgICAgIHJldHVybiB0aGlzLnVuc2lnbmVkID8gVVpFUk8gOiBaRVJPOwogICAgICAgIHZhciBhcHByb3gsIHJlbSwgcmVzOwogICAgICAgIGlmICghdGhpcy51bnNpZ25lZCkgewogICAgICAgICAgaWYgKHRoaXMuZXEoTUlOX1ZBTFVFKSkgewogICAgICAgICAgICBpZiAoZGl2aXNvci5lcShPTkUpIHx8IGRpdmlzb3IuZXEoTkVHX09ORSkpCiAgICAgICAgICAgICAgcmV0dXJuIE1JTl9WQUxVRTsKICAgICAgICAgICAgZWxzZSBpZiAoZGl2aXNvci5lcShNSU5fVkFMVUUpKQogICAgICAgICAgICAgIHJldHVybiBPTkU7CiAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgIHZhciBoYWxmVGhpcyA9IHRoaXMuc2hyKDEpOwogICAgICAgICAgICAgIGFwcHJveCA9IGhhbGZUaGlzLmRpdihkaXZpc29yKS5zaGwoMSk7CiAgICAgICAgICAgICAgaWYgKGFwcHJveC5lcShaRVJPKSkgewogICAgICAgICAgICAgICAgcmV0dXJuIGRpdmlzb3IuaXNOZWdhdGl2ZSgpID8gT05FIDogTkVHX09ORTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgcmVtID0gdGhpcy5zdWIoZGl2aXNvci5tdWwoYXBwcm94KSk7CiAgICAgICAgICAgICAgICByZXMgPSBhcHByb3guYWRkKHJlbS5kaXYoZGl2aXNvcikpOwogICAgICAgICAgICAgICAgcmV0dXJuIHJlczsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSBpZiAoZGl2aXNvci5lcShNSU5fVkFMVUUpKQogICAgICAgICAgICByZXR1cm4gdGhpcy51bnNpZ25lZCA/IFVaRVJPIDogWkVSTzsKICAgICAgICAgIGlmICh0aGlzLmlzTmVnYXRpdmUoKSkgewogICAgICAgICAgICBpZiAoZGl2aXNvci5pc05lZ2F0aXZlKCkpCiAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubmVnKCkuZGl2KGRpdmlzb3IubmVnKCkpOwogICAgICAgICAgICByZXR1cm4gdGhpcy5uZWcoKS5kaXYoZGl2aXNvcikubmVnKCk7CiAgICAgICAgICB9IGVsc2UgaWYgKGRpdmlzb3IuaXNOZWdhdGl2ZSgpKQogICAgICAgICAgICByZXR1cm4gdGhpcy5kaXYoZGl2aXNvci5uZWcoKSkubmVnKCk7CiAgICAgICAgICByZXMgPSBaRVJPOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBpZiAoIWRpdmlzb3IudW5zaWduZWQpCiAgICAgICAgICAgIGRpdmlzb3IgPSBkaXZpc29yLnRvVW5zaWduZWQoKTsKICAgICAgICAgIGlmIChkaXZpc29yLmd0KHRoaXMpKQogICAgICAgICAgICByZXR1cm4gVVpFUk87CiAgICAgICAgICBpZiAoZGl2aXNvci5ndCh0aGlzLnNocnUoMSkpKQogICAgICAgICAgICByZXR1cm4gVU9ORTsKICAgICAgICAgIHJlcyA9IFVaRVJPOwogICAgICAgIH0KICAgICAgICByZW0gPSB0aGlzOwogICAgICAgIHdoaWxlIChyZW0uZ3RlKGRpdmlzb3IpKSB7CiAgICAgICAgICBhcHByb3ggPSBNYXRoLm1heCgxLCBNYXRoLmZsb29yKHJlbS50b051bWJlcigpIC8gZGl2aXNvci50b051bWJlcigpKSk7CiAgICAgICAgICB2YXIgbG9nMiA9IE1hdGguY2VpbChNYXRoLmxvZyhhcHByb3gpIC8gTWF0aC5MTjIpLCBkZWx0YSA9IGxvZzIgPD0gNDggPyAxIDogcG93X2RibCgyLCBsb2cyIC0gNDgpLCBhcHByb3hSZXMgPSBmcm9tTnVtYmVyKGFwcHJveCksIGFwcHJveFJlbSA9IGFwcHJveFJlcy5tdWwoZGl2aXNvcik7CiAgICAgICAgICB3aGlsZSAoYXBwcm94UmVtLmlzTmVnYXRpdmUoKSB8fCBhcHByb3hSZW0uZ3QocmVtKSkgewogICAgICAgICAgICBhcHByb3ggLT0gZGVsdGE7CiAgICAgICAgICAgIGFwcHJveFJlcyA9IGZyb21OdW1iZXIoYXBwcm94LCB0aGlzLnVuc2lnbmVkKTsKICAgICAgICAgICAgYXBwcm94UmVtID0gYXBwcm94UmVzLm11bChkaXZpc29yKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChhcHByb3hSZXMuaXNaZXJvKCkpCiAgICAgICAgICAgIGFwcHJveFJlcyA9IE9ORTsKICAgICAgICAgIHJlcyA9IHJlcy5hZGQoYXBwcm94UmVzKTsKICAgICAgICAgIHJlbSA9IHJlbS5zdWIoYXBwcm94UmVtKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHJlczsKICAgICAgfTsKICAgICAgTG9uZ1Byb3RvdHlwZS5kaXYgPSBMb25nUHJvdG90eXBlLmRpdmlkZTsKICAgICAgTG9uZ1Byb3RvdHlwZS5tb2R1bG8gPSBmdW5jdGlvbiBtb2R1bG8oZGl2aXNvcikgewogICAgICAgIGlmICghaXNMb25nKGRpdmlzb3IpKQogICAgICAgICAgZGl2aXNvciA9IGZyb21WYWx1ZShkaXZpc29yKTsKICAgICAgICBpZiAod2FzbSkgewogICAgICAgICAgdmFyIGxvdyA9ICh0aGlzLnVuc2lnbmVkID8gd2FzbS5yZW1fdSA6IHdhc20ucmVtX3MpKHRoaXMubG93LCB0aGlzLmhpZ2gsIGRpdmlzb3IubG93LCBkaXZpc29yLmhpZ2gpOwogICAgICAgICAgcmV0dXJuIGZyb21CaXRzKGxvdywgd2FzbS5nZXRfaGlnaCgpLCB0aGlzLnVuc2lnbmVkKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRoaXMuc3ViKHRoaXMuZGl2KGRpdmlzb3IpLm11bChkaXZpc29yKSk7CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUubW9kID0gTG9uZ1Byb3RvdHlwZS5tb2R1bG87CiAgICAgIExvbmdQcm90b3R5cGUucmVtID0gTG9uZ1Byb3RvdHlwZS5tb2R1bG87CiAgICAgIExvbmdQcm90b3R5cGUubm90ID0gZnVuY3Rpb24gbm90KCkgewogICAgICAgIHJldHVybiBmcm9tQml0cyh+dGhpcy5sb3csIH50aGlzLmhpZ2gsIHRoaXMudW5zaWduZWQpOwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlLmFuZCA9IGZ1bmN0aW9uIGFuZChvdGhlcikgewogICAgICAgIGlmICghaXNMb25nKG90aGVyKSkKICAgICAgICAgIG90aGVyID0gZnJvbVZhbHVlKG90aGVyKTsKICAgICAgICByZXR1cm4gZnJvbUJpdHModGhpcy5sb3cgJiBvdGhlci5sb3csIHRoaXMuaGlnaCAmIG90aGVyLmhpZ2gsIHRoaXMudW5zaWduZWQpOwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlLm9yID0gZnVuY3Rpb24gb3Iob3RoZXIpIHsKICAgICAgICBpZiAoIWlzTG9uZyhvdGhlcikpCiAgICAgICAgICBvdGhlciA9IGZyb21WYWx1ZShvdGhlcik7CiAgICAgICAgcmV0dXJuIGZyb21CaXRzKHRoaXMubG93IHwgb3RoZXIubG93LCB0aGlzLmhpZ2ggfCBvdGhlci5oaWdoLCB0aGlzLnVuc2lnbmVkKTsKICAgICAgfTsKICAgICAgTG9uZ1Byb3RvdHlwZS54b3IgPSBmdW5jdGlvbiB4b3Iob3RoZXIpIHsKICAgICAgICBpZiAoIWlzTG9uZyhvdGhlcikpCiAgICAgICAgICBvdGhlciA9IGZyb21WYWx1ZShvdGhlcik7CiAgICAgICAgcmV0dXJuIGZyb21CaXRzKHRoaXMubG93IF4gb3RoZXIubG93LCB0aGlzLmhpZ2ggXiBvdGhlci5oaWdoLCB0aGlzLnVuc2lnbmVkKTsKICAgICAgfTsKICAgICAgTG9uZ1Byb3RvdHlwZS5zaGlmdExlZnQgPSBmdW5jdGlvbiBzaGlmdExlZnQobnVtQml0cykgewogICAgICAgIGlmIChpc0xvbmcobnVtQml0cykpCiAgICAgICAgICBudW1CaXRzID0gbnVtQml0cy50b0ludCgpOwogICAgICAgIGlmICgobnVtQml0cyAmPSA2MykgPT09IDApCiAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICBlbHNlIGlmIChudW1CaXRzIDwgMzIpCiAgICAgICAgICByZXR1cm4gZnJv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cobnVtQml0cykpCiAgICAgICAgICBudW1CaXRzID0gbnVtQml0cy50b0ludCgpOwogICAgICAgIG51bUJpdHMgJj0gNjM7CiAgICAgICAgaWYgKG51bUJpdHMgPT09IDApCiAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICBlbHNlIHsKICAgICAgICAgIHZhciBoaWdoID0gdGhpcy5oaWdoOwogICAgICAgICAgaWYgKG51bUJpdHMgPCAzMikgewogICAgICAgICAgICB2YXIgbG93ID0gdGhpcy5sb3c7CiAgICAgICAgICAgIHJldHVybiBmcm9tQml0cyhsb3cgPj4+IG51bUJpdHMgfCBoaWdoIDw8IDMyIC0gbnVtQml0cywgaGlnaCA+Pj4gbnVtQml0cywgdGhpcy51bnNpZ25lZCk7CiAgICAgICAgICB9IGVsc2UgaWYgKG51bUJpdHMgPT09IDMyKQogICAgICAgICAgICByZXR1cm4gZnJvbUJpdHMoaGlnaCwgMCwgdGhpcy51bnNpZ25lZCk7CiAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHJldHVybiBmcm9tQml0cyhoaWdoID4+PiBudW1CaXRzIC0gMzIsIDAsIHRoaXMudW5zaWduZWQpOwogICAgICAgIH0KICAgICAgfTsKICAgICAgTG9uZ1Byb3RvdHlwZS5zaHJ1ID0gTG9uZ1Byb3RvdHlwZS5zaGlmdFJpZ2h0VW5zaWduZWQ7CiAgICAgIExvbmdQcm90b3R5cGUuc2hyX3UgPSBMb25nUHJvdG90eXBlLnNoaWZ0UmlnaHRVbnNpZ25lZDsKICAgICAgTG9uZ1Byb3RvdHlwZS50b1NpZ25lZCA9IGZ1bmN0aW9uIHRvU2lnbmVkKCkgewogICAgICAgIGlmICghdGhpcy51bnNpZ25lZCkKICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgIHJldHVybiBmcm9tQml0cyh0aGlzLmxvdywgdGhpcy5oaWdoLCBmYWxzZSk7CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUudG9VbnNpZ25lZCA9IGZ1bmN0aW9uIHRvVW5zaWduZWQoKSB7CiAgICAgICAgaWYgKHRoaXMudW5zaWduZWQpCiAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICByZXR1cm4gZnJvbUJpdHModGhpcy5sb3csIHRoaXMuaGlnaCwgdHJ1ZSk7CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUudG9CeXRlcyA9IGZ1bmN0aW9uIHRvQnl0ZXMobGUpIHsKICAgICAgICByZXR1cm4gbGUgPyB0aGlzLnRvQnl0ZXNMRSgpIDogdGhpcy50b0J5dGVzQkUoKTsKICAgICAgfTsKICAgICAgTG9uZ1Byb3RvdHlwZS50b0J5dGVzTEUgPSBmdW5jdGlvbiB0b0J5dGVzTEUoKSB7CiAgICAgICAgdmFyIGhpID0gdGhpcy5oaWdoLCBsbyA9IHRoaXMubG93OwogICAgICAgIHJldHVybiBbCiAgICAgICAgICBsbyAmIDI1NSwKICAgICAgICAgIGxvID4+PiA4ICYgMjU1LAogICAgICAgICAgbG8gPj4+IDE2ICYgMjU1LAogICAgICAgICAgbG8gPj4+IDI0LAogICAgICAgICAgaGkgJiAyNTUsCiAgICAgICAgICBoaSA+Pj4gOCAmIDI1NSwKICAgICAgICAgIGhpID4+PiAxNiAmIDI1NSwKICAgICAgICAgIGhpID4+PiAyNAogICAgICAgIF07CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUudG9CeXRlc0JFID0gZnVuY3Rpb24gdG9CeXRlc0JFKCkgewogICAgICAgIHZhciBoaSA9IHRoaXMuaGlnaCwgbG8gPSB0aGlzLmxvdzsKICAgICAgICByZXR1cm4gWwogICAgICAgICAgaGkgPj4+IDI0LAogICAgICAgICAgaGkgPj4+IDE2ICYgMjU1LAogICAgICAgICAgaGkgPj4+IDggJiAyNTUsCiAgICAgICAgICBoaSAmIDI1NSwKICAgICAgICAgIGxvID4+PiAyNCwKICAgICAgICAgIGxvID4+PiAxNiAmIDI1NSwKICAgICAgICAgIGxvID4+PiA4ICYgMjU1LAogIC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Ck7CiAgICAgICAgICBpZiAoIXNvdXJjZSkgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh0eXBlb2Ygc291cmNlICE9PSAib2JqZWN0IikgewogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKHNvdXJjZSArICJtdXN0IGJlIG5vbi1vYmplY3QiKTsKICAgICAgICAgIH0KICAgICAgICAgIGZvciAodmFyIHAgaW4gc291cmNlKSB7CiAgICAgICAgICAgIGlmIChfaGFzKHNvdXJjZSwgcCkpIHsKICAgICAgICAgICAgICBvYmpbcF0gPSBzb3VyY2VbcF07CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIG9iajsKICAgICAgfTsKICAgICAgZXhwb3J0cy5zaHJpbmtCdWYgPSBmdW5jdGlvbihidWYsIHNpemUpIHsKICAgICAgICBpZiAoYnVmLmxlbmd0aCA9PT0gc2l6ZSkgewogICAgICAgICAgcmV0dXJuIGJ1ZjsKICAgICAgICB9CiAgICAgICAgaWYgKGJ1Zi5zdWJhcnJheSkgewogICAgICAgICAgcmV0dXJuIGJ1Zi5zdWJhcnJheSgwLCBzaXplKTsKICAgICAgICB9CiAgICAgICAgYnVmLmxlbmd0aCA9IHNpemU7CiAgICAgICAgcmV0dXJuIGJ1ZjsKICAgICAgfTsKICAgICAgdmFyIGZuVHlwZWQgPSB7CiAgICAgICAgYXJyYXlTZXQ6IGZ1bmN0aW9uKGRlc3QsIHNyYywgc3JjX29mZnMsIGxlbiwgZGVzdF9vZmZzKSB7CiAgICAgICAgICBpZiAoc3JjLnN1YmFycmF5ICYmIGRlc3Quc3ViYXJyYXkpIHsKICAgICAgICAgICAgZGVzdC5zZXQoc3JjLnN1YmFycmF5KHNyY19vZmZzLCBzcmNfb2ZmcyArIGxlbiksIGRlc3Rfb2Zmcyk7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgIH0KICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgbGVuOyBpKyspIHsKICAgICAgICAgICAgZGVzdFtkZXN0X29mZnMgKyBpXSA9IHNyY1tzcmNfb2ZmcyArIGldOwogICAgICAgICAgfQogICAgICAgIH0sCiAgICAgICAgZmxhdHRlbkNodW5rczogZnVuY3Rpb24oY2h1bmtzKSB7CiAgICAgICAgICB2YXIgaSwgbCwgbGVuLCBwb3MsIGNodW5rLCByZXN1bHQ7CiAgICAgICAgICBsZW4gPSAwOwogICAgICAgICAgZm9yIChpID0gMCwgbCA9IGNodW5rcy5sZW5ndGg7IGkgPCBsOyBpKyspIHsKICAgICAgICAgICAgbGVuICs9IGNodW5rc1tpXS5sZW5ndGg7CiAgICAgICAgICB9CiAgICAgICAgICByZXN1bHQgPSBuZXcgVWludDhBcnJheShsZW4pOwogICAgICAgICAgcG9zID0gMDsKICAgICAgICAgIGZvciAoaSA9IDAsIGwgPSBjaHVua3MubGVuZ3RoOyBpIDwgbDsgaSsrKSB7CiAgICAgICAgICAgIGNodW5rID0gY2h1bmtzW2ldOwogICAgICAgICAgICByZXN1bHQuc2V0KGNodW5rLCBwb3MpOwogICAgICAgICAgICBwb3MgKz0gY2h1bmsubGVuZ3RoOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICB9CiAgICAgIH07CiAgICAgIHZhciBmblVudHlwZWQgPSB7CiAgICAgICAgYXJyYXlTZXQ6IGZ1bmN0aW9uKGRlc3QsIHNyYywgc3JjX29mZnMsIGxlbiwgZGVzdF9vZmZzKSB7CiAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgICAgIGRlc3RbZGVzdF9vZmZzICsgaV0gPSBzcmNbc3JjX29mZnMgKyBpXTsKICAgICAgICAgIH0KICAgICAgICB9LAogICAgICAgIGZsYXR0ZW5DaHVua3M6IGZ1bmN0aW9uKGNodW5rcykgewogICAgICAgICAgcmV0dXJuIFtdLmNvbmNhdC5hcHBseShbXSwgY2h1bmtzKTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIGV4cG9ydHMuc2V0VHlwZWQgPSBmdW5jdGlvbihvbikgewogICAgICAgIGlmIChvbikgewogICAgICAgICAgZXhwb3J0cy5CdWY4ID0gVWludDhBcnJheTsKICAgICAgICAgIGV4cG9ydHMuQnVmMTYgPSBVaW50MTZBcnJheTsKICAgICAgICAgIGV4cG9ydHMuQnVmMzIgPSBJbnQzMkFycmF5OwogICAgICAgICAgZXhwb3J0cy5hc3NpZ24oZXhwb3J0cywgZm5UeXBlZCk7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGV4cG9ydHMuQnVmOCA9IEFycmF5OwogICAgICAgICAgZXhwb3J0cy5CdWYxNiA9IEFycmF5OwogICAgICAgICAgZXhwb3J0cy5CdWYzMiA9IEFycmF5OwogICAgICAgICAgZXhwb3J0cy5hc3NpZ24oZXhwb3J0cywgZm5VbnR5cGVkKTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIGV4cG9ydHMuc2V0VHlwZWQoVFlQRURfT0spOwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLnBucG0vcGFrb0AxLjAuMTEvbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvdHJlZXMuanMKICB2YXIgcmVxdWlyZV90cmVlcyA9IF9fY29tbW9uSlMoewogICAgIm5vZGVfbW9kdWxlcy8ucG5wbS9wYWtvQDEuMC4xMS9ub2RlX21vZHVsZXMvcGFrby9saWIvemxpYi90cmVlcy5qcyIoZXhwb3J0cykgewogICAgICBpbml0X2J1ZmZlcl9zaGltKCk7CiAgICAgICJ1c2Ugc3RyaWN0IjsKICAgICAgdmFyIHV0aWxzID0gcmVxdWlyZV9jb21tb24yKCk7CiAgICAgIHZhciBaX0ZJWEVEID0gNDsKICAgICAgdmFyIFpfQklOQVJZID0gMDsKICAgICAgdmFyIFpfVEVYVCA9IDE7CiAgICAgIHZhciBaX1VOS05PV04gPSAyOwogICAgICBmd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TUzNTsKICAgICAgICAgIHB1dF9zaG9ydChzLCBzLmJpX2J1Zik7CiAgICAgICAgICBzLmJpX2J1ZiA9IHZhbHVlID4+IEJ1Zl9zaXplIC0gcy5iaV92YWxpZDsKICAgICAgICAgIHMuYmlfdmFsaWQgKz0gbGVuZ3RoIC0gQnVmX3NpemU7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHMuYmlfYnVmIHw9IHZhbHVlIDw8IHMuYmlfdmFsaWQgJiA2NTUzNTsKICAgICAgICAgIHMuYmlfdmFsaWQgKz0gbGVuZ3RoOwogICAgICAgIH0KICAgICAgfQogICAgICBmdW5jdGlvbiBzZW5kX2NvZGUocywgYywgdHJlZSkgewogICAgICAgIHNlbmRfYml0cyhzLCB0cmVlW2MgKiAyXSwgdHJlZVtjICogMiArIDFdKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBiaV9yZXZlcnNlKGNvZGUsIGxlbikgewogICAgICAgIHZhciByZXMgPSAwOwogICAgICAgIGRvIHsKICAgICAgICAgIHJlcyB8PSBjb2RlICYgMTsKICAgICAgICAgIGNvZGUgPj4+PSAxOwogICAgICAgICAgcmVzIDw8PSAxOwogICAgICAgIH0gd2hpbGUgKC0tbGVuID4gMCk7CiAgICAgICAgcmV0dXJuIHJlcyA+Pj4gMTsKICAgICAgfQogICAgICBmdW5jdGlvbiBiaV9mbHVzaChzKSB7CiAgICAgICAgaWYgKHMuYmlfdmFsaWQgPT09IDE2KSB7CiAgICAgICAgICBwdXRfc2hvcnQocywgcy5iaV9idWYpOwogICAgICAgICAgcy5iaV9idWYgPSAwOwogICAgICAgICAgcy5iaV92YWxpZCA9IDA7CiAgICAgICAgfSBlbHNlIGlmIChzLmJpX3ZhbGlkID49IDgpIHsKICAgICAgICAgIHMucGVuZGluZ19idWZbcy5wZW5kaW5nKytdID0gcy5iaV9idWYgJiAyNTU7CiAgICAgICAgICBzLmJpX2J1ZiA+Pj0gODsKICAgICAgICAgIHMuYmlfdmFsaWQgLT0gODsK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AgICAgICAgfQogICAgICAgICAgdHJlZVtuICogMiArIDFdID0gYml0czsKICAgICAgICAgIGlmIChuID4gbWF4X2NvZGUpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBzLmJsX2NvdW50W2JpdHNdKys7CiAgICAgICAgICB4Yml0cyA9IDA7CiAgICAgICAgICBpZiAobiA+PSBiYXNlKSB7CiAgICAgICAgICAgIHhiaXRzID0gZXh0cmFbbiAtIGJhc2VdOwogICAgICAgICAgfQogICAgICAgICAgZiA9IHRyZWVbbiAqIDJdOwogICAgICAgICAgcy5vcHRfbGVuICs9IGYgKiAoYml0cyArIHhiaXRzKTsKICAgICAgICAgIGlmIChoYXNfc3RyZWUpIHsKICAgICAgICAgICAgcy5zdGF0aWNfbGVuICs9IGYgKiAoc3RyZWVbbiAqIDIgKyAxXSArIHhiaXRzKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKG92ZXJmbG93ID09PSAwKSB7CiAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIGRvIHsKICAgICAgICAgIGJpdHMgPSBtYXhfbGVuZ3RoIC0gMTsKICAgICAgICAgIHdoaWxlIChzLmJsX2NvdW50W2JpdHNdID09PSAwKSB7CiAgICAgICAgICAgIGJpdHMtLTsKICAgICAgICAgIH0KICAgICAgICAgIHMuYmxfY291bnRbYml0c10tLTsKICAgICAgICAgIHMuYmxfY291bnRbYml0cyArIDFdICs9IDI7CiAgICAgICAgICBzLmJsX2NvdW50W21heF9sZW5ndGhdLS07CiAgICAgICAgICBvdmVyZmxvdyAtPSAyOwogICAgICAgIH0gd2hpbGUgKG92ZXJmbG93ID4gMCk7CiAgICAgICAgZm9yIChiaXRzID0gbWF4X2xlbmd0aDsgYml0cyAhPT0gMDsgYml0cy0tKSB7CiAgICAgICAgICBuID0gcy5ibF9jb3VudFtiaXRzXTsKICAgICAgICAgIHdoaWxlIChuICE9PSAwKSB7CiAgICAgICAgICAgIG0gPSBzLmhlYXBbLS1oXTsKICAgICAgICAgICAgaWYgKG0gPiBtYXhfY29kZSkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICh0cmVlW20gKiAyICsgMV0gIT09IGJpdHMpIHsKICAgICAgICAgICAgICBzLm9wdF9sZW4gKz0gKGJpdHMgLSB0cmVlW20gKiAyICsgMV0pICogdHJlZVttICogMl07CiAgICAgICAgICAgICAgdHJlZVttICogMiArIDFdID0gYml0czsKICAgICAgICAgICAgfQogICAgICAgICAgICBuLS07CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIGZ1bmN0aW9uIGdlbl9jb2Rlcyh0cmVlLCBtYXhfY29kZSwgYmxfY291bnQpIHsKICAgICAgICB2YXIgbmV4dF9jb2RlID0gbmV3IEFycmF5KE1BWF9CSVRTICsgMSk7CiAgICAgICAgdmFyIGNvZGUgPSAwOwogICAgICAgIHZhciBiaXRzOwogICAgICAgIHZhciBuOwogICAgICAgIGZvciAoYml0cyA9IDE7IGJpdHMgPD0gTUFYX0JJVFM7IGJpdHMrKykgewogICAgICAgICAgbmV4dF9jb2RlW2JpdHNdID0gY29kZSA9IGNvZGUgKyBibF9jb3VudFtiaXRzIC0gMV0gPDwgMTsKICAgICAgICB9CiAgICAgICAgZm9yIChuID0gMDsgbiA8PSBtYXhfY29kZTsgbisrKSB7CiAgICAgICAgICB2YXIgbGVuID0gdHJlZVtuICogMiArIDFdOwogICAgICAgICAgaWYgKGxlbiA9PT0gMCkgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHRyZWVbbiAqIDJdID0gYmlfcmV2ZXJzZShuZXh0X2NvZGVbbGVuXSsrLCBsZW4pOwogICAgICAgIH0KICAgICAgfQogICAgICBmdW5jdGlvbiB0cl9zdGF0aWNfaW5pdCgpIHsKICAgICAgICB2YXIgbjsKICAgICAgICB2YXIgYml0czsKICAgICAgICB2YXIgbGVuZ3RoOwogICAgICAgIHZhciBjb2RlOwogICAgICAgIHZhciBkaXN0OwogICAgICAgIHZhciBibF9jb3VudCA9IG5ldyBBcnJheShNQVhfQklUUyArIDEpOwogICAgICAgIGxlbmd0aCA9IDA7CiAgICAgICAgZm9yIChjb2RlID0gMDsgY29kZSA8IExFTkdUSF9DT0RFUyAtIDE7IGNvZGUrKykgewogICAgICAgICAgYmFzZV9sZW5ndGhbY29kZV0gPSBsZW5ndGg7CiAgICAgICAgICBmb3IgKG4gPSAwOyBuIDwgMSA8PCBleHRyYV9sYml0c1tjb2RlXTsgbisrKSB7CiAgICAgICAgICAgIF9sZW5ndGhfY29kZVtsZW5ndGgrK10gPSBjb2RlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBfbGVuZ3RoX2NvZGVbbGVuZ3RoIC0gMV0gPSBjb2RlOwogICAgICAgIGRpc3QgPSAwOwogICAgICAgIGZvciAoY29kZSA9IDA7IGNvZGUgPCAxNjsgY29kZSsrKSB7CiAgICAgICAgICBiYXNlX2Rpc3RbY29kZV0gPSBkaXN0OwogICAgICAgICAgZm9yIChuID0gMDsgbiA8IDEgPDwgZXh0cmFfZGJpdHNbY29kZV07IG4rKykgewogICAgICAgICAgICBfZGlzdF9jb2RlW2Rpc3QrK10gPSBjb2RlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBkaXN0ID4+PSA3OwogICAgICAgIGZvciAoOyBjb2RlIDwgRF9DT0RFUzsgY29kZSsrKSB7CiAgICAgICAgICBiYXNlX2Rpc3RbY29kZV0gPSBkaXN0IDw8IDc7CiAgICAgICAgICBmb3IgKG4gPSAwOyBuIDwgMSA8PCBleHRyYV9kYml0c1tjb2RlXSAtIDc7IG4rKykgewogICAgICAgICAgICBfZGlzdF9jb2RlWzI1NiArIGRpc3QrK10gPSBjb2RlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBmb3IgKGJpdHMgPSAwOyBiaXRzIDw9IE1BWF9CSVRTOyBiaXRzKyspIHsKICAgICAgICAgIGJsX2NvdW50W2JpdHNdID0gMDsKICAgICAgICB9CiAgICAgICAgbiA9IDA7CiAgICAgICAgd2hpbGUgKG4gPD0gMTQzKSB7CiAgICAgICAgICBzdGF0aWNfbHRyZWVbbiAqIDIgKyAxXSA9IDg7CiAgICAgICAgICBuKys7CiAgICAgICAgICBibF9jb3VudFs4XSsrOwogICAgICAgIH0KICAgICAgICB3aGlsZSAobiA8PSAyNTUpIHsKICAgICAgICAgIHN0YXRpY19sdHJlZVtuICogMiArIDFdID0gOTsKICAgICAgICAgIG4rKzsKICAgICAgICAgIGJsX2NvdW50WzldKys7CiAgICAgICAgfQogICAgICAgIHdoaWxlIChuIDw9IDI3OSkgewogICAgICAgICAgc3RhdGljX2x0cmVlW24gKiAyICsgMV0gPSA3OwogICAgICAgICAgbisrOwogICAgICAgICAgYmxfY291bnRbN10rKzsKICAgICAgICB9CiAgICAgICAgd2hpbGUgKG4gPD0gMjg3KSB7CiAgICAgICAgICBzdGF0aWNfbHRyZWVbbiAqIDIgKyAxXSA9IDg7CiAgICAgICAgICBuKys7CiAgICAgICAgICBibF9jb3VudFs4XSsrOwogICAgICAgIH0KICAgICAgICBnZW5fY29kZXMoc3RhdGljX2x0cmVlLCBMX0NPREVTICsgMSwgYmxfY291bnQpOwogICAgICAgIGZvciAobiA9IDA7IG4gPCBEX0NPREVTOyBuKyspIHsKICAgICAgICAgIHN0YXRpY19kdHJlZVtuICogMiArIDFdID0gNTsKICAgICAgICAgIHN0YXRpY19kdHJlZVtuICogMl0gPSBiaV9yZXZlcnNlKG4sIDUpOwogICAgICAgIH0KICAgICAgICBzdGF0aWNfbF9kZXNjID0gbmV3IFN0YXRpY1RyZWVEZXNjKHN0YXRpY19sdHJlZSwgZXh0cmFfbGJpdHMsIExJVEVSQUxTICsgMSwgTF9DT0RFUywgTUFYX0JJVFMpOwogICAgICAgIHN0YXRpY19kX2Rlc2MgPSBuZXcgU3RhdGljVHJlZURlc2Moc3RhdGljX2R0cmVlLCBleHRyYV9kYml0cywgMCwgRF9DT0RFUywgTUFYX0JJVFMpOwogICAgICAgIHN0YXRpY19ibF9kZXNjID0gbmV3IFN0YXRpY1RyZWVEZXNjKG5ldyBBcnJheSgwKSwgZXh0cmFfYmxiaXRzLCAwLCBCTF9DT0RFUywgTUFYX0JMX0JJVFMpOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGluaXRfYmxvY2socykgewogICAgICAgIHZhciBuOwogICAgICAgIGZvciAobiA9IDA7IG4gPCBMX0NPREVTOyBuKyspIHsKICAgICAgICAgIHMuZHluX2x0cmVlW24gKiAyXSA9IDA7CiAgICAgICAgfQogICAgICAgIGZvciAobiA9IDA7IG4gPCBEX0NPREVTOyBuKyspIHsKICAgICAgICAgIHMuZHluX2R0cmVlW24gKiAyXSA9IDA7CiAgICAgICAgfQogICAgICAgIGZvciAobiA9IDA7IG4gPCBCTF9DT0RFUzsgbisrKSB7CiAgICAgICAgICBzLmJsX3RyZWVbbiAqIDJdID0gMDsKICAgICAgICB9CiAgICAgICAgcy5keW5fbHRyZWVbRU5EX0JMT0NLICogMl0gPSAxOwogICAgICAgIHMub3B0X2xlbiA9IHMuc3RhdGljX2xlbiA9IDA7CiAgICAgICAgcy5sYXN0X2xpdCA9IHMubWF0Y2hlcyA9IDA7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gYmlfd2luZHVwKHMpIHsKICAgICAgICBpZiAocy5iaV92YWxpZCA+IDgpIHsKICAgICAgICAgIHB1dF9zaG9ydChzLCBzLmJpX2J1Zik7CiAgICAgICAgfSBlbHNlIGlmIChzLmJpX3ZhbGlkID4gMCkgewogICAgICAgICAgcy5wZW5kaW5nX2J1ZltzLnBlbmRpbmcrK10gPSBzLmJpX2J1ZjsKICAgICAgICB9CiAgICAgICAgcy5iaV9idWYgPSAwOwogICAgICAgIHMuYmlfdmFsaWQgPSAwOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGNvcHlfYmxvY2socywgYnVmLCBsZW4sIGhlYWRlcikgewogICAgICAgIGJpX3dpbmR1cChzKTsKICAgICAgICBpZiAoaGVhZGVyKSB7CiAgICAgICAgICBwdXRfc2hvcnQocywgbGVuKTsKICAgICAgICAgIHB1dF9zaG9ydChzLCB+bGVuKTsKICAgICAgICB9CiAgICAgICAgdXRpbHMuYXJyYXlTZXQocy5wZW5kaW5nX2J1Ziwgcy53aW5kb3csIGJ1ZiwgbGVuLCBzLnBlbmRpbmcpOwogICAgICAgIHMucGVuZGluZyArPSBsZW47CiAgICAgIH0KICAgICAgZnVuY3Rpb24gc21hbGxlcih0cmVlLCBuLCBtLCBkZXB0aCkgewogICAgICAgIHZhciBfbjIgPSBuICogMjsKICAgICAgICB2YXIgX20yID0gbSAqIDI7CiAgICAgICAgcmV0dXJuIHRyZWVbX24yXSA8IHRyZWVbX20yXSB8fCB0cmVlW19uMl0gPT09IHRyZWVbX20yXSAmJiBkZXB0aFtuXSA8PSBkZXB0aFttXTsKICAgICAgfQogICAgICBmdW5jdGlvbiBwcWRvd25oZWFwKHMsIHRyZWUsIGspIHsKICAgICAgICB2YXIgdiA9IHMuaGVhcFtrXTsKICAgICAgICB2YXIgaiA9IGsgPDwgMTsKICAgICAgICB3aGlsZSAoaiA8PSBzLmhlYXBfbGVuKSB7CiAgICAgICAgICBpZiAoaiA8IHMuaGVhcF9sZW4gJiYgc21hbGxlcih0cmVlLCBzLmhlYXBbaiArIDFdLCBzLmhlYXBbal0sIHMuZGVwdGgpKSB7CiAgICAgICAgICAgIGorKzsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChzbWFsbGVyKHRyZWUsIHYsIHMuaGVhcFtqXSwgcy5kZXB0aCkpIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBzLmhlYXBba10gPSBzLmhlYXBbal07CiAgICAgICAgICBrID0gajsKICAgICAgICAgIGogPDw9IDE7CiAgICAgICAgfQogICAgICAgIHMuaGVhcFtrXSA9IHY7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gY29tcHJlc3NfYmxvY2socywgbHRyZWUsIGR0cmVlKSB7CiAgICAgICAgdmFyIGRpc3Q7CiAgICAgICAgdmFyIGxjOwogICAgICAgIHZhciBseCA9IDA7CiAgICAgICAgdmFyIGNvZGU7CiAgICAgICAgdmFyIGV4dHJhOwogICAgICAgIGlmIChzLmxhc3RfbGl0ICE9PSAwKSB7CiAgICAgICAgICBkbyB7CiAgICAgICAgICAgIGRpc3QgPSBzLnBlbmRpbmdfYnVmW3MuZF9idWYgKyBseCAqIDJdIDw8IDggfCBzLnBlbmRpbmdfYnVmW3MuZF9idWYgKyBseCAqIDIgKyAxXTsKICAgICAgICAgICAgbGMgPSBzLnBlbmRpbmdfYnVmW3MubF9idWYgKyBseF07CiAgICAgICAgICAgIGx4Kys7CiAgICAgICAgICAgIGlmIChkaXN0ID09PSAwKSB7CiAgICAgICAgICAgICAgc2VuZF9jb2RlKHMsIGxjLCBsdHJlZSk7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgY29kZSA9IF9sZW5ndGhfY29kZVtsY107CiAgICAgICAgICAgICAgc2VuZF9jb2RlKHMsIGNvZGUgKyBMSVRFUkFMUyArIDEsIGx0cmVlKTsKICAgICAgICAgICAgICBleHRyYSA9IGV4dHJhX2xiaXRzW2NvZGVdOwogICAgICAgICAgICAgIGlmIChleHRyYSAhPT0gMCkgewogICAgICAgICAgICAgICAgbGMgLT0gYmFzZV9sZW5ndGhbY29kZV07CiAgICAgICAgICAgICAgICBzZW5kX2JpdHMocywgbGMsIGV4dHJhKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgZGlzdC0tOwogICAgICAgICAgICAgIGNvZGUgPSBkX2NvZGUoZGlzdCk7CiAgICAgICAgICAgICAgc2VuZF9jb2RlKHMsIGNvZGUsIGR0cmVlKTsKICAgICAgICAgICAgICBleHRyYSA9IGV4dHJhX2RiaXRzW2NvZGVdOwogICAgICAgICAgICAgIGlmIChleHRyYSAhPT0gMCkgewogICAgICAgICAgICAgICAgZGlzdCAtPSBiYXNlX2Rpc3RbY29kZV07CiAgICAgICAgICAgICAgICBzZW5kX2JpdHMocywgZGlzdCwgZXh0cmEpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfSB3aGlsZSAobHggPCBzLmxhc3RfbGl0KTsKICAgICAgICB9CiAgICAgICAgc2VuZF9jb2RlKHMsIEVORF9CTE9DSywgbHRyZWUpOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGJ1aWxkX3RyZWUocywgZGVzYykgewogICAgICAgIHZhciB0cmVlID0gZGVzYy5keW5fdHJlZTsKICAgICAgICB2YXIgc3RyZWUgPSBkZXNjLnN0YXRfZGVzYy5zdGF0aWNfdHJlZTsKICAgICAgICB2YXIgaGFzX3N0cmVlID0gZGVzYy5zdGF0X2Rlc2MuaGFzX3N0cmVlOwogICAgICAgIHZhciBlbGVtcyA9IGRlc2Muc3RhdF9kZXNjLmVsZW1zOwogICAgICAgIHZhciBuLCBtOwogICAgICAgIHZhciBtYXhfY29kZSA9IC0xOwogICAgICAgIHZhciBub2RlOwogICAgICAgIHMuaGVhcF9sZW4gPSAwOwogICAgICAgIHMuaGVhcF9tYXggPSBIRUFQX1NJWkU7CiAgICAgICAgZm9yIChuID0gMDsgbiA8IGVsZW1zOyBuKyspIHsKICAgICAgICAgIGlmICh0cmVlW24gKiAyXSAhPT0gMCkgewogICAgICAgICAgICBzLmhlYXBbKytzLmhlYXBfbGVuXSA9IG1heF9jb2RlID0gbjsKICAgICAgICAgICAgcy5kZXB0aFtuXSA9IDA7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICB0cmVlW24gKiAyICsgMV0gPSAwOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICB3aGlsZSAocy5oZWFwX2xlbiA8IDIpIHsKICAgICAgICAgIG5vZGUgPSBzLmhlYXBbKytzLmhlYXBfbGVuXSA9IG1heF9jb2RlIDwgMiA/ICsrbWF4X2NvZGUgOiAwOwogICAgICAgICAgdHJlZVtub2RlICogMl0gPSAxOwogICAgICAgICAgcy5kZXB0aFtub2RlXSA9IDA7CiAgICAgICAgICBzLm9wdF9sZW4tLTsKICAgICAgICAgIGlmIChoYXNfc3RyZWUpIHsKICAgICAgICAgICAgcy5zdGF0aWNfbGVuIC09IHN0cmVlW25vZGUgKiAyICsgMV07CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGRlc2MubWF4X2NvZGUgPSBtYXhfY29kZTsKICAgICAgICBmb3IgKG4gPSBzLmhlYXBfbGVuID4+IDE7IG4gPj0gMTsgbi0tKSB7CiAgICAgICAgICBwcWRvd25oZWFwKHMsIHRyZWUsIG4pOwogICAgICAgIH0KICAgICAgICBub2RlID0gZWxlbXM7CiAgICAgICAgZG8gewogICAgICAgICAgbiA9IHMuaGVhcFsxXTsKICAgICAgICAgIHMuaGVhcFsxXSA9IHMuaGVhcFtzLmhlYXBfbGVuLS1dOwogICAgICAgICAgcHFkb3duaGVhcChzLCB0cmVlLCAxKTsKICAgICAgICAgIG0gPSBzLmhlYXBbMV07CiAgICAgICAgICBzLmhlYXBbLS1zLmhlYXBfbWF4XSA9IG47CiAgICAgICAgICBzLmhlYXBbLS1zLmhlYXBfbWF4XSA9IG07CiAgICAgICAgICB0cmVlW25vZGUgKiAyXSA9IHRyZWVbbiAqIDJdICsgdHJlZVttICogMl07CiAgICAgICAgICBzLmRlcHRoW25vZGVdID0gKHMuZGVwdGhbbl0gPj0gcy5kZXB0aFttXSA/IHMuZGVwdGhbbl0gOiBzLmRlcHRoW21dKSArIDE7CiAgICAgICAgICB0cmVlW24gKiAyICsgMV0gPSB0cmVlW20gKiAyICsgMV0gPSBub2RlOwogICAgICAgICAgcy5oZWFwWzFdID0gbm9kZSsrOwogICAgICAgICAgcHFkb3duaGVhcChzLCB0cmVlLCAxKTsKICAgICAgICB9IHdoaWxlIChzLmhlYXBfbGVuID49IDIpOwogICAgICAgIHMuaGVhcFstLXMuaGVhcF9tYXhdID0gcy5oZWFwWzFdOwogICAgICAgIGdlbl9iaXRsZW4ocywgZGVzYyk7CiAgICAgICAgZ2VuX2NvZGVzKHRyZWUsIG1heF9jb2RlLCBzLmJsX2NvdW50KTsKICAgICAgfQogICAgICBmdW5jdGlvbiBzY2FuX3RyZWUocywgdHJlZSwgbWF4X2NvZGUpIHsKICAgICAgICB2YXIgbjsKICAgICAgICB2YXIgcHJldmxlbiA9IC0xOwogICAgICAgIHZhciBjdXJsZW47CiAgICAgICAgdmFyIG5leHRsZW4gPSB0cmVlWzAgKiAyICsgMV07CiAgICAgICAgdmFyIGNvdW50ID0gMDsKICAgICAgICB2YXIgbWF4X2NvdW50ID0gNzsKICAgICAgICB2YXIgbWluX2NvdW50ID0gNDsKICAgICAgICBpZiAobmV4dGxlbiA9PT0gMCkgewogICAgICAgICAgbWF4X2NvdW50ID0gMTM4OwogICAgICAgICAgbWluX2NvdW50ID0gMzsKICAgICAgICB9CiAgICAgICAgdHJlZVsobWF4X2NvZGUgKyAxKSAqIDIgKyAxXSA9IDY1NTM1OwogICAgICAgIGZvciAobiA9IDA7IG4gPD0gbWF4X2NvZGU7IG4rKykgewogICAgICAgICAgY3VybGVuID0gbmV4dGxlbjsKICAgICAgICAgIG5leHRsZW4gPSB0cmVlWyhuICsgMSkgKiAyICsgMV07CiAgICAgICAgICBpZiAoKytjb3VudCA8IG1heF9jb3VudCAmJiBjdXJsZW4gPT09IG5leHRsZW4pIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9IGVsc2UgaWYgKGNvdW50IDwgbWluX2NvdW50KSB7CiAgICAgICAgICAgIHMuYmxfdHJlZVtjdXJsZW4gKiAyXSArPSBjb3VudDsKICAgICAgICAgIH0gZWxzZSBpZiAoY3VybGVuICE9PSAwKSB7CiAgICAgICAgICAgIGlmIChjdXJsZW4gIT09IHByZXZsZW4pIHsKICAgICAgICAgICAgICBzLmJsX3RyZWVbY3VybGVuICogMl0rKzsKICAgICAgICAgICAgfQogICAgICAgICAgICBzLmJsX3RyZWVbUkVQXzNfNiAqIDJdKys7CiAgICAgICAgICB9IGVsc2UgaWYgKGNvdW50IDw9IDEwKSB7CiAgICAgICAgICAgIHMuYmxfdHJlZVtSRVBaXzNfMTAgKiAyXSsrOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcy5ibF90cmVlW1JFUFpfMTFfMTM4ICogMl0rKzsKICAgICAgICAgIH0KICAgICAgICAgIGNvdW50ID0gMDsKICAgICAgICAgIHByZXZsZW4gPSBjdXJsZW47CiAgICAgICAgICBpZiAobmV4dGxlbiA9PT0gMCkgewogICAgICAgICAgICBtYXhfY291bnQgPSAxMzg7CiAgICAgICAgICAgIG1pbl9jb3VudCA9IDM7CiAgICAgICAgICB9IGVsc2UgaWYgKGN1cmxlbiA9PT0gbmV4dGxlbikgewogICAgICAgICAgICBtYXhfY291bnQgPSA2OwogICAgICAgICAgICBtaW5fY291bnQgPSAzOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgbWF4X2NvdW50ID0gNzsKICAgICAgICAgICAgbWluX2NvdW50ID0gNDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgZnVuY3Rpb24gc2VuZF90cmVlKHMsIHRyZWUsIG1heF9jb2RlKSB7CiAgICAgICAgdmFyIG47CiAgICAgICAgdmFyIHByZXZsZW4gPSAtMTsKICAgICAgICB2YXIgY3VybGVuOwogICAgICAgIHZhciBuZXh0bGVuID0gdHJlZVswICogMiArIDFdOwogICAgICAgIHZhciBjb3VudCA9IDA7CiAgICAgICAgdmFyIG1heF9jb3VudCA9IDc7CiAgICAgICAgdmFyIG1pbl9jb3VudCA9IDQ7CiAgICAgICAgaWYgKG5leHRsZW4gPT09IDApIHsKICAgICAgICAgIG1heF9jb3VudCA9IDEzODsKICAgICAgICAgIG1pbl9jb3VudCA9IDM7CiAgICAgICAgfQogICAgICAgIGZvciAobiA9IDA7IG4gPD0gbWF4X2NvZGU7IG4rKykgewogICAgICAgICAgY3VybGVuID0gbmV4dGxlbjsKICAgICAgICAgIG5leHRsZW4gPSB0cmVlWyhuICsgMSkgKiAyICsgMV07CiAgICAgICAgICBpZiAoKytjb3VudCA8IG1heF9jb3VudCAmJiBjdXJsZW4gPT09IG5leHRsZW4pIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9IGVsc2UgaWYgKGNvdW50IDwgbWluX2NvdW50KSB7CiAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICBzZW5kX2NvZGUocywgY3VybGVuLCBzLmJsX3RyZWUpOwogICAgICAgICAgICB9IHdoaWxlICgtLWNvdW50ICE9PSAwKTsKICAgICAgICAgIH0gZWxzZSBpZiAoY3VybGVuICE9PSAwKSB7CiAgICAgICAgICAgIGlmIChjdXJsZW4gIT09IHByZXZsZW4pIHsKICAgICAgICAgICAgICBzZW5kX2NvZGUocywgY3VybGVuLCBzLmJsX3RyZWUpOwogICAgICAgICAgICAgIGNvdW50LS07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc2VuZF9jb2RlKHMsIFJFUF8zXzYsIHMuYmxfdHJlZSk7CiAgICAgICAgICAgIHNlbmRfYml0cyhzLCBjb3VudCAtIDMsIDIpOwogICAgICAgICAgfSBlbHNlIGlmIChjb3VudCA8PSAxMCkgewogICAgICAgICAgICBzZW5kX2NvZGUocywgUkVQWl8zXzEwLCBzLmJsX3RyZWUpOwogICAgICAgICAgICBzZW5kX2JpdHMocywgY291bnQgLSAzLCAzKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHNlbmRfY29kZShzLCBSRVBaXzExXzEzOCwgcy5ibF90cmVlKTsKICAgICAgICAgICAgc2VuZF9iaXRzKHMsIGNvdW50IC0gMTEsIDcpOwogICAgICAgICAgfQogICAgICAgICAgY291bnQgPSAwOwogICAgICAgICAgcHJldmxlbiA9IGN1cmxlbjsKICAgICAgICAgIGlmIChuZXh0bGVuID09PSAwKSB7CiAgICAgICAgICAgIG1heF9jb3VudCA9IDEzODsKICAgICAgICAgICAgbWluX2NvdW50ID0gMzsKICAgICAgICAgIH0gZWxzZSBpZiAoY3VybGVuID09PSBuZXh0bGVuKSB7CiAgICAgICAgICAgIG1heF9jb3VudCA9IDY7CiAgICAgICAgICAgIG1pbl9jb3VudCA9IDM7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBtYXhfY291bnQgPSA3OwogICAgICAgICAgICBtaW5fY291bnQgPSA0OwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBmdW5jdGlvbiBidWlsZF9ibF90cmVlKHMpIHsKICAgICAgICB2YXIgbWF4X2JsaW5kZXg7CiAgICAgICAgc2Nhbl90cmVlKHMsIHMuZHluX2x0cmVlLCBzLmxfZGVzYy5tYXhfY29kZSk7CiAgICAgICAgc2Nhbl90cmVlKHMsIHMuZHluX2R0cmVlLCBzLmRfZGVzYy5tYXhfY29kZSk7CiAgICAgICAgYnVpbGRfdHJlZShzLCBzLmJsX2Rlc2MpOwogICAgICAgIGZvciAobWF4X2JsaW5kZXggPSBCTF9DT0RFUyAtIDE7IG1heF9ibGluZGV4ID49IDM7IG1heF9ibGluZGV4LS0pIHsKICAgICAgICAgIGlmIChzLmJsX3RyZWVbYmxfb3JkZXJbbWF4X2JsaW5kZXhdICogMiArIDFdICE9PSAwKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBzLm9wdF9sZW4gKz0gMyAqIChtYXhfYmxpbmRleCArIDEpICsgNSArIDUgKyA0OwogICAgICAgIHJldHVybiBtYXhfYmxpbmRleDsKICAgICAgfQogICAgICBmdW5jdGlvbiBzZW5kX2FsbF90cmVlcyhzLCBsY29kZXMsIGRjb2RlcywgYmxjb2RlcykgewogICAgICAgIHZhciByYW5rOwogICAgICAgIHNlbmRfYml0cyhzLCBsY29kZXMgLSAyNTcsIDUpOwogICAgICAgIHNlbmRfYml0cyhzLCBkY29kZXMgLSAxLCA1KTsKICAgICAgICBzZW5kX2JpdHMocywgYmxjb2RlcyAtIDQsIDQpOwogICAgICAgIGZvciAocmFuayA9IDA7IHJhbmsgPCBibGNvZGVzOyByYW5rKyspIHsKICAgICAgICAgIHNlbmRfYml0cyhzLCBzLmJsX3RyZWVbYmxfb3JkZXJbcmFua10gKiAyICsgMV0sIDMpOwogICAgICAgIH0KICAgICAgICBzZW5kX3RyZWUocywgcy5keW5fbHRyZWUsIGxjb2RlcyAtIDEpOwogICAgICAgIHNlbmRfdHJlZShzLCBzLmR5bl9kdHJlZSwgZGNvZGVzIC0gMSk7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZGV0ZWN0X2RhdGFfdHlwZShzKSB7CiAgICAgICAgdmFyIGJsYWNrX21hc2sgPSA0MDkzNjI0NDQ3OwogICAgICAgIHZhciBuOwogICAgICAgIGZvciAobiA9IDA7IG4gPD0gMzE7IG4rKywgYmxhY2tfbWFzayA+Pj49IDEpIHsKICAgICAgICAgIGlmIChibGFja19tYXNrICYgMSAmJiBzLmR5bl9sdHJlZVtuICogMl0gIT09IDApIHsKICAgICAgICAgICAgcmV0dXJuIFpfQklOQVJZOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAocy5keW5fbHRyZWVbOSAqIDJdICE9PSAwIHx8IHMuZHluX2x0cmVlWzEwICogMl0gIT09IDAgfHwgcy5keW5fbHRyZWVbMTMgKiAyXSAhPT0gMCkgewogICAgICAgICAgcmV0dXJuIFpfVEVYVDsKICAgICAgICB9CiAgICAgICAgZm9yIChuID0gMzI7IG4gPCBMSVRFUkFMUzsgbisrKSB7CiAgICAgICAgICBpZiAocy5keW5fbHRyZWVbbiAqIDJdICE9PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBaX1RFWFQ7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiBaX0JJTkFSWTsKICAgICAgfQogICAgICB2YXIgc3RhdGljX2luaXRfZG9uZSA9IGZhbHNlOwogICAgICBmdW5jdGlvbiBfdHJfaW5pdChzKSB7CiAg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HJfaW5pdCA9IF90cl9pbml0OwogICAgICBleHBvcnRzLl90cl9zdG9yZWRfYmxvY2sgPSBfdHJfc3RvcmVkX2Jsb2NrOwogICAgICBleHBvcnRzLl90cl9mbHVzaF9ibG9jayA9IF90cl9mbHVzaF9ibG9jazsKICAgICAgZXhwb3J0cy5fdHJfdGFsbHkgPSBfdHJfdGFsbHk7CiAgICAgIGV4cG9ydHMuX3RyX2FsaWduID0gX3RyX2FsaWduOwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLnBucG0vcGFrb0AxLjAuMTEvbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvYWRsZXIzMi5qcwogIHZhciByZXF1aXJlX2FkbGVyMzIgPSBfX2NvbW1vbkpTKHsKICAgICJub2RlX21vZHVsZXMvLnBucG0vcGFrb0AxLjAuMTEvbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvYWRsZXIzMi5qcyIoZXhwb3J0cywgbW9kdWxlKSB7CiAgICAgIGluaXRfYnVmZmVyX3NoaW0oKTsKICAgICAgInVzZSBzdHJpY3QiOwogICAgICBmdW5jdGlvbiBhZGxlcjMyKGFkbGVyLCBidWYsIGxlbiwgcG9zKSB7CiAgICAgICAgdmFyIHMxID0gYWRsZXIgJiA2NTUzNSB8IDAsIHMyID0gYWRsZXIgPj4+IDE2ICYgNjU1MzUgfCAwLCBuID0gMDsKICAgICAgICB3aGlsZSAobGVuICE9PSAwKSB7CiAgICAgICAgICBuID0gbGVuID4gMmUzID8gMmUzIDogbGVuOwogICAgICAgICAgbGVuIC09IG47CiAgICAgICAgICBkbyB7CiAgICAgICAgICAgIHMxID0gczEgKyBidWZbcG9zKytdIHwgMDsKICAgICAgICAgICAgczIgPSBzMiArIHMxIHwgMDsKICAgICAgICAgIH0gd2hpbGUgKC0tbik7CiAgICAgICAgICBzMSAlPSA2NTUyMTsKICAgICAgICAgIHMyICU9IDY1NTIxOwogICAgICAgIH0KICAgICAgICByZXR1cm4gczEgfCBzMiA8PCAxNiB8IDA7CiAgICAgIH0KICAgICAgbW9kdWxlLmV4cG9ydHMgPSBhZGxlcjMyOwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLnBucG0vcGFrb0AxLjAuMTEvbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvY3JjMzIuanMKICB2YXIgcmVxdWlyZV9jcmMzMiA9IF9fY29tbW9uSlMoewogICAgIm5vZGVfbW9kdWxlcy8ucG5wbS9wYWtvQDEuMC4xMS9ub2RlX21vZHVsZXMvcGFrby9saWIvemxpYi9jcmMzMi5qcyIoZXhwb3J0cywgbW9kdWxlKSB7CiAgICAgIGluaXRfYnVmZmVyX3NoaW0oKTsKICAgICAgInVzZSBzdHJpY3QiOwogICAgICBmdW5jdGlvbiBtYWtlVGFibGUoKSB7CiAgICAgICAgdmFyIGMsIHRhYmxlID0gW107CiAgICAgICAgZm9yICh2YXIgbiA9IDA7IG4gPCAyNTY7IG4rKykgewogICAgICAgICAgYyA9IG47CiAgICAgICAgICBmb3IgKHZhciBrID0gMDsgayA8IDg7IGsrKykgewogICAgICAgICAgICBjID0gYyAmIDEgPyAzOTg4MjkyMzg0IF4gYyA+Pj4gMSA6IGMgPj4+IDE7CiAgICAgICAgICB9CiAgICAgICAgICB0YWJsZVtuXSA9IGM7CiAgICAgICAgfQogICAgICAgIHJldHVybiB0YWJsZTsKICAgICAgfQogICAgICB2YXIgY3JjVGFibGUgPSBtYWtlVGFibGUoKTsKICAgICAgZnVuY3Rpb24gY3JjMzIyKGNyYywgYnVmLCBsZW4sIHBvcykgewogICAgICAgIHZhciB0ID0gY3JjVGFibGUsIGVuZCA9IHBvcyArIGxlbjsKICAgICAgICBjcmMgXj0gLTE7CiAgICAgICAgZm9yICh2YXIgaSA9IHBvczsgaSA8IGVuZDsgaSsrKSB7CiAgICAgICAgICBjcmMgPSBjcmMgPj4+IDggXiB0WyhjcmMgXiBidWZbaV0pICYgMjU1XTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGNyYyBeIC0xOwogICAgICB9CiAgICAgIG1vZHVsZS5leHBvcnRzID0gY3JjMzIyOwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLnBucG0vcGFrb0AxLjAuMTEvbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvbWVzc2FnZXMuanMKICB2YXIgcmVxdWlyZV9tZXNzYWdlczIgPSBfX2NvbW1vbkpTKHsKICAgICJub2RlX21vZHVsZXMvLnBucG0vcGFrb0AxLjAuMTEvbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvbWVzc2FnZXMuanMiKGV4cG9ydHMsIG1vZHVsZSkgewogICAgICBpbml0X2J1ZmZlcl9zaGltKCk7CiAgICAgICJ1c2Ugc3RyaWN0IjsKICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgMjogIm5lZWQgZGljdGlvbmFyeSIsCiAgICAgICAgMTogInN0cmVhbSBlbmQiLAogICAgICAgIDA6ICIiLAogICAgICAgICItMSI6ICJmaWxlIGVycm9yIiwKICAgICAgICAiLTIiOiAic3RyZWFtIGVycm9yIiwKICAgICAgICAiLTMiOiAiZGF0YSBlcnJvciIsCiAgICAgICAgIi00IjogImluc3VmZmljaWVudCBtZW1vcnkiLAogICAgICAgICItNSI6ICJidWZmZXIgZXJyb3IiLAogICAgICAgICItNiI6ICJpbmNvbXBhdGlibGUgdmVyc2lvbiIKICAgICAgfTsKICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5wbnBtL3Bha29AMS4wLjExL25vZGVfbW9kdWxlcy9wYWtvL2xpYi96bGliL2RlZmxhdGUuanMKICB2YXIgcmVxdWlyZV9kZWZsYXRlID0gX19jb21tb25KUyh7CiAgICAibm9kZV9tb2R1bGVzLy5wbnBtL3Bha29AMS4wLjExL25vZGVfbW9kdWxlcy9wYWtvL2xpYi96bGliL2RlZmxhdGUuanMiKGV4cG9ydHMpIHsKICAgICAgaW5pdF9idWZmZXJfc2hpbSg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B2YXIgTF9DT0RFUyA9IExJVEVSQUxTICsgMSArIExFTkdUSF9DT0RFUzsKICAgICAgdmFyIERfQ09ERVMgPSAzMDsKICAgICAgdmFyIEJMX0NPREVTID0gMTk7CiAgICAgIHZhciBIRUFQX1NJWkUgPSAyICogTF9DT0RFUyArIDE7CiAgICAgIHZhciBNQVhfQklUUyA9IDE1OwogICAgICB2YXIgTUlOX01BVENIID0gMzsKICAgICAgdmFyIE1BWF9NQVRDSCA9IDI1ODsKICAgICAgdmFyIE1JTl9MT09LQUhFQUQgPSBNQVhfTUFUQ0ggKyBNSU5fTUFUQ0ggKyAxOwogICAgICB2YXIgUFJFU0VUX0RJQ1QgPSAzMjsKICAgICAgdmFyIElOSVRfU1RBVEUgPSA0MjsKICAgICAgdmFyIEVYVFJBX1NUQVRFID0gNjk7CiAgICAgIHZhciBOQU1FX1NUQVRFID0gNzM7CiAgICAgIHZhciBDT01NRU5UX1NUQVRFID0gOTE7CiAgICAgIHZhciBIQ1JDX1NUQVRFID0gMTAzOwogICAgICB2YXIgQlVTWV9TVEFURSA9IDExMzsKICAgICAgdmFyIEZJTklTSF9TVEFURSA9IDY2NjsKICAgICAgdmFyIEJTX05FRURfTU9SRSA9IDE7CiAgICAgIHZhciBCU19CTE9DS19ET05FID0gMjsKICAgICAgdmFyIEJTX0ZJTklTSF9TVEFSVEVEID0gMzsKICAgICAgdmFyIEJTX0ZJTklTSF9ET05FID0gNDsKICAgICAgdmFyIE9TX0NPREUgPSAzOwogICAgICBmdW5jdGlvbiBlcnIoc3RybSwgZXJyb3JDb2RlKSB7CiAgICAgICAgc3RybS5tc2cgPSBtc2dbZXJyb3JDb2RlXTsKICAgICAgICByZXR1cm4gZXJyb3JDb2RlOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIHJhbmsoZikgewogICAgICAgIHJldHVybiAoZiA8PCAxKSAtIChmID4gNCA/IDkgOiAwKTsKICAgICAgfQogICAgICBmdW5jdGlvbiB6ZXJvKGJ1ZikgewogICAgICAgIHZhciBsZW4gPSBidWYubGVuZ3RoOwogICAgICAgIHdoaWxlICgtLWxlbiA+PSAwKSB7CiAgICAgICAgICBidWZbbGVuXSA9IDA7CiAgICAgICAgfQogICAgICB9CiAgICAgIGZ1bmN0aW9uIGZsdXNoX3BlbmRpbmcoc3RybSkgewogICAgICAgIHZhciBzID0gc3RybS5zdGF0ZTsKICAgICAgICB2YXIgbGVuID0gcy5wZW5kaW5nOwogICAgICAgIGlmIChsZW4gPiBzdHJtLmF2YWlsX291dCkgewogICAgICAgICAgbGVuID0gc3RybS5hdmFpbF9vdXQ7CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gPT09IDApIHsKICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgdXRpbHMuYXJyYXlTZXQoc3RybS5vdXRwdXQsIHMucGVuZGluZ19idWYsIHMucGVuZGluZ19vdXQsIGxlbiwgc3RybS5uZXh0X291dCk7CiAgICAgICAgc3RybS5uZXh0X291dCArPSBsZW47CiAgICAgICAgcy5wZW5kaW5nX291dCArPSBsZW47CiAgICAgICAgc3RybS50b3RhbF9vdXQgKz0gbGVuOwogICAgICAgIHN0cm0uYXZhaWxfb3V0IC09IGxlbjsKICAgICAgICBzLnBlbmRpbmcgLT0gbGVuOwogICAgICAgIGlmIChzLnBlbmRpbmcgPT09IDApIHsKICAgICAgICAgIHMucGVuZGluZ19vdXQgPSAwOwogICAgICAgIH0KICAgICAgfQogICAgICBmdW5jdGlvbiBmbHVzaF9ibG9ja19vbmx5KHMsIGxhc3QpIHsKICAgICAgICB0cmVlcy5fdHJfZmx1c2hfYmxvY2socywgcy5ibG9ja19zdGFydCA+PSAwID8gcy5ibG9ja19zdGFydCA6IC0xLCBzLnN0cnN0YXJ0IC0gcy5ibG9ja19zdGFydCwgbGFzdCk7CiAgICAgICAgcy5ibG9ja19zdGFydCA9IHMuc3Ryc3RhcnQ7CiAgICAgICAgZmx1c2hfcGVuZGluZyhzLnN0cm0pOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIHB1dF9ieXRlKHMsIGIpIHsKICAgICAgICBzLnBlbmRpbmdfYnVmW3MucGVuZGluZysrXSA9IGI7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gcHV0U2hvcnRNU0IocywgYikgewogICAgICAgIHMucGVuZGluZ19idWZbcy5wZW5kaW5nKytdID0gYiA+Pj4gOCAmIDI1NTsKICAgICAgICBzLnBlbmRpbmdfYnVmW3MucGVuZGluZysrXSA9IGIgJiAyNTU7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gcmVhZF9idWYoc3RybSwgYnVmLCBzdGFydCwgc2l6ZSkgewogICAgICAgIHZhciBsZW4gPSBzdHJtLmF2YWlsX2luOwogICAgICAgIGlmIChsZW4gPiBzaXplKSB7CiAgICAgICAgICBsZW4gPSBzaXplOwogICAgICAgIH0KICAgICAgICBpZiAobGVuID09PSAwKSB7CiAgICAgICAgICByZXR1cm4gMDsKICAgICAgICB9CiAgICAgICAgc3RybS5hdmFpbF9pbiAtPSBsZW47CiAgICAgICAgdXRpbHMuYXJyYXlTZXQoYnVmLCBzdHJtLmlucHV0LCBzdHJtLm5leHRfaW4sIGxlbiwgc3RhcnQpOwogICAgICAgIGlmIChzdHJtLnN0YXRlLndyYXAgPT09IDEpIHsKICAgICAgICAgIHN0cm0uYWRsZXIgPSBhZGxlcjMyKHN0cm0uYWRsZXIsIGJ1ZiwgbGVuLCBzdGFydCk7CiAgICAgICAgfSBlbHNlIGlmIChzdHJtLnN0YXRlLndyYXAgPT09IDIpIHsKICAgICAgICAgIHN0cm0uYWRsZXIgPSBjcmMzMjIoc3RybS5hZGxlciwgYnVmLCBsZW4sIHN0YXJ0KTsKICAgICAgICB9CiAgICAgICAgc3RybS5uZXh0X2luICs9IGxlbjsKICAgICAgICBzdHJtLnRvdGFsX2luICs9IGxlbjsKICAgICAgICByZXR1cm4gbGVuOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGxvbmdlc3RfbWF0Y2gocywgY3VyX21hdGNoKSB7CiAgICAgICAgdmFyIGNoYWluX2xlbmd0aCA9IHMubWF4X2NoYWluX2xlbmd0aDsKICAgICAgICB2YXIgc2NhbiA9IHMuc3Ryc3RhcnQ7CiAgICAgICAgdmFyIG1hdGNoOwogICAgICAgIHZhciBsZW47CiAgICAgICAgdmFyIGJlc3RfbGVuID0gcy5wcmV2X2xlbmd0aDsKICAgICAgICB2YXIgbmljZV9tYXRjaCA9IHMubmljZV9tYXRjaDsKICAgICAgICB2YXIgbGltaXQgPSBzLnN0cnN0YXJ0ID4gcy53X3NpemUgLSBNSU5fTE9PS0FIRUFEID8gcy5zdHJzdGFydCAtIChzLndfc2l6ZSAtIE1JTl9MT09LQUhFQUQpIDogMDsKICAgICAgICB2YXIgX3dpbiA9IHMud2luZG93OwogICAgICAgIHZhciB3bWFzayA9IHMud19tYXNrOwogICAgICAgIHZhciBwcmV2ID0gcy5wcmV2OwogICAgICAgIHZhciBzdHJlbmQgPSBzLnN0cnN0YXJ0ICsgTUFYX01BVENIOwogICAgICAgIHZhciBzY2FuX2VuZDEgPSBfd2luW3NjYW4gKyBiZXN0X2xlbiAtIDFdOwogICAgICAgIHZhciBzY2FuX2VuZCA9IF93aW5bc2NhbiArIGJlc3RfbGVuXTsKICAgICAgICBpZiAocy5wcmV2X2xlbmd0aCA+PSBzLmdvb2RfbWF0Y2gpIHsKICAgICAgICAgIGNoYWluX2xlbmd0aCA+Pj0gMjsKICAgICAgICB9CiAgICAgICAgaWYgKG5pY2VfbWF0Y2ggPiBzLmxvb2thaGVhZCkgewogICAgICAgICAgbmljZV9tYXRjaCA9IHMubG9va2FoZWFkOwogICAgICAgIH0KICAgICAgICBkbyB7CiAgICAgICAgICBtYXRjaCA9IGN1cl9tYXRjaDsKICAgICAgICAgIGlmIChfd2luW21hdGNoICsgYmVzdF9sZW5dICE9PSBzY2FuX2VuZCB8fCBfd2luW21hdGNoICsgYmVzdF9sZW4gLSAxXSAhPT0gc2Nhbl9lbmQxIHx8IF93aW5bbWF0Y2hdICE9PSBfd2luW3NjYW5dIHx8IF93aW5bKyttYXRjaF0gIT09IF93aW5bc2NhbiArIDFdKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgc2NhbiArPSAyOwogICAgICAgICAgbWF0Y2grKzsKICAgICAgICAgIGRvIHsKICAgICAgICAgIH0gd2hpbGUgKF93aW5bKytzY2FuXSA9PT0gX3dpblsrK21hdGNoXSAmJiBfd2luWysrc2Nhbl0gPT09IF93aW5bKyttYXRjaF0gJiYgX3dpblsrK3NjYW5dID09PSBfd2luWysrbWF0Y2hdICYmIF93aW5bKytzY2FuXSA9PT0gX3dpblsrK21hdGNoXSAmJiBfd2luWysrc2Nhbl0gPT09IF93aW5bKyttYXRjaF0gJiYgX3dpblsrK3NjYW5dID09PSBfd2luWysrbWF0Y2hdICYmIF93aW5bKytzY2FuXSA9PT0gX3dpblsrK21hdGNoXSAmJiBfd2luWysrc2Nhbl0gPT09IF93aW5bKyttYXRjaF0gJiYgc2NhbiA8IHN0cmVuZCk7CiAgICAgICAgICBsZW4gPSBNQVhfTUFUQ0ggLSAoc3RyZW5kIC0gc2Nhbik7CiAgICAgICAgICBzY2FuID0gc3RyZW5kIC0gTUFYX01BVENIOwogICAgICAgICAgaWYgKGxlbiA+IGJlc3RfbGVuKSB7CiAgICAgICAgICAgIHMubWF0Y2hfc3RhcnQgPSBjdXJfbWF0Y2g7CiAgICAgICAgICAgIGJlc3RfbGVuID0gbGVuOwogICAgICAgICAgICBpZiAobGVuID49IG5pY2VfbWF0Y2gpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBzY2FuX2VuZDEgPSBfd2luW3NjYW4gKyBiZXN0X2xlbiAtIDFdOwogICAgICAgICAgICBzY2FuX2VuZCA9IF93aW5bc2NhbiArIGJlc3RfbGVuXTsKICAgICAgICAgIH0KICAgICAgICB9IHdoaWxlICgoY3VyX21hdGNoID0gcHJldltjdXJfbWF0Y2ggJiB3bWFza10pID4gbGltaXQgJiYgLS1jaGFpbl9sZW5ndGggIT09IDApOwogICAgICAgIGlmIChiZXN0X2xlbiA8PSBzLmxvb2thaGVhZCkgewogICAgICAgICAgcmV0dXJuIGJlc3RfbGVuOwogICAgICAgIH0KICAgICAgICByZXR1cm4gcy5sb29rYWhlYWQ7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZmlsbF93aW5kb3cocykgewogICAgICAgIHZhciBfd19zaXplID0gcy53X3NpemU7CiAgICAgICAgdmFyIHAsIG4sIG0sIG1vcmUsIHN0cjsKICAgICAgICBkbyB7CiAgICAgICAgICBtb3JlID0gcy53aW5kb3dfc2l6ZSAtIHMubG9va2FoZWFkIC0gcy5zdHJzdGFydDsKICAgICAgICAgIGlmIChzLnN0cnN0YXJ0ID49IF93X3NpemUgKyAoX3dfc2l6ZSAtIE1JTl9MT09LQUhFQUQpKSB7CiAgICAgICAgICAgIHV0aWxzLmFycmF5U2V0KHMud2luZG93LCBzLndpbmRvdywgX3dfc2l6ZSwgX3dfc2l6ZSwgMCk7CiAgICAgICAgICAgIHMubWF0Y2hfc3RhcnQgLT0gX3dfc2l6ZTsKICAgICAgICAgICAgcy5zdHJzdGFydCAtPSBfd19zaXplOwogICAgICAgICAgICBzLmJsb2NrX3N0YXJ0IC09IF93X3NpemU7CiAgICAgICAgICAgIG4gPSBzLmhhc2hfc2l6ZTsKICAgICAgICAgICAgcCA9IG47CiAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICBtID0gcy5oZWFkWy0tcF07CiAgICAgICAgICAgICAgcy5oZWFkW3BdID0gbSA+PSBfd19zaXplID8gbSAtIF93X3NpemUgOiAwOwogICAgICAgICAgICB9IHdoaWxlICgtLW4pOwogICAgICAgICAgICBuID0gX3dfc2l6ZTsKICAgICAgICAgICAgcCA9IG47CiAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICBtID0gcy5wcmV2Wy0tcF07CiAgICAgICAgICAgICAgcy5wcmV2W3BdID0gbSA+PSBfd19zaXplID8gbSAtIF93X3NpemUgOiAwOwogICAgICAgICAgICB9IHdoaWxlICgtLW4pOwogICAgICAgICAgICBtb3JlICs9IF93X3NpemU7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX2luID09PSAwKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgbiA9IHJlYWRfYnVmKHMuc3RybSwgcy53aW5kb3csIHMuc3Ryc3RhcnQgKyBzLmxvb2thaGVhZCwgbW9yZSk7CiAgICAgICAgICBzLmxvb2thaGVhZCArPSBuOwogICAgICAgICAgaWYgKHMubG9va2FoZWFkICsgcy5pbnNlcnQgPj0gTUlOX01BVENIKSB7CiAgICAgICAgICAgIHN0ciA9IHMuc3Ryc3RhcnQgLSBzLmluc2VydDsKICAgICAgICAgICAgcy5pbnNfaCA9IHMud2luZG93W3N0cl07CiAgICAgICAgICAgIHMuaW5zX2ggPSAocy5pbnNfaCA8PCBzLmhhc2hfc2hpZnQgXiBzLndpbmRvd1tzdHIgKyAxXSkgJiBzLmhhc2hfbWFzazsKICAgICAgICAgICAgd2hpbGUgKHMuaW5zZXJ0KSB7CiAgICAgICAgICAgICAgcy5pbnNfaCA9IChzLmluc19oIDw8IHMuaGFzaF9zaGlmdCBeIHMud2luZG93W3N0ciArIE1JTl9NQVRDSCAtIDFdKSAmIHMuaGFzaF9tYXNrOwogICAgICAgICAgICAgIHMucHJldltzdHIgJiBzLndfbWFza10gPSBzLmhlYWRbcy5pbnNfaF07CiAgICAgICAgICAgICAgcy5oZWFkW3MuaW5zX2hdID0gc3RyOwogICAgICAgICAgICAgIHN0cisrOwogICAgICAgICAgICAgIHMuaW5zZXJ0LS07CiAgICAgICAgICAgICAgaWYgKHMubG9va2FoZWFkICsgcy5pbnNlcnQgPCBNSU5fTUFUQ0gpIHsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gd2hpbGUgKHMubG9va2FoZWFkIDwgTUlOX0xPT0tBSEVBRCAmJiBzLnN0cm0uYXZhaWxfaW4gIT09IDApOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRlZmxhdGVfc3RvcmVkKHMsIGZsdXNoKSB7CiAgICAgICAgdmFyIG1heF9ibG9ja19zaXplID0gNjU1MzU7CiAgICAgICAgaWYgKG1heF9ibG9ja19zaXplID4gcy5wZW5kaW5nX2J1Zl9zaXplIC0gNSkgewogICAgICAgICAgbWF4X2Jsb2NrX3NpemUgPSBzLnBlbmRpbmdfYnVmX3NpemUgLSA1OwogICAgICAgIH0KICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA8PSAxKSB7CiAgICAgICAgICAgIGZpbGxfd2luZG93KHMpOwogICAgICAgICAgICBpZiAocy5sb29rYWhlYWQgPT09IDAgJiYgZmx1c2ggPT09IFpfTk9fRkxVU0gpIHsKICAgICAgICAgICAgICByZXR1cm4gQlNfTkVFRF9NT1JFOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA9PT0gMCkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBzLnN0cnN0YXJ0ICs9IHMubG9va2FoZWFkOwogICAgICAgICAgcy5sb29rYWhlYWQgPSAwOwogICAgICAgICAgdmFyIG1heF9zdGFydCA9IHMuYmxvY2tfc3RhcnQgKyBtYXhfYmxvY2tfc2l6ZTsKICAgICAgICAgIGlmIChzLnN0cnN0YXJ0ID09PSAwIHx8IHMuc3Ryc3RhcnQgPj0gbWF4X3N0YXJ0KSB7CiAgICAgICAgICAgIHMubG9va2FoZWFkID0gcy5zdHJzdGFydCAtIG1heF9zdGFydDsKICAgICAgICAgICAgcy5zdHJzdGFydCA9IG1heF9zdGFydDsKICAgICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCBmYWxzZSk7CiAgICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKHMuc3Ryc3RhcnQgLSBzLmJsb2NrX3N0YXJ0ID49IHMud19zaXplIC0gTUlOX0xPT0tBSEVBRCkgewogICAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIGZhbHNlKTsKICAgICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgICByZXR1cm4gQlNfTkVFRF9NT1JFOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHMuaW5zZXJ0ID0gMDsKICAgICAgICBpZiAoZmx1c2ggPT09IFpfRklOSVNIKSB7CiAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIHRydWUpOwogICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgcmV0dXJuIEJTX0ZJTklTSF9TVEFSVEVEOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIEJTX0ZJTklTSF9ET05FOwogICAgICAgIH0KICAgICAgICBpZiAocy5zdHJzdGFydCA+IHMuYmxvY2tfc3RhcnQpIHsKICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgZmFsc2UpOwogICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgfQogICAgICBmdW5jdGlvbiBkZWZsYXRlX2Zhc3QocywgZmx1c2gpIHsKICAgICAgICB2YXIgaGFzaF9oZWFkOwogICAgICAgIHZhciBiZmx1c2g7CiAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICBpZiAocy5sb29rYWhlYWQgPCBNSU5fTE9PS0FIRUFEKSB7CiAgICAgICAgICAgIGZpbGxfd2luZG93KHMpOwogICAgICAgICAgICBpZiAocy5sb29rYWhlYWQgPCBNSU5fTE9PS0FIRUFEICYmIGZsdXNoID09PSBaX05PX0ZMVVNIKSB7CiAgICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAocy5sb29rYWhlYWQgPT09IDApIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaGFzaF9oZWFkID0gMDsKICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA+PSBNSU5fTUFUQ0gpIHsKICAgICAgICAgICAgcy5pbnNfaCA9IChzLmluc19oIDw8IHMuaGFzaF9zaGlmdCBeIHMud2luZG93W3Muc3Ryc3RhcnQgKyBNSU5fTUFUQ0ggLSAxXSkgJiBzLmhhc2hfbWFzazsKICAgICAgICAgICAgaGFzaF9oZWFkID0gcy5wcmV2W3Muc3Ryc3RhcnQgJiBzLndfbWFza10gPSBzLmhlYWRbcy5pbnNfaF07CiAgICAgICAgICAgIHMuaGVhZFtzLmluc19oXSA9IHMuc3Ryc3RhcnQ7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoaGFzaF9oZWFkICE9PSAwICYmIHMuc3Ryc3RhcnQgLSBoYXNoX2hlYWQgPD0gcy53X3NpemUgLSBNSU5fTE9PS0FIRUFEKSB7CiAgICAgICAgICAgIHMubWF0Y2hfbGVuZ3RoID0gbG9uZ2VzdF9tYXRjaChzLCBoYXNoX2hlYWQpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHMubWF0Y2hfbGVuZ3RoID49IE1JTl9NQVRDSCkgewogICAgICAgICAgICBiZmx1c2ggPSB0cmVlcy5fdHJfdGFsbHkocywgcy5zdHJzdGFydCAtIHMubWF0Y2hfc3RhcnQsIHMubWF0Y2hfbGVuZ3RoIC0gTUlOX01BVENIKTsKICAgICAgICAgICAgcy5sb29rYWhlYWQgLT0gcy5tYXRjaF9sZW5ndGg7CiAgICAgICAgICAgIGlmIChzLm1hdGNoX2xlbmd0aCA8PSBzLm1heF9sYXp5X21hdGNoICYmIHMubG9va2FoZWFkID49IE1JTl9NQVRDSCkgewogICAgICAgICAgICAgIHMubWF0Y2hfbGVuZ3RoLS07CiAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgcy5zdHJzdGFydCsrOwogICAgICAgICAgICAgICAgcy5pbnNfaCA9IChzLmluc19oIDw8IHMuaGFzaF9zaGlmdCBeIHMud2luZG93W3Muc3Ryc3RhcnQgKyBNSU5fTUFUQ0ggLSAxXSkgJiBzLmhhc2hfbWFzazsKICAgICAgICAgICAgICAgIGhhc2hfaGVhZCA9IHMucHJldltzLnN0cnN0YXJ0ICYgcy53X21hc2tdID0gcy5oZWFkW3MuaW5zX2hdOwogICAgICAgICAgICAgICAgcy5oZWFkW3MuaW5zX2hdID0gcy5zdHJzdGFydDsKICAgICAgICAgICAgICB9IHdoaWxlICgtLXMubWF0Y2hfbGVuZ3RoICE9PSAwKTsKICAgICAgICAgICAgICBzLnN0cnN0YXJ0Kys7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgcy5zdHJzdGFydCArPSBzLm1hdGNoX2xlbmd0aDsKICAgICAgICAgICAgICBzLm1hdGNoX2xlbmd0aCA9IDA7CiAgICAgICAgICAgICAgcy5pbnNfaCA9IHMud2luZG93W3Muc3Ryc3RhcnRdOwogICAgICAgICAgICAgIHMuaW5zX2ggPSAocy5pbnNfaCA8PCBzLmhhc2hfc2hpZnQgXiBzLndpbmRvd1tzLnN0cnN0YXJ0ICsgMV0pICYgcy5oYXNoX21hc2s7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGJmbHVzaCA9IHRyZWVzLl90cl90YWxseShzLCAwLCBzLndpbmRvd1tzLnN0cnN0YXJ0XSk7CiAgICAgICAgICAgIHMubG9va2FoZWFkLS07CiAgICAgICAgICAgIHMuc3Ryc3RhcnQrKzsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChiZmx1c2gpIHsKICAgICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCBmYWxzZSk7CiAgICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBzLmluc2VydCA9IHMuc3Ryc3RhcnQgPCBNSU5fTUFUQ0ggLSAxID8gcy5zdHJzdGFydCA6IE1JTl9NQVRDSCAtIDE7CiAgICAgICAgaWYgKGZsdXNoID09PSBaX0ZJTklTSCkgewogICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCB0cnVlKTsKICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBCU19GSU5JU0hfU1RBUlRFRDsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBCU19GSU5JU0hfRE9ORTsKICAgICAgICB9CiAgICAgICAgaWYgKHMubGFzdF9saXQpIHsKICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgZmFsc2UpOwogICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIEJTX0JMT0NLX0RPTkU7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZGVmbGF0ZV9zbG93KHMsIGZsdXNoKSB7CiAgICAgICAgdmFyIGhhc2hfaGVhZDsKICAgICAgICB2YXIgYmZsdXNoOwogICAgICAgIHZhciBtYXhfaW5zZXJ0OwogICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgaWYgKHMubG9va2FoZWFkIDwgTUlOX0xPT0tBSEVBRCkgewogICAgICAgICAgICBmaWxsX3dpbmRvdyhzKTsKICAgICAgICAgICAgaWYgKHMubG9va2FoZWFkIDwgTUlOX0xPT0tBSEVBRCAmJiBmbHVzaCA9PT0gWl9OT19GTFVTSCkgewogICAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHMubG9va2FoZWFkID09PSAwKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGhhc2hfaGVhZCA9IDA7CiAgICAgICAgICBpZiAocy5sb29rYWhlYWQgPj0gTUlOX01BVENIKSB7CiAgICAgICAgICAgIHMuaW5zX2ggPSAocy5pbnNfaCA8PCBzLmhhc2hfc2hpZnQgXiBzLndpbmRvd1tzLnN0cnN0YXJ0ICsgTUlOX01BVENIIC0gMV0pICYgcy5oYXNoX21hc2s7CiAgICAgICAgICAgIGhhc2hfaGVhZCA9IHMucHJldltzLnN0cnN0YXJ0ICYgcy53X21hc2tdID0gcy5oZWFkW3MuaW5zX2hdOwogICAgICAgICAgICBzLmhlYWRbcy5pbnNfaF0gPSBzLnN0cnN0YXJ0OwogICAgICAgICAgfQogICAgICAgICAgcy5wcmV2X2xlbmd0aCA9IHMubWF0Y2hfbGVuZ3RoOwogICAgICAgICAgcy5wcmV2X21hdGNoID0gcy5tYXRjaF9zdGFydDsKICAgICAgICAgIHMubWF0Y2hfbGVuZ3RoID0gTUlOX01BVENIIC0gMTsKICAgICAgICAgIGlmIChoYXNoX2hlYWQgIT09IDAgJiYgcy5wcmV2X2xlbmd0aCA8IHMubWF4X2xhenlfbWF0Y2ggJiYgcy5zdHJzdGFydCAtIGhhc2hfaGVhZCA8PSBzLndfc2l6ZSAtIE1JTl9MT09LQUhFQUQpIHsKICAgICAgICAgICAgcy5tYXRjaF9sZW5ndGggPSBsb25nZXN0X21hdG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ICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gd2hpbGUgKC0tcy5wcmV2X2xlbmd0aCAhPT0gMCk7CiAgICAgICAgICAgIHMubWF0Y2hfYXZhaWxhYmxlID0gMDsKICAgICAgICAgICAgcy5tYXRjaF9sZW5ndGggPSBNSU5fTUFUQ0ggLSAxOwogICAgICAgICAgICBzLnN0cnN0YXJ0Kys7CiAgICAgICAgICAgIGlmIChiZmx1c2gpIHsKICAgICAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIGZhbHNlKTsKICAgICAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSBpZiAocy5tYXRjaF9hdmFpbGFibGUpIHsKICAgICAgICAgICAgYmZsdXNoID0gdHJlZXMuX3RyX3RhbGx5KHMsIDAsIHMud2luZG93W3Muc3Ryc3RhcnQgLSAxXSk7CiAgICAgICAgICAgIGlmIChiZmx1c2gpIHsKICAgICAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIGZhbHNlKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBzLnN0cnN0YXJ0Kys7CiAgICAgICAgICAgIHMubG9va2FoZWFkLS07CiAgICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcy5tYXRjaF9hdmFpbGFibGUgPSAxOwogICAgICAgICAgICBzLnN0cnN0YXJ0Kys7CiAgICAgICAgICAgIHMubG9va2FoZWFkLS07CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChzLm1hdGNoX2F2YWlsYWJsZSkgewogICAgICAgICAgYmZsdXNoID0gdHJlZXMuX3RyX3RhbGx5KHMsIDAsIHMud2luZG93W3Muc3Ryc3RhcnQgLSAxXSk7CiAgICAgICAgICBzLm1hdGNoX2F2YWlsYWJsZSA9IDA7CiAgICAgICAgfQogICAgICAgIHMuaW5zZXJ0ID0gcy5zdHJzdGFydCA8IE1JTl9NQVRDSCAtIDEgPyBzLnN0cnN0YXJ0IDogTUlOX01BVENIIC0gMTsKICAgICAgICBpZiAoZmx1c2ggPT09IFpfRklOSVNIKSB7CiAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIHRydWUpOwogICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgcmV0dXJuIEJTX0ZJTklTSF9TVEFSVEVEOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIEJTX0ZJTklTSF9ET05FOwogICAgICAgIH0KICAgICAgICBpZiAocy5sYXN0X2xpdCkgewogICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCBmYWxzZSk7CiAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICByZXR1cm4gQlNfTkVFRF9NT1JFOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gQlNfQkxPQ0tfRE9ORTsKICAgICAgfQogICAgICBmdW5jdGlvbiBkZWZsYXRlX3JsZShzLCBmbHVzaCkgewogICAgICAgIHZhciBiZmx1c2g7CiAgICAgICAgdmFyIHByZXY7CiAgICAgICAgdmFyIHNjYW4sIHN0cmVuZDsKICAgICAgICB2YXIgX3dpbiA9IHMud2luZG93OwogICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgaWYgKHMubG9va2FoZWFkIDw9IE1BWF9NQVRDSCkgewogICAgICAgICAgICBmaWxsX3dpbmRvdyhzKTsKICAgICAgICAgICAgaWYgKHMubG9va2FoZWFkIDw9IE1BWF9NQVRDSCAmJiBmbHVzaCA9PT0gWl9OT19GTFVTSCkgewogICAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHMubG9va2FoZWFkID09PSAwKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHMubWF0Y2hfbGVuZ3RoID0gMDsKICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA+PSBNSU5fTUFUQ0ggJiYgcy5zdHJzdGFydCA+IDApIHsKICAgICAgICAgICAgc2NhbiA9IHMuc3Ryc3RhcnQgLSAxOwogICAgICAgICAgICBwcmV2ID0gX3dpbltzY2FuXTsKICAgICAgICAgICAgaWYgKHByZXYgPT09IF93aW5bKytzY2FuXSAmJiBwcmV2ID09PSBfd2luWysrc2Nhbl0gJiYgcHJldiA9PT0gX3dpblsrK3NjYW5dKSB7CiAgICAgICAgICAgICAgc3RyZW5kID0gcy5zdHJzdGFydCArIE1BWF9NQVRDSDsKICAgICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgfSB3aGlsZSAocHJldiA9PT0gX3dpblsrK3NjYW5dICYmIHByZXYgPT09IF93aW5bKytzY2FuXSAmJiBwcmV2ID09PSBfd2luWysrc2Nhbl0gJiYgcHJldiA9PT0gX3dpblsrK3NjYW5dICYmIHByZXYgPT09IF93aW5bKytzY2FuXSAmJiBwcmV2ID09PSBfd2luWysrc2Nhbl0gJiYgcHJldiA9PT0gX3dpblsrK3NjYW5dICYmIHByZXYgPT09IF93aW5bKytzY2FuXSAmJiBzY2FuIDwgc3RyZW5kKTsKICAgICAgICAgICAgICBzLm1hdGNoX2xlbmd0aCA9IE1BWF9NQVRDSCAtIChzdHJlbmQgLSBzY2FuKTsKICAgICAgICAgICAgICBpZiAocy5tYXRjaF9sZW5ndGggPiBzLmxvb2thaGVhZCkgewogICAgICAgICAgICAgICAgcy5tYXRjaF9sZW5ndGggPSBzLmxvb2thaGVhZDsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzLm1hdGNoX2xlbmd0aCA+PSBNSU5fTUFUQ0gpIHsKICAgICAgICAgICAgYmZsdXNoID0gdHJlZXMuX3RyX3RhbGx5KHMsIDEsIHMubWF0Y2hfbGVuZ3RoIC0gTUlOX01BVENIKTsKICAgICAgICAgICAgcy5sb29rYWhlYWQgLT0gcy5tYXRjaF9sZW5ndGg7CiAgICAgICAgICAgIHMuc3Ryc3RhcnQgKz0gcy5tYXRjaF9sZW5ndGg7CiAgICAgICAgICAgIHMubWF0Y2hfbGVuZ3RoID0gMDsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGJmbHVzaCA9IHRyZWVzLl90cl90YWxseShzLCAwLCBzLndpbmRvd1tzLnN0cnN0YXJ0XSk7CiAgICAgICAgICAgIHMubG9va2FoZWFkLS07CiAgICAgICAgICAgIHMuc3Ryc3RhcnQrKzsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChiZmx1c2gpIHsKICAgICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCBmYWxzZSk7CiAgICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBzLmluc2VydCA9IDA7CiAgICAgICAgaWYgKGZsdXNoID09PSBaX0ZJTklTSCkgewogICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCB0cnVlKTsKICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBCU19GSU5JU0hfU1RBUlRFRDsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBCU19GSU5JU0hfRE9ORTsKICAgICAgICB9CiAgICAgICAgaWYgKHMubGFzdF9saXQpIHsKICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgZmFsc2UpOwogICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIEJTX0JMT0NLX0RPTkU7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZGVmbGF0ZV9odWZmKHMsIGZsdXNoKSB7CiAgICAgICAgdmFyIGJmbHVzaDsKICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA9PT0gMCkgewogICAgICAgICAgICBmaWxsX3dpbmRvdyhzKTsKICAgICAgICAgICAgaWYgKHMubG9va2FoZWFkID09PSAwKSB7CiAgICAgICAgICAgICAgaWYgKGZsdXNoID09PSBaX05PX0ZMVVNIKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gQlNfTkVFRF9NT1JFOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgcy5tYXRjaF9sZW5ndGggPSAwOwogICAgICAgICAgYmZsdXNoID0gdHJlZXMuX3RyX3RhbGx5KHMsIDAsIHMud2luZG93W3Muc3Ryc3RhcnRdKTsKICAgICAgICAgIHMubG9va2FoZWFkLS07CiAgICAgICAgICBzLnN0cnN0YXJ0Kys7CiAgICAgICAgICBpZiAoYmZsdXNoKSB7CiAgICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgZmFsc2UpOwogICAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcy5pbnNlcnQgPSAwOwogICAgICAgIGlmIChmbHVzaCA9PT0gWl9GSU5JU0gpIHsKICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgdHJ1ZSk7CiAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICByZXR1cm4gQlNfRklOSVNIX1NUQVJURUQ7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gQlNfRklOSVNIX0RPTkU7CiAgICAgICAgfQogICAgICAgIGlmIChzLmxhc3RfbGl0KSB7CiAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIGZhbHNlKTsKICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiBCU19CTE9DS19ET05FOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIENvbmZpZyhnb29kX2xlbmd0aCwgbWF4X2xhenksIG5pY2VfbGVuZ3RoLCBtYXhfY2hhaW4sIGZ1bmMpIHsKICAgICAgICB0aGlzLmdvb2RfbGVuZ3RoID0gZ29vZF9sZW5ndGg7CiAgICAgICAgdGhpcy5tYXhfbGF6eSA9IG1heF9sYXp5OwogICAgICAgIHRoaXMubmljZV9sZW5ndGggPSBuaWNlX2xlbmd0aDsKICAgICAgICB0aGlzLm1heF9jaGFpbiA9IG1heF9jaGFpbjsKICAgICAgICB0aGlzLmZ1bmMgPSBmdW5jOwogICAgICB9CiAgICAgIHZhciBjb25maWd1cmF0aW9uX3RhYmxlOwogICAgICBjb25maWd1cmF0aW9uX3RhYmxlID0gWwogICAgICAgIG5ldyBDb25maWcoMCwgMCwgMCwgMCwgZGVmbGF0ZV9zdG9yZWQpLAogICAgICAgIG5ldyBDb25maWcoNCwgNCwgOCwgNCwgZGVmbGF0ZV9mYXN0KSwKICAgICAgICBuZXcgQ29uZmlnKDQsIDUsIDE2LCA4LCBkZWZsYXRlX2Zhc3QpLAogICAgICAgIG5ldyBDb25maWcoNCwgNiwgMzIsIDMyLCBkZWZsYXRlX2Zhc3QpLAogICAgICAgIG5ldyBDb25maWcoNCwgNCwgMTY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zLmluc19oID0gMDsKICAgICAgfQogICAgICBmdW5jdGlvbiBEZWZsYXRlU3RhdGUoKSB7CiAgICAgICAgdGhpcy5zdHJtID0gbnVsbDsKICAgICAgICB0aGlzLnN0YXR1cyA9IDA7CiAgICAgICAgdGhpcy5wZW5kaW5nX2J1ZiA9IG51bGw7CiAgICAgICAgdGhpcy5wZW5kaW5nX2J1Zl9zaXplID0gMDsKICAgICAgICB0aGlzLnBlbmRpbmdfb3V0ID0gMDsKICAgICAgICB0aGlzLnBlbmRpbmcgPSAwOwogICAgICAgIHRoaXMud3JhcCA9IDA7CiAgICAgICAgdGhpcy5nemhlYWQgPSBudWxsOwogICAgICAgIHRoaXMuZ3ppbmRleCA9IDA7CiAgICAgICAgdGhpcy5tZXRob2QgPSBaX0RFRkxBVEVEOwogICAgICAgIHRoaXMubGFzdF9mbHVzaCA9IC0xOwogICAgICAgIHRoaXMud19zaXplID0gMDsKICAgICAgICB0aGlzLndfYml0cyA9IDA7CiAgICAgICAgdGhpcy53X21hc2sgPSAwOwogICAgICAgIHRoaXMud2luZG93ID0gbnVsbDsKICAgICAgICB0aGlzLndpbmRvd19zaXplID0gMDsKICAgICAgICB0aGlzLnByZXYgPSBudWxsOwogICAgICAgIHRoaXMuaGVhZCA9IG51bGw7CiAgICAgICAgdGhpcy5pbnNfaCA9IDA7CiAgICAgICAgdGhpcy5oYXNoX3NpemUgPSAwOwogICAgICAgIHRoaXMuaGFzaF9iaXRzID0gMDsKICAgICAgICB0aGlzLmhhc2hfbWFzayA9IDA7CiAgICAgICAgdGhpcy5oYXNoX3NoaWZ0ID0gMDsKICAgICAgICB0aGlzLmJsb2NrX3N0YXJ0ID0gMDsKICAgICAgICB0aGlzLm1hdGNoX2xlbmd0aCA9IDA7CiAgICAgICAgdGhpcy5wcmV2X21hdGNoID0gMDsKICAgICAgICB0aGlzLm1hdGNoX2F2YWlsYWJsZSA9IDA7CiAgICAgICAgdGhpcy5zdHJzdGFydCA9IDA7CiAgICAgICAgdGhpcy5tYXRjaF9zdGFydCA9IDA7CiAgICAgICAgdGhpcy5sb29rYWhlYWQgPSAwOwogICAgICAgIHRoaXMucHJldl9sZW5ndGggPSAwOwogICAgICAgIHRoaXMubWF4X2NoYWluX2xlbmd0aCA9IDA7CiAgICAgICAgdGhpcy5tYXhfbGF6eV9tYXRjaCA9IDA7CiAgICAgICAgdGhpcy5sZXZlbCA9IDA7CiAgICAgICAgdGhpcy5zdHJhdGVneSA9IDA7CiAgICAgICAgdGhpcy5nb29kX21hdGNoID0gMDsKICAgICAgICB0aGlzLm5pY2VfbWF0Y2ggPSAwOwogICAgICAgIHRoaXMuZHluX2x0cmVlID0gbmV3IHV0aWxzLkJ1ZjE2KEhFQVBfU0laRSAqIDIpOwogICAgICAgIHRoaXMuZHluX2R0cmVlID0gbmV3IHV0aWxzLkJ1ZjE2KCgyICogRF9DT0RFUyArIDEpICogMik7CiAgICAgICAgdGhpcy5ibF90cmVlID0gbmV3IHV0aWxzLkJ1ZjE2KCgyICogQkxfQ09ERVMgKyAxKSAqIDIpOwogICAgICAgIHplcm8odGhpcy5keW5fbHRyZWUpOwogICAgICAgIHplcm8odGhpcy5keW5fZHRyZWUpOwogICAgICAgIHplcm8odGhpcy5ibF90cmVlKTsKICAgICAgICB0aGlzLmxfZGVzYyA9IG51bGw7CiAgICAgICAgdGhpcy5kX2Rlc2MgPSBudWxsOwogICAgICAgIHRoaXMuYmxfZGVzYyA9IG51bGw7CiAgICAgICAgdGhpcy5ibF9jb3VudCA9IG5ldyB1dGlscy5CdWYxNihNQVhfQklUUyArIDEpOwogICAgICAgIHRoaXMuaGVhcCA9IG5ldyB1dGlscy5CdWYxNigyICogTF9DT0RFUyArIDEpOwogICAgICAgIHplcm8odGhpcy5oZWFwKTsKICAgICAgICB0aGlzLmhlYXBfbGVuID0gMDsKICAgICAgICB0aGlzLmhlYXBfbWF4ID0gMDsKICAgICAgICB0aGlzLmRlcHRoID0gbmV3IHV0aWxzLkJ1ZjE2KDIgKiBMX0NPREVTICsgMSk7CiAgICAgICAgemVybyh0aGlzLmRlcHRoKTsKICAgICAgICB0aGlzLmxfYnVmID0gMDsKICAgICAgICB0aGlzLmxpdF9idWZzaXplID0gMDsKICAgICAgICB0aGlzLmxhc3RfbGl0ID0gMDsKICAgICAgICB0aGlzLmRfYnVmID0gMDsKICAgICAgICB0aGlzLm9wdF9sZW4gPSAwOwogICAgICAgIHRoaXMuc3RhdGljX2xlbiA9IDA7CiAgICAgICAgdGhpcy5tYXRjaGVzID0gMDsKICAgICAgICB0aGlzLmluc2VydCA9IDA7CiAgICAgICAgdGhpcy5iaV9idWYgPSAwOwogICAgICAgIHRoaXMuYmlfdmFsaWQgPSAwOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRlZmxhdGVSZXNldEtlZXAoc3RybSkgewogICAgICAgIHZhciBzOwogICAgICAgIGlmICghc3RybSB8fCAhc3RybS5zdGF0ZSkgewogICAgICAgICAgcmV0dXJuIGVycihzdHJtLCBaX1NUUkVBTV9FUlJPUik7CiAgICAgICAgfQogICAgICAgIHN0cm0udG90YWxfaW4gPSBzdHJtLnRvdGFsX291dCA9IDA7CiAgICAgICAgc3RybS5kYXRhX3R5cGUgPSBaX1VOS05PV047CiAgICAgICAgcyA9IHN0cm0uc3RhdGU7CiAgICAgICAgcy5wZW5kaW5nID0gMDsKICAgICAgICBzLnBlbmRpbmdfb3V0ID0gMDsKICAgICAgICBpZiAocy53cmFwIDwgMCkgewogICAgICAgICAgcy53cmFwID0gLXMud3JhcDsKICAgICAgICB9CiAgICAgICAgcy5zdGF0dXMgPSBzLndyYXAgPyBJTklUX1NUQVRFIDogQlVTWV9TVEFURTsKICAgICAgICBzdHJtLmFkbGVyID0gcy53cmFwID09PSAyID8gMCA6IDE7CiAgICAgICAgcy5sYXN0X2ZsdXNoID0gWl9OT19GTFVTSDsKICAgICAgICB0cmVlcy5fdHJfaW5pdChzKTsKICAgICAgICByZXR1cm4gWl9PSzsKICAgICAgfQogICAgICBmdW5jdGlvbiBkZWZsYXRlUmVzZXQoc3RybSkgewogICAgICAgIHZhciByZXQgPSBkZWZsYXRlUmVzZXRLZWVwKHN0cm0pOwogICAgICAgIGlmIChyZXQgPT09IFpfT0spIHsKICAgICAgICAgIGxtX2luaXQoc3RybS5zdGF0ZSk7CiAgICAgICAgfQogICAgICAgIHJldHVybiByZXQ7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZGVmbGF0ZVNldEhlYWRlcihzdHJtLCBoZWFkKSB7CiAgICAgICAgaWYgKCFzdHJtIHx8ICFzdHJtLnN0YXRlKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIGlmIChzdHJtLnN0YXRlLndyYXAgIT09IDIpIHsKICAgICAgICAgIHJldHVybiBaX1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgc3RybS5zdGF0ZS5nemhlYWQgPSBoZWFkOwogICAgICAgIHJldHVybiBaX09LOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRlZmxhdGVJbml0MihzdHJtLCBsZXZlbCwgbWV0aG9kLCB3aW5kb3dCaXRzLCBtZW1MZXZlbCwgc3RyYXRlZ3kpIHsKICAgICAgICBpZiAoIXN0cm0pIHsKICAgICAgICAgIHJldHVybiBaX1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgdmFyIHdyYXAgPSAxOwogICAgICAgIGlmIChsZXZlbCA9PT0gWl9ERUZBVUxUX0NPTVBSRVNTSU9OKSB7CiAgICAgICAgICBsZXZlbCA9IDY7CiAgICAgICAgfQogICAgICAgIGlmICh3aW5kb3dCaXRzIDwgMCkgewogICAgICAgICAgd3JhcCA9IDA7CiAgICAgICAgICB3aW5kb3dCaXRzID0gLXdpbmRvd0JpdHM7CiAgICAgICAgfSBlbHNlIGlmICh3aW5kb3dCaXRzID4gMTUpIHsKICAgICAgICAgIHdyYXAgPSAyOwogICAgICAgICAgd2luZG93Qml0cyAtPSAxNjsKICAgICAgICB9CiAgICAgICAgaWYgKG1lbUxldmVsIDwgMSB8fCBtZW1MZXZlbCA+IE1BWF9NRU1fTEVWRUwgfHwgbWV0aG9kICE9PSBaX0RFRkxBVEVEIHx8IHdpbmRvd0JpdHMgPCA4IHx8IHdpbmRvd0JpdHMgPiAxNSB8fCBsZXZlbCA8IDAgfHwgbGV2ZWwgPiA5IHx8IHN0cmF0ZWd5IDwgMCB8fCBzdHJhdGVneSA+IFpfRklYRUQpIHsKICAgICAgICAgIHJldHVybiBlcnIoc3RybSwgWl9TVFJFQU1fRVJST1IpOwogICAgICAgIH0KICAgICAgICBpZiAod2luZG93Qml0cyA9PT0gOCkgewogICAgICAgICAgd2luZG93Qml0cyA9IDk7CiAgICAgICAgfQogICAgICAgIHZhciBzID0gbmV3IERlZmxhdGVTdGF0ZSgpOwogICAgICAgIHN0cm0uc3RhdGUgPSBzOwogICAgICAgIHMuc3RybSA9IHN0cm07CiAgICAgICAgcy53cmFwID0gd3JhcDsKICAgICAgICBzLmd6aGVhZCA9IG51bGw7CiAgICAgICAgcy53X2JpdHMgPSB3aW5kb3dCaXRzOwogICAgICAgIHMud19zaXplID0gMSA8PCBzLndfYml0czsKICAgICAgICBzLndfbWFzayA9IHMud19zaXplIC0gMTsKICAgICAgICBzLmhhc2hfYml0cyA9IG1lbUxldmVsICsgNzsKICAgICAgICBzLmhhc2hfc2l6ZSA9IDEgPDwgcy5oYXNoX2JpdHM7CiAgICAgICAgcy5oYXNoX21hc2sgPSBzLmhhc2hfc2l6ZSAtIDE7CiAgICAgICAgcy5oYXNoX3NoaWZ0ID0gfn4oKHMuaGFzaF9iaXRzICsgTUlOX01BVENIIC0gMSkgLyBNSU5fTUFUQ0gpOwogICAgICAgIHMud2luZG93ID0gbmV3IHV0aWxzLkJ1Zjgocy53X3NpemUgKiAyKTsKICAgICAgICBzLmhlYWQgPSBuZXcgdXRpbHMuQnVmMTYocy5oYXNoX3NpemUpOwogICAgICAgIHMucHJldiA9IG5ldyB1dGl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hdmFpbF9pbiAhPT0gMCB8fCBzLnN0YXR1cyA9PT0gRklOSVNIX1NUQVRFICYmIGZsdXNoICE9PSBaX0ZJTklTSCkgewogICAgICAgICAgcmV0dXJuIGVycihzdHJtLCBzdHJtLmF2YWlsX291dCA9PT0gMCA/IFpfQlVGX0VSUk9SIDogWl9TVFJFQU1fRVJST1IpOwogICAgICAgIH0KICAgICAgICBzLnN0cm0gPSBzdHJtOwogICAgICAgIG9sZF9mbHVzaCA9IHMubGFzdF9mbHVzaDsKICAgICAgICBzLmxhc3RfZmx1c2ggPSBmbHVzaDsKICAgICAgICBpZiAocy5zdGF0dXMgPT09IElOSVRfU1RBVEUpIHsKICAgICAgICAgIGlmIChzLndyYXAgPT09IDIpIHsKICAgICAgICAgICAgc3RybS5hZGxlciA9IDA7CiAgICAgICAgICAgIHB1dF9ieXRlKHMsIDMxKTsKICAgICAgICAgICAgcHV0X2J5dGUocywgMTM5KTsKICAgICAgICAgICAgcHV0X2J5dGUocywgOCk7CiAgICAgICAgICAgIGlmICghcy5nemhlYWQpIHsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCAwKTsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCAwKTsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCAwKTsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCAwKTsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCAwKTsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCBzLmxldmVsID09PSA5ID8gMiA6IHMuc3RyYXRlZ3kgPj0gWl9IVUZGTUFOX09OTFkgfHwgcy5sZXZlbCA8IDIgPyA0IDogMCk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgT1NfQ09ERSk7CiAgICAgICAgICAgICAgcy5zdGF0dXMgPSBCVVNZX1NUQVRFOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIChzLmd6aGVhZC50ZXh0ID8gMSA6IDApICsgKHMuZ3poZWFkLmhjcmMgPyAyIDogMCkgKyAoIXMuZ3poZWFkLmV4dHJhID8gMCA6IDQpICsgKCFzLmd6aGVhZC5uYW1lID8gMCA6IDgpICsgKCFzLmd6aGVhZC5jb21tZW50ID8gMCA6IDE2KSk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgcy5nemhlYWQudGltZSAmIDI1NSk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgcy5nemhlYWQudGltZSA+PiA4ICYgMjU1KTsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCBzLmd6aGVhZC50aW1lID4+IDE2ICYgMjU1KTsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCBzLmd6aGVhZC50aW1lID4+IDI0ICYgMjU1KTsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCBzLmxldmVsID09PSA5ID8gMiA6IHMuc3RyYXRlZ3kgPj0gWl9IVUZGTUFOX09OTFkgfHwgcy5sZXZlbCA8IDIgPyA0IDogMCk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgcy5nemhlYWQub3MgJiAyNTUpOwogICAgICAgICAgICAgIGlmIChzLmd6aGVhZC5leHRyYSAmJiBzLmd6aGVhZC5leHRyYS5sZW5ndGgpIHsKICAgICAgICAgICAgICAgIHB1dF9ieXRlKHMsIHMuZ3poZWFkLmV4dHJhLmxlbmd0aCAmIDI1NSk7CiAgICAgICAgICAgICAgICBwdXRfYnl0ZShzLCBzLmd6aGVhZC5leHRyYS5sZW5ndGggPj4gOCAmIDI1NSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChzLmd6aGVhZC5oY3JjKSB7CiAgICAgICAgICAgICAgICBzdHJtLmFkbGVyID0gY3JjMzIyKHN0cm0uYWRsZXIsIHMucGVuZGluZ19idWYsIHMucGVuZGluZywgMCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHMuZ3ppbmRleCA9IDA7CiAgICAgICAgICAgICAgcy5zdGF0dXMgPSBFWFRSQV9TVEFURTsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgdmFyIGhlYWRlciA9IFpfREVGTEFURUQgKyAocy53X2JpdHMgLSA4IDw8IDQpIDw8IDg7CiAgICAgICAgICAgIHZhciBsZXZlbF9mbGFncyA9IC0xOwogICAgICAgICAgICBpZiAocy5zdHJhdGVneSA+PSBaX0hVRkZNQU5fT05MWSB8fCBzLmxldmVsIDwgMikgewogICAgICAgICAgICAgIGxldmVsX2ZsYWdzID0gMDsKICAgICAgICAgICAgfSBlbHNlIGlmIChzLmxldmVsIDwgNikgewogICAgICAgICAgICAgIGxldmVsX2ZsYWdzID0gMTsKICAgICAgICAgICAgfSBlbHNlIGlmIChzLmxldmVsID09PSA2KSB7CiAgICAgICAgICAgICAgbGV2ZWxfZmxhZ3MgPSAyOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGxldmVsX2ZsYWdzID0gMzsKICAgICAgICAgICAgfQogICAgICAgICAgICBoZWFkZXIgfD0gbGV2ZWxfZmxhZ3MgPDwgNjsKICAgICAgICAgICAgaWYgKHMuc3Ryc3RhcnQgIT09IDApIHsKICAgICAgICAgICAgICBoZWFkZXIgfD0gUFJFU0VUX0RJQ1Q7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaGVhZGVyICs9IDMxIC0gaGVhZGVyICUgMzE7CiAgICAgICAgICAgIHMuc3RhdHVzID0gQlVTWV9TVEFURTsKICAgICAgICAgICAgcHV0U2hvcnRNU0IocywgaGVhZGVyKTsKICAgICAgICAgICAgaWYgKHMuc3Ryc3RhcnQgIT09IDApIHsKICAgICAgICAgICAgICBwdXRTaG9ydE1TQihzLCBzdHJtLmFkbGVyID4+PiAxNik7CiAgICAgICAgICAgICAgcHV0U2hvcnRNU0Iocywgc3RybS5hZGxlciAmIDY1NTM1KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBzdHJtLmFkbGVyID0gMTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHMuc3RhdHVzID09PSBFWFRSQV9TVEFURSkgewogICAgICAgICAgaWYgKHMuZ3poZWFkLmV4dHJhKSB7CiAgICAgICAgICAgIGJlZyA9IHMucGVuZGluZzsKICAgICAgICAgICAgd2hpbGUgKHMuZ3ppbmRleCA8IChzLmd6aGVhZC5leHRyYS5sZW5ndGggJiA2NTUzNSkpIHsKICAgICAgICAgICAgICBpZiAocy5wZW5kaW5nID09PSBzLnBlbmRpbmdfYnVmX3NpemUpIHsKICAgICAgICAgICAgICAgIGlmIChzLmd6aGVhZC5oY3JjICYmIHMucGVuZGluZyA+IGJlZykgewogICAgICAgICAgICAgICAgICBzdHJtLmFkbGVyID0gY3JjMzIyKHN0cm0uYWRsZXIsIHMucGVuZGluZ19idWYsIHMucGVuZGluZyAtIGJlZywgYmVnKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZsdXNoX3BlbmRpbmcoc3RybSk7CiAgICAgICAgICAgICAgICBiZWcgPSBzLnBlbmRpbmc7CiAgICAgICAgICAgICAgICBpZiAocy5wZW5kaW5nID09PSBzLnBlbmRpbmdfYnVmX3NpemUpIHsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIHMuZ3poZWFkLmV4dHJhW3MuZ3ppbmRleF0gJiAyNTUpOwogICAgICAgICAgICAgIHMuZ3ppbmRleCsrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzLmd6aGVhZC5oY3JjICYmIHMucGVuZGluZyA+IGJlZykgewogICAgICAgICAgICAgIHN0cm0uYWRsZXIgPSBjcmMzMjIoc3RybS5hZGxlciwgcy5wZW5kaW5nX2J1Ziwgcy5wZW5kaW5nIC0gYmVnLCBiZWcpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzLmd6aW5kZXggPT09IHMuZ3poZWFkLmV4dHJhLmxlbmd0aCkgewogICAgICAgICAgICAgIHMuZ3ppbmRleCA9IDA7CiAgICAgICAgICAgICAgcy5zdGF0dXMgPSBOQU1FX1NUQVRFOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzLnN0YXR1cyA9IE5BTUVfU1RBVEU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChzLnN0YXR1cyA9PT0gTkFNRV9TVEFURSkgewogICAgICAgICAgaWYgKHMuZ3poZWFkLm5hbWUpIHsKICAgICAgICAgICAgYmVnID0gcy5wZW5kaW5nOwogICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgaWYgKHMucGVuZGluZyA9PT0gcy5wZW5kaW5nX2J1Zl9zaXplKSB7CiAgICAgICAgICAgICAgICBpZiAocy5nemhlYWQuaGNyYyAmJiBzLnBlbmRpbmcgPiBiZWcpIHsKICAgICAgICAgICAgICAgICAgc3RybS5hZGxlciA9IGNyYzMyMihzdHJtLmFkbGVyLCBzLnBlbmRpbmdfYnVmLCBzLnBlbmRpbmcgLSBiZWcsIGJlZyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmbHVzaF9wZW5kaW5nKHN0cm0pOwogICAgICAgICAgICAgICAgYmVnID0gcy5wZW5kaW5nOwogICAgICAgICAgICAgICAgaWYgKHMucGVuZGluZyA9PT0gcy5wZW5kaW5nX2J1Zl9zaXplKSB7CiAgICAgICAgICAgICAgICAgIHZhbCA9IDE7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAocy5nemluZGV4IDwgcy5nemhlYWQubmFtZS5sZW5ndGgpIHsKICAgICAgICAgICAgICAgIHZhbCA9IHMuZ3poZWFkLm5hbWUuY2hhckNvZGVBdChzLmd6aW5kZXgrKykgJiAyNTU7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHZhbCA9IDA7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIHZhbCk7CiAgICAgICAgICAgIH0gd2hpbGUgKHZhbCAhPT0gMCk7CiAgICAgICAgICAgIGlmIChzLmd6aGVhZC5oY3JjICYmIHMucGVuZGluZyA+IGJlZykgewogICAgICAgICAgICAgIHN0cm0uYWRsZXIgPSBjcmMzMjIoc3RybS5hZGxlciwgcy5wZW5kaW5nX2J1Ziwgcy5wZW5kaW5nIC0gYmVnLCBiZWcpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICh2YWwgPT09IDApIHsKICAgICAgICAgICAgICBzLmd6aW5kZXggPSAwOwogICAgICAgICAgICAgIHMuc3RhdHVzID0gQ09NTUVOVF9TVEFURTsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcy5zdGF0dXMgPSBDT01NRU5UX1NUQVRFOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAocy5zdGF0dXMgPT09IENPTU1FTlRfU1RBVEUpIHsKICAgICAgICAgIGlmIChzLmd6aGVhZC5jb21tZW50KSB7CiAgICAgICAgICAgIGJlZyA9IHMucGVuZGluZzsKICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgIGlmIChzLnBlbmRpbmcgPT09IHMucGVuZGluZ19idWZfc2l6ZSkgewogICAgICAgICAgICAgICAgaWYgKHMuZ3poZWFkLmhjcmMgJiYgcy5wZW5kaW5nID4gYmVnKSB7CiAgICAgICAgICAgICAgICAgIHN0cm0uYWRsZXIgPSBjcmMzMjIoc3RybS5hZGxlciwgcy5wZW5kaW5nX2J1Ziwgcy5wZW5kaW5nIC0gYmVnLCBiZWcpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZmx1c2hfcGVuZGluZyhzdHJtKTsKICAgICAgICAgICAgICAgIGJlZyA9IHMucGVuZGluZzsKICAgICAgICAgICAgICAgIGlmIChzLnBlbmRpbmcgPT09IHMucGVuZGluZ19idWZfc2l6ZSkgewogICAgICAgICAgICAgICAgICB2YWwgPSAxOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHMuZ3ppbmRleCA8IHMuZ3poZWFkLmNvbW1lbnQubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICB2YWwgPSBzLmd6aGVhZC5jb21tZW50LmNoYXJDb2RlQXQocy5nemluZGV4KyspICYgMjU1OwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICB2YWwgPSAwOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBwdXRfYnl0ZShzLCB2YWwpOwogICAgICAgICAgICB9IHdoaWxlICh2YWwgIT09IDApOwogICAgICAgICAgICBpZiAocy5nemhlYWQuaGNyYyAmJiBzLnBlbmRpbmcgPiBiZWcpIHsKICAgICAgICAgICAgICBzdHJtLmFkbGVyID0gY3JjMzIyKHN0cm0uYWRsZXIsIHMucGVuZGluZ19idWYsIHMucGVuZGluZyAtIGJlZywgYmVnKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodmFsID09PSAwKSB7CiAgICAgICAgICAgICAgcy5zdGF0dXMgPSBIQ1JDX1NUQVRFOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzLnN0YXR1cyA9IEhDUkNfU1RBVEU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChzLnN0YXR1cyA9PT0gSENSQ19TVEFURSkgewogICAgICAgICAgaWYgKHMuZ3poZWFkLmhjcmMpIHsKICAgICAgICAgICAgaWYgKHMucGVuZGluZyArIDIgPiBzLnBlbmRpbmdfYnVmX3NpemUpIHsKICAgICAgICAgICAgICBmbHVzaF9wZW5kaW5nKHN0cm0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzLnBlbmRpbmcgKyAyIDw9IHMucGVuZGluZ19idWZfc2l6ZSkgewogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIHN0cm0uYWRsZXIgJiAyNTUpOwogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIHN0cm0uYWRsZXIgPj4gOCAmIDI1NSk7CiAgICAgICAgICAgICAgc3RybS5hZGxlciA9IDA7CiAgICAgICAgICAgICAgcy5zdGF0dXMgPSBCVVNZX1NUQVRFOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzLnN0YXR1cyA9IEJVU1lfU1RBVEU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChzLnBlbmRpbmcgIT09IDApIHsKICAgICAgICAgIGZsdXNoX3BlbmRpbmcoc3RybSk7CiAgICAgICAgICBpZiAoc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgcy5sYXN0X2ZsdXNoID0gLTE7CiAgICAgICAgICAgIHJldHVybiBaX09LOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoc3RybS5hdmFpbF9pbiA9PT0gMCAmJiByYW5rKGZsdXNoKSA8PSByYW5rKG9sZF9mbHVzaCkgJiYgZmx1c2ggIT09IFpfRklOSVNIKSB7CiAgICAgICAgICByZXR1cm4gZXJyKHN0cm0sIFpfQlVGX0VSUk9SKTsKICAgICAgICB9CiAgICAgICAgaWYgKHMuc3RhdHVzID09PSBGSU5JU0hfU1RBVEUgJiYgc3RybS5hdmFpbF9pbiAhPT0gMCkgewogICAgICAgICAgcmV0dXJuIGVycihzdHJtLCBaX0JVRl9FUlJPUik7CiAgICAgICAgfQogICAgICAgIGlmIChzdHJtLmF2YWlsX2luICE9PSAwIHx8IHMubG9va2FoZWFkICE9PSAwIHx8IGZsdXNoICE9PSBaX05PX0ZMVVNIICYmIHMuc3RhdHVzICE9PSBGSU5JU0hfU1RBVEUpIHsKICAgICAgICAgIHZhciBic3RhdGUgPSBzLnN0cmF0ZWd5ID09PSBaX0hVRkZNQU5fT05MWSA/IGRlZmxhdGVfaHVmZihzLCBmbHVzaCkgOiBzLnN0cmF0ZWd5ID09PSBaX1JMRSA/IGRlZmxhdGVfcmxlKHMsIGZsdXNoKSA6IGNvbmZpZ3VyYXRpb25fdGFibGVbcy5sZXZlbF0uZnVuYyhzLCBmbHVzaCk7CiAgICAgICAgICBpZiAoYnN0YXRlID09PSBCU19GSU5JU0hfU1RBUlRFRCB8fCBic3RhdGUgPT09IEJTX0ZJTklTSF9ET05FKSB7CiAgICAgICAgICAgIHMuc3RhdHVzID0gRklOSVNIX1NUQVRFOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGJzdGF0ZSA9PT0gQlNfTkVFRF9NT1JFIHx8IGJzdGF0ZSA9PT0gQlNfRklOSVNIX1NUQVJURUQpIHsKICAgICAgICAgICAgaWYgKHN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgICAgcy5sYXN0X2ZsdXNoID0gLTE7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIFpfT0s7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYnN0YXRlID09PSBCU19CTE9DS19ET05FKSB7CiAgICAgICAgICAgIGlmIChmbHVzaCA9PT0gWl9QQVJUSUFMX0ZMVVNIKSB7CiAgICAgICAgICAgICAgdHJlZXMuX3RyX2FsaWduKHMpOwogICAgICAgICAgICB9IGVsc2UgaWYgKGZsdXNoICE9PSBaX0JMT0NLKSB7CiAgICAgICAgICAgICAgdHJlZXMuX3RyX3N0b3JlZF9ibG9jayhzLCAwLCAwLCBmYWxzZSk7CiAgICAgICAgICAgICAgaWYgKGZsdXNoID09PSBaX0ZVTExfRkxVU0gpIHsKICAgICAgICAgICAgICAgIHplcm8ocy5oZWFkKTsKICAgICAgICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA9PT0gMCkgewogICAgICAgICAgICAgICAgICBzLnN0cnN0YXJ0ID0gMDsKICAgICAgICAgICAgICAgICAgcy5ibG9ja19zdGFydCA9IDA7CiAgICAgICAgICAgICAgICAgIHMuaW5zZXJ0ID0gMDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZmx1c2hfcGVuZGluZyhzdHJtKTsKICAgICAgICAgICAgaWYgKHN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgICAgcy5sYXN0X2ZsdXNoID0gLTE7CiAgICAgICAgICAgICAgcmV0dXJuIFpfT0s7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKGZsdXNoICE9PSBaX0ZJTklTSCkgewogICAgICAgICAgcmV0dXJuIFpfT0s7CiAgICAgICAgfQogICAgICAgIGlmIChzLndyYXAgPD0gMCkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VORDsKICAgICAgICB9CiAgICAgICAgaWYgKHMud3JhcCA9PT0gMikgewogICAgICAgICAgcHV0X2J5dGUocywgc3RybS5hZGxlciAmIDI1NSk7CiAgICAgICAgICBwdXRfYnl0ZShzLCBzdHJtLmFkbGVyID4+IDggJiAyNTUpOwogICAgICAgICAgcHV0X2J5dGUocywgc3RybS5hZGxlciA+PiAxNiAmIDI1NSk7CiAgICAgICAgICBwdXRfYnl0ZShzLCBzdHJtLmFkbGVyID4+IDI0ICYgMjU1KTsKICAgICAgICAgIHB1dF9ieXRlKHMsIHN0cm0udG90YWxfaW4gJiAyNTUpOwogICAgICAgICAgcHV0X2J5dGUocywgc3RybS50b3RhbF9pbiA+PiA4ICYgMjU1KTsKICAgICAgICAgIHB1dF9ieXRlKHMsIHN0cm0udG90YWxfaW4gPj4gMTYgJiAyNTUpOwogICAgICAgICAgcHV0X2J5dGUocywgc3RybS50b3RhbF9pbiA+PiAyNCAmIDI1NSk7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHB1dFNob3J0TVNCKHMsIHN0cm0uYWRsZXIgPj4+IDE2KTsKICAgICAgICAgIHB1dFNob3J0TVNCKHMsIHN0cm0uYWRsZXIgJiA2NTUzNSk7CiAgICAgICAgfQogICAgICAgIGZsdXNoX3BlbmRpbmcoc3RybSk7CiAgICAgICAgaWYgKHMud3JhcCA+IDApIHsKICAgICAgICAgIHMud3JhcCA9IC1zLndyYXA7CiAgICAgICAgfQogICAgICAgIHJldHVybiBzLnBlbmRpbmcgIT09IDAgPyBaX09LIDogWl9TVFJFQU1fRU5EOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRlZmxhdGVFbmQoc3RybSkgewogICAgICAgIHZhciBzdGF0dXM7CiAgICAgICAgaWYgKCFzdHJtIHx8ICFzdHJtLnN0YXRlKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIHN0YXR1cyA9IHN0cm0uc3RhdGUuc3RhdHVzOwogICAgICAgIGlmIChzdGF0dXMgIT09IElOSVRfU1RBVEUgJiYgc3RhdHVzICE9PSBFWFRSQV9TVEFURSAmJiBzdGF0dXMgIT09IE5BTUVfU1RBVEUgJiYgc3RhdHVzICE9PSBDT01NRU5UX1NUQVRFICYmIHN0YXR1cyAhPT0gSENSQ19TVEFURSAmJiBzdGF0dXMgIT09IEJVU1lfU1RBVEUgJiYgc3RhdHVzICE9PSBGSU5JU0hfU1RBVEUpIHsKICAgICAgICAgIHJldHVybiBlcnIoc3RybSwgWl9TVFJFQU1fRVJST1IpOwogICAgICAgIH0KICAgICAgICBzdHJtLnN0YXRlID0gbnVsbDsKICAgICAgICByZXR1cm4gc3RhdHVzID09PSBCVVNZX1NUQVRFID8gZXJyKHN0cm0sIFpfREFUQV9FUlJPUikgOiBaX09LOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRlZmxhdGVTZXREaWN0aW9uYXJ5KHN0cm0sIGRpY3Rpb25hcnkpIHsKICAgICAgICB2YXIgZGljdExlbmd0aCA9IGRpY3Rpb25hcnkubGVuZ3RoOwogICAgICAgIHZhciBzOwogICAgICAgIHZhciBzdHIsIG47CiAgICAgICAgdmFyIHdyYXA7CiAgICAgICAgdmFyIGF2YWlsOwogICAgICAgIHZhciBuZXh0OwogICAgICAgIHZhciBpbnB1dDsKICAgICAgICB2YXIgdG1wRGljdDsKICAgICAgICBpZiAoIXN0cm0gfHwgIXN0cm0uc3RhdGUpIHsKICAgICAgICAgIHJldHVybiBaX1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgcyA9IHN0cm0uc3RhdGU7CiAgICAgICAgd3JhcCA9IHMud3JhcDsKICAgICAgICBpZiAod3JhcCA9PT0gMiB8fCB3cmFwID09PSAxICYmIHMuc3RhdHVzICE9PSBJTklUX1NUQVRFIHx8IHMubG9va2FoZWFkKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIGlmICh3cmFwID09PSAxKSB7CiAgICAgICAgICBzdHJtLmFkbGVyID0gYWRsZXIzMihzdHJtLmFkbGVyLCBkaWN0aW9uYXJ5LCBkaWN0TGVuZ3RoLCAwKTsKICAgICAgICB9CiAgICAgICAgcy53cmFwID0gMDsKICAgICAgICBpZiAoZGljdExlbmd0aCA+PSBzLndfc2l6ZSkgewogICAgICAgICAgaWYgKHdyYXAgPT09IDApIHsKICAgICAgICAgICAgemVybyhzLmhlYWQpOwogICAgICAgICAgICBzLnN0cnN0YXJ0ID0gMDsKICAgICAgICAgICAgcy5ibG9ja19zdGFydCA9IDA7CiAgICAgICAgICAgIHMuaW5zZXJ0ID0gMDsKICAgICAgICAgIH0KICAgICAgICAgIHRtcERpY3QgPSBuZXcgdXRpbHMuQnVmOChzLndfc2l6ZSk7CiAgICAgICAgICB1dGlscy5hcnJheVNldCh0bXBEaWN0LCBkaWN0aW9uYXJ5LCBkaWN0TGVuZ3RoIC0gcy53X3NpemUsIHMud19zaXplLCAwKTsKICAgICAgICAgIGRpY3Rpb25hcnkgPSB0bXBEaWN0OwogICAgICAgICAgZGljdExlbmd0aCA9IHMud19zaXplOwogICAgICAgIH0KICAgICAgICBhdmFpbCA9IHN0cm0uYXZhaWxfaW47CiAgICAgICAgbmV4dCA9IHN0cm0ubmV4dF9pbjsKICAgICAgICBpbnB1dCA9IHN0cm0uaW5wdXQ7CiAgICAgICAgc3RybS5hdmFpbF9pbiA9IGRpY3RMZW5ndGg7CiAgICAgICAgc3RybS5uZXh0X2luID0gMDsKICAgICAgICBzdHJtLmlucHV0ID0gZGljdGlvbmFyeTsKICAgICAgICBmaWxsX3dpbmRvdyhzKTsKICAgICAgICB3aGlsZSAocy5sb29rYWhlYWQgPj0gTUlOX01BVENIKSB7CiAgICAgICAgICBzdHIgPSBzLnN0cnN0YXJ0OwogICAgICAgICAgbiA9IHMubG9va2FoZWFkIC0gKE1JTl9NQVRDSCAtIDEpOwogICAgICAgICAgZG8gewogICAgICAgICAgICBzLmluc19oID0gKHMuaW5zX2ggPDwgcy5oYXNoX3NoaWZ0IF4gcy53aW5kb3dbc3RyICsgTUlOX01BVENIIC0gMV0pICYgcy5oYXNoX21hc2s7CiAgICAgICAgICAgIHMucHJldltzdHIgJiBzLndfbWFza10gPSBzLmhlYWRbcy5pbnNfaF07CiAgICAgICAgICAgIHMuaGVhZFtzLmluc19oXSA9IHN0cjsKICAgICAgICAgICAgc3RyKys7CiAgICAgICAgICB9IHdoaWxlICgtLW4pOwogICAgICAgICAgcy5zdHJzdGFydCA9IHN0cjsKICAgICAgICAgIHMubG9va2FoZWFkID0gTUlOX01BVENIIC0gMTsKICAgICAgICAgIGZpbGxfd2luZG93KHMpOwogICAgICAgIH0KICAgICAgICBzLnN0cnN0YXJ0ICs9IHMubG9va2FoZWFkOwogICAgICAgIHMuYmxvY2tfc3RhcnQgPSBzLnN0cnN0YXJ0OwogICAgICAgIHMuaW5zZXJ0ID0gcy5sb29rYWhlYWQ7CiAgICAgICAgcy5sb29rYWhlYWQgPSAwOwogICAgICAgIHMubWF0Y2hfbGVuZ3RoID0gcy5wcmV2X2xlbmd0aCA9IE1JTl9NQVRDSCAtIDE7CiAgICAgICAgcy5tYXRjaF9hdmFpbGF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0gNTUyOTYgJiYgbV9wb3MgKyAxIDwgc3RyX2xlbikgewogICAgICAgICAgICBjMiA9IHN0ci5jaGFyQ29kZUF0KG1fcG9zICsgMSk7CiAgICAgICAgICAgIGlmICgoYzIgJiA2NDUxMikgPT09IDU2MzIwKSB7CiAgICAgICAgICAgICAgYyA9IDY1NTM2ICsgKGMgLSA1NTI5NiA8PCAxMCkgKyAoYzIgLSA1NjMyMCk7CiAgICAgICAgICAgICAgbV9wb3MrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgYnVmX2xlbiArPSBjIDwgMTI4ID8gMSA6IGMgPCAyMDQ4ID8gMiA6IGMgPCA2NTUzNiA/IDMgOiA0OwogICAgICAgIH0KICAgICAgICBidWYgPSBuZXcgdXRpbHMuQnVmOChidWZfbGVuKTsKICAgICAgICBmb3IgKGkgPSAwLCBtX3BvcyA9IDA7IGkgPCBidWZfbGVuOyBtX3BvcysrKSB7CiAgICAgICAgICBjID0gc3RyLmNoYXJDb2RlQXQobV9wb3MpOwogICAgICAgICAgaWYgKChjICYgNjQ1MTIpID09PSA1NTI5NiAmJiBtX3BvcyArIDEgPCBzdHJfbGVuKSB7CiAgICAgICAgICAgIGMyID0gc3RyLmNoYXJDb2RlQXQobV9wb3MgKyAxKTsKICAgICAgICAgICAgaWYgKChjMiAmIDY0NTEyKSA9PT0gNTYzMjApIHsKICAgICAgICAgICAgICBjID0gNjU1MzYgKyAoYyAtIDU1Mjk2IDw8IDEwKSArIChjMiAtIDU2MzIwKTsKICAgICAgICAgICAgICBtX3BvcysrOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYyA8IDEyOCkgewogICAgICAgICAgICBidWZbaSsrXSA9IGM7CiAgICAgICAgICB9IGVsc2UgaWYgKGMgPCAyMDQ4KSB7CiAgICAgICAgICAgIGJ1ZltpKytdID0gMTkyIHwgYyA+Pj4gNjsKICAgICAgICAgICAgYnVmW2krK10gPSAxMjggfCBjICYgNjM7CiAgICAgICAgICB9IGVsc2UgaWYgKGMgPCA2NTUzNikgewogICAgICAgICAgICBidWZbaSsrXSA9IDIyNCB8IGMgPj4+IDEyOwogICAgICAgICAgICBidWZbaSsrXSA9IDEyOCB8IGMgPj4+IDYgJiA2MzsKICAgICAgICAgICAgYnVmW2krK10gPSAxMjggfCBjICYgNjM7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBidWZbaSsrXSA9IDI0MCB8IGMgPj4+IDE4OwogICAgICAgICAgICBidWZbaSsrXSA9IDEyOCB8IGMgPj4+IDEyICYgNjM7CiAgICAgICAgICAgIGJ1ZltpKytdID0gMTI4IHwgYyA+Pj4gNiAmIDYzOwogICAgICAgICAgICBidWZbaSsrXSA9IDEyOCB8IGMgJiA2MzsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJ1ZjsKICAgICAgfTsKICAgICAgZnVuY3Rpb24gYnVmMmJpbnN0cmluZyhidWYsIGxlbikgewogICAgICAgIGlmIChsZW4gPCA2NTUzNCkgewogICAgICAgICAgaWYgKGJ1Zi5zdWJhcnJheSAmJiBTVFJfQVBQTFlfVUlBX09LIHx8ICFidWYuc3ViYXJyYXkgJiYgU1RSX0FQUExZX09LKSB7CiAgICAgICAgICAgIHJldHVybiBTdHJpbmcuZnJvbUNoYXJDb2RlLmFwcGx5KG51bGwsIHV0aWxzLnNocmlua0J1ZihidWYsIGxlbikpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICB2YXIgcmVzdWx0ID0gIiI7CiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBsZW47IGkrKykgewogICAgICAgICAgcmVzdWx0ICs9IFN0cmluZy5mcm9tQ2hhckNvZGUoYnVmW2ldKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgfQogICAgICBleHBvcnRzLmJ1ZjJiaW5zdHJpbmcgPSBmdW5jdGlvbihidWYpIHsKICAgICAgICByZXR1cm4gYnVmMmJpbnN0cmluZyhidWYsIGJ1Zi5sZW5ndGgpOwogICAgICB9OwogICAgICBleHBvcnRzLmJpbnN0cmluZzJidWYgPSBmdW5jdGlvbihzdHIpIHsKICAgICAgICB2YXIgYnVmID0gbmV3IHV0aWxzLkJ1Zjgoc3RyLmxlbmd0aCk7CiAgICAgICAgZm9yICh2YXIgaSA9IDAsIGxlbiA9IGJ1Zi5sZW5ndGg7IGkgPCBsZW47IGkrKykgewogICAgICAgICAgYnVmW2ldID0gc3RyLmNoYXJDb2RlQXQoaSk7CiAgICAgICAgfQogICAgICAgIHJldHVybiBidWY7CiAgICAgIH07CiAgICAgIGV4cG9ydHMuYnVmMnN0cmluZyA9IGZ1bmN0aW9uKGJ1ZiwgbWF4KSB7CiAgICAgICAgdmFyIGksIG91dCwgYywgY19sZW47CiAgICAgICAgdmFyIGxlbiA9IG1heCB8fCBidWYubGVuZ3RoOwogICAgICAgIHZhciB1dGYxNmJ1ZiA9IG5ldyBBcnJheShsZW4gKiAyKTsKICAgICAgICBmb3IgKG91dCA9IDAsIGkgPSAwOyBpIDwgbGVuOyApIHsKICAgICAgICAgIGMgPSBidWZbaSsrXTsKICAgICAgICAgIGlmIChjIDwgMTI4KSB7CiAgICAgICAgICAgIHV0ZjE2YnVmW291dCsrXSA9IGM7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgY19sZW4gPSBfdXRmOGxlbltjXTsKICAgICAgICAgIGlmIChjX2xlbiA+IDQpIHsKICAgICAgICAgICAgdXRmMTZidWZbb3V0KytdID0gNjU1MzM7CiAgICAgICAgICAgIGkgKz0gY19sZW4gLSAxOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGMgJj0gY19sZW4gPT09IDIgPyAzMSA6IGNfbGVuID09PSAzID8gMTUgOiA3OwogICAgICAgICAgd2hpbGUgKGNfbGVuID4gMSAmJiBpIDwgbGVuKSB7CiAgICAgICAgICAgIGMgPSBjIDw8IDYgfCBidWZbaSsrXSAmIDYzOwogICAgICAgICAgICBjX2xlbi0tOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGNfbGVuID4gMSkgewogICAgICAgICAgICB1dGYxNmJ1ZltvdXQrK10gPSA2NTUzMzsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYyA8IDY1NTM2KSB7CiAgICAgICAgICAgIHV0ZjE2YnVmW291dCsrXSA9IGM7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjIC09IDY1NTM2OwogICAgICAgICAgICB1dGYxNmJ1ZltvdXQrK10gPSA1NTI5NiB8IGMgPj4gMTAgJiAxMDIzOwogICAgICAgICAgICB1dGYxNmJ1ZltvdXQrK10gPSA1NjMyMCB8IGMgJiAxMDIzOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gYnVmMmJpbnN0cmluZyh1dGYxNmJ1Ziwgb3V0KTsKICAgICAgfTsKICAgICAgZXhwb3J0cy51dGY4Ym9yZGVyID0gZnVuY3Rpb24oYnVmLCBtYXgpIHsKICAgICAgICB2YXIgcG9zOwogICAgICAgIG1heCA9IG1heCB8fCBidWYubGVuZ3RoOwogICAgICAgIGlmIChtYXggPiBidWYubGVuZ3RoKSB7CiAgICAgICAgICBtYXggPSBidWYubGVuZ3RoOwogICAgICAgIH0KICAgICAgICBwb3MgPSBtYXggLSAxOwogICAgICAgIHdoaWxlIChwb3MgPj0gMCAmJiAoYnVmW3Bvc10gJiAxOTIpID09PSAxMjgpIHsKICAgICAgICAgIHBvcy0tOwogICAgICAgIH0KICAgICAgICBpZiAocG9zIDwgMCkgewogICAgICAgICAgcmV0dXJuIG1heDsKICAgICAgICB9CiAgICAgICAgaWYgKHBvcyA9PT0gMCkgewogICAgICAgICAgcmV0dXJuIG1heDsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHBvcyArIF91dGY4bGVuW2J1Zltwb3NdXSA+IG1heCA/IHBvcyA6IG1heDsKICAgIC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ZmxhdGUuanMiKGV4cG9ydHMpIHsKICAgICAgaW5pdF9idWZmZXJfc2hpbSgpOwogICAgICAidXNlIHN0cmljdCI7CiAgICAgIHZhciB6bGliX2RlZmxhdGUgPSByZXF1aXJlX2RlZmxhdGUoKTsKICAgICAgdmFyIHV0aWxzID0gcmVxdWlyZV9jb21tb24yKCk7CiAgICAgIHZhciBzdHJpbmdzID0gcmVxdWlyZV9zdHJpbmdzKCk7CiAgICAgIHZhciBtc2cgPSByZXF1aXJlX21lc3NhZ2VzMigpOwogICAgICB2YXIgWlN0cmVhbSA9IHJlcXVpcmVfenN0cmVhbSgpOwogICAgICB2YXIgdG9TdHJpbmcgPSBPYmplY3QucHJvdG90eXBlLnRvU3RyaW5nOwogICAgICB2YXIgWl9OT19GTFVTSCA9IDA7CiAgICAgIHZhciBaX0ZJTklTSCA9IDQ7CiAgICAgIHZhciBaX09LID0gMDsKICAgICAgdmFyIFpfU1RSRUFNX0VORCA9IDE7CiAgICAgIHZhciBaX1NZTkNfRkxVU0gyID0gMjsKICAgICAgdmFyIFpfREVGQVVMVF9DT01QUkVTU0lPTiA9IC0xOwogICAgICB2YXIgWl9ERUZBVUxUX1NUUkFURUdZID0gMDsKICAgICAgdmFyIFpfREVGTEFURUQgPSA4OwogICAgICBmdW5jdGlvbiBEZWZsYXRlKG9wdGlvbnMpIHsKICAgICAgICBpZiAoISh0aGlzIGluc3RhbmNlb2YgRGVmbGF0ZSkpCiAgICAgICAgICByZXR1cm4gbmV3IERlZmxhdGUob3B0aW9ucyk7CiAgICAgICAgdGhpcy5vcHRpb25zID0gdXRpbHMuYXNzaWduKHsKICAgICAgICAgIGxldmVsOiBaX0RFRkFVTFRfQ09NUFJFU1NJT04sCiAgICAgICAgICBtZXRob2Q6IFpfREVGTEFURUQsCiAgICAgICAgICBjaHVua1NpemU6IDE2Mzg0LAogICAgICAgICAgd2luZG93Qml0czogMTUsCiAgICAgICAgICBtZW1MZXZlbDogOCwKICAgICAgICAgIHN0cmF0Z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ZiAodHlwZW9mIG9wdC5kaWN0aW9uYXJ5ID09PSAic3RyaW5nIikgewogICAgICAgICAgICBkaWN0ID0gc3RyaW5ncy5zdHJpbmcyYnVmKG9wdC5kaWN0aW9uYXJ5KTsKICAgICAgICAgIH0gZWxzZSBpZiAodG9TdHJpbmcuY2FsbChvcHQuZGljdGlvbmFyeSkgPT09ICJbb2JqZWN0IEFycmF5QnVmZmVyXSIpIHsKICAgICAgICAgICAgZGljdCA9IG5ldyBVaW50OEFycmF5KG9wdC5kaWN0aW9uYXJ5KTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGRpY3QgPSBvcHQuZGljdGlvbmFyeTsKICAgICAgICAgIH0KICAgICAgICAgIHN0YXR1cyA9IHpsaWJfZGVmbGF0ZS5kZWZsYXRlU2V0RGljdGlvbmFyeSh0aGlzLnN0cm0sIGRpY3QpOwogICAgICAgICAgaWYgKHN0YXR1cyAhPT0gWl9PSykgewogICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IobXNnW3N0YXR1c10pOwogICAgICAgICAgfQogICAgICAgICAgdGhpcy5fZGljdF9zZXQgPSB0cnVlOwogICAgICAgIH0KICAgICAgfQogICAgICBEZWZsYXRlLnByb3RvdHlwZS5wdXNoID0gZnVuY3Rpb24oZGF0YSwgbW9kZSkgewogICAgICAgIHZhciBzdHJtID0gdGhpcy5zdHJtOwogICAgICAgIHZhciBjaHVua1NpemUgPSB0aGlzLm9wdGlvbnMuY2h1bmtTaXplOwogICAgICAgIHZhciBzdGF0dXMsIF9tb2RlOwogICAgICAgIGlmICh0aGlzLmVuZGVkKSB7CiAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfQogICAgICAgIF9tb2RlID0gbW9kZSA9PT0gfn5tb2RlID8gbW9kZSA6IG1vZGUgPT09IHRydWUgPyBaX0ZJTklTSCA6IFpfTk9fRkxVU0g7CiAgICAgICAgaWYgKHR5cGVvZiBkYXRhID09PSAic3RyaW5nIikgewogICAgICAgICAgc3RybS5pbnB1dCA9IHN0cmluZ3Muc3RyaW5nMmJ1ZihkYXRhKTsKICAgICAgICB9IGVsc2UgaWYgKHRvU3RyaW5nLmNhbGwoZGF0YSkgPT09ICJbb2JqZWN0IEFycmF5QnVmZmVyXSIpIHsKICAgICAgICAgIHN0cm0uaW5wdXQgPSBuZXcgVWludDhBcnJheShkYXRhKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgc3RybS5pbnB1dCA9IGRhdGE7CiAgICAgICAgfQogICAgICAgIHN0cm0ubmV4dF9pbiA9IDA7CiAgICAgICAgc3RybS5hdmFpbF9pbiA9IHN0cm0uaW5wdXQubGVuZ3RoOwogICAgICAgIGRvIHsKICAgICAgICAgIGlmIChzdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICBzdHJtLm91dHB1dCA9IG5ldyB1dGlscy5CdWY4KGNodW5rU2l6ZSk7CiAgICAgICAgICAgIHN0cm0ubmV4dF9vdXQgPSAwOwogICAgICAgICAgICBzdHJtLmF2YWlsX291dCA9IGNodW5rU2l6ZTsKICAgICAgICAgIH0KICAgICAgICAgIHN0YXR1cyA9IHpsaWJfZGVmbGF0ZS5kZWZsYXRlKHN0cm0sIF9tb2RlKTsKICAgICAgICAgIGlmIChzdGF0dXMgIT09IFpfU1RSRUFNX0VORCAmJiBzdGF0dXMgIT09IFpfT0spIHsKICAgICAgICAgICAgdGhpcy5vbkVuZChzdGF0dXMpOwogICAgICAgICAgICB0aGlzLmVuZGVkID0gdHJ1ZTsKICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHN0cm0uYXZhaWxfb3V0ID09PSAwIHx8IHN0cm0uYXZhaWxfaW4gPT09IDAgJiYgKF9tb2RlID09PSBaX0ZJTklTSCB8fCBfbW9kZSA9PT0gWl9TWU5DX0ZMVVNIMikpIHsKICAgICAgICAgICAgaWYgKHRoaXMub3B0aW9ucy50byA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICB0aGlzLm9uRGF0YShzdHJpbmdzLmJ1ZjJiaW5zdHJpbmcodXRpbHMuc2hyaW5rQnVmKHN0cm0ub3V0cHV0LCBzdHJtLm5leHRfb3V0KSkpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRoaXMub25EYXRhKHV0aWxzLnNocmlua0J1ZihzdHJtLm91dHB1dCwgc3RybS5uZXh0X291dCkpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfSB3aGlsZSAoKHN0cm0uYXZhaWxfaW4gPiAwIHx8IHN0cm0uYXZhaWxfb3V0ID09PSAwKSAmJiBzdGF0dXMgIT09IFpfU1RSRUFNX0VORCk7CiAgICAgICAgaWYgKF9tb2RlID09PSBaX0ZJTklTSCkgewogICAgICAgICAgc3RhdHVzID0gemxpYl9kZWZsYXRlLmRlZmxhdGVFbmQodGhpcy5zdHJtKTsKICAgICAgICAgIHRoaXMub25FbmQoc3RhdHVzKTsKICAgICAgICAgIHRoaXMuZW5kZWQgPSB0cnVlOwogICAgICAgICAgcmV0dXJuIHN0YXR1cyA9PT0gWl9PSzsKICAgICAgICB9CiAgICAgICAgaWYgKF9tb2RlID09PSBaX1NZTkNfRkxVU0gyKSB7CiAgICAgICAgICB0aGlzLm9uRW5kKFpfT0spOwogICAgICAgICAgc3RybS5hdmFpbF9vdXQgPSAwOwogICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgfQogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9OwogICAgICBEZWZsYXRlLnByb3RvdHlwZS5vbkRhdGEgPSBmdW5jdGlvbihjaHVuaykgewogICAgICAgIHRoaXMuY2h1bmtzLnB1c2goY2h1bmspOwogICAgICB9OwogICAgICBEZWZsYXRlLnByb3RvdHlwZS5vbkVuZCA9IGZ1bmN0aW9uKHN0YXR1cykgewogICAgICAgIGlmIChzdGF0dXMgPT09IFpfT0spIHsKICAgICAgICAgIGlmICh0aGlzLm9wdGlvbnMudG8gPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgIHRoaXMucmVzdWx0ID0gdGhpcy5jaHVua3Muam9pbigiIik7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICB0aGlzLnJlc3VsdCA9IHV0aWxzLmZsYXR0ZW5DaHVua3ModGhpcy5jaHVua3MpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICB0aGlzLmNodW5rcyA9IFtdOwogICAgICAgIHRoaXMuZXJyID0gc3RhdHVzOwogICAgICAgIHRoaXMubXNnID0gdGhpcy5zdHJtLm1zZzsKICAgICAgfTsKICAgICAgZnVuY3Rpb24gZGVmbGF0ZShpbnB1dCwgb3B0aW9ucykgewogICAgICAgIHZhciBkZWZsYXRvciA9IG5ldyBEZWZsYXRlKG9wdGlvbnMpOwogICAgICAgIGRlZmxhdG9yLnB1c2goaW5wdXQsIHRydWUpOwogICAgICAgIGlmIChkZWZsYXRvci5lcnIpIHsKICAgICAgICAgIHRocm93IGRlZmxhdG9yLm1zZyB8fCBtc2dbZGVmbGF0b3IuZXJyXTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGRlZmxhdG9yLnJlc3VsdDsKICAgICAgfQogICAgICBmdW5jdGlvbiBkZWZsYXRlUmF3KGlucHV0LCBvcHRpb25zKSB7CiAgICAgICAgb3B0aW9ucyA9IG9wdGlvbnMgfHwge307CiAgICAgICAgb3B0aW9ucy5yYXcgPSB0cnVlOwogICAgICAgIHJldHVybiBkZWZsYXRlKGlucHV0LCBvcHRpb25zKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBnemlwKGlucHV0LCBvcHRpb25zKSB7CiAgICAgICAgb3B0aW9ucyA9IG9wdGlvbnMgfHwge307CiAgICAgICAgb3B0aW9ucy5nemlwID0gdHJ1ZTsKICAgICAgICByZXR1cm4gZGVmbGF0ZShpbnB1dCwgb3B0aW9ucyk7CiAgICAgIH0KICAgICAgZXhwb3J0cy5EZWZsYXRlID0gRGVmbGF0ZTsKICAgICAgZXhwb3J0cy5kZWZsYXRlID0gZGVmbGF0ZTsKICAgICAgZXhwb3J0cy5kZWZsYXRlUmF3ID0gZGVmbGF0ZVJhdzsKICAgICAgZXhwb3J0cy5nemlwID0gZ3ppcDsKICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5wbnBtL3Bha29AMS4wLjExL25vZGVfbW9kdWxlcy9wYWtvL2xpYi96bGliL2luZmZhc3QuanMKICB2YXIgcmVxdWlyZV9pbmZmYXN0ID0gX19jb21tb25KUyh7CiAgICAibm9kZV9tb2R1bGVzLy5wbnBtL3Bha29AMS4wLjExL25vZGVfbW9kdWxlcy9wYWtvL2xpYi96bGliL2luZmZhc3QuanMiKGV4cG9ydHMsIG1vZHVsZSkgewogICAgICBpbml0X2J1ZmZlcl9zaGltKCk7CiAgICAgICJ1c2Ugc3RyaWN0IjsKICAgICAgdmFyIEJBRCA9IDMwOwogICAgICB2YXIgVFlQRSA9IDEyOwogICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIGluZmxhdGVfZmFzdChzdHJtLCBzdGFydCkgewogICAgICAgIHZhciBzdGF0ZTsKICAgICAgICB2YXIgX2luOwogICAgICAgIHZhciBsYXN0OwogICAgICAgIHZhciBfb3V0OwogICAgICAgIHZhciBiZWc7CiAgICAgICAgdmFyIGVuZDsKICAgICAgICB2YXIgZG1heDsKICAgICAgICB2YXIgd3NpemU7CiAgICAgICAgdmFyIHdoYXZlOwogICAgICAgIHZhciB3bmV4dDsKICAgICAgICB2YXIgc193aW5kb3c7CiAgICAgICAgdmFyIGhvbGQ7CiAgICAgICAgdmFyIGJpdHM7CiAgICAgICAgdmFyIGxjb2RlOwogICAgICAgIHZhciBkY29kZTsKICAgICAgICB2YXIgbG1hc2s7CiAgICAgICAgdmFyIGRtYXNrOwogICAgICAgIHZhciBoZXJlOwogICAgICAgIHZhciBvcDsKICAgICAgICB2YXIgbGVuOwogICAgICAgIHZhciBkaXN0OwogICAgICAgIHZhciBmcm9tOwogICAgICAgIHZhciBmcm9tX3NvdXJjZTsKICAgICAgICB2YXIgaW5wdXQsIG91dHB1dDsKICAgICAgICBzdGF0ZSA9IHN0cm0uc3RhdGU7CiAgICAgICAgX2luID0gc3RybS5uZXh0X2luOwogICAgICAgIGlucHV0ID0gc3RybS5pbnB1dDsKICAgICAgICBsYXN0ID0gX2luICsgKHN0cm0uYXZhaWxfaW4gLSA1KTsKICAgICAgICBfb3V0ID0gc3RybS5uZXh0X291dDsKICAgICAgICBvdXRwdXQgPSBzdHJtLm91dHB1dDsKICAgICAgICBiZWcgPSBfb3V0IC0gKHN0YXJ0IC0gc3RybS5hdmFpbF9vdXQpOwogICAgICAgIGVuZCA9IF9vdXQgKyAoc3RybS5hdmFpbF9vdXQgLSAyNTcpOwogICAgICAgIGRtYXggPSBzdGF0ZS5kbWF4OwogICAgICAgIHdzaXplID0gc3RhdGUud3NpemU7CiAgICAgICAgd2hhdmUgPSBzdGF0ZS53aGF2ZTsKICAgICAgICB3bmV4dCA9IHN0YXRlLnduZXh0OwogICAgICAgIHNfd2luZG93ID0gc3RhdGUud2luZG93OwogICAgICAgIGhvbGQgPSBzdGF0ZS5ob2xkOwogICAgICAgIGJpdHMgPSBzdGF0ZS5iaXRzOwogICAgICAgIGxjb2RlID0gc3RhdGUubGVuY29kZTsKICAgICAgICBkY29kZSA9IHN0YXRlLmRpc3Rjb2RlOwogICAgICAgIGxtYXNrID0gKDEgPDwgc3RhdGUubGVuYml0cykgLSAxOwogICAgICAgIGRtYXNrID0gKDEgPDwgc3RhdGUuZGlzdGJpdHMpIC0gMTsKICAgICAgICB0b3A6CiAgICAgICAgICBkbyB7CiAgICAgICAgICAgIGlmIChiaXRzIDwgMTUpIHsKICAgICAgICAgICAgICBob2xkICs9IGlucHV0W19pbisrXSA8PCBiaXRzOwogICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICBob2xkICs9IGlucHV0W19pbisrXSA8PCBiaXRzOwogICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgfQogICAgICAgICAgICBoZXJlID0gbGNvZGVbaG9sZCAmIGxtYXNrXTsKICAgICAgICAgICAgZG9sZW46CiAgICAgICAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICAgICAgICBvcCA9IGhlcmUgPj4+IDI0OwogICAgICAgICAgICAgICAgaG9sZCA+Pj49IG9wOwogICAgICAgICAgICAgICAgYml0cyAtPSBvcDsKICAgICAgICAgICAgICAgIG9wID0gaGVyZSA+Pj4gMTYgJiAyNTU7CiAgICAgICAgICAgICAgICBpZiAob3AgPT09IDApIHsKICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBoZXJlICYgNjU1MzU7CiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG9wICYgMTYpIHsKICAgICAgICAgICAgICAgICAgbGVuID0gaGVyZSAmIDY1NTM1OwogICAgICAgICAgICAgICAgICBvcCAmPSAxNTsKICAgICAgICAgICAgICAgICAgaWYgKG9wKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGJpdHMgPCBvcCkgewogICAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtfaW4rK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgbGVuICs9IGhvbGQgJiAoMSA8PCBvcCkgLSAxOwogICAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBvcDsKICAgICAgICAgICAgICAgICAgICBiaXRzIC09IG9wOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChiaXRzIDwgMTUpIHsKICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W19pbisrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W19pbisrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoZXJlID0gZGNvZGVbaG9sZCAmIGRtYXNrXTsKICAgICAgICAgICAgICAgICAgZG9kaXN0OgogICAgICAgICAgICAgICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgICAgICAgICAgICAgb3AgPSBoZXJlID4+PiAyNDsKICAgICAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBvcDsKICAgICAgICAgICAgICAgICAgICAgIGJpdHMgLT0gb3A7CiAgICAgICAgICAgICAgICAgICAgICBvcCA9IGhlcmUgPj4+IDE2ICYgMjU1OwogICAgICAgICAgICAgICAgICAgICAgaWYgKG9wICYgMTYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGlzdCA9IGhlcmUgJiA2NTUzNTsKICAgICAgICAgICAgICAgICAgICAgICAgb3AgJj0gMTU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiaXRzIDwgb3ApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W19pbisrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYml0cyA8IG9wKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W19pbisrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBkaXN0ICs9IGhvbGQgJiAoMSA8PCBvcCkgLSAxOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGlzdCA+IGRtYXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGRpc3RhbmNlIHRvbyBmYXIgYmFjayI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhayB0b3A7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IG9wOwogICAgICAgICAgICAgICAgICAgICAgICBiaXRzIC09IG9wOwogICAgICAgICAgICAgICAgICAgICAgICBvcCA9IF9vdXQgLSBiZWc7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkaXN0ID4gb3ApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICBvcCA9IGRpc3QgLSBvcDsKICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3AgPiB3aGF2ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLnNhbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBkaXN0YW5jZSB0b28gZmFyIGJhY2siOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhayB0b3A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgIGZyb20gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgIGZyb21fc291cmNlID0gc193aW5kb3c7CiAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHduZXh0ID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tICs9IHdzaXplIC0gb3A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3AgPCBsZW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuIC09IG9wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBzX3dpbmRvd1tmcm9tKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IHdoaWxlICgtLW9wKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbSA9IF9vdXQgLSBkaXN0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tX3NvdXJjZSA9IG91dHB1dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHduZXh0IDwgb3ApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyb20gKz0gd3NpemUgKyB3bmV4dCAtIG9wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3AgLT0gd25leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3AgPCBsZW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuIC09IG9wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBzX3dpbmRvd1tmcm9tKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IHdoaWxlICgtLW9wKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3bmV4dCA8IGxlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wID0gd25leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuIC09IG9wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gc193aW5kb3dbZnJvbSsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IHdoaWxlICgtLW9wKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tID0gX291dCAtIGRpc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbV9zb3VyY2UgPSBvdXRwdXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbSArPSB3bmV4dCAtIG9wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wIDwgbGVuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlbiAtPSBvcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gc193aW5kb3dbZnJvbSsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSB3aGlsZSAoLS1vcCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyb20gPSBfb3V0IC0gZGlzdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbV9zb3VyY2UgPSBvdXRwdXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChsZW4gPiAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IGZyb21fc291cmNlW2Zyb20rK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IGZyb21fc291cmNlW2Zyb20rK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IGZyb21fc291cmNlW2Zyb20rK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW4gLT0gMzsKICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBmcm9tX3NvdXJjZVtmcm9tKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxlbiA+IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBmcm9tX3NvdXJjZVtmcm9tKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tID0gX291dCAtIGRpc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBvdXRwdXRbZnJvbSsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gb3V0cHV0W2Zyb20rK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IG91dHB1dFtmcm9tKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuIC09IDM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgfSB3aGlsZSAobGVuID4gMik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBvdXRwdXRbZnJvbSsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsZW4gPiAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gb3V0cHV0W2Zyb20rK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKChvcCAmIDY0KSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICBoZXJlID0gZGNvZGVbKGhlcmUgJiA2NTUzNSkgKyAoaG9sZCAmICgxIDw8IG9wKSAtIDEpXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWUgZG9kaXN0OwogICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBkaXN0YW5jZSBjb2RlIjsKICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWsgdG9wOwogICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSBlbHNlIGlmICgob3AgJiA2NCkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgaGVyZSA9IGxjb2RlWyhoZXJlICYgNjU1MzUpICsgKGhvbGQgJiAoMSA8PCBvcCkgLSAxKV07CiAgICAgICAgICAgICAgICAgIGNvbnRpbnVlIGRvbGVuOwogICAgICAgICAgICAgICAgfSBlbHNlIGlmIChvcCAmIDMyKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBUWVBFOwogICAgICAgICAgICAgICAgICBicmVhayB0b3A7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGxpdGVyYWwvbGVuZ3RoIGNvZGUiOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICBicmVhayB0b3A7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICB9IHdoaWxlIChfaW4gPCBsYXN0ICYmIF9v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AgICB2YXIgRElTVFMgPSAyOwogICAgICB2YXIgbGJhc2UgPSBbCiAgICAgICAgMywKICAgICAgICA0LAogICAgICAgIDUsCiAgICAgICAgNiwKICAgICAgICA3LAogICAgICAgIDgsCiAgICAgICAgOSwKICAgICAgICAxMCwKICAgICAgICAxMSwKICAgICAgICAxMywKICAgICAgICAxNSwKICAgICAgICAxNywKICAgICAgICAxOSwKICAgICAgICAyMywKICAgICAgICAyNywKICAgICAgICAzMSwKICAgICAgICAzNSwKICAgICAgICA0MywKICAgICAgICA1MSwKICAgICAgICA1OSwKICAgICAgICA2NywKICAgICAgICA4MywKICAgICAgICA5OSwKICAgICAgICAxMTUsCiAgICAgICAgMTMxLAogICAgICAgIDE2MywKICAgICAgICAxOTUsCiAgICAgICAgMjI3LAogICAgICAgIDI1OCwKICAgICAgICAwLAogICAgICAgIDAKICAgICAgXTsKICAgICAgdmFyIGxleHQgPSBbCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTcsCiAgICAgICAgMTcsCiAgICAgICAgMTcsCiAgICAgICAgMTcsCiAgICAgICAgMTgsCiAgICAgICAgMTgsCiAgICAgICAgMTgsCiAgICAgICAgMTgsCiAgICAgICAgMTksCiAgICAgICAgMTksCiAgICAgICAgMTksCiAgICAgICAgMTksCiAgICAgICAgMjAsCiAgICAgICAgMjAsCiAgICAgICAgMjAsCiAgICAgICAgMjAsCiAgICAgICAgMjEsCiAgICAgICAgMjEsCiAgICAgICAgMjEsCiAgICAgICAgMjEsCiAgICAgICAgMTYsCiAgICAgICAgNzIsCiAgICAgICAgNzgKICAgICAgXTsKICAgICAgdmFyIGRiYXNlID0gWwogICAgICAgIDEsCiAgICAgICAgMiwKICAgICAgICAzLAogICAgICAgIDQsCiAgICAgICAgNSwKICAgICAgICA3LAogICAgICAgIDksCiAgICAgICAgMTMsCiAgICAgICAgMTcsCiAgICAgICAgMjUsCiAgICAgICAgMzMsCiAgICAgICAgNDksCiAgICAgICAgNjUsCiAgICAgICAgOTcsCiAgICAgICAgMTI5LAogICAgICAgIDE5MywKICAgICAgICAyNTcsCiAgICAgICAgMzg1LAogICAgICAgIDUxMywKICAgICAgICA3NjksCiAgICAgICAgMTAyNSwKICAgICAgICAxNTM3LAogICAgICAgIDIwNDksCiAgICAgICAgMzA3MywKICAgICAgICA0MDk3LAogICAgICAgIDYxNDUsCiAgICAgICAgODE5MywKICAgICAgICAxMjI4OSwKICAgICAgICAxNjM4NSwKICAgICAgICAyNDU3NywKICAgICAgICAwLAogICAgICAgIDAKICAgICAgXTsKICAgICAgdmFyIGRleHQgPSBbCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTcsCiAgICAgICAgMTcsCiAgICAgICAgMTgsCiAgICAgICAgMTgsCiAgICAgICAgMTksCiAgICAgICAgMTksCiAgICAgICAgMjAsCiAgICAgICAgMjAsCiAgICAgICAgMjEsCiAgICAgICAgMjEsCiAgICAgICAgMjIsCiAgICAgICAgMjIsCiAgICAgICAgMjMsCiAgICAgICAgMjMsCiAgICAgICAgMjQsCiAgICAgICAgMjQsCiAgICAgICAgMjUsCiAgICAgICAgMjUsCiAgICAgICAgMjYsCiAgICAgICAgMjYsCiAgICAgICAgMjcsCiAgICAgICAgMjcsCiAgICAgICAgMjgsCiAgICAgICAgMjgsCiAgICAgICAgMjksCiAgICAgICAgMjksCiAgICAgICAgNjQsCiAgICAgICAgNjQKICAgICAgXTsKICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiBpbmZsYXRlX3RhYmxlKHR5cGUsIGxlbnMsIGxlbnNfaW5kZXgsIGNvZGVzLCB0YWJsZSwgdGFibGVfaW5kZXgsIHdvcmssIG9wdHMpIHsKICAgICAgICB2YXIgYml0cyA9IG9wdHMuYml0czsKICAgICAgICB2YXIgbGVuID0gMDsKICAgICAgICB2YXIgc3ltID0gMDsKICAgICAgICB2YXIgbWluID0gMCwgbWF4ID0gMDsKICAgICAgICB2YXIgcm9vdCA9IDA7CiAgICAgICAgdmFyIGN1cnIgPSAwOwogICAgICAgIHZhciBkcm9wID0gMDsKICAgICAgICB2YXIgbGVmdCA9IDA7CiAgICAgICAgdmFyIHVzZWQgPSAwOwogICAgICAgIHZhciBodWZmID0gMDsKICAgICAgICB2YXIgaW5jcjsKICAgICAgICB2YXIgZmlsbDsKICAgICAgICB2YXIgbG93OwogICAgICAgIHZhciBtYXNrOwogICAgICAgIHZhciBuZXh0OwogICAgICAgIHZhciBiYXNlID0gbnVsbDsKICAgICAgICB2YXIgYmFzZV9pbmRleCA9IDA7CiAgICAgICAgdmFyIGVuZDsKICAgICAgICB2YXIgY291bnQgPSBuZXcgdXRpbHMuQnVmMTYoTUFYQklUUyArIDEpOwogICAgICAgIHZhciBvZmZzID0gbmV3IHV0aWxzLkJ1ZjE2KE1BWEJJVFMgKyAxKTsKICAgICAgICB2YXIgZXh0cmEgPSBudWxsOwogICAgICAgIHZhciBleHRyYV9pbmRleCA9IDA7CiAgICAgICAgdmFyIGhlcmVfYml0cywgaGVyZV9vcCwgaGVyZV92YWw7CiAgICAgICAgZm9yIChsZW4gPSAwOyBsZW4gPD0gTUFYQklUUzsgbGVuKyspIHsKICAgICAgICAgIGNvdW50W2xlbl0gPSAwOwogICAgICAgIH0KICAgICAgICBmb3IgKHN5bSA9IDA7IHN5bSA8IGNvZGVzOyBzeW0rKykgewogICAgICAgICAgY291bnRbbGVuc1tsZW5zX2luZGV4ICsgc3ltXV0rKzsKICAgICAgICB9CiAgICAgICAgcm9vdCA9IGJpdHM7CiAgICAgICAgZm9yIChtYXggPSBNQVhCSVRTOyBtYXggPj0gMTsgbWF4LS0pIHsKICAgICAgICAgIGlmIChjb3VudFttYXhdICE9PSAwKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAocm9vdCA+IG1heCkgewogICAgICAgICAgcm9vdCA9IG1heDsKICAgICAgICB9CiAgICAgICAgaWYgKG1heCA9PT0gMCkgewogICAgICAgICAgdGFibGVbdGFibGVfaW5kZXgrK10gPSAxIDw8IDI0IHwgNjQgPDwgMTYgfCAwOwogICAgICAgICAgdGFibGVbdGFibGVfaW5kZXgrK10gPSAxIDw8IDI0IHwgNjQgPDwgMTYgfCAwOwogICAgICAgICAgb3B0cy5iaXRzID0gMTsKICAgICAgICAgIHJldHVybiAwOwogICAgICAgIH0KICAgICAgICBmb3IgKG1pbiA9IDE7IG1pbiA8IG1heDsgbWluKyspIHsKICAgICAgICAgIGlmIChjb3VudFttaW5dICE9PSAwKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAocm9vdCA8IG1pbikgewogICAgICAgICAgcm9vdCA9IG1pbjsKICAgICAgICB9CiAgICAgICAgbGVmdCA9IDE7CiAgICAgICAgZm9yIChsZW4gPSAxOyBsZW4gPD0gTUFYQklUUzsgbGVuKyspIHsKICAgICAgICAgIGxlZnQgPDw9IDE7CiAgICAgICAgICBsZWZ0IC09IGNvdW50W2xlbl07CiAgICAgICAgICBpZiAobGVmdCA8IDApIHsKICAgICAgICAgICAgcmV0dXJuIC0xOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAobGVmdCA+IDAgJiYgKHR5cGUgPT09IENPREVTIHx8IG1heCAhPT0gMSkpIHsKICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICB9CiAgICAgICAgb2Zmc1sxXSA9IDA7CiAgICAgICAgZm9yIChsZW4gPSAxOyBsZW4gPCBNQVhCSVRTOyBsZW4rKykgewogICAgICAgICAgb2Zmc1tsZW4gKyAxXSA9IG9mZnNbbGVuXSArIGNvdW50W2xlbl07CiAgICAgICAgfQogICAgICAgIGZvciAoc3ltID0gMDsgc3ltIDwgY29kZXM7IHN5bSsrKSB7CiAgICAgICAgICBpZiAobGVuc1tsZW5zX2luZGV4ICsgc3ltXSAhPT0gMCkgewogICAgICAgICAgICB3b3JrW29mZnNbbGVuc1tsZW5zX2luZGV4ICsgc3ltXV0rK10gPSBzeW07CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmICh0eXBlID09PSBDT0RFUykgewogICAgICAgICAgYmFzZSA9IGV4dHJhID0gd29yazsKICAgICAgICAgIGVuZCA9IDE5OwogICAgICAgIH0gZWxzZSBpZiAodHlwZSA9PT0gTEVOUykgewogICAgICAgICAgYmFzZSA9IGxiYXNlOwogICAgICAgICAgYmFzZV9pbmRleCAtPSAyNTc7CiAgICAgICAgICBleHRyYSA9IGxleHQ7CiAgICAgICAgICBleHRyYV9pbmRleCAtPSAyNTc7CiAgICAgICAgICBlbmQgPSAyNTY7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGJhc2UgPSBkYmFzZTsKICAgICAgICAgIGV4dHJhID0gZGV4dDsKICAgICAgICAgIGVuZCA9IC0xOwogICAgICAgIH0KICAgICAgICBodWZmID0gMDsKICAgICAgICBzeW0gPSAwOwogICAgICAgIGxlbiA9IG1pbjsKICAgICAgICBuZXh0ID0gdGFibGVfaW5kZXg7CiAgICAgICAgY3VyciA9IHJvb3Q7CiAgICAgICAgZHJvcCA9IDA7CiAgICAgICAgbG93ID0gLTE7CiAgICAgICAgdXNlZCA9IDEgPDwgcm9vdDsKICAgICAgICBtYXNrID0gdXNlZCAtIDE7CiAgICAgICAgaWYgKHR5cGUgPT09IExFTlMgJiYgdXNlZCA+IEVOT1VHSF9MRU5TIHx8IHR5cGUgPT09IERJU1RTICYmIHVzZWQgPiBFTk9VR0hfRElTVFMpIHsKICAgICAgICAgIHJldHVybiAxOwogICAgICAgIH0KICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgIGhlcmVfYml0cyA9IGxlbiAtIGRyb3A7CiAgICAgICAgICBpZiAod29ya1tzeW1dIDwgZW5kKSB7CiAgICAgICAgICAgIGhlcmVfb3AgPSAwOwogICAgICAgICAgICBoZXJlX3ZhbCA9IHdvcmtbc3ltXTsKICAgICAgICAgIH0gZWxzZSBpZiAod29ya1tzeW1dID4gZW5kKSB7CiAgICAgICAgICAgIGhlcmVfb3AgPSBleHRyYVtleHRyYV9pbmRleCArIHdvcmtbc3ltXV07CiAgICAgICAgICAgIGhlcmVfdmFsID0gYmFzZVtiYXNlX2luZGV4ICsgd29ya1tzeW1dXTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGhlcmVfb3AgPSAzMiArIDY0OwogICAgICAgICAgICBoZXJlX3ZhbCA9IDA7CiAgICAgICAgICB9CiAgICAgICAgICBpbmNyID0gMSA8PCBsZW4gLSBkcm9wOwogICAgICAgICAgZmlsbCA9IDEgPDwgY3VycjsKICAgICAgICAgIG1pbiA9IGZpbGw7CiAgICAgICAgICBkbyB7CiAgICAgICAgICAgIGZpbGwgLT0gaW5jcjsKICAgICAgICAgICAgdGFibGVbbmV4dCArIChodWZmID4+IGRyb3ApICsgZmlsbF0gPSBoZXJlX2JpdHMgPDwgMjQgfCBoZXJlX29wIDw8IDE2IHwgaGVyZV92YWwgfCAwOwogICAgICAgICAgfSB3aGlsZSAoZmlsbCAhPT0gMCk7CiAgICAgICAgICBpbmNyID0gMSA8PCBsZW4gLSAxOwogICAgICAgICAgd2hpbGUgKGh1ZmYgJiBpbmNyKSB7CiAgICAgICAgICAgIGluY3IgPj49IDE7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoaW5jciAhPT0gMCkgewogICAgICAgICAgICBodWZmICY9IGluY3IgLSAxOwogICAgICAgICAgICBodWZmICs9IGluY3I7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBodWZmID0gMDsKICAgICAgICAgIH0KICAgICAgICAgIHN5bSsrOwogICAgICAgICAgaWYgKC0tY291bnRbbGVuXSA9PT0gMCkgewogICAgICAgICAgICBpZiAobGVuID09PSBtYXgpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZW4gPSBsZW5zW2xlbnNfaW5kZXggKyB3b3JrW3N5bV1dOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGxlbiA+IHJvb3QgJiYgKGh1ZmYgJiBtYXNrKSAhPT0gbG93KSB7CiAgICAgICAgICAgIGlmIChkcm9wID09PSAwKSB7CiAgICAgICAgICAgICAgZHJvcCA9IHJvb3Q7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbmV4dCArPSBtaW47CiAgICAgICAgICAgIGN1cnIgPSBsZW4gLSBkcm9wOwogICAgICAgICAgICBsZWZ0ID0gMSA8PCBjdXJyOwogICAgICAgICAgICB3aGlsZSAoY3VyciArIGRyb3AgPCBtYXgpIHsKICAgICAgICAgICAgICBsZWZ0IC09IGNvdW50W2N1cnIgKyBkcm9wXTsKICAgICAgICAgICAgICBpZiAobGVmdCA8PSAwKSB7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY3VycisrOwogICAgICAgICAgICAgIGxlZnQgPDw9IDE7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdXNlZCArPSAxIDw8IGN1cnI7CiAgICAgICAgICAgIGlmICh0eXBlID09PSBMRU5TICYmIHVzZWQgPiBFTk9VR0hfTEVOUyB8fCB0eXBlID09PSBESVNUUyAmJiB1c2VkID4gRU5PVUdIX0RJU1RTKSB7CiAgICAgICAgICAgICAgcmV0dXJuIDE7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbG93ID0gaHVmZiAmIG1hc2s7CiAgICAgICAgICAgIHRhYmxlW2xvd10gPSByb290IDw8IDI0IHwgY3VyciA8PCAxNiB8IG5leHQgLSB0YWJsZV9pbmRleCB8IDA7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChodWZmICE9PSAwKSB7CiAgICAgICAgICB0YWJsZVtuZXh0ICsgaHVmZl0gPSBsZW4gLSBkcm9wIDw8IDI0IHwgNjQgPDwgMTYgfCAwOwogICAgICAgIH0KICAgICAgICBvcHRzLmJpdHMgPSByb290OwogICAgICAgIHJldHVybiAwOwogICAgICB9OwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLnBucG0vcGFrb0AxLjAuMTEvbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvaW5mbGF0ZS5qcwogIHZhciByZXF1aXJlX2luZmxhdGUgPSBfX2NvbW1vbkpTKHsKICAgICJub2RlX21vZHVsZXMvLnBucG0vcGFrb0AxLjAuMTEvbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvaW5mbGF0ZS5qcyIoZXhwb3J0cykgewogICAgICBpbml0X2J1ZmZlcl9zaGltKCk7CiAgICAgICJ1c2Ugc3RyaWN0IjsKICAgICAgdmFyIHV0aWxzID0gcmVxdWlyZV9jb21tb24yKCk7CiAgICAgIHZhciBhZGxlcjMyID0gcmVxdWlyZV9hZGxlcjMyKCk7CiAgICAgIHZhciBjcmMzMjIgPSByZXF1aXJlX2NyYzMyKCk7CiAgICAgIHZhciBpbmZsYXRlX2Zhc3QgPSByZXF1aXJlX2luZmZhc3QoKTsKICAgICAgdmFyIGluZmxhdGVfdGFibGUgPSByZXF1aXJlX2luZnRyZWVzKCk7CiAgICAgIHZhciBDT0RFUyA9IDA7CiAgICAgIHZhciBMRU5TID0gMTsKICAgICAgdmFyIERJU1RTID0gMjsKICAgICAgdmFyIFpfRklOSVNIID0gNDsKICAgICAgdmFyIFpfQkxPQ0sgPSA1OwogICAgICB2YXIgWl9UUkVFUyA9IDY7CiAgICAgIHZhciBaX09LID0gMDsKICAgICAgdmFyIFpfU1RSRUFNX0VORCA9IDE7CiAgICAgIHZhciBaX05FRURfRElDVCA9IDI7CiAgICAgIHZhciBaX1NUUkVBTV9FUlJPUiA9IC0yOwogICAgICB2YXIgWl9EQVRBX0VSUk9SID0gLTM7CiAgICAgIHZhciBaX01FTV9FUlJPUiA9IC00OwogICAgICB2YXIgWl9CVUZfRVJST1IgPSAtNTsKICAgICAgdmFyIFpfREVGTEFURUQgPSA4OwogICAgICB2YXIgSEVBRCA9IDE7CiAgICAgIHZhciBGTEFHUyA9IDI7CiAgICAgIHZhciBUSU1FID0gMzsKICAgICAgdmFyIE9TID0gNDsKICAgICAgdmFyIEVYTEVOID0gNTsKICAgICAgdmFyIEVYVFJBID0gNjsKICAgICAgdmFyIE5BTUUgPSA3OwogICAgICB2YXIgQ09NTUVOVCA9IDg7CiAgICAgIHZhciBIQ1JDID0gOTsKICAgICAgdmFyIERJQ1RJRCA9IDEwOwogICAgICB2YXIgRElDVCA9IDExOwogICAgICB2YXIgVFlQRSA9IDEyOwogICAgICB2YXIgVFlQRURPID0gMTM7CiAgICAgIHZhciBTVE9SRUQgPSAxNDsKICAgICAgdmFyIENPUFlfID0gMTU7CiAgICAgIHZhciBDT1BZID0gMTY7CiAgICAgIHZhciBUQUJMRSA9IDE3OwogICAgICB2YXIgTEVOTEVOUyA9IDE4OwogICAgICB2YXIgQ09ERUxFTlMgPSAxOTsKICAgICAgdmFyIExFTl8gPSAyMDsKICAgICAgdmFyIExFTiA9IDIxOwogICAgICB2YXIgTEVORVhUID0gMjI7CiAgICAgIHZhciBESVNUID0gMjM7CiAgICAgIHZhciBESVNURVhUID0gMjQ7CiAgICAgIHZhciBNQVRDSCA9IDI1OwogICAgICB2YXIgTElUID0gMjY7CiAgICAgIHZhciBDSEVDSyA9IDI3OwogICAgICB2YXIgTEVOR1RIID0gMjg7CiAgICAgIHZhciBET05FID0gMjk7CiAgICAgIHZhciBCQUQgPSAzMDsKICAgICAgdmFyIE1FTSA9IDMxOwogICAgICB2YXIgU1lOQyA9IDMyOwogICAgICB2YXIgRU5PVUdIX0xFTlMgPSA4NTI7CiAgICAgIHZhciBFTk9VR0hfRElTVFMgPSA1OTI7CiAgICAgIHZhciBNQVhfV0JJVFMgPSAxNTsKICAgICAgdmFyIERFRl9XQklUUyA9IE1BWF9XQklUUzsKICAgICAgZnVuY3Rpb24genN3YXAzMihxKSB7CiAgICAgICAgcmV0dXJuIChxID4+PiAyNCAmIDI1NSkgKyAocSA+Pj4gOCAmIDY1MjgwKSArICgocSAmIDY1MjgwKSA8PCA4KSArICgocSAmIDI1NSkgPDwgMjQpOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIEluZmxhdGVTdGF0ZSgpIHsKICAgICAgICB0aGlzLm1vZGUgPSAwOwogICAgICAgIHRoaXMubGFzdCA9IGZhbHNlOwogICAgICAgIHRoaXMud3JhcCA9IDA7CiAgICAgICAgdGhpcy5oYXZlZGljdCA9IGZhbHNlOwogICAgICAgIHRoaXMuZmxhZ3MgPSAwOwogICAgICAgIHRoaXMuZG1heCA9IDA7CiAgICAgICAgdGhpcy5jaGVjayA9IDA7CiAgICAgICAgdGhpcy50b3RhbCA9IDA7CiAgICAgICAgdGhpcy5oZWFkID0gbnVsbDsKICAgICAgICB0aGlzLndiaXRzID0gMDsKICAgICAgICB0aGlzLndzaXplID0gMDsKICAgICAgICB0aGlzLndoYXZlID0gMDsKICAgICAgICB0aGlzLnduZXh0ID0gMDsKICAgICAgICB0aGlzLndpbmRvdyA9IG51bGw7CiAgICAgICAgdGhpcy5ob2xkID0gMDsKICAgICAgICB0aGlzLmJpdHMgPSAwOwogICAgICAgIHRoaXMubGVuZ3RoID0gMDsKICAgICAgICB0aGlzLm9mZnNldCA9IDA7CiAgICAgICAgdGhpcy5leHRyYSA9IDA7CiAgICAgICAgdGhpcy5sZW5jb2RlID0gbnVsbDsKICAgICAgICB0aGlzLmRpc3Rjb2RlID0gbnVsbDsKICAgICAgICB0aGlzLmxlbmJpdHMgPSAwOwogICAgICAgIHRoaXMuZGlzdGJpdHMgPSAwOwogICAgICAgIHRoaXMubmNvZGUgPSAwOwogICAgICAgIHRoaXMubmxlbiA9IDA7CiAgICAgICAgdGhpcy5uZGlzdCA9IDA7CiAgICAgICAgdGhpcy5oYXZlID0gMDsKICAgICAgICB0aGlzLm5leHQgPSBudWxsOwogICAgICAgIHRoaXMub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TKTsKICAgICAgICBzdGF0ZS5zYW5lID0gMTsKICAgICAgICBzdGF0ZS5iYWNrID0gLTE7CiAgICAgICAgcmV0dXJuIFpfT0s7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gaW5mbGF0ZVJlc2V0KHN0cm0pIHsKICAgICAgICB2YXIgc3RhdGU7CiAgICAgICAgaWYgKCFzdHJtIHx8ICFzdHJtLnN0YXRlKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIHN0YXRlID0gc3RybS5zdGF0ZTsKICAgICAgICBzdGF0ZS53c2l6ZSA9IDA7CiAgICAgICAgc3RhdGUud2hhdmUgPSAwOwogICAgICAgIHN0YXRlLnduZXh0ID0gMDsKICAgICAgICByZXR1cm4gaW5mbGF0ZVJlc2V0S2VlcChzdHJtKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBpbmZsYXRlUmVzZXQyKHN0cm0sIHdpbmRvd0JpdHMpIHsKICAgICAgICB2YXIgd3JhcDsKICAgICAgICB2YXIgc3RhdGU7CiAgICAgICAgaWYgKCFzdHJtIHx8ICFzdHJtLnN0YXRlKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIHN0YXRlID0gc3RybS5zdGF0ZTsKICAgICAgICBpZiAod2luZG93Qml0cyA8IDApIHsKICAgICAgICAgIHdyYXAgPSAwOwogICAgICAgICAgd2luZG93Qml0cyA9IC13aW5kb3dCaXRzOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB3cmFwID0gKHdpbmRvd0JpdHMgPj4gNCkgKyAxOwogICAgICAgICAgaWYgKHdpbmRvd0JpdHMgPCA0OCkgewogICAgICAgICAgICB3aW5kb3dCaXRzICY9IDE1OwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAod2luZG93Qml0cyAmJiAod2luZG93Qml0cyA8IDggfHwgd2luZG93Qml0cyA+IDE1KSkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgIH0KICAgICAgICBpZiAoc3RhdGUud2luZG93ICE9PSBudWxsICYmIHN0YXRlLndiaXRzICE9PSB3aW5kb3dCaXRzKSB7CiAgICAgICAgICBzdGF0ZS53aW5kb3cgPSBudWxsOwogICAgICAgIH0KICAgICAgICBzdGF0ZS53cmFwID0gd3JhcDsKICAgICAgICBzdGF0ZS53Yml0cyA9IHdpbmRvd0JpdHM7CiAgICAgICAgcmV0dXJuIGluZmxhdGVSZXNldChzdHJtKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBpbmZsYXRlSW5pdDIoc3RybSwgd2luZG93Qml0cykgewogICAgICAgIHZhciByZXQ7CiAgICAgICAgdmFyIHN0YXRlOwogICAgICAgIGlmICghc3RybSkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgIH0KICAgICAgICBzdGF0ZSA9IG5ldyBJbmZsYXRlU3RhdGUoKTsKICAgICAgICBzdHJtLnN0YXRlID0gc3RhdGU7CiAgICAgICAgc3RhdGUud2luZG93ID0gbnVsbDsKICAgICAgICByZXQgPSBpbmZsYXRlUmVzZXQyKHN0cm0sIHdpbmRvd0JpdHMpOwogICAgICAgIGlmIChyZXQgIT09IFpfT0spIHsKICAgICAgICAgIHN0cm0uc3RhdGUgPSBudWxsOwogICAgICAgIH0KICAgICAgICByZXR1cm4gcmV0OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGluZmxhdGVJbml0KHN0cm0pIHsKICAgICAgICByZXR1cm4gaW5mbGF0ZUluaXQyKHN0cm0sIERFRl9XQklUUyk7CiAgICAgIH0KICAgICAgdmFyIHZpcmdpbiA9IHRydWU7CiAgICAgIHZhciBsZW5maXg7CiAgICAgIHZhciBkaXN0Zml4OwogICAgICBmdW5jdGlvbiBmaXhlZHRhYmxlcyhzdGF0ZSkgewogICAgICAgIGlmICh2aXJnaW4pIHsKICAgICAgICAgIHZhciBzeW07CiAgICAgICAgICBsZW5maXggPSBuZXcgdXRpbHMuQnVmMzIoNTEyKTsKICAgICAgICAgIGRpc3RmaXggPSBuZXcgdXRpbHMuQnVmMzIoMzIpOwogICAgICAgICAgc3ltID0gMDsKICAgICAgICAgIHdoaWxlIChzeW0gPCAxNDQpIHsKICAgICAgICAgICAgc3RhdGUubGVuc1tzeW0rK10gPSA4OwogICAgICAgICAgfQogICAgICAgICAgd2hpbGUgKHN5bSA8IDI1NikgewogICAgICAgICAgICBzdGF0ZS5sZW5zW3N5bSsrXSA9IDk7CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3ltIDwgMjgwKSB7CiAgICAgICAgICAgIHN0YXRlLmxlbnNbc3ltKytdID0gNzsKICAgICAgICAgIH0KICAgICAgICAgIHdoaWxlIChzeW0gPCAyODgpIHsKICAgICAgICAgICAgc3RhdGUubGVuc1tzeW0rK10gPSA4OwogICAgICAgICAgfQogICAgICAgICAgaW5mbGF0ZV90YWJsZShMRU5TLCBzdGF0ZS5sZW5zLCAwLCAyODgsIGxlbmZpeCwgMCwgc3RhdGUud29yaywgeyBiaXRzOiA5IH0pOwogICAgICAgICAgc3ltID0gMDsKICAgICAgICAgIHdoaWxlIChzeW0gPCAzMikgewogICAgICAgICAgICBzdGF0ZS5sZW5zW3N5bSsrXSA9IDU7CiAgICAgICAgICB9CiAgICAgICAgICBpbmZsYXRlX3RhYmxlKERJU1RTLCBzdGF0ZS5sZW5zLCAwLCAzMiwgZGlzdGZpeCwgMCwgc3RhdGUud29yaywgeyBiaXRzOiA1IH0pOwogICAgICAgICAgdmlyZ2luID0gZmFsc2U7CiAgICAgICAgfQogICAgICAgIHN0YXRlLmxlbmNvZGUgPSBsZW5maXg7CiAgICAgICAgc3RhdGUubGVuYml0cyA9IDk7CiAgICAgICAgc3RhdGUuZGlzdGNvZGUgPSBkaXN0Zml4OwogICAgICAgIHN0YXRlLmRpc3RiaXRzID0gNTsKICAgICAgfQogICAgICBmdW5jdGlvbiB1cGRhdGV3aW5kb3coc3RybSwgc3JjLCBlbmQsIGNvcHkpIHsKICAgICAgICB2YXIgZGlzdDsKICAgICAgICB2YXIgc3RhdGUgPSBzdHJtLnN0YXRlOwogICAgICAgIGlmIChzdGF0ZS53aW5kb3cgPT09IG51bGwpIHsKICAgICAgICAgIHN0YXRlLndzaXplID0gMSA8PCBzdGF0ZS53Yml0czsKICAgICAgICAgIHN0YXRlLnduZXh0ID0gMDsKICAgICAgICAgIHN0YXRlLndoYXZlID0gMDsKICAgICAgICAgIHN0YXRlLndpbmRvdyA9IG5ldyB1dGlscy5CdWY4KHN0YXRlLndzaXplKTsKICAgICAgICB9CiAgICAgICAgaWYgKGNvcHkgPj0gc3RhdGUud3NpemUpIHsKICAgICAgICAgIHV0aWxzLmFycmF5U2V0KHN0YXRlLndpbmRvdywgc3JjLCBlbmQgLSBzdGF0ZS53c2l6ZSwgc3RhdGUud3NpemUsIDApOwogICAgICAgICAgc3RhdGUud25leHQgPSAwOwogICAgICAgICAgc3RhdGUud2hhdmUgPSBzdGF0ZS53c2l6ZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGlzdCA9IHN0YXRlLndzaXplIC0gc3RhdGUud25leHQ7CiAgICAgICAgICBpZiAoZGlzdCA+IGNvcHkpIHsKICAgICAgICAgICAgZGlzdCA9IGNvcHk7CiAgICAgICAgICB9CiAgICAgICAgICB1dGlscy5hcnJheVNldChzdGF0ZS53aW5kb3csIHNyYywgZW5kIC0gY29weSwgZGlzdCwgc3RhdGUud25leHQpOwogICAgICAgICAgY29weSAtPSBkaXN0OwogICAgICAgICAgaWYgKGNvcHkpIHsKICAgICAgICAgICAgdXRpbHMuYXJyYXlTZXQoc3RhdGUud2luZG93LCBzcmMsIGVuZCAtIGNvcHksIGNvcHksIDApOwogICAgICAgICAgICBzdGF0ZS53bmV4dCA9IGNvcHk7CiAgICAgICAgICAgIHN0YXRlLndoYXZlID0gc3RhdGUud3NpemU7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzdGF0ZS53bmV4dCArPSBkaXN0OwogICAgICAgICAgICBpZiAoc3RhdGUud25leHQgPT09IHN0YXRlLndzaXplKSB7CiAgICAgICAgICAgICAgc3RhdGUud25leHQgPSAwOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzdGF0ZS53aGF2ZSA8IHN0YXRlLndzaXplKSB7CiAgICAgICAgICAgICAgc3RhdGUud2hhdmUgKz0gZGlzdDsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gMDsKICAgICAgfQogICAgICBmdW5jdGlvbiBpbmZsYXRlKHN0cm0sIGZsdXNoKSB7CiAgICAgICAgdmFyIHN0YXRlOwogICAgICAgIHZhciBpbnB1dCwgb3V0cHV0OwogICAgICAgIHZhciBuZXh0OwogICAgICAgIHZhciBwdXQ7CiAgICAgICAgdmFyIGhhdmUsIGxlZnQ7CiAgICAgICAgdmFyIGhvbGQ7CiAgICAgICAgdmFyIGJpdHM7CiAgICAgICAgdmFyIF9pbiwgX291dDsKICAgICAgICB2YXIgY29weTsKICAgICAgICB2YXIgZnJvbTsKICAgICAgICB2YXIgZnJvbV9zb3VyY2U7CiAgICAgICAgdmFyIGhlcmUgPSAwOwogICAgICAgIHZhciBoZXJlX2JpdHMsIGhlcmVfb3AsIGhlcmVfdmFsOwogICAgICAgIHZhciBsYXN0X2JpdHMsIGxhc3Rfb3AsIGxhc3RfdmFsOwogICAgICAgIHZhciBsZW47CiAgICAgICAgdmFyIHJldDsKICAgICAgICB2YXIgaGJ1ZiA9IG5ldyB1dGlscy5CdWY4KDQpOwogICAgICAgIHZhciBvcHRzOwogICAgICAgIHZhciBuOwogICAgICAgIHZhciBvcmRlciA9IFsxNiwgMTcsIDE4LCAwLCA4LCA3LCA5LCA2LCAxMCwgNSwgMTEsIDQsIDEyLCAzLCAxMywgMiwgMTQsIDEsIDE1XTsKICAgICAgICBpZiAoIXN0cm0gfHwgIXN0cm0uc3RhdGUgfHwgIXN0cm0ub3V0cHV0IHx8ICFzdHJtLmlucHV0ICYmIHN0cm0uYXZhaWxfaW4gIT09IDApIHsKICAgICAgICAgIHJldHVybiBaX1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgc3RhdGUgPSBzdHJtLnN0YXRlOwogICAgICAgIGlmIChzdGF0ZS5tb2RlID09PSBUWVBFKSB7CiAgICAgICAgICBzdGF0ZS5tb2RlID0gVFlQRURPOwogICAgICAgIH0KICAgICAgICBwdXQgPSBzdHJtLm5leHRfb3V0OwogICAgICAgIG91dHB1dCA9IHN0cm0ub3V0cHV0OwogICAgICAgIGxlZnQgPSBzdHJtLmF2YWlsX291dDsKICAgICAgICBuZXh0ID0gc3RybS5uZXh0X2luOwogICAgICAgIGlucHV0ID0gc3RybS5pbnB1dDsKICAgICAgICBoYXZlID0gc3RybS5hdmFpbF9pbjsKICAgICAgICBob2xkID0gc3RhdGUuaG9sZDsKICAgICAgICBiaXRzID0gc3RhdGUuYml0czsKICAgICAgICBfaW4gPSBoYXZlOwogICAgICAgIF9vdXQgPSBsZWZ0OwogICAgICAgIHJldCA9IFpfT0s7CiAgICAgICAgaW5mX2xlYXZlOgogICAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICAgIHN3aXRjaCAoc3RhdGUubW9kZSkgewogICAgICAgICAgICAgIGNhc2UgSEVBRDoKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS53cmFwID09PSAwKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBUWVBFRE87CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAxNikgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUud3JhcCAmIDIgJiYgaG9sZCA9PT0gMzU2MTUpIHsKICAgICAgICAgICAgICAgICAgc3RhdGUuY2hlY2sgPSAwOwogICAgICAgICAgICAgICAgICBoYnVmWzBdID0gaG9sZCAmIDI1NTsKICAgICAgICAgICAgICAgICAgaGJ1ZlsxXSA9IGhvbGQgPj4+IDggJiAyNTU7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmNoZWNrID0gY3JjMzIyKHN0YXRlLmNoZWNrLCBoYnVmLCAyLCAwKTsKICAgICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICAgIGJpdHMgPSAwOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gRkxBR1M7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUuZmxhZ3MgPSAwOwogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHsKICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC5kb25lID0gZmFsc2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoIShzdGF0ZS53cmFwICYgMSkgfHwgKCgoaG9sZCAmIDI1NSkgPDwgOCkgKyAoaG9sZCA+PiA4KSkgJSAzMSkgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbmNvcnJlY3QgaGVhZGVyIGNoZWNrIjsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoKGhvbGQgJiAxNSkgIT09IFpfREVGTEFURUQpIHsKICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAidW5rbm93biBjb21wcmVzc2lvbiBtZXRob2QiOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGhvbGQgPj4+PSA0OwogICAgICAgICAgICAgICAgYml0cyAtPSA0OwogICAgICAgICAgICAgICAgbGVuID0gKGhvbGQgJiAxNSkgKyA4OwogICAgICAgICAgICAgICAgaWYgKHN0YXRlLndiaXRzID09PSAwKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLndiaXRzID0gbGVuOwogICAgICAgICAgICAgICAgfSBlbHNlIGlmIChsZW4gPiBzdGF0ZS53Yml0cykgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIHdpbmRvdyBzaXplIjsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5kbWF4ID0gMSA8PCBsZW47CiAgICAgICAgICAgICAgICBzdHJtLmFkbGVyID0gc3RhdGUuY2hlY2sgPSAxOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IGhvbGQgJiA1MTIgPyBESUNUSUQgOiBUWVBFOwogICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICBiaXRzID0gMDsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGNhc2UgRkxBR1M6CiAgICAgICAgICAgICAgICB3aGlsZSAoYml0cyA8IDE2KSB7CiAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLmZsYWdzID0gaG9sZDsKICAgICAgICAgICAgICAgIGlmICgoc3RhdGUuZmxhZ3MgJiAyNTUpICE9PSBaX0RFRkxBVEVEKSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gInVua25vd24gY29tcHJlc3Npb24gbWV0aG9kIjsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiA1NzM0NCkgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJ1bmtub3duIGhlYWRlciBmbGFncyBzZXQiOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5oZWFkKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmhlYWQudGV4dCA9IGhvbGQgPj4gOCAmIDE7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiA1MTIpIHsKICAgICAgICAgICAgICAgICAgaGJ1ZlswXSA9IGhvbGQgJiAyNTU7CiAgICAgICAgICAgICAgICAgIGhidWZbMV0gPSBob2xkID4+PiA4ICYgMjU1OwogICAgICAgICAgICAgICAgICBzdGF0ZS5jaGVjayA9IGNyYzMyMihzdGF0ZS5jaGVjaywgaGJ1ZiwgMiwgMCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBob2xkID0gMDsKICAgICAgICAgICAgICAgIGJpdHMgPSAwOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IFRJTUU7CiAgICAgICAgICAgICAgY2FzZSBUSU1FOgogICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAzMikgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuaGVhZCkgewogICAgICAgICAgICAgICAgICBzdGF0ZS5oZWFkLnRpbWUgPSBob2xkOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgNTEyKSB7CiAgICAgICAgICAgICAgICAgIGhidWZbMF0gPSBob2xkICYgMjU1OwogICAgICAgICAgICAgICAgICBoYnVmWzFdID0gaG9sZCA+Pj4gOCAmIDI1NTsKICAgICAgICAgICAgICAgICAgaGJ1ZlsyXSA9IGhvbGQgPj4+IDE2ICYgMjU1OwogICAgICAgICAgICAgICAgICBoYnVmWzNdID0gaG9sZCA+Pj4gMjQgJiAyNTU7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmNoZWNrID0gY3JjMzIyKHN0YXRlLmNoZWNrLCBoYnVmLCA0LCAwKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGhvbGQgPSAwOwogICAgICAgICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gT1M7CiAgICAgICAgICAgICAgY2FzZSBPUzoKICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMTYpIHsKICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHsKICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC54ZmxhZ3MgPSBob2xkICYgMjU1OwogICAgICAgICAgICAgICAgICBzdGF0ZS5oZWFkLm9zID0gaG9sZCA+PiA4OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgNTEyKSB7CiAgICAgICAgICAgICAgICAgIGhidWZbMF0gPSBob2xkICYgMjU1OwogICAgICAgICAgICAgICAgICBoYnVmWzFdID0gaG9sZCA+Pj4gOCAmIDI1NTsKICAgICAgICAgICAgICAgICAgc3RhdGUuY2hlY2sgPSBjcmMzMjIoc3RhdGUuY2hlY2ssIGhidWYsIDIsIDApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICBiaXRzID0gMDsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBFWExFTjsKICAgICAgICAgICAgICBjYXNlIEVYTEVOOgogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgMTAyNCkgewogICAgICAgICAgICAgICAgICB3aGlsZSAoYml0cyA8IDE2KSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBzdGF0ZS5sZW5ndGggPSBob2xkOwogICAgICAgICAgICAgICAgICBpZiAoc3RhdGUuaGVhZCkgewogICAgICAgICAgICAgICAgICAgIHN0YXRlLmhlYWQuZXh0cmFfbGVuID0gaG9sZDsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiA1MTIpIHsKICAgICAgICAgICAgICAgICAgICBoYnVmWzBdID0gaG9sZCAmIDI1NTsKICAgICAgICAgICAgICAgICAgICBoYnVmWzFdID0gaG9sZCA+Pj4gOCAmIDI1NTsKICAgICAgICAgICAgICAgICAgICBzdGF0ZS5jaGVjayA9IGNyYzMyMihzdGF0ZS5jaGVjaywgaGJ1ZiwgMiwgMCk7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICAgIGJpdHMgPSAwOwogICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzdGF0ZS5oZWFkKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmhlYWQuZXh0cmEgPSBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEVYVFJBOwogICAgICAgICAgICAgIGNhc2UgRVhUUkE6CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiAxMDI0KSB7CiAgICAgICAgICAgICAgICAgIGNvcHkgPSBzdGF0ZS5sZW5ndGg7CiAgICAgICAgICAgICAgICAgIGlmIChjb3B5ID4gaGF2ZSkgewogICAgICAgICAgICAgICAgICAgIGNvcHkgPSBoYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChjb3B5KSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHsKICAgICAgICAgICAgICAgICAgICAgIGxlbiA9IHN0YXRlLmhlYWQuZXh0cmFfbGVuIC0gc3RhdGUubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZS5oZWFkLmV4dHJhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLmhlYWQuZXh0cmEgPSBuZXcgQXJyYXkoc3RhdGUuaGVhZC5leHRyYV9sZW4pOwogICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgdXRpbHMuYXJyYXlTZXQoc3RhdGUuaGVhZC5leHRyYSwgaW5wdXQsIG5leHQsIGNvcHksIGxlbik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDUxMikgewogICAgICAgICAgICAgICAgICAgICAgc3RhdGUuY2hlY2sgPSBjcmMzMjIoc3RhdGUuY2hlY2ssIGlucHV0LCBjb3B5LCBuZXh0KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGF2ZSAtPSBjb3B5OwogICAgICAgICAgICAgICAgICAgIG5leHQgKz0gY29weTsKICAgICAgICAgICAgICAgICAgICBzdGF0ZS5sZW5ndGggLT0gY29weTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoc3RhdGUubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IE5BTUU7CiAgICAgICAgICAgICAgY2FzZSBOQU1FOgogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgMjA0OCkgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBjb3B5ID0gMDsKICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgIGxlbiA9IGlucHV0W25leHQgKyBjb3B5KytdOwogICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5oZWFkICYmIGxlbiAmJiBzdGF0ZS5sZW5ndGggPCA2NTUzNikgewogICAgICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC5uYW1lICs9IFN0cmluZy5mcm9tQ2hhckNvZGUobGVuKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKGxlbiAmJiBjb3B5IDwgaGF2ZSk7CiAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDUxMikgewogICAgICAgICAgICAgICAgICAgIHN0YXRlLmNoZWNrID0gY3JjMzIyKHN0YXRlLmNoZWNrLCBpbnB1dCwgY29weSwgbmV4dCk7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaGF2ZSAtPSBjb3B5OwogICAgICAgICAgICAgICAgICBuZXh0ICs9IGNvcHk7CiAgICAgICAgICAgICAgICAgIGlmIChsZW4pIHsKICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoc3RhdGUuaGVhZCkgewogICAgICAgICAgICAgICAgICBzdGF0ZS5oZWFkLm5hbWUgPSBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUubGVuZ3RoID0gMDsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBDT01NRU5UOwogICAgICAgICAgICAgIGNhc2UgQ09NTUVOVDoKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDQwOTYpIHsKICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgY29weSA9IDA7CiAgICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgICBsZW4gPSBpbnB1dFtuZXh0ICsgY29weSsrXTsKICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGUuaGVhZCAmJiBsZW4gJiYgc3RhdGUubGVuZ3RoIDwgNjU1MzYpIHsKICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLmhlYWQuY29tbWVudCArPSBTdHJpbmcuZnJvbUNoYXJDb2RlKGxlbik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICB9IHdoaWxlIChsZW4gJiYgY29weSA8IGhhdmUpOwogICAgICAgICAgICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiA1MTIpIHsKICAgICAgICAgICAgICAgICAgICBzdGF0ZS5jaGVjayA9IGNyYzMyMihzdGF0ZS5jaGVjaywgaW5wdXQsIGNvcHksIG5leHQpOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGhhdmUgLT0gY29weTsKICAgICAgICAgICAgICAgICAgbmV4dCArPSBjb3B5OwogICAgICAgICAgICAgICAgICBpZiAobGVuKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHN0YXRlLmhlYWQpIHsKICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC5jb21tZW50ID0gbnVsbDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBIQ1JDOwogICAgICAgICAgICAgIGNhc2UgSENSQzoKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDUxMikgewogICAgICAgICAgICAgICAgICB3aGlsZSAoYml0cyA8IDE2KSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoaG9sZCAhPT0gKHN0YXRlLmNoZWNrICYgNjU1MzUpKSB7CiAgICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaGVhZGVyIGNyYyBtaXNtYXRjaCI7CiAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBob2xkID0gMDsKICAgICAgICAgICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuaGVhZCkgewogICAgICAgICAgICAgICAgICBzdGF0ZS5oZWFkLmhjcmMgPSBzdGF0ZS5mbGFncyA+PiA5ICYgMTsKICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC5kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0cm0uYWRsZXIgPSBzdGF0ZS5jaGVjayA9IDA7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gVFlQRTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGNhc2UgRElDVElEOgogICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAzMikgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdHJtLmFkbGVyID0gc3RhdGUuY2hlY2sgPSB6c3dhcDMyKGhvbGQpOwogICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICBiaXRzID0gMDsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBESUNUOwogICAgICAgICAgICAgIGNhc2UgRElDVDoKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5oYXZlZGljdCA9PT0gMCkgewogICAgICAgICAgICAgICAgICBzdHJtLm5leHRfb3V0ID0gcHV0OwogICAgICAgICAgICAgICAgICBzdHJtLmF2YWlsX291dCA9IGxlZnQ7CiAgICAgICAgICAgICAgICAgIHN0cm0ubmV4dF9pbiA9IG5leHQ7CiAgICAgICAgICAgICAgICAgIHN0cm0uYXZhaWxfaW4gPSBoYXZlOwogICAgICAgICAgICAgICAgICBzdGF0ZS5ob2xkID0gaG9sZDsKICAgICAgICAgICAgICAgICAgc3RhdGUuYml0cyA9IGJpdHM7CiAgICAgICAgICAgICAgICAgIHJldHVybiBaX05FRURfRElDVDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0cm0uYWRsZXIgPSBzdGF0ZS5jaGVjayA9IDE7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gVFlQRTsKICAgICAgICAgICAgICBjYXNlIFRZUEU6CiAgICAgICAgICAgICAgICBpZiAoZmx1c2ggPT09IFpfQkxPQ0sgfHwgZmx1c2ggPT09IFpfVFJFRVMpIHsKICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNhc2UgVFlQRURPOgogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmxhc3QpIHsKICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IGJpdHMgJiA3OwogICAgICAgICAgICAgICAgICBiaXRzIC09IGJpdHMgJiA3OwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQ0hFQ0s7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAzKSB7CiAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLmxhc3QgPSBob2xkICYgMTsKICAgICAgICAgICAgICAgIGhvbGQgPj4+PSAxOwogICAgICAgICAgICAgICAgYml0cyAtPSAxOwogICAgICAgICAgICAgICAgc3dpdGNoIChob2xkICYgMykgewogICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IFNUT1JFRDsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgY2FzZSAxOgogICAgICAgICAgICAgICAgICAgIGZpeGVkdGFibGVzKHN0YXRlKTsKICAgICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gTEVOXzsKICAgICAgICAgICAgICAgICAgICBpZiAoZmx1c2ggPT09IFpfVFJFRVMpIHsKICAgICAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSAyOwogICAgICAgICAgICAgICAgICAgICAgYml0cyAtPSAyOwogICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBUQUJMRTsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgY2FzZSAzOgogICAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgYmxvY2sgdHlwZSI7CiAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGhvbGQgPj4+PSAyOwogICAgICAgICAgICAgICAgYml0cyAtPSAyOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSBTVE9SRUQ6CiAgICAgICAgICAgICAgICBob2xkID4+Pj0gYml0cyAmIDc7CiAgICAgICAgICAgICAgICBiaXRzIC09IGJpdHMgJiA3OwogICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAzMikgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoKGhvbGQgJiA2NTUzNSkgIT09IChob2xkID4+PiAxNiBeIDY1NTM1KSkgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIHN0b3JlZCBibG9jayBsZW5ndGhzIjsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5sZW5ndGggPSBob2xkICYgNjU1MzU7CiAgICAgICAgICAgICAgICBob2xkID0gMDsKICAgICAgICAgICAgICAgIGJpdHMgPSAwOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IENPUFlfOwogICAgICAgICAgICAgICAgaWYgKGZsdXNoID09PSBaX1RSRUVTKSB7CiAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjYXNlIENPUFlfOgogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IENPUFk7CiAgICAgICAgICAgICAgY2FzZSBDT1BZOgogICAgICAgICAgICAgICAgY29weSA9IHN0YXRlLmxlbmd0aDsKICAgICAgICAgICAgICAgIGlmIChjb3B5KSB7CiAgICAgICAgICAgICAgICAgIGlmIChjb3B5ID4gaGF2ZSkgewogICAgICAgICAgICAgICAgICAgIGNvcHkgPSBoYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChjb3B5ID4gbGVmdCkgewogICAgICAgICAgICAgICAgICAgIGNvcHkgPSBsZWZ0OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChjb3B5ID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIHV0aWxzLmFycmF5U2V0KG91dHB1dCwgaW5wdXQsIG5leHQsIGNvcHksIHB1dCk7CiAgICAgICAgICAgICAgICAgIGhhdmUgLT0gY29weTsKICAgICAgICAgICAgICAgICAgbmV4dCArPSBjb3B5OwogICAgICAgICAgICAgICAgICBsZWZ0IC09IGNvcHk7CiAgICAgICAgICAgICAgICAgIHB1dCArPSBjb3B5OwogICAgICAgICAgICAgICAgICBzdGF0ZS5sZW5ndGggLT0gY29weTsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gVFlQRTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGNhc2UgVEFCTEU6CiAgICAgICAgICAgICAgICB3aGlsZSAoYml0cyA8IDE0KSB7CiAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLm5sZW4gPSAoaG9sZCAmIDMxKSArIDI1NzsKICAgICAgICAgICAgICAgIGhvbGQgPj4+PSA1OwogICAgICAgICAgICAgICAgYml0cyAtPSA1OwogICAgICAgICAgICAgICAgc3RhdGUubmRpc3QgPSAoaG9sZCAmIDMxKSArIDE7CiAgICAgICAgICAgICAgICBob2xkID4+Pj0gNTsKICAgICAgICAgICAgICAgIGJpdHMgLT0gNTsKICAgICAgICAgICAgICAgIHN0YXRlLm5jb2RlID0gKGhvbGQgJiAxNSkgKyA0OwogICAgICAgICAgICAgICAgaG9sZCA+Pj49IDQ7CiAgICAgICAgICAgICAgICBiaXRzIC09IDQ7CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUubmxlbiA+IDI4NiB8fCBzdGF0ZS5uZGlzdCA+IDMwKSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gInRvbyBtYW55IGxlbmd0aCBvciBkaXN0YW5jZSBzeW1ib2xzIjsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5oYXZlID0gMDsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBMRU5MRU5TOwogICAgICAgICAgICAgIGNhc2UgTEVOTEVOUzoKICAgICAgICAgICAgICAgIHdoaWxlIChzdGF0ZS5oYXZlIDwgc3RhdGUubmNvZGUpIHsKICAgICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBzdGF0ZS5sZW5zW29yZGVyW3N0YXRlLmhhdmUrK11dID0gaG9sZCAmIDc7CiAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSAzOwogICAgICAgICAgICAgICAgICBiaXRzIC09IDM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB3aGlsZSAoc3RhdGUuaGF2ZSA8IDE5KSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmxlbnNbb3JkZXJbc3RhdGUuaGF2ZSsrXV0gPSAwOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUubGVuY29kZSA9IHN0YXRlLmxlbmR5bjsKICAgICAgICAgICAgICAgIHN0YXRlLmxlbmJpdHMgPSA3OwogICAgICAgICAgICAgICAgb3B0cyA9IHsgYml0czogc3RhdGUubGVuYml0cyB9OwogICAgICAgICAgICAgICAgcmV0ID0gaW5mbGF0ZV90YWJsZShDT0RFUywgc3RhdGUubGVucywgMCwgMTksIHN0YXRlLmxlbmNvZGUsIDAsIHN0YXRlLndvcmssIG9wdHMpOwogICAgICAgICAgICAgICAgc3RhdGUubGVuYml0cyA9IG9wdHMuYml0czsKICAgICAgICAgICAgICAgIGlmIChyZXQpIHsKICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBjb2RlIGxlbmd0aHMgc2V0IjsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5oYXZlID0gMDsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBDT0RFTEVOUzsKICAgICAgICAgICAgICBjYXNlIENPREVMRU5TOgogICAgICAgICAgICAgICAgd2hpbGUgKHN0YXRlLmhhdmUgPCBzdGF0ZS5ubGVuICsgc3RhdGUubmRpc3QpIHsKICAgICAgICAgICAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICAgICAgICAgICAgaGVyZSA9IHN0YXRlLmxlbmNvZGVbaG9sZCAmICgxIDw8IHN0YXRlLmxlbmJpdHMpIC0gMV07CiAgICAgICAgICAgICAgICAgICAgaGVyZV9iaXRzID0gaGVyZSA+Pj4gMjQ7CiAgICAgICAgICAgICAgICAgICAgaGVyZV9vcCA9IGhlcmUgPj4+IDE2ICYgMjU1OwogICAgICAgICAgICAgICAgICAgIGhlcmVfdmFsID0gaGVyZSAmIDY1NTM1OwogICAgICAgICAgICAgICAgICAgIGlmIChoZXJlX2JpdHMgPD0gYml0cykgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaWYgKGhlcmVfdmFsIDwgMTYpIHsKICAgICAgICAgICAgICAgICAgICBob2xkID4+Pj0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgICAgIGJpdHMgLT0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgICAgIHN0YXRlLmxlbnNbc3RhdGUuaGF2ZSsrXSA9IGhlcmVfdmFsOwogICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgIGlmIChoZXJlX3ZhbCA9PT0gMTYpIHsKICAgICAgICAgICAgICAgICAgICAgIG4gPSBoZXJlX2JpdHMgKyAyOwogICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCBuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICAgICAgICBiaXRzIC09IGhlcmVfYml0czsKICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5oYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgYml0IGxlbmd0aCByZXBlYXQiOwogICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgIGxlbiA9IHN0YXRlLmxlbnNbc3RhdGUuaGF2ZSAtIDFdOwogICAgICAgICAgICAgICAgICAgICAgY29weSA9IDMgKyAoaG9sZCAmIDMpOwogICAgICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IDI7CiAgICAgICAgICAgICAgICAgICAgICBiaXRzIC09IDI7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChoZXJlX3ZhbCA9PT0gMTcpIHsKICAgICAgICAgICAgICAgICAgICAgIG4gPSBoZXJlX2JpdHMgKyAzOwogICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCBuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICAgICAgICBiaXRzIC09IGhlcmVfYml0czsKICAgICAgICAgICAgICAgICAgICAgIGxlbiA9IDA7CiAgICAgICAgICAgICAgICAgICAgICBjb3B5ID0gMyArIChob2xkICYgNyk7CiAgICAgICAgICAgICAgICAgICAgICBob2xkID4+Pj0gMzsKICAgICAgICAgICAgICAgICAgICAgIGJpdHMgLT0gMzsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgbiA9IGhlcmVfYml0cyArIDc7CiAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoYml0cyA8IG4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IGhlcmVfYml0czsKICAgICAgICAgICAgICAgICAgICAgIGJpdHMgLT0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgICAgICAgbGVuID0gMDsKICAgICAgICAgICAgICAgICAgICAgIGNvcHkgPSAxMSArIChob2xkICYgMTI3KTsKICAgICAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSA3OwogICAgICAgICAgICAgICAgICAgICAgYml0cyAtPSA3OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGUuaGF2ZSArIGNvcHkgPiBzdGF0ZS5ubGVuICsgc3RhdGUubmRpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgYml0IGxlbmd0aCByZXBlYXQiOwogICAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB3aGlsZSAoY29weS0tKSB7CiAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5sZW5zW3N0YXRlLmhhdmUrK10gPSBsZW47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUubW9kZSA9PT0gQkFEKSB7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmxlbnNbMjU2XSA9PT0gMCkgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGNvZGUgLS0gbWlzc2luZyBlbmQtb2YtYmxvY2siOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLmxlbmJpdHMgPSA5OwogICAgICAgICAgICAgICAgb3B0cyA9IHsgYml0czogc3RhdGUubGVuYml0cyB9OwogICAgICAgICAgICAgICAgcmV0ID0gaW5mbGF0ZV90YWJsZShMRU5TLCBzdGF0ZS5sZW5zLCAwLCBzdGF0ZS5ubGVuLCBzdGF0ZS5sZW5jb2RlLCAwLCBzdGF0ZS53b3JrLCBvcHRzKTsKICAgICAgICAgICAgICAgIHN0YXRlLmxlbmJpdHMgPSBvcHRzLmJpdHM7CiAgICAgICAgICAgICAgICBpZiAocmV0KSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgbGl0ZXJhbC9sZW5ndGhzIHNldCI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUuZGlzdGJpdHMgPSA2OwogICAgICAgICAgICAgICAgc3RhdGUuZGlzdGNvZGUgPSBzdGF0ZS5kaXN0ZHluOwogICAgICAgICAgICAgICAgb3B0cyA9IHsgYml0czogc3RhdGUuZGlzdGJpdHMgfTsKICAgICAgICAgICAgICAgIHJldCA9IGluZmxhdGVfdGFibGUoRElTVFMsIHN0YXRlLmxlbnMsIHN0YXRlLm5sZW4sIHN0YXRlLm5kaXN0LCBzdGF0ZS5kaXN0Y29kZSwgMCwgc3RhdGUud29yaywgb3B0cyk7CiAgICAgICAgICAgICAgICBzdGF0ZS5kaXN0Yml0cyA9IG9wdHMuYml0czsKICAgICAgICAgICAgICAgIGlmIChyZXQpIHsKICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBkaXN0YW5jZXMgc2V0IjsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gTEVOXzsKICAgICAgICAgICAgICAgIGlmIChmbHVzaCA9PT0gWl9UUkVFUykgewogICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY2FzZSBMRU5fOgogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IExFTjsKICAgICAgICAgICAgICBjYXNlIExFTjoKICAgICAgICAgICAgICAgIGlmIChoYXZlID49IDYgJiYgbGVmdCA+PSAyNTgpIHsKICAgICAgICAgICAgICAgICAgc3RybS5uZXh0X291dCA9IHB1dDsKICAgICAgICAgICAgICAgICAgc3RybS5hdmFpbF9vdXQgPSBsZWZ0OwogICAgICAgICAgICAgICAgICBzdHJtLm5leHRfaW4gPSBuZXh0OwogICAgICAgICAgICAgICAgICBzdHJtLmF2YWlsX2luID0gaGF2ZTsKICAgICAgICAgICAgICAgICAgc3RhdGUuaG9sZCA9IGhvbGQ7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmJpdHMgPSBiaXRzOwogICAgICAgICAgICAgICAgICBpbmZsYXRlX2Zhc3Qoc3RybSwgX291dCk7CiAgICAgICAgICAgICAgICAgIHB1dCA9IHN0cm0ubmV4dF9vdXQ7CiAgICAgICAgICAgICAgICAgIG91dHB1dCA9IHN0cm0ub3V0cHV0OwogICAgICAgICAgICAgICAgICBsZWZ0ID0gc3RybS5hdmFpbF9vdXQ7CiAgICAgICAgICAgICAgICAgIG5leHQgPSBzdHJtLm5leHRfaW47CiAgICAgICAgICAgICAgICAgIGlucHV0ID0gc3RybS5pbnB1dDsKICAgICAgICAgICAgICAgICAgaGF2ZSA9IHN0cm0uYXZhaWxfaW47CiAgICAgICAgICAgICAgICAgIGhvbGQgPSBzdGF0ZS5ob2xkOwogICAgICAgICAgICAgICAgICBiaXRzID0gc3RhdGUuYml0czsKICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLm1vZGUgPT09IFRZUEUpIHsKICAgICAgICAgICAgICAgICAgICBzdGF0ZS5iYWNrID0gLTE7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5iYWNrID0gMDsKICAgICAgICAgICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgICAgICAgICBoZXJlID0gc3RhdGUubGVuY29kZVtob2xkICYgKDEgPDwgc3RhdGUubGVuYml0cykgLSAxXTsKICAgICAgICAgICAgICAgICAgaGVyZV9iaXRzID0gaGVyZSA+Pj4gMjQ7CiAgICAgICAgICAgICAgICAgIGhlcmVfb3AgPSBoZXJlID4+PiAxNiAmIDI1NTsKICAgICAgICAgICAgICAgICAgaGVyZV92YWwgPSBoZXJlICYgNjU1MzU7CiAgICAgICAgICAgICAgICAgIGlmIChoZXJlX2JpdHMgPD0gYml0cykgewogICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChoZXJlX29wICYmIChoZXJlX29wICYgMjQwKSA9PT0gMCkgewogICAgICAgICAgICAgICAgICBsYXN0X2JpdHMgPSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICAgIGxhc3Rfb3AgPSBoZXJlX29wOwogICAgICAgICAgICAgICAgICBsYXN0X3ZhbCA9IGhlcmVfdmFsOwogICAgICAgICAgICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgICAgICAgICAgICBoZXJlID0gc3RhdGUubGVuY29kZVtsYXN0X3ZhbCArICgoaG9sZCAmICgxIDw8IGxhc3RfYml0cyArIGxhc3Rfb3ApIC0gMSkgPj4gbGFzdF9iaXRzKV07CiAgICAgICAgICAgICAgICAgICAgaGVyZV9iaXRzID0gaGVyZSA+Pj4gMjQ7CiAgICAgICAgICAgICAgICAgICAgaGVyZV9vcCA9IGhlcmUgPj4+IDE2ICYgMjU1OwogICAgICAgICAgICAgICAgICAgIGhlcmVfdmFsID0gaGVyZSAmIDY1NTM1OwogICAgICAgICAgICAgICAgICAgIGlmIChsYXN0X2JpdHMgKyBoZXJlX2JpdHMgPD0gYml0cykgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IGxhc3RfYml0czsKICAgICAgICAgICAgICAgICAgYml0cyAtPSBsYXN0X2JpdHM7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmJhY2sgKz0gbGFzdF9iaXRzOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaG9sZCA+Pj49IGhlcmVfYml0czsKICAgICAgICAgICAgICAgIGJpdHMgLT0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgc3RhdGUuYmFjayArPSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICBzdGF0ZS5sZW5ndGggPSBoZXJlX3ZhbDsKICAgICAgICAgICAgICAgIGlmIChoZXJlX29wID09PSAwKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBMSVQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKGhlcmVfb3AgJiAzMikgewogICAgICAgICAgICAgICAgICBzdGF0ZS5iYWNrID0gLTE7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBUWVBFOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChoZXJlX29wICYgNjQpIHsKICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBsaXRlcmFsL2xlbmd0aCBjb2RlIjsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5leHRyYSA9IGhlcmVfb3AgJiAxNTsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBMRU5FWFQ7CiAgICAgICAgICAgICAgY2FzZSBMRU5FWFQ6CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuZXh0cmEpIHsKICAgICAgICAgICAgICAgICAgbiA9IHN0YXRlLmV4dHJhOwogICAgICAgICAgICAgICAgICB3aGlsZSAoYml0cyA8IG4pIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIHN0YXRlLmxlbmd0aCArPSBob2xkICYgKDEgPDwgc3RhdGUuZXh0cmEpIC0gMTsKICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IHN0YXRlLmV4dHJhOwogICAgICAgICAgICAgICAgICBiaXRzIC09IHN0YXRlLmV4dHJhOwogICAgICAgICAgICAgICAgICBzdGF0ZS5iYWNrICs9IHN0YXRlLmV4dHJhOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUud2FzID0gc3RhdGUubGVuZ3RoOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IERJU1Q7CiAgICAgICAgICAgICAgY2FzZSBESVNUOgogICAgICAgICAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICAgICAgICAgIGhlcmUgPSBzdGF0ZS5kaXN0Y29kZVtob2xkICYgKDEgPDwgc3RhdGUuZGlzdGJpdHMpIC0gMV07CiAgICAgICAgICAgICAgICAgIGhlcmVfYml0cyA9IGhlcmUgPj4+IDI0OwogICAgICAgICAgICAgICAgICBoZXJlX29wID0gaGVyZSA+Pj4gMTYgJiAyNTU7CiAgICAgICAgICAgICAgICAgIGhlcmVfdmFsID0gaGVyZSAmIDY1NTM1OwogICAgICAgICAgICAgICAgICBpZiAoaGVyZV9iaXRzIDw9IGJpdHMpIHsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoKGhlcmVfb3AgJiAyNDApID09PSAwKSB7CiAgICAgICAgICAgICAgICAgIGxhc3RfYml0cyA9IGhlcmVfYml0czsKICAgICAgICAgICAgICAgICAgbGFzdF9vcCA9IGhlcmVfb3A7CiAgICAgICAgICAgICAgICAgIGxhc3RfdmFsID0gaGVyZV92YWw7CiAgICAgICAgICAgICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgICAgICAgICAgIGhlcmUgPSBzdGF0ZS5kaXN0Y29kZVtsYXN0X3ZhbCArICgoaG9sZCAmICgxIDw8IGxhc3RfYml0cyArIGxhc3Rfb3ApIC0gMSkgPj4gbGFzdF9iaXRzKV07CiAgICAgICAgICAgICAgICAgICAgaGVyZV9iaXRzID0gaGVyZSA+Pj4gMjQ7CiAgICAgICAgICAgICAgICAgICAgaGVyZV9vcCA9IGhlcmUgPj4+IDE2ICYgMjU1OwogICAgICAgICAgICAgICAgICAgIGhlcmVfdmFsID0gaGVyZSAmIDY1NTM1OwogICAgICAgICAgICAgICAgICAgIGlmIChsYXN0X2JpdHMgKyBoZXJlX2JpdHMgPD0gYml0cykgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IGxhc3RfYml0czsKICAgICAgICAgICAgICAgICAgYml0cyAtPSBsYXN0X2JpdHM7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmJhY2sgKz0gbGFzdF9iaXRzOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaG9sZCA+Pj49IGhlcmVfYml0czsKICAgICAgICAgICAgICAgIGJpdHMgLT0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgc3RhdGUuYmFjayArPSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICBpZiAoaGVyZV9vcCAmIDY0KSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgZGlzdGFuY2UgY29kZSI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUub2Zmc2V0ID0gaGVyZV92YWw7CiAgICAgICAgICAgICAgICBzdGF0ZS5leHRyYSA9IGhlcmVfb3AgJiAxNTsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBESVNURVhUOwogICAgICAgICAgICAgIGNhc2UgRElTVEVYVDoKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5leHRyYSkgewogICAgICAgICAgICAgICAgICBuID0gc3RhdGUuZXh0cmE7CiAgICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgbikgewogICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgc3RhdGUub2Zmc2V0ICs9IGhvbGQgJiAoMSA8PCBzdGF0ZS5leHRyYSkgLSAxOwogICAgICAgICAgICAgICAgICBob2xkID4+Pj0gc3RhdGUuZXh0cmE7CiAgICAgICAgICAgICAgICAgIGJpdHMgLT0gc3RhdGUuZXh0cmE7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmJhY2sgKz0gc3RhdGUuZXh0cmE7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUub2Zmc2V0ID4gc3RhdGUuZG1heCkgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGRpc3RhbmNlIHRvbyBmYXIgYmFjayI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IE1BVENIOwogICAgICAgICAgICAgIGNhc2UgTUFUQ0g6CiAgICAgICAgICAgICAgICBpZiAobGVmdCA9PT0gMCkgewogICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb3B5ID0gX291dCAtIGxlZnQ7CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUub2Zmc2V0ID4gY29weSkgewogICAgICAgICAgICAgICAgICBjb3B5ID0gc3RhdGUub2Zmc2V0IC0gY29weTsKICAgICAgICAgICAgICAgICAgaWYgKGNvcHkgPiBzdGF0ZS53aGF2ZSkgewogICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5zYW5lKSB7CiAgICAgICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGRpc3RhbmNlIHRvbyBmYXIgYmFjayI7CiAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChjb3B5ID4gc3RhdGUud25leHQpIHsKICAgICAgICAgICAgICAgICAgICBjb3B5IC09IHN0YXRlLnduZXh0OwogICAgICAgICAgICAgICAgICAgIGZyb20gPSBzdGF0ZS53c2l6ZSAtIGNvcHk7CiAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgZnJvbSA9IHN0YXRlLnduZXh0IC0gY29weTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoY29weSA+IHN0YXRlLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgIGNvcHkgPSBzdGF0ZS5sZW5ndGg7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgZnJvbV9zb3VyY2UgPSBzdGF0ZS53aW5kb3c7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICBmcm9tX3NvdXJjZSA9IG91dHB1dDsKICAgICAgICAgICAgICAgICAgZnJvbSA9IHB1dCAtIHN0YXRlLm9mZnNldDsKICAgICAgICAgICAgICAgICAgY29weSA9IHN0YXRlLmxlbmd0aDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChjb3B5ID4gbGVmdCkgewogICAgICAgICAgICAgICAgICBjb3B5ID0gbGVmdDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGxlZnQgLT0gY29weTsKICAgICAgICAgICAgICAgIHN0YXRlLmxlbmd0aCAtPSBjb3B5OwogICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICBvdXRwdXRbcHV0KytdID0gZnJvbV9zb3VyY2VbZnJvbSsrXTsKICAgICAgICAgICAgICAgIH0gd2hpbGUgKC0tY29weSk7CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBMRU47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIExJVDoKICAgICAgICAgICAgICAgIGlmIChsZWZ0ID09PSAwKSB7CiAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIG91dHB1dFtwdXQrK10gPSBzdGF0ZS5sZW5ndGg7CiAgICAgICAgICAgICAgICBsZWZ0LS07CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gTEVOOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSBDSEVDSzoKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS53cmFwKSB7CiAgICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMzIpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgaG9sZCB8PSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIF9vdXQgLT0gbGVmdDsKICAgICAgICAgICAgICAgICAgc3RybS50b3RhbF9vdXQgKz0gX291dDsKICAgICAgICAgICAgICAgICAgc3RhdGUudG90YWwgKz0gX291dDsKICAgICAgICAgICAgICAgICAgaWYgKF9vdXQpIHsKICAgICAgICAgICAgICAgICAgICBzdHJtLmFkbGVyID0gc3RhdGUuY2hlY2sgPSBzdGF0ZS5mbGFncyA/IGNyYzMyMihzdGF0ZS5jaGVjaywgb3V0cHV0LCBfb3V0LCBwdXQgLSBfb3V0KSA6IGFkbGVyMzIoc3RhdGUuY2hlY2ssIG91dHB1dCwgX291dCwgcHV0IC0gX291dCk7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgX291dCA9IGxlZnQ7CiAgICAgICAgICAgICAgICAgIGlmICgoc3RhdGUuZmxhZ3MgPyBob2xkIDogenN3YXAzMihob2xkKSkgIT09IHN0YXRlLmNoZWNrKSB7CiAgICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW5jb3JyZWN0IGRhdGEgY2hlY2siOwogICAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICAgIGJpdHMgPSAwOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IExFTkdUSDsKICAgICAgICAgICAgICBjYXNlIExFTkdUSDoKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS53cmFwICYmIHN0YXRlLmZsYWdzKSB7CiAgICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMzIpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChob2xkICE9PSAoc3RhdGUudG90YWwgJiA0Mjk0OTY3Mjk1KSkgewogICAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImluY29ycmVjdCBsZW5ndGggY2hlY2siOwogICAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICAgIGJpdHMgPSAwOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IERPTkU7CiAgICAgICAgICAgICAgY2FzZSBET05FOgogICAgICAgICAgICAgICAgcmV0ID0gWl9TVFJFQU1fRU5EOwogICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgIGNhc2UgQkFEOgogICAgICAgICAgICAgICAgcmV0ID0gWl9EQVRBX0VSUk9SOwogICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgIGNhc2UgTUVNOgogICAgICAgICAgICAgICAgcmV0dXJuIFpfTUVNX0VSUk9SOwogICAgICAgICAgICAgIGNhc2UgU1lOQzoKICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgc3RybS5uZXh0X291dCA9IHB1dDsKICAgICAgICBzdHJtLmF2YWlsX291dCA9IGxlZnQ7CiAgICAgICAgc3RybS5uZXh0X2luID0gbmV4dDsKICAgICAgICBzdHJtLmF2YWlsX2luID0gaGF2ZTsKICAgICAgICBzdGF0ZS5ob2xkID0gaG9sZDsKICAgICAgICBzdGF0ZS5iaXRzID0gYml0czsKICAgICAgICBpZiAoc3RhdGUud3NpemUgfHwgX291dCAhPT0gc3RybS5hdmFpbF9vdXQgJiYgc3RhdGUubW9kZSA8IEJBRCAmJiAoc3RhdGUubW9kZSA8IENIRUNLIHx8IGZsdXNoICE9PSBaX0ZJTklTSCkpIHsKICAgICAgICAgIGlmICh1cGRhdGV3aW5kb3coc3RybSwgc3RybS5vdXRwdXQsIHN0cm0ubmV4dF9vdXQsIF9vdXQgLSBzdHJtLmF2YWlsX291dCkpIHsKICAgICAgICAgICAgc3Rhd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fQogICAgICAgIHZhciBzdGF0ZSA9IHN0cm0uc3RhdGU7CiAgICAgICAgaWYgKHN0YXRlLndpbmRvdykgewogICAgICAgICAgc3RhdGUud2luZG93ID0gbnVsbDsKICAgICAgICB9CiAgICAgICAgc3RybS5zdGF0ZSA9IG51bGw7CiAgICAgICAgcmV0dXJuIFpfT0s7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gaW5mbGF0ZUdldEhlYWRlcihzdHJtLCBoZWFkKSB7CiAgICAgICAgdmFyIHN0YXRlOwogICAgICAgIGlmICghc3RybSB8fCAhc3RybS5zdGF0ZSkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgIH0KICAgICAgICBzdGF0ZSA9IHN0cm0uc3RhdGU7CiAgICAgICAgaWYgKChzdGF0ZS53cmFwICYgMikgPT09IDApIHsKICAgICAgICAgIHJldHVybiBaX1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgc3RhdGUuaGVhZCA9IGhlYWQ7CiAgICAgICAgaGVhZC5kb25lID0gZmFsc2U7CiAgICAgICAgcmV0dXJuIFpfT0s7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gaW5mbGF0ZVNldERpY3Rpb25hcnkoc3RybSwgZGljdGlvbmFyeSkgewogICAgICAgIHZhciBkaWN0TGVuZ3RoID0gZGljdGlvbmFyeS5sZW5ndGg7CiAgICAgICAgdmFyIHN0YXRlOwogICAgICAgIHZhciBkaWN0aWQ7CiAgICAgICAgdmFyIHJldDsKICAgICAgICBpZiAoIXN0cm0gfHwgIXN0cm0uc3RhdGUpIHsKICAgICAgICAgIHJldHVybiBaX1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgc3RhdGUgPSBzdHJtLnN0YXRlOwogICAgICAgIGlmIChzdGF0ZS53cmFwICE9PSAwICYmIHN0YXRlLm1vZGUgIT09IERJQ1QpIHsKICAgICAgICAgIHJldHVybiBaX1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgaWYgKHN0YXRlLm1vZGUgPT09IERJQ1QpIHsKICAgICAgICAgIGRpY3RpZCA9IDE7CiAgICAgICAgICBkaWN0aWQgPSBhZGxlcjMyKGRpY3RpZCwgZGljdGlvbmFyeSwgZGljdExlbmd0aCwgMCk7CiAgICAgICAgICBpZiAoZGljdGlkICE9PSBzdGF0ZS5jaGVjaykgewogICAgICAgICAgICByZXR1cm4gWl9EQVRBX0VSUk9SOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXQgPSB1cGRhdGV3aW5kb3coc3RybSwgZGljdGlvbmFyeSwgZGljdExlbmd0aCwgZGljdExlbmd0aCk7CiAgICAgICAgaWYgKHJldCkgewogICAgICAgICAgc3RhdGUubW9kZSA9IE1FTTsKICAgICAgICAgIHJldHVybiBaX01FTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgc3RhdGUuaGF2ZWRpY3QgPSAxOwogICAgICAgIHJldHVybiBaX09LOwogICAgICB9CiAgICAgIGV4cG9ydHMuaW5mbGF0ZVJlc2V0ID0gaW5mbGF0ZVJlc2V0OwogICAgICBleHBvcnRzLmluZmxhdGVSZXNldDIgPSBpbmZsYXRlUmVzZXQyOwogICAgICBleHBvcnRzLmluZmxhdGVSZXNldEtlZXAgPSBpbmZsYXRlUmVzZXRLZWVwOwogICAgICBleHBvcnRzLmluZmxhdGVJbml0ID0gaW5mbGF0ZUluaXQ7CiAgICAgIGV4cG9ydHMuaW5mbGF0ZUluaXQyID0gaW5mbGF0ZUluaXQyOwogICAgICBleHBvcnRzLmluZmxhdGUgPSBpbmZsYXRlOwogICAgICBleHBvcnRzLmluZmxhdGVFbmQgPSBpbmZsYXRlRW5kOwogICAgICBleHBvcnRzLmluZmxhdGVHZXRIZWFkZXIgPSBpbmZsYXRlR2V0SGVhZGVyOwogICAgICBleHBvcnRzLmluZmxhdGVTZXREaWN0aW9uYXJ5ID0gaW5mbGF0ZVNldERpY3Rpb25hcnk7CiAgICAgIGV4cG9ydHMua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LAogICAgICAgIFpfUkxFOiAzLAogICAgICAgIFpfRklYRUQ6IDQsCiAgICAgICAgWl9ERUZBVUxUX1NUUkFURUdZOiAwLAogICAgICAgIFpfQklOQVJZOiAwLAogICAgICAgIFpfVEVYVDogMSwKICAgICAgICBaX1VOS05PV046IDIsCiAgICAgICAgWl9ERUZMQVRFRDogOAogICAgICB9OwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLnBucG0vcGFrb0AxLjAuMTEvbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvZ3poZWFkZXIuanMKICB2YXIgcmVxdWlyZV9nemhlYWRlciA9IF9fY29tbW9uSlMoewogICAgIm5vZGVfbW9kdWxlcy8ucG5wbS9wYWtvQDEuMC4xMS9ub2RlX21vZHVsZXMvcGFrby9saWIvemxpYi9nemhlYWRlci5qcyIoZXhwb3J0cywgbW9kdWxlKSB7CiAgICAgIGluaXRfYnVmZmVyX3NoaW0oKTsKICAgICAgInVzZSBzdHJpY3QiOwogICAgICBmdW5jdGlvbiBHWmhlYWRlcigpIHsKICAgICAgICB0aGlzLnRleHQgPSAwOwogICAgICAgIHRoaXMudGltZSA9IDA7CiAgICAgICAgdGhpcy54ZmxhZ3MgPSAwOwogICAgICAgIHRoaXMub3MgPSAwOwogICAgICAgIHRoaXMuZXh0cmEgPSBudWxsOwogICAgICAgIHRoaXMuZXh0cmFfbGVuID0gMDsKICAgICAgICB0aGlzLm5hbWUgPSAiIjsKICAgICAgICB0aGlzLmNvbW1lbnQgPSAiIjsKICAgICAgICB0aGlzLmhjcmMgPSAwOwogICAgICAgIHRoaXMuZG9uZSA9IGZhbHNlOwogICAgICB9CiAgICAgIG1vZHVsZS5leHBvcnRzID0gR1poZWFkZXI7CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8ucG5wbS9wYWtvQDEuMC4xMS9ub2RlX21vZHVsZXMvcGFrby9saWIvaW5mbGF0ZS5qcwogIHZhciByZXF1aXJlX2luZmxhdGUyID0gX19jb21tb25KUyh7CiAgICAibm9kZV9tb2R1bGVzLy5wbnBtL3Bha29AMS4wLjExL25vZGVfbW9kdWxlcy9wYWtvL2xpYi9pbmZsYXRlLmpzIihleHBvcnRzKSB7CiAgICAgIGluaXRfYnVmZmVyX3NoaW0oKTsKICAgICAgInVzZSBzdHJpY3QiOwogICAgICB2YXIgemxpYl9pbmZsYXRlID0gcmVxdWlyZV9pbmZsYXRlKCk7CiAgICAgIHZhciB1dGlscyA9IHJlcXVpcmVfY29tbW9uMigpOwogICAgICB2YXIgc3RyaW5ncyA9IHJlcXVpcmVfc3RyaW5ncygpOwogICAgICB2YXIgYyA9IHJlcXVpcmVfY29uc3RhbnRzKCk7CiAgICAgIHZhciBtc2cgPSByZXF1aXJlX21lc3NhZ2VzMigpOwogICAgICB2YXIgWlN0cmVhbSA9IHJlcXVpcmVfenN0cmVhbSgpOwogICAgICB2YXIgR1poZWFkZXIgPSByZXF1aXJlX2d6aGVhZGVyKCk7CiAgICAgIHZhciB0b1N0cmluZyA9IE9iamVjdC5wcm90b3R5cGUudG9TdHJpbmc7CiAgICAgIGZ1bmN0aW9uIEluZmxhdGUyKG9wdGlvbnMpIHsKICAgICAgICBpZiAoISh0aGlzIGluc3RhbmNlb2YgSW5mbGF0ZTIpKQogICAgICAgICAgcmV0dXJuIG5ldyBJbmZsYXRlMihvcHRpb25zKTsKICAgICAgICB0aGlzLm9wdGlvbnMgPSB1dGlscy5hc3NpZ24oewogICAgICAgICAgY2h1bmtTaXplOiAxNjM4NCwKICAgICAgICAgIHdpbmRvd0JpdHM6IDAsCiAgICAgICAgICB0bzogIiIKICAgICAgICB9LCBvcHRpb25zIHx8IHt9KTsKICAgICAgICB2YXIgb3B0ID0gdGhpcy5vcHRpb25zOwogICAgICAgIGlmIChvcHQucmF3ICYmIG9wdC53aW5kb3dCaXRzID49IDAgJiYgb3B0LndpbmRvd0JpdHMgPCAxNikgewogICAgICAgICAgb3B0LndpbmRvd0JpdHMgPSAtb3B0LndpbmRvd0JpdHM7CiAgICAgICAgICBpZiAob3B0LndpbmRvd0JpdHMgPT09IDApIHsKICAgICAgICAgICAgb3B0LndpbmRvd0JpdHMgPSAtMTU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChvcHQud2luZG93Qml0cyA+PSAwICYmIG9wdC53aW5kb3dCaXRzIDwgMTYgJiYgIShvcHRpb25zICYmIG9wdGlvbnMud2luZG93Qml0cykpIHsKICAgICAgICAgIG9wdC53aW5kb3dCaXRzICs9IDMyOwogICAgICAgIH0KICAgICAgICBpZiAob3B0LndpbmRvd0JpdHMgPiAxNSAmJiBvcHQud2luZG93Qml0cyA8IDQ4KSB7CiAgICAgICAgICBpZiAoKG9wdC53aW5kb3dCaXRzICYgMTUpID09PSAwKSB7CiAgICAgICAgICAgIG9wdC53aW5kb3dCaXRzIHw9IDE1OwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICB0aGlzLmVyciA9IDA7CiAgICAgICAgdGhpcy5tc2cgPSAiIjsKICAgICAgICB0aGlzLmVuZGVkID0gZmFsc2U7CiAgICAgICAgdGhpcy5jaHVua3MgPSBbXTsKICAgICAgICB0aGlzLnN0cm0gPSBuZXcgWlN0cmVhbSgpOwogICAgICAgIHRoaXMuc3RybS5hdmFpbF9vdXQgPSAwOwogICAgICAgIHZhciBzdGF0dXMgPSB6bGliX2luZmxhdGUuaW5mbGF0ZUluaXQyKHRoaXMuc3RybSwgb3B0LndpbmRvd0JpdHMpOwogICAgICAgIGlmIChzdGF0dXMgIT09IGMuWl9PSykgewogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKG1zZ1tzdGF0dXNdKTsKICAgICAgICB9CiAgICAgICAgdGhpcy5oZWFkZXIgPSBuZXcgR1poZWFkZXIoKTsKICAgICAgICB6bGliX2luZmxhdGUuaW5mbGF0ZUdldEhlYWRlcih0aGlzLnN0cm0sIHRoaXMuaGVhZGVyKTsKICAgICAgICBpZiAob3B0LmRpY3Rpb25hcnkpIHsKICAg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0JVRl9FUlJPUiAmJiBhbGxvd0J1ZkVycm9yID09PSB0cnVlKSB7CiAgICAgICAgICAgIHN0YXR1cyA9IGMuWl9PSzsKICAgICAgICAgICAgYWxsb3dCdWZFcnJvciA9IGZhbHNlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHN0YXR1cyAhPT0gYy5aX1NUUkVBTV9FTkQgJiYgc3RhdHVzICE9PSBjLlpfT0spIHsKICAgICAgICAgICAgdGhpcy5vbkVuZChzdGF0dXMpOwogICAgICAgICAgICB0aGlzLmVuZGVkID0gdHJ1ZTsKICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHN0cm0ubmV4dF9vdXQpIHsKICAgICAgICAgICAgaWYgKHN0cm0uYXZhaWxfb3V0ID09PSAwIHx8IHN0YXR1cyA9PT0gYy5aX1NUUkVBTV9FTkQgfHwgc3RybS5hdmFpbF9pbiA9PT0gMCAmJiAoX21vZGUgPT09IGMuWl9GSU5JU0ggfHwgX21vZGUgPT09IGMuWl9TWU5DX0ZMVVNIKSkgewogICAgICAgICAgICAgIGlmICh0aGlzLm9wdGlvbnMudG8gPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICBuZXh0X291dF91dGY4ID0gc3RyaW5ncy51dGY4Ym9yZGVyKHN0cm0ub3V0cHV0LCBzdHJtLm5leHRfb3V0KTsKICAgICAgICAgICAgICAgIHRhaWwgPSBzdHJtLm5leHRfb3V0IC0gbmV4dF9vdXRfdXRmODsKICAgICAgICAgICAgICAgIHV0ZjhzdHIgPSBzdHJpbmdzLmJ1ZjJzdHJpbmcoc3RybS5vdXRwdXQsIG5leHRfb3V0X3V0ZjgpOwogICAgICAgICAgICAgICAgc3RybS5uZXh0X291dCA9IHRhaWw7CiAgICAgICAgICAgICAgICBzdHJtLmF2YWlsX291dCA9IGNodW5rU2l6ZSAtIHRhaWw7CiAgICAgICAgICAgICAgICBpZiAodGFpbCkgewogICAgICAgICAgICAgICAgICB1dGlscy5hcnJheVNldChzdHJtLm91dHB1dCwgc3RybS5vdXRwdXQsIG5leHRfb3V0X3V0ZjgsIHRhaWwsIDApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgdGhpcy5vbkRhdGEodXRmOHN0cik7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHRoaXMub25EYXRhKHV0aWxzLnNocmlua0J1ZihzdHJtLm91dHB1dCwgc3RybS5uZXh0X291dCkpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKHN0cm0uYXZhaWxfaW4gPT09IDAgJiYgc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgYWxsb3dCdWZFcnJvciA9IHRydWU7CiAgICAgICAgICB9CiAgICAgICAgfSB3aGlsZSAoKHN0cm0uYXZhaWxfaW4gPiAwIHx8IHN0cm0uYXZhaWxfb3V0ID09PSAwKSAmJiBzdGF0dXMgIT09IGMuWl9TVFJFQU1fRU5EKTsKICAgICAgICBpZiAoc3RhdHVzID09PSBjLlpfU1RSRUFNX0VORCkgewogICAgICAgICAgX21vZGUgPSBjLlpfRklOSVNIOwogICAgICAgIH0KICAgICAgICBpZiAoX21vZGUgPT09IGMuWl9GSU5JU0gpIHsKICAgICAgICAgIHN0YXR1cyA9IHpsaWJfaW5mbGF0ZS5pbmZsYXRlRW5kKHRoaXMuc3RybSk7CiAgICAgICAgICB0aGlzLm9uRW5kKHN0YXR1cyk7CiAgICAgICAgICB0aGlzLmVuZGVkID0gdHJ1ZTsKICAgICAgICAgIHJldHVybiBzdGF0dXMgPT09IGMuWl9PSzsKICAgICAgICB9CiAgICAgICAgaWYgKF9tb2RlID09PSBjLlpfU1lOQ19GTFVTSCkgewogICAgICAgICAgdGhpcy5vbkVuZChjLlpfT0spOwogICAgICAgICAgc3RybS5hdmFpbF9vdXQgPSAwOwogICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgfQogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9OwogICAgICBJbmZsYXRlMi5wcm90b3R5cGUub25EYXRhID0gZnVuY3Rpb24oY2h1bmspIHsKICAgICAgICB0aGlzLmNodW5rcy5wdXNoKGNodW5rKTsKICAgICAgfTsKICAgICAgSW5mbGF0ZTIucHJvdG90eXBlLm9uRW5kID0gZnVuY3Rpb24oc3RhdHVzKSB7CiAgICAgICAgaWYgKHN0YXR1cyA9PT0gYy5aX09LKSB7CiAgICAgICAgICBpZiAodGhpcy5vcHRpb25zLnRvID09PSAic3RyaW5nIikgewogICAgICAgICAgICB0aGlzLnJlc3VsdCA9IHRoaXMuY2h1bmtzLmpvaW4oIiIpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgdGhpcy5yZXN1bHQgPSB1dGlscy5mbGF0dGVuQ2h1bmtzKHRoaXMuY2h1bmtzKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgdGhpcy5jaHVua3MgPSBbXTsKICAgICAgICB0aGlzLmVyciA9IHN0YXR1czsKICAgICAgICB0aGlzLm1zZyA9IHRoaXMuc3RybS5tc2c7CiAgICAgIH07CiAgICAgIGZ1bmN0aW9uIGluZmxhdGUoaW5wdXQsIG9wdGlvbnMpIHsKICAgICAgICB2YXIgaW5mbGF0b3IgPSBuZXcgSW5mbGF0ZTIob3B0aW9ucyk7CiAgICAgICAgaW5mbGF0b3IucHVzaChpbnB1dCwgdHJ1ZSk7CiAgICAgICAgaWYgKGluZmxhdG9yLmVycikgewogICAgICAgICAgdGhyb3cgaW5mbGF0b3IubXNnIHx8IG1zZ1tpbmZsYXRvci5lcnJdOwogICAgICAgIH0KICAgICAgICByZXR1cm4gaW5mbGF0b3IucmVzdWx0OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGluZmxhdGVSYXcoaW5wdXQsIG9wdGlvbnMpIHsKICAgICAgICBvcHRpb25zID0gb3B0aW9ucyB8fCB7fTsKICAgICAgICBvcHRpb25zLnJhdy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SlMoewogICAgIm5vZGVfbW9kdWxlcy8ucG5wbS9idWZmZXItY3JjMzJAMC4yLjEzL25vZGVfbW9kdWxlcy9idWZmZXItY3JjMzIvaW5kZXguanMiKGV4cG9ydHMsIG1vZHVsZSkgewogICAgICBpbml0X2J1ZmZlcl9zaGltKCk7CiAgICAgIHZhciBCdWZmZXI4ID0gcmVxdWlyZV9idWZmZXIoKS5CdWZmZXI7CiAgICAgIHZhciBDUkNfVEFCTEUgPSBbCiAgICAgICAgMCwKICAgICAgICAxOTk2OTU5ODk0LAogICAgICAgIDM5OTM5MTk3ODgsCiAgICAgICAgMjU2NzUyNDc5NCwKICAgICAgICAxMjQ2MzQxMzcsCiAgICAgICAgMTg4NjA1NzYxNSwKICAgICAgICAzOTE1NjIxNjg1LAogICAgICAgIDI2NTczOTIwMzUsCiAgICAgICAgMjQ5MjY4Mjc0LAogICAgICAgIDIwNDQ1MDgzMjQsCiAgICAgICAgMzc3MjExNTIzMCwKICAgICAgICAyNTQ3MTc3ODY0LAogICAgICAgIDE2Mjk0MTk5NSwKICAgICAgICAyMTI1NTYxMDIxLAogICAgICAgIDM4ODc2MDcwNDcsCiAgICAgICAgMjQyODQ0NDA0OSwKICAgICAgICA0OTg1MzY1NDgsCiAgICAgICAgMTc4OTkyNzY2NiwKICAgICAgICA0MDg5MDE2NjQ4LAogICAgICAgIDIyMjcwNjEyMTQsCiAgICAgICAgNDUwNTQ4ODYxLAogICAgICAgIDE4NDMyNTg2MDMsCiAgICAgICAgNDEwNzU4MDc1MywKICAgICAgICAyMjExNjc3NjM5LAogICAgICAgIDMyNTg4Mzk5MCwKICAgICAgICAxNjg0Nzc3MTUyLAogICAgICAgIDQyNTExMjIwNDIsCiAgICAgICAgMjMyMTkyNjYzNiwKICAgICAgICAzMzU2MzM0ODcsCiAgICAgICAgMTY2MTM2NTQ2NSwKICAgICAgICA0MTk1MzAyNzU1LAogICAgICAgIDIzNjYxMTUzMTcsCiAgICAgICAgOTk3MDczMDk2LAogICAgICAgIDEyODE5NTM4ODYsCiAgICAgICAgMzU3OTg1NTMzMiwKICAgICAgICAyNzI0Njg4MjQyLAogICAgICAgIDEwMDY4ODgxNDUsCiAgICAgICAgMTI1ODYwNzY4NywKICAgICAgICAzNTI0MTAxNjI5LAogICAgICAgIDI3Njg5NDI0NDMsCiAgICAgICAgOTAxMDk3NzIyLAogICAgICAgIDExMTkwMDA2ODQsCiAgICAgICAgMzY4NjUxNzIwNiwKICAgICAgICAyODk4MDY1NzI4LAogICAgICAgIDg1MzA0NDQ1MSwKICAgICAgICAxMTcyMjY2MTAxLAogICAgICAgIDM3MDUwMTU3NTksCiAgICAgICAgMjg4MjYxNjY2NSwKICAgICAgICA2NTE3Njc5ODAsCiAgICAgICAgMTM3MzUwMzU0NiwKICAgICAgICAzMzY5NTU0MzA0LAogICAgICAgIDMyMTgxMDQ1OTgsCiAgICAgICAgNTY1NTA3MjUzLAogICAgICAgIDE0NTQ2MjE3MzEsCiAgICAgICAgMzQ4NTExMTcwNSwKICAgICAgICAzMDk5NDM2MzAzLAogICAgICAgIDY3MTI2Njk3NCwKICAgICAgICAxNTk0MTk4MDI0LAogICAgICAgIDMzMjI3MzA5MzAsCiAgICAgICAgMjk3MDM0NzgxMiwKICAgICAgICA3OTU4MzU1MjcsCiAgICAgICAgMTQ4MzIzMDIyNSwKICAgICAgICAzMjQ0MzY3Mjc1LAogICAgICAgIDMwNjAxNDk1NjUsCiAgICAgICAgMTk5NDE0NjE5MiwKICAgICAgICAzMTE1ODUzNCwKICAgICAgICAyNTYzOTA3NzcyLAogICAgICAgIDQwMjM3MTc5MzAsCiAgICAgICAgMTkwNzQ1OTQ2NSwKICAgICAgICAxMTI2MzcyMTUsCiAgICAgICAgMjY4MDE1MzI1MywKICAgICAgICAzOTA0NDI3MDU5LAogICAgICAgIDIwMTM3NzYyOTAsCiAgICAgICAgMjUxNzIyMDM2LAogICAgICAgIDI1MTcyMTUzNzQsCiAgICAgICAgMzc3NTgzMDA0MCwKICAgICAgICAyMTM3NjU2NzYzLAogICAgICAgIDE0MTM3NjgxMywKICAgICAgICAyNDM5Mjc3NzE5LAogICAgICAgIDM4NjUyNzEyOTcsCiAgICAgICAgMTgwMjE5NTQ0NCwKICAgICAgICA0NzY4NjQ4NjYsCiAgICAgICAgMjIzODAwMTM2OCwKICAgICAgICA0MDY2NTA4ODc4LAogICAgICAgIDE4MTIzNzA5MjUsCiAgICAgICAgNDUzMDkyNzMxLAogICAgICAgIDIxODE2MjUwMjUsCiAgICAgICAgNDExMTQ1MTIyMywKICAgICAgICAxNzA2MDg4OTAyLAogICAgICAgIDMxNDA0MjcwNCwKICAgICAgICAyMzQ0NTMyMjAyLAogICAgICAgIDQyNDAwMTc1MzIsCiAgICAgICAgMTY1ODY1ODI3MSwKICAgICAgICAzNjY2MTk5NzcsCiAgICAgICAgMjM2MjY3MDMyMywKICAgICAgICA0MjI0OTk0NDA1LAogICAgICAgIDEzMDM1MzU5NjAsCiAgICAgICAgOTg0OTYxNDg2LAogICAgICAgIDI3NDcwMDcwOTIsCiAgICAgICAgMzU2OTAzNzUzOCwKICAgICAgICAxMjU2MTcwODE3LAogICAgICAgIDEwMzc2MDQzMTEsCiAgICAgICAgMjc2NTIxMDczMywKICAgICAgICAzNTU0MDc5OTk1LAogICAgICAgIDExMzEwMTQ1MDYsCiAgICAgICAgODc5Njc5OTk2LAogICAgICAgIDI5MDkyNDM0NjIsCiAgICAgICAgMzY2Mzc3MTg1NiwKICAgICAgICAxMTQxMTI0NDY3LAogICAgICAgIDg1NTg0MjI3NywKICAgICAgICAyODUyODAxNjMxLAogICAgICAgIDM3MDg2NDg2NDksCiAgICAgICAgMTM0MjUzMzk0OCwKICAgICAgICA2NTQ0NTkzMDYsCiAgICAgICAgMzE4ODM5NjA0OCwKICAgICAgICAzMzczMDE1MTc0LAogICAgICAgIDE0NjY0Nzk5MDksCiAgICAgICAgNTQ0MTc5NjM1LAogICAgICAgIDMxMTA1MjM5MTMsCiAgICAgICAgMzQ2MjUyMjAxNSwKICAgICAgICAxNTkxNjcxMDU0LAogICAgICAgIDcwMjEzODc3NiwKICAgICAgICAyOTY2NDYwNDUwLAogICAgICAgIDMzNTI3OTk0MTIsCiAgICAgICAgMTUwNDkxODgwNywKICAgICAgICA3ODM1NTE4NzMsCiAgICAgICAgMzA4MjY0MDQ0MywKICAgICAgICAzMjMzNDQyOTg5LAogICAgICAgIDM5ODgyOTIzODQsCiAgICAgICAgMjU5NjI1NDY0NiwKICAgICAgICA2MjMxNzA2OCwKICAgICAgICAxOTU3ODEwODQyLAogICAgICAgIDM5Mzk4NDU5NDUsCiAgICAgICAgMjY0NzgxNjExMSwKICAgICAgICA4MTQ3MDk5NywKICAgICAgICAxOTQzODAzNTIzLAogICAgICAgIDM4MTQ5MTg5MzAsCiAgICAgICAgMjQ4OTU5NjgwNCwKICAgICAgICAyMjUyNzQ0MzAsCiAgICAgICAgMjA1Mzc5MDM3NiwKICAgICAgICAzODI2MTc1NzU1LAogICAgICAgIDI0NjY5MDYwMTMsCiAgICAgICAgMTY3ODE2NzQzLAogICAgICAgIDIwOTc2NTEzNzcsCiAgICAgICAgNDAyNzU1MjU4MCwKICAgICAgICAyMjY1NDkwMzg2LAogICAgICAgIDUwMzQ0NDA3MiwKICAgICAgICAxNzYyMDUwODE0LAogICAgICAgIDQxNTA0MTcyNDUsCiAgICAgICAgMjE1NDEyOTM1NSwKICAgICAgICA0MjY1MjIyMjUsCiAgICAgICAgMTg1MjUwNzg3OSwKICAgICAgICA0Mjc1MzEzNTI2LAogICAgICAgIDIzMTIzMTc5MjAsCiAgICAgICAgMjgyNzUzNjI2LAogICAgICAgIDE3NDI1NTU4NTIsCiAgICAgICAgNDE4OTcwODE0MywKICAgICAgICAyMzk0ODc3OTQ1LAogICAgICAgIDM5NzkxNzc2MywKICAgICAgICAxNjIyMTgzNjM3LAogICAgICAgIDM2MDQzOTA4ODgsCiAgICAgICAgMjcxNDg2NjU1OCwKICAgICAgICA5NTM3Mjk3MzIsCiAgICAgICAgMTM0MDA3NjYyNiwKICAgICAgICAzNTE4NzE5OTg1LAogICAgICAgIDI3OTczNjA5OTksCiAgICAgICAgMTA2ODgyODM4MSwKICAgICAgICAxMjE5NjM4ODU5LAogICAgICAgIDM2MjQ3NDE4NTAsCiAgICAgICAgMjkzNjY3NTE0OCwKICAgICAgICA5MDYxODU0NjIsCiAgICAgICAgMTA5MDgxMjUxMiwKICAgICAgICAzNzQ3NjcyMDAzLAogICAgICAgIDI4MjUzNzk2NjksCiAgICAgICAgODI5MzI5MTM1LAogICAgICAgIDExODEzMzUxNjEsCiAgICAgICAgMzQxMjE3NzgwNCwKICAgICAgICAzMTYwODM0ODQyLAogICAgICAgIDYyODA4NTQwOCwKICAgICAgICAxMzgyNjA1MzY2LAogICAgICAgIDM0MjMzNjkxMDksCiAgICAgICAgMzEzODA3ODQ2NywKICAgICAgICA1NzA1NjIyMzMsCiAgICAgICAgMTQyNjQwMDgxNSwKICAgICAgICAzMzE3MzE2NTQyLAogICAgICAgIDI5OTg3MzM2MDgsCiAgICAgICAgNzMzMjM5OTU0LAogICAgICAgIDE1NTUyNjE5NTYsCiAgICAgICAgMzI2ODkzNTU5MSwKICAgICAgICAzMDUwMzYwNjI1LAogICAgICAgIDc1MjQ1OTQwMywKICAgICAgICAxNTQxMzIwMjIxLAogICAgICAgIDI2MDcwNzE5MjAsCiAgICAgICAgMzk2NTk3MzAzMCwKICAgICAgICAxOTY5OTIyOTcyLAogICAgICAgIDQwNzM1NDk4LAogICAgICAgIDI2MTc4MzcyMjUsCiAgICAgICAgMzk0MzU3NzE1MSwKICAgICAgICAxOTEzMDg3ODc3LAogICAgICAgIDgzOTA4MzcxLAogICAgICAgIDI1MTIzNDE2MzQsCiAgICAgICAgMzgwMzc0MDY5MiwKICAgICAgICAyMDc1MjA4NjIyLAogICAgICAgIDIxMzI2MTExMiwKICAgICAgICAyNDYzMjcyNjAzLAogICAgICAgIDM4NTU5OTAyODUsCiAgICAgICAgMjA5NDg1NDA3MSwKICAgICAgICAxOTg5NTg4ODEsCiAgICAgICAgMjI2MjAyOTAxMiwKICAgICAgICA0MDU3MjYwNjEwLAogICAgICAgIDE3NTkzNTk5OTIsCiAgICAgICAgNTM0NDE0MTkwLAogICAgICAgIDIxNzY3MTg1NDEsCiAgICAgICAgNDEzOTMyOTExNSwKICAgICAgICAxODczODM2MDAxLAogICAgICAgIDQxNDY2NDU2NywKICAgICAgICAyMjgyMjQ4OTM0LAogICAgICAgIDQyNzkyMDAzNjgsCiAgICAgICAgMTcxMTY4NDU1NCwKICAgICAgICAyODUyODExMTYsCiAgICAgICAgMjQwNTgwMTcyNywKICAgICAgICA0MTY3MjE2NzQ1LAogICAgICAgIDE2MzQ0Njc3OTUsCiAgICAgICAgMzc2MjI5NzAxLAogICAgICAgIDI2ODUwNjc4OTYsCiAgICAgICAgMzYwODAwNzQwNiwKICAgICAgICAxMzA4OTE4NjEyLAogICAgICAgIDk1NjU0MzkzOCwKICAgICAgICAyODA4NTU1MTA1LAogICAgICAgIDM0OTU5NTgyNjMsCiAgICAgICAgMTIzMTYzNjMwMSwKICAgICAgICAxMDQ3NDI3MDM1LAogICAgICAgIDI5MzI5NTk4MTgsCiAgICAgICAgMzY1NDcwMzgzNiwKICAgICAgICAxMDg4MzU5MjcwLAogICAgICAgIDkzNjkxOGUzLAogICAgICAgIDI4NDc3MTQ4OTksCiAgICAgICAgMzczNjgzNzgyOSwKICAgICAgICAxMjAyOTAwODYzLAogICAgICAgIDgxNzIzMzg5NywKICAgICAgICAzMTgzMzQyMTA4LAogICAgICAgIDM0MDEyMzcxMzAsCiAgICAgICAgMTQwNDI3NzU1MiwKICAgICAgICA2MTU4MTgxNTAsCiAgICAgICAgMzEzNDIwNzQ5MywKICAgICAgICAzNDUzNDIxMjAzLAogICAgICAgIDE0MjM4NTc0NDksCiAgICAgICAgNjAxNDUwNDMxLAogICAgICAgIDMwMDk4Mzc2MTQsCiAgICAgICAgMzI5NDcxMDQ1NiwKICAgICAgICAxNTY3MTAzN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W9kdWxlcy9vYmplY3QuZW50cmllcy1wb255ZmlsbC9lbnRyaWVzLmpzCiAgdmFyIHJlcXVpcmVfZW50cmllcyA9IF9fY29tbW9uSlMoewogICAgIm5vZGVfbW9kdWxlcy8ucG5wbS9vYmplY3QuZW50cmllcy1wb255ZmlsbEAxLjAuMS9ub2RlX21vZHVsZXMvb2JqZWN0LmVudHJpZXMtcG9ueWZpbGwvZW50cmllcy5qcyIoZXhwb3J0cywgbW9kdWxlKSB7CiAgICAgIGluaXRfYnVmZmVyX3NoaW0oKTsKICAgICAgInVzZSBzdHJpY3QiOwogICAgICB2YXIgaGFzID0gZnVuY3Rpb24ob2JqLCBwcm9wKSB7CiAgICAgICAgcmV0dXJuIE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbChvYmosIHByb3ApOwogICAgICB9OwogICAgICB2YXIgaXNFbnVtZXJhYmxlID0gZnVuY3Rpb24ob2JqLCBwcm9wKSB7CiAgICAgICAgcmV0dXJuIE9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChvYmosIHByb3ApOwogICAgICB9OwogICAgICBmdW5jdGlvbiBlbnRyaWVzMihvYmopIHsKICAgICAgICBpZiAob2JqID09IG51bGwpIHsKICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoIkNhbm5vdCBjb252ZXJ0IHVuZGVmaW5lZCBvciBudWxsIHRvIG9iamVjdCIpOwogICAgICAgIH0KICAgICAgICB2YXIgcGFpcnMgPSBbXTsKICAgICAgICBmb3IgKHZhciBrZXkgaW4gb2JqKSB7CiAgICAgICAgICBpZiAoaGFzKG9iaiwga2V5KSAmJiBpc0VudW1lcmFibGUob2JqLCBrZXkpKSB7CiAgICAgICAgICAgIHBhaXJzLnB1c2goW2tleSwgb2JqW2tleV1dKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIHBhaXJzOwogICAgICB9CiAgICAgIG1vZHVsZS5leHBvcnR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YmluZCgpIDogZnVuY3Rpb24gX2dldFByb3RvdHlwZU9mMihvMikgewogICAgICAgICAgcmV0dXJuIG8yLl9fcHJvdG9fXyB8fCBPYmplY3QuZ2V0UHJvdG90eXBlT2YobzIpOwogICAgICAgIH07CiAgICAgICAgcmV0dXJuIF9nZXRQcm90b3R5cGVPZihvKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBfc2V0UHJvdG90eXBlT2YobywgcCkgewogICAgICAgIF9zZXRQcm90b3R5cGVPZiA9IE9iamVjdC5zZXRQcm90b3R5cGVPZiA/IE9iamVjdC5zZXRQcm90b3R5cGVPZi5iaW5kKCkgOiBmdW5jdGlvbiBfc2V0UHJvdG90eXBlT2YyKG8yLCBwMikgewogICAgICAgICAgbzIuX19wcm90b19fID0gcDI7CiAgICAgICAgICByZXR1cm4gbzI7CiAgICAgICAgfTsKICAgICAgICByZXR1cm4gX3NldFByb3RvdHlwZU9mKG8sIHApOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIF9pc05hdGl2ZVJlZmxlY3RDb25zdHJ1Y3QoKSB7CiAgICAgICAgaWYgKHR5cGVvZiBSZWZsZWN0ID09PSAidW5kZWZpbmVkIiB8fCAhUmVmbGVjdC5jb25zdHJ1Y3QpCiAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgaWYgKFJlZmxlY3QuY29uc3RydWN0LnNoYW0pCiAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgaWYgKHR5cGVvZiBQcm94eSA9PT0gImZ1bmN0aW9uIikKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIHRyeSB7CiAgICAgICAgICBCb29sZWFuLnByb3RvdHlwZS52YWx1ZU9mLmNhbGwoUmVmbGVjdC5jb25zdHJ1Y3QoQm9vbGVhbiwgW10sIGZ1bmN0aW9uKCkgewogICAgICAgICAgfSkpOwogICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgcmV0dXJu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dENvbnN0cnVjdCkgewogICAgICAgICAgICB2YXIgTmV3VGFyZ2V0ID0gX2dldFByb3RvdHlwZU9mKHRoaXMpLmNvbnN0cnVjdG9yOwogICAgICAgICAgICByZXN1bHQgPSBSZWZsZWN0LmNvbnN0cnVjdChTdXBlciwgYXJndW1lbnRzLCBOZXdUYXJnZXQpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcmVzdWx0ID0gU3VwZXIuYXBwbHkodGhpcywgYXJndW1lbnRzKTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBfcG9zc2libGVDb25zdHJ1Y3RvclJldHVybih0aGlzLCByZXN1bHQpOwogICAgICAgIH07CiAgICAgIH0KICAgICAgZnVuY3Rpb24gX3N1cGVyUHJvcEJhc2Uob2JqZWN0LCBwcm9wZXJ0eSkgewogICAgICAgIHdoaWxlICghT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKG9iamVjdCwgcHJvcGVydHkpKSB7CiAgICAgICAgICBvYmplY3QgPSBfZ2V0UHJvdG90eXBlT2Yob2JqZWN0KTsKICAgICAgICAgIGlmIChvYmplY3QgPT09IG51bGwpCiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICByZXR1cm4gb2JqZWN0OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIF9nZXQoKSB7CiAgICAgICAgaWYgKHR5cGVvZiBSZWZsZWN0ICE9PSAidW5kZWZpbmVkIiAmJiBSZWZsZWN0LmdldCkgewogICAgICAgICAgX2dldCA9IFJlZmxlY3QuZ2V0LmJpbmQoKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgX2dldCA9IGZ1bmN0aW9uIF9nZXQyKHRhcmdldCwgcHJvcGVydHksIHJlY2VpdmVyKSB7CiAgICAgICAgICAgIHZhciBiYXNlID0gX3N1cGVyUHJvcEJhc2UodGFyZ2V0LCBwcm9wZXJ0eSk7CiAgICAgICAgICAgIGlmICghYmFzZSkKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIHZhciBkZXNjID0gT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcihiYXNlLCBwcm9wZXJ0eSk7CiAgICAgICAgICAgIGlmIChkZXNjLmdldCkgewogICAgICAgICAgICAgIHJldHVybiBkZXNjLmdldC5jYWxsKGFyZ3VtZW50cy5sZW5ndGggPCAzID8gdGFyZ2V0IDogcmVjZWl2ZXIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiBkZXNjLnZhbHVlOwogICAgICAgICAgfTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIF9nZXQuYXBwbHkodGhpcywgYXJndW1lbnRzKTsKICAgICAgfQogICAgICB2YXIgRW1pdHRlciA9IC8qIEBfX1BVUkVfXyAqLyBmdW5jdGlvbigpIHsKICAgICAgICBmdW5jdGlvbiBFbWl0dGVyMigpIHsKICAgICAgICAgIF9jbGFzc0NhbGxDaGVjayh0aGlzLCBFbWl0dGVyMik7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImxpc3RlbmVycyIsIHsKICAgICAgICAgICAgdmFsdWU6IHt9LAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgX2NyZWF0ZUNsYXNzKEVtaXR0ZXIyLCBbewogICAgICAgICAga2V5OiAiYWRkRXZlbnRMaXN0ZW5lciIsCiAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24gYWRkRXZlbnRMaXN0ZW5lcih0eXBlLCBjYWxsYmFjaywgb3B0aW9ucykgewogICAgICAgICAgICBpZiAoISh0eXBlIGluIHRoaXMubGlzdGVuZXJzKSkgewogICAgICAgICAgICAgIHRoaXMubGlzdGVuZXJzW3R5cGVdID0gW107CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGhpcy5saXN0ZW5lcnNbdHlwZV0ucHVzaCh7CiAgICAgICAgICAgICAgY2FsbGJhY2ssCiAgICAgICAgICAgICAgb3B0aW9ucwogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICB9LCB7CiAgICAgICAgICBrZXk6ICJyZW1vdmVFdmVudExpc3RlbmVyIiwKICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbiByZW1vdmVFdmVudExpc3RlbmVyKHR5cGUsIGNhbGxiYWNrKSB7CiAgICAgICAgICAgIGlmICghKHR5cGUgaW4gdGhpcy5saXN0ZW5lcnMpKSB7CiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHZhciBzdGFjayA9IHRoaXMubGlzdGVuZXJzW3R5cGVdOwogICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgbCA9IHN0YWNrLmxlbmd0aDsgaSA8IGw7IGkrKykgewogICAgICAgICAgICAgIGlmIChzdGFja1tpXS5jYWxsYmFjayA9PT0gY2FsbGJhY2spIHsKICAgICAgICAgICAgICAgIHN0YWNrLnNwbGljZShpLCAxKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9LCB7CiAgICAgICAgICBrZXk6ICJkaXNwYXRjaEV2ZW50IiwKICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbiBkaXNwYXRjaEV2ZW50KGV2ZW50KSB7CiAgICAgICAgICAgIGlmICghKGV2ZW50LnR5cGUgaW4gdGhpcy5saXN0ZW5lcnMpKSB7CiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHZhciBzdGFjayA9IHRoaXMubGlzdGVuZXJzW2V2ZW50LnR5cGVdOwogICAgICAgICAgICB2YXIgc3RhY2tUb0NhbGwgPSBzdGFjay5zbGljZSgpOwogICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgbCA9IHN0YWNrVG9DYWxsLmxlbmd0aDsgaSA8IGw7IGkrKykgewogICAgICAgICAgICAgIHZhciBsaXN0ZW5lciA9IHN0YWNrVG9DYWxsW2ldOwogICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICBsaXN0ZW5lci5jYWxsYmFjay5jYWxsKHRoaXMsIGV2ZW50KTsKICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICBQcm9taXNlLnJlc29sdmUoKS50aGVuKGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgICB0aHJvdyBlOwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChsaXN0ZW5lci5vcHRpb25zICYmIGxpc3RlbmVyLm9wdGlvbnMub25jZSkgewogICAgICAgICAgICAgICAgdGhpcy5yZW1vdmVFdmVudExpc3RlbmVyKGV2ZW50LnR5cGUsIGxpc3RlbmVyLmNhbGxiYWNrKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuICFldmVudC5kZWZhdWx0UHJldmVudGVkOwogICAgICAgICAgfQogICAgICAgIH1dKTsKICAgICAgICByZXR1cm4gRW1pdHRlcjI7CiAgICAgIH0oKTsKICAgICAgdmFyIEFib3J0U2lnbmFsID0gLyogQF9fUFVSRV9fICovIGZ1bmN0aW9uKF9FbWl0dGVyKSB7CiAgICAgICAgX2luaGVyaXRzKEFib3J0U2lnbmFsMiwgX0VtaXR0ZXIpOwogICAgICAgIHZhciBfc3VwZXIgPSBfY3JlYXRlU3VwZXIoQWJvcnRTaWduYWwyKTsKICAgICAgICBmdW5jdGlvbiBBYm9ydFNpZ25hbDIoKSB7CiAgICAgICAgICB2YXIgX3RoaXM7CiAgICAgICAgICBfY2xhc3NDYWxsQ2hlY2sodGhpcywgQWJvcnRTaWduYWwyKTsKICAgICAgICAgIF90aGlzID0gX3N1cGVyLmNhbGwodGhpcyk7CiAgICAgICAgICBpZiAoIV90aGlzLmxpc3RlbmVycykgewogICAgICAgICAgICBFbWl0dGVyLmNhbGwoX2Fzc2VydFRoaXNJbml0aWFsaXplZChfdGhpcykpOwogICAgICAgICAgfQogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KF9hc3NlcnRUaGlzSW5pdGlhbGl6ZWQoX3RoaXMpLCAiYWJvcnRlZCIsIHsKICAgICAgICAgICAgdmFsdWU6IGZhbHNlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShfYXNzZXJ0VGhpc0luaXRpYWxpemVkKF90aGlzKSwgIm9uYWJvcnQiLCB7CiAgICAgICAgICAgIHZhbHVlOiBudWxsLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShfYXNzZXJ0VGhpc0luaXRpYWxpemVkKF90aGlzKSwgInJlYXNvbiIsIHsKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMCwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZQogICAgICAgICAgfSk7CiAgICAgICAgICByZXR1cm4gX3RoaXM7CiAgICAgICAgfQogICAgICAgIF9jcmVhdGVDbGFzcyhBYm9ydFNpZ25hbDIsIFt7CiAgICAgICAgICBrZXk6ICJ0b1N0cmluZyIsCiAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24gdG9TdHJpbmcoKSB7CiAgICAgICAgICAgIHJldHVybiAiW29iamVjdCBBYm9ydFNpZ25hbF0iOwogICAgICAgICAgfQogICAgICAgIH0sIHsKICAgICAgICAgIGtleTogImRpc3BhdGNoRXZlbnQiLAogICAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIGRpc3BhdGNoRXZlbnQoZXZlbnQpIHsKICAgICAgICAgICAgaWYgKGV2ZW50LnR5cGUgPT09ICJhYm9ydCIpIHsKICAgICAgICAgICAgICB0aGlzLmFib3J0ZWQgPSB0cnVlOwogICAgICAgICAgICAgIGlmICh0eXBlb2YgdGhpcy5vbmFib3J0ID09PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgICAgICAgICB0aGlzLm9uYWJvcnQuY2FsbCh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIF9nZXQoX2dldFByb3RvdHlwZU9mKEFib3J0U2lnbmFsMi5wcm90b3R5cGUpLCAiZGlzcGF0Y2hFdmVudCIsIHRoaXMpLmNhbGwodGhpcywgZXZlbnQpOwogICAgICAgICAgfQogICAgICAgIH1dKTsKICAgICAgICByZXR1cm4gQWJvcnRTaWduYWwyOwogICAgICB9KEVtaXR0ZXIpOwogICAgICB2YXIgQWJvcnRDb250cm9sbGVyID0gLyogQF9fUFVSRV9fICovIGZ1bmN0aW9uKCkgewogICAgICAgIGZ1bmN0aW9uIEFib3J0Q29udHJvbGxlcjIoKSB7CiAgICAgICAgICBfY2xhc3NDYWxsQ2hlY2sodGhpcywgQWJvcnRDb250cm9sbGVyMik7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInNpZ25hbCIsIHsKICAgICAgICAgICAgdmFsdWU6IG5ldyBBYm9ydFNpZ25hbCgpLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgX2NyZWF0ZUNsYXNzKEFib3J0Q29udHJvbGxlcjIsIFt7CiAgICAgICAgICBrZXk6ICJhYm9ydCIsCiAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24gYWJvcnQocmVhc29uKSB7CiAgICAgICAgICAgIHZhciBldmVudDsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBldmVudCA9IG5ldyBFdmVudCgiYWJvcnQiKTsKICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgIGlmICh0eXBlb2YgZG9jdW1lbnQgIT09ICJ1bmRlZmluZWQiKSB7CiAgICAgICAgICAgICAgICBpZiAoIWRvY3VtZW50LmNyZWF0ZUV2ZW50KSB7CiAgICAgICAgICAgICAgICAgIGV2ZW50ID0gZG9jdW1lbnQuY3JlYXRlRXZlbnRPYmplY3QoKTsKICAgICAgICAgICAgICAgICAgZXZlbnQudHlwZSA9ICJhYm9ydCI7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICBldmVudCA9IGRvY3VtZW50LmNyZWF0ZUV2ZW50KCJFdmVudCIpOwogICAgICAgICAgICAgICAgICBldmVudC5pbml0RXZlbnQoImFib3J0IiwgZmFsc2UsIGZhbHNlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgZXZlbnQgPSB7CiAgICAgICAgICAgICAgICAgIHR5cGU6ICJhYm9ydCIsCiAgICAgICAgICAgICAgICAgIGJ1YmJsZXM6IGZhbHNlLAogICAgICAgICAgICAgICAgICBjYW5jZWxhYmxlOiBmYWxzZQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdmFyIHNpZ25hbFJlYXNvbiA9IHJlYXNvbjsKICAgICAgICAgICAgaWYgKHNpZ25hbFJlYXNvbiA9PT0gdm9pZCAwKSB7CiAgICAgICAgICAgICAgaWYgKHR5cGVvZiBkb2N1bWVudCA9PT0gInVuZGVmaW5lZCIpIHsKICAgICAgICAgICAgICAgIHNpZ25hbFJlYXNvbiA9IG5ldyBFcnJvcigiVGhpcyBvcGVyYXRpb24gd2FzIGFib3J0ZWQiKTsKICAgICAgICAgICAgICAgIHNpZ25hbFJlYXNvbi5uYW1lID0gIkFib3J0RXJyb3IiOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICBzaWduYWxSZWFzb24gPSBuZXcgRE9NRXhjZXB0aW9uKCJzaWduYWwgaXMgYWJvcnRlZCB3aXRob3V0IHJlYXNvbiIpOwogICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgICAgICAgIHNpZ25hbFJlYXNvbiA9IG5ldyBFcnJvcigiVGhpcyBvcGVyYXRpb24gd2FzIGFib3J0ZWQiKTsKICAgICAgICAgICAgICAgICAgc2lnbmFsUmVhc29uLm5hbWUgPSAiQWJvcnRFcnJvciI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIHRoaXMuc2lnbmFsLnJlYXNvbiA9IHNpZ25hbFJlYXNvbjsKICAgICAgICAgICAgdGhpcy5zaWduYWwuZGlzcGF0Y2hFdmVudChldmVudCk7CiAgICAgICAgICB9CiAgICAgICAgfSwgewogICAgICAgICAga2V5OiAidG9TdHJpbmciLAogICAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIHRvU3RyaW5nKCkgewogICAgICAgICAgICByZXR1cm4gIltvYmplY3QgQWJvcnRDb250cm9sbGVyXSI7CiAgICAgICAgICB9CiAgICAgICAgfV0pOwogICAgICAgIHJldHVybiBBYm9ydENvbnRyb2xsZXIyOwogICAgICB9KCk7CiAgICAgIGlmICh0eXBlb2YgU3ltYm9sICE9PSAidW5kZWZpbmVkIiAmJiBTeW1ib2wudG9TdHJpbmdUYWcpIHsKICAgICAgICBBYm9ydENvbnRyb2xsZXIucHJvdG90eXBlW1N5bWJvbC50b1N0cmluZ1RhZ10gPSAiQWJvcnRDb250cm9sbGVyIjsKICAgICAgICBBYm9ydFNpZ25hbC5wcm90b3R5cGVbU3ltYm9sLnRvU3RyaW5nVGFnXSA9ICJBYm9ydFNpZ25hbCI7CiAgICAgIH0K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0ZSBpbml0Mi5zaWduYWw7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdmFyIHJlcXVlc3QgPSBuZXcgTmF0aXZlUmVxdWVzdChpbnB1dCwgaW5pdDIpOwogICAgICAgICAgICBpZiAoc2lnbmFsKSB7CiAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHJlcXVlc3QsICJzaWduYWwiLCB7CiAgICAgICAgICAgICAgICB3cml0YWJsZTogZmFsc2UsCiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiBmYWxzZSwKICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIHZhbHVlOiBzaWduYWwKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gcmVxdWVzdDsKICAgICAgICAgIH07CiAgICAgICAgICBSZXF1ZXN0LnByb3RvdHlwZSA9IE5hdGl2ZVJlcXVlc3QucHJvdG90eXBlOwogICAgICAgIH0KICAgICAgICB2YXIgcmVhbEZldGNoID0gZmV0Y2gyOwogICAgICAgIHZhciBhYm9ydGFibGVGZXRjaCA9IGZ1bmN0aW9uIGFib3J0YWJsZUZldGNoMihpbnB1dCwgaW5pdDIpIHsKICAgICAgICAgIHZhciBzaWduYWwgPSBSZXF1ZXN0ICYmIFJlcXVlc3QucHJvdG90eXBlLmlzUHJvdG90eXBlT2YoaW5wdXQpID8gaW5wdXQuc2lnbmFsIDogaW5pdDIgPyBpbml0Mi5zaWduYWwgOiB2b2lkIDA7CiAgICAgICAgICBpZiAoc2lnbmFsKSB7CiAgICAgICAgICAgIHZhciBhYm9ydEVycm9yOwogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgIGFib3J0RXJyb3IgPSBuZXcgRE9NRXhjZXB0aW9uKCJBYm9ydGVkIiwgIkFib3J0RXJyb3IiKTsKICAgICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgICAgYWJvcnRFcnJvciA9IG5ldyBFcnJvcigiQWJvcnRlZCIpOwogICAgICAgICAgICAgIGFib3J0RXJyb3IubmFtZSA9ICJBYm9ydEVycm9yIjsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoc2lnbmFsLmFib3J0ZWQpIHsKICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZWplY3QoYWJvcnRFcnJvcik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdmFyIGNhbmNlbGxhdGlvbiA9IG5ldyBQcm9taXNlKGZ1bmN0aW9uKF8sIHJlamVjdCkgewogICAgICAgICAgICAgIHNpZ25hbC5hZGRFdmVudExpc3RlbmVyKCJhYm9ydCIsIGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgcmV0dXJuIHJlamVjdChhYm9ydEVycm9yKTsKICAgICAgICAgICAgICB9LCB7CiAgICAgICAgICAgICAgICBvbmNlOiB0cnVlCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBpZiAoaW5pdDIgJiYgaW5pdDIuc2lnbmFsKSB7CiAgICAgICAgICAgICAgZGVsZXRlIGluaXQyLnNpZ25hbDsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yYWNlKFtjYW5jZWxsYXRpb24sIHJlYWxGZXRjaChpbnB1dCwgaW5pdDIpXSk7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gcmVhbEZldGNoKGlucHV0LCBpbml0Mik7CiAgICAgICAgfTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgZmV0Y2g6IGFib3J0YWJsZUZldGNoLAogICAgICAgICAgUmVxdWVzdAogICAgICAgIH07CiAgICAgIH0KICAgICAgZXhwb3J0cy5BYm9ydENvbnRyb2xsZXIgPSBBYm9ydENvbnRyb2xsZXI7CiAgICAgIGV4cG9ydHMuQWJvcnRTaWduYWwgPSBBYm9ydFNpZ25hbDsKICAgICAgZXhwb3J0cy5hYm9ydGFibGVGZXRj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mRlZmF1bHQoKTsKICAgICAgICAgIHN0YXR1c1JlcG9ydGVyLmFkZENhbGxiYWNrKHN0YXR1c0NhbGxiYWNrKTsKICAgICAgICAgIGNvbnN0IG5ld0VudHJ5ID0gewogICAgICAgICAgICBhYm9ydGVyLAogICAgICAgICAgICBwcm9taXNlOiB0aGlzLmZpbGxDYWxsYmFjayhkYXRhLCBhYm9ydGVyLnNpZ25hbCwgKG1lc3NhZ2UpID0+IHsKICAgICAgICAgICAgICBzdGF0dXNSZXBvcnRlci5jYWxsYmFjayhtZXNzYWdlKTsKICAgICAgICAgICAgfSksCiAgICAgICAgICAgIHNldHRsZWQ6IGZhbHNlLAogICAgICAgICAgICBzdGF0dXNSZXBvcnRlciwKICAgICAgICAgICAgZ2V0IGFib3J0ZWQoKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuYWJvcnRlci5zaWduYWwuYWJvcnRlZDsKICAgICAgICAgICAgfQogICAgICAgICAgfTsKICAgICAgICAgIG5ld0VudHJ5LmFib3J0ZXIuYWRkU2lnbmFsKHNpZ25hbCk7CiAgICAgICAgICBuZXdFbnRyeS5hYm9ydGVyLnNpZ25hbC5hZGRFdmVudExpc3RlbmVyKCJhYm9ydCIsICgpID0+IHsKICAgICAgICAgICAgaWYgKCFuZXdFbnRyeS5zZXR0bGVkKSB7CiAgICAgICAgICAgICAgdGhpcy5ldmljdChrZXksIG5ld0VudHJ5KTsKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgICBuZXdFbnRyeS5wcm9taXNlLnRoZW4oKCkgPT4gewogICAgICAgICAgICBuZXdFbnRyeS5zZXR0bGVkID0gdHJ1ZTsKICAgICAgICAgIH0sICgpID0+IHsKICAgICAgICAgICAgbmV3RW50cnkuc2V0dGxlZCA9IHRydWU7CiAgICAgICAgICAgIHRoaXMuZXZpY3Qoa2V5LCBuZXdFbnRyeSk7CiAgICAgICAgICB9KS5jYXRjaCgoZSkgPT4gewogICAgICAgICAgICBjb25zb2xlLmVycm9yKGUpOwogICAgICAgICAgICB0aHJvdyBlOwogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmNhY2hlLnNldChrZXksIG5ld0VudHJ5KTsKICAgICAgICB9CiAgICAgICAgc3RhdGljIGNoZWNrU2luZ2xlUHJvbWlzZShwcm9taXNlLCBzaWduYWwpIHsKICAgICAgICAgIGZ1bmN0aW9uIGNoZWNrRm9yU2luZ2xlQWJvcnQoKSB7CiAgICAgICAgICAgIGlmIChzaWduYWwgJiYgc2lnbmFsLmFib3J0ZWQpIHsKICAgICAgICAgICAgICB0aHJvdyBPYmplY3QuYXNzaWduKG5ldyBFcnJvcigiYWJvcnRlZCIpLCB7IGNvZGU6ICJFUlJfQUJPUlRFRCIgfSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBwcm9taXNlLnRoZW4oKHJlc3VsdCkgPT4gewogICAgICAgICAgICBjaGVja0ZvclNpbmdsZUFib3J0KCk7CiAgICAgICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgICAgICB9LCAoZXJyb3IpID0+IHsKICAgICAgICAgICAgY2hlY2tGb3JTaW5nbGVBYm9ydCgpOwogICAgICAgICAgICB0aHJvdyBlcnJvcjsKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgICBoYXMoa2V5KSB7CiAgICAgICAgICByZXR1cm4gdGhpcy5jYWNoZS5oYXMoa2V5KTsKICAgICAgICB9CiAgICAgICAgZ2V0KGtleSwgZGF0YSwgc2lnbmFsLCBzdGF0dXNDYWxsYmFjaykgewogICAgICAgICAgaWYgKCFzaWduYWwgJiYgZGF0YSBpbnN0YW5jZW9mIGFib3J0Y29udHJvbGxlcl9wb255ZmlsbF8xLkFib3J0U2lnbmFsKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoInNlY29uZCBnZXQgYXJndW1lbnQgYXBwZWFycyB0byBiZSBhbiBBYm9ydFNpZ25hbCwgcGVyaGFwcyB5b3Ugb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0IGJlIGEgbnVtYmVyIGdyZWF0ZXIgdGhhbiAwIik7CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLm1heFNpemUgPSBvcHRpb25zLm1heFNpemU7CiAgICAgICAgICB0aGlzLmNhY2hlID0gbmV3IE1hcCgpOwogICAgICAgICAgdGhpcy5vbGRDYWNoZSA9IG5ldyBNYXAoKTsKICAgICAgICAgIHRoaXMuX3NpemUgPSAwOwogICAgICAgIH0KICAgICAgICBfc2V0KGtleSwgdmFsdWUpIHsKICAgICAgICAgIHRoaXMuY2FjaGUuc2V0KGtleSwgdmFsdWUpOwogICAgICAgICAgdGhpcy5fc2l6ZSsrOwogICAgICAgICAgaWYgKHRoaXMuX3NpemUgPj0gdGhpcy5tYXhTaXplKSB7CiAgICAgICAgICAgIHRoaXMuX3NpemUgPSAwOwogICAgICAgICAgICB0aGlzLm9sZENhY2hlID0gdGhpcy5jYWNoZTsKICAgICAgICAgICAgdGhpcy5jYWNoZSA9IG5ldyBNYXAoKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZ2V0KGtleSkgewogICAgICAgICAgaWYgKHRoaXMuY2FjaGUuaGFzKGtleSkpIHsKICAgICAgICAgICAgcmV0dXJuIHRoaXMuY2FjaGUuZ2V0KGtleSk7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAodGhpcy5vbGRDYWNoZS5oYXMoa2V5KSkgewogICAgICAgICAgICBjb25zdCB2YWx1ZSA9IHRoaXMub2xkQ2FjaGUuZ2V0KGtleSk7CiAgICAgICAgICAgIHRoaXMuX3NldChrZXksIHZhbHVlKTsKICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBzZXQoa2V5LCB2YWx1ZSkgewogICAgICAgICAgaWYgKHRoaXMuY2FjaGUuaGFzKGtleSkpIHsKICAgICAgICAgICAgdGhpcy5jYWNoZS5zZXQoa2V5LCB2YWx1ZSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICB0aGlzLl9zZXQoa2V5LCB2YWx1ZSk7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICB9CiAgICAgICAgaGFzKGtleSkgewogICAgICAgICAgcmV0dXJuIHRoaXMuY2FjaGUuaGFzKGtleSkgfHwgdGhpcy5vbGRDYWNoZS5oYXMoa2V5KTsKICAgICAgICB9CiAgICAgICAgcGVlayhrZXkpIHsKICAgICAgICAgIGlmICh0aGlzLmNhY2hlLmhhcyhrZXkpKSB7CiAgICAgICAgICAgIHJldHVybiB0aGlzLmNhY2hlLmdldChrZXkpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHRoaXMub2xkQ2FjaGUuaGFzKGtleSkpIHsKICAgICAgICAgICAgcmV0dXJuIHRoaXMub2xkQ2FjaGUuZ2V0KGtleSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGRlbGV0ZShrZXkpIHsKICAgICAgICAgIGNvbnN0IGRlbGV0ZWQgPSB0aGlzLmNhY2hlLmRlbGV0ZShrZXkpOwogICAgICAgICAgaWYgKGRlbGV0ZWQpIHsKICAgICAgICAgICAgdGhpcy5fc2l6ZS0tOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIHRoaXMub2xkQ2FjaGUuZGVsZXRlKGtleSkgfHwgZGVsZXRlZDsKICAgICAgICB9CiAgICAgICAgY2xlYXIoKSB7CiAgICAgICAgICB0aGlzLmNhY2hlLmNsZWFyKCk7CiAgICAgICAgICB0aGlzLm9sZENhY2hlLmNsZWFyKCk7CiAgICAgICAgICB0aGlzLl9zaXplID0gMDsKICAgICAgICB9CiAgICAgICAgKmtleXMoKSB7CiAgICAgICAgICBmb3IgKGNvbnN0IFtrZXldIG9mIHRoaXMpIHsKICAgICAgICAgICAgeWllbGQga2V5OwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICAqdmFsdWVzKCkgewogICAgICAgICAgZm9yIChjb25zdCBbLCB2YWx1ZV0gb2YgdGhpcykgewogICAgICAgICAgICB5aWVsZCB2YWx1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgKltTeW1ib2wuaXRlcmF0b3JdKCkgewogICAgICAgICAgZm9yIChjb25zdCBpdGVtIG9mIHRoaXMuY2FjaGUpIHsKICAgICAgICAgICAgeWllbGQgaXRlbTsKICAgICAgICAgIH0KICAgICAgICAgIGZvciAoY29uc3QgaXRlbSBvZiB0aGlzLm9sZENhY2hlKSB7CiAgICAgICAgICAgIGNvbnN0IFtrZXldID0gaXRlbTsKICAgICAgICAgICAgaWYgKCF0aGlzLmNhY2hlLmhhcyhrZXkpKSB7CiAgICAgICAgICAgICAgeWllbGQgaXRlbTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBnZXQgc2l6ZSgpIHsKICAgICAgICAgIGxldCBvbGRDYWNoZVNpemUgPSAwOwogICAgICAgICAgZm9yIChjb25zdCBrZXkgb2YgdGhpcy5vbGRDYWNoZS5rZXlzKCkpIHsKICAgICAgICAgICAgaWYgKCF0aGlzLmNhY2hlLmhhcyhrZXkpKSB7CiAgICAgICAgICAgICAgb2xkQ2FjaGVTaXplKys7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiB0aGlzLl9zaXplICsgb2xkQ2FjaGVTaXplOwogICAgICAgIH0KICAgICAgfTsKICAgICAgbW9kdWxlLmV4cG9ydHMgPSBRdWlja0xSVTM7CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8ucG5wbS9jcm9zcy1mZXRjaEAzLjEuOC9ub2RlX21vZHVsZXMvY3Jvc3MtZmV0Y2gvZGlzdC9icm93c2VyLXBvbHlmaWxsLmpzCiAgdmFyIHJlcXVpcmVfYnJvd3Nlcl9wb2x5ZmlsbCA9IF9fY29tbW9uSlMoewogICAgIm5vZGVfbW9kdWxlcy8ucG5wbS9jcm9zcy1mZXRjaEAzLjEuOC9ub2RlX21vZHVsZXMvY3Jvc3MtZmV0Y2gvZGlzdC9icm93c2VyLXBvbHlmaWxsLmpzIihleHBvcnRzKSB7CiAgICAgIGluaXRfYnVmZmVyX3NoaW0oKTsKICAgICAgKGZ1bmN0aW9uKHNlbGYyKSB7CiAgICAgICAgdmFyIGlycmVsZXZhbnQgPSBmdW5jdGlvbihleHBvcnRzMikgewogICAgICAgICAgdmFyIHN1cHBvcnQgPSB7CiAgICAgICAgICAgIHNlYXJjaFBhcmFtczogIlVSTFNlYXJjaFBhcmFtcyIgaW4gc2VsZjIsCiAgICAgICAgICAgIGl0ZXJhYmxlOiAiU3ltYm9sIiBpbiBzZWxmMiAmJiAiaXRlcmF0b3IiIGluIFN5bWJvbCwKICAgICAgICAgICAgYmxvYjogIkZpbGVSZWFkZXIiIGluIHNlbGYyICYmICJCbG9iIiBpbiBzZWxmMiAmJiBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgbmV3IEJsb2IoKTsKICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0oKSwKICAgICAgICAgICAgZm9ybURhdGE6ICJGb3JtRGF0YSIgaW4gc2VsZjIsCiAgICAgICAgICAgIGFycmF5QnVmZmVyOiAiQXJyYXlCdWZmZXIiIGluIHNlbGYyCiAgICAgICAgICB9OwogICAgICAgICAgZnVuY3Rpb24gaXNEYXRhVmlldyhvYmopIHsKICAgICAgICAgICAgcmV0dXJuIG9iaiAmJiBEYXRhVmlldy5wcm90b3R5cGUuaXNQcm90b3R5cGVPZihvYmopOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHN1cHBvcnQuYXJyYXlCdWZmZXIpIHsKICAgICAgICAgICAgdmFyIHZpZXdDbGFzc2VzID0gWwogICAgICAgICAgICAgICJbb2JqZWN0IEludDhBcnJheV0iLAogICAgICAgICAgICAgICJbb2JqZWN0IFVpbnQ4QXJyYXldIiwKICAgICAgICAgICAgICAiW29iamVjdCBVaW50OENsYW1wZWRBcnJheV0iLAogICAgICAgICAgICAgICJbb2JqZWN0IEludDE2QXJyYXldIiwKICAgICAgICAgICAgICAiW29iamVjdCBVaW50MTZBcnJheV0iLAogICAgICAgICAgICAgICJbb2JqZWN0IEludDMyQXJyYXldIiwKICAgICAgICAgICAgICAiW29iamVjdCBVaW50MzJBcnJheV0iLAogICAgICAgICAgICAgICJbb2JqZWN0IEZsb2F0MzJBcnJheV0iLAogICAgICAgICAgICAgICJbb2JqZWN0IEZsb2F0NjRBcnJheV0iCiAgICAgICAgICAgIF07CiAgICAgICAgICAgIHZhciBpc0FycmF5QnVmZmVyVmlldyA9IEFycmF5QnVmZmVyLmlzVmlldyB8fCBmdW5jdGlvbihvYmopIHsKICAgICAgICAgICAgICByZXR1cm4gb2JqICYmIHZpZXdDbGFzc2VzLmluZGV4T2YoT2JqZWN0LnByb3RvdHlwZS50b1N0cmluZy5jYWxsKG9iaikpID4gLTE7CiAgICAgICAgICAgIH07CiAgICAgICAgICB9CiAgICAgICAgICBmdW5jdGlvbiBub3JtYWxpemVOYW1lKG5hbWUpIHsKICAgICAgICAgICAgaWYgKHR5cGVvZiBuYW1lICE9PSAic3RyaW5nIikgewogICAgICAgICAgICAgIG5hbWUgPSBTdHJpbmcobmFtZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKC9bXmEtejAtOVwtIyQlJicqKy5eX2B8fl0vaS50ZXN0KG5hbWUpKSB7CiAgICAgICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcigiSW52YWxpZCBjaGFyYWN0ZXIgaW4gaGVhZGVyIGZpZWxkIG5hbWUiKTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gbmFtZS50b0xvd2VyQ2FzZSgpOwogICAgICAgICAgfQogICAgICAgICAgZnVuY3Rpb24gbm9ybWFsaXplVmFsdWUodmFsdWUpIHsKICAgICAgICAgICAgaWYgKHR5cGVvZiB2YWx1ZSAhPT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICB2YWx1ZSA9IFN0cmluZyh2YWx1ZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgfQogICAgICAgICAgZnVuY3Rpb24gaXRlcmF0b3JGb3IoaXRlbXMpIHsKICAgICAgICAgICAgdmFyIGl0ZXJhdG9yID0gewogICAgICAgICAgICAgIG5leHQ6IGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgdmFyIHZhbHVlID0gaXRlbXMuc2hpZnQoKTsKICAgICAgICAgICAgICAgIHJldHVybiB7IGRvbmU6IHZhbHVlID09PSB2b2lkIDAsIHZhbHVlIH07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9OwogICAgICAgICAgICBpZiAoc3VwcG9ydC5pdGVyYWJsZSkgewogICAgICAgICAgICAgIGl0ZXJhdG9yW1N5bWJvbC5pdGVyYXRvcl0gPSBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgIHJldHVybiBpdGVyYXRvcjsKICAgICAgICAgICAgICB9OwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiBpdGVyYXRvcjsKICAgICAgICAgIH0KICAgICAgICAgIGZ1bmN0aW9uIEhlYWRlcnMoaGVhZGVycykgewogICAgICAgICAgICB0aGlzLm1hcCA9IHt9OwogICAgICAgICAgICBpZiAoaGVhZGVycyBpbnN0YW5jZW9mIEhlYWRlcnMpIHsKICAgICAgICAgICAgICBoZWFkZXJzLmZvckVhY2goZnVuY3Rpb24odmFsdWUsIG5hbWUpIHsKICAgICAgICAgICAgICAgIHRoaXMuYXBwZW5kKG5hbWUsIHZhbHVlKTsKICAgICAgICAgICAgICB9LCB0aGlzKTsKICAgICAgICAgICAgfSBlbHNlIGlmIChBcnJheS5pc0FycmF5KGhlYWRlcnMpKSB7CiAgICAgICAgICAgICAgaGVhZGVycy5mb3JFYWNoKGZ1bmN0aW9uKGhlYWRlcikgewogICAgICAgICAgICAgICAgdGhpcy5hcHBlbmQoaGVhZGVyWzBdLCBoZWFkZXJbMV0pOwogICAgICAgICAgICAgIH0sIHRoaXMpOwogICAgICAgICAgICB9IGVsc2UgaWYgKGhlYWRlcnMpIHsKICAgICAgICAgICAgICBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyhoZWFkZXJzKS5mb3JFYWNoKGZ1bmN0aW9uKG5hbWUpIHsKICAgICAgICAgICAgICAgIHRoaXMuYXBwZW5kKG5hbWUsIGhlYWRlcnNbbmFtZV0pOwogICAgICAgICAgICAgIH0sIHRoaXMpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBIZWFkZXJzLnByb3RvdHlwZS5hcHBlbmQgPSBmdW5jdGlvbihuYW1lLCB2YWx1ZSkgewogICAgICAgICAgICBuYW1lID0gbm9ybWFsaXplTmFtZShuYW1lKTsKICAgICAgICAgICAgdmFsdWUgPSBub3JtYWxpemVWYWx1ZSh2YWx1ZSk7CiAgICAgICAgICAgIHZhciBvbGRWYWx1ZSA9IHRoaXMubWFwW25hbWVdOwogICAgICAgICAgICB0aGlzLm1hcFtuYW1lXSA9IG9sZFZhbHVlID8gb2xkVmFsdWUgKyAiLCAiICsgdmFsdWUgOiB2YWx1ZTsKICAgICAgICAgIH07CiAgICAgICAgICBIZWFkZXJzLnByb3RvdHlwZVsiZGVsZXRlIl0gPSBmdW5jdGlvbihuYW1lKSB7CiAgICAgICAgICAgIGRlbGV0ZSB0aGlzLm1hcFtub3JtYWxpemVOYW1lKG5hbWUpXTsKICAgICAgICAgIH07CiAgICAgICAgICBIZWFkZXJzLnByb3RvdHlwZS5nZXQgPSBmdW5jdGlvbihuYW1lKSB7CiAgICAgICAgICAgIG5hbWUgPSBub3JtYWxpemVOYW1lKG5hbWUpOwogICAgICAgICAgICByZXR1cm4gdGhpcy5oYXMobmFtZSkgPyB0aGlzLm1hcFtuYW1lXSA6IG51bGw7CiAgICAgICAgICB9OwogICAgICAgICAgSGVhZGVycy5wcm90b3R5cGUuaGFzID0gZnVuY3Rpb24obmFtZSkgewogICAgICAgICAgICByZXR1cm4gdGhpcy5tYXAuaGFzT3duUHJvcGVydHkobm9ybWFsaXplTmFtZShuYW1lKSk7CiAgICAgICAgICB9OwogICAgICAgICAgSGVhZGVycy5wcm90b3R5cGUuc2V0ID0gZnVuY3Rpb24obmFtZSwgdmFsdWUpIHsKICAgICAgICAgICAgdGhpcy5tYXBbbm9ybWFsaXplTmFtZShuYW1lKV0gPSBub3JtYWxpemVWYWx1ZSh2YWx1ZSk7CiAgICAgICAgICB9OwogICAgICAgICAgSGVhZGVycy5wcm90b3R5cGUuZm9yRWFjaCA9IGZ1bmN0aW9uKGNhbGxiYWNrLCB0aGlzQXJnKSB7CiAgICAgICAgICAgIGZvciAodmFyIG5hbWUgaW4gdGhpcy5tYXApIHsKICAgICAgICAgICAgICBpZiAodGhpcy5tYXAuaGFzT3duUHJvcGVydHkobmFtZSkpIHsKICAgICAgICAgICAgICAgIGNhbGxiYWNrLmNhbGwodGhpc0FyZywgdGhpcy5tYXBbbmFtZV0sIG5hbWUsIHRoaXMpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfTsKICAgICAgICAgIEhlYWRlcnMucHJvdG90eXBlLmtleXMgPSBmdW5jdGlvbigpIHsKICAgICAgICAgICAgdmFyIGl0ZW1zID0gW107CiAgICAgICAgICAgIHRoaXMuZm9yRWFjaChmdW5jdGlvbih2YWx1ZSwgbmFtZSkgewogICAgICAgICAgICAgIGl0ZW1zLnB1c2gobmFtZSk7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICByZXR1cm4gaXRlcmF0b3JGb3IoaXRlbXMpOwogICAgICAgICAgfTsKICAgICAgICAgIEhlYWRlcnMucHJvdG90eXBlLnZhbHVlcyA9IGZ1bmN0aW9uKCkgewogICAgICAgICAgICB2YXIgaXRlbXMgPSBbXTsKICAgICAgICAgICAgdGhpcy5mb3JFYWNoKGZ1bmN0aW9uKHZhbHVlKSB7CiAgICAgICAgICAgICAgaXRlbXMucHVzaCh2YWx1ZSk7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICByZXR1cm4gaXRlcmF0b3JGb3IoaXRlbXMpOwogICAgICAgICAgfTsKICAgICAgICAgIEhlYWRlcnMucHJvdG90eXBlLmVudHJpZXMgPSBmdW5jdGlvbigpIHsKICAgICAgICAgICAgdmFyIGl0ZW1zID0gW107CiAgICAgICAgICAgIHRoaXMuZm9yRWFjaChmdW5jdGlvbih2YWx1ZSwgbmFtZSkgewogICAgICAgICAgICAgIGl0ZW1zLnB1c2goW25hbWUsIHZhbHVlXSk7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICByZXR1cm4gaXRlcmF0b3JGb3IoaXRlbXMpOwogICAgICAgICAgfTsKICAgICAgICAgIGlmIChzdXBwb3J0Lml0ZXJhYmxlKSB7CiAgICAgICAgICAgIEhlYWRlcnMucHJvdG90eXBlW1N5bWJvbC5pdGVyYXRvcl0gPSBIZWFkZXJzLnByb3RvdHlwZS5lbnRyaWVzOwogICAgICAgICAgfQogICAgICAgICAgZnVuY3Rpb24gY29uc3VtZWQoYm9keSkgewogICAgICAgICAgICBpZiAoYm9keS5ib2R5VXNlZCkgewogICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdChuZXcgVHlwZUVycm9yKCJBbHJlYWR5IHJlYWQiKSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYm9keS5ib2R5VXNlZCA9IHRydWU7CiAgICAgICAgICB9CiAgICAgICAgICBmdW5jdGlvbiBmaWxlUmVhZGVyUmVhZHkocmVhZGVyKSB7CiAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZShmdW5jdGlvbihyZXNvbHZlLCByZWplY3QpIHsKICAgICAgICAgICAgICByZWFkZXIub25sb2FkID0gZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICByZXNvbHZlKHJlYWRlci5yZXN1bHQpOwogICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgcmVhZGVyLm9uZXJyb3IgPSBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgIHJlamVjdChyZWFkZXIuZXJyb3IpOwogICAgICAgICAgICAgIH07CiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgICAgZnVuY3Rpb24gcmVhZEJsb2JBc0FycmF5QnVmZmVyKGJsb2IpIHsKICAgICAgICAgICAgdmFyIHJlYWRlciA9IG5ldyBGaWxlUmVhZGVyKCk7CiAgICAgICAgICAgIHZhciBwcm9taXNlID0gZmlsZVJlYWRlclJlYWR5KHJlYWRlcik7CiAgICAgICAgICAgIHJlYWRlci5yZWFkQXNBcnJheUJ1ZmZlcihibG9iKTsKICAgICAgICAgICAgcmV0dXJuIHByb21pc2U7CiAgICAgICAgICB9CiAgICAgICAgICBmdW5jdGlvbiByZWFkQmxvYkFzVGV4dChibG9iKSB7CiAgICAgICAgICAgIHZhciByZWFkZXIgPSBuZXcgRmlsZVJlYWRlcigpOwogICAgICAgICAgICB2YXIgcHJvbWlzZSA9IGZpbGVSZWFkZXJSZWFkeShyZWFkZXIpOwogICAgICAgICAgICByZWFkZXIucmVhZEFzVGV4dChibG9iKTsKICAgICAgICAgICAgcmV0dXJuIHByb21pc2U7CiAgICAgICAgICB9CiAgICAgICAgICBmdW5jdGlvbiByZWFkQXJyYXlCdWZmZXJBc1RleHQoYnVmKSB7CiAgICAgICAgICAgIHZhciB2aWV3ID0gbmV3IFVpbnQ4QXJyYXkoYnVmKTsKICAgICAgICAgICAgdmFyIGNoYXJzID0gbmV3IEFycmF5KHZpZXcubGVuZ3RoKTsKICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCB2aWV3Lmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgICAgY2hhcnNbaV0gPSBTdHJpbmcuZnJvbUNoYXJDb2RlKHZpZXdbaV0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiBjaGFycy5qb2luKCIiKTsKICAgICAgICAgIH0KICAgICAgICAgIGZ1bmN0aW9uIGJ1ZmZlckNsb25lKGJ1ZikgewogICAgICAgICAgICBpZiAoYnVmLnNsaWNlKSB7CiAgICAgICAgICAgICAgcmV0dXJuIGJ1Zi5zbGljZSgwKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICB2YXIgdmlldyA9IG5ldyBVaW50OEFycmF5KGJ1Zi5ieXRlTGVuZ3RoKTsKICAgICAgICAgICAgICB2aWV3LnNldChuZXcgVWludDhBcnJheShidWYpKTsKICAgICAgICAgICAgICByZXR1cm4gdmlldy5idWZmZXI7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGZ1bmN0aW9uIEJvZHkoKSB7CiAgICAgICAgICAgIHRoaXMuYm9keVVzZWQgPSBmYWxzZTsKICAgICAgICAgICAgdGhpcy5faW5pdEJvZHkgPSBmdW5jdGlvbihib2R5KSB7CiAgICAgICAgICAgICAgdGhpcy5fYm9keUluaXQgPSBib2R5OwogICAgICAgICAgICAgIGlmICghYm9keSkgewogICAgICAgICAgICAgICAgdGhpcy5fYm9keVRleHQgPSAiIjsKICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBib2R5ID09PSAic3RyaW5nIikgewogICAgICAgICAgICAgICAgdGhpcy5fYm9keVRleHQgPSBib2R5OwogICAgICAgICAgICAgIH0gZWxzZSBpZiAoc3VwcG9ydC5ibG9iICYmIEJsb2IucHJvdG90eXBlLmlzUHJvdG90eXBlT2YoYm9keSkpIHsKICAgICAgICAgICAgICAgIHRoaXMuX2JvZHlCbG9iID0gYm9keTsKICAgICAgICAgICAgICB9IGVsc2UgaWYgKHN1cHBvcnQuZm9ybURhdGEgJiYgRm9ybURhdGEucHJvdG90eXBlLmlzUHJvdG90eXBlT2YoYm9keSkpIHsKICAgICAgICAgICAgICAgIHRoaXMuX2JvZHlGb3JtRGF0YSA9IGJvZHk7CiAgICAgICAgICAgICAgfSBlbHNlIGlmIChzdXBwb3J0LnNlYXJjaFBhcmFtcyAmJiBVUkxTZWFyY2hQYXJhbXMucHJvdG90eXBlLmlzUHJvdG90eXBlT2YoYm9keSkpIHsKICAgICAgICAgICAgICAgIHRoaXMuX2JvZHlUZXh0ID0gYm9keS50b1N0cmluZygpOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAoc3VwcG9ydC5hcnJheUJ1ZmZlciAmJiBzdXBwb3J0LmJsb2IgJiYgaXNEYXRhVmlldyhib2R5KSkgewogICAgICAgICAgICAgICAgdGhpcy5fYm9keUFycmF5QnVmZmVyID0gYnVmZmVyQ2xvbmUoYm9keS5idWZmZXIpOwogICAgICAgICAgICAgICAgdGhpcy5fYm9keUluaXQgPSBuZXcgQmxvYihbdGhpcy5fYm9keUFycmF5QnVmZmVyXSk7CiAgICAgICAgICAgICAgfSBlbHNlIGlmIChzdXBwb3J0LmFycmF5QnVmZmVyICYmIChBcnJheUJ1ZmZlci5wcm90b3R5cGUuaXNQcm90b3R5cGVPZihib2R5KSB8fCBpc0FycmF5QnVmZmVyVmlldyhib2R5KSkpIHsKICAgICAgICAgICAgICAgIHRoaXMuX2JvZHlBcnJheUJ1ZmZlciA9IGJ1ZmZlckNsb25lKGJvZHkpOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICB0aGlzLl9ib2R5VGV4dCA9IGJvZHkgPSBPYmplY3QucHJvdG90eXBlLnRvU3RyaW5nLmNhbGwoYm9keSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmICghdGhpcy5oZWFkZXJzLmdldCgiY29udGVudC10eXBlIikpIHsKICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgYm9keSA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgdGhpcy5oZWFkZXJzLnNldCgiY29udGVudC10eXBlIiwgInRleHQvcGxhaW47Y2hhcnNldD1VVEYtOCIpOwogICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0aGlzLl9ib2R5QmxvYiAmJiB0aGlzLl9ib2R5QmxvYi50eXBlKSB7CiAgICAgICAgICAgICAgICAgIHRoaXMuaGVhZGVycy5zZXQoImNvbnRlbnQtdHlwZSIsIHRoaXMuX2JvZHlCbG9iLnR5cGUpOwogICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzdXBwb3J0LnNlYXJjaFBhcmFtcyAmJiBVUkxTZWFyY2hQYXJhbXMucHJvdG90eXBlLmlzUHJvdG90eXBlT2YoYm9keSkpIHsKICAgICAgICAgICAgICAgICAgdGhpcy5oZWFkZXJzLnNldCgiY29udGVudC10eXBlIiwgImFwcGxpY2F0aW9uL3gtd3d3LWZvcm0tdXJsZW5jb2RlZDtjaGFyc2V0PVVURi04Iik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9OwogICAgICAgICAgICBpZiAoc3VwcG9ydC5ibG9iKSB7CiAgICAgICAgICAgICAgdGhpcy5ibG9iID0gZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICB2YXIgcmVqZWN0ZWQgPSBjb25zdW1lZCh0aGlzKTsKICAgICAgICAgICAgICAgIGlmIChyZWplY3RlZCkgewogICAgICAgICAgICAgICAgICByZXR1cm4gcmVqZWN0ZWQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAodGhpcy5fYm9keUJsb2IpIHsKICAgICAgICAgICAgICAgICAgcmV0dXJuIFByb21pc2UucmVzb2x2ZSh0aGlzLl9ib2R5QmxvYik7CiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX2JvZHlBcnJheUJ1ZmZlcikgewogICAgICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZXNvbHZlKG5ldyBCbG9iKFt0aGlzLl9ib2R5QXJyYXlCdWZmZXJdKSk7CiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX2JvZHlGb3JtRGF0YSkgewogICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoImNvdWxkIG5vdCByZWFkIEZvcm1EYXRhIGJvZHkgYXMgYmxvYiIpOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgcmV0dXJuIFByb21pc2UucmVzb2x2ZShuZXcgQmxvYihbdGhpcy5fYm9keVRleHRdKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICB0aGlzLmFycmF5QnVmZmVyID0gZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICBpZiAodGhpcy5fYm9keUFycmF5QnVmZmVyKSB7CiAgICAgICAgICAgICAgICAgIHJldHVybiBjb25zdW1lZCh0aGlzKSB8fCBQcm9taXNlLnJlc29sdmUodGhpcy5fYm9keUFycmF5QnVmZmVyKTsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmJsb2IoKS50aGVuKHJlYWRCbG9iQXNBcnJheUJ1ZmZlcik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnRleHQgPSBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICB2YXIgcmVqZWN0ZWQgPSBjb25zdW1lZCh0aGlzKTsKICAgICAgICAgICAgICBpZiAocmVqZWN0ZWQpIHsKICAgICAgICAgICAgICAgIHJldHVybiByZWplY3RlZDsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHRoaXMuX2JvZHlCbG9iKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gcmVhZEJsb2JBc1RleHQodGhpcy5fYm9keUJsb2IpOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5fYm9keUFycmF5QnVmZmVyKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZXNvbHZlKHJlYWRBcnJheUJ1ZmZlckFzVGV4dCh0aGlzLl9ib2R5QXJyYXlCdWZmZXIpKTsKICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX2JvZHlGb3JtRGF0YSkgewogICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJjb3VsZCBub3QgcmVhZCBGb3JtRGF0YSBib2R5IGFzIHRleHQiKTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgcmV0dXJuIFByb21pc2UucmVzb2x2ZSh0aGlzLl9ib2R5VGV4dCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9OwogICAgICAgICAgICBpZiAoc3VwcG9ydC5mb3JtRGF0YSkgewogICAgICAgICAgICAgIHRoaXMuZm9ybURhdGEgPSBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnRleHQoKS50aGVuKGRlY29kZSk7CiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLmpzb24gPSBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICByZXR1cm4gdGhpcy50ZXh0KCkudGhlbihKU09OLnBhcnNlKTsKICAgICAgICAgICAgfTsKICAgICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgICB9CiAgICAgICAgICB2YXIgbWV0aG9kcyA9IFsiREVMRVRFIiwgIkdFVCIsICJIRUFEIiwgIk9QVElPTlMiLCAiUE9TVCIsICJQVVQiXTsKICAgICAgICAgIGZ1bmN0aW9uIG5vcm1hbGl6ZU1ldGhvZChtZXRob2QpIHsKICAgICAgICAgICAgdmFyIHVwY2FzZWQgPSBtZXRob2QudG9VcHBlckNhc2UoKTsKICAgICAgICAgICAgcmV0dXJuIG1ldGhvZHMuaW5kZXhPZih1cGNhc2VkKSA+IC0xID8gdXBjYXNlZCA6IG1ldGhvZDsKICAgICAgICAgIH0KICAgICAgICAgIGZ1bmN0aW9uIFJlcXVlc3QoaW5wdXQsIG9wdGlvbnMpIHsKICAgICAgICAgICAgb3B0aW9ucyA9IG9wdGlvbnMgfHwge307CiAgICAgICAgICAgIHZhciBib2R5ID0gb3B0aW9ucy5ib2R5OwogICAgICAgICAgICBpZiAoaW5wdXQgaW5zdGFuY2VvZiBSZXF1ZXN0KSB7CiAgICAgICAgICAgICAgaWYgKGlucHV0LmJvZHlVc2VkKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCJBbHJlYWR5IHJlYWQiKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy51cmwgPSBpbnB1dC51cmw7CiAgICAgICAgICAgICAgdGhpcy5jcmVkZW50aWFscyA9IGlucHV0LmNyZWRlbnRpYWxzOwogICAgICAgICAgICAgIGlmICghb3B0aW9ucy5oZWFkZXJzKSB7CiAgICAgICAgICAgICAgICB0aGlzLmhlYWRlcnMgPSBuZXcgSGVhZGVycyhpbnB1dC5oZWFkZXJzKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy5tZXRob2QgPSBpbnB1dC5tZXRob2Q7CiAgICAgICAgICAgICAgdGhpcy5tb2RlID0gaW5wdXQubW9kZTsKICAgICAgICAgICAgICB0aGlzLnNpZ25hbCA9IGlucHV0LnNpZ25hbDsKICAgICAgICAgICAgICBpZiAoIWJvZHkgJiYgaW5wdXQuX2JvZHlJbml0ICE9IG51bGwpIHsKICAgICAgICAgICAgICAgIGJvZHkgPSBpbnB1dC5fYm9keUluaXQ7CiAgICAgICAgICAgICAgICBpbnB1dC5ib2R5VXNlZCA9IHRydWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRoaXMudXJsID0gU3RyaW5nKGlucHV0KTsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLmNyZWRlbnRpYWxzID0gb3B0aW9ucy5jcmVkZW50aWFscyB8fCB0aGlzLmNyZWRlbnRpYWxzIHx8ICJzYW1lLW9yaWdpbiI7CiAgICAgICAgICAgIGlmIChvcHRpb25zLmhlYWRlcnMgfHwgIXRoaXMuaGVhZGVycykgewogICAgICAgICAgICAgIHRoaXMuaGVhZGVycyA9IG5ldyBIZWFkZXJzKG9wdGlvbnMuaGVhZGVycyk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGhpcy5tZXRob2QgPSBub3JtYWxpemVNZXRob2Qob3B0aW9ucy5tZXRob2QgfHwgdGhpcy5tZXRob2QgfHwgIkdFVCIpOwogICAgICAgICAgICB0aGlzLm1vZGUgPSBvcHRpb25zLm1vZGUgfHwgdGhpcy5tb2RlIHx8IG51bGw7CiAgICAgICAgICAgIHRoaXMuc2lnbmFsID0gb3B0aW9ucy5zaWduYWwgfHwgdGhpcy5zaWduYWw7CiAgICAgICAgICAgIHRoaXMucmVmZXJyZXIgPSBudWxsOwogICAgICAgICAgICBpZiAoKHRoaXMubWV0aG9kID09PSAiR0VUIiB8fCB0aGlzLm1ldGhvZCA9PT0gIkhFQUQiKSAmJiBib2R5KSB7CiAgICAgICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcigiQm9keSBub3QgYWxsb3dlZCBmb3IgR0VUIG9yIEhFQUQgcmVxdWVzdHMiKTsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLl9pbml0Qm9keShib2R5KTsKICAgICAgICAgIH0KICAgICAgICAgIFJlcXVlc3QucHJvdG90eXBlLmNsb25lID0gZnVuY3Rpb24oKSB7CiAgICAgICAgICAgIHJldHVybiBuZXcgUmVxdWVzdCh0aGlzLCB7IGJvZHk6IHRoaXMuX2JvZHlJbml0IH0pOwogICAgICAgICAgfTsKICAgICAgICAgIGZ1bmN0aW9uIGRlY29kZShib2R5KSB7CiAgICAgICAgICAgIHZhciBmb3JtID0gbmV3IEZvcm1EYXRhKCk7CiAgICAgICAgICAgIGJvZHkudHJpbSgpLnNwbGl0KCImIikuZm9yRWFjaChmdW5jdGlvbihieXRlcykgewogICAgICAgICAgICAgIGlmIChieXRlcykgewogICAgICAgICAgICAgICAgdmFyIHNwbGl0ID0gYnl0ZXMuc3BsaXQoIj0iKTsKICAgICAgICAgICAgICAgIHZhciBuYW1lID0gc3BsaXQuc2hpZnQoKS5yZXBsYWNlKC9cKy9nLCAiICIpOwogICAgICAgICAgICAgICAgdmFyIHZhbHVlID0gc3BsaXQuam9pbigiPSIpLnJlcGxhY2UoL1wrL2csICIgIik7CiAgICAgICAgICAgICAgICBmb3JtLmFwcGVuZChkZWNvZGVVUklDb21wb25lbnQobmFtZSksIGRlY29kZVVSSUNvbXBvbmVudCh2YWx1ZSkpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIHJldHVybiBmb3JtOwogICAgICAgICAgfQogICAgICAgICAgZnVuY3Rpb24gcGFyc2VIZWFkZXJzKHJhd0hlYWRlcnMpIHsKICAgICAgICAgICAgdmFyIGhlYWRlcnMgPSBuZXcgSGVhZGVycygpOwogICAgICAgICAgICB2YXIgcHJlUHJvY2Vzc2VkSGVhZGVycyA9IHJhd0hlYWRlcnMucmVwbGFjZSgvXHI/XG5bXHQgXSsvZywgIiAiKTsKICAgICAgICAgICAgcHJlUHJvY2Vzc2VkSGVhZGVycy5zcGxpdCgvXHI/XG4vKS5mb3JFYWNoKGZ1bmN0aW9uKGxpbmUpIHsKICAgICAgICAgICAgICB2YXIgcGFydHMgPSBsaW5lLnNwbGl0KCI6Iik7CiAgICAgICAgICAgICAgdmFyIGtleSA9IHBhcnRzLnNoaWZ0KCkudHJpbSgpOwogICAgICAgICAgICAgIGlmIChrZXkpIHsKICAgICAgICAgICAgICAgIHZhciB2YWx1ZSA9IHBhcnRzLmpvaW4oIjoiKS50cmltKCk7CiAgICAgICAgICAgICAgICBoZWFkZXJzLmFwcGVuZChrZXksIHZhbHVlKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICByZXR1cm4gaGVhZGVyczsKICAgICAgICAgIH0KICAgICAgICAgIEJvZHkuY2FsbChSZXF1ZXN0LnByb3RvdHlwZSk7CiAgICAgICAgICBmdW5jdGlvbiBSZXNwb25zZShib2R5SW5pdCwgb3B0aW9ucykgewogICAgICAgICAgICBpZiAoIW9wdGlvbnMpIHsKICAgICAgICAgICAgICBvcHRpb25zID0ge307CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGhpcy50eXBlID0gImRlZmF1bHQiOwogICAgICAgICAgICB0aGlzLnN0YXR1cyA9IG9wdGlvbnMuc3RhdHVzID09PSB2b2lkIDAgPyAyMDAgOiBvcHRpb25zLnN0YXR1czsKICAgICAgICAgICAgdGhpcy5vayA9IHRoaXMuc3RhdHVzID49IDIwMCAmJiB0aGlzLnN0YXR1cyA8IDMwMDsKICAgICAgICAgICAgdGhpcy5zdGF0dXNUZXh0ID0gInN0YXR1c1RleHQiIGluIG9wdGlvbnMgPyBvcHRpb25zLnN0YXR1c1RleHQgOiAiT0siOwogICAgICAgICAgICB0aGlzLmhlYWRlcnMgPSBuZXcgSGVhZGVycyhvcHRpb25zLmhlYWRlcnMpOwogICAgICAgICAgICB0aGlzLnVybCA9IG9wdGlvbnMudXJsIHx8ICIiOwogICAgICAgICAgICB0aGlzLl9pbml0Qm9keShib2R5SW5pdCk7CiAgICAgICAgICB9CiAgICAgICAgICBCb2R5LmNhbGwoUmVzcG9uc2UucHJvdG90eXBlKTsKICAgICAgICAgIFJlc3BvbnNlLnByb3RvdHlwZS5jbG9uZSA9IGZ1bmN0aW9uKCkgewogICAgICAgICAgICByZXR1cm4gbmV3IFJlc3BvbnNlKHRoaXMuX2JvZHlJbml0LCB7CiAgICAgICAgICAgICAgc3RhdHVzOiB0aGlzLnN0YXR1cywKICAgICAgICAgICAgICBzdGF0dXNUZXh0OiB0aGlzLnN0YXR1c1RleHQsCiAgICAgICAgICAgICAgaGVhZGVyczogbmV3IEhlYWRlcnModGhpcy5oZWFkZXJzKSwKICAgICAgICAgICAgICB1cmw6IHRoaXMudXJsCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfTsKICAgICAgICAgIFJlc3BvbnNlLmVycm9yID0gZnVuY3Rpb24oKSB7CiAgICAgICAgICAgIHZhciByZXNwb25zZSA9IG5ldyBSZXNwb25zZShudWxsLCB7IHN0YXR1czogMCwgc3RhdHVzVGV4dDogIiIgfSk7CiAgICAgICAgICAgIHJlc3BvbnNlLnR5cGUgPSAiZXJyb3IiOwogICAgICAgICAgICByZXR1cm4gcmVzcG9uc2U7CiAgICAgICAgICB9OwogICAgICAgICAgdmFyIHJlZGlyZWN0U3RhdHVzZXMgPSBbMzAxLCAzMDIsIDMwMywgMzA3LCAzMDhdOwogICAgICAgICAgUmVzcG9uc2UucmVkaXJlY3QgPSBmdW5jdGlvbih1cmwsIHN0YXR1cykgewogICAgICAgICAgICBpZiAocmVkaXJlY3RTdGF0dXNlcy5pbmRleE9mKHN0YXR1cykgPT09IC0xKSB7CiAgICAgICAgICAgICAgdGhyb3cgbmV3IFJhbmdlRXJyb3IoIkludmFsaWQgc3RhdHVzIGNvZGUiKTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gbmV3IFJlc3BvbnNlKG51bGwsIHsgc3RhdHVzLCBoZWFkZXJzOiB7IGxvY2F0aW9uOiB1cmwgfSB9KTsKICAgICAgICAgIH07CiAgICAgICAgICBleHBvcnRzMi5ET01FeGNlcHRpb24gPSBzZWxmMi5ET01FeGNlcHRpb247CiAgICAgICAgICB0cnkgewogICAgICAgICAgICBuZXcgZXhwb3J0czIuRE9NRXhjZXB0aW9uKCk7CiAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgZXhwb3J0czIuRE9NRXhjZXB0aW9uID0gZnVuY3Rpb24obWVzc2FnZSwgbmFtZSkgewogICAgICAgICAgICAgIHRoaXMubWVzc2FnZSA9IG1lc3NhZ2U7CiAgICAgICAgICAgICAgdGhpcy5uYW1lID0gbmFtZTsKICAgICAgICAgICAgICB2YXIgZXJyb3IgPSBFcnJvcihtZXNzYWdlKTsKICAgICAgICAgICAgICB0aGlzLnN0YWNrID0gZXJyb3Iuc3RhY2s7CiAgICAgICAgICAgIH07CiAgICAgICAgICAgIGV4cG9ydHMyLkRPTUV4Y2VwdGlvbi5wcm90b3R5cGUgPSBPYmplY3QuY3JlYXRlKEVycm9yLnByb3RvdHlwZSk7CiAgICAgICAgICAgIGV4cG9ydHMyLkRPTUV4Y2VwdGlvbi5wcm90b3R5cGUuY29uc3RydWN0b3IgPSBleHBvcnRzMi5ET01FeGNlcHRpb247CiAgICAgICAgICB9CiAgICAgICAgICBmdW5jdGlvbiBmZXRjaDIoaW5wdXQsIGluaXQyKSB7CiAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZShmdW5jdGlvbihyZXNvbHZlLCByZWplY3QpIHsKICAgICAgICAgICAgICB2YXIgcmVxdWVzdCA9IG5ldyBSZXF1ZXN0KGlucHV0LCBpbml0Mik7CiAgICAgICAgICAgICAgaWYgKHJlcXVlc3Quc2lnbmFsICYmIHJlcXVlc3Quc2lnbmFsLmFib3J0ZWQpIHsKICAgICAgICAgICAgICAgIHJldHVybiByZWplY3QobmV3IGV4cG9ydHMyLkRPTUV4Y2VwdGlvbigiQWJvcnRlZCIsICJBYm9ydEVycm9yIikpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB2YXIgeGhyID0gbmV3IFhNTEh0dHBSZXF1ZXN0KCk7CiAgICAgICAgICAgICAgZnVuY3Rpb24gYWJvcnRYaHIoKSB7CiAgICAgICAgICAgICAgICB4aHIuYWJvcnQoKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgeGhyLm9ubG9hZCA9IGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgdmFyIG9wdGlvbnMgPSB7CiAgICAgICAgICAgICAgICAgIHN0YXR1czogeGhyLnN0YXR1cywKICAgICAgICAgICAgICAgICAgc3RhdHVzVGV4dDogeGhyLnN0YXR1c1RleHQsCiAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHBhcnNlSGVhZGVycyh4aHIuZ2V0QWxsUmVzcG9uc2VIZWFkZXJzKCkgfHwgIiIpCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgb3B0aW9ucy51cmwgPSAicmVzcG9uc2VVUkwiIGluIHhociA/IHhoci5yZXNwb25zZVVSTCA6IG9wdGlvbnMuaGVhZGVycy5nZXQoIlgtUmVxdWVzdC1VUkwiKTsKICAgICAgICAgICAgICAgIHZhciBib2R5ID0gInJlc3BvbnNlIiBpbiB4aHIgPyB4aHIucmVzcG9uc2UgOiB4aHIucmVzcG9uc2VUZXh0OwogICAgICAgICAgICAgICAgcmVzb2x2ZShuZXcgUmVzcG9uc2UoYm9keSwgb3B0aW9ucykpOwogICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgeGhyLm9uZXJyb3IgPSBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgIHJlamVjdChuZXcgVHlwZUVycm9yKCJOZXR3b3JrIHJlcXVlc3QgZmFpbGVkIikpOwogICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgeGhyLm9udGltZW91dCA9IGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgcmVqZWN0KG5ldyBUeXBlRXJyb3IoIk5ldHdvcmsgcmVxdWVzdCBmYWlsZWQiKSk7CiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICB4aHIub25hYm9ydCA9IGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgcmVqZWN0KG5ldyBleHBvcnRzMi5ET01FeGNlcHRpb24oIkFib3J0ZWQiLCAiQWJvcnRFcnJvciIpKTsKICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgIHhoci5vcGVuKHJlcXVlc3QubWV0aG9kLCByZXF1ZXN0LnVybCwgdHJ1ZSk7CiAgICAgICAgICAgICAgaWYgKHJlcXVlc3QuY3JlZGVudGlhbHMgPT09ICJpbmNsdWRlIikgewogICAgICAgICAgICAgICAgeGhyLndpdGhDcmVkZW50aWFscyA9IHRydWU7CiAgICAgICAgICAgICAgfSBlbHNlIGlmIChyZXF1ZXN0LmNyZWRlbnRpYWxzID09PSAib21pdCIpIHsKICAgICAgICAgICAgICAgIHhoci53aXRoQ3JlZGVudGlhbHMgPSBmYWxzZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKCJyZXNwb25zZVR5cGUiIGluIHhociAmJiBzdXBwb3J0LmJsb2IpIHsKICAgICAgICAgICAgICAgIHhoci5yZXNwb25zZVR5cGUgPSAiYmxvYiI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHJlcXVlc3QuaGVhZGVycy5mb3JFYWNoKGZ1bmN0aW9uKHZhbHVlLCBuYW1lKSB7CiAgICAgICAgICAgICAgICB4aHIuc2V0UmVxdWVzdEhlYWRlcihuYW1lLCB2YWx1ZSk7CiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgaWYgKHJlcXVlc3Quc2lnbmFsKSB7CiAgICAgICAgICAgICAgICByZXF1ZXN0LnNpZ25hbC5hZGRFdmVudExpc3RlbmVyKCJhYm9ydCIsIGFib3J0WGhyKTsKICAgICAgICAgICAgICAgIHhoci5vbnJlYWR5c3RhdGVjaGFuZ2UgPSBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgICAgaWYgKHhoci5yZWFkeVN0YXRlID09PSA0KSB7CiAgICAgICAgICAgICAgICAgICAgcmVxdWVzdC5zaWduYWwucmVtb3ZlRXZlbnRMaXN0ZW5lcigiYWJvcnQiLCBhYm9ydFhocik7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHhoci5zZW5kKHR5cGVvZiByZXF1ZXN0Ll9ib2R5SW5pdCA9PT0gInVuZGVmaW5lZCIgPyBudWxsIDogcmVxdWVzdC5fYm9keUluaXQpOwogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICAgIGZldGNoMi5wb2x5ZmlsbCA9IHRydWU7CiAgICAgICAgICBpZiAoIXNlbGYyLmZldGNoKSB7CiAgICAgICAgICA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dW5jdGlvbiBtYWtlT3B0cyhvYmogPSB7fSkgewogICAgcmV0dXJuICJhYm9ydGVkIiBpbiBvYmogPyB7IHNpZ25hbDogb2JqIH0gOiBvYmo7CiAgfQogIGZ1bmN0aW9uIG9wdGltaXplQ2h1bmtzKGNodW5rcywgbG93ZXN0KSB7CiAgICBjb25zdCBtZXJnZWRDaHVua3MgPSBbXTsKICAgIGxldCBsYXN0Q2h1bmsgPSBudWxsOwogICAgaWYgKGNodW5rcy5sZW5ndGggPT09IDApIHsKICAgICAgcmV0dXJuIGNodW5rczsKICAgIH0KICAgIGNodW5rcy5zb3J0KChjMCwgYzEpID0+IHsKICAgICAgY29uc3QgZGlmID0gYzAubWludi5ibG9ja1Bvc2l0aW9uIC0gYzEubWludi5ibG9ja1Bvc2l0aW9uOwogICAgICBpZiAoZGlmICE9PSAwKSB7CiAgICAgICAgcmV0dXJuIGRpZjsKICAgICAgfSBlbHNlIHsKICAgICAgICByZXR1cm4gYzAubWludi5kYXRhUG9zaXRpb24gLSBjMS5taW52LmRhdGFQb3NpdGlvbjsKICAgICAgfQogICAgfSk7CiAgICBjaHVua3MuZm9yRWFjaCgoY2h1bmspID0+IHsKICAgICAgaWYgKCFsb3dlc3QgfHwgY2h1bmsubWF4di5jb21wYXJlVG8obG93ZXN0KSA+IDApIHsKICAgICAgICBpZiAobGFzdENodW5rID09PSBudWxsKSB7CiAgICAgICAgICBtZXJnZWRDaHVua3MucHVzaChjaHVuayk7CiAgICAgICAgICBsYXN0Q2h1bmsgPSBjaHVuazsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgaWYgKGNhbk1lcmdlQmxvY2tzKGxhc3RDaHVuaywgY2h1bmspKSB7CiAgICAgICAgICAgIGlmIChjaHVuay5tYXh2LmNvbXBhcmVUbyhsYXN0Q2h1bmsubWF4dikgPiAwKSB7CiAgICAgICAgICAgICAgbGFzdENodW5rLm1heHYgPSBjaHVuay5tYXh2OwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2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yB8fCB7fTsKICAgICAgcmV0dXJuIHJldC5saW5lQ291bnQgPT09IHZvaWQgMCA/IC0xIDogcmV0LmxpbmVDb3VudDsKICAgIH0KICAgIGZldGNoQmFpKG9wdHMgPSB7fSkgewogICAgICBpZiAoIXRoaXMuYmFpUCkgewogICAgICAgIHRoaXMuYmFpUCA9IHRoaXMuZmlsZWhhbmRsZS5yZWFkRmlsZShvcHRzKS5jYXRjaCgoZSkgPT4gewogICAgICAgICAgdGhpcy5iYWlQID0gdm9pZCAwOwogICAgICAgICAgdGhyb3cgZTsKICAgICAgICB9KTsKICAgICAgfQogICAgICByZXR1cm4gdGhpcy5iYWlQOwogICAgfQogICAgYXN5bmMgX3BhcnNlKCkgewogICAgICBjb25zdCBkYXRhID0geyBiYWk6IHRydWUsIG1heEJsb2NrU2l6ZTogMSA8PCAxNiB9OwogICAgICBjb25zdCBieXRlcyA9IGF3YWl0IHRoaXMuZmV0Y2hCYWkoKTsKICAgICAgaWYgKGJ5dGVzLnJlYWRVSW50MzJMRSgwKSAhPT0gQkFJX01BR0lDKSB7CiAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJOb3QgYSBCQUkgZmlsZSIpOwogICAgICB9CiAgICAgIGRhdGEucmVmQ291bnQgPSBieXRlcy5yZWFkSW50MzJMRSg0KTsKICAgICAgY29uc3QgZGVwdGggPSA1OwogICAgICBjb25zdCBiaW5MaW1pdCA9ICgoMSA8PCAoZGVwdGggKyAxKSAqIDMpIC0gMSkgLyA3OwogICAgICBkYXRhLmluZGljZXMgPSBuZXcgQXJyYXkoZGF0YS5yZWZDb3VudCk7CiAgICAgIGxldCBjdXJyT2Zmc2V0ID0gODsKICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBkYXRhLnJlZkNvdW50OyBpICs9IDEpIHsKICAgICAgICBjb25zdCBiaW5Db3VudCA9IGJ5dGVzLnJlYWRJbnQzMkxFKGN1cnJPZmZzZXQpOwogICAgICAgIGxldCBzdGF0czsKICAgICAgICBjdXJyT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RhdGEsIHUpOwogICAgICAgICAgICAgIGNodW5rc1trXSA9IG5ldyBDaHVuayh1LCB2LCBiaW4pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJpbkluZGV4W2Jpbl0gPSBjaHVua3M7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGNvbnN0IGxpbmVhckNvdW50ID0gYnl0ZXMucmVhZEludDMyTEUoY3Vyck9mZnNldCk7CiAgICAgICAgY3Vyck9mZnNldCArPSA0OwogICAgICAgIGNvbnN0IGxpbmVhckluZGV4ID0gbmV3IEFycmF5KGxpbmVhckNvdW50KTsKICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IGxpbmVhckNvdW50OyBrICs9IDEpIHsKICAgICAgICAgIGxpbmVhckluZGV4W2tdID0gZnJvbUJ5dGVzKGJ5dGVzLCBjdXJyT2Zmc2V0KTsKICAgICAgICAgIGN1cnJPZmZzZXQgKz0gODsKICAgICAgICAgIHRoaXMuX2ZpbmRGaXJzdERhdGEoZGF0YSwgbGluZWFySW5kZXhba10pOwogICAgICAgIH0KICAgICAgICBkYXRhLmluZGljZXNbaV0gPSB7IGJpbkluZGV4LCBsaW5lYXJJbmRleCwgc3RhdHMgfTsKICAgICAgfQogICAgICByZXR1cm4gZGF0YTsKICAgIH0KICAgIGFzeW5jIGluZGV4Q292KHNlcUlkLCBzdGFydCwgZW5kLCBvcHRzID0ge30pIHsKICAgICAgY29uc3QgdiA9IDE2Mzg0OwogICAgICBjb25zdCByYW5nZSA9IHN0YXJ0ICE9PSB2b2lkIDA7CiAgICAgIGNvbnN0IGluZGV4RGF0YSA9IGF3YWl0IHRoaXMucGFyc2Uob3B0cyk7CiAgICAgIGNvbnN0IHNlcUlkeCA9IGluZGV4RGF0YS5pbmRpY2VzW3NlcUlkXTsKICAgICAgaWYgKCFzZXFJZHgpIHsKICAgICAgICByZXR1cm4gW107CiAgICAgIH0KICAgICAgY29uc3QgeyBsaW5lYXJJbmRleCA9IFtdLCBzdGF0cyB9ID0gc2VxSWR4OwogICAgICBpZiAoIWxpbmVhckluZGV4Lmxlbmd0aCkgewogICAgICAgIHJldHVybiBbXTsKICAgICAgfQogICAgICBjb25zdCBlID0gZW5kICE9PSB2b2lkIDAgPyByb3VuZFVwKGVuZCwgdikgOiAobGluZWFySW5kZXgubGVuZ3RoIC0gMSkgKiB2OwogICAgICBjb25zdCBzID0gc3RhcnQgIT09IHZvaWQgMCA/IHJvdW5kRG93bihzdGFydCwgdikgOiAwOwogICAgICBsZXQgZGVwdGhzOwogICAgICBpZiAocmFuZ2UpIHsKICAgICAgICBkZXB0aHMgPSBuZXcgQXJyYXkoKGUgLSBzKSAvIHYpOwogICAgICB9IGVsc2UgewogICAgICAgIGRlcHRocyA9IG5ldyBBcnJheShsaW5lYXJJbmRleC5sZW5ndGggLSAxKTsKICAgICAgfQogICAgICBjb25zdCB0b3RhbFNpemUgPSBsaW5lYXJJbmRleFtsaW5lYXJJbmRleC5sZW5ndGggLSAxXS5ibG9ja1Bvc2l0aW9uOwogICAgICBpZiAoZSA+IChsaW5lYXJJbmRleC5sZW5ndGggLSAxKSAqIHYpIHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoInF1ZXJ5IG91dHNpZGUgb2YgcmFuZ2Ugb2YgbGluZWFyIGluZGV4Iik7CiAgICAgIH0KICAgICAgbGV0IGN1cnJlbnRQb3MgPSBsaW5lYXJJbmRleFtzIC8gdl0uYmxvY2tQb3NpdGlvbjsKICAgICAgZm9yIChsZXQgaSA9IHMgLyB2LCBqID0gMDsgaSA8IGUgLyB2OyBpKyssIGorKykgewogICAgICAgIGRlcHRoc1tqXSA9IHsKICAgICAgICAgIHNjb3JlOiBsaW5lYXJJbmRleFtpICsgMV0uYmxvY2tQb3NpdGlvbiAtIGN1cnJlbnRQb3MsCiAgICAgICAgICBzdGFydDogaSAqIHYsCiAgICAgICAgICBlbmQ6IGkgKiB2ICsgdgogICAgICAgIH07CiAgICAgICAgY3VycmVudFBvcyA9IGxpbmVhckluZGV4W2kgKyAxXS5ibG9ja1Bvc2l0aW9uOwogICAgICB9CiAgICAgIHJldHVybiBkZXB0aHMubWFwKChkKSA9PiB7CiAgICAgICAgcmV0dXJuIHsgLi4uZCwgc2NvcmU6IGQuc2NvcmUgKiBzdGF0cy5saW5lQ291bnQgLyB0b3RhbFNpemUgfTsKICAgICAgfSk7CiAgICB9CiAgICByZWcyYmlucyhiZWcsIGVuZCkgewogICAgICBlbmQgLT0gMTsKICAgICAgcmV0dXJuIFsKICAgICAgICBbMCwgMF0sCiAgICAgICAgWzEgKyAoYmVnID4+IDI2KSwgMSArIChlbmQgPj4gMjYpXSwKICAgICAgICBbOSArIChiZWcgPj4gMjMpLCA5ICsgKGVuZCA+PiAyMyldLAogICAgICAgIFs3MyArIChiZWcgPj4gMjApLCA3MyArIChlbmQgPj4gMjApXSwKICAgICAgICBbNTg1ICsgKGJlZyA+PiAxNyksIDU4NSArIChlbmQgPj4gMTcpXSwKICAgICAgICBbNDY4MSArIChiZWcgPj4gMTQpLCA0NjgxICsgKGVuZCA+PiAxNCldCiAgICAgIF07CiAgICB9CiAgICBhc3luYyBibG9ja3NGb3JSYW5nZShyZWZJZCwgbWluLCBtYXgsIG9wdHMgPSB7fSkgewogICAgICBpZiAobWluIDwgMCkgewogICAgICAgIG1pbiA9IDA7CiAgICAgIH0KICAgICAgY29uc3QgaW5kZXhEYXRhID0gYXdhaXQgdGhpcy5wYXJzZShvcHRzKTsKICAgICAgaWYgKCFpbmRleERhdGEpIHsKICAgICAgICByZXR1cm4gW107CiAgICAgIH0KICAgICAgY29uc3QgYmEgPSBpbmRleERhdGEuaW5kaWNlc1tyZWZJZF07CiAgICAgIGlmICghYmEpIHsKICAgICAgICByZXR1cm4gW107CiAgICAgIH0KICAgICAgY29uc3Qgb3ZlcmxhcHBpbmdCaW5zID0gdGhpcy5yZWcyYmlucyhtaW4sIG1heCk7CiAgICAgIGNvbnN0IGNodW5rcyA9IFtdOwogICAgICBmb3IgKGNvbnN0IFtzdGFydCwgZW5kXSBvZiBvdmVybGFwcGluZ0JpbnMpIHsKICAgICAgICBmb3IgKGxldCBiaW4gPSBzdGFydDsgYmluIDw9IGVuZDsgYmluKyspIHsKICAgICAgICAgIGlmIChiYS5iaW5JbmRleFtiaW5dKSB7CiAgICAgICAgICAgIGNvbnN0IGJpbkNodW5rcyA9IGJhLmJpbkluZGV4W2Jpbl07CiAgICAgICAgICAgIGZvciAobGV0IGMgPSAwOyBjIDwgYmluQ2h1bmtzLmxlbmd0aDsgKytjKSB7CiAgICAgICAgICAgICAgY2h1bmtzLnB1c2gobmV3IENodW5rKGJpbkNodW5rc1tjXS5taW52LCBiaW5DaHVua3NbY10ubWF4diwgYmluKSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgY29uc3QgbmludHYgPSBiYS5saW5lYXJJbmRleC5sZW5ndGg7CiAgICAgIGxldCBsb3dlc3QgPSBudWxsOwogICAgICBjb25zdCBtaW5MaW4gPSBNYXRoLm1pbihtaW4gPj4gMTQsIG5pbnR2IC0gMSk7CiAgICAgIGNvbnN0IG1heExpbiA9IE1hdGgubWluKG1heCA+PiAxNCwgbmludHYgLSAxKTsKICAgICAgZm9yIChsZXQgaSA9IG1pbkxpbjsgaSA8PSBtYXhMaW47ICsraSkgewogICAgICAgIGNvbnN0IHZwID0gYmEubGluZWFySW5kZXhbaV07CiAgICAgICAgaWYgKHZwKSB7CiAgICAgICAgICBpZiAoIWxvd2VzdCB8fCB2cC5jb21wYXJlVG8obG93ZXN0KSA8IDApIHsKICAgICAgICAgICAgbG93ZXN0ID0gdnA7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiBvcHRpbWl6ZUNodW5rcyhjaHVua3MsIGxvd2VzdCk7CiAgICB9CiAgfTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5wbnBtL0BnbW9kK2JhbUAxLjEuMTgvbm9kZV9tb2R1bGVzL0BnbW9kL2JhbS9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GluaXQyKSB7CiAgICAgIGxldCByZXNwb25zZTsKICAgICAgdHJ5IHsKICAgICAgICByZXNwb25zZSA9IGF3YWl0IHRoaXMuZmV0Y2hJbXBsZW1lbnRhdGlvbihpbnB1dCwgaW5pdDIpOwogICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgaWYgKGAke2V9YC5pbmNsdWRlcygiRmFpbGVkIHRvIGZldGNoIikpIHsKICAgICAgICAgIGNvbnNvbGUud2FybihgZ2VuZXJpYy1maWxlaGFuZGxlOiByZWZldGNoaW5nICR7aW5wdXR9IHRvIGF0dGVtcHQgdG8gd29yayBhcm91bmQgY2hyb21lIENPUlMgaGVhZGVyIGNhY2hpbmcgYnVnYCk7CiAgICAgICAgICByZXNwb25zZSA9IGF3YWl0IHRoaXMuZmV0Y2hJbXBsZW1lbnRhdGlvbihpbnB1dCwgewogICAgICAgICAgICAuLi5pbml0MiwKICAgICAgICAgICAgY2FjaGU6ICJyZWxvYWQiCiAgICAgICAgICB9KTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgdGhyb3cgZTsKICAgICAgICB9CiAgICAgIH0KICAgICAgcmV0dXJuIHJlc3BvbnNlOwogICAgfQogICAgYXN5bmMgcmVhZChidWZmZXIsIG9mZnNldCA9IDAsIGxlbmd0aCwgcG9zaXRpb24gPSAwLCBvcHRzID0ge30pIHsKICAgICAgY29uc3QgeyBoZWFkZXJzID0ge30sIHNpZ25hbCwgb3ZlcnJpZGVzID0ge30gfSA9IG9wdHM7CiAgICAgIGlmIChsZW5ndGggPCBJbmZpbml0eSkgewogICAgICAgIGhlYWRlcnMucmFuZ2UgPSBgYnl0ZXM9JHtwb3NpdGlvbn0tJHtwb3NpdGlvbiArIGxlbmd0aH1gOwogICAgICB9IGVsc2UgaWYgKGxlbmd0aCA9PT0gSW5maW5pdHkgJiYgcG9zaXRpb24gIT09IDApIHsKICAgICAgICBoZWFkZXJzLnJhbmdlID0gYGJ5dGVzPSR7cG9zaXRpb259LWA7CiAgICAgIH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ICIiKTsKICAgICAgICBpZiAoc2l6ZU1hdGNoICYmIHNpemVNYXRjaFsxXSkgewogICAgICAgICAgdGhpcy5fc3RhdCA9IHsgc2l6ZTogcGFyc2VJbnQoc2l6ZU1hdGNoWzFdLCAxMCkgfTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHsgYnl0ZXNSZWFkOiBieXRlc0NvcGllZCwgYnVmZmVyIH07CiAgICAgIH0KICAgICAgaWYgKHJlc3BvbnNlLnN0YXR1cyA9PT0gMjAwKSB7CiAgICAgICAgdGhyb3cgbmV3IEVycm9yKCIke3RoaXMudXJsfSBmZXRjaCByZXR1cm5lZCBzdGF0dXMgMjAwLCBleHBlY3RlZCAyMDYiKTsKICAgICAgfQogICAgICB0aHJvdyBuZXcgRXJyb3IoYEhUVFAgJHtyZXNwb25zZS5zdGF0dXN9IGZldGNoaW5nICR7dGhpcy51cmx9YCk7CiAgICB9CiAgICBhc3luYyByZWFkRmlsZShvcHRpb25zID0ge30pIHsKICAgICAgbGV0IGVuY29kaW5nOwogICAgICBsZXQgb3B0czsKICAgICAgaWYgKHR5cGVvZiBvcHRpb25zID09PSAic3RyaW5nIikgewogICAgICAgIGVuY29kaW5nID0gb3B0aW9uczsKICAgICAgICBvcHRzID0ge307CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZW5jb2RpbmcgPSBvcHRpb25zLmVuY29kaW5nOwogICAgICAgIG9wdHMgPSBvcHRpb25zOwogICAgICAgIGRlbGV0ZSBvcHRzLmVuY29kaW5nOwogICAgICB9CiAgICAgIGNvbnN0IHsgaGVhZGVycyA9IHt9LCBzaWduYWwsIG92ZXJyaWRlcyA9IHt9IH0gPSBvcHRzOwogICAgICBjb25zdCBhcmdzID0gewogICAgICAgIGhlYWRlcnMsCiAgICAgICAgbWV0aG9kOiAiR0VUIiwKICAgICAgICByZWRpcmVjdDogImZvbGxvdyIsCiAgICAgICAgbW9kZTogImNvcnMiLAogICAgICAgIHNpZ25hbCwKICAgICAgICAuLi50aGl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IH0KICB9CiAgYXN5bmMgZnVuY3Rpb24gdW56aXBDaHVua1NsaWNlKGlucHV0RGF0YSwgY2h1bmspIHsKICAgIHRyeSB7CiAgICAgIGxldCBzdHJtOwogICAgICBjb25zdCB7IG1pbnYsIG1heHYgfSA9IGNodW5rOwogICAgICBsZXQgY3BvcyA9IG1pbnYuYmxvY2tQb3NpdGlvbjsKICAgICAgbGV0IGRwb3MgPSBtaW52LmRhdGFQb3NpdGlvbjsKICAgICAgY29uc3QgY2h1bmtzID0gW107CiAgICAgIGNvbnN0IGNwb3NpdGlvbnMgPSBbXTsKICAgICAgY29uc3QgZHBvc2l0aW9ucyA9IFtdOwogICAgICBsZXQgdG90YWxTaXplID0gMDsKICAgICAgbGV0IGkgPSAwOwogICAgICBkbyB7CiAgICAgICAgY29uc3QgcmVtYWluaW5nSW5wdXQgPSBpbnB1dERhdGEuc3ViYXJyYXkoY3BvcyAtIG1pbnYuYmxvY2tQb3NpdGlvbik7CiAgICAgICAgY29uc3QgaW5mbGF0b3IgPSBuZXcgaW1wb3J0X3Bha28uSW5mbGF0ZSgpOwogICAgICAgICh7IHN0cm0gfSA9IGluZmxhdG9yKTsKICAgICAgICBpbmZsYXRvci5wdXNoKHJlbWFpbmluZ0lucHV0LCBpbXBvcnRfcGFrby5aX1NZTkNfRkxVU0gpOwogICAgICAgIGlmIChpbmZsYXRvci5lcnIpIHsKICAgICAgICAgIHRocm93IG5ldyBFcnJvcihpbmZsYXRvci5tc2cpOwogICAgICAgIH0KICAgICAgICBjb25zdCBidWZmZXIyID0gaW5mbGF0b3IucmVzdWx0OwogICAgICAgIGNodW5rcy5wdXNoKGJ1ZmZlcjIpOwogICAgICAgIGxldCBsZW4gPSBidWZmZXIyLmxlbmd0aDsKICAgICAgICBjcG9zaXRpb25zLnB1c2goY3Bvcyk7CiAgICAgICAgZHBvc2l0aW9ucy5wdXNoKGRwb3MpOwogICAgICAgIGlmIChjaHVua3MubGVuZ3RoID09PSAxICYmIG1pbnYuZGF0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ICAgICAgICAgIGlmIChiaW4gPiB0aGlzLm1heEJpbk51bWJlcikgewogICAgICAgICAgICBzdGF0cyA9IHRoaXMucGFyc2VQc2V1ZG9CaW4oYnl0ZXMsIGN1cnJPZmZzZXQgKyA0KTsKICAgICAgICAgICAgY3Vyck9mZnNldCArPSA0ICsgOCArIDQgKyAxNiArIDE2OwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY29uc3QgbG9mZnNldCA9IGZyb21CeXRlcyhieXRlcywgY3Vyck9mZnNldCArIDQpOwogICAgICAgICAgICB0aGlzLl9maW5kRmlyc3REYXRhKGRhdGEsIGxvZmZzZXQpOwogICAgICAgICAgICBjb25zdCBjaHVua0NvdW50ID0gYnl0ZXMucmVhZEludDMyTEUoY3Vyck9mZnNldCArIDEyKTsKICAgICAgICAgICAgY3Vyck9mZnNldCArPSAxNjsKICAgICAgICAgICAgY29uc3QgY2h1bmtzID0gbmV3IEFycmF5KGNodW5rQ291bnQpOwogICAgICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IGNodW5rQ291bnQ7IGsgKz0gMSkgewogICAgICAgICAgICAgIGNvbnN0IHUgPSBmcm9tQnl0ZXMoYnl0ZXMsIGN1cnJPZmZzZXQpOwogICAgICAgICAgICAgIGNvbnN0IHYgPSBmcm9tQnl0ZXMoYnl0ZXMsIGN1cnJPZmZzZXQgKyA4KTsKICAgICAgICAgICAgICBjdXJyT2Zmc2V0ICs9IDE2OwogICAgICAgICAgICAgIGNodW5rc1trXSA9IG5ldyBDaHVuayh1LCB2LCBiaW4pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJpbkluZGV4W2Jpbl0gPSBjaHVua3M7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGRhdGEuaW5kaWNlc1tpXSA9IHsgYmluSW5kZXgsIHN0YXRzIH07CiAgICAgIH0KICAgICAgcmV0dXJuIGRhdGE7CiAgICB9CiAgICBwYXJzZVBzZXVkb0JpbihieXRlcywgb2Zmc2V0KSB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pbkNodW5rc1tjXS5tYXh2LCBiaW4pKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gb3B0aW1pemVDaHVua3MoY2h1bmtzLCBuZXcgVmlydHVhbE9mZnNldCgwLCAwKSk7CiAgICB9CiAgICByZWcyYmlucyhiZWcsIGVuZCkgewogICAgICBiZWcgLT0gMTsKICAgICAgaWYgKGJlZyA8IDEpIHsKICAgICAgICBiZWcgPSAxOwogICAgICB9CiAgICAgIGlmIChlbmQgPiAyICoqIDUwKSB7CiAgICAgICAgZW5kID0gMiAqKiAzNDsKICAgICAgfQogICAgICBlbmQgLT0gMTsKICAgICAgbGV0IGwgPSAwOwogICAgICBsZXQgdCA9IDA7CiAgICAgIGxldCBzID0gdGhpcy5taW5TaGlmdCArIHRoaXMuZGVwdGggKiAzOwogICAgICBjb25zdCBiaW5zID0gW107CiAgICAgIGZvciAoOyBsIDw9IHRoaXMuZGVwdGg7IHMgLT0gMywgdCArPSBsc2hpZnQoMSwgbCAqIDMpLCBsICs9IDEpIHsKICAgICAgICBjb25zdCBiID0gdCArIHJzaGlmdChiZWcsIHMpOwogICAgICAgIGNvbnN0IGUgPSB0ICsgcnNoaWZ0KGVuZCwgcyk7CiAgICAgICAgaWYgKGUgLSBiICsgYmlucy5sZW5ndGggPiB0aGlzLm1heEJpbk51bWJlcikgewogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBxdWVyeSAke2JlZ30tJHtlbmR9IGlzIHRvbyBsYXJnZSBmb3IgY3VycmVudCBiaW5uaW5nIHNjaGVtZSAoc2hpZnQgJHt0aGlzLm1pblNoaWZ0fSwgZGVwdGggJHt0aGlzLmRlcHRofSksIHRyeSBhIHNtYWxsZXIgcXVlcnkgb3IgYSBjb2Fyc2VyIGluZGV4IGJpbm5pbmcgc2NoZW1lYCk7CiAgICAgICAgfQogICAgICAgIGJpbnMucHVzaChbYiwgZV0pOwogICAgICB9CiAgICAgIHJldHVybiBia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y5kYXRhKS5mb3JFYWNoKChrKSA9PiB7CiAgICAgICAgaWYgKGtbMF0gIT09ICJfIiAmJiBrICE9PSAibmV4dF9zZXFfaWQiKSB7CiAgICAgICAgICB0YWdzLnB1c2goayk7CiAgICAgICAgfQogICAgICB9KTsKICAgICAgY29uc3Qgc2VlbiA9IHt9OwogICAgICByZXR1cm4gdGFncy5maWx0ZXIoKHQpID0+IHsKICAgICAgICBpZiAodCBpbiB0aGlzLmRhdGEgJiYgdGhpcy5kYXRhW3RdID09PSB2b2lkIDAgfHwgdCA9PT0gIkNHIiB8fCB0ID09PSAiY2ciKSB7CiAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfQogICAgICAgIGNvbnN0IGx0ID0gdC50b0xvd2VyQ2FzZSgpOwogICAgICAgIGNvbnN0IHMgPSBzZWVuW2x0XTsKICAgICAgICBzZWVuW2x0XSA9IHRydWU7CiAgICAgICAgcmV0dXJuICFzOwogICAgICB9KTsKICAgIH0KICAgIHBhcmVudCgpIHsKICAgICAgcmV0dXJuIHZvaWQgMDsKICAgIH0KICAgIGNoaWxkcmVuKCkgewogICAgICByZXR1cm4gdGhpcy5nZXQoInN1YmZlYXR1cmVzIik7CiAgICB9CiAgICBpZCgpIHsKICAgICAgcmV0dXJuIHRoaXMuX2lkOwogICAgfQogICAgbXEoKSB7CiAgICAgIGNvbnN0IG1xID0gKHRoaXMuZ2V0KCJfYmluX21xX25sIikgJiA2NTI4MCkgPj4gODsKICAgICAgcmV0dXJuIG1xID09PSAyNTUgPyB2b2lkIDAgOiBtcTsKICAgIH0KICAgIHNjb3JlKCkgewogICAgICByZXR1cm4gdGhpcy5nZXQoIm1xIik7CiAgICB9CiAgICBxdWFsKCkgewogICAgICB2YXIgX2E7CiAgICAgIHJldHVybiAoX2EgPSB0aGlzLnF1YWxSYXcoKSkgPT09IG51bGwgfHwgX2EgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9hLmpvaW4oIiAiKTsKICAgIH0KICAgIHF1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AgICAgICBjYXNlICJJIjoKICAgICAgICAgICAgdmFsdWUgPSBieXRlQXJyYXkucmVhZFVJbnQzMkxFKHApOwogICAgICAgICAgICBwICs9IDQ7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAiYyI6CiAgICAgICAgICAgIHZhbHVlID0gYnl0ZUFycmF5LnJlYWRJbnQ4KHApOwogICAgICAgICAgICBwICs9IDE7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAiQyI6CiAgICAgICAgICAgIHZhbHVlID0gYnl0ZUFycmF5LnJlYWRVSW50OChwKTsKICAgICAgICAgICAgcCArPSAxOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgInMiOgogICAgICAgICAgICB2YWx1ZSA9IGJ5dGVBcnJheS5yZWFkSW50MTZMRShwKTsKICAgICAgICAgICAgcCArPSAyOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgIlMiOgogICAgICAgICAgICB2YWx1ZSA9IGJ5dGVBcnJheS5yZWFkVUludDE2TEUocCk7CiAgICAgICAgICAgIHAgKz0gMjsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICJmIjoKICAgICAgICAgICAgdmFsdWUgPSBieXRlQXJyYXkucmVhZEZsb2F0TEUocCk7CiAgICAgICAgICAgIHAgKz0gNDsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICJaIjoKICAgICAgICAgIGNhc2UgIkgiOgogICAgICAgICAgICB2YWx1ZSA9ICIiOwogICAgICAgICAgICB3aGlsZSAocCA8PSBibG9ja0VuZCkgewogICAgICAgICAgICAgIGNvbnN0IGNjID0gYnl0ZUFycmF5W3ArK107CiAgICAgICAgICAgICAgaWYgKGNjID09PSAwKSB7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgdmFsdWUgKz0gU3RyaW5nLmZyb21DaGFyQ29kZShjYyk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAiQiI6IHsKICAgICAgICAgICAgdmFsdWUgPSAiIjsKICAgICAgICAgICAgY29uc3QgY2MgPSBieXRlQXJyYXlbcCsrXTsKICAgICAgICAgICAgY29uc3QgQnR5cGUgPSBTdHJpbmcuZnJvbUNoYXJDb2RlKGNjKTsKICAgICAgICAgICAgY29uc3QgbGltaXQgPSBieXRlQXJyYXkucmVhZEludDMyTEUocCk7CiAgICAgICAgICAgIHAgKz0gNDsKICAgICAgICAgICAgaWYgKEJ0eXBlID09PSAiaSIpIHsKICAgICAgICAgICAgICBpZiAodGFnID09PSAiQ0ciKSB7CiAgICAgICAgICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IGxpbWl0OyBrKyspIHsKICAgICAgICAgICAgICAgICAgY29uc3QgY2lnb3AgPSBieXRlQXJyYXkucmVhZEludDMyTEUocCk7CiAgICAgICAgICAgICAgICAgIGNvbnN0IGxvcCA9IGNpZ29wID4+IDQ7CiAgICAgICAgICAgICAgICAgIGNvbnN0IG9wID0gQ0lHQVJfREVDT0RFUltjaWdvcCAmIDE1XTsKICAgICAgICAgICAgICAgICAgdmFsdWUgKz0gbG9wICsgb3A7CiAgICAgICAgICAgICAgICAgIHAgKz0gNDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgZm9yIChsZXQgayA9IDA7IGsgPCBsaW1pdDsgaysrKSB7CiAgICAgICAgICAgICAgICAgIHZhbHVlICs9IGJ5dGVBcnJheS5yZWFkSW50MzJMRShwKTsKICAgICAgICAgICAgICAgICAgaWYgKGsgKyAxIDwgbGltaXQpIHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZSArPSAiLCI7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgcCArPSA0OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoQnR5cGUgPT09ICJJIikgewogICAgICAgICAgICAgIGlmICh0YWcgPT09ICJDRyIpIHsKICAgICAgICAgICAgICAgIGZvciAobGV0IGsgPSAwOyBrIDwgbGltaXQ7IGsrKykgewogICAgICAgICAgICAgICAgICBjb25zdCBjaWdvcCA9IGJ5dGVBcnJheS5yZWFkVUludDMyTEUocCk7CiAgICAgICAgICAgICAgICAgIGNvbnN0IGxvcCA9IGNpZ29wID4+IDQ7CiAgICAgICAgICAgICAgICAgIGNvbnN0IG9wID0gQ0lHQVJfREVDT0RFUltjaWdvcCAmIDE1XTsKICAgICAgICAgICAgICAgICAgdmFsdWUgKz0gbG9wICsgb3A7CiAgICAgICAgICAgICAgICAgIHAgKz0gNDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgZm9yIChsZXQgayA9IDA7IGsgPCBsaW1pdDsgaysrKSB7CiAgICAgICAgICAgICAgICAgIHZhbHVlICs9IGJ5dGVBcnJheS5yZWFkVUludDMyTEUocCk7CiAgICAgICAgICAgICAgICAgIGlmIChrICsgMSA8IGxpbWl0KSB7CiAgICAgICAgICAgICAgICAgICAgdmFsdWUgKz0gIiwiOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIHAgKz0gNDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKEJ0eXBlID09PSAicyIpIHsKICAgICAgICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IGxpbWl0OyBrKyspIHsKICAgICAgICAgICAgICAgIHZhbHVlICs9IGJ5dGVBcnJheS5yZWFkSW50MTZMRShwKTsKICAgICAgICAgICAgICAgIGlmIChrICsgMSA8IGxpbWl0KSB7CiAgICAgICAgICAgICAgICAgIHZhbHVlICs9ICIsIjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHAgKz0gMjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKEJ0eXBlID09PSAiUyIpIHsKICAgICAgICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IGxpbWl0OyBrKyspIHsKICAgICAgICAgICAgICAgIHZhbHVlICs9IGJ5dGVBcnJheS5yZWFkVUludDE2TEUocCk7CiAgICAgICAgICAgICAgICBpZiAoayArIDEgPCBsaW1pdCkgewogICAgICAgICAgICAgICAgICB2YWx1ZSArPSAiLCI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBwICs9IDI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChCdHlwZSA9PT0gImMiKSB7CiAgICAgICAgICAgICAgZm9yIChsZXQgayA9IDA7IGsgPCBsaW1pdDsgaysrKSB7CiAgICAgICAgICAgICAgICB2YWx1ZSArPSBieXRlQXJyYXkucmVhZEludDgocCk7CiAgICAgICAgICAgICAgICBpZiAoayArIDEgPCBsaW1pdCkgewogICAgICAgICAgICAgICAgICB2YWx1ZSArPSAiLCI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBwICs9IDE7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChCdHlwZSA9PT0gIkMiKSB7CiAgICAgICAgICAgICAgZm9yIChsZXQgayA9IDA7IGsgPCBsaW1pdDsgaysrKSB7CiAgICAgICAgICAgICAgICB2YWx1ZSArPSBieXRlQXJyYXkucmVhZFVJbnQ4KHApOwogICAgICAgICAgICAgICAgaWYgKGsgKyAxIDwgbGltaXQpIHsKICAgICAgICAgICAgICAgICAgdmFsdWUgKz0gIiwiOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgcCArPSAxOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoQnR5cGUgPT09ICJmIikgewogICAgICAgICAgICAgIGZvciAobGV0IGsgPSAwOyBrIDwgbGltaXQ7IGsrKykgewogICAgICAgICAgICAgICAgdmFsdWUgKz0gYnl0ZUFycmF5LnJlYWRGbG9hdExFKHApOwogICAgICAgICAgICAgICAgaWYgKGsgKyAxIDwgbGltaXQpIHsKICAgICAgICAgICAgICAgICAgdmFsdWUgKz0gIiwiOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgcCArPSA0OwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIGNvbnNvbGUud2FybihgVW5rbm93biBCQU0gdGFnIHR5cGUgJyR7dHlwZX0nLCB0YWdzIG1heSBiZSBpbmNvbXBsZXRlYCk7CiAgICAgICAgICAgIHZhbHVlID0gdm9pZCAwOwogICAgICAgICAgICBwID0gYmxvY2tFbmQ7CiAgICAgICAgfQogICAgICAgIHRoaXMuX3RhZ09mZnNldCA9IHA7CiAgICAgICAgdGhpcy5fdGFnTGlzdC5wdXNoKHRhZyk7CiAgICAgICAgaWYgKGxjVGFnID09PSB0YWdOYW1lKSB7CiAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgfQogICAgICAgIHRoaXMuZGF0YVtsY1RhZ10gPSB2YWx1ZTsKICAgICAgfQogICAgICB0aGlzLl9hbGxUYWdzUGFyc2VkID0gdHJ1ZTsKICAgICAgcmV0dXJuIHZvaWQgMDsKICAgIH0KICAgIF9wYXJzZUFsbFRhZ3MoKSB7CiAgICAgIHRoaXMuX3BhcnNlVGFnKCIiKTsKICAgIH0KICAgIF9wYXJzZUNpZ2FyKGNpZ2FyKSB7CiAgICAgIHJldHVybiBjaWdhci5tYXRjaCgvXGQrXEQvZykubWFwKChvcCkgPT4gW29wLm1hdGNoKC9cRC8pWzBdLnRvVXBwZXJDYXNlKCksIHBhcnNlSW50KG9wLCAxMCldKTsKICAgIH0KICAgIGlzUGFpcmVkKCkgewogICAgICByZXR1cm4gISEodGhpcy5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AgaWYgKG9wICE9PSAiTiIpIHsKICAgICAgICAgIGNvbnNvbGUud2FybigiQ0cgdGFnIHdpdGggbm8gTiB0YWciKTsKICAgICAgICB9CiAgICAgICAgdGhpcy5kYXRhLmxlbmd0aF9vbl9yZWYgPSBsb3A7CiAgICAgICAgcmV0dXJuIHRoaXMuZ2V0KCJDRyIpOwogICAgICB9IGVsc2UgewogICAgICAgIGZvciAobGV0IGMgPSAwOyBjIDwgbnVtQ2lnYXJPcHM7ICsrYykgewogICAgICAgICAgY2lnb3AgPSBieXRlQXJyYXkucmVhZEludDMyTEUocCk7CiAgICAgICAgICBsb3AgPSBjaWdvcCA+PiA0OwogICAgICAgICAgb3AgPSBDSUdBUl9ERUNPREVSW2NpZ29wICYgMTVdOwogICAgICAgICAgY2lnYXIgKz0gbG9wICsgb3A7CiAgICAgICAgICBpZiAob3AgIT09ICJIIiAmJiBvcCAhPT0gIlMiICYmIG9wICE9PSAiSSIpIHsKICAgICAgICAgICAgbHJlZiArPSBsb3A7CiAgICAgICAgICB9CiAgICAgICAgICBwICs9IDQ7CiAgICAgICAgfQogICAgICAgIHRoaXMuZGF0YS5sZW5ndGhfb25fcmVmID0gbHJlZjsKICAgICAgICByZXR1cm4gY2lnYXI7CiAgICAgIH0KICAgIH0KICAgIF9mbGFncygpIHsKICAgIH0KICAgIGxlbmd0aF9vbl9yZWYoKSB7CiAgICAgIGlmICh0aGlzLmRhdGEubGVuZ3RoX29uX3JlZikgewogICAgICAgIHJldHVybiB0aGlzLmRhdGEubGVuZ3RoX29uX3JlZjsKICAgICAgfSBlbHNlIHsKICAgICAgICB0aGlzLmdldCgiY2lnYXIiKTsKICAgICAgICByZXR1cm4gdGhpcy5kYXRhLmxlbmd0aF9vbl9yZWY7CiAgICAgIH0KICAgIH0KICAgIF9uX2NpZ2FyX29wKCkgewogICAgICByZXR1cm4gdGhpcy5nZXQoIl9mbGFnX25jIikgJiA2NTUzNTsKICAgIH0KICAgIF9sX3JlYWRfbmFtZSgpIH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WZpZCgpKSB7CiAgICAgICAgY29uc3QgczEgPSB0aGlzLmlzUmV2ZXJzZUNvbXBsZW1lbnRlZCgpID8gIlIiIDogIkYiOwogICAgICAgIGNvbnN0IHMyID0gdGhpcy5pc01hdGVSZXZlcnNlQ29tcGxlbWVudGVkKCkgPyAiUiIgOiAiRiI7CiAgICAgICAgbGV0IG8xID0gIiAiOwogICAgICAgIGxldCBvMiA9ICIgIjsKICAgICAgICBpZiAodGhpcy5pc1JlYWQxKCkpIHsKICAgICAgICAgIG8xID0gIjEiOwogICAgICAgICAgbzIgPSAiMiI7CiAgICAgICAgfSBlbHNlIGlmICh0aGlzLmlzUmVhZDIoKSkgewogICAgICAgICAgbzEgPSAiMiI7CiAgICAgICAgICBvMiA9ICIxIjsKICAgICAgICB9CiAgICAgICAgY29uc3QgdG1wID0gW107CiAgICAgICAgY29uc3QgaXNpemUgPSB0aGlzLnRlbXBsYXRlX2xlbmd0aCgpOwogICAgICAgIGlmIChpc2l6ZSA+IDApIHsKICAgICAgICAgIHRtcFswXSA9IHMxOwogICAgICAgICAgdG1wWzFdID0gbzE7CiAgICAgICAgICB0bXBbMl0gPSBzMjsKICAgICAgICAgIHRtcFszXSA9IG8yOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB0bXBbMl0gPSBzMTsKICAgICAgICAgIHRtcFszXSA9IG8xOwogICAgICAgICAgdG1wWzBdID0gczI7CiAgICAgICAgICB0bXBbMV0gPSBvMjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRtcC5qb2luKCIiKTsKICAgICAgfQogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIF9iaW5fbXFfbmwoKSB7CiAgICAgIHJldHVybiB0aGlzLmJ5dGVzLmJ5dGVBcnJheS5yZWFkSW50MzJMRSh0aGlzLmJ5dGVzLnN0YXJ0ICsgMTIpOwogICAgfQogICAgX2ZsYWdfbmMoKSB7CiAgICAgIHJldHVybiB0aGlzLmJ5dGVzLmJ5dGVBcnJheS5yZW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zLCBjaHJJZCwgbWluLCBtYXgsIG9wdHMpOwogICAgfQogICAgYXN5bmMgKl9mZXRjaENodW5rRmVhdHVyZXMoY2h1bmtzLCBjaHJJZCwgbWluLCBtYXgsIG9wdHMpIHsKICAgICAgY29uc3QgeyB2aWV3QXNQYWlycyA9IGZhbHNlIH0gPSBvcHRzOwogICAgICBjb25zdCBmZWF0cyA9IFtdOwogICAgICBsZXQgZG9uZSA9IGZhbHNlOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNodW5rcy5sZW5ndGg7IGkrKykgewogICAgICAgIGNvbnN0IGMgPSBjaHVua3NbaV07CiAgICAgICAgY29uc3QgcmVjb3JkcyA9IGF3YWl0IHRoaXMuZmVhdHVyZUNhY2hlLmdldChjLnRvU3RyaW5nKCksIHsKICAgICAgICAgIGNodW5rOiBjLAogICAgICAgICAgb3B0cwogICAgICAgIH0sIG9wdHMuc2lnbmFsKTsKICAgICAgICBjb25zdCByZWNzID0gW107CiAgICAgICAgZm9yIChsZXQgaTIgPSAwOyBpMiA8IHJlY29yZHMubGVuZ3RoOyBpMiArPSAxKSB7CiAgICAgICAgICBjb25zdCBmZWF0dXJlID0gcmVjb3Jkc1tpMl07CiAgICAgICAgICBpZiAoZmVhdHVyZS5zZXFfaWQoKSA9PT0gY2hySWQpIHsKICAgICAgICAgICAgaWYgKGZlYXR1cmUuZ2V0KCJzdGFydCIpID49IG1heCkgewogICAgICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9IGVsc2UgaWYgKGZlYXR1cmUuZ2V0KCJlbmQiKSA+PSBtaW4pIHsKICAgICAgICAgICAgICByZWNzLnB1c2goZmVhdHVyZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZmVhdHMucHVzaChyZWNzKTsKICAgICAgICB5aWVsZCByZWNzOwogICAgICAgIGlmIChkb25lKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgICAgY2hlY2tBYm9ydFNpZ25hbChvcHRzLnNpZ25hbCk7CiAgICAgIGlmICh2aWV3QXNQYWlycykgewogICAgICAgIHlpZWxkIHRoaXMuZmV0Y2hQYWlycyhjaHJJZCwgZmVhdHMsIG9wdHMpOwogICAgICB9CiAgICB9CiAgICBhc3luYyBmZXRjaFBhaXJzKGNocklkLCBmZWF0cywgb3B0cykgewogICAgICBjb25zdCB7IHBhaXJBY3Jvc3NDaHIgPSBmYWxzZSwgbWF4SW5zZXJ0U2l6ZSA9IDJlNSB9ID0gb3B0czsKICAgICAgY29uc3QgdW5tYXRlZFBhaXJzID0ge307CiAgICAgIGNvbnN0IHJlYWRJZHMgPSB7fTsKICAgICAgZmVhdHMubWFwKChyZXQpID0+IHsKICAgICAgICBjb25zdCByZWFkTmFtZXMgPSB7fTsKICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHJldC5sZW5ndGg7IGkrKykgewogICAgICAgICAgY29uc3QgbmFtZSA9IHJldFtpXS5uYW1lKCk7CiAgICAgICAgICBjb25zdCBpZCA9IHJldFtpXS5pZCgpOwogICAgICAgICAgaWYgKCFyZWFkTmFtZXNbbmFtZV0pIHsKICAgICAgICAgICAgcmVhZE5hbWVzW25hbWVdID0gMDsKICAgICAgICAgIH0KICAgICAgICAgIHJlYWROYW1lc1tuYW1lXSsrOwogICAgICAgICAgcmVhZElkc1tpZF0gPSAxOwogICAgICAgIH0KICAgICAgICAoMCwgaW1wb3J0X29iamVjdC5kZWZhdWx0KShyZWFkTmFtZXMpLmZvckVhY2goKFtrLCB2XSkgPT4gewogICAgICAgICAgaWYgKHYgPT09IDEpIHsKICAgICAgICAgICAgdW5tYXRlZFBhaXJzW2tdID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICB9KTsKICAgICAgfSk7CiAgICAgIGNvbnN0IG1hdGVQcm9taXNlcyA9IFtdOwogICAgICBmZWF0cy5tYXAoKHJldCkgPT4gewogICAgICAgIGZvciA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gIGJ5dGVzOiB7CiAgICAgICAgICAgICAgYnl0ZUFycmF5OiBiYSwKICAgICAgICAgICAgICBzdGFydDogYmxvY2tTdGFydCwKICAgICAgICAgICAgICBlbmQ6IGJsb2NrRW5kCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIGZpbGVPZmZzZXQ6IGNwb3NpdGlvbnMgPyBjcG9zaXRpb25zW3Bvc10gKiAoMSA8PCA4KSArIChibG9ja1N0YXJ0IC0gZHBvc2l0aW9uc1twb3NdKSArIGNodW5rLm1pbnYuZGF0YVBvc2l0aW9uICsgMSA6IGltcG9ydF9idWZmZXJfY3JjMzIuZGVmYXVsdC5zaWduZWQoYmEuc2xpY2UoYmxvY2tTdGFydCwgYmxvY2tFbmQpKQogICAgICAgICAgfSk7CiAgICAgICAgICBzaW5rLnB1c2goZmVhdHVyZSk7CiAgICAgICAgICBpZiAodGhpcy55aWVsZFRocmVhZFRpbWUgJiYgK0RhdGUubm93KCkgLSBsYXN0ID4gdGhpcy55aWVsZFRocmVhZFRpbWUpIHsKICAgICAgICAgICAgYXdhaXQgdGltZW91dCgxKTsKICAgICAgICAgICAgbGFzdCA9ICtEYXRlLm5vdygpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBibG9ja1N0YXJ0ID0gYmxvY2tFbmQgKyAxOwogICAgICB9CiAgICAgIHJldHVybiBzaW5rOwogICAgfQogICAgYXN5bmMgaGFzUmVmU2VxKHNlcU5hbWUpIHsKICAgICAgY29uc3QgcmVmSWQgPSB0aGlzLmNoclRvSW5kZXggJiYgdGhpcy5jaHJUb0luZGV4W3NlcU5hbWVdOwogICAgICByZXR1cm4gdGhpcy5pbmRleC5oYXNSZWZTZXEocmVmSWQpOwogICAgfQogICAgYXN5bmMgbGluZUNvdW50KHNlcU5hbWUpIHsKICAgICAgY29uc3QgcmVmSWQgPSB0aGlzLmNoclRvSW5kZXggJiYgdGhpcy5jaHJUb0luZGV4W3NlcU5hbWVdOwogICAgICByZXR1cm4gdGhpcy5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IGl0ZW0pID09PSBmYWxzZSkgewogICAgICAgICAgdGhpcy5fbW92ZVRvUmVjZW50KGtleSwgaXRlbSk7CiAgICAgICAgICByZXR1cm4gaXRlbS52YWx1ZTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHNldChrZXksIHZhbHVlLCB7IG1heEFnZSA9IHRoaXMubWF4QWdlIH0gPSB7fSkgewogICAgICBjb25zdCBleHBpcnkgPSB0eXBlb2YgbWF4QWdlID09PSAibnVtYmVyIiAmJiBtYXhBZ2UgIT09IE51bWJlci5QT1NJVElWRV9JTkZJTklUWSA/IERhdGUubm93KCkgKyBtYXhBZ2UgOiB2b2lkIDA7CiAgICAgIGlmICh0aGlzLmNhY2hlLmhhcyhrZXkpKSB7CiAgICAgICAgdGhpcy5jYWNoZS5zZXQoa2V5LCB7CiAgICAgICAgICB2YWx1ZSwKICAgICAgICAgIGV4cGlyeQogICAgICAgIH0pOwogICAgICB9IGVsc2UgewogICAgICAgIHRoaXMuX3NldChrZXksIHsgdmFsdWUsIGV4cGlyeSB9KTsKICAgICAgfQogICAgICByZXR1cm4gdGhpczsKICAgIH0KICAgIGhhcyhrZXkpIHsKICAgICAgaWYgKHRoaXMuY2FjaGUuaGFzKGtleSkpIHsKICAgICAgICByZXR1cm4gIXRoaXMuX2RlbGV0ZUlmRXhwaXJlZChrZXksIHRoaXMuY2FjaGUuZ2V0KGtleSkpOwogICAgICB9CiAgICAgIGlmICh0aGlzLm9sZENhY2hlLmhhcyhrZXkpKSB7CiAgICAgICAgcmV0dXJuICF0aGlzLl9kZWxldGVJZkV4cGlyZWQoa2V5LCB0aGlzLm9sZENhY2hlLmdldChrZXkpKTsKICAgICAgfQogICAgICByZXR1cm4gZmFsc2U7CiAgICB9CiAgICBwZWVrKGtleSkgewogICAgICBpZiAodGhpcy5jYWNoZS5oYXMoa2V5KSkgewogICAgICAgIHJldHVybiB0aGlzLl9wZWVrKGtleSwgdGhpcy5jYWNoZSk7CiAgICAgIH0KICAgICAgaW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gICAgfQogICAgICAgIH0KICAgICAgfQogICAgfQogICAgKmVudHJpZXNEZXNjZW5kaW5nKCkgewogICAgICBsZXQgaXRlbXMgPSBbLi4udGhpcy5jYWNoZV07CiAgICAgIGZvciAobGV0IGkgPSBpdGVtcy5sZW5ndGggLSAxOyBpID49IDA7IC0taSkgewogICAgICAgIGNvbnN0IGl0ZW0gPSBpdGVtc1tpXTsKICAgICAgICBjb25zdCBba2V5LCB2YWx1ZV0gPSBpdGVtOwogICAgICAgIGNvbnN0IGRlbGV0ZWQgPSB0aGlzLl9kZWxldGVJZkV4cGlyZWQoa2V5LCB2YWx1ZSk7CiAgICAgICAgaWYgKGRlbGV0ZWQgPT09IGZhbHNlKSB7CiAgICAgICAgICB5aWVsZCBba2V5LCB2YWx1ZS52YWx1ZV07CiAgICAgICAgfQogICAgICB9CiAgICAgIGl0ZW1zID0gWy4uLnRoaXMub2xkQ2FjaGVdOwogICAgICBmb3IgKGxldCBpID0gaXRlbXMubGVuZ3RoIC0gMTsgaSA+PSAwOyAtLWkpIHsKICAgICAgICBjb25zdCBpdGVtID0gaXRlbXNbaV07CiAgICAgICAgY29uc3QgW2tleSwgdmFsdWVdID0gaXRlbTsKICAgICAgICBpZiAoIXRoaXMuY2FjaGUuaGFzKGtleSkpIHsKICAgICAgICAgIGNvbnN0IGRlbGV0ZWQgPSB0aGlzLl9kZWxldGVJZkV4cGlyZWQoa2V5LCB2YWx1ZSk7CiAgICAgICAgICBpZiAoZGVsZXRlZCA9PT0gZmFsc2UpIHsKICAgICAgICAgICAgeWllbGQgW2tleSwgdmFsdWUudmFsdWVdOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfQogICAgKmVudHJpZXNBc2NlbmRpbmcoKSB7CiAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsdWVdIG9mIHRoaXMuX2VudHJpZXNBc2NlbmRpbmcoKSkgewogICAgICAgIHlpZWxkIFtrZXksIHZhbHVlLnZhbHVlXTsKICAgICAgfQogICAg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yA9IDA7CiAgICAgIGlmIChoaSA9PSBudWxsKQogICAgICAgIGhpID0gYS5sZW5ndGg7CiAgICAgIHdoaWxlIChsbyA8IGhpKSB7CiAgICAgICAgY29uc3QgbWlkID0gbG8gKyBoaSA+Pj4gMTsKICAgICAgICBpZiAoY29tcGFyZShhW21pZF0sIHgpID4gMCkKICAgICAgICAgIGhpID0gbWlkOwogICAgICAgIGVsc2UKICAgICAgICAgIGxvID0gbWlkICsgMTsKICAgICAgfQogICAgICByZXR1cm4gbG87CiAgICB9CiAgICBmdW5jdGlvbiBjZW50ZXIoYSwgeCwgbG8sIGhpKSB7CiAgICAgIGlmIChsbyA9PSBudWxsKQogICAgICAgIGxvID0gMDsKICAgICAgaWYgKGhpID09IG51bGwpCiAgICAgICAgaGkgPSBhLmxlbmd0aDsKICAgICAgY29uc3QgaSA9IGxlZnQoYSwgeCwgbG8sIGhpIC0gMSk7CiAgICAgIHJldHVybiBpID4gbG8gJiYgZGVsdGEoYVtpIC0gMV0sIHgpID4gLWRlbHRhKGFbaV0sIHgpID8gaSAtIDEgOiBpOwogICAgfQogICAgcmV0dXJuIHsgbGVmdCwgY2VudGVyLCByaWdodCB9OwogIH0KICBmdW5jdGlvbiBhc2NlbmRpbmdDb21wYXJhdG9yKGYpIHsKICAgIHJldHVybiAoZCwgeCkgPT4gYXNjZW5kaW5nX2RlZmF1bHQoZihkKSwgeCk7CiAgfQoKICAvLyBzcmMvZGF0YS1mZXRjaGVycy91dGlscy50cwogIHZhciBEYXRhU291cmNlID0gY2xhc3MgewogICAgY29uc3RydWN0b3IoZmlsZSwgY2hyb21TaXplcywgb3B0aW9ucykgewogICAgICB0aGlzLmZpbGUgPSBmaWxlOwogICAgICB0aGlzLm9wdGlvbnMgPSBvcHRpb25zOwogICAgICB0aGlzLmNocm9tSW5mbyA9IHNpemVzVG9DaHJvbUluZm8oY2hyb21TaXplcyk7CiAgICAgIHRoaXMudGlsZXNldEluZm8gPSB0aWxlc2V0SW5mb0Zyb21Da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jdXJyTnVtLAogICAgICAgICAgICB0eXBlOiBtZFN0cmluZ1tpXQogICAgICAgICAgfSk7CiAgICAgICAgfSBlbHNlIGlmIChkZWxldGlvbkVuY291bnRlcmVkKSB7CiAgICAgICAgICBiYW1TZXFTaGlmdCAtPSAxOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBzdWJzdGl0dXRpb25zLnB1c2goewogICAgICAgICAgICBwb3M6IGN1cnJQb3MsCiAgICAgICAgICAgIGJhc2U6IG1kU3RyaW5nW2ldLAogICAgICAgICAgICBsZW5ndGg6IDEsCiAgICAgICAgICAgIGJhbVNlcVNoaWZ0CiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgY3Vyck51bSA9IDA7CiAgICAgICAgY3VyclBvcyArPSAxOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gc3Vic3RpdHV0aW9uczsKICB9CiAgZnVuY3Rpb24gZ2V0U3Vic3RpdHV0aW9ucyhzZWdtZW50LCBzZXEpIHsKICAgIGxldCBzdWJzdGl0dXRpb25zID0gW107CiAgICBsZXQgc29mdENsaXBwaW5nQXRSZWFkU3RhcnQgPSBudWxsOwogICAgaWYgKHNlZ21lbnQuY2lnYXIpIHsKICAgICAgY29uc3QgY2lnYXJTdWJzID0gcGFyc2VNRChzZWdtZW50LmNpZ2FyLCB0cnVlKTsKICAgICAgbGV0IGN1cnJQb3MgPSAwOwogICAgICBmb3IgKGNvbnN0IHN1YiBvZiBjaWdhclN1YnMpIHsKICAgICAgICBpZiAoc3ViLnR5cGUgPT09ICJYIikgewogICAgICAgICAgc3Vic3RpdHV0aW9ucy5wdXNoKHsKICAgICAgICAgICAgcG9zOiBjdXJyUG9zLAogICAgICAgICAgICBsZW5ndGg6IHN1Yi5sZW5ndGgsCiAgICAgICAgICAgIHR5cGU6ICJYIgogICAgICAgICAgfSk7CiAgICAgICAgICBjdXJyUG9zICs9IHN1Yi5sZW5ndGg7CiAgICAgICAgfSBlbHNlIGlmIChzdWIudHlwZSA9PT0gIkkiKSB7CiAgICAgICAgICBzdWJzdGl0dXRpb25zLnB1c2goewogICAgICAgICAgICBwb3M6IGN1cnJQb3MsCiAgICAgICAgICAgIGxlbmd0aDogc3ViLmxlbmd0aCwKICAgICAgICAgICAgdHlwZTogIkkiCiAgICAgICAgICB9KTsKICAgICAgICB9IGVsc2UgaWYgKHN1Yi50eXBlID09PSAiRCIpIHsKICAgICAgICAgIHN1YnN0aXR1dGlvbnMucHVzaCh7CiAgICAgICAgICAgIHBvczogY3VyclBvcywKICAgICAgICAgICAgbGVuZ3RoOiBzdWIubGVuZ3RoLAogICAgICAgICAgICB0eXBlOiAiRCIKICAgICAgICAgIH0pOwogICAgICAgICAgY3VyclBvcyArPSBzdWIubGVuZ3RoOwogICAgICAgIH0gZWxzZSBpZiAoc3ViLnR5cGUgPT09ICJOIikgewogICAgICAgICAgc3Vic3RpdHV0aW9ucy5wdXNoKHsKICAgICAgICAgICAgcG9zOiBjdXJyUG9zLAogICAgICAgICAgICBsZW5ndGg6IHN1Yi5sZW5ndGgsCiAgICAgICAgICAgIHR5cGU6ICJOIgogICAgICAgICAgfSk7CiAgICAgICAgICBjdXJyUG9zICs9IHN1Yi5sZW5ndGg7CiAgICAgICAgfSBlbHNlIGlmIChzdWIudHlwZSA9PT0gIj0iIHx8IHN1Yi50eXBlID09PSAiTSIpIHsKICAgICAgICAgIGN1cnJQb3MgKz0gc3ViLmxlbmd0aDsKICAgICAgICB9IGVsc2UgewogICAgICAgIH0KICAgICAgfQogICAgICBjb25zdCBmaXJzdFN1YiA9IGNpZ2FyU3Vic1swXTsKICAgICAgY29uc3QgbGFzdFN1YiA9IGNpZ2FyU3Vic1tjaWdhclN1YnMubGVuZ3RoIC0gMV07CiAgICAgIGlmIChmaXJzdFN1Yi50eXBlID09PSAiUyIpIHsKICAgICAgICBzb2Z0Q2xpcHBpbmdBdFJlYWRTdGFydCA9IGZpcnN0U3ViOwogICAgICAgIHN1YnN0aXR1dGlvbnMucHVzaCh7CiAgIC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B9KTsKICAgIHJldHVybiBqdW5jdGlvbnMuZmlsdGVyKChkKSA9PiBkLnNjb3JlID49IG1pbkNvdmVyYWdlKTsKICB9OwogIHZhciB0aWxlRnVuY3Rpb25zID0gewogICAgaW5pdCwKICAgIHRpbGVzZXRJbmZvLAogICAgZmV0Y2hUaWxlc0RlYm91bmNlZCwKICAgIHRpbGUsCiAgICBnZXRUYWJ1bGFyRGF0YQogIH07CiAgZXhwb3NlKHRpbGVGdW5jdGlvbnMpOwp9KSgpOwovKiEKICogVGhlIGJ1ZmZlciBtb2R1bGUgZnJvbSBub2RlLmpzLCBmb3IgdGhlIGJyb3dzZXIuCiAqCiAqIEBhdXRob3IgICBGZXJvc3MgQWJvdWtoYWRpamVoIDxodHRwczovL2Zlcm9zcy5vcmc+CiAqIEBsaWNlbnNlICBNSVQKICovCi8qISBpZWVlNzU0LiBCU0QtMy1DbGF1c2UgTGljZW5zZS4gRmVyb3NzIEFib3VraGFkaWplaCA8aHR0cHM6Ly9mZXJvc3Mub3JnL29wZW5zb3VyY2U+ICovCg==",VXe=typeof window<"u"&&window.Blob&&new Blob([atob(w8e)],{type:"text/javascript;charset=utf-8"});function rTg(){const e=VXe&&(window.URL||window.webkitURL).createObjectURL(VXe);try{return e?new Worker(e):new Worker("data:application/javascript;base64,"+w8e,{type:"module"})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const oTg=200;class zD{constructor(g,i){at(this,"dataConfig",{}),at(this,"uid"),at(this,"fetchTimeout"),at(this,"toFetch"),at(this,"MAX_TILE_WIDTH",2e4),at(this,"worker"),at(this,"track"),this.uid=g.libraries.slugid.nice(),this.toFetch=new Set;const{url:n,indexUrl:I,assembly:r,...o}=i;this.worker=Xz(new rTg).then(async C=>{const a=Object.entries(In(r).size);return await C.init(this.uid,{url:n,indexUrl:I},a,o),C})}async tilesetInfo(g){(await this.worker).tilesetInfo(this.uid).then(g)}fetchTilesDebounced(g,i){var n;const{toFetch:I}=this,r=i[0].split(".")[0],o=I.size?[...I][0].split(".")[0]:null;if(r!==o){for(const C of this.toFetch)(n=this.track)==null||n.fetching.delete(C);this.toFetch.clear()}i.forEach(C=>this.toFetch.add(C)),this.fetchTimeout&&clearTimeout(this.fetchTimeout),this.fetchTimeout=setTimeout(()=>{this.sendFetch(g,[...this.toFetch]),this.toFetch.clear()},oTg)}async sendFetch(g,i){(await this.worker).fetchTilesDebounced(this.uid,i).then(g)}async getTabularData(g){const i=await(await this.worker).getTabularData(this.uid,g);return JSON.parse(new TextDecoder().decode(i))}}at(zD,"config",{type:"bam"});const S8e="KCgpID0+IHsKICB2YXIgX19jcmVhdGUgPSBPYmplY3QuY3JlYXRlOwogIHZhciBfX2RlZlByb3AgPSBPYmplY3QuZGVmaW5lUHJvcGVydHk7CiAgdmFyIF9fZ2V0T3duUHJvcERlc2MgPSBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yOwogIHZhciBfX2dldE93blByb3BOYW1lcyA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eU5hbWVzOwogIHZhciBfX2dldFByb3RvT2YgPSBPYmplY3QuZ2V0UHJvdG90eXBlT2Y7CiAgdmFyIF9faGFzT3duUHJvcCA9IE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHk7CiAgdmFyIF9fbWFya0FzTW9kdWxlID0gKHRhcmdldCkgPT4gX19kZWZQcm9wKHRhcmdldCwgIl9fZXNNb2R1bGUiLCB7IHZhbHVlOiB0cnVlIH0pOwogIHZhciBfX2VzbSA9IChmbiwgcmVzKSA9PiBmdW5jdGlvbiBfX2luaXQoKSB7CiAgICByZXR1cm4gZm4gJiYgKHJlcyA9ICgwLCBmbltPYmplY3Qua2V5cyhmbilbMF1dKShmbiA9IDApKSwgcmVzOwogIH07CiAgdmFyIF9fY29tbW9uSlMgPSAoY2IsIG1vZCkgPT4gZnVuY3Rpb24gX19yZXF1aXJlKCkgewogICAgcmV0dXJuIG1vZCB8fCAoMCwgY2JbT2JqZWN0LmtleX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mV2TG9va3VwW2I2NC5jaGFyQ29kZUF0KGkyICsgMSldIDw8IDQgfCByZXZMb29rdXBbYjY0LmNoYXJDb2RlQXQoaTIgKyAyKV0gPj4gMjsKICAgICAgICAgIGFycltjdXJCeXRlKytdID0gdG1wID4+IDggJiAyNTU7CiAgICAgICAgICBhcnJbY3VyQnl0ZSsrXSA9IHRtcCAmIDI1NTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGFycjsKICAgICAgfQogICAgICBmdW5jdGlvbiB0cmlwbGV0VG9CYXNlNjQobnVtKSB7CiAgICAgICAgcmV0dXJuIGxvb2t1cFtudW0gPj4gMTggJiA2M10gKyBsb29rdXBbbnVtID4+IDEyICYgNjNdICsgbG9va3VwW251bSA+PiA2ICYgNjNdICsgbG9va3VwW251bSAmIDYzXTsKICAgICAgfQogICAgICBmdW5jdGlvbiBlbmNvZGVDaHVuayh1aW50OCwgc3RhcnQsIGVuZCkgewogICAgICAgIHZhciB0bXA7CiAgICAgICAgdmFyIG91dHB1dCA9IFtdOwogICAgICAgIGZvciAodmFyIGkyID0gc3RhcnQ7IGkyIDwgZW5kOyBpMiArPSAzKSB7CiAgICAgICAgICB0bXAgPSAodWludDhbaTJdIDw8IDE2ICYgMTY3MTE2ODApICsgKHVpbnQ4W2kyICsgMV0gPDwgOCAmIDY1MjgwKSArICh1aW50OFtpMiArIDJdICYgMjU1KTsKICAgICAgICAgIG91dHB1dC5wdXNoKHRyaXBsZXRUb0Jhc2U2NCh0bXApKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIG91dHB1dC5qb2luKCIiKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBmcm9tQnl0ZUFycmF5KHVpbnQ4KSB7CiAgICAgICAgdmFyIHRtcDsKICAgICAgICB2YXIgbGVuMiA9IHVpbnQ4Lmxlbmd0aDsKICAgICAgICB2YXIgZXh0cmFCeXRlcyA9IGxlbjIgJSAzOwogICAgICAgIHZhciBwYXJ0cyA9IFtdOwogICAgICAgIHZhciB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ICAgICAgZXhwb3J0czIucmVhZCA9IGZ1bmN0aW9uKGJ1ZmZlciwgb2Zmc2V0LCBpc0xFLCBtTGVuLCBuQnl0ZXMpIHsKICAgICAgICB2YXIgZSwgbTsKICAgICAgICB2YXIgZUxlbiA9IG5CeXRlcyAqIDggLSBtTGVuIC0gMTsKICAgICAgICB2YXIgZU1heCA9ICgxIDw8IGVMZW4pIC0gMTsKICAgICAgICB2YXIgZUJpYXMgPSBlTWF4ID4+IDE7CiAgICAgICAgdmFyIG5CaXRzID0gLTc7CiAgICAgICAgdmFyIGkgPSBpc0xFID8gbkJ5dGVzIC0gMSA6IDA7CiAgICAgICAgdmFyIGQgPSBpc0xFID8gLTEgOiAxOwogICAgICAgIHZhciBzID0gYnVmZmVyW29mZnNldCArIGldOwogICAgICAgIGkgKz0gZDsKICAgICAgICBlID0gcyAmICgxIDw8IC1uQml0cykgLSAxOwogICAgICAgIHMgPj49IC1uQml0czsKICAgICAgICBuQml0cyArPSBlTGVuOwogICAgICAgIGZvciAoOyBuQml0cyA+IDA7IGUgPSBlICogMjU2ICsgYnVmZmVyW29mZnNldCArIGldLCBpICs9IGQsIG5CaXRzIC09IDgpIHsKICAgICAgICB9CiAgICAgICAgbSA9IGUgJiAoMSA8PCAtbkJpdHMpIC0gMTsKICAgICAgICBlID4+PSAtbkJpdHM7CiAgICAgICAgbkJpdHMgKz0gbUxlbjsKICAgICAgICBmb3IgKDsgbkJpdHMgPiAwOyBtID0gbSAqIDI1NiArIGJ1ZmZlcltvZmZzZXQgKyBpXSwgaSArPSBkLCBuQml0cyAtPSA4KSB7CiAgICAgICAgfQogICAgICAgIGlmIChlID09PSAwKSB7CiAgICAgICAgICBlID0gMSAtIGVCaWFzOwogICAgICAgIH0gZWxzZSBpZiAoZSA9PT0gZU1heCkgewogICAgICAgICAgcmV0dXJuIG0gPyBOYU4gOiAocyA/IC0xIDogMSkgKiBJbmZpbml0eTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgbSA9IG0gKy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ICAgICAgICAgfQogICAgICAgICAgaWYgKGUgKyBlQmlhcyA+PSAxKSB7CiAgICAgICAgICAgIHZhbHVlICs9IHJ0IC8gYzsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHZhbHVlICs9IHJ0ICogTWF0aC5wb3coMiwgMSAtIGVCaWFzKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh2YWx1ZSAqIGMgPj0gMikgewogICAgICAgICAgICBlKys7CiAgICAgICAgICAgIGMgLz0gMjsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChlICsgZUJpYXMgPj0gZU1heCkgewogICAgICAgICAgICBtID0gMDsKICAgICAgICAgICAgZSA9IGVNYXg7CiAgICAgICAgICB9IGVsc2UgaWYgKGUgKyBlQmlhcyA+PSAxKSB7CiAgICAgICAgICAgIG0gPSAodmFsdWUgKiBjIC0gMSkgKiBNYXRoLnBvdygyLCBtTGVuKTsKICAgICAgICAgICAgZSA9IGUgKyBlQmlhczsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIG0gPSB2YWx1ZSAqIE1hdGgucG93KDIsIGVCaWFzIC0gMSkgKiBNYXRoLnBvdygyLCBtTGVuKTsKICAgICAgICAgICAgZSA9IDA7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGZvciAoOyBtTGVuID49IDg7IGJ1ZmZlcltvZmZzZXQgKyBpXSA9IG0gJiAyNTUsIGkgKz0gZCwgbSAvPSAyNTYsIG1MZW4gLT0gOCkgewogICAgICAgIH0KICAgICAgICBlID0gZSA8PCBtTGVuIHwgbTsKICAgICAgICBlTGVuICs9IG1MZW47CiAgICAgICAgZm9yICg7IGVMZW4gPiAwOyBidWZmZXJbb2Zmc2V0ICsgaV0gPSBlICYgMjU1LCBpICs9IGQsIGUgLz0gMjU2LCBlTGVuIC09IDgpIHsKICAgICAgICB9CiAgICAgICAgYnVmZmVyW29mZnNldCArIGkgLSBkXSB8PSBzICogMTI4OwogICAgICB9OwogICAgfQogIH0pO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Y3Rpb24iKSB7CiAgICAgICAgY29uc29sZS5lcnJvcigiVGhpcyBicm93c2VyIGxhY2tzIHR5cGVkIGFycmF5IChVaW50OEFycmF5KSBzdXBwb3J0IHdoaWNoIGlzIHJlcXVpcmVkIGJ5IGBidWZmZXJgIHY1LnguIFVzZSBgYnVmZmVyYCB2NC54IGlmIHlvdSByZXF1aXJlIG9sZCBicm93c2VyIHN1cHBvcnQuIik7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gdHlwZWRBcnJheVN1cHBvcnQoKSB7CiAgICAgICAgdHJ5IHsKICAgICAgICAgIGNvbnN0IGFyciA9IG5ldyBVaW50OEFycmF5KDEpOwogICAgICAgICAgY29uc3QgcHJvdG8gPSB7IGZvbzogZnVuY3Rpb24oKSB7CiAgICAgICAgICAgIHJldHVybiA0MjsKICAgICAgICAgIH0gfTsKICAgICAgICAgIE9iamVjdC5zZXRQcm90b3R5cGVPZihwcm90bywgVWludDhBcnJheS5wcm90b3R5cGUpOwogICAgICAgICAgT2JqZWN0LnNldFByb3RvdHlwZU9mKGFyciwgcHJvdG8pOwogICAgICAgICAgcmV0dXJuIGFyci5mb28oKSA9PT0gNDI7CiAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgfQogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoQnVmZmVyMTAucHJvdG90eXBlLCAicGFyZW50IiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHsKICAgICAgICAgIGlmICghQnVmZmVyMTAuaXNCdWZmZXIodGhpcykpCiAgICAgICAgICAgIHJldHVybiB2b2lkIDA7CiAgICAgICAgICByZXR1cm4gdGhpcy5idWZmZXI7CiAgICAgICAgfQogICAgICB9KTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KEJ1ZmZlcjEwLnByb3RvdHlwZSwgIm9mZnNldCIsIHsKICAgICAgIC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DApIHsKICAgICAgICAgICAgcmV0dXJuIGJ1ZjsKICAgICAgICAgIH0KICAgICAgICAgIG9iai5jb3B5KGJ1ZiwgMCwgMCwgbGVuKTsKICAgICAgICAgIHJldHVybiBidWY7CiAgICAgICAgfQogICAgICAgIGlmIChvYmoubGVuZ3RoICE9PSB2b2lkIDApIHsKICAgICAgICAgIGlmICh0eXBlb2Ygb2JqLmxlbmd0aCAhPT0gIm51bWJlciIgfHwgbnVtYmVySXNOYU4ob2JqLmxlbmd0aCkpIHsKICAgICAgICAgICAgcmV0dXJuIGNyZWF0ZUJ1ZmZlcigwKTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBmcm9tQXJyYXlMaWtlKG9iaik7CiAgICAgICAgfQogICAgICAgIGlmIChvYmoudHlwZSA9PT0gIkJ1ZmZlciIgJiYgQXJyYXkuaXNBcnJheShvYmouZGF0YSkpIHsKICAgICAgICAgIHJldHVybiBmcm9tQXJyYXlMaWtlKG9iai5kYXRhKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgZnVuY3Rpb24gY2hlY2tlZChsZW5ndGgpIHsKICAgICAgICBpZiAobGVuZ3RoID49IEtfTUFYX0xFTkdUSCkgewogICAgICAgICAgdGhyb3cgbmV3IFJhbmdlRXJyb3IoIkF0dGVtcHQgdG8gYWxsb2NhdGUgQnVmZmVyIGxhcmdlciB0aGFuIG1heGltdW0gc2l6ZTogMHgiICsgS19NQVhfTEVOR1RILnRvU3RyaW5nKDE2KSArICIgYnl0ZXMiKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGxlbmd0aCB8IDA7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gU2xvd0J1ZmZlcihsZW5ndGgpIHsKICAgICAgICBpZiAoK2xlbmd0aCAhPSBsZW5ndGgpIHsKICAgICAgICAgIGxlbmd0aCA9IDA7CiAgICAgICAgfQogICAgICAgIHJldHVybiBCdWZmZXIxMC5hbGxvYygrbGVuZ3RoKTsKICAgICAgfQogICAgICBCdWZmZ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ICAgICAgcmV0dXJuIC0xOwogICAgICAgIGlmICh5IDwgeCkKICAgICAgICAgIHJldHVybiAxOwogICAgICAgIHJldHVybiAwOwogICAgICB9OwogICAgICBCdWZmZXIxMC5pc0VuY29kaW5nID0gZnVuY3Rpb24gaXNFbmNvZGluZyhlbmNvZGluZykgewogICAgICAgIHN3aXRjaCAoU3RyaW5nKGVuY29kaW5nKS50b0xvd2VyQ2FzZSgpKSB7CiAgICAgICAgICBjYXNlICJoZXgiOgogICAgICAgICAgY2FzZSAidXRmOCI6CiAgICAgICAgICBjYXNlICJ1dGYtOCI6CiAgICAgICAgICBjYXNlICJhc2NpaSI6CiAgICAgICAgICBjYXNlICJsYXRpbjEiOgogICAgICAgICAgY2FzZSAiYmluYXJ5IjoKICAgICAgICAgIGNhc2UgImJhc2U2NCI6CiAgICAgICAgICBjYXNlICJ1Y3MyIjoKICAgICAgICAgIGNhc2UgInVjcy0yIjoKICAgICAgICAgIGNhc2UgInV0ZjE2bGUiOgogICAgICAgICAgY2FzZSAidXRmLTE2bGUiOgogICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIEJ1ZmZlcjEwLmNvbmNhdCA9IGZ1bmN0aW9uIGNvbmNhdChsaXN0LCBsZW5ndGgpIHsKICAgICAgICBpZiAoIUFycmF5LmlzQXJyYXkobGlzdCkpIHsKICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoJyJsaXN0IiBhcmd1bWVudCBtdXN0IGJlIGFuIEFycmF5IG9mIEJ1ZmZlcnMnKTsKICAgICAgICB9CiAgICAgICAgaWYgKGxpc3QubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICByZXR1cm4gQnVmZmVyMTAuYWxsb2MoMCk7CiAgICAgICAgfQogICAgICAgIGxldCBpOwogICAgICAgIGlmIChsZW5ndGggPT09IHZvaWQgMCkgewogICAgICAgICAgbGVuZ3RoID0gMDsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBsaXN0Lmxlbmd0aDsgKytpKSB7CiAgICAgICAgICAgIGxlbmd0aCArPSBsaXN0W2ldLmxlbmd0aDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgY29uc3QgYnVmZmVyID0gQnVmZmVyMTAuYWxsb2NVbnNhZmUobGVuZ3RoKTsKICAgICAgICBsZXQgcG9zID0gMDsKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7ICsraSkgewogICAgICAgICAgbGV0IGJ1ZiA9IGxpc3RbaV07CiAgICAgICAgICBpZiAoaXNJbnN0YW5jZShidWYsIFVpbnQ4QXJyYXkpKSB7CiAgICAgICAgICAgIGlmIChwb3MgKyBidWYubGVuZ3RoID4gYnVmZmVyLmxlbmd0aCkgewogICAgICAgICAgICAgIGlmICghQnVmZmVyMTAuaXNCdWZmZXIoYnVmKSkKICAgICAgICAgICAgICAgIGJ1ZiA9IEJ1ZmZlcjEwLmZyb20oYnVmKTsKICAgICAgICAgICAgICBidWYuY29weShidWZmZXIsIHBvcyk7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgVWludDhBcnJheS5wcm90b3R5cGUuc2V0LmNhbGwoYnVmZmVyLCBidWYsIHBvcyk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSBpZiAoIUJ1ZmZlcjEwLmlzQnVmZmVyKGJ1ZikpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcignImxpc3QiIGFyZ3VtZW50IG11c3QgYmUgYW4gQXJyYXkgb2YgQnVmZmVycycpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgYnVmLmNvcHkoYnVmZmVyLCBwb3MpOwogICAgICAgICAgfQogICAgICAgICAgcG9zICs9IGJ1Zi5sZW5ndGg7CiAgICAgICAgfQogICAgICAgIHJldHVybiBidWZmZXI7CiAgICAgIH07C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dGYtOCI6CiAgICAgICAgICAgICAgcmV0dXJuIHV0ZjhUb0J5dGVzKHN0cmluZykubGVuZ3RoOwogICAgICAgICAgICBjYXNlICJ1Y3MyIjoKICAgICAgICAgICAgY2FzZSAidWNzLTIiOgogICAgICAgICAgICBjYXNlICJ1dGYxNmxlIjoKICAgICAgICAgICAgY2FzZSAidXRmLTE2bGUiOgogICAgICAgICAgICAgIHJldHVybiBsZW4gKiAyOwogICAgICAgICAgICBjYXNlICJoZXgiOgogICAgICAgICAgICAgIHJldHVybiBsZW4gPj4+IDE7CiAgICAgICAgICAgIGNhc2UgImJhc2U2NCI6CiAgICAgICAgICAgICAgcmV0dXJuIGJhc2U2NFRvQnl0ZXMoc3RyaW5nKS5sZW5ndGg7CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgaWYgKGxvd2VyZWRDYXNlKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gbXVzdE1hdGNoID8gLTEgOiB1dGY4VG9CeXRlcyhzdHJpbmcpLmxlbmd0aDsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgZW5jb2RpbmcgPSAoIiIgKyBlbmNvZGluZykudG9Mb3dlckNhc2UoKTsKICAgICAgICAgICAgICBsb3dlcmVkQ2FzZSA9IHRydWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIEJ1ZmZlcjEwLmJ5dGVMZW5ndGggPSBieXRlTGVuZ3RoOwogICAgICBmdW5jdGlvbiBzbG93VG9TdHJpbmcoZW5jb2RpbmcsIHN0YXJ0LCBlbmQpIHsKICAgICAgICBsZXQgbG93ZXJlZENhc2UgPSBmYWxzZTsKICAgICAgICBpZiAoc3RhcnQgPT09IHZvaWQgMCB8fCBzdGFydCA8IDApIHsKICAgICAgICAgIHN0YXJ0ID0gMDsKICAgICAgICB9CiAgICAgICAgaWYgKHN0YXJ0ID4gdGhpcy5sZW5ndGgpIHsKICAgICAgICAgIHJldHVybiAiIjsKICAgICAgICB9CiAgICAgICAgaWYgKGVuZCA9PT0gdm9pZCAwIHx8IGVuZCA+IHRoaXMubGVuZ3RoKSB7CiAgICAgICAgICBlbmQgPSB0aGlzLmxlbmd0aDsKICAgICAgICB9CiAgICAgICAgaWYgKGVuZCA8PSAwKSB7CiAgICAgICAgICByZXR1cm4gIiI7CiAgICAgICAgfQogICAgICAgIGVuZCA+Pj49IDA7CiAgICAgICAgc3RhcnQgPj4+PSAwOwogICAgICAgIGlmIChlbmQgPD0gc3RhcnQpIHsKICAgICAgICAgIHJldHVybiAiIjsKICAgICAgICB9CiAgICAgICAgaWYgKCFlbmNvZGluZykKICAgICAgICAgIGVuY29kaW5nID0gInV0ZjgiOwogICAgICAgIHdoaWxlICh0cnVlKSB7CiAgICAgICAgICBzd2l0Y2ggKGVuY29kaW5nKSB7CiAgICAgICAgICAgIGNhc2UgImhleCI6CiAgICAgICAgICAgICAgcmV0dXJuIGhleFNsaWNlKHRoaXMsIHN0YXJ0LCBlbmQpOwogICAgICAgICAgICBjYXNlICJ1dGY4IjoKICAgICAgICAgICAgY2FzZSAidXRmLTgiOgogICAgICAgICAgICAgIHJldHVybiB1dGY4U2xpY2UodGhpcywgc3RhcnQsIGVuZCk7CiAgICAgICAgICAgIGNhc2UgImFzY2lpIjoKICAgICAgICAgICAgICByZXR1cm4gYXNjaWlTbGljZSh0aGlzLCBzdGFydCwgZW5kKTsKICAgICAgICAgICAgY2FzZSAibGF0aW4xIjoKICAgICAgICAgICAgY2FzZSAiYmluYXJ5IjoKICAgICAgICAgICAgICByZXR1cm4gbGF0aW4xU2xpY2UodGhpcywgc3RhcnQsIGVuZCk7CiAgICAgICAgICAgIGNhc2UgImJhc2U2NCI6CiAgICAgICAgICAgICAgcmV0dXJuIGJhc2U2NFNsaWNlKHRoaXMsIHN0YXJ0LCBlbmQpOwogICAgICAgICAgICBjYXNlICJ1Y3MyIjoKICAgICAgICAgICAgY2FzZSAidWNzLTIiOgogICAgICAgICAgICBjYXNlICJ1dGYxNmxlIjoKICAgICAgICAgICAgY2FzZSAidXRmLTE2bGUiOgogICAgICAgICAgICAgIHJldHVybiB1dGYxNmxlU2xpY2UodGhpcywgc3RhcnQsIGVuZCk7CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgaWYgKGxvd2VyZWRDYXNlKQogICAgICAgICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcigiVW5rbm93biBlbmNvZGluZzogIiArIGVuY29kaW5nKTsKICAgICAgICAgICAgICBlbmNvZGluZyA9IChlbmNvZGluZyArICIiKS50b0xvd2VyQ2FzZSgpOwogICAgICAgICAgICAgIGxvd2VyZWRDYXNlID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgQnVmZmVyMTAucHJvdG90eXBlLl9pc0J1ZmZlciA9IHRydWU7CiAgICAgIGZ1bmN0aW9uIHN3YXAoYiwgbiwgbSkgewogICAgICAgIGNvbnN0IGkgPSBiW25dOwogICAgICAgIGJbbl0gPSBiW21dOwogICAgICAgIGJbbV0gPSBpOwogICAgICB9CiAgICAgIEJ1ZmZlcjEwLnByb3RvdHlwZS5zd2FwMTYgPSBmdW5jdGlvbiBzd2FwMTYoKSB7CiAgICAgICAgY29uc3QgbGVuID0gdGhpcy5sZW5ndGg7CiAgICAgICAgaWYgKGxlbiAlIDIgIT09IDApIHsKICAgICAgICAgIHRocm93IG5ldyBSYW5nZUVycm9yKCJCdWZmZXIgc2l6ZSBtdXN0IGJlIGEgbXVsdGlwbGUgb2YgMTYtYml0cyIpOwogICAgICAgIH0KICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbjsgaSArPSAyKSB7CiAgICAgICAgICBzd2FwKHRoaXMsIGksIGkgKyAxKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgIH07CiAgICAgIEJ1ZmZlcjEwLnByb3RvdHlwZS5zd2FwMzIgPSBmdW5jdGlvbiBzd2FwMzIoKSB7CiAgICAgICAgY29uc3QgbGVuID0gdGhpcy5sZW5ndGg7CiAgICAgICAgaWYgKGxlbiAlIDQgIT09IDApIHsKICAgICAgICAgIHRocm93IG5ldyBSYW5nZUVycm9yKCJCdWZmZXIgc2l6ZSBtdXN0IGJlIGEgbXVsdGlwbGUgb2YgMzItYml0cyIpOwogICAgICAgIH0KICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbjsgaSArPSA0KSB7CiAgICAgICAgICBzd2FwKHRoaXMsIGksIGkgKyAzKTsKICAgICAgICAgIHN3YXAodGhpcywgaSArIDEsIGkgKyAyKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgIH07CiAgICAgIEJ1ZmZlcjEwLnByb3RvdHlwZS5zd2FwNjQgPSBmdW5jdGlvbiBzd2FwNjQoKSB7CiAgICAgICAgY29uc3QgbGVuID0gdGhpcy5sZW5ndGg7CiAgICAgICAgaWYgKGxlbiAlIDggIT09IDApIHsKICAgICAgICAgIHRocm93IG5ldyBSYW5nZUVycm9yKCJCdWZmZXIgc2l6ZSBtdXN0IGJlIGEgbXVsdGlwbGUgb2YgNjQtYml0cyIpOwogICAgICAgIH0KICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbjsgaSArPSA4KSB7CiAgICAgICAgICBzd2FwKHRoaXMsIGksIGkgKyA3KTsKICAgICAgICAgIHN3YXAodGhpcywgaSArIDEsIGkgKyA2KTsKICAgICAgICAgIHN3YXAodGhpcywgaSArIDIsIGkgKyA1KTsKICAgICAgICAgIHN3YXAodGhpcywgaSArIDMsIGkgKyA0KTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgIH07CiAgICAgIEJ1ZmZlcjEwLnByb3RvdHlwZS50b1N0cmluZyA9IGZ1bmN0aW9uIHRvU3RyaW5nKCkgewogICAgICAgIGNvbnN0IGxlbmd0aCA9IHRoaXMubGVuZ3RoOwogICAgICAgIGlmIChsZW5ndGggPT09IDApCiAgICAgICAgICBy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VuZCA+IHRoaXMubGVuZ3RoKSB7CiAgICAgICAgICB0aHJvdyBuZXcgUmFuZ2VFcnJvcigib3V0IG9mIHJhbmdlIGluZGV4Iik7CiAgICAgICAgfQogICAgICAgIGlmICh0aGlzU3RhcnQgPj0gdGhpc0VuZCAmJiBzdGFydCA+PSBlbmQpIHsKICAgICAgICAgIHJldHVybiAwOwogICAgICAgIH0KICAgICAgICBpZiAodGhpc1N0YXJ0ID49IHRoaXNFbmQpIHsKICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICB9CiAgICAgICAgaWYgKHN0YXJ0ID49IGVuZCkgewogICAgICAgICAgcmV0dXJuIDE7CiAgICAgICAgfQogICAgICAgIHN0YXJ0ID4+Pj0gMDsKICAgICAgICBlbmQgPj4+PSAwOwogICAgICAgIHRoaXNTdGFydCA+Pj49IDA7CiAgICAgICAgdGhpc0VuZCA+Pj49IDA7CiAgICAgICAgaWYgKHRoaXMgPT09IHRhcmdldCkKICAgICAgICAgIHJldHVybiAwOwogICAgICAgIGxldCB4ID0gdGhpc0VuZCAtIHRoaXNTdGFydDsKICAgICAgICBsZXQgeSA9IGVuZCAtIHN0YXJ0OwogICAgICAgIGNvbnN0IGxlbiA9IE1hdGgubWluKHgsIHkpOwogICAgICAgIGNvbnN0IHRoaXNDb3B5ID0gdGhpcy5zbGljZSh0aGlzU3RhcnQsIHRoaXNFbmQpOwogICAgICAgIGNvbnN0IHRhcmdldENvcHkgPSB0YXJnZXQuc2xpY2Uoc3RhcnQsIGVuZCk7CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsZW47ICsraSkgewogICAgICAgICAgaWYgKHRoaXNDb3B5W2ldICE9PSB0YXJnZXRDb3B5W2ldKSB7CiAgICAgICAgICAgIHggPSB0aGlzQ29weVtpXTsKICAgICAgICAgICAgeSA9IHRhcmdldENvcHlbaV07CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoeCA8IHkpCiAgICA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5sZW5ndGggLSAxOwogICAgICAgIH0gZWxzZSBpZiAoYnl0ZU9mZnNldCA8IDApIHsKICAgICAgICAgIGlmIChkaXIpCiAgICAgICAgICAgIGJ5dGVPZmZzZXQgPSAwOwogICAgICAgICAgZWxzZQogICAgICAgICAgICByZXR1cm4gLTE7CiAgICAgICAgfQogICAgICAgIGlmICh0eXBlb2YgdmFsID09PSAic3RyaW5nIikgewogICAgICAgICAgdmFsID0gQnVmZmVyMTAuZnJvbSh2YWwsIGVuY29kaW5nKTsKICAgICAgICB9CiAgICAgICAgaWYgKEJ1ZmZlcjEwLmlzQnVmZmVyKHZhbCkpIHsKICAgICAgICAgIGlmICh2YWwubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBhcnJheUluZGV4T2YoYnVmZmVyLCB2YWwsIGJ5dGVPZmZzZXQsIGVuY29kaW5nLCBkaXIpOwogICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIHZhbCA9PT0gIm51bWJlciIpIHsKICAgICAgICAgIHZhbCA9IHZhbCAmIDI1NTsKICAgICAgICAgIGlmICh0eXBlb2YgVWludDhBcnJheS5wcm90b3R5cGUuaW5kZXhPZiA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICBpZiAoZGlyKSB7CiAgICAgICAgICAgICAgcmV0dXJuIFVpbnQ4QXJyYXkucHJvdG90eXBlLmluZGV4T2YuY2FsbChidWZmZXIsIHZhbCwgYnl0ZU9mZnNldCk7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgcmV0dXJuIFVpbnQ4QXJyYXkucHJvdG90eXBlLmxhc3RJbmRleE9mLmNhbGwoYnVmZmVyLCB2YWwsIGJ5dGVPZmZzZXQpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gYXJyYXlJbmRleE9mKGJ1ZmZlciwgW3ZhbF0sIGJ5dGVPZmZzZXQsIGVuY29kaW5nLCBkaXIpOwogICAgICAgIH0KICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCJ2YWwgbXVzdCBiZSBzdHJpbmcsIG51bWJlciBvciBCdWZmZXIiKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBhcnJheUluZGV4T2YoYXJyLCB2YWwsIGJ5dGVPZmZzZXQsIGVuY29kaW5nLCBkaXIpIHsKICAgICAgICBsZXQgaW5kZXhTaXplID0gMTsKICAgICAgICBsZXQgYXJyTGVuZ3RoID0gYXJyLmxlbmd0aDsKICAgICAgICBsZXQgdmFsTGVuZ3RoID0gdmFsLmxlbmd0aDsKICAgICAgICBpZiAoZW5jb2RpbmcgIT09IHZvaWQgMCkgewogICAgICAgICAgZW5jb2RpbmcgPSBTdHJpbmcoZW5jb2RpbmcpLnRvTG93ZXJDYXNlKCk7CiAgICAgICAgICBpZiAoZW5jb2RpbmcgPT09ICJ1Y3MyIiB8fCBlbmNvZGluZyA9PT0gInVjcy0yIiB8fCBlbmNvZGluZyA9PT0gInV0ZjE2bGUiIHx8IGVuY29kaW5nID09PSAidXRmLTE2bGUiKSB7CiAgICAgICAgICAgIGlmIChhcnIubGVuZ3RoIDwgMiB8fCB2YWwubGVuZ3RoIDwgMikgewogICAgICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpbmRleFNpemUgPSAyOwogICAgICAgICAgICBhcnJMZW5ndGggLz0gMjsKICAgICAgICAgICAgdmFsTGVuZ3RoIC89IDI7CiAgICAgICAgICAgIGJ5dGVPZmZzZXQgLz0gMjsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZnVuY3Rpb24gcmVhZChidWYsIGkyKSB7CiAgICAgICAgICBpZiAoaW5kZXhTaXplID09PSAxKSB7CiAgICAgICAgICAgIHJldHVybiBidWZbaTJdOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcmV0dXJuIGJ1Zi5yZWFkVUludDE2QkUoaTIgKiBpbmRleFNpemUpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBsZXQgaTsKICAgICAgICBpZiAoZGlyKSB7CiAgICAgICAgICBsZXQgZm91bmRJbmRleCA9IC0xOwogICAgICAgICAgZm9yIChpID0gYnl0ZU9mZnNldDsgaSA8IGFyckxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgIGlmIChyZWFkKGFyciwgaSkgPT09IHJlYWQodmFsLCBmb3VuZEluZGV4ID09PSAtMSA/IDAgOiBpIC0gZm91bmRJbmRleCkpIHsKICAgICAgICAgICAgICBpZiAoZm91bmRJbmRleCA9PT0gLTEpCiAgICAgICAgICAgICAgICBmb3VuZEluZGV4ID0gaTsKICAgICAgICAgICAgICBpZiAoaSAtIGZvdW5kSW5kZXggKyAxID09PSB2YWxMZW5ndGgpCiAgICAgICAgICAgICAgICByZXR1cm4gZm91bmRJbmRleCAqIGluZGV4U2l6ZTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBpZiAoZm91bmRJbmRleCAhPT0gLTEpCiAgICAgICAgICAgICAgICBpIC09IGkgLSBmb3VuZEluZGV4OwogICAgICAgICAgICAgIGZvdW5kSW5kZXggPSAtMTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBpZiAoYnl0ZU9mZnNldCArIHZhbExlbmd0aCA+IGFyckxlbmd0aCkKICAgICAgICAgICAgYnl0ZU9mZnNldCA9IGFyckxlbmd0aCAtIHZhbExlbmd0aDsKICAgICAgICAgIGZvciAoaSA9IGJ5dGVPZmZzZXQ7IGkgPj0gMDsgaS0tKSB7CiAgICAgICAgICAgIGxldCBmb3VuZCA9IHRydWU7CiAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgdmFsTGVuZ3RoOyBqKyspIHsKICAgICAgICAgICAgICBpZiAocmVhZChhcnIsIGkgKyBqKSAhPT0gcmVhZCh2YWwsIGopKSB7CiAgICAgICAgICAgICAgICBmb3VuZC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md0aCk7CiAgICAgICAgICAgIGNhc2UgImFzY2lpIjoKICAgICAgICAgICAgY2FzZSAibGF0aW4xIjoKICAgICAgICAgICAgY2FzZSAiYmluYXJ5IjoKICAgICAgICAgICAgICByZXR1cm4gYXNjaWlXcml0ZSh0aGlzLCBzdHJpbmcsIG9mZnNldCwgbGVuZ3RoKTsKICAgICAgICAgICAgY2FzZSAiYmFzZTY0IjoKICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0V3JpdGUodGhpcywgc3RyaW5nLCBvZmZzZXQsIGxlbmd0aCk7CiAgICAgICAgICAgIGNhc2UgInVjczIiOgogICAgICAgICAgICBjYXNlICJ1Y3MtMiI6CiAgICAgICAgICAgIGNhc2UgInV0ZjE2bGUiOgogICAgICAgICAgICBjYXNlICJ1dGYtMTZsZSI6CiAgICAgICAgICAgICAgcmV0dXJuIHVjczJXcml0ZSh0aGlzLCBzdHJpbmcsIG9mZnNldCwgbGVuZ3RoKTsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICBpZiAobG93ZXJlZENhc2UpCiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCJVbmtub3duIGVuY29kaW5nOiAiICsgZW5jb2RpbmcpOwogICAgICAgICAgICAgIGVuY29kaW5nID0gKCIiICsgZW5jb2RpbmcpLnRvTG93ZXJDYXNlKCk7CiAgICAgICAgICAgICAgbG93ZXJlZENhc2UgPSB0cnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfTsKICAgICAgQnVmZmVyMTAucHJvdG90eXBlLnRvSlNPTiA9IGZ1bmN0aW9uIHRvSlNPTigpIHsKICAgICAgICByZXR1cm4gewogICAgICAgICAgdHlwZTogIkJ1ZmZlciIsCiAgICAgICAgICBkYXRhOiBBcnJheS5wcm90b3R5cGUuc2xpY2UuY2FsbCh0aGlzLl9hcnIgfHwgdGhpcywgMCkKICAgICAgICB9OwogICAgICB9OwogICAgICBmdW5jdGlvbiBiYXNlNjRTbGljZSh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AgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgICAgIHNlY29uZEJ5dGUgPSBidWZbaSArIDFdOwogICAgICAgICAgICAgICAgaWYgKChzZWNvbmRCeXRlICYgMTkyKSA9PT0gMTI4KSB7CiAgICAgICAgICAgICAgICAgIHRlbXBDb2RlUG9pbnQgPSAoZmlyc3RCeXRlICYgMzEpIDw8IDYgfCBzZWNvbmRCeXRlICYgNjM7CiAgICAgICAgICAgICAgICAgIGlmICh0ZW1wQ29kZVBvaW50ID4gMTI3KSB7CiAgICAgICAgICAgICAgICAgICAgY29kZVBvaW50ID0gdGVtcENvZGVQb2ludDsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSAzOgogICAgICAgICAgICAgICAgc2Vjb25kQnl0ZSA9IGJ1ZltpICsgMV07CiAgICAgICAgICAgICAgICB0aGlyZEJ5dGUgPSBidWZbaSArIDJdOwogICAgICAgICAgICAgICAgaWYgKChzZWNvbmRCeXRlICYgMTkyKSA9PT0gMTI4ICYmICh0aGlyZEJ5dGUgJiAxOTIpID09PSAxMjgpIHsKICAgICAgICAgICAgICAgICAgdGVtcENvZGVQb2ludCA9IChmaXJzdEJ5dGUgJiAxNSkgPDwgMTIgfCAoc2Vjb25kQnl0ZSAmIDYzKSA8PCA2IHwgdGhpcmRCeXRlICYgNjM7CiAgICAgICAgICAgICAgICAgIGlmICh0ZW1wQ29kZVBvaW50ID4gMjA0NyAmJiAodGVtcENvZGVQb2ludCA8IDU1Mjk2IHx8IHRlbXBDb2RlUG9pbnQgPiA1NzM0MykpIHsKICAgICAgICAgICAgICAgICAgICBjb2RlUG9pbnQgPSB0ZW1wQ29kZVBvaW50OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIDQ6CiAgICAgICAgICAgICAgICBzZWNvbmRCeXRlID0gYnVmW2kgKyAxXTsKICAgICAgICAgICAgICAgIHRoaXJkQnl0ZSA9IGJ1ZltpICsgMl07CiAgICAgICAgICAgICAgICBmb3VydGhCeXRlID0gYnVmW2kgKyAzXTsKICAgICAgICAgICAgICAgIGlmICgoc2Vjb25kQnl0ZSAmIDE5MikgPT09IDEyOCAmJiAodGhpcmRCeXRlICYgMTkyKSA9PT0gMTI4ICYmIChmb3VydGhCeXRlICYgMTkyKSA9PT0gMTI4KSB7CiAgICAgICAgICAgICAgICAgIHRlbXBDb2RlUG9pbnQgPSAoZmlyc3RCeXRlICYgMTUpIDw8IDE4IHwgKHNlY29uZEJ5dGUgJiA2MykgPDwgMTIgfCAodGhpcmRCeXRlICYgNjMpIDw8IDYgfCBmb3VydGhCeXRlICYgNjM7CiAgICAgICAgICAgICAgICAgIGlmICh0ZW1wQ29kZVBvaW50ID4gNjU1MzUgJiYgdGVtcENvZGVQb2ludCA8IDExMTQxMTIpIHsKICAgICAgICAgICAgICAgICAgICBjb2RlUG9pbnQgPSB0ZW1wQ29kZVBvaW50OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChjb2RlUG9pbnQgPT09IG51bGwpIHsKICAgICAgICAgICAgY29kZVBvaW50ID0gNjU1MzM7CiAgICAgICAgICAgIGJ5dGVzUGVyU2VxdWVuY2UgPSAxOwogICAgICAgICAgfSBlbHNlIGlmIChjb2RlUG9pbnQgPiA2NTUzNSkgewogICAgICAgICAgICBjb2RlUG9pbnQgLT0gNjU1MzY7CiAgICAgICAgICAgIHJlcy5wdXNoKGNvZGVQb2ludCA+Pj4gMTAgJiAxMDIzIHwgNTUyOTYpOwogICAgICAgICAgICBjb2RlUG9pbnQgPSA1NjMyMCB8IGNvZGVQb2ludCAmIDEwMjM7CiAgICAgICAgICB9CiAgICAgICAgICByZXMucHVzaChjb2RlUG9pbnQpOwogICAgICAgICAgaSArPSBie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NlKHN0YXJ0LCBlbmQpIHsKICAgICAgICBjb25zdCBsZW4gPSB0aGlzLmxlbmd0aDsKICAgICAgICBzdGFydCA9IH5+c3RhcnQ7CiAgICAgICAgZW5kID0gZW5kID09PSB2b2lkIDAgPyBsZW4gOiB+fmVuZDsKICAgICAgICBpZiAoc3RhcnQgPCAwKSB7CiAgICAgICAgICBzdGFydCArPSBsZW47CiAgICAgICAgICBpZiAoc3RhcnQgPCAwKQogICAgICAgICAgICBzdGFydCA9IDA7CiAgICAgICAgfSBlbHNlIGlmIChzdGFydCA+IGxlbikgewogICAgICAgICAgc3RhcnQgPSBsZW47CiAgICAgICAgfQogICAgICAgIGlmIChlbmQgPCAwKSB7CiAgICAgICAgICBlbmQgKz0gbGVuOwogICAgICAgICAgaWYgKGVuZCA8IDApCiAgICAgICAgICAgIGVuZCA9IDA7CiAgICAgICAgfSBlbHNlIGlmIChlbmQgPiBsZW4pIHsKICAgICAgICAgIGVuZCA9IGxlbjsKICAgICAgICB9CiAgICAgICAgaWYgKGVuZCA8IHN0YXJ0KQogICAgICAgICAgZW5kID0gc3RhcnQ7CiAgICAgICAgY29uc3QgbmV3QnVmID0gdGhpcy5zdWJhcnJheShzdGFydCwgZW5kKTsKICAgICAgICBPYmplY3Quc2V0UHJvdG90eXBlT2YobmV3QnVmLCBCdWZmZXIxMC5wcm90b3R5cGUpOwogICAgICAgIHJldHVybiBuZXdCdWY7CiAgICAgIH07CiAgICAgIGZ1bmN0aW9uIGNoZWNrT2Zmc2V0KG9mZnNldCwgZXh0LCBsZW5ndGgpIHsKICAgICAgICBpZiAob2Zmc2V0ICUgMSAhPT0gMCB8fCBvZmZzZXQgPCAwKQogICAgICAgICAgdGhyb3cgbmV3IFJhbmdlRXJyb3IoIm9mZnNldCBpcyBub3QgdWludCIpOwogICAgICAgIGlmIChvZmZzZXQgKyBleHQgPiBsZW5ndGgpCiAgICAgICAgICB0aHJvdyBuZXcgUmFuZ2VFcnJvcigiVHJ5aW5nIHRvIGFj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IGxvOwogICAgICAgIGxvID0gbG8gPj4gODsKICAgICAgICBidWZbb2Zmc2V0KytdID0gbG87CiAgICAgICAgbGV0IGhpID0gTnVtYmVyKHZhbHVlID4+IEJpZ0ludCgzMikgJiBCaWdJbnQoNDI5NDk2NzI5NSkpOwogICAgICAgIGJ1ZltvZmZzZXQrK10gPSBoaTsKICAgICAgICBoaSA9IGhpID4+IDg7CiAgICAgICAgYnVmW29mZnNldCsrXSA9IGhpOwogICAgICAgIGhpID0gaGkgPj4gODsKICAgICAgICBidWZbb2Zmc2V0KytdID0gaGk7CiAgICAgICAgaGkgPSBoaSA+PiA4OwogICAgICAgIGJ1ZltvZmZzZXQrK10gPSBoaTsKICAgICAgICByZXR1cm4gb2Zmc2V0OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIHdydEJpZ1VJbnQ2NEJFKGJ1ZiwgdmFsdWUsIG9mZnNldCwgbWluLCBtYXgpIHsKICAgICAgICBjaGVja0ludEJJKHZhbHVlLCBtaW4sIG1heCwgYnVmLCBvZmZzZXQsIDcpOwogICAgICAgIGxldCBsbyA9IE51bWJlcih2YWx1ZSAmIEJpZ0ludCg0Mjk0OTY3Mjk1KSk7CiAgICAgICAgYnVmW29mZnNldCArIDddID0gbG87CiAgICAgICAgbG8gPSBsbyA+PiA4OwogICAgICAgIGJ1ZltvZmZzZXQgKyA2XSA9IGxvOwogICAgICAgIGxvID0gbG8gPj4gODsKICAgICAgICBidWZbb2Zmc2V0ICsgNV0gPSBsbzsKICAgICAgICBsbyA9IGxvID4+IDg7CiAgICAgICAgYnVmW29mZnNldCArIDRdID0gbG87CiAgICAgICAgbGV0IGhpID0gTnVtYmVyKHZhbHVlID4+IEJpZ0ludCgzMikgJiBCaWdJbnQoNDI5NDk2NzI5NSkpOwogICAgICAgIGJ1ZltvZmZzZXQgKyAzXSA9IGhpOwogICAgICAgIGhpID0gaGkgPj4gODsKICAgICAgICBidWZbb2Zmc2V0ICsgMl0gPSBoaTsKICAgICAgICBoaSA9I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AgICAgICAgaWYgKHR5cGVvZiBzdGFydCA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgZW5jb2RpbmcgPSBzdGFydDsKICAgICAgICAgICAgc3RhcnQgPSAwOwogICAgICAgICAgICBlbmQgPSB0aGlzLmxlbmd0aDsKICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGVuZCA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgZW5jb2RpbmcgPSBlbmQ7CiAgICAgICAgICAgIGVuZCA9IHRoaXMubGVuZ3RoOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGVuY29kaW5nICE9PSB2b2lkIDAgJiYgdHlwZW9mIGVuY29kaW5nICE9PSAic3RyaW5nIikgewogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCJlbmNvZGluZyBtdXN0IGJlIGEgc3RyaW5nIik7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAodHlwZW9mIGVuY29kaW5nID09PSAic3RyaW5nIiAmJiAhQnVmZmVyMTAuaXNFbmNvZGluZyhlbmNvZGluZykpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcigiVW5rbm93biBlbmNvZGluZzogIiArIGVuY29kaW5nKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh2YWwubGVuZ3RoID09PSAxKSB7CiAgICAgICAgICAgIGNvbnN0IGNvZGUgPSB2YWwuY2hhckNvZGVBdCgwKTsKICAgICAgICAgICAgaWYgKGVuY29kaW5nID09PSAidXRmOCIgJiYgY29kZSA8IDEyOCB8fCBlbmNvZGluZyA9PT0gImxhdGluMSIpIHsKICAgICAgICAgICAgICB2YWwgPSBjb2RlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgdmFsID09PSAibnVtYmVyIikgewogICAgICAgICAgdmFsID0gdmFsICYgMjU1OwogICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIHZhbCA9PT0gImJvb2xlYW4iKSB7CiAgICAgICAgICB2YWwgPSBOdW1iZXIodmFsKTsKICAgICAgICB9CiAgICAgICAgaWYgKHN0YXJ0IDwgMCB8fCB0aGlzLmxlbmd0aCA8IHN0YXJ0IHx8IHRoaXMubGVuZ3RoIDwgZW5kKSB7CiAgICAgICAgICB0aHJvdyBuZXcgUmFuZ2VFcnJvcigiT3V0IG9mIHJhbmdlIGluZGV4Iik7CiAgICAgICAgfQogICAgICAgIGlmIChlbmQgPD0gc3RhcnQpIHsKICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgIH0KICAgICAgICBzdGFydCA9IHN0YXJ0ID4+PiAwOwogICAgICAgIGVuZCA9IGVuZCA9PT0gdm9pZCAwID8gdGhpcy5sZW5ndGggOiBlbmQgPj4+IDA7CiAgICAgICAgaWYgKCF2YWwpCiAgICAgICAgICB2YWwgPSAwOwogICAgICAgIGxldCBpOwogICAgICAgIGlmICh0eXBlb2YgdmFsID09PSAibnVtYmVyIikgewogICAgICAgICAgZm9yIChpID0gc3RhcnQ7IGkgPCBlbmQ7ICsraSkgewogICAgICAgICAgICB0aGlzW2ldID0gdmFsOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb25zdCBieXRlcyA9IEJ1ZmZlcjEwLmlzQnVmZmVyKHZhbCkgPyB2YWwgOiBCdWZmZXIxMC5mcm9tKHZhbCwgZW5jb2RpbmcpOwogICAgICAgICAgY29uc3QgbGVuID0gYnl0ZXMubGVuZ3RoOwogICAgICAgICAgaWYgKGxlbiA9PT0gMCkgewogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCdUaGUgdmFsdWUgIicgKyB2YWwgKyAnIiBpcyBpbnZhbGlkIGZvciBhcmd1bWVudCAidmFsdWUiJyk7CiAgICAgICAgICB9CiAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgZW5kIC0gc3RhcnQ7ICsraSkgewogICAgICAgICAgICB0aGlzW2kgKyBzdGFydF0gPSBieXRlc1tpICUgbGVuXTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgIH07CiAgICAgIHZhciBlcnJvcnMgPSB7fTsKICAgICAgZnVuY3Rpb24gRShzeW0sIGdldE1lc3NhZ2UsIEJhc2UpIHsKICAgICAgICBlcnJvcnNbc3ltXSA9IGNsYXNzIE5vZGVFcnJvciBleHRlbmRzIEJhc2UgewogICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgIHN1cGVyKCk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAibWVzc2FnZSIsIHsKICAgICAgICAgICAgICB2YWx1ZTogZ2V0TWVzc2FnZS5hcHBseSh0aGlzLCBhcmd1bWVudHMpLAogICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZQogICAgICAgICAgICB9KTsKICAgICAgICAgICAgdGhpcy5uYW1lID0gYCR7dGhpcy5uYW1lfSBbJHtzeW19XWA7CiAgICAgICAgICAgIHRoaXMuc3RhY2s7CiAgICAgICAgICAgIGRlbGV0ZSB0aGlzLm5hbWU7CiAgICAgICAgICB9CiAgICAgICAgICBnZXQgY29kZSgpIHsKICAgICAgICAgICAgcmV0dXJuIHN5bTsKICAgICAgICAgIH0KICAgICAgICAgIHNldCBjb2RlKHZhbHVlKSB7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAiY29kZSIsIHsKICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZQogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICAgIHRvU3RyaW5nKCkgewogICAgICAgICAgICByZXR1cm4gYCR7dGhpcy5uYW1lfSBb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zdHJpbmcsIHVuaXRzKSB7CiAgICAgICAgdW5pdHMgPSB1bml0cyB8fCBJbmZpbml0eTsKICAgICAgICBsZXQgY29kZVBvaW50OwogICAgICAgIGNvbnN0IGxlbmd0aCA9IHN0cmluZy5sZW5ndGg7CiAgICAgICAgbGV0IGxlYWRTdXJyb2dhdGUgPSBudWxsOwogICAgICAgIGNvbnN0IGJ5dGVzID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsZW5ndGg7ICsraSkgewogICAgICAgICAgY29kZVBvaW50ID0gc3RyaW5nLmNoYXJDb2RlQXQoaSk7CiAgICAgICAgICBpZiAoY29kZVBvaW50ID4gNTUyOTUgJiYgY29kZVBvaW50IDwgNTczNDQpIHsKICAgICAgICAgICAgaWYgKCFsZWFkU3Vycm9nYXRlKSB7CiAgICAgICAgICAgICAgaWYgKGNvZGVQb2ludCA+IDU2MzE5KSB7CiAgICAgICAgICAgICAgICBpZiAoKHVuaXRzIC09IDMpID4gLTEpCiAgICAgICAgICAgICAgICAgIGJ5dGVzLnB1c2goMjM5LCAxOTEsIDE4OSk7CiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICB9IGVsc2UgaWYgKGkgKyAxID09PSBsZW5ndGgpIHsKICAgICAgICAgICAgICAgIGlmICgodW5pdHMgLT0gMykgPiAtMSkKICAgICAgICAgICAgICAgICAgYnl0ZXMucHVzaCgyMzksIDE5MSwgMTg5KTsKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBsZWFkU3Vycm9nYXRlID0gY29kZVBvaW50OwogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChjb2RlUG9pbnQgPCA1NjMyMCkgewogICAgICAgICAgICAgIGlmICgodW5pdHMgLT0gMykgPiAtMSkKICAgICAgICAgICAgICAgIGJ5dGVzLnB1c2goMjM5LCAxOTEsIDE4OSk7CiAgICAgICAgICAgICAgbGVhZFN1cnJvZ2F0ZSA9IGNvZGVQb2ludDsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb2RlUG9pbnQgPSAobGVhZFN1cnJvZ2F0ZSAtIDU1Mjk2IDw8IDEwIHwgY29kZVBvaW50IC0gNTYzMjApICsgNjU1MzY7CiAgICAgICAgICB9IGVsc2UgaWYgKGxlYWRTdXJyb2dhdGUpIHsKICAgICAgICAgICAgaWYgKCh1bml0cyAtPSAzKSA+IC0xKQogICAgICAgICAgICAgIGJ5dGVzLnB1c2goMjM5LCAxOTEsIDE4OSk7CiAgICAgICAgICB9CiAgICAgICAgICBsZWFkU3Vycm9nYXRlID0gbnVsbDsKICAgICAgICAgIGlmIChjb2RlUG9pbnQgPCAxMjgpIHsKICAgICAgICAgICAgaWYgKCh1bml0cyAtPSAxKSA8IDApCiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGJ5dGVzLnB1c2goY29kZVBvaW50KTsKICAgICAgICAgIH0gZWxzZSBpZiAoY29kZVBvaW50IDwgMjA0OCkgewogICAgICAgICAgICBpZiAoKHVuaXRzIC09IDIpIDwgMCkKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgYnl0ZXMucHVzaChjb2RlUG9pbnQgPj4gNiB8IDE5MiwgY29kZVBvaW50ICYgNjMgfCAxMjgpOwogICAgICAgICAgfSBlbHNlIGlmIChjb2RlUG9pbnQgPCA2NTUzNikgewogICAgICAgICAgICBpZiAoKHVuaXRzIC09IDMpIDwgMCkKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgYnl0ZXMucHVzaChjb2RlUG9pbnQgPj4gMTIgfCAyMjQsIGNvZGVQb2ludCA+PiA2ICYgNjMgfCAxMjgsIGNvZGVQb2ludCAmIDYzIHwgMTI4KTsKICAgICAgICAgIH0gZWxzZSBpZiAoY29kZVBvaW50IDwgMTExNDExMikgewogICAgICAgICAgICBpZiAoKHVuaXRzIC09IDQpIDwgMCkKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgYnl0ZXMucHVzaChjb2RlUG9pbnQgPj4gMTggfCAyNDAsIGNvZGVQb2ludCA+PiAxMiAmIDYzIHwgMTI4LCBjb2RlUG9pbnQgPj4gNiAmIDYzIHwgMTI4LCBjb2RlUG9pbnQgJiA2MyB8IDEyOCk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgY29kZSBwb2ludCIpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gYnl0ZXM7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gYXNjaWlUb0J5dGVzKHN0cikgewogICAgICAgIGNvbnN0IGJ5dGVBcnJheSA9IFtdOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgc3RyLmxlbmd0aDsgKytpKSB7CiAgICAgICAgICBieXRlQXJyYXkucHVzaChzdHIuY2hhckNvZGVBdChpKSAmIDI1NSk7CiAgICAgICAgfQogICAgICAgIHJldHVybiBieXRlQXJyYXk7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gdXRmMTZsZVRvQnl0ZXMoc3RyLCB1bml0cykgewogICAgICAgIGxldCBjLCBoaSwgbG87CiAgICAgICAgY29uc3QgYnl0ZUFycmF5ID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBzdHIubGVuZ3RoOyArK2kpIHsKICAgICAgICAgIGlmICgodW5pdHMgLT0gMikgPCAwKQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGMgPSBzdHIuY2hhckNvZGVBdChpKTsKICAgICAgICAgIGhpID0gYyA+PiA4OwogICAgICAgICAgbG8gPSBjICUgMjU2OwogICAgICAgICAgYnl0ZUFycmF5LnB1c2gobG8pOwogICAgICAgICAgYnl0ZUFycmF5LnB1c2goaGkpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gYnl0ZUFycmF5OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGJhc2U2NFRvQnl0ZXMoc3RyKSB7CiAgICAgICAgcmV0dXJuIGJhc2U2NC50b0J5dGVBcnJheShiYXNlNjRjbGVhbihzdHIpKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBibGl0QnVmZmVyKHNyYywgZHN0LCBvZmZzZXQsIGxlbmd0aCkgewogICAgICAgIGxldCBpOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW5ndGg7ICsraSkgewogICAgICAgICAgaWYgKGkgKyBvZmZzZXQgPj0gZHN0Lmxlbmd0aCB8fCBpID49IHNyYy5sZW5ndGgpCiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZHN0W2kgKyBvZmZzZXRdID0gc3JjW2ldOwogICAgICAgIH0KICAgICAgICByZXR1cm4gaTsKICAgICAgfQogICAgICBmdW5jdGlvbiBpc0luc3RhbmNlKG9iaiwgdHlwZSkgewogICAgICAgIHJldHVybiBvYmogaW5zdGFuY2VvZiB0eXBlIHx8IG9iaiAhPSBudWxsICYmIG9iai5jb25zdHJ1Y3RvciAhPSBudWxsICYmIG9iai5jb25zdHJ1Y3Rvci5uYW1lICE9IG51bGwgJiYgb2JqLmNvbnN0cnVjdG9yLm5hbWUgPT09IHR5cGUubmFtZTsKICAgICAgfQogICAgICBmdW5jdGlvbiBudW1iZXJJc05hTihvYmopIHsKICAgICAgICByZXR1cm4gb2JqICE9PSBvYmo7CiAgICAgIH0KICAgICAgdmFyIGhleFNsaWNlTG9va3VwVGFibGUgPSBmdW5jdGlvbigpIHsKICAgICAgICBjb25zdCBhbHBoYWJldCA9ICIwMTIzNDU2Nzg5YWJjZGVmIjsKICAgICAgICBjb25zdCB0YWJsZSA9IG5ldyBBcnJheSgyNTYpOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgMTY7ICsraSkgewogICAgICAgICAgY29uc3QgaTE2ID0gaSAqIDE2OwogICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCAxNjsgKytqKSB7Ci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b3RvdHlwZSwgcHJvdG9Qcm9wcyk7CiAgICAgICAgaWYgKHN0YXRpY1Byb3BzKQogICAgICAgICAgX2RlZmluZVByb3BlcnRpZXMoQ29uc3RydWN0b3IsIHN0YXRpY1Byb3BzKTsKICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoQ29uc3RydWN0b3IsICJwcm90b3R5cGUiLCB7CiAgICAgICAgICB3cml0YWJsZTogZmFsc2UKICAgICAgICB9KTsKICAgICAgICByZXR1cm4gQ29uc3RydWN0b3I7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gX2luaGVyaXRzKHN1YkNsYXNzLCBzdXBlckNsYXNzKSB7CiAgICAgICAgaWYgKHR5cGVvZiBzdXBlckNsYXNzICE9PSAiZnVuY3Rpb24iICYmIHN1cGVyQ2xhc3MgIT09IG51bGwpIHsKICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoIlN1cGVyIGV4cHJlc3Npb24gbXVzdCBlaXRoZXIgYmUgbnVsbCBvciBhIGZ1bmN0aW9uIik7CiAgICAgICAgfQogICAgICAgIHN1YkNsYXNzLnByb3RvdHlwZSA9IE9iamVjdC5jcmVhdGUoc3VwZXJDbGFzcyAmJiBzdXBlckNsYXNzLnByb3RvdHlwZSwgewogICAgICAgICAgY29uc3RydWN0b3I6IHsKICAgICAgICAgICAgdmFsdWU6IHN1YkNsYXNzLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlCiAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHN1YkNsYXNzLCAicHJvdG90eXBlIiwgewogICAgICAgICAgd3JpdGFibGU6IGZhbHNlCiAgICAgICAgfSk7CiAgICAgICAgaWYgKHN1cGVyQ2xhc3MpCiAgICAgICAgICBfc2V0UHJvdG90eXBlT2Yoc3ViQ2xhc3MsIHN1cGVyQ2xhc3MpOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIF9nZXRQcm90b3R5cGVPZihvKSB7CiAgICAgICAgX2dldFByb3RvdHlwZU9mID0gT2JqZWN0LnNldFByb3RvdHlwZU9mID8gT2JqZWN0LmdldFByb3RvdHlwZU9mLmJpbmQoKSA6IGZ1bmN0aW9uIF9nZXRQcm90b3R5cGVPZjIobzIpIHsKICAgICAgICAgIHJldHVybiBvMi5fX3Byb3RvX18gfHwgT2JqZWN0LmdldFByb3RvdHlwZU9mKG8yKTsKICAgICAgICB9OwogICAgICAgIHJldHVybiBfZ2V0UHJvdG90eXBlT2Yobyk7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gX3NldFByb3RvdHlwZU9mKG8sIHApIHsKICAgICAgICBfc2V0UHJvdG90eXBlT2YgPSBPYmplY3Quc2V0UHJvdG90eXBlT2YgPyBPYmplY3Quc2V0UHJvdG90eXBlT2YuYmluZCgpIDogZnVuY3Rpb24gX3NldFByb3RvdHlwZU9mMihvMiwgcDIpIHsKICAgICAgICAgIG8yLl9fcHJvdG9fXyA9IHAyOwogICAgICAgICAgcmV0dXJuIG8yOwogICAgICAgIH07CiAgICAgICAgcmV0dXJuIF9zZXRQcm90b3R5cGVPZihvLCBwKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBfaXNOYXRpdmVSZWZsZWN0Q29uc3RydWN0KCkgewogICAgICAgIGlmICh0eXBlb2YgUmVmbGVjdCA9PT0gInVuZGVmaW5lZCIgfHwgIVJlZmxlY3QuY29uc3RydWN0KQogICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIGlmIChSZWZsZWN0LmNvbnN0cnVjdC5zaGFtKQogICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIGlmICh0eXBlb2YgUHJveHkgPT09ICJmdW5jdGlvbiIpCiAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICB0cnkgewogICAgICAgICAgQm9vbGVhbi5wcm90b3R5cGUudmFsdWVPZi5jYWxsKFJlZmxlY3QuY29uc3RydWN0KEJvb2xlYW4sIFtdLCBmdW5jdGlvbigpIHsKICAgICAgICAgIH0pKTsKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgIH0KICAgICAgZnVuY3Rpb24gX2Fzc2VydFRoaXNJbml0aWFsaXplZChzZWxmMikgewogICAgICAgIGlmIChzZWxmMiA9PT0gdm9pZCAwKSB7CiAgICAgICAgICB0aHJvdyBuZXcgUmVmZXJlbmNlRXJyb3IoInRoaXMgaGFzbid0IGJlZW4gaW5pdGlhbGlzZWQgLSBzdXBlcigpIGhhc24ndCBiZWVuIGNhbGxlZCIpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gc2VsZjI7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gX3Bvc3NpYmxlQ29uc3RydWN0b3JSZXR1cm4oc2VsZjIsIGNhbGwpIHsKICAgICAgICBpZiAoY2FsbCAmJiAodHlwZW9mIGNhbGwgPT09ICJvYmplY3QiIHx8IHR5cGVvZiBjYWxsID09PSAiZnVuY3Rpb24iKSkgewogICAgICAgICAgcmV0dXJuIGNhbGw7CiAgICAgICAgfSBlbHNlIGlmIChjYWxsICE9PSB2b2lkIDApIHsKICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoIkRlcml2ZWQgY29uc3RydWN0b3JzIG1heSBvbmx5IHJldHVybiBvYmplY3Qgb3IgdW5kZWZpbmVkIik7CiAgICAgICAgfQogICAgICAgIHJldHVybiBfYXNzZXJ0VGhpc0luaXRpYWxpemVkKHNlbGYyKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBfY3JlYXRlU3VwZXIoRGVyaXZlZCkgewogICAgICAgIHZhciBoYXNOYXRpdmVSZWZsZWN0Q29uc3RydWN0ID0gX2lzTmF0aXZlUmVmbGVjdENvbnN0cnVjdCgpOwogICAgICAgIHJldHVybiBmdW5jdGlvbiBfY3JlYXRlU3VwZ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IHByb3BlcnR5LCByZWNlaXZlcikgewogICAgICAgICAgICB2YXIgYmFzZSA9IF9zdXBlclByb3BCYXNlKHRhcmdldCwgcHJvcGVydHkpOwogICAgICAgICAgICBpZiAoIWJhc2UpCiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB2YXIgZGVzYyA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IoYmFzZSwgcHJvcGVydHkpOwogICAgICAgICAgICBpZiAoZGVzYy5nZXQpIHsKICAgICAgICAgICAgICByZXR1cm4gZGVzYy5nZXQuY2FsbChhcmd1bWVudHMubGVuZ3RoIDwgMyA/IHRhcmdldCA6IHJlY2VpdmVyKTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gZGVzYy52YWx1ZTsKICAgICAgICAgIH07CiAgICAgICAgfQogICAgICAgIHJldHVybiBfZ2V0LmFwcGx5KHRoaXMsIGFyZ3VtZW50cyk7CiAgICAgIH0KICAgICAgdmFyIEVtaXR0ZXIgPSAvKiBAX19QVVJFX18gKi8gZnVuY3Rpb24oKSB7CiAgICAgICAgZnVuY3Rpb24gRW1pdHRlcjIoKSB7CiAgICAgICAgICBfY2xhc3NDYWxsQ2hlY2sodGhpcywgRW1pdHRlcjIpOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJsaXN0ZW5lcnMiLCB7CiAgICAgICAgICAgIHZhbHVlOiB7fSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZQogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICAgIF9jcmVhdGVDbGFzcyhFbWl0dGVyMiwgW3sKICAgICAgICAgIGtleTogImFkZEV2ZW50TGlzdGVuZXIiLAogICAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIGFkZEV2ZW50TGlzdGVuZXIodHlwZSwgY2FsbGJhY2ssIG9wdGlvbnMpIHsKICAgICAgICAgICAgaWYgKCEodHlwZSBpbiB0aGlzLmxpc3RlbmVycykpIHsKICAgICAgICAgICAgICB0aGlzLmxpc3RlbmVyc1t0eXBlXSA9IFtdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHRoaXMubGlzdGVuZXJzW3R5cGVdLnB1c2goewogICAgICAgICAgICAgIGNhbGxiYWNrLAogICAgICAgICAgICAgIG9wdGlvbnMKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9CiAgICAgICAgfSwgewogICAgICAgICAga2V5OiAicmVtb3ZlRXZlbnRMaXN0ZW5lciIsCiAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24gcmVtb3ZlRXZlbnRMaXN0ZW5lcih0eXBlLCBjYWxsYmFjaykgewogICAgICAgICAgICBpZiAoISh0eXBlIGluIHRoaXMubGlzdGVuZXJzKSkgewogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICB2YXIgc3RhY2sgPSB0aGlzLmxpc3RlbmVyc1t0eXBlXTsKICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIGwgPSBzdGFjay5sZW5ndGg7IGkgPCBsOyBpKyspIHsKICAgICAgICAgICAgICBpZiAoc3RhY2tbaV0uY2FsbGJhY2sgPT09IGNhbGxiYWNrKSB7CiAgICAgICAgICAgICAgICBzdGFjay5zcGxpY2UoaSwgMSk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfSwgewogICAgICAgICAga2V5OiAiZGlzcGF0Y2hFdmVudCIsCiAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24gZGlzcGF0Y2hFdmVudChldmVudCkgewogICAgICAgICAgICBpZiAoIShldmVudC50eXBlIGluIHRoaXMubGlzdGVuZXJzKSkgewogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICB2YXIgc3RhY2sgPSB0aGlzLmxpc3RlbmVyc1tldmVudC50eXBlXTsKICAgICAgICAgICAgdmFyIHN0YWNrVG9DYWxsID0gc3RhY2suc2xpY2UoKTsKICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIGwgPSBzdGFja1RvQ2FsbC5sZW5ndGg7IGkgPCBsOyBpKyspIHsKICAgICAgICAgICAgICB2YXIgbGlzdGVuZXIgPSBzdGFja1RvQ2FsbFtpXTsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgbGlzdGVuZXIuY2FsbGJhY2suY2FsbCh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgUHJvbWlzZS5yZXNvbHZlKCkudGhlbihmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgICAgdGhyb3cgZTsKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAobGlzdGVuZXIub3B0aW9ucyAmJiBsaXN0ZW5lci5vcHRpb25zLm9uY2UpIHsKICAgICAgICAgICAgICAgIHRoaXMucmVtb3ZlRXZlbnRMaXN0ZW5lcihldmVudC50eXBlLCBsaXN0ZW5lci5jYWxsYmFjayk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiAhZXZlbnQuZGVmYXVsdFByZXZlbnRlZDsKICAgICAgICAgIH0KICAgICAgICB9XSk7CiAgICAgICAgcmV0dXJuIEVtaXR0ZXIyOwogICAgICB9KCk7CiAgICAgIHZhciBBYm9ydFNpZ25hbCA9IC8qIEBfX1BVUkVfXyAqLyBmdW5jdGlvbihfRW1pdHRlcikgewogICAgICAgIF9pbmhlcml0cyhBYm9ydFNpZ25hbDIsIF9FbWl0dGVyKTsKICAgICAgICB2YXIgX3N1cGVyID0gX2NyZWF0ZVN1cGVyKEFib3J0U2lnbmFsMik7CiAgICAgICAgZnVuY3Rpb24gQWJvcnRTaWduYWwyKCkgewogICAgICAgICAgdmFyIF90aGlzOwogICAgICAgICAgX2NsYXNzQ2FsbENoZWNrKHRoaXMsIEFib3J0U2lnbmFsMik7CiAgICAgICAgICBfdGhpcyA9IF9zdXBlci5jYWxsKHRoaXMpOwogICAgICAgICAgaWYgKCFfdGhpcy5saXN0ZW5lcnMpIHsKICAgICAgICAgICAgRW1pdHRlci5jYWxsKF9hc3NlcnRUaGlzSW5pdGlhbGl6ZWQoX3RoaXMpKTsKICAgICAgICAgIH0KICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShfYXNzZXJ0VGhpc0luaXRpYWxpemVkKF90aGlzKSwgImFib3J0ZWQiLCB7CiAgICAgICAgICAgIHZhbHVlOiBmYWxzZSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZQogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoX2Fzc2VydFRoaXNJbml0aWFsaXplZChfdGhpcyksICJvbmFib3J0IiwgewogICAgICAgICAgICB2YWx1ZTogbnVsbCwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZQogICAgICAgICAgfSk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoX2Fzc2VydFRoaXNJbml0aWFsaXplZChfdGhpcyksICJyZWFzb24iLCB7CiAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUKICAgICAgICAgIH0pOwogICAgICAgICAgcmV0dXJuIF90aGlzOwogICAgICAgIH0KICAgICAgICBfY3JlYXRlQ2xhc3MoQWJvcnRTaWduYWwyLCBbewogICAgICAgICAga2V5OiAidG9TdHJpbmciLAogICAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIHRvU3RyaW5nKCkgewogICAgICAgICAgICByZXR1cm4gIltvYmplY3QgQWJvcnRTaWduYWxdIjsKICAgICAgICAgIH0KICAgICAgICB9LCB7CiAgICAgICAgICBrZXk6ICJkaXNwYXRjaEV2ZW50IiwKICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbiBkaXNwYXRjaEV2ZW50KGV2ZW50KSB7CiAgICAgICAgICAgIGlmIChldmVudC50eXBlID09PSAiYWJvcnQiKSB7CiAgICAgICAgICAgICAgdGhpcy5hYm9ydGVkID0gdHJ1ZTsKICAgICAgICAgICAgICBpZiAodHlwZW9mIHRoaXMub25hYm9ydCA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgdGhpcy5vbmFib3J0LmNhbGwodGhpcywgZXZlbnQpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBfZ2V0KF9nZXRQcm90b3R5cGVPZihBYm9ydFNpZ25hbDIucHJvdG90eXBlKSwgImRpc3BhdGNoRXZlbnQiLCB0aGlzKS5jYWxsKHRoaXMsIGV2ZW50KTsKICAgICAgICAgIH0KICAgICAgICB9XSk7CiAgICAgICAgcmV0dXJuIEFib3J0U2lnbmFsMjsKICAgICAgfShFbWl0dGVyKTsKICAgICAgdmFyIEFib3J0Q29udHJvbGxlciA9IC8qIEBfX1BVUkVfXyAqLyBmdW5jdGlvbigpIHsKICAgICAgICBmdW5jdGlvbiBBYm9ydENvbnRyb2xsZXIyKCkgewogICAgICAgICAgX2NsYXNzQ2FsbENoZWNrKHRoaXMsIEFib3J0Q29udHJvbGxlcjIpOwogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJzaWduYWwiLCB7CiAgICAgICAgICAgIHZhbHVlOiBuZXcgQWJvcnRTaWduYWwoKSwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZQogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICAgIF9jcmVhdGVDbGFzcyhBYm9ydENvbnRyb2xsZXIyLCBbewogICAgICAgICAga2V5OiAiYWJvcnQiLAogICAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIGFib3J0KHJlYXNvbikgewogICAgICAgICAgICB2YXIgZXZlbnQ7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgZXZlbnQgPSBuZXcgRXZlbnQoImFib3J0Iik7CiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICBpZiAodHlwZW9mIGRvY3VtZW50ICE9PSAidW5kZWZpbmVkIikgewogICAgICAgICAgICAgICAgaWYgKCFkb2N1bWVudC5jcmVhdGVFdmVudCkgewogICAgICAgICAgICAgICAgICBldmVudCA9IGRvY3VtZW50LmNyZWF0ZUV2ZW50T2JqZWN0KCk7CiAgICAgICAgICAgICAgICAgIGV2ZW50LnR5cGUgPSAiYWJvcnQiOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgZXZlbnQgPSBkb2N1bWVudC5jcmVhdGVFdmVudCgiRXZlbnQiKTsKICAgICAgICAgICAgICAgICAgZXZlbnQuaW5pdEV2ZW50KCJhYm9ydCIsIGZhbHNlLCBmYWxzZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGV2ZW50ID0gewogICAgICAgICAgICAgICAgICB0eXBlOiAiYWJvcnQiLAogICAgICAgICAgICAgICAgICBidWJibGVzOiBmYWxzZSwKICAgICAgICAgICAgICAgICAgY2FuY2VsYWJsZTogZmFsc2UKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIHZhciBzaWduYWxSZWFzb24gPSByZWFzb247CiAgICAgICAgICAgIGlmIChzaWduYWxSZWFzb24gPT09IHZvaWQgMCkgewogICAgICAgICAgICAgIGlmICh0eXBlb2YgZG9jdW1lbnQgPT09ICJ1bmRlZmluZWQiKSB7CiAgICAgICAgICAgICAgICBzaWduYWxSZWFzb24gPSBuZXcgRXJyb3IoIlRoaXMgb3BlcmF0aW9uIHdhcyBhYm9ydGVkIik7CiAgICAgICAgICAgICAgICBzaWduYWxSZWFzb24ubmFtZSA9ICJBYm9ydEVycm9yIjsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgc2lnbmFsUmVhc29uID0gbmV3IERPTUV4Y2VwdGlvbigic2lnbmFsIGlzIGFib3J0ZWQgd2l0aG91dCByZWFzb24iKTsKICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICAgICAgICBzaWduYWxSZWFzb24gPSBuZXcgRXJyb3IoIlRoaXMgb3BlcmF0aW9uIHdhcyBhYm9ydGVkIik7CiAgICAgICAgICAgICAgICAgIHNpZ25hbFJlYXNvbi5uYW1lID0gIkFib3J0RXJyb3IiOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnNpZ25hbC5yZWFzb24gPSBzaWduYWxSZWFzb247CiAgICAgICAgICAgIHRoaXMuc2lnbmFsLmRpc3BhdGNoRXZlbnQoZXZlbnQpOwogICAgICAgICAgfQogICAgICAgIH0sIHsKICAgICAgICAgIGtleTogInRvU3RyaW5nIiwKICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbiB0b1N0cmluZygpIHsKICAgICAgICAgICAgcmV0dXJuICJbb2JqZWN0IEFib3J0Q29udHJvbGxlcl0iOwogICAgICAgICAgfQogICAgICAgIH1dKTsKICAgICAgICByZXR1cm4gQWJvcnRDb250cm9sbGVyMjsKICAgICAgfSgpOwogICAgICBpZiAodHlwZW9mIFN5bWJvbCAhPT0gInVuZGVmaW5lZCIgJiYgU3ltYm9sLnRvU3RyaW5nVGFnKSB7CiAgICAgICAgQWJvcnRDb250cm9sbGVyLnByb3RvdHlwZVtTeW1ib2wudG9TdHJpbmdUYWddID0gIkFib3J0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bCkgewogICAgICAgICAgICAgIHNpZ25hbCA9IGluaXQyLnNpZ25hbDsKICAgICAgICAgICAgICBkZWxldGUgaW5pdDIuc2lnbmFsOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHZhciByZXF1ZXN0ID0gbmV3IE5hdGl2ZVJlcXVlc3QoaW5wdXQsIGluaXQyKTsKICAgICAgICAgICAgaWYgKHNpZ25hbCkgewogICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShyZXF1ZXN0LCAic2lnbmFsIiwgewogICAgICAgICAgICAgICAgd3JpdGFibGU6IGZhbHNlLAogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogZmFsc2UsCiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICB2YWx1ZTogc2lnbmFsCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIHJlcXVlc3Q7CiAgICAgICAgICB9OwogICAgICAgICAgUmVxdWVzdC5wcm90b3R5cGUgPSBOYXRpdmVSZXF1ZXN0LnByb3RvdHlwZTsKICAgICAgICB9CiAgICAgICAgdmFyIHJlYWxGZXRjaCA9IGZldGNoOwogICAgICAgIHZhciBhYm9ydGFibGVGZXRjaCA9IGZ1bmN0aW9uIGFib3J0YWJsZUZldGNoMihpbnB1dCwgaW5pdDIpIHsKICAgICAgICAgIHZhciBzaWduYWwgPSBSZXF1ZXN0ICYmIFJlcXVlc3QucHJvdG90eXBlLmlzUHJvdG90eXBlT2YoaW5wdXQpID8gaW5wdXQuc2lnbmFsIDogaW5pdDIgPyBpbml0Mi5zaWduYWwgOiB2b2lkIDA7CiAgICAgICAgICBpZiAoc2lnbmFsKSB7CiAgICAgICAgICAgIHZhciBhYm9ydEVycm9yOwogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgIGFib3J0RXJyb3IgPSBuZXcgRE9NRXhjZXB0aW9uKCJBYm9ydGVkIiwgIkFib3J0RXJyb3IiKTsKICAgICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgICAgYWJvcnRFcnJvciA9IG5ldyBFcnJvcigiQWJvcnRlZCIpOwogICAgICAgICAgICAgIGFib3J0RXJyb3IubmFtZSA9ICJBYm9ydEVycm9yIjsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoc2lnbmFsLmFib3J0ZWQpIHsKICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZWplY3QoYWJvcnRFcnJvcik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdmFyIGNhbmNlbGxhdGlvbiA9IG5ldyBQcm9taXNlKGZ1bmN0aW9uKF8sIHJlamVjdCkgewogICAgICAgICAgICAgIHNpZ25hbC5hZGRFdmVudExpc3RlbmVyKCJhYm9ydCIsIGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgcmV0dXJuIHJlamVjdChhYm9ydEVycm9yKTsKICAgICAgICAgICAgICB9LCB7CiAgICAgICAgICAgICAgICBvbmNlOiB0cnVlCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBpZiAoaW5pdDIgJiYgaW5pdDIuc2lnbmFsKSB7CiAgICAgICAgICAgICAgZGVsZXRlIGluaXQyLnNpZ25hbDsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yYWNlKFtjYW5jZWxsYXRpb24sIHJlYWxGZXRjaChpbnB1dCwgaW5pdDIpXSk7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gcmVhbEZldGNoKGlucHV0LCBpbml0Mik7CiAgICAgICAgfTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgZmV0Y2g6IGFib3J0YWJsZUZldGNoLAogICAgICAgICAgUmVxdWVzdAogICAgICAgIH07CiAgICAgIH0KICAgICAgZXhwb3J0czIuQWJvcnRDb250cm9sbGVyID0gQWJvcnRDb250cm9sbGVyOwogICAgICBleHBvcnRzMi5BYm9ydFN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B7CiAgICAgICAgICAgICAgdGhpcy5oYW5kbGVBYm9ydGVkKHNpZ25hbCk7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBoYW5kbGVBYm9ydGVkKHNpZ25hbCkgewogICAgICAgICAgdGhpcy5zaWduYWxzLmRlbGV0ZShzaWduYWwpOwogICAgICAgICAgaWYgKHRoaXMuc2lnbmFscy5zaXplID09PSAwKSB7CiAgICAgICAgICAgIHRoaXMuYWJvcnRDb250cm9sbGVyLmFib3J0KCk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGdldCBzaWduYWwoKSB7CiAgICAgICAgICByZXR1cm4gdGhpcy5hYm9ydENvbnRyb2xsZXIuc2lnbmFsOwogICAgICAgIH0KICAgICAgICBhYm9ydCgpIHsKICAgICAgICAgIHRoaXMuYWJvcnRDb250cm9sbGVyLmFib3J0KCk7CiAgICAgICAgfQogICAgICB9OwogICAgICBleHBvcnRzMi5kZWZhdWx0ID0gQWdncmVnYXRlQWJvcnRDb250cm9sbGVyOwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLnBucG0vYWJvcnRhYmxlLXByb21pc2UtY2FjaGVAMS41LjAvbm9kZV9tb2R1bGVzL2Fib3J0YWJsZS1wcm9taXNlLWNhY2hlL2VzbS9BZ2dyZWdhdGVTdGF0dXNSZXBvcnRlci5qcwogIHZhciByZXF1aXJlX0FnZ3JlZ2F0ZVN0YXR1c1JlcG9ydGVyID0gX19jb21tb25KUyh7CiAgICAibm9kZV9tb2R1bGVzLy5wbnBtL2Fib3J0YWJsZS1wcm9taXNlLWNhY2hlQDEuNS4wL25vZGVfbW9kdWxlcy9hYm9ydGFibGUtcHJvbWlzZS1jYWNoZS9lc20vQWdncmVnYXRlU3RhdHVzUmVwb3J0ZXIuanMiKGV4cG9ydHMyKSB7CiAgICAgIGluaXRfYnVmZmVyX3NoaW0oKTsKICAgICAgInVzZSBzdHJpY3QiOwogICAgICBPYmplY3QuZG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gpOwogICAgICAgICAgY29uc3Qgc3RhdHVzUmVwb3J0ZXIgPSBuZXcgQWdncmVnYXRlU3RhdHVzUmVwb3J0ZXJfMS5kZWZhdWx0KCk7CiAgICAgICAgICBzdGF0dXNSZXBvcnRlci5hZGRDYWxsYmFjayhzdGF0dXNDYWxsYmFjayk7CiAgICAgICAgICBjb25zdCBuZXdFbnRyeSA9IHsKICAgICAgICAgICAgYWJvcnRlciwKICAgICAgICAgICAgcHJvbWlzZTogdGhpcy5maWxsQ2FsbGJhY2soZGF0YSwgYWJvcnRlci5zaWduYWwsIChtZXNzYWdlKSA9PiB7CiAgICAgICAgICAgICAgc3RhdHVzUmVwb3J0ZXIuY2FsbGJhY2sobWVzc2FnZSk7CiAgICAgICAgICAgIH0pLAogICAgICAgICAgICBzZXR0bGVkOiBmYWxzZSwKICAgICAgICAgICAgc3RhdHVzUmVwb3J0ZXIsCiAgICAgICAgICAgIGdldCBhYm9ydGVkKCkgewogICAgICAgICAgICAgIHJldHVybiB0aGlzLmFib3J0ZXIuc2lnbmFsLmFib3J0ZWQ7CiAgICAgICAgICAgIH0KICAgICAgICAgIH07CiAgICAgICAgICBuZXdFbnRyeS5hYm9ydGVyLmFkZFNpZ25hbChzaWduYWwpOwogICAgICAgICAgbmV3RW50cnkuYWJvcnRlci5zaWduYWwuYWRkRXZlbnRMaXN0ZW5lcigiYWJvcnQiLCAoKSA9PiB7CiAgICAgICAgICAgIGlmICghbmV3RW50cnkuc2V0dGxlZCkgewogICAgICAgICAgICAgIHRoaXMuZXZpY3Qoa2V5LCBuZXdFbnRyeSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0pOwogICAgICAgICAgbmV3RW50cnkucHJvbWlzZS50aGVuKCgpID0+IHsKICAgICAgICAgICAgbmV3RW50cnkuc2V0dGxlZCA9IHRydWU7CiAgICAgICAgICB9LCAoKSA9PiB7CiAgICAgICAgICAgIG5ld0VudHJ5LnNldHRsZWQgPSB0cnVlOwogICAgICAgICAgICB0aGlzLmV2aWN0KGtleSwgbmV3RW50cnkpOwogICAgICAgICAgfSkuY2F0Y2goKGUpID0+IHsKICAgICAgICAgICAgY29uc29sZS5lcnJvcihlKTsKICAgICAgICAgICAgdGhyb3cgZTsKICAgICAgICAgIH0pOwogICAgICAgICAgdGhpcy5jYWNoZS5zZXQoa2V5LCBuZXdFbnRyeSk7CiAgICAgICAgfQogICAgICAgIHN0YXRpYyBjaGVja1NpbmdsZVByb21pc2UocHJvbWlzZSwgc2lnbmFsKSB7CiAgICAgICAgICBmdW5jdGlvbiBjaGVja0ZvclNpbmdsZUFib3J0KCkgewogICAgICAgICAgICBpZiAoc2lnbmFsICYmIHNpZ25hbC5hYm9ydGVkKSB7CiAgICAgICAgICAgICAgdGhyb3cgT2JqZWN0LmFzc2lnbihuZXcgRXJyb3IoImFib3J0ZWQiKSwgeyBjb2RlOiAiRVJSX0FCT1JURUQiIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gcHJvbWlzZS50aGVuKChyZXN1bHQpID0+IHsKICAgICAgICAgICAgY2hlY2tGb3JTaW5nbGVBYm9ydCgpOwogICAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgICAgfSwgKGVycm9yKSA9PiB7CiAgICAgICAgICAgIGNoZWNrRm9yU2luZ2xlQWJvcnQoKTsKICAgICAgICAgICAgdGhyb3cgZXJyb3I7CiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgaGFzKGtleSkgewogICAgICAgICAgcmV0dXJuIHRoaXMuY2FjaGUuaGFzKGtleSk7CiAgICAgICAgfQogICAgICAgIGdldChrZXksIGRhdGEsIHNpZ25hbCwgc3RhdHVzQ2FsbGJhY2spIHsKICAgICAgICAgIGlmICghc2lnbmFsICYmIGRhdGEgaW5zdGFuY2VvZiBhYm9ydGNvbnRyb2xsZXJfcG9ueWZpbGxfMS5BYm9ydFNpZ25hbCkgewogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCJ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sKTsKICAgICAgICB9CiAgICAgICAgZGVsZXRlKGtleSkgewogICAgICAgICAgY29uc3QgY2FjaGVkRW50cnkgPSB0aGlzLmNhY2hlLmdldChrZXkpOwogICAgICAgICAgaWYgKGNhY2hlZEVudHJ5KSB7CiAgICAgICAgICAgIGlmICghY2FjaGVkRW50cnkuc2V0dGxlZCkgewogICAgICAgICAgICAgIGNhY2hlZEVudHJ5LmFib3J0ZXIuYWJvcnQoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLmNhY2hlLmRlbGV0ZShrZXkpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjbGVhcigpIHsKICAgICAgICAgIGNvbnN0IGtleUl0ZXIgPSB0aGlzLmNhY2hlLmtleXMoKTsKICAgICAgICAgIGxldCBkZWxldGVDb3VudCA9IDA7CiAgICAgICAgICBmb3IgKGxldCByZXN1bHQgPSBrZXlJdGVyLm5leHQoKTsgIXJlc3VsdC5kb25lOyByZXN1bHQgPSBrZXlJdGVyLm5leHQoKSkgewogICAgICAgICAgICB0aGlzLmRlbGV0ZShyZXN1bHQudmFsdWUpOwogICAgICAgICAgICBkZWxldGVDb3VudCArPSAxOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIGRlbGV0ZUNvdW50OwogICAgICAgIH0KICAgICAgfTsKICAgICAgZXhwb3J0czIuZGVmYXVsdCA9IEFib3J0YWJsZVByb21pc2VDYWNoZTI7CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8ucG5wbS9hYm9ydGFibGUtcHJvbWlzZS1jYWNoZUAxLjUuMC9ub2RlX21vZHVsZXMvYWJvcnRhYmxlLXByb21pc2UtY2FjaGUvZXNtL2luZGV4LmpzCiAgdmFyIHJlcXVpcmVfZXNtID0gX19jb21tb25KUyh7CiAgICAibm9kZV9tb2R1bGVzLy5wbnBtL2Fib3J0YWJsZS1wcm9taXNlLWNhY2hlQDEuNS4wL25vZGVfbW9kdWxlcy9hYm9ydGFibGUtcHJ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TaXplID4gMCkpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcigiYG1heFNpemVgIG11c3QgYmUgYSBudW1iZXIgZ3JlYXRlciB0aGFuIDAiKTsKICAgICAgICAgIH0KICAgICAgICAgIHRoaXMubWF4U2l6ZSA9IG9wdGlvbnMubWF4U2l6ZTsKICAgICAgICAgIHRoaXMuY2FjaGUgPSBuZXcgTWFwKCk7CiAgICAgICAgICB0aGlzLm9sZENhY2hlID0gbmV3IE1hcCgpOwogICAgICAgICAgdGhpcy5fc2l6ZSA9IDA7CiAgICAgICAgfQogICAgICAgIF9zZXQoa2V5LCB2YWx1ZSkgewogICAgICAgICAgdGhpcy5jYWNoZS5zZXQoa2V5LCB2YWx1ZSk7CiAgICAgICAgICB0aGlzLl9zaXplKys7CiAgICAgICAgICBpZiAodGhpcy5fc2l6ZSA+PSB0aGlzLm1heFNpemUpIHsKICAgICAgICAgICAgdGhpcy5fc2l6ZSA9IDA7CiAgICAgICAgICAgIHRoaXMub2xkQ2FjaGUgPSB0aGlzLmNhY2hlOwogICAgICAgICAgICB0aGlzLmNhY2hlID0gbmV3IE1hcCgpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBnZXQoa2V5KSB7CiAgICAgICAgICBpZiAodGhpcy5jYWNoZS5oYXMoa2V5KSkgewogICAgICAgICAgICByZXR1cm4gdGhpcy5jYWNoZS5nZXQoa2V5KTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh0aGlzLm9sZENhY2hlLmhhcyhrZXkpKSB7CiAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gdGhpcy5vbGRDYWNoZS5nZXQoa2V5KTsKICAgICAgICAgICAgdGhpcy5vbGRDYWNoZS5kZWxldGUoa2V5KTsKICAgICAgICAgICAgdGhpcy5fc2V0KGtleSwgdmFsdWUpOwogICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHNldChrZXksIHZhbHVlKSB7CiAgICAgICAgICBpZiAodGhpcy5jYWNoZS5oYXMoa2V5KSkgewogICAgICAgICAgICB0aGlzLmNhY2hlLnNldChrZXksIHZhbHVlKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRoaXMuX3NldChrZXksIHZhbHVlKTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgIH0KICAgICAgICBoYXMoa2V5KSB7CiAgICAgICAgICByZXR1cm4gdGhpcy5jYWNoZS5oYXMoa2V5KSB8fCB0aGlzLm9sZENhY2hlLmhhcyhrZXkpOwogICAgICAgIH0KICAgICAgICBwZWVrKGtleSkgewogICAgICAgICAgaWYgKHRoaXMuY2FjaGUuaGFzKGtleSkpIHsKICAgICAgICAgICAgcmV0dXJuIHRoaXMuY2FjaGUuZ2V0KGtleSk7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAodGhpcy5vbGRDYWNoZS5oYXMoa2V5KSkgewogICAgICAgICAgICByZXR1cm4gdGhpcy5vbGRDYWNoZS5nZXQoa2V5KTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZGVsZXRlKGtleSkgewogICAgICAgICAgY29uc3QgZGVsZXRlZCA9IHRoaXMuY2FjaGUuZGVsZXRlKGtleSk7CiAgICAgICAgICBpZiAoZGVsZXRlZCkgewogICAgICAgICAgICB0aGlzLl9zaXplLS07CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gdGhpcy5vbGRDYWNoZS5kZWxldGUoa2V5KSB8fCBkZWxldGVkOwogICAgICAgIH0KICAgICAgICBjbGVhcigpIHsKICAgICAgICAgIHRoaXMuY2FjaGUuY2xlYXIoKTsKICAgICAgICAgIHRoaXMub2xkQ2FjaGUuY2xlYXIoKTsKICAgICAgICAgIHRoaXMuX3NpemUgPSAwOwogICAgICAgIH0KICAgICAgICAqa2V5cygpIHsKICAgICAgICAgIGZvciAoY29uc3QgW2tleV0gb2YgdGhpcykgewogICAgICAgICAgICB5aWVsZCBrZXk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgICp2YWx1ZXMoKSB7CiAgICAgICAgICBmb3IgKGNvbnN0IFssIHZhbHVlXSBvZiB0aGlzKSB7CiAgICAgICAgICAgIHlpZWxkIHZhbHVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICAqW1N5bWJvbC5pdGVyYXRvcl0oKSB7CiAgICAgICAgICBmb3IgKGNvbnN0IGl0ZW0gb2YgdGhpcy5jYWNoZSkgewogICAgICAgICAgICB5aWVsZCBpdGVtOwogICAgICAgICAgfQogICAgICAgICAgZm9yIChjb25zdCBpdGVtIG9mIHRoaXMub2xkQ2FjaGUpIHsKICAgICAgICAgICAgY29uc3QgW2tleV0gPSBpdGVtOwogICAgICAgICAgICBpZiAoIXRoaXMuY2FjaGUuaGFzKGtleSkpIHsKICAgICAgICAgICAgICB5aWVsZCBpdGVtOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGdldCBzaXplKCkgewogICAgICAgICAgbGV0IG9sZENhY2hlU2l6ZSA9IDA7CiAgICAgICAgICBmb3IgKGNvbnN0IGtleSBvZiB0aGlzLm9sZENhY2hlLmtleXMoKSkgewogICAgICAgICAgICBpZiAoIXRoaXMuY2FjaGUuaGFzKGtleSkpIHsKICAgICAgICAgICAgICBvbGRDYWNoZVNpemUrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIHRoaXMuX3NpemUgKyBvbGRDYWNoZVNpemU7CiAgICAgICAgfQogICAgICB9OwogICAgICBtb2R1bGUyLmV4cG9ydHMgPSBRdWlja0xSVTsKICAgIH0KICB9KTsKCiAgLy8gKGRpc2FibGVkKTpub2RlX21vZHVsZXMvLnBucG0vZ2VuZXJpYy1maWxlaGFuZGxlQDMuMS4xL25vZGVfbW9kdWxlcy9nZW5lcmljLWZpbGVoYW5kbGUvZXNtL2xvY2FsRmlsZQogIHZhciByZXF1aXJlX2xvY2FsRmlsZSA9IF9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VyY2UpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAodHlwZW9mIHNvdXJjZSAhPT0gIm9iamVjdCIpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcihzb3VyY2UgKyAibXVzdCBiZSBub24tb2JqZWN0Iik7CiAgICAgICAgICB9CiAgICAgICAgICBmb3IgKHZhciBwIGluIHNvdXJjZSkgewogICAgICAgICAgICBpZiAoX2hhcyhzb3VyY2UsIHApKSB7CiAgICAgICAgICAgICAgb2JqW3BdID0gc291cmNlW3BdOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiBvYmo7CiAgICAgIH07CiAgICAgIGV4cG9ydHMyLnNocmlua0J1ZiA9IGZ1bmN0aW9uKGJ1Ziwgc2l6ZSkgewogICAgICAgIGlmIChidWYubGVuZ3RoID09PSBzaXplKSB7CiAgICAgICAgICByZXR1cm4gYnVmOwogICAgICAgIH0KICAgICAgICBpZiAoYnVmLnN1YmFycmF5KSB7CiAgICAgICAgICByZXR1cm4gYnVmLnN1YmFycmF5KDAsIHNpemUpOwogICAgICAgIH0KICAgICAgICBidWYubGVuZ3RoID0gc2l6ZTsKICAgICAgICByZXR1cm4gYnVmOwogICAgICB9OwogICAgICB2YXIgZm5UeXBlZCA9IHsKICAgICAgICBhcnJheVNldDogZnVuY3Rpb24oZGVzdCwgc3JjLCBzcmNfb2ZmcywgbGVuLCBkZXN0X29mZnMpIHsKICAgICAgICAgIGlmIChzcmMuc3ViYXJyYXkgJiYgZGVzdC5zdWJhcnJheSkgewogICAgICAgICAgICBkZXN0LnNldChzcmMuc3ViYXJyYXkoc3JjX29mZnMsIHNyY19vZmZzICsgbGVuKSwgZGVzdF9vZmZzKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBsZW47IGkrKykgewogICAgICAgICAgICBkZXN0W2Rlc3Rfb2ZmcyArIGldID0gc3JjW3NyY19vZmZzICsgaV07CiAgICAgICAgICB9CiAgICAgICAgfSwKICAgICAgICBmbGF0dGVuQ2h1bmtzOiBmdW5jdGlvbihjaHVua3MpIHsKICAgICAgICAgIHZhciBpLCBsLCBsZW4sIHBvcywgY2h1bmssIHJlc3VsdDsKICAgICAgICAgIGxlbiA9IDA7CiAgICAgICAgICBmb3IgKGkgPSAwLCBsID0gY2h1bmtzLmxlbmd0aDsgaSA8IGw7IGkrKykgewogICAgICAgICAgICBsZW4gKz0gY2h1bmtzW2ldLmxlbmd0aDsKICAgICAgICAgIH0KICAgICAgICAgIHJlc3VsdCA9IG5ldyBVaW50OEFycmF5KGxlbik7CiAgICAgICAgICBwb3MgPSAwOwogICAgICAgICAgZm9yIChpID0gMCwgbCA9IGNodW5rcy5sZW5ndGg7IGkgPCBsOyBpKyspIHsKICAgICAgICAgICAgY2h1bmsgPSBjaHVua3NbaV07CiAgICAgICAgICAgIHJlc3VsdC5zZXQoY2h1bmssIHBvcyk7CiAgICAgICAgICAgIHBvcyArPSBjaHVuay5sZW5ndGg7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgIH0KICAgICAgfTsKICAgICAgdmFyIGZuVW50eXBlZCA9IHsKICAgICAgICBhcnJheVNldDogZnVuY3Rpb24oZGVzdCwgc3JjLCBzcmNfb2ZmcywgbGVuLCBkZXN0X29mZnMpIHsKICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgbGVuOyBpKyspIHsKICAgICAgICAgICAgZGVzdFtkZXN0X29mZnMgKyBpXSA9IHNyY1tzcmNfb2ZmcyArIGldOwogICAgICAgICAgfQogICAgICAgIH0sCiAgICAgICAgZmxhdHRlbkNodW5rczogZnVuY3Rpb24oY2h1bmtzKSB7CiAgICAgICAgICByZXR1cm4gW10uY29uY2F0LmFwcGx5KFtdLCBjaHVua3MpOwogICAgICAgIH0KICAgICAgfTsKICAgICAgZXhwb3J0czIuc2V0VHlwZWQgPSBmdW5jdGlvbihvbikgewogICAgICAgIGlmIChvbikgewogICAgICAgICAgZXhwb3J0czIuQnVmOCA9IFVpbnQ4QXJyYXk7CiAgICAgICAgICBleHBvcnRzMi5CdWYxNiA9IFVpbnQxNkFycmF5OwogICAgICAgICAgZXhwb3J0czIuQnVmMzIgPSBJbnQzMkFycmF5OwogICAgICAgICAgZXhwb3J0czIuYXNzaWduKGV4cG9ydHMyLCBmblR5cGVkKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZXhwb3J0czIuQnVmOCA9IEFycmF5OwogICAgICAgICAgZXhwb3J0czIuQnVmMTYgPSBBcnJheTsKICAgICAgICAgIGV4cG9ydHMyLkJ1ZjMyID0gQXJyYXk7CiAgICAgICAgICBleHBvcnRzMi5hc3NpZ24oZXhwb3J0czIsIGZuVW50eXBlZCk7CiAgICAgICAgfQogICAgICB9OwogICAgICBleHBvcnRzMi5zZXRUeXBlZChUWVBFRF9PSyk7CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8ucG5wbS9wYWtvQDEuMC4xMS9ub2RlX21vZHVsZXMvcGFrby9saWIvemxpYi90cmVlcy5qcwogIHZhciByZXF1aXJlX3RyZWVzID0gX19jb21tb25KUyh7CiAgICAibm9kZV9tb2R1bGVzLy5wbnBtL3Bha29AMS4wLjExL25vZGVfbW9kdWxlcy9wYWtvL2xpYi96bGliL3RyZWVzLmpzIihleHBvcnRzMikgewogICAgICBpbml0X2J1ZmZlcl9zaGltKCk7CiAgICAgICJ1c2Ugc3RyaWN0IjsKICAgICAgdmFyIHV0aWxzID0gcmVxdWlyZV9jb21tb24oKTsKICAgICAgdmFyIFpfRklYRUQgPSA0OwogICAgICB2YXIgWl9CSU5BUlkgPSAwOwogICAgICB2YXIgWl9URVhUID0gMTsKICAgICAgdmFyIFpfVU5LTk9XTiA9IDI7CiAgICAgIGZ1bmN0aW9uIHplcm8oYnVmKSB7CiAgICAgICAgdmFyIGxlb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Nob3J0KHMsIHMuYmlfYnVmKTsKICAgICAgICAgIHMuYmlfYnVmID0gdmFsdWUgPj4gQnVmX3NpemUgLSBzLmJpX3ZhbGlkOwogICAgICAgICAgcy5iaV92YWxpZCArPSBsZW5ndGggLSBCdWZfc2l6ZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgcy5iaV9idWYgfD0gdmFsdWUgPDwgcy5iaV92YWxpZCAmIDY1NTM1OwogICAgICAgICAgcy5iaV92YWxpZCArPSBsZW5ndGg7CiAgICAgICAgfQogICAgICB9CiAgICAgIGZ1bmN0aW9uIHNlbmRfY29kZShzLCBjLCB0cmVlKSB7CiAgICAgICAgc2VuZF9iaXRzKHMsIHRyZWVbYyAqIDJdLCB0cmVlW2MgKiAyICsgMV0pOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGJpX3JldmVyc2UoY29kZSwgbGVuKSB7CiAgICAgICAgdmFyIHJlcyA9IDA7CiAgICAgICAgZG8gewogICAgICAgICAgcmVzIHw9IGNvZGUgJiAxOwogICAgICAgICAgY29kZSA+Pj49IDE7CiAgICAgICAgICByZXMgPDw9IDE7CiAgICAgICAgfSB3aGlsZSAoLS1sZW4gPiAwKTsKICAgICAgICByZXR1cm4gcmVzID4+PiAxOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGJpX2ZsdXNoKHMpIHsKICAgICAgICBpZiAocy5iaV92YWxpZCA9PT0gMTYpIHsKICAgICAgICAgIHB1dF9zaG9ydChzLCBzLmJpX2J1Zik7CiAgICAgICAgICBzLmJpX2J1ZiA9IDA7CiAgICAgICAgICBzLmJpX3ZhbGlkID0gMDsKICAgICAgICB9IGVsc2UgaWYgKHMuYmlfdmFsaWQgPj0gOCkgewogICAgICAgICAgcy5wZW5kaW5nX2J1ZltzLnBlbmRpbmcrK10gPSBzLmJpX2J1ZiAmIDI1NTsKICAgICAgICAgIHMuYmlfYnVmID4+PSA4OwogICAgICAgICAgcy5iaV92YWxpZCAtPSA4OwogICAgICAgIH0KICAgICAgfQogICAgICBmdW5jdGlvbiBnZW5fYml0bGVuKHMsIGRlc2MpIHsKICAgICAgICB2YXIgdHJlZSA9IGRlc2MuZHluX3RyZWU7CiAgICAgICAgdmFyIG1heF9jb2RlID0gZGVzYy5tYXhfY29kZTsKICAgICAgICB2YXIgc3RyZWUgPSBkZXNjLnN0YXRfZGVzYy5zdGF0aWNfdHJlZTsKICAgICAgICB2YXIgaGFzX3N0cmVlID0gZGVzYy5zdGF0X2Rlc2MuaGFzX3N0cmVlOwogICAgICAgIHZhciBleHRyYSA9IGRlc2Muc3RhdF9kZXNjLmV4dHJhX2JpdHM7CiAgICAgICAgdmFyIGJhc2UgPSBkZXNjLnN0YXRfZGVzYy5leHRyYV9iYXNlOwogICAgICAgIHZhciBtYXhfbGVuZ3RoID0gZGVzYy5zdGF0X2Rlc2MubWF4X2xlbmd0aDsKICAgICAgICB2YXIgaDsKICAgICAgICB2YXIgbiwgbTsKICAgICAgICB2YXIgYml0czsKICAgICAgICB2YXIgeGJpdHM7CiAgICAgICAgdmFyIGY7CiAgICAgICAgdmFyIG92ZXJmbG93ID0gMDsKICAgICAgICBmb3IgKGJpdHMgPSAwOyBiaXRzIDw9IE1BWF9CSVRTOyBiaXRzKyspIHsKICAgICAgICAgIHMuYmxfY291bnRbYml0c10gPSAwOwogICAgICAgIH0KICAgICAgICB0cmVlW3MuaGVhcFtzLmhlYXBfbWF4XSAqIDIgKyAxXSA9IDA7CiAgICAgICAgZm9yIChoID0gcy5oZWFwX21heCArIDE7IGggPCBIRUFQX1NJWkU7IGgrKykgewogICAgICAgICAgbiA9IHMuaGVhcFtoXTsKICAgICAgICAgIGJpdHMgPSB0cmVlW3RyZWVbbiAqIDIgKyAxXSAqIDIgKyAxXSArIDE7CiAgICAgICAgICBpZiAoYml0cyA+IG1heF9sZW5ndGgpIHsKICAgICAgICAgICAgYml0cyA9IG1heF9sZW5ndGg7CiAgICAgICAgICAgIG92ZXJmbG93Kys7CiAgICAgICAgICB9CiAgICAgICAgICB0cmVlW24gKiAyICsgMV0gPSBiaXRzOwogICAgICAgICAgaWYgKG4gPiBtYXhfY29kZSkgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHMuYmxfY291bnRbYml0c10rKzsKICAgICAgICAgIHhiaXRzID0gMDsKICAgICAgICAgIGlmIChuID49IGJhc2UpIHsKICAgICAgICAgICAgeGJpdHMgPSBleHRyYVtuIC0gYmFzZV07CiAgICAgICAgICB9CiAgICAgICAgICBmID0gdHJlZVtuICogMl07CiAgICAgICAgICBzLm9wdF9sZW4gKz0gZiAqIChiaXRzICsgeGJpdHMpOwogICAgICAgICAgaWYgKGhhc19zdHJlZSkgewogICAgICAgICAgICBzLnN0YXRpY19sZW4gKz0gZiAqIChzdHJlZVtuICogMiArIDFdICsgeGJpdHMpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAob3ZlcmZsb3cgPT09IDApIHsKICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgZG8gewogICAgICAgICAgYml0cyA9IG1heF9sZW5ndGggLSAxOwogICAgICAgICAgd2hpbGUgKHMuYmxfY291bnRbYml0c10gPT09IDApIHsKICAgICAgICAgICAgYml0cy0tOwogICAgICAgICAgfQogICAgICAgICAgcy5ibF9jb3VudFtiaXRzXS0tOwogICAgICAgICAgcy5ibF9jb3VudFtiaXRzICsgMV0gKz0gMjsKICAgICAgICAgIHMuYmxfY291bnRbbWF4X2xlbmd0aF0tLTsKICAgICAgICAgIG92ZXJmbG93IC09IDI7CiAgICAgICAgfSB3aGlsZSAob3ZlcmZsb3cgPiAwKTsKICAgICAgICBmb3IgKGJpdHMgPSBtYXhfbGVuZ3RoOyBiaXRzICE9PSAwOyBiaXRzLS0pIHsKICAgICAgICAgIG4gPSBzLmJsX2NvdW50W2JpdHNdOwogICAgICAgICAgd2hpbGUgKG4gIT09IDApIHsKICAgICAgICAgICAgbSA9IHMuaGVhcFstLWhdOwogICAgICAgICAgICBpZiAobSA+IG1heF9jb2RlKSB7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHRyZWVbbSAqIDIgKyAxXSAhPT0gYml0cykgewogICAgICAgICAgICAgIHMub3B0X2xlbiArPSAoYml0cyAtIHRyZWVbbSAqIDIgKyAxXSkgKiB0cmVlW20gKiAyXTsKICAgICAgICAgICAgICB0cmVlW20gKiAyICsgMV0gPSBiaXRzOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG4tLTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZ2VuX2NvZGVzKHRyZWUsIG1heF9jb2RlLCBibF9jb3VudCkgewogICAgICAgIHZhciBuZXh0X2NvZGUgPSBuZXcgQXJyYXkoTUFYX0JJVFMgKyAxKTsKICAgICAgICB2YXIgY29kZSA9IDA7CiAgICAgICAgdmFyIGJpdHM7CiAgICAgICAgdmFyIG47CiAgICAgICAgZm9yIChiaXRzID0gMTsgYml0cyA8PSBNQVhfQklUUzsgYml0cysrKSB7CiAgICAgICAgICBuZXh0X2NvZGVbYml0c10gPSBjb2RlID0gY29kZSArIGJsX2NvdW50W2JpdHMgLSAxXSA8PCAxOwogICAgICAgIH0KICAgICAgICBmb3IgKG4gPSAwOyBuIDw9IG1heF9jb2RlOyBuKyspIHsKICAgICAgICAgIHZhciBsZW4gPSB0cmVlW24gKiAyICsgMV07CiAgICAgICAgICBpZiAobGVuID09PSAwKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgdHJlZVtuICogMl0gPSBiaV9yZXZlcnNlKG5leHRfY29kZVtsZW5dKyssIGxlbik7CiAgICAgICAgfQogICAgICB9CiAgICAgIGZ1bmN0aW9uIHRyX3N0YXRpY19pbml0KCkgewogICAgICAgIHZhciBuOwogICAgICAgIHZhciBiaXRzOwogICAgICAgIHZhciBsZW5ndGg7CiAgICAgICAgdmFyIGNvZGU7CiAgICAgICAg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gYmxfY291bnRbYml0c10gPSAwOwogICAgICAgIH0KICAgICAgICBuID0gMDsKICAgICAgICB3aGlsZSAobiA8PSAxNDMpIHsKICAgICAgICAgIHN0YXRpY19sdHJlZVtuICogMiArIDFdID0gODsKICAgICAgICAgIG4rKzsKICAgICAgICAgIGJsX2NvdW50WzhdKys7CiAgICAgICAgfQogICAgICAgIHdoaWxlIChuIDw9IDI1NSkgewogICAgICAgICAgc3RhdGljX2x0cmVlW24gKiAyICsgMV0gPSA5OwogICAgICAgICAgbisrOwogICAgICAgICAgYmxfY291bnRbOV0rKzsKICAgICAgICB9CiAgICAgICAgd2hpbGUgKG4gPD0gMjc5KSB7CiAgICAgICAgICBzdGF0aWNfbHRyZWVbbiAqIDIgKyAxXSA9IDc7CiAgICAgICAgICBuKys7CiAgICAgICAgICBibF9jb3VudFs3XSsrOwogICAgICAgIH0KICAgICAgICB3aGlsZSAobiA8PSAyODcpIHsKICAgICAgICAgIHN0YXRpY19sdHJlZVtuICogMiArIDFdID0gODsKICAgICAgICAgIG4rKzsKICAgICAgICAgIGJsX2NvdW50WzhdKys7CiAgICAgICAgfQogICAgICAgIGdlbl9jb2RlcyhzdGF0aWNfbHRyZWUsIExfQ09ERVMgKyAxLCBibF9jb3VudCk7CiAgICAgICAgZm9yIChuID0gMDsgbiA8IERfQ09ERVM7IG4rKykgewogICAgICAgICAgc3RhdGljX2R0cmVlW24gKiAyICsgMV0gPSA1OwogICAgICAgICAgc3RhdGljX2R0cmVlW24gKiAyXSA9IGJpX3JldmVyc2UobiwgNSk7CiAgICAgICAgfQogICAgICAgIHN0YXRpY19sX2Rlc2MgPSBuZXcgU3RhdGljVHJlZURlc2Moc3RhdGljX2x0cmVlLCBleHRyYV9sYml0cywgTElURVJBTFMgKyAxLCBMX0NPREVTLCBNQVhfQklUUyk7CiAgICAgICAgc3RhdGljX2RfZGVzYyA9IG5ldyBTdGF0aWNUcmVlRGVzYyhzdGF0aWNfZHRyZWUsIGV4dHJhX2RiaXRzLCAwLCBEX0NPREVTLCBNQVhfQklUUyk7CiAgICAgICAgc3RhdGljX2JsX2Rlc2MgPSBuZXcgU3RhdGljVHJlZURlc2MobmV3IEFycmF5KDApLCBleHRyYV9ibGJpdHMsIDAsIEJMX0NPREVTLCBNQVhfQkxfQklUUyk7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gaW5pdF9ibG9jayhzKSB7CiAgICAgICAgdmFyIG47CiAgICAgICAgZm9yIChuID0gMDsgbiA8IExfQ09ERVM7IG4rKykgewogICAgICAgICAgcy5keW5fbHRyZWVbbiAqIDJdID0gMDsKICAgICAgICB9CiAgICAgICAgZm9yIChuID0gMDsgbiA8IERfQ09ERVM7IG4rKykgewogICAgICAgICAgcy5keW5fZHRyZWVbbiAqIDJdID0gMDsKICAgICAgICB9CiAgICAgICAgZm9yIChuID0gMDsgbiA8IEJMX0NPREVTOyBuKyspIHsKICAgICAgICAgIHMuYmxfdHJlZVtuICogMl0gPSAwOwogICAgICAgIH0KICAgICAgICBzLmR5bl9sdHJlZVtFTkRfQkxPQ0sgKiAyXSA9IDE7CiAgICAgICAgcy5vcHRfbGVuID0gcy5zdGF0aWNfbGVuID0gMDsKICAgICAgICBzLmxhc3RfbGl0ID0gcy5tYXRjaGVzID0gMDsKICAgICAgfQogICAgICBmdW5jdGlvbiBiaV93aW5kdXAocykgewogICAgICAgIGlmIChzLmJpX3ZhbGlkID4gOCkgewogICAgICAgICAgcHV0X3Nob3J0KHMsIHMuYmlfYnVmKTsKICAgICAgICB9IGVsc2UgaWYgKHMuYmlfdmFsaWQgPiAwKSB7CiAgICAgICAgICBzLnBlbmRpbmdfYnVmW3MucGVuZGluZysrXSA9IHMuYmlfYnVmOwogICAgICAgIH0KICAgICAgICBzLmJpX2J1ZiA9IDA7CiAgICAgICAgcy5iaV92YWxpZCA9IDA7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gY29weV9ibG9jayhzLCBidWYsIGxlbiwgaGVhZGVyKSB7CiAgICAgICAgYmlfd2luZHVwKHMpOwogICAgICAgIGlmIChoZWFkZXIpIHsKICAgICAgICAgIHB1dF9zaG9ydChzLCBsZW4pOwogICAgICAgICAgcHV0X3Nob3J0KHMsIH5sZW4pOwogICAgICAgIH0KICAgICAgICB1dGlscy5hcnJheVNldChzLnBlbmRpbmdfYnVmLCBzLndpbmRvdywgYnVmLCBsZW4sIHMucGVuZGluZyk7CiAgICAgICAgcy5wZW5kaW5nICs9IGxlbjsKICAgICAgfQogICAgICBmdW5jdGlvbiBzbWFsbGVyKHRyZWUsIG4sIG0sIGRlcHRoKSB7CiAgICAgICAgdmFyIF9uMiA9IG4gKiAyOwogICAgICAgIHZhciBfbTIgPSBtICogMjsKICAgICAgICByZXR1cm4gdHJlZVtfbjJdIDwgdHJlZVtfbTJdIHx8IHRyZWVbX24yXSA9PT0gdHJlZVtfbTJdICYmIGRlcHRoW25dIDw9IGRlcHRoW21dOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIHBxZG93bmhlYXAocywgdHJlZSwgaykgewogICAgICAgIHZhciB2ID0gcy5oZWFwW2tdOwogICAgICAgIHZhciBqID0gayA8PCAxOwogICAgICAgIHdoaWxlIChqIDw9IHMuaGVhcF9sZW4pIHsKICAgICAgICAgIGlmIChqIDwgcy5oZWFwX2xlbiAmJiBzbWFsbGVyKHRyZWUsIHMuaGVhcFtqICsgMV0sIHMuaGVhcFtqXSwgcy5kZXB0aCkpIHsKICAgICAgICAgICAgaisrOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHNtYWxsZXIodHJlZSwgdiwgcy5oZWFwW2pdLCBzLmRlcHRoKSkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIHMuaGVhcFtrXSA9IHMuaGVhcFtqXTsKICAgICAgICAgIGsgPSBqOwogICAgICAgICAgaiA8PD0gMTsKICAgICAgICB9CiAgICAgICAgcy5oZWFwW2tdID0gdjsKICAgICAgfQogICAgICBmdW5jdGlvbiBjb21wcmVzc19ibG9jayhzLCBsdHJlZSwgZHRyZWUpIHsKICAgICAgICB2YXIgZGlzdDsKICAgICAgICB2YXIgbGM7CiAgICAgICAgdmFyIGx4ID0gMDsKICAgICAgICB2YXIgY29kZTsKICAgICAgICB2YXIgZXh0cmE7CiAgICAgICAgaWYgKHMubGFzdF9saXQgIT09IDApIHsKICAgICAgICAgIGRvIHsKICAgICAgICAgICAgZGlzdCA9IHMucGVuZGluZ19idWZbcy5kX2J1ZiArIGx4ICogMl0gPDwgOCB8IHMucGVuZGluZ19idWZbcy5kX2J1ZiArIGx4ICogMiArIDFdOwogICAgICAgICAgICBsYyA9IHMucGVuZGluZ19idWZbcy5sX2J1ZiArIGx4XTsKICAgICAgICAgICAgbHgrKzsKICAgICAgICAgICAgaWYgKGRpc3QgPT09IDApIHsKICAgICAgICAgICAgICBzZW5kX2NvZGUocywgbGMsIGx0cmVlKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjb2RlID0gX2xlbmd0aF9jb2RlW2xjXTsKICAgICAgICAgICAgICBzZW5kX2NvZGUocywgY29kZSArIExJVEVSQUxTICsgMSwgbHRyZWUpOwogICAgICAgICAgICAgIGV4dHJhID0gZXh0cmFfbGJpdHNbY29kZV07CiAgICAgICAgICAgICAgaWYgKGV4dHJhICE9PSAwKSB7CiAgICAgICAgICAgICAgICBsYyAtPSBiYXNlX2xlbmd0aFtjb2RlXTsKICAgICAgICAgICAgICAgIHNlbmRfYml0cyhzLCBsYywgZXh0cmEpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBkaXN0LS07CiAgICAgICAgICAgICAgY29kZSA9IGRfY29kZShkaXN0KTsKICAgICAgICAgICAgICBzZW5kX2NvZGUocywgY29kZSwgZHRyZWUpOwogICAgICAgICAgICAgIGV4dHJhID0gZXh0cmFfZGJpdHNbY29kZV07CiAgICAgICAgICAgICAgaWYgKGV4dHJhICE9PSAwKSB7CiAgICAgICAgICAgICAgICBkaXN0IC09IGJhc2VfZGlzdFtjb2RlXTsKICAgICAgICAgICAgICAgIHNlbmRfYml0cyhzLCBkaXN0LCBleHRyYSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9IHdoaWxlIChseCA8IHMubGFzdF9saXQpOwogICAgICAgIH0KICAgICAgICBzZW5kX2NvZGUocywgRU5EX0JMT0NLLCBsdHJlZSk7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gYnVpbGRfdHJlZShzLCBkZXNjKSB7CiAgICAgICAgdmFyIHRyZWUgPSBkZXNjLmR5bl90cmVlOwogICAgICAgIHZhciBzdHJlZSA9IGRlc2Muc3RhdF9kZXNjLnN0YXRpY190cmVlOwogICAgICAgIHZhciBoYXNfc3RyZWUgPSBkZXNjLnN0YXRfZGVzYy5oYXNfc3RyZWU7CiAgICAgICAgdmFyIGVsZW1zID0gZGVzYy5zdGF0X2Rlc2MuZWxlbXM7CiAgICAgICAgdmFyIG4sIG07CiAgICAgICAgdmFyIG1heF9jb2RlID0gLTE7CiAgICAgICAgdmFyIG5vZGU7CiAgICAgICAgcy5oZWFwX2xlbiA9IDA7CiAgICAgICAgcy5oZWFwX21heCA9IEhFQVBfU0laRTsKICAgICAgICBmb3IgKG4gPSAwOyBuIDwgZWxlbXM7IG4rKykgewogICAgICAgICAgaWYgKHRyZWVbbiAqIDJdICE9PSAwKSB7CiAgICAgICAgICAgIHMuaGVhcFsrK3MuaGVhcF9sZW5dID0gbWF4X2NvZGUgPSBuOwogICAgICAgICAgICBzLmRlcHRoW25dID0gMDsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRyZWVbbiAqIDIgKyAxXSA9IDA7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHdoaWxlIChzLmhlYXBfbGVuIDwgMikgewogICAgICAgICAgbm9kZSA9IHMuaGVhcFsrK3MuaGVhcF9sZW5dID0gbWF4X2NvZGUgPCAyID8gKyttYXhfY29kZSA6IDA7CiAgICAgICAgICB0cmVlW25vZGUgKiAyXSA9IDE7CiAgICAgICAgICBzLmRlcHRoW25vZGVdID0gMDsKICAgICAgICAgIHMub3B0X2xlbi0tOwogICAgICAgICAgaWYgKGhhc19zdHJlZSkgewogICAgICAgICAgICBzLnN0YXRpY19sZW4gLT0gc3RyZWVbbm9kZSAqIDIgKyAxXTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZGVzYy5tYXhfY29kZSA9IG1heF9jb2RlOwogICAgICAgIGZvciAobiA9IHMuaGVhcF9sZW4gPj4gMTsgbiA+PSAxOyBuLS0pIHsKICAgICAgICAgIHBxZG93bmhlYXAocywgdHJlZSwgbik7CiAgICAgICAgfQogICAgICAgIG5vZGUgPSBlbGVtczsKICAgICAgICBkbyB7CiAgICAgICAgICBuID0gcy5oZWFwWzFdOwogICAgICAgICAgcy5oZWFwWzFdID0gcy5oZWFwW3MuaGVhcF9sZW4tLV07CiAgICAgICAgICBwcWRvd25oZWFwKHMsIHRyZWUsIDEpOwogICAgICAgICAgbSA9IHMuaGVhcFsxXTsKICAgICAgICAgIHMuaGVhcFstLXMuaGVhcF9tYXhdID0gbjsKICAgICAgICAgIHMuaGVhcFstLXMuaGVhcF9tYXhdID0gbTsKICAgICAgICAgIHRyZWVbbm9kZSAqIDJdID0gdHJlZVtuICogMl0gKyB0cmVlW20gKiAyXTsKICAgICAgICAgIHMuZGVwdGhbbm9kZV0gPSAocy5kZXB0aFtuXSA+PSBzLmRlcHRoW21dID8gcy5kZXB0aFtuXSA6IHMuZGVwdGhbbV0pICsgMTsKICAgICAgICAgIHRyZWVbbiAqIDIgKyAxXSA9IHRyZWVbbSAqIDIgKyAxXSA9IG5vZGU7CiAgICAgICAgICBzLmhlYXBbMV0gPSBub2RlKys7CiAgICAgICAgICBwcWRvd25oZWFwKHMsIHRyZWUsIDEpOwogICAgICAgIH0gd2hpbGUgKHMuaGVhcF9sZW4gPj0gMik7CiAgICAgICAgcy5oZWFwWy0tcy5oZWFwX21heF0gPSBzLmhlYXBbMV07CiAgICAgICAgZ2VuX2JpdGxlbihzLCBkZXNjKTsKICAgICAgICBnZW5fY29kZXModHJlZSwgbWF4X2NvZGUsIHMuYmxfY291bnQpOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIHNjYW5fdHJlZShzLCB0cmVlLCBtYXhfY29kZSkgewogICAgICAgIHZhciBuOwogICAgICAgIHZhciBwcmV2bGVuID0gLTE7CiAgICAgICAgdmFyIGN1cmxlbjsKICAgICAgICB2YXIgbmV4dGxlbiA9IHRyZWVbMCAqIDIgKyAxXTsKICAgICAgICB2YXIgY291bnQgPSAwOwogICAgICAgIHZhciBtYXhfY291bnQgPSA3OwogICAgICAgIHZhciBtaW5fY291bnQgPSA0OwogICAgICAgIGlmIChuZXh0bGVuID09PSAwKSB7CiAgICAgICAgICBtYXhfY291bnQgPSAxMzg7CiAgICAgICAgICBtaW5fY291bnQgPSAzOwogICAgICAgIH0KICAgICAgICB0cmVlWyhtYXhfY29kZSArIDEpICogMiArIDFdID0gNjU1MzU7CiAgICAgICAgZm9yIChuID0gMDsgbiA8PSBtYXhfY29kZTsgbisrKSB7CiAgICAgICAgICBjdXJsZW4gPSBuZXh0bGVuOwogICAgICAgICAgbmV4dGxlbiA9IHRyZWVbKG4gKyAxKSAqIDIgKyAxXTsKICAgICAgICAgIGlmICgrK2NvdW50IDwgbWF4X2NvdW50ICYmIGN1cmxlbiA9PT0gbmV4dGxlbikgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0gZWxzZSBpZiAoY291bnQgPCBtaW5fY291bnQpIHsKICAgICAgICAgICAgcy5ibF90cmVlW2N1cmxlbiAqIDJdICs9IGNvdW50OwogICAgICAgICAgfSBlbHNlIGlmIChjdXJsZW4gIT09IDApIHsKICAgICAgICAgICAgaWYgKGN1cmxlbiAhPT0gcHJldmxlbikgewogICAgICAgICAgICAgIHMuYmxfdHJlZVtjdXJsZW4gKiAyXSsrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHMuYmxfdHJlZVtSRVBfM182ICogMl0rKzsKICAgICAgICAgIH0gZWxzZSBpZiAoY291bnQgPD0gMTApIHsKICAgICAgICAgICAgcy5ibF90cmVlW1JFUFpfM18xMCAqIDJdKys7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzLmJsX3RyZWVbUkVQWl8xMV8xMzggKiAyXSsrOwogICAgICAgICAgfQogICAgICAgICAgY291bnQgPSAwOwogICAgICAgICAgcHJldmxlbiA9IGN1cmxlbjsKICAgICAgICAgIGlmIChuZXh0bGVuID09PSAwKSB7CiAgICAgICAgICAgIG1heF9jb3VudCA9IDEzODsKICAgICAgICAgICAgbWluX2NvdW50ID0gMzsKICAgICAgICAgIH0gZWxzZSBpZiAoY3VybGVuID09PSBuZXh0bGVuKSB7CiAgICAgICAgICAgIG1heF9jb3VudCA9IDY7CiAgICAgICAgICAgIG1pbl9jb3VudCA9IDM7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBtYXhfY291bnQgPSA3OwogICAgICAgICAgICBtaW5fY291bnQgPSA0OwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBmdW5jdGlvbiBzZW5kX3RyZWUocywgdHJlZSwgbWF4X2NvZGUpIHsKICAgICAgICB2YXIgbjsKICAgICAgICB2YXIgcHJldmxlbiA9IC0xOwogICAgICAgIHZhciBjdXJsZW47CiAgICAgICAgdmFyIG5leHRsZW4gPSB0cmVlWzAgKiAyICsgMV07CiAgICAgICAgdmFyIGNvdW50ID0gMDsKICAgICAgICB2YXIgbWF4X2NvdW50ID0gNzsKICAgICAgICB2YXIgbWluX2NvdW50ID0gNDsKICAgICAgICBpZiAobmV4dGxlbiA9PT0gMCkgewogICAgICAgICAgbWF4X2NvdW50ID0gMTM4OwogICAgICAgICAgbWluX2NvdW50ID0gMzsKICAgICAgICB9CiAgICAgICAgZm9yIChuID0gMDsgbiA8PSBtYXhfY29kZTsgbisrKSB7CiAgICAgICAgICBjdXJsZW4gPSBuZXh0bGVuOwogICAgICAgICAgbmV4dGxlbiA9IHRyZWVbKG4gKyAxKSAqIDIgKyAxXTsKICAgICAgICAgIGlmICgrK2NvdW50IDwgbWF4X2NvdW50ICYmIGN1cmxlbiA9PT0gbmV4dGxlbikgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0gZWxzZSBpZiAoY291bnQgPCBtaW5fY291bnQpIHsKICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgIHNlbmRfY29kZShzLCBjdXJsZW4sIHMuYmxfdHJlZSk7CiAgICAgICAgICAgIH0gd2hpbGUgKC0tY291bnQgIT09IDApOwogICAgICAgICAgfSBlbHNlIGlmIChjdXJsZW4gIT09IDApIHsKICAgICAgICAgICAgaWYgKGN1cmxlbiAhPT0gcHJldmxlbikgewogICAgICAgICAgICAgIHNlbmRfY29kZShzLCBjdXJsZW4sIHMuYmxfdHJlZSk7CiAgICAgICAgICAgICAgY291bnQtLTsKICAgICAgICAgICAgfQogICAgICAgICAgICBzZW5kX2NvZGUocywgUkVQXzNfNiwgcy5ibF90cmVlKTsKICAgICAgICAgICAgc2VuZF9iaXRzKHMsIGNvdW50IC0gMywgMik7CiAgICAgICAgICB9IGVsc2UgaWYgKGNvdW50IDw9IDEwKSB7CiAgICAgICAgICAgIHNlbmRfY29kZShzLCBSRVBaXzNfMTAsIHMuYmxfdHJlZSk7CiAgICAgICAgICAgIHNlbmRfYml0cyhzLCBjb3VudCAtIDMsIDMpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc2VuZF9jb2RlKHMsIFJFUFpfMTFfMTM4LCBzLmJsX3RyZWUpOwogICAgICAgICAgICBzZW5kX2JpdHMocywgY291bnQgLSAxMSwgNyk7CiAgICAgICAgICB9CiAgICAgICAgICBjb3VudCA9IDA7CiAgICAgICAgICBwcmV2bGVuID0gY3VybGVuOwogICAgICAgICAgaWYgKG5leHRsZW4gPT09IDApIHsKICAgICAgICAgICAgbWF4X2NvdW50ID0gMTM4OwogICAgICAgICAgICBtaW5fY291bnQgPSAzOwogICAgICAgICAgfSBlbHNlIGlmIChjdXJsZW4gPT09IG5leHRsZW4pIHsKICAgICAgICAgICAgbWF4X2NvdW50ID0gNjsKICAgICAgICAgICAgbWluX2NvdW50ID0gMzsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIG1heF9jb3VudCA9IDc7CiAgICAgICAgICAgIG1pbl9jb3VudCA9IDQ7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIGZ1bmN0aW9uIGJ1aWxkX2JsX3RyZWUocykgewogICAgICAgIHZhciBtYXhfYmxpbmRleDsKICAgICAgICBzY2FuX3RyZWUocywgcy5keW5fbHRyZWUsIHMubF9kZXNjLm1heF9jb2RlKTsKICAgICAgICBzY2FuX3RyZWUocywgcy5keW5fZHRyZWUsIHMuZF9kZXNjLm1heF9jb2RlKTsKICAgICAgICBidWlsZF90cmVlKHMsIHMuYmxfZGVzYyk7CiAgICAgICAgZm9yIChtYXhfYmxpbmRleCA9IEJMX0NPREVTIC0gMTsgbWF4X2JsaW5kZXggPj0gMzsgbWF4X2JsaW5kZXgtLSkgewogICAgICAgICAgaWYgKHMuYmxfdHJlZVtibF9vcmRlclttYXhfYmxpbmRleF0gKiAyICsgMV0gIT09IDApIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHMub3B0X2xlbiArPSAzICogKG1heF9ibGluZGV4ICsgMSkgKyA1ICsgNSArIDQ7CiAgICAgICAgcmV0dXJuIG1heF9ibGluZGV4OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIHNlbmRfYWxsX3RyZWVzKHMsIGxjb2RlcywgZGNvZGVzLCBibGNvZGVzKSB7CiAgICAgICAgdmFyIHJhbms7CiAgICAgICAgc2VuZF9iaXRzKHMsIGxjb2RlcyAtIDI1NywgNSk7CiAgICAgICAgc2VuZF9iaXRzKHMsIGRjb2RlcyAtIDEsIDUpOwogICAgICAgIHNlbmRfYml0cyhzLCBibGNvZGVzIC0gNCwgNCk7CiAgICAgICAgZm9yIChyYW5rID0gMDsgcmFuayA8IGJsY29kZXM7IHJhbmsrKykgewogICAgICAgICAgc2VuZF9iaXRzKHMsIHMuYmxfdHJlZVtibF9vcmRlcltyYW5rXSAqIDIgKyAxXSwgMyk7CiAgICAgICAgfQogICAgICAgIHNlbmRfdHJlZShzLCBzLmR5bl9sdHJlZSwgbGNvZGVzIC0gMSk7CiAgICAgICAgc2VuZF90cmVlKHMsIHMuZHluX2R0cmVlLCBkY29kZXMgLSAxKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBkZXRlY3RfZGF0YV90eXBlKHMpIHsKICAgICAgICB2YXIgYmxhY2tfbWFzayA9IDQwOTM2MjQ0NDc7CiAgICAgICAgdmFyIG47CiAgICAgICAgZm9yIChuID0gMDsgbiA8PSAzMTsgbisrLCBibGFja19tYXNrID4+Pj0gMSkgewogICAgICAgICAgaWYgKGJsYWNrX21hc2sgJiAxICYmIHMuZHluX2x0cmVlW24gKiAyXSAhPT0gMCkgewogICAgICAgICAgICByZXR1cm4gWl9CSU5BUlk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChzLmR5bl9sdHJlZVs5ICogMl0gIT09IDAgfHwgcy5keW5fbHRyZWVbMTAgKiAyXSAhPT0gMCB8fCBzLmR5bl9sdHJlZVsxMyAqIDJdICE9PSAwKSB7CiAgICAgICAgICByZXR1cm4gWl9URVhUOwogICAgICAgIH0KICAgICAgICBmb3IgKG4gPSAzMjsgbiA8IExJVEVSQUxTOyBuKyspIHsKICAgICAgICAgIGlmIChzLmR5bl9sdHJlZVtuICogMl0gIT09IDApIHsKICAgICAgICAgICAgcmV0dXJuIFpfVEVYVDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIFpfQklOQVJZOwogICAgICB9CiAgICAgIHZhciBzdGF0aWNfaW5pdF9kb25lID0gZmFsc2U7CiAgICAgIGZ1bmN0aW9uIF90cl9pbml0KHMpIHsKICAgICAgICBpZiAoIXN0YXRpY19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ICAgIGlmIChzLnN0cm0uZGF0YV90eXBlID09PSBaX1VOS05PV04pIHsKICAgICAgICAgICAgcy5zdHJtLmRhdGFfdHlwZSA9IGRldGVjdF9kYXRhX3R5cGUocyk7CiAgICAgICAgICB9CiAgICAgICAgICBidWlsZF90cmVlKHMsIHMubF9kZXNjKTsKICAgICAgICAgIGJ1aWxkX3RyZWUocywgcy5kX2Rlc2MpOwogICAgICAgICAgbWF4X2JsaW5kZXggPSBidWlsZF9ibF90cmVlKHMpOwogICAgICAgICAgb3B0X2xlbmIgPSBzLm9wdF9sZW4gKyAzICsgNyA+Pj4gMzsKICAgICAgICAgIHN0YXRpY19sZW5iID0gcy5zdGF0aWNfbGVuICsgMyArIDcgPj4+IDM7CiAgICAgICAgICBpZiAoc3RhdGljX2xlbmIgPD0gb3B0X2xlbmIpIHsKICAgICAgICAgICAgb3B0X2xlbmIgPSBzdGF0aWNfbGVuYjsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgb3B0X2xlbmIgPSBzdGF0aWNfbGVuYiA9IHN0b3JlZF9sZW4gKyA1OwogICAgICAgIH0KICAgICAgICBpZiAoc3RvcmVkX2xlbiArIDQgPD0gb3B0X2xlbmIgJiYgYnVmICE9PSAtMSkgewogICAgICAgICAgX3RyX3N0b3JlZF9ibG9jayhzLCBidWYsIHN0b3JlZF9sZW4sIGxhc3QpOwogICAgICAgIH0gZWxzZSBpZiAocy5zdHJhdGVneSA9PT0gWl9GSVhFRCB8fCBzdGF0aWNfbGVuYiA9PT0gb3B0X2xlbmIpIHsKICAgICAgICAgIHNlbmRfYml0cyhzLCAoU1RBVElDX1RSRUVTIDw8IDEpICsgKGxhc3QgPyAxIDogMCksIDMpOwogICAgICAgICAgY29tcHJlc3NfYmxvY2socywgc3RhdGljX2x0cmVlLCBzdGF0aWNfZHRyZWUpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBzZW5kX2JpdHMocywgKERZTl9UUkVFUyA8PCAxKSArIChsYXN0ID8gMSA6IDApLCAzKTsKICAgICAgICAgIHNlbmRfYWxsX3RyZWVzKHMsIHMubF9kZXNjLm1heF9jb2RlICsgMSwgcy5kX2Rlc2MubWF4X2NvZGUgKyAxLCBtYXhfYmxpbmRleCArIDEpOwogICAgICAgICAgY29tcHJlc3NfYmxvY2socywgcy5keW5fbHRyZWUsIHMuZHluX2R0cmVlKTsKICAgICAgICB9CiAgICAgICAgaW5pdF9ibG9jayhzKTsKICAgICAgICBpZiAobGFzdCkgewogICAgICAgICAgYmlfd2luZHVwKHMpOwogICAgICAgIH0KICAgICAgfQogICAgICBmdW5jdGlvbiBfdHJfdGFsbHkocywgZGlzdCwgbGMpIHsKICAgICAgICBzLnBlbmRpbmdfYnVmW3MuZF9idWYgKyBzLmxhc3RfbGl0ICogMl0gPSBkaXN0ID4+PiA4ICYgMjU1OwogICAgICAgIHMucGVuZGluZ19idWZbcy5kX2J1ZiArIHMubGFzdF9saXQgKiAyICsgMV0gPSBkaXN0ICYgMjU1OwogICAgICAgIHMucGVuZGluZ19idWZbcy5sX2J1ZiArIHMubGFzdF9saXRdID0gbGMgJiAyNTU7CiAgICAgICAgcy5sYXN0X2xpdCsrOwogICAgICAgIGlmIChkaXN0ID09PSAwKSB7CiAgICAgICAgICBzLmR5bl9sdHJlZVtsYyAqIDJdKys7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHMubWF0Y2hlcysrOwogICAgICAgICAgZGlzdC0tOwogICAgICAgICAgcy5keW5fbHRyZWVbKF9sZW5ndGhfY29kZVtsY10gKyBMSVRFUkFMUyArIDEpICogMl0rKzsKICAgICAgICAgIHMuZHluX2R0cmVlW2RfY29kZShkaXN0KSAqIDJdKys7CiAgICAgICAgfQogICAgICAgIHJldHVybiBzLmxhc3RfbGl0ID09PSBzLmxpdF9idWZzaXplIC0gMTsKICAgICAgfQogICAgICBleHBvcnRzMi5fdHJfaW5pdCA9IF90cl9pbml0OwogICAgICBleHBvcnRzMi5fdHJfc3RvcmVkX2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gIH0KICAgICAgZnVuY3Rpb24gcHV0X2J5dGUocywgYikgewogICAgICAgIHMucGVuZGluZ19idWZbcy5wZW5kaW5nKytdID0gYjsKICAgICAgfQogICAgICBmdW5jdGlvbiBwdXRTaG9ydE1TQihzLCBiKSB7CiAgICAgICAgcy5wZW5kaW5nX2J1ZltzLnBlbmRpbmcrK10gPSBiID4+PiA4ICYgMjU1OwogICAgICAgIHMucGVuZGluZ19idWZbcy5wZW5kaW5nKytdID0gYiAmIDI1NTsKICAgICAgfQogICAgICBmdW5jdGlvbiByZWFkX2J1ZihzdHJtLCBidWYsIHN0YXJ0LCBzaXplKSB7CiAgICAgICAgdmFyIGxlbiA9IHN0cm0uYXZhaWxfaW47CiAgICAgICAgaWYgKGxlbiA+IHNpemUpIHsKICAgICAgICAgIGxlbiA9IHNpemU7CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gPT09IDApIHsKICAgICAgICAgIHJldHVybiAwOwogICAgICAgIH0KICAgICAgICBzdHJtLmF2YWlsX2luIC09IGxlbjsKICAgICAgICB1dGlscy5hcnJheVNldChidWYsIHN0cm0uaW5wdXQsIHN0cm0ubmV4dF9pbiwgbGVuLCBzdGFydCk7CiAgICAgICAgaWYgKHN0cm0uc3RhdGUud3JhcCA9PT0gMSkgewogICAgICAgICAgc3RybS5hZGxlciA9IGFkbGVyMzIoc3RybS5hZGxlciwgYnVmLCBsZW4sIHN0YXJ0KTsKICAgICAgICB9IGVsc2UgaWYgKHN0cm0uc3RhdGUud3JhcCA9PT0gMikgewogICAgICAgICAgc3RybS5hZGxlciA9IGNyYzMyKHN0cm0uYWRsZXIsIGJ1ZiwgbGVuLCBzdGFydCk7CiAgICAgICAgfQogICAgICAgIHN0cm0ubmV4dF9pbiArPSBsZW47CiAgICAgICAgc3RybS50b3RhbF9pbiArPSBsZW47CiAgICAgICAgcmV0dXJuIGxlbjsKICAgICAgfQogICAgICBmdW5jdGlvbiBsb25nZXN0X21hdGNoKHMsIGN1cl9tYXRjaCkgewog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SAhPT0gX3dpbltzY2FuXSB8fCBfd2luWysrbWF0Y2hdICE9PSBfd2luW3NjYW4gKyAxXSkgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHNjYW4gKz0gMjsKICAgICAgICAgIG1hdGNoKys7CiAgICAgICAgICBkbyB7CiAgICAgICAgICB9IHdoaWxlIChfd2luWysrc2Nhbl0gPT09IF93aW5bKyttYXRjaF0gJiYgX3dpblsrK3NjYW5dID09PSBfd2luWysrbWF0Y2hdICYmIF93aW5bKytzY2FuXSA9PT0gX3dpblsrK21hdGNoXSAmJiBfd2luWysrc2Nhbl0gPT09IF93aW5bKyttYXRjaF0gJiYgX3dpblsrK3NjYW5dID09PSBfd2luWysrbWF0Y2hdICYmIF93aW5bKytzY2FuXSA9PT0gX3dpblsrK21hdGNoXSAmJiBfd2luWysrc2Nhbl0gPT09IF93aW5bKyttYXRjaF0gJiYgX3dpblsrK3NjYW5dID09PSBfd2luWysrbWF0Y2hdICYmIHNjYW4gPCBzdHJlbmQpOwogICAgICAgICAgbGVuID0gTUFYX01BVENIIC0gKHN0cmVuZCAtIHNjYW4pOwogICAgICAgICAgc2NhbiA9IHN0cmVuZCAtIE1BWF9NQVRDSDsKICAgICAgICAgIGlmIChsZW4gPiBiZXN0X2xlbikgewogICAgICAgICAgICBzLm1hdGNoX3N0YXJ0ID0gY3VyX21hdGNoOwogICAgICAgICAgICBiZXN0X2xlbiA9IGxlbjsKICAgICAgICAgICAgaWYgKGxlbiA+PSBuaWNlX21hdGNoKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc2Nhbl9lbmQxID0gX3dpbltzY2FuICsgYmVzdF9sZW4gLSAxXTsKICAgICAgICAgICAgc2Nhbl9lbmQgPSBfd2luW3NjYW4gKyBiZXN0X2xlbl07CiAgICAgICAgICB9CiAgICAgICAgfSB3aGlsZSAoKGN1cl9tYXRjaCA9IHByZXZbY3VyX21hdGNoICYgd21hc2tdKSA+IGxpbWl0ICYmIC0tY2hhaW5fbGVuZ3RoICE9PSAwKTsKICAgICAgICBpZiAoYmVzdF9sZW4gPD0gcy5sb29rYWhlYWQpIHsKICAgICAgICAgIHJldHVybiBiZXN0X2xlbjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHMubG9va2FoZWFkOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGZpbGxfd2luZG93KHMpIHsKICAgICAgICB2YXIgX3dfc2l6ZSA9IHMud19zaXplOwogICAgICAgIHZhciBwLCBuLCBtLCBtb3JlLCBzdHI7CiAgICAgICAgZG8gewogICAgICAgICAgbW9yZSA9IHMud2luZG93X3NpemUgLSBzLmxvb2thaGVhZCAtIHMuc3Ryc3RhcnQ7CiAgICAgICAgICBpZiAocy5zdHJzdGFydCA+PSBfd19zaXplICsgKF93X3NpemUgLSBNSU5fTE9PS0FIRUFEKSkgewogICAgICAgICAgICB1dGlscy5hcnJheVNldChzLndpbmRvdywgcy53aW5kb3csIF93X3NpemUsIF93X3NpemUsIDApOwogICAgICAgICAgICBzLm1hdGNoX3N0YXJ0IC09IF93X3NpemU7CiAgICAgICAgICAgIHMuc3Ryc3RhcnQgLT0gX3dfc2l6ZTsKICAgICAgICAgICAgcy5ibG9ja19zdGFydCAtPSBfd19zaXplOwogICAgICAgICAgICBuID0gcy5oYXNoX3NpemU7CiAgICAgICAgICAgIHAgPSBuOwogICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgbSA9IHMuaGVhZFstLXBdOwogICAgICAgICAgICAgIHMuaGVhZFtwXSA9IG0gPj0gX3dfc2l6ZSA/IG0gLSBfd19zaXplIDogMDsKICAgICAgICAgICAgfSB3aGlsZSAoLS1uKTsKICAgICAgICAgICAgbiA9IF93X3NpemU7CiAgICAgICAgICAgIHAgPSBuOwogICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgbSA9IHMucHJldlstLXBdOwogICAgICAgICAgICAgIHMucHJldltwXSA9IG0gPj0gX3dfc2l6ZSA/IG0gLSBfd19zaXplIDogMDsKICAgICAgICAgICAgfSB3aGlsZSAoLS1uKTsKICAgICAgICAgICAgbW9yZSArPSBfd19zaXplOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9pbiA9PT0gMCkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIG4gPSByZWFkX2J1ZihzLnN0cm0sIHMud2luZG93LCBzLnN0cnN0YXJ0ICsgcy5sb29rYWhlYWQsIG1vcmUpOwogICAgICAgICAgcy5sb29rYWhlYWQgKz0gbjsKICAgICAgICAgIGlmIChzLmxvb2thaGVhZCArIHMuaW5zZXJ0ID49IE1JTl9NQVRDSCkgewogICAgICAgICAgICBzdHIgPSBzLnN0cnN0YXJ0IC0gcy5pbnNlcnQ7CiAgICAgICAgICAgIHMuaW5zX2ggPSBzLndpbmRvd1tzdHJdOwogICAgICAgICAgICBzLmluc19oID0gKHMuaW5zX2ggPDwgcy5oYXNoX3NoaWZ0IF4gcy53aW5kb3dbc3RyICsgMV0pICYgcy5oYXNoX21hc2s7CiAgICAgICAgICAgIHdoaWxlIChzLmluc2VydCkgewogICAgICAgICAgICAgIHMuaW5zX2ggPSAocy5pbnNfaCA8PCBzLmhhc2hfc2hpZnQgXiBzLndpbmRvd1tzdHIgKyBNSU5fTUFUQ0ggLSAxXSkgJiBzLmhhc2hfbWFzazsKICAgICAgICAgICAgICBzLnByZXZbc3RyICYgcy53X21hc2tdID0gcy5oZWFkW3MuaW5zX2hdOwogICAgICAgICAgICAgIHMuaGVhZFtzLmluc19oXSA9IHN0cjsKICAgICAgICAgICAgICBzdHIrKzsKICAgICAgICAgICAgICBzLmluc2VydC0tOwogICAgICAgICAgICAgIGlmIChzLmxvb2thaGVhZCArIHMuaW5zZXJ0IDwgTUlOX01BVENIKSB7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9IHdoaWxlIChzLmxvb2thaGVhZCA8IE1JTl9MT09LQUhFQUQgJiYgcy5zdHJtLmF2YWlsX2luICE9PSAwKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBkZWZsYXRlX3N0b3JlZChzLCBmbHVzaCkgewogICAgICAgIHZhciBtYXhfYmxvY2tfc2l6ZSA9IDY1NTM1OwogICAgICAgIGlmIChtYXhfYmxvY2tfc2l6ZSA+IHMucGVuZGluZ19idWZfc2l6ZSAtIDUpIHsKICAgICAgICAgIG1heF9ibG9ja19zaXplID0gcy5wZW5kaW5nX2J1Zl9zaXplIC0gNTsKICAgICAgICB9CiAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICBpZiAocy5sb29rYWhlYWQgPD0gMSkgewogICAgICAgICAgICBmaWxsX3dpbmRvdyhzKTsKICAgICAgICAgICAgaWYgKHMubG9va2FoZWFkID09PSAwICYmIGZsdXNoID09PSBaX05PX0ZMVVNIKSB7CiAgICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAocy5sb29rYWhlYWQgPT09IDApIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgcy5zdHJzdGFydCArPSBzLmxvb2thaGVhZDsKICAgICAgICAgIHMubG9va2FoZWFkID0gMDsKICAgICAgICAgIHZhciBtYXhfc3RhcnQgPSBzLmJsb2NrX3N0YXJ0ICsgbWF4X2Jsb2NrX3NpemU7CiAgICAgICAgICBpZiAocy5zdHJzdGFydCA9PT0gMCB8fCBzLnN0cnN0YXJ0ID49IG1heF9zdGFydCkgewogICAgICAgICAgICBzLmxvb2thaGVhZCA9IHMuc3Ryc3RhcnQgLSBtYXhfc3RhcnQ7CiAgICAgICAgICAgIHMuc3Ryc3RhcnQgPSBtYXhfc3RhcnQ7CiAgICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgZmFsc2UpOwogICAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzLnN0cnN0YXJ0IC0gcy5ibG9ja19zdGFydCA+PSBzLndfc2l6ZSAtIE1JTl9MT09LQUhFQUQpIHsKICAgICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCBmYWxzZSk7CiAgICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBzLmluc2VydCA9IDA7CiAgICAgICAgaWYgKGZsdXNoID09PSBaX0ZJTklTSCkgewogICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCB0cnVlKTsKICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBCU19GSU5JU0hfU1RBUlRFRDsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBCU19GSU5JU0hfRE9ORTsKICAgICAgICB9CiAgICAgICAgaWYgKHMuc3Ryc3RhcnQgPiBzLmJsb2NrX3N0YXJ0KSB7CiAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIGZhbHNlKTsKICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZGVmbGF0ZV9mYXN0KHMsIGZsdXNoKSB7CiAgICAgICAgdmFyIGhhc2hfaGVhZDsKICAgICAgICB2YXIgYmZsdXNoOwogICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgaWYgKH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IE1JTl9NQVRDSCk7CiAgICAgICAgICAgIHMubG9va2FoZWFkIC09IHMubWF0Y2hfbGVuZ3RoOwogICAgICAgICAgICBpZiAocy5tYXRjaF9sZW5ndGggPD0gcy5tYXhfbGF6eV9tYXRjaCAmJiBzLmxvb2thaGVhZCA+PSBNSU5fTUFUQ0gpIHsKICAgICAgICAgICAgICBzLm1hdGNoX2xlbmd0aC0tOwogICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgIHMuc3Ryc3RhcnQrKzsKICAgICAgICAgICAgICAgIHMuaW5zX2ggPSAocy5pbnNfaCA8PCBzLmhhc2hfc2hpZnQgXiBzLndpbmRvd1tzLnN0cnN0YXJ0ICsgTUlOX01BVENIIC0gMV0pICYgcy5oYXNoX21hc2s7CiAgICAgICAgICAgICAgICBoYXNoX2hlYWQgPSBzLnByZXZbcy5zdHJzdGFydCAmIHMud19tYXNrXSA9IHMuaGVhZFtzLmluc19oXTsKICAgICAgICAgICAgICAgIHMuaGVhZFtzLmluc19oXSA9IHMuc3Ryc3RhcnQ7CiAgICAgICAgICAgICAgfSB3aGlsZSAoLS1zLm1hdGNoX2xlbmd0aCAhPT0gMCk7CiAgICAgICAgICAgICAgcy5zdHJzdGFydCsrOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHMuc3Ryc3RhcnQgKz0gcy5tYXRjaF9sZW5ndGg7CiAgICAgICAgICAgICAgcy5tYXRjaF9sZW5ndGggPSAwOwogICAgICAgICAgICAgIHMuaW5zX2ggPSBzLndpbmRvd1tzLnN0cnN0YXJ0XTsKICAgICAgICAgICAgICBzLmluc19oID0gKHMuaW5zX2ggPDwgcy5oYXNoX3NoaWZ0IF4gcy53aW5kb3dbcy5zdHJzdGFydCArIDFdKSAmIHMuaGFzaF9tYXNrOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBiZmx1c2ggPSB0cmVlcy5fdHJfdGFsbHkocywgMCwgcy53aW5kb3dbcy5zdHJzdGFydF0pOwogICAgICAgICAgICBzLmxvb2thaGVhZC0tOwogICAgICAgICAgICBzLnN0cnN0YXJ0Kys7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYmZsdXNoKSB7CiAgICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgZmFsc2UpOwogICAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcy5pbnNlcnQgPSBzLnN0cnN0YXJ0IDwgTUlOX01BVENIIC0gMSA/IHMuc3Ryc3RhcnQgOiBNSU5fTUFUQ0ggLSAxOwogICAgICAgIGlmIChmbHVzaCA9PT0gWl9GSU5JU0gpIHsKICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgdHJ1ZSk7CiAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICByZXR1cm4gQlNfRklOSVNIX1NUQVJURUQ7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gQlNfRklOSVNIX0RPTkU7CiAgICAgICAgfQogICAgICAgIGlmIChzLmxhc3RfbGl0KSB7CiAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIGZhbHNlKTsKICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiBCU19CTE9DS19ET05FOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRlZmxhdGVfc2xvdyhzLCBmbHVzaCkgewogICAgICAgIHZhciBoYXNoX2hlYWQ7CiAgICAgICAgdmFyIGJmbHVzaDsKICAgICAgICB2YXIgbWF4X2luc2VydDsKICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA8IE1JTl9MT09LQUhFQUQpIHsKICAgICAgICAgICAgZmlsbF93aW5kb3cocyk7CiAgICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA8IE1JTl9MT09LQUhFQUQgJiYgZmx1c2ggPT09IFpfTk9fRkxVU0gpIHsKICAgICAgICAgICAgICByZXR1cm4gQlNfTkVFRF9NT1JFOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA9PT0gMCkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBoYXNoX2hlYWQgPSAwOwogICAgICAgICAgaWYgKHMubG9va2FoZWFkID49IE1JTl9NQVRDSCkgewogICAgICAgICAgICBzLmluc19oID0gKHMuaW5zX2ggPDwgcy5oYXNoX3NoaWZ0IF4gcy53aW5kb3dbcy5zdHJzdGFydCArIE1JTl9NQVRDSCAtIDFdKSAmIHMuaGFzaF9tYXNrOwogICAgICAgICAgICBoYXNoX2hlYWQgPSBzLnByZXZbcy5zdHJzdGFydCAmIHMud19tYXNrXSA9IHMuaGVhZFtzLmluc19oXTsKICAgICAgICAgICAgcy5oZWFkW3MuaW5zX2hdID0gcy5zdHJzdGFydDsKICAgICAgICAgIH0KICAgICAgICAgIHMucHJldl9sZW5ndGggPSBzLm1hdGNoX2xlbmd0aDsKICAgICAgICAgIHMucHJldl9tYXRjaCA9IHMubWF0Y2hfc3RhcnQ7CiAgICAgICAgICBzLm1hdGNoX2xlbmd0aCA9IE1JTl9NQVRDSCAtIDE7CiAgICAgICAgICBpZiAoaGFzaF9oZWFkICE9PSAwICYmIHMucHJldl9sZW5ndGggPCBzLm1heF9sYXp5X21hdGNoICYmIHMuc3Ryc3RhcnQgLSBoYXNoX2hlYWQgPD0gcy53X3NpemUgLSBNSU5fTE9PS0FIRUFEKSB7CiAgICAgICAgICAgIHMubWF0Y2hfbGVuZ3RoID0gbG9uZ2VzdF9tYXRjaChzLCB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iAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IHdoaWxlICgtLXMucHJldl9sZW5ndGggIT09IDApOwogICAgICAgICAgICBzLm1hdGNoX2F2YWlsYWJsZSA9IDA7CiAgICAgICAgICAgIHMubWF0Y2hfbGVuZ3RoID0gTUlOX01BVENIIC0gMTsKICAgICAgICAgICAgcy5zdHJzdGFydCsrOwogICAgICAgICAgICBpZiAoYmZsdXNoKSB7CiAgICAgICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCBmYWxzZSk7CiAgICAgICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgaWYgKHMubWF0Y2hfYXZhaWxhYmxlKSB7CiAgICAgICAgICAgIGJmbHVzaCA9IHRyZWVzLl90cl90YWxseShzLCAwLCBzLndpbmRvd1tzLnN0cnN0YXJ0IC0gMV0pOwogICAgICAgICAgICBpZiAoYmZsdXNoKSB7CiAgICAgICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCBmYWxzZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcy5zdHJzdGFydCsrOwogICAgICAgICAgICBzLmxvb2thaGVhZC0tOwogICAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHMubWF0Y2hfYXZhaWxhYmxlID0gMTsKICAgICAgICAgICAgcy5zdHJzdGFydCsrOwogICAgICAgICAgICBzLmxvb2thaGVhZC0tOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAocy5tYXRjaF9hdmFpbGFibGUpIHsKICAgICAgICAgIGJmbHVzaCA9IHRyZWVzLl90cl90YWxseShzLCAwLCBzLndpbmRvd1tzLnN0cnN0YXJ0IC0gMV0pOwogICAgICAgICAgcy5tYXRjaF9hdmFpbGFibGUgPSAwOwogICAgICAgIH0KICAgICAgICBzLmluc2VydCA9IHMuc3Ryc3RhcnQgPCBNSU5fTUFUQ0ggLSAxID8gcy5zdHJzdGFydCA6IE1JTl9NQVRDSCAtIDE7CiAgICAgICAgaWYgKGZsdXNoID09PSBaX0ZJTklTSCkgewogICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCB0cnVlKTsKICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBCU19GSU5JU0hfU1RBUlRFRDsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBCU19GSU5JU0hfRE9ORTsKICAgICAgICB9CiAgICAgICAgaWYgKHMubGFzdF9saXQpIHsKICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgZmFsc2UpOwogICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIEJTX0JMT0NLX0RPTkU7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZGVmbGF0ZV9ybGUocywgZmx1c2gpIHsKICAgICAgICB2YXIgYmZsdXNoOwogICAgICAgIHZhciBwcmV2OwogICAgICAgIHZhciBzY2FuLCBzdHJlbmQ7CiAgICAgICAgdmFyIF93aW4gPSBzLndpbmRvdzsKICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA8PSBNQVhfTUFUQ0gpIHsKICAgICAgICAgICAgZmlsbF93aW5kb3cocyk7CiAgICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA8PSBNQVhfTUFUQ0ggJiYgZmx1c2ggPT09IFpfTk9fRkxVU0gpIHsKICAgICAgICAgICAgICByZXR1cm4gQlNfTkVFRF9NT1JFOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA9PT0gMCkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBzLm1hdGNoX2xlbmd0aCA9IDA7CiAgICAgICAgICBpZiAocy5sb29rYWhlYWQgPj0gTUlOX01BVENIICYmIHMuc3Ryc3RhcnQgPiAwKSB7CiAgICAgICAgICAgIHNjYW4gPSBzLnN0cnN0YXJ0IC0gMTsKICAgICAgICAgICAgcHJldiA9IF93aW5bc2Nhbl07CiAgICAgICAgICAgIGlmIChwcmV2ID09PSBfd2luWysrc2Nhbl0gJiYgcHJldiA9PT0gX3dpblsrK3NjYW5dICYmIHByZXYgPT09IF93aW5bKytzY2FuXSkgewogICAgICAgICAgICAgIHN0cmVuZCA9IHMuc3Ryc3RhcnQgKyBNQVhfTUFUQ0g7CiAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgIH0gd2hpbGUgKHByZXYgPT09IF93aW5bKytzY2FuXSAmJiBwcmV2ID09PSBfd2luWysrc2Nhbl0gJiYgcHJldiA9PT0gX3dpblsrK3NjYW5dICYmIHByZXYgPT09IF93aW5bKytzY2FuXSAmJiBwcmV2ID09PSBfd2luWysrc2Nhbl0gJiYgcHJldiA9PT0gX3dpblsrK3NjYW5dICYmIHByZXYgPT09IF93aW5bKytzY2FuXSAmJiBwcmV2ID09PSBfd2luWysrc2Nhbl0gJiYgc2NhbiA8IHN0cmVuZCk7CiAgICAgICAgICAgICAgcy5tYXRjaF9sZW5ndGggPSBNQVhfTUFUQ0ggLSAoc3RyZW5kIC0gc2Nhbik7CiAgICAgICAgICAgICAgaWYgKHMubWF0Y2hfbGVuZ3RoID4gcy5sb29rYWhlYWQpIHsKICAgICAgICAgICAgICAgIHMubWF0Y2hfbGVuZ3RoID0gcy5sb29rYWhlYWQ7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAocy5tYXRjaF9sZW5ndGggPj0gTUlOX01BVENIKSB7CiAgICAgICAgICAgIGJmbHVzaCA9IHRyZWVzLl90cl90YWxseShzLCAxLCBzLm1hdGNoX2xlbmd0aCAtIE1JTl9NQVRDSCk7CiAgICAgICAgICAgIHMubG9va2FoZWFkIC09IHMubWF0Y2hfbGVuZ3RoOwogICAgICAgICAgICBzLnN0cnN0YXJ0ICs9IHMubWF0Y2hfbGVuZ3RoOwogICAgICAgICAgICBzLm1hdGNoX2xlbmd0aCA9IDA7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBiZmx1c2ggPSB0cmVlcy5fdHJfdGFsbHkocywgMCwgcy53aW5kb3dbcy5zdHJzdGFydF0pOwogICAgICAgICAgICBzLmxvb2thaGVhZC0tOwogICAgICAgICAgICBzLnN0cnN0YXJ0Kys7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYmZsdXNoKSB7CiAgICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgZmFsc2UpOwogICAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcy5pbnNlcnQgPSAwOwogICAgICAgIGlmIChmbHVzaCA9PT0gWl9GSU5JU0gpIHsKICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgdHJ1ZSk7CiAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICByZXR1cm4gQlNfRklOSVNIX1NUQVJURUQ7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gQlNfRklOSVNIX0RPTkU7CiAgICAgICAgfQogICAgICAgIGlmIChzLmxhc3RfbGl0KSB7CiAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIGZhbHNlKTsKICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiBCU19CTE9DS19ET05FOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRlZmxhdGVfaHVmZihzLCBmbHVzaCkgewogICAgICAgIHZhciBiZmx1c2g7CiAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICBpZiAocy5sb29rYWhlYWQgPT09IDApIHsKICAgICAgICAgICAgZmlsbF93aW5kb3cocyk7CiAgICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA9PT0gMCkgewogICAgICAgICAgICAgIGlmIChmbHVzaCA9PT0gWl9OT19GTFVTSCkgewogICAgICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHMubWF0Y2hfbGVuZ3RoID0gMDsKICAgICAgICAgIGJmbHVzaCA9IHRyZWVzLl90cl90YWxseShzLCAwLCBzLndpbmRvd1tzLnN0cnN0YXJ0XSk7CiAgICAgICAgICBzLmxvb2thaGVhZC0tOwogICAgICAgICAgcy5zdHJzdGFydCsrOwogICAgICAgICAgaWYgKGJmbHVzaCkgewogICAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIGZhbHNlKTsKICAgICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgICByZXR1cm4gQlNfTkVFRF9NT1JFOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHMuaW5zZXJ0ID0gMDsKICAgICAgICBpZiAoZmx1c2ggPT09IFpfRklOSVNIKSB7CiAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIHRydWUpOwogICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgcmV0dXJuIEJTX0ZJTklTSF9TVEFSVEVEOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIEJTX0ZJTklTSF9ET05FOwogICAgICAgIH0KICAgICAgICBpZiAocy5sYXN0X2xpdCkgewogICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCBmYWxzZSk7CiAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICByZXR1cm4gQlNfTkVFRF9NT1JFOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gQlNfQkxPQ0tfRE9ORTsKICAgICAgfQogICAgICBmdW5jdGlvbiBDb25maWcoZ29vZF9sZW5ndGgsIG1heF9sYXp5LCBuaWNlX2xlbmd0aCwgbWF4X2NoYWluLCBmdW5jKSB7CiAgICAgICAgdGhpcy5nb29kX2xlbmd0aCA9IGdvb2RfbGVuZ3RoOwogICAgICAgIHRoaXMubWF4X2xhenkgPSBtYXhfbGF6eTsKICAgICAgICB0aGlzLm5pY2VfbGVuZ3RoID0gbmljZV9sZW5ndGg7CiAgICAgICAgdGhpcy5tYXhfY2hhaW4gPSBtYXhfY2hhaW47CiAgICAgICAgdGhpcy5mdW5jID0gZnVuYzsKICAgICAgfQogICAgICB2YXIgY29uZmlndXJhdGlvbl90YWJsZTsKICAgICAgY29uZmlndXJhdGlvbl90YWJsZSA9IFsKICAgICAgICBuZXcgQ29uZmlnKDAsIDAsIDAsIDAsIGRlZmxhdGVfc3RvcmVkKSwKICAgICAgICBuZXcgQ29uZmlnKDQsIDQsIDgsIDQsIGRlZmxhdGVfZmFzdCksCiAgICAgICAgbmV3IENvbmZpZyg0LCA1LCAxNiwgOCwgZGVmbGF0ZV9mYXN0KSwKICAgICAgICBuZXcgQ29uZmlnKDQsIDYsIDMyLCAzMiwgZGVmbGF0ZV9mYXN0KSwKICAgICAgICBuZXcgQ29uZmlnKDQsIDQsIDE2LCAxNiwgZG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nNfaCA9IDA7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gRGVmbGF0ZVN0YXRlKCkgewogICAgICAgIHRoaXMuc3RybSA9IG51bGw7CiAgICAgICAgdGhpcy5zdGF0dXMgPSAwOwogICAgICAgIHRoaXMucGVuZGluZ19idWYgPSBudWxsOwogICAgICAgIHRoaXMucGVuZGluZ19idWZfc2l6ZSA9IDA7CiAgICAgICAgdGhpcy5wZW5kaW5nX291dCA9IDA7CiAgICAgICAgdGhpcy5wZW5kaW5nID0gMDsKICAgICAgICB0aGlzLndyYXAgPSAwOwogICAgICAgIHRoaXMuZ3poZWFkID0gbnVsbDsKICAgICAgICB0aGlzLmd6aW5kZXggPSAwOwogICAgICAgIHRoaXMubWV0aG9kID0gWl9ERUZMQVRFRDsKICAgICAgICB0aGlzLmxhc3RfZmx1c2ggPSAtMTsKICAgICAgICB0aGlzLndfc2l6ZSA9IDA7CiAgICAgICAgdGhpcy53X2JpdHMgPSAwOwogICAgICAgIHRoaXMud19tYXNrID0gMDsKICAgICAgICB0aGlzLndpbmRvdyA9IG51bGw7CiAgICAgICAgdGhpcy53aW5kb3dfc2l6ZSA9IDA7CiAgICAgICAgdGhpcy5wcmV2ID0gbnVsbDsKICAgICAgICB0aGlzLmhlYWQgPSBudWxsOwogICAgICAgIHRoaXMuaW5zX2ggPSAwOwogICAgICAgIHRoaXMuaGFzaF9zaXplID0gMDsKICAgICAgICB0aGlzLmhhc2hfYml0cyA9IDA7CiAgICAgICAgdGhpcy5oYXNoX21hc2sgPSAwOwogICAgICAgIHRoaXMuaGFzaF9zaGlmdCA9IDA7CiAgICAgICAgdGhpcy5ibG9ja19zdGFydCA9IDA7CiAgICAgICAgdGhpcy5tYXRjaF9sZW5ndGggPSAwOwogICAgICAgIHRoaXMucHJldl9tYXRjaCA9IDA7CiAgICAgICAgdGhpcy5tYXRjaF9hdmFpbGFibGUgPSAwOwogICAgICAgIHRoaXMuc3Ryc3RhcnQgPSAwOwogICAgICAgIHRoaXMubW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xNigyICogTF9DT0RFUyArIDEpOwogICAgICAgIHplcm8odGhpcy5kZXB0aCk7CiAgICAgICAgdGhpcy5sX2J1ZiA9IDA7CiAgICAgICAgdGhpcy5saXRfYnVmc2l6ZSA9IDA7CiAgICAgICAgdGhpcy5sYXN0X2xpdCA9IDA7CiAgICAgICAgdGhpcy5kX2J1ZiA9IDA7CiAgICAgICAgdGhpcy5vcHRfbGVuID0gMDsKICAgICAgICB0aGlzLnN0YXRpY19sZW4gPSAwOwogICAgICAgIHRoaXMubWF0Y2hlcyA9IDA7CiAgICAgICAgdGhpcy5pbnNlcnQgPSAwOwogICAgICAgIHRoaXMuYmlfYnVmID0gMDsKICAgICAgICB0aGlzLmJpX3ZhbGlkID0gMDsKICAgICAgfQogICAgICBmdW5jdGlvbiBkZWZsYXRlUmVzZXRLZWVwKHN0cm0pIHsKICAgICAgICB2YXIgczsKICAgICAgICBpZiAoIXN0cm0gfHwgIXN0cm0uc3RhdGUpIHsKICAgICAgICAgIHJldHVybiBlcnIoc3RybSwgWl9TVFJFQU1fRVJST1IpOwogICAgICAgIH0KICAgICAgICBzdHJtLnRvdGFsX2luID0gc3RybS50b3RhbF9vdXQgPSAwOwogICAgICAgIHN0cm0uZGF0YV90eXBlID0gWl9VTktOT1dOOwogICAgICAgIHMgPSBzdHJtLnN0YXRlOwogICAgICAgIHMucGVuZGluZyA9IDA7CiAgICAgICAgcy5wZW5kaW5nX291dCA9IDA7CiAgICAgICAgaWYgKHMud3JhcCA8IDApIHsKICAgICAgICAgIHMud3JhcCA9IC1zLndyYXA7CiAgICAgICAgfQogICAgICAgIHMuc3RhdHVzID0gcy53cmFwID8gSU5JVF9TVEFURSA6IEJVU1lfU1RBVEU7CiAgICAgICAgc3RybS5hZGxlciA9IHMud3JhcCA9PT0gMiA/IDAgOiAxOwogICAgICAgIHMubGFzdF9mbHVzaCA9IFpfTk9fRkxVU0g7CiAgICAgICAgdHJlZXMuX3RyX2luaXQocyk7CiAgICAgICAgcmV0dXJuIFpfT0s7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZGVmbGF0ZVJlc2V0KHN0cm0pIHsKICAgICAgICB2YXIgcmV0ID0gZGVmbGF0ZVJlc2V0S2VlcChzdHJtKTsKICAgICAgICBpZiAocmV0ID09PSBaX09LKSB7CiAgICAgICAgICBsbV9pbml0KHN0cm0uc3RhdGUpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gcmV0OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRlZmxhdGVTZXRIZWFkZXIoc3RybSwgaGVhZCkgewogICAgICAgIGlmICghc3RybSB8fCAhc3RybS5zdGF0ZSkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgIH0KICAgICAgICBpZiAoc3RybS5zdGF0ZS53cmFwICE9PSAyKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIHN0cm0uc3RhdGUuZ3poZWFkID0gaGVhZDsKICAgICAgICByZXR1cm4gWl9PSzsKICAgICAgfQogICAgICBmdW5jdGlvbiBkZWZsYXRlSW5pdDIoc3RybSwgbGV2ZWwsIG1ldGhvZCwgd2luZG93Qml0cywgbWVtTGV2ZWwsIHN0cmF0ZWd5KSB7CiAgICAgICAgaWYgKCFzdHJtKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIHZhciB3cmFwID0gMTsKICAgICAgICBpZiAobGV2ZWwgPT09IFpfREVGQVVMVF9DT01QUkVTU0lPTikgewogICAgICAgICAgbGV2ZWwgPSA2OwogICAgICAgIH0KICAgICAgICBpZiAod2luZG93Qml0cyA8IDApIHsKICAgICAgICAgIHdyYXAgPSAwOwogICAgICAgICAgd2luZG93Qml0cyA9IC13aW5kb3dCaXRzOwogICAgICAgIH0gZWxzZSBpZiAod2luZG93Qml0cyA+IDE1KSB7CiAgICAgICAgICB3cmFwID0gMjsKICAgICAgICAgIHdpbm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zdHJtLmlucHV0ICYmIHN0cm0uYXZhaWxfaW4gIT09IDAgfHwgcy5zdGF0dXMgPT09IEZJTklTSF9TVEFURSAmJiBmbHVzaCAhPT0gWl9GSU5JU0gpIHsKICAgICAgICAgIHJldHVybiBlcnIoc3RybSwgc3RybS5hdmFpbF9vdXQgPT09IDAgPyBaX0JVRl9FUlJPUiA6IFpfU1RSRUFNX0VSUk9SKTsKICAgICAgICB9CiAgICAgICAgcy5zdHJtID0gc3RybTsKICAgICAgICBvbGRfZmx1c2ggPSBzLmxhc3RfZmx1c2g7CiAgICAgICAgcy5sYXN0X2ZsdXNoID0gZmx1c2g7CiAgICAgICAgaWYgKHMuc3RhdHVzID09PSBJTklUX1NUQVRFKSB7CiAgICAgICAgICBpZiAocy53cmFwID09PSAyKSB7CiAgICAgICAgICAgIHN0cm0uYWRsZXIgPSAwOwogICAgICAgICAgICBwdXRfYnl0ZShzLCAzMSk7CiAgICAgICAgICAgIHB1dF9ieXRlKHMsIDEzOSk7CiAgICAgICAgICAgIHB1dF9ieXRlKHMsIDgpOwogICAgICAgICAgICBpZiAoIXMuZ3poZWFkKSB7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgMCk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgMCk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgMCk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgMCk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgMCk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgcy5sZXZlbCA9PT0gOSA/IDIgOiBzLnN0cmF0ZWd5ID49IFpfSFVGRk1BTl9PTkxZIHx8IHMubGV2ZWwgPCAyID8gNCA6IDApOwogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIE9TX0NPREUpOwogICAgICAgICAgICAgIHMuc3RhdHVzID0gQlVTWV9TVEFURTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCAocy5nemhlYWQudGV4dCA/IDEgOiAwKSArIChzLmd6aGVhZC5oY3JjID8gMiA6IDApICsgKCFzLmd6aGVhZC5leHRyYSA/IDAgOiA0KSArICghcy5nemhlYWQubmFtZSA/IDAgOiA4KSArICghcy5nemhlYWQuY29tbWVudCA/IDAgOiAxNikpOwogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIHMuZ3poZWFkLnRpbWUgJiAyNTUpOwogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIHMuZ3poZWFkLnRpbWUgPj4gOCAmIDI1NSk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgcy5nemhlYWQudGltZSA+PiAxNiAmIDI1NSk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgcy5nemhlYWQudGltZSA+PiAyNCAmIDI1NSk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgcy5sZXZlbCA9PT0gOSA/IDIgOiBzLnN0cmF0ZWd5ID49IFpfSFVGRk1BTl9PTkxZIHx8IHMubGV2ZWwgPCAyID8gNCA6IDApOwogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIHMuZ3poZWFkLm9zICYgMjU1KTsKICAgICAgICAgICAgICBpZiAocy5nemhlYWQuZXh0cmEgJiYgcy5nemhlYWQuZXh0cmEubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICBwdXRfYnl0ZShzLCBzLmd6aGVhZC5leHRyYS5sZW5ndGggJiAyNTUpOwogICAgICAgICAgICAgICAgcHV0X2J5dGUocywgcy5nemhlYWQuZXh0cmEubGVuZ3RoID4+IDggJiAyNTUpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAocy5nemhlYWQuaGNyYykgewogICAgICAgICAgICAgICAgc3RybS5hZGxlciA9IGNyYzMyKHN0cm0uYWRsZXIsIHMucGVuZGluZ19idWYsIHMucGVuZGluZywgMCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHMuZ3ppbmRleCA9IDA7CiAgICAgICAgICAgICAgcy5zdGF0dXMgPSBFWFRSQV9TVEFURTsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgdmFyIGhlYWRlciA9IFpfREVGTEFURUQgKyAocy53X2JpdHMgLSA4IDw8IDQpIDw8IDg7CiAgICAgICAgICAgIHZhciBsZXZlbF9mbGFncyA9IC0xOwogICAgICAgICAgICBpZiAocy5zdHJhdGVneSA+PSBaX0hVRkZNQU5fT05MWSB8fCBzLmxldmVsIDwgMikgewogICAgICAgICAgICAgIGxldmVsX2ZsYWdzID0gMDsKICAgICAgICAgICAgfSBlbHNlIGlmIChzLmxldmVsIDwgNikgewogICAgICAgICAgICAgIGxldmVsX2ZsYWdzID0gMTsKICAgICAgICAgICAgfSBlbHNlIGlmIChzLmxldmVsID09PSA2KSB7CiAgICAgICAgICAgICAgbGV2ZWxfZmxhZ3MgPSAyOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGxldmVsX2ZsYWdzID0gMzsKICAgICAgICAgICAgfQogICAgICAgICAgICBoZWFkZXIgfD0gbGV2ZWxfZmxhZ3MgPDwgNjsKICAgICAgICAgICAgaWYgKHMuc3Ryc3RhcnQgIT09IDApIHsKICAgICAgICAgICAgICBoZWFkZXIgfD0gUFJFU0VUX0RJQ1Q7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaGVhZGVyICs9IDMxIC0gaGVhZGVyICUgMzE7CiAgICAgICAgICAgIHMuc3RhdHVzID0gQlVTWV9TVEFURTsKICAgICAgICAgICAgcHV0U2hvcnRNU0IocywgaGVhZGVyKTsKICAgICAgICAgICAgaWYgKHMuc3Ryc3RhcnQgIT09IDApIHsKICAgICAgICAgICAgICBwdXRTaG9ydE1TQihzLCBzdHJtLmFkbGVyID4+PiAxNik7CiAgICAgICAgICAgICAgcHV0U2hvcnRNU0Iocywgc3RybS5hZGxlciAmIDY1NTM1KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBzdHJtLmFkbGVyID0gMTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHMuc3RhdHVzID09PSBFWFRSQV9TVEFURSkgewogICAgICAgICAgaWYgKHMuZ3poZWFkLmV4dHJhKSB7CiAgICAgICAgICAgIGJlZyA9IHMucGVuZGluZzsKICAgICAgICAgICAgd2hpbGUgKHMuZ3ppbmRleCA8IChzLmd6aGVhZC5leHRyYS5sZW5ndGggJiA2NTUzNSkpIHsKICAgICAgICAgICAgICBpZiAocy5wZW5kaW5nID09PSBzLnBlbmRpbmdfYnVmX3NpemUpIHsKICAgICAgICAgICAgICAgIGlmIChzLmd6aGVhZC5oY3JjICYmIHMucGVuZGluZyA+IGJlZykgewogICAgICAgICAgICAgICAgICBzdHJtLmFkbGVyID0gY3JjMzIoc3RybS5hZGxlciwgcy5wZW5kaW5nX2J1Ziwgcy5wZW5kaW5nIC0gYmVnLCBiZWcpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZmx1c2hfcGVuZGluZyhzdHJtKTsKICAgICAgICAgICAgICAgIGJlZyA9IHMucGVuZGluZzsKICAgICAgICAgICAgICAgIGlmIChzLnBlbmRpbmcgPT09IHMucGVuZGluZ19idWZfc2l6ZSkgewogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgcy5nemhlYWQuZXh0cmFbcy5nemluZGV4XSAmIDI1NSk7CiAgICAgICAgICAgICAgcy5nemluZGV4Kys7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHMuZ3poZWFkLmhjcmMgJiYgcy5wZW5kaW5nID4gYmVnKSB7CiAgICAgICAgICAgICAgc3RybS5hZGxlciA9IGNyYzMyKHN0cm0uYWRsZXIsIHMucGVuZGluZ19idWYsIHMucGVuZGluZyAtIGJlZywgYmVnKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAocy5nemluZGV4ID09PSBzLmd6aGVhZC5leHRyYS5sZW5ndGgpIHsKICAgICAgICAgICAgICBzLmd6aW5kZXggPSAwOwogICAgICAgICAgICAgIHMuc3RhdHVzID0gTkFNRV9TVEFURTsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcy5zdGF0dXMgPSBOQU1FX1NUQVRFOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAocy5zdGF0dXMgPT09IE5BTUVfU1RBVEUpIHsKICAgICAgICAgIGlmIChzLmd6aGVhZC5uYW1lKSB7CiAgICAgICAgICAgIGJlZyA9IHMucGVuZGluZzsKICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgIGlmIChzLnBlbmRpbmcgPT09IHMucGVuZGluZ19idWZfc2l6ZSkgewogICAgICAgICAgICAgICAgaWYgKHMuZ3poZWFkLmhjcmMgJiYgcy5wZW5kaW5nID4gYmVnKSB7CiAgICAgICAgICAgICAgICAgIHN0cm0uYWRsZXIgPSBjcmMzMihzdHJtLmFkbGVyLCBzLnBlbmRpbmdfYnVmLCBzLnBlbmRpbmcgLSBiZWcsIGJlZyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmbHVzaF9wZW5kaW5nKHN0cm0pOwogICAgICAgICAgICAgICAgYmVnID0gcy5wZW5kaW5nOwogICAgICAgICAgICAgICAgaWYgKHMucGVuZGluZyA9PT0gcy5wZW5kaW5nX2J1Zl9zaXplKSB7CiAgICAgICAgICAgICAgICAgIHZhbCA9IDE7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAocy5nemluZGV4IDwgcy5nemhlYWQubmFtZS5sZW5ndGgpIHsKICAgICAgICAgICAgICAgIHZhbCA9IHMuZ3poZWFkLm5hbWUuY2hhckNvZGVBdChzLmd6aW5kZXgrKykgJiAyNTU7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHZhbCA9IDA7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIHZhbCk7CiAgICAgICAgICAgIH0gd2hpbGUgKHZhbCAhPT0gMCk7CiAgICAgICAgICAgIGlmIChzLmd6aGVhZC5oY3JjICYmIHMucGVuZGluZyA+IGJlZykgewogICAgICAgICAgICAgIHN0cm0uYWRsZXIgPSBjcmMzMihzdHJtLmFkbGVyLCBzLnBlbmRpbmdfYnVmLCBzLnBlbmRpbmcgLSBiZWcsIGJlZyk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHZhbCA9PT0gMCkgewogICAgICAgICAgICAgIHMuZ3ppbmRleCA9IDA7CiAgICAgICAgICAgICAgcy5zdGF0dXMgPSBDT01NRU5UX1NUQVRFOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzLnN0YXR1cyA9IENPTU1FTlRfU1RBVEU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChzLnN0YXR1cyA9PT0gQ09NTUVOVF9TVEFURSkgewogICAgICAgICAgaWYgKHMuZ3poZWFkLmNvbW1lbnQpIHsKICAgICAgICAgICAgYmVnID0gcy5wZW5kaW5nOwogICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgaWYgKHMucGVuZGluZyA9PT0gcy5wZW5kaW5nX2J1Zl9zaXplKSB7CiAgICAgICAgICAgICAgICBpZiAocy5nemhlYWQuaGNyYyAmJiBzLnBlbmRpbmcgPiBiZWcpIHsKICAgICAgICAgICAgICAgICAgc3RybS5hZGxlciA9IGNyYzMyKHN0cm0uYWRsZXIsIHMucGVuZGluZ19idWYsIHMucGVuZGluZyAtIGJlZywgYmVnKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZsdXNoX3BlbmRpbmcoc3RybSk7CiAgICAgICAgICAgICAgICBiZWcgPSBzLnBlbmRpbmc7CiAgICAgICAgICAgICAgICBpZiAocy5wZW5kaW5nID09PSBzLnBlbmRpbmdfYnVmX3NpemUpIHsKICAgICAgICAgICAgICAgICAgdmFsID0gMTsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChzLmd6aW5kZXggPCBzLmd6aGVhZC5jb21tZW50Lmxlbmd0aCkgewogICAgICAgICAgICAgICAgdmFsID0gcy5nemhlYWQuY29tbWVudC5jaGFyQ29kZUF0KHMuZ3ppbmRleCsrKSAmIDI1NTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgdmFsID0gMDsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgdmFsKTsKICAgICAgICAgICAgfSB3aGlsZSAodmFsICE9PSAwKTsKICAgICAgICAgICAgaWYgKHMuZ3poZWFkLmhjcmMgJiYgcy5wZW5kaW5nID4gYmVnKSB7CiAgICAgICAgICAgICAgc3RybS5hZGxlciA9IGNyYzMyKHN0cm0uYWRsZXIsIHMucGVuZGluZ19idWYsIHMucGVuZGluZyAtIGJlZywgYmVnKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodmFsID09PSAwKSB7CiAgICAgICAgICAgICAgcy5zdGF0dXMgPSBIQ1JDX1NUQVRFOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzLnN0YXR1cyA9IEhDUkNfU1RBVEU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChzLnN0YXR1cyA9PT0gSENSQ19TVEFURSkgewogICAgICAgICAgaWYgKHMuZ3poZWFkLmhjcmMpIHsKICAgICAgICAgICAgaWYgKHMucGVuZGluZyArIDIgPiBzLnBlbmRpbmdfYnVmX3NpemUpIHsKICAgICAgICAgICAgICBmbHVzaF9wZW5kaW5nKHN0cm0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzLnBlbmRpbmcgKyAyIDw9IHMucGVuZGluZ19idWZfc2l6ZSkgewogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIHN0cm0uYWRsZXIgJiAyNTUpOwogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIHN0cm0uYWRsZXIgPj4gOCAmIDI1NSk7CiAgICAgICAgICAgICAgc3RybS5hZGxlciA9IDA7CiAgICAgICAgICAgICAgcy5zdGF0dXMgPSBCVVNZX1NUQVRFOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzLnN0YXR1cyA9IEJVU1lfU1RBVEU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChzLnBlbmRpbmcgIT09IDApIHsKICAgICAgICAgIGZsdXNoX3BlbmRpbmcoc3RybSk7CiAgICAgICAgICBpZiAoc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgcy5sYXN0X2ZsdXNoID0gLTE7CiAgICAgICAgICAgIHJldHVybiBaX09LOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoc3RybS5hdmFpbF9pbiA9PT0gMCAmJiByYW5rKGZsdXNoKSA8PSByYW5rKG9sZF9mbHVzaCkgJiYgZmx1c2ggIT09IFpfRklOSVNIKSB7CiAgICAgICAgICByZXR1cm4gZXJyKHN0cm0sIFpfQlVGX0VSUk9SKTsKICAgICAgICB9CiAgICAgICAgaWYgKHMuc3RhdHVzID09PSBGSU5JU0hfU1RBVEUgJiYgc3RybS5hdmFpbF9pbiAhPT0gMCkgewogICAgICAgICAgcmV0dXJuIGVycihzdHJtLCBaX0JVRl9FUlJPUik7CiAgICAgICAgfQogICAgICAgIGlmIChzdHJtLmF2YWlsX2luICE9PSAwIHx8IHMubG9va2FoZWFkICE9PSAwIHx8IGZsdXNoICE9PSBaX05PX0ZMVVNIICYmIHMuc3RhdHVzICE9PSBGSU5JU0hfU1RBVEUpIHsKICAgICAgICAgIHZhciBic3RhdGUgPSBzLnN0cmF0ZWd5ID09PSBaX0hVRkZNQU5fT05MWSA/IGRlZmxhdGVfaHVmZihzLCBmbHVzaCkgOiBzLnN0cmF0ZWd5ID09PSBaX1JMRSA/IGRlZmxhdGVfcmxlKHMsIGZsdXNoKSA6IGNvbmZpZ3VyYXRpb25fdGFibGVbcy5sZXZlbF0uZnVuYyhzLCBmbHVzaCk7CiAgICAgICAgICBpZiAoYnN0YXRlID09PSBCU19GSU5JU0hfU1RBUlRFRCB8fCBic3RhdGUgPT09IEJTX0ZJTklTSF9ET05FKSB7CiAgICAgICAgICAgIHMuc3RhdHVzID0gRklOSVNIX1NUQVRFOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGJzdGF0ZSA9PT0gQlNfTkVFRF9NT1JFIHx8IGJzdGF0ZSA9PT0gQlNfRklOSVNIX1NUQVJURUQpIHsKICAgICAgICAgICAgaWYgKHN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgICAgcy5sYXN0X2ZsdXNoID0gLTE7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIFpfT0s7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYnN0YXRlID09PSBCU19CTE9DS19ET05FKSB7CiAgICAgICAgICAgIGlmIChmbHVzaCA9PT0gWl9QQVJUSUFMX0ZMVVNIKSB7CiAgICAgICAgICAgICAgdHJlZXMuX3RyX2FsaWduKHMpOwogICAgICAgICAgICB9IGVsc2UgaWYgKGZsdXNoICE9PSBaX0JMT0NLKSB7CiAgICAgICAgICAgICAgdHJlZXMuX3RyX3N0b3JlZF9ibG9jayhzLCAwLCAwLCBmYWxzZSk7CiAgICAgICAgICAgICAgaWYgKGZsdXNoID09PSBaX0ZVTExfRkxVU0gpIHsKICAgICAgICAgICAgICAgIHplcm8ocy5oZWFkKTsKICAgICAgICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA9PT0gMCkgewogICAgICAgICAgICAgICAgICBzLnN0cnN0YXJ0ID0gMDsKICAgICAgICAgICAgICAgICAgcy5ibG9ja19zdGFydCA9IDA7CiAgICAgICAgICAgICAgICAgIHMuaW5zZXJ0ID0gMDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZmx1c2hfcGVuZGluZyhzdHJtKTsKICAgICAgICAgICAgaWYgKHN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgICAgcy5sYXN0X2ZsdXNoID0gLTE7CiAgICAgICAgICAgICAgcmV0dXJuIFpfT0s7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKGZsdXNoICE9PSBaX0ZJTklTSCkgewogICAgICAgICAgcmV0dXJuIFpfT0s7CiAgICAgICAgfQogICAgICAgIGlmIChzLndyYXAgPD0gMCkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VORDsKICAgICAgICB9CiAgICAgICAgaWYgKHMud3JhcCA9PT0gMikgewogICAgICAgICAgcHV0X2J5dGUocywgc3RybS5hZGxlciAmIDI1NSk7CiAgICAgICAgICBwdXRfYnl0ZShzLCBzdHJtLmFkbGVyID4+IDggJiAyNTUpOwogICAgICAgICAgcHV0X2J5dGUocywgc3RybS5hZGxlciA+PiAxNiAmIDI1NSk7CiAgICAgICAgICBwdXRfYnl0ZShzLCBzdHJtLmFkbGVyID4+IDI0ICYgMjU1KTsKICAgICAgICAgIHB1dF9ieXRlKHMsIHN0cm0udG90YWxfaW4gJiAyNTUpOwogICAgICAgICAgcHV0X2J5dGUocywgc3RybS50b3RhbF9pbiA+PiA4ICYgMjU1KTsKICAgICAgICAgIHB1dF9ieXRlKHMsIHN0cm0udG90YWxfaW4gPj4gMTYgJiAyNTUpOwogICAgICAgICAgcHV0X2J5dGUocywgc3RybS50b3RhbF9pbiA+PiAyNCAmIDI1NSk7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHB1dFNob3J0TVNCKHMsIHN0cm0uYWRsZXIgPj4+IDE2KTsKICAgICAgICAgIHB1dFNob3J0TVNCKHMsIHN0cm0uYWRsZXIgJiA2NTUzNSk7CiAgICAgICAgfQogICAgICAgIGZsdXNoX3BlbmRpbmcoc3RybSk7CiAgICAgICAgaWYgKHMud3JhcCA+IDApIHsKICAgICAgICAgIHMud3JhcCA9IC1zLndyYXA7CiAgICAgICAgfQogICAgICAgIHJldHVybiBzLnBlbmRpbmcgIT09IDAgPyBaX09LIDogWl9TVFJFQU1fRU5EOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRlZmxhdGVFbmQoc3RybSkgewogICAgICAgIHZhciBzdGF0dXM7CiAgICAgICAgaWYgKCFzdHJtIHx8ICFzdHJtLnN0YXRlKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIHN0YXR1cyA9IHN0cm0uc3RhdGUuc3RhdHVzOwogICAgICAgIGlmIChzdGF0dXMgIT09IElOSVRfU1RBVEUgJiYgc3RhdHVzICE9PSBFWFRSQV9TVEFURSAmJiBzdGF0dXMgIT09IE5BTUVfU1RBVEUgJiYgc3RhdHVzICE9PSBDT01NRU5UX1NUQVRFICYmIHN0YXR1cyAhPT0gSENSQ19TVEFURSAmJiBzdGF0dXMgIT09IEJVU1lfU1RBVEUgJiYgc3RhdHVzICE9PSBGSU5JU0hfU1RBVEUpIHsKICAgICAgICAgIHJldHVybiBlcnIoc3RybSwgWl9TVFJFQU1fRVJST1IpOwogICAgICAgIH0KICAgICAgICBzdHJtLnN0YXRlID0gbnVsbDsKICAgICAgICByZXR1cm4gc3RhdHVzID09PSBCVVNZX1NUQVRFID8gZXJyKHN0cm0sIFpfREFUQV9FUlJPUikgOiBaX09LOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRlZmxhdGVTZXREaWN0aW9uYXJ5KHN0cm0sIGRpY3Rpb25hcnkpIHsKICAgICAgICB2YXIgZGljdExlbmd0aCA9IGRpY3Rpb25hcnkubGVuZ3RoOwogICAgICAgIHZhciBzOwogICAgICAgIHZhciBzdHIsIG47CiAgICAgICAgdmFyIHdyYXA7CiAgICAgICAgdmFyIGF2YWlsOwogICAgICAgIHZhciBuZXh0OwogICAgICAgIHZhciBpbnB1dDsKICAgICAgICB2YXIgdG1wRGljdDsKICAgICAgICBpZiAoIXN0cm0gfHwgIXN0cm0uc3RhdGUpIHsKICAgICAgICAgIHJldHVybiBaX1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgcyA9IHN0cm0uc3RhdGU7CiAgICAgICAgd3JhcCA9IHMud3JhcDsKICAgICAgICBpZiAod3JhcCA9PT0gMiB8fCB3cmFwID09PSAxICYmIHMuc3RhdHVzICE9PSBJTklUX1NUQVRFIHx8IHMubG9va2FoZWFkKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIGlmICh3cmFwID09PSAxKSB7CiAgICAgICAgICBzdHJtLmFkbGVyID0gYWRsZXIzMihzdHJtLmFkbGVyLCBkaWN0aW9uYXJ5LCBkaWN0TGVuZ3RoLCAwKTsKICAgICAgICB9CiAgICAgICAgcy53cmFwID0gMDsKICAgICAgICBpZiAoZGljdExlbmd0aCA+PSBzLndfc2l6ZSkgewogICAgICAgICAgaWYgKHdyYXAgPT09IDApIHsKICAgICAgICAgICAgemVybyhzLmhlYWQpOwogICAgICAgICAgICBzLnN0cnN0YXJ0ID0gMDsKICAgICAgICAgICAgcy5ibG9ja19zdGFydCA9IDA7CiAgICAgICAgICAgIHMuaW5zZXJ0ID0gMDsKICAgICAgICAgIH0KICAgICAgICAgIHRtcERpY3QgPSBuZXcgdXRpbHMuQnVmOChzLndfc2l6ZSk7CiAgICAgICAgICB1dGlscy5hcnJheVNldCh0bXBEaWN0LCBkaWN0aW9uYXJ5LCBkaWN0TGVuZ3RoIC0gcy53X3NpemUsIHMud19zaXplLCAwKTsKICAgICAgICAgIGRpY3Rpb25hcnkgPSB0bXBEaWN0OwogICAgICAgICAgZGljdExlbmd0aCA9IHMud19zaXplOwogICAgICAgIH0KICAgICAgICBhdmFpbCA9IHN0cm0uYXZhaWxfaW47CiAgICAgICAgbmV4dCA9IHN0cm0ubmV4dF9pbjsKICAgICAgICBpbnB1dCA9IHN0cm0uaW5wdXQ7CiAgICAgICAgc3RybS5hdmFpbF9pbiA9IGRpY3RMZW5ndGg7CiAgICAgICAgc3RybS5uZXh0X2luID0gMDsKICAgICAgICBzdHJtLmlucHV0ID0gZGljdGlvbmFyeTsKICAgICAgICBmaWxsX3dpbmRvdyhzKTsKICAgICAgICB3aGlsZSAocy5sb29rYWhlYWQgPj0gTUlOX01BVENIKSB7CiAgICAgICAgICBzdHIgPSBzLnN0cnN0YXJ0OwogICAgICAgICAgbiA9IHMubG9va2FoZWFkIC0gKE1JTl9NQVRDSCAtIDEpOwogICAgICAgICAgZG8gewogICAgICAgICAgICBzLmluc19oID0gKHMuaW5zX2ggPDwgcy5oYXNoX3NoaWZ0IF4gcy53aW5kb3dbc3RyICsgTUlOX01BVENIIC0gMV0pICYgcy5oYXNoX21hc2s7CiAgICAgICAgICAgIHMucHJldltzdHIgJiBzLndfbWFza10gPSBzLmhlYWRbcy5pbnNfaF07CiAgICAgICAgICAgIHMuaGVhZFtzLmluc19oXSA9IHN0cjsKICAgICAgICAgICAgc3RyKys7CiAgICAgICAgICB9IHdoaWxlICgtLW4pOwogICAgICAgICAgcy5zdHJzdGFydCA9IHN0cjsKICAgICAgICAgIHMubG9va2FoZWFkID0gTUlOX01BVENIIC0gMTsKICAgICAgICAgIGZpbGxfd2luZG93KHMpOwogICAgICAgIH0KICAgICAgICBzLnN0cnN0YXJ0ICs9IHMubG9va2FoZWFkOwogICAgICAgIHMuYmxvY2tfc3RhcnQgPSBzLnN0cnN0YXJ0OwogICAgICAgIHMuaW5zZXJ0ID0gcy5sb29rYWhlYWQ7CiAgICAgICAgcy5sb29rYWhlYWQgPSAwOwogICAgICAgIHMubWF0Y2hfbGVuZ3RoID0gcy5wcmV2X2xlbmd0aCA9IE1JTl9NQVRDSCAtIDE7CiAgICAgICAgcy5tYXRjaF9hdmFpbGF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A2NDUxMikgPT09IDU1Mjk2ICYmIG1fcG9zICsgMSA8IHN0cl9sZW4pIHsKICAgICAgICAgICAgYzIgPSBzdHIuY2hhckNvZGVBdChtX3BvcyArIDEpOwogICAgICAgICAgICBpZiAoKGMyICYgNjQ1MTIpID09PSA1NjMyMCkgewogICAgICAgICAgICAgIGMgPSA2NTUzNiArIChjIC0gNTUyOTYgPDwgMTApICsgKGMyIC0gNTYzMjApOwogICAgICAgICAgICAgIG1fcG9zKys7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJ1Zl9sZW4gKz0gYyA8IDEyOCA/IDEgOiBjIDwgMjA0OCA/IDIgOiBjIDwgNjU1MzYgPyAzIDogNDsKICAgICAgICB9CiAgICAgICAgYnVmID0gbmV3IHV0aWxzLkJ1ZjgoYnVmX2xlbik7CiAgICAgICAgZm9yIChpID0gMCwgbV9wb3MgPSAwOyBpIDwgYnVmX2xlbjsgbV9wb3MrKykgewogICAgICAgICAgYyA9IHN0ci5jaGFyQ29kZUF0KG1fcG9zKTsKICAgICAgICAgIGlmICgoYyAmIDY0NTEyKSA9PT0gNTUyOTYgJiYgbV9wb3MgKyAxIDwgc3RyX2xlbikgewogICAgICAgICAgICBjMiA9IHN0ci5jaGFyQ29kZUF0KG1fcG9zICsgMSk7CiAgICAgICAgICAgIGlmICgoYzIgJiA2NDUxMikgPT09IDU2MzIwKSB7CiAgICAgICAgICAgICAgYyA9IDY1NTM2ICsgKGMgLSA1NTI5NiA8PCAxMCkgKyAoYzIgLSA1NjMyMCk7CiAgICAgICAgICAgICAgbV9wb3MrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKGMgPCAxMjgpIHsKICAgICAgICAgICAgYnVmW2krK10gPSBjOwogICAgICAgICAgfSBlbHNlIGlmIChjIDwgMjA0OCkgewogICAgICAgICAgICBidWZbaSsrXSA9IDE5MiB8IGMgPj4+IDY7CiAgICAgICAgICAgIGJ1ZltpKytdID0gMTI4IHwgYyAmIDYzOwogICAgICAgICAgfSBlbHNlIGlmIChjIDwgNjU1MzYpIHsKICAgICAgICAgICAgYnVmW2krK10gPSAyMjQgfCBjID4+PiAxMjsKICAgICAgICAgICAgYnVmW2krK10gPSAxMjggfCBjID4+PiA2ICYgNjM7CiAgICAgICAgICAgIGJ1ZltpKytdID0gMTI4IHwgYyAmIDYzOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgYnVmW2krK10gPSAyNDAgfCBjID4+PiAxODsKICAgICAgICAgICAgYnVmW2krK10gPSAxMjggfCBjID4+PiAxMiAmIDYzOwogICAgICAgICAgICBidWZbaSsrXSA9IDEyOCB8IGMgPj4+IDYgJiA2MzsKICAgICAgICAgICAgYnVmW2krK10gPSAxMjggfCBjICYgNjM7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiBidWY7CiAgICAgIH07CiAgICAgIGZ1bmN0aW9uIGJ1ZjJiaW5zdHJpbmcoYnVmLCBsZW4pIHsKICAgICAgICBpZiAobGVuIDwgNjU1MzQpIHsKICAgICAgICAgIGlmIChidWYuc3ViYXJyYXkgJiYgU1RSX0FQUExZX1VJQV9PSyB8fCAhYnVmLnN1YmFycmF5ICYmIFNUUl9BUFBMWV9PSykgewogICAgICAgICAgICByZXR1cm4gU3RyaW5nLmZyb21DaGFyQ29kZS5hcHBseShudWxsLCB1dGlscy5zaHJpbmtCdWYoYnVmLCBsZW4pKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgdmFyIHJlc3VsdCA9ICIiOwogICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgbGVuOyBpKyspIHsKICAgICAgICAgIHJlc3VsdCArPSBTdHJpbmcuZnJvbUNoYXJDb2RlKGJ1ZltpXSk7CiAgICAgICAgfQogICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgIH0KICAgICAgZXhwb3J0czIuYnVmMmJpbnN0cmluZyA9IGZ1bmN0aW9uKGJ1ZikgewogICAgICAgIHJldHVybiBidWYyYmluc3RyaW5nKGJ1ZiwgYnVmLmxlbmd0aCk7CiAgICAgIH07CiAgICAgIGV4cG9ydHMyLmJpbnN0cmluZzJidWYgPSBmdW5jdGlvbihzdHIpIHsKICAgICAgICB2YXIgYnVmID0gbmV3IHV0aWxzLkJ1Zjgoc3RyLmxlbmd0aCk7CiAgICAgICAgZm9yICh2YXIgaSA9IDAsIGxlbiA9IGJ1Zi5sZW5ndGg7IGkgPCBsZW47IGkrKykgewogICAgICAgICAgYnVmW2ldID0gc3RyLmNoYXJDb2RlQXQoaSk7CiAgICAgICAgfQogICAgICAgIHJldHVybiBidWY7CiAgICAgIH07CiAgICAgIGV4cG9ydHMyLmJ1ZjJzdHJpbmcgPSBmdW5jdGlvbihidWYsIG1heCkgewogICAgICAgIHZhciBpLCBvdXQsIGMsIGNfbGVuOwogICAgICAgIHZhciBsZW4gPSBtYXggfHwgYnVmLmxlbmd0aDsKICAgICAgICB2YXIgdXRmMTZidWYgPSBuZXcgQXJyYXkobGVuICogMik7CiAgICAgICAgZm9yIChvdXQgPSAwLCBpID0gMDsgaSA8IGxlbjsgKSB7CiAgICAgICAgICBjID0gYnVmW2krK107CiAgICAgICAgICBpZiAoYyA8IDEyOCkgewogICAgICAgICAgICB1dGYxNmJ1ZltvdXQrK10gPSBjOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGNfbGVuID0gX3V0ZjhsZW5bY107CiAgICAgICAgICBpZiAoY19sZW4gPiA0KSB7CiAgICAgICAgICAgIHV0ZjE2YnVmW291dCsrXSA9IDY1NTMzOwogICAgICAgICAgICBpICs9IGNfbGVuIC0gMTsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBjICY9IGNfbGVuID09PSAyID8gMzEgOiBjX2xlbiA9PT0gMyA/IDE1IDogNzsKICAgICAgICAgIHdoaWxlIChjX2xlbiA+IDEgJiYgaSA8IGxlbikgewogICAgICAgICAgICBjID0gYyA8PCA2IHwgYnVmW2krK10gJiA2MzsKICAgICAgICAgICAgY19sZW4tLTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChjX2xlbiA+IDEpIHsKICAgICAgICAgICAgdXRmMTZidWZbb3V0KytdID0gNjU1MzM7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGMgPCA2NTUzNikgewogICAgICAgICAgICB1dGYxNmJ1ZltvdXQrK10gPSBjOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgYyAtPSA2NTUzNjsKICAgICAgICAgICAgdXRmMTZidWZbb3V0KytdID0gNTUyOTYgfCBjID4+IDEwICYgMTAyMzsKICAgICAgICAgICAgdXRmMTZidWZbb3V0KytdID0gNTYzMjAgfCBjICYgMTAyMzsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJ1ZjJiaW5zdHJpbmcodXRmMTZidWYsIG91dCk7CiAgICAgIH07CiAgICAgIGV4cG9ydHMyLnV0Zjhib3JkZXIgPSBmdW5jdGlvbihidWYsIG1heCkgewogICAgICAgIHZhciBwb3M7CiAgICAgICAgbWF4ID0gbWF4IHx8IGJ1Zi5sZW5ndGg7CiAgICAgICAgaWYgKG1heCA+IGJ1Zi5sZW5ndGgpIHsKICAgICAgICAgIG1heCA9IGJ1Zi5sZW5ndGg7CiAgICAgICAgfQogICAgICAgIHBvcyA9IG1heCAtIDE7CiAgICAgICAgd2hpbGUgKHBvcyA+PSAwICYmIChidWZbcG9zXSAmIDE5MikgPT09IDEyOCkgewogICAgICAgICAgcG9zLS07CiAgICAgICAgfQogICAgICAgIGlmIChwb3MgPCAwKSB7CiAgICAgICAgICByZXR1cm4gbWF4OwogICAgICAgIH0KICAgICAgICBpZiAocG9zID09PSAwKSB7CiAgICAgICAgICByZXR1cm4gbWF4OwogICAgICAgIH0KICAgICAgICByZXR1cm4gcG9zICsgX3V0ZjhsZW5bYnVmW3Bvc11dID4gbWF4ID8gcG9zIDogbWF4OwogICAgICB9OwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLnBucG0vcGFrb0AxLjAuMTEvbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvenN0cmVhbS5qcwogIHZhciByZXF1aXJlX3pzdHJlYW0gPSBfX2NvbW1vbkpTKHsKICAgICJub2RlX21vZHVsZXMvLnBucG0vcGFrb0AxLjAuMTEvbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvenN0cmVhbS5qcyIoZXhwb3J0czIsIG1vZHVsZTIpIHsKICAgICAgaW5pdF9idWZmZXJfc2hpbSgpOwogICAgICAidXNlIHN0cmljdCI7CiAgICAgIGZ1bmN0aW9uIFpTdHJlYW0oKSB7CiAgICAgICAgdGhpcy5pbnB1dCA9IG51bGw7CiAgICAgICAgdGhpcy5uZXh0X2luID0gMDsKICAgICAgICB0aGlzLmF2YWlsX2luID0gMDsKICAgICAgICB0aGlzLnRvdGFsX2luID0gMDsKICAgICAgICB0aGlzLm91dHB1dCA9IG51bGw7CiAgICAgICAgdGhpcy5uZXh0X291dCA9IDA7CiAgICAgICAgdGhpcy5hdmFpbF9vdXQgPSAwOwogICAgICAgIHRoaXMudG90YWxfb3V0ID0gMDsKICAgICAgICB0aGlzLm1zZyA9ICIiOwogICAgICAgIHRoaXMuc3RhdGUgPSBudWxsOwogICAgICAgIHRoaXMuZGF0YV90eXBlID0gMjsKICAgICAgICB0aGlzLmFkbGVyID0gMDsKICAgICAgfQogICAgICBtb2R1bGUyLmV4cG9ydHMgPSBaU3RyZWFtOwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLnBucG0vcGFrb0AxLjAuMTEvbm9kZV9tb2R1bGVzL3Bha28vbGliL2RlZmxhdGUuanMKICB2YXIgcmVxdWlyZV9kZWZsYXRlMiA9IF9fY29tbW9uSlMoewogICAgIm5vZGVfbW9kdWxlcy8ucG5wbS9wYWtvQDEuMC4xMS9ub2RlX21vZHVsZXMvcGFrby9saWIvZGVm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AgICAgICBzdHJhdGVneTogWl9ERUZBVUxUX1NUUkFURUdZLAogICAgICAgICAgdG86ICIiCiAgICAgICAgfSwgb3B0aW9ucyB8fCB7fSk7CiAgICAgICAgdmFyIG9wdCA9IHRoaXMub3B0aW9uczsKICAgICAgICBpZiAob3B0LnJhdyAmJiBvcHQud2luZG93Qml0cyA+IDApIHsKICAgICAgICAgIG9wdC53aW5kb3dCaXRzID0gLW9wdC53aW5kb3dCaXRzOwogICAgICAgIH0gZWxzZSBpZiAob3B0Lmd6aXAgJiYgb3B0LndpbmRvd0JpdHMgPiAwICYmIG9wdC53aW5kb3dCaXRzIDwgMTYpIHsKICAgICAgICAgIG9wdC53aW5kb3dCaXRzICs9IDE2OwogICAgICAgIH0KICAgICAgICB0aGlzLmVyciA9IDA7CiAgICAgICAgdGhpcy5tc2cgPSAiIjsKICAgICAgICB0aGlzLmVuZGVkID0gZmFsc2U7CiAgICAgICAgdGhpcy5jaHVua3MgPSBbXTsKICAgICAgICB0aGlzLnN0cm0gPSBuZXcgWlN0cmVhbSgpOwogICAgICAgIHRoaXMuc3RybS5hdmFpbF9vdXQgPSAwOwogICAgICAgIHZhciBzdGF0dXMgPSB6bGliX2RlZmxhdGUuZGVmbGF0ZUluaXQyKHRoaXMuc3RybSwgb3B0LmxldmVsLCBvcHQubWV0aG9kLCBvcHQud2luZG93Qml0cywgb3B0Lm1lbUxldmVsLCBvcHQuc3RyYXRlZ3kpOwogICAgICAgIGlmIChzdGF0dXMgIT09IFpfT0spIHsKICAgICAgICAgIHRocm93IG5ldyBFcnJvcihtc2dbc3RhdHVzXSk7CiAgICAgICAgfQogICAgICAgIGlmIChvcHQuaGVhZGVyKSB7CiAgICAgICAgICB6bGliX2RlZmxhdGUuZGVmbGF0ZVNldEhlYWRlcih0aGlzLnN0cm0sIG9wdC5oZWFkZXIpOwogICAgICAgIH0KICAgICAgICBpZiAob3B0LmRpY3Rpb25hcnkpIHsKICAgICAgICAgIHZhciBkaWN0OwogICAgICAgICA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sKICAgICAgICAgIHN0cm0uaW5wdXQgPSBzdHJpbmdzLnN0cmluZzJidWYoZGF0YSk7CiAgICAgICAgfSBlbHNlIGlmICh0b1N0cmluZy5jYWxsKGRhdGEpID09PSAiW29iamVjdCBBcnJheUJ1ZmZlcl0iKSB7CiAgICAgICAgICBzdHJtLmlucHV0ID0gbmV3IFVpbnQ4QXJyYXkoZGF0YSk7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHN0cm0uaW5wdXQgPSBkYXRhOwogICAgICAgIH0KICAgICAgICBzdHJtLm5leHRfaW4gPSAwOwogICAgICAgIHN0cm0uYXZhaWxfaW4gPSBzdHJtLmlucHV0Lmxlbmd0aDsKICAgICAgICBkbyB7CiAgICAgICAgICBpZiAoc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgc3RybS5vdXRwdXQgPSBuZXcgdXRpbHMuQnVmOChjaHVua1NpemUpOwogICAgICAgICAgICBzdHJtLm5leHRfb3V0ID0gMDsKICAgICAgICAgICAgc3RybS5hdmFpbF9vdXQgPSBjaHVua1NpemU7CiAgICAgICAgICB9CiAgICAgICAgICBzdGF0dXMgPSB6bGliX2RlZmxhdGUuZGVmbGF0ZShzdHJtLCBfbW9kZSk7CiAgICAgICAgICBpZiAoc3RhdHVzICE9PSBaX1NUUkVBTV9FTkQgJiYgc3RhdHVzICE9PSBaX09LKSB7CiAgICAgICAgICAgIHRoaXMub25FbmQoc3RhdHVzKTsKICAgICAgICAgICAgdGhpcy5lbmRlZCA9IHRydWU7CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChzdHJtLmF2YWlsX291dCA9PT0gMCB8fCBzdHJtLmF2YWlsX2luID09PSAwICYmIChfbW9kZSA9PT0gWl9GSU5JU0ggfHwgX21vZGUgPT09IFpfU1lOQ19GTFVTSDIpKSB7CiAgICAgICAgICAgIGlmICh0aGlzLm9wdGlvbnMudG8gPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgdGhpcy5vbkRhdGEoc3RyaW5ncy5idWYyYmluc3RyaW5nKHV0aWxzLnNocmlua0J1ZihzdHJtLm91dHB1dCwgc3RybS5uZXh0X291dCkpKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICB0aGlzLm9uRGF0YSh1dGlscy5zaHJpbmtCdWYoc3RybS5vdXRwdXQsIHN0cm0ubmV4dF9vdXQpKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gd2hpbGUgKChzdHJtLmF2YWlsX2luID4gMCB8fCBzdHJtLmF2YWlsX291dCA9PT0gMCkgJiYgc3RhdHVzICE9PSBaX1NUUkVBTV9FTkQpOwogICAgICAgIGlmIChfbW9kZSA9PT0gWl9GSU5JU0gpIHsKICAgICAgICAgIHN0YXR1cyA9IHpsaWJfZGVmbGF0ZS5kZWZsYXRlRW5kKHRoaXMuc3RybSk7CiAgICAgICAgICB0aGlzLm9uRW5kKHN0YXR1cyk7CiAgICAgICAgICB0aGlzLmVuZGVkID0gdHJ1ZTsKICAgICAgICAgIHJldHVybiBzdGF0dXMgPT09IFpfT0s7CiAgICAgICAgfQogICAgICAgIGlmIChfbW9kZSA9PT0gWl9TWU5DX0ZMVVNIMikgewogICAgICAgICAgdGhpcy5vbkVuZChaX09LKTsKICAgICAgICAgIHN0cm0uYXZhaWxfb3V0ID0gMDsKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfTsKICAgICAgRGVmbGF0ZS5wcm90b3R5cGUub25EYXRhID0gZnVuY3Rpb24oY2h1bmspIHsKICAgICAgICB0aGlzLmNodW5rcy5wdXNoKGNodW5rKTsKICAgICAgfTsKICAgICAgRGVmbGF0ZS5wcm90b3R5cGUub25FbmQgPSBmdW5jdGlvbihzdGF0dXMpIHsKICAgICAgICBpZiAoc3RhdHVzID09PSBaX09LKSB7CiAgICAgICAgICBpZiAodGhpcy5vcHR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hdGUgPSBEZWZsYXRlOwogICAgICBleHBvcnRzMi5kZWZsYXRlID0gZGVmbGF0ZTsKICAgICAgZXhwb3J0czIuZGVmbGF0ZVJhdyA9IGRlZmxhdGVSYXc7CiAgICAgIGV4cG9ydHMyLmd6aXAgPSBnemlwOwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLnBucG0vcGFrb0AxLjAuMTEvbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvaW5mZmFzdC5qcwogIHZhciByZXF1aXJlX2luZmZhc3QgPSBfX2NvbW1vbkpTKHsKICAgICJub2RlX21vZHVsZXMvLnBucG0vcGFrb0AxLjAuMTEvbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvaW5mZmFzdC5qcyIoZXhwb3J0czIsIG1vZHVsZTIpIHsKICAgICAgaW5pdF9idWZmZXJfc2hpbSgpOwogICAgICAidXNlIHN0cmljdCI7CiAgICAgIHZhciBCQUQgPSAzMDsKICAgICAgdmFyIFRZUEUgPSAxMjsKICAgICAgbW9kdWxlMi5leHBvcnRzID0gZnVuY3Rpb24gaW5mbGF0ZV9mYXN0KHN0cm0sIHN0YXJ0KSB7CiAgICAgICAgdmFyIHN0YXRlOwogICAgICAgIHZhciBfaW47CiAgICAgICAgdmFyIGxhc3Q7CiAgICAgICAgdmFyIF9vdXQ7CiAgICAgICAgdmFyIGJlZzsKICAgICAgICB2YXIgZW5kOwogICAgICAgIHZhciBkbWF4OwogICAgICAgIHZhciB3c2l6ZTsKICAgICAgICB2YXIgd2hhdmU7CiAgICAgICAgdmFyIHduZXh0OwogICAgICAgIHZhciBzX3dpbmRvdzsKICAgICAgICB2YXIgaG9sZDsKICAgICAgICB2YXIgYml0czsKICAgICAgICB2YXIgbGNvZGU7CiAgICAgICAgdmFyIGRjb2RlOwogICAgICAgIHZhciBsbWFzazsKICAgICAgICB2YXIgZG1hc2s7CiAgICAgICAgdmFyIGhlcmU7CiAgICAgICAgdmFyIG9wOwogICAgICAgIHZhciBsZW47CiAgICAgICAgdmFyIGRpc3Q7CiAgICAgICAgdmFyIGZyb207CiAgICAgICAgdmFyIGZyb21fc291cmNlOwogICAgICAgIHZhciBpbnB1dCwgb3V0cHV0OwogICAgICAgIHN0YXRlID0gc3RybS5zdGF0ZTsKICAgICAgICBfaW4gPSBzdHJtLm5leHRfaW47CiAgICAgICAgaW5wdXQgPSBzdHJtLmlucHV0OwogICAgICAgIGxhc3QgPSBfaW4gKyAoc3RybS5hdmFpbF9pbiAtIDUpOwogICAgICAgIF9vdXQgPSBzdHJtLm5leHRfb3V0OwogICAgICAgIG91dHB1dCA9IHN0cm0ub3V0cHV0OwogICAgICAgIGJlZyA9IF9vdXQgLSAoc3RhcnQgLSBzdHJtLmF2YWlsX291dCk7CiAgICAgICAgZW5kID0gX291dCArIChzdHJtLmF2YWlsX291dCAtIDI1Nyk7CiAgICAgICAgZG1heCA9IHN0YXRlLmRtYXg7CiAgICAgICAgd3NpemUgPSBzdGF0ZS53c2l6ZTsKICAgICAgICB3aGF2ZSA9IHN0YXRlLndoYXZlOwogICAgICAgIHduZXh0ID0gc3RhdGUud25leHQ7CiAgICAgICAgc193aW5kb3cgPSBzdGF0ZS53aW5kb3c7CiAgICAgICAgaG9sZCA9IHN0YXRlLmhvbGQ7CiAgICAgICAgYml0cyA9IHN0YXRlLmJpdHM7CiAgICAgICAgbGNvZGUgPSBzdGF0ZS5sZW5jb2RlOwogICAgICAgIGRjb2RlID0gc3RhdGUuZGlzdGNvZGU7CiAgICAgICAgbG1hc2sgPSAoMSA8PCBzdGF0ZS5sZW5iaXRzKSAtIDE7CiAgICAgICAgZG1hc2sgPSAoMSA8PCBzdGF0ZS5kaXN0Yml0cykgLSAxOwogICAgICAgIHRvcDoKICAgICAgICAgIGRvIHsKICAgICAgICAgICAgaWYgKGJpdHMgPCAxNSkgewogICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbX2luKytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbX2luKytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGhlcmUgPSBsY29kZVtob2xkICYgbG1hc2tdOwogICAgICAgICAgICBkb2xlbjoKICAgICAgICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgICAgICAgIG9wID0gaGVyZSA+Pj4gMjQ7CiAgICAgICAgICAgICAgICBob2xkID4+Pj0gb3A7CiAgICAgICAgICAgICAgICBiaXRzIC09IG9wOwogICAgICAgICAgICAgICAgb3AgPSBoZXJlID4+PiAxNiAmIDI1NTsKICAgICAgICAgICAgICAgIGlmIChvcCA9PT0gMCkgewogICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IGhlcmUgJiA2NTUzNTsKICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAob3AgJiAxNikgewogICAgICAgICAgICAgICAgICBsZW4gPSBoZXJlICYgNjU1MzU7CiAgICAgICAgICAgICAgICAgIG9wICY9IDE1OwogICAgICAgICAgICAgICAgICBpZiAob3ApIHsKICAgICAgICAgICAgICAgICAgICBpZiAoYml0cyA8IG9wKSB7CiAgICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W19pbisrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsZW4gKz0gaG9sZCAmICgxIDw8IG9wKSAtIDE7CiAgICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IG9wOwogICAgICAgICAgICAgICAgICAgIGJpdHMgLT0gb3A7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaWYgKGJpdHMgPCAxNSkgewogICAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbX2luKytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbX2luKytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGhlcmUgPSBkY29kZVtob2xkICYgZG1hc2tdOwogICAgICAgICAgICAgICAgICBkb2Rpc3Q6CiAgICAgICAgICAgICAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICAgICAgICAgICAgICBvcCA9IGhlcmUgPj4+IDI0OwogICAgICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IG9wOwogICAgICAgICAgICAgICAgICAgICAgYml0cyAtPSBvcDsKICAgICAgICAgICAgICAgICAgICAgIG9wID0gaGVyZSA+Pj4gMTYgJiAyNTU7CiAgICAgICAgICAgICAgICAgICAgICBpZiAob3AgJiAxNikgewogICAgICAgICAgICAgICAgICAgICAgICBkaXN0ID0gaGVyZSAmIDY1NTM1OwogICAgICAgICAgICAgICAgICAgICAgICBvcCAmPSAxNTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJpdHMgPCBvcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbX2luKytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiaXRzIDwgb3ApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbX2luKytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3QgKz0gaG9sZCAmICgxIDw8IG9wKSAtIDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkaXN0ID4gZG1heCkgewogICAgICAgICAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgZGlzdGFuY2UgdG9vIGZhciBiYWNrIjsKICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrIHRvcDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBob2xkID4+Pj0gb3A7CiAgICAgICAgICAgICAgICAgICAgICAgIGJpdHMgLT0gb3A7CiAgICAgICAgICAgICAgICAgICAgICAgIG9wID0gX291dCAtIGJlZzsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRpc3QgPiBvcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgIG9wID0gZGlzdCAtIG9wOwogICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcCA+IHdoYXZlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGUuc2FuZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGRpc3RhbmNlIHRvbyBmYXIgYmFjayI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrIHRvcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbV9zb3VyY2UgPSBzX3dpbmRvdzsKICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAod25leHQgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyb20gKz0gd3NpemUgLSBvcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcCA8IGxlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW4gLT0gb3A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IHNfd2luZG93W2Zyb20rK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKC0tb3ApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tID0gX291dCAtIGRpc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyb21fc291cmNlID0gb3V0cHV0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAod25leHQgPCBvcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbSArPSB3c2l6ZSArIHduZXh0IC0gb3A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcCAtPSB3bmV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcCA8IGxlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW4gLT0gb3A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IHNfd2luZG93W2Zyb20rK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKC0tb3ApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHduZXh0IDwgbGVuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3AgPSB3bmV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW4gLT0gb3A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBzX3dpbmRvd1tmcm9tKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKC0tb3ApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyb20gPSBfb3V0IC0gZGlzdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tX3NvdXJjZSA9IG91dHB1dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tICs9IHduZXh0IC0gb3A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3AgPCBsZW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuIC09IG9wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBzX3dpbmRvd1tmcm9tKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IHdoaWxlICgtLW9wKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbSA9IF9vdXQgLSBkaXN0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tX3NvdXJjZSA9IG91dHB1dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGxlbiA+IDIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gZnJvbV9zb3VyY2VbZnJvbSsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gZnJvbV9zb3VyY2VbZnJvbSsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gZnJvbV9zb3VyY2VbZnJvbSsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlbiAtPSAzOwogICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobGVuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IGZyb21fc291cmNlW2Zyb20rK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobGVuID4gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IGZyb21fc291cmNlW2Zyb20rK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgIGZyb20gPSBfb3V0IC0gZGlzdDsKICAgICAgICAgICAgICAgICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IG91dHB1dFtmcm9tKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBvdXRwdXRbZnJvbSsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gb3V0cHV0W2Zyb20rK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW4gLT0gMzsKICAgICAgICAgICAgICAgICAgICAgICAgICB9IHdoaWxlIChsZW4gPiAyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobGVuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IG91dHB1dFtmcm9tKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxlbiA+IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBvdXRwdXRbZnJvbSsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoKG9wICYgNjQpID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGhlcmUgPSBkY29kZVsoaGVyZSAmIDY1NTM1KSArIChob2xkICYgKDEgPDwgb3ApIC0gMSldOwogICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZSBkb2Rpc3Q7CiAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGRpc3RhbmNlIGNvZGUiOwogICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICAgICAgICBicmVhayB0b3A7CiAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKChvcCAmIDY0KSA9PT0gMCkgewogICAgICAgICAgICAgICAgICBoZXJlID0gbGNvZGVbKGhlcmUgJiA2NTUzNSkgKyAoaG9sZCAmICgxIDw8IG9wKSAtIDEpXTsKICAgICAgICAgICAgICAgICAgY29udGludWUgZG9sZW47CiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG9wICYgMzIpIHsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IFRZUEU7CiAgICAgICAgICAgICAgICAgIGJyZWFrIHRvcDsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgbGl0ZXJhbC9sZW5ndGggY29kZSI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrIHRvcDsKICAgICAgICAgICAgICAgIH0K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mFyIEVOT1VHSF9ESVNUUyA9IDU5MjsKICAgICAgdmFyIENPREVTID0gMDsKICAgICAgdmFyIExFTlMgPSAxOwogICAgICB2YXIgRElTVFMgPSAyOwogICAgICB2YXIgbGJhc2UgPSBbCiAgICAgICAgMywKICAgICAgICA0LAogICAgICAgIDUsCiAgICAgICAgNiwKICAgICAgICA3LAogICAgICAgIDgsCiAgICAgICAgOSwKICAgICAgICAxMCwKICAgICAgICAxMSwKICAgICAgICAxMywKICAgICAgICAxNSwKICAgICAgICAxNywKICAgICAgICAxOSwKICAgICAgICAyMywKICAgICAgICAyNywKICAgICAgICAzMSwKICAgICAgICAzNSwKICAgICAgICA0MywKICAgICAgICA1MSwKICAgICAgICA1OSwKICAgICAgICA2NywKICAgICAgICA4MywKICAgICAgICA5OSwKICAgICAgICAxMTUsCiAgICAgICAgMTMxLAogICAgICAgIDE2MywKICAgICAgICAxOTUsCiAgICAgICAgMjI3LAogICAgICAgIDI1OCwKICAgICAgICAwLAogICAgICAgIDAKICAgICAgXTsKICAgICAgdmFyIGxleHQgPSBbCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTcsCiAgICAgICAgMTcsCiAgICAgICAgMTcsCiAgICAgICAgMTcsCiAgICAgICAgMTgsCiAgICAgICAgMTgsCiAgICAgICAgMTgsCiAgICAgICAgMTgsCiAgICAgICAgMTksCiAgICAgICAgMTksCiAgICAgICAgMTksCiAgICAgICAgMTksCiAgICAgICAgMjAsCiAgICAgICAgMjAsCiAgICAgICAgMjAsCiAgICAgICAgMjAsCiAgICAgICAgMjEsCiAgICAgICAgMjEsCiAgICAgICAgMjEsCiAgICAgICAgMjEsCiAgICAgICAgMTYsCiAgICAgICAgNzIsCiAgICAgICAgNzgKICAgICAgXTsKICAgICAgdmFyIGRiYXNlID0gWwogICAgICAgIDEsCiAgICAgICAgMiwKICAgICAgICAzLAogICAgICAgIDQsCiAgICAgICAgNSwKICAgICAgICA3LAogICAgICAgIDksCiAgICAgICAgMTMsCiAgICAgICAgMTcsCiAgICAgICAgMjUsCiAgICAgICAgMzMsCiAgICAgICAgNDksCiAgICAgICAgNjUsCiAgICAgICAgOTcsCiAgICAgICAgMTI5LAogICAgICAgIDE5MywKICAgICAgICAyNTcsCiAgICAgICAgMzg1LAogICAgICAgIDUxMywKICAgICAgICA3NjksCiAgICAgICAgMTAyNSwKICAgICAgICAxNTM3LAogICAgICAgIDIwNDksCiAgICAgICAgMzA3MywKICAgICAgICA0MDk3LAogICAgICAgIDYxNDUsCiAgICAgICAgODE5MywKICAgICAgICAxMjI4OSwKICAgICAgICAxNjM4NSwKICAgICAgICAyNDU3NywKICAgICAgICAwLAogICAgICAgIDAKICAgICAgXTsKICAgICAgdmFyIGRleHQgPSBbCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTYsCiAgICAgICAgMTcsCiAgICAgICAgMTcsCiAgICAgICAgMTgsCiAgICAgICAgMTgsCiAgICAgICAgMTksCiAgICAgICAgMTksCiAgICAgICAgMjAsCiAgICAgICAgMjAsCiAgICAgICAgMjEsCiAgICAgICAgMjEsCiAgICAgICAgMjIsCiAgICAgICAgMjIsCiAgICAgICAgMjMsCiAgICAgICAgMjMsCiAgICAgICAgMjQsCiAgICAgICAgMjQsCiAgICAgICAgMjUsCiAgICAgICAgMjUsCiAgICAgICAgMjYsCiAgICAgICAgMjYsCiAgICAgICAgMjcsCiAgICAgICAgMjcsCiAgICAgICAgMjgsCiAgICAgICAgMjgsCiAgICAgICAgMjksCiAgICAgICAgMjksCiAgICAgICAgNjQsCiAgICAgICAgNjQKICAgICAgXTsKICAgICAgbW9kdWxlMi5leHBvcnRzID0gZnVuY3Rpb24gaW5mbGF0ZV90YWJsZSh0eXBlLCBsZW5zLCBsZW5zX2luZGV4LCBjb2RlcywgdGFibGUsIHRhYmxlX2luZGV4LCB3b3JrLCBvcHRzKSB7CiAgICAgICAgdmFyIGJpdHMgPSBvcHRzLmJpdHM7CiAgICAgICAgdmFyIGxlbiA9IDA7CiAgICAgICAgdmFyIHN5bSA9IDA7CiAgICAgICAgdmFyIG1pbiA9IDAsIG1heCA9IDA7CiAgICAgICAgdmFyIHJvb3QyID0gMDsKICAgICAgICB2YXIgY3VyciA9IDA7CiAgICAgICAgdmFyIGRyb3AgPSAwOwogICAgICAgIHZhciBsZWZ0ID0gMDsKICAgICAgICB2YXIgdXNlZCA9IDA7CiAgICAgICAgdmFyIGh1ZmYgPSAwOwogICAgICAgIHZhciBpbmNyOwogICAgICAgIHZhciBmaWxsOwogICAgICAgIHZhciBsb3c7CiAgICAgICAgdmFyIG1hc2s7CiAgICAgICAgdmFyIG5leHQ7CiAgICAgICAgdmFyIGJhc2UgPSBudWxsOwogICAgICAgIHZhciBiYXNlX2luZGV4ID0gMDsKICAgICAgICB2YXIgZW5kOwogICAgICAgIHZhciBjb3VudCA9IG5ldyB1dGlscy5CdWYxNihNQVhCSVRTICsgMSk7CiAgICAgICAgdmFyIG9mZnMgPSBuZXcgdXRpbHMuQnVmMTYoTUFYQklUUyArIDEpOwogICAgICAgIHZhciBleHRyYSA9IG51bGw7CiAgICAgICAgdmFyIGV4dHJhX2luZGV4ID0gMDsKICAgICAgICB2YXIgaGVyZV9iaXRzLCBoZXJlX29wLCBoZXJlX3ZhbDsKICAgICAgICBmb3IgKGxlbiA9IDA7IGxlbiA8PSBNQVhCSVRTOyBsZW4rKykgewogICAgICAgICAgY291bnRbbGVuXSA9IDA7CiAgICAgICAgfQogICAgICAgIGZvciAoc3ltID0gMDsgc3ltIDwgY29kZXM7IHN5bSsrKSB7CiAgICAgICAgICBjb3VudFtsZW5zW2xlbnNfaW5kZXggKyBzeW1dXSsrOwogICAgICAgIH0KICAgICAgICByb290MiA9IGJpdHM7CiAgICAgICAgZm9yIChtYXggPSBNQVhCSVRTOyBtYXggPj0gMTsgbWF4LS0pIHsKICAgICAgICAgIGlmIChjb3VudFttYXhdICE9PSAwKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAocm9vdDIgPiBtYXgpIHsKICAgICAgICAgIHJvb3QyID0gbWF4OwogICAgICAgIH0KICAgICAgICBpZiAobWF4ID09PSAwKSB7CiAgICAgICAgICB0YWJsZVt0YWJsZV9pbmRleCsrXSA9IDEgPDwgMjQgfCA2NCA8PCAxNiB8IDA7CiAgICAgICAgICB0YWJsZVt0YWJsZV9pbmRleCsrXSA9IDEgPDwgMjQgfCA2NCA8PCAxNiB8IDA7CiAgICAgICAgICBvcHRzLmJpdHMgPSAxOwogICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgfQogICAgICAgIGZvciAobWluID0gMTsgbWluIDwgbWF4OyBtaW4rKykgewogICAgICAgICAgaWYgKGNvdW50W21pbl0gIT09IDApIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChyb290MiA8IG1pbikgewogICAgICAgICAgcm9vdDIgPSBtaW47CiAgICAgICAgfQogICAgICAgIGxlZnQgPSAxOwogICAgICAgIGZvciAobGVuID0gMTsgbGVuIDw9IE1BWEJJVFM7IGxlbisrKSB7CiAgICAgICAgICBsZWZ0IDw8PSAxOwogICAgICAgICAgbGVmdCAtPSBjb3VudFtsZW5dOwogICAgICAgICAgaWYgKGxlZnQgPCAwKSB7CiAgICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKGxlZnQgPiAwICYmICh0eXBlID09PSBDT0RFUyB8fCBtYXggIT09IDEpKSB7CiAgICAgICAgICByZXR1cm4gLTE7CiAgICAgICAgfQogICAgICAgIG9mZnNbMV0gPSAwOwogICAgICAgIGZvciAobGVuID0gMTsgbGVuIDwgTUFYQklUUzsgbGVuKyspIHsKICAgICAgICAgIG9mZnNbbGVuICsgMV0gPSBvZmZzW2xlbl0gKyBjb3VudFtsZW5dOwogICAgICAgIH0KICAgICAgICBmb3IgKHN5bSA9IDA7IHN5bSA8IGNvZGVzOyBzeW0rKykgewogICAgICAgICAgaWYgKGxlbnNbbGVuc19pbmRleCArIHN5bV0gIT09IDApIHsKICAgICAgICAgICAgd29ya1tvZmZzW2xlbnNbbGVuc19pbmRleCArIHN5bV1dKytdID0gc3ltOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAodHlwZSA9PT0gQ09ERVMpIHsKICAgICAgICAgIGJhc2UgPSBleHRyYSA9IHdvcms7CiAgICAgICAgICBlbmQgPSAxOTsKICAgICAgICB9IGVsc2UgaWYgKHR5cGUgPT09IExFTlMpIHsKICAgICAgICAgIGJhc2UgPSBsYmFzZTsKICAgICAgICAgIGJhc2VfaW5kZXggLT0gMjU3OwogICAgICAgICAgZXh0cmEgPSBsZXh0OwogICAgICAgICAgZXh0cmFfaW5kZXggLT0gMjU3OwogICAgICAgICAgZW5kID0gMjU2OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBiYXNlID0gZGJhc2U7CiAgICAgICAgICBleHRyYSA9IGRleHQ7CiAgICAgICAgICBlbmQgPSAtMTsKICAgICAgICB9CiAgICAgICAgaHVmZiA9IDA7CiAgICAgICAgc3ltID0gMDsKICAgICAgICBsZW4gPSBtaW47CiAgICAgICAgbmV4dCA9IHRhYmxlX2luZGV4OwogICAgICAgIGN1cnIgPSByb290MjsKICAgICAgICBkcm9wID0gMDsKICAgICAgICBsb3cgPSAtMTsKICAgICAgICB1c2VkID0gMSA8PCByb290MjsKICAgICAgICBtYXNrID0gdXNlZCAtIDE7CiAgICAgICAgaWYgKHR5cGUgPT09IExFTlMgJiYgdXNlZCA+IEVOT1VHSF9MRU5TIHx8IHR5cGUgPT09IERJU1RTICYmIHVzZWQgPiBFTk9VR0hfRElTVFMpIHsKICAgICAgICAgIHJldHVybiAxOwogICAgICAgIH0KICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgIGhlcmVfYml0cyA9IGxlbiAtIGRyb3A7CiAgICAgICAgICBpZiAod29ya1tzeW1dIDwgZW5kKSB7CiAgICAgICAgICAgIGhlcmVfb3AgPSAwOwogICAgICAgICAgICBoZXJlX3ZhbCA9IHdvcmtbc3ltXTsKICAgICAgICAgIH0gZWxzZSBpZiAod29ya1tzeW1dID4gZW5kKSB7CiAgICAgICAgICAgIGhlcmVfb3AgPSBleHRyYVtleHRyYV9pbmRleCArIHdvcmtbc3ltXV07CiAgICAgICAgICAgIGhlcmVfdmFsID0gYmFzZVtiYXNlX2luZGV4ICsgd29ya1tzeW1dXTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGhlcmVfb3AgPSAzMiArIDY0OwogICAgICAgICAgICBoZXJlX3ZhbCA9IDA7CiAgICAgICAgICB9CiAgICAgICAgICBpbmNyID0gMSA8PCBsZW4gLSBkcm9wOwogICAgICAgICAgZmlsbCA9IDEgPDwgY3VycjsKICAgICAgICAgIG1pbiA9IGZpbGw7CiAgICAgICAgICBkbyB7CiAgICAgICAgICAgIGZpbGwgLT0gaW5jcjsKICAgICAgICAgICAgdGFibGVbbmV4dCArIChodWZmID4+IGRyb3ApICsgZmlsbF0gPSBoZXJlX2JpdHMgPDwgMjQgfCBoZXJlX29wIDw8IDE2IHwgaGVyZV92YWwgfCAwOwogICAgICAgICAgfSB3aGlsZSAoZmlsbCAhPT0gMCk7CiAgICAgICAgICBpbmNyID0gMSA8PCBsZW4gLSAxOwogICAgICAgICAgd2hpbGUgKGh1ZmYgJiBpbmNyKSB7CiAgICAgICAgICAgIGluY3IgPj49IDE7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoaW5jciAhPT0gMCkgewogICAgICAgICAgICBodWZmICY9IGluY3IgLSAxOwogICAgICAgICAgICBodWZmICs9IGluY3I7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBodWZmID0gMDsKICAgICAgICAgIH0KICAgICAgICAgIHN5bSsrOwogICAgICAgICAgaWYgKC0tY291bnRbbGVuXSA9PT0gMCkgewogICAgICAgICAgICBpZiAobGVuID09PSBtYXgpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZW4gPSBsZW5zW2xlbnNfaW5kZXggKyB3b3JrW3N5bV1dOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGxlbiA+IHJvb3QyICYmIChodWZmICYgbWFzaykgIT09IGxvdykgewogICAgICAgICAgICBpZiAoZHJvcCA9PT0gMCkgewogICAgICAgICAgICAgIGRyb3AgPSByb290MjsKICAgICAgICAgICAgfQogICAgICAgICAgICBuZXh0ICs9IG1pbjsKICAgICAgICAgICAgY3VyciA9IGxlbiAtIGRyb3A7CiAgICAgICAgICAgIGxlZnQgPSAxIDw8IGN1cnI7CiAgICAgICAgICAgIHdoaWxlIChjdXJyICsgZHJvcCA8IG1heCkgewogICAgICAgICAgICAgIGxlZnQgLT0gY291bnRbY3VyciArIGRyb3BdOwogICAgICAgICAgICAgIGlmIChsZWZ0IDw9IDApIHsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjdXJyKys7CiAgICAgICAgICAgICAgbGVmdCA8PD0gMTsKICAgICAgICAgICAgfQogICAgICAgICAgICB1c2VkICs9IDEgPDwgY3VycjsKICAgICAgICAgICAgaWYgKHR5cGUgPT09IExFTlMgJiYgdXNlZCA+IEVOT1VHSF9MRU5TIHx8IHR5cGUgPT09IERJU1RTICYmIHVzZWQgPiBFTk9VR0hfRElTVFMpIHsKICAgICAgICAgICAgICByZXR1cm4gMTsKICAgICAgICAgICAgfQogICAgICAgICAgICBsb3cgPSBodWZmICYgbWFzazsKICAgICAgICAgICAgdGFibGVbbG93XSA9IHJvb3QyIDw8IDI0IHwgY3VyciA8PCAxNiB8IG5leHQgLSB0YWJsZV9pbmRleCB8IDA7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChodWZmIC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QVRBX0VSUk9SID0gLTM7CiAgICAgIHZhciBaX01FTV9FUlJPUiA9IC00OwogICAgICB2YXIgWl9CVUZfRVJST1IgPSAtNTsKICAgICAgdmFyIFpfREVGTEFURUQgPSA4OwogICAgICB2YXIgSEVBRCA9IDE7CiAgICAgIHZhciBGTEFHUyA9IDI7CiAgICAgIHZhciBUSU1FID0gMzsKICAgICAgdmFyIE9TID0gNDsKICAgICAgdmFyIEVYTEVOID0gNTsKICAgICAgdmFyIEVYVFJBID0gNjsKICAgICAgdmFyIE5BTUUgPSA3OwogICAgICB2YXIgQ09NTUVOVCA9IDg7CiAgICAgIHZhciBIQ1JDID0gOTsKICAgICAgdmFyIERJQ1RJRCA9IDEwOwogICAgICB2YXIgRElDVCA9IDExOwogICAgICB2YXIgVFlQRSA9IDEyOwogICAgICB2YXIgVFlQRURPID0gMTM7CiAgICAgIHZhciBTVE9SRUQgPSAxNDsKICAgICAgdmFyIENPUFlfID0gMTU7CiAgICAgIHZhciBDT1BZID0gMTY7CiAgICAgIHZhciBUQUJMRSA9IDE3OwogICAgICB2YXIgTEVOTEVOUyA9IDE4OwogICAgICB2YXIgQ09ERUxFTlMgPSAxOTsKICAgICAgdmFyIExFTl8gPSAyMDsKICAgICAgdmFyIExFTiA9IDIxOwogICAgICB2YXIgTEVORVhUID0gMjI7CiAgICAgIHZhciBESVNUID0gMjM7CiAgICAgIHZhciBESVNURVhUID0gMjQ7CiAgICAgIHZhciBNQVRDSCA9IDI1OwogICAgICB2YXIgTElUID0gMjY7CiAgICAgIHZhciBDSEVDSyA9IDI3OwogICAgICB2YXIgTEVOR1RIID0gMjg7CiAgICAgIHZhciBET05FID0gMjk7CiAgICAgIHZhciBCQUQgPSAzMDsKICAgICAgdmFyIE1FTSA9IDMxOwogICAgICB2YXIgU1lOQyA9IDMyOwogICAgICB2YXIgRU5PVUdIX0xFTlMgPSA4NTI7CiAgICAgIHZhciBFTk9VR0hfRElTVFMgPSA1OTI7CiAgICAgIHZhciBNQVhfV0JJVFMgPSAxNTsKICAgICAgdmFyIERFRl9XQklUUyA9IE1BWF9XQklUUzsKICAgICAgZnVuY3Rpb24genN3YXAzMihxKSB7CiAgICAgICAgcmV0dXJuIChxID4+PiAyNCAmIDI1NSkgKyAocSA+Pj4gOCAmIDY1MjgwKSArICgocSAmIDY1MjgwKSA8PCA4KSArICgocSAmIDI1NSkgPDwgMjQpOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIEluZmxhdGVTdGF0ZSgpIHsKICAgICAgICB0aGlzLm1vZGUgPSAwOwogICAgICAgIHRoaXMubGFzdCA9IGZhbHNlOwogICAgICAgIHRoaXMud3JhcCA9IDA7CiAgICAgICAgdGhpcy5oYXZlZGljdCA9IGZhbHNlOwogICAgICAgIHRoaXMuZmxhZ3MgPSAwOwogICAgICAgIHRoaXMuZG1heCA9IDA7CiAgICAgICAgdGhpcy5jaGVjayA9IDA7CiAgICAgICAgdGhpcy50b3RhbCA9IDA7CiAgICAgICAgdGhpcy5oZWFkID0gbnVsbDsKICAgICAgICB0aGlzLndiaXRzID0gMDsKICAgICAgICB0aGlzLndzaXplID0gMDsKICAgICAgICB0aGlzLndoYXZlID0gMDsKICAgICAgICB0aGlzLnduZXh0ID0gMDsKICAgICAgICB0aGlzLndpbmRvdyA9IG51bGw7CiAgICAgICAgdGhpcy5ob2xkID0gMDsKICAgICAgICB0aGlzLmJpdHMgPSAwOwogICAgICAgIHRoaXMubGVuZ3RoID0gMDsKICAgICAgICB0aGlzLm9mZnNldCA9IDA7CiAgICAgICAgdGhpcy5leHRyYSA9IDA7CiAgICAgICAgdGhpcy5sZW5jb2RlID0gbnVsbDsKICAgICAgICB0aGlzLmRpc3Rjb2RlID0gbnVsbDsKICAgICAgICB0aGlzLmxlbmJpdHMgPSAwOwogICAgICAgIHRoaXMuZGlzdGJpdHMgPSAwOwogICAgICAgIHRoaXMubmNvZGUgPSAwOwogICAgICAgIHRoaXMubmxlbiA9IDA7CiAgICAgICAgdGhpcy5uZGlzdCA9IDA7CiAgICAgICAgdGhpcy5oYXZlID0gMDsKICAgICAgICB0aGlzLm5leHQgPSBudWxsOwogICAgICAgIHRoaXMubGVucyA9IG5ldyB1dGlscy5CdWYxNigzMjApOwogICAgICAgIHRoaXMud29yayA9IG5ldyB1dGlscy5CdWYxNigyODgpOwogICAgICAgIHRoaXMubGVuZHluID0gbnVsbDsKICAgICAgICB0aGlzLmRpc3RkeW4gPSBudWxsOwogICAgICAgIHRoaXMuc2FuZSA9IDA7CiAgICAgICAgdGhpcy5iYWNrID0gMDsKICAgICAgICB0aGlzLndhcyA9IDA7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gaW5mbGF0ZVJlc2V0S2VlcChzdHJtKSB7CiAgICAgICAgdmFyIHN0YXRlOwogICAgICAgIGlmICghc3RybSB8fCAhc3RybS5zdGF0ZSkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgIH0KICAgICAgICBzdGF0ZSA9IHN0cm0uc3RhdGU7CiAgICAgICAgc3RybS50b3RhbF9pbiA9IHN0cm0udG90YWxfb3V0ID0gc3RhdGUudG90YWwgPSAwOwogICAgICAgIHN0cm0ubXNnID0gIiI7CiAgICAgICAgaWYgKHN0YXRlLndyYXApIHsKICAgICAgICAgIHN0cm0uYWRsZXIgPSBzdGF0ZS53cmFwICYgMTsKICAgICAgICB9CiAgICAgICAgc3RhdGUubW9kZSA9IEhFQUQ7CiAgICAgICAgc3RhdGUubGFzdCA9IDA7CiAgICAgICAgc3RhdGUuaGF2ZWRpY3QgPSAwOwogICAgICAgIHN0YXRlLmRtYXggPSAzMjc2ODsKICAgICAgICBzdGF0ZS5oZWFkID0gbnVsbDsKICAgICAgICBzdGF0ZS5ob2xkID0gMDsKICAgICAgICBzdGF0ZS5iaXRzID0gMDsKICAgICAgICBzdGF0ZS5sZW5jb2RlID0gc3RhdGUubGVuZHluID0gbmV3IHV0aWxzLkJ1ZjMyKEVOT1VHSF9MRU5TKTsKICAgICAgICBzdGF0ZS5kaXN0Y29kZSA9IHN0YXRlLmRpc3RkeW4gPSBuZXcgdXRpbHMuQnVmMzIoRU5PVUdIX0RJU1RTKTsKICAgICAgICBzdGF0ZS5zYW5lID0gMTsKICAgICAgICBzdGF0ZS5iYWNrID0gLTE7CiAgICAgICAgcmV0dXJuIFpfT0s7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gaW5mbGF0ZVJlc2V0KHN0cm0pIHsKICAgICAgICB2YXIgc3RhdGU7CiAgICAgICAgaWYgKCFzdHJtIHx8ICFzdHJtLnN0YXRlKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIHN0YXRlID0gc3RybS5zdGF0ZTsKICAgICAgICBzdGF0ZS53c2l6ZSA9IDA7CiAgICAgICAgc3RhdGUud2hhdmUgPSAwOwogICAgICAgIHN0YXRlLnduZXh0ID0gMDsKICAgICAgICByZXR1cm4gaW5mbGF0ZVJlc2V0S2VlcChzdHJtKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBpbmZsYXRlUmVzZXQyKHN0cm0sIHdpbmRvd0JpdHMpIHsKICAgICAgICB2YXIgd3JhcDsKICAgICAgICB2YXIgc3RhdGU7CiAgICAgICAgaWYgKCFzdHJtIHx8ICFzdHJtLnN0YXRlKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIHN0YXRlID0gc3RybS5zdGF0ZTsKICAgICAgICBpZiAod2luZG93Qml0cyA8IDApIHsKICAgICAgICAgIHdyYXAgPSAwOwogICAgICAgICAgd2luZG93Qml0cyA9IC13aW5kb3dCaXRzOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB3cmFwID0gKHdpbmRvd0JpdHMgPj4gNCkgKyAxOwogICAgICAgICAgaWYgKHdpbmRvd0JpdHMgPCA0OCkgewogICAgICAgICAgICB3aW5kb3dCaXRzICY9IDE1OwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAod2luZG93Qml0cyAmJiAod2luZG93Qml0cyA8IDggfHwgd2luZG93Qml0cyA+IDE1KSkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgIH0KICAgICAgICBpZiAoc3RhdGUud2luZG93ICE9PSBudWxsICYmIHN0YXRlLndiaXRzICE9PSB3aW5kb3dCaXRzKSB7CiAgICAgICAgICBzdGF0ZS53aW5kb3cgPSBudWxsOwogICAgICAgIH0KICAgICAgICBzdGF0ZS53cmFwID0gd3JhcDsKICAgICAgICBzdGF0ZS53Yml0cyA9IHdpbmRvd0JpdHM7CiAgICAgICAgcmV0dXJuIGluZmxhdGVSZXNldChzdHJtKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBpbmZsYXRlSW5pdDIoc3RybSwgd2luZG93Qml0cykgewogICAgICAgIHZhciByZXQ7CiAgICAgICAgdmFyIHN0YXRlOwogICAgICAgIGlmICghc3RybSkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgIH0KICAgICAgICBzdGF0ZSA9IG5ldyBJbmZsYXRlU3RhdGUoKTsKICAgICAgICBzdHJtLnN0YXRlID0gc3RhdGU7CiAgICAgICAgc3RhdGUud2luZG93ID0gbnVsbDsKICAgICAgICByZXQgPSBpbmZsYXRlUmVzZXQyKHN0cm0sIHdpbmRvd0JpdHMpOwogICAgICAgIGlmIChyZXQgIT09IFpfT0spIHsKICAgICAgICAgIHN0cm0uc3RhdGUgPSBudWxsOwogICAgICAgIH0KICAgICAgICByZXR1cm4gcmV0OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGluZmxhdGVJbml0KHN0cm0pIHsKICAgICAgICByZXR1cm4gaW5mbGF0ZUluaXQyKHN0cm0sIERFRl9XQklUUyk7CiAgICAgIH0KICAgICAgdmFyIHZpcmdpbiA9IHRydWU7CiAgICAgIHZhciBsZW5maXg7CiAgICAgIHZhciBkaXN0Zml4OwogICAgICBmdW5jdGlvbiBmaXhlZHRhYmxlcyhzdGF0ZSkgewogICAgICAgIGlmICh2aXJnaW4pIHsKICAgICAgICAgIHZhciBzeW07CiAgICAgICAgICBsZW5maXggPSBuZXcgdXRpbHMuQnVmMzIoNTEyKTsKICAgICAgICAgIGRpc3RmaXggPSBuZXcgdXRpbHMuQnVmMzIoMzIpOwogICAgICAgICAgc3ltID0gMDsKICAgICAgICAgIHdoaWxlIChzeW0gPCAxNDQpIHsKICAgICAgICAgICAgc3RhdGUubGVuc1tzeW0rK10gPSA4OwogICAgICAgICAgfQogICAgICAgICAgd2hpbGUgKHN5bSA8IDI1NikgewogICAgICAgICAgICBzdGF0ZS5sZW5zW3N5bSsrXSA9IDk7CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3ltIDwgMjgwKSB7CiAgICAgICAgICAgIHN0YXRlLmxlbnNbc3ltKytdID0gNzsKICAgICAgICAgIH0KICAgICAgICAgIHdoaWxlIChzeW0gPCAyODgpIHsKICAgICAgICAgICAgc3RhdGUubGVuc1tzeW0rK10gPSA4OwogICAgICAgICAgfQogICAgICAgICAgaW5mbGF0ZV90YWJsZShMRU5TLCBzdGF0ZS5sZW5zLCAwLCAyODgsIGxlbmZpeCwgMCwgc3RhdGUud29yaywgeyBiaXRzOiA5IH0pOwogICAgICAgICAgc3ltID0gMDsKICAgICAgICAgIHdoaWxlIChzeW0gPCAzMikgewogICAgICAgICAgICBzdGF0ZS5sZW5zW3N5bSsrXSA9IDU7CiAgICAgICAgICB9CiAgICAgICAgICBpbmZsYXRlX3RhYmxlKERJU1RTLCBzdGF0ZS5sZW5zLCAwLCAzMiwgZGlzdGZpeCwgMCwgc3RhdGUud29yaywgeyBiaXRzOiA1IH0pOwogICAgICAgICAgdmlyZ2luID0gZmFsc2U7CiAgICAgICAgfQogICAgICAgIHN0YXRlLmxlbmNvZGUgPSBsZW5maXg7CiAgICAgICAgc3RhdGUubGVuYml0cyA9IDk7CiAgICAgICAgc3RhdGUuZGlzdGNvZGUgPSBkaXN0Zml4OwogICAgICAgIHN0YXRlLmRpc3RiaXRzID0gNTsKICAgICAgfQogICAgICBmdW5jdGlvbiB1cGRhdGV3aW5kb3coc3RybSwgc3JjLCBlbmQsIGNvcHkpIHsKICAgICAgICB2YXIgZGlzdDsKICAgICAgICB2YXIgc3RhdGUgPSBzdHJtLnN0YXRlOwogICAgICAgIGlmIChzdGF0ZS53aW5kb3cgPT09IG51bGwpIHsKICAgICAgICAgIHN0YXRlLndzaXplID0gMSA8PCBzdGF0ZS53Yml0czsKICAgICAgICAgIHN0YXRlLnduZXh0ID0gMDsKICAgICAgICAgIHN0YXRlLndoYXZlID0gMDsKICAgICAgICAgIHN0YXRlLndpbmRvdyA9IG5ldyB1dGlscy5CdWY4KHN0YXRlLndzaXplKTsKICAgICAgICB9CiAgICAgICAgaWYgKGNvcHkgPj0gc3RhdGUud3NpemUpIHsKICAgICAgICAgIHV0aWxzLmFycmF5U2V0KHN0YXRlLndpbmRvdywgc3JjLCBlbmQgLSBzdGF0ZS53c2l6ZSwgc3RhdGUud3NpemUsIDApOwogICAgICAgICAgc3RhdGUud25leHQgPSAwOwogICAgICAgICAgc3RhdGUud2hhdmUgPSBzdGF0ZS53c2l6ZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGlzdCA9IHN0YXRlLndzaXplIC0gc3RhdGUud25leHQ7CiAgICAgICAgICBpZiAoZGlzdCA+IGNvcHkpIHsKICAgICAgICAgICAgZGlzdCA9IGNvcHk7CiAgICAgICAgICB9CiAgICAgICAgICB1dGlscy5hcnJheVNldChzdGF0ZS53aW5kb3csIHNyYywgZW5kIC0gY29weSwgZGlzdCwgc3RhdGUud25leHQpOwogICAgICAgICAgY29weSAtPSBkaXN0OwogICAgICAgICAgaWYgKGNvcHkpIHsKICAgICAgICAgICAgdXRpbHMuYXJyYXlTZXQoc3RhdGUud2luZG93LCBzcmMsIGVuZCAtIGNvcHksIGNvcHksIDApOwogICAgICAgICAgICBzdGF0ZS53bmV4dCA9IGNvcHk7CiAgICAgICAgICAgIHN0YXRlLndoYXZlID0gc3RhdGUud3NpemU7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzdGF0ZS53bmV4dCArPSBkaXN0OwogICAgICAgICAgICBpZiAoc3RhdGUud25leHQgPT09IHN0YXRlLndzaXplKSB7CiAgICAgICAgICAgICAgc3RhdGUud25leHQgPSAwOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzdGF0ZS53aGF2ZSA8IHN0YXRlLndzaXplKSB7CiAgICAgICAgICAgICAgc3RhdGUud2hhdmUgKz0gZGlzdDsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gMDsKICAgICAgfQogICAgICBmdW5jdGlvbiBpbmZsYXRlKHN0cm0sIGZsdXNoKSB7CiAgICAgICAgdmFyIHN0YXRlOwogICAgICAgIHZhciBpbnB1dCwgb3V0cHV0OwogICAgICAgIHZhciBuZXh0OwogICAgICAgIHZhciBwdXQ7CiAgICAgICAgdmFyIGhhdmUsIGxlZnQ7CiAgICAgICAgdmFyIGhvbGQ7CiAgICAgICAgdmFyIGJpdHM7CiAgICAgICAgdmFyIF9pbiwgX291dDsKICAgICAgICB2YXIgY29weTsKICAgICAgICB2YXIgZnJvbTsKICAgICAgICB2YXIgZnJvbV9zb3VyY2U7CiAgICAgICAgdmFyIGhlcmUgPSAwOwogICAgICAgIHZhciBoZXJlX2JpdHMsIGhlcmVfb3AsIGhlcmVfdmFsOwogICAgICAgIHZhciBsYXN0X2JpdHMsIGxhc3Rfb3AsIGxhc3RfdmFsOwogICAgICAgIHZhciBsZW47CiAgICAgICAgdmFyIHJldDsKICAgICAgICB2YXIgaGJ1ZiA9IG5ldyB1dGlscy5CdWY4KDQpOwogICAgICAgIHZhciBvcHRzOwogICAgICAgIHZhciBuOwogICAgICAgIHZhciBvcmRlciA9IFsxNiwgMTcsIDE4LCAwLCA4LCA3LCA5LCA2LCAxMCwgNSwgMTEsIDQsIDEyLCAzLCAxMywgMiwgMTQsIDEsIDE1XTsKICAgICAgICBpZiAoIXN0cm0gfHwgIXN0cm0uc3RhdGUgfHwgIXN0cm0ub3V0cHV0IHx8ICFzdHJtLmlucHV0ICYmIHN0cm0uYXZhaWxfaW4gIT09IDApIHsKICAgICAgICAgIHJldHVybiBaX1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgc3RhdGUgPSBzdHJtLnN0YXRlOwogICAgICAgIGlmIChzdGF0ZS5tb2RlID09PSBUWVBFKSB7CiAgICAgICAgICBzdGF0ZS5tb2RlID0gVFlQRURPOwogICAgICAgIH0KICAgICAgICBwdXQgPSBzdHJtLm5leHRfb3V0OwogICAgICAgIG91dHB1dCA9IHN0cm0ub3V0cHV0OwogICAgICAgIGxlZnQgPSBzdHJtLmF2YWlsX291dDsKICAgICAgICBuZXh0ID0gc3RybS5uZXh0X2luOwogICAgICAgIGlucHV0ID0gc3RybS5pbnB1dDsKICAgICAgICBoYXZlID0gc3RybS5hdmFpbF9pbjsKICAgICAgICBob2xkID0gc3RhdGUuaG9sZDsKICAgICAgICBiaXRzID0gc3RhdGUuYml0czsKICAgICAgICBfaW4gPSBoYXZlOwogICAgICAgIF9vdXQgPSBsZWZ0OwogICAgICAgIHJldCA9IFpfT0s7CiAgICAgICAgaW5mX2xlYXZlOgogICAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICAgIHN3aXRjaCAoc3RhdGUubW9kZSkgewogICAgICAgICAgICAgIGNhc2UgSEVBRDoKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS53cmFwID09PSAwKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBUWVBFRE87CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAxNikgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUud3JhcCAmIDIgJiYgaG9sZCA9PT0gMzU2MTUpIHsKICAgICAgICAgICAgICAgICAgc3RhdGUuY2hlY2sgPSAwOwogICAgICAgICAgICAgICAgICBoYnVmWzBdID0gaG9sZCAmIDI1NTsKICAgICAgICAgICAgICAgICAgaGJ1ZlsxXSA9IGhvbGQgPj4+IDggJiAyNTU7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmNoZWNrID0gY3JjMzIoc3RhdGUuY2hlY2ssIGhidWYsIDIsIDApOwogICAgICAgICAgICAgICAgICBob2xkID0gMDsKICAgICAgICAgICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBGTEFHUzsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5mbGFncyA9IDA7CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuaGVhZCkgewogICAgICAgICAgICAgICAgICBzdGF0ZS5oZWFkLmRvbmUgPSBmYWxzZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmICghKHN0YXRlLndyYXAgJiAxKSB8fCAoKChob2xkICYgMjU1KSA8PCA4KSArIChob2xkID4+IDgpKSAlIDMxKSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImluY29ycmVjdCBoZWFkZXIgY2hlY2siOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmICgoaG9sZCAmIDE1KSAhPT0gWl9ERUZMQVRFRCkgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJ1bmtub3duIGNvbXByZXNzaW9uIG1ldGhvZCI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaG9sZCA+Pj49IDQ7CiAgICAgICAgICAgICAgICBiaXRzIC09IDQ7CiAgICAgICAgICAgICAgICBsZW4gPSAoaG9sZCAmIDE1KSArIDg7CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUud2JpdHMgPT09IDApIHsKICAgICAgICAgICAgICAgICAgc3RhdGUud2JpdHMgPSBsZW47CiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGxlbiA+IHN0YXRlLndiaXRzKSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgd2luZG93IHNpemUiOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLmRtYXggPSAxIDw8IGxlbjsKICAgICAgICAgICAgICAgIHN0cm0uYWRsZXIgPSBzdGF0ZS5jaGVjayA9IDE7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gaG9sZCAmIDUxMiA/IERJQ1RJRCA6IFRZUEU7CiAgICAgICAgICAgICAgICBob2xkID0gMDsKICAgICAgICAgICAgICAgIGJpdHMgPSAwOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSBGTEFHUzoKICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMTYpIHsKICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUuZmxhZ3MgPSBob2xkOwogICAgICAgICAgICAgICAgaWYgKChzdGF0ZS5mbGFncyAmIDI1NSkgIT09IFpfREVGTEFURUQpIHsKICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAidW5rbm93biBjb21wcmVzc2lvbiBtZXRob2QiOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDU3MzQ0KSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gInVua25vd24gaGVhZGVyIGZsYWdzIHNldCI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHsKICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC50ZXh0ID0gaG9sZCA+PiA4ICYgMTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDUxMikgewogICAgICAgICAgICAgICAgICBoYnVmWzBdID0gaG9sZCAmIDI1NTsKICAgICAgICAgICAgICAgICAgaGJ1ZlsxXSA9IGhvbGQgPj4+IDggJiAyNTU7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmNoZWNrID0gY3JjMzIoc3RhdGUuY2hlY2ssIGhidWYsIDIsIDApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICBiaXRzID0gMDsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBUSU1FOwogICAgICAgICAgICAgIGNhc2UgVElNRToKICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMzIpIHsKICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHsKICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC50aW1lID0gaG9sZDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDUxMikgewogICAgICAgICAgICAgICAgICBoYnVmWzBdID0gaG9sZCAmIDI1NTsKICAgICAgICAgICAgICAgICAgaGJ1ZlsxXSA9IGhvbGQgPj4+IDggJiAyNTU7CiAgICAgICAgICAgICAgICAgIGhidWZbMl0gPSBob2xkID4+PiAxNiAmIDI1NTsKICAgICAgICAgICAgICAgICAgaGJ1ZlszXSA9IGhvbGQgPj4+IDI0ICYgMjU1OwogICAgICAgICAgICAgICAgICBzdGF0ZS5jaGVjayA9IGNyYzMyKHN0YXRlLmNoZWNrLCBoYnVmLCA0LCAwKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGhvbGQgPSAwOwogICAgICAgICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gT1M7CiAgICAgICAgICAgICAgY2FzZSBPUzoKICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMTYpIHsKICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHsKICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC54ZmxhZ3MgPSBob2xkICYgMjU1OwogICAgICAgICAgICAgICAgICBzdGF0ZS5oZWFkLm9zID0gaG9sZCA+PiA4OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgNTEyKSB7CiAgICAgICAgICAgICAgICAgIGhidWZbMF0gPSBob2xkICYgMjU1OwogICAgICAgICAgICAgICAgICBoYnVmWzFdID0gaG9sZCA+Pj4gOCAmIDI1NTsKICAgICAgICAgICAgICAgICAgc3RhdGUuY2hlY2sgPSBjcmMzMihzdGF0ZS5jaGVjaywgaGJ1ZiwgMiwgMCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBob2xkID0gMDsKICAgICAgICAgICAgICAgIGJpdHMgPSAwOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEVYTEVOOwogICAgICAgICAgICAgIGNhc2UgRVhMRU46CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiAxMDI0KSB7CiAgICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMTYpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIHN0YXRlLmxlbmd0aCA9IGhvbGQ7CiAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5oZWFkKSB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC5leHRyYV9sZW4gPSBob2xkOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDUxMikgewogICAgICAgICAgICAgICAgICAgIGhidWZbMF0gPSBob2xkICYgMjU1OwogICAgICAgICAgICAgICAgICAgIGhidWZbMV0gPSBob2xkID4+PiA4ICYgMjU1OwogICAgICAgICAgICAgICAgICAgIHN0YXRlLmNoZWNrID0gY3JjMzIoc3RhdGUuY2hlY2ssIGhidWYsIDIsIDApOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGhvbGQgPSAwOwogICAgICAgICAgICAgICAgICBiaXRzID0gMDsKICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoc3RhdGUuaGVhZCkgewogICAgICAgICAgICAgICAgICBzdGF0ZS5oZWFkLmV4dHJhID0gbnVsbDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBFWFRSQTsKICAgICAgICAgICAgICBjYXNlIEVYVFJBOgogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgMTAyNCkgewogICAgICAgICAgICAgICAgICBjb3B5ID0gc3RhdGUubGVuZ3RoOwogICAgICAgICAgICAgICAgICBpZiAoY29weSA+IGhhdmUpIHsKICAgICAgICAgICAgICAgICAgICBjb3B5ID0gaGF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoY29weSkgewogICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5oZWFkKSB7CiAgICAgICAgICAgICAgICAgICAgICBsZW4gPSBzdGF0ZS5oZWFkLmV4dHJhX2xlbiAtIHN0YXRlLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgIGlmICghc3RhdGUuaGVhZC5leHRyYSkgewogICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5oZWFkLmV4dHJhID0gbmV3IEFycmF5KHN0YXRlLmhlYWQuZXh0cmFfbGVuKTsKICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgIHV0aWxzLmFycmF5U2V0KHN0YXRlLmhlYWQuZXh0cmEsIGlucHV0LCBuZXh0LCBjb3B5LCBsZW4pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiA1MTIpIHsKICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLmNoZWNrID0gY3JjMzIoc3RhdGUuY2hlY2ssIGlucHV0LCBjb3B5LCBuZXh0KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGF2ZSAtPSBjb3B5OwogICAgICAgICAgICAgICAgICAgIG5leHQgKz0gY29weTsKICAgICAgICAgICAgICAgICAgICBzdGF0ZS5sZW5ndGggLT0gY29weTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoc3RhdGUubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IE5BTUU7CiAgICAgICAgICAgICAgY2FzZSBOQU1FOgogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgMjA0OCkgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBjb3B5ID0gMDsKICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgIGxlbiA9IGlucHV0W25leHQgKyBjb3B5KytdOwogICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5oZWFkICYmIGxlbiAmJiBzdGF0ZS5sZW5ndGggPCA2NTUzNikgewogICAgICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC5uYW1lICs9IFN0cmluZy5mcm9tQ2hhckNvZGUobGVuKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKGxlbiAmJiBjb3B5IDwgaGF2ZSk7CiAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDUxMikgewogICAgICAgICAgICAgICAgICAgIHN0YXRlLmNoZWNrID0gY3JjMzIoc3RhdGUuY2hlY2ssIGlucHV0LCBjb3B5LCBuZXh0KTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlIC09IGNvcHk7CiAgICAgICAgICAgICAgICAgIG5leHQgKz0gY29weTsKICAgICAgICAgICAgICAgICAgaWYgKGxlbikgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzdGF0ZS5oZWFkKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmhlYWQubmFtZSA9IG51bGw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IENPTU1FTlQ7CiAgICAgICAgICAgICAgY2FzZSBDT01NRU5UOgogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgNDA5NikgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBjb3B5ID0gMDsKICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgIGxlbiA9IGlucHV0W25leHQgKyBjb3B5KytdOwogICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5oZWFkICYmIGxlbiAmJiBzdGF0ZS5sZW5ndGggPCA2NTUzNikgewogICAgICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC5jb21tZW50ICs9IFN0cmluZy5mcm9tQ2hhckNvZGUobGVuKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKGxlbiAmJiBjb3B5IDwgaGF2ZSk7CiAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDUxMikgewogICAgICAgICAgICAgICAgICAgIHN0YXRlLmNoZWNrID0gY3JjMzIoc3RhdGUuY2hlY2ssIGlucHV0LCBjb3B5LCBuZXh0KTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlIC09IGNvcHk7CiAgICAgICAgICAgICAgICAgIG5leHQgKz0gY29weTsKICAgICAgICAgICAgICAgICAgaWYgKGxlbikgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzdGF0ZS5oZWFkKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmhlYWQuY29tbWVudCA9IG51bGw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gSENSQzsKICAgICAgICAgICAgICBjYXNlIEhDUkM6CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiA1MTIpIHsKICAgICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAxNikgewogICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaWYgKGhvbGQgIT09IChzdGF0ZS5jaGVjayAmIDY1NTM1KSkgewogICAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImhlYWRlciBjcmMgbWlzbWF0Y2giOwogICAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICAgIGJpdHMgPSAwOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHsKICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC5oY3JjID0gc3RhdGUuZmxhZ3MgPj4gOSAmIDE7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmhlYWQuZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdHJtLmFkbGVyID0gc3RhdGUuY2hlY2sgPSAwOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IFRZUEU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIERJQ1RJRDoKICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMzIpIHsKICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RybS5hZGxlciA9IHN0YXRlLmNoZWNrID0genN3YXAzMihob2xkKTsKICAgICAgICAgICAgICAgIGhvbGQgPSAwOwogICAgICAgICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gRElDVDsKICAgICAgICAgICAgICBjYXNlIERJQ1Q6CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuaGF2ZWRpY3QgPT09IDApIHsKICAgICAgICAgICAgICAgICAgc3RybS5uZXh0X291dCA9IHB1dDsKICAgICAgICAgICAgICAgICAgc3RybS5hdmFpbF9vdXQgPSBsZWZ0OwogICAgICAgICAgICAgICAgICBzdHJtLm5leHRfaW4gPSBuZXh0OwogICAgICAgICAgICAgICAgICBzdHJtLmF2YWlsX2luID0gaGF2ZTsKICAgICAgICAgICAgICAgICAgc3RhdGUuaG9sZCA9IGhvbGQ7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmJpdHMgPSBiaXRzOwogICAgICAgICAgICAgICAgICByZXR1cm4gWl9ORUVEX0RJQ1Q7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdHJtLmFkbGVyID0gc3RhdGUuY2hlY2sgPSAxOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IFRZUEU7CiAgICAgICAgICAgICAgY2FzZSBUWVBFOgogICAgICAgICAgICAgICAgaWYgKGZsdXNoID09PSBaX0JMT0NLIHx8IGZsdXNoID09PSBaX1RSRUVTKSB7CiAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjYXNlIFRZUEVETzoKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5sYXN0KSB7CiAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBiaXRzICYgNzsKICAgICAgICAgICAgICAgICAgYml0cyAtPSBiaXRzICYgNzsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IENIRUNLOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMykgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5sYXN0ID0gaG9sZCAmIDE7CiAgICAgICAgICAgICAgICBob2xkID4+Pj0gMTsKICAgICAgICAgICAgICAgIGJpdHMgLT0gMTsKICAgICAgICAgICAgICAgIHN3aXRjaCAoaG9sZCAmIDMpIHsKICAgICAgICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBTVE9SRUQ7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgICAgICAgICBmaXhlZHRhYmxlcyhzdGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IExFTl87CiAgICAgICAgICAgICAgICAgICAgaWYgKGZsdXNoID09PSBaX1RSRUVTKSB7CiAgICAgICAgICAgICAgICAgICAgICBob2xkID4+Pj0gMjsKICAgICAgICAgICAgICAgICAgICAgIGJpdHMgLT0gMjsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gVEFCTEU7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgIGNhc2UgMzoKICAgICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGJsb2NrIHR5cGUiOwogICAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBob2xkID4+Pj0gMjsKICAgICAgICAgICAgICAgIGJpdHMgLT0gMjsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGNhc2UgU1RPUkVEOgogICAgICAgICAgICAgICAgaG9sZCA+Pj49IGJpdHMgJiA3OwogICAgICAgICAgICAgICAgYml0cyAtPSBiaXRzICYgNzsKICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMzIpIHsKICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKChob2xkICYgNjU1MzUpICE9PSAoaG9sZCA+Pj4gMTYgXiA2NTUzNSkpIHsKICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBzdG9yZWQgYmxvY2sgbGVuZ3RocyI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUubGVuZ3RoID0gaG9sZCAmIDY1NTM1OwogICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICBiaXRzID0gMDsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBDT1BZXzsKICAgICAgICAgICAgICAgIGlmIChmbHVzaCA9PT0gWl9UUkVFUykgewogICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY2FzZSBDT1BZXzoKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBDT1BZOwogICAgICAgICAgICAgIGNhc2UgQ09QWToKICAgICAgICAgICAgICAgIGNvcHkgPSBzdGF0ZS5sZW5ndGg7CiAgICAgICAgICAgICAgICBpZiAoY29weSkgewogICAgICAgICAgICAgICAgICBpZiAoY29weSA+IGhhdmUpIHsKICAgICAgICAgICAgICAgICAgICBjb3B5ID0gaGF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoY29weSA+IGxlZnQpIHsKICAgICAgICAgICAgICAgICAgICBjb3B5ID0gbGVmdDsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoY29weSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICB1dGlscy5hcnJheVNldChvdXRwdXQsIGlucHV0LCBuZXh0LCBjb3B5LCBwdXQpOwogICAgICAgICAgICAgICAgICBoYXZlIC09IGNvcHk7CiAgICAgICAgICAgICAgICAgIG5leHQgKz0gY29weTsKICAgICAgICAgICAgICAgICAgbGVmdCAtPSBjb3B5OwogICAgICAgICAgICAgICAgICBwdXQgKz0gY29weTsKICAgICAgICAgICAgICAgICAgc3RhdGUubGVuZ3RoIC09IGNvcHk7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IFRZUEU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIFRBQkxFOgogICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAxNCkgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5ubGVuID0gKGhvbGQgJiAzMSkgKyAyNTc7CiAgICAgICAgICAgICAgICBob2xkID4+Pj0gNTsKICAgICAgICAgICAgICAgIGJpdHMgLT0gNTsKICAgICAgICAgICAgICAgIHN0YXRlLm5kaXN0ID0gKGhvbGQgJiAzMSkgKyAxOwogICAgICAgICAgICAgICAgaG9sZCA+Pj49IDU7CiAgICAgICAgICAgICAgICBiaXRzIC09IDU7CiAgICAgICAgICAgICAgICBzdGF0ZS5uY29kZSA9IChob2xkICYgMTUpICsgNDsKICAgICAgICAgICAgICAgIGhvbGQgPj4+PSA0OwogICAgICAgICAgICAgICAgYml0cyAtPSA0OwogICAgICAgICAgICAgICAgaWYgKHN0YXRlLm5sZW4gPiAyODYgfHwgc3RhdGUubmRpc3QgPiAzMCkgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJ0b28gbWFueSBsZW5ndGggb3IgZGlzdGFuY2Ugc3ltYm9scyI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUuaGF2ZSA9IDA7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gTEVOTEVOUzsKICAgICAgICAgICAgICBjYXNlIExFTkxFTlM6CiAgICAgICAgICAgICAgICB3aGlsZSAoc3RhdGUuaGF2ZSA8IHN0YXRlLm5jb2RlKSB7CiAgICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMykgewogICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgc3RhdGUubGVuc1tvcmRlcltzdGF0ZS5oYXZlKytdXSA9IGhvbGQgJiA3OwogICAgICAgICAgICAgICAgICBob2xkID4+Pj0gMzsKICAgICAgICAgICAgICAgICAgYml0cyAtPSAzOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgd2hpbGUgKHN0YXRlLmhhdmUgPCAxOSkgewogICAgICAgICAgICAgICAgICBzdGF0ZS5sZW5zW29yZGVyW3N0YXRlLmhhdmUrK11dID0gMDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLmxlbmNvZGUgPSBzdGF0ZS5sZW5keW47CiAgICAgICAgICAgICAgICBzdGF0ZS5sZW5iaXRzID0gNzsKICAgICAgICAgICAgICAgIG9wdHMgPSB7IGJpdHM6IHN0YXRlLmxlbmJpdHMgfTsKICAgICAgICAgICAgICAgIHJldCA9IGluZmxhdGVfdGFibGUoQ09ERVMsIHN0YXRlLmxlbnMsIDAsIDE5LCBzdGF0ZS5sZW5jb2RlLCAwLCBzdGF0ZS53b3JrLCBvcHRzKTsKICAgICAgICAgICAgICAgIHN0YXRlLmxlbmJpdHMgPSBvcHRzLmJpdHM7CiAgICAgICAgICAgICAgICBpZiAocmV0KSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgY29kZSBsZW5ndGhzIHNldCI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUuaGF2ZSA9IDA7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQ09ERUxFTlM7CiAgICAgICAgICAgICAgY2FzZSBDT0RFTEVOUzoKICAgICAgICAgICAgICAgIHdoaWxlIChzdGF0ZS5oYXZlIDwgc3RhdGUubmxlbiArIHN0YXRlLm5kaXN0KSB7CiAgICAgICAgICAgICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgICAgICAgICAgIGhlcmUgPSBzdGF0ZS5sZW5jb2RlW2hvbGQgJiAoMSA8PCBzdGF0ZS5sZW5iaXRzKSAtIDFdOwogICAgICAgICAgICAgICAgICAgIGhlcmVfYml0cyA9IGhlcmUgPj4+IDI0OwogICAgICAgICAgICAgICAgICAgIGhlcmVfb3AgPSBoZXJlID4+PiAxNiAmIDI1NTsKICAgICAgICAgICAgICAgICAgICBoZXJlX3ZhbCA9IGhlcmUgJiA2NTUzNTsKICAgICAgICAgICAgICAgICAgICBpZiAoaGVyZV9iaXRzIDw9IGJpdHMpIHsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChoZXJlX3ZhbCA8IDE2KSB7CiAgICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IGhlcmVfYml0czsKICAgICAgICAgICAgICAgICAgICBiaXRzIC09IGhlcmVfYml0czsKICAgICAgICAgICAgICAgICAgICBzdGF0ZS5sZW5zW3N0YXRlLmhhdmUrK10gPSBoZXJlX3ZhbDsKICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaGVyZV92YWwgPT09IDE2KSB7CiAgICAgICAgICAgICAgICAgICAgICBuID0gaGVyZV9iaXRzICsgMjsKICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgbikgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICBob2xkID4+Pj0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgICAgICAgYml0cyAtPSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGUuaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGJpdCBsZW5ndGggcmVwZWF0IjsKICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICBsZW4gPSBzdGF0ZS5sZW5zW3N0YXRlLmhhdmUgLSAxXTsKICAgICAgICAgICAgICAgICAgICAgIGNvcHkgPSAzICsgKGhvbGQgJiAzKTsKICAgICAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSAyOwogICAgICAgICAgICAgICAgICAgICAgYml0cyAtPSAyOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaGVyZV92YWwgPT09IDE3KSB7CiAgICAgICAgICAgICAgICAgICAgICBuID0gaGVyZV9iaXRzICsgMzsKICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgbikgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICBob2xkID4+Pj0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgICAgICAgYml0cyAtPSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICAgICAgICBsZW4gPSAwOwogICAgICAgICAgICAgICAgICAgICAgY29weSA9IDMgKyAoaG9sZCAmIDcpOwogICAgICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IDM7CiAgICAgICAgICAgICAgICAgICAgICBiaXRzIC09IDM7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgIG4gPSBoZXJlX2JpdHMgKyA3OwogICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCBuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICAgICAgICBiaXRzIC09IGhlcmVfYml0czsKICAgICAgICAgICAgICAgICAgICAgIGxlbiA9IDA7CiAgICAgICAgICAgICAgICAgICAgICBjb3B5ID0gMTEgKyAoaG9sZCAmIDEyNyk7CiAgICAgICAgICAgICAgICAgICAgICBob2xkID4+Pj0gNzsKICAgICAgICAgICAgICAgICAgICAgIGJpdHMgLT0gNzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLmhhdmUgKyBjb3B5ID4gc3RhdGUubmxlbiArIHN0YXRlLm5kaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGJpdCBsZW5ndGggcmVwZWF0IjsKICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGNvcHktLSkgewogICAgICAgICAgICAgICAgICAgICAgc3RhdGUubGVuc1tzdGF0ZS5oYXZlKytdID0gbGVuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLm1vZGUgPT09IEJBRCkgewogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5sZW5zWzI1Nl0gPT09IDApIHsKICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBjb2RlIC0tIG1pc3NpbmcgZW5kLW9mLWJsb2NrIjsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5sZW5iaXRzID0gOTsKICAgICAgICAgICAgICAgIG9wdHMgPSB7IGJpdHM6IHN0YXRlLmxlbmJpdHMgfTsKICAgICAgICAgICAgICAgIHJldCA9IGluZmxhdGVfdGFibGUoTEVOUywgc3RhdGUubGVucywgMCwgc3RhdGUubmxlbiwgc3RhdGUubGVuY29kZSwgMCwgc3RhdGUud29yaywgb3B0cyk7CiAgICAgICAgICAgICAgICBzdGF0ZS5sZW5iaXRzID0gb3B0cy5iaXRzOwogICAgICAgICAgICAgICAgaWYgKHJldCkgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGxpdGVyYWwvbGVuZ3RocyBzZXQiOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLmRpc3RiaXRzID0gNjsKICAgICAgICAgICAgICAgIHN0YXRlLmRpc3Rjb2RlID0gc3RhdGUuZGlzdGR5bjsKICAgICAgICAgICAgICAgIG9wdHMgPSB7IGJpdHM6IHN0YXRlLmRpc3RiaXRzIH07CiAgICAgICAgICAgICAgICByZXQgPSBpbmZsYXRlX3RhYmxlKERJU1RTLCBzdGF0ZS5sZW5zLCBzdGF0ZS5ubGVuLCBzdGF0ZS5uZGlzdCwgc3RhdGUuZGlzdGNvZGUsIDAsIHN0YXRlLndvcmssIG9wdHMpOwogICAgICAgICAgICAgICAgc3RhdGUuZGlzdGJpdHMgPSBvcHRzLmJpdHM7CiAgICAgICAgICAgICAgICBpZiAocmV0KSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgZGlzdGFuY2VzIHNldCI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IExFTl87CiAgICAgICAgICAgICAgICBpZiAoZmx1c2ggPT09IFpfVFJFRVMpIHsKICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNhc2UgTEVOXzoKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBMRU47CiAgICAgICAgICAgICAgY2FzZSBMRU46CiAgICAgICAgICAgICAgICBpZiAoaGF2ZSA+PSA2ICYmIGxlZnQgPj0gMjU4KSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubmV4dF9vdXQgPSBwdXQ7CiAgICAgICAgICAgICAgICAgIHN0cm0uYXZhaWxfb3V0ID0gbGVmdDsKICAgICAgICAgICAgICAgICAgc3RybS5uZXh0X2luID0gbmV4dDsKICAgICAgICAgICAgICAgICAgc3RybS5hdmFpbF9pbiA9IGhhdmU7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmhvbGQgPSBob2xkOwogICAgICAgICAgICAgICAgICBzdGF0ZS5iaXRzID0gYml0czsKICAgICAgICAgICAgICAgICAgaW5mbGF0ZV9mYXN0KHN0cm0sIF9vdXQpOwogICAgICAgICAgICAgICAgICBwdXQgPSBzdHJtLm5leHRfb3V0OwogICAgICAgICAgICAgICAgICBvdXRwdXQgPSBzdHJtLm91dHB1dDsKICAgICAgICAgICAgICAgICAgbGVmdCA9IHN0cm0uYXZhaWxfb3V0OwogICAgICAgICAgICAgICAgICBuZXh0ID0gc3RybS5uZXh0X2luOwogICAgICAgICAgICAgICAgICBpbnB1dCA9IHN0cm0uaW5wdXQ7CiAgICAgICAgICAgICAgICAgIGhhdmUgPSBzdHJtLmF2YWlsX2luOwogICAgICAgICAgICAgICAgICBob2xkID0gc3RhdGUuaG9sZDsKICAgICAgICAgICAgICAgICAgYml0cyA9IHN0YXRlLmJpdHM7CiAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5tb2RlID09PSBUWVBFKSB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGUuYmFjayA9IC0xOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUuYmFjayA9IDA7CiAgICAgICAgICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgICAgICAgICAgaGVyZSA9IHN0YXRlLmxlbmNvZGVbaG9sZCAmICgxIDw8IHN0YXRlLmxlbmJpdHMpIC0gMV07CiAgICAgICAgICAgICAgICAgIGhlcmVfYml0cyA9IGhlcmUgPj4+IDI0OwogICAgICAgICAgICAgICAgICBoZXJlX29wID0gaGVyZSA+Pj4gMTYgJiAyNTU7CiAgICAgICAgICAgICAgICAgIGhlcmVfdmFsID0gaGVyZSAmIDY1NTM1OwogICAgICAgICAgICAgICAgICBpZiAoaGVyZV9iaXRzIDw9IGJpdHMpIHsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoaGVyZV9vcCAmJiAoaGVyZV9vcCAmIDI0MCkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgbGFzdF9iaXRzID0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgICBsYXN0X29wID0gaGVyZV9vcDsKICAgICAgICAgICAgICAgICAgbGFzdF92YWwgPSBoZXJlX3ZhbDsKICAgICAgICAgICAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICAgICAgICAgICAgaGVyZSA9IHN0YXRlLmxlbmNvZGVbbGFzdF92YWwgKyAoKGhvbGQgJiAoMSA8PCBsYXN0X2JpdHMgKyBsYXN0X29wKSAtIDEpID4+IGxhc3RfYml0cyldOwogICAgICAgICAgICAgICAgICAgIGhlcmVfYml0cyA9IGhlcmUgPj4+IDI0OwogICAgICAgICAgICAgICAgICAgIGhlcmVfb3AgPSBoZXJlID4+PiAxNiAmIDI1NTsKICAgICAgICAgICAgICAgICAgICBoZXJlX3ZhbCA9IGhlcmUgJiA2NTUzNTsKICAgICAgICAgICAgICAgICAgICBpZiAobGFzdF9iaXRzICsgaGVyZV9iaXRzIDw9IGJpdHMpIHsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBsYXN0X2JpdHM7CiAgICAgICAgICAgICAgICAgIGJpdHMgLT0gbGFzdF9iaXRzOwogICAgICAgICAgICAgICAgICBzdGF0ZS5iYWNrICs9IGxhc3RfYml0czsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICBiaXRzIC09IGhlcmVfYml0czsKICAgICAgICAgICAgICAgIHN0YXRlLmJhY2sgKz0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgc3RhdGUubGVuZ3RoID0gaGVyZV92YWw7CiAgICAgICAgICAgICAgICBpZiAoaGVyZV9vcCA9PT0gMCkgewogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gTElUOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChoZXJlX29wICYgMzIpIHsKICAgICAgICAgICAgICAgICAgc3RhdGUuYmFjayA9IC0xOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gVFlQRTsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoaGVyZV9vcCAmIDY0KSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgbGl0ZXJhbC9sZW5ndGggY29kZSI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUuZXh0cmEgPSBoZXJlX29wICYgMTU7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gTEVORVhUOwogICAgICAgICAgICAgIGNhc2UgTEVORVhUOgogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmV4dHJhKSB7CiAgICAgICAgICAgICAgICAgIG4gPSBzdGF0ZS5leHRyYTsKICAgICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCBuKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBzdGF0ZS5sZW5ndGggKz0gaG9sZCAmICgxIDw8IHN0YXRlLmV4dHJhKSAtIDE7CiAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBzdGF0ZS5leHRyYTsKICAgICAgICAgICAgICAgICAgYml0cyAtPSBzdGF0ZS5leHRyYTsKICAgICAgICAgICAgICAgICAgc3RhdGUuYmFjayArPSBzdGF0ZS5leHRyYTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLndhcyA9IHN0YXRlLmxlbmd0aDsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBESVNUOwogICAgICAgICAgICAgIGNhc2UgRElTVDoKICAgICAgICAgICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgICAgICAgICBoZXJlID0gc3RhdGUuZGlzdGNvZGVbaG9sZCAmICgxIDw8IHN0YXRlLmRpc3RiaXRzKSAtIDFdOwogICAgICAgICAgICAgICAgICBoZXJlX2JpdHMgPSBoZXJlID4+PiAyNDsKICAgICAgICAgICAgICAgICAgaGVyZV9vcCA9IGhlcmUgPj4+IDE2ICYgMjU1OwogICAgICAgICAgICAgICAgICBoZXJlX3ZhbCA9IGhlcmUgJiA2NTUzNTsKICAgICAgICAgICAgICAgICAgaWYgKGhlcmVfYml0cyA8PSBiaXRzKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKChoZXJlX29wICYgMjQwKSA9PT0gMCkgewogICAgICAgICAgICAgICAgICBsYXN0X2JpdHMgPSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICAgIGxhc3Rfb3AgPSBoZXJlX29wOwogICAgICAgICAgICAgICAgICBsYXN0X3ZhbCA9IGhlcmVfdmFsOwogICAgICAgICAgICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgICAgICAgICAgICBoZXJlID0gc3RhdGUuZGlzdGNvZGVbbGFzdF92YWwgKyAoKGhvbGQgJiAoMSA8PCBsYXN0X2JpdHMgKyBsYXN0X29wKSAtIDEpID4+IGxhc3RfYml0cyldOwogICAgICAgICAgICAgICAgICAgIGhlcmVfYml0cyA9IGhlcmUgPj4+IDI0OwogICAgICAgICAgICAgICAgICAgIGhlcmVfb3AgPSBoZXJlID4+PiAxNiAmIDI1NTsKICAgICAgICAgICAgICAgICAgICBoZXJlX3ZhbCA9IGhlcmUgJiA2NTUzNTsKICAgICAgICAgICAgICAgICAgICBpZiAobGFzdF9iaXRzICsgaGVyZV9iaXRzIDw9IGJpdHMpIHsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBsYXN0X2JpdHM7CiAgICAgICAgICAgICAgICAgIGJpdHMgLT0gbGFzdF9iaXRzOwogICAgICAgICAgICAgICAgICBzdGF0ZS5iYWNrICs9IGxhc3RfYml0czsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICBiaXRzIC09IGhlcmVfYml0czsKICAgICAgICAgICAgICAgIHN0YXRlLmJhY2sgKz0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgaWYgKGhlcmVfb3AgJiA2NCkgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGRpc3RhbmNlIGNvZGUiOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLm9mZnNldCA9IGhlcmVfdmFsOwogICAgICAgICAgICAgICAgc3RhdGUuZXh0cmEgPSBoZXJlX29wICYgMTU7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gRElTVEVYVDsKICAgICAgICAgICAgICBjYXNlIERJU1RFWFQ6CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuZXh0cmEpIHsKICAgICAgICAgICAgICAgICAgbiA9IHN0YXRlLmV4dHJhOwogICAgICAgICAgICAgICAgICB3aGlsZSAoYml0cyA8IG4pIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIHN0YXRlLm9mZnNldCArPSBob2xkICYgKDEgPDwgc3RhdGUuZXh0cmEpIC0gMTsKICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IHN0YXRlLmV4dHJhOwogICAgICAgICAgICAgICAgICBiaXRzIC09IHN0YXRlLmV4dHJhOwogICAgICAgICAgICAgICAgICBzdGF0ZS5iYWNrICs9IHN0YXRlLmV4dHJhOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLm9mZnNldCA+IHN0YXRlLmRtYXgpIHsKICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBkaXN0YW5jZSB0b28gZmFyIGJhY2siOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBNQVRDSDsKICAgICAgICAgICAgICBjYXNlIE1BVENIOgogICAgICAgICAgICAgICAgaWYgKGxlZnQgPT09IDApIHsKICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY29weSA9IF9vdXQgLSBsZWZ0OwogICAgICAgICAgICAgICAgaWYgKHN0YXRlLm9mZnNldCA+IGNvcHkpIHsKICAgICAgICAgICAgICAgICAgY29weSA9IHN0YXRlLm9mZnNldCAtIGNvcHk7CiAgICAgICAgICAgICAgICAgIGlmIChjb3B5ID4gc3RhdGUud2hhdmUpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGUuc2FuZSkgewogICAgICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBkaXN0YW5jZSB0b28gZmFyIGJhY2siOwogICAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoY29weSA+IHN0YXRlLnduZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgY29weSAtPSBzdGF0ZS53bmV4dDsKICAgICAgICAgICAgICAgICAgICBmcm9tID0gc3RhdGUud3NpemUgLSBjb3B5OwogICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgIGZyb20gPSBzdGF0ZS53bmV4dCAtIGNvcHk7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaWYgKGNvcHkgPiBzdGF0ZS5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICBjb3B5ID0gc3RhdGUubGVuZ3RoOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGZyb21fc291cmNlID0gc3RhdGUud2luZG93OwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgZnJvbV9zb3VyY2UgPSBvdXRwdXQ7CiAgICAgICAgICAgICAgICAgIGZyb20gPSBwdXQgLSBzdGF0ZS5vZmZzZXQ7CiAgICAgICAgICAgICAgICAgIGNvcHkgPSBzdGF0ZS5sZW5ndGg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoY29weSA+IGxlZnQpIHsKICAgICAgICAgICAgICAgICAgY29weSA9IGxlZnQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBsZWZ0IC09IGNvcHk7CiAgICAgICAgICAgICAgICBzdGF0ZS5sZW5ndGggLT0gY29weTsKICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgb3V0cHV0W3B1dCsrXSA9IGZyb21fc291cmNlW2Zyb20rK107CiAgICAgICAgICAgICAgICB9IHdoaWxlICgtLWNvcHkpOwogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gTEVOOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSBMSVQ6CiAgICAgICAgICAgICAgICBpZiAobGVmdCA9PT0gMCkgewogICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBvdXRwdXRbcHV0KytdID0gc3RhdGUubGVuZ3RoOwogICAgICAgICAgICAgICAgbGVmdC0tOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IExFTjsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGNhc2UgQ0hFQ0s6CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUud3JhcCkgewogICAgICAgICAgICAgICAgICB3aGlsZSAoYml0cyA8IDMyKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICAgIGhvbGQgfD0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBfb3V0IC09IGxlZnQ7CiAgICAgICAgICAgICAgICAgIHN0cm0udG90YWxfb3V0ICs9IF9vdXQ7CiAgICAgICAgICAgICAgICAgIHN0YXRlLnRvdGFsICs9IF9vdXQ7CiAgICAgICAgICAgICAgICAgIGlmIChfb3V0KSB7CiAgICAgICAgICAgICAgICAgICAgc3RybS5hZGxlciA9IHN0YXRlLmNoZWNrID0gc3RhdGUuZmxhZ3MgPyBjcmMzMihzdGF0ZS5jaGVjaywgb3V0cHV0LCBfb3V0LCBwdXQgLSBfb3V0KSA6IGFkbGVyMzIoc3RhdGUuY2hlY2ssIG91dHB1dCwgX291dCwgcHV0IC0gX291dCk7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgX291dCA9IGxlZnQ7CiAgICAgICAgICAgICAgICAgIGlmICgoc3RhdGUuZmxhZ3MgPyBob2xkIDogenN3YXAzMihob2xkKSkgIT09IHN0YXRlLmNoZWNrKSB7CiAgICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW5jb3JyZWN0IGRhdGEgY2hlY2siOwogICAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICAgIGJpdHMgPSAwOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IExFTkdUSDsKICAgICAgICAgICAgICBjYXNlIExFTkdUSDoKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS53cmFwICYmIHN0YXRlLmZsYWdzKSB7CiAgICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMzIpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChob2xkICE9PSAoc3RhdGUudG90YWwgJiA0Mjk0OTY3Mjk1KSkgewogICAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImluY29ycmVjdCBsZW5ndGggY2hlY2siOwogICAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICAgIGJpdHMgPSAwOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IERPTkU7CiAgICAgICAgICAgICAgY2FzZSBET05FOgogICAgICAgICAgICAgICAgcmV0ID0gWl9TVFJFQU1fRU5EOwogICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgIGNhc2UgQkFEOgogICAgICAgICAgICAgICAgcmV0ID0gWl9EQVRBX0VSUk9SOwogICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgIGNhc2UgTUVNOgogICAgICAgICAgICAgICAgcmV0dXJuIFpfTUVNX0VSUk9SOwogICAgICAgICAgICAgIGNhc2UgU1lOQzoKICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgc3RybS5uZXh0X291dCA9IHB1dDsKICAgICAgICBzdHJtLmF2YWlsX291dCA9IGxlZnQ7CiAgICAgICAgc3RybS5uZXh0X2luID0gbmV4dDsKICAgICAgICBzdHJtLmF2YWlsX2luID0gaGF2ZTsKICAgICAgICBzdGF0ZS5ob2xkID0gaG9sZDsKICAgICAgICBzdGF0ZS5iaXRzID0gYml0czsKICAgICAgICBpZiAoc3RhdGUud3NpemUgfHwgX291dCAhPT0gc3RybS5hdmFpbF9vdXQgJiYgc3RhdGUubW9kZSA8IEJBRCAmJiAoc3RhdGUubW9kZSA8IENIRUNLIHx8IGZsdXNoICE9PSBaX0ZJTklTSCkpIHsKICAgICAgICAgIGlmICh1cGRhdGV3aW5kb3coc3RybSwgc3RybS5vdXRwdXQsIHN0cm0ubmV4dF9vdXQsIF9vdXQgLSBzdHJtLmF2YWl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X1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgdmFyIHN0YXRlID0gc3RybS5zdGF0ZTsKICAgICAgICBpZiAoc3RhdGUud2luZG93KSB7CiAgICAgICAgICBzdGF0ZS53aW5kb3cgPSBudWxsOwogICAgICAgIH0KICAgICAgICBzdHJtLnN0YXRlID0gbnVsbDsKICAgICAgICByZXR1cm4gWl9PSzsKICAgICAgfQogICAgICBmdW5jdGlvbiBpbmZsYXRlR2V0SGVhZGVyKHN0cm0sIGhlYWQpIHsKICAgICAgICB2YXIgc3RhdGU7CiAgICAgICAgaWYgKCFzdHJtIHx8ICFzdHJtLnN0YXRlKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIHN0YXRlID0gc3RybS5zdGF0ZTsKICAgICAgICBpZiAoKHN0YXRlLndyYXAgJiAyKSA9PT0gMCkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgIH0KICAgICAgICBzdGF0ZS5oZWFkID0gaGVhZDsKICAgICAgICBoZWFkLmRvbmUgPSBmYWxzZTsKICAgICAgICByZXR1cm4gWl9PSzsKICAgICAgfQogICAgICBmdW5jdGlvbiBpbmZsYXRlU2V0RGljdGlvbmFyeShzdHJtLCBkaWN0aW9uYXJ5KSB7CiAgICAgICAgdmFyIGRpY3RMZW5ndGggPSBkaWN0aW9uYXJ5Lmxlbmd0aDsKICAgICAgICB2YXIgc3RhdGU7CiAgICAgICAgdmFyIGRpY3RpZDsKICAgICAgICB2YXIgcmV0OwogICAgICAgIGlmICghc3RybSB8fCAhc3RybS5zdGF0ZSkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgIH0KICAgICAgICBzdGF0ZSA9IHN0cm0uc3RhdGU7CiAgICAgICAgaWYgKHN0YXRlLndyYXAgIT09IDAgJiYgc3RhdGUubW9kZSAhPT0gRElDVCkgewogICAgICAgICAgcmV0dXJu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RVNTSU9OOiAtMSwKICAgICAgICBaX0ZJTFRFUkVEOiAxLAogICAgICAgIFpfSFVGRk1BTl9PTkxZOiAyLAogICAgICAgIFpfUkxFOiAzLAogICAgICAgIFpfRklYRUQ6IDQsCiAgICAgICAgWl9ERUZBVUxUX1NUUkFURUdZOiAwLAogICAgICAgIFpfQklOQVJZOiAwLAogICAgICAgIFpfVEVYVDogMSwKICAgICAgICBaX1VOS05PV046IDIsCiAgICAgICAgWl9ERUZMQVRFRDogOAogICAgICB9OwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLnBucG0vcGFrb0AxLjAuMTEvbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvZ3poZWFkZXIuanMKICB2YXIgcmVxdWlyZV9nemhlYWRlciA9IF9fY29tbW9uSlMoewogICAgIm5vZGVfbW9kdWxlcy8ucG5wbS9wYWtvQDEuMC4xMS9ub2RlX21vZHVsZXMvcGFrby9saWIvemxpYi9nemhlYWRlci5qcyIoZXhwb3J0czIsIG1vZHVsZTIpIHsKICAgICAgaW5pdF9idWZmZXJfc2hpbSgpOwogICAgICAidXNlIHN0cmljdCI7CiAgICAgIGZ1bmN0aW9uIEdaaGVhZGVyKCkgewogICAgICAgIHRoaXMudGV4dCA9IDA7CiAgICAgICAgdGhpcy50aW1lID0gMDsKICAgICAgICB0aGlzLnhmbGFncyA9IDA7CiAgICAgICAgdGhpcy5vcyA9IDA7CiAgICAgICAgdGhpcy5leHRyYSA9IG51bGw7CiAgICAgICAgdGhpcy5leHRyYV9sZW4gPSAwOwogICAgICAgIHRoaXMubmFtZSA9ICIiOwogICAgICAgIHRoaXMuY29tbWVudCA9ICIiOwogICAgICAgIHRoaXMuaGNyYyA9IDA7CiAgICAgICAgdGhpcy5kb25lID0gZmFsc2U7CiAgICAgIH0KICAgICAgbW9kdWxlMi5leHBvcnRzID0gR1poZWFkZXI7CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8ucG5wbS9wYWtvQ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dHMgPj0gMCAmJiBvcHQud2luZG93Qml0cyA8IDE2KSB7CiAgICAgICAgICBvcHQud2luZG93Qml0cyA9IC1vcHQud2luZG93Qml0czsKICAgICAgICAgIGlmIChvcHQud2luZG93Qml0cyA9PT0gMCkgewogICAgICAgICAgICBvcHQud2luZG93Qml0cyA9IC0xNTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKG9wdC53aW5kb3dCaXRzID49IDAgJiYgb3B0LndpbmRvd0JpdHMgPCAxNiAmJiAhKG9wdGlvbnMgJiYgb3B0aW9ucy53aW5kb3dCaXRzKSkgewogICAgICAgICAgb3B0LndpbmRvd0JpdHMgKz0gMzI7CiAgICAgICAgfQogICAgICAgIGlmIChvcHQud2luZG93Qml0cyA+IDE1ICYmIG9wdC53aW5kb3dCaXRzIDwgNDgpIHsKICAgICAgICAgIGlmICgob3B0LndpbmRvd0JpdHMgJiAxNSkgPT09IDApIHsKICAgICAgICAgICAgb3B0LndpbmRvd0JpdHMgfD0gMTU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHRoaXMuZXJyID0gMDsKICAgICAgICB0aGlzLm1zZyA9ICIiOwogICAgICAgIHRoaXMuZW5kZWQgPSBmYWxzZTsKICAgICAgICB0aGlzLmNodW5rcyA9IFtdOwogICAgICAgIHRoaXMuc3RybSA9IG5ldyBaU3RyZWFtKCk7CiAgICAgICAgdGhpcy5zdHJtLmF2YWlsX291dCA9IDA7CiAgICAgICAgdmFyIHN0YXR1cyA9IHpsaWJfaW5mbGF0ZS5pbmZsYXRlSW5pdDIodGhpcy5zdHJtLCBvcHQud2luZG93Qml0cyk7CiAgICAgICAgaWYgKHN0YXR1cyAhPT0gYy5aX09LKSB7CiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IobXNnW3N0YXR1c10pOwogICAgICAgIH0KICAgICAgICB0aGlzLmhlYWRlciA9IG5ldyBHWmhlYWRlcigpOwogICAgICAgIHpsaWJfaW5mbGF0ZS5pbmZsYXRlR2V0SGVhZGVyKHRoaXMuc3RybSwgdGhpcy5oZWFkZXIpOwogICAgICAgIGlmIChvcHQuZGljdGlvbmFyeSkgewogICAgICAgICAgaWYgKHR5cGVvZiBvcHQuZGljdGlvbmFyeSA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgb3B0LmRpY3Rpb25hcnkgPSBzdHJpbmdzLnN0cmluZzJidWYob3B0LmRpY3Rpb25hcnkpOwogICAgICAgICAgfSBlbHNlIGlmICh0b1N0cmluZy5jYWxsKG9wdC5kaWN0aW9uYXJ5KSA9PT0gIltvYmplY3QgQXJyYXlCdWZmZXJdIikgewogICAgICAgICAgICBvcHQuZGljdGlvbmFyeSA9IG5ldyBVaW50OEFycmF5KG9wdC5kaWN0aW9uYXJ5KTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChvcHQucmF3KSB7CiAgICAgICAgICAgIHN0YXR1cyA9IHpsaWJfaW5mbGF0ZS5pbmZsYXRlU2V0RGljdGlvbmFyeSh0aGlzLnN0cm0sIG9wdC5kaWN0aW9uYXJ5KTsKICAgICAgICAgICAgaWYgKHN0YXR1cyAhPT0gYy5aX09LKSB7CiAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKG1zZ1tzdGF0dXNdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBJbmZsYXRlMi5wcm90b3R5cGUucHVzaCA9IGZ1bmN0aW9uKGRhdGEsIG1vZGUpIHsKICAgICAgICB2YXIgc3RybSA9IHRoaXMuc3RybTsKICAgICAgICB2YXIgY2h1bmtTaXplID0gdGhpcy5vcHRpb25zLmNodW5rU2l6ZTsKICAgICAgICB2YXIgZGljdGlvbmFyeSA9IHRoaXMub3B0aW9ucy5kaWN0aW9uYXJ5OwogICAgICAgIHZhciBzdGF0dXMsIF9tb2RlOwogICAgICAgIHZhciBuZXh0X291dF91dGY4LCB0YWlsLCB1dGY4c3RyOwogICAgICAgIHZhciBhbGxvd0J1ZkVycm9y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RoaXMuc3RybSwgZGljdGlvbmFyeSk7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoc3RhdHVzID09PSBjLlpfQlVGX0VSUk9SICYmIGFsbG93QnVmRXJyb3IgPT09IHRydWUpIHsKICAgICAgICAgICAgc3RhdHVzID0gYy5aX09LOwogICAgICAgICAgICBhbGxvd0J1ZkVycm9yID0gZmFsc2U7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoc3RhdHVzICE9PSBjLlpfU1RSRUFNX0VORCAmJiBzdGF0dXMgIT09IGMuWl9PSykgewogICAgICAgICAgICB0aGlzLm9uRW5kKHN0YXR1cyk7CiAgICAgICAgICAgIHRoaXMuZW5kZWQgPSB0cnVlOwogICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoc3RybS5uZXh0X291dCkgewogICAgICAgICAgICBpZiAoc3RybS5hdmFpbF9vdXQgPT09IDAgfHwgc3RhdHVzID09PSBjLlpfU1RSRUFNX0VORCB8fCBzdHJtLmF2YWlsX2luID09PSAwICYmIChfbW9kZSA9PT0gYy5aX0ZJTklTSCB8fCBfbW9kZSA9PT0gYy5aX1NZTkNfRkxVU0gpKSB7CiAgICAgICAgICAgICAgaWYgKHRoaXMub3B0aW9ucy50byA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgIG5leHRfb3V0X3V0ZjggPSBzdHJpbmdzLnV0Zjhib3JkZXIoc3RybS5vdXRwdXQsIHN0cm0ubmV4dF9vdXQpOwogICAgICAgICAgICAgICAgdGFpbCA9IHN0cm0ubmV4dF9vdXQgLSBuZXh0X291dF91dGY4OwogICAgICAgICAgICAgICAgdXRmOHN0ciA9IHN0cmluZ3MuYnVmMnN0cmluZyhzdHJtLm91dHB1dCwgbmV4dF9vdXRfdXRmOCk7CiAgICAgICAgICAgICAgICBzdHJtLm5leHRfb3V0ID0gdGFpbDsKICAgICAgICAgICAgICAgIHN0cm0uYXZhaWxfb3V0ID0gY2h1bmtTaXplIC0gdGFpbDsKICAgICAgICAgICAgICAgIGlmICh0YWlsKSB7CiAgICAgICAgICAgICAgICAgIHV0aWxzLmFycmF5U2V0KHN0cm0ub3V0cHV0LCBzdHJtLm91dHB1dCwgbmV4dF9vdXRfdXRmOCwgdGFpbCwgMCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB0aGlzLm9uRGF0YSh1dGY4c3RyKTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgdGhpcy5vbkRhdGEodXRpbHMuc2hyaW5rQnVmKHN0cm0ub3V0cHV0LCBzdHJtLm5leHRfb3V0KSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoc3RybS5hdmFpbF9pbiA9PT0gMCAmJiBzdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICBhbGxvd0J1ZkVycm9yID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICB9IHdoaWxlICgoc3RybS5hdmFpbF9pbiA+IDAgfHwgc3RybS5hdmFpbF9vdXQgPT09IDApICYmIHN0YXR1cyAhPT0gYy5aX1NUUkVBTV9FTkQpOwogICAgICAgIGlmIChzdGF0dXMgPT09IGMuWl9TVFJFQU1fRU5EKSB7CiAgICAgICAgICBfbW9kZSA9IGMuWl9GSU5JU0g7CiAgICAgICAgfQogICAgICAgIGlmIChfbW9kZSA9PT0gYy5aX0ZJTklTSCkgewogICAgICAgICAgc3RhdHVzID0gemxpYl9pbmZsYXRlLmluZmxhdGVFbmQodGhpcy5zdHJtKTsKICAgICAgICAgIHRoaXMub25FbmQoc3RhdHVzKTsKICAgICAgICAgIHRoaXMuZW5kZWQgPSB0cnVlOwogICAgICAgICAgcmV0dXJuIHN0YXR1cyA9PT0gYy5aX09LOwogICAgICAgIH0KICAgICAgICBpZiAoX21vZGUgPT09IGMuWl9TWU5DX0ZMVVNIKSB7CiAgICAgICAgICB0aGlzLm9uRW5kKGMuWl9PSyk7CiAgICAgICAgICBzdHJtLmF2YWlsX291dCA9IDA7CiAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIH07CiAgICAgIEluZmxhdGUyLnByb3RvdHlwZS5vbkRhdGEgPSBmdW5jdGlvbihjaHVuaykgewogICAgICAgIHRoaXMuY2h1bmtzLnB1c2goY2h1bmspOwogICAgICB9OwogICAgICBJbmZsYXRlMi5wcm90b3R5cGUub25FbmQgPSBmdW5jdGlvbihzdGF0dXMpIHsKICAgICAgICBpZiAoc3RhdHVzID09PSBjLlpfT0spIHsKICAgICAgICAgIGlmICh0aGlzLm9wdGlvbnMudG8gPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgIHRoaXMucmVzdWx0ID0gdGhpcy5jaHVua3Muam9pbigiIik7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICB0aGlzLnJlc3VsdCA9IHV0aWxzLmZsYXR0ZW5DaHVua3ModGhpcy5jaHVua3MpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICB0aGlzLmNodW5rcyA9IFtdOwogICAgICAgIHRoaXMuZXJyID0gc3RhdHVzOwogICAgICAgIHRoaXMubXNnID0gdGhpcy5zdHJtLm1zZzsKICAgICAgfTsKICAgICAgZnVuY3Rpb24gaW5mbGF0ZShpbnB1dCwgb3B0aW9ucykgewogICAgICAgIHZhciBpbmZsYXRvciA9IG5ldyBJbmZsYXRlMihvcHRpb25zKTsKICAgICAgICBpbmZsYXRvci5wdXNoKGlucHV0LCB0cnVlKTsKICAgICAgICBpZiAoaW5mbGF0b3IuZXJyKSB7CiAgICAgICAgICB0aHJvdyBpbmZsYXRvci5tc2cgfHwgbXNnW2luZmxhdG9yLmVycl07CiAgICAgICAgfQogICAgICAgIHJldHVybiBpbmZsYXRvci5yZXN1bHQ7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gaW5mbGF0ZVJhdyhpbnB1dCwgb3B0aW9ucyk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cmMvbG9uZy5qcwogIHZhciByZXF1aXJlX2xvbmcgPSBfX2NvbW1vbkpTKHsKICAgICJub2RlX21vZHVsZXMvLnBucG0vbG9uZ0A0LjAuMC9ub2RlX21vZHVsZXMvbG9uZy9zcmMvbG9uZy5qcyIoZXhwb3J0czIsIG1vZHVsZTIpIHsKICAgICAgaW5pdF9idWZmZXJfc2hpbSgpOwogICAgICBtb2R1bGUyLmV4cG9ydHMgPSBMb25nNDsKICAgICAgdmFyIHdhc20gPSBudWxsOwogICAgICB0cnkgewogICAgICAgIHdhc20gPSBuZXcgV2ViQXNzZW1ibHkuSW5zdGFuY2UobmV3IFdlYkFzc2VtYmx5Lk1vZHVsZShuZXcgVWludDhBcnJheShbCiAgICAgICAgICAwLAogICAgICAgICAgOTcsCiAgICAgICAgICAxMTUsCiAgICAgICAgICAxMDksCiAgICAgICAgICAxLAogICAgICAgICAgMCwKICAgICAgICAgIDAsCiAgICAgICAgICAwLAogICAgICAgICAgMSwKICAgICAgICAgIDEzLAogICAgICAgICAgMiwKICAgICAgICAgIDk2LAogICAgICAgICAgMCwKICAgICAgICAgIDEsCiAgICAgICAgICAxMjcsCiAgICAgICAgICA5NiwKICAgICAgICAgIDQsCiAgICAgICAgICAxMjcsCiAgICAgICAgICAxMjcsCiAgICAgICAgICAxMjcsCiAgICAgICAgICAxMjcsCiAgICAgICAgICAxLAogICAgICAgICAgMTI3LAogICAgICAgICAgMywKICAgICAgICAgIDcsCiAgICAgICAgICA2LAogICAgICAgICAgMCwKICAgICAgICAgIDEsCiAgICAgICAgICAxLAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICAxLAogICAgICAgICAgNiwKICAgICAgICAgIDYsCiAgICAgICAgICAxLAogICAgICAgICAgMTI3LAogICAgICAgICAgMSwKICAgICAgICAgIDY1LAogICAgICAgICAgMCwKICAgICAgICAgIDExLAogICAgICAgICAgNywKICAgICAgICAgIDUwLAogICAgICAgICAgNiwKICAgICAgICAgIDMsCiAgICAgICAgICAxMDksCiAgICAgICAgICAxMTcsCiAgICAgICAgICAxMDgsCiAgICAgICAgICAwLAogICAgICAgICAgMSwKICAgICAgICAgIDUsCiAgICAgICAgICAxMDAsCiAgICAgICAgICAxMDUsCiAgICAgICAgICAxMTgsCiAgICAgICAgICA5NSwKICAgICAgICAgIDExNSwKICAgICAgICAgIDAsCiAgICAgICAgICAyLAogICAgICAgICAgNSwKICAgICAgICAgIDEwMCwKICAgICAgICAgIDEwNSwKICAgICAgICAgIDExOCwKICAgICAgICAgIDk1LAogICAgICAgICAgMTE3LAogICAgICAgICAgMCwKICAgICAgICAgIDMsCiAgICAgICAgICA1LAogICAgICAgICAgMTE0LAogICAgICAgICAgMTAxLAogICAgICAgICAgMTA5LAogICAgICAgICAgOTUsCiAgICAgICAgICAxMTUsCiAgICAgICAgICAwLAogICAgICAgICAgNCwKICAgICAgICAgIDUsCiAgICAgICAgICAxMTQsCiAgICAgICAgICAxMDEsCiAgICAgICAgICAxMDksCiAgICAgICAgICA5NSwKICAgICAgICAgIDExNywKICAgICAgICAgIDAsCiAgICAgICAgICA1LAogICAgICAgICAgOCwKICAgICAgICAgIDEwMywKICAgICAgICAgIDEwMSwKICAgICAgICAgIDExNiwKICAgICAgICAgIDk1LAogICAgICAgICAgMTA0LAogICAgICAgICAgMTA1LAogICAgICAgICAgMTAzLAogICAgICAgICAgMTA0LAogICAgICAgICAgMCwKICAgICAgICAgIDAsCiAgICAgICAgICAxMCwKICAgICAgICAgIDE5MSwKICAgICAgICAgIDEsCiAgICAgICAgICA2LAogICAgICAgICAgNCwKICAgICAgICAgIDAsCiAgICAgICAgICAzNSwKICAgICAgICAgIDAsCiAgICAgICAgICAxMSwKICAgICAgICAgIDM2LAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICAxMjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDAsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMzIsCiAgICAgICAgICAyLAogICAgICAgICAgMTczLAogICAgICAgICAgMzIsCiAgICAgICAgICAzLAogICAgICAgICAgMTczLAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNCwKICAgICAgICAgIDEzMiwKICAgICAgICAgIDEyNiwKICAgICAgICAgIDM0LAogICAgICAgICAgNCwKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzUsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAzNiwKICAgICAgICAgIDAsCiAgICAgICAgICAzMiwKICAgICAgICAgIDQsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAxMSwKICAgICAgICAgIDM2LAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICAxMjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDAsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMzIsCiAgICAgICAgICAyLAogICAgICAgICAgMTczLAogICAgICAgICAgMzIsCiAgICAgICAgICAzLAogICAgICAgICAgMTczLAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNCwKICAgICAgICAgIDEzMiwKICAgICAgICAgIDEyNywKICAgICAgICAgIDM0LAogICAgICAgICAgNCwKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzUsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAzNiwKICAgICAgICAgIDAsCiAgICAgICAgICAzMiwKICAgICAgICAgIDQsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAxMSwKICAgICAgICAgIDM2LAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICAxMjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDAsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMzIsCiAgICAgICAgICAyLAogICAgICAgICAgMTczLAogICAgICAgICAgMzIsCiAgICAgICAgICAzLAogICAgICAgICAgMTczLAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNCwKICAgICAgICAgIDEzMiwKICAgICAgICAgIDEyOCwKICAgICAgICAgIDM0LAogICAgICAgICAgNCwKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzUsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAzNiwKICAgICAgICAgIDAsCiAgICAgICAgICAzMiwKICAgICAgICAgIDQsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAxMSwKICAgICAgICAgIDM2LAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICAxMjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDAsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMzIsCiAgICAgICAgICAyLAogICAgICAgICAgMTczLAogICAgICAgICAgMzIsCiAgICAgICAgICAzLAogICAgICAgICAgMTczLAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNCwKICAgICAgICAgIDEzMiwKICAgICAgICAgIDEyOSwKICAgICAgICAgIDM0LAogICAgICAgICAgNCwKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzUsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAzNiwKICAgICAgICAgIDAsCiAgICAgICAgICAzMiwKICAgICAgICAgIDQsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAxMSwKICAgICAgICAgIDM2LAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICAxMjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDAsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMzIsCiAgICAgICAgICAyLAogICAgICAgICAgMTczLAogICAgICAgICAgMzIsCiAgICAgICAgICAzLAogICAgICAgICAgMTczLAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNCwKICAgICAgICAgIDEzMiwKICAgICAgICAgIDEzMCwKICAgICAgICAgIDM0LAogICAgICAgICAgNCwKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzUsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAzNiwKICAgICAgICAgIDAsCiAgICAgICAgICAzMiwKICAgICAgICAgIDQsCiAgICAgICAgICAxNjcsCiAgICAgICAgICAxMQogICAgICAgIF0pKSwge30pLmV4cG9ydHM7CiAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgfQogICAgICBmdW5jdGlvbiBMb25nNChsb3csIGhpZ2gsIHVuc2lnbmVkKSB7CiAgICAgICAgdGhpcy5sb3cgPSBsb3cgfCAwOwogICAgICAgIHRoaXMuaGlnaCA9IGhpZ2ggfCAwOwogICAgICAgIHRoaXMudW5zaWduZWQgPSAhIXVuc2lnbmVkOwogICAgICB9CiAgICAgIExvbmc0LnByb3RvdHlwZS5fX2lzTG9uZ19fOwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoTG9uZzQucHJvdG90eXBlLCAiX19pc0xvbmdfXyIsIHsgdmFsdWU6IHRydWUgfSk7CiAgICAgIGZ1bmN0aW9uIGlzTG9uZyhvYmopIHsKICAgICAgICByZXR1cm4gKG9iaiAmJiBvYmpbIl9faXNMb25nX18iXSkgPT09IHRydWU7CiAgICAgIH0KICAgICAgTG9uZzQuaXNMb25nID0gaXNMb25nOwogICAgICB2YXIgSU5UX0NBQ0hFID0ge307CiAgICAgIHZhciBVSU5UX0NBQ0hFID0ge307CiAgICAgIGZ1bmN0aW9uIGZyb21JbnQodmFsdWUsIHVuc2lnbmVkKSB7CiAgICAgICAgdmFyIG9iaiwgY2FjaGVkT2JqLCBjYWNoZTsKICAgICAgICBpZiAodW5zaWduZWQpIHsKICAgICAgICAgIHZhbHVlID4+Pj0gMDsKICAgICAgICAgIGlmIChjYWNoZSA9IDAgPD0gdmFsdWUgJiYgdmFsdWUgPCAyNTYpIHsKICAgICAgICAgICAgY2FjaGVkT2JqID0gVUlOVF9DQUNIRVt2YWx1ZV07CiAgICAgICAgICAgIGlmIChjYWNoZWRPYmopCiAgICAgICAgICAgICAgcmV0dXJuIGNhY2hlZE9iajsKICAgICAgICAgIH0KICAgICAgICAgIG9iaiA9IGZyb21CaXRzKHZhbHVlLCAodmFsdWUgfCAwKSA8IDAgPyAtMSA6IDAsIHRydWUpOwogICAgICAgICAgaWYgKGNhY2hlKQogICAgICAgICAgICBVSU5UX0NBQ0hFW3ZhbHVlXSA9IG9iajsKICAgICAgICAgIHJldHVybiBvYmo7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHZhbHVlIHw9IDA7CiAgICAgICAgICBpZiAoY2FjaGUgPSAtMTI4IDw9IHZhbHVlICYmIHZhbHVlIDwgMTI4KSB7CiAgICAgICAgICAgIGNhY2hlZE9iaiA9IElOVF9DQUNIRVt2YWx1ZV07CiAgICAgICAgICAgIGlmIChjYWNoZWRPYmopCiAgICAgICAgICAgICAgcmV0dXJuIGNhY2hlZE9iajsKICAgICAgICAgIH0KICAgICAgICAgIG9iaiA9IGZyb21CaXRzKHZhbHVlLCB2YWx1ZSA8IDAgPyAtMSA6IDAsIGZhbHNlKTsKICAgICAgICAgIGlmIChjYWNoZSkKICAgICAgICAgICAgSU5UX0NBQ0hFW3ZhbHVlXSA9IG9iajsKICAgICAgICAgIHJldHVybiBvYmo7CiAgICAgICAgfQogICAgICB9CiAgICAgIExvbmc0LmZyb21JbnQgPSBmcm9tSW50OwogICAgICBmdW5jdGlvbiBmcm9tTnVtYmVyKHZhbHVlLCB1bnNpZ25lZCkgewogICAgICAgIGlmIChpc05hTih2YWx1ZSkpCiAgICAgICAgICByZXR1cm4gdW5zaWduZWQgPyBVWkVSTyA6IFpFUk87CiAgICAgICAgaWYgKHVuc2lnbmVkKSB7CiAgICAgICAgICBpZiAodmFsdWUgPCAwKQogICAgICAgICAgICByZXR1cm4gVVpFUk87CiAgICAgICAgICBpZiAodmFsdWUgPj0gVFdPX1BXUl82NF9EQkwpCiAgICAgICAgICAgIHJldHVybiBNQVhfVU5TSUdORURfVkFMVUU7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGlmICh2YWx1ZSA8PSAtVFdPX1BXUl82M19EQkwpCiAgICAgICAgICAgIHJldHVybiBNSU5fVkFMVUU7CiAgICAgICAgICBpZiAodmFsdWUgKyAxID49IFRXT19QV1JfNjNfREJMKQogICAgICAgICAgICByZXR1cm4gTUFYX1ZBTFVFOwogICAgICAgIH0KICAgICAgICBpZiAodmFsdWUgPCAwKQogICAgICAgICAgcmV0dXJuIGZyb21OdW1iZXIoLXZhbHVlLCB1bnNpZ25lZCkubmVnKCk7CiAgICAgICAgcmV0dXJuIGZyb21CaXRzKHZhbHVlICUgVFdPX1BXUl8zMl9EQkwgfCAwLCB2YWx1ZSAvIFRXT19QV1JfMzJfREJMIHwgMCwgdW5zaWduZWQpOwogICAgICB9CiAgICAgIExvbmc0LmZyb21OdW1iZXIgPSBmcm9tTnVtYmVyOwogICAgICBmdW5jdGlvbiBmcm9tQml0cyhsb3dCaXRzLCBoaWdoQml0cywgdW5zaWduZWQpIHsKICAgICAgICByZXR1cm4gbmV3IExvbmc0KGxvd0JpdHMsIGhpZ2hCaXRzLCB1bnNpZ25lZCk7CiAgICAgIH0KICAgICAgTG9uZzQuZnJvbUJpdHMgPSBmcm9tQml0czsKICAgICAgdmFyIHBvd19kYmwgPSBNYXRoLnBvdzsKICAgICAgZnVuY3Rpb24gZnJvbVN0cmluZyhzdHIsIHVuc2lnbmVkLCByYWRpeCkgewogICAgICAgIGlmIChzdHIubGVuZ3RoID09PSAwKQogICAgICAgICAgdGhyb3cgRXJyb3IoImVtcHR5IHN0cmluZyIpOwogICAgICAgIGlmIChzdHIgPT09ICJOYU4iIHx8IHN0ciA9PT0gIkluZmluaXR5IiB8fCBzdHIgPT09ICIrSW5maW5pdHkiIHx8IHN0ciA9PT0gIi1JbmZpbml0eSIpCiAgICAgICAgICByZXR1cm4gWkVSTzsKICAgICAgICBpZiAodHlwZW9mIHVuc2lnbmVkID09PSAibnVtYmVyIikgewogICAgICAgICAgcmFkaXggPSB1bnNpZ25lZCwgdW5zaWduZWQgPSBmYWxzZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgdW5zaWduZWQgPSAhIXVuc2lnbmVkOwogICAgICAgIH0KICAgICAgICByYWRpeCA9IHJhZGl4IHx8IDEwOwogICAgICAgIGlmIChyYWRpeCA8IDIgfHwgMzYgPCByYWRpeCkKICAgICAgICAgIHRocm93IFJhbmdlRXJyb3IoInJhZGl4Iik7CiAgICAgICAgdmFyIHA7CiAgICAgICAgaWYgKChwID0gc3RyLmluZGV4T2YoIi0iKSkgPiAwKQogICAgICAgICAgdGhyb3cgRXJyb3IoImludGVyaW9yIGh5cGhlbiIpOwogICAgICAgIGVsc2UgaWYgKHAgPT09IDApIHsKICAgICAgICAgIHJldHVybiBmcm9tU3RyaW5nKHN0ci5zdWJzdHJpbmcoMSksIHVuc2lnbmVkLCByYWRpeCkubmVnKCk7CiAgICAgICAgfQogICAgICAgIHZhciByYWRpeFRvUG93ZXIgPSB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AmPSA2NTUzNTsKICAgICAgICBjNDggKz0gYTQ4ICsgYjQ4OwogICAgICAgIGM0OCAmPSA2NTUzNTsKICAgICAgICByZXR1cm4gZnJvbUJpdHMoYzE2IDw8IDE2IHwgYzAwLCBjNDggPDwgMTYgfCBjMzIsIHRoaXMudW5zaWduZWQpOwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlLnN1YnRyYWN0ID0gZnVuY3Rpb24gc3VidHJhY3Qoc3VidHJhaGVuZCkgewogICAgICAgIGlmICghaXNMb25nKHN1YnRyYWhlbmQpKQogICAgICAgICAgc3VidHJhaGVuZCA9IGZyb21WYWx1ZShzdWJ0cmFoZW5kKTsKICAgICAgICByZXR1cm4gdGhpcy5hZGQoc3VidHJhaGVuZC5uZWcoKSk7CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUuc3ViID0gTG9uZ1Byb3RvdHlwZS5zdWJ0cmFjdDsKICAgICAgTG9uZ1Byb3RvdHlwZS5tdWx0aXBseSA9IGZ1bmN0aW9uIG11bHRpcGx5KG11bHRpcGxpZXIpIHsKICAgICAgICBpZiAodGhpcy5pc1plcm8oKSkKICAgICAgICAgIHJldHVybiBaRVJPOwogICAgICAgIGlmICghaXNMb25nKG11bHRpcGxpZXIpKQogICAgICAgICAgbXVsdGlwbGllciA9IGZyb21WYWx1ZShtdWx0aXBsaWVyKTsKICAgICAgICBpZiAod2FzbSkgewogICAgICAgICAgdmFyIGxvdyA9IHdhc20ubXVsKHRoaXMubG93LCB0aGlzLmhpZ2gsIG11bHRpcGxpZXIubG93LCBtdWx0aXBsaWVyLmhpZ2gpOwogICAgICAgICAgcmV0dXJuIGZyb21CaXRzKGxvdywgd2FzbS5nZXRfaGlnaCgpLCB0aGlzLnVuc2lnbmVkKTsKICAgICAgICB9CiAgICAgICAgaWYgKG11bHRpcGxpZXIuaXNaZXJvKCkpCiAgICAgICAgICByZXR1cm4gWkVSTzsKICAgICAgICBpZiAodGhpcy5lcShNSU5fVkFMVUUpKQogICA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GlmICghaXNMb25nKGRpdmlzb3IpKQogICAgICAgICAgZGl2aXNvciA9IGZyb21WYWx1ZShkaXZpc29yKTsKICAgICAgICBpZiAoZGl2aXNvci5pc1plcm8oKSkKICAgICAgICAgIHRocm93IEVycm9yKCJkaXZpc2lvbiBieSB6ZXJvIik7CiAgICAgICAgaWYgKHdhc20pIHsKICAgICAgICAgIGlmICghdGhpcy51bnNpZ25lZCAmJiB0aGlzLmhpZ2ggPT09IC0yMTQ3NDgzNjQ4ICYmIGRpdmlzb3IubG93ID09PSAtMSAmJiBkaXZpc29yLmhpZ2ggPT09IC0xKSB7CiAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgfQogICAgICAgICAgdmFyIGxvdyA9ICh0aGlzLnVuc2lnbmVkID8gd2FzbS5kaXZfdSA6IHdhc20uZGl2X3MpKHRoaXMubG93LCB0aGlzLmhpZ2gsIGRpdmlzb3IubG93LCBkaXZpc29yLmhpZ2gpOwogICAgICAgICAgcmV0dXJuIGZyb21CaXRzKGxvdywgd2FzbS5nZXRfaGlnaCgpLCB0aGlzLnVuc2lnbmVkKTsKICAgICAgICB9CiAgICAgICAgaWYgKHRoaXMuaXNaZXJvKCkpCiAgICAgICAgICByZXR1cm4gdGhpcy51bnNpZ25lZCA/IFVaRVJPIDogWkVSTzsKICAgICAgICB2YXIgYXBwcm94LCByZW0sIHJlczsKICAgICAgICBpZiAoIXRoaXMudW5zaWduZWQpIHsKICAgICAgICAgIGlmICh0aGlzLmVxKE1JTl9WQUxVRSkpIHsKICAgICAgICAgICAgaWYgKGRpdmlzb3IuZXEoT05FKSB8fCBkaXZpc29yLmVxKE5FR19PTkUpKQogICAgICAgICAgICAgIHJldHVybiBNSU5fVkFMVUU7CiAgICAgICAgICAgIGVsc2UgaWYgKGRpdmlzb3IuZXEoTUlOX1ZBTFVFKSkKICAgICAgICAgICAgICByZXR1cm4gT05FOwogICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICB2YXIgaGFsZlRoaXMgPSB0aGlzLnNocigxKTsKICAgICAgICAgICAgICBhcHByb3ggPSBoYWxmVGhpcy5kaXYoZGl2aXNvcikuc2hsKDEpOwogICAgICAgICAgICAgIGlmIChhcHByb3guZXEoWkVSTykpIHsKICAgICAgICAgICAgICAgIHJldHVybiBkaXZpc29yLmlzTmVnYXRpdmUoKSA/IE9ORSA6IE5FR19PTkU7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHJlbSA9IHRoaXMuc3ViKGRpdmlzb3IubXVsKGFwcHJveCkpOwogICAgICAgICAgICAgICAgcmVzID0gYXBwcm94LmFkZChyZW0uZGl2KGRpdmlzb3IpKTsKICAgICAgICAgICAgICAgIHJldHVybiByZXM7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgaWYgKGRpdmlzb3IuZXEoTUlOX1ZBTFVFKSkKICAgICAgICAgICAgcmV0dXJuIHRoaXMudW5zaWduZWQgPyBVWkVSTyA6IFpFUk87CiAgICAgICAgICBpZiAodGhpcy5pc05lZ2F0aXZlKCkpIHsKICAgICAgICAgICAgaWYgKGRpdmlzb3IuaXNOZWdhdGl2ZSgpKQogICAgICAgICAgICAgIHJldHVybiB0aGlzLm5lZygpLmRpdihkaXZpc29yLm5lZygpKTsKICAgICAgICAgICAgcmV0dXJuIHRoaXMubmVnKCkuZGl2KGRpdmlzb3IpLm5lZygpOwogICAgICAgICAgfSBlbHNlIGlmIChkaXZpc29yLmlzTmVnYXRpdmUoKSkKICAgICAgICAgICAgcmV0dXJuIHRoaXMuZGl2KGRpdmlzb3IubmVnKCkpLm5lZygpOwogICAgICAgICAgcmVzID0gWkVSTzsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgaWYgKCFkaXZpc29yLnVuc2lnbmVkKQogICAgICAgICAgICBkaXZpc29yID0gZGl2aXNvci50b1Vuc2lnbmVkKCk7CiAgICAgICAgICBpZiAoZGl2aXNvci5ndCh0aGlzKSkKICAgICAgICAgICAgcmV0dXJuIFVaRVJPOwogICAgICAgICAgaWYgKGRpdmlzb3IuZ3QodGhpcy5zaHJ1KDEpKSkKICAgICAgICAgICAgcmV0dXJuIFVPTkU7CiAgICAgICAgICByZXMgPSBVWkVSTzsKICAgICAgICB9CiAgICAgICAgcmVtID0gdGhpczsKICAgICAgICB3aGlsZSAocmVtLmd0ZShkaXZpc29yKSkgewogICAgICAgICAgYXBwcm94ID0gTWF0aC5tYXgoMSwgTWF0aC5mbG9vcihyZW0udG9OdW1iZXIoKSAvIGRpdmlzb3IudG9OdW1iZXIoKSkpOwogICAgICAgICAgdmFyIGxvZzIgPSBNYXRoLmNlaWwoTWF0aC5sb2coYXBwcm94KSAvIE1hdGguTE4yKSwgZGVsdGEgPSBsb2cyIDw9IDQ4ID8gMSA6IHBvd19kYmwoMiwgbG9nMiAtIDQ4KSwgYXBwcm94UmVzID0gZnJvbU51bWJlcihhcHByb3gpLCBhcHByb3hSZW0gPSBhcHByb3hSZXMubXVsKGRpdmlzb3IpOwogICAgICAgICAgd2hpbGUgKGFwcHJveFJlbS5pc05lZ2F0aXZlKCkgfHwgYXBwcm94UmVtLmd0KHJlbSkpIHsKICAgICAgICAgICAgYXBwcm94IC09IGRlbHRhOwogICAgICAgICAgICBhcHByb3hSZXMgPSBmcm9tTnVtYmVyKGFwcHJveCwgdGhpcy51bnNpZ25lZCk7CiAgICAgICAgICAgIGFwcHJveFJlbSA9IGFwcHJveFJlcy5tdWwoZGl2aXNvcik7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYXBwcm94UmVzLmlzWmVybygpKQogICAgICAgICAgICBhcHByb3hSZXMgPSBPTkU7CiAgICAgICAgICByZXMgPSByZXMuYWRkKGFwcHJveFJlcyk7CiAgICAgICAgICByZW0gPSByZW0uc3ViKGFwcHJveFJlbSk7CiAgICAgICAgfQogICAgICAgIHJldHVybiByZXM7CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUuZGl2ID0gTG9uZ1Byb3RvdHl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lwZS5vciA9IGZ1bmN0aW9uIG9yKG90aGVyKSB7CiAgICAgICAgaWYgKCFpc0xvbmcob3RoZXIpKQogICAgICAgICAgb3RoZXIgPSBmcm9tVmFsdWUob3RoZXIpOwogICAgICAgIHJldHVybiBmcm9tQml0cyh0aGlzLmxvdyB8IG90aGVyLmxvdywgdGhpcy5oaWdoIHwgb3RoZXIuaGlnaCwgdGhpcy51bnNpZ25lZCk7CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUueG9yID0gZnVuY3Rpb24geG9yKG90aGVyKSB7CiAgICAgICAgaWYgKCFpc0xvbmcob3RoZXIpKQogICAgICAgICAgb3RoZXIgPSBmcm9tVmFsdWUob3RoZXIpOwogICAgICAgIHJldHVybiBmcm9tQml0cyh0aGlzLmxvdyBeIG90aGVyLmxvdywgdGhpcy5oaWdoIF4gb3RoZXIuaGlnaCwgdGhpcy51bnNpZ25lZCk7CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUuc2hpZnRMZWZ0ID0gZnVuY3Rpb24gc2hpZnRMZWZ0KG51bUJpdHMpIHsKICAgICAgICBpZiAoaXNMb25nKG51bUJpdHMpKQogICAgICAgICAgbnVtQml0cyA9IG51bUJpdHMudG9JbnQoKTsKICAgICAgICBpZiAoKG51bUJpdHMgJj0gNjMpID09PSAwKQogICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgZWxzZSBpZiAobnVtQml0cyA8IDMyKQogICAgICAgICAgcmV0dXJuIGZyb21CaXRzKHRoaXMubG93IDw8IG51bUJpdHMsIHRoaXMuaGlnaCA8PCBudW1CaXRzIHwgdGhpcy5sb3cgPj4+IDMyIC0gbnVtQml0cywgdGhpcy51bnNpZ25lZCk7CiAgICAgICAgZWxzZQogICAgICAgICAgcmV0dXJuIGZyb21CaXRzKDAsIHRoaXMubG93IDw8IG51bUJpdHMgLSAzMiwgdGhpcy51bnNpZ25lZCk7CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUuc2hsID0gTG9uZ1Byb3RvdHlwZS5zaGlmdExlZnQ7CiAgICAgIExvbmdQcm90b3R5cGUuc2hpZnRSaWdodCA9IGZ1bmN0aW9uIHNoaWZ0UmlnaHQobnVtQml0cykgewogICAgICAgIGlmIChpc0xvbmcobnVtQml0cykpCiAgICAgICAgICBudW1CaXRzID0gbnVtQml0cy50b0ludCgpOwogICAgICAgIGlmICgobnVtQml0cyAmPSA2MykgPT09IDApCiAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICBlbHNlIGlmIChudW1CaXRzIDwgMzIpCiAgICAgICAgICByZXR1cm4gZnJvbUJpdHModGhpcy5sb3cgPj4+IG51bUJpdHMgfCB0aGlzLmhpZ2ggPDwgMzIgLSBudW1CaXRzLCB0aGlzLmhpZ2ggPj4gbnVtQml0cywgdGhpcy51bnNpZ25lZCk7CiAgICAgICAgZWxzZQogICAgICAgICAgcmV0dXJuIGZyb21CaXRzKHRoaXMuaGlnaCA+PiBudW1CaXRzIC0gMzIsIHRoaXMuaGlnaCA+PSAwID8gMCA6IC0xLCB0aGlzLnVuc2lnbmVkKTsKICAgICAgfTsKICAgICAgTG9uZ1Byb3RvdHlwZS5zaHIgPSBMb25nUHJvdG90eXBlLnNoaWZ0UmlnaHQ7CiAgICAgIExvbmdQcm90b3R5cGUuc2hpZnRSaWdodFVuc2lnbmVkID0gZnVuY3Rpb24gc2hpZnRSaWdodFVuc2lnbmVkKG51bUJpdHMpIHsKICAgICAgICBpZiAoaXNMb25nKG51bUJpdHMpKQogICAgICAgICAgbnVtQml0cyA9IG51bUJpdHMudG9JbnQoKTsKICAgICAgICBudW1CaXRzICY9IDYzOwogICAgICAgIGlmIChudW1CaXRzID09PSAwKQogICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgZWxzZSB7CiAgICAgICAgICB2YXIgaGlnaCA9IHRoaXMuaGlnaDsKICAgICAgICAgIGlmIChudW1CaXRzIDwgMzIpIHsKICAgICAgICAgICAgdmFyIGxvdyA9IHRoaXMubG93OwogICAgICAgICAgICByZXR1cm4gZnJvbUJpdHMobG93ID4+PiBudW1CaXRzIHwgaGlnaCA8PCAzMiAtIG51bUJpdHMsIGhpZ2ggPj4+IG51bUJpdHMsIHRoaXMudW5zaWduZWQpOwogICAgICAgICAgfSBlbHNlIGlmIChudW1CaXRzID09PSAzMikKICAgICAgICAgICAgcmV0dXJuIGZyb21CaXRzKGhpZ2gsIDAsIHRoaXMudW5zaWduZWQpOwogICAgICAgICAgZWxzZQogICAgICAgICAgICByZXR1cm4gZnJvbUJpdHMoaGlnaCA+Pj4gbnVtQml0cyAtIDMyLCAwLCB0aGlzLnVuc2lnbmVkKTsKICAgICAgICB9CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUuc2hydSA9IExvbmdQcm90b3R5cGUuc2hpZnRSaWdodFVuc2lnbmVkOwogICAgICBMb25nUHJvdG90eXBlLnNocl91ID0gTG9uZ1Byb3RvdHlwZS5zaGlmdFJpZ2h0VW5zaWduZWQ7CiAgICAgIExvbmdQcm90b3R5cGUudG9TaWduZWQgPSBmdW5jdGlvbiB0b1NpZ25lZCgpIHsKICAgICAgICBpZiAoIXRoaXMudW5zaWduZWQpCiAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICByZXR1cm4gZnJvbUJpdHModGhpcy5sb3csIHRoaXMuaGlnaCwgZmFsc2UpOwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlLnRvVW5zaWduZWQgPSBmdW5jdGlvbiB0b1Vuc2lnbmVkKCkgewogICAgICAgIGlmICh0aGlzLnVuc2lnbmVkKQogICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgcmV0dXJuIGZyb21CaXRzKHRoaXMubG93LCB0aGlzLmhpZ2gsIHRydWUpOwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlLnRvQnl0ZXMgPSBmdW5jdGlvbiB0b0J5dGVzKGxlKSB7CiAgICAgICAgcmV0dXJuIGxlID8gdGhpcy50b0J5dGVzTEUoKSA6IHRoa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gY29uc3QgZmFsbGJhY2tEZXNlcmlhbGl6ZXIgPSBleHRlbmQuZGVzZXJpYWxpemUuYmluZChleHRlbmQpOwogICAgICAgIGNvbnN0IGZhbGxiYWNrU2VyaWFsaXplciA9IGV4dGVuZC5zZXJpYWxpemUuYmluZChleHRlbmQpOwogICAgICAgIHJldHVybiB7CiAgICAgICAgICBkZXNlcmlhbGl6ZShtZXNzYWdlKSB7CiAgICAgICAgICAgIHJldHVybiBpbXBsZW1lbnRhdGlvbi5kZXNlcmlhbGl6ZShtZXNzYWdlLCBmYWxsYmFja0Rlc2VyaWFsaXplcik7CiAgICAgICAgICB9LAogICAgICAgICAgc2VyaWFsaXplKGlucHV0KSB7CiAgICAgICAgICAgIHJldHVybiBpbXBsZW1lbnRhdGlvbi5zZXJpYWxpemUoaW5wdXQsIGZhbGxiYWNrU2VyaWFsaXplcik7CiAgICAgICAgICB9CiAgICAgICAgfTsKICAgICAgfQogICAgICBleHBvcnRzMi5leHRlbmRTZXJpYWxpemVyID0gZXh0ZW5kU2VyaWFsaXplcjsKICAgICAgdmFyIERlZmF1bHRFcnJvclNlcmlhbGl6ZXIgPSB7CiAgICAgICAgZGVzZXJpYWxpemUobWVzc2FnZSkgewogICAgICAgICAgcmV0dXJuIE9iamVjdC5hc3NpZ24oRXJyb3IobWVzc2FnZS5tZXNzYWdlKSwgewogICAgICAgICAgICBuYW1lOiBtZXNzYWdlLm5hbWUsCiAgICAgICAgICAgIHN0YWNrOiBtZXNzYWdlLnN0YWNrCiAgICAgICAgICB9KTsKICAgICAgICB9LAogICAgICAgIHNlcmlhbGl6ZShlcnJvcikgewogICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgX19lcnJvcl9tYXJrZXI6ICIkJGVycm9yIiwKICAgICAgICAgICAgbWVzc2FnZTogZXJyb3IubWVzc2FnZSwKICAgICAgICAgICAgbmFtZTogZXJyb3IubmFtZSwKICAgICAgICAgICAgc3RhY2s6IGVycm9yLnN0YWNrCiAgICAgICAgICB9OwogICAgICAgIH0KICAgICAgfTsKICAgICAgdmFyIGlzU2VyaWFsaXplZEVycm9yID0gKHRoaW5nKSA9PiB0aGluZyAmJiB0eXBlb2YgdGhpbmcgPT09ICJvYmplY3QiICYmICJfX2Vycm9yX21hcmtlciIgaW4gdGhpbmcgJiYgdGhpbmcuX19lcnJvcl9tYXJrZXIgPT09ICIkJGVycm9yIjsKICAgICAgZXhwb3J0czIuRGVmYXVsdFNlcmlhbGl6ZXIgPSB7CiAgICAgICAgZGVzZXJpYWxpemUobWVzc2FnZSkgewogICAgICAgICAgaWYgKGlzU2VyaWFsaXplZEVycm9yKG1lc3NhZ2UpKSB7CiAgICAgICAgICAgIHJldHVybiBEZWZhdWx0RXJyb3JTZXJpYWxpemVyLmRlc2VyaWFsaXplKG1lc3NhZ2UpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcmV0dXJuIG1lc3NhZ2U7CiAgICAgICAgICB9CiAgICAgICAgfSwKICAgICAgICBzZXJpYWxpemUoaW5wdXQpIHsKICAgICAgICAgIGlmIChpbnB1dCBpbnN0YW5jZW9mIEVycm9yKSB7CiAgICAgICAgICAgIHJldHVybiBEZWZhdWx0RXJyb3JTZXJpYWxpemVyLnNlcmlhbGl6ZShpbnB1dCk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICByZXR1cm4gaW5wdXQ7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9OwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLnBucG0vdGhyZWFkc0AxLjcuMC9ub2RlX21vZHVsZXMvdGhyZWFkcy9kaXN0L2NvbW1vbi5qcwogIHZhciByZXF1aXJlX2NvbW1vbjIgPSBfX2NvbW1vbkpTKHsKICAgICJub2RlX21vZHVsZXMvLnBucG0vdGhyZWFkc0AxLjcuMC9ub2RlX21vZHVsZXMvdGhyZWFkcy9kaXN0L2NvbW1vbi5qcyIoZXhwb3J0czIpIHsKICAgICAgaW5pdF9idWZmZXJfc2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sKICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgIHJlamVjdChlKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgZnVuY3Rpb24gcmVqZWN0ZWQodmFsdWUpIHsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOwogICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgcmVqZWN0KGUpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgewogICAgICAgICAgICByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsKICAgICAgICAgIH0KICAgICAgICAgIHN0ZXAoKGdlbmVyYXRvciA9IGdlbmVyYXRvci5hcHBseSh0aGlzQXJnLCBfYXJndW1lbnRzIHx8IFtdKSkubmV4dCgpKTsKICAgICAgICB9KTsKICAgICAgfTsKICAgICAgdmFyIF9faW1wb3J0RGVmYXVsdCA9IGV4cG9ydHMyICYmIGV4cG9ydHMyLl9faW1wb3J0RGVmYXVsdCB8fCBmdW5jdGlvbihtb2QpIHsKICAgICAgICByZXR1cm4gbW9kICYmIG1vZC5fX2VzTW9kdWxlID8gbW9kIDogeyAiZGVmYXVsdCI6IG1vZCB9OwogICAgICB9OwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0czIsICJfX2VzTW9kdWxlIiwgeyB2YWx1ZTogdHJ1ZSB9KTsKICAgICAgZXhwb3J0czIuZXhwb3NlID0gZXhwb3J0czIuaXNXb3JrZXJSdW50aW1lID0gZXhwb3J0czIuVHJhbnNmZXIgPSBleHBvcnRzMi5yZWdpc3RlclNlcmlhbGl6ZXIgPSB2b2lkIDA7CiAgICAgIHZhciBpc19v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mZXRjaC5iaW5kKGdsb2JhbFRoaXMpOwogICAgICBpZiAoIWZldGNoKSB7CiAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcihgbm8gZmV0Y2ggZnVuY3Rpb24gc3VwcGxpZWQsIGFuZCBub25lIGZvdW5kIGluIGdsb2JhbCBlbnZpcm9ubWVudGApOwogICAgICB9CiAgICAgIGlmIChvcHRzLm92ZXJyaWRlcykgewogICAgICAgIHRoaXMuYmFzZU92ZXJyaWRlcyA9IG9wdHMub3ZlcnJpZGVzOwogICAgICB9CiAgICAgIHRoaXMuZmV0Y2hJbXBsZW1lbnRhdGlvbiA9IGZldGNoOwogICAgfQogICAgYXN5bmMgZmV0Y2goaW5wdXQsIGluaXQyKSB7CiAgICAgIGxldCByZXNwb25zZTsKICAgICAgdHJ5IHsKICAgICAgICByZXNwb25zZSA9IGF3YWl0IHRoaXMuZmV0Y2hJbXBsZW1lbnRhdGlvbihpbnB1dCwgaW5pdDIpOwogICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgaWYgKGAke2V9YC5pbmNsdWRlcygiRmFpbGVkIHRvIGZldGNoIikpIHsKICAgICAgICAgIGNvbnNvbGUud2FybihgZ2VuZXJpYy1maWxlaGFuZGxlOiByZWZldGNoaW5nICR7aW5wdXR9IHRvIGF0dGVtcHQgdG8gd29yayBhcm91bmQgY2hyb21lIENPUlMgaGVhZGVyIGNhY2hpbmcgYnVnYCk7CiAgICAgICAgICByZXNwb25zZSA9IGF3YWl0IHRoaXMuZmV0Y2hJbXBsZW1lbnRhdGlvbihpbnB1dCwgewogICAgICAgICAgICAuLi5pbml0MiwKICAgICAgICAgICAgY2FjaGU6ICJyZWxvYWQiCiAgICAgICAgICB9KTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgdGhyb3cgZTsKICAgICAgICB9CiAgICAgIH0KICAgICAgcmV0dXJuIHJlc3BvbnNlOwogICAgfQogICAgYXN5bmMgcmVhZChidWZmZXIsIG9mZnNldCA9IDAsIGxlbmd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uc3RhdHVzID09PSAyMDYpIHsKICAgICAgICBjb25zdCByZXNwb25zZURhdGEgPSBhd2FpdCB0aGlzLmdldEJ1ZmZlckZyb21SZXNwb25zZShyZXNwb25zZSk7CiAgICAgICAgY29uc3QgYnl0ZXNDb3BpZWQgPSByZXNwb25zZURhdGEuY29weShidWZmZXIsIG9mZnNldCwgMCwgTWF0aC5taW4obGVuZ3RoLCByZXNwb25zZURhdGEubGVuZ3RoKSk7CiAgICAgICAgY29uc3QgcmVzID0gcmVzcG9uc2UuaGVhZGVycy5nZXQoImNvbnRlbnQtcmFuZ2UiKTsKICAgICAgICBjb25zdCBzaXplTWF0Y2ggPSAvXC8oXGQrKSQvLmV4ZWMocmVzIHx8ICIiKTsKICAgICAgICBpZiAoc2l6ZU1hdGNoICYmIHNpemVNYXRjaFsxXSkgewogICAgICAgICAgdGhpcy5fc3RhdCA9IHsgc2l6ZTogcGFyc2VJbnQoc2l6ZU1hdGNoWzFdLCAxMCkgfTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHsgYnl0ZXNSZWFkOiBieXRlc0NvcGllZCwgYnVmZmVyIH07CiAgICAgIH0KICAgICAgaWYgKHJlc3BvbnNlLnN0YXR1cyA9PT0gMjAwKSB7CiAgICAgICAgdGhyb3cgbmV3IEVycm9yKCIke3RoaXMudXJsfSBmZXRjaCByZXR1cm5lZCBzdGF0dXMgMjAwLCBleHBlY3RlZCAyMDYiKTsKICAgICAgfQogICAgICB0aHJvdyBuZXcgRXJyb3IoYEhUVFAgJHtyZXNwb25zZS5zdGF0dXN9IGZldGNoaW5nICR7dGhpcy51cmx9YCk7CiAgICB9CiAgICBhc3luYyByZWFkRmlsZShvcHRpb25zID0ge30pIHsKICAgICAgbGV0IGVuY29kaW5nOwogICAgICBsZXQgb3B0czsKICAgICAgaWYgKHR5cGVvZiBvcHRpb25zID09PSAic3RyaW5nIikgewogICAgICAgIGVuY29kaW5nID0gb3B0aW9uczsKICAgICAgICBvcHRzID0ge307CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZW5jb2RpbmcgPSBvcHRpb25zLmVuY29kaW5nOwogICAgICAgIG9wdHMgPSBvcHRpb25zOwogICAgICAgIGRlbGV0ZSBvcHRzLmVuY29kaW5nOwogICAgICB9CiAgICAgIGNvbnN0IHsgaGVhZGVycyA9IHt9LCBzaWduYWwsIG92ZXJyaWRlcyA9IHt9IH0gPSBvcHRzOwogICAgICBjb25zdCBhcmdzID0gewogICAgICAgIGhlYWRlcnMsCiAgICAgICAgbWV0aG9kOiAiR0VUIiwKICAgICAgICByZWRpcmVjdDogImZvbGxvdyIsCiAgICAgICAgbW9kZTogImNvcnMiLAogICAgICAgIHNpZ25hbCwKICAgICAgICAuLi50aGlzLmJhc2VPdmVycmlkZXMsCiAgICAgICAgLi4ub3ZlcnJpZGVzCiAgICAgIH07CiAgICAgIGNvbnN0IHJlc3BvbnNlID0gYXdhaXQgdGhpcy5mZXRjaCh0aGlzLnVybCwgYXJncyk7CiAgICAgIGlmICghcmVzcG9uc2UpIHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoImdlbmVyaWMtZmlsZWhhbmRsZSBmYWlsZWQgdG8gZmV0Y2giKTsKICAgICAgfQogICAgICBpZiAocmVzcG9uc2Uuc3RhdHVzICE9PSAyMDApIHsKICAgICAgICB0aHJvdyBPYmplY3QuYXNzaWduKG5ldyBFcnJvcihgSFRUUCAke3Jlc3BvbnNlLnN0YXR1c30gZmV0Y2hpbmcgJHt0aGlzLnVybH1gKSwgewogICAgICAgICAgc3RhdHVzOiByZXNwb25zZS5zdGF0dXMKICAgICAgICB9KTsKICAgICAgfQogICAgICBpZiAoZW5jb2RpbmcgPT09ICJ1dGY4IikgewogICAgICAgIHJldHVybiByZXNwb25zZS50ZXh0KCk7CiAgICAgIH0KICAgICAgaWYgKGVuY29kaW5nKSB7CiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGB1bnN1cHBvcnRlZCBlbmNvZGluZzogJHtlbmNvZGluZ31gKTsKICAgICA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G9yLmVycikgewogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGluZmxhdG9yLm1zZyk7CiAgICAgICAgfQogICAgICAgIHBvcyArPSBzdHJtLm5leHRfaW47CiAgICAgICAgY2h1bmtzW2ldID0gaW5mbGF0b3IucmVzdWx0OwogICAgICAgIHRvdGFsU2l6ZSArPSBjaHVua3NbaV0ubGVuZ3RoOwogICAgICAgIGkgKz0gMTsKICAgICAgfSB3aGlsZSAoc3RybS5hdmFpbF9pbik7CiAgICAgIGNvbnN0IHJlc3VsdCA9IG5ldyBVaW50OEFycmF5KHRvdGFsU2l6ZSk7CiAgICAgIGZvciAobGV0IGkyID0gMCwgb2Zmc2V0ID0gMDsgaTIgPCBjaHVua3MubGVuZ3RoOyBpMisrKSB7CiAgICAgICAgcmVzdWx0LnNldChjaHVua3NbaTJdLCBvZmZzZXQpOwogICAgICAgIG9mZnNldCArPSBjaHVua3NbaTJdLmxlbmd0aDsKICAgICAgfQogICAgICByZXR1cm4gaW1wb3J0X2J1ZmZlcjQuQnVmZmVyLmZyb20ocmVzdWx0KTsKICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgaWYgKGAke2V9YC5tYXRjaCgvaW5jb3JyZWN0IGhlYWRlciBjaGVjay8pKSB7CiAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJwcm9ibGVtIGRlY29tcHJlc3NpbmcgYmxvY2s6IGluY29ycmVjdCBnemlwIGhlYWRlciBjaGVjayIpOwogICAgICB9CiAgICAgIHRocm93IGU7CiAgICB9CiAgfQogIGFzeW5jIGZ1bmN0aW9uIHVuemlwQ2h1bmtTbGljZShpbnB1dERhdGEsIGNodW5rKSB7CiAgICB0cnkgewogICAgICBsZXQgc3RybTsKICAgICAgY29uc3QgeyBtaW52LCBtYXh2IH0gPSBjaHVuazsKICAgICAgbGV0IGNwb3MgPSBtaW52LmJsb2NrUG9zaXRpb247CiAgICAgIGxldCBkcG9zID0gbWludi5kYXRhUG9zaXRpb247CiAgICAgIGNvbnN0IGNodW5rcyA9IFtdOwogICAgICBjb25zdCBjcG9zaXRpb25zID0gW107CiAgICAgIGNvbnN0IGRwb3NpdGlvbnMgPSBbXTsKICAgICAgbGV0IHRvdGFsU2l6ZSA9IDA7CiAgICAgIGxldCBpID0gMDsKICAgICAgZG8gewogICAgICAgIGNvbnN0IHJlbWFpbmluZ0lucHV0ID0gaW5wdXREYXRhLnN1YmFycmF5KGNwb3MgLSBtaW52LmJsb2NrUG9zaXRpb24pOwogICAgICAgIGNvbnN0IGluZmxhdG9yID0gbmV3IGltcG9ydF9wYWtvLkluZmxhdGUoKTsKICAgICAgICAoeyBzdHJtIH0gPSBpbmZsYXRvcik7CiAgICAgICAgaW5mbGF0b3IucHVzaChyZW1haW5pbmdJbnB1dCwgaW1wb3J0X3Bha28uWl9TWU5DX0ZMVVNIKTsKICAgICAgICBpZiAoaW5mbGF0b3IuZXJyKSB7CiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoaW5mbGF0b3IubXNnKTsKICAgICAgICB9CiAgICAgICAgY29uc3QgYnVmZmVyMiA9IGluZmxhdG9yLnJlc3VsdDsKICAgICAgICBjaHVua3MucHVzaChidWZmZXIyKTsKICAgICAgICBsZXQgbGVuID0gYnVmZmVyMi5sZW5ndGg7CiAgICAgICAgY3Bvc2l0aW9ucy5wdXNoKGNwb3MpOwogICAgICAgIGRwb3NpdGlvbnMucHVzaChkcG9zKTsKICAgICAgICBpZiAoY2h1bmtzLmxlbmd0aCA9PT0gMSAmJiBtaW52LmRhdGFQb3NpdGlvbikgewogICAgICAgICAgY2h1bmtzWzBdID0gY2h1bmtzWzBdLnN1YmFycmF5KG1pbnYuZGF0YVBvc2l0aW9uKTsKICAgICAgICAgIGxlbiA9IGNodW5rc1swXS5sZW5ndGg7CiAgICAgICAgfQogICAgICAgIGNvbnN0IG9yaWdDcG9zID0gY3BvczsKICAgICAgICBjcG9zICs9IHN0cm0ubmV4dF9pbjsKICAgICAgICBkcG9zICs9IGxlbjsKICAgICAgICBp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3IERPTUV4Y2VwdGlvbigiYWJvcnRlZCIsICJBYm9ydEVycm9yIik7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29uc3QgZSA9IG5ldyBBYm9ydEVycm9yKCJhYm9ydGVkIik7CiAgICAgICAgZS5jb2RlID0gIkVSUl9BQk9SVEVEIjsKICAgICAgICB0aHJvdyBlOwogICAgICB9CiAgICB9CiAgfQogIGZ1bmN0aW9uIGNhbk1lcmdlQmxvY2tzKGNodW5rMSwgY2h1bmsyKSB7CiAgICByZXR1cm4gY2h1bmsyLm1pbnYuYmxvY2tQb3NpdGlvbiAtIGNodW5rMS5tYXh2LmJsb2NrUG9zaXRpb24gPCA2NWUzICYmIGNodW5rMi5tYXh2LmJsb2NrUG9zaXRpb24gLSBjaHVuazEubWludi5ibG9ja1Bvc2l0aW9uIDwgNWU2OwogIH0KICBmdW5jdGlvbiBvcHRpbWl6ZUNodW5rcyhjaHVua3MsIGxvd2VzdCkgewogICAgY29uc3QgbWVyZ2VkQ2h1bmtzID0gW107CiAgICBsZXQgbGFzdENodW5rID0gbnVsbDsKICAgIGlmIChjaHVua3MubGVuZ3RoID09PSAwKSB7CiAgICAgIHJldHVybiBjaHVua3M7CiAgICB9CiAgICBjaHVua3Muc29ydChmdW5jdGlvbihjMCwgYzEpIHsKICAgICAgY29uc3QgZGlmID0gYzAubWludi5ibG9ja1Bvc2l0aW9uIC0gYzEubWludi5ibG9ja1Bvc2l0aW9uOwogICAgICBpZiAoZGlmICE9PSAwKSB7CiAgICAgICAgcmV0dXJuIGRpZjsKICAgICAgfSBlbHNlIHsKICAgICAgICByZXR1cm4gYzAubWludi5kYXRhUG9zaXRpb24gLSBjMS5taW52LmRhdGFQb3NpdGlvbjsKICAgICAgfQogICAgfSk7CiAgICBjaHVua3MuZm9yRWFjaCgoY2h1bmspID0+IHsKICAgICAgaWYgKCFsb3dlc3QgfHwgY2h1bmsubWF4di5jb21wYXJlVG8obG93ZXN0KSA+IDApIHsKICAgICAgICBpZiAobG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3QgYmluQ291bnQgPSBieXRlcy5yZWFkSW50MzJMRShjdXJyT2Zmc2V0KTsKICAgICAgICBjdXJyT2Zmc2V0ICs9IDQ7CiAgICAgICAgY29uc3QgYmluSW5kZXggPSB7fTsKICAgICAgICBsZXQgc3RhdHM7CiAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBiaW5Db3VudDsgaiArPSAxKSB7CiAgICAgICAgICBjb25zdCBiaW4gPSBieXRlcy5yZWFkVUludDMyTEUoY3Vyck9mZnNldCk7CiAgICAgICAgICBjdXJyT2Zmc2V0ICs9IDQ7CiAgICAgICAgICBpZiAoYmluID4gbWF4QmluTnVtYmVyICsgMSkgewogICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoInRhYml4IGluZGV4IGNvbnRhaW5zIHRvbyBtYW55IGJpbnMsIHBsZWFzZSB1c2UgYSBDU0kgaW5kZXgiKTsKICAgICAgICAgIH0gZWxzZSBpZiAoYmluID09PSBtYXhCaW5OdW1iZXIgKyAxKSB7CiAgICAgICAgICAgIGNvbnN0IGNodW5rQ291bnQgPSBieXRlcy5yZWFkSW50MzJMRShjdXJyT2Zmc2V0KTsKICAgICAgICAgICAgY3Vyck9mZnNldCArPSA0OwogICAgICAgICAgICBpZiAoY2h1bmtDb3VudCA9PT0gMikgewogICAgICAgICAgICAgIHN0YXRzID0gdGhpcy5wYXJzZVBzZXVkb0JpbihieXRlcywgY3Vyck9mZnNldCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY3Vyck9mZnNldCArPSAxNiAqIGNodW5rQ291bnQ7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjb25zdCBjaHVua0NvdW50ID0gYnl0ZXMucmVhZEludDMyTEUoY3Vyck9mZnNldCk7CiAgICAgICAgICAgIGN1cnJPZmZzZXQgKz0gNDsKICAgICAgICAgICAgY29uc3QgY2h1bmtzID0gbmV3IEFycmF5KGNodW5rQ291bnQpOwogICAgICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IGNodW5rQ291bnQ7IGsgKz0gMSkgewogICAgICAgICAgICAgIGNvbnN0IHUgPSBmcm9tQnl0ZXMoYnl0ZXMsIGN1cnJPZmZzZXQpOwogICAgICAgICAgICAgIGNvbnN0IHYgPSBmcm9tQnl0ZXMoYnl0ZXMsIGN1cnJPZmZzZXQgKyA4KTsKICAgICAgICAgICAgICBjdXJyT2Zmc2V0ICs9IDE2OwogICAgICAgICAgICAgIGZpcnN0RGF0YUxpbmUgPSB0aGlzLl9maW5kRmlyc3REYXRhKGZpcnN0RGF0YUxpbmUsIHUpOwogICAgICAgICAgICAgIGNodW5rc1trXSA9IG5ldyBDaHVuayh1LCB2LCBiaW4pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJpbkluZGV4W2Jpbl0gPSBjaHVua3M7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGNvbnN0IGxpbmVhckNvdW50ID0gYnl0ZXMucmVhZEludDMyTEUoY3Vyck9mZnNldCk7CiAgICAgICAgY3Vyck9mZnNldCArPSA0OwogICAgICAgIGNvbnN0IGxpbmVhckluZGV4ID0gbmV3IEFycmF5KGxpbmVhckNvdW50KTsKICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IGxpbmVhckNvdW50OyBrICs9IDEpIHsKICAgICAgICAgIGxpbmVhckluZGV4W2tdID0gZnJvbUJ5dGVzKGJ5dGVzLCBjdXJyT2Zmc2V0KTsKICAgICAgICAgIGN1cnJPZmZzZXQgKz0gODsKICAgICAgICAgIGZpcnN0RGF0YUxpbmUgPSB0aGlzLl9maW5kRmlyc3REYXRhKGZpcnN0RGF0YUxpbmUsIGxpbmVhckluZGV4W2tdKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHsgYmluSW5kZXgsIGxpbmVhckluZGV4LCBzdGF0cyB9OwogICAgICB9KTsKICAgICAgcmV0dXJuIHsKICAgICAgICBpbmRpY2VzLAogICAgICAgIG1ldGFDaGFyLAogICAgICAgIG1heEJpbk51bWJlciwKICAgICA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WU7CiAgICAgICAgICAgIHJlZk5hbWVUb0lkW3JlZk5hbWVdID0gY3VyclJlZklkOwogICAgICAgICAgfQogICAgICAgICAgY3Vyck5hbWVTdGFydCA9IGkgKyAxOwogICAgICAgICAgY3VyclJlZklkICs9IDE7CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiB7IHJlZk5hbWVUb0lkLCByZWZJZFRvTmFtZSB9OwogICAgfQogICAgYXN5bmMgYmxvY2tzRm9yUmFuZ2UocmVmTmFtZSwgbWluLCBtYXgsIG9wdHMgPSB7fSkgewogICAgICBpZiAobWluIDwgMCkgewogICAgICAgIG1pbiA9IDA7CiAgICAgIH0KICAgICAgY29uc3QgaW5kZXhEYXRhID0gYXdhaXQgdGhpcy5wYXJzZShvcHRzKTsKICAgICAgaWYgKCFpbmRleERhdGEpIHsKICAgICAgICByZXR1cm4gW107CiAgICAgIH0KICAgICAgY29uc3QgcmVmSWQgPSBpbmRleERhdGEucmVmTmFtZVRvSWRbcmVmTmFtZV07CiAgICAgIGNvbnN0IGJhID0gaW5kZXhEYXRhLmluZGljZXNbcmVmSWRdOwogICAgICBpZiAoIWJhKSB7CiAgICAgICAgcmV0dXJuIFtdOwogICAgICB9CiAgICAgIGNvbnN0IG1pbk9mZnNldCA9IGJhLmxpbmVhckluZGV4Lmxlbmd0aCA/IGJhLmxpbmVhckluZGV4W21pbiA+PiBUQURfTElEWF9TSElGVCA+PSBiYS5saW5lYXJJbmRleC5sZW5ndGggPyBiYS5saW5lYXJJbmRleC5sZW5ndGggLSAxIDogbWluID4+IFRBRF9MSURYX1NISUZUXSA6IG5ldyBWaXJ0dWFsT2Zmc2V0KDAsIDApOwogICAgICBpZiAoIW1pbk9mZnNldCkgewogICAgICAgIGNvbnNvbGUud2FybigicXVlcnlpbmcgb3V0c2lkZSBvZiBwb3NzaWJsZSB0YWJpeCByYW5nZSIpOwogICAgICB9CiAgICAgIGNvbnN0IG92ZXJsYXBwaW5nQmlucyA9IHJlZzJiaW5zKG1pbiwgbWF4KTsKICAgICAgY29uc3QgY2h1bmtzID0gW107CiAgICAgIGZvciAoY29uc3QgW3N0YXJ0LCBlbmRdIG9mIG92ZXJsYXBwaW5nQmlucykgewogICAgICAgIGZvciAobGV0IGJpbiA9IHN0YXJ0OyBiaW4gPD0gZW5kOyBiaW4rKykgewogICAgICAgICAgaWYgKGJhLmJpbkluZGV4W2Jpbl0pIHsKICAgICAgICAgICAgY29uc3QgYmluQ2h1bmtzID0gYmEuYmluSW5kZXhbYmluXTsKICAgICAgICAgICAgZm9yIChsZXQgYyA9IDA7IGMgPCBiaW5DaHVua3MubGVuZ3RoOyArK2MpIHsKICAgICAgICAgICAgICBjaHVua3MucHVzaChuZXcgQ2h1bmsoYmluQ2h1bmtzW2NdLm1pbnYsIGJpbkNodW5rc1tjXS5tYXh2LCBiaW4pKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBjb25zdCBuaW50diA9IGJhLmxpbmVhckluZGV4Lmxlbmd0aDsKICAgICAgbGV0IGxvd2VzdCA9IG51bGw7CiAgICAgIGNvbnN0IG1pbkxpbiA9IE1hdGgubWluKG1pbiA+PiAxNCwgbmludHYgLSAxKTsKICAgICAgY29uc3QgbWF4TGluID0gTWF0aC5taW4obWF4ID4+IDE0LCBuaW50diAtIDEpOwogICAgICBmb3IgKGxldCBpID0gbWluTGluOyBpIDw9IG1heExpbjsgKytpKSB7CiAgICAgICAgY29uc3QgdnAgPSBiYS5saW5lYXJJbmRleFtpXTsKICAgICAgICBpZiAodnApIHsKICAgICAgICAgIGlmICghbG93ZXN0IHx8IHZwLmNvbXBhcmVUbyhsb3dlc3QpIDwgMCkgewogICAgICAgICAgICBsb3dlc3QgPSB2cDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgcmV0dXJuIG9wdGltaXplQ2h1bmtzKGNodW5rcywgbG93ZXN0KTsKICAgIH0KICB9OwoKICAvLyBub2RlX21vZHVsZXMvLnBucG0vQGdtb2QrdGFiaXhAMS41LjExL25vZGVfbW9kdWxlcy9AZ21vZC90YWJpeC9lc20vY3NpLmpzCiAgaW5pdF9idWZmZXJfc2hpbSgpOwogIHZhciBpbXBvcnRfbG9uZzMgPSBfX3RvTW9kdWxlKHJlcXVpcmVfbG9uZygpKTsKICB2YXIgQ1NJMV9NQUdJQyA9IDIxNTgyNjU5OwogIHZhciBDU0kyX01BR0lDID0gMzgzNTk4NzU7CiAgZnVuY3Rpb24gbHNoaWZ0KG51bSwgYml0cykgewogICAgcmV0dXJuIG51bSAqIDIgKiogYml0czsKICB9CiAgZnVuY3Rpb24gcnNoaWZ0KG51bSwgYml0cykgewogICAgcmV0dXJuIE1hdGguZmxvb3IobnVtIC8gMiAqKiBiaXRzKTsKICB9CiAgdmFyIENTSSA9IGNsYXNzIGV4dGVuZHMgSW5kZXhGaWxlIHsKICAgIGNvbnN0cnVjdG9yKGFyZ3MpIHsKICAgICAgc3VwZXIoYXJncyk7CiAgICAgIHRoaXMubWF4QmluTnVtYmVyID0gMDsKICAgICAgdGhpcy5kZXB0aCA9IDA7CiAgICAgIHRoaXMubWluU2hpZnQgPSAwOwogICAgfQogICAgYXN5bmMgbGluZUNvdW50KHJlZk5hbWUsIG9wdHMgPSB7fSkgewogICAgICBjb25zdCBpbmRleERhdGEgPSBhd2FpdCB0aGlzLnBhcnNlKG9wdHMpOwogICAgICBpZiAoIWluZGV4RGF0YSkgewogICAgICAgIHJldHVybiAtMTsKICAgICAgfQogICAgICBjb25zdCByZWZJZCA9IGluZGV4RGF0YS5yZWZOYW1lVG9JZFtyZWZOYW1lXTsKICAgICAgY29uc3QgaWR4ID0gaW5kZXhEYXRhLmluZGljZXNbcmVmSWRdOwogICAgICBpZiAoIWlkeCkgewogICAgICAgIHJldHVybiAtMTsKICAgICAgfQogICAgICBjb25zdCB7IHN0YXRzIH0gPSBpbmRleERhdGEuaW5kaWNlc1tyZWZJZF07CiAgICAgIGlmIChzdGF0cykgewogICAgICAgIHJ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gICAgY29uc3QgbG9mZnNldCA9IGZyb21CeXRlcyhieXRlcywgY3Vyck9mZnNldCArIDQpOwogICAgICAgICAgICBmaXJzdERhdGFMaW5lID0gdGhpcy5fZmluZEZpcnN0RGF0YShmaXJzdERhdGFMaW5lLCBsb2Zmc2V0KTsKICAgICAgICAgICAgY29uc3QgY2h1bmtDb3VudCA9IGJ5dGVzLnJlYWRJbnQzMkxFKGN1cnJPZmZzZXQgKyAxMik7CiAgICAgICAgICAgIGN1cnJPZmZzZXQgKz0gMTY7CiAgICAgICAgICAgIGNvbnN0IGNodW5rcyA9IG5ldyBBcnJheShjaHVua0NvdW50KTsKICAgICAgICAgICAgZm9yIChsZXQgayA9IDA7IGsgPCBjaHVua0NvdW50OyBrICs9IDEpIHsKICAgICAgICAgICAgICBjb25zdCB1ID0gZnJvbUJ5dGVzKGJ5dGVzLCBjdXJyT2Zmc2V0KTsKICAgICAgICAgICAgICBjb25zdCB2ID0gZnJvbUJ5dGVzKGJ5dGVzLCBjdXJyT2Zmc2V0ICsgOCk7CiAgICAgICAgICAgICAgY3Vyck9mZnNldCArPSAxNjsKICAgICAgICAgICAgICBjaHVua3Nba10gPSBuZXcgQ2h1bmsodSwgdiwgYmluKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBiaW5JbmRleFtiaW5dID0gY2h1bmtzOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4geyBiaW5JbmRleCwgc3RhdHMgfTsKICAgICAgfSk7CiAgICAgIHJldHVybiB7CiAgICAgICAgLi4uYXV4LAogICAgICAgIGNzaTogdHJ1ZSwKICAgICAgICByZWZDb3VudCwKICAgICAgICBtYXhCbG9ja1NpemU6IDEgPDwgMTYsCiAgICAgICAgZmlyc3REYXRhTGluZSwKICAgICAgICBjc2lWZXJzaW9uLAogICAgICAgIGluZGljZXMsCiAgICAgICAgZGVwdGg6IHRoaXMuZGVwdGgsCiAgICAgICAgbWF4QmluTnVtYmVyOiB0aGlzLm1heEJpbk51bWJlciwKICAgICAgICBtYXhSZWZMZW5ndGgKICAgICAgfTsKICAgIH0KICAgIHBhcnNlUHNldWRvQmluKGJ5dGVzLCBvZmZzZXQpIHsKICAgICAgY29uc3QgbGluZUNvdW50ID0gbG9uZ1RvTnVtYmVyKGltcG9ydF9sb25nMy5kZWZhdWx0LmZyb21CeXRlc0xFKGJ5dGVzLnNsaWNlKG9mZnNldCArIDI4LCBvZmZzZXQgKyAzNiksIHRydWUpKTsKICAgICAgcmV0dXJuIHsgbGluZUNvdW50IH07CiAgICB9CiAgICBhc3luYyBibG9ja3NGb3JSYW5nZShyZWZOYW1lLCBtaW4sIG1heCwgb3B0cyA9IHt9KSB7CiAgICAgIGlmIChtaW4gPCAwKSB7CiAgICAgICAgbWluID0gMDsKICAgICAgfQogICAgICBjb25zdCBpbmRleERhdGEgPSBhd2FpdCB0aGlzLnBhcnNlKG9wdHMpOwogICAgICBpZiAoIWluZGV4RGF0YSkgewogICAgICAgIHJldHVybiBbXTsKICAgICAgfQogICAgICBjb25zdCByZWZJZCA9IGluZGV4RGF0YS5yZWZOYW1lVG9JZFtyZWZOYW1lXTsKICAgICAgY29uc3QgYmEgPSBpbmRleERhdGEuaW5kaWNlc1tyZWZJZF07CiAgICAgIGlmICghYmEpIHsKICAgICAgICByZXR1cm4gW107CiAgICAgIH0KICAgICAgY29uc3Qgb3ZlcmxhcHBpbmdCaW5zID0gdGhpcy5yZWcyYmlucyhtaW4sIG1heCk7CiAgICAgIGNvbnN0IGNodW5rcyA9IFtdOwogICAgICBmb3IgKGNvbnN0IFtzdGFydCwgZW5kXSBvZiBvdmVybGFwcGluZ0JpbnMpIHsKICAgICAgICBmb3IgKGxldCBiaW4gPSBzdGFydDsgYmluIDw9IGVuZDsgYmluKyspIHsKICAgICAgICAgIGlmIChiYS5iaW5JbmRleFtiaW5dKSB7CiAgICAgICAgICAgIGNvbnN0IGJpbkNodW5rcyA9IGJhLmJpbkluZGV4W2Jpbl07CiAgICAgICAgICAgIGZvciAobGV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GFuZGxlIG9yIHBhdGgiKTsKICAgICAgfQogICAgICBpZiAodGJpRmlsZWhhbmRsZSkgewogICAgICAgIHRoaXMuaW5kZXggPSBuZXcgVGFiaXhJbmRleCh7CiAgICAgICAgICBmaWxlaGFuZGxlOiB0YmlGaWxlaGFuZGxlLAogICAgICAgICAgcmVuYW1lUmVmU2VxcwogICAgICAgIH0pOwogICAgICB9IGVsc2UgaWYgKGNzaUZpbGVoYW5kbGUpIHsKICAgICAgICB0aGlzLmluZGV4ID0gbmV3IENTSSh7CiAgICAgICAgICBmaWxlaGFuZGxlOiBjc2lGaWxlaGFuZGxlLAogICAgICAgICAgcmVuYW1lUmVmU2VxcwogICAgICAgIH0pOwogICAgICB9IGVsc2UgaWYgKHRiaVBhdGgpIHsKICAgICAgICB0aGlzLmluZGV4ID0gbmV3IFRhYml4SW5kZXgoewogICAgICAgICAgZmlsZWhhbmRsZTogbmV3IGltcG9ydF9sb2NhbEZpbGUuZGVmYXVsdCh0YmlQYXRoKSwKICAgICAgICAgIHJlbmFtZVJlZlNlcXMKICAgICAgICB9KTsKICAgICAgfSBlbHNlIGlmIChjc2lQYXRoKSB7CiAgICAgICAgdGhpcy5pbmRleCA9IG5ldyBDU0koewogICAgICAgICAgZmlsZWhhbmRsZTogbmV3IGltcG9ydF9sb2NhbEZpbGUuZGVmYXVsdChjc2lQYXRoKSwKICAgICAgICAgIHJlbmFtZVJlZlNlcXMKICAgICAgICB9KTsKICAgICAgfSBlbHNlIGlmIChwYXRoKSB7CiAgICAgICAgdGhpcy5pbmRleCA9IG5ldyBUYWJpeEluZGV4KHsKICAgICAgICAgIGZpbGVoYW5kbGU6IG5ldyBpbXBvcnRfbG9jYWxGaWxlLmRlZmF1bHQoYCR7cGF0aH0udGJpYCksCiAgICAgICAgICByZW5hbWVSZWZTZXFzCiAgICAgICAgfSk7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcigibXVzdCBwcm92aWRlIG9uZSB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ucykgewogICAgICAgICAgICB3aGlsZSAoYmxvY2tTdGFydCArIGMubWludi5kYXRhUG9zaXRpb24gPj0gZHBvc2l0aW9uc1twb3MrK10pIHsKICAgICAgICAgICAgfQogICAgICAgICAgICBwb3MtLTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IHsgc3RhcnRDb29yZGluYXRlLCBvdmVybGFwcyB9ID0gdGhpcy5jaGVja0xpbmUobWV0YWRhdGEsIHJlZk5hbWUsIHN0YXJ0LCBlbmQsIGxpbmUpOwogICAgICAgICAgaWYgKHByZXZpb3VzU3RhcnRDb29yZGluYXRlICE9PSB2b2lkIDAgJiYgc3RhcnRDb29yZGluYXRlICE9PSB2b2lkIDAgJiYgcHJldmlvdXNTdGFydENvb3JkaW5hdGUgPiBzdGFydENvb3JkaW5hdGUpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBMaW5lcyBub3Qgc29ydGVkIGJ5IHN0YXJ0IGNvb3JkaW5hdGUgKCR7cHJldmlvdXNTdGFydENvb3JkaW5hdGV9ID4gJHtzdGFydENvb3JkaW5hdGV9KSwgdGhpcyBmaWxlIGlzIG5vdCB1c2FibGUgd2l0aCBUYWJpeC5gKTsKICAgICAgICAgIH0KICAgICAgICAgIHByZXZpb3VzU3RhcnRDb29yZGluYXRlID0gc3RhcnRDb29yZGluYXRlOwogICAgICAgICAgaWYgKG92ZXJsYXBzKSB7CiAgICAgICAgICAgIGNhbGxiYWNrKGxpbmUudHJpbSgpLCBjcG9zaXRpb25zW3Bvc10gKiAoMSA8PCA4KSArIChibG9ja1N0YXJ0IC0gZHBvc2l0aW9uc1twb3NdKSArIGMubWludi5kYXRhUG9zaXRpb24gKyAxKTsKICAgICAgICAgIH0gZWxzZSBpZiAoc3RhcnRDb29yZGluYXRlICE9PSB2b2lkIDAgJiYgc3RhcnRDb29yZGluYXRlID49IGVuZCkgewogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICB9CiAgICAgICAgICBpZiAodGhpcy55aW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lZ2lvblN0YXJ0LCByZWdpb25FbmQsIGxpbmUpIHsKICAgICAgY29uc3QgeyBjb2x1bW5OdW1iZXJzLCBtZXRhQ2hhciwgY29vcmRpbmF0ZVR5cGUsIGZvcm1hdCB9ID0gbWV0YWRhdGE7CiAgICAgIGlmIChsaW5lLmNoYXJBdCgwKSA9PT0gbWV0YUNoYXIpIHsKICAgICAgICByZXR1cm4geyBvdmVybGFwczogZmFsc2UgfTsKICAgICAgfQogICAgICBsZXQgeyByZWYsIHN0YXJ0LCBlbmQgfSA9IGNvbHVtbk51bWJlcnM7CiAgICAgIGlmICghcmVmKSB7CiAgICAgICAgcmVmID0gMDsKICAgICAgfQogICAgICBpZiAoIXN0YXJ0KSB7CiAgICAgICAgc3RhcnQgPSAwOwogICAgICB9CiAgICAgIGlmICghZW5kKSB7CiAgICAgICAgZW5kID0gMDsKICAgICAgfQogICAgICBpZiAoZm9ybWF0ID09PSAiVkNGIikgewogICAgICAgIGVuZCA9IDg7CiAgICAgIH0KICAgICAgY29uc3QgbWF4Q29sdW1uID0gTWF0aC5tYXgocmVmLCBzdGFydCwgZW5kKTsKICAgICAgbGV0IGN1cnJlbnRDb2x1bW5OdW1iZXIgPSAxOwogICAgICBsZXQgY3VycmVudENvbHVtblN0YXJ0ID0gMDsKICAgICAgbGV0IHJlZlNlcSA9ICIiOwogICAgICBsZXQgc3RhcnRDb29yZGluYXRlID0gLUluZmluaXR5OwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxpbmUubGVuZ3RoICsgMTsgaSArPSAxKSB7CiAgICAgICAgaWYgKGxpbmVbaV0gPT09ICIJIiB8fCBpID09PSBsaW5lLmxlbmd0aCkgewogICAgICAgICAgaWYgKGN1cnJlbnRDb2x1bW5OdW1iZXIgPT09IHJlZikgewogICAgICAgICAgICBpZiAodGhpcy5yZW5hbWVSZWZTZXEobGluZS5zbGljZShjdXJyZW50Q29sdW1uU3RhcnQsIGkpKSAhPT0gcmVnaW9uUmVmTmFtZSkgewogICAgICAgICAgICAgIHJldHVybiB7IG92ZXJsYXBzOiBmYWxzZSB9OwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgaWYgKGN1cnJlbnRDb2x1bW5OdW1iZXIgPT09IHN0YXJ0KSB7CiAgICAgICAgICAgIHN0YXJ0Q29vcmRpbmF0ZSA9IHBhcnNlSW50KGxpbmUuc2xpY2UoY3VycmVudENvbHVtblN0YXJ0LCBpKSwgMTApOwogICAgICAgICAgICBpZiAoY29vcmRpbmF0ZVR5cGUgPT09ICIxLWJhc2VkLWNsb3NlZCIpIHsKICAgICAgICAgICAgICBzdGFydENvb3JkaW5hdGUgLT0gMTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoc3RhcnRDb29yZGluYXRlID49IHJlZ2lvbkVuZCkgewogICAgICAgICAgICAgIHJldHVybiB7IHN0YXJ0Q29vcmRpbmF0ZSwgb3ZlcmxhcHM6IGZhbHNlIH07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGVuZCA9PT0gMCB8fCBlbmQgPT09IHN0YXJ0KSB7CiAgICAgICAgICAgICAgaWYgKHN0YXJ0Q29vcmRpbmF0ZSArIDEgPD0gcmVnaW9uU3RhcnQpIHsKICAgICAgICAgICAgICAgIHJldHVybiB7IHN0YXJ0Q29vcmRpbmF0ZSwgb3ZlcmxhcHM6IGZhbHNlIH07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgaWYgKGZvcm1hdCA9PT0gIlZDRiIgJiYgY3VycmVudENvbHVtbk51bWJlciA9PT0gNCkgewogICAgICAgICAgICByZWZTZXEgPSBsaW5lLnNsaWNlKGN1cnJlbnRDb2x1bW5TdGFydCwgaSk7CiAgICAgICAgICB9IGVsc2UgaWYgKGN1cnJlbnRDb2x1bW5OdW1iZXIgPT09IGVuZCkgewogICAgICAgICAgICBsZXQgZW5kQ29vcmRpbmF0ZTsKICAgICAgICAgICAgaWYgKGZvcm1hdCA9PT0gIlZDRiIpIHsKICAgICAgICAgICAgICBlbmRDb29yZGluYXRlID0gdGhpcy5fZ2V0VmNmRW5kKHN0YXJ0Q29vcmRpbmF0ZSwgcmVmU2VxLCBsaW5lLnNsaWNlKGN1cnJlbnRDb2x1bW5TdGFydCwgaSkpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGVuZENvb3JkaW5hdGUgPSBwYXJzZUludChsaW5lLnNsaWNlKGN1cnJlbnRDb2x1bW5TdGFydCwgaSksIDEwKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoZW5kQ29vcmRpbmF0ZSA8PSByZWdpb25TdGFydCkgewogICAgICAgICAgICAgIHJldHVybiB7IG92ZXJsYXBzOiBmYWxzZSB9OwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBjdXJyZW50Q29sdW1uU3RhcnQgPSBpICsgMTsKICAgICAgICAgIGN1cnJlbnRDb2x1bW5OdW1iZXIgKz0gMTsKICAgICAgICAgIGlmIChjdXJyZW50Q29sdW1uTnVtYmVyID4gbWF4Q29sdW1uKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4geyBzdGFydENvb3JkaW5hdGUsIG92ZXJsYXBzOiB0cnVlIH07CiAgICB9CiAgICBfZ2V0VmNmRW5kKHN0YXJ0Q29vcmRpbmF0ZSwgcmVmU2VxLCBpbmZvKSB7CiAgICAgIGxldCBlbmRDb29yZGluYXRlID0gc3RhcnRDb29yZGluYXRlICsgcmVmU2VxLmxlbmd0aDsKICAgICAgY29uc3QgaXNUUkEgPSBpbmZvLmluZGV4T2YoIlNWVFlQRT1UUkEiKSAhPT0gLTE7CiAgICAgIGlmIChpbmZvWzBdICE9PSAiLiIgJiYgIWlzVFJBKSB7CiAgICAgICAgbGV0IHByZXZDaGFyID0gIjsiOwogICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgaW5mby5sZW5ndGg7IGogKz0gMSkgewogICAgICAgICAgaWYgKHByZXZDaGFyID09PSAiOyIgJiYgaW5mby5zbGljZShqLCBqICsgNCkgPT09ICJFTkQ9IikgewogICAgICAgICAgICBsZXQgdmFsdWVFbmQgPSBpbmZvLmluZGV4T2YoIjsiLCBqKTsKICAgICAgICAgICAgaWYgKHZhbHVlRW5kID09PSAtMSkgewogICAgICAgICAgICAgIHZhbHVlRW5kID0gaW5mby5sZW5ndGg7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZW5kQ29vcmRpbmF0ZSA9IHBhcnNlSW50KGluZm8uc2xpY2UoaiArIDQsIHZhbHVlRW5kKSwgMTApOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIHByZXZDaGFyID0gaW5mb1tqXTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoaXNUUkEpIHsKICAgICAgICByZXR1cm4gc3RhcnRDb29yZGluYXRlICsgMTsKICAgICAgfQogICAgICByZXR1cm4gZW5kQ29vcmRpbmF0ZTsKICAgIH0KICAgIGFzeW5jIGxpbmVDb3VudChyZWZOYW1lLCBvcHRzID0ge30pIHsKICAgICAgcmV0dXJuIHRoaXMuaW5kZXgubGluZUNvdW50KHJlZk5hbWUsIG9wdHMpOwogICAgfQogICAgYXN5bmMgX3JlYWRSZWdpb24ocG9zLCBzaXplLCBvcHRzID0ge30pIHsKICAgICAgY29uc3QgYiA9IGltcG9ydF9idWZmZXI3LkJ1ZmZlci5hbGxvYyhzaXplKTsKICAgICAgY29uc3QgeyBieXRlc1JlYWQsIGJ1ZmZlciB9ID0gYXdhaXQgdGhpcy5maWxlaGFuZGxlLnJlYWQoYiwgMCwgc2l6ZSwgcG9zLCBvcHRzKTsKICAgICAgcmV0dXJuIGJ1ZmZlci5zbGljZSgwLCBieXRlc1JlYWQpOwogICAgfQogICAgYXN5bmMgcmVhZENodW5rKGMsIG9wdHMgPSB7fSkgewogICAgICBjb25zdCBkYXRhID0gYXdhaXQgdGhpcy5fcmVhZFJlZ2l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IENJR0FSOiB7CiAgICAgICAgTnVtYmVyOiAxLAogICAgICAgIFR5cGU6ICJGbG9hdCIsCiAgICAgICAgRGVzY3JpcHRpb246ICJDaWdhciBzdHJpbmcgZGVzY3JpYmluZyBob3cgdG8gYWxpZ24gYW4gYWx0ZXJuYXRlIGFsbGVsZSB0byB0aGUgcmVmZXJlbmNlIGFsbGVsZSIKICAgICAgfSwKICAgICAgREI6IHsKICAgICAgICBOdW1iZXI6IDAsCiAgICAgICAgVHlwZTogIkZsYWciLAogICAgICAgIERlc2NyaXB0aW9uOiAiZGJTTlAgbWVtYmVyc2hpcCIKICAgICAgfSwKICAgICAgRFA6IHsKICAgICAgICBOdW1iZXI6IDEsCiAgICAgICAgVHlwZTogIkludGVnZXIiLAogICAgICAgIERlc2NyaXB0aW9uOiAiY29tYmluZWQgZGVwdGggYWNyb3NzIHNhbXBsZXMiCiAgICAgIH0sCiAgICAgIEVORDogewogICAgICAgIE51bWJlcjogMSwKICAgICAgICBUeXBlOiAiSW50ZWdlciIsCiAgICAgICAgRGVzY3JpcHRpb246ICJFbmQgcG9zaXRpb24gKGZvciB1c2Ugd2l0aCBzeW1ib2xpYyBhbGxlbGVzKSIKICAgICAgfSwKICAgICAgSDI6IHsKICAgICAgICBOdW1iZXI6IDAsCiAgICAgICAgVHlwZTogIkZsYWciLAogICAgICAgIERlc2NyaXB0aW9uOiAiSGFwTWFwMiBtZW1iZXJzaGlwIgogICAgICB9LAogICAgICBIMzogewogICAgICAgIE51bWJlcjogMCwKICAgICAgICBUeXBlOiAiRmxhZyIsCiAgICAgICAgRGVzY3JpcHRpb246ICJIYXBNYXAzIG1lbWJlcnNoaXAiCiAgICAgIH0sCiAgICAgIE1ROiB7CiAgICAgICAgTnVtYmVyOiAxLAogICAgICAgIFR5cGU6IG51bGwsCiAgICAgICAgRGVzY3JpcHRpb246ICJSTVMgbWFwcGluZyBxdWFsaXR5IgogICAgICB9LAogICAgICBNUTA6IHsKICAgICAgICBOdW1iZXI6IDEsCiAgICAgICAgVHlwZTogIkludGVnZXIiLAogICAgICAgIERlc2NyaXB0aW9uOiAiTnVtYmVyIG9mIE1BUFEgPT0gMCByZWFkcyIKICAgICAgfSwKICAgICAgTlM6IHsKICAgICAgICBOdW1iZXI6IDEsCiAgICAgICAgVHlwZTogIkludGVnZXIiLAogICAgICAgIERlc2NyaXB0aW9uOiAiTnVtYmVyIG9mIHNhbXBsZXMgd2l0aCBkYXRhIgogICAgICB9LAogICAgICBTQjogewogICAgICAgIE51bWJlcjogNCwKICAgICAgICBUeXBlOiAiSW50ZWdlciIsCiAgICAgICAgRGVzY3JpcHRpb246ICJTdHJhbmQgYmlhcyIKICAgICAgfSwKICAgICAgU09NQVRJQzogewogICAgICAgIE51bWJlcjogMCwKICAgICAgICBUeXBlOiAiRmxhZyIsCiAgICAgICAgRGVzY3JpcHRpb246ICJTb21hdGljIG11dGF0aW9uIChmb3IgY2FuY2VyIGdlbm9taWNzKSIKICAgICAgfSwKICAgICAgVkFMSURBVEVEOiB7CiAgICAgICAgTnVtYmVyOiAwLAogICAgICAgIFR5cGU6ICJGbGFnIiwKICAgICAgICBEZXNjcmlwdGlvbjogIlZhbGlkYXRlZCBieSBmb2xsb3ctdXAgZXhwZXJpbWVudCIKICAgICAgfSwKICAgICAgIjEwMDBHIjogewogICAgICAgIE51bWJlcjogMCwKICAgICAgICBUeXBlOiAiRmxhZyIsCiAgICAgICAgRGVzY3JpcHRpb246ICIxMDAwIEdlbm9tZXMgbWVtYmVyc2hpcCIKICAgICAgfSwKICAgICAgSU1QUkVDSVNFOiB7CiAgICAgICAgTnVtYmVyOiAwLAogICAgICAgIFR5cGU6ICJGbGFnIiwKICAgICAgICBEZXNjcmlwdGlvbjogIkltcHJlY2lzZSBzdHJ1Y3R1cmFsIHZhcmlhdGlvbiIKICAgICAgfSwKICAgICAgTk9WRUw6IHsKICAgICAgICBOdW1iZXI6IDAsCiAgICAgICAgVHlwZTogIkZsYWciLAogICAgICAgIERlc2NyaXB0aW9uOiAiSW5kaWNhdGVzIGEgbm92ZWwgc3RydWN0dXJhbCB2YXJpYXRpb24iCiAgICAgIH0sCiAgICAgIFNWVFlQRTogewogICAgICAgIE51bWJlcjogMSwKICAgICAgICBUeXBlOiAiU3RyaW5nIiwKICAgICAgICBEZXNjcmlwdGlvbjogIlR5cGUgb2Ygc3RydWN0dXJhbCB2YXJpYW50IgogICAgICB9LAogICAgICBTVkxFTjogewogICAgICAgIE51bWJlcjogbnVsbCwKICAgICAgICBUeXBlOiAiSW50ZWdlciIsCiAgICAgICAgRGVzY3JpcHRpb246ICJEaWZmZXJlbmNlIGluIGxlbmd0aCBiZXR3ZWVuIFJFRiBhbmQgQUxUIGFsbGVsZXMiCiAgICAgIH0sCiAgICAgIENJUE9TOiB7CiAgICAgICAgTnVtYmVyOiAyLAogICAgICAgIFR5cGU6ICJJbnRlZ2VyIiwKICAgICAgICBEZXNjcmlwdGlvbjogIkNvbmZpZGVuY2UgaW50ZXJ2YWwgYXJvdW5kIFBPUyBmb3IgaW1wcmVjaXNlIHZhcmlhbnRzIgogICAgICB9LAogICAgICBDSUVORDogewogICAgICAgIE51bWJlcjogMiwKICAgICAgICBUeXBlOiAiSW50ZWdlciIsCiAgICAgICAgRGVzY3JpcHRpb246ICJDb25maWRlbmNlIGludGVydmFsIGFyb3VuZCBFTkQgZm9yIGltcHJlY2lzZSB2YXJpYW50cyIKICAgICAgfSwKICAgICAgSE9NTEVOOiB7CiAgICAgICAgVHlwZTogIkludGVnZXIiLAogICAgICAgIERlc2NyaXB0aW9uOiAiTGVuZ3RoIG9mIGJhc2UgcGFpciBpZGVudGljYWwgbWljcm8taG9tb2xvZ3kgYXQgZXZlbnQgYnJlYWtwb2ludHMiCiAgICAgIH0sCiAgICAgIEhPTVNFUTogewogICAgICAgIFR5cGU6ICJTdHJpbmciLAogICAgICAgIERlc2NyaXB0aW9uOiAiU2VxdWVuY2Ugb2YgYmFzZSBwYWlyIGlkZW50aWNhbCBtaWNyby1ob21vbG9neSBhdCBldmVudCBicmVha3BvaW50cyIKICAgICAgfSwKICAgICAgQktQVElEOiB7CiAgICAgICAgVHlwZTogIlN0cmluZyIsCiAgICAgICAgRGVzY3JpcHRpb246ICJJRCBvZiB0aGUgYXNzZW1ibGVkIGFsdGVybmF0ZSBhbGxlbGUgaW4gdGhlIGFzc2VtYmx5IGZpbGUiCiAgICAgIH0sCiAgICAgIE1FSU5GTzogewogICAgICAgIE51bWJlcjogNCwKICAgICAgICBUeXBlOiAiU3RyaW5nIiwKICAgICAgICBEZXNjcmlwdGlvbjogIk1vYmlsZSBlbGVtZW50IGluZm8gb2YgdGhlIGZvcm0gTkFNRSxTVEFSVCxFTkQsUE9MQVJJVFkiCiAgICAgIH0sCiAgICAgIE1FVFJBTlM6IHsKICAgICAgICBOdW1iZXI6IDQsCiAgICAgICAgVHlwZTogIlN0cmluZyIsCiAgICAgICAgRGVzY3JpcHRpb246ICJNb2JpbGUgZWxlbWVudCB0cmFuc2R1Y3Rpb24gaW5mbyBvZiB0aGUgZm9ybSBDSFIsU1RBUlQsRU5ELFBPTEFSSVRZIgogICAgICB9LAogICAgICBER1ZJRDogewogICAgICAgIE51bWJlcjogMSwKICAgICAgICBUeXBlOiAiU3RyaW5nIiwKICAgICAgICBEZXNjcmlwdGlvbjogIklEIG9mIHRoaXMgZWxlbWVudCBpbiBEYXRhYmFzZSBvZiBHZW5vbWljIFZhcmlhdGlvbiIKICAgICAgfSwKICAgICAgREJWQVJJRDogewogICAgICAgIE51bWJlcjogMSwKICAgICAgICBUeXBlOiAiU3RyaW5nIiwKICAgICAgICBEZXNjcmlwdGlvbjogIklEIG9mIHRoaXMgZWxlbWVudCBpbiBEQlZBUiIKICAgICAgfSwKICAgICAgREJSSVBJRDogewogICAgICAgIE51bWJlcjogMSwKICAgICAgICBUeXBlOiAiU3RyaW5nIiwKICAgICAgICBEZXNjcmlwdGlvbjogIklEIG9mIHRoaXMgZWxlbWVudCBpbiBEQlJJUCIKICAgICAgfSwKICAgICAgTUFURUlEOiB7CiAgICAgICAgTnVtYmVyOiBudWxsLAogICAgICAgIFR5cGU6ICJTdHJpbmciLAogICAgICAgIERlc2NyaXB0aW9uOiAiSUQgb2YgbWF0ZSBicmVha2VuZHMiCiAgICAgIH0sCiAgICAgIFBBUklEOiB7CiAgICAgICAgTnVtYmVyOiAxLAogICAgICAgIFR5cGU6ICJTdHJpbmciLAogICAgICAgIERlc2NyaXB0aW9uOiAiSUQgb2YgcGFydG5lciBicmVha2VuZCIKICAgICAgfSwKICAgICAgRVZFTlQ6IHsKICAgICAgICBOdW1iZXI6IDEsCiAgICAgICAgVHlwZTogIlN0cmluZyIsCiAgICAgICAgRGVzY3JpcHRpb246ICJJRCBvZiBldmVudCBhc3NvY2lhdGVkIHRvIGJyZWFrZW5kIgogICAgICB9LAogICAgICBDSUxFTjogewogICAgICAgIE51bWJlcjogMiwKICAgICAgICBUeXBlOiAiSW50ZWdlciIsCiAgICAgICAgRGVzY3JpcHRpb246ICJDb25maWRlbmNlIGludGVydmFsIGFyb3VuZCB0aGUgaW5zZXJ0ZWQgbWF0ZXJpYWwgYmV0d2VlbiBicmVha2VuZCIKICAgICAgfSwKICAgICAgRFBBREo6IHsgVHlwZTogIkludGVnZXIiLCBEZXNjcmlwdGlvbjogIlJlYWQgRGVwdGggb2YgYWRqYWNlbmN5IiB9LAogICAgICBDTjogewogICAgICAgIE51bWJlcjogMSwKICAgICAgICBUeXBlOiAiSW50ZWdlciIsCiAgICAgICAgRGVzY3JpcHRpb246ICJDb3B5IG51bWJlciBvZiBzZWdtZW50IGNvbnRhaW5pbmcgYnJlYWtlbmQiCiAgICAgIH0sCiAgICAgIENOQURKOiB7CiAgICAgICAgTnVtYmVyOiBudWxsLAogICAgICAgIFR5cGU6ICJJbnRlZ2VyIiwKICAgICAgICBEZXNjcmlwdGlvbjogIkNvcHkgbnVtYmVyIG9mIGFkamFjZW5jeSIKICAgICAgfSwKICAgICAgQ0lDTjogewogICAgICAgIE51bWJlcjogMiwKICAgICAgICBUeXBlOiAiSW50ZWdlciIsCiAgICAgICAgRGVzY3JpcHRpb246ICJDb25maWRlbmNlIGludGVydmFsIGFyb3VuZCBjb3B5IG51bWJlciBmb3IgdGhlIHNlZ21lbnQiCiAgICAgIH0sCiAgICAgIENJQ05BREo6IHsKICAgICAgICBOdW1iZXI6IG51bGwsCiAgICAgICAgVHlwZTogIkludGVnZXIiLAogICAgICAgIERlc2NyaXB0aW9uOiAiQ29uZmlkZW5jZSBpbnRlcnZhbCBhcm91bmQgY29weSBudW1iZXIgZm9yIHRoZSBhZGphY2VuY3kiCiAgICAgIH0KICAgIH0sCiAgICBHZW5vdHlwZUZpZWxkczogewogICAgICBBRDogewogICAgICAgIE51bWJlcjogIlIiLAogICAgICAgIFR5cGU6ICJJbnRlZ2VyIiwKICAgICAgICBEZXNjcmlwdGlvbjogIlJlYWQgZGVwdGggZm9yIGVhY2ggYWxsZWxlIgogICAgICB9LAogICAgICBBREY6IHsKICAgICAgICBOdW1iZXI6ICJSIiwKICAgICAgICBUeXBlOiAiSW50ZWdlciIsCiAgICAgICAgRGVzY3JpcHRpb246ICJSZWFkIGRlcHRoIGZvciBlYWNoIGFsbGVsZSBvbiB0aGUgZm9yd2FyZCBzdHJhbmQiCiAgICAgIH0sCiAgICAgIEFEUjogewogICAgICAgIE51bWJlcjogIlIiLAogICAgICAgIFR5cGU6ICJJbnRlZ2VyIiwKICAgICAgICBEZXNjcmlwdGlvbjogIlJlYWQgZGVwdGggZm9yIGVhY2ggYWxsZWxlIG9uIHRoZSByZXZlcnNlIHN0cmFuZCIKICAgICAgfSwKICAgICAgRFA6IHsKICAgICAgICBOdW1iZXI6IDEsCiAgICAgICAgVHlwZTogIkludGVnZXIiLAogICAgICAgIERlc2NyaXB0aW9uOiAiUmVhZCBkZXB0aCIKICAgICAgfSwKICAgICAgRUM6IHsKICAgICAgICBOdW1iZXI6ICJBIiwKICAgICAgICBUeXBlOiAiSW50ZWdlciIsCiAgICAgICAgRGVzY3JpcHRpb246ICJFeHBlY3RlZCBhbHRlcm5hdGUgYWxsZWxlIGNvdW50cyIKICAgICAgfSwKICAgICAgRlQ6IHsKICAgICAgICBOdW1iZXI6IDEsCiAgICAgICAgVHlwZTogIlN0cmluZyIsCiAgICAgICAgRGVzY3JpcHRpb246ICdGaWx0ZXIgaW5kaWNhdGluZyBpZiB0aGlzIGdlbm90eXBlIHdhcyAiY2FsbGVkIicKICAgICAgfSwKICAgICAgR0w6IHsKICAgICAgICBOdW1iZXI6ICJHIiwKICAgICAgICBUeXBlOiAiRmxvYXQiLAogICAgICAgIERlc2NyaXB0aW9uOiAiR2Vub3R5cGUgbGlrZWxpaG9vZHMiCiAgICAgIH0sCiAgICAgIEdQOiB7CiAgICAgICAgTnVtYmVyOiAiRyIsCiAgICAgICAgVHlwZTogIkZsb2F0IiwKICAgICAgICBEZXNjcmlwdGlvbjogIkdlbm90eXBlIHBvc3RlcmlvciBwcm9iYWJpbGl0aWVzIgogICAgICB9LAogICAgICBHUTogewogICAgICAgIE51bWJlcjogMSwKICAgICAgICBUeXBlOiAiSW50ZWdlciIsCiAgICAgICAgRGVzY3JpcHRpb246ICJDb25kaXRpb25hbCBnZW5vdHlwZSBxdWFsaXR5IgogICAgICB9LAogICAgICBHVDogewogICAgICAgIE51bWJlcjogMSwKICAgICAgICBUeXBlOiAiU3RyaW5nIiwKICAgICAgICBEZXNjcmlwdGlvbjogIkdlbm90eXBlIgogICAgICB9LAogICAgICBIUTogewogICAgICAgIE51bWJlcjogMiwKICAgICAgICBUeXBlOiAiSW50ZWdlciIsCiAgICAgICAgRGVzY3JpcHRpb246ICJIYXBsb3R5cGUgcXVhbGl0eSIKICAgICAgfSwKICAgICAgTVE6IHsKICAgICAgICBOdW1iZXI6IDEsCiAgICAgICAgVHlwZTogIkludGVnZXIiLAogICAgICAgIERlc2NyaXB0aW9uOiAiUk1TIG1hcHBpbmcgcXVhbGl0eSIKICAgICAgfSwKICAgICAgUEw6IHsKICAgICAgICBOdW1iZXI6ICJ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0aCgiIyMiKSkgewogICAgICAgICAgdGhpcy5fcGFyc2VNZXRhZGF0YShsaW5lKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgbGFzdExpbmUgPSBsaW5lOwogICAgICAgIH0KICAgICAgfSk7CiAgICAgIGlmICghbGFzdExpbmUpIHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIk5vIGZvcm1hdCBsaW5lIGZvdW5kIGluIGhlYWRlciIpOwogICAgICB9CiAgICAgIGNvbnN0IGZpZWxkcyA9IGxhc3RMaW5lLnRyaW0oKS5zcGxpdCgiCSIpOwogICAgICBjb25zdCB0aGlzSGVhZGVyID0gZmllbGRzLnNsaWNlKDAsIDgpOwogICAgICBjb25zdCBjb3JyZWN0SGVhZGVyID0gWwogICAgICAgICIjQ0hST00iLAogICAgICAgICJQT1MiLAogICAgICAgICJJRCIsCiAgICAgICAgIlJFRiIsCiAgICAgICAgIkFMVCIsCiAgICAgICAgIlFVQUwiLAogICAgICAgICJGSUxURVIiLAogICAgICAgICJJTkZPIgogICAgICBdOwogICAgICBpZiAoZmllbGRzLmxlbmd0aCA8IDgpIHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYFZDRiBoZWFkZXIgbWlzc2luZyBjb2x1bW5zOgoke2xhc3RMaW5lfWApOwogICAgICB9IGVsc2UgaWYgKHRoaXNIZWFkZXIubGVuZ3RoICE9PSBjb3JyZWN0SGVhZGVyLmxlbmd0aCB8fCAhdGhpc0hlYWRlci5ldmVyeSgodmFsdWUsIGluZGV4KSA9PiB2YWx1ZSA9PT0gY29ycmVjdEhlYWRlcltpbmRleF0pKSB7CiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBWQ0YgY29sdW1uIGhlYWRlcnMgbm90IGNvcnJlY3Q6CiR7bGFzdExpbmV9YCk7CiAgICAgIH0KICAgICAgdGhpcy5zYW1wbGVzID0gZmllbGRzLnNsaWNlKDkpOwogICAgfQogICAgX3BhcnNlR2Vub3R5cGVzKGZvcm1hdCwgcH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c3RyLmxlbmd0aDsgaSArPSAxKSB7CiAgICAgICAgaWYgKHN0YXRlID09PSAxKSB7CiAgICAgICAgICBpZiAoc3RyW2ldID09PSAiPSIpIHsKICAgICAgICAgICAgc3RhdGUgPSAyOwogICAgICAgICAgfSBlbHNlIGlmIChzdHJbaV0gIT09IHBhaXJTZXBhcmF0b3IpIHsKICAgICAgICAgICAgY3VycktleSArPSBzdHJbaV07CiAgICAgICAgICB9IGVsc2UgaWYgKGN1cnJWYWx1ZSA9PT0gIiIpIHsKICAgICAgICAgICAgZGF0YVtjdXJyS2V5XSA9IG51bGw7CiAgICAgICAgICAgIGN1cnJLZXkgPSAiIjsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgaWYgKHN0YXRlID09PSAyKSB7CiAgICAgICAgICBpZiAoc3RyW2ldID09PSBwYWlyU2VwYXJhdG9yKSB7CiAgICAgICAgICAgIGRhdGFbY3VycktleV0gPSBjdXJyVmFsdWU7CiAgICAgICAgICAgIGN1cnJLZXkgPSAiIjsKICAgICAgICAgICAgY3VyclZhbHVlID0gIiI7CiAgICAgICAgICAgIHN0YXRlID0gMTsKICAgICAgICAgIH0gZWxzZSBpZiAoc3RyW2ldID09PSAnIicpIHsKICAgICAgICAgICAgc3RhdGUgPSAzOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY3VyclZhbHVlICs9IHN0cltpXTsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgaWYgKHN0YXRlID09PSAzKSB7CiAgICAgICAgICBpZiAoc3RyW2ldICE9PSAnIicpIHsKICAgICAgICAgICAgY3VyclZhbHVlICs9IHN0cltpXTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHN0YXRlID0gMjsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKHN0YXRlID09PSAyIHx8IHN0YXRlID09PSAzKSB7CiAgICAgICAgZGF0YVtjdXJyS2V5XSA9IGN1cnJWYWx1ZTsKICAgICAgfSBlbHNlIGlmIChzdGF0ZSA9PT0gMSkgewogICAgICAgIGRhdGFbY3VycktleV0gPSBudWxsOwogICAgICB9CiAgICAgIHJldHVybiBkYXRhOwogICAgfQogICAgcGFyc2VMaW5lKGxpbmUpIHsKICAgICAgbGluZSA9IGxpbmUudHJpbSgpOwogICAgICBpZiAoIWxpbmUubGVuZ3RoKSB7CiAgICAgICAgcmV0dXJuIHZvaWQgMDsKICAgICAgfQogICAgICBjb25zdCBwYXJzZXIgPSB0aGlzOwogICAgICBsZXQgY3VyckNoYXIgPSAwOwogICAgICBmb3IgKGxldCBjdXJyRmllbGQgPSAwOyBjdXJyQ2hhciA8IGxpbmUubGVuZ3RoOyBjdXJyQ2hhciArPSAxKSB7CiAgICAgICAgaWYgKGxpbmVbY3VyckNoYXJdID09PSAiCSIpIHsKICAgICAgICAgIGN1cnJGaWVsZCArPSAxOwogICAgICAgIH0KICAgICAgICBpZiAoY3VyckZpZWxkID09PSA5KSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgICAgY29uc3QgZmllbGRzID0gbGluZS5zdWJzdHIoMCwgY3VyckNoYXIpLnNwbGl0KCIJIik7CiAgICAgIGNvbnN0IHJlc3QgPSBsaW5lLnN1YnN0cihjdXJyQ2hhciArIDEpOwogICAgICBjb25zdCBbQ0hST00sIFBPUywgSUQsIFJFRiwgQUxULCBRVUFMLCBGSUxURVJdID0gZmllbGRzOwogICAgICBjb25zdCBjaHJvbSA9IENIUk9NOwogICAgICBjb25zdCBwb3MgPSArUE9TOwogICAgICBjb25zdCBpZCA9IElEID09PSAiLiIgPyBudWxsIDogSUQuc3BsaXQoIjsiKTsKICAgICAgY29uc3QgcmVmID0gUkVGOwogICAgICBjb25zdCBhbHQgPSBBTFQgPT09ICIuIiA/IG51bGwgOiBBTFQuc3BsaXQoIiwiKTsKICAgICAgY29uc3QgcXVhbCA9IFFVQUwgPT09ICIuIiA/IG51bGwgOiArUVVBTDsKICAgICAgY29uc3QgZmlsdGVyID0gRklMVEVSID09PSAiLiIgPyBudWxsIDogRklMVEVSLnNwbGl0KCI7Iik7CiAgICAgIGlmICh0aGlzLnN0cmljdCAmJiBmaWVsZHNbN10gPT09IHZvaWQgMCkgewogICAgICAgIHRocm93IG5ldyBFcnJvcigibm8gSU5GTyBmaWVsZCBzcGVjaWZpZWQsIG11c3QgY29udGFpbiBhdCBsZWFzdCBhICcuJyAodHVybiBvZmYgc3RyaWN0IG1vZGUgdG8gYWxsb3cpIik7CiAgICAgIH0KICAgICAgY29uc3QgaW5mbyA9IGZpZWxkc1s3XSA9PT0gdm9pZCAwIHx8IGZpZWxkc1s3XSA9PT0gIi4iID8ge30gOiB0aGlzLl9wYXJzZUtleVZhbHVlKGZpZWxkc1s3XSk7CiAgICAgIE9iamVjdC5rZXlzKGluZm8pLmZvckVhY2goKGtleSkgPT4gewogICAgICAgIGxldCBpdGVtczsKICAgICAgICBpZiAoaW5mb1trZXldKSB7CiAgICAgICAgICBpdGVtcyA9IGluZm9ba2V5XS5zcGxpdCgiLCIpLm1hcCgodmFsKSA9PiB2YWwgPT09ICIuIiA/IG51bGwgOiB2YWwpLm1hcCgoZikgPT4gZiA/IGRlY29kZVVSSUNvbXBvbmVudE5vVGhyb3coZikgOiBmKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgaXRlbXMgPSBpbmZvW2tleV07CiAgICAgICAgfQogICAgICAgIGNvbnN0IGl0ZW1UeXBlID0gdGhpcy5nZXRNZXRhZGF0YSgiSU5GTyIsIGtleSwgIlR5cGUiKTsKICAgICAgICBpZiAoaXRlbVR5cGUpIHsKICAgICAgICAgIGlmIChpdGVtVHlwZSA9PT0gIkludGVnZXIiIHx8IGl0ZW1UeXBlID09PSAiRmxvYXQiKSB7CiAgICAgICAgICAgIGl0ZW1zID0gaXRlbXMubWFwKCh2YWwpID0+IHsKICAgICAgICAgICAgICBpZiAodmFsID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgcmV0dXJuIE51bWJlcih2YWwpOwogICAgICAgICAgICB9KTsKICAgICAgICAgIH0gZWxzZSBpZiAoaXRlbVR5cGUgPT09ICJGbGFnIikgewogICAgICAgICAgICBpZiAoaW5mb1trZXldKSB7CiAgICAgICAgICAgICAgY29uc29sZS53YXJuKGBJbmZvIGZpZWxkICR7a2V5fSBpcyBhIEZsYWcgYW5kIHNob3VsZCBub3QgaGF2ZSBhIHZhbHVlIChnb3QgdmFsdWUgJHtpbmZvW2tleV19KWApOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGl0ZW1zID0gdHJ1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpbmZvW2tleV0gPSBpdGVtczsKICAgICAgfSk7CiAgICAgIGNvbnN0IHZhcmlhbnQgPSBuZXcgVmFyaWFudCh7CiAgICAgICAgQ0hST006IGNocm9tLAogICAgICAgIFBPUzogcG9zLAogICAgICAgIEFMVDogYWx0LAogICAgICAgIElORk86IGluZm8sCiAgICAgICAgUkVGOiByZWYsCiAgICAgICAgRklMVEVSOiBmaWx0ZXIgJiYgZmlsdGVyLmxlbmd0aCA9PT0gMSAmJiBmaWx0ZXJbMF0gPT09ICJQQVNTIiA/ICJQQVNTIiA6IGZpbHRlciwKICAgICAgICBJRDogaWQsCiAgICAgICAgUVVBTDogcXVhbAogICAgICB9KTsKICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHZhcmlhbnQsICJTQU1QTEVTIiwgewogICAgICAgIGdldCgpIHsKICAgICAgICAgIGNvbnN0IHNhbXBsZXMgPSBwYXJzZXIuX3BhcnNlR2Vub3R5cGVzKGZpZWxkc1s4XSwgcmVzdCk7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgIlNBTVBMRVMiLCB7CiAgICAgICAgICAgIHZhbHVlOiBzYW1wbGVzLAogICAgICAgICAgICBjb25maWd1cmFibGU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PT0gbnVsbCkKICAgICAgICBsbyA9IDA7CiAgICAgIGlmIChoaSA9PSBudWxsKQogICAgICAgIGhpID0gYS5sZW5ndGg7CiAgICAgIHdoaWxlIChsbyA8IGhpKSB7CiAgICAgICAgY29uc3QgbWlkID0gbG8gKyBoaSA+Pj4gMTsKICAgICAgICBpZiAoY29tcGFyZShhW21pZF0sIHgpID4gMCkKICAgICAgICAgIGhpID0gbWlkOwogICAgICAgIGVsc2UKICAgICAgICAgIGxvID0gbWlkICsgMTsKICAgICAgfQogICAgICByZXR1cm4gbG87CiAgICB9CiAgICBmdW5jdGlvbiBjZW50ZXIoYSwgeCwgbG8sIGhpKSB7CiAgICAgIGlmIChsbyA9PSBudWxsKQogICAgICAgIGxvID0gMDsKICAgICAgaWYgKGhpID09IG51bGwpCiAgICAgICAgaGkgPSBhLmxlbmd0aDsKICAgICAgY29uc3QgaSA9IGxlZnQoYSwgeCwgbG8sIGhpIC0gMSk7CiAgICAgIHJldHVybiBpID4gbG8gJiYgZGVsdGEoYVtpIC0gMV0sIHgpID4gLWRlbHRhKGFbaV0sIHgpID8gaSAtIDEgOiBpOwogICAgfQogICAgcmV0dXJuIHsgbGVmdCwgY2VudGVyLCByaWdodCB9OwogIH0KICBmdW5jdGlvbiBhc2NlbmRpbmdDb21wYXJhdG9yKGYpIHsKICAgIHJldHVybiAoZCwgeCkgPT4gYXNjZW5kaW5nX2RlZmF1bHQoZihkKSwgeCk7CiAgfQoKICAvLyBzcmMvZGF0YS1mZXRjaGVycy91dGlscy50cwogIHZhciBEYXRhU291cmNlID0gY2xhc3MgewogICAgY29uc3RydWN0b3IoZmlsZSwgY2hyb21TaXplcywgb3B0aW9ucykgewogICAgICB0aGlzLmZpbGUgPSBmaWxlOwogICAgICB0aGlzLm9wdGlvbnMgPSBvcHRpb25zOwogICAgICB0aGlzLmNocm9tSW5mbyA9IHNpemVzVG9DaHJvbUluZm8oY2hyb21TaXplcyk7CiAgICAgIHRoaXMudGlsZXNldEluZm8gPSB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lBPUzsKICAgICAgICBjb25zdCB0aWxlc1Byb21pc2UgPSBuZXcgUHJvbWlzZSgocmVzb2x2ZSkgPT4gewogICAgICAgICAgY29uc3QgdGlsZXMgPSBbXTsKICAgICAgICAgIGNvbnN0IGxpbmVDYWxsYmFjayA9IChsaW5lKSA9PiB7CiAgICAgICAgICAgIGNvbnN0IHZjZlJlY29yZCA9IHBhcnNlci5wYXJzZUxpbmUobGluZSk7CiAgICAgICAgICAgIGNvbnN0IHZjZlRpbGUgPSByZWNvcmRUb1RpbGUodmNmUmVjb3JkLCBjaHJvbVN0YXJ0LCBwcmV2UE9TKTsKICAgICAgICAgICAgcHJldlBPUyA9IHZjZlRpbGUuUE9TOwogICAgICAgICAgICB0aWxlcy5wdXNoKHZjZlRpbGUpOwogICAgICAgICAgfTsKICAgICAgICAgIGlmIChtYXhYID4gY2hyb21FbmQpIHsKICAgICAgICAgICAgc3RhcnRQb3MgPSBjdXJNaW5YIC0gY2hyb21TdGFydDsKICAgICAgICAgICAgZW5kUG9zID0gY2hyb21FbmQgLSBjaHJvbVN0YXJ0OwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhcnRQb3MgPSBNYXRoLmZsb29yKGN1ck1pblggLSBjaHJvbVN0YXJ0KTsKICAgICAgICAgICAgZW5kUG9zID0gTWF0aC5jZWlsKG1heFggLSBjaHJvbVN0YXJ0KTsKICAgICAgICAgIH0KICAgICAgICAgIHNvdXJjZS5maWxlLnRiaS5nZXRMaW5lcyhjaHJvbU5hbWUsIHN0YXJ0UG9zLCBlbmRQb3MsIGxpbmVDYWxsYmFjaykudGhlbigoKSA9PiB7CiAgICAgICAgICAgIHJlc29sdmUodGlsZXMpOwogICAgICAgICAgfSk7CiAgICAgICAgfSk7CiAgICAgICAgcmVjb3JkUHJvbWlzZXMucHVzaCh0aWxlc1Byb21pc2UpOwogICAgICAgIGlmIChtYXhYIDw9IGNocm9tRW5kKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9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AgIGNvbnN0IHRpbGVXaWR0aCA9ICtzb3VyY2UudGlsZXNldEluZm8ubWF4X3dpZHRoIC8gMiAqKiArejsKICAgIGNvbnN0IG1pblggPSBzb3VyY2UudGlsZXNldEluZm8ubWluX3Bvc1swXSArIHggKiB0aWxlV2lkdGg7CiAgICBjb25zdCBtYXhYID0gc291cmNlLnRpbGVzZXRJbmZvLm1pbl9wb3NbMF0gKyAoeCArIDEpICogdGlsZVdpZHRoOwogICAgdGlsZVZhbHVlc1tDQUNIRV9LRVldID0gYXdhaXQgc291cmNlLmZpbGUuZ2V0VGlsZURhdGEobWluWCwgbWF4WCk7CiAgICByZXR1cm4gdGlsZVZhbHVlc1tDQUNIRV9LRVldOwogIH07CiAgdmFyIGZldGNoVGlsZXNEZWJvdW5jZWQgPSBhc3luYyAodWlkLCB0aWxlSWRzKSA9PiB7CiAgICBjb25zdCB0aWxlcyA9IHt9OwogICAgY29uc3QgdmFsaWRUaWxlSWRzID0gW107CiAgICBjb25zdCB0aWxlUHJvbWlzZXMgPSBbXTsKICAgIGZvciAoY29uc3QgdGlsZUlkIG9mIHRpbGVJZHMpIHsKICAgICAgY29uc3QgcGFydHMgPSB0aWxlSWQuc3BsaXQoIi4iKTsKICAgICAgY29uc3QgeiA9IHBhcnNlSW50KHBhcnRzWzBdLCAxMCk7CiAgICAgIGNvbnN0IHggPSBwYXJzZUludChwYXJ0c1sxXSwgMTApOwogICAgICBpZiAoTnVtYmVyLmlzTmFOKHgpIHx8IE51bWJlci5pc05hTih6KSkgewogICAgICAgIGNvbnNvbGUud2FybigiSW52YWxpZCB0aWxlIHpvb20gb3IgcG9zaXRpb246IiwgeiwgeCk7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdmFsaWRUaWxlSWRzLnB1c2godGlsZUlkKTsKICAgICAgdGlsZVByb21pc2VzLnB1c2godGlsZSh1aWQsIHosIHgpKTsKICAgIH0KICAgIHJldHVybiBQcm9taXNlLmFsbCh0aWxlUHJvbWlzZXM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kpTIEZvdW5kYXRpb24gYW5kIG90aGVyIGNvbnRyaWJ1dG9ycyA8aHR0cHM6Ly9vcGVuanNmLm9yZy8+CiAqIFJlbGVhc2VkIHVuZGVyIE1JVCBsaWNlbnNlIDxodHRwczovL2xvZGFzaC5jb20vbGljZW5zZT4KICogQmFzZWQgb24gVW5kZXJzY29yZS5qcyAxLjguMyA8aHR0cDovL3VuZGVyc2NvcmVqcy5vcmcvTElDRU5TRT4KICogQ29weXJpZ2h0IEplcmVteSBBc2hrZW5hcywgRG9jdW1lbnRDbG91ZCBhbmQgSW52ZXN0aWdhdGl2ZSBSZXBvcnRlcnMgJiBFZGl0b3JzCiAqLwo=",WXe=typeof window<"u"&&window.Blob&&new Blob([atob(S8e)],{type:"text/javascript;charset=utf-8"});function CTg(){const e=WXe&&(window.URL||window.webkitURL).createObjectURL(WXe);try{return e?new Worker(e):new Worker("data:application/javascript;base64,"+S8e,{type:"module"})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const aTg=200;class R8e{constructor(g,i){at(this,"dataConfig",{}),at(this,"uid"),at(this,"prevRequestTime"),at(this,"track"),at(this,"toFetch"),at(this,"fetchTimeout"),at(this,"worker"),this.uid=g.libraries.slugid.nice(),this.prevRequestTime=0,this.toFetch=new Set;const{url:n,indexUrl:I,assembly:r,...o}=i;this.worker=Xz(new CTg).then(async C=>{const a=Object.entries(In(r).size);return await C.init(this.uid,{url:n,indexUrl:I},a,o),C})}async tilesetInfo(g){(await this.worker).tilesetInfo(this.uid).then(g)}fetchTilesDebounced(g,i){this.track.drawLoadingCue(),i.forEach(n=>this.toFetch.add(n)),this.fetchTimeout&&clearTimeout(this.fetchTimeout),this.fetchTimeout=setTimeout(()=>{this.sendFetch(g,[...this.toFetch]),this.toFetch.clear()},aTg)}async sendFetch(g,i){(await this.worker).fetchTilesDebounced(this.uid,i).then(g)}async getTabularData(g){const i=await(await this.worker).getTabularData(this.uid,g);return JSON.parse(new TextDecoder().decode(i))}}at(R8e,"config",{type:"vcf"});const Y_=BigInt(32);function sTg(e,g,i){const n=+!!i,I=+!i;return BigInt(e.getInt32(g,i)*I+e.getInt32(g+4,i)*n)<>Y_),r=Number(i&BigInt(4294967295));n?(e.setInt32(g+4,I,n),e.setUint32(g,r,n)):(e.setInt32(g,I,n),e.setUint32(g+4,r,n))}function cTg(e,g,i,n){const I=Number(i>>Y_),r=Number(i&BigInt(4294967295));n?(e.setUint32(g+4,I,n),e.setUint32(g,r,n)):(e.setUint32(g,I,n),e.setUint32(g+4,r,n))}"getBigInt64"in DataView||(DataView.prototype.getBigInt64=function(e,g){return sTg(this,e,g)});"getBigUint64"in DataView||(DataView.prototype.getBigUint64=function(e,g){return ATg(this,e,g)});"setBigInt64"in DataView||(DataView.prototype.setBigInt64=function(e,g,i){lTg(this,e,g,i)});"setBigUint64"in DataView||(DataView.prototype.setBigUint64=function(e,g,i){cTg(this,e,g,i)});let uTg=class{constructor(g,i){this.code="",this.scopes=[["vars"]],this.bitFields=[],this.tmpVariableCount=0,this.references=new Map,this.imports=[],this.reverseImports=new Map,this.useContextVariables=!1,this.importPath=g,this.useContextVariables=i}generateVariable(g){const i=[...this.scopes[this.scopes.length-1]];return g&&i.push(g),i.join(".")}generateOption(g){switch(typeof g){case"number":return g.toString();case"string":return this.generateVariable(g);case"function":return`${this.addImport(g)}.call(${this.generateVariable()}, vars)`}}generateError(g){this.pushCode(`throw new Error(${g});`)}generateTmpVariable(){return"$tmp"+this.tmpVariableCount++}pushCode(g){this.code+=g+` +`}pushPath(g){g&&this.scopes[this.scopes.length-1].push(g)}popPath(g){g&&this.scopes[this.scopes.length-1].pop()}pushScope(g){this.scopes.push([g])}popScope(){this.scopes.pop()}addImport(g){if(!this.importPath)return`(${g})`;let i=this.reverseImports.get(g);return i||(i=this.imports.push(g)-1,this.reverseImports.set(g,i)),`${this.importPath}[${i}]`}addReference(g){this.references.has(g)||this.references.set(g,{resolved:!1,requested:!1})}markResolved(g){const i=this.references.get(g);i&&(i.resolved=!0)}markRequested(g){g.forEach(i=>{const n=this.references.get(i);n&&(n.requested=!0)})}getUnresolvedReferences(){return Array.from(this.references).filter(([g,i])=>!i.resolved&&!i.requested).map(([g,i])=>g)}};const Os=new Map,Np="___parser_",Js={uint8:1,uint16le:2,uint16be:2,uint32le:4,uint32be:4,int8:1,int16le:2,int16be:2,int32le:4,int32be:4,int64be:8,int64le:8,uint64be:8,uint64le:8,floatle:4,floatbe:4,doublele:8,doublebe:8},bY={uint8:"Uint8",uint16le:"Uint16",uint16be:"Uint16",uint32le:"Uint32",uint32be:"Uint32",int8:"Int8",int16le:"Int16",int16be:"Int16",int32le:"Int32",int32be:"Int32",int64be:"BigInt64",int64le:"BigInt64",uint64be:"BigUint64",uint64le:"BigUint64",floatle:"Float32",floatbe:"Float32",doublele:"Float64",doublebe:"Float64"},yY={uint8:!1,uint16le:!0,uint16be:!1,uint32le:!0,uint32be:!1,int8:!1,int16le:!0,int16be:!1,int32le:!0,int32be:!1,int64be:!1,int64le:!0,uint64be:!1,uint64le:!0,floatle:!0,floatbe:!1,doublele:!0,doublebe:!1};class ri{constructor(){this.varName="",this.type="",this.options={},this.endian="be",this.useContextVariables=!1}static start(){return new ri}primitiveGenerateN(g,i){const n=bY[g],I=yY[g];i.pushCode(`${i.generateVariable(this.varName)} = dataView.get${n}(offset, ${I});`),i.pushCode(`offset += ${Js[g]};`)}primitiveN(g,i,n){return this.setNextParser(g,i,n)}useThisEndian(g){return g+this.endian.toLowerCase()}uint8(g,i={}){return this.primitiveN("uint8",g,i)}uint16(g,i={}){return this.primitiveN(this.useThisEndian("uint16"),g,i)}uint16le(g,i={}){return this.primitiveN("uint16le",g,i)}uint16be(g,i={}){return this.primitiveN("uint16be",g,i)}uint32(g,i={}){return this.primitiveN(this.useThisEndian("uint32"),g,i)}uint32le(g,i={}){return this.primitiveN("uint32le",g,i)}uint32be(g,i={}){return this.primitiveN("uint32be",g,i)}int8(g,i={}){return this.primitiveN("int8",g,i)}int16(g,i={}){return this.primitiveN(this.useThisEndian("int16"),g,i)}int16le(g,i={}){return this.primitiveN("int16le",g,i)}int16be(g,i={}){return this.primitiveN("int16be",g,i)}int32(g,i={}){return this.primitiveN(this.useThisEndian("int32"),g,i)}int32le(g,i={}){return this.primitiveN("int32le",g,i)}int32be(g,i={}){return this.primitiveN("int32be",g,i)}bigIntVersionCheck(){if(!DataView.prototype.getBigInt64)throw new Error("BigInt64 is unsupported on this runtime")}int64(g,i={}){return this.bigIntVersionCheck(),this.primitiveN(this.useThisEndian("int64"),g,i)}int64be(g,i={}){return this.bigIntVersionCheck(),this.primitiveN("int64be",g,i)}int64le(g,i={}){return this.bigIntVersionCheck(),this.primitiveN("int64le",g,i)}uint64(g,i={}){return this.bigIntVersionCheck(),this.primitiveN(this.useThisEndian("uint64"),g,i)}uint64be(g,i={}){return this.bigIntVersionCheck(),this.primitiveN("uint64be",g,i)}uint64le(g,i={}){return this.bigIntVersionCheck(),this.primitiveN("uint64le",g,i)}floatle(g,i={}){return this.primitiveN("floatle",g,i)}floatbe(g,i={}){return this.primitiveN("floatbe",g,i)}doublele(g,i={}){return this.primitiveN("doublele",g,i)}doublebe(g,i={}){return this.primitiveN("doublebe",g,i)}bitN(g,i,n){return n.length=g,this.setNextParser("bit",i,n)}bit1(g,i={}){return this.bitN(1,g,i)}bit2(g,i={}){return this.bitN(2,g,i)}bit3(g,i={}){return this.bitN(3,g,i)}bit4(g,i={}){return this.bitN(4,g,i)}bit5(g,i={}){return this.bitN(5,g,i)}bit6(g,i={}){return this.bitN(6,g,i)}bit7(g,i={}){return this.bitN(7,g,i)}bit8(g,i={}){return this.bitN(8,g,i)}bit9(g,i={}){return this.bitN(9,g,i)}bit10(g,i={}){return this.bitN(10,g,i)}bit11(g,i={}){return this.bitN(11,g,i)}bit12(g,i={}){return this.bitN(12,g,i)}bit13(g,i={}){return this.bitN(13,g,i)}bit14(g,i={}){return this.bitN(14,g,i)}bit15(g,i={}){return this.bitN(15,g,i)}bit16(g,i={}){return this.bitN(16,g,i)}bit17(g,i={}){return this.bitN(17,g,i)}bit18(g,i={}){return this.bitN(18,g,i)}bit19(g,i={}){return this.bitN(19,g,i)}bit20(g,i={}){return this.bitN(20,g,i)}bit21(g,i={}){return this.bitN(21,g,i)}bit22(g,i={}){return this.bitN(22,g,i)}bit23(g,i={}){return this.bitN(23,g,i)}bit24(g,i={}){return this.bitN(24,g,i)}bit25(g,i={}){return this.bitN(25,g,i)}bit26(g,i={}){return this.bitN(26,g,i)}bit27(g,i={}){return this.bitN(27,g,i)}bit28(g,i={}){return this.bitN(28,g,i)}bit29(g,i={}){return this.bitN(29,g,i)}bit30(g,i={}){return this.bitN(30,g,i)}bit31(g,i={}){return this.bitN(31,g,i)}bit32(g,i={}){return this.bitN(32,g,i)}namely(g){return Os.set(g,this),this.alias=g,this}skip(g,i={}){return this.seek(g,i)}seek(g,i={}){if(i.assert)throw new Error("assert option on seek is not allowed.");return this.setNextParser("seek","",{length:g})}string(g,i){if(!i.zeroTerminated&&!i.length&&!i.greedy)throw new Error("One of length, zeroTerminated, or greedy must be defined for string.");if((i.zeroTerminated||i.length)&&i.greedy)throw new Error("greedy is mutually exclusive with length and zeroTerminated for string.");if(i.stripNull&&!(i.length||i.greedy))throw new Error("length or greedy must be defined if stripNull is enabled.");return i.encoding=i.encoding||"utf8",this.setNextParser("string",g,i)}buffer(g,i){if(!i.length&&!i.readUntil)throw new Error("length or readUntil must be defined for buffer.");return this.setNextParser("buffer",g,i)}wrapped(g,i){if(typeof i!="object"&&typeof g=="object"&&(i=g,g=""),!i||!i.wrapper||!i.type)throw new Error("Both wrapper and type must be defined for wrapped.");if(!i.length&&!i.readUntil)throw new Error("length or readUntil must be defined for wrapped.");return this.setNextParser("wrapper",g,i)}array(g,i){if(!i.readUntil&&!i.length&&!i.lengthInBytes)throw new Error("One of readUntil, length and lengthInBytes must be defined for array.");if(!i.type)throw new Error("type is required for array.");if(typeof i.type=="string"&&!Os.has(i.type)&&!(i.type in Js))throw new Error(`Array element type "${i.type}" is unkown.`);return this.setNextParser("array",g,i)}choice(g,i){if(typeof i!="object"&&typeof g=="object"&&(i=g,g=""),!i)throw new Error("tag and choices are are required for choice.");if(!i.tag)throw new Error("tag is requird for choice.");if(!i.choices)throw new Error("choices is required for choice.");for(const n in i.choices){const I=parseInt(n,10),r=i.choices[I];if(isNaN(I))throw new Error(`Choice key "${n}" is not a number.`);if(typeof r=="string"&&!Os.has(r)&&!(r in Js))throw new Error(`Choice type "${r}" is unkown.`)}return this.setNextParser("choice",g,i)}nest(g,i){if(typeof i!="object"&&typeof g=="object"&&(i=g,g=""),!i||!i.type)throw new Error("type is required for nest.");if(!(i.type instanceof ri)&&!Os.has(i.type))throw new Error("type must be a known parser name or a Parser object.");if(!(i.type instanceof ri)&&!g)throw new Error("type must be a Parser object if the variable name is omitted.");return this.setNextParser("nest",g,i)}pointer(g,i){if(!i.offset)throw new Error("offset is required for pointer.");if(!i.type)throw new Error("type is required for pointer.");if(typeof i.type=="string"&&!(i.type in Js)&&!Os.has(i.type))throw new Error(`Pointer type "${i.type}" is unkown.`);return this.setNextParser("pointer",g,i)}saveOffset(g,i={}){return this.setNextParser("saveOffset",g,i)}endianness(g){switch(g.toLowerCase()){case"little":this.endian="le";break;case"big":this.endian="be";break;default:throw new Error('endianness must be one of "little" or "big"')}return this}endianess(g){return this.endianness(g)}useContextVars(g=!0){return this.useContextVariables=g,this}create(g){if(!(g instanceof Function))throw new Error("Constructor must be a Function object.");return this.constructorFn=g,this}getContext(g){const i=new uTg(g,this.useContextVariables);return i.pushCode("var dataView = new DataView(buffer.buffer, buffer.byteOffset, buffer.length);"),this.alias?(this.addAliasedCode(i),i.pushCode(`return ${Np+this.alias}(0).result;`)):this.addRawCode(i),i}getCode(){const g="imports";return this.getContext(g).code}addRawCode(g){g.pushCode("var offset = 0;"),g.pushCode(`var vars = ${this.constructorFn?"new constructorFn()":"{}"};`),g.pushCode("vars.$parent = null;"),g.pushCode("vars.$root = vars;"),this.generate(g),this.resolveReferences(g),g.pushCode("delete vars.$parent;"),g.pushCode("delete vars.$root;"),g.pushCode("return vars;")}addAliasedCode(g){return g.pushCode(`function ${Np+this.alias}(offset, context) {`),g.pushCode(`var vars = ${this.constructorFn?"new constructorFn()":"{}"};`),g.pushCode("var ctx = Object.assign({$parent: null, $root: vars}, context || {});"),g.pushCode("vars = Object.assign(vars, ctx);"),this.generate(g),g.markResolved(this.alias),this.resolveReferences(g),g.pushCode("Object.keys(ctx).forEach(function (item) { delete vars[item]; });"),g.pushCode("return { offset: offset, result: vars };"),g.pushCode("}"),g}resolveReferences(g){const i=g.getUnresolvedReferences();g.markRequested(i),i.forEach(n=>{var I;(I=Os.get(n))===null||I===void 0||I.addAliasedCode(g)})}compile(){const g="imports",i=this.getContext(g);this.compiled=new Function(g,"TextDecoder",`return function (buffer, constructorFn) { ${i.code} };`)(i.imports,TextDecoder)}sizeOf(){let g=NaN;if(Object.keys(Js).indexOf(this.type)>=0)g=Js[this.type];else if(this.type==="string"&&typeof this.options.length=="number")g=this.options.length;else if(this.type==="buffer"&&typeof this.options.length=="number")g=this.options.length;else if(this.type==="array"&&typeof this.options.length=="number"){let i=NaN;typeof this.options.type=="string"?i=Js[this.options.type]:this.options.type instanceof ri&&(i=this.options.type.sizeOf()),g=this.options.length*i}else this.type==="seek"?g=this.options.length:this.type==="nest"?g=this.options.type.sizeOf():this.type||(g=0);return this.next&&(g+=this.next.sizeOf()),g}parse(g){return this.compiled||this.compile(),this.compiled(g,this.constructorFn)}setNextParser(g,i,n){const I=new ri;return I.type=g,I.varName=i,I.options=n,I.endian=this.endian,this.head?this.head.next=I:this.next=I,this.head=I,this}generate(g){if(this.type){switch(this.type){case"uint8":case"uint16le":case"uint16be":case"uint32le":case"uint32be":case"int8":case"int16le":case"int16be":case"int32le":case"int32be":case"int64be":case"int64le":case"uint64be":case"uint64le":case"floatle":case"floatbe":case"doublele":case"doublebe":this.primitiveGenerateN(this.type,g);break;case"bit":this.generateBit(g);break;case"string":this.generateString(g);break;case"buffer":this.generateBuffer(g);break;case"seek":this.generateSeek(g);break;case"nest":this.generateNest(g);break;case"array":this.generateArray(g);break;case"choice":this.generateChoice(g);break;case"pointer":this.generatePointer(g);break;case"saveOffset":this.generateSaveOffset(g);break;case"wrapper":this.generateWrapper(g);break}this.type!=="bit"&&this.generateAssert(g)}const i=g.generateVariable(this.varName);return this.options.formatter&&this.type!=="bit"&&this.generateFormatter(g,i,this.options.formatter),this.generateNext(g)}generateAssert(g){if(!this.options.assert)return;const i=g.generateVariable(this.varName);switch(typeof this.options.assert){case"function":{const n=g.addImport(this.options.assert);g.pushCode(`if (!${n}.call(vars, ${i})) {`)}break;case"number":g.pushCode(`if (${this.options.assert} !== ${i}) {`);break;case"string":g.pushCode(`if (${JSON.stringify(this.options.assert)} !== ${i}) {`);break;default:throw new Error("assert option must be a string, number or a function.")}g.generateError(`"Assertion error: ${i} is " + ${JSON.stringify(this.options.assert.toString())}`),g.pushCode("}")}generateNext(g){return this.next&&(g=this.next.generate(g)),g}generateBit(g){const i=JSON.parse(JSON.stringify(this));if(i.options=this.options,i.generateAssert=this.generateAssert.bind(this),i.generateFormatter=this.generateFormatter.bind(this),i.varName=g.generateVariable(i.varName),g.bitFields.push(i),!this.next||this.next&&["bit","nest"].indexOf(this.next.type)<0){const n=g.generateTmpVariable();g.pushCode(`var ${n} = 0;`);const I=(s=0)=>{let l=0;for(let c=s;c32)break;l+=u}return l},r=s=>(s<=8?(g.pushCode(`${n} = dataView.getUint8(offset);`),s=8):s<=16?(g.pushCode(`${n} = dataView.getUint16(offset);`),s=16):s<=24?(g.pushCode(`${n} = (dataView.getUint16(offset) << 8) | dataView.getUint8(offset + 2);`),s=24):(g.pushCode(`${n} = dataView.getUint32(offset);`),s=32),g.pushCode(`offset += ${s/8};`),s);let o=0;const C=this.endian==="be";let a=0,A=0;g.bitFields.forEach((s,l)=>{let c=s.options.length;if(c>A){if(A){const h=-1>>>32-A;g.pushCode(`${s.varName} = (${n} & 0x${h.toString(16)}) << ${c-A};`),c-=A}o=0,A=a=r(I(l)-A)}const u=C?a-o-c:o,d=-1>>>32-c;g.pushCode(`${s.varName} ${c> ${u} & 0x${d.toString(16)};`),s.options.length===32&&g.pushCode(`${s.varName} >>>= 0`),s.options.assert&&s.generateAssert(g),s.options.formatter&&s.generateFormatter(g,s.varName,s.options.formatter),o+=c,A-=c}),g.bitFields=[]}}generateSeek(g){const i=g.generateOption(this.options.length);g.pushCode(`offset += ${i};`)}generateString(g){const i=g.generateVariable(this.varName),n=g.generateTmpVariable(),I=this.options.encoding,r=I.toLowerCase()==="hex",o='b => b.toString(16).padStart(2, "0")';if(this.options.length&&this.options.zeroTerminated){const C=this.options.length;g.pushCode(`var ${n} = offset;`),g.pushCode(`while(dataView.getUint8(offset++) !== 0 && offset - ${n} < ${C});`);const a=`offset - ${n} < ${C} ? offset - 1 : offset`;g.pushCode(r?`${i} = Array.from(buffer.subarray(${n}, ${a}), ${o}).join('');`:`${i} = new TextDecoder('${I}').decode(buffer.subarray(${n}, ${a}));`)}else if(this.options.length){const C=g.generateOption(this.options.length);g.pushCode(r?`${i} = Array.from(buffer.subarray(offset, offset + ${C}), ${o}).join('');`:`${i} = new TextDecoder('${I}').decode(buffer.subarray(offset, offset + ${C}));`),g.pushCode(`offset += ${C};`)}else this.options.zeroTerminated?(g.pushCode(`var ${n} = offset;`),g.pushCode("while(dataView.getUint8(offset++) !== 0);"),g.pushCode(r?`${i} = Array.from(buffer.subarray(${n}, offset - 1), ${o}).join('');`:`${i} = new TextDecoder('${I}').decode(buffer.subarray(${n}, offset - 1));`)):this.options.greedy&&(g.pushCode(`var ${n} = offset;`),g.pushCode("while(buffer.length > offset++);"),g.pushCode(r?`${i} = Array.from(buffer.subarray(${n}, offset), ${o}).join('');`:`${i} = new TextDecoder('${I}').decode(buffer.subarray(${n}, offset));`));this.options.stripNull&&g.pushCode(`${i} = ${i}.replace(/\\x00+$/g, '')`)}generateBuffer(g){const i=g.generateVariable(this.varName);if(typeof this.options.readUntil=="function"){const n=this.options.readUntil,I=g.generateTmpVariable(),r=g.generateTmpVariable();g.pushCode(`var ${I} = offset;`),g.pushCode(`var ${r} = 0;`),g.pushCode("while (offset < buffer.length) {"),g.pushCode(`${r} = dataView.getUint8(offset);`);const o=g.addImport(n);g.pushCode(`if (${o}.call(${g.generateVariable()}, ${r}, buffer.subarray(offset))) break;`),g.pushCode("offset += 1;"),g.pushCode("}"),g.pushCode(`${i} = buffer.subarray(${I}, offset);`)}else if(this.options.readUntil==="eof")g.pushCode(`${i} = buffer.subarray(offset);`);else{const n=g.generateOption(this.options.length);g.pushCode(`${i} = buffer.subarray(offset, offset + ${n});`),g.pushCode(`offset += ${n};`)}this.options.clone&&g.pushCode(`${i} = buffer.constructor.from(${i});`)}generateArray(g){const i=g.generateOption(this.options.length),n=g.generateOption(this.options.lengthInBytes),I=this.options.type,r=g.generateTmpVariable(),o=g.generateVariable(this.varName),C=g.generateTmpVariable(),a=this.options.key,A=typeof a=="string";if(A?g.pushCode(`${o} = {};`):g.pushCode(`${o} = [];`),typeof this.options.readUntil=="function"?g.pushCode("do {"):this.options.readUntil==="eof"?g.pushCode(`for (var ${r} = 0; offset < buffer.length; ${r}++) {`):n!==void 0?g.pushCode(`for (var ${r} = offset + ${n}; offset < ${r}; ) {`):g.pushCode(`for (var ${r} = ${i}; ${r} > 0; ${r}--) {`),typeof I=="string")if(Os.get(I)){const s=g.generateTmpVariable();if(g.pushCode(`var ${s} = ${Np+I}(offset, {`),g.useContextVariables){const l=g.generateVariable();g.pushCode(`$parent: ${l},`),g.pushCode(`$root: ${l}.$root,`),!this.options.readUntil&&n===void 0&&g.pushCode(`$index: ${i} - ${r},`)}g.pushCode("});"),g.pushCode(`var ${C} = ${s}.result; offset = ${s}.offset;`),I!==this.alias&&g.addReference(I)}else{const s=bY[I],l=yY[I];g.pushCode(`var ${C} = dataView.get${s}(offset, ${l});`),g.pushCode(`offset += ${Js[I]};`)}else if(I instanceof ri){g.pushCode(`var ${C} = {};`);const s=g.generateVariable();g.pushScope(C),g.useContextVariables&&(g.pushCode(`${C}.$parent = ${s};`),g.pushCode(`${C}.$root = ${s}.$root;`),!this.options.readUntil&&n===void 0&&g.pushCode(`${C}.$index = ${i} - ${r};`)),I.generate(g),g.useContextVariables&&(g.pushCode(`delete ${C}.$parent;`),g.pushCode(`delete ${C}.$root;`),g.pushCode(`delete ${C}.$index;`)),g.popScope()}if(A?g.pushCode(`${o}[${C}.${a}] = ${C};`):g.pushCode(`${o}.push(${C});`),g.pushCode("}"),typeof this.options.readUntil=="function"){const s=this.options.readUntil,l=g.addImport(s);g.pushCode(`while (!${l}.call(${g.generateVariable()}, ${C}, buffer.subarray(offset)));`)}}generateChoiceCase(g,i,n){if(typeof n=="string"){const I=g.generateVariable(this.varName);if(Os.has(n)){const r=g.generateTmpVariable();g.pushCode(`var ${r} = ${Np+n}(offset, {`),g.useContextVariables&&(g.pushCode(`$parent: ${I}.$parent,`),g.pushCode(`$root: ${I}.$root,`)),g.pushCode("});"),g.pushCode(`${I} = ${r}.result; offset = ${r}.offset;`),n!==this.alias&&g.addReference(n)}else{const r=bY[n],o=yY[n];g.pushCode(`${I} = dataView.get${r}(offset, ${o});`),g.pushCode(`offset += ${Js[n]}`)}}else n instanceof ri&&(g.pushPath(i),n.generate(g),g.popPath(i))}generateChoice(g){const i=g.generateOption(this.options.tag),n=g.generateVariable(this.varName);if(this.varName&&(g.pushCode(`${n} = {};`),g.useContextVariables)){const I=g.generateVariable();g.pushCode(`${n}.$parent = ${I};`),g.pushCode(`${n}.$root = ${I}.$root;`)}g.pushCode(`switch(${i}) {`);for(const I in this.options.choices){const r=parseInt(I,10),o=this.options.choices[r];g.pushCode(`case ${r}:`),this.generateChoiceCase(g,this.varName,o),g.pushCode("break;")}g.pushCode("default:"),this.options.defaultChoice?this.generateChoiceCase(g,this.varName,this.options.defaultChoice):g.generateError(`"Met undefined tag value " + ${i} + " at choice"`),g.pushCode("}"),this.varName&&g.useContextVariables&&(g.pushCode(`delete ${n}.$parent;`),g.pushCode(`delete ${n}.$root;`))}generateNest(g){const i=g.generateVariable(this.varName);if(this.options.type instanceof ri){if(this.varName&&(g.pushCode(`${i} = {};`),g.useContextVariables)){const n=g.generateVariable();g.pushCode(`${i}.$parent = ${n};`),g.pushCode(`${i}.$root = ${n}.$root;`)}g.pushPath(this.varName),this.options.type.generate(g),g.popPath(this.varName),this.varName&&g.useContextVariables&&g.useContextVariables&&(g.pushCode(`delete ${i}.$parent;`),g.pushCode(`delete ${i}.$root;`))}else if(Os.has(this.options.type)){const n=g.generateTmpVariable();if(g.pushCode(`var ${n} = ${Np+this.options.type}(offset, {`),g.useContextVariables){const I=g.generateVariable();g.pushCode(`$parent: ${I},`),g.pushCode(`$root: ${I}.$root,`)}g.pushCode("});"),g.pushCode(`${i} = ${n}.result; offset = ${n}.offset;`),this.options.type!==this.alias&&g.addReference(this.options.type)}}generateWrapper(g){const i=g.generateVariable(this.varName),n=g.generateTmpVariable();if(typeof this.options.readUntil=="function"){const a=this.options.readUntil,A=g.generateTmpVariable(),s=g.generateTmpVariable();g.pushCode(`var ${A} = offset;`),g.pushCode(`var ${s} = 0;`),g.pushCode("while (offset < buffer.length) {"),g.pushCode(`${s} = dataView.getUint8(offset);`);const l=g.addImport(a);g.pushCode(`if (${l}.call(${g.generateVariable()}, ${s}, buffer.subarray(offset))) break;`),g.pushCode("offset += 1;"),g.pushCode("}"),g.pushCode(`${n} = buffer.subarray(${A}, offset);`)}else if(this.options.readUntil==="eof")g.pushCode(`${n} = buffer.subarray(offset);`);else{const a=g.generateOption(this.options.length);g.pushCode(`${n} = buffer.subarray(offset, offset + ${a});`),g.pushCode(`offset += ${a};`)}this.options.clone&&g.pushCode(`${n} = buffer.constructor.from(${n});`);const I=g.generateTmpVariable(),r=g.generateTmpVariable(),o=g.generateTmpVariable(),C=g.addImport(this.options.wrapper);if(g.pushCode(`${n} = ${C}.call(this, ${n}).subarray(0);`),g.pushCode(`var ${I} = buffer;`),g.pushCode(`var ${r} = offset;`),g.pushCode(`var ${o} = dataView;`),g.pushCode(`buffer = ${n};`),g.pushCode("offset = 0;"),g.pushCode("dataView = new DataView(buffer.buffer, buffer.byteOffset, buffer.length);"),this.options.type instanceof ri)this.varName&&g.pushCode(`${i} = {};`),g.pushPath(this.varName),this.options.type.generate(g),g.popPath(this.varName);else if(Os.has(this.options.type)){const a=g.generateTmpVariable();g.pushCode(`var ${a} = ${Np+this.options.type}(0);`),g.pushCode(`${i} = ${a}.result;`),this.options.type!==this.alias&&g.addReference(this.options.type)}g.pushCode(`buffer = ${I};`),g.pushCode(`dataView = ${o};`),g.pushCode(`offset = ${r};`)}generateFormatter(g,i,n){if(typeof n=="function"){const I=g.addImport(n);g.pushCode(`${i} = ${I}.call(${g.generateVariable()}, ${i});`)}}generatePointer(g){const i=this.options.type,n=g.generateOption(this.options.offset),I=g.generateTmpVariable(),r=g.generateVariable(this.varName);if(g.pushCode(`var ${I} = offset;`),g.pushCode(`offset = ${n};`),this.options.type instanceof ri){if(g.pushCode(`${r} = {};`),g.useContextVariables){const o=g.generateVariable();g.pushCode(`${r}.$parent = ${o};`),g.pushCode(`${r}.$root = ${o}.$root;`)}g.pushPath(this.varName),this.options.type.generate(g),g.popPath(this.varName),g.useContextVariables&&(g.pushCode(`delete ${r}.$parent;`),g.pushCode(`delete ${r}.$root;`))}else if(Os.has(this.options.type)){const o=g.generateTmpVariable();if(g.pushCode(`var ${o} = ${Np+this.options.type}(offset, {`),g.useContextVariables){const C=g.generateVariable();g.pushCode(`$parent: ${C},`),g.pushCode(`$root: ${C}.$root,`)}g.pushCode("});"),g.pushCode(`${r} = ${o}.result; offset = ${o}.offset;`),this.options.type!==this.alias&&g.addReference(this.options.type)}else if(Object.keys(Js).indexOf(this.options.type)>=0){const o=bY[i],C=yY[i];g.pushCode(`${r} = dataView.get${o}(offset, ${C});`),g.pushCode(`offset += ${Js[i]};`)}g.pushCode(`offset = ${I};`)}generateSaveOffset(g){const i=g.generateVariable(this.varName);g.pushCode(`${i} = offset`)}}var V8e={},xle={},ay={},yH={};Object.defineProperty(yH,"__esModule",{value:!0});function Fle(e,g){if(!(e instanceof g))throw new TypeError("Cannot call a class as a function")}function XXe(e,g){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function e2(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function fTg(e,g){if(g&&(typeof g=="object"||typeof g=="function"))return g;if(g!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return e2(e)}function mTg(e){var g=hTg();return function(){var n=Yw(e),I;if(g){var r=Yw(this).constructor;I=Reflect.construct(n,arguments,r)}else I=n.apply(this,arguments);return fTg(this,I)}}function pTg(e,g){for(;!Object.prototype.hasOwnProperty.call(e,g)&&(e=Yw(e),e!==null););return e}function x5(){return typeof Reflect<"u"&&Reflect.get?x5=Reflect.get.bind():x5=function(g,i,n){var I=pTg(g,i);if(I){var r=Object.getOwnPropertyDescriptor(I,i);return r.get?r.get.call(arguments.length<3?g:n):r.value}},x5.apply(this,arguments)}var TXe=function(){function e(){Fle(this,e),Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}return Ele(e,[{key:"addEventListener",value:function(i,n,I){i in this.listeners||(this.listeners[i]=[]),this.listeners[i].push({callback:n,options:I})}},{key:"removeEventListener",value:function(i,n){if(i in this.listeners){for(var I=this.listeners[i],r=0,o=I.length;r"u")I=new Error("This operation was aborted"),I.name="AbortError";else try{I=new DOMException("signal is aborted without reason")}catch{I=new Error("This operation was aborted"),I.name="AbortError"}this.signal.reason=I,this.signal.dispatchEvent(n)}},{key:"toString",value:function(){return"[object AbortController]"}}]),e}();typeof Symbol<"u"&&Symbol.toStringTag&&(W8e.prototype[Symbol.toStringTag]="AbortController",Dle.prototype[Symbol.toStringTag]="AbortSignal");function bTg(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof e.Request=="function"&&!e.Request.prototype.hasOwnProperty("signal")||!e.AbortController}function yTg(e){typeof e=="function"&&(e={fetch:e});var g=e,i=g.fetch,n=g.Request,I=n===void 0?i.Request:n,r=g.AbortController,o=g.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,C=o===void 0?!1:o;if(!bTg({fetch:i,Request:I,AbortController:r,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:C}))return{fetch:i,Request:a};var a=I;(a&&!a.prototype.hasOwnProperty("signal")||C)&&(a=function(c,u){var d;u&&u.signal&&(d=u.signal,delete u.signal);var h=new I(c,u);return d&&Object.defineProperty(h,"signal",{writable:!1,enumerable:!1,configurable:!0,value:d}),h},a.prototype=I.prototype);var A=i,s=function(c,u){var d=a&&a.prototype.isPrototypeOf(c)?c.signal:u?u.signal:void 0;if(d){var h;try{h=new DOMException("Aborted","AbortError")}catch{h=new Error("Aborted"),h.name="AbortError"}if(d.aborted)return Promise.reject(h);var f=new Promise(function(m,b){d.addEventListener("abort",function(){return b(h)},{once:!0})});return u&&u.signal&&delete u.signal,Promise.race([f,A(c,u)])}return A(c,u)};return{fetch:s,Request:a}}yH.AbortController=W8e;yH.AbortSignal=Dle;yH.abortableFetch=yTg;Object.defineProperty(ay,"__esModule",{value:!0});ay.AbortSignal=ay.AbortController=void 0;const X8e=yH;var PD=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof Sb<"u")return Sb;throw new Error("unable to locate global object")};let ZTg=typeof PD().AbortController>"u"?X8e.AbortController:PD().AbortController;ay.AbortController=ZTg;let GTg=typeof PD().AbortController>"u"?X8e.AbortSignal:PD().AbortSignal;ay.AbortSignal=GTg;var Mle={};Object.defineProperty(Mle,"__esModule",{value:!0});const vTg=ay;class BTg{}class wTg{constructor(){this.signals=new Set,this.abortController=new vTg.AbortController}addSignal(g=new BTg){if(this.signal.aborted)throw new Error("cannot add a signal, already aborted!");this.signals.add(g),g.aborted?this.handleAborted(g):typeof g.addEventListener=="function"&&g.addEventListener("abort",()=>{this.handleAborted(g)})}handleAborted(g){this.signals.delete(g),this.signals.size===0&&this.abortController.abort()}get signal(){return this.abortController.signal}abort(){this.abortController.abort()}}Mle.default=wTg;var zle={};Object.defineProperty(zle,"__esModule",{value:!0});class STg{constructor(){this.callbacks=new Set}addCallback(g=()=>{}){this.callbacks.add(g),g(this.currentMessage)}callback(g){this.currentMessage=g,this.callbacks.forEach(i=>{i(g)})}}zle.default=STg;var T8e=Sb&&Sb.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(xle,"__esModule",{value:!0});const RTg=ay,VTg=T8e(Mle),WTg=T8e(zle);class _D{constructor({fill:g,cache:i}){if(typeof g!="function")throw new TypeError("must pass a fill function");if(typeof i!="object")throw new TypeError("must pass a cache object");if(typeof i.get!="function"||typeof i.set!="function"||typeof i.delete!="function")throw new TypeError("cache must implement get(key), set(key, val), and and delete(key)");this.cache=i,this.fillCallback=g}static isAbortException(g){return g.name==="AbortError"||g.code==="ERR_ABORTED"||g.message==="AbortError: aborted"||g.message==="Error: aborted"}evict(g,i){this.cache.get(g)===i&&this.cache.delete(g)}fill(g,i,n,I){const r=new VTg.default,o=new WTg.default;o.addCallback(I);const C={aborter:r,promise:this.fillCallback(i,r.signal,a=>{o.callback(a)}),settled:!1,statusReporter:o,get aborted(){return this.aborter.signal.aborted}};C.aborter.addSignal(n),C.aborter.signal.addEventListener("abort",()=>{C.settled||this.evict(g,C)}),C.promise.then(()=>{C.settled=!0},()=>{C.settled=!0,this.evict(g,C)}).catch(a=>{throw console.error(a),a}),this.cache.set(g,C)}static checkSinglePromise(g,i){function n(){if(i&&i.aborted)throw Object.assign(new Error("aborted"),{code:"ERR_ABORTED"})}return g.then(I=>(n(),I),I=>{throw n(),I})}has(g){return this.cache.has(g)}get(g,i,n,I){if(!n&&i instanceof RTg.AbortSignal)throw new TypeError("second get argument appears to be an AbortSignal, perhaps you meant to pass `null` for the fill data?");const r=this.cache.get(g);return r?r.aborted&&!r.settled?(this.evict(g,r),this.get(g,i,n,I)):r.settled?r.promise:(r.aborter.addSignal(n),r.statusReporter.addCallback(I),_D.checkSinglePromise(r.promise,n)):(this.fill(g,i,n,I),_D.checkSinglePromise(this.cache.get(g).promise,n))}delete(g){const i=this.cache.get(g);i&&(i.settled||i.aborter.abort(),this.cache.delete(g))}clear(){const g=this.cache.keys();let i=0;for(let n=g.next();!n.done;n=g.next())this.delete(n.value),i+=1;return i}}xle.default=_D;var XTg=Sb&&Sb.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(V8e,"__esModule",{value:!0});const TTg=XTg(xle);var HTg=V8e.default=TTg.default;let HXe=class LG{constructor(g,i){this.ranges=arguments.length===2?[{min:g,max:i}]:0 in g?Object.assign({},g):[g]}min(){return this.ranges[0].min}max(){return this.ranges[this.ranges.length-1].max}contains(g){for(let i=0;i=g)return!0}return!1}isContiguous(){return this.ranges.length>1}getRanges(){return this.ranges.map(g=>new LG(g.min,g.max))}toString(){return this.ranges.map(g=>`[${g.min}-${g.max}]`).join(",")}union(g){const i=this.getRanges().concat(g.getRanges()).sort(this.rangeOrder),n=[];let I=i[0];for(let r=1;rI.max()+1?(n.push(I),I=o):o.max()>I.max()&&(I=new LG(I.min(),o.max()))}return n.push(I),n.length===1?n[0]:new LG(n)}intersection(g){let i=this,n=g;const I=this.ranges(),r=n.ranges(),o=I.length,C=r.length;let a=0,A=0;const s=[];for(;a=l&&s.push(new LG(l,c)),i.max()>n.max()?A+=1:a+=1}if(s.length===0)throw new Error("found range of length 0");return s.length===1?s[0]:new LG(s)}coverage(){let g=0;const i=this.ranges();for(let n=0;nI.min()?1:n.max()n.max()?1:0}};function aS(e){let g=e.length;for(;--g>=0;)e[g]=0}const NTg=3,kTg=258,H8e=29,YTg=256,KTg=YTg+1+H8e,N8e=30,xTg=512,FTg=new Array((KTg+2)*2);aS(FTg);const ETg=new Array(N8e*2);aS(ETg);const DTg=new Array(xTg);aS(DTg);const MTg=new Array(kTg-NTg+1);aS(MTg);const zTg=new Array(H8e);aS(zTg);const PTg=new Array(N8e);aS(PTg);const _Tg=(e,g,i,n)=>{let I=e&65535|0,r=e>>>16&65535|0,o=0;for(;i!==0;){o=i>2e3?2e3:i,i-=o;do I=I+g[n++]|0,r=r+I|0;while(--o);I%=65521,r%=65521}return I|r<<16|0};var die=_Tg;const OTg=()=>{let e,g=[];for(var i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;g[i]=e}return g},JTg=new Uint32Array(OTg()),LTg=(e,g,i,n)=>{const I=JTg,r=n+i;e^=-1;for(let o=n;o>>8^I[(e^g[o])&255];return e^-1};var Gl=LTg,hie={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Ple={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const UTg=(e,g)=>Object.prototype.hasOwnProperty.call(e,g);var QTg=function(e){const g=Array.prototype.slice.call(arguments,1);for(;g.length;){const i=g.shift();if(i){if(typeof i!="object")throw new TypeError(i+"must be non-object");for(const n in i)UTg(i,n)&&(e[n]=i[n])}}return e},jTg=e=>{let g=0;for(let n=0,I=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;b9[254]=b9[254]=1;var $Tg=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let g,i,n,I,r,o=e.length,C=0;for(I=0;I>>6,g[r++]=128|i&63):i<65536?(g[r++]=224|i>>>12,g[r++]=128|i>>>6&63,g[r++]=128|i&63):(g[r++]=240|i>>>18,g[r++]=128|i>>>12&63,g[r++]=128|i>>>6&63,g[r++]=128|i&63);return g};const qTg=(e,g)=>{if(g<65534&&e.subarray&&Y8e)return String.fromCharCode.apply(null,e.length===g?e:e.subarray(0,g));let i="";for(let n=0;n{const i=g||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,g));let n,I;const r=new Array(i*2);for(I=0,n=0;n4){r[I++]=65533,n+=C-1;continue}for(o&=C===2?31:C===3?15:7;C>1&&n1){r[I++]=65533;continue}o<65536?r[I++]=o:(o-=65536,r[I++]=55296|o>>10&1023,r[I++]=56320|o&1023)}return qTg(r,I)},tHg=(e,g)=>{g=g||e.length,g>e.length&&(g=e.length);let i=g-1;for(;i>=0&&(e[i]&192)===128;)i--;return i<0||i===0?g:i+b9[e[i]]>g?i:g},fie={string2buf:$Tg,buf2string:eHg,utf8border:tHg};function gHg(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var iHg=gHg;const ZY=16209,nHg=16191;var IHg=function(g,i){let n,I,r,o,C,a,A,s,l,c,u,d,h,f,m,b,p,y,Z,v,G,B,S,R;const w=g.state;n=g.next_in,S=g.input,I=n+(g.avail_in-5),r=g.next_out,R=g.output,o=r-(i-g.avail_out),C=r+(g.avail_out-257),a=w.dmax,A=w.wsize,s=w.whave,l=w.wnext,c=w.window,u=w.hold,d=w.bits,h=w.lencode,f=w.distcode,m=(1<>>24,u>>>=y,d-=y,y=p>>>16&255,y===0)R[r++]=p&65535;else if(y&16){Z=p&65535,y&=15,y&&(d>>=y,d-=y),d<15&&(u+=S[n++]<>>24,u>>>=y,d-=y,y=p>>>16&255,y&16){if(v=p&65535,y&=15,da){g.msg="invalid distance too far back",w.mode=ZY;break e}if(u>>>=y,d-=y,y=r-o,v>y){if(y=v-y,y>s&&w.sane){g.msg="invalid distance too far back",w.mode=ZY;break e}if(G=0,B=c,l===0){if(G+=A-y,y2;)R[r++]=B[G++],R[r++]=B[G++],R[r++]=B[G++],Z-=3;Z&&(R[r++]=B[G++],Z>1&&(R[r++]=B[G++]))}else{G=r-v;do R[r++]=R[G++],R[r++]=R[G++],R[r++]=R[G++],Z-=3;while(Z>2);Z&&(R[r++]=R[G++],Z>1&&(R[r++]=R[G++]))}}else if(y&64){g.msg="invalid distance code",w.mode=ZY;break e}else{p=f[(p&65535)+(u&(1<>3,n-=Z,d-=Z<<3,u&=(1<{const a=C.bits;let A=0,s=0,l=0,c=0,u=0,d=0,h=0,f=0,m=0,b=0,p,y,Z,v,G,B=null,S;const R=new Uint16Array(AG+1),w=new Uint16Array(AG+1);let T=null,W,V,X;for(A=0;A<=AG;A++)R[A]=0;for(s=0;s=1&&R[c]===0;c--);if(u>c&&(u=c),c===0)return I[r++]=1<<24|64<<16|0,I[r++]=1<<24|64<<16|0,C.bits=1,0;for(l=1;l0&&(e===YXe||c!==1))return-1;for(w[1]=0,A=1;ANXe||e===KXe&&m>kXe)return 1;for(;;){W=A-h,o[s]+1=S?(V=T[o[s]-S],X=B[o[s]-S]):(V=32+64,X=0),p=1<>h)+y]=W<<24|V<<16|X|0;while(y!==0);for(p=1<>=1;if(p!==0?(b&=p-1,b+=p):b=0,s++,--R[A]===0){if(A===c)break;A=g[i+o[s]]}if(A>u&&(b&v)!==Z){for(h===0&&(h=u),G+=l,d=A-h,f=1<NXe||e===KXe&&m>kXe)return 1;Z=b&v,I[Z]=u<<24|d<<16|G-r|0}}return b!==0&&(I[G+b]=A-h<<24|64<<16|0),C.bits=u,0};var TW=sHg;const AHg=0,K8e=1,x8e=2,{Z_FINISH:xXe,Z_BLOCK:lHg,Z_TREES:GY,Z_OK:sy,Z_STREAM_END:cHg,Z_NEED_DICT:uHg,Z_STREAM_ERROR:hs,Z_DATA_ERROR:F8e,Z_MEM_ERROR:E8e,Z_BUF_ERROR:dHg,Z_DEFLATED:FXe}=Ple,K_=16180,EXe=16181,DXe=16182,MXe=16183,zXe=16184,PXe=16185,_Xe=16186,OXe=16187,JXe=16188,LXe=16189,OD=16190,Zu=16191,dj=16192,UXe=16193,hj=16194,QXe=16195,jXe=16196,$Xe=16197,qXe=16198,vY=16199,BY=16200,e9e=16201,t9e=16202,g9e=16203,i9e=16204,n9e=16205,fj=16206,I9e=16207,r9e=16208,Cn=16209,D8e=16210,M8e=16211,hHg=852,fHg=592,mHg=15,pHg=mHg,o9e=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function bHg(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const lZ=e=>{if(!e)return 1;const g=e.state;return!g||g.strm!==e||g.modeM8e?1:0},z8e=e=>{if(lZ(e))return hs;const g=e.state;return e.total_in=e.total_out=g.total=0,e.msg="",g.wrap&&(e.adler=g.wrap&1),g.mode=K_,g.last=0,g.havedict=0,g.flags=-1,g.dmax=32768,g.head=null,g.hold=0,g.bits=0,g.lencode=g.lendyn=new Int32Array(hHg),g.distcode=g.distdyn=new Int32Array(fHg),g.sane=1,g.back=-1,sy},P8e=e=>{if(lZ(e))return hs;const g=e.state;return g.wsize=0,g.whave=0,g.wnext=0,z8e(e)},_8e=(e,g)=>{let i;if(lZ(e))return hs;const n=e.state;return g<0?(i=0,g=-g):(i=(g>>4)+5,g<48&&(g&=15)),g&&(g<8||g>15)?hs:(n.window!==null&&n.wbits!==g&&(n.window=null),n.wrap=i,n.wbits=g,P8e(e))},O8e=(e,g)=>{if(!e)return hs;const i=new bHg;e.state=i,i.strm=e,i.window=null,i.mode=K_;const n=_8e(e,g);return n!==sy&&(e.state=null),n},yHg=e=>O8e(e,pHg);let C9e=!0,mj,pj;const ZHg=e=>{if(C9e){mj=new Int32Array(512),pj=new Int32Array(32);let g=0;for(;g<144;)e.lens[g++]=8;for(;g<256;)e.lens[g++]=9;for(;g<280;)e.lens[g++]=7;for(;g<288;)e.lens[g++]=8;for(TW(K8e,e.lens,0,288,mj,0,e.work,{bits:9}),g=0;g<32;)e.lens[g++]=5;TW(x8e,e.lens,0,32,pj,0,e.work,{bits:5}),C9e=!1}e.lencode=mj,e.lenbits=9,e.distcode=pj,e.distbits=5},J8e=(e,g,i,n)=>{let I;const r=e.state;return r.window===null&&(r.wsize=1<=r.wsize?(r.window.set(g.subarray(i-r.wsize,i),0),r.wnext=0,r.whave=r.wsize):(I=r.wsize-r.wnext,I>n&&(I=n),r.window.set(g.subarray(i-n,i-n+I),r.wnext),n-=I,n?(r.window.set(g.subarray(i-n,i),0),r.wnext=n,r.whave=r.wsize):(r.wnext+=I,r.wnext===r.wsize&&(r.wnext=0),r.whave{let i,n,I,r,o,C,a,A,s,l,c,u,d,h,f=0,m,b,p,y,Z,v,G,B;const S=new Uint8Array(4);let R,w;const T=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(lZ(e)||!e.output||!e.input&&e.avail_in!==0)return hs;i=e.state,i.mode===Zu&&(i.mode=dj),o=e.next_out,I=e.output,a=e.avail_out,r=e.next_in,n=e.input,C=e.avail_in,A=i.hold,s=i.bits,l=C,c=a,B=sy;e:for(;;)switch(i.mode){case K_:if(i.wrap===0){i.mode=dj;break}for(;s<16;){if(C===0)break e;C--,A+=n[r++]<>>8&255,i.check=Gl(i.check,S,2,0),A=0,s=0,i.mode=EXe;break}if(i.head&&(i.head.done=!1),!(i.wrap&1)||(((A&255)<<8)+(A>>8))%31){e.msg="incorrect header check",i.mode=Cn;break}if((A&15)!==FXe){e.msg="unknown compression method",i.mode=Cn;break}if(A>>>=4,s-=4,G=(A&15)+8,i.wbits===0&&(i.wbits=G),G>15||G>i.wbits){e.msg="invalid window size",i.mode=Cn;break}i.dmax=1<>8&1),i.flags&512&&i.wrap&4&&(S[0]=A&255,S[1]=A>>>8&255,i.check=Gl(i.check,S,2,0)),A=0,s=0,i.mode=DXe;case DXe:for(;s<32;){if(C===0)break e;C--,A+=n[r++]<>>8&255,S[2]=A>>>16&255,S[3]=A>>>24&255,i.check=Gl(i.check,S,4,0)),A=0,s=0,i.mode=MXe;case MXe:for(;s<16;){if(C===0)break e;C--,A+=n[r++]<>8),i.flags&512&&i.wrap&4&&(S[0]=A&255,S[1]=A>>>8&255,i.check=Gl(i.check,S,2,0)),A=0,s=0,i.mode=zXe;case zXe:if(i.flags&1024){for(;s<16;){if(C===0)break e;C--,A+=n[r++]<>>8&255,i.check=Gl(i.check,S,2,0)),A=0,s=0}else i.head&&(i.head.extra=null);i.mode=PXe;case PXe:if(i.flags&1024&&(u=i.length,u>C&&(u=C),u&&(i.head&&(G=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(r,r+u),G)),i.flags&512&&i.wrap&4&&(i.check=Gl(i.check,n,u,r)),C-=u,r+=u,i.length-=u),i.length))break e;i.length=0,i.mode=_Xe;case _Xe:if(i.flags&2048){if(C===0)break e;u=0;do G=n[r+u++],i.head&&G&&i.length<65536&&(i.head.name+=String.fromCharCode(G));while(G&&u>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Zu;break;case LXe:for(;s<32;){if(C===0)break e;C--,A+=n[r++]<>>=s&7,s-=s&7,i.mode=fj;break}for(;s<3;){if(C===0)break e;C--,A+=n[r++]<>>=1,s-=1,A&3){case 0:i.mode=UXe;break;case 1:if(ZHg(i),i.mode=vY,g===GY){A>>>=2,s-=2;break e}break;case 2:i.mode=jXe;break;case 3:e.msg="invalid block type",i.mode=Cn}A>>>=2,s-=2;break;case UXe:for(A>>>=s&7,s-=s&7;s<32;){if(C===0)break e;C--,A+=n[r++]<>>16^65535)){e.msg="invalid stored block lengths",i.mode=Cn;break}if(i.length=A&65535,A=0,s=0,i.mode=hj,g===GY)break e;case hj:i.mode=QXe;case QXe:if(u=i.length,u){if(u>C&&(u=C),u>a&&(u=a),u===0)break e;I.set(n.subarray(r,r+u),o),C-=u,r+=u,a-=u,o+=u,i.length-=u;break}i.mode=Zu;break;case jXe:for(;s<14;){if(C===0)break e;C--,A+=n[r++]<>>=5,s-=5,i.ndist=(A&31)+1,A>>>=5,s-=5,i.ncode=(A&15)+4,A>>>=4,s-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=Cn;break}i.have=0,i.mode=$Xe;case $Xe:for(;i.have>>=3,s-=3}for(;i.have<19;)i.lens[T[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,R={bits:i.lenbits},B=TW(AHg,i.lens,0,19,i.lencode,0,i.work,R),i.lenbits=R.bits,B){e.msg="invalid code lengths set",i.mode=Cn;break}i.have=0,i.mode=qXe;case qXe:for(;i.have>>24,b=f>>>16&255,p=f&65535,!(m<=s);){if(C===0)break e;C--,A+=n[r++]<>>=m,s-=m,i.lens[i.have++]=p;else{if(p===16){for(w=m+2;s>>=m,s-=m,i.have===0){e.msg="invalid bit length repeat",i.mode=Cn;break}G=i.lens[i.have-1],u=3+(A&3),A>>>=2,s-=2}else if(p===17){for(w=m+3;s>>=m,s-=m,G=0,u=3+(A&7),A>>>=3,s-=3}else{for(w=m+7;s>>=m,s-=m,G=0,u=11+(A&127),A>>>=7,s-=7}if(i.have+u>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=Cn;break}for(;u--;)i.lens[i.have++]=G}}if(i.mode===Cn)break;if(i.lens[256]===0){e.msg="invalid code -- missing end-of-block",i.mode=Cn;break}if(i.lenbits=9,R={bits:i.lenbits},B=TW(K8e,i.lens,0,i.nlen,i.lencode,0,i.work,R),i.lenbits=R.bits,B){e.msg="invalid literal/lengths set",i.mode=Cn;break}if(i.distbits=6,i.distcode=i.distdyn,R={bits:i.distbits},B=TW(x8e,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,R),i.distbits=R.bits,B){e.msg="invalid distances set",i.mode=Cn;break}if(i.mode=vY,g===GY)break e;case vY:i.mode=BY;case BY:if(C>=6&&a>=258){e.next_out=o,e.avail_out=a,e.next_in=r,e.avail_in=C,i.hold=A,i.bits=s,IHg(e,c),o=e.next_out,I=e.output,a=e.avail_out,r=e.next_in,n=e.input,C=e.avail_in,A=i.hold,s=i.bits,i.mode===Zu&&(i.back=-1);break}for(i.back=0;f=i.lencode[A&(1<>>24,b=f>>>16&255,p=f&65535,!(m<=s);){if(C===0)break e;C--,A+=n[r++]<>y)],m=f>>>24,b=f>>>16&255,p=f&65535,!(y+m<=s);){if(C===0)break e;C--,A+=n[r++]<>>=y,s-=y,i.back+=y}if(A>>>=m,s-=m,i.back+=m,i.length=p,b===0){i.mode=n9e;break}if(b&32){i.back=-1,i.mode=Zu;break}if(b&64){e.msg="invalid literal/length code",i.mode=Cn;break}i.extra=b&15,i.mode=e9e;case e9e:if(i.extra){for(w=i.extra;s>>=i.extra,s-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=t9e;case t9e:for(;f=i.distcode[A&(1<>>24,b=f>>>16&255,p=f&65535,!(m<=s);){if(C===0)break e;C--,A+=n[r++]<>y)],m=f>>>24,b=f>>>16&255,p=f&65535,!(y+m<=s);){if(C===0)break e;C--,A+=n[r++]<>>=y,s-=y,i.back+=y}if(A>>>=m,s-=m,i.back+=m,b&64){e.msg="invalid distance code",i.mode=Cn;break}i.offset=p,i.extra=b&15,i.mode=g9e;case g9e:if(i.extra){for(w=i.extra;s>>=i.extra,s-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=Cn;break}i.mode=i9e;case i9e:if(a===0)break e;if(u=c-a,i.offset>u){if(u=i.offset-u,u>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=Cn;break}u>i.wnext?(u-=i.wnext,d=i.wsize-u):d=i.wnext-u,u>i.length&&(u=i.length),h=i.window}else h=I,d=o-i.offset,u=i.length;u>a&&(u=a),a-=u,i.length-=u;do I[o++]=h[d++];while(--u);i.length===0&&(i.mode=BY);break;case n9e:if(a===0)break e;I[o++]=i.length,a--,i.mode=BY;break;case fj:if(i.wrap){for(;s<32;){if(C===0)break e;C--,A|=n[r++]<{if(lZ(e))return hs;let g=e.state;return g.window&&(g.window=null),e.state=null,sy},BHg=(e,g)=>{if(lZ(e))return hs;const i=e.state;return i.wrap&2?(i.head=g,g.done=!1,sy):hs},wHg=(e,g)=>{const i=g.length;let n,I,r;return lZ(e)||(n=e.state,n.wrap!==0&&n.mode!==OD)?hs:n.mode===OD&&(I=1,I=die(I,g,i,0),I!==n.check)?F8e:(r=J8e(e,g,i,i),r?(n.mode=D8e,E8e):(n.havedict=1,sy))};var SHg=P8e,RHg=_8e,VHg=z8e,WHg=yHg,XHg=O8e,THg=GHg,HHg=vHg,NHg=BHg,kHg=wHg,YHg="pako inflate (from Nodeca project)",Eu={inflateReset:SHg,inflateReset2:RHg,inflateResetKeep:VHg,inflateInit:WHg,inflateInit2:XHg,inflate:THg,inflateEnd:HHg,inflateGetHeader:NHg,inflateSetDictionary:kHg,inflateInfo:YHg};function KHg(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var xHg=KHg;const L8e=Object.prototype.toString,{Z_NO_FLUSH:FHg,Z_FINISH:EHg,Z_OK:y9,Z_STREAM_END:bj,Z_NEED_DICT:yj,Z_STREAM_ERROR:DHg,Z_DATA_ERROR:a9e,Z_MEM_ERROR:MHg}=Ple;function ZH(e){this.options=k8e.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});const g=this.options;g.raw&&g.windowBits>=0&&g.windowBits<16&&(g.windowBits=-g.windowBits,g.windowBits===0&&(g.windowBits=-15)),g.windowBits>=0&&g.windowBits<16&&!(e&&e.windowBits)&&(g.windowBits+=32),g.windowBits>15&&g.windowBits<48&&(g.windowBits&15||(g.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new iHg,this.strm.avail_out=0;let i=Eu.inflateInit2(this.strm,g.windowBits);if(i!==y9)throw new Error(hie[i]);if(this.header=new xHg,Eu.inflateGetHeader(this.strm,this.header),g.dictionary&&(typeof g.dictionary=="string"?g.dictionary=fie.string2buf(g.dictionary):L8e.call(g.dictionary)==="[object ArrayBuffer]"&&(g.dictionary=new Uint8Array(g.dictionary)),g.raw&&(i=Eu.inflateSetDictionary(this.strm,g.dictionary),i!==y9)))throw new Error(hie[i])}ZH.prototype.push=function(e,g){const i=this.strm,n=this.options.chunkSize,I=this.options.dictionary;let r,o,C;if(this.ended)return!1;for(g===~~g?o=g:o=g===!0?EHg:FHg,L8e.call(e)==="[object ArrayBuffer]"?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(i.avail_out===0&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),r=Eu.inflate(i,o),r===yj&&I&&(r=Eu.inflateSetDictionary(i,I),r===y9?r=Eu.inflate(i,o):r===a9e&&(r=yj));i.avail_in>0&&r===bj&&i.state.wrap>0&&e[i.next_in]!==0;)Eu.inflateReset(i),r=Eu.inflate(i,o);switch(r){case DHg:case a9e:case yj:case MHg:return this.onEnd(r),this.ended=!0,!1}if(C=i.avail_out,i.next_out&&(i.avail_out===0||r===bj))if(this.options.to==="string"){let a=fie.utf8border(i.output,i.next_out),A=i.next_out-a,s=fie.buf2string(i.output,a);i.next_out=A,i.avail_out=n-A,A&&i.output.set(i.output.subarray(a,a+A),0),this.onData(s)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(!(r===y9&&C===0)){if(r===bj)return r=Eu.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(i.avail_in===0)break}}return!0};ZH.prototype.onData=function(e){this.chunks.push(e)};ZH.prototype.onEnd=function(e){e===y9&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=k8e.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function _le(e,g){const i=new ZH(g);if(i.push(e),i.err)throw i.msg||hie[i.err];return i.result}function zHg(e,g){return g=g||{},g.raw=!0,_le(e,g)}var PHg=ZH,_Hg=_le,OHg=zHg,JHg=_le,LHg=Ple,UHg={Inflate:PHg,inflate:_Hg,inflateRaw:OHg,ungzip:JHg,constants:LHg};const{Inflate:Fsi,inflate:Esi,inflateRaw:QHg,ungzip:Dsi}=UHg;var jHg=QHg;function $Hg(e){return jHg(e.subarray(2))}class qHg extends Error{constructor(g){super(g),this.code="ERR_ABORTED"}}function eNg(e){e.sort((I,r)=>Number(I.offset)-Number(r.offset));const g=[];let i,n;for(let I=0;I=i}function nNg(e){const g=e?"big":"little",i=new ri().endianess(g).uint32("chromId").uint32("start").uint32("end").uint32("validCnt").floatle("minScore").floatle("maxScore").floatle("sumData").floatle("sumSqData").saveOffset("offset"),n=new ri().endianess(g).uint8("isLeaf").skip(1).uint16("cnt").choice({tag:"isLeaf",choices:{1:new ri().endianess(g).array("blocksToFetch",{length:"cnt",type:new ri().endianess(g).uint32("startChrom").uint32("startBase").uint32("endChrom").uint32("endBase").uint64("blockOffset").uint64("blockSize").saveOffset("offset")}),0:new ri().array("recurOffsets",{length:"cnt",type:new ri().endianess(g).uint32("startChrom").uint32("startBase").uint32("endChrom").uint32("endBase").uint64("blockOffset").saveOffset("offset")})}}),I=new ri().endianess(g).uint32("chromId").int32("start").int32("end").string("rest",{zeroTerminated:!0}).saveOffset("offset");return{bigWigParser:new ri().endianess(g).skip(4).int32("blockStart").skip(4).uint32("itemStep").uint32("itemSpan").uint8("blockType").skip(1).uint16("itemCount").choice({tag:"blockType",choices:{[iNg]:new ri().array("items",{length:"itemCount",type:new ri().floatle("score")}),[gNg]:new ri().array("items",{length:"itemCount",type:new ri().endianess(g).int32("start").floatle("score")}),[tNg]:new ri().array("items",{length:"itemCount",type:new ri().endianess(g).int32("start").int32("end").floatle("score")})}}),bigBedParser:I,summaryParser:i,leafParser:n}}class U8e{constructor(g,i,n,I,r,o){if(this.bbi=g,this.refsByName=i,this.cirTreeOffset=n,this.isBigEndian=I,this.isCompressed=r,this.blockType=o,this.featureCache=new HTg({cache:new mXt({maxSize:1e3}),fill:async(a,A)=>{const s=Number(a.length),l=Number(a.offset),{buffer:c}=await this.bbi.read(wb.Buffer.alloc(s),0,s,l,{signal:A});return c}}),!(n>=0))throw new Error("invalid cirTreeOffset!");const C=nNg(I);this.leafParser=C.leafParser,this.bigBedParser=C.bigBedParser}async readWigData(g,i,n,I,r){try{const{refsByName:o,bbi:C,cirTreeOffset:a,isBigEndian:A}=this,s=o[g];s===void 0&&I.complete();const l={chrId:s,start:i,end:n};this.cirTreePromise||(this.cirTreePromise=C.read(wb.Buffer.alloc(48),0,48,Number(a),r));const{buffer:c}=await this.cirTreePromise,u=A?c.readUInt32BE(4):c.readUInt32LE(4);let d=[],h=0;const f=(y,Z,v)=>{try{const G=y.subarray(Z),B=this.leafParser.parse(G);if(B.blocksToFetch&&(d=d.concat(B.blocksToFetch.filter(m).map(S=>({offset:S.blockOffset,length:S.blockSize})))),B.recurOffsets){const S=B.recurOffsets.filter(m).map(R=>Number(R.blockOffset));S.length>0&&p(S,v+1)}}catch(G){I.error(G)}},m=y=>{const{startChrom:Z,startBase:v,endChrom:G,endBase:B}=y;return(Zs||G===s&&B>=i)},b=async(y,Z,v)=>{try{const G=Z.max()-Z.min(),B=Z.min(),S=await this.featureCache.get(`${G}_${B}`,{length:G,offset:B},r.signal);for(let R=0;R{try{h+=y.length;const v=4+Number(u)*32;let G=new HXe(y[0],y[0]+v);for(let B=1;Bb(y,B,Z))}catch(v){I.error(v)}};return p([Number(a)+48],1)}catch(o){I.error(o)}}parseSummaryBlock(g,i,n){const I=[];let r=i;const o=new DataView(g.buffer,g.byteOffset,g.length);for(;rZj(C.start,C.end,I.start,I.end)):r}parseBigWigBlock(g,i,n){const I=g.subarray(i),r=new DataView(I.buffer,I.byteOffset,I.length);let o=0;o+=4;const C=r.getInt32(o,!0);o+=8;const a=r.getUint32(o,!0);o+=4;const A=r.getUint32(o,!0);o+=4;const s=r.getUint8(o);o+=2;const l=r.getUint16(o,!0);o+=2;const c=new Array(l);switch(s){case 1:for(let u=0;uZj(u.start,u.end,n.start,n.end)):c}async readFeatures(g,i,n={}){try{const{blockType:I,isCompressed:r}=this,{signal:o,request:C}=n,a=eNg(i);wY(o),await Promise.all(a.map(async A=>{wY(o);const{length:s,offset:l}=A,c=await this.featureCache.get(`${s}_${l}`,A,o);A.blocks.forEach(u=>{wY(o);let d=Number(u.offset)-Number(A.offset),h=c;switch(r&&(h=$Hg(c.subarray(d)),d=0),wY(o),I){case"summary":g.next(this.parseSummaryBlock(h,d,C));break;case"bigwig":g.next(this.parseBigWigBlock(h,d,C));break;case"bigbed":g.next(this.parseBigBedBlock(h,d,Number(u.offset)*(1<<8),C));break;default:console.warn(`Don't know what to do with ${I}`)}})})),g.complete()}catch(I){g.error(I)}}}var mie=function(e,g){return mie=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var I in n)Object.prototype.hasOwnProperty.call(n,I)&&(i[I]=n[I])},mie(e,g)};function Ole(e,g){if(typeof g!="function"&&g!==null)throw new TypeError("Class extends value "+String(g)+" is not a constructor or null");mie(e,g);function i(){this.constructor=e}e.prototype=g===null?Object.create(g):(i.prototype=g.prototype,new i)}function s9e(e){var g=typeof Symbol=="function"&&Symbol.iterator,i=g&&e[g],n=0;if(i)return i.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(g?"Object is not iterable.":"Symbol.iterator is not defined.")}function pie(e,g){var i=typeof Symbol=="function"&&e[Symbol.iterator];if(!i)return e;var n=i.call(e),I,r=[],o;try{for(;(g===void 0||g-- >0)&&!(I=n.next()).done;)r.push(I.value)}catch(C){o={error:C}}finally{try{I&&!I.done&&(i=n.return)&&i.call(n)}finally{if(o)throw o.error}}return r}function bie(e,g,i){if(i||arguments.length===2)for(var n=0,I=g.length,r;n=2,!1,!0))}var BNg=function(e,g){return e.push(g),e};function wNg(){return q8e(function(e,g){vNg(BNg,[])(e).subscribe(g)})}const d9e=-2003829722,Bj=-2021002517;function SNg(e){return new TextDecoder().decode(e)}function h9e(e){const g=e?"big":"little",i=new ri().endianess(g).int32("magic").uint16("version").uint16("numZoomLevels").uint64("chromTreeOffset").uint64("unzoomedDataOffset").uint64("unzoomedIndexOffset").uint16("fieldCount").uint16("definedFieldCount").uint64("asOffset").uint64("totalSummaryOffset").uint32("uncompressBufSize").uint64("extHeaderOffset").array("zoomLevels",{length:"numZoomLevels",type:new ri().endianess(g).uint32("reductionLevel").uint32("reserved").uint64("dataOffset").uint64("indexOffset")}),n=new ri().endianess(g).uint64("basesCovered").doublele("scoreMin").doublele("scoreMax").doublele("scoreSum").doublele("scoreSumSquares"),I=new ri().endianess(g).uint32("magic").uint32("blockSize").uint32("keySize").uint32("valSize").uint64("itemCount"),r=new ri().endianess(g).uint8("isLeafNode").skip(1).uint16("cnt").saveOffset("offset");return{chromTreeParser:I,totalSummaryParser:n,headerParser:i,isLeafNode:r}}class RNg{getHeader(g={}){const i="aborted"in g?{signal:g}:g;return this.headerP||(this.headerP=this._getHeader(i).catch(n=>{throw this.headerP=void 0,n})),this.headerP}constructor(g={}){const{filehandle:i,renameRefSeqs:n=o=>o,path:I,url:r}=g;if(this.renameRefSeqs=n,i)this.bbi=i;else if(r)this.bbi=new XDe(r);else if(I)this.bbi=new s1t(I);else throw new Error("no file given")}async _getHeader(g){const i=await this._getMainHeader(g),n=await this._readChromTree(i,g);return{...i,...n}}async _getMainHeader(g,i=2e3){const{buffer:n}=await this.bbi.read(wb.Buffer.alloc(i),0,i,0,g),I=this._isBigEndian(n),r=h9e(I),o=r.headerParser.parse(n),{magic:C,asOffset:a,totalSummaryOffset:A}=o;if(o.fileType=C===Bj?"bigbed":"bigwig",a>i||A>i)return this._getMainHeader(g,i*2);if(a){const s=Number(o.asOffset);o.autoSql=SNg(n.subarray(s,n.indexOf(0,s)))}if(o.totalSummaryOffset>i)return this._getMainHeader(g,i*2);if(o.totalSummaryOffset){const s=n.subarray(Number(o.totalSummaryOffset)),l=r.totalSummaryParser.parse(s);o.totalSummary={...l,basesCovered:Number(l.basesCovered)}}return{...o,isBigEndian:I}}_isBigEndian(g){let i=g.readInt32LE(0);if(i===d9e||i===Bj)return!1;if(i=g.readInt32BE(0),i===d9e||i===Bj)return!0;throw new Error("not a BigWig/BigBed file")}async _readChromTree(g,i){const n=g.isBigEndian,I=n?"big":"little",r=[],o={};let C=Number(g.unzoomedDataOffset);const a=Number(g.chromTreeOffset);for(;C%4!==0;)C+=1;const A=C-a,{buffer:s}=await this.bbi.read(wb.Buffer.alloc(A),0,A,Number(a),i),l=h9e(n),{keySize:c}=l.chromTreeParser.parse(s),u=new ri().endianess(I).string("key",{stripNull:!0,length:c}).uint32("refId").uint32("refSize").saveOffset("offset"),d=new ri().endianess(I).skip(c).uint64("childOffset").saveOffset("offset"),h=32,f=async m=>{let b=m;if(b>=s.length)throw new Error("reading beyond end of buffer");const p=l.isLeafNode.parse(s.subarray(b)),{isLeafNode:y,cnt:Z}=p;if(b+=p.offset,y)for(let v=0;v0,o)}async getFeatureStream(g,i,n,I={scale:1}){await this.getHeader(I);const r=this.renameRefSeqs(g);let o;if(I.basesPerSpan?o=await this.getView(1/I.basesPerSpan,I):I.scale?o=await this.getView(I.scale,I):o=await this.getView(1,I),!o)throw new Error("unable to get block view for data");return new dNg(C=>{o.readWigData(r,i,n,C,I)})}async getFeatures(g,i,n,I={scale:1}){const r=await this.getFeatureStream(g,i,n,I);return(await ZNg(r.pipe(wNg()))).flat()}}class VNg extends RNg{async getView(g,i){const{zoomLevels:n,refsByName:I,fileSize:r,isBigEndian:o,uncompressBufSize:C}=await this.getHeader(i),a=1/g;let A=n.length;r||(A-=1);for(let s=A;s>=0;s-=1){const l=n[s];if(l&&l.reductionLevel<=2*a){const c=Number(l.indexOffset);return new U8e(this.bbi,I,c,o,C>0,"summary")}}return this.getUnzoomedView(i)}}function e6e(e,g){if(!new.target)throw new Error('Uncaught TypeError: Class constructor cannot be invoked without "new"');const i=class{constructor(){at(this,"dataConfig"),at(this,"bwFileHeader"),at(this,"bwFile"),at(this,"TILE_SIZE"),at(this,"errorTxt"),at(this,"dataPromises"),at(this,"chromSizes"),at(this,"assembly"),at(this,"tilesetInfoLoading"),this.dataConfig=g,this.assembly=this.dataConfig.assembly,this.bwFileHeader=null,this.bwFile=null,this.TILE_SIZE=1024,this.errorTxt="",this.dataPromises=[];const I=In(this.assembly).size,r=[],o={};let C=0;Object.keys(In(this.assembly).size).forEach((a,A)=>{const s={id:A,chr:a,pos:C};r.push(s),o[a]=s,C+=In(this.assembly).size[a]}),this.chromSizes={chrToAbs:(a,A)=>this.chromSizes.chrPositions[a].pos+A,cumPositions:r,chrPositions:o,totalLength:C,chromLengths:I},this.dataPromises.push(this.loadBBI(g))}async loadBBI(I){return I.url?(this.bwFile=new VNg({filehandle:new uMe(I.url,{overrides:I.urlFetchOptions})}),this.bwFile.getHeader().then(r=>{this.bwFileHeader=r})):(console.error('Please enter a "url" field to the data config'),null)}tilesetInfo(I){return this.tilesetInfoLoading=!0,Promise.all(this.dataPromises).then(()=>{this.tilesetInfoLoading=!1;const r=this.chromSizes.totalLength,o={tile_size:this.TILE_SIZE,max_zoom:Math.ceil(Math.log(r/this.TILE_SIZE)/Math.log(2)),max_width:2**Math.ceil(Math.log(r)/Math.log(2)),min_pos:[0],max_pos:[r]};return I&&I(o),o}).catch(r=>(this.tilesetInfoLoading=!1,console.error(r),I&&I({error:`Error parsing bigwig: ${r}`}),null))}fetchTilesDebounced(I,r){const o={},C=[],a=[];for(const A of r){const s=A.split("."),l=parseInt(s[0],10),c=parseInt(s[1],10);if(Number.isNaN(c)||Number.isNaN(l)){console.warn("Invalid tile zoom or position:",l,c);continue}C.push(A),a.push(this.tile(l,c))}return Promise.all(a).then(A=>{for(let s=0;s{const p=b.chr,y=b.pos,Z=b.pos+f[p];let v,G;if(y<=l&&lZ)v=l-y,G=Z-y,a.push(this.bwFile.getFeatures(p,v,G,{scale:1/u}).then(B=>(B.forEach(S=>{S.startAbs=e.utils.chrToAbs(p,S.start,this.chromSizes),S.endAbs=e.utils.chrToAbs(p,S.end,this.chromSizes)}),B))),l=Z;else{if(v=Math.floor(l-y),G=Math.ceil(c-y),!this.bwFile)return;a.push(this.bwFile.getFeatures(p,v,G,{scale:1/u}).then(B=>(B.forEach(S=>{S.startAbs=e.utils.chrToAbs(p,S.start,this.chromSizes),S.endAbs=e.utils.chrToAbs(p,S.end,this.chromSizes)}),B)));return}}),Promise.all(a).then(b=>{const p=b.flat(),y=[];for(let v=0;v{if(vc)return;const B=p.filter(S=>v>=S.startAbs&&vS.score);y[G]=B.length>0?B[0]:null});const Z=new e.utils.DenseDataExtrema1D(y);return A.min_value=Math.min(...y),A.max_value=Math.max(...y),A.dense=y,A.denseDataExtrema=Z,A.minNonZero=Z.minNonZeroInTile,A.maxNonZero=Z.maxNonZeroInTile,A})}determineScale(I,r){const o=[1],C=r-I;if(!this.bwFileHeader)throw Error("no bigwig header");this.bwFileHeader.zoomLevels.forEach(A=>{o.push(A.reductionLevel)});let a;return o.forEach(A=>{if(a)return;C/A<=this.TILE_SIZE*20&&(a=A)}),a||o.slice(-1)[0]}};return new i}e6e.config={type:"bigwig"};function t6e(e,g){const{field:i,not:n}=e;let I=Array.from(g);if(dSt(e)){const{oneOf:r}=e;I=I.filter(o=>n?r.indexOf(o[i])===-1:r.indexOf(o[i])!==-1)}else if(hSt(e)){const{inRange:r}=e;I=I.filter(o=>{const C=+o[i];return n?!(r[0]<=C&&C<=r[1]):r[0]<=C&&C<=r[1]})}else if(fSt(e)){const{include:r}=e;I=I.filter(o=>n?`${o[i]}`.includes(r):!`${o[i]}`.includes(r))}return I}function WNg(e,g){const{fields:i,separator:n,newField:I}=e;let r=Array.from(g);return r=r.map(o=>{const C=i.map(a=>o[a]);return o[I]=C.join(n),o}),r}function XNg(e,g){const{field:i,replace:n,newField:I}=e;let r=Array.from(g);return r=r.map(o=>(o[I]=o[i],n.forEach(C=>{const{from:a,to:A}=C;o[I]=o[I].toString().replaceAll(a,A)}),o)),r}function TNg(e,g){const{field:i,base:n,newField:I}=e;let r=Array.from(g);return r=r.map(o=>(+o[i]&&(n==="e"?o[I??i]=Math.log(+o[i]):o[I??i]=Math.log(+o[i])/Math.log(n??10)),o)),r}function HNg(e,g){const{startField:i,endField:n,newField:I}=e,r=Array.from(g);return r.forEach(o=>{const C=o[i],a=o[n];!C||!a||(o[I]=Math.abs(+a-+C))}),r}function NNg(e,g){const{firstBp:i,secondBp:n,newField:I}=e,r=Array.from(g),[o,C,a,A,s]=["DUP","TRA","DEL","t2tINV","h2hINV"];return r.forEach(l=>{const c=l[i.chrField],u=l[n.chrField];if(c!==u){l[I]=C;return}let d=l[i.posField],h=l[n.posField],f=l[i.strandField],m=l[n.strandField];if(d>h){const b=d,p=f;d=h,f=m,h=b,m=p}switch(`${f}${m}`){case"+-":l[I]=a;break;case"--":l[I]=A;break;case"++":l[I]=s;break;case"-+":l[I]=o;break;default:l[I]="unknown"}}),r}function kNg(e,g,i){const{startField:n,endField:I,newField:r,groupField:o}=e,C={},a=1;return g.forEach(s=>{const l=i(s[n]),c=i(s[I]),u=o?s[o]:"__NO_GROUP__",d=Math.floor(l);for(let h=d;h{const[l,c]=s;return Object.entries(c).map(u=>{const[d,h]=u;return{[n]:i.invert(+d),[I]:i.invert(+d+a),[r??"coverage"]:h,[o??"group"]:l}})})}function YNg(e,g,i){const{boundingBox:n,method:I,newField:r}=e,{startField:o,endField:C,groupField:a}=n;let A=0;n.padding&&i&&!n.isPaddingBP?A=Math.abs(i.invert(n.padding)-i.invert(0)):n.padding&&n.isPaddingBP&&(A=n.padding);const s=Array.from(g);if(s&&s.length>0&&(!Object.keys(s[0]).find(l=>l===o)||!Object.keys(s[0]).find(l=>l===C)))return s;if(I==="pile"){const{maxRows:l}=e,c={};s.sort((d,h)=>d[o]-h[o]).forEach(d=>{const h=+d[o]-A,f=+d[C]+A,m=a?d[a]:"__NO_GROUP__";c[m]||(c[m]=[]);let b=c[m].findIndex(p=>fc[o]-u[o]).forEach(c=>{let u=c[o]-A,d=c[C]+A,h=l.filter(f=>f.start===u&&d===f.end||f.start0){let f=0;do h=l.filter(m=>m.start===u&&d===m.end||m.start0&&(f%2===0?(u+=A*f,d+=A*f):(u-=A*f,d-=A*f)),f++;while(h.length>0&&f<1e3)}c[`${r}Start`]=`${u+A}`,c[`${r}Etart`]=`${d-A}`,l.push({start:u,end:d})})}return s}function KNg(e,g,i="hg38"){const{separator:n,fields:I,flag:r}=e;let o=Array.from(g);return o=o.map(C=>{const a=[];return I.forEach(A=>{const{field:s,type:l,newField:c,chrField:u}=A;C[s].toString().split(n).forEach((h,f)=>{let m=h;l==="genomic"&&(m=In(i).interval[C[u]][0]+ +h),a[f]?a[f][c]=m:a[f]=Object.assign(JSON.parse(JSON.stringify(C)),{[c]:m,[r.field]:r.value})})}),[C,...a]}).reduce((C,a)=>C.concat(a),[]),o}function xNg(e,g){const{field:i,genomicField:n,baseGenomicField:I,genomicLengthField:r}=e;let o=Array.from(g);return o=o.map(C=>{let a=JSON.parse(C[i]);return a=a.map(A=>{var s,l;return A[n]&&C[I]&&(A[`${n}_start`]=+A[n]+ +C[I],A[`${n}_end`]=+A[n]+ +C[I]+ +A[r]),Object.assign(JSON.parse(JSON.stringify(C)),{...A,[`${n}_start`]:A[`${n}_start`],[`${n}_end`]:A[`${n}_end`],type:(l=(s=A.type)!=null?s:A.variant)!=null?l:null,isParsedRow:"yes"})}),[C,...a]}).reduce((C,a)=>C.concat(a),[]),o}function FNg(e,g){if(bSt(e).length===0)return g;const i=tU(e,"nominal");if(i.length!==1)return console.warn("Currently, we only support aggregating datasets with single nominal field."),g;const n=e[i[0]];if(!pt(n))return g;const I=n.field;if(!I)return g;const r=[...tU(e,"quantitative"),...tU(e,"genomic")],o=[],C=Array.from(new Set(g.map(A=>A[I])));let a=!1;return C.forEach(A=>{const s={};s[I]=A,r.forEach(l=>{const c=e[l];if(!pt(c)){a=!0;return}const{field:u}=c;if(!u||!("aggregate"in c)){a=!0;return}s[u]=c.aggregate==="max"?Math.max(...g.filter(d=>d[I]===A).map(d=>+d[u])):Math.min(...g.filter(d=>d[I]===A).map(d=>+d[u]))}),o.push(s)}),a?g:o}class ENg{constructor(g){Vg(this,Iie),Vg(this,kle),Vg(this,MD),Vg(this,oie),Vg(this,Cie),Vg(this,aie),at(this,"dataConfig"),at(this,"tilesetInfoLoading"),Vg(this,$V,void 0),Vg(this,m9,void 0),Vg(this,p9,void 0),Vg(this,q0,void 0),Vg(this,ED,void 0),Vg(this,DD,void 0),this.dataConfig=g,this.tilesetInfoLoading=!1,ho(this,q0,this.dataConfig.assembly),ho(this,ED,this.dataConfig.filter),g.url||console.error("Please provide the `url` of the data");const{urlFetchOptions:i,url:n}=g;ho(this,DD,new uMe(n,{overrides:i})),ho(this,m9,Mi(this,aie,y8e).call(this)),ho(this,$V,Mi(this,Iie,f8e).call(this))}tilesetInfo(g){if(Ut(this,$V))return this.tilesetInfoLoading=!0,Ut(this,$V).then(()=>Mi(this,oie,p8e).call(this,g)).catch(i=>{this.tilesetInfoLoading=!1,console.error("[Gosling Data Fetcher] Error parsing data:",i)})}fetchTilesDebounced(g,i){const n={},I=[],r=[];for(const o of i){const C=o.split("."),a=parseInt(C[0],10),A=parseInt(C[1],10),s=parseInt(C[2],10);if(Number.isNaN(A)||Number.isNaN(a)){console.warn("[Gosling Data Fetcher] Invalid tile zoom or position:",a,A,s);continue}I.push(o),r.push(Mi(this,Cie,b8e).call(this,a,A,s))}Promise.all(r).then(o=>{o.forEach((C,a)=>{if(C){const A=I[a];n[A]=C,n[A].tilePositionId=A}}),g(n)})}}$V=new WeakMap;m9=new WeakMap;p9=new WeakMap;q0=new WeakMap;ED=new WeakMap;DD=new WeakMap;Iie=new WeakSet;f8e=async function(){var e,g;const{chromosomeField:i,genomicFields:n,headerNames:I,longToWideId:r,genomicFieldsToConvert:o}=this.dataConfig,C=(e=this.dataConfig.separator)!=null?e:",";try{const A=(await Ut(this,DD).readFile()).toString(),s=I?`${I.join(C)} +${A}`:A,l=ZXt(C).parse(s,c=>Mi(this,kle,m8e).call(this,c,o,i,n));if(r&&((g=l[0])!=null&&g[r])){const c=Object.keys(l[0]),u={};l.forEach(d=>{u[d[r]]?c.forEach(h=>{u[d[r]][`${h}_2`]=d[h]}):u[d[r]]=JSON.parse(JSON.stringify(d))}),ho(this,p9,Object.keys(u).map(d=>u[d]))}else ho(this,p9,l)}catch(a){console.error("[Gosling Data Fetcher] Error fetching data",a)}};kle=new WeakSet;m8e=function(e,g,i,n){try{return g?g.forEach(I=>{const r=I.genomicFields,o=e[I.chromosomeField];r.forEach(C=>{const a=e[C];e[C]=String(Mi(this,MD,rie).call(this,o,a))})}):i&&n&&n.forEach(I=>{const r=e[I],o=e[i];e[I]=String(Mi(this,MD,rie).call(this,o,r))}),e}catch{return}};MD=new WeakSet;rie=function(e,g){if(Ut(this,q0)!=="unknown"){const i=X6(e,Ut(this,q0),this.dataConfig.chromosomePrefix);return In(Ut(this,q0)).interval[i][0]+ +g}else return g};oie=new WeakSet;p8e=function(e){this.tilesetInfoLoading=!1;const g=1024,i=Ut(this,m9).totalLength,n={tile_size:g,max_zoom:Math.ceil(Math.log(i/g)/Math.log(2)),max_width:i,min_pos:[0,0],max_pos:[i,i]};return e&&e(n),n};Cie=new WeakSet;b8e=async function(e,g,i){var n,I;const r=await this.tilesetInfo();if(!r)return;const o=+r.max_width/2**+e,C=r.min_pos[0]+g*o,a=r.min_pos[0]+(g+1)*o;let A=cMe(Ut(this,p9),[C,a],this.dataConfig);(n=Ut(this,ED))==null||n.forEach(l=>{A=t6e(l,A)});const s=(I=this.dataConfig.sampleLength)!=null?I:1e3;return{tabularData:A.length>s?Uoe(A,s):A,server:null,tilePos:[g,i],zoomLevel:e}};aie=new WeakSet;y8e=function(){const e=In(Ut(this,q0)).size,g=[],i={};let n=0;return Object.keys(e).forEach((I,r)=>{const o={id:r,chr:I,pos:n};g.push(o),i[I]=o,n+=e[I]}),{chrToAbs:(I,r)=>Ut(this,m9).chrPositions[I].pos+r,cumPositions:g,chrPositions:i,totalLength:n,chromLengths:e}};function g6e(e,g,i){if(!new.target)throw new Error('Uncaught TypeError: Class constructor cannot be invoked without "new"');return new ENg(g)}g6e.config={type:"csv"};function i6e(e,...g){if(!new.target)throw new Error('Uncaught TypeError: Class constructor cannot be invoked without "new"');class i{constructor(I){at(this,"dataConfig"),at(this,"tilesetInfoLoading"),at(this,"chromSizes"),at(this,"values"),at(this,"assembly");const[r]=I;if(this.dataConfig=r,this.tilesetInfoLoading=!1,this.assembly=this.dataConfig.assembly,!r.values){console.error("Please provide `values` of the JSON data");return}const o=In(this.assembly).size,C=[],a={};let A=0;Object.keys(In(this.assembly).size).forEach((u,d)=>{const h={id:d,chr:u,pos:A};C.push(h),a[u]=h,A+=In(this.assembly).size[u]}),this.chromSizes={chrToAbs:(u,d)=>this.chromSizes.chrPositions[u].pos+d,cumPositions:C,chrPositions:a,totalLength:A,chromLengths:o};const{chromosomeField:s,genomicFields:l,genomicFieldsToConvert:c}=this.dataConfig;this.values=r.values.map(u=>{try{return c?c.forEach(d=>{const h=d.genomicFields,f=X6(u[d.chromosomeField],this.assembly);h.forEach(m=>{const b=u[m];u[m]=String(this.chromSizes.chrToAbs(f,b))})}):s&&l&&l.forEach(d=>{const h=u[d],f=X6(u[s],this.assembly);u[d]=String(this.chromSizes.chrToAbs(f,h))}),u}catch{return}})}tilesetInfo(I){this.tilesetInfoLoading=!1;const r=1024,o=this.chromSizes.totalLength,C={tile_size:r,max_zoom:Math.ceil(Math.log(o/r)/Math.log(2)),max_width:o,min_pos:[0,0],max_pos:[o,o]};return I&&I(C),C}fetchTilesDebounced(I,r){const o={},C=[],a=[];for(const A of r){const s=A.split("."),l=parseInt(s[0],10),c=parseInt(s[1],10),u=parseInt(s[2],10);if(Number.isNaN(c)||Number.isNaN(l)){console.warn("[Gosling Data Fetcher] Invalid tile zoom or position:",l,c,u);continue}C.push(A),a.push(this.tile(l,c,u))}return Promise.all(a).then(A=>{A.forEach((s,l)=>{const c=C[l];o[c]=s,o[c].tilePositionId=c}),I(o)}),o}tile(I,r,o){var C;const a=this.tilesetInfo(),A=+a.max_width/2**+I,s=a.min_pos[0]+r*A,l=a.min_pos[0]+(r+1)*A;let c=cMe(this.values,[s,l],this.dataConfig);const u=(C=this.dataConfig.sampleLength)!=null?C:1e3;return u{const a=Object.entries(In(r).size);return await C.init(this.uid,{url:n,indexUrl:I},a,o),C})}async tilesetInfo(g){(await this.worker).tilesetInfo(this.uid).then(g)}fetchTilesDebounced(g,i){this.track.drawLoadingCue(),i.forEach(n=>this.toFetch.add(n)),this.fetchTimeout&&clearTimeout(this.fetchTimeout),this.fetchTimeout=setTimeout(()=>{this.sendFetch(g,[...this.toFetch]),this.toFetch.clear()},MNg)}async sendFetch(g,i){(await this.worker).fetchTilesDebounced(this.uid,i).then(g)}async getTabularData(g){const i=await(await this.worker).getTabularData(this.uid,g);return JSON.parse(new TextDecoder().decode(i))}}at(I6e,"config",{type:"gff"});const r6e="KCgpID0+IHsKICB2YXIgX19jcmVhdGUgPSBPYmplY3QuY3JlYXRlOwogIHZhciBfX2RlZlByb3AgPSBPYmplY3QuZGVmaW5lUHJv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1wICYgMjU1OwogICAgICAgIH0KICAgICAgICByZXR1cm4gYXJyOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIHRyaXBsZXRUb0Jhc2U2NChudW0pIHsKICAgICAgICByZXR1cm4gbG9va3VwW251bSA+PiAxOCAmIDYzXSArIGxvb2t1cFtudW0gPj4gMTIgJiA2M10gKyBsb29rdXBbbnVtID4+IDYgJiA2M10gKyBsb29rdXBbbnVtICYgNjNdOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGVuY29kZUNodW5rKHVpbnQ4LCBzdGFydCwgZW5kKSB7CiAgICAgICAgdmFyIHRtcDsKICAgICAgICB2YXIgb3V0cHV0ID0gW107CiAgICAgICAgZm9yICh2YXIgaTIgPSBzdGFydDsgaTIgPCBlbmQ7IGkyICs9IDMpIHsKICAgICAgICAgIHRtcCA9ICh1aW50OFtpMl0gPDwgMTYgJiAxNjcxMTY4MCkgKyAodWludDhbaTIgKyAxXSA8PCA4ICYgNjUyODApICsgKHVpbnQ4W2kyICsgMl0gJiAyNTUpOwogICAgICAgICAgb3V0cHV0LnB1c2godHJpcGxldFRvQmFzZTY0KHRtcCkpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gb3V0cHV0LmpvaW4oIiIpOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGZyb21CeXRlQXJyYXkodWludDgpIHsKICAgICAgICB2YXIgdG1wOwogICAgICAgIHZhciBsZW4yID0gdWludDgubGVuZ3RoOwogICAgICAgIHZhciBleHRyYUJ5dGVzID0gbGVuMiAlIDM7CiAgICAgICAgdmFyIHBhcnRzID0gW107CiAgICAgICAgdmFyIG1heENodW5rTGVuZ3RoID0gMTYzODM7CiAgICAgICAgZm9yICh2YXIgaTIgPSAwLCBsZW4yMiA9IGxlbjIgLSBleHRyYUJ5dGVzOyBpMiA8IGxlbjIyOyBpMiArPSBtYXhDaHVua0xlbmd0aCkgewogICAgICAgICAgcGFydHMucHVzaChlbmNvZGVDaHVuayh1aW50OCwgaTIsIGkyICsgbWF4Q2h1bmtMZW5ndGggPiBsZW4yMiA/IGxlbjIyIDogaTIgKyBtYXhDaHVua0xlbmd0aCkpOwogICAgICAgIH0KICAgICAgICBpZiAoZXh0cmFCeXRlcyA9PT0gMSkgewogICAgICAgICAgdG1wID0gdWludDhbbGVuMiAtIDFdOwogICAgICAgICAgcGFydHMucHVzaChsb29rdXBbdG1wID4+IDJdICsgbG9va3VwW3RtcCA8PCA0ICYgNjNdICsgIj09Iik7CiAgICAgICAgfSBlbHNlIGlmIChleHRyYUJ5dGVzID09PSAyKSB7CiAgICAgICAgICB0bXAgPSAodWludDhbbGVuMiAtIDJdIDw8IDgpICsgdWludDhbbGVuMiAtIDFdOwogICAgICAgICAgcGFydHMucHVzaChsb29rdXBbdG1wID4+IDEwXSArIGxvb2t1cFt0bXAgPj4gNCAmIDYzXSArIGxvb2t1cFt0bXAgPDwgMiAmIDYzXSArICI9Iik7CiAgICAgICAgfQogICAgICAgIHJldHVybiBwYXJ0cy5qb2luKCIiKTsKICAgICAgfQogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLnBucG0vaWVlZTc1NEAxLjIuMS9ub2RlX21vZHVsZXMvaWVlZTc1NC9pbmRleC5qcwogIHZhciByZXF1aXJlX2llZWU3NTQgPSBfX2NvbW1vbkpTKHsKICAgICJub2RlX21vZHVsZXMvLnBucG0vaWVlZTc1NEAxLjIuMS9ub2RlX21vZHVsZXMvaWVlZTc1NC9pbmRleC5qcyIoZXhwb3J0czIpIHsKICAgICAgaW5pdF9idWZmZXJfc2hpbSgpOwogICAgICBleHBvcnRzMi5yZWFkID0gZnVuY3Rpb24oYnVmZmVyLCBvZmZzZXQsIGlzTEUsIG1MZW4sIG5CeXRlcykgewogICAgICAgIHZhciBlLCBtOwogICAgICAgIHZhciBlTGVuID0gbkJ5dGVzICogOCAtIG1MZW4gLSAxOwogICAgICAgIHZhciBlTWF4ID0gKDEgPDwgZUxlbikgLSAxOwogICAgICAgIHZhciBlQmlhcyA9IGVNYXggPj4gMTsKICAgICAgICB2YXIgbkJpdHMgPSAtNzsKICAgICAgICB2YXIgaSA9IGlzTEUgPyBuQnl0ZXMgLSAxIDogMDsKICAgICAgICB2YXIgZCA9IGlzTEUgPyAtMSA6IDE7CiAgICAgICAgdmFyIHMgPSBidWZmZXJbb2Zmc2V0ICsgaV07CiAgICAgICAgaSArPSBkOwogICAgICAgIGUgPSBzICYgKDEgPDwgLW5CaXRzKSAtIDE7CiAgICAgICAgcyA+Pj0gLW5CaXRzOwogICAgICAgIG5CaXRzICs9IGVMZW47CiAgICAgICAgZm9yICg7IG5CaXRzID4gMDsgZSA9IGUgKiAyNTYgKyBidWZmZXJbb2Zmc2V0ICsgaV0sIGkgKz0gZCwgbkJpdHMgLT0gOCkgewogICAgICAgIH0KICAgICAgICBtID0gZSAmICgxIDw8IC1uQml0cykgLSAxOwogICAgICAgIGUgPj49IC1uQml0czsKICAgICAgICBuQml0cyArPSBtTGVuOwogICAgICAgIGZvciAoOyBuQml0cyA+IDA7IG0gPSBtICogMjU2ICsgYnVmZmVyW29mZnNldCArIGldLCBpICs9IGQsIG5CaXRzIC09IDgpIHsKICAgICAgICB9CiAgICAgICAgaWYgKGUgPT09IDApIHsKICAgICAgICAgIGUgPSAxIC0gZUJpYXM7CiAgICAgICAgfSBlbHNlIGlmIChlID09PSBlTWF4KSB7CiAgICAgICAgICByZXR1cm4gbSA/IE5hTiA6IChzID8gLTEgOiAxKSAqIEluZmluaXR5OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBtID0gbSArIE1hdGgucG93KDIsIG1MZW4pOwogICAgICAgICAgZSA9IGUgLSBlQmlhczsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIChzID8gLTEgOiAxKSAqIG0gKiBNYXRoLnBvdygyLCBlIC0gbUxlbik7CiAgICAgIH07CiAgICAgIGV4cG9ydHMyLndyaXRlID0gZnVuY3Rpb24oYnVmZmVyLCB2YWx1ZSwgb2Zmc2V0LCBpc0xFLCBtTGVuLCBuQnl0ZXMpIHsKICAgICAgICB2YXIgZSwgbSwgYzsKICAgICAgICB2YXIgZUxlbiA9IG5CeXRlcyAqIDggLSBtTGVuIC0gMTsKICAgICAgICB2YXIgZU1heCA9ICgxIDw8IGVMZW4pIC0gMTsKICAgICAgICB2YXIgZUJpYXMgPSBlTWF4ID4+IDE7CiAgICAgICAgdmFyIHJ0ID0gbUxlbiA9PT0gMjMgPyBNYXRoLnBvdygyLCAtMjQpIC0gTWF0aC5wb3coMiwgLTc3KSA6IDA7CiAgICAgICAgdmFyIGkgPSBpc0xFID8gMCA6IG5CeXRlcyAtIDE7CiAgICAgICAgdmFyIGQgPSBpc0xFID8gMSA6IC0xOwogICAgICAgIHZhciBzID0gdmFsdWUgPCAwIHx8IHZhbHVlID09PSAwICYmIDEgLyB2YWx1ZSA8IDAgPyAxIDogMDsKICAgICAgICB2YWx1ZSA9IE1hdGguYWJzKHZhbHVlKTsKICAgICAgICBpZiAoaXNOYU4odmFsdWUpIHx8IHZhbHVlID09PSBJbmZpbml0eSkgewogICAgICAgICAgbSA9IGlzTmFOKHZhbHVlKSA/IDEgOiAwOwogICAgICAgICAgZSA9IGVNYXg7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGUgPSBNYXRoLmZsb29yKE1hdGgubG9nKHZhbHVlKSAvIE1hdGguTE4yKTsKICAgICAgICAgIGlmICh2YWx1ZSAqIChjID0gTWF0aC5wb3coMiwgLWUpKSA8IDEpIHsKICAgICAgICAgICAgZS0tOwogICAgICAgICAgICBjICo9IDI7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoZSArIGVCaWFzID49IDEpIHsKICAgICAgICAgICAgdmFsdWUgKz0gcnQgLyBjOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgdmFsdWUgKz0gcnQgKiBNYXRoLnBvdygyLCAxIC0gZUJpYXMpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHZhbHVlICogYyA+PSAyKSB7CiAgICAgICAgICAgIGUrKzsKICAgICAgICAgICAgYyAvPSAyOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGUgKyBlQmlhcyA+PSBlTWF4KSB7CiAgICAgICAgICAgIG0gPSAwOwogICAgICAgICAgICBlID0gZU1heDsKICAgICAgICAgIH0gZWxzZSBpZiAoZSArIGVCaWFzID49IDEpIHsKICAgICAgICAgICAgbSA9ICh2YWx1ZSAqIGMgLSAxKSAqIE1hdGgucG93KDIsIG1MZW4pOwogICAgICAgICAgICBlID0gZSArIGVCaWFzOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgbSA9IHZhbHVlICogTWF0aC5wb3coMiwgZUJpYXMgLSAxKSAqIE1hdGgucG93KDIsIG1MZW4pOwogICAgICAgICAgICBlID0gMDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZm9yICg7IG1MZW4gPj0gODsgYnVmZmVyW29mZnNldCArIGldID0gbSAmIDI1NSwgaSArPSBkLCBtIC89IDI1NiwgbUxlbiAtPSA4KSB7CiAgICAgICAgfQogICAgICAgIGUgPSBlIDw8IG1MZW4gfCBtOwogICAgICAgIGVMZW4gKz0gbUxlbjsKICAgICAgICBmb3IgKDsgZUxlbiA+IDA7IGJ1ZmZlcltvZmZzZXQgKyBpXSA9IGUgJiAyNTUsIGkgKz0gZCwgZSAvPSAyNTYsIGVMZW4gLT0gOCkgewogICAgICAgIH0KICAgICAgICBidWZmZXJbb2Zmc2V0ICsgaSAtIGRdIHw9IHMgKiAxMjg7CiAgICAgIH07CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8ucG5wbS9idWZmZXJANi4wLjMvbm9kZV9tb2R1bGVzL2J1ZmZlci9pbmRleC5qcwogIHZhciByZXF1aXJlX2J1ZmZlciA9IF9fY29tbW9uSlMoewogICAgIm5vZGVfbW9kdWxlcy8ucG5wbS9idWZmZXJANi4wLjMvbm9kZV9tb2R1bGVzL2J1ZmZlci9pbmRleC5qcyIoZXhwb3J0czIpIHsKICAgICAga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ICBmdW5jdGlvbiB0eXBlZEFycmF5U3VwcG9ydCgpIHsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgYXJyID0gbmV3IFVpbnQ4QXJyYXkoMSk7CiAgICAgICAgICBjb25zdCBwcm90byA9IHsgZm9vOiBmdW5jdGlvbigpIHsKICAgICAgICAgICAgcmV0dXJuIDQyOwogICAgICAgICAgfSB9OwogICAgICAgICAgT2JqZWN0LnNldFByb3RvdHlwZU9mKHByb3RvLCBVaW50OEFycmF5LnByb3RvdHlwZSk7CiAgICAgICAgICBPYmplY3Quc2V0UHJvdG90eXBlT2YoYXJyLCBwcm90byk7CiAgICAgICAgICByZXR1cm4gYXJyLmZvbygpID09PSA0MjsKICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfQogICAgICB9CiAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShCdWZmZXIxMC5wcm90b3R5cGUsICJwYXJlbnQiLCB7CiAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkgewogICAgICAgICAgaWYgKCFCdWZmZXIxMC5pc0J1ZmZlcih0aGlzKSkKICAgICAgICAgICAgcmV0dXJuIHZvaWQgMDsKICAgICAgICAgIHJldHVybiB0aGlzLmJ1ZmZlcjsKICAgICAgICB9CiAgICAgIH0pOwogICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoQnVmZmVyMTAucHJvdG90eXBlLCAib2Zmc2V0IiwgewogICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHsKICAgICAgICAgIGlmICghQnVmZmVyMTAuaXNCdWZmZXIodGhpcykpCiAgICAgICAgICAgIHJldHVybiB2b2lkIDA7CiAgICAgICAgICByZXR1cm4gdGhpcy5ieXRlT2Zmc2V0OwogICAgICAgIH0KICAgICAgfSk7CiAgICAgIGZ1bmN0aW9uIGNyZWF0ZUJ1ZmZlcihsZW5ndGgpIHsKICAgICAgICBpZiAobGVuZ3RoID4gS19NQVhfTEVOR1RIKSB7CiAgICAgICAgICB0aHJvdyBuZXcgUmFuZ2VFcnJvcignVGhlIHZhbHVlICInICsgbGVuZ3RoICsgJyIgaXMgaW52YWxpZCBmb3Igb3B0aW9uICJzaXplIicpOwogICAgICAgIH0KICAgICAgICBjb25zdCBidWYgPSBuZXcgVWludDhBcnJheShsZW5ndGgpOwogICAgICAgIE9iamVjdC5zZXRQcm90b3R5cGVPZihidWYsIEJ1ZmZlcjEwLnByb3RvdHlwZSk7CiAgICAgICAgcmV0dXJuIGJ1ZjsKICAgICAgfQogICAgICBmdW5jdGlvbiBCdWZmZXIxMChhcmcsIGVuY29kaW5nT3JPZmZzZXQsIGxlbmd0aCkgewogICAgICAgIGlmICh0eXBlb2YgYXJnID09PSAibnVtYmVyIikgewogICAgICAgICAgaWYgKHR5cGVvZiBlbmNvZGluZ09yT2Zmc2V0ID09PSAic3RyaW5nIikgewogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCdUaGUgInN0cmluZyIgYXJndW1lbnQgbXVzdCBiZSBvZiB0eXBlIHN0cmluZy4gUmVjZWl2ZWQgdHlwZSBudW1iZXInKTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBhbGxvY1Vuc2FmZShhcmcpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gZnJvbShhcmcsIGVuY29kaW5nT3JPZmZzZXQsIGxlbmd0aCk7CiAgICAgIH0KICAgICAgQnVmZmVyMTAucG9vbFNpemUgPSA4MTkyOwogICAgICBmdW5jdGlvbiBmcm9tKHZhbHVlLCBlbmNvZGluZ09yT2Zmc2V0LCBsZW5ndGgpIHsKICAgICAgICBpZiAodHlwZW9mIHZhbHVlID09PSAic3RyaW5nIikgewogICAgICAgICAgcmV0dXJuIGZyb21TdHJpbmcodmFsdWUsIGVuY29kaW5nT3JPZmZzZXQpOwogICAgICAgIH0KICAgICAgICBpZ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KICAgICAgfTsKICAgICAgZnVuY3Rpb24gYWxsb2NVbnNhZmUoc2l6ZSkgewogICAgICAgIGFzc2VydFNpemUoc2l6ZSk7CiAgICAgICAgcmV0dXJuIGNyZWF0ZUJ1ZmZlcihzaXplIDwgMCA/IDAgOiBjaGVja2VkKHNpemUpIHwgMCk7CiAgICAgIH0KICAgICAgQnVmZmVyMTAuYWxsb2NVbnNhZmUgPSBmdW5jdGlvbihzaXplKSB7CiAgICAgICAgcmV0dXJuIGFsbG9jVW5zYWZlKHNpemUpOwogICAgICB9OwogICAgICBCdWZmZXIxMC5hbGxvY1Vuc2FmZVNsb3cgPSBmdW5jdGlvbihzaXplKSB7CiAgICAgICAgcmV0dXJuIGFsbG9jVW5zYWZlKHNpemUpOwogICAgICB9OwogICAgICBmdW5jdGlvbiBmcm9tU3RyaW5nKHN0cmluZywgZW5jb2RpbmcpIHsKICAgICAgICBpZiAodHlwZW9mIGVuY29kaW5nICE9PSAic3RyaW5nIiB8fCBlbmNvZGluZyA9PT0gIiIpIHsKICAgICAgICAgIGVuY29kaW5nID0gInV0ZjgiOwogICAgICAgIH0KICAgICAgICBpZiAoIUJ1ZmZlcjEwLmlzRW5jb2RpbmcoZW5jb2RpbmcpKSB7CiAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCJVbmtub3duIGVuY29kaW5nOiAiICsgZW5jb2RpbmcpOwogICAgICAgIH0KICAgICAgICBjb25zdCBsZW5ndGggPSBieXRlTGVuZ3RoKHN0cmluZywgZW5jb2RpbmcpIHwgMDsKICAgICAgICBsZXQgYnVmID0gY3JlYXRlQnVmZmVyKGxlbmd0aCk7CiAgICAgICAgY29uc3QgYWN0dWFsID0gYnVmLndyaXRlKHN0cmluZywgZW5jb2RpbmcpOwogICAgICAgIGlmIChhY3R1YWwgIT09IGxlbmd0aCkgewogICAgICAgICAgYnVmID0gYnVmLnNsaWNlKDAsIGFjdHVhbCk7CiAgICAgICAgfQogICAgICAgIHJldHVybiBidWY7CiAgIC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BSYW5nZUVycm9yKCcibGVuZ3RoIiBpcyBvdXRzaWRlIG9mIGJ1ZmZlciBib3VuZHMnKTsKICAgICAgICB9CiAgICAgICAgbGV0IGJ1ZjsKICAgICAgICBpZiAoYnl0ZU9mZnNldCA9PT0gdm9pZCAwICYmIGxlbmd0aCA9PT0gdm9pZCAwKSB7CiAgICAgICAgICBidWYgPSBuZXcgVWludDhBcnJheShhcnJheSk7CiAgICAgICAgfSBlbHNlIGlmIChsZW5ndGggPT09IHZvaWQgMCkgewogICAgICAgICAgYnVmID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXksIGJ5dGVPZmZzZXQpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBidWYgPSBuZXcgVWludDhBcnJheShhcnJheSwgYnl0ZU9mZnNldCwgbGVuZ3RoKTsKICAgICAgICB9CiAgICAgICAgT2JqZWN0LnNldFByb3RvdHlwZU9mKGJ1ZiwgQnVmZmVyMTAucHJvdG90eXBlKTsKICAgICAgICByZXR1cm4gYnVmOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGZyb21PYmplY3Qob2JqKSB7CiAgICAgICAgaWYgKEJ1ZmZlcjEwLmlzQnVmZmVyKG9iaikpIHsKICAgICAgICAgIGNvbnN0IGxlbiA9IGNoZWNrZWQob2JqLmxlbmd0aCkgfCAwOwogICAgICAgICAgY29uc3QgYnVmID0gY3JlYXRlQnVmZmVyKGxlbik7CiAgICAgICAgICBpZiAoYnVmLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICByZXR1cm4gYnVmOwogICAgICAgICAgfQogICAgICAgICAgb2JqLmNvcHkoYnVmLCAwLCAwLCBsZW4pOwogICAgICAgICAgcmV0dXJuIGJ1ZjsKICAgICAgICB9CiAgICAgICAgaWYgKG9iai5sZW5ndGggIT09IHZvaWQgMCkgewogICAgICAgICAgaWYgKHR5cGVvZiBvYmoubGVuZ3RoICE9PSAibnVtYmVyIiB8fCBudW1iZXJJc05hTihvYmoubGVuZ3RoKSkgewogICAgICAgICAgICByZXR1cm4gY3JlYXRlQnVmZmVyKDApOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIGZyb21BcnJheUxpa2Uob2JqKTsKICAgICAgICB9CiAgICAgICAgaWYgKG9iai50eXBlID09PSAiQnVmZmVyIiAmJiBBcnJheS5pc0FycmF5KG9iai5kYXRhKSkgewogICAgICAgICAgcmV0dXJuIGZyb21BcnJheUxpa2Uob2JqLmRhdGEpOwogICAgICAgIH0KICAgICAgfQogICAgICBmdW5jdGlvbiBjaGVja2VkKGxlbmd0aCkgewogICAgICAgIGlmIChsZW5ndGggPj0gS19NQVhfTEVOR1RIKSB7CiAgICAgICAgICB0aHJvdyBuZXcgUmFuZ2VFcnJvcigiQXR0ZW1wdCB0byBhbGxvY2F0ZSBCdWZmZXIgbGFyZ2VyIHRoYW4gbWF4aW11bSBzaXplOiAweCIgKyBLX01BWF9MRU5HVEgudG9TdHJpbmcoMTYpICsgIiBieXRlcyIpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gbGVuZ3RoIHwgMDsKICAgICAgfQogICAgICBmdW5jdGlvbiBTbG93QnVmZmVyKGxlbmd0aCkgewogICAgICAgIGlmICgrbGVuZ3RoICE9IGxlbmd0aCkgewogICAgICAgICAgbGVuZ3RoID0gMDsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIEJ1ZmZlcjEwLmFsbG9jKCtsZW5ndGgpOwogICAgICB9CiAgICAgIEJ1ZmZlcjEwLmlzQnVmZmVyID0gZnVuY3Rpb24gaXNCdWZmZXIyKGIpIHsKICAgICAgICByZXR1cm4gYiAhPSBudWxsICYmIGIuX2lzQnVmZmVyID09PSB0cnVlICYmIGIgIT09IEJ1ZmZlcjEwLnByb3RvdHlwZTsKICAgICAgfTsKICAgICAgQnVmZmVyMTAuY29tcGFyZSA9IGZ1bmN0aW9uIGNvbXBhcmUoYSwgYikgewogICAgICAgIGlmIChpc0luc3RhbmNlKGEsIFVpbnQ4QXJyYXkpKQogICAgICAgICAgYS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1dGY4IjoKICAgICAgICAgIGNhc2UgInV0Zi04IjoKICAgICAgICAgIGNhc2UgImFzY2lpIjoKICAgICAgICAgIGNhc2UgImxhdGluMSI6CiAgICAgICAgICBjYXNlICJiaW5hcnkiOgogICAgICAgICAgY2FzZSAiYmFzZTY0IjoKICAgICAgICAgIGNhc2UgInVjczIiOgogICAgICAgICAgY2FzZSAidWNzLTIiOgogICAgICAgICAgY2FzZSAidXRmMTZsZSI6CiAgICAgICAgICBjYXNlICJ1dGYtMTZsZSI6CiAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgfTsKICAgICAgQnVmZmVyMTAuY29uY2F0ID0gZnVuY3Rpb24gY29uY2F0KGxpc3QsIGxlbmd0aCkgewogICAgICAgIGlmICghQXJyYXkuaXNBcnJheShsaXN0KSkgewogICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcignImxpc3QiIGFyZ3VtZW50IG11c3QgYmUgYW4gQXJyYXkgb2YgQnVmZmVycycpOwogICAgICAgIH0KICAgICAgICBpZiAobGlzdC5sZW5ndGggPT09IDApIHsKICAgICAgICAgIHJldHVybiBCdWZmZXIxMC5hbGxvYygwKTsKICAgICAgICB9CiAgICAgICAgbGV0IGk7CiAgICAgICAgaWYgKGxlbmd0aCA9PT0gdm9pZCAwKSB7CiAgICAgICAgICBsZW5ndGggPSAwOwogICAgICAgICAgZm9yIChpID0gMDsgaSA8IGxpc3QubGVuZ3RoOyArK2kpIHsKICAgICAgICAgICAgbGVuZ3RoICs9IGxpc3RbaV0ubGVuZ3RoOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjb25zdCBidWZmZXIgPSBCdWZmZXIxMC5hbGxvY1Vuc2FmZShsZW5ndGgpOwogICAgICAgIGxldCBwb3MgPSAwOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsaXN0Lmxlbmd0aDsgKytpKSB7CiAgICAgICAgICBsZXQgYnVmID0gbGlzdFtpXTsKICAgICAgICAgIGlmIChpc0luc3RhbmNlKGJ1ZiwgVWludDhBcnJheSkpIHsKICAgICAgICAgICAgaWYgKHBvcyArIGJ1Zi5sZW5ndGggPiBidWZmZXIubGVuZ3RoKSB7CiAgICAgICAgICAgICAgaWYgKCFCdWZmZXIxMC5pc0J1ZmZlcihidWYpKQogICAgICAgICAgICAgICAgYnVmID0gQnVmZmVyMTAuZnJvbShidWYpOwogICAgICAgICAgICAgIGJ1Zi5jb3B5KGJ1ZmZlciwgcG9zKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBVaW50OEFycmF5LnByb3RvdHlwZS5zZXQuY2FsbChidWZmZXIsIGJ1ZiwgcG9zKTsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIGlmICghQnVmZmVyMTAuaXNCdWZmZXIoYnVmKSkgewogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCcibGlzdCIgYXJndW1lbnQgbXVzdCBiZSBhbiBBcnJheSBvZiBCdWZmZXJzJyk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBidWYuY29weShidWZmZXIsIHBvcyk7CiAgICAgICAgICB9CiAgICAgICAgICBwb3MgKz0gYnVmLmxlbmd0aDsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJ1ZmZlcjsKICAgICAgfTsKICAgICAgZnVuY3Rpb24gYnl0ZUxlbmd0aChzdHJpbmcsIGVuY29kaW5nKSB7CiAgICAgICAgaWYgKEJ1ZmZlcjEwLmlzQnVmZmVyKHN0cmluZykpIHsKICAgICAgICAgIHJldHVybiBzdHJpbmcubGVuZ3RoOwogICAgICAgIH0KICAgICAgICBpZiAoQXJyYXlCdWZmZXIuaXNWaWV3KHN0cmluZykgfHwgaXNJbnN0YW5jZShzdHJpbmcsIEFycmF5QnVmZmVyKSkgewogICAgICAgICAgcmV0dXJuIHN0cmluZy5ieXRlTGVuZ3RoOwogICAgICAgIH0KICAgICAgICBpZiAodHlwZW9mIHN0cmluZyAhPT0gInN0cmluZyIpIHsKICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoJ1RoZSAic3RyaW5nIiBhcmd1bWVudCBtdXN0IGJlIG9uZSBvZiB0eXBlIHN0cmluZywgQnVmZmVyLCBvciBBcnJheUJ1ZmZlci4gUmVjZWl2ZWQgdHlwZSAnICsgdHlwZW9mIHN0cmluZyk7CiAgICAgICAgfQogICAgICAgIGNvbnN0IGxlbiA9IHN0cmluZy5sZW5ndGg7CiAgICAgICAgY29uc3QgbXVzdE1hdGNoID0gYXJndW1lbnRzLmxlbmd0aCA+IDIgJiYgYXJndW1lbnRzWzJdID09PSB0cnVlOwogICAgICAgIGlmICghbXVzdE1hdGNoICYmIGxlbiA9PT0gMCkKICAgICAgICAgIHJldHVybiAwOwogICAgICAgIGxldCBsb3dlcmVkQ2FzZSA9IGZhbHNlOwogICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgc3dpdGNoIChlbmNvZGluZykgewogICAgICAgICAgICBjYXNlICJhc2NpaSI6CiAgICAgICAgICAgIGNhc2UgImxhdGluMSI6CiAgICAgICAgICAgIGNhc2UgImJpbmFyeSI6CiAgICAgICAgICAgICAgcmV0dXJuIGxlbjsKICAgICAgICAgICAgY2FzZSAidXRmOCI6CiAgICAgICAgICAgIGNhc2UgInV0Zi04IjoKICAgICAgICAgICAgICByZXR1cm4gdXRmOFRvQnl0ZXMoc3RyaW5nKS5sZW5ndGg7CiAgICAgICAgICAgIGNhc2UgInVjczIiOgogICAgICAgICAgICBjYXNlICJ1Y3MtMiI6CiAgICAgICAgICAgIGNhc2UgInV0ZjE2bGUiOgogICAgICAgICAgICBjYXNlICJ1dGYtMTZsZSI6CiAgICAgICAgICAgICAgcmV0dXJuIGxlbiAqIDI7CiAgICAgICAgICAgIGNhc2UgImhleCI6CiAgICAgICAgICAgICAgcmV0dXJuIGxlbiA+Pj4gMTsKICAgICAgICAgICAgY2FzZSAiYmFzZTY0IjoKICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0VG9CeXRlcyhzdHJpbmcpLmxlbmd0aDsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICBpZiAobG93ZXJlZENhc2UpIHsKICAgICAgICAgICAgICAgIHJldHVybiBtdXN0TWF0Y2ggPyAtMSA6IHV0ZjhUb0J5dGVzKHN0cmluZykubGVuZ3RoOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBlbmNvZGluZyA9ICgiIiArIGVuY29kaW5nKS50b0xvd2VyQ2FzZSgpOwogICAgICAgICAgICAgIGxvd2VyZWRDYXNlID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgQnVmZmVyMTAuYnl0ZUxlbmd0aCA9IGJ5dGVMZW5ndGg7CiAgICAgIGZ1bmN0aW9uIHNsb3dUb1N0cmluZyhlbmNvZGluZywgc3RhcnQsIGVuZCkgewogICAgICAgIGxldCBsb3dlcmVkQ2FzZSA9IGZhbHNlOwogICAgICAgIGlmIChzdGFydCA9PT0gdm9pZCAwIHx8IHN0YXJ0IDwgMCkgewogICAgICAgICAgc3RhcnQgPSAwOwogICAgICAgIH0KICAgICAgICBpZiAoc3RhcnQgPiB0aGlzLmxlbmd0aCkgewogICAgICAgICAgcmV0dXJuICIiOwogICAgICAgIH0KICAgICAgICBpZiAoZW5kID09PSB2b2lkIDAgfHwgZW5kID4gdGhpcy5sZW5ndGgpIHsKICAgICAgICAgIGVuZCA9IHRoaXMubGVuZ3RoOwogICAgICAgIH0KICAgICAgICBpZiAoZW5kIDw9IDApIHsKICAgICAgICAgIHJldHVybiAiIjsKICAgICAgICB9CiAgICAgICAgZW5kID4+Pj0gMDsKICAgICAgICBzdGFydCA+Pj49IDA7CiAgICAgICAgaWYgKGVuZCA8PSBzdGFydCkgewogICAgICAgICAgcmV0dXJuICIiOwogICAgICAgIH0KICAgICAgICBpZiAoIWVuY29kaW5nKQogICAgICAgICAgZW5jb2RpbmcgPSAidXRmOCI7CiAgICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICAgIHN3aXRjaCAoZW5jb2RpbmcpIHsKICAgICAgICAgICAgY2FzZSAiaGV4IjoKICAgICAgICAgICAgICByZXR1cm4gaGV4U2xpY2UodGhpcywgc3RhcnQsIGVuZCk7CiAgICAgICAgICAgIGNhc2UgInV0ZjgiOgogICAgICAgICAgICBjYXNlICJ1dGYtOCI6CiAgICAgICAgICAgICAgcmV0dXJuIHV0ZjhTbGljZSh0aGlzLCBzdGFydCwgZW5kKTsKICAgICAgICAgICAgY2FzZSAiYXNjaWkiOgogICAgICAgICAgICAgIHJldHVybiBhc2NpaVNsaWNlKHRoaXMsIHN0YXJ0LCBlbmQpOwogICAgICAgICAgICBjYXNlICJsYXRpbjEiOgogICAgICAgICAgICBjYXNlICJiaW5hcnkiOgogICAgICAgICAgICAgIHJldHVybiBsYXRpbjFTbGljZSh0aGlzLCBzdGFydCwgZW5kKTsKICAgICAgICAgICAgY2FzZSAiYmFzZTY0IjoKICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0U2xpY2UodGhpcywgc3RhcnQsIGVuZCk7CiAgICAgICAgICAgIGNhc2UgInVjczIiOgogICAgICAgICAgICBjYXNlICJ1Y3MtMiI6CiAgICAgICAgICAgIGNhc2UgInV0ZjE2bGUiOgogICAgICAgICAgICBjYXNlICJ1dGYtMTZsZSI6CiAgICAgICAgICAgICAgcmV0dXJuIHV0ZjE2bGVTbGljZSh0aGlzLCBzdGFydCwgZW5kKTsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICBpZiAobG93ZXJlZENhc2UpCiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCJVbmtub3duIGVuY29kaW5nOiAiICsgZW5jb2RpbmcpOwogICAgICAgICAgICAgIGVuY29kaW5nID0gKGVuY29kaW5nICsgIiIpLnRvTG93ZXJDYXNlKCk7CiAgICAgICAgICAgICAgbG93ZXJlZENhc2UgPSB0cnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBCdWZmZXIxMC5wcm90b3R5cGUuX2lzQnVmZmVyID0gdHJ1ZTsKICAgICAgZnVuY3Rpb24gc3dhcChiLCBuLCBtKSB7CiAgICAgICAgY29uc3QgaSA9IGJbbl07CiAgICAgICAgYltuXSA9IGJbbV07CiAgICAgICAgYlttXSA9IGk7CiAgICAgIH0KICAgICAgQnVmZmVyMTAucHJvdG90eXBlLnN3YXAxNiA9IGZ1bmN0aW9uIHN3YXAxNigpIHsKICAgICAgICBjb25zdCBsZW4gPSB0aGlzLmxlbmd0aDsKICAgICAgICBpZiAobGVuICUgMiAhPT0gMCkgewogICAgICAgICAgdGhyb3cgbmV3IFJhbmdlRXJyb3IoIkJ1ZmZlciBzaXplIG11c3QgYmUgYSBtdWx0aXBsZSBvZiAxNi1iaXRzIik7CiAgICAgICAgfQogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGVuOyBpICs9IDIpIHsKICAgICAgICAgIHN3YXAodGhpcywgaSwgaSArIDEpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gdGhpczsKICAgICAgfTsKICAgICAgQnVmZmVyMTAucHJvdG90eXBlLnN3YXAzMiA9IGZ1bmN0aW9uIHN3YXAzMigpIHsKICAgICAgICBjb25zdCBsZW4gPSB0aGlzLmxlbmd0aDsKICAgICAgICBpZiAobGVuICUgNCAhPT0gMCkgewogICAgICAgICAgdGhyb3cgbmV3IFJhbmdlRXJyb3IoIkJ1ZmZlciBzaXplIG11c3QgYmUgYSBtdWx0aXBsZSBvZiAzMi1iaXRzIik7CiAgICAgICAgfQogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGVuOyBpICs9IDQpIHsKICAgICAgICAgIHN3YXAodGhpcywgaSwgaSArIDMpOwogICAgICAgICAgc3dhcCh0aGlzLCBpICsgMSwgaSArIDIpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gdGhpczsKICAgICAgfTsKICAgICAgQnVmZmVyMTAucHJvdG90eXBlLnN3YXA2NCA9IGZ1bmN0aW9uIHN3YXA2NCgpIHsKICAgICAgICBjb25zdCBsZW4gPSB0aGlzLmxlbmd0aDsKICAgICAgICBpZiAobGVuICUgOCAhPT0gMCkgewogICAgICAgICAgdGhyb3cgbmV3IFJhbmdlRXJyb3IoIkJ1ZmZlciBzaXplIG11c3QgYmUgYSBtdWx0aXBsZSBvZiA2NC1iaXRzIik7CiAgICAgICAgfQogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGVuOyBpICs9IDgpIHsKICAgICAgICAgIHN3YXAodGhpcywgaSwgaSArIDcpOwogICAgICAgICAgc3dhcCh0aGlzLCBpICsgMSwgaSArIDYpOwogICAgICAgICAgc3dhcCh0aGlzLCBpICsgMiwgaSArIDUpOwogICAgICAgICAgc3dhcCh0aGlzLCBpICsgMywgaSArIDQpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gdGhpczsKICAgICAgfTsKICAgICAgQnVmZmVyMTAucHJvdG90eXBlLnRvU3RyaW5nID0gZnVuY3Rpb24gdG9TdHJpbmcoKSB7CiAgICAgICAgY29uc3QgbGVuZ3RoID0gdGhpcy5sZW5ndGg7CiAgICAgICAgaWYgKGxlbmd0aCA9PT0gMCkKICAgICAgICAgIHJldHVybiAiIjsKICAgICAgICBpZiAoYXJndW1lbnRzLmxlbmd0aCA9PT0gMCkKICAgICAgICAgIHJldHVybiB1dGY4U2xpY2UodGhpcywgMCwgbGVuZ3RoKTsKICAgICAgICByZXR1cm4gc2xvd1RvU3RyaW5nLmFwcGx5KHRoaXMsIGFyZ3VtZW50cyk7CiAgICAgIH07CiAgICAgIEJ1ZmZlcjEwLnByb3RvdHlwZS50b0xvY2FsZVN0cmluZyA9IEJ1ZmZlcjEwLnByb3RvdHlwZS50b1N0cmluZzsKICAgICAgQnVmZmVyMTAucHJvdG90eXBlLmVxdWFscyA9IGZ1bmN0aW9uIGVxdWFscyhiKSB7CiA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oKTsKICAgICAgICB9CiAgICAgICAgaWYgKCFCdWZmZXIxMC5pc0J1ZmZlcih0YXJnZXQpKSB7CiAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCdUaGUgInRhcmdldCIgYXJndW1lbnQgbXVzdCBiZSBvbmUgb2YgdHlwZSBCdWZmZXIgb3IgVWludDhBcnJheS4gUmVjZWl2ZWQgdHlwZSAnICsgdHlwZW9mIHRhcmdldCk7CiAgICAgICAgfQogICAgICAgIGlmIChzdGFydCA9PT0gdm9pZCAwKSB7CiAgICAgICAgICBzdGFydCA9IDA7CiAgICAgICAgfQogICAgICAgIGlmIChlbmQgPT09IHZvaWQgMCkgewogICAgICAgICAgZW5kID0gdGFyZ2V0ID8gdGFyZ2V0Lmxlbmd0aCA6IDA7CiAgICAgICAgfQogICAgICAgIGlmICh0aGlzU3RhcnQgPT09IHZvaWQgMCkgewogICAgICAgICAgdGhpc1N0YXJ0ID0gMDsKICAgICAgICB9CiAgICAgICAgaWYgKHRoaXNFbmQgPT09IHZvaWQgMCkgewogICAgICAgICAgdGhpc0VuZCA9IHRoaXMubGVuZ3RoOwogICAgICAgIH0KICAgICAgICBpZiAoc3RhcnQgPCAwIHx8IGVuZCA+IHRhcmdldC5sZW5ndGggfHwgdGhpc1N0YXJ0IDwgMCB8fCB0aGlzRW5kID4gdGhpcy5sZW5ndGgpIHsKICAgICAgICAgIHRocm93IG5ldyBSYW5nZUVycm9yKCJvdXQgb2YgcmFuZ2UgaW5kZXgiKTsKICAgICAgICB9CiAgICAgICAgaWYgKHRoaXNTdGFydCA+PSB0aGlzRW5kICYmIHN0YXJ0ID49IGVuZCkgewogICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgfQogICAgICAgIGlmICh0aGlzU3RhcnQgPj0gdGhpc0VuZCkgewogICAgICAgICAgcmV0dXJuIC0xOwogICAgICAgIH0KICAgICAgICBpZiAoc3RhcnQgPj0gZW5kKSB7CiAgICAgICAgICByZXR1cm4gMTsKICAgICAgICB9CiAgICAgICAgc3RhcnQgPj4+PSAwOwogICAgICAgIGVuZCA+Pj49IDA7CiAgICAgICAgdGhpc1N0YXJ0ID4+Pj0gMDsKICAgICAgICB0aGlzRW5kID4+Pj0gMDsKICAgICAgICBpZiAodGhpcyA9PT0gdGFyZ2V0KQogICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgbGV0IHggPSB0aGlzRW5kIC0gdGhpc1N0YXJ0OwogICAgICAgIGxldCB5ID0gZW5kIC0gc3RhcnQ7CiAgICAgICAgY29uc3QgbGVuID0gTWF0aC5taW4oeCwgeSk7CiAgICAgICAgY29uc3QgdGhpc0NvcHkgPSB0aGlzLnNsaWNlKHRoaXNTdGFydCwgdGhpc0VuZCk7CiAgICAgICAgY29uc3QgdGFyZ2V0Q29weSA9IHRhcmdldC5zbGljZShzdGFydCwgZW5kKTsKICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbjsgKytpKSB7CiAgICAgICAgICBpZiAodGhpc0NvcHlbaV0gIT09IHRhcmdldENvcHlbaV0pIHsKICAgICAgICAgICAgeCA9IHRoaXNDb3B5W2ldOwogICAgICAgICAgICB5ID0gdGFyZ2V0Q29weVtpXTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmICh4IDwgeSkKICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICBpZiAoeSA8IHgpCiAgICAgICAgICByZXR1cm4gMTsKICAgICAgICByZXR1cm4gMDsKICAgICAgfTsKICAgICAgZnVuY3Rpb24gYmlkaXJlY3Rpb25hbEluZGV4T2YoYnVmZmVyLCB2YWwsIGJ5dGVPZmZzZXQsIGVuY29kaW5nLCBkaXIpIHsKICAgICAgICBpZiAoYnVmZmVyLmxlbmd0aCA9PT0gMCkKICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICBpZiAodHlwZW9mIGJ5dGVPZmZzZXQgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICBlbmNvZGluZyA9IGJ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ICAgICAgICAgaWYgKHZhbC5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgcmV0dXJuIC0xOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIGFycmF5SW5kZXhPZihidWZmZXIsIHZhbCwgYnl0ZU9mZnNldCwgZW5jb2RpbmcsIGRpcik7CiAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgdmFsID09PSAibnVtYmVyIikgewogICAgICAgICAgdmFsID0gdmFsICYgMjU1OwogICAgICAgICAgaWYgKHR5cGVvZiBVaW50OEFycmF5LnByb3RvdHlwZS5pbmRleE9mID09PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgICAgIGlmIChkaXIpIHsKICAgICAgICAgICAgICByZXR1cm4gVWludDhBcnJheS5wcm90b3R5cGUuaW5kZXhPZi5jYWxsKGJ1ZmZlciwgdmFsLCBieXRlT2Zmc2V0KTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICByZXR1cm4gVWludDhBcnJheS5wcm90b3R5cGUubGFzdEluZGV4T2YuY2FsbChidWZmZXIsIHZhbCwgYnl0ZU9mZnNldCk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBhcnJheUluZGV4T2YoYnVmZmVyLCBbdmFsXSwgYnl0ZU9mZnNldCwgZW5jb2RpbmcsIGRpcik7CiAgICAgICAgfQogICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoInZhbCBtdXN0IGJlIHN0cmluZywgbnVtYmVyIG9yIEJ1ZmZlciIpOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGFycmF5SW5kZXhPZihhcnIsIHZhbCwgYnl0ZU9mZnNldCwgZW5jb2RpbmcsIGRpcikgewogICAgICAgIGxldCBpbmRleFNpemUgPSAxOwogICAgICAgIGxldCBhcnJMZW5ndGggPSBhcnIubGVuZ3RoOwogICAgICAgIGxldCB2YWxMZW5ndGggPSB2YWwubGVuZ3RoOwogICAgICAgIGlmIChlbmNvZGluZyAhPT0gdm9pZCAwKSB7CiAgICAgICAgICBlbmNvZGluZyA9IFN0cmluZyhlbmNvZGluZykudG9Mb3dlckNhc2UoKTsKICAgICAgICAgIGlmIChlbmNvZGluZyA9PT0gInVjczIiIHx8IGVuY29kaW5nID09PSAidWNzLTIiIHx8IGVuY29kaW5nID09PSAidXRmMTZsZSIgfHwgZW5jb2RpbmcgPT09ICJ1dGYtMTZsZSIpIHsKICAgICAgICAgICAgaWYgKGFyci5sZW5ndGggPCAyIHx8IHZhbC5sZW5ndGggPCAyKSB7CiAgICAgICAgICAgICAgcmV0dXJuIC0xOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGluZGV4U2l6ZSA9IDI7CiAgICAgICAgICAgIGFyckxlbmd0aCAvPSAyOwogICAgICAgICAgICB2YWxMZW5ndGggLz0gMjsKICAgICAgICAgICAgYnl0ZU9mZnNldCAvPSAyOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBmdW5jdGlvbiByZWFkKGJ1ZiwgaTIpIHsKICAgICAgICAgIGlmIChpbmRleFNpemUgPT09IDEpIHsKICAgICAgICAgICAgcmV0dXJuIGJ1ZltpMl07CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICByZXR1cm4gYnVmLnJlYWRVSW50MTZCRShpMiAqIGluZGV4U2l6ZSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGxldCBpOwogICAgICAgIGlmIChkaXIpIHsKICAgICAgICAgIGxldCBmb3VuZEluZGV4ID0gLTE7CiAgICAgICAgICBmb3IgKGkgPSBieXRlT2Zmc2V0OyBpIDwgYXJyTGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgaWYgKHJlYWQoYXJyLCBpKSA9PT0gcmVhZCh2YWwsIGZvdW5kSW5kZXggPT09IC0xID8gMCA6IGkgLSBmb3VuZEluZGV4KSkgewogICAgICAgICAgICAgIGlmIChmb3VuZEluZGV4ID09PSAtMSkKICAgICAgICAgICAgICAgIGZvdW5kSW5kZXggPSBpOwogICAgICAgICAgICAgIGlmIChpIC0gZm91bmRJbmRleCArIDEgPT09IHZhbExlbmd0aCkKICAgICAgICAgICAgICAgIHJldHVybiBmb3VuZEluZGV4ICogaW5kZXhTaXplOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGlmIChmb3VuZEluZGV4ICE9PSAtMSkKICAgICAgICAgICAgICAgIGkgLT0gaSAtIGZvdW5kSW5kZXg7CiAgICAgICAgICAgICAgZm91bmRJbmRleCA9IC0xOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGlmIChieXRlT2Zmc2V0ICsgdmFsTGVuZ3RoID4gYXJyTGVuZ3RoKQogICAgICAgICAgICBieXRlT2Zmc2V0ID0gYXJyTGVuZ3RoIC0gdmFsTGVuZ3RoOwogICAgICAgICAgZm9yIChpID0gYnl0ZU9mZnNldDsgaSA+PSAwOyBpLS0pIHsKICAgICAgICAgICAgbGV0IGZvdW5kID0gdHJ1ZTsKICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCB2YWxMZW5ndGg7IGorKykgewogICAgICAgICAgICAgIGlmIChyZWFkKGFyciwgaSArIGopICE9PSByZWFkKHZhbCwgaikpIHsKICAgICAgICAgICAgICAgIGZvdW5kID0gZmFsc2U7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGZvdW5kKQogICAgICAgICAgICAgIHJldHVybiBpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gLTE7CiAgICAgIH0KICAgICAgQnVmZmVyMTAucHJvdG90eXBlLmluY2x1ZGVzID0gZnVuY3Rpb24gaW5jbHVkZXModmFsLCBieXRlT2Zmc2V0LCBlbmNvZGluZykgewogICAgICAgIHJldHVybiB0aGlzLmluZGV4T2YodmFsLCBieXRlT2Zmc2V0LCBlbmNvZGluZykgIT09IC0xOwogICAgICB9OwogICAgICBCdWZmZXIxMC5wcm90b3R5cGUuaW5kZXhPZiA9IGZ1bmN0aW9uIGluZGV4T2YodmFsLCBieXRlT2Zmc2V0LCBlbmNvZGluZykgewogICAgICAgIHJldHVybiBiaWRpcmVjdGlvbmFsSW5kZXhPZih0aGlzLCB2YWwsIGJ5dGVPZmZzZXQsIGVuY29kaW5nLCB0cnVlKTsKICAgICAgfTsKICAgICAgQnVmZmVyMTAucHJvdG90eXBlLmxhc3RJbmRleE9mID0gZnVuY3Rpb24gbGFzdEluZGV4T2YodmFsLCBieXRlT2Zmc2V0LCBlbmNvZGluZykgewogICAgICAgIHJldHVybiBiaWRpcmVjdGlvbmFsSW5kZXhPZih0aGlzLCB2YWwsIGJ5dGVPZmZzZXQsIGVuY29kaW5nLCBmYWxzZSk7CiAgICAgIH07CiAgICAgIGZ1bmN0aW9uIGhleFdyaXRlKGJ1Ziwgc3RyaW5nLCBvZmZzZXQsIGxlbmd0aCkgewogICAgICAgIG9mZnNldCA9IE51bWJlcihvZmZzZXQpIHx8IDA7CiAgICAgICAgY29uc3QgcmVtYWluaW5nID0gYnVmLmxlbmd0aCAtIG9mZnNldDsKICAgICAgICBpZiAoIWxlbmd0aCkgewogICAgICAgICAgbGVuZ3RoID0gcmVtYWluaW5nOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBsZW5ndGggPSBOdW1iZXIobGVuZ3RoKTsKICAgICAgICAgIGlmIChsZW5ndGggPiByZW1haW5pbmcpIHsKICAgICAgICAgICAgbGVuZ3RoID0gcmVtYWluaW5nOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjb25zdCBzdHJMZW4gPSBzdHJpbmcubGVuZ3RoOwogICAgICAgIGlmIChsZW5ndGggPiBzdHJMZW4gLyAyKSB7CiAgICAgICAgICBsZW5ndGggPSBzdHJMZW4gLyAyOwogICAgICAgIH0KICAgICAgICBsZXQgaTsKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbGVuZ3RoOyArK2kpIHsKICAgICAgICAgI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mcsIG9mZnNldCwgbGVuZ3RoLCBlbmNvZGluZykgewogICAgICAgIGlmIChvZmZzZXQgPT09IHZvaWQgMCkgewogICAgICAgICAgZW5jb2RpbmcgPSAidXRmOCI7CiAgICAgICAgICBsZW5ndGggPSB0aGlzLmxlbmd0aDsKICAgICAgICAgIG9mZnNldCA9IDA7CiAgICAgICAgfSBlbHNlIGlmIChsZW5ndGggPT09IHZvaWQgMCAmJiB0eXBlb2Ygb2Zmc2V0ID09PSAic3RyaW5nIikgewogICAgICAgICAgZW5jb2RpbmcgPSBvZmZzZXQ7CiAgICAgICAgICBsZW5ndGggPSB0aGlzLmxlbmd0aDsKICAgICAgICAgIG9mZnNldCA9IDA7CiAgICAgICAgfSBlbHNlIGlmIChpc0Zpbml0ZShvZmZzZXQpKSB7CiAgICAgICAgICBvZmZzZXQgPSBvZmZzZXQgPj4+IDA7CiAgICAgICAgICBpZiAoaXNGaW5pdGUobGVuZ3RoKSkgewogICAgICAgICAgICBsZW5ndGggPSBsZW5ndGggPj4+IDA7CiAgICAgICAgICAgIGlmIChlbmNvZGluZyA9PT0gdm9pZCAwKQogICAgICAgICAgICAgIGVuY29kaW5nID0gInV0ZjgiOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgZW5jb2RpbmcgPSBsZW5ndGg7CiAgICAgICAgICAgIGxlbmd0aCA9IHZvaWQgMDsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJCdWZmZXIud3JpdGUoc3RyaW5nLCBlbmNvZGluZywgb2Zmc2V0WywgbGVuZ3RoXSkgaXMgbm8gbG9uZ2VyIHN1cHBvcnRlZCIpOwogICAgICAgIH0KICAgICAgICBjb25zdCByZW1haW5pbmcgPSB0aGlzLmxlbmd0aCAtIG9mZnNldDsKICAgICAgICBpZiAobGVuZ3RoID09PSB2b2lkIDAgfHwgbGVuZ3RoID4gcmVtYWluaW5nKQogICAgICAgICAgbGVuZ3RoID0gcmVtYWluaW5nOwogICAgICAgIGlmIChzdHJpbmcubGVuZ3RoID4gMCAmJiAobGVuZ3RoIDwgMCB8fCBvZmZzZXQgPCAwKSB8fCBvZmZzZXQgPiB0aGlzLmxlbmd0aCkgewogICAgICAgICAgdGhyb3cgbmV3IFJhbmdlRXJyb3IoIkF0dGVtcHQgdG8gd3JpdGUgb3V0c2lkZSBidWZmZXIgYm91bmRzIik7CiAgICAgICAgfQogICAgICAgIGlmICghZW5jb2RpbmcpCiAgICAgICAgICBlbmNvZGluZyA9ICJ1dGY4IjsKICAgICAgICBsZXQgbG93ZXJlZENhc2UgPSBmYWxzZTsKICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgIHN3aXRjaCAoZW5jb2RpbmcpIHsKICAgICAgICAgICAgY2FzZSAiaGV4IjoKICAgICAgICAgICAgICByZXR1cm4gaGV4V3JpdGUodGhpcywgc3RyaW5nLCBvZmZzZXQsIGxlbmd0aCk7CiAgICAgICAgICAgIGNhc2UgInV0ZjgiOgogICAgICAgICAgICBjYXNlICJ1dGYtOCI6CiAgICAgICAgICAgICAgcmV0dXJuIHV0ZjhXcml0ZSh0aGlzLCBzdHJpbmcsIG9mZnNldCwgbGVuZ3RoKTsKICAgICAgICAgICAgY2FzZSAiYXNjaWkiOgogICAgICAgICAgICBjYXNlICJsYXRpbjEiOgogICAgICAgICAgICBjYXNlICJiaW5hcnkiOgogICAgICAgICAgICAgIHJldHVybiBhc2NpaVdyaXRlKHRoaXMsIHN0cmluZywgb2Zmc2V0LCBsZW5ndGgpOwogICAgICAgICAgICBjYXNlICJiYXNlNjQiOgogICAgICAgICAgICAgIHJldHVybiBiYXNlNjRXcml0ZSh0aGlzLCBzdHJpbmcsIG9mZnNldCwgbGVuZ3RoKTsKICAgICAgICAgICAgY2FzZSAidWNzMiI6CiAgICAgICAgICAgIGNhc2UgInVjcy0yIjoKICAgICAgICAgICAgY2FzZSAidXRmMTZsZSI6CiAgICAgICAgICAgIGNhc2UgInV0Zi0xNmxlIjoKICAgICAgICAgICAgICByZXR1cm4gdWNzMldyaXRlKHRoaXMsIHN0cmluZywgb2Zmc2V0LCBsZW5ndGgpOwogICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgIGlmIChsb3dlcmVkQ2FzZSkKICAgICAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoIlVua25vd24gZW5jb2Rpbmc6ICIgKyBlbmNvZGluZyk7CiAgICAgICAgICAgICAgZW5jb2RpbmcgPSAoIiIgKyBlbmNvZGluZykudG9Mb3dlckNhc2UoKTsKICAgICAgICAgICAgICBsb3dlcmVkQ2FzZSA9IHRydWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9OwogICAgICBCdWZmZXIxMC5wcm90b3R5cGUudG9KU09OID0gZnVuY3Rpb24gdG9KU09OKCkgewogICAgICAgIHJldHVybiB7CiAgICAgICAgICB0eXBlOiAiQnVmZmVyIiwKICAgICAgICAgIGRhdGE6IEFycmF5LnByb3RvdHlwZS5zbGljZS5jYWxsKHRoaXMuX2FyciB8fCB0aGlzLCAwKQogICAgICAgIH07CiAgICAgIH07CiAgICAgIGZ1bmN0aW9uIGJhc2U2NFNsaWNlKGJ1Ziwgc3RhcnQsIGVuZCkgewogICAgICAgIGlmIChzdGFydCA9PT0gMCAmJiBlbmQgPT09IGJ1Zi5sZW5ndGgpIHsKICAgICAgICAgIHJldHVybiBiYXNlNjQuZnJvbUJ5dGVBcnJheShidWYpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICByZXR1cm4gYmFzZTY0LmZyb21CeXRlQXJyYXkoYnVmLnNsaWNlKHN0YXJ0LCBlbmQpKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgZnVuY3Rpb24gdXRmOFNsaWNlKGJ1Ziwgc3RhcnQsIGVuZCkgewogICAgICAgIGVuZCA9IE1hdGgubWluKGJ1Zi5sZW5ndGgsIGVuZCk7CiAgICAgICAgY29uc3QgcmVzID0gW107CiAgICAgICAgbGV0IGkgPSBzdGFydDsKICAgICAgICB3aGlsZSAoaSA8IGVuZCkgewogICAgICAgICAgY29uc3QgZmlyc3RCeXRlID0gYnVmW2ldOwogICAgICAgICAgbGV0IGNvZGVQb2ludCA9IG51bGw7CiAgICAgICAgICBsZXQgYnl0ZXNQZXJTZXF1ZW5jZSA9IGZpcnN0Qnl0ZSA+IDIzOSA/IDQgOiBmaXJzdEJ5dGUgPiAyMjMgPyAzIDogZmlyc3RCeXRlID4gMTkxID8gMiA6IDE7CiAgICAgICAgICBpZiAoaSArIGJ5dGVzUGVyU2VxdWVuY2UgPD0gZW5kKSB7CiAgICAgICAgICAgIGxldCBzZWNvbmRCeXRlLCB0aGlyZEJ5dGUsIGZvdXJ0aEJ5dGUsIHRlbXBDb2RlUG9pbnQ7CiAgICAgICAgICAgIHN3aXRjaCAoYnl0ZXNQZXJTZXF1ZW5jZSkgewogICAgICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgICAgIGlmIChmaXJzdEJ5dGUgPCAxMjgpIHsKICAgICAgICAgICAgICAgICAgY29kZVBvaW50ID0gZmlyc3RCeXRlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgc2Vjb25kQnl0ZSA9IGJ1ZltpICsgMV07CiAgICAgICAgICAgICAgICBpZiAoKHNlY29uZEJ5dGUgJiAxOTIpID09PSAxMjgpIHsKICAgICAgICAgICAgICAgICAgdGVtcENvZGVQb2ludCA9IChmaXJzdEJ5dGUgJiAzMSkgPDwgNiB8IHNlY29uZEJ5dGUgJiA2MzsKICAgICAgICAgICAgICAgICAgaWYgKHRlbXBDb2RlUG9pbnQgPiAxMjcpIHsKICAgICAgICAgICAgICAgICAgICBjb2RlUG9pbnQgPSB0ZW1wQ29kZVBvaW50OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjY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dGUgJiA2MzsKICAgICAgICAgICAgICAgICAgaWYgKHRlbXBDb2RlUG9pbnQgPiA2NTUzNSAmJiB0ZW1wQ29kZVBvaW50IDwgMTExNDExMikgewogICAgICAgICAgICAgICAgICAgIGNvZGVQb2ludCA9IHRlbXBDb2RlUG9pbnQ7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKGNvZGVQb2ludCA9PT0gbnVsbCkgewogICAgICAgICAgICBjb2RlUG9pbnQgPSA2NTUzMzsKICAgICAgICAgICAgYnl0ZXNQZXJTZXF1ZW5jZSA9IDE7CiAgICAgICAgICB9IGVsc2UgaWYgKGNvZGVQb2ludCA+IDY1NTM1KSB7CiAgICAgICAgICAgIGNvZGVQb2ludCAtPSA2NTUzNjsKICAgICAgICAgICAgcmVzLnB1c2goY29kZVBvaW50ID4+PiAxMCAmIDEwMjMgfCA1NTI5Nik7CiAgICAgICAgICAgIGNvZGVQb2ludCA9IDU2MzIwIHwgY29kZVBvaW50ICYgMTAyMzsKICAgICAgICAgIH0KICAgICAgICAgIHJlcy5wdXNoKGNvZGVQb2ludCk7CiAgICAgICAgICBpICs9IGJ5dGVzUGVyU2VxdWVuY2U7CiAgICAgICAgfQogICAgICAgIHJldHVybiBkZWNvZGVDb2RlUG9pbnRzQXJyYXkocmVzKTsKICAgICAgfQogICAgICB2YXIgTUFYX0FSR1VNRU5UU19MRU5HVEggPSA0MDk2OwogICAgICBmdW5jdGlvbiBkZWNvZGVDb2RlUG9pbnRzQXJyYXkoY29kZVBvaW50cykgewogICAgICAgIGNvbnN0IGxlbiA9IGNvZGVQb2ludHMubGVuZ3RoOwogICAgICAgIGlmIChsZW4gPD0gTUFYX0FSR1VNRU5UU19MRU5HVEgpIHsKICAgICAgICAgIHJldHVybiBTdHJpbmcuZnJvbUNoYXJDb2RlLmFwcGx5KFN0cmluZywgY29kZVBvaW50cyk7CiAgICAgICAgfQogICAgICAgIGxldCByZXMgPSAiIjsKICAgICAgICBsZXQgaSA9IDA7CiAgICAgICAgd2hpbGUgKGkgPCBsZW4pIHsKICAgICAgICAgIHJlcyArPSBTdHJpbmcuZnJvbUNoYXJDb2RlLmFwcGx5KFN0cmluZywgY29kZVBvaW50cy5zbGljZShpLCBpICs9IE1BWF9BUkdVTUVOVFNfTEVOR1RIKSk7CiAgICAgICAgfQogICAgICAgIHJldHVybiByZXM7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gYXNjaWlTbGljZShidWYsIHN0YXJ0LCBlbmQpIHsKICAgICAgICBsZXQgcmV0ID0gIiI7CiAgICAgICAgZW5kID0gTWF0aC5taW4oYnVmLmxlbmd0aCwgZW5kKTsKICAgICAgICBmb3IgKGxldCBpID0gc3RhcnQ7IGkgPCBlbmQ7ICsraSkgewogICAgICAgICAgcmV0ICs9IFN0cmluZy5mcm9tQ2hhckNvZGUoYnVmW2ldICYgMTI3KTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHJldDsKICAgICAgfQogICAgICBmdW5jdGlvbiBsYXRpbjFTbGljZShidWYsIHN0YXJ0LCBlbmQpIHsKICAgICAgICBsZXQgcmV0ID0gIiI7CiAgICAgICAgZW5kID0gTWF0aC5taW4oYnVmLmxlbmd0aCwgZW5kKTsKICAgICAgICBmb3IgKGxldCBpID0gc3RhcnQ7IGkgPCBlbmQ7ICsraSkgewogICAgICAgICAgcmV0ICs9IFN0cmluZy5mcm9tQ2hhckNvZGUoYnVmW2ldKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHJldDsKICAgICAgfQogICAgICBmdW5jdGlvbiBoZXhTbGljZShidWYsIHN0YXJ0LCBlbmQpIHsKICAgICAgICBjb25zdCBsZW4gPSBidWYubGVuZ3RoOwogICAgICAgIGlmICghc3RhcnQgfHwgc3RhcnQgPCAwKQogICAgICAgICAgc3RhcnQgPSAwOwogICAgICAgIGlmICghZW5kIHx8IGVuZCA8IDAgfHwgZW5kID4gbGVuKQogICAgICAgICAgZW5kID0gbGVuOwogICAgICAgIGxldCBvdXQgPSAiIjsKICAgICAgICBmb3IgKGxldCBpID0gc3RhcnQ7IGkgPCBlbmQ7ICsraSkgewogICAgICAgICAgb3V0ICs9IGhleFNsaWNlTG9va3VwVGFibGVbYnVmW2ldXTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIG91dDsKICAgICAgfQogICAgICBmdW5jdGlvbiB1dGYxNmxlU2xpY2UoYnVmLCBzdGFydCwgZW5kKSB7CiAgICAgICAgY29uc3QgYnl0ZXMgPSBidWYuc2xpY2Uoc3RhcnQsIGVuZCk7CiAgICAgICAgbGV0IHJlcyA9ICIiOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYnl0ZXMubGVuZ3RoIC0gMTsgaSArPSAyKSB7CiAgICAgICAgICByZXMgKz0gU3RyaW5nLmZyb21DaGFyQ29kZShieXRlc1tpXSArIGJ5dGVzW2kgKyAxXSAqIDI1Nik7CiAgICAgICAgfQogICAgICAgIHJldHVybiByZXM7CiAgICAgIH0KICAgICAgQnVmZmVyMTAucHJvdG90eXBlLnNsaWNlID0gZnVuY3Rpb24gc2xpY2Uoc3RhcnQsIGVuZCkgewogICAgICAgIGNvbnN0IGxlbiA9IHRoaXMubGVuZ3RoOwogICAgICAgIHN0YXJ0ID0gfn5zdGFydDsKICAgICAgICBlbmQgPSBlbmQgPT09IHZvaWQgMCA/IGxlbiA6IH5+ZW5kOwogICAgICAgIGlmIChzdGFydCA8IDApIHsKICAgICAgICAgIHN0YXJ0ICs9IGxlbjsKICAgICAgICAgIGlmIChzdGFydCA8IDApCiAgICAgICAgICAgIHN0YXJ0ID0gMDsKICAgICAgICB9IGVsc2UgaWYgKHN0YXJ0ID4gbGVuKSB7CiAgICAgICAgICBzdGFydCA9IGxlbjsKICAgICAgICB9CiAgICAgICAgaWYgKGVuZCA8IDApIHsKICAgICAgICAgIGVuZCArPSBsZW47CiAgICAgICAgICBpZiAoZW5kIDwgMCkKICAgICAgICA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8IGVuZCAtIHN0YXJ0KSB7CiAgICAgICAgICBlbmQgPSB0YXJnZXQubGVuZ3RoIC0gdGFyZ2V0U3RhcnQgKyBzdGFydDsKICAgICAgICB9CiAgICAgICAgY29uc3QgbGVuID0gZW5kIC0gc3RhcnQ7CiAgICAgICAgaWYgKHRoaXMgPT09IHRhcmdldCAmJiB0eXBlb2YgVWludDhBcnJheS5wcm90b3R5cGUuY29weVdpdGhpbiA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgdGhpcy5jb3B5V2l0aGluKHRhcmdldFN0YXJ0LCBzdGFydCwgZW5kKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgVWludDhBcnJheS5wcm90b3R5cGUuc2V0LmNhbGwodGFyZ2V0LCB0aGlzLnN1YmFycmF5KHN0YXJ0LCBlbmQpLCB0YXJnZXRTdGFydCk7CiAgICAgICAgfQogICAgICAgIHJldHVybiBsZW47CiAgICAgIH07CiAgICAgIEJ1ZmZlcjEwLnByb3RvdHlwZS5maWxsID0gZnVuY3Rpb24gZmlsbCh2YWwsIHN0YXJ0LCBlbmQsIGVuY29kaW5nKSB7CiAgICAgICAgaWYgKHR5cGVvZiB2YWwgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICBpZiAodHlwZW9mIHN0YXJ0ID09PSAic3RyaW5nIikgewogICAgICAgICAgICBlbmNvZGluZyA9IHN0YXJ0OwogICAgICAgICAgICBzdGFydCA9IDA7CiAgICAgICAgICAgIGVuZCA9IHRoaXMubGVuZ3RoOwogICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgZW5kID09PSAic3RyaW5nIikgewogICAgICAgICAgICBlbmNvZGluZyA9IGVuZDsKICAgICAgICAgICAgZW5kID0gdGhpcy5sZW5ndGg7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoZW5jb2RpbmcgIT09IHZvaWQgMCAmJiB0eXBlb2YgZW5jb2RpbmcgIT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoImVuY29kaW5nIG11c3QgYmUgYSBzdHJpbmciKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh0eXBlb2YgZW5jb2RpbmcgPT09ICJzdHJpbmciICYmICFCdWZmZXIxMC5pc0VuY29kaW5nKGVuY29kaW5nKSkgewogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCJVbmtub3duIGVuY29kaW5nOiAiICsgZW5jb2RpbmcpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHZhbC5sZW5ndGggPT09IDEpIHsKICAgICAgICAgICAgY29uc3QgY29kZSA9IHZhbC5jaGFyQ29kZUF0KDApOwogICAgICAgICAgICBpZiAoZW5jb2RpbmcgPT09ICJ1dGY4IiAmJiBjb2RlIDwgMTI4IHx8IGVuY29kaW5nID09PSAibGF0aW4xIikgewogICAgICAgICAgICAgIHZhbCA9IGNvZGU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiB2YWwgPT09ICJudW1iZXIiKSB7CiAgICAgICAgICB2YWwgPSB2YWwgJiAyNTU7CiAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgdmFsID09PSAiYm9vbGVhbiIpIHsKICAgICAgICAgIHZhbCA9IE51bWJlcih2YWwpOwogICAgICAgIH0KICAgICAgICBpZiAoc3RhcnQgPCAwIHx8IHRoaXMubGVuZ3RoIDwgc3RhcnQgfHwgdGhpcy5sZW5ndGggPCBlbmQpIHsKICAgICAgICAgIHRocm93IG5ldyBSYW5nZUVycm9yKCJPdXQgb2YgcmFuZ2UgaW5kZXgiKTsKICAgICAgICB9CiAgICAgICAgaWYgKGVuZCA8PSBzdGFydCkgewogICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgfQogICAgICAgIHN0YXJ0ID0gc3RhcnQgPj4+IDA7CiAgICAgICAgZW5kID0gZW5kID09PSB2b2lkIDAgPyB0aGlzLmxlbmd0aCA6IGVuZCA+Pj4gMDsKICAgICAgICBpZiAoIXZhbCkKICAgICAgICAgIHZhbCA9IDA7CiAgICAgICAgbGV0IGk7CiAgICAgICAgaWYgKHR5cGVvZiB2YWwgPT09ICJudW1iZXIiKSB7CiAgICAgICAgICBmb3IgKGkgPSBzdGFydDsgaSA8IGVuZDsgKytpKSB7CiAgICAgICAgICAgIHRoaXNbaV0gPSB2YWw7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGNvbnN0IGJ5dGVzID0gQnVmZmVyMTAuaXNCdWZmZXIodmFsKSA/IHZhbCA6IEJ1ZmZlcjEwLmZyb20odmFsLCBlbmNvZGluZyk7CiAgICAgICAgICBjb25zdCBsZW4gPSBieXRlcy5sZW5ndGg7CiAgICAgICAgICBpZiAobGVuID09PSAwKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoJ1RoZSB2YWx1ZSAiJyArIHZhbCArICciIGlzIGludmFsaWQgZm9yIGFyZ3VtZW50ICJ2YWx1ZSInKTsKICAgICAgICAgIH0KICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBlbmQgLSBzdGFydDsgKytpKSB7CiAgICAgICAgICAgIHRoaXNbaSArIHN0YXJ0XSA9IGJ5dGVzW2kgJSBsZW5dOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gdGhpczsKICAgICAgfTsKICAgICAgdmFyIGVycm9ycyA9IHt9OwogICAgICBmdW5jdGlvbiBFKHN5bSwgZ2V0TWVzc2FnZSwgQmFzZSkgewogICAgICAgIGVycm9yc1tzeW1dID0gY2xhc3MgTm9kZUVycm9yIGV4dGVuZHMgQmFzZSB7CiAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgc3VwZXIoKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJtZXNzYWdlIiwgewogICAgICAgICAgICAgIHZhbHVlOiBnZXRNZXNzYWdlLmFwcGx5KHRoaXMsIGFyZ3VtZW50cyksCiAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICB0aGlzLm5hbWUgPSBgJHt0aGlzLm5hbWV9IFske3N5bX1dYDsKICAgICAgICAgICAgdGhpcy5zdGFjazsKICAgICAgICAgICAgZGVsZXRlIHRoaXMubmFtZTsKICAgICAgICAgIH0KICAgICAgICAgIGdldCBjb2RlKCkgewogICAgICAgICAgICByZXR1cm4gc3ltOwogICAgICAgICAgfQogICAgICAgICAgc2V0IGNvZGUodmFsdWUpIHsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsICJjb2RlIiwgewogICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgICAgdG9TdHJpbmcoKSB7CiAgICAgICAgICAgIHJldHVybiBgJHt0aGlzLm5hbWV9IFske3N5bX1dOiAke3RoaXMubWVzc2FnZX1gOwogICAgICAgICAgfQogICAgICAgIH07CiAgICAgIH0KICAgICAgRSgiRVJSX0JVRkZFUl9PVVRfT0ZfQk9VTkRTIiwgZnVuY3Rpb24obmFtZSkgewogICAgICAgIGlmIChuYW1lKSB7CiAgICAgICAgICByZXR1cm4gYCR7bmFtZX0gaXMgb3V0c2lkZSBvZiBidWZmZXIgYm91bmRzYDsKICAgICAgICB9CiAgICAgICAgcmV0dXJuICJBdHRlbXB0IHRvIGFjY2VzcyBtZW1vcnkgb3V0c2lkZSBidWZmZXIgYm91bmRzIjsKICAgICAgfSwgUmFuZ2VFcnJvcik7CiAgICAgIEUoIkVSUl9JTlZBTElEX0FSR19UWVBFIiwgZnVuY3Rpb24obmFtZS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SkgKiA4fSR7bn1gOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHJhbmdlID0gYD49IC0oMiR7bn0gKiogJHsoYnl0ZUxlbmd0aDIgKyAxKSAqIDggLSAxfSR7bn0pIGFuZCA8IDIgKiogJHsoYnl0ZUxlbmd0aDIgKyAxKSAqIDggLSAxfSR7bn1gOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICByYW5nZSA9IGA+PSAke21pbn0ke259IGFuZCA8PSAke21heH0ke259YDsKICAgICAgICAgIH0KICAgICAgICAgIHRocm93IG5ldyBlcnJvcnMuRVJSX09VVF9PRl9SQU5HRSgidmFsdWUiLCByYW5nZSwgdmFsdWUpOwogICAgICAgIH0KICAgICAgICBjaGVja0JvdW5kcyhidWYsIG9mZnNldCwgYnl0ZUxlbmd0aDIpOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIHZhbGlkYXRlTnVtYmVyKHZhbHVlLCBuYW1lKSB7CiAgICAgICAgaWYgKHR5cGVvZiB2YWx1ZSAhPT0gIm51bWJlciIpIHsKICAgICAgICAgIHRocm93IG5ldyBlcnJvcnMuRVJSX0lOVkFMSURfQVJHX1RZUEUobmFtZSwgIm51bWJlciIsIHZhbHVlKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgZnVuY3Rpb24gYm91bmRzRXJyb3IodmFsdWUsIGxlbmd0aCwgdHlwZSkgewogICAgICAgIGlmIChNYXRoLmZsb29yKHZhbHVlKSAhPT0gdmFsdWUpIHsKICAgICAgICAgIHZhbGlkYXRlTnVtYmVyKHZhbHVlLCB0eXBlKTsKICAgICAgICAgIHRocm93IG5ldyBlcnJvcnMuRVJSX09VVF9PRl9SQU5HRSh0eXBlIHx8ICJvZmZzZXQiLCAiYW4gaW50ZWdlciIsIHZhbHVlKTsKICAgICAgICB9CiAgICAgICAgaWYgKGxlbmd0aCA8IDApIHsKICAgICAgICAgIHRocm93IG5ldyBlcnJvcnMuRVJSX0JVRkZFU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hdGUpIHsKICAgICAgICAgICAgICBpZiAoY29kZVBvaW50ID4gNTYzMTkpIHsKICAgICAgICAgICAgICAgIGlmICgodW5pdHMgLT0gMykgPiAtMSkKICAgICAgICAgICAgICAgICAgYnl0ZXMucHVzaCgyMzksIDE5MSwgMTg5KTsKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAoaSArIDEgPT09IGxlbmd0aCkgewogICAgICAgICAgICAgICAgaWYgKCh1bml0cyAtPSAzKSA+IC0xKQogICAgICAgICAgICAgICAgICBieXRlcy5wdXNoKDIzOSwgMTkxLCAxODkpOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGxlYWRTdXJyb2dhdGUgPSBjb2RlUG9pbnQ7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGNvZGVQb2ludCA8IDU2MzIwKSB7CiAgICAgICAgICAgICAgaWYgKCh1bml0cyAtPSAzKSA+IC0xKQogICAgICAgICAgICAgICAgYnl0ZXMucHVzaCgyMzksIDE5MSwgMTg5KTsKICAgICAgICAgICAgICBsZWFkU3Vycm9nYXRlID0gY29kZVBvaW50OwogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvZGVQb2ludCA9IChsZWFkU3Vycm9nYXRlIC0gNTUyOTYgPDwgMTAgfCBjb2RlUG9pbnQgLSA1NjMyMCkgKyA2NTUzNjsKICAgICAgICAgIH0gZWxzZSBpZiAobGVhZFN1cnJvZ2F0ZSkgewogICAgICAgICAgICBpZiAoKHVuaXRzIC09IDMpID4gLTEpCiAgICAgICAgICAgICAgYnl0ZXMucHVzaCgyMzksIDE5MSwgMTg5KTsKICAgICAgICAgIH0KICAgICAgICAgIGxlYWRTdXJyb2dhdGUgPSBudWxsOwogICAgICAgICAgaWYgKGNvZGVQb2ludCA8IDEyOCkgewogICAgICAgICAgICBpZiAoKHVuaXRzIC09IDEpIDwgMCkKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgYnl0ZXMucHVzaChjb2RlUG9pbnQpOwogICAgICAgICAgfSBlbHNlIGlmIChjb2RlUG9pbnQgPCAyMDQ4KSB7CiAgICAgICAgICAgIGlmICgodW5pdHMgLT0gMikgPCAwKQogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBieXRlcy5wdXNoKGNvZGVQb2ludCA+PiA2IHwgMTkyLCBjb2RlUG9pbnQgJiA2MyB8IDEyOCk7CiAgICAgICAgICB9IGVsc2UgaWYgKGNvZGVQb2ludCA8IDY1NTM2KSB7CiAgICAgICAgICAgIGlmICgodW5pdHMgLT0gMykgPCAwKQogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBieXRlcy5wdXNoKGNvZGVQb2ludCA+PiAxMiB8IDIyNCwgY29kZVBvaW50ID4+IDYgJiA2MyB8IDEyOCwgY29kZVBvaW50ICYgNjMgfCAxMjgpOwogICAgICAgICAgfSBlbHNlIGlmIChjb2RlUG9pbnQgPCAxMTE0MTEyKSB7CiAgICAgICAgICAgIGlmICgodW5pdHMgLT0gNCkgPCAwKQogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBieXRlcy5wdXNoKGNvZGVQb2ludCA+PiAxOCB8IDI0MCwgY29kZVBvaW50ID4+IDEyICYgNjMgfCAxMjgsIGNvZGVQb2ludCA+PiA2ICYgNjMgfCAxMjgsIGNvZGVQb2ludCAmIDYzIHwgMTI4KTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiSW52YWxpZCBjb2RlIHBvaW50Iik7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiBieXRlczsKICAgICAgfQogICAgICBmdW5jdGlvbiBhc2NpaVRvQnl0ZXMoc3RyKSB7CiAgICAgICAgY29uc3QgYnl0ZUFycmF5ID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBzdHIubGVuZ3RoOyArK2kpIHsKICAgICAgICAgIGJ5dGVBcnJheS5wdXNoKHN0ci5jaGFyQ29kZUF0KGkpICYgMjU1KTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJ5dGVBcnJheTsKICAgICAgfQogICAgICBmdW5jdGlvbiB1dGYxNmxlVG9CeXRlcyhzdHIsIHVuaXRzKSB7CiAgICAgICAgbGV0IGMsIGhpLCBsbzsKICAgICAgICBjb25zdCBieXRlQXJyYXkgPSBbXTsKICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHN0ci5sZW5ndGg7ICsraSkgewogICAgICAgICAgaWYgKCh1bml0cyAtPSAyKSA8IDApCiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgYyA9IHN0ci5jaGFyQ29kZUF0KGkpOwogICAgICAgICAgaGkgPSBjID4+IDg7CiAgICAgICAgICBsbyA9IGMgJSAyNTY7CiAgICAgICAgICBieXRlQXJyYXkucHVzaChsbyk7CiAgICAgICAgICBieXRlQXJyYXkucHVzaChoaSk7CiAgICAgICAgfQogICAgICAgIHJldHVybiBieXRlQXJyYXk7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gYmFzZTY0VG9CeXRlcyhzdHIpIHsKICAgICAgICByZXR1cm4gYmFzZTY0LnRvQnl0ZUFycmF5KGJhc2U2NGNsZWFuKHN0cikpOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGJsaXRCdWZmZXIoc3JjLCBkc3QsIG9mZnNldCwgbGVuZ3RoKSB7CiAgICAgICAgbGV0IGk7CiAgICAgICAgZm9yIChpID0gMDsgaSA8IGxlbmd0aDsgKytpKSB7CiAgICAgICAgICBpZiAoaSArIG9mZnNldCA+PSBkc3QubGVuZ3RoIHx8IGkgPj0gc3JjLmxlbmd0aCkKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBkc3RbaSArIG9mZnNldF0gPSBzcmNbaV07CiAgICAgICAgfQogICAgICAgIHJ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wZXJDbGFzcyAhPT0gbnVsbCkgewogICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcigiU3VwZXIgZXhwcmVzc2lvbiBtdXN0IGVpdGhlciBiZSBudWxsIG9yIGEgZnVuY3Rpb24iKTsKICAgICAgICB9CiAgICAgICAgc3ViQ2xhc3MucHJvdG90eXBlID0gT2JqZWN0LmNyZWF0ZShzdXBlckNsYXNzICYmIHN1cGVyQ2xhc3MucHJvdG90eXBlLCB7CiAgICAgICAgICBjb25zdHJ1Y3RvcjogewogICAgICAgICAgICB2YWx1ZTogc3ViQ2xhc3MsCiAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUKICAgICAgICAgIH0KICAgICAgICB9KTsKICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoc3ViQ2xhc3MsICJwcm90b3R5cGUiLCB7CiAgICAgICAgICB3cml0YWJsZTogZmFsc2UKICAgICAgICB9KTsKICAgICAgICBpZiAoc3VwZXJDbGFzcykKICAgICAgICAgIF9zZXRQcm90b3R5cGVPZihzdWJDbGFzcywgc3VwZXJDbGFzcyk7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gX2dldFByb3RvdHlwZU9mKG8pIHsKICAgICAgICBfZ2V0UHJvdG90eXBlT2YgPSBPYmplY3Quc2V0UHJvdG90eXBlT2YgPyBPYmplY3QuZ2V0UHJvdG90eXBlT2YuYmluZCgpIDogZnVuY3Rpb24gX2dldFByb3RvdHlwZU9mMihvMikgewogICAgICAgICAgcmV0dXJuIG8yLl9fcHJvdG9fXyB8fCBPYmplY3QuZ2V0UHJvdG90eXBlT2YobzIpOwogICAgICAgIH07CiAgICAgICAgcmV0dXJuIF9nZXRQcm90b3R5cGVPZihvKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBfc2V0UHJvdG90eXBlT2YobywgcCkgewogICAgICAgIF9zZXRQcm90b3R5cGVPZiA9IE9iamVjdC5zZXRQcm90b3R5cGVPZiA/IE9iamVjdC5zZXRQcm90b3R5cGVPZi5iaW5kKCkgOiBmdW5jdGlvbiBfc2V0UHJvdG90eXBlT2YyKG8yLCBwMikgewogICAgICAgICAgbzIuX19wcm90b19fID0gcDI7CiAgICAgICAgICByZXR1cm4gbzI7CiAgICAgICAgfTsKICAgICAgICByZXR1cm4gX3NldFByb3RvdHlwZU9mKG8sIHApOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIF9pc05hdGl2ZVJlZmxlY3RDb25zdHJ1Y3QoKSB7CiAgICAgICAgaWYgKHR5cGVvZiBSZWZsZWN0ID09PSAidW5kZWZpbmVkIiB8fCAhUmVmbGVjdC5jb25zdHJ1Y3QpCiAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgaWYgKFJlZmxlY3QuY29uc3RydWN0LnNoYW0pCiAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgaWYgKHR5cGVvZiBQcm94eSA9PT0gImZ1bmN0aW9uIikKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIHRyeSB7CiAgICAgICAgICBCb29sZWFuLnByb3RvdHlwZS52YWx1ZU9mLmNhbGwoUmVmbGVjdC5jb25zdHJ1Y3QoQm9vbGVhbiwgW10sIGZ1bmN0aW9uKCkgewogICAgICAgICAgfSkpOwogICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgfQogICAgICBmdW5jdGlvbiBfYXNzZXJ0VGhpc0luaXRpYWxpemVkKHNlbGYyKSB7CiAgICAgICAgaWYgKHNlbGYyID09PSB2b2lkIDApIHsKICAgICAgICAgIHRocm93IG5ldyBSZWZlcmVuY2VFcnJvcigidGhpcyBoYXNuJ3QgYmVlbiBpbml0aWFsaXNlZCAtIHN1cGVyKCkgaGFzbid0IGJlZW4gY2FsbGVkIik7CiAgICAgICAgfQogICAgICAgIHJldHVybiBzZWxmMjsK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IHJldHVybiBfcG9zc2libGVDb25zdHJ1Y3RvclJldHVybih0aGlzLCByZXN1bHQpOwogICAgICAgIH07CiAgICAgIH0KICAgICAgZnVuY3Rpb24gX3N1cGVyUHJvcEJhc2Uob2JqZWN0LCBwcm9wZXJ0eSkgewogICAgICAgIHdoaWxlICghT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKG9iamVjdCwgcHJvcGVydHkpKSB7CiAgICAgICAgICBvYmplY3QgPSBfZ2V0UHJvdG90eXBlT2Yob2JqZWN0KTsKICAgICAgICAgIGlmIChvYmplY3QgPT09IG51bGwpCiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICByZXR1cm4gb2JqZWN0OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIF9nZXQoKSB7CiAgICAgICAgaWYgKHR5cGVvZiBSZWZsZWN0ICE9PSAidW5kZWZpbmVkIiAmJiBSZWZsZWN0LmdldCkgewogICAgICAgICAgX2dldCA9IFJlZmxlY3QuZ2V0LmJpbmQoKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgX2dldCA9IGZ1bmN0aW9uIF9nZXQyKHRhcmdldCwgcHJvcGVydHksIHJlY2VpdmVyKSB7CiAgICAgICAgICAgIHZhciBiYXNlID0gX3N1cGVyUHJvcEJhc2UodGFyZ2V0LCBwcm9wZXJ0eSk7CiAgICAgICAgICAgIGlmICghYmFzZSkKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIHZhciBkZXNjID0gT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcihiYXNlLCBwcm9wZXJ0eSk7CiAgICAgICAgICAgIGlmIChkZXNjLmdldCkgewogICAgICAgICAgICAgIHJldHVybiBkZXNjLmdldC5jYWxsKGFyZ3VtZW50cy5sZW5ndGggPCAzID8gdGFyZ2V0IDogcmVjZWl2ZXIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiBkZXNjLnZhbHVlOwogICAgICAgICAgfTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIF9nZXQuYXBwbHkodGhpcywgYXJndW1lbnRzKTsKICAgICAgfQogICAgICB2YXIgRW1pdHRlciA9IC8qIEBfX1BVUkVfXyAqLyBmdW5jdGlvbigpIHsKICAgICAgICBmdW5jdGlvbiBFbWl0dGVyMigpIHsKICAgICAgICAgIF9jbGFzc0NhbGxDaGVjayh0aGlzLCBFbWl0dGVyMik7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgImxpc3RlbmVycyIsIHsKICAgICAgICAgICAgdmFsdWU6IHt9LAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgX2NyZWF0ZUNsYXNzKEVtaXR0ZXIyLCBbewogICAgICAgICAga2V5OiAiYWRkRXZlbnRMaXN0ZW5lciIsCiAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24gYWRkRXZlbnRMaXN0ZW5lcih0eXBlLCBjYWxsYmFjaywgb3B0aW9ucykgewogICAgICAgICAgICBpZiAoISh0eXBlIGluIHRoaXMubGlzdGVuZXJzKSkgewogICAgICAgICAgICAgIHRoaXMubGlzdGVuZXJzW3R5cGVdID0gW107CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGhpcy5saXN0ZW5lcnNbdHlwZV0ucHVzaCh7CiAgICAgICAgICAgICAgY2FsbGJhY2ssCiAgICAgICAgICAgICAgb3B0aW9ucwogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICB9LCB7CiAgICAgICAgICBrZXk6ICJyZW1vdmVFdmVudExpc3RlbmVyIiwKICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbiByZW1vdmVFdmVudExpc3RlbmVyKHR5cGUsIGNhbGxiYWNrKSB7CiAgICAgICAgICAgIGlmICghKHR5cGUgaW4gdGhpcy5saXN0ZW5lcnMpKSB7CiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHZhciBzdGFjayA9IHRoaXMubGlzdGVuZXJzW3R5cGVdOwogICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgbCA9IHN0YWNrLmxlbmd0aDsgaSA8IGw7IGkrKykgewogICAgICAgICAgICAgIGlmIChzdGFja1tpXS5jYWxsYmFjayA9PT0gY2FsbGJhY2spIHsKICAgICAgICAgICAgICAgIHN0YWNrLnNwbGljZShpLCAxKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9LCB7CiAgICAgICAgICBrZXk6ICJkaXNwYXRjaEV2ZW50IiwKICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbiBkaXNwYXRjaEV2ZW50KGV2ZW50KSB7CiAgICAgICAgICAgIGlmICghKGV2ZW50LnR5cGUgaW4gdGhpcy5saXN0ZW5lcnMpKSB7CiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHZhciBzdGFjayA9IHRoaXMubGlzdGVuZXJzW2V2ZW50LnR5cGVdOwogICAgICAgICAgICB2YXIgc3RhY2tUb0NhbGwgPSBzdGFjay5zbGljZSgpOwogICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgbCA9IHN0YWNrVG9DYWxsLmxlbmd0aDsgaSA8IGw7IGkrKykgewogICAgICAgICAgICAgIHZhciBsaXN0ZW5lciA9IHN0YWNrVG9DYWxsW2ldOwogICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICBsaXN0ZW5lci5jYWxsYmFjay5jYWxsKHRoaXMsIGV2ZW50KTsKICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICBQcm9taXNlLnJlc29sdmUoKS50aGVuKGZ1bmN0aW9uKCkgewogICAgICAgICAgICAgICAgICB0aHJvdyBlOwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChsaXN0ZW5lci5vcHRpb25zICYmIGxpc3RlbmVyLm9wdGlvbnMub25jZSkgewogICAgICAgICAgICAgICAgdGhpcy5yZW1vdmVFdmVudExpc3RlbmVyKGV2ZW50LnR5cGUsIGxpc3RlbmVyLmNhbGxiYWNrKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuICFldmVudC5kZWZhdWx0UHJldmVudGVkOwogICAgICAgICAgfQogICAgICAgIH1dKTsKICAgICAgICByZXR1cm4gRW1pdHRlcjI7CiAgICAgIH0oKTsKICAgICAgdmFyIEFib3J0U2lnbmFsID0gLyogQF9fUFVSRV9fICovIGZ1bmN0aW9uKF9FbWl0dGVyKSB7CiAgICAgICAgX2luaGVyaXRzKEFib3J0U2lnbmFsMiwgX0VtaXR0ZXIpOwogICAgICAgIHZhciBfc3VwZXIgPSBfY3JlYXRlU3VwZXIoQWJvcnRTaWduYWwyKTsKICAgICAgICBmdW5jdGlvbiBBYm9ydFNpZ25hbDIoKSB7CiAgICAgICAgICB2YXIgX3RoaXM7CiAgICAgICAgICBfY2xhc3NDYWxsQ2hlY2sodGhpcywgQWJvcnRTaWduYWwyKTsKICAgICAgICAgIF90aGlzID0gX3N1cGVyLmNhbGwodGhpcyk7CiAgICAgICAgICBpZiAoIV90aGlzLmxpc3RlbmVycykgewogICAgICAgICAgICBFbWl0dGVyLmNhbGwoX2Fzc2VydFRoaXNJbml0aWFsaXplZChfdGhpcykpOwogICAgICAgICAgfQogICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KF9hc3NlcnRUaGlzSW5pdGlhbGl6ZWQoX3RoaXMpLCAiYWJvcnRlZCIsIHsKICAgICAgICAgICAgdmFsdWU6IGZhbHNlLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShfYXNzZXJ0VGhpc0luaXRpYWxpemVkKF90aGlzKSwgIm9uYWJvcnQiLCB7CiAgICAgICAgICAgIHZhbHVlOiBudWxsLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlCiAgICAgICAgICB9KTsKICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShfYXNzZXJ0VGhpc0luaXRpYWxpemVkKF90aGlzKSwgInJlYXNvbiIsIHsKICAgICAgICAgICAgdmFsdWU6IHZvaWQgMCwKICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZQogICAgICAgICAgfSk7CiAgICAgICAgICByZXR1cm4gX3RoaXM7CiAgICAgICAgfQogICAgICAgIF9jcmVhdGVDbGFzcyhBYm9ydFNpZ25hbDIsIFt7CiAgICAgICAgICBrZXk6ICJ0b1N0cmluZyIsCiAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24gdG9TdHJpbmcoKSB7CiAgICAgICAgICAgIHJldHVybiAiW29iamVjdCBBYm9ydFNpZ25hbF0iOwogICAgICAgICAgfQogICAgICAgIH0sIHsKICAgICAgICAgIGtleTogImRpc3BhdGNoRXZlbnQiLAogICAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIGRpc3BhdGNoRXZlbnQoZXZlbnQpIHsKICAgICAgICAgICAgaWYgKGV2ZW50LnR5cGUgPT09ICJhYm9ydCIpIHsKICAgICAgICAgICAgICB0aGlzLmFib3J0ZWQgPSB0cnVlOwogICAgICAgICAgICAgIGlmICh0eXBlb2YgdGhpcy5vbmFib3J0ID09PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgICAgICAgICB0aGlzLm9uYWJvcnQuY2FsbCh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIF9nZXQoX2dldFByb3RvdHlwZU9mKEFib3J0U2lnbmFsMi5wcm90b3R5cGUpLCAiZGlzcGF0Y2hFdmVudCIsIHRoaXMpLmNhbGwodGhpcywgZXZlbnQpOwogICAgICAgICAgfQogICAgICAgIH1dKTsKICAgICAgICByZXR1cm4gQWJvcnRTaWduYWwyOwogICAgICB9KEVtaXR0ZXIpOwogICAgICB2YXIgQWJvcnRDb250cm9sbGVyID0gLyogQF9fUFVSRV9fICovIGZ1bmN0aW9uKCkgewogICAgICAgIGZ1bmN0aW9uIEFib3J0Q29udHJvbGxlcjIoKSB7CiAgICAgICAgICBfY2xhc3NDYWxsQ2hlY2sodGhpcywgQWJvcnRDb250cm9sbGVyMik7CiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgInNpZ25hbCIsIHsKICAgICAgICAgICAgdmFsdWU6IG5ldyBBYm9ydFNpZ25hbCgpLAogICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgX2NyZWF0ZUNsYXNzKEFib3J0Q29udHJvbGxlcjIsIFt7CiAgICAgICAgICBrZXk6ICJhYm9ydCIsCiAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24gYWJvcnQocmVhc29uKSB7CiAgICAgICAgICAgIHZhciBldmVudDsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBldmVudCA9IG5ldyBFdmVudCgiYWJvcnQiKTsKICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgIGlmICh0eXBlb2YgZG9jdW1lbnQgIT09ICJ1bmRlZmluZWQiKSB7CiAgICAgICAgICAgICAgICBpZiAoIWRvY3VtZW50LmNyZWF0ZUV2ZW50KSB7CiAgICAgICAgICAgICAgICAgIGV2ZW50ID0gZG9jdW1lbnQuY3JlYXRlRXZlbnRPYmplY3QoKTsKICAgICAgICAgICAgICAgICAgZXZlbnQudHlwZSA9ICJhYm9ydCI7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICBldmVudCA9IGRvY3VtZW50LmNyZWF0ZUV2ZW50KCJFdmVudCIpOwogICAgICAgICAgICAgICAgICBldmVudC5pbml0RXZlbnQoImFib3J0IiwgZmFsc2UsIGZhbHNlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgZXZlbnQgPSB7CiAgICAgICAgICAgICAgICAgIHR5cGU6ICJhYm9ydCIsCiAgICAgICAgICAgICAgICAgIGJ1YmJsZXM6IGZhbHNlLAogICAgICAgICAgICAgICAgICBjYW5jZWxhYmxlOiBmYWxzZQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdmFyIHNpZ25hbFJlYXNvbiA9IHJlYXNvbjsKICAgICAgICAgICAgaWYgKHNpZ25hbFJlYXNvbiA9PT0gdm9pZCAwKSB7CiAgICAgICAgICAgICAgaWYgKHR5cGVvZiBkb2N1bWVudCA9PT0gInVuZGVmaW5lZCIpIHsKICAgICAgICAgICAgICAgIHNpZ25hbFJlYXNvbiA9IG5ldyBFcnJvcigiVGhpcyBvcGVyYXRpb24gd2FzIGFib3J0ZWQiKTsKICAgICAgICAgICAgICAgIHNpZ25hbFJlYXNvbi5uYW1lID0gIkFib3J0RXJyb3IiOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICBzaWduYWxSZWFzb24gPSBuZXcgRE9NRXhjZXB0aW9uKCJzaWduYWwgaXMgYWJvcnRlZCB3aXRob3V0IHJlYXNvbiIpOwogICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgICAgICAgIHNpZ25hbFJlYXNvbiA9IG5ldyBFcnJvcigiVGhpcyBvcGVyYXRpb24gd2FzIGFib3J0ZWQiKTsKICAgICAgICAgICAgICAgICAgc2lnbmFsUmVhc29uLm5hbWUgPSAiQWJvcnRFcnJvciI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIHRoaXMuc2lnbmFsLnJlYXNvbiA9IHNpZ25hbFJlYXNvbjsKICAgICAgICAgICAgdGhpcy5zaWduYWwuZGlzcGF0Y2hFdmVudChldmVudCk7CiAgICAgICAgICB9CiAgICAgICAgfSwgewogICAgICAgICAga2V5OiAidG9TdHJpbmciLAogICAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIHRvU3RyaW5nKCkgewogICAgICAgICAgICByZXR1cm4gIltvYmplY3QgQWJvcnRDb250cm9sbGVyXSI7CiAgICAgICAgICB9CiAgICAgICAgfV0pOwogICAgICAgIHJldHVybiBBYm9ydENvbnRyb2xsZXIyOwogICAgICB9KCk7CiAgICAgIGlmICh0eXBlb2YgU3ltYm9sICE9PSAidW5kZWZpbmVkIiAmJiBTeW1ib2wudG9TdHJpbmdUYWcpIHsKICAgICAgICBBYm9ydENvbnRyb2xsZXIucHJvdG90eXBlW1N5bWJvbC50b1N0cmluZ1RhZ10gPSAiQWJvcnRDb250cm9sbGVyIjsKICAgICAgICBBYm9ydFNpZ25hbC5wcm90b3R5cGVbU3ltYm9sLnRvU3RyaW5nVGFnXSA9ICJBYm9ydFNpZ25hbCI7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gcG9seWZpbGxOZWVkZWQoc2VsZjIpIHsKICAgICAgICBpZiAoc2VsZjIuX19GT1JDRV9JTlNUQUxMX0FCT1JUQ09OVFJPTExFUl9QT0xZRklMTCkgewogICAgICAgICAgY29uc29sZS5sb2coIl9fRk9SQ0VfSU5TVEFMTF9BQk9SVENPTlRST0xMRVJfUE9MWUZJTEw9dHJ1ZSBpcyBzZXQsIHdpbGwgZm9yY2UgaW5zdGFsbCBwb2x5ZmlsbCIpOwogICAgICAgICAgcmV0dXJuI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TsKICAgICAgICBpZiAoIXBvbHlmaWxsTmVlZGVkKHsKICAgICAgICAgIGZldGNoLAogICAgICAgICAgUmVxdWVzdDogTmF0aXZlUmVxdWVzdCwKICAgICAgICAgIEFib3J0Q29udHJvbGxlcjogTmF0aXZlQWJvcnRDb250cm9sbGVyLAogICAgICAgICAgX19GT1JDRV9JTlNUQUxMX0FCT1JUQ09OVFJPTExFUl9QT0xZRklMTAogICAgICAgIH0pKSB7CiAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICBmZXRjaCwKICAgICAgICAgICAgUmVxdWVzdAogICAgICAgICAgfTsKICAgICAgICB9CiAgICAgICAgdmFyIFJlcXVlc3QgPSBOYXRpdmVSZXF1ZXN0OwogICAgICAgIGlmIChSZXF1ZXN0ICYmICFSZXF1ZXN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eSgic2lnbmFsIikgfHwgX19GT1JDRV9JTlNUQUxMX0FCT1JUQ09OVFJPTExFUl9QT0xZRklMTCkgewogICAgICAgICAgUmVxdWVzdCA9IGZ1bmN0aW9uIFJlcXVlc3QyKGlucHV0LCBpbml0MikgewogICAgICAgICAgICB2YXIgc2lnbmFsOwogICAgICAgICAgICBpZiAoaW5pdDIgJiYgaW5pdDIuc2lnbmFsKSB7CiAgICAgICAgICAgICAgc2lnbmFsID0gaW5pdDIuc2lnbmFsOwogICAgICAgICAgICAgIGRlbGV0ZSBpbml0Mi5zaWduYWw7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdmFyIHJlcXVlc3QgPSBuZXcgTmF0aXZlUmVxdWVzdChpbnB1dCwgaW5pdDIpOwogICAgICAgICAgICBpZiAoc2lnbmFsKSB7CiAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHJlcXVlc3QsICJzaWduYWwiLCB7CiAgICAgICAgICAgICAgICB3cml0YWJsZTogZmFsc2UsCiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiBmYWxzZSwKICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIHZhbHVlOiBzaWduYWwKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gcmVxdWVzdDsKICAgICAgICAgIH07CiAgICAgICAgICBSZXF1ZXN0LnByb3RvdHlwZSA9IE5hdGl2ZVJlcXVlc3QucHJvdG90eXBlOwogICAgICAgIH0KICAgICAgICB2YXIgcmVhbEZldGNoID0gZmV0Y2g7CiAgICAgICAgdmFyIGFib3J0YWJsZUZldGNoID0gZnVuY3Rpb24gYWJvcnRhYmxlRmV0Y2gyKGlucHV0LCBpbml0MikgewogICAgICAgICAgdmFyIHNpZ25hbCA9IFJlcXVlc3QgJiYgUmVxdWVzdC5wcm90b3R5cGUuaXNQcm90b3R5cGVPZihpbnB1dCkgPyBpbnB1dC5zaWduYWwgOiBpbml0MiA/IGluaXQyLnNpZ25hbCA6IHZvaWQgMDsKICAgICAgICAgIGlmIChzaWduYWwpIHsKICAgICAgICAgICAgdmFyIGFib3J0RXJyb3I7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgYWJvcnRFcnJvciA9IG5ldyBET01FeGNlcHRpb24oIkFib3J0ZWQiLCAiQWJvcnRFcnJvciIpOwogICAgICAgICAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICAgICAgICBhYm9ydEVycm9yID0gbmV3IEVycm9yKCJBYm9ydGVkIik7CiAgICAgICAgICAgICAgYWJvcnRFcnJvci5uYW1lID0gIkFib3J0RXJyb3IiOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzaWduYWwuYWJvcnRlZCkgewogICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdChhYm9ydEVycm9yKTsKICAgICAgICAgICAgfQogICAgICAgICAgICB2YXIgY2FuY2VsbGF0aW9uID0gbmV3IFByb21pc2UoZnVuY3Rpb24oXywgcmVqZWN0KSB7CiAgICAgICAgICAgICAgc2lnbmFsLmFkZEV2ZW50TGlzdGVuZXIoImFib3J0IiwgZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gcmVqZWN0KGFib3J0RXJyb3IpOwogICAgICAgICAgICAgIH0sIHsKICAgICAgICAgICAgICAgIG9uY2U6IHRydWUKICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGlmIChpbml0MiAmJiBpbml0Mi5zaWduYWwpIHsKICAgICAgICAgICAgICBkZWxldGUgaW5pdDIuc2lnbmFsOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJhY2UoW2NhbmNlbGxhdGlvbiwgcmVhbEZldGNoKGlucHV0LCBpbml0MildKTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiByZWFsRmV0Y2goaW5wdXQsIGluaXQyKTsKICAgICAgICB9OwogICAgICAgIHJldHVybiB7CiAgICAgICAgICBmZXRjaDogYWJvcnRhYmxlRmV0Y2gsCiAgICAgICAgICBSZXF1ZXN0CiAgICAgICAgfTsKICAgICAgfQogICAgICBleHBvcnRzMi5BYm9ydENvbnRyb2xsZXIgPSBBYm9ydENvbnRyb2xsZXI7CiAgICAgIGV4cG9ydHMyLkFib3J0U2lnbmFsID0gQWJvcnRTaWduYWw7CiAgICAgIGV4cG9ydHMyLmFib3J0YWJsZUZldGNoID0gYWJvcnRhYmxlRmV0Y2hEZWNvcmF0b3I7CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8ucG5wbS9hYm9ydGFibGUtcHJvbWlzZS1jYWNoZUAxLjUuMC9ub2RlX21vZHVsZXMvYWJvcnRhYmxlLXByb21pc2UtY2FjaGUvZXNtL2Fib3J0Y29udHJvbGxlci1wb255ZmlsbC5qcwogIHZhciByZXF1aXJlX2Fib3J0Y29udHJvbGxlcl9wb255ZmlsbCA9IF9fY29tbW9uSlMoewogICAgIm5vZGVfbW9kdWxlcy8ucG5wbS9hYm9ydGFibGUtcHJvbW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gICAgdGhpcy5zaWduYWxzID0gbmV3IFNldCgpOwogICAgICAgICAgdGhpcy5hYm9ydENvbnRyb2xsZXIgPSBuZXcgYWJvcnRjb250cm9sbGVyX3BvbnlmaWxsXzEuQWJvcnRDb250cm9sbGVyKCk7CiAgICAgICAgfQogICAgICAgIGFkZFNpZ25hbChzaWduYWwgPSBuZXcgTnVsbFNpZ25hbCgpKSB7CiAgICAgICAgICBpZiAodGhpcy5zaWduYWwuYWJvcnRlZCkgewogICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoImNhbm5vdCBhZGQgYSBzaWduYWwsIGFscmVhZHkgYWJvcnRlZCEiKTsKICAgICAgICAgIH0KICAgICAgICAgIHRoaXMuc2lnbmFscy5hZGQoc2lnbmFsKTsKICAgICAgICAgIGlmIChzaWduYWwuYWJvcnRlZCkgewogICAgICAgICAgICB0aGlzLmhhbmRsZUFib3J0ZWQoc2lnbmFsKTsKICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIHNpZ25hbC5hZGRFdmVudExpc3RlbmVyID09PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgICAgIHNpZ25hbC5hZGRFdmVudExpc3RlbmVyKCJhYm9ydCIsICgpID0+IHsKICAgICAgICAgICAgICB0aGlzLmhhbmRsZUFib3J0ZWQoc2lnbmFsKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGhhbmRsZUFib3J0ZWQoc2lnbmFsKSB7CiAgICAgICAgICB0aGlzLnNpZ25hbHMuZGVsZXRlKHNpZ25hbCk7CiAgICAgICAgICBpZiAodGhpcy5zaWduYWxzLnNpemUgPT09IDApIHsKICAgICAgICAgICAgdGhpcy5hYm9ydENvbnRyb2xsZXIuYWJvcnQoKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZ2V0IHNpZ25hbCgpIHsKICAgICAgICAgIHJldHVybiB0aGlzLmFib3J0Q29udHJvbGxlci5zaWduYWw7CiAgICAgICAgfQogICA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AgICAgICAgfSksCiAgICAgICAgICAgIHNldHRsZWQ6IGZhbHNlLAogICAgICAgICAgICBzdGF0dXNSZXBvcnRlciwKICAgICAgICAgICAgZ2V0IGFib3J0ZWQoKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuYWJvcnRlci5zaWduYWwuYWJvcnRlZDsKICAgICAgICAgICAgfQogICAgICAgICAgfTsKICAgICAgICAgIG5ld0VudHJ5LmFib3J0ZXIuYWRkU2lnbmFsKHNpZ25hbCk7CiAgICAgICAgICBuZXdFbnRyeS5hYm9ydGVyLnNpZ25hbC5hZGRFdmVudExpc3RlbmVyKCJhYm9ydCIsICgpID0+IHsKICAgICAgICAgICAgaWYgKCFuZXdFbnRyeS5zZXR0bGVkKSB7CiAgICAgICAgICAgICAgdGhpcy5ldmljdChrZXksIG5ld0VudHJ5KTsKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgICBuZXdFbnRyeS5wcm9taXNlLnRoZW4oKCkgPT4gewogICAgICAgICAgICBuZXdFbnRyeS5zZXR0bGVkID0gdHJ1ZTsKICAgICAgICAgIH0sICgpID0+IHsKICAgICAgICAgICAgbmV3RW50cnkuc2V0dGxlZCA9IHRydWU7CiAgICAgICAgICAgIHRoaXMuZXZpY3Qoa2V5LCBuZXdFbnRyeSk7CiAgICAgICAgICB9KS5jYXRjaCgoZSkgPT4gewogICAgICAgICAgICBjb25zb2xlLmVycm9yKGUpOwogICAgICAgICAgICB0aHJvdyBlOwogICAgICAgICAgfSk7CiAgICAgICAgICB0aGlzLmNhY2hlLnNldChrZXksIG5ld0VudHJ5KTsKICAgICAgICB9CiAgICAgICAgc3RhdGljIGNoZWNrU2luZ2xlUHJvbWlzZShwcm9taXNlLCBzaWduYWwpIHsKICAgICAgICAgIGZ1bmN0aW9uIGNoZWNrRm9yU2luZ2xlQWJvcnQoKSB7CiAgICAgICAgICAgIGlmIChzaWduYWwgJiYgc2lnbmFsLmFib3J0ZWQpIHsKICAgICAgICAgICAgICB0aHJvdyBPYmplY3QuYXNzaWduKG5ldyBFcnJvcigiYWJvcnRlZCIpLCB7IGNvZGU6ICJFUlJfQUJPUlRFRCIgfSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBwcm9taXNlLnRoZW4oKHJlc3VsdCkgPT4gewogICAgICAgICAgICBjaGVja0ZvclNpbmdsZUFib3J0KCk7CiAgICAgICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgICAgICB9LCAoZXJyb3IpID0+IHsKICAgICAgICAgICAgY2hlY2tGb3JTaW5nbGVBYm9ydCgpOwogICAgICAgICAgICB0aHJvdyBlcnJvcjsKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgICBoYXMoa2V5KSB7CiAgICAgICAgICByZXR1cm4gdGhpcy5jYWNoZS5oYXMoa2V5KTsKICAgICAgICB9CiAgICAgICAgZ2V0KGtleSwgZGF0YSwgc2lnbmFsLCBzdGF0dXNDYWxsYmFjaykgewogICAgICAgICAgaWYgKCFzaWduYWwgJiYgZGF0YSBpbnN0YW5jZW9mIGFib3J0Y29udHJvbGxlcl9wb255ZmlsbF8xLkFib3J0U2lnbmFsKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoInNlY29uZCBnZXQgYXJndW1lbnQgYXBwZWFycyB0byBiZSBhbiBBYm9ydFNpZ25hbCwgcGVyaGFwcyB5b3UgbWVhbnQgdG8gcGFzcyBgbnVsbGAgZm9yIHRoZSBmaWxsIGRhdGE/Iik7CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCBjYWNoZUVudHJ5ID0gdGhpcy5jYWNoZS5nZXQoa2V5KTsKICAgICAgICAgIGlmIChjYWNoZUVudHJ5KSB7CiAgICAgICAgICAgIGlmIChjYWNoZUVudHJ5LmFib3J0ZWQgJiYgIWNhY2hlRW50cnkuc2V0dGxlZCkgewogICAgICAgICAgICAgIHRoaXMuZXZpY3Qoa2V5LCBjYWNoZUVudHJ5KTsKICAgICAgICAgICAgICByZXR1cm4gdGhpcy5nZXQoa2V5LCBkYXRhLCBzaWduYWwsIHN0YXR1c0NhbGxiYWNrKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoY2FjaGVFbnRyeS5zZXR0bGVkKSB7CiAgICAgICAgICAgICAgcmV0dXJuIGNhY2hlRW50cnkucHJvbWlzZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjYWNoZUVudHJ5LmFib3J0ZXIuYWRkU2lnbmFsKHNpZ25hbCk7CiAgICAgICAgICAgIGNhY2hlRW50cnkuc3RhdHVzUmVwb3J0ZXIuYWRkQ2FsbGJhY2soc3RhdHVzQ2FsbGJhY2spOwogICAgICAgICAgICByZXR1cm4gQWJvcnRhYmxlUHJvbWlzZUNhY2hlMi5jaGVja1NpbmdsZVByb21pc2UoY2FjaGVFbnRyeS5wcm9taXNlLCBzaWduYWwpOwogICAgICAgICAgfQogICAgICAgICAgdGhpcy5maWxsKGtleSwgZGF0YSwgc2lnbmFsLCBzdGF0dXNDYWxsYmFjayk7CiAgICAgICAgICByZXR1cm4gQWJvcnRhYmxlUHJvbWlzZUNhY2hlMi5jaGVja1NpbmdsZVByb21pc2UodGhpcy5jYWNoZS5nZXQoa2V5KS5wcm9taXNlLCBzaWduYWwpOwogICAgICAgIH0KICAgICAgICBkZWxldGUoa2V5KSB7CiAgICAgICAgICBjb25zdCBjYWNoZWRFbnRyeSA9IHRoaXMuY2FjaGUuZ2V0KGtleSk7CiAgICAgICAgICBpZiAoY2FjaGVkRW50cnkpIHsKICAgICAgICAgICAgaWYgKCFjYWNoZWRFbnRyeS5zZXR0bGVkKSB7CiAgICAgICAgICAgICAgY2FjaGVkRW50cnkuYWJvcnRlci5hYm9ydCgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHRoaXMuY2FjaGUuZGVsZXRlKGtleSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGNsZWFyKCkgewogICAgICAgICAgY29uc3Qga2V5SXRlciA9I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HVsZSIsIHsgdmFsdWU6IHRydWUgfSk7CiAgICAgIHZhciBBYm9ydGFibGVQcm9taXNlQ2FjaGVfMSA9IF9faW1wb3J0RGVmYXVsdChyZXF1aXJlX0Fib3J0YWJsZVByb21pc2VDYWNoZSgpKTsKICAgICAgZXhwb3J0czIuZGVmYXVsdCA9IEFib3J0YWJsZVByb21pc2VDYWNoZV8xLmRlZmF1bHQ7CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8ucG5wbS9xdWljay1scnVANC4wLjEvbm9kZV9tb2R1bGVzL3F1aWNrLWxydS9pbmRleC5qcwogIHZhciByZXF1aXJlX3F1aWNrX2xydSA9IF9fY29tbW9uSlMoewogICAgIm5vZGVfbW9kdWxlcy8ucG5wbS9xdWljay1scnVANC4wLjEvbm9kZV9tb2R1bGVzL3F1aWNrLWxydS9pbmRleC5qcyIoZXhwb3J0czIsIG1vZHVsZTIpIHsKICAgICAgaW5pdF9idWZmZXJfc2hpbSgpOwogICAgICAidXNlIHN0cmljdCI7CiAgICAgIHZhciBRdWlja0xSVSA9IGNsYXNzIHsKICAgICAgICBjb25zdHJ1Y3RvcihvcHRpb25zID0ge30pIHsKICAgICAgICAgIGlmICghKG9wdGlvbnMubWF4U2l6ZSAmJiBvcHRpb25zLm1heFNpemUgPiAwKSkgewogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCJgbWF4U2l6ZWAgbXVzdCBiZSBhIG51bWJlciBncmVhdGVyIHRoYW4gMCIpOwogICAgICAgICAgfQogICAgICAgICAgdGhpcy5tYXhTaXplID0gb3B0aW9ucy5tYXhTaXplOwogICAgICAgICAgdGhpcy5jYWNoZSA9IG5ldyBNYXAoKTsKICAgICAgICAgIHRoaXMub2xkQ2FjaGUgPSBuZXcgTWFwKCk7CiAgICAgICAgICB0aGlzLl9zaXplID0gMDsKICAgICAgICB9CiAgICAgICAgX3NldChrZXksIHZhbHVlKSB7CiAgICAgICAgICB0aGlzLmNhY2hlLnNldChrZXksIHZhbHVlKTsKICAgICAgICAgIHRoaXMuX3NpemUrKzsKICAgICAgICAgIGlmICh0aGlzLl9zaXplID49IHRoaXMubWF4U2l6ZSkgewogICAgICAgICAgICB0aGlzLl9zaXplID0gMDsKICAgICAgICAgICAgdGhpcy5vbGRDYWNoZSA9IHRoaXMuY2FjaGU7CiAgICAgICAgICAgIHRoaXMuY2FjaGUgPSBuZXcgTWFwKCk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGdldChrZXkpIHsKICAgICAgICAgIGlmICh0aGlzLmNhY2hlLmhhcyhrZXkpKSB7CiAgICAgICAgICAgIHJldHVybiB0aGlzLmNhY2hlLmdldChrZXkpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHRoaXMub2xkQ2FjaGUuaGFzKGtleSkpIHsKICAgICAgICAgICAgY29uc3QgdmFsdWUgPSB0aGlzLm9sZENhY2hlLmdldChrZXkpOwogICAgICAgICAgICB0aGlzLm9sZENhY2hlLmRlbGV0ZShrZXkpOwogICAgICAgICAgICB0aGlzLl9zZXQoa2V5LCB2YWx1ZSk7CiAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgc2V0KGtleSwgdmFsdWUpIHsKICAgICAgICAgIGlmICh0aGlzLmNhY2hlLmhhcyhrZXkpKSB7CiAgICAgICAgICAgIHRoaXMuY2FjaGUuc2V0KGtleSwgdmFsdWUpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgdGhpcy5fc2V0KGtleSwgdmFsdWUpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgfQogICAgICAgIGhhcyhrZXkpIHsKICAgICAgICAgIHJldHVybiB0aGlzLmNhY2hlLmhhcyhrZXkpIHx8IHRoaXMub2xkQ2FjaGUuaGFzKGtleSk7CiAgICAgICAgfQogICAgICAgIHBlZWsoa2V5KSB7CiAgICAgICAgICBpZiAodGhpcy5jYWNoZS5oYXMoa2V5KSkgewogICAgICAgICAgICByZXR1cm4gdGhpcy5jYWNoZS5nZXQoa2V5KTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh0aGlzLm9sZENhY2hlLmhhcyhrZXkpKSB7CiAgICAgICAgICAgIHJldHVybiB0aGlzLm9sZENhY2hlLmdldChrZXkpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBkZWxldGUoa2V5KSB7CiAgICAgICAgICBjb25zdCBkZWxldGVkID0gdGhpcy5jYWNoZS5kZWxldGUoa2V5KTsKICAgICAgICAgIGlmIChkZWxldGVkKSB7CiAgICAgICAgICAgIHRoaXMuX3NpemUtLTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiB0aGlzLm9sZENhY2hlLmRlbGV0ZShrZXkpIHx8IGRlbGV0ZWQ7CiAgICAgICAgfQogICAgICAgIGNsZWFyKCkgewogICAgICAgICAgdGhpcy5jYWNoZS5jbGVhcigpOwogICAgICAgICAgdGhpcy5vbGRDYWNoZS5jbGVhcigpOwogICAgICAgICAgdGhpcy5fc2l6ZSA9IDA7CiAgICAgICAgfQogICAgICAgICprZXlzKCkgewogICAgICAgICAgZm9yIChjb25zdCBba2V5XSBvZiB0aGlzKSB7CiAgICAgICAgICAgIHlpZWxkIGtleTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgKnZhbHVlcygpIHsKICAgICAgICAgIGZvciAoY29uc3QgWywgdmFsdWVdIG9mIHRoaXMpIHsKICAgICAgICAgICAgeWllbGQgdmFsdWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgICpbU3ltYm9sLml0ZXJhdG9yXSgpIHsKICAgICAgICAgIGZvciAoY29uc3QgaXRlbSBvZiB0aGlzLmNhY2hlKSB7CiAgICAgICAgICAgIHlpZWxkIGl0ZW07CiAgICAgICAgICB9CiAgICAgICAgICBmb3IgKGNvbnN0IGl0ZW0gb2YgdGhpcy5vbGRDYWNoZSkgewogICAgICAgICAgICBjb25zdCBba2V5XSA9I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vLnBucG0vcGFrb0AxLjAuMTEvbm9kZV9tb2R1bGVzL3Bha28vbGliL3V0aWxzL2NvbW1vbi5qcyIoZXhwb3J0czIpIHsKICAgICAgaW5pdF9idWZmZXJfc2hpbSgpOwogICAgICAidXNlIHN0cmljdCI7CiAgICAgIHZhciBUWVBFRF9PSyA9IHR5cGVvZiBVaW50OEFycmF5ICE9PSAidW5kZWZpbmVkIiAmJiB0eXBlb2YgVWludDE2QXJyYXkgIT09ICJ1bmRlZmluZWQiICYmIHR5cGVvZiBJbnQzMkFycmF5ICE9PSAidW5kZWZpbmVkIjsKICAgICAgZnVuY3Rpb24gX2hhcyhvYmosIGtleSkgewogICAgICAgIHJldHVybiBPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwob2JqLCBrZXkpOwogICAgICB9CiAgICAgIGV4cG9ydHMyLmFzc2lnbiA9IGZ1bmN0aW9uKG9iaikgewogICAgICAgIHZhciBzb3VyY2VzID0gQXJyYXkucHJvdG90eXBlLnNsaWNlLmNhbGwoYXJndW1lbnRzLCAxKTsKICAgICAgICB3aGlsZSAoc291cmNlcy5sZW5ndGgpIHsKICAgICAgICAgIHZhciBzb3VyY2UgPSBzb3VyY2VzLnNoaWZ0KCk7CiAgICAgICAgICBpZiAoIXNvdXJjZSkgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh0eXBlb2Ygc291cmNlICE9PSAib2JqZWN0IikgewogICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKHNvdXJjZSArICJtdXN0IGJlIG5vbi1vYmplY3QiKTsKICAgICAgICAgIH0KICAgICAgICAgIGZvciAodmFyIHAgaW4gc291cmNlKSB7CiAgICAgICAgICAgIGlmIChfaGFzKHNvdXJjZSwgcCkpIHsKICAgICAgICAgICAgICBvYmpbcF0gPSBzb3VyY2VbcF07CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIG9iajsKICAgICAgfTsKICAgICAgZXhwb3J0czIuc2hyaW5rQnVmID0gZnVuY3Rpb24oYnVmLCBzaXplKSB7CiAgICAgICAgaWYgKGJ1Zi5sZW5ndGggPT09IHNpemUpIHsKICAgICAgICAgIHJldHVybiBidWY7CiAgICAgICAgfQogICAgICAgIGlmIChidWYuc3ViYXJyYXkpIHsKICAgICAgICAgIHJldHVybiBidWYuc3ViYXJyYXkoMCwgc2l6ZSk7CiAgICAgICAgfQogICAgICAgIGJ1Zi5sZW5ndGggPSBzaXplOwogICAgICAgIHJldHVybiBidWY7CiAgICAgIH07CiAgICAgIHZhciBmblR5cGVkID0gewogICAgICAgIGFycmF5U2V0OiBmdW5jdGlvbihkZXN0LCBzcmMsIHNyY19vZmZzLCBsZW4sIGRlc3Rfb2ZmcykgewogICAgICAgICAgaWYgKHNyYy5zdWJhcnJheSAmJiBkZXN0LnN1YmFycmF5KSB7CiAgICAgICAgICAgIGRlc3Quc2V0KHNyYy5zdWJhcnJheShzcmNfb2Zmcywgc3JjX29mZnMgKyBsZW4pLCBkZXN0X29mZnMpOwogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICB9CiAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgICAgIGRlc3RbZGVzdF9vZmZzICsgaV0gPSBzcmNbc3JjX29mZnMgKyBpXTsKICAgICAgICAgIH0KICAgICAgICB9LAogICAgICAgIGZsYXR0ZW5DaHVua3M6IGZ1bmN0aW9uKGNodW5rcykgewogICAgICAgICAgdmFyIGksIGwsIGxlbiwgcG9zLCBjaHVuaywgcmVzdWx0OwogICAgICAgICAgbGVuID0gMDsKICAgICAgICAgIGZvciAoaSA9IDAsIGwgPSBjaHVua3MubGVuZ3RoOyBpIDwgbDsgaSsrKSB7CiAgICAgICAgICAgIGxlbiArPSBjaHVua3NbaV0ubGVuZ3RoOwogICAgICAgICAgfQogICAgICAgICAgcmVzdWx0ID0gbmV3IFVpbnQ4QXJyYXkobGVuKTsKICAgICAgICAgIHBvcyA9IDA7CiAgICAgICAgICBmb3IgKGkgPSAwLCBsID0gY2h1bmtzLmxlbmd0aDsgaSA8IGw7IGkrKykgewogICAgICAgICAgICBjaHVuayA9IGNodW5rc1tpXTsKICAgICAgICAgICAgcmVzdWx0LnNldChjaHVuaywgcG9zKTsKICAgICAgICAgICAgcG9zICs9IGNodW5rLmxlbmd0aDsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgICAgfQogICAgICB9OwogICAgICB2YXIgZm5VbnR5cGVkID0gewogICAgICAgIGFycmF5U2V0OiBmdW5jdGlvbihkZXN0LCBzcmMsIHNyY19vZmZzLCBsZW4sIGRlc3Rfb2ZmcykgewogICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBsZW47IGkrKykgewogICAgICAgICAgICBkZXN0W2Rlc3Rfb2ZmcyArIGldID0gc3JjW3NyY19vZmZzICsgaV07CiAgICAgICAgICB9CiAgICAgICAgfSwKICAgICAgICBmbGF0dGVuQ2h1bmtzOiBmdW5jdGlvbihjaHVua3MpIHsKICAgICAgICAgIHJldHVybiBbXS5jb25jYXQuYXBwbHkoW10sIGNodW5rcyk7CiAgICAgICAgfQogICAgICB9OwogICAgICBleHBvcnRzMi5zZXRUeXBlZCA9IGZ1bmN0aW9uKG9uKSB7CiAgICAgICAgaWYgKG9uKSB7CiAgICAgICAgICBleHBvcnRzMi5CdWY4ID0gVWludDhBcnJheTsKICAgICAgICAgIGV4cG9ydHMyLkJ1ZjE2ID0gVWludDE2QXJyYXk7CiAgICAgICAgICBleHBvcnRzMi5CdWYzMiA9IEludDMyQXJyYXk7CiAgICAgICAgICBleHBvcnRzMi5hc3NpZ24oZXhwb3J0czIsIGZuVHlwZWQpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBleHBvcnRzMi5CdWY4ID0gQXJyYXk7CiAgICAgICAgICBleHBvcnRzMi5CdWYxNiA9IEFycmF5OwogICAgICAgIC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KyAxXSk7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gYmlfcmV2ZXJzZShjb2RlLCBsZW4pIHsKICAgICAgICB2YXIgcmVzID0gMDsKICAgICAgICBkbyB7CiAgICAgICAgICByZXMgfD0gY29kZSAmIDE7CiAgICAgICAgICBjb2RlID4+Pj0gMTsKICAgICAgICAgIHJlcyA8PD0gMTsKICAgICAgICB9IHdoaWxlICgtLWxlbiA+IDApOwogICAgICAgIHJldHVybiByZXMgPj4+IDE7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gYmlfZmx1c2gocykgewogICAgICAgIGlmIChzLmJpX3ZhbGlkID09PSAxNikgewogICAgICAgICAgcHV0X3Nob3J0KHMsIHMuYmlfYnVmKTsKICAgICAgICAgIHMuYmlfYnVmID0gMDsKICAgICAgICAgIHMuYmlfdmFsaWQgPSAwOwogICAgICAgIH0gZWxzZSBpZiAocy5iaV92YWxpZCA+PSA4KSB7CiAgICAgICAgICBzLnBlbmRpbmdfYnVmW3MucGVuZGluZysrXSA9IHMuYmlfYnVmICYgMjU1OwogICAgICAgICAgcy5iaV9idWYgPj49IDg7CiAgICAgICAgICBzLmJpX3ZhbGlkIC09IDg7CiAgICAgICAgfQogICAgICB9CiAgICAgIGZ1bmN0aW9uIGdlbl9iaXRsZW4ocywgZGVzYykgewogICAgICAgIHZhciB0cmVlID0gZGVzYy5keW5fdHJlZTsKICAgICAgICB2YXIgbWF4X2NvZGUgPSBkZXNjLm1heF9jb2RlOwogICAgICAgIHZhciBzdHJlZSA9IGRlc2Muc3RhdF9kZXNjLnN0YXRpY190cmVlOwogICAgICAgIHZhciBoYXNfc3RyZWUgPSBkZXNjLnN0YXRfZGVzYy5oYXNfc3RyZWU7CiAgICAgICAgdmFyIGV4dHJhID0gZGVzYy5zdGF0X2Rlc2MuZXh0cmFfYml0czsKICAgICAgICB2YXIgYmFzZSA9IGRlc2Muc3RhdF9kZXNjLmV4dHJhX2Jhc2U7CiAgICAgICAgdmFyIG1heF9sZW5ndGggPSBkZXNjLnN0YXRfZGVzYy5tYXhfbGVuZ3RoOwogICAgICAgIHZhciBoOwogICAgICAgIHZhciBuLCBtOwogICAgICAgIHZhciBiaXRzOwogICAgICAgIHZhciB4Yml0czsKICAgICAgICB2YXIgZjsKICAgICAgICB2YXIgb3ZlcmZsb3cgPSAwOwogICAgICAgIGZvciAoYml0cyA9IDA7IGJpdHMgPD0gTUFYX0JJVFM7IGJpdHMrKykgewogICAgICAgICAgcy5ibF9jb3VudFtiaXRzXSA9IDA7CiAgICAgICAgfQogICAgICAgIHRyZWVbcy5oZWFwW3MuaGVhcF9tYXhdICogMiArIDFdID0gMDsKICAgICAgICBmb3IgKGggPSBzLmhlYXBfbWF4ICsgMTsgaCA8IEhFQVBfU0laRTsgaCsrKSB7CiAgICAgICAgICBuID0gcy5oZWFwW2hdOwogICAgICAgICAgYml0cyA9IHRyZWVbdHJlZVtuICogMiArIDFdICogMiArIDFdICsgMTsKICAgICAgICAgIGlmIChiaXRzID4gbWF4X2xlbmd0aCkgewogICAgICAgICAgICBiaXRzID0gbWF4X2xlbmd0aDsKICAgICAgICAgICAgb3ZlcmZsb3crKzsKICAgICAgICAgIH0KICAgICAgICAgIHRyZWVbbiAqIDIgKyAxXSA9IGJpdHM7CiAgICAgICAgICBpZiAobiA+IG1heF9jb2RlKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgcy5ibF9jb3VudFtiaXRzXSsrOwogICAgICAgICAgeGJpdHMgPSAwOwogICAgICAgICAgaWYgKG4gPj0gYmFzZSkgewogICAgICAgICAgICB4Yml0cyA9IGV4dHJhW24gLSBiYXNlXTsKICAgICAgICAgIH0KICAgICAgICAgIGYgPSB0cmVlW24gKiAyXTsKICAgICAgICAgIHMub3B0X2xlbiArPSBmICogKGJpdHMgKyB4Yml0cyk7CiAgICAgICAgICBpZiAoaGFzX3N0cmVlKSB7CiAgICAgICAgICAgIHMuc3RhdGljX2xlbiArPSBmICogKHN0cmVlW24gKiAyICsgMV0gKyB4Yml0cyk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChvdmVyZmxvdyA9PT0gMCkgewogICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBkbyB7CiAgICAgICAgICBiaXRzID0gbWF4X2xlbmd0aCAtIDE7CiAgICAgICAgICB3aGlsZSAocy5ibF9jb3VudFtiaXRzXSA9PT0gMCkgewogICAgICAgICAgICBiaXRzLS07CiAgICAgICAgICB9CiAgICAgICAgICBzLmJsX2NvdW50W2JpdHNdLS07CiAgICAgICAgICBzLmJsX2NvdW50W2JpdHMgKyAxXSArPSAyOwogICAgICAgICAgcy5ibF9jb3VudFttYXhfbGVuZ3RoXS0tOwogICAgICAgICAgb3ZlcmZsb3cgLT0gMjsKICAgICAgICB9IHdoaWxlIChvdmVyZmxvdyA+IDApOwogICAgICAgIGZvciAoYml0cyA9IG1heF9sZW5ndGg7IGJpdHMgIT09IDA7IGJpdHMtLSkgewogICAgICAgICAgbiA9IHMuYmxfY291bnRbYml0c107CiAgICAgICAgICB3aGlsZSAobiAhPT0gMCkgewogICAgICAgICAgICBtID0gcy5oZWFwWy0taF07CiAgICAgICAgICAgIGlmIChtID4gbWF4X2NvZGUpIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodHJlZVttICogMiArIDFdICE9PSBiaXRzKSB7CiAgICAgICAgICAgICAgcy5vcHRfbGVuICs9IChiaXRzIC0gdHJlZVttICogMiArIDFdKSAqIHRyZWVbbSAqIDJdOwogICAgICAgICAgICAgIHRyZWVbbSAqIDIgKyAxXSA9IGJpdHM7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbi0tOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBmdW5jdGlvbiBnZW5fY29kZXModHJlZSwgbWF4X2NvZGUsIGJsX2NvdW50KSB7CiAgICAgICAgdmFyIG5leHRfY29kZSA9IG5ldyBBcnJheShNQVhfQklUUyArIDEpOwogICAgICAgIHZhciBjb2RlID0gMDsKICAgICAgICB2YXIgYml0czsKICAgICAgICB2YXIgbjsKICAgICAgICBmb3IgKGJpdHMgPSAxOyBiaXRzIDw9IE1BWF9CSVRTOyBiaXRzKyspIHsKICAgICAgICAgIG5leHRfY29kZVtiaXRzXSA9IGNvZGUgPSBjb2RlICsgYmxfY291bnRbYml0cyAtIDFdIDw8IDE7CiAgICAgICAgfQogICAgICAgIGZvciAobiA9IDA7IG4gPD0gbWF4X2NvZGU7IG4rKykgewogICAgICAgICAgdmFyIGxlbiA9IHRyZWVbbiAqIDIgKyAxXTsKICAgICAgICAgIGlmIChsZW4gPT09IDApIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICB0cmVlW24gKiAyXSA9IGJpX3JldmVyc2UobmV4dF9jb2RlW2xlbl0rKywgbGVuKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgZnVuY3Rpb24gdHJfc3RhdGljX2luaXQoKSB7CiAgICAgICAgdmFyIG47CiAgICAgICAgdmFyIGJpdHM7CiAgICAgICAgdmFyIGxlbmd0aDsKICAgICAgICB2YXIgY29kZTsKICAgICAgICB2YXIgZGlzdDsKICAgICAgICB2YXIgYmxfY291bnQgPSBuZXcgQXJyYXkoTUFYX0JJVFMgKyAxKTsKICAgICAgICBsZW5ndGggPSAwOwogICAgICAgIGZvciAoY29kZSA9IDA7IGNvZGUgPCBMRU5HVEhfQ09ERVMgLSAxOyBjb2RlKyspIHsKICAgICAgICAgIGJhc2VfbGVuZ3RoW2NvZGVdID0gbGVuZ3RoOwogICAgICAgICAgZm9yIChuID0gMDsgbiA8IDEgPDwgZXh0cmFfbGJpdHNbY29kZV07IG4rKykgewogICAgICAgICAgICBfbGVuZ3RoX2NvZGVbbGVuZ3RoKytdID0gY29kZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgX2xlbmd0aF9jb2RlW2xlbmd0aCAtIDFdID0gY29kZTsKICAgICAgICBkaXN0ID0gMDsKICAgICAgICBmb3IgKGNvZGUgPSAwOyBjb2RlIDwgMTY7IGNvZGUrKykgewogICAgICAgICAgYmFzZV9kaXN0W2NvZGVdID0gZGlzdDsKICAgICAgICAgIGZvciAobiA9IDA7IG4gPCAxIDw8IGV4dHJhX2RiaXRzW2NvZGVdOyBuKyspIHsKICAgICAgICAgICAgX2Rpc3RfY29kZVtkaXN0KytdID0gY29kZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZGlzdCA+Pj0gNzsKICAgICAgICBmb3IgKDsgY29kZSA8IERfQ09ERVM7IGNvZGUrKykgewogICAgICAgICAgYmFzZV9kaXN0W2NvZGVdID0gZGlzdCA8PCA3OwogICAgICAgICAgZm9yIChuID0gMDsgbiA8IDEgPDwgZXh0cmFfZGJpdHNbY29kZV0gLSA3OyBuKyspIHsKICAgICAgICAgICAgX2Rpc3RfY29kZVsyNTYgKyBkaXN0KytdID0gY29kZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZm9yIChiaXRzID0gMDsgYml0cyA8PSBNQVhfQklUUzsgYml0cysrKSB7CiAgICAgICAgICBibF9jb3VudFtiaXRzXSA9IDA7CiAgICAgICAgfQogICAgICAgIG4gPSAwOwogICAgICAgIHdoaWxlIChuIDw9IDE0MykgewogICAgICAgICAgc3RhdGljX2x0cmVlW24gKiAyICsgMV0gPSA4OwogICAgICAgICAgbisrOwogICAgICAgICAgYmxfY291bnRbOF0rKzsKICAgICAgICB9CiAgICAgICAgd2hpbGUgKG4gPD0gMjU1KSB7CiAgICAgICAgICBzdGF0aWNfbHRyZWVbbiAqIDIgKyAxXSA9IDk7CiAgICAgICAgICBuKys7CiAgICAgICAgICBibF9jb3VudFs5XSsrOwogICAgICAgIH0KICAgICAgICB3aGlsZSAobiA8PSAyNzkpIHsKICAgICAgICAgIHN0YXRpY19sdHJlZVtuICogMiArIDFdID0gNzsKICAgICAgICAgIG4rKzsKICAgICAgICAgIGJsX2Nvd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gICAgIH0KICAgICAgICBmb3IgKG4gPSAwOyBuIDwgQkxfQ09ERVM7IG4rKykgewogICAgICAgICAgcy5ibF90cmVlW24gKiAyXSA9IDA7CiAgICAgICAgfQogICAgICAgIHMuZHluX2x0cmVlW0VORF9CTE9DSyAqIDJdID0gMTsKICAgICAgICBzLm9wdF9sZW4gPSBzLnN0YXRpY19sZW4gPSAwOwogICAgICAgIHMubGFzdF9saXQgPSBzLm1hdGNoZXMgPSAwOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGJpX3dpbmR1cChzKSB7CiAgICAgICAgaWYgKHMuYmlfdmFsaWQgPiA4KSB7CiAgICAgICAgICBwdXRfc2hvcnQocywgcy5iaV9idWYpOwogICAgICAgIH0gZWxzZSBpZiAocy5iaV92YWxpZCA+IDApIHsKICAgICAgICAgIHMucGVuZGluZ19idWZbcy5wZW5kaW5nKytdID0gcy5iaV9idWY7CiAgICAgICAgfQogICAgICAgIHMuYmlfYnVmID0gMDsKICAgICAgICBzLmJpX3ZhbGlkID0gMDsKICAgICAgfQogICAgICBmdW5jdGlvbiBjb3B5X2Jsb2NrKHMsIGJ1ZiwgbGVuLCBoZWFkZXIpIHsKICAgICAgICBiaV93aW5kdXAocyk7CiAgICAgICAgaWYgKGhlYWRlcikgewogICAgICAgICAgcHV0X3Nob3J0KHMsIGxlbik7CiAgICAgICAgICBwdXRfc2hvcnQocywgfmxlbik7CiAgICAgICAgfQogICAgICAgIHV0aWxzLmFycmF5U2V0KHMucGVuZGluZ19idWYsIHMud2luZG93LCBidWYsIGxlbiwgcy5wZW5kaW5nKTsKICAgICAgICBzLnBlbmRpbmcgKz0gbGVuOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIHNtYWxsZXIodHJlZSwgbiwgbSwgZGVwdGgpIHsKICAgICAgICB2YXIgX24yID0gbiAqIDI7CiAgICAgICAgdmFyIF9tMiA9IG0gKiAyOwogICAgICAgIHJldHVybiB0cmVlW19uMl0gPCB0cmVlW19tMl0gfHwgdHJlZVtfbjJdID09PSB0cmVlW19tMl0gJiYgZGVwdGhbbl0gPD0gZGVwdGhbbV07CiAgICAgIH0KICAgICAgZnVuY3Rpb24gcHFkb3duaGVhcChzLCB0cmVlLCBrKSB7CiAgICAgICAgdmFyIHYgPSBzLmhlYXBba107CiAgICAgICAgdmFyIGogPSBrIDw8IDE7CiAgICAgICAgd2hpbGUgKGogPD0gcy5oZWFwX2xlbikgewogICAgICAgICAgaWYgKGogPCBzLmhlYXBfbGVuICYmIHNtYWxsZXIodHJlZSwgcy5oZWFwW2ogKyAxXSwgcy5oZWFwW2pdLCBzLmRlcHRoKSkgewogICAgICAgICAgICBqKys7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoc21hbGxlcih0cmVlLCB2LCBzLmhlYXBbal0sIHMuZGVwdGgpKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgcy5oZWFwW2tdID0gcy5oZWFwW2pdOwogICAgICAgICAgayA9IGo7CiAgICAgICAgICBqIDw8PSAxOwogICAgICAgIH0KICAgICAgICBzLmhlYXBba10gPSB2OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGNvbXByZXNzX2Jsb2NrKHMsIGx0cmVlLCBkdHJlZSkgewogICAgICAgIHZhciBkaXN0OwogICAgICAgIHZhciBsYzsKICAgICAgICB2YXIgbHggPSAwOwogICAgICAgIHZhciBjb2RlOwogICAgICAgIHZhciBleHRyYTsKICAgICAgICBpZiAocy5sYXN0X2xpdCAhPT0gMCkgewogICAgICAgICAgZG8gewogICAgICAgICAgICBkaXN0ID0gcy5wZW5kaW5nX2J1ZltzLmRfYnVmICsgbHggKiAyXSA8PCA4IHwgcy5wZW5kaW5nX2J1ZltzLmRfYnVmICsgbHggKiAyICsgMV07CiAgICAgICAgICAgIGxjID0gcy5wZW5kaW5nX2J1ZltzLmxfYnVmICsgbHhdOwogICAgICAgICAgICBseCsrOwogICAgICAgICAgICBpZiAoZGlzdCA9PT0gMCkgewogICAgICAgICAgICAgIHNlbmRfY29kZShzLCBsYywgbHRyZWUpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGNvZGUgPSBfbGVuZ3RoX2NvZGVbbGNdOwogICAgICAgICAgICAgIHNlbmRfY29kZShzLCBjb2RlICsgTElURVJBTFMgKyAxLCBsdHJlZSk7CiAgICAgICAgICAgICAgZXh0cmEgPSBleHRyYV9sYml0c1tjb2RlXTsKICAgICAgICAgICAgICBpZiAoZXh0cmEgIT09IDApIHsKICAgICAgICAgICAgICAgIGxjIC09IGJhc2VfbGVuZ3RoW2NvZGVdOwogICAgICAgICAgICAgICAgc2VuZF9iaXRzKHMsIGxjLCBleHRyYSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGRpc3QtLTsKICAgICAgICAgICAgICBjb2RlID0gZF9jb2RlKGRpc3QpOwogICAgICAgICAgICAgIHNlbmRfY29kZShzLCBjb2RlLCBkdHJlZSk7CiAgICAgICAgICAgICAgZXh0cmEgPSBleHRyYV9kYml0c1tjb2RlXTsKICAgICAgICAgICAgICBpZiAoZXh0cmEgIT09IDApIHsKICAgICAgICAgICAgICAgIGRpc3QgLT0gYmFzZV9kaXN0W2NvZGVdOwogICAgICAgICAgICAgICAgc2VuZF9iaXRzKHMsIGRpc3QsIGV4dHJhKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gd2hpbGUgKGx4IDwgcy5sYXN0X2xpdCk7CiAgICAgICAgfQogICAgICAgIHNlbmRfY29kZShzLCBFTkRfQkxPQ0ssIGx0cmVlKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBidWlsZF90cmVlKHMsIGRlc2MpIHsKICAgICAgICB2YXIgdHJlZSA9IGRlc2MuZHluX3RyZWU7CiAgICAgICAgdmFyIHN0cmVlID0gZGVzYy5zdGF0X2Rlc2Muc3RhdGljX3RyZWU7CiAgICAgICAgdmFyIGhhc19zdHJlZSA9IGRlc2Muc3RhdF9kZXNjLmhhc19zdHJlZTsKICAgICAgICB2YXIgZWxlbXMgPSBkZXNjLnN0YXRfZGVzYy5lbGVtczsKICAgICAgICB2YXIgbiwgbTsKICAgICAgICB2YXIgbWF4X2NvZGUgPSAtMTsKICAgICAgICB2YXIgbm9kZTsKICAgICAgICBzLmhlYXBfbGVuID0gMDsKICAgICAgICBzLmhlYXBfbWF4ID0gSEVBUF9TSVpFOwogICAgICAgIGZvciAobiA9IDA7IG4gPCBlbGVtczsgbisrKSB7CiAgICAgICAgICBpZiAodHJlZVtuICogMl0gIT09IDApIHsKICAgICAgICAgICAgcy5oZWFwWysrcy5oZWFwX2xlbl0gPSBtYXhfY29kZSA9IG47CiAgICAgICAgICAgIHMuZGVwdGhbbl0gPSAwOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgdHJlZVtuICogMiArIDFdID0gMDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgd2hpbGUgKHMuaGVhcF9sZW4gPCAyKSB7CiAgICAgICAgICBub2RlID0gcy5oZWFwWysrcy5oZWFwX2xlbl0gPSBtYXhfY29kZSA8IDIgPyArK21heF9jb2RlIDogMDsKICAgICAgICAgIHRyZWVbbm9kZSAqIDJdID0gMTsKICAgICAgICAgIHMuZGVwdGhbbm9kZV0gPSAwOwogICAgICAgICAgcy5vcHRfbGVuLS07CiAgICAgICAgICBpZiAoaGFzX3N0cmVlKSB7CiAgICAgICAgICAgIHMuc3RhdGljX2xlbiAtPSBzdHJlZVtub2RlICogMiArIDFdOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBkZXNjLm1heF9jb2RlID0gbWF4X2NvZGU7CiAgICAgICAgZm9yIChuID0gcy5oZWFwX2xlbiA+PiAxOyBuID49IDE7IG4tLSkgewogICAgICAgICAgcHFkb3duaGVhcChzLCB0cmVlLCBuKTsKICAgICAgICB9CiAgICAgICAgbm9kZSA9IGVsZW1zOwogICAgICAgIGRvIHsKICAgICAgICAgIG4gPSBzLmhlYXBbMV07CiAgICAgICAgICBzLmhlYXBbMV0gPSBzLmhlYXBbcy5oZWFwX2xlbi0tXTsKICAgICAgICAgIHBxZG93bmhlYXAocywgdHJlZSwgMSk7CiAgICAgICAgICBtID0gcy5oZWFwWzFdOwogICAgICAgICAgcy5oZWFwWy0tcy5oZWFwX21heF0gPSBuOwogICAgICAgICAgcy5oZWFwWy0tcy5oZWFwX21heF0gPSBtOwogICAgICAgICAgdHJlZVtub2RlICogMl0gPSB0cmVlW24gKiAyXSArIHRyZWVbbSAqIDJdOwogICAgICAgICAgcy5kZXB0aFtub2RlXSA9IChzLmRlcHRoW25dID49IHMuZGVwdGhbbV0gPyBzLmRlcHRoW25dIDogcy5kZXB0aFttXSkgKyAxOwogICAgICAgICAgdHJlZVtuICogMiArIDFdID0gdHJlZVttICogMiArIDFdID0gbm9kZTsKICAgICAgICAgIHMuaGVhcFsxXSA9IG5vZGUrKzsKICAgICAgICAgIHBxZG93bmhlYXAocywgdHJlZSwgMSk7CiAgICAgICAgfSB3aGlsZSAocy5oZWFwX2xlbiA+PSAyKTsKICAgICAgICBzLmhlYXBbLS1zLmhlYXBfbWF4XSA9IHMuaGVhcFsxXTsKICAgICAgICBnZW5fYml0bGVuKHMsIGRlc2MpOwogICAgICAgIGdlbl9jb2Rlcyh0cmVlLCBtYXhfY29kZSwgcy5ibF9jb3VudCk7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gc2Nhbl90cmVlKHMsIHRyZWUsIG1heF9jb2RlKSB7CiAgICAgICAgdmFyIG47CiAgICAgICAgdmFyIHByZXZsZW4gPSAtMTsKICAgICAgICB2YXIgY3VybGVuOwogICAgICAgIHZhciBuZXh0bGVuID0gdHJlZVswICogMiArIDFdOwogICAgICAgIHZhciBjb3VudCA9IDA7CiAgICAgICAgdmFyIG1heF9jb3VudCA9IDc7CiAgICAgICAgdmFyIG1pbl9jb3VudCA9IDQ7CiAgICAgICAgaWYgKG5leHRsZW4gPT09IDApIHsKICAgICAgICAgIG1heF9jb3VudCA9IDEzODsKICAgICAgICAgIG1pbl9jb3VudCA9IDM7CiAgICAgICAgfQogICAgICAgIHRyZWVbKG1heF9jb2RlICsgMSkgKiAyICsgMV0gPSA2NTUzNTsKICAgICAgICBmb3IgKG4gPSAwOyBuIDw9IG1heF9jb2RlOyBuKyspIHsKICAgICAgICAgIGN1cmxlbiA9IG5leHRsZW47CiAgICAgICAgICBuZXh0bGVuID0gdHJlZVsobiArIDEpICogMiArIDFdOwogICAgICAgICAgaWYgKCsrY291bnQgPCBtYXhfY291bnQgJiYgY3VybGVuID09PSBuZXh0bGVuKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfSBlbHNlIGlmIChjb3VudCA8IG1pbl9jb3VudCkgewogICAgICAgICAgICBzLmJsX3RyZWVbY3VybGVuICogMl0gKz0gY291bnQ7CiAgICAgICAgICB9IGVsc2UgaWYgKGN1cmxlbiAhPT0gMCkgewogICAgICAgICAgICBpZiAoY3VybGVuICE9PSBwcmV2bGVuKSB7CiAgICAgICAgICAgICAgcy5ibF90cmVlW2N1cmxlbiAqIDJdKys7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcy5ibF90cmVlW1JFUF8zXzYgKiAyXSsrOwogICAgICAgICAgfSBlbHNlIGlmIChjb3VudCA8PSAxMCkgewogICAgICAgICAgICBzLmJsX3RyZWVbUkVQWl8zXzEwICogMl0rKzsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHMuYmxfdHJlZVtSRVBaXzExXzEzOCAqIDJdKys7CiAgICAgICAgICB9CiAgICAgICAgICBjb3VudCA9IDA7CiAgICAgICAgICBwcmV2bGVuID0gY3VybGVuOwogICAgICAgICAgaWYgKG5leHRsZW4gPT09IDApIHsKICAgICAgICAgICAgbWF4X2NvdW50ID0gMTM4OwogICAgICAgICAgICBtaW5fY291bnQgPSAzOwogICAgICAgICAgfSBlbHNlIGlmIChjdXJsZW4gPT09IG5leHRsZW4pIHsKICAgICAgICAgICAgbWF4X2NvdW50ID0gNjsKICAgICAgICAgICAgbWluX2NvdW50ID0gMzsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIG1heF9jb3VudCA9IDc7CiAgICAgICAgICAgIG1pbl9jb3VudCA9IDQ7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIGZ1bmN0aW9uIHNlbmRfdHJlZShzLCB0cmVlLCBtYXhfY29kZSkgewogICAgICAgIHZhciBuOwogICAgICAgIHZhciBwcmV2bGVuID0gLTE7CiAgICAgICAgdmFyIGN1cmxlbjsKICAgICAgICB2YXIgbmV4dGxlbiA9IHRyZWVbMCAqIDIgKyAxXTsKICAgICAgICB2YXIgY291bnQgPSAwOwogICAgICAgIHZhciBtYXhfY291bnQgPSA3OwogICAgICAgIHZhciBtaW5fY291bnQgPSA0OwogICAgICAgIGlmIChuZXh0bGVuID09PSAwKSB7CiAgICAgICAgICBtYXhfY291bnQgPSAxMzg7CiAgICAgICAgICBtaW5fY291bnQgPSAzOwogICAgICAgIH0KICAgICAgICBmb3IgKG4gPSAwOyBuIDw9IG1heF9jb2RlOyBuKyspIHsKICAgICAgICAgIGN1cmxlbiA9IG5leHRsZW47CiAgICAgICAgICBuZXh0bGVuID0gdHJlZVsobiArIDEpICogMiArIDFdOwogICAgICAgICAgaWYgKCsrY291bnQgPCBtYXhfY291bnQgJiYgY3VybGVuID09PSBuZXh0bGVuKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfSBlbHNlIGlmIChjb3VudCA8IG1pbl9jb3VudCkgewogICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgc2VuZF9jb2RlKHMsIGN1cmxlbiwgcy5ibF90cmVlKTsKICAgICAgICAgICAgfSB3aGlsZSAoLS1jb3VudCAhPT0gMCk7CiAgICAgICAgICB9IGVsc2UgaWYgKGN1cmxlbiAhPT0gMCkgewogICAgICAgICAgICBpZiAoY3VybGVuICE9PSBwcmV2bGVuKSB7CiAgICAgICAgICAgICAgc2VuZF9jb2RlKHMsIGN1cmxlbiwgcy5ibF90cmVlKTsKICAgICAgICAgICAgICBjb3VudC0tOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHNlbmRfY29kZShzLCBSRVBfM182LCBzLmJsX3RyZWUpOwogICAgICAgICAgICBzZW5kX2JpdHMocywgY291bnQgLSAzLCAyKTsKICAgICAgICAgIH0gZWxzZSBpZiAoY291bnQgPD0gMTApIHsKICAgICAgICAgICAgc2VuZF9jb2RlKHMsIFJFUFpfM18xMCwgcy5ibF90cmVlKTsKICAgICAgICAgICAgc2VuZF9iaXRzKHMsIGNvdW50IC0gMywgMyk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzZW5kX2NvZGUocywgUkVQWl8xMV8xMzgsIHMuYmxfdHJlZSk7CiAgICAgICAgICAgIHNlbmRfYml0cyhzLCBjb3VudCAtIDExLCA3KTsKICAgICAgICAgIH0KICAgICAgICAgIGNvdW50ID0gMDsKICAgICAgICAgIHByZXZsZW4gPSBjdXJsZW47CiAgICAgICAgICBpZiAobmV4dGxlbiA9PT0gMCkgewogICAgICAgICAgICBtYXhfY291bnQgPSAxMzg7CiAgICAgICAgICAgIG1pbl9jb3VudCA9IDM7CiAgICAgICAgICB9IGVsc2UgaWYgKGN1cmxlbiA9PT0gbmV4dGxlbikgewogICAgICAgICAgICBtYXhfY291bnQgPSA2OwogICAgICAgICAgICBtaW5fY291bnQgPSAzOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgbWF4X2NvdW50ID0gNzsKICAgICAgICAgICAgbWluX2NvdW50ID0gNDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgZnVuY3Rpb24gYnVpbGRfYmxfdHJlZShzKSB7CiAgICAgICAgdmFyIG1heF9ibGluZGV4OwogICAgICAgIHNjYW5fdHJlZShzLCBzLmR5bl9sdHJlZSwgcy5sX2Rlc2MubWF4X2NvZGUpOwogICAgICAgIHNjYW5fdHJlZShzLCBzLmR5bl9kdHJlZSwgcy5kX2Rlc2MubWF4X2NvZGUpOwogICAgICAgIGJ1aWxkX3RyZWUocywgcy5ibF9kZXNjKTsKICAgICAgICBmb3IgKG1heF9ibGluZGV4ID0gQkxfQ09ERVMgLSAxOyBtYXhfYmxpbmRleCA+PSAzOyBtYXhfYmxpbmRleC0tKSB7CiAgICAgICAgICBpZiAocy5ibF90cmVlW2JsX29yZGVyW21heF9ibGluZGV4XSAqIDIgKyAxXSAhPT0gMCkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcy5vcHRfbGVuICs9IDMgKiAobWF4X2JsaW5kZXggKyAxKSArIDUgKyA1ICsgNDsKICAgICAgICByZXR1cm4gbWF4X2JsaW5kZXg7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gc2VuZF9hbGxfdHJlZXMocywgbGNvZGVzLCBkY29kZXMsIGJsY29kZXMpIHsKICAgICAgICB2YXIgcmFuazsKICAgICAgICBzZW5kX2JpdHMocywgbGNvZGVzIC0gMjU3LCA1KTsKICAgICAgICBzZW5kX2JpdHMocywgZGNvZGVzIC0gMSwgNSk7CiAgICAgICAgc2VuZF9iaXRzKHMsIGJsY29kZXMgLSA0LCA0KTsKICAgICAgICBmb3IgKHJhbmsgPSAwOyByYW5rIDwgYmxjb2RlczsgcmFuaysrKSB7CiAgICAgICAgICBzZW5kX2JpdHMocywgcy5ibF90cmVlW2JsX29yZGVyW3JhbmtdICogMiArIDFdLCAzKTsKICAgICAgICB9CiAgICAgICAgc2VuZF90cmVlKHMsIHMuZHluX2x0cmVlLCBsY29kZXMgLSAxKTsKICAgICAgICBzZW5kX3RyZWUocywgcy5keW5fZHRyZWUsIGRjb2RlcyAtIDEpOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRldGVjdF9kYXRhX3R5cGUocykgewogICAgICAgIHZhciBibGFja19tYXNrID0gNDA5MzYyNDQ0NzsKICAgICAgICB2YXIgbjsKICAgICAgICBmb3IgKG4gPSAwOyBuIDw9IDMxOyBuKyssIGJsYWNrX21hc2sgPj4+PSAxKSB7CiAgICAgICAgICBpZiAoYmxhY2tfbWFzayAmIDEgJiYgcy5keW5fbHRyZWVbbiAqIDJdICE9PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBaX0JJTkFSWTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHMuZHluX2x0cmVlWzkgKiAyXSAhPT0gMCB8fCBzLmR5bl9sdHJlZVsxMCAqIDJdICE9PSAwIHx8IHMuZHluX2x0cmVlWzEzICogMl0gIT09IDApIHsKICAgICAgICAgIHJldHVybiBaX1RFWFQ7CiAgICAgICAgfQogICAgICAgIGZvciAobiA9IDMyOyBuIDwgTElURVJBTFM7IG4rKykgewogICAgICAgICAgaWYgKHMuZHluX2x0cmVlW24gKiAyXSAhPT0gMCkgewogICAgICAgICAgICByZXR1cm4gWl9URVhUOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gWl9CSU5BUlk7CiAgICAgIH0KICAgICAgdmFyIHN0YXRpY19pbml0X2RvbmUgPSBmYWxzZTsKICAgICAgZnVuY3Rpb24gX3RyX2luaXQocykgewogICAgICAgIGlmICghc3RhdGljX2luaXRfZG9uZSkgewogICAgICAgICAgdHJfc3RhdGljX2luaXQoKTsKICAgICAgICAgIHN0YXRpY19pbml0X2RvbmUgPSB0cnVlOwogICAgICAgIH0KICAgICAgICBzLmxfZGVzYyA9IG5ldyBUcmVlRGVzYyhzLmR5bl9sdHJlZSwgc3RhdGljX2xfZGVzYyk7CiAgICAgICAgcy5kX2Rlc2MgPSBuZXcgVHJlZURlc2Mocy5keW5fZHRyZWUsIHN0YXRpY19kX2Rlc2MpOwogICAgICAgIHMuYmxfZGVzYyA9IG5ldyBUcmVlRGVzYyhzLmJsX3RyZWUsIHN0YXRpY19ibF9kZXNjKTsKICAgICAgICBzLmJpX2J1ZiA9IDA7CiAgICAgICAgcy5iaV92YWxpZCA9IDA7CiAgICAgICAgaW5pdF9ibG9jayhzKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBfdHJfc3RvcmVkX2Jsb2NrKHMsIGJ1Ziwgc3RvcmVkX2xlbiwgbGFzdCkgewogICAgICAgIHNlbmRfYml0cyhzLCAoU1RPUkVEX0JMT0NLIDw8IDEpICsgKGxhc3QgPyAxIDogMCksIDMpOwogICAgICAgIGNvcHlfYmxvY2socywgYnVmLCBzdG9yZWRfbGVuLCB0cnVlKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBfdHJfYWxpZ24ocykgewogICAgICAgIHNlbmRfYml0cyhzLCBTVEFUSUNfVFJFRVMgPDwgMSwgMyk7CiAgICAgICAgc2VuZF9jb2RlKHMsIEVORF9CTE9DSywgc3RhdGljX2x0cmVlKTsKICAgICAgICBiaV9mbHVzaChzKTsKICAgICAgfQogICAgICBmdW5jdGlvbiBfdHJfZmx1c2hfYmxvY2socywgYnVmLCBzdG9yZWRfbGVuLCBsYXN0KSB7CiAgICAgICAgdmFyIG9wdF9sZW5iLCBzdGF0aWNfbGVuYjsKICAgICAgICB2YXIgbWF4X2JsaW5kZXggPSAwOwogICAgICAgIGlmIChzLmxldmVsID4gMCkgewogICAgICAgICAgaWYgKHMuc3RybS5kYXRhX3R5cGUgPT09IFpfVU5LTk9XTikgewogICAgICAgICAgICBzLnN0cm0uZGF0YV90eXBlID0gZGV0ZWN0X2RhdGFfdHlwZShzKTsKICAgICAgICAgIH0KICAgICAgICAgIGJ1aWxkX3RyZWUocywgcy5sX2Rlc2MpOwogICAgICAgICAgYnVpbGRfdHJlZShzLCBzLmRfZGVzYyk7CiAgICAgICAgICBtYXhfYmxpbmRleCA9IGJ1aWxkX2JsX3RyZWUocyk7CiAgICAgICAgICBvcHRfbGVuYiA9IHMub3B0X2xlbiArIDMgKyA3ID4+PiAzOwogICAgICAgICAgc3RhdGljX2xlbmIgPSBzLnN0YXRpY19sZW4gKyAzICsgNyA+Pj4gMzsKICAgICAgICAgIGlmIChzdGF0aWNfbGVuYiA8PSBvcHRfbGVuYikgewogICAgICAgICAgICBvcHRfbGVuYiA9IHN0YXRpY19sZW5iOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBvcHRfbGVuYiA9IHN0YXRpY19sZW5iID0gc3RvcmVkX2xlbiArIDU7CiAgICAgICAgfQogICAgICAgIGlmIChzdG9yZWRfbGVuICsgNCA8PSBvcHRfbGVuYiAmJiBidWYgIT09IC0xKSB7CiAgICAgICAgICBfdHJfc3RvcmVkX2Jsb2NrKHMsIGJ1Ziwgc3RvcmVkX2xlbiwgbGFzdCk7CiAgICAgICAgfSBlbHNlIGlmIChzLnN0cmF0ZWd5ID09PSBaX0ZJWEVEIHx8IHN0YXRpY19sZW5iID09PSBvcHRfbGVuYikgewogICAgICAgICAgc2VuZF9iaXRzKHMsIChTVEFUSUNfVFJFRVMgPDwgMSkgKyAobGFzdCA/IDEgOiAwKSwgMyk7CiAgICAgICAgICBjb21wcmVzc19ibG9jayhzLCBzdGF0aWNfbHRyZWUsIHN0YXRpY19kdHJlZSk7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHNlbmRfYml0cyhzLCAoRFlOX1RSRUVTIDw8IDEpICsgKGxhc3QgPyAxIDogMCksIDMpOwogICAgICAgICAgc2VuZF9hbGxfdHJlZXMocywgcy5sX2Rlc2MubWF4X2NvZGUgKyAxLCBzLmRfZGVzYy5tYXhfY29kZSArIDEsIG1heF9ibGluZGV4ICsgMSk7CiAgICAgICAgICBjb21wcmVzc19ibG9jayhzLCBzLmR5bl9sdHJlZSwgcy5keW5fZHRyZWUpOwogICAgICAgIH0KICAgICAgICBpbml0X2Jsb2NrKHMpOwogICAgICAgIGlmIChsYXN0KSB7CiAgICAgICAgICBiaV93aW5kdXAocyk7CiAgICAgICAgfQogICAgICB9CiAgICAgIGZ1bmN0aW9uIF90cl90YWxseShzLCBkaXN0LCBsYykgewogICAgICAgIHMucGVuZGluZ19idWZbcy5kX2J1ZiArIHMubGFzdF9saXQgKiAyXSA9IGRpc3QgPj4+IDgg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vYWRsZXIzMi5qcyIoZXhwb3J0czIsIG1vZHVsZTIpIHsKICAgICAgaW5pdF9idWZmZXJfc2hpbSgpOwogICAgICAidXNlIHN0cmljdCI7CiAgICAgIGZ1bmN0aW9uIGFkbGVyMzIoYWRsZXIsIGJ1ZiwgbGVuLCBwb3MpIHsKICAgICAgICB2YXIgczEgPSBhZGxlciAmIDY1NTM1IHwgMCwgczIgPSBhZGxlciA+Pj4gMTYgJiA2NTUzNSB8IDAsIG4gPSAwOwogICAgICAgIHdoaWxlIChsZW4gIT09IDApIHsKICAgICAgICAgIG4gPSBsZW4gPiAyZTMgPyAyZTMgOiBsZW47CiAgICAgICAgICBsZW4gLT0gbjsKICAgICAgICAgIGRvIHsKICAgICAgICAgICAgczEgPSBzMSArIGJ1Zltwb3MrK10gfCAwOwogICAgICAgICAgICBzMiA9IHMyICsgczEgfCAwOwogICAgICAgICAgfSB3aGlsZSAoLS1uKTsKICAgICAgICAgIHMxICU9IDY1NTIxOwogICAgICAgICAgczIgJT0gNjU1MjE7CiAgICAgICAgfQogICAgICAgIHJldHVybiBzMSB8IHMyIDw8IDE2IHwgMDsKICAgICAgfQogICAgICBtb2R1bGUyLmV4cG9ydHMgPSBhZGxlcjMyOwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLnBucG0vcGFrb0AxLjAuMTEvbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvY3JjMzIuanMKICB2YXIgcmVxdWlyZV9jcmMzMiA9IF9fY29tbW9uSlMoewogICAgIm5vZGVfbW9kdWxlcy8ucG5wbS9wYWtvQDEuMC4xMS9ub2RlX21vZHVsZXMvcGFrby9saWIvemxpYi9jcmMzMi5qcyIoZXhwb3J0czIsIG1vZHVsZTIpIHsKICAgICAgaW5pdF9idWZmZXJfc2hpbSgpOwogICAgICAidXNlIHN0cmljdCI7CiAgICAgIGZ1bmN0aW9uIG1ha2VUYWJsZSgpIHsKICAgICAgICB2YXIgYywgdGFibGUgPSBbXTsKICAgIC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V9TVEFURSA9IDczOwogICAgICB2YXIgQ09NTUVOVF9TVEFURSA9IDkxOwogICAgICB2YXIgSENSQ19TVEFURSA9IDEwMzsKICAgICAgdmFyIEJVU1lfU1RBVEUgPSAxMTM7CiAgICAgIHZhciBGSU5JU0hfU1RBVEUgPSA2NjY7CiAgICAgIHZhciBCU19ORUVEX01PUkUgPSAxOwogICAgICB2YXIgQlNfQkxPQ0tfRE9ORSA9IDI7CiAgICAgIHZhciBCU19GSU5JU0hfU1RBUlRFRCA9IDM7CiAgICAgIHZhciBCU19GSU5JU0hfRE9ORSA9IDQ7CiAgICAgIHZhciBPU19DT0RFID0gMzsKICAgICAgZnVuY3Rpb24gZXJyKHN0cm0sIGVycm9yQ29kZSkgewogICAgICAgIHN0cm0ubXNnID0gbXNnW2Vycm9yQ29kZV07CiAgICAgICAgcmV0dXJuIGVycm9yQ29kZTsKICAgICAgfQogICAgICBmdW5jdGlvbiByYW5rKGYpIHsKICAgICAgICByZXR1cm4gKGYgPDwgMSkgLSAoZiA+IDQgPyA5IDogMCk7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gemVybyhidWYpIHsKICAgICAgICB2YXIgbGVuID0gYnVmLmxlbmd0aDsKICAgICAgICB3aGlsZSAoLS1sZW4gPj0gMCkgewogICAgICAgICAgYnVmW2xlbl0gPSAwOwogICAgICAgIH0KICAgICAgfQogICAgICBmdW5jdGlvbiBmbHVzaF9wZW5kaW5nKHN0cm0pIHsKICAgICAgICB2YXIgcyA9IHN0cm0uc3RhdGU7CiAgICAgICAgdmFyIGxlbiA9IHMucGVuZGluZzsKICAgICAgICBpZiAobGVuID4gc3RybS5hdmFpbF9vdXQpIHsKICAgICAgICAgIGxlbiA9IHN0cm0uYXZhaWxfb3V0OwogICAgICAgIH0KICAgICAgICBpZiAobGVuID09PSAwKSB7CiAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIHV0aWxzLmFycmF5U2V0KHN0cm0ub3V0cHV0LCBzLnBlbmRpbmdf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AgbGVuID0gc2l6ZTsKICAgICAgICB9CiAgICAgICAgaWYgKGxlbiA9PT0gMCkgewogICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgfQogICAgICAgIHN0cm0uYXZhaWxfaW4gLT0gbGVuOwogICAgICAgIHV0aWxzLmFycmF5U2V0KGJ1Ziwgc3RybS5pbnB1dCwgc3RybS5uZXh0X2luLCBsZW4sIHN0YXJ0KTsKICAgICAgICBpZiAoc3RybS5zdGF0ZS53cmFwID09PSAxKSB7CiAgICAgICAgICBzdHJtLmFkbGVyID0gYWRsZXIzMihzdHJtLmFkbGVyLCBidWYsIGxlbiwgc3RhcnQpOwogICAgICAgIH0gZWxzZSBpZiAoc3RybS5zdGF0ZS53cmFwID09PSAyKSB7CiAgICAgICAgICBzdHJtLmFkbGVyID0gY3JjMzIoc3RybS5hZGxlciwgYnVmLCBsZW4sIHN0YXJ0KTsKICAgICAgICB9CiAgICAgICAgc3RybS5uZXh0X2luICs9IGxlbjsKICAgICAgICBzdHJtLnRvdGFsX2luICs9IGxlbjsKICAgICAgICByZXR1cm4gbGVuOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGxvbmdlc3RfbWF0Y2gocywgY3VyX21hdGNoKSB7CiAgICAgICAgdmFyIGNoYWluX2xlbmd0aCA9IHMubWF4X2NoYWluX2xlbmd0aDsKICAgICAgICB2YXIgc2NhbiA9IHMuc3Ryc3RhcnQ7CiAgICAgICAgdmFyIG1hdGNoOwogICAgICAgIHZhciBsZW47CiAgICAgICAgdmFyIGJlc3RfbGVuID0gcy5wcmV2X2xlbmd0aDsKICAgICAgICB2YXIgbmljZV9tYXRjaCA9IHMubmljZV9tYXRjaDsKICAgICAgICB2YXIgbGltaXQgPSBzLnN0cnN0YXJ0ID4gcy53X3NpemUgLSBNSU5fTE9PS0FIRUFEID8gcy5zdHJzdGFydCAtIChzLndfc2l6ZSAtIE1JTl9MT09LQUhFQUQpIDogMDsKICAgICAgICB2YXIgX3dpbiA9IHMud2luZG93OwogICAgICAgIHZhciB3bWFzayA9IHMud19tYXNrOwogICAgICAgIHZhciBwcmV2ID0gcy5wcmV2OwogICAgICAgIHZhciBzdHJlbmQgPSBzLnN0cnN0YXJ0ICsgTUFYX01BVENIOwogICAgICAgIHZhciBzY2FuX2VuZDEgPSBfd2luW3NjYW4gKyBiZXN0X2xlbiAtIDFdOwogICAgICAgIHZhciBzY2FuX2VuZCA9IF93aW5bc2NhbiArIGJlc3RfbGVuXTsKICAgICAgICBpZiAocy5wcmV2X2xlbmd0aCA+PSBzLmdvb2RfbWF0Y2gpIHsKICAgICAgICAgIGNoYWluX2xlbmd0aCA+Pj0gMjsKICAgICAgICB9CiAgICAgICAgaWYgKG5pY2VfbWF0Y2ggPiBzLmxvb2thaGVhZCkgewogICAgICAgICAgbmljZV9tYXRjaCA9IHMubG9va2FoZWFkOwogICAgICAgIH0KICAgICAgICBkbyB7CiAgICAgICAgICBtYXRjaCA9IGN1cl9tYXRjaDsKICAgICAgICAgIGlmIChfd2luW21hdGNoICsgYmVzdF9sZW5dICE9PSBzY2FuX2VuZCB8fCBfd2luW21hdGNoICsgYmVzdF9sZW4gLSAxXSAhPT0gc2Nhbl9lbmQxIHx8IF93aW5bbWF0Y2hdICE9PSBfd2luW3NjYW5dIHx8IF93aW5bKyttYXRjaF0gIT09IF93aW5bc2NhbiArIDFdKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgc2NhbiArPSAyOwogICAgICAgICAgbWF0Y2grKzsKICAgICAgICAgIGRvIHsKICAgICAgICAgIH0gd2hpbGUgKF93aW5bKytzY2FuXSA9PT0gX3dpblsrK21hdGNoXSAmJiBfd2luWysrc2Nhbl0gPT09IF93aW5bKyttYXRjaF0gJiYgX3dpblsrK3NjYW5dID09PSBfd2luWysrbWF0Y2hdICYmIF93aW5bKytzY2FuXSA9PT0gX3dpblsrK21hdGNoXSAmJiBfd2luWysrc2Nhbl0gPT09IF93aW5bKyttYXRjaF0gJiYgX3dpblsrK3NjYW5dID09PSBfd2luWysrbWF0Y2hdICYmIF93aW5bKytzY2FuXSA9PT0gX3dpblsrK21hdGNoXSAmJiBfd2luWysrc2Nhbl0gPT09IF93aW5bKyttYXRjaF0gJiYgc2NhbiA8IHN0cmVuZCk7CiAgICAgICAgICBsZW4gPSBNQVhfTUFUQ0ggLSAoc3RyZW5kIC0gc2Nhbik7CiAgICAgICAgICBzY2FuID0gc3RyZW5kIC0gTUFYX01BVENIOwogICAgICAgICAgaWYgKGxlbiA+IGJlc3RfbGVuKSB7CiAgICAgICAgICAgIHMubWF0Y2hfc3RhcnQgPSBjdXJfbWF0Y2g7CiAgICAgICAgICAgIGJlc3RfbGVuID0gbGVuOwogICAgICAgICAgICBpZiAobGVuID49IG5pY2VfbWF0Y2gpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBzY2FuX2VuZDEgPSBfd2luW3NjYW4gKyBiZXN0X2xlbiAtIDFdOwogICAgICAgICAgICBzY2FuX2VuZCA9IF93aW5bc2NhbiArIGJlc3RfbGVuXTsKICAgICAgICAgIH0KICAgICAgICB9IHdoaWxlICgoY3VyX21hdGNoID0gcHJldltjdXJfbWF0Y2ggJiB3bWFza10pID4gbGltaXQgJiYgLS1jaGFpbl9sZW5ndGggIT09IDApOwogICAgICAgIGlmIChiZXN0X2xlbiA8PSBzLmxvb2thaGVhZCkgewogICAgICAgICAgcmV0dXJuIGJlc3RfbGVuOwogICAgICAgIH0KICAgICAgICByZXR1cm4gcy5sb29rYWhlYWQ7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZmlsbF93aW5kb3cocykgewogICAgICAgIHZhciBfd19zaXplID0gcy53X3NpemU7CiAgICAgICAgdmFyIHAsIG4sIG0sIG1vcmUsIHN0cjsKICAgICAgICBkbyB7CiAgICAgICAgICBtb3JlID0gcy53aW5kb3dfc2l6ZSAtIHMubG9va2FoZWFkIC0gcy5zdHJzdGFydDsKICAgICAgICAgIGlmIChzLnN0cnN0YXJ0ID49IF93X3NpemUgKyAoX3dfc2l6ZSAtIE1JTl9MT09LQUhFQUQpKSB7CiAgICAgICAgICAgIHV0aWxzLmFycmF5U2V0KHMud2luZG93LCBzLndpbmRvdywgX3dfc2l6ZSwgX3dfc2l6ZSwgMCk7CiAgICAgICAgICAgIHMubWF0Y2hfc3RhcnQgLT0gX3dfc2l6ZTsKICAgICAgICAgICAgcy5zdHJzdGFydCAtPSBfd19zaXplOwogICAgICAgICAgICBzLmJsb2NrX3N0YXJ0IC09IF93X3NpemU7CiAgICAgICAgICAgIG4gPSBzLmhhc2hfc2l6ZTsKICAgICAgICAgICAgcCA9IG47CiAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICBtID0gcy5oZWFkWy0tcF07CiAgICAgICAgICAgICAgcy5oZWFkW3BdID0gbSA+PSBfd19zaXplID8gbSAtIF93X3NpemUgOiAwOwogICAgICAgICAgICB9IHdoaWxlICgtLW4pOwogICAgICAgICAgICBuID0gX3dfc2l6ZTsKICAgICAgICAgICAgcCA9IG47CiAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICBtID0gcy5wcmV2Wy0tcF07CiAgICAgICAgICAgICAgcy5wcmV2W3BdID0gbSA+PSBfd19zaXplID8gbSAtIF93X3NpemUgOiAwOwogICAgICAgICAgICB9IHdoaWxlICgtLW4pOwogICAgICAgICAgICBtb3JlICs9IF93X3NpemU7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX2luID09PSAwKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgbiA9IHJlYWRfYnVmKHMuc3RybSwgcy53aW5kb3csIHMuc3Ryc3RhcnQgKyBzLmxvb2thaGVhZCwgbW9yZSk7CiAgICAgICAgICBzLmxvb2thaGVhZCArPSBuOwogICAgICAgICAgaWYgKHMubG9va2FoZWFkICsgcy5pbnNlcnQgPj0gTUlOX01BVENIKSB7CiAgICAgICAgICAgIHN0ciA9IHMuc3Ryc3RhcnQgLSBzLmluc2VydDsKICAgICAgICAgICAgcy5pbnNfaCA9IHMud2luZG93W3N0cl07CiAgICAgICAgICAgIHMuaW5zX2ggPSAocy5pbnNfaCA8PCBzLmhhc2hfc2hpZnQgXiBzLndpbmRvd1tzdHIgKyAxXSkgJiBzLmhhc2hfbWFzazsKICAgICAgICAgICAgd2hpbGUgKHMuaW5zZXJ0KSB7CiAgICAgICAgICAgICAgcy5pbnNfaCA9IChzLmluc19oIDw8IHMuaGFzaF9zaGlmdCBeIHMud2luZG93W3N0ciArIE1JTl9NQVRDSCAtIDFdKSAmIHMuaGFzaF9tYXNrOwogICAgICAgICAgICAgIHMucHJldltzdHIgJiBzLndfbWFza10gPSBzLmhlYWRbcy5pbnNfaF07CiAgICAgICAgICAgICAgcy5oZWFkW3MuaW5zX2hdID0gc3RyOwogICAgICAgICAgICAgIHN0cisrOwogICAgICAgICAgICAgIHMuaW5zZXJ0LS07CiAgICAgICAgICAgICAgaWYgKHMubG9va2FoZWFkICsgcy5pbnNlcnQgPCBNSU5fTUFUQ0gpIHsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gd2hpbGUgKHMubG9va2FoZWFkIDwgTUlOX0xPT0tBSEVBRCAmJiBzLnN0cm0uYXZhaWxfaW4gIT09IDApOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRlZmxhdGVfc3RvcmVkKHMsIGZsdXNoKSB7CiAgICAgICAgdmFyIG1heF9ibG9ja19zaXplID0gNjU1MzU7CiAgICAgICAgaWYgKG1heF9ibG9ja19zaXplID4gcy5wZW5kaW5nX2J1Zl9zaXplIC0gNSkgewogICAgICAgICAgbWF4X2Jsb2NrX3NpemUgPSBzLnBlbmRpbmdfYnVmX3NpemUgLSA1OwogICAgICAgIH0KICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA8PSAxKSB7CiAgICAgICAgICAgIGZpbGxfd2luZG93KHMpOwogICAgICAgICAgICBpZiAocy5sb29rYWhlYWQgPT09IDAgJiYgZmx1c2ggPT09IFpfTk9fRkxVU0gpIHsKICAgICAgICAgICAgICByZXR1cm4gQlNfTkVFRF9NT1JFOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA9PT0gMCkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBzLnN0cnN0YXJ0ICs9IHMubG9va2FoZWFkOwogICAgICAgICAgcy5sb29rYWhlYWQgPSAwOwogICAgICAgICAgdmFyIG1heF9zdGFydCA9IHMuYmxvY2tfc3RhcnQgKyBtYXhfYmxvY2tfc2l6ZTsKICAgICAgICAgIGlmIChzLnN0cnN0YXJ0ID09PSAwIHx8IHMuc3Ryc3RhcnQgPj0gbWF4X3N0YXJ0KSB7CiAgICAgICAgICAgIHMubG9va2FoZWFkID0gcy5zdHJzdGFydCAtIG1heF9zdGFydDsKICAgICAgICAgICAgcy5zdHJzdGFydCA9IG1heF9zdGFydDsKICAgICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCBmYWxzZSk7CiAgICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKHMuc3Ryc3RhcnQgLSBzLmJsb2NrX3N0YXJ0ID49IHMud19zaXplIC0gTUlOX0xPT0tBSEVBRCkgewogICAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIGZhbHNlKTsKICAgICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgICByZXR1cm4gQlNfTkVFRF9NT1JFOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHMuaW5zZXJ0ID0gMDsKICAgICAgICBpZiAoZmx1c2ggPT09IFpfRklOSVNIKSB7CiAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIHRydWUpOwogICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgcmV0dXJuIEJTX0ZJTklTSF9TVEFSVEVEOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIEJTX0ZJTklTSF9ET05FOwogICAgICAgIH0KICAgICAgICBpZiAocy5zdHJzdGFydCA+IHMuYmxvY2tfc3RhcnQpIHsKICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgZmFsc2UpOwogICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgfQogICAgICBmdW5jdGlvbiBkZWZsYXRlX2Zhc3QocywgZmx1c2gpIHsKICAgICAgICB2YXIgaGFzaF9oZWFkOwogICAgICAgIHZhciBiZmx1c2g7CiAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICBpZiAocy5sb29rYWhlYWQgPCBNSU5fTE9PS0FIRUFEKSB7CiAgICAgICAgICAgIGZpbGxfd2luZG93KHMpOwogICAgICAgICAgICBpZiAocy5sb29rYWhlYWQgPCBNSU5fTE9PS0FIRUFEICYmIGZsdXNoID09PSBaX05PX0ZMVVNIKSB7CiAgICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAocy5sb29rYWhlYWQgPT09IDApIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaGFzaF9oZWFkID0gMDsKICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA+PSBNSU5fTUFUQ0gpIHsKICAgICAgIC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AgICAgICAgIGhhc2hfaGVhZCA9IHMucHJldltzLnN0cnN0YXJ0ICYgcy53X21hc2tdID0gcy5oZWFkW3MuaW5zX2hdOwogICAgICAgICAgICAgICAgcy5oZWFkW3MuaW5zX2hdID0gcy5zdHJzdGFydDsKICAgICAgICAgICAgICB9IHdoaWxlICgtLXMubWF0Y2hfbGVuZ3RoICE9PSAwKTsKICAgICAgICAgICAgICBzLnN0cnN0YXJ0Kys7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgcy5zdHJzdGFydCArPSBzLm1hdGNoX2xlbmd0aDsKICAgICAgICAgICAgICBzLm1hdGNoX2xlbmd0aCA9IDA7CiAgICAgICAgICAgICAgcy5pbnNfaCA9IHMud2luZG93W3Muc3Ryc3RhcnRdOwogICAgICAgICAgICAgIHMuaW5zX2ggPSAocy5pbnNfaCA8PCBzLmhhc2hfc2hpZnQgXiBzLndpbmRvd1tzLnN0cnN0YXJ0ICsgMV0pICYgcy5oYXNoX21hc2s7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGJmbHVzaCA9IHRyZWVzLl90cl90YWxseShzLCAwLCBzLndpbmRvd1tzLnN0cnN0YXJ0XSk7CiAgICAgICAgICAgIHMubG9va2FoZWFkLS07CiAgICAgICAgICAgIHMuc3Ryc3RhcnQrKzsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChiZmx1c2gpIHsKICAgICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCBmYWxzZSk7CiAgICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBzLmluc2VydCA9IHMuc3Ryc3RhcnQgPCBNSU5fTUFUQ0ggLSAxID8gcy5zdHJzdGFydCA6IE1JTl9NQVRDSCAtIDE7CiAgICAgICAgaWYgKGZsdXNoID09PSBaX0ZJTklTSCkgewogICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCB0cnVlKTsKICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBCU19GSU5JU0hfU1RBUlRFRDsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBCU19GSU5JU0hfRE9ORTsKICAgICAgICB9CiAgICAgICAgaWYgKHMubGFzdF9saXQpIHsKICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgZmFsc2UpOwogICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIEJTX0JMT0NLX0RPTkU7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZGVmbGF0ZV9zbG93KHMsIGZsdXNoKSB7CiAgICAgICAgdmFyIGhhc2hfaGVhZDsKICAgICAgICB2YXIgYmZsdXNoOwogICAgICAgIHZhciBtYXhfaW5zZXJ0OwogICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgaWYgKHMubG9va2FoZWFkIDwgTUlOX0xPT0tBSEVBRCkgewogICAgICAgICAgICBmaWxsX3dpbmRvdyhzKTsKICAgICAgICAgICAgaWYgKHMubG9va2FoZWFkIDwgTUlOX0xPT0tBSEVBRCAmJiBmbHVzaCA9PT0gWl9OT19GTFVTSCkgewogICAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHMubG9va2FoZWFkID09PSAwKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGhhc2hfaGVhZCA9IDA7CiAgICAgICAgICBpZiAocy5sb29rYWhlYWQgPj0gTUlOX01BVENIKSB7CiAgICAgICAgICAgI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A9IHMuc3Ryc3RhcnQgKyBzLmxvb2thaGVhZCAtIE1JTl9NQVRDSDsKICAgICAgICAgICAgYmZsdXNoID0gdHJlZXMuX3RyX3RhbGx5KHMsIHMuc3Ryc3RhcnQgLSAxIC0gcy5wcmV2X21hdGNoLCBzLnByZXZfbGVuZ3RoIC0gTUlOX01BVENIKTsKICAgICAgICAgICAgcy5sb29rYWhlYWQgLT0gcy5wcmV2X2xlbmd0aCAtIDE7CiAgICAgICAgICAgIHMucHJldl9sZW5ndGggLT0gMjsKICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgIGlmICgrK3Muc3Ryc3RhcnQgPD0gbWF4X2luc2VydCkgewogICAgICAgICAgICAgICAgcy5pbnNfaCA9IChzLmluc19oIDw8IHMuaGFzaF9zaGlmdCBeIHMud2luZG93W3Muc3Ryc3RhcnQgKyBNSU5fTUFUQ0ggLSAxXSkgJiBzLmhhc2hfbWFzazsKICAgICAgICAgICAgICAgIGhhc2hfaGVhZCA9IHMucHJldltzLnN0cnN0YXJ0ICYgcy53X21hc2tdID0gcy5oZWFkW3MuaW5zX2hdOwogICAgICAgICAgICAgICAgcy5oZWFkW3MuaW5zX2hdID0gcy5zdHJzdGFydDsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gd2hpbGUgKC0tcy5wcmV2X2xlbmd0aCAhPT0gMCk7CiAgICAgICAgICAgIHMubWF0Y2hfYXZhaWxhYmxlID0gMDsKICAgICAgICAgICAgcy5tYXRjaF9sZW5ndGggPSBNSU5fTUFUQ0ggLSAxOwogICAgICAgICAgICBzLnN0cnN0YXJ0Kys7CiAgICAgICAgICAgIGlmIChiZmx1c2gpIHsKICAgICAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIGZhbHNlKTsKICAgICAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSBpZiAocy5tYXRjaF9hdmFpbGFibGUpIHsKICAgICAgICAgICAgYmZsdXNoID0gdHJlZXMuX3RyX3RhbGx5KHMsIDAsIHMud2luZG93W3Muc3Ryc3RhcnQgLSAxXSk7CiAgICAgICAgICAgIGlmIChiZmx1c2gpIHsKICAgICAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIGZhbHNlKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBzLnN0cnN0YXJ0Kys7CiAgICAgICAgICAgIHMubG9va2FoZWFkLS07CiAgICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcy5tYXRjaF9hdmFpbGFibGUgPSAxOwogICAgICAgICAgICBzLnN0cnN0YXJ0Kys7CiAgICAgICAgICAgIHMubG9va2FoZWFkLS07CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChzLm1hdGNoX2F2YWlsYWJsZSkgewogICAgICAgICAgYmZsdXNoID0gdHJlZXMuX3RyX3RhbGx5KHMsIDAsIHMud2luZG93W3Muc3Ryc3RhcnQgLSAxXSk7CiAgICAgICAgICBzLm1hdGNoX2F2YWlsYWJsZSA9IDA7CiAgICAgICAgfQogICAgICAgIHMuaW5zZXJ0ID0gcy5zdHJzdGFydCA8IE1JTl9NQVRDSCAtIDEgPyBzLnN0cnN0YXJ0IDogTUlOX01BVENIIC0gMTsKICAgICAgICBpZiAoZmx1c2ggPT09IFpfRklOSVNIKSB7CiAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIHRydWUpOwogICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgcmV0dXJuIEJTX0ZJTklTSF9TVEFSVEVEOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIEJTX0ZJTklTSF9ET05FOwogICAgICAgIH0KICAgICAgICBpZiAocy5sYXN0X2xpdCkgewogICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCBmYWxzZSk7CiAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICByZXR1cm4gQlNfTkVFRF9NT1JFOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gQlNfQkxPQ0tfRE9ORTsKICAgICAgfQogICAgICBmdW5jdGlvbiBkZWZsYXRlX3JsZShzLCBmbHVzaCkgewogICAgICAgIHZhciBiZmx1c2g7CiAgICAgICAgdmFyIHByZXY7CiAgICAgICAgdmFyIHNjYW4sIHN0cmVuZDsKICAgICAgICB2YXIgX3dpbiA9IHMud2luZG93OwogICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgaWYgKHMubG9va2FoZWFkIDw9IE1BWF9NQVRDSCkgewogICAgICAgICAgICBmaWxsX3dpbmRvdyhzKTsKICAgICAgICAgICAgaWYgKHMubG9va2FoZWFkIDw9IE1BWF9NQVRDSCAmJiBmbHVzaCA9PT0gWl9OT19GTFVTSCkgewogICAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHMubG9va2FoZWFkID09PSAwKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHMubWF0Y2hfbGVuZ3RoID0gMDsKICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA+PSBNSU5fTUFUQ0ggJiYgcy5zdHJzdGFydCA+IDApIHsKICAgICAgICAgICAgc2NhbiA9IHMuc3Ryc3RhcnQgLSAxOwogICAgICAgICAgICBwcmV2ID0gX3dpbltzY2FuXTsKICAgICAgICAgICAgaWYgKHByZXYgPT09IF93aW5bKytzY2FuXSAmJiBwcmV2ID09PSBfd2luWysrc2Nhbl0gJiYgcHJldiA9PT0gX3dpblsrK3NjYW5dKSB7CiAgICAgICAgICAgICAgc3RyZW5kID0gcy5zdHJzdGFydCArIE1BWF9NQVRDSDsKICAgICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgfSB3aGlsZSAocHJldiA9PT0gX3dpblsrK3NjYW5dICYmIHByZXYgPT09IF93aW5bKytzY2FuXSAmJiBwcmV2ID09PSBfd2luWysrc2Nhbl0gJiYgcHJldiA9PT0gX3dpblsrK3NjYW5dICYmIHByZXYgPT09IF93aW5bKytzY2FuXSAmJiBwcmV2ID09PSBfd2luWysrc2Nhbl0gJiYgcHJldiA9PT0gX3dpblsrK3NjYW5dICYmIHByZXYgPT09IF93aW5bKytzY2FuXSAmJiBzY2FuIDwgc3RyZW5kKTsKICAgICAgICAgICAgICBzLm1hdGNoX2xlbmd0aCA9IE1BWF9NQVRDSCAtIChzdHJlbmQgLSBzY2FuKTsKICAgICAgICAgICAgICBpZiAocy5tYXRjaF9sZW5ndGggPiBzLmxvb2thaGVhZCkgewogICAgICAgICAgICAgICAgcy5tYXRjaF9sZW5ndGggPSBzLmxvb2thaGVhZDsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzLm1hdGNoX2xlbmd0aCA+PSBNSU5fTUFUQ0gpIHsKICAgICAgICAgICAgYmZsdXNoID0gdHJlZXMuX3RyX3RhbGx5KHMsIDEsIHMubWF0Y2hfbGVuZ3RoIC0gTUlOX01BVENIKTsKICAgICAgICAgICAgcy5sb29rYWhlYWQgLT0gcy5tYXRjaF9sZW5ndGg7CiAgICAgICAgICAgIHMuc3Ryc3RhcnQgKz0gcy5tYXRjaF9sZW5ndGg7CiAgICAgICAgICAgIHMubWF0Y2hfbGVuZ3RoID0gMDsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGJmbHVzaCA9IHRyZWVzLl90cl90YWxseShzLCAwLCBzLndpbmRvd1tzLnN0cnN0YXJ0XSk7CiAgICAgICAgICAgIHMubG9va2FoZWFkLS07CiAgICAgICAgICAgIHMuc3Ryc3RhcnQrKzsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChiZmx1c2gpIHsKICAgICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCBmYWxzZSk7CiAgICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBzLmluc2VydCA9IDA7CiAgICAgICAgaWYgKGZsdXNoID09PSBaX0ZJTklTSCkgewogICAgICAgICAgZmx1c2hfYmxvY2tfb25seShzLCB0cnVlKTsKICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBCU19GSU5JU0hfU1RBUlRFRDsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBCU19GSU5JU0hfRE9ORTsKICAgICAgICB9CiAgICAgICAgaWYgKHMubGFzdF9saXQpIHsKICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgZmFsc2UpOwogICAgICAgICAgaWYgKHMuc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgcmV0dXJuIEJTX05FRURfTU9SRTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIEJTX0JMT0NLX0RPTkU7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZGVmbGF0ZV9odWZmKHMsIGZsdXNoKSB7CiAgICAgICAgdmFyIGJmbHVzaDsKICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgIGlmIChzLmxvb2thaGVhZCA9PT0gMCkgewogICAgICAgICAgICBmaWxsX3dpbmRvdyhzKTsKICAgICAgICAgICAgaWYgKHMubG9va2FoZWFkID09PSAwKSB7CiAgICAgICAgICAgICAgaWYgKGZsdXNoID09PSBaX05PX0ZMVVNIKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gQlNfTkVFRF9NT1JFOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgcy5tYXRjaF9sZW5ndGggPSAwOwogICAgICAgICAgYmZsdXNoID0gdHJlZXMuX3RyX3RhbGx5KHMsIDAsIHMud2luZG93W3Muc3Ryc3RhcnRdKTsKICAgICAgICAgIHMubG9va2FoZWFkLS07CiAgICAgICAgICBzLnN0cnN0YXJ0Kys7CiAgICAgICAgICBpZiAoYmZsdXNoKSB7CiAgICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgZmFsc2UpOwogICAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcy5pbnNlcnQgPSAwOwogICAgICAgIGlmIChmbHVzaCA9PT0gWl9GSU5JU0gpIHsKICAgICAgICAgIGZsdXNoX2Jsb2NrX29ubHkocywgdHJ1ZSk7CiAgICAgICAgICBpZiAocy5zdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICByZXR1cm4gQlNfRklOSVNIX1NUQVJURUQ7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gQlNfRklOSVNIX0RPTkU7CiAgICAgICAgfQogICAgICAgIGlmIChzLmxhc3RfbGl0KSB7CiAgICAgICAgICBmbHVzaF9ibG9ja19vbmx5KHMsIGZhbHNlKTsKICAgICAgICAgIGlmIChzLnN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBCU19ORUVEX01PUkU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiBCU19CTE9DS19ET05FOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIENvbmZpZyhnb29kX2xlbmd0aC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RkxBVEVEOwogICAgICAgIHRoaXMubGFzdF9mbHVzaCA9IC0xOwogICAgICAgIHRoaXMud19zaXplID0gMDsKICAgICAgICB0aGlzLndfYml0cyA9IDA7CiAgICAgICAgdGhpcy53X21hc2sgPSAwOwogICAgICAgIHRoaXMud2luZG93ID0gbnVsbDsKICAgICAgICB0aGlzLndpbmRvd19zaXplID0gMDsKICAgICAgICB0aGlzLnByZXYgPSBudWxsOwogICAgICAgIHRoaXMuaGVhZCA9IG51bGw7CiAgICAgICAgdGhpcy5pbnNfaCA9IDA7CiAgICAgICAgdGhpcy5oYXNoX3NpemUgPSAwOwogICAgICAgIHRoaXMuaGFzaF9iaXRzID0gMDsKICAgICAgICB0aGlzLmhhc2hfbWFzayA9IDA7CiAgICAgICAgdGhpcy5oYXNoX3NoaWZ0ID0gMDsKICAgICAgICB0aGlzLmJsb2NrX3N0YXJ0ID0gMDsKICAgICAgICB0aGlzLm1hdGNoX2xlbmd0aCA9IDA7CiAgICAgICAgdGhpcy5wcmV2X21hdGNoID0gMDsKICAgICAgICB0aGlzLm1hdGNoX2F2YWlsYWJsZSA9IDA7CiAgICAgICAgdGhpcy5zdHJzdGFydCA9IDA7CiAgICAgICAgdGhpcy5tYXRjaF9zdGFydCA9IDA7CiAgICAgICAgdGhpcy5sb29rYWhlYWQgPSAwOwogICAgICAgIHRoaXMucHJldl9sZW5ndGggPSAwOwogICAgICAgIHRoaXMubWF4X2NoYWluX2xlbmd0aCA9IDA7CiAgICAgICAgdGhpcy5tYXhfbGF6eV9tYXRjaCA9IDA7CiAgICAgICAgdGhpcy5sZXZlbCA9IDA7CiAgICAgICAgdGhpcy5zdHJhdGVneSA9IDA7CiAgICAgICAgdGhpcy5nb29kX21hdGNoID0gMDsKICAgICAgICB0aGlzLm5pY2VfbWF0Y2ggPSAwOwogICAgICAgIHRoaXMuZHluX2x0cmVlID0gbmV3IHV0aWxzLkJ1ZjE2KEhFQVBfU0laRSAqIDIpOwogICAgICAgIHRoaXMuZHluX2R0cmVlID0gbmV3IHV0aWxzLkJ1ZjE2KCgyICogRF9DT0RFUyArIDEpICogMik7CiAgICAgICAgdGhpcy5ibF90cmVlID0gbmV3IHV0aWxzLkJ1ZjE2KCgyICogQkxfQ09ERVMgKyAxKSAqIDIpOwogICAgICAgIHplcm8odGhpcy5keW5fbHRyZWUpOwogICAgICAgIHplcm8odGhpcy5keW5fZHRyZWUpOwogICAgICAgIHplcm8odGhpcy5ibF90cmVlKTsKICAgICAgICB0aGlzLmxfZGVzYyA9IG51bGw7CiAgICAgICAgdGhpcy5kX2Rlc2MgPSBudWxsOwogICAgICAgIHRoaXMuYmxfZGVzYyA9IG51bGw7CiAgICAgICAgdGhpcy5ibF9jb3VudCA9IG5ldyB1dGlscy5CdWYxNihNQVhfQklUUyArIDEpOwogICAgICAgIHRoaXMuaGVhcCA9IG5ldyB1dGlscy5CdWYxNigyICogTF9DT0RFUyArIDEpOwogICAgICAgIHplcm8odGhpcy5oZWFwKTsKICAgICAgICB0aGlzLmhlYXBfbGVuID0gMDsKICAgICAgICB0aGlzLmhlYXBfbWF4ID0gMDsKICAgICAgICB0aGlzLmRlcHRoID0gbmV3IHV0aWxzLkJ1ZjE2KDIgKiBMX0NPREVTICsgMSk7CiAgICAgICAgemVybyh0aGlzLmRlcHRoKTsKICAgICAgICB0aGlzLmxfYnVmID0gMDsKICAgICAgICB0aGlzLmxpdF9idWZzaXplID0gMDsKICAgICAgICB0aGlzLmxhc3RfbGl0ID0gMDsKICAgICAgICB0aGlzLmRfYnVmID0gMDsKICAgICAgICB0aGlzLm9wdF9sZW4gPSAwOwogICAgICAgIHRoaXMuc3RhdGljX2xlbiA9IDA7CiAgICAgICAgdGhpcy5tYXRjaGVzID0gMDsKICAgICAgICB0aGlzLmluc2VydCA9IDA7CiAgICAgICAgdGhpcy5iaV9idWYgPSAwOwogICAgICAgIHRoaXMuYmlfdmFsaWQgPSAwOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRlZmxhdGVSZXNldEtlZXAoc3RybSkgewogICAgICAgIHZhciBzOwogICAgICAgIGlmICghc3RybSB8fCAhc3RybS5zdGF0ZSkgewogICAgICAgICAgcmV0dXJuIGVycihzdHJtLCBaX1NUUkVBTV9FUlJPUik7CiAgICAgICAgfQogICAgICAgIHN0cm0udG90YWxfaW4gPSBzdHJtLnRvdGFsX291dCA9IDA7CiAgICAgICAgc3RybS5kYXRhX3R5cGUgPSBaX1VOS05PV047CiAgICAgICAgcyA9IHN0cm0uc3RhdGU7CiAgICAgICAgcy5wZW5kaW5nID0gMDsKICAgICAgICBzLnBlbmRpbmdfb3V0ID0gMDsKICAgICAgICBpZiAocy53cmFwIDwgMCkgewogICAgICAgICAgcy53cmFwID0gLXMud3JhcDsKICAgICAgICB9CiAgICAgICAgcy5zdGF0dXMgPSBzLndyYXAgPyBJTklUX1NUQVRFIDogQlVTWV9TVEFURTsKICAgICAgICBzdHJtLmFkbGVyID0gcy53cmFwID09PSAyID8gMCA6IDE7CiAgICAgICAgcy5sYXN0X2ZsdXNoID0gWl9OT19GTFVTSDsKICAgICAgICB0cmVlcy5fdHJfaW5pdChzKTsKICAgICAgICByZXR1cm4gWl9PSzsKICAgICAgfQogICAgICBmdW5jdGlvbiBkZWZsYXRlUmVzZXQoc3RybSkgewogICAgICAgIHZhciByZXQgPSBkZWZsYXRlUmVzZXRLZWVwKHN0cm0pOwogICAgICAgIGlmIChyZXQgPT09IFpfT0spIHsKICAgICAgICAgIGxtX2luaXQoc3RybS5zdGF0ZSk7CiAgICAgICAgfQogICAgICAgIHJldHVybiByZXQ7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZGVmbGF0ZVNldEhlYWRlcihzdHJtLCBoZWFkKSB7CiAgICAgICAgaWYgKCFzdHJtIHx8ICFzdHJtLnN0YXRlKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIGlmIChzdHJtLnN0YXRlLndyYXAgIT09IDIpIHsKICAgICAgICAgIHJldHVybiBaX1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgc3RybS5zdGF0ZS5nemhlYWQgPSBoZWFkOwogICAgICAgIHJldHVybiBaX09LOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGRlZmxhdGVJbml0MihzdHJtLCBsZXZlbCwgbWV0aG9kLCB3aW5kb3dCaXRzLCBtZW1MZXZlbCwgc3RyYXRlZ3kpIHsKICAgICAgICBpZiAoIXN0cm0pIHsKICAgICAgICAgIHJldHVybiBaX1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgdmFyIHdyYXAgPSAxOwogICAgICAgIGlmIChsZXZlbCA9PT0gWl9ERUZBVUxUX0NPTVBSRVNTSU9OKSB7CiAgICAgICAgICBsZXZlbCA9IDY7CiAgICAgICAgfQogICAgICAgIGlmICh3aW5kb3dCaXRzIDwgMCkgewogICAgICAgICAgd3JhcCA9IDA7CiAgICAgICAgICB3aW5kb3dCaXRzID0gLXdpbmRvd0JpdHM7CiAgICAgICAgfSBlbHNlIGlmICh3aW5kb3dCaXRzID4gMTUpIHsKICAgICAgICAgIHdyYXAgPSAyOwogICAgICAgICAgd2luZG93Qml0cyAtPSAxNjsKICAgICAgICB9CiAgICAgICAgaWYgKG1lbUxldmVsIDwgMSB8fCBtZW1MZXZlbCA+IE1BWF9NRU1fTEVWRUwgfHwgbWV0aG9kICE9PSBaX0RFRkxBVEVEIHx8IHdpbmRvd0JpdHMgPCA4IHx8IHdpbmRvd0JpdHMgPiAxNSB8fCBsZXZlbCA8IDAgfHwgbGV2ZWwgPiA5IHx8IHN0cmF0ZWd5IDwgMCB8fCBzdHJhdGVneSA+IFpfRklYRUQpIHsKICAgICAgICAgIHJldHVybiBlcnIoc3RybSwgWl9TVFJFQU1fRVJST1IpOwogICAgICAgIH0KICAgICAgICBpZiAod2luZG93Qml0cyA9PT0gOCkgewogICAgICAgICAgd2luZG93Qml0cyA9IDk7CiAgICAgICAgfQogICAgICAgIHZhciBzID0gbmV3IERlZmxhdGVTdGF0ZSgpOwogICAgICAgIHN0cm0uc3RhdGUgPSBzOwogICAgICAgIHMuc3RybSA9IHN0cm07CiAgICAgICAgcy53cmFwID0gd3JhcDsKICAgICAgICBzLmd6aGVhZCA9IG51bGw7CiAgICAgICAgcy53X2JpdHMgPSB3aW5kb3dCaXRzOwogICAgICAgIHMud19zaXplID0gMSA8PCBzLndfYml0czsKICAgICAgICBzLndfbWFzayA9IHMud19zaXplIC0gMTsKICAgICAgICBzLmhhc2hfYml0cyA9IG1lbUxldmVsICsgNzsKICAgICAgICBzLmhhc2hfc2l6ZSA9IDEgPDwgcy5oYXNoX2JpdHM7CiAgICAgICAgcy5oYXNoX21hc2sgPSBzLmhhc2hfc2l6ZSAtIDE7CiAgICAgICAgcy5oYXNoX3NoaWZ0ID0gfn4oKHMuaGFzaF9iaXRzICsgTUlOX01BVENIIC0gMSkgLyBNSU5fTUFUQ0gpOwogICAgICAgIHMud2luZG93ID0gbmV3IHV0aWxzLkJ1Zjgocy53X3NpemUgKiAyKTsKICAgICAgICBzLmhlYWQgPSBuZXcgdXRpbHMuQnVmMTYocy5oYXNoX3NpemUpOwogICAgICAgIHMucHJldiA9IG5ldyB1dGlscy5CdWYxNihzLndfc2l6ZSk7CiAgICAgICAgcy5saXRfYnVmc2l6ZSA9IDEgPDwgbWVtTGV2ZWwgKyA2OwogICAgICAgIHMucGVuZGluZ19idWZfc2l6ZSA9IHMubGl0X2J1ZnNpemUgKiA0OwogICAgICAgIHMucGVuZGluZ19idWYgPSBuZXcgdXRpbHMuQnVmOChzLnBlbmRpbmdfYnVmX3NpemUpOwogICAgICAgIHMuZF9idWYgPSAxICogcy5saXRfYnVmc2l6ZTsKICAgICAgICBzLmxfYnVmID0gKDEgKyAyKSAqIHMubGl0X2J1ZnNpemU7CiAgICAgICAgcy5sZXZlbCA9IGxldmVsOwogICAgICAgIHMuc3RyYXRlZ3kgPSBzdHJhdGVneTsKICAgICAgICBzLm1ldGhvZCA9IG1ldG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GxlciA9IDA7CiAgICAgICAgICAgIHB1dF9ieXRlKHMsIDMxKTsKICAgICAgICAgICAgcHV0X2J5dGUocywgMTM5KTsKICAgICAgICAgICAgcHV0X2J5dGUocywgOCk7CiAgICAgICAgICAgIGlmICghcy5nemhlYWQpIHsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCAwKTsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCAwKTsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCAwKTsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCAwKTsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCAwKTsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCBzLmxldmVsID09PSA5ID8gMiA6IHMuc3RyYXRlZ3kgPj0gWl9IVUZGTUFOX09OTFkgfHwgcy5sZXZlbCA8IDIgPyA0IDogMCk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgT1NfQ09ERSk7CiAgICAgICAgICAgICAgcy5zdGF0dXMgPSBCVVNZX1NUQVRFOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHB1dF9ieXRlKHMsIChzLmd6aGVhZC50ZXh0ID8gMSA6IDApICsgKHMuZ3poZWFkLmhjcmMgPyAyIDogMCkgKyAoIXMuZ3poZWFkLmV4dHJhID8gMCA6IDQpICsgKCFzLmd6aGVhZC5uYW1lID8gMCA6IDgpICsgKCFzLmd6aGVhZC5jb21tZW50ID8gMCA6IDE2KSk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgcy5nemhlYWQudGltZSAmIDI1NSk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgcy5nemhlYWQudGltZSA+PiA4ICYgMjU1KTsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCBzLmd6aGVhZC50aW1lID4+IDE2ICYgMjU1KTsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCBzLmd6aGVhZC50aW1lID4+IDI0ICYgMjU1KTsKICAgICAgICAgICAgICBwdXRfYnl0ZShzLCBzLmxldmVsID09PSA5ID8gMiA6IHMuc3RyYXRlZ3kgPj0gWl9IVUZGTUFOX09OTFkgfHwgcy5sZXZlbCA8IDIgPyA0IDogMCk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgcy5nemhlYWQub3MgJiAyNTUpOwogICAgICAgICAgICAgIGlmIChzLmd6aGVhZC5leHRyYSAmJiBzLmd6aGVhZC5leHRyYS5sZW5ndGgpIHsKICAgICAgICAgICAgICAgIHB1dF9ieXRlKHMsIHMuZ3poZWFkLmV4dHJhLmxlbmd0aCAmIDI1NSk7CiAgICAgICAgICAgICAgICBwdXRfYnl0ZShzLCBzLmd6aGVhZC5leHRyYS5sZW5ndGggPj4gOCAmIDI1NSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChzLmd6aGVhZC5oY3JjKSB7CiAgICAgICAgICAgICAgICBzdHJtLmFkbGVyID0gY3JjMzIoc3RybS5hZGxlciwgcy5wZW5kaW5nX2J1Ziwgcy5wZW5kaW5nLCAwKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgcy5nemluZGV4ID0gMDsKICAgICAgICAgICAgICBzLnN0YXR1cyA9IEVYVFJBX1NUQVRFOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICB2YXIgaGVhZGVyID0gWl9ERUZMQVRFRCArIChzLndfYml0cyAtIDggPDwgNCkgPDwgODsKICAgICAgICAgICAgdmFyIGxldmVsX2ZsYWdzID0gLTE7CiAgICAgICAgICAgIGlmIChzLnN0cmF0ZWd5ID49IFpfSFVGRk1BTl9PTkxZIHx8IHMubGV2ZWwgPCAyKSB7CiAgICAgICAgICAgICAgbGV2ZWxfZmxhZ3MgPSAwOwogICAgICAgICAgICB9IGVsc2UgaWYgKHMubGV2ZWwgPCA2KSB7CiAgICAgICAgICAgICAgbGV2ZWxfZmxhZ3MgPSAxOwogICAgICAgICAgICB9IGVsc2UgaWYgKHMubGV2ZWwgPT09IDYpIHsKICAgICAgICAgICAgICBsZXZlbF9mbGFncyA9IDI7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgbGV2ZWxfZmxhZ3MgPSAzOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGhlYWRlciB8PSBsZXZlbF9mbGFncyA8PCA2OwogICAgICAgICAgICBpZiAocy5zdHJzdGFydCAhPT0gMCkgewogICAgICAgICAgICAgIGhlYWRlciB8PSBQUkVTRVRfRElDVDsKICAgICAgICAgICAgfQogICAgICAgICAgICBoZWFkZXIgKz0gMzEgLSBoZWFkZXIgJSAzMTsKICAgICAgICAgICAgcy5zdGF0dXMgPSBCVVNZX1NUQVRFOwogICAgICAgICAgICBwdXRTaG9ydE1TQihzLCBoZWFkZXIpOwogICAgICAgICAgICBpZiAocy5zdHJzdGFydCAhPT0gMCkgewogICAgICAgICAgICAgIHB1dFNob3J0TVNCKHMsIHN0cm0uYWRsZXIgPj4+IDE2KTsKICAgICAgICAgICAgICBwdXRTaG9ydE1TQihzLCBzdHJtLmFkbGVyICYgNjU1MzUpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHN0cm0uYWRsZXIgPSAxOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAocy5zdGF0dXMgPT09IEVYVFJBX1NUQVRFKSB7CiAgICAgICAgICBpZiAocy5nemhlYWQuZXh0cmEpIHsKICAgICAgICAgICAgYmVnID0gcy5wZW5kaW5nOwogICAgICAgICAgICB3aGlsZSAocy5nemluZGV4IDwgKHMuZ3poZWFkLmV4dHJhLmxlbmd0aCAmIDY1NTM1KSkgewogICAgICAgICAgICAgIGlmIChzLnBlbmRpbmcgPT09IHMucGVuZGluZ19idWZfc2l6ZSkgewogICAgICAgICAgICAgICAgaWYgKHMuZ3poZWFkLmhjcmMgJiYgcy5wZW5kaW5nID4gYmVnKSB7CiAgICAgICAgICAgICAgICAgIHN0cm0uYWRsZXIgPSBjcmMzMihzdHJtLmFkbGVyLCBzLnBlbmRpbmdfYnVmLCBzLnBlbmRpbmcgLSBiZWcsIGJlZyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmbHVzaF9wZW5kaW5nKHN0cm0pOwogICAgICAgICAgICAgICAgYmVnID0gcy5wZW5kaW5nOwogICAgICAgICAgICAgICAgaWYgKHMucGVuZGluZyA9PT0gcy5wZW5kaW5nX2J1Zl9zaXplKSB7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBwdXRfYnl0ZShzLCBzLmd6aGVhZC5leHRyYVtzLmd6aW5kZXhdICYgMjU1KTsKICAgICAgICAgICAgICBzLmd6aW5kZXgrKzsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAocy5nemhlYWQuaGNyYyAmJiBzLnBlbmRpbmcgPiBiZWcpIHsKICAgICAgICAgICAgICBzdHJtLmFkbGVyID0gY3JjMzIoc3RybS5hZGxlciwgcy5wZW5kaW5nX2J1Ziwgcy5wZW5kaW5nIC0gYmVnLCBiZWcpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzLmd6aW5kZXggPT09IHMuZ3poZWFkLmV4dHJhLmxlbmd0aCkgewogICAgICAgICAgICAgIHMuZ3ppbmRleCA9IDA7CiAgICAgICAgICAgICAgcy5zdGF0dXMgPSBOQU1FX1NUQVRFOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzLnN0YXR1cyA9IE5BTUVfU1RBVEU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChzLnN0YXR1cyA9PT0gTkFNRV9TVEFURSkgewogICAgICAgICAgaWYgKHMuZ3poZWFkLm5hbWUpIHsKICAgICAgICAgICAgYmVnID0gcy5wZW5kaW5nOwogICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgaWYgKHMucGVuZGluZyA9PT0gcy5wZW5kaW5nX2J1Zl9zaXplKSB7CiAgICAgICAgICAgICAgICBpZiAocy5nemhlYWQuaGNyYyAmJiBzLnBlbmRpbmcgPiBiZWcpIHsKICAgICAgICAgICAgICAgICAgc3RybS5hZGxlciA9IGNyYzMyKHN0cm0uYWRsZXIsIHMucGVuZGluZ19idWYsIHMucGVuZGluZyAtIGJlZywgYmVnKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZsdXNoX3BlbmRpbmcoc3RybSk7CiAgICAgICAgICAgICAgICBiZWcgPSBzLnBlbmRpbmc7CiAgICAgICAgICAgICAgICBpZiAocy5wZW5kaW5nID09PSBzLnBlbmRpbmdfYnVmX3NpemUpIHsKICAgICAgICAgICAgICAgICAgdmFsID0gMTsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChzLmd6aW5kZXggPCBzLmd6aGVhZC5uYW1lLmxlbmd0aCkgewogICAgICAgICAgICAgICAgdmFsID0gcy5nemhlYWQubmFtZS5jaGFyQ29kZUF0KHMuZ3ppbmRleCsrKSAmIDI1NTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgdmFsID0gMDsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgdmFsKTsKICAgICAgICAgICAgfSB3aGlsZSAodmFsICE9PSAwKTsKICAgICAgICAgICAgaWYgKHMuZ3poZWFkLmhjcmMgJiYgcy5wZW5kaW5nID4gYmVnKSB7CiAgICAgICAgICAgICAgc3RybS5hZGxlciA9IGNyYzMyKHN0cm0uYWRsZXIsIHMucGVuZGluZ19idWYsIHMucGVuZGluZyAtIGJlZywgYmVnKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodmFsID09PSAwKSB7CiAgICAgICAgICAgICAgcy5nemluZGV4ID0gMDsKICAgICAgICAgICAgICBzLnN0YXR1cyA9IENPTU1FTlRfU1RBVEU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHMuc3RhdHVzID0gQ09NTUVOVF9TVEFURTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHMuc3RhdHVzID09PSBDT01NRU5UX1NUQVRFKSB7CiAgICAgICAgICBpZiAocy5nemhlYWQuY29tbWVudCkgewogICAgICAgICAgICBiZWcgPSBzLnBlbmRpbmc7CiAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICBpZiAocy5wZW5kaW5nID09PSBzLnBlbmRpbmdfYnVmX3NpemUpIHsKICAgICAgICAgICAgICAgIGlmIChzLmd6aGVhZC5oY3JjICYmIHMucGVuZGluZyA+IGJlZykgewogICAgICAgICAgICAgICAgICBzdHJtLmFkbGVyID0gY3JjMzIoc3RybS5hZGxlciwgcy5wZW5kaW5nX2J1Ziwgcy5wZW5kaW5nIC0gYmVnLCBiZWcpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZmx1c2hfcGVuZGluZyhzdHJtKTsKICAgICAgICAgICAgICAgIGJlZyA9IHMucGVuZGluZzsKICAgICAgICAgICAgICAgIGlmIChzLnBlbmRpbmcgPT09IHMucGVuZGluZ19idWZfc2l6ZSkgewogICAgICAgICAgICAgICAgICB2YWwgPSAxOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHMuZ3ppbmRleCA8IHMuZ3poZWFkLmNvbW1lbnQubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICB2YWwgPSBzLmd6aGVhZC5jb21tZW50LmNoYXJDb2RlQXQocy5nemluZGV4KyspICYgMjU1OwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICB2YWwgPSAwOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBwdXRfYnl0ZShzLCB2YWwpOwogICAgICAgICAgICB9IHdoaWxlICh2YWwgIT09IDApOwogICAgICAgICAgICBpZiAocy5nemhlYWQuaGNyYyAmJiBzLnBlbmRpbmcgPiBiZWcpIHsKICAgICAgICAgICAgICBzdHJtLmFkbGVyID0gY3JjMzIoc3RybS5hZGxlciwgcy5wZW5kaW5nX2J1Ziwgcy5wZW5kaW5nIC0gYmVnLCBiZWcpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICh2YWwgPT09IDApIHsKICAgICAgICAgICAgICBzLnN0YXR1cyA9IEhDUkNfU1RBVEU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHMuc3RhdHVzID0gSENSQ19TVEFURTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHMuc3RhdHVzID09PSBIQ1JDX1NUQVRFKSB7CiAgICAgICAgICBpZiAocy5nemhlYWQuaGNyYykgewogICAgICAgICAgICBpZiAocy5wZW5kaW5nICsgMiA+IHMucGVuZGluZ19idWZfc2l6ZSkgewogICAgICAgICAgICAgIGZsdXNoX3BlbmRpbmcoc3RybSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHMucGVuZGluZyArIDIgPD0gcy5wZW5kaW5nX2J1Zl9zaXplKSB7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgc3RybS5hZGxlciAmIDI1NSk7CiAgICAgICAgICAgICAgcHV0X2J5dGUocywgc3RybS5hZGxlciA+PiA4ICYgMjU1KTsKICAgICAgICAgICAgICBzdHJtLmFkbGVyID0gMDsKICAgICAgICAgICAgICBzLnN0YXR1cyA9IEJVU1lfU1RBVEU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHMuc3RhdHVzID0gQlVTWV9TVEFURTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHMucGVuZGluZyAhPT0gMCkgewogICAgICAgICAgZmx1c2hfcGVuZGluZyhzdHJtKTsKICAgICAgICAgIGlmIChzdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICB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ICAgICAgICAgICAgICBzLmxhc3RfZmx1c2ggPSAtMTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gWl9PSzsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChic3RhdGUgPT09IEJTX0JMT0NLX0RPTkUpIHsKICAgICAgICAgICAgaWYgKGZsdXNoID09PSBaX1BBUlRJQUxfRkxVU0gpIHsKICAgICAgICAgICAgICB0cmVlcy5fdHJfYWxpZ24ocyk7CiAgICAgICAgICAgIH0gZWxzZSBpZiAoZmx1c2ggIT09IFpfQkxPQ0spIHsKICAgICAgICAgICAgICB0cmVlcy5fdHJfc3RvcmVkX2Jsb2NrKHMsIDAsIDAsIGZhbHNlKTsKICAgICAgICAgICAgICBpZiAoZmx1c2ggPT09IFpfRlVMTF9GTFVTSCkgewogICAgICAgICAgICAgICAgemVybyhzLmhlYWQpOwogICAgICAgICAgICAgICAgaWYgKHMubG9va2FoZWFkID09PSAwKSB7CiAgICAgICAgICAgICAgICAgIHMuc3Ryc3RhcnQgPSAwOwogICAgICAgICAgICAgICAgICBzLmJsb2NrX3N0YXJ0ID0gMDsKICAgICAgICAgICAgICAgICAgcy5pbnNlcnQgPSAwOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBmbHVzaF9wZW5kaW5nKHN0cm0pOwogICAgICAgICAgICBpZiAoc3RybS5hdmFpbF9vdXQgPT09IDApIHsKICAgICAgICAgICAgICBzLmxhc3RfZmx1c2ggPSAtMTsKICAgICAgICAgICAgICByZXR1cm4gWl9PSzsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoZmx1c2ggIT09IFpfRklOSVNIKSB7CiAgICAgICAgICByZXR1cm4gWl9PSzsKICAgICAgICB9CiAgICAgICAgaWYgKHMud3JhcCA8PSAwKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRU5EOwogICAgICAgIH0KICAgICAgICBpZiAocy53cmFwID09PSAyKSB7CiAgICAgICAgICBwdXRfYnl0ZShzLCBzdHJtLmFkbGVyICYgMjU1KTsKICAgICAgICAgIHB1dF9ieXRlKHMsIHN0cm0uYWRsZXIgPj4gOCAmIDI1NSk7CiAgICAgICAgICBwdXRfYnl0ZShzLCBzdHJtLmFkbGVyID4+IDE2ICYgMjU1KTsKICAgICAgICAgIHB1dF9ieXRlKHMsIHN0cm0uYWRsZXIgPj4gMjQgJiAyNTUpOwogICAgICAgICAgcHV0X2J5dGUocywgc3RybS50b3RhbF9pbiAmIDI1NSk7CiAgICAgICAgICBwdXRfYnl0ZShzLCBzdHJtLnRvdGFsX2luID4+IDggJiAyNTUpOwogICAgICAgICAgcHV0X2J5dGUocywgc3RybS50b3RhbF9pbiA+PiAxNiAmIDI1NSk7CiAgICAgICAgICBwdXRfYnl0ZShzLCBzdHJtLnRvdGFsX2luID4+IDI0ICYgMjU1KTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgcHV0U2hvcnRNU0Iocywgc3RybS5hZGxlciA+Pj4gMTYpOwogICAgICAgICAgcHV0U2hvcnRNU0Iocywgc3RybS5hZGxlciAmIDY1NTM1KTsKICAgICAgICB9CiAgICAgICAgZmx1c2hfcGVuZGluZyhzdHJtKTsKICAgICAgICBpZiAocy53cmFwID4gMCkgewogICAgICAgICAgcy53cmFwID0gLXMud3JhcDsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHMucGVuZGluZyAhPT0gMCA/IFpfT0sgOiBaX1NUUkVBTV9FTkQ7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZGVmbGF0ZUVuZChzdHJtKSB7CiAgICAgICAgdmFyIHN0YXR1czsKICAgICAgICBpZiAoIXN0cm0gfHwgIXN0cm0uc3RhdGUpIHsKICAgICAgICAgIHJldHVybiBaX1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgc3RhdHVzID0gc3RybS5zdGF0ZS5zdGF0dXM7CiAgICAgICAgaWYgKHN0YXR1cyAhPT0gSU5JVF9TVEFURSAmJiBzdGF0dXMgIT09IEVYVFJBX1NUQVRFICYmIHN0YXR1cyAhPT0gTkFNRV9TVEFURSAmJiBzdGF0dXMgIT09IENPTU1FTlRfU1RBVEUgJiYgc3RhdHVzICE9PSBIQ1JDX1NUQVRFICYmIHN0YXR1cyAhPT0gQlVTWV9TVEFURSAmJiBzdGF0dXMgIT09IEZJTklTSF9TVEFURSkgewogICAgICAgICAgcmV0dXJuIGVycihzdHJtLCBaX1NUUkVBTV9FUlJPUik7CiAgICAgICAgfQogICAgICAgIHN0cm0uc3RhdGUgPSBudWxsOwogICAgICAgIHJldHVybiBzdGF0dXMgPT09IEJVU1lfU1RBVEUgPyBlcnIoc3RybSwgWl9EQVRBX0VSUk9SKSA6IFpfT0s7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gZGVmbGF0ZVNldERpY3Rpb25hcnkoc3RybSwgZGljdGlvbmFyeSkgewogICAgICAgIHZhciBkaWN0TGVuZ3RoID0gZGljdGlvbmFyeS5sZW5ndGg7CiAgICAgICAgdmFyIHM7CiAgICAgICAgdmFyIHN0ciwgbjsKICAgICAgICB2YXIgd3JhcDsKICAgICAgICB2YXIgYXZhaWw7CiAgICAgICAgdmFyIG5leHQ7CiAgICAgICAgdmFyIGlucHV0OwogICAgICAgIHZhciB0bXBEaWN0OwogICAgICAgIGlmICghc3RybSB8fCAhc3RybS5zdGF0ZSkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgIH0KICAgICAgICBzID0gc3RybS5zdGF0ZTsKICAgICAgICB3cmFwID0gcy53cmFwOwogICAgICAgIGlmICh3cmFwID09PSAyIHx8IHdyYXAgPT09IDEgJiYgcy5zdGF0dXMgIT09IElOSVRfU1RBVEUgfHwgcy5sb29rYWhlYWQpIHsKICAgICAgICAgIHJldHVybiBaX1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgaWYgKHdyYXAgPT09IDEpIHsKICAgICAgICAgIHN0cm0uYWRsZXIgPSBhZGxlcjMyKHN0cm0uYWRsZXIsIGRpY3Rpb25hcnksIGRpY3RMZW5ndGgsIDApOwogICAgICAgIH0KICAgICAgICBzLndyYXAgPSAwOwogICAgICAgIGlmIChkaWN0TGVuZ3RoID49IHMud19zaXplKSB7CiAgICAgICAgICBpZiAod3JhcCA9PT0gMCkgewogICAgICAgICAgICB6ZXJvKHMuaGVhZCk7CiAgICAgICAgICAgIHMuc3Ryc3RhcnQgPSAwOwogICAgICAgICAgICBzLmJsb2NrX3N0YXJ0ID0gMDsKICAgICAgICAgICAgcy5pbnNlcnQgPSAwOwogICAgICAgICAgfQogICAgICAgICAgdG1wRGljdCA9IG5ldyB1dGlscy5CdWY4KHMud19zaXplKTsKICAgICAgICAgIHV0aWxzLmFycmF5U2V0KHRtcERpY3QsIGRpY3Rpb25hcnksIGRpY3RMZW5ndGggLSBzLndfc2l6ZSwgcy53X3NpemUsIDApOwogICAgICAgICAgZGljdGlvbmFyeSA9IHRtcERpY3Q7CiAgICAgICAgICBkaWN0TGVuZ3RoID0gcy53X3NpemU7CiAgICAgICAgfQogICAgICAgIGF2YWlsID0gc3RybS5hdmFpbF9pbjsKICAgICAgICBuZXh0ID0gc3RybS5uZXh0X2luOwogICAgICAgIGlucHV0ID0gc3RybS5pbnB1dDsKICAgICAgICBzdHJtLmF2YWlsX2luID0gZGljdExlbmd0aDsKICAgICAgICBzdHJtLm5leHRfaW4gPSAwOwogICAgICAgIHN0cm0uaW5wdXQgPSBkaWN0aW9uYXJ5OwogICAgICAgIGZpbGxfd2luZG93KHMpOwogICAgICAgIHdoaWxlIChzLmxvb2thaGVhZCA+PSBNSU5fTUFUQ0gpIHsKICAgICAgICAgIHN0ciA9IHMuc3Ryc3RhcnQ7CiAgICAgICAgICBuID0gcy5sb29rYWhlYWQgLSAoTUlOX01BVENIIC0gMSk7CiAgICAgICAgICBkbyB7CiAgICAgICAgICAgIHMuaW5zX2ggPSAocy5pbnNfaCA8PCBzLmhhc2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bGVuKTsKICAgICAgICBmb3IgKGkgPSAwLCBtX3BvcyA9IDA7IGkgPCBidWZfbGVuOyBtX3BvcysrKSB7CiAgICAgICAgICBjID0gc3RyLmNoYXJDb2RlQXQobV9wb3MpOwogICAgICAgICAgaWYgKChjICYgNjQ1MTIpID09PSA1NTI5NiAmJiBtX3BvcyArIDEgPCBzdHJfbGVuKSB7CiAgICAgICAgICAgIGMyID0gc3RyLmNoYXJDb2RlQXQobV9wb3MgKyAxKTsKICAgICAgICAgICAgaWYgKChjMiAmIDY0NTEyKSA9PT0gNTYzMjApIHsKICAgICAgICAgICAgICBjID0gNjU1MzYgKyAoYyAtIDU1Mjk2IDw8IDEwKSArIChjMiAtIDU2MzIwKTsKICAgICAgICAgICAgICBtX3BvcysrOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYyA8IDEyOCkgewogICAgICAgICAgICBidWZbaSsrXSA9IGM7CiAgICAgICAgICB9IGVsc2UgaWYgKGMgPCAyMDQ4KSB7CiAgICAgICAgICAgIGJ1ZltpKytdID0gMTkyIHwgYyA+Pj4gNjsKICAgICAgICAgICAgYnVmW2krK10gPSAxMjggfCBjICYgNjM7CiAgICAgICAgICB9IGVsc2UgaWYgKGMgPCA2NTUzNikgewogICAgICAgICAgICBidWZbaSsrXSA9IDIyNCB8IGMgPj4+IDEyOwogICAgICAgICAgICBidWZbaSsrXSA9IDEyOCB8IGMgPj4+IDYgJiA2MzsKICAgICAgICAgICAgYnVmW2krK10gPSAxMjggfCBjICYgNjM7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBidWZbaSsrXSA9IDI0MCB8IGMgPj4+IDE4OwogICAgICAgICAgICBidWZbaSsrXSA9IDEyOCB8IGMgPj4+IDEyICYgNjM7CiAgICAgICAgICAgIGJ1ZltpKytdID0gMTI4IHwgYyA+Pj4gNiAmIDYzOwogICAgICAgICAgICBidWZbaSsrXSA9IDEyOCB8IGMgJiA2MzsKICAgICAgICAgIH0KICAg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ywgY19sZW47CiAgICAgICAgdmFyIGxlbiA9IG1heCB8fCBidWYubGVuZ3RoOwogICAgICAgIHZhciB1dGYxNmJ1ZiA9IG5ldyBBcnJheShsZW4gKiAyKTsKICAgICAgICBmb3IgKG91dCA9IDAsIGkgPSAwOyBpIDwgbGVuOyApIHsKICAgICAgICAgIGMgPSBidWZbaSsrXTsKICAgICAgICAgIGlmIChjIDwgMTI4KSB7CiAgICAgICAgICAgIHV0ZjE2YnVmW291dCsrXSA9IGM7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgY19sZW4gPSBfdXRmOGxlbltjXTsKICAgICAgICAgIGlmIChjX2xlbiA+IDQpIHsKICAgICAgICAgICAgdXRmMTZidWZbb3V0KytdID0gNjU1MzM7CiAgICAgICAgICAgIGkgKz0gY19sZW4gLSAxOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGMgJj0gY19sZW4gPT09IDIgPyAzMSA6IGNfbGVuID09PSAzID8gMTUgOiA3OwogICAgICAgICAgd2hpbGUgKGNfbGVuID4gMSAmJiBpIDwgbGVuKSB7CiAgICAgICAgICAgIGMgPSBjIDw8IDYgfCBidWZbaSsrXSAmIDYzOwogICAgICAgICAgICBjX2xlbi0tOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGNfbGVuID4gMSkgewogICAgICAgICAgICB1dGYxNmJ1ZltvdXQrK10gPSA2NTUzMzsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYyA8IDY1NTM2KSB7CiAgICAgICAgICAgIHV0ZjE2YnVmW291dCsrXSA9IGM7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjIC09IDY1NTM2OwogICAgICAgICAgICB1dGYxNmJ1ZltvdXQrK10gPSA1NTI5NiB8IGMgPj4gMTAgJiAxMDIzOwogICAgICAgICAgICB1dGYxNmJ1ZltvdXQrK10gPSA1NjMyMCB8IGMgJiAxMDIzOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gYnVmMmJpbnN0cmluZyh1dGYxNmJ1Ziwgb3V0KTsKICAgICAgfTsKICAgICAgZXhwb3J0czIudXRmOGJvcmRlciA9IGZ1bmN0aW9uKGJ1ZiwgbWF4KSB7CiAgICAgICAgdmFyIHBvczsKICAgICAgICBtYXggPSBtYXggfHwgYnVmLmxlbmd0aDsKICAgICAgICBpZiAobWF4ID4gYnVmLmxlbmd0aCkgewogICAgICAgICAgbWF4ID0gYnVmLmxlbmd0aDsKICAgICAgICB9CiAgICAgICAgcG9zID0gbWF4IC0gMTsKICAgICAgICB3aGlsZSAocG9zID49IDAgJiYgKGJ1Zltwb3NdICYgMTkyKSA9PT0gMTI4KSB7CiAgICAgICAgICBwb3MtLTsKICAgICAgICB9CiAgICAgICAgaWYgKHBvcyA8IDApIHsKICAgICAgICAgIHJldHVybiBtYXg7CiAgICAgICAgfQogICAgICAgIGlmIChwb3MgPT09IDApIHsKICAgICAgICAgIHJldHVybiBtYXg7CiAgICAgICAgfQogICAgICAgIHJldHVybiBwb3MgKyBfdXRmOGxlbltidWZbcG9zXV0gPiBtYXggPyBwb3MgOiBtYXg7CiAgICAgIH07CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8ucG5wbS9wYWtvQDEuMC4xMS9ub2RlX21vZHVsZXMvcGFrby9saWIvemxpYi96c3RyZWFtLmpzCiAgdmFyIHJlcXVpcmVfenN0cmVhbSA9IF9fY29tbW9uSlMoewogICAgIm5vZGVfbW9kdWxlcy8ucG5wbS9wYWtvQDEuMC4xMS9ub2RlX21vZHVsZXMvcGFrby9saWIvemxpYi96c3RyZWFtLmpzIihleHBvcnRzMiwgbW9kdWxlMikgewogICAgICBpbml0X2J1ZmZlcl9zaGltKCk7CiAgICAgICJ1c2Ugc3RyaWN0IjsKICAgICAgZnVuY3Rpb24gWlN0cmVhbSgpIHsKICAgICAgICB0aGlzLmlucHV0ID0gbnVsbDs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TFVTSCA9IDA7CiAgICAgIHZhciBaX0ZJTklTSCA9IDQ7CiAgICAgIHZhciBaX09LID0gMDsKICAgICAgdmFyIFpfU1RSRUFNX0VORCA9IDE7CiAgICAgIHZhciBaX1NZTkNfRkxVU0gyID0gMjsKICAgICAgdmFyIFpfREVGQVVMVF9DT01QUkVTU0lPTiA9IC0xOwogICAgICB2YXIgWl9ERUZBVUxUX1NUUkFURUdZID0gMDsKICAgICAgdmFyIFpfREVGTEFURUQgPSA4OwogICAgICBmdW5jdGlvbiBEZWZsYXRlKG9wdGlvbnMpIHsKICAgICAgICBpZiAoISh0aGlzIGluc3RhbmNlb2YgRGVmbGF0ZSkpCiAgICAgICAgICByZXR1cm4gbmV3IERlZmxhdGUob3B0aW9ucyk7CiAgICAgICAgdGhpcy5vcHRpb25zID0gdXRpbHMuYXNzaWduKHsKICAgICAgICAgIGxldmVsOiBaX0RFRkFVTFRfQ09NUFJFU1NJT04sCiAgICAgICAgICBtZXRob2Q6IFpfREVGTEFURUQsCiAgICAgICAgICBjaHVua1NpemU6IDE2Mzg0LAogICAgICAgICAgd2luZG93Qml0czogMTUsCiAgICAgICAgICBtZW1MZXZlbDogOCwKICAgICAgICAgIHN0cmF0ZWd5OiBaX0RFRkFVTFRfU1RSQVRFR1ksCiAgICAgICAgICB0bzogIiIKICAgICAgICB9LCBvcHRpb25zIHx8IHt9KTsKICAgICAgICB2YXIgb3B0ID0gdGhpcy5vcHRpb25zOwogICAgICAgIGlmIChvcHQucmF3ICYmIG9wdC53aW5kb3dCaXRzID4gMCkgewogICAgICAgICAgb3B0LndpbmRvd0JpdHMgPSAtb3B0LndpbmRvd0JpdHM7CiAgICAgICAgfSBlbHNlIGlmIChvcHQuZ3ppcCAmJiBvcHQud2luZG93Qml0cyA+IDAgJiYgb3B0LndpbmRvd0JpdHMgPCAxNikgewogICAgICAgICAgb3B0LndpbmRvd0JpdHMgKz0gMTY7CiAgICAgICAgfQogICAgICAgIHRoaXMuZXJyID0gMDsKICAg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ZS5kZWZsYXRlU2V0RGljdGlvbmFyeSh0aGlzLnN0cm0sIGRpY3QpOwogICAgICAgICAgaWYgKHN0YXR1cyAhPT0gWl9PSykgewogICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IobXNnW3N0YXR1c10pOwogICAgICAgICAgfQogICAgICAgICAgdGhpcy5fZGljdF9zZXQgPSB0cnVlOwogICAgICAgIH0KICAgICAgfQogICAgICBEZWZsYXRlLnByb3RvdHlwZS5wdXNoID0gZnVuY3Rpb24oZGF0YSwgbW9kZSkgewogICAgICAgIHZhciBzdHJtID0gdGhpcy5zdHJtOwogICAgICAgIHZhciBjaHVua1NpemUgPSB0aGlzLm9wdGlvbnMuY2h1bmtTaXplOwogICAgICAgIHZhciBzdGF0dXMsIF9tb2RlOwogICAgICAgIGlmICh0aGlzLmVuZGVkKSB7CiAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfQogICAgICAgIF9tb2RlID0gbW9kZSA9PT0gfn5tb2RlID8gbW9kZSA6IG1vZGUgPT09IHRydWUgPyBaX0ZJTklTSCA6IFpfTk9fRkxVU0g7CiAgICAgICAgaWYgKHR5cGVvZiBkYXRhID09PSAic3RyaW5nIikgewogICAgICAgICAgc3RybS5pbnB1dCA9IHN0cmluZ3Muc3RyaW5nMmJ1ZihkYXRhKTsKICAgICAgICB9IGVsc2UgaWYgKHRvU3RyaW5nLmNhbGwoZGF0YSkgPT09ICJbb2JqZWN0IEFycmF5QnVmZmVyXSIpIHsKICAgICAgICAgIHN0cm0uaW5wdXQgPSBuZXcgVWludDhBcnJheShkYXRhKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgc3RybS5pbnB1dCA9IGRhdGE7CiAgICAgICAgfQogICAgICAgIHN0cm0ubmV4dF9pbiA9IDA7CiAgICAgICAgc3RybS5hdmFpbF9pbiA9IHN0cm0uaW5wdXQubGVuZ3RoOwogICAgICAgIGRvIHsKICAgICAgICAgIGlmIChzdHJtLmF2YWlsX291dCA9PT0gMCkgewogICAgICAgICAgICBzdHJtLm91dHB1dCA9IG5ldyB1dGlscy5CdWY4KGNodW5rU2l6ZSk7CiAgICAgICAgICAgIHN0cm0ubmV4dF9vdXQgPSAwOwogICAgICAgICAgICBzdHJtLmF2YWlsX291dCA9IGNodW5rU2l6ZTsKICAgICAgICAgIH0KICAgICAgICAgIHN0YXR1cyA9IHpsaWJfZGVmbGF0ZS5kZWZsYXRlKHN0cm0sIF9tb2RlKTsKICAgICAgICAgIGlmIChzdGF0dXMgIT09IFpfU1RSRUFNX0VORCAmJiBzdGF0dXMgIT09IFpfT0spIHsKICAgICAgICAgICAgdGhpcy5vbkVuZChzdGF0dXMpOwogICAgICAgICAgICB0aGlzLmVuZGVkID0gdHJ1ZTsKICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHN0cm0uYXZhaWxfb3V0ID09PSAwIHx8IHN0cm0uYXZhaWxfaW4gPT09IDAgJiYgKF9tb2RlID09PSBaX0ZJTklTSCB8fCBfbW9kZSA9PT0gWl9TWU5DX0ZMVVNIMikpIHsKICAgICAgICAgICAgaWYgKHRoaXMub3B0aW9ucy50byA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICB0aGlzLm9uRGF0YShzdHJpbmdzLmJ1ZjJiaW5zdHJpbmcodXRpbHMuc2hyaW5rQnVmKHN0cm0ub3V0cHV0LCBzdHJtLm5leHRfb3V0KSkpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRoaXMub25EYXRhKHV0aWxzLnNocmlua0J1ZihzdHJtLm91dHB1dCwgc3RybS5uZXh0X291dCkpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfSB3aGlsZSAoKHN0cm0uYXZhaWxfaW4gPiAwIHx8IHN0cm0uYXZhaWxfb3V0ID09PSAwKSAmJiBzdGF0dXMgIT09IFpfU1RSRUFNX0VORCk7CiAgICAgICAgaWYgKF9tb2RlID09PSBaX0ZJTklTSCkgewogICAgICAgICAgc3RhdHVzID0gemxpYl9kZWZsYXRlLmRlZmxhdGVFbmQodGhpcy5zdHJtKTsKICAgICAgICAgIHRoaXMub25FbmQoc3RhdHVzKTsKICAgICAgICAgIHRoaXMuZW5kZWQgPSB0cnVlOwogICAgICAgICAgcmV0dXJuIHN0YXR1cyA9PT0gWl9PSzsKICAgICAgICB9CiAgICAgICAgaWYgKF9tb2RlID09PSBaX1NZTkNfRkxVU0gyKSB7CiAgICAgICAgICB0aGlzLm9uRW5kKFpfT0spOwogICAgICAgICAgc3RybS5hdmFpbF9vdXQgPSAwOwogICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgfQogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9OwogICAgICBEZWZsYXRlLnByb3RvdHlwZS5vbkRhdGEgPSBmdW5jdGlvbihjaHVuaykgewogICAgICAgIHRoaXMuY2h1bmtzLnB1c2goY2h1bmspOwogICAgICB9OwogICAgICBEZWZsYXRlLnByb3RvdHlwZS5vbkVuZCA9IGZ1bmN0aW9uKHN0YXR1cykgewogICAgICAgIGlmIChzdGF0dXMgPT09IFpfT0spIHsKICAgICAgICAgIGlmICh0aGlzLm9wdGlvbnMudG8gPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgIHRoaXMucmVzdWx0ID0gdGhpcy5jaHVua3Muam9pbigiIik7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICB0aGlzLnJlc3VsdCA9IHV0aWxzLmZsYXR0ZW5DaHVua3ModGhpcy5jaHVua3MpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICB0aGlzLmNodW5rcyA9IFtdOwogICAgICAgIHRoaXMuZXJyID0gc3RhdHVzOwogICAgICAgIHRoaXMubXNnID0gdGhpcy5zdHJtLm1zZzsKICAgICAgfTsKICAgICAgZnVuY3Rpb24gZGVmbGF0ZShpbnB1dCwgb3B0aW9ucykgewogICAgICAgIHZhciBkZWZsYXRvciA9IG5ldyBEZWZsYXRlKG9wdGlv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X2J1ZmZlcl9zaGltKCk7CiAgICAgICJ1c2Ugc3RyaWN0IjsKICAgICAgdmFyIEJBRCA9IDMwOwogICAgICB2YXIgVFlQRSA9IDEyOwogICAgICBtb2R1bGUyLmV4cG9ydHMgPSBmdW5jdGlvbiBpbmZsYXRlX2Zhc3Qoc3RybSwgc3RhcnQpIHsKICAgICAgICB2YXIgc3RhdGU7CiAgICAgICAgdmFyIF9pbjsKICAgICAgICB2YXIgbGFzdDsKICAgICAgICB2YXIgX291dDsKICAgICAgICB2YXIgYmVnOwogICAgICAgIHZhciBlbmQ7CiAgICAgICAgdmFyIGRtYXg7CiAgICAgICAgdmFyIHdzaXplOwogICAgICAgIHZhciB3aGF2ZTsKICAgICAgICB2YXIgd25leHQ7CiAgICAgICAgdmFyIHNfd2luZG93OwogICAgICAgIHZhciBob2xkOwogICAgICAgIHZhciBiaXRzOwogICAgICAgIHZhciBsY29kZTsKICAgICAgICB2YXIgZGNvZGU7CiAgICAgICAgdmFyIGxtYXNrOwogICAgICAgIHZhciBkbWFzazsKICAgICAgICB2YXIgaGVyZTsKICAgICAgICB2YXIgb3A7CiAgICAgICAgdmFyIGxlbjsKICAgICAgICB2YXIgZGlzdDsKICAgICAgICB2YXIgZnJvbTsKICAgICAgICB2YXIgZnJvbV9zb3VyY2U7CiAgICAgICAgdmFyIGlucHV0LCBvdXRwdXQ7CiAgICAgICAgc3RhdGUgPSBzdHJtLnN0YXRlOwogICAgICAgIF9pbiA9IHN0cm0ubmV4dF9pbjsKICAgICAgICBpbnB1dCA9IHN0cm0uaW5wdXQ7CiAgICAgICAgbGFzdCA9IF9pbiArIChzdHJtLmF2YWlsX2luIC0gNSk7CiAgICAgICAgX291dCA9IHN0cm0ubmV4dF9vdXQ7CiAgICAgICAgb3V0cHV0ID0gc3RybS5vdXRwdXQ7CiAgICAgICAgYmVnID0gX291dCAtIChzdGFydCAtIHN0cm0uYXZhaWxfb3V0KTsKICAgICAgICBlbmQgPSBfb3V0ICsgKHN0cm0uYXZhaWxfb3V0IC0gMjU3KTsKICAgICAgICBkbWF4ID0gc3RhdGUuZG1heDsKICAgICAgICB3c2l6ZSA9IHN0YXRlLndzaXplOwogICAgICAgIHdoYXZlID0gc3RhdGUud2hhdmU7CiAgICAgICAgd25leHQgPSBzdGF0ZS53bmV4dDsKICAgICAgICBzX3dpbmRvdyA9IHN0YXRlLndpbmRvdzsKICAgICAgICBob2xkID0gc3RhdGUuaG9sZDsKICAgICAgICBiaXRzID0gc3RhdGUuYml0czsKICAgICAgICBsY29kZSA9IHN0YXRlLmxlbmNvZGU7CiAgICAgICAgZGNvZGUgPSBzdGF0ZS5kaXN0Y29kZTsKICAgICAgICBsbWFzayA9ICgxIDw8IHN0YXRlLmxlbmJpdHMpIC0gMTsKICAgICAgICBkbWFzayA9ICgxIDw8IHN0YXRlLmRpc3RiaXRzKSAtIDE7CiAgICAgICAgdG9wOgogICAgICAgICAgZG8gewogICAgICAgICAgICBpZiAoYml0cyA8IDE1KSB7CiAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtfaW4rK10gPDwgYml0czsKICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtfaW4rK10gPDwgYml0czsKICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaGVyZSA9IGxjb2RlW2hvbGQgJiBsbWFza107CiAgICAgICAgICAgIGRvbGVuOgogICAgICAgICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgICAgICAgb3AgPSBoZXJlID4+PiAyNDsKICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBvcDsKICAgICAgICAgICAgICAgIGJpdHMgLT0gb3A7CiAgICAgICAgICAgICAgICBvcCA9IGhlcmUgPj4+IDE2ICYgMjU1OwogICAgICAgICAgICAgICAgaWYgKG9wID09PSAwKSB7CiAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gaGVyZSAmIDY1NTM1OwogICAgICAgICAgICAgICAgfSBlbHNlIGlmIChvcCAmIDE2KSB7CiAgICAgICAgICAgICAgICAgIGxlbiA9IGhlcmUgJiA2NTUzNTsKICAgICAgICAgICAgICAgICAgb3AgJj0gMTU7CiAgICAgICAgICAgICAgICAgIGlmIChvcCkgewogICAgICAgICAgICAgICAgICAgIGlmIChiaXRzIDwgb3ApIHsKICAgICAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbX2luKytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGxlbiArPSBob2xkICYgKDEgPDwgb3ApIC0gMTsKICAgICAgICAgICAgICAgICAgICBob2xkID4+Pj0gb3A7CiAgICAgICAgICAgICAgICAgICAgYml0cyAtPSBvcDsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoYml0cyA8IDE1KSB7CiAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtfaW4rK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtfaW4rK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaGVyZSA9IGRjb2RlW2hvbGQgJiBkbWFza107CiAgICAgICAgICAgICAgICAgIGRvZGlzdDoKICAgICAgICAgICAgICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgICAgICAgICAgICAgIG9wID0gaGVyZSA+Pj4gMjQ7CiAgICAgICAgICAgICAgICAgICAgICBob2xkID4+Pj0gb3A7CiAgICAgICAgICAgICAgICAgICAgICBiaXRzIC09IG9wOwogICAgICAgICAgICAgICAgICAgICAgb3AgPSBoZXJlID4+PiAxNiAmIDI1NTsKICAgICAgICAgICAgICAgICAgICAgIGlmIChvcCAmIDE2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3QgPSBoZXJlICYgNjU1MzU7CiAgICAgICAgICAgICAgICAgICAgICAgIG9wICY9IDE1OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYml0cyA8IG9wKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtfaW4rK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJpdHMgPCBvcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtfaW4rK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZGlzdCArPSBob2xkICYgKDEgPDwgb3ApIC0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRpc3QgPiBkbWF4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBkaXN0YW5jZSB0b28gZmFyIGJhY2siOwogICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWsgdG9wOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBvcDsKICAgICAgICAgICAgICAgICAgICAgICAgYml0cyAtPSBvcDsKICAgICAgICAgICAgICAgICAgICAgICAgb3AgPSBfb3V0IC0gYmVnOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGlzdCA+IG9wKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgb3AgPSBkaXN0IC0gb3A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wID4gd2hhdmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5zYW5lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgZGlzdGFuY2UgdG9vIGZhciBiYWNrIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWsgdG9wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tX3NvdXJjZSA9IHNfd2luZG93OwogICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3bmV4dCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbSArPSB3c2l6ZSAtIG9wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wIDwgbGVuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlbiAtPSBvcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gc193aW5kb3dbZnJvbSsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSB3aGlsZSAoLS1vcCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyb20gPSBfb3V0IC0gZGlzdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbV9zb3VyY2UgPSBvdXRwdXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh3bmV4dCA8IG9wKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tICs9IHdzaXplICsgd25leHQgLSBvcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wIC09IHduZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wIDwgbGVuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlbiAtPSBvcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gc193aW5kb3dbZnJvbSsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSB3aGlsZSAoLS1vcCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyb20gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAod25leHQgPCBsZW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcCA9IHduZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlbiAtPSBvcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IHNfd2luZG93W2Zyb20rK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSB3aGlsZSAoLS1vcCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbSA9IF9vdXQgLSBkaXN0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyb21fc291cmNlID0gb3V0cHV0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyb20gKz0gd25leHQgLSBvcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcCA8IGxlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW4gLT0gb3A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IHNfd2luZG93W2Zyb20rK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKC0tb3ApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tID0gX291dCAtIGRpc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyb21fc291cmNlID0gb3V0cHV0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAobGVuID4gMikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBmcm9tX3NvdXJjZVtmcm9tKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBmcm9tX3NvdXJjZVtmcm9tKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBmcm9tX3NvdXJjZVtmcm9tKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuIC09IDM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsZW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gZnJvbV9zb3VyY2VbZnJvbSsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsZW4gPiAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gZnJvbV9zb3VyY2VbZnJvbSsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbSA9IF9vdXQgLSBkaXN0OwogICAgICAgICAgICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gb3V0cHV0W2Zyb20rK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IG91dHB1dFtmcm9tKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBvdXRwdXRbZnJvbSsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlbiAtPSAzOwogICAgICAgICAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKGxlbiA+IDIpOwogICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsZW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gb3V0cHV0W2Zyb20rK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobGVuID4gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IG91dHB1dFtmcm9tKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICgob3AgJiA2NCkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgaGVyZSA9IGRjb2RlWyhoZXJlICYgNjU1MzUpICsgKGhvbGQgJiAoMSA8PCBvcCkgLSAxKV07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlIGRvZGlzdDsKICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgZGlzdGFuY2UgY29kZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrIHRvcDsKICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoKG9wICYgNjQpID09PSAwKSB7CiAgICAgICAgICAgICAgICAgIGhlcmUgPSBsY29kZVsoaGVyZSAmIDY1NTM1KSArIChob2xkICYgKDEgPDwgb3ApIC0gMSldOwogICAgICAgICAgICAgICAgICBjb250aW51ZSBkb2xlbjsKICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAob3AgJiAzMikgewogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gVFlQRTsKICAgICAgICAgICAgICAgICAgYnJlYWsgdG9wOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBsaXRlcmFsL2xlbmd0aCBjb2RlIjsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgYnJlYWsgdG9wOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgfQogICAgICAgICAgfSB3aGlsZSAoX2luIDwgbGFzdCAmJiBfb3V0IDwgZW5kKTsKICAgICAgICBsZW4gPSBiaXRzID4+IDM7CiAgICAgICAgX2luIC09IGxlbjsKICAgICAgICBiaXRzIC09IGxlbiA8PCAzOwogICAgICAgIGhvbGQgJj0gKDEgPDwgYml0cykgLSAxOwogICAgICAgIHN0cm0ubmV4dF9pbiA9IF9pbjsKICAgICAgICBzdHJtLm5leHRfb3V0ID0gX291dDsKICAgICAgICBzdHJtLmF2YWlsX2luID0gX2luIDwgbGFzdCA/IDUgKyAobGFzdCAtIF9pbikgOiA1IC0gKF9pbiAtIGxhc3QpOwogICAgICAgIHN0cm0uYXZhaWxfb3V0ID0gX291dCA8IGVuZCA/IDI1NyArIChlbmQgLSBfb3V0KSA6IDI1NyAtIChfb3V0IC0gZW5kKTsKICAgICAgICBzdGF0ZS5ob2xkID0gaG9sZDsKICAgICAgICBzdGF0ZS5iaXRzID0gYml0czsKICAgICAgICByZXR1cm47CiAgICAgIH07CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8ucG5wbS9wYWtvQDEuMC4xMS9ub2RlX21vZHVsZXMvcGFrby9saWIvemxpYi9pbmZ0cmVlcy5qcwogIHZhciByZXF1aXJlX2luZnRyZWVzID0gX19jb21tb25KUyh7CiAgICAibm9kZV9tb2R1bGVzLy5wbnBtL3Bha29AMS4wLjExL25vZGVfbW9kdWxlcy9wYWtvL2xpYi96bGliL2luZnRyZWVzLmpzIihleHBvcnRzMiwgbW9kdWxlMikgewogICAgICBpbml0X2J1ZmZlcl9zaGltKCk7CiAgICAgICJ1c2Ugc3RyaWN0IjsKICAgICAgdmFyIHV0aWxzID0gcmVxdWlyZV9jb21tb24oKTsKICAgICAgdmFyIE1BWEJJVFMgPSAxNTsKICAgICAgdmFyIEVOT1VHSF9MRU5TID0gODUyOwogICAgICB2YXIgRU5PVUdIX0RJU1RTID0gNTkyOwogICAgICB2YXIgQ09ERVMgPSAwOwogICAgICB2YXIgTEVOUyA9IDE7CiAgICAgIHZhciBESVNUUyA9IDI7CiAgICAgIHZhciBsYmFzZSA9IFsKICAgICAgICAzLAogICAgICAgIDQsCiAgICAgICAgNSwKICAgICAgICA2LAogICAgICAgIDcsCiAgICAgICAgOCwKICAgICAgICA5LAogICAgICAgIDEwLAogICAgICAgIDExLAogICAgICAgIDEzLAogICAgICAgIDE1LAogICAgICAgIDE3LAogICAgICAgIDE5LAogICAgICAgIDIzLAogICAgICAgIDI3LAogICAgICAgIDMxLAogICAgICAgIDM1LAogICAgICAgIDQzLAogICAgICAgIDUxLAogICAgICAgIDU5LAogICAgICAgIDY3LAogICAgICAgIDgzLAogICAgICAgIDk5LAogICAgICAgIDExNSwKICAgICAgICAxMzEsCiAgICAgICAgMTYzLAogICAgICAgIDE5NSwKICAgICAgICAyMjcsCiAgICAgICAgMjU4LAogICAgICAgIDAsCiAgICAgICAgMAogICAgICBdOwogICAgICB2YXIgbGV4dCA9IFsKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNywKICAgICAgICAxNywKICAgICAgICAxNywKICAgICAgICAxNywKICAgICAgICAxOCwKICAgICAgICAxOCwKICAgICAgICAxOCwKICAgICAgICAxOCwKICAgICAgICAxOSwKICAgICAgICAxOSwKICAgICAgICAxOSwKICAgICAgICAxOSwKICAgICAgICAyMCwKICAgICAgICAyMCwKICAgICAgICAyMCwKICAgICAgICAyMCwKICAgICAgICAyMSwKICAgICAgICAyMSwKICAgICAgICAyMSwKICAgICAgICAyMSwKICAgICAgICAxNiwKICAgICAgICA3MiwKICAgICAgICA3OAogICAgICBdOwogICAgICB2YXIgZGJhc2UgPSBbCiAgICAgICAgMSwKICAgICAgICAyLAogICAgICAgIDMsCiAgICAgICAgNCwKICAgICAgICA1LAogICAgICAgIDcsCiAgICAgICAgOSwKICAgICAgICAxMywKICAgICAgICAxNywKICAgICAgICAyNSwKICAgICAgICAzMywKICAgICAgICA0OSwKICAgICAgICA2NSwKICAgICAgICA5NywKICAgICAgICAxMjksCiAgICAgICAgMTkzLAogICAgICAgIDI1NywKICAgICAgICAzODUsCiAgICAgICAgNTEzLAogICAgICAgIDc2OSwKICAgICAgICAxMDI1LAogICAgICAgIDE1MzcsCiAgICAgICAgMjA0OSwKICAgICAgICAzMDczLAogICAgICAgIDQwOTcsCiAgICAgICAgNjE0NSwKICAgICAgICA4MTkzLAogICAgICAgIDEyMjg5LAogICAgICAgIDE2Mzg1LAogICAgICAgIDI0NTc3LAogICAgICAgIDAsCiAgICAgICAgMAogICAgICBdOwogICAgICB2YXIgZGV4dCA9IFsKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNiwKICAgICAgICAxNywKICAgICAgICAxNywKICAgICAgICAxOCwKICAgICAgICAxOCwKICAgICAgICAxOSwKICAgICAgICAxOSwKICAgICAgICAyMCwKICAgICAgICAyMCwKICAgICAgICAyMSwKICAgICAgICAyMSwKICAgICAgICAyMiwKICAgICAgICAyMiwKICAgICAgICAyMywKICAgICAgICAyMywKICAgICAgICAyNCwKICAgICAgICAyNCwKICAgICAgICAyNSwKICAgICAgICAyNSwKICAgICAgICAyNiwKICAgICAgICAyNiwKICAgICAgICAyNywKICAgICAgICAyNywKICAgICAgICAyOCwKICAgICAgICAyOCwKICAgICAgICAyOSwKICAgICAgICAyOSwKICAgICAgICA2NCwKICAgICAgICA2NAogICAgICBdOwogICAgICBtb2R1bGUyLmV4cG9ydHMgPSBmdW5jdGlvbiBpbmZsYXRlX3RhYmxlKHR5cGUsIGxlbnMsIGxlbnNfaW5kZXgsIGNvZGVzLCB0YWJsZSwgdGFibGVfaW5kZXgsIHdvcmssIG9wdHMpIHsKICAgICAgICB2YXIgYml0cyA9IG9wdHMuYml0czsKICAgICAgICB2YXIgbGVuID0gMDsKICAgICAgICB2YXIgc3ltID0gMDsKICAgICAgICB2YXIgbWluID0gMCwgbWF4ID0gMDsKICAgICAgICB2YXIgcm9vdDIgPSAwOwogICAgICAgIHZhciBjdXJyID0gMDsKICAgICAgICB2YXIgZHJvcCA9IDA7CiAgICAgICAgdmFyIGxlZnQgPSAwOwogICAgICAgIHZhciB1c2VkID0gMDsKICAgICAgICB2YXIgaHVmZiA9IDA7CiAgICAgICAgdmFyIGluY3I7CiAgICAgICAgdmFyIGZpbGw7CiAgICAgICAgdmFyIGxvdzsKICAgICAgICB2YXIgbWFzazsKICAgICAgICB2YXIgbmV4dDsKICAgICAgICB2YXIgYmFzZSA9IG51bGw7CiAgICAgICAgdmFyIGJhc2VfaW5kZXggPSAwOwogICAgICAgIHZhciBlbmQ7CiAgICAgICAgdmFyIGNvdW50ID0gbmV3IHV0aWxzLkJ1ZjE2KE1BWEJJVFMgKyAxKTsKICAgICAgICB2YXIgb2ZmcyA9IG5ldyB1dGlscy5CdWYxNihNQVhCSVRTICsgMSk7CiAgICAgICAgdmFyIGV4dHJhID0gbnVsbDsKICAgICAgICB2YXIgZXh0cmFfaW5kZXggPSAwOwogICAgICAgIHZhciBoZXJlX2JpdHMsIGhlcmVfb3AsIGhlcmVfdmFsOwogICAgICAgIGZvciAobGVuID0gMDsgbGVuIDw9IE1BWEJJVFM7IGxlbisrKSB7CiAgICAgICAgICBjb3VudFtsZW5dID0gMDsKICAgICAgICB9CiAgICAgICAgZm9yIChzeW0gPSAwOyBzeW0gPCBjb2Rlczsgc3ltKyspIHsKICAgICAgICAgIGNvdW50W2xlbnNbbGVuc19pbmRleCArIHN5bV1dKys7CiAgICAgICAgfQogICAgICAgIHJvb3QyID0gYml0czsKICAgICAgICBmb3IgKG1heCA9IE1BWEJJVFM7IG1heCA+PSAxOyBtYXgtLSkgewogICAgICAgICAgaWYgKGNvdW50W21heF0gIT09IDApIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChyb290MiA+IG1heCkgewogICAgICAgICAgcm9vdDIgPSBtYXg7CiAgICAgICAgfQogICAgICAgIGlmIChtYXggPT09IDApIHsKICAgICAgICAgIHRhYmxlW3RhYmxlX2luZGV4KytdID0gMSA8PCAyNCB8IDY0IDw8IDE2IHwgMDsKICAgICAgICAgIHRhYmxlW3RhYmxlX2luZGV4KytdID0gMSA8PCAyNCB8IDY0IDw8IDE2IHwgMDsKICAgICAgICAgIG9wdHMuYml0cyA9IDE7CiAgICAgICAgICByZXR1cm4gMDsKICAgICAgICB9CiAgICAgICAgZm9yIChtaW4gPSAxOyBtaW4gPCBtYXg7IG1pbisrKSB7CiAgICAgICAgICBpZiAoY291bnRbbWluXSAhPT0gMCkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHJvb3QyIDwgbWluKSB7CiAgICAgICAgICByb290MiA9IG1pbjsKICAgICAgICB9CiAgICAgICAgbGVmdCA9IDE7CiAgICAgICAgZm9yIChsZW4gPSAxOyBsZW4gPD0gTUFYQklUUzsgbGVuKyspIHsKICAgICAgICAgIGxlZnQgPDw9IDE7CiAgICAgICAgICBsZWZ0IC09IGNvdW50W2xlbl07CiAgICAgICAgICBpZiAobGVmdCA8IDApIHsKICAgICAgICAgICAgcmV0dXJuIC0xOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAobGVmdCA+IDAgJiYgKHR5cGUgPT09IENPREVTIHx8IG1heCAhPT0gMSkpIHsKICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICB9CiAgICAgICAgb2Zmc1sxXSA9IDA7CiAgICAgICAgZm9yIChsZW4gPSAxOyBsZW4gPCBNQVhCSVRTOyBsZW4rKykgewogICAgICAgICAgb2Zmc1tsZW4gKyAxXSA9IG9mZnNbbGVuXSArIGNvdW50W2xlbl07CiAgICAgICAgfQogICAgICAgIGZvciAoc3ltID0gMDsgc3ltIDwgY29kZXM7IHN5bSsrKSB7CiAgICAgICAgICBpZiAobGVuc1tsZW5zX2luZGV4ICsgc3ltXSAhPT0gMCkgewogICAgICAgICAgICB3b3JrW29mZnNbbGVuc1tsZW5zX2luZGV4ICsgc3ltXV0rK10gPSBzeW07CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmICh0eXBlID09PSBDT0RFUykgewogICAgICAgICAgYmFzZSA9IGV4dHJhID0gd29yazsKICAgICAgICAgIGVuZCA9IDE5OwogICAgICAgIH0gZWxzZSBpZiAodHlwZSA9PT0gTEVOUykgewogICAgICAgICAgYmFzZSA9IGxiYXNlOwogICAgICAgICAgYmFzZV9pbmRleCAtPSAyNTc7CiAgICAgICAgICBleHRyYSA9IGxleHQ7CiAgICAgICAgICBleHRyYV9pbmRleCAtPSAyNTc7CiAgICAgICAgICBlbmQgPSAyNTY7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGJhc2UgPSBkYmFzZTsKICAgICAgICAgIGV4dHJhID0gZGV4dDsKICAgICAgICAgIGVuZCA9IC0xOwogICAgICAgIH0KICAgICAgICBodWZmID0gMDsKICAgICAgICBzeW0gPSAwOwogICAgICAgIGxlbiA9IG1pbjsKICAgICAgICBuZXh0ID0gdGFibGVfaW5kZXg7CiAgICAgICAgY3VyciA9IHJvb3QyOwogICAgICAgIGRyb3AgPSAwOwogICAgICAgIGxvdyA9IC0xOwogICAgICAgIHVzZWQgPSAxIDw8IHJvb3QyOwogICAgICAgIG1hc2sgPSB1c2VkIC0gMTsKICAgICAgICBpZiAodHlwZSA9PT0gTEVOUyAmJiB1c2VkID4gRU5PVUdIX0xFTlMgfHwgdHlwZSA9PT0gRElTVFMgJiYgdXNlZCA+IEVOT1VHSF9ESVNUUykgewogICAgICAgICAgcmV0dXJuIDE7CiAgICAgICAgfQogICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgaGVyZV9iaXRzID0gbGVuIC0gZHJvcDsKICAgICAgICAgIGlmICh3b3JrW3N5bV0gPCBlbmQpIHsKICAgICAgICAgICAgaGVyZV9vcCA9IDA7CiAgICAgICAgICAgIGhlcmVfdmFsID0gd29ya1tzeW1dOwogICAgICAgICAgfSBlbHNlIGlmICh3b3JrW3N5bV0gPiBlbmQpIHsKICAgICAgICAgICAgaGVyZV9vcCA9IGV4dHJhW2V4dHJhX2luZGV4ICsgd29ya1tzeW1dXTsKICAgICAgICAgICAgaGVyZV92YWwgPSBiYXNlW2Jhc2VfaW5kZXggKyB3b3JrW3N5bV1dOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgaGVyZV9vcCA9IDMyICsgNjQ7CiAgICAgICAgICAgIGhlcmVfdmFsID0gMDsKICAgICAgICAgIH0KICAgICAgICAgIGluY3IgPSAxIDw8IGxlbiAtIGRyb3A7CiAgICAgICAgICBmaWxsID0gMSA8PCBjdXJyOwogICAgICAgICAgbWluID0gZmlsbDsKICAgICAgICAgIGRvIHsKICAgICAgICAgICAgZmlsbCAtPSBpbmNyOwogICAgICAgICAgICB0YWJsZVtuZXh0ICsgKGh1ZmYgPj4gZHJvcCkgKyBmaWxsXSA9IGhlcmVfYml0cyA8PCAyNCB8IGhlcmVfb3AgPDwgMTYgfCBoZXJlX3ZhbCB8IDA7CiAgICAgICAgICB9IHdoaWxlIChmaWxsICE9PSAwKTsKICAgICAgICAgIGluY3IgPSAxIDw8IGxlbiAtIDE7CiAgICAgICAgICB3aGlsZSAoaHVmZiAmIGluY3IpIHsKICAgICAgICAgICAgaW5jciA+Pj0gMTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChpbmNyICE9PSAwKSB7CiAgICAgICAgICAgIGh1ZmYgJj0gaW5jciAtIDE7CiAgICAgICAgICAgIGh1ZmYgKz0gaW5jcjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGh1ZmYgPSAwOwogICAgICAgICAgfQogICAgICAgICAgc3ltKys7CiAgICAgICAgICBpZiAoLS1jb3VudFtsZW5dID09PSAwKSB7CiAgICAgICAgICAgIGlmIChsZW4gPT09IG1heCkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGxlbiA9IGxlbnNbbGVuc19pbmRleCArIHdvcmtbc3ltXV07CiAgICAgICAgICB9CiAgICAgICAgICBpZiAobGVuID4gcm9vdDIgJiYgKGh1ZmYgJiBtYXNrKSAhPT0gbG93KSB7CiAgICAgICAgICAgIGlmIChkcm9wID09PSAwKSB7CiAgICAgICAgICAgICAgZHJvcCA9IHJvb3QyOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG5leHQgKz0gbWluOwogICAgICAgICAgICBjdXJyID0gbGVuIC0gZHJvcDsKICAgICAgICAgICAgbGVmdCA9IDEgPDwgY3VycjsKICAgICAgICAgICAgd2hpbGUgKGN1cnIgKyBkcm9wIDwgbWF4KSB7CiAgICAgICAgICAgICAgbGVmdCAtPSBjb3VudFtjdXJyICsgZHJvcF07CiAgICAgICAgICAgICAgaWYgKGxlZnQgPD0gMCkgewogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGN1cnIrKzsKICAgICAgICAgICAgICBsZWZ0IDw8PSAxOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHVzZWQgKz0gMSA8PCBjdXJyOwogICAgICAgICAgICBpZiAodHlwZSA9PT0gTEVOUyAmJiB1c2VkID4gRU5PVUdIX0xFTlMgfHwgdHlwZSA9PT0gRElTVFMgJiYgdXNlZCA+IEVOT1VHSF9ESVNUUykgewogICAgICAgICAgICAgIHJldHVybiAxOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGxvdyA9IGh1ZmYgJiBtYXNrOwogICAgICAgICAgICB0YWJsZVtsb3ddID0gcm9vdDIgPDwgMjQgfCBjdXJyIDw8IDE2IHwgbmV4dCAtIHRhYmxlX2luZGV4IHwgMDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKGh1ZmYgIT09IDApIHsKICAgICAgICAgIHRhYmxlW25leHQgKyBodWZmXSA9IGxlbiAtIGRyb3AgPDwgMjQgfCA2NCA8PCAxNiB8IDA7CiAgICAgICAgfQogICAgICAgIG9wdHMuYml0cyA9IHJvb3QyOwogICAgICAgIHJldHVybiAwOwogICAgICB9OwogICAgfQogIH0pOwoKICAvLyBub2RlX21vZHVsZXMvLnBucG0vcGFrb0AxLjAuMTEvbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvaW5mbGF0ZS5qcwogIHZhciByZXF1aXJlX2luZmxhdGUgPSBfX2NvbW1vbkpTKHsKICAgICJub2RlX21vZHVsZXMvLnBucG0vcGFrb0AxLjAuMTEvbm9kZV9tb2R1bGVzL3Bha28vbGliL3psaWIvaW5mbGF0ZS5qcyIoZXhwb3J0czIpIHsKICAgICAgaW5pdF9idWZmZXJfc2hpbSgpOwogICAgICAidXNlIHN0cmljdCI7CiAgICAgIHZhciB1dGlscyA9IHJlcXVpcmVfY29tbW9uKCk7CiAgICAgIHZhciBhZGxlcjMyID0gcmVxdWlyZV9hZGxlcjMyKCk7CiAgICAgIHZhciBjcmMzMiA9IHJlcXVpcmVfY3JjMzIoKTsKICAgICAgdmFyIGluZmxhdGVfZmFzdCA9IHJlcXVpcmVfaW5mZmFzdCgpOwogICAgICB2YXIgaW5mbGF0ZV90YWJsZSA9IHJlcXVpcmVfaW5mdHJlZXMoKTsKICAgICAgdmFyIENPREVTID0gMDsKICAgICAgdmFyIExFTlMgPSAxOwogICAgICB2YXIgRElTVFMgPSAyOwogICAgICB2YXIgWl9GSU5JU0ggPSA0OwogICAgICB2YXIgWl9CTE9DSyA9IDU7CiAgICAgIHZhciBaX1RSRUVTID0gNjsKICAgICAgdmFyIFpfT0sgPSAwOwogICAgICB2YXIgWl9TVFJFQU1fRU5EID0gMTsKICAgICAgdmFyIFpfTkVFRF9ESUNUID0gMjsKICAgICAgdmFyIFpfU1RSRUFNX0VSUk9SID0gLTI7CiAgICAgIHZhciBaX0RBVEFfRVJST1IgPSAtMzsKICAgICAgdmFyIFpfTUVNX0VSUk9SID0gLTQ7CiAgICAgIHZhciBaX0JVRl9FUlJPUiA9IC01OwogICAgICB2YXIgWl9ERUZMQVRFRCA9IDg7CiAgICAgIHZhciBIRUFEID0gMTsKICAgICAgdmFyIEZMQUdTID0gMjsKICAgICAgdmFyIFRJTUUgPSAzOwogICAgICB2YXIgT1MgPSA0OwogICAgICB2YXIgRVhMRU4gPSA1OwogICAgICB2YXIgRVhUUkEgPSA2OwogICAgICB2YXIgTkFNRSA9IDc7CiAgICAgIHZhciBDT01NRU5UID0gODsKICAgICAgdmFyIEhDUkMgPSA5OwogICAgICB2YXIgRElDVElEID0gMTA7CiAgICAgIHZhciBESUNUID0gMTE7CiAgICAgIHZhciBUWVBFID0gMTI7CiAgICAgIHZhciBUWVBFRE8gPSAxMzsKICAgICAgdmFyIFNUT1JFRCA9IDE0OwogICAgICB2YXIgQ09QWV8gPSAxNTsKICAgICAgdmFyIENPUFkgPSAxNjsKICAgICAgdmFyIFRBQkxFID0gMTc7CiAgICAgIHZhciBMRU5MRU5TID0gMTg7CiAgICAgIHZhciBDT0RFTEVOUyA9IDE5OwogICAgICB2YXIgTEVOXyA9IDIwOwogICAgICB2YXIgTEVOID0gMjE7CiAgICAgIHZhciBMRU5FWFQgPSAyMjsKICAgICAgdmFyIERJU1QgPSAyMzsKICAgICAgdmFyIERJU1RFWFQgPSAyNDsKICAgICAgdmFyIE1BVENIID0gMjU7CiAgICAgIHZhciBMSVQgPSAyNjsKICAgICAgdmFyIENIRUNLID0gMjc7CiAgICAgIHZhciBMRU5HVEggPSAyODsKICAgICAgdmFyIERPTkUgPSAyOTsKICAgICAgdmFyIEJBRCA9IDMwOwogICAgICB2YXIgTUVNID0gMzE7CiAgICAgIHZhciBTWU5DID0gMzI7CiAgICAgIHZhciBFTk9VR0hfTEVOUyA9IDg1MjsKICAgICAgdmFyIEVOT1VHSF9ESVNUUyA9IDU5MjsKICAgICAgdmFyIE1BWF9XQklUUyA9IDE1OwogICAgICB2YXIgREVGX1dCSVRTID0gTUFYX1dCSVRTOwogICAgICBmdW5jdGlvbiB6c3dhcDMyKHEpIHsKICAgICAgICByZXR1cm4gKHEgPj4+IDI0ICYgMjU1KSArIChxID4+PiA4ICYgNjUyODApICsgKChxICYgNjUyODApIDw8IDgpICsgKChxICYgMjU1KSA8PCAyNCk7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gSW5mbGF0ZVN0YXRlKCkgewogICAgICAgIHRoaXMubW9kZSA9IDA7CiAgICAgICAgdGhpcy5sYXN0ID0gZmFsc2U7CiAgICAgICAgdGhpcy53cmFwID0gMDsKICAgICAgICB0aGlzLmhhdmVkaWN0ID0gZmFsc2U7CiAgICAgICAgdGhpcy5mbGFncyA9IDA7CiAgICAgICAgdGhpcy5kbWF4ID0gMDsKICAgICAgICB0aGlzLmNoZWNrID0gMDsKICAgICAgICB0aGlzLnRvdGFsID0gMDsKICAgICAgICB0aGlzLmhlYWQgPSBudWxsOwogICAgICAgIHRoaXMud2JpdHMgPSAwOwogICAgICAgIHRoaXMud3NpemUgPSAwOwogICAgICAgIHRoaXMud2hhdmUgPSAwOwogICAgICAgIHRoaXMud25leHQgPSAwOwogICAgICAgIHRoaXMud2luZG93ID0gbnVsbDsKICAgICAgICB0aGlzLmhvbGQgPSAwOwogICAgICAgIHRoaXMuYml0cyA9IDA7CiAgICAgICAgdGhpcy5sZW5ndGggPSAwOwogICAgICAgIHRoaXMub2Zmc2V0ID0gMDsKICAgICAgICB0aGlzLmV4dHJhID0gMDsKICAgICAgICB0aGlzLmxlbmNvZGUgPSBudWxsOwogICAgICAgIHRoaXMuZGlzdGNvZGUgPSBudWxsOwogICAgICAgIHRoaXMubGVuYml0cyA9IDA7CiAgICAgICAgdGhpcy5kaXN0Yml0cyA9IDA7CiAgICAgICAgdGhpcy5uY29kZSA9IDA7CiAgICAgICAgdGhpcy5ubGVuID0gMDsKICAgICAgICB0aGlzLm5kaXN0ID0gMDsKICAgICAgICB0aGlzLmhhdmUgPSAwOwogICAgICAgIHRoaXMubmV4dCA9IG51bGw7CiAgICAgICAgdGhpcy5sZW5zID0gbmV3IHV0aWxzLkJ1ZjE2KDMyMCk7CiAgICAgICAgdGhpcy53b3JrID0gbmV3IHV0aWxzLkJ1ZjE2KDI4OCk7CiAgICAgICAgdGhpcy5sZW5keW4gPSBudWxsOwogICAgICAgIHRoaXMuZGlzdGR5biA9IG51bGw7CiAgICAgICAgdGhpcy5zYW5lID0gMDsKICAgICAgICB0aGlzLmJhY2sgPSAwOwogICAgICAgIHRoaXMud2FzID0gMDsKICAgICAgfQogICAgICBmdW5jdGlvbiBpbmZsYXRlUmVzZXRLZWVwKHN0cm0pIHsKICAgICAgICB2YXIgc3RhdGU7CiAgICAgICAgaWYgKCFzdHJtIHx8ICFzdHJtLnN0YXRlKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIHN0YXRlID0gc3RybS5zdGF0ZTsKICAgICAgICBzdHJtLnRvdGFsX2luID0gc3RybS50b3RhbF9vdXQgPSBzdGF0ZS50b3RhbCA9IDA7CiAgICAgICAgc3RybS5tc2cgPSAiIjsKICAgICAgICBpZiAoc3RhdGUud3JhcCkgewogICAgICAgICAgc3RybS5hZGxlciA9IHN0YXRlLndyYXAgJiAxOwogICAgICAgIH0KICAgICAgICBzdGF0ZS5tb2RlID0gSEVBRDsKICAgICAgICBzdGF0ZS5sYXN0ID0gMDsKICAgICAgICBzdGF0ZS5oYXZlZGljdCA9IDA7CiAgICAgICAgc3RhdGUuZG1heCA9IDMyNzY4OwogICAgICAgIHN0YXRlLmhlYWQgPSBudWxsOwogICAgICAgIHN0YXRlLmhvbGQgPSAwOwogICAgICAgIHN0YXRlLmJpdHMgPSAwOwogICAgICAgIHN0YXRlLmxlbmNvZGUgPSBzdGF0ZS5sZW5keW4gPSBuZXcgdXRpbHMuQnVmMzIoRU5PVUdIX0xFTlMpOwogICAgICAgIHN0YXRlLmRpc3Rjb2RlID0gc3RhdGUuZGlzdGR5biA9IG5ldyB1dGlscy5CdWYzMihFTk9VR0hfRElTVFMpOwogICAgICAgIHN0YXRlLnNhbmUgPSAxOwogICAgICAgIHN0YXRlLmJhY2sgPSAtMTsKICAgICAgICByZXR1cm4gWl9PSzsKICAgICAgfQogICAgICBmdW5jdGlvbiBpbmZsYXRlUmVzZXQoc3RybSkgewogICAgICAgIHZhciBzdGF0ZTsKICAgICAgICBpZiAoIXN0cm0gfHwgIXN0cm0uc3RhdGUpIHsKICAgICAgICAgIHJldHVybiBaX1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgc3RhdGUgPSBzdHJtLnN0YXRlOwogICAgICAgIHN0YXRlLndzaXplID0gMDsKICAgICAgICBzdGF0ZS53aGF2ZSA9IDA7CiAgICAgICAgc3RhdGUud25leHQgPSAwOwogICAgICAgIHJldHVybiBpbmZsYXRlUmVzZXRLZWVwKHN0cm0pOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGluZmxhdGVSZXNldDIoc3RybSwgd2luZG93Qml0cykgewogICAgICAgIHZhciB3cmFwOwogICAgICAgIHZhciBzdGF0ZTsKICAgICAgICBpZiAoIXN0cm0gfHwgIXN0cm0uc3RhdGUpIHsKICAgICAgICAgIHJldHVybiBaX1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgc3RhdGUgPSBzdHJtLnN0YXRlOwogICAgICAgIGlmICh3aW5kb3dCaXRzIDwgMCkgewogICAgICAgICAgd3JhcCA9IDA7CiAgICAgICAgICB3aW5kb3dCaXRzID0gLXdpbmRvd0JpdHM7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHdyYXAgPSAod2luZG93Qml0cyA+PiA0KSArIDE7CiAgICAgICAgICBpZiAod2luZG93Qml0cyA8IDQ4KSB7CiAgICAgICAgICAgIHdpbmRvd0JpdHMgJj0gMTU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmICh3aW5kb3dCaXRzICYmICh3aW5kb3dCaXRzIDwgOCB8fCB3aW5kb3dCaXRzID4gMTUpKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIGlmIChzdGF0ZS53aW5kb3cgIT09IG51bGwgJiYgc3RhdGUud2JpdHMgIT09IHdpbmRvd0JpdHMpIHsKICAgICAgICAgIHN0YXRlLndpbmRvdyA9IG51bGw7CiAgICAgICAgfQogICAgICAgIHN0YXRlLndyYXAgPSB3cmFwOwogICAgICAgIHN0YXRlLndiaXRzID0gd2luZG93Qml0czsKICAgICAgICByZXR1cm4gaW5mbGF0ZVJlc2V0KHN0cm0pOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGluZmxhdGVJbml0MihzdHJtLCB3aW5kb3dCaXRzKSB7CiAgICAgICAgdmFyIHJldDsKICAgICAgICB2YXIgc3RhdGU7CiAgICAgICAgaWYgKCFzdHJtKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIHN0YXRlID0gbmV3IEluZmxhdGVTdGF0ZSgpOwogICAgICAgIHN0cm0uc3RhdGUgPSBzdGF0ZTsKICAgICAgICBzdGF0ZS53aW5kb3cgPSBudWxsOwogICAgICAgIHJldCA9IGluZmxhdGVSZXNldDIoc3RybSwgd2luZG93Qml0cyk7CiAgICAgICAgaWYgKHJldCAhPT0gWl9PSykgewogICAgICAgICAgc3RybS5zdGF0ZSA9IG51bGw7CiAgICAgICAgfQogICAgICAgIHJldHVybiByZXQ7CiAgICAgIH0KICAgICAgZnVuY3Rpb24gaW5mbGF0ZUluaXQoc3RybSkgewogICAgICAgIHJldHVybiBpbmZsYXRlSW5pdDIoc3RybSwgREVGX1dCSVRTKTsKICAgICAgfQogICAgICB2YXIgdmlyZ2luID0gdHJ1ZTsKICAgICAgdmFyIGxlbmZpeDsKICAgICAgdmFyIGRpc3RmaXg7CiAgICAgIGZ1bmN0aW9uIGZpeGVkdGFibGVzKHN0YXRlKSB7CiAgICAgICAgaWYgKHZpcmdpbikgewogICAgICAgICAgdmFyIHN5bTsKICAgICAgICAgIGxlbmZpeCA9IG5ldyB1dGlscy5CdWYzMig1MTIpOwogICAgICAgICAgZGlzdGZpeCA9IG5ldyB1dGlscy5CdWYzMigzMik7CiAgICAgICAgICBzeW0gPSAwOwogICAgICAgICAgd2hpbGUgKHN5bSA8IDE0NCkgewogICAgICAgICAgICBzdGF0ZS5sZW5zW3N5bSsrXSA9IDg7CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3ltIDwgMjU2KSB7CiAgICAgICAgICAgIHN0YXRlLmxlbnNbc3ltKytdID0gOTsKICAgICAgICAgIH0KICAgICAgICAgIHdoaWxlIChzeW0gPCAyODApIHsKICAgICAgICAgICAgc3RhdGUubGVuc1tzeW0rK10gPSA3OwogICAgICAgICAgfQogICAgICAgICAgd2hpbGUgKHN5bSA8IDI4OCkgewogICAgICAgICAgICBzdGF0ZS5sZW5zW3N5bSsrXSA9IDg7CiAgICAgICAgICB9CiAgICAgICAgICBpbmZsYXRlX3RhYmxlKExFTlMsIHN0YXRlLmxlbnMsIDAsIDI4OCwgbGVuZml4LCAwLCBzdGF0ZS53b3JrLCB7IGJpdHM6IDkgfSk7CiAgICAgICAgICBzeW0gPSAwOwogICAgICAgICAgd2hpbGUgKHN5bSA8IDMyKSB7CiAgICAgICAgICAgIHN0YXRlLmxlbnNbc3ltKytdID0gNTsKICAgICAgICAgIH0KICAgICAgICAgIGluZmxhdGVfdGFibGUoRElTVFMsIHN0YXRlLmxlbnMsIDAsIDMyLCBkaXN0Zml4LCAwLCBzdGF0ZS53b3JrLCB7IGJpdHM6IDUgfSk7CiAgICAgICAgICB2aXJnaW4gPSBmYWxzZTsKICAgICAgICB9CiAgICAgICAgc3RhdGUubGVuY29kZSA9IGxlbmZpeDsKICAgICAgICBzdGF0ZS5sZW5iaXRzID0gOTsKICAgICAgICBzdGF0ZS5kaXN0Y29kZSA9IGRpc3RmaXg7CiAgICAgICAgc3RhdGUuZGlzdGJpdHMgPSA1OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIHVwZGF0ZXdpbmRvdyhzdHJtLCBzcmMsIGVuZCwgY29weSkgewogICAgICAgIHZhciBkaXN0OwogICAgICAgIHZhciBzdGF0ZSA9IHN0cm0uc3RhdGU7CiAgICAgICAgaWYgKHN0YXRlLndpbmRvdyA9PT0gbnVsbCkgewogICAgICAgICAgc3RhdGUud3NpemUgPSAxIDw8IHN0YXRlLndiaXRzOwogICAgICAgICAgc3RhdGUud25leHQgPSAwOwogICAgICAgICAgc3RhdGUud2hhdmUgPSAwOwogICAgICAgICAgc3RhdGUud2luZG93ID0gbmV3IHV0aWxzLkJ1Zjgoc3RhdGUud3NpemUpOwogICAgICAgIH0KICAgICAgICBpZiAoY29weSA+PSBzdGF0ZS53c2l6ZSkgewogICAgICAgICAgdXRpbHMuYXJyYXlTZXQoc3RhdGUud2luZG93LCBzcmMsIGVuZCAtIHN0YXRlLndzaXplLCBzdGF0ZS53c2l6ZSwgMCk7CiAgICAgICAgICBzdGF0ZS53bmV4dCA9IDA7CiAgICAgICAgICBzdGF0ZS53aGF2ZSA9IHN0YXRlLndzaXplOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBkaXN0ID0gc3RhdGUud3NpemUgLSBzdGF0ZS53bmV4dDsKICAgICAgICAgIGlmIChkaXN0ID4gY29weSkgewogICAgICAgICAgICBkaXN0ID0gY29weTsKICAgICAgICAgIH0KICAgICAgICAgIHV0aWxzLmFycmF5U2V0KHN0YXRlLndpbmRvdywgc3JjLCBlbmQgLSBjb3B5LCBkaXN0LCBzdGF0ZS53bmV4dCk7CiAgICAgICAgICBjb3B5IC09IGRpc3Q7CiAgICAgICAgICBpZiAoY29weSkgewogICAgICAgICAgICB1dGlscy5hcnJheVNldChzdGF0ZS53aW5kb3csIHNyYywgZW5kIC0gY29weSwgY29weSwgMCk7CiAgICAgICAgICAgIHN0YXRlLnduZXh0ID0gY29weTsKICAgICAgICAgICAgc3RhdGUud2hhdmUgPSBzdGF0ZS53c2l6ZTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHN0YXRlLnduZXh0ICs9IGRpc3Q7CiAgICAgICAgICAgIGlmIChzdGF0ZS53bmV4dCA9PT0gc3RhdGUud3NpemUpIHsKICAgICAgICAgICAgICBzdGF0ZS53bmV4dCA9IDA7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHN0YXRlLndoYXZlIDwgc3RhdGUud3NpemUpIHsKICAgICAgICAgICAgICBzdGF0ZS53aGF2ZSArPSBkaXN0OwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiAwOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGluZmxhdGUoc3RybSwgZmx1c2gpIHsKICAg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xfb3V0OwogICAgICAgIG5leHQgPSBzdHJtLm5leHRfaW47CiAgICAgICAgaW5wdXQgPSBzdHJtLmlucHV0OwogICAgICAgIGhhdmUgPSBzdHJtLmF2YWlsX2luOwogICAgICAgIGhvbGQgPSBzdGF0ZS5ob2xkOwogICAgICAgIGJpdHMgPSBzdGF0ZS5iaXRzOwogICAgICAgIF9pbiA9IGhhdmU7CiAgICAgICAgX291dCA9IGxlZnQ7CiAgICAgICAgcmV0ID0gWl9PSzsKICAgICAgICBpbmZfbGVhdmU6CiAgICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgICAgc3dpdGNoIChzdGF0ZS5tb2RlKSB7CiAgICAgICAgICAgICAgY2FzZSBIRUFEOgogICAgICAgICAgICAgICAgaWYgKHN0YXRlLndyYXAgPT09IDApIHsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IFRZUEVETzsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB3aGlsZSAoYml0cyA8IDE2KSB7CiAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChzdGF0ZS53cmFwICYgMiAmJiBob2xkID09PSAzNTYxNSkgewogICAgICAgICAgICAgICAgICBzdGF0ZS5jaGVjayA9IDA7CiAgICAgICAgICAgICAgICAgIGhidWZbMF0gPSBob2xkICYgMjU1OwogICAgICAgICAgICAgICAgICBoYnVmWzFdID0gaG9sZCA+Pj4gOCAmIDI1NTsKICAgICAgICAgICAgICAgICAgc3RhdGUuY2hlY2sgPSBjcmMzMihzdGF0ZS5jaGVjaywgaGJ1ZiwgMiwgMCk7CiAgICAgICAgICAgICAgICAgIGhvbGQgPSAwOwogICAgICAgICAgICAgICAgICBiaXRzID0gMDsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEZMQUdTOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLmZsYWdzID0gMDsKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5oZWFkKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmhlYWQuZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKCEoc3RhdGUud3JhcCAmIDEpIHx8ICgoKGhvbGQgJiAyNTUpIDw8IDgpICsgKGhvbGQgPj4gOCkpICUgMzEpIHsKICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW5jb3JyZWN0IGhlYWRlciBjaGVjayI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKChob2xkICYgMTUpICE9PSBaX0RFRkxBVEVEKSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gInVua25vd24gY29tcHJlc3Npb24gbWV0aG9kIjsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBob2xkID4+Pj0gNDsKICAgICAgICAgICAgICAgIGJpdHMgLT0gNDsKICAgICAgICAgICAgICAgIGxlbiA9IChob2xkICYgMTUpICsgODsKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS53Yml0cyA9PT0gMCkgewogICAgICAgICAgICAgICAgICBzdGF0ZS53Yml0cyA9IGxlbjsKICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobGVuID4gc3RhdGUud2JpdHMpIHsKICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCB3aW5kb3cgc2l6ZSI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUuZG1heCA9IDEgPDwgbGVuOwogICAgICAgICAgICAgICAgc3RybS5hZGxlciA9IHN0YXRlLmNoZWNrID0gMTsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBob2xkICYgNTEyID8gRElDVElEIDogVFlQRTsKICAgICAgICAgICAgICAgIGhvbGQgPSAwOwogICAgICAgICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIEZMQUdTOgogICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAxNikgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5mbGFncyA9IGhvbGQ7CiAgICAgICAgICAgICAgICBpZiAoKHN0YXRlLmZsYWdzICYgMjU1KSAhPT0gWl9ERUZMQVRFRCkgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJ1bmtub3duIGNvbXByZXNzaW9uIG1ldGhvZCI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgNTczNDQpIHsKICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAidW5rbm93biBoZWFkZXIgZmxhZ3Mgc2V0IjsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuaGVhZCkgewogICAgICAgICAgICAgICAgICBzdGF0ZS5oZWFkLnRleHQgPSBob2xkID4+IDggJiAxOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgNTEyKSB7CiAgICAgICAgICAgICAgICAgIGhidWZbMF0gPSBob2xkICYgMjU1OwogICAgICAgICAgICAgICAgICBoYnVmWzFdID0gaG9sZCA+Pj4gOCAmIDI1NTsKICAgICAgICAgICAgICAgICAgc3RhdGUuY2hlY2sgPSBjcmMzMihzdGF0ZS5jaGVjaywgaGJ1ZiwgMiwgMCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBob2xkID0gMDsKICAgICAgICAgICAgICAgIGJpdHMgPSAwOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IFRJTUU7CiAgICAgICAgICAgICAgY2FzZSBUSU1FOgogICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAzMikgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuaGVhZCkgewogICAgICAgICAgICAgICAgICBzdGF0ZS5oZWFkLnRpbWUgPSBob2xkOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgNTEyKSB7CiAgICAgICAgICAgICAgICAgIGhidWZbMF0gPSBob2xkICYgMjU1OwogICAgICAgICAgICAgICAgICBoYnVmWzFdID0gaG9sZCA+Pj4gOCAmIDI1NTsKICAgICAgICAgICAgICAgICAgaGJ1ZlsyXSA9IGhvbGQgPj4+IDE2ICYgMjU1OwogICAgICAgICAgICAgICAgICBoYnVmWzNdID0gaG9sZCA+Pj4gMjQgJiAyNTU7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmNoZWNrID0gY3JjMzIoc3RhdGUuY2hlY2ssIGhidWYsIDQsIDApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICBiaXRzID0gMDsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBPUzsKICAgICAgICAgICAgICBjYXNlIE9TOgogICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAxNikgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuaGVhZCkgewogICAgICAgICAgICAgICAgICBzdGF0ZS5oZWFkLnhmbGFncyA9IGhvbGQgJiAyNTU7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmhlYWQub3MgPSBob2xkID4+IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiA1MTIpIHsKICAgICAgICAgICAgICAgICAgaGJ1ZlswXSA9IGhvbGQgJiAyNTU7CiAgICAgICAgICAgICAgICAgIGhidWZbMV0gPSBob2xkID4+PiA4ICYgMjU1OwogICAgICAgICAgICAgICAgICBzdGF0ZS5jaGVjayA9IGNyYzMyKHN0YXRlLmNoZWNrLCBoYnVmLCAyLCAwKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGhvbGQgPSAwOwogICAgICAgICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gRVhMRU47CiAgICAgICAgICAgICAgY2FzZSBFWExFTjoKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDEwMjQpIHsKICAgICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAxNikgewogICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgc3RhdGUubGVuZ3RoID0gaG9sZDsKICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHsKICAgICAgICAgICAgICAgICAgICBzdGF0ZS5oZWFkLmV4dHJhX2xlbiA9IGhvbGQ7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgNTEyKSB7CiAgICAgICAgICAgICAgICAgICAgaGJ1ZlswXSA9IGhvbGQgJiAyNTU7CiAgICAgICAgICAgICAgICAgICAgaGJ1ZlsxXSA9IGhvbGQgPj4+IDggJiAyNTU7CiAgICAgICAgICAgICAgICAgICAgc3RhdGUuY2hlY2sgPSBjcmMzMihzdGF0ZS5jaGVjaywgaGJ1ZiwgMiwgMCk7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICAgIGJpdHMgPSAwOwogICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzdGF0ZS5oZWFkKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmhlYWQuZXh0cmEgPSBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEVYVFJBOwogICAgICAgICAgICAgIGNhc2UgRVhUUkE6CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiAxMDI0KSB7CiAgICAgICAgICAgICAgICAgIGNvcHkgPSBzdGF0ZS5sZW5ndGg7CiAgICAgICAgICAgICAgICAgIGlmIChjb3B5ID4gaGF2ZSkgewogICAgICAgICAgICAgICAgICAgIGNvcHkgPSBoYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChjb3B5KSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHsKICAgICAgICAgICAgICAgICAgICAgIGxlbiA9IHN0YXRlLmhlYWQuZXh0cmFfbGVuIC0gc3RhdGUubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZS5oZWFkLmV4dHJhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLmhlYWQuZXh0cmEgPSBuZXcgQXJyYXkoc3RhdGUuaGVhZC5leHRyYV9sZW4pOwogICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgdXRpbHMuYXJyYXlTZXQoc3RhdGUuaGVhZC5leHRyYSwgaW5wdXQsIG5leHQsIGNvcHksIGxlbik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDUxMikgewogICAgICAgICAgICAgICAgICAgICAgc3RhdGUuY2hlY2sgPSBjcmMzMihzdGF0ZS5jaGVjaywgaW5wdXQsIGNvcHksIG5leHQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXZlIC09IGNvcHk7CiAgICAgICAgICAgICAgICAgICAgbmV4dCArPSBjb3B5OwogICAgICAgICAgICAgICAgICAgIHN0YXRlLmxlbmd0aCAtPSBjb3B5OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gTkFNRTsKICAgICAgICAgICAgICBjYXNlIE5BTUU6CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiAyMDQ4KSB7CiAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGNvcHkgPSAwOwogICAgICAgICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgICAgICAgbGVuID0gaW5wdXRbbmV4dCArIGNvcHkrK107CiAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLmhlYWQgJiYgbGVuICYmIHN0YXRlLmxlbmd0aCA8IDY1NTM2KSB7CiAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5oZWFkLm5hbWUgKz0gU3RyaW5nLmZyb21DaGFyQ29kZShsZW4pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgfSB3aGlsZSAobGVuICYmIGNvcHkgPCBoYXZlKTsKICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgNTEyKSB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGUuY2hlY2sgPSBjcmMzMihzdGF0ZS5jaGVjaywgaW5wdXQsIGNvcHksIG5leHQpOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGhhdmUgLT0gY29weTsKICAgICAgICAgICAgICAgICAgbmV4dCArPSBjb3B5OwogICAgICAgICAgICAgICAgICBpZiAobGVuKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHN0YXRlLmhlYWQpIHsKICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC5uYW1lID0gbnVsbDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQ09NTUVOVDsKICAgICAgICAgICAgICBjYXNlIENPTU1FTlQ6CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiA0MDk2KSB7CiAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGNvcHkgPSAwOwogICAgICAgICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgICAgICAgbGVuID0gaW5wdXRbbmV4dCArIGNvcHkrK107CiAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLmhlYWQgJiYgbGVuICYmIHN0YXRlLmxlbmd0aCA8IDY1NTM2KSB7CiAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5oZWFkLmNvbW1lbnQgKz0gU3RyaW5nLmZyb21DaGFyQ29kZShsZW4pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgfSB3aGlsZSAobGVuICYmIGNvcHkgPCBoYXZlKTsKICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgNTEyKSB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGUuY2hlY2sgPSBjcmMzMihzdGF0ZS5jaGVjaywgaW5wdXQsIGNvcHksIG5leHQpOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGhhdmUgLT0gY29weTsKICAgICAgICAgICAgICAgICAgbmV4dCArPSBjb3B5OwogICAgICAgICAgICAgICAgICBpZiAobGVuKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHN0YXRlLmhlYWQpIHsKICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC5jb21tZW50ID0gbnVsbDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBIQ1JDOwogICAgICAgICAgICAgIGNhc2UgSENSQzoKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDUxMikgewogICAgICAgICAgICAgICAgICB3aGlsZSAoYml0cyA8IDE2KSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoaG9sZCAhPT0gKHN0YXRlLmNoZWNrICYgNjU1MzUpKSB7CiAgICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaGVhZGVyIGNyYyBtaXNtYXRjaCI7CiAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBob2xkID0gMDsKICAgICAgICAgICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuaGVhZCkgewogICAgICAgICAgICAgICAgICBzdGF0ZS5oZWFkLmhjcmMgPSBzdGF0ZS5mbGFncyA+PiA5ICYgMTsKICAgICAgICAgICAgICAgICAgc3RhdGUuaGVhZC5kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0cm0uYWRsZXIgPSBzdGF0ZS5jaGVjayA9IDA7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gVFlQRTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGNhc2UgRElDVElEOgogICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAzMikgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdHJtLmFkbGVyID0gc3RhdGUuY2hlY2sgPSB6c3dhcDMyKGhvbGQpOwogICAgICAgICAgICAgICAgaG9sZCA9IDA7CiAgICAgICAgICAgICAgICBiaXRzID0gMDsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBESUNUOwogICAgICAgICAgICAgIGNhc2UgRElDVDoKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5oYXZlZGljdCA9PT0gMCkgewogICAgICAgICAgICAgICAgICBzdHJtLm5leHRfb3V0ID0gcHV0OwogICAgICAgICAgICAgICAgICBzdHJtLmF2YWlsX291dCA9IGxlZnQ7CiAgICAgICAgICAgICAgICAgIHN0cm0ubmV4dF9pbiA9IG5leHQ7CiAgICAgICAgICAgICAgICAgIHN0cm0uYXZhaWxfaW4gPSBoYXZlOwogICAgICAgICAgICAgICAgICBzdGF0ZS5ob2xkID0gaG9sZDsKICAgICAgICAgICAgICAgICAgc3RhdGUuYml0cyA9IGJpdHM7CiAgICAgICAgICAgICAgICAgIHJldHVybiBaX05FRURfRElDVDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0cm0uYWRsZXIgPSBzdGF0ZS5jaGVjayA9IDE7CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gVFlQRTsKICAgICAgICAgICAgICBjYXNlIFRZUEU6CiAgICAgICAgICAgICAgICBpZiAoZmx1c2ggPT09IFpfQkxPQ0sgfHwgZmx1c2ggPT09IFpfVFJFRVMpIHsKICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNhc2UgVFlQRURPOgogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmxhc3QpIHsKICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IGJpdHMgJiA3OwogICAgICAgICAgICAgICAgICBiaXRzIC09IGJpdHMgJiA3OwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQ0hFQ0s7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAzKSB7CiAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLmxhc3QgPSBob2xkICYgMTsKICAgICAgICAgICAgICAgIGhvbGQgPj4+PSAxOwogICAgICAgICAgICAgICAgYml0cyAtPSAxOwogICAgICAgICAgICAgICAgc3dpdGNoIChob2xkICYgMykgewogICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IFNUT1JFRDsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgY2FzZSAxOgogICAgICAgICAgICAgICAgICAgIGZpeGVkdGFibGVzKHN0YXRlKTsKICAgICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gTEVOXzsKICAgICAgICAgICAgICAgICAgICBpZiAoZmx1c2ggPT09IFpfVFJFRVMpIHsKICAgICAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSAyOwogICAgICAgICAgICAgICAgICAgICAgYml0cyAtPSAyOwogICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBUQUJMRTsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgY2FzZSAzOgogICAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgYmxvY2sgdHlwZSI7CiAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGhvbGQgPj4+PSAyOwogICAgICAgICAgICAgICAgYml0cyAtPSAyOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSBTVE9SRUQ6CiAgICAgICAgICAgICAgICBob2xkID4+Pj0gYml0cyAmIDc7CiAgICAgICAgICAgICAgICBiaXRzIC09IGJpdHMgJiA3OwogICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAzMikgewogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoKGhvbGQgJiA2NTUzNSkgIT09IChob2xkID4+PiAxNiBeIDY1NTM1KSkgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIHN0b3JlZCBibG9jayBsZW5ndGhzIjsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5sZW5ndGggPSBob2xkICYgNjU1MzU7CiAgICAgICAgICAgICAgICBob2xkID0gMDsKICAgICAgICAgICAgICAgIGJpdHMgPSAwOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IENPUFlfOwogICAgICAgICAgICAgICAgaWYgKGZsdXNoID09PSBaX1RSRUVTKSB7CiAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjYXNlIENPUFlfOgogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IENPUFk7CiAgICAgICAgICAgICAgY2FzZSBDT1BZOgogICAgICAgICAgICAgICAgY29weSA9IHN0YXRlLmxlbmd0aDsKICAgICAgICAgICAgICAgIGlmIChjb3B5KSB7CiAgICAgICAgICAgICAgICAgIGlmIChjb3B5ID4gaGF2ZSkgewogICAgICAgICAgICAgICAgICAgIGNvcHkgPSBoYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChjb3B5ID4gbGVmdCkgewogICAgICAgICAgICAgICAgICAgIGNvcHkgPSBsZWZ0OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChjb3B5ID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIHV0aWxzLmFycmF5U2V0KG91dHB1dCwgaW5wdXQsIG5leHQsIGNvcHksIHB1dCk7CiAgICAgICAgICAgICAgICAgIGhhdmUgLT0gY29weTsKICAgICAgICAgICAgICAgICAgbmV4dCArPSBjb3B5OwogICAgICAgICAgICAgICAgICBsZWZ0IC09IGNvcHk7CiAgICAgICAgICAgICAgICAgIHB1dCArPSBjb3B5OwogICAgICAgICAgICAgICAgICBzdGF0ZS5sZW5ndGggLT0gY29weTsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gVFlQRTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGNhc2UgVEFCTEU6CiAgICAgICAgICAgICAgICB3aGlsZSAoYml0cyA8IDE0KSB7CiAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLm5sZW4gPSAoaG9sZCAmIDMxKSArIDI1NzsKICAgICAgICAgICAgICAgIGhvbGQgPj4+PSA1OwogICAgICAgICAgICAgICAgYml0cyAtPSA1OwogICAgICAgICAgICAgICAgc3RhdGUubmRpc3QgPSAoaG9sZCAmIDMxKSArIDE7CiAgICAgICAgICAgICAgICBob2xkID4+Pj0gNTsKICAgICAgICAgICAgICAgIGJpdHMgLT0gNTsKICAgICAgICAgICAgICAgIHN0YXRlLm5jb2RlID0gKGhvbGQgJiAxNSkgKyA0OwogICAgICAgICAgICAgICAgaG9sZCA+Pj49IDQ7CiAgICAgICAgICAgICAgICBiaXRzIC09IDQ7CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUubmxlbiA+IDI4NiB8fCBzdGF0ZS5uZGlzdCA+IDMwKSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gInRvbyBtYW55IGxlbmd0aCBvciBkaXN0YW5jZSBzeW1ib2xzIjsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5oYXZlID0gMDsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBMRU5MRU5TOwogICAgICAgICAgICAgIGNhc2UgTEVOTEVOUzoKICAgICAgICAgICAgICAgIHdoaWxlIChzdGF0ZS5oYXZlIDwgc3RhdGUubmNvZGUpIHsKICAgICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBzdGF0ZS5sZW5zW29yZGVyW3N0YXRlLmhhdmUrK11dID0gaG9sZCAmIDc7CiAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSAzOwogICAgICAgICAgICAgICAgICBiaXRzIC09IDM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB3aGlsZSAoc3RhdGUuaGF2ZSA8IDE5KSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmxlbnNbb3JkZXJbc3RhdGUuaGF2ZSsrXV0gPSAwOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUubGVuY29kZSA9IHN0YXRlLmxlbmR5bjsKICAgICAgICAgICAgICAgIHN0YXRlLmxlbmJpdHMgPSA3OwogICAgICAgICAgICAgICAgb3B0cyA9IHsgYml0czogc3RhdGUubGVuYml0cyB9OwogICAgICAgICAgICAgICAgcmV0ID0gaW5mbGF0ZV90YWJsZShDT0RFUywgc3RhdGUubGVucywgMCwgMTksIHN0YXRlLmxlbmNvZGUsIDAsIHN0YXRlLndvcmssIG9wdHMpOwogICAgICAgICAgICAgICAgc3RhdGUubGVuYml0cyA9IG9wdHMuYml0czsKICAgICAgICAgICAgICAgIGlmIChyZXQpIHsKICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBjb2RlIGxlbmd0aHMgc2V0IjsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5oYXZlID0gMDsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBDT0RFTEVOUzsKICAgICAgICAgICAgICBjYXNlIENPREVMRU5TOgogICAgICAgICAgICAgICAgd2hpbGUgKHN0YXRlLmhhdmUgPCBzdGF0ZS5ubGVuICsgc3RhdGUubmRpc3QpIHsKICAgICAgICAgICAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICAgICAgICAgICAgaGVyZSA9IHN0YXRlLmxlbmNvZGVbaG9sZCAmICgxIDw8IHN0YXRlLmxlbmJpdHMpIC0gMV07CiAgICAgICAgICAgICAgICAgICAgaGVyZV9iaXRzID0gaGVyZSA+Pj4gMjQ7CiAgICAgICAgICAgICAgICAgICAgaGVyZV9vcCA9IGhlcmUgPj4+IDE2ICYgMjU1OwogICAgICAgICAgICAgICAgICAgIGhlcmVfdmFsID0gaGVyZSAmIDY1NTM1OwogICAgICAgICAgICAgICAgICAgIGlmIChoZXJlX2JpdHMgPD0gYml0cykgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaWYgKGhlcmVfdmFsIDwgMTYpIHsKICAgICAgICAgICAgICAgICAgICBob2xkID4+Pj0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgICAgIGJpdHMgLT0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgICAgIHN0YXRlLmxlbnNbc3RhdGUuaGF2ZSsrXSA9IGhlcmVfdmFsOwogICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgIGlmIChoZXJlX3ZhbCA9PT0gMTYpIHsKICAgICAgICAgICAgICAgICAgICAgIG4gPSBoZXJlX2JpdHMgKyAyOwogICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCBuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICAgICAgICBiaXRzIC09IGhlcmVfYml0czsKICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5oYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgYml0IGxlbmd0aCByZXBlYXQiOwogICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgIGxlbiA9IHN0YXRlLmxlbnNbc3RhdGUuaGF2ZSAtIDFdOwogICAgICAgICAgICAgICAgICAgICAgY29weSA9IDMgKyAoaG9sZCAmIDMpOwogICAgICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IDI7CiAgICAgICAgICAgICAgICAgICAgICBiaXRzIC09IDI7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChoZXJlX3ZhbCA9PT0gMTcpIHsKICAgICAgICAgICAgICAgICAgICAgIG4gPSBoZXJlX2JpdHMgKyAzOwogICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCBuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICAgICAgICBiaXRzIC09IGhlcmVfYml0czsKICAgICAgICAgICAgICAgICAgICAgIGxlbiA9IDA7CiAgICAgICAgICAgICAgICAgICAgICBjb3B5ID0gMyArIChob2xkICYgNyk7CiAgICAgICAgICAgICAgICAgICAgICBob2xkID4+Pj0gMzsKICAgICAgICAgICAgICAgICAgICAgIGJpdHMgLT0gMzsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgbiA9IGhlcmVfYml0cyArIDc7CiAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoYml0cyA8IG4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaGF2ZS0tOwogICAgICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IGhlcmVfYml0czsKICAgICAgICAgICAgICAgICAgICAgIGJpdHMgLT0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgICAgICAgbGVuID0gMDsKICAgICAgICAgICAgICAgICAgICAgIGNvcHkgPSAxMSArIChob2xkICYgMTI3KTsKICAgICAgICAgICAgICAgICAgICAgIGhvbGQgPj4+PSA3OwogICAgICAgICAgICAgICAgICAgICAgYml0cyAtPSA3OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGUuaGF2ZSArIGNvcHkgPiBzdGF0ZS5ubGVuICsgc3RhdGUubmRpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgYml0IGxlbmd0aCByZXBlYXQiOwogICAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB3aGlsZSAoY29weS0tKSB7CiAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5sZW5zW3N0YXRlLmhhdmUrK10gPSBsZW47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUubW9kZSA9PT0gQkFEKSB7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHN0YXRlLmxlbnNbMjU2XSA9PT0gMCkgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGNvZGUgLS0gbWlzc2luZyBlbmQtb2YtYmxvY2siOwogICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YXRlLmxlbmJpdHMgPSA5OwogICAgICAgICAgICAgICAgb3B0cyA9IHsgYml0czogc3RhdGUubGVuYml0cyB9OwogICAgICAgICAgICAgICAgcmV0ID0gaW5mbGF0ZV90YWJsZShMRU5TLCBzdGF0ZS5sZW5zLCAwLCBzdGF0ZS5ubGVuLCBzdGF0ZS5sZW5jb2RlLCAwLCBzdGF0ZS53b3JrLCBvcHRzKTsKICAgICAgICAgICAgICAgIHN0YXRlLmxlbmJpdHMgPSBvcHRzLmJpdHM7CiAgICAgICAgICAgICAgICBpZiAocmV0KSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgbGl0ZXJhbC9sZW5ndGhzIHNldCI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUuZGlzdGJpdHMgPSA2OwogICAgICAgICAgICAgICAgc3RhdGUuZGlzdGNvZGUgPSBzdGF0ZS5kaXN0ZHluOwogICAgICAgICAgICAgICAgb3B0cyA9IHsgYml0czogc3RhdGUuZGlzdGJpdHMgfTsKICAgICAgICAgICAgICAgIHJldCA9IGluZmxhdGVfdGFibGUoRElTVFMsIHN0YXRlLmxlbnMsIHN0YXRlLm5sZW4sIHN0YXRlLm5kaXN0LCBzdGF0ZS5kaXN0Y29kZSwgMCwgc3RhdGUud29yaywgb3B0cyk7CiAgICAgICAgICAgICAgICBzdGF0ZS5kaXN0Yml0cyA9IG9wdHMuYml0czsKICAgICAgICAgICAgICAgIGlmIChyZXQpIHsKICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBkaXN0YW5jZXMgc2V0IjsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gTEVOXzsKICAgICAgICAgICAgICAgIGlmIChmbHVzaCA9PT0gWl9UUkVFUykgewogICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY2FzZSBMRU5fOgogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IExFTjsKICAgICAgICAgICAgICBjYXNlIExFTjoKICAgICAgICAgICAgICAgIGlmIChoYXZlID49IDYgJiYgbGVmdCA+PSAyNTgpIHsKICAgICAgICAgICAgICAgICAgc3RybS5uZXh0X291dCA9IHB1dDsKICAgICAgICAgICAgICAgICAgc3RybS5hdmFpbF9vdXQgPSBsZWZ0OwogICAgICAgICAgICAgICAgICBzdHJtLm5leHRfaW4gPSBuZXh0OwogICAgICAgICAgICAgICAgICBzdHJtLmF2YWlsX2luID0gaGF2ZTsKICAgICAgICAgICAgICAgICAgc3RhdGUuaG9sZCA9IGhvbGQ7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmJpdHMgPSBiaXRzOwogICAgICAgICAgICAgICAgICBpbmZsYXRlX2Zhc3Qoc3RybSwgX291dCk7CiAgICAgICAgICAgICAgICAgIHB1dCA9IHN0cm0ubmV4dF9vdXQ7CiAgICAgICAgICAgICAgICAgIG91dHB1dCA9IHN0cm0ub3V0cHV0OwogICAgICAgICAgICAgICAgICBsZWZ0ID0gc3RybS5hdmFpbF9vdXQ7CiAgICAgICAgICAgICAgICAgIG5leHQgPSBzdHJtLm5leHRfaW47CiAgICAgICAgICAgICAgICAgIGlucHV0ID0gc3RybS5pbnB1dDsKICAgICAgICAgICAgICAgICAgaGF2ZSA9IHN0cm0uYXZhaWxfaW47CiAgICAgICAgICAgICAgICAgIGhvbGQgPSBzdGF0ZS5ob2xkOwogICAgICAgICAgICAgICAgICBiaXRzID0gc3RhdGUuYml0czsKICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLm1vZGUgPT09IFRZUEUpIHsKICAgICAgICAgICAgICAgICAgICBzdGF0ZS5iYWNrID0gLTE7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5iYWNrID0gMDsKICAgICAgICAgICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgICAgICAgICBoZXJlID0gc3RhdGUubGVuY29kZVtob2xkICYgKDEgPDwgc3RhdGUubGVuYml0cykgLSAxXTsKICAgICAgICAgICAgICAgICAgaGVyZV9iaXRzID0gaGVyZSA+Pj4gMjQ7CiAgICAgICAgICAgICAgICAgIGhlcmVfb3AgPSBoZXJlID4+PiAxNiAmIDI1NTsKICAgICAgICAgICAgICAgICAgaGVyZV92YWwgPSBoZXJlICYgNjU1MzU7CiAgICAgICAgICAgICAgICAgIGlmIChoZXJlX2JpdHMgPD0gYml0cykgewogICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgIGJpdHMgKz0gODsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChoZXJlX29wICYmIChoZXJlX29wICYgMjQwKSA9PT0gMCkgewogICAgICAgICAgICAgICAgICBsYXN0X2JpdHMgPSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICAgIGxhc3Rfb3AgPSBoZXJlX29wOwogICAgICAgICAgICAgICAgICBsYXN0X3ZhbCA9IGhlcmVfdmFsOwogICAgICAgICAgICAgICAgICBmb3IgKDsgOyApIHsKICAgICAgICAgICAgICAgICAgICBoZXJlID0gc3RhdGUubGVuY29kZVtsYXN0X3ZhbCArICgoaG9sZCAmICgxIDw8IGxhc3RfYml0cyArIGxhc3Rfb3ApIC0gMSkgPj4gbGFzdF9iaXRzKV07CiAgICAgICAgICAgICAgICAgICAgaGVyZV9iaXRzID0gaGVyZSA+Pj4gMjQ7CiAgICAgICAgICAgICAgICAgICAgaGVyZV9vcCA9IGhlcmUgPj4+IDE2ICYgMjU1OwogICAgICAgICAgICAgICAgICAgIGhlcmVfdmFsID0gaGVyZSAmIDY1NTM1OwogICAgICAgICAgICAgICAgICAgIGlmIChsYXN0X2JpdHMgKyBoZXJlX2JpdHMgPD0gYml0cykgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IGxhc3RfYml0czsKICAgICAgICAgICAgICAgICAgYml0cyAtPSBsYXN0X2JpdHM7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmJhY2sgKz0gbGFzdF9iaXRzOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaG9sZCA+Pj49IGhlcmVfYml0czsKICAgICAgICAgICAgICAgIGJpdHMgLT0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgc3RhdGUuYmFjayArPSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICBzdGF0ZS5sZW5ndGggPSBoZXJlX3ZhbDsKICAgICAgICAgICAgICAgIGlmIChoZXJlX29wID09PSAwKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBMSVQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKGhlcmVfb3AgJiAzMikgewogICAgICAgICAgICAgICAgICBzdGF0ZS5iYWNrID0gLTE7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBUWVBFOwogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChoZXJlX29wICYgNjQpIHsKICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW52YWxpZCBsaXRlcmFsL2xlbmd0aCBjb2RlIjsKICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5leHRyYSA9IGhlcmVfb3AgJiAxNTsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBMRU5FWFQ7CiAgICAgICAgICAgICAgY2FzZSBMRU5FWFQ6CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUuZXh0cmEpIHsKICAgICAgICAgICAgICAgICAgbiA9IHN0YXRlLmV4dHJhOwogICAgICAgICAgICAgICAgICB3aGlsZSAoYml0cyA8IG4pIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIHN0YXRlLmxlbmd0aCArPSBob2xkICYgKDEgPDwgc3RhdGUuZXh0cmEpIC0gMTsKICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IHN0YXRlLmV4dHJhOwogICAgICAgICAgICAgICAgICBiaXRzIC09IHN0YXRlLmV4dHJhOwogICAgICAgICAgICAgICAgICBzdGF0ZS5iYWNrICs9IHN0YXRlLmV4dHJhOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUud2FzID0gc3RhdGUubGVuZ3RoOwogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IERJU1Q7CiAgICAgICAgICAgICAgY2FzZSBESVNUOgogICAgICAgICAgICAgICAgZm9yICg7IDsgKSB7CiAgICAgICAgICAgICAgICAgIGhlcmUgPSBzdGF0ZS5kaXN0Y29kZVtob2xkICYgKDEgPDwgc3RhdGUuZGlzdGJpdHMpIC0gMV07CiAgICAgICAgICAgICAgICAgIGhlcmVfYml0cyA9IGhlcmUgPj4+IDI0OwogICAgICAgICAgICAgICAgICBoZXJlX29wID0gaGVyZSA+Pj4gMTYgJiAyNTU7CiAgICAgICAgICAgICAgICAgIGhlcmVfdmFsID0gaGVyZSAmIDY1NTM1OwogICAgICAgICAgICAgICAgICBpZiAoaGVyZV9iaXRzIDw9IGJpdHMpIHsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzOwogICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoKGhlcmVfb3AgJiAyNDApID09PSAwKSB7CiAgICAgICAgICAgICAgICAgIGxhc3RfYml0cyA9IGhlcmVfYml0czsKICAgICAgICAgICAgICAgICAgbGFzdF9vcCA9IGhlcmVfb3A7CiAgICAgICAgICAgICAgICAgIGxhc3RfdmFsID0gaGVyZV92YWw7CiAgICAgICAgICAgICAgICAgIGZvciAoOyA7ICkgewogICAgICAgICAgICAgICAgICAgIGhlcmUgPSBzdGF0ZS5kaXN0Y29kZVtsYXN0X3ZhbCArICgoaG9sZCAmICgxIDw8IGxhc3RfYml0cyArIGxhc3Rfb3ApIC0gMSkgPj4gbGFzdF9iaXRzKV07CiAgICAgICAgICAgICAgICAgICAgaGVyZV9iaXRzID0gaGVyZSA+Pj4gMjQ7CiAgICAgICAgICAgICAgICAgICAgaGVyZV9vcCA9IGhlcmUgPj4+IDE2ICYgMjU1OwogICAgICAgICAgICAgICAgICAgIGhlcmVfdmFsID0gaGVyZSAmIDY1NTM1OwogICAgICAgICAgICAgICAgICAgIGlmIChsYXN0X2JpdHMgKyBoZXJlX2JpdHMgPD0gYml0cykgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaG9sZCA+Pj49IGxhc3RfYml0czsKICAgICAgICAgICAgICAgICAgYml0cyAtPSBsYXN0X2JpdHM7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmJhY2sgKz0gbGFzdF9iaXRzOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaG9sZCA+Pj49IGhlcmVfYml0czsKICAgICAgICAgICAgICAgIGJpdHMgLT0gaGVyZV9iaXRzOwogICAgICAgICAgICAgICAgc3RhdGUuYmFjayArPSBoZXJlX2JpdHM7CiAgICAgICAgICAgICAgICBpZiAoaGVyZV9vcCAmIDY0KSB7CiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gImludmFsaWQgZGlzdGFuY2UgY29kZSI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUub2Zmc2V0ID0gaGVyZV92YWw7CiAgICAgICAgICAgICAgICBzdGF0ZS5leHRyYSA9IGhlcmVfb3AgJiAxNTsKICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBESVNURVhUOwogICAgICAgICAgICAgIGNhc2UgRElTVEVYVDoKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5leHRyYSkgewogICAgICAgICAgICAgICAgICBuID0gc3RhdGUuZXh0cmE7CiAgICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgbikgewogICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgc3RhdGUub2Zmc2V0ICs9IGhvbGQgJiAoMSA8PCBzdGF0ZS5leHRyYSkgLSAxOwogICAgICAgICAgICAgICAgICBob2xkID4+Pj0gc3RhdGUuZXh0cmE7CiAgICAgICAgICAgICAgICAgIGJpdHMgLT0gc3RhdGUuZXh0cmE7CiAgICAgICAgICAgICAgICAgIHN0YXRlLmJhY2sgKz0gc3RhdGUuZXh0cmE7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUub2Zmc2V0ID4gc3RhdGUuZG1heCkgewogICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGRpc3RhbmNlIHRvbyBmYXIgYmFjayI7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7CiAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IE1BVENIOwogICAgICAgICAgICAgIGNhc2UgTUFUQ0g6CiAgICAgICAgICAgICAgICBpZiAobGVmdCA9PT0gMCkgewogICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb3B5ID0gX291dCAtIGxlZnQ7CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUub2Zmc2V0ID4gY29weSkgewogICAgICAgICAgICAgICAgICBjb3B5ID0gc3RhdGUub2Zmc2V0IC0gY29weTsKICAgICAgICAgICAgICAgICAgaWYgKGNvcHkgPiBzdGF0ZS53aGF2ZSkgewogICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5zYW5lKSB7CiAgICAgICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbnZhbGlkIGRpc3RhbmNlIHRvbyBmYXIgYmFjayI7CiAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEOwogICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChjb3B5ID4gc3RhdGUud25leHQpIHsKICAgICAgICAgICAgICAgICAgICBjb3B5IC09IHN0YXRlLnduZXh0OwogICAgICAgICAgICAgICAgICAgIGZyb20gPSBzdGF0ZS53c2l6ZSAtIGNvcHk7CiAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgZnJvbSA9IHN0YXRlLnduZXh0IC0gY29weTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBpZiAoY29weSA+IHN0YXRlLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgIGNvcHkgPSBzdGF0ZS5sZW5ndGg7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgZnJvbV9zb3VyY2UgPSBzdGF0ZS53aW5kb3c7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICBmcm9tX3NvdXJjZSA9IG91dHB1dDsKICAgICAgICAgICAgICAgICAgZnJvbSA9IHB1dCAtIHN0YXRlLm9mZnNldDsKICAgICAgICAgICAgICAgICAgY29weSA9IHN0YXRlLmxlbmd0aDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChjb3B5ID4gbGVmdCkgewogICAgICAgICAgICAgICAgICBjb3B5ID0gbGVmdDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGxlZnQgLT0gY29weTsKICAgICAgICAgICAgICAgIHN0YXRlLmxlbmd0aCAtPSBjb3B5OwogICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICBvdXRwdXRbcHV0KytdID0gZnJvbV9zb3VyY2VbZnJvbSsrXTsKICAgICAgICAgICAgICAgIH0gd2hpbGUgKC0tY29weSk7CiAgICAgICAgICAgICAgICBpZiAoc3RhdGUubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBMRU47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIExJVDoKICAgICAgICAgICAgICAgIGlmIChsZWZ0ID09PSAwKSB7CiAgICAgICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIG91dHB1dFtwdXQrK10gPSBzdGF0ZS5sZW5ndGg7CiAgICAgICAgICAgICAgICBsZWZ0LS07CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gTEVOOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSBDSEVDSzoKICAgICAgICAgICAgICAgIGlmIChzdGF0ZS53cmFwKSB7CiAgICAgICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgMzIpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXZlLS07CiAgICAgICAgICAgICAgICAgICAgaG9sZCB8PSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7CiAgICAgICAgICAgICAgICAgICAgYml0cyArPSA4OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIF9vdXQgLT0gbGVmdDsKICAgICAgICAgICAgICAgICAgc3RybS50b3RhbF9vdXQgKz0gX291dDsKICAgICAgICAgICAgICAgICAgc3RhdGUudG90YWwgKz0gX291dDsKICAgICAgICAgICAgICAgICAgaWYgKF9vdXQpIHsKICAgICAgICAgICAgICAgICAgICBzdHJtLmFkbGVyID0gc3RhdGUuY2hlY2sgPSBzdGF0ZS5mbGFncyA/IGNyYzMyKHN0YXRlLmNoZWNrLCBvdXRwdXQsIF9vdXQsIHB1dCAtIF9vdXQpIDogYWRsZXIzMihzdGF0ZS5jaGVjaywgb3V0cHV0LCBfb3V0LCBwdXQgLSBfb3V0KTsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBfb3V0ID0gbGVmdDsKICAgICAgICAgICAgICAgICAgaWYgKChzdGF0ZS5mbGFncyA/IGhvbGQgOiB6c3dhcDMyKGhvbGQpKSAhPT0gc3RhdGUuY2hlY2spIHsKICAgICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICJpbmNvcnJlY3QgZGF0YSBjaGVjayI7CiAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBob2xkID0gMDsKICAgICAgICAgICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gTEVOR1RIOwogICAgICAgICAgICAgIGNhc2UgTEVOR1RIOgogICAgICAgICAgICAgICAgaWYgKHN0YXRlLndyYXAgJiYgc3RhdGUuZmxhZ3MpIHsKICAgICAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCAzMikgewogICAgICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhdmUtLTsKICAgICAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0czsKICAgICAgICAgICAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgaWYgKGhvbGQgIT09IChzdGF0ZS50b3RhbCAmIDQyOTQ5NjcyOTUpKSB7CiAgICAgICAgICAgICAgICAgICAgc3RybS5tc2cgPSAiaW5jb3JyZWN0IGxlbmd0aCBjaGVjayI7CiAgICAgICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICBob2xkID0gMDsKICAgICAgICAgICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gRE9ORTsKICAgICAgICAgICAgICBjYXNlIERPTkU6CiAgICAgICAgICAgICAgICByZXQgPSBaX1NUUkVBTV9FTkQ7CiAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgY2FzZSBCQUQ6CiAgICAgICAgICAgICAgICByZXQgPSBaX0RBVEFfRVJST1I7CiAgICAgICAgICAgICAgICBicmVhayBpbmZfbGVhdmU7CiAgICAgICAgICAgICAgY2FzZSBNRU06CiAgICAgICAgICAgICAgICByZXR1cm4gWl9NRU1fRVJST1I7CiAgICAgICAgICAgICAgY2FzZSBTWU5DOgogICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICBzdHJtLm5leHRfb3V0ID0gcHV0OwogICAgICAgIHN0cm0uYXZhaWxfb3V0ID0gbGVmdDsKICAgICAgICBzdHJtLm5leHRfaW4gPSBuZXh0OwogICAgICAgIHN0cm0uYXZhaWxfaW4gPSBoYXZlOwogICAgICAgIHN0YXRlLmhvbGQgPSBob2xkOwogICAgICAgIHN0YXRlLmJpdHMgPSBiaXRzOwogICAgICAgIGlmIChzdGF0ZS53c2l6ZSB8fCBfb3V0ICE9PSBzdHJtLmF2YWlsX291dCAmJiBzdGF0ZS5tb2RlIDwgQkFEICYmIChzdGF0ZS5tb2RlIDwgQ0hFQ0sgfHwgZmx1c2ggIT09IFpfRklOSVNIKSkgewogICAgICAgICAgaWYgKHVwZGF0ZXdpbmRvdyhzdHJtLCBzdHJtLm91dHB1dCwgc3RybS5uZXh0X291dCwgX291dCAtIHN0cm0uYXZhaWxfb3V0KSkgewogICAgICAgICAgICBzdGF0ZS5tb2RlID0gTUVNOwogICAgICAgICAgICByZXR1cm4gWl9NRU1fRVJST1I7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIF9pbiAtPSBzdHJtLmF2YWlsX2luOwogICAgICAgIF9vdXQgLT0gc3RybS5hdmFpbF9vdXQ7CiAgICAgICAgc3RybS50b3RhbF9pbiArPSBfaW47CiAgICAgICAgc3RybS50b3RhbF9vdXQgKz0gX291dDsKICAgICAgICBzdGF0ZS50b3RhbCArPSBfb3V0OwogICAgICAgIGlmIChzdGF0ZS53cmFwICYmIF9vdXQpIHsKICAgICAgICAgIHN0cm0uYWRsZXIgPSBzdGF0ZS5jaGVjayA9IHN0YXRlLmZsYWdzID8gY3JjMzIoc3RhdGUuY2hlY2ssIG91dHB1dCwgX291dCwgc3RybS5uZXh0X291dCAtIF9vdXQpIDogYWRsZXIzMihzdGF0ZS5jaGVjaywgb3V0cHV0LCBfb3V0LCBzdHJtLm5leHRfb3V0IC0gX291dCk7CiAgICAgICAgfQogICAgICAgIHN0cm0uZGF0YV90eXBlID0gc3RhdGUuYml0cyArIChzdGF0ZS5sYXN0ID8gNjQgOiAwKSArIChzdGF0ZS5tb2RlID09PSBUWVBFID8gMTI4IDogMCkgKyAoc3RhdGUubW9kZSA9PT0gTEVOXyB8fCBzdGF0ZS5tb2RlID09PSBDT1BZXyA/IDI1NiA6IDApOwogICAgICAgIGlmICgoX2luID09PSAwICYmIF9vdXQgPT09IDAgfHwgZmx1c2ggPT09IFpfRklOSVNIKSAmJiByZXQgPT09IFpfT0spIHsKICAgICAgICAgIHJldCA9IFpfQlVGX0VSUk9SOwogICAgICAgIH0KICAgICAgICByZXR1cm4gcmV0OwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGluZmxhdGVFbmQoc3RybSkgewogICAgICAgIGlmICghc3RybSB8fCAhc3RybS5zdGF0ZSkgewogICAgICAgICAgcmV0dXJuIFpfU1RSRUFNX0VSUk9SOwogICAgICAgIH0KICAgICAgICB2YXIgc3RhdGUgPSBzdHJtLnN0YXRlOwogICAgICAgIGlmIChzdGF0ZS53aW5kb3cpIHsKICAgICAgICAgIHN0YXRlLndpbmRvdyA9IG51bGw7CiAgICAgICAgfQogICAgICAgIHN0cm0uc3RhdGUgPSBudWxsOwogICAgICAgIHJldHVybiBaX09LOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGluZmxhdGVHZXRIZWFkZXIoc3RybSwgaGVhZCkgewogICAgICAgIHZhciBzdGF0ZTsKICAgICAgICBpZiAoIXN0cm0gfHwgIXN0cm0uc3RhdGUpIHsKICAgICAgICAgIHJldHVybiBaX1NUUkVBTV9FUlJPUjsKICAgICAgICB9CiAgICAgICAgc3RhdGUgPSBzdHJtLnN0YXRlOwogICAgICAgIGlmICgoc3RhdGUud3JhcCAmIDIpID09PSAwKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIHN0YXRlLmhlYWQgPSBoZWFkOwogICAgICAgIGhlYWQuZG9uZSA9IGZhbHNlOwogICAgICAgIHJldHVybiBaX09LOwogICAgICB9CiAgICAgIGZ1bmN0aW9uIGluZmxhdGVTZXREaWN0aW9uYXJ5KHN0cm0sIGRpY3Rpb25hcnkpIHsKICAgICAgICB2YXIgZGljdExlbmd0aCA9IGRpY3Rpb25hcnkubGVuZ3RoOwogICAgICAgIHZhciBzdGF0ZTsKICAgICAgICB2YXIgZGljdGlkOwogICAgICAgIHZhciByZXQ7CiAgICAgICAgaWYgKCFzdHJtIHx8ICFzdHJtLnN0YXRlKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIHN0YXRlID0gc3RybS5zdGF0ZTsKICAgICAgICBpZiAoc3RhdGUud3JhcCAhPT0gMCAmJiBzdGF0ZS5tb2RlICE9PSBESUNUKSB7CiAgICAgICAgICByZXR1cm4gWl9TVFJFQU1fRVJST1I7CiAgICAgICAgfQogICAgICAgIGlmIChzdGF0ZS5tb2RlID09PSBESUNUKSB7CiAgICAgICAgICBkaWN0aWQgPSAxOwogICAgICAgICAgZGljdGlkID0gYWRsZXIzMihkaWN0aWQsIGRpY3Rpb25hcnksIGRpY3RMZW5ndGgsIDApOwogICAgICAgICAgaWYgKGRpY3RpZCAhPT0gc3RhdGUuY2hlY2spIHsKICAgICAgICAgICAgcmV0dXJuIFpfREFUQV9FUlJPUjsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0ID0gdXBkYXRld2luZG93KHN0cm0sIGRpY3Rpb25hcnksIGRpY3RMZW5ndGgsIGRpY3RMZW5ndG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KGV4cG9ydHMyLCBtb2R1bGUyKSB7CiAgICAgIGluaXRfYnVmZmVyX3NoaW0oKTsKICAgICAgInVzZSBzdHJpY3QiOwogICAgICBtb2R1bGUyLmV4cG9ydHMgPSB7CiAgICAgICAgWl9OT19GTFVTSDogMCwKICAgICAgICBaX1BBUlRJQUxfRkxVU0g6IDEsCiAgICAgICAgWl9TWU5DX0ZMVVNIOiAyLAogICAgICAgIFpfRlVMTF9GTFVTSDogMywKICAgICAgICBaX0ZJTklTSDogNCwKICAgICAgICBaX0JMT0NLOiA1LAogICAgICAgIFpfVFJFRVM6IDYsCiAgICAgICAgWl9PSzogMCwKICAgICAgICBaX1NUUkVBTV9FTkQ6IDEsCiAgICAgICAgWl9ORUVEX0RJQ1Q6IDIsCiAgICAgICAgWl9FUlJOTzogLTEsCiAgICAgICAgWl9TVFJFQU1fRVJST1I6IC0yLAogICAgICAgIFpfREFUQV9FUlJPUjogLTMsCiAgICAgICAgWl9CVUZfRVJST1I6IC01LAogICAgICAgIFpfTk9fQ09NUFJFU1NJT046IDAsCiAgICAgICAgWl9CRVNUX1NQRUVEOiAxLAogICAgICAgIFpfQkVTVF9DT01QUkVTU0lPTjogOSwKICAgICAgICBaX0RFRkFVTFRfQ09NUFJFU1NJT046IC0xLAogICAgICAgIFpfRklMVEVSRUQ6IDEsCiAgICAgICAgWl9IVUZGTUFOX09OTFk6IDIsCiAgICAgICAgWl9STEU6IDMsCiAgICAgICAgWl9GSVhFRDogNCwKICAgICAgICBaX0RFRkFVTFRfU1RSQVRFR1k6IDAsCiAgICAgICAgWl9CSU5BUlk6IDAsCiAgICAgICAgWl9URVhUOiAxLAogICAgICAgIFpfVU5LTk9XTjogMiwKICAgICAgICBaX0RFRkxBVEVEOiA4CiAgICAgIH07CiAgICB9CiAgfSk7CgogIC8vIG5vZGVfbW9kdWxlcy8ucG5wbS9wYWtvQDEuMC4xMS9ub2RlX21vZHVsZXMvcGFrby9saWIvemxpYi9nemhlYWRlci5qcwogIHZhciBy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dzID0gcmVxdWlyZV9zdHJpbmdzKCk7CiAgICAgIHZhciBjID0gcmVxdWlyZV9jb25zdGFudHMoKTsKICAgICAgdmFyIG1zZyA9IHJlcXVpcmVfbWVzc2FnZXMoKTsKICAgICAgdmFyIFpTdHJlYW0gPSByZXF1aXJlX3pzdHJlYW0oKTsKICAgICAgdmFyIEdaaGVhZGVyID0gcmVxdWlyZV9nemhlYWRlcigpOwogICAgICB2YXIgdG9TdHJpbmcgPSBPYmplY3QucHJvdG90eXBlLnRvU3RyaW5nOwogICAgICBmdW5jdGlvbiBJbmZsYXRlMihvcHRpb25zKSB7CiAgICAgICAgaWYgKCEodGhpcyBpbnN0YW5jZW9mIEluZmxhdGUyKSkKICAgICAgICAgIHJldHVybiBuZXcgSW5mbGF0ZTIob3B0aW9ucyk7CiAgICAgICAgdGhpcy5vcHRpb25zID0gdXRpbHMuYXNzaWduKHsKICAgICAgICAgIGNodW5rU2l6ZTogMTYzODQsCiAgICAgICAgICB3aW5kb3dCaXRzOiAwLAogICAgICAgICAgdG86ICIiCiAgICAgICAgfSwgb3B0aW9ucyB8fCB7fSk7CiAgICAgICAgdmFyIG9wdCA9IHRoaXMub3B0aW9uczsKICAgICAgICBpZiAob3B0LnJhdyAmJiBvcHQud2luZG93Qml0cyA+PSAwICYmIG9wdC53aW5kb3dCaXRzIDwgMTYpIHsKICAgICAgICAgIG9wdC53aW5kb3dCaXRzID0gLW9wdC53aW5kb3dCaXRzOwogICAgICAgICAgaWYgKG9wdC53aW5kb3dCaXRzID09PSAwKSB7CiAgICAgICAgICAgIG9wdC53aW5kb3dCaXRzID0gLTE1OwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAob3B0LndpbmRvd0JpdHMgPj0gMCAmJiBvcHQud2luZG93Qml0cyA8IDE2ICYmICEob3B0aW9ucyAmJiBvcHRpb25zLndpbmRvd0JpdHMpKSB7CiAgICAgICAgICBvcHQud2luZG93Qml0cyArPSAzMjsKICAgICAgICB9CiAgICAgICAg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XJyYXkob3B0LmRpY3Rpb25hcnkpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG9wdC5yYXcpIHsKICAgICAgICAgICAgc3RhdHVzID0gemxpYl9pbmZsYXRlLmluZmxhdGVTZXREaWN0aW9uYXJ5KHRoaXMuc3RybSwgb3B0LmRpY3Rpb25hcnkpOwogICAgICAgICAgICBpZiAoc3RhdHVzICE9PSBjLlpfT0spIHsKICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IobXNnW3N0YXR1c10pOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIEluZmxhdGUyLnByb3RvdHlwZS5wdXNoID0gZnVuY3Rpb24oZGF0YSwgbW9kZSkgewogICAgICAgIHZhciBzdHJtID0gdGhpcy5zdHJtOwogICAgICAgIHZhciBjaHVua1NpemUgPSB0aGlzLm9wdGlvbnMuY2h1bmtTaXplOwogICAgICAgIHZhciBkaWN0aW9uYXJ5ID0gdGhpcy5vcHRpb25zLmRpY3Rpb25hcnk7CiAgICAgICAgdmFyIHN0YXR1cywgX21vZGU7CiAgICAgICAgdmFyIG5leHRfb3V0X3V0ZjgsIHRhaWwsIHV0ZjhzdHI7CiAgICAgICAgdmFyIGFsbG93QnVmRXJyb3IgPSBmYWxzZTsKICAgICAgICBpZiAodGhpcy5lbmRlZCkgewogICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgICBfbW9kZSA9IG1vZGUgPT09IH5+bW9kZSA/IG1vZGUgOiBtb2RlID09PSB0cnVlID8gYy5aX0ZJTklTSCA6IGMuWl9OT19GTFVTSDsKICAgICAgICBpZiAodHlwZW9mIGRhdGEgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICBzdHJtLmlucHV0ID0gc3RyaW5ncy5iaW5zdHJpbmcyYnVmKGRhdGEpOwogICAgICAgIH0gZWxzZSBpZiAodG9TdHJpbmcuY2FsbChkYXRhKSA9PT0gIltvYmplY3QgQXJyYXlCdWZmZXJdIikgewogICAgICAgICAgc3RybS5pbnB1dCA9IG5ldyBVaW50OEFycmF5KGRhdGEpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBzdHJtLmlucHV0ID0gZGF0YTsKICAgICAgICB9CiAgICAgICAgc3RybS5uZXh0X2luID0gMDsKICAgICAgICBzdHJtLmF2YWlsX2luID0gc3RybS5pbnB1dC5sZW5ndGg7CiAgICAgICAgZG8gewogICAgICAgICAgaWYgKHN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgIHN0cm0ub3V0cHV0ID0gbmV3IHV0aWxzLkJ1ZjgoY2h1bmtTaXplKTsKICAgICAgICAgICAgc3RybS5uZXh0X291dCA9IDA7CiAgICAgICAgICAgIHN0cm0uYXZhaWxfb3V0ID0gY2h1bmtTaXplOwogICAgICAgICAgfQogICAgICAgICAgc3RhdHVzID0gemxpYl9pbmZsYXRlLmluZmxhdGUoc3RybSwgYy5aX05PX0ZMVVNIKTsKICAgICAgICAgIGlmIChzdGF0dXMgPT09IGMuWl9ORUVEX0RJQ1QgJiYgZGljdGlvbmFyeSkgewogICAgICAgICAgICBzdGF0dXMgPSB6bGliX2luZmxhdGUuaW5mbGF0ZVNldERpY3Rpb25hcnkodGhpcy5zdHJtLCBkaWN0aW9uYXJ5KTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChzdGF0dXMgPT09IGMuWl9CVUZfRVJST1IgJiYgYWxsb3dCdWZFcnJvciA9PT0gdHJ1ZSkgewogICAgICAgICAgICBzdGF0dXMgPSBjLlpfT0s7CiAgICAgICAgICAgIGFsbG93QnVmRXJyb3IgPSBmYWxzZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChzdGF0dXMgIT09IGMuWl9TVFJFQU1fRU5EICYmIHN0YXR1cyAhPT0gYy5aX09LKSB7CiAgICAgICAgICAgIHRoaXMub25FbmQoc3RhdHVzKTsKICAgICAgICAgICAgdGhpcy5lbmRlZCA9IHRydWU7CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChzdHJtLm5leHRfb3V0KSB7CiAgICAgICAgICAgIGlmIChzdHJtLmF2YWlsX291dCA9PT0gMCB8fCBzdGF0dXMgPT09IGMuWl9TVFJFQU1fRU5EIHx8IHN0cm0uYXZhaWxfaW4gPT09IDAgJiYgKF9tb2RlID09PSBjLlpfRklOSVNIIHx8IF9tb2RlID09PSBjLlpfU1lOQ19GTFVTSCkpIHsKICAgICAgICAgICAgICBpZiAodGhpcy5vcHRpb25zLnRvID09PSAic3RyaW5nIikgewogICAgICAgICAgICAgICAgbmV4dF9vdXRfdXRmOCA9IHN0cmluZ3MudXRmOGJvcmRlcihzdHJtLm91dHB1dCwgc3RybS5uZXh0X291dCk7CiAgICAgICAgICAgICAgICB0YWlsID0gc3RybS5uZXh0X291dCAtIG5leHRfb3V0X3V0Zjg7CiAgICAgICAgICAgICAgICB1dGY4c3RyID0gc3RyaW5ncy5idWYyc3RyaW5nKHN0cm0ub3V0cHV0LCBuZXh0X291dF91dGY4KTsKICAgICAgICAgICAgICAgIHN0cm0ubmV4dF9vdXQgPSB0YWlsOwogICAgICAgICAgICAgICAgc3RybS5hdmFpbF9vdXQgPSBjaHVua1NpemUgLSB0YWlsOwogICAgICAgICAgICAgICAgaWYgKHRhaWwpIHsKICAgICAgICAgICAgICAgICAgdXRpbHMuYXJyYXlTZXQoc3RybS5vdXRwdXQsIHN0cm0ub3V0cHV0LCBuZXh0X291dF91dGY4LCB0YWlsLCAwKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHRoaXMub25EYXRhKHV0ZjhzdHIpOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICB0aGlzLm9uRGF0YSh1dGlscy5zaHJpbmtCdWYoc3RybS5vdXRwdXQsIHN0cm0ubmV4dF9vdXQpKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzdHJtLmF2YWlsX2luID09PSAwICYmIHN0cm0uYXZhaWxfb3V0ID09PSAwKSB7CiAgICAgICAgICAgIGFsbG93QnVmRXJyb3IgPSB0cnVlOwogICAgICAgICAgfQogICAgICAgIH0gd2hpbGUgKChzdHJtLmF2YWlsX2luID4gMCB8fCBzdHJtLmF2YWlsX291dCA9PT0gMCkgJiYgc3RhdHVzICE9PSBjLlpfU1RSRUFNX0VORCk7CiAgICAgICAgaWYgKHN0YXR1cyA9PT0gYy5aX1NUUkVBTV9FTkQpIHsKICAgICAgICAgIF9tb2RlID0gYy5aX0ZJTklTSDsKICAgICAgICB9CiAgICAgICAgaWYgKF9tb2RlID09PSBjLlpfRklOSVNIKSB7CiAgICAgICAgICBzdGF0dXMgPSB6bGliX2luZmxhdGUuaW5mbGF0ZUVuZCh0aGlzLnN0cm0pOwogICAgICAgICAgdGhpcy5vbkVuZChzdGF0dXMpOwogICAgICAgICAgdGhpcy5lbmRlZCA9IHRydWU7CiAgICAgICAgICByZXR1cm4gc3RhdHVzID09PSBjLlpfT0s7CiAgICAgICAgfQogICAgICAgIGlmIChfbW9kZSA9PT0gYy5aX1NZTkNfRkxVU0gpIHsKICAgICAgICAgIHRoaXMub25FbmQoYy5aX09LKTsKICAgICAgICAgIHN0cm0uYXZhaWxfb3V0ID0gMDsKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfTsKICAgICAgSW5mbGF0ZTIucHJvdG90eXBlLm9uRGF0YSA9IGZ1bmN0aW9uKGNodW5rKSB7CiAgICAgICAgdGhpcy5jaHVua3MucHVzaChjaHVuayk7CiAgICAgIH07CiAgICAgIEluZmxhdGUyLnByb3RvdHlwZS5vbkVuZCA9IGZ1bmN0aW9uKHN0YXR1cykgewogICAgICAgIGlmIChzdGF0dXMgPT09IGMuWl9PSykgewogICAgICAgICAgaWYgKHRoaXMub3B0aW9ucy50byA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgdGhpcy5yZXN1bHQgPSB0aGlzLmNodW5rcy5qb2luKCIiKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRoaXMucmVzdWx0ID0gdXRpbHMuZmxhdHRlbkNodW5rcyh0aGlzLmNodW5rcyk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHRoaXMuY2h1bmtzID0gW107CiAgICAgICAgdGhpcy5lcnIgPSBzdGF0dXM7CiAgICAgICAgdGhpcy5tc2cgPSB0aGlzLnN0cm0ubXNnOwogICAgICB9OwogICAgICBmdW5jdGlvbiBpbmZsYXRlKGlucHV0LCBvcHRpb25zKSB7CiAgICAgICAgdmFyIGluZmxhdG9yID0gbmV3IEluZmxhdGUyKG9wdGlvbnMpOwogICAgICAgIGluZmxhdG9yLnB1c2goaW5wdXQsIHRydWUpOwogICAgICAgIGlmIChpbmZsYXRvci5lcnIpIHsKICAgICAgICAgIHRocm93IGluZmxhdG9yLm1zZyB8fCBtc2dbaW5mbGF0b3IuZXJyXTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGluZmxhdG9yLnJlc3VsdDsKICAgICAgfQogICAgICBmdW5jdGlvbiBpbmZsYXRlUmF3KGlucHV0LCBvcHRpb25zKSB7CiAgICAgICAgb3B0aW9ucyA9IG9wdGlvbnMgfHwge307CiAgICAgICAgb3B0aW9ucy5yYXcgPSB0cnVlOwogICAgICAgIHJldHVybiBpbmZsYXRlKGlucHV0LCBvcHRpb25zKTsKICAgICAgfQogICAgICBleHBvcnRzMi5JbmZsYXRlID0gSW5mbGF0ZTI7CiAgICAgIGV4cG9ydHMyLmluZmxhdGUgPSBpbmZsYXRlOwogICAgICBleHBvcnRzMi5pbmZsYXRlUmF3ID0gaW5mbGF0ZVJhdzsKICAgICAgZXhwb3J0czIudW5nemlwID0gaW5mbGF0ZTsKICAgIH0KICB9KTsKCiAgLy8gbm9kZV9tb2R1bGVzLy5wbnBtL3Bha29AMS4wLjExL25vZGVfbW9kdW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AgICAgICAgICA5NywKICAgICAgICAgIDExNSwKICAgICAgICAgIDEwOSwKICAgICAgICAgIDEsCiAgICAgICAgICAwLAogICAgICAgICAgMCwKICAgICAgICAgIDAsCiAgICAgICAgICAxLAogICAgICAgICAgMTMsCiAgICAgICAgICAyLAogICAgICAgICAgOTYsCiAgICAgICAgICAwLAogICAgICAgICAgMSwKICAgICAgICAgIDEyNywKICAgICAgICAgIDk2LAogICAgICAgICAgNCwKICAgICAgICAgIDEyNywKICAgICAgICAgIDEyNywKICAgICAgICAgIDEyNywKICAgICAgICAgIDEyNywKICAgICAgICAgIDEsCiAgICAgICAgICAxMjcsCiAgICAgICAgICAzLAogICAgICAgICAgNywKICAgICAgICAgIDYsCiAgICAgICAgICAwLAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICAxLAogICAgICAgICAgMSwKICAgICAgICAgIDEsCiAgICAgICAgICA2LAogICAgICAgICAgNiwKICAgICAgICAgIDEsCiAgICAgICAgICAxMjcsCiAgICAgICAgICAxLAogICAgICAgICAgNjUsCiAgICAgICAgICAwLAogICAgICAgICAgMTEsCiAgICAgICAgICA3LAogICAgICAgICAgNTAsCiAgICAgICAgICA2LAogICAgICAgICAgMywKICAgICAgICAgIDEwOSwKICAgICAgICAgIDExNywKICAgICAgICAgIDEwOCwKICAgICAgICAgIDAsCiAgICAgICAgICAxLAogICAgICAgICAgNSwKICAgICAgICAgIDEwMCwKICAgICAgICAgIDEwNSwKICAgICAgICAgIDExOCwKICAgICAgICAgIDk1LAogICAgICAgICAgMTE1LAogICAgICAgICAgMCwKICAgICAgICAgIDIsCiAgICAgICAgICA1LAogICAgICAgICAgMTAwLAogICAgICAgICAgMTA1LAogICAgICAgICAgMTE4LAogICAgICAgICAgOTUsCiAgICAgICAgICAxMTcsCiAgICAgICAgICAwLAogICAgICAgICAgMywKICAgICAgICAgIDUsCiAgICAgICAgICAxMTQsCiAgICAgICAgICAxMDEsCiAgICAgICAgICAxMDksCiAgICAgICAgICA5NSwKICAgICAgICAgIDExNSwKICAgICAgICAgIDAsCiAgICAgICAgICA0LAogICAgICAgICAgNSwKICAgICAgICAgIDExNCwKICAgICAgICAgIDEwMSwKICAgICAgICAgIDEwOSwKICAgICAgICAgIDk1LAogICAgICAgICAgMTE3LAogICAgICAgICAgMCwKICAgICAgICAgIDUsCiAgICAgICAgICA4LAogICAgICAgICAgMTAzLAogICAgICAgICAgMTAxLAogICAgICAgICAgMTE2LAogICAgICAgICAgOTUsCiAgICAgICAgICAxMDQsCiAgICAgICAgICAxMDUsCiAgICAgICAgICAxMDMsCiAgICAgICAgICAxMDQsCiAgICAgICAgICAwLAogICAgICAgICAgMCwKICAgICAgICAgIDEwLAogICAgICAgICAgMTkxLAogICAgICAgICAgMSwKICAgICAgICAgIDYsCiAgICAgICAgICA0LAogICAgICAgICAgMCwKICAgICAgICAgIDM1LAogICAgICAgICAgMCwKICAgICAgICAgIDExLAogICAgICAgICAgMzYsCiAgICAgICAgICAxLAogICAgICAgICAgMSwKICAgICAgICAgIDEyNiwKICAgICAgICAgIDMyLAogICAgICAgICAgMCwKICAgICAgICAgIDE3MywKICAgICAgICAgIDMyLAogICAgICAgICAgMSwKICAgICAgICAgIDE3MywKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzQsCiAgICAgICAgICAxMzIsCiAgICAgICAgICAzMiwKICAgICAgICAgIDIsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDMsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMTI2LAogICAgICAgICAgMzQsCiAgICAgICAgICA0LAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNSwKICAgICAgICAgIDE2NywKICAgICAgICAgIDM2LAogICAgICAgICAgMCwKICAgICAgICAgIDMyLAogICAgICAgICAgNCwKICAgICAgICAgIDE2NywKICAgICAgICAgIDExLAogICAgICAgICAgMzYsCiAgICAgICAgICAxLAogICAgICAgICAgMSwKICAgICAgICAgIDEyNiwKICAgICAgICAgIDMyLAogICAgICAgICAgMCwKICAgICAgICAgIDE3MywKICAgICAgICAgIDMyLAogICAgICAgICAgMSwKICAgICAgICAgIDE3MywKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzQsCiAgICAgICAgICAxMzIsCiAgICAgICAgICAzMiwKICAgICAgICAgIDIsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDMsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMTI3LAogICAgICAgICAgMzQsCiAgICAgICAgICA0LAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNSwKICAgICAgICAgIDE2NywKICAgICAgICAgIDM2LAogICAgICAgICAgMCwKICAgICAgICAgIDMyLAogICAgICAgICAgNCwKICAgICAgICAgIDE2NywKICAgICAgICAgIDExLAogICAgICAgICAgMzYsCiAgICAgICAgICAxLAogICAgICAgICAgMSwKICAgICAgICAgIDEyNiwKICAgICAgICAgIDMyLAogICAgICAgICAgMCwKICAgICAgICAgIDE3MywKICAgICAgICAgIDMyLAogICAgICAgICAgMSwKICAgICAgICAgIDE3MywKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzQsCiAgICAgICAgICAxMzIsCiAgICAgICAgICAzMiwKICAgICAgICAgIDIsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDMsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMTI4LAogICAgICAgICAgMzQsCiAgICAgICAgICA0LAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNSwKICAgICAgICAgIDE2NywKICAgICAgICAgIDM2LAogICAgICAgICAgMCwKICAgICAgICAgIDMyLAogICAgICAgICAgNCwKICAgICAgICAgIDE2NywKICAgICAgICAgIDExLAogICAgICAgICAgMzYsCiAgICAgICAgICAxLAogICAgICAgICAgMSwKICAgICAgICAgIDEyNiwKICAgICAgICAgIDMyLAogICAgICAgICAgMCwKICAgICAgICAgIDE3MywKICAgICAgICAgIDMyLAogICAgICAgICAgMSwKICAgICAgICAgIDE3MywKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzQsCiAgICAgICAgICAxMzIsCiAgICAgICAgICAzMiwKICAgICAgICAgIDIsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDMsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMTI5LAogICAgICAgICAgMzQsCiAgICAgICAgICA0LAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNSwKICAgICAgICAgIDE2NywKICAgICAgICAgIDM2LAogICAgICAgICAgMCwKICAgICAgICAgIDMyLAogICAgICAgICAgNCwKICAgICAgICAgIDE2NywKICAgICAgICAgIDExLAogICAgICAgICAgMzYsCiAgICAgICAgICAxLAogICAgICAgICAgMSwKICAgICAgICAgIDEyNiwKICAgICAgICAgIDMyLAogICAgICAgICAgMCwKICAgICAgICAgIDE3MywKICAgICAgICAgIDMyLAogICAgICAgICAgMSwKICAgICAgICAgIDE3MywKICAgICAgICAgIDY2LAogICAgICAgICAgMzIsCiAgICAgICAgICAxMzQsCiAgICAgICAgICAxMzIsCiAgICAgICAgICAzMiwKICAgICAgICAgIDIsCiAgICAgICAgICAxNzMsCiAgICAgICAgICAzMiwKICAgICAgICAgIDMsCiAgICAgICAgICAxNzMsCiAgICAgICAgICA2NiwKICAgICAgICAgIDMyLAogICAgICAgICAgMTM0LAogICAgICAgICAgMTMyLAogICAgICAgICAgMTMwLAogICAgICAgICAgMzQsCiAgICAgICAgICA0LAogICAgICAgICAgNjYsCiAgICAgICAgICAzMiwKICAgICAgICAgIDEzNSwKICAgICAgICAgIDE2NywKICAgICAgICAgIDM2LAogICAgICAgICAgMCwKICAgICAgICAgIDMyLAogICAgICAgICAgNCwKICAgICAgICAgIDE2NywKICAgICAgICAgIDExCiAgICAgICAgXSkpLCB7fSkuZXhwb3J0czsKICAgICAgfSBjYXRjaCAoZSkgewogICAgICB9CiAgICAgIGZ1bmN0aW9uIExvbmc0KGxvdywgaGlnaCwgdW5zaWduZWQpIHsKICAgICAgICB0aGlzLmxvdyA9IGxvdyB8IDA7CiAgICAgICAgdGhpcy5oaWdoID0gaGlnaCB8IDA7CiAgICAgICAgdGhpcy51bnNpZ25lZCA9ICEhdW5zaWduZWQ7CiAgICAgIH0KICAgICAgTG9uZzQucHJvdG90eXBlLl9faXNMb25nX187CiAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShMb25nNC5wcm90b3R5cGUsICJfX2lzTG9uZ19fIiwgeyB2YWx1ZTogdHJ1ZSB9KTsKICAgICAgZnVuY3Rpb24gaXNMb25nKG9iaikgewogICAgICAgIHJldHVybiAob2JqICYmIG9ialsiX19pc0xvbmdfXyJdKSA9PT0gdHJ1ZTsKICAgICAgfQogICAgICBMb25nNC5pc0xvbmcgPSBpc0xvbmc7CiAgICAgIHZhciBJTlRfQ0FDSEUgPSB7fTsKICAgICAgdmFyIFVJTlRfQ0FDSEUgPSB7fTsKICAgICAgZnVuY3Rpb24gZnJvbUludCh2YWx1ZSwgdW5zaWduZWQpIHsKICAgICAgICB2YXIgb2JqLCBjYWNoZWRPYmosIGNhY2hlOwogICAgICAgIGlmICh1bnNpZ25lZCkgewogICAgICAgICAgdmFsdWUgPj4+PSAwOwogICAgICAgICAgaWYgKGNhY2hlID0gMCA8PSB2YWx1ZSAmJiB2YWx1ZSA8IDI1NikgewogICAgICAgICAgICBjYWNoZWRPYmogPSBVSU5UX0NBQ0hFW3ZhbHVlXTsKICAgICAgICAgICAgaWYgKGNhY2hlZE9iaikKICAgICAgICAgICAgICByZXR1cm4gY2FjaGVkT2JqOwogICAgICAgICAgfQogICAgICAgICAgb2JqID0gZnJvbUJpdHModmFsdWUsICh2YWx1ZSB8IDApIDwgMCA/IC0xIDogMCwgdHJ1ZSk7CiAgICAgICAgICBpZiAoY2FjaGUpCiAgICAgICAgICAgIFVJTlRfQ0FDSEVbdmFsdWVdID0gb2JqOwogICAgICAgICAgcmV0dXJuIG9iajsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgdmFsdWUgfD0gMDsKICAgICAgICAgIGlmIChjYWNoZSA9IC0xMjggPD0gdmFsdWUgJiYgdmFsdWUgPCAxMjgpIHsKICAgICAgICAgICAgY2FjaGVkT2JqID0gSU5UX0NBQ0hFW3ZhbHVlXTsKICAgICAgICAgICAgaWYgKGNhY2hlZE9iaikKICAgICAgICAgICAgICByZXR1cm4gY2FjaGVkT2JqOwogICAgICAgICAgfQogICAgICAgICAgb2JqID0gZnJvbUJpdHModmFsdWUsIHZhbHVlIDwgMCA/IC0xIDogMCwgZmFsc2UpOwogICAgICAgICAgaWYgKGNhY2hlKQogICAgICAgICAgICBJTlRfQ0FDSEVbdmFsdWVdID0gb2JqOwogICAgICAgICAgcmV0dXJuIG9iajsKICAgICAgICB9CiAgICAgIH0KICAgICAgTG9uZzQuZnJvbUludCA9IGZyb21JbnQ7CiAgICAgIGZ1bmN0aW9uIGZyb21OdW1iZXIodmFsdWUsIHVuc2lnbmVkKSB7CiAgICAgICAgaWYgKGlzTmFOKHZhbHVlKSkKICAgICAgICAgIHJldHVybiB1bnNpZ25lZCA/IFVaRVJPIDogWkVSTzsKICAgICAgICBpZiAodW5zaWduZWQpIHsKICAgICAgICAgIGlmICh2YWx1ZSA8IDApCiAgICAgICAgICAgIHJldHVybiBVWkVSTzsKICAgICAgICAgIGlmICh2YWx1ZSA+PSBUV09fUFdSXzY0X0RCTCkKICAgICAgICAgICAgcmV0dXJuIE1BWF9VTlNJR05FRF9WQUxVRTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgaWYgKHZhbHVlIDw9IC1UV09fUFdSXzYzX0RCTCkKICAgICAgICAgICAgcmV0dXJuIE1JTl9WQUxVRTsKICAgICAgICAgIGlmICh2YWx1ZSArIDEgPj0gVFdPX1BXUl82M19EQkwpCiAgICAgICAgICAgIHJldHVybiBNQVhfVkFMVUU7CiAgICAgICAgfQogICAgICAgIGlmICh2YWx1ZSA8IDApCiAgICAgICAgICByZXR1cm4gZnJvbU51bWJlcigtdmFsdWUsIHVuc2lnbmVkKS5uZWcoKTsKICAgICAgICByZXR1cm4gZnJvbUJpdHModmFsdWUgJSBUV09fUFdSXzMyX0RCTCB8IDAsIHZhbHVlIC8gVFdPX1BXUl8zMl9EQkwgfCAwLCB1bnNpZ25lZCk7CiAgICAgIH0KICAgICAgTG9uZzQuZnJvbU51bWJlciA9IGZyb21OdW1iZXI7CiAgICAgIGZ1bmN0aW9uIGZyb21CaXRzKGxvd0JpdHMsIGhpZ2hCaXRzLCB1bnNpZ25lZCkgewogICAgICAgIHJldHVybiBuZXcgTG9uZzQobG93Qml0cywgaGlnaEJpdHMsIHVuc2lnbmVkKTsKICAgICAgfQogICAgICBMb25nNC5mcm9tQml0cyA9IGZyb21CaXRzOwogICAgICB2YXIgcG93X2RibCA9IE1hdGgucG93OwogICAgICBmdW5jdGlvbiBmcm9tU3RyaW5nKHN0ciwgdW5zaWduZWQsIHJhZGl4KSB7CiAgICAgICAgaWYgKHN0ci5sZW5ndGggPT09IDApCiAgICAgICAgICB0aHJvdyBFcnJvcigiZW1wdHkgc3RyaW5nIik7CiAgICAgICAgaWYgKHN0ciA9PT0gIk5hTiIgfHwgc3RyID09PSAiSW5maW5pdHkiIHx8IHN0ciA9PT0gIitJbmZpbml0eSIgfHwgc3RyID09PSAiLUluZmluaXR5IikKICAgICAgICAgIHJldHVybiBaRVJPOwogICAgICAgIGlmICh0eXBlb2YgdW5zaWduZWQgPT09ICJudW1iZXIiKSB7CiAgICAgICAgICByYWRpeCA9IHVuc2lnbmVkLCB1bnNpZ25lZCA9IGZhbHNlOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB1bnNpZ25lZCA9ICEhdW5zaWduZWQ7CiAgICAgICAgfQogICAgICAgIHJhZGl4ID0gcmFkaXggfHwgMTA7CiAgICAgICAgaWYgKHJhZGl4IDwgMiB8fCAzNiA8IHJhZGl4KQogICAgICAgICAgdGhyb3cgUmFuZ2VFcnJvcigicmFkaXgiKTsKICAgICAgICB2YXIgcDsKICAgICAgICBpZiAoKHAgPSBzdHIuaW5kZXhPZigiLSIpKSA+IDApCiAgICAgICAgICB0aHJvdyBFcnJvcigiaW50ZXJpb3IgaHlwaGVuIik7CiAgICAgICAgZWxzZSBpZiAocCA9PT0gMCkgewogICAgICAgICAgcmV0dXJuIGZyb21TdHJpbmcoc3RyLnN1YnN0cmluZygxKSwgdW5zaWduZWQsIHJhZGl4KS5uZWcoKTsKICAgICAgICB9CiAgICAgICAgdmFyIHJhZGl4VG9Qb3dlciA9IGZyb21OdW1iZXIocG93X2RibChyYWRpeCwgOCkpOwogICAgICAgIHZhciByZXN1bHQgPSBaRVJPOwogICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgc3RyLmxlbmd0aDsgaSArPSA4KSB7CiAgICAgICAgICB2YXIgc2l6ZSA9IE1hdGgubWluKDgsIHN0ci5sZW5ndGggLSBpKSwgdmFsdWUgPSBwYXJzZUludChzdHIuc3Vic3RyaW5nKGksIGkgKyBzaXplKSwgcmFkaXgpOwogICAgICAgICAgaWYgKHNpemUgPCA4KSB7CiAgICAgICAgICAgIHZhciBwb3dlciA9IGZyb21OdW1iZXIocG93X2RibChyYWRpeCwgc2l6ZSkpOwogICAgICAgICAgICByZXN1bHQgPSByZXN1bHQubXVsKHBvd2VyKS5hZGQoZnJvbU51bWJlcih2YWx1ZSkpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcmVzdWx0ID0gcmVzdWx0Lm11bChyYWRpeFRvUG93ZXIpOwogICAgICAgICAgICByZXN1bHQgPSByZXN1bHQuYWRkKGZyb21OdW1iZXIodmFsdWUpKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmVzdWx0LnVuc2lnbmVkID0gdW5zaWduZWQ7CiAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgfQogICAgICBMb25nNC5mcm9tU3RyaW5nID0gZnJvbVN0cmluZzsKICAgICAgZnVuY3Rpb24gZnJvbVZhbHVlKHZhbCwgdW5zaWduZWQpIHsKICAgICAgICBpZiAodHlwZW9mIHZhbCA9PT0gIm51bWJlciIpCiAgICAgICAgICByZXR1cm4gZnJvbU51bWJlcih2YWwsIHVuc2lnbmVkKTsKICAgICAgICBpZiAodHlwZW9mIHZhbCA9PT0gInN0cmluZyIpCiAgICAgICAgICByZXR1cm4gZnJvbVN0cmluZyh2YWwsIHVuc2lnbmVkKTsKICAgICAgICByZXR1cm4gZnJvbUJpdHModmFsLmxvdywgdmFsLmhpZ2gsIHR5cGVvZiB1bnNpZ25lZCA9PT0gImJvb2xlYW4iID8gdW5zaWduZWQgOiB2YWwudW5zaWduZWQpOwogICAgICB9CiAgICAgIExvbmc0LmZyb21WYWx1ZSA9IGZyb21WYWx1ZTsKICAgICAgdmFyIFRXT19QV1JfMTZfREJMID0gMSA8PCAxNjsKICAgICAgdmFyIFRXT19QV1JfMjRfREJMID0gMSA8PCAyNDsKICAgICAgdmFyIFRXT19QV1JfMzJfREJMID0gVFdPX1BXUl8xNl9EQkwgKiBUV09fUFdSXzE2X0RCTDsKICAgICAgdmFyIFRXT19QV1JfNjRfREJMID0gVFdPX1BXUl8zMl9EQkwgKiBUV09fUFdSXzMyX0RCTDsKICAgICAgdmFyIFRXT19QV1JfNjNfREJMID0gVFdPX1BXUl82NF9EQkwgLyAyOwogICAg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G90eXBlLnRvTnVtYmVyID0gZnVuY3Rpb24gdG9OdW1iZXIyKCkgewogICAgICAgIGlmICh0aGlzLnVuc2lnbmVkKQogICAgICAgICAgcmV0dXJuICh0aGlzLmhpZ2ggPj4+IDApICogVFdPX1BXUl8zMl9EQkwgKyAodGhpcy5sb3cgPj4+IDApOwogICAgICAgIHJldHVybiB0aGlzLmhpZ2ggKiBUV09fUFdSXzMyX0RCTCArICh0aGlzLmxvdyA+Pj4gMCk7CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUudG9TdHJpbmcgPSBmdW5jdGlvbiB0b1N0cmluZyhyYWRpeCkgewogICAgICAgIHJhZGl4ID0gcmFkaXggfHwgMTA7CiAgICAgICAgaWYgKHJhZGl4IDwgMiB8fCAzNiA8IHJhZGl4KQogICAgICAgICAgdGhyb3cgUmFuZ2VFcnJvcigicmFkaXgiKTsKICAgICAgICBpZiAodGhpcy5pc1plcm8oKSkKICAgICAgICAgIHJldHVybiAiMCI7CiAgICAgICAgaWYgKHRoaXMuaXNOZWdhdGl2ZSgpKSB7CiAgICAgICAgICBpZiAodGhpcy5lcShNSU5fVkFMVUUpKSB7CiAgICAgICAgICAgIHZhciByYWRpeExvbmcgPSBmcm9tTnVtYmVyKHJhZGl4KSwgZGl2ID0gdGhpcy5kaXYocmFkaXhMb25nKSwgcmVtMSA9IGRpdi5tdWwocmFkaXhMb25nKS5zdWIodGhpcyk7CiAgICAgICAgICAgIHJldHVybiBkaXYudG9TdHJpbmcocmFkaXgpICsgcmVtMS50b0ludCgpLnRvU3RyaW5nKHJhZGl4KTsKICAgICAgICAgIH0gZWxzZQogICAgICAgICAgICByZXR1cm4gIi0iICsgdGhpcy5uZWcoKS50b1N0cmluZyhyYWRpeCk7CiAgICAgICAgfQogICAgICAgIHZhciByYWRpeFRvUG93ZXIgPSBmcm9tTnVtYmVyKHBvd19kYmwocmFkaXgsIDYpLCB0aGlzLnVuc2lnbmVkKSwgcmVtID0gdGhpczsKICAgICAgICB2YXIgcmVzdWx0ID0gIiI7CiAgICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICAgIHZhciByZW1EaXYgPSByZW0uZGl2KHJhZGl4VG9Qb3dlciksIGludHZhbCA9IHJlbS5zdWIocmVtRGl2Lm11bChyYWRpeFRvUG93ZXIpKS50b0ludCgpID4+PiAwLCBkaWdpdHMgPSBpbnR2YWwudG9TdHJpbmcocmFkaXgpOwogICAgICAgICAgcmVtID0gcmVtRGl2OwogICAgICAgICAgaWYgKHJlbS5pc1plcm8oKSkKICAgICAgICAgICAgcmV0dXJuIGRpZ2l0cyArIHJlc3VsdDsKICAgICAgICAgIGVsc2UgewogICAgICAgICAgICB3aGlsZSAoZGlnaXRzLmxlbmd0aCA8IDYpCiAgICAgICAgICAgICAgZGlnaXRzID0gIjAiICsgZGlnaXRzOwogICAgICAgICAgICByZXN1bHQgPSAiIiArIGRpZ2l0cyArIHJlc3VsdDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUuZ2V0SGlnaEJpdHMgPSBmdW5jdGlvbiBnZXRIaWdoQml0cygpIHsKICAgICAgICByZXR1cm4gdGhpcy5oaWdoOwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlLmdldEhpZ2hCaXRzVW5zaWduZWQgPSBmdW5jdGlvbiBnZXRIaWdoQml0c1Vuc2lnbmVkKCkgewogICAgICAgIHJldHVybiB0aGlzLmhpZ2ggPj4+IDA7CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUuZ2V0TG93Qml0cyA9IGZ1bmN0aW9uIGdldExvd0JpdHMoKSB7CiAgICAgICAgcmV0dXJuIHRoaXMubG93OwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlLmdldExvd0JpdHNVbnNpZ25lZCA9IGZ1bmN0aW9uIGdldExvd0JpdHNVbnNpZ25lZCgpIHsKICAgICAgICByZXR1cm4gdGhpcy5sb3cgPj4+IDA7CiAgICAgIH07CiAgICAgIExvbmd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YnRyYWN0OwogICAgICBMb25nUHJvdG90eXBlLm11bHRpcGx5ID0gZnVuY3Rpb24gbXVsdGlwbHkobXVsdGlwbGllcikgewogICAgICAgIGlmICh0aGlzLmlzWmVybygpKQogICAgICAgICAgcmV0dXJuIFpFUk87CiAgICAgICAgaWYgKCFpc0xvbmcobXVsdGlwbGllcikpCiAgICAgICAgICBtdWx0aXBsaWVyID0gZnJvbVZhbHVlKG11bHRpcGxpZXIpOwogICAgICAgIGlmICh3YXNtKSB7CiAgICAgICAgICB2YXIgbG93ID0gd2FzbS5tdWwodGhpcy5sb3csIHRoaXMuaGlnaCwgbXVsdGlwbGllci5sb3csIG11bHRpcGxpZXIuaGlnaCk7CiAgICAgICAgICByZXR1cm4gZnJvbUJpdHMobG93LCB3YXNtLmdldF9oaWdoKCksIHRoaXMudW5zaWduZWQpOwogICAgICAgIH0KICAgICAgICBpZiAobXVsdGlwbGllci5pc1plcm8oKSkKICAgICAgICAgIHJldHVybiBaRVJPOwogICAgICAgIGlmICh0aGlzLmVxKE1JTl9WQUxVRSkpCiAgICAgICAgICByZXR1cm4gbXVsdGlwbGllci5pc09kZCgpID8gTUlOX1ZBTFVFIDogWkVSTzsKICAgICAgICBpZiAobXVsdGlwbGllci5lcShNSU5fVkFMVUUpKQogICAgICAgICAgcmV0dXJuIHRoaXMuaXNPZGQoKSA/IE1JTl9WQUxVRSA6IFpFUk87CiAgICAgICAgaWYgKHRoaXMuaXNOZWdhdGl2ZSgpKSB7CiAgICAgICAgICBpZiAobXVsdGlwbGllci5pc05lZ2F0aXZlKCkpCiAgICAgICAgICAgIHJldHVybiB0aGlzLm5lZygpLm11bChtdWx0aXBsaWVyLm5lZygpKTsKICAgICAgICAgIGVsc2UKICAgICAgICAgICAgcmV0dXJuIHRoaXMubmVnKCkubXVsKG11bHRpcGxpZXIpLm5lZygpOwogICAgICAgIH0gZWxzZSBpZiAobXVsdGlwbGllci5pc05lZ2F0aXZlKCkpCiAgICAgICAgICByZXR1cm4gdGh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lnaCk7CiAgICAgICAgICByZXR1cm4gZnJvbUJpdHMobG93LCB3YXNtLmdldF9oaWdoKCksIHRoaXMudW5zaWduZWQpOwogICAgICAgIH0KICAgICAgICBpZiAodGhpcy5pc1plcm8oKSkKICAgICAgICAgIHJldHVybiB0aGlzLnVuc2lnbmVkID8gVVpFUk8gOiBaRVJPOwogICAgICAgIHZhciBhcHByb3gsIHJlbSwgcmVzOwogICAgICAgIGlmICghdGhpcy51bnNpZ25lZCkgewogICAgICAgICAgaWYgKHRoaXMuZXEoTUlOX1ZBTFVFKSkgewogICAgICAgICAgICBpZiAoZGl2aXNvci5lcShPTkUpIHx8IGRpdmlzb3IuZXEoTkVHX09ORSkpCiAgICAgICAgICAgICAgcmV0dXJuIE1JTl9WQUxVRTsKICAgICAgICAgICAgZWxzZSBpZiAoZGl2aXNvci5lcShNSU5fVkFMVUUpKQogICAgICAgICAgICAgIHJldHVybiBPTkU7CiAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgIHZhciBoYWxmVGhpcyA9IHRoaXMuc2hyKDEpOwogICAgICAgICAgICAgIGFwcHJveCA9IGhhbGZUaGlzLmRpdihkaXZpc29yKS5zaGwoMSk7CiAgICAgICAgICAgICAgaWYgKGFwcHJveC5lcShaRVJPKSkgewogICAgICAgICAgICAgICAgcmV0dXJuIGRpdmlzb3IuaXNOZWdhdGl2ZSgpID8gT05FIDogTkVHX09ORTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgcmVtID0gdGhpcy5zdWIoZGl2aXNvci5tdWwoYXBwcm94KSk7CiAgICAgICAgICAgICAgICByZXMgPSBhcHByb3guYWRkKHJlbS5kaXYoZGl2aXNvcikpOwogICAgICAgICAgICAgICAgcmV0dXJuIHJlczsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSBpZiAoZGl2aXNvci5lcShNSU5fVkFMVUUpKQogICAgICAgICAgICByZXR1cm4gdGhpcy51bnNpZ25lZCA/IFVaRVJPIDogWkVSTzsKICAgICAgICAgIGlmICh0aGlzLmlzTmVnYXRpdmUoKSkgewogICAgICAgICAgICBpZiAoZGl2aXNvci5pc05lZ2F0aXZlKCkpCiAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubmVnKCkuZGl2KGRpdmlzb3IubmVnKCkpOwogICAgICAgICAgICByZXR1cm4gdGhpcy5uZWcoKS5kaXYoZGl2aXNvcikubmVnKCk7CiAgICAgICAgICB9IGVsc2UgaWYgKGRpdmlzb3IuaXNOZWdhdGl2ZSgpKQogICAgICAgICAgICByZXR1cm4gdGhpcy5kaXYoZGl2aXNvci5uZWcoKSkubmVnKCk7CiAgICAgICAgICByZXMgPSBaRVJPOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBpZiAoIWRpdmlzb3IudW5zaWduZWQpCiAgICAgICAgICAgIGRpdmlzb3IgPSBkaXZpc29yLnRvVW5zaWduZWQoKTsKICAgICAgICAgIGlmIChkaXZpc29yLmd0KHRoaXMpKQogICAgICAgICAgICByZXR1cm4gVVpFUk87CiAgICAgICAgICBpZiAoZGl2aXNvci5ndCh0aGlzLnNocnUoMSkpKQogICAgICAgICAgICByZXR1cm4gVU9ORTsKICAgICAgICAgIHJlcyA9IFVaRVJPOwogICAgICAgIH0KICAgICAgICByZW0gPSB0aGlzOwogICAgICAgIHdoaWxlIChyZW0uZ3RlKGRpdmlzb3IpKSB7CiAgICAgICAgICBhcHByb3ggPSBNYXRoLm1heCgxLCBNYXRoLmZsb29yKHJlbS50b051bWJlcigpIC8gZGl2aXNvci50b051bWJlcigpKSk7CiAgICAgICAgICB2YXIgbG9nMiA9IE1hdGguY2VpbChNYXRoLmxvZyhhcHByb3gpIC8gTWF0aC5MTjIpLCBkZWx0YSA9IGxvZzIgPD0gNDggPyAxIDogcG93X2RibCgyLCBsb2cyIC0gNDgpLCBhcHByb3hSZXMgPSBmcm9tTnVtYmVyKGFwcHJveCksIGFwcHJveFJlbSA9IGFwcHJveFJlcy5tdWwoZGl2aXNvcik7CiAgICAgICAgICB3aGlsZSAoYXBwcm94UmVtLmlzTmVnYXRpdmUoKSB8fCBhcHByb3hSZW0uZ3QocmVtKSkgewogICAgICAgICAgICBhcHByb3ggLT0gZGVsdGE7CiAgICAgICAgICAgIGFwcHJveFJlcyA9IGZyb21OdW1iZXIoYXBwcm94LCB0aGlzLnVuc2lnbmVkKTsKICAgICAgICAgICAgYXBwcm94UmVtID0gYXBwcm94UmVzLm11bChkaXZpc29yKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChhcHByb3hSZXMuaXNaZXJvKCkpCiAgICAgICAgICAgIGFwcHJveFJlcyA9IE9ORTsKICAgICAgICAgIHJlcyA9IHJlcy5hZGQoYXBwcm94UmVzKTsKICAgICAgICAgIHJlbSA9IHJlbS5zdWIoYXBwcm94UmVtKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHJlczsKICAgICAgfTsKICAgICAgTG9uZ1Byb3RvdHlwZS5kaXYgPSBMb25nUHJvdG90eXBlLmRpdmlkZTsKICAgICAgTG9uZ1Byb3RvdHlwZS5tb2R1bG8gPSBmdW5jdGlvbiBtb2R1bG8oZGl2aXNvcikgewogICAgICAgIGlmICghaXNMb25nKGRpdmlzb3IpKQogICAgICAgICAgZGl2aXNvciA9IGZyb21WYWx1ZShkaXZpc29yKTsKICAgICAgICBpZiAod2FzbSkgewogICAgICAgICAgdmFyIGxvdyA9ICh0aGlzLnVuc2lnbmVkID8gd2FzbS5yZW1fdSA6IHdhc20ucmVtX3MpKHRoaXMubG93LCB0aGlzLmhpZ2gsIGRpdmlzb3IubG93LCBkaXZpc29yLmhpZ2gpOwogICAgICAgICAgcmV0dXJuIGZyb21CaXRzKGxvdywgd2FzbS5nZXRfaGlnaCgpLCB0aGlzLnVuc2lnbmVkKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRoaXMuc3ViKHRoaXMuZGl2KGRpdmlzb3IpLm11bChkaXZpc29yKSk7CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUubW9kID0gTG9uZ1Byb3RvdHlwZS5tb2R1bG87CiAgICAgIExvbmdQcm90b3R5cGUucmVtID0gTG9uZ1Byb3RvdHlwZS5tb2R1bG87CiAgICAgIExvbmdQcm90b3R5cGUubm90ID0gZnVuY3Rpb24gbm90KCkgewogICAgICAgIHJldHVybiBmcm9tQml0cyh+dGhpcy5sb3csIH50aGlzLmhpZ2gsIHRoaXMudW5zaWduZWQpOwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlLmFuZCA9IGZ1bmN0aW9uIGFuZChvdGhlcikgewogICAgICAgIGlmICghaXNMb25nKG90aGVyKSkKICAgICAgICAgIG90aGVyID0gZnJvbVZhbHVlKG90aGVyKTsKICAgICAgICByZXR1cm4gZnJvbUJpdHModGhpcy5sb3cgJiBvdGhlci5sb3csIHRoaXMuaGlnaCAmIG90aGVyLmhpZ2gsIHRoaXMudW5zaWduZWQpOwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlLm9yID0gZnVuY3Rpb24gb3Iob3RoZXIpIHsKICAgICAgICBpZiAoIWlzTG9uZyhvdGhlcikpCiAgICAgICAgICBvdGhlciA9IGZyb21WYWx1ZShvdGhlcik7CiAgICAgICAgcmV0dXJuIGZyb21CaXRzKHRoaXMubG93IHwgb3RoZXIubG93LCB0aGlzLmhpZ2ggfCBvdGhlci5oaWdoLCB0aGlzLnVuc2lnbmVkKTsKICAgICAgfTsKICAgICAgTG9uZ1Byb3RvdHlwZS54b3IgPSBmdW5jdGlvbiB4b3Iob3RoZXIpIHsKICAgICAgICBpZiAoIWlzTG9uZyhvdGhlcikpCiAgICAgICAgICBvdGhlciA9IGZyb21WYWx1ZShvdGhlcik7CiAgICAgICAgcmV0dXJuIGZyb21CaXRzKHRoaXMubG93IF4gb3RoZXIubG93LCB0aGlzLmhpZ2ggXiBvdGhlci5oaWdoLCB0aGlzLnVuc2lnbmVkKTsKICAgICAgfTsKICAgICAgTG9uZ1Byb3RvdHlwZS5zaGlmdExlZnQgPSBmdW5jdGlvbiBzaGlmdExlZnQobnVtQml0cykgewogICAgICAgIGlmIChpc0xvbmcobnVtQml0cykpCiAgICAgICAgICBudW1CaXRzID0gbnVtQml0cy50b0ludCgpOwogICAgICAgIGlmICgobnVtQml0cyAmPSA2MykgPT09IDApCiAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICBlbHNlIGlmIChudW1CaXRzIDwgMzIpCiAgICAgICAgICByZXR1cm4gZnJvbUJpdHModGhpcy5sb3cgPDwgbnVtQml0cywgdGhpcy5oaWdoIDw8IG51bUJpdHMgfCB0aGlzLmxvdyA+Pj4gMzIgLSBudW1CaXRzLCB0aGlzLnVuc2lnbmVkKTsKICAgICAgICBlbHNlCiAgICAgICAgICByZXR1cm4gZnJvbUJpdHMoMCwgdGhpcy5sb3cgPDwgbnVtQml0cyAtIDMyLCB0aGlzLnVuc2lnbmVkKTsKICAgICAgfTsKICAgICAgTG9uZ1Byb3RvdHlwZS5zaGwgPSBMb25nUHJvdG90eXBlLnNoaWZ0TGVmdDsKICAgICAgTG9uZ1Byb3RvdHlwZS5zaGlmdFJpZ2h0ID0gZnVuY3Rpb24gc2hpZnRSaWdodChudW1CaXRzKSB7CiAgICAgICAgaWYgKGlzTG9uZyhudW1CaXRzKSkKICAgICAgICAgIG51bUJpdHMgPSBudW1CaXRzLnRvSW50KCk7CiAgICAgICAgaWYgKChudW1CaXRzICY9IDYzKSA9PT0gMCkKICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgIGVsc2UgaWYgKG51bUJpdHMgPCAzMikKICAgICAgICAgIHJldHVybiBmcm9tQml0cyh0aGlzLmxvdyA+Pj4gbnVtQml0cyB8IHRoaXMuaGlnaCA8PCAzMiAtIG51bUJpdHMsIHRoaXMuaGlnaCA+PiBudW1CaXRzLCB0aGlzLnVuc2lnbmVkKTsKICAgICAgICBlbHNlCiAgICAgICAgICByZXR1cm4gZnJvbUJpdHModGhpcy5oaWdoID4+IG51bUJpdHMgLSAzMiwgdGhpcy5oaWdoID49IDAgPyAwIDogLTEsIHRoaXMudW5zaWduZWQpOwogICAgICB9OwogICAgICBMb25nUHJvdG90eXBlLnNociA9IExvbmdQcm90b3R5cGUuc2hpZnRSaWdodDsKICAgICAgTG9uZ1Byb3RvdHlwZS5zaGlmdFJpZ2h0VW5zaWduZWQgPSBmdW5jdGlvbiBzaGlmdFJpZ2h0VW5zaWduZWQobnVtQml0cykgewogICAgICAgIGlmIChpc0xvbmcobnVtQml0cykpCiAgICAgICAgICBudW1CaXRzID0gbnVtQml0cy50b0ludCgpOwogICAgICAgIG51bUJpdHMgJj0gNjM7CiAgICAgICAgaWYgKG51bUJpdHMgPT09IDApCiAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICBlbHNlIHsKICAgICAgICAgIHZhciBoaWdoID0gdGhpcy5oaWdoOwogICAgICAgICAgaWYgKG51bUJpdHMgPCAzMikgewogICAgICAgICAgICB2YXIgbG93ID0gdGhpcy5sb3c7CiAgICAgICAgICAgIHJldHVybiBmcm9tQml0cyhsb3cgPj4+IG51bUJpdHMgfCBoaWdoIDw8IDMyIC0gbnVtQml0cywgaGlnaCA+Pj4gbnVtQml0cywgdGhpcy51bnNpZ25lZCk7CiAgICAgICAgICB9IGVsc2UgaWYgKG51bUJpdHMgPT09IDMyKQogICAgICAgICAgICByZXR1cm4gZnJvbUJpdHMoaGlnaCwgMCwgdGhpcy51bnNpZ25lZCk7CiAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHJldHVybiBmcm9tQml0cyhoaWdoID4+PiBudW1CaXRzIC0gMzIsIDAsIHRoaXMudW5zaWduZWQpOwogICAgICAgIH0KICAgICAgfTsKICAgICAgTG9uZ1Byb3RvdHlwZS5zaHJ1ID0gTG9uZ1Byb3RvdHlwZS5zaGlmdFJpZ2h0VW5zaWduZWQ7CiAgICAgIExvbmdQcm90b3R5cGUuc2hyX3UgPSBMb25nUHJvdG90eXBlLnNoaWZ0UmlnaHRVbnNpZ25lZDsKICAgICAgTG9uZ1Byb3RvdHlwZS50b1NpZ25lZCA9IGZ1bmN0aW9uIHRvU2lnbmVkKCkgewogICAgICAgIGlmICghdGhpcy51bnNpZ25lZCkKICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgIHJldHVybiBmcm9tQml0cyh0aGlzLmxvdywgdGhpcy5oaWdoLCBmYWxzZSk7CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUudG9VbnNpZ25lZCA9IGZ1bmN0aW9uIHRvVW5zaWduZWQoKSB7CiAgICAgICAgaWYgKHRoaXMudW5zaWduZWQpCiAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICByZXR1cm4gZnJvbUJpdHModGhpcy5sb3csIHRoaXMuaGlnaCwgdHJ1ZSk7CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUudG9CeXRlcyA9IGZ1bmN0aW9uIHRvQnl0ZXMobGUpIHsKICAgICAgICByZXR1cm4gbGUgPyB0aGlzLnRvQnl0ZXNMRSgpIDogdGhpcy50b0J5dGVzQkUoKTsKICAgICAgfTsKICAgICAgTG9uZ1Byb3RvdHlwZS50b0J5dGVzTEUgPSBmdW5jdGlvbiB0b0J5dGVzTEUoKSB7CiAgICAgICAgdmFyIGhpID0gdGhpcy5oaWdoLCBsbyA9IHRoaXMubG93OwogICAgICAgIHJldHVybiBbCiAgICAgICAgICBsbyAmIDI1NSwKICAgICAgICAgIGxvID4+PiA4ICYgMjU1LAogICAgICAgICAgbG8gPj4+IDE2ICYgMjU1LAogICAgICAgICAgbG8gPj4+IDI0LAogICAgICAgICAgaGkgJiAyNTUsCiAgICAgICAgICBoaSA+Pj4gOCAmIDI1NSwKICAgICAgICAgIGhpID4+PiAxNiAmIDI1NSwKICAgICAgICAgIGhpID4+PiAyNAogICAgICAgIF07CiAgICAgIH07CiAgICAgIExvbmdQcm90b3R5cGUudG9CeXRlc0JFID0gZnVuY3Rpb24gdG9CeXRlc0JFKCkgewogICAgICAgIHZhciBoaSA9IHRoaXMuaG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mlhbGl6ZXIgPSBleHRlbmRTZXJpYWxpemVyOwogICAgICB2YXIgRGVmYXVsdEVycm9yU2VyaWFsaXplciA9IHsKICAgICAgICBkZXNlcmlhbGl6ZShtZXNzYWdlKSB7CiAgICAgICAgICByZXR1cm4gT2JqZWN0LmFzc2lnbihFcnJvcihtZXNzYWdlLm1lc3NhZ2UpLCB7CiAgICAgICAgICAgIG5hbWU6IG1lc3NhZ2UubmFtZSwKICAgICAgICAgICAgc3RhY2s6IG1lc3NhZ2Uuc3RhY2sKICAgICAgICAgIH0pOwogICAgICAgIH0sCiAgICAgICAgc2VyaWFsaXplKGVycm9yKSB7CiAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICBfX2Vycm9yX21hcmtlcjogIiQkZXJyb3IiLAogICAgICAgICAgICBtZXNzYWdlOiBlcnJvci5tZXNzYWdlLAogICAgICAgICAgICBuYW1lOiBlcnJvci5uYW1lLAogICAgICAgICAgICBzdGFjazogZXJyb3Iuc3RhY2sKICAgICAgICAgIH07CiAgICAgICAgfQogICAgICB9OwogICAgICB2YXIgaXNTZXJpYWxpemVkRXJyb3IgPSAodGhpbmcpID0+IHRoaW5nICYmIHR5cGVvZiB0aGluZyA9PT0gIm9iamVjdCIgJiYgIl9fZXJyb3JfbWFya2VyIiBpbiB0aGluZyAmJiB0aGluZy5fX2Vycm9yX21hcmtlciA9PT0gIiQkZXJyb3IiOwogICAgICBleHBvcnRzMi5EZWZhdWx0U2VyaWFsaXplciA9IHsKICAgICAgICBkZXNlcmlhbGl6ZShtZXNzYWdlKSB7CiAgICAgICAgICBpZiAoaXNTZXJpYWxpemVkRXJyb3IobWVzc2FnZSkpIHsKICAgICAgICAgICAgcmV0dXJuIERlZmF1bHRFcnJvclNlcmlhbGl6ZXIuZGVzZXJpYWxpemUobWVzc2FnZSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICByZXR1cm4gbWVzc2FnZTsKICAgICAgICAgIH0KICAgICAgICB9LAogICAgICAgIHNlcmlh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yaWN0IjsKICAgICAgdmFyIF9fYXdhaXRlciA9IGV4cG9ydHMyICYmIGV4cG9ydHMyLl9fYXdhaXRlciB8fCBmdW5jdGlvbih0aGlzQXJnLCBfYXJndW1lbnRzLCBQLCBnZW5lcmF0b3IpIHsKICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgewogICAgICAgICAgcmV0dXJuIHZhbHVlIGluc3RhbmNlb2YgUCA/IHZhbHVlIDogbmV3IFAoZnVuY3Rpb24ocmVzb2x2ZSkgewogICAgICAgICAgICByZXNvbHZlKHZhbHVlKTsKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgICByZXR1cm4gbmV3IChQIHx8IChQID0gUHJvbWlzZSkpKGZ1bmN0aW9uKHJlc29sdmUsIHJlamVjdCkgewogICAgICAgICAgZnVuY3Rpb24gZnVsZmlsbGVkKHZhbHVlKSB7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOwogICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgcmVqZWN0KGUpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgewogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgIHN0ZXAoZ2VuZXJhdG9yWyJ0aHJvdyJdKHZhbHVlKSk7CiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICByZWplY3QoZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGZ1bmN0aW9uIHN0ZXAocmVzdWx0KSB7CiAgICAgICAgICAgIHJlc3VsdC5kb25lID8gcmVzb2x2ZShyZXN1bHQudmFsdWUpIDogYWRvcHQocmVzdWx0LnZhbHVlKS50aGVuKGZ1bGZpbGxlZCwgcmVqZWN0ZWQpOwogICAgICAgICAgfQogICAgICAgICAgc3RlcCgoZ2VuZX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ihjaCkgewogICAgICAgICAgICByZXR1cm4gIlxceCIgKyBoZXgoY2gpOwogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICAgIGZ1bmN0aW9uIGRlc2NyaWJlRXhwZWN0YXRpb24oZXhwZWN0YXRpb24pIHsKICAgICAgICAgIHJldHVybiBERVNDUklCRV9FWFBFQ1RBVElPTl9GTlNbZXhwZWN0YXRpb24udHlwZV0oZXhwZWN0YXRpb24pOwogICAgICAgIH0KICAgICAgICBmdW5jdGlvbiBkZXNjcmliZUV4cGVjdGVkKGV4cGVjdGVkMikgewogICAgICAgICAgdmFyIGRlc2NyaXB0aW9ucyA9IG5ldyBBcnJheShleHBlY3RlZDIubGVuZ3RoKSwgaSwgajsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBleHBlY3RlZDIubGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgZGVzY3JpcHRpb25zW2ldID0gZGVzY3JpYmVFeHBlY3RhdGlvbihleHBlY3RlZDJbaV0pOwogICAgICAgICAgfQogICAgICAgICAgZGVzY3JpcHRpb25zLnNvcnQoKTsKICAgICAgICAgIGlmIChkZXNjcmlwdGlvbnMubGVuZ3RoID4gMCkgewogICAgICAgICAgICBmb3IgKGkgPSAxLCBqID0gMTsgaSA8IGRlc2NyaXB0aW9ucy5sZW5ndGg7IGkrKykgewogICAgICAgICAgICAgIGlmIChkZXNjcmlwdGlvbnNbaSAtIDFdICE9PSBkZXNjcmlwdGlvbnNbaV0pIHsKICAgICAgICAgICAgICAgIGRlc2NyaXB0aW9uc1tqXSA9IGRlc2NyaXB0aW9uc1tpXTsKICAgICAgICAgICAgICAgIGorKzsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZGVzY3JpcHRpb25zLmxlbmd0aCA9IGo7CiAgICAgICAgICB9CiAgICAgICAgICBzd2l0Y2ggKGRlc2NyaXB0aW9ucy5sZW5ndGgpIHsKICAgICAgICAgICAgY2FzZSAxOgogICAgICAgICAgICAgI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lZCwgaWdub3JlQ2FzZSkgewogICAgICAgICAgcmV0dXJuIHsgdHlwZTogImNsYXNzIiwgcGFydHMsIGludmVydGVkLCBpZ25vcmVDYXNlIH07CiAgICAgICAgfQogICAgICAgIGZ1bmN0aW9uIHBlZyRhbnlFeHBlY3RhdGlvbigpIHsKICAgICAgICAgIHJldHVybiB7IHR5cGU6ICJhbnkiIH07CiAgICAgICAgfQogICAgICAgIGZ1bmN0aW9uIHBlZyRlbmRFeHBlY3RhdGlvbigpIHsKICAgICAgICAgIHJldHVybiB7IHR5cGU6ICJlbmQiIH07CiAgICAgICAgfQogICAgICAgIGZ1bmN0aW9uIHBlZyRvdGhlckV4cGVjdGF0aW9uKGRlc2NyaXB0aW9uKSB7CiAgICAgICAgICByZXR1cm4geyB0eXBlOiAib3RoZXIiLCBkZXNjcmlwdGlvbiB9OwogICAgICAgIH0KICAgICAgICBmdW5jdGlvbiBwZWckY29tcHV0ZVBvc0RldGFpbHMocG9zKSB7CiAgICAgICAgICB2YXIgZGV0YWlscyA9IHBlZyRwb3NEZXRhaWxzQ2FjaGVbcG9zXSwgcDsKICAgICAgICAgIGlmIChkZXRhaWxzKSB7CiAgICAgICAgICAgIHJldHVybiBkZXRhaWxzOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcCA9IHBvcyAtIDE7CiAgICAgICAgICAgIHdoaWxlICghcGVnJHBvc0RldGFpbHNDYWNoZVtwXSkgewogICAgICAgICAgICAgIHAtLTsKICAgICAgICAgICAgfQogICAgICAgICAgICBkZXRhaWxzID0gcGVnJHBvc0RldGFpbHNDYWNoZVtwXTsKICAgICAgICAgICAgZGV0YWlscyA9IHsKICAgICAgICAgICAgICBsaW5lOiBkZXRhaWxzLmxpbmUsCiAgICAgICAgICAgICAgY29sdW1uOiBkZXRhaWxzLmNvbHVtbgogICAgICAgICAgICB9OwogICAgICAgICAgICB3aGlsZSAocCA8IHBvcykgewogICAgICAgICAgICAgIGlmIChpbnB1dC5jaGFyQ29kZUF0KHApID09PSAxMCkgewogICAgICAgICAgICAgICAgZGV0YWlscy5saW5lKys7CiAgICAgICAgICAgICAgICBkZXRhaWxzLmNvbHVtbiA9IDE7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGRldGFpbHMuY29sdW1uKys7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHArKzsKICAgICAgICAgICAgfQogICAgICAgICAgICBwZWckcG9zRGV0YWlsc0NhY2hlW3Bvc10gPSBkZXRhaWxzOwogICAgICAgICAgICByZXR1cm4gZGV0YWlsczsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZnVuY3Rpb24gcGVnJGNvbXB1dGVMb2NhdGlvbihzdGFydFBvcywgZW5kUG9zKSB7CiAgICAgICAgICB2YXIgc3RhcnRQb3NEZXRhaWxzID0gcGVnJGNvbXB1dGVQb3NEZXRhaWxzKHN0YXJ0UG9zKSwgZW5kUG9zRGV0YWlscyA9IHBlZyRjb21wdXRlUG9zRGV0YWlscyhlbmRQb3MpOwogICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgc3RhcnQ6IHsKICAgICAgICAgICAgICBvZmZzZXQ6IHN0YXJ0UG9zLAogICAgICAgICAgICAgIGxpbmU6IHN0YXJ0UG9zRGV0YWlscy5saW5lLAogICAgICAgICAgICAgIGNvbHVtbjogc3RhcnRQb3NEZXRhaWxzLmNvbHVtbgogICAgICAgICAgICB9LAogICAgICAgICAgICBlbmQ6IHsKICAgICAgICAgICAgICBvZmZzZXQ6IGVuZFBvcywKICAgICAgICAgICAgICBsaW5lOiBlbmRQb3NEZXRhaWxzLmxpbmUsCiAgICAgICAgICAgICAgY29sdW1uOiBlbmRQb3NEZXRhaWxzLmNvbHVtbgogICAgICAgICAgICB9CiAgICAgICAgICB9OwogICAgICAgIH0KICAgICAgICBmdW5jdGlvbiBwZWckZmFpbChleHBlY3RlZDIpIHsKICAgICAgICAgIGlmIChwZWckY3VyclBvcyA8IHBlZyRtYXhGYWlsUG9zKSB7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChwZWckY3VyclBvcyA+IHBlZyRtYXhGYWlsUG9zKSB7CiAgICAgICAgICAgIHBlZyRtYXhGYWlsUG9zID0gcGVnJGN1cnJQb3M7CiAgICAgICAgICAgIHBlZyRtYXhGYWlsRXhwZWN0ZWQgPSBbXTsKICAgICAgICAgIH0KICAgICAgICAgIHBlZyRtYXhGYWlsRXhwZWN0ZWQucHVzaChleHBlY3RlZDIpOwogICAgICAgIH0KICAgICAgICBmdW5jdGlvbiBwZWckYnVpbGRTaW1wbGVFcnJvcihtZXNzYWdlLCBsb2NhdGlvbjIpIHsKICAgICAgICAgIHJldHVybiBuZXcgcGVnJFN5bnRheEVycm9yKG1lc3NhZ2UsIG51bGwsIG51bGwsIGxvY2F0aW9uMik7CiAgICAgICAgfQogICAgICAgIGZ1bmN0aW9uIHBlZyRidWlsZFN0cnVjdHVyZWRFcnJvcihleHBlY3RlZDIsIGZvdW5kLCBsb2NhdGlvbjIpIHsKICAgICAgICAgIHJldHVybiBuZXcgcGVnJFN5bnRheEVycm9yKHBlZyRTeW50YXhFcnJvci5idWlsZE1lc3NhZ2UoZXhwZWN0ZWQyLCBmb3VuZCksIGV4cGVjdGVkMiwgZm91bmQsIGxvY2F0aW9uMik7CiAgICAgICAgfQogICAgICAgIGZ1bmN0aW9uIHBlZyRwYXJzZWRlY2xhcmF0aW9uKCkgewogICAgICAgICAgdmFyIHMwLCBzMSwgczIsIHMzLCBzNCwgczUsIHM2LCBzNywgczgsIHM5LCBzMTAsIHMxMSwgczEyLCBzMTM7CiAgICAgICAgICBzMCA9IHBlZyRjdXJyUG9zOwogICAgICAgICAgczEgPSBwZWckcGFyc2VfKCk7CiAgICAgICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgczIgPSBwZWckcGFyc2VkZWNsYXJlVHlwZSgpOwogICAgICAgICAgICBpZiAoczIgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICBzMyA9IHBlZyRwYXJzZV8oKTsKICAgICAgICAgICAgICBpZiAoczMgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgIHM0ID0gcGVnJHBhcnNlZGVjbGFyZU5hbWUoKTsKICAgICAgICAgICAgICAgIGlmIChzNCAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICBzNSA9IHBlZyRwYXJzZV8oKTsKICAgICAgICAgICAgICAgICAgaWYgKHM1ICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICAgICAgczYgPSBwZWckcGFyc2Vjb21tZW50KCk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHM2ICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICAgICAgICBzNyA9IHBlZyRwYXJzZV8oKTsKICAgICAgICAgICAgICAgICAgICAgIGlmIChzNyAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW5wdXQuY2hhckNvZGVBdChwZWckY3VyclBvcykgPT09IDQwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgczggPSBwZWckYzA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MrKzsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICBzOCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGMxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHM4ICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgczkgPSBwZWckcGFyc2VfKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHM5ICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMTAgPSBwZWckcGFyc2VmaWVsZExpc3QoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzMTAgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgczExID0gcGVnJHBhcnNlXygpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoczExICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0LmNoYXJDb2RlQXQocGVnJGN1cnJQb3MpID09PSA0MSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgczEyID0gcGVnJGMyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MrKzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgczEyID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGMzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHMxMiAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgczEzID0gcGVnJHBhcnNlXygpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHMxMyAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZWckc2F2ZWRQb3MgPSBzMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgczEgPSBwZWckYzQoczIsIHM0LCBzNiwgczEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgczAgPSBzMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBzMDsKICAgICAgICB9CiAgICAgICAgZnVuY3Rpb24gcGVnJHBhcnNlZGVjbGFyZVR5cGUoKSB7CiAgICAgICAgICB2YXIgczA7CiAgICAgICAgICBpZiAoaW5wdXQuc3Vic3RyKHBlZyRjdXJyUG9zLCA2KSA9PT0gcGVnJGM1KSB7CiAgICAgICAgICAgIHMwID0gcGVnJGM1OwogICAgICAgICAgICBwZWckY3VyclBvcyArPSA2OwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgczAgPSBwZWckRkFJTEVEOwogICAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7CiAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGM2KTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDYpID09PSBwZWckYzcpIHsKICAgICAgICAgICAgICBzMCA9IHBlZyRjNzsKICAgICAgICAgICAgICBwZWckY3VyclBvcyArPSA2OwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7CiAgICAgICAgICAgICAgICBwZWckZmFpbChwZWckYzgpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICBpZiAoaW5wdXQuc3Vic3RyKHBlZyRjdXJyUG9zLCA1KSA9PT0gcGVnJGM5KSB7CiAgICAgICAgICAgICAgICBzMCA9IHBlZyRjOTsKICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zICs9IDU7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsKICAgICAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGMxMCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gczA7CiAgICAgICAgfQogICAgICAgIGZ1bmN0aW9uIHBlZyRwYXJzZWRlY2xhcmVOYW1lKCkgewogICAgICAgICAgdmFyIHMwLCBzMSwgczIsIHMzOwogICAgICAgICAgczAgPSBwZWckcGFyc2VuYW1lKCk7CiAgICAgICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgczAgPSBwZWckY3VyclBvczsKICAgICAgICAgICAgczEgPSBwZWckcGFyc2VuYW1lKCk7CiAgICAgICAgICAgIGlmIChzMSAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgIHMyID0gcGVnJHBhcnNlaW5kZXhUeXBlKCk7CiAgICAgICAgICAgICAgaWYgKHMyICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICBzMSA9IFtzMSwgczJdOwogICAgICAgICAgICAgICAgczAgPSBzMTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgczAgPSBwZWckY3VyclBvczsKICAgICAgICAgICAgICBzMSA9IHBlZyRwYXJzZW5hbWUoKTsKICAgICAgICAgICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDQpID09PSBwZWckYzExKSB7CiAgICAgICAgICAgICAgICAgIHMyID0gcGVnJGMxMTsKICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gNDsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgIHMyID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIHBlZyRmYWlsKHBlZyRjMTIpOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoczIgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgczEgPSBbczEsIHMyXTsKICAgICAgICAgICAgICAgICAgczAgPSBzMTsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICBzMCA9IHBlZyRjdXJyUG9zOwogICAgICAgICAgICAgICAgczEgPSBwZWckcGFyc2VuYW1lKCk7CiAgICAgICAgICAgICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgczIgPSBwZWckcGFyc2VpbmRleFR5cGUoKTsKICAgICAgICAgICAgICAgICAgaWYgKHMyICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0LnN1YnN0cihwZWckY3VyclBvcywgNCkgPT09IHBlZyRjMTEpIHsKICAgICAgICAgICAgICAgICAgICAgIHMzID0gcGVnJGMxMTsKICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zICs9IDQ7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgIHMzID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGMxMik7CiAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChzMyAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICAgICAgczEgPSBbczEsIHMyLCBzM107CiAgICAgICAgICAgICAgICAgICAgICBzMCA9IHMxOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwOwogICAgICAgICAgICAgICAgICAgICAgczAgPSBwZWckRkFJTEVEOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwOwogICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgICAgczAgPSBwZWckRkFJTEVEOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIHMwOwogICAgICAgIH0KICAgICAgICBmdW5jdGlvbiBwZWckcGFyc2VpbmRleFR5cGUoKSB7CiAgICAgICAgICB2YXIgczA7CiAgICAgICAgICBpZiAoaW5wdXQuc3Vic3RyKHBlZyRjdXJyUG9zLCA3KSA9PT0gcGVnJGMxMykgewogICAgICAgICAgICBzMCA9IHBlZyRjMTM7CiAgICAgICAgICAgIHBlZyRjdXJyUG9zICs9IDc7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsKICAgICAgICAgICAgICBwZWckZmFpbChwZWckYzE0KTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDUpID09PSBwZWckYzE1KSB7CiAgICAgICAgICAgICAgczAgPSBwZWckYzE1OwogICAgICAgICAgICAgIHBlZyRjdXJyUG9zICs9IDU7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgczAgPSBwZWckRkFJTEVEOwogICAgICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsKICAgICAgICAgICAgICAgIHBlZyRmYWlsKHBlZyRjMTYpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICBpZiAoaW5wdXQuc3Vic3RyKHBlZyRjdXJyUG9zLCA2KSA9PT0gcGVnJGMxNykgewogICAgICAgICAgICAgICAgczAgPSBwZWckYzE3OwogICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gNjsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgczAgPSBwZWckRkFJTEVEOwogICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgICAgICBwZWckZmFpbChwZWckYzE4KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBzMDsKICAgICAgICB9CiAgICAgICAgZnVuY3Rpb24gcGVnJHBhcnNlY29tbWVudCgpIHsKICAgICAgICAgIHZhciBzMDsKICAgICAgICAgIHMwID0gcGVnJHBhcnNlbm9uUXVvdGVkU3RyaW5nKCk7CiAgICAgICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgczAgPSBwZWckcGFyc2VfKCk7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gczA7CiAgICAgICAgfQogICAgICAgIGZ1bmN0aW9uIHBlZyRwYXJzZWZpZWxkTGlzdCgpIHsKICAgICAgICAgIHZhciBzMCwgczEsIHMyLCBzMywgczQsIHM1LCBzNjsKICAgICAgICAgIHMwID0gcGVnJGN1cnJQb3M7CiAgICAgICAgICBzMSA9IHBlZyRwYXJzZWZpZWxkKCk7CiAgICAgICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgczIgPSBwZWckcGFyc2VfKCk7CiAgICAgICAgICAgIGlmIChzMiAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgIHMzID0gW107CiAgICAgICAgICAgICAgczQgPSBwZWckY3VyclBvczsKICAgICAgICAgICAgICBzNSA9IHBlZyRwYXJzZV8oKTsKICAgICAgICAgICAgICBpZiAoczUgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgIHM2ID0gcGVnJHBhcnNlZmllbGQoKTsKICAgICAgICAgICAgICAgIGlmIChzNiAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICBwZWckc2F2ZWRQb3MgPSBzNDsKICAgICAgICAgICAgICAgICAgczUgPSBwZWckYzE5KHMxLCBzNik7CiAgICAgICAgICAgICAgICAgIHM0ID0gczU7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHM0OwogICAgICAgICAgICAgICAgICBzNCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczQ7CiAgICAgICAgICAgICAgICBzNCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHdoaWxlIChzNCAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgczMucHVzaChzNCk7CiAgICAgICAgICAgICAgICBzNCA9IHBlZyRjdXJyUG9zOwogICAgICAgICAgICAgICAgczUgPSBwZWckcGFyc2VfKCk7CiAgICAgICAgICAgICAgICBpZiAoczUgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgczYgPSBwZWckcGFyc2VmaWVsZCgpOwogICAgICAgICAgICAgICAgICBpZiAoczYgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgICBwZWckc2F2ZWRQb3MgPSBzNDsKICAgICAgICAgICAgICAgICAgICBzNSA9IHBlZyRjMTkoczEsIHM2KTsKICAgICAgICAgICAgICAgICAgICBzNCA9IHM1OwogICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczQ7CiAgICAgICAgICAgICAgICAgICAgczQgPSBwZWckRkFJTEVEOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHM0OwogICAgICAgICAgICAgICAgICBzNCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChzMyAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgczQgPSBwZWckcGFyc2VfKCk7CiAgICAgICAgICAgICAgICBpZiAoczQgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgcGVnJHNhdmVkUG9zID0gczA7CiAgICAgICAgICAgICAgICAgIHMxID0gcGVnJGMyMChzMSwgczMpOwogICAgICAgICAgICAgICAgICBzMCA9IHMxOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgICAgczAgPSBwZWckRkFJTEVEOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwOwogICAgICAgICAgICAgICAgczAgPSBwZWckRkFJTEVEOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwOwogICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgczAgPSBwZWckRkFJTEVEOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIHMwOwogICAgICAgIH0KICAgICAgICBmdW5jdGlvbiBwZWckcGFyc2Vjb21tZW50U3RhcnQoKSB7CiAgICAgICAgICB2YXIgczA7CiAgICAgICAgICBpZiAoaW5wdXQuY2hhckNvZGVBdChwZWckY3VyclBvcykgPT09IDM1KSB7CiAgICAgICAgICAgIHMwID0gcGVnJGMyMTsKICAgICAgICAgICAgcGVnJGN1cnJQb3MrKzsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgIHBlZyRmYWlsKHBlZyRjMjIpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gczA7CiAgICAgICAgfQogICAgICAgIGZ1bmN0aW9uIHBlZyRwYXJzZWludGVybmFsQ29tbWVudCgpIHsKICAgICAgICAgIHZhciBzMCwgczEsIHMyLCBzMywgczQ7CiAgICAgICAgICBzMCA9IHBlZyRjdXJyUG9zOwogICAgICAgICAgczEgPSBwZWckcGFyc2VfKCk7CiAgICAgICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgczIgPSBwZWckcGFyc2Vjb21tZW50U3RhcnQoKTsKICAgICAgICAgICAgaWYgKHMyICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgczMgPSBwZWckcGFyc2Vub25RdW90ZWRTdHJpbmcoKTsKICAgICAgICAgICAgICBpZiAoczMgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgIHM0ID0gcGVnJHBhcnNlXygpOwogICAgICAgICAgICAgICAgaWYgKHM0ICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICAgIHMxID0gW3MxLCBzMiwgczMsIHM0XTsKICAgICAgICAgICAgICAgICAgczAgPSBzMTsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBzMDsKICAgICAgICB9CiAgICAgICAgZnVuY3Rpb24gcGVnJHBhcnNlZmllbGQoKSB7CiAgICAgICAgICB2YXIgczAsIHMxLCBzMiwgczMsIHM0LCBzNSwgczYsIHM3LCBzOCwgczksIHMxMCwgczExLCBzMTIsIHMxMzsKICAgICAgICAgIHMwID0gcGVnJGN1cnJQb3M7CiAgICAgICAgICBzMSA9IHBlZyRwYXJzZWZpZWxkVHlwZSgpOwogICAgICAgICAgaWYgKHMxICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgIHMyID0gcGVnJHBhcnNlXygpOwogICAgICAgICAgICBpZiAoczIgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICBzMyA9IHBlZyRwYXJzZW5hbWUoKTsKICAgICAgICAgICAgICBpZiAoczMgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgIHM0ID0gcGVnJHBhcnNlXygpOwogICAgICAgICAgICAgICAgaWYgKHM0ICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICAgIGlmIChpbnB1dC5jaGFyQ29kZUF0KHBlZyRjdXJyUG9zKSA9PT0gNTkpIHsKICAgICAgICAgICAgICAgICAgICBzNSA9IHBlZyRjMjM7CiAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MrKzsKICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICBzNSA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGMyNCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChzNSAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICAgIHM2ID0gcGVnJHBhcnNlXygpOwogICAgICAgICAgICAgICAgICAgIGlmIChzNiAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICAgICAgczcgPSBwZWckcGFyc2Vjb21tZW50KCk7CiAgICAgICAgICAgICAgICAgICAgICBpZiAoczcgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcGVnJHNhdmVkUG9zID0gczA7CiAgICAgICAgICAgICAgICAgICAgICAgIHMxID0gcGVnJGMyNShzMSwgczMsIHM3KTsKICAgICAgICAgICAgICAgICAgICAgICAgczAgPSBzMTsKICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICBzMCA9IHBlZyRjdXJyUG9zOwogICAgICAgICAgICBzMSA9IHBlZyRwYXJzZWZpZWxkVHlwZSgpOwogICAgICAgICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICBzMiA9IHBlZyRwYXJzZV8oKTsKICAgICAgICAgICAgICBpZiAoczIgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgIGlmIChpbnB1dC5jaGFyQ29kZUF0KHBlZyRjdXJyUG9zKSA9PT0gOTEpIHsKICAgICAgICAgICAgICAgICAgczMgPSBwZWckYzI2OwogICAgICAgICAgICAgICAgICBwZWckY3VyclBvcysrOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgczMgPSBwZWckRkFJTEVEOwogICAgICAgICAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGMyNyk7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChzMyAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICBzNCA9IHBlZyRwYXJzZV8oKTsKICAgICAgICAgICAgICAgICAgaWYgKHM0ICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICAgICAgczUgPSBwZWckcGFyc2VmaWVsZFNpemUoKTsKICAgICAgICAgICAgICAgICAgICBpZiAoczUgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgICAgIHM2ID0gcGVnJHBhcnNlXygpOwogICAgICAgICAgICAgICAgICAgICAgaWYgKHM2ICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dC5jaGFyQ29kZUF0KHBlZyRjdXJyUG9zKSA9PT0gOTMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICBzNyA9IHBlZyRjMjg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MrKzsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICBzNyA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGMyOSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzNyAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICAgICAgICAgIHM4ID0gcGVnJHBhcnNlXygpOwogICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzOCAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgczkgPSBwZWckcGFyc2VuYW1lKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoczkgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgczEwID0gcGVnJHBhcnNlXygpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoczEwICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0LmNoYXJDb2RlQXQocGVnJGN1cnJQb3MpID09PSA1OSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgczExID0gcGVnJGMyMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zKys7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMxMSA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRmYWlsKHBlZyRjMjQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoczExICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMTIgPSBwZWckcGFyc2VfKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoczEyICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMxMyA9IHBlZyRwYXJzZWNvbW1lbnQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHMxMyAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRzYXZlZFBvcyA9IHMwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMxID0gcGVnJGMzMChzMSwgczUsIHM5LCBzMTMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gczE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgczAgPSBwZWckY3VyclBvczsKICAgICAgICAgICAgICBzMSA9IHBlZyRwYXJzZWZpZWxkVHlwZSgpOwogICAgICAgICAgICAgIGlmIChzMSAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgczIgPSBwZWckcGFyc2VfKCk7CiAgICAgICAgICAgICAgICBpZiAoczIgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgaWYgKGlucHV0LmNoYXJDb2RlQXQocGVnJGN1cnJQb3MpID09PSA0MCkgewogICAgICAgICAgICAgICAgICAgIHMzID0gcGVnJGMwOwogICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zKys7CiAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgczMgPSBwZWckRkFJTEVEOwogICAgICAgICAgICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgIHBlZyRmYWlsKHBlZyRjMSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChzMyAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICAgIHM0ID0gcGVnJHBhcnNlXygpOwogICAgICAgICAgICAgICAgICAgIGlmIChzNCAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICAgICAgczUgPSBwZWckcGFyc2VmaWVsZFZhbHVlcygpOwogICAgICAgICAgICAgICAgICAgICAgaWYgKHM1ICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHM2ID0gcGVnJHBhcnNlXygpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoczYgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW5wdXQuY2hhckNvZGVBdChwZWckY3VyclBvcykgPT09IDQxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzNyA9IHBlZyRjMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zKys7CiAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHM3ID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGMzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHM3ICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzOCA9IHBlZyRwYXJzZV8oKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzOCAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzOSA9IHBlZyRwYXJzZW5hbWUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHM5ICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgczEwID0gcGVnJHBhcnNlXygpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzMTAgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dC5jaGFyQ29kZUF0KHBlZyRjdXJyUG9zKSA9PT0gNTkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgczExID0gcGVnJGMyMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MrKzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMxMSA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZWckZmFpbChwZWckYzI0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHMxMSAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMTIgPSBwZWckcGFyc2VfKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzMTIgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMTMgPSBwZWckcGFyc2Vjb21tZW50KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHMxMyAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJHNhdmVkUG9zID0gczA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMSA9IHBlZyRjMzEoczEsIHM1LCBzOSwgczEzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gczE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgczAgPSBwZWckRkFJTEVEOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgczAgPSBwZWckRkFJTEVEOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgczAgPSBwZWckRkFJTEVEOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwOwogICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgICAgczAgPSBwZWckRkFJTEVEOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwOwogICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgczAgPSBwZWckcGFyc2VpbnRlcm5hbENvbW1lbnQoKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBzMDsKICAgICAgICB9CiAgICAgICAgZnVuY3Rpb24gcGVnJHBhcnNlZmllbGRWYWx1ZXMoKSB7CiAgICAgICAgICB2YXIgczAsIHMxLCBzMiwgczMsIHM0LCBzNSwgczY7CiAgICAgICAgICBzMCA9IHBlZyRjdXJyUG9zOwogICAgICAgICAgczEgPSBwZWckcGFyc2VuYW1lKCk7CiAgICAgICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgczIgPSBbXTsKICAgICAgICAgICAgczMgPSBwZWckY3VyclBvczsKICAgICAgICAgICAgaWYgKGlucHV0LmNoYXJDb2RlQXQocGVnJGN1cnJQb3MpID09PSA0NCkgewogICAgICAgICAgICAgIHM0ID0gcGVnJGMzMjsKICAgICAgICAgICAgICBwZWckY3VyclBvcysrOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHM0ID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7CiAgICAgICAgICAgICAgICBwZWckZmFpbChwZWckYzMzKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHM0ICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgczUgPSBwZWckcGFyc2VfKCk7CiAgICAgICAgICAgICAgaWYgKHM1ICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICBzNiA9IHBlZyRwYXJzZW5hbWUoKTsKICAgICAgICAgICAgICAgIGlmIChzNiAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICBwZWckc2F2ZWRQb3MgPSBzMzsKICAgICAgICAgICAgICAgICAgczQgPSBwZWckYzE5KHMxLCBzNik7CiAgICAgICAgICAgICAgICAgIHMzID0gczQ7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMzOwogICAgICAgICAgICAgICAgICBzMyA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczM7CiAgICAgICAgICAgICAgICBzMyA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczM7CiAgICAgICAgICAgICAgczMgPSBwZWckRkFJTEVEOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHdoaWxlIChzMyAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgIHMyLnB1c2goczMpOwogICAgICAgICAgICAgIHMzID0gcGVnJGN1cnJQb3M7CiAgICAgICAgICAgICAgaWYgKGlucHV0LmNoYXJDb2RlQXQocGVnJGN1cnJQb3MpID09PSA0NCkgewogICAgICAgICAgICAgICAgczQgPSBwZWckYzMyOwogICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MrKzsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgczQgPSBwZWckRkFJTEVEOwogICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgICAgICBwZWckZmFpbChwZWckYzMzKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHM0ICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICBzNSA9IHBlZyRwYXJzZV8oKTsKICAgICAgICAgICAgICAgIGlmIChzNSAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICBzNiA9IHBlZyRwYXJzZW5hbWUoKTsKICAgICAgICAgICAgICAgICAgaWYgKHM2ICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgICAgICAgcGVnJHNhdmVkUG9zID0gczM7CiAgICAgICAgICAgICAgICAgICAgczQgPSBwZWckYzE5KHMxLCBzNik7CiAgICAgICAgICAgICAgICAgICAgczMgPSBzNDsKICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMzOwogICAgICAgICAgICAgICAgICAgIHMzID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMzsKICAgICAgICAgICAgICAgICAgczMgPSBwZWckRkFJTEVEOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMzOwogICAgICAgICAgICAgICAgczMgPSBwZWckRkFJTEVEOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoczIgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICBwZWckc2F2ZWRQb3MgPSBzMDsKICAgICAgICAgICAgICBzMSA9IHBlZyRjMzQoczEsIHMyKTsKICAgICAgICAgICAgICBzMCA9IHMxOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgczAgPSBwZWckRkFJTEVEOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwOwogICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gczA7CiAgICAgICAgfQogICAgICAgIGZ1bmN0aW9uIHBlZyRwYXJzZWZpZWxkVHlwZSgpIHsKICAgICAgICAgIHZhciBzMCwgczEsIHMyLCBzMzsKICAgICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDMpID09PSBwZWckYzM1KSB7CiAgICAgICAgICAgIHMwID0gcGVnJGMzNTsKICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gMzsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgIHBlZyRmYWlsKHBlZyRjMzYpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgaWYgKGlucHV0LnN1YnN0cihwZWckY3VyclBvcywgNCkgPT09IHBlZyRjMzcpIHsKICAgICAgICAgICAgICBzMCA9IHBlZyRjMzc7CiAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gNDsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGMzOCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDUpID09PSBwZWckYzM5KSB7CiAgICAgICAgICAgICAgICBzMCA9IHBlZyRjMzk7CiAgICAgICAgICAgICAgICBwZWckY3VyclBvcyArPSA1OwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7CiAgICAgICAgICAgICAgICAgIHBlZyRmYWlsKHBlZyRjNDApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDYpID09PSBwZWckYzQxKSB7CiAgICAgICAgICAgICAgICAgIHMwID0gcGVnJGM0MTsKICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gNjsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIHBlZyRmYWlsKHBlZyRjNDIpOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgaWYgKGlucHV0LnN1YnN0cihwZWckY3VyclBvcywgNCkgPT09IHBlZyRjNDMpIHsKICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRjNDM7CiAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gNDsKICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGM0NCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDUpID09PSBwZWckYzQ1KSB7CiAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRjNDU7CiAgICAgICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyArPSA1OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRmYWlsKHBlZyRjNDYpOwogICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDUpID09PSBwZWckYzQ3KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJGM0NzsKICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gNTsKICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRmYWlsKHBlZyRjNDgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0LnN1YnN0cihwZWckY3VyclBvcywgNCkgPT09IHBlZyRjNDkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRjNDk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gNDsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGM1MCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDYpID09PSBwZWckYzUxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRjNTE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyArPSA2OwogICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRmYWlsKHBlZyRjNTIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDcpID09PSBwZWckYzUzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJGM1MzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gNzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRmYWlsKHBlZyRjNTQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0LnN1YnN0cihwZWckY3VyclBvcywgNCkgPT09IHBlZyRjNTUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRjNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gNDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGM1Nik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDYpID09PSBwZWckYzU3KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRjNTc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyArPSA2OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRmYWlsKHBlZyRjNTgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDYpID09PSBwZWckYzU5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJGM1OTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gNjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRmYWlsKHBlZyRjNjApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0LnN1YnN0cihwZWckY3VyclBvcywgMykgPT09IHBlZyRjNjEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRjNjE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGM2Mik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJGN1cnJQb3M7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgczEgPSBwZWckcGFyc2VkZWNsYXJlVHlwZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzMSAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgczIgPSBwZWckcGFyc2VfKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoczIgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgczMgPSBwZWckcGFyc2VkZWNsYXJlTmFtZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoczMgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZWckc2F2ZWRQb3MgPSBzMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMSA9IHBlZyRjNjMoczEsIHMzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHMxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgczAgPSBwZWckRkFJTEVEOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gczA7CiAgICAgICAgfQogICAgICAgIGZ1bmN0aW9uIHBlZyRwYXJzZWZpZWxkU2l6ZSgpIHsKICAgICAgICAgIHZhciBzMDsKICAgICAgICAgIHMwID0gcGVnJHBhcnNlbnVtYmVyKCk7CiAgICAgICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgczAgPSBwZWckcGFyc2VuYW1lKCk7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gczA7CiAgICAgICAgfQogICAgICAgIGZ1bmN0aW9uIHBlZyRwYXJzZW5hbWUoKSB7CiAgICAgICAgICB2YXIgczAsIHMxLCBzMiwgczMsIHM0OwogICAgICAgICAgczAgPSBwZWckY3VyclBvczsKICAgICAgICAgIHMxID0gcGVnJGN1cnJQb3M7CiAgICAgICAgICBpZiAocGVnJGM2NC50ZXN0KGlucHV0LmNoYXJBdChwZWckY3VyclBvcykpKSB7CiAgICAgICAgICAgIHMyID0gaW5wdXQuY2hhckF0KHBlZyRjdXJyUG9zKTsKICAgICAgICAgICAgcGVnJGN1cnJQb3MrKzsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHMyID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgIHBlZyRmYWlsKHBlZyRjNjUpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoczIgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgczMgPSBbXTsKICAgICAgICAgICAgaWYgKHBlZyRjNjYudGVzdChpbnB1dC5jaGFyQXQocGVnJGN1cnJQb3MpKSkgewogICAgICAgICAgICAgIHM0ID0gaW5wdXQuY2hhckF0KHBlZyRjdXJyUG9zKTsKICAgICAgICAgICAgICBwZWckY3VyclBvcysrOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHM0ID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7CiAgICAgICAgICAgICAgICBwZWckZmFpbChwZWckYzY3KTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgd2hpbGUgKHM0ICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgczMucHVzaChzNCk7CiAgICAgICAgICAgICAgaWYgKHBlZyRjNjYudGVzdChpbnB1dC5jaGFyQXQocGVnJGN1cnJQb3MpKSkgewogICAgICAgICAgICAgICAgczQgPSBpbnB1dC5jaGFyQXQocGVnJGN1cnJQb3MpOwogICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MrKzsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgczQgPSBwZWckRkFJTEVEOwogICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgICAgICBwZWckZmFpbChwZWckYzY3KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHMzICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgICAgczIgPSBbczIsIHMzXTsKICAgICAgICAgICAgICBzMSA9IHMyOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczE7CiAgICAgICAgICAgICAgczEgPSBwZWckRkFJTEVEOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBwZWckY3VyclBvcyA9IHMxOwogICAgICAgICAgICBzMSA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgcGVnJHNhdmVkUG9zID0gczA7CiAgICAgICAgICAgIHMxID0gcGVnJGM2OChzMSk7CiAgICAgICAgICB9CiAgICAgICAgICBzMCA9IHMxOwogICAgICAgICAgcmV0dXJuIHMwOwogICAgICAgIH0KICAgICAgICBmdW5jdGlvbiBwZWckcGFyc2VxdW90ZWRTdHJpbmcoKSB7CiAgICAgICAgICB2YXIgczAsIHMxLCBzMiwgczM7CiAgICAgICAgICBzMCA9IHBlZyRjdXJyUG9zOwogICAgICAgICAgaWYgKGlucHV0LmNoYXJDb2RlQXQocGVnJGN1cnJQb3MpID09PSAzNCkgewogICAgICAgICAgICBzMSA9IHBlZyRjNjk7CiAgICAgICAgICAgIHBlZyRjdXJyUG9zKys7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzMSA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsKICAgICAgICAgICAgICBwZWckZmFpbChwZWckYzcwKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKHMxICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgIHMyID0gW107CiAgICAgICAgICAgIGlmIChwZWckYzcxLnRlc3QoaW5wdXQuY2hhckF0KHBlZyRjdXJyUG9zKSkpIHsKICAgICAgICAgICAgICBzMyA9IGlucHV0LmNoYXJBdChwZWckY3VyclBvcyk7CiAgICAgICAgICAgICAgcGVnJGN1cnJQb3MrKzsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBzMyA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGM3Mik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIHdoaWxlIChzMyAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgIHMyLnB1c2goczMpOwogICAgICAgICAgICAgIGlmIChwZWckYzcxLnRlc3QoaW5wdXQuY2hhckF0KHBlZyRjdXJyUG9zKSkpIHsKICAgICAgICAgICAgICAgIHMzID0gaW5wdXQuY2hhckF0KHBlZyRjdXJyUG9zKTsKICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zKys7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHMzID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsKICAgICAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGM3Mik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzMiAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgIGlmIChpbnB1dC5jaGFyQ29kZUF0KHBlZyRjdXJyUG9zKSA9PT0gMzQpIHsKICAgICAgICAgICAgICAgIHMzID0gcGVnJGM2OTsKICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zKys7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHMzID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsKICAgICAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGM3MCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChzMyAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgcGVnJHNhdmVkUG9zID0gczA7CiAgICAgICAgICAgICAgICBzMSA9IHBlZyRjNzMoczIpOwogICAgICAgICAgICAgICAgczAgPSBzMTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDsKICAgICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgIHMwID0gcGVnJEZBSUxFRDsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBzMDsKICAgICAgICB9CiAgICAgICAgZnVuY3Rpb24gcGVnJHBhcnNlbm9uUXVvdGVkU3RyaW5nKCkgewogICAgICAgICAgdmFyIHMwLCBzMSwgczI7CiAgICAgICAgICBzMCA9IHBlZyRjdXJyUG9zOwogICAgICAgICAgczEgPSBbXTsKICAgICAgICAgIGlmIChwZWckYzc0LnRlc3QoaW5wdXQuY2hhckF0KHBlZyRjdXJyUG9zKSkpIHsKICAgICAgICAgICAgczIgPSBpbnB1dC5jaGFyQXQocGVnJGN1cnJQb3MpOwogICAgICAgICAgICBwZWckY3VyclBvcysrOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgczIgPSBwZWckRkFJTEVEOwogICAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7CiAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGM3NSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHdoaWxlIChzMiAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICBzMS5wdXNoKHMyKTsKICAgICAgICAgICAgaWYgKHBlZyRjNzQudGVzdChpbnB1dC5jaGFyQXQocGVnJGN1cnJQb3MpKSkgewogICAgICAgICAgICAgIHMyID0gaW5wdXQuY2hhckF0KHBlZyRjdXJyUG9zKTsKICAgICAgICAgICAgICBwZWckY3VyclBvcysrOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHMyID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7CiAgICAgICAgICAgICAgICBwZWckZmFpbChwZWckYzc1KTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzMSAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICBwZWckc2F2ZWRQb3MgPSBzMDsKICAgICAgICAgICAgczEgPSBwZWckYzc2KHMxKTsKICAgICAgICAgIH0KICAgICAgICAgIHMwID0gczE7CiAgICAgICAgICByZXR1cm4gczA7CiAgICAgICAgfQogICAgICAgIGZ1bmN0aW9uIHBlZyRwYXJzZW51bWJlcigpIHsKICAgICAgICAgIHZhciBzMCwgczEsIHMyLCBzMzsKICAgICAgICAgIHBlZyRzaWxlbnRGYWlscysrOwogICAgICAgICAgczAgPSBwZWckY3VyclBvczsKICAgICAgICAgIHMxID0gcGVnJHBhcnNlXygpOwogICAgICAgICAgaWYgKHMxICE9PSBwZWckRkFJTEVEKSB7CiAgICAgICAgICAgIHMyID0gW107CiAgICAgICAgICAgIGlmIChwZWckYzc4LnRlc3QoaW5wdXQuY2hhckF0KHBlZyRjdXJyUG9zKSkpIHsKICAgICAgICAgICAgICBzMyA9IGlucHV0LmNoYXJBdChwZWckY3VyclBvcyk7CiAgICAgICAgICAgICAgcGVnJGN1cnJQb3MrKzsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBzMyA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGM3OSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzMyAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgIHdoaWxlIChzMyAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICAgICAgczIucHVzaChzMyk7CiAgICAgICAgICAgICAgICBpZiAocGVnJGM3OC50ZXN0KGlucHV0LmNoYXJBdChwZWckY3VyclBvcykpKSB7CiAgICAgICAgICAgICAgICAgIHMzID0gaW5wdXQuY2hhckF0KHBlZyRjdXJyUG9zKTsKICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MrKzsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgIHMzID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIHBlZyRmYWlsKHBlZyRjNzkpOwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHMyID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoczIgIT09IHBlZyRGQUlMRUQpIHsKICAgICAgICAgICAgICBwZWckc2F2ZWRQb3MgPSBzMDsKICAgICAgICAgICAgICBzMSA9IHBlZyRjODAoKTsKICAgICAgICAgICAgICBzMCA9IHMxOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7CiAgICAgICAgICAgICAgczAgPSBwZWckRkFJTEVEOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwOwogICAgICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICB9CiAgICAgICAgICBwZWckc2lsZW50RmFpbHMtLTsKICAgICAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICBzMSA9IHBlZyRGQUlMRUQ7CiAgICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsKICAgICAgICAgICAgICBwZWckZmFpbChwZWckYzc3KTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIHMwOwogICAgICAgIH0KICAgICAgICBmdW5jdGlvbiBwZWckcGFyc2VfKCkgewogICAgICAgICAgdmFyIHMwLCBzMTsKICAgICAgICAgIHBlZyRzaWxlbnRGYWlscysrOwogICAgICAgICAgczAgPSBbXTsKICAgICAgICAgIGlmIChwZWckYzgyLnRlc3QoaW5wdXQuY2hhckF0KHBlZyRjdXJyUG9zKSkpIHsKICAgICAgICAgICAgczEgPSBpbnB1dC5jaGFyQXQocGVnJGN1cnJQb3MpOwogICAgICAgICAgICBwZWckY3VyclBvcysrOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgczEgPSBwZWckRkFJTEVEOwogICAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7CiAgICAgICAgICAgICAgcGVnJGZhaWwocGVnJGM4Myk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHdoaWxlIChzMSAhPT0gcGVnJEZBSUxFRCkgewogICAgICAgICAgICBzMC5wdXNoKHMxKTsKICAgICAgICAgICAgaWYgKHBlZyRjODIudGVzdChpbnB1dC5jaGFyQXQocGVnJGN1cnJQb3MpKSkgewogICAgICAgICAgICAgIHMxID0gaW5wdXQuY2hhckF0KHBlZyRjdXJyUG9zKTsKICAgICAgICAgICAgICBwZWckY3VyclBvcysrOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHMxID0gcGVnJEZBSUxFRDsKICAgICAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7CiAgICAgICAgICAgICAgICBwZWckZmFpbChwZWckYzgzKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHBlZyRzaWxlbnRGYWlscy0tOwogICAgICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7CiAgICAgICA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9wdHM7CiAgICAgIGNvbnN0IGFyZ3MgPSB7CiAgICAgICAgaGVhZGVycywKICAgICAgICBtZXRob2Q6ICJHRVQiLAogICAgICAgIHJlZGlyZWN0OiAiZm9sbG93IiwKICAgICAgICBtb2RlOiAiY29ycyIsCiAgICAgICAgc2lnbmFsLAogICAgICAgIC4uLnRoaXMuYmFzZU92ZXJyaWRlcywKICAgICAgICAuLi5vdmVycmlkZXMKICAgICAgfTsKICAgICAgY29uc3QgcmVzcG9uc2UgPSBhd2FpdCB0aGlzLmZldGNoKHRoaXMudXJsLCBhcmdzKTsKICAgICAgaWYgKCFyZXNwb25zZSkgewogICAgICAgIHRocm93IG5ldyBFcnJvcigiZ2VuZXJpYy1maWxlaGFuZGxlIGZhaWxlZCB0byBmZXRjaCIpOwogICAgICB9CiAgICAgIGlmIChyZXNwb25zZS5zdGF0dXMgIT09IDIwMCkgewogICAgICAgIHRocm93IE9iamVjdC5hc3NpZ24obmV3IEVycm9yKGBIVFRQICR7cmVzcG9uc2Uuc3RhdHVzfSBmZXRjaGluZyAke3RoaXMudXJsfWApLCB7CiAgICAgICAgICBzdGF0dXM6IHJlc3BvbnNlLnN0YXR1cwogICAgICAgIH0pOwogICAgICB9CiAgICAgIGlmIChlbmNvZGluZyA9PT0gInV0ZjgiKSB7CiAgICAgICAgcmV0dXJuIHJlc3BvbnNlLnRleHQoKTsKICAgICAgfQogICAgICBpZiAoZW5jb2RpbmcpIHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYHVuc3VwcG9ydGVkIGVuY29kaW5nOiAke2VuY29kaW5nfWApOwogICAgICB9CiAgICAgIHJldHVybiB0aGlzLmdldEJ1ZmZlckZyb21SZXNwb25zZShyZXNwb25zZSk7CiAgICB9CiAgICBhc3luYyBzdGF0KCkgewogICAgICBpZiAoIXRoaXMuX3N0YXQpIHsKICAgICAgICBjb25zdCBidWYgPSBpbXBvcnRfYnVmZmVyMi5CdWZmZXIuYWxsb2NVbnNhZmUoMTApOwogICAgIC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sxLCBjaHVuazIpIHsKICAgIHJldHVybiBjaHVuazIubWludi5ibG9ja1Bvc2l0aW9uIC0gY2h1bmsxLm1heHYuYmxvY2tQb3NpdGlvbiA8IDY1ZTMgJiYgY2h1bmsyLm1heHYuYmxvY2tQb3NpdGlvbiAtIGNodW5rMS5taW52LmJsb2NrUG9zaXRpb24gPCA1ZTY7CiAgfQogIGZ1bmN0aW9uIG9wdGltaXplQ2h1bmtzKGNodW5rcywgbG93ZXN0KSB7CiAgICBjb25zdCBtZXJnZWRDaHVua3MgPSBbXTsKICAgIGxldCBsYXN0Q2h1bmsgPSBudWxsOwogICAgaWYgKGNodW5rcy5sZW5ndGggPT09IDApIHsKICAgICAgcmV0dXJuIGNodW5rczsKICAgIH0KICAgIGNodW5rcy5zb3J0KGZ1bmN0aW9uKGMwLCBjMSkgewogICAgICBjb25zdCBkaWYgPSBjMC5taW52LmJsb2NrUG9zaXRpb24gLSBjMS5taW52LmJsb2NrUG9zaXRpb247CiAgICAgIGlmIChkaWYgIT09IDApIHsKICAgICAgICByZXR1cm4gZGlmOwogICAgICB9IGVsc2UgewogICAgICAgIHJldHVybiBjMC5taW52LmRhdGFQb3NpdGlvbiAtIGMxLm1pbnYuZGF0YVBvc2l0aW9uOwogICAgICB9CiAgICB9KTsKICAgIGNodW5rcy5mb3JFYWNoKChjaHVuaykgPT4gewogICAgICBpZiAoIWxvd2VzdCB8fCBjaHVuay5tYXh2LmNvbXBhcmVUbyhsb3dlc3QpID4gMCkgewogICAgICAgIGlmIChsYXN0Q2h1bmsgPT09IG51bGwpIHsKICAgICAgICAgIG1lcmdlZENodW5rcy5wdXNoKGNodW5rKTsKICAgICAgICAgIGxhc3RDaHVuayA9IGNodW5rOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBpZiAoY2FuTWVyZ2VCbG9ja3MobGFzdENodW5rLCBjaHVuaykpIHsKICAgICAgICAgICAgaWYgKGNodW5rLm1heHYuY29tcGFyZVRvKGxhc3RDaHVuay5tYXh2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ZC90YWJpeC9lc20vdGJpLmpzCiAgdmFyIFRCSV9NQUdJQyA9IDIxNTc4MzI0OwogIHZhciBUQURfTElEWF9TSElGVCA9IDE0OwogIGZ1bmN0aW9uIHJlZzJiaW5zKGJlZywgZW5kKSB7CiAgICBiZWcgKz0gMTsKICAgIGVuZCAtPSAxOwogICAgcmV0dXJuIFsKICAgICAgWzAsIDBdLAogICAgICBbMSArIChiZWcgPj4gMjYpLCAxICsgKGVuZCA+PiAyNildLAogICAgICBbOSArIChiZWcgPj4gMjMpLCA5ICsgKGVuZCA+PiAyMyldLAogICAgICBbNzMgKyAoYmVnID4+IDIwKSwgNzMgKyAoZW5kID4+IDIwKV0sCiAgICAgIFs1ODUgKyAoYmVnID4+IDE3KSwgNTg1ICsgKGVuZCA+PiAxNyldLAogICAgICBbNDY4MSArIChiZWcgPj4gMTQpLCA0NjgxICsgKGVuZCA+PiAxNCldCiAgICBdOwogIH0KICB2YXIgVGFiaXhJbmRleCA9IGNsYXNzIGV4dGVuZHMgSW5kZXhGaWxlIHsKICAgIGFzeW5jIGxpbmVDb3VudChyZWZOYW1lLCBvcHRzID0ge30pIHsKICAgICAgY29uc3QgaW5kZXhEYXRhID0gYXdhaXQgdGhpcy5wYXJzZShvcHRzKTsKICAgICAgaWYgKCFpbmRleERhdGEpIHsKICAgICAgICByZXR1cm4gLTE7CiAgICAgIH0KICAgICAgY29uc3QgcmVmSWQgPSBpbmRleERhdGEucmVmTmFtZVRvSWRbcmVmTmFtZV07CiAgICAgIGNvbnN0IGlkeCA9IGluZGV4RGF0YS5pbmRpY2VzW3JlZklkXTsKICAgICAgaWYgKCFpZHgpIHsKICAgICAgICByZXR1cm4gLTE7CiAgICAgIH0KICAgICAgY29uc3QgeyBzdGF0cyB9ID0gaW5kZXhEYXRhLmluZGljZXNbcmVmSWRdOwogICAgICBpZiAoc3RhdHMpIHsKICAgICAgICByZXR1cm4gc3RhdHMubGluZUNvdW50OwogICAgICB9CiAgICAgIHJldHVybiAtMTsK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ShjdXJyT2Zmc2V0KTsKICAgICAgICAgIGN1cnJPZmZzZXQgKz0gNDsKICAgICAgICAgIGlmIChiaW4gPiBtYXhCaW5OdW1iZXIgKyAxKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigidGFiaXggaW5kZXggY29udGFpbnMgdG9vIG1hbnkgYmlucywgcGxlYXNlIHVzZSBhIENTSSBpbmRleCIpOwogICAgICAgICAgfSBlbHNlIGlmIChiaW4gPT09IG1heEJpbk51bWJlciArIDEpIHsKICAgICAgICAgICAgY29uc3QgY2h1bmtDb3VudCA9IGJ5dGVzLnJlYWRJbnQzMkxFKGN1cnJPZmZzZXQpOwogICAgICAgICAgICBjdXJyT2Zmc2V0ICs9IDQ7CiAgICAgICAgICAgIGlmIChjaHVua0NvdW50ID09PSAyKSB7CiAgICAgICAgICAgICAgc3RhdHMgPSB0aGlzLnBhcnNlUHNldWRvQmluKGJ5dGVzLCBjdXJyT2Zmc2V0KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjdXJyT2Zmc2V0ICs9IDE2ICogY2h1bmtDb3VudDsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGNvbnN0IGNodW5rQ291bnQgPSBieXRlcy5yZWFkSW50MzJMRShjdXJyT2Zmc2V0KTsKICAgICAgICAgICAgY3Vyck9mZnNldCArPSA0OwogICAgICAgICAgICBjb25zdCBjaHVua3MgPSBuZXcgQXJyYXkoY2h1bmtDb3VudCk7CiAgICAgICAgICAgIGZvciAobGV0IGsgPSAwOyBrIDwgY2h1bmtDb3VudDsgayArPSAxKSB7CiAgICAgICAgICAgICAgY29uc3QgdSA9IGZyb21CeXRlcyhieXRlcywgY3Vyck9mZnNldCk7CiAgICAgICAgICAgICAgY29uc3QgdiA9IGZyb21CeXRlcyhieXRlcywgY3Vyck9mZnNldCArIDgpOwogICAgICAgICAgICAgIGN1cnJPZmZzZXQgKz0gMTY7CiAgICAgICAgICAgICAgZmlyc3REYXRhTGluZSA9IHRoaXMuX2ZpbmRGaXJzdERhdGEoZmlyc3REYXRhTGluZSwgdSk7CiAgICAgICAgICAgICAgY2h1bmtzW2tdID0gbmV3IENodW5rKHUsIHYsIGJpbik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYmluSW5kZXhbYmluXSA9IGNodW5rczsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgY29uc3QgbGluZWFyQ291bnQgPSBieXRlcy5yZWFkSW50MzJMRShjdXJyT2Zmc2V0KTsKICAgICAgICBjdXJyT2Zmc2V0ICs9IDQ7CiAgICAgICAgY29uc3QgbGluZWFySW5kZXggPSBuZXcgQXJyYXkobGluZWFyQ291bnQpOwogICAgICAgIGZvciAobGV0IGsgPSAwOyBrIDwgbGluZWFyQ291bnQ7IGsgKz0gMSkgewogICAgICAgICAgbGluZWFySW5kZXhba10gPSBmcm9tQnl0ZXMoYnl0ZXMsIGN1cnJPZmZzZXQpOwogICAgICAgICAgY3Vyck9mZnNldCArPSA4OwogICAgICAgICAgZmlyc3REYXRhTGluZSA9IHRoaXMuX2ZpbmRGaXJzdERhdGEoZmlyc3REYXRhTGluZSwgbGluZWFySW5kZXhba10pOwogICAgICAgIH0KICAgICAgICByZXR1cm4geyBiaW5JbmRleCwgbGluZWFySW5kZXgsIHN0YXRzIH07CiAgICAgIH0pOwogICAgICByZXR1cm4gewogICAgICAgIGluZGljZXMsCiAgICAgICAgbWV0YUNoYXIsCiAgICAgICAgbWF4QmluTnVtYmVyLAogICAgICAgIG1heFJlZkxlbmd0aCwKICAgICAgICBza2lwTGluZXMsCiAgICAgICAgZmlyc3REYXRhTGluZSwKICAgICAgICBjb2x1bW5OdW1iZXJzLAogICAgICAgIGNvb3JkaW5hdGVUeXBlLAogICAgICAgIGZvcm1hdCwKICAgICAgICByZWZJZFRvTmFtZSwKICAgICAgICByZWZOYW1lVG9JZCwKICAgICAgICBtYXhCbG9ja1NpemU6IDEgPDwgMTYKICAgICAgfTsKICAgIH0KICAgIHBhcnNlUHNldWRvQm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b3B0cyA9IHt9KSB7CiAgICAgIGlmIChtaW4gPCAwKSB7CiAgICAgICAgbWluID0gMDsKICAgICAgfQogICAgICBjb25zdCBpbmRleERhdGEgPSBhd2FpdCB0aGlzLnBhcnNlKG9wdHMpOwogICAgICBpZiAoIWluZGV4RGF0YSkgewogICAgICAgIHJldHVybiBbXTsKICAgICAgfQogICAgICBjb25zdCByZWZJZCA9IGluZGV4RGF0YS5yZWZOYW1lVG9JZFtyZWZOYW1lXTsKICAgICAgY29uc3QgYmEgPSBpbmRleERhdGEuaW5kaWNlc1tyZWZJZF07CiAgICAgIGlmICghYmEpIHsKICAgICAgICByZXR1cm4gW107CiAgICAgIH0KICAgICAgY29uc3QgbWluT2Zmc2V0ID0gYmEubGluZWFySW5kZXgubGVuZ3RoID8gYmEubGluZWFySW5kZXhbbWluID4+IFRBRF9MSURYX1NISUZUID49IGJhLmxpbmVhckluZGV4Lmxlbmd0aCA/IGJhLmxpbmVhckluZGV4Lmxlbmd0aCAtIDEgOiBtaW4gPj4gVEFEX0xJRFhfU0hJRlRdIDogbmV3IFZpcnR1YWxPZmZzZXQoMCwgMCk7CiAgICAgIGlmICghbWluT2Zmc2V0KSB7CiAgICAgICAgY29uc29sZS53YXJuKCJxdWVyeWluZyBvdXRzaWRlIG9mIHBvc3NpYmxlIHRhYml4IHJhbmdlIik7CiAgICAgIH0KICAgICAgY29uc3Qgb3ZlcmxhcHBpbmdCaW5zID0gcmVnMmJpbnMobWluLCBtYXgpOwogICAgICBjb25zdCBjaHVua3MgPSBbXTsKICAgICAgZm9yIChjb25zdCBbc3RhcnQsIGVuZF0gb2Ygb3ZlcmxhcHBpbmdCaW5zKSB7CiAgICAgICAgZm9yIChsZXQgYmluID0gc3RhcnQ7IGJpbiA8PSBlbmQ7IGJpbisrKSB7CiAgICAgICAgICBpZiAoYmEuYmluSW5kZXhbYmluXSkgewogICAgICAgICAgICBjb25zdCBiaW5DaHVua3MgPSBiYS5iaW5JbmRleFtiaW5dOwogICAgICAgICAgICBmb3IgKGxldCBjID0gMDsgYyA8IGJpbkNodW5rcy5sZW5ndGg7ICsrYykgewogICAgICAgICAgICAgIGNodW5rcy5wdXNoKG5ldyBDaHVuayhiaW5DaHVua3NbY10ubWludiwgYmluQ2h1bmtzW2NdLm1heHYsIGJpbikpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIGNvbnN0IG5pbnR2ID0gYmEubGluZWFySW5kZXgubGVuZ3RoOwogICAgICBsZXQgbG93ZXN0ID0gbnVsbDsKICAgICAgY29uc3QgbWluTGluID0gTWF0aC5taW4obWluID4+IDE0LCBuaW50diAtIDEpOwogICAgICBjb25zdCBtYXhMaW4gPSBNYXRoLm1pbihtYXggPj4gMTQsIG5pbnR2IC0gMSk7CiAgICAgIGZvciAobGV0IGkgPSBtaW5MaW47IGkgPD0gbWF4TGluOyArK2kpIHsKICAgICAgICBjb25zdCB2cCA9IGJhLmxpbmVhckluZGV4W2ldOwogICAgICAgIGlmICh2cCkgewogICAgICAgICAgaWYgKCFsb3dlc3QgfHwgdnAuY29tcGFyZVRvKGxvd2VzdCkgPCAwKSB7CiAgICAgICAgICAgIGxvd2VzdCA9IHZwOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gb3B0aW1pemVDaHVua3MoY2h1bmtzLCBsb3dlc3QpOwogICAgfQogIH07CgogIC8vIG5vZGVfbW9kdWxlcy8ucG5wbS9AZ21vZCt0YWJpeEAxLjUuMTEvbm9kZV9tb2R1bGVzL0BnbW9kL3RhYml4L2VzbS9jc2kuanMKICBpbml0X2J1ZmZlcl9zaGltKCk7CiAgdmFyIGltcG9ydF9sb25nMyA9IF9fdG9Nb2R1bGUocmVxdWlyZV9sb25nKCkpOwogIHZhciBDU0kxX01BR0lDID0gMjE1ODI2NTk7CiAgdmFyIENTSTJfTUFHSUMgPSAzODM1OTg3NTsKICBmdW5jdGlvbiBsc2hpZnQobnVtLCBiaXRzKSB7C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ICAgICAgZm9ybWF0OiAiZ2VuZXJpYyIKICAgICAgfTsKICAgICAgY29uc3QgcmVmQ291bnQgPSBieXRlcy5yZWFkSW50MzJMRSgxNiArIGF1eExlbmd0aCk7CiAgICAgIGxldCBmaXJzdERhdGFMaW5lOwogICAgICBsZXQgY3Vyck9mZnNldCA9IDE2ICsgYXV4TGVuZ3RoICsgNDsKICAgICAgY29uc3QgaW5kaWNlcyA9IG5ldyBBcnJheShyZWZDb3VudCkuZmlsbCgwKS5tYXAoKCkgPT4gewogICAgICAgIGNvbnN0IGJpbkNvdW50ID0gYnl0ZXMucmVhZEludDMyTEUoY3Vyck9mZnNldCk7CiAgICAgICAgY3Vyck9mZnNldCArPSA0OwogICAgICAgIGNvbnN0IGJpbkluZGV4ID0ge307CiAgICAgICAgbGV0IHN0YXRzOwogICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgYmluQ291bnQ7IGogKz0gMSkgewogICAgICAgICAgY29uc3QgYmluID0gYnl0ZXMucmVhZFVJbnQzMkxFKGN1cnJPZmZzZXQpOwogICAgICAgICAgaWYgKGJpbiA+IHRoaXMubWF4QmluTnVtYmVyKSB7CiAgICAgICAgICAgIHN0YXRzID0gdGhpcy5wYXJzZVBzZXVkb0JpbihieXRlcywgY3Vyck9mZnNldCArIDQpOwogICAgICAgICAgICBjdXJyT2Zmc2V0ICs9IDQgKyA4ICsgNCArIDE2ICsgMTY7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjb25zdCBsb2Zmc2V0ID0gZnJvbUJ5dGVzKGJ5dGVzLCBjdXJyT2Zmc2V0ICsgNCk7CiAgICAgICAgICAgIGZpcnN0RGF0YUxpbmUgPSB0aGlzLl9maW5kRmlyc3REYXRhKGZpcnN0RGF0YUxpbmUsIGxvZmZzZXQpOwogICAgICAgICAgICBjb25zdCBjaHVua0NvdW50ID0gYnl0ZXMucmVhZEludDMyTEUoY3Vyck9mZnNldCArIDEyKTsKICAgICAgICAgICAgY3Vyck9mZnNldCArPSAxNjsKICAgICAgICAgICAgY29uc3QgY2h1bmtzID0gbmV3IEFycmF5KGNodW5rQ291bnQpOwogICAgICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IGNodW5rQ291bnQ7IGsgKz0gMSkgewogICAgICAgICAgICAgIGNvbnN0IHUgPSBmcm9tQnl0ZXMoYnl0ZXMsIGN1cnJPZmZzZXQpOwogICAgICAgICAgICAgIGNvbnN0IHYgPSBmcm9tQnl0ZXMoYnl0ZXMsIGN1cnJPZmZzZXQgKyA4KTsKICAgICAgICAgICAgICBjdXJyT2Zmc2V0ICs9IDE2OwogICAgICAgICAgICAgIGNodW5rc1trXSA9IG5ldyBDaHVuayh1LCB2LCBiaW4pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJpbkluZGV4W2Jpbl0gPSBjaHVua3M7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiB7IGJpbkluZGV4LCBzdGF0cyB9OwogICAgICB9KTsKICAgICAgcmV0dXJuIHsKICAgICAgICAuLi5hdXgsCiAgICAgICAgY3NpOiB0cnVlLAogICAgICAgIHJlZkNvdW50LAogICAgICAgIG1heEJsb2NrU2l6ZTogMSA8PCAxNiwKICAgICAgICBmaXJzdERhdGFMaW5lLAogICAgICAgIGNzaVZlcnNpb24sCiAgICAgICAgaW5kaWNlcywKICAgICAgICBkZXB0aDogdGhpcy5kZXB0aCwKICAgICAgICBtYXhCaW5OdW1iZXI6IHRoaXMubWF4QmluTnVtYmVyLAogICAgICAgIG1heFJlZkxlbmd0aAogICAgICB9OwogICAgfQogICAgcGFyc2VQc2V1ZG9CaW4oYnl0ZXMsIG9mZnNldCkgewogICAgICBjb25zdCBsaW5lQ291bnQgPSBsb25nVG9OdW1iZXIoaW1wb3J0X2xvbmczLmRlZmF1bHQuZnJvbUJ5dGVzTEUoYnl0ZXMuc2xpY2Uob2Zmc2V0ICsgMjgsIG9mZnNldCArIDM2KSwgdHJ1ZSkpOwogICAgICByZXR1cm4geyBsaW5lQ291bnQgfTsKICAgIH0KICAgIGFzeW5jIGJsb2Nrc0ZvclJhbmdlKHJlZk5hbWUsIG1pbiwgbWF4LCBvcHRzID0ge30pIHsKICAgICAgaWYgKG1pbiA8IDApIHsKICAgICAgICBtaW4gPSAwOwogICAgICB9CiAgICAgIGNvbnN0IGluZGV4RGF0YSA9IGF3YWl0IHRoaXMucGFyc2Uob3B0cyk7CiAgICAgIGlmICghaW5kZXhEYXRhKSB7CiAgICAgICAgcmV0dXJuIFtdOwogICAgICB9CiAgICAgIGNvbnN0IHJlZklkID0gaW5kZXhEYXRhLnJlZk5hbWVUb0lkW3JlZk5hbWVdOwogICAgICBjb25zdCBiYSA9IGluZGV4RGF0YS5pbmRpY2VzW3JlZklkXTsKICAgICAgaWYgKCFiYSkgewogICAgICAgIHJldHVybiBbXTsKICAgICAgfQogICAgICBjb25zdCBvdmVybGFwcGluZ0JpbnMgPSB0aGlzLnJlZzJiaW5zKG1pbiwgbWF4KTsKICAgICAgY29uc3QgY2h1bmtzID0gW107CiAgICAgIGZvciAoY29uc3QgW3N0YXJ0LCBlbmRdIG9mIG92ZXJsYXBwaW5nQmlucykgewogICAgICAgIGZvciAobGV0IGJpbiA9IHN0YXJ0OyBiaW4gPD0gZW5kOyBiaW4rKykgewogICAgICAgICAgaWYgKGJhLmJpbkluZGV4W2Jpbl0pIHsKICAgICAgICAgICAgY29uc3QgYmluQ2h1bmtzID0gYmEuYmluSW5kZXhbYmluXTsKICAgICAgICAgICAgZm9yIChsZXQgYyA9IDA7IGMgPCBiaW5DaHVua3MubGVuZ3RoOyArK2MpIHsKICAgICAgICAgICAgICBjaHVua3MucHVzaChuZXcgQ2h1bmsoYmluQ2h1bmtzW2NdLm1pbnYsIGJpbkNodW5rc1tjXS5tYXh2LCBiaW4pKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gb3B0aW1pemVDaHVua3MoY2h1bmtzLCBuZXcgVmlydHVhbE9m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QgbGFzdCA9IERhdGUubm93KCk7CiAgICAgIGZvciAobGV0IGNodW5rTnVtID0gMDsgY2h1bmtOdW0gPCBjaHVua3MubGVuZ3RoOyBjaHVua051bSArPSAxKSB7CiAgICAgICAgbGV0IHByZXZpb3VzU3RhcnRDb29yZGluYXRlOwogICAgICAgIGNvbnN0IGMgPSBjaHVua3NbY2h1bmtOdW1dOwogICAgICAgIGNvbnN0IHsgYnVmZmVyLCBjcG9zaXRpb25zLCBkcG9zaXRpb25zIH0gPSBhd2FpdCB0aGlzLmNodW5rQ2FjaGUuZ2V0KGMudG9TdHJpbmcoKSwgYyk7CiAgICAgICAgY2hlY2tBYm9ydFNpZ25hbChzaWduYWwpOwogICAgICAgIGxldCBibG9ja1N0YXJ0ID0gMDsKICAgICAgICBsZXQgcG9zID0gMDsKICAgICAgICB3aGlsZSAoYmxvY2tTdGFydCA8IGJ1ZmZlci5sZW5ndGgpIHsKICAgICAgICAgIGNvbnN0IG4gPSBidWZmZXIuaW5kZXhPZigiXG4iLCBibG9ja1N0YXJ0KTsKICAgICAgICAgIGlmIChuID09PSAtMSkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IGIgPSBidWZmZXIuc2xpY2UoYmxvY2tTdGFydCwgbik7CiAgICAgICAgICBjb25zdCBsaW5lID0gKGRlY29kZXIgPT09IG51bGwgfHwgZGVjb2RlciA9PT0gdm9pZCAwID8gdm9pZCAwIDogZGVjb2Rlci5kZWNvZGUoYikpIHx8IGIudG9TdHJpbmcoKTsKICAgICAgICAgIGlmIChkcG9zaXRpb25zKSB7CiAgICAgICAgICAgIHdoaWxlIChibG9ja1N0YXJ0ICsgYy5taW52LmRhdGFQb3NpdGlvbiA+PSBkcG9zaXRpb25zW3BvcysrXSkgewogICAgICAgICAgICB9CiAgICAgICAgICAgIHBvcy0tOwogICAgICAgICAgfQogICAgICAgICAgY29uc3QgeyBzdGFydENvb3JkaW5hdGUsIG92ZXJsYXBzIH0gPS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XRhQ2hhcikgewogICAgICAgIHJldHVybiB7IG92ZXJsYXBzOiBmYWxzZSB9OwogICAgICB9CiAgICAgIGxldCB7IHJlZiwgc3RhcnQsIGVuZCB9ID0gY29sdW1uTnVtYmVyczsKICAgICAgaWYgKCFyZWYpIHsKICAgICAgICByZWYgPSAwOwogICAgICB9CiAgICAgIGlmICghc3RhcnQpIHsKICAgICAgICBzdGFydCA9IDA7CiAgICAgIH0KICAgICAgaWYgKCFlbmQpIHsKICAgICAgICBlbmQgPSAwOwogICAgICB9CiAgICAgIGlmIChmb3JtYXQgPT09ICJWQ0YiKSB7CiAgICAgICAgZW5kID0gODsKICAgICAgfQogICAgICBjb25zdCBtYXhDb2x1bW4gPSBNYXRoLm1heChyZWYsIHN0YXJ0LCBlbmQpOwogICAgICBsZXQgY3VycmVudENvbHVtbk51bWJlciA9IDE7CiAgICAgIGxldCBjdXJyZW50Q29sdW1uU3RhcnQgPSAwOwogICAgICBsZXQgcmVmU2VxID0gIiI7CiAgICAgIGxldCBzdGFydENvb3JkaW5hdGUgPSAtSW5maW5pdHk7CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGluZS5sZW5ndGggKyAxOyBpICs9IDEpIHsKICAgICAgICBpZiAobGluZVtpXSA9PT0gIgkiIHx8IGkgPT09IGxpbmUubGVuZ3RoKSB7CiAgICAgICAgICBpZiAoY3VycmVudENvbHVtbk51bWJlciA9PT0gcmVmKSB7CiAgICAgICAgICAgIGlmICh0aGlzLnJlbmFtZVJlZlNlcShsaW5lLnNsaWNlKGN1cnJlbnRDb2x1bW5TdGFydCwgaSkpICE9PSByZWdpb25SZWZOYW1lKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHsgb3ZlcmxhcHM6IGZhbHNlIH07CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSBpZiAoY3VycmVudENvbHVtbk51bWJlciA9PT0gc3RhcnQpIHsKICAgICAgICAgICAgc3RhcnRDb29yZGluYXRlID0gcGFyc2VJbnQobGluZS5zbGljZShjdXJyZW50Q29sdW1uU3RhcnQsIGkpLCAxMCk7CiAgICAgICAgICAgIGlmIChjb29yZGluYXRlVHlwZSA9PT0gIjEtYmFzZWQtY2xvc2VkIikgewogICAgICAgICAgICAgIHN0YXJ0Q29vcmRpbmF0ZSAtPSAxOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzdGFydENvb3JkaW5hdGUgPj0gcmVnaW9uRW5kKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHsgc3RhcnRDb29yZGluYXRlLCBvdmVybGFwczogZmFsc2UgfTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoZW5kID09PSAwIHx8IGVuZCA9PT0gc3RhcnQpIHsKICAgICAgICAgICAgICBpZiAoc3RhcnRDb29yZGluYXRlICsgMSA8PSByZWdpb25TdGFydCkgewogICAgICAgICAgICAgICAgcmV0dXJuIHsgc3RhcnRDb29yZGluYXRlLCBvdmVybGFwczogZmFsc2UgfTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSBpZiAoZm9ybWF0ID09PSAiVkNGIiAmJiBjdXJyZW50Q29sdW1uTnVtYmVyID09PSA0KSB7CiAgICAgICAgICAgIHJlZlNlcSA9IGxpbmUuc2xpY2UoY3VycmVudENvbHVtblN0YXJ0LCBpKTsKICAgICAgICAgIH0gZWxzZSBpZiAoY3VycmVudENvbHVtbk51bWJlciA9PT0gZW5kKSB7CiAgICAgICAgICAgIGxldCBlbmRDb29yZGluYXRlOwogICAgICAgICAgICBpZiAoZm9ybWF0ID09PSAiVkNGIikgewogICAgICAgICAgICAgIGVuZENvb3JkaW5hdGUgPSB0aGlzLl9nZXRWY2ZFbmQoc3RhcnRDb29yZGluYXRlLCByZWZTZXEsIGxpbmUuc2xpY2UoY3VycmVudENvbHVtblN0YXJ0LCBpKSk7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgZW5kQ29vcmRpbmF0ZSA9IHBhcnNlSW50KGxpbmUuc2xpY2UoY3VycmVudENvbHVtblN0YXJ0LCBpKSwgMTApOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChlbmRDb29yZGluYXRlIDw9IHJlZ2lvblN0YXJ0KSB7CiAgICAgICAgICAgICAgcmV0dXJuIHsgb3ZlcmxhcHM6IGZhbHNlIH07CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGN1cnJlbnRDb2x1bW5TdGFydCA9IGkgKyAxOwogICAgICAgICAgY3VycmVudENvbHVtbk51bWJlciArPSAxOwogICAgICAgICAgaWYgKGN1cnJlbnRDb2x1bW5OdW1iZXIgPiBtYXhDb2x1bW4pIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiB7IHN0YXJ0Q29vcmRpbmF0ZSwgb3ZlcmxhcHM6IHRydWUgfTsKICAgIH0KICAgIF9nZXRWY2ZFbmQoc3RhcnRDb29yZGluYXRlLCByZWZTZXEsIGluZm8pIHsKICAgICAgbGV0IGVuZENvb3JkaW5hdGUgPSBzdGFydENvb3JkaW5hdGUgKyByZWZTZXEubGVuZ3RoOwogICAgICBjb25zdCBpc1RSQSA9IGluZm8uaW5kZXhPZigiU1ZUWVBFPVRSQSIpICE9PSAtMTsKICAgICAgaWYgKGluZm9bMF0gIT09ICIuIiAmJiAhaXNUUkEpIHsKICAgICAgICBsZXQgcHJldkNoYXIgPSAiOyI7CiAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBpbmZvLmxlbmd0aDsgaiArPSAxKSB7CiAgICAgICAgICBpZiAocHJldkNoYXIgPT09ICI7IiAmJiBpbmZvLnNsaWNlKGosIGogKyA0KSA9PT0gIkVORD0iKSB7CiAgICAgICAgICAgIGxldCB2YWx1ZUVuZCA9IGluZm8uaW5kZXhPZigiOyIsIGopOwogICAgICAgICAgICBpZiAodmFsdWVFbmQgPT09IC0xKSB7CiAgICAgICAgICAgICAgdmFsdWVFbmQgPSBpbmZvLmxlbmd0aDsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbmRDb29yZGluYXRlID0gcGFyc2VJbnQoaW5mby5zbGljZShqICsgNCwgdmFsdWVFbmQpLCAxMCk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgcHJldkNoYXIgPSBpbmZvW2pdOwogICAgICAgIH0KICAgICAgfSBlbHNlIGlmIChpc1RSQSkgewogICAgICAgIHJldHVybiBzdGFydENvb3JkaW5hdGUgKyAxOwogICAgICB9CiAgICAgIHJldHVybiBlbmRDb29yZGluYXRlOwogICAgfQogICAgYXN5bmMgbGluZUNvdW50KHJlZk5hbWUsIG9wdHMgPSB7fSkgewogICAgICByZXR1cm4gdGhpcy5pbmRleC5saW5lQ291bnQocmVmTmFtZSwgb3B0cyk7CiAgICB9CiAgICBhc3luYyBfcmVhZFJlZ2lvbihwb3MsIHNpemUsIG9wdHMgPSB7fSkgewogICAgICBjb25zdCBiID0gaW1wb3J0X2J1ZmZlcjcuQnVmZmVyLmFsbG9jKHNpemUpOwogICAgICBjb25zdCB7IGJ5dGVzUmVhZCwgYnVmZmVyIH0gPSBhd2FpdCB0aGlzLmZpbGVoYW5kbGUucmVhZChiLCAwLCBzaXplLCBwb3MsIG9wdHMpOwogICAgICByZXR1cm4gYnVmZmVyLnNsaWNlKDAsIGJ5dGVzUmVhZCk7CiAgICB9CiAgICBhc3luYyByZWFkQ2h1bmsoYywgb3B0cyA9IHt9KSB7CiAgICAgIGNvbnN0IGRhdGEgPSBhd2FpdCB0aGlzLl9yZWFkUmVnaW9uKGMubWludi5ibG9ja1Bvc2l0aW9uLCBjLmZldGNoZWRTaXplKCksIG9wdHMpOwogICAgICB0cnkgewogICAgICAgIHJldHVybiB1bnppcENodW5rU2xpY2UoZGF0YSwgYyk7CiAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYGVycm9yIGRlY29tcHJlc3Np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ZHVsZXMvLnBucG0vZDMtYXJyYXlAMi4xMi4xL25vZGVfbW9kdWxlcy9kMy1hcnJheS9zcmMvYmlzZWN0b3IuanMKICBpbml0X2J1ZmZlcl9zaGltKCk7CiAgZnVuY3Rpb24gYmlzZWN0b3JfZGVmYXVsdChmKSB7CiAgICBsZXQgZGVsdGEgPSBmOwogICAgbGV0IGNvbXBhcmUgPSBmOwogICAgaWYgKGYubGVuZ3RoID09PSAxKSB7CiAgICAgIGRlbHRhID0gKGQsIHgpID0+IGYoZCkgLSB4OwogICAgICBjb21wYXJlID0gYXNjZW5kaW5nQ29tcGFyYXRvcihmKTsKICAgIH0KICAgIGZ1bmN0aW9uIGxlZnQoYSwgeCwgbG8sIGhpKSB7CiAgICAgIGlmIChsbyA9PSBudWxsKQogICAgICAgIGxvID0gMDsKICAgICAgaWYgKGhpID09IG51bGwpCiAgICAgICAgaGkgPSBhLmxlbmd0aDsKICAgICAgd2hpbGUgKGxvIDwgaGkpIHsKICAgICAgICBjb25zdCBtaWQgPSBsbyArIGhpID4+PiAxOwogICAgICAgIGlmIChjb21wYXJlKGFbbWlkXSwgeCkgPCAwKQogICAgICAgICAgbG8gPSBtaWQgKyAxOwogICAgICAgIGVsc2UKICAgICAgICAgIGhpID0gbWlkOwogICAgICB9CiAgICAgIHJldHVybiBsbzsKICAgIH0KICAgIGZ1bmN0aW9uIHJpZ2h0KGEsIHgsIGxvLCBoaSkgewogICAgICBpZiAobG8gPT0gbnVsbCkKICAgICAgICBsbyA9IDA7CiAgICAgIGlmIChoaSA9PSBudWxsKQogICAgICAgIGhpID0gYS5sZW5ndGg7CiAgICAgIHdoaWxlIChsbyA8IGhpKSB7CiAgICAgICAgY29uc3QgbWlkID0gbG8gKyBoaSA+Pj4gMTsKICAgICAgICBpZiAoY29tcGFyZShhW21pZF0sIHgpID4gMCkKICAgICAgICAgIGhpID0gbWlkOwogICAgICAgIGVsc2UKICAgICAgICAgIGxvID0gbWlkICsgMTsKICAgICAgfQogICAgICByZXR1cm4gbG87CiAgICB9CiAgICBmdW5jdGlvbiBjZW50ZXIoYSwgeCwgbG8sIGhpKSB7CiAgICAgIGlmIChsbyA9PSBudWxsKQogICAgICAgIGxvID0gMDsKICAgICAgaWYgKGhpID09IG51bGwpCiAgICAgICAgaGkgPSBhLmxlbmd0aDsKICAgICAgY29uc3QgaSA9IGxlZnQoYSwgeCwgbG8sIGhpIC0gMSk7CiAgICAgIHJldHVybiBpID4gbG8gJiYgZGVsdGEoYVtpIC0gMV0sIHgpID4gLWRlbHRhKGFbaV0sIHgpID8gaSAtIDEgOiBpOwogICAgfQogICAgcmV0dXJuIHsgbGVmdCwgY2VudGVyLCByaWdodCB9OwogIH0KICBmdW5jdGlvbiBhc2NlbmRpbmdDb21wYXJhdG9yKGYpIHsKICAgIHJldHVybiAoZCwgeCkgPT4gYXNjZW5kaW5nX2RlZmF1bHQoZihkKSwgeCk7CiAgfQoKICAvLyBzcmMvZGF0YS1mZXRjaGVycy91dGlscy50cwogIHZhciBEYXRhU291cmNlID0gY2xhc3MgewogICAgY29uc3RydWN0b3IoZmlsZSwgY2hyb21TaXplcywgb3B0aW9ucykgewogICAgICB0aGlzLmZpbGUgPSBmaWxlOwogICAgICB0aGlzLm9wdGlvbnMgPSBvcHRpb25zOwogICAgICB0aGlzLmNocm9tSW5mbyA9IHNpemVzVG9DaHJvbUluZm8oY2hyb21TaXplcyk7CiAgICAgIHRoaXMudGlsZXNldEluZm8gPSB0aWxlc2V0SW5mb0Zyb21DaHJvbUluZm8odGhpcy5jaHJvbUluZm8pOwogICAgfQogICAgY2hyb21JbmZvOwogICAgdGlsZXNldEluZm87CiAgfTsKICB2YXIgY2hyb21JbmZvQmlzZWN0b3IgPSBiaXNlY3Rvcl9kZWZhdWx0KChkKSA9PiBkLnBvcykubGVmdDsKICB2YXIgY2hyVG9BYnMgPSAoY2hyb20sIGNocm9tUG9zLCBjaHJvbUluZm8pID0+IGNocm9tSW5mby5jaHJQb3NpdGlvbnNbY2hyb21dL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GVmYXVsdFR5cGVzX2RlZmF1bHQuZGVmYXVsdEJlZFNjaGVtYSk7CiAgICAgICAgdGhpcy5hdHRlbXB0RGVmYXVsdEJlZCA9IHRydWU7CiAgICAgIH0KICAgIH0KICAgIHBhcnNlTGluZShsaW5lLCBvcHRzID0ge30pIHsKICAgICAgY29uc3QgeyBhdXRvU3FsIH0gPSB0aGlzOwogICAgICBjb25zdCB7IHVuaXF1ZUlkIH0gPSBvcHRzOwogICAgICBjb25zdCBmaWVsZHMgPSBBcnJheS5pc0FycmF5KGxpbmUpID8gbGluZSA6IGxpbmUuc3BsaXQoIgkiKTsKICAgICAgbGV0IGZlYXR1cmUgPSB7fTsKICAgICAgaWYgKCF0aGlzLmF0dGVtcHREZWZhdWx0QmVkIHx8IHRoaXMuYXR0ZW1wdERlZmF1bHRCZWQgJiYgaXNCZWQxMkxpa2UoZmllbGRzKSkgewogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXV0b1NxbC5maWVsZHMubGVuZ3RoOyBpKyspIHsKICAgICAgICAgIGNvbnN0IGF1dG9GaWVsZCA9IGF1dG9TcWwuZmllbGRzW2ldOwogICAgICAgICAgbGV0IGNvbHVtblZhbCA9IGZpZWxkc1tpXTsKICAgICAgICAgIGNvbnN0IHsgaXNOdW1lcmljLCBpc0FycmF5OiBpc0FycmF5MiwgYXJyYXlJc051bWVyaWMsIG5hbWUgfSA9IGF1dG9GaWVsZDsKICAgICAgICAgIGlmIChjb2x1bW5WYWwgPT09IG51bGwgfHwgY29sdW1uVmFsID09PSB2b2lkIDApIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoY29sdW1uVmFsICE9PSAiLiIpIHsKICAgICAgICAgICAgaWYgKGlzTnVtZXJpYykgewogICAgICAgICAgICAgIGNvbnN0IG51bSA9IE51bWJlcihjb2x1bW5WYWwpOwogICAgICAgICAgICAgIGNvbHVtblZhbCA9IE51bWJlci5pc05hTihudW0pID8gY29sdW1uVmFsIDogbnVtOwogICAgICAgICAgICB9IGVsc2UgaWYgKGlzQXJyYXkyKSB7CiAgICAgICAgICAgICAgY29sdW1uVmFsID0gY29sdW1uVmFsLnNwbGl0KCIsIik7CiAgICAgICAgICAgICAgaWYgKGNvbHVtblZhbFtjb2x1bW5WYWwubGVuZ3RoIC0gMV0gPT09ICIiKSB7CiAgICAgICAgICAgICAgICBjb2x1bW5WYWwucG9wKCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChhcnJheUlzTnVtZXJpYykgewogICAgICAgICAgICAgICAgY29sdW1uVmFsID0gY29sdW1uVmFsLm1hcCgoc3RyKSA9PiBOdW1iZXIoc3RyKSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGZlYXR1cmVbbmFtZV0gPSBjb2x1bW5WYWw7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGNvbnN0IGZpZWxkTmFtZXMgPSBbImNocm9tIiwgImNocm9tU3RhcnQiLCAiY2hyb21FbmQiLCAibmFtZSJdOwogICAgICAgIGZlYXR1cmUgPSBPYmplY3QuZnJvbUVudHJpZXMoZmllbGRzLm1hcCgoZiwgaSkgPT4gW2ZpZWxkTmFtZXNbaV0gfHwgImZpZWxkIiArIGksIGZdKSk7CiAgICAgICAgZmVhdHVyZS5jaHJvbVN0YXJ0ID0gK2ZlYXR1cmUuY2hyb21TdGFydDsKICAgICAgICBmZWF0dXJlLmNocm9tRW5kID0gK2ZlYXR1cmUuY2hyb21FbmQ7CiAgICAgICAgaWYgKCFOdW1iZXIuaXNOYU4oTnVtYmVyLnBhcnNlRmxvYXQoZmVhdHVyZS5maWVsZDQpKSkgewogICAgICAgICAgZmVhdHVyZS5zY29yZSA9ICtmZWF0dXJlLmZpZWxkNDsKICAgICAgICAgIGRlbGV0ZSBmZWF0dXJlLmZpZWxkNDsKICAgICAgICB9CiAgICAgICAgaWYgKGZlYXR1cmUuZmllbGQ1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4jZ2VuZXJhdGVBdXRvU1FMRmllbGRzKCk7CiAgICAgIHJldHVybiBTdHJpbmcucHJvdG90eXBlLmNvbmNhdChBVVRPX1NRTF9IRUFERVIsIGF1dG9TcWxGaWVsZHMsIEFVVE9fU1FMX0ZPT1RFUik7CiAgICB9CiAgICAjZ2VuZXJhdGVBdXRvU1FMRmllbGRzKCkgewogICAgICBjb25zdCBCRUQxMkZpZWxkcyA9IFsKICAgICAgICBbInN0cmluZyIsICJjaHJvbSJdLAogICAgICAgIFsidWludCIsICJjaHJvbVN0YXJ0Il0sCiAgICAgICAgWyJ1aW50IiwgImNocm9tRW5kIl0sCiAgICAgICAgWyJzdHJpbmciLCAibmFtZSJdLAogICAgICAgIFsiZmxvYXQiLCAic2NvcmUiXSwKICAgICAgICBbImNoYXIiLCAic3RyYW5kIl0sCiAgICAgICAgWyJ1aW50IiwgInRoaWNrU3RhcnQiXSwKICAgICAgICBbInVpbnQiLCAidGhpY2tFbmQiXSwKICAgICAgICBbInN0cmluZyIsICJpdGVtUmdiIl0sCiAgICAgICAgWyJ1aW50IiwgImJsb2NrQ291bnQiXSwKICAgICAgICBbInVpbnRbYmxvY2tDb3VudF0iLCAiYmxvY2tTaXplcyJdLAogICAgICAgIFsidWludFtibG9ja0NvdW50XSIsICJibG9ja1N0YXJ0cyJdCiAgICAgIF07CiAgICAgIGlmICghdGhpcy4jbl9jb2x1bW5zKQogICAgICAgIHRocm93IG5ldyBFcnJvcigiTnVtYmVyIG9mIGNvbHVtbnMgd2FzIG5vdCBhYmxlIHRvIGJlIGRldGVybWluZWQiKTsKICAgICAgaWYgKCF0aGlzLiNjdXN0b21GaWVsZHMpCiAgICAgICAgcmV0dXJuICIiOwogICAgICBjb25zdCBjdXN0b21GaWVsZFR5cGUgPSAic3RyaW5nIjsKICAgICAgY29uc3QgY3VzdG9tRmllbGRzV2l0aFR5cGVzID0gdGhpcy4jY3VzdG9tRmllbGRzLm1hcCgoY29sdW1uKSA9PiBbY3VzdG9tRmll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maWxlLnRiaS5nZXRMaW5lcyhjaHJvbU5hbWUsIGNocm9tU3RhcnQsIGNocm9tRW5kLCAobGluZSkgPT4gewogICAgICAgICAgICByZXNvbHZlKGxpbmUuc3BsaXQoIgkiKS5sZW5ndGgpOwogICAgICAgICAgfSk7CiAgICAgICAgfSk7CiAgICAgICAgaWYgKG5fY29scyA+IDApCiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgICByZXR1cm4gbl9jb2xzOwogICAgfQogICAgYXN5bmMgZ2V0VGlsZURhdGEobWluWCwgbWF4WCkgewogICAgICBjb25zdCBzb3VyY2UgPSBkYXRhU291cmNlcy5nZXQodGhpcy4jdWlkKTsKICAgICAgY29uc3QgcGFyc2VyMiA9IGF3YWl0IHRoaXMuZ2V0UGFyc2VyKCk7CiAgICAgIGxldCBjdXJNaW5YID0gbWluWDsKICAgICAgY29uc3QgeyBjaHJvbUxlbmd0aHMsIGN1bVBvc2l0aW9ucyB9ID0gc291cmNlLmNocm9tSW5mbzsKICAgICAgY29uc3QgYWxsVGlsZXMgPSBbXTsKICAgICAgZm9yIChjb25zdCBjdW1Qb3Mgb2YgY3VtUG9zaXRpb25zKSB7CiAgICAgICAgY29uc3QgY2hyb21OYW1lID0gY3VtUG9zLmNocjsKICAgICAgICBjb25zdCBjaHJvbVN0YXJ0ID0gY3VtUG9zLnBvczsKICAgICAgICBjb25zdCBjaHJvbUVuZCA9IGN1bVBvcy5wb3MgKyBjaHJvbUxlbmd0aHNbY2hyb21OYW1lXTsKICAgICAgICBsZXQgc3RhcnRQb3MsIGVuZFBvczsKICAgICAgICBpZiAoY2hyb21TdGFydCA+IGN1ck1pblggfHwgY3VyTWluWCA+PSBjaHJvbUVuZCkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHRpbGVzUHJvbWlzZSA9IG5ldyBQcm9taXNlKChyZXNvbHZlKSA9PiB7CiAgICAgICAgICBjb25zdCB0aWxlcyA9IFtdOwogICAgICAgICAgY29uc3QgbGluZUNhbGxiYWNrID0gKGxpbmUpID0+IHsKICAgICAgICAgICAgY29uc3QgYmVkVGlsZSA9IHBhcnNlcjIucGFyc2VMaW5lKGxpbmUsIGNocm9tU3RhcnQpOwogICAgICAgICAgICB0aWxlcy5wdXNoKGJlZFRpbGUpOwogICAgICAgICAgfTsKICAgICAgICAgIGlmIChtYXhYID4gY2hyb21FbmQpIHsKICAgICAgICAgICAgc3RhcnRQb3MgPSBjdXJNaW5YIC0gY2hyb21TdGFydDsKICAgICAgICAgICAgZW5kUG9zID0gY2hyb21FbmQgLSBjaHJvbVN0YXJ0OwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhcnRQb3MgPSBNYXRoLmZsb29yKGN1ck1pblggLSBjaHJvbVN0YXJ0KTsKICAgICAgICAgICAgZW5kUG9zID0gTWF0aC5jZWlsKG1heFggLSBjaHJvbVN0YXJ0KTsKICAgICAgICAgIH0KICAgICAgICAgIHNvdXJjZS5maWxlLnRiaS5nZXRMaW5lcyhjaHJvbU5hbWUsIHN0YXJ0UG9zLCBlbmRQb3MsIGxpbmVDYWxsYmFjaykudGhlbigoKSA9PiB7CiAgICAgICAgICAgIHJlc29sdmUodGlsZXMpOwogICAgICAgICAgfSk7CiAgICAgICAgfSk7CiAgICAgICAgYWxsVGlsZXMucHVzaCh0aWxlc1Byb21pc2UpOwogICAgICAgIGlmIChtYXhYIDw9IGNocm9tRW5kKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgY3VyTWluWCA9IGNocm9tRW5kOwogICAgICB9CiAgICAgIGNvbnN0IHRpbGVBcnJheXMgPSBhd2FpdCBQcm9taXNlLmFsbChhbGxUaWxlcyk7CiAgICAgIHJldHVybiB0aWxlQXJyYXlzLmZsYXQoKTsKICAgIH0KICB9OwogIHZhciBiZWRGaWxlcyA9IG5ldyBNYXAoKTsKICB2YXIgdGlsZVZhbHVlcyA9IHt9OwogIHZhciBkYXRhU291cmNlcyA9IG5ld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window<"u"&&window.Blob&&new Blob([atob(r6e)],{type:"text/javascript;charset=utf-8"});function zNg(){const e=m9e&&(window.URL||window.webkitURL).createObjectURL(m9e);try{return e?new Worker(e):new Worker("data:application/javascript;base64,"+r6e,{type:"module"})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const PNg=200;class o6e{constructor(g,i){at(this,"dataConfig",{}),at(this,"uid"),at(this,"prevRequestTime"),at(this,"track"),at(this,"toFetch"),at(this,"fetchTimeout"),at(this,"worker"),this.uid=g.libraries.slugid.nice(),this.prevRequestTime=0,this.toFetch=new Set;const{url:n,indexUrl:I,assembly:r,...o}=i;this.worker=Xz(new zNg).then(async C=>{const a=Object.entries(In(r).size);return await C.init(this.uid,{url:n,indexUrl:I},a,o),C})}async tilesetInfo(g){(await this.worker).tilesetInfo(this.uid).then(g)}fetchTilesDebounced(g,i){this.track.drawLoadingCue(),i.forEach(n=>this.toFetch.add(n)),this.fetchTimeout&&clearTimeout(this.fetchTimeout),this.fetchTimeout=setTimeout(()=>{this.sendFetch(g,[...this.toFetch]),this.toFetch.clear()},PNg)}async sendFetch(g,i){(await this.worker).fetchTilesDebounced(this.uid,i).then(g)}async getTabularData(g){const i=await(await this.worker).getTabularData(this.uid,g);return JSON.parse(new TextDecoder().decode(i))}}at(o6e,"config",{type:"bed"});const _Ng=Object.freeze(Object.defineProperty({__proto__:null,BamDataFetcher:zD,BedDataFetcher:o6e,BigWigDataFetcher:e6e,CsvDataFetcher:g6e,GffDataFetcher:I6e,JsonDataFetcher:i6e,VcfDataFetcher:R8e},Symbol.toStringTag,{value:"Module"})),ONg="gosling-data-row-uid";function JNg(e,g){var i,n,I,r,o,C,a,A,s,l,c,u,d,h,f,m;const b=[];if(!eCe(e.data)){console.warn("No data is specified");return}if(e.data.type==="vector"||e.data.type==="bigwig"){if(!("dense"in g))return;const p=(i=e.data.binSize)!=null?i:1,y=g.dense,Z=g.tileSize,v=g.tileWidth/g.tileSize,G=(n=e.data.value)!=null?n:"value",B=(I=e.data.column)!=null?I:"position",S=(r=e.data.start)!=null?r:"start",R=(o=e.data.end)!=null?o:"end",w=`${G}_min`,T=`${G}_max`,W=(C=e.data.aggregation)!=null?C:"mean";let V=0,X=Number.MAX_SAFE_INTEGER,N=Number.MIN_SAFE_INTEGER,Y=Number.MIN_SAFE_INTEGER,x=Number.MAX_SAFE_INTEGER;Array.from(Array(Z).keys()).forEach((M,F)=>{if(p===1){const $=y[F]/(W==="mean"?v:1);b.push({[G]:$,[B]:g.tileX+(F+.5)*v,[S]:g.tileX+F*v,[R]:g.tileX+(F+1)*v,[w]:$,[T]:$})}else if(F%p===0)V=X=N=y[F],Y=F,x=F+p;else if(F%p===p-1)b.push({[G]:V/p/(W==="mean"?v:1),[B]:g.tileX+(Y+p/2)*v,[S]:g.tileX+Y*v,[R]:g.tileX+x*v,[w]:X,[T]:N});else if(F===Z-1){const $=Z%p,Q=Y+$;b.push({[G]:V/$/(W==="mean"?v:1),[B]:g.tileX+(Y+$/2)*v,[S]:g.tileX+Y*v,[R]:g.tileX+Q*v,[w]:X,[T]:N})}else V+=y[F],X>y[F]&&(X=y[F]),N{let M=0,F=Number.MIN_SAFE_INTEGER,$=Number.MAX_SAFE_INTEGER,Q=Number.MAX_SAFE_INTEGER,U=Number.MIN_SAFE_INTEGER;Array.from(Array(G).keys()).forEach((j,ee)=>{if(p===1){const Ie=v[G*x+ee]/(N==="mean"?B:1);b.push({[S]:Y,[R]:Ie,[w]:g.tileX+(ee+.5)*B,[T]:g.tileX+ee*B,[W]:g.tileX+(ee+1)*B,[V]:Ie,[X]:Ie})}else if(ee%p===0)M=Q=U=v[G*x+ee],F=ee,$=ee+p;else if(ee%p===p-1)b.push({[S]:Y,[R]:N==="mean"?M/p/B:M,[w]:g.tileX+(F+p/2)*B,[T]:g.tileX+F*B,[W]:g.tileX+$*B,[V]:Q,[X]:U});else if(ee===G-1){const Ie=G%p,fe=F+Ie;b.push({[S]:Y,[R]:N==="mean"?M/Ie/B:M,[w]:g.tileX+(F+Ie/2)*B,[T]:g.tileX+F*B,[W]:g.tileX+fe*B,[V]:Q,[X]:U})}else{const Ie=v[G*x+ee];M+=Ie,Q>Ie&&(Q=Ie),U"u"||typeof g.tileHeight>"u")return;const p=Math.sqrt(g.dense.length),{tileX:y,tileY:Z,tileWidth:v,tileHeight:G}=g,B=g.dense,S=v/p,R=G/p,w=(f=e.data.column)!=null?f:"x",T=(m=e.data.row)!=null?m:"y",W=16;for(let V=0;V{const{chrOffset:B,fields:S}=v,R={};if(R[ONg]=`${G}`,p.forEach(w=>{R[w.name]=+S[w.index]+B}),Z?.forEach(w=>{R[w.name]=w.type==="quantitative"?+S[w.index]:S[w.index]}),b.push({...R,type:"gene"}),y){const[w,T]=y,W=S[w.index].split(","),V=S[T.index].split(",");W.forEach((X,N)=>{const Y=V[N];if(b.push({...R,[w.name]:+X+B,[T.name]:+Y+B,type:"exon"}),N+1I===e.chromosome))){if(aSt(e))return[i[e.chromosome][0]+1,i[e.chromosome][1]];if(sSt(e))return e.interval;if(ASt(e)){const n=i[e.chromosome][0],[I,r]=e.interval;return[n+I,n+r]}}}function $Ng(e,g){const i={},n=z0;e.forEach(I=>{n.forEach(r=>{const o=I.spec()[r];if(!pt(o)||o.domain===void 0)return;const{domain:C,type:a}=o;if(a==="quantitative"){const A=Array.from(C);if(!i[r])i[r]=A;else{const s=i[r];s[0]>A[0]&&(s[0]=A[0]),s[1]{n.forEach(r=>{const o=I.spec()[r];pt(o)&&o.type==="genomic"||(I.setChannelDomain(r,i[r],g),I.generateScales())}),I.updateChannelValue()})}const qNg={compactLayout:!1,trackSourceServers:["https://server.gosling-lang.org/api/v1/"],views:[{genomePositionSearchBoxVisible:!1,genomePositionSearchBox:{autocompleteServer:"https://higlass.io/api/v1",autocompleteId:"P0PLbQMwTYGy-5uPIQid7A",chromInfoServer:"https://higlass.io/api/v1",chromInfoId:"hg38"},layout:{x:0,y:0,w:6.4,h:600},tracks:{top:[],left:[{type:"combined",width:130,height:600,contents:[{type:"gosling-track",server:"https://server.gosling-lang.org/api/v1/",tilesetUid:"cistrome-multivec",width:130,height:600,options:{showMousePosition:!0,mousePositionColor:"#000000",fontSize:24,labelPosition:"none",labelShowResolution:!1,labelColor:"black",labelBackgroundColor:"white",labelTextOpacity:1,labelLeftMargin:1,labelTopMargin:1,labelRightMargin:0,labelBottomMargin:0,backgroundColor:"transparent",spec:{spacing:10,orientation:"vertical",assembly:"hg38",layout:"linear",static:!1,xDomain:{interval:[0,1e9]},centerRadius:.3,xOffset:0,yOffset:0,style:{outlineWidth:.5},data:{url:"https://server.gosling-lang.org/api/v1/tileset_info/?d=cistrome-multivec",type:"multivec",row:"sample",column:"position",value:"peak",categories:["sample 1","sample 2","sample 3","sample 4"],binSize:4},mark:"rect",x:{field:"start",type:"genomic",axis:"left",domain:{interval:[0,1e9]},linkingId:"7f94b74e-25ec-4e67-8c75-3dc0f1b0d6bd"},xe:{field:"end",type:"genomic"},row:{field:"sample",type:"nominal",legend:!0},color:{field:"peak",type:"quantitative",legend:!0},tooltip:[{field:"start",type:"genomic",alt:"Start Position"},{field:"end",type:"genomic",alt:"End Position"},{field:"peak",type:"quantitative",alt:"Value",format:".2"},{field:"sample",type:"nominal",alt:"Sample"}],width:160,height:600,overlayOnPreviousTrack:!1},theme:{base:"light",root:{background:"white",titleColor:"black",titleBackgroundColor:"transparent",titleFontSize:18,titleFontFamily:"Arial",titleAlign:"left",titleFontWeight:"bold",subtitleColor:"gray",subtitleBackgroundColor:"transparent",subtitleFontSize:16,subtitleFontFamily:"Arial",subtitleFontWeight:"normal",subtitleAlign:"left",mousePositionColor:"#000000"},track:{background:"transparent",alternatingBackground:"transparent",titleColor:"black",titleBackground:"white",titleFontSize:24,titleAlign:"left",outline:"black",outlineWidth:1},legend:{position:"top",background:"white",backgroundOpacity:.7,labelColor:"black",labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",backgroundStroke:"#DBDBDB",tickColor:"black"},axis:{tickColor:"black",labelColor:"black",labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",baselineColor:"black",gridColor:"#E3E3E3",gridStrokeWidth:1,gridStrokeType:"solid",gridStrokeDash:[4,4]},markCommon:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},point:{color:"#E79F00",size:3,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},rect:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},triangle:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},area:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},line:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},bar:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},rule:{color:"#E79F00",size:1,stroke:"black",strokeWidth:1,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},link:{color:"#E79F00",size:1,stroke:"black",strokeWidth:1,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},text:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6],textAnchor:"middle",textFontWeight:"normal"},brush:{color:"gray",size:1,stroke:"black",strokeWidth:1,opacity:.3,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]}}}}]},{uid:"15483511-f6fb-11eb-914b-976b6ecda162",type:"axis-track",chromInfoPath:"https://s3.amazonaws.com/gosling-lang.org/data/hg38.chrom.sizes",options:{layout:"linear",outerRadius:null,width:160,height:600,theme:{base:"light",root:{background:"white",titleColor:"black",titleBackgroundColor:"transparent",titleFontSize:18,titleFontFamily:"Arial",titleAlign:"left",titleFontWeight:"bold",subtitleColor:"gray",subtitleBackgroundColor:"transparent",subtitleFontSize:16,subtitleFontFamily:"Arial",subtitleFontWeight:"normal",subtitleAlign:"left",mousePositionColor:"#000000"},track:{background:"transparent",alternatingBackground:"transparent",titleColor:"black",titleBackground:"white",titleFontSize:24,titleAlign:"left",outline:"black",outlineWidth:1},legend:{position:"top",background:"white",backgroundOpacity:.7,labelColor:"black",labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",backgroundStroke:"#DBDBDB",tickColor:"black"},axis:{tickColor:"black",labelColor:"black",labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",baselineColor:"black",gridColor:"#E3E3E3",gridStrokeWidth:1,gridStrokeType:"solid",gridStrokeDash:[4,4]},markCommon:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},point:{color:"#E79F00",size:3,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},rect:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},triangle:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},area:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},line:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},bar:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},rule:{color:"#E79F00",size:1,stroke:"black",strokeWidth:1,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},link:{color:"#E79F00",size:1,stroke:"black",strokeWidth:1,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},text:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6],textAnchor:"middle",textFontWeight:"normal"},brush:{color:"gray",size:1,stroke:"black",strokeWidth:1,opacity:.3,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]}},assembly:"hg38",stroke:"transparent",color:"black",fontSize:12,fontFamily:"Arial",fontWeight:"normal",tickColor:"black",tickFormat:"plain",tickPositions:"even",reverseOrientation:!1},width:30}],center:[],right:[],bottom:[],gallery:[],whole:[]},initialXDomain:[0,1e9],initialYDomain:[0,1e9],zoomFixed:!1,zoomLimits:[1,null],uid:"15483510-f6fb-11eb-914b-976b6ecda162",chromInfoPath:"https://s3.amazonaws.com/gosling-lang.org/data/hg38.chrom.sizes"},{genomePositionSearchBoxVisible:!1,genomePositionSearchBox:{autocompleteServer:"https://higlass.io/api/v1",autocompleteId:"P0PLbQMwTYGy-5uPIQid7A",chromInfoServer:"https://higlass.io/api/v1",chromInfoId:"hg38"},layout:{x:6.8,y:0,w:5.2,h:600},tracks:{top:[],left:[{type:"combined",width:130,height:600,contents:[{type:"gosling-track",server:"https://server.gosling-lang.org/api/v1/",tilesetUid:"cistrome-multivec",width:130,height:600,options:{showMousePosition:!0,mousePositionColor:"#000000",fontSize:24,labelPosition:"none",labelShowResolution:!1,labelColor:"black",labelBackgroundColor:"white",labelTextOpacity:1,labelLeftMargin:1,labelTopMargin:1,labelRightMargin:0,labelBottomMargin:0,backgroundColor:"transparent",spec:{spacing:10,orientation:"vertical",assembly:"hg38",layout:"linear",static:!1,xDomain:{interval:[0,1e9]},centerRadius:.3,xOffset:0,yOffset:0,style:{outlineWidth:.5},data:{url:"https://server.gosling-lang.org/api/v1/tileset_info/?d=cistrome-multivec",type:"multivec",row:"sample",column:"position",value:"peak",categories:["sample 1","sample 2","sample 3","sample 4"],binSize:4},mark:"rect",x:{field:"start",type:"genomic",domain:{interval:[0,1e9]},linkingId:"7f94b74e-25ec-4e67-8c75-3dc0f1b0d6bd"},xe:{field:"end",type:"genomic"},row:{field:"sample",type:"nominal",legend:!0},color:{field:"peak",type:"quantitative",legend:!0},tooltip:[{field:"start",type:"genomic",alt:"Start Position"},{field:"end",type:"genomic",alt:"End Position"},{field:"peak",type:"quantitative",alt:"Value",format:".2"},{field:"sample",type:"nominal",alt:"Sample"}],width:130,height:600},theme:{base:"light",root:{background:"white",titleColor:"black",titleBackgroundColor:"transparent",titleFontSize:18,titleFontFamily:"Arial",titleAlign:"left",titleFontWeight:"bold",subtitleColor:"gray",subtitleBackgroundColor:"transparent",subtitleFontSize:16,subtitleFontFamily:"Arial",subtitleFontWeight:"normal",subtitleAlign:"left",mousePositionColor:"#000000"},track:{background:"transparent",alternatingBackground:"transparent",titleColor:"black",titleBackground:"white",titleFontSize:24,titleAlign:"left",outline:"black",outlineWidth:1},legend:{position:"top",background:"white",backgroundOpacity:.7,labelColor:"black",labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",backgroundStroke:"#DBDBDB",tickColor:"black"},axis:{tickColor:"black",labelColor:"black",labelFontSize:12,labelFontWeight:"normal",labelFontFamily:"Arial",baselineColor:"black",gridColor:"#E3E3E3",gridStrokeWidth:1,gridStrokeType:"solid",gridStrokeDash:[4,4]},markCommon:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},point:{color:"#E79F00",size:3,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},rect:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},triangle:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},area:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},line:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},bar:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},rule:{color:"#E79F00",size:1,stroke:"black",strokeWidth:1,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},link:{color:"#E79F00",size:1,stroke:"black",strokeWidth:1,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]},text:{color:"#E79F00",size:1,stroke:"black",strokeWidth:0,opacity:1,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6],textAnchor:"middle",textFontWeight:"normal"},brush:{color:"gray",size:1,stroke:"black",strokeWidth:1,opacity:.3,nominalColorRange:["#E79F00","#029F73","#0072B2","#CB7AA7","#D45E00","#57B4E9","#EFE441"],quantitativeSizeRange:[2,6]}}}}]}],center:[],right:[],bottom:[],gallery:[],whole:[]},initialXDomain:[0,1e9],initialYDomain:[0,1e9],zoomFixed:!1,zoomLimits:[1,null],uid:"154b1b40-f6fb-11eb-914b-976b6ecda162"}],zoomLocks:{locksByViewUid:{},locksDict:{}},locationLocks:{locksByViewUid:{},locksDict:{}},editable:!1,chromInfoPath:"https://s3.amazonaws.com/gosling-lang.org/data/hg38.chrom.sizes"},es=30,ekg=e=>({genomePositionSearchBoxVisible:!1,genomePositionSearchBox:qVt(e),layout:{w:12,h:12,x:0,y:0},tracks:{top:[],left:[],center:[],right:[],bottom:[],gallery:[],whole:[]},initialXDomain:[0,In(e).total],initialYDomain:[0,In(e).total],zoomFixed:!1});class tkg{constructor(){at(this,"assembly"),at(this,"orientation"),at(this,"hg"),this.assembly="hg38",this.hg={compactLayout:!1,trackSourceServers:[],views:[],zoomLocks:{locksByViewUid:{},locksDict:{}},locationLocks:{locksByViewUid:{},locksDict:{}}},this.setEditable(!1)}spec(){return this.hg}setViewOrientation(g){return this.orientation=g,this}addDefaultView(g,i){return this.hg.views.push(JSON.parse(JSON.stringify({...ekg(i),uid:g}))),this}setAssembly(g){return this.assembly=g,this.setChromInfoPath(In(this.assembly).path),this}getAssembly(){return this.assembly}setTextTrack(g,i,n,I="black",r=14,o="normal",C="left",a="transparent",A="Arial"){var s;return this.getLastView()&&((s=this.getLastView().tracks.top)==null||s.push({type:"text",width:g,height:i,options:{backgroundColor:a,textColor:I,fontSize:r,fontWeight:o,fontFamily:A,offsetY:0,align:C,text:n}})),this}setDummyTrack(g){var i;return this.getLastView()&&((i=this.getLastView().tracks.top)==null||i.push({type:"dummy-track",width:g.width,height:g.height,options:{width:g.width,height:g.height,title:g.title,...g.style}})),this}addBrush(g,i,n,I,r){var o,C,a,A,s,l;if(I)return(l=this.getView(i))==null||l.tracks.whole.push({type:g==="circular"?"brush-track":"viewport-projection-horizontal",uid:sr(),fromViewUid:I,options:{projectionFillColor:(o=r?.color)!=null?o:n.brush.color,projectionStrokeColor:(C=r?.stroke)!=null?C:n.brush.stroke,projectionFillOpacity:(a=r?.opacity)!=null?a:n.brush.opacity,projectionStrokeOpacity:(A=r?.opacity)!=null?A:n.brush.opacity,strokeWidth:(s=r?.strokeWidth)!=null?s:n.brush.strokeWidth,startAngle:r?.startAngle,endAngle:r?.endAngle,innerRadius:r?.innerRadius,outerRadius:r?.outerRadius}}),this}getLastView(){return this.hg.views[this.hg.views.length-1]}getMainTrackPosition(){return this.orientation==="vertical"?"left":"center"}getLastVisView(){const g=this.hg.views.filter(i=>{var n,I;return((I=(n=i.tracks[this.getMainTrackPosition()])==null?void 0:n[0])==null?void 0:I.type)==="combined"});return g[g.length-1]}getView(g){return this.hg.views.find(i=>i.uid===g)}validateSpec(g=!1){return Z8e(jNg,this.spec(),g).state==="success"}setDomain(g,i){return g&&(this.getLastView().initialXDomain=yie(g,this.getAssembly())),i&&(this.getLastView().initialYDomain=yie(i,this.getAssembly())),this}adjustDomain(g="horizontal",i,n){if(g!=="vertical")return this;const I=this.getLastView().initialXDomain;if(!I)return this;const[r,o]=I,C=o-r,a=(r+o)/2;return this.getLastView().initialXDomain=[a-C/i/2/n*i,a+C/i/2/n*i],this}setZoomFixed(g){return this.getLastView().zoomFixed=g,this}setZoomLimits(g){return this.getLastView().zoomLimits=g,this}setLayout(g){return this.getLastView().layout=g,this}setEditable(g){return this.hg.editable=g,this}setChromInfoPath(g){return this.getLastView()&&(this.getLastView().chromInfoPath=g),this.hg.chromInfoPath=g,this}addTrackSourceServers(g){var i,n;return g&&((i=this.hg.trackSourceServers)==null?void 0:i.indexOf(g))===-1&&((n=this.hg.trackSourceServers)==null||n.push(g)),this}setMainTrack(g){var i;return this.getLastView()?(this.getLastView().tracks[this.getMainTrackPosition()]=[{type:"combined",uid:`${(i=g.uid)!=null?i:sr()}-${this.getMainTrackPosition()}-combined`,width:g.width-1,height:g.height,contents:[g]}],this):this}addTrackToCombined(g){var i;return this.getLastVisView()?((i=this.getLastVisView().tracks[this.getMainTrackPosition()][0])==null||i.contents.push(g),this):this}setAxisTrack(g,i="regular",n){if(!this.hg.views)return this;const I=g==="left"||g==="right"?"width":"height",r={type:"axis-track",chromInfoPath:this.hg.chromInfoPath,options:{...n,assembly:this.getAssembly(),stroke:"transparent",color:n.theme.axis.labelColor,labelMargin:n.theme.axis.labelMargin,excludeChrPrefix:n.theme.axis.labelExcludeChrPrefix,fontSize:n.theme.axis.labelFontSize,fontFamily:n.theme.axis.labelFontFamily,fontWeight:n.theme.axis.labelFontWeight,tickColor:n.theme.axis.tickColor,tickFormat:i==="narrower"?"si":"plain",tickPositions:i==="regular"?"even":"ends",reverseOrientation:g==="bottom"||g==="right"}};if(n.layout==="circular")this.addTrackToCombined({...r,options:{...r.options,layout:"circular"}});else{const o={...r,[I]:es};if(g==="left"){if(this.getLastView().tracks.left.filter(C=>C.type==="axis-track").length!==0)return this;this.getLastView().tracks.left=F1t(this.getLastView().tracks.left,0,o)}else if(g==="right"){if(this.getLastView().tracks.right.filter(C=>C.type==="axis-track").length!==0)return this;this.getLastView().tracks.right.push(o)}else{if(this.getLastView().tracks[g].filter(C=>C.type==="axis-track").length!==0)return this;this.getLastView().tracks[g].push(o)}}return this}setExampleHiglassViewConfig(){this.hg=qNg}}function t2(e,g,i,n){const I=n&&n!==0?n:void 0;let r=0;switch(g){case"less-than":case"LT":case"lt":r=i>e?I?(i-e)/I:1:0;break;case"less-than-or-equal-to":case"LTET":case"ltet":r=i>=e?I?(i-e)/I:1:0;break;case"greater-than":case"GT":case"gt":r=i{e[i]&&i!=="base"&&(g[i]=Object.assign(JSON.parse(JSON.stringify(g[i])),JSON.parse(JSON.stringify(e[i]))))}),g}}class ikg{constructor(g,i,n){at(this,"id"),at(this,"theme"),at(this,"specOriginal"),at(this,"specComplete"),at(this,"dataAggregated"),at(this,"channelScales"),at(this,"mouseEventModel"),this.id=sr(),this.theme=n??C6e(),this.dataAggregated=i,this.specOriginal=g,this.specComplete=JSON.parse(JSON.stringify(g)),this.channelScales={},this.mouseEventModel=new ITg;const I=this.validateSpec();if(!I.valid){console.warn("Gosling specification is not valid!",I.errorMessages);return}this.generateCompleteSpec(this.specComplete),this.flipRanges(this.specComplete),this.generateScales(),this.dataAggregated=FNg(this.spec(),this.dataAggregated)}getId(){return this.id}originalSpec(){return this.specOriginal}spec(){return this.specComplete}data(){return this.dataAggregated}getMouseEventModel(){return this.mouseEventModel}generateCompleteSpec(g){if(!g.width||!g.height){console.warn("Size of track is not determined yet.");return}if(g.orientation==="vertical"){const I=g.width;g.width=g.height,g.height=I}const i=this.getGenomicChannelKey();let n=!1;i==="x"&&(n=pt(g.x)&&g.x.axis!==void 0&&g.x.axis!=="none"),i==="y"&&(n=pt(g.y)&&g.y.axis!==void 0&&g.y.axis!=="none"),g.layout!=="circular"?pt(g.x)&&g.x.axis!==void 0&&g.x.axis!=="none"&&(g.height-=es):i==="x"&&n&&pt(g.x)&&g.x.axis==="top"?g.outerRadius=g.outerRadius-es:i==="x"&&n&&pt(g.x)&&g.x.axis==="bottom"&&(g.innerRadius=g.innerRadius+es),z0.forEach(I=>{const r=g[I];pt(r)&&!("zeroBaseline"in r)&&r.type==="quantitative"&&(r.zeroBaseline=!0)}),this.addScaleMaterials(g)}flipRanges(g){pt(g.y)&&g.y.flip&&Array.isArray(g.y.range)&&(g.y.range=g.y.range.reverse())}getGenomicChannelKey(){return v8e(this.spec())}getGenomicChannel(){return Yle(this.spec())}setChannelDomain(g,i,n){const I=this.originalSpec()[g];if(!n&&pt(I)&&I.domain!==void 0)return;const r=this.specComplete[g];pt(r)&&(r.domain=i)}updateChannelValue(){if(this.originalSpec().y===void 0){const g=this.spec().y,i=this.getChannelDomainArray("row");g&&YK(g)&&i&&this.spec().mark!=="withinLink"&&(g.value=this.spec().height/i.length/2)}}encodedValue(g,i){var n;if(g==="text"&&i!==void 0)return`${+i?~~i:i}`;const I=this.spec()[g],r=pt(I)?I.type:YK(I)?"constant":void 0;if(r){if(r==="constant")return this.channelScales[g]();if(i!==void 0&&(i===null&&(r==="quantitative"?i=0:r==="nominal"&&(i="null")),typeof this.channelScales[g]=="function"))switch(g){case"x":case"y":case"x1":case"y1":case"xe":case"ye":case"x1e":if(r==="quantitative"||r==="genomic")return this.channelScales[g](i);if(r==="nominal")return this.channelScales[g](i);break;case"stroke":case"color":if(r==="quantitative"){const o=this.channelScales[g].copy(),C=o.domain(),a=C[1]-C[0],A=Array.from((n=I.scaleOffset)!=null?n:[0,1]);return o.domain([C[0]+a*A.sort()[0],C[0]+a*A.sort()[1]])(i)}if(r==="nominal")return this.channelScales[g](i);break;case"size":if(r==="quantitative")return this.channelScales[g](i);if(r==="nominal")return this.channelScales[g](i);break;case"row":if(r==="nominal")return this.channelScales[g](i);break;case"strokeWidth":case"opacity":if(r==="quantitative")return this.channelScales[g](i);break;default:console.warn(`${g} is not supported for encoding values, so returning a undefined value`);return}}}trackVisibility(g){const i=this.spec();if(!i.visibility||i.visibility.length===0||i.visibility.filter(I=>I.target==="track").length===0)return!0;let n=!0;return i.visibility.filter(I=>I.target==="track").forEach(I=>{const{operation:r,measure:o,threshold:C}=I;let a;o==="zoomLevel"?a=g[o]:a=i[o],a!==void 0&&(n=n&&t2(a,r,C)===1)}),n}markVisibility(g,i){const n=this.spec();if(!n.visibility||n.visibility.length===0||n.visibility.filter(r=>r.target==="mark").length===0)return 1;let I=1;return n.visibility.filter(r=>r.target==="mark").forEach(r=>{const{operation:o,threshold:C,conditionPadding:a,transitionPadding:A,measure:s}=r,l=a??0,c=n.mark;let u=1;if(c==="text"&&C==="|xe-x|"&&s==="width"){const d=this.encodedPIXIProperty("xe",g),h=this.encodedPIXIProperty("x",g);d!==void 0&&i?.width&&(u=t2(i.width+l,o,Math.abs(d-h),A))}else s==="width"&&typeof C=="number"&&i?.width?u=t2(i.width+l,o,C,A):s==="zoomLevel"&&typeof C=="number"&&i?.zoomLevel&&(u=t2(i.zoomLevel,o,C,A));I>u&&(I=u)}),I}visualPropertyByChannel(g,i){const n=i!==void 0?tn(i,this.spec()[g]):void 0;return this.encodedValue(g,n)}encodedPIXIProperty(g,i,n){const I=this.spec().mark;if(["text","color","row","stroke","opacity","strokeWidth","x","y","xe","x1","x1e","ye","size"].includes(g))return this.visualPropertyByChannel(g,i);switch(I){case"bar":return X1t(this,g,i,n);case"point":case"text":return R1t(this,g,i);case"rect":return N1t(this,g,i,n);default:return}}addScaleMaterials(g){const i=this.data(),n=this.getGenomicChannel();if(!n||!n.field){console.warn("Genomic field is not provided in the specification");return}if(typeof g.width>"u"||typeof g.height>"u"){console.warn("Track size is not determined yet");return}z0.forEach(I=>{var r,o,C,a;const A=g[I];if(pSt(g,I)&&pt(A)){const s=oz(i,c=>c[n.field]),l=[...s.keys()];if(!A.domain){const c="zeroBaseline"in A&&A.zeroBaseline?0:HK(l.map(d=>sZe(s.get(d).map(h=>A.field?h[A.field]:void 0)))),u=F2(l.map(d=>sZe(s.get(d).map(h=>A.field?h[A.field]:void 0))));A.domain=[c,u]}if(!A.range){const c=g.row,u=pt(c)?c.field:void 0,d=(r=this.getChannelDomainArray("row"))!=null?r:u?Array.from(new Set(i.map(f=>f[u]))):[1],h=g.height/d.length;switch(I){case"x":A.range=[0,g.width];break;case"y":A.range=[0,h];break}}}else{const s=g.row,l=pt(s)?s.field:void 0,c=(o=this.getChannelDomainArray("row"))!=null?o:l?Array.from(new Set(i.map(d=>d[l]))):[1],u=g.height/c.length;if(A){if(pt(A)&&(A.type==="quantitative"||A.type==="genomic")){if(A.domain===void 0){const d="zeroBaseline"in A&&A.zeroBaseline?0:(C=HK(i.map(f=>+f[A.field])))!=null?C:0,h=(a=F2(i.map(f=>+f[A.field])))!=null?a:0;A.domain=[d,h]}else A.type==="genomic"&&!tGe(A.domain)&&(A.domain=yie(A.domain));if((I==="color"||I==="stroke")&&A.type==="quantitative"&&!A.scaleOffset&&(A.scaleOffset=[0,1]),!A.range){let d;switch(I){case"x":case"xe":case"x1":case"x1e":d=[0,g.width];break;case"y":case"ye":d=[0,u];break;case"color":case"stroke":d=gkg.QUANTITATIVE_COLOR;break;case"size":d=this.theme.markCommon.quantitativeSizeRange;break;case"strokeWidth":d=[1,3];break;case"opacity":d=[0,1];break}d&&(A.range=d)}}else if(pt(A)&&A.type==="nominal"&&(A.domain===void 0&&(A.domain=Array.from(new Set(i.map(d=>{var h;return(h=d[A.field])!=null?h:"null"})))),!A.range)){let d=2,h;switch(I){case"x":case"xe":h=[0,g.width];break;case"y":case"ye":h=[u,0];break;case"color":case"stroke":h=this.theme.markCommon.nominalColorRange;break;case"row":h=[0,g.height];break;case"size":h=A.domain.map(()=>d++);break}h&&(A.range=h)}}else{let d;switch(I){case"x":d=g.width/2;break;case"y":g.mark==="withinLink"?d=u:d=u/2;break;case"size":g.mark==="line"?d=this.theme.line.size:g.mark==="bar"||g.mark==="rect"||g.mark==="triangleRight"||g.mark==="triangleLeft"||g.mark==="triangleBottom"||g.stretch&&g.mark==="point"&&pt(g.x)&&pt(g.xe)?d=void 0:g.mark==="text"?d=12:d=this.theme.point.size;break;case"color":d=this.theme.markCommon.color;break;case"row":d=0;break;case"stroke":g.mark==="text"?d=this.theme.text.stroke:d=this.theme.markCommon.stroke;break;case"strokeWidth":g.mark==="rule"?d=this.theme.rule.strokeWidth:g.mark==="withinLink"||g.mark==="betweenLink"?d=this.theme.link.strokeWidth:g.mark==="text"?d=this.theme.text.strokeWidth:d=this.theme.markCommon.strokeWidth;break;case"opacity":d=this.theme.markCommon.opacity;break;case"text":d="";break}typeof d<"u"&&(g[I]={value:d})}}}),[["x","xe"],["y","ye"]].forEach(I=>{const[r,o]=I,C=g[r],a=g[o];if(pt(C)&&pt(a)&&C.type===a.type&&C.domain&&a.domain&&Array.isArray(C.domain)&&Array.isArray(a.domain)){if(C.type==="genomic"||C.type==="quantitative"){const A=HK([C.domain[0],a.domain[0]]),s=F2([C.domain[1],a.domain[1]]);C.domain=a.domain=[A,s]}else if(C.type==="nominal"){const A=Array.from(new Set([...C.domain,...a.domain]));C.range=a.range=A}}})}generateScales(){const g=this.spec();z0.forEach(i=>{const n=g[i];if(YK(n))this.channelScales[i]=()=>n.value;else if(pt(n)){if(i==="text")return;const I=n.domain,r=n.range;if(I===void 0||r===void 0)return;if(n.type==="quantitative"||n.type==="genomic")switch(i){case"x":case"x1":case"xe":case"x1e":case"y":case"ye":case"size":case"opacity":case"strokeWidth":this.channelScales[i]=vb().domain(I).range(r);break;case"color":case"stroke":let o=VDe;Object.keys($x).includes(r)&&(o=$x[r]),this.channelScales[i]=OEe(o).domain(I);break}else if(n.type==="nominal")switch(i){case"x":case"xe":case"y":case"ye":case"row":this.channelScales[i]=FEe().domain(I).range(r);break;case"size":this.channelScales[i]=_x().domain(I).range(r);break;case"color":case"stroke":this.channelScales[i]=_x(r).domain(I);break}}})}getChannelScale(g){return this.channelScales[g]}setChannelScale(g,i){this.channelScales[g]=i}isShowYAxis(){const g=this.spec(),i=this.getChannelDomainArray("y"),n=this.getChannelRangeArray("y");return pt(g.y)&&g.y.axis!=="none"&&g.y.type==="quantitative"&&!!i&&!!n}getChannelDomainArray(g){const i=this.spec()[g];return pt(i)&&tGe(i.domain)?i.domain:void 0}getChannelRangeArray(g){const i=this.spec()[g];return pt(i)&&mSt(i.range)?i.range:void 0}validateSpec(){return G8e(this.originalSpec())}}function Fa(e,g){bCe.publish(e,g)}function nkg(e,g){bCe.subscribe(e,g)}function Ikg(e){bCe.unsubscribe(e)}const p9e={stroke:"black",strokeWidth:1,strokeOpacity:1,color:"none",opacity:1,arrange:"front"};function rkg(){return{goslingModels:[],tabularData:[],skipRendering:!1}}const okg={type:"gosling-track",datatype:["multivec","epilogos"],orientation:"1d-horizontal",defaultOptions:{theme:qV("light")}},Ckg=(e,g,i)=>{var n,I,r,o,C,a,A,s,l,c,u,d,h,f,m,b,p,y,Z,v,G,B,S,R,w,T,W,V,X,N,Y,x,M,F,$,Q,U,j;const{tileProxy:ee}=e.services,{TiledPixiTrack:Ie}=e.tracks,fe=Td({color:"black",size:12}),Ve=class Zie extends Ie{constructor(){var ae,ie,ye,ue,Ye,Be;super(g,i),Vg(this,h),Vg(this,m),Vg(this,p),Vg(this,Z),Vg(this,G),Vg(this,S),Vg(this,w),Vg(this,W),Vg(this,X),Vg(this,Y),Vg(this,M),Vg(this,$),Vg(this,U),at(this,"tileSize"),at(this,"mRangeBrush"),Vg(this,n,void 0),Vg(this,I,void 0),at(this,"firstDraw",!0),at(this,"gLegend",e.libraries.d3Selection.select(g.svgElement).append("g")),at(this,"displayedLegends",[]),at(this,"textGraphics",[]),at(this,"textsBeingUsed",0),at(this,"pMouseHover",new e.libraries.PIXI.Graphics),at(this,"pMouseSelection",new e.libraries.PIXI.Graphics),Vg(this,r,0),Vg(this,o,0),Vg(this,C,!1),Vg(this,a,e.libraries.d3Selection.select(g.svgElement).append("g")),Vg(this,A,new e.libraries.PIXI.TextStyle(fe)),Vg(this,s,new e.libraries.PIXI.Graphics),Vg(this,l,new e.libraries.PIXI.Text("",fe)),at(this,"prevVisibleAndFetchedTiles"),at(this,"resolvedTracks"),Vg(this,c,new WeakMap),at(this,"hideMousePosition");const{isShowGlobalMousePosition:ke}=g;g.dataFetcher.track=this,ho(this,I,{}),ho(this,n,this.options.spec.assembly),"overlay"in this.options.spec?this.options.spec.overlay=this.options.spec._overlay.map(it=>({...it,_renderingId:sr()})):this.options.spec._renderingId=sr(),this.fetchedTiles={},this.tileSize=(ie=(ae=this.tilesetInfo)==null?void 0:ae.tile_size)!=null?ie:1024;const{valid:_e,errorMessages:Pe}=G8e(this.options.spec);_e||console.warn("The specification of the following track is invalid",Pe,this.options.spec),this.pMain.addChild(this.pMouseHover),this.pMain.addChild(this.pMouseSelection),this.pMask.interactive=!0,this.mRangeBrush=new $9g(Ut(this,a),e.libraries,(ye=this.options.spec.style)==null?void 0:ye.brush),this.mRangeBrush.on("brush",Mi(this,X,N).bind(this)),this.pMask.on("mousedown",it=>{const{x:lt,y:je}=it.data.getLocalPosition(this.pMain);Mi(this,p,y).call(this,lt,je,it.data.originalEvent.altKey)}),this.pMask.on("mouseup",it=>{const{x:lt,y:je}=it.data.getLocalPosition(this.pMain);Mi(this,G,B).call(this,lt,je)}),this.pMask.on("mousemove",it=>{const{x:lt}=it.data.getLocalPosition(this.pMain);Mi(this,Z,v).call(this,lt)}),this.pMask.on("mouseout",Mi(this,S,R).bind(this)),this.flipText=this.options.spec.orientation==="vertical",(ue=this.options)!=null&&ue.showMousePosition&&!this.hideMousePosition&&(this.hideMousePosition=e.utils.showMousePosition(this,Pr(this.getResolvedTracks()[0]),ke())),this.pLabel.removeChild(this.trackNotFoundText),Ut(this,l).anchor.x=1,Ut(this,l).anchor.y=1,this.pLabel.addChild(Ut(this,s)),this.pLabel.addChild(Ut(this,l)),e.libraries.PIXI.GRAPHICS_CURVES.adaptive=(Be=(Ye=this.options.spec.style)==null?void 0:Ye.enableSmoothPath)!=null?Be:!1,e.libraries.PIXI.GRAPHICS_CURVES.adaptive&&(e.libraries.PIXI.GRAPHICS_CURVES.maxLength=1,e.libraries.PIXI.GRAPHICS_CURVES.maxSegments=2048*10)}draw(){var ae,ie;this.clearMouseEventData(),this.textsBeingUsed=0,(ae=this.pMouseHover)==null||ae.clear();const ye=()=>{const ue=this.dataFetcher instanceof zD;this.processAllTiles(ue),super.draw(),Object.values(this.fetchedTiles).forEach(Ye=>{Ye.drawnAtScale&&([Ye.graphics.scale.x,Ye.graphics.position.x]=this.getXScaleAndOffset(Ye.drawnAtScale))}),this.prevVisibleAndFetchedTiles=this.visibleAndFetchedTiles()};lk(this.dataFetcher)&&!vDe(this.visibleAndFetchedTiles(),this.prevVisibleAndFetchedTiles)?this.updateTileAsync(this.dataFetcher,ye):ye(),(ie=this.mRangeBrush)==null||ie.drawBrush(!0),this.firstDraw&&(Mi(this,M,F).call(this),this.firstDraw=!1)}getXScaleAndOffset(ae){const ie=ae.domain(),ye=this._xScale.domain(),ue=(ie[1]-ie[0])/(ye[1]-ye[0]),Be=this._xScale.domain().map(ae)[0];return[ue,-Be*ue]}initTile(ae){this.drawTile(ae)}updateTile(){}renderTile(){}drawTile(ae){var ie,ye;const ue=Ut(this,I)[ae.tileId];if(!ue)return;ae.drawnAtScale||(ae.drawnAtScale=this._xScale.copy());const[Ye,Be]=this.getXScaleAndOffset(ae.drawnAtScale),ke=Ye===1;if(!Mi(this,U,j).call(this,Ye)&&Mi(this,$,Q).call(this)&&!ke){ae.graphics.scale.x=Ye,ae.graphics.position.x=Be;return}ae.drawnAtScale=this._xScale.copy(),(ie=ae.graphics)==null||ie.clear(),(ye=ae.graphics)==null||ye.removeChildren(),this.pBackground.clear(),this.pBackground.removeChildren(),this.pBorder.clear(),this.pBorder.removeChildren().forEach(Pe=>Pe.destroy()),this.displayedLegends=[],ue.goslingModels.forEach(Pe=>{const it=this.dimensions[0],lt=this._xScale.invert(it)-this._xScale.invert(0);Pe.trackVisibility({zoomLevel:lt})&&(tSt(e,this,ae,Pe,this.options.theme),eSt(e,this,ae,Pe),gSt(e,this,ae,Pe,this.options.theme))}),this.forceDraw()}rerender(ae){this.options=ae,this.options.spec.layout==="circular"&&this.mRangeBrush.remove(),this.getResolvedTracks(!0),this.clearMouseEventData(),this.textsBeingUsed=0,ho(this,c,new WeakMap),this.processAllTiles(!0),this.draw(),this.forceDraw()}clearMouseEventData(){this.visibleAndFetchedGoslingModels().forEach(ae=>ae.getMouseEventModel().clear())}visibleAndFetchedGoslingModels(){return this.visibleAndFetchedTiles().flatMap(ae=>{var ie,ye;return(ye=(ie=Ut(this,I)[ae.tileId])==null?void 0:ie.goslingModels)!=null?ye:[]})}remove(){super.remove(),this.gLegend&&(this.gLegend.remove(),this.gLegend=void 0),this.mRangeBrush.remove()}setDimensions(ae){super.setDimensions(ae),this.mRangeBrush.setSize(ae[1])}setPosition(ae){super.setPosition(ae),[this.pMain.position.x,this.pMain.position.y]=this.position,[this.pMouseOver.position.x,this.pMouseOver.position.y]=this.position,this.mRangeBrush.setOffset(...ae)}forceDraw(){this.animate()}zoomed(ae,ie){const ye=this.mRangeBrush.getRange();this.mRangeBrush.updateRange(ye?[ae(this._xScale.invert(ye[0])),ae(this._xScale.invert(ye[1]))]:null),this.xScale(ae),this.yScale(ie),this.refreshTiles(),this.draw(),this.forceDraw();const ue=ae.domain().map(Ye=>EZ(Ye,Ut(this,n),!0));Fa("location",{id:g.viewUid,genomicRange:ue})}setMask(ae,ie){if(this.pMask.clear(),this.pMask.beginFill(),this.options.spec.layout==="circular"&&this.options.spec.overlayOnPreviousTrack){const[ye,ue]=this.position,[Ye,Be]=this.dimensions,ke=ye+Ye/2,_e=ue+Be/2,Pe=this.options.spec.outerRadius;this.pMask.drawCircle(ke,_e,Pe)}else this.pMask.drawRect(ae[0],ae[1],ie[0],ie[1]);this.pMask.endFill()}processAllTiles(ae=!1){var ie,ye;this.tileSize=(ye=(ie=this.tilesetInfo)==null?void 0:ie.tile_size)!=null?ye:1024;const ue=this.visibleAndFetchedTiles();if(ue.every(ke=>Ut(this,c).get(ke)!==void 0))return;ue.forEach(ke=>Mi(this,m,b).call(this,ke,ae)),this.combineAllTilesIfNeeded();const Ye=ue.flatMap(ke=>this.transformDataAndCreateModels(ke));$Ng(Ye);const Be=[].concat(...Ye.map(ke=>ke.data()));Be.length!==0&&this.options.siblingIds.forEach(ke=>Fa("rawData",{id:ke,data:Be})),ue.forEach(ke=>{Ut(this,c).set(ke,!0)})}async updateTileAsync(ae,ie){if(!this.tilesetInfo)return;const ye=this.visibleAndFetchedTiles(),ue=await ae.getTabularData(Object.values(ye).map(Be=>Be.remoteId)),Ye=this.tilesetInfo;ye.forEach((Be,ke)=>{if(ke===0){const[_e]=e.utils.trackUtils.calculate1DVisibleTiles(Ye,this._xScale);Be.tileData.zoomLevel=_e[0],Be.tileData.tilePos=[_e[1],_e[1]],Be.tileData.tabularData=ue}else Be.tileData.tabularData=[]}),ie()}calculateVisibleTiles(){var ae,ie,ye,ue,Ye;if(this.tilesetInfo)if(lk(this.dataFetcher)){const Be=e.utils.trackUtils.calculate1DVisibleTiles(this.tilesetInfo,this._xScale),ke=(ie=(ae=this.tilesetInfo.max_tile_width)!=null?ae:this.dataFetcher.MAX_TILE_WIDTH)!=null?ie:Number.MAX_SAFE_INTEGER;for(const _e of Be){const{tileWidth:Pe}=this.getTilePosAndDimensions(_e[0],[_e[1],_e[1]]);if(this.forceDraw(),Pe>ke)return}this.setVisibleTiles(Be)}else{if(!this.tilesetInfo)return;const Be=this.calculateZoomLevel();if("resolutions"in this.tilesetInfo){const ke=this.tilesetInfo.resolutions.map(lt=>+lt).sort((lt,je)=>je-lt),_e=ee.calculateTilesFromResolution(ke[Be],this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]);let Pe;Pr(this.getResolvedTracks()[0])&&(Pe=ee.calculateTilesFromResolution(ke[Be],this._yScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0]));const it=Mi(ye=Zie,u,d).call(ye,_e,Pe,Be);this.setVisibleTiles(it)}else{const ke=ee.calculateTiles(Be,this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.max_zoom,this.tilesetInfo.max_width);let _e;Pr(this.getResolvedTracks()[0])&&(_e=ee.calculateTiles(Be,this._yScale,this.tilesetInfo.min_pos[1],this.tilesetInfo.max_pos[1],this.tilesetInfo.max_zoom,(ue=this.tilesetInfo.max_width1)!=null?ue:this.tilesetInfo.max_width));const Pe=Mi(Ye=Zie,u,d).call(Ye,ke,_e,Be);this.setVisibleTiles(Pe)}}}calculateZoomLevel(){if(!this.tilesetInfo)throw Error("tilesetInfo not parsed");if("resolutions"in this.tilesetInfo)return ee.calculateZoomLevelFromResolutions(this.tilesetInfo.resolutions,this._xScale);const ae=ee.calculateZoomLevel(this._xScale,this.tilesetInfo.min_pos[0],this.tilesetInfo.max_pos[0],this.tilesetInfo.bins_per_dimension||this.tilesetInfo.tile_size);let ie=Math.min(ae,this.maxZoom);return ie=Math.max(ie,0),ie}getTilePosAndDimensions(ae,ie){if(!this.tilesetInfo)throw Error("tilesetInfo not parsed");if("resolutions"in this.tilesetInfo){const ue=this.tilesetInfo.resolutions.map(lt=>+lt).sort((lt,je)=>je-lt)[ae],[Ye,Be]=ie,ke=ue*Ut(this,h,f),_e=ke,Pe=ke*Ye,it=_e*Be;return{tileX:Pe,tileY:it,tileWidth:ke,tileHeight:_e}}else{const[ye,ue]=ie,Ye=this.tilesetInfo.min_pos[0],Be=this.tilesetInfo.min_pos[1],ke=this.tilesetInfo.max_width/2**ae,_e=this.tilesetInfo.max_width/2**ae,Pe=Ye+ye*ke,it=Be+ue*_e;return{tileX:Pe,tileY:it,tileWidth:ke,tileHeight:_e}}}getIndicesOfVisibleDataInTile(ae){const ie=this._xScale.range();if(!this.tilesetInfo||!ae.tileData.tilePos||!("dense"in ae.tileData))return[0,0];const{tileX:ye,tileWidth:ue}=this.getTilePosAndDimensions(ae.tileData.zoomLevel,ae.tileData.tilePos),Ye=e.libraries.d3Scale.scaleLinear().domain([0,Ut(this,h,f)]).range([ye,ye+ue]),Be=Math.max(0,Math.round(Ye.invert(this._xScale.invert(ie[0])))),ke=Math.min(ae.tileData.dense.length,Math.round(Ye.invert(this._xScale.invert(ie[1]))));return[Be,ke]}receivedTiles(ae){super.receivedTiles(ae),lk(this.dataFetcher)&&this.drawLoadingCue()}removeOldTiles(){super.removeOldTiles(),lk(this.dataFetcher)&&this.drawLoadingCue()}combineAllTilesIfNeeded(){var ae,ie,ye;if(!this.shouldCombineTiles())return;const ue=this.visibleAndFetchedTiles();if(!ue||ue.length<=1)return;this.tileSize=((ie=(ae=this.tilesetInfo)==null?void 0:ae.tile_size)!=null?ie:1024)*ue.length;let Ye=[];ue.forEach((ke,_e)=>{const Pe=Ut(this,I)[ke.tileId];Pe&&(Ye=[...Ye,...Pe.tabularData],Pe.skipRendering=_e!==0)});const Be=Ut(this,I)[ue[0].tileId];Be.tabularData=Ye,(ye=Be.tabularData[0])!=null&&ye.uid&&(Be.tabularData=Mwt(Be.tabularData,"uid"))}shouldCombineTiles(){const ae=nSt(this.options.spec,"displace"),ie=()=>{const ue=this.visibleAndFetchedTiles();return ue.length>=1&&"dense"in ue[0].tileData},ye=this.dataFetcher instanceof zD;return ae&&!ie()&&!ye}tileToLocalId(ae){return`${ae.join(".")}`}tileToRemoteId(ae){return`${ae.join(".")}`}getResolvedTracks(ae=!1){if(ae||!this.resolvedTracks){const ie=structuredClone(this.options.spec),ye=S1(ie).filter(ue=>ue.mark!=="brush");ye.forEach(ue=>{"values"in ue.data&&(ue.data.values=[])}),this.resolvedTracks=ye}return this.resolvedTracks}transformDataAndCreateModels(ae){const ie=Ut(this,I)[ae.tileId];return!ie||ie.skipRendering?[]:(ie.goslingModels=[],this.getResolvedTracks().forEach(ue=>{var Ye;let Be=Array.from(ie.tabularData);(Ye=ue.dataTransform)==null||Ye.forEach(Ce=>{switch(Ce.type){case"filter":Be=t6e(Ce,Be);break;case"concat":Be=WNg(Ce,Be);break;case"replace":Be=XNg(Ce,Be);break;case"log":Be=TNg(Ce,Be);break;case"exonSplit":Be=KNg(Ce,Be,ue.assembly);break;case"genomicLength":Be=HNg(Ce,Be);break;case"svType":Be=NNg(Ce,Be);break;case"coverage":Be=kNg(Ce,Be,this._xScale.copy());break;case"subjson":Be=xNg(Ce,Be);break;case"displace":Be=YNg(Ce,Be,this._xScale.copy());break}});try{if(PubSub){const Ze=Be.length;PubSub.publish("data-preview",{id:g.viewUid,dataConfig:JSON.stringify({data:ue.data}),data:100>Ze?Be:Uoe(Be,100)})}}catch{}const[ke,_e]=this.dimensions,Pe=qx(ue)&&this.options.spec.layout==="linear"?es:0,[it,lt]=[ke,_e+Pe],je=Math.min(it,lt)/Math.min(ue.width,ue.height);ue.innerRadius&&(ue.innerRadius=ue.innerRadius*je),ue.outerRadius&&(ue.outerRadius=ue.outerRadius*je),ue.width=it,ue.height=lt;const He=new ikg(ue,Be,this.options.theme);ie.goslingModels.push(He)}),ie.goslingModels)}mouseMoveZoomHandler(){}getMouseOverHtml(ae,ie){var ye,ue,Ye,Be,ke;if(Mi(this,W,V).call(this,"trackMouseOver",ae,ie),Ut(this,C)||!this.tilesetInfo)return"";this.pMouseHover.clear();const _e=EZ(Math.floor(this._xScale.invert(ae)),Ut(this,n)),Pe=Mi(this,w,T).call(this,ae,ie);if(Pe.length!==0?document.body.style.cursor="pointer":document.body.style.cursor="default",Pe.length!==0){const it=(ye=this.options.spec.experimental)==null?void 0:ye.mouseEvents;if(!!it||FZ(it)&&!!it.mouseOver){const Ce=this.pMouseHover;((Ye=(ue=this.options.spec.style)==null?void 0:ue.mouseOver)==null?void 0:Ye.arrange)!=="behind"&&(this.pMain.removeChild(Ce),this.pMain.addChild(Ce)),Mi(this,Y,x).call(this,Ce,Pe,Object.assign({},p9e,(Be=this.options.spec.style)==null?void 0:Be.mouseOver)),Fa("mouseOver",{id:g.viewUid,genomicPosition:_e,data:Pe.map(Ze=>Ze.value)})}const He=(ke=this.visibleAndFetchedGoslingModels().find(Ce=>{var Ze;return Ce.spec().tooltip&&((Ze=Ce.spec().tooltip)==null?void 0:Ze.length)!==0}))==null?void 0:ke.spec().tooltip;if(He){let Ce=He.map(Ze=>{var Te;const E=Pe[0].value[Ze.field];let H=E;if(Ze.type==="quantitative"&&Ze.format)H=e.libraries.d3Format.format(Ze.format)(+E);else if(Ze.type==="genomic"){const{chromosome:K,position:te}=EZ(+E,Ut(this,n));H=`${K}:${e.libraries.d3Format.format(",")(te)}`}return`${(Te=Ze.alt)!=null?Te:Ze.field}${H}`}).join("");return Ce=`${Ce}
`,Pe.length>1&&(Ce+=`
${Pe.length-1} Additional Selections...
`),`
${Ce}
`}}return""}minVisibleValue(){return 0}maxVisibleValue(){return 0}exportSVG(){throw new Error("exportSVG() not supported for gosling-track")}drawLoadingCue(){if(this.fetching.size){const ie=`Fetching... ${Array.from(this.fetching).join(" ")}`;Ut(this,l).text=ie,Ut(this,l).x=this.position[0]+this.dimensions[0]-6/2,Ut(this,l).y=this.position[1]+this.dimensions[1]-6/2;const ye=e.libraries.PIXI.TextMetrics.measureText(ie,Ut(this,A)),{width:ue,height:Ye}=ye;Ut(this,s).clear(),Ut(this,s).lineStyle(1,St("grey"),1,.5),Ut(this,s).beginFill(St("white"),.8),Ut(this,s).drawRect(this.position[0]+this.dimensions[0]-ue-6-1,this.position[1]+this.dimensions[1]-Ye-6-1,ue+6,Ye+6),Ut(this,l).visible=!0,Ut(this,s).visible=!0}else Ut(this,l).visible=!1,Ut(this,s).visible=!1}updateScaleOffsetFromOriginalSpec(ae,ie,ye){this.getResolvedTracks().map(ue=>{if(ue._renderingId===ae){const Ye=ue[ye];pt(Ye)&&(Ye.scaleOffset=ie)}})}shareScaleOffsetAcrossTracksAndTiles(ae,ie){this.visibleAndFetchedGoslingModels().forEach(ue=>{const Ye=ue.spec()[ie];pt(Ye)&&(Ye.scaleOffset=ae);const Be=ue.originalSpec()[ie];pt(Be)&&(Be.scaleOffset=ae)})}};n=new WeakMap,I=new WeakMap,r=new WeakMap,o=new WeakMap,C=new WeakMap,a=new WeakMap,A=new WeakMap,s=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakSet,d=function(pe,ae,ie){if(!ae)return pe.map(ue=>[ie,ue]);const ye=[];return pe.forEach(ue=>ae.forEach(Ye=>ye.push([ie,ue,Ye]))),ye},h=new WeakSet,f=function(){let pe;return this.tilesetInfo&&(pe="bins_per_dimension"in this.tilesetInfo?this.tilesetInfo.bins_per_dimension:this.tilesetInfo.tile_size),pe??256},m=new WeakSet,b=function(pe,ae=!1){if(Ut(this,I)[pe.tileId]&&!ae||!pe.tileData.tilePos)return;const ie=rkg(),ye=this.getResolvedTracks();if(ye.length===0)return[];const ue=ye[0];if("tabularData"in pe.tileData)ie.tabularData=pe.tileData.tabularData;else{const{tileX:Ye,tileY:Be,tileWidth:ke,tileHeight:_e}=this.getTilePosAndDimensions(pe.tileData.zoomLevel,pe.tileData.tilePos),Pe="length"in pe.tileData?Array.from(pe.tileData):[],it=Object.assign({},pe.tileData,{sparse:Pe,tileX:Ye,tileY:Be,tileWidth:ke,tileHeight:_e,tileSize:this.tileSize}),lt=JNg(ue,it);lt&&(ie.tabularData=lt)}Ut(this,I)[pe.tileId]=ie},p=new WeakSet,y=function(pe,ae,ie){var ye;ho(this,r,pe),ho(this,o,ae);const ue=(ye=this.options.spec.experimental)==null?void 0:ye.mouseEvents,Ye=!!ue||FZ(ue)&&!!ue.rangeSelect;ho(this,C,Ye&&ie),this.pMouseHover.clear()},Z=new WeakSet,v=function(pe){this.options.spec.layout!=="circular"&&Ut(this,C)&&this.mRangeBrush.updateRange([pe,Ut(this,r)]).drawBrush().visible().disable()},G=new WeakSet,B=function(pe,ae){var ie;Mi(this,W,V).call(this,"trackClick",pe,ae);const ye=(ie=this.options.spec.experimental)==null?void 0:ie.mouseEvents,ue=!!ye||FZ(ye)&&!!ye.click,Ye=Math.sqrt((Ut(this,r)-pe)**2+(Ut(this,o)-ae)**2)>1;if(!Ut(this,C)&&!Ye?(this.mRangeBrush.clear(),this.pMouseSelection.clear()):this.mRangeBrush.enable(),ho(this,C,!1),!!this.tilesetInfo&&!Ye&&ue){const Be=EZ(Math.floor(this._xScale.invert(pe)),Ut(this,n)),ke=Mi(this,w,T).call(this,pe,ae);ke.length!==0&&this.options.siblingIds.forEach(_e=>Fa("click",{id:_e,genomicPosition:Be,data:ke.map(Pe=>Pe.value)}))}},S=new WeakSet,R=function(){ho(this,C,!1),document.body.style.cursor="default",this.pMouseHover.clear()},w=new WeakSet,T=function(pe,ae){var ie;const ye=this.visibleAndFetchedGoslingModels(),ue=(ie=this.options.spec.experimental)==null?void 0:ie.mouseEvents,Ye=FZ(ue)&&ue.enableMouseOverOnMultipleMarks,Be=FZ(ue)&&ue.groupMarksByField,ke=ye.map(_e=>_e.getMouseEventModel().findAll(pe,ae,!0)).flat();if(Ye||ke.splice(1,ke.length-1),ke.length!==0&&Be){const _e=Array.from(ke);ye.forEach(Pe=>{const it=Pe.getMouseEventModel().getSiblings(_e,Be);ke.push(...it)})}return ke},W=new WeakSet,V=function(pe,ae,ie){const[ye,ue]=this.position,[Ye,Be]=this.dimensions;if(this.options.spec.layout==="circular"){const ke=ye+Ye/2,_e=ue+Be/2,Pe=this.options.spec.innerRadius,it=this.options.spec.outerRadius,lt=this.options.spec.startAngle,je=this.options.spec.endAngle;q9g([ae,ie],[Ye/2,Be/2],[Pe,it],[lt,je])&&Fa(pe,{id:g.viewUid,spec:structuredClone(this.options.spec),shape:{x:ye,y:ue,width:Ye,height:Be,cx:ke,cy:_e,innerRadius:Pe,outerRadius:it,startAngle:lt,endAngle:je}})}else Fa(pe,{id:g.viewUid,spec:structuredClone(this.options.spec),shape:{x:ye,y:ue,width:Ye,height:Be}})},X=new WeakSet,N=function(pe,ae=!1){var ie,ye,ue,Ye;if(this.pMouseSelection.clear(),pe===null){ae||Fa("rangeSelect",{id:g.viewUid,genomicRange:null,data:[]});return}const Be=this.visibleAndFetchedGoslingModels(),[ke,_e]=pe;let Pe=Be.map(je=>je.getMouseEventModel().findAllWithinRange(ke,_e,!0)).flat();const it=(ie=this.options.spec.experimental)==null?void 0:ie.mouseEvents,lt=FZ(it)&&it.groupMarksByField;if(Pe.length!==0&<&&Be.forEach(je=>{const He=je.getMouseEventModel().getSiblings(Pe,lt),Ce=Array.from(new Set(He.map(Ze=>Ze.value[lt])));Pe=Pe.filter(Ze=>Ce.indexOf(Ze.value[lt])===-1)}),Pe.length!==0){const je=this.pMouseSelection;((ue=(ye=this.options.spec.style)==null?void 0:ye.select)==null?void 0:ue.arrange)!=="behind"&&(this.pMain.removeChild(je),this.pMain.addChild(je)),Mi(this,Y,x).call(this,je,Pe,Object.assign({},p9e,(Ye=this.options.spec.style)==null?void 0:Ye.select))}if(!ae){const je=[EZ(Math.floor(this._xScale.invert(ke)),Ut(this,n)),EZ(Math.floor(this._xScale.invert(_e)),Ut(this,n))];Fa("rangeSelect",{id:g.viewUid,genomicRange:je,data:Pe.map(He=>He.value)})}this.forceDraw()},Y=new WeakSet,x=function(pe,ae,ie){pe.lineStyle(ie.strokeWidth,St(ie.stroke),ie.strokeOpacity,.5),pe.beginFill(St(ie.color),ie.color==="none"?0:ie.opacity),ae.forEach(ye=>{if(ye.type==="point"){const[ue,Ye,Be=3]=ye.polygon;pe.drawCircle(ue,Ye,Be)}else ye.type==="line"?(pe.moveTo(ye.polygon[0],ye.polygon[1]),E1t(ye.polygon).map(ue=>pe.lineTo(ue[0],ue[1]))):pe.drawPolygon(ye.polygon)})},M=new WeakSet,F=function(){Fa("onNewTrack",{id:g.viewUid})},$=new WeakSet,Q=function(){var pe,ae;const ie=(pe=this.options.spec.experimental)==null?void 0:pe.stretchGraphics;if(ie===!0)return!0;if(ie===!1)return!1;const ye=!Pr(this.getResolvedTracks()[0]),ue=this.options.spec.layout!=="circular",Ye=["bar","line","rect","area"],Be=this.getResolvedTracks().reduce((_e,Pe)=>_e&&Ye.includes(Pe.mark),!0),ke=!((ae=this.options.spec.experimental)!=null&&ae.mouseEvents);return ye&&ue&&Be&&ke},U=new WeakSet,j=function(pe){var ae,ie;const ue=(ie=(ae=this.options.spec.experimental)==null?void 0:ae.stretchGraphicsThreshold)!=null?ie:1.5;return pe>ue||pe<1/ue},Vg(Ve,u);let oe=Ve;return new oe},RY=Kle(okg,Ckg),akg={type:"dummy-track",defaultOptions:{height:0,width:0,title:"",background:"#fff",textFontSize:12,textFontWeight:"normal",textStroke:"#000",textStrokeWidth:.1,outline:"#fff"}},skg=(e,g,i)=>{var n,I,r,o;const{SVGTrack:C}=e.tracks;class a extends C{constructor(){super(g,i),Vg(this,n),Vg(this,r),Mi(this,n,I).call(this),Mi(this,r,o).call(this),Fa("onNewTrack",{id:g.viewUid})}}return n=new WeakSet,I=function(){this.gMain.append("rect").attr("fill",i.background).attr("x",0).attr("y",0).attr("width",i.width).attr("height",i.height).style("stroke",i.outline)},r=new WeakSet,o=function(){this.gMain.append("text").attr("x",i.width/2).attr("y",(i.height+i.textFontSize)/2).style("text-anchor","middle").style("font-size",`${i.textFontSize}px`).style("font-weight",i.textFontWeight).style("stroke",i.textStroke).style("stroke-width",i.textStrokeWidth).text(i.title)},new a},b9e=Kle(akg,skg);let y9e=!1;function Akg(){if(!y9e){Zp({name:"GoslingTrack",track:RY,config:RY.config}),Zp({name:"Gosling2DTrack",track:RY,config:{...RY.config,type:"gosling-2d-track",orientation:"2d"}}),Zp({name:"AxisTrack",track:SXe,config:SXe.config}),Zp({name:"TextTrack",track:N6,config:N6.config}),Zp({name:"BrushTrack",track:lie,config:lie.config}),Zp({name:"DummyTrack",track:b9e,config:b9e.config});for(const e of Object.values(_Ng)){const{config:g}=e;Zp({dataFetcher:e,config:g},{pluginType:"dataFetcher"})}y9e=!0}}function a6e(e){let g=0,i=0;return e.forEach(n=>{const I=n.boundingBox.x+n.boundingBox.width,r=n.boundingBox.y+n.boundingBox.height;i{A.boundingBox.y+=C+a}),I=[{track:ckg({width:r.width,height:C},e.title,e.subtitle),boundingBox:{x:0,y:0,width:r.width,height:C},layout:{x:0,y:0,w:12,h:C/r.height*12}},...I]}else r.height=r.height+(8-r.height%8);const o=!(typeof e.responsiveSize!="object"?e.responsiveSize:e.responsiveSize.height);return I.forEach(C=>{C.layout.x=C.boundingBox.x/r.width*12,C.layout.w=C.boundingBox.width/r.width*12,C.layout.y=o?C.boundingBox.y:C.boundingBox.y/r.height*12,C.layout.h=o?C.boundingBox.height:C.boundingBox.height/r.height*12}),{trackInfos:I,size:r}}function Gie(e,g,i=0,n=0,I=!0){let r=0,o=0,C=!0,a=!1;FB(e,c=>{a=!0,c.layout!=="circular"&&(C=!1)});let A=!0;lMe(e,c=>{(c.arrangement==="vertical"||c.arrangement==="horizontal")&&(A=!1)});const s=I&&C&&a&&A&&("views"in e&&(e.arrangement==="parallel"||e.arrangement==="serial")||"tracks"in e),l=g.length;if("tracks"in e){const c=e.tracks;e.orientation==="vertical"?(o=Math.max(...c.map(u=>u.height)),c.forEach((u,d,h)=>{G9e([u])===1&&(u.width+=es),u.height=o,g.push({track:u,boundingBox:{x:i+r,y:n,width:u.width,height:o},layout:{x:0,y:0,w:0,h:0}}),h[d+1]&&h[d+1].overlayOnPreviousTrack||(r+=u.width,d!==h.length-1&&(r+=e.spacing!==void 0?e.spacing:0))})):(r=Math.max(...c.map(u=>u.width)),c.forEach((u,d,h)=>{G9e([u])===1&&(u.height+=es);const f=S1(u);f.length>0&&Pr(f[0])&&lkg([u])===1&&(r+=es),u.width=r,g.push({track:u,boundingBox:{x:i,y:n+o,width:r,height:u.height},layout:{x:0,y:0,w:0,h:0}}),h[d+1]&&h[d+1].overlayOnPreviousTrack||(o+=u.height,d!==h.length-1&&(o+=e.spacing!==void 0?e.spacing:0))}))}else if(e.arrangement==="parallel"||e.arrangement==="vertical"){const c=e.spacing!==void 0?e.spacing:kK;e.views.forEach((u,d,h)=>{var f,m,b,p,y;const Z=Gie(u,g,i+((f=u.xOffset)!=null?f:0),n+((m=u.yOffset)!=null?m:0)+o,!s&&I);r<((b=u.xOffset)!=null?b:0)+Z.width&&(r=((p=u.xOffset)!=null?p:0)+Z.width),d!==h.length-1&&(o+=c),o+=((y=u.yOffset)!=null?y:0)+Z.height})}else(e.arrangement==="serial"||e.arrangement==="horizontal")&&e.views.forEach((c,u,d)=>{var h,f,m,b,p;const y=e.spacing!==void 0?e.spacing:kK,Z=Gie(c,g,i+((h=c.xOffset)!=null?h:0)+r,n+((f=c.yOffset)!=null?f:0),!s&&I);o<((m=c.xOffset)!=null?m:0)+Z.height&&(o=((b=c.xOffset)!=null?b:0)+Z.height),u!==d.length-1&&(r+=y),r+=((p=c.xOffset)!=null?p:0)+Z.width});if(s){const c=g.slice(l),u="views"in e&&(e.arrangement==="parallel"||e.arrangement==="serial")&&e.views.length>1,d=e.spacing!==void 0?e.spacing:kK,h=v1t,f=e.centerRadius!==void 0?e.centerRadius:TDe,m=r/2+h,b=m*(1-f);c.forEach((p,y)=>{var Z,v;if(dT(p.track))return;p.track.layout="circular",p.track.outerRadius=m-h-(p.boundingBox.y-n)/o*b,p.track.innerRadius=m-h-(p.boundingBox.y+p.boundingBox.height-n)/o*b;const G=d/r*360;p.track.startAngle=G+(p.boundingBox.x-i)/r*(r-d)/r*360,p.track.endAngle=(p.boundingBox.x+p.boundingBox.width-i)/r*(r-d)/r*360,p.boundingBox.x=i+((Z=p.track.xOffset)!=null?Z:0),p.boundingBox.y=n+((v=p.track.yOffset)!=null?v:0),p.boundingBox.height=p.track.height=p.boundingBox.width=p.track.width=m*2,y!==0&&(p.track.overlayOnPreviousTrack=!0),u&&eI(p.track)&&(p.track._overlay=p.track._overlay.filter(B=>B.mark!=="brush"))}),o=m*2}return e._assignedWidth=r,e._assignedHeight=o,{x:i,y:n,width:r,height:o}}function G9e(e){return e.filter(g=>qx(g)).length}function lkg(e){return e.filter(g=>ySt(g)).length}const ckg=(e,g,i)=>JSON.parse(JSON.stringify({mark:"header",width:e.width,height:e.height,title:g,subtitle:i}));function ukg(e){if(!e.includes("tileset_info/?d=")||!e.includes("https:")&&!e.includes("http:"))return{server:void 0,tilesetUid:void 0};const g=e.split("tileset_info/?d=")[0],i=e.split("tileset_info/?d=")[1];return{server:g,tilesetUid:i}}function dkg(e,g,i,n,I,r,o){var C,a,A,s,l,c,u,d,h,f,m,b,p,y,Z;if(dT(g))return e.addDefaultView(g.id).setDummyTrack(g).setLayout(n),e;const v=S1(g),G=v[0],B=(C=G.id)!=null?C:sr();G.id||(G.id=B),v.forEach(R=>{R.id&&r.addMapping(R.id,B)});const S=G.assembly;if(eGe(G.data)){let R,w;if(eCe(G.data)){const $=ukg(G.data.url);R=$.server,w=$.tilesetUid}const T=Yle(G),W=v8e(G),X=(W==="x"||W==="xe")&&pt(T)?T.domain:void 0,N=Pr(G)&&pt(G.y)?G.y.domain:void 0,Y=i.width-(G.layout!=="circular"&&G.orientation==="vertical"&&qx(G)?es:0),x=i.height-(G.layout!=="circular"&&G.orientation==="horizontal"&&qx(G)?es:0),M={uid:`${B}-track`,type:Pr(G)?"gosling-2d-track":"gosling-track",server:R,tilesetUid:w,width:Y,height:x,options:{id:B,siblingIds:r.getSiblingGoslingIds(B),showMousePosition:G.layout==="circular"?!1:I.root.showMousePosition,mousePositionColor:I.root.mousePositionColor,name:G.layout==="linear"?G.title:" ",labelPosition:G.title?I.track.titleAlign==="left"?"topLeft":"topRight":"none",labelShowResolution:!1,labelColor:I.track.titleColor,labelBackgroundColor:I.track.titleBackground,labelBackgroundOpacity:.5,labelTextOpacity:1,labelLeftMargin:1,labelTopMargin:1,labelRightMargin:0,labelBottomMargin:0,backgroundColor:"transparent",spec:{...g},theme:I}};if(G.data&&eGe(G.data)&&(G.data.type==="csv"||G.data.type==="json"||G.data.type==="bigwig"||G.data.type==="bam"||G.data.type==="vcf"||G.data.type==="gff"||G.data.type==="bed")){const $=ee=>{const Ie=G[ee];return Ie&&pt(Ie)?Ie.field:void 0},Q={x:$("x"),xe:$("xe"),x1:$("x1"),x1e:$("x1e")},U="url"in G.data&&o?.[G.data.url]||{},j="indexUrl"in G.data&&o?.[G.data.indexUrl]||{};M.data={...G.data,...Q,urlFetchOptions:U,indexUrlFetchOptions:j,assembly:S}}if(uSt(G)){M.type="heatmap";const $=pt(G.color)&&typeof G.color.range=="string"?G.color.range:"viridis";M.options.colorRange=ISt($),M.options.trackBorderWidth=(A=(a=G.style)==null?void 0:a.outlineWidth)!=null?A:I.track.outlineWidth,M.options.trackBorderColor=(l=(s=G.style)==null?void 0:s.outline)!=null?l:I.track.outline,M.options.extent=(u=(c=G.style)==null?void 0:c.matrixExtent)!=null?u:"full",M.options.colorbarPosition=(d=G.color)!=null&&d.legend?M.options.extent==="lower-left"?"bottomLeft":"topRight":"hidden"}G.overlayOnPreviousTrack?e.setViewOrientation(G.orientation).addTrackToCombined(M):e.setViewOrientation(G.orientation).setAssembly(S).addDefaultView(B,S).setDomain(X,N??X).adjustDomain(G.orientation,Y,x).setMainTrack(M).addTrackSourceServers(R).setZoomFixed(G.static===!0).setZoomLimits((h=G.zoomLimits)!=null?h:[1,null]).setLayout(n);const F=($,Q="horizontal",U,j)=>Q==="horizontal"?$==="x"&&U<=200||$==="y"&&j<=200?"narrower":$==="x"&&U<=400||$==="y"&&j<=400?"narrow":"regular":$==="x"&&j<=200||$==="y"&&U<=200?"narrower":$==="x"&&j<=400||$==="y"&&U<=400?"narrow":"regular";["x","y"].forEach($=>{const Q=G[$];if(pt(Q)&&"axis"in Q&&Q.axis&&Q.axis!=="none"&&Q.type==="genomic"){const U=F($,g.orientation,i.width,i.height);e.setAxisTrack(Q.axis,U,{id:`${B}-${Q.axis}-axis`,layout:G.layout,innerRadius:Q.axis==="top"?G.outerRadius-es:G.innerRadius,outerRadius:Q.axis==="top"?G.outerRadius:G.innerRadius+es,width:G.width,height:G.height,startAngle:G.startAngle,endAngle:G.endAngle,theme:I})}}),e.validateSpec(!0)}else G.mark==="header"&&(e.addDefaultView(`${B}-title`).setLayout(n),typeof G.title=="string"&&e.setTextTrack(i.width,((f=I.root.titleFontSize)!=null?f:18)+jx,G.title,I.root.titleColor,(m=I.root.titleFontSize)!=null?m:18,I.root.titleFontWeight,I.root.titleAlign,I.root.titleBackgroundColor,(b=I.root.titleFontFamily)!=null?b:b6.fontFamily),typeof G.subtitle=="string"&&e.setTextTrack(i.width,((p=I.root.subtitleFontSize)!=null?p:14)+jx,G.subtitle,I.root.subtitleColor,(y=I.root.subtitleFontSize)!=null?y:14,I.root.subtitleFontWeight,I.root.subtitleAlign,I.root.subtitleBackgroundColor,(Z=I.root.subtitleFontFamily)!=null?Z:b6.fontFamily));return e}function hkg(e){const g=[];return e.spec().views.forEach(i=>{var n,I,r,o,C,a,A,s,l,c,u,d,h,f,m;const b=i.uid;let p=(C=(o=(r=(I=(n=i.tracks.center)==null?void 0:n[0])==null?void 0:I.contents)==null?void 0:r[0])==null?void 0:o.options)==null?void 0:C.spec;if(p||(p=(c=(l=(s=(A=(a=i.tracks.left)==null?void 0:a[0])==null?void 0:A.contents)==null?void 0:s[0])==null?void 0:l.options)==null?void 0:c.spec,p||(p=(m=(f=(h=(d=(u=i.tracks.left)==null?void 0:u[1])==null?void 0:d.contents)==null?void 0:h[0])==null?void 0:f.options)==null?void 0:m.spec)),!b||!p)return;S1(p).forEach(Z=>{z0.forEach(v=>{var G,B,S,R;const w=Z[v];if(pt(w)&&"linkingId"in w&&w.linkingId){g.push({layout:Z.layout==="circular"?"circular":"linear",hgViewId:b,linkId:w.linkingId,isBrush:Z.mark==="brush",style:{color:(G=Z.color)==null?void 0:G.value,stroke:(B=Z.stroke)==null?void 0:B.value,strokeWidth:(S=Z.strokeWidth)==null?void 0:S.value,opacity:(R=Z.opacity)==null?void 0:R.value,startAngle:Z.startAngle,endAngle:Z.endAngle,innerRadius:Z.innerRadius,outerRadius:Z.outerRadius}});return}})})}),g}class fkg{constructor(){Vg(this,Ru,{})}addMapping(g,i){Ut(this,Ru)[g]&&Ut(this,Ru)[g]!==i&&console.warn(`The track ID ${g} already exists but overwriting with a different ID.`),Ut(this,Ru)[g]=i}getTable(){return Ut(this,Ru)}getGoslingIds(){return Object.keys(Ut(this,Ru))}getHiGlassId(g){return Ut(this,Ru)[g]}getSiblingGoslingIds(g){return Object.entries(Ut(this,Ru)).filter(([,i])=>i===g).map(([i])=>i)}}Ru=new WeakMap;function mkg(e){const g=new Set;return e.id&&g.add(e.id),FB(e,i=>{("views"in i||"tracks"in i)&&i.id&&g.add(i.id)}),Array.from(g)}function pkg(e){const g=new Set;return FB(e,i=>{!("views"in i)&&!("tracks"in i)&&i.id&&g.add(i.id)}),Array.from(g)}function bkg(e,g){let i;return e.id===g&&(i=e),FB(e,n=>{n.id===g&&(i=n)}),i}function ykg(e,g){return mkg(e).map(i=>{const n=bkg(e,i),I=pkg(n),r={x:Number.MAX_SAFE_INTEGER,y:Number.MAX_SAFE_INTEGER,xe:-Number.MAX_SAFE_INTEGER,ye:-Number.MAX_SAFE_INTEGER};return I.map(o=>g.find(C=>C.id===o)).forEach(o=>{if(!o)return;const{shape:C}=o;r.x>C.x&&(r.x=C.x),r.y>C.y&&(r.y=C.y),r.xe{const{track:u,boundingBox:d,layout:h}=c;dkg(r,u,d,h,n,o,I)});const C=hkg(r);C.filter(c=>c.isBrush).forEach(c=>{var u;r.addBrush(c.layout,c.hgViewId,n,(u=C.find(d=>!d.isBrush&&d.linkId===c.linkId))==null?void 0:u.hgViewId,c.style)}),C.filter(c=>!c.isBrush).forEach(c=>{r.spec().zoomLocks.locksByViewUid[c.hgViewId]=c.linkId,r.spec().locationLocks.locksByViewUid[c.hgViewId]=c.linkId}),Array.from(new Set(C.map(c=>c.linkId))).forEach(c=>{r.spec().zoomLocks.locksDict[c]={uid:c},r.spec().locationLocks.locksDict[c]={uid:c},C.filter(u=>!u.isBrush).filter(u=>u.linkId===c).forEach(u=>{r.spec().zoomLocks.locksDict[c][u.hgViewId]=[1246253105e-1,1246253105e-1,249250.621],r.spec().locationLocks.locksDict[c][u.hgViewId]=[1246253105e-1,1246253105e-1,249250.621]})});const A=g.map(c=>({id:c.track.id,spec:c.track,shape:c.track.layout==="linear"||dT(c.track)?c.boundingBox:{...c.boundingBox,cx:c.boundingBox.x+c.boundingBox.width/2,cy:c.boundingBox.y+c.boundingBox.height/2,innerRadius:c.track.innerRadius,outerRadius:c.track.outerRadius,startAngle:c.track.startAngle,endAngle:c.track.endAngle}})),s=ykg(e,A),l=[...A.map(c=>({...c,type:"track"})),...s.map(c=>({...c,type:"view"}))];i(r.spec(),a6e(g),e,l,o.getTable())}function s6e(e,g,i,n,I){if(typeof e._assignedWidth>"u"||typeof e._assignedHeight>"u")return console.warn("Responsive spec cannot be used when width and height of a view is not determined yet."),!1;let r=!1;const{responsiveSpec:o}=e,C=e._assignedWidth*g,a=e._assignedHeight*i,A={width:C,height:a,aspectRatio:C/a},s={width:n,height:I,aspectRatio:n/I};return o&&o.forEach(l=>{const{spec:c,selectivity:u}=l;if(Gkg(u,A,s)&&!r){Object.keys(c).forEach(d=>{e[d]=c[d]}),delete e.responsiveSpec,r=!0;return}}),"views"in e&&e.views.forEach(l=>{r=s6e(l,g,i,n,I)||r}),r}function Gkg(e,g,i){if(e.length===0)return!1;let n=!0;return e.forEach(I=>{const{measure:r,operation:o,threshold:C,target:a}=I;n=n&&t2((a==="container"?i:g)[r],o,C)===1}),n}function vkg(e,g,i,n,I,r){var o,C;const a=JSON.parse(JSON.stringify(e));jVt(a),X9g(a,i),W6(a);const A=Z9e(a,n);let{trackInfos:s}=A;const{size:l}=A,c=typeof e.responsiveSize=="object"&&((o=e.responsiveSize)==null?void 0:o.width)||e.responsiveSize,u=typeof e.responsiveSize=="object"&&((C=e.responsiveSize)==null?void 0:C.height)||e.responsiveSize,d=c&&I.containerSize?I.containerSize.width/l.width:1,h=u&&I.containerSize?I.containerSize.height/l.height:1,f=I.containerParentSize?I.containerParentSize.width:Number.MAX_SAFE_INTEGER,m=I.containerParentSize?I.containerParentSize.height:Number.MAX_SAFE_INTEGER;s6e(a,d,h,f,m)&&(W6(a),s=Z9e(a,n).trackInfos),Fa("specProcessed",{id:a.id,spec:a}),Zkg(a,s,g,n,r)}Akg();const A6e=Ue.forwardRef((e,g)=>{var i;const[n,I]=Ue.useState((i=e.id)!=null?i:sr());Ue.useEffect(()=>{var u;I((u=e.id)!=null?u:sr())},[e.id]);const r=e.viewConfig||{},o=!1,C=Ue.useMemo(()=>k.createElement(CS,{ref:g,options:{pixelPreciseMarginPadding:o,containerPaddingX:0,containerPaddingY:0,viewMarginTop:0,viewMarginBottom:0,viewMarginLeft:0,viewMarginRight:0,viewPaddingTop:0,viewPaddingBottom:0,viewPaddingLeft:0,viewPaddingRight:0,sizeMode:"bounded",rangeSelectionOnAlt:!0},viewConfig:r}),[r,o]),{padding:a=60,margin:A=0,border:s="none",background:l,alt:c="Gosling visualization"}=e.options||{};return k.createElement(k.Fragment,null,k.createElement("div",{id:n,className:`gosling-component ${e.className||""}`,style:{position:"relative",padding:a,margin:A,border:s,background:l,width:e.options.responsiveWidth?`calc(100% - ${a*2}px)`:e.size.width,height:e.options.responsiveHeight?`calc(100% - ${a*2}px)`:e.size.height,textAlign:"left"},"aria-label":c,role:"graphics-document","aria-roledescription":"visualization"},k.createElement("div",{key:JSON.stringify(r),id:"higlass-wrapper",className:"higlass-wrapper",style:{position:"relative",display:"block",background:l,margin:0,padding:0,width:e.options.responsiveWidth?"100%":e.size.width,height:e.options.responsiveHeight?"100%":e.size.height}},C)))});A6e.displayName="HiGlassComponentWrapper";function Bkg(e,g,i,n,I){const r=structuredClone(I),o=d=>{const h=r[d];return h||console.warn(`Unable to find the track ID, named ${d}.`),h??d},C=()=>Object.keys(r),a=()=>[...i],A=()=>[...a().filter(d=>d.type==="track")],s=d=>{const h=A().find(f=>f.id===d);return h||console.warn(`[getTrack()] Unable to find a track using the ID (${d})`),h},l=()=>[...a().filter(d=>d.type==="view")],c=d=>{const h=l().find(f=>f.id===d);return h||console.warn(`Unable to find a view with the ID of ${d}`),h},u=d=>{var h,f;const m=(h=d?.resolution)!=null?h:4,b=(f=d?.transparentBackground)!=null?f:!1,p=e.pixiRenderer,y=Wd.create({width:p.width/2,height:p.height/2,resolution:m});p.render(e.pixiStage,y);const Z=p.plugins.extract.canvas(y),v=document.createElement("canvas");v.width=Z.width,v.height=Z.height;const G=v.getContext("2d");return b||(G.fillStyle=n.root.background,G.fillRect(0,0,v.width,v.height)),G.drawImage(Z,0,0),{canvas:v,resolution:m,canvasWidth:Z.width,canvasHeight:Z.height}};return{subscribe:nkg,unsubscribe:Ikg,zoomTo:(d,h,f=0,m=1e3)=>{var b;const p=(b=s(d))==null?void 0:b.spec.assembly,Z=sCe.fromString(h).toAbsoluteCoordinates(p,f),v=o(d);e.api.zoomTo(v,...Z,...Z,m)},zoomToExtent:(d,h=1e3)=>{var f;const m=(f=s(d))==null?void 0:f.spec.assembly,[b,p]=[0,In(m).total],y=o(d);e.api.zoomTo(y,b,p,b,p,h)},zoomToGene:(d,h,f=0,m=1e3)=>{const b=o(d);e.api.zoomToGene(b,h,f,m)},suggestGene:(d,h,f)=>{const m=o(d);e.api.suggestGene(m,h,f)},getTrackIds:C,getTracksAndViews:a,getTracks:A,getTrack:s,getView:c,getViews:l,getCanvas:u,exportPng:d=>{const{canvas:h}=u({resolution:4,transparentBackground:d});h.toBlob(f=>{const m=document.createElement("a");document.body.append(m),m.download="gosling-visualization",m.href=URL.createObjectURL(f),m.click(),m.remove()},"image/png")},exportPdf:async d=>{const{jsPDF:h}=await Pct(()=>import("./jspdf.es.min-fee19fbe.js").then(p=>p.j),[]),{canvas:f}=u({resolution:4,transparentBackground:d}),m=f.toDataURL("image/jpeg",1),b=new h({orientation:f.width{qoe(i)&&g.forEach(n=>{delete i[n]})})}const wkg=(e,g)=>{e.views.forEach(i=>{var n,I,r;const o=i.uid;if(!g.views.find(a=>a.uid===o)){const{locksByViewUid:a}=e.zoomLocks,A=a[o],s=(n=Object.entries(a).find(([c,u])=>c&&u===A))==null?void 0:n[0],l=!!g.views.find(c=>c.uid===s);s&&l&&(i.initialXDomain=(I=g.views.find(c=>c.uid===s))==null?void 0:I.initialXDomain,i.initialYDomain=(r=g.views.find(c=>c.uid===s))==null?void 0:r.initialYDomain)}})},Skg=300,tp=Ue.forwardRef((e,g)=>{var i,n,I;const[r,o]=Ue.useState(),[C,a]=Ue.useState(!0),[A,s]=Ue.useState({width:200,height:200}),l=Ue.useRef(),c=Ue.useRef(),u=Ue.useRef(),d=Ue.useRef([]),h=Ue.useRef({}),f=Ue.useRef(null),m=C6e(e.theme||"light"),b=(i=e.id)!=null?i:sr(),p=G=>{const B=d.current.filter(T=>T.type=="view"),S=G.filter(T=>T.type=="view"),R=new Set(B.map(T=>T.id));S.filter(T=>!R.has(T.id)).forEach(T=>{Fa("onNewView",{id:T.id})})};Ue.useImperativeHandle(g,()=>{const G=B9e(f),B=B9e(d);return{api:Bkg(G,r,B,m,h.current),hgApi:G}},[r,m]);const y=Ue.useCallback(G=>{const B=G??e.spec;if(B){if(V9g(B).state==="error"){console.warn("Gosling spec is not valid. Please refer to the console message.");return}vkg(B,(R,w,T,W,V)=>{var X,N;if(u.current&&vDe(v9e(u.current,["linkingId"]),v9e(T,["linkingId"])))return;(X=e.compiled)==null||X.call(e,B,R,{_processedSpec:T}),s(w);const Y=typeof r<"u";(N=e.experimental)!=null&&N.reactive&&Y?setTimeout(()=>{var x,M;wkg(R,(x=f.current)==null?void 0:x.api.getViewConfig()),(M=f.current)==null||M.api.setViewConfig(R)},Skg):o(R),p(W),u.current=T,d.current=W,h.current=V},[...W9g],m,{containerSize:l.current,containerParentSize:c.current},e.urlToFetchOptions)}},[e.spec,m]);Ue.useEffect(()=>{var G;if(!((G=e.spec)!=null&&G.responsiveSize))return;const B=document.getElementById(b);if(!B)return;const S=new dXe.ResizeSensor(B,T=>{(!l.current||l.current.height!==T.height||l.current.width!==T.width)&&(l.current=T,y())}),R=B.parentElement;if(!R)return;const w=new dXe.ResizeSensor(R,T=>{(!c.current||c.current.height!==T.height||c.current.width!==T.width)&&(c.current=T,y())});return()=>{S.detach(),w.detach()}}),Ue.useEffect(()=>{C?(y({title:" ",tracks:[{}]}),a(!1)):y()},[e.spec,m,C]);const Z=typeof((n=e.spec)==null?void 0:n.responsiveSize)!="object"?(I=e.spec)==null?void 0:I.responsiveSize:e.spec.responsiveSize.height;return Ue.useMemo(()=>{var G,B,S;return k.createElement(A6e,{ref:f,viewConfig:r,size:A,id:b,className:e.className,options:{padding:e.padding,border:e.border,margin:e.margin,responsiveWidth:typeof((G=e.spec)==null?void 0:G.responsiveSize)!="object"?(B=e.spec)==null?void 0:B.responsiveSize:e.spec.responsiveSize.width,responsiveHeight:Z,background:m.root.background,alt:(S=e.spec)==null?void 0:S.description}})},[r,A,m,Z])});tp.displayName="GoslingComponent";function B9e(e){return new Proxy({},{get(g,i,n){if(!e.current)throw Error("ref is not set!");return Reflect.get(e.current,i,n)}})}var w9e=_I;w9e.createRoot,w9e.hydrateRoot;function Rkg(){return k.createElement(k.Fragment,null,k.createElement("h1",{style:{marginLeft:"60px",marginTop:"60px"}},"Zoom and pan in the track below using your mouse and mouse wheel."),k.createElement(tp,{spec:{tracks:[{id:"heatmap-track",data:{url:"https://server.gosling-lang.org/api/v1/tileset_info/?d=cistrome-multivec",type:"multivec",row:"sample",column:"position",value:"peak",categories:["sample 1","sample 2","sample 3","sample 4"],binSize:4},mark:"rect",x:{field:"start",type:"genomic"},xe:{field:"end",type:"genomic"},row:{field:"sample",type:"nominal",legend:!0},color:{field:"peak",type:"quantitative",legend:!0,range:"pink"},width:600,height:130}]},experimental:{reactive:!0}}))}var l6e={exports:{}},Vkg="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",Wkg=Vkg,Xkg=Wkg;function c6e(){}function u6e(){}u6e.resetWarningCache=c6e;var Tkg=function(){function e(n,I,r,o,C,a){if(a!==Xkg){var A=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw A.name="Invariant Violation",A}}e.isRequired=e;function g(){return e}var i={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:g,element:e,elementType:e,instanceOf:g,node:e,objectOf:g,oneOf:g,oneOfType:g,shape:g,exact:g,checkPropTypes:u6e,resetWarningCache:c6e};return i.PropTypes=i,i};l6e.exports=Tkg();var Hkg=l6e.exports;const S9e=Ba(Hkg),R9e={};function vie(e,g){e===void 0&&(e=R9e),g===void 0&&(g=R9e);const i=Object.keys(e),n=Object.keys(g);return e===g||i.length===n.length&&i.every(I=>e[I]===g[I])}/*! + * https://github.com/Starcounter-Jack/JSON-Patch + * (c) 2017-2022 Joachim Wester + * MIT licensed + */var Nkg=globalThis&&globalThis.__extends||function(){var e=function(g,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,I){n.__proto__=I}||function(n,I){for(var r in I)I.hasOwnProperty(r)&&(n[r]=I[r])},e(g,i)};return function(g,i){e(g,i);function n(){this.constructor=g}g.prototype=i===null?Object.create(i):(n.prototype=i.prototype,new n)}}(),kkg=Object.prototype.hasOwnProperty;function Bie(e,g){return kkg.call(e,g)}function wie(e){if(Array.isArray(e)){for(var g=new Array(e.length),i=0;i=48&&n<=57){g++;continue}return!1}return!0}function n0(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function d6e(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Rie(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(var g=0,i=e.length;g0&&a[s-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(i&&c===void 0&&(A[u]===void 0?c=a.slice(0,s).join("/"):s==l-1&&(c=g.path),c!==void 0&&d(g,0,e,c)),s++,Array.isArray(A)){if(u==="-")u=A.length;else{if(i&&!Sie(u))throw new Nn("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",r,g,e);Sie(u)&&(u=~~u)}if(s>=l){if(i&&g.op==="add"&&u>A.length)throw new Nn("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",r,g,e);var o=Kkg[g.op].call(g,A,u,e);if(o.test===!1)throw new Nn("Test operation failed","TEST_OPERATION_FAILED",r,g,e);return o}}else if(s>=l){var o=yv[g.op].call(g,A,u,e);if(o.test===!1)throw new Nn("Test operation failed","TEST_OPERATION_FAILED",r,g,e);return o}if(A=A[u],i&&s0)throw new Nn('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",g,e,i);if((e.op==="move"||e.op==="copy")&&typeof e.from!="string")throw new Nn("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",g,e,i);if((e.op==="add"||e.op==="replace"||e.op==="test")&&e.value===void 0)throw new Nn("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",g,e,i);if((e.op==="add"||e.op==="replace"||e.op==="test")&&Rie(e.value))throw new Nn("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",g,e,i);if(i){if(e.op=="add"){var I=e.path.split("/").length,r=n.split("/").length;if(I!==r+1&&I!==r)throw new Nn("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",g,e,i)}else if(e.op==="replace"||e.op==="remove"||e.op==="_get"){if(e.path!==n)throw new Nn("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",g,e,i)}else if(e.op==="move"||e.op==="copy"){var o={op:"_get",path:e.from,value:void 0},C=f6e([o],i);if(C&&C.name==="OPERATION_PATH_UNRESOLVABLE")throw new Nn("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",g,e,i)}}}else throw new Nn("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",g,e,i)}function f6e(e,g,i){try{if(!Array.isArray(e))throw new Nn("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(g)x_(la(g),la(e),i||!0);else{i=i||UD;for(var n=0;n0&&(e.patches=[],e.callback&&e.callback(n)),n}function Qle(e,g,i,n,I){if(g!==e){typeof g.toJSON=="function"&&(g=g.toJSON());for(var r=wie(g),o=wie(e),C=!1,a=o.length-1;a>=0;a--){var A=o[a],s=e[A];if(Bie(g,A)&&!(g[A]===void 0&&s!==void 0&&Array.isArray(g)===!1)){var l=g[A];typeof s=="object"&&s!=null&&typeof l=="object"&&l!=null&&Array.isArray(s)===Array.isArray(l)?Qle(s,l,i,n+"/"+n0(A),I):s!==l&&(I&&i.push({op:"test",path:n+"/"+n0(A),value:la(s)}),i.push({op:"replace",path:n+"/"+n0(A),value:la(l)}))}else Array.isArray(e)===Array.isArray(g)?(I&&i.push({op:"test",path:n+"/"+n0(A),value:la(s)}),i.push({op:"remove",path:n+"/"+n0(A)}),C=!0):(I&&i.push({op:"test",path:n,value:e}),i.push({op:"replace",path:n,value:g}))}if(!(!C&&r.length==o.length))for(var a=0;a0)return[p,n+c.join(`, +`+m),s].join(` +`+a)}return y}(g,"",0)};const wj=Ba(Qkg);function PC(e,g,i){return e.fields=g||[],e.fname=i,e}function xn(e){return e==null?null:e.fname}function Ur(e){return e==null?null:e.fields}function m6e(e){return e.length===1?jkg(e[0]):$kg(e)}const jkg=e=>function(g){return g[e]},$kg=e=>{const g=e.length;return function(i){for(let n=0;no?A():o=C+1:a==="["?(C>o&&A(),I=o=C+1):a==="]"&&(I||qe("Access path missing open bracket: "+e),I>0&&A(),I=0,o=C+1)}return I&&qe("Access path missing closing bracket: "+e),n&&qe("Access path missing closing quote: "+e),C>o&&(C++,A()),g}function HC(e,g,i){const n=qc(e);return e=n.length===1?n[0]:e,PC((i&&i.get||m6e)(n),[e],g||e)}const GH=HC("id"),io=PC(e=>e,[],"identity"),uf=PC(()=>0,[],"zero"),sS=PC(()=>1,[],"one"),fs=PC(()=>!0,[],"true"),_h=PC(()=>!1,[],"false");function qkg(e,g,i){const n=[g].concat([].slice.call(i));console[e].apply(console,n)}const p6e=0,jle=1,$le=2,b6e=3,y6e=4;function qle(e,g){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:qkg,n=e||p6e;return{level(I){return arguments.length?(n=+I,this):n},error(){return n>=jle&&i(g||"error","ERROR",arguments),this},warn(){return n>=$le&&i(g||"warn","WARN",arguments),this},info(){return n>=b6e&&i(g||"log","INFO",arguments),this},debug(){return n>=y6e&&i(g||"log","DEBUG",arguments),this}}}var et=Array.isArray;function Wt(e){return e===Object(e)}const W9e=e=>e!=="__proto__";function AS(){for(var e=arguments.length,g=new Array(e),i=0;i{for(const r in I)if(r==="signals")n.signals=eYg(n.signals,I.signals);else{const o=r==="legend"?{layout:1}:r==="style"?!0:null;lS(n,r,I[r],o)}return n},{})}function lS(e,g,i,n){if(!W9e(g))return;let I,r;if(Wt(i)&&!et(i)){r=Wt(e[g])?e[g]:e[g]={};for(I in i)n&&(n===!0||n[I])?lS(r,I,i[I]):W9e(I)&&(r[I]=i[I])}else e[g]=i}function eYg(e,g){if(e==null)return g;const i={},n=[];function I(r){i[r.name]||(i[r.name]=1,n.push(r))}return g.forEach(I),e.forEach(I),n}function jg(e){return e[e.length-1]}function _r(e){return e==null||e===""?null:+e}const Z6e=e=>g=>e*Math.exp(g),G6e=e=>g=>Math.log(e*g),v6e=e=>g=>Math.sign(g)*Math.log1p(Math.abs(g/e)),B6e=e=>g=>Math.sign(g)*Math.expm1(Math.abs(g))*e,QD=e=>g=>g<0?-Math.pow(-g,e):Math.pow(g,e);function F_(e,g,i,n){const I=i(e[0]),r=i(jg(e)),o=(r-I)*g;return[n(I-o),n(r-o)]}function w6e(e,g){return F_(e,g,_r,io)}function S6e(e,g){var i=Math.sign(e[0]);return F_(e,g,G6e(i),Z6e(i))}function R6e(e,g,i){return F_(e,g,QD(i),QD(1/i))}function V6e(e,g,i){return F_(e,g,v6e(i),B6e(i))}function E_(e,g,i,n,I){const r=n(e[0]),o=n(jg(e)),C=g!=null?n(g):(r+o)/2;return[I(C+(r-C)*i),I(C+(o-C)*i)]}function ece(e,g,i){return E_(e,g,i,_r,io)}function tce(e,g,i){const n=Math.sign(e[0]);return E_(e,g,i,G6e(n),Z6e(n))}function jD(e,g,i,n){return E_(e,g,i,QD(n),QD(1/n))}function gce(e,g,i,n){return E_(e,g,i,v6e(n),B6e(n))}function W6e(e){return 1+~~(new Date(e).getMonth()/3)}function X6e(e){return 1+~~(new Date(e).getUTCMonth()/3)}function Vt(e){return e!=null?et(e)?e:[e]:[]}function T6e(e,g,i){let n=e[0],I=e[1],r;return I=i-g?[g,i]:[n=Math.min(Math.max(n,g),i-r),n+r]}function Bg(e){return typeof e=="function"}const tYg="descending";function ice(e,g,i){i=i||{},g=Vt(g)||[];const n=[],I=[],r={},o=i.comparator||gYg;return Vt(e).forEach((C,a)=>{C!=null&&(n.push(g[a]===tYg?-1:1),I.push(C=Bg(C)?C:HC(C,null,i)),(Ur(C)||[]).forEach(A=>r[A]=1))}),I.length===0?null:PC(o(I,n),Object.keys(r))}const D_=(e,g)=>(eg||g==null)&&e!=null?1:(g=g instanceof Date?+g:g,(e=e instanceof Date?+e:e)!==e&&g===g?-1:g!==g&&e===e?1:0),gYg=(e,g)=>e.length===1?iYg(e[0],g[0]):nYg(e,g,e.length),iYg=(e,g)=>function(i,n){return D_(e(i),e(n))*g},nYg=(e,g,i)=>(g.push(0),function(n,I){let r,o=0,C=-1;for(;o===0&&++Ce}function nce(e,g){let i;return n=>{i&&clearTimeout(i),i=setTimeout(()=>(g(n),i=null),e)}}function vg(e){for(let g,i,n=1,I=arguments.length;no&&(o=I))}else{for(I=g(e[i]);io&&(o=I))}return[r,o]}function H6e(e,g){const i=e.length;let n=-1,I,r,o,C,a;if(g==null){for(;++n=r){I=o=r;break}if(n===i)return[-1,-1];for(C=a=n;++nr&&(I=r,C=n),o=r){I=o=r;break}if(n===i)return[-1,-1];for(C=a=n;++nr&&(I=r,C=n),o{I.set(r,e[r])}),I}function N6e(e,g,i,n,I,r){if(!i&&i!==0)return r;const o=+i;let C=e[0],a=jg(e),A;ar&&(o=I,I=r,r=o),i=i===void 0||i,n=n===void 0||n,(i?I<=e:IC.replace(/\\(.)/g,"$1")):Vt(e));const n=e&&e.length,I=i&&i.get||m6e,r=C=>I(g?[C]:qc(C));let o;if(!n)o=function(){return""};else if(n===1){const C=r(e[0]);o=function(a){return""+C(a)}}else{const C=e.map(r);o=function(a){let A=""+C[0](a),s=0;for(;++s{g={},i={},n=0},r=(o,C)=>(++n>e&&(i=g,g={},n=1),g[o]=C);return I(),{clear:I,has:o=>gg(g,o)||gg(i,o),get:o=>gg(g,o)?g[o]:gg(i,o)?r(o,i[o]):void 0,set:(o,C)=>gg(g,o)?g[o]=C:r(o,C)}}function F6e(e,g,i,n){const I=g.length,r=i.length;if(!r)return g;if(!I)return i;const o=n||new g.constructor(I+r);let C=0,a=0,A=0;for(;C0?i[a++]:g[C++];for(;C=0;)i+=e;return i}function E6e(e,g,i,n){const I=i||" ",r=e+"",o=g-r.length;return o<=0?r:n==="left"?g2(I,o)+r:n==="center"?g2(I,~~(o/2))+r+g2(I,Math.ceil(o/2)):r+g2(I,o)}function vH(e){return e&&jg(e)-e[0]||0}function ft(e){return et(e)?"["+e.map(ft)+"]":Wt(e)||Rt(e)?JSON.stringify(e).replace("\u2028","\\u2028").replace("\u2029","\\u2029"):e}function rce(e){return e==null||e===""?null:!e||e==="false"||e==="0"?!1:!!e}const oYg=e=>Vi(e)||nm(e)?e:Date.parse(e);function oce(e,g){return g=g||oYg,e==null||e===""?null:g(e)}function Cce(e){return e==null||e===""?null:e+""}function JA(e){const g={},i=e.length;for(let n=0;n9999?"+"+CC(e,6):CC(e,4)}function sYg(e){var g=e.getUTCHours(),i=e.getUTCMinutes(),n=e.getUTCSeconds(),I=e.getUTCMilliseconds();return isNaN(e)?"Invalid Date":aYg(e.getUTCFullYear())+"-"+CC(e.getUTCMonth()+1,2)+"-"+CC(e.getUTCDate(),2)+(I?"T"+CC(g,2)+":"+CC(i,2)+":"+CC(n,2)+"."+CC(I,3)+"Z":n?"T"+CC(g,2)+":"+CC(i,2)+":"+CC(n,2)+"Z":i||g?"T"+CC(g,2)+":"+CC(i,2)+"Z":"")}function AYg(e){var g=new RegExp('["'+e+` +\r]`),i=e.charCodeAt(0);function n(l,c){var u,d,h=I(l,function(f,m){if(u)return u(f,m-1);d=f,u=c?CYg(f,c):M6e(f)});return h.columns=d||[],h}function I(l,c){var u=[],d=l.length,h=0,f=0,m,b=d<=0,p=!1;l.charCodeAt(d-1)===FR&&--d,l.charCodeAt(d-1)===Vj&&--d;function y(){if(b)return Sj;if(p)return p=!1,X9e;var v,G=h,B;if(l.charCodeAt(G)===Rj){for(;h++=d?b=!0:(B=l.charCodeAt(h++))===FR?p=!0:B===Vj&&(p=!0,l.charCodeAt(h)===FR&&++h),l.slice(G+1,v-1).replace(/""/g,'"')}for(;h1)n=pYg(e,g,i);else for(I=0,n=new Array(r=e.arcs.length);Ig?1:e>=g?0:NaN}function bYg(e,g){return e==null||g==null?NaN:ge?1:g>=e?0:NaN}function BH(e){let g,i,n;e.length!==2?(g=md,i=(C,a)=>md(e(C),a),n=(C,a)=>e(C)-a):(g=e===md||e===bYg?e:yYg,i=e,n=e);function I(C,a,A=0,s=C.length){if(A>>1;i(C[l],a)<0?A=l+1:s=l}while(A>>1;i(C[l],a)<=0?A=l+1:s=l}while(AA&&n(C[l-1],a)>-n(C[l],a)?l-1:l}return{left:I,center:o,right:r}}function yYg(){return 0}function P6e(e){return e===null?NaN:+e}function*ZYg(e,g){if(g===void 0)for(let i of e)i!=null&&(i=+i)>=i&&(yield i);else{let i=-1;for(let n of e)(n=g(n,++i,e))!=null&&(n=+n)>=n&&(yield n)}}const _6e=BH(md),$D=_6e.right,GYg=_6e.left;BH(P6e).center;const wH=$D;function vYg(e,g){let i=0,n,I=0,r=0;if(g===void 0)for(let o of e)o!=null&&(o=+o)>=o&&(n=o-I,I+=n/++i,r+=n*(o-I));else{let o=-1;for(let C of e)(C=g(C,++o,e))!=null&&(C=+C)>=C&&(n=C-I,I+=n/++i,r+=n*(C-I))}if(i>1)return r/(i-1)}function BYg(e,g){const i=vYg(e,g);return i&&Math.sqrt(i)}class Yo{constructor(){this._partials=new Float64Array(32),this._n=0}add(g){const i=this._partials;let n=0;for(let I=0;I0){for(o=g[--i];i>0&&(n=o,I=g[--i],o=n+I,r=I-(o-n),!r););i>0&&(r<0&&g[i-1]<0||r>0&&g[i-1]>0)&&(I=r*2,n=o+I,I==n-o&&(o=n))}return o}}class N9e extends Map{constructor(g,i=L6e){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:i}}),g!=null)for(const[n,I]of g)this.set(n,I)}get(g){return super.get(Wie(this,g))}has(g){return super.has(Wie(this,g))}set(g,i){return super.set(O6e(this,g),i)}delete(g){return super.delete(J6e(this,g))}}class qD extends Set{constructor(g,i=L6e){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:i}}),g!=null)for(const n of g)this.add(n)}has(g){return super.has(Wie(this,g))}add(g){return super.add(O6e(this,g))}delete(g){return super.delete(J6e(this,g))}}function Wie({_intern:e,_key:g},i){const n=g(i);return e.has(n)?e.get(n):i}function O6e({_intern:e,_key:g},i){const n=g(i);return e.has(n)?e.get(n):(e.set(n,i),i)}function J6e({_intern:e,_key:g},i){const n=g(i);return e.has(n)&&(i=e.get(n),e.delete(n)),i}function L6e(e){return e!==null&&typeof e=="object"?e.valueOf():e}function wYg(e,g){return Array.from(g,i=>e[i])}function SYg(e=md){if(e===md)return U6e;if(typeof e!="function")throw new TypeError("compare is not a function");return(g,i)=>{const n=e(g,i);return n||n===0?n:(e(i,i)===0)-(e(g,g)===0)}}function U6e(e,g){return(e==null||!(e>=e))-(g==null||!(g>=g))||(eg?1:0)}const RYg=Math.sqrt(50),VYg=Math.sqrt(10),WYg=Math.sqrt(2);function eM(e,g,i){const n=(g-e)/Math.max(0,i),I=Math.floor(Math.log10(n)),r=n/Math.pow(10,I),o=r>=RYg?10:r>=VYg?5:r>=WYg?2:1;let C,a,A;return I<0?(A=Math.pow(10,-I)/o,C=Math.round(e*A),a=Math.round(g*A),C/Ag&&--a,A=-A):(A=Math.pow(10,I)*o,C=Math.round(e/A),a=Math.round(g/A),C*Ag&&--a),a0))return[];if(e===g)return[e];const n=g=I))return[];const C=r-I+1,a=new Array(C);if(n)if(o<0)for(let A=0;A=n)&&(i=n);else{let n=-1;for(let I of e)(I=g(I,++n,e))!=null&&(i=I)&&(i=I)}return i}function Hie(e,g){let i;if(g===void 0)for(const n of e)n!=null&&(i>n||i===void 0&&n>=n)&&(i=n);else{let n=-1;for(let I of e)(I=g(I,++n,e))!=null&&(i>I||i===void 0&&I>=I)&&(i=I)}return i}function Q6e(e,g,i=0,n=1/0,I){if(g=Math.floor(g),i=Math.floor(Math.max(0,i)),n=Math.floor(Math.min(e.length-1,n)),!(i<=g&&g<=n))return e;for(I=I===void 0?U6e:SYg(I);n>i;){if(n-i>600){const a=n-i+1,A=g-i+1,s=Math.log(a),l=.5*Math.exp(2*s/3),c=.5*Math.sqrt(s*l*(a-l)/a)*(A-a/2<0?-1:1),u=Math.max(i,Math.floor(g-A*l/a+c)),d=Math.min(n,Math.floor(g+(a-A)*l/a+c));Q6e(e,g,u,d,I)}const r=e[g];let o=i,C=n;for(ER(e,i,g),I(e[n],r)>0&&ER(e,i,n);o0;)--C}I(e[i],r)===0?ER(e,i,C):(++C,ER(e,C,n)),C<=g&&(i=C+1),g<=C&&(n=C-1)}return e}function ER(e,g,i){const n=e[g];e[g]=e[i],e[i]=n}function Nie(e,g,i){if(e=Float64Array.from(ZYg(e,i)),!(!(n=e.length)||isNaN(g=+g))){if(g<=0||n<2)return Hie(e);if(g>=1)return tb(e);var n,I=(n-1)*g,r=Math.floor(I),o=tb(Q6e(e,r).subarray(0,r+1)),C=Hie(e.subarray(r+1));return o+(C-o)*(I-r)}}function j6e(e,g,i=P6e){if(!(!(n=e.length)||isNaN(g=+g))){if(g<=0||n<2)return+i(e[0],0,e);if(g>=1)return+i(e[n-1],n-1,e);var n,I=(n-1)*g,r=Math.floor(I),o=+i(e[r],r,e),C=+i(e[r+1],r+1,e);return o+(C-o)*(I-r)}}function XYg(e,g){let i=0,n=0;if(g===void 0)for(let I of e)I!=null&&(I=+I)>=I&&(++i,n+=I);else{let I=-1;for(let r of e)(r=g(r,++I,e))!=null&&(r=+r)>=r&&(++i,n+=r)}if(i)return n/i}function $6e(e,g){return Nie(e,.5,g)}function*TYg(e){for(const g of e)yield*g}function q6e(e){return Array.from(TYg(e))}function ca(e,g,i){e=+e,g=+g,i=(I=arguments.length)<2?(g=e,e=0,1):I<3?1:+i;for(var n=-1,I=Math.max(0,Math.ceil((g-e)/i))|0,r=new Array(I);++n(e(r=new Date(+r)),r),I.ceil=r=>(e(r=new Date(r-1)),g(r,1),e(r),r),I.round=r=>{const o=I(r),C=I.ceil(r);return r-o(g(r=new Date(+r),o==null?1:Math.floor(o)),r),I.range=(r,o,C)=>{const a=[];if(r=I.ceil(r),C=C==null?1:Math.floor(C),!(r0))return a;let A;do a.push(A=new Date(+r)),g(r,C),e(r);while(ARI(o=>{if(o>=o)for(;e(o),!r(o);)o.setTime(o-1)},(o,C)=>{if(o>=o)if(C<0)for(;++C<=0;)for(;g(o,-1),!r(o););else for(;--C>=0;)for(;g(o,1),!r(o););}),i&&(I.count=(r,o)=>(Wj.setTime(+r),Xj.setTime(+o),e(Wj),e(Xj),Math.floor(i(Wj,Xj))),I.every=r=>(r=Math.floor(r),!isFinite(r)||!(r>0)?null:r>1?I.filter(n?o=>n(o)%r===0:o=>I.count(0,o)%r===0):I)),I}const Kw=RI(()=>{},(e,g)=>{e.setTime(+e+g)},(e,g)=>g-e);Kw.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?RI(g=>{g.setTime(Math.floor(g/e)*e)},(g,i)=>{g.setTime(+g+i*e)},(g,i)=>(i-g)/e):Kw);Kw.range;const Id=1e3,ts=Id*60,rd=ts*60,Dd=rd*24,ace=Dd*7,k9e=Dd*30,Tj=Dd*365,od=RI(e=>{e.setTime(e-e.getMilliseconds())},(e,g)=>{e.setTime(+e+g*Id)},(e,g)=>(g-e)/Id,e=>e.getUTCSeconds());od.range;const M_=RI(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Id)},(e,g)=>{e.setTime(+e+g*ts)},(e,g)=>(g-e)/ts,e=>e.getMinutes());M_.range;const z_=RI(e=>{e.setUTCSeconds(0,0)},(e,g)=>{e.setTime(+e+g*ts)},(e,g)=>(g-e)/ts,e=>e.getUTCMinutes());z_.range;const P_=RI(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Id-e.getMinutes()*ts)},(e,g)=>{e.setTime(+e+g*rd)},(e,g)=>(g-e)/rd,e=>e.getHours());P_.range;const __=RI(e=>{e.setUTCMinutes(0,0,0)},(e,g)=>{e.setTime(+e+g*rd)},(e,g)=>(g-e)/rd,e=>e.getUTCHours());__.range;const pd=RI(e=>e.setHours(0,0,0,0),(e,g)=>e.setDate(e.getDate()+g),(e,g)=>(g-e-(g.getTimezoneOffset()-e.getTimezoneOffset())*ts)/Dd,e=>e.getDate()-1);pd.range;const Im=RI(e=>{e.setUTCHours(0,0,0,0)},(e,g)=>{e.setUTCDate(e.getUTCDate()+g)},(e,g)=>(g-e)/Dd,e=>e.getUTCDate()-1);Im.range;const tqe=RI(e=>{e.setUTCHours(0,0,0,0)},(e,g)=>{e.setUTCDate(e.getUTCDate()+g)},(e,g)=>(g-e)/Dd,e=>Math.floor(e/Dd));tqe.range;function cZ(e){return RI(g=>{g.setDate(g.getDate()-(g.getDay()+7-e)%7),g.setHours(0,0,0,0)},(g,i)=>{g.setDate(g.getDate()+i*7)},(g,i)=>(i-g-(i.getTimezoneOffset()-g.getTimezoneOffset())*ts)/ace)}const uS=cZ(0),tM=cZ(1),HYg=cZ(2),NYg=cZ(3),xw=cZ(4),kYg=cZ(5),YYg=cZ(6);uS.range;tM.range;HYg.range;NYg.range;xw.range;kYg.range;YYg.range;function uZ(e){return RI(g=>{g.setUTCDate(g.getUTCDate()-(g.getUTCDay()+7-e)%7),g.setUTCHours(0,0,0,0)},(g,i)=>{g.setUTCDate(g.getUTCDate()+i*7)},(g,i)=>(i-g)/ace)}const dS=uZ(0),gM=uZ(1),KYg=uZ(2),xYg=uZ(3),Fw=uZ(4),FYg=uZ(5),EYg=uZ(6);dS.range;gM.range;KYg.range;xYg.range;Fw.range;FYg.range;EYg.range;const G9=RI(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,g)=>{e.setMonth(e.getMonth()+g)},(e,g)=>g.getMonth()-e.getMonth()+(g.getFullYear()-e.getFullYear())*12,e=>e.getMonth());G9.range;const v9=RI(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,g)=>{e.setUTCMonth(e.getUTCMonth()+g)},(e,g)=>g.getUTCMonth()-e.getUTCMonth()+(g.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());v9.range;const Yc=RI(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,g)=>{e.setFullYear(e.getFullYear()+g)},(e,g)=>g.getFullYear()-e.getFullYear(),e=>e.getFullYear());Yc.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:RI(g=>{g.setFullYear(Math.floor(g.getFullYear()/e)*e),g.setMonth(0,1),g.setHours(0,0,0,0)},(g,i)=>{g.setFullYear(g.getFullYear()+i*e)});Yc.range;const Kc=RI(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,g)=>{e.setUTCFullYear(e.getUTCFullYear()+g)},(e,g)=>g.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());Kc.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:RI(g=>{g.setUTCFullYear(Math.floor(g.getUTCFullYear()/e)*e),g.setUTCMonth(0,1),g.setUTCHours(0,0,0,0)},(g,i)=>{g.setUTCFullYear(g.getUTCFullYear()+i*e)});Kc.range;function gqe(e,g,i,n,I,r){const o=[[od,1,Id],[od,5,5*Id],[od,15,15*Id],[od,30,30*Id],[r,1,ts],[r,5,5*ts],[r,15,15*ts],[r,30,30*ts],[I,1,rd],[I,3,3*rd],[I,6,6*rd],[I,12,12*rd],[n,1,Dd],[n,2,2*Dd],[i,1,ace],[g,1,k9e],[g,3,3*k9e],[e,1,Tj]];function C(A,s,l){const c=sf).right(o,c);if(u===o.length)return e.every(mm(A/Tj,s/Tj,l));if(u===0)return Kw.every(Math.max(mm(A,s,l),1));const[d,h]=o[c/o[u-1][2](e[g]=1+i,e),{});function Ace(e){const g=Vt(e).slice(),i={};return g.length||qe("Missing time unit."),g.forEach(I=>{gg(Hj,I)?i[I]=1:qe(`Invalid time unit: ${I}.`)}),(i[yI]||i[zr]?1:0)+(i[NC]||i[Qr]||i[kC]?1:0)+(i[xc]?1:0)>1&&qe(`Incompatible time units: ${e}`),g.sort((I,r)=>Hj[I]-Hj[r]),g}const _Yg={[hr]:"%Y ",[NC]:"Q%q ",[Qr]:"%b ",[kC]:"%d ",[yI]:"W%U ",[zr]:"%a ",[xc]:"%j ",[ba]:"%H:00",[ya]:"00:%M",[ms]:":%S",[LA]:".%L",[`${hr}-${Qr}`]:"%Y-%m ",[`${hr}-${Qr}-${kC}`]:"%Y-%m-%d ",[`${ba}-${ya}`]:"%H:%M"};function iqe(e,g){const i=vg({},_Yg,g),n=Ace(e),I=n.length;let r="",o=0,C,a;for(o=0;oo;--C)if(a=n.slice(o,C).join("-"),i[a]!=null){r+=i[a],o=C;break}return r.trim()}const s0=new Date;function lce(e){return s0.setFullYear(e),s0.setMonth(0),s0.setDate(1),s0.setHours(0,0,0,0),s0}function nqe(e){return rqe(new Date(e))}function Iqe(e){return kie(new Date(e))}function rqe(e){return pd.count(lce(e.getFullYear())-1,e)}function kie(e){return uS.count(lce(e.getFullYear())-1,e)}function Yie(e){return lce(e).getDay()}function OYg(e,g,i,n,I,r,o){if(0<=e&&e<100){const C=new Date(-1,g,i,n,I,r,o);return C.setFullYear(e),C}return new Date(e,g,i,n,I,r,o)}function oqe(e){return aqe(new Date(e))}function Cqe(e){return Kie(new Date(e))}function aqe(e){const g=Date.UTC(e.getUTCFullYear(),0,1);return Im.count(g-1,e)}function Kie(e){const g=Date.UTC(e.getUTCFullYear(),0,1);return dS.count(g-1,e)}function xie(e){return s0.setTime(Date.UTC(e,0,1)),s0.getUTCDay()}function JYg(e,g,i,n,I,r,o){if(0<=e&&e<100){const C=new Date(Date.UTC(-1,g,i,n,I,r,o));return C.setUTCFullYear(i.y),C}return new Date(Date.UTC(e,g,i,n,I,r,o))}function sqe(e,g,i,n,I){const r=g||1,o=jg(e),C=(m,b,p)=>(p=p||m,LYg(i[p],n[p],m===o&&r,b)),a=new Date,A=JA(e),s=A[hr]?C(hr):no(2012),l=A[Qr]?C(Qr):A[NC]?C(NC):uf,c=A[yI]&&A[zr]?C(zr,1,yI+zr):A[yI]?C(yI,1):A[zr]?C(zr,1):A[kC]?C(kC,1):A[xc]?C(xc,1):sS,u=A[ba]?C(ba):uf,d=A[ya]?C(ya):uf,h=A[ms]?C(ms):uf,f=A[LA]?C(LA):uf;return function(m){a.setTime(+m);const b=s(a);return I(b,l(a),c(a,b),u(a),d(a),h(a),f(a))}}function LYg(e,g,i,n){const I=i<=1?e:n?(r,o)=>n+i*Math.floor((e(r,o)-n)/i):(r,o)=>i*Math.floor(e(r,o)/i);return g?(r,o)=>g(I(r,o),o):I}function Ew(e,g,i){return g+e*7-(i+6)%7}const UYg={[hr]:e=>e.getFullYear(),[NC]:e=>Math.floor(e.getMonth()/3),[Qr]:e=>e.getMonth(),[kC]:e=>e.getDate(),[ba]:e=>e.getHours(),[ya]:e=>e.getMinutes(),[ms]:e=>e.getSeconds(),[LA]:e=>e.getMilliseconds(),[xc]:e=>rqe(e),[yI]:e=>kie(e),[yI+zr]:(e,g)=>Ew(kie(e),e.getDay(),Yie(g)),[zr]:(e,g)=>Ew(1,e.getDay(),Yie(g))},QYg={[NC]:e=>3*e,[yI]:(e,g)=>Ew(e,0,Yie(g))};function Aqe(e,g){return sqe(e,g||1,UYg,QYg,OYg)}const jYg={[hr]:e=>e.getUTCFullYear(),[NC]:e=>Math.floor(e.getUTCMonth()/3),[Qr]:e=>e.getUTCMonth(),[kC]:e=>e.getUTCDate(),[ba]:e=>e.getUTCHours(),[ya]:e=>e.getUTCMinutes(),[ms]:e=>e.getUTCSeconds(),[LA]:e=>e.getUTCMilliseconds(),[xc]:e=>aqe(e),[yI]:e=>Kie(e),[zr]:(e,g)=>Ew(1,e.getUTCDay(),xie(g)),[yI+zr]:(e,g)=>Ew(Kie(e),e.getUTCDay(),xie(g))},$Yg={[NC]:e=>3*e,[yI]:(e,g)=>Ew(e,0,xie(g))};function lqe(e,g){return sqe(e,g||1,jYg,$Yg,JYg)}const qYg={[hr]:Yc,[NC]:G9.every(3),[Qr]:G9,[yI]:uS,[kC]:pd,[zr]:pd,[xc]:pd,[ba]:P_,[ya]:M_,[ms]:od,[LA]:Kw},eKg={[hr]:Kc,[NC]:v9.every(3),[Qr]:v9,[yI]:dS,[kC]:Im,[zr]:Im,[xc]:Im,[ba]:__,[ya]:z_,[ms]:od,[LA]:Kw};function hS(e){return qYg[e]}function fS(e){return eKg[e]}function cqe(e,g,i){return e?e.offset(g,i):void 0}function uqe(e,g,i){return cqe(hS(e),g,i)}function dqe(e,g,i){return cqe(fS(e),g,i)}function hqe(e,g,i,n){return e?e.range(g,i,n):void 0}function fqe(e,g,i,n){return hqe(hS(e),g,i,n)}function mqe(e,g,i,n){return hqe(fS(e),g,i,n)}const i2=1e3,n2=i2*60,I2=n2*60,O_=I2*24,tKg=O_*7,Y9e=O_*30,Fie=O_*365,pqe=[hr,Qr,kC,ba,ya,ms,LA],r2=pqe.slice(0,-1),o2=r2.slice(0,-1),C2=o2.slice(0,-1),gKg=C2.slice(0,-1),iKg=[hr,yI],K9e=[hr,Qr],bqe=[hr],DR=[[r2,1,i2],[r2,5,5*i2],[r2,15,15*i2],[r2,30,30*i2],[o2,1,n2],[o2,5,5*n2],[o2,15,15*n2],[o2,30,30*n2],[C2,1,I2],[C2,3,3*I2],[C2,6,6*I2],[C2,12,12*I2],[gKg,1,O_],[iKg,1,tKg],[K9e,1,Y9e],[K9e,3,3*Y9e],[bqe,1,Fie]];function yqe(e){const g=e.extent,i=e.maxbins||40,n=Math.abs(vH(g))/i;let I=BH(C=>C[2]).right(DR,n),r,o;return I===DR.length?(r=bqe,o=mm(g[0]/Fie,g[1]/Fie,i)):I?(I=DR[n/DR[I-1][2]53)return null;"w"in ie||(ie.w=1),"Z"in ie?(ue=kj(MR(ie.y,0,1)),Ye=ue.getUTCDay(),ue=Ye>4||Ye===0?gM.ceil(ue):gM(ue),ue=Im.offset(ue,(ie.V-1)*7),ie.y=ue.getUTCFullYear(),ie.m=ue.getUTCMonth(),ie.d=ue.getUTCDate()+(ie.w+6)%7):(ue=Nj(MR(ie.y,0,1)),Ye=ue.getDay(),ue=Ye>4||Ye===0?tM.ceil(ue):tM(ue),ue=pd.offset(ue,(ie.V-1)*7),ie.y=ue.getFullYear(),ie.m=ue.getMonth(),ie.d=ue.getDate()+(ie.w+6)%7)}else("W"in ie||"U"in ie)&&("w"in ie||(ie.w="u"in ie?ie.u%7:"W"in ie?1:0),Ye="Z"in ie?kj(MR(ie.y,0,1)).getUTCDay():Nj(MR(ie.y,0,1)).getDay(),ie.m=0,ie.d="W"in ie?(ie.w+6)%7+ie.W*7-(Ye+5)%7:ie.w+ie.U*7-(Ye+6)%7);return"Z"in ie?(ie.H+=ie.Z/100|0,ie.M+=ie.Z%100,kj(ie)):Nj(ie)}}function B(oe,pe,ae,ie){for(var ye=0,ue=pe.length,Ye=ae.length,Be,ke;ye=Ye)return-1;if(Be=pe.charCodeAt(ye++),Be===37){if(Be=pe.charAt(ye++),ke=Z[Be in x9e?pe.charAt(ye++):Be],!ke||(ie=ke(oe,ae,ie))<0)return-1}else if(Be!=ae.charCodeAt(ie++))return-1}return ie}function S(oe,pe,ae){var ie=A.exec(pe.slice(ae));return ie?(oe.p=s.get(ie[0].toLowerCase()),ae+ie[0].length):-1}function R(oe,pe,ae){var ie=u.exec(pe.slice(ae));return ie?(oe.w=d.get(ie[0].toLowerCase()),ae+ie[0].length):-1}function w(oe,pe,ae){var ie=l.exec(pe.slice(ae));return ie?(oe.w=c.get(ie[0].toLowerCase()),ae+ie[0].length):-1}function T(oe,pe,ae){var ie=m.exec(pe.slice(ae));return ie?(oe.m=b.get(ie[0].toLowerCase()),ae+ie[0].length):-1}function W(oe,pe,ae){var ie=h.exec(pe.slice(ae));return ie?(oe.m=f.get(ie[0].toLowerCase()),ae+ie[0].length):-1}function V(oe,pe,ae){return B(oe,g,pe,ae)}function X(oe,pe,ae){return B(oe,i,pe,ae)}function N(oe,pe,ae){return B(oe,n,pe,ae)}function Y(oe){return o[oe.getDay()]}function x(oe){return r[oe.getDay()]}function M(oe){return a[oe.getMonth()]}function F(oe){return C[oe.getMonth()]}function $(oe){return I[+(oe.getHours()>=12)]}function Q(oe){return 1+~~(oe.getMonth()/3)}function U(oe){return o[oe.getUTCDay()]}function j(oe){return r[oe.getUTCDay()]}function ee(oe){return a[oe.getUTCMonth()]}function Ie(oe){return C[oe.getUTCMonth()]}function fe(oe){return I[+(oe.getUTCHours()>=12)]}function Ve(oe){return 1+~~(oe.getUTCMonth()/3)}return{format:function(oe){var pe=v(oe+="",p);return pe.toString=function(){return oe},pe},parse:function(oe){var pe=G(oe+="",!1);return pe.toString=function(){return oe},pe},utcFormat:function(oe){var pe=v(oe+="",y);return pe.toString=function(){return oe},pe},utcParse:function(oe){var pe=G(oe+="",!0);return pe.toString=function(){return oe},pe}}}var x9e={"-":"",_:" ",0:"0"},jI=/^\s*\d+/,nKg=/^%/,IKg=/[\\^$*+?|[\]().{}]/g;function ai(e,g,i){var n=e<0?"-":"",I=(n?-e:e)+"",r=I.length;return n+(r[g.toLowerCase(),i]))}function oKg(e,g,i){var n=jI.exec(g.slice(i,i+1));return n?(e.w=+n[0],i+n[0].length):-1}function CKg(e,g,i){var n=jI.exec(g.slice(i,i+1));return n?(e.u=+n[0],i+n[0].length):-1}function aKg(e,g,i){var n=jI.exec(g.slice(i,i+2));return n?(e.U=+n[0],i+n[0].length):-1}function sKg(e,g,i){var n=jI.exec(g.slice(i,i+2));return n?(e.V=+n[0],i+n[0].length):-1}function AKg(e,g,i){var n=jI.exec(g.slice(i,i+2));return n?(e.W=+n[0],i+n[0].length):-1}function F9e(e,g,i){var n=jI.exec(g.slice(i,i+4));return n?(e.y=+n[0],i+n[0].length):-1}function E9e(e,g,i){var n=jI.exec(g.slice(i,i+2));return n?(e.y=+n[0]+(+n[0]>68?1900:2e3),i+n[0].length):-1}function lKg(e,g,i){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(g.slice(i,i+6));return n?(e.Z=n[1]?0:-(n[2]+(n[3]||"00")),i+n[0].length):-1}function cKg(e,g,i){var n=jI.exec(g.slice(i,i+1));return n?(e.q=n[0]*3-3,i+n[0].length):-1}function uKg(e,g,i){var n=jI.exec(g.slice(i,i+2));return n?(e.m=n[0]-1,i+n[0].length):-1}function D9e(e,g,i){var n=jI.exec(g.slice(i,i+2));return n?(e.d=+n[0],i+n[0].length):-1}function dKg(e,g,i){var n=jI.exec(g.slice(i,i+3));return n?(e.m=0,e.d=+n[0],i+n[0].length):-1}function M9e(e,g,i){var n=jI.exec(g.slice(i,i+2));return n?(e.H=+n[0],i+n[0].length):-1}function hKg(e,g,i){var n=jI.exec(g.slice(i,i+2));return n?(e.M=+n[0],i+n[0].length):-1}function fKg(e,g,i){var n=jI.exec(g.slice(i,i+2));return n?(e.S=+n[0],i+n[0].length):-1}function mKg(e,g,i){var n=jI.exec(g.slice(i,i+3));return n?(e.L=+n[0],i+n[0].length):-1}function pKg(e,g,i){var n=jI.exec(g.slice(i,i+6));return n?(e.L=Math.floor(n[0]/1e3),i+n[0].length):-1}function bKg(e,g,i){var n=nKg.exec(g.slice(i,i+1));return n?i+n[0].length:-1}function yKg(e,g,i){var n=jI.exec(g.slice(i));return n?(e.Q=+n[0],i+n[0].length):-1}function ZKg(e,g,i){var n=jI.exec(g.slice(i));return n?(e.s=+n[0],i+n[0].length):-1}function z9e(e,g){return ai(e.getDate(),g,2)}function GKg(e,g){return ai(e.getHours(),g,2)}function vKg(e,g){return ai(e.getHours()%12||12,g,2)}function BKg(e,g){return ai(1+pd.count(Yc(e),e),g,3)}function Gqe(e,g){return ai(e.getMilliseconds(),g,3)}function wKg(e,g){return Gqe(e,g)+"000"}function SKg(e,g){return ai(e.getMonth()+1,g,2)}function RKg(e,g){return ai(e.getMinutes(),g,2)}function VKg(e,g){return ai(e.getSeconds(),g,2)}function WKg(e){var g=e.getDay();return g===0?7:g}function XKg(e,g){return ai(uS.count(Yc(e)-1,e),g,2)}function vqe(e){var g=e.getDay();return g>=4||g===0?xw(e):xw.ceil(e)}function TKg(e,g){return e=vqe(e),ai(xw.count(Yc(e),e)+(Yc(e).getDay()===4),g,2)}function HKg(e){return e.getDay()}function NKg(e,g){return ai(tM.count(Yc(e)-1,e),g,2)}function kKg(e,g){return ai(e.getFullYear()%100,g,2)}function YKg(e,g){return e=vqe(e),ai(e.getFullYear()%100,g,2)}function KKg(e,g){return ai(e.getFullYear()%1e4,g,4)}function xKg(e,g){var i=e.getDay();return e=i>=4||i===0?xw(e):xw.ceil(e),ai(e.getFullYear()%1e4,g,4)}function FKg(e){var g=e.getTimezoneOffset();return(g>0?"-":(g*=-1,"+"))+ai(g/60|0,"0",2)+ai(g%60,"0",2)}function P9e(e,g){return ai(e.getUTCDate(),g,2)}function EKg(e,g){return ai(e.getUTCHours(),g,2)}function DKg(e,g){return ai(e.getUTCHours()%12||12,g,2)}function MKg(e,g){return ai(1+Im.count(Kc(e),e),g,3)}function Bqe(e,g){return ai(e.getUTCMilliseconds(),g,3)}function zKg(e,g){return Bqe(e,g)+"000"}function PKg(e,g){return ai(e.getUTCMonth()+1,g,2)}function _Kg(e,g){return ai(e.getUTCMinutes(),g,2)}function OKg(e,g){return ai(e.getUTCSeconds(),g,2)}function JKg(e){var g=e.getUTCDay();return g===0?7:g}function LKg(e,g){return ai(dS.count(Kc(e)-1,e),g,2)}function wqe(e){var g=e.getUTCDay();return g>=4||g===0?Fw(e):Fw.ceil(e)}function UKg(e,g){return e=wqe(e),ai(Fw.count(Kc(e),e)+(Kc(e).getUTCDay()===4),g,2)}function QKg(e){return e.getUTCDay()}function jKg(e,g){return ai(gM.count(Kc(e)-1,e),g,2)}function $Kg(e,g){return ai(e.getUTCFullYear()%100,g,2)}function qKg(e,g){return e=wqe(e),ai(e.getUTCFullYear()%100,g,2)}function e5g(e,g){return ai(e.getUTCFullYear()%1e4,g,4)}function t5g(e,g){var i=e.getUTCDay();return e=i>=4||i===0?Fw(e):Fw.ceil(e),ai(e.getUTCFullYear()%1e4,g,4)}function g5g(){return"+0000"}function _9e(){return"%"}function O9e(e){return+e}function J9e(e){return Math.floor(+e/1e3)}var lG,cce,Sqe,uce,Rqe;i5g({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function i5g(e){return lG=Zqe(e),cce=lG.format,Sqe=lG.parse,uce=lG.utcFormat,Rqe=lG.utcParse,lG}function a2(e){const g={};return i=>g[i]||(g[i]=e(i))}function n5g(e,g){return i=>{const n=e(i),I=n.indexOf(g);if(I<0)return n;let r=I5g(n,I);const o=rI;)if(n[r]!=="0"){++r;break}return n.slice(0,r)+o}}function I5g(e,g){let i=e.lastIndexOf("e"),n;if(i>0)return i;for(i=e.length;--i>g;)if(n=e.charCodeAt(i),n>=48&&n<=57)return i+1}function Vqe(e){const g=a2(e.format),i=e.formatPrefix;return{format:g,formatPrefix:i,formatFloat(n){const I=Rb(n||",");if(I.precision==null){switch(I.precision=12,I.type){case"%":I.precision-=2;break;case"e":I.precision-=1;break}return n5g(g(I),g(".1f")(1)[1])}else return g(I)},formatSpan(n,I,r,o){o=Rb(o??",f");const C=mm(n,I,r),a=Math.max(Math.abs(n),Math.abs(I));let A;if(o.precision==null)switch(o.type){case"s":return isNaN(A=lCe(C,a))||(o.precision=A),i(o,a);case"":case"e":case"g":case"p":case"r":{isNaN(A=GMe(C,a))||(o.precision=A-(o.type==="e"));break}case"f":case"%":{isNaN(A=ZMe(C))||(o.precision=A-(o.type==="%")*2);break}}return g(o)}}}let Eie;Wqe();function Wqe(){return Eie=Vqe({format:mT,formatPrefix:vz})}function Xqe(e){return Vqe(yMe(e))}function iM(e){return arguments.length?Eie=Xqe(e):Eie}function L9e(e,g,i){i=i||{},Wt(i)||qe(`Invalid time multi-format specifier: ${i}`);const n=g(ms),I=g(ya),r=g(ba),o=g(kC),C=g(yI),a=g(Qr),A=g(NC),s=g(hr),l=e(i[LA]||".%L"),c=e(i[ms]||":%S"),u=e(i[ya]||"%I:%M"),d=e(i[ba]||"%I %p"),h=e(i[kC]||i[zr]||"%a %d"),f=e(i[yI]||"%b %d"),m=e(i[Qr]||"%B"),b=e(i[NC]||"%B"),p=e(i[hr]||"%Y");return y=>(n(y)Rt(n)?g(n):L9e(g,hS,n),utcFormat:n=>Rt(n)?i(n):L9e(i,fS,n),timeParse:a2(e.parse),utcParse:a2(e.utcParse)}}let Die;Hqe();function Hqe(){return Die=Tqe({format:cce,parse:Sqe,utcFormat:uce,utcParse:Rqe})}function Nqe(e){return Tqe(Zqe(e))}function B9(e){return arguments.length?Die=Nqe(e):Die}const Mie=(e,g)=>vg({},e,g);function kqe(e,g){const i=e?Xqe(e):iM(),n=g?Nqe(g):B9();return Mie(i,n)}function dce(e,g){const i=arguments.length;return i&&i!==2&&qe("defaultLocale expects either zero or two arguments."),i?Mie(iM(e),B9(g)):Mie(iM(),B9())}function r5g(){return Wqe(),Hqe(),dce()}const o5g=/^(data:|([A-Za-z]+:)?\/\/)/,C5g=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|file|data):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,a5g=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,U9e="file://";function s5g(e,g){return i=>({options:i||{},sanitize:l5g,load:A5g,fileAccess:!!g,file:c5g(g),http:d5g(e)})}async function A5g(e,g){const i=await this.sanitize(e,g),n=i.href;return i.localFile?this.file(n):this.http(n,g)}async function l5g(e,g){g=vg({},this.options,g);const i=this.fileAccess,n={href:null};let I,r,o;const C=C5g.test(e.replace(a5g,""));(e==null||typeof e!="string"||!C)&&qe("Sanitize failure, invalid URI: "+ft(e));const a=o5g.test(e);return(o=g.baseURL)&&!a&&(!e.startsWith("/")&&!o.endsWith("/")&&(e="/"+e),e=o+e),r=(I=e.startsWith(U9e))||g.mode==="file"||g.mode!=="http"&&!a&&i,I?e=e.slice(U9e.length):e.startsWith("//")&&(g.defaultProtocol==="file"?(e=e.slice(2),r=!0):e=(g.defaultProtocol||"http")+":"+e),Object.defineProperty(n,"localFile",{value:!!r}),n.href=e,g.target&&(n.target=g.target+""),g.rel&&(n.rel=g.rel+""),g.context==="image"&&g.crossOrigin&&(n.crossOrigin=g.crossOrigin+""),n}function c5g(e){return e?g=>new Promise((i,n)=>{e.readFile(g,(I,r)=>{I?n(I):i(r)})}):u5g}async function u5g(){qe("No file system access.")}function d5g(e){return e?async function(g,i){const n=vg({},this.options.http,i),I=i&&i.response,r=await e(g,n);return r.ok?Bg(r[I])?r[I]():r.text():qe(r.status+""+r.statusText)}:h5g}async function h5g(){qe("No HTTP fetch method available.")}const f5g=e=>e!=null&&e===e,m5g=e=>e==="true"||e==="false"||e===!0||e===!1,p5g=e=>!Number.isNaN(Date.parse(e)),Yqe=e=>!Number.isNaN(+e)&&!(e instanceof Date),b5g=e=>Yqe(e)&&Number.isInteger(+e),zie={boolean:rce,integer:_r,number:_r,date:oce,string:Cce,unknown:io},WY=[m5g,b5g,Yqe,p5g],y5g=["boolean","integer","number","date"];function Kqe(e,g){if(!e||!e.length)return"unknown";const i=e.length,n=WY.length,I=WY.map((r,o)=>o+1);for(let r=0,o=0,C,a;rr===0?o:r,0)-1]}function xqe(e,g){return g.reduce((i,n)=>(i[n]=Kqe(e,n),i),{})}function Q9e(e){const g=function(i,n){const I={delimiter:e};return hce(i,n?vg(n,I):I)};return g.responseType="text",g}function hce(e,g){return g.header&&(e=g.header.map(ft).join(g.delimiter)+` +`+e),AYg(g.delimiter).parse(e+"")}hce.responseType="text";function Z5g(e){return typeof Buffer=="function"&&Bg(Buffer.isBuffer)?Buffer.isBuffer(e):!1}function fce(e,g){const i=g&&g.property?HC(g.property):io;return Wt(e)&&!Z5g(e)?G5g(i(e),g):i(JSON.parse(e))}fce.responseType="json";function G5g(e,g){return!et(e)&&k6e(e)&&(e=[...e]),g&&g.copy?JSON.parse(JSON.stringify(e)):e}const v5g={interior:(e,g)=>e!==g,exterior:(e,g)=>e===g};function Fqe(e,g){let i,n,I,r;return e=fce(e,g),g&&g.feature?(i=dYg,I=g.feature):g&&g.mesh?(i=fYg,I=g.mesh,r=v5g[g.filter]):qe("Missing TopoJSON feature or mesh parameter."),n=(n=e.objects[I])?i(e,n,r):qe("Invalid TopoJSON object: "+I),n&&n.features||[n]}Fqe.responseType="json";const F5={dsv:hce,csv:Q9e(","),tsv:Q9e(" "),json:fce,topojson:Fqe};function mce(e,g){return arguments.length>1?(F5[e]=g,this):gg(F5,e)?F5[e]:null}function Eqe(e){const g=mce(e);return g&&g.responseType||"text"}function Dqe(e,g,i,n){g=g||{};const I=mce(g.type||"json");return I||qe("Unknown data format type: "+g.type),e=I(e,g),g.parse&&B5g(e,g.parse,i,n),gg(e,"columns")&&delete e.columns,e}function B5g(e,g,i,n){if(!e.length)return;const I=B9();i=i||I.timeParse,n=n||I.utcParse;let r=e.columns||Object.keys(e[0]),o,C,a,A,s,l;g==="auto"&&(g=xqe(e,r)),r=Object.keys(g);const c=r.map(u=>{const d=g[u];let h,f;if(d&&(d.startsWith("date:")||d.startsWith("utc:")))return h=d.split(/:(.+)?/,2),f=h[1],(f[0]==="'"&&f[f.length-1]==="'"||f[0]==='"'&&f[f.length-1]==='"')&&(f=f.slice(1,-1)),(h[0]==="utc"?n:i)(f);if(!zie[d])throw Error("Illegal format pattern: "+u+":"+d);return zie[d]});for(a=0,s=e.length,l=r.length;a{const r=g(I);return n[r]||(n[r]=1,i.push(I)),i},i.remove=I=>{const r=g(I);if(n[r]){n[r]=0;const o=i.indexOf(I);o>=0&&i.splice(o,1)}return i},i}async function E5(e,g){try{await g(e)}catch(i){e.error(i)}}const Mqe=Symbol("vega_id");let w5g=1;function U_(e){return!!(e&&eg(e))}function eg(e){return e[Mqe]}function zqe(e,g){return e[Mqe]=g,e}function li(e){const g=e===Object(e)?e:{data:e};return eg(g)?g:zqe(g,w5g++)}function pce(e){return Q_(e,li({}))}function Q_(e,g){for(const i in e)g[i]=e[i];return g}function Pqe(e,g){return zqe(g,eg(e))}function dZ(e,g){return e?g?(i,n)=>e(i,n)||eg(g(i))-eg(g(n)):(i,n)=>e(i,n)||eg(i)-eg(n):null}function _qe(e){return e&&e.constructor===hZ}function hZ(){const e=[],g=[],i=[],n=[],I=[];let r=null,o=!1;return{constructor:hZ,insert(C){const a=Vt(C),A=a.length;for(let s=0;s{d(b)&&(A[eg(b)]=-1)});for(l=0,c=e.length;l0&&(m(h,d,u.value),C.modifies(d));for(l=0,c=I.length;l{d(b)&&A[eg(b)]>0&&m(b,u.field,u.value)}),C.modifies(u.field);if(o)C.mod=g.length||n.length?a.filter(b=>A[eg(b)]>0):a.slice();else for(f in s)C.mod.push(s[f]);return(r||r==null&&(g.length||n.length))&&C.clean(!0),C}}}const D5="_:mod:_";function j_(){Object.defineProperty(this,D5,{writable:!0,value:{}})}j_.prototype={set(e,g,i,n){const I=this,r=I[e],o=I[D5];return g!=null&&g>=0?(r[g]!==i||n)&&(r[g]=i,o[g+":"+e]=-1,o[e]=-1):(r!==i||n)&&(I[e]=i,o[e]=et(i)?1+i.length:-1),I},modified(e,g){const i=this[D5];if(arguments.length){if(et(e)){for(let n=0;n=0?g+1{u instanceof Yi?(u!==this&&(g&&u.targets().add(this),r.push(u)),I.push({op:u,name:l,index:c})):n.set(l,c,u)};for(o in e)if(C=e[o],o===R5g)Vt(C).forEach(l=>{l instanceof Yi?l!==this&&(l.targets().add(this),r.push(l)):qe("Pulse parameters must be operator instances.")}),this.source=C;else if(et(C))for(n.set(o,-1,Array(a=C.length)),A=0;A{const i=Date.now();return i-g>e?(g=i,1):0})},debounce(e){const g=Oh();return this.targets().add(Oh(null,null,nce(e,i=>{const n=i.dataflow;g.receive(i),n&&n.run&&n.run()}))),g},between(e,g){let i=!1;return e.targets().add(Oh(null,null,()=>i=!0)),g.targets().add(Oh(null,null,()=>i=!1)),this.filter(()=>i)},detach(){this._filter=fs,this._targets=null}};function k5g(e,g,i,n){const I=this,r=Oh(i,n),o=function(A){A.dataflow=I;try{r.receive(A)}catch(s){I.error(s)}finally{I.run()}};let C;typeof e=="string"&&typeof document<"u"?C=document.querySelectorAll(e):C=Vt(e);const a=C.length;for(let A=0;Ag=n);return i.requests=0,i.done=()=>{--i.requests===0&&(e._pending=null,g(e))},e._pending=i}const D5g={skip:!0};function M5g(e,g,i,n,I){return(e instanceof Yi?P5g:z5g)(this,e,g,i,n,I),this}function z5g(e,g,i,n,I,r){const o=vg({},r,D5g);let C,a;Bg(i)||(i=no(i)),n===void 0?C=A=>e.touch(i(A)):Bg(n)?(a=new Yi(null,n,I,!1),C=A=>{a.evaluate(A);const s=i(A),l=a.value;_qe(l)?e.pulse(s,l,r):e.update(s,l,o)}):C=A=>e.update(i(A),n,o),g.apply(C)}function P5g(e,g,i,n,I,r){if(n===void 0)g.targets().add(i);else{const o=r||{},C=new Yi(null,_5g(i,n),I,!1);C.modified(o.force),C.rank=g.rank,g.targets().add(C),i&&(C.skip(!0),C.value=i.value,C.targets().add(i),e.connect(i,[C]))}}function _5g(e,g){return g=Bg(g)?g:no(g),e?function(i,n){const I=g(i,n);return e.skip()||(e.skip(I!==this.value).value=I),I}:g}function O5g(e){e.rank=++this._rank}function J5g(e){const g=[e];let i,n,I;for(;g.length;)if(this.rank(i=g.pop()),n=i._targets)for(I=n.length;--I>=0;)g.push(i=n[I]),i===e&&qe("Cycle detected in dataflow graph.")}const nM={},Wl=1<<0,ef=1<<1,Xu=1<<2,L5g=Wl|ef,$9e=Wl|Xu,cG=Wl|ef|Xu,q9e=1<<3,_R=1<<4,eTe=1<<5,tTe=1<<6;function rm(e,g,i){this.dataflow=e,this.stamp=g??-1,this.add=[],this.rem=[],this.mod=[],this.fields=null,this.encode=i||null}function Yj(e,g){const i=[];return qh(e,g,n=>i.push(n)),i}function gTe(e,g){const i={};return e.visit(g,n=>{i[eg(n)]=1}),n=>i[eg(n)]?null:n}function XY(e,g){return e?(i,n)=>e(i,n)&&g(i,n):g}rm.prototype={StopPropagation:nM,ADD:Wl,REM:ef,MOD:Xu,ADD_REM:L5g,ADD_MOD:$9e,ALL:cG,REFLOW:q9e,SOURCE:_R,NO_SOURCE:eTe,NO_FIELDS:tTe,fork(e){return new rm(this.dataflow).init(this,e)},clone(){const e=this.fork(cG);return e.add=e.add.slice(),e.rem=e.rem.slice(),e.mod=e.mod.slice(),e.source&&(e.source=e.source.slice()),e.materialize(cG|_R)},addAll(){let e=this;return!e.source||e.add===e.rem||!e.rem.length&&e.source.length===e.add.length||(e=new rm(this.dataflow).init(this),e.add=e.source,e.rem=[]),e},init(e,g){const i=this;return i.stamp=e.stamp,i.encode=e.encode,e.fields&&!(g&tTe)&&(i.fields=e.fields),g&Wl?(i.addF=e.addF,i.add=e.add):(i.addF=null,i.add=[]),g&ef?(i.remF=e.remF,i.rem=e.rem):(i.remF=null,i.rem=[]),g&Xu?(i.modF=e.modF,i.mod=e.mod):(i.modF=null,i.mod=[]),g&eTe?(i.srcF=null,i.source=null):(i.srcF=e.srcF,i.source=e.source,e.cleans&&(i.cleans=e.cleans)),i},runAfter(e){this.dataflow.runAfter(e)},changed(e){const g=e||cG;return g&Wl&&this.add.length||g&ef&&this.rem.length||g&Xu&&this.mod.length},reflow(e){if(e)return this.fork(cG).reflow();const g=this.add.length,i=this.source&&this.source.length;return i&&i!==g&&(this.mod=this.source,g&&this.filter(Xu,gTe(this,Wl))),this},clean(e){return arguments.length?(this.cleans=!!e,this):this.cleans},modifies(e){const g=this.fields||(this.fields={});return et(e)?e.forEach(i=>g[i]=!0):g[e]=!0,this},modified(e,g){const i=this.fields;return(g||this.mod.length)&&i?arguments.length?et(e)?e.some(n=>i[n]):i[e]:!!i:!1},filter(e,g){const i=this;return e&Wl&&(i.addF=XY(i.addF,g)),e&ef&&(i.remF=XY(i.remF,g)),e&Xu&&(i.modF=XY(i.modF,g)),e&_R&&(i.srcF=XY(i.srcF,g)),i},materialize(e){e=e||cG;const g=this;return e&Wl&&g.addF&&(g.add=Yj(g.add,g.addF),g.addF=null),e&ef&&g.remF&&(g.rem=Yj(g.rem,g.remF),g.remF=null),e&Xu&&g.modF&&(g.mod=Yj(g.mod,g.modF),g.modF=null),e&_R&&g.srcF&&(g.source=g.source.filter(g.srcF),g.srcF=null),g},visit(e,g){const i=this,n=g;if(e&_R)return qh(i.source,i.srcF,n),i;e&Wl&&qh(i.add,i.addF,n),e&ef&&qh(i.rem,i.remF,n),e&Xu&&qh(i.mod,i.modF,n);const I=i.source;if(e&q9e&&I){const r=i.add.length+i.mod.length;r===I.length||(r?qh(I,gTe(i,$9e),n):qh(I,i.srcF,n))}return i}};function bce(e,g,i,n){const I=this;let r=0;this.dataflow=e,this.stamp=g,this.fields=null,this.encode=n||null,this.pulses=i;for(const o of i)if(o.stamp===g){if(o.fields){const C=I.fields||(I.fields={});for(const a in o.fields)C[a]=1}o.changed(I.ADD)&&(r|=I.ADD),o.changed(I.REM)&&(r|=I.REM),o.changed(I.MOD)&&(r|=I.MOD)}this.changes=r}mt(bce,rm,{fork(e){const g=new rm(this.dataflow).init(this,e&this.NO_FIELDS);return e!==void 0&&(e&g.ADD&&this.visit(g.ADD,i=>g.add.push(i)),e&g.REM&&this.visit(g.REM,i=>g.rem.push(i)),e&g.MOD&&this.visit(g.MOD,i=>g.mod.push(i))),g},changed(e){return this.changes&e},modified(e){const g=this,i=g.fields;return i&&g.changes&g.MOD?et(e)?e.some(n=>i[n]):i[e]:0},filter(){qe("MultiPulse does not support filtering.")},materialize(){qe("MultiPulse does not support materialization.")},visit(e,g){const i=this,n=i.pulses,I=n.length;let r=0;if(e&i.SOURCE)for(;rn._enqueue(s,!0)),n._touched=L_(GH);let o=0,C,a,A;try{for(;n._heap.size()>0;){if(C=n._heap.pop(),C.rank!==C.qrank){n._enqueue(C,!0);continue}a=C.run(n._getPulse(C,e)),a.then?a=await a:a.async&&(I.push(a.async),a=nM),a!==nM&&C._targets&&C._targets.forEach(s=>n._enqueue(s)),++o}}catch(s){n._heap.clear(),A=s}if(n._input={},n._pulse=null,n.debug(`Pulse ${r}: ${o} operators`),A&&(n._postrun=[],n.error(A)),n._postrun.length){const s=n._postrun.sort((l,c)=>c.priority-l.priority);n._postrun=[];for(let l=0;ln.runAsync(null,()=>{s.forEach(l=>{try{l(n)}catch(c){n.error(c)}})})),n}async function Q5g(e,g,i){for(;this._running;)await this._running;const n=()=>this._running=null;return(this._running=this.evaluate(e,g,i)).then(n,n),this._running}function j5g(e,g,i){return this._pulse?Oqe(this):(this.evaluate(e,g,i),this)}function $5g(e,g,i){if(this._pulse||g)this._postrun.push({priority:i||0,callback:e});else try{e(this)}catch(n){this.error(n)}}function Oqe(e){return e.error("Dataflow already running. Use runAsync() to chain invocations."),e}function q5g(e,g){const i=e.stampI.pulse),g):this._input[e.id]||txg(this._pulse,i&&i.pulse)}function txg(e,g){return g&&g.stamp===e.stamp?g:(e=e.fork(),g&&g!==nM&&(e.source=g.source),e)}const yce={skip:!1,force:!1};function gxg(e,g){const i=g||yce;return this._pulse?this._enqueue(e):this._touched.add(e),i.skip&&e.skip(!0),this}function ixg(e,g,i){const n=i||yce;return(e.set(g)||n.force)&&this.touch(e,n),this}function nxg(e,g,i){this.touch(e,i||yce);const n=new rm(this,this._clock+(this._pulse?0:1)),I=e.pulse&&e.pulse.source||[];return n.target=e,this._input[e.id]=g.pulse(n,I),this}function Ixg(e){let g=[];return{clear:()=>g=[],size:()=>g.length,peek:()=>g[0],push:i=>(g.push(i),Jqe(g,0,g.length-1,e)),pop:()=>{const i=g.pop();let n;return g.length?(n=g[0],g[0]=i,rxg(g,0,e)):n=i,n}}}function Jqe(e,g,i,n){let I,r;const o=e[i];for(;i>g;){if(r=i-1>>1,I=e[r],n(o,I)<0){e[i]=I,i=r;continue}break}return e[i]=o}function rxg(e,g,i){const n=g,I=e.length,r=e[g];let o=(g<<1)+1,C;for(;o=0&&(o=C),e[g]=e[o],g=o,o=(g<<1)+1;return e[g]=r,Jqe(e,n,g,i)}function aB(){this.logger(qle()),this.logLevel(jle),this._clock=0,this._rank=0,this._locale=dce();try{this._loader=J_()}catch{}this._touched=L_(GH),this._input={},this._pulse=null,this._heap=Ixg((e,g)=>e.qrank-g.qrank),this._postrun=[]}function OR(e){return function(){return this._log[e].apply(this,arguments)}}aB.prototype={stamp(){return this._clock},loader(e){return arguments.length?(this._loader=e,this):this._loader},locale(e){return arguments.length?(this._locale=e,this):this._locale},logger(e){return arguments.length?(this._log=e,this):this._log},error:OR("error"),warn:OR("warn"),info:OR("info"),debug:OR("debug"),logLevel:OR("level"),cleanThreshold:1e4,add:T5g,connect:H5g,rank:O5g,rerank:J5g,pulse:nxg,touch:gxg,update:ixg,changeset:hZ,ingest:K5g,parse:Y5g,preload:F5g,request:x5g,events:k5g,on:M5g,evaluate:U5g,run:j5g,runAsync:Q5g,runAfter:$5g,_enqueue:q5g,_getPulse:exg};function Le(e,g){Yi.call(this,e,null,g)}mt(Le,Yi,{run(e){if(e.stampthis.pulse=i):g!==e.StopPropagation&&(this.pulse=g),g},evaluate(e){const g=this.marshall(e.stamp),i=this.transform(g,e);return g.clear(),i},transform(){}});const Dw={};function Lqe(e){const g=Uqe(e);return g&&g.Definition||null}function Uqe(e){return e=e&&e.toLowerCase(),gg(Dw,e)?Dw[e]:null}function*Qqe(e,g){if(g==null)for(let i of e)i!=null&&i!==""&&(i=+i)>=i&&(yield i);else{let i=-1;for(let n of e)n=g(n,++i,e),n!=null&&n!==""&&(n=+n)>=n&&(yield n)}}function Zce(e,g,i){const n=Float64Array.from(Qqe(e,i));return n.sort(md),g.map(I=>j6e(n,I))}function Gce(e,g){return Zce(e,[.25,.5,.75],g)}function vce(e,g){const i=e.length,n=BYg(e,g),I=Gce(e,g),r=(I[2]-I[0])/1.34;return 1.06*(Math.min(n,r)||n||Math.abs(I[0])||1)*Math.pow(i,-.2)}function jqe(e){const g=e.maxbins||20,i=e.base||10,n=Math.log(i),I=e.divide||[5,2];let r=e.extent[0],o=e.extent[1],C,a,A,s,l,c;const u=e.span||o-r||Math.abs(r)||1;if(e.step)C=e.step;else if(e.steps){for(s=u/g,l=0,c=e.steps.length;lg;)C*=i;for(l=0,c=I.length;l=A&&u/s<=g&&(C=s)}s=Math.log(C);const d=s>=0?0:~~(-s/n)+1,h=Math.pow(i,-d-1);return(e.nice||e.nice===void 0)&&(s=Math.floor(r/C+h)*C,r=rc);const I=e.length,r=new Float64Array(I);let o=0,C=1,a=n(e[0]),A=a,s=a+g,l;for(;C=s){for(A=(a+A)/2;o>1);oI;)e[o--]=e[n]}n=I,I=r}return e}function axg(e){return function(){return e=(1103515245*e+12345)%2147483647,e/2147483647}}function sxg(e,g){g==null&&(g=e,e=0);let i,n,I;const r={min(o){return arguments.length?(i=o||0,I=n-i,r):i},max(o){return arguments.length?(n=o||0,I=n-i,r):n},sample(){return i+Math.floor(I*ps())},pdf(o){return o===Math.floor(o)&&o>=i&&o=n?1:(C-i+1)/I},icdf(o){return o>=0&&o<=1?i-1+Math.floor(o*I):NaN}};return r.min(e).max(g)}const eet=Math.sqrt(2*Math.PI),Axg=Math.SQRT2;let JR=NaN;function q_(e,g){e=e||0,g=g??1;let i=0,n=0,I,r;if(JR===JR)i=JR,JR=NaN;else{do i=ps()*2-1,n=ps()*2-1,I=i*i+n*n;while(I===0||I>1);r=Math.sqrt(-2*Math.log(I)/I),i*=r,JR=n*r}return e+i*g}function Bce(e,g,i){i=i??1;const n=(e-(g||0))/i;return Math.exp(-.5*n*n)/(i*eet)}function eO(e,g,i){g=g||0,i=i??1;const n=(e-g)/i,I=Math.abs(n);let r;if(I>37)r=0;else{const o=Math.exp(-I*I/2);let C;I<7.07106781186547?(C=.0352624965998911*I+.700383064443688,C=C*I+6.37396220353165,C=C*I+33.912866078383,C=C*I+112.079291497871,C=C*I+221.213596169931,C=C*I+220.206867912376,r=o*C,C=.0883883476483184*I+1.75566716318264,C=C*I+16.064177579207,C=C*I+86.7807322029461,C=C*I+296.564248779674,C=C*I+637.333633378831,C=C*I+793.826512519948,C=C*I+440.413735824752,r=r/C):(C=I+.65,C=I+4/C,C=I+3/C,C=I+2/C,C=I+1/C,r=o/C/2.506628274631)}return n>0?1-r:r}function tO(e,g,i){return e<0||e>1?NaN:(g||0)+(i??1)*Axg*lxg(2*e-1)}function lxg(e){let g=-Math.log((1-e)*(1+e)),i;return g<6.25?(g-=3.125,i=-364441206401782e-35,i=-16850591381820166e-35+i*g,i=128584807152564e-32+i*g,i=11157877678025181e-33+i*g,i=-1333171662854621e-31+i*g,i=20972767875968562e-33+i*g,i=6637638134358324e-30+i*g,i=-4054566272975207e-29+i*g,i=-8151934197605472e-29+i*g,i=26335093153082323e-28+i*g,i=-12975133253453532e-27+i*g,i=-5415412054294628e-26+i*g,i=10512122733215323e-25+i*g,i=-4112633980346984e-24+i*g,i=-29070369957882005e-24+i*g,i=42347877827932404e-23+i*g,i=-13654692000834679e-22+i*g,i=-13882523362786469e-21+i*g,i=.00018673420803405714+i*g,i=-.000740702534166267+i*g,i=-.006033670871430149+i*g,i=.24015818242558962+i*g,i=1.6536545626831027+i*g):g<16?(g=Math.sqrt(g)-3.25,i=22137376921775787e-25,i=9075656193888539e-23+i*g,i=-27517406297064545e-23+i*g,i=18239629214389228e-24+i*g,i=15027403968909828e-22+i*g,i=-4013867526981546e-21+i*g,i=29234449089955446e-22+i*g,i=12475304481671779e-21+i*g,i=-47318229009055734e-21+i*g,i=6828485145957318e-20+i*g,i=24031110387097894e-21+i*g,i=-.0003550375203628475+i*g,i=.0009532893797373805+i*g,i=-.0016882755560235047+i*g,i=.002491442096107851+i*g,i=-.003751208507569241+i*g,i=.005370914553590064+i*g,i=1.0052589676941592+i*g,i=3.0838856104922208+i*g):Number.isFinite(g)?(g=Math.sqrt(g)-5,i=-27109920616438573e-27,i=-2555641816996525e-25+i*g,i=15076572693500548e-25+i*g,i=-3789465440126737e-24+i*g,i=761570120807834e-23+i*g,i=-1496002662714924e-23+i*g,i=2914795345090108e-23+i*g,i=-6771199775845234e-23+i*g,i=22900482228026655e-23+i*g,i=-99298272942317e-20+i*g,i=4526062597223154e-21+i*g,i=-1968177810553167e-20+i*g,i=7599527703001776e-20+i*g,i=-.00021503011930044477+i*g,i=-.00013871931833623122+i*g,i=1.0103004648645344+i*g,i=4.849906401408584+i*g):i=1/0,i*e}function wce(e,g){let i,n;const I={mean(r){return arguments.length?(i=r||0,I):i},stdev(r){return arguments.length?(n=r??1,I):n},sample:()=>q_(i,n),pdf:r=>Bce(r,i,n),cdf:r=>eO(r,i,n),icdf:r=>tO(r,i,n)};return I.mean(e).stdev(g)}function Sce(e,g){const i=wce();let n=0;const I={data(r){return arguments.length?(e=r,n=r?r.length:0,I.bandwidth(g)):e},bandwidth(r){return arguments.length?(g=r,!g&&e&&(g=vce(e)),I):g},sample(){return e[~~(ps()*n)]+g*i.sample()},pdf(r){let o=0,C=0;for(;CRce(i,n),pdf:r=>Vce(r,i,n),cdf:r=>Wce(r,i,n),icdf:r=>Xce(r,i,n)};return I.mean(e).stdev(g)}function get(e,g){let i=0,n;function I(o){const C=[];let a=0,A;for(A=0;A=g&&e<=i?1/(i-g):0}function Nce(e,g,i){return i==null&&(i=g??1,g=0),ei?1:(e-g)/(i-g)}function kce(e,g,i){return i==null&&(i=g??1,g=0),e>=0&&e<=1?g+e*(i-g):NaN}function iet(e,g){let i,n;const I={min(r){return arguments.length?(i=r||0,I):i},max(r){return arguments.length?(n=r??1,I):n},sample:()=>Tce(i,n),pdf:r=>Hce(r,i,n),cdf:r=>Nce(r,i,n),icdf:r=>kce(r,i,n)};return g==null&&(g=e??1,e=0),I.min(e).max(g)}function Yce(e,g,i){let n=0,I=0;for(const r of e){const o=i(r);g(r)==null||o==null||isNaN(o)||(n+=(o-n)/++I)}return{coef:[n],predict:()=>n,rSquared:0}}function SH(e,g,i,n){const I=n-e*e,r=Math.abs(I)<1e-24?0:(i-e*g)/I;return[g-r*e,r]}function gO(e,g,i,n){e=e.filter(u=>{let d=g(u),h=i(u);return d!=null&&(d=+d)>=d&&h!=null&&(h=+h)>=h}),n&&e.sort((u,d)=>g(u)-g(d));const I=e.length,r=new Float64Array(I),o=new Float64Array(I);let C=0,a=0,A=0,s,l,c;for(c of e)r[C]=s=+g(c),o[C]=l=+i(c),++C,a+=(s-a)/C,A+=(l-A)/C;for(C=0;C=r&&o!=null&&(o=+o)>=o&&n(r,o,++I)}function mS(e,g,i,n,I){let r=0,o=0;return RH(e,g,i,(C,a)=>{const A=a-I(C),s=a-n;r+=A*A,o+=s*s}),1-r/o}function Kce(e,g,i){let n=0,I=0,r=0,o=0,C=0;RH(e,g,i,(s,l)=>{++C,n+=(s-n)/C,I+=(l-I)/C,r+=(s*l-r)/C,o+=(s*s-o)/C});const a=SH(n,I,r,o),A=s=>a[0]+a[1]*s;return{coef:a,predict:A,rSquared:mS(e,g,i,I,A)}}function net(e,g,i){let n=0,I=0,r=0,o=0,C=0;RH(e,g,i,(s,l)=>{++C,s=Math.log(s),n+=(s-n)/C,I+=(l-I)/C,r+=(s*l-r)/C,o+=(s*s-o)/C});const a=SH(n,I,r,o),A=s=>a[0]+a[1]*Math.log(s);return{coef:a,predict:A,rSquared:mS(e,g,i,I,A)}}function Iet(e,g,i){const[n,I,r,o]=gO(e,g,i);let C=0,a=0,A=0,s=0,l=0,c,u,d;RH(e,g,i,(b,p)=>{c=n[l++],u=Math.log(p),d=c*p,C+=(p*u-C)/l,a+=(d-a)/l,A+=(d*u-A)/l,s+=(c*d-s)/l});const[h,f]=SH(a/o,C/o,A/o,s/o),m=b=>Math.exp(h+f*(b-r));return{coef:[Math.exp(h-f*r),f],predict:m,rSquared:mS(e,g,i,o,m)}}function ret(e,g,i){let n=0,I=0,r=0,o=0,C=0,a=0;RH(e,g,i,(l,c)=>{const u=Math.log(l),d=Math.log(c);++a,n+=(u-n)/a,I+=(d-I)/a,r+=(u*d-r)/a,o+=(u*u-o)/a,C+=(c-C)/a});const A=SH(n,I,r,o),s=l=>A[0]*Math.pow(l,A[1]);return A[0]=Math.exp(A[0]),{coef:A,predict:s,rSquared:mS(e,g,i,C,s)}}function xce(e,g,i){const[n,I,r,o]=gO(e,g,i),C=n.length;let a=0,A=0,s=0,l=0,c=0,u,d,h,f;for(u=0;u(G=G-r,p*G*G+y*G+Z+o);return{coef:[Z-y*r+p*r*r+o,y-2*p*r,p],predict:v,rSquared:mS(e,g,i,o,v)}}function oet(e,g,i,n){if(n===0)return Yce(e,g,i);if(n===1)return Kce(e,g,i);if(n===2)return xce(e,g,i);const[I,r,o,C]=gO(e,g,i),a=I.length,A=[],s=[],l=n+1;let c,u,d,h,f;for(c=0;c{p-=o;let y=C+m[0]+m[1]*p+m[2]*p*p;for(c=3;c=0;--r)for(C=g[r],a=1,I[r]+=C,o=1;o<=r;++o)a*=(r+1-o)/o,I[r-o]+=C*Math.pow(i,o)*a;return I[0]+=n,I}function uxg(e){const g=e.length-1,i=[];let n,I,r,o,C;for(n=0;nMath.abs(e[n][o])&&(o=I);for(r=n;r=n;r--)e[r][I]-=e[r][n]*e[n][I]/e[n][n]}for(I=g-1;I>=0;--I){for(C=0,r=I+1;rI[p]-m?b:p;let Z=0,v=0,G=0,B=0,S=0;const R=1/Math.abs(I[y]-m||1);for(let W=b;W<=p;++W){const V=I[W],X=r[W],N=dxg(Math.abs(m-V)*R)*c[W],Y=V*N;Z+=N,v+=Y,G+=X*N,B+=X*Y,S+=V*Y}const[w,T]=SH(v/Z,G/Z,B/Z,S/Z);s[f]=w+T*m,l[f]=Math.abs(r[f]-s[f]),hxg(I,f+1,d)}if(u===iTe)break;const h=$6e(l);if(Math.abs(h)=1?nTe:(b=1-m*m)*b}return fxg(I,s,o,C)}function dxg(e){return(e=1-e*e*e)*e*e}function hxg(e,g,i){const n=e[g];let I=i[0],r=i[1]+1;if(!(r>=e.length))for(;g>I&&e[r]-n<=n-e[I];)i[0]=++I,i[1]=r,++r}function fxg(e,g,i,n){const I=e.length,r=[];let o=0,C=0,a=[],A;for(;o[h,e(h)],r=g[0],o=g[1],C=o-r,a=C/n,A=[I(r)],s=[];if(i===n){for(let h=1;h0;)s.push(I(r+h/i*C))}let l=A[0],c=s[s.length-1];const u=1/C,d=pxg(l[1],s);for(;c;){const h=I((l[0]+c[0])/2);h[0]-l[0]>=a&&bxg(l,h,c,u,d)>mxg?s.push(h):(l=c,A.push(c),s.pop()),c=s[s.length-1]}return A}function pxg(e,g){let i=e,n=e;const I=g.length;for(let r=0;rn&&(n=o)}return 1/(n-i)}function bxg(e,g,i,n,I){const r=Math.atan2(I*(i[1]-e[1]),n*(i[0]-e[0])),o=Math.atan2(I*(g[1]-e[1]),n*(g[0]-e[0]));return Math.abs(r-o)}function yxg(e){return g=>{const i=e.length;let n=1,I=String(e[0](g));for(;n{},Zxg={init:Kj,add:Kj,rem:Kj,idx:0},w9={values:{init:e=>e.cell.store=!0,value:e=>e.cell.data.values(),idx:-1},count:{value:e=>e.cell.num},__count__:{value:e=>e.missing+e.valid},missing:{value:e=>e.missing},valid:{value:e=>e.valid},sum:{init:e=>e.sum=0,value:e=>e.sum,add:(e,g)=>e.sum+=+g,rem:(e,g)=>e.sum-=g},product:{init:e=>e.product=1,value:e=>e.valid?e.product:void 0,add:(e,g)=>e.product*=g,rem:(e,g)=>e.product/=g},mean:{init:e=>e.mean=0,value:e=>e.valid?e.mean:void 0,add:(e,g)=>(e.mean_d=g-e.mean,e.mean+=e.mean_d/e.valid),rem:(e,g)=>(e.mean_d=g-e.mean,e.mean-=e.valid?e.mean_d/e.valid:e.mean)},average:{value:e=>e.valid?e.mean:void 0,req:["mean"],idx:1},variance:{init:e=>e.dev=0,value:e=>e.valid>1?e.dev/(e.valid-1):void 0,add:(e,g)=>e.dev+=e.mean_d*(g-e.mean),rem:(e,g)=>e.dev-=e.mean_d*(g-e.mean),req:["mean"],idx:1},variancep:{value:e=>e.valid>1?e.dev/e.valid:void 0,req:["variance"],idx:2},stdev:{value:e=>e.valid>1?Math.sqrt(e.dev/(e.valid-1)):void 0,req:["variance"],idx:2},stdevp:{value:e=>e.valid>1?Math.sqrt(e.dev/e.valid):void 0,req:["variance"],idx:2},stderr:{value:e=>e.valid>1?Math.sqrt(e.dev/(e.valid*(e.valid-1))):void 0,req:["variance"],idx:2},distinct:{value:e=>e.cell.data.distinct(e.get),req:["values"],idx:3},ci0:{value:e=>e.cell.data.ci0(e.get),req:["values"],idx:3},ci1:{value:e=>e.cell.data.ci1(e.get),req:["values"],idx:3},median:{value:e=>e.cell.data.q2(e.get),req:["values"],idx:3},q1:{value:e=>e.cell.data.q1(e.get),req:["values"],idx:3},q3:{value:e=>e.cell.data.q3(e.get),req:["values"],idx:3},min:{init:e=>e.min=void 0,value:e=>e.min=Number.isNaN(e.min)?e.cell.data.min(e.get):e.min,add:(e,g)=>{(g{g<=e.min&&(e.min=NaN)},req:["values"],idx:4},max:{init:e=>e.max=void 0,value:e=>e.max=Number.isNaN(e.max)?e.cell.data.max(e.get):e.max,add:(e,g)=>{(g>e.max||e.max===void 0)&&(e.max=g)},rem:(e,g)=>{g>=e.max&&(e.max=NaN)},req:["values"],idx:4},argmin:{init:e=>e.argmin=void 0,value:e=>e.argmin||e.cell.data.argmin(e.get),add:(e,g,i)=>{g{g<=e.min&&(e.argmin=void 0)},req:["min","values"],idx:3},argmax:{init:e=>e.argmax=void 0,value:e=>e.argmax||e.cell.data.argmax(e.get),add:(e,g,i)=>{g>e.max&&(e.argmax=i)},rem:(e,g)=>{g>=e.max&&(e.argmax=void 0)},req:["max","values"],idx:3}},VH=Object.keys(w9).filter(e=>e!=="__count__");function Gxg(e,g){return i=>vg({name:e,out:i||e},Zxg,g)}[...VH,"__count__"].forEach(e=>{w9[e]=Gxg(e,w9[e])});function set(e,g){return w9[e](g)}function Aet(e,g){return e.idx-g.idx}function vxg(e){const g={};e.forEach(n=>g[n.name]=n);const i=n=>{n.req&&n.req.forEach(I=>{g[I]||i(g[I]=w9[I]())})};return e.forEach(i),Object.values(g).sort(Aet)}function Bxg(){this.valid=0,this.missing=0,this._ops.forEach(e=>e.init(this))}function wxg(e,g){if(e==null||e===""){++this.missing;return}e===e&&(++this.valid,this._ops.forEach(i=>i.add(this,e,g)))}function Sxg(e,g){if(e==null||e===""){--this.missing;return}e===e&&(--this.valid,this._ops.forEach(i=>i.rem(this,e,g)))}function Rxg(e){return this._out.forEach(g=>e[g.out]=g.value(this)),e}function cet(e,g){const i=g||io,n=vxg(e),I=e.slice().sort(Aet);function r(o){this._ops=n,this._out=I,this.cell=o,this.init()}return r.prototype.init=Bxg,r.prototype.add=wxg,r.prototype.rem=Sxg,r.prototype.set=Rxg,r.prototype.get=i,r.fields=e.map(o=>o.out),r}function Fce(e){this._key=e?HC(e):eg,this.reset()}const vr=Fce.prototype;vr.reset=function(){this._add=[],this._rem=[],this._ext=null,this._get=null,this._q=null};vr.add=function(e){this._add.push(e)};vr.rem=function(e){this._rem.push(e)};vr.values=function(){if(this._get=null,this._rem.length===0)return this._add;const e=this._add,g=this._rem,i=this._key,n=e.length,I=g.length,r=Array(n-I),o={};let C,a,A;for(C=0;C=0;)r=e(g[n])+"",gg(i,r)||(i[r]=1,++I);return I};vr.extent=function(e){if(this._get!==e||!this._ext){const g=this.values(),i=H6e(g,e);this._ext=[g[i[0]],g[i[1]]],this._get=e}return this._ext};vr.argmin=function(e){return this.extent(e)[0]||{}};vr.argmax=function(e){return this.extent(e)[1]||{}};vr.min=function(e){const g=this.extent(e)[0];return g!=null?e(g):void 0};vr.max=function(e){const g=this.extent(e)[1];return g!=null?e(g):void 0};vr.quartile=function(e){return(this._get!==e||!this._q)&&(this._q=Gce(this.values(),e),this._get=e),this._q};vr.q1=function(e){return this.quartile(e)[0]};vr.q2=function(e){return this.quartile(e)[1]};vr.q3=function(e){return this.quartile(e)[2]};vr.ci=function(e){return(this._get!==e||!this._ci)&&(this._ci=$qe(this.values(),1e3,.05,e),this._get=e),this._ci};vr.ci0=function(e){return this.ci(e)[0]};vr.ci1=function(e){return this.ci(e)[1]};function pm(e){Le.call(this,null,e),this._adds=[],this._mods=[],this._alen=0,this._mlen=0,this._drop=!0,this._cross=!1,this._dims=[],this._dnames=[],this._measures=[],this._countOnly=!1,this._counts=null,this._prev=null,this._inputs=null,this._outputs=null}pm.Definition={type:"Aggregate",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:VH},{name:"fields",type:"field",null:!0,array:!0},{name:"as",type:"string",null:!0,array:!0},{name:"drop",type:"boolean",default:!0},{name:"cross",type:"boolean",default:!1},{name:"key",type:"field"}]};mt(pm,Le,{transform(e,g){const i=this,n=g.fork(g.NO_SOURCE|g.NO_FIELDS),I=e.modified();return i.stamp=n.stamp,i.value&&(I||g.modified(i._inputs,!0))?(i._prev=i.value,i.value=I?i.init(e):Object.create(null),g.visit(g.SOURCE,r=>i.add(r))):(i.value=i.value||i.init(e),g.visit(g.REM,r=>i.rem(r)),g.visit(g.ADD,r=>i.add(r))),n.modifies(i._outputs),i._drop=e.drop!==!1,e.cross&&i._dims.length>1&&(i._drop=!1,i.cross()),g.clean()&&i._drop&&n.clean(!0).runAfter(()=>this.clean()),i.changes(n)},cross(){const e=this,g=e.value,i=e._dnames,n=i.map(()=>({})),I=i.length;function r(C){let a,A,s,l;for(a in C)for(s=C[a].tuple,A=0;A{const m=xn(f);return I(f),i.push(m),m}),this.cellkey=e.key?e.key:Pie(this._dims),this._countOnly=!0,this._counts=[],this._measures=[];const r=e.fields||[null],o=e.ops||["count"],C=e.as||[],a=r.length,A={};let s,l,c,u,d,h;for(a!==o.length&&qe("Unmatched number of fields and aggregate ops."),h=0;hcet(f,f.field)),Object.create(null)},cellkey:Pie(),cell(e,g){let i=this.value[e];return i?i.num===0&&this._drop&&i.stamp{const l=n(s);s[C]=l,s[a]=l==null?null:I+r*(1+(l-I)/r)}:s=>s[C]=n(s)),g.modifies(i?o:C)},_bins(e){if(this.value&&!e.modified())return this.value;const g=e.field,i=jqe(e),n=i.step;let I=i.start,r=I+Math.ceil((i.stop-I)/n)*n,o,C;(o=e.anchor)!=null&&(C=o-(I+n*Math.floor((o-I)/n)),I+=C,r+=C);const a=function(A){let s=_r(g(A));return s==null?null:sr?1/0:(s=Math.max(I,Math.min(s,r-n)),I+n*Math.floor(Vxg+(s-I)/n))};return a.start=I,a.stop=i.stop,a.step=n,this.value=PC(a,Ur(g),e.name||"bin_"+xn(g))}});function uet(e,g,i){const n=e;let I=g||[],r=i||[],o={},C=0;return{add:a=>r.push(a),remove:a=>o[n(a)]=++C,size:()=>I.length,data:(a,A)=>(C&&(I=I.filter(s=>!o[n(s)]),o={},C=0),A&&a&&I.sort(a),r.length&&(I=a?F6e(a,I,r.sort(a)):I.concat(r),r=[]),I)}}function Dce(e){Le.call(this,[],e)}Dce.Definition={type:"Collect",metadata:{source:!0},params:[{name:"sort",type:"compare"}]};mt(Dce,Le,{transform(e,g){const i=g.fork(g.ALL),n=uet(eg,this.value,i.materialize(i.ADD).add),I=e.sort,r=g.changed()||I&&(e.modified("sort")||g.modified(I.fields));return i.visit(i.REM,n.remove),this.modified(r),this.value=i.source=n.data(dZ(I),r),g.source&&g.source.root&&(this.value.root=g.source.root),i}});function det(e){Yi.call(this,null,Wxg,e)}mt(det,Yi);function Wxg(e){return this.value&&!e.modified()?this.value:ice(e.fields,e.orders)}function Mce(e){Le.call(this,null,e)}Mce.Definition={type:"CountPattern",metadata:{generates:!0,changes:!0},params:[{name:"field",type:"field",required:!0},{name:"case",type:"enum",values:["upper","lower","mixed"],default:"mixed"},{name:"pattern",type:"string",default:'[\\w"]+'},{name:"stopwords",type:"string",default:""},{name:"as",type:"string",array:!0,length:2,default:["text","count"]}]};function Xxg(e,g,i){switch(g){case"upper":e=e.toUpperCase();break;case"lower":e=e.toLowerCase();break}return e.match(i)}mt(Mce,Le,{transform(e,g){const i=l=>c=>{for(var u=Xxg(C(c),e.case,r)||[],d,h=0,f=u.length;hI[l]=1+(I[l]||0)),s=i(l=>I[l]-=1);return n?g.visit(g.SOURCE,A):(g.visit(g.ADD,A),g.visit(g.REM,s)),this._finish(g,a)},_parameterCheck(e,g){let i=!1;return(e.modified("stopwords")||!this._stop)&&(this._stop=new RegExp("^"+(e.stopwords||"")+"$","i"),i=!0),(e.modified("pattern")||!this._match)&&(this._match=new RegExp(e.pattern||"[\\w']+","g"),i=!0),(e.modified("field")||g.modified(e.field.fields))&&(i=!0),i&&(this._counts={}),i},_finish(e,g){const i=this._counts,n=this._tuples||(this._tuples={}),I=g[0],r=g[1],o=e.fork(e.NO_SOURCE|e.NO_FIELDS);let C,a,A;for(C in i)a=n[C],A=i[C]||0,!a&&A?(n[C]=a=li({}),a[I]=C,a[r]=A,o.add.push(a)):A===0?(a&&o.rem.push(a),i[C]=null,n[C]=null):a[r]!==A&&(a[r]=A,o.mod.push(a));return o.modifies(g)}});function zce(e){Le.call(this,null,e)}zce.Definition={type:"Cross",metadata:{generates:!0},params:[{name:"filter",type:"expr"},{name:"as",type:"string",array:!0,length:2,default:["a","b"]}]};mt(zce,Le,{transform(e,g){const i=g.fork(g.NO_SOURCE),n=e.as||["a","b"],I=n[0],r=n[1],o=!this.value||g.changed(g.ADD_REM)||e.modified("as")||e.modified("filter");let C=this.value;return o?(C&&(i.rem=C),C=g.materialize(g.SOURCE).source,i.add=this.value=Txg(C,I,r,e.filter||fs)):i.mod=C,i.source=this.value,i.modifies(n)}});function Txg(e,g,i,n){for(var I=[],r={},o=e.length,C=0,a,A;Chet(r,g))):typeof n[I]===rTe&&n[I](e[I]);return n}function Pce(e){Le.call(this,null,e)}const fet=[{key:{function:"normal"},params:[{name:"mean",type:"number",default:0},{name:"stdev",type:"number",default:1}]},{key:{function:"lognormal"},params:[{name:"mean",type:"number",default:0},{name:"stdev",type:"number",default:1}]},{key:{function:"uniform"},params:[{name:"min",type:"number",default:0},{name:"max",type:"number",default:1}]},{key:{function:"kde"},params:[{name:"field",type:"field",required:!0},{name:"from",type:"data"},{name:"bandwidth",type:"number",default:0}]}],kxg={key:{function:"mixture"},params:[{name:"distributions",type:"param",array:!0,params:fet},{name:"weights",type:"number",array:!0}]};Pce.Definition={type:"Density",metadata:{generates:!0},params:[{name:"extent",type:"number",array:!0,length:2},{name:"steps",type:"number"},{name:"minsteps",type:"number",default:25},{name:"maxsteps",type:"number",default:200},{name:"method",type:"string",default:"pdf",values:["pdf","cdf"]},{name:"distribution",type:"param",params:fet.concat(kxg)},{name:"as",type:"string",array:!0,default:["value","density"]}]};mt(Pce,Le,{transform(e,g){const i=g.fork(g.NO_SOURCE|g.NO_FIELDS);if(!this.value||g.changed()||e.modified()){const n=het(e.distribution,Yxg(g)),I=e.steps||e.minsteps||25,r=e.steps||e.maxsteps||200;let o=e.method||"pdf";o!=="pdf"&&o!=="cdf"&&qe("Invalid density method: "+o),!e.extent&&!n.data&&qe("Missing density extent parameter."),o=n[o];const C=e.as||["value","density"],a=e.extent||kc(n.data()),A=iO(o,a,I,r).map(s=>{const l={};return l[C[0]]=s[0],l[C[1]]=s[1],li(l)});this.value&&(i.rem=this.value),this.value=i.add=i.source=A}return i}});function Yxg(e){return()=>e.materialize(e.SOURCE).source}function met(e,g){return e?e.map((i,n)=>g[n]||xn(i)):null}function _ce(e,g,i){const n=[],I=l=>l(a);let r,o,C,a,A,s;if(g==null)n.push(e.map(i));else for(r={},o=0,C=e.length;ovH(kc(e,g))/30;mt(Oce,Le,{transform(e,g){if(this.value&&!(e.modified()||g.changed()))return g;const i=g.materialize(g.SOURCE).source,n=_ce(g.source,e.groupby,io),I=e.smooth||!1,r=e.field,o=e.step||Kxg(i,r),C=dZ((d,h)=>r(d)-r(h)),a=e.as||pet,A=n.length;let s=1/0,l=-1/0,c=0,u;for(;cl&&(l=h),d[++u][a]=h}return this.value={start:s,stop:l,step:o},g.reflow(!0).modifies(a)}});function bet(e){Yi.call(this,null,xxg,e),this.modified(!0)}mt(bet,Yi);function xxg(e){const g=e.expr;return this.value&&!e.modified("expr")?this.value:PC(i=>g(i,e),Ur(g),xn(g))}function Jce(e){Le.call(this,[void 0,void 0],e)}Jce.Definition={type:"Extent",metadata:{},params:[{name:"field",type:"field",required:!0}]};mt(Jce,Le,{transform(e,g){const i=this.value,n=e.field,I=g.changed()||g.modified(n.fields)||e.modified("field");let r=i[0],o=i[1];if((I||r==null)&&(r=1/0,o=-1/0),g.visit(I?g.SOURCE:g.ADD,C=>{const a=_r(n(C));a!=null&&(ao&&(o=a))}),!Number.isFinite(r)||!Number.isFinite(o)){let C=xn(n);C&&(C=` for field "${C}"`),g.dataflow.warn(`Infinite extent${C}: [${r}, ${o}]`),r=o=void 0}this.value=[r,o]}});function Lce(e,g){Yi.call(this,e),this.parent=g,this.count=0}mt(Lce,Yi,{connect(e){return this.detachSubflow=e.detachSubflow,this.targets().add(e),e.source=this},add(e){this.count+=1,this.value.add.push(e)},rem(e){this.count-=1,this.value.rem.push(e)},mod(e){this.value.mod.push(e)},init(e){this.value.init(e,e.NO_SOURCE)},evaluate(){return this.value}});function nO(e){Le.call(this,{},e),this._keys=cS();const g=this._targets=[];g.active=0,g.forEach=i=>{for(let n=0,I=g.active;nn&&n.count>0);this.initTargets(i)}},initTargets(e){const g=this._targets,i=g.length,n=e?e.length:0;let I=0;for(;Ithis.subflow(a,I,g);return this._group=e.group||{},this.initTargets(),g.visit(g.REM,a=>{const A=eg(a),s=r.get(A);s!==void 0&&(r.delete(A),C(s).rem(a))}),g.visit(g.ADD,a=>{const A=n(a);r.set(eg(a),A),C(A).add(a)}),o||g.modified(n.fields)?g.visit(g.MOD,a=>{const A=eg(a),s=r.get(A),l=n(a);s===l?C(l).mod(a):(r.set(A,l),C(s).rem(a),C(l).add(a))}):g.changed(g.MOD)&&g.visit(g.MOD,a=>{C(r.get(eg(a))).mod(a)}),o&&g.visit(g.REFLOW,a=>{const A=eg(a),s=r.get(A),l=n(a);s!==l&&(r.set(A,l),C(s).rem(a),C(l).add(a))}),g.clean()?i.runAfter(()=>{this.clean(),r.clean()}):r.empty>i.cleanThreshold&&i.runAfter(r.clean),g}});function yet(e){Yi.call(this,null,Fxg,e)}mt(yet,Yi);function Fxg(e){return this.value&&!e.modified()?this.value:et(e.name)?Vt(e.name).map(g=>HC(g)):HC(e.name,e.as)}function Uce(e){Le.call(this,cS(),e)}Uce.Definition={type:"Filter",metadata:{changes:!0},params:[{name:"expr",type:"expr",required:!0}]};mt(Uce,Le,{transform(e,g){const i=g.dataflow,n=this.value,I=g.fork(),r=I.add,o=I.rem,C=I.mod,a=e.expr;let A=!0;g.visit(g.REM,l=>{const c=eg(l);n.has(c)?n.delete(c):o.push(l)}),g.visit(g.ADD,l=>{a(l,e)?r.push(l):n.set(eg(l),1)});function s(l){const c=eg(l),u=a(l,e),d=n.get(c);u&&d?(n.delete(c),r.push(l)):!u&&!d?(n.set(c,1),o.push(l)):A&&u&&!d&&C.push(l)}return g.visit(g.MOD,s),e.modified()&&(A=!1,g.visit(g.REFLOW,s)),n.empty>i.cleanThreshold&&i.runAfter(n.clean),I}});function Qce(e){Le.call(this,[],e)}Qce.Definition={type:"Flatten",metadata:{generates:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"index",type:"string"},{name:"as",type:"string",array:!0}]};mt(Qce,Le,{transform(e,g){const i=g.fork(g.NO_SOURCE),n=e.fields,I=met(n,e.as||[]),r=e.index||null,o=I.length;return i.rem=this.value,g.visit(g.SOURCE,C=>{const a=n.map(d=>d(C)),A=a.reduce((d,h)=>Math.max(d,h.length),0);let s=0,l,c,u;for(;s{for(let s=0,l;so[n]=i(o,e))}});function Zet(e){Le.call(this,[],e)}mt(Zet,Le,{transform(e,g){const i=g.fork(g.ALL),n=e.generator;let I=this.value,r=e.size-I.length,o,C,a;if(r>0){for(o=[];--r>=0;)o.push(a=li(n(e))),I.push(a);i.add=i.add.length?i.materialize(i.ADD).add.concat(o):o}else C=I.slice(0,-r),i.rem=i.rem.length?i.materialize(i.REM).rem.concat(C):C,I=I.slice(-r);return i.source=this.value=I,i}});const TY={value:"value",median:$6e,mean:XYg,min:Hie,max:tb},Exg=[];function qce(e){Le.call(this,[],e)}qce.Definition={type:"Impute",metadata:{changes:!0},params:[{name:"field",type:"field",required:!0},{name:"key",type:"field",required:!0},{name:"keyvals",array:!0},{name:"groupby",type:"field",array:!0},{name:"method",type:"enum",default:"value",values:["value","mean","median","max","min"]},{name:"value",default:0}]};function Dxg(e){var g=e.method||TY.value,i;if(TY[g]==null)qe("Unrecognized imputation method: "+g);else return g===TY.value?(i=e.value!==void 0?e.value:0,()=>i):TY[g]}function Mxg(e){const g=e.field;return i=>i?g(i):NaN}mt(qce,Le,{transform(e,g){var i=g.fork(g.ALL),n=Dxg(e),I=Mxg(e),r=xn(e.field),o=xn(e.key),C=(e.groupby||[]).map(xn),a=zxg(g.source,e.groupby,e.key,e.keyvals),A=[],s=this.value,l=a.domain.length,c,u,d,h,f,m,b,p,y,Z;for(f=0,p=a.length;fm(f),r=[],o=n?n.slice():[],C={},a={},A,s,l,c,u,d,h,f;for(o.forEach((m,b)=>C[m]=b+1),c=0,h=e.length;ci.add(r))):(I=i.value=i.value||this.init(e),g.visit(g.REM,r=>i.rem(r)),g.visit(g.ADD,r=>i.add(r))),i.changes(),g.visit(g.SOURCE,r=>{vg(r,I[i.cellkey(r)].tuple)}),g.reflow(n).modifies(this._outputs)},changes(){const e=this._adds,g=this._mods;let i,n;for(i=0,n=this._alen;i{const d=Sce(u,o)[C],h=e.counts?u.length:1,f=s||kc(u);iO(d,f,l,c).forEach(m=>{const b={};for(let p=0;p(this._pending=Vt(I.data),r=>r.touch(this)))}:i.request(e.url,e.format).then(n=>xj(this,g,Vt(n.data)))}});function _xg(e){return e.modified("async")&&!(e.modified("values")||e.modified("url")||e.modified("format"))}function xj(e,g,i){i.forEach(li);const n=g.fork(g.NO_FIELDS&g.NO_SOURCE);return n.rem=e.value,e.value=n.source=n.add=i,e._pending=null,n.rem.length&&n.clean(!0),n}function gue(e){Le.call(this,{},e)}gue.Definition={type:"Lookup",metadata:{modifies:!0},params:[{name:"index",type:"index",params:[{name:"from",type:"data",required:!0},{name:"key",type:"field",required:!0}]},{name:"values",type:"field",array:!0},{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0},{name:"default",default:null}]};mt(gue,Le,{transform(e,g){const i=e.fields,n=e.index,I=e.values,r=e.default==null?null:e.default,o=e.modified(),C=i.length;let a=o?g.SOURCE:g.ADD,A=g,s=e.as,l,c,u;return I?(c=I.length,C>1&&!s&&qe('Multi-field lookup requires explicit "as" parameter.'),s&&s.length!==C*c&&qe('The "as" parameter has too few output field names.'),s=s||I.map(xn),l=function(d){for(var h=0,f=0,m,b;hg.modified(d.fields)),a|=u?g.MOD:0),g.visit(a,l),A.modifies(s)}});function Bet(e){Yi.call(this,null,Oxg,e)}mt(Bet,Yi);function Oxg(e){if(this.value&&!e.modified())return this.value;const g=e.extents,i=g.length;let n=1/0,I=-1/0,r,o;for(r=0;rI&&(I=o[1]);return[n,I]}function wet(e){Yi.call(this,null,Jxg,e)}mt(wet,Yi);function Jxg(e){return this.value&&!e.modified()?this.value:e.values.reduce((g,i)=>g.concat(i),[])}function Ret(e){Le.call(this,null,e)}mt(Ret,Le,{transform(e,g){return this.modified(e.modified()),this.value=e,g.fork(g.NO_SOURCE|g.NO_FIELDS)}});function iue(e){pm.call(this,e)}iue.Definition={type:"Pivot",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"field",type:"field",required:!0},{name:"value",type:"field",required:!0},{name:"op",type:"enum",values:VH,default:"sum"},{name:"limit",type:"number",default:0},{name:"key",type:"field"}]};mt(iue,pm,{_transform:pm.prototype.transform,transform(e,g){return this._transform(Lxg(e,g),g)}});function Lxg(e,g){const i=e.field,n=e.value,I=(e.op==="count"?"__count__":e.op)||"sum",r=Ur(i).concat(Ur(n)),o=Qxg(i,e.limit||0,g);return g.changed()&&e.set("__pivot__",null,null,!0),{key:e.key,groupby:e.groupby,ops:o.map(()=>I),fields:o.map(C=>Uxg(C,i,n,r)),as:o.map(C=>C+""),modified:e.modified.bind(e)}}function Uxg(e,g,i,n){return PC(I=>g(I)===e?i(I):NaN,n,e+"")}function Qxg(e,g,i){const n={},I=[];return i.visit(i.SOURCE,r=>{const o=e(r);n[o]||(n[o]=1,I.push(o))}),I.sort(D_),g?I.slice(0,g):I}function Vet(e){nO.call(this,e)}mt(Vet,nO,{transform(e,g){const i=e.subflow,n=e.field,I=r=>this.subflow(eg(r),i,g,r);return(e.modified("field")||n&&g.modified(Ur(n)))&&qe("PreFacet does not support field modification."),this.initTargets(),n?(g.visit(g.MOD,r=>{const o=I(r);n(r).forEach(C=>o.mod(C))}),g.visit(g.ADD,r=>{const o=I(r);n(r).forEach(C=>o.add(li(C)))}),g.visit(g.REM,r=>{const o=I(r);n(r).forEach(C=>o.rem(C))})):(g.visit(g.MOD,r=>I(r).mod(r)),g.visit(g.ADD,r=>I(r).add(r)),g.visit(g.REM,r=>I(r).rem(r))),g.clean()&&g.runAfter(()=>this.clean()),g}});function nue(e){Le.call(this,null,e)}nue.Definition={type:"Project",metadata:{generates:!0,changes:!0},params:[{name:"fields",type:"field",array:!0},{name:"as",type:"string",null:!0,array:!0}]};mt(nue,Le,{transform(e,g){const i=g.fork(g.NO_SOURCE),n=e.fields,I=met(e.fields,e.as||[]),r=n?(C,a)=>jxg(C,a,n,I):Q_;let o;return this.value?o=this.value:(g=g.addAll(),o=this.value={}),g.visit(g.REM,C=>{const a=eg(C);i.rem.push(o[a]),o[a]=null}),g.visit(g.ADD,C=>{const a=r(C,li({}));o[eg(C)]=a,i.add.push(a)}),g.visit(g.MOD,C=>{i.mod.push(r(C,o[eg(C)]))}),i}});function jxg(e,g,i,n){for(let I=0,r=i.length;I{const c=Zce(l,A);for(let u=0;u{const r=eg(I);i.rem.push(n[r]),n[r]=null}),g.visit(g.ADD,I=>{const r=pce(I);n[eg(I)]=r,i.add.push(r)}),g.visit(g.MOD,I=>{const r=n[eg(I)];for(const o in I)r[o]=I[o],i.modifies(o);i.mod.push(r)})),i}});function rue(e){Le.call(this,[],e),this.count=0}rue.Definition={type:"Sample",metadata:{},params:[{name:"size",type:"number",default:1e3}]};mt(rue,Le,{transform(e,g){const i=g.fork(g.NO_SOURCE),n=e.modified("size"),I=e.size,r=this.value.reduce((s,l)=>(s[eg(l)]=1,s),{});let o=this.value,C=this.count,a=0;function A(s){let l,c;o.length=a&&(l=o[c],r[eg(l)]&&i.rem.push(l),o[c]=s)),++C}if(g.rem.length&&(g.visit(g.REM,s=>{const l=eg(s);r[l]&&(r[l]=-1,i.rem.push(s)),--C}),o=o.filter(s=>r[eg(s)]!==-1)),(g.rem.length||n)&&o.length{r[eg(s)]||A(s)}),a=-1),n&&o.length>I){const s=o.length-I;for(let l=0;l{r[eg(s)]&&i.mod.push(s)}),g.add.length&&g.visit(g.ADD,A),(g.add.length||a<0)&&(i.add=o.filter(s=>!r[eg(s)])),this.count=C,this.value=i.source=o,i}});function oue(e){Le.call(this,null,e)}oue.Definition={type:"Sequence",metadata:{generates:!0,changes:!0},params:[{name:"start",type:"number",required:!0},{name:"stop",type:"number",required:!0},{name:"step",type:"number",default:1},{name:"as",type:"string",default:"data"}]};mt(oue,Le,{transform(e,g){if(this.value&&!e.modified())return;const i=g.materialize().fork(g.MOD),n=e.as||"data";return i.rem=this.value?g.rem.concat(this.value):g.rem,this.value=ca(e.start,e.stop,e.step||1).map(I=>{const r={};return r[n]=I,li(r)}),i.add=g.add.concat(this.value),i}});function Tet(e){Le.call(this,null,e),this.modified(!0)}mt(Tet,Le,{transform(e,g){return this.value=g.source,g.changed()?g.fork(g.NO_SOURCE|g.NO_FIELDS):g.StopPropagation}});function Cue(e){Le.call(this,null,e)}const Het=["unit0","unit1"];Cue.Definition={type:"TimeUnit",metadata:{modifies:!0},params:[{name:"field",type:"field",required:!0},{name:"interval",type:"boolean",default:!0},{name:"units",type:"enum",values:sce,array:!0},{name:"step",type:"number",default:1},{name:"maxbins",type:"number",default:40},{name:"extent",type:"date",array:!0},{name:"timezone",type:"enum",default:"local",values:["local","utc"]},{name:"as",type:"string",array:!0,length:2,default:Het}]};mt(Cue,Le,{transform(e,g){const i=e.field,n=e.interval!==!1,I=e.timezone==="utc",r=this._floor(e,g),o=(I?fS:hS)(r.unit).offset,C=e.as||Het,a=C[0],A=C[1],s=r.step;let l=r.start||1/0,c=r.stop||-1/0,u=g.ADD;return(e.modified()||g.changed(g.REM)||g.modified(Ur(i)))&&(g=g.reflow(!0),u=g.SOURCE,l=1/0,c=-1/0),g.visit(u,d=>{const h=i(d);let f,m;h==null?(d[a]=null,n&&(d[A]=null)):(d[a]=f=m=r(h),n&&(d[A]=m=o(f,s)),fc&&(c=m))}),r.start=l,r.stop=c,g.modifies(n?C:a)},_floor(e,g){const i=e.timezone==="utc",{units:n,step:I}=e.units?{units:e.units,step:e.step||1}:yqe({extent:e.extent||kc(g.materialize(g.SOURCE).source,e.field),maxbins:e.maxbins}),r=Ace(n),o=this.value||{},C=(i?lqe:Aqe)(r,I);return C.unit=jg(r),C.units=r,C.step=I,C.start=o.start,C.stop=o.stop,this.value=C}});function Net(e){Le.call(this,cS(),e)}mt(Net,Le,{transform(e,g){const i=g.dataflow,n=e.field,I=this.value,r=C=>I.set(n(C),C);let o=!0;return e.modified("field")||g.modified(n.fields)?(I.clear(),g.visit(g.SOURCE,r)):g.changed()?(g.visit(g.REM,C=>I.delete(n(C))),g.visit(g.ADD,r)):o=!1,this.modified(o),I.empty>i.cleanThreshold&&i.runAfter(I.clean),g.fork()}});function ket(e){Le.call(this,null,e)}mt(ket,Le,{transform(e,g){(!this.value||e.modified("field")||e.modified("sort")||g.changed()||e.sort&&g.modified(e.sort.fields))&&(this.value=(e.sort?g.source.slice().sort(dZ(e.sort)):g.source).map(e.field))}});function qxg(e,g,i,n){const I=S9[e](g,i);return{init:I.init||uf,update:function(r,o){o[n]=I.next(r)}}}const S9={row_number:function(){return{next:e=>e.index+1}},rank:function(){let e;return{init:()=>e=1,next:g=>{const i=g.index,n=g.data;return i&&g.compare(n[i-1],n[i])?e=i+1:e}}},dense_rank:function(){let e;return{init:()=>e=1,next:g=>{const i=g.index,n=g.data;return i&&g.compare(n[i-1],n[i])?++e:e}}},percent_rank:function(){const e=S9.rank(),g=e.next;return{init:e.init,next:i=>(g(i)-1)/(i.data.length-1)}},cume_dist:function(){let e;return{init:()=>e=0,next:g=>{const i=g.data,n=g.compare;let I=g.index;if(e0||qe("ntile num must be greater than zero.");const i=S9.cume_dist(),n=i.next;return{init:i.init,next:I=>Math.ceil(g*n(I))}},lag:function(e,g){return g=+g||1,{next:i=>{const n=i.index-g;return n>=0?e(i.data[n]):null}}},lead:function(e,g){return g=+g||1,{next:i=>{const n=i.index+g,I=i.data;return ne(g.data[g.i0])}},last_value:function(e){return{next:g=>e(g.data[g.i1-1])}},nth_value:function(e,g){return g=+g,g>0||qe("nth_value nth must be greater than zero."),{next:i=>{const n=i.i0+(g-1);return ng=null,next:i=>{const n=e(i.data[i.index]);return n!=null?g=n:g}}},next_value:function(e){let g,i;return{init:()=>(g=null,i=-1),next:n=>{const I=n.data;return n.index<=i?g:(i=eFg(e,I,n.index))<0?(i=I.length,g=null):g=e(I[i])}}}};function eFg(e,g,i){for(let n=g.length;iC[d]=1)}c(e.sort),g.forEach((u,d)=>{const h=i[d],f=xn(h),m=aet(u,f,I[d]);if(c(h),r.push(m),gg(S9,u))o.push(qxg(u,i[d],n[d],m));else{if(h==null&&u!=="count"&&qe("Null aggregate field specified."),u==="count"){A.push(m);return}l=!1;let b=a[f];b||(b=a[f]=[],b.field=h,s.push(b)),b.push(set(u,m))}}),(A.length||s.length)&&(this.cell=gFg(s,A,l)),this.inputs=Object.keys(C)}const Ket=Yet.prototype;Ket.init=function(){this.windows.forEach(e=>e.init()),this.cell&&this.cell.init()};Ket.update=function(e,g){const i=this.cell,n=this.windows,I=e.data,r=n&&n.length;let o;if(i){for(o=e.p0;ocet(a,a.field));const n={num:0,agg:null,store:!1,count:g};if(!i)for(var I=e.length,r=n.agg=Array(I),o=0;othis.group(I(C));let o=this.state;(!o||i)&&(o=this.state=new Yet(e)),i||g.modified(o.inputs)?(this.value={},g.visit(g.SOURCE,C=>r(C).add(C))):(g.visit(g.REM,C=>r(C).remove(C)),g.visit(g.ADD,C=>r(C).add(C)));for(let C=0,a=this._mlen;C0&&!I(r[i],r[i-1])&&(e.i0=g.left(r,r[i])),n1?0:e<-1?Mw:Math.acos(e)}function CTe(e){return e>=1?IM:e<=-1?-IM:Math.asin(e)}const _ie=Math.PI,Oie=2*_ie,I0=1e-6,aFg=Oie-I0;function Fet(e){this._+=e[0];for(let g=1,i=e.length;g=0))throw new Error(`invalid digits: ${e}`);if(g>15)return Fet;const i=10**g;return function(n){this._+=n[0];for(let I=1,r=n.length;II0)if(!(Math.abs(l*a-A*s)>I0)||!r)this._append`L${this._x1=g},${this._y1=i}`;else{let u=n-o,d=I-C,h=a*a+A*A,f=u*u+d*d,m=Math.sqrt(h),b=Math.sqrt(c),p=r*Math.tan((_ie-Math.acos((h+c-f)/(2*m*b)))/2),y=p/b,Z=p/m;Math.abs(y-1)>I0&&this._append`L${g+y*s},${i+y*l}`,this._append`A${r},${r},0,0,${+(l*u>s*d)},${this._x1=g+Z*a},${this._y1=i+Z*A}`}}arc(g,i,n,I,r,o){if(g=+g,i=+i,n=+n,o=!!o,n<0)throw new Error(`negative radius: ${n}`);let C=n*Math.cos(I),a=n*Math.sin(I),A=g+C,s=i+a,l=1^o,c=o?I-r:r-I;this._x1===null?this._append`M${A},${s}`:(Math.abs(this._x1-A)>I0||Math.abs(this._y1-s)>I0)&&this._append`L${A},${s}`,n&&(c<0&&(c=c%Oie+Oie),c>aFg?this._append`A${n},${n},0,1,${l},${g-C},${i-a}A${n},${n},0,1,${l},${this._x1=A},${this._y1=s}`:c>I0&&this._append`A${n},${n},0,${+(c>=_ie)},${l},${this._x1=g+n*Math.cos(r)},${this._y1=i+n*Math.sin(r)}`)}rect(g,i,n,I){this._append`M${this._x0=this._x1=+g},${this._y0=this._y1=+i}h${n=+n}v${+I}h${-n}Z`}toString(){return this._}};function IO(){return new sue}IO.prototype=sue.prototype;function rO(e){let g=3;return e.digits=function(i){if(!arguments.length)return g;if(i==null)g=null;else{const n=Math.floor(i);if(!(n>=0))throw new RangeError(`invalid digits: ${i}`);g=n}return e},()=>new sue(g)}function AFg(e){return e.innerRadius}function lFg(e){return e.outerRadius}function cFg(e){return e.startAngle}function uFg(e){return e.endAngle}function dFg(e){return e&&e.padAngle}function hFg(e,g,i,n,I,r,o,C){var a=i-e,A=n-g,s=o-I,l=C-r,c=l*a-s*A;if(!(c*cV*V+X*X&&(B=R,S=w),{cx:B,cy:S,x01:-s,y01:-l,x11:B*(I/Z-1),y11:S*(I/Z-1)}}function fFg(){var e=AFg,g=lFg,i=ui(0),n=null,I=cFg,r=uFg,o=dFg,C=null,a=rO(A);function A(){var s,l,c=+e.apply(this,arguments),u=+g.apply(this,arguments),d=I.apply(this,arguments)-IM,h=r.apply(this,arguments)-IM,f=oTe(h-d),m=h>d;if(C||(C=s=a()),uFr))C.moveTo(0,0);else if(f>xet-Fr)C.moveTo(u*kp(d),u*vl(d)),C.arc(0,0,u,d,h,!m),c>Fr&&(C.moveTo(c*kp(h),c*vl(h)),C.arc(0,0,c,h,d,m));else{var b=d,p=h,y=d,Z=h,v=f,G=f,B=o.apply(this,arguments)/2,S=B>Fr&&(n?+n.apply(this,arguments):X0(c*c+u*u)),R=Fj(oTe(u-c)/2,+i.apply(this,arguments)),w=R,T=R,W,V;if(S>Fr){var X=CTe(S/c*vl(B)),N=CTe(S/u*vl(B));(v-=X*2)>Fr?(X*=m?1:-1,y+=X,Z-=X):(v=0,y=Z=(d+h)/2),(G-=N*2)>Fr?(N*=m?1:-1,b+=N,p-=N):(G=0,b=p=(d+h)/2)}var Y=u*kp(b),x=u*vl(b),M=c*kp(Z),F=c*vl(Z);if(R>Fr){var $=u*kp(p),Q=u*vl(p),U=c*kp(y),j=c*vl(y),ee;if(fFr?T>Fr?(W=HY(U,j,Y,x,u,T,m),V=HY($,Q,M,F,u,T,m),C.moveTo(W.cx+W.x01,W.cy+W.y01),TFr)||!(v>Fr)?C.lineTo(M,F):w>Fr?(W=HY(M,F,$,Q,c,-w,m),V=HY(Y,x,U,j,c,-w,m),C.lineTo(W.cx+W.x01,W.cy+W.y01),w=u;--d)C.point(p[d],y[d]);C.lineEnd(),C.areaEnd()}m&&(p[c]=+e(f,c,l),y[c]=+g(f,c,l),C.point(n?+n(f,c,l):p[c],i?+i(f,c,l):y[c]))}if(b)return C=null,b+""||null}function s(){return Pet().defined(I).curve(o).context(r)}return A.x=function(l){return arguments.length?(e=typeof l=="function"?l:ui(+l),n=null,A):e},A.x0=function(l){return arguments.length?(e=typeof l=="function"?l:ui(+l),A):e},A.x1=function(l){return arguments.length?(n=l==null?null:typeof l=="function"?l:ui(+l),A):n},A.y=function(l){return arguments.length?(g=typeof l=="function"?l:ui(+l),i=null,A):g},A.y0=function(l){return arguments.length?(g=typeof l=="function"?l:ui(+l),A):g},A.y1=function(l){return arguments.length?(i=l==null?null:typeof l=="function"?l:ui(+l),A):i},A.lineX0=A.lineY0=function(){return s().x(e).y(g)},A.lineY1=function(){return s().x(e).y(i)},A.lineX1=function(){return s().x(n).y(g)},A.defined=function(l){return arguments.length?(I=typeof l=="function"?l:ui(!!l),A):I},A.curve=function(l){return arguments.length?(o=l,r!=null&&(C=o(r)),A):o},A.context=function(l){return arguments.length?(l==null?r=C=null:C=o(r=l),A):r},A}const mFg={draw(e,g){const i=X0(g/Mw);e.moveTo(i,0),e.arc(0,0,i,0,xet)}};function pFg(e,g){let i=null,n=rO(I);e=typeof e=="function"?e:ui(e||mFg),g=typeof g=="function"?g:ui(g===void 0?64:+g);function I(){let r;if(i||(i=r=n()),e.apply(this,arguments).draw(i,+g.apply(this,arguments)),r)return i=null,r+""||null}return I.type=function(r){return arguments.length?(e=typeof r=="function"?r:ui(r),I):e},I.size=function(r){return arguments.length?(g=typeof r=="function"?r:ui(+r),I):g},I.context=function(r){return arguments.length?(i=r??null,I):i},I}function bm(){}function rM(e,g,i){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+g)/6,(e._y0+4*e._y1+i)/6)}function oO(e){this._context=e}oO.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:rM(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,g){switch(e=+e,g=+g,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,g):this._context.moveTo(e,g);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:rM(this,e,g);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=g}};function bFg(e){return new oO(e)}function Oet(e){this._context=e}Oet.prototype={areaStart:bm,areaEnd:bm,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,g){switch(e=+e,g=+g,this._point){case 0:this._point=1,this._x2=e,this._y2=g;break;case 1:this._point=2,this._x3=e,this._y3=g;break;case 2:this._point=3,this._x4=e,this._y4=g,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+g)/6);break;default:rM(this,e,g);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=g}};function yFg(e){return new Oet(e)}function Jet(e){this._context=e}Jet.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,g){switch(e=+e,g=+g,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var i=(this._x0+4*this._x1+e)/6,n=(this._y0+4*this._y1+g)/6;this._line?this._context.lineTo(i,n):this._context.moveTo(i,n);break;case 3:this._point=4;default:rM(this,e,g);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=g}};function ZFg(e){return new Jet(e)}function Let(e,g){this._basis=new oO(e),this._beta=g}Let.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var e=this._x,g=this._y,i=e.length-1;if(i>0)for(var n=e[0],I=g[0],r=e[i]-n,o=g[i]-I,C=-1,a;++C<=i;)a=C/i,this._basis.point(this._beta*e[C]+(1-this._beta)*(n+a*r),this._beta*g[C]+(1-this._beta)*(I+a*o));this._x=this._y=null,this._basis.lineEnd()},point:function(e,g){this._x.push(+e),this._y.push(+g)}};const GFg=function e(g){function i(n){return g===1?new oO(n):new Let(n,g)}return i.beta=function(n){return e(+n)},i}(.85);function oM(e,g,i){e._context.bezierCurveTo(e._x1+e._k*(e._x2-e._x0),e._y1+e._k*(e._y2-e._y0),e._x2+e._k*(e._x1-g),e._y2+e._k*(e._y1-i),e._x2,e._y2)}function lue(e,g){this._context=e,this._k=(1-g)/6}lue.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:oM(this,this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,g){switch(e=+e,g=+g,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,g):this._context.moveTo(e,g);break;case 1:this._point=2,this._x1=e,this._y1=g;break;case 2:this._point=3;default:oM(this,e,g);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=g}};const vFg=function e(g){function i(n){return new lue(n,g)}return i.tension=function(n){return e(+n)},i}(0);function cue(e,g){this._context=e,this._k=(1-g)/6}cue.prototype={areaStart:bm,areaEnd:bm,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x3,this._y3),this._context.closePath();break}case 2:{this._context.lineTo(this._x3,this._y3),this._context.closePath();break}case 3:{this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5);break}}},point:function(e,g){switch(e=+e,g=+g,this._point){case 0:this._point=1,this._x3=e,this._y3=g;break;case 1:this._point=2,this._context.moveTo(this._x4=e,this._y4=g);break;case 2:this._point=3,this._x5=e,this._y5=g;break;default:oM(this,e,g);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=g}};const BFg=function e(g){function i(n){return new cue(n,g)}return i.tension=function(n){return e(+n)},i}(0);function uue(e,g){this._context=e,this._k=(1-g)/6}uue.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,g){switch(e=+e,g=+g,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:oM(this,e,g);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=g}};const wFg=function e(g){function i(n){return new uue(n,g)}return i.tension=function(n){return e(+n)},i}(0);function due(e,g,i){var n=e._x1,I=e._y1,r=e._x2,o=e._y2;if(e._l01_a>Fr){var C=2*e._l01_2a+3*e._l01_a*e._l12_a+e._l12_2a,a=3*e._l01_a*(e._l01_a+e._l12_a);n=(n*C-e._x0*e._l12_2a+e._x2*e._l01_2a)/a,I=(I*C-e._y0*e._l12_2a+e._y2*e._l01_2a)/a}if(e._l23_a>Fr){var A=2*e._l23_2a+3*e._l23_a*e._l12_a+e._l12_2a,s=3*e._l23_a*(e._l23_a+e._l12_a);r=(r*A+e._x1*e._l23_2a-g*e._l12_2a)/s,o=(o*A+e._y1*e._l23_2a-i*e._l12_2a)/s}e._context.bezierCurveTo(n,I,r,o,e._x2,e._y2)}function Uet(e,g){this._context=e,this._alpha=g}Uet.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,g){if(e=+e,g=+g,this._point){var i=this._x2-e,n=this._y2-g;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(i*i+n*n,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,g):this._context.moveTo(e,g);break;case 1:this._point=2;break;case 2:this._point=3;default:due(this,e,g);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=g}};const SFg=function e(g){function i(n){return g?new Uet(n,g):new lue(n,0)}return i.alpha=function(n){return e(+n)},i}(.5);function Qet(e,g){this._context=e,this._alpha=g}Qet.prototype={areaStart:bm,areaEnd:bm,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x3,this._y3),this._context.closePath();break}case 2:{this._context.lineTo(this._x3,this._y3),this._context.closePath();break}case 3:{this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5);break}}},point:function(e,g){if(e=+e,g=+g,this._point){var i=this._x2-e,n=this._y2-g;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(i*i+n*n,this._alpha))}switch(this._point){case 0:this._point=1,this._x3=e,this._y3=g;break;case 1:this._point=2,this._context.moveTo(this._x4=e,this._y4=g);break;case 2:this._point=3,this._x5=e,this._y5=g;break;default:due(this,e,g);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=g}};const RFg=function e(g){function i(n){return g?new Qet(n,g):new cue(n,0)}return i.alpha=function(n){return e(+n)},i}(.5);function jet(e,g){this._context=e,this._alpha=g}jet.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,g){if(e=+e,g=+g,this._point){var i=this._x2-e,n=this._y2-g;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(i*i+n*n,this._alpha))}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:due(this,e,g);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=g}};const VFg=function e(g){function i(n){return g?new jet(n,g):new uue(n,0)}return i.alpha=function(n){return e(+n)},i}(.5);function $et(e){this._context=e}$et.prototype={areaStart:bm,areaEnd:bm,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,g){e=+e,g=+g,this._point?this._context.lineTo(e,g):(this._point=1,this._context.moveTo(e,g))}};function WFg(e){return new $et(e)}function aTe(e){return e<0?-1:1}function sTe(e,g,i){var n=e._x1-e._x0,I=g-e._x1,r=(e._y1-e._y0)/(n||I<0&&-0),o=(i-e._y1)/(I||n<0&&-0),C=(r*I+o*n)/(n+I);return(aTe(r)+aTe(o))*Math.min(Math.abs(r),Math.abs(o),.5*Math.abs(C))||0}function ATe(e,g){var i=e._x1-e._x0;return i?(3*(e._y1-e._y0)/i-g)/2:g}function Ej(e,g,i){var n=e._x0,I=e._y0,r=e._x1,o=e._y1,C=(r-n)/3;e._context.bezierCurveTo(n+C,I+C*g,r-C,o-C*i,r,o)}function CM(e){this._context=e}CM.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:Ej(this,this._t0,ATe(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,g){var i=NaN;if(e=+e,g=+g,!(e===this._x1&&g===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,g):this._context.moveTo(e,g);break;case 1:this._point=2;break;case 2:this._point=3,Ej(this,ATe(this,i=sTe(this,e,g)),i);break;default:Ej(this,this._t0,i=sTe(this,e,g));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=g,this._t0=i}}};function qet(e){this._context=new ett(e)}(qet.prototype=Object.create(CM.prototype)).point=function(e,g){CM.prototype.point.call(this,g,e)};function ett(e){this._context=e}ett.prototype={moveTo:function(e,g){this._context.moveTo(g,e)},closePath:function(){this._context.closePath()},lineTo:function(e,g){this._context.lineTo(g,e)},bezierCurveTo:function(e,g,i,n,I,r){this._context.bezierCurveTo(g,e,n,i,r,I)}};function XFg(e){return new CM(e)}function TFg(e){return new qet(e)}function ttt(e){this._context=e}ttt.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,g=this._y,i=e.length;if(i)if(this._line?this._context.lineTo(e[0],g[0]):this._context.moveTo(e[0],g[0]),i===2)this._context.lineTo(e[1],g[1]);else for(var n=lTe(e),I=lTe(g),r=0,o=1;o=0;--g)I[g]=(o[g]-I[g+1])/r[g];for(r[i-1]=(e[i]+I[i-1])/2,g=0;g=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,g){switch(e=+e,g=+g,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,g):this._context.moveTo(e,g);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,g),this._context.lineTo(e,g);else{var i=this._x*(1-this._t)+e*this._t;this._context.lineTo(i,this._y),this._context.lineTo(i,g)}break}}this._x=e,this._y=g}};function NFg(e){return new CO(e,.5)}function kFg(e){return new CO(e,0)}function YFg(e){return new CO(e,1)}function om(e,g){if(typeof document<"u"&&document.createElement){const i=document.createElement("canvas");if(i&&i.getContext)return i.width=e,i.height=g,i}return null}const KFg=()=>typeof Image<"u"?Image:null;function eu(e,g){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(g).domain(e);break}return this}function ip(e,g){switch(arguments.length){case 0:break;case 1:{typeof e=="function"?this.interpolator(e):this.range(e);break}default:{this.domain(e),typeof g=="function"?this.interpolator(g):this.range(g);break}}return this}const Jie=Symbol("implicit");function hue(){var e=new N9e,g=[],i=[],n=Jie;function I(r){let o=e.get(r);if(o===void 0){if(n!==Jie)return n;e.set(r,o=g.push(r)-1)}return i[o%i.length]}return I.domain=function(r){if(!arguments.length)return g.slice();g=[],e=new N9e;for(const o of r)e.has(o)||e.set(o,g.push(o)-1);return I},I.range=function(r){return arguments.length?(i=Array.from(r),I):i.slice()},I.unknown=function(r){return arguments.length?(n=r,I):n},I.copy=function(){return hue(g,i).unknown(n)},eu.apply(I,arguments),I}function pS(e,g,i){e.prototype=g.prototype=i,i.constructor=e}function WH(e,g){var i=Object.create(e.prototype);for(var n in g)i[n]=g[n];return i}function np(){}var Ay=.7,zw=1/Ay,sB="\\s*([+-]?\\d+)\\s*",R9="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",dc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",xFg=/^#([0-9a-f]{3,8})$/,FFg=new RegExp(`^rgb\\(${sB},${sB},${sB}\\)$`),EFg=new RegExp(`^rgb\\(${dc},${dc},${dc}\\)$`),DFg=new RegExp(`^rgba\\(${sB},${sB},${sB},${R9}\\)$`),MFg=new RegExp(`^rgba\\(${dc},${dc},${dc},${R9}\\)$`),zFg=new RegExp(`^hsl\\(${R9},${dc},${dc}\\)$`),PFg=new RegExp(`^hsla\\(${R9},${dc},${dc},${R9}\\)$`),cTe={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};pS(np,V9,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:uTe,formatHex:uTe,formatHex8:_Fg,formatHsl:OFg,formatRgb:dTe,toString:dTe});function uTe(){return this.rgb().formatHex()}function _Fg(){return this.rgb().formatHex8()}function OFg(){return gtt(this).formatHsl()}function dTe(){return this.rgb().formatRgb()}function V9(e){var g,i;return e=(e+"").trim().toLowerCase(),(g=xFg.exec(e))?(i=g[1].length,g=parseInt(g[1],16),i===6?hTe(g):i===3?new FI(g>>8&15|g>>4&240,g>>4&15|g&240,(g&15)<<4|g&15,1):i===8?NY(g>>24&255,g>>16&255,g>>8&255,(g&255)/255):i===4?NY(g>>12&15|g>>8&240,g>>8&15|g>>4&240,g>>4&15|g&240,((g&15)<<4|g&15)/255):null):(g=FFg.exec(e))?new FI(g[1],g[2],g[3],1):(g=EFg.exec(e))?new FI(g[1]*255/100,g[2]*255/100,g[3]*255/100,1):(g=DFg.exec(e))?NY(g[1],g[2],g[3],g[4]):(g=MFg.exec(e))?NY(g[1]*255/100,g[2]*255/100,g[3]*255/100,g[4]):(g=zFg.exec(e))?pTe(g[1],g[2]/100,g[3]/100,1):(g=PFg.exec(e))?pTe(g[1],g[2]/100,g[3]/100,g[4]):cTe.hasOwnProperty(e)?hTe(cTe[e]):e==="transparent"?new FI(NaN,NaN,NaN,0):null}function hTe(e){return new FI(e>>16&255,e>>8&255,e&255,1)}function NY(e,g,i,n){return n<=0&&(e=g=i=NaN),new FI(e,g,i,n)}function fue(e){return e instanceof np||(e=V9(e)),e?(e=e.rgb(),new FI(e.r,e.g,e.b,e.opacity)):new FI}function aM(e,g,i,n){return arguments.length===1?fue(e):new FI(e,g,i,n??1)}function FI(e,g,i,n){this.r=+e,this.g=+g,this.b=+i,this.opacity=+n}pS(FI,aM,WH(np,{brighter(e){return e=e==null?zw:Math.pow(zw,e),new FI(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ay:Math.pow(Ay,e),new FI(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new FI(gb(this.r),gb(this.g),gb(this.b),sM(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:fTe,formatHex:fTe,formatHex8:JFg,formatRgb:mTe,toString:mTe}));function fTe(){return`#${T0(this.r)}${T0(this.g)}${T0(this.b)}`}function JFg(){return`#${T0(this.r)}${T0(this.g)}${T0(this.b)}${T0((isNaN(this.opacity)?1:this.opacity)*255)}`}function mTe(){const e=sM(this.opacity);return`${e===1?"rgb(":"rgba("}${gb(this.r)}, ${gb(this.g)}, ${gb(this.b)}${e===1?")":`, ${e})`}`}function sM(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function gb(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function T0(e){return e=gb(e),(e<16?"0":"")+e.toString(16)}function pTe(e,g,i,n){return n<=0?e=g=i=NaN:i<=0||i>=1?e=g=NaN:g<=0&&(e=NaN),new hA(e,g,i,n)}function gtt(e){if(e instanceof hA)return new hA(e.h,e.s,e.l,e.opacity);if(e instanceof np||(e=V9(e)),!e)return new hA;if(e instanceof hA)return e;e=e.rgb();var g=e.r/255,i=e.g/255,n=e.b/255,I=Math.min(g,i,n),r=Math.max(g,i,n),o=NaN,C=r-I,a=(r+I)/2;return C?(g===r?o=(i-n)/C+(i0&&a<1?0:o,new hA(o,C,a,e.opacity)}function Lie(e,g,i,n){return arguments.length===1?gtt(e):new hA(e,g,i,n??1)}function hA(e,g,i,n){this.h=+e,this.s=+g,this.l=+i,this.opacity=+n}pS(hA,Lie,WH(np,{brighter(e){return e=e==null?zw:Math.pow(zw,e),new hA(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ay:Math.pow(Ay,e),new hA(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,g=isNaN(e)||isNaN(this.s)?0:this.s,i=this.l,n=i+(i<.5?i:1-i)*g,I=2*i-n;return new FI(Dj(e>=240?e-240:e+120,I,n),Dj(e,I,n),Dj(e<120?e+240:e-120,I,n),this.opacity)},clamp(){return new hA(bTe(this.h),kY(this.s),kY(this.l),sM(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=sM(this.opacity);return`${e===1?"hsl(":"hsla("}${bTe(this.h)}, ${kY(this.s)*100}%, ${kY(this.l)*100}%${e===1?")":`, ${e})`}`}}));function bTe(e){return e=(e||0)%360,e<0?e+360:e}function kY(e){return Math.max(0,Math.min(1,e||0))}function Dj(e,g,i){return(e<60?g+(i-g)*e/60:e<180?i:e<240?g+(i-g)*(240-e)/60:g)*255}const itt=Math.PI/180,ntt=180/Math.PI,AM=18,Itt=.96422,rtt=1,ott=.82521,Ctt=4/29,AB=6/29,att=3*AB*AB,LFg=AB*AB*AB;function stt(e){if(e instanceof hc)return new hc(e.l,e.a,e.b,e.opacity);if(e instanceof Cd)return Att(e);e instanceof FI||(e=fue(e));var g=_j(e.r),i=_j(e.g),n=_j(e.b),I=Mj((.2225045*g+.7168786*i+.0606169*n)/rtt),r,o;return g===i&&i===n?r=o=I:(r=Mj((.4360747*g+.3850649*i+.1430804*n)/Itt),o=Mj((.0139322*g+.0971045*i+.7141733*n)/ott)),new hc(116*I-16,500*(r-I),200*(I-o),e.opacity)}function Uie(e,g,i,n){return arguments.length===1?stt(e):new hc(e,g,i,n??1)}function hc(e,g,i,n){this.l=+e,this.a=+g,this.b=+i,this.opacity=+n}pS(hc,Uie,WH(np,{brighter(e){return new hc(this.l+AM*(e??1),this.a,this.b,this.opacity)},darker(e){return new hc(this.l-AM*(e??1),this.a,this.b,this.opacity)},rgb(){var e=(this.l+16)/116,g=isNaN(this.a)?e:e+this.a/500,i=isNaN(this.b)?e:e-this.b/200;return g=Itt*zj(g),e=rtt*zj(e),i=ott*zj(i),new FI(Pj(3.1338561*g-1.6168667*e-.4906146*i),Pj(-.9787684*g+1.9161415*e+.033454*i),Pj(.0719453*g-.2289914*e+1.4052427*i),this.opacity)}}));function Mj(e){return e>LFg?Math.pow(e,1/3):e/att+Ctt}function zj(e){return e>AB?e*e*e:att*(e-Ctt)}function Pj(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function _j(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function UFg(e){if(e instanceof Cd)return new Cd(e.h,e.c,e.l,e.opacity);if(e instanceof hc||(e=stt(e)),e.a===0&&e.b===0)return new Cd(NaN,0=1?(i=1,g-1):Math.floor(i*g),I=e[n],r=e[n+1],o=n>0?e[n-1]:2*I-r,C=n()=>e;function htt(e,g){return function(i){return e+i*g}}function jFg(e,g,i){return e=Math.pow(e,i),g=Math.pow(g,i)-e,i=1/i,function(n){return Math.pow(e+n*g,i)}}function AO(e,g){var i=g-e;return i?htt(e,i>180||i<-180?i-360*Math.round(i/360):i):sO(isNaN(e)?g:e)}function $Fg(e){return(e=+e)==1?EI:function(g,i){return i-g?jFg(g,i,e):sO(isNaN(g)?i:g)}}function EI(e,g){var i=g-e;return i?htt(e,i):sO(isNaN(e)?g:e)}const $ie=function e(g){var i=$Fg(g);function n(I,r){var o=i((I=aM(I)).r,(r=aM(r)).r),C=i(I.g,r.g),a=i(I.b,r.b),A=EI(I.opacity,r.opacity);return function(s){return I.r=o(s),I.g=C(s),I.b=a(s),I.opacity=A(s),I+""}}return n.gamma=e,n}(1);function ftt(e){return function(g){var i=g.length,n=new Array(i),I=new Array(i),r=new Array(i),o,C;for(o=0;oi&&(r=g.slice(i,r),C[o]?C[o]+=r:C[++o]=r),(n=n[0])===(I=I[0])?C[o]?C[o]+=I:C[++o]=I:(C[++o]=null,a.push({i:o,x:lA(n,I)})),i=Oj.lastIndex;return i180?s+=360:s-A>180&&(A+=360),c.push({i:l.push(I(l)+"rotate(",null,n)-2,x:lA(A,s)})):s&&l.push(I(l)+"rotate("+s+n)}function C(A,s,l,c){A!==s?c.push({i:l.push(I(l)+"skewX(",null,n)-2,x:lA(A,s)}):s&&l.push(I(l)+"skewX("+s+n)}function a(A,s,l,c,u,d){if(A!==l||s!==c){var h=u.push(I(u)+"scale(",null,",",null,")");d.push({i:h-4,x:lA(A,l)},{i:h-2,x:lA(s,c)})}else(l!==1||c!==1)&&u.push(I(u)+"scale("+l+","+c+")")}return function(A,s){var l=[],c=[];return A=e(A),s=e(s),r(A.translateX,A.translateY,s.translateX,s.translateY,l,c),o(A.rotate,s.rotate,l,c),C(A.skewX,s.skewX,l,c),a(A.scaleX,A.scaleY,s.scaleX,s.scaleY,l,c),A=s=null,function(u){for(var d=-1,h=c.length,f;++dg&&(i=e,e=g,g=i),function(n){return Math.max(e,Math.min(g,n))}}function BEg(e,g,i){var n=e[0],I=e[1],r=g[0],o=g[1];return I2?wEg:BEg,a=A=null,l}function l(c){return c==null||isNaN(c=+c)?r:(a||(a=C(e.map(n),g,i)))(n(o(c)))}return l.invert=function(c){return o(I((A||(A=C(g,e.map(n),lA)))(c)))},l.domain=function(c){return arguments.length?(e=Array.from(c,tne),s()):e.slice()},l.range=function(c){return arguments.length?(g=Array.from(c),s()):g.slice()},l.rangeRound=function(c){return g=Array.from(c),i=XH,s()},l.clamp=function(c){return arguments.length?(o=c?!0:ZC,s()):o!==ZC},l.interpolate=function(c){return arguments.length?(i=c,s()):i},l.unknown=function(c){return arguments.length?(r=c,l):r},function(c,u){return n=c,I=u,s()}}function Rtt(){return lO()(ZC,ZC)}function Vtt(e,g,i,n){var I=mm(e,g,i),r;switch(n=Rb(n??",f"),n.type){case"s":{var o=Math.max(Math.abs(e),Math.abs(g));return n.precision==null&&!isNaN(r=lCe(I,o))&&(n.precision=r),vz(n,o)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(r=GMe(I,Math.max(Math.abs(e),Math.abs(g))))&&(n.precision=r-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(r=ZMe(I))&&(n.precision=r-(n.type==="%")*2);break}}return mT(n)}function fZ(e){var g=e.domain;return e.ticks=function(i){var n=g();return Xie(n[0],n[n.length-1],i??10)},e.tickFormat=function(i,n){var I=g();return Vtt(I[0],I[I.length-1],i??10,n)},e.nice=function(i){i==null&&(i=10);var n=g(),I=0,r=n.length-1,o=n[I],C=n[r],a,A,s=10;for(C0;){if(A=Tie(o,C,i),A===a)return n[I]=o,n[r]=C,g(n);if(A>0)o=Math.floor(o/A)*A,C=Math.ceil(C/A)*A;else if(A<0)o=Math.ceil(o*A)/A,C=Math.floor(C*A)/A;else break;a=A}return e},e}function Wtt(){var e=Rtt();return e.copy=function(){return TH(e,Wtt())},eu.apply(e,arguments),fZ(e)}function Xtt(e){var g;function i(n){return n==null||isNaN(n=+n)?g:n}return i.invert=i,i.domain=i.range=function(n){return arguments.length?(e=Array.from(n,tne),i):e.slice()},i.unknown=function(n){return arguments.length?(g=n,i):g},i.copy=function(){return Xtt(e).unknown(g)},e=arguments.length?Array.from(e,tne):[0,1],fZ(i)}function Ttt(e,g){e=e.slice();var i=0,n=e.length-1,I=e[i],r=e[n],o;return rMath.pow(e,g)}function XEg(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),g=>Math.log(g)/e)}function VTe(e){return(g,i)=>-e(-g,i)}function Zue(e){const g=e(STe,RTe),i=g.domain;let n=10,I,r;function o(){return I=XEg(n),r=WEg(n),i()[0]<0?(I=VTe(I),r=VTe(r),e(SEg,REg)):e(STe,RTe),g}return g.base=function(C){return arguments.length?(n=+C,o()):n},g.domain=function(C){return arguments.length?(i(C),o()):i()},g.ticks=C=>{const a=i();let A=a[0],s=a[a.length-1];const l=s0){for(;c<=u;++c)for(d=1;ds)break;m.push(h)}}else for(;c<=u;++c)for(d=n-1;d>=1;--d)if(h=c>0?d/r(-c):d*r(c),!(hs)break;m.push(h)}m.length*2{if(C==null&&(C=10),a==null&&(a=n===10?"s":","),typeof a!="function"&&(!(n%1)&&(a=Rb(a)).precision==null&&(a.trim=!0),a=mT(a)),C===1/0)return a;const A=Math.max(1,n*C/g.ticks().length);return s=>{let l=s/r(Math.round(I(s)));return l*ni(Ttt(i(),{floor:C=>r(Math.floor(I(C))),ceil:C=>r(Math.ceil(I(C)))})),g}function Htt(){const e=Zue(lO()).domain([1,10]);return e.copy=()=>TH(e,Htt()).base(e.base()),eu.apply(e,arguments),e}function WTe(e){return function(g){return Math.sign(g)*Math.log1p(Math.abs(g/e))}}function XTe(e){return function(g){return Math.sign(g)*Math.expm1(Math.abs(g))*e}}function Gue(e){var g=1,i=e(WTe(g),XTe(g));return i.constant=function(n){return arguments.length?e(WTe(g=+n),XTe(g)):g},fZ(i)}function Ntt(){var e=Gue(lO());return e.copy=function(){return TH(e,Ntt()).constant(e.constant())},eu.apply(e,arguments)}function TTe(e){return function(g){return g<0?-Math.pow(-g,e):Math.pow(g,e)}}function TEg(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function HEg(e){return e<0?-e*e:e*e}function vue(e){var g=e(ZC,ZC),i=1;function n(){return i===1?e(ZC,ZC):i===.5?e(TEg,HEg):e(TTe(i),TTe(1/i))}return g.exponent=function(I){return arguments.length?(i=+I,n()):i},fZ(g)}function Bue(){var e=vue(lO());return e.copy=function(){return TH(e,Bue()).exponent(e.exponent())},eu.apply(e,arguments),e}function NEg(){return Bue.apply(null,arguments).exponent(.5)}function ktt(){var e=[],g=[],i=[],n;function I(){var o=0,C=Math.max(1,g.length);for(i=new Array(C-1);++o0?i[C-1]:e[0],C=i?[n[i-1],g]:[n[A-1],n[A]]},o.unknown=function(a){return arguments.length&&(r=a),o},o.thresholds=function(){return n.slice()},o.copy=function(){return Ytt().domain([e,g]).range(I).unknown(r)},eu.apply(fZ(o),arguments)}function Ktt(){var e=[.5],g=[0,1],i,n=1;function I(r){return r!=null&&r<=r?g[wH(e,r,0,n)]:i}return I.domain=function(r){return arguments.length?(e=Array.from(r),n=Math.min(e.length,g.length-1),I):e.slice()},I.range=function(r){return arguments.length?(g=Array.from(r),n=Math.min(e.length,g.length-1),I):g.slice()},I.invertExtent=function(r){var o=g.indexOf(r);return[e[o-1],e[o]]},I.unknown=function(r){return arguments.length?(i=r,I):i},I.copy=function(){return Ktt().domain(e).range(g).unknown(i)},eu.apply(I,arguments)}function kEg(e){return new Date(e)}function YEg(e){return e instanceof Date?+e:+new Date(+e)}function wue(e,g,i,n,I,r,o,C,a,A){var s=Rtt(),l=s.invert,c=s.domain,u=A(".%L"),d=A(":%S"),h=A("%I:%M"),f=A("%I %p"),m=A("%a %d"),b=A("%b %d"),p=A("%B"),y=A("%Y");function Z(v){return(a(v)0?n:1:0}const DEg="identity",Pw="linear",Md="log",HH="pow",NH="sqrt",dO="symlog",ly="time",cy="utc",fc="sequential",bS="diverging",_w="quantile",hO="quantize",fO="threshold",Xue="ordinal",ine="point",ztt="band",Tue="bin-ordinal",VI="continuous",kH="discrete",YH="discretizing",vs="interpolating",Hue="temporal";function MEg(e){return function(g){let i=g[0],n=g[1],I;return n=n&&i[a]<=I&&(r<0&&(r=a),o=a);if(!(r<0))return n=e.invertExtent(i[r]),I=e.invertExtent(i[o]),[n[0]===void 0?n[1]:n[0],I[1]===void 0?I[0]:I[1]]}}function Nue(){const e=hue().unknown(void 0),g=e.domain,i=e.range;let n=[0,1],I,r,o=!1,C=0,a=0,A=.5;delete e.unknown;function s(){const l=g().length,c=n[1]h+I*m);return i(c?f.reverse():f)}return e.domain=function(l){return arguments.length?(g(l),s()):g()},e.range=function(l){return arguments.length?(n=[+l[0],+l[1]],s()):n.slice()},e.rangeRound=function(l){return n=[+l[0],+l[1]],o=!0,s()},e.bandwidth=function(){return r},e.step=function(){return I},e.round=function(l){return arguments.length?(o=!!l,s()):o},e.padding=function(l){return arguments.length?(a=Math.max(0,Math.min(1,l)),C=a,s()):C},e.paddingInner=function(l){return arguments.length?(C=Math.max(0,Math.min(1,l)),s()):C},e.paddingOuter=function(l){return arguments.length?(a=Math.max(0,Math.min(1,l)),s()):a},e.align=function(l){return arguments.length?(A=Math.max(0,Math.min(1,l)),s()):A},e.invertRange=function(l){if(l[0]==null||l[1]==null)return;const c=n[1]n[1-c])))return m=Math.max(0,$D(u,h)-1),b=h===f?m:$D(u,f)-1,h-u[m]>r+1e-10&&++m,c&&(p=m,m=d-b,b=d-p),m>b?void 0:g().slice(m,b+1)},e.invert=function(l){const c=e.invertRange([l,l]);return c&&c[0]},e.copy=function(){return Nue().domain(g()).range(n).round(o).paddingInner(C).paddingOuter(a).align(A)},s()}function Ptt(e){const g=e.copy;return e.padding=e.paddingOuter,delete e.paddingInner,e.copy=function(){return Ptt(g())},e}function PEg(){return Ptt(Nue().paddingInner(1))}var _Eg=Array.prototype.map;function OEg(e){return _Eg.call(e,_r)}const JEg=Array.prototype.slice;function _tt(){let e=[],g=[];function i(n){return n==null||n!==n?void 0:g[(wH(e,n)-1)%g.length]}return i.domain=function(n){return arguments.length?(e=OEg(n),i):e.slice()},i.range=function(n){return arguments.length?(g=JEg.call(n),i):g.slice()},i.tickFormat=function(n,I){return Vtt(e[0],jg(e),n??10,I)},i.copy=function(){return _tt().domain(i.domain()).range(i.range())},i}const lM=new Map,Ott=Symbol("vega_scale");function Jtt(e){return e[Ott]=!0,e}function LEg(e){return e&&e[Ott]===!0}function UEg(e,g,i){const n=function(){const r=g();return r.invertRange||(r.invertRange=r.invert?MEg(r):r.invertExtent?zEg(r):void 0),r.type=e,Jtt(r)};return n.metadata=JA(Vt(i)),n}function si(e,g,i){return arguments.length>1?(lM.set(e,UEg(e,g,i)),this):Ltt(e)?lM.get(e):void 0}si(DEg,Xtt);si(Pw,Wtt,VI);si(Md,Htt,[VI,Md]);si(HH,Bue,VI);si(NH,NEg,VI);si(dO,Ntt,VI);si(ly,KEg,[VI,Hue]);si(cy,xEg,[VI,Hue]);si(fc,Sue,[VI,vs]);si(`${fc}-${Pw}`,Sue,[VI,vs]);si(`${fc}-${Md}`,xtt,[VI,vs,Md]);si(`${fc}-${HH}`,Rue,[VI,vs]);si(`${fc}-${NH}`,FEg,[VI,vs]);si(`${fc}-${dO}`,Ftt,[VI,vs]);si(`${bS}-${Pw}`,Ett,[VI,vs]);si(`${bS}-${Md}`,Dtt,[VI,vs,Md]);si(`${bS}-${HH}`,Vue,[VI,vs]);si(`${bS}-${NH}`,EEg,[VI,vs]);si(`${bS}-${dO}`,Mtt,[VI,vs]);si(_w,ktt,[YH,_w]);si(hO,Ytt,YH);si(fO,Ktt,YH);si(Tue,_tt,[kH,YH]);si(Xue,hue,kH);si(ztt,Nue,kH);si(ine,PEg,kH);function Ltt(e){return lM.has(e)}function mZ(e,g){const i=lM.get(e);return i&&i.metadata[g]}function kue(e){return mZ(e,VI)}function Ow(e){return mZ(e,kH)}function nne(e){return mZ(e,YH)}function Utt(e){return mZ(e,Md)}function QEg(e){return mZ(e,Hue)}function Qtt(e){return mZ(e,vs)}function jtt(e){return mZ(e,_w)}const jEg=["clamp","base","constant","exponent"];function $tt(e,g){const i=g[0],n=jg(g)-i;return function(I){return e(i+I*n)}}function mO(e,g,i){return yue(Yue(g||"rgb",i),e)}function qtt(e,g){const i=new Array(g),n=g+1;for(let I=0;Ie[C]?o[C](e[C]()):0),o)}function Yue(e,g){const i=ZEg[$Eg(e)];return g!=null&&i&&i.gamma?i.gamma(g):i}function $Eg(e){return"interpolate"+e.toLowerCase().split("-").map(g=>g[0].toUpperCase()+g.slice(1)).join("")}const qEg={blues:"cfe1f2bed8eca8cee58fc1de74b2d75ba3cf4592c63181bd206fb2125ca40a4a90",greens:"d3eecdc0e6baabdda594d3917bc77d60ba6c46ab5e329a512089430e7735036429",greys:"e2e2e2d4d4d4c4c4c4b1b1b19d9d9d8888887575756262624d4d4d3535351e1e1e",oranges:"fdd8b3fdc998fdb87bfda55efc9244f87f2cf06b18e4580bd14904b93d029f3303",purples:"e2e1efd4d4e8c4c5e0b4b3d6a3a0cc928ec3827cb97566ae684ea25c3696501f8c",reds:"fdc9b4fcb49afc9e80fc8767fa7051f6573fec3f2fdc2a25c81b1db21218970b13",blueGreen:"d5efedc1e8e0a7ddd18bd2be70c6a958ba9144ad77319c5d2089460e7736036429",bluePurple:"ccddecbad0e4a8c2dd9ab0d4919cc98d85be8b6db28a55a6873c99822287730f71",greenBlue:"d3eecec5e8c3b1e1bb9bd8bb82cec269c2ca51b2cd3c9fc7288abd1675b10b60a1",orangeRed:"fddcaffdcf9bfdc18afdad77fb9562f67d53ee6545e24932d32d1ebf130da70403",purpleBlue:"dbdaebc8cee4b1c3de97b7d87bacd15b9fc93a90c01e7fb70b70ab056199045281",purpleBlueGreen:"dbd8eac8cee4b0c3de93b7d872acd1549fc83892bb1c88a3097f8702736b016353",purpleRed:"dcc9e2d3b3d7ce9eccd186c0da6bb2e14da0e23189d91e6fc61159ab07498f023a",redPurple:"fccfccfcbec0faa9b8f98faff571a5ec539ddb3695c41b8aa908808d0179700174",yellowGreen:"e4f4acd1eca0b9e2949ed68880c97c62bb6e47aa5e3297502083440e723b036034",yellowOrangeBrown:"feeaa1fedd84fecc63feb746fca031f68921eb7215db5e0bc54c05ab3d038f3204",yellowOrangeRed:"fee087fed16ffebd59fea849fd903efc7335f9522bee3423de1b20ca0b22af0225",blueOrange:"134b852f78b35da2cb9dcae1d2e5eff2f0ebfce0bafbbf74e8932fc5690d994a07",brownBlueGreen:"704108a0651ac79548e3c78af3e6c6eef1eac9e9e48ed1c74da79e187a72025147",purpleGreen:"5b1667834792a67fb6c9aed3e6d6e8eff0efd9efd5aedda971bb75368e490e5e29",purpleOrange:"4114696647968f83b7b9b4d6dadbebf3eeeafce0bafbbf74e8932fc5690d994a07",redBlue:"8c0d25bf363adf745ef4ae91fbdbc9f2efeed2e5ef9dcae15da2cb2f78b3134b85",redGrey:"8c0d25bf363adf745ef4ae91fcdccbfaf4f1e2e2e2c0c0c0969696646464343434",yellowGreenBlue:"eff9bddbf1b4bde5b594d5b969c5be45b4c22c9ec02182b82163aa23479c1c3185",redYellowBlue:"a50026d4322cf16e43fcac64fedd90faf8c1dcf1ecabd6e875abd04a74b4313695",redYellowGreen:"a50026d4322cf16e43fcac63fedd8df9f7aed7ee8ea4d86e64bc6122964f006837",pinkYellowGreen:"8e0152c0267edd72adf0b3d6faddedf5f3efe1f2cab6de8780bb474f9125276419",spectral:"9e0142d13c4bf0704afcac63fedd8dfbf8b0e0f3a1a9dda269bda94288b55e4fa2",viridis:"440154470e61481a6c482575472f7d443a834144873d4e8a39568c35608d31688e2d708e2a788e27818e23888e21918d1f988b1fa08822a8842ab07f35b77943bf7154c56866cc5d7ad1518fd744a5db36bcdf27d2e21be9e51afde725",magma:"0000040404130b0924150e3720114b2c11603b0f704a107957157e651a80721f817f24828c29819a2e80a8327db6377ac43c75d1426fde4968e95462f1605df76f5cfa7f5efc8f65fe9f6dfeaf78febf84fece91fddea0fcedaffcfdbf",inferno:"0000040403130c0826170c3b240c4f330a5f420a68500d6c5d126e6b176e781c6d86216b932667a12b62ae305cbb3755c73e4cd24644dd513ae65c30ed6925f3771af8850ffb9506fca50afcb519fac62df6d645f2e661f3f484fcffa4",plasma:"0d088723069033059742039d5002a25d01a66a00a87801a88405a7900da49c179ea72198b12a90ba3488c33d80cb4779d35171da5a69e16462e76e5bed7953f2834cf68f44fa9a3dfca636fdb32ffec029fcce25f9dc24f5ea27f0f921",cividis:"00205100235800265d002961012b65042e670831690d346b11366c16396d1c3c6e213f6e26426e2c456e31476e374a6e3c4d6e42506e47536d4c566d51586e555b6e5a5e6e5e616e62646f66676f6a6a706e6d717270717573727976737c79747f7c75827f758682768985778c8877908b78938e789691789a94789e9778a19b78a59e77a9a177aea575b2a874b6ab73bbaf71c0b26fc5b66dc9b96acebd68d3c065d8c462ddc85fe2cb5ce7cf58ebd355f0d652f3da4ff7de4cfae249fce647",rainbow:"6e40aa883eb1a43db3bf3cafd83fa4ee4395fe4b83ff576eff6659ff7847ff8c38f3a130e2b72fcfcc36bee044aff05b8ff4576ff65b52f6673af27828ea8d1ddfa319d0b81cbecb23abd82f96e03d82e14c6edb5a5dd0664dbf6e40aa",sinebow:"ff4040fc582af47218e78d0bd5a703bfbf00a7d5038de70b72f41858fc2a40ff402afc5818f4720be78d03d5a700bfbf03a7d50b8de71872f42a58fc4040ff582afc7218f48d0be7a703d5bf00bfd503a7e70b8df41872fc2a58ff4040",turbo:"23171b32204a3e2a71453493493eae4b49c54a53d7485ee44569ee4074f53c7ff8378af93295f72e9ff42ba9ef28b3e926bce125c5d925cdcf27d5c629dcbc2de3b232e9a738ee9d3ff39347f68950f9805afc7765fd6e70fe667cfd5e88fc5795fb51a1f84badf545b9f140c5ec3cd0e637dae034e4d931ecd12ef4c92bfac029ffb626ffad24ffa223ff9821ff8d1fff821dff771cfd6c1af76118f05616e84b14df4111d5380fcb2f0dc0260ab61f07ac1805a313029b0f00950c00910b00",browns:"eedbbdecca96e9b97ae4a865dc9856d18954c7784cc0673fb85536ad44339f3632",tealBlues:"bce4d89dd3d181c3cb65b3c245a2b9368fae347da0306a932c5985",teals:"bbdfdfa2d4d58ac9c975bcbb61b0af4da5a43799982b8b8c1e7f7f127273006667",warmGreys:"dcd4d0cec5c1c0b8b4b3aaa7a59c9998908c8b827f7e7673726866665c5a59504e",goldGreen:"f4d166d5ca60b6c35c98bb597cb25760a6564b9c533f8f4f33834a257740146c36",goldOrange:"f4d166f8be5cf8aa4cf5983bf3852aef701be2621fd65322c54923b142239e3a26",goldRed:"f4d166f6be59f9aa51fc964ef6834bee734ae56249db5247cf4244c43141b71d3e",lightGreyRed:"efe9e6e1dad7d5cbc8c8bdb9bbaea9cd967ddc7b43e15f19df4011dc000b",lightGreyTeal:"e4eaead6dcddc8ced2b7c2c7a6b4bc64b0bf22a6c32295c11f85be1876bc",lightMulti:"e0f1f2c4e9d0b0de9fd0e181f6e072f6c053f3993ef77440ef4a3c",lightOrange:"f2e7daf7d5baf9c499fab184fa9c73f68967ef7860e8645bde515bd43d5b",lightTealBlue:"e3e9e0c0dccf9aceca7abfc859afc0389fb9328dad2f7ca0276b95255988",darkBlue:"3232322d46681a5c930074af008cbf05a7ce25c0dd38daed50f3faffffff",darkGold:"3c3c3c584b37725e348c7631ae8b2bcfa424ecc31ef9de30fff184ffffff",darkGreen:"3a3a3a215748006f4d048942489e4276b340a6c63dd2d836ffeb2cffffaa",darkMulti:"3737371f5287197d8c29a86995ce3fffe800ffffff",darkRed:"3434347036339e3c38cc4037e75d1eec8620eeab29f0ce32ffeb2c"},eDg={category10:"1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf",category20:"1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5",category20b:"393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6",category20c:"3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9",tableau10:"4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac",tableau20:"4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5",accent:"7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666",dark2:"1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666",paired:"a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928",pastel1:"fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2",pastel2:"b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc",set1:"e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999",set2:"66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3",set3:"8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"};function tgt(e){const g=e.length/6|0,i=new Array(g);for(let n=0;nmO(tgt(e)));function Kue(e,g){return e=e&&e.toLowerCase(),arguments.length>1?(HTe[e]=g,this):HTe[e]}const M5="symbol",tDg="discrete",gDg="gradient",iDg=e=>et(e)?e.map(g=>String(g)):String(e),nDg=(e,g)=>e[1]-g[1],IDg=(e,g)=>g[1]-e[1];function xue(e,g,i){let n;return Vi(g)&&(e.bins&&(g=Math.max(g,e.bins.length)),i!=null&&(g=Math.min(g,Math.floor(vH(e.domain())/i||1)))),Wt(g)&&(n=g.step,g=g.interval),Rt(g)&&(g=e.type===ly?hS(g):e.type==cy?fS(g):qe("Only time and utc scales accept interval strings."),n&&(g=g.every(n))),g}function igt(e,g,i){let n=e.range(),I=n[0],r=jg(n),o=nDg;if(I>r&&(n=r,r=I,I=n,o=IDg),I=Math.floor(I),r=Math.ceil(r),g=g.map(C=>[C,e(C)]).filter(C=>I<=C[1]&&C[1]<=r).sort(o).map(C=>C[0]),i>0&&g.length>1){const C=[g[0],jg(g)];for(;g.length>i&&g.length>=3;)g=g.filter((a,A)=>!(A%2));g.length<3&&(g=C)}return g}function Fue(e,g){return e.bins?igt(e,e.bins):e.ticks?e.ticks(g):e.domain()}function ngt(e,g,i,n,I,r){const o=g.type;let C=iDg;if(o===ly||I===ly)C=e.timeFormat(n);else if(o===cy||I===cy)C=e.utcFormat(n);else if(Utt(o)){const a=e.formatFloat(n);if(r||g.bins)C=a;else{const A=Igt(g,i,!1);C=s=>A(s)?a(s):""}}else if(g.tickFormat){const a=g.domain();C=e.formatSpan(a[0],a[a.length-1],i,n)}else n&&(C=e.format(n));return C}function Igt(e,g,i){const n=Fue(e,g),I=e.base(),r=Math.log(I),o=Math.max(1,I*g/n.length),C=a=>{let A=a/Math.pow(I,Math.round(Math.log(a)/r));return A*I1?n[1]-n[0]:n[0],o;for(o=1;oIne[e.type]||e.bins;function Cgt(e,g,i,n,I,r,o){const C=rgt[g.type]&&r!==ly&&r!==cy?rDg(e,g,I):ngt(e,g,i,I,r,o);return n===M5&&aDg(g)?sDg(C):n===tDg?ADg(C):lDg(C)}const sDg=e=>(g,i,n)=>{const I=NTe(n[i+1],NTe(n.max,1/0)),r=kTe(g,e),o=kTe(I,e);return r&&o?r+" – "+o:o?"< "+o:"≥ "+r},NTe=(e,g)=>e??g,ADg=e=>(g,i)=>i?e(g):null,lDg=e=>g=>e(g),kTe=(e,g)=>Number.isFinite(e)?g(e):null;function cDg(e){const g=e.domain(),i=g.length-1;let n=+g[0],I=+jg(g),r=I-n;if(e.type===fO){const o=i?r/i:.1;n-=o,I+=o,r=I-n}return o=>(o-n)/r}function uDg(e,g,i,n){const I=n||g.type;return Rt(i)&&QEg(I)&&(i=i.replace(/%a/g,"%A").replace(/%b/g,"%B")),!i&&I===ly?e.timeFormat("%A, %d %B %Y, %X"):!i&&I===cy?e.utcFormat("%A, %d %B %Y, %X UTC"):Cgt(e,g,5,null,i,n,!0)}function agt(e,g,i){i=i||{};const n=Math.max(3,i.maxlen||7),I=uDg(e,g,i.format,i.formatType);if(nne(g.type)){const r=ogt(g).slice(1).map(I),o=r.length;return`${o} boundar${o===1?"y":"ies"}: ${r.join(", ")}`}else if(Ow(g.type)){const r=g.domain(),o=r.length,C=o>n?r.slice(0,n-2).map(I).join(", ")+", ending with "+r.slice(-1).map(I):r.map(I).join(", ");return`${o} value${o===1?"":"s"}: ${C}`}else{const r=g.domain();return`values from ${I(r[0])} to ${I(jg(r))}`}}let sgt=0;function dDg(){sgt=0}const cM="p_";function Eue(e){return e&&e.gradient}function Agt(e,g,i){const n=e.gradient;let I=e.id,r=n==="radial"?cM:"";return I||(I=e.id="gradient_"+sgt++,n==="radial"?(e.x1=Bl(e.x1,.5),e.y1=Bl(e.y1,.5),e.r1=Bl(e.r1,0),e.x2=Bl(e.x2,.5),e.y2=Bl(e.y2,.5),e.r2=Bl(e.r2,.5),r=cM):(e.x1=Bl(e.x1,0),e.y1=Bl(e.y1,0),e.x2=Bl(e.x2,1),e.y2=Bl(e.y2,0))),g[I]=e,"url("+(i||"")+"#"+r+I+")"}function Bl(e,g){return e??g}function lgt(e,g){var i=[],n;return n={gradient:"linear",x1:e?e[0]:0,y1:e?e[1]:0,x2:g?g[0]:1,y2:g?g[1]:0,stops:i,stop:function(I,r){return i.push({offset:I,color:r}),n}}}const YTe={basis:{curve:bFg},"basis-closed":{curve:yFg},"basis-open":{curve:ZFg},bundle:{curve:GFg,tension:"beta",value:.85},cardinal:{curve:vFg,tension:"tension",value:0},"cardinal-open":{curve:wFg,tension:"tension",value:0},"cardinal-closed":{curve:BFg,tension:"tension",value:0},"catmull-rom":{curve:SFg,tension:"alpha",value:.5},"catmull-rom-closed":{curve:RFg,tension:"alpha",value:.5},"catmull-rom-open":{curve:VFg,tension:"alpha",value:.5},linear:{curve:Aue},"linear-closed":{curve:WFg},monotone:{horizontal:TFg,vertical:XFg},natural:{curve:HFg},step:{curve:NFg},"step-after":{curve:YFg},"step-before":{curve:kFg}};function Due(e,g,i){var n=gg(YTe,e)&&YTe[e],I=null;return n&&(I=n.curve||n[g||"vertical"],n.tension&&i!=null&&(I=I[n.tension](i))),I}const hDg={m:2,l:2,h:1,v:1,z:0,c:6,s:4,q:4,t:2,a:7},fDg=/[mlhvzcsqta]([^mlhvzcsqta]+|$)/gi,mDg=/^[+-]?(([0-9]*\.[0-9]+)|([0-9]+\.)|([0-9]+))([eE][+-]?[0-9]+)?/,pDg=/^((\s+,?\s*)|(,\s*))/,bDg=/^[01]/;function Jw(e){const g=[];return(e.match(fDg)||[]).forEach(n=>{let I=n[0];const r=I.toLowerCase(),o=hDg[r],C=yDg(r,o,n.slice(1).trim()),a=C.length;if(a1&&(h=Math.sqrt(h),i*=h,n*=h);const f=c/i,m=l/i,b=-l/n,p=c/n,y=f*C+m*a,Z=b*C+p*a,v=f*e+m*g,G=b*e+p*g;let S=1/((v-y)*(v-y)+(G-Z)*(G-Z))-.25;S<0&&(S=0);let R=Math.sqrt(S);r==I&&(R=-R);const w=.5*(y+v)-R*(G-Z),T=.5*(Z+G)+R*(v-y),W=Math.atan2(Z-T,y-w);let X=Math.atan2(G-T,v-w)-W;X<0&&r===1?X+=Ql:X>0&&r===0&&(X-=Ql);const N=Math.ceil(Math.abs(X/(A0+.001))),Y=[];for(let x=0;x+e}function KY(e,g,i){return Math.max(g,Math.min(e,i))}function dgt(){var e=SDg,g=RDg,i=VDg,n=WDg,I=Gu(0),r=I,o=I,C=I,a=null;function A(s,l,c){var u,d=l??+e.call(this,s),h=c??+g.call(this,s),f=+i.call(this,s),m=+n.call(this,s),b=Math.min(f,m)/2,p=KY(+I.call(this,s),0,b),y=KY(+r.call(this,s),0,b),Z=KY(+o.call(this,s),0,b),v=KY(+C.call(this,s),0,b);if(a||(a=u=IO()),p<=0&&y<=0&&Z<=0&&v<=0)a.rect(d,h,f,m);else{var G=d+f,B=h+m;a.moveTo(d+p,h),a.lineTo(G-y,h),a.bezierCurveTo(G-Hh*y,h,G,h+Hh*y,G,h+y),a.lineTo(G,B-v),a.bezierCurveTo(G,B-Hh*v,G-Hh*v,B,G-v,B),a.lineTo(d+Z,B),a.bezierCurveTo(d+Hh*Z,B,d,B-Hh*Z,d,B-Z),a.lineTo(d,h+p),a.bezierCurveTo(d,h+Hh*p,d+Hh*p,h,d+p,h),a.closePath()}if(u)return a=null,u+""||null}return A.x=function(s){return arguments.length?(e=Gu(s),A):e},A.y=function(s){return arguments.length?(g=Gu(s),A):g},A.width=function(s){return arguments.length?(i=Gu(s),A):i},A.height=function(s){return arguments.length?(n=Gu(s),A):n},A.cornerRadius=function(s,l,c,u){return arguments.length?(I=Gu(s),r=l!=null?Gu(l):I,C=c!=null?Gu(c):I,o=u!=null?Gu(u):r,A):I},A.context=function(s){return arguments.length?(a=s??null,A):a},A}function hgt(){var e,g,i,n,I=null,r,o,C,a;function A(l,c,u){const d=u/2;if(r){var h=C-c,f=l-o;if(h||f){var m=Math.sqrt(h*h+f*f),b=(h/=m)*a,p=(f/=m)*a,y=Math.atan2(f,h);I.moveTo(o-b,C-p),I.lineTo(l-h*d,c-f*d),I.arc(l,c,d,y-Math.PI,y),I.lineTo(o+b,C+p),I.arc(o,C,a,y,y+Math.PI)}else I.arc(l,c,d,0,Ql);I.closePath()}else r=1;o=l,C=c,a=d}function s(l){var c,u=l.length,d,h=!1,f;for(I==null&&(I=f=IO()),c=0;c<=u;++c)!(ce.x||0,FH=e=>e.y||0,XDg=e=>e.width||0,TDg=e=>e.height||0,HDg=e=>(e.x||0)+(e.width||0),NDg=e=>(e.y||0)+(e.height||0),kDg=e=>e.startAngle||0,YDg=e=>e.endAngle||0,KDg=e=>e.padAngle||0,xDg=e=>e.innerRadius||0,FDg=e=>e.outerRadius||0,EDg=e=>e.cornerRadius||0,DDg=e=>KH(e.cornerRadiusTopLeft,e.cornerRadius)||0,MDg=e=>KH(e.cornerRadiusTopRight,e.cornerRadius)||0,zDg=e=>KH(e.cornerRadiusBottomRight,e.cornerRadius)||0,PDg=e=>KH(e.cornerRadiusBottomLeft,e.cornerRadius)||0,_Dg=e=>KH(e.size,64),ODg=e=>e.size||1,pO=e=>e.defined!==!1,JDg=e=>ugt(e.shape||"circle"),LDg=fFg().startAngle(kDg).endAngle(YDg).padAngle(KDg).innerRadius(xDg).outerRadius(FDg).cornerRadius(EDg),UDg=_et().x(xH).y1(FH).y0(NDg).defined(pO),QDg=_et().y(FH).x1(xH).x0(HDg).defined(pO),jDg=Pet().x(xH).y(FH).defined(pO),$Dg=dgt().x(xH).y(FH).width(XDg).height(TDg).cornerRadius(DDg,MDg,zDg,PDg),qDg=pFg().type(JDg).size(_Dg),eMg=hgt().x(xH).y(FH).defined(pO).size(ODg);function Mue(e){return e.cornerRadius||e.cornerRadiusTopLeft||e.cornerRadiusTopRight||e.cornerRadiusBottomRight||e.cornerRadiusBottomLeft}function tMg(e,g){return LDg.context(e)(g)}function gMg(e,g){const i=g[0],n=i.interpolate||"linear";return(i.orient==="horizontal"?QDg:UDg).curve(Due(n,i.orient,i.tension)).context(e)(g)}function iMg(e,g){const i=g[0],n=i.interpolate||"linear";return jDg.curve(Due(n,i.orient,i.tension)).context(e)(g)}function yS(e,g,i,n){return $Dg.context(e)(g,i,n)}function nMg(e,g){return(g.mark.shape||g.shape).context(e)(g)}function IMg(e,g){return qDg.context(e)(g)}function rMg(e,g){return eMg.context(e)(g)}var fgt=1;function mgt(){fgt=1}function zue(e,g,i){var n=g.clip,I=e._defs,r=g.clip_id||(g.clip_id="clip"+fgt++),o=I.clipping[r]||(I.clipping[r]={id:r});return Bg(n)?o.path=n(null):Mue(i)?o.path=yS(null,i,0,0):(o.width=i.width||0,o.height=i.height||0),"url(#"+r+")"}function oI(e){this.clear(),e&&this.union(e)}oI.prototype={clone(){return new oI(this)},clear(){return this.x1=+Number.MAX_VALUE,this.y1=+Number.MAX_VALUE,this.x2=-Number.MAX_VALUE,this.y2=-Number.MAX_VALUE,this},empty(){return this.x1===+Number.MAX_VALUE&&this.y1===+Number.MAX_VALUE&&this.x2===-Number.MAX_VALUE&&this.y2===-Number.MAX_VALUE},equals(e){return this.x1===e.x1&&this.y1===e.y1&&this.x2===e.x2&&this.y2===e.y2},set(e,g,i,n){return ithis.x2&&(this.x2=e),g>this.y2&&(this.y2=g),this},expand(e){return this.x1-=e,this.y1-=e,this.x2+=e,this.y2+=e,this},round(){return this.x1=Math.floor(this.x1),this.y1=Math.floor(this.y1),this.x2=Math.ceil(this.x2),this.y2=Math.ceil(this.y2),this},scale(e){return this.x1*=e,this.y1*=e,this.x2*=e,this.y2*=e,this},translate(e,g){return this.x1+=e,this.x2+=e,this.y1+=g,this.y2+=g,this},rotate(e,g,i){const n=this.rotatedPoints(e,g,i);return this.clear().add(n[0],n[1]).add(n[2],n[3]).add(n[4],n[5]).add(n[6],n[7])},rotatedPoints(e,g,i){var{x1:n,y1:I,x2:r,y2:o}=this,C=Math.cos(e),a=Math.sin(e),A=g-g*C+i*a,s=i-g*a-i*C;return[C*n-a*I+A,a*n+C*I+s,C*n-a*o+A,a*n+C*o+s,C*r-a*I+A,a*r+C*I+s,C*r-a*o+A,a*r+C*o+s]},union(e){return e.x1this.x2&&(this.x2=e.x2),e.y2>this.y2&&(this.y2=e.y2),this},intersect(e){return e.x1>this.x1&&(this.x1=e.x1),e.y1>this.y1&&(this.y1=e.y1),e.x2=e.x2&&this.y1<=e.y1&&this.y2>=e.y2},alignsWith(e){return e&&(this.x1==e.x1||this.x2==e.x2||this.y1==e.y1||this.y2==e.y2)},intersects(e){return e&&!(this.x2e.x2||this.y2e.y2)},contains(e,g){return!(ethis.x2||gthis.y2)},width(){return this.x2-this.x1},height(){return this.y2-this.y1}};function bO(e){this.mark=e,this.bounds=this.bounds||new oI}function yO(e){bO.call(this,e),this.items=this.items||[]}mt(yO,bO);function Pue(e){this._pending=0,this._loader=e||J_()}function ETe(e){e._pending+=1}function LR(e){e._pending-=1}Pue.prototype={pending(){return this._pending},sanitizeURL(e){const g=this;return ETe(g),g._loader.sanitize(e,{context:"href"}).then(i=>(LR(g),i)).catch(()=>(LR(g),null))},loadImage(e){const g=this,i=KFg();return ETe(g),g._loader.sanitize(e,{context:"image"}).then(n=>{const I=n.href;if(!I||!i)throw{url:I};const r=new i,o=gg(n,"crossOrigin")?n.crossOrigin:"anonymous";return o!=null&&(r.crossOrigin=o),r.onload=()=>LR(g),r.onerror=()=>LR(g),r.src=I,r}).catch(n=>(LR(g),{complete:!1,width:0,height:0,src:n&&n.url||""}))},ready(){const e=this;return new Promise(g=>{function i(n){e.pending()?setTimeout(()=>{i(!0)},10):g(n)}i(!1)})}};function oh(e,g,i){if(g.stroke&&g.opacity!==0&&g.strokeOpacity!==0){const n=g.strokeWidth!=null?+g.strokeWidth:1;e.expand(n+(i?oMg(g,n):0))}return e}function oMg(e,g){return e.strokeJoin&&e.strokeJoin!=="miter"?0:g}const CMg=Ql-1e-8;let ZO,z5,P5,H0,rne,_5,one,Cne;const Vf=(e,g)=>ZO.add(e,g),O5=(e,g)=>Vf(z5=e,P5=g),DTe=e=>Vf(e,ZO.y1),MTe=e=>Vf(ZO.x1,e),l0=(e,g)=>rne*e+one*g,c0=(e,g)=>_5*e+Cne*g,Qj=(e,g)=>Vf(l0(e,g),c0(e,g)),jj=(e,g)=>O5(l0(e,g),c0(e,g));function EH(e,g){return ZO=e,g?(H0=g*ym,rne=Cne=Math.cos(H0),_5=Math.sin(H0),one=-_5):(rne=Cne=1,H0=_5=one=0),aMg}const aMg={beginPath(){},closePath(){},moveTo:jj,lineTo:jj,rect(e,g,i,n){H0?(Qj(e+i,g),Qj(e+i,g+n),Qj(e,g+n),jj(e,g)):(Vf(e+i,g+n),O5(e,g))},quadraticCurveTo(e,g,i,n){const I=l0(e,g),r=c0(e,g),o=l0(i,n),C=c0(i,n);zTe(z5,I,o,DTe),zTe(P5,r,C,MTe),O5(o,C)},bezierCurveTo(e,g,i,n,I,r){const o=l0(e,g),C=c0(e,g),a=l0(i,n),A=c0(i,n),s=l0(I,r),l=c0(I,r);PTe(z5,o,a,s,DTe),PTe(P5,C,A,l,MTe),O5(s,l)},arc(e,g,i,n,I,r){if(n+=H0,I+=H0,z5=i*Math.cos(I)+e,P5=i*Math.sin(I)+g,Math.abs(I-n)>CMg)Vf(e-i,g-i),Vf(e+i,g+i);else{const o=A=>Vf(i*Math.cos(A)+e,i*Math.sin(A)+g);let C,a;if(o(n),o(I),I!==n)if(n=n%Ql,n<0&&(n+=Ql),I=I%Ql,I<0&&(I+=Ql),II;++a,C-=A0)o(C);else for(C=n-n%A0+A0,a=0;a<4&&CZDg?(s=o*o+C*r,s>=0&&(s=Math.sqrt(s),a=(-o+s)/r,A=(-o-s)/r)):a=.5*C/o,0c)return!1;h>l&&(l=h)}else if(u>0){if(h0?(e.globalAlpha=i,e.fillStyle=ygt(e,g,g.fill),!0):!1}var AMg=[];function Uw(e,g,i){var n=(n=g.strokeWidth)!=null?n:1;return n<=0?!1:(i*=g.strokeOpacity==null?1:g.strokeOpacity,i>0?(e.globalAlpha=i,e.strokeStyle=ygt(e,g,g.stroke),e.lineWidth=n,e.lineCap=g.strokeCap||"butt",e.lineJoin=g.strokeJoin||"miter",e.miterLimit=g.strokeMiterLimit||10,e.setLineDash&&(e.setLineDash(g.strokeDash||AMg),e.lineDashOffset=g.strokeDashOffset||0),!0):!1)}function lMg(e,g){return e.zindex-g.zindex||e.index-g.index}function Jue(e){if(!e.zdirty)return e.zitems;var g=e.items,i=[],n,I,r;for(I=0,r=g.length;I=0;)if(n=g(i[I]))return n;if(i===r){for(i=e.items,I=i.length;--I>=0;)if(!i[I].zindex&&(n=g(i[I])))return n}return null}function Lue(e){return function(g,i,n){UA(i,I=>{(!n||n.intersects(I.bounds))&&Zgt(e,g,I,I)})}}function cMg(e){return function(g,i,n){i.items.length&&(!n||n.intersects(i.bounds))&&Zgt(e,g,i.items[0],i.items)}}function Zgt(e,g,i,n){var I=i.opacity==null?1:i.opacity;I!==0&&(e(g,n)||(Lw(g,i),i.fill&&uM(g,i,I)&&g.fill(),i.stroke&&Uw(g,i,I)&&g.stroke()))}function GO(e){return e=e||fs,function(g,i,n,I,r,o){return n*=g.pixelRatio,I*=g.pixelRatio,dM(i,C=>{const a=C.bounds;if(!(a&&!a.contains(r,o)||!a)&&e(g,C,n,I,r,o))return C})}}function DH(e,g){return function(i,n,I,r){var o=Array.isArray(n)?n[0]:n,C=g??o.fill,a=o.stroke&&i.isPointInStroke,A,s;return a&&(A=o.strokeWidth,s=o.strokeCap,i.lineWidth=A??1,i.lineCap=s??"butt"),e(i,n)?!1:C&&i.isPointInPath(I,r)||a&&i.isPointInStroke(I,r)}}function Uue(e){return GO(DH(e))}function nb(e,g){return"translate("+e+","+g+")"}function Que(e){return"rotate("+e+")"}function uMg(e,g){return"scale("+e+","+g+")"}function Ggt(e){return nb(e.x||0,e.y||0)}function dMg(e){return nb(e.x||0,e.y||0)+(e.angle?" "+Que(e.angle):"")}function hMg(e){return nb(e.x||0,e.y||0)+(e.angle?" "+Que(e.angle):"")+(e.scaleX||e.scaleY?" "+uMg(e.scaleX||1,e.scaleY||1):"")}function jue(e,g,i){function n(o,C){o("transform",dMg(C)),o("d",g(null,C))}function I(o,C){return g(EH(o,C.angle),C),oh(o,C).translate(C.x||0,C.y||0)}function r(o,C){var a=C.x||0,A=C.y||0,s=C.angle||0;o.translate(a,A),s&&o.rotate(s*=ym),o.beginPath(),g(o,C),s&&o.rotate(-s),o.translate(-a,-A)}return{type:e,tag:"path",nested:!1,attr:n,bound:I,draw:Lue(r),pick:Uue(r),isect:i||_ue(r)}}var fMg=jue("arc",tMg);function mMg(e,g){for(var i=e[0].orient==="horizontal"?g[1]:g[0],n=e[0].orient==="horizontal"?"y":"x",I=e.length,r=1/0,o,C;--I>=0;)e[I].defined!==!1&&(C=Math.abs(e[I][n]-i),C=0;)if(e[n].defined!==!1&&(I=e[n].x-g[0],r=e[n].y-g[1],o=I*I+r*r,o=0;)if(e[i].defined!==!1&&(n=e[i].x-g[0],I=e[i].y-g[1],r=n*n+I*I,n=e[i].size||1,r.5&&g<1.5?.5-Math.abs(g-1):0}function GMg(e,g){e("transform",Ggt(g))}function wgt(e,g){const i=Bgt(g);e("d",yS(null,g,i,i))}function vMg(e,g){e("class","background"),e("aria-hidden",!0),wgt(e,g)}function BMg(e,g){e("class","foreground"),e("aria-hidden",!0),g.strokeForeground?wgt(e,g):e("d","")}function wMg(e,g,i){const n=g.clip?zue(i,g,g):null;e("clip-path",n)}function SMg(e,g){if(!g.clip&&g.items){const i=g.items,n=i.length;for(let I=0;I{const I=n.x||0,r=n.y||0,o=n.strokeForeground,C=n.opacity==null?1:n.opacity;(n.stroke||n.fill)&&C&&(T9(e,n,I,r),Lw(e,n),n.fill&&uM(e,n,C)&&e.fill(),n.stroke&&!o&&Uw(e,n,C)&&e.stroke()),e.save(),e.translate(I,r),n.clip&&vgt(e,n),i&&i.translate(-I,-r),UA(n,a=>{this.draw(e,a,i)}),i&&i.translate(I,r),e.restore(),o&&n.stroke&&C&&(T9(e,n,I,r),Lw(e,n),Uw(e,n,C)&&e.stroke())})}function TMg(e,g,i,n,I,r){if(g.bounds&&!g.bounds.contains(I,r)||!g.items)return null;const o=i*e.pixelRatio,C=n*e.pixelRatio;return dM(g,a=>{let A,s,l;const c=a.bounds;if(c&&!c.contains(I,r))return;s=a.x||0,l=a.y||0;const u=s+(a.width||0),d=l+(a.height||0),h=a.clip;if(h&&(Iu||rd))return;if(e.save(),e.translate(s,l),s=I-s,l=r-l,h&&Mue(a)&&!WMg(e,a,o,C))return e.restore(),null;const f=a.strokeForeground,m=g.interactive!==!1;return m&&f&&a.stroke&&VMg(e,a,o,C)?(e.restore(),a):(A=dM(a,b=>HMg(b,s,l)?this.pick(b,i,n,s,l):null),!A&&m&&(a.fill||!f&&a.stroke)&&RMg(e,a,o,C)&&(A=a),e.restore(),A||null)})}function HMg(e,g,i){return(e.interactive!==!1||e.marktype==="group")&&e.bounds&&e.bounds.contains(g,i)}var NMg={type:"group",tag:"g",nested:!1,attr:GMg,bound:SMg,draw:XMg,pick:TMg,isect:pgt,content:wMg,background:vMg,foreground:BMg},H9={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"};function que(e,g){var i=e.image;return(!i||e.url&&e.url!==i.url)&&(i={complete:!1,width:0,height:0},g.loadImage(e.url).then(n=>{e.image=n,e.image.url=e.url})),i}function ede(e,g){return e.width!=null?e.width:!g||!g.width?0:e.aspect!==!1&&e.height?e.height*g.width/g.height:g.width}function tde(e,g){return e.height!=null?e.height:!g||!g.height?0:e.aspect!==!1&&e.width?e.width*g.height/g.width:g.height}function vO(e,g){return e==="center"?g/2:e==="right"?g:0}function BO(e,g){return e==="middle"?g/2:e==="bottom"?g:0}function kMg(e,g,i){const n=que(g,i),I=ede(g,n),r=tde(g,n),o=(g.x||0)-vO(g.align,I),C=(g.y||0)-BO(g.baseline,r),a=!n.src&&n.toDataURL?n.toDataURL():n.src||"";e("href",a,H9["xmlns:xlink"],"xlink:href"),e("transform",nb(o,C)),e("width",I),e("height",r),e("preserveAspectRatio",g.aspect===!1?"none":"xMidYMid")}function YMg(e,g){const i=g.image,n=ede(g,i),I=tde(g,i),r=(g.x||0)-vO(g.align,n),o=(g.y||0)-BO(g.baseline,I);return e.set(r,o,r+n,o+I)}function KMg(e,g,i){UA(g,n=>{if(i&&!i.intersects(n.bounds))return;const I=que(n,this);let r=ede(n,I),o=tde(n,I);if(r===0||o===0)return;let C=(n.x||0)-vO(n.align,r),a=(n.y||0)-BO(n.baseline,o),A,s,l,c;n.aspect!==!1&&(s=I.width/I.height,l=n.width/n.height,s===s&&l===l&&s!==l&&(l{if(!(i&&!i.intersects(n.bounds))){var I=n.opacity==null?1:n.opacity;I&&Sgt(e,n,I)&&(Lw(e,n),e.stroke())}})}function UMg(e,g,i,n){return e.isPointInStroke?Sgt(e,g,1)&&e.isPointInStroke(i,n):!1}var QMg={type:"rule",tag:"line",nested:!1,attr:OMg,bound:JMg,draw:LMg,pick:GO(UMg),isect:bgt},jMg=jue("shape",nMg),$Mg=jue("symbol",IMg,Oue);const LTe=x6e();var xA={height:tu,measureWidth:gde,estimateWidth:sne,width:sne,canvas:Rgt};Rgt(!0);function Rgt(e){xA.width=e&&Cm?gde:sne}function sne(e,g){return Vgt(Gm(e,g),tu(e))}function Vgt(e,g){return~~(.8*e.length*g)}function gde(e,g){return tu(e)<=0||!(g=Gm(e,g))?0:Wgt(g,wO(e))}function Wgt(e,g){const i=`(${g}) ${e}`;let n=LTe.get(i);return n===void 0&&(Cm.font=g,n=Cm.measureText(e).width,LTe.set(i,n)),n}function tu(e){return e.fontSize!=null?+e.fontSize||0:11}function Zm(e){return e.lineHeight!=null?e.lineHeight:tu(e)+2}function qMg(e){return et(e)?e.length>1?e:e[0]:e}function MH(e){return qMg(e.lineBreak&&e.text&&!et(e.text)?e.text.split(e.lineBreak):e.text)}function ide(e){const g=MH(e);return(et(g)?g.length-1:0)*Zm(e)}function Gm(e,g){const i=g==null?"":(g+"").trim();return e.limit>0&&i.length?t3g(e,i):i}function e3g(e){if(xA.width===gde){const g=wO(e);return i=>Wgt(i,g)}else{const g=tu(e);return i=>Vgt(i,g)}}function t3g(e,g){var i=+e.limit,n=e3g(e);if(n(g)>>1,n(g.slice(a))>i?o=a+1:C=a;return I+g.slice(o)}else{for(;o>>1),n(g.slice(0,a))Math.max(c,xA.width(g,u)),0)):l=xA.width(g,s),I==="center"?a-=l/2:I==="right"&&(a-=l),e.set(a+=o,A+=C,a+l,A+n),g.angle&&!i)e.rotate(g.angle*ym,o,C);else if(i===2)return e.rotatedPoints(g.angle*ym,o,C);return e}function n3g(e,g,i){UA(g,n=>{var I=n.opacity==null?1:n.opacity,r,o,C,a,A,s,l;if(!(i&&!i.intersects(n.bounds)||I===0||n.fontSize<=0||n.text==null||n.text.length===0)){if(e.font=wO(n),e.textAlign=n.align||"left",r=SO(n),o=r.x1,C=r.y1,n.angle&&(e.save(),e.translate(o,C),e.rotate(n.angle*ym),o=C=0),o+=n.dx||0,C+=(n.dy||0)+nde(n),s=MH(n),Lw(e,n),et(s))for(A=Zm(n),a=0;ag;)e.removeChild(i[--n]);return e}function Ygt(e){return"mark-"+e.marktype+(e.role?" role-"+e.role:"")+(e.name?" "+e.name:"")}function RO(e,g){const i=g.getBoundingClientRect();return[e.clientX-i.left-(g.clientLeft||0),e.clientY-i.top-(g.clientTop||0)]}function s3g(e,g,i,n){var I=e&&e.mark,r,o;if(I&&(r=Za[I.marktype]).tip){for(o=RO(g,i),o[0]-=n[0],o[1]-=n[1];e=e.mark.group;)o[0]-=e.x||0,o[1]-=e.y||0;e=r.tip(I.items,o)}return e}function vm(e,g){this._active=null,this._handlers={},this._loader=e||J_(),this._tooltip=g||A3g}function A3g(e,g,i,n){e.element().setAttribute("title",n||"")}vm.prototype={initialize(e,g,i){return this._el=e,this._obj=i||null,this.origin(g)},element(){return this._el},canvas(){return this._el&&this._el.firstChild},origin(e){return arguments.length?(this._origin=e||[0,0],this):this._origin.slice()},scene(e){return arguments.length?(this._scene=e,this):this._scene},on(){},off(){},_handlerIndex(e,g,i){for(let n=e?e.length:0;--n>=0;)if(e[n].type===g&&(!i||e[n].handler===i))return n;return-1},handlers(e){const g=this._handlers,i=[];if(e)i.push(...g[this.eventName(e)]);else for(const n in g)i.push(...g[n]);return i},eventName(e){const g=e.indexOf(".");return g<0?e:e.slice(0,g)},handleHref(e,g,i){this._loader.sanitize(i,{context:"href"}).then(n=>{const I=new MouseEvent(e.type,e),r=Wf(null,"a");for(const o in n)r.setAttribute(o,n[o]);r.dispatchEvent(I)}).catch(()=>{})},handleTooltip(e,g,i){if(g&&g.tooltip!=null){g=s3g(g,e,this.canvas(),this._origin);const n=i&&g&&g.tooltip||null;this._tooltip.call(this._obj,this,e,g,n)}},getItemBoundingClientRect(e){const g=this.canvas();if(!g)return;const i=g.getBoundingClientRect(),n=this._origin,I=e.bounds,r=I.width(),o=I.height();let C=I.x1+n[0]+i.left,a=I.y1+n[1]+i.top;for(;e.mark&&(e=e.mark.group);)C+=e.x||0,a+=e.y||0;return{x:C,y:a,width:r,height:o,left:C,top:a,right:C+r,bottom:a+o}}};function gu(e){this._el=null,this._bgcolor=null,this._loader=new Pue(e)}gu.prototype={initialize(e,g,i,n,I){return this._el=e,this.resize(g,i,n,I)},element(){return this._el},canvas(){return this._el&&this._el.firstChild},background(e){return arguments.length===0?this._bgcolor:(this._bgcolor=e,this)},resize(e,g,i,n){return this._width=e,this._height=g,this._origin=i||[0,0],this._scale=n||1,this},dirty(){},render(e){const g=this;return g._call=function(){g._render(e)},g._call(),g._call=null,g},_render(){},renderAsync(e){const g=this.render(e);return this._ready?this._ready.then(()=>g):Promise.resolve(g)},_load(e,g){var i=this,n=i._loader[e](g);if(!i._ready){const I=i._call;i._ready=i._loader.ready().then(r=>{r&&I(),i._ready=null})}return n},sanitizeURL(e){return this._load("sanitizeURL",e)},loadImage(e){return this._load("loadImage",e)}};const l3g="keydown",c3g="keypress",u3g="keyup",Kgt="dragenter",L5="dragleave",xgt="dragover",lne="mousedown",d3g="mouseup",hM="mousemove",NW="mouseout",Fgt="mouseover",fM="click",h3g="dblclick",f3g="wheel",Egt="mousewheel",mM="touchstart",pM="touchmove",bM="touchend",m3g=[l3g,c3g,u3g,Kgt,L5,xgt,lne,d3g,hM,NW,Fgt,fM,h3g,f3g,Egt,mM,pM,bM],cne=hM,N9=NW,une=fM;function PH(e,g){vm.call(this,e,g),this._down=null,this._touch=null,this._first=!0,this._events={}}const p3g=e=>e===mM||e===pM||e===bM?[mM,pM,bM]:[e];function QTe(e,g){p3g(g).forEach(i=>b3g(e,i))}function b3g(e,g){const i=e.canvas();i&&!e._events[g]&&(e._events[g]=1,i.addEventListener(g,e[g]?n=>e[g](n):n=>e.fire(g,n)))}function jTe(e,g,i){return function(n){const I=this._active,r=this.pickEvent(n);r===I?this.fire(e,n):((!I||!I.exit)&&this.fire(i,n),this._active=r,this.fire(g,n),this.fire(e,n))}}function $Te(e){return function(g){this.fire(e,g),this._active=null}}mt(PH,vm,{initialize(e,g,i){return this._canvas=e&&ode(e,"canvas"),[fM,lne,hM,NW,L5].forEach(n=>QTe(this,n)),vm.prototype.initialize.call(this,e,g,i)},canvas(){return this._canvas},context(){return this._canvas.getContext("2d")},events:m3g,DOMMouseScroll(e){this.fire(Egt,e)},mousemove:jTe(hM,Fgt,NW),dragover:jTe(xgt,Kgt,L5),mouseout:$Te(NW),dragleave:$Te(L5),mousedown(e){this._down=this._active,this.fire(lne,e)},click(e){this._down===this._active&&(this.fire(fM,e),this._down=null)},touchstart(e){this._touch=this.pickEvent(e.changedTouches[0]),this._first&&(this._active=this._touch,this._first=!1),this.fire(mM,e,!0)},touchmove(e){this.fire(pM,e,!0)},touchend(e){this.fire(bM,e,!0),this._touch=null},fire(e,g,i){const n=i?this._touch:this._active,I=this._handlers[e];if(g.vegaType=e,e===une&&n&&n.href?this.handleHref(g,n,n.href):(e===cne||e===N9)&&this.handleTooltip(g,n,e!==N9),I)for(let r=0,o=I.length;r=0&&n.splice(I,1),this},pickEvent(e){const g=RO(e,this._canvas),i=this._origin;return this.pick(this._scene,g[0],g[1],g[0]-i[0],g[1]-i[1])},pick(e,g,i,n,I){const r=this.context();return Za[e.marktype].pick.call(this,r,e,g,i,n,I)}});function y3g(){return typeof window<"u"&&window.devicePixelRatio||1}var Z3g=y3g();function G3g(e,g,i,n,I,r){const o=typeof HTMLElement<"u"&&e instanceof HTMLElement&&e.parentNode!=null,C=e.getContext("2d"),a=o?Z3g:I;e.width=g*a,e.height=i*a;for(const A in r)C[A]=r[A];return o&&a!==1&&(e.style.width=g+"px",e.style.height=i+"px"),C.pixelRatio=a,C.setTransform(a,0,0,a,a*n[0],a*n[1]),e}function yM(e){gu.call(this,e),this._options={},this._redraw=!1,this._dirty=new oI,this._tempb=new oI}const qTe=gu.prototype,v3g=(e,g,i)=>new oI().set(0,0,g,i).translate(-e[0],-e[1]);function B3g(e,g,i){return g.expand(1).round(),e.pixelRatio%1&&g.scale(e.pixelRatio).round().scale(1/e.pixelRatio),g.translate(-(i[0]%1),-(i[1]%1)),e.beginPath(),e.rect(g.x1,g.y1,g.width(),g.height()),e.clip(),g}mt(yM,gu,{initialize(e,g,i,n,I,r){return this._options=r||{},this._canvas=this._options.externalContext?null:om(1,1,this._options.type),e&&this._canvas&&(fA(e,0).appendChild(this._canvas),this._canvas.setAttribute("class","marks")),qTe.initialize.call(this,e,g,i,n,I)},resize(e,g,i,n){if(qTe.resize.call(this,e,g,i,n),this._canvas)G3g(this._canvas,this._width,this._height,this._origin,this._scale,this._options.context);else{const I=this._options.externalContext;I||qe("CanvasRenderer is missing a valid canvas or context"),I.scale(this._scale,this._scale),I.translate(this._origin[0],this._origin[1])}return this._redraw=!0,this},canvas(){return this._canvas},context(){return this._options.externalContext||(this._canvas?this._canvas.getContext("2d"):null)},dirty(e){const g=this._tempb.clear().union(e.bounds);let i=e.mark.group;for(;i;)g.translate(i.x||0,i.y||0),i=i.mark.group;this._dirty.union(g)},_render(e){const g=this.context(),i=this._origin,n=this._width,I=this._height,r=this._dirty,o=v3g(i,n,I);g.save();const C=this._redraw||r.empty()?(this._redraw=!1,o.expand(1)):B3g(g,o.intersect(r),i);return this.clear(-i[0],-i[1],n,I),this.draw(g,e,C),g.restore(),r.clear(),this},draw(e,g,i){const n=Za[g.marktype];g.clip&&ZMg(e,g),n.draw.call(this,e,g,i),g.clip&&e.restore()},clear(e,g,i,n){const I=this._options,r=this.context();I.type!=="pdf"&&!I.externalContext&&r.clearRect(e,g,i,n),this._bgcolor!=null&&(r.fillStyle=this._bgcolor,r.fillRect(e,g,i,n))}});function Cde(e,g){vm.call(this,e,g);const i=this;i._hrefHandler=dne(i,(n,I)=>{I&&I.href&&i.handleHref(n,I,I.href)}),i._tooltipHandler=dne(i,(n,I)=>{i.handleTooltip(n,I,n.type!==N9)})}const dne=(e,g)=>i=>{let n=i.target.__data__;n=Array.isArray(n)?n[0]:n,i.vegaType=i.type,g.call(e._obj,i,n)};mt(Cde,vm,{initialize(e,g,i){let n=this._svg;return n&&(n.removeEventListener(une,this._hrefHandler),n.removeEventListener(cne,this._tooltipHandler),n.removeEventListener(N9,this._tooltipHandler)),this._svg=n=e&&ode(e,"svg"),n&&(n.addEventListener(une,this._hrefHandler),n.addEventListener(cne,this._tooltipHandler),n.addEventListener(N9,this._tooltipHandler)),vm.prototype.initialize.call(this,e,g,i)},canvas(){return this._svg},on(e,g){const i=this.eventName(e),n=this._handlers;if(this._handlerIndex(n[i],e,g)<0){const r={type:e,handler:g,listener:dne(this,g)};(n[i]||(n[i]=[])).push(r),this._svg&&this._svg.addEventListener(i,r.listener)}return this},off(e,g){const i=this.eventName(e),n=this._handlers[i],I=this._handlerIndex(n,e,g);return I>=0&&(this._svg&&this._svg.removeEventListener(i,n[I].listener),n.splice(I,1)),this}});const Dgt="aria-hidden",ade="aria-label",sde="role",Ade="aria-roledescription",Mgt="graphics-object",lde="graphics-symbol",zgt=(e,g,i)=>({[sde]:e,[Ade]:g,[ade]:i||void 0}),w3g=JA(["axis-domain","axis-grid","axis-label","axis-tick","axis-title","legend-band","legend-entry","legend-gradient","legend-label","legend-title","legend-symbol","title"]),eHe={axis:{desc:"axis",caption:V3g},legend:{desc:"legend",caption:W3g},"title-text":{desc:"title",caption:e=>`Title text '${gHe(e)}'`},"title-subtitle":{desc:"subtitle",caption:e=>`Subtitle text '${gHe(e)}'`}},tHe={ariaRole:sde,ariaRoleDescription:Ade,description:ade};function Pgt(e,g){const i=g.aria===!1;if(e(Dgt,i||void 0),i||g.description==null)for(const n in tHe)e(tHe[n],void 0);else{const n=g.mark.marktype;e(ade,g.description),e(sde,g.ariaRole||(n==="group"?Mgt:lde)),e(Ade,g.ariaRoleDescription||`${n} mark`)}}function _gt(e){return e.aria===!1?{[Dgt]:!0}:w3g[e.role]?null:eHe[e.role]?R3g(e,eHe[e.role]):S3g(e)}function S3g(e){const g=e.marktype,i=g==="group"||g==="text"||e.items.some(n=>n.description!=null&&n.aria!==!1);return zgt(i?Mgt:lde,`${g} mark container`,e.description)}function R3g(e,g){try{const i=e.items[0],n=g.caption||(()=>"");return zgt(g.role||lde,g.desc,i.description||n(i))}catch{return null}}function gHe(e){return Vt(e.text).join(" ")}function V3g(e){const g=e.datum,i=e.orient,n=g.title?Ogt(e):null,I=e.context,r=I.scales[g.scale].value,o=I.dataflow.locale(),C=r.type;return`${i==="left"||i==="right"?"Y":"X"}-axis`+(n?` titled '${n}'`:"")+` for a ${Ow(C)?"discrete":C} scale with ${agt(o,r,e)}`}function W3g(e){const g=e.datum,i=g.title?Ogt(e):null,n=`${g.type||""} legend`.trim(),I=g.scales,r=Object.keys(I),o=e.context,C=o.scales[I[r[0]]].value,a=o.dataflow.locale();return T3g(n)+(i?` titled '${i}'`:"")+` for ${X3g(r)} with ${agt(a,C,e)}`}function Ogt(e){try{return Vt(jg(e.items).items[0].text).join(" ")}catch{return null}}function X3g(e){return e=e.map(g=>g+(g==="fill"||g==="stroke"?" color":"")),e.length<2?e[0]:e.slice(0,-1).join(", ")+" and "+jg(e)}function T3g(e){return e.length?e[0].toUpperCase()+e.slice(1):e}const Jgt=e=>(e+"").replace(/&/g,"&").replace(//g,">"),H3g=e=>Jgt(e).replace(/"/g,""").replace(/\t/g," ").replace(/\n/g," ").replace(/\r/g," ");function cde(){let e="",g="",i="";const n=[],I=()=>g=i="",r=a=>{g&&(e+=`${g}>${i}`,I()),n.push(a)},o=(a,A)=>(A!=null&&(g+=` ${a}="${H3g(A)}"`),C),C={open(a){r(a),g="<"+a;for(var A=arguments.length,s=new Array(A>1?A-1:0),l=1;l${i}`:"/>"):e+=``,I(),C},attr:o,text:a=>(i+=Jgt(a),C),toString:()=>e};return C}const Lgt=e=>Ugt(cde(),e)+"";function Ugt(e,g){if(e.open(g.tagName),g.hasAttributes()){const i=g.attributes,n=i.length;for(let I=0;I{A.dirty=g})),!n.zdirty){if(i.exit){r.nested&&n.items.length?(a=n.items[0],a._svg&&this._update(r,a._svg,a)):i._svg&&(a=i._svg.parentNode,a&&a.removeChild(i._svg)),i._svg=null;continue}i=r.nested?n.items[0]:i,i._update!==g&&(!i._svg||!i._svg.ownerSVGElement?(this._dirtyAll=!1,nHe(i,g)):this._update(r,i._svg,i),i._update=g)}return!this._dirtyAll},mark(e,g,i){if(!this.isDirty(g))return g._svg;const n=this._svg,I=Za[g.marktype],r=g.interactive===!1?"none":null,o=I.tag==="g",C=IHe(g,e,i,"g",n);C.setAttribute("class",Ygt(g));const a=_gt(g);for(const c in a)co(C,c,a[c]);o||co(C,"pointer-events",r),co(C,"clip-path",g.clip?zue(this,g,g.group):null);let A=null,s=0;const l=c=>{const u=this.isDirty(c),d=IHe(c,C,A,I.tag,n);u&&(this._update(I,d,c),o&&Y3g(this,d,c)),A=d,++s};return I.nested?g.items.length&&l(g.items[0]):UA(g,l),fA(C,s),C},_update(e,g,i){ad=g,Dr=g.__values__,Pgt(kW,i),e.attr(kW,i,this);const n=x3g[e.type];n&&n.call(this,e,g,i),ad&&this.style(ad,i)},style(e,g){if(g!=null){for(const i in ZM){let n=i==="font"?zH(g):g[i];if(n===Dr[i])continue;const I=ZM[i];n==null?e.removeAttribute(I):(Eue(n)&&(n=Agt(n,this._defs.gradient,jgt())),e.setAttribute(I,n+"")),Dr[i]=n}for(const i in GM)U5(e,GM[i],g[i])}},defs(){const e=this._svg,g=this._defs;let i=g.el,n=0;for(const I in g.gradient)i||(g.el=i=mC(e,UR+1,"defs",dI)),n=N3g(i,g.gradient[I],n);for(const I in g.clipping)i||(g.el=i=mC(e,UR+1,"defs",dI)),n=k3g(i,g.clipping[I],n);i&&(n===0?(e.removeChild(i),g.el=null):fA(i,n))},_clearDefs(){const e=this._defs;e.gradient={},e.clipping={}}});function nHe(e,g){for(;e&&e.dirty!==g;e=e.mark.group)if(e.dirty=g,e.mark&&e.mark.dirty!==g)e.mark.dirty=g;else return}function N3g(e,g,i){let n,I,r;if(g.gradient==="radial"){let o=mC(e,i++,"pattern",dI);Xf(o,{id:cM+g.id,viewBox:"0,0,1,1",width:"100%",height:"100%",preserveAspectRatio:"xMidYMid slice"}),o=mC(o,0,"rect",dI),Xf(o,{width:1,height:1,fill:`url(${jgt()}#${g.id})`}),e=mC(e,i++,"radialGradient",dI),Xf(e,{id:g.id,fx:g.x1,fy:g.y1,fr:g.r1,cx:g.x2,cy:g.y2,r:g.r2})}else e=mC(e,i++,"linearGradient",dI),Xf(e,{id:g.id,x1:g.x1,x2:g.x2,y1:g.y1,y2:g.y2});for(n=0,I=g.stops.length;n{n=e.mark(g,r,n),++I}),fA(g,1+I)}function IHe(e,g,i,n,I){let r=e._svg,o;if(!r&&(o=g.ownerDocument,r=Wf(o,n,dI),e._svg=r,e.mark&&(r.__data__=e,r.__values__={fill:"default"},n==="g"))){const C=Wf(o,"path",dI);r.appendChild(C),C.__data__=e;const a=Wf(o,"g",dI);r.appendChild(a),a.__data__=e;const A=Wf(o,"path",dI);r.appendChild(A),A.__data__=e,A.__values__={fill:"default"}}return(r.ownerSVGElement!==I||K3g(r,i))&&g.insertBefore(r,i?i.nextSibling:g.firstChild),r}function K3g(e,g){return e.parentNode&&e.parentNode.childNodes.length>1&&e.previousSibling!=g}let ad=null,Dr=null;const x3g={group(e,g,i){const n=ad=g.childNodes[2];Dr=n.__values__,e.foreground(kW,i,this),Dr=g.__values__,ad=g.childNodes[1],e.content(kW,i,this);const I=ad=g.childNodes[0];e.background(kW,i,this);const r=i.mark.interactive===!1?"none":null;if(r!==Dr.events&&(co(n,"pointer-events",r),co(I,"pointer-events",r),Dr.events=r),i.strokeForeground&&i.stroke){const o=i.fill;co(n,"display",null),this.style(I,i),co(I,"stroke",null),o&&(i.fill=null),Dr=n.__values__,this.style(n,i),o&&(i.fill=o),ad=null}else co(n,"display","none")},image(e,g,i){i.smooth===!1?(U5(g,"image-rendering","optimizeSpeed"),U5(g,"image-rendering","pixelated")):U5(g,"image-rendering",null)},text(e,g,i){const n=MH(i);let I,r,o,C;et(n)?(r=n.map(a=>Gm(i,a)),I=r.join(` +`),I!==Dr.text&&(fA(g,0),o=g.ownerDocument,C=Zm(i),r.forEach((a,A)=>{const s=Wf(o,"tspan",dI);s.__data__=i,s.textContent=a,A&&(s.setAttribute("x",0),s.setAttribute("dy",C)),g.appendChild(s)}),Dr.text=I)):(r=Gm(i,n),r!==Dr.text&&(g.textContent=r,Dr.text=r)),co(g,"font-family",zH(i)),co(g,"font-size",tu(i)+"px"),co(g,"font-style",i.fontStyle),co(g,"font-variant",i.fontVariant),co(g,"font-weight",i.fontWeight)}};function kW(e,g,i){g!==Dr[e]&&(i?F3g(ad,e,g,i):co(ad,e,g),Dr[e]=g)}function U5(e,g,i){i!==Dr[g]&&(i==null?e.style.removeProperty(g):e.style.setProperty(g,i+""),Dr[g]=i)}function Xf(e,g){for(const i in g)co(e,i,g[i])}function co(e,g,i){i!=null?e.setAttribute(g,i):e.removeAttribute(g)}function F3g(e,g,i,n){i!=null?e.setAttributeNS(n,g,i):e.removeAttributeNS(n,g)}function jgt(){let e;return typeof window>"u"?"":(e=window.location).hash?e.href.slice(0,-e.hash.length):e.href}function dde(e){gu.call(this,e),this._text=null,this._defs={gradient:{},clipping:{}}}mt(dde,gu,{svg(){return this._text},_render(e){const g=cde();g.open("svg",vg({},H9,{class:"marks",width:this._width*this._scale,height:this._height*this._scale,viewBox:`0 0 ${this._width} ${this._height}`}));const i=this._bgcolor;return i&&i!=="transparent"&&i!=="none"&&g.open("rect",{width:this._width,height:this._height,fill:i}).close(),g.open("g",Qgt,{transform:"translate("+this._origin+")"}),this.mark(g,e),g.close(),this.defs(g),this._text=g.close()+"",this},mark(e,g){const i=Za[g.marktype],n=i.tag,I=[Pgt,i.attr];e.open("g",{class:Ygt(g),"clip-path":g.clip?zue(this,g,g.group):null},_gt(g),{"pointer-events":n!=="g"&&g.interactive===!1?"none":null});const r=o=>{const C=this.href(o);if(C&&e.open("a",C),e.open(n,this.attr(g,o,I,n!=="g"?n:null)),n==="text"){const a=MH(o);if(et(a)){const A={x:0,dy:Zm(o)};for(let s=0;sthis.mark(e,l)),e.close(),a&&s?(A&&(o.fill=null),o.stroke=s,e.open("path",this.attr(g,o,i.foreground,"bgrect")).close(),A&&(o.fill=A)):e.open("path",this.attr(g,o,i.foreground,"bgfore")).close()}e.close(),C&&e.close()};return i.nested?g.items&&g.items.length&&r(g.items[0]):UA(g,r),e.close()},href(e){const g=e.href;let i;if(g){if(i=this._hrefs&&this._hrefs[g])return i;this.sanitizeURL(g).then(n=>{n["xlink:href"]=n.href,n.href=null,(this._hrefs||(this._hrefs={}))[g]=n})}return null},attr(e,g,i,n){const I={},r=(o,C,a,A)=>{I[A||o]=C};return Array.isArray(i)?i.forEach(o=>o(r,g,this)):i(r,g,this),n&&E3g(I,g,e,n,this._defs),I},defs(e){const g=this._defs.gradient,i=this._defs.clipping;if(Object.keys(g).length+Object.keys(i).length!==0){e.open("defs");for(const I in g){const r=g[I],o=r.stops;r.gradient==="radial"?(e.open("pattern",{id:cM+I,viewBox:"0,0,1,1",width:"100%",height:"100%",preserveAspectRatio:"xMidYMid slice"}),e.open("rect",{width:"1",height:"1",fill:"url(#"+I+")"}).close(),e.close(),e.open("radialGradient",{id:I,fx:r.x1,fy:r.y1,fr:r.r1,cx:r.x2,cy:r.y2,r:r.r2})):e.open("linearGradient",{id:I,x1:r.x1,x2:r.x2,y1:r.y1,y2:r.y2});for(let C=0;C1?(Qw[e]=g,this):Qw[e]}function git(e,g,i){const n=[],I=new oI().union(g),r=e.marktype;return r?iit(e,I,i,n):r==="group"?nit(e,I,i,n):qe("Intersect scene must be mark node or group item.")}function iit(e,g,i,n){if(D3g(e,g,i)){const I=e.items,r=e.marktype,o=I.length;let C=0;if(r==="group")for(;C=0;r--)if(i[r]!=n[r])return!1;for(r=i.length-1;r>=0;r--)if(I=i[r],!hde(e[I],g[I],I))return!1;return typeof e==typeof g}function P3g(){mgt(),dDg()}const jw="top",mA="left",wA="right",Bm="bottom",_3g="top-left",O3g="top-right",J3g="bottom-left",L3g="bottom-right",fde="start",hne="middle",fo="end",U3g="x",Q3g="y",WO="group",mde="axis",pde="title",j3g="frame",$3g="scope",bde="legend",Cit="row-header",ait="row-footer",sit="row-title",Ait="column-header",lit="column-footer",cit="column-title",q3g="padding",ezg="symbol",uit="fit",dit="fit-x",hit="fit-y",tzg="pad",yde="none",xY="all",fne="each",Zde="flush",Hf="column",Nf="row";function fit(e){Le.call(this,null,e)}mt(fit,Le,{transform(e,g){const i=g.dataflow,n=e.mark,I=n.marktype,r=Za[I],o=r.bound;let C=n.bounds,a;if(r.nested)n.items.length&&i.dirty(n.items[0]),C=FY(n,o),n.items.forEach(A=>{A.bounds.clear().union(C)});else if(I===WO||e.modified())switch(g.visit(g.MOD,A=>i.dirty(A)),C.clear(),n.items.forEach(A=>C.union(FY(A,o))),n.role){case mde:case bde:case pde:g.reflow()}else a=g.changed(g.REM),g.visit(g.ADD,A=>{C.union(FY(A,o))}),g.visit(g.MOD,A=>{a=a||C.alignsWith(A.bounds),i.dirty(A),C.union(FY(A,o))}),a&&(C.clear(),n.items.forEach(A=>C.union(A.bounds)));return rit(n),g.modifies("bounds")}});function FY(e,g,i){return g(e.bounds.clear(),e,i)}const rHe=":vega_identifier:";function Gde(e){Le.call(this,0,e)}Gde.Definition={type:"Identifier",metadata:{modifies:!0},params:[{name:"as",type:"string",required:!0}]};mt(Gde,Le,{transform(e,g){const i=gzg(g.dataflow),n=e.as;let I=i.value;return g.visit(g.ADD,r=>r[n]=r[n]||++I),i.set(this.value=I),g}});function gzg(e){return e._signals[rHe]||(e._signals[rHe]=e.add(0))}function mit(e){Le.call(this,null,e)}mt(mit,Le,{transform(e,g){let i=this.value;i||(i=g.dataflow.scenegraph().mark(e.markdef,izg(e),e.index),i.group.context=e.context,e.context.group||(e.context.group=i.group),i.source=this.source,i.clip=e.clip,i.interactive=e.interactive,this.value=i);const n=i.marktype===WO?yO:bO;return g.visit(g.ADD,I=>n.call(I,i)),(e.modified("clip")||e.modified("interactive"))&&(i.clip=e.clip,i.interactive=!!e.interactive,i.zdirty=!0,g.reflow()),i.items=g.source,g}});function izg(e){const g=e.groups,i=e.parent;return g&&g.size===1?g.get(Object.keys(g.object)[0]):g&&i?g.lookup(i):null}function pit(e){Le.call(this,null,e)}const oHe={parity:e=>e.filter((g,i)=>i%2?g.opacity=0:1),greedy:(e,g)=>{let i;return e.filter((n,I)=>!I||!bit(i.bounds,n.bounds,g)?(i=n,1):n.opacity=0)}},bit=(e,g,i)=>i>Math.max(g.x1-e.x2,e.x1-g.x2,g.y1-e.y2,e.y1-g.y2),CHe=(e,g)=>{for(var i=1,n=e.length,I=e[0].bounds,r;i{const g=e.bounds;return g.width()>1&&g.height()>1},Izg=(e,g,i)=>{var n=e.range(),I=new oI;return g===jw||g===Bm?I.set(n[0],-1/0,n[1],1/0):I.set(-1/0,n[0],1/0,n[1]),I.expand(i||1),r=>I.encloses(r.bounds)},aHe=e=>(e.forEach(g=>g.opacity=1),e),sHe=(e,g)=>e.reflow(g.modified()).modifies("opacity");mt(pit,Le,{transform(e,g){const i=oHe[e.method]||oHe.parity,n=e.separation||0;let I=g.materialize(g.SOURCE).source,r,o;if(!I||!I.length)return;if(!e.method)return e.modified("method")&&(aHe(I),g=sHe(g,e)),g;if(I=I.filter(nzg),!I.length)return;if(e.sort&&(I=I.slice().sort(e.sort)),r=aHe(I),g=sHe(g,e),r.length>=3&&CHe(r,n)){do r=i(r,n);while(r.length>=3&&CHe(r,n));r.length<3&&!jg(I).opacity&&(r.length>1&&(jg(r).opacity=0),jg(I).opacity=1)}e.boundScale&&e.boundTolerance>=0&&(o=Izg(e.boundScale,e.boundOrient,+e.boundTolerance),I.forEach(a=>{o(a)||(a.opacity=0)}));const C=r[0].mark.bounds.clear();return I.forEach(a=>{a.opacity&&C.union(a.bounds)}),g}});function yit(e){Le.call(this,null,e)}mt(yit,Le,{transform(e,g){const i=g.dataflow;if(g.visit(g.ALL,n=>i.dirty(n)),g.fields&&g.fields.zindex){const n=g.source&&g.source[0];n&&(n.mark.zdirty=!0)}}});const Er=new oI;function vv(e,g,i){return e[g]===i?0:(e[g]=i,1)}function rzg(e){var g=e.items[0].orient;return g===mA||g===wA}function ozg(e){let g=+e.grid;return[e.ticks?g++:-1,e.labels?g++:-1,g+ +e.domain]}function Czg(e,g,i,n){var I=g.items[0],r=I.datum,o=I.translate!=null?I.translate:.5,C=I.orient,a=ozg(r),A=I.range,s=I.offset,l=I.position,c=I.minExtent,u=I.maxExtent,d=r.title&&I.items[a[2]].items[0],h=I.titlePadding,f=I.bounds,m=d&&ide(d),b=0,p=0,y,Z;switch(Er.clear().union(f),f.clear(),(y=a[0])>-1&&f.union(I.items[y].bounds),(y=a[1])>-1&&f.union(I.items[y].bounds),C){case jw:b=l||0,p=-s,Z=Math.max(c,Math.min(u,-f.y1)),f.add(0,-Z).add(A,0),d&&EY(e,d,Z,h,m,0,-1,f);break;case mA:b=-s,p=l||0,Z=Math.max(c,Math.min(u,-f.x1)),f.add(-Z,0).add(0,A),d&&EY(e,d,Z,h,m,1,-1,f);break;case wA:b=i+s,p=l||0,Z=Math.max(c,Math.min(u,f.x2)),f.add(0,0).add(Z,A),d&&EY(e,d,Z,h,m,1,1,f);break;case Bm:b=l||0,p=n+s,Z=Math.max(c,Math.min(u,f.y2)),f.add(0,0).add(A,Z),d&&EY(e,d,Z,h,0,0,1,f);break;default:b=I.x,p=I.y}return oh(f.translate(b,p),I),vv(I,"x",b+o)|vv(I,"y",p+o)&&(I.bounds=Er,e.dirty(I),I.bounds=f,e.dirty(I)),I.mark.bounds.clear().union(f)}function EY(e,g,i,n,I,r,o,C){const a=g.bounds;if(g.auto){const A=o*(i+I+n);let s=0,l=0;e.dirty(g),r?s=(g.x||0)-(g.x=A):l=(g.y||0)-(g.y=A),g.mark.bounds.clear().union(a.translate(-s,-l)),e.dirty(g)}C.union(a)}const AHe=(e,g)=>Math.floor(Math.min(e,g)),lHe=(e,g)=>Math.ceil(Math.max(e,g));function azg(e){var g=e.items,i=g.length,n=0,I,r;const o={marks:[],rowheaders:[],rowfooters:[],colheaders:[],colfooters:[],rowtitle:null,coltitle:null};for(;n1)for(G=0;G0&&(p[G]+=V/2);if(C&&an(i.center,Nf)&&s!==1)for(G=0;G0&&(y[G]+=X/2);for(G=0;GI&&(e.warn("Grid headers exceed limit: "+I),g=g.slice(0,I)),h+=r,b=0,y=g.length;b=0&&(G=i[p])==null;p-=c);C?(B=u==null?G.x:Math.round(G.bounds.x1+u*G.bounds.width()),S=h):(B=h,S=u==null?G.y:Math.round(G.bounds.y1+u*G.bounds.height())),Z.union(v.bounds.translate(B-(v.x||0),S-(v.y||0))),v.x=B,v.y=S,e.dirty(v),f=o(f,Z[A])}return f}function uHe(e,g,i,n,I,r){if(g){e.dirty(g);var o=i,C=i;n?o=Math.round(I.x1+r*I.width()):C=Math.round(I.y1+r*I.height()),g.bounds.translate(o-(g.x||0),C-(g.y||0)),g.mark.bounds.clear().union(g.bounds),g.x=o,g.y=C,e.dirty(g)}}function dzg(e,g){const i=e[g]||{};return(n,I)=>i[n]!=null?i[n]:e[n]!=null?e[n]:I}function hzg(e,g){let i=-1/0;return e.forEach(n=>{n.offset!=null&&(i=Math.max(i,n.offset))}),i>-1/0?i:g}function fzg(e,g,i,n,I,r,o){const C=dzg(i,g),a=hzg(e,C("offset",0)),A=C("anchor",fde),s=A===fo?1:A===hne?.5:0,l={align:fne,bounds:C("bounds",Zde),columns:C("direction")==="vertical"?1:e.length,padding:C("margin",8),center:C("center"),nodirty:!0};switch(g){case mA:l.anchor={x:Math.floor(n.x1)-a,column:fo,y:s*(o||n.height()+2*n.y1),row:A};break;case wA:l.anchor={x:Math.ceil(n.x2)+a,y:s*(o||n.height()+2*n.y1),row:A};break;case jw:l.anchor={y:Math.floor(I.y1)-a,row:fo,x:s*(r||I.width()+2*I.x1),column:A};break;case Bm:l.anchor={y:Math.ceil(I.y2)+a,x:s*(r||I.width()+2*I.x1),column:A};break;case _3g:l.anchor={x:a,y:a};break;case O3g:l.anchor={x:r-a,y:a,column:fo};break;case J3g:l.anchor={x:a,y:o-a,row:fo};break;case L3g:l.anchor={x:r-a,y:o-a,column:fo,row:fo};break}return l}function mzg(e,g){var i=g.items[0],n=i.datum,I=i.orient,r=i.bounds,o=i.x,C=i.y,a,A;return i._bounds?i._bounds.clear().union(r):i._bounds=r.clone(),r.clear(),bzg(e,i,i.items[0].items[0]),r=pzg(i,r),a=2*i.padding,A=2*i.padding,r.empty()||(a=Math.ceil(r.width()+a),A=Math.ceil(r.height()+A)),n.type===ezg&&yzg(i.items[0].items[0].items[0].items),I!==yde&&(i.x=o=0,i.y=C=0),i.width=a,i.height=A,oh(r.set(o,C,o+a,C+A),i),i.mark.bounds.clear().union(r),i}function pzg(e,g){return e.items.forEach(i=>g.union(i.bounds)),g.x1=e.padding,g.y1=e.padding,g}function bzg(e,g,i){var n=g.padding,I=n-i.x,r=n-i.y;if(!g.datum.title)(I||r)&&QR(e,i,I,r);else{var o=g.items[1].items[0],C=o.anchor,a=g.titlePadding||0,A=n-o.x,s=n-o.y;switch(o.orient){case mA:I+=Math.ceil(o.bounds.width())+a;break;case wA:case Bm:break;default:r+=o.bounds.height()+a}switch((I||r)&&QR(e,i,I,r),o.orient){case mA:s+=dG(g,i,o,C,1,1);break;case wA:A+=dG(g,i,o,fo,0,0)+a,s+=dG(g,i,o,C,1,1);break;case Bm:A+=dG(g,i,o,C,0,0),s+=dG(g,i,o,fo,-1,0,1)+a;break;default:A+=dG(g,i,o,C,0,0)}(A||s)&&QR(e,o,A,s),(A=Math.round(o.bounds.x1-n))<0&&(QR(e,i,-A,0),QR(e,o,-A,0))}}function dG(e,g,i,n,I,r,o){const C=e.datum.type!=="symbol",a=i.datum.vgrad,A=C&&(r||!a)&&!o?g.items[0]:g,s=A.bounds[I?"y2":"x2"]-e.padding,l=a&&r?s:0,c=a&&r?0:s,u=I<=0?0:ide(i);return Math.round(n===fde?l:n===fo?c-u:.5*(s-u))}function QR(e,g,i,n){g.x+=i,g.y+=n,g.bounds.translate(i,n),g.mark.bounds.translate(i,n),e.dirty(g)}function yzg(e){const g=e.reduce((i,n)=>(i[n.column]=Math.max(n.bounds.x2-n.x,i[n.column]||0),i),{});e.forEach(i=>{i.width=g[i.column],i.height=i.bounds.y2-i.y})}function Zzg(e,g,i,n,I){var r=g.items[0],o=r.frame,C=r.orient,a=r.anchor,A=r.offset,s=r.padding,l=r.items[0].items[0],c=r.items[1]&&r.items[1].items[0],u=C===mA||C===wA?n:i,d=0,h=0,f=0,m=0,b=0,p;if(o!==WO?C===mA?(d=I.y2,u=I.y1):C===wA?(d=I.y1,u=I.y2):(d=I.x1,u=I.x2):C===mA&&(d=n,u=0),p=a===fde?d:a===fo?u:(d+u)/2,c&&c.text){switch(C){case jw:case Bm:b=l.bounds.height()+s;break;case mA:m=l.bounds.width()+s;break;case wA:m=-l.bounds.width()-s;break}Er.clear().union(c.bounds),Er.translate(m-(c.x||0),b-(c.y||0)),vv(c,"x",m)|vv(c,"y",b)&&(e.dirty(c),c.bounds.clear().union(Er),c.mark.bounds.clear().union(Er),e.dirty(c)),Er.clear().union(c.bounds)}else Er.clear();switch(Er.union(l.bounds),C){case jw:h=p,f=I.y1-Er.height()-A;break;case mA:h=I.x1-Er.width()-A,f=p;break;case wA:h=I.x2+Er.width()+A,f=p;break;case Bm:h=p,f=I.y2+A;break;default:h=r.x,f=r.y}return vv(r,"x",h)|vv(r,"y",f)&&(Er.translate(h,f),e.dirty(r),r.bounds.clear().union(Er),g.bounds.clear().union(Er),e.dirty(r)),r.bounds}function Git(e){Le.call(this,null,e)}mt(Git,Le,{transform(e,g){const i=g.dataflow;return e.mark.items.forEach(n=>{e.layout&&lzg(i,n,e.layout),vzg(i,n,e)}),Gzg(e.mark.group)?g.reflow():g}});function Gzg(e){return e&&e.mark.role!=="legend-entry"}function vzg(e,g,i){var n=g.items,I=Math.max(0,g.width||0),r=Math.max(0,g.height||0),o=new oI().set(0,0,I,r),C=o.clone(),a=o.clone(),A=[],s,l,c,u,d,h;for(d=0,h=n.length;d{c=m.orient||wA,c!==yde&&(f[c]||(f[c]=[])).push(m)});for(const m in f){const b=f[m];Zit(e,b,fzg(b,m,i.legends,C,a,I,r))}A.forEach(m=>{const b=m.bounds;if(b.equals(m._bounds)||(m.bounds=m._bounds,e.dirty(m),m.bounds=b,e.dirty(m)),i.autosize&&(i.autosize.type===uit||i.autosize.type===dit||i.autosize.type===hit))switch(m.orient){case mA:case wA:o.add(b.x1,0).add(b.x2,0);break;case jw:case Bm:o.add(0,b.y1).add(0,b.y2)}else o.union(b)})}o.union(C).union(a),s&&o.union(Zzg(e,s,I,r,o)),g.clip&&o.set(0,0,g.width||0,g.height||0),Bzg(e,g,o,i)}function Bzg(e,g,i,n){const I=n.autosize||{},r=I.type;if(e._autosize<1||!r)return;let o=e._width,C=e._height,a=Math.max(0,g.width||0),A=Math.max(0,Math.ceil(-i.x1)),s=Math.max(0,g.height||0),l=Math.max(0,Math.ceil(-i.y1));const c=Math.max(0,Math.ceil(i.x2-a)),u=Math.max(0,Math.ceil(i.y2-s));if(I.contains===q3g){const d=e.padding();o-=d.left+d.right,C-=d.top+d.bottom}r===yde?(A=0,l=0,a=o,s=C):r===uit?(a=Math.max(0,o-A-c),s=Math.max(0,C-l-u)):r===dit?(a=Math.max(0,o-A-c),C=s+l+u):r===hit?(o=a+A+c,s=Math.max(0,C-l-u)):r===tzg&&(o=a+A+c,C=s+l+u),e._resizeView(o,C,a,s,[A,l],I.resize)}const wzg=Object.freeze(Object.defineProperty({__proto__:null,bound:fit,identifier:Gde,mark:mit,overlap:pit,render:yit,viewlayout:Git},Symbol.toStringTag,{value:"Module"}));function vit(e){Le.call(this,null,e)}mt(vit,Le,{transform(e,g){if(this.value&&!e.modified())return g.StopPropagation;var i=g.dataflow.locale(),n=g.fork(g.NO_SOURCE|g.NO_FIELDS),I=this.value,r=e.scale,o=e.count==null?e.values?e.values.length:10:e.count,C=xue(r,o,e.minstep),a=e.format||ngt(i,r,C,e.formatSpecifier,e.formatType,!!e.values),A=e.values?igt(r,e.values,C):Fue(r,C);return I&&(n.rem=I),I=A.map((s,l)=>li({index:l/(A.length-1||1),value:s,label:a(s)})),e.extra&&I.length&&I.push(li({index:-1,extra:{value:I[0].value},label:""})),n.source=I,n.add=I,this.value=I,n}});function Bit(e){Le.call(this,null,e)}function Szg(){return li({})}function Rzg(e){const g=cS().test(i=>i.exit);return g.lookup=i=>g.get(e(i)),g}mt(Bit,Le,{transform(e,g){var i=g.dataflow,n=g.fork(g.NO_SOURCE|g.NO_FIELDS),I=e.item||Szg,r=e.key||eg,o=this.value;return et(n.encode)&&(n.encode=null),o&&(e.modified("key")||g.modified(r))&&qe("DataJoin does not support modified key function or fields."),o||(g=g.addAll(),this.value=o=Rzg(r)),g.visit(g.ADD,C=>{const a=r(C);let A=o.get(a);A?A.exit?(o.empty--,n.add.push(A)):n.mod.push(A):(A=I(C),o.set(a,A),n.add.push(A)),A.datum=C,A.exit=!1}),g.visit(g.MOD,C=>{const a=r(C),A=o.get(a);A&&(A.datum=C,n.mod.push(A))}),g.visit(g.REM,C=>{const a=r(C),A=o.get(a);C===A.datum&&!A.exit&&(n.rem.push(A),A.exit=!0,++o.empty)}),g.changed(g.ADD_MOD)&&n.modifies("datum"),(g.clean()||e.clean&&o.empty>i.cleanThreshold)&&i.runAfter(o.clean),n}});function wit(e){Le.call(this,null,e)}mt(wit,Le,{transform(e,g){var i=g.fork(g.ADD_REM),n=e.mod||!1,I=e.encoders,r=g.encode;if(et(r))if(i.changed()||r.every(l=>I[l]))r=r[0],i.encode=null;else return g.StopPropagation;var o=r==="enter",C=I.update||_h,a=I.enter||_h,A=I.exit||_h,s=(r&&!o?I[r]:C)||_h;if(g.changed(g.ADD)&&(g.visit(g.ADD,l=>{a(l,e),C(l,e)}),i.modifies(a.output),i.modifies(C.output),s!==_h&&s!==C&&(g.visit(g.ADD,l=>{s(l,e)}),i.modifies(s.output))),g.changed(g.REM)&&A!==_h&&(g.visit(g.REM,l=>{A(l,e)}),i.modifies(A.output)),o||s!==_h){const l=g.MOD|(e.modified()?g.REFLOW:0);o?(g.visit(l,c=>{const u=a(c,e)||n;(s(c,e)||u)&&i.mod.push(c)}),i.mod.length&&i.modifies(a.output)):g.visit(l,c=>{(s(c,e)||n)&&i.mod.push(c)}),i.mod.length&&i.modifies(s.output)}return i.changed()?i:g.StopPropagation}});function Sit(e){Le.call(this,[],e)}mt(Sit,Le,{transform(e,g){if(this.value!=null&&!e.modified())return g.StopPropagation;var i=g.dataflow.locale(),n=g.fork(g.NO_SOURCE|g.NO_FIELDS),I=this.value,r=e.type||M5,o=e.scale,C=+e.limit,a=xue(o,e.count==null?5:e.count,e.minstep),A=!!e.values||r===M5,s=e.format||Cgt(i,o,a,r,e.formatSpecifier,e.formatType,A),l=e.values||ogt(o,a),c,u,d,h,f;return I&&(n.rem=I),r===M5?(C&&l.length>C?(g.dataflow.warn("Symbol legend count exceeds limit, filtering items."),I=l.slice(0,C-1),f=!0):I=l,Bg(d=e.size)?(!e.values&&o(I[0])===0&&(I=I.slice(1)),h=I.reduce((m,b)=>Math.max(m,d(b,e)),0)):d=no(h=d||8),I=I.map((m,b)=>li({index:b,label:s(m,b,I),value:m,offset:h,size:d(m,e)})),f&&(f=l[I.length],I.push(li({index:I.length,label:`…${l.length-I.length} entries`,value:f,offset:h,size:d(f,e)})))):r===gDg?(c=o.domain(),u=egt(o,c[0],jg(c)),l.length<3&&!e.values&&c[0]!==jg(c)&&(l=[c[0],jg(c)]),I=l.map((m,b)=>li({index:b,label:s(m,b,l),value:m,perc:u(m)}))):(d=l.length-1,u=cDg(o),I=l.map((m,b)=>li({index:b,label:s(m,b,l),value:m,perc:b?u(m):0,perc2:b===d?1:u(l[b+1])}))),n.source=I,n.add=I,this.value=I,n}});const Vzg=e=>e.source.x,Wzg=e=>e.source.y,Xzg=e=>e.target.x,Tzg=e=>e.target.y;function vde(e){Le.call(this,{},e)}vde.Definition={type:"LinkPath",metadata:{modifies:!0},params:[{name:"sourceX",type:"field",default:"source.x"},{name:"sourceY",type:"field",default:"source.y"},{name:"targetX",type:"field",default:"target.x"},{name:"targetY",type:"field",default:"target.y"},{name:"orient",type:"enum",default:"vertical",values:["horizontal","vertical","radial"]},{name:"shape",type:"enum",default:"line",values:["line","arc","curve","diagonal","orthogonal"]},{name:"require",type:"signal"},{name:"as",type:"string",default:"path"}]};mt(vde,Le,{transform(e,g){var i=e.sourceX||Vzg,n=e.sourceY||Wzg,I=e.targetX||Xzg,r=e.targetY||Tzg,o=e.as||"path",C=e.orient||"vertical",a=e.shape||"line",A=dHe.get(a+"-"+C)||dHe.get(a);return A||qe("LinkPath unsupported type: "+e.shape+(e.orient?"-"+e.orient:"")),g.visit(g.SOURCE,s=>{s[o]=A(i(s),n(s),I(s),r(s))}),g.reflow(e.modified()).modifies(o)}});const Rit=(e,g,i,n)=>"M"+e+","+g+"L"+i+","+n,Hzg=(e,g,i,n)=>Rit(g*Math.cos(e),g*Math.sin(e),n*Math.cos(i),n*Math.sin(i)),Vit=(e,g,i,n)=>{var I=i-e,r=n-g,o=Math.hypot(I,r)/2,C=180*Math.atan2(r,I)/Math.PI;return"M"+e+","+g+"A"+o+","+o+" "+C+" 0 1 "+i+","+n},Nzg=(e,g,i,n)=>Vit(g*Math.cos(e),g*Math.sin(e),n*Math.cos(i),n*Math.sin(i)),Wit=(e,g,i,n)=>{const I=i-e,r=n-g,o=.2*(I+r),C=.2*(r-I);return"M"+e+","+g+"C"+(e+o)+","+(g+C)+" "+(i+C)+","+(n-o)+" "+i+","+n},kzg=(e,g,i,n)=>Wit(g*Math.cos(e),g*Math.sin(e),n*Math.cos(i),n*Math.sin(i)),Yzg=(e,g,i,n)=>"M"+e+","+g+"V"+n+"H"+i,Kzg=(e,g,i,n)=>"M"+e+","+g+"H"+i+"V"+n,xzg=(e,g,i,n)=>{const I=Math.cos(e),r=Math.sin(e),o=Math.cos(i),C=Math.sin(i),a=Math.abs(i-e)>Math.PI?i<=e:i>e;return"M"+g*I+","+g*r+"A"+g+","+g+" 0 0,"+(a?1:0)+" "+g*o+","+g*C+"L"+n*o+","+n*C},Fzg=(e,g,i,n)=>{const I=(e+i)/2;return"M"+e+","+g+"C"+I+","+g+" "+I+","+n+" "+i+","+n},Ezg=(e,g,i,n)=>{const I=(g+n)/2;return"M"+e+","+g+"C"+e+","+I+" "+i+","+I+" "+i+","+n},Dzg=(e,g,i,n)=>{const I=Math.cos(e),r=Math.sin(e),o=Math.cos(i),C=Math.sin(i),a=(g+n)/2;return"M"+g*I+","+g*r+"C"+a*I+","+a*r+" "+a*o+","+a*C+" "+n*o+","+n*C},dHe=cS({line:Rit,"line-radial":Hzg,arc:Vit,"arc-radial":Nzg,curve:Wit,"curve-radial":kzg,"orthogonal-horizontal":Yzg,"orthogonal-vertical":Kzg,"orthogonal-radial":xzg,"diagonal-horizontal":Fzg,"diagonal-vertical":Ezg,"diagonal-radial":Dzg});function Bde(e){Le.call(this,null,e)}Bde.Definition={type:"Pie",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"startAngle",type:"number",default:0},{name:"endAngle",type:"number",default:6.283185307179586},{name:"sort",type:"boolean",default:!1},{name:"as",type:"string",array:!0,length:2,default:["startAngle","endAngle"]}]};mt(Bde,Le,{transform(e,g){var i=e.as||["startAngle","endAngle"],n=i[0],I=i[1],r=e.field||sS,o=e.startAngle||0,C=e.endAngle!=null?e.endAngle:2*Math.PI,a=g.source,A=a.map(r),s=A.length,l=o,c=(C-o)/eqe(A),u=ca(s),d,h,f;for(e.sort&&u.sort((m,b)=>A[m]-A[b]),d=0;d-1)return n;var I=g.domain,r=e.type,o=g.zero||g.zero===void 0&&zzg(e),C,a;if(!I)return 0;if(Xit(r)&&g.padding&&I[0]!==jg(I)&&(I=Uzg(r,I,g.range,g.padding,g.exponent,g.constant)),(o||g.domainMin!=null||g.domainMax!=null||g.domainMid!=null)&&(C=(I=I.slice()).length-1||1,o&&(I[0]>0&&(I[0]=0),I[C]<0&&(I[C]=0)),g.domainMin!=null&&(I[0]=g.domainMin),g.domainMax!=null&&(I[C]=g.domainMax),g.domainMid!=null)){a=g.domainMid;const A=a>I[C]?C+1:aI+(r<0?-1:r>0?1:0),0));n!==g.length&&i.warn("Log scale domain includes zero: "+ft(g))}return g}function Qzg(e,g,i){let n=g.bins;if(n&&!et(n)){const I=e.domain(),r=I[0],o=jg(I),C=n.step;let a=n.start==null?r:n.start,A=n.stop==null?o:n.stop;C||qe("Scale bins parameter missing step property."),ao&&(A=C*Math.floor(o/C)),n=ca(a,A+C/2,C)}return n?e.bins=n:e.bins&&delete e.bins,e.type===Tue&&(n?!g.domain&&!g.domainRaw&&(e.domain(n),i=n.length):e.bins=e.domain()),i}function jzg(e,g,i){var n=e.type,I=g.round||!1,r=g.range;if(g.rangeStep!=null)r=$zg(n,g,i);else if(g.scheme&&(r=qzg(n,g,i),Bg(r))){if(e.interpolator)return e.interpolator(r);qe(`Scale type ${n} does not support interpolating color schemes.`)}if(r&&Qtt(n))return e.interpolator(mO(mne(r,g.reverse),g.interpolate,g.interpolateGamma));r&&g.interpolate&&e.interpolate?e.interpolate(Yue(g.interpolate,g.interpolateGamma)):Bg(e.round)?e.round(I):Bg(e.rangeRound)&&e.interpolate(I?XH:Ip),r&&e.range(mne(r,g.reverse))}function $zg(e,g,i){e!==ztt&&e!==ine&&qe("Only band and point scales support rangeStep.");var n=(g.paddingOuter!=null?g.paddingOuter:g.padding)||0,I=e===ine?1:(g.paddingInner!=null?g.paddingInner:g.padding)||0;return[0,g.rangeStep*Wue(i,I,n)]}function qzg(e,g,i){var n=g.schemeExtent,I,r;return et(g.scheme)?r=mO(g.scheme,g.interpolate,g.interpolateGamma):(I=g.scheme.toLowerCase(),r=Kue(I),r||qe(`Unrecognized scheme name: ${g.scheme}`)),i=e===fO?i+1:e===Tue?i-1:e===_w||e===hO?+g.schemeCount||Mzg:i,Qtt(e)?hHe(r,n,g.reverse):Bg(r)?qtt(hHe(r,n),i):e===Xue?r:r.slice(0,i)}function hHe(e,g,i){return Bg(e)&&(g||i)?$tt(e,mne(g||[0,1],i)):e}function mne(e,g){return g?e.slice().reverse():e}function Nit(e){Le.call(this,null,e)}mt(Nit,Le,{transform(e,g){const i=e.modified("sort")||g.changed(g.ADD)||g.modified(e.sort.fields)||g.modified("datum");return i&&g.source.sort(dZ(e.sort)),this.modified(i),g}});const fHe="zero",kit="center",Yit="normalize",Kit=["y0","y1"];function wde(e){Le.call(this,null,e)}wde.Definition={type:"Stack",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"groupby",type:"field",array:!0},{name:"sort",type:"compare"},{name:"offset",type:"enum",default:fHe,values:[fHe,kit,Yit]},{name:"as",type:"string",array:!0,length:2,default:Kit}]};mt(wde,Le,{transform(e,g){var i=e.as||Kit,n=i[0],I=i[1],r=dZ(e.sort),o=e.field||sS,C=e.offset===kit?ePg:e.offset===Yit?tPg:gPg,a,A,s,l;for(a=iPg(g.source,e.groupby,r,o),A=0,s=a.length,l=a.max;Ah(s),o,C,a,A,s,l,c,u,d;if(g==null)I.push(e.slice());else for(o={},C=0,a=e.length;Cd&&(d=u),i&&c.sort(i)}return I.max=d,I}const nPg=Object.freeze(Object.defineProperty({__proto__:null,axisticks:vit,datajoin:Bit,encode:wit,legendentries:Sit,linkpath:vde,pie:Bde,scale:Tit,sortitems:Nit,stack:wde},Symbol.toStringTag,{value:"Module"}));var og=1e-6,vM=1e-12,kg=Math.PI,Kn=kg/2,BM=kg/4,Mo=kg*2,Ln=180/kg,Xg=kg/180,Qg=Math.abs,ZS=Math.atan,bs=Math.atan2,Ag=Math.cos,MY=Math.ceil,xit=Math.exp,pne=Math.hypot,wM=Math.log,e4=Math.pow,tg=Math.sin,gs=Math.sign||function(e){return e>0?1:e<0?-1:0},zo=Math.sqrt,Sde=Math.tan;function Fit(e){return e>1?0:e<-1?kg:Math.acos(e)}function YC(e){return e>1?Kn:e<-1?-Kn:Math.asin(e)}function cr(){}function SM(e,g){e&&pHe.hasOwnProperty(e.type)&&pHe[e.type](e,g)}var mHe={Feature:function(e,g){SM(e.geometry,g)},FeatureCollection:function(e,g){for(var i=e.features,n=-1,I=i.length;++n=0?1:-1,I=n*i,r=Ag(g),o=tg(g),C=Gne*o,a=Zne*r+C*Ag(I),A=C*n*tg(I);RM.add(bs(A,a)),yne=e,Zne=r,Gne=o}function CPg(e){return VM=new Yo,_u(e,Fc),VM*2}function WM(e){return[bs(e[1],e[0]),YC(e[2])]}function uy(e){var g=e[0],i=e[1],n=Ag(i);return[n*Ag(g),n*tg(g),tg(i)]}function zY(e,g){return e[0]*g[0]+e[1]*g[1]+e[2]*g[2]}function $w(e,g){return[e[1]*g[2]-e[2]*g[1],e[2]*g[0]-e[0]*g[2],e[0]*g[1]-e[1]*g[0]]}function t4(e,g){e[0]+=g[0],e[1]+=g[1],e[2]+=g[2]}function PY(e,g){return[e[0]*g,e[1]*g,e[2]*g]}function XM(e){var g=zo(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=g,e[1]/=g,e[2]/=g}var Zn,dC,Hn,na,r0,zit,Pit,lB,YW,tf,zd,Du={point:vne,lineStart:yHe,lineEnd:ZHe,polygonStart:function(){Du.point=Oit,Du.lineStart=aPg,Du.lineEnd=sPg,YW=new Yo,Fc.polygonStart()},polygonEnd:function(){Fc.polygonEnd(),Du.point=vne,Du.lineStart=yHe,Du.lineEnd=ZHe,RM<0?(Zn=-(Hn=180),dC=-(na=90)):YW>og?na=90:YW<-og&&(dC=-90),zd[0]=Zn,zd[1]=Hn},sphere:function(){Zn=-(Hn=180),dC=-(na=90)}};function vne(e,g){tf.push(zd=[Zn=e,Hn=e]),gna&&(na=g)}function _it(e,g){var i=uy([e*Xg,g*Xg]);if(lB){var n=$w(lB,i),I=[n[1],-n[0],0],r=$w(I,n);XM(r),r=WM(r);var o=e-r0,C=o>0?1:-1,a=r[0]*Ln*C,A,s=Qg(o)>180;s^(C*r0na&&(na=A)):(a=(a+360)%360-180,s^(C*r0na&&(na=g))),s?eea(Zn,Hn)&&(Hn=e):ea(e,Hn)>ea(Zn,Hn)&&(Zn=e):Hn>=Zn?(eHn&&(Hn=e)):e>r0?ea(Zn,e)>ea(Zn,Hn)&&(Hn=e):ea(e,Hn)>ea(Zn,Hn)&&(Zn=e)}else tf.push(zd=[Zn=e,Hn=e]);gna&&(na=g),lB=i,r0=e}function yHe(){Du.point=_it}function ZHe(){zd[0]=Zn,zd[1]=Hn,Du.point=vne,lB=null}function Oit(e,g){if(lB){var i=e-r0;YW.add(Qg(i)>180?i+(i>0?360:-360):i)}else zit=e,Pit=g;Fc.point(e,g),_it(e,g)}function aPg(){Fc.lineStart()}function sPg(){Oit(zit,Pit),Fc.lineEnd(),Qg(YW)>og&&(Zn=-(Hn=180)),zd[0]=Zn,zd[1]=Hn,lB=null}function ea(e,g){return(g-=e)<0?g+360:g}function APg(e,g){return e[0]-g[0]}function GHe(e,g){return e[0]<=e[1]?e[0]<=g&&g<=e[1]:gea(n[0],n[1])&&(n[1]=I[1]),ea(I[0],n[1])>ea(n[0],n[1])&&(n[0]=I[0])):r.push(n=I);for(o=-1/0,i=r.length-1,g=0,n=r[i];g<=i;n=I,++g)I=r[g],(C=ea(n[1],I[0]))>o&&(o=C,Zn=I[0],Hn=n[1])}return tf=zd=null,Zn===1/0||dC===1/0?[[NaN,NaN],[NaN,NaN]]:[[Zn,dC],[Hn,na]]}var s2,TM,HM,NM,kM,YM,KM,xM,Bne,wne,Sne,Jit,Lit,wo,So,Ro,SA={sphere:cr,point:Rde,lineStart:vHe,lineEnd:BHe,polygonStart:function(){SA.lineStart=dPg,SA.lineEnd=hPg},polygonEnd:function(){SA.lineStart=vHe,SA.lineEnd=BHe}};function Rde(e,g){e*=Xg,g*=Xg;var i=Ag(g);_H(i*Ag(e),i*tg(e),tg(g))}function _H(e,g,i){++s2,HM+=(e-HM)/s2,NM+=(g-NM)/s2,kM+=(i-kM)/s2}function vHe(){SA.point=cPg}function cPg(e,g){e*=Xg,g*=Xg;var i=Ag(g);wo=i*Ag(e),So=i*tg(e),Ro=tg(g),SA.point=uPg,_H(wo,So,Ro)}function uPg(e,g){e*=Xg,g*=Xg;var i=Ag(g),n=i*Ag(e),I=i*tg(e),r=tg(g),o=bs(zo((o=So*r-Ro*I)*o+(o=Ro*n-wo*r)*o+(o=wo*I-So*n)*o),wo*n+So*I+Ro*r);TM+=o,YM+=o*(wo+(wo=n)),KM+=o*(So+(So=I)),xM+=o*(Ro+(Ro=r)),_H(wo,So,Ro)}function BHe(){SA.point=Rde}function dPg(){SA.point=fPg}function hPg(){Uit(Jit,Lit),SA.point=Rde}function fPg(e,g){Jit=e,Lit=g,e*=Xg,g*=Xg,SA.point=Uit;var i=Ag(g);wo=i*Ag(e),So=i*tg(e),Ro=tg(g),_H(wo,So,Ro)}function Uit(e,g){e*=Xg,g*=Xg;var i=Ag(g),n=i*Ag(e),I=i*tg(e),r=tg(g),o=So*r-Ro*I,C=Ro*n-wo*r,a=wo*I-So*n,A=pne(o,C,a),s=YC(A),l=A&&-s/A;Bne.add(l*o),wne.add(l*C),Sne.add(l*a),TM+=s,YM+=s*(wo+(wo=n)),KM+=s*(So+(So=I)),xM+=s*(Ro+(Ro=r)),_H(wo,So,Ro)}function mPg(e){s2=TM=HM=NM=kM=YM=KM=xM=0,Bne=new Yo,wne=new Yo,Sne=new Yo,_u(e,SA);var g=+Bne,i=+wne,n=+Sne,I=pne(g,i,n);return Ikg&&(e-=Math.round(e/Mo)*Mo),[e,g]}Vne.invert=Vne;function Qit(e,g,i){return(e%=Mo)?g||i?Rne(SHe(e),RHe(g,i)):SHe(e):g||i?RHe(g,i):Vne}function wHe(e){return function(g,i){return g+=e,Qg(g)>kg&&(g-=Math.round(g/Mo)*Mo),[g,i]}}function SHe(e){var g=wHe(e);return g.invert=wHe(-e),g}function RHe(e,g){var i=Ag(e),n=tg(e),I=Ag(g),r=tg(g);function o(C,a){var A=Ag(a),s=Ag(C)*A,l=tg(C)*A,c=tg(a),u=c*i+s*n;return[bs(l*I-u*r,s*i-c*n),YC(u*I+l*r)]}return o.invert=function(C,a){var A=Ag(a),s=Ag(C)*A,l=tg(C)*A,c=tg(a),u=c*I-l*r;return[bs(l*I+c*r,s*i+u*n),YC(u*i-s*n)]},o}function pPg(e){e=Qit(e[0]*Xg,e[1]*Xg,e.length>2?e[2]*Xg:0);function g(i){return i=e(i[0]*Xg,i[1]*Xg),i[0]*=Ln,i[1]*=Ln,i}return g.invert=function(i){return i=e.invert(i[0]*Xg,i[1]*Xg),i[0]*=Ln,i[1]*=Ln,i},g}function bPg(e,g,i,n,I,r){if(i){var o=Ag(g),C=tg(g),a=n*i;I==null?(I=g+n*Mo,r=g-a/2):(I=VHe(o,I),r=VHe(o,r),(n>0?Ir)&&(I+=n*Mo));for(var A,s=I;n>0?s>r:s1&&e.push(e.pop().concat(e.shift()))},result:function(){var i=e;return e=[],g=null,i}}}function Q5(e,g){return Qg(e[0]-g[0])=0;--C)I.point((l=s[C])[0],l[1]);else n(c.x,c.p.x,-1,I);c=c.p}c=c.o,s=c.z,u=!u}while(!c.v);I.lineEnd()}}}function WHe(e){if(g=e.length){for(var g,i=0,n=e[0],I;++i=0?1:-1,R=S*B,w=R>kg,T=f*v;if(a.add(bs(T*S*tg(R),m*G+T*Ag(R))),o+=w?B+S*Mo:B,w^d>=i^y>=i){var W=$w(uy(u),uy(p));XM(W);var V=$w(r,W);XM(V);var X=(w^B>=0?-1:1)*YC(V[2]);(n>X||n===X&&(W[0]||W[1]))&&(C+=w^B>=0?1:-1)}}return(o<-og||o0){for(a||(I.polygonStart(),a=!0),I.lineStart(),v=0;v1&&y&2&&Z.push(Z.pop().concat(Z.shift())),s.push(Z.filter(ZPg))}}return c}}function ZPg(e){return e.length>1}function GPg(e,g){return((e=e.x)[0]<0?e[1]-Kn-og:Kn-e[1])-((g=g.x)[0]<0?g[1]-Kn-og:Kn-g[1])}const XHe=qit(function(){return!0},vPg,wPg,[-kg,-Kn]);function vPg(e){var g=NaN,i=NaN,n=NaN,I;return{lineStart:function(){e.lineStart(),I=1},point:function(r,o){var C=r>0?kg:-kg,a=Qg(r-g);Qg(a-kg)0?Kn:-Kn),e.point(n,i),e.lineEnd(),e.lineStart(),e.point(C,i),e.point(r,i),I=0):n!==C&&a>=kg&&(Qg(g-n)og?ZS((tg(g)*(r=Ag(n))*tg(i)-tg(n)*(I=Ag(g))*tg(e))/(I*r*o)):(g+n)/2}function wPg(e,g,i,n){var I;if(e==null)I=i*Kn,n.point(-kg,I),n.point(0,I),n.point(kg,I),n.point(kg,0),n.point(kg,-I),n.point(0,-I),n.point(-kg,-I),n.point(-kg,0),n.point(-kg,I);else if(Qg(e[0]-g[0])>og){var r=e[0]0,I=Qg(g)>og;function r(s,l,c,u){bPg(u,e,i,c,s,l)}function o(s,l){return Ag(s)*Ag(l)>g}function C(s){var l,c,u,d,h;return{lineStart:function(){d=u=!1,h=1},point:function(f,m){var b=[f,m],p,y=o(f,m),Z=n?y?0:A(f,m):y?A(f+(f<0?kg:-kg),m):0;if(!l&&(d=u=y)&&s.lineStart(),y!==u&&(p=a(l,b),(!p||Q5(l,p)||Q5(b,p))&&(b[2]=1)),y!==u)h=0,y?(s.lineStart(),p=a(b,l),s.point(p[0],p[1])):(p=a(l,b),s.point(p[0],p[1],2),s.lineEnd()),l=p;else if(I&&l&&n^y){var v;!(Z&c)&&(v=a(b,l,!0))&&(h=0,n?(s.lineStart(),s.point(v[0][0],v[0][1]),s.point(v[1][0],v[1][1]),s.lineEnd()):(s.point(v[1][0],v[1][1]),s.lineEnd(),s.lineStart(),s.point(v[0][0],v[0][1],3)))}y&&(!l||!Q5(l,b))&&s.point(b[0],b[1]),l=b,u=y,c=Z},lineEnd:function(){u&&s.lineEnd(),l=null},clean:function(){return h|(d&&u)<<1}}}function a(s,l,c){var u=uy(s),d=uy(l),h=[1,0,0],f=$w(u,d),m=zY(f,f),b=f[0],p=m-b*b;if(!p)return!c&&s;var y=g*m/p,Z=-g*b/p,v=$w(h,f),G=PY(h,y),B=PY(f,Z);t4(G,B);var S=v,R=zY(G,S),w=zY(S,S),T=R*R-w*(zY(G,G)-1);if(!(T<0)){var W=zo(T),V=PY(S,(-R-W)/w);if(t4(V,G),V=WM(V),!c)return V;var X=s[0],N=l[0],Y=s[1],x=l[1],M;N0^V[1]<(Qg(V[0]-X)kg^(X<=V[0]&&V[0]<=N)){var U=PY(S,(-R+W)/w);return t4(U,G),[V,WM(U)]}}}function A(s,l){var c=n?e:kg-e,u=0;return s<-c?u|=1:s>c&&(u|=2),l<-c?u|=4:l>c&&(u|=8),u}return qit(o,C,r,n?[0,-e]:[-kg,e-kg])}function RPg(e,g,i,n,I,r){var o=e[0],C=e[1],a=g[0],A=g[1],s=0,l=1,c=a-o,u=A-C,d;if(d=i-o,!(!c&&d>0)){if(d/=c,c<0){if(d0){if(d>l)return;d>s&&(s=d)}if(d=I-o,!(!c&&d<0)){if(d/=c,c<0){if(d>l)return;d>s&&(s=d)}else if(c>0){if(d0)){if(d/=u,u<0){if(d0){if(d>l)return;d>s&&(s=d)}if(d=r-C,!(!u&&d<0)){if(d/=u,u<0){if(d>l)return;d>s&&(s=d)}else if(u>0){if(d0&&(e[0]=o+s*c,e[1]=C+s*u),l<1&&(g[0]=o+l*c,g[1]=C+l*u),!0}}}}}var A2=1e9,OY=-A2;function ent(e,g,i,n){function I(A,s){return e<=A&&A<=i&&g<=s&&s<=n}function r(A,s,l,c){var u=0,d=0;if(A==null||(u=o(A,l))!==(d=o(s,l))||a(A,s)<0^l>0)do c.point(u===0||u===3?e:i,u>1?n:g);while((u=(u+l+4)%4)!==d);else c.point(s[0],s[1])}function o(A,s){return Qg(A[0]-e)0?0:3:Qg(A[0]-i)0?2:1:Qg(A[1]-g)0?1:0:s>0?3:2}function C(A,s){return a(A.x,s.x)}function a(A,s){var l=o(A,1),c=o(s,1);return l!==c?l-c:l===0?s[1]-A[1]:l===1?A[0]-s[0]:l===2?A[1]-s[1]:s[0]-A[0]}return function(A){var s=A,l=jit(),c,u,d,h,f,m,b,p,y,Z,v,G={point:B,lineStart:T,lineEnd:W,polygonStart:R,polygonEnd:w};function B(X,N){I(X,N)&&s.point(X,N)}function S(){for(var X=0,N=0,Y=u.length;Nn&&(j-Q)*(n-U)>(ee-U)*(e-Q)&&++X:ee<=n&&(j-Q)*(n-U)<(ee-U)*(e-Q)&&--X;return X}function R(){s=l,c=[],u=[],v=!0}function w(){var X=S(),N=v&&X,Y=(c=q6e(c)).length;(N||Y)&&(A.polygonStart(),N&&(A.lineStart(),r(null,null,1,A),A.lineEnd()),Y&&$it(c,C,X,r,A),A.polygonEnd()),s=A,c=u=d=null}function T(){G.point=V,u&&u.push(d=[]),Z=!0,y=!1,b=p=NaN}function W(){c&&(V(h,f),m&&y&&l.rejoin(),c.push(l.result())),G.point=B,y&&s.lineEnd()}function V(X,N){var Y=I(X,N);if(u&&d.push([X,N]),Z)h=X,f=N,m=Y,Z=!1,Y&&(s.lineStart(),s.point(X,N));else if(Y&&y)s.point(X,N);else{var x=[b=Math.max(OY,Math.min(A2,b)),p=Math.max(OY,Math.min(A2,p))],M=[X=Math.max(OY,Math.min(A2,X)),N=Math.max(OY,Math.min(A2,N))];RPg(x,M,e,g,i,n)?(y||(s.lineStart(),s.point(x[0],x[1])),s.point(M[0],M[1]),Y||s.lineEnd(),v=!1):Y&&(s.lineStart(),s.point(X,N),v=!1)}b=X,p=N,y=Y}return G}}function THe(e,g,i){var n=ca(e,g-og,i).concat(g);return function(I){return n.map(function(r){return[I,r]})}}function HHe(e,g,i){var n=ca(e,g-og,i).concat(g);return function(I){return n.map(function(r){return[r,I]})}}function VPg(){var e,g,i,n,I,r,o,C,a=10,A=a,s=90,l=360,c,u,d,h,f=2.5;function m(){return{type:"MultiLineString",coordinates:b()}}function b(){return ca(MY(n/s)*s,i,s).map(d).concat(ca(MY(C/l)*l,o,l).map(h)).concat(ca(MY(g/a)*a,e,a).filter(function(p){return Qg(p%s)>og}).map(c)).concat(ca(MY(r/A)*A,I,A).filter(function(p){return Qg(p%l)>og}).map(u))}return m.lines=function(){return b().map(function(p){return{type:"LineString",coordinates:p}})},m.outline=function(){return{type:"Polygon",coordinates:[d(n).concat(h(o).slice(1),d(i).reverse().slice(1),h(C).reverse().slice(1))]}},m.extent=function(p){return arguments.length?m.extentMajor(p).extentMinor(p):m.extentMinor()},m.extentMajor=function(p){return arguments.length?(n=+p[0][0],i=+p[1][0],C=+p[0][1],o=+p[1][1],n>i&&(p=n,n=i,i=p),C>o&&(p=C,C=o,o=p),m.precision(f)):[[n,C],[i,o]]},m.extentMinor=function(p){return arguments.length?(g=+p[0][0],e=+p[1][0],r=+p[0][1],I=+p[1][1],g>e&&(p=g,g=e,e=p),r>I&&(p=r,r=I,I=p),m.precision(f)):[[g,r],[e,I]]},m.step=function(p){return arguments.length?m.stepMajor(p).stepMinor(p):m.stepMinor()},m.stepMajor=function(p){return arguments.length?(s=+p[0],l=+p[1],m):[s,l]},m.stepMinor=function(p){return arguments.length?(a=+p[0],A=+p[1],m):[a,A]},m.precision=function(p){return arguments.length?(f=+p,c=THe(r,I,90),u=HHe(g,e,f),d=THe(C,o,90),h=HHe(n,i,f),m):f},m.extentMajor([[-180,-90+og],[180,90-og]]).extentMinor([[-180,-80-og],[180,80+og]])}const k9=e=>e;var i4=new Yo,Wne=new Yo,tnt,gnt,Xne,Tne,df={point:cr,lineStart:cr,lineEnd:cr,polygonStart:function(){df.lineStart=WPg,df.lineEnd=TPg},polygonEnd:function(){df.lineStart=df.lineEnd=df.point=cr,i4.add(Qg(Wne)),Wne=new Yo},result:function(){var e=i4/2;return i4=new Yo,e}};function WPg(){df.point=XPg}function XPg(e,g){df.point=int,tnt=Xne=e,gnt=Tne=g}function int(e,g){Wne.add(Tne*e-Xne*g),Xne=e,Tne=g}function TPg(){int(tnt,gnt)}const NHe=df;var qw=1/0,FM=qw,Y9=-qw,EM=Y9,HPg={point:NPg,lineStart:cr,lineEnd:cr,polygonStart:cr,polygonEnd:cr,result:function(){var e=[[qw,FM],[Y9,EM]];return Y9=EM=-(FM=qw=1/0),e}};function NPg(e,g){eY9&&(Y9=e),gEM&&(EM=g)}const DM=HPg;var Hne=0,Nne=0,l2=0,MM=0,zM=0,Bv=0,kne=0,Yne=0,c2=0,nnt,Int,jl,$l,pA={point:dy,lineStart:kHe,lineEnd:YHe,polygonStart:function(){pA.lineStart=KPg,pA.lineEnd=xPg},polygonEnd:function(){pA.point=dy,pA.lineStart=kHe,pA.lineEnd=YHe},result:function(){var e=c2?[kne/c2,Yne/c2]:Bv?[MM/Bv,zM/Bv]:l2?[Hne/l2,Nne/l2]:[NaN,NaN];return Hne=Nne=l2=MM=zM=Bv=kne=Yne=c2=0,e}};function dy(e,g){Hne+=e,Nne+=g,++l2}function kHe(){pA.point=kPg}function kPg(e,g){pA.point=YPg,dy(jl=e,$l=g)}function YPg(e,g){var i=e-jl,n=g-$l,I=zo(i*i+n*n);MM+=I*(jl+e)/2,zM+=I*($l+g)/2,Bv+=I,dy(jl=e,$l=g)}function YHe(){pA.point=dy}function KPg(){pA.point=FPg}function xPg(){rnt(nnt,Int)}function FPg(e,g){pA.point=rnt,dy(nnt=jl=e,Int=$l=g)}function rnt(e,g){var i=e-jl,n=g-$l,I=zo(i*i+n*n);MM+=I*(jl+e)/2,zM+=I*($l+g)/2,Bv+=I,I=$l*e-jl*g,kne+=I*(jl+e),Yne+=I*($l+g),c2+=I*3,dy(jl=e,$l=g)}const KHe=pA;function ont(e){this._context=e}ont.prototype={_radius:4.5,pointRadius:function(e){return this._radius=e,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(e,g){switch(this._point){case 0:{this._context.moveTo(e,g),this._point=1;break}case 1:{this._context.lineTo(e,g);break}default:{this._context.moveTo(e+this._radius,g),this._context.arc(e,g,this._radius,0,Mo);break}}},result:cr};var Kne=new Yo,n4,Cnt,ant,u2,d2,PM={point:cr,lineStart:function(){PM.point=EPg},lineEnd:function(){n4&&snt(Cnt,ant),PM.point=cr},polygonStart:function(){n4=!0},polygonEnd:function(){n4=null},result:function(){var e=+Kne;return Kne=new Yo,e}};function EPg(e,g){PM.point=snt,Cnt=u2=e,ant=d2=g}function snt(e,g){u2-=e,d2-=g,Kne.add(zo(u2*u2+d2*d2)),u2=e,d2=g}const xHe=PM;let FHe,_M,EHe,DHe;class MHe{constructor(g){this._append=g==null?Ant:DPg(g),this._radius=4.5,this._=""}pointRadius(g){return this._radius=+g,this}polygonStart(){this._line=0}polygonEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){this._line===0&&(this._+="Z"),this._point=NaN}point(g,i){switch(this._point){case 0:{this._append`M${g},${i}`,this._point=1;break}case 1:{this._append`L${g},${i}`;break}default:{if(this._append`M${g},${i}`,this._radius!==EHe||this._append!==_M){const n=this._radius,I=this._;this._="",this._append`m0,${n}a${n},${n} 0 1,1 0,${-2*n}a${n},${n} 0 1,1 0,${2*n}z`,EHe=n,_M=this._append,DHe=this._,this._=I}this._+=DHe;break}}}result(){const g=this._;return this._="",g.length?g:null}}function Ant(e){let g=1;this._+=e[0];for(const i=e.length;g=0))throw new RangeError(`invalid digits: ${e}`);if(g>15)return Ant;if(g!==FHe){const i=10**g;FHe=g,_M=function(I){let r=1;this._+=I[0];for(const o=I.length;r=0))throw new RangeError(`invalid digits: ${C}`);i=a}return g===null&&(r=new MHe(i)),o},o.projection(e).digits(i).context(g)}function XO(e){return function(g){var i=new xne;for(var n in e)i[n]=e[n];return i.stream=g,i}}function xne(){}xne.prototype={constructor:xne,point:function(e,g){this.stream.point(e,g)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function Vde(e,g,i){var n=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),n!=null&&e.clipExtent(null),_u(i,e.stream(DM)),g(DM.result()),n!=null&&e.clipExtent(n),e}function TO(e,g,i){return Vde(e,function(n){var I=g[1][0]-g[0][0],r=g[1][1]-g[0][1],o=Math.min(I/(n[1][0]-n[0][0]),r/(n[1][1]-n[0][1])),C=+g[0][0]+(I-o*(n[1][0]+n[0][0]))/2,a=+g[0][1]+(r-o*(n[1][1]+n[0][1]))/2;e.scale(150*o).translate([C,a])},i)}function Wde(e,g,i){return TO(e,[[0,0],g],i)}function Xde(e,g,i){return Vde(e,function(n){var I=+g,r=I/(n[1][0]-n[0][0]),o=(I-r*(n[1][0]+n[0][0]))/2,C=-r*n[0][1];e.scale(150*r).translate([o,C])},i)}function Tde(e,g,i){return Vde(e,function(n){var I=+g,r=I/(n[1][1]-n[0][1]),o=-r*n[0][0],C=(I-r*(n[1][1]+n[0][1]))/2;e.scale(150*r).translate([o,C])},i)}var zHe=16,MPg=Ag(30*Xg);function PHe(e,g){return+g?PPg(e,g):zPg(e)}function zPg(e){return XO({point:function(g,i){g=e(g,i),this.stream.point(g[0],g[1])}})}function PPg(e,g){function i(n,I,r,o,C,a,A,s,l,c,u,d,h,f){var m=A-n,b=s-I,p=m*m+b*b;if(p>4*g&&h--){var y=o+c,Z=C+u,v=a+d,G=zo(y*y+Z*Z+v*v),B=YC(v/=G),S=Qg(Qg(v)-1)g||Qg((m*W+b*V)/p-.5)>.3||o*c+C*u+a*d2?X[2]%360*Xg:0,W()):[C*Ln,a*Ln,A*Ln]},w.angle=function(X){return arguments.length?(l=X%360*Xg,W()):l*Ln},w.reflectX=function(X){return arguments.length?(c=X?-1:1,W()):c<0},w.reflectY=function(X){return arguments.length?(u=X?-1:1,W()):u<0},w.precision=function(X){return arguments.length?(v=PHe(G,Z=X*X),V()):zo(Z)},w.fitExtent=function(X,N){return TO(w,X,N)},w.fitSize=function(X,N){return Wde(w,X,N)},w.fitWidth=function(X,N){return Xde(w,X,N)},w.fitHeight=function(X,N){return Tde(w,X,N)};function W(){var X=_He(i,0,0,c,u,l).apply(null,g(r,o)),N=_He(i,n-X[0],I-X[1],c,u,l);return s=Qit(C,a,A),G=Rne(g,N),B=Rne(s,G),v=PHe(G,Z),V()}function V(){return S=R=null,w}return function(){return g=e.apply(this,arguments),w.invert=g.invert&&T,W()}}function Hde(e){var g=0,i=kg/3,n=cnt(e),I=n(g,i);return I.parallels=function(r){return arguments.length?n(g=r[0]*Xg,i=r[1]*Xg):[g*Ln,i*Ln]},I}function LPg(e){var g=Ag(e);function i(n,I){return[n*g,tg(I)/g]}return i.invert=function(n,I){return[n/g,YC(I*g)]},i}function UPg(e,g){var i=tg(e),n=(i+tg(g))/2;if(Qg(n)=.12&&f<.234&&h>=-.425&&h<-.214?I:f>=.166&&f<.234&&h>=-.214&&h<-.115?o:i).invert(c)},s.stream=function(c){return e&&g===c?e:e=QPg([i.stream(g=c),I.stream(c),o.stream(c)])},s.precision=function(c){return arguments.length?(i.precision(c),I.precision(c),o.precision(c),l()):i.precision()},s.scale=function(c){return arguments.length?(i.scale(c),I.scale(c*.35),o.scale(c),s.translate(i.translate())):i.scale()},s.translate=function(c){if(!arguments.length)return i.translate();var u=i.scale(),d=+c[0],h=+c[1];return n=i.translate(c).clipExtent([[d-.455*u,h-.238*u],[d+.455*u,h+.238*u]]).stream(A),r=I.translate([d-.307*u,h+.201*u]).clipExtent([[d-.425*u+og,h+.12*u+og],[d-.214*u-og,h+.234*u-og]]).stream(A),C=o.translate([d-.205*u,h+.212*u]).clipExtent([[d-.214*u+og,h+.166*u+og],[d-.115*u-og,h+.234*u-og]]).stream(A),l()},s.fitExtent=function(c,u){return TO(s,c,u)},s.fitSize=function(c,u){return Wde(s,c,u)},s.fitWidth=function(c,u){return Xde(s,c,u)},s.fitHeight=function(c,u){return Tde(s,c,u)};function l(){return e=g=null,s}return s.scale(1070)}function dnt(e){return function(g,i){var n=Ag(g),I=Ag(i),r=e(n*I);return r===1/0?[2,0]:[r*I*tg(g),r*tg(i)]}}function OH(e){return function(g,i){var n=zo(g*g+i*i),I=e(n),r=tg(I),o=Ag(I);return[bs(g*r,n*o),YC(n&&i*r/n)]}}var hnt=dnt(function(e){return zo(2/(1+e))});hnt.invert=OH(function(e){return 2*YC(e/2)});function $Pg(){return iu(hnt).scale(124.75).clipAngle(180-.001)}var fnt=dnt(function(e){return(e=Fit(e))&&e/tg(e)});fnt.invert=OH(function(e){return e});function qPg(){return iu(fnt).scale(79.4188).clipAngle(180-.001)}function HO(e,g){return[e,wM(Sde((Kn+g)/2))]}HO.invert=function(e,g){return[e,2*ZS(xit(g))-Kn]};function e_g(){return mnt(HO).scale(961/Mo)}function mnt(e){var g=iu(e),i=g.center,n=g.scale,I=g.translate,r=g.clipExtent,o=null,C,a,A;g.scale=function(l){return arguments.length?(n(l),s()):n()},g.translate=function(l){return arguments.length?(I(l),s()):I()},g.center=function(l){return arguments.length?(i(l),s()):i()},g.clipExtent=function(l){return arguments.length?(l==null?o=C=a=A=null:(o=+l[0][0],C=+l[0][1],a=+l[1][0],A=+l[1][1]),s()):o==null?null:[[o,C],[a,A]]};function s(){var l=kg*n(),c=g(pPg(g.rotate()).invert([0,0]));return r(o==null?[[c[0]-l,c[1]-l],[c[0]+l,c[1]+l]]:e===HO?[[Math.max(c[0]-l,o),C],[Math.min(c[0]+l,a),A]]:[[o,Math.max(c[1]-l,C)],[a,Math.min(c[1]+l,A)]])}return s()}function JY(e){return Sde((Kn+e)/2)}function t_g(e,g){var i=Ag(e),n=e===g?tg(e):wM(i/Ag(g))/wM(JY(g)/JY(e)),I=i*e4(JY(e),n)/n;if(!n)return HO;function r(o,C){I>0?C<-Kn+og&&(C=-Kn+og):C>Kn-og&&(C=Kn-og);var a=I/e4(JY(C),n);return[a*tg(n*o),I-a*Ag(n*o)]}return r.invert=function(o,C){var a=I-C,A=gs(n)*zo(o*o+a*a),s=bs(o,Qg(a))*gs(a);return a*n<0&&(s-=kg*gs(o)*gs(a)),[s/n,2*ZS(e4(I/A,1/n))-Kn]},r}function g_g(){return Hde(t_g).scale(109.5).parallels([30,30])}function JM(e,g){return[e,g]}JM.invert=JM;function i_g(){return iu(JM).scale(152.63)}function n_g(e,g){var i=Ag(e),n=e===g?tg(e):(i-Ag(g))/(g-e),I=i/n+e;if(Qg(n)og&&--n>0);return[e/(.8707+(r=i*i)*(-.131979+r*(-.013791+r*r*r*(.003971-.001529*r)))),i]};function s_g(){return iu(ynt).scale(175.295)}function Znt(e,g){return[Ag(g)*tg(e),tg(g)]}Znt.invert=OH(YC);function A_g(){return iu(Znt).scale(249.5).clipAngle(90+og)}function Gnt(e,g){var i=Ag(g),n=1+Ag(e)*i;return[i*tg(e)/n,tg(g)/n]}Gnt.invert=OH(function(e){return 2*ZS(e)});function l_g(){return iu(Gnt).scale(250).clipAngle(142)}function vnt(e,g){return[wM(Sde((Kn+g)/2)),-e]}vnt.invert=function(e,g){return[-g,2*ZS(xit(e))-Kn]};function c_g(){var e=mnt(vnt),g=e.center,i=e.rotate;return e.center=function(n){return arguments.length?g([-n[1],n[0]]):(n=g(),[n[1],-n[0]])},e.rotate=function(n){return arguments.length?i([n[0],n[1],n.length>2?n[2]+90:90]):(n=i(),[n[0],n[1],n[2]-90])},i([0,0,90]).scale(159.155)}var u_g=Math.abs,Fne=Math.cos,UM=Math.sin,d_g=1e-6,Bnt=Math.PI,Ene=Bnt/2,OHe=h_g(2);function JHe(e){return e>1?Ene:e<-1?-Ene:Math.asin(e)}function h_g(e){return e>0?Math.sqrt(e):0}function f_g(e,g){var i=e*UM(g),n=30,I;do g-=I=(g+UM(g)-i)/(1+Fne(g));while(u_g(I)>d_g&&--n>0);return g/2}function m_g(e,g,i){function n(I,r){return[e*I*Fne(r=f_g(i,r)),g*UM(r)]}return n.invert=function(I,r){return r=JHe(r/g),[I/(e*Fne(r)),JHe((2*r+UM(2*r))/i)]},n}var p_g=m_g(OHe/Ene,OHe,Bnt);function b_g(){return iu(p_g).scale(169.529)}const y_g=lnt(),Dne=["clipAngle","clipExtent","scale","translate","center","rotate","parallels","precision","reflectX","reflectY","coefficient","distance","fraction","lobes","parallel","radius","ratio","spacing","tilt"];function Z_g(e,g){return function i(){const n=g();return n.type=e,n.path=lnt().projection(n),n.copy=n.copy||function(){const I=i();return Dne.forEach(r=>{n[r]&&I[r](n[r]())}),I.path.pointRadius(n.path.pointRadius()),I},Jtt(n)}}function Nde(e,g){if(!e||typeof e!="string")throw new Error("Projection type must be a name string.");return e=e.toLowerCase(),arguments.length>1?(QM[e]=Z_g(e,g),this):QM[e]||null}function wnt(e){return e&&e.path||y_g}const QM={albers:unt,albersusa:jPg,azimuthalequalarea:$Pg,azimuthalequidistant:qPg,conicconformal:g_g,conicequalarea:OM,conicequidistant:I_g,equalEarth:o_g,equirectangular:i_g,gnomonic:C_g,identity:a_g,mercator:e_g,mollweide:b_g,naturalEarth1:s_g,orthographic:A_g,stereographic:l_g,transversemercator:c_g};for(const e in QM)Nde(e,QM[e]);function kde(e,g,i){e.prototype=g.prototype=i,i.constructor=e}function Snt(e,g){var i=Object.create(e.prototype);for(var n in g)i[n]=g[n];return i}function JH(){}var K9=.7,jM=1/K9,cB="\\s*([+-]?\\d+)\\s*",x9="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",mc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",G_g=/^#([0-9a-f]{3,8})$/,v_g=new RegExp(`^rgb\\(${cB},${cB},${cB}\\)$`),B_g=new RegExp(`^rgb\\(${mc},${mc},${mc}\\)$`),w_g=new RegExp(`^rgba\\(${cB},${cB},${cB},${x9}\\)$`),S_g=new RegExp(`^rgba\\(${mc},${mc},${mc},${x9}\\)$`),R_g=new RegExp(`^hsl\\(${x9},${mc},${mc}\\)$`),V_g=new RegExp(`^hsla\\(${x9},${mc},${mc},${x9}\\)$`),LHe={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};kde(JH,Yde,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:UHe,formatHex:UHe,formatHex8:W_g,formatHsl:X_g,formatRgb:QHe,toString:QHe});function UHe(){return this.rgb().formatHex()}function W_g(){return this.rgb().formatHex8()}function X_g(){return Rnt(this).formatHsl()}function QHe(){return this.rgb().formatRgb()}function Yde(e){var g,i;return e=(e+"").trim().toLowerCase(),(g=G_g.exec(e))?(i=g[1].length,g=parseInt(g[1],16),i===6?jHe(g):i===3?new GC(g>>8&15|g>>4&240,g>>4&15|g&240,(g&15)<<4|g&15,1):i===8?LY(g>>24&255,g>>16&255,g>>8&255,(g&255)/255):i===4?LY(g>>12&15|g>>8&240,g>>8&15|g>>4&240,g>>4&15|g&240,((g&15)<<4|g&15)/255):null):(g=v_g.exec(e))?new GC(g[1],g[2],g[3],1):(g=B_g.exec(e))?new GC(g[1]*255/100,g[2]*255/100,g[3]*255/100,1):(g=w_g.exec(e))?LY(g[1],g[2],g[3],g[4]):(g=S_g.exec(e))?LY(g[1]*255/100,g[2]*255/100,g[3]*255/100,g[4]):(g=R_g.exec(e))?eNe(g[1],g[2]/100,g[3]/100,1):(g=V_g.exec(e))?eNe(g[1],g[2]/100,g[3]/100,g[4]):LHe.hasOwnProperty(e)?jHe(LHe[e]):e==="transparent"?new GC(NaN,NaN,NaN,0):null}function jHe(e){return new GC(e>>16&255,e>>8&255,e&255,1)}function LY(e,g,i,n){return n<=0&&(e=g=i=NaN),new GC(e,g,i,n)}function T_g(e){return e instanceof JH||(e=Yde(e)),e?(e=e.rgb(),new GC(e.r,e.g,e.b,e.opacity)):new GC}function Mne(e,g,i,n){return arguments.length===1?T_g(e):new GC(e,g,i,n??1)}function GC(e,g,i,n){this.r=+e,this.g=+g,this.b=+i,this.opacity=+n}kde(GC,Mne,Snt(JH,{brighter(e){return e=e==null?jM:Math.pow(jM,e),new GC(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?K9:Math.pow(K9,e),new GC(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new GC(Ib(this.r),Ib(this.g),Ib(this.b),$M(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:$He,formatHex:$He,formatHex8:H_g,formatRgb:qHe,toString:qHe}));function $He(){return`#${N0(this.r)}${N0(this.g)}${N0(this.b)}`}function H_g(){return`#${N0(this.r)}${N0(this.g)}${N0(this.b)}${N0((isNaN(this.opacity)?1:this.opacity)*255)}`}function qHe(){const e=$M(this.opacity);return`${e===1?"rgb(":"rgba("}${Ib(this.r)}, ${Ib(this.g)}, ${Ib(this.b)}${e===1?")":`, ${e})`}`}function $M(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ib(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function N0(e){return e=Ib(e),(e<16?"0":"")+e.toString(16)}function eNe(e,g,i,n){return n<=0?e=g=i=NaN:i<=0||i>=1?e=g=NaN:g<=0&&(e=NaN),new bA(e,g,i,n)}function Rnt(e){if(e instanceof bA)return new bA(e.h,e.s,e.l,e.opacity);if(e instanceof JH||(e=Yde(e)),!e)return new bA;if(e instanceof bA)return e;e=e.rgb();var g=e.r/255,i=e.g/255,n=e.b/255,I=Math.min(g,i,n),r=Math.max(g,i,n),o=NaN,C=r-I,a=(r+I)/2;return C?(g===r?o=(i-n)/C+(i0&&a<1?0:o,new bA(o,C,a,e.opacity)}function N_g(e,g,i,n){return arguments.length===1?Rnt(e):new bA(e,g,i,n??1)}function bA(e,g,i,n){this.h=+e,this.s=+g,this.l=+i,this.opacity=+n}kde(bA,N_g,Snt(JH,{brighter(e){return e=e==null?jM:Math.pow(jM,e),new bA(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?K9:Math.pow(K9,e),new bA(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,g=isNaN(e)||isNaN(this.s)?0:this.s,i=this.l,n=i+(i<.5?i:1-i)*g,I=2*i-n;return new GC(I4(e>=240?e-240:e+120,I,n),I4(e,I,n),I4(e<120?e+240:e-120,I,n),this.opacity)},clamp(){return new bA(tNe(this.h),UY(this.s),UY(this.l),$M(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=$M(this.opacity);return`${e===1?"hsl(":"hsla("}${tNe(this.h)}, ${UY(this.s)*100}%, ${UY(this.l)*100}%${e===1?")":`, ${e})`}`}}));function tNe(e){return e=(e||0)%360,e<0?e+360:e}function UY(e){return Math.max(0,Math.min(1,e||0))}function I4(e,g,i){return(e<60?g+(i-g)*e/60:e<180?i:e<240?g+(i-g)*(240-e)/60:g)*255}function k_g(){}const vu=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function Vnt(){var e=1,g=1,i=C;function n(a,A){return A.map(s=>I(a,s))}function I(a,A){var s=[],l=[];return r(a,A,c=>{i(c,a,A),Y_g(c)>0?s.push([c]):l.push(c)}),l.forEach(c=>{for(var u=0,d=s.length,h;u=A,vu[f<<1].forEach(p);++u=A,vu[h|f<<1].forEach(p);for(vu[f<<0].forEach(p);++d=A,m=a[d*e]>=A,vu[f<<1|m<<2].forEach(p);++u=A,b=m,m=a[d*e+u+1]>=A,vu[h|f<<1|m<<2|b<<3].forEach(p);vu[f|m<<3].forEach(p)}for(u=-1,m=a[d*e]>=A,vu[m<<2].forEach(p);++u=A,vu[m<<2|b<<3].forEach(p);vu[m<<3].forEach(p);function p(y){var Z=[y[0][0]+u,y[0][1]+d],v=[y[1][0]+u,y[1][1]+d],G=o(Z),B=o(v),S,R;(S=c[G])?(R=l[B])?(delete c[S.end],delete l[R.start],S===R?(S.ring.push(v),s(S.ring)):l[S.start]=c[R.end]={start:S.start,end:R.end,ring:S.ring.concat(R.ring)}):(delete c[S.end],S.ring.push(v),c[S.end=B]=S):(S=l[B])?(R=c[G])?(delete l[S.start],delete c[R.end],S===R?(S.ring.push(v),s(S.ring)):l[R.start]=c[S.end]={start:R.start,end:S.end,ring:R.ring.concat(S.ring)}):(delete l[S.start],S.ring.unshift(Z),l[S.start=G]=S):l[G]=c[B]={start:G,end:B,ring:[Z,v]}}}function o(a){return a[0]*2+a[1]*(e+1)*4}function C(a,A,s){a.forEach(l=>{var c=l[0],u=l[1],d=c|0,h=u|0,f,m=A[h*e+d];c>0&&c0&&u=0&&s>=0||qe("invalid size"),e=A,g=s,n},n.smooth=function(a){return arguments.length?(i=a?C:k_g,n):i===C},n}function Y_g(e){for(var g=0,i=e.length,n=e[i-1][1]*e[0][0]-e[i-1][0]*e[0][1];++gn!=u>n&&i<(c-A)*(n-s)/(u-s)+A&&(I=-I)}return I}function F_g(e,g,i){var n;return E_g(e,g,i)&&D_g(e[n=+(e[0]===g[0])],i[n],g[n])}function E_g(e,g,i){return(g[0]-e[0])*(i[1]-e[1])===(i[0]-e[0])*(g[1]-e[1])}function D_g(e,g,i){return e<=g&&g<=i||i<=g&&g<=e}function Wnt(e,g,i){return function(n){var I=kc(n),r=i?Math.min(I[0],0):I[0],o=I[1],C=o-r,a=g?mm(r,o,e):C/(e+1);return ca(r+a,o,a)}}function Kde(e){Le.call(this,null,e)}Kde.Definition={type:"Isocontour",metadata:{generates:!0},params:[{name:"field",type:"field"},{name:"thresholds",type:"number",array:!0},{name:"levels",type:"number"},{name:"nice",type:"boolean",default:!1},{name:"resolve",type:"enum",values:["shared","independent"],default:"independent"},{name:"zero",type:"boolean",default:!0},{name:"smooth",type:"boolean",default:!0},{name:"scale",type:"number",expr:!0},{name:"translate",type:"number",array:!0,expr:!0},{name:"as",type:"string",null:!0,default:"contour"}]};mt(Kde,Le,{transform(e,g){if(this.value&&!g.changed()&&!e.modified())return g.StopPropagation;var i=g.fork(g.NO_SOURCE|g.NO_FIELDS),n=g.materialize(g.SOURCE).source,I=e.field||io,r=Vnt().smooth(e.smooth!==!1),o=e.thresholds||M_g(n,I,e),C=e.as===null?null:e.as||"contour",a=[];return n.forEach(A=>{const s=I(A),l=r.size([s.width,s.height])(s.values,et(o)?o:o(s.values));z_g(l,s,A,e),l.forEach(c=>{a.push(Q_(A,li(C!=null?{[C]:c}:c)))})}),this.value&&(i.rem=this.value),this.value=i.source=i.add=a,i}});function M_g(e,g,i){const n=Wnt(i.levels||10,i.nice,i.zero!==!1);return i.resolve!=="shared"?n:n(e.map(I=>tb(g(I).values)))}function z_g(e,g,i,n){let I=n.scale||g.scale,r=n.translate||g.translate;if(Bg(I)&&(I=I(i,n)),Bg(r)&&(r=r(i,n)),(I===1||I==null)&&!r)return;const o=(Vi(I)?I:I[0])||1,C=(Vi(I)?I:I[1])||1,a=r&&r[0]||0,A=r&&r[1]||0;e.forEach(Xnt(g,o,C,a,A))}function Xnt(e,g,i,n,I){const r=e.x1||0,o=e.y1||0,C=g*i<0;function a(l){l.forEach(A)}function A(l){C&&l.reverse(),l.forEach(s)}function s(l){l[0]=(l[0]-r)*g+n,l[1]=(l[1]-o)*i+I}return function(l){return l.coordinates.forEach(a),l}}function gNe(e,g,i){const n=e>=0?e:vce(g,i);return Math.round((Math.sqrt(4*n*n+1)-1)/2)}function r4(e){return Bg(e)?e:no(+e)}function Tnt(){var e=a=>a[0],g=a=>a[1],i=sS,n=[-1,-1],I=960,r=500,o=2;function C(a,A){const s=gNe(n[0],a,e)>>o,l=gNe(n[1],a,g)>>o,c=s?s+2:0,u=l?l+2:0,d=2*c+(I>>o),h=2*u+(r>>o),f=new Float32Array(d*h),m=new Float32Array(d*h);let b=f;a.forEach(y=>{const Z=c+(+e(y)>>o),v=u+(+g(y)>>o);Z>=0&&Z=0&&v0&&l>0?(hG(d,h,f,m,s),fG(d,h,m,f,l),hG(d,h,f,m,s),fG(d,h,m,f,l),hG(d,h,f,m,s),fG(d,h,m,f,l)):s>0?(hG(d,h,f,m,s),hG(d,h,m,f,s),hG(d,h,f,m,s),b=m):l>0&&(fG(d,h,f,m,l),fG(d,h,m,f,l),fG(d,h,f,m,l),b=m);const p=A?Math.pow(2,-2*o):1/eqe(b);for(let y=0,Z=d*h;y>o),y2:u+(r>>o)}}return C.x=function(a){return arguments.length?(e=r4(a),C):e},C.y=function(a){return arguments.length?(g=r4(a),C):g},C.weight=function(a){return arguments.length?(i=r4(a),C):i},C.size=function(a){if(!arguments.length)return[I,r];var A=+a[0],s=+a[1];return A>=0&&s>=0||qe("invalid size"),I=A,r=s,C},C.cellSize=function(a){return arguments.length?((a=+a)>=1||qe("invalid cell size"),o=Math.floor(Math.log(a)/Math.LN2),C):1<=I&&(C>=r&&(a-=i[C-r+o*e]),n[C-I+o*e]=a/Math.min(C+1,e-1+r-C,r))}function fG(e,g,i,n,I){const r=(I<<1)+1;for(let o=0;o=I&&(C>=r&&(a-=i[o+(C-r)*e]),n[o+(C-I)*e]=a/Math.min(C+1,g-1+r-C,r))}function xde(e){Le.call(this,null,e)}xde.Definition={type:"KDE2D",metadata:{generates:!0},params:[{name:"size",type:"number",array:!0,length:2,required:!0},{name:"x",type:"field",required:!0},{name:"y",type:"field",required:!0},{name:"weight",type:"field"},{name:"groupby",type:"field",array:!0},{name:"cellSize",type:"number"},{name:"bandwidth",type:"number",array:!0,length:2},{name:"counts",type:"boolean",default:!1},{name:"as",type:"string",default:"grid"}]};const P_g=["x","y","weight","size","cellSize","bandwidth"];function Hnt(e,g){return P_g.forEach(i=>g[i]!=null?e[i](g[i]):0),e}mt(xde,Le,{transform(e,g){if(this.value&&!g.changed()&&!e.modified())return g.StopPropagation;var i=g.fork(g.NO_SOURCE|g.NO_FIELDS),n=g.materialize(g.SOURCE).source,I=__g(n,e.groupby),r=(e.groupby||[]).map(xn),o=Hnt(Tnt(),e),C=e.as||"grid",a=[];function A(s,l){for(let c=0;cli(A({[C]:o(s,e.counts)},s.dims))),this.value&&(i.rem=this.value),this.value=i.source=i.add=a,i}});function __g(e,g){var i=[],n=s=>s(C),I,r,o,C,a,A;if(g==null)i.push(e);else for(I={},r=0,o=e.length;ri.push(C(s))),r&&o&&(g.visit(a,s=>{var l=r(s),c=o(s);l!=null&&c!=null&&(l=+l)===l&&(c=+c)===c&&n.push([l,c])}),i=i.concat({type:zne,geometry:{type:O_g,coordinates:n}})),this.value={type:Ede,features:i}}});function Mde(e){Le.call(this,null,e)}Mde.Definition={type:"GeoPath",metadata:{modifies:!0},params:[{name:"projection",type:"projection"},{name:"field",type:"field"},{name:"pointRadius",type:"number",expr:!0},{name:"as",type:"string",default:"path"}]};mt(Mde,Le,{transform(e,g){var i=g.fork(g.ALL),n=this.value,I=e.field||io,r=e.as||"path",o=i.SOURCE;!n||e.modified()?(this.value=n=wnt(e.projection),i.materialize().reflow()):o=I===io||g.modified(I.fields)?i.ADD_MOD:i.ADD;const C=J_g(n,e.pointRadius);return i.visit(o,a=>a[r]=n(I(a))),n.pointRadius(C),i.modifies(r)}});function J_g(e,g){const i=e.pointRadius();return e.context(null),g!=null&&e.pointRadius(g),i}function zde(e){Le.call(this,null,e)}zde.Definition={type:"GeoPoint",metadata:{modifies:!0},params:[{name:"projection",type:"projection",required:!0},{name:"fields",type:"field",array:!0,required:!0,length:2},{name:"as",type:"string",array:!0,length:2,default:["x","y"]}]};mt(zde,Le,{transform(e,g){var i=e.projection,n=e.fields[0],I=e.fields[1],r=e.as||["x","y"],o=r[0],C=r[1],a;function A(s){const l=i([n(s),I(s)]);l?(s[o]=l[0],s[C]=l[1]):(s[o]=void 0,s[C]=void 0)}return e.modified()?g=g.materialize().reflow(!0).visit(g.SOURCE,A):(a=g.modified(n.fields)||g.modified(I.fields),g.visit(a?g.ADD_MOD:g.ADD,A)),g.modifies(r)}});function Pde(e){Le.call(this,null,e)}Pde.Definition={type:"GeoShape",metadata:{modifies:!0,nomod:!0},params:[{name:"projection",type:"projection"},{name:"field",type:"field",default:"datum"},{name:"pointRadius",type:"number",expr:!0},{name:"as",type:"string",default:"shape"}]};mt(Pde,Le,{transform(e,g){var i=g.fork(g.ALL),n=this.value,I=e.as||"shape",r=i.ADD;return(!n||e.modified())&&(this.value=n=L_g(wnt(e.projection),e.field||HC("datum"),e.pointRadius),i.materialize().reflow(),r=i.SOURCE),i.visit(r,o=>o[I]=n),i.modifies(I)}});function L_g(e,g,i){const n=i==null?I=>e(g(I)):I=>{var r=e.pointRadius(),o=e.pointRadius(i)(g(I));return e.pointRadius(r),o};return n.context=I=>(e.context(I),n),n}function _de(e){Le.call(this,[],e),this.generator=VPg()}_de.Definition={type:"Graticule",metadata:{changes:!0,generates:!0},params:[{name:"extent",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"extentMajor",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"extentMinor",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"step",type:"number",array:!0,length:2},{name:"stepMajor",type:"number",array:!0,length:2,default:[90,360]},{name:"stepMinor",type:"number",array:!0,length:2,default:[10,10]},{name:"precision",type:"number",default:2.5}]};mt(_de,Le,{transform(e,g){var i=this.value,n=this.generator,I;if(!i.length||e.modified())for(const r in e)Bg(n[r])&&n[r](e[r]);return I=n(),i.length?g.mod.push(Pqe(i[0],I)):g.add.push(li(I)),i[0]=I,g}});function Ode(e){Le.call(this,null,e)}Ode.Definition={type:"heatmap",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"color",type:"string",expr:!0},{name:"opacity",type:"number",expr:!0},{name:"resolve",type:"enum",values:["shared","independent"],default:"independent"},{name:"as",type:"string",default:"image"}]};mt(Ode,Le,{transform(e,g){if(!g.changed()&&!e.modified())return g.StopPropagation;var i=g.materialize(g.SOURCE).source,n=e.resolve==="shared",I=e.field||io,r=Q_g(e.opacity,e),o=U_g(e.color,e),C=e.as||"image",a={$x:0,$y:0,$value:0,$max:n?tb(i.map(A=>tb(I(A).values))):0};return i.forEach(A=>{const s=I(A),l=vg({},A,a);n||(l.$max=tb(s.values||[])),A[C]=j_g(s,l,o.dep?o:no(o(l)),r.dep?r:no(r(l)))}),g.reflow(!0).modifies(C)}});function U_g(e,g){let i;return Bg(e)?(i=n=>Mne(e(n,g)),i.dep=Nnt(e)):i=no(Mne(e||"#888")),i}function Q_g(e,g){let i;return Bg(e)?(i=n=>e(n,g),i.dep=Nnt(e)):e?i=no(e):(i=n=>n.$value/n.$max||0,i.dep=!0),i}function Nnt(e){if(!Bg(e))return!1;const g=JA(Ur(e));return g.$x||g.$y||g.$value||g.$max}function j_g(e,g,i,n){const I=e.width,r=e.height,o=e.x1||0,C=e.y1||0,a=e.x2||I,A=e.y2||r,s=e.values,l=s?f=>s[f]:uf,c=om(a-o,A-C),u=c.getContext("2d"),d=u.getImageData(0,0,a-o,A-C),h=d.data;for(let f=C,m=0;f{e[n]!=null&&iNe(i,n,e[n])})):Dne.forEach(n=>{e.modified(n)&&iNe(i,n,e[n])}),e.pointRadius!=null&&i.path.pointRadius(e.pointRadius),e.fit&&$_g(i,e),g.fork(g.NO_SOURCE|g.NO_FIELDS)}});function $_g(e,g){const i=eOg(g.fit);g.extent?e.fitExtent(g.extent,i):g.size&&e.fitSize(g.size,i)}function q_g(e){const g=Nde((e||"mercator").toLowerCase());return g||qe("Unrecognized projection type: "+e),g()}function iNe(e,g,i){Bg(e[g])&&e[g](i)}function eOg(e){return e=Vt(e),e.length===1?e[0]:{type:Ede,features:e.reduce((g,i)=>g.concat(tOg(i)),[])}}function tOg(e){return e.type===Ede?e.features:Vt(e).filter(g=>g!=null).map(g=>g.type===zne?g:{type:zne,geometry:g})}const gOg=Object.freeze(Object.defineProperty({__proto__:null,contour:Fde,geojson:Dde,geopath:Mde,geopoint:zde,geoshape:Pde,graticule:_de,heatmap:Ode,isocontour:Kde,kde2d:xde,projection:knt},Symbol.toStringTag,{value:"Module"}));function iOg(e,g){var i,n=1;e==null&&(e=0),g==null&&(g=0);function I(){var r,o=i.length,C,a=0,A=0;for(r=0;r=(l=(C+A)/2))?C=l:A=l,(f=i>=(c=(a+s)/2))?a=c:s=c,I=r,!(r=r[m=f<<1|h]))return I[m]=o,e;if(u=+e._x.call(null,r.data),d=+e._y.call(null,r.data),g===u&&i===d)return o.next=r,I?I[m]=o:e._root=o,e;do I=I?I[m]=new Array(4):e._root=new Array(4),(h=g>=(l=(C+A)/2))?C=l:A=l,(f=i>=(c=(a+s)/2))?a=c:s=c;while((m=f<<1|h)===(b=(d>=c)<<1|u>=l));return I[b]=r,I[m]=o,e}function IOg(e){var g,i,n=e.length,I,r,o=new Array(n),C=new Array(n),a=1/0,A=1/0,s=-1/0,l=-1/0;for(i=0;is&&(s=I),rl&&(l=r));if(a>s||A>l)return this;for(this.cover(a,A).cover(s,l),i=0;ie||e>=I||n>g||g>=r;)switch(A=(gs||(C=d.y0)>l||(a=d.x1)=m)<<1|e>=f)&&(d=c[c.length-1],c[c.length-1]=c[c.length-1-h],c[c.length-1-h]=d)}else{var b=e-+this._x.call(null,u.data),p=g-+this._y.call(null,u.data),y=b*b+p*p;if(y=(c=(o+a)/2))?o=c:a=c,(h=l>=(u=(C+A)/2))?C=u:A=u,g=i,!(i=i[f=h<<1|d]))return this;if(!i.length)break;(g[f+1&3]||g[f+2&3]||g[f+3&3])&&(n=g,m=f)}for(;i.data!==e;)if(I=i,!(i=i.next))return this;return(r=i.next)&&delete i.next,I?(r?I.next=r:delete I.next,this):g?(r?g[f]=r:delete g[f],(i=g[0]||g[1]||g[2]||g[3])&&i===(g[3]||g[2]||g[1]||g[0])&&!i.length&&(n?n[m]=i:this._root=i),this):(this._root=r,this)}function AOg(e){for(var g=0,i=e.length;gc.index){var w=u-B.x-B.vx,T=d-B.y-B.vy,W=w*w+T*T;Wu+R||vd+R||GA.r&&(A.r=A[s].r)}function a(){if(g){var A,s=g.length,l;for(i=new Array(s),A=0;A[g(Z,v,o),Z])),y;for(f=0,C=new Array(m);f{}};function Knt(){for(var e=0,g=arguments.length,i={},n;e=0&&(n=i.slice(I+1),i=i.slice(0,I)),i&&!g.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:n}})}j5.prototype=Knt.prototype={constructor:j5,on:function(e,g){var i=this._,n=wOg(e+"",i),I,r=-1,o=n.length;if(arguments.length<2){for(;++r0)for(var i=new Array(I),n=0,I,r;n=0&&e._call.call(void 0,g),e=e._next;--e1}function oNe(){hy=(e3=F9.now())+NO,e1=h2=0;try{VOg()}finally{e1=0,XOg(),hy=0}}function WOg(){var e=F9.now(),g=e-e3;g>xnt&&(NO-=g,e3=e)}function XOg(){for(var e,g=qM,i,n=1/0;g;)g._call?(n>g._time&&(n=g._time),e=g,g=g._next):(i=g._next,g._next=null,g=e?e._next=i:qM=i);f2=e,Pne(n)}function Pne(e){if(!e1){h2&&(h2=clearTimeout(h2));var g=e-hy;g>24?(e<1/0&&(h2=setTimeout(oNe,e-F9.now()-NO)),jR&&(jR=clearInterval(jR))):(jR||(e3=F9.now(),jR=setInterval(WOg,xnt)),e1=1,Fnt(oNe))}}function TOg(e,g,i){var n=new t3,I=g;return g==null?(n.restart(e,g,i),n):(n._restart=n.restart,n.restart=function(r,o,C){o=+o,C=C==null?Ude():+C,n._restart(function a(A){A+=I,n._restart(a,I+=o,C),r(A)},o,C)},n.restart(e,g,i),n)}const HOg=1664525,NOg=1013904223,CNe=4294967296;function kOg(){let e=1;return()=>(e=(HOg*e+NOg)%CNe)/CNe}function YOg(e){return e.x}function KOg(e){return e.y}var xOg=10,FOg=Math.PI*(3-Math.sqrt(5));function EOg(e){var g,i=1,n=.001,I=1-Math.pow(n,1/300),r=0,o=.6,C=new Map,a=Ent(l),A=Knt("tick","end"),s=kOg();e==null&&(e=[]);function l(){c(),A.call("tick",g),i1?(f==null?C.delete(h):C.set(h,d(f)),g):C.get(h)},find:function(h,f,m){var b=0,p=e.length,y,Z,v,G,B;for(m==null?m=1/0:m*=m,b=0;b1?(A.on(h,f),g):A.on(h)}}}function DOg(){var e,g,i,n,I=Ho(-30),r,o=1,C=1/0,a=.81;function A(u){var d,h=e.length,f=Jde(e,YOg,KOg).visitAfter(l);for(n=u,d=0;d=C)return;(u.data!==g||u.next)&&(m===0&&(m=kf(i),y+=m*m),b===0&&(b=kf(i),y+=b*b),y=0;)i.tick();else if(i.stopped()&&i.restart(),!n)return g.StopPropagation}return this.finish(e,g)},finish(e,g){const i=g.dataflow;for(let C=this._argops,a=0,A=C.length,s;ae.touch(g).run()}function OOg(e,g){const i=EOg(e),n=i.stop,I=i.restart;let r=!1;return i.stopped=()=>r,i.restart=()=>(r=!1,I()),i.stop=()=>(r=!0,n()),Mnt(i,g,!0).on("end",()=>r=!0)}function Mnt(e,g,i,n){var I=Vt(g.forces),r,o,C,a;for(r=0,o=_ne.length;rg(n,i):g)}const QOg=Object.freeze(Object.defineProperty({__proto__:null,force:Qde},Symbol.toStringTag,{value:"Module"}));function jOg(e,g){return e.parent===g.parent?1:2}function $Og(e){return e.reduce(qOg,0)/e.length}function qOg(e,g){return e+g.x}function eJg(e){return 1+e.reduce(tJg,0)}function tJg(e,g){return Math.max(e,g.y)}function gJg(e){for(var g;g=e.children;)e=g[0];return e}function iJg(e){for(var g;g=e.children;)e=g[g.length-1];return e}function nJg(){var e=jOg,g=1,i=1,n=!1;function I(r){var o,C=0;r.eachAfter(function(c){var u=c.children;u?(c.x=$Og(u),c.y=eJg(u)):(c.x=o?C+=e(c,o):0,c.y=0,o=c)});var a=gJg(r),A=iJg(r),s=a.x-e(a,A)/2,l=A.x+e(A,a)/2;return r.eachAfter(n?function(c){c.x=(c.x-r.x)*g,c.y=(r.y-c.y)*i}:function(c){c.x=(c.x-s)/(l-s)*g,c.y=(1-(r.y?c.y/r.y:1))*i})}return I.separation=function(r){return arguments.length?(e=r,I):e},I.size=function(r){return arguments.length?(n=!1,g=+r[0],i=+r[1],I):n?null:[g,i]},I.nodeSize=function(r){return arguments.length?(n=!0,g=+r[0],i=+r[1],I):n?[g,i]:null},I}function IJg(e){var g=0,i=e.children,n=i&&i.length;if(!n)g=1;else for(;--n>=0;)g+=i[n].value;e.value=g}function rJg(){return this.eachAfter(IJg)}function oJg(e,g){let i=-1;for(const n of this)e.call(g,n,++i,this);return this}function CJg(e,g){for(var i=this,n=[i],I,r,o=-1;i=n.pop();)if(e.call(g,i,++o,this),I=i.children)for(r=I.length-1;r>=0;--r)n.push(I[r]);return this}function aJg(e,g){for(var i=this,n=[i],I=[],r,o,C,a=-1;i=n.pop();)if(I.push(i),r=i.children)for(o=0,C=r.length;o=0;)i+=n[I].value;g.value=i})}function lJg(e){return this.eachBefore(function(g){g.children&&g.children.sort(e)})}function cJg(e){for(var g=this,i=uJg(g,e),n=[g];g!==i;)g=g.parent,n.push(g);for(var I=n.length;e!==i;)n.splice(I,0,e),e=e.parent;return n}function uJg(e,g){if(e===g)return e;var i=e.ancestors(),n=g.ancestors(),I=null;for(e=i.pop(),g=n.pop();e===g;)I=e,e=i.pop(),g=n.pop();return I}function dJg(){for(var e=this,g=[e];e=e.parent;)g.push(e);return g}function hJg(){return Array.from(this)}function fJg(){var e=[];return this.eachBefore(function(g){g.children||e.push(g)}),e}function mJg(){var e=this,g=[];return e.each(function(i){i!==e&&g.push({source:i.parent,target:i})}),g}function*pJg(){var e=this,g,i=[e],n,I,r;do for(g=i.reverse(),i=[];e=g.pop();)if(yield e,n=e.children)for(I=0,r=n.length;I=0;--C)I.push(r=o[C]=new t1(o[C])),r.parent=n,r.depth=n.depth+1;return i.eachBefore(znt)}function bJg(){return jde(this).eachBefore(GJg)}function yJg(e){return e.children}function ZJg(e){return Array.isArray(e)?e[1]:null}function GJg(e){e.data.value!==void 0&&(e.value=e.data.value),e.data=e.data.data}function znt(e){var g=0;do e.height=g;while((e=e.parent)&&e.height<++g)}function t1(e){this.data=e,this.depth=this.height=0,this.parent=null}t1.prototype=jde.prototype={constructor:t1,count:rJg,each:oJg,eachAfter:aJg,eachBefore:CJg,find:sJg,sum:AJg,sort:lJg,path:cJg,ancestors:dJg,descendants:hJg,leaves:fJg,links:mJg,copy:bJg,[Symbol.iterator]:pJg};function $5(e){return e==null?null:Pnt(e)}function Pnt(e){if(typeof e!="function")throw new Error;return e}function u0(){return 0}function UG(e){return function(){return e}}const vJg=1664525,BJg=1013904223,sNe=4294967296;function wJg(){let e=1;return()=>(e=(vJg*e+BJg)%sNe)/sNe}function SJg(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function RJg(e,g){let i=e.length,n,I;for(;i;)I=g()*i--|0,n=e[i],e[i]=e[I],e[I]=n;return e}function VJg(e,g){for(var i=0,n=(e=RJg(Array.from(e),g)).length,I=[],r,o;i0&&i*i>n*n+I*I}function o4(e,g){for(var i=0;i1e-6?(w+Math.sqrt(w*w-4*R*T))/(2*R):T/w);return{x:n+v+G*W,y:I+B+S*W,r:W}}function ANe(e,g,i){var n=e.x-g.x,I,r,o=e.y-g.y,C,a,A=n*n+o*o;A?(r=g.r+i.r,r*=r,a=e.r+i.r,a*=a,r>a?(I=(A+a-r)/(2*A),C=Math.sqrt(Math.max(0,a/A-I*I)),i.x=e.x-I*n-C*o,i.y=e.y-I*o+C*n):(I=(A+r-a)/(2*A),C=Math.sqrt(Math.max(0,r/A-I*I)),i.x=g.x+I*n-C*o,i.y=g.y+I*o+C*n)):(i.x=g.x+i.r,i.y=g.y)}function lNe(e,g){var i=e.r+g.r-1e-6,n=g.x-e.x,I=g.y-e.y;return i>0&&i*i>n*n+I*I}function cNe(e){var g=e._,i=e.next._,n=g.r+i.r,I=(g.x*i.r+i.x*g.r)/n,r=(g.y*i.r+i.y*g.r)/n;return I*I+r*r}function jY(e){this._=e,this.next=null,this.previous=null}function HJg(e,g){if(!(r=(e=SJg(e)).length))return 0;var i,n,I,r,o,C,a,A,s,l,c;if(i=e[0],i.x=0,i.y=0,!(r>1))return i.r;if(n=e[1],i.x=-n.r,n.x=i.r,n.y=0,!(r>2))return i.r+n.r;ANe(n,i,I=e[2]),i=new jY(i),n=new jY(n),I=new jY(I),i.next=I.previous=n,n.next=i.previous=I,I.next=n.previous=i;e:for(a=3;aEJg(i(y,Z,I))),b=m.map(mNe),p=new Set(m).add("");for(const y of b)p.has(y)||(p.add(y),m.push(y),b.push(mNe(y)),r.push(a4));o=(y,Z)=>m[Z],C=(y,Z)=>b[Z]}for(s=0,a=r.length;s=0&&(u=r[m],u.data===a4);--m)u.data=null}if(l.parent=KJg,l.eachBefore(function(m){m.depth=m.parent.depth+1,--a}).eachBefore(znt),l.parent=null,a>0)throw new Error("cycle");return l}return n.id=function(I){return arguments.length?(e=$5(I),n):e},n.parentId=function(I){return arguments.length?(g=$5(I),n):g},n.path=function(I){return arguments.length?(i=$5(I),n):i},n}function EJg(e){e=`${e}`;let g=e.length;return One(e,g-1)&&!One(e,g-2)&&(e=e.slice(0,-1)),e[0]==="/"?e:`/${e}`}function mNe(e){let g=e.length;if(g<2)return"";for(;--g>1&&!One(e,g););return e.slice(0,g)}function One(e,g){if(e[g]==="/"){let i=0;for(;g>0&&e[--g]==="\\";)++i;if(!(i&1))return!0}return!1}function DJg(e,g){return e.parent===g.parent?1:2}function s4(e){var g=e.children;return g?g[0]:e.t}function A4(e){var g=e.children;return g?g[g.length-1]:e.t}function MJg(e,g,i){var n=i/(g.i-e.i);g.c-=n,g.s+=i,e.c+=n,g.z+=i,g.m+=i}function zJg(e){for(var g=0,i=0,n=e.children,I=n.length,r;--I>=0;)r=n[I],r.z+=g,r.m+=g,g+=r.s+(i+=r.c)}function PJg(e,g,i){return e.a.parent===g.parent?e.a:i}function q5(e,g){this._=e,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=g}q5.prototype=Object.create(t1.prototype);function _Jg(e){for(var g=new q5(e,0),i,n=[g],I,r,o,C;i=n.pop();)if(r=i._.children)for(i.children=new Array(C=r.length),o=C-1;o>=0;--o)n.push(I=i.children[o]=new q5(r[o],o)),I.parent=i;return(g.parent=new q5(null,0)).children=[g],g}function OJg(){var e=DJg,g=1,i=1,n=null;function I(A){var s=_Jg(A);if(s.eachAfter(r),s.parent.m=-s.z,s.eachBefore(o),n)A.eachBefore(a);else{var l=A,c=A,u=A;A.eachBefore(function(b){b.xc.x&&(c=b),b.depth>u.depth&&(u=b)});var d=l===c?1:e(l,c)/2,h=d-l.x,f=g/(c.x+d+h),m=i/(u.depth||1);A.eachBefore(function(b){b.x=(b.x+h)*f,b.y=b.depth*m})}return A}function r(A){var s=A.children,l=A.parent.children,c=A.i?l[A.i-1]:null;if(s){zJg(A);var u=(s[0].z+s[s.length-1].z)/2;c?(A.z=c.z+e(A._,c._),A.m=A.z-u):A.z=u}else c&&(A.z=c.z+e(A._,c._));A.parent.A=C(A,c,A.parent.A||l[0])}function o(A){A._.x=A.z+A.parent.m,A.m+=A.parent.m}function C(A,s,l){if(s){for(var c=A,u=A,d=s,h=c.parent.children[0],f=c.m,m=u.m,b=d.m,p=h.m,y;d=A4(d),c=s4(c),d&&c;)h=s4(h),u=A4(u),u.a=A,y=d.z+b-c.z-f+e(d._,c._),y>0&&(MJg(PJg(d,A,l),A,y),f+=y,m+=y),b+=d.m,f+=c.m,p+=h.m,m+=u.m;d&&!A4(u)&&(u.t=d,u.m+=b-m),c&&!s4(h)&&(h.t=c,h.m+=f-p,l=A)}return l}function a(A){A.x*=g,A.y=A.depth*i}return I.separation=function(A){return arguments.length?(e=A,I):e},I.size=function(A){return arguments.length?(n=!1,g=+A[0],i=+A[1],I):n?null:[g,i]},I.nodeSize=function(A){return arguments.length?(n=!0,g=+A[0],i=+A[1],I):n?[g,i]:null},I}function kO(e,g,i,n,I){for(var r=e.children,o,C=-1,a=r.length,A=e.value&&(I-i)/e.value;++Cb&&(b=A),v=f*f*Z,p=Math.max(b/v,v/m),p>y){f-=A;break}y=p}o.push(a={value:f,dice:u1?n:1)},i}(Lnt);function JJg(){var e=Qnt,g=!1,i=1,n=1,I=[0],r=u0,o=u0,C=u0,a=u0,A=u0;function s(c){return c.x0=c.y0=0,c.x1=i,c.y1=n,c.eachBefore(l),I=[0],g&&c.eachBefore(Jnt),c}function l(c){var u=I[c.depth],d=c.x0+u,h=c.y0+u,f=c.x1-u,m=c.y1-u;f=c-1){var b=r[l];b.x0=d,b.y0=h,b.x1=f,b.y1=m;return}for(var p=A[l],y=u/2+p,Z=l+1,v=c-1;Z>>1;A[G]m-h){var R=u?(d*S+f*B)/u:f;s(l,Z,B,d,h,R,m),s(Z,c,S,R,h,f,m)}else{var w=u?(h*S+m*B)/u:m;s(l,Z,B,d,h,f,w),s(Z,c,S,d,w,f,m)}}}function UJg(e,g,i,n,I){(e.depth&1?kO:LH)(e,g,i,n,I)}const QJg=function e(g){function i(n,I,r,o,C){if((a=n._squarify)&&a.ratio===g)for(var a,A,s,l,c=-1,u,d=a.length,h=n.value;++c1?n:1)},i}(Lnt);function Jne(e,g,i){const n={};return e.each(I=>{const r=I.data;i(r)&&(n[g(r)]=I)}),e.lookup=n,e}function $de(e){Le.call(this,null,e)}$de.Definition={type:"Nest",metadata:{treesource:!0,changes:!0},params:[{name:"keys",type:"field",array:!0},{name:"generate",type:"boolean"}]};const jJg=e=>e.values;mt($de,Le,{transform(e,g){g.source||qe("Nest transform requires an upstream data source.");var i=e.generate,n=e.modified(),I=g.clone(),r=this.value;return(!r||n||g.changed())&&(r&&r.each(o=>{o.children&&U_(o.data)&&I.rem.push(o.data)}),this.value=r=jde({values:Vt(e.keys).reduce((o,C)=>(o.key(C),o),$Jg()).entries(I.source)},jJg),i&&r.each(o=>{o.children&&(o=li(o.data),I.add.push(o),I.source.push(o))}),Jne(r,eg,eg)),I.source.root=r,I}});function $Jg(){const e=[],g={entries:I=>n(i(I,0),0),key:I=>(e.push(I),g)};function i(I,r){if(r>=e.length)return I;const o=I.length,C=e[r++],a={},A={};let s=-1,l,c,u;for(;++se.length)return I;const o=[];for(const C in I)o.push({key:C,values:n(I[C],r)});return o}return g}function Ch(e){Le.call(this,null,e)}const qJg=(e,g)=>e.parent===g.parent?1:2;mt(Ch,Le,{transform(e,g){(!g.source||!g.source.root)&&qe(this.constructor.name+" transform requires a backing tree data source.");const i=this.layout(e.method),n=this.fields,I=g.source.root,r=e.as||n;e.field?I.sum(e.field):I.count(),e.sort&&I.sort(dZ(e.sort,o=>o.data)),eLg(i,this.params,e),i.separation&&i.separation(e.separation!==!1?qJg:sS);try{this.value=i(I)}catch(o){qe(o)}return I.each(o=>tLg(o,n,r)),g.reflow(e.modified()).modifies(r).modifies("leaf")}});function eLg(e,g,i){for(let n,I=0,r=g.length;Ir[eg(o)]=1),n.each(o=>{const C=o.data,a=o.parent&&o.parent.data;a&&r[eg(C)]&&r[eg(a)]&&I.add.push(li({source:a,target:C}))}),this.value=I.add):g.changed(g.MOD)&&(g.visit(g.MOD,o=>r[eg(o)]=1),i.forEach(o=>{(r[eg(o.source)]||r[eg(o.target)])&&I.mod.push(o)})),I}});const bNe={binary:LJg,dice:LH,slice:kO,slicedice:UJg,squarify:Qnt,resquarify:QJg},jne=["x0","y0","x1","y1","depth","children"];function nhe(e){Ch.call(this,e)}nhe.Definition={type:"Treemap",metadata:{tree:!0,modifies:!0},params:[{name:"field",type:"field"},{name:"sort",type:"compare"},{name:"method",type:"enum",default:"squarify",values:["squarify","resquarify","binary","dice","slice","slicedice"]},{name:"padding",type:"number",default:0},{name:"paddingInner",type:"number",default:0},{name:"paddingOuter",type:"number",default:0},{name:"paddingTop",type:"number",default:0},{name:"paddingRight",type:"number",default:0},{name:"paddingBottom",type:"number",default:0},{name:"paddingLeft",type:"number",default:0},{name:"ratio",type:"number",default:1.618033988749895},{name:"round",type:"boolean",default:!1},{name:"size",type:"number",array:!0,length:2},{name:"as",type:"string",array:!0,length:jne.length,default:jne}]};mt(nhe,Ch,{layout(){const e=JJg();return e.ratio=g=>{const i=e.tile();i.ratio&&e.tile(i.ratio(g))},e.method=g=>{gg(bNe,g)?e.tile(bNe[g]):qe("Unrecognized Treemap layout method: "+g)},e},params:["method","ratio","size","round","padding","paddingInner","paddingOuter","paddingTop","paddingRight","paddingBottom","paddingLeft"],fields:jne});const gLg=Object.freeze(Object.defineProperty({__proto__:null,nest:$de,pack:qde,partition:ehe,stratify:the,tree:ghe,treelinks:ihe,treemap:nhe},Symbol.toStringTag,{value:"Module"})),l4=4278190080;function iLg(e,g){const i=e.bitmap();return(g||[]).forEach(n=>i.set(e(n.boundary[0]),e(n.boundary[3]))),[i,void 0]}function nLg(e,g,i,n,I){const r=e.width,o=e.height,C=n||I,a=om(r,o).getContext("2d"),A=om(r,o).getContext("2d"),s=C&&om(r,o).getContext("2d");i.forEach(B=>ex(a,B,!1)),ex(A,g,!1),C&&ex(s,g,!0);const l=c4(a,r,o),c=c4(A,r,o),u=C&&c4(s,r,o),d=e.bitmap(),h=C&&e.bitmap();let f,m,b,p,y,Z,v,G;for(m=0;m{I.items.forEach(r=>ex(e,r.items,i))}):Za[n].draw(e,{items:i?g.map(ILg):g})}function ILg(e){const g=Q_(e,{});return g.stroke&&g.strokeOpacity!==0||g.fill&&g.fillOpacity!==0?{...g,strokeOpacity:1,stroke:"#000",fillOpacity:0}:g}const Bu=5,so=31,E9=32,gf=new Uint32Array(E9+1),cA=new Uint32Array(E9+1);cA[0]=0;gf[0]=~cA[0];for(let e=1;e<=E9;++e)cA[e]=cA[e-1]<<1|1,gf[e]=~cA[e];function rLg(e,g){const i=new Uint32Array(~~((e*g+E9)/E9));function n(r,o){i[r]|=o}function I(r,o){i[r]&=o}return{array:i,get:(r,o)=>{const C=o*e+r;return i[C>>>Bu]&1<<(C&so)},set:(r,o)=>{const C=o*e+r;n(C>>>Bu,1<<(C&so))},clear:(r,o)=>{const C=o*e+r;I(C>>>Bu,~(1<<(C&so)))},getRange:(r,o,C,a)=>{let A=a,s,l,c,u;for(;A>=o;--A)if(s=A*e+r,l=A*e+C,c=s>>>Bu,u=l>>>Bu,c===u){if(i[c]&gf[s&so]&cA[(l&so)+1])return!0}else{if(i[c]&gf[s&so]||i[u]&cA[(l&so)+1])return!0;for(let d=c+1;d{let A,s,l,c,u;for(;o<=a;++o)if(A=o*e+r,s=o*e+C,l=A>>>Bu,c=s>>>Bu,l===c)n(l,gf[A&so]&cA[(s&so)+1]);else for(n(l,gf[A&so]),n(c,cA[(s&so)+1]),u=l+1;u{let A,s,l,c,u;for(;o<=a;++o)if(A=o*e+r,s=o*e+C,l=A>>>Bu,c=s>>>Bu,l===c)I(l,cA[A&so]|gf[(s&so)+1]);else for(I(l,cA[A&so]),I(c,gf[(s&so)+1]),u=l+1;ur<0||o<0||a>=g||C>=e}}function oLg(e,g,i){const n=Math.max(1,Math.sqrt(e*g/1e6)),I=~~((e+2*i+n)/n),r=~~((g+2*i+n)/n),o=C=>~~((C+i)/n);return o.invert=C=>C*n-i,o.bitmap=()=>rLg(I,r),o.ratio=n,o.padding=i,o.width=e,o.height=g,o}function CLg(e,g,i,n){const I=e.width,r=e.height;return function(o){const C=o.datum.datum.items[n].items,a=C.length,A=o.datum.fontSize,s=xA.width(o.datum,o.datum.text);let l=0,c,u,d,h,f,m,b;for(let p=0;p=l&&(l=b,o.x=f,o.y=m);return f=s/2,m=A/2,c=o.x-f,u=o.x+f,d=o.y-m,h=o.y+m,o.align="center",c<0&&u<=I?o.align="left":0<=c&&II||g-(o=n/2)<0||g+o>r}function Yf(e,g,i,n,I,r,o,C){const a=I*r/(n*2),A=e(g-a),s=e(g+a),l=e(i-(r=r/2)),c=e(i+r);return o.outOfBounds(A,l,s,c)||o.getRange(A,l,s,c)||C&&C.getRange(A,l,s,c)}function aLg(e,g,i,n){const I=e.width,r=e.height,o=g[0],C=g[1];function a(A,s,l,c,u){const d=e.invert(A),h=e.invert(s);let f=l,m=r,b;if(!g3(d,h,c,u,I,r)&&!Yf(e,d,h,u,c,f,o,C)&&!Yf(e,d,h,u,c,u,o,null)){for(;m-f>=1;)b=(f+m)/2,Yf(e,d,h,u,c,b,o,C)?m=b:f=b;if(f>l)return[d,h,f,!0]}}return function(A){const s=A.datum.datum.items[n].items,l=s.length,c=A.datum.fontSize,u=xA.width(A.datum,A.datum.text);let d=i?c:0,h=!1,f=!1,m=0,b,p,y,Z,v,G,B,S,R,w,T,W,V,X,N,Y,x;for(let M=0;Mp&&(x=b,b=p,p=x),y>Z&&(x=y,y=Z,Z=x),R=e(b),T=e(p),w=~~((R+T)/2),W=e(y),X=e(Z),V=~~((W+X)/2),B=w;B>=R;--B)for(S=V;S>=W;--S)Y=a(B,S,d,u,c),Y&&([A.x,A.y,d,h]=Y);for(B=w;B<=T;++B)for(S=V;S<=X;++S)Y=a(B,S,d,u,c),Y&&([A.x,A.y,d,h]=Y);!h&&!i&&(N=Math.abs(p-b+Z-y),v=(b+p)/2,G=(y+Z)/2,N>=m&&!g3(v,G,u,c,I,r)&&!Yf(e,v,G,c,u,c,o,null)&&(m=N,A.x=v,A.y=G,f=!0))}return h||f?(v=u/2,G=c/2,o.setRange(e(A.x-v),e(A.y-G),e(A.x+v),e(A.y+G)),A.align="center",A.baseline="middle",!0):!1}}const sLg=[-1,-1,1,1],ALg=[-1,1,-1,1];function lLg(e,g,i,n){const I=e.width,r=e.height,o=g[0],C=g[1],a=e.bitmap();return function(A){const s=A.datum.datum.items[n].items,l=s.length,c=A.datum.fontSize,u=xA.width(A.datum,A.datum.text),d=[];let h=i?c:0,f=!1,m=!1,b=0,p,y,Z,v,G,B,S,R,w,T,W,V;for(let X=0;X=1;)W=(w+T)/2,Yf(e,G,B,c,u,W,o,C)?T=W:w=W;w>h&&(A.x=G,A.y=B,h=w,f=!0)}}!f&&!i&&(V=Math.abs(y-p+v-Z),G=(p+y)/2,B=(Z+v)/2,V>=b&&!g3(G,B,u,c,I,r)&&!Yf(e,G,B,c,u,c,o,null)&&(b=V,A.x=G,A.y=B,m=!0))}return f||m?(G=u/2,B=c/2,o.setRange(e(A.x-G),e(A.y-B),e(A.x+G),e(A.y+B)),A.align="center",A.baseline="middle",!0):!1}}const cLg=["right","center","left"],uLg=["bottom","middle","top"];function dLg(e,g,i,n){const I=e.width,r=e.height,o=g[0],C=g[1],a=n.length;return function(A){const s=A.boundary,l=A.datum.fontSize;if(s[2]<0||s[5]<0||s[0]>I||s[3]>r)return!1;let c=A.textWidth??0,u,d,h,f,m,b,p,y,Z,v,G,B,S,R,w;for(let T=0;T>>2&3)-1,h=u===0&&d===0||n[T]<0,f=u&&d?Math.SQRT1_2:1,m=n[T]<0?-1:1,b=s[1+u]+n[T]*u*f,G=s[4+d]+m*l*d/2+n[T]*d*f,y=G-l/2,Z=G+l/2,B=e(b),R=e(y),w=e(Z),!c)if(yNe(B,B,R,w,o,C,b,b,y,Z,s,h))c=xA.width(A.datum,A.datum.text);else continue;if(v=b+m*c*u/2,b=v-c/2,p=v+c/2,B=e(b),S=e(p),yNe(B,S,R,w,o,C,b,p,y,Z,s,h))return A.x=u?u*m<0?p:b:v,A.y=d?d*m<0?Z:y:G,A.align=cLg[u*m+1],A.baseline=uLg[d*m+1],o.setRange(B,R,S,w),!0}return!1}}function yNe(e,g,i,n,I,r,o,C,a,A,s,l){return!(I.outOfBounds(e,i,g,n)||(l&&r||I).getRange(e,i,g,n))}const u4=0,d4=4,h4=8,f4=0,m4=1,p4=2,hLg={"top-left":u4+f4,top:u4+m4,"top-right":u4+p4,left:d4+f4,middle:d4+m4,right:d4+p4,"bottom-left":h4+f4,bottom:h4+m4,"bottom-right":h4+p4},fLg={naive:CLg,"reduced-search":aLg,floodfill:lLg};function mLg(e,g,i,n,I,r,o,C,a,A,s){if(!e.length)return e;const l=Math.max(n.length,I.length),c=pLg(n,l),u=bLg(I,l),d=yLg(e[0].datum),h=d==="group"&&e[0].datum.items[a].marktype,f=h==="area",m=ZLg(d,h,C,a),b=A===null||A===1/0,p=f&&s==="naive";let y=-1,Z=-1;const v=e.map(R=>{const w=b?xA.width(R,R.text):void 0;return y=Math.max(y,w),Z=Math.max(Z,R.fontSize),{datum:R,opacity:0,x:void 0,y:void 0,align:void 0,baseline:void 0,boundary:m(R),textWidth:w}});A=A===null||A===1/0?Math.max(y,Z)+Math.max(...n):A;const G=oLg(g[0],g[1],A);let B;if(!p){i&&v.sort((T,W)=>i(T.datum,W.datum));let R=!1;for(let T=0;TT.datum);B=r.length||w?nLg(G,w||[],r,R,f):iLg(G,o&&v)}const S=f?fLg[s](G,B,o,a):dLg(G,B,u,c);return v.forEach(R=>R.opacity=+S(R)),v}function pLg(e,g){const i=new Float64Array(g),n=e.length;for(let I=0;I[r.x,r.x,r.x,r.y,r.y,r.y];return e?e==="line"||e==="area"?r=>I(r.datum):g==="line"?r=>{const o=r.datum.items[n].items;return I(o.length?o[i==="start"?0:o.length-1]:{x:NaN,y:NaN})}:r=>{const o=r.datum.bounds;return[o.x1,(o.x1+o.x2)/2,o.x2,o.y1,(o.y1+o.y2)/2,o.y2]}:I}const $ne=["x","y","opacity","align","baseline"],jnt=["top-left","left","bottom-left","top","bottom","top-right","right","bottom-right"];function Ihe(e){Le.call(this,null,e)}Ihe.Definition={type:"Label",metadata:{modifies:!0},params:[{name:"size",type:"number",array:!0,length:2,required:!0},{name:"sort",type:"compare"},{name:"anchor",type:"string",array:!0,default:jnt},{name:"offset",type:"number",array:!0,default:[1]},{name:"padding",type:"number",default:0,null:!0},{name:"lineAnchor",type:"string",values:["start","end"],default:"end"},{name:"markIndex",type:"number",default:0},{name:"avoidBaseMark",type:"boolean",default:!0},{name:"avoidMarks",type:"data",array:!0},{name:"method",type:"string",default:"naive"},{name:"as",type:"string",array:!0,length:$ne.length,default:$ne}]};mt(Ihe,Le,{transform(e,g){function i(r){const o=e[r];return Bg(o)&&g.modified(o.fields)}const n=e.modified();if(!(n||g.changed(g.ADD_REM)||i("sort")))return;(!e.size||e.size.length!==2)&&qe("Size parameter should be specified as a [width, height] array.");const I=e.as||$ne;return mLg(g.materialize(g.SOURCE).source||[],e.size,e.sort,Vt(e.offset==null?1:e.offset),Vt(e.anchor||jnt),e.avoidMarks||[],e.avoidBaseMark!==!1,e.lineAnchor||"end",e.markIndex||0,e.padding===void 0?0:e.padding,e.method||"naive").forEach(r=>{const o=r.datum;o[I[0]]=r.x,o[I[1]]=r.y,o[I[2]]=r.opacity,o[I[3]]=r.align,o[I[4]]=r.baseline}),g.reflow(n).modifies(I)}});const GLg=Object.freeze(Object.defineProperty({__proto__:null,label:Ihe},Symbol.toStringTag,{value:"Module"}));function $nt(e,g){var i=[],n=function(s){return s(C)},I,r,o,C,a,A;if(g==null)i.push(e);else for(I={},r=0,o=e.length;r{Cet(A,e.x,e.y,e.bandwidth||.3).forEach(s=>{const l={};for(let c=0;ce==="poly"?g:e==="quad"?2:1;function ohe(e){Le.call(this,null,e)}ohe.Definition={type:"Regression",metadata:{generates:!0},params:[{name:"x",type:"field",required:!0},{name:"y",type:"field",required:!0},{name:"groupby",type:"field",array:!0},{name:"method",type:"string",default:"linear",values:Object.keys(qne)},{name:"order",type:"number",default:3},{name:"extent",type:"number",array:!0,length:2},{name:"params",type:"boolean",default:!1},{name:"as",type:"string",array:!0}]};mt(ohe,Le,{transform(e,g){const i=g.fork(g.NO_SOURCE|g.NO_FIELDS);if(!this.value||g.changed()||e.modified()){const n=g.materialize(g.SOURCE).source,I=$nt(n,e.groupby),r=(e.groupby||[]).map(xn),o=e.method||"linear",C=e.order==null?3:e.order,a=vLg(o,C),A=e.as||[xn(e.x),xn(e.y)],s=qne[o],l=[];let c=e.extent;gg(qne,o)||qe("Invalid regression method: "+o),c!=null&&o==="log"&&c[0]<=0&&(g.dataflow.warn("Ignoring extent with values <= 0 for log regression."),c=null),I.forEach(u=>{if(u.length<=a){g.dataflow.warn("Skipping regression with more parameters than data points.");return}const h=s(u,e.x,e.y,C);if(e.params){l.push(li({keys:u.dims,coef:h.coef,rSquared:h.rSquared}));return}const f=c||kc(u,e.x),m=b=>{const p={};for(let y=0;ym([b,h.predict(b)])):iO(h.predict,f,25,200).forEach(m)}),this.value&&(i.rem=this.value),this.value=i.add=i.source=l}return i}});const BLg=Object.freeze(Object.defineProperty({__proto__:null,loess:rhe,regression:ohe},Symbol.toStringTag,{value:"Module"})),bd=11102230246251565e-32,Kr=134217729,wLg=(3+8*bd)*bd;function b4(e,g,i,n,I){let r,o,C,a,A=g[0],s=n[0],l=0,c=0;s>A==s>-A?(r=A,A=g[++l]):(r=s,s=n[++c]);let u=0;if(lA==s>-A?(o=A+r,C=r-(o-A),A=g[++l]):(o=s+r,C=r-(o-s),s=n[++c]),r=o,C!==0&&(I[u++]=C);lA==s>-A?(o=r+A,a=o-r,C=r-(o-a)+(A-a),A=g[++l]):(o=r+s,a=o-r,C=r-(o-a)+(s-a),s=n[++c]),r=o,C!==0&&(I[u++]=C);for(;l=V||-W>=V||(l=e-S,C=e-(S+l)+(l-I),l=i-R,A=i-(R+l)+(l-I),l=g-w,a=g-(w+l)+(l-r),l=n-T,s=n-(T+l)+(l-r),C===0&&a===0&&A===0&&s===0)||(V=WLg*o+wLg*Math.abs(W),W+=S*s+T*C-(w*A+R*a),W>=V||-W>=V))return W;y=C*T,c=Kr*C,u=c-(c-C),d=C-u,c=Kr*T,h=c-(c-T),f=T-h,Z=d*f-(y-u*h-d*h-u*f),v=a*R,c=Kr*a,u=c-(c-a),d=a-u,c=Kr*R,h=c-(c-R),f=R-h,G=d*f-(v-u*h-d*h-u*f),m=Z-G,l=Z-m,Ao[0]=Z-(m+l)+(l-G),b=y+m,l=b-y,p=y-(b-l)+(m-l),m=p-v,l=p-m,Ao[1]=p-(m+l)+(l-v),B=b+m,l=B-b,Ao[2]=b-(B-l)+(m-l),Ao[3]=B;const X=b4(4,mG,4,Ao,ZNe);y=S*s,c=Kr*S,u=c-(c-S),d=S-u,c=Kr*s,h=c-(c-s),f=s-h,Z=d*f-(y-u*h-d*h-u*f),v=w*A,c=Kr*w,u=c-(c-w),d=w-u,c=Kr*A,h=c-(c-A),f=A-h,G=d*f-(v-u*h-d*h-u*f),m=Z-G,l=Z-m,Ao[0]=Z-(m+l)+(l-G),b=y+m,l=b-y,p=y-(b-l)+(m-l),m=p-v,l=p-m,Ao[1]=p-(m+l)+(l-v),B=b+m,l=B-b,Ao[2]=b-(B-l)+(m-l),Ao[3]=B;const N=b4(X,ZNe,4,Ao,GNe);y=C*s,c=Kr*C,u=c-(c-C),d=C-u,c=Kr*s,h=c-(c-s),f=s-h,Z=d*f-(y-u*h-d*h-u*f),v=a*A,c=Kr*a,u=c-(c-a),d=a-u,c=Kr*A,h=c-(c-A),f=A-h,G=d*f-(v-u*h-d*h-u*f),m=Z-G,l=Z-m,Ao[0]=Z-(m+l)+(l-G),b=y+m,l=b-y,p=y-(b-l)+(m-l),m=p-v,l=p-m,Ao[1]=p-(m+l)+(l-v),B=b+m,l=B-b,Ao[2]=b-(B-l)+(m-l),Ao[3]=B;const Y=b4(N,GNe,4,Ao,vNe);return vNe[Y-1]}function $Y(e,g,i,n,I,r){const o=(g-r)*(i-I),C=(e-I)*(n-r),a=o-C;if(o===0||C===0||o>0!=C>0)return a;const A=Math.abs(o+C);return Math.abs(a)>=RLg*A?a:-XLg(e,g,i,n,I,r,A)}const BNe=Math.pow(2,-52),qY=new Uint32Array(512);class i3{static from(g,i=YLg,n=KLg){const I=g.length,r=new Float64Array(I*2);for(let o=0;o>1;if(i>0&&typeof g[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=g;const n=Math.max(2*i-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(i)),this._hullPrev=new Uint32Array(i),this._hullNext=new Uint32Array(i),this._hullTri=new Uint32Array(i),this._hullHash=new Int32Array(this._hashSize).fill(-1),this._ids=new Uint32Array(i),this._dists=new Float64Array(i),this.update()}update(){const{coords:g,_hullPrev:i,_hullNext:n,_hullTri:I,_hullHash:r}=this,o=g.length>>1;let C=1/0,a=1/0,A=-1/0,s=-1/0;for(let R=0;RA&&(A=w),T>s&&(s=T),this._ids[R]=R}const l=(C+A)/2,c=(a+s)/2;let u=1/0,d,h,f;for(let R=0;R0&&(h=R,u=w)}let p=g[2*h],y=g[2*h+1],Z=1/0;for(let R=0;RW&&(R[w++]=V,W=this._dists[V])}this.hull=R.subarray(0,w),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if($Y(m,b,p,y,v,G)<0){const R=h,w=p,T=y;h=f,p=v,y=G,f=R,v=w,G=T}const B=kLg(m,b,p,y,v,G);this._cx=B.x,this._cy=B.y;for(let R=0;R0&&Math.abs(V-w)<=BNe&&Math.abs(X-T)<=BNe||(w=V,T=X,W===d||W===h||W===f))continue;let N=0;for(let $=0,Q=this._hashKey(V,X);$=0;)if(Y=x,Y===N){Y=-1;break}if(Y===-1)continue;let M=this._addTriangle(Y,W,n[Y],-1,-1,I[Y]);I[W]=this._legalize(M+2),I[Y]=M,S++;let F=n[Y];for(;x=n[F],$Y(V,X,g[2*F],g[2*F+1],g[2*x],g[2*x+1])<0;)M=this._addTriangle(F,W,x,I[W],-1,I[F]),I[W]=this._legalize(M+2),n[F]=F,S--,F=x;if(Y===N)for(;x=i[Y],$Y(V,X,g[2*x],g[2*x+1],g[2*Y],g[2*Y+1])<0;)M=this._addTriangle(x,W,Y,-1,I[Y],I[x]),this._legalize(M+2),I[x]=M,n[Y]=Y,S--,Y=x;this._hullStart=i[W]=Y,n[Y]=i[F]=W,n[W]=F,r[this._hashKey(V,X)]=W,r[this._hashKey(g[2*Y],g[2*Y+1])]=Y}this.hull=new Uint32Array(S);for(let R=0,w=this._hullStart;R0?3-i:1+i)/4}function y4(e,g,i,n){const I=e-i,r=g-n;return I*I+r*r}function HLg(e,g,i,n,I,r,o,C){const a=e-o,A=g-C,s=i-o,l=n-C,c=I-o,u=r-C,d=a*a+A*A,h=s*s+l*l,f=c*c+u*u;return a*(l*f-h*u)-A*(s*f-h*c)+d*(s*u-l*c)<0}function NLg(e,g,i,n,I,r){const o=i-e,C=n-g,a=I-e,A=r-g,s=o*o+C*C,l=a*a+A*A,c=.5/(o*A-C*a),u=(A*s-C*l)*c,d=(o*l-a*s)*c;return u*u+d*d}function kLg(e,g,i,n,I,r){const o=i-e,C=n-g,a=I-e,A=r-g,s=o*o+C*C,l=a*a+A*A,c=.5/(o*A-C*a),u=e+(A*s-C*l)*c,d=g+(o*l-a*s)*c;return{x:u,y:d}}function wv(e,g,i,n){if(n-i<=20)for(let I=i+1;I<=n;I++){const r=e[I],o=g[r];let C=I-1;for(;C>=i&&g[e[C]]>o;)e[C+1]=e[C--];e[C+1]=r}else{const I=i+n>>1;let r=i+1,o=n;$R(e,I,r),g[e[i]]>g[e[n]]&&$R(e,i,n),g[e[r]]>g[e[n]]&&$R(e,r,n),g[e[i]]>g[e[r]]&&$R(e,i,r);const C=e[r],a=g[C];for(;;){do r++;while(g[e[r]]a);if(o=o-i?(wv(e,g,r,n),wv(e,g,i,o-1)):(wv(e,g,i,o-1),wv(e,g,r,n))}}function $R(e,g,i){const n=e[g];e[g]=e[i],e[i]=n}function YLg(e){return e[0]}function KLg(e){return e[1]}const wNe=1e-6;class k0{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(g,i){this._+=`M${this._x0=this._x1=+g},${this._y0=this._y1=+i}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(g,i){this._+=`L${this._x1=+g},${this._y1=+i}`}arc(g,i,n){g=+g,i=+i,n=+n;const I=g+n,r=i;if(n<0)throw new Error("negative radius");this._x1===null?this._+=`M${I},${r}`:(Math.abs(this._x1-I)>wNe||Math.abs(this._y1-r)>wNe)&&(this._+="L"+I+","+r),n&&(this._+=`A${n},${n},0,1,1,${g-n},${i}A${n},${n},0,1,1,${this._x1=I},${this._y1=r}`)}rect(g,i,n,I){this._+=`M${this._x0=this._x1=+g},${this._y0=this._y1=+i}h${+n}v${+I}h${-n}Z`}value(){return this._||null}}class eIe{constructor(){this._=[]}moveTo(g,i){this._.push([g,i])}closePath(){this._.push(this._[0].slice())}lineTo(g,i){this._.push([g,i])}value(){return this._.length?this._:null}}let xLg=class{constructor(g,[i,n,I,r]=[0,0,960,500]){if(!((I=+I)>=(i=+i))||!((r=+r)>=(n=+n)))throw new Error("invalid bounds");this.delaunay=g,this._circumcenters=new Float64Array(g.points.length*2),this.vectors=new Float64Array(g.points.length*2),this.xmax=I,this.xmin=i,this.ymax=r,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:g,hull:i,triangles:n},vectors:I}=this;let r,o;const C=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let h=0,f=0,m=n.length,b,p;h1;)r-=2;for(let o=2;o0){if(i>=this.ymax)return null;(o=(this.ymax-i)/I)0){if(g>=this.xmax)return null;(o=(this.xmax-g)/n)this.xmax?2:0)|(ithis.ymax?8:0)}_simplify(g){if(g&&g.length>4){for(let i=0;i1e-10)return!1}return!0}function zLg(e,g,i){return[e+Math.sin(e+g)*i,g+Math.cos(e-g)*i]}class Che{static from(g,i=ELg,n=DLg,I){return new Che("length"in g?PLg(g,i,n,I):Float64Array.from(_Lg(g,i,n,I)))}constructor(g){this._delaunator=new i3(g),this.inedges=new Int32Array(g.length/2),this._hullIndex=new Int32Array(g.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){const g=this._delaunator,i=this.points;if(g.hull&&g.hull.length>2&&MLg(g)){this.collinear=Int32Array.from({length:i.length/2},(c,u)=>u).sort((c,u)=>i[2*c]-i[2*u]||i[2*c+1]-i[2*u+1]);const a=this.collinear[0],A=this.collinear[this.collinear.length-1],s=[i[2*a],i[2*a+1],i[2*A],i[2*A+1]],l=1e-8*Math.hypot(s[3]-s[1],s[2]-s[0]);for(let c=0,u=i.length/2;c0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=I[0],o[I[0]]=1,I.length===2&&(o[I[1]]=0,this.triangles[1]=I[1],this.triangles[2]=I[1]))}voronoi(g){return new xLg(this,g)}*neighbors(g){const{inedges:i,hull:n,_hullIndex:I,halfedges:r,triangles:o,collinear:C}=this;if(C){const l=C.indexOf(g);l>0&&(yield C[l-1]),l=0&&r!==n&&r!==I;)n=r;return r}_step(g,i,n){const{inedges:I,hull:r,_hullIndex:o,halfedges:C,triangles:a,points:A}=this;if(I[g]===-1||!A.length)return(g+1)%(A.length>>1);let s=g,l=pG(i-A[g*2],2)+pG(n-A[g*2+1],2);const c=I[g];let u=c;do{let d=a[u];const h=pG(i-A[d*2],2)+pG(n-A[d*2+1],2);if(h>5,tx=1<<11;function ULg(){var e=[256,256],g,i,n,I,r,o,C,a=qnt,A=[],s=Math.random,l={};l.layout=function(){for(var d=c(om()),h=tUg((e[0]>>5)*e[1]),f=null,m=A.length,b=-1,p=[],y=A.map(v=>({text:g(v),font:i(v),style:I(v),weight:r(v),rotate:o(v),size:~~(n(v)+1e-14),padding:C(v),xoff:0,yoff:0,x1:0,y1:0,x0:0,y0:0,hasText:!1,sprite:null,datum:v})).sort((v,G)=>G.size-v.size);++b>1,Z.y=e[1]*(s()+.5)>>1,QLg(d,Z,y,b),Z.hasText&&u(h,Z,f)&&(p.push(Z),f?$Lg(f,Z):f=[{x:Z.x+Z.x0,y:Z.y+Z.y0},{x:Z.x+Z.x1,y:Z.y+Z.y1}],Z.x-=e[0]>>1,Z.y-=e[1]>>1)}return p};function c(d){d.width=d.height=1;var h=Math.sqrt(d.getContext("2d").getImageData(0,0,1,1).data.length>>2);d.width=(b2<<5)/h,d.height=tx/h;var f=d.getContext("2d");return f.fillStyle=f.strokeStyle="red",f.textAlign="center",{context:f,ratio:h}}function u(d,h,f){for(var m=h.x,b=h.y,p=Math.sqrt(e[0]*e[0]+e[1]*e[1]),y=a(e),Z=s()<.5?1:-1,v=-Z,G,B,S;(G=y(v+=Z))&&(B=~~G[0],S=~~G[1],!(Math.min(Math.abs(B),Math.abs(S))>=p));)if(h.x=m+B,h.y=b+S,!(h.x+h.x0<0||h.y+h.y0<0||h.x+h.x1>e[0]||h.y+h.y1>e[1])&&(!f||!jLg(h,d,e[0]))&&(!f||qLg(h,f))){for(var R=h.sprite,w=h.width>>5,T=e[0]>>5,W=h.x-(w<<4),V=W&127,X=32-V,N=h.y1-h.y0,Y=(h.y+h.y0)*T+(W>>5),x,M=0;M>>V:0);Y+=T}return h.sprite=null,!0}return!1}return l.words=function(d){return arguments.length?(A=d,l):A},l.size=function(d){return arguments.length?(e=[+d[0],+d[1]],l):e},l.font=function(d){return arguments.length?(i=Yp(d),l):i},l.fontStyle=function(d){return arguments.length?(I=Yp(d),l):I},l.fontWeight=function(d){return arguments.length?(r=Yp(d),l):r},l.rotate=function(d){return arguments.length?(o=Yp(d),l):o},l.text=function(d){return arguments.length?(g=Yp(d),l):g},l.spiral=function(d){return arguments.length?(a=gUg[d]||d,l):a},l.fontSize=function(d){return arguments.length?(n=Yp(d),l):n},l.padding=function(d){return arguments.length?(C=Yp(d),l):C},l.random=function(d){return arguments.length?(s=d,l):s},l}function QLg(e,g,i,n){if(!g.sprite){var I=e.context,r=e.ratio;I.clearRect(0,0,(b2<<5)/r,tx/r);var o=0,C=0,a=0,A=i.length,s,l,c,u,d;for(--n;++n>5<<5,c=~~Math.max(Math.abs(b+p),Math.abs(b-p))}else s=s+31>>5<<5;if(c>a&&(a=c),o+s>=b2<<5&&(o=0,C+=a,a=0),C+c>=tx)break;I.translate((o+(s>>1))/r,(C+(c>>1))/r),g.rotate&&I.rotate(g.rotate*Z4),I.fillText(g.text,0,0),g.padding&&(I.lineWidth=2*g.padding,I.strokeText(g.text,0,0)),I.restore(),g.width=s,g.height=c,g.xoff=o,g.yoff=C,g.x1=s>>1,g.y1=c>>1,g.x0=-g.x1,g.y0=-g.y1,g.hasText=!0,o+=s}for(var Z=I.getImageData(0,0,(b2<<5)/r,tx/r).data,v=[];--n>=0;)if(g=i[n],!!g.hasText){for(s=g.width,l=s>>5,c=g.y1-g.y0,u=0;u>5),R=Z[(C+d)*(b2<<5)+(o+u)<<2]?1<<31-u%32:0;v[S]|=R,G|=R}G?B=d:(g.y0++,c--,d--,C++)}g.y1=g.y0+B,g.sprite=v.slice(0,(g.y1-g.y0)*l)}}}function jLg(e,g,i){i>>=5;for(var n=e.sprite,I=e.width>>5,r=e.x-(I<<4),o=r&127,C=32-o,a=e.y1-e.y0,A=(e.y+e.y0)*i+(r>>5),s,l=0;l>>o:0))&g[A+c])return!0;A+=i}return!1}function $Lg(e,g){var i=e[0],n=e[1];g.x+g.x0n.x&&(n.x=g.x+g.x1),g.y+g.y1>n.y&&(n.y=g.y+g.y1)}function qLg(e,g){return e.x+e.x1>g[0].x&&e.x+e.x0g[0].y&&e.y+e.y0h(d(f))}I.forEach(d=>{d[o[0]]=NaN,d[o[1]]=NaN,d[o[3]]=0});const A=r.words(I).text(e.text).size(e.size||[500,500]).padding(e.padding||1).spiral(e.spiral||"archimedean").rotate(e.rotate||0).font(e.font||"sans-serif").fontStyle(e.fontStyle||"normal").fontWeight(e.fontWeight||"normal").fontSize(C).random(ps).layout(),s=r.size(),l=s[0]>>1,c=s[1]>>1,u=A.length;for(let d=0,h,f;dnew Uint8Array(e),rUg=e=>new Uint16Array(e),DW=e=>new Uint32Array(e);function oUg(){let e=8,g=[],i=DW(0),n=eK(0,e),I=eK(0,e);return{data:()=>g,seen:()=>i=CUg(i,g.length),add(r){for(let o=0,C=g.length,a=r.length,A;og.length,curr:()=>n,prev:()=>I,reset:r=>I[r]=n[r],all:()=>e<257?255:e<65537?65535:4294967295,set(r,o){n[r]|=o},clear(r,o){n[r]&=~o},resize(r,o){const C=n.length;(r>C||o>e)&&(e=Math.max(o,e),n=eK(r,e,n),I=eK(r,e))}}}function CUg(e,g,i){return e.length>=g?e:(i=i||new e.constructor(g),i.set(e),i)}function eK(e,g,i){const n=(g<257?IUg:g<65537?rUg:DW)(e);return i&&n.set(i),n}function SNe(e,g,i){const n=1<0)for(f=0;fe,size:()=>i}}function aUg(e,g){return e.sort.call(g,(i,n)=>{const I=e[i],r=e[n];return Ir?1:0}),wYg(e,g)}function sUg(e,g,i,n,I,r,o,C,a){let A=0,s=0,l;for(l=0;Ag.modified(n.fields));return i?this.reinit(e,g):this.eval(e,g)}else return this.init(e,g)},init(e,g){const i=e.fields,n=e.query,I=this._indices={},r=this._dims=[],o=n.length;let C=0,a,A;for(;C{const r=I.remove(g,i);for(const o in n)n[o].reindex(r)})},update(e,g,i){const n=this._dims,I=e.query,r=g.stamp,o=n.length;let C=0,a,A;for(i.filters=0,A=0;Au)for(f=u,m=Math.min(l,d);fd)for(f=Math.max(l,d),m=c;fl)for(d=l,h=Math.min(A,c);dc)for(d=Math.max(A,c),h=s;dC[s]&i?null:o[s];return r.filter(r.MOD,A),I&I-1?(r.filter(r.ADD,s=>{const l=C[s]&i;return!l&&l^a[s]&i?o[s]:null}),r.filter(r.REM,s=>{const l=C[s]&i;return l&&!(l^(l^a[s]&i))?o[s]:null})):(r.filter(r.ADD,A),r.filter(r.REM,s=>(C[s]&i)===I?o[s]:null)),r.filter(r.SOURCE,s=>A(s._index))}});const AUg=Object.freeze(Object.defineProperty({__proto__:null,crossfilter:Ahe,resolvefilter:lhe},Symbol.toStringTag,{value:"Module"})),lUg="RawCode",fy="Literal",cUg="Property",uUg="Identifier",dUg="ArrayExpression",hUg="BinaryExpression",tIt="CallExpression",fUg="ConditionalExpression",mUg="LogicalExpression",pUg="MemberExpression",bUg="ObjectExpression",yUg="UnaryExpression";function ol(e){this.type=e}ol.prototype.visit=function(e){let g,i,n;if(e(this))return 1;for(g=ZUg(this),i=0,n=g.length;i";nu[my]="Identifier";nu[op]="Keyword";nu[KO]="Null";nu[pZ]="Numeric";nu[AC]="Punctuator";nu[jH]="String";nu[GUg]="RegularExpression";var vUg="ArrayExpression",BUg="BinaryExpression",wUg="CallExpression",SUg="ConditionalExpression",gIt="Identifier",RUg="Literal",VUg="LogicalExpression",WUg="MemberExpression",XUg="ObjectExpression",TUg="Property",HUg="UnaryExpression",DI="Unexpected token %0",NUg="Unexpected number",kUg="Unexpected string",YUg="Unexpected identifier",KUg="Unexpected reserved word",xUg="Unexpected end of input",tIe="Invalid regular expression",G4="Invalid regular expression: missing /",iIt="Octal literals are not allowed in strict mode.",FUg="Duplicate data property in object literal not allowed in strict mode",ur="ILLEGAL",D9="Disabled.",EUg=new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\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0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"),DUg=new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B2\\u08E4-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-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\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA69D\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2D\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]");function xO(e,g){if(!e)throw new Error("ASSERT: "+g)}function Mu(e){return e>=48&&e<=57}function che(e){return"0123456789abcdefABCDEF".indexOf(e)>=0}function MW(e){return"01234567".indexOf(e)>=0}function MUg(e){return e===32||e===9||e===11||e===12||e===160||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(e)>=0}function M9(e){return e===10||e===13||e===8232||e===8233}function $H(e){return e===36||e===95||e>=65&&e<=90||e>=97&&e<=122||e===92||e>=128&&EUg.test(String.fromCharCode(e))}function n3(e){return e===36||e===95||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===92||e>=128&&DUg.test(String.fromCharCode(e))}const zUg={if:1,in:1,do:1,var:1,for:1,new:1,try:1,let:1,this:1,else:1,case:1,void:1,with:1,enum:1,while:1,break:1,catch:1,throw:1,const:1,yield:1,class:1,super:1,return:1,typeof:1,delete:1,switch:1,export:1,import:1,public:1,static:1,default:1,finally:1,extends:1,package:1,private:1,function:1,continue:1,debugger:1,interface:1,protected:1,instanceof:1,implements:1};function nIt(){for(;$e1114111||e!=="}")&&oi({},DI,ur),g<=65535?String.fromCharCode(g):(i=(g-65536>>10)+55296,n=(g-65536&1023)+56320,String.fromCharCode(i,n))}function IIt(){var e,g;for(e=zt.charCodeAt($e++),g=String.fromCharCode(e),e===92&&(zt.charCodeAt($e)!==117&&oi({},DI,ur),++$e,e=gIe("u"),(!e||e==="\\"||!$H(e.charCodeAt(0)))&&oi({},DI,ur),g=e);$e>>=")return $e+=4,{type:AC,value:o,start:e,end:$e};if(r=o.substr(0,3),r===">>>"||r==="<<="||r===">>=")return $e+=3,{type:AC,value:r,start:e,end:$e};if(I=r.substr(0,2),n===I[1]&&"+-<>&|".indexOf(n)>=0||I==="=>")return $e+=2,{type:AC,value:I,start:e,end:$e};if(I==="//"&&oi({},DI,ur),"<>=!+-*%&|^/".indexOf(n)>=0)return++$e,{type:AC,value:n,start:e,end:$e};oi({},DI,ur)}function JUg(e){let g="";for(;$e=0&&$e=0&&(i=i.replace(/\\u\{([0-9a-fA-F]+)\}/g,(n,I)=>{if(parseInt(I,16)<=1114111)return"x";oi({},tIe)}).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"x"));try{new RegExp(i)}catch{oi({},tIe)}try{return new RegExp(e,g)}catch{return null}}function jUg(){var e,g,i,n,I;for(e=zt[$e],xO(e==="/","Regular expression literal must start with a slash"),g=zt[$e++],i=!1,n=!1;$e=0&&oi({},tIe,i),{value:i,literal:g}}function qUg(){var e,g,i,n;return bi=null,nIt(),e=$e,g=jUg(),i=$Ug(),n=QUg(g.value,i.value),{literal:g.literal+i.literal,value:n,regex:{pattern:g.value,flags:i.value},start:e,end:$e}}function e7g(e){return e.type===my||e.type===op||e.type===YO||e.type===KO}function rIt(){if(nIt(),$e>=jr)return{type:QH,start:$e,end:$e};const e=zt.charCodeAt($e);return $H(e)?OUg():e===40||e===41||e===59?v4():e===39||e===34?UUg():e===46?Mu(zt.charCodeAt($e+1))?VNe():v4():Mu(e)?VNe():v4()}function pC(){const e=bi;return $e=e.end,bi=rIt(),$e=e.end,e}function oIt(){const e=$e;bi=rIt(),$e=e}function t7g(e){const g=new ol(vUg);return g.elements=e,g}function WNe(e,g,i){const n=new ol(e==="||"||e==="&&"?VUg:BUg);return n.operator=e,n.left=g,n.right=i,n}function g7g(e,g){const i=new ol(wUg);return i.callee=e,i.arguments=g,i}function i7g(e,g,i){const n=new ol(SUg);return n.test=e,n.consequent=g,n.alternate=i,n}function uhe(e){const g=new ol(gIt);return g.name=e,g}function y2(e){const g=new ol(RUg);return g.value=e.value,g.raw=zt.slice(e.start,e.end),e.regex&&(g.raw==="//"&&(g.raw="/(?:)/"),g.regex=e.regex),g}function XNe(e,g,i){const n=new ol(WUg);return n.computed=e==="[",n.object=g,n.property=i,n.computed||(i.member=!0),n}function n7g(e){const g=new ol(XUg);return g.properties=e,g}function TNe(e,g,i){const n=new ol(TUg);return n.key=g,n.value=i,n.kind=e,n}function I7g(e,g){const i=new ol(HUg);return i.operator=e,i.argument=g,i.prefix=!0,i}function oi(e,g){var i,n=Array.prototype.slice.call(arguments,2),I=g.replace(/%(\d)/g,(r,o)=>(xO(o":case"<=":case">=":case"instanceof":case"in":g=7;break;case"<<":case">>":case">>>":g=8;break;case"+":case"-":g=9;break;case"*":case"/":case"%":g=11;break}return g}function f7g(){var e,g,i,n,I,r,o,C,a,A;if(e=bi,a=gx(),n=bi,I=kNe(n),I===0)return a;for(n.prec=I,pC(),g=[e,bi],o=gx(),r=[a,n,o];(I=kNe(bi))>0;){for(;r.length>2&&I<=r[r.length-2].prec;)o=r.pop(),C=r.pop().value,a=r.pop(),g.pop(),i=WNe(C,a,o),r.push(i);n=pC(),n.prec=I,r.push(n),g.push(bi),i=gx(),r.push(i)}for(A=r.length-1,i=r[A],g.pop();A>1;)g.pop(),i=WNe(r[A-1].value,r[A-2],i),A-=2;return i}function py(){var e,g,i;return e=f7g(),gn("?")&&(pC(),g=py(),$r(":"),i=py(),e=i7g(e,g,i)),e}function dhe(){const e=py();if(gn(","))throw new Error(D9);return e}function hhe(e){zt=e,$e=0,jr=zt.length,bi=null,oIt();const g=dhe();if(bi.type!==QH)throw new Error("Unexpect token after expression.");return g}var CIt={NaN:"NaN",E:"Math.E",LN2:"Math.LN2",LN10:"Math.LN10",LOG2E:"Math.LOG2E",LOG10E:"Math.LOG10E",PI:"Math.PI",SQRT1_2:"Math.SQRT1_2",SQRT2:"Math.SQRT2",MIN_VALUE:"Number.MIN_VALUE",MAX_VALUE:"Number.MAX_VALUE"};function aIt(e){function g(o,C,a,A){let s=e(C[0]);return a&&(s=a+"("+s+")",a.lastIndexOf("new ",0)===0&&(s="("+s+")")),s+"."+o+(A<0?"":A===0?"()":"("+C.slice(1).map(e).join(",")+")")}function i(o,C,a){return A=>g(o,A,C,a)}const n="new Date",I="String",r="RegExp";return{isNaN:"Number.isNaN",isFinite:"Number.isFinite",abs:"Math.abs",acos:"Math.acos",asin:"Math.asin",atan:"Math.atan",atan2:"Math.atan2",ceil:"Math.ceil",cos:"Math.cos",exp:"Math.exp",floor:"Math.floor",hypot:"Math.hypot",log:"Math.log",max:"Math.max",min:"Math.min",pow:"Math.pow",random:"Math.random",round:"Math.round",sin:"Math.sin",sqrt:"Math.sqrt",tan:"Math.tan",clamp:function(o){o.length<3&&qe("Missing arguments to clamp function."),o.length>3&&qe("Too many arguments to clamp function.");const C=o.map(e);return"Math.max("+C[1]+", Math.min("+C[2]+","+C[0]+"))"},now:"Date.now",utc:"Date.UTC",datetime:n,date:i("getDate",n,0),day:i("getDay",n,0),year:i("getFullYear",n,0),month:i("getMonth",n,0),hours:i("getHours",n,0),minutes:i("getMinutes",n,0),seconds:i("getSeconds",n,0),milliseconds:i("getMilliseconds",n,0),time:i("getTime",n,0),timezoneoffset:i("getTimezoneOffset",n,0),utcdate:i("getUTCDate",n,0),utcday:i("getUTCDay",n,0),utcyear:i("getUTCFullYear",n,0),utcmonth:i("getUTCMonth",n,0),utchours:i("getUTCHours",n,0),utcminutes:i("getUTCMinutes",n,0),utcseconds:i("getUTCSeconds",n,0),utcmilliseconds:i("getUTCMilliseconds",n,0),length:i("length",null,-1),parseFloat:"parseFloat",parseInt:"parseInt",upper:i("toUpperCase",I,0),lower:i("toLowerCase",I,0),substring:i("substring",I),split:i("split",I),trim:i("trim",I,0),regexp:r,test:i("test",r),if:function(o){o.length<3&&qe("Missing arguments to if function."),o.length>3&&qe("Too many arguments to if function.");const C=o.map(e);return"("+C[0]+"?"+C[1]+":"+C[2]+")"}}}function m7g(e){const g=e&&e.length-1;return g&&(e[0]==='"'&&e[g]==='"'||e[0]==="'"&&e[g]==="'")?e.slice(1,-1):e}function sIt(e){e=e||{};const g=e.allowed?JA(e.allowed):{},i=e.forbidden?JA(e.forbidden):{},n=e.constants||CIt,I=(e.functions||aIt)(l),r=e.globalvar,o=e.fieldvar,C=Bg(r)?r:d=>`${r}["${d}"]`;let a={},A={},s=0;function l(d){if(Rt(d))return d;const h=c[d.type];return h==null&&qe("Unsupported type: "+d.type),h(d)}const c={Literal:d=>d.raw,Identifier:d=>{const h=d.name;return s>0?h:gg(i,h)?qe("Illegal identifier: "+h):gg(n,h)?n[h]:gg(g,h)?h:(a[h]=1,C(h))},MemberExpression:d=>{const h=!d.computed,f=l(d.object);h&&(s+=1);const m=l(d.property);return f===o&&(A[m7g(m)]=1),h&&(s-=1),f+(h?"."+m:"["+m+"]")},CallExpression:d=>{d.callee.type!=="Identifier"&&qe("Illegal callee type: "+d.callee.type);const h=d.callee.name,f=d.arguments,m=gg(I,h)&&I[h];return m||qe("Unrecognized function: "+h),Bg(m)?m(f):m+"("+f.map(l).join(",")+")"},ArrayExpression:d=>"["+d.elements.map(l).join(",")+"]",BinaryExpression:d=>"("+l(d.left)+" "+d.operator+" "+l(d.right)+")",UnaryExpression:d=>"("+d.operator+l(d.argument)+")",ConditionalExpression:d=>"("+l(d.test)+"?"+l(d.consequent)+":"+l(d.alternate)+")",LogicalExpression:d=>"("+l(d.left)+d.operator+l(d.right)+")",ObjectExpression:d=>"{"+d.properties.map(l).join(",")+"}",Property:d=>{s+=1;const h=l(d.key);return s-=1,h+":"+l(d.value)}};function u(d){const h={code:l(d),globals:Object.keys(a),fields:Object.keys(A)};return a={},A={},h}return u.functions=I,u.constants=n,u}function qH(e,g,i){e.prototype=g.prototype=i,i.constructor=e}function EO(e,g){var i=Object.create(e.prototype);for(var n in g)i[n]=g[n];return i}function bZ(){}var z9=.7,I3=1/z9,uB="\\s*([+-]?\\d+)\\s*",P9="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",pc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",p7g=/^#([0-9a-f]{3,8})$/,b7g=new RegExp(`^rgb\\(${uB},${uB},${uB}\\)$`),y7g=new RegExp(`^rgb\\(${pc},${pc},${pc}\\)$`),Z7g=new RegExp(`^rgba\\(${uB},${uB},${uB},${P9}\\)$`),G7g=new RegExp(`^rgba\\(${pc},${pc},${pc},${P9}\\)$`),v7g=new RegExp(`^hsl\\(${P9},${pc},${pc}\\)$`),B7g=new RegExp(`^hsla\\(${P9},${pc},${pc},${P9}\\)$`),YNe={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};qH(bZ,fhe,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:KNe,formatHex:KNe,formatHex8:w7g,formatHsl:S7g,formatRgb:xNe,toString:xNe});function KNe(){return this.rgb().formatHex()}function w7g(){return this.rgb().formatHex8()}function S7g(){return lIt(this).formatHsl()}function xNe(){return this.rgb().formatRgb()}function fhe(e){var g,i;return e=(e+"").trim().toLowerCase(),(g=p7g.exec(e))?(i=g[1].length,g=parseInt(g[1],16),i===6?FNe(g):i===3?new Or(g>>8&15|g>>4&240,g>>4&15|g&240,(g&15)<<4|g&15,1):i===8?tK(g>>24&255,g>>16&255,g>>8&255,(g&255)/255):i===4?tK(g>>12&15|g>>8&240,g>>8&15|g>>4&240,g>>4&15|g&240,((g&15)<<4|g&15)/255):null):(g=b7g.exec(e))?new Or(g[1],g[2],g[3],1):(g=y7g.exec(e))?new Or(g[1]*255/100,g[2]*255/100,g[3]*255/100,1):(g=Z7g.exec(e))?tK(g[1],g[2],g[3],g[4]):(g=G7g.exec(e))?tK(g[1]*255/100,g[2]*255/100,g[3]*255/100,g[4]):(g=v7g.exec(e))?MNe(g[1],g[2]/100,g[3]/100,1):(g=B7g.exec(e))?MNe(g[1],g[2]/100,g[3]/100,g[4]):YNe.hasOwnProperty(e)?FNe(YNe[e]):e==="transparent"?new Or(NaN,NaN,NaN,0):null}function FNe(e){return new Or(e>>16&255,e>>8&255,e&255,1)}function tK(e,g,i,n){return n<=0&&(e=g=i=NaN),new Or(e,g,i,n)}function AIt(e){return e instanceof bZ||(e=fhe(e)),e?(e=e.rgb(),new Or(e.r,e.g,e.b,e.opacity)):new Or}function mhe(e,g,i,n){return arguments.length===1?AIt(e):new Or(e,g,i,n??1)}function Or(e,g,i,n){this.r=+e,this.g=+g,this.b=+i,this.opacity=+n}qH(Or,mhe,EO(bZ,{brighter(e){return e=e==null?I3:Math.pow(I3,e),new Or(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?z9:Math.pow(z9,e),new Or(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Or(rb(this.r),rb(this.g),rb(this.b),r3(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ENe,formatHex:ENe,formatHex8:R7g,formatRgb:DNe,toString:DNe}));function ENe(){return`#${Y0(this.r)}${Y0(this.g)}${Y0(this.b)}`}function R7g(){return`#${Y0(this.r)}${Y0(this.g)}${Y0(this.b)}${Y0((isNaN(this.opacity)?1:this.opacity)*255)}`}function DNe(){const e=r3(this.opacity);return`${e===1?"rgb(":"rgba("}${rb(this.r)}, ${rb(this.g)}, ${rb(this.b)}${e===1?")":`, ${e})`}`}function r3(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function rb(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Y0(e){return e=rb(e),(e<16?"0":"")+e.toString(16)}function MNe(e,g,i,n){return n<=0?e=g=i=NaN:i<=0||i>=1?e=g=NaN:g<=0&&(e=NaN),new yA(e,g,i,n)}function lIt(e){if(e instanceof yA)return new yA(e.h,e.s,e.l,e.opacity);if(e instanceof bZ||(e=fhe(e)),!e)return new yA;if(e instanceof yA)return e;e=e.rgb();var g=e.r/255,i=e.g/255,n=e.b/255,I=Math.min(g,i,n),r=Math.max(g,i,n),o=NaN,C=r-I,a=(r+I)/2;return C?(g===r?o=(i-n)/C+(i0&&a<1?0:o,new yA(o,C,a,e.opacity)}function cIt(e,g,i,n){return arguments.length===1?lIt(e):new yA(e,g,i,n??1)}function yA(e,g,i,n){this.h=+e,this.s=+g,this.l=+i,this.opacity=+n}qH(yA,cIt,EO(bZ,{brighter(e){return e=e==null?I3:Math.pow(I3,e),new yA(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?z9:Math.pow(z9,e),new yA(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,g=isNaN(e)||isNaN(this.s)?0:this.s,i=this.l,n=i+(i<.5?i:1-i)*g,I=2*i-n;return new Or(w4(e>=240?e-240:e+120,I,n),w4(e,I,n),w4(e<120?e+240:e-120,I,n),this.opacity)},clamp(){return new yA(zNe(this.h),gK(this.s),gK(this.l),r3(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=r3(this.opacity);return`${e===1?"hsl(":"hsla("}${zNe(this.h)}, ${gK(this.s)*100}%, ${gK(this.l)*100}%${e===1?")":`, ${e})`}`}}));function zNe(e){return e=(e||0)%360,e<0?e+360:e}function gK(e){return Math.max(0,Math.min(1,e||0))}function w4(e,g,i){return(e<60?g+(i-g)*e/60:e<180?i:e<240?g+(i-g)*(240-e)/60:g)*255}const V7g=Math.PI/180,W7g=180/Math.PI,o3=18,uIt=.96422,dIt=1,hIt=.82521,fIt=4/29,dB=6/29,mIt=3*dB*dB,X7g=dB*dB*dB;function pIt(e){if(e instanceof bc)return new bc(e.l,e.a,e.b,e.opacity);if(e instanceof sd)return ZIt(e);e instanceof Or||(e=AIt(e));var g=W4(e.r),i=W4(e.g),n=W4(e.b),I=S4((.2225045*g+.7168786*i+.0606169*n)/dIt),r,o;return g===i&&i===n?r=o=I:(r=S4((.4360747*g+.3850649*i+.1430804*n)/uIt),o=S4((.0139322*g+.0971045*i+.7141733*n)/hIt)),new bc(116*I-16,500*(r-I),200*(I-o),e.opacity)}function bIt(e,g,i,n){return arguments.length===1?pIt(e):new bc(e,g,i,n??1)}function bc(e,g,i,n){this.l=+e,this.a=+g,this.b=+i,this.opacity=+n}qH(bc,bIt,EO(bZ,{brighter(e){return new bc(this.l+o3*(e??1),this.a,this.b,this.opacity)},darker(e){return new bc(this.l-o3*(e??1),this.a,this.b,this.opacity)},rgb(){var e=(this.l+16)/116,g=isNaN(this.a)?e:e+this.a/500,i=isNaN(this.b)?e:e-this.b/200;return g=uIt*R4(g),e=dIt*R4(e),i=hIt*R4(i),new Or(V4(3.1338561*g-1.6168667*e-.4906146*i),V4(-.9787684*g+1.9161415*e+.033454*i),V4(.0719453*g-.2289914*e+1.4052427*i),this.opacity)}}));function S4(e){return e>X7g?Math.pow(e,1/3):e/mIt+fIt}function R4(e){return e>dB?e*e*e:mIt*(e-fIt)}function V4(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function W4(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function T7g(e){if(e instanceof sd)return new sd(e.h,e.c,e.l,e.opacity);if(e instanceof bc||(e=pIt(e)),e.a===0&&e.b===0)return new sd(NaN,0g?1:e>=g?0:NaN}function H7g(e,g){return e==null||g==null?NaN:ge?1:g>=e?0:NaN}function N7g(e){let g,i,n;e.length!==2?(g=X4,i=(C,a)=>X4(e(C),a),n=(C,a)=>e(C)-a):(g=e===X4||e===H7g?e:k7g,i=e,n=e);function I(C,a,A=0,s=C.length){if(A>>1;i(C[l],a)<0?A=l+1:s=l}while(A>>1;i(C[l],a)<=0?A=l+1:s=l}while(AA&&n(C[l-1],a)>-n(C[l],a)?l-1:l}return{left:I,center:o,right:r}}function k7g(){return 0}function Y7g(e,...g){e=new qD(e),g=g.map(K7g);e:for(const i of e)for(const n of g)if(!n.has(i)){e.delete(i);continue e}return e}function K7g(e){return e instanceof qD?e:new qD(e)}function x7g(...e){const g=new qD;for(const i of e)for(const n of i)g.add(n);return g}const phe="intersect",PNe="union",F7g="vlMulti",E7g="vlPoint",_Ne="or",D7g="and",Nl="_vgsid_",_9=HC(Nl),M7g="E",z7g="R",P7g="R-E",_7g="R-LE",O7g="R-RE",C3="index:unit";function ONe(e,g){for(var i=g.fields,n=g.values,I=i.length,r=0,o,C;rvg(g.fields?{values:g.fields.map(n=>(n.getter||(n.getter=HC(n.field)))(i.datum))}:{[Nl]:_9(i.datum)},g))}function $7g(e,g,i,n){for(var I=this.context.data[e],r=I?I.values.value:[],o={},C={},a={},A,s,l,c,u,d,h,f,m,b,p=r.length,y=0,Z,v;y(G[s[S].field]=B,G),{})))}else u=Nl,d=_9(A),h=o[u]||(o[u]={}),f=h[c]||(h[c]=[]),f.push(d),i&&(f=C[c]||(C[c]=[]),f.push({[Nl]:d}));if(g=g||PNe,o[Nl]?o[Nl]=T4[`${Nl}_${g}`](...Object.values(o[Nl])):Object.keys(o).forEach(G=>{o[G]=Object.keys(o[G]).map(B=>o[G][B]).reduce((B,S)=>B===void 0?S:T4[`${a[G]}_${g}`](B,S))}),r=Object.keys(C),i&&r.length){const G=n?E7g:F7g;o[G]=g===PNe?{[_Ne]:r.reduce((B,S)=>(B.push(...C[S]),B),[])}:{[D7g]:r.map(B=>({[_Ne]:C[B]}))}}return o}var T4={[`${Nl}_union`]:x7g,[`${Nl}_intersect`]:Y7g,E_union:function(e,g){if(!e.length)return g;for(var i=0,n=g.length;ig.indexOf(i)>=0):g},R_union:function(e,g){var i=_r(g[0]),n=_r(g[1]);return i>n&&(i=g[1],n=g[0]),e.length?(e[0]>i&&(e[0]=i),e[1]n&&(i=g[1],n=g[0]),e.length?nn&&(e[1]=n),e):[i,n]}};const q7g=":",eQg="@";function bhe(e,g,i,n){g[0].type!==fy&&qe("First argument to selection functions must be a string literal.");const I=g[0].value,r=g.length>=2&&jg(g).value,o="unit",C=eQg+o,a=q7g+I;r===phe&&!gg(n,C)&&(n[C]=i.getData(I).indataRef(i,o)),gg(n,a)||(n[a]=i.getData(I).tuplesRef())}function vIt(e){const g=this.context.data[e];return g?g.values.value:[]}function tQg(e,g,i){const n=this.context.data[e]["index:"+g],I=n?n.value.get(i):void 0;return I&&I.count}function gQg(e,g){const i=this.context.dataflow,n=this.context.data[e],I=n.input;return i.pulse(I,i.changeset().remove(fs).insert(g)),1}function iQg(e,g,i){if(e){const n=this.context.dataflow,I=e.mark.source;n.pulse(I,n.changeset().encode(e,g))}return i!==void 0?i:e}const eN=e=>function(g,i){return this.context.dataflow.locale()[e](i)(g)},nQg=eN("format"),BIt=eN("timeFormat"),IQg=eN("utcFormat"),rQg=eN("timeParse"),oQg=eN("utcParse"),iK=new Date(2e3,0,1);function DO(e,g,i){return!Number.isInteger(e)||!Number.isInteger(g)?"":(iK.setYear(2e3),iK.setMonth(e),iK.setDate(g),BIt.call(this,iK,i))}function CQg(e){return DO.call(this,e,1,"%B")}function aQg(e){return DO.call(this,e,1,"%b")}function sQg(e){return DO.call(this,0,2+e,"%A")}function AQg(e){return DO.call(this,0,2+e,"%a")}const lQg=":",cQg="@",iIe="%",wIt="$";function yhe(e,g,i,n){g[0].type!==fy&&qe("First argument to data functions must be a string literal.");const I=g[0].value,r=lQg+I;if(!gg(r,n))try{n[r]=i.getData(I).tuplesRef()}catch{}}function uQg(e,g,i,n){g[0].type!==fy&&qe("First argument to indata must be a string literal."),g[1].type!==fy&&qe("Second argument to indata must be a string literal.");const I=g[0].value,r=g[1].value,o=cQg+r;gg(o,n)||(n[o]=i.getData(I).indataRef(i,r))}function VC(e,g,i,n){if(g[0].type===fy)JNe(i,n,g[0].value);else for(e in i.scales)JNe(i,n,e)}function JNe(e,g,i){const n=iIe+i;if(!gg(g,n))try{g[n]=e.scaleRef(i)}catch{}}function ah(e,g){if(Bg(e))return e;if(Rt(e)){const i=g.scales[e];return i&&LEg(i.value)?i.value:void 0}}function dQg(e,g,i){g.__bandwidth=I=>I&&I.bandwidth?I.bandwidth():0,i._bandwidth=VC,i._range=VC,i._scale=VC;const n=I=>"_["+(I.type===fy?ft(iIe+I.value):ft(iIe)+"+"+e(I))+"]";return{_bandwidth:I=>`this.__bandwidth(${n(I[0])})`,_range:I=>`${n(I[0])}.range()`,_scale:I=>`${n(I[0])}(${e(I[1])})`}}function Zhe(e,g){return function(i,n,I){if(i){const r=ah(i,(I||this).context);return r&&r.path[e](n)}else return g(n)}}const hQg=Zhe("area",CPg),fQg=Zhe("bounds",lPg),mQg=Zhe("centroid",mPg);function pQg(e){const g=this.context.group;let i=!1;if(g)for(;e;){if(e===g){i=!0;break}e=e.mark.group}return i}function Ghe(e,g,i){try{e[g].apply(e,["EXPRESSION"].concat([].slice.call(i)))}catch(n){e.warn(n)}return i[i.length-1]}function bQg(){return Ghe(this.context.dataflow,"warn",arguments)}function yQg(){return Ghe(this.context.dataflow,"info",arguments)}function ZQg(){return Ghe(this.context.dataflow,"debug",arguments)}function H4(e){const g=e/255;return g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4)}function nIe(e){const g=mhe(e),i=H4(g.r),n=H4(g.g),I=H4(g.b);return .2126*i+.7152*n+.0722*I}function GQg(e,g){const i=nIe(e),n=nIe(g),I=Math.max(i,n),r=Math.min(i,n);return(I+.05)/(r+.05)}function vQg(){const e=[].slice.call(arguments);return e.unshift({}),vg(...e)}function SIt(e,g){return e===g||e!==e&&g!==g?!0:et(e)?et(g)&&e.length===g.length?BQg(e,g):!1:Wt(e)&&Wt(g)?RIt(e,g):!1}function BQg(e,g){for(let i=0,n=e.length;iRIt(e,g)}function wQg(e,g,i,n,I,r){const o=this.context.dataflow,C=this.context.data[e],a=C.input,A=o.stamp();let s=C.changes,l,c;if(o._trigger===!1||!(a.value.length||g||n))return 0;if((!s||s.stamp{C.modified=!0,o.pulse(a,s).run()},!0,1)),i&&(l=i===!0?fs:et(i)||U_(i)?i:LNe(i),s.remove(l)),g&&s.insert(g),n&&(l=LNe(n),a.value.some(l)?s.remove(l):s.insert(n)),I)for(c in r)s.modify(I,c,r[c]);return 1}function SQg(e){const g=e.touches,i=g[0].clientX-g[1].clientX,n=g[0].clientY-g[1].clientY;return Math.hypot(i,n)}function RQg(e){const g=e.touches;return Math.atan2(g[0].clientY-g[1].clientY,g[0].clientX-g[1].clientX)}const UNe={};function VQg(e,g){const i=UNe[g]||(UNe[g]=HC(g));return et(e)?e.map(i):i(e)}function vhe(e){return et(e)||ArrayBuffer.isView(e)?e:null}function Bhe(e){return vhe(e)||(Rt(e)?e:null)}function WQg(e){for(var g=arguments.length,i=new Array(g>1?g-1:0),n=1;n1?g-1:0),n=1;n1?g-1:0),n=1;n1?g-1:0),n=1;nr.stop(A(s),e(s))),r}function PQg(e,g,i){const n=ah(e,(i||this).context);return function(I){return n?n.path.context(I)(g):""}}function _Qg(e){let g=null;return function(i){return i?X9(i,g=g||Jw(e)):e}}const VIt=e=>e.data;function WIt(e,g){const i=vIt.call(g,e);return i.root&&i.root.lookup||{}}function OQg(e,g,i){const n=WIt(e,this),I=n[g],r=n[i];return I&&r?I.path(r).map(VIt):void 0}function JQg(e,g){const i=WIt(e,this)[g];return i?i.ancestors().map(VIt):void 0}const XIt=()=>typeof window<"u"&&window||null;function LQg(){const e=XIt();return e?e.screen:{}}function UQg(){const e=XIt();return e?[e.innerWidth,e.innerHeight]:[void 0,void 0]}function QQg(){const e=this.context.dataflow,g=e.container&&e.container();return g?[g.clientWidth,g.clientHeight]:[void 0,void 0]}function TIt(e,g,i){if(!e)return[];const[n,I]=e,r=new oI().set(n[0],n[1],I[0],I[1]),o=i||this.context.dataflow.scenegraph().root;return git(o,r,jQg(g))}function jQg(e){let g=null;if(e){const i=Vt(e.marktype),n=Vt(e.markname);g=I=>(!i.length||i.some(r=>I.marktype===r))&&(!n.length||n.some(r=>I.name===r))}return g}function $Qg(e,g,i){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:5;e=Vt(e);const I=e[e.length-1];return I===void 0||Math.hypot(I[0]-g,I[1]-i)>n?[...e,[g,i]]:e}function qQg(e){return Vt(e).reduce((g,i,n)=>{let[I,r]=i;return g+=n==0?`M ${I},${r} `:n===e.length-1?" Z":`L ${I},${r} `},"")}function ejg(e,g,i){const{x:n,y:I,mark:r}=i,o=new oI().set(Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER);for(const[a,A]of g)ao.x2&&(o.x2=a),Ao.y2&&(o.y2=A);return o.translate(n,I),TIt([[o.x1,o.y1],[o.x2,o.y2]],e,r).filter(a=>tjg(a.x,a.y,g))}function tjg(e,g,i){let n=0;for(let I=0,r=i.length-1;Ig!=C>g&&e<(o-a)*(g-A)/(C-A)+a&&n++}return n&1}const O9={random(){return ps()},cumulativeNormal:eO,cumulativeLogNormal:Wce,cumulativeUniform:Nce,densityNormal:Bce,densityLogNormal:Vce,densityUniform:Hce,quantileNormal:tO,quantileLogNormal:Xce,quantileUniform:kce,sampleNormal:q_,sampleLogNormal:Rce,sampleUniform:Tce,isArray:et,isBoolean:gp,isDate:nm,isDefined(e){return e!==void 0},isNumber:Vi,isObject:Wt,isRegExp:Y6e,isString:Rt,isTuple:U_,isValid(e){return e!=null&&e===e},toBoolean:rce,toDate(e){return oce(e)},toNumber:_r,toString:Cce,indexof:XQg,join:WQg,lastindexof:TQg,replace:NQg,reverse:kQg,slice:HQg,flush:N6e,lerp:K6e,merge:vQg,pad:E6e,peek:jg,pluck:VQg,span:vH,inrange:Zv,truncate:D6e,rgb:mhe,lab:bIt,hcl:yIt,hsl:cIt,luminance:nIe,contrast:GQg,sequence:ca,format:nQg,utcFormat:IQg,utcParse:oQg,utcOffset:dqe,utcSequence:mqe,timeFormat:BIt,timeParse:rQg,timeOffset:uqe,timeSequence:fqe,timeUnitSpecifier:iqe,monthFormat:CQg,monthAbbrevFormat:aQg,dayFormat:sQg,dayAbbrevFormat:AQg,quarter:W6e,utcquarter:X6e,week:Iqe,utcweek:Cqe,dayofyear:nqe,utcdayofyear:oqe,warn:bQg,info:yQg,debug:ZQg,extent(e){return kc(e)},inScope:pQg,intersect:TIt,clampRange:T6e,pinchDistance:SQg,pinchAngle:RQg,screen:LQg,containerSize:QQg,windowSize:UQg,bandspace:YQg,setdata:gQg,pathShape:_Qg,panLinear:w6e,panLog:S6e,panPow:R6e,panSymlog:V6e,zoomLinear:ece,zoomLog:tce,zoomPow:jD,zoomSymlog:gce,encode:iQg,modify:wQg,lassoAppend:$Qg,lassoPath:qQg,intersectLasso:ejg},gjg=["view","item","group","xy","x","y"],ijg="event.vega.",HIt="this.",whe={},NIt={forbidden:["_"],allowed:["datum","event","item"],fieldvar:"datum",globalvar:e=>`_[${ft(wIt+e)}]`,functions:njg,constants:CIt,visitors:whe},IIe=sIt(NIt);function njg(e){const g=aIt(e);gjg.forEach(i=>g[i]=ijg+i);for(const i in O9)g[i]=HIt+i;return vg(g,dQg(e,O9,whe)),g}function aI(e,g,i){return arguments.length===1?O9[e]:(O9[e]=g,i&&(whe[e]=i),IIe&&(IIe.functions[e]=HIt+e),this)}aI("bandwidth",KQg,VC);aI("copy",xQg,VC);aI("domain",FQg,VC);aI("range",DQg,VC);aI("invert",EQg,VC);aI("scale",MQg,VC);aI("gradient",zQg,VC);aI("geoArea",hQg,VC);aI("geoBounds",fQg,VC);aI("geoCentroid",mQg,VC);aI("geoShape",PQg,VC);aI("indata",tQg,uQg);aI("data",vIt,yhe);aI("treePath",OQg,yhe);aI("treeAncestors",JQg,yhe);aI("vlSelectionTest",J7g,bhe);aI("vlSelectionIdTest",Q7g,bhe);aI("vlSelectionResolve",$7g,bhe);aI("vlSelectionTuples",j7g);function Ec(e,g){const i={};let n;try{e=Rt(e)?e:ft(e)+"",n=hhe(e)}catch{qe("Expression parse error: "+e)}n.visit(r=>{if(r.type!==tIt)return;const o=r.callee.name,C=NIt.visitors[o];C&&C(o,r.arguments,g,i)});const I=IIe(n);return I.globals.forEach(r=>{const o=wIt+r;!gg(i,o)&&g.getSignal(r)&&(i[o]=g.signalRef(r))}),{$expr:vg({code:I.code},g.options.ast?{ast:n}:null),$fields:I.fields,$params:i}}function Ijg(e){const g=this,i=e.operators||[];return e.background&&(g.background=e.background),e.eventConfig&&(g.eventConfig=e.eventConfig),e.locale&&(g.locale=e.locale),i.forEach(n=>g.parseOperator(n)),i.forEach(n=>g.parseOperatorParameters(n)),(e.streams||[]).forEach(n=>g.parseStream(n)),(e.updates||[]).forEach(n=>g.parseUpdate(n)),g.resolve()}const rjg=JA(["rule"]),QNe=JA(["group","image","rect"]);function ojg(e,g){let i="";return rjg[g]||(e.x2&&(e.x?(QNe[g]&&(i+="if(o.x>o.x2)$=o.x,o.x=o.x2,o.x2=$;"),i+="o.width=o.x2-o.x;"):i+="o.x=o.x2-(o.width||0);"),e.xc&&(i+="o.x=o.xc-(o.width||0)/2;"),e.y2&&(e.y?(QNe[g]&&(i+="if(o.y>o.y2)$=o.y,o.y=o.y2,o.y2=$;"),i+="o.height=o.y2-o.y;"):i+="o.y=o.y2-(o.height||0);"),e.yc&&(i+="o.y=o.yc-(o.height||0)/2;")),i}function She(e){return(e+"").toLowerCase()}function Cjg(e){return She(e)==="operator"}function ajg(e){return She(e)==="collect"}function qR(e,g,i){i.endsWith(";")||(i="return("+i+");");const n=Function(...g.concat(i));return e&&e.functions?n.bind(e.functions):n}function sjg(e,g,i,n){return`((u = ${e}) < (v = ${g}) || u == null) && v != null ? ${i} + : (u > v || v == null) && u != null ? ${n} + : ((v = v instanceof Date ? +v : v), (u = u instanceof Date ? +u : u)) !== u && v === v ? ${i} + : v !== v && u === u ? ${n} : `}var Ajg={operator:(e,g)=>qR(e,["_"],g.code),parameter:(e,g)=>qR(e,["datum","_"],g.code),event:(e,g)=>qR(e,["event"],g.code),handler:(e,g)=>{const i=`var datum=event.item&&event.item.datum;return ${g.code};`;return qR(e,["_","event"],i)},encode:(e,g)=>{const{marktype:i,channels:n}=g;let I="var o=item,datum=o.datum,m=0,$;";for(const r in n){const o="o["+ft(r)+"]";I+=`$=${n[r].code};if(${o}!==$)${o}=$,m=1;`}return I+=ojg(n,i),I+="return m;",qR(e,["item","_"],I)},codegen:{get(e){const g=`[${e.map(ft).join("][")}]`,i=Function("_",`return _${g};`);return i.path=g,i},comparator(e,g){let i;const n=(r,o)=>{const C=g[o];let a,A;return r.path?(a=`a${r.path}`,A=`b${r.path}`):((i=i||{})["f"+o]=r,a=`this.f${o}(a)`,A=`this.f${o}(b)`),sjg(a,A,-C,C)},I=Function("a","b","var u, v; return "+e.map(n).join("")+"0;");return i?I.bind(i):I}}};function ljg(e){const g=this;Cjg(e.type)||!e.type?g.operator(e,e.update?g.operatorExpression(e.update):null):g.transform(e,e.type)}function cjg(e){const g=this;if(e.params){const i=g.get(e.id);i||qe("Invalid operator id: "+e.id),g.dataflow.connect(i,i.parameters(g.parseParameters(e.params),e.react,e.initonly))}}function ujg(e,g){g=g||{};const i=this;for(const n in e){const I=e[n];g[n]=et(I)?I.map(r=>jNe(r,i,g)):jNe(I,i,g)}return g}function jNe(e,g,i){if(!e||!Wt(e))return e;for(let n=0,I=$Ne.length,r;nI&&I.$tupleid?eg:I);return g.fn[i]||(g.fn[i]=ice(n,e.$order,g.expr.codegen))}function bjg(e,g){const i=e.$encode,n={};for(const I in i){const r=i[I];n[I]=PC(g.encodeExpression(r.$expr),r.$fields),n[I].output=r.$output}return n}function yjg(e,g){return g}function Zjg(e,g){const i=e.$subflow;return function(n,I,r){const o=g.fork().parse(i),C=o.get(i.operators[0].id),a=o.signals.parent;return a&&a.set(r),C.detachSubflow=()=>g.detach(o),C}}function Gjg(){return eg}function vjg(e){var g=this,i=e.filter!=null?g.eventExpression(e.filter):void 0,n=e.stream!=null?g.get(e.stream):void 0,I;e.source?n=g.events(e.source,e.type,i):e.merge&&(I=e.merge.map(r=>g.get(r)),n=I[0].merge.apply(I[0],I.slice(1))),e.between&&(I=e.between.map(r=>g.get(r)),n=n.between(I[0],I[1])),e.filter&&(n=n.filter(i)),e.throttle!=null&&(n=n.throttle(+e.throttle)),e.debounce!=null&&(n=n.debounce(+e.debounce)),n==null&&qe("Invalid stream definition: "+JSON.stringify(e)),e.consume&&n.consume(!0),g.stream(e,n)}function Bjg(e){var g=this,i=Wt(i=e.source)?i.$ref:i,n=g.get(i),I=null,r=e.update,o=void 0;n||qe("Source not defined: "+e.source),I=e.target&&e.target.$expr?g.eventExpression(e.target.$expr):g.get(e.target),r&&r.$expr&&(r.$params&&(o=g.parseParameters(r.$params)),r=g.handlerExpression(r.$expr)),g.update(e,n,I,r,o)}const wjg={skip:!0};function Sjg(e){var g=this,i={};if(e.signals){var n=i.signals={};Object.keys(g.signals).forEach(r=>{const o=g.signals[r];e.signals(r,o)&&(n[r]=o.value)})}if(e.data){var I=i.data={};Object.keys(g.data).forEach(r=>{const o=g.data[r];e.data(r,o)&&(I[r]=o.input.value)})}return g.subcontext&&e.recurse!==!1&&(i.subcontext=g.subcontext.map(r=>r.getState(e))),i}function Rjg(e){var g=this,i=g.dataflow,n=e.data,I=e.signals;Object.keys(I||{}).forEach(r=>{i.update(g.signals[r],I[r],wjg)}),Object.keys(n||{}).forEach(r=>{i.pulse(g.data[r].input,i.changeset().remove(fs).insert(n[r]))}),(e.subcontext||[]).forEach((r,o)=>{const C=g.subcontext[o];C&&C.setState(r)})}function kIt(e,g,i,n){return new YIt(e,g,i,n)}function YIt(e,g,i,n){this.dataflow=e,this.transforms=g,this.events=e.events.bind(e),this.expr=n||Ajg,this.signals={},this.scales={},this.nodes={},this.data={},this.fn={},i&&(this.functions=Object.create(i),this.functions.context=this)}function qNe(e){this.dataflow=e.dataflow,this.transforms=e.transforms,this.events=e.events,this.expr=e.expr,this.signals=Object.create(e.signals),this.scales=Object.create(e.scales),this.nodes=Object.create(e.nodes),this.data=Object.create(e.data),this.fn=Object.create(e.fn),e.functions&&(this.functions=Object.create(e.functions),this.functions.context=this)}YIt.prototype=qNe.prototype={fork(){const e=new qNe(this);return(this.subcontext||(this.subcontext=[])).push(e),e},detach(e){this.subcontext=this.subcontext.filter(i=>i!==e);const g=Object.keys(e.nodes);for(const i of g)e.nodes[i]._targets=null;for(const i of g)e.nodes[i].detach();e.nodes=null},get(e){return this.nodes[e]},set(e,g){return this.nodes[e]=g},add(e,g){const i=this,n=i.dataflow,I=e.value;if(i.set(e.id,g),ajg(e.type)&&I&&(I.$ingest?n.ingest(g,I.$ingest,I.$format):I.$request?n.preload(g,I.$request,I.$format):n.pulse(g,n.changeset().insert(I))),e.root&&(i.root=g),e.parent){let r=i.get(e.parent.$ref);r?(n.connect(r,[g]),g.targets().add(r)):(i.unresolved=i.unresolved||[]).push(()=>{r=i.get(e.parent.$ref),n.connect(r,[g]),g.targets().add(r)})}if(e.signal&&(i.signals[e.signal]=g),e.scale&&(i.scales[e.scale]=g),e.data)for(const r in e.data){const o=i.data[r]||(i.data[r]={});e.data[r].forEach(C=>o[C]=g)}},resolve(){return(this.unresolved||[]).forEach(e=>e()),delete this.unresolved,this},operator(e,g){this.add(e,this.dataflow.add(e.value,g))},transform(e,g){this.add(e,this.dataflow.add(this.transforms[She(g)]))},stream(e,g){this.set(e.id,g)},update(e,g,i,n,I){this.dataflow.on(g,i,n,I,e.options)},operatorExpression(e){return this.expr.operator(this,e)},parameterExpression(e){return this.expr.parameter(this,e)},eventExpression(e){return this.expr.event(this,e)},handlerExpression(e){return this.expr.handler(this,e)},encodeExpression(e){return this.expr.encode(this,e)},parse:Ijg,parseOperator:ljg,parseOperatorParameters:cjg,parseParameters:ujg,parseStream:vjg,parseUpdate:Bjg,getState:Sjg,setState:Rjg};function Vjg(e){const g=e.container();g&&(g.setAttribute("role","graphics-document"),g.setAttribute("aria-roleDescription","visualization"),KIt(g,e.description()))}function KIt(e,g){e&&(g==null?e.removeAttribute("aria-label"):e.setAttribute("aria-label",g))}function Wjg(e){e.add(null,g=>(e._background=g.bg,e._resize=1,g.bg),{bg:e._signals.background})}const N4="default";function Xjg(e){const g=e._signals.cursor||(e._signals.cursor=e.add({user:N4,item:null}));e.on(e.events("view","mousemove"),g,(i,n)=>{const I=g.value,r=I?Rt(I)?I:I.user:N4,o=n.item&&n.item.cursor||null;return I&&r===I.user&&o==I.item?I:{user:r,item:o}}),e.add(null,function(i){let n=i.cursor,I=this.value;return Rt(n)||(I=n.item,n=n.user),rIe(e,n&&n!==N4?n:I||n),I},{cursor:g})}function rIe(e,g){const i=e.globalCursor()?typeof document<"u"&&document.body:e.container();if(i)return g==null?i.style.removeProperty("cursor"):i.style.cursor=g}function a3(e,g){var i=e._runtime.data;return gg(i,g)||qe("Unrecognized data set: "+g),i[g]}function Tjg(e,g){return arguments.length<2?a3(this,e).values.value:MO.call(this,e,hZ().remove(fs).insert(g))}function MO(e,g){_qe(g)||qe("Second argument to changes must be a changeset.");const i=a3(this,e);return i.modified=!0,this.pulse(i.input,g)}function Hjg(e,g){return MO.call(this,e,hZ().insert(g))}function Njg(e,g){return MO.call(this,e,hZ().remove(g))}function xIt(e){var g=e.padding();return Math.max(0,e._viewWidth+g.left+g.right)}function FIt(e){var g=e.padding();return Math.max(0,e._viewHeight+g.top+g.bottom)}function zO(e){var g=e.padding(),i=e._origin;return[g.left+i[0],g.top+i[1]]}function kjg(e){var g=zO(e),i=xIt(e),n=FIt(e);e._renderer.background(e.background()),e._renderer.resize(i,n,g),e._handler.origin(g),e._resizeListeners.forEach(I=>{try{I(i,n)}catch(r){e.error(r)}})}function Yjg(e,g,i){var n=e._renderer,I=n&&n.canvas(),r,o,C;return I&&(C=zO(e),o=g.changedTouches?g.changedTouches[0]:g,r=RO(o,I),r[0]-=C[0],r[1]-=C[1]),g.dataflow=e,g.item=i,g.vega=Kjg(e,i,r),g}function Kjg(e,g,i){const n=g?g.mark.marktype==="group"?g:g.mark.group:null;function I(o){var C=n,a;if(o){for(a=g;a;a=a.mark.group)if(a.mark.name===o){C=a;break}}return C&&C.mark&&C.mark.interactive?C:{}}function r(o){if(!o)return i;Rt(o)&&(o=I(o));const C=i.slice();for(;o;)C[0]-=o.x||0,C[1]-=o.y||0,o=o.mark&&o.mark.group;return C}return{view:no(e),item:no(g||{}),group:I,xy:r,x:o=>r(o)[0],y:o=>r(o)[1]}}const eke="view",xjg="timer",Fjg="window",Ejg={trap:!1};function Djg(e){const g=vg({defaults:{}},e),i=(n,I)=>{I.forEach(r=>{et(n[r])&&(n[r]=JA(n[r]))})};return i(g.defaults,["prevent","allow"]),i(g,["view","window","selector"]),g}function EIt(e,g,i,n){e._eventListeners.push({type:i,sources:Vt(g),handler:n})}function Mjg(e,g){var i=e._eventConfig.defaults,n=i.prevent,I=i.allow;return n===!1||I===!0?!1:n===!0||I===!1?!0:n?n[g]:I?!I[g]:e.preventDefault()}function nK(e,g,i){const n=e._eventConfig&&e._eventConfig[g];return n===!1||Wt(n)&&!n[i]?(e.warn(`Blocked ${g} ${i} event listener.`),!1):!0}function zjg(e,g,i){var n=this,I=new $_(i),r=function(A,s){n.runAsync(null,()=>{e===eke&&Mjg(n,g)&&A.preventDefault(),I.receive(Yjg(n,A,s))})},o;if(e===xjg)nK(n,"timer",g)&&n.timer(r,g);else if(e===eke)nK(n,"view",g)&&n.addEventListener(g,r,Ejg);else if(e===Fjg?nK(n,"window",g)&&typeof window<"u"&&(o=[window]):typeof document<"u"&&nK(n,"selector",g)&&(o=Array.from(document.querySelectorAll(e))),!o)n.warn("Can not resolve event source: "+e);else{for(var C=0,a=o.length;C=0;)g[n].stop();for(n=i.length;--n>=0;)for(r=i[n],I=r.sources.length;--I>=0;)r.sources[I].removeEventListener(r.type,r.handler);return e&&e.call(this,this._handler,null,null,null),this}function fa(e,g,i){const n=document.createElement(e);for(const I in g)n.setAttribute(I,g[I]);return i!=null&&(n.textContent=i),n}const Ojg="vega-bind",Jjg="vega-bind-name",Ljg="vega-bind-radio";function Ujg(e,g,i){if(!g)return;const n=i.param;let I=i.state;return I||(I=i.state={elements:null,active:!1,set:null,update:o=>{o!=e.signal(n.signal)&&e.runAsync(null,()=>{I.source=!0,e.signal(n.signal,o)})}},n.debounce&&(I.update=nce(n.debounce,I.update))),(n.input==null&&n.element?Qjg:$jg)(I,g,n,e),I.active||(e.on(e._signals[n.signal],null,()=>{I.source?I.source=!1:I.set(e.signal(n.signal))}),I.active=!0),I}function Qjg(e,g,i,n){const I=i.event||"input",r=()=>e.update(g.value);n.signal(i.signal,g.value),g.addEventListener(I,r),EIt(n,g,I,r),e.set=o=>{g.value=o,g.dispatchEvent(jjg(I))}}function jjg(e){return typeof Event<"u"?new Event(e):{type:e}}function $jg(e,g,i,n){const I=n.signal(i.signal),r=fa("div",{class:Ojg}),o=i.input==="radio"?r:r.appendChild(fa("label"));o.appendChild(fa("span",{class:Jjg},i.name||i.signal)),g.appendChild(r);let C=qjg;switch(i.input){case"checkbox":C=e4g;break;case"select":C=t4g;break;case"radio":C=g4g;break;case"range":C=i4g;break}C(e,o,i,I)}function qjg(e,g,i,n){const I=fa("input");for(const r in i)r!=="signal"&&r!=="element"&&I.setAttribute(r==="input"?"type":r,i[r]);I.setAttribute("name",i.signal),I.value=n,g.appendChild(I),I.addEventListener("input",()=>e.update(I.value)),e.elements=[I],e.set=r=>I.value=r}function e4g(e,g,i,n){const I={type:"checkbox",name:i.signal};n&&(I.checked=!0);const r=fa("input",I);g.appendChild(r),r.addEventListener("change",()=>e.update(r.checked)),e.elements=[r],e.set=o=>r.checked=!!o||null}function t4g(e,g,i,n){const I=fa("select",{name:i.signal}),r=i.labels||[];i.options.forEach((o,C)=>{const a={value:o};s3(o,n)&&(a.selected=!0),I.appendChild(fa("option",a,(r[C]||o)+""))}),g.appendChild(I),I.addEventListener("change",()=>{e.update(i.options[I.selectedIndex])}),e.elements=[I],e.set=o=>{for(let C=0,a=i.options.length;C{const a={type:"radio",name:i.signal,value:o};s3(o,n)&&(a.checked=!0);const A=fa("input",a);A.addEventListener("change",()=>e.update(o));const s=fa("label",{},(r[C]||o)+"");return s.prepend(A),I.appendChild(s),A}),e.set=o=>{const C=e.elements,a=C.length;for(let A=0;A{a.textContent=C.value,e.update(+C.value)};C.addEventListener("input",A),C.addEventListener("change",A),e.elements=[C],e.set=s=>{C.value=s,a.textContent=s}}function s3(e,g){return e===g||e+""==g+""}function DIt(e,g,i,n,I,r){return g=g||new n(e.loader()),g.initialize(i,xIt(e),FIt(e),zO(e),I,r).background(e.background())}function Rhe(e,g){return g?function(){try{g.apply(this,arguments)}catch(i){e.error(i)}}:null}function n4g(e,g,i,n){const I=new n(e.loader(),Rhe(e,e.tooltip())).scene(e.scenegraph().root).initialize(i,zO(e),e);return g&&g.handlers().forEach(r=>{I.on(r.type,r.handler)}),I}function I4g(e,g){const i=this,n=i._renderType,I=i._eventConfig.bind,r=VO(n);e=i._el=e?k4(i,e,!0):null,Vjg(i),r||i.error("Unrecognized renderer type: "+n);const o=r.handler||PH,C=e?r.renderer:r.headless;return i._renderer=C?DIt(i,i._renderer,e,C):null,i._handler=n4g(i,i._handler,e,o),i._redraw=!0,e&&I!=="none"&&(g=g?i._elBind=k4(i,g,!0):e.appendChild(fa("form",{class:"vega-bindings"})),i._bind.forEach(a=>{a.param.element&&I!=="container"&&(a.element=k4(i,a.param.element,!!a.param.input))}),i._bind.forEach(a=>{Ujg(i,a.element||g,a)})),i}function k4(e,g,i){if(typeof g=="string")if(typeof document<"u"){if(g=document.querySelector(g),!g)return e.error("Signal bind element not found: "+g),null}else return e.error("DOM document instance not found."),null;if(g&&i)try{g.textContent=""}catch(n){g=null,e.error(n)}return g}const eV=e=>+e||0,r4g=e=>({top:e,bottom:e,left:e,right:e});function nke(e){return Wt(e)?{top:eV(e.top),bottom:eV(e.bottom),left:eV(e.left),right:eV(e.right)}:r4g(eV(e))}async function Vhe(e,g,i,n){const I=VO(g),r=I&&I.headless;return r||qe("Unrecognized renderer type: "+g),await e.runAsync(),DIt(e,null,null,r,i,n).renderAsync(e._scenegraph.root)}async function o4g(e,g){e!==Tf.Canvas&&e!==Tf.SVG&&e!==Tf.PNG&&qe("Unrecognized image type: "+e);const i=await Vhe(this,e,g);return e===Tf.SVG?C4g(i.svg(),"image/svg+xml"):i.canvas().toDataURL("image/png")}function C4g(e,g){const i=new Blob([e],{type:g});return window.URL.createObjectURL(i)}async function a4g(e,g){return(await Vhe(this,Tf.Canvas,e,g)).canvas()}async function s4g(e){return(await Vhe(this,Tf.SVG,e)).svg()}function A4g(e,g,i){return kIt(e,Dw,O9,i).parse(g)}function l4g(e){var g=this._runtime.scales;return gg(g,e)||qe("Unrecognized scale or projection: "+e),g[e].value}var MIt="width",zIt="height",Whe="padding",Ike={skip:!0};function PIt(e,g){var i=e.autosize(),n=e.padding();return g-(i&&i.contains===Whe?n.left+n.right:0)}function _It(e,g){var i=e.autosize(),n=e.padding();return g-(i&&i.contains===Whe?n.top+n.bottom:0)}function c4g(e){var g=e._signals,i=g[MIt],n=g[zIt],I=g[Whe];function r(){e._autosize=e._resize=1}e._resizeWidth=e.add(null,C=>{e._width=C.size,e._viewWidth=PIt(e,C.size),r()},{size:i}),e._resizeHeight=e.add(null,C=>{e._height=C.size,e._viewHeight=_It(e,C.size),r()},{size:n});const o=e.add(null,r,{pad:I});e._resizeWidth.rank=i.rank+1,e._resizeHeight.rank=n.rank+1,o.rank=I.rank+1}function u4g(e,g,i,n,I,r){this.runAfter(o=>{let C=0;o._autosize=0,o.width()!==i&&(C=1,o.signal(MIt,i,Ike),o._resizeWidth.skip(!0)),o.height()!==n&&(C=1,o.signal(zIt,n,Ike),o._resizeHeight.skip(!0)),o._viewWidth!==e&&(o._resize=1,o._viewWidth=e),o._viewHeight!==g&&(o._resize=1,o._viewHeight=g),(o._origin[0]!==I[0]||o._origin[1]!==I[1])&&(o._resize=1,o._origin=I),C&&o.run("enter"),r&&o.runAfter(a=>a.resize())},!1,1)}function d4g(e){return this._runtime.getState(e||{data:h4g,signals:f4g,recurse:!0})}function h4g(e,g){return g.modified&&et(g.input.value)&&e.indexOf("_:vega:_")}function f4g(e,g){return!(e==="parent"||g instanceof Dw.proxy)}function m4g(e){return this.runAsync(null,g=>{g._trigger=!1,g._runtime.setState(e)},g=>{g._trigger=!0}),this}function p4g(e,g){function i(n){e({timestamp:Date.now(),elapsed:n})}this._timers.push(TOg(i,g))}function b4g(e,g,i,n){const I=e.element();I&&I.setAttribute("title",y4g(n))}function y4g(e){return e==null?"":et(e)?OIt(e):Wt(e)&&!nm(e)?Z4g(e):e+""}function Z4g(e){return Object.keys(e).map(g=>{const i=e[g];return g+": "+(et(i)?OIt(i):JIt(i))}).join(` +`)}function OIt(e){return"["+e.map(JIt).join(", ")+"]"}function JIt(e){return et(e)?"[…]":Wt(e)&&!nm(e)?"{…}":e}function LIt(e,g){const i=this;if(g=g||{},aB.call(i),g.loader&&i.loader(g.loader),g.logger&&i.logger(g.logger),g.logLevel!=null&&i.logLevel(g.logLevel),g.locale||e.locale){const r=vg({},e.locale,g.locale);i.locale(kqe(r.number,r.time))}i._el=null,i._elBind=null,i._renderType=g.renderer||Tf.Canvas,i._scenegraph=new rde;const n=i._scenegraph.root;i._renderer=null,i._tooltip=g.tooltip||b4g,i._redraw=!0,i._handler=new PH().scene(n),i._globalCursor=!1,i._preventDefault=!1,i._timers=[],i._eventListeners=[],i._resizeListeners=[],i._eventConfig=Djg(e.eventConfig),i.globalCursor(i._eventConfig.globalCursor);const I=A4g(i,e,g.expr);i._runtime=I,i._signals=I.signals,i._bind=(e.bindings||[]).map(r=>({state:null,param:vg({},r)})),I.root&&I.root.set(n),n.source=I.data.root.input,i.pulse(I.data.root.input,i.changeset().insert(n.items)),i._width=i.width(),i._height=i.height(),i._viewWidth=PIt(i,i._width),i._viewHeight=_It(i,i._height),i._origin=[0,0],i._resize=0,i._autosize=1,c4g(i),Wjg(i),Xjg(i),i.description(e.description),g.hover&&i.hover(),g.container&&i.initialize(g.container,g.bind)}function IK(e,g){return gg(e._signals,g)?e._signals[g]:qe("Unrecognized signal name: "+ft(g))}function UIt(e,g){const i=(e._targets||[]).filter(n=>n._update&&n._update.handler===g);return i.length?i[0]:null}function rke(e,g,i,n){let I=UIt(i,n);return I||(I=Rhe(e,()=>n(g,i.value)),I.handler=n,e.on(i,null,I)),e}function oke(e,g,i){const n=UIt(g,i);return n&&g._targets.remove(n),e}mt(LIt,aB,{async evaluate(e,g,i){if(await aB.prototype.evaluate.call(this,e,g),this._redraw||this._resize)try{this._renderer&&(this._resize&&(this._resize=0,kjg(this)),await this._renderer.renderAsync(this._scenegraph.root)),this._redraw=!1}catch(n){this.error(n)}return i&&E5(this,i),this},dirty(e){this._redraw=!0,this._renderer&&this._renderer.dirty(e)},description(e){if(arguments.length){const g=e!=null?e+"":null;return g!==this._desc&&KIt(this._el,this._desc=g),this}return this._desc},container(){return this._el},scenegraph(){return this._scenegraph},origin(){return this._origin.slice()},signal(e,g,i){const n=IK(this,e);return arguments.length===1?n.value:this.update(n,g,i)},width(e){return arguments.length?this.signal("width",e):this.signal("width")},height(e){return arguments.length?this.signal("height",e):this.signal("height")},padding(e){return arguments.length?this.signal("padding",nke(e)):nke(this.signal("padding"))},autosize(e){return arguments.length?this.signal("autosize",e):this.signal("autosize")},background(e){return arguments.length?this.signal("background",e):this.signal("background")},renderer(e){return arguments.length?(VO(e)||qe("Unrecognized renderer type: "+e),e!==this._renderType&&(this._renderType=e,this._resetRenderer()),this):this._renderType},tooltip(e){return arguments.length?(e!==this._tooltip&&(this._tooltip=e,this._resetRenderer()),this):this._tooltip},loader(e){return arguments.length?(e!==this._loader&&(aB.prototype.loader.call(this,e),this._resetRenderer()),this):this._loader},resize(){return this._autosize=1,this.touch(IK(this,"autosize"))},_resetRenderer(){this._renderer&&(this._renderer=null,this.initialize(this._el,this._elBind))},_resizeView:u4g,addEventListener(e,g,i){let n=g;return i&&i.trap===!1||(n=Rhe(this,g),n.raw=g),this._handler.on(e,n),this},removeEventListener(e,g){for(var i=this._handler.handlers(e),n=i.length,I,r;--n>=0;)if(r=i[n].type,I=i[n].handler,e===r&&(g===I||g===I.raw)){this._handler.off(r,I);break}return this},addResizeListener(e){const g=this._resizeListeners;return g.indexOf(e)<0&&g.push(e),this},removeResizeListener(e){var g=this._resizeListeners,i=g.indexOf(e);return i>=0&&g.splice(i,1),this},addSignalListener(e,g){return rke(this,e,IK(this,e),g)},removeSignalListener(e,g){return oke(this,IK(this,e),g)},addDataListener(e,g){return rke(this,e,a3(this,e).values,g)},removeDataListener(e,g){return oke(this,a3(this,e).values,g)},globalCursor(e){if(arguments.length){if(this._globalCursor!==!!e){const g=rIe(this,null);this._globalCursor=!!e,g&&rIe(this,g)}return this}else return this._globalCursor},preventDefault(e){return arguments.length?(this._preventDefault=e,this):this._preventDefault},timer:p4g,events:zjg,finalize:_jg,hover:Pjg,data:Tjg,change:MO,insert:Hjg,remove:Njg,scale:l4g,initialize:I4g,toImageURL:o4g,toCanvas:a4g,toSVG:s4g,getState:d4g,setState:m4g});const G4g="view",A3="[",l3="]",QIt="{",jIt="}",v4g=":",$It=",",B4g="@",w4g=">",S4g=/[[\]{}]/,R4g={"*":1,arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1};let qIt,ert;function Cp(e,g,i){return qIt=g||G4g,ert=i||R4g,trt(e.trim()).map(oIe)}function V4g(e){return ert[e]}function zW(e,g,i,n,I){const r=e.length;let o=0,C;for(;g=0?--o:n&&n.indexOf(C)>=0&&++o}return g}function trt(e){const g=[],i=e.length;let n=0,I=0;for(;I' after between selector: "+e;n=n.map(oIe);const I=oIe(e.slice(1).trim());return I.between?{between:n,stream:I}:(I.between=n,I)}function X4g(e){const g={source:qIt},i=[];let n=[0,0],I=0,r=0,o=e.length,C=0,a,A;if(e[o-1]===jIt){if(C=e.lastIndexOf(QIt),C>=0){try{n=T4g(e.substring(C+1,o-1))}catch{throw"Invalid throttle specification: "+e}e=e.slice(0,C).trim(),o=e.length}else throw"Unmatched right brace: "+e;C=0}if(!o)throw e;if(e[0]===B4g&&(I=++C),a=zW(e,C,v4g),a1?(g.type=i[1],I?g.markname=i[0].slice(1):V4g(i[0])?g.marktype=i[0]:g.source=i[0]):g.type=i[0],g.type.slice(-1)==="!"&&(g.consume=!0,g.type=g.type.slice(0,-1)),A!=null&&(g.filter=A),n[0]&&(g.throttle=n[0]),n[1]&&(g.debounce=n[1]),g}function T4g(e){const g=e.split($It);if(!e.length||g.length>2)throw e;return g.map(i=>{const n=+i;if(n!==n)throw e;return n})}function H4g(e){return Wt(e)?e:{type:e||"pad"}}const tV=e=>+e||0,N4g=e=>({top:e,bottom:e,left:e,right:e});function k4g(e){return Wt(e)?e.signal?e:{top:tV(e.top),bottom:tV(e.bottom),left:tV(e.left),right:tV(e.right)}:N4g(tV(e))}const MI=e=>Wt(e)&&!et(e)?vg({},e):{value:e};function Cke(e,g,i,n){return i!=null?(Wt(i)&&!et(i)||et(i)&&i.length&&Wt(i[0])?e.update[g]=i:e[n||"enter"][g]={value:i},1):0}function yr(e,g,i){for(const n in g)Cke(e,n,g[n]);for(const n in i)Cke(e,n,i[n],"update")}function GS(e,g,i){for(const n in g)i&&gg(i,n)||(e[n]=vg(e[n]||{},g[n]));return e}function QG(e,g){return g&&(g.enter&&g.enter[e]||g.update&&g.update[e])}const Xhe="mark",The="frame",Hhe="scope",Y4g="axis",K4g="axis-domain",x4g="axis-grid",F4g="axis-label",E4g="axis-tick",D4g="axis-title",M4g="legend",z4g="legend-band",P4g="legend-entry",_4g="legend-gradient",grt="legend-label",O4g="legend-symbol",J4g="legend-title",L4g="title",U4g="title-text",Q4g="title-subtitle";function j4g(e,g,i,n,I){const r={},o={};let C,a,A,s;a="lineBreak",g==="text"&&I[a]!=null&&!QG(a,e)&&Y4(r,a,I[a]),(i=="legend"||String(i).startsWith("axis"))&&(i=null),s=i===The?I.group:i===Xhe?vg({},I.mark,I[g]):null;for(a in s)A=QG(a,e)||(a==="fill"||a==="stroke")&&(QG("fill",e)||QG("stroke",e)),A||Y4(r,a,s[a]);Vt(n).forEach(l=>{const c=I.style&&I.style[l];for(const u in c)QG(u,e)||Y4(r,u,c[u])}),e=vg({},e);for(a in r)s=r[a],s.signal?(C=C||{})[a]=s:o[a]=s;return e.enter=vg(o,e.enter),C&&(e.update=vg(C,e.update)),e}function Y4(e,g,i){e[g]=i&&i.signal?{signal:i.signal}:{value:i}}const irt=e=>Rt(e)?ft(e):e.signal?`(${e.signal})`:nrt(e);function PO(e){if(e.gradient!=null)return q4g(e);let g=e.signal?`(${e.signal})`:e.color?$4g(e.color):e.field!=null?nrt(e.field):e.value!==void 0?ft(e.value):void 0;return e.scale!=null&&(g=e$g(e,g)),g===void 0&&(g=null),e.exponent!=null&&(g=`pow(${g},${ix(e.exponent)})`),e.mult!=null&&(g+=`*${ix(e.mult)}`),e.offset!=null&&(g+=`+${ix(e.offset)}`),e.round&&(g=`round(${g})`),g}const rK=(e,g,i,n)=>`(${e}(${[g,i,n].map(PO).join(",")})+'')`;function $4g(e){return e.c?rK("hcl",e.h,e.c,e.l):e.h||e.s?rK("hsl",e.h,e.s,e.l):e.l||e.a?rK("lab",e.l,e.a,e.b):e.r||e.g||e.b?rK("rgb",e.r,e.g,e.b):null}function q4g(e){const g=[e.start,e.stop,e.count].map(i=>i==null?null:ft(i));for(;g.length&&jg(g)==null;)g.pop();return g.unshift(irt(e.gradient)),`gradient(${g.join(",")})`}function ix(e){return Wt(e)?"("+PO(e)+")":e}function nrt(e){return Irt(Wt(e)?e:{datum:e})}function Irt(e){let g,i,n;if(e.signal)g="datum",n=e.signal;else if(e.group||e.parent){for(i=Math.max(1,e.level||1),g="item";i-- >0;)g+=".mark.group";e.parent?(n=e.parent,g+=".datum"):n=e.group}else e.datum?(g="datum",n=e.datum):qe("Invalid field reference: "+ft(e));return e.signal||(n=Rt(n)?qc(n).map(ft).join("]["):Irt(n)),g+"["+n+"]"}function e$g(e,g){const i=irt(e.scale);return e.range!=null?g=`lerp(_range(${i}), ${+e.range})`:(g!==void 0&&(g=`_scale(${i}, ${g})`),e.band&&(g=(g?g+"+":"")+`_bandwidth(${i})`+(+e.band==1?"":"*"+ix(e.band)),e.extra&&(g=`(datum.extra ? _scale(${i}, datum.extra.value) : ${g})`)),g==null&&(g="0")),g}function t$g(e){let g="";return e.forEach(i=>{const n=PO(i);g+=i.test?`(${i.test})?${n}:`:n}),jg(g)===":"&&(g+="null"),g}function rrt(e,g,i,n,I,r){const o={};r=r||{},r.encoders={$encode:o},e=j4g(e,g,i,n,I.config);for(const C in e)o[C]=g$g(e[C],g,r,I);return r}function g$g(e,g,i,n){const I={},r={};for(const o in e)e[o]!=null&&(I[o]=n$g(i$g(e[o]),n,i,r));return{$expr:{marktype:g,channels:I},$fields:Object.keys(r),$output:Object.keys(e)}}function i$g(e){return et(e)?t$g(e):PO(e)}function n$g(e,g,i,n){const I=Ec(e,g);return I.$fields.forEach(r=>n[r]=1),vg(i,I.$params),I.$expr}const I$g="outer",r$g=["value","update","init","react","bind"];function ake(e,g){qe(e+' for "outer" push: '+ft(g))}function ort(e,g){const i=e.name;if(e.push===I$g)g.signals[i]||ake("No prior signal definition",i),r$g.forEach(n=>{e[n]!==void 0&&ake("Invalid property ",n)});else{const n=g.addSignal(i,e.value);e.react===!1&&(n.react=!1),e.bind&&g.addBinding(i,e.bind)}}function CIe(e,g,i,n){this.id=-1,this.type=e,this.value=g,this.params=i,n&&(this.parent=n)}function _O(e,g,i,n){return new CIe(e,g,i,n)}function c3(e,g){return _O("operator",e,g)}function qt(e){const g={$ref:e.id};return e.id<0&&(e.refs=e.refs||[]).push(g),g}function J9(e,g){return g?{$field:e,$name:g}:{$field:e}}const aIe=J9("key");function ske(e,g){return{$compare:e,$order:g}}function o$g(e,g){const i={$key:e};return g&&(i.$flat=!0),i}const C$g="ascending",a$g="descending";function s$g(e){return Wt(e)?(e.order===a$g?"-":"+")+OO(e.op,e.field):""}function OO(e,g){return(e&&e.signal?"$"+e.signal:e||"")+(e&&g?"_":"")+(g&&g.signal?"$"+g.signal:g||"")}const Nhe="scope",sIe="view";function BI(e){return e&&e.signal}function A$g(e){return e&&e.expr}function nx(e){if(BI(e))return!0;if(Wt(e)){for(const g in e)if(nx(e[g]))return!0}return!1}function rA(e,g){return e??g}function ob(e){return e&&e.signal||e}const Ake="timer";function L9(e,g){return(e.merge?c$g:e.stream?u$g:e.type?d$g:qe("Invalid stream specification: "+ft(e)))(e,g)}function l$g(e){return e===Nhe?sIe:e||sIe}function c$g(e,g){const i=e.merge.map(I=>L9(I,g)),n=khe({merge:i},e,g);return g.addStream(n).id}function u$g(e,g){const i=L9(e.stream,g),n=khe({stream:i},e,g);return g.addStream(n).id}function d$g(e,g){let i;e.type===Ake?(i=g.event(Ake,e.throttle),e={between:e.between,filter:e.filter}):i=g.event(l$g(e.source),e.type);const n=khe({stream:i},e,g);return Object.keys(n).length===1?i:g.addStream(n).id}function khe(e,g,i){let n=g.between;return n&&(n.length!==2&&qe('Stream "between" parameter must have 2 entries: '+ft(g)),e.between=[L9(n[0],i),L9(n[1],i)]),n=g.filter?[].concat(g.filter):[],(g.marktype||g.markname||g.markrole)&&n.push(h$g(g.marktype,g.markname,g.markrole)),g.source===Nhe&&n.push("inScope(event.item)"),n.length&&(e.filter=Ec("("+n.join(")&&(")+")",i).$expr),(n=g.throttle)!=null&&(e.throttle=+n),(n=g.debounce)!=null&&(e.debounce=+n),g.consume&&(e.consume=!0),e}function h$g(e,g,i){const n="event.item";return n+(e&&e!=="*"?"&&"+n+".mark.marktype==='"+e+"'":"")+(i?"&&"+n+".mark.role==='"+i+"'":"")+(g?"&&"+n+".mark.name==='"+g+"'":"")}const f$g={code:"_.$value",ast:{type:"Identifier",value:"value"}};function m$g(e,g,i){const n=e.encode,I={target:i};let r=e.events,o=e.update,C=[];r||qe("Signal update missing events specification."),Rt(r)&&(r=Cp(r,g.isSubscope()?Nhe:sIe)),r=Vt(r).filter(a=>a.signal||a.scale?(C.push(a),0):1),C.length>1&&(C=[b$g(C)]),r.length&&C.push(r.length>1?{merge:r}:r[0]),n!=null&&(o&&qe("Signal encode and update are mutually exclusive."),o="encode(item(),"+ft(n)+")"),I.update=Rt(o)?Ec(o,g):o.expr!=null?Ec(o.expr,g):o.value!=null?o.value:o.signal!=null?{$expr:f$g,$params:{$value:g.signalRef(o.signal)}}:qe("Invalid signal update specification."),e.force&&(I.options={force:!0}),C.forEach(a=>g.addUpdate(vg(p$g(a,g),I)))}function p$g(e,g){return{source:e.signal?g.signalRef(e.signal):e.scale?g.scaleRef(e.scale):L9(e,g)}}function b$g(e){return{signal:"["+e.map(g=>g.scale?'scale("'+g.scale+'")':g.signal)+"]"}}function y$g(e,g){const i=g.getSignal(e.name);let n=e.update;e.init&&(n?qe("Signals can not include both init and update expressions."):(n=e.init,i.initonly=!0)),n&&(n=Ec(n,g),i.update=n.$expr,i.params=n.$params),e.on&&e.on.forEach(I=>m$g(I,g,i.id))}const Wi=e=>(g,i,n)=>_O(e,i,g||void 0,n),Crt=Wi("aggregate"),Z$g=Wi("axisticks"),art=Wi("bound"),Cl=Wi("collect"),lke=Wi("compare"),G$g=Wi("datajoin"),srt=Wi("encode"),v$g=Wi("expression"),B$g=Wi("facet"),w$g=Wi("field"),S$g=Wi("key"),R$g=Wi("legendentries"),V$g=Wi("load"),W$g=Wi("mark"),X$g=Wi("multiextent"),T$g=Wi("multivalues"),H$g=Wi("overlap"),N$g=Wi("params"),Art=Wi("prefacet"),k$g=Wi("projection"),Y$g=Wi("proxy"),K$g=Wi("relay"),lrt=Wi("render"),x$g=Wi("scale"),yZ=Wi("sieve"),F$g=Wi("sortitems"),crt=Wi("viewlayout"),E$g=Wi("values");let D$g=0;const urt={min:"min",max:"max",count:"sum"};function M$g(e,g){const i=e.type||"linear";Ltt(i)||qe("Unrecognized scale type: "+ft(i)),g.addScale(e.name,{type:i,domain:void 0})}function z$g(e,g){const i=g.getScale(e.name).params;let n;i.domain=drt(e.domain,e,g),e.range!=null&&(i.range=frt(e,g,i)),e.interpolate!=null&&q$g(e.interpolate,i),e.nice!=null&&(i.nice=$$g(e.nice)),e.bins!=null&&(i.bins=j$g(e.bins,g));for(n in e)gg(i,n)||n==="name"||(i[n]=is(e[n],g))}function is(e,g){return Wt(e)?e.signal?g.signalRef(e.signal):qe("Unsupported object: "+ft(e)):e}function Ix(e,g){return e.signal?g.signalRef(e.signal):e.map(i=>is(i,g))}function JO(e){qe("Can not find data set: "+ft(e))}function drt(e,g,i){if(!e){(g.domainMin!=null||g.domainMax!=null)&&qe("No scale domain defined for domainMin/domainMax to override.");return}return e.signal?i.signalRef(e.signal):(et(e)?P$g:e.fields?O$g:_$g)(e,g,i)}function P$g(e,g,i){return e.map(n=>is(n,i))}function _$g(e,g,i){const n=i.getData(e.data);return n||JO(e.data),Ow(g.type)?n.valuesRef(i,e.field,hrt(e.sort,!1)):jtt(g.type)?n.domainRef(i,e.field):n.extentRef(i,e.field)}function O$g(e,g,i){const n=e.data,I=e.fields.reduce((r,o)=>(o=Rt(o)?{data:n,field:o}:et(o)||o.signal?J$g(o,i):o,r.push(o),r),[]);return(Ow(g.type)?L$g:jtt(g.type)?U$g:Q$g)(e,i,I)}function J$g(e,g){const i="_:vega:_"+D$g++,n=Cl({});if(et(e))n.value={$ingest:e};else if(e.signal){const I="setdata("+ft(i)+","+e.signal+")";n.params.input=g.signalRef(I)}return g.addDataPipeline(i,[n,yZ({})]),{data:i,field:"data"}}function L$g(e,g,i){const n=hrt(e.sort,!0);let I,r;const o=i.map(A=>{const s=g.getData(A.data);return s||JO(A.data),s.countsRef(g,A.field,n)}),C={groupby:aIe,pulse:o};n&&(I=n.op||"count",r=n.field?OO(I,n.field):"count",C.ops=[urt[I]],C.fields=[g.fieldRef(r)],C.as=[r]),I=g.add(Crt(C));const a=g.add(Cl({pulse:qt(I)}));return r=g.add(E$g({field:aIe,sort:g.sortRef(n),pulse:qt(a)})),qt(r)}function hrt(e,g){return e&&(!e.field&&!e.op?Wt(e)?e.field="key":e={field:"key"}:!e.field&&e.op!=="count"?qe("No field provided for sort aggregate op: "+e.op):g&&e.field&&e.op&&!urt[e.op]&&qe("Multiple domain scales can not be sorted using "+e.op)),e}function U$g(e,g,i){const n=i.map(I=>{const r=g.getData(I.data);return r||JO(I.data),r.domainRef(g,I.field)});return qt(g.add(T$g({values:n})))}function Q$g(e,g,i){const n=i.map(I=>{const r=g.getData(I.data);return r||JO(I.data),r.extentRef(g,I.field)});return qt(g.add(X$g({extents:n})))}function j$g(e,g){return e.signal||et(e)?Ix(e,g):g.objectProperty(e)}function $$g(e){return Wt(e)?{interval:is(e.interval),step:is(e.step)}:is(e)}function q$g(e,g){g.interpolate=is(e.type||e),e.gamma!=null&&(g.interpolateGamma=is(e.gamma))}function frt(e,g,i){const n=g.config.range;let I=e.range;if(I.signal)return g.signalRef(I.signal);if(Rt(I)){if(n&&gg(n,I))return e=vg({},e,{range:n[I]}),frt(e,g,i);I==="width"?I=[0,{signal:"width"}]:I==="height"?I=Ow(e.type)?[0,{signal:"height"}]:[{signal:"height"},0]:qe("Unrecognized scale range value: "+ft(I))}else if(I.scheme){i.scheme=et(I.scheme)?Ix(I.scheme,g):is(I.scheme,g),I.extent&&(i.schemeExtent=Ix(I.extent,g)),I.count&&(i.schemeCount=is(I.count,g));return}else if(I.step){i.rangeStep=is(I.step,g);return}else{if(Ow(e.type)&&!et(I))return drt(I,e,g);et(I)||qe("Unsupported range type: "+ft(I))}return I.map(r=>(et(r)?Ix:is)(r,g))}function e8g(e,g){const i=g.config.projection||{},n={};for(const I in e)I!=="name"&&(n[I]=AIe(e[I],I,g));for(const I in i)n[I]==null&&(n[I]=AIe(i[I],I,g));g.addProjection(e.name,n)}function AIe(e,g,i){return et(e)?e.map(n=>AIe(n,g,i)):Wt(e)?e.signal?i.signalRef(e.signal):g==="fit"?e:qe("Unsupported parameter object: "+ft(e)):e}const al="top",vS="left",BS="right",wm="bottom",mrt="center",t8g="vertical",g8g="start",i8g="middle",n8g="end",lIe="index",Yhe="label",I8g="offset",g1="perc",r8g="perc2",as="value",tN="guide-label",Khe="guide-title",o8g="group-title",C8g="group-subtitle",cke="symbol",rx="gradient",cIe="discrete",uIe="size",a8g="shape",s8g="fill",A8g="stroke",l8g="strokeWidth",c8g="strokeDash",u8g="opacity",xhe=[uIe,a8g,s8g,A8g,l8g,c8g,u8g],gN={name:1,style:1,interactive:1},ti={value:0},ss={value:1},LO="group",prt="rect",Fhe="rule",d8g="symbol",ZZ="text";function U9(e){return e.type=LO,e.interactive=e.interactive||!1,e}function _C(e,g){const i=(n,I)=>rA(e[n],rA(g[n],I));return i.isVertical=n=>t8g===rA(e.direction,g.direction||(n?g.symbolDirection:g.gradientDirection)),i.gradientLength=()=>rA(e.gradientLength,g.gradientLength||g.gradientWidth),i.gradientThickness=()=>rA(e.gradientThickness,g.gradientThickness||g.gradientHeight),i.entryColumns=()=>rA(e.columns,rA(g.columns,+i.isVertical(!0))),i}function brt(e,g){const i=g&&(g.update&&g.update[e]||g.enter&&g.enter[e]);return i&&i.signal?i:i?i.value:null}function h8g(e,g,i){const n=g.config.style[i];return n&&n[e]}function UO(e,g,i){return`item.anchor === '${g8g}' ? ${e} : item.anchor === '${n8g}' ? ${g} : ${i}`}const Ehe=UO(ft(vS),ft(BS),ft(mrt));function f8g(e){const g=e("tickBand");let i=e("tickOffset"),n,I;return g?g.signal?(n={signal:`(${g.signal}) === 'extent' ? 1 : 0.5`},I={signal:`(${g.signal}) === 'extent'`},Wt(i)||(i={signal:`(${g.signal}) === 'extent' ? 0 : ${i}`})):g==="extent"?(n=1,I=!0,i=0):(n=.5,I=!1):(n=e("bandPosition"),I=e("tickExtra")),{extra:I,band:n,offset:i}}function yrt(e,g){return g?e?Wt(e)?Object.assign({},e,{offset:yrt(e.offset,g)}):{value:e,offset:g}:g:e}function Ga(e,g){return g?(e.name=g.name,e.style=g.style||e.style,e.interactive=!!g.interactive,e.encode=GS(e.encode,g,gN)):e.interactive=!1,e}function m8g(e,g,i,n){const I=_C(e,i),r=I.isVertical(),o=I.gradientThickness(),C=I.gradientLength();let a,A,s,l,c;r?(A=[0,1],s=[0,0],l=o,c=C):(A=[0,0],s=[1,0],l=C,c=o);const u={enter:a={opacity:ti,x:ti,y:ti,width:MI(l),height:MI(c)},update:vg({},a,{opacity:ss,fill:{gradient:g,start:A,stop:s}}),exit:{opacity:ti}};return yr(u,{stroke:I("gradientStrokeColor"),strokeWidth:I("gradientStrokeWidth")},{opacity:I("gradientOpacity")}),Ga({type:prt,role:_4g,encode:u},n)}function p8g(e,g,i,n,I){const r=_C(e,i),o=r.isVertical(),C=r.gradientThickness(),a=r.gradientLength();let A,s,l,c,u="";o?(A="y",l="y2",s="x",c="width",u="1-"):(A="x",l="x2",s="y",c="height");const d={opacity:ti,fill:{scale:g,field:as}};d[A]={signal:u+"datum."+g1,mult:a},d[s]=ti,d[l]={signal:u+"datum."+r8g,mult:a},d[c]=MI(C);const h={enter:d,update:vg({},d,{opacity:ss}),exit:{opacity:ti}};return yr(h,{stroke:r("gradientStrokeColor"),strokeWidth:r("gradientStrokeWidth")},{opacity:r("gradientOpacity")}),Ga({type:prt,role:z4g,key:as,from:I,encode:h},n)}const b8g=`datum.${g1}<=0?"${vS}":datum.${g1}>=1?"${BS}":"${mrt}"`,y8g=`datum.${g1}<=0?"${wm}":datum.${g1}>=1?"${al}":"${i8g}"`;function uke(e,g,i,n){const I=_C(e,g),r=I.isVertical(),o=MI(I.gradientThickness()),C=I.gradientLength();let a=I("labelOverlap"),A,s,l,c,u="";const d={enter:A={opacity:ti},update:s={opacity:ss,text:{field:Yhe}},exit:{opacity:ti}};return yr(d,{fill:I("labelColor"),fillOpacity:I("labelOpacity"),font:I("labelFont"),fontSize:I("labelFontSize"),fontStyle:I("labelFontStyle"),fontWeight:I("labelFontWeight"),limit:rA(e.labelLimit,g.gradientLabelLimit)}),r?(A.align={value:"left"},A.baseline=s.baseline={signal:y8g},l="y",c="x",u="1-"):(A.align=s.align={signal:b8g},A.baseline={value:"top"},l="x",c="y"),A[l]=s[l]={signal:u+"datum."+g1,mult:C},A[c]=s[c]=o,o.offset=rA(e.labelOffset,g.gradientLabelOffset)||0,a=a?{separation:I("labelSeparation"),method:a,order:"datum."+lIe}:void 0,Ga({type:ZZ,role:grt,style:tN,key:as,from:n,encode:d,overlap:a},i)}function Z8g(e,g,i,n,I){const r=_C(e,g),o=i.entries,C=!!(o&&o.interactive),a=o?o.name:void 0,A=r("clipHeight"),s=r("symbolOffset"),l={data:"value"},c=`(${I}) ? datum.${I8g} : datum.${uIe}`,u=A?MI(A):{field:uIe},d=`datum.${lIe}`,h=`max(1, ${I})`;let f,m,b,p,y;u.mult=.5,f={enter:m={opacity:ti,x:{signal:c,mult:.5,offset:s},y:u},update:b={opacity:ss,x:m.x,y:m.y},exit:{opacity:ti}};let Z=null,v=null;e.fill||(Z=g.symbolBaseFillColor,v=g.symbolBaseStrokeColor),yr(f,{fill:r("symbolFillColor",Z),shape:r("symbolType"),size:r("symbolSize"),stroke:r("symbolStrokeColor",v),strokeDash:r("symbolDash"),strokeDashOffset:r("symbolDashOffset"),strokeWidth:r("symbolStrokeWidth")},{opacity:r("symbolOpacity")}),xhe.forEach(R=>{e[R]&&(b[R]=m[R]={scale:e[R],field:as})});const G=Ga({type:d8g,role:O4g,key:as,from:l,clip:A?!0:void 0,encode:f},i.symbols),B=MI(s);B.offset=r("labelOffset"),f={enter:m={opacity:ti,x:{signal:c,offset:B},y:u},update:b={opacity:ss,text:{field:Yhe},x:m.x,y:m.y},exit:{opacity:ti}},yr(f,{align:r("labelAlign"),baseline:r("labelBaseline"),fill:r("labelColor"),fillOpacity:r("labelOpacity"),font:r("labelFont"),fontSize:r("labelFontSize"),fontStyle:r("labelFontStyle"),fontWeight:r("labelFontWeight"),limit:r("labelLimit")});const S=Ga({type:ZZ,role:grt,style:tN,key:as,from:l,encode:f},i.labels);return f={enter:{noBound:{value:!A},width:ti,height:A?MI(A):ti,opacity:ti},exit:{opacity:ti},update:b={opacity:ss,row:{signal:null},column:{signal:null}}},r.isVertical(!0)?(p=`ceil(item.mark.items.length / ${h})`,b.row.signal=`${d}%${p}`,b.column.signal=`floor(${d} / ${p})`,y={field:["row",d]}):(b.row.signal=`floor(${d} / ${h})`,b.column.signal=`${d} % ${h}`,y={field:d}),b.column.signal=`(${I})?${b.column.signal}:${d}`,n={facet:{data:n,name:"value",groupby:lIe}},U9({role:Hhe,from:n,encode:GS(f,o,gN),marks:[G,S],name:a,interactive:C,sort:y})}function G8g(e,g){const i=_C(e,g);return{align:i("gridAlign"),columns:i.entryColumns(),center:{row:!0,column:!1},padding:{row:i("rowPadding"),column:i("columnPadding")}}}const Dhe='item.orient === "left"',Mhe='item.orient === "right"',QO=`(${Dhe} || ${Mhe})`,v8g=`datum.vgrad && ${QO}`,B8g=UO('"top"','"bottom"','"middle"'),w8g=UO('"right"','"left"','"center"'),S8g=`datum.vgrad && ${Mhe} ? (${w8g}) : (${QO} && !(datum.vgrad && ${Dhe})) ? "left" : ${Ehe}`,R8g=`item._anchor || (${QO} ? "middle" : "start")`,V8g=`${v8g} ? (${Dhe} ? -90 : 90) : 0`,W8g=`${QO} ? (datum.vgrad ? (${Mhe} ? "bottom" : "top") : ${B8g}) : "top"`;function X8g(e,g,i,n){const I=_C(e,g),r={enter:{opacity:ti},update:{opacity:ss,x:{field:{group:"padding"}},y:{field:{group:"padding"}}},exit:{opacity:ti}};return yr(r,{orient:I("titleOrient"),_anchor:I("titleAnchor"),anchor:{signal:R8g},angle:{signal:V8g},align:{signal:S8g},baseline:{signal:W8g},text:e.title,fill:I("titleColor"),fillOpacity:I("titleOpacity"),font:I("titleFont"),fontSize:I("titleFontSize"),fontStyle:I("titleFontStyle"),fontWeight:I("titleFontWeight"),limit:I("titleLimit"),lineHeight:I("titleLineHeight")},{align:I("titleAlign"),baseline:I("titleBaseline")}),Ga({type:ZZ,role:J4g,style:Khe,from:n,encode:r},i)}function T8g(e,g){let i;return Wt(e)&&(e.signal?i=e.signal:e.path?i="pathShape("+dke(e.path)+")":e.sphere&&(i="geoShape("+dke(e.sphere)+', {type: "Sphere"})')),i?g.signalRef(i):!!e}function dke(e){return Wt(e)&&e.signal?e.signal:ft(e)}function Zrt(e){const g=e.role||"";return!g.indexOf("axis")||!g.indexOf("legend")||!g.indexOf("title")?g:e.type===LO?Hhe:g||Xhe}function H8g(e){return{marktype:e.type,name:e.name||void 0,role:e.role||Zrt(e),zindex:+e.zindex||void 0,aria:e.aria,description:e.description}}function N8g(e,g){return e&&e.signal?g.signalRef(e.signal):e!==!1}function zhe(e,g){const i=Lqe(e.type);i||qe("Unrecognized transform type: "+ft(e.type));const n=_O(i.type.toLowerCase(),null,Grt(i,e,g));return e.signal&&g.addSignal(e.signal,g.proxy(n)),n.metadata=i.metadata||{},n}function Grt(e,g,i){const n={},I=e.params.length;for(let r=0;rhke(e,r,i)):hke(e,I,i)}function hke(e,g,i){const n=e.type;if(BI(g))return mke(n)?qe("Expression references can not be signals."):K4(n)?i.fieldRef(g):pke(n)?i.compareRef(g):i.signalRef(g.signal);{const I=e.expr||K4(n);return I&&x8g(g)?i.exprRef(g.expr,g.as):I&&F8g(g)?J9(g.field,g.as):mke(n)?Ec(g,i):E8g(n)?qt(i.getData(g).values):K4(n)?J9(g):pke(n)?i.compareRef(g):g}}function Y8g(e,g,i){return Rt(g.from)||qe('Lookup "from" parameter must be a string literal.'),i.getData(g.from).lookupRef(i,g.key)}function K8g(e,g,i){const n=g[e.name];return e.array?(et(n)||qe("Expected an array of sub-parameters. Instead: "+ft(n)),n.map(I=>fke(e,I,i))):fke(e,n,i)}function fke(e,g,i){const n=e.params.length;let I;for(let o=0;oe&&e.expr,F8g=e=>e&&e.field,E8g=e=>e==="data",mke=e=>e==="expr",K4=e=>e==="field",pke=e=>e==="compare";function D8g(e,g,i){let n,I,r,o,C;return e?(n=e.facet)&&(g||qe("Only group marks can be faceted."),n.field!=null?o=C=ox(n,i):(e.data?C=qt(i.getData(e.data).aggregate):(r=zhe(vg({type:"aggregate",groupby:Vt(n.groupby)},n.aggregate),i),r.params.key=i.keyRef(n.groupby),r.params.pulse=ox(n,i),o=C=qt(i.add(r))),I=i.keyRef(n.groupby,!0))):o=qt(i.add(Cl(null,[{}]))),o||(o=ox(e,i)),{key:I,pulse:o,parent:C}}function ox(e,g){return e.$ref?e:e.data&&e.data.$ref?e.data:qt(g.getData(e.data).output)}function by(e,g,i,n,I){this.scope=e,this.input=g,this.output=i,this.values=n,this.aggregate=I,this.index={}}by.fromEntries=function(e,g){const i=g.length,n=g[i-1],I=g[i-2];let r=g[0],o=null,C=1;for(r&&r.type==="load"&&(r=g[1]),e.add(g[0]);Cl??"null").join(",")+"),0)",s=Ec(A,g);a.update=s.$expr,a.params=s.$params}function jO(e,g){const i=Zrt(e),n=e.type===LO,I=e.from&&e.from.facet,r=e.overlap;let o=e.layout||i===Hhe||i===The,C,a,A,s,l,c,u;const d=i===Xhe||o||I,h=D8g(e.from,n,g);a=g.add(G$g({key:h.key||(e.key?J9(e.key):void 0),pulse:h.pulse,clean:!n}));const f=qt(a);a=A=g.add(Cl({pulse:f})),a=g.add(W$g({markdef:H8g(e),interactive:N8g(e.interactive,g),clip:T8g(e.clip,g),context:{$context:!0},groups:g.lookup(),parent:g.signals.parent?g.signalRef("parent"):null,index:g.markpath(),pulse:qt(a)}));const m=qt(a);a=s=g.add(srt(rrt(e.encode,e.type,i,e.style,g,{mod:!1,pulse:m}))),a.params.parent=g.encode(),e.transform&&e.transform.forEach(v=>{const G=zhe(v,g),B=G.metadata;(B.generates||B.changes)&&qe("Mark transforms should not generate new data."),B.nomod||(s.params.mod=!0),G.params.pulse=qt(a),g.add(a=G)}),e.sort&&(a=g.add(F$g({sort:g.compareRef(e.sort),pulse:qt(a)})));const b=qt(a);(I||o)&&(o=g.add(crt({layout:g.objectProperty(e.layout),legends:g.legends,mark:m,pulse:b})),c=qt(o));const p=g.add(art({mark:m,pulse:c||b}));u=qt(p),n&&(d&&(C=g.operators,C.pop(),o&&C.pop()),g.pushState(b,c||u,f),I?M8g(e,g,h):d?z8g(e,g,h):g.parse(e),g.popState(),d&&(o&&C.push(o),C.push(p))),r&&(u=P8g(r,u,g));const y=g.add(lrt({pulse:u})),Z=g.add(yZ({pulse:qt(y)},void 0,g.parent()));e.name!=null&&(l=e.name,g.addData(l,new by(g,A,y,Z)),e.on&&e.on.forEach(v=>{(v.insert||v.remove||v.toggle)&&qe("Marks only support modify triggers."),Brt(v,g,l)}))}function P8g(e,g,i){const n=e.method,I=e.bound,r=e.separation,o={separation:BI(r)?i.signalRef(r.signal):r,method:BI(n)?i.signalRef(n.signal):n,pulse:g};if(e.order&&(o.sort=i.compareRef({field:e.order})),I){const C=I.tolerance;o.boundTolerance=BI(C)?i.signalRef(C.signal):+C,o.boundScale=i.scaleRef(I.scale),o.boundOrient=I.orient}return qt(i.add(H$g(o)))}function _8g(e,g){const i=g.config.legend,n=e.encode||{},I=_C(e,i),r=n.legend||{},o=r.name||void 0,C=r.interactive,a=r.style,A={};let s=0,l,c,u;xhe.forEach(p=>e[p]?(A[p]=e[p],s=s||e[p]):0),s||qe("Missing valid scale for legend.");const d=O8g(e,g.scaleType(s)),h={title:e.title!=null,scales:A,type:d,vgrad:d!=="symbol"&&I.isVertical()},f=qt(g.add(Cl(null,[h]))),m={enter:{x:{value:0},y:{value:0}}},b=qt(g.add(R$g(c={type:d,scale:g.scaleRef(s),count:g.objectProperty(I("tickCount")),limit:g.property(I("symbolLimit")),values:g.objectProperty(e.values),minstep:g.property(e.tickMinStep),formatType:g.property(e.formatType),formatSpecifier:g.property(e.format)})));return d===rx?(u=[m8g(e,s,i,n.gradient),uke(e,i,n.labels,b)],c.count=c.count||g.signalRef(`max(2,2*floor((${ob(I.gradientLength())})/100))`)):d===cIe?u=[p8g(e,s,i,n.gradient,b),uke(e,i,n.labels,b)]:(l=G8g(e,i),u=[Z8g(e,i,n,b,ob(l.columns))],c.size=U8g(e,g,u[0].marks)),u=[U9({role:P4g,from:f,encode:m,marks:u,layout:l,interactive:C})],h.title&&u.push(X8g(e,i,n.title,f)),jO(U9({role:M4g,from:f,encode:GS(L8g(I,e,i),r,gN),marks:u,aria:I("aria"),description:I("description"),zindex:I("zindex"),name:o,interactive:C,style:a}),g)}function O8g(e,g){let i=e.type||cke;return!e.type&&J8g(e)===1&&(e.fill||e.stroke)&&(i=kue(g)?rx:nne(g)?cIe:cke),i!==rx?i:nne(g)?cIe:rx}function J8g(e){return xhe.reduce((g,i)=>g+(e[i]?1:0),0)}function L8g(e,g,i){const n={enter:{},update:{}};return yr(n,{orient:e("orient"),offset:e("offset"),padding:e("padding"),titlePadding:e("titlePadding"),cornerRadius:e("cornerRadius"),fill:e("fillColor"),stroke:e("strokeColor"),strokeWidth:i.strokeWidth,strokeDash:i.strokeDash,x:e("legendX"),y:e("legendY"),format:g.format,formatType:g.formatType}),n}function U8g(e,g,i){const n=ob(yke("size",e,i)),I=ob(yke("strokeWidth",e,i)),r=ob(Q8g(i[1].encode,g,tN));return Ec(`max(ceil(sqrt(${n})+${I}),${r})`,g)}function yke(e,g,i){return g[e]?`scale("${g[e]}",datum)`:brt(e,i[0].encode)}function Q8g(e,g,i){return brt("fontSize",e)||h8g("fontSize",g,i)}const j8g=`item.orient==="${vS}"?-90:item.orient==="${BS}"?90:0`;function $8g(e,g){e=Rt(e)?{text:e}:e;const i=_C(e,g.config.title),n=e.encode||{},I=n.group||{},r=I.name||void 0,o=I.interactive,C=I.style,a=[],A={},s=qt(g.add(Cl(null,[A])));return a.push(t6g(e,i,q8g(e),s)),e.subtitle&&a.push(g6g(e,i,n.subtitle,s)),jO(U9({role:L4g,from:s,encode:e6g(i,I),marks:a,aria:i("aria"),description:i("description"),zindex:i("zindex"),name:r,interactive:o,style:C}),g)}function q8g(e){const g=e.encode;return g&&g.title||vg({name:e.name,interactive:e.interactive,style:e.style},g)}function e6g(e,g){const i={enter:{},update:{}};return yr(i,{orient:e("orient"),anchor:e("anchor"),align:{signal:Ehe},angle:{signal:j8g},limit:e("limit"),frame:e("frame"),offset:e("offset")||0,padding:e("subtitlePadding")}),GS(i,g,gN)}function t6g(e,g,i,n){const I={value:0},r=e.text,o={enter:{opacity:I},update:{opacity:{value:1}},exit:{opacity:I}};return yr(o,{text:r,align:{signal:"item.mark.group.align"},angle:{signal:"item.mark.group.angle"},limit:{signal:"item.mark.group.limit"},baseline:"top",dx:g("dx"),dy:g("dy"),fill:g("color"),font:g("font"),fontSize:g("fontSize"),fontStyle:g("fontStyle"),fontWeight:g("fontWeight"),lineHeight:g("lineHeight")},{align:g("align"),angle:g("angle"),baseline:g("baseline")}),Ga({type:ZZ,role:U4g,style:o8g,from:n,encode:o},i)}function g6g(e,g,i,n){const I={value:0},r=e.subtitle,o={enter:{opacity:I},update:{opacity:{value:1}},exit:{opacity:I}};return yr(o,{text:r,align:{signal:"item.mark.group.align"},angle:{signal:"item.mark.group.angle"},limit:{signal:"item.mark.group.limit"},baseline:"top",dx:g("dx"),dy:g("dy"),fill:g("subtitleColor"),font:g("subtitleFont"),fontSize:g("subtitleFontSize"),fontStyle:g("subtitleFontStyle"),fontWeight:g("subtitleFontWeight"),lineHeight:g("subtitleLineHeight")},{align:g("align"),angle:g("angle"),baseline:g("baseline")}),Ga({type:ZZ,role:Q4g,style:C8g,from:n,encode:o},i)}function i6g(e,g){const i=[];e.transform&&e.transform.forEach(n=>{i.push(zhe(n,g))}),e.on&&e.on.forEach(n=>{Brt(n,g,e.name)}),g.addDataPipeline(e.name,n6g(e,g,i))}function n6g(e,g,i){const n=[];let I=null,r=!1,o=!1,C,a,A,s,l;for(e.values?BI(e.values)||nx(e.format)?(n.push(Zke(g,e)),n.push(I=Kp())):n.push(I=Kp({$ingest:e.values,$format:e.format})):e.url?nx(e.url)||nx(e.format)?(n.push(Zke(g,e)),n.push(I=Kp())):n.push(I=Kp({$request:e.url,$format:e.format})):e.source&&(I=C=Vt(e.source).map(c=>qt(g.getData(c).output)),n.push(null)),a=0,A=i.length;ae===wm||e===al,$O=(e,g,i)=>BI(e)?C6g(e.signal,g,i):e===vS||e===al?g:i,zI=(e,g,i)=>BI(e)?r6g(e.signal,g,i):wrt(e)?g:i,FA=(e,g,i)=>BI(e)?o6g(e.signal,g,i):wrt(e)?i:g,Srt=(e,g,i)=>BI(e)?a6g(e.signal,g,i):e===al?{value:g}:{value:i},I6g=(e,g,i)=>BI(e)?s6g(e.signal,g,i):e===BS?{value:g}:{value:i},r6g=(e,g,i)=>Rrt(`${e} === '${al}' || ${e} === '${wm}'`,g,i),o6g=(e,g,i)=>Rrt(`${e} !== '${al}' && ${e} !== '${wm}'`,g,i),C6g=(e,g,i)=>Phe(`${e} === '${vS}' || ${e} === '${al}'`,g,i),a6g=(e,g,i)=>Phe(`${e} === '${al}'`,g,i),s6g=(e,g,i)=>Phe(`${e} === '${BS}'`,g,i),Rrt=(e,g,i)=>(g=g!=null?MI(g):g,i=i!=null?MI(i):i,Gke(g)&&Gke(i)?(g=g?g.signal||ft(g.value):null,i=i?i.signal||ft(i.value):null,{signal:`${e} ? (${g}) : (${i})`}):[vg({test:e},g)].concat(i||[])),Gke=e=>e==null||Object.keys(e).length===1,Phe=(e,g,i)=>({signal:`${e} ? (${Sv(g)}) : (${Sv(i)})`}),A6g=(e,g,i,n,I)=>({signal:(n!=null?`${e} === '${vS}' ? (${Sv(n)}) : `:"")+(i!=null?`${e} === '${wm}' ? (${Sv(i)}) : `:"")+(I!=null?`${e} === '${BS}' ? (${Sv(I)}) : `:"")+(g!=null?`${e} === '${al}' ? (${Sv(g)}) : `:"")+"(null)"}),Sv=e=>BI(e)?e.signal:e==null?null:ft(e),l6g=(e,g)=>g===0?0:BI(e)?{signal:`(${e.signal}) * ${g}`}:{value:e*g},hB=(e,g)=>{const i=e.signal;return i&&i.endsWith("(null)")?{signal:i.slice(0,-6)+g.signal}:e};function bG(e,g,i,n){let I;if(g&&gg(g,e))return g[e];if(gg(i,e))return i[e];if(e.startsWith("title")){switch(e){case"titleColor":I="fill";break;case"titleFont":case"titleFontSize":case"titleFontWeight":I=e[5].toLowerCase()+e.slice(6)}return n[Khe][I]}else if(e.startsWith("label")){switch(e){case"labelColor":I="fill";break;case"labelFont":case"labelFontSize":I=e[5].toLowerCase()+e.slice(6)}return n[tN][I]}return null}function vke(e){const g={};for(const i of e)if(i)for(const n in i)g[n]=1;return Object.keys(g)}function c6g(e,g){var i=g.config,n=i.style,I=i.axis,r=g.scaleType(e.scale)==="band"&&i.axisBand,o=e.orient,C,a,A;if(BI(o)){const l=vke([i.axisX,i.axisY]),c=vke([i.axisTop,i.axisBottom,i.axisLeft,i.axisRight]);C={};for(A of l)C[A]=zI(o,bG(A,i.axisX,I,n),bG(A,i.axisY,I,n));a={};for(A of c)a[A]=A6g(o.signal,bG(A,i.axisTop,I,n),bG(A,i.axisBottom,I,n),bG(A,i.axisLeft,I,n),bG(A,i.axisRight,I,n))}else C=o===al||o===wm?i.axisX:i.axisY,a=i["axis"+o[0].toUpperCase()+o.slice(1)];return C||a||r?vg({},I,C,a,r):I}function u6g(e,g,i,n){const I=_C(e,g),r=e.orient;let o,C;const a={enter:o={opacity:ti},update:C={opacity:ss},exit:{opacity:ti}};yr(a,{stroke:I("domainColor"),strokeCap:I("domainCap"),strokeDash:I("domainDash"),strokeDashOffset:I("domainDashOffset"),strokeWidth:I("domainWidth"),strokeOpacity:I("domainOpacity")});const A=Bke(e,0),s=Bke(e,1);return o.x=C.x=zI(r,A,ti),o.x2=C.x2=zI(r,s),o.y=C.y=FA(r,A,ti),o.y2=C.y2=FA(r,s),Ga({type:Fhe,role:K4g,from:n,encode:a},i)}function Bke(e,g){return{scale:e.scale,range:g}}function d6g(e,g,i,n,I){const r=_C(e,g),o=e.orient,C=e.gridScale,a=$O(o,1,-1),A=h6g(e.offset,a);let s,l,c;const u={enter:s={opacity:ti},update:c={opacity:ss},exit:l={opacity:ti}};yr(u,{stroke:r("gridColor"),strokeCap:r("gridCap"),strokeDash:r("gridDash"),strokeDashOffset:r("gridDashOffset"),strokeOpacity:r("gridOpacity"),strokeWidth:r("gridWidth")});const d={scale:e.scale,field:as,band:I.band,extra:I.extra,offset:I.offset,round:r("tickRound")},h=zI(o,{signal:"height"},{signal:"width"}),f=C?{scale:C,range:0,mult:a,offset:A}:{value:0,offset:A},m=C?{scale:C,range:1,mult:a,offset:A}:vg(h,{mult:a,offset:A});return s.x=c.x=zI(o,d,f),s.y=c.y=FA(o,d,f),s.x2=c.x2=FA(o,m),s.y2=c.y2=zI(o,m),l.x=zI(o,d),l.y=FA(o,d),Ga({type:Fhe,role:x4g,key:as,from:n,encode:u},i)}function h6g(e,g){if(g!==1)if(!Wt(e))e=BI(g)?{signal:`(${g.signal}) * (${e||0})`}:g*(e||0);else{let i=e=vg({},e);for(;i.mult!=null;)if(Wt(i.mult))i=i.mult=vg({},i.mult);else return i.mult=BI(g)?{signal:`(${i.mult}) * (${g.signal})`}:i.mult*g,e;i.mult=g}return e}function f6g(e,g,i,n,I,r){const o=_C(e,g),C=e.orient,a=$O(C,-1,1);let A,s,l;const c={enter:A={opacity:ti},update:l={opacity:ss},exit:s={opacity:ti}};yr(c,{stroke:o("tickColor"),strokeCap:o("tickCap"),strokeDash:o("tickDash"),strokeDashOffset:o("tickDashOffset"),strokeOpacity:o("tickOpacity"),strokeWidth:o("tickWidth")});const u=MI(I);u.mult=a;const d={scale:e.scale,field:as,band:r.band,extra:r.extra,offset:r.offset,round:o("tickRound")};return l.y=A.y=zI(C,ti,d),l.y2=A.y2=zI(C,u),s.x=zI(C,d),l.x=A.x=FA(C,ti,d),l.x2=A.x2=FA(C,u),s.y=FA(C,d),Ga({type:Fhe,role:E4g,key:as,from:n,encode:c},i)}function x4(e,g,i,n,I){return{signal:'flush(range("'+e+'"), scale("'+e+'", datum.value), '+g+","+i+","+n+","+I+")"}}function m6g(e,g,i,n,I,r){const o=_C(e,g),C=e.orient,a=e.scale,A=$O(C,-1,1),s=ob(o("labelFlush")),l=ob(o("labelFlushOffset")),c=o("labelAlign"),u=o("labelBaseline");let d=s===0||!!s,h;const f=MI(I);f.mult=A,f.offset=MI(o("labelPadding")||0),f.offset.mult=A;const m={scale:a,field:as,band:.5,offset:yrt(r.offset,o("labelOffset"))},b=zI(C,d?x4(a,s,'"left"','"right"','"center"'):{value:"center"},I6g(C,"left","right")),p=zI(C,Srt(C,"bottom","top"),d?x4(a,s,'"top"','"bottom"','"middle"'):{value:"middle"}),y=x4(a,s,`-(${l})`,l,0);d=d&&l;const Z={opacity:ti,x:zI(C,m,f),y:FA(C,m,f)},v={enter:Z,update:h={opacity:ss,text:{field:Yhe},x:Z.x,y:Z.y,align:b,baseline:p},exit:{opacity:ti,x:Z.x,y:Z.y}};yr(v,{dx:!c&&d?zI(C,y):null,dy:!u&&d?FA(C,y):null}),yr(v,{angle:o("labelAngle"),fill:o("labelColor"),fillOpacity:o("labelOpacity"),font:o("labelFont"),fontSize:o("labelFontSize"),fontWeight:o("labelFontWeight"),fontStyle:o("labelFontStyle"),limit:o("labelLimit"),lineHeight:o("labelLineHeight")},{align:c,baseline:u});const G=o("labelBound");let B=o("labelOverlap");return B=B||G?{separation:o("labelSeparation"),method:B,order:"datum.index",bound:G?{scale:a,orient:C,tolerance:G}:null}:void 0,h.align!==b&&(h.align=hB(h.align,b)),h.baseline!==p&&(h.baseline=hB(h.baseline,p)),Ga({type:ZZ,role:F4g,style:tN,key:as,from:n,encode:v,overlap:B},i)}function p6g(e,g,i,n){const I=_C(e,g),r=e.orient,o=$O(r,-1,1);let C,a;const A={enter:C={opacity:ti,anchor:MI(I("titleAnchor",null)),align:{signal:Ehe}},update:a=vg({},C,{opacity:ss,text:MI(e.title)}),exit:{opacity:ti}},s={signal:`lerp(range("${e.scale}"), ${UO(0,1,.5)})`};return a.x=zI(r,s),a.y=FA(r,s),C.angle=zI(r,ti,l6g(o,90)),C.baseline=zI(r,Srt(r,wm,al),{value:wm}),a.angle=C.angle,a.baseline=C.baseline,yr(A,{fill:I("titleColor"),fillOpacity:I("titleOpacity"),font:I("titleFont"),fontSize:I("titleFontSize"),fontStyle:I("titleFontStyle"),fontWeight:I("titleFontWeight"),limit:I("titleLimit"),lineHeight:I("titleLineHeight")},{align:I("titleAlign"),angle:I("titleAngle"),baseline:I("titleBaseline")}),b6g(I,r,A,i),A.update.align=hB(A.update.align,C.align),A.update.angle=hB(A.update.angle,C.angle),A.update.baseline=hB(A.update.baseline,C.baseline),Ga({type:ZZ,role:D4g,style:Khe,from:n,encode:A},i)}function b6g(e,g,i,n){const I=(C,a)=>C!=null?(i.update[a]=hB(MI(C),i.update[a]),!1):!QG(a,n),r=I(e("titleX"),"x"),o=I(e("titleY"),"y");i.enter.auto=o===r?MI(o):zI(g,MI(o),MI(r))}function y6g(e,g){const i=c6g(e,g),n=e.encode||{},I=n.axis||{},r=I.name||void 0,o=I.interactive,C=I.style,a=_C(e,i),A=f8g(a),s={scale:e.scale,ticks:!!a("ticks"),labels:!!a("labels"),grid:!!a("grid"),domain:!!a("domain"),title:e.title!=null},l=qt(g.add(Cl({},[s]))),c=qt(g.add(Z$g({scale:g.scaleRef(e.scale),extra:g.property(A.extra),count:g.objectProperty(e.tickCount),values:g.objectProperty(e.values),minstep:g.property(e.tickMinStep),formatType:g.property(e.formatType),formatSpecifier:g.property(e.format)}))),u=[];let d;return s.grid&&u.push(d6g(e,i,n.grid,c,A)),s.ticks&&(d=a("tickSize"),u.push(f6g(e,i,n.ticks,c,d,A))),s.labels&&(d=s.ticks?d:0,u.push(m6g(e,i,n.labels,c,d,A))),s.domain&&u.push(u6g(e,i,n.domain,l)),s.title&&u.push(p6g(e,i,n.title,l)),jO(U9({role:Y4g,from:l,encode:GS(Z6g(a,e),I,gN),marks:u,aria:a("aria"),description:a("description"),zindex:a("zindex"),name:r,interactive:o,style:C}),g)}function Z6g(e,g){const i={enter:{},update:{}};return yr(i,{orient:e("orient"),offset:e("offset")||0,position:rA(g.position,0),titlePadding:e("titlePadding"),minExtent:e("minExtent"),maxExtent:e("maxExtent"),range:{signal:`abs(span(range("${g.scale}")))`},translate:e("translate"),format:g.format,formatType:g.formatType}),i}function Vrt(e,g,i){const n=Vt(e.signals),I=Vt(e.scales);return i||n.forEach(r=>ort(r,g)),Vt(e.projections).forEach(r=>e8g(r,g)),I.forEach(r=>M$g(r,g)),Vt(e.data).forEach(r=>i6g(r,g)),I.forEach(r=>z$g(r,g)),(i||n).forEach(r=>y$g(r,g)),Vt(e.axes).forEach(r=>y6g(r,g)),Vt(e.marks).forEach(r=>jO(r,g)),Vt(e.legends).forEach(r=>_8g(r,g)),e.title&&$8g(e.title,g),g.parseLambdas(),g}const G6g=e=>GS({enter:{x:{value:0},y:{value:0}},update:{width:{signal:"width"},height:{signal:"height"}}},e);function v6g(e,g){const i=g.config,n=qt(g.root=g.add(c3())),I=B6g(e,i);I.forEach(A=>ort(A,g)),g.description=e.description||i.description,g.eventConfig=i.events,g.legends=g.objectProperty(i.legend&&i.legend.layout),g.locale=i.locale;const r=g.add(Cl()),o=g.add(srt(rrt(G6g(e.encode),LO,The,e.style,g,{pulse:qt(r)}))),C=g.add(crt({layout:g.objectProperty(e.layout),legends:g.legends,autosize:g.signalRef("autosize"),mark:n,pulse:qt(o)}));g.operators.pop(),g.pushState(qt(o),qt(C),null),Vrt(e,g,I),g.operators.push(C);let a=g.add(art({mark:n,pulse:qt(C)}));return a=g.add(lrt({pulse:qt(a)})),a=g.add(yZ({pulse:qt(a)})),g.addData("root",new by(g,r,r,a)),g}function iV(e,g){return g&&g.signal?{name:e,update:g.signal}:{name:e,value:g}}function B6g(e,g){const i=o=>rA(e[o],g[o]),n=[iV("background",i("background")),iV("autosize",H4g(i("autosize"))),iV("padding",k4g(i("padding"))),iV("width",i("width")||0),iV("height",i("height")||0)],I=n.reduce((o,C)=>(o[C.name]=C,o),{}),r={};return Vt(e.signals).forEach(o=>{gg(I,o.name)?o=vg(I[o.name],o):n.push(o),r[o.name]=o}),Vt(g.signals).forEach(o=>{!gg(r,o.name)&&!gg(I,o.name)&&n.push(o)}),n}function Wrt(e,g){this.config=e||{},this.options=g||{},this.bindings=[],this.field={},this.signals={},this.lambdas={},this.scales={},this.events={},this.data={},this.streams=[],this.updates=[],this.operators=[],this.eventConfig=null,this.locale=null,this._id=0,this._subid=0,this._nextsub=[0],this._parent=[],this._encode=[],this._lookup=[],this._markpath=[]}function wke(e){this.config=e.config,this.options=e.options,this.legends=e.legends,this.field=Object.create(e.field),this.signals=Object.create(e.signals),this.lambdas=Object.create(e.lambdas),this.scales=Object.create(e.scales),this.events=Object.create(e.events),this.data=Object.create(e.data),this.streams=[],this.updates=[],this.operators=[],this._id=0,this._subid=++e._nextsub[0],this._nextsub=e._nextsub,this._parent=e._parent.slice(),this._encode=e._encode.slice(),this._lookup=e._lookup.slice(),this._markpath=e._markpath}Wrt.prototype=wke.prototype={parse(e){return Vrt(e,this)},fork(){return new wke(this)},isSubscope(){return this._subid>0},toRuntime(){return this.finish(),{description:this.description,operators:this.operators,streams:this.streams,updates:this.updates,bindings:this.bindings,eventConfig:this.eventConfig,locale:this.locale}},id(){return(this._subid?this._subid+":":0)+this._id++},add(e){return this.operators.push(e),e.id=this.id(),e.refs&&(e.refs.forEach(g=>{g.$ref=e.id}),e.refs=null),e},proxy(e){const g=e instanceof CIe?qt(e):e;return this.add(Y$g({value:g}))},addStream(e){return this.streams.push(e),e.id=this.id(),e},addUpdate(e){return this.updates.push(e),e},finish(){let e,g;this.root&&(this.root.root=!0);for(e in this.signals)this.signals[e].signal=e;for(e in this.scales)this.scales[e].scale=e;function i(n,I,r){let o,C;n&&(o=n.data||(n.data={}),C=o[I]||(o[I]=[]),C.push(r))}for(e in this.data){g=this.data[e],i(g.input,e,"input"),i(g.output,e,"output"),i(g.values,e,"values");for(const n in g.index)i(g.index[n],e,"index:"+n)}return this},pushState(e,g,i){this._encode.push(qt(this.add(yZ({pulse:e})))),this._parent.push(g),this._lookup.push(i?qt(this.proxy(i)):null),this._markpath.push(-1)},popState(){this._encode.pop(),this._parent.pop(),this._lookup.pop(),this._markpath.pop()},parent(){return jg(this._parent)},encode(){return jg(this._encode)},lookup(){return jg(this._lookup)},markpath(){const e=this._markpath;return++e[e.length-1]},fieldRef(e,g){if(Rt(e))return J9(e,g);e.signal||qe("Unsupported field reference: "+ft(e));const i=e.signal;let n=this.field[i];if(!n){const I={name:this.signalRef(i)};g&&(I.as=g),this.field[i]=n=qt(this.add(w$g(I)))}return n},compareRef(e){let g=!1;const i=r=>BI(r)?(g=!0,this.signalRef(r.signal)):A$g(r)?(g=!0,this.exprRef(r.expr)):r,n=Vt(e.field).map(i),I=Vt(e.order).map(i);return g?qt(this.add(lke({fields:n,orders:I}))):ske(n,I)},keyRef(e,g){let i=!1;const n=r=>BI(r)?(i=!0,qt(I[r.signal])):r,I=this.signals;return e=Vt(e).map(n),i?qt(this.add(S$g({fields:e,flat:g}))):o$g(e,g)},sortRef(e){if(!e)return e;const g=OO(e.op,e.field),i=e.order||C$g;return i.signal?qt(this.add(lke({fields:g,orders:this.signalRef(i.signal)}))):ske(g,i)},event(e,g){const i=e+":"+g;if(!this.events[i]){const n=this.id();this.streams.push({id:n,source:e,type:g}),this.events[i]=n}return this.events[i]},hasOwnSignal(e){return gg(this.signals,e)},addSignal(e,g){this.hasOwnSignal(e)&&qe("Duplicate signal name: "+ft(e));const i=g instanceof CIe?g:this.add(c3(g));return this.signals[e]=i},getSignal(e){return this.signals[e]||qe("Unrecognized signal name: "+ft(e)),this.signals[e]},signalRef(e){return this.signals[e]?qt(this.signals[e]):(gg(this.lambdas,e)||(this.lambdas[e]=this.add(c3(null))),qt(this.lambdas[e]))},parseLambdas(){const e=Object.keys(this.lambdas);for(let g=0,i=e.length;g0?",":"")+(Wt(I)?I.signal||_he(I):ft(I))}return i+"]"}function S6g(e){let g="{",i=0,n,I;for(n in e)I=e[n],g+=(++i>1?",":"")+ft(n)+":"+(Wt(I)?I.signal||_he(I):ft(I));return g+"}"}function R6g(){const e="sans-serif",n="#4c78a8",I="#000",r="#888",o="#ddd";return{description:"Vega visualization",padding:0,autosize:"pad",background:null,events:{defaults:{allow:["wheel"]}},group:null,mark:null,arc:{fill:n},area:{fill:n},image:null,line:{stroke:n,strokeWidth:2},path:{stroke:n},rect:{fill:n},rule:{stroke:I},shape:{stroke:n},symbol:{fill:n,size:64},text:{fill:I,font:e,fontSize:11},trail:{fill:n,size:2},style:{"guide-label":{fill:I,font:e,fontSize:10},"guide-title":{fill:I,font:e,fontSize:11,fontWeight:"bold"},"group-title":{fill:I,font:e,fontSize:13,fontWeight:"bold"},"group-subtitle":{fill:I,font:e,fontSize:12},point:{size:30,strokeWidth:2,shape:"circle"},circle:{size:30,strokeWidth:2},square:{size:30,strokeWidth:2,shape:"square"},cell:{fill:"transparent",stroke:o},view:{fill:"transparent"}},title:{orient:"top",anchor:"middle",offset:4,subtitlePadding:3},axis:{minExtent:0,maxExtent:200,bandPosition:.5,domain:!0,domainWidth:1,domainColor:r,grid:!1,gridWidth:1,gridColor:o,labels:!0,labelAngle:0,labelLimit:180,labelOffset:0,labelPadding:2,ticks:!0,tickColor:r,tickOffset:0,tickRound:!0,tickSize:5,tickWidth:1,titlePadding:4},axisBand:{tickOffset:-.5},projection:{type:"mercator"},legend:{orient:"right",padding:0,gridAlign:"each",columnPadding:10,rowPadding:2,symbolDirection:"vertical",gradientDirection:"vertical",gradientLength:200,gradientThickness:16,gradientStrokeColor:o,gradientStrokeWidth:0,gradientLabelOffset:2,labelAlign:"left",labelBaseline:"middle",labelLimit:160,labelOffset:4,labelOverlap:!0,symbolLimit:30,symbolType:"circle",symbolSize:100,symbolOffset:0,symbolStrokeWidth:1.5,symbolBaseFillColor:"transparent",symbolBaseStrokeColor:r,titleLimit:180,titleOrient:"top",titlePadding:5,layout:{offset:18,direction:"horizontal",left:{direction:"vertical"},right:{direction:"vertical"}}},range:{category:{scheme:"tableau10"},ordinal:{scheme:"blues"},heatmap:{scheme:"yellowgreenblue"},ramp:{scheme:"blues"},diverging:{scheme:"blueorange",extent:[1,0]},symbol:["circle","square","triangle-up","cross","diamond","triangle-right","triangle-down","triangle-left"]}}}function V6g(e,g,i){return Wt(e)||qe("Input Vega specification must be an object."),g=AS(R6g(),g,e.config),v6g(e,new Wrt(g,i)).toRuntime()}var W6g="5.25.0";vg(Dw,rFg,wzg,nPg,gOg,QOg,GLg,gLg,BLg,LLg,nUg,AUg);const X6g=Object.freeze(Object.defineProperty({__proto__:null,Bounds:oI,CanvasHandler:PH,CanvasRenderer:yM,DATE:kC,DAY:zr,DAYOFYEAR:xc,Dataflow:aB,Debug:y6e,Error:jle,EventStream:$_,Gradient:lgt,GroupItem:yO,HOURS:ba,Handler:vm,Info:b6e,Item:bO,MILLISECONDS:LA,MINUTES:ya,MONTH:Qr,Marks:Za,MultiPulse:bce,None:p6e,Operator:Yi,Parameters:j_,Pulse:rm,QUARTER:NC,RenderType:Tf,Renderer:gu,ResourceLoader:Pue,SECONDS:ms,SVGHandler:Cde,SVGRenderer:ude,SVGStringRenderer:dde,Scenegraph:rde,TIME_UNITS:sce,Transform:Le,View:LIt,WEEK:yI,Warn:$le,YEAR:hr,accessor:PC,accessorFields:Ur,accessorName:xn,array:Vt,ascending:D_,bandwidthNRD:vce,bin:jqe,bootstrapCI:$qe,boundClip:rit,boundContext:EH,boundItem:Ane,boundMark:Xgt,boundStroke:oh,changeset:hZ,clampRange:T6e,codegenExpression:sIt,compare:ice,constant:no,cumulativeLogNormal:Wce,cumulativeNormal:eO,cumulativeUniform:Nce,dayofyear:nqe,debounce:nce,defaultLocale:dce,definition:Lqe,densityLogNormal:Vce,densityNormal:Bce,densityUniform:Hce,domChild:mC,domClear:fA,domCreate:Wf,domFind:ode,dotbin:qqe,error:qe,expressionFunction:aI,extend:vg,extent:kc,extentIndex:H6e,falsy:_h,fastmap:cS,field:HC,flush:N6e,font:wO,fontFamily:zH,fontSize:tu,format:F5,formatLocale:iM,formats:mce,hasOwnProperty:gg,id:GH,identity:io,inferType:Kqe,inferTypes:xqe,ingest:li,inherits:mt,inrange:Zv,interpolate:Yue,interpolateColors:mO,interpolateRange:$tt,intersect:git,intersectBoxLine:Gv,intersectPath:_ue,intersectPoint:Oue,intersectRule:bgt,isArray:et,isBoolean:gp,isDate:nm,isFunction:Bg,isIterable:k6e,isNumber:Vi,isObject:Wt,isRegExp:Y6e,isString:Rt,isTuple:U_,key:Ice,lerp:K6e,lineHeight:Zm,loader:J_,locale:kqe,logger:qle,lruCache:x6e,markup:cde,merge:F6e,mergeConfig:AS,multiLineOffset:ide,one:sS,pad:E6e,panLinear:w6e,panLog:S6e,panPow:R6e,panSymlog:V6e,parse:V6g,parseExpression:hhe,parseSelector:Cp,path:IO,pathCurves:Due,pathEqual:oit,pathParse:Jw,pathRectangle:dgt,pathRender:X9,pathSymbols:ugt,pathTrail:hgt,peek:jg,point:RO,projection:Nde,quantileLogNormal:Xce,quantileNormal:tO,quantileUniform:kce,quantiles:Zce,quantizeInterpolator:qtt,quarter:W6e,quartiles:Gce,get random(){return ps},randomInteger:sxg,randomKDE:Sce,randomLCG:axg,randomLogNormal:tet,randomMixture:get,randomNormal:wce,randomUniform:iet,read:Dqe,regressionConstant:Yce,regressionExp:Iet,regressionLinear:Kce,regressionLoess:Cet,regressionLog:net,regressionPoly:oet,regressionPow:ret,regressionQuad:xce,renderModule:VO,repeat:g2,resetDefaultLocale:r5g,resetSVGClipId:mgt,resetSVGDefIds:P3g,responseType:Eqe,runtimeContext:kIt,sampleCurve:iO,sampleLogNormal:Rce,sampleNormal:q_,sampleUniform:Tce,scale:si,sceneEqual:hde,sceneFromJSON:Hgt,scenePickVisit:dM,sceneToJSON:Tgt,sceneVisit:UA,sceneZOrder:Jue,scheme:Kue,serializeXML:Lgt,setRandom:oxg,span:vH,splitAccessPath:qc,stringValue:ft,textMetrics:xA,timeBin:yqe,timeFloor:Aqe,timeFormatLocale:B9,timeInterval:hS,timeOffset:uqe,timeSequence:fqe,timeUnitSpecifier:iqe,timeUnits:Ace,toBoolean:rce,toDate:oce,toNumber:_r,toSet:JA,toString:Cce,transform:Uqe,transforms:Dw,truncate:D6e,truthy:fs,tupleid:eg,typeParsers:zie,utcFloor:lqe,utcInterval:fS,utcOffset:dqe,utcSequence:mqe,utcdayofyear:oqe,utcquarter:X6e,utcweek:Cqe,version:W6g,visitArray:qh,week:Iqe,writeConfig:lS,zero:uf,zoomLinear:ece,zoomLog:tce,zoomPow:jD,zoomSymlog:gce},Symbol.toStringTag,{value:"Module"}));function T6g(e,g,i){let n;g.x2&&(g.x?(i&&e.x>e.x2&&(n=e.x,e.x=e.x2,e.x2=n),e.width=e.x2-e.x):e.x=e.x2-(e.width||0)),g.xc&&(e.x=e.xc-(e.width||0)/2),g.y2&&(g.y?(i&&e.y>e.y2&&(n=e.y,e.y=e.y2,e.y2=n),e.height=e.y2-e.y):e.y=e.y2-(e.height||0)),g.yc&&(e.y=e.yc-(e.height||0)/2)}var H6g={NaN:NaN,E:Math.E,LN2:Math.LN2,LN10:Math.LN10,LOG2E:Math.LOG2E,LOG10E:Math.LOG10E,PI:Math.PI,SQRT1_2:Math.SQRT1_2,SQRT2:Math.SQRT2,MIN_VALUE:Number.MIN_VALUE,MAX_VALUE:Number.MAX_VALUE},N6g={"*":(e,g)=>e*g,"+":(e,g)=>e+g,"-":(e,g)=>e-g,"/":(e,g)=>e/g,"%":(e,g)=>e%g,">":(e,g)=>e>g,"<":(e,g)=>ee<=g,">=":(e,g)=>e>=g,"==":(e,g)=>e==g,"!=":(e,g)=>e!=g,"===":(e,g)=>e===g,"!==":(e,g)=>e!==g,"&":(e,g)=>e&g,"|":(e,g)=>e|g,"^":(e,g)=>e^g,"<<":(e,g)=>e<>":(e,g)=>e>>g,">>>":(e,g)=>e>>>g},k6g={"+":e=>+e,"-":e=>-e,"~":e=>~e,"!":e=>!e};const Y6g=Array.prototype.slice,xp=(e,g,i)=>{const n=i?i(g[0]):g[0];return n[e].apply(n,Y6g.call(g,1))},K6g=(e,g,i,n,I,r,o)=>new Date(e,g||0,i??1,n||0,I||0,r||0,o||0);var x6g={isNaN:Number.isNaN,isFinite:Number.isFinite,abs:Math.abs,acos:Math.acos,asin:Math.asin,atan:Math.atan,atan2:Math.atan2,ceil:Math.ceil,cos:Math.cos,exp:Math.exp,floor:Math.floor,log:Math.log,max:Math.max,min:Math.min,pow:Math.pow,random:Math.random,round:Math.round,sin:Math.sin,sqrt:Math.sqrt,tan:Math.tan,clamp:(e,g,i)=>Math.max(g,Math.min(i,e)),now:Date.now,utc:Date.UTC,datetime:K6g,date:e=>new Date(e).getDate(),day:e=>new Date(e).getDay(),year:e=>new Date(e).getFullYear(),month:e=>new Date(e).getMonth(),hours:e=>new Date(e).getHours(),minutes:e=>new Date(e).getMinutes(),seconds:e=>new Date(e).getSeconds(),milliseconds:e=>new Date(e).getMilliseconds(),time:e=>new Date(e).getTime(),timezoneoffset:e=>new Date(e).getTimezoneOffset(),utcdate:e=>new Date(e).getUTCDate(),utcday:e=>new Date(e).getUTCDay(),utcyear:e=>new Date(e).getUTCFullYear(),utcmonth:e=>new Date(e).getUTCMonth(),utchours:e=>new Date(e).getUTCHours(),utcminutes:e=>new Date(e).getUTCMinutes(),utcseconds:e=>new Date(e).getUTCSeconds(),utcmilliseconds:e=>new Date(e).getUTCMilliseconds(),length:e=>e.length,join:function(){return xp("join",arguments)},indexof:function(){return xp("indexOf",arguments)},lastindexof:function(){return xp("lastIndexOf",arguments)},slice:function(){return xp("slice",arguments)},reverse:e=>e.slice().reverse(),parseFloat,parseInt,upper:e=>String(e).toUpperCase(),lower:e=>String(e).toLowerCase(),substring:function(){return xp("substring",arguments,String)},split:function(){return xp("split",arguments,String)},replace:function(){return xp("replace",arguments,String)},trim:e=>String(e).trim(),regexp:RegExp,test:(e,g)=>RegExp(e).test(g)};const F6g=["view","item","group","xy","x","y"],dIe=new Set([Function,eval,setTimeout,setInterval]);typeof setImmediate=="function"&&dIe.add(setImmediate);const E6g={Literal:(e,g)=>g.value,Identifier:(e,g)=>{const i=g.name;return e.memberDepth>0?i:i==="datum"?e.datum:i==="event"?e.event:i==="item"?e.item:H6g[i]||e.params["$"+i]},MemberExpression:(e,g)=>{const i=!g.computed,n=e(g.object);i&&(e.memberDepth+=1);const I=e(g.property);if(i&&(e.memberDepth-=1),dIe.has(n[I])){console.error(`Prevented interpretation of member "${I}" which could lead to insecure code execution`);return}return n[I]},CallExpression:(e,g)=>{const i=g.arguments;let n=g.callee.name;return n.startsWith("_")&&(n=n.slice(1)),n==="if"?e(i[0])?e(i[1]):e(i[2]):(e.fn[n]||x6g[n]).apply(e.fn,i.map(e))},ArrayExpression:(e,g)=>g.elements.map(e),BinaryExpression:(e,g)=>N6g[g.operator](e(g.left),e(g.right)),UnaryExpression:(e,g)=>k6g[g.operator](e(g.argument)),ConditionalExpression:(e,g)=>e(g.test)?e(g.consequent):e(g.alternate),LogicalExpression:(e,g)=>g.operator==="&&"?e(g.left)&&e(g.right):e(g.left)||e(g.right),ObjectExpression:(e,g)=>g.properties.reduce((i,n)=>{e.memberDepth+=1;const I=e(n.key);return e.memberDepth-=1,dIe.has(e(n.value))?console.error(`Prevented interpretation of property "${I}" which could lead to insecure code execution`):i[I]=e(n.value),i},{})};function nV(e,g,i,n,I,r){const o=C=>E6g[C.type](o,C);return o.memberDepth=0,o.fn=Object.create(g),o.params=i,o.datum=n,o.event=I,o.item=r,F6g.forEach(C=>o.fn[C]=function(){return I.vega[C](...arguments)}),o(e)}var D6g={operator(e,g){const i=g.ast,n=e.functions;return I=>nV(i,n,I)},parameter(e,g){const i=g.ast,n=e.functions;return(I,r)=>nV(i,n,r,I)},event(e,g){const i=g.ast,n=e.functions;return I=>nV(i,n,void 0,void 0,I)},handler(e,g){const i=g.ast,n=e.functions;return(I,r)=>{const o=r.item&&r.item.datum;return nV(i,n,I,o,r)}},encode(e,g){const{marktype:i,channels:n}=g,I=e.functions,r=i==="group"||i==="image"||i==="rect";return(o,C)=>{const a=o.datum;let A=0,s;for(const l in n)s=nV(n[l].ast,I,C,a,void 0,o),o[l]!==s&&(o[l]=s,A=1);return i!=="rule"&&T6g(o,n,r),A}}};const M6g="vega-lite",z6g='Dominik Moritz, Kanit "Ham" Wongsuphasawat, Arvind Satyanarayan, Jeffrey Heer',P6g="5.9.0",_6g=["Kanit Wongsuphasawat (http://kanitw.yellowpigz.com)","Dominik Moritz (https://www.domoritz.de)","Arvind Satyanarayan (https://arvindsatya.com)","Jeffrey Heer (https://jheer.org)"],O6g="https://vega.github.io/vega-lite/",J6g="Vega-Lite is a concise high-level language for interactive visualization.",L6g=["vega","chart","visualization"],U6g="build/vega-lite.js",Q6g="build/vega-lite.min.js",j6g="build/vega-lite.min.js",$6g="build/src/index",q6g="build/src/index.d.ts",eqg={vl2pdf:"./bin/vl2pdf",vl2png:"./bin/vl2png",vl2svg:"./bin/vl2svg",vl2vg:"./bin/vl2vg"},tqg=["bin","build","src","vega-lite*","tsconfig.json"],gqg={changelog:"conventional-changelog -p angular -r 2",prebuild:"yarn clean:build",build:"yarn build:only","build:only":"tsc -p tsconfig.build.json && rollup -c","prebuild:examples":"yarn build:only","build:examples":"yarn data && TZ=America/Los_Angeles scripts/build-examples.sh","prebuild:examples-full":"yarn build:only","build:examples-full":"TZ=America/Los_Angeles scripts/build-examples.sh 1","build:example":"TZ=America/Los_Angeles scripts/build-example.sh","build:toc":"yarn build:jekyll && scripts/generate-toc","build:site":"rollup -c site/rollup.config.mjs","build:jekyll":"pushd site && bundle exec jekyll build -q && popd","build:versions":"scripts/update-version.sh",clean:"yarn clean:build && del-cli 'site/data/*' 'examples/compiled/*.png' && find site/examples ! -name 'index.md' ! -name 'data' -type f -delete","clean:build":"del-cli 'build/*' !build/vega-lite-schema.json",data:"rsync -r node_modules/vega-datasets/data/* site/data",schema:"mkdir -p build && ts-json-schema-generator -f tsconfig.json -p src/index.ts -t TopLevelSpec --no-type-check --no-ref-encode > build/vega-lite-schema.json && yarn renameschema && cp build/vega-lite-schema.json site/_data/",renameschema:"scripts/rename-schema.sh",presite:"yarn data && yarn schema && yarn build:site && yarn build:versions && scripts/create-example-pages.sh",site:"yarn site:only","site:only":"pushd site && bundle exec jekyll serve -I -l && popd",prettierbase:"prettier '**/*.{md,css,yml}'",format:"eslint . --fix && yarn prettierbase --write",lint:"eslint . && yarn prettierbase --check",jest:"NODE_OPTIONS=--experimental-vm-modules npx jest",test:"yarn jest test/ && yarn lint && yarn schema && yarn jest examples/ && yarn test:runtime","test:cover":"yarn jest --collectCoverage test/","test:inspect":"node --inspect-brk --experimental-vm-modules ./node_modules/.bin/jest --runInBand test","test:runtime":"NODE_OPTIONS=--experimental-vm-modules TZ=America/Los_Angeles npx jest test-runtime/ --config test-runtime/jest-config.json","test:runtime:generate":"yarn build:only && del-cli test-runtime/resources && VL_GENERATE_TESTS=true yarn test:runtime",watch:"tsc -p tsconfig.build.json -w","watch:site":"yarn build:site -w","watch:test":"yarn jest --watch test/","watch:test:runtime":"NODE_OPTIONS=--experimental-vm-modules TZ=America/Los_Angeles npx jest --watch test-runtime/ --config test-runtime/jest-config.json",release:"release-it"},iqg={type:"git",url:"https://github.com/vega/vega-lite.git"},nqg="BSD-3-Clause",Iqg={url:"https://github.com/vega/vega-lite/issues"},rqg={"@babel/core":"^7.21.4","@babel/preset-env":"^7.21.4","@babel/preset-typescript":"^7.21.4","@release-it/conventional-changelog":"^5.1.1","@rollup/plugin-alias":"^5.0.0","@rollup/plugin-babel":"^6.0.3","@rollup/plugin-commonjs":"^24.1.0","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.0.2","@rollup/plugin-terser":"^0.4.1","@types/chai":"^4.3.4","@types/d3":"^7.4.0","@types/jest":"^27.4.1","@types/pako":"^2.0.0","@typescript-eslint/eslint-plugin":"^5.59.1","@typescript-eslint/parser":"^5.59.1","ajv-formats":"^2.1.1",ajv:"^8.12.0",chai:"^4.3.7",cheerio:"^1.0.0-rc.12","conventional-changelog-cli":"^2.2.2",d3:"^7.8.4","del-cli":"^5.0.0","eslint-config-prettier":"^8.8.0","eslint-plugin-jest":"^27.2.1","eslint-plugin-prettier":"^4.2.1",eslint:"^8.39.0","highlight.js":"^11.7.0","jest-dev-server":"^6.1.1",jest:"^27.5.1",mkdirp:"^3.0.1",pako:"^2.1.0",prettier:"^2.8.8",puppeteer:"^15.0.0","release-it":"^15.10.1","rollup-plugin-bundle-size":"^1.0.3","rollup-plugin-sourcemaps":"^0.6.3",rollup:"^3.21.0",serve:"^14.2.0",terser:"^5.17.1","ts-jest":"^29.1.0","ts-json-schema-generator":"^1.2.0",typescript:"~4.9.5","vega-cli":"^5.25.0","vega-datasets":"^2.7.0","vega-embed":"^6.22.1","vega-tooltip":"^0.32.0","yaml-front-matter":"^4.1.1"},oqg={"@types/clone":"~2.1.1",clone:"~2.1.2","fast-deep-equal":"~3.1.3","fast-json-stable-stringify":"~2.1.0","json-stringify-pretty-compact":"~3.0.0",tslib:"~2.5.0","vega-event-selector":"~3.0.1","vega-expression":"~5.1.0","vega-util":"~1.17.2",yargs:"~17.7.1"},Cqg={vega:"^5.24.0"},aqg={node:">=16"},sqg={name:M6g,author:z6g,version:P6g,collaborators:_6g,homepage:O6g,description:J6g,keywords:L6g,main:U6g,unpkg:Q6g,jsdelivr:j6g,module:$6g,types:q6g,bin:eqg,files:tqg,scripts:gqg,repository:iqg,license:nqg,bugs:Iqg,devDependencies:rqg,dependencies:oqg,peerDependencies:Cqg,engines:aqg};var Xrt={exports:{}};(function(e){var g=function(){function i(c,u){return u!=null&&c instanceof u}var n;try{n=Map}catch{n=function(){}}var I;try{I=Set}catch{I=function(){}}var r;try{r=Promise}catch{r=function(){}}function o(c,u,d,h,f){typeof u=="object"&&(d=u.depth,h=u.prototype,f=u.includeNonEnumerable,u=u.circular);var m=[],b=[],p=typeof Buffer<"u";typeof u>"u"&&(u=!0),typeof d>"u"&&(d=1/0);function y(Z,v){if(Z===null)return null;if(v===0)return Z;var G,B;if(typeof Z!="object")return Z;if(i(Z,n))G=new n;else if(i(Z,I))G=new I;else if(i(Z,r))G=new r(function(Y,x){Z.then(function(M){Y(y(M,v-1))},function(M){x(y(M,v-1))})});else if(o.__isArray(Z))G=[];else if(o.__isRegExp(Z))G=new RegExp(Z.source,l(Z)),Z.lastIndex&&(G.lastIndex=Z.lastIndex);else if(o.__isDate(Z))G=new Date(Z.getTime());else{if(p&&Buffer.isBuffer(Z))return Buffer.allocUnsafe?G=Buffer.allocUnsafe(Z.length):G=new Buffer(Z.length),Z.copy(G),G;i(Z,Error)?G=Object.create(Z):typeof h>"u"?(B=Object.getPrototypeOf(Z),G=Object.create(B)):(G=Object.create(h),B=h)}if(u){var S=m.indexOf(Z);if(S!=-1)return b[S];m.push(Z),b.push(G)}i(Z,n)&&Z.forEach(function(Y,x){var M=y(x,v-1),F=y(Y,v-1);G.set(M,F)}),i(Z,I)&&Z.forEach(function(Y){var x=y(Y,v-1);G.add(x)});for(var R in Z){var w;B&&(w=Object.getOwnPropertyDescriptor(B,R)),!(w&&w.set==null)&&(G[R]=y(Z[R],v-1))}if(Object.getOwnPropertySymbols)for(var T=Object.getOwnPropertySymbols(Z),R=0;RfB(i,g))}:Jhe(e)?{or:e.or.map(i=>fB(i,g))}:g(e)}const nc=Trt,mg=lqg;function Hrt(e){throw new Error(e)}function i1(e,g){const i={};for(const n of g)gg(e,n)&&(i[n]=e[n]);return i}function WC(e,g){const i={...e};for(const n of g)delete i[n];return i}Set.prototype.toJSON=function(){return`Set(${[...this].map(e=>Ohe(e)).join(",")})`};const Oi=Ohe;function $g(e){if(Vi(e))return e;const g=Rt(e)?e:Ohe(e);if(g.length<250)return g;let i=0;for(let n=0;nC===0?o:`[${o}]`),r=I.map((o,C)=>I.slice(0,C+1).join(""));for(const o of r)g.add(o)}return g}function $he(e,g){return e===void 0||g===void 0?!0:jhe(fIe(e),fIe(g))}function Ri(e){return At(e).length===0}const At=Object.keys,fr=Object.values,Sm=Object.entries;function Q9(e){return e===!0||e===!1}function dn(e){const g=e.replace(/\W/g,"_");return(e.match(/^\d+/)?"_":"")+g}function PW(e,g){return Uhe(e)?`!(${PW(e.not,g)})`:Lhe(e)?`(${e.and.map(i=>PW(i,g)).join(") && (")})`:Jhe(e)?`(${e.or.map(i=>PW(i,g)).join(") || (")})`:g(e)}function u3(e,g){if(g.length===0)return!0;const i=g.shift();return i in e&&u3(e[i],g)&&delete e[i],Ri(e)}function iN(e){return e.charAt(0).toUpperCase()+e.substr(1)}function qhe(e,g="datum"){const i=qc(e),n=[];for(let I=1;I<=i.length;I++){const r=`[${i.slice(0,I).map(ft).join("][")}]`;n.push(`${g}${r}`)}return n.join(" && ")}function Yrt(e,g="datum"){return`${g}[${ft(qc(e).join("."))}]`}function fqg(e){return e.replace(/(\[|\]|\.|'|")/g,"\\$1")}function ys(e){return`${qc(e).map(fqg).join("\\.")}`}function Zy(e,g,i){return e.replace(new RegExp(g.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),"g"),i)}function efe(e){return`${qc(e).join(".")}`}function n1(e){return e?qc(e).length:0}function CI(...e){for(const g of e)if(g!==void 0)return g}let Krt=42;function xrt(e){const g=++Krt;return e?String(e)+g:g}function mqg(){Krt=42}function Frt(e){return Ert(e)?e:`__${e}`}function Ert(e){return e.startsWith("__")}function j9(e){if(e!==void 0)return(e%360+360)%360}function qO(e){return Vi(e)?!0:!isNaN(e)&&!isNaN(parseFloat(e))}const yd="row",Zd="column",eJ="facet",hn="x",JI="y",sl="x2",Iu="y2",ap="xOffset",wS="yOffset",Al="radius",sh="radius2",Bs="theta",Ah="theta2",ll="latitude",cl="longitude",ul="latitude2",Zs="longitude2",KC="color",ru="fill",ou="stroke",xC="shape",lh="size",GZ="angle",ch="opacity",sp="fillOpacity",Ap="strokeOpacity",lp="strokeWidth",cp="strokeDash",nN="text",IN="order",rN="detail",tJ="key",Gy="tooltip",gJ="href",iJ="url",nJ="description",pqg={x:1,y:1,x2:1,y2:1},Drt={theta:1,theta2:1,radius:1,radius2:1};function Mrt(e){return e in Drt}const tfe={longitude:1,longitude2:1,latitude:1,latitude2:1};function zrt(e){switch(e){case ll:return"y";case ul:return"y2";case cl:return"x";case Zs:return"x2"}}function Prt(e){return e in tfe}const bqg=At(tfe),gfe={...pqg,...Drt,...tfe,xOffset:1,yOffset:1,color:1,fill:1,stroke:1,opacity:1,fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeDash:1,size:1,angle:1,shape:1,order:1,text:1,detail:1,key:1,tooltip:1,href:1,url:1,description:1};function mB(e){return e===KC||e===ru||e===ou}const _rt={row:1,column:1,facet:1},ns=At(_rt),ife={...gfe,..._rt},yqg=At(ife),{order:_si,detail:Osi,tooltip:Jsi,...Zqg}=ife,{row:Lsi,column:Usi,facet:Qsi,...Gqg}=Zqg;function vqg(e){return!!Gqg[e]}function Ort(e){return!!ife[e]}const Bqg=[sl,Iu,ul,Zs,Ah,sh];function Jrt(e){return vZ(e)!==e}function vZ(e){switch(e){case sl:return hn;case Iu:return JI;case ul:return ll;case Zs:return cl;case Ah:return Bs;case sh:return Al}return e}function Rm(e){if(Mrt(e))switch(e){case Bs:return"startAngle";case Ah:return"endAngle";case Al:return"outerRadius";case sh:return"innerRadius"}return e}function Cu(e){switch(e){case hn:return sl;case JI:return Iu;case ll:return ul;case cl:return Zs;case Bs:return Ah;case Al:return sh}}function FC(e){switch(e){case hn:case sl:return"width";case JI:case Iu:return"height"}}function Lrt(e){switch(e){case hn:return"xOffset";case JI:return"yOffset";case sl:return"x2Offset";case Iu:return"y2Offset";case Bs:return"thetaOffset";case Al:return"radiusOffset";case Ah:return"theta2Offset";case sh:return"radius2Offset"}}function nfe(e){switch(e){case hn:return"xOffset";case JI:return"yOffset"}}function Urt(e){switch(e){case"xOffset":return"x";case"yOffset":return"y"}}const wqg=At(gfe),{x:jsi,y:$si,x2:qsi,y2:eAi,xOffset:tAi,yOffset:gAi,latitude:iAi,longitude:nAi,latitude2:IAi,longitude2:rAi,theta:oAi,theta2:CAi,radius:aAi,radius2:sAi,...Ife}=gfe,Sqg=At(Ife),rfe={x:1,y:1},au=At(rfe);function LI(e){return e in rfe}const ofe={theta:1,radius:1},Rqg=At(ofe);function IJ(e){return e==="width"?hn:JI}const Qrt={xOffset:1,yOffset:1};function SS(e){return e in Qrt}const{text:AAi,tooltip:lAi,href:cAi,url:uAi,description:dAi,detail:hAi,key:fAi,order:mAi,...jrt}=Ife,Vqg=At(jrt);function Wqg(e){return!!Ife[e]}function Xqg(e){switch(e){case KC:case ru:case ou:case lh:case xC:case ch:case lp:case cp:return!0;case sp:case Ap:case GZ:return!1}}const $rt={...rfe,...ofe,...Qrt,...jrt},rJ=At($rt);function uh(e){return!!$rt[e]}function Tqg(e,g){return Nqg(e)[g]}const qrt={arc:"always",area:"always",bar:"always",circle:"always",geoshape:"always",image:"always",line:"always",rule:"always",point:"always",rect:"always",square:"always",trail:"always",text:"always",tick:"always"},{geoshape:pAi,...Hqg}=qrt;function Nqg(e){switch(e){case KC:case ru:case ou:case nJ:case rN:case tJ:case Gy:case gJ:case IN:case ch:case sp:case Ap:case lp:case eJ:case yd:case Zd:return qrt;case hn:case JI:case ap:case wS:case ll:case cl:return Hqg;case sl:case Iu:case ul:case Zs:return{area:"always",bar:"always",image:"always",rect:"always",rule:"always",circle:"binned",point:"binned",square:"binned",tick:"binned",line:"binned",trail:"binned"};case lh:return{point:"always",tick:"always",rule:"always",circle:"always",square:"always",bar:"always",text:"always",line:"always",trail:"always"};case cp:return{line:"always",point:"always",tick:"always",rule:"always",circle:"always",square:"always",bar:"always",geoshape:"always"};case xC:return{point:"always",geoshape:"always"};case nN:return{text:"always"};case GZ:return{point:"always",square:"always",text:"always"};case iJ:return{image:"always"};case Bs:return{text:"always",arc:"always"};case Al:return{text:"always",arc:"always"};case Ah:case sh:return{arc:"always"}}}function F4(e){switch(e){case hn:case JI:case Bs:case Al:case ap:case wS:case lh:case GZ:case lp:case ch:case sp:case Ap:case sl:case Iu:case Ah:case sh:return;case eJ:case yd:case Zd:case xC:case cp:case nN:case Gy:case gJ:case iJ:case nJ:return"discrete";case KC:case ru:case ou:return"flexible";case ll:case cl:case ul:case Zs:case rN:case tJ:case IN:return}}const kqg={argmax:1,argmin:1,average:1,count:1,distinct:1,product:1,max:1,mean:1,median:1,min:1,missing:1,q1:1,q3:1,ci0:1,ci1:1,stderr:1,stdev:1,stdevp:1,sum:1,valid:1,values:1,variance:1,variancep:1},Yqg={count:1,min:1,max:1};function Pd(e){return!!e&&!!e.argmin}function up(e){return!!e&&!!e.argmax}function Cfe(e){return Rt(e)&&!!kqg[e]}const Kqg=new Set(["count","valid","missing","distinct"]);function eot(e){return Rt(e)&&Kqg.has(e)}function xqg(e){return Rt(e)&&Eg(["min","max"],e)}const Fqg=new Set(["count","sum","distinct","valid","missing"]),Eqg=new Set(["mean","average","median","q1","q3","min","max"]);function tot(e){return gp(e)&&(e=mJ(e,void 0)),"bin"+At(e).map(g=>oJ(e[g])?dn(`_${g}_${Sm(e[g])}`):dn(`_${g}_${e[g]}`)).join("")}function Ji(e){return e===!0||BZ(e)&&!e.binned}function or(e){return e==="binned"||BZ(e)&&e.binned===!0}function BZ(e){return Wt(e)}function oJ(e){return e?.param}function Ske(e){switch(e){case yd:case Zd:case lh:case KC:case ru:case ou:case lp:case ch:case sp:case Ap:case xC:return 6;case cp:return 4;default:return 10}}function oN(e){return!!e?.expr}function hC(e){const g=At(e||{}),i={};for(const n of g)i[n]=Ca(e[n]);return i}function got(e){const{anchor:g,frame:i,offset:n,orient:I,angle:r,limit:o,color:C,subtitleColor:a,subtitleFont:A,subtitleFontSize:s,subtitleFontStyle:l,subtitleFontWeight:c,subtitleLineHeight:u,subtitlePadding:d,...h}=e,f={...h,...C?{fill:C}:{}},m={...g?{anchor:g}:{},...i?{frame:i}:{},...n?{offset:n}:{},...I?{orient:I}:{},...r!==void 0?{angle:r}:{},...o!==void 0?{limit:o}:{}},b={...a?{subtitleColor:a}:{},...A?{subtitleFont:A}:{},...s?{subtitleFontSize:s}:{},...l?{subtitleFontStyle:l}:{},...c?{subtitleFontWeight:c}:{},...u?{subtitleLineHeight:u}:{},...d?{subtitlePadding:d}:{}},p=i1(e,["align","baseline","dx","dy","limit"]);return{titleMarkConfig:f,subtitleMarkConfig:p,nonMarkTitleProperties:m,subtitle:b}}function nf(e){return Rt(e)||et(e)&&Rt(e[0])}function Qt(e){return!!e?.signal}function dp(e){return!!e.step}function Dqg(e){return et(e)?!1:"fields"in e&&!("data"in e)}function Mqg(e){return et(e)?!1:"fields"in e&&"data"in e}function Ad(e){return et(e)?!1:"field"in e&&"data"in e}const zqg={aria:1,description:1,ariaRole:1,ariaRoleDescription:1,blend:1,opacity:1,fill:1,fillOpacity:1,stroke:1,strokeCap:1,strokeWidth:1,strokeOpacity:1,strokeDash:1,strokeDashOffset:1,strokeJoin:1,strokeOffset:1,strokeMiterLimit:1,startAngle:1,endAngle:1,padAngle:1,innerRadius:1,outerRadius:1,size:1,shape:1,interpolate:1,tension:1,orient:1,align:1,baseline:1,text:1,dir:1,dx:1,dy:1,ellipsis:1,limit:1,radius:1,theta:1,angle:1,font:1,fontSize:1,fontWeight:1,fontStyle:1,lineBreak:1,lineHeight:1,cursor:1,href:1,tooltip:1,cornerRadius:1,cornerRadiusTopLeft:1,cornerRadiusTopRight:1,cornerRadiusBottomLeft:1,cornerRadiusBottomRight:1,aspect:1,width:1,height:1,url:1,smooth:1},Pqg=At(zqg),_qg={arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1},mIe=["cornerRadius","cornerRadiusTopLeft","cornerRadiusTopRight","cornerRadiusBottomLeft","cornerRadiusBottomRight"];function iot(e){const g=et(e.condition)?e.condition.map(Rke):Rke(e.condition);return{...Ca(e),condition:g}}function Ca(e){if(oN(e)){const{expr:g,...i}=e;return{signal:g,...i}}return e}function Rke(e){if(oN(e)){const{expr:g,...i}=e;return{signal:g,...i}}return e}function nn(e){if(oN(e)){const{expr:g,...i}=e;return{signal:g,...i}}return Qt(e)?e:e!==void 0?{value:e}:void 0}function Oqg(e){return Qt(e)?e.signal:ft(e)}function Vke(e){return Qt(e)?e.signal:ft(e.value)}function Gd(e){return Qt(e)?e.signal:e==null?null:ft(e)}function Jqg(e,g,i){for(const n of i){const I=vy(n,g.markDef,g.config);I!==void 0&&(e[n]=nn(I))}return e}function not(e){return[].concat(e.type,e.style??[])}function di(e,g,i,n={}){const{vgChannel:I,ignoreVgConfig:r}=n;return I&&g[I]!==void 0?g[I]:g[e]!==void 0?g[e]:r&&(!I||I===e)?void 0:vy(e,g,i,n)}function vy(e,g,i,{vgChannel:n}={}){return CI(n?d3(e,g,i.style):void 0,d3(e,g,i.style),n?i[g.type][n]:void 0,i[g.type][e],n?i.mark[n]:i.mark[e])}function d3(e,g,i){return Iot(e,not(g),i)}function Iot(e,g,i){g=Vt(g);let n;for(const I of g){const r=i[I];r&&r[e]!==void 0&&(n=r[e])}return n}function rot(e,g){return Vt(e).reduce((i,n)=>(i.field.push(Bt(n,g)),i.order.push(n.sort??"ascending"),i),{field:[],order:[]})}function oot(e,g){const i=[...e];return g.forEach(n=>{for(const I of i)if(nc(I,n))return;i.push(n)}),i}function Cot(e,g){return nc(e,g)||!g?e:e?[...Vt(e),...Vt(g)].join(", "):g}function aot(e,g){const i=e.value,n=g.value;if(i==null||n===null)return{explicit:e.explicit,value:null};if((nf(i)||Qt(i))&&(nf(n)||Qt(n)))return{explicit:e.explicit,value:Cot(i,n)};if(nf(i)||Qt(i))return{explicit:e.explicit,value:i};if(nf(n)||Qt(n))return{explicit:e.explicit,value:n};if(!nf(i)&&!Qt(i)&&!nf(n)&&!Qt(n))return{explicit:e.explicit,value:oot(i,n)};throw new Error("It should never reach here")}function afe(e){return`Invalid specification ${Oi(e)}. Make sure the specification includes at least one of the following properties: "mark", "layer", "facet", "hconcat", "vconcat", "concat", or "repeat".`}const Lqg='Autosize "fit" only works for single views and layered views.';function Wke(e){return`${e=="width"?"Width":"Height"} "container" only works for single views and layered views.`}function Xke(e){const g=e=="width"?"Width":"Height",i=e=="width"?"x":"y";return`${g} "container" only works well with autosize "fit" or "fit-${i}".`}function Tke(e){return e?`Dropping "fit-${e}" because spec has discrete ${FC(e)}.`:'Dropping "fit" because spec has discrete size.'}function sfe(e){return`Unknown field for ${e}. Cannot calculate view size.`}function Hke(e){return`Cannot project a selection on encoding channel "${e}", which has no field.`}function Uqg(e,g){return`Cannot project a selection on encoding channel "${e}" as it uses an aggregate function ("${g}").`}function Qqg(e){return`The "nearest" transform is not supported for ${e} marks.`}function sot(e){return`Selection not supported for ${e} yet.`}function jqg(e){return`Cannot find a selection named "${e}".`}const $qg="Scale bindings are currently only supported for scales with unbinned, continuous domains.",qqg="Legend bindings are only supported for selections over an individual field or encoding channel.";function eei(e){return`Lookups can only be performed on selection parameters. "${e}" is a variable parameter.`}function tei(e){return`Cannot define and lookup the "${e}" selection in the same view. Try moving the lookup into a second, layered view?`}const gei="The same selection must be used to override scale domains in a layered view.",iei='Interval selections should be initialized using "x", "y", "longitude", or "latitude" keys.';function nei(e){return`Unknown repeated value "${e}".`}function Nke(e){return`The "columns" property cannot be used when "${e}" has nested row/column.`}const Iei="Axes cannot be shared in concatenated or repeated views yet (https://github.com/vega/vega-lite/issues/2415).";function rei(e){return`Unrecognized parse "${e}".`}function kke(e,g,i){return`An ancestor parsed field "${e}" as ${i} but a child wants to parse the field as ${g}.`}const oei="Attempt to add the same child twice.";function Cei(e){return`Ignoring an invalid transform: ${Oi(e)}.`}const aei='If "from.fields" is not specified, "as" has to be a string that specifies the key to be used for the data from the secondary source.';function Yke(e){return`Config.customFormatTypes is not true, thus custom format type and format for channel ${e} are dropped.`}function sei(e){const{parentProjection:g,projection:i}=e;return`Layer's shared projection ${Oi(g)} is overridden by a child projection ${Oi(i)}.`}const Aei="Arc marks uses theta channel rather than angle, replacing angle with theta.";function lei(e){return`${e}Offset dropped because ${e} is continuous`}function cei(e){return`There is no ${e} encoding. Replacing ${e}Offset encoding as ${e}.`}function uei(e,g,i){return`Channel ${e} is a ${g}. Converted to {value: ${Oi(i)}}.`}function Aot(e){return`Invalid field type "${e}".`}function dei(e,g){return`Invalid field type "${e}" for aggregate: "${g}", using "quantitative" instead.`}function hei(e){return`Invalid aggregation operator "${e}".`}function lot(e,g){const{fill:i,stroke:n}=g;return`Dropping color ${e} as the plot also has ${i&&n?"fill and stroke":i?"fill":"stroke"}.`}function fei(e){return`Position range does not support relative band size for ${e}.`}function pIe(e,g){return`Dropping ${Oi(e)} from channel "${g}" since it does not contain any data field, datum, value, or signal.`}const mei="Line marks cannot encode size with a non-groupby field. You may want to use trail marks instead.";function CJ(e,g,i){return`${e} dropped as it is incompatible with "${g}"${i?` when ${i}`:""}.`}function pei(e){return`${e} encoding has no scale, so specified scale is ignored.`}function bei(e){return`${e}-encoding is dropped as ${e} is not a valid encoding channel.`}function yei(e){return`${e} encoding should be discrete (ordinal / nominal / binned).`}function Zei(e){return`${e} encoding should be discrete (ordinal / nominal / binned) or use a discretizing scale (e.g. threshold).`}function Gei(e){return`Facet encoding dropped as ${e.join(" and ")} ${e.length>1?"are":"is"} also specified.`}function E4(e,g){return`Using discrete channel "${e}" to encode "${g}" field can be misleading as it does not encode ${g==="ordinal"?"order":"magnitude"}.`}function vei(e){return`The ${e} for range marks cannot be an expression`}function Bei(e,g){return`Line mark is for continuous lines and thus cannot be used with ${e&&g?"x2 and y2":e?"x2":"y2"}. We will use the rule mark (line segments) instead.`}function wei(e,g){return`Specified orient "${e}" overridden with "${g}".`}function Sei(e){return`Cannot use the scale property "${e}" with non-color channel.`}function Rei(e){return`Cannot use the relative band size with ${e} scale.`}function Vei(e){return`Using unaggregated domain with raw field has no effect (${Oi(e)}).`}function Wei(e){return`Unaggregated domain not applicable for "${e}" since it produces values outside the origin domain of the source data.`}function Xei(e){return`Unaggregated domain is currently unsupported for log scale (${Oi(e)}).`}function Tei(e){return`Cannot apply size to non-oriented mark "${e}".`}function Hei(e,g,i){return`Channel "${e}" does not work with "${g}" scale. We are using "${i}" scale instead.`}function Nei(e,g){return`FieldDef does not work with "${e}" scale. We are using "${g}" scale instead.`}function cot(e,g,i){return`${i}-scale's "${g}" is dropped as it does not work with ${e} scale.`}function uot(e){return`The step for "${e}" is dropped because the ${e==="width"?"x":"y"} is continuous.`}function kei(e,g,i,n){return`Conflicting ${g.toString()} property "${e.toString()}" (${Oi(i)} and ${Oi(n)}). Using ${Oi(i)}.`}function Yei(e,g,i,n){return`Conflicting ${g.toString()} property "${e.toString()}" (${Oi(i)} and ${Oi(n)}). Using the union of the two domains.`}function Kei(e){return`Setting the scale to be independent for "${e}" means we also have to set the guide (axis or legend) to be independent.`}function xei(e){return`Dropping sort property ${Oi(e)} as unioned domains only support boolean or op "count", "min", and "max".`}const Kke="Domains that should be unioned has conflicting sort properties. Sort will be set to true.",Fei="Detected faceted independent scales that union domain of multiple fields from different data sources. We will use the first field. The result view size may be incorrect.",Eei="Detected faceted independent scales that union domain of the same fields from different source. We will assume that this is the same field from a different fork of the same data source. However, if this is not the case, the result view size may be incorrect.",Dei="Detected faceted independent scales that union domain of multiple fields from the same data source. We will use the first field. The result view size may be incorrect.";function Mei(e){return`Cannot stack "${e}" if there is already "${e}2".`}function zei(e){return`Cannot stack non-linear scale (${e}).`}function Pei(e){return`Stacking is applied even though the aggregate function is non-summative ("${e}").`}function h3(e,g){return`Invalid ${e}: ${Oi(g)}.`}function _ei(e){return`Dropping day from datetime ${Oi(e)} as day cannot be combined with other units.`}function Oei(e,g){return`${g?"extent ":""}${g&&e?"and ":""}${e?"center ":""}${g&&e?"are ":"is "}not needed when data are aggregated.`}function Jei(e,g,i){return`${e} is not usually used with ${g} for ${i}.`}function Lei(e,g){return`Continuous axis should not have customized aggregation function ${e}; ${g} already agregates the axis.`}function xke(e){return`1D error band does not support ${e}.`}function dot(e){return`Channel ${e} is required for "binned" bin.`}function Uei(e){return`Channel ${e} should not be used with "binned" bin.`}function Qei(e){return`Domain for ${e} is required for threshold scale.`}globalThis&&globalThis.__classPrivateFieldSet;globalThis&&globalThis.__classPrivateFieldGet;const hot=qle($le);let I1=hot;function jei(e){return I1=e,I1}function $ei(){return I1=hot,I1}function ut(...e){I1.warn(...e)}function qei(...e){I1.debug(...e)}function wZ(e){if(e&&Wt(e)){for(const g of lfe)if(g in e)return!0}return!1}const fot=["january","february","march","april","may","june","july","august","september","october","november","december"],eti=fot.map(e=>e.substr(0,3)),mot=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],tti=mot.map(e=>e.substr(0,3));function gti(e){if(qO(e)&&(e=+e),Vi(e))return e>4&&ut(h3("quarter",e)),e-1;throw new Error(h3("quarter",e))}function iti(e){if(qO(e)&&(e=+e),Vi(e))return e-1;{const g=e.toLowerCase(),i=fot.indexOf(g);if(i!==-1)return i;const n=g.substr(0,3),I=eti.indexOf(n);if(I!==-1)return I;throw new Error(h3("month",e))}}function nti(e){if(qO(e)&&(e=+e),Vi(e))return e%7;{const g=e.toLowerCase(),i=mot.indexOf(g);if(i!==-1)return i;const n=g.substr(0,3),I=tti.indexOf(n);if(I!==-1)return I;throw new Error(h3("day",e))}}function Afe(e,g){const i=[];if(g&&e.day!==void 0&&At(e).length>1&&(ut(_ei(e)),e=mg(e),delete e.day),e.year!==void 0?i.push(e.year):i.push(2012),e.month!==void 0){const n=g?iti(e.month):e.month;i.push(n)}else if(e.quarter!==void 0){const n=g?gti(e.quarter):e.quarter;i.push(Vi(n)?n*3:`${n}*3`)}else i.push(0);if(e.date!==void 0)i.push(e.date);else if(e.day!==void 0){const n=g?nti(e.day):e.day;i.push(Vi(n)?n+1:`${n}+1`)}else i.push(1);for(const n of["hours","minutes","seconds","milliseconds"]){const I=e[n];i.push(typeof I>"u"?0:I)}return i}function By(e){const i=Afe(e,!0).join(", ");return e.utc?`utc(${i})`:`datetime(${i})`}function Iti(e){const i=Afe(e,!1).join(", ");return e.utc?`utc(${i})`:`datetime(${i})`}function rti(e){const g=Afe(e,!0);return e.utc?+new Date(Date.UTC(...g)):+new Date(...g)}const pot={year:1,quarter:1,month:1,week:1,day:1,dayofyear:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1},lfe=At(pot);function oti(e){return!!pot[e]}function cfe(e){return e.startsWith("utc")}function Cti(e){return e.substr(3)}const ati={"year-month":"%b %Y ","year-month-date":"%b %d, %Y "};function aJ(e){return lfe.filter(g=>bot(e,g))}function sti(e){const g=aJ(e);return g[g.length-1]}function bot(e,g){const i=e.indexOf(g);return!(i<0||i>0&&g==="seconds"&&e.charAt(i-1)==="i"||e.length>i+3&&g==="day"&&e.charAt(i+3)==="o"||i>0&&g==="year"&&e.charAt(i-1)==="f")}function Ati(e,g,{end:i}={end:!1}){const n=qhe(g),I=cfe(e)?"utc":"";function r(a){return a==="quarter"?`(${I}quarter(${n})-1)`:`${I}${a}(${n})`}let o;const C={};for(const a of lfe)bot(e,a)&&(C[a]=r(a),o=a);return i&&(C[o]+="+1"),Iti(C)}function yot(e){if(!e)return;const g=aJ(e);return`timeUnitSpecifier(${Oi(g)}, ${Oi(ati)})`}function lti(e,g,i){if(!e)return;const n=yot(e);return`${i||cfe(e)?"utc":"time"}Format(${g}, ${n})`}function Zr(e){if(!e)return;let g;return Rt(e)?g={unit:e}:Wt(e)&&(g={...e,...e.unit?{unit:e.unit}:{}}),cfe(g.unit)&&(g.utc=!0,g.unit=Cti(g.unit)),g}function cti(e){const{utc:g,...i}=Zr(e);return i.unit?(g?"utc":"")+At(i).map(n=>dn(`${n==="unit"?"":`_${n}_`}${i[n]}`)).join(""):(g?"utc":"")+"timeunit"+At(i).map(n=>dn(`_${n}_${i[n]}`)).join("")}function Zot(e,g=i=>i){const i=Zr(e),n=sti(i.unit);if(n&&n!=="day"){const I={year:2001,month:1,date:1,hours:0,minutes:0,seconds:0,milliseconds:0},r=i.step||1,o={...I,...n==="quarter"?{month:+I.month+r*3}:{[n]:+I[n]+r}};return`${g(By(o))} - ${g(By(I))}`}}function uti(e){return e?.param}function ufe(e){return!!e?.field&&e.equal!==void 0}function dfe(e){return!!e?.field&&e.lt!==void 0}function hfe(e){return!!e?.field&&e.lte!==void 0}function ffe(e){return!!e?.field&&e.gt!==void 0}function mfe(e){return!!e?.field&&e.gte!==void 0}function pfe(e){if(e?.field){if(et(e.range)&&e.range.length===2)return!0;if(Qt(e.range))return!0}return!1}function bfe(e){return!!e?.field&&(et(e.oneOf)||et(e.in))}function dti(e){return!!e?.field&&e.valid!==void 0}function Got(e){return bfe(e)||ufe(e)||pfe(e)||dfe(e)||ffe(e)||hfe(e)||mfe(e)}function wl(e,g){return pJ(e,{timeUnit:g,wrapTime:!0})}function hti(e,g){return e.map(i=>wl(i,g))}function vot(e,g=!0){const{field:i}=e,n=Zr(e.timeUnit)?.unit,I=n?`time(${Ati(n,i)})`:Bt(e,{expr:"datum"});if(ufe(e))return`${I}===${wl(e.equal,n)}`;if(dfe(e)){const r=e.lt;return`${I}<${wl(r,n)}`}else if(ffe(e)){const r=e.gt;return`${I}>${wl(r,n)}`}else if(hfe(e)){const r=e.lte;return`${I}<=${wl(r,n)}`}else if(mfe(e)){const r=e.gte;return`${I}>=${wl(r,n)}`}else{if(bfe(e))return`indexof([${hti(e.oneOf,n).join(",")}], ${I}) !== -1`;if(dti(e))return yfe(I,e.valid);if(pfe(e)){const{range:r}=e,o=Qt(r)?{signal:`${r.signal}[0]`}:r[0],C=Qt(r)?{signal:`${r.signal}[1]`}:r[1];if(o!==null&&C!==null&&g)return"inrange("+I+", ["+wl(o,n)+", "+wl(C,n)+"])";const a=[];return o!==null&&a.push(`${I} >= ${wl(o,n)}`),C!==null&&a.push(`${I} <= ${wl(C,n)}`),a.length>0?a.join(" && "):"true"}}throw new Error(`Invalid field predicate: ${Oi(e)}`)}function yfe(e,g=!0){return g?`isValid(${e}) && isFinite(+${e})`:`!isValid(${e}) || !isFinite(+${e})`}function fti(e){return Got(e)&&e.timeUnit?{...e,timeUnit:Zr(e.timeUnit)?.unit}:e}const CN={quantitative:"quantitative",ordinal:"ordinal",temporal:"temporal",nominal:"nominal",geojson:"geojson"};function mti(e){return e==="quantitative"||e==="temporal"}function Bot(e){return e==="ordinal"||e==="nominal"}const wy=CN.quantitative,Zfe=CN.ordinal,r1=CN.temporal,Gfe=CN.nominal,RS=CN.geojson;function pti(e){if(e)switch(e=e.toLowerCase(),e){case"q":case wy:return"quantitative";case"t":case r1:return"temporal";case"o":case Zfe:return"ordinal";case"n":case Gfe:return"nominal";case RS:return"geojson"}}const XC={LINEAR:"linear",LOG:"log",POW:"pow",SQRT:"sqrt",SYMLOG:"symlog",IDENTITY:"identity",SEQUENTIAL:"sequential",TIME:"time",UTC:"utc",QUANTILE:"quantile",QUANTIZE:"quantize",THRESHOLD:"threshold",BIN_ORDINAL:"bin-ordinal",ORDINAL:"ordinal",POINT:"point",BAND:"band"},bIe={linear:"numeric",log:"numeric",pow:"numeric",sqrt:"numeric",symlog:"numeric",identity:"numeric",sequential:"numeric",time:"time",utc:"time",ordinal:"ordinal","bin-ordinal":"bin-ordinal",point:"ordinal-position",band:"ordinal-position",quantile:"discretizing",quantize:"discretizing",threshold:"discretizing"};function bti(e,g){const i=bIe[e],n=bIe[g];return i===n||i==="ordinal-position"&&n==="time"||n==="ordinal-position"&&i==="time"}const yti={linear:0,log:1,pow:1,sqrt:1,symlog:1,identity:1,sequential:1,time:0,utc:0,point:10,band:11,ordinal:0,"bin-ordinal":0,quantile:0,quantize:0,threshold:0};function Fke(e){return yti[e]}const wot=new Set(["linear","log","pow","sqrt","symlog"]),Sot=new Set([...wot,"time","utc"]);function Rot(e){return wot.has(e)}const Vot=new Set(["quantile","quantize","threshold"]),Zti=new Set([...Sot,...Vot,"sequential","identity"]),Gti=new Set(["ordinal","bin-ordinal","point","band"]);function UI(e){return Gti.has(e)}function va(e){return Zti.has(e)}function RA(e){return Sot.has(e)}function o1(e){return Vot.has(e)}const vti={pointPadding:.5,barBandPaddingInner:.1,rectBandPaddingInner:0,bandWithNestedOffsetPaddingInner:.2,bandWithNestedOffsetPaddingOuter:.2,minBandSize:2,minFontSize:8,maxFontSize:40,minOpacity:.3,maxOpacity:.8,minSize:9,minStrokeWidth:1,maxStrokeWidth:4,quantileCount:4,quantizeCount:4,zero:!0};function Bti(e){return!Rt(e)&&!!e.name}function Wot(e){return e?.param}function wti(e){return e?.unionWith}function Sti(e){return Wt(e)&&"field"in e}const Rti={type:1,domain:1,domainMax:1,domainMin:1,domainMid:1,align:1,range:1,rangeMax:1,rangeMin:1,scheme:1,bins:1,reverse:1,round:1,clamp:1,nice:1,base:1,exponent:1,constant:1,interpolate:1,zero:1,padding:1,paddingInner:1,paddingOuter:1},{type:bAi,domain:yAi,range:ZAi,rangeMax:GAi,rangeMin:vAi,scheme:BAi,...Vti}=Rti,Wti=At(Vti);function yIe(e,g){switch(g){case"type":case"domain":case"reverse":case"range":return!0;case"scheme":case"interpolate":return!["point","band","identity"].includes(e);case"bins":return!["point","band","identity","ordinal"].includes(e);case"round":return RA(e)||e==="band"||e==="point";case"padding":case"rangeMin":case"rangeMax":return RA(e)||["point","band"].includes(e);case"paddingOuter":case"align":return["point","band"].includes(e);case"paddingInner":return e==="band";case"domainMax":case"domainMid":case"domainMin":case"clamp":return RA(e);case"nice":return RA(e)||e==="quantize"||e==="threshold";case"exponent":return e==="pow";case"base":return e==="log";case"constant":return e==="symlog";case"zero":return va(e)&&!Eg(["log","time","utc","threshold","quantile"],e)}}function Xot(e,g){switch(g){case"interpolate":case"scheme":case"domainMid":return mB(e)?void 0:Sei(g);case"align":case"type":case"bins":case"domain":case"domainMax":case"domainMin":case"range":case"base":case"exponent":case"constant":case"nice":case"padding":case"paddingInner":case"paddingOuter":case"rangeMax":case"rangeMin":case"reverse":case"round":case"clamp":case"zero":return}}function Xti(e,g){return Eg([Zfe,Gfe],g)?e===void 0||UI(e):g===r1?Eg([XC.TIME,XC.UTC,void 0],e):g===wy?Rot(e)||o1(e)||e===void 0:!0}function Tti(e,g,i=!1){if(!uh(e))return!1;switch(e){case hn:case JI:case ap:case wS:case Bs:case Al:return RA(g)||g==="band"?!0:g==="point"?!i:!1;case lh:case lp:case ch:case sp:case Ap:case GZ:return RA(g)||o1(g)||Eg(["band","point","ordinal"],g);case KC:case ru:case ou:return g!=="band";case cp:case xC:return g==="ordinal"||o1(g)}}const Qo={arc:"arc",area:"area",bar:"bar",image:"image",line:"line",point:"point",rect:"rect",rule:"rule",text:"text",tick:"tick",trail:"trail",circle:"circle",square:"square",geoshape:"geoshape"},Tot=Qo.arc,sJ=Qo.area,AJ=Qo.bar,Hti=Qo.image,lJ=Qo.line,cJ=Qo.point,Nti=Qo.rect,f3=Qo.rule,Hot=Qo.text,vfe=Qo.tick,kti=Qo.trail,Bfe=Qo.circle,wfe=Qo.square,Not=Qo.geoshape;function hp(e){return["line","area","trail"].includes(e)}function kot(e){return["rect","bar","image","arc"].includes(e)}const Yti=new Set(At(Qo));function Dc(e){return e.type}const Kti=["stroke","strokeWidth","strokeDash","strokeDashOffset","strokeOpacity","strokeJoin","strokeMiterLimit"],xti=["fill","fillOpacity"],Fti=[...Kti,...xti],Eti={color:1,filled:1,invalid:1,order:1,radius2:1,theta2:1,timeUnitBandSize:1,timeUnitBandPosition:1},Eke=At(Eti),Dti={area:["line","point"],bar:["binSpacing","continuousBandSize","discreteBandSize"],rect:["binSpacing","continuousBandSize","discreteBandSize"],line:["point"],tick:["bandSize","thickness"]},Mti={color:"#4c78a8",invalid:"filter",timeUnitBandSize:1},zti={mark:1,arc:1,area:1,bar:1,circle:1,image:1,line:1,point:1,rect:1,rule:1,square:1,text:1,tick:1,trail:1,geoshape:1},Yot=At(zti);function Sy(e){return e&&e.band!=null}const Pti={horizontal:["cornerRadiusTopRight","cornerRadiusBottomRight"],vertical:["cornerRadiusTopLeft","cornerRadiusTopRight"]},Kot=5,_ti={binSpacing:1,continuousBandSize:Kot,timeUnitBandPosition:.5},Oti={binSpacing:0,continuousBandSize:Kot,timeUnitBandPosition:.5},Jti={thickness:1};function Lti(e){return Dc(e)?e.type:e}function Sfe(e){const{channel:g,channelDef:i,markDef:n,scale:I,config:r}=e,o=Vfe(e);return dt(i)&&!eot(i.aggregate)&&I&&RA(I.get("type"))?Uti({fieldDef:i,channel:g,markDef:n,ref:o,config:r}):o}function Uti({fieldDef:e,channel:g,markDef:i,ref:n,config:I}){return hp(i.type)?n:di("invalid",i,I)===null?[Qti(e,g),n]:n}function Qti(e,g){const i=Rfe(e,!0),I=vZ(g)==="y"?{field:{group:"height"}}:{value:0};return{test:i,...I}}function Rfe(e,g=!0){return yfe(Rt(e)?e:Bt(e,{expr:"datum"}),!g)}function jti(e){const{datum:g}=e;return wZ(g)?By(g):`${Oi(g)}`}function Cb(e,g,i,n){const I={};if(g&&(I.scale=g),su(e)){const{datum:r}=e;wZ(r)?I.signal=By(r):Qt(r)?I.signal=r.signal:oN(r)?I.signal=r.expr:I.value=r}else I.field=Bt(e,i);if(n){const{offset:r,band:o}=n;r&&(I.offset=r),o&&(I.band=o)}return I}function m3({scaleName:e,fieldOrDatumDef:g,fieldOrDatumDef2:i,offset:n,startSuffix:I,bandPosition:r=.5}){const o=0{switch(g.fieldTitle){case"plain":return e.field;case"functional":return sgi(e);default:return agi(e,g)}};let jot=Qot;function $ot(e){jot=e}function Agi(){$ot(Qot)}function pB(e,g,{allowDisabling:i,includeDefault:n=!0}){const I=Hfe(e)?.title;if(!dt(e))return I??e.title;const r=e,o=n?Nfe(r,g):void 0;return i?CI(I,r.title,o):I??r.title??o}function Hfe(e){if(a1(e)&&e.axis)return e.axis;if(Lot(e)&&e.legend)return e.legend;if(Xfe(e)&&e.header)return e.header}function Nfe(e,g){return jot(e,g)}function y3(e){if(Uot(e)){const{format:g,formatType:i}=e;return{format:g,formatType:i}}else{const g=Hfe(e)??{},{format:i,formatType:n}=g;return{format:i,formatType:n}}}function lgi(e,g){switch(g){case"latitude":case"longitude":return"quantitative";case"row":case"column":case"facet":case"shape":case"strokeDash":return"nominal";case"order":return"ordinal"}if(Tfe(e)&&et(e.sort))return"ordinal";const{aggregate:i,bin:n,timeUnit:I}=e;if(I)return"temporal";if(n||i&&!up(i)&&!Pd(i))return"quantitative";if(SZ(e)&&e.scale?.type)switch(bIe[e.scale.type]){case"numeric":case"discretizing":return"quantitative";case"time":return"temporal"}return"nominal"}function Mc(e){if(dt(e))return e;if(fJ(e))return e.condition}function ZI(e){if(fg(e))return e;if(AN(e))return e.condition}function qot(e,g,i,n={}){if(Rt(e)||Vi(e)||gp(e)){const I=Rt(e)?"string":Vi(e)?"number":"boolean";return ut(uei(g,I,e)),{value:e}}return fg(e)?Z3(e,g,i,n):AN(e)?{...e,condition:Z3(e.condition,g,i,n)}:e}function Z3(e,g,i,n){if(Uot(e)){const{format:I,formatType:r,...o}=e;if(Ry(r)&&!i.customFormatTypes)return ut(Yke(g)),Z3(o,g,i,n)}else{const I=a1(e)?"axis":Lot(e)?"legend":Xfe(e)?"header":null;if(I&&e[I]){const{format:r,formatType:o,...C}=e[I];if(Ry(o)&&!i.customFormatTypes)return ut(Yke(g)),Z3({...e,[I]:C},g,i,n)}}return dt(e)?kfe(e,g,n):cgi(e)}function cgi(e){let g=e.type;if(g)return e;const{datum:i}=e;return g=Vi(i)?"quantitative":Rt(i)?"nominal":wZ(i)?"temporal":void 0,{...e,type:g}}function kfe(e,g,{compositeMark:i=!1}={}){const{aggregate:n,timeUnit:I,bin:r,field:o}=e,C={...e};if(!i&&n&&!Cfe(n)&&!up(n)&&!Pd(n)&&(ut(hei(n)),delete C.aggregate),I&&(C.timeUnit=Zr(I)),o&&(C.field=`${o}`),Ji(r)&&(C.bin=mJ(r,g)),or(r)&&!LI(g)&&ut(Uei(g)),Po(C)){const{type:a}=C,A=pti(a);a!==A&&(C.type=A),a!=="quantitative"&&eot(n)&&(ut(dei(a,n)),C.type="quantitative")}else if(!Jrt(g)){const a=lgi(C,g);C.type=a}if(Po(C)){const{compatible:a,warning:A}=ugi(C,g)||{};a===!1&&ut(A)}if(Tfe(C)&&Rt(C.sort)){const{sort:a}=C;if(Mke(a))return{...C,sort:{encoding:a}};const A=a.substr(1);if(a.charAt(0)==="-"&&Mke(A))return{...C,sort:{encoding:A,order:"descending"}}}if(Xfe(C)){const{header:a}=C;if(a){const{orient:A,...s}=a;if(A)return{...C,header:{...s,labelOrient:a.labelOrient||A,titleOrient:a.titleOrient||A}}}}return C}function mJ(e,g){return gp(e)?{maxbins:Ske(g)}:e==="binned"?{binned:!0}:!e.maxbins&&!e.step?{...e,maxbins:Ske(g)}:e}const yG={compatible:!0};function ugi(e,g){const i=e.type;if(i==="geojson"&&g!=="shape")return{compatible:!1,warning:`Channel ${g} should not be used with a geojson data.`};switch(g){case yd:case Zd:case eJ:return b3(e)?yG:{compatible:!1,warning:yei(g)};case hn:case JI:case ap:case wS:case KC:case ru:case ou:case nN:case rN:case tJ:case Gy:case gJ:case iJ:case GZ:case Bs:case Al:case nJ:return yG;case cl:case Zs:case ll:case ul:return i!==wy?{compatible:!1,warning:`Channel ${g} should be used with a quantitative field only, not ${e.type} field.`}:yG;case ch:case sp:case Ap:case lp:case lh:case Ah:case sh:case sl:case Iu:return i==="nominal"&&!e.sort?{compatible:!1,warning:`Channel ${g} should not be used with an unsorted discrete field.`}:yG;case xC:case cp:return!b3(e)&&!ogi(e)?{compatible:!1,warning:Zei(g)}:yG;case IN:return e.type==="nominal"&&!("sort"in e)?{compatible:!1,warning:"Channel order is inappropriate for nominal field, which has no inherent order."}:yG}}function s1(e){const{formatType:g}=y3(e);return g==="time"||!g&&dgi(e)}function dgi(e){return e&&(e.type==="temporal"||dt(e)&&!!e.timeUnit)}function pJ(e,{timeUnit:g,type:i,wrapTime:n,undefinedIfExprNotRequired:I}){const r=g&&Zr(g)?.unit;let o=r||i==="temporal",C;return oN(e)?C=e.expr:Qt(e)?C=e.signal:wZ(e)?(o=!0,C=By(e)):(Rt(e)||Vi(e))&&o&&(C=`datetime(${Oi(e)})`,oti(r)&&(Vi(e)&&e<1e4||Rt(e)&&isNaN(Date.parse(e)))&&(C=By({[r]:e}))),C?n&&o?`time(${C})`:C:I?void 0:Oi(e)}function eCt(e,g){const{type:i}=e;return g.map(n=>{const I=pJ(n,{timeUnit:dt(e)?e.timeUnit:void 0,type:i,undefinedIfExprNotRequired:!0});return I!==void 0?{signal:I}:n})}function lN(e,g){return Ji(e.bin)?uh(g)&&["ordinal","nominal"].includes(e.type):(console.warn("Only call this method for binned field defs."),!1)}const _ke={labelAlign:{part:"labels",vgProp:"align"},labelBaseline:{part:"labels",vgProp:"baseline"},labelColor:{part:"labels",vgProp:"fill"},labelFont:{part:"labels",vgProp:"font"},labelFontSize:{part:"labels",vgProp:"fontSize"},labelFontStyle:{part:"labels",vgProp:"fontStyle"},labelFontWeight:{part:"labels",vgProp:"fontWeight"},labelOpacity:{part:"labels",vgProp:"opacity"},labelOffset:null,labelPadding:null,gridColor:{part:"grid",vgProp:"stroke"},gridDash:{part:"grid",vgProp:"strokeDash"},gridDashOffset:{part:"grid",vgProp:"strokeDashOffset"},gridOpacity:{part:"grid",vgProp:"opacity"},gridWidth:{part:"grid",vgProp:"strokeWidth"},tickColor:{part:"ticks",vgProp:"stroke"},tickDash:{part:"ticks",vgProp:"strokeDash"},tickDashOffset:{part:"ticks",vgProp:"strokeDashOffset"},tickOpacity:{part:"ticks",vgProp:"opacity"},tickSize:null,tickWidth:{part:"ticks",vgProp:"strokeWidth"}};function cN(e){return e?.condition}const tCt=["domain","grid","labels","ticks","title"],hgi={grid:"grid",gridCap:"grid",gridColor:"grid",gridDash:"grid",gridDashOffset:"grid",gridOpacity:"grid",gridScale:"grid",gridWidth:"grid",orient:"main",bandPosition:"both",aria:"main",description:"main",domain:"main",domainCap:"main",domainColor:"main",domainDash:"main",domainDashOffset:"main",domainOpacity:"main",domainWidth:"main",format:"main",formatType:"main",labelAlign:"main",labelAngle:"main",labelBaseline:"main",labelBound:"main",labelColor:"main",labelFlush:"main",labelFlushOffset:"main",labelFont:"main",labelFontSize:"main",labelFontStyle:"main",labelFontWeight:"main",labelLimit:"main",labelLineHeight:"main",labelOffset:"main",labelOpacity:"main",labelOverlap:"main",labelPadding:"main",labels:"main",labelSeparation:"main",maxExtent:"main",minExtent:"main",offset:"both",position:"main",tickCap:"main",tickColor:"main",tickDash:"main",tickDashOffset:"main",tickMinStep:"both",tickOffset:"both",tickOpacity:"main",tickRound:"both",ticks:"main",tickSize:"main",tickWidth:"both",title:"main",titleAlign:"main",titleAnchor:"main",titleAngle:"main",titleBaseline:"main",titleColor:"main",titleFont:"main",titleFontSize:"main",titleFontStyle:"main",titleFontWeight:"main",titleLimit:"main",titleLineHeight:"main",titleOpacity:"main",titlePadding:"main",titleX:"main",titleY:"main",encode:"both",scale:"both",tickBand:"both",tickCount:"both",tickExtra:"both",translate:"both",values:"both",zindex:"both"},gCt={orient:1,aria:1,bandPosition:1,description:1,domain:1,domainCap:1,domainColor:1,domainDash:1,domainDashOffset:1,domainOpacity:1,domainWidth:1,format:1,formatType:1,grid:1,gridCap:1,gridColor:1,gridDash:1,gridDashOffset:1,gridOpacity:1,gridWidth:1,labelAlign:1,labelAngle:1,labelBaseline:1,labelBound:1,labelColor:1,labelFlush:1,labelFlushOffset:1,labelFont:1,labelFontSize:1,labelFontStyle:1,labelFontWeight:1,labelLimit:1,labelLineHeight:1,labelOffset:1,labelOpacity:1,labelOverlap:1,labelPadding:1,labels:1,labelSeparation:1,maxExtent:1,minExtent:1,offset:1,position:1,tickBand:1,tickCap:1,tickColor:1,tickCount:1,tickDash:1,tickDashOffset:1,tickExtra:1,tickMinStep:1,tickOffset:1,tickOpacity:1,tickRound:1,ticks:1,tickSize:1,tickWidth:1,title:1,titleAlign:1,titleAnchor:1,titleAngle:1,titleBaseline:1,titleColor:1,titleFont:1,titleFontSize:1,titleFontStyle:1,titleFontWeight:1,titleLimit:1,titleLineHeight:1,titleOpacity:1,titlePadding:1,titleX:1,titleY:1,translate:1,values:1,zindex:1},fgi={...gCt,style:1,labelExpr:1,encoding:1};function Oke(e){return!!fgi[e]}const mgi={axis:1,axisBand:1,axisBottom:1,axisDiscrete:1,axisLeft:1,axisPoint:1,axisQuantitative:1,axisRight:1,axisTemporal:1,axisTop:1,axisX:1,axisXBand:1,axisXDiscrete:1,axisXPoint:1,axisXQuantitative:1,axisXTemporal:1,axisY:1,axisYBand:1,axisYDiscrete:1,axisYPoint:1,axisYQuantitative:1,axisYTemporal:1},iCt=At(mgi);function dh(e){return"mark"in e}class bJ{constructor(g,i){this.name=g,this.run=i}hasMatchingType(g){return dh(g)?Lti(g.mark)===this.name:!1}}function ab(e,g){const i=e&&e[g];return i?et(i)?yy(i,n=>!!n.field):dt(i)||fJ(i):!1}function nCt(e,g){const i=e&&e[g];return i?et(i)?yy(i,n=>!!n.field):dt(i)||su(i)||AN(i):!1}function GIe(e,g){if(LI(g)){const i=e[g];if((dt(i)||su(i))&&(Bot(i.type)||dt(i)&&i.timeUnit)){const n=nfe(g);return nCt(e,n)}}return!1}function Yfe(e){return yy(yqg,g=>{if(ab(e,g)){const i=e[g];if(et(i))return yy(i,n=>!!n.aggregate);{const n=Mc(i);return n&&!!n.aggregate}}return!1})}function ICt(e,g){const i=[],n=[],I=[],r=[],o={};return Kfe(e,(C,a)=>{if(dt(C)){const{field:A,aggregate:s,bin:l,timeUnit:c,...u}=C;if(s||c||l){const h=Hfe(C)?.title;let f=Bt(C,{forAs:!0});const m={...h?[]:{title:pB(C,g,{allowDisabling:!0})},...u,field:f};if(s){let b;if(up(s)?(b="argmax",f=Bt({op:"argmax",field:s.argmax},{forAs:!0}),m.field=`${f}.${A}`):Pd(s)?(b="argmin",f=Bt({op:"argmin",field:s.argmin},{forAs:!0}),m.field=`${f}.${A}`):s!=="boxplot"&&s!=="errorbar"&&s!=="errorband"&&(b=s),b){const p={op:b,as:f};A&&(p.field=A),r.push(p)}}else if(i.push(f),Po(C)&&Ji(l)){if(n.push({bin:l,field:A,as:f}),i.push(Bt(C,{binSuffix:"end"})),lN(C,a)&&i.push(Bt(C,{binSuffix:"range"})),LI(a)){const b={field:`${f}_end`};o[`${a}2`]=b}m.bin="binned",Jrt(a)||(m.type=wy)}else if(c){I.push({timeUnit:c,field:A,as:f});const b=Po(C)&&C.type!==r1&&"time";b&&(a===nN||a===Gy?m.formatType=b:Wqg(a)?m.legend={formatType:b,...m.legend}:LI(a)&&(m.axis={formatType:b,...m.axis}))}o[a]=m}else i.push(A),o[a]=e[a]}else o[a]=e[a]}),{bins:n,timeUnits:I,aggregate:r,groupby:i,encoding:o}}function pgi(e,g,i){const n=Tqg(g,i);if(n){if(n==="binned"){const I=e[g===sl?hn:JI];return!!(dt(I)&&dt(e[g])&&or(I.bin))}}else return!1;return!0}function bgi(e,g,i,n){const I={};for(const r of At(e))Ort(r)||ut(bei(r));for(let r of wqg){if(!e[r])continue;const o=e[r];if(SS(r)){const C=Urt(r),a=I[C];if(dt(a)){if(mti(a.type)&&dt(o)&&!a.timeUnit){ut(lei(C));continue}}else r=C,ut(cei(C))}if(r==="angle"&&g==="arc"&&!e.theta&&(ut(Aei),r=Bs),!pgi(e,r,g)){ut(CJ(r,g));continue}if(r===lh&&g==="line"&&Mc(e[r])?.aggregate){ut(mei);continue}if(r===KC&&(i?"fill"in e:"stroke"in e)){ut(lot("encoding",{fill:"fill"in e,stroke:"stroke"in e}));continue}if(r===rN||r===IN&&!et(o)&&!QA(o)||r===Gy&&et(o))o&&(I[r]=Vt(o).reduce((C,a)=>(dt(a)?C.push(kfe(a,r)):ut(pIe(a,r)),C),[]));else{if(r===Gy&&o===null)I[r]=null;else if(!dt(o)&&!su(o)&&!QA(o)&&!hJ(o)&&!Qt(o)){ut(pIe(o,r));continue}I[r]=qot(o,r,n)}}return I}function yJ(e,g){const i={};for(const n of At(e)){const I=qot(e[n],n,g,{compositeMark:!0});i[n]=I}return i}function ygi(e){const g=[];for(const i of At(e))if(ab(e,i)){const n=e[i],I=Vt(n);for(const r of I)dt(r)?g.push(r):fJ(r)&&g.push(r.condition)}return g}function Kfe(e,g,i){if(e)for(const n of At(e)){const I=e[n];if(et(I))for(const r of I)g.call(i,r,n);else g.call(i,I,n)}}function Zgi(e,g,i,n){return e?At(e).reduce((I,r)=>{const o=e[r];return et(o)?o.reduce((C,a)=>g.call(n,C,a,r),I):g.call(n,I,o,r)},i):i}function rCt(e,g){return At(g).reduce((i,n)=>{switch(n){case hn:case JI:case gJ:case nJ:case iJ:case sl:case Iu:case ap:case wS:case Bs:case Ah:case Al:case sh:case ll:case cl:case ul:case Zs:case nN:case xC:case GZ:case Gy:return i;case IN:if(e==="line"||e==="trail")return i;case rN:case tJ:{const I=g[n];if(et(I)||dt(I))for(const r of Vt(I))r.aggregate||i.push(Bt(r,{}));return i}case lh:if(e==="trail")return i;case KC:case ru:case ou:case ch:case sp:case Ap:case cp:case lp:{const I=Mc(g[n]);return I&&!I.aggregate&&i.push(Bt(I,{})),i}}},[])}function Ggi(e){const{tooltip:g,...i}=e;if(!g)return{filteredEncoding:i};let n,I;if(et(g)){for(const r of g)r.aggregate?(n||(n=[]),n.push(r)):(I||(I=[]),I.push(r));n&&(i.tooltip=n)}else g.aggregate?i.tooltip=g:I=g;return et(I)&&I.length===1&&(I=I[0]),{customTooltipWithoutAggregatedField:I,filteredEncoding:i}}function vIe(e,g,i,n=!0){if("tooltip"in i)return{tooltip:i.tooltip};const I=e.map(({fieldPrefix:o,titlePrefix:C})=>{const a=n?` of ${xfe(g)}`:"";return{field:o+g.field,type:g.type,title:Qt(C)?{signal:`${C}"${escape(a)}"`}:C+a}}),r=ygi(i).map(Igi);return{tooltip:[...I,...Ic(r,$g)]}}function xfe(e){const{title:g,field:i}=e;return CI(g,i)}function Ffe(e,g,i,n,I){const{scale:r,axis:o}=i;return({partName:C,mark:a,positionPrefix:A,endPositionPrefix:s=void 0,extraEncoding:l={}})=>{const c=xfe(i);return oCt(e,C,I,{mark:a,encoding:{[g]:{field:`${A}_${i.field}`,type:i.type,...c!==void 0?{title:c}:{},...r!==void 0?{scale:r}:{},...o!==void 0?{axis:o}:{}},...Rt(s)?{[`${g}2`]:{field:`${s}_${i.field}`}}:{},...n,...l}})}}function oCt(e,g,i,n){const{clip:I,color:r,opacity:o}=e,C=e.type;return e[g]||e[g]===void 0&&i[g]?[{...n,mark:{...i[g],...I?{clip:I}:{},...r?{color:r}:{},...o?{opacity:o}:{},...Dc(n.mark)?n.mark:{type:n.mark},style:`${C}-${String(g)}`,...gp(e[g])?{}:e[g]}}]:[]}function CCt(e,g,i){const{encoding:n}=e,I=g==="vertical"?"y":"x",r=n[I],o=n[`${I}2`],C=n[`${I}Error`],a=n[`${I}Error2`];return{continuousAxisChannelDef:oK(r,i),continuousAxisChannelDef2:oK(o,i),continuousAxisChannelDefError:oK(C,i),continuousAxisChannelDefError2:oK(a,i),continuousAxis:I}}function oK(e,g){if(e?.aggregate){const{aggregate:i,...n}=e;return i!==g&&ut(Lei(i,g)),n}else return e}function aCt(e,g){const{mark:i,encoding:n}=e,{x:I,y:r}=n;if(Dc(i)&&i.orient)return i.orient;if(Kf(I)){if(Kf(r)){const o=dt(I)&&I.aggregate,C=dt(r)&&r.aggregate;if(!o&&C===g)return"vertical";if(!C&&o===g)return"horizontal";if(o===g&&C===g)throw new Error("Both x and y cannot have aggregate");return s1(r)&&!s1(I)?"horizontal":"vertical"}return"horizontal"}else{if(Kf(r))return"vertical";throw new Error(`Need a valid continuous axis for ${g}s`)}}const G3="boxplot",vgi=["box","median","outliers","rule","ticks"],Bgi=new bJ(G3,ACt);function sCt(e){return Vi(e)?"tukey":e}function ACt(e,{config:g}){e={...e,encoding:yJ(e.encoding,g)};const{mark:i,encoding:n,params:I,projection:r,...o}=e,C=Dc(i)?i:{type:i};I&&ut(sot("boxplot"));const a=C.extent??g.boxplot.extent,A=di("size",C,g),s=C.invalid,l=sCt(a),{bins:c,timeUnits:u,transform:d,continuousAxisChannelDef:h,continuousAxis:f,groupby:m,aggregate:b,encodingWithoutContinuousAxis:p,ticksOrient:y,boxOrient:Z,customTooltipWithoutAggregatedField:v}=wgi(e,a,g),{color:G,size:B,...S}=p,R=Be=>Ffe(C,f,h,Be,g.boxplot),w=R(S),T=R(p),W=R({...S,...B?{size:B}:{}}),V=vIe([{fieldPrefix:l==="min-max"?"upper_whisker_":"max_",titlePrefix:"Max"},{fieldPrefix:"upper_box_",titlePrefix:"Q3"},{fieldPrefix:"mid_box_",titlePrefix:"Median"},{fieldPrefix:"lower_box_",titlePrefix:"Q1"},{fieldPrefix:l==="min-max"?"lower_whisker_":"min_",titlePrefix:"Min"}],h,p),X={type:"tick",color:"black",opacity:1,orient:y,invalid:s,aria:!1},N=l==="min-max"?V:vIe([{fieldPrefix:"upper_whisker_",titlePrefix:"Upper Whisker"},{fieldPrefix:"lower_whisker_",titlePrefix:"Lower Whisker"}],h,p),Y=[...w({partName:"rule",mark:{type:"rule",invalid:s,aria:!1},positionPrefix:"lower_whisker",endPositionPrefix:"lower_box",extraEncoding:N}),...w({partName:"rule",mark:{type:"rule",invalid:s,aria:!1},positionPrefix:"upper_box",endPositionPrefix:"upper_whisker",extraEncoding:N}),...w({partName:"ticks",mark:X,positionPrefix:"lower_whisker",extraEncoding:N}),...w({partName:"ticks",mark:X,positionPrefix:"upper_whisker",extraEncoding:N})],x=[...l!=="tukey"?Y:[],...T({partName:"box",mark:{type:"bar",...A?{size:A}:{},orient:Z,invalid:s,ariaRoleDescription:"box"},positionPrefix:"lower_box",endPositionPrefix:"upper_box",extraEncoding:V}),...W({partName:"median",mark:{type:"tick",invalid:s,...Wt(g.boxplot.median)&&g.boxplot.median.color?{color:g.boxplot.median.color}:{},...A?{size:A}:{},orient:y,aria:!1},positionPrefix:"mid_box",extraEncoding:V})];if(l==="min-max")return{...o,transform:(o.transform??[]).concat(d),layer:x};const M=`datum["lower_box_${h.field}"]`,F=`datum["upper_box_${h.field}"]`,$=`(${F} - ${M})`,Q=`${M} - ${a} * ${$}`,U=`${F} + ${a} * ${$}`,j=`datum["${h.field}"]`,ee={joinaggregate:lCt(h.field),groupby:m},Ie={transform:[{filter:`(${Q} <= ${j}) && (${j} <= ${U})`},{aggregate:[{op:"min",field:h.field,as:`lower_whisker_${h.field}`},{op:"max",field:h.field,as:`upper_whisker_${h.field}`},{op:"min",field:`lower_box_${h.field}`,as:`lower_box_${h.field}`},{op:"max",field:`upper_box_${h.field}`,as:`upper_box_${h.field}`},...b],groupby:m}],layer:Y},{tooltip:fe,...Ve}=S,{scale:oe,axis:pe}=h,ae=xfe(h),ie=WC(pe,["title"]),ye=oCt(C,"outliers",g.boxplot,{transform:[{filter:`(${j} < ${Q}) || (${j} > ${U})`}],mark:"point",encoding:{[f]:{field:h.field,type:h.type,...ae!==void 0?{title:ae}:{},...oe!==void 0?{scale:oe}:{},...Ri(ie)?{}:{axis:ie}},...Ve,...G?{color:G}:{},...v?{tooltip:v}:{}}})[0];let ue;const Ye=[...c,...u,ee];return ye?ue={transform:Ye,layer:[ye,Ie]}:(ue=Ie,ue.transform.unshift(...Ye)),{...o,layer:[ue,{transform:d,layer:x}]}}function lCt(e){return[{op:"q1",field:e,as:`lower_box_${e}`},{op:"q3",field:e,as:`upper_box_${e}`}]}function wgi(e,g,i){const n=aCt(e,G3),{continuousAxisChannelDef:I,continuousAxis:r}=CCt(e,n,G3),o=I.field,C=sCt(g),a=[...lCt(o),{op:"median",field:o,as:`mid_box_${o}`},{op:"min",field:o,as:(C==="min-max"?"lower_whisker_":"min_")+o},{op:"max",field:o,as:(C==="min-max"?"upper_whisker_":"max_")+o}],A=C==="min-max"||C==="tukey"?[]:[{calculate:`datum["upper_box_${o}"] - datum["lower_box_${o}"]`,as:`iqr_${o}`},{calculate:`min(datum["upper_box_${o}"] + datum["iqr_${o}"] * ${g}, datum["max_${o}"])`,as:`upper_whisker_${o}`},{calculate:`max(datum["lower_box_${o}"] - datum["iqr_${o}"] * ${g}, datum["min_${o}"])`,as:`lower_whisker_${o}`}],{[r]:s,...l}=e.encoding,{customTooltipWithoutAggregatedField:c,filteredEncoding:u}=Ggi(l),{bins:d,timeUnits:h,aggregate:f,groupby:m,encoding:b}=ICt(u,i),p=n==="vertical"?"horizontal":"vertical",y=n,Z=[...d,...h,{aggregate:[...f,...a],groupby:m},...A];return{bins:d,timeUnits:h,transform:Z,groupby:m,aggregate:f,continuousAxisChannelDef:I,continuousAxis:r,encodingWithoutContinuousAxis:b,ticksOrient:p,boxOrient:y,customTooltipWithoutAggregatedField:c}}const Efe="errorbar",Sgi=["ticks","rule"],Rgi=new bJ(Efe,cCt);function cCt(e,{config:g}){e={...e,encoding:yJ(e.encoding,g)};const{transform:i,continuousAxisChannelDef:n,continuousAxis:I,encodingWithoutContinuousAxis:r,ticksOrient:o,markDef:C,outerSpec:a,tooltipEncoding:A}=uCt(e,Efe,g);delete r.size;const s=Ffe(C,I,n,r,g.errorbar),l=C.thickness,c=C.size,u={type:"tick",orient:o,aria:!1,...l!==void 0?{thickness:l}:{},...c!==void 0?{size:c}:{}},d=[...s({partName:"ticks",mark:u,positionPrefix:"lower",extraEncoding:A}),...s({partName:"ticks",mark:u,positionPrefix:"upper",extraEncoding:A}),...s({partName:"rule",mark:{type:"rule",ariaRoleDescription:"errorbar",...l!==void 0?{size:l}:{}},positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:A})];return{...a,transform:i,...d.length>1?{layer:d}:{...d[0]}}}function Vgi(e,g){const{encoding:i}=e;if(Wgi(i))return{orient:aCt(e,g),inputType:"raw"};const n=Xgi(i),I=Tgi(i),r=i.x,o=i.y;if(n){if(I)throw new Error(`${g} cannot be both type aggregated-upper-lower and aggregated-error`);const C=i.x2,a=i.y2;if(fg(C)&&fg(a))throw new Error(`${g} cannot have both x2 and y2`);if(fg(C)){if(Kf(r))return{orient:"horizontal",inputType:"aggregated-upper-lower"};throw new Error(`Both x and x2 have to be quantitative in ${g}`)}else if(fg(a)){if(Kf(o))return{orient:"vertical",inputType:"aggregated-upper-lower"};throw new Error(`Both y and y2 have to be quantitative in ${g}`)}throw new Error("No ranged axis")}else{const C=i.xError,a=i.xError2,A=i.yError,s=i.yError2;if(fg(a)&&!fg(C))throw new Error(`${g} cannot have xError2 without xError`);if(fg(s)&&!fg(A))throw new Error(`${g} cannot have yError2 without yError`);if(fg(C)&&fg(A))throw new Error(`${g} cannot have both xError and yError with both are quantiative`);if(fg(C)){if(Kf(r))return{orient:"horizontal",inputType:"aggregated-error"};throw new Error("All x, xError, and xError2 (if exist) have to be quantitative")}else if(fg(A)){if(Kf(o))return{orient:"vertical",inputType:"aggregated-error"};throw new Error("All y, yError, and yError2 (if exist) have to be quantitative")}throw new Error("No ranged axis")}}function Wgi(e){return(fg(e.x)||fg(e.y))&&!fg(e.x2)&&!fg(e.y2)&&!fg(e.xError)&&!fg(e.xError2)&&!fg(e.yError)&&!fg(e.yError2)}function Xgi(e){return fg(e.x2)||fg(e.y2)}function Tgi(e){return fg(e.xError)||fg(e.xError2)||fg(e.yError)||fg(e.yError2)}function uCt(e,g,i){const{mark:n,encoding:I,params:r,projection:o,...C}=e,a=Dc(n)?n:{type:n};r&&ut(sot(g));const{orient:A,inputType:s}=Vgi(e,g),{continuousAxisChannelDef:l,continuousAxisChannelDef2:c,continuousAxisChannelDefError:u,continuousAxisChannelDefError2:d,continuousAxis:h}=CCt(e,A,g),{errorBarSpecificAggregate:f,postAggregateCalculates:m,tooltipSummary:b,tooltipTitleWithFieldName:p}=Hgi(a,l,c,u,d,s,g,i),{[h]:y,[h==="x"?"x2":"y2"]:Z,[h==="x"?"xError":"yError"]:v,[h==="x"?"xError2":"yError2"]:G,...B}=I,{bins:S,timeUnits:R,aggregate:w,groupby:T,encoding:W}=ICt(B,i),V=[...w,...f],X=s!=="raw"?[]:T,N=vIe(b,l,W,p);return{transform:[...C.transform??[],...S,...R,...V.length===0?[]:[{aggregate:V,groupby:X}],...m],groupby:X,continuousAxisChannelDef:l,continuousAxis:h,encodingWithoutContinuousAxis:W,ticksOrient:A==="vertical"?"horizontal":"vertical",markDef:a,outerSpec:C,tooltipEncoding:N}}function Hgi(e,g,i,n,I,r,o,C){let a=[],A=[];const s=g.field;let l,c=!1;if(r==="raw"){const u=e.center?e.center:e.extent?e.extent==="iqr"?"median":"mean":C.errorbar.center,d=e.extent?e.extent:u==="mean"?"stderr":"iqr";if(u==="median"!=(d==="iqr")&&ut(Jei(u,d,o)),d==="stderr"||d==="stdev")a=[{op:d,field:s,as:`extent_${s}`},{op:u,field:s,as:`center_${s}`}],A=[{calculate:`datum["center_${s}"] + datum["extent_${s}"]`,as:`upper_${s}`},{calculate:`datum["center_${s}"] - datum["extent_${s}"]`,as:`lower_${s}`}],l=[{fieldPrefix:"center_",titlePrefix:iN(u)},{fieldPrefix:"upper_",titlePrefix:Jke(u,d,"+")},{fieldPrefix:"lower_",titlePrefix:Jke(u,d,"-")}],c=!0;else{let h,f,m;d==="ci"?(h="mean",f="ci0",m="ci1"):(h="median",f="q1",m="q3"),a=[{op:f,field:s,as:`lower_${s}`},{op:m,field:s,as:`upper_${s}`},{op:h,field:s,as:`center_${s}`}],l=[{fieldPrefix:"upper_",titlePrefix:pB({field:s,aggregate:m,type:"quantitative"},C,{allowDisabling:!1})},{fieldPrefix:"lower_",titlePrefix:pB({field:s,aggregate:f,type:"quantitative"},C,{allowDisabling:!1})},{fieldPrefix:"center_",titlePrefix:pB({field:s,aggregate:h,type:"quantitative"},C,{allowDisabling:!1})}]}}else{(e.center||e.extent)&&ut(Oei(e.center,e.extent)),r==="aggregated-upper-lower"?(l=[],A=[{calculate:`datum["${i.field}"]`,as:`upper_${s}`},{calculate:`datum["${s}"]`,as:`lower_${s}`}]):r==="aggregated-error"&&(l=[{fieldPrefix:"",titlePrefix:s}],A=[{calculate:`datum["${s}"] + datum["${n.field}"]`,as:`upper_${s}`}],I?A.push({calculate:`datum["${s}"] + datum["${I.field}"]`,as:`lower_${s}`}):A.push({calculate:`datum["${s}"] - datum["${n.field}"]`,as:`lower_${s}`}));for(const u of A)l.push({fieldPrefix:u.as.substring(0,6),titlePrefix:Zy(Zy(u.calculate,'datum["',""),'"]',"")})}return{postAggregateCalculates:A,errorBarSpecificAggregate:a,tooltipSummary:l,tooltipTitleWithFieldName:c}}function Jke(e,g,i){return`${iN(e)} ${i} ${g}`}const Dfe="errorband",Ngi=["band","borders"],kgi=new bJ(Dfe,dCt);function dCt(e,{config:g}){e={...e,encoding:yJ(e.encoding,g)};const{transform:i,continuousAxisChannelDef:n,continuousAxis:I,encodingWithoutContinuousAxis:r,markDef:o,outerSpec:C,tooltipEncoding:a}=uCt(e,Dfe,g),A=o,s=Ffe(A,I,n,r,g.errorband),l=e.encoding.x!==void 0&&e.encoding.y!==void 0;let c={type:l?"area":"rect"},u={type:l?"line":"rule"};const d={...A.interpolate?{interpolate:A.interpolate}:{},...A.tension&&A.interpolate?{tension:A.tension}:{}};return l?(c={...c,...d,ariaRoleDescription:"errorband"},u={...u,...d,aria:!1}):A.interpolate?ut(xke("interpolate")):A.tension&&ut(xke("tension")),{...C,transform:i,layer:[...s({partName:"band",mark:c,positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:a}),...s({partName:"borders",mark:u,positionPrefix:"lower",extraEncoding:a}),...s({partName:"borders",mark:u,positionPrefix:"upper",extraEncoding:a})]}}const hCt={};function Mfe(e,g,i){const n=new bJ(e,g);hCt[e]={normalizer:n,parts:i}}function Ygi(){return At(hCt)}Mfe(G3,ACt,vgi);Mfe(Efe,cCt,Sgi);Mfe(Dfe,dCt,Ngi);const Kgi=["gradientHorizontalMaxLength","gradientHorizontalMinLength","gradientVerticalMaxLength","gradientVerticalMinLength","unselectedOpacity"],fCt={titleAlign:"align",titleAnchor:"anchor",titleAngle:"angle",titleBaseline:"baseline",titleColor:"color",titleFont:"font",titleFontSize:"fontSize",titleFontStyle:"fontStyle",titleFontWeight:"fontWeight",titleLimit:"limit",titleLineHeight:"lineHeight",titleOrient:"orient",titlePadding:"offset"},mCt={labelAlign:"align",labelAnchor:"anchor",labelAngle:"angle",labelBaseline:"baseline",labelColor:"color",labelFont:"font",labelFontSize:"fontSize",labelFontStyle:"fontStyle",labelFontWeight:"fontWeight",labelLimit:"limit",labelLineHeight:"lineHeight",labelOrient:"orient",labelPadding:"offset"},xgi=At(fCt),Fgi=At(mCt),Egi={header:1,headerRow:1,headerColumn:1,headerFacet:1},pCt=At(Egi),bCt=["size","shape","fill","stroke","strokeDash","strokeWidth","opacity"],Dgi={gradientHorizontalMaxLength:200,gradientHorizontalMinLength:100,gradientVerticalMaxLength:200,gradientVerticalMinLength:64,unselectedOpacity:.35},Mgi={aria:1,clipHeight:1,columnPadding:1,columns:1,cornerRadius:1,description:1,direction:1,fillColor:1,format:1,formatType:1,gradientLength:1,gradientOpacity:1,gradientStrokeColor:1,gradientStrokeWidth:1,gradientThickness:1,gridAlign:1,labelAlign:1,labelBaseline:1,labelColor:1,labelFont:1,labelFontSize:1,labelFontStyle:1,labelFontWeight:1,labelLimit:1,labelOffset:1,labelOpacity:1,labelOverlap:1,labelPadding:1,labelSeparation:1,legendX:1,legendY:1,offset:1,orient:1,padding:1,rowPadding:1,strokeColor:1,symbolDash:1,symbolDashOffset:1,symbolFillColor:1,symbolLimit:1,symbolOffset:1,symbolOpacity:1,symbolSize:1,symbolStrokeColor:1,symbolStrokeWidth:1,symbolType:1,tickCount:1,tickMinStep:1,title:1,titleAlign:1,titleAnchor:1,titleBaseline:1,titleColor:1,titleFont:1,titleFontSize:1,titleFontStyle:1,titleFontWeight:1,titleLimit:1,titleLineHeight:1,titleOpacity:1,titleOrient:1,titlePadding:1,type:1,values:1,zindex:1},jA="_vgsid_",zgi={point:{on:"click",fields:[jA],toggle:"event.shiftKey",resolve:"global",clear:"dblclick"},interval:{on:"[mousedown, window:mouseup] > window:mousemove!",encodings:["x","y"],translate:"[mousedown, window:mouseup] > window:mousemove!",zoom:"wheel!",mark:{fill:"#333",fillOpacity:.125,stroke:"white"},resolve:"global",clear:"dblclick"}};function zfe(e){return e==="legend"||!!e?.legend}function D4(e){return zfe(e)&&Wt(e)}function Pfe(e){return!!e?.select}function yCt(e){const g=[];for(const i of e||[]){if(Pfe(i))continue;const{expr:n,bind:I,...r}=i;if(I&&n){const o={...r,bind:I,init:n};g.push(o)}else{const o={...r,...n?{update:n}:{},...I?{bind:I}:{}};g.push(o)}}return g}function Pgi(e){return ZJ(e)||Ofe(e)||_fe(e)}function _fe(e){return"concat"in e}function ZJ(e){return"vconcat"in e}function Ofe(e){return"hconcat"in e}function ZCt({step:e,offsetIsDiscrete:g}){return g?e.for??"offset":"position"}function zc(e){return Wt(e)&&e.step!==void 0}function Lke(e){return e.view||e.width||e.height}const Uke=20,_gi={align:1,bounds:1,center:1,columns:1,spacing:1},Ogi=At(_gi);function Jgi(e,g,i){const n=i[g],I={},{spacing:r,columns:o}=n;r!==void 0&&(I.spacing=r),o!==void 0&&(dJ(e)&&!sN(e.facet)||_fe(e))&&(I.columns=o),ZJ(e)&&(I.columns=1);for(const C of Ogi)if(e[C]!==void 0)if(C==="spacing"){const a=e[C];I[C]=Vi(a)?a:{row:a.row??r,column:a.column??r}}else I[C]=e[C];return I}function BIe(e,g){return e[g]??e[g==="width"?"continuousWidth":"continuousHeight"]}function v3(e,g){const i=B3(e,g);return zc(i)?i.step:GCt}function B3(e,g){const i=e[g]??e[g==="width"?"discreteWidth":"discreteHeight"];return CI(i,{step:e.step})}const GCt=20,Lgi={continuousWidth:200,continuousHeight:200,step:GCt},Ugi={background:"white",padding:5,timeFormat:"%b %d, %Y",countTitle:"Count of Records",view:Lgi,mark:Mti,arc:{},area:{},bar:_ti,circle:{},geoshape:{},image:{},line:{},point:{},rect:Oti,rule:{color:"black"},square:{},text:{color:"black"},tick:Jti,trail:{},boxplot:{size:14,extent:1.5,box:{},median:{color:"white"},outliers:{},rule:{},ticks:null},errorbar:{center:"mean",rule:!0,ticks:!1},errorband:{band:{opacity:.3},borders:!1},scale:vti,projection:{},legend:Dgi,header:{titlePadding:10,labelPadding:10},headerColumn:{},headerRow:{},headerFacet:{},selection:zgi,style:{},title:{},facet:{spacing:Uke},concat:{spacing:Uke},normalizedNumberFormat:".0%"},wu=["#4c78a8","#f58518","#e45756","#72b7b2","#54a24b","#eeca3b","#b279a2","#ff9da6","#9d755d","#bab0ac"],Qke={text:11,guideLabel:10,guideTitle:11,groupTitle:13,groupSubtitle:12},jke={blue:wu[0],orange:wu[1],red:wu[2],teal:wu[3],green:wu[4],yellow:wu[5],purple:wu[6],pink:wu[7],brown:wu[8],gray0:"#000",gray1:"#111",gray2:"#222",gray3:"#333",gray4:"#444",gray5:"#555",gray6:"#666",gray7:"#777",gray8:"#888",gray9:"#999",gray10:"#aaa",gray11:"#bbb",gray12:"#ccc",gray13:"#ddd",gray14:"#eee",gray15:"#fff"};function Qgi(e={}){return{signals:[{name:"color",value:Wt(e)?{...jke,...e}:jke}],mark:{color:{signal:"color.blue"}},rule:{color:{signal:"color.gray0"}},text:{color:{signal:"color.gray0"}},style:{"guide-label":{fill:{signal:"color.gray0"}},"guide-title":{fill:{signal:"color.gray0"}},"group-title":{fill:{signal:"color.gray0"}},"group-subtitle":{fill:{signal:"color.gray0"}},cell:{stroke:{signal:"color.gray8"}}},axis:{domainColor:{signal:"color.gray13"},gridColor:{signal:"color.gray8"},tickColor:{signal:"color.gray13"}},range:{category:[{signal:"color.blue"},{signal:"color.orange"},{signal:"color.red"},{signal:"color.teal"},{signal:"color.green"},{signal:"color.yellow"},{signal:"color.purple"},{signal:"color.pink"},{signal:"color.brown"},{signal:"color.grey8"}]}}}function jgi(e){return{signals:[{name:"fontSize",value:Wt(e)?{...Qke,...e}:Qke}],text:{fontSize:{signal:"fontSize.text"}},style:{"guide-label":{fontSize:{signal:"fontSize.guideLabel"}},"guide-title":{fontSize:{signal:"fontSize.guideTitle"}},"group-title":{fontSize:{signal:"fontSize.groupTitle"}},"group-subtitle":{fontSize:{signal:"fontSize.groupSubtitle"}}}}}function $gi(e){return{text:{font:e},style:{"guide-label":{font:e},"guide-title":{font:e},"group-title":{font:e},"group-subtitle":{font:e}}}}function vCt(e){const g=At(e||{}),i={};for(const n of g){const I=e[n];i[n]=cN(I)?iot(I):Ca(I)}return i}function qgi(e){const g=At(e),i={};for(const n of g)i[n]=vCt(e[n]);return i}const eii=[...Yot,...iCt,...pCt,"background","padding","legend","lineBreak","scale","style","title","view"];function BCt(e={}){const{color:g,font:i,fontSize:n,selection:I,...r}=e,o=AS({},mg(Ugi),i?$gi(i):{},g?Qgi(g):{},n?jgi(n):{},r||{});I&&lS(o,"selection",I,!0);const C=WC(o,eii);for(const a of["background","lineBreak","padding"])o[a]&&(C[a]=Ca(o[a]));for(const a of Yot)o[a]&&(C[a]=hC(o[a]));for(const a of iCt)o[a]&&(C[a]=vCt(o[a]));for(const a of pCt)o[a]&&(C[a]=hC(o[a]));return o.legend&&(C.legend=hC(o.legend)),o.scale&&(C.scale=hC(o.scale)),o.style&&(C.style=qgi(o.style)),o.title&&(C.title=hC(o.title)),o.view&&(C.view=hC(o.view)),C}const tii=new Set(["view",...Yti]),gii=["color","fontSize","background","padding","facet","concat","numberFormat","numberFormatType","normalizedNumberFormat","normalizedNumberFormatType","timeFormat","countTitle","header","axisQuantitative","axisTemporal","axisDiscrete","axisPoint","axisXBand","axisXPoint","axisXDiscrete","axisXQuantitative","axisXTemporal","axisYBand","axisYPoint","axisYDiscrete","axisYQuantitative","axisYTemporal","scale","selection","overlay"],iii={view:["continuousWidth","continuousHeight","discreteWidth","discreteHeight","step"],...Dti};function nii(e){e=mg(e);for(const g of gii)delete e[g];if(e.axis)for(const g in e.axis)cN(e.axis[g])&&delete e.axis[g];if(e.legend)for(const g of Kgi)delete e.legend[g];if(e.mark){for(const g of Eke)delete e.mark[g];e.mark.tooltip&&Wt(e.mark.tooltip)&&delete e.mark.tooltip}e.params&&(e.signals=(e.signals||[]).concat(yCt(e.params)),delete e.params);for(const g of tii){for(const n of Eke)delete e[g][n];const i=iii[g];if(i)for(const n of i)delete e[g][n];rii(e,g)}for(const g of Ygi())delete e[g];Iii(e);for(const g in e)Wt(e[g])&&Ri(e[g])&&delete e[g];return Ri(e)?void 0:e}function Iii(e){const{titleMarkConfig:g,subtitleMarkConfig:i,subtitle:n}=got(e.title);Ri(g)||(e.style["group-title"]={...e.style["group-title"],...g}),Ri(i)||(e.style["group-subtitle"]={...e.style["group-subtitle"],...i}),Ri(n)?delete e.title:e.title=n}function rii(e,g,i,n){const I=n?e[g][n]:e[g];g==="view"&&(i="cell");const r={...I,...e.style[i??g]};Ri(r)||(e.style[i??g]=r),n||delete e[g]}function GJ(e){return"layer"in e}function oii(e){return"repeat"in e}function Cii(e){return!et(e.repeat)&&e.repeat.layer}class Jfe{map(g,i){return dJ(g)?this.mapFacet(g,i):oii(g)?this.mapRepeat(g,i):Ofe(g)?this.mapHConcat(g,i):ZJ(g)?this.mapVConcat(g,i):_fe(g)?this.mapConcat(g,i):this.mapLayerOrUnit(g,i)}mapLayerOrUnit(g,i){if(GJ(g))return this.mapLayer(g,i);if(dh(g))return this.mapUnit(g,i);throw new Error(afe(g))}mapLayer(g,i){return{...g,layer:g.layer.map(n=>this.mapLayerOrUnit(n,i))}}mapHConcat(g,i){return{...g,hconcat:g.hconcat.map(n=>this.map(n,i))}}mapVConcat(g,i){return{...g,vconcat:g.vconcat.map(n=>this.map(n,i))}}mapConcat(g,i){const{concat:n,...I}=g;return{...I,concat:n.map(r=>this.map(r,i))}}mapFacet(g,i){return{...g,spec:this.map(g.spec,i)}}mapRepeat(g,i){return{...g,spec:this.map(g.spec,i)}}}const aii={zero:1,center:1,normalize:1};function sii(e){return e in aii}const Aii=new Set([Tot,AJ,sJ,f3,cJ,Bfe,wfe,lJ,Hot,vfe]),lii=new Set([AJ,sJ,Tot]);function ZG(e){return dt(e)&&C1(e)==="quantitative"&&!e.bin}function $ke(e,g,{orient:i,type:n}){const I=g==="x"?"y":"radius",r=g==="x",o=e[g],C=e[I];if(dt(o)&&dt(C))if(ZG(o)&&ZG(C)){if(o.stack)return g;if(C.stack)return I;const a=dt(o)&&!!o.aggregate,A=dt(C)&&!!C.aggregate;if(a!==A)return a?g:I;if(r&&n==="bar"){if(i==="vertical")return I;if(i==="horizontal")return g}}else{if(ZG(o))return g;if(ZG(C))return I}else{if(ZG(o))return g;if(ZG(C))return I}}function cii(e){switch(e){case"x":return"y";case"y":return"x";case"theta":return"radius";case"radius":return"theta"}}function wCt(e,g){const i=Dc(e)?e:{type:e},n=i.type;if(!Aii.has(n))return null;const I=$ke(g,"x",i)||$ke(g,"theta",i);if(!I)return null;const r=g[I],o=dt(r)?Bt(r,{}):void 0,C=cii(I),a=[],A=new Set;if(g[C]){const c=g[C],u=dt(c)?Bt(c,{}):void 0;u&&u!==o&&(a.push(C),A.add(u));const d=C==="x"?"xOffset":"yOffset",h=g[d],f=dt(h)?Bt(h,{}):void 0;f&&f!==o&&(a.push(d),A.add(f))}const s=Sqg.reduce((c,u)=>{if(u!=="tooltip"&&ab(g,u)){const d=g[u];for(const h of Vt(d)){const f=Mc(h);if(f.aggregate)continue;const m=Bt(f,{});(!m||!A.has(m))&&c.push({channel:u,fieldDef:f})}}return c},[]);let l;return r.stack!==void 0?gp(r.stack)?l=r.stack?"zero":null:l=r.stack:lii.has(n)&&(l="zero"),!l||!sii(l)||Yfe(g)&&s.length===0?null:r?.scale?.type&&r?.scale?.type!==XC.LINEAR?(r?.stack&&ut(zei(r.scale.type)),null):fg(g[Cu(I)])?(r.stack!==void 0&&ut(Mei(I)),null):(dt(r)&&r.aggregate&&!Fqg.has(r.aggregate)&&ut(Pei(r.aggregate)),{groupbyChannels:a,groupbyFields:A,fieldChannel:I,impute:r.impute===null?!1:hp(n),stackBy:s,offset:l})}function uii(e){const{point:g,line:i,...n}=e;return At(n).length>1?n:n.type}function dii(e){for(const g of["line","area","rule","trail"])e[g]&&(e={...e,[g]:WC(e[g],["point","line"])});return e}function M4(e,g={},i){return e.point==="transparent"?{opacity:0}:e.point?Wt(e.point)?e.point:{}:e.point!==void 0?null:g.point||i.shape?Wt(g.point)?g.point:{}:void 0}function qke(e,g={}){return e.line?e.line===!0?{}:e.line:e.line!==void 0?null:g.line?g.line===!0?{}:g.line:void 0}class hii{constructor(){this.name="path-overlay"}hasMatchingType(g,i){if(dh(g)){const{mark:n,encoding:I}=g,r=Dc(n)?n:{type:n};switch(r.type){case"line":case"rule":case"trail":return!!M4(r,i[r.type],I);case"area":return!!M4(r,i[r.type],I)||!!qke(r,i[r.type])}}return!1}run(g,i,n){const{config:I}=i,{params:r,projection:o,mark:C,name:a,encoding:A,...s}=g,l=yJ(A,I),c=Dc(C)?C:{type:C},u=M4(c,I[c.type],l),d=c.type==="area"&&qke(c,I[c.type]),h=[{name:a,...r?{params:r}:{},mark:uii({...c.type==="area"&&c.opacity===void 0&&c.fillOpacity===void 0?{opacity:.7}:{},...c}),encoding:WC(l,["shape"])}],f=wCt(c,l);let m=l;if(f){const{fieldChannel:b,offset:p}=f;m={...l,[b]:{...l[b],...p?{stack:p}:{}}}}return m=WC(m,["y2","x2"]),d&&h.push({...o?{projection:o}:{},mark:{type:"line",...i1(c,["clip","interpolate","tension","tooltip"]),...d},encoding:m}),u&&h.push({...o?{projection:o}:{},mark:{type:"point",opacity:1,filled:!0,...i1(c,["clip","tooltip"]),...u},encoding:m}),n({...s,layer:h},{...i,config:dii(I)})}}function fii(e,g){return g?sN(e)?RCt(e,g):SCt(e,g):e}function z4(e,g){return g?RCt(e,g):e}function wIe(e,g,i){const n=g[e];if(igi(n)){if(n.repeat in i)return{...g,[e]:i[n.repeat]};ut(nei(n.repeat));return}return g}function SCt(e,g){if(e=wIe("field",e,g),e!==void 0){if(e===null)return null;if(Tfe(e)&&yc(e.sort)){const i=wIe("field",e.sort,g);e={...e,...i?{sort:i}:{}}}return e}}function eYe(e,g){if(dt(e))return SCt(e,g);{const i=wIe("datum",e,g);return i!==e&&!i.type&&(i.type="nominal"),i}}function tYe(e,g){if(fg(e)){const i=eYe(e,g);if(i)return i;if(hJ(e))return{condition:e.condition}}else{if(AN(e)){const i=eYe(e.condition,g);if(i)return{...e,condition:i};{const{condition:n,...I}=e;return I}}return e}}function RCt(e,g){const i={};for(const n in e)if(gg(e,n)){const I=e[n];if(et(I))i[n]=I.map(r=>tYe(r,g)).filter(r=>r);else{const r=tYe(I,g);r!==void 0&&(i[n]=r)}}return i}class mii{constructor(){this.name="RuleForRangedLine"}hasMatchingType(g){if(dh(g)){const{encoding:i,mark:n}=g;if(n==="line"||Dc(n)&&n.type==="line")for(const I of Bqg){const r=vZ(I),o=i[r];if(i[I]&&(dt(o)&&!or(o.bin)||su(o)))return!0}}return!1}run(g,i,n){const{encoding:I,mark:r}=g;return ut(Bei(!!I.x2,!!I.y2)),n({...g,mark:Wt(r)?{...r,type:"rule"}:"rule"},i)}}class pii extends Jfe{constructor(){super(...arguments),this.nonFacetUnitNormalizers=[Bgi,Rgi,kgi,new hii,new mii]}map(g,i){if(dh(g)){const n=ab(g.encoding,yd),I=ab(g.encoding,Zd),r=ab(g.encoding,eJ);if(n||I||r)return this.mapFacetedUnit(g,i)}return super.map(g,i)}mapUnit(g,i){const{parentEncoding:n,parentProjection:I}=i,r=z4(g.encoding,i.repeater),o={...g,...g.name?{name:[i.repeaterPrefix,g.name].filter(a=>a).join("_")}:{},...r?{encoding:r}:{}};if(n||I)return this.mapUnitWithParentEncodingOrProjection(o,i);const C=this.mapLayerOrUnit.bind(this);for(const a of this.nonFacetUnitNormalizers)if(a.hasMatchingType(o,i.config))return a.run(o,i,C);return o}mapRepeat(g,i){return Cii(g)?this.mapLayerRepeat(g,i):this.mapNonLayerRepeat(g,i)}mapLayerRepeat(g,i){const{repeat:n,spec:I,...r}=g,{row:o,column:C,layer:a}=n,{repeater:A={},repeaterPrefix:s=""}=i;return o||C?this.mapRepeat({...g,repeat:{...o?{row:o}:{},...C?{column:C}:{}},spec:{repeat:{layer:a},spec:I}},i):{...r,layer:a.map(l=>{const c={...A,layer:l},u=`${(I.name?`${I.name}_`:"")+s}child__layer_${dn(l)}`,d=this.mapLayerOrUnit(I,{...i,repeater:c,repeaterPrefix:u});return d.name=u,d})}}mapNonLayerRepeat(g,i){const{repeat:n,spec:I,data:r,...o}=g;!et(n)&&g.columns&&(g=WC(g,["columns"]),ut(Nke("repeat")));const C=[],{repeater:a={},repeaterPrefix:A=""}=i,s=!et(n)&&n.row||[a?a.row:null],l=!et(n)&&n.column||[a?a.column:null],c=et(n)&&n||[a?a.repeat:null];for(const d of c)for(const h of s)for(const f of l){const m={repeat:d,row:h,column:f,layer:a.layer},b=(I.name?`${I.name}_`:"")+A+"child__"+(et(n)?`${dn(d)}`:(n.row?`row_${dn(h)}`:"")+(n.column?`column_${dn(f)}`:"")),p=this.map(I,{...i,repeater:m,repeaterPrefix:b});p.name=b,C.push(WC(p,["data"]))}const u=et(n)?g.columns:n.column?n.column.length:1;return{data:I.data??r,align:"all",...o,columns:u,concat:C}}mapFacet(g,i){const{facet:n}=g;return sN(n)&&g.columns&&(g=WC(g,["columns"]),ut(Nke("facet"))),super.mapFacet(g,i)}mapUnitWithParentEncodingOrProjection(g,i){const{encoding:n,projection:I}=g,{parentEncoding:r,parentProjection:o,config:C}=i,a=iYe({parentProjection:o,projection:I}),A=gYe({parentEncoding:r,encoding:z4(n,i.repeater)});return this.mapUnit({...g,...a?{projection:a}:{},...A?{encoding:A}:{}},{config:C})}mapFacetedUnit(g,i){const{row:n,column:I,facet:r,...o}=g.encoding,{mark:C,width:a,projection:A,height:s,view:l,params:c,encoding:u,...d}=g,{facetMapping:h,layout:f}=this.getFacetMappingAndLayout({row:n,column:I,facet:r},i),m=z4(o,i.repeater);return this.mapFacet({...d,...f,facet:h,spec:{...a?{width:a}:{},...s?{height:s}:{},...l?{view:l}:{},...A?{projection:A}:{},mark:C,encoding:m,...c?{params:c}:{}}},i)}getFacetMappingAndLayout(g,i){const{row:n,column:I,facet:r}=g;if(n||I){r&&ut(Gei([...n?[yd]:[],...I?[Zd]:[]]));const o={},C={};for(const a of[yd,Zd]){const A=g[a];if(A){const{align:s,center:l,spacing:c,columns:u,...d}=A;o[a]=d;for(const h of["align","center","spacing"])A[h]!==void 0&&(C[h]??(C[h]={}),C[h][a]=A[h])}}return{facetMapping:o,layout:C}}else{const{align:o,center:C,spacing:a,columns:A,...s}=r;return{facetMapping:fii(s,i.repeater),layout:{...o?{align:o}:{},...C?{center:C}:{},...a?{spacing:a}:{},...A?{columns:A}:{}}}}}mapLayer(g,{parentEncoding:i,parentProjection:n,...I}){const{encoding:r,projection:o,...C}=g,a={...I,parentEncoding:gYe({parentEncoding:i,encoding:r,layer:!0}),parentProjection:iYe({parentProjection:n,projection:o})};return super.mapLayer({...C,...g.name?{name:[a.repeaterPrefix,g.name].filter(A=>A).join("_")}:{}},a)}}function gYe({parentEncoding:e,encoding:g={},layer:i}){let n={};if(e){const I=new Set([...At(e),...At(g)]);for(const r of I){const o=g[r],C=e[r];if(fg(o)){const a={...C,...o};n[r]=a}else AN(o)?n[r]={...o,condition:{...C,...o.condition}}:o||o===null?n[r]=o:(i||QA(C)||Qt(C)||fg(C)||et(C))&&(n[r]=C)}}else n=g;return!n||Ri(n)?void 0:n}function iYe(e){const{parentProjection:g,projection:i}=e;return g&&i&&ut(sei({parentProjection:g,projection:i})),i??g}function Lfe(e){return"filter"in e}function bii(e){return e?.stop!==void 0}function VCt(e){return"lookup"in e}function yii(e){return"data"in e}function Zii(e){return"param"in e}function Gii(e){return"pivot"in e}function vii(e){return"density"in e}function Bii(e){return"quantile"in e}function wii(e){return"regression"in e}function Sii(e){return"loess"in e}function Rii(e){return"sample"in e}function Vii(e){return"window"in e}function Wii(e){return"joinaggregate"in e}function Xii(e){return"flatten"in e}function Tii(e){return"calculate"in e}function WCt(e){return"bin"in e}function Hii(e){return"impute"in e}function Nii(e){return"timeUnit"in e}function kii(e){return"aggregate"in e}function Yii(e){return"stack"in e}function Kii(e){return"fold"in e}function xii(e){return e.map(g=>Lfe(g)?{filter:fB(g.filter,fti)}:g)}class Fii extends Jfe{map(g,i){return i.emptySelections??(i.emptySelections={}),i.selectionPredicates??(i.selectionPredicates={}),g=nYe(g,i),super.map(g,i)}mapLayerOrUnit(g,i){if(g=nYe(g,i),g.encoding){const n={};for(const[I,r]of Sm(g.encoding))n[I]=XCt(r,i);g={...g,encoding:n}}return super.mapLayerOrUnit(g,i)}mapUnit(g,i){const{selection:n,...I}=g;return n?{...I,params:Sm(n).map(([r,o])=>{const{init:C,bind:a,empty:A,...s}=o;s.type==="single"?(s.type="point",s.toggle=!1):s.type==="multi"&&(s.type="point"),i.emptySelections[r]=A!=="none";for(const l of fr(i.selectionPredicates[r]??{}))l.empty=A!=="none";return{name:r,value:C,select:s,bind:a}})}:g}}function nYe(e,g){const{transform:i,...n}=e;if(i){const I=i.map(r=>{if(Lfe(r))return{filter:SIe(r,g)};if(WCt(r)&&BZ(r.bin))return{...r,bin:TCt(r.bin)};if(VCt(r)){const{selection:o,...C}=r.from;return o?{...r,from:{param:o,...C}}:r}return r});return{...n,transform:I}}return e}function XCt(e,g){const i=mg(e);if(dt(i)&&BZ(i.bin)&&(i.bin=TCt(i.bin)),SZ(i)&&i.scale?.domain?.selection){const{selection:n,...I}=i.scale.domain;i.scale.domain={...I,...n?{param:n}:{}}}if(hJ(i))if(et(i.condition))i.condition=i.condition.map(n=>{const{selection:I,param:r,test:o,...C}=n;return r?n:{...C,test:SIe(n,g)}});else{const{selection:n,param:I,test:r,...o}=XCt(i.condition,g);i.condition=I?i.condition:{...o,test:SIe(i.condition,g)}}return i}function TCt(e){const g=e.extent;if(g?.selection){const{selection:i,...n}=g;return{...e,extent:{...n,param:i}}}return e}function SIe(e,g){const i=n=>fB(n,I=>{var r;const o=g.emptySelections[I]??!0,C={param:I,empty:o};return(r=g.selectionPredicates)[I]??(r[I]=[]),g.selectionPredicates[I].push(C),C});return e.selection?i(e.selection):fB(e.test||e.filter,n=>n.selection?i(n.selection):n)}class RIe extends Jfe{map(g,i){const n=i.selections??[];if(g.params&&!dh(g)){const I=[];for(const r of g.params)Pfe(r)?n.push(r):I.push(r);g.params=I}return i.selections=n,super.map(g,i)}mapUnit(g,i){const n=i.selections;if(!n||!n.length)return g;const I=(i.path??[]).concat(g.name),r=[];for(const o of n)if(!o.views||!o.views.length)r.push(o);else for(const C of o.views)(Rt(C)&&(C===g.name||I.includes(C))||et(C)&&C.map(a=>I.indexOf(a)).every((a,A,s)=>a!==-1&&(A===0||a>s[A-1])))&&r.push(o);return r.length&&(g.params=r),g}}for(const e of["mapFacet","mapRepeat","mapHConcat","mapVConcat","mapLayer"]){const g=RIe.prototype[e];RIe.prototype[e]=function(i,n){return g.call(this,i,Eii(i,n))}}function Eii(e,g){return e.name?{...g,path:(g.path??[]).concat(e.name)}:g}function HCt(e,g){g===void 0&&(g=BCt(e.config));const i=Pii(e,g),{width:n,height:I}=e,r=_ii(i,{width:n,height:I,autosize:e.autosize},g);return{...i,...r?{autosize:r}:{}}}const Dii=new pii,Mii=new Fii,zii=new RIe;function Pii(e,g={}){const i={config:g};return zii.map(Dii.map(Mii.map(e,i),i),i)}function IYe(e){return Rt(e)?{type:e}:e??{}}function _ii(e,g,i){let{width:n,height:I}=g;const r=dh(e)||GJ(e),o={};r?n=="container"&&I=="container"?(o.type="fit",o.contains="padding"):n=="container"?(o.type="fit-x",o.contains="padding"):I=="container"&&(o.type="fit-y",o.contains="padding"):(n=="container"&&(ut(Wke("width")),n=void 0),I=="container"&&(ut(Wke("height")),I=void 0));const C={type:"pad",...o,...i?IYe(i.autosize):{},...IYe(e.autosize)};if(C.type==="fit"&&!r&&(ut(Lqg),C.type="pad"),n=="container"&&!(C.type=="fit"||C.type=="fit-x")&&ut(Xke("width")),I=="container"&&!(C.type=="fit"||C.type=="fit-y")&&ut(Xke("height")),!nc(C,{type:"pad"}))return C}function Oii(e){return e==="fit"||e==="fit-x"||e==="fit-y"}function Jii(e){return e?`fit-${IJ(e)}`:"fit"}const Lii=["background","padding"];function rYe(e,g){const i={};for(const n of Lii)e&&e[n]!==void 0&&(i[n]=Ca(e[n]));return g&&(i.params=e.params),i}class hh{constructor(g={},i={}){this.explicit=g,this.implicit=i}clone(){return new hh(mg(this.explicit),mg(this.implicit))}combine(){return{...this.explicit,...this.implicit}}get(g){return CI(this.explicit[g],this.implicit[g])}getWithExplicit(g){return this.explicit[g]!==void 0?{explicit:!0,value:this.explicit[g]}:this.implicit[g]!==void 0?{explicit:!1,value:this.implicit[g]}:{explicit:!1,value:void 0}}setWithExplicit(g,{value:i,explicit:n}){i!==void 0&&this.set(g,i,n)}set(g,i,n){return delete this[n?"implicit":"explicit"][g],this[n?"explicit":"implicit"][g]=i,this}copyKeyFromSplit(g,{explicit:i,implicit:n}){i[g]!==void 0?this.set(g,i[g],!0):n[g]!==void 0&&this.set(g,n[g],!1)}copyKeyFromObject(g,i){i[g]!==void 0&&this.set(g,i[g],!0)}copyAll(g){for(const i of At(g.combine())){const n=g.getWithExplicit(i);this.setWithExplicit(i,n)}}}function Xl(e){return{explicit:!0,value:e}}function QC(e){return{explicit:!1,value:e}}function NCt(e){return(g,i,n,I)=>{const r=e(g.value,i.value);return r>0?g:r<0?i:vJ(g,i,n,I)}}function vJ(e,g,i,n){return e.explicit&&g.explicit&&ut(kei(i,n,e.value,g.value)),e}function Vm(e,g,i,n,I=vJ){return e===void 0||e.value===void 0?g:e.explicit&&!g.explicit?e:g.explicit&&!e.explicit?g:nc(e.value,g.value)?e:I(e,g,i,n)}class Uii extends hh{constructor(g={},i={},n=!1){super(g,i),this.explicit=g,this.implicit=i,this.parseNothing=n}clone(){const g=super.clone();return g.parseNothing=this.parseNothing,g}}function A1(e){return"url"in e}function $9(e){return"values"in e}function kCt(e){return"name"in e&&!A1(e)&&!$9(e)&&!am(e)}function am(e){return e&&(YCt(e)||KCt(e)||Ufe(e))}function YCt(e){return"sequence"in e}function KCt(e){return"sphere"in e}function Ufe(e){return"graticule"in e}var zi;(function(e){e[e.Raw=0]="Raw",e[e.Main=1]="Main",e[e.Row=2]="Row",e[e.Column=3]="Column",e[e.Lookup=4]="Lookup"})(zi||(zi={}));function xCt(e){const{signals:g,hasLegend:i,index:n,...I}=e;return I.field=ys(I.field),I}function Vy(e,g=!0,i=io){if(et(e)){const n=e.map(I=>Vy(I,g,i));return g?`[${n.join(", ")}]`:n}else if(wZ(e))return i(g?By(e):rti(e));return g?i(Oi(e)):e}function Qii(e,g){for(const i of fr(e.component.selection??{})){const n=i.name;let I=`${n}${Xm}, ${i.resolve==="global"?"true":`{unit: ${sb(e)}}`}`;for(const r of wJ)r.defined(i)&&(r.signals&&(g=r.signals(e,i,g)),r.modifyExpr&&(I=r.modifyExpr(e,i,I)));g.push({name:n+Rni,on:[{events:{signal:i.name+Xm},update:`modify(${ft(i.name+Wy)}, ${I})`}]})}return Qfe(g)}function jii(e,g){if(e.component.selection&&At(e.component.selection).length){const i=ft(e.getName("cell"));g.unshift({name:"facet",value:{},on:[{events:Cp("mousemove","scope"),update:`isTuple(facet) ? facet : group(${i}).datum`}]})}return Qfe(g)}function $ii(e,g){let i=!1;for(const n of fr(e.component.selection??{})){const I=n.name,r=ft(I+Wy);if(g.filter(C=>C.name===I).length===0){const C=n.resolve==="global"?"union":n.resolve,a=n.type==="point"?", true, true)":")";g.push({name:n.name,update:`${tat}(${r}, ${ft(C)}${a}`})}i=!0;for(const C of wJ)C.defined(n)&&C.topLevelSignals&&(g=C.topLevelSignals(e,n,g))}return i&&g.filter(I=>I.name==="unit").length===0&&g.unshift({name:"unit",value:{},on:[{events:"mousemove",update:"isTuple(group()) ? group() : unit"}]}),Qfe(g)}function qii(e,g){const i=[...g],n=sb(e,{escape:!1});for(const I of fr(e.component.selection??{})){const r={name:I.name+Wy};if(I.project.hasSelectionId&&(r.transform=[{type:"collect",sort:{field:jA}}]),I.init){const C=I.project.items.map(xCt);r.values=I.project.hasSelectionId?I.init.map(a=>({unit:n,[jA]:Vy(a,!1)[0]})):I.init.map(a=>({unit:n,fields:C,values:Vy(a,!1)}))}i.filter(C=>C.name===I.name+Wy).length||i.push(r)}return i}function FCt(e,g){for(const i of fr(e.component.selection??{}))for(const n of wJ)n.defined(i)&&n.marks&&(g=n.marks(e,i,g));return g}function eni(e,g){for(const i of e.children)$n(i)&&(g=FCt(i,g));return g}function tni(e,g,i,n){const I=rat(e,g.param,g);return{signal:va(i.get("type"))&&et(n)&&n[0]>n[1]?`isValid(${I}) && reverse(${I})`:I}}function Qfe(e){return e.map(g=>(g.on&&!g.on.length&&delete g.on,g))}class Xi{constructor(g,i){this.debugName=i,this._children=[],this._parent=null,g&&(this.parent=g)}clone(){throw new Error("Cannot clone node")}get parent(){return this._parent}set parent(g){this._parent=g,g&&g.addChild(this)}get children(){return this._children}numChildren(){return this._children.length}addChild(g,i){if(this._children.includes(g)){ut(oei);return}i!==void 0?this._children.splice(i,0,g):this._children.push(g)}removeChild(g){const i=this._children.indexOf(g);return this._children.splice(i,1),i}remove(){let g=this._parent.removeChild(this);for(const i of this._children)i._parent=this._parent,this._parent.addChild(i,g++)}insertAsParentOf(g){const i=g.parent;i.removeChild(this),this.parent=i,g.parent=this}swapWithParent(){const g=this._parent,i=g.parent;for(const I of this._children)I.parent=g;this._children=[],g.removeChild(this);const n=g.parent.removeChild(g);this._parent=i,i.addChild(this,n),g.parent=this}}class Ko extends Xi{clone(){const g=new this.constructor;return g.debugName=`clone_${this.debugName}`,g._source=this._source,g._name=`clone_${this._name}`,g.type=this.type,g.refCounts=this.refCounts,g.refCounts[g._name]=0,g}constructor(g,i,n,I){super(g,i),this.type=n,this.refCounts=I,this._source=this._name=i,this.refCounts&&!(this._name in this.refCounts)&&(this.refCounts[this._name]=0)}dependentFields(){return new Set}producedFields(){return new Set}hash(){return this._hash===void 0&&(this._hash=`Output ${xrt()}`),this._hash}getSource(){return this.refCounts[this._name]++,this._source}isRequired(){return!!this.refCounts[this._name]}setSource(g){this._source=g}}class Zc extends Xi{clone(){return new Zc(null,mg(this.formula))}constructor(g,i){super(g),this.formula=i}static makeFromEncoding(g,i){const n=i.reduceFieldDef((I,r)=>{const{field:o,timeUnit:C}=r;if(C){const a=Bt(r,{forAs:!0});I[$g({as:a,field:o,timeUnit:C})]={as:a,field:o,timeUnit:C}}return I},{});return Ri(n)?null:new Zc(g,n)}static makeFromTransform(g,i){const{timeUnit:n,...I}={...i},r=Zr(n),o={...I,timeUnit:r};return new Zc(g,{[$g(o)]:o})}merge(g){this.formula={...this.formula};for(const i in g.formula)this.formula[i]||(this.formula[i]=g.formula[i]);for(const i of g.children)g.removeChild(i),i.parent=this;g.remove()}removeFormulas(g){const i={};for(const[n,I]of Sm(this.formula))g.has(I.as)||(i[n]=I);this.formula=i}producedFields(){return new Set(fr(this.formula).map(g=>g.as))}dependentFields(){return new Set(fr(this.formula).map(g=>g.field))}hash(){return`TimeUnit ${$g(this.formula)}`}assemble(){const g=[];for(const i of fr(this.formula)){const{field:n,as:I,timeUnit:r}=i,{unit:o,utc:C,...a}=Zr(r);g.push({field:ys(n),type:"timeunit",...o?{units:aJ(o)}:{},...C?{timezone:"utc"}:{},...a,as:[I,`${I}_end`]})}return g}}const uN="_tuple_fields";class gni{constructor(...g){this.items=g,this.hasChannel={},this.hasField={},this.hasSelectionId=!1}}const ini={defined:()=>!0,parse:(e,g,i)=>{const n=g.name,I=g.project??(g.project=new gni),r={},o={},C=new Set,a=(d,h)=>{const f=h==="visual"?d.channel:d.field;let m=dn(`${n}_${f}`);for(let b=1;C.has(m);b++)m=dn(`${n}_${f}_${b}`);return C.add(m),{[h]:m}},A=g.type,s=e.config.selection[A],l=i.value!==void 0?Vt(i.value):null;let{fields:c,encodings:u}=Wt(i.select)?i.select:{};if(!c&&!u&&l){for(const d of l)if(Wt(d))for(const h of At(d))vqg(h)?(u||(u=[])).push(h):A==="interval"?(ut(iei),u=s.encodings):(c??(c=[])).push(h)}!c&&!u&&(u=s.encodings,"fields"in s&&(c=s.fields));for(const d of u??[]){const h=e.fieldDef(d);if(h){let f=h.field;if(h.aggregate){ut(Uqg(d,h.aggregate));continue}else if(!f){ut(Hke(d));continue}if(h.timeUnit){f=e.vgField(d);const m={timeUnit:h.timeUnit,as:f,field:h.field};o[$g(m)]=m}if(!r[f]){const m=A==="interval"&&uh(d)&&va(e.getScaleComponent(d).get("type"))?"R":h.bin?"R-RE":"E",b={field:f,channel:d,type:m,index:I.items.length};b.signals={...a(b,"data"),...a(b,"visual")},I.items.push(r[f]=b),I.hasField[f]=r[f],I.hasSelectionId=I.hasSelectionId||f===jA,Prt(d)?(b.geoChannel=d,b.channel=zrt(d),I.hasChannel[b.channel]=r[f]):I.hasChannel[d]=r[f]}}else ut(Hke(d))}for(const d of c??[]){if(I.hasField[d])continue;const h={type:"E",field:d,index:I.items.length};h.signals={...a(h,"data")},I.items.push(h),I.hasField[d]=h,I.hasSelectionId=I.hasSelectionId||d===jA}l&&(g.init=l.map(d=>I.items.map(h=>Wt(d)?d[h.geoChannel||h.channel]!==void 0?d[h.geoChannel||h.channel]:d[h.field]:d))),Ri(o)||(I.timeUnit=new Zc(null,o))},signals:(e,g,i)=>{const n=g.name+uN;return i.filter(r=>r.name===n).length>0||g.project.hasSelectionId?i:i.concat({name:n,value:g.project.items.map(xCt)})}},vd={defined:e=>e.type==="interval"&&e.resolve==="global"&&e.bind&&e.bind==="scales",parse:(e,g)=>{const i=g.scales=[];for(const n of g.project.items){const I=n.channel;if(!uh(I))continue;const r=e.getScaleComponent(I),o=r?r.get("type"):void 0;if(!r||!va(o)){ut($qg);continue}r.set("selectionExtent",{param:g.name,field:n.field},!0),i.push(n)}},topLevelSignals:(e,g,i)=>{const n=g.scales.filter(o=>i.filter(C=>C.name===o.signals.data).length===0);if(!e.parent||oYe(e)||n.length===0)return i;const I=i.filter(o=>o.name===g.name)[0];let r=I.update;if(r.indexOf(tat)>=0)I.update=`{${n.map(o=>`${ft(ys(o.field))}: ${o.signals.data}`).join(", ")}}`;else{for(const o of n){const C=`${ft(ys(o.field))}: ${o.signals.data}`;r.includes(C)||(r=`${r.substring(0,r.length-1)}, ${C}}`)}I.update=r}return i.concat(n.map(o=>({name:o.signals.data})))},signals:(e,g,i)=>{if(e.parent&&!oYe(e))for(const n of g.scales){const I=i.filter(r=>r.name===n.signals.data)[0];I.push="outer",delete I.value,delete I.update}return i}};function VIe(e,g){return`domain(${ft(e.scaleName(g))})`}function oYe(e){return e.parent&&HS(e.parent)&&!e.parent.parent}const bB="_brush",ECt="_scale_trigger",IV="geo_interval_init_tick",DCt="_init",nni="_center",Ini={defined:e=>e.type==="interval",parse:(e,g,i)=>{var n;if(e.hasProjection){const I={...Wt(i.select)?i.select:{}};I.fields=[jA],I.encodings||(I.encodings=i.value?At(i.value):[cl,ll]),i.select={type:"interval",...I}}if(g.translate&&!vd.defined(g)){const I=`!event.item || event.item.mark.name !== ${ft(g.name+bB)}`;for(const r of g.events){if(!r.between){ut(`${r} is not an ordered event stream for interval selections.`);continue}const o=Vt((n=r.between[0]).filter??(n.filter=[]));o.indexOf(I)<0&&o.push(I)}}},signals:(e,g,i)=>{const n=g.name,I=n+Xm,r=fr(g.project.hasChannel).filter(C=>C.channel===hn||C.channel===JI),o=g.init?g.init[0]:null;if(i.push(...r.reduce((C,a)=>C.concat(rni(e,g,a,o&&o[a.index])),[])),e.hasProjection){const C=ft(e.projectionName()),a=e.projectionName()+nni,{x:A,y:s}=g.project.hasChannel,l=A&&A.signals.visual,c=s&&s.signals.visual,u=A?o&&o[A.index]:`${a}[0]`,d=s?o&&o[s.index]:`${a}[1]`,h=Z=>e.getSizeSignalRef(Z).signal,f=`[[${l?l+"[0]":"0"}, ${c?c+"[0]":"0"}],[${l?l+"[1]":h("width")}, ${c?c+"[1]":h("height")}]]`;o&&(i.unshift({name:n+DCt,init:`[scale(${C}, [${A?u[0]:u}, ${s?d[0]:d}]), scale(${C}, [${A?u[1]:u}, ${s?d[1]:d}])]`}),(!A||!s)&&(i.find(v=>v.name===a)||i.unshift({name:a,update:`invert(${C}, [${h("width")}/2, ${h("height")}/2])`})));const m=`intersect(${f}, {markname: ${ft(e.getName("marks"))}}, unit.mark)`,b=`{unit: ${sb(e)}}`,p=`vlSelectionTuples(${m}, ${b})`,y=r.map(Z=>Z.signals.visual);return i.concat({name:I,on:[{events:[...y.length?[{signal:y.join(" || ")}]:[],...o?[{signal:IV}]:[]],update:p}]})}else{if(!vd.defined(g)){const A=n+ECt,s=r.map(l=>{const c=l.channel,{data:u,visual:d}=l.signals,h=ft(e.scaleName(c)),f=e.getScaleComponent(c).get("type"),m=va(f)?"+":"";return`(!isArray(${u}) || (${m}invert(${h}, ${d})[0] === ${m}${u}[0] && ${m}invert(${h}, ${d})[1] === ${m}${u}[1]))`});s.length&&i.push({name:A,value:{},on:[{events:r.map(l=>({scale:e.scaleName(l.channel)})),update:s.join(" && ")+` ? ${A} : {}`}]})}const C=r.map(A=>A.signals.data),a=`unit: ${sb(e)}, fields: ${n+uN}, values`;return i.concat({name:I,...o?{init:`{${a}: ${Vy(o)}}`}:{},...C.length?{on:[{events:[{signal:C.join(" || ")}],update:`${C.join(" && ")} ? {${a}: [${C}]} : null`}]}:{}})}},topLevelSignals:(e,g,i)=>($n(e)&&e.hasProjection&&g.init&&(i.filter(I=>I.name===IV).length||i.unshift({name:IV,value:null,on:[{events:"timer{1}",update:`${IV} === null ? {} : ${IV}`}]})),i),marks:(e,g,i)=>{const n=g.name,{x:I,y:r}=g.project.hasChannel,o=I?.signals.visual,C=r?.signals.visual,a=`data(${ft(g.name+Wy)})`;if(vd.defined(g)||!I&&!r)return i;const A={x:I!==void 0?{signal:`${o}[0]`}:{value:0},y:r!==void 0?{signal:`${C}[0]`}:{value:0},x2:I!==void 0?{signal:`${o}[1]`}:{field:{group:"width"}},y2:r!==void 0?{signal:`${C}[1]`}:{field:{group:"height"}}};if(g.resolve==="global")for(const h of At(A))A[h]=[{test:`${a}.length && ${a}[0].unit === ${sb(e)}`,...A[h]},{value:0}];const{fill:s,fillOpacity:l,cursor:c,...u}=g.mark,d=At(u).reduce((h,f)=>(h[f]=[{test:[I!==void 0&&`${o}[0] !== ${o}[1]`,r!==void 0&&`${C}[0] !== ${C}[1]`].filter(m=>m).join(" && "),value:u[f]},{value:null}],h),{});return[{name:`${n+bB}_bg`,type:"rect",clip:!0,encode:{enter:{fill:{value:s},fillOpacity:{value:l}},update:A}},...i,{name:n+bB,type:"rect",clip:!0,encode:{enter:{...c?{cursor:{value:c}}:{},fill:{value:"transparent"}},update:{...A,...d}}}]}};function rni(e,g,i,n){const I=!e.hasProjection,r=i.channel,o=i.signals.visual,C=ft(I?e.scaleName(r):e.projectionName()),a=c=>`scale(${C}, ${c})`,A=e.getSizeSignalRef(r===hn?"width":"height").signal,s=`${r}(unit)`,l=g.events.reduce((c,u)=>[...c,{events:u.between[0],update:`[${s}, ${s}]`},{events:u,update:`[${o}[0], clamp(${s}, 0, ${A})]`}],[]);if(I){const c=i.signals.data,u=vd.defined(g),d=e.getScaleComponent(r),h=d?d.get("type"):void 0,f=n?{init:Vy(n,!0,a)}:{value:[]};return l.push({events:{signal:g.name+ECt},update:va(h)?`[${a(`${c}[0]`)}, ${a(`${c}[1]`)}]`:"[0, 0]"}),u?[{name:c,on:[]}]:[{name:o,...f,on:l},{name:c,...n?{init:Vy(n)}:{},on:[{events:{signal:o},update:`${o}[0] === ${o}[1] ? null : invert(${C}, ${o})`}]}]}else{const c=r===hn?0:1,u=g.name+DCt,d=n?{init:`[${u}[0][${c}], ${u}[1][${c}]]`}:{value:[]};return[{name:o,...d,on:l}]}}const oni={defined:e=>e.type==="point",signals:(e,g,i)=>{const n=g.name,I=n+uN,r=g.project,o="(item().isVoronoi ? datum.datum : datum)",C=fr(e.component.selection??{}).reduce((l,c)=>c.type==="interval"?l.concat(c.name+bB):l,[]).map(l=>`indexof(item().mark.name, '${l}') < 0`).join(" && "),a=`datum && item().mark.marktype !== 'group' && indexof(item().mark.role, 'legend') < 0${C?` && ${C}`:""}`;let A=`unit: ${sb(e)}, `;if(g.project.hasSelectionId)A+=`${jA}: ${o}[${ft(jA)}]`;else{const l=r.items.map(c=>e.fieldDef(c.channel)?.bin?`[${o}[${ft(e.vgField(c.channel,{}))}], ${o}[${ft(e.vgField(c.channel,{binSuffix:"end"}))}]]`:`${o}[${ft(c.field)}]`).join(", ");A+=`fields: ${I}, values: [${l}]`}const s=g.events;return i.concat([{name:n+Xm,on:s?[{events:s,update:`${a} ? {${A}} : null`,force:!0}]:[]}])}};function VS(e,g,i,n){const I=hJ(g)&&g.condition,r=n(g);if(I){const C=Vt(I).map(a=>{const A=n(a);if(ggi(a)){const{param:s,empty:l}=a;return{test:Iat(e,{param:s,empty:l}),...A}}else return{test:R3(e,a.test),...A}});return{[i]:[...C,...r!==void 0?[r]:[]]}}else return r!==void 0?{[i]:r}:{}}function jfe(e,g="text"){const i=e.encoding[g];return VS(e,i,g,n=>BJ(n,e.config))}function BJ(e,g,i="datum"){if(e){if(QA(e))return nn(e.value);if(fg(e)){const{format:n,formatType:I}=y3(e);return Wfe({fieldOrDatumDef:e,format:n,formatType:I,expr:i,config:g})}}}function MCt(e,g={}){const{encoding:i,markDef:n,config:I,stack:r}=e,o=i.tooltip;if(et(o))return{tooltip:CYe({tooltip:o},r,I,g)};{const C=g.reactiveGeom?"datum.datum":"datum";return VS(e,o,"tooltip",a=>{const A=BJ(a,I,C);if(A)return A;if(a===null)return;let s=di("tooltip",n,I);if(s===!0&&(s={content:"encoding"}),Rt(s))return{value:s};if(Wt(s))return Qt(s)?s:s.content==="encoding"?CYe(i,r,I,g):{signal:C}})}}function zCt(e,g,i,{reactiveGeom:n}={}){const I={...i,...i.tooltipFormat},r={},o=n?"datum.datum":"datum",C=[];function a(s,l){const c=vZ(l),u=Po(s)?s:{...s,type:e[c].type},d=u.title||Nfe(u,I),h=Vt(d).join(", ");let f;if(LI(l)){const m=l==="x"?"x2":"y2",b=Mc(e[m]);if(or(u.bin)&&b){const p=Bt(u,{expr:o}),y=Bt(b,{expr:o}),{format:Z,formatType:v}=y3(u);f=aN(p,y,Z,v,I),r[m]=!0}}if((LI(l)||l===Bs||l===Al)&&g&&g.fieldChannel===l&&g.offset==="normalize"){const{format:m,formatType:b}=y3(u);f=Wfe({fieldOrDatumDef:u,format:m,formatType:b,expr:o,config:I,normalizeStack:!0}).signal}f??(f=BJ(u,I,o).signal),C.push({channel:l,key:h,value:f})}Kfe(e,(s,l)=>{dt(s)?a(s,l):fJ(s)&&a(s.condition,l)});const A={};for(const{channel:s,key:l,value:c}of C)!r[s]&&!A[l]&&(A[l]=c);return A}function CYe(e,g,i,{reactiveGeom:n}={}){const I=zCt(e,g,i,{reactiveGeom:n}),r=Sm(I).map(([o,C])=>`"${o}": ${C}`);return r.length>0?{signal:`{${r.join(", ")}}`}:void 0}function Cni(e){const{markDef:g,config:i}=e,n=di("aria",g,i);return n===!1?{}:{...n?{aria:n}:{},...ani(e),...sni(e)}}function ani(e){const{mark:g,markDef:i,config:n}=e;if(n.aria===!1)return{};const I=di("ariaRoleDescription",i,n);return I!=null?{ariaRoleDescription:{value:I}}:g in _qg?{}:{ariaRoleDescription:{value:g}}}function sni(e){const{encoding:g,markDef:i,config:n,stack:I}=e,r=g.description;if(r)return VS(e,r,"description",a=>BJ(a,e.config));const o=di("description",i,n);if(o!=null)return{description:nn(o)};if(n.aria===!1)return{};const C=zCt(g,I,n);if(!Ri(C))return{description:{signal:Sm(C).map(([a,A],s)=>`"${s>0?"; ":""}${a}: " + (${A})`).join(" + ")}}}function xI(e,g,i={}){const{markDef:n,encoding:I,config:r}=g,{vgChannel:o}=i;let{defaultRef:C,defaultValue:a}=i;C===void 0&&(a??(a=di(e,n,r,{vgChannel:o,ignoreVgConfig:!0})),a!==void 0&&(C=nn(a)));const A=I[e];return VS(g,A,o??e,s=>Vfe({channel:e,channelDef:s,markDef:n,config:r,scaleName:g.scaleName(e),scale:g.getScaleComponent(e),stack:null,defaultRef:C}))}function PCt(e,g={filled:void 0}){const{markDef:i,encoding:n,config:I}=e,{type:r}=i,o=g.filled??di("filled",i,I),C=Eg(["bar","point","circle","square","geoshape"],r)?"transparent":void 0,a=di(o===!0?"color":void 0,i,I,{vgChannel:"fill"})??I.mark[o===!0&&"color"]??C,A=di(o===!1?"color":void 0,i,I,{vgChannel:"stroke"})??I.mark[o===!1&&"color"],s=o?"fill":"stroke",l={...a?{fill:nn(a)}:{},...A?{stroke:nn(A)}:{}};return i.color&&(o?i.fill:i.stroke)&&ut(lot("property",{fill:"fill"in i,stroke:"stroke"in i})),{...l,...xI("color",e,{vgChannel:s,defaultValue:o?a:A}),...xI("fill",e,{defaultValue:n.fill?a:void 0}),...xI("stroke",e,{defaultValue:n.stroke?A:void 0})}}function Ani(e){const{encoding:g,mark:i}=e,n=g.order;return!hp(i)&&QA(n)?VS(e,n,"zindex",I=>nn(I.value)):{}}function q9({channel:e,markDef:g,encoding:i={},model:n,bandPosition:I}){const r=`${e}Offset`,o=g[r],C=i[r];if((r==="xOffset"||r==="yOffset")&&C)return{offsetType:"encoding",offset:Vfe({channel:r,channelDef:C,markDef:g,config:n?.config,scaleName:n.scaleName(r),scale:n.getScaleComponent(r),stack:null,defaultRef:nn(o),bandPosition:I})};const a=g[r];return a?{offsetType:"visual",offset:a}:{}}function Jr(e,g,{defaultPos:i,vgChannel:n}){const{encoding:I,markDef:r,config:o,stack:C}=g,a=I[e],A=I[Cu(e)],s=g.scaleName(e),l=g.getScaleComponent(e),{offset:c,offsetType:u}=q9({channel:e,markDef:r,encoding:I,model:g,bandPosition:.5}),d=$fe({model:g,defaultPos:i,channel:e,scaleName:s,scale:l}),h=!a&&LI(e)&&(I.latitude||I.longitude)?{field:g.getName(e)}:lni({channel:e,channelDef:a,channel2Def:A,markDef:r,config:o,scaleName:s,scale:l,stack:C,offset:c,defaultRef:d,bandPosition:u==="encoding"?0:void 0});return h?{[n||e]:h}:void 0}function lni(e){const{channel:g,channelDef:i,scaleName:n,stack:I,offset:r,markDef:o}=e;if(fg(i)&&I&&g===I.fieldChannel){if(dt(i)){let C=i.bandPosition;if(C===void 0&&o.type==="text"&&(g==="radius"||g==="theta")&&(C=.5),C!==void 0)return m3({scaleName:n,fieldOrDatumDef:i,startSuffix:"start",bandPosition:C,offset:r})}return Cb(i,n,{suffix:"end"},{offset:r})}return Sfe(e)}function $fe({model:e,defaultPos:g,channel:i,scaleName:n,scale:I}){const{markDef:r,config:o}=e;return()=>{const C=vZ(i),a=Rm(i),A=di(i,r,o,{vgChannel:a});if(A!==void 0)return _W(i,A);switch(g){case"zeroOrMin":case"zeroOrMax":if(n){const s=I.get("type");if(!Eg([XC.LOG,XC.TIME,XC.UTC],s)){if(I.domainDefinitelyIncludesZero())return{scale:n,value:0}}}if(g==="zeroOrMin")return C==="y"?{field:{group:"height"}}:{value:0};switch(C){case"radius":return{signal:`min(${e.width.signal},${e.height.signal})/2`};case"theta":return{signal:"2*PI"};case"x":return{field:{group:"width"}};case"y":return{value:0}}break;case"mid":return{...e[FC(i)],mult:.5}}}}const cni={left:"x",center:"xc",right:"x2"},uni={top:"y",middle:"yc",bottom:"y2"};function _Ct(e,g,i,n="middle"){if(e==="radius"||e==="theta")return Rm(e);const I=e==="x"?"align":"baseline",r=di(I,g,i);let o;return Qt(r)?(ut(vei(I)),o=void 0):o=r,e==="x"?cni[o||(n==="top"?"left":"center")]:uni[o||n]}function w3(e,g,{defaultPos:i,defaultPos2:n,range:I}){return I?OCt(e,g,{defaultPos:i,defaultPos2:n}):Jr(e,g,{defaultPos:i})}function OCt(e,g,{defaultPos:i,defaultPos2:n}){const{markDef:I,config:r}=g,o=Cu(e),C=FC(e),a=dni(g,n,o),A=a[C]?_Ct(e,I,r):Rm(e);return{...Jr(e,g,{defaultPos:i,vgChannel:A}),...a}}function dni(e,g,i){const{encoding:n,mark:I,markDef:r,stack:o,config:C}=e,a=vZ(i),A=FC(i),s=Rm(i),l=n[a],c=e.scaleName(a),u=e.getScaleComponent(a),{offset:d}=i in n||i in r?q9({channel:i,markDef:r,encoding:n,model:e}):q9({channel:a,markDef:r,encoding:n,model:e});if(!l&&(i==="x2"||i==="y2")&&(n.latitude||n.longitude)){const f=FC(i),m=e.markDef[f];return m!=null?{[f]:{value:m}}:{[s]:{field:e.getName(i)}}}const h=hni({channel:i,channelDef:l,channel2Def:n[i],markDef:r,config:C,scaleName:c,scale:u,stack:o,offset:d,defaultRef:void 0});return h!==void 0?{[s]:h}:CK(i,r)||CK(i,{[i]:d3(i,r,C.style),[A]:d3(A,r,C.style)})||CK(i,C[I])||CK(i,C.mark)||{[s]:$fe({model:e,defaultPos:g,channel:i,scaleName:c,scale:u})()}}function hni({channel:e,channelDef:g,channel2Def:i,markDef:n,config:I,scaleName:r,scale:o,stack:C,offset:a,defaultRef:A}){return fg(g)&&C&&e.charAt(0)===C.fieldChannel.charAt(0)?Cb(g,r,{suffix:"start"},{offset:a}):Sfe({channel:e,channelDef:i,scaleName:r,scale:o,stack:C,markDef:n,config:I,offset:a,defaultRef:A})}function CK(e,g){const i=FC(e),n=Rm(e);if(g[n]!==void 0)return{[n]:_W(e,g[n])};if(g[e]!==void 0)return{[n]:_W(e,g[e])};if(g[i]){const I=g[i];if(Sy(I))ut(fei(i));else return{[i]:_W(e,I)}}}function Wm(e,g){const{config:i,encoding:n,markDef:I}=e,r=I.type,o=Cu(g),C=FC(g),a=n[g],A=n[o],s=e.getScaleComponent(g),l=s?s.get("type"):void 0,c=I.orient,u=n[C]??n.size??di("size",I,i,{vgChannel:C}),d=Lrt(g),h=r==="bar"&&(g==="x"?c==="vertical":c==="horizontal");return dt(a)&&(Ji(a.bin)||or(a.bin)||a.timeUnit&&!A)&&!(u&&!Sy(u))&&!n[d]&&!UI(l)?pni({fieldDef:a,fieldDef2:A,channel:g,model:e}):(fg(a)&&UI(l)||h)&&!A?mni(a,g,e):OCt(g,e,{defaultPos:"zeroOrMax",defaultPos2:"zeroOrMin"})}function fni(e,g,i,n,I){if(Sy(I))if(i){const o=i.get("type");if(o==="band"){let C=`bandwidth('${g}')`;return I.band!==1&&(C=`${I.band} * ${C}`),{signal:`max(0.25, ${C})`}}else I.band!==1&&(ut(Rei(o)),I=void 0)}else return{mult:I.band,field:{group:e}};else{if(Qt(I))return I;if(I)return{value:I}}if(i){const o=i.get("range");if(dp(o)&&Vi(o.step))return{value:o.step-2}}return{value:v3(n.view,e)-2}}function mni(e,g,i){const{markDef:n,encoding:I,config:r,stack:o}=i,C=n.orient,a=i.scaleName(g),A=i.getScaleComponent(g),s=FC(g),l=Cu(g),c=Lrt(g),u=i.scaleName(c),d=i.getScaleComponent(nfe(g)),h=C==="horizontal"&&g==="y"||C==="vertical"&&g==="x";let f;(I.size||n.size)&&(h?f=xI("size",i,{vgChannel:s,defaultRef:nn(n.size)}):ut(Tei(n.type)));const m=!!f,b=Oot({channel:g,fieldDef:e,markDef:n,config:r,scaleType:A?.get("type"),useVlSizeChannel:h});f=f||{[s]:fni(s,u||a,d||A,r,b)};const p=A?.get("type")==="band"&&Sy(b)&&!m?"top":"middle",y=_Ct(g,n,r,p),Z=y==="xc"||y==="yc",{offset:v,offsetType:G}=q9({channel:g,markDef:n,encoding:I,model:i,bandPosition:Z?.5:0}),B=Sfe({channel:g,channelDef:e,markDef:n,config:r,scaleName:a,scale:A,stack:o,offset:v,defaultRef:$fe({model:i,defaultPos:"mid",channel:g,scaleName:a,scale:A}),bandPosition:Z?G==="encoding"?0:.5:Qt(b)?{signal:`(1-${b})/2`}:Sy(b)?(1-b.band)/2:0});if(s)return{[y]:B,...f};{const S=Rm(l),R=f[s],w=v?{...R,offset:v}:R;return{[y]:B,[S]:et(B)?[B[0],{...B[1],offset:w}]:{...B,offset:w}}}}function rV(e,g,i,n,I){if(Mrt(e))return 0;const r=e==="x"||e==="y2"?-g/2:g/2;if(Qt(i)||Qt(I)||Qt(n)){const o=Gd(i),C=Gd(I),a=Gd(n),A=a?`${a} + `:"",s=o?`(${o} ? -1 : 1) * `:"",l=C?`(${C} + ${r})`:r;return{signal:A+s+l}}else return I=I||0,n+(i?-I-r:+I+r)}function pni({fieldDef:e,fieldDef2:g,channel:i,model:n}){const{config:I,markDef:r,encoding:o}=n,C=n.getScaleComponent(i),a=n.scaleName(i),A=C?C.get("type"):void 0,s=C.get("reverse"),l=Oot({channel:i,fieldDef:e,markDef:r,config:I,scaleType:A}),u=n.component.axes[i]?.[0]?.get("translate")??.5,d=LI(i)?di("binSpacing",r,I)??0:0,h=Cu(i),f=Rm(i),m=Rm(h),{offset:b}=q9({channel:i,markDef:r,encoding:o,model:n,bandPosition:0}),p=Qt(l)?{signal:`(1-${l.signal})/2`}:Sy(l)?(1-l.band)/2:.5;if(Ji(e.bin)||e.timeUnit)return{[m]:aYe({fieldDef:e,scaleName:a,bandPosition:p,offset:rV(h,d,s,u,b)}),[f]:aYe({fieldDef:e,scaleName:a,bandPosition:Qt(p)?{signal:`1-${p.signal}`}:1-p,offset:rV(i,d,s,u,b)})};if(or(e.bin)){const y=Cb(e,a,{},{offset:rV(h,d,s,u,b)});if(dt(g))return{[m]:y,[f]:Cb(g,a,{},{offset:rV(i,d,s,u,b)})};if(BZ(e.bin)&&e.bin.step)return{[m]:y,[f]:{signal:`scale("${a}", ${Bt(e,{expr:"datum"})} + ${e.bin.step})`,offset:rV(i,d,s,u,b)}}}ut(dot(h))}function aYe({fieldDef:e,scaleName:g,bandPosition:i,offset:n}){return m3({scaleName:g,fieldOrDatumDef:e,bandPosition:i,offset:n})}const bni=new Set(["aria","width","height"]);function ws(e,g){const{fill:i=void 0,stroke:n=void 0}=g.color==="include"?PCt(e):{};return{...yni(e.markDef,g),...sYe(e,"fill",i),...sYe(e,"stroke",n),...xI("opacity",e),...xI("fillOpacity",e),...xI("strokeOpacity",e),...xI("strokeWidth",e),...xI("strokeDash",e),...Ani(e),...MCt(e),...jfe(e,"href"),...Cni(e)}}function sYe(e,g,i){const{config:n,mark:I,markDef:r}=e;if(di("invalid",r,n)==="hide"&&i&&!hp(I)){const C=Zni(e,{invalid:!0,channels:rJ});if(C)return{[g]:[{test:C,value:null},...Vt(i)]}}return i?{[g]:i}:{}}function yni(e,g){return Pqg.reduce((i,n)=>(!bni.has(n)&&e[n]!==void 0&&g[n]!=="ignore"&&(i[n]=nn(e[n])),i),{})}function Zni(e,{invalid:g=!1,channels:i}){const n=i.reduce((r,o)=>{const C=e.getScaleComponent(o);if(C){const a=C.get("type"),A=e.vgField(o,{expr:"datum"});A&&va(a)&&(r[A]=!0)}return r},{}),I=At(n);if(I.length>0){const r=g?"||":"&&";return I.map(o=>Rfe(o,g)).join(` ${r} `)}}function qfe(e){const{config:g,markDef:i}=e;if(di("invalid",i,g)){const I=Gni(e,{channels:au});if(I)return{defined:{signal:I}}}return{}}function Gni(e,{invalid:g=!1,channels:i}){const n=i.reduce((r,o)=>{const C=e.getScaleComponent(o);if(C){const a=C.get("type"),A=e.vgField(o,{expr:"datum",binSuffix:e.stack?.impute?"mid":void 0});A&&va(a)&&(r[A]=!0)}return r},{}),I=At(n);if(I.length>0){const r=g?"||":"&&";return I.map(o=>Rfe(o,g)).join(` ${r} `)}}function AYe(e,g){if(g!==void 0)return{[e]:nn(g)}}const P4="voronoi",JCt={defined:e=>e.type==="point"&&e.nearest,parse:(e,g)=>{if(g.events)for(const i of g.events)i.markname=e.getName(P4)},marks:(e,g,i)=>{const{x:n,y:I}=g.project.hasChannel,r=e.mark;if(hp(r))return ut(Qqg(r)),i;const o={name:e.getName(P4),type:"path",interactive:!0,from:{data:e.getName("marks")},encode:{update:{fill:{value:"transparent"},strokeWidth:{value:.35},stroke:{value:"transparent"},isVoronoi:{value:!0},...MCt(e,{reactiveGeom:!0})}},transform:[{type:"voronoi",x:{expr:n||!I?"datum.datum.x || 0":"0"},y:{expr:I||!n?"datum.datum.y || 0":"0"},size:[e.getSizeSignalRef("width"),e.getSizeSignalRef("height")]}]};let C=0,a=!1;return i.forEach((A,s)=>{const l=A.name??"";l===e.component.mark[0].name?C=s:l.indexOf(P4)>=0&&(a=!0)}),a||i.splice(C+1,0,o),i}},LCt={defined:e=>e.type==="point"&&e.resolve==="global"&&e.bind&&e.bind!=="scales"&&!zfe(e.bind),parse:(e,g,i)=>gat(g,i),topLevelSignals:(e,g,i)=>{const n=g.name,I=g.project,r=g.bind,o=g.init&&g.init[0],C=JCt.defined(g)?"(item().isVoronoi ? datum.datum : datum)":"datum";return I.items.forEach((a,A)=>{const s=dn(`${n}_${a.field}`);i.filter(c=>c.name===s).length||i.unshift({name:s,...o?{init:Vy(o[A])}:{value:null},on:g.events?[{events:g.events,update:`datum && item().mark.marktype !== 'group' ? ${C}[${ft(a.field)}] : null`}]:[],bind:r[a.field]??r[a.channel]??r})}),i},signals:(e,g,i)=>{const n=g.name,I=g.project,r=i.filter(A=>A.name===n+Xm)[0],o=n+uN,C=I.items.map(A=>dn(`${n}_${A.field}`)),a=C.map(A=>`${A} !== null`).join(" && ");return C.length&&(r.update=`${a} ? {fields: ${o}, values: [${C.join(", ")}]} : null`),delete r.value,delete r.on,i}},S3="_toggle",UCt={defined:e=>e.type==="point"&&!!e.toggle,signals:(e,g,i)=>i.concat({name:g.name+S3,value:!1,on:[{events:g.events,update:g.toggle}]}),modifyExpr:(e,g)=>{const i=g.name+Xm,n=g.name+S3;return`${n} ? null : ${i}, `+(g.resolve==="global"?`${n} ? null : true, `:`${n} ? null : {unit: ${sb(e)}}, `)+`${n} ? ${i} : null`}},vni={defined:e=>e.clear!==void 0&&e.clear!==!1,parse:(e,g)=>{g.clear&&(g.clear=Rt(g.clear)?Cp(g.clear,"view"):g.clear)},topLevelSignals:(e,g,i)=>{if(LCt.defined(g))for(const n of g.project.items){const I=i.findIndex(r=>r.name===dn(`${g.name}_${n.field}`));I!==-1&&i[I].on.push({events:g.clear,update:"null"})}return i},signals:(e,g,i)=>{function n(I,r){I!==-1&&i[I].on&&i[I].on.push({events:g.clear,update:r})}if(g.type==="interval")for(const I of g.project.items){const r=i.findIndex(o=>o.name===I.signals.visual);if(n(r,"[0, 0]"),r===-1){const o=i.findIndex(C=>C.name===I.signals.data);n(o,"null")}}else{let I=i.findIndex(r=>r.name===g.name+Xm);n(I,"null"),UCt.defined(g)&&(I=i.findIndex(r=>r.name===g.name+S3),n(I,"false"))}return i}},QCt={defined:e=>{const g=e.resolve==="global"&&e.bind&&zfe(e.bind),i=e.project.items.length===1&&e.project.items[0].field!==jA;return g&&!i&&ut(qqg),g&&i},parse:(e,g,i)=>{const n=mg(i);if(n.select=Rt(n.select)?{type:n.select,toggle:g.toggle}:{...n.select,toggle:g.toggle},gat(g,n),Wt(i.select)&&(i.select.on||i.select.clear)){const o='event.item && indexof(event.item.mark.role, "legend") < 0';for(const C of g.events)C.filter=Vt(C.filter??[]),C.filter.includes(o)||C.filter.push(o)}const I=D4(g.bind)?g.bind.legend:"click",r=Rt(I)?Cp(I,"view"):Vt(I);g.bind={legend:{merge:r}}},topLevelSignals:(e,g,i)=>{const n=g.name,I=D4(g.bind)&&g.bind.legend,r=o=>C=>{const a=mg(C);return a.markname=o,a};for(const o of g.project.items){if(!o.hasLegend)continue;const C=`${dn(o.field)}_legend`,a=`${n}_${C}`;if(i.filter(s=>s.name===a).length===0){const s=I.merge.map(r(`${C}_symbols`)).concat(I.merge.map(r(`${C}_labels`))).concat(I.merge.map(r(`${C}_entries`)));i.unshift({name:a,...g.init?{}:{value:null},on:[{events:s,update:"datum.value || item().items[0].items[0].datum.value",force:!0},{events:I.merge,update:`!event.item || !datum ? null : ${a}`,force:!0}]})}}return i},signals:(e,g,i)=>{const n=g.name,I=g.project,r=i.find(c=>c.name===n+Xm),o=n+uN,C=I.items.filter(c=>c.hasLegend).map(c=>dn(`${n}_${dn(c.field)}_legend`)),A=`${C.map(c=>`${c} !== null`).join(" && ")} ? {fields: ${o}, values: [${C.join(", ")}]} : null`;g.events&&C.length>0?r.on.push({events:C.map(c=>({signal:c})),update:A}):C.length>0&&(r.update=A,delete r.value,delete r.on);const s=i.find(c=>c.name===n+S3),l=D4(g.bind)&&g.bind.legend;return s&&(g.events?s.on.push({...s.on[0],events:l}):s.on[0].events=l),i}};function Bni(e,g,i){const n=e.fieldDef(g)?.field;for(const I of fr(e.component.selection??{})){const r=I.project.hasField[n]??I.project.hasChannel[g];if(r&&QCt.defined(I)){const o=i.get("selections")??[];o.push(I.name),i.set("selections",o,!1),r.hasLegend=!0}}}const jCt="_translate_anchor",$Ct="_translate_delta",wni={defined:e=>e.type==="interval"&&e.translate,signals:(e,g,i)=>{const n=g.name,I=vd.defined(g),r=n+jCt,{x:o,y:C}=g.project.hasChannel;let a=Cp(g.translate,"scope");return I||(a=a.map(A=>(A.between[0].markname=n+bB,A))),i.push({name:r,value:{},on:[{events:a.map(A=>A.between[0]),update:"{x: x(unit), y: y(unit)"+(o!==void 0?`, extent_x: ${I?VIe(e,hn):`slice(${o.signals.visual})`}`:"")+(C!==void 0?`, extent_y: ${I?VIe(e,JI):`slice(${C.signals.visual})`}`:"")+"}"}]},{name:n+$Ct,value:{},on:[{events:a,update:`{x: ${r}.x - x(unit), y: ${r}.y - y(unit)}`}]}),o!==void 0&&lYe(e,g,o,"width",i),C!==void 0&&lYe(e,g,C,"height",i),i}};function lYe(e,g,i,n,I){const r=g.name,o=r+jCt,C=r+$Ct,a=i.channel,A=vd.defined(g),s=I.filter(Z=>Z.name===i.signals[A?"data":"visual"])[0],l=e.getSizeSignalRef(n).signal,c=e.getScaleComponent(a),u=c&&c.get("type"),d=c&&c.get("reverse"),h=A?a===hn?d?"":"-":d?"-":"":"",f=`${o}.extent_${a}`,m=`${h}${C}.${a} / ${A?`${l}`:`span(${f})`}`,b=!A||!c?"panLinear":u==="log"?"panLog":u==="symlog"?"panSymlog":u==="pow"?"panPow":"panLinear",p=A?u==="pow"?`, ${c.get("exponent")??1}`:u==="symlog"?`, ${c.get("constant")??1}`:"":"",y=`${b}(${f}, ${m}${p})`;s.on.push({events:{signal:C},update:A?y:`clampRange(${y}, 0, ${l})`})}const qCt="_zoom_anchor",eat="_zoom_delta",Sni={defined:e=>e.type==="interval"&&e.zoom,signals:(e,g,i)=>{const n=g.name,I=vd.defined(g),r=n+eat,{x:o,y:C}=g.project.hasChannel,a=ft(e.scaleName(hn)),A=ft(e.scaleName(JI));let s=Cp(g.zoom,"scope");return I||(s=s.map(l=>(l.markname=n+bB,l))),i.push({name:n+qCt,on:[{events:s,update:I?"{"+[a?`x: invert(${a}, x(unit))`:"",A?`y: invert(${A}, y(unit))`:""].filter(l=>l).join(", ")+"}":"{x: x(unit), y: y(unit)}"}]},{name:r,on:[{events:s,force:!0,update:"pow(1.001, event.deltaY * pow(16, event.deltaMode))"}]}),o!==void 0&&cYe(e,g,o,"width",i),C!==void 0&&cYe(e,g,C,"height",i),i}};function cYe(e,g,i,n,I){const r=g.name,o=i.channel,C=vd.defined(g),a=I.filter(b=>b.name===i.signals[C?"data":"visual"])[0],A=e.getSizeSignalRef(n).signal,s=e.getScaleComponent(o),l=s&&s.get("type"),c=C?VIe(e,o):a.name,u=r+eat,d=`${r}${qCt}.${o}`,h=!C||!s?"zoomLinear":l==="log"?"zoomLog":l==="symlog"?"zoomSymlog":l==="pow"?"zoomPow":"zoomLinear",f=C?l==="pow"?`, ${s.get("exponent")??1}`:l==="symlog"?`, ${s.get("constant")??1}`:"":"",m=`${h}(${c}, ${d}, ${u}${f})`;a.on.push({events:{signal:u},update:C?m:`clampRange(${m}, 0, ${A})`})}const Wy="_store",Xm="_tuple",Rni="_modify",tat="vlSelectionResolve",wJ=[oni,Ini,ini,UCt,LCt,vd,QCt,vni,wni,Sni,JCt];function Vni(e){let g=e.parent;for(;g&&!DA(g);)g=g.parent;return g}function sb(e,{escape:g}={escape:!0}){let i=g?ft(e.name):e.name;const n=Vni(e);if(n){const{facet:I}=n;for(const r of ns)I[r]&&(i+=` + '__facet_${r}_' + (facet[${ft(n.vgField(r))}])`)}return i}function eme(e){return fr(e.component.selection??{}).reduce((g,i)=>g||i.project.hasSelectionId,!1)}function gat(e,g){(Rt(g.select)||!g.select.on)&&delete e.events,(Rt(g.select)||!g.select.clear)&&delete e.clear,(Rt(g.select)||!g.select.toggle)&&delete e.toggle}function WIe(e){const g=[];return e.type==="Identifier"?[e.name]:e.type==="Literal"?[e.value]:(e.type==="MemberExpression"&&(g.push(...WIe(e.object)),g.push(...WIe(e.property))),g)}function iat(e){return e.object.type==="MemberExpression"?iat(e.object):e.object.name==="datum"}function nat(e){const g=hhe(e),i=new Set;return g.visit(n=>{n.type==="MemberExpression"&&iat(n)&&i.add(WIe(n).slice(1).join("."))}),i}class WS extends Xi{clone(){return new WS(null,this.model,mg(this.filter))}constructor(g,i,n){super(g),this.model=i,this.filter=n,this.expr=R3(this.model,this.filter,this),this._dependentFields=nat(this.expr)}dependentFields(){return this._dependentFields}producedFields(){return new Set}assemble(){return{type:"filter",expr:this.expr}}hash(){return`Filter ${this.expr}`}}function Wni(e,g){const i={},n=e.config.selection;if(!g||!g.length)return i;for(const I of g){const r=dn(I.name),o=I.select,C=Rt(o)?o:o.type,a=Wt(o)?mg(o):{type:C},A=n[C];for(const c in A)c==="fields"||c==="encodings"||(c==="mark"&&(a[c]={...A[c],...a[c]}),(a[c]===void 0||a[c]===!0)&&(a[c]=mg(A[c]??a[c])));const s=i[r]={...a,name:r,type:C,init:I.value,bind:I.bind,events:Rt(a.on)?Cp(a.on,"scope"):Vt(mg(a.on))},l=mg(I);for(const c of wJ)c.defined(s)&&c.parse&&c.parse(e,s,l)}return i}function Iat(e,g,i,n="datum"){const I=Rt(g)?g:g.param,r=dn(I),o=ft(r+Wy);let C;try{C=e.getSelectionComponent(r,I)}catch{return`!!${r}`}if(C.project.timeUnit){const c=i??e.component.data.raw,u=C.project.timeUnit.clone();c.parent?u.insertAsParentOf(c):c.parent=u}const a=C.project.hasSelectionId?"vlSelectionIdTest(":"vlSelectionTest(",A=C.resolve==="global"?")":`, ${ft(C.resolve)})`,s=`${a}${o}, ${n}${A}`,l=`length(data(${o}))`;return g.empty===!1?`${l} && ${s}`:`!${l} || ${s}`}function rat(e,g,i){const n=dn(g),I=i.encoding;let r=i.field,o;try{o=e.getSelectionComponent(n,g)}catch{return n}if(!I&&!r)r=o.project.items[0].field,o.project.items.length>1&&ut(`A "field" or "encoding" must be specified when using a selection as a scale domain. Using "field": ${ft(r)}.`);else if(I&&!r){const C=o.project.items.filter(a=>a.channel===I);!C.length||C.length>1?(r=o.project.items[0].field,ut((C.length?"Multiple ":"No ")+`matching ${ft(I)} encoding found for selection ${ft(i.param)}. Using "field": ${ft(r)}.`)):r=C[0].field}return`${o.name}[${ft(ys(r))}]`}function Xni(e,g){for(const[i,n]of Sm(e.component.selection??{})){const I=e.getName(`lookup_${i}`);e.component.data.outputNodes[I]=n.materialized=new Ko(new WS(g,e,{param:i}),I,zi.Lookup,e.component.data.outputNodeRefCounts)}}function R3(e,g,i){return PW(g,n=>Rt(n)?n:uti(n)?Iat(e,n,i):vot(n))}function Tni(e,g){if(e)return et(e)&&!nf(e)?e.map(i=>Nfe(i,g)).join(", "):e}function _4(e,g,i,n){var I,r;e.encode??(e.encode={}),(I=e.encode)[g]??(I[g]={}),(r=e.encode[g]).update??(r.update={}),e.encode[g].update[i]=n}function Z2(e,g,i,n={header:!1}){const{disable:I,orient:r,scale:o,labelExpr:C,title:a,zindex:A,...s}=e.combine();if(!I){for(const l in s){const c=hgi[l],u=s[l];if(c&&c!==g&&c!=="both")delete s[l];else if(cN(u)){const{condition:d,...h}=u,f=Vt(d),m=_ke[l];if(m){const{vgProp:b,part:p}=m,y=[...f.map(Z=>{const{test:v,...G}=Z;return{test:R3(null,v),...G}}),h];_4(s,p,b,y),delete s[l]}else if(m===null){const b={signal:f.map(p=>{const{test:y,...Z}=p;return`${R3(null,y)} ? ${Vke(Z)} : `}).join("")+Vke(h)};s[l]=b}}else if(Qt(u)){const d=_ke[l];if(d){const{vgProp:h,part:f}=d;_4(s,f,h,u),delete s[l]}}Eg(["labelAlign","labelBaseline"],l)&&s[l]===null&&delete s[l]}if(g==="grid"){if(!s.grid)return;if(s.encode){const{grid:l}=s.encode;s.encode={...l?{grid:l}:{}},Ri(s.encode)&&delete s.encode}return{scale:o,orient:r,...s,domain:!1,labels:!1,aria:!1,maxExtent:0,minExtent:0,ticks:!1,zindex:CI(A,0)}}else{if(!n.header&&e.mainExtracted)return;if(C!==void 0){let c=C;s.encode?.labels?.update&&Qt(s.encode.labels.update.text)&&(c=Zy(C,"datum.label",s.encode.labels.update.text.signal)),_4(s,"labels","text",{signal:c})}if(s.labelAlign===null&&delete s.labelAlign,s.encode){for(const c of tCt)e.hasAxisPart(c)||delete s.encode[c];Ri(s.encode)&&delete s.encode}const l=Tni(a,i);return{scale:o,orient:r,grid:!1,...l?{title:l}:{},...s,...i.aria===!1?{aria:!1}:{},zindex:CI(A,0)}}}}function oat(e){const{axes:g}=e.component,i=[];for(const n of au)if(g[n]){for(const I of g[n])if(!I.get("disable")&&!I.get("gridScale")){const r=n==="x"?"height":"width",o=e.getSizeSignalRef(r).signal;r!==o&&i.push({name:r,update:o})}}return i}function Hni(e,g){const{x:i=[],y:n=[]}=e;return[...i.map(I=>Z2(I,"grid",g)),...n.map(I=>Z2(I,"grid",g)),...i.map(I=>Z2(I,"main",g)),...n.map(I=>Z2(I,"main",g))].filter(I=>I)}function uYe(e,g,i,n){return Object.assign.apply(null,[{},...e.map(I=>{if(I==="axisOrient"){const r=i==="x"?"bottom":"left",o=g[i==="x"?"axisBottom":"axisLeft"]||{},C=g[i==="x"?"axisTop":"axisRight"]||{},a=new Set([...At(o),...At(C)]),A={};for(const s of a.values())A[s]={signal:`${n.signal} === "${r}" ? ${Gd(o[s])} : ${Gd(C[s])}`};return A}return g[I]})])}function Nni(e,g,i,n){const I=g==="band"?["axisDiscrete","axisBand"]:g==="point"?["axisDiscrete","axisPoint"]:Rot(g)?["axisQuantitative"]:g==="time"||g==="utc"?["axisTemporal"]:[],r=e==="x"?"axisX":"axisY",o=Qt(i)?"axisOrient":`axis${iN(i)}`,C=[...I,...I.map(A=>r+A.substr(4))],a=["axis",o,r];return{vlOnlyAxisConfig:uYe(C,n,e,i),vgAxisConfig:uYe(a,n,e,i),axisConfigStyle:kni([...a,...C],n)}}function kni(e,g){const i=[{}];for(const n of e){let I=g[n]?.style;if(I){I=Vt(I);for(const r of I)i.push(g.style[r])}}return Object.assign.apply(null,i)}function XIe(e,g,i,n={}){const I=Iot(e,i,g);if(I!==void 0)return{configFrom:"style",configValue:I};for(const r of["vlOnlyAxisConfig","vgAxisConfig","axisConfigStyle"])if(n[r]?.[e]!==void 0)return{configFrom:r,configValue:n[r][e]};return{}}const dYe={scale:({model:e,channel:g})=>e.scaleName(g),format:({format:e})=>e,formatType:({formatType:e})=>e,grid:({fieldOrDatumDef:e,axis:g,scaleType:i})=>g.grid??Yni(i,e),gridScale:({model:e,channel:g})=>Kni(e,g),labelAlign:({axis:e,labelAngle:g,orient:i,channel:n})=>e.labelAlign||aat(g,i,n),labelAngle:({labelAngle:e})=>e,labelBaseline:({axis:e,labelAngle:g,orient:i,channel:n})=>e.labelBaseline||Cat(g,i,n),labelFlush:({axis:e,fieldOrDatumDef:g,channel:i})=>e.labelFlush??Fni(g.type,i),labelOverlap:({axis:e,fieldOrDatumDef:g,scaleType:i})=>e.labelOverlap??Eni(g.type,i,dt(g)&&!!g.timeUnit,dt(g)?g.sort:void 0),orient:({orient:e})=>e,tickCount:({channel:e,model:g,axis:i,fieldOrDatumDef:n,scaleType:I})=>{const r=e==="x"?"width":e==="y"?"height":void 0,o=r?g.getSizeSignalRef(r):void 0;return i.tickCount??Mni({fieldOrDatumDef:n,scaleType:I,size:o,values:i.values})},tickMinStep:zni,title:({axis:e,model:g,channel:i})=>{if(e.title!==void 0)return e.title;const n=sat(g,i);if(n!==void 0)return n;const I=g.typedFieldDef(i),r=i==="x"?"x2":"y2",o=g.fieldDef(r);return oot(I?[zke(I)]:[],dt(o)?[zke(o)]:[])},values:({axis:e,fieldOrDatumDef:g})=>Pni(e,g),zindex:({axis:e,fieldOrDatumDef:g,mark:i})=>e.zindex??_ni(i,g)};function Yni(e,g){return!UI(e)&&dt(g)&&!Ji(g?.bin)&&!or(g?.bin)}function Kni(e,g){const i=g==="x"?"y":"x";if(e.getScaleComponent(i))return e.scaleName(i)}function xni(e,g,i,n,I){const r=g?.labelAngle;if(r!==void 0)return Qt(r)?r:j9(r);{const{configValue:o}=XIe("labelAngle",n,g?.style,I);return o!==void 0?j9(o):i===hn&&Eg([Gfe,Zfe],e.type)&&!(dt(e)&&e.timeUnit)?270:void 0}}function TIe(e){return`(((${e.signal} % 360) + 360) % 360)`}function Cat(e,g,i,n){if(e!==void 0)if(i==="x"){if(Qt(e)){const I=TIe(e),r=Qt(g)?`(${g.signal} === "top")`:g==="top";return{signal:`(45 < ${I} && ${I} < 135) || (225 < ${I} && ${I} < 315) ? "middle" :(${I} <= 45 || 315 <= ${I}) === ${r} ? "bottom" : "top"`}}if(45{if(SZ(n)&&Pot(n.sort)){const{field:r,timeUnit:o}=n,C=n.sort,a=C.map((A,s)=>`${vot({field:r,timeUnit:o,equal:A})} ? ${s} : `).join("")+C.length;g=new l1(g,{calculate:a,as:c1(n,I,{forAs:!0})})}}),g}producedFields(){return new Set([this.transform.as])}dependentFields(){return this._dependentFields}assemble(){return{type:"formula",expr:this.transform.calculate,as:this.transform.as}}hash(){return`Calculate ${$g(this.transform)}`}}function c1(e,g,i){return Bt(e,{prefix:g,suffix:"sort_index",...i??{}})}function SJ(e,g){return Eg(["top","bottom"],g)?"column":Eg(["left","right"],g)||e==="row"?"row":"column"}function u1(e,g,i,n){const I=n==="row"?i.headerRow:n==="column"?i.headerColumn:i.headerFacet;return CI((g||{})[e],I[e],i.header[e])}function RJ(e,g,i,n){const I={};for(const r of e){const o=u1(r,g||{},i,n);o!==void 0&&(I[r]=o)}return I}const tme=["row","column"],gme=["header","footer"];function Oni(e,g){const i=e.component.layoutHeaders[g].title,n=e.config?e.config:void 0,I=e.component.layoutHeaders[g].facetFieldDef?e.component.layoutHeaders[g].facetFieldDef:void 0,{titleAnchor:r,titleAngle:o,titleOrient:C}=RJ(["titleAnchor","titleAngle","titleOrient"],I.header,n,g),a=SJ(g,C),A=j9(o);return{name:`${g}-title`,type:"group",role:`${a}-title`,title:{text:i,...g==="row"?{orient:"left"}:{},style:"guide-title",...lat(A,a),...Aat(a,A,r),...cat(n,I,g,xgi,fCt)}}}function Aat(e,g,i="middle"){switch(i){case"start":return{align:"left"};case"end":return{align:"right"}}const n=aat(g,e==="row"?"left":"top",e==="row"?"y":"x");return n?{align:n}:{}}function lat(e,g){const i=Cat(e,g==="row"?"left":"top",g==="row"?"y":"x",!0);return i?{baseline:i}:{}}function Jni(e,g){const i=e.component.layoutHeaders[g],n=[];for(const I of gme)if(i[I])for(const r of i[I]){const o=Uni(e,g,I,i,r);o!=null&&n.push(o)}return n}function Lni(e,g){const{sort:i}=e;return yc(i)?{field:Bt(i,{expr:"datum"}),order:i.order??"ascending"}:et(i)?{field:c1(e,g,{expr:"datum"}),order:"ascending"}:{field:Bt(e,{expr:"datum"}),order:i??"ascending"}}function HIe(e,g,i){const{format:n,formatType:I,labelAngle:r,labelAnchor:o,labelOrient:C,labelExpr:a}=RJ(["format","formatType","labelAngle","labelAnchor","labelOrient","labelExpr"],e.header,i,g),A=Wfe({fieldOrDatumDef:e,format:n,formatType:I,expr:"parent",config:i}).signal,s=SJ(g,C);return{text:{signal:a?Zy(Zy(a,"datum.label",A),"datum.value",Bt(e,{expr:"parent"})):A},...g==="row"?{orient:"left"}:{},style:"guide-label",frame:"group",...lat(r,s),...Aat(s,r,o),...cat(i,e,g,Fgi,mCt)}}function Uni(e,g,i,n,I){if(I){let r=null;const{facetFieldDef:o}=n,C=e.config?e.config:void 0;if(o&&I.labels){const{labelOrient:l}=RJ(["labelOrient"],o.header,C,g);(g==="row"&&!Eg(["top","bottom"],l)||g==="column"&&!Eg(["left","right"],l))&&(r=HIe(o,g,C))}const a=DA(e)&&!sN(e.facet),A=I.axes,s=A?.length>0;if(r||s){const l=g==="row"?"height":"width";return{name:e.getName(`${g}_${i}`),type:"group",role:`${g}-${i}`,...n.facetFieldDef?{from:{data:e.getName(`${g}_domain`)},sort:Lni(o,g)}:{},...s&&a?{from:{data:e.getName(`facet_domain_${g}`)}}:{},...r?{title:r}:{},...I.sizeSignal?{encode:{update:{[l]:I.sizeSignal}}}:{},...s?{axes:A}:{}}}}return null}const Qni={column:{start:0,end:1},row:{start:1,end:0}};function jni(e,g){return Qni[g][e]}function $ni(e,g){const i={};for(const n of ns){const I=e[n];if(I?.facetFieldDef){const{titleAnchor:r,titleOrient:o}=RJ(["titleAnchor","titleOrient"],I.facetFieldDef.header,g,n),C=SJ(n,o),a=jni(r,C);a!==void 0&&(i[C]=a)}}return Ri(i)?void 0:i}function cat(e,g,i,n,I){const r={};for(const o of n){if(!I[o])continue;const C=u1(o,g?.header,e,i);C!==void 0&&(r[I[o]]=C)}return r}function ime(e){return[...aK(e,"width"),...aK(e,"height"),...aK(e,"childWidth"),...aK(e,"childHeight")]}function aK(e,g){const i=g==="width"?"x":"y",n=e.component.layoutSize.get(g);if(!n||n==="merged")return[];const I=e.getSizeSignalRef(g).signal;if(n==="step"){const r=e.getScaleComponent(i);if(r){const o=r.get("type"),C=r.get("range");if(UI(o)&&dp(C)){const a=e.scaleName(i);return DA(e.parent)&&e.parent.component.resolve.scale[i]==="independent"?[hYe(a,C)]:[hYe(a,C),{name:I,update:uat(a,r,`domain('${a}').length`)}]}}throw new Error("layout size is step although width/height is not step.")}else if(n=="container"){const r=I.endsWith("width"),o=r?"containerSize()[0]":"containerSize()[1]",C=BIe(e.config.view,r?"width":"height"),a=`isFinite(${o}) ? ${o} : ${C}`;return[{name:I,init:a,on:[{update:a,events:"window:resize"}]}]}else return[{name:I,value:n}]}function hYe(e,g){const i=`${e}_step`;return Qt(g.step)?{name:i,update:g.step.signal}:{name:i,value:g.step}}function uat(e,g,i){const n=g.get("type"),I=g.get("padding"),r=CI(g.get("paddingOuter"),I);let o=g.get("paddingInner");return o=n==="band"?o!==void 0?o:I:1,`bandspace(${i}, ${Gd(o)}, ${Gd(r)}) * ${e}_step`}function dat(e){return e==="childWidth"?"width":e==="childHeight"?"height":e}function hat(e,g){return At(e).reduce((i,n)=>{const I=e[n];return{...i,...VS(g,I,n,r=>nn(r.value))}},{})}function fat(e,g){if(DA(g))return e==="theta"?"independent":"shared";if(HS(g))return"shared";if(sme(g))return LI(e)||e==="theta"||e==="radius"?"independent":"shared";throw new Error("invalid model type for resolve")}function nme(e,g){const i=e.scale[g],n=LI(g)?"axis":"legend";return i==="independent"?(e[n][g]==="shared"&&ut(Kei(g)),"independent"):e[n][g]||"shared"}const qni={...Mgi,disable:1,labelExpr:1,selections:1,opacity:1,shape:1,stroke:1,fill:1,size:1,strokeWidth:1,strokeDash:1,encode:1},mat=At(qni);class eIi extends hh{}const fYe={symbols:tIi,gradient:gIi,labels:iIi,entries:nIi};function tIi(e,{fieldOrDatumDef:g,model:i,channel:n,legendCmpt:I,legendType:r}){if(r!=="symbol")return;const{markDef:o,encoding:C,config:a,mark:A}=i,s=o.filled&&A!=="trail";let l={...Jqg({},i,Fti),...PCt(i,{filled:s})};const c=I.get("symbolOpacity")??a.legend.symbolOpacity,u=I.get("symbolFillColor")??a.legend.symbolFillColor,d=I.get("symbolStrokeColor")??a.legend.symbolStrokeColor,h=c===void 0?pat(C.opacity)??o.opacity:void 0;if(l.fill){if(n==="fill"||s&&n===KC)delete l.fill;else if(l.fill.field)u?delete l.fill:(l.fill=nn(a.legend.symbolBaseFillColor??"black"),l.fillOpacity=nn(h??1));else if(et(l.fill)){const f=NIe(C.fill??C.color)??o.fill??(s&&o.color);f&&(l.fill=nn(f))}}if(l.stroke){if(n==="stroke"||!s&&n===KC)delete l.stroke;else if(l.stroke.field||d)delete l.stroke;else if(et(l.stroke)){const f=CI(NIe(C.stroke||C.color),o.stroke,s?o.color:void 0);f&&(l.stroke={value:f})}}if(n!==ch){const f=dt(g)&&yat(i,I,g);f?l.opacity=[{test:f,...nn(h??1)},nn(a.legend.unselectedOpacity)]:h&&(l.opacity=nn(h))}return l={...l,...e},Ri(l)?void 0:l}function gIi(e,{model:g,legendType:i,legendCmpt:n}){if(i!=="gradient")return;const{config:I,markDef:r,encoding:o}=g;let C={};const A=(n.get("gradientOpacity")??I.legend.gradientOpacity)===void 0?pat(o.opacity)||r.opacity:void 0;return A&&(C.opacity=nn(A)),C={...C,...e},Ri(C)?void 0:C}function iIi(e,{fieldOrDatumDef:g,model:i,channel:n,legendCmpt:I}){const r=i.legend(n)||{},o=i.config,C=dt(g)?yat(i,I,g):void 0,a=C?[{test:C,value:1},{value:o.legend.unselectedOpacity}]:void 0,{format:A,formatType:s}=r;let l;Ry(s)?l=VA({fieldOrDatumDef:g,field:"datum.value",format:A,formatType:s,config:o}):A===void 0&&s===void 0&&o.customFormatTypes&&(g.type==="quantitative"&&o.numberFormatType?l=VA({fieldOrDatumDef:g,field:"datum.value",format:o.numberFormat,formatType:o.numberFormatType,config:o}):g.type==="temporal"&&o.timeFormatType&&dt(g)&&g.timeUnit===void 0&&(l=VA({fieldOrDatumDef:g,field:"datum.value",format:o.timeFormat,formatType:o.timeFormatType,config:o})));const c={...a?{opacity:a}:{},...l?{text:l}:{},...e};return Ri(c)?void 0:c}function nIi(e,{legendCmpt:g}){return g.get("selections")?.length?{...e,fill:{value:"transparent"}}:e}function pat(e){return bat(e,(g,i)=>Math.max(g,i.value))}function NIe(e){return bat(e,(g,i)=>CI(g,i.value))}function bat(e,g){if(ngi(e))return Vt(e.condition).reduce(g,e.value);if(QA(e))return e.value}function yat(e,g,i){const n=g.get("selections");if(!n?.length)return;const I=ft(i.field);return n.map(r=>`(!length(data(${ft(dn(r)+Wy)})) || (${r}[${I}] && indexof(${r}[${I}], datum.value) >= 0))`).join(" || ")}const mYe={direction:({direction:e})=>e,format:({fieldOrDatumDef:e,legend:g,config:i})=>{const{format:n,formatType:I}=g;return Eot(e,e.type,n,I,i,!1)},formatType:({legend:e,fieldOrDatumDef:g,scaleType:i})=>{const{formatType:n}=e;return Dot(n,g,i)},gradientLength:e=>{const{legend:g,legendConfig:i}=e;return g.gradientLength??i.gradientLength??AIi(e)},labelOverlap:({legend:e,legendConfig:g,scaleType:i})=>e.labelOverlap??g.labelOverlap??lIi(i),symbolType:({legend:e,markDef:g,channel:i,encoding:n})=>e.symbolType??rIi(g.type,i,n.shape,g.shape),title:({fieldOrDatumDef:e,config:g})=>pB(e,g,{allowDisabling:!0}),type:({legendType:e,scaleType:g,channel:i})=>{if(mB(i)&&RA(g)){if(e==="gradient")return}else if(e==="symbol")return;return e},values:({fieldOrDatumDef:e,legend:g})=>IIi(g,e)};function IIi(e,g){const i=e.values;if(et(i))return eCt(g,i);if(Qt(i))return i}function rIi(e,g,i,n){if(g!=="shape"){const I=NIe(i)??n;if(I)return I}switch(e){case"bar":case"rect":case"image":case"square":return"square";case"line":case"trail":case"rule":return"stroke";case"arc":case"point":case"circle":case"tick":case"geoshape":case"area":case"text":return"circle"}}function oIi(e){const{legend:g}=e;return CI(g.type,CIi(e))}function CIi({channel:e,timeUnit:g,scaleType:i}){if(mB(e)){if(Eg(["quarter","month","day"],g))return"symbol";if(RA(i))return"gradient"}return"symbol"}function aIi({legendConfig:e,legendType:g,orient:i,legend:n}){return n.direction??e[g?"gradientDirection":"symbolDirection"]??sIi(i,g)}function sIi(e,g){switch(e){case"top":case"bottom":return"horizontal";case"left":case"right":case"none":case void 0:return;default:return g==="gradient"?"horizontal":void 0}}function AIi({legendConfig:e,model:g,direction:i,orient:n,scaleType:I}){const{gradientHorizontalMaxLength:r,gradientHorizontalMinLength:o,gradientVerticalMaxLength:C,gradientVerticalMinLength:a}=e;if(RA(I))return i==="horizontal"?n==="top"||n==="bottom"?pYe(g,"width",o,r):o:pYe(g,"height",a,C)}function pYe(e,g,i,n){return{signal:`clamp(${e.getSizeSignalRef(g).signal}, ${i}, ${n})`}}function lIi(e){if(Eg(["quantile","threshold","log","symlog"],e))return"greedy"}function Zat(e){const g=$n(e)?cIi(e):fIi(e);return e.component.legends=g,g}function cIi(e){const{encoding:g}=e,i={};for(const n of[KC,...bCt]){const I=ZI(g[n]);!I||!e.getScaleComponent(n)||n===xC&&dt(I)&&I.type===RS||(i[n]=hIi(e,n))}return i}function uIi(e,g){const i=e.scaleName(g);if(e.mark==="trail"){if(g==="color")return{stroke:i};if(g==="size")return{strokeWidth:i}}return g==="color"?e.markDef.filled?{fill:i}:{stroke:i}:{[g]:i}}function dIi(e,g,i,n){switch(g){case"disable":return i!==void 0;case"values":return!!i?.values;case"title":if(g==="title"&&e===n?.title)return!0}return e===(i||{})[g]}function hIi(e,g){let i=e.legend(g);const{markDef:n,encoding:I,config:r}=e,o=r.legend,C=new eIi({},uIi(e,g));Bni(e,g,C);const a=i!==void 0?!i:o.disable;if(C.set("disable",a,i!==void 0),a)return C;i=i||{};const A=e.getScaleComponent(g).get("type"),s=ZI(I[g]),l=dt(s)?Zr(s.timeUnit)?.unit:void 0,c=i.orient||r.legend.orient||"right",u=oIi({legend:i,channel:g,timeUnit:l,scaleType:A}),d=aIi({legend:i,legendType:u,orient:c,legendConfig:o}),h={legend:i,channel:g,model:e,markDef:n,encoding:I,fieldOrDatumDef:s,legendConfig:o,config:r,scaleType:A,orient:c,legendType:u,direction:d};for(const y of mat){if(u==="gradient"&&y.startsWith("symbol")||u==="symbol"&&y.startsWith("gradient"))continue;const Z=y in mYe?mYe[y](h):i[y];if(Z!==void 0){const v=dIi(Z,y,i,e.fieldDef(g));(v||r.legend[y]===void 0)&&C.set(y,Z,v)}}const f=i?.encoding??{},m=C.get("selections"),b={},p={fieldOrDatumDef:s,model:e,channel:g,legendCmpt:C,legendType:u};for(const y of["labels","legend","title","symbols","gradient","entries"]){const Z=hat(f[y]??{},e),v=y in fYe?fYe[y](Z,p):Z;v!==void 0&&!Ri(v)&&(b[y]={...m?.length&&dt(s)?{name:`${dn(s.field)}_legend_${y}`}:{},...m?.length?{interactive:!!m}:{},update:v})}return Ri(b)||C.set("encode",b,!!i?.encoding),C}function fIi(e){const{legends:g,resolve:i}=e.component;for(const n of e.children){Zat(n);for(const I of At(n.component.legends))i.legend[I]=nme(e.component.resolve,I),i.legend[I]==="shared"&&(g[I]=Gat(g[I],n.component.legends[I]),g[I]||(i.legend[I]="independent",delete g[I]))}for(const n of At(g))for(const I of e.children)I.component.legends[n]&&i.legend[n]==="shared"&&delete I.component.legends[n];return g}function Gat(e,g){if(!e)return g.clone();const i=e.getWithExplicit("orient"),n=g.getWithExplicit("orient");if(i.explicit&&n.explicit&&i.value!==n.value)return;let I=!1;for(const r of mat){const o=Vm(e.getWithExplicit(r),g.getWithExplicit(r),r,"legend",(C,a)=>{switch(r){case"symbolType":return mIi(C,a);case"title":return aot(C,a);case"type":return I=!0,QC("symbol")}return vJ(C,a,r,"legend")});e.setWithExplicit(r,o)}return I&&(e.implicit?.encode?.gradient&&u3(e.implicit,["encode","gradient"]),e.explicit?.encode?.gradient&&u3(e.explicit,["encode","gradient"])),e}function mIi(e,g){return g.value==="circle"?g:e}function pIi(e,g,i,n){var I,r;e.encode??(e.encode={}),(I=e.encode)[g]??(I[g]={}),(r=e.encode[g]).update??(r.update={}),e.encode[g].update[i]=n}function vat(e){const g=e.component.legends,i={};for(const I of At(g)){const r=e.getScaleComponent(I),o=Oi(r.get("domains"));if(i[o])for(const C of i[o])Gat(C,g[I])||i[o].push(g[I]);else i[o]=[g[I].clone()]}return fr(i).flat().map(I=>bIi(I,e.config)).filter(I=>I!==void 0)}function bIi(e,g){const{disable:i,labelExpr:n,selections:I,...r}=e.combine();if(!i){if(g.aria===!1&&r.aria==null&&(r.aria=!1),r.encode?.symbols){const o=r.encode.symbols.update;o.fill&&o.fill.value!=="transparent"&&!o.stroke&&!r.stroke&&(o.stroke={value:"transparent"});for(const C of bCt)r[C]&&delete o[C]}if(r.title||delete r.title,n!==void 0){let o=n;r.encode?.labels?.update&&Qt(r.encode.labels.update.text)&&(o=Zy(n,"datum.label",r.encode.labels.update.text.signal)),pIi(r,"labels","text",{signal:o})}return r}}function yIi(e){return HS(e)||sme(e)?ZIi(e):Bat(e)}function ZIi(e){return e.children.reduce((g,i)=>g.concat(i.assembleProjections()),Bat(e))}function Bat(e){const g=e.component.projection;if(!g||g.merged)return[];const i=g.combine(),{name:n}=i;if(g.data){const I={signal:`[${g.size.map(o=>o.signal).join(", ")}]`},r=g.data.reduce((o,C)=>{const a=Qt(C)?C.signal:`data('${e.lookupDataSource(C)}')`;return Eg(o,a)||o.push(a),o},[]);if(r.length<=0)throw new Error("Projection's fit didn't find any data sources");return[{name:n,size:I,fit:{signal:r.length>1?`[${r.join(", ")}]`:r[0]},...i}]}else return[{name:n,translate:{signal:"[width / 2, height / 2]"},...i}]}const GIi=["type","clipAngle","clipExtent","center","rotate","precision","reflectX","reflectY","coefficient","distance","fraction","lobes","parallel","radius","ratio","spacing","tilt"];class wat extends hh{constructor(g,i,n,I){super({...i},{name:g}),this.specifiedProjection=i,this.size=n,this.data=I,this.merged=!1}get isFit(){return!!this.data}}function Sat(e){e.component.projection=$n(e)?vIi(e):SIi(e)}function vIi(e){if(e.hasProjection){const g=hC(e.specifiedProjection),i=!(g&&(g.scale!=null||g.translate!=null)),n=i?[e.getSizeSignalRef("width"),e.getSizeSignalRef("height")]:void 0,I=i?BIi(e):void 0,r=new wat(e.projectionName(!0),{...hC(e.config.projection)??{},...g??{}},n,I);return r.get("type")||r.set("type","equalEarth",!1),r}}function BIi(e){const g=[],{encoding:i}=e;for(const n of[[cl,ll],[Zs,ul]])(ZI(i[n[0]])||ZI(i[n[1]]))&&g.push({signal:e.getName(`geojson_${g.length}`)});return e.channelHasField(xC)&&e.typedFieldDef(xC).type===RS&&g.push({signal:e.getName(`geojson_${g.length}`)}),g.length===0&&g.push(e.requestDataName(zi.Main)),g}function wIi(e,g){const i=Qhe(GIi,I=>!!(!gg(e.explicit,I)&&!gg(g.explicit,I)||gg(e.explicit,I)&&gg(g.explicit,I)&&nc(e.get(I),g.get(I))));if(nc(e.size,g.size)){if(i)return e;if(nc(e.explicit,{}))return g;if(nc(g.explicit,{}))return e}return null}function SIi(e){if(e.children.length===0)return;let g;for(const n of e.children)Sat(n);const i=Qhe(e.children,n=>{const I=n.component.projection;if(I)if(g){const r=wIi(g,I);return r&&(g=r),!!r}else return g=I,!0;else return!0});if(g&&i){const n=e.projectionName(!0),I=new wat(n,g.specifiedProjection,g.size,mg(g.data));for(const r of e.children){const o=r.component.projection;o&&(o.isFit&&I.data.push(...r.component.projection.data),r.renameProjection(o.get("name"),n),o.merged=!0)}return I}}function RIi(e,g,i,n){if(lN(g,i)){const I=$n(e)?e.axis(i)??e.legend(i)??{}:{},r=Bt(g,{expr:"datum"}),o=Bt(g,{expr:"datum",binSuffix:"end"});return{formulaAs:Bt(g,{binSuffix:"range",forAs:!0}),formula:aN(r,o,I.format,I.formatType,n)}}return{}}function Rat(e,g){return`${tot(e)}_${g}`}function VIi(e,g){return{signal:e.getName(`${g}_bins`),extentSignal:e.getName(`${g}_extent`)}}function Ime(e,g,i){const n=mJ(i,void 0)??{},I=Rat(n,g);return e.getName(`${I}_bins`)}function WIi(e){return"as"in e}function bYe(e,g,i){let n,I;WIi(e)?n=Rt(e.as)?[e.as,`${e.as}_end`]:[e.as[0],e.as[1]]:n=[Bt(e,{forAs:!0}),Bt(e,{binSuffix:"end",forAs:!0})];const r={...mJ(g,void 0)},o=Rat(r,e.field),{signal:C,extentSignal:a}=VIi(i,o);if(oJ(r.extent)){const s=r.extent;I=rat(i,s.param,s),delete r.extent}const A={bin:r,field:e.field,as:[n],...C?{signal:C}:{},...a?{extentSignal:a}:{},...I?{span:I}:{}};return{key:o,binComponent:A}}class Gc extends Xi{clone(){return new Gc(null,mg(this.bins))}constructor(g,i){super(g),this.bins=i}static makeFromEncoding(g,i){const n=i.reduceFieldDef((I,r,o)=>{if(Po(r)&&Ji(r.bin)){const{key:C,binComponent:a}=bYe(r,r.bin,i);I[C]={...a,...I[C],...RIi(i,r,o,i.config)}}return I},{});return Ri(n)?null:new Gc(g,n)}static makeFromTransform(g,i,n){const{key:I,binComponent:r}=bYe(i,i.bin,n);return new Gc(g,{[I]:r})}merge(g,i){for(const n of At(g.bins))n in this.bins?(i(g.bins[n].signal,this.bins[n].signal),this.bins[n].as=Ic([...this.bins[n].as,...g.bins[n].as],$g)):this.bins[n]=g.bins[n];for(const n of g.children)g.removeChild(n),n.parent=this;g.remove()}producedFields(){return new Set(fr(this.bins).map(g=>g.as).flat(2))}dependentFields(){return new Set(fr(this.bins).map(g=>g.field))}hash(){return`Bin ${$g(this.bins)}`}assemble(){return fr(this.bins).flatMap(g=>{const i=[],[n,...I]=g.as,{extent:r,...o}=g.bin,C={type:"bin",field:ys(g.field),as:n,signal:g.signal,...oJ(r)?{extent:null}:{extent:r},...g.span?{span:{signal:`span(${g.span})`}}:{},...o};!r&&g.extentSignal&&(i.push({type:"extent",field:ys(g.field),signal:g.extentSignal}),C.extent={signal:g.extentSignal}),i.push(C);for(const a of I)for(let A=0;A<2;A++)i.push({type:"formula",expr:Bt({field:n[A]},{expr:"datum"}),as:a[A]});return g.formula&&i.push({type:"formula",expr:g.formula,as:g.formulaAs}),i})}}function XIi(e,g,i,n){const I=$n(n)?n.encoding[Cu(g)]:void 0;if(Po(i)&&$n(n)&&Jot(i,I,n.markDef,n.config))e.add(Bt(i,{})),e.add(Bt(i,{suffix:"end"})),i.bin&&lN(i,g)&&e.add(Bt(i,{binSuffix:"range"}));else if(Prt(g)){const r=zrt(g);e.add(n.getName(r))}else e.add(Bt(i));return SZ(i)&&Sti(i.scale?.range)&&e.add(i.scale.range.field),e}function TIi(e,g){for(const i of At(g)){const n=g[i];for(const I of At(n))i in e?e[i][I]=new Set([...e[i][I]??[],...n[I]]):e[i]={[I]:n[I]}}}class EA extends Xi{clone(){return new EA(null,new Set(this.dimensions),mg(this.measures))}constructor(g,i,n){super(g),this.dimensions=i,this.measures=n}get groupBy(){return this.dimensions}static makeFromEncoding(g,i){let n=!1;i.forEachFieldDef(o=>{o.aggregate&&(n=!0)});const I={},r=new Set;return!n||(i.forEachFieldDef((o,C)=>{const{aggregate:a,field:A}=o;if(a)if(a==="count")I["*"]??(I["*"]={}),I["*"].count=new Set([Bt(o,{forAs:!0})]);else{if(Pd(a)||up(a)){const s=Pd(a)?"argmin":"argmax",l=a[s];I[l]??(I[l]={}),I[l][s]=new Set([Bt({op:s,field:l},{forAs:!0})])}else I[A]??(I[A]={}),I[A][a]=new Set([Bt(o,{forAs:!0})]);uh(C)&&i.scaleDomain(C)==="unaggregated"&&(I[A]??(I[A]={}),I[A].min=new Set([Bt({field:A,aggregate:"min"},{forAs:!0})]),I[A].max=new Set([Bt({field:A,aggregate:"max"},{forAs:!0})]))}else XIi(r,C,o,i)}),r.size+At(I).length===0)?null:new EA(g,r,I)}static makeFromTransform(g,i){const n=new Set,I={};for(const r of i.aggregate){const{op:o,field:C,as:a}=r;o&&(o==="count"?(I["*"]??(I["*"]={}),I["*"].count=new Set([a||Bt(r,{forAs:!0})])):(I[C]??(I[C]={}),I[C][o]=new Set([a||Bt(r,{forAs:!0})])))}for(const r of i.groupby??[])n.add(r);return n.size+At(I).length===0?null:new EA(g,n,I)}merge(g){return krt(this.dimensions,g.dimensions)?(TIi(this.measures,g.measures),!0):(qei("different dimensions, cannot merge"),!1)}addDimensions(g){g.forEach(this.dimensions.add,this.dimensions)}dependentFields(){return new Set([...this.dimensions,...At(this.measures)])}producedFields(){const g=new Set;for(const i of At(this.measures))for(const n of At(this.measures[i])){const I=this.measures[i][n];I.size===0?g.add(`${n}_${i}`):I.forEach(g.add,g)}return g}hash(){return`Aggregate ${$g({dimensions:this.dimensions,measures:this.measures})}`}assemble(){const g=[],i=[],n=[];for(const r of At(this.measures))for(const o of At(this.measures[r]))for(const C of this.measures[r][o])n.push(C),g.push(o),i.push(r==="*"?null:ys(r));return{type:"aggregate",groupby:[...this.dimensions].map(ys),ops:g,fields:i,as:n}}}class XS extends Xi{constructor(g,i,n,I){super(g),this.model=i,this.name=n,this.data=I;for(const r of ns){const o=i.facet[r];if(o){const{bin:C,sort:a}=o;this[r]={name:i.getName(`${r}_domain`),fields:[Bt(o),...Ji(C)?[Bt(o,{binSuffix:"end"})]:[]],...yc(a)?{sortField:a}:et(a)?{sortIndexField:c1(o,r)}:{}}}}this.childModel=i.child}hash(){let g="Facet";for(const i of ns)this[i]&&(g+=` ${i.charAt(0)}:${$g(this[i])}`);return g}get fields(){const g=[];for(const i of ns)this[i]?.fields&&g.push(...this[i].fields);return g}dependentFields(){const g=new Set(this.fields);for(const i of ns)this[i]&&(this[i].sortField&&g.add(this[i].sortField.field),this[i].sortIndexField&&g.add(this[i].sortIndexField));return g}producedFields(){return new Set}getSource(){return this.name}getChildIndependentFieldsWithStep(){const g={};for(const i of au){const n=this.childModel.component.scales[i];if(n&&!n.merged){const I=n.get("type"),r=n.get("range");if(UI(I)&&dp(r)){const o=VJ(this.childModel,i),C=ame(o);C?g[i]=C:ut(sfe(i))}}}return g}assembleRowColumnHeaderData(g,i,n){const I={row:"y",column:"x",facet:void 0}[g],r=[],o=[],C=[];I&&n&&n[I]&&(i?(r.push(`distinct_${n[I]}`),o.push("max")):(r.push(n[I]),o.push("distinct")),C.push(`distinct_${n[I]}`));const{sortField:a,sortIndexField:A}=this[g];if(a){const{op:s=uJ,field:l}=a;r.push(l),o.push(s),C.push(Bt(a,{forAs:!0}))}else A&&(r.push(A),o.push("max"),C.push(A));return{name:this[g].name,source:i??this.data,transform:[{type:"aggregate",groupby:this[g].fields,...r.length?{fields:r,ops:o,as:C}:{}}]}}assembleFacetHeaderData(g){const{columns:i}=this.model.layout,{layoutHeaders:n}=this.model.component,I=[],r={};for(const a of tme){for(const A of gme){const s=(n[a]&&n[a][A])??[];for(const l of s)if(l.axes?.length>0){r[a]=!0;break}}if(r[a]){const A=`length(data("${this.facet.name}"))`,s=a==="row"?i?{signal:`ceil(${A} / ${i})`}:1:i?{signal:`min(${A}, ${i})`}:{signal:A};I.push({name:`${this.facet.name}_${a}`,transform:[{type:"sequence",start:0,stop:s}]})}}const{row:o,column:C}=r;return(o||C)&&I.unshift(this.assembleRowColumnHeaderData("facet",null,g)),I}assemble(){const g=[];let i=null;const n=this.getChildIndependentFieldsWithStep(),{column:I,row:r,facet:o}=this;if(I&&r&&(n.x||n.y)){i=`cross_${this.column.name}_${this.row.name}`;const C=[].concat(n.x??[],n.y??[]),a=C.map(()=>"distinct");g.push({name:i,source:this.data,transform:[{type:"aggregate",groupby:this.fields,fields:C,ops:a}]})}for(const C of[Zd,yd])this[C]&&g.push(this.assembleRowColumnHeaderData(C,i,n));if(o){const C=this.assembleFacetHeaderData(n);C&&g.push(...C)}return g}}function yYe(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}function HIi(e,g){const i=qhe(e);if(g==="number")return`toNumber(${i})`;if(g==="boolean")return`toBoolean(${i})`;if(g==="string")return`toString(${i})`;if(g==="date")return`toDate(${i})`;if(g==="flatten")return i;if(g.startsWith("date:")){const n=yYe(g.slice(5,g.length));return`timeParse(${i},'${n}')`}else if(g.startsWith("utc:")){const n=yYe(g.slice(4,g.length));return`utcParse(${i},'${n}')`}else return ut(rei(g)),null}function NIi(e){const g={};return Cx(e.filter,i=>{if(Got(i)){let n=null;ufe(i)?n=Ca(i.equal):hfe(i)?n=Ca(i.lte):dfe(i)?n=Ca(i.lt):ffe(i)?n=Ca(i.gt):mfe(i)?n=Ca(i.gte):pfe(i)?n=i.range[0]:bfe(i)&&(n=(i.oneOf??i.in)[0]),n&&(wZ(n)?g[i.field]="date":Vi(n)?g[i.field]="number":Rt(n)&&(g[i.field]="string")),i.timeUnit&&(g[i.field]="date")}}),g}function kIi(e){const g={};function i(n){s1(n)?g[n.field]="date":n.type==="quantitative"&&xqg(n.aggregate)?g[n.field]="number":n1(n.field)>1?n.field in g||(g[n.field]="flatten"):SZ(n)&&yc(n.sort)&&n1(n.sort.field)>1&&(n.sort.field in g||(g[n.sort.field]="flatten"))}if(($n(e)||DA(e))&&e.forEachFieldDef((n,I)=>{if(Po(n))i(n);else{const r=vZ(I),o=e.fieldDef(r);i({...n,type:o.type})}}),$n(e)){const{mark:n,markDef:I,encoding:r}=e;if(hp(n)&&!e.encoding.order){const o=I.orient==="horizontal"?"y":"x",C=r[o];dt(C)&&C.type==="quantitative"&&!(C.field in g)&&(g[C.field]="number")}}return g}function YIi(e){const g={};if($n(e)&&e.component.selection)for(const i of At(e.component.selection)){const n=e.component.selection[i];for(const I of n.project.items)!I.channel&&n1(I.field)>1&&(g[I.field]="flatten")}return g}class Lr extends Xi{clone(){return new Lr(null,mg(this._parse))}constructor(g,i){super(g),this._parse=i}hash(){return`Parse ${$g(this._parse)}`}static makeExplicit(g,i,n){let I={};const r=i.data;return!am(r)&&r?.format?.parse&&(I=r.format.parse),this.makeWithAncestors(g,I,{},n)}static makeWithAncestors(g,i,n,I){for(const C of At(n)){const a=I.getWithExplicit(C);a.value!==void 0&&(a.explicit||a.value===n[C]||a.value==="derived"||n[C]==="flatten"?delete n[C]:ut(kke(C,n[C],a.value)))}for(const C of At(i)){const a=I.get(C);a!==void 0&&(a===i[C]?delete i[C]:ut(kke(C,i[C],a)))}const r=new hh(i,n);I.copyAll(r);const o={};for(const C of At(r.combine())){const a=r.get(C);a!==null&&(o[C]=a)}return At(o).length===0||I.parseNothing?null:new Lr(g,o)}get parse(){return this._parse}merge(g){this._parse={...this._parse,...g.parse},g.remove()}assembleFormatParse(){const g={};for(const i of At(this._parse)){const n=this._parse[i];n1(i)===1&&(g[i]=n)}return g}producedFields(){return new Set(At(this._parse))}dependentFields(){return new Set(At(this._parse))}assembleTransforms(g=!1){return At(this._parse).filter(i=>g?n1(i)>1:!0).map(i=>{const n=HIi(i,this._parse[i]);return n?{type:"formula",expr:n,as:efe(i)}:null}).filter(i=>i!==null)}}class Tm extends Xi{clone(){return new Tm(null)}constructor(g){super(g)}dependentFields(){return new Set}producedFields(){return new Set([jA])}hash(){return"Identifier"}assemble(){return{type:"identifier",as:jA}}}class dN extends Xi{clone(){return new dN(null,this.params)}constructor(g,i){super(g),this.params=i}dependentFields(){return new Set}producedFields(){}hash(){return`Graticule ${$g(this.params)}`}assemble(){return{type:"graticule",...this.params===!0?{}:this.params}}}class hN extends Xi{clone(){return new hN(null,this.params)}constructor(g,i){super(g),this.params=i}dependentFields(){return new Set}producedFields(){return new Set([this.params.as??"data"])}hash(){return`Hash ${$g(this.params)}`}assemble(){return{type:"sequence",...this.params}}}class Xy extends Xi{constructor(g){super(null),g??(g={name:"source"});let i;if(am(g)||(i=g.format?{...WC(g.format,["parse"])}:{}),$9(g))this._data={values:g.values};else if(A1(g)){if(this._data={url:g.url},!i.type){let n=/(?:\.([^.]+))?$/.exec(g.url)[1];Eg(["json","csv","tsv","dsv","topojson"],n)||(n="json"),i.type=n}}else KCt(g)?this._data={values:[{type:"Sphere"}]}:(kCt(g)||am(g))&&(this._data={});this._generator=am(g),g.name&&(this._name=g.name),i&&!Ri(i)&&(this._data.format=i)}dependentFields(){return new Set}producedFields(){}get data(){return this._data}hasName(){return!!this._name}get isGenerator(){return this._generator}get dataName(){return this._name}set dataName(g){this._name=g}set parent(g){throw new Error("Source nodes have to be roots.")}remove(){throw new Error("Source nodes are roots and cannot be removed.")}hash(){throw new Error("Cannot hash sources")}assemble(){return{name:this._name,...this._data,transform:[]}}}var ZYe=globalThis&&globalThis.__classPrivateFieldSet||function(e,g,i,n,I){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!I)throw new TypeError("Private accessor was defined without a setter");if(typeof g=="function"?e!==g||!I:!g.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?I.call(e,i):I?I.value=i:g.set(e,i),i},KIi=globalThis&&globalThis.__classPrivateFieldGet||function(e,g,i,n){if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof g=="function"?e!==g||!n:!g.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?n:i==="a"?n.call(e):n?n.value:g.get(e)},G2;function rme(e){return e instanceof Xy||e instanceof dN||e instanceof hN}class ome{constructor(){G2.set(this,void 0),ZYe(this,G2,!1,"f")}setModified(){ZYe(this,G2,!0,"f")}get modifiedFlag(){return KIi(this,G2,"f")}}G2=new WeakMap;class RZ extends ome{getNodeDepths(g,i,n){n.set(g,i);for(const I of g.children)this.getNodeDepths(I,i+1,n);return n}optimize(g){const n=[...this.getNodeDepths(g,0,new Map).entries()].sort((I,r)=>r[1]-I[1]);for(const I of n)this.run(I[0]);return this.modifiedFlag}}class Cme extends ome{optimize(g){this.run(g);for(const i of g.children)this.optimize(i);return this.modifiedFlag}}class xIi extends Cme{mergeNodes(g,i){const n=i.shift();for(const I of i)g.removeChild(I),I.parent=n,I.remove()}run(g){const i=g.children.map(I=>I.hash()),n={};for(let I=0;I1&&(this.setModified(),this.mergeNodes(g,n[I]))}}class FIi extends Cme{constructor(g){super(),this.requiresSelectionId=g&&eme(g)}run(g){g instanceof Tm&&(this.requiresSelectionId&&(rme(g.parent)||g.parent instanceof EA||g.parent instanceof Lr)||(this.setModified(),g.remove()))}}class EIi extends ome{optimize(g){return this.run(g,new Set),this.modifiedFlag}run(g,i){let n=new Set;g instanceof Zc&&(n=g.producedFields(),jhe(n,i)&&(this.setModified(),g.removeFormulas(i),g.producedFields.length===0&&g.remove()));for(const I of g.children)this.run(I,new Set([...i,...n]))}}class DIi extends Cme{constructor(){super()}run(g){g instanceof Ko&&!g.isRequired()&&(this.setModified(),g.remove())}}class MIi extends RZ{run(g){if(!rme(g)&&!(g.numChildren()>1)){for(const i of g.children)if(i instanceof Lr)if(g instanceof Lr)this.setModified(),g.merge(i);else{if($he(g.producedFields(),i.dependentFields()))continue;this.setModified(),i.swapWithParent()}}}}class zIi extends RZ{run(g){const i=[...g.children],n=g.children.filter(I=>I instanceof Lr);if(g.numChildren()>1&&n.length>=1){const I={},r=new Set;for(const o of n){const C=o.parse;for(const a of At(C))a in I?I[a]!==C[a]&&r.add(a):I[a]=C[a]}for(const o of r)delete I[o];if(!Ri(I)){this.setModified();const o=new Lr(g,I);for(const C of i){if(C instanceof Lr)for(const a of At(I))delete C.parse[a];g.removeChild(C),C.parent=o,C instanceof Lr&&At(C.parse).length===0&&C.remove()}}}}}class PIi extends RZ{run(g){g instanceof Ko||g.numChildren()>0||g instanceof XS||g instanceof Xy||(this.setModified(),g.remove())}}class _Ii extends RZ{run(g){const i=g.children.filter(I=>I instanceof Zc),n=i.pop();for(const I of i)this.setModified(),n.merge(I)}}class OIi extends RZ{run(g){const i=g.children.filter(I=>I instanceof EA),n={};for(const I of i){const r=$g(I.groupBy);r in n||(n[r]=[]),n[r].push(I)}for(const I of At(n)){const r=n[I];if(r.length>1){const o=r.pop();for(const C of r)o.merge(C)&&(g.removeChild(C),C.parent=o,C.remove(),this.setModified())}}}}class JIi extends RZ{constructor(g){super(),this.model=g}run(g){const i=!(rme(g)||g instanceof WS||g instanceof Lr||g instanceof Tm),n=[],I=[];for(const r of g.children)r instanceof Gc&&(i&&!$he(g.producedFields(),r.dependentFields())?n.push(r):I.push(r));if(n.length>0){const r=n.pop();for(const o of n)r.merge(o,this.model.renameSignal.bind(this.model));this.setModified(),g instanceof Gc?g.merge(r,this.model.renameSignal.bind(this.model)):r.swapWithParent()}if(I.length>1){const r=I.pop();for(const o of I)r.merge(o,this.model.renameSignal.bind(this.model));this.setModified()}}}class LIi extends RZ{run(g){const i=[...g.children];if(!yy(i,o=>o instanceof Ko)||g.numChildren()<=1)return;const I=[];let r;for(const o of i)if(o instanceof Ko){let C=o;for(;C.numChildren()===1;){const[a]=C.children;if(a instanceof Ko)C=a;else break}I.push(...C.children),r?(g.removeChild(o),o.parent=r.parent,r.parent.removeChild(r),r.parent=C,this.setModified()):r=C}else I.push(o);if(I.length){this.setModified();for(const o of I)o.parent.removeChild(o),o.parent=r}}}class VZ extends Xi{clone(){return new VZ(null,mg(this.transform))}constructor(g,i){super(g),this.transform=i}addDimensions(g){this.transform.groupby=Ic(this.transform.groupby.concat(g),i=>i)}dependentFields(){const g=new Set;return this.transform.groupby&&this.transform.groupby.forEach(g.add,g),this.transform.joinaggregate.map(i=>i.field).filter(i=>i!==void 0).forEach(g.add,g),g}producedFields(){return new Set(this.transform.joinaggregate.map(this.getDefaultName))}getDefaultName(g){return g.as??Bt(g)}hash(){return`JoinAggregateTransform ${$g(this.transform)}`}assemble(){const g=[],i=[],n=[];for(const r of this.transform.joinaggregate)i.push(r.op),n.push(this.getDefaultName(r)),g.push(r.field===void 0?null:r.field);const I=this.transform.groupby;return{type:"joinaggregate",as:n,ops:i,fields:g,...I!==void 0?{groupby:I}:{}}}}function UIi(e){return e.stack.stackBy.reduce((g,i)=>{const n=i.fieldDef,I=Bt(n);return I&&g.push(I),g},[])}function QIi(e){return et(e)&&e.every(g=>Rt(g))&&e.length>1}class Bd extends Xi{clone(){return new Bd(null,mg(this._stack))}constructor(g,i){super(g),this._stack=i}static makeFromTransform(g,i){const{stack:n,groupby:I,as:r,offset:o="zero"}=i,C=[],a=[];if(i.sort!==void 0)for(const l of i.sort)C.push(l.field),a.push(CI(l.order,"ascending"));const A={field:C,order:a};let s;return QIi(r)?s=r:Rt(r)?s=[r,`${r}_end`]:s=[`${i.stack}_start`,`${i.stack}_end`],new Bd(g,{dimensionFieldDefs:[],stackField:n,groupby:I,offset:o,sort:A,facetby:[],as:s})}static makeFromEncoding(g,i){const n=i.stack,{encoding:I}=i;if(!n)return null;const{groupbyChannels:r,fieldChannel:o,offset:C,impute:a}=n,A=r.map(u=>{const d=I[u];return Mc(d)}).filter(u=>!!u),s=UIi(i),l=i.encoding.order;let c;return et(l)||dt(l)?c=rot(l):c=s.reduce((u,d)=>(u.field.push(d),u.order.push(o==="y"?"descending":"ascending"),u),{field:[],order:[]}),new Bd(g,{dimensionFieldDefs:A,stackField:i.vgField(o),facetby:[],stackby:s,sort:c,offset:C,impute:a,as:[i.vgField(o,{suffix:"start",forAs:!0}),i.vgField(o,{suffix:"end",forAs:!0})]})}get stack(){return this._stack}addDimensions(g){this._stack.facetby.push(...g)}dependentFields(){const g=new Set;return g.add(this._stack.stackField),this.getGroupbyFields().forEach(g.add,g),this._stack.facetby.forEach(g.add,g),this._stack.sort.field.forEach(g.add,g),g}producedFields(){return new Set(this._stack.as)}hash(){return`Stack ${$g(this._stack)}`}getGroupbyFields(){const{dimensionFieldDefs:g,impute:i,groupby:n}=this._stack;return g.length>0?g.map(I=>I.bin?i?[Bt(I,{binSuffix:"mid"})]:[Bt(I,{}),Bt(I,{binSuffix:"end"})]:[Bt(I)]).flat():n??[]}assemble(){const g=[],{facetby:i,dimensionFieldDefs:n,stackField:I,stackby:r,sort:o,offset:C,impute:a,as:A}=this._stack;if(a)for(const s of n){const{bandPosition:l=.5,bin:c}=s;if(c){const u=Bt(s,{expr:"datum"}),d=Bt(s,{expr:"datum",binSuffix:"end"});g.push({type:"formula",expr:`${l}*${u}+${1-l}*${d}`,as:Bt(s,{binSuffix:"mid",forAs:!0})})}g.push({type:"impute",field:I,groupby:[...r,...i],key:Bt(s,{binSuffix:"mid"}),method:"value",value:0})}return g.push({type:"stack",groupby:[...this.getGroupbyFields(),...i],field:I,sort:o,as:A,offset:C}),g}}class TS extends Xi{clone(){return new TS(null,mg(this.transform))}constructor(g,i){super(g),this.transform=i}addDimensions(g){this.transform.groupby=Ic(this.transform.groupby.concat(g),i=>i)}dependentFields(){const g=new Set;return(this.transform.groupby??[]).forEach(g.add,g),(this.transform.sort??[]).forEach(i=>g.add(i.field)),this.transform.window.map(i=>i.field).filter(i=>i!==void 0).forEach(g.add,g),g}producedFields(){return new Set(this.transform.window.map(this.getDefaultName))}getDefaultName(g){return g.as??Bt(g)}hash(){return`WindowTransform ${$g(this.transform)}`}assemble(){const g=[],i=[],n=[],I=[];for(const l of this.transform.window)i.push(l.op),n.push(this.getDefaultName(l)),I.push(l.param===void 0?null:l.param),g.push(l.field===void 0?null:l.field);const r=this.transform.frame,o=this.transform.groupby;if(r&&r[0]===null&&r[1]===null&&i.every(l=>Cfe(l)))return{type:"joinaggregate",as:n,ops:i,fields:g,...o!==void 0?{groupby:o}:{}};const C=[],a=[];if(this.transform.sort!==void 0)for(const l of this.transform.sort)C.push(l.field),a.push(l.order??"ascending");const A={field:C,order:a},s=this.transform.ignorePeers;return{type:"window",params:I,as:n,ops:i,fields:g,sort:A,...s!==void 0?{ignorePeers:s}:{},...o!==void 0?{groupby:o}:{},...r!==void 0?{frame:r}:{}}}}function jIi(e){function g(i){if(!(i instanceof XS)){const n=i.clone();if(n instanceof Ko){const I=YIe+n.getSource();n.setSource(I),e.model.component.data.outputNodes[I]=n}else(n instanceof EA||n instanceof Bd||n instanceof TS||n instanceof VZ)&&n.addDimensions(e.fields);for(const I of i.children.flatMap(g))I.parent=n;return[n]}return i.children.flatMap(g)}return g}function kIe(e){if(e instanceof XS)if(e.numChildren()===1&&!(e.children[0]instanceof Ko)){const g=e.children[0];(g instanceof EA||g instanceof Bd||g instanceof TS||g instanceof VZ)&&g.addDimensions(e.fields),g.swapWithParent(),kIe(e)}else{const g=e.model.component.data.main;Vat(g);const i=jIi(e),n=e.children.map(i).flat();for(const I of n)I.parent=g}else e.children.map(kIe)}function Vat(e){if(e instanceof Ko&&e.type===zi.Main&&e.numChildren()===1){const g=e.children[0];g instanceof XS||(g.swapWithParent(),Vat(e))}}const YIe="scale_",sK=5;function KIe(e){for(const g of e){for(const i of g.children)if(i.parent!==g)return!1;if(!KIe(g.children))return!1}return!0}function Ls(e,g){let i=!1;for(const n of g)i=e.optimize(n)||i;return i}function GYe(e,g,i){let n=e.sources,I=!1;return I=Ls(new DIi,n)||I,I=Ls(new FIi(g),n)||I,n=n.filter(r=>r.numChildren()>0),I=Ls(new PIi,n)||I,n=n.filter(r=>r.numChildren()>0),i||(I=Ls(new MIi,n)||I,I=Ls(new JIi(g),n)||I,I=Ls(new EIi,n)||I,I=Ls(new zIi,n)||I,I=Ls(new OIi,n)||I,I=Ls(new _Ii,n)||I,I=Ls(new xIi,n)||I,I=Ls(new LIi,n)||I),e.sources=n,I}function $Ii(e,g){KIe(e.sources);let i=0,n=0;for(let I=0;Ig(i))}}function Wat(e){$n(e)?qIi(e):eri(e)}function qIi(e){const g=e.component.scales;for(const i of At(g)){const n=gri(e,i);if(g[i].setWithExplicit("domains",n),nri(e,i),e.component.data.isFaceted){let r=e;for(;!DA(r)&&r.parent;)r=r.parent;if(r.component.resolve.scale[i]==="shared")for(const C of n.value)Ad(C)&&(C.data=YIe+C.data.replace(YIe,""))}}}function eri(e){for(const i of e.children)Wat(i);const g=e.component.scales;for(const i of At(g)){let n,I=null;for(const r of e.children){const o=r.component.scales[i];if(o){n===void 0?n=o.getWithExplicit("domains"):n=Vm(n,o.getWithExplicit("domains"),"domains","scale",xIe);const C=o.get("selectionExtent");I&&C&&I.param!==C.param&&ut(gei),I=C}}g[i].setWithExplicit("domains",n),I&&g[i].set("selectionExtent",I,!0)}}function tri(e,g,i,n){if(e==="unaggregated"){const{valid:I,reason:r}=vYe(g,i);if(!I){ut(r);return}}else if(e===void 0&&n.useUnaggregatedDomain){const{valid:I}=vYe(g,i);if(I)return"unaggregated"}return e}function gri(e,g){const i=e.getScaleComponent(g).get("type"),{encoding:n}=e,I=tri(e.scaleDomain(g),e.typedFieldDef(g),i,e.config.scale);return I!==e.scaleDomain(g)&&(e.specifiedScales[g]={...e.specifiedScales[g],domain:I}),g==="x"&&ZI(n.x2)?ZI(n.x)?Vm(Jh(i,I,e,"x"),Jh(i,I,e,"x2"),"domain","scale",xIe):Jh(i,I,e,"x2"):g==="y"&&ZI(n.y2)?ZI(n.y)?Vm(Jh(i,I,e,"y"),Jh(i,I,e,"y2"),"domain","scale",xIe):Jh(i,I,e,"y2"):Jh(i,I,e,g)}function iri(e,g,i){return e.map(n=>({signal:`{data: ${pJ(n,{timeUnit:i,type:g})}}`}))}function O4(e,g,i){const n=Zr(i)?.unit;return g==="temporal"||n?iri(e,g,n):[e]}function Jh(e,g,i,n){const{encoding:I}=i,r=ZI(I[n]),{type:o}=r,C=r.timeUnit;if(wti(g)){const l=Jh(e,void 0,i,n),c=O4(g.unionWith,o,C);return Xl([...c,...l.value])}else{if(Qt(g))return Xl([g]);if(g&&g!=="unaggregated"&&!Wot(g))return Xl(O4(g,o,C))}const a=i.stack;if(a&&n===a.fieldChannel){if(a.offset==="normalize")return QC([[0,1]]);const l=i.requestDataName(zi.Main);return QC([{data:l,field:i.vgField(n,{suffix:"start"})},{data:l,field:i.vgField(n,{suffix:"end"})}])}const A=uh(n)&&dt(r)?Iri(i,n,e):void 0;if(su(r)){const l=O4([r.datum],o,C);return QC(l)}const s=r;if(g==="unaggregated"){const l=i.requestDataName(zi.Main),{field:c}=r;return QC([{data:l,field:Bt({field:c,aggregate:"min"})},{data:l,field:Bt({field:c,aggregate:"max"})}])}else if(Ji(s.bin)){if(UI(e))return QC(e==="bin-ordinal"?[]:[{data:Q9(A)?i.requestDataName(zi.Main):i.requestDataName(zi.Raw),field:i.vgField(n,lN(s,n)?{binSuffix:"range"}:{}),sort:A===!0||!Wt(A)?{field:i.vgField(n,{}),op:"min"}:A}]);{const{bin:l}=s;if(Ji(l)){const c=Ime(i,s.field,l);return QC([new TC(()=>{const u=i.getSignalName(c);return`[${u}.start, ${u}.stop]`})])}else return QC([{data:i.requestDataName(zi.Main),field:i.vgField(n,{})}])}}else if(s.timeUnit&&Eg(["time","utc"],e)&&Jot(s,$n(i)?i.encoding[Cu(n)]:void 0,i.markDef,i.config)){const l=i.requestDataName(zi.Main);return QC([{data:l,field:i.vgField(n)},{data:l,field:i.vgField(n,{suffix:"end"})}])}else return QC(A?[{data:Q9(A)?i.requestDataName(zi.Main):i.requestDataName(zi.Raw),field:i.vgField(n),sort:A}]:[{data:i.requestDataName(zi.Main),field:i.vgField(n)}])}function J4(e,g){const{op:i,field:n,order:I}=e;return{op:i??(g?"sum":uJ),...n?{field:ys(n)}:{},...I?{order:I}:{}}}function nri(e,g){const i=e.component.scales[g],n=e.specifiedScales[g].domain,I=e.fieldDef(g)?.bin,r=Wot(n)&&n,o=BZ(I)&&oJ(I.extent)&&I.extent;(r||o)&&i.set("selectionExtent",r??o,!0)}function Iri(e,g,i){if(!UI(i))return;const n=e.fieldDef(g),I=n.sort;if(Pot(I))return{op:"min",field:c1(n,g),order:"ascending"};const{stack:r}=e,o=r?new Set([...r.groupbyFields,...r.stackBy.map(C=>C.fieldDef.field)]):void 0;if(yc(I)){const C=r&&!o.has(I.field);return J4(I,C)}else if(zot(I)){const{encoding:C,order:a}=I,A=e.fieldDef(C),{aggregate:s,field:l}=A,c=r&&!o.has(l);if(Pd(s)||up(s))return J4({field:Bt(A),order:a},c);if(Cfe(s)||!s)return J4({op:s,field:l,order:a},c)}else{if(I==="descending")return{op:"min",field:e.vgField(g),order:"descending"};if(Eg(["ascending",void 0],I))return!0}}function vYe(e,g){const{aggregate:i,type:n}=e;return i?Rt(i)&&!Eqg.has(i)?{valid:!1,reason:Wei(i)}:n==="quantitative"&&g==="log"?{valid:!1,reason:Xei(e)}:{valid:!0}:{valid:!1,reason:Vei(e)}}function xIe(e,g,i,n){return e.explicit&&g.explicit&&ut(Yei(i,n,e.value,g.value)),{explicit:e.explicit,value:[...e.value,...g.value]}}function rri(e){const g=Ic(e.map(o=>{if(Ad(o)){const{sort:C,...a}=o;return a}return o}),$g),i=Ic(e.map(o=>{if(Ad(o)){const C=o.sort;return C!==void 0&&!Q9(C)&&("op"in C&&C.op==="count"&&delete C.field,C.order==="ascending"&&delete C.order),C}}).filter(o=>o!==void 0),$g);if(g.length===0)return;if(g.length===1){const o=e[0];if(Ad(o)&&i.length>0){let C=i[0];if(i.length>1){ut(Kke);const a=i.filter(A=>Wt(A)&&"op"in A&&A.op!=="min");i.every(A=>Wt(A)&&"op"in A)&&a.length===1?C=a[0]:C=!0}else if(Wt(C)&&"field"in C){const a=C.field;o.field===a&&(C=C.order?{order:C.order}:!0)}return{...o,sort:C}}return o}const n=Ic(i.map(o=>Q9(o)||!("op"in o)||Rt(o.op)&&o.op in Yqg?o:(ut(xei(o)),!0)),$g);let I;n.length===1?I=n[0]:n.length>1&&(ut(Kke),I=!0);const r=Ic(e.map(o=>Ad(o)?o.data:null),o=>o);return r.length===1&&r[0]!==null?{data:r[0],fields:g.map(C=>C.field),...I?{sort:I}:{}}:{fields:g,...I?{sort:I}:{}}}function ame(e){if(Ad(e)&&Rt(e.field))return e.field;if(Dqg(e)){let g;for(const i of e.fields)if(Ad(i)&&Rt(i.field)){if(!g)g=i.field;else if(g!==i.field)return ut(Fei),g}return ut(Eei),g}else if(Mqg(e)){ut(Dei);const g=e.fields[0];return Rt(g)?g:void 0}}function VJ(e,g){const n=e.component.scales[g].get("domains").map(I=>(Ad(I)&&(I.data=e.lookupDataSource(I.data)),I));return rri(n)}function Xat(e){return HS(e)||sme(e)?e.children.reduce((g,i)=>g.concat(Xat(i)),BYe(e)):BYe(e)}function BYe(e){return At(e.component.scales).reduce((g,i)=>{const n=e.component.scales[i];if(n.merged)return g;const I=n.combine(),{name:r,type:o,selectionExtent:C,domains:a,range:A,reverse:s,...l}=I,c=ori(I.range,r,i,e),u=VJ(e,i),d=C?tni(e,C,n,u):null;return g.push({name:r,type:o,...u?{domain:u}:{},...d?{domainRaw:d}:{},range:c,...s!==void 0?{reverse:s}:{},...l}),g},[])}function ori(e,g,i,n){if(LI(i)){if(dp(e))return{step:{signal:`${g}_step`}}}else if(Wt(e)&&Ad(e))return{...e,data:n.lookupDataSource(e.data)};return e}class Tat extends hh{constructor(g,i){super({},{name:g}),this.merged=!1,this.setWithExplicit("type",i)}domainDefinitelyIncludesZero(){return this.get("zero")!==!1?!0:yy(this.get("domains"),g=>et(g)&&g.length===2&&g[0]<=0&&g[1]>=0)}}const Cri=["range","scheme"];function ari(e){const g=e.component.scales;for(const i of rJ){const n=g[i];if(!n)continue;const I=sri(i,e);n.setWithExplicit("range",I)}}function wYe(e,g){const i=e.fieldDef(g);if(i?.bin){const{bin:n,field:I}=i,r=FC(g),o=e.getName(r);if(Wt(n)&&n.binned&&n.step!==void 0)return new TC(()=>{const C=e.scaleName(g),a=`(domain("${C}")[1] - domain("${C}")[0]) / ${n.step}`;return`${e.getSignalName(o)} / (${a})`});if(Ji(n)){const C=Ime(e,I,n);return new TC(()=>{const a=e.getSignalName(C),A=`(${a}.stop - ${a}.start) / ${a}.step`;return`${e.getSignalName(o)} / (${A})`})}}}function sri(e,g){const i=g.specifiedScales[e],{size:n}=g,r=g.getScaleComponent(e).get("type");for(const l of Cri)if(i[l]!==void 0){const c=yIe(r,l),u=Xot(e,l);if(!c)ut(cot(r,l,e));else if(u)ut(u);else switch(l){case"range":{const d=i.range;if(et(d)){if(LI(e))return Xl(d.map(h=>{if(h==="width"||h==="height"){const f=g.getName(h),m=g.getSignalName.bind(g);return TC.fromName(m,f)}return h}))}else if(Wt(d))return Xl({data:g.requestDataName(zi.Main),field:d.field,sort:{op:"min",field:g.vgField(e)}});return Xl(d)}case"scheme":return Xl(Ari(i[l]))}}const o=e===hn||e==="xOffset"?"width":"height",C=n[o];if(zc(C)){if(LI(e))if(UI(r)){const l=Hat(C,g,e);if(l)return Xl({step:l})}else ut(uot(o));else if(SS(e)){const l=e===ap?"x":"y";if(g.getScaleComponent(l).get("type")==="band"){const d=Nat(C,r);if(d)return Xl(d)}}}const{rangeMin:a,rangeMax:A}=i,s=lri(e,g);return(a!==void 0||A!==void 0)&&yIe(r,"rangeMin")&&et(s)&&s.length===2?Xl([a??s[0],A??s[1]]):QC(s)}function Ari(e){return Bti(e)?{scheme:e.name,...WC(e,["name"])}:{scheme:e}}function lri(e,g){const{size:i,config:n,mark:I,encoding:r}=g,o=g.getSignalName.bind(g),{type:C}=ZI(r[e]),A=g.getScaleComponent(e).get("type"),{domain:s,domainMid:l}=g.specifiedScales[e];switch(e){case hn:case JI:{if(Eg(["point","band"],A)){const d=kat(e,i,n.view);if(zc(d))return{step:Hat(d,g,e)}}const c=FC(e),u=g.getName(c);return e===JI&&va(A)?[TC.fromName(o,u),0]:[0,TC.fromName(o,u)]}case ap:case wS:return cri(e,g,A);case lh:{const c=g.component.scales[e].get("zero"),u=Yat(I,c,n),d=hri(I,i,g,n);return o1(A)?dri(u,d,uri(A,n,s,e)):[u,d]}case Bs:return[0,Math.PI*2];case GZ:return[0,360];case Al:return[0,new TC(()=>{const c=g.getSignalName("width"),u=g.getSignalName("height");return`min(${c},${u})/2`})];case lp:return[n.scale.minStrokeWidth,n.scale.maxStrokeWidth];case cp:return[[1,0],[4,2],[2,1],[1,1],[1,2,4,2]];case xC:return"symbol";case KC:case ru:case ou:return A==="ordinal"?C==="nominal"?"category":"ordinal":l!==void 0?"diverging":I==="rect"||I==="geoshape"?"heatmap":"ramp";case ch:case sp:case Ap:return[n.scale.minOpacity,n.scale.maxOpacity]}}function Hat(e,g,i){const{encoding:n}=g,I=g.getScaleComponent(i),r=nfe(i),o=n[r];if(ZCt({step:e,offsetIsDiscrete:fg(o)&&Bot(o.type)})==="offset"&&nCt(n,r)){const a=g.getScaleComponent(r);let s=`domain('${g.scaleName(r)}').length`;if(a.get("type")==="band"){const c=a.get("paddingInner")??a.get("padding")??0,u=a.get("paddingOuter")??a.get("padding")??0;s=`bandspace(${s}, ${c}, ${u})`}const l=I.get("paddingInner")??I.get("padding");return{signal:`${e.step} * ${s} / (1-${Oqg(l)})`}}else return e.step}function Nat(e,g){if(ZCt({step:e,offsetIsDiscrete:UI(g)})==="offset")return{step:e.step}}function cri(e,g,i){const n=e===ap?"x":"y",r=g.getScaleComponent(n).get("type"),o=g.scaleName(n);if(r==="band"){const C=kat(n,g.size,g.config.view);if(zc(C)){const a=Nat(C,i);if(a)return a}return[0,{signal:`bandwidth('${o}')`}]}else{const C=g.encoding[n];return dt(C)&&C.timeUnit?[0,{signal:Zot(C.timeUnit,A=>`scale('${o}', ${A})`)}]:Hrt(`Cannot use ${e} scale if ${n} scale is not discrete.`)}}function kat(e,g,i){const n=e===hn?"width":"height",I=g[n];return I||B3(i,n)}function uri(e,g,i,n){switch(e){case"quantile":return g.scale.quantileCount;case"quantize":return g.scale.quantizeCount;case"threshold":return i!==void 0&&et(i)?i.length+1:(ut(Qei(n)),3)}}function dri(e,g,i){const n=()=>{const I=Gd(g),r=Gd(e),o=`(${I} - ${r}) / (${i} - 1)`;return`sequence(${r}, ${I} + ${o}, ${o})`};return Qt(g)?new TC(n):{signal:n()}}function Yat(e,g,i){if(g)return Qt(g)?{signal:`${g.signal} ? 0 : ${Yat(e,!1,i)}`}:0;switch(e){case"bar":case"tick":return i.scale.minBandSize;case"line":case"trail":case"rule":return i.scale.minStrokeWidth;case"text":return i.scale.minFontSize;case"point":case"square":case"circle":return i.scale.minSize}throw new Error(CJ("size",e))}const SYe=.95;function hri(e,g,i,n){const I={x:wYe(i,"x"),y:wYe(i,"y")};switch(e){case"bar":case"tick":{if(n.scale.maxBandSize!==void 0)return n.scale.maxBandSize;const r=RYe(g,I,n.view);return Vi(r)?r-1:new TC(()=>`${r.signal} - 1`)}case"line":case"trail":case"rule":return n.scale.maxStrokeWidth;case"text":return n.scale.maxFontSize;case"point":case"square":case"circle":{if(n.scale.maxSize)return n.scale.maxSize;const r=RYe(g,I,n.view);return Vi(r)?Math.pow(SYe*r,2):new TC(()=>`pow(${SYe} * ${r.signal}, 2)`)}}throw new Error(CJ("size",e))}function RYe(e,g,i){const n=zc(e.width)?e.width.step:v3(i,"width"),I=zc(e.height)?e.height.step:v3(i,"height");return g.x||g.y?new TC(()=>`min(${[g.x?g.x.signal:n,g.y?g.y.signal:I].join(", ")})`):Math.min(n,I)}function Kat(e,g){$n(e)?fri(e,g):Fat(e,g)}function fri(e,g){const i=e.component.scales,{config:n,encoding:I,markDef:r,specifiedScales:o}=e;for(const C of At(i)){const a=o[C],A=i[C],s=e.getScaleComponent(C),l=ZI(I[C]),c=a[g],u=s.get("type"),d=s.get("padding"),h=s.get("paddingInner"),f=yIe(u,g),m=Xot(C,g);if(c!==void 0&&(f?m&&ut(m):ut(cot(u,g,C))),f&&m===void 0)if(c!==void 0){const b=l.timeUnit,p=l.type;switch(g){case"domainMax":case"domainMin":wZ(a[g])||p==="temporal"||b?A.set(g,{signal:pJ(a[g],{type:p,timeUnit:b})},!0):A.set(g,a[g],!0);break;default:A.copyKeyFromObject(g,a)}}else{const b=g in VYe?VYe[g]({model:e,channel:C,fieldOrDatumDef:l,scaleType:u,scalePadding:d,scalePaddingInner:h,domain:a.domain,domainMin:a.domainMin,domainMax:a.domainMax,markDef:r,config:n,hasNestedOffsetScale:GIe(I,C),hasSecondaryRangeChannel:!!I[Cu(C)]}):n.scale[g];b!==void 0&&A.set(g,b,!1)}}}const VYe={bins:({model:e,fieldOrDatumDef:g})=>dt(g)?mri(e,g):void 0,interpolate:({channel:e,fieldOrDatumDef:g})=>pri(e,g.type),nice:({scaleType:e,channel:g,domain:i,domainMin:n,domainMax:I,fieldOrDatumDef:r})=>bri(e,g,i,n,I,r),padding:({channel:e,scaleType:g,fieldOrDatumDef:i,markDef:n,config:I})=>yri(e,g,I.scale,i,n,I.bar),paddingInner:({scalePadding:e,channel:g,markDef:i,scaleType:n,config:I,hasNestedOffsetScale:r})=>Zri(e,g,i.type,n,I.scale,r),paddingOuter:({scalePadding:e,channel:g,scaleType:i,scalePaddingInner:n,config:I,hasNestedOffsetScale:r})=>Gri(e,g,i,n,I.scale,r),reverse:({fieldOrDatumDef:e,scaleType:g,channel:i,config:n})=>{const I=dt(e)?e.sort:void 0;return vri(g,I,i,n.scale)},zero:({channel:e,fieldOrDatumDef:g,domain:i,markDef:n,scaleType:I,config:r,hasSecondaryRangeChannel:o})=>Bri(e,g,i,n,I,r.scale,o)};function xat(e){$n(e)?ari(e):Fat(e,"range")}function Fat(e,g){const i=e.component.scales;for(const n of e.children)g==="range"?xat(n):Kat(n,g);for(const n of At(i)){let I;for(const r of e.children){const o=r.component.scales[n];if(o){const C=o.getWithExplicit(g);I=Vm(I,C,g,"scale",NCt((a,A)=>{switch(g){case"range":return a.step&&A.step?a.step-A.step:0}return 0}))}}i[n].setWithExplicit(g,I)}}function mri(e,g){const i=g.bin;if(Ji(i)){const n=Ime(e,g.field,i);return new TC(()=>e.getSignalName(n))}else if(or(i)&&BZ(i)&&i.step!==void 0)return{step:i.step}}function pri(e,g){if(Eg([KC,ru,ou],e)&&g!=="nominal")return"hcl"}function bri(e,g,i,n,I,r){if(!(Mc(r)?.bin||et(i)||I!=null||n!=null||Eg([XC.TIME,XC.UTC],e)))return LI(g)?!0:void 0}function yri(e,g,i,n,I,r){if(LI(e)){if(RA(g)){if(i.continuousPadding!==void 0)return i.continuousPadding;const{type:o,orient:C}=I;if(o==="bar"&&!(dt(n)&&(n.bin||n.timeUnit))&&(C==="vertical"&&e==="x"||C==="horizontal"&&e==="y"))return r.continuousBandSize}if(g===XC.POINT)return i.pointPadding}}function Zri(e,g,i,n,I,r=!1){if(e===void 0){if(LI(g)){const{bandPaddingInner:o,barBandPaddingInner:C,rectBandPaddingInner:a,bandWithNestedOffsetPaddingInner:A}=I;return r?A:CI(o,i==="bar"?C:a)}else if(SS(g)&&n===XC.BAND)return I.offsetBandPaddingInner}}function Gri(e,g,i,n,I,r=!1){if(e===void 0){if(LI(g)){const{bandPaddingOuter:o,bandWithNestedOffsetPaddingOuter:C}=I;if(r)return C;if(i===XC.BAND)return CI(o,Qt(n)?{signal:`${n.signal}/2`}:n/2)}else if(SS(g)){if(i===XC.POINT)return .5;if(i===XC.BAND)return I.offsetBandPaddingOuter}}}function vri(e,g,i,n){if(i==="x"&&n.xReverse!==void 0)return va(e)&&g==="descending"?Qt(n.xReverse)?{signal:`!${n.xReverse.signal}`}:!n.xReverse:n.xReverse;if(va(e)&&g==="descending")return!0}function Bri(e,g,i,n,I,r,o){if(!!i&&i!=="unaggregated"&&va(I)){if(et(i)){const a=i[0],A=i[i.length-1];if(a<=0&&A>=0)return!0}return!1}if(e==="size"&&g.type==="quantitative"&&!o1(I))return!0;if(!(dt(g)&&g.bin)&&Eg([...au,...Rqg],e)){const{orient:a,type:A}=n;return Eg(["bar","area","line","trail"],A)&&(a==="horizontal"&&e==="y"||a==="vertical"&&e==="x")?!1:Eg(["bar","area"],A)&&!o?!0:r?.zero}return!1}function wri(e,g,i,n,I=!1){const r=Sri(g,i,n,I),{type:o}=e;return uh(g)?o!==void 0?Tti(g,o)?dt(i)&&!Xti(o,i.type)?(ut(Nei(o,r)),r):o:(ut(Hei(g,o,r)),r):r:null}function Sri(e,g,i,n){switch(g.type){case"nominal":case"ordinal":{if(mB(e)||F4(e)==="discrete")return e==="shape"&&g.type==="ordinal"&&ut(E4(e,"ordinal")),"ordinal";if(LI(e)||SS(e)){if(Eg(["rect","bar","image","rule"],i.type)||n)return"band"}else if(i.type==="arc"&&e in ofe)return"band";const I=i[FC(e)];return Sy(I)||a1(g)&&g.axis?.tickBand?"band":"point"}case"temporal":return mB(e)?"time":F4(e)==="discrete"?(ut(E4(e,"temporal")),"ordinal"):dt(g)&&g.timeUnit&&Zr(g.timeUnit).utc?"utc":"time";case"quantitative":return mB(e)?dt(g)&&Ji(g.bin)?"bin-ordinal":"linear":F4(e)==="discrete"?(ut(E4(e,"quantitative")),"ordinal"):"linear";case"geojson":return}throw new Error(Aot(g.type))}function Rri(e,{ignoreRange:g}={}){Eat(e),Wat(e);for(const i of Wti)Kat(e,i);g||xat(e)}function Eat(e){$n(e)?e.component.scales=Vri(e):e.component.scales=Xri(e)}function Vri(e){const{encoding:g,mark:i,markDef:n}=e,I={};for(const r of rJ){const o=ZI(g[r]);if(o&&i===Not&&r===xC&&o.type===RS)continue;let C=o&&o.scale;if(SS(r)){const a=Urt(r);if(!GIe(g,a)){C&&ut(pei(r));continue}}if(o&&C!==null&&C!==!1){C??(C={});const a=GIe(g,r),A=wri(C,r,o,n,a);I[r]=new Tat(e.scaleName(`${r}`,!0),{value:A,explicit:C.type===A})}}return I}const Wri=NCt((e,g)=>Fke(e)-Fke(g));function Xri(e){var g;const i=e.component.scales={},n={},I=e.component.resolve;for(const r of e.children){Eat(r);for(const o of At(r.component.scales))if((g=I.scale)[o]??(g[o]=fat(o,e)),I.scale[o]==="shared"){const C=n[o],a=r.component.scales[o].getWithExplicit("type");C?bti(C.value,a.value)?n[o]=Vm(C,a,"type","scale",Wri):(I.scale[o]="independent",delete n[o]):n[o]=a}}for(const r of At(n)){const o=e.scaleName(r,!0),C=n[r];i[r]=new Tat(o,C);for(const a of e.children){const A=a.component.scales[r];A&&(a.renameScale(A.get("name"),o),A.merged=!0)}}return i}class L4{constructor(){this.nameMap={}}rename(g,i){this.nameMap[g]=i}has(g){return this.nameMap[g]!==void 0}get(g){for(;this.nameMap[g]&&g!==this.nameMap[g];)g=this.nameMap[g];return g}}function $n(e){return e?.type==="unit"}function DA(e){return e?.type==="facet"}function sme(e){return e?.type==="concat"}function HS(e){return e?.type==="layer"}class Ame{constructor(g,i,n,I,r,o,C){this.type=i,this.parent=n,this.config=r,this.correctDataNames=a=>(a.from?.data&&(a.from.data=this.lookupDataSource(a.from.data)),a.from?.facet?.data&&(a.from.facet.data=this.lookupDataSource(a.from.facet.data)),a),this.parent=n,this.config=r,this.view=hC(C),this.name=g.name??I,this.title=nf(g.title)?{text:g.title}:g.title?hC(g.title):void 0,this.scaleNameMap=n?n.scaleNameMap:new L4,this.projectionNameMap=n?n.projectionNameMap:new L4,this.signalNameMap=n?n.signalNameMap:new L4,this.data=g.data,this.description=g.description,this.transforms=xii(g.transform??[]),this.layout=i==="layer"||i==="unit"?{}:Jgi(g,i,r),this.component={data:{sources:n?n.component.data.sources:[],outputNodes:n?n.component.data.outputNodes:{},outputNodeRefCounts:n?n.component.data.outputNodeRefCounts:{},isFaceted:dJ(g)||n?.component.data.isFaceted&&g.data===void 0},layoutSize:new hh,layoutHeaders:{row:{},column:{},facet:{}},mark:null,resolve:{scale:{},axis:{},legend:{},...o?mg(o):{}},selection:null,scales:null,projection:null,axes:{},legends:{}}}get width(){return this.getSizeSignalRef("width")}get height(){return this.getSizeSignalRef("height")}parse(){this.parseScale(),this.parseLayoutSize(),this.renameTopLevelLayoutSizeSignal(),this.parseSelections(),this.parseProjection(),this.parseData(),this.parseAxesAndHeaders(),this.parseLegends(),this.parseMarkGroup()}parseScale(){Rri(this)}parseProjection(){Sat(this)}renameTopLevelLayoutSizeSignal(){this.getName("width")!=="width"&&this.renameSignal(this.getName("width"),"width"),this.getName("height")!=="height"&&this.renameSignal(this.getName("height"),"height")}parseLegends(){Zat(this)}assembleEncodeFromView(g){const{style:i,...n}=g,I={};for(const r of At(n)){const o=n[r];o!==void 0&&(I[r]=nn(o))}return I}assembleGroupEncodeEntry(g){let i={};return this.view&&(i=this.assembleEncodeFromView(this.view)),!g&&(this.description&&(i.description=nn(this.description)),this.type==="unit"||this.type==="layer")?{width:this.getSizeSignalRef("width"),height:this.getSizeSignalRef("height"),...i??{}}:Ri(i)?void 0:i}assembleLayout(){if(!this.layout)return;const{spacing:g,...i}=this.layout,{component:n,config:I}=this,r=$ni(n.layoutHeaders,I);return{padding:g,...this.assembleDefaultLayout(),...i,...r?{titleBand:r}:{}}}assembleDefaultLayout(){return{}}assembleHeaderMarks(){const{layoutHeaders:g}=this.component;let i=[];for(const n of ns)g[n].title&&i.push(Oni(this,n));for(const n of tme)i=i.concat(Jni(this,n));return i}assembleAxes(){return Hni(this.component.axes,this.config)}assembleLegends(){return vat(this)}assembleProjections(){return yIi(this)}assembleTitle(){const{encoding:g,...i}=this.title??{},n={...got(this.config.title).nonMarkTitleProperties,...i,...g?{encode:{update:g}}:{}};if(n.text)return Eg(["unit","layer"],this.type)?Eg(["middle",void 0],n.anchor)&&(n.frame??(n.frame="group")):n.anchor??(n.anchor="start"),Ri(n)?void 0:n}assembleGroup(g=[]){const i={};g=g.concat(this.assembleSignals()),g.length>0&&(i.signals=g);const n=this.assembleLayout();n&&(i.layout=n),i.marks=[].concat(this.assembleHeaderMarks(),this.assembleMarks());const I=!this.parent||DA(this.parent)?Xat(this):[];I.length>0&&(i.scales=I);const r=this.assembleAxes();r.length>0&&(i.axes=r);const o=this.assembleLegends();return o.length>0&&(i.legends=o),i}getName(g){return dn((this.name?`${this.name}_`:"")+g)}getDataName(g){return this.getName(zi[g].toLowerCase())}requestDataName(g){const i=this.getDataName(g),n=this.component.data.outputNodeRefCounts;return n[i]=(n[i]||0)+1,i}getSizeSignalRef(g){if(DA(this.parent)){const i=dat(g),n=IJ(i),I=this.component.scales[n];if(I&&!I.merged){const r=I.get("type"),o=I.get("range");if(UI(r)&&dp(o)){const C=I.get("name"),a=VJ(this,n),A=ame(a);if(A){const s=Bt({aggregate:"distinct",field:A},{expr:"datum"});return{signal:uat(C,I,s)}}else return ut(sfe(n)),null}}}return{signal:this.signalNameMap.get(this.getName(g))}}lookupDataSource(g){const i=this.component.data.outputNodes[g];return i?i.getSource():g}getSignalName(g){return this.signalNameMap.get(g)}renameSignal(g,i){this.signalNameMap.rename(g,i)}renameScale(g,i){this.scaleNameMap.rename(g,i)}renameProjection(g,i){this.projectionNameMap.rename(g,i)}scaleName(g,i){if(i)return this.getName(g);if(Ort(g)&&uh(g)&&this.component.scales[g]||this.scaleNameMap.has(this.getName(g)))return this.scaleNameMap.get(this.getName(g))}projectionName(g){if(g)return this.getName("projection");if(this.component.projection&&!this.component.projection.merged||this.projectionNameMap.has(this.getName("projection")))return this.projectionNameMap.get(this.getName("projection"))}getScaleComponent(g){if(!this.component.scales)throw new Error("getScaleComponent cannot be called before parseScale(). Make sure you have called parseScale or use parseUnitModelWithScale().");const i=this.component.scales[g];return i&&!i.merged?i:this.parent?this.parent.getScaleComponent(g):void 0}getSelectionComponent(g,i){let n=this.component.selection[g];if(!n&&this.parent&&(n=this.parent.getSelectionComponent(g,i)),!n)throw new Error(jqg(i));return n}hasAxisOrientSignalRef(){return this.component.axes.x?.some(g=>g.hasOrientSignalRef())||this.component.axes.y?.some(g=>g.hasOrientSignalRef())}}class Dat extends Ame{vgField(g,i={}){const n=this.fieldDef(g);if(n)return Bt(n,i)}reduceFieldDef(g,i){return Zgi(this.getMapping(),(n,I,r)=>{const o=Mc(I);return o?g(n,o,r):n},i)}forEachFieldDef(g,i){Kfe(this.getMapping(),(n,I)=>{const r=Mc(n);r&&g(r,I)},i)}}class WJ extends Xi{clone(){return new WJ(null,mg(this.transform))}constructor(g,i){super(g),this.transform=i,this.transform=mg(i);const n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??"value",n[1]??"density"],i.groupby&&i.minsteps==null&&i.maxsteps==null&&i.steps==null&&(this.transform.steps=200)}dependentFields(){return new Set([this.transform.density,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`DensityTransform ${$g(this.transform)}`}assemble(){const{density:g,...i}=this.transform;return{type:"kde",field:g,...i}}}class eT extends Xi{clone(){return new eT(null,{...this.filter})}constructor(g,i){super(g),this.filter=i}static make(g,i){const{config:n,mark:I,markDef:r}=i;if(di("invalid",r,n)!=="filter")return null;const C=i.reduceFieldDef((a,A,s)=>{const l=uh(s)&&i.getScaleComponent(s);if(l){const c=l.get("type");va(c)&&A.aggregate!=="count"&&!hp(I)&&(a[A.field]=A)}return a},{});return At(C).length?new eT(g,C):null}dependentFields(){return new Set(At(this.filter))}producedFields(){return new Set}hash(){return`FilterInvalid ${$g(this.filter)}`}assemble(){const g=At(this.filter).reduce((i,n)=>{const I=this.filter[n],r=Bt(I,{expr:"datum"});return I!==null&&(I.type==="temporal"?i.push(`(isDate(${r}) || (isValid(${r}) && isFinite(+${r})))`):I.type==="quantitative"&&(i.push(`isValid(${r})`),i.push(`isFinite(+${r})`))),i},[]);return g.length>0?{type:"filter",expr:g.join(" && ")}:null}}class XJ extends Xi{clone(){return new XJ(this.parent,mg(this.transform))}constructor(g,i){super(g),this.transform=i,this.transform=mg(i);const{flatten:n,as:I=[]}=this.transform;this.transform.as=n.map((r,o)=>I[o]??r)}dependentFields(){return new Set(this.transform.flatten)}producedFields(){return new Set(this.transform.as)}hash(){return`FlattenTransform ${$g(this.transform)}`}assemble(){const{flatten:g,as:i}=this.transform;return{type:"flatten",fields:g,as:i}}}class TJ extends Xi{clone(){return new TJ(null,mg(this.transform))}constructor(g,i){super(g),this.transform=i,this.transform=mg(i);const n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??"key",n[1]??"value"]}dependentFields(){return new Set(this.transform.fold)}producedFields(){return new Set(this.transform.as)}hash(){return`FoldTransform ${$g(this.transform)}`}assemble(){const{fold:g,as:i}=this.transform;return{type:"fold",fields:g,as:i}}}class yB extends Xi{clone(){return new yB(null,mg(this.fields),this.geojson,this.signal)}static parseAll(g,i){if(i.component.projection&&!i.component.projection.isFit)return g;let n=0;for(const I of[[cl,ll],[Zs,ul]]){const r=I.map(o=>{const C=ZI(i.encoding[o]);return dt(C)?C.field:su(C)?{expr:`${C.datum}`}:QA(C)?{expr:`${C.value}`}:void 0});(r[0]||r[1])&&(g=new yB(g,r,null,i.getName(`geojson_${n++}`)))}if(i.channelHasField(xC)){const I=i.typedFieldDef(xC);I.type===RS&&(g=new yB(g,null,I.field,i.getName(`geojson_${n++}`)))}return g}constructor(g,i,n,I){super(g),this.fields=i,this.geojson=n,this.signal=I}dependentFields(){const g=(this.fields??[]).filter(Rt);return new Set([...this.geojson?[this.geojson]:[],...g])}producedFields(){return new Set}hash(){return`GeoJSON ${this.geojson} ${this.signal} ${$g(this.fields)}`}assemble(){return[...this.geojson?[{type:"filter",expr:`isValid(datum["${this.geojson}"])`}]:[],{type:"geojson",...this.fields?{fields:this.fields}:{},...this.geojson?{geojson:this.geojson}:{},signal:this.signal}]}}class tT extends Xi{clone(){return new tT(null,this.projection,mg(this.fields),mg(this.as))}constructor(g,i,n,I){super(g),this.projection=i,this.fields=n,this.as=I}static parseAll(g,i){if(!i.projectionName())return g;for(const n of[[cl,ll],[Zs,ul]]){const I=n.map(o=>{const C=ZI(i.encoding[o]);return dt(C)?C.field:su(C)?{expr:`${C.datum}`}:QA(C)?{expr:`${C.value}`}:void 0}),r=n[0]===Zs?"2":"";(I[0]||I[1])&&(g=new tT(g,i.projectionName(),I,[i.getName(`x${r}`),i.getName(`y${r}`)]))}return g}dependentFields(){return new Set(this.fields.filter(Rt))}producedFields(){return new Set(this.as)}hash(){return`Geopoint ${this.projection} ${$g(this.fields)} ${$g(this.as)}`}assemble(){return{type:"geopoint",projection:this.projection,fields:this.fields,as:this.as}}}class Ab extends Xi{clone(){return new Ab(null,mg(this.transform))}constructor(g,i){super(g),this.transform=i}dependentFields(){return new Set([this.transform.impute,this.transform.key,...this.transform.groupby??[]])}producedFields(){return new Set([this.transform.impute])}processSequence(g){const{start:i=0,stop:n,step:I}=g;return{signal:`sequence(${[i,n,...I?[I]:[]].join(",")})`}}static makeFromTransform(g,i){return new Ab(g,i)}static makeFromEncoding(g,i){const n=i.encoding,I=n.x,r=n.y;if(dt(I)&&dt(r)){const o=I.impute?I:r.impute?r:void 0;if(o===void 0)return;const C=I.impute?r:r.impute?I:void 0,{method:a,value:A,frame:s,keyvals:l}=o.impute,c=rCt(i.mark,n);return new Ab(g,{impute:o.field,key:C.field,...a?{method:a}:{},...A!==void 0?{value:A}:{},...s?{frame:s}:{},...l!==void 0?{keyvals:l}:{},...c.length?{groupby:c}:{}})}return null}hash(){return`Impute ${$g(this.transform)}`}assemble(){const{impute:g,key:i,keyvals:n,method:I,groupby:r,value:o,frame:C=[null,null]}=this.transform,a={type:"impute",field:g,key:i,...n?{keyvals:bii(n)?this.processSequence(n):n}:{},method:"value",...r?{groupby:r}:{},value:!I||I==="value"?o:null};if(I&&I!=="value"){const A={type:"window",as:[`imputed_${g}_value`],ops:[I],fields:[g],frame:C,ignorePeers:!1,...r?{groupby:r}:{}},s={type:"formula",expr:`datum.${g} === null ? datum.imputed_${g}_value : datum.${g}`,as:g};return[a,A,s]}else return[a]}}class HJ extends Xi{clone(){return new HJ(null,mg(this.transform))}constructor(g,i){super(g),this.transform=i,this.transform=mg(i);const n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??i.on,n[1]??i.loess]}dependentFields(){return new Set([this.transform.loess,this.transform.on,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`LoessTransform ${$g(this.transform)}`}assemble(){const{loess:g,on:i,...n}=this.transform;return{type:"loess",x:i,y:g,...n}}}class gT extends Xi{clone(){return new gT(null,mg(this.transform),this.secondary)}constructor(g,i,n){super(g),this.transform=i,this.secondary=n}static make(g,i,n,I){const r=i.component.data.sources,{from:o}=n;let C=null;if(yii(o)){let a=Pat(o.data,r);a||(a=new Xy(o.data),r.push(a));const A=i.getName(`lookup_${I}`);C=new Ko(a,A,zi.Lookup,i.component.data.outputNodeRefCounts),i.component.data.outputNodes[A]=C}else if(Zii(o)){const a=o.param;n={as:a,...n};let A;try{A=i.getSelectionComponent(dn(a),a)}catch{throw new Error(eei(a))}if(C=A.materialized,!C)throw new Error(tei(a))}return new gT(g,n,C.getSource())}dependentFields(){return new Set([this.transform.lookup])}producedFields(){return new Set(this.transform.as?Vt(this.transform.as):this.transform.from.fields)}hash(){return`Lookup ${$g({transform:this.transform,secondary:this.secondary})}`}assemble(){let g;if(this.transform.from.fields)g={values:this.transform.from.fields,...this.transform.as?{as:Vt(this.transform.as)}:{}};else{let i=this.transform.as;Rt(i)||(ut(aei),i="_lookup"),g={as:[i]}}return{type:"lookup",from:this.secondary,key:this.transform.from.key,fields:[this.transform.lookup],...g,...this.transform.default?{default:this.transform.default}:{}}}}class NJ extends Xi{clone(){return new NJ(null,mg(this.transform))}constructor(g,i){super(g),this.transform=i,this.transform=mg(i);const n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??"prob",n[1]??"value"]}dependentFields(){return new Set([this.transform.quantile,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`QuantileTransform ${$g(this.transform)}`}assemble(){const{quantile:g,...i}=this.transform;return{type:"quantile",field:g,...i}}}class kJ extends Xi{clone(){return new kJ(null,mg(this.transform))}constructor(g,i){super(g),this.transform=i,this.transform=mg(i);const n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??i.on,n[1]??i.regression]}dependentFields(){return new Set([this.transform.regression,this.transform.on,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`RegressionTransform ${$g(this.transform)}`}assemble(){const{regression:g,on:i,...n}=this.transform;return{type:"regression",x:i,y:g,...n}}}class YJ extends Xi{clone(){return new YJ(null,mg(this.transform))}constructor(g,i){super(g),this.transform=i}addDimensions(g){this.transform.groupby=Ic((this.transform.groupby??[]).concat(g),i=>i)}producedFields(){}dependentFields(){return new Set([this.transform.pivot,this.transform.value,...this.transform.groupby??[]])}hash(){return`PivotTransform ${$g(this.transform)}`}assemble(){const{pivot:g,value:i,groupby:n,limit:I,op:r}=this.transform;return{type:"pivot",field:g,value:i,...I!==void 0?{limit:I}:{},...r!==void 0?{op:r}:{},...n!==void 0?{groupby:n}:{}}}}class KJ extends Xi{clone(){return new KJ(null,mg(this.transform))}constructor(g,i){super(g),this.transform=i}dependentFields(){return new Set}producedFields(){return new Set}hash(){return`SampleTransform ${$g(this.transform)}`}assemble(){return{type:"sample",size:this.transform.sample}}}function Mat(e){let g=0;function i(n,I){if(n instanceof Xy&&!n.isGenerator&&!A1(n.data)&&(e.push(I),I={name:null,source:I.name,transform:[]}),n instanceof Lr&&(n.parent instanceof Xy&&!I.source?(I.format={...I.format??{},parse:n.assembleFormatParse()},I.transform.push(...n.assembleTransforms(!0))):I.transform.push(...n.assembleTransforms())),n instanceof XS){I.name||(I.name=`data_${g++}`),!I.source||I.transform.length>0?(e.push(I),n.data=I.name):n.data=I.source,e.push(...n.assemble());return}switch((n instanceof dN||n instanceof hN||n instanceof eT||n instanceof WS||n instanceof l1||n instanceof tT||n instanceof EA||n instanceof gT||n instanceof TS||n instanceof VZ||n instanceof TJ||n instanceof XJ||n instanceof WJ||n instanceof HJ||n instanceof NJ||n instanceof kJ||n instanceof Tm||n instanceof KJ||n instanceof YJ)&&I.transform.push(n.assemble()),(n instanceof Gc||n instanceof Zc||n instanceof Ab||n instanceof Bd||n instanceof yB)&&I.transform.push(...n.assemble()),n instanceof Ko&&(I.source&&I.transform.length===0?n.setSource(I.source):n.parent instanceof Ko?n.setSource(I.name):(I.name||(I.name=`data_${g++}`),n.setSource(I.name),n.numChildren()===1&&(e.push(I),I={name:null,source:I.name,transform:[]}))),n.numChildren()){case 0:n instanceof Ko&&(!I.source||I.transform.length>0)&&e.push(I);break;case 1:i(n.children[0],I);break;default:{I.name||(I.name=`data_${g++}`);let r=I.name;!I.source||I.transform.length>0?e.push(I):r=I.source;for(const o of n.children)i(o,{name:null,source:r,transform:[]});break}}}return i}function Tri(e){const g=[],i=Mat(g);for(const n of e.children)i(n,{source:e.name,name:null,transform:[]});return g}function Hri(e,g){const i=[],n=Mat(i);let I=0;for(const o of e.sources){o.hasName()||(o.dataName=`source_${I++}`);const C=o.assemble();n(o,C)}for(const o of i)o.transform.length===0&&delete o.transform;let r=0;for(const[o,C]of i.entries())(C.transform??[]).length===0&&!C.source&&i.splice(r++,0,i.splice(o,1)[0]);for(const o of i)for(const C of o.transform??[])C.type==="lookup"&&(C.from=e.outputNodes[C.from].getSource());for(const o of i)o.name in g&&(o.values=g[o.name]);return i}function Nri(e){return e==="top"||e==="left"||Qt(e)?"header":"footer"}function kri(e){for(const g of ns)Yri(e,g);WYe(e,"x"),WYe(e,"y")}function Yri(e,g){const{facet:i,config:n,child:I,component:r}=e;if(e.channelHasField(g)){const o=i[g],C=u1("title",null,n,g);let a=pB(o,n,{allowDisabling:!0,includeDefault:C===void 0||!!C});I.component.layoutHeaders[g].title&&(a=et(a)?a.join(", "):a,a+=` / ${I.component.layoutHeaders[g].title}`,I.component.layoutHeaders[g].title=null);const A=u1("labelOrient",o.header,n,g),s=o.header!==null?CI(o.header?.labels,n.header.labels,!0):!1,l=Eg(["bottom","right"],A)?"footer":"header";r.layoutHeaders[g]={title:o.header!==null?a:null,facetFieldDef:o,[l]:g==="facet"?[]:[zat(e,g,s)]}}}function zat(e,g,i){const n=g==="row"?"height":"width";return{labels:i,sizeSignal:e.child.component.layoutSize.get(n)?e.child.getSizeSignalRef(n):void 0,axes:[]}}function WYe(e,g){const{child:i}=e;if(i.component.axes[g]){const{layoutHeaders:n,resolve:I}=e.component;if(I.axis[g]=nme(I,g),I.axis[g]==="shared"){const r=g==="x"?"column":"row",o=n[r];for(const C of i.component.axes[g]){const a=Nri(C.get("orient"));o[a]??(o[a]=[zat(e,r,!1)]);const A=Z2(C,"main",e.config,{header:!0});A&&o[a][0].axes.push(A),C.mainExtracted=!0}}}}function Kri(e){lme(e),V3(e,"width"),V3(e,"height")}function xri(e){lme(e);const g=e.layout.columns===1?"width":"childWidth",i=e.layout.columns===void 0?"height":"childHeight";V3(e,g),V3(e,i)}function lme(e){for(const g of e.children)g.parseLayoutSize()}function V3(e,g){const i=dat(g),n=IJ(i),I=e.component.resolve,r=e.component.layoutSize;let o;for(const C of e.children){const a=C.component.layoutSize.getWithExplicit(i),A=I.scale[n]??fat(n,e);if(A==="independent"&&a.value==="step"){o=void 0;break}if(o){if(A==="independent"&&o.value!==a.value){o=void 0;break}o=Vm(o,a,i,"")}else o=a}if(o){for(const C of e.children)e.renameSignal(C.getName(i),e.getName(g)),C.component.layoutSize.set(i,"merged",!1);r.setWithExplicit(g,o)}else r.setWithExplicit(g,{explicit:!1,value:void 0})}function Fri(e){const{size:g,component:i}=e;for(const n of au){const I=FC(n);if(g[I]){const r=g[I];i.layoutSize.set(I,zc(r)?"step":r,!0)}else{const r=Eri(e,I);i.layoutSize.set(I,r,!1)}}}function Eri(e,g){const i=g==="width"?"x":"y",n=e.config,I=e.getScaleComponent(i);if(I){const r=I.get("type"),o=I.get("range");if(UI(r)){const C=B3(n.view,g);return dp(o)||zc(C)?"step":C}else return BIe(n.view,g)}else{if(e.hasProjection||e.mark==="arc")return BIe(n.view,g);{const r=B3(n.view,g);return zc(r)?r.step:r}}}function FIe(e,g,i){return Bt(g,{suffix:`by_${Bt(e)}`,...i??{}})}class OW extends Dat{constructor(g,i,n,I){super(g,"facet",i,n,I,g.resolve),this.child=fme(g.spec,this,this.getName("child"),void 0,I),this.children=[this.child],this.facet=this.initFacet(g.facet)}initFacet(g){if(!sN(g))return{facet:this.initFacetFieldDef(g,"facet")};const i=At(g),n={};for(const I of i){if(![yd,Zd].includes(I)){ut(CJ(I,"facet"));break}const r=g[I];if(r.field===void 0){ut(pIe(r,I));break}n[I]=this.initFacetFieldDef(r,I)}return n}initFacetFieldDef(g,i){const n=kfe(g,i);return n.header?n.header=hC(n.header):n.header===null&&(n.header=null),n}channelHasField(g){return!!this.facet[g]}fieldDef(g){return this.facet[g]}parseData(){this.component.data=xJ(this),this.child.parseData()}parseLayoutSize(){lme(this)}parseSelections(){this.child.parseSelections(),this.component.selection=this.child.component.selection}parseMarkGroup(){this.child.parseMarkGroup()}parseAxesAndHeaders(){this.child.parseAxesAndHeaders(),kri(this)}assembleSelectionTopLevelSignals(g){return this.child.assembleSelectionTopLevelSignals(g)}assembleSignals(){return this.child.assembleSignals(),[]}assembleSelectionData(g){return this.child.assembleSelectionData(g)}getHeaderLayoutMixins(){const g={};for(const i of ns)for(const n of gme){const I=this.component.layoutHeaders[i],r=I[n],{facetFieldDef:o}=I;if(o){const C=u1("titleOrient",o.header,this.config,i);if(["right","bottom"].includes(C)){const a=SJ(i,C);g.titleAnchor??(g.titleAnchor={}),g.titleAnchor[a]="end"}}if(r?.[0]){const C=i==="row"?"height":"width",a=n==="header"?"headerBand":"footerBand";i!=="facet"&&!this.child.component.layoutSize.get(C)&&(g[a]??(g[a]={}),g[a][i]=.5),I.title&&(g.offset??(g.offset={}),g.offset[i==="row"?"rowTitle":"columnTitle"]=10)}}return g}assembleDefaultLayout(){const{column:g,row:i}=this.facet,n=g?this.columnDistinctSignal():i?1:void 0;let I="all";return(!i&&this.component.resolve.scale.x==="independent"||!g&&this.component.resolve.scale.y==="independent")&&(I="none"),{...this.getHeaderLayoutMixins(),...n?{columns:n}:{},bounds:"full",align:I}}assembleLayoutSignals(){return this.child.assembleLayoutSignals()}columnDistinctSignal(){if(!(this.parent&&this.parent instanceof OW))return{signal:`length(data('${this.getName("column_domain")}'))`}}assembleGroupStyle(){}assembleGroup(g){return this.parent&&this.parent instanceof OW?{...this.channelHasField("column")?{encode:{update:{columns:{field:Bt(this.facet.column,{prefix:"distinct"})}}}}:{},...super.assembleGroup(g)}:super.assembleGroup(g)}getCardinalityAggregateForChild(){const g=[],i=[],n=[];if(this.child instanceof OW){if(this.child.channelHasField("column")){const I=Bt(this.child.facet.column);g.push(I),i.push("distinct"),n.push(`distinct_${I}`)}}else for(const I of au){const r=this.child.component.scales[I];if(r&&!r.merged){const o=r.get("type"),C=r.get("range");if(UI(o)&&dp(C)){const a=VJ(this.child,I),A=ame(a);A?(g.push(A),i.push("distinct"),n.push(`distinct_${A}`)):ut(sfe(I))}}}return{fields:g,ops:i,as:n}}assembleFacet(){const{name:g,data:i}=this.component.data.facetRoot,{row:n,column:I}=this.facet,{fields:r,ops:o,as:C}=this.getCardinalityAggregateForChild(),a=[];for(const s of ns){const l=this.facet[s];if(l){a.push(Bt(l));const{bin:c,sort:u}=l;if(Ji(c)&&a.push(Bt(l,{binSuffix:"end"})),yc(u)){const{field:d,op:h=uJ}=u,f=FIe(l,u);n&&I?(r.push(f),o.push("max"),C.push(f)):(r.push(d),o.push(h),C.push(f))}else if(et(u)){const d=c1(l,s);r.push(d),o.push("max"),C.push(d)}}}const A=!!n&&!!I;return{name:g,data:i,groupby:a,...A||r.length>0?{aggregate:{...A?{cross:A}:{},...r.length?{fields:r,ops:o,as:C}:{}}}:{}}}facetSortFields(g){const{facet:i}=this,n=i[g];return n?yc(n.sort)?[FIe(n,n.sort,{expr:"datum"})]:et(n.sort)?[c1(n,g,{expr:"datum"})]:[Bt(n,{expr:"datum"})]:[]}facetSortOrder(g){const{facet:i}=this,n=i[g];if(n){const{sort:I}=n;return[(yc(I)?I.order:!et(I)&&I)||"ascending"]}return[]}assembleLabelTitle(){const{facet:g,config:i}=this;if(g.facet)return HIe(g.facet,"facet",i);const n={row:["top","bottom"],column:["left","right"]};for(const I of tme)if(g[I]){const r=u1("labelOrient",g[I]?.header,i,I);if(n[I].includes(r))return HIe(g[I],I,i)}}assembleMarks(){const{child:g}=this,i=this.component.data.facetRoot,n=Tri(i),I=g.assembleGroupEncodeEntry(!1),r=this.assembleLabelTitle()||g.assembleTitle(),o=g.assembleGroupStyle();return[{name:this.getName("cell"),type:"group",...r?{title:r}:{},...o?{style:o}:{},from:{facet:this.assembleFacet()},sort:{field:ns.map(a=>this.facetSortFields(a)).flat(),order:ns.map(a=>this.facetSortOrder(a)).flat()},...n.length>0?{data:n}:{},...I?{encode:{update:I}}:{},...g.assembleGroup(jii(this,[]))}]}getMapping(){return this.facet}}function Dri(e,g){const{row:i,column:n}=g;if(i&&n){let I=null;for(const r of[i,n])if(yc(r.sort)){const{field:o,op:C=uJ}=r.sort;e=I=new VZ(e,{joinaggregate:[{op:C,field:o,as:FIe(r,r.sort,{forAs:!0})}],groupby:[Bt(r)]})}return I}return null}function Pat(e,g){for(const i of g){const n=i.data;if(e.name&&i.hasName()&&e.name!==i.dataName)continue;const I=e.format?.mesh,r=n.format?.feature;if(I&&r)continue;const o=e.format?.feature;if((o||r)&&o!==r)continue;const C=n.format?.mesh;if(!((I||C)&&I!==C)){if($9(e)&&$9(n)){if(nc(e.values,n.values))return i}else if(A1(e)&&A1(n)){if(e.url===n.url)return i}else if(kCt(e)&&e.name===i.dataName)return i}}return null}function Mri(e,g){if(e.data||!e.parent){if(e.data===null){const n=new Xy({values:[]});return g.push(n),n}const i=Pat(e.data,g);if(i)return am(e.data)||(i.data.format=Nrt({},e.data.format,i.data.format)),!i.hasName()&&e.data.name&&(i.dataName=e.data.name),i;{const n=new Xy(e.data);return g.push(n),n}}else return e.parent.component.data.facetRoot?e.parent.component.data.facetRoot:e.parent.component.data.main}function zri(e,g,i){let n=0;for(const I of g.transforms){let r,o;if(Tii(I))o=e=new l1(e,I),r="derived";else if(Lfe(I)){const C=NIi(I);o=e=Lr.makeWithAncestors(e,{},C,i)??e,e=new WS(e,g,I.filter)}else if(WCt(I))o=e=Gc.makeFromTransform(e,I,g),r="number";else if(Nii(I))r="date",i.getWithExplicit(I.field).value===void 0&&(e=new Lr(e,{[I.field]:r}),i.set(I.field,r,!1)),o=e=Zc.makeFromTransform(e,I);else if(kii(I))o=e=EA.makeFromTransform(e,I),r="number",eme(g)&&(e=new Tm(e));else if(VCt(I))o=e=gT.make(e,g,I,n++),r="derived";else if(Vii(I))o=e=new TS(e,I),r="number";else if(Wii(I))o=e=new VZ(e,I),r="number";else if(Yii(I))o=e=Bd.makeFromTransform(e,I),r="derived";else if(Kii(I))o=e=new TJ(e,I),r="derived";else if(Xii(I))o=e=new XJ(e,I),r="derived";else if(Gii(I))o=e=new YJ(e,I),r="derived";else if(Rii(I))e=new KJ(e,I);else if(Hii(I))o=e=Ab.makeFromTransform(e,I),r="derived";else if(vii(I))o=e=new WJ(e,I),r="derived";else if(Bii(I))o=e=new NJ(e,I),r="derived";else if(wii(I))o=e=new kJ(e,I),r="derived";else if(Sii(I))o=e=new HJ(e,I),r="derived";else{ut(Cei(I));continue}if(o&&r!==void 0)for(const C of o.producedFields()??[])i.set(C,r,!1)}return e}function xJ(e){let g=Mri(e,e.component.data.sources);const{outputNodes:i,outputNodeRefCounts:n}=e.component.data,I=e.data,o=!(I&&(am(I)||A1(I)||$9(I)))&&e.parent?e.parent.component.data.ancestorParse.clone():new Uii;am(I)?(YCt(I)?g=new hN(g,I.sequence):Ufe(I)&&(g=new dN(g,I.graticule)),o.parseNothing=!0):I?.format?.parse===null&&(o.parseNothing=!0),g=Lr.makeExplicit(g,e,o)??g,g=new Tm(g);const C=e.parent&&HS(e.parent);($n(e)||DA(e))&&C&&(g=Gc.makeFromEncoding(g,e)??g),e.transforms.length>0&&(g=zri(g,e,o));const a=YIi(e),A=kIi(e);g=Lr.makeWithAncestors(g,{},{...a,...A},o)??g,$n(e)&&(g=yB.parseAll(g,e),g=tT.parseAll(g,e)),($n(e)||DA(e))&&(C||(g=Gc.makeFromEncoding(g,e)??g),g=Zc.makeFromEncoding(g,e)??g,g=l1.parseAllForSortIndex(g,e));const s=e.getDataName(zi.Raw),l=new Ko(g,s,zi.Raw,n);if(i[s]=l,g=l,$n(e)){const h=EA.makeFromEncoding(g,e);h&&(g=h,eme(e)&&(g=new Tm(g))),g=Ab.makeFromEncoding(g,e)??g,g=Bd.makeFromEncoding(g,e)??g}$n(e)&&(g=eT.make(g,e)??g);const c=e.getDataName(zi.Main),u=new Ko(g,c,zi.Main,n);i[c]=u,g=u,$n(e)&&Xni(e,u);let d=null;if(DA(e)){const h=e.getName("facet");g=Dri(g,e.facet)??g,d=new XS(g,e,h,u.getSource()),i[h]=d}return{...e.component.data,outputNodes:i,outputNodeRefCounts:n,raw:l,main:u,facetRoot:d,ancestorParse:o}}class Pri extends Ame{constructor(g,i,n,I){super(g,"concat",i,n,I,g.resolve),(g.resolve?.axis?.x==="shared"||g.resolve?.axis?.y==="shared")&&ut(Iei),this.children=this.getChildren(g).map((r,o)=>fme(r,this,this.getName(`concat_${o}`),void 0,I))}parseData(){this.component.data=xJ(this);for(const g of this.children)g.parseData()}parseSelections(){this.component.selection={};for(const g of this.children){g.parseSelections();for(const i of At(g.component.selection))this.component.selection[i]=g.component.selection[i]}}parseMarkGroup(){for(const g of this.children)g.parseMarkGroup()}parseAxesAndHeaders(){for(const g of this.children)g.parseAxesAndHeaders()}getChildren(g){return ZJ(g)?g.vconcat:Ofe(g)?g.hconcat:g.concat}parseLayoutSize(){xri(this)}parseAxisGroup(){return null}assembleSelectionTopLevelSignals(g){return this.children.reduce((i,n)=>n.assembleSelectionTopLevelSignals(i),g)}assembleSignals(){return this.children.forEach(g=>g.assembleSignals()),[]}assembleLayoutSignals(){const g=ime(this);for(const i of this.children)g.push(...i.assembleLayoutSignals());return g}assembleSelectionData(g){return this.children.reduce((i,n)=>n.assembleSelectionData(i),g)}assembleMarks(){return this.children.map(g=>{const i=g.assembleTitle(),n=g.assembleGroupStyle(),I=g.assembleGroupEncodeEntry(!1);return{type:"group",name:g.getName("group"),...i?{title:i}:{},...n?{style:n}:{},...I?{encode:{update:I}}:{},...g.assembleGroup()}})}assembleGroupStyle(){}assembleDefaultLayout(){const g=this.layout.columns;return{...g!=null?{columns:g}:{},bounds:"full",align:"each"}}}function _ri(e){return e===!1||e===null}const Ori={disable:1,gridScale:1,scale:1,...gCt,labelExpr:1,encode:1},_at=At(Ori);class cme extends hh{constructor(g={},i={},n=!1){super(),this.explicit=g,this.implicit=i,this.mainExtracted=n}clone(){return new cme(mg(this.explicit),mg(this.implicit),this.mainExtracted)}hasAxisPart(g){return g==="axis"?!0:g==="grid"||g==="title"?!!this.get(g):!_ri(this.get(g))}hasOrientSignalRef(){return Qt(this.explicit.orient)}}function Jri(e,g,i){const{encoding:n,config:I}=e,r=ZI(n[g])??ZI(n[Cu(g)]),o=e.axis(g)||{},{format:C,formatType:a}=o;if(Ry(a))return{text:VA({fieldOrDatumDef:r,field:"datum.value",format:C,formatType:a,config:I}),...i};if(C===void 0&&a===void 0&&I.customFormatTypes){if(C1(r)==="quantitative"){if(a1(r)&&r.stack==="normalize"&&I.normalizedNumberFormatType)return{text:VA({fieldOrDatumDef:r,field:"datum.value",format:I.normalizedNumberFormat,formatType:I.normalizedNumberFormatType,config:I}),...i};if(I.numberFormatType)return{text:VA({fieldOrDatumDef:r,field:"datum.value",format:I.numberFormat,formatType:I.numberFormatType,config:I}),...i}}if(C1(r)==="temporal"&&I.timeFormatType&&dt(r)&&!r.timeUnit)return{text:VA({fieldOrDatumDef:r,field:"datum.value",format:I.timeFormat,formatType:I.timeFormatType,config:I}),...i}}return i}function Lri(e){return au.reduce((g,i)=>(e.component.scales[i]&&(g[i]=[toi(i,e)]),g),{})}const Uri={bottom:"top",top:"bottom",left:"right",right:"left"};function Qri(e){const{axes:g,resolve:i}=e.component,n={top:0,bottom:0,right:0,left:0};for(const I of e.children){I.parseAxesAndHeaders();for(const r of At(I.component.axes))i.axis[r]=nme(e.component.resolve,r),i.axis[r]==="shared"&&(g[r]=jri(g[r],I.component.axes[r]),g[r]||(i.axis[r]="independent",delete g[r]))}for(const I of au){for(const r of e.children)if(r.component.axes[I]){if(i.axis[I]==="independent"){g[I]=(g[I]??[]).concat(r.component.axes[I]);for(const o of r.component.axes[I]){const{value:C,explicit:a}=o.getWithExplicit("orient");if(!Qt(C)){if(n[C]>0&&!a){const A=Uri[C];n[C]>n[A]&&o.set("orient",A,!1)}n[C]++}}}delete r.component.axes[I]}if(i.axis[I]==="independent"&&g[I]&&g[I].length>1)for(const r of g[I])r.get("grid")&&!r.explicit.grid&&(r.implicit.grid=!1)}}function jri(e,g){if(e){if(e.length!==g.length)return;const i=e.length;for(let n=0;ni.clone());return e}function $ri(e,g){for(const i of _at){const n=Vm(e.getWithExplicit(i),g.getWithExplicit(i),i,"axis",(I,r)=>{switch(i){case"title":return aot(I,r);case"gridScale":return{explicit:I.explicit,value:CI(I.value,r.value)}}return vJ(I,r,i,"axis")});e.setWithExplicit(i,n)}return e}function qri(e,g,i,n,I){if(g==="disable")return i!==void 0;switch(i=i||{},g){case"titleAngle":case"labelAngle":return e===(Qt(i.labelAngle)?i.labelAngle:j9(i.labelAngle));case"values":return!!i.values;case"encode":return!!i.encoding||!!i.labelAngle;case"title":if(e===sat(n,I))return!0}return e===i[g]}const eoi=new Set(["grid","translate","format","formatType","orient","labelExpr","tickCount","position","tickMinStep"]);function toi(e,g){let i=g.axis(e);const n=new cme,I=ZI(g.encoding[e]),{mark:r,config:o}=g,C=i?.orient||o[e==="x"?"axisX":"axisY"]?.orient||o.axis?.orient||Dni(e),a=g.getScaleComponent(e).get("type"),A=Nni(e,a,C,g.config),s=i!==void 0?!i:XIe("disable",o.style,i?.style,A).configValue;if(n.set("disable",s,i!==void 0),s)return n;i=i||{};const l=xni(I,i,e,o.style,A),c=Dot(i.formatType,I,a),u=Eot(I,I.type,i.format,i.formatType,o,!0),d={fieldOrDatumDef:I,axis:i,channel:e,model:g,scaleType:a,orient:C,labelAngle:l,format:u,formatType:c,mark:r,config:o};for(const m of _at){const b=m in dYe?dYe[m](d):Oke(m)?i[m]:void 0,p=b!==void 0,y=qri(b,m,i,g,e);if(p&&y)n.set(m,b,y);else{const{configValue:Z=void 0,configFrom:v=void 0}=Oke(m)&&m!=="values"?XIe(m,o.style,i.style,A):{},G=Z!==void 0;p&&!G?n.set(m,b,y):(v!=="vgAxisConfig"||eoi.has(m)&&G||cN(Z)||Qt(Z))&&n.set(m,Z,!1)}}const h=i.encoding??{},f=tCt.reduce((m,b)=>{if(!n.hasAxisPart(b))return m;const p=hat(h[b]??{},g),y=b==="labels"?Jri(g,e,p):p;return y!==void 0&&!Ri(y)&&(m[b]={update:y}),m},{});return Ri(f)||n.set("encode",f,!!i.encoding||i.labelAngle!==void 0),n}function goi({encoding:e,size:g}){for(const i of au){const n=FC(i);zc(g[n])&&Kf(e[i])&&(delete g[n],ut(uot(n)))}return g}function ioi(e,g,i){const n=hC(e),I=di("orient",n,i);if(n.orient=ooi(n.type,g,I),I!==void 0&&I!==n.orient&&ut(wei(n.orient,I)),n.type==="bar"&&n.orient){const C=di("cornerRadiusEnd",n,i);if(C!==void 0){const a=n.orient==="horizontal"&&g.x2||n.orient==="vertical"&&g.y2?["cornerRadius"]:Pti[n.orient];for(const A of a)n[A]=C;n.cornerRadiusEnd!==void 0&&delete n.cornerRadiusEnd}}return di("opacity",n,i)===void 0&&(n.opacity=Ioi(n.type,g)),di("cursor",n,i)===void 0&&(n.cursor=noi(n,g,i)),n}function noi(e,g,i){return g.href||e.href||di("href",e,i)?"pointer":e.cursor}function Ioi(e,g){if(Eg([cJ,vfe,Bfe,wfe],e)&&!Yfe(g))return .7}function roi(e,g,{graticule:i}){if(i)return!1;const n=vy("filled",e,g),I=e.type;return CI(n,I!==cJ&&I!==lJ&&I!==f3)}function ooi(e,g,i){switch(e){case cJ:case Bfe:case wfe:case Hot:case Nti:case Hti:return}const{x:n,y:I,x2:r,y2:o}=g;switch(e){case AJ:if(dt(n)&&(or(n.bin)||dt(I)&&I.aggregate&&!n.aggregate))return"vertical";if(dt(I)&&(or(I.bin)||dt(n)&&n.aggregate&&!I.aggregate))return"horizontal";if(o||r){if(i)return i;if(!r)return(dt(n)&&n.type===wy&&!Ji(n.bin)||p3(n))&&dt(I)&&or(I.bin)?"horizontal":"vertical";if(!o)return(dt(I)&&I.type===wy&&!Ji(I.bin)||p3(I))&&dt(n)&&or(n.bin)?"vertical":"horizontal"}case f3:if(r&&!(dt(n)&&or(n.bin))&&o&&!(dt(I)&&or(I.bin)))return;case sJ:if(o)return dt(I)&&or(I.bin)?"horizontal":"vertical";if(r)return dt(n)&&or(n.bin)?"vertical":"horizontal";if(e===f3){if(n&&!I)return"vertical";if(I&&!n)return"horizontal"}case lJ:case vfe:{const C=Pke(n),a=Pke(I);if(i)return i;if(C&&!a)return e!=="tick"?"horizontal":"vertical";if(!C&&a)return e!=="tick"?"vertical":"horizontal";if(C&&a)return"vertical";{const A=Po(n)&&n.type===r1,s=Po(I)&&I.type===r1;if(A&&!s)return"vertical";if(!A&&s)return"horizontal"}return}}return"vertical"}const Coi={vgMark:"arc",encodeEntry:e=>({...ws(e,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"}),...Jr("x",e,{defaultPos:"mid"}),...Jr("y",e,{defaultPos:"mid"}),...Wm(e,"radius"),...Wm(e,"theta")})},aoi={vgMark:"area",encodeEntry:e=>({...ws(e,{align:"ignore",baseline:"ignore",color:"include",orient:"include",size:"ignore",theta:"ignore"}),...w3("x",e,{defaultPos:"zeroOrMin",defaultPos2:"zeroOrMin",range:e.markDef.orient==="horizontal"}),...w3("y",e,{defaultPos:"zeroOrMin",defaultPos2:"zeroOrMin",range:e.markDef.orient==="vertical"}),...qfe(e)})},soi={vgMark:"rect",encodeEntry:e=>({...ws(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...Wm(e,"x"),...Wm(e,"y")})},Aoi={vgMark:"shape",encodeEntry:e=>({...ws(e,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"})}),postEncodingTransform:e=>{const{encoding:g}=e,i=g.shape;return[{type:"geoshape",projection:e.projectionName(),...i&&dt(i)&&i.type===RS?{field:Bt(i,{expr:"datum"})}:{}}]}},loi={vgMark:"image",encodeEntry:e=>({...ws(e,{align:"ignore",baseline:"ignore",color:"ignore",orient:"ignore",size:"ignore",theta:"ignore"}),...Wm(e,"x"),...Wm(e,"y"),...jfe(e,"url")})},coi={vgMark:"line",encodeEntry:e=>({...ws(e,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"}),...Jr("x",e,{defaultPos:"mid"}),...Jr("y",e,{defaultPos:"mid"}),...xI("size",e,{vgChannel:"strokeWidth"}),...qfe(e)})},uoi={vgMark:"trail",encodeEntry:e=>({...ws(e,{align:"ignore",baseline:"ignore",color:"include",size:"include",orient:"ignore",theta:"ignore"}),...Jr("x",e,{defaultPos:"mid"}),...Jr("y",e,{defaultPos:"mid"}),...xI("size",e),...qfe(e)})};function ume(e,g){const{config:i}=e;return{...ws(e,{align:"ignore",baseline:"ignore",color:"include",size:"include",orient:"ignore",theta:"ignore"}),...Jr("x",e,{defaultPos:"mid"}),...Jr("y",e,{defaultPos:"mid"}),...xI("size",e),...xI("angle",e),...doi(e,i,g)}}function doi(e,g,i){return i?{shape:{value:i}}:xI("shape",e)}const hoi={vgMark:"symbol",encodeEntry:e=>ume(e)},foi={vgMark:"symbol",encodeEntry:e=>ume(e,"circle")},moi={vgMark:"symbol",encodeEntry:e=>ume(e,"square")},poi={vgMark:"rect",encodeEntry:e=>({...ws(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...Wm(e,"x"),...Wm(e,"y")})},boi={vgMark:"rule",encodeEntry:e=>{const{markDef:g}=e,i=g.orient;return!e.encoding.x&&!e.encoding.y&&!e.encoding.latitude&&!e.encoding.longitude?{}:{...ws(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...w3("x",e,{defaultPos:i==="horizontal"?"zeroOrMax":"mid",defaultPos2:"zeroOrMin",range:i!=="vertical"}),...w3("y",e,{defaultPos:i==="vertical"?"zeroOrMax":"mid",defaultPos2:"zeroOrMin",range:i!=="horizontal"}),...xI("size",e,{vgChannel:"strokeWidth"})}}},yoi={vgMark:"text",encodeEntry:e=>{const{config:g,encoding:i}=e;return{...ws(e,{align:"include",baseline:"include",color:"include",size:"ignore",orient:"ignore",theta:"include"}),...Jr("x",e,{defaultPos:"mid"}),...Jr("y",e,{defaultPos:"mid"}),...jfe(e),...xI("size",e,{vgChannel:"fontSize"}),...xI("angle",e),...AYe("align",Zoi(e.markDef,i,g)),...AYe("baseline",Goi(e.markDef,i,g)),...Jr("radius",e,{defaultPos:null}),...Jr("theta",e,{defaultPos:null})}}};function Zoi(e,g,i){if(di("align",e,i)===void 0)return"center"}function Goi(e,g,i){if(di("baseline",e,i)===void 0)return"middle"}const voi={vgMark:"rect",encodeEntry:e=>{const{config:g,markDef:i}=e,n=i.orient,I=n==="horizontal"?"width":"height",r=n==="horizontal"?"height":"width";return{...ws(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...Jr("x",e,{defaultPos:"mid",vgChannel:"xc"}),...Jr("y",e,{defaultPos:"mid",vgChannel:"yc"}),...xI("size",e,{defaultValue:Boi(e),vgChannel:I}),[r]:nn(di("thickness",i,g))}}};function Boi(e){const{config:g,markDef:i}=e,{orient:n}=i,I=n==="horizontal"?"width":"height",r=e.getScaleComponent(n==="horizontal"?"x":"y"),o=di("size",i,g,{vgChannel:I})??g.tick.bandSize;if(o!==void 0)return o;{const C=r?r.get("range"):void 0;return C&&dp(C)&&Vi(C.step)?C.step*3/4:v3(g.view,I)*3/4}}const AK={arc:Coi,area:aoi,bar:soi,circle:foi,geoshape:Aoi,image:loi,line:coi,point:hoi,rect:poi,rule:boi,square:moi,text:yoi,tick:voi,trail:uoi};function woi(e){if(Eg([lJ,sJ,kti],e.mark)){const g=rCt(e.mark,e.encoding);if(g.length>0)return Soi(e,g)}else if(e.mark===AJ){const g=mIe.some(i=>di(i,e.markDef,e.config));if(e.stack&&!e.fieldDef("size")&&g)return Roi(e)}return dme(e)}const XYe="faceted_path_";function Soi(e,g){return[{name:e.getName("pathgroup"),type:"group",from:{facet:{name:XYe+e.requestDataName(zi.Main),data:e.requestDataName(zi.Main),groupby:g}},encode:{update:{width:{field:{group:"width"}},height:{field:{group:"height"}}}},marks:dme(e,{fromPrefix:XYe})}]}const TYe="stack_group_";function Roi(e){const[g]=dme(e,{fromPrefix:TYe}),i=e.scaleName(e.stack.fieldChannel),n=(A={})=>e.vgField(e.stack.fieldChannel,A),I=(A,s)=>{const l=[n({prefix:"min",suffix:"start",expr:s}),n({prefix:"max",suffix:"start",expr:s}),n({prefix:"min",suffix:"end",expr:s}),n({prefix:"max",suffix:"end",expr:s})];return`${A}(${l.map(c=>`scale('${i}',${c})`).join(",")})`};let r,o;e.stack.fieldChannel==="x"?(r={...i1(g.encode.update,["y","yc","y2","height",...mIe]),x:{signal:I("min","datum")},x2:{signal:I("max","datum")},clip:{value:!0}},o={x:{field:{group:"x"},mult:-1},height:{field:{group:"height"}}},g.encode.update={...WC(g.encode.update,["y","yc","y2"]),height:{field:{group:"height"}}}):(r={...i1(g.encode.update,["x","xc","x2","width"]),y:{signal:I("min","datum")},y2:{signal:I("max","datum")},clip:{value:!0}},o={y:{field:{group:"y"},mult:-1},width:{field:{group:"width"}}},g.encode.update={...WC(g.encode.update,["x","xc","x2"]),width:{field:{group:"width"}}});for(const A of mIe){const s=vy(A,e.markDef,e.config);g.encode.update[A]?(r[A]=g.encode.update[A],delete g.encode.update[A]):s&&(r[A]=nn(s)),s&&(g.encode.update[A]={value:0})}const C=[];if(e.stack.groupbyChannels?.length>0)for(const A of e.stack.groupbyChannels){const s=e.fieldDef(A),l=Bt(s);l&&C.push(l),(s?.bin||s?.timeUnit)&&C.push(Bt(s,{binSuffix:"end"}))}return r=["stroke","strokeWidth","strokeJoin","strokeCap","strokeDash","strokeDashOffset","strokeMiterLimit","strokeOpacity"].reduce((A,s)=>{if(g.encode.update[s])return{...A,[s]:g.encode.update[s]};{const l=vy(s,e.markDef,e.config);return l!==void 0?{...A,[s]:nn(l)}:A}},r),r.stroke&&(r.strokeForeground={value:!0},r.strokeOffset={value:0}),[{type:"group",from:{facet:{data:e.requestDataName(zi.Main),name:TYe+e.requestDataName(zi.Main),groupby:C,aggregate:{fields:[n({suffix:"start"}),n({suffix:"start"}),n({suffix:"end"}),n({suffix:"end"})],ops:["min","max","min","max"]}}},encode:{update:r},marks:[{type:"group",encode:{update:o},marks:[g]}]}]}function Voi(e){const{encoding:g,stack:i,mark:n,markDef:I,config:r}=e,o=g.order;if(!(!et(o)&&QA(o)&&hIe(o.value)||!o&&hIe(di("order",I,r)))){if((et(o)||dt(o))&&!i)return rot(o,{expr:"datum"});if(hp(n)){const C=I.orient==="horizontal"?"y":"x",a=g[C];if(dt(a)){const A=a.sort;if(et(A))return{field:Bt(a,{prefix:C,suffix:"sort_index",expr:"datum"})};if(yc(A))return{field:Bt({aggregate:Yfe(e.encoding)?A.op:void 0,field:A.field},{expr:"datum"})};if(zot(A)){const s=e.fieldDef(A.encoding);return{field:Bt(s,{expr:"datum"}),order:A.order}}else return A===null?void 0:{field:Bt(a,{binSuffix:e.stack?.impute?"mid":void 0,expr:"datum"})}}return}}}function dme(e,g={fromPrefix:""}){const{mark:i,markDef:n,encoding:I,config:r}=e,o=CI(n.clip,Woi(e),Xoi(e)),C=not(n),a=I.key,A=Voi(e),s=Toi(e),l=di("aria",n,r),c=AK[i].postEncodingTransform?AK[i].postEncodingTransform(e):null;return[{name:e.getName("marks"),type:AK[i].vgMark,...o?{clip:!0}:{},...C?{style:C}:{},...a?{key:a.field}:{},...A?{sort:A}:{},...s||{},...l===!1?{aria:l}:{},from:{data:g.fromPrefix+e.requestDataName(zi.Main)},encode:{update:AK[i].encodeEntry(e)},...c?{transform:c}:{}}]}function Woi(e){const g=e.getScaleComponent("x"),i=e.getScaleComponent("y");return g?.get("selectionExtent")||i?.get("selectionExtent")?!0:void 0}function Xoi(e){const g=e.component.projection;return g&&!g.isFit?!0:void 0}function Toi(e){if(!e.component.selection)return null;const g=At(e.component.selection).length;let i=g,n=e.parent;for(;n&&i===0;)i=At(n.component.selection).length,n=n.parent;return i?{interactive:g>0||e.mark==="geoshape"||!!e.encoding.tooltip}:null}class Oat extends Dat{constructor(g,i,n,I={},r){super(g,"unit",i,n,r,void 0,Lke(g)?g.view:void 0),this.specifiedScales={},this.specifiedAxes={},this.specifiedLegends={},this.specifiedProjection={},this.selection=[],this.children=[];const o=Dc(g.mark)?{...g.mark}:{type:g.mark},C=o.type;o.filled===void 0&&(o.filled=roi(o,r,{graticule:g.data&&Ufe(g.data)}));const a=this.encoding=bgi(g.encoding||{},C,o.filled,r);this.markDef=ioi(o,a,r),this.size=goi({encoding:a,size:Lke(g)?{...I,...g.width?{width:g.width}:{},...g.height?{height:g.height}:{}}:I}),this.stack=wCt(this.markDef,a),this.specifiedScales=this.initScales(C,a),this.specifiedAxes=this.initAxes(a),this.specifiedLegends=this.initLegends(a),this.specifiedProjection=g.projection,this.selection=(g.params??[]).filter(A=>Pfe(A))}get hasProjection(){const{encoding:g}=this,i=this.mark===Not,n=g&&bqg.some(I=>fg(g[I]));return i||n}scaleDomain(g){const i=this.specifiedScales[g];return i?i.domain:void 0}axis(g){return this.specifiedAxes[g]}legend(g){return this.specifiedLegends[g]}initScales(g,i){return rJ.reduce((n,I)=>{const r=ZI(i[I]);return r&&(n[I]=this.initScale(r.scale??{})),n},{})}initScale(g){const{domain:i,range:n}=g,I=hC(g);return et(i)&&(I.domain=i.map(Ca)),et(n)&&(I.range=n.map(Ca)),I}initAxes(g){return au.reduce((i,n)=>{const I=g[n];if(fg(I)||n===hn&&fg(g.x2)||n===JI&&fg(g.y2)){const r=fg(I)?I.axis:void 0;i[n]=r&&this.initAxis({...r})}return i},{})}initAxis(g){const i=At(g),n={};for(const I of i){const r=g[I];n[I]=cN(r)?iot(r):Ca(r)}return n}initLegends(g){return Vqg.reduce((i,n)=>{const I=ZI(g[n]);if(I&&Xqg(n)){const r=I.legend;i[n]=r&&hC(r)}return i},{})}parseData(){this.component.data=xJ(this)}parseLayoutSize(){Fri(this)}parseSelections(){this.component.selection=Wni(this,this.selection)}parseMarkGroup(){this.component.mark=woi(this)}parseAxesAndHeaders(){this.component.axes=Lri(this)}assembleSelectionTopLevelSignals(g){return $ii(this,g)}assembleSignals(){return[...oat(this),...Qii(this,[])]}assembleSelectionData(g){return qii(this,g)}assembleLayout(){return null}assembleLayoutSignals(){return ime(this)}assembleMarks(){let g=this.component.mark??[];return(!this.parent||!HS(this.parent))&&(g=FCt(this,g)),g.map(this.correctDataNames)}assembleGroupStyle(){const{style:g}=this.view||{};return g!==void 0?g:this.encoding.x||this.encoding.y?"cell":"view"}getMapping(){return this.encoding}get mark(){return this.markDef.type}channelHasField(g){return ab(this.encoding,g)}fieldDef(g){const i=this.encoding[g];return Mc(i)}typedFieldDef(g){const i=this.fieldDef(g);return Po(i)?i:null}}class hme extends Ame{constructor(g,i,n,I,r){super(g,"layer",i,n,r,g.resolve,g.view);const o={...I,...g.width?{width:g.width}:{},...g.height?{height:g.height}:{}};this.children=g.layer.map((C,a)=>{if(GJ(C))return new hme(C,this,this.getName(`layer_${a}`),o,r);if(dh(C))return new Oat(C,this,this.getName(`layer_${a}`),o,r);throw new Error(afe(C))})}parseData(){this.component.data=xJ(this);for(const g of this.children)g.parseData()}parseLayoutSize(){Kri(this)}parseSelections(){this.component.selection={};for(const g of this.children){g.parseSelections();for(const i of At(g.component.selection))this.component.selection[i]=g.component.selection[i]}}parseMarkGroup(){for(const g of this.children)g.parseMarkGroup()}parseAxesAndHeaders(){Qri(this)}assembleSelectionTopLevelSignals(g){return this.children.reduce((i,n)=>n.assembleSelectionTopLevelSignals(i),g)}assembleSignals(){return this.children.reduce((g,i)=>g.concat(i.assembleSignals()),oat(this))}assembleLayoutSignals(){return this.children.reduce((g,i)=>g.concat(i.assembleLayoutSignals()),ime(this))}assembleSelectionData(g){return this.children.reduce((i,n)=>n.assembleSelectionData(i),g)}assembleGroupStyle(){const g=new Set;for(const n of this.children)for(const I of Vt(n.assembleGroupStyle()))g.add(I);const i=Array.from(g);return i.length>1?i:i.length===1?i[0]:void 0}assembleTitle(){let g=super.assembleTitle();if(g)return g;for(const i of this.children)if(g=i.assembleTitle(),g)return g}assembleLayout(){return null}assembleMarks(){return eni(this,this.children.flatMap(g=>g.assembleMarks()))}assembleLegends(){return this.children.reduce((g,i)=>g.concat(i.assembleLegends()),vat(this))}}function fme(e,g,i,n,I){if(dJ(e))return new OW(e,g,i,I);if(GJ(e))return new hme(e,g,i,n,I);if(dh(e))return new Oat(e,g,i,n,I);if(Pgi(e))return new Pri(e,g,i,I);throw new Error(afe(e))}function Hoi(e,g={}){g.logger&&jei(g.logger),g.fieldTitle&&$ot(g.fieldTitle);try{const i=BCt(AS(g.config,e.config)),n=HCt(e,i),I=fme(n,null,"",void 0,i);return I.parse(),$Ii(I.component.data,I),{spec:koi(I,Noi(e,n.autosize,i,I),e.datasets,e.usermeta),normalized:n}}finally{g.logger&&$ei(),g.fieldTitle&&Agi()}}function Noi(e,g,i,n){const I=n.component.layoutSize.get("width"),r=n.component.layoutSize.get("height");if(g===void 0?(g={type:"pad"},n.hasAxisOrientSignalRef()&&(g.resize=!0)):Rt(g)&&(g={type:g}),I&&r&&Oii(g.type)){if(I==="step"&&r==="step")ut(Tke()),g.type="pad";else if(I==="step"||r==="step"){const o=I==="step"?"width":"height";ut(Tke(IJ(o)));const C=o==="width"?"height":"width";g.type=Jii(C)}}return{...At(g).length===1&&g.type?g.type==="pad"?{}:{autosize:g.type}:{autosize:g},...rYe(i,!1),...rYe(e,!0)}}function koi(e,g,i={},n){const I=e.config?nii(e.config):void 0,r=[].concat(e.assembleSelectionData([]),Hri(e.component.data,i)),o=e.assembleProjections(),C=e.assembleTitle(),a=e.assembleGroupStyle(),A=e.assembleGroupEncodeEntry(!0);let s=e.assembleLayoutSignals();s=s.filter(u=>(u.name==="width"||u.name==="height")&&u.value!==void 0?(g[u.name]=+u.value,!1):!0);const{params:l,...c}=g;return{$schema:"https://vega.github.io/schema/vega/v5.json",...e.description?{description:e.description}:{},...c,...C?{title:C}:{},...a?{style:a}:{},...A?{encode:{update:A}}:{},data:r,...o.length>0?{projections:o}:{},...e.assembleGroup([...s,...e.assembleSelectionTopLevelSignals([]),...yCt(l)]),...I?{config:I}:{},...n?{usermeta:n}:{}}}const Yoi=sqg.version,Koi=Object.freeze(Object.defineProperty({__proto__:null,accessPathDepth:n1,accessPathWithDatum:qhe,compile:Hoi,contains:Eg,deepEqual:nc,deleteNestedProperty:u3,duplicate:mg,entries:Sm,every:Qhe,fieldIntersection:$he,flatAccessWithDatum:Yrt,getFirstDefined:CI,hasIntersection:jhe,hash:$g,internalField:Frt,isBoolean:Q9,isEmpty:Ri,isEqual:hqg,isInternalField:Ert,isNullOrFalse:hIe,isNumeric:qO,keys:At,logicalExpr:PW,mergeDeep:Nrt,never:Hrt,normalize:HCt,normalizeAngle:j9,omit:WC,pick:i1,prefixGenerator:fIe,removePathFromField:efe,replaceAll:Zy,replacePathInField:ys,resetIdCounter:mqg,setEqual:krt,some:yy,stringify:Oi,titleCase:iN,unique:Ic,uniqueId:xrt,vals:fr,varName:dn,version:Yoi},Symbol.toStringTag,{value:"Module"}));function Jat(e){const[g,i]=/schema\/([\w-]+)\/([\w\.\-]+)\.json$/g.exec(e).slice(1,3);return{library:g,version:i}}var xoi="vega-themes",Foi="2.13.0",Eoi="Themes for stylized Vega and Vega-Lite visualizations.",Doi=["vega","vega-lite","themes","style"],Moi="BSD-3-Clause",zoi={name:"UW Interactive Data Lab",url:"https://idl.cs.washington.edu"},Poi=[{name:"Emily Gu",url:"https://github.com/emilygu"},{name:"Arvind Satyanarayan",url:"http://arvindsatya.com"},{name:"Jeffrey Heer",url:"https://idl.cs.washington.edu"},{name:"Dominik Moritz",url:"https://www.domoritz.de"}],_oi="build/vega-themes.js",Ooi="build/vega-themes.module.js",Joi="build/vega-themes.min.js",Loi="build/vega-themes.min.js",Uoi="build/vega-themes.module.d.ts",Qoi={type:"git",url:"https://github.com/vega/vega-themes.git"},joi=["src","build"],$oi={prebuild:"yarn clean",build:"rollup -c",clean:"rimraf build && rimraf examples/build","copy:data":"rsync -r node_modules/vega-datasets/data/* examples/data","copy:build":"rsync -r build/* examples/build","deploy:gh":"yarn build && mkdir -p examples/build && rsync -r build/* examples/build && gh-pages -d examples",preversion:"yarn lint",serve:"browser-sync start -s -f build examples --serveStatic examples",start:"yarn build && concurrently --kill-others -n Server,Rollup 'yarn serve' 'rollup -c -w'",format:"eslint . --fix",lint:"eslint .",release:"release-it"},qoi={"@babel/core":"^7.21.4","@babel/plugin-transform-runtime":"^7.21.4","@babel/preset-env":"^7.21.4","@babel/preset-typescript":"^7.21.4","@release-it/conventional-changelog":"^5.1.1","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.0.2","@rollup/plugin-terser":"^0.4.1","@typescript-eslint/eslint-plugin":"^5.59.0","@typescript-eslint/parser":"^5.59.0","browser-sync":"^2.29.1",concurrently:"^8.0.1",eslint:"^8.38.0","eslint-config-prettier":"^8.8.0","eslint-plugin-prettier":"^4.2.1","gh-pages":"^5.0.0",prettier:"^2.8.7","release-it":"^15.10.1",rollup:"^3.20.6","rollup-plugin-bundle-size":"^1.0.3","rollup-plugin-ts":"^3.2.0",typescript:"^5.0.4",vega:"^5.24.0","vega-lite":"^5.7.1"},eCi={vega:"*","vega-lite":"*"},tCi={},gCi={name:xoi,version:Foi,description:Eoi,keywords:Doi,license:Moi,author:zoi,contributors:Poi,main:_oi,module:Ooi,unpkg:Joi,jsdelivr:Loi,types:Uoi,repository:Qoi,files:joi,scripts:$oi,devDependencies:qoi,peerDependencies:eCi,dependencies:tCi};const GG="#fff",HYe="#888",iCi={background:"#333",view:{stroke:HYe},title:{color:GG,subtitleColor:GG},style:{"guide-label":{fill:GG},"guide-title":{fill:GG}},axis:{domainColor:GG,gridColor:HYe,tickColor:GG}},Fp="#4572a7",nCi={background:"#fff",arc:{fill:Fp},area:{fill:Fp},line:{stroke:Fp,strokeWidth:2},path:{stroke:Fp},rect:{fill:Fp},shape:{stroke:Fp},symbol:{fill:Fp,strokeWidth:1.5,size:50},axis:{bandPosition:.5,grid:!0,gridColor:"#000000",gridOpacity:1,gridWidth:.5,labelPadding:10,tickSize:5,tickWidth:.5},axisBand:{grid:!1,tickExtra:!0},legend:{labelBaseline:"middle",labelFontSize:11,symbolSize:50,symbolType:"square"},range:{category:["#4572a7","#aa4643","#8aa453","#71598e","#4598ae","#d98445","#94aace","#d09393","#b9cc98","#a99cbc"]}},Ep="#30a2da",U4="#cbcbcb",ICi="#999",rCi="#333",NYe="#f0f0f0",kYe="#333",oCi={arc:{fill:Ep},area:{fill:Ep},axis:{domainColor:U4,grid:!0,gridColor:U4,gridWidth:1,labelColor:ICi,labelFontSize:10,titleColor:rCi,tickColor:U4,tickSize:10,titleFontSize:14,titlePadding:10,labelPadding:4},axisBand:{grid:!1},background:NYe,group:{fill:NYe},legend:{labelColor:kYe,labelFontSize:11,padding:1,symbolSize:30,symbolType:"square",titleColor:kYe,titleFontSize:14,titlePadding:10},line:{stroke:Ep,strokeWidth:2},path:{stroke:Ep,strokeWidth:.5},rect:{fill:Ep},range:{category:["#30a2da","#fc4f30","#e5ae38","#6d904f","#8b8b8b","#b96db8","#ff9e27","#56cc60","#52d2ca","#52689e","#545454","#9fe4f8"],diverging:["#cc0020","#e77866","#f6e7e1","#d6e8ed","#91bfd9","#1d78b5"],heatmap:["#d6e8ed","#cee0e5","#91bfd9","#549cc6","#1d78b5"]},point:{filled:!0,shape:"circle"},shape:{stroke:Ep},bar:{binSpacing:2,fill:Ep,stroke:null},title:{anchor:"start",fontSize:24,fontWeight:600,offset:20}},Dp="#000",CCi={group:{fill:"#e5e5e5"},arc:{fill:Dp},area:{fill:Dp},line:{stroke:Dp},path:{stroke:Dp},rect:{fill:Dp},shape:{stroke:Dp},symbol:{fill:Dp,size:40},axis:{domain:!1,grid:!0,gridColor:"#FFFFFF",gridOpacity:1,labelColor:"#7F7F7F",labelPadding:4,tickColor:"#7F7F7F",tickSize:5.67,titleFontSize:16,titleFontWeight:"normal"},legend:{labelBaseline:"middle",labelFontSize:11,symbolSize:40},range:{category:["#000000","#7F7F7F","#1A1A1A","#999999","#333333","#B0B0B0","#4D4D4D","#C9C9C9","#666666","#DCDCDC"]}},aCi=22,sCi="normal",YYe="Benton Gothic, sans-serif",KYe=11.5,ACi="normal",Mp="#82c6df",Q4="Benton Gothic Bold, sans-serif",xYe="normal",FYe=13,oV={"category-6":["#ec8431","#829eb1","#c89d29","#3580b1","#adc839","#ab7fb4"],"fire-7":["#fbf2c7","#f9e39c","#f8d36e","#f4bb6a","#e68a4f","#d15a40","#ab4232"],"fireandice-6":["#e68a4f","#f4bb6a","#f9e39c","#dadfe2","#a6b7c6","#849eae"],"ice-7":["#edefee","#dadfe2","#c4ccd2","#a6b7c6","#849eae","#607785","#47525d"]},lCi={background:"#ffffff",title:{anchor:"start",color:"#000000",font:Q4,fontSize:aCi,fontWeight:sCi},arc:{fill:Mp},area:{fill:Mp},line:{stroke:Mp,strokeWidth:2},path:{stroke:Mp},rect:{fill:Mp},shape:{stroke:Mp},symbol:{fill:Mp,size:30},axis:{labelFont:YYe,labelFontSize:KYe,labelFontWeight:ACi,titleFont:Q4,titleFontSize:FYe,titleFontWeight:xYe},axisX:{labelAngle:0,labelPadding:4,tickSize:3},axisY:{labelBaseline:"middle",maxExtent:45,minExtent:45,tickSize:2,titleAlign:"left",titleAngle:0,titleX:-45,titleY:-11},legend:{labelFont:YYe,labelFontSize:KYe,symbolType:"square",titleFont:Q4,titleFontSize:FYe,titleFontWeight:xYe},range:{category:oV["category-6"],diverging:oV["fireandice-6"],heatmap:oV["fire-7"],ordinal:oV["fire-7"],ramp:oV["fire-7"]}},zp="#ab5787",lK="#979797",cCi={background:"#f9f9f9",arc:{fill:zp},area:{fill:zp},line:{stroke:zp},path:{stroke:zp},rect:{fill:zp},shape:{stroke:zp},symbol:{fill:zp,size:30},axis:{domainColor:lK,domainWidth:.5,gridWidth:.2,labelColor:lK,tickColor:lK,tickWidth:.2,titleColor:lK},axisBand:{grid:!1},axisX:{grid:!0,tickSize:10},axisY:{domain:!1,grid:!0,tickSize:0},legend:{labelFontSize:11,padding:1,symbolSize:30,symbolType:"square"},range:{category:["#ab5787","#51b2e5","#703c5c","#168dd9","#d190b6","#00609f","#d365ba","#154866","#666666","#c4c4c4"]}},Pp="#3e5c69",uCi={background:"#fff",arc:{fill:Pp},area:{fill:Pp},line:{stroke:Pp},path:{stroke:Pp},rect:{fill:Pp},shape:{stroke:Pp},symbol:{fill:Pp},axis:{domainWidth:.5,grid:!0,labelPadding:2,tickSize:5,tickWidth:.5,titleFontWeight:"normal"},axisBand:{grid:!1},axisX:{gridWidth:.2},axisY:{gridDash:[3],gridWidth:.4},legend:{labelFontSize:11,padding:1,symbolType:"square"},range:{category:["#3e5c69","#6793a6","#182429","#0570b0","#3690c0","#74a9cf","#a6bddb","#e2ddf2"]}},Ta="#1696d2",EYe="#000000",dCi="#FFFFFF",cK="Lato",j4="Lato",hCi="Lato",fCi="#DEDDDD",mCi=18,CV={"main-colors":["#1696d2","#d2d2d2","#000000","#fdbf11","#ec008b","#55b748","#5c5859","#db2b27"],"shades-blue":["#CFE8F3","#A2D4EC","#73BFE2","#46ABDB","#1696D2","#12719E","#0A4C6A","#062635"],"shades-gray":["#F5F5F5","#ECECEC","#E3E3E3","#DCDBDB","#D2D2D2","#9D9D9D","#696969","#353535"],"shades-yellow":["#FFF2CF","#FCE39E","#FDD870","#FCCB41","#FDBF11","#E88E2D","#CA5800","#843215"],"shades-magenta":["#F5CBDF","#EB99C2","#E46AA7","#E54096","#EC008B","#AF1F6B","#761548","#351123"],"shades-green":["#DCEDD9","#BCDEB4","#98CF90","#78C26D","#55B748","#408941","#2C5C2D","#1A2E19"],"shades-black":["#D5D5D4","#ADABAC","#848081","#5C5859","#332D2F","#262223","#1A1717","#0E0C0D"],"shades-red":["#F8D5D4","#F1AAA9","#E9807D","#E25552","#DB2B27","#A4201D","#6E1614","#370B0A"],"one-group":["#1696d2","#000000"],"two-groups-cat-1":["#1696d2","#000000"],"two-groups-cat-2":["#1696d2","#fdbf11"],"two-groups-cat-3":["#1696d2","#db2b27"],"two-groups-seq":["#a2d4ec","#1696d2"],"three-groups-cat":["#1696d2","#fdbf11","#000000"],"three-groups-seq":["#a2d4ec","#1696d2","#0a4c6a"],"four-groups-cat-1":["#000000","#d2d2d2","#fdbf11","#1696d2"],"four-groups-cat-2":["#1696d2","#ec0008b","#fdbf11","#5c5859"],"four-groups-seq":["#cfe8f3","#73bf42","#1696d2","#0a4c6a"],"five-groups-cat-1":["#1696d2","#fdbf11","#d2d2d2","#ec008b","#000000"],"five-groups-cat-2":["#1696d2","#0a4c6a","#d2d2d2","#fdbf11","#332d2f"],"five-groups-seq":["#cfe8f3","#73bf42","#1696d2","#0a4c6a","#000000"],"six-groups-cat-1":["#1696d2","#ec008b","#fdbf11","#000000","#d2d2d2","#55b748"],"six-groups-cat-2":["#1696d2","#d2d2d2","#ec008b","#fdbf11","#332d2f","#0a4c6a"],"six-groups-seq":["#cfe8f3","#a2d4ec","#73bfe2","#46abdb","#1696d2","#12719e"],"diverging-colors":["#ca5800","#fdbf11","#fdd870","#fff2cf","#cfe8f3","#73bfe2","#1696d2","#0a4c6a"]},pCi={background:dCi,title:{anchor:"start",fontSize:mCi,font:cK},axisX:{domain:!0,domainColor:EYe,domainWidth:1,grid:!1,labelFontSize:12,labelFont:j4,labelAngle:0,tickColor:EYe,tickSize:5,titleFontSize:12,titlePadding:10,titleFont:cK},axisY:{domain:!1,domainWidth:1,grid:!0,gridColor:fCi,gridWidth:1,labelFontSize:12,labelFont:j4,labelPadding:8,ticks:!1,titleFontSize:12,titlePadding:10,titleFont:cK,titleAngle:0,titleY:-10,titleX:18},legend:{labelFontSize:12,labelFont:j4,symbolSize:100,titleFontSize:12,titlePadding:10,titleFont:cK,orient:"right",offset:10},view:{stroke:"transparent"},range:{category:CV["six-groups-cat-1"],diverging:CV["diverging-colors"],heatmap:CV["diverging-colors"],ordinal:CV["six-groups-seq"],ramp:CV["shades-blue"]},area:{fill:Ta},rect:{fill:Ta},line:{color:Ta,stroke:Ta,strokeWidth:5},trail:{color:Ta,stroke:Ta,strokeWidth:0,size:1},path:{stroke:Ta,strokeWidth:.5},point:{filled:!0},text:{font:hCi,color:Ta,fontSize:11,align:"center",fontWeight:400,size:11},style:{bar:{fill:Ta,stroke:null}},arc:{fill:Ta},shape:{stroke:Ta},symbol:{fill:Ta,size:30}},_p="#3366CC",DYe="#ccc",uK="Arial, sans-serif",bCi={arc:{fill:_p},area:{fill:_p},path:{stroke:_p},rect:{fill:_p},shape:{stroke:_p},symbol:{stroke:_p},circle:{fill:_p},background:"#fff",padding:{top:10,right:10,bottom:10,left:10},style:{"guide-label":{font:uK,fontSize:12},"guide-title":{font:uK,fontSize:12},"group-title":{font:uK,fontSize:12}},title:{font:uK,fontSize:14,fontWeight:"bold",dy:-3,anchor:"start"},axis:{gridColor:DYe,tickColor:DYe,domain:!1,grid:!0},range:{category:["#4285F4","#DB4437","#F4B400","#0F9D58","#AB47BC","#00ACC1","#FF7043","#9E9D24","#5C6BC0","#F06292","#00796B","#C2185B"],heatmap:["#c6dafc","#5e97f6","#2a56c6"]}},mme=e=>e*(1/3+1),MYe=mme(9),zYe=mme(10),PYe=mme(12),aV="Segoe UI",_Ye="wf_standard-font, helvetica, arial, sans-serif",OYe="#252423",sV="#605E5C",JYe="transparent",yCi="#C8C6C4",qs="#118DFF",ZCi="#12239E",GCi="#E66C37",vCi="#6B007B",BCi="#E044A7",wCi="#744EC2",SCi="#D9B300",RCi="#D64550",Lat=qs,Uat="#DEEFFF",LYe=[Uat,Lat],VCi=[Uat,"#c7e4ff","#b0d9ff","#9aceff","#83c3ff","#6cb9ff","#55aeff","#3fa3ff","#2898ff",Lat],WCi={view:{stroke:JYe},background:JYe,font:aV,header:{titleFont:_Ye,titleFontSize:PYe,titleColor:OYe,labelFont:aV,labelFontSize:zYe,labelColor:sV},axis:{ticks:!1,grid:!1,domain:!1,labelColor:sV,labelFontSize:MYe,titleFont:_Ye,titleColor:OYe,titleFontSize:PYe,titleFontWeight:"normal"},axisQuantitative:{tickCount:3,grid:!0,gridColor:yCi,gridDash:[1,5],labelFlush:!1},axisBand:{tickExtra:!0},axisX:{labelPadding:5},axisY:{labelPadding:10},bar:{fill:qs},line:{stroke:qs,strokeWidth:3,strokeCap:"round",strokeJoin:"round"},text:{font:aV,fontSize:MYe,fill:sV},arc:{fill:qs},area:{fill:qs,line:!0,opacity:.6},path:{stroke:qs},rect:{fill:qs},point:{fill:qs,filled:!0,size:75},shape:{stroke:qs},symbol:{fill:qs,strokeWidth:1.5,size:50},legend:{titleFont:aV,titleFontWeight:"bold",titleColor:sV,labelFont:aV,labelFontSize:zYe,labelColor:sV,symbolType:"circle",symbolSize:75},range:{category:[qs,ZCi,GCi,vCi,BCi,wCi,SCi,RCi],diverging:LYe,heatmap:LYe,ordinal:VCi}},XCi=gCi.version,TCi=Object.freeze(Object.defineProperty({__proto__:null,dark:iCi,excel:nCi,fivethirtyeight:oCi,ggplot2:CCi,googlecharts:bCi,latimes:lCi,powerbi:WCi,quartz:cCi,urbaninstitute:pCi,version:XCi,vox:uCi},Symbol.toStringTag,{value:"Module"}));function iT(e){return iT=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(g){return typeof g}:function(g){return g&&typeof Symbol=="function"&&g.constructor===Symbol&&g!==Symbol.prototype?"symbol":typeof g},iT(e)}function HCi(e,g){if(iT(e)!=="object"||e===null)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var n=i.call(e,g||"default");if(iT(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(g==="string"?String:Number)(e)}function NCi(e){var g=HCi(e,"string");return iT(g)==="symbol"?g:String(g)}function kCi(e,g,i){return g=NCi(g),g in e?Object.defineProperty(e,g,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[g]=i,e}function YCi(e,g){if(e==null)return{};var i={},n=Object.keys(e),I,r;for(r=0;r=0)&&(i[I]=e[I]);return i}function KCi(e,g){if(e==null)return{};var i=YCi(e,g),n,I;if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(I=0;I=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}const xCi=["title","image"];function FCi(e,g,i){if(et(e))return`[${e.map(n=>g(Rt(n)?n:UYe(n,i))).join(", ")}]`;if(Wt(e)){let n="";const I=e,{title:r,image:o}=I,C=KCi(I,xCi);r&&(n+=`

${g(r)}

`),o&&(n+=``);const a=Object.keys(C);if(a.length>0){n+="";for(const A of a){let s=C[A];s!==void 0&&(Wt(s)&&(s=UYe(s,i)),n+=``)}n+="
${g(A)}:${g(s)}
"}return n||"{}"}return g(e)}function ECi(e){const g=[];return function(i,n){if(typeof n!="object"||n===null)return n;const I=g.indexOf(this)+1;return g.length=I,g.length>e?"[Object]":g.indexOf(n)>=0?"[Circular]":(g.push(n),n)}}function UYe(e,g){return JSON.stringify(e,ECi(g))}var DCi=`#vg-tooltip-element { + visibility: hidden; + padding: 8px; + position: fixed; + z-index: 1000; + font-family: sans-serif; + font-size: 11px; + border-radius: 3px; + box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1); + /* The default theme is the light theme. */ + background-color: rgba(255, 255, 255, 0.95); + border: 1px solid #d9d9d9; + color: black; +} +#vg-tooltip-element.visible { + visibility: visible; +} +#vg-tooltip-element h2 { + margin-top: 0; + margin-bottom: 10px; + font-size: 13px; +} +#vg-tooltip-element table { + border-spacing: 0; +} +#vg-tooltip-element table tr { + border: none; +} +#vg-tooltip-element table tr td { + overflow: hidden; + text-overflow: ellipsis; + padding-top: 2px; + padding-bottom: 2px; +} +#vg-tooltip-element table tr td.key { + color: #808080; + max-width: 150px; + text-align: right; + padding-right: 4px; +} +#vg-tooltip-element table tr td.value { + display: block; + max-width: 300px; + max-height: 7em; + text-align: left; +} +#vg-tooltip-element.dark-theme { + background-color: rgba(32, 32, 32, 0.9); + border: 1px solid #f5f5f5; + color: white; +} +#vg-tooltip-element.dark-theme td.key { + color: #bfbfbf; +} +`;const Qat="vg-tooltip-element",MCi={offsetX:10,offsetY:10,id:Qat,styleId:"vega-tooltip-style",theme:"light",disableDefaultStyle:!1,sanitize:zCi,maxDepth:2,formatTooltip:FCi};function zCi(e){return String(e).replace(/&/g,"&").replace(/window.innerWidth&&(I=+e.clientX-i-g.width);let r=e.clientY+n;return r+g.height>window.innerHeight&&(r=+e.clientY-n-g.height),{x:I,y:r}}function QYe(e,g){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);g&&(n=n.filter(function(I){return Object.getOwnPropertyDescriptor(e,I).enumerable})),i.push.apply(i,n)}return i}function jYe(e){for(var g=1;g0?I.insertBefore(n,I.childNodes[0]):I.appendChild(n)}}tooltipHandler(g,i,n,I){if(this.el=document.getElementById(this.options.id),this.el||(this.el=document.createElement("div"),this.el.setAttribute("id",this.options.id),this.el.classList.add("vg-tooltip"),(document.fullscreenElement??document.body).appendChild(this.el)),I==null||I===""){this.el.classList.remove("visible",`${this.options.theme}-theme`);return}this.el.innerHTML=this.options.formatTooltip(I,this.options.sanitize,this.options.maxDepth),this.el.classList.add("visible",`${this.options.theme}-theme`);const{x:r,y:o}=_Ci(i,this.el.getBoundingClientRect(),this.options.offsetX,this.options.offsetY);this.el.style.top=`${o}px`,this.el.style.left=`${r}px`}}function nT(e){return nT=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(g){return typeof g}:function(g){return g&&typeof Symbol=="function"&&g.constructor===Symbol&&g!==Symbol.prototype?"symbol":typeof g},nT(e)}function JCi(e,g){if(nT(e)!=="object"||e===null)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var n=i.call(e,g||"default");if(nT(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(g==="string"?String:Number)(e)}function LCi(e){var g=JCi(e,"string");return nT(g)==="symbol"?g:String(g)}function UCi(e,g,i){return g=LCi(g),g in e?Object.defineProperty(e,g,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[g]=i,e}function QCi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $4,$Ye;function jCi(){return $Ye||($Ye=1,$4=function(e){e.prototype[Symbol.iterator]=function*(){for(let g=this.head;g;g=g.next)yield g.value}}),$4}var $Ci=Ai;Ai.Node=Ty;Ai.create=Ai;function Ai(e){var g=this;if(g instanceof Ai||(g=new Ai),g.tail=null,g.head=null,g.length=0,e&&typeof e.forEach=="function")e.forEach(function(I){g.push(I)});else if(arguments.length>0)for(var i=0,n=arguments.length;i1)i=g;else if(this.head)n=this.head.next,i=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var I=0;n!==null;I++)i=e(i,n.value,I),n=n.next;return i};Ai.prototype.reduceReverse=function(e,g){var i,n=this.tail;if(arguments.length>1)i=g;else if(this.tail)n=this.tail.prev,i=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(var I=this.length-1;n!==null;I--)i=e(i,n.value,I),n=n.prev;return i};Ai.prototype.toArray=function(){for(var e=new Array(this.length),g=0,i=this.head;i!==null;g++)e[g]=i.value,i=i.next;return e};Ai.prototype.toArrayReverse=function(){for(var e=new Array(this.length),g=0,i=this.tail;i!==null;g++)e[g]=i.value,i=i.prev;return e};Ai.prototype.slice=function(e,g){g=g||this.length,g<0&&(g+=this.length),e=e||0,e<0&&(e+=this.length);var i=new Ai;if(gthis.length&&(g=this.length);for(var n=0,I=this.head;I!==null&&nthis.length&&(g=this.length);for(var n=this.length,I=this.tail;I!==null&&n>g;n--)I=I.prev;for(;I!==null&&n>e;n--,I=I.prev)i.push(I.value);return i};Ai.prototype.splice=function(e,g,...i){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var n=0,I=this.head;I!==null&&n1;class iai{constructor(g){if(typeof g=="number"&&(g={max:g}),g||(g={}),g.max&&(typeof g.max!="number"||g.max<0))throw new TypeError("max must be a non-negative number");this[d0]=g.max||1/0;const i=g.length||q4;if(this[vG]=typeof i!="function"?q4:i,this[JW]=g.stale||!1,g.maxAge&&typeof g.maxAge!="number")throw new TypeError("maxAge must be a number");this[K0]=g.maxAge||0,this[Tu]=g.dispose,this[qYe]=g.noDisposeOnSet||!1,this[jat]=g.updateAgeOnGet||!1,this.reset()}set max(g){if(typeof g!="number"||g<0)throw new TypeError("max must be a non-negative number");this[d0]=g||1/0,AV(this)}get max(){return this[d0]}set allowStale(g){this[JW]=!!g}get allowStale(){return this[JW]}set maxAge(g){if(typeof g!="number")throw new TypeError("maxAge must be a non-negative number");this[K0]=g,AV(this)}get maxAge(){return this[K0]}set lengthCalculator(g){typeof g!="function"&&(g=q4),g!==this[vG]&&(this[vG]=g,this[zu]=0,this[TI].forEach(i=>{i.length=this[vG](i.value,i.key),this[zu]+=i.length})),AV(this)}get lengthCalculator(){return this[vG]}get length(){return this[zu]}get itemCount(){return this[TI].length}rforEach(g,i){i=i||this;for(let n=this[TI].tail;n!==null;){const I=n.prev;eKe(this,g,n,i),n=I}}forEach(g,i){i=i||this;for(let n=this[TI].head;n!==null;){const I=n.next;eKe(this,g,n,i),n=I}}keys(){return this[TI].toArray().map(g=>g.key)}values(){return this[TI].toArray().map(g=>g.value)}reset(){this[Tu]&&this[TI]&&this[TI].length&&this[TI].forEach(g=>this[Tu](g.key,g.value)),this[tA]=new Map,this[TI]=new gai,this[zu]=0}dump(){return this[TI].map(g=>W3(this,g)?!1:{k:g.key,v:g.value,e:g.now+(g.maxAge||0)}).toArray().filter(g=>g)}dumpLru(){return this[TI]}set(g,i,n){if(n=n||this[K0],n&&typeof n!="number")throw new TypeError("maxAge must be a number");const I=n?Date.now():0,r=this[vG](i,g);if(this[tA].has(g)){if(r>this[d0])return ZB(this,this[tA].get(g)),!1;const a=this[tA].get(g).value;return this[Tu]&&(this[qYe]||this[Tu](g,a.value)),a.now=I,a.maxAge=n,a.value=i,this[zu]+=r-a.length,a.length=r,this.get(g),AV(this),!0}const o=new nai(g,i,r,I,n);return o.length>this[d0]?(this[Tu]&&this[Tu](g,i),!1):(this[zu]+=o.length,this[TI].unshift(o),this[tA].set(g,this[TI].head),AV(this),!0)}has(g){if(!this[tA].has(g))return!1;const i=this[tA].get(g).value;return!W3(this,i)}get(g){return e$(this,g,!0)}peek(g){return e$(this,g,!1)}pop(){const g=this[TI].tail;return g?(ZB(this,g),g.value):null}del(g){ZB(this,this[tA].get(g))}load(g){this.reset();const i=Date.now();for(let n=g.length-1;n>=0;n--){const I=g[n],r=I.e||0;if(r===0)this.set(I.k,I.v);else{const o=r-i;o>0&&this.set(I.k,I.v,o)}}}prune(){this[tA].forEach((g,i)=>e$(this,i,!1))}}const e$=(e,g,i)=>{const n=e[tA].get(g);if(n){const I=n.value;if(W3(e,I)){if(ZB(e,n),!e[JW])return}else i&&(e[jat]&&(n.value.now=Date.now()),e[TI].unshiftNode(n));return I.value}},W3=(e,g)=>{if(!g||!g.maxAge&&!e[K0])return!1;const i=Date.now()-g.now;return g.maxAge?i>g.maxAge:e[K0]&&i>e[K0]},AV=e=>{if(e[zu]>e[d0])for(let g=e[TI].tail;e[zu]>e[d0]&&g!==null;){const i=g.prev;ZB(e,g),g=i}},ZB=(e,g)=>{if(g){const i=g.value;e[Tu]&&e[Tu](i.key,i.value),e[zu]-=i.length,e[tA].delete(i.key),e[TI].removeNode(g)}};class nai{constructor(g,i,n,I,r){this.key=g,this.value=i,this.length=n,this.now=I,this.maxAge=r||0}}const eKe=(e,g,i,n)=>{let I=i.value;W3(e,I)&&(ZB(e,i),e[JW]||(I=void 0)),I&&g.call(n,I.value,I.key,e)};var Iai=iai;const rai=Object.freeze({loose:!0}),oai=Object.freeze({}),Cai=e=>e?typeof e!="object"?rai:e:oai;var pme=Cai,EIe={exports:{}};const aai="2.0.0",sai=256,Aai=Number.MAX_SAFE_INTEGER||9007199254740991,lai=16,cai=["major","premajor","minor","preminor","patch","prepatch","prerelease"];var bme={MAX_LENGTH:sai,MAX_SAFE_COMPONENT_LENGTH:lai,MAX_SAFE_INTEGER:Aai,RELEASE_TYPES:cai,SEMVER_SPEC_VERSION:aai,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2};const uai=typeof process=="object"&&process.env&&{}.NODE_DEBUG&&/\bsemver\b/i.test({}.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};var FJ=uai;(function(e,g){const{MAX_SAFE_COMPONENT_LENGTH:i}=bme,n=FJ;g=e.exports={};const I=g.re=[],r=g.src=[],o=g.t={};let C=0;const a=(A,s,l)=>{const c=C++;n(A,c,s),o[A]=c,r[c]=s,I[c]=new RegExp(s,l?"g":void 0)};a("NUMERICIDENTIFIER","0|[1-9]\\d*"),a("NUMERICIDENTIFIERLOOSE","[0-9]+"),a("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),a("MAINVERSION",`(${r[o.NUMERICIDENTIFIER]})\\.(${r[o.NUMERICIDENTIFIER]})\\.(${r[o.NUMERICIDENTIFIER]})`),a("MAINVERSIONLOOSE",`(${r[o.NUMERICIDENTIFIERLOOSE]})\\.(${r[o.NUMERICIDENTIFIERLOOSE]})\\.(${r[o.NUMERICIDENTIFIERLOOSE]})`),a("PRERELEASEIDENTIFIER",`(?:${r[o.NUMERICIDENTIFIER]}|${r[o.NONNUMERICIDENTIFIER]})`),a("PRERELEASEIDENTIFIERLOOSE",`(?:${r[o.NUMERICIDENTIFIERLOOSE]}|${r[o.NONNUMERICIDENTIFIER]})`),a("PRERELEASE",`(?:-(${r[o.PRERELEASEIDENTIFIER]}(?:\\.${r[o.PRERELEASEIDENTIFIER]})*))`),a("PRERELEASELOOSE",`(?:-?(${r[o.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${r[o.PRERELEASEIDENTIFIERLOOSE]})*))`),a("BUILDIDENTIFIER","[0-9A-Za-z-]+"),a("BUILD",`(?:\\+(${r[o.BUILDIDENTIFIER]}(?:\\.${r[o.BUILDIDENTIFIER]})*))`),a("FULLPLAIN",`v?${r[o.MAINVERSION]}${r[o.PRERELEASE]}?${r[o.BUILD]}?`),a("FULL",`^${r[o.FULLPLAIN]}$`),a("LOOSEPLAIN",`[v=\\s]*${r[o.MAINVERSIONLOOSE]}${r[o.PRERELEASELOOSE]}?${r[o.BUILD]}?`),a("LOOSE",`^${r[o.LOOSEPLAIN]}$`),a("GTLT","((?:<|>)?=?)"),a("XRANGEIDENTIFIERLOOSE",`${r[o.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),a("XRANGEIDENTIFIER",`${r[o.NUMERICIDENTIFIER]}|x|X|\\*`),a("XRANGEPLAIN",`[v=\\s]*(${r[o.XRANGEIDENTIFIER]})(?:\\.(${r[o.XRANGEIDENTIFIER]})(?:\\.(${r[o.XRANGEIDENTIFIER]})(?:${r[o.PRERELEASE]})?${r[o.BUILD]}?)?)?`),a("XRANGEPLAINLOOSE",`[v=\\s]*(${r[o.XRANGEIDENTIFIERLOOSE]})(?:\\.(${r[o.XRANGEIDENTIFIERLOOSE]})(?:\\.(${r[o.XRANGEIDENTIFIERLOOSE]})(?:${r[o.PRERELEASELOOSE]})?${r[o.BUILD]}?)?)?`),a("XRANGE",`^${r[o.GTLT]}\\s*${r[o.XRANGEPLAIN]}$`),a("XRANGELOOSE",`^${r[o.GTLT]}\\s*${r[o.XRANGEPLAINLOOSE]}$`),a("COERCE",`(^|[^\\d])(\\d{1,${i}})(?:\\.(\\d{1,${i}}))?(?:\\.(\\d{1,${i}}))?(?:$|[^\\d])`),a("COERCERTL",r[o.COERCE],!0),a("LONETILDE","(?:~>?)"),a("TILDETRIM",`(\\s*)${r[o.LONETILDE]}\\s+`,!0),g.tildeTrimReplace="$1~",a("TILDE",`^${r[o.LONETILDE]}${r[o.XRANGEPLAIN]}$`),a("TILDELOOSE",`^${r[o.LONETILDE]}${r[o.XRANGEPLAINLOOSE]}$`),a("LONECARET","(?:\\^)"),a("CARETTRIM",`(\\s*)${r[o.LONECARET]}\\s+`,!0),g.caretTrimReplace="$1^",a("CARET",`^${r[o.LONECARET]}${r[o.XRANGEPLAIN]}$`),a("CARETLOOSE",`^${r[o.LONECARET]}${r[o.XRANGEPLAINLOOSE]}$`),a("COMPARATORLOOSE",`^${r[o.GTLT]}\\s*(${r[o.LOOSEPLAIN]})$|^$`),a("COMPARATOR",`^${r[o.GTLT]}\\s*(${r[o.FULLPLAIN]})$|^$`),a("COMPARATORTRIM",`(\\s*)${r[o.GTLT]}\\s*(${r[o.LOOSEPLAIN]}|${r[o.XRANGEPLAIN]})`,!0),g.comparatorTrimReplace="$1$2$3",a("HYPHENRANGE",`^\\s*(${r[o.XRANGEPLAIN]})\\s+-\\s+(${r[o.XRANGEPLAIN]})\\s*$`),a("HYPHENRANGELOOSE",`^\\s*(${r[o.XRANGEPLAINLOOSE]})\\s+-\\s+(${r[o.XRANGEPLAINLOOSE]})\\s*$`),a("STAR","(<|>)?=?\\s*\\*"),a("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),a("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(EIe,EIe.exports);var yme=EIe.exports;const tKe=/^[0-9]+$/,$at=(e,g)=>{const i=tKe.test(e),n=tKe.test(g);return i&&n&&(e=+e,g=+g),e===g?0:i&&!n?-1:n&&!i?1:e$at(g,e);var hai={compareIdentifiers:$at,rcompareIdentifiers:dai};const dK=FJ,{MAX_LENGTH:gKe,MAX_SAFE_INTEGER:hK}=bme,{re:iKe,t:nKe}=yme,fai=pme,{compareIdentifiers:BG}=hai;let mai=class Sl{constructor(g,i){if(i=fai(i),g instanceof Sl){if(g.loose===!!i.loose&&g.includePrerelease===!!i.includePrerelease)return g;g=g.version}else if(typeof g!="string")throw new TypeError(`Invalid Version: ${g}`);if(g.length>gKe)throw new TypeError(`version is longer than ${gKe} characters`);dK("SemVer",g,i),this.options=i,this.loose=!!i.loose,this.includePrerelease=!!i.includePrerelease;const n=g.trim().match(i.loose?iKe[nKe.LOOSE]:iKe[nKe.FULL]);if(!n)throw new TypeError(`Invalid Version: ${g}`);if(this.raw=g,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>hK||this.major<0)throw new TypeError("Invalid major version");if(this.minor>hK||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>hK||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(I=>{if(/^[0-9]+$/.test(I)){const r=+I;if(r>=0&&r=0;)typeof this.prerelease[I]=="number"&&(this.prerelease[I]++,I=-2);I===-1&&this.prerelease.push(0)}if(i){const I=Number(n)?1:0;BG(this.prerelease[0],i)===0?isNaN(this.prerelease[1])&&(this.prerelease=[i,I]):this.prerelease=[i,I]}break;default:throw new Error(`invalid increment argument: ${g}`)}return this.format(),this.raw=this.version,this}};var Zme=mai;const IKe=Zme,pai=(e,g,i)=>new IKe(e,i).compare(new IKe(g,i));var NS=pai;const bai=NS,yai=(e,g,i)=>bai(e,g,i)===0;var Zai=yai;const Gai=NS,vai=(e,g,i)=>Gai(e,g,i)!==0;var Bai=vai;const wai=NS,Sai=(e,g,i)=>wai(e,g,i)>0;var Rai=Sai;const Vai=NS,Wai=(e,g,i)=>Vai(e,g,i)>=0;var Xai=Wai;const Tai=NS,Hai=(e,g,i)=>Tai(e,g,i)<0;var Nai=Hai;const kai=NS,Yai=(e,g,i)=>kai(e,g,i)<=0;var Kai=Yai;const xai=Zai,Fai=Bai,Eai=Rai,Dai=Xai,Mai=Nai,zai=Kai,Pai=(e,g,i,n)=>{switch(g){case"===":return typeof e=="object"&&(e=e.version),typeof i=="object"&&(i=i.version),e===i;case"!==":return typeof e=="object"&&(e=e.version),typeof i=="object"&&(i=i.version),e!==i;case"":case"=":case"==":return xai(e,i,n);case"!=":return Fai(e,i,n);case">":return Eai(e,i,n);case">=":return Dai(e,i,n);case"<":return Mai(e,i,n);case"<=":return zai(e,i,n);default:throw new TypeError(`Invalid operator: ${g}`)}};var _ai=Pai,t$,rKe;function Oai(){if(rKe)return t$;rKe=1;const e=Symbol("SemVer ANY");class g{static get ANY(){return e}constructor(s,l){if(l=i(l),s instanceof g){if(s.loose===!!l.loose)return s;s=s.value}o("comparator",s,l),this.options=l,this.loose=!!l.loose,this.parse(s),this.semver===e?this.value="":this.value=this.operator+this.semver.version,o("comp",this)}parse(s){const l=this.options.loose?n[I.COMPARATORLOOSE]:n[I.COMPARATOR],c=s.match(l);if(!c)throw new TypeError(`Invalid comparator: ${s}`);this.operator=c[1]!==void 0?c[1]:"",this.operator==="="&&(this.operator=""),c[2]?this.semver=new C(c[2],this.options.loose):this.semver=e}toString(){return this.value}test(s){if(o("Comparator.test",s,this.options.loose),this.semver===e||s===e)return!0;if(typeof s=="string")try{s=new C(s,this.options)}catch{return!1}return r(s,this.operator,this.semver,this.options)}intersects(s,l){if(!(s instanceof g))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new a(s.value,l).test(this.value):s.operator===""?s.value===""?!0:new a(this.value,l).test(s.semver):(l=i(l),l.includePrerelease&&(this.value==="<0.0.0-0"||s.value==="<0.0.0-0")||!l.includePrerelease&&(this.value.startsWith("<0.0.0")||s.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&s.operator.startsWith(">")||this.operator.startsWith("<")&&s.operator.startsWith("<")||this.semver.version===s.semver.version&&this.operator.includes("=")&&s.operator.includes("=")||r(this.semver,"<",s.semver,l)&&this.operator.startsWith(">")&&s.operator.startsWith("<")||r(this.semver,">",s.semver,l)&&this.operator.startsWith("<")&&s.operator.startsWith(">")))}}t$=g;const i=pme,{re:n,t:I}=yme,r=_ai,o=FJ,C=Zme,a=qat();return t$}var g$,oKe;function qat(){if(oKe)return g$;oKe=1;class e{constructor(V,X){if(X=n(X),V instanceof e)return V.loose===!!X.loose&&V.includePrerelease===!!X.includePrerelease?V:new e(V.raw,X);if(V instanceof I)return this.raw=V.value,this.set=[[V]],this.format(),this;if(this.options=X,this.loose=!!X.loose,this.includePrerelease=!!X.includePrerelease,this.raw=V,this.set=V.split("||").map(N=>this.parseRange(N.trim())).filter(N=>N.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${V}`);if(this.set.length>1){const N=this.set[0];if(this.set=this.set.filter(Y=>!d(Y[0])),this.set.length===0)this.set=[N];else if(this.set.length>1){for(const Y of this.set)if(Y.length===1&&h(Y[0])){this.set=[Y];break}}}this.format()}format(){return this.range=this.set.map(V=>V.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(V){V=V.trim();const N=((this.options.includePrerelease&&c)|(this.options.loose&&u))+":"+V,Y=i.get(N);if(Y)return Y;const x=this.options.loose,M=x?C[a.HYPHENRANGELOOSE]:C[a.HYPHENRANGE];V=V.replace(M,w(this.options.includePrerelease)),r("hyphen replace",V),V=V.replace(C[a.COMPARATORTRIM],A),r("comparator trim",V),V=V.replace(C[a.TILDETRIM],s),V=V.replace(C[a.CARETTRIM],l),V=V.split(/\s+/).join(" ");let F=V.split(" ").map(j=>m(j,this.options)).join(" ").split(/\s+/).map(j=>R(j,this.options));x&&(F=F.filter(j=>(r("loose invalid filter",j,this.options),!!j.match(C[a.COMPARATORLOOSE])))),r("range list",F);const $=new Map,Q=F.map(j=>new I(j,this.options));for(const j of Q){if(d(j))return[j];$.set(j.value,j)}$.size>1&&$.has("")&&$.delete("");const U=[...$.values()];return i.set(N,U),U}intersects(V,X){if(!(V instanceof e))throw new TypeError("a Range is required");return this.set.some(N=>f(N,X)&&V.set.some(Y=>f(Y,X)&&N.every(x=>Y.every(M=>x.intersects(M,X)))))}test(V){if(!V)return!1;if(typeof V=="string")try{V=new o(V,this.options)}catch{return!1}for(let X=0;XW.value==="<0.0.0-0",h=W=>W.value==="",f=(W,V)=>{let X=!0;const N=W.slice();let Y=N.pop();for(;X&&N.length;)X=N.every(x=>Y.intersects(x,V)),Y=N.pop();return X},m=(W,V)=>(r("comp",W,V),W=Z(W,V),r("caret",W),W=p(W,V),r("tildes",W),W=G(W,V),r("xrange",W),W=S(W,V),r("stars",W),W),b=W=>!W||W.toLowerCase()==="x"||W==="*",p=(W,V)=>W.trim().split(/\s+/).map(X=>y(X,V)).join(" "),y=(W,V)=>{const X=V.loose?C[a.TILDELOOSE]:C[a.TILDE];return W.replace(X,(N,Y,x,M,F)=>{r("tilde",W,N,Y,x,M,F);let $;return b(Y)?$="":b(x)?$=`>=${Y}.0.0 <${+Y+1}.0.0-0`:b(M)?$=`>=${Y}.${x}.0 <${Y}.${+x+1}.0-0`:F?(r("replaceTilde pr",F),$=`>=${Y}.${x}.${M}-${F} <${Y}.${+x+1}.0-0`):$=`>=${Y}.${x}.${M} <${Y}.${+x+1}.0-0`,r("tilde return",$),$})},Z=(W,V)=>W.trim().split(/\s+/).map(X=>v(X,V)).join(" "),v=(W,V)=>{r("caret",W,V);const X=V.loose?C[a.CARETLOOSE]:C[a.CARET],N=V.includePrerelease?"-0":"";return W.replace(X,(Y,x,M,F,$)=>{r("caret",W,Y,x,M,F,$);let Q;return b(x)?Q="":b(M)?Q=`>=${x}.0.0${N} <${+x+1}.0.0-0`:b(F)?x==="0"?Q=`>=${x}.${M}.0${N} <${x}.${+M+1}.0-0`:Q=`>=${x}.${M}.0${N} <${+x+1}.0.0-0`:$?(r("replaceCaret pr",$),x==="0"?M==="0"?Q=`>=${x}.${M}.${F}-${$} <${x}.${M}.${+F+1}-0`:Q=`>=${x}.${M}.${F}-${$} <${x}.${+M+1}.0-0`:Q=`>=${x}.${M}.${F}-${$} <${+x+1}.0.0-0`):(r("no pr"),x==="0"?M==="0"?Q=`>=${x}.${M}.${F}${N} <${x}.${M}.${+F+1}-0`:Q=`>=${x}.${M}.${F}${N} <${x}.${+M+1}.0-0`:Q=`>=${x}.${M}.${F} <${+x+1}.0.0-0`),r("caret return",Q),Q})},G=(W,V)=>(r("replaceXRanges",W,V),W.split(/\s+/).map(X=>B(X,V)).join(" ")),B=(W,V)=>{W=W.trim();const X=V.loose?C[a.XRANGELOOSE]:C[a.XRANGE];return W.replace(X,(N,Y,x,M,F,$)=>{r("xRange",W,N,Y,x,M,F,$);const Q=b(x),U=Q||b(M),j=U||b(F),ee=j;return Y==="="&&ee&&(Y=""),$=V.includePrerelease?"-0":"",Q?Y===">"||Y==="<"?N="<0.0.0-0":N="*":Y&&ee?(U&&(M=0),F=0,Y===">"?(Y=">=",U?(x=+x+1,M=0,F=0):(M=+M+1,F=0)):Y==="<="&&(Y="<",U?x=+x+1:M=+M+1),Y==="<"&&($="-0"),N=`${Y+x}.${M}.${F}${$}`):U?N=`>=${x}.0.0${$} <${+x+1}.0.0-0`:j&&(N=`>=${x}.${M}.0${$} <${x}.${+M+1}.0-0`),r("xRange return",N),N})},S=(W,V)=>(r("replaceStars",W,V),W.trim().replace(C[a.STAR],"")),R=(W,V)=>(r("replaceGTE0",W,V),W.trim().replace(C[V.includePrerelease?a.GTE0PRE:a.GTE0],"")),w=W=>(V,X,N,Y,x,M,F,$,Q,U,j,ee,Ie)=>(b(N)?X="":b(Y)?X=`>=${N}.0.0${W?"-0":""}`:b(x)?X=`>=${N}.${Y}.0${W?"-0":""}`:M?X=`>=${X}`:X=`>=${X}${W?"-0":""}`,b(Q)?$="":b(U)?$=`<${+Q+1}.0.0-0`:b(j)?$=`<${Q}.${+U+1}.0-0`:ee?$=`<=${Q}.${U}.${j}-${ee}`:W?$=`<${Q}.${U}.${+j+1}-0`:$=`<=${$}`,`${X} ${$}`.trim()),T=(W,V,X)=>{for(let N=0;N0){const Y=W[N].semver;if(Y.major===V.major&&Y.minor===V.minor&&Y.patch===V.patch)return!0}return!1}return!0};return g$}const Jai=qat(),Lai=(e,g,i)=>{try{g=new Jai(g,i)}catch{return!1}return g.test(e)};var Uai=Lai,est=QCi(Uai);function Qai(e,g,i){const n=e.open(g),I=1e4,r=250,{origin:o}=new URL(g);let C=~~(I/r);function a(s){s.source===n&&(C=0,e.removeEventListener("message",a,!1))}e.addEventListener("message",a,!1);function A(){C<=0||(n.postMessage(i,o),setTimeout(A,r),C-=1)}setTimeout(A,r)}var jai=`.vega-embed { + position: relative; + display: inline-block; + box-sizing: border-box; +} +.vega-embed.has-actions { + padding-right: 38px; +} +.vega-embed details:not([open]) > :not(summary) { + display: none !important; +} +.vega-embed summary { + list-style: none; + position: absolute; + top: 0; + right: 0; + padding: 6px; + z-index: 1000; + background: white; + box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1); + color: #1b1e23; + border: 1px solid #aaa; + border-radius: 999px; + opacity: 0.2; + transition: opacity 0.4s ease-in; + cursor: pointer; + line-height: 0px; +} +.vega-embed summary::-webkit-details-marker { + display: none; +} +.vega-embed summary:active { + box-shadow: #aaa 0px 0px 0px 1px inset; +} +.vega-embed summary svg { + width: 14px; + height: 14px; +} +.vega-embed details[open] summary { + opacity: 0.7; +} +.vega-embed:hover summary, .vega-embed:focus-within summary { + opacity: 1 !important; + transition: opacity 0.2s ease; +} +.vega-embed .vega-actions { + position: absolute; + z-index: 1001; + top: 35px; + right: -9px; + display: flex; + flex-direction: column; + padding-bottom: 8px; + padding-top: 8px; + border-radius: 4px; + box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.2); + border: 1px solid #d9d9d9; + background: white; + animation-duration: 0.15s; + animation-name: scale-in; + animation-timing-function: cubic-bezier(0.2, 0, 0.13, 1.5); + text-align: left; +} +.vega-embed .vega-actions a { + padding: 8px 16px; + font-family: sans-serif; + font-size: 14px; + font-weight: 600; + white-space: nowrap; + color: #434a56; + text-decoration: none; +} +.vega-embed .vega-actions a:hover, .vega-embed .vega-actions a:focus { + background-color: #f7f7f9; + color: black; +} +.vega-embed .vega-actions::before, .vega-embed .vega-actions::after { + content: ""; + display: inline-block; + position: absolute; +} +.vega-embed .vega-actions::before { + left: auto; + right: 14px; + top: -16px; + border: 8px solid rgba(0, 0, 0, 0); + border-bottom-color: #d9d9d9; +} +.vega-embed .vega-actions::after { + left: auto; + right: 15px; + top: -14px; + border: 7px solid rgba(0, 0, 0, 0); + border-bottom-color: #fff; +} +.vega-embed .chart-wrapper.fit-x { + width: 100%; +} +.vega-embed .chart-wrapper.fit-y { + height: 100%; +} + +.vega-embed-wrapper { + max-width: 100%; + overflow: auto; + padding-right: 14px; +} + +@keyframes scale-in { + from { + opacity: 0; + transform: scale(0.6); + } + to { + opacity: 1; + transform: scale(1); + } +} +`;function tst(e,...g){for(const i of g)$ai(e,i);return e}function $ai(e,g){for(const i of Object.keys(g))lS(e,i,g[i],!0)}function CKe(e,g){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);g&&(n=n.filter(function(I){return Object.getOwnPropertyDescriptor(e,I).enumerable})),i.push.apply(i,n)}return i}function sm(e){for(var g=1;ge,"vega-lite":(e,g)=>IT.compile(e,{config:g}).spec},gsi=` + + + + +`,isi="chart-wrapper";function nsi(e){return typeof e=="function"}function sKe(e,g,i,n){const I=`${g}
`,r=`
${i}`,o=window.open("");o.document.write(I+e+r),o.document.title=`${v2[n]} JSON Source`}function Isi(e,g){if(e.$schema){const i=Jat(e.$schema);g&&g!==i.library&&console.warn(`The given visualization spec is written in ${v2[i.library]}, but mode argument sets ${v2[g]??g}.`);const n=i.library;return est(X3[n],`^${i.version.slice(1)}`)||console.warn(`The input spec uses ${v2[n]} ${i.version}, but the current version of ${v2[n]} is v${X3[n]}.`),n}return"mark"in e||"encoding"in e||"layer"in e||"hconcat"in e||"vconcat"in e||"facet"in e||"repeat"in e?"vega-lite":"marks"in e||"signals"in e||"scales"in e||"axes"in e?"vega":g??"vega"}function rsi(e){return!!(e&&"load"in e)}function AKe(e){return rsi(e)?e:nA.loader(e)}function osi(e){const g=e.usermeta?.embedOptions??{};return Rt(g.defaultStyle)&&(g.defaultStyle=!1),g}async function Csi(e,g,i={}){let n,I;Rt(g)?(I=AKe(i.loader),n=JSON.parse(await I.load(g))):n=g;const r=osi(n),o=r.loader;(!I||o)&&(I=AKe(i.loader??o));const C=await lKe(r,I),a=await lKe(i,I),A=sm(sm({},tst(a,C)),{},{config:AS(a.config??{},C.config??{})});return await ssi(e,n,A,I)}async function lKe(e,g){const i=Rt(e.config)?JSON.parse(await g.load(e.config)):e.config??{},n=Rt(e.patch)?JSON.parse(await g.load(e.patch)):e.patch;return sm(sm(sm({},e),n?{patch:n}:{}),i?{config:i}:{})}function asi(e){const g=e.getRootNode?e.getRootNode():document;return g instanceof ShadowRoot?{root:g,rootContainer:g}:{root:document,rootContainer:document.head??document.body}}async function ssi(e,g,i={},n){const I=i.theme?AS(TCi[i.theme],i.config??{}):i.config,r=gp(i.actions)?i.actions:tst({},qai,i.actions??{}),o=sm(sm({},esi),i.i18n),C=i.renderer??"canvas",a=i.logLevel??nA.Warn,A=i.downloadFileName??"visualization",s=typeof e=="string"?document.querySelector(e):e;if(!s)throw new Error(`${e} does not exist`);if(i.defaultStyle!==!1){const Z="vega-embed-style",{root:v,rootContainer:G}=asi(s);if(!v.getElementById(Z)){const B=document.createElement("style");B.id=Z,B.innerHTML=i.defaultStyle===void 0||i.defaultStyle===!0?jai.toString():i.defaultStyle,G.appendChild(B)}}const l=Isi(g,i.mode);let c=tsi[l](g,I);if(l==="vega-lite"&&c.$schema){const Z=Jat(c.$schema);est(X3.vega,`^${Z.version.slice(1)}`)||console.warn(`The compiled spec uses Vega ${Z.version}, but current version is v${X3.vega}.`)}s.classList.add("vega-embed"),r&&s.classList.add("has-actions"),s.innerHTML="";let u=s;if(r){const Z=document.createElement("div");Z.classList.add(isi),s.appendChild(Z),u=Z}const d=i.patch;if(d&&(c=d instanceof Function?d(c):x_(c,d,!0,!1).newDocument),i.formatLocale&&nA.formatLocale(i.formatLocale),i.timeFormatLocale&&nA.timeFormatLocale(i.timeFormatLocale),i.expressionFunctions)for(const Z in i.expressionFunctions){const v=i.expressionFunctions[Z];"fn"in v?nA.expressionFunction(Z,v.fn,v.visitor):v instanceof Function&&nA.expressionFunction(Z,v)}const{ast:h}=i,f=nA.parse(c,l==="vega-lite"?{}:I,{ast:h}),m=new(i.viewClass||nA.View)(f,sm({loader:n,logLevel:a,renderer:C},h?{expr:nA.expressionInterpreter??i.expr??D6g}:{}));if(m.addSignalListener("autosize",(Z,v)=>{const{type:G}=v;G=="fit-x"?(u.classList.add("fit-x"),u.classList.remove("fit-y")):G=="fit-y"?(u.classList.remove("fit-x"),u.classList.add("fit-y")):G=="fit"?u.classList.add("fit-x","fit-y"):u.classList.remove("fit-x","fit-y")}),i.tooltip!==!1){const Z=nsi(i.tooltip)?i.tooltip:new OCi(i.tooltip===!0?{}:i.tooltip).call;m.tooltip(Z)}let{hover:b}=i;if(b===void 0&&(b=l==="vega"),b){const{hoverSet:Z,updateSet:v}=typeof b=="boolean"?{}:b;m.hover(Z,v)}i&&(i.width!=null&&m.width(i.width),i.height!=null&&m.height(i.height),i.padding!=null&&m.padding(i.padding)),await m.initialize(u,i.bind).runAsync();let p;if(r!==!1){let Z=s;if(i.defaultStyle!==!1){const G=document.createElement("details");G.title=o.CLICK_TO_VIEW_ACTIONS,s.append(G),Z=G;const B=document.createElement("summary");B.innerHTML=gsi,G.append(B),p=S=>{G.contains(S.target)||G.removeAttribute("open")},document.addEventListener("click",p)}const v=document.createElement("div");if(Z.append(v),v.classList.add("vega-actions"),r===!0||r.export!==!1){for(const G of["svg","png"])if(r===!0||r.export===!0||r.export[G]){const B=o[`${G.toUpperCase()}_ACTION`],S=document.createElement("a"),R=Wt(i.scaleFactor)?i.scaleFactor[G]:i.scaleFactor;S.text=B,S.href="#",S.target="_blank",S.download=`${A}.${G}`,S.addEventListener("mousedown",async function(w){w.preventDefault();const T=await m.toImageURL(G,R);this.href=T}),v.append(S)}}if(r===!0||r.source!==!1){const G=document.createElement("a");G.text=o.SOURCE_ACTION,G.href="#",G.addEventListener("click",function(B){sKe(wj(g),i.sourceHeader??"",i.sourceFooter??"",l),B.preventDefault()}),v.append(G)}if(l==="vega-lite"&&(r===!0||r.compiled!==!1)){const G=document.createElement("a");G.text=o.COMPILED_ACTION,G.href="#",G.addEventListener("click",function(B){sKe(wj(c),i.sourceHeader??"",i.sourceFooter??"","vega"),B.preventDefault()}),v.append(G)}if(r===!0||r.editor!==!1){const G=i.editorUrl??"https://vega.github.io/editor/",B=document.createElement("a");B.text=o.EDITOR_ACTION,B.href="#",B.addEventListener("click",function(S){Qai(window,G,{config:I,mode:l,renderer:C,spec:wj(g)}),S.preventDefault()}),v.append(B)}}function y(){p&&document.removeEventListener("click",p),m.finalize()}return{view:m,spec:g,vgSpec:c,finalize:y,embedOptions:i}}function Asi(e){return!!e&&{}.toString.call(e)==="[object Function]"}function lsi(e,g,i){i&&(Asi(i)?i(e.data(g)):e.change(g,nA.changeset().remove(()=>!0).insert(i)))}function csi(e,g){Object.keys(g).forEach(i=>{lsi(e,i,g[i])})}function gst(e){const g=new Set;return e.forEach(i=>{Object.keys(i).forEach(n=>{g.add(n)})}),g}const ist=()=>{};function i$(e,g){const i=Object.keys(g);return i.forEach(n=>{try{e.addSignalListener(n,g[n])}catch(I){console.warn("Cannot add invalid signal listener.",I)}}),i.length>0}function usi(e,g){if(e===g)return!1;const i={width:!1,height:!1,isExpensive:!1},n=gst([e,g]);return n.has("width")&&(!("width"in e)||!("width"in g)||e.width!==g.width)&&("width"in e&&typeof e.width=="number"?i.width=e.width:i.isExpensive=!0),n.has("height")&&(!("height"in e)||!("height"in g)||e.height!==g.height)&&("height"in e&&typeof e.height=="number"?i.height=e.height:i.isExpensive=!0),n.delete("width"),n.delete("height"),[...n].some(I=>!(I in e)||!(I in g)||!Trt(e[I],g[I]))&&(i.isExpensive=!0),i.width!==!1||i.height!==!1||i.isExpensive?i:!1}function cKe(e,g){const i=Object.keys(g);return i.forEach(n=>{try{e.removeSignalListener(n,g[n])}catch(I){console.warn("Cannot remove invalid signal listener.",I)}}),i.length>0}function n$(e){const{spec:g,width:i,height:n}=e;return typeof i<"u"&&typeof n<"u"?{...g,width:i,height:n}:typeof i<"u"?{...g,width:i}:typeof n<"u"?{...g,height:n}:g}function B2(e,g,i){return g in e?Object.defineProperty(e,g,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[g]=i,e}class nst extends k.PureComponent{constructor(){super(...arguments),B2(this,"containerRef",k.createRef()),B2(this,"resultPromise",void 0),B2(this,"handleError",g=>{const{onError:i=ist}=this.props;i(g,this.containerRef.current),console.warn(g)}),B2(this,"modifyView",g=>{this.resultPromise&&this.resultPromise.then(i=>(i&&g(i.view),!0)).catch(this.handleError)})}componentDidMount(){this.createView()}componentDidUpdate(g){const i=gst([this.props,g]);if(i.delete("className"),i.delete("signalListeners"),i.delete("spec"),i.delete("style"),i.delete("width"),i.delete("height"),Array.from(i).some(n=>this.props[n]!==g[n]))this.clearView(),this.createView();else{const n=usi(n$(this.props),n$(g)),{signalListeners:I}=this.props,{signalListeners:r}=g;if(n)if(n.isExpensive)this.clearView(),this.createView();else{const o=!vie(I,r);this.modifyView(C=>{n.width!==!1&&C.width(n.width),n.height!==!1&&C.height(n.height),o&&(r&&cKe(C,r),I&&i$(C,I)),C.run()})}else vie(I,r)||this.modifyView(o=>{r&&cKe(o,r),I&&i$(o,I),o.run()})}}componentWillUnmount(){this.clearView()}createView(){const{spec:g,onNewView:i,signalListeners:n={},width:I,height:r,...o}=this.props;if(this.containerRef.current){const C=n$(this.props);this.resultPromise=Csi(this.containerRef.current,C,o).then(a=>{if(a){const{view:A}=a;i$(A,n)&&A.run()}return a}).catch(this.handleError),i&&this.modifyView(i)}}clearView(){return this.resultPromise&&this.resultPromise.then(g=>{g&&g.finalize()}).catch(this.handleError),this.resultPromise=void 0,this}render(){const{className:g,style:i}=this.props;return k.createElement("div",{ref:this.containerRef,className:g,style:i})}}B2(nst,"propTypes",{className:S9e.string,onError:S9e.func});function DIe(){return DIe=Object.assign||function(e){for(var g=1;g{this.update();const{onNewView:i=ist}=this.props;i(g)})}componentDidMount(){this.update()}componentDidUpdate(g){vie(this.props.data,g.data)||this.update()}update(){const{data:g}=this.props;this.vegaEmbed.current&&g&&Object.keys(g).length>0&&this.vegaEmbed.current.modifyView(i=>{csi(i,g),i.resize().run()})}render(){const{data:g,...i}=this.props;return k.createElement(nst,DIe({ref:this.vegaEmbed},i,{onNewView:this.handleNewView}))}}MIe(Gme,"defaultProps",{data:dsi});function zIe(){return zIe=Object.assign||function(e){for(var g=1;g{if(!e.current)return;const n=e.current;return n.api.subscribe("rangeSelect",(I,r)=>i(r.data)),()=>n.api.unsubscribe("rangeSelect")},[]),k.createElement(k.Fragment,null,k.createElement(tp,{ref:e,spec:fsi,experimental:{reactive:!0}}),k.createElement("div",{style:{marginLeft:80}},k.createElement(hsi,{spec:msi,data:{table:g}})))}const bsi=["point","bar","line","area"],ysi=["linear","circular"],Zsi=(e,g,i)=>({layout:g,arrangement:"vertical",centerRadius:.4,style:{select:{color:"black",stroke:"black",strokeWidth:6,arrange:"behind",opacity:.1}},views:[{tracks:[{id:"widget-track",data:{url:"https://server.gosling-lang.org/api/v1/tileset_info/?d=cistrome-multivec",type:"multivec",row:"sample",column:"position",value:"peak",categories:Array.from(Array(6)).map((n,I)=>`sample ${I}`),binSize:i===0?1:i},mark:e,x:{field:"start",type:"genomic"},xe:{field:"end",type:"genomic"},row:{field:"sample",type:"nominal",legend:!1},y:{field:"peak",type:"quantitative",axis:"none"},color:{field:"sample",type:"nominal",legend:!0},tooltip:[{field:"start",type:"genomic",alt:"Start Position"},{field:"end",type:"genomic",alt:"End Position"},{field:"peak",type:"quantitative",alt:"Value",format:".2"},{field:"sample",type:"nominal",alt:"Sample"}],width:600,height:230}]}]});function Gsi(){const e=Ue.useRef(null),[g,i]=Ue.useState("point"),[n,I]=Ue.useState("linear"),[r,o]=Ue.useState(8);return k.createElement(k.Fragment,null,k.createElement("span",null,k.createElement("div",{style:{marginTop:30,marginLeft:80}},"Bin Size: ",k.createElement("input",{type:"range",min:0,max:32,step:4,value:r,className:"slider",id:"bin-slider",style:{width:100,display:"inline",margin:10},onChange:C=>o(+C.currentTarget.value)}),r===0?1:r)),k.createElement("div",{style:{marginTop:30,marginLeft:80}},"Mark: ",k.createElement("select",{name:"mark",onChange:C=>i(C.currentTarget.value)},bsi.map(C=>k.createElement("option",{key:C,value:C},C)))),k.createElement("div",{style:{marginTop:30,marginLeft:80}},"Layout: ",k.createElement("select",{name:"layout",onChange:C=>I(C.currentTarget.value)},ysi.map(C=>k.createElement("option",{key:C,value:C},C)))),k.createElement(tp,{ref:e,spec:Zsi(g,n,r),experimental:{reactive:!0}}))}const vsi=["chr1","chr2","chr3","chr4","chr5","chr6","chr7","chr8","chr9","chr10","chr11","chr12","chr13","chr14","chr15","chr16","chr17","chr18","chr19","chr20","chr21","chr22","chrX","chrY"];function Bsi(){const e=Ue.useRef();return k.createElement(k.Fragment,null,k.createElement("div",{style:{marginTop:30,marginLeft:80}},"Zoom To Chromosome: ",k.createElement("select",{name:"Chromosome",onChange:g=>e.current?.api.zoomTo("navigation-track-id",g.currentTarget.value,0,1e3)},vsi.map(g=>k.createElement("option",{key:g,value:g},g)))),k.createElement("div",{style:{marginTop:30,marginLeft:80}},"Zoom To Gene: ",k.createElement("button",{className:"mr-3 p-1 rounded bg-slate-200",onClick:()=>e.current?.api.zoomToGene("navigation-track-id","MYC",3e3,1e3)},"MYC"),k.createElement("button",{className:"mr-3 p-1 rounded bg-slate-200",onClick:()=>e.current?.api.zoomToGene("navigation-track-id","CCNK",3e3,1e3)},"CCNK")),k.createElement("div",{style:{marginTop:30,marginLeft:80}},k.createElement("button",{className:"mr-3 p-1 rounded bg-slate-200",onClick:()=>e.current?.api.zoomToExtent("navigation-track-id",1e3)},"Zoom To Extent")),k.createElement(tp,{ref:e,spec:{style:{outlineWidth:0},xDomain:{chromosome:"chr1"},spacing:0,tracks:[{id:"navigation-track-id",template:"gene",data:{url:"https://server.gosling-lang.org/api/v1/tileset_info/?d=gene-annotation",type:"beddb",genomicFields:[{index:1,name:"start"},{index:2,name:"end"}],valueFields:[{index:5,name:"strand",type:"nominal"},{index:3,name:"name",type:"nominal"}],exonIntervalFields:[{index:12,name:"start"},{index:13,name:"end"}]},encoding:{startPosition:{field:"start",axis:"none"},endPosition:{field:"end"},strandColor:{field:"strand",range:["gray"]},strandRow:{field:"strand"},opacity:{value:.4},geneHeight:{value:15},geneLabel:{field:"name"},geneLabelFontSize:{value:30},geneLabelColor:{field:"strand",range:["gray"]},geneLabelStroke:{value:"white"},geneLabelStrokeThickness:{value:4},geneLabelOpacity:{value:1},type:{field:"type"}},width:1e3,height:40},{data:{url:"https://server.gosling-lang.org/api/v1/tileset_info/?d=cistrome-multivec",type:"multivec",row:"sample",column:"position",value:"peak",categories:["sample 1","sample 2","sample 3","sample 4"]},mark:"area",x:{field:"position",type:"genomic"},y:{field:"peak",type:"quantitative",axis:"none"},color:{field:"sample",type:"nominal"},width:1e3,height:30},{alignment:"overlay",data:{url:"https://raw.githubusercontent.com/sehilyi/gemini-datasets/master/data/cytogenetic_band.csv",type:"csv",chromosomeField:"Chr.",genomicFields:["ISCN_start","ISCN_stop","Basepair_start","Basepair_stop"]},tracks:[{mark:"text",dataTransform:[{type:"filter",field:"Stain",oneOf:["acen-1","acen-2"],not:!0}],text:{field:"Band",type:"nominal"},color:{value:"black"},strokeWidth:{value:0},visibility:[{operation:"less-than",measure:"width",threshold:"|xe-x|",transitionPadding:10,target:"mark"}]},{mark:"rect",dataTransform:[{type:"filter",field:"Stain",oneOf:["acen-1","acen-2"],not:!0}],color:{field:"Density",type:"nominal",domain:["","25","50","75","100"],range:["white","#D9D9D9","#979797","#636363","black"]}},{mark:"rect",dataTransform:[{type:"filter",field:"Stain",oneOf:["gvar"]}],color:{value:"#A0A0F2"}},{mark:"triangleRight",dataTransform:[{type:"filter",field:"Stain",oneOf:["acen-1"]}],color:{value:"#B40101"}},{mark:"triangleLeft",dataTransform:[{type:"filter",field:"Stain",oneOf:["acen-2"]}],color:{value:"#B40101"}}],x:{field:"Basepair_start",type:"genomic",axis:"bottom"},xe:{field:"Basepair_stop",type:"genomic"},stroke:{value:"gray"},strokeWidth:{value:1},width:1e3,height:20}]},experimental:{reactive:!0}}))}function wsi(){const e=Ue.useRef(),[g,i]=Ue.useState(),[n,I]=Ue.useState([]);Ue.useEffect(()=>{if(!e.current)return;const o=e.current;o.api.subscribe("click",(C,a)=>{const{genomicPosition:A}=a;i(`${A.chromosome}:${A.position}`),I(a.data)}),o.api.subscribe("rangeSelect",(C,a)=>{if(!a||!a.genomicRange)i("N/A"),I([]);else{const{genomicRange:A}=a;A.length===2&&i(`${A[0].chromosome}:${A[0].position}-${A[1].chromosome}:${A[1].position}`),I(a.data.length>10?a.data.slice(0,10):a.data)}})},[]);const r=Ue.useMemo(()=>k.createElement(tp,{ref:e,spec:{xDomain:{chromosome:"chr3",interval:[52168e3,5289e4]},tracks:[{title:"Group Marks By Gene",template:"gene",data:{url:"https://server.gosling-lang.org/api/v1/tileset_info/?d=gene-annotation",type:"beddb",genomicFields:[{index:1,name:"start"},{index:2,name:"end"}],valueFields:[{index:5,name:"strand",type:"nominal"},{index:3,name:"name",type:"nominal"}],exonIntervalFields:[{index:12,name:"start"},{index:13,name:"end"}]},encoding:{startPosition:{field:"start"},endPosition:{field:"end"},strandColor:{field:"strand",range:["gray"]},strandRow:{field:"strand"},opacity:{value:.4},geneHeight:{value:20},geneLabel:{field:"name"},geneLabelFontSize:{value:20},geneLabelColor:{field:"strand",range:["gray"]},geneLabelStroke:{value:"white"},geneLabelStrokeThickness:{value:4},geneLabelOpacity:{value:1},type:{field:"type"}},tooltip:[{field:"name",type:"nominal"}],width:600,height:60,experimental:{mouseEvents:{mouseOver:!0,rangeSelect:!0,groupMarksByField:"name"}},style:{mouseOver:{arrange:"behind",color:"#E0E0E0",stroke:"#E0E0E0",strokeWidth:4},select:{arrange:"behind",color:"#B9D4FA",stroke:"#B9D4FA",strokeWidth:4}}}]}}),[]);return k.createElement("div",null,k.createElement("div",{style:{marginTop:30,marginLeft:60}},"Hold down the alt or option key to select a range. ",k.createElement("br",null),"Selected Position: ",k.createElement("b",null,g||"N/A")),r)}const lV={data:{type:"csv",url:"https://s3.amazonaws.com/gosling-lang.org/data/IslandViewer/NC_004631.1_islands.csv",chromosomeField:"Accession",genomicFields:["Island start","Island end"]},x:{field:"Island start",type:"genomic"},xe:{field:"Island end",type:"genomic"}},PIe="detailedView",uKe=200,Ssi=.5,Ist=120,gC=Ist/6,Rsi={title:"IslandViewer 4 (Bertelli et al. 2017)",subtitle:"Salmonella enterica subsp. enterica serovar Typhi Ty2, complete genome.",description:"Reimplementation of https://www.pathogenomics.sfu.ca/islandviewer/accession/NC_004631.1/",assembly:[["NC_004631.1",4791961]],spacing:50,views:[{layout:"circular",static:!0,alignment:"overlay",spacing:.1,tracks:[{data:{url:"https://s3.amazonaws.com/gosling-lang.org/data/IslandViewer/NC_004631.1_GCcontent.csv",type:"csv",separator:" ",genomicFields:["Position"]},y:{field:"GCcontent",type:"quantitative",range:[-250,0],axis:"none"},mark:"line",size:{value:.5},x:{field:"Position",type:"genomic"},color:{value:"black"}},{style:{outlineWidth:1,outline:"black"},data:{url:"https://s3.amazonaws.com/gosling-lang.org/data/IslandViewer/NC_004631.1_annotations.csv",type:"csv",genomicFields:["Gene start"]},dataTransform:[{type:"displace",method:"pile",boundingBox:{padding:3.5,startField:"Gene start",endField:"Gene start"},newField:"row"}],y:{field:"row",type:"nominal",flip:!0},mark:"point",x:{field:"Gene start",type:"genomic"},size:{value:3},color:{field:"Type",type:"nominal",domain:["Victors","BLAST","RGI","PAG"],range:["#460B80","#A684EA","#FF9CC1","#FF9CC1"]}},{...lV,row:{field:"Method",domain:["Predicted by at least one method","IslandPath-DIMOB","SIGI-HMM","IslandPick","Islander"],type:"nominal"},color:{field:"Method",type:"nominal",domain:["Predicted by at least one method","IslandPath-DIMOB","SIGI-HMM","IslandPick","Islander"],range:["#B22222","#4169E1","#FF8C00","#008001","#40E0D0"]},mark:"rect"},{mark:"brush",x:{linkingId:"detail"}}],width:uKe*2,centerRadius:Ssi},{layout:"linear",xDomain:{chromosome:"NC_004631.1",interval:[1e6,15e5]},linkingId:"detail",alignment:"overlay",tracks:[{data:{url:"https://s3.amazonaws.com/gosling-lang.org/data/IslandViewer/NC_004631.1_genes.csv",type:"csv",chromosomeField:"Accession",genomicFields:["Gene start","Gene end"]},id:PIe,x:{field:"Gene start",type:"genomic"},xe:{field:"Gene end",type:"genomic"},y:{value:5.5*gC},size:{value:gC},mark:"rect",dataTransform:[{type:"filter",field:"Strand",oneOf:["1"]}],color:{value:"#E9967A"},tooltip:[{field:"Gene name",type:"nominal",alt:"Name"}]},{data:{url:"https://s3.amazonaws.com/gosling-lang.org/data/IslandViewer/NC_004631.1_genes.csv",type:"csv",chromosomeField:"Accession",genomicFields:["Gene start","Gene end"]},x:{field:"Gene start",type:"genomic"},xe:{field:"Gene end",type:"genomic"},y:{value:4.5*gC},size:{value:gC},mark:"rect",dataTransform:[{type:"filter",field:"Strand",oneOf:["-1"]}],color:{value:"#87976E"},tooltip:[{field:"Gene name",type:"nominal",alt:"Name"}]},{data:{url:"https://s3.amazonaws.com/gosling-lang.org/data/IslandViewer/NC_004631.1_genes.csv",type:"csv",chromosomeField:"Accession",genomicFields:["Gene start","Gene end"]},x:{field:"Gene start",type:"genomic"},xe:{field:"Gene end",type:"genomic"},y:{value:5.5*gC},mark:"text",text:{field:"Gene name",type:"nominal"},dataTransform:[{type:"filter",field:"Strand",oneOf:["1"]}],color:{value:"#ffffff"},visibility:[{operation:"less-than",measure:"width",threshold:"|xe-x|",transitionPadding:10,target:"mark"}]},{data:{url:"https://s3.amazonaws.com/gosling-lang.org/data/IslandViewer/NC_004631.1_genes.csv",type:"csv",chromosomeField:"Accession",genomicFields:["Gene start","Gene end"]},x:{field:"Gene start",type:"genomic"},xe:{field:"Gene end",type:"genomic"},y:{value:4.5*gC},mark:"text",text:{field:"Gene name",type:"nominal"},dataTransform:[{type:"filter",field:"Strand",oneOf:["-1"]}],color:{value:"#ffffff"},visibility:[{operation:"less-than",measure:"width",threshold:"|xe-x|",transitionPadding:10,target:"mark"}]},{...lV,mark:"rect",dataTransform:[{type:"filter",field:"Method",oneOf:["IslandPath-DIMOB"]}],y:{value:.5*gC},size:{value:gC},color:{value:"#4169E1"}},{...lV,mark:"rect",dataTransform:[{type:"filter",field:"Method",oneOf:["SIGI-HMM"]}],y:{value:1.5*gC},size:{value:gC},color:{value:"#FF8C00"}},{...lV,mark:"rect",dataTransform:[{type:"filter",field:"Method",oneOf:["IslandPick"]}],y:{value:2.5*gC},size:{value:gC},color:{value:"#008001"}},{...lV,mark:"rect",dataTransform:[{type:"filter",field:"Method",oneOf:["Islander"]}],y:{value:3.5*gC},size:{value:gC},color:{value:"#40E0D0"}},{data:{url:"https://s3.amazonaws.com/gosling-lang.org/data/IslandViewer/NC_004631.1_annotations.csv",type:"csv",genomicFields:["Gene start"]},dataTransform:[{type:"displace",method:"pile",boundingBox:{padding:3.5,startField:"Gene start",endField:"Gene start"},newField:"row"}],row:{field:"row",type:"nominal"},mark:"point",x:{field:"Gene start",type:"genomic"},size:{value:3},color:{field:"Type",type:"nominal",domain:["Victors","BLAST","RGI","PAG"],range:["#460B80","#A684EA","#FF9CC1","#FF9CC1"]},tooltip:[{field:"Type",type:"nominal",alt:"Name"}]}],width:uKe*2,height:Ist}]};function Vsi(){const e=Ue.useRef(null),[g,i]=Ue.useState([]);Ue.useEffect(()=>{if(!e.current)return;const I=e.current;return I.api.subscribe("rawData",(r,o)=>{const C=I.hgApi.api.getLocation(PIe).xDomain;if(o.data.length>0&&o.id===PIe&&"Accnum"in o.data[0]){const A=o.data.filter(s=>s["Gene start"]>C[0]&&s["Gene start"]C[0]&&s["Gene end"]c.findIndex(u=>u["Gene name"]===s["Gene name"])===l);i(A)}}),()=>{I.api.unsubscribe("rawData")}},[]);const n=["Prediction Method","Gene name","Accnum","Product"];return k.createElement("div",{style:{display:"flex"}},k.createElement("div",{style:{display:"inline-block"}},k.createElement(tp,{padding:0,ref:e,spec:Rsi,experimental:{reactive:!0}})),g.length===0?null:k.createElement("div",{style:{height:window.innerHeight,overflowY:"scroll",display:"inline-block",flexGrow:1,marginLeft:"10px"}},k.createElement("table",{className:"table-fixed border-collapse border border-slate-400"},k.createElement("thead",{className:"capitalize"},k.createElement("tr",{className:"border border-slate-300 bg-slate-100"},n.map(I=>k.createElement("th",{className:"px-1",key:I},I)))),k.createElement("tbody",null,g.map(I=>k.createElement("tr",{className:"border border-slate-300",key:I["Gene name"]},n.map(r=>{let o="";return r==="Prediction Method"?I.Islands.length>0?I.Annotations.length>0?o=I.Islands+"/"+I.Annotations:o=I.Islands:I.Annotations.length>0&&(o=I.Annotations):o=I[r],k.createElement("td",{className:"px-1",key:r},o)})))))))}const I$=300,dKe=300;function Wsi(){const[e,g]=Ue.useState([]),[i,n]=Ue.useState(1),[I,r]=Ue.useState(dKe),o=Ue.useRef(null),C="goslingVis",a=Ue.useCallback(l=>{let c=l.data("leaves").slice();c.sort((u,d)=>u.x-d.x),g(c.map(u=>u.id)),n(Math.max(...c.map(u=>u.distance)))},[]);Ue.useEffect(()=>{if(!o.current)return;o.current.api.subscribe("rawData",()=>{const c=o.current.api.getTracks();r(c[c.map(u=>u.id).indexOf(C)].shape.height)});const l=o.current;return()=>{l.api.unsubscribe("rawData")}},[]);const A=Ue.useMemo(()=>({title:"GeneSpy + iTol",subtitle:"Genomic neighborhood visualization with aligned phylogenetic tree",description:"Idea: https://doi.org/10.1093/bioinformatics/bty459",assembly:[["",11e3]],static:!0,views:[{alignment:"overlay",data:{url:"https://s3.amazonaws.com/gosling-lang.org/data/GeneSpy/gene_spy_example.csv",type:"csv",genomicFields:["Gene start","Gene end"]},dataTransform:[{type:"genomicLength",startField:"Gene start",endField:"Gene end",newField:"Gene length"}],color:{field:"type",type:"nominal",domain:["anchor","conserved","disrupted"],range:["red","gray","yellow"]},id:C,row:{field:"Accession",type:"nominal",domain:e},tracks:[{dataTransform:[{type:"filter",field:"Strand",oneOf:["+"]}],mark:"triangleRight",style:{align:"right"},x:{field:"Gene start",type:"genomic",axis:"none"},xe:{field:"Gene end",type:"genomic"}},{dataTransform:[{type:"filter",field:"Strand",oneOf:["-"]}],mark:"triangleLeft",style:{align:"left"},x:{field:"Gene start",type:"genomic"},xe:{field:"Gene end",type:"genomic"}}],height:dKe}]}),[e]),s=Ue.useMemo(()=>({$schema:"https://vega.github.io/schema/vega/v5.json",description:"An example of Cartesian layouts for a node-link diagram of hierarchical data.",width:I$,height:I,padding:0,data:[{name:"tree",url:"https://s3.amazonaws.com/gosling-lang.org/data/GeneSpy/gene_spy_tree.json",transform:[{type:"stratify",key:"id",parentKey:"parent"},{type:"tree",method:"cluster",field:{field:"distance"},sort:{field:"value",order:"ascending"},size:[{signal:"height"},{signal:"width"}],separation:!1,as:["y","x","depth","children"]},{type:"formula",expr:"width * (datum.distance/"+i+")",as:"x"}]},{name:"leaves",source:"tree",transform:[{type:"filter",expr:"!datum.children"}]},{name:"links",source:"tree",transform:[{type:"treelinks"},{type:"linkpath",orient:"horizontal",shape:"orthogonal"}]}],marks:[{type:"path",from:{data:"links"},encode:{update:{path:{field:"path"},stroke:{value:"#000"}}}},{type:"rule",from:{data:"leaves"},encode:{update:{x:{field:"x"},y:{field:"y"},x2:{value:I$},y2:{field:"y"},stroke:{value:"#eee"}}}},{type:"text",from:{data:"leaves"},encode:{enter:{text:{field:"name"},fontSize:{value:9},baseline:{value:"middle"}},update:{x:{value:I$},y:{field:"y"},dx:{signal:"datum.children ? -7 : 7"},align:"left"}}}]}),[i,I]);return k.createElement(k.Fragment,null,k.createElement("div",{style:{display:"inline-block"}},k.createElement(Gme,{spec:s,onNewView:a,actions:!1})),k.createElement("div",{style:{display:"inline-block"}},k.createElement(tp,{ref:o,padding:0,spec:A,experimental:{reactive:!0}})))}const r$={Simple:Ue.createElement(Rkg,null),"Widget (Encoding)":Ue.createElement(Gsi,null),"Widget (Navigation)":Ue.createElement(Bsi,null),"Mouse Events":Ue.createElement(wsi,null),"Vega-Lite":Ue.createElement(psi,null),IslandViewer:Ue.createElement(Vsi,null),GeneSpy:Ue.createElement(Wsi,null)};function Xsi(){return Ue.createElement("div",{className:"flex flex-row h-full w-full"},Ue.createElement("div",{className:"flex-none border-r-[1px]"},Ue.createElement("div",{className:"font-bold font-lg m-3"},"Examples"),Ue.createElement("ol",{className:"list-decimal list-inside divide-y divide-solid"},Object.entries(r$).map(e=>Ue.createElement("li",{className:"p-3",key:e[0]},Ue.createElement(Ect,{className:"hover:underline",to:`/${e[0].replace(" ","_")}`},e[0]))))),Ue.createElement("div",{className:""},Ue.createElement(Tct,null,Ue.createElement(i8,{path:"/",element:r$.Simple}),Object.entries(r$).map(e=>Ue.createElement(i8,{key:e[0],path:`/${e[0].replace(" ","_")}`,element:e[1]})))))}const Tsi=o$.createRoot(document.getElementById("root"));Tsi.render(k.createElement(Kct,null,k.createElement(Xsi,null)));export{Pct as _,un as c,Ba as g}; diff --git a/assets/index-c064dc85.css b/assets/index-c064dc85.css new file mode 100644 index 0000000..54d67f7 --- /dev/null +++ b/assets/index-c064dc85.css @@ -0,0 +1 @@ +html,body,#root{height:100%;width:100%}body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale} diff --git a/assets/index.es-eac68d26.js b/assets/index.es-93d23083.js similarity index 99% rename from assets/index.es-eac68d26.js rename to assets/index.es-93d23083.js index 38a4f3a..3303cb7 100644 --- a/assets/index.es-eac68d26.js +++ b/assets/index.es-93d23083.js @@ -1,4 +1,4 @@ -import{c as Tt,g as Vo}from"./index-6614c9bf.js";import{_ as Ha}from"./jspdf.es.min-b9cca550.js";var Gt=function(a){return a&&a.Math==Math&&a},U=Gt(typeof globalThis=="object"&&globalThis)||Gt(typeof window=="object"&&window)||Gt(typeof self=="object"&&self)||Gt(typeof Tt=="object"&&Tt)||function(){return this}()||Tt||Function("return this")(),ot={},L=function(a){try{return!!a()}catch{return!0}},Nl=L,ce=!Nl(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),Ml=L,br=!Ml(function(){var a=function(){}.bind();return typeof a!="function"||a.hasOwnProperty("prototype")}),_l=br,Ht=Function.prototype.call,Y=_l?Ht.bind(Ht):function(){return Ht.apply(Ht,arguments)},Lo={},ko={}.propertyIsEnumerable,Bo=Object.getOwnPropertyDescriptor,Dl=Bo&&!ko.call({1:2},1);Lo.f=Dl?function(e){var t=Bo(this,e);return!!t&&t.enumerable}:ko;var xr=function(a,e){return{enumerable:!(a&1),configurable:!(a&2),writable:!(a&4),value:e}},Fo=br,jo=Function.prototype,Ya=jo.call,Vl=Fo&&jo.bind.bind(Ya,Ya),k=Fo?Vl:function(a){return function(){return Ya.apply(a,arguments)}},Uo=k,Ll=Uo({}.toString),kl=Uo("".slice),Fe=function(a){return kl(Ll(a),8,-1)},Bl=k,Fl=L,jl=Fe,Zr=Object,Ul=Bl("".split),zo=Fl(function(){return!Zr("z").propertyIsEnumerable(0)})?function(a){return jl(a)=="String"?Ul(a,""):Zr(a)}:Zr,je=function(a){return a==null},zl=je,Gl=TypeError,ge=function(a){if(zl(a))throw Gl("Can't call method on "+a);return a},Hl=zo,Yl=ge,wt=function(a){return Hl(Yl(a))},Xa=typeof document=="object"&&document.all,Xl=typeof Xa>"u"&&Xa!==void 0,Go={all:Xa,IS_HTMLDDA:Xl},Ho=Go,Wl=Ho.all,D=Ho.IS_HTMLDDA?function(a){return typeof a=="function"||a===Wl}:function(a){return typeof a=="function"},mn=D,Yo=Go,ql=Yo.all,Te=Yo.IS_HTMLDDA?function(a){return typeof a=="object"?a!==null:mn(a)||a===ql}:function(a){return typeof a=="object"?a!==null:mn(a)},Jr=U,Ql=D,Kl=function(a){return Ql(a)?a:void 0},Ue=function(a,e){return arguments.length<2?Kl(Jr[a]):Jr[a]&&Jr[a][e]},Zl=k,Tr=Zl({}.isPrototypeOf),Sr=typeof navigator<"u"&&String(navigator.userAgent)||"",Xo=U,ea=Sr,bn=Xo.process,xn=Xo.Deno,Tn=bn&&bn.versions||xn&&xn.version,Sn=Tn&&Tn.v8,ue,cr;Sn&&(ue=Sn.split("."),cr=ue[0]>0&&ue[0]<4?1:+(ue[0]+ue[1]));!cr&&ea&&(ue=ea.match(/Edge\/(\d+)/),(!ue||ue[1]>=74)&&(ue=ea.match(/Chrome\/(\d+)/),ue&&(cr=+ue[1])));var Oi=cr,On=Oi,Jl=L,eh=U,th=eh.String,Wo=!!Object.getOwnPropertySymbols&&!Jl(function(){var a=Symbol();return!th(a)||!(Object(a)instanceof Symbol)||!Symbol.sham&&On&&On<41}),rh=Wo,qo=rh&&!Symbol.sham&&typeof Symbol.iterator=="symbol",ah=Ue,ih=D,nh=Tr,sh=qo,oh=Object,Qo=sh?function(a){return typeof a=="symbol"}:function(a){var e=ah("Symbol");return ih(e)&&nh(e.prototype,oh(a))},uh=String,Or=function(a){try{return uh(a)}catch{return"Object"}},lh=D,hh=Or,vh=TypeError,Se=function(a){if(lh(a))return a;throw vh(hh(a)+" is not a function")},fh=Se,ch=je,ut=function(a,e){var t=a[e];return ch(t)?void 0:fh(t)},ta=Y,ra=D,aa=Te,gh=TypeError,dh=function(a,e){var t,r;if(e==="string"&&ra(t=a.toString)&&!aa(r=ta(t,a))||ra(t=a.valueOf)&&!aa(r=ta(t,a))||e!=="string"&&ra(t=a.toString)&&!aa(r=ta(t,a)))return r;throw gh("Can't convert object to primitive value")},Ko={exports:{}},En=U,ph=Object.defineProperty,Ei=function(a,e){try{ph(En,a,{value:e,configurable:!0,writable:!0})}catch{En[a]=e}return e},yh=U,mh=Ei,$n="__core-js_shared__",bh=yh[$n]||mh($n,{}),$i=bh,Cn=$i;(Ko.exports=function(a,e){return Cn[a]||(Cn[a]=e!==void 0?e:{})})("versions",[]).push({version:"3.30.2",mode:"global",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.30.2/LICENSE",source:"https://github.com/zloirock/core-js"});var Ci=Ko.exports,xh=ge,Th=Object,Er=function(a){return Th(xh(a))},Sh=k,Oh=Er,Eh=Sh({}.hasOwnProperty),le=Object.hasOwn||function(e,t){return Eh(Oh(e),t)},$h=k,Ch=0,wh=Math.random(),Ah=$h(1 .toString),Zo=function(a){return"Symbol("+(a===void 0?"":a)+")_"+Ah(++Ch+wh,36)},Ph=U,Rh=Ci,wn=le,Ih=Zo,Nh=Wo,Mh=qo,Je=Ph.Symbol,ia=Rh("wks"),_h=Mh?Je.for||Je:Je&&Je.withoutSetter||Ih,G=function(a){return wn(ia,a)||(ia[a]=Nh&&wn(Je,a)?Je[a]:_h("Symbol."+a)),ia[a]},Dh=Y,An=Te,Pn=Qo,Vh=ut,Lh=dh,kh=G,Bh=TypeError,Fh=kh("toPrimitive"),jh=function(a,e){if(!An(a)||Pn(a))return a;var t=Vh(a,Fh),r;if(t){if(e===void 0&&(e="default"),r=Dh(t,a,e),!An(r)||Pn(r))return r;throw Bh("Can't convert object to primitive value")}return e===void 0&&(e="number"),Lh(a,e)},Uh=jh,zh=Qo,wi=function(a){var e=Uh(a,"string");return zh(e)?e:e+""},Gh=U,Rn=Te,Wa=Gh.document,Hh=Rn(Wa)&&Rn(Wa.createElement),$r=function(a){return Hh?Wa.createElement(a):{}},Yh=ce,Xh=L,Wh=$r,Jo=!Yh&&!Xh(function(){return Object.defineProperty(Wh("div"),"a",{get:function(){return 7}}).a!=7}),qh=ce,Qh=Y,Kh=Lo,Zh=xr,Jh=wt,ev=wi,tv=le,rv=Jo,In=Object.getOwnPropertyDescriptor;ot.f=qh?In:function(e,t){if(e=Jh(e),t=ev(t),rv)try{return In(e,t)}catch{}if(tv(e,t))return Zh(!Qh(Kh.f,e,t),e[t])};var de={},av=ce,iv=L,eu=av&&iv(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),nv=Te,sv=String,ov=TypeError,K=function(a){if(nv(a))return a;throw ov(sv(a)+" is not an object")},uv=ce,lv=Jo,hv=eu,Yt=K,Nn=wi,vv=TypeError,na=Object.defineProperty,fv=Object.getOwnPropertyDescriptor,sa="enumerable",oa="configurable",ua="writable";de.f=uv?hv?function(e,t,r){if(Yt(e),t=Nn(t),Yt(r),typeof e=="function"&&t==="prototype"&&"value"in r&&ua in r&&!r[ua]){var i=fv(e,t);i&&i[ua]&&(e[t]=r.value,r={configurable:oa in r?r[oa]:i[oa],enumerable:sa in r?r[sa]:i[sa],writable:!1})}return na(e,t,r)}:na:function(e,t,r){if(Yt(e),t=Nn(t),Yt(r),lv)try{return na(e,t,r)}catch{}if("get"in r||"set"in r)throw vv("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var cv=ce,gv=de,dv=xr,At=cv?function(a,e,t){return gv.f(a,e,dv(1,t))}:function(a,e,t){return a[e]=t,a},tu={exports:{}},qa=ce,pv=le,ru=Function.prototype,yv=qa&&Object.getOwnPropertyDescriptor,Ai=pv(ru,"name"),mv=Ai&&function(){}.name==="something",bv=Ai&&(!qa||qa&&yv(ru,"name").configurable),Cr={EXISTS:Ai,PROPER:mv,CONFIGURABLE:bv},xv=k,Tv=D,Qa=$i,Sv=xv(Function.toString);Tv(Qa.inspectSource)||(Qa.inspectSource=function(a){return Sv(a)});var Pi=Qa.inspectSource,Ov=U,Ev=D,Mn=Ov.WeakMap,$v=Ev(Mn)&&/native code/.test(String(Mn)),Cv=Ci,wv=Zo,_n=Cv("keys"),Ri=function(a){return _n[a]||(_n[a]=wv(a))},Ii={},Av=$v,au=U,Pv=Te,Rv=At,la=le,ha=$i,Iv=Ri,Nv=Ii,Dn="Object already initialized",Ka=au.TypeError,Mv=au.WeakMap,gr,Et,dr,_v=function(a){return dr(a)?Et(a):gr(a,{})},Dv=function(a){return function(e){var t;if(!Pv(e)||(t=Et(e)).type!==a)throw Ka("Incompatible receiver, "+a+" required");return t}};if(Av||ha.state){var fe=ha.state||(ha.state=new Mv);fe.get=fe.get,fe.has=fe.has,fe.set=fe.set,gr=function(a,e){if(fe.has(a))throw Ka(Dn);return e.facade=a,fe.set(a,e),e},Et=function(a){return fe.get(a)||{}},dr=function(a){return fe.has(a)}}else{var Xe=Iv("state");Nv[Xe]=!0,gr=function(a,e){if(la(a,Xe))throw Ka(Dn);return e.facade=a,Rv(a,Xe,e),e},Et=function(a){return la(a,Xe)?a[Xe]:{}},dr=function(a){return la(a,Xe)}}var wr={set:gr,get:Et,has:dr,enforce:_v,getterFor:Dv},Ni=k,Vv=L,Lv=D,Xt=le,Za=ce,kv=Cr.CONFIGURABLE,Bv=Pi,iu=wr,Fv=iu.enforce,jv=iu.get,Vn=String,or=Object.defineProperty,Uv=Ni("".slice),zv=Ni("".replace),Gv=Ni([].join),Hv=Za&&!Vv(function(){return or(function(){},"length",{value:8}).length!==8}),Yv=String(String).split("String"),Xv=tu.exports=function(a,e,t){Uv(Vn(e),0,7)==="Symbol("&&(e="["+zv(Vn(e),/^Symbol\(([^)]*)\)/,"$1")+"]"),t&&t.getter&&(e="get "+e),t&&t.setter&&(e="set "+e),(!Xt(a,"name")||kv&&a.name!==e)&&(Za?or(a,"name",{value:e,configurable:!0}):a.name=e),Hv&&t&&Xt(t,"arity")&&a.length!==t.arity&&or(a,"length",{value:t.arity});try{t&&Xt(t,"constructor")&&t.constructor?Za&&or(a,"prototype",{writable:!1}):a.prototype&&(a.prototype=void 0)}catch{}var r=Fv(a);return Xt(r,"source")||(r.source=Gv(Yv,typeof e=="string"?e:"")),a};Function.prototype.toString=Xv(function(){return Lv(this)&&jv(this).source||Bv(this)},"toString");var nu=tu.exports,Wv=D,qv=de,Qv=nu,Kv=Ei,ze=function(a,e,t,r){r||(r={});var i=r.enumerable,n=r.name!==void 0?r.name:e;if(Wv(t)&&Qv(t,n,r),r.global)i?a[e]=t:Kv(e,t);else{try{r.unsafe?a[e]&&(i=!0):delete a[e]}catch{}i?a[e]=t:qv.f(a,e,{value:t,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return a},su={},Zv=Math.ceil,Jv=Math.floor,ef=Math.trunc||function(e){var t=+e;return(t>0?Jv:Zv)(t)},tf=ef,Ar=function(a){var e=+a;return e!==e||e===0?0:tf(e)},rf=Ar,af=Math.max,nf=Math.min,ou=function(a,e){var t=rf(a);return t<0?af(t+e,0):nf(t,e)},sf=Ar,of=Math.min,lt=function(a){return a>0?of(sf(a),9007199254740991):0},uf=lt,Pr=function(a){return uf(a.length)},lf=wt,hf=ou,vf=Pr,Ln=function(a){return function(e,t,r){var i=lf(e),n=vf(i),o=hf(r,n),s;if(a&&t!=t){for(;n>o;)if(s=i[o++],s!=s)return!0}else for(;n>o;o++)if((a||o in i)&&i[o]===t)return a||o||0;return!a&&-1}},uu={includes:Ln(!0),indexOf:Ln(!1)},ff=k,va=le,cf=wt,gf=uu.indexOf,df=Ii,kn=ff([].push),lu=function(a,e){var t=cf(a),r=0,i=[],n;for(n in t)!va(df,n)&&va(t,n)&&kn(i,n);for(;e.length>r;)va(t,n=e[r++])&&(~gf(i,n)||kn(i,n));return i},Mi=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],pf=lu,yf=Mi,mf=yf.concat("length","prototype");su.f=Object.getOwnPropertyNames||function(e){return pf(e,mf)};var hu={};hu.f=Object.getOwnPropertySymbols;var bf=Ue,xf=k,Tf=su,Sf=hu,Of=K,Ef=xf([].concat),$f=bf("Reflect","ownKeys")||function(e){var t=Tf.f(Of(e)),r=Sf.f;return r?Ef(t,r(e)):t},Bn=le,Cf=$f,wf=ot,Af=de,Pf=function(a,e,t){for(var r=Cf(e),i=Af.f,n=wf.f,o=0;of;f++)if(v=y(a[f]),v&&ds(ys,v))return v;return new hr(!1)}l=Cd(a,h)}for(d=n?a.next:l.next;!(g=Td(d,l)).done;){try{v=y(g.value)}catch(x){ps(l,"throw",x)}if(typeof v=="object"&&v&&ds(ys,v))return v}return new hr(!1)},Pd=G,Uu=Pd("iterator"),zu=!1;try{var Rd=0,ms={next:function(){return{done:!!Rd++}},return:function(){zu=!0}};ms[Uu]=function(){return this},Array.from(ms,function(){throw 2})}catch{}var Id=function(a,e){if(!e&&!zu)return!1;var t=!1;try{var r={};r[Uu]=function(){return{next:function(){return{done:t=!0}}}},a(r)}catch{}return t},Nd=Rr,Md=Id,_d=Nt.CONSTRUCTOR,Gu=_d||!Md(function(a){Nd.all(a).then(void 0,function(){})}),Dd=ee,Vd=Y,Ld=Se,kd=ht,Bd=Fi,Fd=ju,jd=Gu;Dd({target:"Promise",stat:!0,forced:jd},{all:function(e){var t=this,r=kd.f(t),i=r.resolve,n=r.reject,o=Bd(function(){var s=Ld(t.resolve),u=[],l=0,h=1;Fd(e,function(f){var c=l++,v=!1;h++,Vd(s,t,f).then(function(d){v||(v=!0,u[c]=d,--h||i(u))},n)}),--h||i(u)});return o.error&&n(o.value),r.promise}});var Ud=ee,zd=Nt.CONSTRUCTOR,si=Rr,Gd=Ue,Hd=D,Yd=ze,bs=si&&si.prototype;Ud({target:"Promise",proto:!0,forced:zd,real:!0},{catch:function(a){return this.then(void 0,a)}});if(Hd(si)){var xs=Gd("Promise").prototype.catch;bs.catch!==xs&&Yd(bs,"catch",xs,{unsafe:!0})}var Xd=ee,Wd=Y,qd=Se,Qd=ht,Kd=Fi,Zd=ju,Jd=Gu;Xd({target:"Promise",stat:!0,forced:Jd},{race:function(e){var t=this,r=Qd.f(t),i=r.reject,n=Kd(function(){var o=qd(t.resolve);Zd(e,function(s){Wd(o,t,s).then(r.resolve,i)})});return n.error&&i(n.value),r.promise}});var ep=ee,tp=Y,rp=ht,ap=Nt.CONSTRUCTOR;ep({target:"Promise",stat:!0,forced:ap},{reject:function(e){var t=rp.f(this);return tp(t.reject,void 0,e),t.promise}});var ip=K,np=Te,sp=ht,op=function(a,e){if(ip(a),np(e)&&e.constructor===a)return e;var t=sp.f(a),r=t.resolve;return r(e),t.promise},up=ee,lp=Ue,hp=Nt.CONSTRUCTOR,vp=op;lp("Promise");up({target:"Promise",stat:!0,forced:hp},{resolve:function(e){return vp(this,e)}});function Ts(a,e,t,r,i,n,o){try{var s=a[n](o),u=s.value}catch(l){t(l);return}s.done?e(u):Promise.resolve(u).then(r,i)}function xe(a){return function(){var e=this,t=arguments;return new Promise(function(r,i){var n=a.apply(e,t);function o(u){Ts(n,r,i,o,s,"next",u)}function s(u){Ts(n,r,i,o,s,"throw",u)}o(void 0)})}}var fp=Di,cp=String,pe=function(a){if(fp(a)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return cp(a)},gp=K,Hu=function(){var a=gp(this),e="";return a.hasIndices&&(e+="d"),a.global&&(e+="g"),a.ignoreCase&&(e+="i"),a.multiline&&(e+="m"),a.dotAll&&(e+="s"),a.unicode&&(e+="u"),a.unicodeSets&&(e+="v"),a.sticky&&(e+="y"),e},Hi=L,dp=U,Yi=dp.RegExp,Xi=Hi(function(){var a=Yi("a","y");return a.lastIndex=2,a.exec("abcd")!=null}),pp=Xi||Hi(function(){return!Yi("a","y").sticky}),yp=Xi||Hi(function(){var a=Yi("^r","gy");return a.lastIndex=2,a.exec("str")!=null}),Yu={BROKEN_CARET:yp,MISSED_STICKY:pp,UNSUPPORTED_Y:Xi},Xu={},mp=lu,bp=Mi,xp=Object.keys||function(e){return mp(e,bp)},Tp=ce,Sp=eu,Op=de,Ep=K,$p=wt,Cp=xp;Xu.f=Tp&&!Sp?Object.defineProperties:function(e,t){Ep(e);for(var r=$p(t),i=Cp(t),n=i.length,o=0,s;n>o;)Op.f(e,s=i[o++],r[s]);return e};var wp=K,Ap=Xu,Ss=Mi,Pp=Ii,Rp=xu,Ip=$r,Np=Ri,Os=">",Es="<",oi="prototype",ui="script",Wu=Np("IE_PROTO"),Ea=function(){},qu=function(a){return Es+ui+Os+a+Es+"/"+ui+Os},$s=function(a){a.write(qu("")),a.close();var e=a.parentWindow.Object;return a=null,e},Mp=function(){var a=Ip("iframe"),e="java"+ui+":",t;return a.style.display="none",Rp.appendChild(a),a.src=String(e),t=a.contentWindow.document,t.open(),t.write(qu("document.F=Object")),t.close(),t.F},er,vr=function(){try{er=new ActiveXObject("htmlfile")}catch{}vr=typeof document<"u"?document.domain&&er?$s(er):Mp():$s(er);for(var a=Ss.length;a--;)delete vr[oi][Ss[a]];return vr()};Pp[Wu]=!0;var Wi=Object.create||function(e,t){var r;return e!==null?(Ea[oi]=wp(e),r=new Ea,Ea[oi]=null,r[Wu]=e):r=vr(),t===void 0?r:Ap.f(r,t)},_p=L,Dp=U,Vp=Dp.RegExp,Lp=_p(function(){var a=Vp(".","s");return!(a.dotAll&&a.exec(` +import{c as Tt,g as Vo}from"./index-84a3106f.js";import{_ as Ha}from"./jspdf.es.min-fee19fbe.js";var Gt=function(a){return a&&a.Math==Math&&a},U=Gt(typeof globalThis=="object"&&globalThis)||Gt(typeof window=="object"&&window)||Gt(typeof self=="object"&&self)||Gt(typeof Tt=="object"&&Tt)||function(){return this}()||Tt||Function("return this")(),ot={},L=function(a){try{return!!a()}catch{return!0}},Nl=L,ce=!Nl(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),Ml=L,br=!Ml(function(){var a=function(){}.bind();return typeof a!="function"||a.hasOwnProperty("prototype")}),_l=br,Ht=Function.prototype.call,Y=_l?Ht.bind(Ht):function(){return Ht.apply(Ht,arguments)},Lo={},ko={}.propertyIsEnumerable,Bo=Object.getOwnPropertyDescriptor,Dl=Bo&&!ko.call({1:2},1);Lo.f=Dl?function(e){var t=Bo(this,e);return!!t&&t.enumerable}:ko;var xr=function(a,e){return{enumerable:!(a&1),configurable:!(a&2),writable:!(a&4),value:e}},Fo=br,jo=Function.prototype,Ya=jo.call,Vl=Fo&&jo.bind.bind(Ya,Ya),k=Fo?Vl:function(a){return function(){return Ya.apply(a,arguments)}},Uo=k,Ll=Uo({}.toString),kl=Uo("".slice),Fe=function(a){return kl(Ll(a),8,-1)},Bl=k,Fl=L,jl=Fe,Zr=Object,Ul=Bl("".split),zo=Fl(function(){return!Zr("z").propertyIsEnumerable(0)})?function(a){return jl(a)=="String"?Ul(a,""):Zr(a)}:Zr,je=function(a){return a==null},zl=je,Gl=TypeError,ge=function(a){if(zl(a))throw Gl("Can't call method on "+a);return a},Hl=zo,Yl=ge,wt=function(a){return Hl(Yl(a))},Xa=typeof document=="object"&&document.all,Xl=typeof Xa>"u"&&Xa!==void 0,Go={all:Xa,IS_HTMLDDA:Xl},Ho=Go,Wl=Ho.all,D=Ho.IS_HTMLDDA?function(a){return typeof a=="function"||a===Wl}:function(a){return typeof a=="function"},mn=D,Yo=Go,ql=Yo.all,Te=Yo.IS_HTMLDDA?function(a){return typeof a=="object"?a!==null:mn(a)||a===ql}:function(a){return typeof a=="object"?a!==null:mn(a)},Jr=U,Ql=D,Kl=function(a){return Ql(a)?a:void 0},Ue=function(a,e){return arguments.length<2?Kl(Jr[a]):Jr[a]&&Jr[a][e]},Zl=k,Tr=Zl({}.isPrototypeOf),Sr=typeof navigator<"u"&&String(navigator.userAgent)||"",Xo=U,ea=Sr,bn=Xo.process,xn=Xo.Deno,Tn=bn&&bn.versions||xn&&xn.version,Sn=Tn&&Tn.v8,ue,cr;Sn&&(ue=Sn.split("."),cr=ue[0]>0&&ue[0]<4?1:+(ue[0]+ue[1]));!cr&&ea&&(ue=ea.match(/Edge\/(\d+)/),(!ue||ue[1]>=74)&&(ue=ea.match(/Chrome\/(\d+)/),ue&&(cr=+ue[1])));var Oi=cr,On=Oi,Jl=L,eh=U,th=eh.String,Wo=!!Object.getOwnPropertySymbols&&!Jl(function(){var a=Symbol();return!th(a)||!(Object(a)instanceof Symbol)||!Symbol.sham&&On&&On<41}),rh=Wo,qo=rh&&!Symbol.sham&&typeof Symbol.iterator=="symbol",ah=Ue,ih=D,nh=Tr,sh=qo,oh=Object,Qo=sh?function(a){return typeof a=="symbol"}:function(a){var e=ah("Symbol");return ih(e)&&nh(e.prototype,oh(a))},uh=String,Or=function(a){try{return uh(a)}catch{return"Object"}},lh=D,hh=Or,vh=TypeError,Se=function(a){if(lh(a))return a;throw vh(hh(a)+" is not a function")},fh=Se,ch=je,ut=function(a,e){var t=a[e];return ch(t)?void 0:fh(t)},ta=Y,ra=D,aa=Te,gh=TypeError,dh=function(a,e){var t,r;if(e==="string"&&ra(t=a.toString)&&!aa(r=ta(t,a))||ra(t=a.valueOf)&&!aa(r=ta(t,a))||e!=="string"&&ra(t=a.toString)&&!aa(r=ta(t,a)))return r;throw gh("Can't convert object to primitive value")},Ko={exports:{}},En=U,ph=Object.defineProperty,Ei=function(a,e){try{ph(En,a,{value:e,configurable:!0,writable:!0})}catch{En[a]=e}return e},yh=U,mh=Ei,$n="__core-js_shared__",bh=yh[$n]||mh($n,{}),$i=bh,Cn=$i;(Ko.exports=function(a,e){return Cn[a]||(Cn[a]=e!==void 0?e:{})})("versions",[]).push({version:"3.30.2",mode:"global",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.30.2/LICENSE",source:"https://github.com/zloirock/core-js"});var Ci=Ko.exports,xh=ge,Th=Object,Er=function(a){return Th(xh(a))},Sh=k,Oh=Er,Eh=Sh({}.hasOwnProperty),le=Object.hasOwn||function(e,t){return Eh(Oh(e),t)},$h=k,Ch=0,wh=Math.random(),Ah=$h(1 .toString),Zo=function(a){return"Symbol("+(a===void 0?"":a)+")_"+Ah(++Ch+wh,36)},Ph=U,Rh=Ci,wn=le,Ih=Zo,Nh=Wo,Mh=qo,Je=Ph.Symbol,ia=Rh("wks"),_h=Mh?Je.for||Je:Je&&Je.withoutSetter||Ih,G=function(a){return wn(ia,a)||(ia[a]=Nh&&wn(Je,a)?Je[a]:_h("Symbol."+a)),ia[a]},Dh=Y,An=Te,Pn=Qo,Vh=ut,Lh=dh,kh=G,Bh=TypeError,Fh=kh("toPrimitive"),jh=function(a,e){if(!An(a)||Pn(a))return a;var t=Vh(a,Fh),r;if(t){if(e===void 0&&(e="default"),r=Dh(t,a,e),!An(r)||Pn(r))return r;throw Bh("Can't convert object to primitive value")}return e===void 0&&(e="number"),Lh(a,e)},Uh=jh,zh=Qo,wi=function(a){var e=Uh(a,"string");return zh(e)?e:e+""},Gh=U,Rn=Te,Wa=Gh.document,Hh=Rn(Wa)&&Rn(Wa.createElement),$r=function(a){return Hh?Wa.createElement(a):{}},Yh=ce,Xh=L,Wh=$r,Jo=!Yh&&!Xh(function(){return Object.defineProperty(Wh("div"),"a",{get:function(){return 7}}).a!=7}),qh=ce,Qh=Y,Kh=Lo,Zh=xr,Jh=wt,ev=wi,tv=le,rv=Jo,In=Object.getOwnPropertyDescriptor;ot.f=qh?In:function(e,t){if(e=Jh(e),t=ev(t),rv)try{return In(e,t)}catch{}if(tv(e,t))return Zh(!Qh(Kh.f,e,t),e[t])};var de={},av=ce,iv=L,eu=av&&iv(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),nv=Te,sv=String,ov=TypeError,K=function(a){if(nv(a))return a;throw ov(sv(a)+" is not an object")},uv=ce,lv=Jo,hv=eu,Yt=K,Nn=wi,vv=TypeError,na=Object.defineProperty,fv=Object.getOwnPropertyDescriptor,sa="enumerable",oa="configurable",ua="writable";de.f=uv?hv?function(e,t,r){if(Yt(e),t=Nn(t),Yt(r),typeof e=="function"&&t==="prototype"&&"value"in r&&ua in r&&!r[ua]){var i=fv(e,t);i&&i[ua]&&(e[t]=r.value,r={configurable:oa in r?r[oa]:i[oa],enumerable:sa in r?r[sa]:i[sa],writable:!1})}return na(e,t,r)}:na:function(e,t,r){if(Yt(e),t=Nn(t),Yt(r),lv)try{return na(e,t,r)}catch{}if("get"in r||"set"in r)throw vv("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var cv=ce,gv=de,dv=xr,At=cv?function(a,e,t){return gv.f(a,e,dv(1,t))}:function(a,e,t){return a[e]=t,a},tu={exports:{}},qa=ce,pv=le,ru=Function.prototype,yv=qa&&Object.getOwnPropertyDescriptor,Ai=pv(ru,"name"),mv=Ai&&function(){}.name==="something",bv=Ai&&(!qa||qa&&yv(ru,"name").configurable),Cr={EXISTS:Ai,PROPER:mv,CONFIGURABLE:bv},xv=k,Tv=D,Qa=$i,Sv=xv(Function.toString);Tv(Qa.inspectSource)||(Qa.inspectSource=function(a){return Sv(a)});var Pi=Qa.inspectSource,Ov=U,Ev=D,Mn=Ov.WeakMap,$v=Ev(Mn)&&/native code/.test(String(Mn)),Cv=Ci,wv=Zo,_n=Cv("keys"),Ri=function(a){return _n[a]||(_n[a]=wv(a))},Ii={},Av=$v,au=U,Pv=Te,Rv=At,la=le,ha=$i,Iv=Ri,Nv=Ii,Dn="Object already initialized",Ka=au.TypeError,Mv=au.WeakMap,gr,Et,dr,_v=function(a){return dr(a)?Et(a):gr(a,{})},Dv=function(a){return function(e){var t;if(!Pv(e)||(t=Et(e)).type!==a)throw Ka("Incompatible receiver, "+a+" required");return t}};if(Av||ha.state){var fe=ha.state||(ha.state=new Mv);fe.get=fe.get,fe.has=fe.has,fe.set=fe.set,gr=function(a,e){if(fe.has(a))throw Ka(Dn);return e.facade=a,fe.set(a,e),e},Et=function(a){return fe.get(a)||{}},dr=function(a){return fe.has(a)}}else{var Xe=Iv("state");Nv[Xe]=!0,gr=function(a,e){if(la(a,Xe))throw Ka(Dn);return e.facade=a,Rv(a,Xe,e),e},Et=function(a){return la(a,Xe)?a[Xe]:{}},dr=function(a){return la(a,Xe)}}var wr={set:gr,get:Et,has:dr,enforce:_v,getterFor:Dv},Ni=k,Vv=L,Lv=D,Xt=le,Za=ce,kv=Cr.CONFIGURABLE,Bv=Pi,iu=wr,Fv=iu.enforce,jv=iu.get,Vn=String,or=Object.defineProperty,Uv=Ni("".slice),zv=Ni("".replace),Gv=Ni([].join),Hv=Za&&!Vv(function(){return or(function(){},"length",{value:8}).length!==8}),Yv=String(String).split("String"),Xv=tu.exports=function(a,e,t){Uv(Vn(e),0,7)==="Symbol("&&(e="["+zv(Vn(e),/^Symbol\(([^)]*)\)/,"$1")+"]"),t&&t.getter&&(e="get "+e),t&&t.setter&&(e="set "+e),(!Xt(a,"name")||kv&&a.name!==e)&&(Za?or(a,"name",{value:e,configurable:!0}):a.name=e),Hv&&t&&Xt(t,"arity")&&a.length!==t.arity&&or(a,"length",{value:t.arity});try{t&&Xt(t,"constructor")&&t.constructor?Za&&or(a,"prototype",{writable:!1}):a.prototype&&(a.prototype=void 0)}catch{}var r=Fv(a);return Xt(r,"source")||(r.source=Gv(Yv,typeof e=="string"?e:"")),a};Function.prototype.toString=Xv(function(){return Lv(this)&&jv(this).source||Bv(this)},"toString");var nu=tu.exports,Wv=D,qv=de,Qv=nu,Kv=Ei,ze=function(a,e,t,r){r||(r={});var i=r.enumerable,n=r.name!==void 0?r.name:e;if(Wv(t)&&Qv(t,n,r),r.global)i?a[e]=t:Kv(e,t);else{try{r.unsafe?a[e]&&(i=!0):delete a[e]}catch{}i?a[e]=t:qv.f(a,e,{value:t,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return a},su={},Zv=Math.ceil,Jv=Math.floor,ef=Math.trunc||function(e){var t=+e;return(t>0?Jv:Zv)(t)},tf=ef,Ar=function(a){var e=+a;return e!==e||e===0?0:tf(e)},rf=Ar,af=Math.max,nf=Math.min,ou=function(a,e){var t=rf(a);return t<0?af(t+e,0):nf(t,e)},sf=Ar,of=Math.min,lt=function(a){return a>0?of(sf(a),9007199254740991):0},uf=lt,Pr=function(a){return uf(a.length)},lf=wt,hf=ou,vf=Pr,Ln=function(a){return function(e,t,r){var i=lf(e),n=vf(i),o=hf(r,n),s;if(a&&t!=t){for(;n>o;)if(s=i[o++],s!=s)return!0}else for(;n>o;o++)if((a||o in i)&&i[o]===t)return a||o||0;return!a&&-1}},uu={includes:Ln(!0),indexOf:Ln(!1)},ff=k,va=le,cf=wt,gf=uu.indexOf,df=Ii,kn=ff([].push),lu=function(a,e){var t=cf(a),r=0,i=[],n;for(n in t)!va(df,n)&&va(t,n)&&kn(i,n);for(;e.length>r;)va(t,n=e[r++])&&(~gf(i,n)||kn(i,n));return i},Mi=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],pf=lu,yf=Mi,mf=yf.concat("length","prototype");su.f=Object.getOwnPropertyNames||function(e){return pf(e,mf)};var hu={};hu.f=Object.getOwnPropertySymbols;var bf=Ue,xf=k,Tf=su,Sf=hu,Of=K,Ef=xf([].concat),$f=bf("Reflect","ownKeys")||function(e){var t=Tf.f(Of(e)),r=Sf.f;return r?Ef(t,r(e)):t},Bn=le,Cf=$f,wf=ot,Af=de,Pf=function(a,e,t){for(var r=Cf(e),i=Af.f,n=wf.f,o=0;of;f++)if(v=y(a[f]),v&&ds(ys,v))return v;return new hr(!1)}l=Cd(a,h)}for(d=n?a.next:l.next;!(g=Td(d,l)).done;){try{v=y(g.value)}catch(x){ps(l,"throw",x)}if(typeof v=="object"&&v&&ds(ys,v))return v}return new hr(!1)},Pd=G,Uu=Pd("iterator"),zu=!1;try{var Rd=0,ms={next:function(){return{done:!!Rd++}},return:function(){zu=!0}};ms[Uu]=function(){return this},Array.from(ms,function(){throw 2})}catch{}var Id=function(a,e){if(!e&&!zu)return!1;var t=!1;try{var r={};r[Uu]=function(){return{next:function(){return{done:t=!0}}}},a(r)}catch{}return t},Nd=Rr,Md=Id,_d=Nt.CONSTRUCTOR,Gu=_d||!Md(function(a){Nd.all(a).then(void 0,function(){})}),Dd=ee,Vd=Y,Ld=Se,kd=ht,Bd=Fi,Fd=ju,jd=Gu;Dd({target:"Promise",stat:!0,forced:jd},{all:function(e){var t=this,r=kd.f(t),i=r.resolve,n=r.reject,o=Bd(function(){var s=Ld(t.resolve),u=[],l=0,h=1;Fd(e,function(f){var c=l++,v=!1;h++,Vd(s,t,f).then(function(d){v||(v=!0,u[c]=d,--h||i(u))},n)}),--h||i(u)});return o.error&&n(o.value),r.promise}});var Ud=ee,zd=Nt.CONSTRUCTOR,si=Rr,Gd=Ue,Hd=D,Yd=ze,bs=si&&si.prototype;Ud({target:"Promise",proto:!0,forced:zd,real:!0},{catch:function(a){return this.then(void 0,a)}});if(Hd(si)){var xs=Gd("Promise").prototype.catch;bs.catch!==xs&&Yd(bs,"catch",xs,{unsafe:!0})}var Xd=ee,Wd=Y,qd=Se,Qd=ht,Kd=Fi,Zd=ju,Jd=Gu;Xd({target:"Promise",stat:!0,forced:Jd},{race:function(e){var t=this,r=Qd.f(t),i=r.reject,n=Kd(function(){var o=qd(t.resolve);Zd(e,function(s){Wd(o,t,s).then(r.resolve,i)})});return n.error&&i(n.value),r.promise}});var ep=ee,tp=Y,rp=ht,ap=Nt.CONSTRUCTOR;ep({target:"Promise",stat:!0,forced:ap},{reject:function(e){var t=rp.f(this);return tp(t.reject,void 0,e),t.promise}});var ip=K,np=Te,sp=ht,op=function(a,e){if(ip(a),np(e)&&e.constructor===a)return e;var t=sp.f(a),r=t.resolve;return r(e),t.promise},up=ee,lp=Ue,hp=Nt.CONSTRUCTOR,vp=op;lp("Promise");up({target:"Promise",stat:!0,forced:hp},{resolve:function(e){return vp(this,e)}});function Ts(a,e,t,r,i,n,o){try{var s=a[n](o),u=s.value}catch(l){t(l);return}s.done?e(u):Promise.resolve(u).then(r,i)}function xe(a){return function(){var e=this,t=arguments;return new Promise(function(r,i){var n=a.apply(e,t);function o(u){Ts(n,r,i,o,s,"next",u)}function s(u){Ts(n,r,i,o,s,"throw",u)}o(void 0)})}}var fp=Di,cp=String,pe=function(a){if(fp(a)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return cp(a)},gp=K,Hu=function(){var a=gp(this),e="";return a.hasIndices&&(e+="d"),a.global&&(e+="g"),a.ignoreCase&&(e+="i"),a.multiline&&(e+="m"),a.dotAll&&(e+="s"),a.unicode&&(e+="u"),a.unicodeSets&&(e+="v"),a.sticky&&(e+="y"),e},Hi=L,dp=U,Yi=dp.RegExp,Xi=Hi(function(){var a=Yi("a","y");return a.lastIndex=2,a.exec("abcd")!=null}),pp=Xi||Hi(function(){return!Yi("a","y").sticky}),yp=Xi||Hi(function(){var a=Yi("^r","gy");return a.lastIndex=2,a.exec("str")!=null}),Yu={BROKEN_CARET:yp,MISSED_STICKY:pp,UNSUPPORTED_Y:Xi},Xu={},mp=lu,bp=Mi,xp=Object.keys||function(e){return mp(e,bp)},Tp=ce,Sp=eu,Op=de,Ep=K,$p=wt,Cp=xp;Xu.f=Tp&&!Sp?Object.defineProperties:function(e,t){Ep(e);for(var r=$p(t),i=Cp(t),n=i.length,o=0,s;n>o;)Op.f(e,s=i[o++],r[s]);return e};var wp=K,Ap=Xu,Ss=Mi,Pp=Ii,Rp=xu,Ip=$r,Np=Ri,Os=">",Es="<",oi="prototype",ui="script",Wu=Np("IE_PROTO"),Ea=function(){},qu=function(a){return Es+ui+Os+a+Es+"/"+ui+Os},$s=function(a){a.write(qu("")),a.close();var e=a.parentWindow.Object;return a=null,e},Mp=function(){var a=Ip("iframe"),e="java"+ui+":",t;return a.style.display="none",Rp.appendChild(a),a.src=String(e),t=a.contentWindow.document,t.open(),t.write(qu("document.F=Object")),t.close(),t.F},er,vr=function(){try{er=new ActiveXObject("htmlfile")}catch{}vr=typeof document<"u"?document.domain&&er?$s(er):Mp():$s(er);for(var a=Ss.length;a--;)delete vr[oi][Ss[a]];return vr()};Pp[Wu]=!0;var Wi=Object.create||function(e,t){var r;return e!==null?(Ea[oi]=wp(e),r=new Ea,Ea[oi]=null,r[Wu]=e):r=vr(),t===void 0?r:Ap.f(r,t)},_p=L,Dp=U,Vp=Dp.RegExp,Lp=_p(function(){var a=Vp(".","s");return!(a.dotAll&&a.exec(` `)&&a.flags==="s")}),kp=L,Bp=U,Fp=Bp.RegExp,jp=kp(function(){var a=Fp("(?b)","g");return a.exec("b").groups.a!=="b"||"b".replace(a,"$c")!=="bc"}),tt=Y,Nr=k,Up=pe,zp=Hu,Gp=Yu,Hp=Ci,Yp=Wi,Xp=wr.get,Wp=Lp,qp=jp,Qp=Hp("native-string-replace",String.prototype.replace),mr=RegExp.prototype.exec,li=mr,Kp=Nr("".charAt),Zp=Nr("".indexOf),Jp=Nr("".replace),$a=Nr("".slice),hi=function(){var a=/a/,e=/b*/g;return tt(mr,a,"a"),tt(mr,e,"a"),a.lastIndex!==0||e.lastIndex!==0}(),Qu=Gp.BROKEN_CARET,vi=/()??/.exec("")[1]!==void 0,ey=hi||vi||Qu||Wp||qp;ey&&(li=function(e){var t=this,r=Xp(t),i=Up(e),n=r.raw,o,s,u,l,h,f,c;if(n)return n.lastIndex=t.lastIndex,o=tt(li,n,i),t.lastIndex=n.lastIndex,o;var v=r.groups,d=Qu&&t.sticky,g=tt(zp,t),p=t.source,y=0,x=i;if(d&&(g=Jp(g,"y",""),Zp(g,"g")===-1&&(g+="g"),x=$a(i,t.lastIndex),t.lastIndex>0&&(!t.multiline||t.multiline&&Kp(i,t.lastIndex-1)!==` `)&&(p="(?: "+p+")",x=" "+x,y++),s=new RegExp("^(?:"+p+")",g)),vi&&(s=new RegExp("^"+p+"$(?!\\s)",g)),hi&&(u=t.lastIndex),l=tt(mr,d?s:t,x),d?l?(l.input=$a(l.input,y),l[0]=$a(l[0],y),l.index=t.lastIndex,t.lastIndex+=l[0].length):t.lastIndex=0:hi&&l&&(t.lastIndex=t.global?l.index+l[0].length:u),vi&&l&&l.length>1&&tt(Qp,l[0],s,function(){for(h=1;h=n?a?"":void 0:(o=Rs(r,i),o<55296||o>56319||i+1===n||(s=Rs(r,i+1))<56320||s>57343?a?uy(r,i):o:a?ly(r,i,i+2):(o-55296<<10)+(s-56320)+65536)}},hy={codeAt:Is(!1),charAt:Is(!0)},vy=hy.charAt,Ki=function(a,e,t){return e+(t?vy(a,e).length:1)},Ns=Y,fy=K,cy=D,gy=Fe,dy=Mr,py=TypeError,Zi=function(a,e){var t=a.exec;if(cy(t)){var r=Ns(t,a,e);return r!==null&&fy(r),r}if(gy(a)==="RegExp")return Ns(dy,a,e);throw py("RegExp#exec called on incompatible receiver")},yy=Y,my=qi,by=K,xy=je,Ty=lt,wa=pe,Sy=ge,Oy=ut,Ey=Ki,Ms=Zi;my("match",function(a,e,t){return[function(i){var n=Sy(this),o=xy(i)?void 0:Oy(i,a);return o?yy(o,i,n):new RegExp(i)[a](wa(n))},function(r){var i=by(this),n=wa(r),o=t(e,i,n);if(o.done)return o.value;if(!i.global)return Ms(i,n);var s=i.unicode;i.lastIndex=0;for(var u=[],l=0,h;(h=Ms(i,n))!==null;){var f=wa(h[0]);u[l]=f,f===""&&(i.lastIndex=Ey(n,Ty(i.lastIndex),s)),l++}return l===0?null:u}]});var Ji=k,$y=Er,Cy=Math.floor,Aa=Ji("".charAt),wy=Ji("".replace),Pa=Ji("".slice),Ay=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,Py=/\$([$&'`]|\d{1,2})/g,Ry=function(a,e,t,r,i,n){var o=t+a.length,s=r.length,u=Py;return i!==void 0&&(i=$y(i),u=Ay),wy(n,u,function(l,h){var f;switch(Aa(h,0)){case"$":return"$";case"&":return a;case"`":return Pa(e,0,t);case"'":return Pa(e,o);case"<":f=i[Pa(h,1,-1)];break;default:var c=+h;if(c===0)return l;if(c>s){var v=Cy(c/10);return v===0?l:v<=s?r[v-1]===void 0?Aa(h,1):r[v-1]+Aa(h,1):l}f=r[c-1]}return f===void 0?"":f})},Iy=Li,_s=Y,_r=k,Ny=qi,My=L,_y=K,Dy=D,Vy=je,Ly=Ar,ky=lt,qe=pe,By=ge,Fy=Ki,jy=ut,Uy=Ry,zy=Zi,Gy=G,fi=Gy("replace"),Hy=Math.max,Yy=Math.min,Xy=_r([].concat),Ra=_r([].push),Ds=_r("".indexOf),Vs=_r("".slice),Wy=function(a){return a===void 0?a:String(a)},qy=function(){return"a".replace(/./,"$0")==="$0"}(),Ls=function(){return/./[fi]?/./[fi]("a","$0")==="":!1}(),Qy=!My(function(){var a=/./;return a.exec=function(){var e=[];return e.groups={a:"7"},e},"".replace(a,"$")!=="7"});Ny("replace",function(a,e,t){var r=Ls?"$":"$0";return[function(n,o){var s=By(this),u=Vy(n)?void 0:jy(n,fi);return u?_s(u,n,s,o):_s(e,qe(s),n,o)},function(i,n){var o=_y(this),s=qe(i);if(typeof n=="string"&&Ds(n,r)===-1&&Ds(n,"$<")===-1){var u=t(e,o,s,n);if(u.done)return u.value}var l=Dy(n);l||(n=qe(n));var h=o.global;if(h){var f=o.unicode;o.lastIndex=0}for(var c=[];;){var v=zy(o,s);if(v===null||(Ra(c,v),!h))break;var d=qe(v[0]);d===""&&(o.lastIndex=Fy(s,ky(o.lastIndex),f))}for(var g="",p=0,y=0;y=p&&(g+=Vs(s,p,b)+w,p=b+x.length)}return g+Vs(s,p)}]},!Qy||!qy||Ls);var Ky=Te,Zy=Fe,Jy=G,em=Jy("match"),Zu=function(a){var e;return Ky(a)&&((e=a[em])!==void 0?!!e:Zy(a)=="RegExp")},tm=Zu,rm=TypeError,en=function(a){if(tm(a))throw rm("The method doesn't accept regular expressions");return a},am=G,im=am("match"),tn=function(a){var e=/./;try{"/./"[a](e)}catch{try{return e[im]=!1,"/./"[a](e)}catch{}}return!1},nm=ee,Ju=It,sm=ot.f,om=lt,ks=pe,um=en,lm=ge,hm=tn,Bs=Ju("".startsWith),vm=Ju("".slice),fm=Math.min,el=hm("startsWith"),cm=!el&&!!function(){var a=sm(String.prototype,"startsWith");return a&&!a.writable}();nm({target:"String",proto:!0,forced:!cm&&!el},{startsWith:function(e){var t=ks(lm(this));um(e);var r=om(fm(arguments.length>1?arguments[1]:void 0,t.length)),i=ks(e);return Bs?Bs(t,i,r):vm(t,r,r+i.length)===i}});var gm=G,dm=Wi,pm=de.f,ci=gm("unscopables"),gi=Array.prototype;gi[ci]==null&&pm(gi,ci,{configurable:!0,value:dm(null)});var ym=function(a){gi[ci][a]=!0},mm=L,bm=!mm(function(){function a(){}return a.prototype.constructor=null,Object.getPrototypeOf(new a)!==a.prototype}),xm=le,Tm=D,Sm=Er,Om=Ri,Em=bm,Fs=Om("IE_PROTO"),di=Object,$m=di.prototype,tl=Em?di.getPrototypeOf:function(a){var e=Sm(a);if(xm(e,Fs))return e[Fs];var t=e.constructor;return Tm(t)&&e instanceof t?t.prototype:e instanceof di?$m:null},Cm=L,wm=D,Am=Te,js=tl,Pm=ze,Rm=G,pi=Rm("iterator"),rl=!1,ke,Ia,Na;[].keys&&(Na=[].keys(),"next"in Na?(Ia=js(js(Na)),Ia!==Object.prototype&&(ke=Ia)):rl=!0);var Im=!Am(ke)||Cm(function(){var a={};return ke[pi].call(a)!==a});Im&&(ke={});wm(ke[pi])||Pm(ke,pi,function(){return this});var al={IteratorPrototype:ke,BUGGY_SAFARI_ITERATORS:rl},Nm=al.IteratorPrototype,Mm=Wi,_m=xr,Dm=_i,Vm=Mt,Lm=function(){return this},km=function(a,e,t,r){var i=e+" Iterator";return a.prototype=Mm(Nm,{next:_m(+!r,t)}),Dm(a,i,!1),Vm[i]=Lm,a},Bm=ee,Fm=Y,il=Cr,jm=D,Um=km,Us=tl,zs=fu,zm=_i,Gm=At,Ma=ze,Hm=G,Ym=Mt,nl=al,Xm=il.PROPER,Wm=il.CONFIGURABLE,Gs=nl.IteratorPrototype,tr=nl.BUGGY_SAFARI_ITERATORS,ct=Hm("iterator"),Hs="keys",gt="values",Ys="entries",qm=function(){return this},Qm=function(a,e,t,r,i,n,o){Um(t,e,r);var s=function(y){if(y===i&&c)return c;if(!tr&&y in h)return h[y];switch(y){case Hs:return function(){return new t(this,y)};case gt:return function(){return new t(this,y)};case Ys:return function(){return new t(this,y)}}return function(){return new t(this)}},u=e+" Iterator",l=!1,h=a.prototype,f=h[ct]||h["@@iterator"]||i&&h[i],c=!tr&&f||s(i),v=e=="Array"&&h.entries||f,d,g,p;if(v&&(d=Us(v.call(new a)),d!==Object.prototype&&d.next&&(Us(d)!==Gs&&(zs?zs(d,Gs):jm(d[ct])||Ma(d,ct,qm)),zm(d,u,!0))),Xm&&i==gt&&f&&f.name!==gt&&(Wm?Gm(h,"name",gt):(l=!0,c=function(){return Fm(f,this)})),i)if(g={values:s(gt),keys:n?c:s(Hs),entries:s(Ys)},o)for(p in g)(tr||l||!(p in h))&&Ma(h,p,g[p]);else Bm({target:e,proto:!0,forced:tr||l},g);return h[ct]!==c&&Ma(h,ct,c,{name:i}),Ym[e]=c,g},Km=function(a,e){return{value:a,done:e}},Zm=wt,rn=ym,Xs=Mt,sl=wr,Jm=de.f,e0=Qm,rr=Km,t0=ce,ol="Array Iterator",r0=sl.set,a0=sl.getterFor(ol),i0=e0(Array,"Array",function(a,e){r0(this,{type:ol,target:Zm(a),index:0,kind:e})},function(){var a=a0(this),e=a.target,t=a.kind,r=a.index++;return!e||r>=e.length?(a.target=void 0,rr(void 0,!0)):t=="keys"?rr(r,!1):t=="values"?rr(e[r],!1):rr([r,e[r]],!1)},"values"),Ws=Xs.Arguments=Xs.Array;rn("keys");rn("values");rn("entries");if(t0&&Ws.name!=="values")try{Jm(Ws,"name",{value:"values"})}catch{}var n0={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},s0=$r,_a=s0("span").classList,qs=_a&&_a.constructor&&_a.constructor.prototype,o0=qs===Object.prototype?void 0:qs,Qs=U,ul=n0,u0=o0,mt=i0,Da=At,ll=G,Va=ll("iterator"),Ks=ll("toStringTag"),La=mt.values,hl=function(a,e){if(a){if(a[Va]!==La)try{Da(a,Va,La)}catch{a[Va]=La}if(a[Ks]||Da(a,Ks,e),ul[e]){for(var t in mt)if(a[t]!==mt[t])try{Da(a,t,mt[t])}catch{a[t]=mt[t]}}}};for(var ka in ul)hl(Qs[ka]&&Qs[ka].prototype,ka);hl(u0,"DOMTokenList");function l0(a,e){if(Ha(a)!=="object"||a===null)return a;var t=a[Symbol.toPrimitive];if(t!==void 0){var r=t.call(a,e||"default");if(Ha(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(a)}function h0(a){var e=l0(a,"string");return Ha(e)==="symbol"?e:String(e)}function an(a,e,t){return e=h0(e),e in a?Object.defineProperty(a,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):a[e]=t,a}var v0=Se,f0=Er,c0=zo,g0=Pr,d0=TypeError,Zs=function(a){return function(e,t,r,i){v0(t);var n=f0(e),o=c0(n),s=g0(n),u=a?s-1:0,l=a?-1:1;if(r<2)for(;;){if(u in o){i=o[u],u+=l;break}if(u+=l,a?u<0:s<=u)throw d0("Reduce of empty array with no initial value")}for(;a?u>=0:s>u;u+=l)u in o&&(i=t(i,o[u],u,n));return i}},p0={left:Zs(!1),right:Zs(!0)},y0=L,vl=function(a,e){var t=[][a];return!!t&&y0(function(){t.call(null,e||function(){return 1},1)})},m0=ee,b0=p0.left,x0=vl,Js=Oi,T0=Rt,S0=!T0&&Js>79&&Js<83,O0=S0||!x0("reduce");m0({target:"Array",proto:!0,forced:O0},{reduce:function(e){var t=arguments.length;return b0(this,e,t,t>1?arguments[1]:void 0)}});var E0=ee,fl=It,$0=ot.f,C0=lt,eo=pe,w0=en,A0=ge,P0=tn,to=fl("".endsWith),R0=fl("".slice),I0=Math.min,cl=P0("endsWith"),N0=!cl&&!!function(){var a=$0(String.prototype,"endsWith");return a&&!a.writable}();E0({target:"String",proto:!0,forced:!N0&&!cl},{endsWith:function(e){var t=eo(A0(this));w0(e);var r=arguments.length>1?arguments[1]:void 0,i=t.length,n=r===void 0?i:I0(C0(r),i),o=eo(e);return to?to(t,o,n):R0(t,n-o.length,n)===o}});var M0=wi,_0=de,D0=xr,V0=function(a,e,t){var r=M0(e);r in a?_0.f(a,r,D0(0,t)):a[r]=t},ro=ou,L0=Pr,k0=V0,B0=Array,F0=Math.max,j0=function(a,e,t){for(var r=L0(a),i=ro(e,r),n=ro(t===void 0?r:t,r),o=B0(F0(n-i,0)),s=0;i1||"".split(/.?/).length?r=function(i,n){var o=Ba(ao(this)),s=n===void 0?so:n>>>0;if(s===0)return[];if(i===void 0)return[o];if(!Y0(i))return dt(e,o,i,s);for(var u=[],l=(i.ignoreCase?"i":"")+(i.multiline?"m":"")+(i.unicode?"u":"")+(i.sticky?"y":""),h=0,f=new RegExp(i.source,l+"g"),c,v,d;(c=dt(K0,f,o))&&(v=f.lastIndex,!(v>h&&(Ke(u,pt(o,h,c.index)),c.length>1&&c.index=s)));)f.lastIndex===c.index&&f.lastIndex++;return h===o.length?(d||!tb(f,""))&&Ke(u,""):Ke(u,pt(o,h)),u.length>s?io(u,0,s):u}:"0".split(void 0,0).length?r=function(i,n){return i===void 0&&n===0?[]:dt(e,this,i,n)}:r=e,[function(n,o){var s=ao(this),u=H0(n)?void 0:Q0(n,a);return u?dt(u,n,s,o):dt(r,Ba(s),n,o)},function(i,n){var o=G0(this),s=Ba(i),u=t(r,o,s,n,r!==e);if(u.done)return u.value;var l=X0(o,RegExp),h=o.unicode,f=(o.ignoreCase?"i":"")+(o.multiline?"m":"")+(o.unicode?"u":"")+(Qe?"g":"y"),c=new l(Qe?"^(?:"+o.source+")":o,f),v=n===void 0?so:n>>>0;if(v===0)return[];if(s.length===0)return no(c,s)===null?[s]:[];for(var d=0,g=0,p=[];g"u"?Tt:window,ar=["moz","webkit"],at="AnimationFrame",st=be["request"+at],Ct=be["cancel"+at]||be["cancelRequest"+at];for(var yt=0;!st&&yt3&&(this.alpha=s[3]),this.ok=!0}}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.alpha=this.alpha<0?0:this.alpha>1||isNaN(this.alpha)?1:this.alpha,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toRGBA=function(){return"rgba("+this.r+", "+this.g+", "+this.b+", "+this.alpha+")"},this.toHex=function(){var u=this.r.toString(16),l=this.g.toString(16),h=this.b.toString(16);return u.length==1&&(u="0"+u),l.length==1&&(l="0"+l),h.length==1&&(h="0"+h),"#"+u+l+h},this.getHelpXML=function(){for(var u=new Array,l=0;l "+g.toRGB()+" -> "+g.toHex());d.appendChild(p),d.appendChild(y),v.appendChild(d)}catch{}return v}};const mi=Vo(bb);var xb=ee,Tb=It,Sb=uu.indexOf,Ob=vl,bi=Tb([].indexOf),pl=!!bi&&1/bi([1],1,-0)<0,Eb=pl||!Ob("indexOf");xb({target:"Array",proto:!0,forced:Eb},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return pl?bi(this,e,t)||0:Sb(this,e,t)}});var $b=ee,Cb=k,wb=en,Ab=ge,vo=pe,Pb=tn,Rb=Cb("".indexOf);$b({target:"String",proto:!0,forced:!Pb("includes")},{includes:function(e){return!!~Rb(vo(Ab(this)),vo(wb(e)),arguments.length>1?arguments[1]:void 0)}});var Ib=Fe,Nb=Array.isArray||function(e){return Ib(e)=="Array"},Mb=ee,_b=k,Db=Nb,Vb=_b([].reverse),fo=[1,2];Mb({target:"Array",proto:!0,forced:String(fo)===String(fo.reverse())},{reverse:function(){return Db(this)&&(this.length=this.length),Vb(this)}});/*! ***************************************************************************** diff --git a/assets/jspdf.es.min-b9cca550.js b/assets/jspdf.es.min-fee19fbe.js similarity index 99% rename from assets/jspdf.es.min-b9cca550.js rename to assets/jspdf.es.min-fee19fbe.js index eed72c6..e956597 100644 --- a/assets/jspdf.es.min-b9cca550.js +++ b/assets/jspdf.es.min-fee19fbe.js @@ -1,4 +1,4 @@ -import{_ as ls}from"./index-6614c9bf.js";function fe(i){return fe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},fe(i)}var Qe=Uint8Array,tn=Uint16Array,ha=Uint32Array,so=new Qe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),co=new Qe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),hs=new Qe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),xc=function(i,e){for(var n=new tn(31),a=0;a<31;++a)n[a]=e+=1<>>1|(ye&21845)<<1;Pr=(Pr&52428)>>>2|(Pr&13107)<<2,Pr=(Pr&61680)>>>4|(Pr&3855)<<4,ds[ye]=((Pr&65280)>>>8|(Pr&255)<<8)>>>1}var Kn=function(i,e,n){for(var a=i.length,c=0,o=new tn(e);c>>f]=g}else for(h=new tn(a),c=0;c>>15-i[c];return h},jr=new Qe(288);for(var ye=0;ye<144;++ye)jr[ye]=8;for(var ye=144;ye<256;++ye)jr[ye]=9;for(var ye=256;ye<280;++ye)jr[ye]=7;for(var ye=280;ye<288;++ye)jr[ye]=8;var fa=new Qe(32);for(var ye=0;ye<32;++ye)fa[ye]=5;var Su=Kn(jr,9,0),_u=Kn(jr,9,1),Pu=Kn(fa,5,0),ku=Kn(fa,5,1),es=function(i){for(var e=i[0],n=1;ne&&(e=i[n]);return e},Mn=function(i,e,n){var a=e/8>>0;return(i[a]|i[a+1]<<8)>>>(e&7)&n},ns=function(i,e){var n=e/8>>0;return(i[n]|i[n+1]<<8|i[n+2]<<16)>>>(e&7)},Ns=function(i){return(i/8>>0)+(i&7&&1)},kc=function(i,e,n){(e==null||e<0)&&(e=0),(n==null||n>i.length)&&(n=i.length);var a=new(i instanceof tn?tn:i instanceof ha?ha:Qe)(n-e);return a.set(i.subarray(e,n)),a},Fu=function(i,e,n){var a=i.length,c=!e||n,o=!n||n.i;n||(n={}),e||(e=new Qe(a*3));var l=function(Y){var Q=e.length;if(Y>Q){var et=new Qe(Math.max(Q*2,Y));et.set(e),e=et}},h=n.f||0,f=n.p||0,g=n.b||0,b=n.l,A=n.d,S=n.m,p=n.n,O=a*8;do{if(!b){n.f=h=Mn(i,f,1);var I=Mn(i,f+1,3);if(f+=3,I)if(I==1)b=_u,A=ku,S=9,p=5;else if(I==2){var X=Mn(i,f,31)+257,ot=Mn(i,f+10,15)+4,ut=X+Mn(i,f+5,31)+1;f+=14;for(var wt=new Qe(ut),tt=new Qe(19),R=0;RO)break;for(var F=Kn(tt,gt,1),R=0;R>>4;if(q<16)wt[R++]=q;else{var z=0,D=0;for(q==16?(D=3+Mn(i,f,3),f+=2,z=wt[R-1]):q==17?(D=3+Mn(i,f,7),f+=3):q==18&&(D=11+Mn(i,f,127),f+=7);D--;)wt[R++]=z}}var at=wt.subarray(0,X),nt=wt.subarray(X);S=es(at),p=es(nt),b=Kn(at,S,1),A=Kn(nt,p,1)}else throw"invalid block type";else{var q=Ns(f)+4,_=i[q-4]|i[q-3]<<8,B=q+_;if(B>a){if(o)throw"unexpected EOF";break}c&&l(g+_),e.set(i.subarray(q,B),g),n.b=g+=_,n.p=f=B*8;continue}if(f>O)throw"unexpected EOF"}c&&l(g+131072);for(var lt=(1<>>4;if(f+=z&15,f>O)throw"unexpected EOF";if(!z)throw"invalid length/literal";if(ht<256)e[g++]=ht;else if(ht==256){b=null;break}else{var kt=ht-254;if(ht>264){var R=ht-257,L=so[R];kt=Mn(i,f,(1<>>4;if(!j)throw"invalid distance";f+=j&15;var nt=xu[M];if(M>3){var L=co[M];nt+=ns(i,f)&(1<O)throw"unexpected EOF";c&&l(g+131072);for(var W=g+kt;g>0;i[a]|=n,i[a+1]|=n>>>8},ia=function(i,e,n){n<<=e&7;var a=e/8>>0;i[a]|=n,i[a+1]|=n>>>8,i[a+2]|=n>>>16},rs=function(i,e){for(var n=[],a=0;aS&&(S=o[a].s);var p=new tn(S+1),O=ps(n[b-1],p,0);if(O>e){var a=0,I=0,q=O-e,_=1<e)I+=_-(1<>>=q;I>0;){var X=o[a].s;p[X]=0&&I;--a){var ot=o[a].s;p[ot]==e&&(--p[ot],++I)}O=e}return[new Qe(p),O]},ps=function(i,e,n){return i.s==-1?Math.max(ps(i.l,e,n+1),ps(i.r,e,n+1)):e[i.s]=n},ac=function(i){for(var e=i.length;e&&!i[--e];);for(var n=new tn(++e),a=0,c=i[0],o=1,l=function(f){n[a++]=f},h=1;h<=e;++h)if(i[h]==c&&h!=e)++o;else{if(!c&&o>2){for(;o>138;o-=138)l(32754);o>2&&(l(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(l(c),--o;o>6;o-=6)l(8304);o>2&&(l(o-3<<5|8208),o=0)}for(;o--;)l(c);o=1,c=i[h]}return[n.subarray(0,a),e]},aa=function(i,e){for(var n=0,a=0;a>>8,i[c+2]=i[c]^255,i[c+3]=i[c+1]^255;for(var o=0;o4&&!dt[hs[P-1]];--P);var z=g+5<<3,D=aa(c,jr)+aa(o,fa)+l,at=aa(c,S)+aa(o,I)+l+14+3*P+aa(tt,dt)+(2*tt[16]+3*tt[17]+7*tt[18]);if(z<=D&&z<=at)return ao(e,b,i.subarray(f,f+g));var nt,lt,$,ft;if(lr(e,b,1+(at15&&(lr(e,b,j[R]>>>5&127),b+=j[R]>>>12)}}else nt=Su,lt=jr,$=Pu,ft=fa;for(var R=0;R255){var M=a[R]>>>18&31;ia(e,b,nt[M+257]),b+=lt[M+257],M>7&&(lr(e,b,a[R]>>>23&31),b+=so[M]);var W=a[R]&31;ia(e,b,$[W]),b+=ft[W],W>3&&(ia(e,b,a[R]>>>5&8191),b+=co[W])}else ia(e,b,nt[a[R]]),b+=lt[a[R]];return ia(e,b,nt[256]),b+lt[256]},Iu=new ha([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Cu=new Qe(0),ju=function(i,e,n,a,c,o){var l=i.length,h=new Qe(a+l+5*(1+Math.floor(l/7e3))+c),f=h.subarray(a,h.length-c),g=0;if(!e||l<8)for(var b=0;b<=l;b+=65535){var A=b+65535;A>>13,O=S&8191,I=(1<7e3||dt>24576)&&nt>423){g=oc(i,f,0,ut,wt,tt,gt,dt,P,b-P,g),dt=R=gt=0,P=b;for(var lt=0;lt<286;++lt)wt[lt]=0;for(var lt=0;lt<30;++lt)tt[lt]=0}var $=2,ft=0,ht=O,kt=D-at&32767;if(nt>2&&z==ot(b-kt))for(var L=Math.min(p,nt)-1,j=Math.min(32767,b),M=Math.min(258,nt);kt<=j&&--ht&&D!=at;){if(i[b+$]==i[b+$-kt]){for(var W=0;W$){if($=W,ft=kt,W>L)break;for(var Y=Math.min(kt,W-2),Q=0,lt=0;ltQ&&(Q=At,at=et)}}}D=at,at=q[D],kt+=D-at+32768&32767}if(ft){ut[dt++]=268435456|fs[$]<<18|ic[ft];var Nt=fs[$]&31,Ct=ic[ft]&31;gt+=so[Nt]+co[Ct],++wt[257+Nt],++tt[Ct],F=b+$,++R}else ut[dt++]=i[b],++wt[i[b]]}}g=oc(i,f,o,ut,wt,tt,gt,dt,P,b-P,g),o||(g=ao(f,g,Cu))}return kc(h,0,a+Ns(g)+c)},Ou=function(){var i=1,e=0;return{p:function(n){for(var a=i,c=e,o=n.length,l=0;l!=o;){for(var h=Math.min(l+5552,o);l>>8<<16|(e&255)<<8|e>>>8)+((i&255)<<23)*2}}},Bu=function(i,e,n,a,c){return ju(i,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(i.length)))*1.5):12+e.mem,n,a,!c)},Mu=function(i,e,n){for(;n;++e)i[e]=n,n>>>=8},Eu=function(i,e){var n=e.level,a=n==0?0:n<6?1:n==9?3:2;i[0]=120,i[1]=a<<6|(a?32-2*a:1)},qu=function(i){if((i[0]&15)!=8||i[0]>>>4>7||(i[0]<<8|i[1])%31)throw"invalid zlib data";if(i[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function gs(i,e){e===void 0&&(e={});var n=Ou();n.p(i);var a=Bu(i,e,2,4);return Eu(a,e),Mu(a,a.length-4,n.d()),a}function Du(i,e){return Fu((qu(i),i.subarray(2,-4)),e)}var Ht=function(){return typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:this}();function is(){Ht.console&&typeof Ht.console.log=="function"&&Ht.console.log.apply(Ht.console,arguments)}var ve={log:is,warn:function(i){Ht.console&&(typeof Ht.console.warn=="function"?Ht.console.warn.apply(Ht.console,arguments):is.call(null,arguments))},error:function(i){Ht.console&&(typeof Ht.console.error=="function"?Ht.console.error.apply(Ht.console,arguments):is(i))}};function as(i,e,n){var a=new XMLHttpRequest;a.open("GET",i),a.responseType="blob",a.onload=function(){Wr(a.response,e,n)},a.onerror=function(){ve.error("could not download file")},a.send()}function sc(i){var e=new XMLHttpRequest;e.open("HEAD",i,!1);try{e.send()}catch{}return e.status>=200&&e.status<=299}function eo(i){try{i.dispatchEvent(new MouseEvent("click"))}catch{var e=document.createEvent("MouseEvents");e.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),i.dispatchEvent(e)}}var oa,ms,Wr=Ht.saveAs||((typeof window>"u"?"undefined":fe(window))!=="object"||window!==Ht?function(){}:typeof HTMLAnchorElement<"u"&&"download"in HTMLAnchorElement.prototype?function(i,e,n){var a=Ht.URL||Ht.webkitURL,c=document.createElement("a");e=e||i.name||"download",c.download=e,c.rel="noopener",typeof i=="string"?(c.href=i,c.origin!==location.origin?sc(c.href)?as(i,e,n):eo(c,c.target="_blank"):eo(c)):(c.href=a.createObjectURL(i),setTimeout(function(){a.revokeObjectURL(c.href)},4e4),setTimeout(function(){eo(c)},0))}:"msSaveOrOpenBlob"in navigator?function(i,e,n){if(e=e||i.name||"download",typeof i=="string")if(sc(i))as(i,e,n);else{var a=document.createElement("a");a.href=i,a.target="_blank",setTimeout(function(){eo(a)})}else navigator.msSaveOrOpenBlob(function(c,o){return o===void 0?o={autoBom:!1}:fe(o)!=="object"&&(ve.warn("Deprecated: Expected third argument to be a object"),o={autoBom:!o}),o.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(c.type)?new Blob([String.fromCharCode(65279),c],{type:c.type}):c}(i,n),e)}:function(i,e,n,a){if((a=a||open("","_blank"))&&(a.document.title=a.document.body.innerText="downloading..."),typeof i=="string")return as(i,e,n);var c=i.type==="application/octet-stream",o=/constructor/i.test(Ht.HTMLElement)||Ht.safari,l=/CriOS\/[\d]+/.test(navigator.userAgent);if((l||c&&o)&&(typeof FileReader>"u"?"undefined":fe(FileReader))==="object"){var h=new FileReader;h.onloadend=function(){var b=h.result;b=l?b:b.replace(/^data:[^;]*;/,"data:attachment/file;"),a?a.location.href=b:location=b,a=null},h.readAsDataURL(i)}else{var f=Ht.URL||Ht.webkitURL,g=f.createObjectURL(i);a?a.location=g:location.href=g,a=null,setTimeout(function(){f.revokeObjectURL(g)},4e4)}});/** +import{_ as ls}from"./index-84a3106f.js";function fe(i){return fe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},fe(i)}var Qe=Uint8Array,tn=Uint16Array,ha=Uint32Array,so=new Qe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),co=new Qe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),hs=new Qe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),xc=function(i,e){for(var n=new tn(31),a=0;a<31;++a)n[a]=e+=1<>>1|(ye&21845)<<1;Pr=(Pr&52428)>>>2|(Pr&13107)<<2,Pr=(Pr&61680)>>>4|(Pr&3855)<<4,ds[ye]=((Pr&65280)>>>8|(Pr&255)<<8)>>>1}var Kn=function(i,e,n){for(var a=i.length,c=0,o=new tn(e);c>>f]=g}else for(h=new tn(a),c=0;c>>15-i[c];return h},jr=new Qe(288);for(var ye=0;ye<144;++ye)jr[ye]=8;for(var ye=144;ye<256;++ye)jr[ye]=9;for(var ye=256;ye<280;++ye)jr[ye]=7;for(var ye=280;ye<288;++ye)jr[ye]=8;var fa=new Qe(32);for(var ye=0;ye<32;++ye)fa[ye]=5;var Su=Kn(jr,9,0),_u=Kn(jr,9,1),Pu=Kn(fa,5,0),ku=Kn(fa,5,1),es=function(i){for(var e=i[0],n=1;ne&&(e=i[n]);return e},Mn=function(i,e,n){var a=e/8>>0;return(i[a]|i[a+1]<<8)>>>(e&7)&n},ns=function(i,e){var n=e/8>>0;return(i[n]|i[n+1]<<8|i[n+2]<<16)>>>(e&7)},Ns=function(i){return(i/8>>0)+(i&7&&1)},kc=function(i,e,n){(e==null||e<0)&&(e=0),(n==null||n>i.length)&&(n=i.length);var a=new(i instanceof tn?tn:i instanceof ha?ha:Qe)(n-e);return a.set(i.subarray(e,n)),a},Fu=function(i,e,n){var a=i.length,c=!e||n,o=!n||n.i;n||(n={}),e||(e=new Qe(a*3));var l=function(Y){var Q=e.length;if(Y>Q){var et=new Qe(Math.max(Q*2,Y));et.set(e),e=et}},h=n.f||0,f=n.p||0,g=n.b||0,b=n.l,A=n.d,S=n.m,p=n.n,O=a*8;do{if(!b){n.f=h=Mn(i,f,1);var I=Mn(i,f+1,3);if(f+=3,I)if(I==1)b=_u,A=ku,S=9,p=5;else if(I==2){var X=Mn(i,f,31)+257,ot=Mn(i,f+10,15)+4,ut=X+Mn(i,f+5,31)+1;f+=14;for(var wt=new Qe(ut),tt=new Qe(19),R=0;RO)break;for(var F=Kn(tt,gt,1),R=0;R>>4;if(q<16)wt[R++]=q;else{var z=0,D=0;for(q==16?(D=3+Mn(i,f,3),f+=2,z=wt[R-1]):q==17?(D=3+Mn(i,f,7),f+=3):q==18&&(D=11+Mn(i,f,127),f+=7);D--;)wt[R++]=z}}var at=wt.subarray(0,X),nt=wt.subarray(X);S=es(at),p=es(nt),b=Kn(at,S,1),A=Kn(nt,p,1)}else throw"invalid block type";else{var q=Ns(f)+4,_=i[q-4]|i[q-3]<<8,B=q+_;if(B>a){if(o)throw"unexpected EOF";break}c&&l(g+_),e.set(i.subarray(q,B),g),n.b=g+=_,n.p=f=B*8;continue}if(f>O)throw"unexpected EOF"}c&&l(g+131072);for(var lt=(1<>>4;if(f+=z&15,f>O)throw"unexpected EOF";if(!z)throw"invalid length/literal";if(ht<256)e[g++]=ht;else if(ht==256){b=null;break}else{var kt=ht-254;if(ht>264){var R=ht-257,L=so[R];kt=Mn(i,f,(1<>>4;if(!j)throw"invalid distance";f+=j&15;var nt=xu[M];if(M>3){var L=co[M];nt+=ns(i,f)&(1<O)throw"unexpected EOF";c&&l(g+131072);for(var W=g+kt;g>0;i[a]|=n,i[a+1]|=n>>>8},ia=function(i,e,n){n<<=e&7;var a=e/8>>0;i[a]|=n,i[a+1]|=n>>>8,i[a+2]|=n>>>16},rs=function(i,e){for(var n=[],a=0;aS&&(S=o[a].s);var p=new tn(S+1),O=ps(n[b-1],p,0);if(O>e){var a=0,I=0,q=O-e,_=1<e)I+=_-(1<>>=q;I>0;){var X=o[a].s;p[X]=0&&I;--a){var ot=o[a].s;p[ot]==e&&(--p[ot],++I)}O=e}return[new Qe(p),O]},ps=function(i,e,n){return i.s==-1?Math.max(ps(i.l,e,n+1),ps(i.r,e,n+1)):e[i.s]=n},ac=function(i){for(var e=i.length;e&&!i[--e];);for(var n=new tn(++e),a=0,c=i[0],o=1,l=function(f){n[a++]=f},h=1;h<=e;++h)if(i[h]==c&&h!=e)++o;else{if(!c&&o>2){for(;o>138;o-=138)l(32754);o>2&&(l(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(l(c),--o;o>6;o-=6)l(8304);o>2&&(l(o-3<<5|8208),o=0)}for(;o--;)l(c);o=1,c=i[h]}return[n.subarray(0,a),e]},aa=function(i,e){for(var n=0,a=0;a>>8,i[c+2]=i[c]^255,i[c+3]=i[c+1]^255;for(var o=0;o4&&!dt[hs[P-1]];--P);var z=g+5<<3,D=aa(c,jr)+aa(o,fa)+l,at=aa(c,S)+aa(o,I)+l+14+3*P+aa(tt,dt)+(2*tt[16]+3*tt[17]+7*tt[18]);if(z<=D&&z<=at)return ao(e,b,i.subarray(f,f+g));var nt,lt,$,ft;if(lr(e,b,1+(at15&&(lr(e,b,j[R]>>>5&127),b+=j[R]>>>12)}}else nt=Su,lt=jr,$=Pu,ft=fa;for(var R=0;R255){var M=a[R]>>>18&31;ia(e,b,nt[M+257]),b+=lt[M+257],M>7&&(lr(e,b,a[R]>>>23&31),b+=so[M]);var W=a[R]&31;ia(e,b,$[W]),b+=ft[W],W>3&&(ia(e,b,a[R]>>>5&8191),b+=co[W])}else ia(e,b,nt[a[R]]),b+=lt[a[R]];return ia(e,b,nt[256]),b+lt[256]},Iu=new ha([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Cu=new Qe(0),ju=function(i,e,n,a,c,o){var l=i.length,h=new Qe(a+l+5*(1+Math.floor(l/7e3))+c),f=h.subarray(a,h.length-c),g=0;if(!e||l<8)for(var b=0;b<=l;b+=65535){var A=b+65535;A>>13,O=S&8191,I=(1<7e3||dt>24576)&&nt>423){g=oc(i,f,0,ut,wt,tt,gt,dt,P,b-P,g),dt=R=gt=0,P=b;for(var lt=0;lt<286;++lt)wt[lt]=0;for(var lt=0;lt<30;++lt)tt[lt]=0}var $=2,ft=0,ht=O,kt=D-at&32767;if(nt>2&&z==ot(b-kt))for(var L=Math.min(p,nt)-1,j=Math.min(32767,b),M=Math.min(258,nt);kt<=j&&--ht&&D!=at;){if(i[b+$]==i[b+$-kt]){for(var W=0;W$){if($=W,ft=kt,W>L)break;for(var Y=Math.min(kt,W-2),Q=0,lt=0;ltQ&&(Q=At,at=et)}}}D=at,at=q[D],kt+=D-at+32768&32767}if(ft){ut[dt++]=268435456|fs[$]<<18|ic[ft];var Nt=fs[$]&31,Ct=ic[ft]&31;gt+=so[Nt]+co[Ct],++wt[257+Nt],++tt[Ct],F=b+$,++R}else ut[dt++]=i[b],++wt[i[b]]}}g=oc(i,f,o,ut,wt,tt,gt,dt,P,b-P,g),o||(g=ao(f,g,Cu))}return kc(h,0,a+Ns(g)+c)},Ou=function(){var i=1,e=0;return{p:function(n){for(var a=i,c=e,o=n.length,l=0;l!=o;){for(var h=Math.min(l+5552,o);l>>8<<16|(e&255)<<8|e>>>8)+((i&255)<<23)*2}}},Bu=function(i,e,n,a,c){return ju(i,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(i.length)))*1.5):12+e.mem,n,a,!c)},Mu=function(i,e,n){for(;n;++e)i[e]=n,n>>>=8},Eu=function(i,e){var n=e.level,a=n==0?0:n<6?1:n==9?3:2;i[0]=120,i[1]=a<<6|(a?32-2*a:1)},qu=function(i){if((i[0]&15)!=8||i[0]>>>4>7||(i[0]<<8|i[1])%31)throw"invalid zlib data";if(i[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function gs(i,e){e===void 0&&(e={});var n=Ou();n.p(i);var a=Bu(i,e,2,4);return Eu(a,e),Mu(a,a.length-4,n.d()),a}function Du(i,e){return Fu((qu(i),i.subarray(2,-4)),e)}var Ht=function(){return typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:this}();function is(){Ht.console&&typeof Ht.console.log=="function"&&Ht.console.log.apply(Ht.console,arguments)}var ve={log:is,warn:function(i){Ht.console&&(typeof Ht.console.warn=="function"?Ht.console.warn.apply(Ht.console,arguments):is.call(null,arguments))},error:function(i){Ht.console&&(typeof Ht.console.error=="function"?Ht.console.error.apply(Ht.console,arguments):is(i))}};function as(i,e,n){var a=new XMLHttpRequest;a.open("GET",i),a.responseType="blob",a.onload=function(){Wr(a.response,e,n)},a.onerror=function(){ve.error("could not download file")},a.send()}function sc(i){var e=new XMLHttpRequest;e.open("HEAD",i,!1);try{e.send()}catch{}return e.status>=200&&e.status<=299}function eo(i){try{i.dispatchEvent(new MouseEvent("click"))}catch{var e=document.createEvent("MouseEvents");e.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),i.dispatchEvent(e)}}var oa,ms,Wr=Ht.saveAs||((typeof window>"u"?"undefined":fe(window))!=="object"||window!==Ht?function(){}:typeof HTMLAnchorElement<"u"&&"download"in HTMLAnchorElement.prototype?function(i,e,n){var a=Ht.URL||Ht.webkitURL,c=document.createElement("a");e=e||i.name||"download",c.download=e,c.rel="noopener",typeof i=="string"?(c.href=i,c.origin!==location.origin?sc(c.href)?as(i,e,n):eo(c,c.target="_blank"):eo(c)):(c.href=a.createObjectURL(i),setTimeout(function(){a.revokeObjectURL(c.href)},4e4),setTimeout(function(){eo(c)},0))}:"msSaveOrOpenBlob"in navigator?function(i,e,n){if(e=e||i.name||"download",typeof i=="string")if(sc(i))as(i,e,n);else{var a=document.createElement("a");a.href=i,a.target="_blank",setTimeout(function(){eo(a)})}else navigator.msSaveOrOpenBlob(function(c,o){return o===void 0?o={autoBom:!1}:fe(o)!=="object"&&(ve.warn("Deprecated: Expected third argument to be a object"),o={autoBom:!o}),o.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(c.type)?new Blob([String.fromCharCode(65279),c],{type:c.type}):c}(i,n),e)}:function(i,e,n,a){if((a=a||open("","_blank"))&&(a.document.title=a.document.body.innerText="downloading..."),typeof i=="string")return as(i,e,n);var c=i.type==="application/octet-stream",o=/constructor/i.test(Ht.HTMLElement)||Ht.safari,l=/CriOS\/[\d]+/.test(navigator.userAgent);if((l||c&&o)&&(typeof FileReader>"u"?"undefined":fe(FileReader))==="object"){var h=new FileReader;h.onloadend=function(){var b=h.result;b=l?b:b.replace(/^data:[^;]*;/,"data:attachment/file;"),a?a.location.href=b:location=b,a=null},h.readAsDataURL(i)}else{var f=Ht.URL||Ht.webkitURL,g=f.createObjectURL(i);a?a.location=g:location.href=g,a=null,setTimeout(function(){f.revokeObjectURL(g)},4e4)}});/** * A class to parse color values * @author Stoyan Stefanov * {@link http://www.phpied.com/rgb-color-parser-in-javascript/} @@ -163,7 +163,7 @@ endobj\r * http://opensource.org/licenses/mit-license */function En(i,e){if(this.pos=0,this.buffer=i,this.datav=new DataView(i.buffer),this.is_with_alpha=!!e,this.bottom_up=!0,this.flag=String.fromCharCode(this.buffer[0])+String.fromCharCode(this.buffer[1]),this.pos+=2,["BM","BA","CI","CP","IC","PT"].indexOf(this.flag)===-1)throw new Error("Invalid BMP File");this.parseHeader(),this.parseBGR()}function Nc(i){function e(R){if(!R)throw Error("assert :P")}function n(R,gt,dt){for(var F=0;4>F;F++)if(R[gt+F]!=dt.charCodeAt(F))return!0;return!1}function a(R,gt,dt,F,P){for(var z=0;zz+1?[]:new gt),!(D.length>>0;t&u;)u>>>=1;return u?(t&u-1)+u:t}function dt(t,r,u,d,m){e(!(d%u));do t[r+(d-=u)]=m;while(0=m),512>=m)var w=o(512);else if((w=o(m))==null)return 0;return function(y,N,x,k,U,K){var Z,G,vt=N,it=1<Z;++Z){if(H[Z]>1<(Rt-=H[Z]))return 0;for(;0=Z;++Z,U<<=1){if(St+=Rt<<=1,0>(Rt-=H[Z]))return 0;for(;0bt&&!(0>=(pt-=H[bt]));)++bt,pt<<=1;it+=_t=1<<(pt=bt-x),y[N+(bt=Ot&mt)].g=pt+x,y[N+bt].value=vt-N-bt}k.g=Z-x,k.value=K[G++],dt(y,vt+(Ot>>x),U,_t,k),Ot=gt(Ot,Z)}}return St!=2*V[15]-1?0:it}(t,r,u,d,m,w)}function P(){this.value=this.g=0}function z(){this.value=this.g=0}function D(){this.G=l(5,P),this.H=o(5),this.jc=this.Qb=this.qb=this.nd=0,this.pd=l(rn,z)}function at(t,r,u,d){e(t!=null),e(r!=null),e(2147483648>d),t.Ca=254,t.I=0,t.b=-8,t.Ka=0,t.oa=r,t.pa=u,t.Jd=r,t.Yc=u+d,t.Zc=4<=d?u+d-4+1:u,Q(t)}function nt(t,r){for(var u=0;0d),t.Sb=d,t.Ra=0,t.u=0,t.h=0,4>>=8,t.Ra+=t.oa[t.pa+t.bb]<>>0,++t.bb,t.u-=8;M(t)&&(t.h=1,t.u=0)}function ht(t,r){if(e(0<=r),!t.h&&r<=gi){var u=j(t)&pi[r];return t.u+=r,ft(t),u}return t.h=1,t.u=0}function kt(){this.b=this.Ca=this.I=0,this.oa=[],this.pa=0,this.Jd=[],this.Yc=0,this.Zc=[],this.Ka=0}function L(){this.Ra=0,this.oa=[],this.h=this.u=this.bb=this.Sb=this.pa=0}function j(t){return t.Ra>>>(t.u&mi-1)>>>0}function M(t){return e(t.bb<=t.Sb),t.h||t.bb==t.Sb&&t.u>mi}function W(t,r){t.u=r,t.h=M(t)}function Y(t){t.u>=Yi&&(e(t.u>=Yi),ft(t))}function Q(t){e(t!=null&&t.oa!=null),t.pa>>0,t.b+=8):(e(t!=null&&t.oa!=null),t.pat.b&&Q(t);var d=t.b,m=u*r>>>8,w=(t.I>>>d>m)+0;for(w?(u-=m,t.I-=m+1<>>0):u=m+1,d=u,m=0;256<=d;)m+=8,d>>=8;return d=7^m+an[d],t.b-=d,t.Ca=(u<>24&255,t[r+1]=u>>16&255,t[r+2]=u>>8&255,t[r+3]=u>>0&255}function Nt(t,r){return t[r+0]<<0|t[r+1]<<8}function Ct(t,r){return Nt(t,r)|t[r+2]<<16}function Bt(t,r){return Nt(t,r)|Nt(t,r+2)<<16}function Ut(t,r){var u=1<=m||0>=w?0:(u[0]=m,d[0]=w,1)}function Et(t,r){return t+(1<>>r}function Lt(t,r){return((4278255360&t)+(4278255360&r)>>>0&4278255360)+((16711935&t)+(16711935&r)>>>0&16711935)>>>0}function xt(t,r){R[r]=function(u,d,m,w,y,N,x){var k;for(k=0;k>>1)+(t&r)>>>0}function qt(t){return 0<=t&&256>t?t:0>t?0:255>1))}function $t(t,r,u){return Math.abs(r-u)-Math.abs(t-u)}function te(t,r,u,d,m,w,y){for(d=w[y-1],u=0;u>8&255,x=16711935&(x=(x=16711935&y)+((N<<16)+N));d[m+w]=(4278255360&y)+x>>>0}}function de(t,r){r.jd=t>>0&255,r.hd=t>>8&255,r.ud=t>>16&255}function Wt(t,r,u,d,m,w){var y;for(y=0;y>>8,k=N,U=255&(U=(U=N>>>16)+((t.jd<<24>>24)*(x<<24>>24)>>>5));k=255&(k=(k=k+((t.hd<<24>>24)*(x<<24>>24)>>>5))+((t.ud<<24>>24)*(U<<24>>24)>>>5)),m[w+y]=(4278255360&N)+(U<<16)+k}}function ee(t,r,u,d,m){R[r]=function(w,y,N,x,k,U,K,Z,G){for(x=K;x>w.b,G=w.Ea,vt=w.K[0],it=w.w;if(8>Z)for(w=(1<>=Z}else R["VP8LMapColor"+u](x,k,vt,it,U,K,y,N,G)}}function It(t,r,u,d,m){for(u=r+u;r>16&255,d[m++]=w>>8&255,d[m++]=w>>0&255}}function Ve(t,r,u,d,m){for(u=r+u;r>16&255,d[m++]=w>>8&255,d[m++]=w>>0&255,d[m++]=w>>24&255}}function oe(t,r,u,d,m){for(u=r+u;r>16&240|y>>12&15,y=y>>0&240|y>>28&15;d[m++]=w,d[m++]=y}}function yn(t,r,u,d,m){for(u=r+u;r>16&248|y>>13&7,y=y>>5&224|y>>3&31;d[m++]=w,d[m++]=y}}function ge(t,r,u,d,m){for(u=r+u;r>0&255,d[m++]=w>>8&255,d[m++]=w>>16&255}}function Le(t,r,u,d,m,w){if(w==0)for(u=r+u;r>24|w[1]>>8&65280|w[2]<<8&16711680|w[3]<<24)>>>0),m+=32;else a(d,m,t,r,u)}function Rn(t,r){R[r][0]=R[t+"0"],R[r][1]=R[t+"1"],R[r][2]=R[t+"2"],R[r][3]=R[t+"3"],R[r][4]=R[t+"4"],R[r][5]=R[t+"5"],R[r][6]=R[t+"6"],R[r][7]=R[t+"7"],R[r][8]=R[t+"8"],R[r][9]=R[t+"9"],R[r][10]=R[t+"10"],R[r][11]=R[t+"11"],R[r][12]=R[t+"12"],R[r][13]=R[t+"13"],R[r][14]=R[t+"0"],R[r][15]=R[t+"0"]}function ce(t){return t==To||t==zo||t==za||t==Uo}function Br(){this.eb=[],this.size=this.A=this.fb=0}function Ae(){this.y=[],this.f=[],this.ea=[],this.F=[],this.Tc=this.Ed=this.Cd=this.Fd=this.lb=this.Db=this.Ab=this.fa=this.J=this.W=this.N=this.O=0}function Ln(){this.Rd=this.height=this.width=this.S=0,this.f={},this.f.RGBA=new Br,this.f.kb=new Ae,this.sd=null}function $n(){this.width=[0],this.height=[0],this.Pd=[0],this.Qd=[0],this.format=[0]}function xe(){this.Id=this.fd=this.Md=this.hb=this.ib=this.da=this.bd=this.cd=this.j=this.v=this.Da=this.Sd=this.ob=0}function Yt(t){return alert("todo:WebPSamplerProcessPlane"),t.T}function ue(t,r){var u=t.T,d=r.ba.f.RGBA,m=d.eb,w=d.fb+t.ka*d.A,y=bn[r.ba.S],N=t.y,x=t.O,k=t.f,U=t.N,K=t.ea,Z=t.W,G=r.cc,vt=r.dc,it=r.Mc,H=r.Nc,V=t.ka,pt=t.ka+t.T,bt=t.U,mt=bt+1>>1;for(V==0?y(N,x,null,null,k,U,K,Z,k,U,K,Z,m,w,null,null,bt):(y(r.ec,r.fc,N,x,G,vt,it,H,k,U,K,Z,m,w-d.A,m,w,bt),++u);V+2u,m=u==Da||u==Ra||u==Ta||u==Ro||u==12||ce(u);if(r.memory=null,r.Ib=null,r.Jb=null,r.Nd=null,!Vi(r.Oa,t,m?11:12))return 0;if(m&&ce(u)&&yt(),t.da)alert("todo:use_scaling");else{if(d){if(r.Ib=Yt,t.Kb){if(u=t.U+1>>1,r.memory=o(t.U+2*u),r.memory==null)return 0;r.ec=r.memory,r.fc=0,r.cc=r.ec,r.dc=r.fc+t.U,r.Mc=r.cc,r.Nc=r.dc+u,r.Ib=ue,yt()}}else alert("todo:EmitYUV");m&&(r.Jb=Mr,d&&J())}if(d&&!Ts){for(t=0;256>t;++t)au[t]=89858*(t-128)+Ha>>Ua,cu[t]=-22014*(t-128)+Ha,su[t]=-45773*(t-128),ou[t]=113618*(t-128)+Ha>>Ua;for(t=Qi;t>Ua,uu[t-Qi]=ln(r,255),lu[t-Qi]=ln(r+8>>4,15);Ts=1}return 1}function Tn(t){var r=t.ma,u=t.U,d=t.T;return e(!(1&t.ka)),0>=u||0>=d?0:(u=r.Ib(t,r),r.Jb!=null&&r.Jb(t,r,u),r.Dc+=u,1)}function zn(t){t.ma.memory=null}function zt(t,r,u,d){return ht(t,8)!=47?0:(r[0]=ht(t,14)+1,u[0]=ht(t,14)+1,d[0]=ht(t,1),ht(t,3)!=0?0:!t.h)}function Nn(t,r){if(4>t)return t+1;var u=t-2>>1;return(2+(1&t)<>4)*t+(8-(15&u)))?u:1;var u}function en(t,r,u){var d=j(u),m=t[r+=255&d].g-8;return 0>>0,e(8>=u.g),t.g}function Oe(t,r,u){var d=t.xc;return e((r=d==0?0:t.vc[t.md*(u>>d)+(r>>d)])>_t.b)*St;itbt&&(ne=bt),(0,gr[se[le++]>>8&15])(Z,G+ +ae,V,pt+ae-bt,ne-ae,V,pt+ae),ae=ne}G+=bt,pt+=bt,++it&Ot||(_t+=St)}K!=k.nc&&a(x,N-vt,x,N+(K-U-1)*vt,vt);break;case 1:for(vt=Z,H=G,bt=(Z=k.Ea)-(pt=Z&~(V=(G=1<>k.b)*it;U=m),0w.o&&(d=w.o),u=d?u=0:(m[0]+=4*w.v,w.ka=u-w.j,w.U=w.va-w.v,w.T=d-u,u=1),u){if(N=N[0],11>(u=t.ca).S){var U=u.f.RGBA,K=(d=u.S,m=w.U,w=w.T,k=U.eb,U.A),Z=w;for(U=U.fb+t.Ma*U.A;0d){var m=t.l.width,w=u.ca,y=u.tb+m*d,N=t.V,x=t.Ba+t.c*d,k=t.gc;e(t.ab==1),e(k[0].hc==3),Eo(k[0],d,r,N,x,w,y),An(u,d,r,w,y,m)}t.C=t.Ma=r}function Sn(t,r,u,d,m,w,y){var N=t.$/d,x=t.$%d,k=t.m,U=t.s,K=u+t.$,Z=K;m=u+d*m;var G=u+d*w,vt=280+U.ua,it=t.Pb?N:16777216,H=0=it){var Ot=K-u;e((it=t).Pb),it.wd=it.m,it.xd=Ot,0Rt.g?(W(mt,mt.u+Rt.g),Ot[St]=Rt.value,mt=0):(W(mt,mt.u+Rt.g-256),e(256<=Rt.value),mt=Rt.value),mt==0&&(bt=!0)}else mt=en(pt.G[0],pt.H[0],k);if(k.h)break;if(bt||256>mt){if(!bt)if(pt.nd)r[K]=(pt.qb|mt<<8)>>>0;else{if(Y(k),bt=en(pt.G[1],pt.H[1],k),Y(k),Ot=en(pt.G[2],pt.H[2],k),St=en(pt.G[3],pt.H[3],k),k.h)break;r[K]=(St<<24|bt<<16|mt<<8|Ot)>>>0}if(bt=!1,++K,++x>=d&&(x=0,++N,y!=null&&N<=w&&!(N%16)&&y(t,N),H!=null))for(;Z>>H.Mb]=mt}else if(280>mt){if(mt=Nn(mt-256,k),Ot=en(pt.G[4],pt.H[4],k),Y(k),Ot=Un(d,Ot=Nn(Ot,k)),k.h)break;if(K-u=d;)x-=d,++N,y!=null&&N<=w&&!(N%16)&&y(t,N);if(e(K<=m),x&V&&(pt=Oe(U,x,N)),H!=null)for(;Z>>H.Mb]=mt}else{if(!(mt>>H.Mb]=mt;mt=K,e(!(bt>>>(Ot=H).Xa)),r[mt]=Ot.X[bt],bt=!0}bt||e(k.h==M(k))}if(t.Pb&&k.h&&Kw?w:N),t.a=0,t.$=K-u}return 1}return t.a=3,0}function Hn(t){e(t!=null),t.vc=null,t.yc=null,t.Ya=null;var r=t.Wa;r!=null&&(r.X=null),t.vb=null,e(t!=null)}function pn(){var t=new Bo;return t==null?null:(t.a=0,t.xb=Bs,Rn("Predictor","VP8LPredictors"),Rn("Predictor","VP8LPredictors_C"),Rn("PredictorAdd","VP8LPredictorsAdd"),Rn("PredictorAdd","VP8LPredictorsAdd_C"),Ba=ie,gn=Wt,In=It,mr=Ve,Gn=oe,rr=yn,vi=ge,R.VP8LMapColor32b=Xi,R.VP8LMapColor8b=qo,t)}function Wn(t,r,u,d,m){var w=1,y=[t],N=[r],x=d.m,k=d.s,U=null,K=0;t:for(;;){if(u)for(;w&&ht(x,1);){var Z=y,G=N,vt=d,it=1,H=vt.m,V=vt.gc[vt.ab],pt=ht(H,2);if(vt.Oc&1<=vt.ab),pt){case 0:case 1:V.b=ht(H,3)+2,it=Wn(Et(V.Ea,V.b),Et(V.nc,V.b),0,vt,V.K),V.K=V.K[0];break;case 3:var bt,mt=ht(H,8)+1,Ot=16>_t.b),le=o(se);if(le==null)bt=0;else{var ae=_t.K[0],ne=_t.w;for(le[0]=_t.K[0][0],St=1;St<1*Rt;++St)le[St]=Lt(ae[ne+St],le[St-1]);for(;St<4*se;++St)le[St]=0;_t.K[0]=null,_t.K[0]=le,bt=1}}it=bt;break;case 2:break;default:e(0)}w=it}}if(y=y[0],N=N[0],w&&ht(x,1)&&!(w=1<=(K=ht(x,4))&&11>=K)){d.a=3;break t}var me;if(me=w)e:{var pe,Zt,Me,on=d,Ee=y,sn=N,he=K,fn=u,dn=on.m,ze=on.s,We=[null],$e=1,wn=0,Yn=Gc[he];n:for(;;){if(fn&&ht(dn,1)){var Ue=ht(dn,3)+2,cr=Et(Ee,Ue),Hr=Et(sn,Ue),Li=cr*Hr;if(!Wn(cr,Hr,0,on,We))break n;for(We=We[0],ze.xc=Ue,pe=0;pe>8&65535;We[pe]=Nr,Nr>=$e&&($e=Nr+1)}}if(dn.h)break n;for(Zt=0;5>Zt;++Zt){var _e=js[Zt];!Zt&&0=Hs),Va=Ws;var ta=o(wn);if(Va==null||ta==null||Go==null){on.a=1;break n}var Ga=Go;for(pe=Me=0;pe<$e;++pe){var Bn=Va[pe],Ni=Bn.G,Ai=Bn.H,Vs=0,Ya=1,Gs=0;for(Zt=0;5>Zt;++Zt){_e=js[Zt],Ni[Zt]=Ga,Ai[Zt]=Me,!Zt&&0$a)break r}else Xo=$a;for(na=0;na<$a&&Xo--;){Y(xr);var tc=Qs[0+(127&j(xr))];W(xr,xr.u+tc.g);var xi=tc.value;if(16>xi)Zs[na++]=xi,xi!=0&&($s=xi);else{var yu=xi==16,ec=xi-16,Lu=Uc[ec],nc=ht(xr,zc[ec])+Lu;if(na+nc>$a)break r;for(var Nu=yu?$s:0;0=Zt){var ra,Zo=ta[0];for(ra=1;ra<_e;++ra)ta[ra]>Zo&&(Zo=ta[ra]);Gs+=Zo}}if(Bn.nd=Ya,Bn.Qb=0,Ya&&(Bn.qb=(Ni[3][Ai[3]+0].value<<24|Ni[1][Ai[1]+0].value<<16|Ni[2][Ai[2]+0].value)>>>0,Vs==0&&256>Ni[0][Ai[0]+0].value&&(Bn.Qb=1,Bn.qb+=Ni[0][Ai[0]+0].value<<8)),Bn.jc=!Bn.Qb&&6>Gs,Bn.jc){var Qa,ur=Bn;for(Qa=0;Qa>=qe(to,8,_r),Sr>>=qe(ur.G[1][ur.H[1]+Sr],16,_r),Sr>>=qe(ur.G[2][ur.H[2]+Sr],0,_r),qe(ur.G[3][ur.H[3]+Sr],24,_r))}}}ze.vc=We,ze.Wb=$e,ze.Ya=Va,ze.yc=Go,me=1;break e}me=0}if(!(w=me)){d.a=3;break t}if(0d+1?[]:0),!(m.lengthm)return ke(t,7,"Truncated header.");var w=u[d+0]|u[d+1]<<8|u[d+2]<<16,y=t.Od;if(y.Rb=!(1&w),y.td=w>>1&7,y.yd=w>>4&1,y.ub=w>>5,3m)return ke(t,7,"cannot parse picture header");if(!va(u,d,m))return ke(t,3,"Bad code word");N.c=16383&(u[d+4]<<8|u[d+3]),N.Td=u[d+4]>>6,N.i=16383&(u[d+6]<<8|u[d+5]),N.Ud=u[d+6]>>6,d+=7,m-=7,t.za=N.c+15>>4,t.Ub=N.i+15>>4,r.width=N.c,r.height=N.i,r.Da=0,r.j=0,r.v=0,r.va=r.width,r.o=r.height,r.da=0,r.ib=r.width,r.hb=r.height,r.U=r.width,r.T=r.height,c((w=t.Pa).jb,0,255,w.jb.length),e((w=t.Qa)!=null),w.Cb=0,w.Bb=0,w.Fb=1,c(w.Zb,0,0,w.Zb.length),c(w.Lb,0,0,w.Lb)}if(y.ub>m)return ke(t,7,"bad partition length");at(w=t.m,u,d,y.ub),d+=y.ub,m-=y.ub,y.Rb&&(N.Ld=et(w),N.Kd=et(w)),N=t.Qa;var x,k=t.Pa;if(e(w!=null),e(N!=null),N.Cb=et(w),N.Cb){if(N.Bb=et(w),et(w)){for(N.Fb=et(w),x=0;4>x;++x)N.Zb[x]=et(w)?lt(w,7):0;for(x=0;4>x;++x)N.Lb[x]=et(w)?lt(w,6):0}if(N.Bb)for(x=0;3>x;++x)k.jb[x]=et(w)?nt(w,8):255}else N.Bb=0;if(w.Ka)return ke(t,3,"cannot parse segment header");if((N=t.ed).zd=et(w),N.Tb=nt(w,6),N.wb=nt(w,3),N.Pc=et(w),N.Pc&&et(w)){for(k=0;4>k;++k)et(w)&&(N.vd[k]=lt(w,6));for(k=0;4>k;++k)et(w)&&(N.od[k]=lt(w,6))}if(t.L=N.Tb==0?0:N.zd?1:2,w.Ka)return ke(t,3,"cannot parse filter header");var U=m;if(m=x=d,d=x+U,N=U,t.Xb=(1<N&&(K=N),at(t.Jc[+U],u,x,K),x+=K,N-=K,m+=3}at(t.Jc[+k],u,x,N),u=xK;++K){if(U.Cb){var Z=U.Zb[K];U.Fb||(Z+=u)}else{if(0>16,8>G.Eb[1]&&(G.Eb[1]=8),G.Qc[0]=Ho[ln(Z+k,117)],G.Qc[1]=Wo[ln(Z+x,127)],G.lc=Z+x}if(!y.Rb)return ke(t,4,"Not a key frame.");for(et(w),y=t.Pa,u=0;4>u;++u){for(m=0;8>m;++m)for(d=0;3>d;++d)for(N=0;11>N;++N)k=rt(w,$c[u][m][d][N])?nt(w,8):Kc[u][m][d][N],y.Wc[u][m].Yb[d][N]=k;for(m=0;17>m;++m)y.Xc[u][m]=y.Wc[u][Qc[m]]}return t.kc=et(w),t.kc&&(t.Bd=nt(w,8)),t.cb=1}function wa(t,r,u,d,m,w,y){var N=r[m].Yb[u];for(u=0;16>m;++m){if(!rt(t,N[u+0]))return m;for(;!rt(t,N[u+1]);)if(N=r[++m].Yb[0],u=0,m==16)return 16;var x=r[m+1].Yb;if(rt(t,N[u+2])){var k=t,U=0;if(rt(k,(Z=N)[(K=u)+3]))if(rt(k,Z[K+6])){for(N=0,K=2*(U=rt(k,Z[K+8]))+(Z=rt(k,Z[K+9+U])),U=0,Z=Jc[K];Z[N];++N)U+=U+rt(k,Z[N]);U+=3+(8<(k=t).b&&Q(k);var K,Z=k.b,G=(K=k.Ca>>1)-(k.I>>Z)>>31;--k.b,k.Ca+=G,k.Ca|=1,k.I-=(K+1&G)<>4,t.zb=r.j-u>>4,0>t.yb&&(t.yb=0),0>t.zb&&(t.zb=0)),t.Va=r.o+15+u>>4,t.Hb=r.va+15+u>>4,t.Hb>t.za&&(t.Hb=t.za),t.Va>t.Ub&&(t.Va=t.Ub),0u;++u){var m;if(t.Qa.Cb){var w=t.Qa.Lb[u];t.Qa.Fb||(w+=d.Tb)}else w=d.Tb;for(m=0;1>=m;++m){var y=t.gd[u][m],N=w;if(d.Pc&&(N+=d.vd[0],m&&(N+=d.od[0])),0<(N=0>N?0:63>2:x>>1)>9-d.wb&&(x=9-d.wb),1>x&&(x=1),y.dd=x,y.tc=2*N+x,y.ld=40<=N?2:15<=N?1:0}else y.tc=0;y.La=m}}}u=0}else ke(t,6,"Frame setup failed"),u=t.a;if(u=u==0){if(u){t.$c=0,0t.Vb){if(t.Vb=0,t.Ec=o(y),t.Fc=0,t.Ec==null){u=ke(t,1,"no memory during frame initialization.");break t}t.Vb=y}y=t.Ec,N=t.Fc,t.Ac=y,t.Bc=N,N+=d,t.Gd=l(k,ma),t.Hd=0,t.rb=l(U+1,ga),t.sb=1,t.wa=K?l(K,ni):null,t.Y=0,t.D.Nb=0,t.D.wa=t.wa,t.D.Y=t.Y,0=u;++u)Ss[255+u]=0>u?-u:u;for(u=-1020;1020>=u;++u)_s[1020+u]=-128>u?-128:127=u;++u)Ps[112+u]=-16>u?-16:15=u;++u)ks[255+u]=0>u?0:255mt;++mt){var ae,ne=Rt[0+mt];for(ae=0;4>ae;++ae){ne=Zc[Ot[St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ke(G,6,"Output aborted.")}return 1}(t,r)),r.bc!=null&&r.bc(r),u&=1}return u?(t.cb=0,u):0}function _n(t,r,u,d,m){m=t[r+u+32*d]+(m>>3),t[r+u+32*d]=-256&m?0>m?0:255:m}function ii(t,r,u,d,m,w){_n(t,r,0,u,d+m),_n(t,r,1,u,d+w),_n(t,r,2,u,d-w),_n(t,r,3,u,d-m)}function nn(t){return(20091*t>>16)+t}function Ci(t,r,u,d){var m,w=0,y=o(16);for(m=0;4>m;++m){var N=t[r+0]+t[r+8],x=t[r+0]-t[r+8],k=(35468*t[r+4]>>16)-nn(t[r+12]),U=nn(t[r+4])+(35468*t[r+12]>>16);y[w+0]=N+U,y[w+1]=x+k,y[w+2]=x-k,y[w+3]=N-U,w+=4,r++}for(m=w=0;4>m;++m)N=(t=y[w+0]+4)+y[w+8],x=t-y[w+8],k=(35468*y[w+4]>>16)-nn(y[w+12]),_n(u,d,0,0,N+(U=nn(y[w+4])+(35468*y[w+12]>>16))),_n(u,d,1,0,x+k),_n(u,d,2,0,x-k),_n(u,d,3,0,N-U),w++,d+=32}function ya(t,r,u,d){var m=t[r+0]+4,w=35468*t[r+4]>>16,y=nn(t[r+4]),N=35468*t[r+1]>>16;ii(u,d,0,m+y,t=nn(t[r+1]),N),ii(u,d,1,m+w,t,N),ii(u,d,2,m-w,t,N),ii(u,d,3,m-y,t,N)}function bo(t,r,u,d,m){Ci(t,r,u,d),m&&Ci(t,r+16,u,d+4)}function La(t,r,u,d){bi(t,r+0,u,d,1),bi(t,r+32,u,d+128,1)}function wo(t,r,u,d){var m;for(t=t[r+0]+4,m=0;4>m;++m)for(r=0;4>r;++r)_n(u,d,r,m,t)}function Na(t,r,u,d){t[r+0]&&jn(t,r+0,u,d),t[r+16]&&jn(t,r+16,u,d+4),t[r+32]&&jn(t,r+32,u,d+128),t[r+48]&&jn(t,r+48,u,d+128+4)}function yo(t,r,u,d){var m,w=o(16);for(m=0;4>m;++m){var y=t[r+0+m]+t[r+12+m],N=t[r+4+m]+t[r+8+m],x=t[r+4+m]-t[r+8+m],k=t[r+0+m]-t[r+12+m];w[0+m]=y+N,w[8+m]=y-N,w[4+m]=k+x,w[12+m]=k-x}for(m=0;4>m;++m)y=(t=w[0+4*m]+3)+w[3+4*m],N=w[1+4*m]+w[2+4*m],x=w[1+4*m]-w[2+4*m],k=t-w[3+4*m],u[d+0]=y+N>>3,u[d+16]=k+x>>3,u[d+32]=y-N>>3,u[d+48]=k-x>>3,d+=64}function ji(t,r,u){var d,m=r-32,w=hn,y=255-t[m-1];for(d=0;du;++u)a(t,r+32*u,t,r-32,16)}function ai(t,r){var u;for(u=16;0d;++d)c(r,u+32*d,t,16)}function Aa(t,r){var u,d=16;for(u=0;16>u;++u)d+=t[r-1+32*u]+t[r+u-32];oi(d>>5,t,r)}function Ge(t,r){var u,d=8;for(u=0;16>u;++u)d+=t[r-1+32*u];oi(d>>4,t,r)}function xo(t,r){var u,d=8;for(u=0;16>u;++u)d+=t[r+u-32];oi(d>>4,t,r)}function xa(t,r){oi(128,t,r)}function Vt(t,r,u){return t+2*r+u+2>>2}function So(t,r){var u,d=r-32;for(d=new Uint8Array([Vt(t[d-1],t[d+0],t[d+1]),Vt(t[d+0],t[d+1],t[d+2]),Vt(t[d+1],t[d+2],t[d+3]),Vt(t[d+2],t[d+3],t[d+4])]),u=0;4>u;++u)a(t,r+32*u,d,0,d.length)}function _o(t,r){var u=t[r-1],d=t[r-1+32],m=t[r-1+64],w=t[r-1+96];At(t,r+0,16843009*Vt(t[r-1-32],u,d)),At(t,r+32,16843009*Vt(u,d,m)),At(t,r+64,16843009*Vt(d,m,w)),At(t,r+96,16843009*Vt(m,w,w))}function Vn(t,r){var u,d=4;for(u=0;4>u;++u)d+=t[r+u-32]+t[r-1+32*u];for(d>>=3,u=0;4>u;++u)c(t,r+32*u,d,4)}function Sa(t,r){var u=t[r-1+0],d=t[r-1+32],m=t[r-1+64],w=t[r-1-32],y=t[r+0-32],N=t[r+1-32],x=t[r+2-32],k=t[r+3-32];t[r+0+96]=Vt(d,m,t[r-1+96]),t[r+1+96]=t[r+0+64]=Vt(u,d,m),t[r+2+96]=t[r+1+64]=t[r+0+32]=Vt(w,u,d),t[r+3+96]=t[r+2+64]=t[r+1+32]=t[r+0+0]=Vt(y,w,u),t[r+3+64]=t[r+2+32]=t[r+1+0]=Vt(N,y,w),t[r+3+32]=t[r+2+0]=Vt(x,N,y),t[r+3+0]=Vt(k,x,N)}function _a(t,r){var u=t[r+1-32],d=t[r+2-32],m=t[r+3-32],w=t[r+4-32],y=t[r+5-32],N=t[r+6-32],x=t[r+7-32];t[r+0+0]=Vt(t[r+0-32],u,d),t[r+1+0]=t[r+0+32]=Vt(u,d,m),t[r+2+0]=t[r+1+32]=t[r+0+64]=Vt(d,m,w),t[r+3+0]=t[r+2+32]=t[r+1+64]=t[r+0+96]=Vt(m,w,y),t[r+3+32]=t[r+2+64]=t[r+1+96]=Vt(w,y,N),t[r+3+64]=t[r+2+96]=Vt(y,N,x),t[r+3+96]=Vt(N,x,x)}function si(t,r){var u=t[r-1+0],d=t[r-1+32],m=t[r-1+64],w=t[r-1-32],y=t[r+0-32],N=t[r+1-32],x=t[r+2-32],k=t[r+3-32];t[r+0+0]=t[r+1+64]=w+y+1>>1,t[r+1+0]=t[r+2+64]=y+N+1>>1,t[r+2+0]=t[r+3+64]=N+x+1>>1,t[r+3+0]=x+k+1>>1,t[r+0+96]=Vt(m,d,u),t[r+0+64]=Vt(d,u,w),t[r+0+32]=t[r+1+96]=Vt(u,w,y),t[r+1+32]=t[r+2+96]=Vt(w,y,N),t[r+2+32]=t[r+3+96]=Vt(y,N,x),t[r+3+32]=Vt(N,x,k)}function Oi(t,r){var u=t[r+0-32],d=t[r+1-32],m=t[r+2-32],w=t[r+3-32],y=t[r+4-32],N=t[r+5-32],x=t[r+6-32],k=t[r+7-32];t[r+0+0]=u+d+1>>1,t[r+1+0]=t[r+0+64]=d+m+1>>1,t[r+2+0]=t[r+1+64]=m+w+1>>1,t[r+3+0]=t[r+2+64]=w+y+1>>1,t[r+0+32]=Vt(u,d,m),t[r+1+32]=t[r+0+96]=Vt(d,m,w),t[r+2+32]=t[r+1+96]=Vt(m,w,y),t[r+3+32]=t[r+2+96]=Vt(w,y,N),t[r+3+64]=Vt(y,N,x),t[r+3+96]=Vt(N,x,k)}function Po(t,r){var u=t[r-1+0],d=t[r-1+32],m=t[r-1+64],w=t[r-1+96];t[r+0+0]=u+d+1>>1,t[r+2+0]=t[r+0+32]=d+m+1>>1,t[r+2+32]=t[r+0+64]=m+w+1>>1,t[r+1+0]=Vt(u,d,m),t[r+3+0]=t[r+1+32]=Vt(d,m,w),t[r+3+32]=t[r+1+64]=Vt(m,w,w),t[r+3+64]=t[r+2+64]=t[r+0+96]=t[r+1+96]=t[r+2+96]=t[r+3+96]=w}function ko(t,r){var u=t[r-1+0],d=t[r-1+32],m=t[r-1+64],w=t[r-1+96],y=t[r-1-32],N=t[r+0-32],x=t[r+1-32],k=t[r+2-32];t[r+0+0]=t[r+2+32]=u+y+1>>1,t[r+0+32]=t[r+2+64]=d+u+1>>1,t[r+0+64]=t[r+2+96]=m+d+1>>1,t[r+0+96]=w+m+1>>1,t[r+3+0]=Vt(N,x,k),t[r+2+0]=Vt(y,N,x),t[r+1+0]=t[r+3+32]=Vt(u,y,N),t[r+1+32]=t[r+3+64]=Vt(d,u,y),t[r+1+64]=t[r+3+96]=Vt(m,d,u),t[r+1+96]=Vt(w,m,d)}function Fo(t,r){var u;for(u=0;8>u;++u)a(t,r+32*u,t,r-32,8)}function Bi(t,r){var u;for(u=0;8>u;++u)c(t,r,t[r-1],8),r+=32}function qr(t,r,u){var d;for(d=0;8>d;++d)c(r,u+32*d,t,8)}function hr(t,r){var u,d=8;for(u=0;8>u;++u)d+=t[r+u-32]+t[r-1+32*u];qr(d>>4,t,r)}function Io(t,r){var u,d=4;for(u=0;8>u;++u)d+=t[r+u-32];qr(d>>3,t,r)}function Dr(t,r){var u,d=4;for(u=0;8>u;++u)d+=t[r-1+32*u];qr(d>>3,t,r)}function Mi(t,r){qr(128,t,r)}function ci(t,r,u){var d=t[r-u],m=t[r+0],w=3*(m-d)+Do[1020+t[r-2*u]-t[r+u]],y=Ea[112+(w+4>>3)];t[r-u]=hn[255+d+Ea[112+(w+3>>3)]],t[r+0]=hn[255+m-y]}function Pa(t,r,u,d){var m=t[r+0],w=t[r+u];return vn[255+t[r-2*u]-t[r-u]]>d||vn[255+w-m]>d}function ka(t,r,u,d){return 4*vn[255+t[r-u]-t[r+0]]+vn[255+t[r-2*u]-t[r+u]]<=d}function Fa(t,r,u,d,m){var w=t[r-3*u],y=t[r-2*u],N=t[r-u],x=t[r+0],k=t[r+u],U=t[r+2*u],K=t[r+3*u];return 4*vn[255+N-x]+vn[255+y-k]>d?0:vn[255+t[r-4*u]-w]<=m&&vn[255+w-y]<=m&&vn[255+y-N]<=m&&vn[255+K-U]<=m&&vn[255+U-k]<=m&&vn[255+k-x]<=m}function Ia(t,r,u,d){var m=2*d+1;for(d=0;16>d;++d)ka(t,r+d,u,m)&&ci(t,r+d,u)}function er(t,r,u,d){var m=2*d+1;for(d=0;16>d;++d)ka(t,r+d*u,1,m)&&ci(t,r+d*u,1)}function fr(t,r,u,d){var m;for(m=3;0>7,V=18*pt+63>>7,pt=9*pt+63>>7;x[k-3*U]=hn[255+x[k-3*U]+pt],x[k-2*U]=hn[255+K+V],x[k-U]=hn[255+Z+H],x[k+0]=hn[255+G-H],x[k+U]=hn[255+vt-V],x[k+2*U]=hn[255+it-pt]}r+=d}}function Pn(t,r,u,d,m,w,y,N){for(w=2*w+1;0>3)],it=Ea[112+(it+3>>3)],H=vt+1>>1;x[k-2*U]=hn[255+x[k-2*U]+H],x[k-U]=hn[255+K+it],x[k+0]=hn[255+Z-vt],x[k+U]=hn[255+G-H]}r+=d}}function Ei(t,r,u,d,m,w){dr(t,r,u,1,16,d,m,w)}function Rr(t,r,u,d,m,w){dr(t,r,1,u,16,d,m,w)}function jo(t,r,u,d,m,w){var y;for(y=3;0k?0:255:k)&255,k=x,m[w+N]=U}}function Ui(t,r,u,d){var m=r.width,w=r.o;if(e(t!=null&&r!=null),0>u||0>=d||u+d>w)return null;if(!t.Cc){if(t.ga==null){var y;if(t.ga=new hi,(y=t.ga==null)||(y=r.width*r.o,e(t.Gb.length==0),t.Gb=o(y),t.Uc=0,t.Gb==null?y=0:(t.mb=t.Gb,t.nb=t.Uc,t.rc=null,y=1),y=!y),!y){y=t.ga;var N=t.Fa,x=t.P,k=t.qc,U=t.mb,K=t.nb,Z=x+1,G=k-1,vt=y.l;if(e(N!=null&&U!=null&&r!=null),Lr[0]=null,Lr[1]=Tr,Lr[2]=zi,Lr[3]=pr,y.ca=U,y.tb=K,y.c=r.width,y.i=r.height,e(0=k)r=0;else if(y.$a=N[x+0]>>0&3,y.Z=N[x+0]>>2&3,y.Lc=N[x+0]>>4&3,x=N[x+0]>>6&3,0>y.$a||1=y.c*y.i;y=!r}if(y)return null;t.ga.Lc!=1?t.Ga=0:d=w-u}e(t.ga!=null),e(u+d<=w);t:{if(r=(N=t.ga).c,w=N.l.o,N.$a==0){if(Z=t.rc,G=t.Vc,vt=t.Fa,x=t.P+1+u*r,k=t.mb,U=t.nb+u*r,e(x<=t.P+t.qc),N.Z!=0)for(e(Lr[N.Z]!=null),y=0;y=r)r=1;else if(N.ic||J(),N.ic){N=y.V,Z=y.Ba,G=y.c;var it=y.i,H=(vt=1,x=y.$/G,k=y.$%G,U=y.m,K=y.s,y.$),V=G*it,pt=G*r,bt=K.wc,mt=H(it=en(mt.G[0],mt.H[0],U)))N[Z+H]=it,++H,++k>=G&&(k=0,++x<=r&&!(x%16)&&xn(y,x));else{if(!(280>it)){vt=0;break e}it=Nn(it-256,U);var Ot,St=en(mt.G[4],mt.H[4],U);if(Y(U),!(H>=(St=Un(G,St=Nn(St,U)))&&V-H>=it)){vt=0;break e}for(Ot=0;Ot=G;)k-=G,++x<=r&&!(x%16)&&xn(y,x);Hr?r:x);break e}!vt||U.h&&H=w&&(t.Cc=1),d=1}if(!d)return null;if(t.Cc&&((d=t.ga)!=null&&(d.mc=null),t.ga=null,0>23,N[x+4*y+1]=N[x+4*y+1]*K>>23,N[x+4*y+2]=N[x+4*y+2]*K>>23)}r+=w}}function v(t,r,u,d,m){for(;0>4)*x>>16;t[r+2*w+0]=(240&y|y>>4)*x>>16&240|(15&y|y<<4)*x>>16>>4&15,t[r+2*w+1]=240&k|N}r+=m}}function C(t,r,u,d,m,w,y,N){var x,k,U=255;for(k=0;k>8}function J(){wr=s,yi=v,Ma=C,xs=T}function st(t,r,u){R[t]=function(d,m,w,y,N,x,k,U,K,Z,G,vt,it,H,V,pt,bt){var mt,Ot=bt-1>>1,St=N[x+0]|k[U+0]<<16,Rt=K[Z+0]|G[vt+0]<<16;e(d!=null);var _t=3*St+Rt+131074>>2;for(r(d[m+0],255&_t,_t>>16,it,H),w!=null&&(_t=3*Rt+St+131074>>2,r(w[y+0],255&_t,_t>>16,V,pt)),mt=1;mt<=Ot;++mt){var se=N[x+mt]|k[U+mt]<<16,le=K[Z+mt]|G[vt+mt]<<16,ae=St+se+Rt+le+524296,ne=ae+2*(se+Rt)>>3;_t=ne+St>>1,St=(ae=ae+2*(St+le)>>3)+se>>1,r(d[m+2*mt-1],255&_t,_t>>16,it,H+(2*mt-1)*u),r(d[m+2*mt-0],255&St,St>>16,it,H+(2*mt-0)*u),w!=null&&(_t=ae+Rt>>1,St=ne+le>>1,r(w[y+2*mt-1],255&_t,_t>>16,V,pt+(2*mt-1)*u),r(w[y+2*mt+0],255&St,St>>16,V,pt+(2*mt+0)*u)),St=se,Rt=le}1&bt||(_t=3*St+Rt+131074>>2,r(d[m+bt-1],255&_t,_t>>16,it,H+(bt-1)*u),w!=null&&(_t=3*Rt+St+131074>>2,r(w[y+bt-1],255&_t,_t>>16,V,pt+(bt-1)*u)))}}function yt(){bn[qa]=eu,bn[Da]=Ms,bn[Is]=nu,bn[Ra]=Es,bn[Ta]=qs,bn[Ro]=Ds,bn[Cs]=ru,bn[To]=Ms,bn[zo]=Es,bn[za]=qs,bn[Uo]=Ds}function jt(t){return t&~iu?0>t?0:255:t>>Rs}function Dt(t,r){return jt((19077*t>>8)+(26149*r>>8)-14234)}function Kt(t,r,u){return jt((19077*t>>8)-(6419*r>>8)-(13320*u>>8)+8708)}function Qt(t,r){return jt((19077*t>>8)+(33050*r>>8)-17685)}function re(t,r,u,d,m){d[m+0]=Dt(t,u),d[m+1]=Kt(t,r,u),d[m+2]=Qt(t,r)}function Ne(t,r,u,d,m){d[m+0]=Qt(t,r),d[m+1]=Kt(t,r,u),d[m+2]=Dt(t,u)}function Se(t,r,u,d,m){var w=Kt(t,r,u);r=w<<3&224|Qt(t,r)>>3,d[m+0]=248&Dt(t,u)|w>>5,d[m+1]=r}function Be(t,r,u,d,m){var w=240&Qt(t,r)|15;d[m+0]=240&Dt(t,u)|Kt(t,r,u)>>4,d[m+1]=w}function Ye(t,r,u,d,m){d[m+0]=255,re(t,r,u,d,m+1)}function Te(t,r,u,d,m){Ne(t,r,u,d,m),d[m+3]=255}function kn(t,r,u,d,m){re(t,r,u,d,m),d[m+3]=255}function ln(t,r){return 0>t?0:t>r?r:t}function nr(t,r,u){R[t]=function(d,m,w,y,N,x,k,U,K){for(var Z=U+(-2&K)*u;U!=Z;)r(d[m+0],w[y+0],N[x+0],k,U),r(d[m+1],w[y+0],N[x+0],k,U+u),m+=2,++y,++x,U+=2*u;1&K&&r(d[m+0],w[y+0],N[x+0],k,U)}}function Oa(t,r,u){return u==0?t==0?r==0?6:5:r==0?4:0:u}function Hi(t,r,u,d,m){switch(t>>>30){case 3:bi(r,u,d,m,0);break;case 2:Ki(r,u,d,m);break;case 1:jn(r,u,d,m)}}function Wi(t,r){var u,d,m=r.M,w=r.Nb,y=t.oc,N=t.pc+40,x=t.oc,k=t.pc+584,U=t.oc,K=t.pc+600;for(u=0;16>u;++u)y[N+32*u-1]=129;for(u=0;8>u;++u)x[k+32*u-1]=129,U[K+32*u-1]=129;for(0u;++u)a(y,N+32*u-4,y,N+32*u+12,4);for(u=-1;8>u;++u)a(x,k+32*u-4,x,k+32*u+4,4),a(U,K+32*u-4,U,K+32*u+4,4)}var G=t.Gd,vt=t.Hd+d,it=Z.ad,H=Z.Hc;if(0=t.za-1?c(V,pt,G[vt].y[15],4):a(V,pt,G[vt+1].y,0,4)),u=0;4>u;u++)V[pt+128+u]=V[pt+256+u]=V[pt+384+u]=V[pt+0+u];for(u=0;16>u;++u,H<<=2)V=y,pt=N+zs[u],On[Z.Ob[u]](V,pt),Hi(H,it,16*+u,V,pt)}else if(V=Oa(d,m,Z.Ob[0]),yr[V](y,N),H!=0)for(u=0;16>u;++u,H<<=2)Hi(H,it,16*+u,y,N+zs[u]);for(u=Z.Gc,V=Oa(d,m,Z.Dd),sr[V](x,k),sr[V](U,K),H=it,V=x,pt=k,255&(Z=u>>0)&&(170&Z?vr(H,256,V,pt):ir(H,256,V,pt)),Z=U,H=K,255&(u>>=8)&&(170&u?vr(it,320,Z,H):ir(it,320,Z,H)),mu;++u)a(G,vt+u*t.R,y,N+32*u,16);for(u=0;8>u;++u)a(it,Z+u*t.B,x,k+32*u,8),a(H,V+u*t.B,U,K+32*u,8)}}function fi(t,r,u,d,m,w,y,N,x){var k=[0],U=[0],K=0,Z=x!=null?x.kd:0,G=x??new Ri;if(t==null||12>u)return 7;G.data=t,G.w=r,G.ha=u,r=[r],u=[u],G.gb=[G.gb];t:{var vt=r,it=u,H=G.gb;if(e(t!=null),e(it!=null),e(H!=null),H[0]=0,12<=it[0]&&!n(t,vt[0],"RIFF")){if(n(t,vt[0]+8,"WEBP")){H=3;break t}var V=Bt(t,vt[0]+4);if(12>V||4294967286it[0]-8){H=7;break t}H[0]=V,vt[0]+=12,it[0]-=12}H=0}if(H!=0)return H;for(V=0H[0])H=7;else{if(!n(pt,it[0],"VP8X")){if(Bt(pt,it[0]+4)!=10){H=3;break t}if(18>H[0]){H=7;break t}var St=Bt(pt,it[0]+8),Rt=1+Ct(pt,it[0]+12);if(2147483648<=Rt*(pt=1+Ct(pt,it[0]+15))){H=3;break t}Ot!=null&&(Ot[0]=St),bt!=null&&(bt[0]=Rt),mt!=null&&(mt[0]=pt),it[0]+=18,H[0]-=18,_t[0]=1}H=0}}if(K=K[0],vt=vt[0],H!=0)return H;if(it=!!(2&vt),!V&&K)return 3;if(w!=null&&(w[0]=!!(16&vt)),y!=null&&(y[0]=it),N!=null&&(N[0]=0),y=k[0],vt=U[0],K&&it&&x==null){H=0;break}if(4>u){H=7;break}if(V&&K||!V&&!K&&!n(t,r[0],"ALPH")){u=[u],G.na=[G.na],G.P=[G.P],G.Sa=[G.Sa];t:{St=t,H=r,V=u;var _t=G.gb;bt=G.na,mt=G.P,Ot=G.Sa,Rt=22,e(St!=null),e(V!=null),pt=H[0];var se=V[0];for(e(bt!=null),e(Ot!=null),bt[0]=null,mt[0]=null,Ot[0]=0;;){if(H[0]=pt,V[0]=se,8>se){H=7;break t}var le=Bt(St,pt+4);if(4294967286_t){H=3;break t}if(!n(St,pt,"VP8 ")||!n(St,pt,"VP8L")){H=0;break t}if(se[0]V[0])H=7;else{if(pt||Rt){if(_t=Bt(_t,St+4),12<=bt&&_t>bt-12){H=3;break t}if(Z&&_t>V[0]-8){H=7;break t}mt[0]=_t,H[0]+=8,V[0]-=8,Ot[0]=Rt}else Ot[0]=5<=V[0]&&_t[St+0]==47&&!(_t[St+4]>>5),mt[0]=V[0];H=0}if(u=u[0],G.Ja=G.Ja[0],G.xa=G.xa[0],r=r[0],H!=0)break;if(4294967286u){H=7;break}N=y,Z=vt,it=w,t==null||5>u?t=0:5<=u&&t[r+0]==47&&!(t[r+4]>>5)?(V=[0],_t=[0],bt=[0],$(mt=new L,t,r,u),zt(mt,V,_t,bt)?(N!=null&&(N[0]=V[0]),Z!=null&&(Z[0]=_t[0]),it!=null&&(it[0]=bt[0]),t=1):t=0):t=0}else{if(10>u){H=7;break}N=vt,t==null||10>u||!va(t,r+3,u-3)?t=0:(Z=t[r+0]|t[r+1]<<8|t[r+2]<<16,it=16383&(t[r+7]<<8|t[r+6]),t=16383&(t[r+9]<<8|t[r+8]),1&Z||3<(Z>>1&7)||!(Z>>4&1)||Z>>5>=G.Ja||!it||!t?t=0:(y&&(y[0]=it),N&&(N[0]=t),t=1))}if(!t||(y=y[0],vt=vt[0],K&&(k[0]!=y||U[0]!=vt)))return 3;x!=null&&(x[0]=G,x.offset=r-x.w,e(4294967286>r-x.w),e(x.offset==x.ha-u));break}return H==0||H==7&&K&&x==null?(w!=null&&(w[0]|=G.na!=null&&0u||(w&=-2,y&=-2),0>w||0>y||0>=N||0>=x||w+N>d||y+x>m))return 0;if(r.v=w,r.j=y,r.va=w+N,r.o=y+x,r.U=N,r.T=x,r.da=t!=null&&0t.S){var r=t.f.RGBA;r.fb+=(t.height-1)*r.A,r.A=-r.A}else r=t.f.kb,t=t.height,r.O+=(t-1)*r.fa,r.fa=-r.fa,r.N+=(t-1>>1)*r.Ab,r.Ab=-r.Ab,r.W+=(t-1>>1)*r.Db,r.Db=-r.Db,r.F!=null&&(r.J+=(t-1)*r.lb,r.lb=-r.lb);return 0}function di(t,r,u,d){if(d==null||0>=t||0>=r)return 2;if(u!=null){if(u.Da){var m=u.cd,w=u.bd,y=-2&u.v,N=-2&u.j;if(0>y||0>N||0>=m||0>=w||y+m>t||N+w>r)return 2;t=m,r=w}if(u.da){if(!Xt(t,r,m=[u.ib],w=[u.hb]))return 2;t=m[0],r=w[0]}}d.width=t,d.height=r;t:{var x=d.width,k=d.height;if(t=d.S,0>=x||0>=k||!(t>=qa&&13>t))t=2;else{if(0>=d.Rd&&d.sd==null){y=w=m=r=0;var U=(N=x*Us[t])*k;if(11>t||(w=(k+1)/2*(r=(x+1)/2),t==12&&(y=(m=x)*k)),(k=o(U+2*w+y))==null){t=1;break t}d.sd=k,11>t?((x=d.f.RGBA).eb=k,x.fb=0,x.A=N,x.size=U):((x=d.f.kb).y=k,x.O=0,x.fa=N,x.Fd=U,x.f=k,x.N=0+U,x.Ab=r,x.Cd=w,x.ea=k,x.W=0+U+w,x.Db=r,x.Ed=w,t==12&&(x.F=k,x.J=0+U+2*w),x.Tc=y,x.lb=m)}if(r=1,m=d.S,w=d.width,y=d.height,m>=qa&&13>m)if(11>m)t=d.f.RGBA,r&=(N=Math.abs(t.A))*(y-1)+w<=t.size,r&=N>=w*Us[m],r&=t.eb!=null;else{t=d.f.kb,N=(w+1)/2,U=(y+1)/2,x=Math.abs(t.fa),k=Math.abs(t.Ab);var K=Math.abs(t.Db),Z=Math.abs(t.lb),G=Z*(y-1)+w;r&=x*(y-1)+w<=t.Fd,r&=k*(U-1)+N<=t.Cd,r=(r&=K*(U-1)+N<=t.Ed)&x>=w&k>=N&K>=N,r&=t.y!=null,r&=t.f!=null,r&=t.ea!=null,m==12&&(r&=Z>=w,r&=G<=t.Tc,r&=t.F!=null)}else r=0;t=r?0:2}}return t!=0||u!=null&&u.fd&&(t=Gi(d)),t}var rn=64,pi=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535,131071,262143,524287,1048575,2097151,4194303,8388607,16777215],gi=24,mi=32,Yi=8,an=[0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7];xt("Predictor0","PredictorAdd0"),R.Predictor0=function(){return 4278190080},R.Predictor1=function(t){return t},R.Predictor2=function(t,r,u){return r[u+0]},R.Predictor3=function(t,r,u){return r[u+1]},R.Predictor4=function(t,r,u){return r[u-1]},R.Predictor5=function(t,r,u){return Pt(Pt(t,r[u+1]),r[u+0])},R.Predictor6=function(t,r,u){return Pt(t,r[u-1])},R.Predictor7=function(t,r,u){return Pt(t,r[u+0])},R.Predictor8=function(t,r,u){return Pt(r[u-1],r[u+0])},R.Predictor9=function(t,r,u){return Pt(r[u+0],r[u+1])},R.Predictor10=function(t,r,u){return Pt(Pt(t,r[u-1]),Pt(r[u+0],r[u+1]))},R.Predictor11=function(t,r,u){var d=r[u+0];return 0>=$t(d>>24&255,t>>24&255,(r=r[u-1])>>24&255)+$t(d>>16&255,t>>16&255,r>>16&255)+$t(d>>8&255,t>>8&255,r>>8&255)+$t(255&d,255&t,255&r)?d:t},R.Predictor12=function(t,r,u){var d=r[u+0];return(qt((t>>24&255)+(d>>24&255)-((r=r[u-1])>>24&255))<<24|qt((t>>16&255)+(d>>16&255)-(r>>16&255))<<16|qt((t>>8&255)+(d>>8&255)-(r>>8&255))<<8|qt((255&t)+(255&d)-(255&r)))>>>0},R.Predictor13=function(t,r,u){var d=r[u-1];return(Gt((t=Pt(t,r[u+0]))>>24&255,d>>24&255)<<24|Gt(t>>16&255,d>>16&255)<<16|Gt(t>>8&255,d>>8&255)<<8|Gt(t>>0&255,d>>0&255))>>>0};var Mo=R.PredictorAdd0;R.PredictorAdd1=te,xt("Predictor2","PredictorAdd2"),xt("Predictor3","PredictorAdd3"),xt("Predictor4","PredictorAdd4"),xt("Predictor5","PredictorAdd5"),xt("Predictor6","PredictorAdd6"),xt("Predictor7","PredictorAdd7"),xt("Predictor8","PredictorAdd8"),xt("Predictor9","PredictorAdd9"),xt("Predictor10","PredictorAdd10"),xt("Predictor11","PredictorAdd11"),xt("Predictor12","PredictorAdd12"),xt("Predictor13","PredictorAdd13");var Ji=R.PredictorAdd2;ee("ColorIndexInverseTransform","MapARGB","32b",function(t){return t>>8&255},function(t){return t}),ee("VP8LColorIndexInverseTransformAlpha","MapAlpha","8b",function(t){return t},function(t){return t>>8&255});var Ba,Fn=R.ColorIndexInverseTransform,Xi=R.MapARGB,Eo=R.VP8LColorIndexInverseTransformAlpha,qo=R.MapAlpha,gr=R.VP8LPredictorsAdd=[];gr.length=16,(R.VP8LPredictors=[]).length=16,(R.VP8LPredictorsAdd_C=[]).length=16,(R.VP8LPredictors_C=[]).length=16;var gn,In,mr,Gn,rr,vi,Cn,bi,Ki,vr,jn,ir,zr,wi,Ur,br,Zi,mn,ar,be,we,Fe,De,or,wr,yi,Ma,xs,Ss=o(511),_s=o(2041),Ps=o(225),ks=o(767),Fs=0,Do=_s,Ea=Ps,hn=ks,vn=Ss,qa=0,Da=1,Is=2,Ra=3,Ta=4,Ro=5,Cs=6,To=7,zo=8,za=9,Uo=10,zc=[2,3,7],Uc=[3,3,11],js=[280,256,256,256,40],Hc=[0,1,1,1,0],Wc=[17,18,0,1,2,3,4,5,16,6,7,8,9,10,11,12,13,14,15],Vc=[24,7,23,25,40,6,39,41,22,26,38,42,56,5,55,57,21,27,54,58,37,43,72,4,71,73,20,28,53,59,70,74,36,44,88,69,75,52,60,3,87,89,19,29,86,90,35,45,68,76,85,91,51,61,104,2,103,105,18,30,102,106,34,46,84,92,67,77,101,107,50,62,120,1,119,121,83,93,17,31,100,108,66,78,118,122,33,47,117,123,49,63,99,109,82,94,0,116,124,65,79,16,32,98,110,48,115,125,81,95,64,114,126,97,111,80,113,127,96,112],Gc=[2954,2956,2958,2962,2970,2986,3018,3082,3212,3468,3980,5004],Yc=8,Ho=[4,5,6,7,8,9,10,10,11,12,13,14,15,16,17,17,18,19,20,20,21,21,22,22,23,23,24,25,25,26,27,28,29,30,31,32,33,34,35,36,37,37,38,39,40,41,42,43,44,45,46,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,76,77,78,79,80,81,82,83,84,85,86,87,88,89,91,93,95,96,98,100,101,102,104,106,108,110,112,114,116,118,122,124,126,128,130,132,134,136,138,140,143,145,148,151,154,157],Wo=[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,119,122,125,128,131,134,137,140,143,146,149,152,155,158,161,164,167,170,173,177,181,185,189,193,197,201,205,209,213,217,221,225,229,234,239,245,249,254,259,264,269,274,279,284],$i=null,Jc=[[173,148,140,0],[176,155,140,135,0],[180,157,141,134,130,0],[254,254,243,230,196,177,153,140,133,130,129,0]],Xc=[0,1,4,8,5,2,3,6,9,12,13,10,7,11,14,15],Os=[-0,1,-1,2,-2,3,4,6,-3,5,-4,-5,-6,7,-7,8,-8,-9],Kc=[[[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]],[[253,136,254,255,228,219,128,128,128,128,128],[189,129,242,255,227,213,255,219,128,128,128],[106,126,227,252,214,209,255,255,128,128,128]],[[1,98,248,255,236,226,255,255,128,128,128],[181,133,238,254,221,234,255,154,128,128,128],[78,134,202,247,198,180,255,219,128,128,128]],[[1,185,249,255,243,255,128,128,128,128,128],[184,150,247,255,236,224,128,128,128,128,128],[77,110,216,255,236,230,128,128,128,128,128]],[[1,101,251,255,241,255,128,128,128,128,128],[170,139,241,252,236,209,255,255,128,128,128],[37,116,196,243,228,255,255,255,128,128,128]],[[1,204,254,255,245,255,128,128,128,128,128],[207,160,250,255,238,128,128,128,128,128,128],[102,103,231,255,211,171,128,128,128,128,128]],[[1,152,252,255,240,255,128,128,128,128,128],[177,135,243,255,234,225,128,128,128,128,128],[80,129,211,255,194,224,128,128,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[246,1,255,128,128,128,128,128,128,128,128],[255,128,128,128,128,128,128,128,128,128,128]]],[[[198,35,237,223,193,187,162,160,145,155,62],[131,45,198,221,172,176,220,157,252,221,1],[68,47,146,208,149,167,221,162,255,223,128]],[[1,149,241,255,221,224,255,255,128,128,128],[184,141,234,253,222,220,255,199,128,128,128],[81,99,181,242,176,190,249,202,255,255,128]],[[1,129,232,253,214,197,242,196,255,255,128],[99,121,210,250,201,198,255,202,128,128,128],[23,91,163,242,170,187,247,210,255,255,128]],[[1,200,246,255,234,255,128,128,128,128,128],[109,178,241,255,231,245,255,255,128,128,128],[44,130,201,253,205,192,255,255,128,128,128]],[[1,132,239,251,219,209,255,165,128,128,128],[94,136,225,251,218,190,255,255,128,128,128],[22,100,174,245,186,161,255,199,128,128,128]],[[1,182,249,255,232,235,128,128,128,128,128],[124,143,241,255,227,234,128,128,128,128,128],[35,77,181,251,193,211,255,205,128,128,128]],[[1,157,247,255,236,231,255,255,128,128,128],[121,141,235,255,225,227,255,255,128,128,128],[45,99,188,251,195,217,255,224,128,128,128]],[[1,1,251,255,213,255,128,128,128,128,128],[203,1,248,255,255,128,128,128,128,128,128],[137,1,177,255,224,255,128,128,128,128,128]]],[[[253,9,248,251,207,208,255,192,128,128,128],[175,13,224,243,193,185,249,198,255,255,128],[73,17,171,221,161,179,236,167,255,234,128]],[[1,95,247,253,212,183,255,255,128,128,128],[239,90,244,250,211,209,255,255,128,128,128],[155,77,195,248,188,195,255,255,128,128,128]],[[1,24,239,251,218,219,255,205,128,128,128],[201,51,219,255,196,186,128,128,128,128,128],[69,46,190,239,201,218,255,228,128,128,128]],[[1,191,251,255,255,128,128,128,128,128,128],[223,165,249,255,213,255,128,128,128,128,128],[141,124,248,255,255,128,128,128,128,128,128]],[[1,16,248,255,255,128,128,128,128,128,128],[190,36,230,255,236,255,128,128,128,128,128],[149,1,255,128,128,128,128,128,128,128,128]],[[1,226,255,128,128,128,128,128,128,128,128],[247,192,255,128,128,128,128,128,128,128,128],[240,128,255,128,128,128,128,128,128,128,128]],[[1,134,252,255,255,128,128,128,128,128,128],[213,62,250,255,255,128,128,128,128,128,128],[55,93,255,128,128,128,128,128,128,128,128]],[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]]],[[[202,24,213,235,186,191,220,160,240,175,255],[126,38,182,232,169,184,228,174,255,187,128],[61,46,138,219,151,178,240,170,255,216,128]],[[1,112,230,250,199,191,247,159,255,255,128],[166,109,228,252,211,215,255,174,128,128,128],[39,77,162,232,172,180,245,178,255,255,128]],[[1,52,220,246,198,199,249,220,255,255,128],[124,74,191,243,183,193,250,221,255,255,128],[24,71,130,219,154,170,243,182,255,255,128]],[[1,182,225,249,219,240,255,224,128,128,128],[149,150,226,252,216,205,255,171,128,128,128],[28,108,170,242,183,194,254,223,255,255,128]],[[1,81,230,252,204,203,255,192,128,128,128],[123,102,209,247,188,196,255,233,128,128,128],[20,95,153,243,164,173,255,203,128,128,128]],[[1,222,248,255,216,213,128,128,128,128,128],[168,175,246,252,235,205,255,255,128,128,128],[47,116,215,255,211,212,255,255,128,128,128]],[[1,121,236,253,212,214,255,255,128,128,128],[141,84,213,252,201,202,255,219,128,128,128],[42,80,160,240,162,185,255,205,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[244,1,255,128,128,128,128,128,128,128,128],[238,1,255,128,128,128,128,128,128,128,128]]]],Zc=[[[231,120,48,89,115,113,120,152,112],[152,179,64,126,170,118,46,70,95],[175,69,143,80,85,82,72,155,103],[56,58,10,171,218,189,17,13,152],[114,26,17,163,44,195,21,10,173],[121,24,80,195,26,62,44,64,85],[144,71,10,38,171,213,144,34,26],[170,46,55,19,136,160,33,206,71],[63,20,8,114,114,208,12,9,226],[81,40,11,96,182,84,29,16,36]],[[134,183,89,137,98,101,106,165,148],[72,187,100,130,157,111,32,75,80],[66,102,167,99,74,62,40,234,128],[41,53,9,178,241,141,26,8,107],[74,43,26,146,73,166,49,23,157],[65,38,105,160,51,52,31,115,128],[104,79,12,27,217,255,87,17,7],[87,68,71,44,114,51,15,186,23],[47,41,14,110,182,183,21,17,194],[66,45,25,102,197,189,23,18,22]],[[88,88,147,150,42,46,45,196,205],[43,97,183,117,85,38,35,179,61],[39,53,200,87,26,21,43,232,171],[56,34,51,104,114,102,29,93,77],[39,28,85,171,58,165,90,98,64],[34,22,116,206,23,34,43,166,73],[107,54,32,26,51,1,81,43,31],[68,25,106,22,64,171,36,225,114],[34,19,21,102,132,188,16,76,124],[62,18,78,95,85,57,50,48,51]],[[193,101,35,159,215,111,89,46,111],[60,148,31,172,219,228,21,18,111],[112,113,77,85,179,255,38,120,114],[40,42,1,196,245,209,10,25,109],[88,43,29,140,166,213,37,43,154],[61,63,30,155,67,45,68,1,209],[100,80,8,43,154,1,51,26,71],[142,78,78,16,255,128,34,197,171],[41,40,5,102,211,183,4,1,221],[51,50,17,168,209,192,23,25,82]],[[138,31,36,171,27,166,38,44,229],[67,87,58,169,82,115,26,59,179],[63,59,90,180,59,166,93,73,154],[40,40,21,116,143,209,34,39,175],[47,15,16,183,34,223,49,45,183],[46,17,33,183,6,98,15,32,183],[57,46,22,24,128,1,54,17,37],[65,32,73,115,28,128,23,128,205],[40,3,9,115,51,192,18,6,223],[87,37,9,115,59,77,64,21,47]],[[104,55,44,218,9,54,53,130,226],[64,90,70,205,40,41,23,26,57],[54,57,112,184,5,41,38,166,213],[30,34,26,133,152,116,10,32,134],[39,19,53,221,26,114,32,73,255],[31,9,65,234,2,15,1,118,73],[75,32,12,51,192,255,160,43,51],[88,31,35,67,102,85,55,186,85],[56,21,23,111,59,205,45,37,192],[55,38,70,124,73,102,1,34,98]],[[125,98,42,88,104,85,117,175,82],[95,84,53,89,128,100,113,101,45],[75,79,123,47,51,128,81,171,1],[57,17,5,71,102,57,53,41,49],[38,33,13,121,57,73,26,1,85],[41,10,67,138,77,110,90,47,114],[115,21,2,10,102,255,166,23,6],[101,29,16,10,85,128,101,196,26],[57,18,10,102,102,213,34,20,43],[117,20,15,36,163,128,68,1,26]],[[102,61,71,37,34,53,31,243,192],[69,60,71,38,73,119,28,222,37],[68,45,128,34,1,47,11,245,171],[62,17,19,70,146,85,55,62,70],[37,43,37,154,100,163,85,160,1],[63,9,92,136,28,64,32,201,85],[75,15,9,9,64,255,184,119,16],[86,6,28,5,64,255,25,248,1],[56,8,17,132,137,255,55,116,128],[58,15,20,82,135,57,26,121,40]],[[164,50,31,137,154,133,25,35,218],[51,103,44,131,131,123,31,6,158],[86,40,64,135,148,224,45,183,128],[22,26,17,131,240,154,14,1,209],[45,16,21,91,64,222,7,1,197],[56,21,39,155,60,138,23,102,213],[83,12,13,54,192,255,68,47,28],[85,26,85,85,128,128,32,146,171],[18,11,7,63,144,171,4,4,246],[35,27,10,146,174,171,12,26,128]],[[190,80,35,99,180,80,126,54,45],[85,126,47,87,176,51,41,20,32],[101,75,128,139,118,146,116,128,85],[56,41,15,176,236,85,37,9,62],[71,30,17,119,118,255,17,18,138],[101,38,60,138,55,70,43,26,142],[146,36,19,30,171,255,97,27,20],[138,45,61,62,219,1,81,188,64],[32,41,20,117,151,142,20,21,163],[112,19,12,61,195,128,48,4,24]]],$c=[[[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[176,246,255,255,255,255,255,255,255,255,255],[223,241,252,255,255,255,255,255,255,255,255],[249,253,253,255,255,255,255,255,255,255,255]],[[255,244,252,255,255,255,255,255,255,255,255],[234,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255]],[[255,246,254,255,255,255,255,255,255,255,255],[239,253,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[251,255,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[251,254,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,254,253,255,254,255,255,255,255,255,255],[250,255,254,255,254,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[217,255,255,255,255,255,255,255,255,255,255],[225,252,241,253,255,255,254,255,255,255,255],[234,250,241,250,253,255,253,254,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[223,254,254,255,255,255,255,255,255,255,255],[238,253,254,254,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[249,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,255,255,255,255,255,255,255,255,255],[247,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[252,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[186,251,250,255,255,255,255,255,255,255,255],[234,251,244,254,255,255,255,255,255,255,255],[251,251,243,253,254,255,254,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[236,253,254,255,255,255,255,255,255,255,255],[251,253,253,254,254,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[254,254,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[254,254,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[248,255,255,255,255,255,255,255,255,255,255],[250,254,252,254,255,255,255,255,255,255,255],[248,254,249,253,255,255,255,255,255,255,255]],[[255,253,253,255,255,255,255,255,255,255,255],[246,253,253,255,255,255,255,255,255,255,255],[252,254,251,254,254,255,255,255,255,255,255]],[[255,254,252,255,255,255,255,255,255,255,255],[248,254,253,255,255,255,255,255,255,255,255],[253,255,254,254,255,255,255,255,255,255,255]],[[255,251,254,255,255,255,255,255,255,255,255],[245,251,254,255,255,255,255,255,255,255,255],[253,253,254,255,255,255,255,255,255,255,255]],[[255,251,253,255,255,255,255,255,255,255,255],[252,253,254,255,255,255,255,255,255,255,255],[255,254,255,255,255,255,255,255,255,255,255]],[[255,252,255,255,255,255,255,255,255,255,255],[249,255,254,255,255,255,255,255,255,255,255],[255,255,254,255,255,255,255,255,255,255,255]],[[255,255,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]]],Qc=[0,1,2,3,6,4,5,6,6,6,6,6,6,6,6,7,0],yr=[],On=[],sr=[],tu=1,Bs=2,Lr=[],bn=[];st("UpsampleRgbLinePair",re,3),st("UpsampleBgrLinePair",Ne,3),st("UpsampleRgbaLinePair",kn,4),st("UpsampleBgraLinePair",Te,4),st("UpsampleArgbLinePair",Ye,4),st("UpsampleRgba4444LinePair",Be,2),st("UpsampleRgb565LinePair",Se,2);var eu=R.UpsampleRgbLinePair,nu=R.UpsampleBgrLinePair,Ms=R.UpsampleRgbaLinePair,Es=R.UpsampleBgraLinePair,qs=R.UpsampleArgbLinePair,Ds=R.UpsampleRgba4444LinePair,ru=R.UpsampleRgb565LinePair,Ua=16,Ha=1<d.ca.S||(alert("todo:WebPInitConvertARGBToYUV"),d.ca.f.kb.F!=null&&J()),d.Pb&&0(x=u.Md)?0:100k;++k)12>(K=m.pb[k]).lc&&(K.ia=x*hu[0>K.lc?0:K.lc]>>3),U|=K.ia;U&&(alert("todo:VP8InitRandom"),m.ia=1)}m.Ga=u.Id,100m.Ga&&(m.Ga=0)}vo(t,d)||(r=t.a)}}else r=t.a}r==0&&y.Oa!=null&&y.Oa.fd&&(r=Gi(y.ba))}y=r}w=y!=0?null:11>w?N.f.RGBA.eb:N.f.kb.y}else w=null;return w};var Us=[3,4,3,4,4,2,2,4,4,4,2,1,1]};function g(R,gt){for(var dt="",F=0;F<4;F++)dt+=String.fromCharCode(R[gt++]);return dt}function b(R,gt){return(R[gt+0]<<0|R[gt+1]<<8|R[gt+2]<<16)>>>0}function A(R,gt){return(R[gt+0]<<0|R[gt+1]<<8|R[gt+2]<<16|R[gt+3]<<24)>>>0}new f;var S=[0],p=[0],O=[],I=new f,q=i,_=function(R,gt){var dt={},F=0,P=!1,z=0,D=0;if(dt.frames=[],!function(j,M,W,Y){for(var Q=0;Q>1&1}lt!="ANMF"&&(gt+=ft)}return dt}}(q,0);_.response=q,_.rgbaoutput=!0,_.dataurl=!1;var B=_.header?_.header:null,X=_.frames?_.frames:null;if(B){B.loop_counter=B.loop_count,S=[B.canvas_height],p=[B.canvas_width];for(var ot=0;ot>>1)&255;return _},f=function(S,p,O){var I,q,_,B,X=[],ot=S.length;X[0]=4;for(var ut=0;ut>>lt&255,lt+=B.bits;gt[z]=P>>>lt&255}}if(B.bits===16){R=(tt=new Uint32Array(B.decodePixels().buffer)).length,dt=new Uint8Array(R*(32/B.pixelBitlength)*B.colors),gt=new Uint8Array(R*(32/B.pixelBitlength)),F=B.colors>1,z=0,D=0;for(var ft=0;z>>0&255,F&&(dt[D++]=P>>>16&255,P=tt[z++],dt[D++]=P>>>0&255),gt[ft++]=P>>>16&255;_=8}I!==i.image_compression.NONE&&e()?(S=n(dt,B.width*B.colors,B.colors,I),wt=n(gt,B.width,1,I)):(S=dt,wt=gt,at=void 0)}if(B.colorType===3&&(q=this.color_spaces.INDEXED,ut=B.palette,B.transparency.indexed)){var ht=B.transparency.indexed,kt=0;for(z=0,R=ht.length;z=0;i--){for(var a=this.bottom_up?i:this.height-1-i,c=0;c>7-h&1];this.data[l+4*h]=f.blue,this.data[l+4*h+1]=f.green,this.data[l+4*h+2]=f.red,this.data[l+4*h+3]=255}n!==0&&(this.pos+=4-n)}},En.prototype.bit4=function(){for(var i=Math.ceil(this.width/2),e=i%4,n=this.height-1;n>=0;n--){for(var a=this.bottom_up?n:this.height-1-n,c=0;c>4,f=15&o,g=this.palette[h];if(this.data[l]=g.blue,this.data[l+1]=g.green,this.data[l+2]=g.red,this.data[l+3]=255,2*c+1>=this.width)break;g=this.palette[f],this.data[l+4]=g.blue,this.data[l+4+1]=g.green,this.data[l+4+2]=g.red,this.data[l+4+3]=255}e!==0&&(this.pos+=4-e)}},En.prototype.bit8=function(){for(var i=this.width%4,e=this.height-1;e>=0;e--){for(var n=this.bottom_up?e:this.height-1-e,a=0;a=0;n--){for(var a=this.bottom_up?n:this.height-1-n,c=0;c>5&e)/e*255|0,f=(o>>10&e)/e*255|0,g=o>>15?255:0,b=a*this.width*4+4*c;this.data[b]=f,this.data[b+1]=h,this.data[b+2]=l,this.data[b+3]=g}this.pos+=i}},En.prototype.bit16=function(){for(var i=this.width%3,e=parseInt("11111",2),n=parseInt("111111",2),a=this.height-1;a>=0;a--){for(var c=this.bottom_up?a:this.height-1-a,o=0;o>5&n)/n*255|0,g=(l>>11)/e*255|0,b=c*this.width*4+4*o;this.data[b]=g,this.data[b+1]=f,this.data[b+2]=h,this.data[b+3]=255}this.pos+=i}},En.prototype.bit24=function(){for(var i=this.height-1;i>=0;i--){for(var e=this.bottom_up?i:this.height-1-i,n=0;n=0;i--)for(var e=this.bottom_up?i:this.height-1-i,n=0;na&&(c.push(i.slice(f,o)),h=0,f=o),h+=e[o],o++;return f!==o&&c.push(i.slice(f,o)),c},yc=function(i,e,n){n||(n={});var a,c,o,l,h,f,g,b=[],A=[b],S=n.textIndent||0,p=0,O=0,I=i.split(" "),q=io.apply(this,[" ",n])[0];if(f=n.lineIndent===-1?I[0].length+2:n.lineIndent||0){var _=Array(f).join(" "),B=[];I.map(function(ot){(ot=ot.split(/\s*\n/)).length>1?B=B.concat(ot.map(function(ut,wt){return(wt&&ut.length?` `:"")+ut})):B.push(ot[0])}),I=B,f=bc.apply(this,[_,n])}for(o=0,l=I.length;oe||X){if(O>e){for(h=wc.apply(this,[a,c,e-(S+p),e]),b.push(h.shift()),b=[h.pop()];h.length;)A.push([h.shift()]);O=c.slice(a.length-(b[0]?b[0].length:0)).reduce(function(ot,ut){return ot+ut},0)}else b=[a];A.push(b),S=O+f,p=q}else b.push(a),S+=p+O,p=q}return g=f?function(ot,ut){return(ut?_:"")+ot.join(" ")}:function(ot){return ot.join(" ")},A.map(g)},_i.splitTextToSize=function(i,e,n){var a,c=(n=n||{}).fontSize||this.internal.getFontSize(),o=function(b){if(b.widths&&b.kerning)return{widths:b.widths,kerning:b.kerning};var A=this.internal.getFont(b.fontName,b.fontStyle);return A.metadata.Unicode?{widths:A.metadata.Unicode.widths||{0:1},kerning:A.metadata.Unicode.kerning||{}}:{font:A.metadata,fontSize:this.internal.getFontSize(),charSpace:this.internal.getCharSpace()}}.call(this,n);a=Array.isArray(i)?i:String(i).split(/\r?\n/);var l=1*this.internal.scaleFactor*e/c;o.textIndent=n.textIndent?1*n.textIndent*this.internal.scaleFactor/c:0,o.lineIndent=n.lineIndent;var h,f,g=[];for(h=0,f=a.length;himport("./index.es-eac68d26.js"),["assets/index.es-eac68d26.js","assets/index-6614c9bf.js","assets/index-1c16127b.css"])).catch(function(n){return Promise.reject(new Error("Could not load canvg: "+n))}).then(function(n){return n.default?n.default:n})}Tt.API.addSvgAsImage=function(n,a,c,o,l,h,f,g){if(isNaN(a)||isNaN(c))throw ve.error("jsPDF.addSvgAsImage: Invalid coordinates",arguments),new Error("Invalid coordinates passed to jsPDF.addSvgAsImage");if(isNaN(o)||isNaN(l))throw ve.error("jsPDF.addSvgAsImage: Invalid measurements",arguments),new Error("Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage");var b=document.createElement("canvas");b.width=o,b.height=l;var A=b.getContext("2d");A.fillStyle="#fff",A.fillRect(0,0,b.width,b.height);var S={ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0},p=this;return e().then(function(O){return O.fromString(A,n,S)},function(){return Promise.reject(new Error("Could not load canvg."))}).then(function(O){return O.render(S)}).then(function(){p.addImage(b.toDataURL("image/jpeg",1),a,c,o,l,f,g)})}}(),Tt.API.putTotalPages=function(i){var e,n=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(e=new RegExp(i,"g"),n=this.internal.getNumberOfPages()):(e=new RegExp(this.pdfEscape16(i,this.internal.getFont()),"g"),n=this.pdfEscape16(this.internal.getNumberOfPages()+"",this.internal.getFont()));for(var a=1;a<=this.internal.getNumberOfPages();a++)for(var c=0;c1){for(b=0;be||X){if(O>e){for(h=wc.apply(this,[a,c,e-(S+p),e]),b.push(h.shift()),b=[h.pop()];h.length;)A.push([h.shift()]);O=c.slice(a.length-(b[0]?b[0].length:0)).reduce(function(ot,ut){return ot+ut},0)}else b=[a];A.push(b),S=O+f,p=q}else b.push(a),S+=p+O,p=q}return g=f?function(ot,ut){return(ut?_:"")+ot.join(" ")}:function(ot){return ot.join(" ")},A.map(g)},_i.splitTextToSize=function(i,e,n){var a,c=(n=n||{}).fontSize||this.internal.getFontSize(),o=function(b){if(b.widths&&b.kerning)return{widths:b.widths,kerning:b.kerning};var A=this.internal.getFont(b.fontName,b.fontStyle);return A.metadata.Unicode?{widths:A.metadata.Unicode.widths||{0:1},kerning:A.metadata.Unicode.kerning||{}}:{font:A.metadata,fontSize:this.internal.getFontSize(),charSpace:this.internal.getCharSpace()}}.call(this,n);a=Array.isArray(i)?i:String(i).split(/\r?\n/);var l=1*this.internal.scaleFactor*e/c;o.textIndent=n.textIndent?1*n.textIndent*this.internal.scaleFactor/c:0,o.lineIndent=n.lineIndent;var h,f,g=[];for(h=0,f=a.length;himport("./index.es-93d23083.js"),["assets/index.es-93d23083.js","assets/index-84a3106f.js","assets/index-c064dc85.css"])).catch(function(n){return Promise.reject(new Error("Could not load canvg: "+n))}).then(function(n){return n.default?n.default:n})}Tt.API.addSvgAsImage=function(n,a,c,o,l,h,f,g){if(isNaN(a)||isNaN(c))throw ve.error("jsPDF.addSvgAsImage: Invalid coordinates",arguments),new Error("Invalid coordinates passed to jsPDF.addSvgAsImage");if(isNaN(o)||isNaN(l))throw ve.error("jsPDF.addSvgAsImage: Invalid measurements",arguments),new Error("Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage");var b=document.createElement("canvas");b.width=o,b.height=l;var A=b.getContext("2d");A.fillStyle="#fff",A.fillRect(0,0,b.width,b.height);var S={ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0},p=this;return e().then(function(O){return O.fromString(A,n,S)},function(){return Promise.reject(new Error("Could not load canvg."))}).then(function(O){return O.render(S)}).then(function(){p.addImage(b.toDataURL("image/jpeg",1),a,c,o,l,f,g)})}}(),Tt.API.putTotalPages=function(i){var e,n=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(e=new RegExp(i,"g"),n=this.internal.getNumberOfPages()):(e=new RegExp(this.pdfEscape16(i,this.internal.getFont()),"g"),n=this.pdfEscape16(this.internal.getNumberOfPages()+"",this.internal.getFont()));for(var a=1;a<=this.internal.getNumberOfPages();a++)for(var c=0;c1){for(b=0;b Gosling React Example - - + +