auto-champion-select 1.10.0 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +31 -31
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(`.dropdown-champions-default{position:inherit;inline-size:100%}.dropdown-champions-default.dropdown-drop-up::part(ui-dropdown-menu),.dropdown-champions-default.dropdown-drop-up::part(ui-dropdown-content),.dropdown-champions-default.dropdown-drop-up::part(ui-dropdown-options){top:auto;bottom:100%;transform-origin:bottom}.dropdown-champions-default .controlado-champion-option__content{display:inline-flex;align-items:center;gap:8px;width:100%;min-width:0;line-height:20px;vertical-align:middle}.dropdown-champions-default .controlado-champion-option__icon{display:block;flex:0 0 20px;width:20px;height:20px;border:1px solid rgba(200,170,110,.65);border-radius:50%;background:#010a13;object-fit:cover;box-sizing:border-box;pointer-events:none}.dropdown-champions-default img.controlado-champion-option__icon{clip-path:circle(41.67% at 51.5% 51.5%);object-position:center;transform:scale(1.2);transform-origin:51.5% 51.5%}.dropdown-champions-default .controlado-champion-option__static-icon{display:grid;place-items:center;color:#f0e6d2;font-family:var(--font-display);font-size:13px;font-weight:700;line-height:1}.dropdown-champions-default .controlado-champion-option__text{display:flex;align-items:baseline;gap:8px;width:100%;min-width:0}.dropdown-champions-default .controlado-champion-option__name{flex:0 0 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dropdown-champions-default .controlado-champion-option__description{flex:1 1 auto;min-width:0;color:#a09b8ce6;font-size:11px;line-height:1;overflow:hidden;text-align:right;text-overflow:ellipsis;white-space:nowrap}.champion-priority-selector{display:grid;gap:0;padding:2px 0 3px}.champion-priority-selector__scroll{position:relative;inline-size:100%;height:58px;border:1px solid rgba(120,90,40,.7);border-top:0;background:rgba(30,35,40,.5);box-sizing:border-box}.champion-priority-selector__track{display:inline-flex;align-items:center;gap:12px;min-width:max-content;min-height:45px;padding:10px 8px 8px;box-sizing:border-box}.champion-priority-selector__empty{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;color:#5f5b4f;font-family:var(--font-body);font-size:11px;line-height:13px;text-align:center;white-space:nowrap;pointer-events:none}.champion-priority-selector__icon{position:relative;flex:0 0 auto;width:34px;height:34px;border:1px solid #c8aa6e;border-radius:50%;background:#1e2328;box-shadow:0 0 0 1px #010a13e6;box-sizing:border-box;cursor:grab;outline:none}.champion-priority-selector__icon:focus{border-color:#f0e6d2}.champion-priority-selector__icon--dragging{cursor:grabbing;filter:brightness(1.15);z-index:1}.champion-priority-selector__icon:before,.champion-priority-selector__remove,.champion-priority-selector__position-badge{display:grid;place-items:center;width:17px;height:17px;padding:0;border-radius:50%;box-sizing:border-box;font-family:var(--font-body);font-size:10px;font-weight:700;line-height:1;z-index:2}.champion-priority-selector__icon:before{content:attr(data-rank);position:absolute;left:-6px;top:-6px;border:1px solid #c8aa6e;background:#010a13;color:#f0e6d2;text-align:center;pointer-events:none}.champion-priority-selector__icon>img{position:relative;z-index:0;display:block;width:100%;height:100%;border-radius:50%;clip-path:circle(45.87% at 50% 50%);object-fit:cover;object-position:center;pointer-events:none;transform:scale(1.09);transform-origin:center}.champion-priority-selector__icon--random{display:grid;place-items:center;color:#f0e6d2;font-family:var(--font-display);font-weight:700}.champion-priority-selector__random-icon{font-size:20px;line-height:1;transform:translateY(-.5px);pointer-events:none}.champion-priority-selector__remove{position:absolute;right:-6px;bottom:-6px;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:1px solid #785a28;background:#1e2328;color:#c8aa6e;cursor:pointer;font-family:var(--font-display);font-size:0;text-align:center}.champion-priority-selector__remove:before{content:attr(data-icon);font-family:var(--font-display);font-size:7px;line-height:1;transform:translate(.4px,-.1px)}.champion-priority-selector__remove:hover{border-color:#c8aa6e;color:#f0e6d2}.champion-priority-selector__position-badge{position:absolute;left:-6px;bottom:-6px;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:1px solid #785a28;background:#010a13;color:#c8aa6e;cursor:pointer}.champion-priority-selector__position-badge:hover,.champion-priority-selector__position-badge:focus{border-color:#c8aa6e;color:#f0e6d2;outline:none}.champion-priority-selector__position-badge--empty{background:#1e2328;font-size:0}.champion-priority-selector__position-badge--empty:before{content:"+";font-family:var(--font-body);font-size:12px;line-height:1;transform:translate(.25px,.4px)}.champion-priority-selector__position-badge--random{left:auto;right:-6px;top:-6px;bottom:auto}.champion-priority-selector__position-badge--random:before{content:"";display:block;width:11px;height:11px;background:url(/fe/lol-tft-team-planner/images/team_editor_trait_filter_icon.png) center / contain no-repeat;transform:none}.champion-priority-selector__position-badge--random:hover:before,.champion-priority-selector__position-badge--random:focus:before,.champion-priority-selector__position-badge--random.champion-priority-selector__position-badge--active:before{background-image:url(/fe/lol-tft-team-planner/images/team_editor_trait_filter_icon_pressed.png)}.champion-priority-selector__position-badge--random.champion-priority-selector__position-badge--active{border-color:#c8aa6e;background:#010a13}.champion-priority-selector__position-badge img{display:block;width:11px;height:11px;object-fit:contain;transform:translate(.1px)}.champion-priority-selector__position-badge:after{content:attr(data-count);position:absolute;right:-5px;top:-5px;display:none;place-items:center;width:11px;min-width:11px;height:11px;border:1px solid #785a28;border-radius:50%;background:#010a13;box-sizing:border-box;color:#f0e6d2;font-family:var(--font-body);font-size:7px;font-weight:700;line-height:1;text-align:center}.champion-priority-selector__position-badge[data-count]:after{display:grid}.champion-priority-selector__position-menu{position:fixed;z-index:10002;display:flex;gap:4px;padding:5px;border:1px solid #785a28;background:#010a13;box-shadow:0 0 0 1px #010a13d9,0 4px 16px #0000008c;box-sizing:border-box}.champion-priority-selector__position-menu[hidden]{display:none}.champion-priority-selector__position-option{display:grid;place-items:center;width:28px;height:28px;padding:0;border:1px solid #463714;background:#1e2328;box-sizing:border-box;cursor:pointer}.champion-priority-selector__position-option:hover,.champion-priority-selector__position-option--selected{border-color:#c8aa6e;background:#0f1b2d}.champion-priority-selector__position-option img{display:block;width:18px;height:18px;pointer-events:none}.auto-select-checkboxes-div{display:flex;border-top:thin solid #1e282d}.auto-select-checkbox{margin:auto}.auto-select-checkbox:last-child{margin-right:17px}.auto-select-social-roster-section__header{position:relative;padding-right:28px;box-sizing:border-box}.auto-select-social-roster-section .group-name,.auto-select-social-roster-section .group-name-text{min-width:0}.auto-select-settings-trigger{display:grid;place-items:center;width:18px;height:18px;padding:0;border:0;background:transparent;box-shadow:none;box-sizing:border-box;cursor:pointer;outline:none}.auto-select-social-roster-section__header>.auto-select-settings-trigger{position:absolute;right:8px;top:50%;transform:translateY(-50%)}.auto-select-champ-select-menu__title>.auto-select-settings-trigger{position:absolute;right:5px;top:50%;transform:translateY(-50%)}.auto-select-settings-trigger:before{content:"";display:block;width:13px;height:13px;background:#5f5b4f;opacity:.95;-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M19.43 12.98c.04-.32.07-.65.07-.98s-.02-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.37-.31-.6-.22l-2.49 1a7.34 7.34 0 0 0-1.69-.98L14.5 2.42A.5.5 0 0 0 14 2h-4a.5.5 0 0 0-.49.42l-.38 2.65c-.61.24-1.18.56-1.69.98l-2.49-1a.5.5 0 0 0-.6.22l-2 3.46a.5.5 0 0 0 .12.64l2.11 1.65c-.04.32-.08.65-.08.98s.03.66.08.98l-2.11 1.65a.5.5 0 0 0-.12.64l2 3.46c.12.22.37.31.6.22l2.49-1c.51.4 1.08.73 1.69.98l.38 2.65c.04.24.25.42.49.42h4c.25 0 .46-.18.5-.42l.38-2.65c.61-.25 1.18-.58 1.69-.98l2.49 1c.23.08.48 0 .6-.22l2-3.46a.5.5 0 0 0-.12-.64l-2.11-1.65ZM12 15.5A3.5 3.5 0 1 1 12 8a3.5 3.5 0 0 1 0 7.5Z'/%3E%3C/svg%3E") center / 13px 13px no-repeat;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M19.43 12.98c.04-.32.07-.65.07-.98s-.02-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.37-.31-.6-.22l-2.49 1a7.34 7.34 0 0 0-1.69-.98L14.5 2.42A.5.5 0 0 0 14 2h-4a.5.5 0 0 0-.49.42l-.38 2.65c-.61.24-1.18.56-1.69.98l-2.49-1a.5.5 0 0 0-.6.22l-2 3.46a.5.5 0 0 0 .12.64l2.11 1.65c-.04.32-.08.65-.08.98s.03.66.08.98l-2.11 1.65a.5.5 0 0 0-.12.64l2 3.46c.12.22.37.31.6.22l2.49-1c.51.4 1.08.73 1.69.98l.38 2.65c.04.24.25.42.49.42h4c.25 0 .46-.18.5-.42l.38-2.65c.61-.25 1.18-.58 1.69-.98l2.49 1c.23.08.48 0 .6-.22l2-3.46a.5.5 0 0 0-.12-.64l-2.11-1.65ZM12 15.5A3.5 3.5 0 1 1 12 8a3.5 3.5 0 0 1 0 7.5Z'/%3E%3C/svg%3E") center / 13px 13px no-repeat}.auto-select-settings-trigger:hover:before,.auto-select-settings-trigger:focus:before,.auto-select-settings-trigger[aria-expanded=true]:before{background:#c8aa6e;opacity:1}.auto-select-settings-flyout{color:#a09b8c;font-family:var(--font-body);font-size:12px;line-height:16px;z-index:10004}.auto-select-settings-flyout lc-flyout-content{display:block;width:100%;box-sizing:border-box}.auto-select-settings-menu{display:flex;flex-direction:column;width:100%;padding:6px 0;color:#a09b8c}.auto-select-settings-menu__empty{min-height:32px;padding:8px 12px;box-sizing:border-box;color:#5f5b4f;font-size:11px}.auto-select-settings-checkbox{display:block;min-height:0;width:100%;height:36px;padding:0;box-sizing:content-box;color:#a09b8c;cursor:pointer}.auto-select-settings-checkbox:hover,.auto-select-settings-checkbox[selected]{color:#f0e6d2}.auto-select-settings-range{display:grid;gap:8px;padding:8px 12px 10px;border-bottom:thin solid #1e282d;box-sizing:border-box}.auto-select-settings-range__header{display:flex;align-items:baseline;justify-content:space-between;gap:8px;min-width:0}.auto-select-settings-range__label{min-width:0;overflow:hidden;color:#f0e6d2;font-size:12px;text-overflow:ellipsis;white-space:nowrap}.auto-select-settings-range__value{flex:0 0 auto;color:#a09b8c;font-size:11px}.auto-select-settings-range__track{position:relative;height:30px;margin:0 15px;cursor:pointer}.auto-select-settings-range__track:before{content:"";position:absolute;left:0;right:0;top:14px;height:2px;background:#1e2328}.auto-select-settings-range__fill{position:absolute;top:13px;height:2px;border:thin solid #010a13;background:linear-gradient(to right,#785a28 0%,#c89b3c 56%,#c8aa6e 100%);box-sizing:border-box;pointer-events:none}.auto-select-settings-range__handle{position:absolute;top:0;width:30px;height:30px;padding:0;border:0;background:url(/fe/lol-uikit/images/slider-btn.png) no-repeat top left;background-size:100%;box-sizing:border-box;cursor:pointer;outline:none;transform:translate(-50%)}.auto-select-settings-range__handle:hover,.auto-select-settings-range__handle:focus{background-position:0 -30px}.auto-select-settings-range__handle--dragging{background-position:0 -60px}.auto-select-champ-select-menu{position:absolute;right:0;bottom:36px;z-index:10000;width:min(340px,calc(100vw - 32px));color:#a09b8c;font-family:var(--font-body);font-size:12px;font-weight:400;line-height:normal;pointer-events:none;text-transform:none}.auto-select-champ-select-menu-button-wrapper{position:relative;display:block;width:38px;height:32px;flex:0 0 38px;box-sizing:border-box}.auto-select-champ-select-menu__header{position:relative;display:block;width:38px;height:32px;border:1px solid #785a28;background:#1e2328;box-shadow:inset 0 0 0 1px #010a13;box-sizing:border-box;cursor:pointer;outline:none;padding:0}.auto-select-champ-select-menu__header:before{content:"";position:absolute;left:50%;top:50%;width:20px;height:20px;background-color:#c8aa6e;-webkit-mask:url(/fe/lol-static-assets/images/nav-icon-collections.svg) center / 20px 20px no-repeat;mask:url(/fe/lol-static-assets/images/nav-icon-collections.svg) center / 20px 20px no-repeat;pointer-events:none;transform:translate(-50%,-50%)}.auto-select-champ-select-menu__header:hover{border-color:#c8aa6e;background:#2a3038}.auto-select-champ-select-menu__header:hover:before{background-color:#f0e6d2}.auto-select-champ-select-menu__header:active,.auto-select-champ-select-menu-button-wrapper--open .auto-select-champ-select-menu__header{border-color:#c89b3c;background:#111820}.auto-select-champ-select-menu-button-wrapper--open{z-index:10000}.auto-select-champ-select-menu-button-wrapper--open .auto-select-champ-select-menu__header:hover{border-color:#c8aa6e;background:#1e2328}.auto-select-champ-select-menu-button-wrapper--open .auto-select-champ-select-menu__header:before{background-color:#f0e6d2}.auto-select-champ-select-menu__content{display:grid;gap:4px;width:100%;margin-bottom:4px;border:1px solid #785a28;background:rgba(1,10,19,.96);box-shadow:0 0 18px #000000a6;box-sizing:border-box;pointer-events:auto;padding:8px}.auto-select-champ-select-menu__title{position:relative;display:flex;align-items:center;justify-content:center;min-height:24px;padding-right:24px;padding-bottom:4px;border-bottom:thin solid #1e282d;color:#f0e6d2;font-family:var(--font-display);font-size:14px;font-weight:700;text-align:center}.auto-select-champ-select-menu .auto-select-checkboxes-div{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));align-items:center;border-top:0;border-bottom:thin solid #1e282d;padding-bottom:6px}.auto-select-champ-select-menu .auto-select-checkbox{justify-self:center;margin:0}.auto-select-champ-select-menu .dropdown-champions-default{min-height:32px}.auto-select-champ-select-menu .champion-priority-selector__scroll{height:56px}.auto-select-champ-select-menu--collapsed .auto-select-champ-select-menu__content{display:none}`)),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(`.dropdown-champions-default{position:inherit;inline-size:100%}.dropdown-champions-default.dropdown-drop-up::part(ui-dropdown-menu),.dropdown-champions-default.dropdown-drop-up::part(ui-dropdown-content),.dropdown-champions-default.dropdown-drop-up::part(ui-dropdown-options){top:auto;bottom:100%;transform-origin:bottom}.dropdown-champions-default .controlado-champion-option__content{display:inline-flex;align-items:center;gap:8px;width:100%;min-width:0;line-height:20px;vertical-align:middle}.dropdown-champions-default .controlado-champion-option__icon{display:block;flex:0 0 20px;width:20px;height:20px;border:1px solid rgba(200,170,110,.65);border-radius:50%;background:#010a13;object-fit:cover;box-sizing:border-box;pointer-events:none}.dropdown-champions-default img.controlado-champion-option__icon{clip-path:circle(41.67% at 51.5% 51.5%);object-position:center;transform:scale(1.2);transform-origin:51.5% 51.5%}.dropdown-champions-default .controlado-champion-option__static-icon{display:grid;place-items:center;color:#f0e6d2;font-family:var(--font-display);font-size:13px;font-weight:700;line-height:1}.dropdown-champions-default .controlado-champion-option__text{display:flex;align-items:baseline;gap:8px;width:100%;min-width:0}.dropdown-champions-default .controlado-champion-option__name{flex:0 0 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dropdown-champions-default .controlado-champion-option__description{flex:1 1 auto;min-width:0;color:#a09b8ce6;font-size:11px;line-height:1;overflow:hidden;text-align:right;text-overflow:ellipsis;white-space:nowrap}.champion-priority-selector{display:grid;gap:0;padding:2px 0 3px}.champion-priority-selector__scroll{position:relative;inline-size:100%;height:58px;border:1px solid rgba(120,90,40,.7);border-top:0;background:rgba(30,35,40,.5);box-sizing:border-box}.champion-priority-selector__track{display:inline-flex;align-items:center;gap:12px;min-width:max-content;min-height:45px;padding:10px 8px 8px;box-sizing:border-box}.champion-priority-selector__empty{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;color:#5f5b4f;font-family:var(--font-body);font-size:11px;line-height:13px;text-align:center;white-space:nowrap;pointer-events:none}.champion-priority-selector__icon{position:relative;flex:0 0 auto;width:34px;height:34px;border:1px solid #c8aa6e;border-radius:50%;background:#1e2328;box-shadow:0 0 0 1px #010a13e6;box-sizing:border-box;cursor:grab;outline:none}.champion-priority-selector__icon:focus{border-color:#f0e6d2}.champion-priority-selector__icon--dragging{cursor:grabbing;filter:brightness(1.15);z-index:1}.champion-priority-selector__icon:before,.champion-priority-selector__remove,.champion-priority-selector__position-badge{display:grid;place-items:center;width:17px;height:17px;padding:0;border-radius:50%;box-sizing:border-box;font-family:var(--font-body);font-size:10px;font-weight:700;line-height:1;z-index:2}.champion-priority-selector__icon:before{content:attr(data-rank);position:absolute;left:-6px;top:-6px;border:1px solid #c8aa6e;background:#010a13;color:#f0e6d2;text-align:center;pointer-events:none}.champion-priority-selector__icon>img{position:relative;z-index:0;display:block;width:100%;height:100%;border-radius:50%;clip-path:circle(45.87% at 50% 50%);object-fit:cover;object-position:center;pointer-events:none;transform:scale(1.09);transform-origin:center}.champion-priority-selector__icon--random{display:grid;place-items:center;color:#f0e6d2;font-family:var(--font-display);font-weight:700}.champion-priority-selector__random-icon{font-size:20px;line-height:1;transform:translateY(-.5px);pointer-events:none}.champion-priority-selector__remove{position:absolute;right:-6px;bottom:-6px;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:1px solid #785a28;background:#1e2328;color:#c8aa6e;cursor:pointer;font-family:var(--font-display);font-size:0;text-align:center}.champion-priority-selector__remove:before{content:attr(data-icon);font-family:var(--font-display);font-size:7px;line-height:1;transform:translate(.4px,-.1px)}.champion-priority-selector__remove:hover{border-color:#c8aa6e;color:#f0e6d2}.champion-priority-selector__position-badge{position:absolute;left:-6px;bottom:-6px;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:1px solid #785a28;background:#010a13;color:#c8aa6e;cursor:pointer}.champion-priority-selector__position-badge:hover,.champion-priority-selector__position-badge:focus{border-color:#c8aa6e;color:#f0e6d2;outline:none}.champion-priority-selector__position-badge--empty{background:#1e2328;font-size:0}.champion-priority-selector__position-badge--empty:before{content:"+";font-family:var(--font-body);font-size:12px;line-height:1;transform:translate(.25px,.4px)}.champion-priority-selector__position-badge--random{left:auto;right:-6px;top:-6px;bottom:auto}.champion-priority-selector__position-badge--random:before{content:"";display:block;width:11px;height:11px;background:url(/fe/lol-tft-team-planner/images/team_editor_trait_filter_icon.png) center / contain no-repeat;transform:none}.champion-priority-selector__position-badge--random:hover:before,.champion-priority-selector__position-badge--random:focus:before,.champion-priority-selector__position-badge--random.champion-priority-selector__position-badge--active:before{background-image:url(/fe/lol-tft-team-planner/images/team_editor_trait_filter_icon_pressed.png)}.champion-priority-selector__position-badge--random.champion-priority-selector__position-badge--active{border-color:#c8aa6e;background:#010a13}.champion-priority-selector__position-badge img{display:block;width:11px;height:11px;object-fit:contain;transform:translate(.1px)}.champion-priority-selector__position-badge:after{content:attr(data-count);position:absolute;right:-5px;top:-5px;display:none;place-items:center;width:11px;min-width:11px;height:11px;border:1px solid #785a28;border-radius:50%;background:#010a13;box-sizing:border-box;color:#f0e6d2;font-family:var(--font-body);font-size:7px;font-weight:700;line-height:1;text-align:center}.champion-priority-selector__position-badge[data-count]:after{display:grid}.champion-priority-selector__position-menu{position:fixed;z-index:10002;display:flex;gap:4px;padding:5px;border:1px solid #785a28;background:#010a13;box-shadow:0 0 0 1px #010a13d9,0 4px 16px #0000008c;box-sizing:border-box}.champion-priority-selector__position-menu[hidden]{display:none}.champion-priority-selector__position-option{display:grid;place-items:center;width:28px;height:28px;padding:0;border:1px solid #463714;background:#1e2328;box-sizing:border-box;cursor:pointer}.champion-priority-selector__position-option:hover,.champion-priority-selector__position-option--selected{border-color:#c8aa6e;background:#0f1b2d}.champion-priority-selector__position-option img{display:block;width:18px;height:18px;pointer-events:none}.auto-select-checkboxes-div{display:flex;border-top:thin solid #1e282d}.auto-select-checkbox{margin:auto}.auto-select-checkbox:last-child{margin-right:17px}.auto-select-social-roster-section__header{position:relative;padding-right:28px;box-sizing:border-box}.auto-select-social-roster-section .group-name,.auto-select-social-roster-section .group-name-text{min-width:0}.auto-select-social-roster-section .group-name-text{padding-right:5px}.auto-select-settings-trigger{display:grid;place-items:center;width:18px;height:18px;padding:0;border:0;background:transparent;box-shadow:none;box-sizing:border-box;cursor:pointer;outline:none}.auto-select-social-roster-section__header>.auto-select-settings-trigger{position:absolute;right:8px;top:50%;transform:translateY(-50%)}.auto-select-champ-select-menu__title>.auto-select-settings-trigger{position:absolute;right:5px;top:50%;transform:translateY(-50%)}.auto-select-settings-trigger:before{content:"";display:block;width:13px;height:13px;background:#5f5b4f;opacity:.95;-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M19.43 12.98c.04-.32.07-.65.07-.98s-.02-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.37-.31-.6-.22l-2.49 1a7.34 7.34 0 0 0-1.69-.98L14.5 2.42A.5.5 0 0 0 14 2h-4a.5.5 0 0 0-.49.42l-.38 2.65c-.61.24-1.18.56-1.69.98l-2.49-1a.5.5 0 0 0-.6.22l-2 3.46a.5.5 0 0 0 .12.64l2.11 1.65c-.04.32-.08.65-.08.98s.03.66.08.98l-2.11 1.65a.5.5 0 0 0-.12.64l2 3.46c.12.22.37.31.6.22l2.49-1c.51.4 1.08.73 1.69.98l.38 2.65c.04.24.25.42.49.42h4c.25 0 .46-.18.5-.42l.38-2.65c.61-.25 1.18-.58 1.69-.98l2.49 1c.23.08.48 0 .6-.22l2-3.46a.5.5 0 0 0-.12-.64l-2.11-1.65ZM12 15.5A3.5 3.5 0 1 1 12 8a3.5 3.5 0 0 1 0 7.5Z'/%3E%3C/svg%3E") center / 13px 13px no-repeat;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M19.43 12.98c.04-.32.07-.65.07-.98s-.02-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.37-.31-.6-.22l-2.49 1a7.34 7.34 0 0 0-1.69-.98L14.5 2.42A.5.5 0 0 0 14 2h-4a.5.5 0 0 0-.49.42l-.38 2.65c-.61.24-1.18.56-1.69.98l-2.49-1a.5.5 0 0 0-.6.22l-2 3.46a.5.5 0 0 0 .12.64l2.11 1.65c-.04.32-.08.65-.08.98s.03.66.08.98l-2.11 1.65a.5.5 0 0 0-.12.64l2 3.46c.12.22.37.31.6.22l2.49-1c.51.4 1.08.73 1.69.98l.38 2.65c.04.24.25.42.49.42h4c.25 0 .46-.18.5-.42l.38-2.65c.61-.25 1.18-.58 1.69-.98l2.49 1c.23.08.48 0 .6-.22l2-3.46a.5.5 0 0 0-.12-.64l-2.11-1.65ZM12 15.5A3.5 3.5 0 1 1 12 8a3.5 3.5 0 0 1 0 7.5Z'/%3E%3C/svg%3E") center / 13px 13px no-repeat}.auto-select-settings-trigger:hover:before,.auto-select-settings-trigger:focus:before,.auto-select-settings-trigger[aria-expanded=true]:before{background:#c8aa6e;opacity:1}.auto-select-settings-flyout{color:#a09b8c;font-family:var(--font-body);font-size:12px;line-height:16px;z-index:10004}.auto-select-settings-flyout lc-flyout-content{display:block;width:100%;box-sizing:border-box}.auto-select-settings-menu{display:flex;flex-direction:column;width:100%;padding:6px 0;color:#a09b8c}.auto-select-settings-menu__empty{min-height:32px;padding:8px 12px;box-sizing:border-box;color:#5f5b4f;font-size:11px}.auto-select-settings-checkbox{display:block;min-height:0;width:100%;height:36px;padding:0;box-sizing:content-box;color:#a09b8c;cursor:pointer}.auto-select-settings-checkbox:hover,.auto-select-settings-checkbox[selected]{color:#f0e6d2}.auto-select-settings-range{display:grid;gap:8px;padding:8px 12px 10px;border-bottom:thin solid #1e282d;box-sizing:border-box}.auto-select-settings-range__header{display:flex;align-items:baseline;justify-content:space-between;gap:8px;min-width:0}.auto-select-settings-range__label{min-width:0;overflow:hidden;color:#f0e6d2;font-size:12px;text-overflow:ellipsis;white-space:nowrap}.auto-select-settings-range__value{flex:0 0 auto;color:#a09b8c;font-size:11px}.auto-select-settings-range__track{position:relative;height:30px;margin:0 15px;cursor:pointer}.auto-select-settings-range__track:before{content:"";position:absolute;left:0;right:0;top:14px;height:2px;background:#1e2328}.auto-select-settings-range__fill{position:absolute;top:13px;height:2px;border:thin solid #010a13;background:linear-gradient(to right,#785a28 0%,#c89b3c 56%,#c8aa6e 100%);box-sizing:border-box;pointer-events:none}.auto-select-settings-range__handle{position:absolute;top:0;width:30px;height:30px;padding:0;border:0;background:url(/fe/lol-uikit/images/slider-btn.png) no-repeat top left;background-size:100%;box-sizing:border-box;cursor:pointer;outline:none;transform:translate(-50%)}.auto-select-settings-range__handle:hover,.auto-select-settings-range__handle:focus{background-position:0 -30px}.auto-select-settings-range__handle--dragging{background-position:0 -60px}.auto-select-champ-select-menu{position:absolute;right:0;bottom:36px;z-index:10000;width:min(340px,calc(100vw - 32px));color:#a09b8c;font-family:var(--font-body);font-size:12px;font-weight:400;line-height:normal;pointer-events:none;text-transform:none}.auto-select-champ-select-menu-button-wrapper{position:relative;display:block;width:38px;height:32px;flex:0 0 38px;box-sizing:border-box}.auto-select-champ-select-menu__header{position:relative;display:block;width:38px;height:32px;border:1px solid #785a28;background:#1e2328;box-shadow:inset 0 0 0 1px #010a13;box-sizing:border-box;cursor:pointer;outline:none;padding:0}.auto-select-champ-select-menu__header:before{content:"";position:absolute;left:50%;top:50%;width:20px;height:20px;background-color:#c8aa6e;-webkit-mask:url(/fe/lol-static-assets/images/nav-icon-collections.svg) center / 20px 20px no-repeat;mask:url(/fe/lol-static-assets/images/nav-icon-collections.svg) center / 20px 20px no-repeat;pointer-events:none;transform:translate(-50%,-50%)}.auto-select-champ-select-menu__header:hover{border-color:#c8aa6e;background:#2a3038}.auto-select-champ-select-menu__header:hover:before{background-color:#f0e6d2}.auto-select-champ-select-menu__header:active,.auto-select-champ-select-menu-button-wrapper--open .auto-select-champ-select-menu__header{border-color:#c89b3c;background:#111820}.auto-select-champ-select-menu-button-wrapper--open{z-index:10000}.auto-select-champ-select-menu-button-wrapper--open .auto-select-champ-select-menu__header:hover{border-color:#c8aa6e;background:#1e2328}.auto-select-champ-select-menu-button-wrapper--open .auto-select-champ-select-menu__header:before{background-color:#f0e6d2}.auto-select-champ-select-menu__content{display:grid;gap:4px;width:100%;margin-bottom:4px;border:1px solid #785a28;background:rgba(1,10,19,.96);box-shadow:0 0 18px #000000a6;box-sizing:border-box;pointer-events:auto;padding:8px}.auto-select-champ-select-menu__title{position:relative;display:flex;align-items:center;justify-content:center;min-height:24px;padding-right:24px;padding-bottom:4px;border-bottom:thin solid #1e282d;color:#f0e6d2;font-family:var(--font-display);font-size:14px;font-weight:700;text-align:center}.auto-select-champ-select-menu .auto-select-checkboxes-div{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));align-items:center;border-top:0;border-bottom:thin solid #1e282d;padding-bottom:6px}.auto-select-champ-select-menu .auto-select-checkbox{justify-self:center;margin:0}.auto-select-champ-select-menu .dropdown-champions-default{min-height:32px}.auto-select-champ-select-menu .champion-priority-selector__scroll{height:56px}.auto-select-champ-select-menu--collapsed .auto-select-champ-select-menu__content{display:none}`)),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
|
2
2
|
/**
|
|
3
3
|
* @author balaclava
|
|
4
4
|
* @name auto-champion-select
|
|
5
5
|
* @link https://github.com/controlado/auto-champion-select#readme
|
|
6
6
|
* @description Pick or ban automatically! 🐧
|
|
7
|
-
* @version 1.
|
|
7
|
+
* @version 1.11.1
|
|
8
8
|
* @license GPL-3.0-or-later
|
|
9
9
|
*/
|
|
10
|
-
import{request as I,sleep as v,linkEndpoint as yt}from"https://cdn.jsdelivr.net/npm/balaclava-utils@latest";const ue="1.10.0",pe={enabled:!1,hideAutoAcceptPrompt:!0},me={minMs:2e3,maxMs:4e3},fe={enabled:!1,force:!1,champions:[432,235],randomAssignedPositions:[],randomPoolPositions:[],positionsByChampionId:{235:["BOTTOM","UTILITY"],432:["UTILITY"]}},ge={enabled:!1,force:!1,champions:[157,777,238,38],randomPoolPositions:[]},Pe={controladoAutoAccept:pe,controladoActionDelay:me,controladoPick:fe,controladoBan:ge},qt=0,jt=8e3,st=100,rt=2e3,ye=4e3;function at(o,t){const e=Number(o),n=Number.isFinite(t)?t:rt;if(!Number.isFinite(e))return at(n,rt);const i=Math.round(e/st)*st;return Math.max(qt,Math.min(jt,i))}function G(o,t,e=rt,n=ye){const i=at(o,e),s=at(t,n);return{minMs:Math.min(i,s),maxMs:Math.max(i,s)}}function Ce(o){const{minMs:t,maxMs:e}=G(o.minMs,o.maxMs),n=e-t;return t+Math.floor(Math.random()*(n+1))}function V(o){const t=o/1e3;return`${Number.isInteger(t)?t.toFixed(0):t.toFixed(1)}s`}function u(o){const t=Number(o);return Number.isSafeInteger(t)&&t>0?t:null}function Se(o,t=null){const e=[],n=new Set,i=Ae(t);if(!Array.isArray(o))return e;for(const s of o){const r=u(s);r===null||n.has(r)||i&&!i.has(r)||(e.push(r),n.add(r))}return e}function Ae(o){return o?new Set(Array.from(o,u).filter(t=>t!==null)):null}const x=[{value:"TOP",label:"Top",iconPath:"/fe/lol-parties/icon-position-top.png"},{value:"JUNGLE",label:"Jungle",iconPath:"/fe/lol-parties/icon-position-jungle.png"},{value:"MIDDLE",label:"Mid",iconPath:"/fe/lol-parties/icon-position-middle.png"},{value:"BOTTOM",label:"ADC",iconPath:"/fe/lol-parties/icon-position-bottom.png"},{value:"UTILITY",label:"Support",iconPath:"/fe/lol-parties/icon-position-utility.png"}],Ee=new Set(x.map(o=>o.value));function F(o){const t=String(o??"").toUpperCase();return Ee.has(t)?t:null}function O(o){if(!Array.isArray(o))return[];const t=new Set;for(const e of o){const n=F(e);n&&t.add(n)}return x.map(e=>e.value).filter(e=>t.has(e))}function W(o,t=null){const e={};if(!o||typeof o!="object"||Array.isArray(o))return e;const n=be(t);for(const[i,s]of Object.entries(o)){const r=u(i);if(r===null||!Array.isArray(s))continue;const a=String(r);if(n&&!n.has(a))continue;const l=[],d=new Set;for(const y of s){const z=F(y);!z||d.has(z)||(l.push(z),d.add(z))}l.length>0&&(e[a]=l)}return e}function be(o){if(!o)return null;const t=new Set;for(const e of o){const n=u(e);n!==null&&t.add(String(n))}return t}function Ct(o){return x.find(t=>t.value===o)}function Wt(o,t){var n;const e=u(t);return e===null?[]:((n=o==null?void 0:o.positionsByChampionId)==null?void 0:n[String(e)])||[]}function Oe(o,t,e){const n=Wt(o,t);if(n.length===0)return!0;const i=F(e);return i!==null&&n.includes(i)}const S="random",_="bravery";function p(o){return o===S}function w(o){return o===_}function L(o){return p(o)?S:w(o)?_:u(o)}function T(o){const t=L(o);return t===null?null:String(t)}function pt(o,t=null){const e=[],n=new Set,i=we(t);if(!Array.isArray(o))return e;for(const s of o){const r=L(s);if(r===null)continue;const a=String(r);n.has(a)||typeof r=="number"&&i&&!i.has(r)||(e.push(r),n.add(a))}return e}function H(o){return o?Array.from(o,u).filter(t=>t!==null):[]}function we(o){return o?new Set(Array.from(o,u).filter(t=>t!==null)):null}const St=new Set;function Xt(o,t){return Object.prototype.hasOwnProperty.call(o,t)}function E(o,t){return Xt(o,t)}function Ie(o){return Array.isArray(o.priorityOptions)?o.priorityOptions:o.champions}function Te(o,t){return Xt(o,"randomPoolPositions")?o.randomPoolPositions:t.randomPositions}function mt(){if(!globalThis.DataStore)throw new Error("DataStore is not available");return globalThis.DataStore}function _e(o){return o!==null&&typeof o=="object"&&!Array.isArray(o)}function ft(o){if(o!==void 0)return JSON.parse(JSON.stringify(o))}function Kt(o){const t=Pe[o];if(!t)throw new Error(`Unknown auto-champion-select config key: ${o}`);return ft(t)}function Qt(o,t,e={}){const n=Kt(o),i=_e(t)?ft(t):{},s={...n,...i},r={};if(E(n,"enabled")&&(r.enabled=s.enabled===!0),E(n,"hideAutoAcceptPrompt")&&(r.hideAutoAcceptPrompt=s.hideAutoAcceptPrompt===!0),E(n,"minMs")&&E(n,"maxMs")){const{minMs:a,maxMs:l}=G(s.minMs,s.maxMs,n.minMs,n.maxMs);r.minMs=a,r.maxMs=l}return E(n,"force")&&(r.force=s.force===!0),E(n,"champions")&&(r.priorityOptions=pt(Ie(s),e.allowedChampionIds),r.champions=H(r.priorityOptions)),E(n,"randomAssignedPositions")&&(r.randomAssignedPositions=O(s.randomAssignedPositions)),E(n,"randomPoolPositions")&&(r.randomPoolPositions=O(Te(i,s))),E(n,"positionsByChampionId")&&(r.positionsByChampionId=W(s.positionsByChampionId,e.selectedChampionIds||r.champions)),r}function Jt(o,t,e={}){const n=t===void 0?Kt(o):t;return Qt(o,n,e)}function P(o,t={}){const n=mt().get(o);return Jt(o,n,t)}function Re(o,t,e={}){const n=mt(),i=Qt(o,t,e);return n.set(o,i),i}function ve(o,t){return JSON.stringify(o)===JSON.stringify(t)}function Le(o,t,e){St.has(o)||(St.add(o),console.warn(`auto-champion-select: Repaired ${o} in DataStore. The stored value used a different schema; plugins like reynbow/auto-champ-lock write this shape. Saved normalized config.`,{storedConfig:t,normalizedConfig:e}))}function Zt(o,t={}){const e=mt(),n=e.get(o),i=Jt(o,n,t);return(n===void 0||!ve(n,i))&&(n!==void 0&&Le(o,n,i),e.set(o,i)),i}function B(o,t,e={}){const n=P(o,e),i=ft(n),s=t(i)||i;return Re(o,s,e)}const f=Object.freeze({readyCheckAccept:"/lol-matchmaking/v1/ready-check/accept",gameflowPhase:"/lol-gameflow/v1/gameflow-phase",wallet:"/lol-inventory/v1/wallet",ownedChampions:"/lol-champions/v1/owned-champions-minimal",championSummary:"/lol-game-data/assets/v1/champion-summary.json",recommendedChampionPositions:"/lol-perks/v1/recommended-champion-positions",champSelectSession:"/lol-champ-select/v1/session",pickableChampionIds:"/lol-champ-select/v1/pickable-champion-ids",bannableChampionIds:"/lol-champ-select/v1/bannable-champion-ids",championIcon(o){return`/lol-game-data/assets/v1/champion-icons/${o}.png`},champSelectAction(o){return`/lol-champ-select/v1/session/actions/${o}`}}),Me=1e3;function gt(o){let t=null;return function(){return t||(t=Promise.resolve().then(o).finally(()=>{t=null})),t}}function te(o,t={}){const e=[],n=new Set;if(!Array.isArray(o))return e;for(const i of o){if(!i||typeof i!="object")continue;const s=u(i.id),r=typeof i.name=="string"?i.name:"";s===null||!r||n.has(r)||(e.push({...i,id:s,name:r,squarePortraitPath:i.squarePortraitPath||f.championIcon(s),recommendedPositions:t[String(s)]||[]}),n.add(r))}return e.sort((i,s)=>i.name.localeCompare(s.name)),e}function ke(o){const t={};if(!o||typeof o!="object"||Array.isArray(o))return t;for(const[e,n]of Object.entries(o))!n||typeof n!="object"||Array.isArray(n)||(t[e]=n.recommendedPositions);return W(t)}async function Ne(){try{const o=await I("GET",f.recommendedChampionPositions);return o.ok?ke(await o.json()):(console.warn("auto-champion-select(recommended-champion-positions): Request failed",o),{})}catch(o){return console.warn("auto-champion-select(recommended-champion-positions): Failed to load",o),{}}}const X=gt(Ne);async function xe(){let o=await I("GET",f.ownedChampions);for(;!o.ok;)console.debug("auto-champion-select(owned-champions-minimal): Retrying..."),o=await I("GET",f.ownedChampions),await v(Me);return te(await o.json(),await X())}async function De(){const[o,t]=await Promise.all([I("GET",f.championSummary),X()]);return te(await o.json(),t)}const Fe=gt(xe),ee=gt(De),At=300,Be=-1,ne=-3,C=Object.freeze({SATISFIED:"satisfied",TRY_NEXT_CHAMPION:"try-next-champion",STOP_CYCLE:"stop-cycle"}),M=Object.freeze({CONTINUE:"continue-cycle",STOP:"stop-cycle"}),b=Object.freeze({READY:"ready",SKIP_ACTION:"skip-action",STOP_CYCLE:"stop-cycle"}),g=Object.freeze({SATISFIED:"satisfied",TRY_NEXT_PRIORITY_OPTION:"try-next-priority-option",STOP_CYCLE:"stop-cycle"});function lt(o){return Array.isArray(o)?o.flat():[]}function $e(o){return lt(o).filter(t=>t.type==="ban"&&t.completed===!0).map(t=>t.championId)}function Et(o){return Array.isArray(o)?o:[]}function Y(o){const t=new Set;for(const e of o){const n=u(e);n!==null&&t.add(n)}return t}function bt(o){return o.type==="pick"?0:1}function Ot(){return{pickConfig:P("controladoPick"),banConfig:P("controladoBan"),actionDelayConfig:P("controladoActionDelay")}}function He(o){const t=[...o];for(let e=t.length-1;e>0;e--){const n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t}function Ge(o){return Array.isArray(o)&&o.length===1&&o[0]===Be}function K(o){return Number(o)===ne}class ze{constructor(){this.session=null,this.actions=null,this.localPlayerCellId=null,this.alliedIntentChampionIds=new Set,this.teammateIntentChampionIds=new Set,this.localPlayerIntentChampionId=null,this.localPlayerIntentIsBravery=!1,this.pickedChampionIds=new Set,this.bannedChampionIds=new Set,this.localPlayerAssignedPosition=null,this.rejectedBraveryActionIds=new Set,this.watchTask=null,this.watchVersion=0,this.mounted=!1}mount(){this.mounted||(this.mounted=!0,this.rejectedBraveryActionIds.clear(),this.watchVersion+=1,this.watchTask||(this.watchTask=this.watch()))}unmount(){this.mounted&&(this.mounted=!1,this.rejectedBraveryActionIds.clear(),this.watchVersion+=1)}async watch(){try{for(;this.mounted;){const t=this.watchVersion;let e=!1;try{await this.refreshSessionState(),e=!0}catch(n){console.debug("auto-champion-select: Failed to update champion select",n)}if(!e||!this.mounted||t!==this.watchVersion){this.mounted&&t===this.watchVersion&&await v(At);continue}try{await this.runAutoSelectCycle()}catch(n){console.debug("auto-champion-select: Failed to run champion select cycle",n)}this.mounted&&t===this.watchVersion&&await v(At)}}finally{this.watchTask=null}}async refreshSessionState(){var r,a;const t=await I("GET",f.champSelectSession);if(!t.ok)throw new Error(`Session request failed with status ${t.status}`);this.session=await t.json(),this.actions=this.session.actions,this.localPlayerCellId=this.session.localPlayerCellId;const e=Et(this.session.myTeam),n=Et(this.session.theirTeam),i=e.find(l=>l.cellId===this.localPlayerCellId),s=e.filter(l=>l.cellId!==this.localPlayerCellId);this.localPlayerAssignedPosition=F(i==null?void 0:i.assignedPosition),this.localPlayerIntentChampionId=u(i==null?void 0:i.championPickIntent),this.localPlayerIntentIsBravery=K(i==null?void 0:i.championPickIntent),this.pickedChampionIds=Y([...e,...n].map(l=>l.championId)),this.bannedChampionIds=Y([...((r=this.session.bans)==null?void 0:r.myTeamBans)||[],...((a=this.session.bans)==null?void 0:a.theirTeamBans)||[],...$e(this.actions)]),this.alliedIntentChampionIds=Y(e.map(l=>l.championPickIntent)),this.teammateIntentChampionIds=Y(s.map(l=>l.championPickIntent))}async runAutoSelectCycle(){const t=Ot();if(!t.pickConfig.enabled&&!t.banConfig.enabled)return;const e=this.getLocalPlayerActions();if(e.length===0){console.debug("auto-champion-select: No local player sub actions found, skipping..."),this.unmount();return}for(const n of e)if(await this.runAutoSelectForAction(n,t)===M.STOP)return}async runAutoSelectForAction(t,e){const n=await this.prepareActionForAutoSelect(t,e);switch(n.status){case b.READY:return this.tryAutoSelectPlan(n.plan);case b.SKIP_ACTION:return M.CONTINUE;case b.STOP_CYCLE:return M.STOP;default:throw new Error(`Unexpected auto-select plan status: ${n.status}`)}}async prepareActionForAutoSelect(t,e){if(!this.isActionAvailable(t))return{status:b.SKIP_ACTION};const n=this.getConfigForActionType(t.type,e);if(!(n!=null&&n.enabled))return{status:b.SKIP_ACTION};const i=this.createAutoSelectPlan(t,n);if(!i)return{status:b.SKIP_ACTION};const s=this.createPlanLimitedToAlreadySatisfiedPriorityOption(i);if(s)return{status:b.READY,plan:s};const r=await this.delayAndRefreshAutoSelectPlan(t,n,e.actionDelayConfig);return r?{status:b.READY,plan:this.createPlanLimitedToAlreadySatisfiedPriorityOption(r)||r}:{status:b.STOP_CYCLE}}async tryAutoSelectPlan(t){for(const e of t.priorityOptions){const n=await this.tryPriorityOptionForAction(t.action,e,t.config);if(n===g.SATISFIED)return M.CONTINUE;if(n===g.STOP_CYCLE)return M.STOP}return M.CONTINUE}async tryPriorityOptionForAction(t,e,n){if(this.isPriorityOptionAlreadySatisfied(t,e))return g.SATISFIED;if(w(e))return this.tryBraveryForAction(t);const i=await this.resolveChampionIdsForPriorityOption(t,e,n),s=p(e)&&!this.isLockingExistingPickIntent(t,i);for(const r of i){const a={tryNextRandomCandidateOnFailure:s},l=await this.attemptChampionForAction(t,r,n,a);if(l===C.SATISFIED)return g.SATISFIED;if(l===C.STOP_CYCLE)return g.STOP_CYCLE}return g.TRY_NEXT_PRIORITY_OPTION}async tryBraveryForAction(t){if(t.type!=="pick")return g.TRY_NEXT_PRIORITY_OPTION;if(this.isBraveryPickIntentSet(t))return g.SATISFIED;console.debug("auto-champion-select: Trying to pick Bravery...");const e=await this.selectChampion(t.id,ne);console.debug(e.ok?"auto-champion-select: Bravery request accepted, refreshing champ select state...":"auto-champion-select: Failed to pick Bravery, refreshing champ select state...");const n=await this.refreshPendingAction(t);return!n||!this.isActionAvailable(n)?e.ok?g.SATISFIED:g.STOP_CYCLE:this.isBraveryPickIntentSet(n)?g.SATISFIED:(this.rejectedBraveryActionIds.add(t.id),console.debug("auto-champion-select: Bravery was not applied after refresh, trying next pick..."),g.TRY_NEXT_PRIORITY_OPTION)}getLocalPlayerActions(){return lt(this.actions).filter(t=>this.isPendingLocalPlayerAction(t)).sort((t,e)=>bt(t)-bt(e))}isPendingLocalPlayerAction(t){return t.actorCellId===this.localPlayerCellId&&t.completed===!1}isActionAvailable(t){return t.type==="pick"||t.isInProgress===!0}getConfigForActionType(t,e){return t==="pick"?e.pickConfig:t==="ban"?e.banConfig:null}createAutoSelectPlan(t,e){const n=this.getAvailablePriorityOptionsForAction(t,e);return n.length===0?null:{action:t,config:e,priorityOptions:n}}getAvailablePriorityOptionsForAction(t,e){return pt(e.priorityOptions||e.champions).filter(n=>!this.isPriorityOptionUnavailableForAction(t,n,e))}isPriorityOptionUnavailableForAction(t,e,n){return p(e)?this.isRandomPriorityOptionUnavailableForAction(t,n):w(e)?t.type!=="pick"||this.rejectedBraveryActionIds.has(t.id):this.isChampionUnavailableForAction(t,e,n)}isRandomPriorityOptionUnavailableForAction(t,e){if(t.type!=="pick")return!1;const n=O(e.randomAssignedPositions);return n.length===0?!1:this.localPlayerAssignedPosition?n.includes(this.localPlayerAssignedPosition)?!1:(console.debug(`auto-champion-select: Skipping random pick because assigned position ${this.localPlayerAssignedPosition} is not in ${n.join(", ")}.`),!0):(console.debug(`auto-champion-select: Skipping random pick because no assigned position is available for ${n.join(", ")} restriction.`),!0)}createPlanLimitedToAlreadySatisfiedPriorityOption(t){const e=t.priorityOptions.find(n=>this.isPriorityOptionAlreadySatisfied(t.action,n));return e===void 0?null:{...t,priorityOptions:[e]}}isPriorityOptionAlreadySatisfied(t,e){return p(e)?this.hasAnyPickIntentSet(t):w(e)?this.isBraveryPickIntentSet(t):this.isPickIntentSetToChampion(t,e)}hasAnyPickIntentSet(t){return t.type==="pick"&&t.isInProgress!==!0&&(this.localPlayerIntentChampionId!==null||this.localPlayerIntentIsBravery||u(t.championId)!==null||K(t.championId))}isBraveryPickIntentSet(t){return t.type==="pick"&&t.isInProgress!==!0&&(this.localPlayerIntentIsBravery||K(t.championId))}isLockingExistingPickIntent(t,e){return t.type==="pick"&&t.isInProgress===!0&&e.length===1&&e[0]===this.getPickIntentChampionId(t)}getPickIntentChampionId(t){return t.type!=="pick"?null:u(t.championId)??this.localPlayerIntentChampionId}async delayAndRefreshAutoSelectPlan(t,e,n){const i=Ce(n);if(i<=0)return console.debug(`auto-champion-select: Action delay is instant for ${t.type}.`),this.createAutoSelectPlan(t,e);console.debug(`auto-champion-select: Waiting ${i}ms before ${t.type}...`);const s=this.watchVersion;if(await v(i),!this.mounted||s!==this.watchVersion)return null;let r=null;try{await this.refreshSessionState(),r=this.findPendingAction(t)}catch(l){return console.debug("auto-champion-select: Failed to refresh champion select after action delay",l),null}if(!r||!this.isActionAvailable(r))return null;const a=this.getConfigForActionType(t.type,Ot());return a!=null&&a.enabled?this.createAutoSelectPlan(r,a):null}async resolveChampionIdsForPriorityOption(t,e,n){return w(e)?[]:p(e)?this.resolveRandomChampionIdsForAction(t,n):[e]}async resolveRandomChampionIdsForAction(t,e){if(t.type==="pick"&&t.isInProgress===!0){const r=this.getPickIntentChampionId(t);if(r!==null&&!this.isChampionUnavailableForAction(t,r,e))return[r]}const n=await this.fetchRandomCandidateChampionIds(t);if(n.length===0)return[];const i=n.filter(r=>!this.isChampionUnavailableForAction(t,r,e)),s=t.type==="pick"&&!this.hasConfiguredRandomPoolPositions(e)?await this.preferAssignedPositionRandomPickCandidates(i):await this.filterRandomChampionIdsByConfiguredPoolPositions(i,e);return He(s)}async fetchRandomCandidateChampionIds(t){const e=t.type==="pick"?f.pickableChampionIds:f.bannableChampionIds;try{const n=await I("GET",e);if(!n.ok)return console.debug(`auto-champion-select: Failed to load random ${t.type} candidates`,n),[];const i=await n.json();return t.type==="ban"&&Ge(i)?(console.debug("auto-champion-select: Random ban endpoint returned unrestricted sentinel, falling back to all champions..."),await this.fetchAllChampionIdsForRandomBan()):Se(i)}catch(n){return console.debug(`auto-champion-select: Failed to load random ${t.type} candidates`,n),[]}}async fetchAllChampionIdsForRandomBan(){return(await ee()).map(e=>e.id)}hasConfiguredRandomPoolPositions(t){return O(t.randomPoolPositions).length>0}async filterRandomChampionIdsByConfiguredPoolPositions(t,e){const n=O(e.randomPoolPositions);if(n.length===0)return t;const i=new Set(n),s=await X(),r=t.filter(a=>{var l;return(l=s[String(a)])==null?void 0:l.some(d=>i.has(d))});return r.length===0&&console.debug(`auto-champion-select: No random candidates matched ${n.join(", ")} restriction.`),r}async preferAssignedPositionRandomPickCandidates(t){if(!this.localPlayerAssignedPosition)return t;const e=await X(),n=t.filter(i=>{var s;return(s=e[String(i)])==null?void 0:s.includes(this.localPlayerAssignedPosition)});return n.length>0?n:t}async attemptChampionForAction(t,e,n,i={}){const s=u(e);if(s===null||this.isChampionUnavailableForAction(t,s,n))return C.TRY_NEXT_CHAMPION;if(this.isPickIntentSetToChampion(t,s)||(console.debug(`auto-champion-select: Trying to ${t.type} ${s}...`),(await this.selectChampion(t.id,s)).ok))return C.SATISFIED;console.debug(`auto-champion-select: Failed to ${t.type} ${s}, refreshing champ select state...`);const a=await this.refreshPendingAction(t);return!a||!this.isActionAvailable(a)?C.STOP_CYCLE:i.tryNextRandomCandidateOnFailure===!0?this.hasAnyPickIntentSet(a)?C.SATISFIED:(console.debug(`auto-champion-select: Failed random ${t.type} candidate ${s}, trying next ${t.type}...`),C.TRY_NEXT_CHAMPION):this.isChampionUnavailableForAction(a,s,n)?(console.debug(`auto-champion-select: ${s} is unavailable after refresh, trying next ${t.type}...`),C.TRY_NEXT_CHAMPION):C.STOP_CYCLE}isPickIntentSetToChampion(t,e){return t.type==="pick"&&t.isInProgress!==!0&&(this.localPlayerIntentChampionId===e||u(t.championId)===e)}async refreshPendingAction(t){try{await this.refreshSessionState()}catch(e){return console.debug("auto-champion-select: Failed to refresh champion select action",e),null}return this.findPendingAction(t)}findPendingAction(t){return lt(this.actions).find(e=>e.id===t.id&&e.actorCellId===t.actorCellId&&e.type===t.type&&e.completed===!1)||null}isChampionUnavailableForAction(t,e,n){if(t.type==="pick"&&!Oe(n,e,this.localPlayerAssignedPosition)){const i=Wt(n,e);return this.localPlayerAssignedPosition?console.debug(`auto-champion-select: Picking ${e} but assigned position ${this.localPlayerAssignedPosition} is not in ${i.join(", ")}, skipping...`):console.debug(`auto-champion-select: Picking ${e} but no assigned position is available for ${i.join(", ")} restriction, skipping...`),!0}if(this.bannedChampionIds.has(e))return console.debug(`auto-champion-select: Banning ${e} but it's already banned, skipping...`),!0;if(t.type==="ban"&&this.alliedIntentChampionIds.has(e))if(n.force===!0)console.debug(`auto-champion-select: Banning ${e} but it has an allied pick intent, forcing...`);else return console.debug(`auto-champion-select: Banning ${e} but it has an allied pick intent, skipping...`),!0;if(t.type==="pick"&&this.teammateIntentChampionIds.has(e))if(n.force===!0)console.debug(`auto-champion-select: Picking ${e} but it has a teammate pick intent, forcing...`);else return console.debug(`auto-champion-select: Picking ${e} but it has a teammate pick intent, skipping...`),!0;return t.type==="pick"&&this.pickedChampionIds.has(e)?(console.debug(`auto-champion-select: Picking ${e} but it's already picked, skipping...`),!0):!1}selectChampion(t,e){const n=f.champSelectAction(t);return I("PATCH",n,{body:{championId:e,completed:!0}})}}const A=Object.freeze({dropdown:"lol-uikit-framed-dropdown",dropdownOption:"lol-uikit-dropdown-option",radioInputOption:"lol-uikit-radio-input-option",scrollable:"lol-uikit-scrollable",socialRosterGroup:"lol-social-roster-group"}),c=Object.freeze({socialRoster:".lol-social-roster",champSelectButtons:".bottom-right-buttons",firstChampSelectSquareButton:"lol-social-chat-toggle-button, .missions-tracker-button-component, .champ-select-voice-button-wrapper",dropdownRoot:".ui-dropdown",dropdownCurrent:".ui-dropdown-current",dropdownCurrentContent:".ui-dropdown-current-content",dropdownOption:A.dropdownOption,dropdownOptionSelected:`${A.dropdownOption}[selected]`,dropdownOptionsContainer:".ui-dropdown-options-container",dropdownOptions:".ui-dropdown-options",dropdownScrollable:A.scrollable,socialRosterGroupArrow:".arrow",socialRosterGroupHeader:".group-header",socialRosterGroupLabel:"span"});function wt(){return document.querySelector(c.socialRoster)}function ct(){return document.querySelector(c.champSelectButtons)}const Ve=50,Ye=100,Q=210,J=40,j="controlado-position-filter",dt="controlado-position-filter-visible",R="controlado-position-filter__badge",ht="controlado-position-filter__badge--active",It="controlado-placeholder",Tt="controlado-search",oe="controlado-filter-input",ie="controlado-tag--search",se="controlado-tag",re="controlado-filter-icon",N="controlado-filter-icon--trash",_t="controlado-champion-option__content",Rt="controlado-champion-option__icon",Ue="controlado-champion-option__text",vt="controlado-champion-option__name",qe="controlado-champion-option__description",je="controlado-champion-option__static-icon",Lt=`
|
|
11
|
-
${
|
|
10
|
+
import{request as E,sleep as v,linkEndpoint as bt}from"https://cdn.jsdelivr.net/npm/balaclava-utils@latest";const Ee="1.11.1",Oe={enabled:!1,hideAutoAcceptPrompt:!0},we={minMs:2e3,maxMs:4e3},Te={enabled:!1,force:!1,pickIntent:!0,champions:[432,235],randomAssignedPositions:[],randomPoolPositions:[],positionsByChampionId:{235:["BOTTOM","UTILITY"],432:["UTILITY"]}},Ie={enabled:!1,force:!1,champions:[157,777,238,38],randomPoolPositions:[]},ke={controladoAutoAccept:Oe,controladoActionDelay:we,controladoPick:Te,controladoBan:Ie},Qt=0,Zt=8e3,st=100,at=2e3,Le=4e3;function rt(o,t){const e=Number(o),n=Number.isFinite(t)?t:at;if(!Number.isFinite(e))return rt(n,at);const i=Math.round(e/st)*st;return Math.max(Qt,Math.min(Zt,i))}function $(o,t,e=at,n=Le){const i=rt(o,e),s=rt(t,n);return{minMs:Math.min(i,s),maxMs:Math.max(i,s)}}function _e(o){const{minMs:t,maxMs:e}=$(o.minMs,o.maxMs),n=e-t;return t+Math.floor(Math.random()*(n+1))}function z(o){const t=o/1e3;return`${Number.isInteger(t)?t.toFixed(0):t.toFixed(1)}s`}function p(o){const t=Number(o);return Number.isSafeInteger(t)&&t>0?t:null}function ve(o,t=null){const e=[],n=new Set,i=Re(t);if(!Array.isArray(o))return e;for(const s of o){const a=p(s);a===null||n.has(a)||i&&!i.has(a)||(e.push(a),n.add(a))}return e}function Re(o){return o?new Set(Array.from(o,p).filter(t=>t!==null)):null}const D=[{value:"TOP",label:"Top",iconPath:"/fe/lol-parties/icon-position-top.png"},{value:"JUNGLE",label:"Jungle",iconPath:"/fe/lol-parties/icon-position-jungle.png"},{value:"MIDDLE",label:"Mid",iconPath:"/fe/lol-parties/icon-position-middle.png"},{value:"BOTTOM",label:"ADC",iconPath:"/fe/lol-parties/icon-position-bottom.png"},{value:"UTILITY",label:"Support",iconPath:"/fe/lol-parties/icon-position-utility.png"}],Me=new Set(D.map(o=>o.value));function x(o){const t=String(o??"").toUpperCase();return Me.has(t)?t:null}function T(o){if(!Array.isArray(o))return[];const t=new Set;for(const e of o){const n=x(e);n&&t.add(n)}return D.map(e=>e.value).filter(e=>t.has(e))}function j(o,t=null){const e={};if(!o||typeof o!="object"||Array.isArray(o))return e;const n=Ne(t);for(const[i,s]of Object.entries(o)){const a=p(i);if(a===null||!Array.isArray(s))continue;const r=String(a);if(n&&!n.has(r))continue;const c=[],h=new Set;for(const S of s){const H=x(S);!H||h.has(H)||(c.push(H),h.add(H))}c.length>0&&(e[r]=c)}return e}function Ne(o){if(!o)return null;const t=new Set;for(const e of o){const n=p(e);n!==null&&t.add(String(n))}return t}function te(o){return D.find(t=>t.value===o)}function ee(o,t){var n;const e=p(t);return e===null?[]:((n=o==null?void 0:o.positionsByChampionId)==null?void 0:n[String(e)])||[]}function Be(o,t,e){const n=ee(o,t);if(n.length===0)return!0;const i=x(e);return i!==null&&n.includes(i)}const b="random",L="bravery";function f(o){return o===b}function I(o){return o===L}function R(o){return f(o)?b:I(o)?L:p(o)}function k(o){const t=R(o);return t===null?null:String(t)}function mt(o,t=null){const e=[],n=new Set,i=De(t);if(!Array.isArray(o))return e;for(const s of o){const a=R(s);if(a===null)continue;const r=String(a);n.has(r)||typeof a=="number"&&i&&!i.has(a)||(e.push(a),n.add(r))}return e}function F(o){return o?Array.from(o,p).filter(t=>t!==null):[]}function De(o){return o?new Set(Array.from(o,p).filter(t=>t!==null)):null}const Et=new Set;function ne(o,t){return Object.prototype.hasOwnProperty.call(o,t)}function A(o,t){return ne(o,t)}function xe(o){return Array.isArray(o.priorityOptions)?o.priorityOptions:o.champions}function Fe(o,t){return ne(o,"randomPoolPositions")?o.randomPoolPositions:t.randomPositions}function gt(){if(!DataStore)throw new Error("DataStore is not available");return DataStore}function $e(o){return o!==null&&typeof o=="object"&&!Array.isArray(o)}function ft(o){if(o!==void 0)return JSON.parse(JSON.stringify(o))}function oe(o){const t=ke[o];if(!t)throw new Error(`Unknown auto-champion-select config key: ${o}`);return ft(t)}function ie(o,t,e={}){const n=oe(o),i=$e(t)?ft(t):{},s={...n,...i},a={};if(A(n,"enabled")&&(a.enabled=s.enabled===!0),A(n,"hideAutoAcceptPrompt")&&(a.hideAutoAcceptPrompt=s.hideAutoAcceptPrompt===!0),A(n,"minMs")&&A(n,"maxMs")){const{minMs:r,maxMs:c}=$(s.minMs,s.maxMs,n.minMs,n.maxMs);a.minMs=r,a.maxMs=c}return A(n,"force")&&(a.force=s.force===!0),A(n,"pickIntent")&&(a.pickIntent=s.pickIntent!==!1),A(n,"champions")&&(a.priorityOptions=mt(xe(s),e.allowedChampionIds),a.champions=F(a.priorityOptions)),A(n,"randomAssignedPositions")&&(a.randomAssignedPositions=T(s.randomAssignedPositions)),A(n,"randomPoolPositions")&&(a.randomPoolPositions=T(Fe(i,s))),A(n,"positionsByChampionId")&&(a.positionsByChampionId=j(s.positionsByChampionId,e.selectedChampionIds||a.champions)),a}function se(o,t,e={}){const n=t===void 0?oe(o):t;return ie(o,n,e)}function y(o,t={}){const n=gt().get(o);return se(o,n,t)}function He(o,t,e={}){const n=gt(),i=ie(o,t,e);return n.set(o,i),i}function ze(o,t){return JSON.stringify(o)===JSON.stringify(t)}function Ve(o,t,e){Et.has(o)||(Et.add(o),console.warn(`auto-champion-select: Repaired ${o} in DataStore. The stored value used a different schema; plugins like reynbow/auto-champ-lock write this shape. Saved normalized config.`,{storedConfig:t,normalizedConfig:e}))}function ae(o,t={}){const e=gt(),n=e.get(o),i=se(o,n,t);return(n===void 0||!ze(n,i))&&(n!==void 0&&Ve(o,n,i),e.set(o,i)),i}function M(o,t,e={}){const n=y(o,e),i=ft(n),s=t(i)||i;return He(o,s,e)}const g=Object.freeze({readyCheckAccept:"/lol-matchmaking/v1/ready-check/accept",regionLocale:"/riotclient/region-locale",gameflowPhase:"/lol-gameflow/v1/gameflow-phase",wallet:"/lol-inventory/v1/wallet",ownedChampions:"/lol-champions/v1/owned-champions-minimal",championSummary:"/lol-game-data/assets/v1/champion-summary.json",recommendedChampionPositions:"/lol-perks/v1/recommended-champion-positions",champSelectSession:"/lol-champ-select/v1/session",pickableChampionIds:"/lol-champ-select/v1/pickable-champion-ids",bannableChampionIds:"/lol-champ-select/v1/bannable-champion-ids",championIcon(o){return`/lol-game-data/assets/v1/champion-icons/${o}.png`},champSelectAction(o){return`/lol-champ-select/v1/session/actions/${o}`}}),Ge=1e3;function yt(o){let t=null;return function(){return t||(t=Promise.resolve().then(o).finally(()=>{t=null})),t}}function re(o,t={}){const e=[],n=new Set;if(!Array.isArray(o))return e;for(const i of o){if(!i||typeof i!="object")continue;const s=p(i.id),a=typeof i.name=="string"?i.name:"";s===null||!a||n.has(a)||(e.push({...i,id:s,name:a,squarePortraitPath:i.squarePortraitPath||g.championIcon(s),recommendedPositions:t[String(s)]||[]}),n.add(a))}return e.sort((i,s)=>i.name.localeCompare(s.name)),e}function Ue(o){const t={};if(!o||typeof o!="object"||Array.isArray(o))return t;for(const[e,n]of Object.entries(o))!n||typeof n!="object"||Array.isArray(n)||(t[e]=n.recommendedPositions);return j(t)}async function Ye(){try{const o=await E("GET",g.recommendedChampionPositions);return o.ok?Ue(await o.json()):(console.warn("auto-champion-select(recommended-champion-positions): Request failed",o),{})}catch(o){return console.warn("auto-champion-select(recommended-champion-positions): Failed to load",o),{}}}const K=yt(Ye);async function qe(){let o=await E("GET",g.ownedChampions);for(;!o.ok;)console.debug("auto-champion-select(owned-champions-minimal): Retrying..."),o=await E("GET",g.ownedChampions),await v(Ge);return re(await o.json(),await K())}async function je(){const[o,t]=await Promise.all([E("GET",g.championSummary),K()]);return re(await o.json(),t)}const Ke=yt(qe),le=yt(je),Ot=300,We=-1,ce=-3,C=Object.freeze({SATISFIED:"satisfied",TRY_NEXT_CHAMPION:"try-next-champion",STOP_CYCLE:"stop-cycle"}),N=Object.freeze({CONTINUE:"continue-cycle",STOP:"stop-cycle"}),w=Object.freeze({READY:"ready",SKIP_ACTION:"skip-action",STOP_CYCLE:"stop-cycle"}),P=Object.freeze({SATISFIED:"satisfied",TRY_NEXT_PRIORITY_OPTION:"try-next-priority-option",STOP_CYCLE:"stop-cycle"});function lt(o){return Array.isArray(o)?o.flat():[]}function Xe(o){return lt(o).filter(t=>t.type==="ban"&&t.completed===!0).map(t=>t.championId)}function wt(o){return Array.isArray(o)?o:[]}function V(o){const t=new Set;for(const e of o){const n=p(e);n!==null&&t.add(n)}return t}function Tt(o){return o.type==="pick"?0:1}function It(){return{pickConfig:y("controladoPick"),banConfig:y("controladoBan"),actionDelayConfig:y("controladoActionDelay")}}function Je(o){const t=[...o];for(let e=t.length-1;e>0;e--){const n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t}function Qe(o){return Array.isArray(o)&&o.length===1&&o[0]===We}function J(o){return Number(o)===ce}class Ze{constructor(){this.session=null,this.actions=null,this.localPlayerCellId=null,this.alliedIntentChampionIds=new Set,this.teammateIntentChampionIds=new Set,this.localPlayerIntentChampionId=null,this.localPlayerIntentIsBravery=!1,this.pickedChampionIds=new Set,this.bannedChampionIds=new Set,this.localPlayerAssignedPosition=null,this.rejectedBraveryActionIds=new Set,this.watchTask=null,this.watchVersion=0,this.mounted=!1}mount(){this.mounted||(this.mounted=!0,this.rejectedBraveryActionIds.clear(),this.watchVersion+=1,this.watchTask||(this.watchTask=this.watch()))}unmount(){this.mounted&&(this.mounted=!1,this.rejectedBraveryActionIds.clear(),this.watchVersion+=1)}async watch(){try{for(;this.mounted;){const t=this.watchVersion;let e=!1;try{await this.refreshSessionState(),e=!0}catch(n){console.debug("auto-champion-select: Failed to update champion select",n)}if(!e||!this.mounted||t!==this.watchVersion){this.mounted&&t===this.watchVersion&&await v(Ot);continue}try{await this.runAutoSelectCycle()}catch(n){console.debug("auto-champion-select: Failed to run champion select cycle",n)}this.mounted&&t===this.watchVersion&&await v(Ot)}}finally{this.watchTask=null}}async refreshSessionState(){var a,r;const t=await E("GET",g.champSelectSession);if(!t.ok)throw new Error(`Session request failed with status ${t.status}`);this.session=await t.json(),this.actions=this.session.actions,this.localPlayerCellId=this.session.localPlayerCellId;const e=wt(this.session.myTeam),n=wt(this.session.theirTeam),i=e.find(c=>c.cellId===this.localPlayerCellId),s=e.filter(c=>c.cellId!==this.localPlayerCellId);this.localPlayerAssignedPosition=x(i==null?void 0:i.assignedPosition),this.localPlayerIntentChampionId=p(i==null?void 0:i.championPickIntent),this.localPlayerIntentIsBravery=J(i==null?void 0:i.championPickIntent),this.pickedChampionIds=V([...e,...n].map(c=>c.championId)),this.bannedChampionIds=V([...((a=this.session.bans)==null?void 0:a.myTeamBans)||[],...((r=this.session.bans)==null?void 0:r.theirTeamBans)||[],...Xe(this.actions)]),this.alliedIntentChampionIds=V(e.map(c=>c.championPickIntent)),this.teammateIntentChampionIds=V(s.map(c=>c.championPickIntent))}async runAutoSelectCycle(){const t=It();if(!t.pickConfig.enabled&&!t.banConfig.enabled)return;const e=this.getLocalPlayerActions();if(e.length===0){console.debug("auto-champion-select: No local player sub actions found, skipping..."),this.unmount();return}for(const n of e)if(await this.runAutoSelectForAction(n,t)===N.STOP)return}async runAutoSelectForAction(t,e){const n=await this.prepareActionForAutoSelect(t,e);switch(n.status){case w.READY:return this.tryAutoSelectPlan(n.plan);case w.SKIP_ACTION:return N.CONTINUE;case w.STOP_CYCLE:return N.STOP;default:throw new Error(`Unexpected auto-select plan status: ${n.status}`)}}async prepareActionForAutoSelect(t,e){const n=this.getConfigForActionType(t.type,e);if(!(n!=null&&n.enabled))return{status:w.SKIP_ACTION};if(!this.isActionAvailable(t,n))return{status:w.SKIP_ACTION};const i=this.createAutoSelectPlan(t,n);if(!i)return{status:w.SKIP_ACTION};const s=this.createPlanLimitedToAlreadySatisfiedPriorityOption(i);if(s)return{status:w.READY,plan:s};const a=await this.delayAndRefreshAutoSelectPlan(t,n,e.actionDelayConfig);return a?{status:w.READY,plan:this.createPlanLimitedToAlreadySatisfiedPriorityOption(a)||a}:{status:w.STOP_CYCLE}}async tryAutoSelectPlan(t){for(const e of t.priorityOptions){const n=await this.tryPriorityOptionForAction(t.action,e,t.config);if(n===P.SATISFIED)return N.CONTINUE;if(n===P.STOP_CYCLE)return N.STOP}return N.CONTINUE}async tryPriorityOptionForAction(t,e,n){if(this.isPriorityOptionAlreadySatisfied(t,e))return P.SATISFIED;if(I(e))return this.tryBraveryForAction(t,n);const i=await this.resolveChampionIdsForPriorityOption(t,e,n),s=f(e)&&!this.isLockingExistingPickIntent(t,i);for(const a of i){const r={tryNextRandomCandidateOnFailure:s},c=await this.attemptChampionForAction(t,a,n,r);if(c===C.SATISFIED)return P.SATISFIED;if(c===C.STOP_CYCLE)return P.STOP_CYCLE}return P.TRY_NEXT_PRIORITY_OPTION}async tryBraveryForAction(t,e){if(t.type!=="pick")return P.TRY_NEXT_PRIORITY_OPTION;if(this.isBraveryPickIntentSet(t))return P.SATISFIED;console.debug("auto-champion-select: Trying to pick Bravery...");const n=await this.selectChampion(t.id,ce);console.debug(n.ok?"auto-champion-select: Bravery request accepted, refreshing champ select state...":"auto-champion-select: Failed to pick Bravery, refreshing champ select state...");const i=await this.refreshPendingAction(t);return!i||!this.isActionAvailable(i,e)?n.ok?P.SATISFIED:P.STOP_CYCLE:this.isBraveryPickIntentSet(i)?P.SATISFIED:(this.rejectedBraveryActionIds.add(t.id),console.debug("auto-champion-select: Bravery was not applied after refresh, trying next pick..."),P.TRY_NEXT_PRIORITY_OPTION)}getLocalPlayerActions(){return lt(this.actions).filter(t=>this.isPendingLocalPlayerAction(t)).sort((t,e)=>Tt(t)-Tt(e))}isPendingLocalPlayerAction(t){return t.actorCellId===this.localPlayerCellId&&t.completed===!1}isActionAvailable(t,e){return t.type==="pick"?t.isInProgress===!0||e.pickIntent!==!1:t.isInProgress===!0}getConfigForActionType(t,e){return t==="pick"?e.pickConfig:t==="ban"?e.banConfig:null}createAutoSelectPlan(t,e){const n=this.getAvailablePriorityOptionsForAction(t,e);return n.length===0?null:{action:t,config:e,priorityOptions:n}}getAvailablePriorityOptionsForAction(t,e){return mt(e.priorityOptions||e.champions).filter(n=>!this.isPriorityOptionUnavailableForAction(t,n,e))}isPriorityOptionUnavailableForAction(t,e,n){return f(e)?this.isRandomPriorityOptionUnavailableForAction(t,n):I(e)?t.type!=="pick"||this.rejectedBraveryActionIds.has(t.id):this.isChampionUnavailableForAction(t,e,n)}isRandomPriorityOptionUnavailableForAction(t,e){if(t.type!=="pick")return!1;const n=T(e.randomAssignedPositions);return n.length===0?!1:this.localPlayerAssignedPosition?n.includes(this.localPlayerAssignedPosition)?!1:(console.debug(`auto-champion-select: Skipping random pick because assigned position ${this.localPlayerAssignedPosition} is not in ${n.join(", ")}.`),!0):(console.debug(`auto-champion-select: Skipping random pick because no assigned position is available for ${n.join(", ")} restriction.`),!0)}createPlanLimitedToAlreadySatisfiedPriorityOption(t){const e=t.priorityOptions.find(n=>this.isPriorityOptionAlreadySatisfied(t.action,n));return e===void 0?null:{...t,priorityOptions:[e]}}isPriorityOptionAlreadySatisfied(t,e){return f(e)?this.hasAnyPickIntentSet(t):I(e)?this.isBraveryPickIntentSet(t):this.isPickIntentSetToChampion(t,e)}hasAnyPickIntentSet(t){return t.type==="pick"&&t.isInProgress!==!0&&(this.localPlayerIntentChampionId!==null||this.localPlayerIntentIsBravery||p(t.championId)!==null||J(t.championId))}isBraveryPickIntentSet(t){return t.type==="pick"&&t.isInProgress!==!0&&(this.localPlayerIntentIsBravery||J(t.championId))}isLockingExistingPickIntent(t,e){return t.type==="pick"&&t.isInProgress===!0&&e.length===1&&e[0]===this.getPickIntentChampionId(t)}getPickIntentChampionId(t){return t.type!=="pick"?null:p(t.championId)??this.localPlayerIntentChampionId}async delayAndRefreshAutoSelectPlan(t,e,n){const i=_e(n);if(i<=0)return console.debug(`auto-champion-select: Action delay is instant for ${t.type}.`),this.createAutoSelectPlan(t,e);console.debug(`auto-champion-select: Waiting ${i}ms before ${t.type}...`);const s=this.watchVersion;if(await v(i),!this.mounted||s!==this.watchVersion)return null;let a=null;try{await this.refreshSessionState(),a=this.findPendingAction(t)}catch(c){return console.debug("auto-champion-select: Failed to refresh champion select after action delay",c),null}const r=this.getConfigForActionType(t.type,It());return!(r!=null&&r.enabled)||!a||!this.isActionAvailable(a,r)?null:this.createAutoSelectPlan(a,r)}async resolveChampionIdsForPriorityOption(t,e,n){return I(e)?[]:f(e)?this.resolveRandomChampionIdsForAction(t,n):[e]}async resolveRandomChampionIdsForAction(t,e){if(t.type==="pick"&&t.isInProgress===!0){const a=this.getPickIntentChampionId(t);if(a!==null&&!this.isChampionUnavailableForAction(t,a,e))return[a]}const n=await this.fetchRandomCandidateChampionIds(t);if(n.length===0)return[];const i=n.filter(a=>!this.isChampionUnavailableForAction(t,a,e)),s=t.type==="pick"&&!this.hasConfiguredRandomPoolPositions(e)?await this.preferAssignedPositionRandomPickCandidates(i):await this.filterRandomChampionIdsByConfiguredPoolPositions(i,e);return Je(s)}async fetchRandomCandidateChampionIds(t){const e=t.type==="pick"?g.pickableChampionIds:g.bannableChampionIds;try{const n=await E("GET",e);if(!n.ok)return console.debug(`auto-champion-select: Failed to load random ${t.type} candidates`,n),[];const i=await n.json();return t.type==="ban"&&Qe(i)?(console.debug("auto-champion-select: Random ban endpoint returned unrestricted sentinel, falling back to all champions..."),await this.fetchAllChampionIdsForRandomBan()):ve(i)}catch(n){return console.debug(`auto-champion-select: Failed to load random ${t.type} candidates`,n),[]}}async fetchAllChampionIdsForRandomBan(){return(await le()).map(e=>e.id)}hasConfiguredRandomPoolPositions(t){return T(t.randomPoolPositions).length>0}async filterRandomChampionIdsByConfiguredPoolPositions(t,e){const n=T(e.randomPoolPositions);if(n.length===0)return t;const i=new Set(n),s=await K(),a=t.filter(r=>{var c;return(c=s[String(r)])==null?void 0:c.some(h=>i.has(h))});return a.length===0&&console.debug(`auto-champion-select: No random candidates matched ${n.join(", ")} restriction.`),a}async preferAssignedPositionRandomPickCandidates(t){if(!this.localPlayerAssignedPosition)return t;const e=await K(),n=t.filter(i=>{var s;return(s=e[String(i)])==null?void 0:s.includes(this.localPlayerAssignedPosition)});return n.length>0?n:t}async attemptChampionForAction(t,e,n,i={}){const s=p(e);if(s===null||this.isChampionUnavailableForAction(t,s,n))return C.TRY_NEXT_CHAMPION;if(this.isPickIntentSetToChampion(t,s)||(console.debug(`auto-champion-select: Trying to ${t.type} ${s}...`),(await this.selectChampion(t.id,s)).ok))return C.SATISFIED;console.debug(`auto-champion-select: Failed to ${t.type} ${s}, refreshing champ select state...`);const r=await this.refreshPendingAction(t);return!r||!this.isActionAvailable(r,n)?C.STOP_CYCLE:i.tryNextRandomCandidateOnFailure===!0?this.hasAnyPickIntentSet(r)?C.SATISFIED:(console.debug(`auto-champion-select: Failed random ${t.type} candidate ${s}, trying next ${t.type}...`),C.TRY_NEXT_CHAMPION):this.isChampionUnavailableForAction(r,s,n)?(console.debug(`auto-champion-select: ${s} is unavailable after refresh, trying next ${t.type}...`),C.TRY_NEXT_CHAMPION):C.STOP_CYCLE}isPickIntentSetToChampion(t,e){return t.type==="pick"&&t.isInProgress!==!0&&(this.localPlayerIntentChampionId===e||p(t.championId)===e)}async refreshPendingAction(t){try{await this.refreshSessionState()}catch(e){return console.debug("auto-champion-select: Failed to refresh champion select action",e),null}return this.findPendingAction(t)}findPendingAction(t){return lt(this.actions).find(e=>e.id===t.id&&e.actorCellId===t.actorCellId&&e.type===t.type&&e.completed===!1)||null}isChampionUnavailableForAction(t,e,n){if(t.type==="pick"&&!Be(n,e,this.localPlayerAssignedPosition)){const i=ee(n,e);return this.localPlayerAssignedPosition?console.debug(`auto-champion-select: Picking ${e} but assigned position ${this.localPlayerAssignedPosition} is not in ${i.join(", ")}, skipping...`):console.debug(`auto-champion-select: Picking ${e} but no assigned position is available for ${i.join(", ")} restriction, skipping...`),!0}if(this.bannedChampionIds.has(e))return console.debug(`auto-champion-select: Banning ${e} but it's already banned, skipping...`),!0;if(t.type==="ban"&&this.alliedIntentChampionIds.has(e))if(n.force===!0)console.debug(`auto-champion-select: Banning ${e} but it has an allied pick intent, forcing...`);else return console.debug(`auto-champion-select: Banning ${e} but it has an allied pick intent, skipping...`),!0;if(t.type==="pick"&&this.teammateIntentChampionIds.has(e))if(n.force===!0)console.debug(`auto-champion-select: Picking ${e} but it has a teammate pick intent, forcing...`);else return console.debug(`auto-champion-select: Picking ${e} but it has a teammate pick intent, skipping...`),!0;return t.type==="pick"&&this.pickedChampionIds.has(e)?(console.debug(`auto-champion-select: Picking ${e} but it's already picked, skipping...`),!0):!1}selectChampion(t,e){const n=g.champSelectAction(t);return E("PATCH",n,{body:{championId:e,completed:!0}})}}const tn={socialRosterTitle:"AUTO CHAMPION SELECT",champSelectMenuTitle:"Auto Champion Select"},en={autoAccept:"Accept",pick:"Pick",ban:"Ban"},nn={on:"ON",off:"OFF"},on={pick:"Pick",ban:"Ban"},sn={TOP:"Top",JUNGLE:"Jungle",MIDDLE:"Mid",BOTTOM:"ADC",UTILITY:"Support"},an={two:"{first} or {second}",many:"{items}, or {last}"},rn={pickPlaceholder:"Add pick",banPlaceholder:"Add ban",search:"Search",emptyTitle:"No champions",pickEmptyHint:"Use the menu to add a pick",banEmptyHint:"Use the menu to add a ban",remove:"Remove {name}",positionFilterLabel:"Filter champions by position",random:{label:"Random",assignedTitlePart:"runs only when assigned role matches {positions}",poolTitlePart:"limits Random pool to {positions}"},bravery:{label:"Bravery",description:"For Arena mode"},positionBadge:{randomAssignedAny:"The plugin can use Random in any role. Click to run it only in selected draft roles.",randomAssignedSome:"The plugin will use Random only when your assigned role matches {positions}. Draft modes only. Click to edit.",randomPoolAny:"The plugin can choose any available champion at random. Click to filter the pool first.",randomPoolSome:"The plugin filters Random to champions for {positions}, then picks one. Click to edit.",championSome:"The plugin will pick this champion only when your assigned role matches {positions}. Draft modes only. Click to edit.",championAny:"The plugin can pick this champion in any role. Click to limit it to selected draft roles."}},ln={triggerLabel:"Auto champion select settings",empty:"No settings available",actionDelay:"Action delay",pickIntent:"Set pick intent",forcePick:"Ignore ally pick intent",forceBan:"Ignore ally pick intent when banning",hideAutoAcceptPrompt:"Hide auto-accept prompt",handleLabel:"{label} {handle}",handles:{min:"min",max:"max"},actionDelayValue:{instant:"Instant",exact:"Delays actions for {delay}",upTo:"Delays actions up to {delay}",range:"Delays actions {min}-{max}"}},cn={readyCheckAccepted:"Match accepted!",readyCheckAcceptFailed:"Failed to accept match. Check console."},dn={group:"Balaclava: Auto Champion Select",autoSwitchName:"Auto {name} [{state}]",turnOn:"Turn ON",turnOff:"Turn OFF",autoSwitchOn:"Auto {name} is ON!",autoSwitchOff:"Auto {name} is OFF!",autoSwitchError:"Failed to toggle Auto {name}. Check console.",forcePickName:"Ignore Team Intent Pick",forceBanName:"Ignore Team Intent Ban",forceSwitchName:"{name} [{state}]",forcePickLegend:"Pick even if a teammate intends that champion",forceBanLegend:"Ban even if a teammate intends that champion",forceSwitchOn:"{name} is ON!",forceSwitchOff:"{name} is OFF!",forceSwitchError:"Failed to toggle {name}. Check console.",refreshChampionsName:"Refresh Champions",refreshChampionsLegend:"Normally champion selectors refresh automatically...",refreshChampionsSuccess:"Refreshed Champions!",refreshChampionsError:"Failed to refresh Champions. Check console."},hn={plugin:tn,toggles:en,states:nn,actions:on,positions:sn,list:an,selectors:rn,settings:ln,toasts:cn,commandBar:dn},un={socialRosterTitle:"AUTO CHAMPION SELECT",champSelectMenuTitle:"Auto Champion Select"},pn={autoAccept:"Aceptar",pick:"Pick",ban:"Ban"},mn={on:"ON",off:"OFF"},gn={pick:"Pick",ban:"Ban"},fn={TOP:"Top",JUNGLE:"Jungla",MIDDLE:"Mid",BOTTOM:"ADC",UTILITY:"Soporte"},yn={two:"{first} o {second}",many:"{items} o {last}"},Pn={pickPlaceholder:"Agregar pick",banPlaceholder:"Agregar ban",search:"Buscar",emptyTitle:"Sin campeones",pickEmptyHint:"Usa el menú para agregar",banEmptyHint:"Usa el menú para agregar",remove:"Quitar {name}",positionFilterLabel:"Filtrar campeones por posición",random:{label:"Aleatorio",assignedTitlePart:"solo si la posición asignada es {positions}",poolTitlePart:"filtra el pool a {positions}"},bravery:{label:"Valentía",description:"Para Arena"},positionBadge:{randomAssignedAny:"Aleatorio sirve en cualquier posición. Haz clic para limitar posiciones de draft.",randomAssignedSome:"Aleatorio solo si tu posición es {positions}. Solo draft; haz clic para editar.",randomPoolAny:"Aleatorio puede elegir cualquier campeón disponible. Haz clic para filtrar.",randomPoolSome:"Aleatorio elige campeones de {positions}. Haz clic para editar.",championSome:"Este campeón solo se elige si tu posición es {positions}. Solo draft; haz clic para editar.",championAny:"Este campeón sirve en cualquier posición. Haz clic para limitar posiciones."}},Sn={triggerLabel:"Ajustes de Auto Champion Select",empty:"Sin ajustes",actionDelay:"Retraso de acción",pickIntent:"Marcar intención de selección",forcePick:"Ignorar intención aliada al pickear",forceBan:"Ignorar intención aliada al banear",hideAutoAcceptPrompt:"Ocultar confirmación de partida",handleLabel:"{label} {handle}",handles:{min:"mín",max:"máx"},actionDelayValue:{instant:"Sin retraso",exact:"Retraso de {delay}",upTo:"Hasta {delay}",range:"Retraso de {min}-{max}"}},An={readyCheckAccepted:"¡Partida aceptada!",readyCheckAcceptFailed:"No se pudo aceptar la partida. Revisa la consola."},Cn={group:"Balaclava: Auto Champion Select",autoSwitchName:"Auto {name} [{state}]",turnOn:"Activar",turnOff:"Desactivar",autoSwitchOn:"Auto {name} está ON!",autoSwitchOff:"Auto {name} está OFF!",autoSwitchError:"No se pudo cambiar Auto {name}. Revisa la consola.",forcePickName:"Ignorar intención aliada al pickear",forceBanName:"Ignorar intención aliada al banear",forceSwitchName:"{name} [{state}]",forcePickLegend:"Pickea aunque un aliado quiera el mismo campeón",forceBanLegend:"Banea aunque un aliado quiera ese campeón",forceSwitchOn:"{name} está ON!",forceSwitchOff:"{name} está OFF!",forceSwitchError:"No se pudo cambiar {name}. Revisa la consola.",refreshChampionsName:"Actualizar campeones",refreshChampionsLegend:"Normalmente los selectores se actualizan solos...",refreshChampionsSuccess:"¡Campeones actualizados!",refreshChampionsError:"No se actualizaron campeones. Revisa la consola."},bn={plugin:un,toggles:pn,states:mn,actions:gn,positions:fn,list:yn,selectors:Pn,settings:Sn,toasts:An,commandBar:Cn},En={socialRosterTitle:"AUTO CHAMPION SELECT",champSelectMenuTitle:"Auto Champion Select"},On={autoAccept:"수락",pick:"선택",ban:"밴"},wn={on:"ON",off:"OFF"},Tn={pick:"선택",ban:"밴"},In={TOP:"탑",JUNGLE:"정글",MIDDLE:"미드",BOTTOM:"원딜",UTILITY:"서폿"},kn={two:"{first} 또는 {second}",many:"{items} 또는 {last}"},Ln={pickPlaceholder:"픽 추가",banPlaceholder:"밴 추가",search:"검색",emptyTitle:"챔피언 없음",pickEmptyHint:"메뉴에서 추가",banEmptyHint:"메뉴에서 추가",remove:"{name} 제거",positionFilterLabel:"포지션별 챔피언 필터",random:{label:"랜덤",assignedTitlePart:"배정 포지션이 {positions}일 때만 실행",poolTitlePart:"랜덤 풀을 {positions}로 제한"},bravery:{label:"용기",description:"아레나용"},positionBadge:{randomAssignedAny:"랜덤은 모든 포지션에서 사용 가능. 클릭해 드래프트 포지션 제한.",randomAssignedSome:"랜덤은 배정 포지션이 {positions}일 때만 사용. 드래프트 전용; 클릭해 편집.",randomPoolAny:"랜덤은 가능한 모든 챔피언 중 선택 가능. 클릭해 풀 필터.",randomPoolSome:"랜덤은 {positions} 챔피언 중 선택. 클릭해 편집.",championSome:"이 챔피언은 배정 포지션이 {positions}일 때만 선택. 드래프트 전용; 클릭해 편집.",championAny:"이 챔피언은 모든 포지션에서 선택 가능. 클릭해 포지션 제한."}},_n={triggerLabel:"Auto Champion Select 설정",empty:"설정 없음",actionDelay:"동작 지연",pickIntent:"선택 의도 설정",forcePick:"아군 희망 챔피언 무시하고 선택",forceBan:"아군 희망 챔피언 무시하고 밴",hideAutoAcceptPrompt:"자동 수락 알림 숨기기",handleLabel:"{label} {handle}",handles:{min:"최소",max:"최대"},actionDelayValue:{instant:"즉시",exact:"{delay} 지연",upTo:"{delay}까지 지연",range:"{min}-{max} 지연"}},vn={readyCheckAccepted:"게임 수락됨!",readyCheckAcceptFailed:"게임 수락 실패. 콘솔 확인."},Rn={group:"Balaclava: Auto Champion Select",autoSwitchName:"자동 {name} [{state}]",turnOn:"켜기",turnOff:"끄기",autoSwitchOn:"자동 {name} 켜짐!",autoSwitchOff:"자동 {name} 꺼짐!",autoSwitchError:"자동 {name} 전환 실패. 콘솔 확인.",forcePickName:"희망 챔피언 무시 선택",forceBanName:"희망 챔피언 무시 밴",forceSwitchName:"{name} [{state}]",forcePickLegend:"팀원이 같은 챔피언을 희망해도 선택",forceBanLegend:"팀원이 같은 챔피언을 희망해도 밴",forceSwitchOn:"{name} 켜짐!",forceSwitchOff:"{name} 꺼짐!",forceSwitchError:"{name} 전환 실패. 콘솔 확인.",refreshChampionsName:"챔피언 새로고침",refreshChampionsLegend:"챔피언 목록은 보통 자동으로 새로고침됩니다...",refreshChampionsSuccess:"챔피언 새로고침 완료!",refreshChampionsError:"챔피언 새로고침 실패. 콘솔 확인."},Mn={plugin:En,toggles:On,states:wn,actions:Tn,positions:In,list:kn,selectors:Ln,settings:_n,toasts:vn,commandBar:Rn},Nn={socialRosterTitle:"AUTO CHAMPION SELECT",champSelectMenuTitle:"Auto Champion Select"},Bn={autoAccept:"Aceitar",pick:"Pick",ban:"Ban"},Dn={on:"ON",off:"OFF"},xn={pick:"Pick",ban:"Ban"},Fn={TOP:"Top",JUNGLE:"Jungle",MIDDLE:"Mid",BOTTOM:"ADC",UTILITY:"Suporte"},$n={two:"{first} ou {second}",many:"{items} ou {last}"},Hn={pickPlaceholder:"Adicionar pick",banPlaceholder:"Adicionar ban",search:"Buscar",emptyTitle:"Nenhum campeão",pickEmptyHint:"Use o menu para adicionar um pick",banEmptyHint:"Use o menu para adicionar um ban",remove:"Remover {name}",positionFilterLabel:"Filtrar campeões por posição",random:{label:"Aleatório",assignedTitlePart:"só roda quando sua rota for {positions}",poolTitlePart:"limita o pool a {positions}"},bravery:{label:"Bravura",description:"Para o modo Arena"},positionBadge:{randomAssignedAny:"Aleatório pode rodar em qualquer rota. Clique para limitar às rotas do draft.",randomAssignedSome:"Aleatório só roda se sua rota for {positions}. Draft apenas. Clique para editar.",randomPoolAny:"Aleatório pode escolher qualquer campeão disponível. Clique para filtrar o pool.",randomPoolSome:"Aleatório escolhe campeões de {positions}. Clique para editar.",championSome:"Este campeão só será escolhido se sua rota for {positions}. Draft apenas. Clique para editar.",championAny:"Este campeão pode ser escolhido em qualquer rota. Clique para limitar às rotas do draft."}},zn={triggerLabel:"Configurações do Auto Champion Select",empty:"Nenhuma configuração disponível",actionDelay:"Delay de ação",pickIntent:"Marcar intenção de pick",forcePick:"Ignorar intenção aliada no pick",forceBan:"Ignorar intenção aliada no ban",hideAutoAcceptPrompt:"Ocultar confirmação da fila",handleLabel:"{label} {handle}",handles:{min:"mínimo",max:"máximo"},actionDelayValue:{instant:"Sem delay",exact:"Delay de {delay}",upTo:"Delay de até {delay}",range:"Delay de {min}-{max}"}},Vn={readyCheckAccepted:"Fila aceita!",readyCheckAcceptFailed:"Falha ao aceitar a fila. Verifique o console."},Gn={group:"Balaclava: Auto Champion Select",autoSwitchName:"Auto {name} [{state}]",turnOn:"Ativar",turnOff:"Desativar",autoSwitchOn:"Auto {name} está ON!",autoSwitchOff:"Auto {name} está OFF!",autoSwitchError:"Falha ao alternar Auto {name}. Verifique o console.",forcePickName:"Ignorar intenção aliada no pick",forceBanName:"Ignorar intenção aliada no ban",forceSwitchName:"{name} [{state}]",forcePickLegend:"Escolhe mesmo se um aliado indicar o mesmo campeão",forceBanLegend:"Bane mesmo se um aliado indicar o campeão",forceSwitchOn:"{name} está ON!",forceSwitchOff:"{name} está OFF!",forceSwitchError:"Falha ao alternar {name}. Verifique o console.",refreshChampionsName:"Atualizar campeões",refreshChampionsLegend:"Normalmente as listas de campeões atualizam automaticamente...",refreshChampionsSuccess:"Campeões atualizados!",refreshChampionsError:"Falha ao atualizar campeões. Verifique o console."},Un={plugin:Nn,toggles:Bn,states:Dn,actions:xn,positions:Fn,list:$n,selectors:Hn,settings:zn,toasts:Vn,commandBar:Gn},Yn={socialRosterTitle:"AUTO CHAMPION SELECT",champSelectMenuTitle:"Auto Champion Select"},qn={autoAccept:"Kabul Et",pick:"Seç",ban:"Yasakla"},jn={on:"ON",off:"OFF"},Kn={pick:"Seç",ban:"Yasakla"},Wn={TOP:"Üst",JUNGLE:"Orman",MIDDLE:"Orta",BOTTOM:"Alt",UTILITY:"Destek"},Xn={two:"{first} veya {second}",many:"{items} veya {last}"},Jn={pickPlaceholder:"Seçim ekle",banPlaceholder:"Yasaklama ekle",search:"Ara",emptyTitle:"Şampiyon yok",pickEmptyHint:"Menüden seçenek ekle",banEmptyHint:"Menüden seçenek ekle",remove:"{name} kaldır",positionFilterLabel:"Şampiyonları konuma göre filtrele",random:{label:"Rastgele",assignedTitlePart:"atanan konum {positions} ise çalışır",poolTitlePart:"rastgele havuzu {positions} ile sınırlar"},bravery:{label:"Cesaret",description:"Arena modu için"},positionBadge:{randomAssignedAny:"Rastgele her konumda kullanılabilir. Draft konumlarıyla sınırla.",randomAssignedSome:"Rastgele yalnız atanan konum {positions} ise kullanılır. Sadece draft; düzenle.",randomPoolAny:"Rastgele tüm uygun şampiyonlardan seçebilir. Havuzu filtrele.",randomPoolSome:"Rastgele, {positions} şampiyonlarından seçer. Düzenle.",championSome:"Bu şampiyon yalnız atanan konum {positions} ise seçilir. Sadece draft; düzenle.",championAny:"Bu şampiyon her konumda seçilebilir. Konumları sınırla."}},Qn={triggerLabel:"Auto Champion Select ayarları",empty:"Ayar yok",actionDelay:"İşlem gecikmesi",pickIntent:"Seçim niyeti ayarla",forcePick:"Seçim niyetini yok sayarak seç",forceBan:"Seçim niyetini yok sayarak yasakla",hideAutoAcceptPrompt:"Karşılaşma kabul penceresini gizle",handleLabel:"{label} {handle}",handles:{min:"min",max:"maks"},actionDelayValue:{instant:"Anında",exact:"{delay} gecikme",upTo:"{delay} kadar gecikme",range:"{min}-{max} gecikme"}},Zn={readyCheckAccepted:"Karşılaşma kabul edildi!",readyCheckAcceptFailed:"Karşılaşma kabul edilemedi. Konsola bakın."},to={group:"Balaclava: Auto Champion Select",autoSwitchName:"Oto {name} [{state}]",turnOn:"Aç",turnOff:"Kapat",autoSwitchOn:"Oto {name} açık!",autoSwitchOff:"Oto {name} kapalı!",autoSwitchError:"Oto {name} değiştirilemedi. Konsola bakın.",forcePickName:"Seçim niyetini yok sayarak seç",forceBanName:"Seçim niyetini yok sayarak yasakla",forceSwitchName:"{name} [{state}]",forcePickLegend:"Takım arkadaşı aynı şampiyonu istese de seçer",forceBanLegend:"Takım arkadaşı aynı şampiyonu istese de yasaklar",forceSwitchOn:"{name} açık!",forceSwitchOff:"{name} kapalı!",forceSwitchError:"{name} değiştirilemedi. Konsola bakın.",refreshChampionsName:"Şampiyonları yenile",refreshChampionsLegend:"Seçiciler normalde otomatik yenilenir...",refreshChampionsSuccess:"Şampiyonlar yenilendi!",refreshChampionsError:"Şampiyonlar yenilenemedi. Konsola bakın."},eo={plugin:Yn,toggles:qn,states:jn,actions:Kn,positions:Wn,list:Xn,selectors:Jn,settings:Qn,toasts:Zn,commandBar:to},no={socialRosterTitle:"AUTO CHAMPION SELECT",champSelectMenuTitle:"Auto Champion Select"},oo={autoAccept:"Chấp nhận",pick:"Chọn",ban:"Cấm"},io={on:"ON",off:"OFF"},so={pick:"Chọn",ban:"Cấm"},ao={TOP:"Đường trên",JUNGLE:"Rừng",MIDDLE:"Đường giữa",BOTTOM:"Đường dưới",UTILITY:"Hỗ trợ"},ro={two:"{first} hoặc {second}",many:"{items} hoặc {last}"},lo={pickPlaceholder:"Thêm tướng chọn",banPlaceholder:"Thêm tướng cấm",search:"Tìm",emptyTitle:"Không có tướng",pickEmptyHint:"Dùng menu để thêm",banEmptyHint:"Dùng menu để thêm",remove:"Xóa {name}",positionFilterLabel:"Lọc tướng theo vị trí",random:{label:"Ngẫu nhiên",assignedTitlePart:"chỉ chạy khi vị trí là {positions}",poolTitlePart:"lọc bể tướng theo {positions}"},bravery:{label:"Quả Cảm",description:"Cho chế độ Võ Đài"},positionBadge:{randomAssignedAny:"Ngẫu nhiên dùng được mọi vị trí. Bấm để giới hạn vị trí Cấm Chọn.",randomAssignedSome:"Ngẫu nhiên chỉ dùng khi vị trí là {positions}. Chỉ Cấm Chọn; bấm để sửa.",randomPoolAny:"Ngẫu nhiên có thể chọn mọi tướng hợp lệ. Bấm để lọc nhóm.",randomPoolSome:"Ngẫu nhiên chọn tướng thuộc {positions}. Bấm để sửa.",championSome:"Tướng này chỉ được chọn khi vị trí là {positions}. Chỉ Cấm Chọn; bấm để sửa.",championAny:"Tướng này dùng được mọi vị trí. Bấm để giới hạn."}},co={triggerLabel:"Cài đặt Auto Champion Select",empty:"Không có cài đặt",actionDelay:"Độ trễ thao tác",pickIntent:"Đặt ý định chọn tướng",forcePick:"Bỏ qua ý định chọn tướng",forceBan:"Bỏ qua ý định chọn khi cấm",hideAutoAcceptPrompt:"Ẩn lời nhắc chấp nhận trận",handleLabel:"{label} {handle}",handles:{min:"tối thiểu",max:"tối đa"},actionDelayValue:{instant:"Ngay",exact:"Trễ {delay}",upTo:"Tới {delay}",range:"Trễ {min}-{max}"}},ho={readyCheckAccepted:"Đã chấp nhận trận!",readyCheckAcceptFailed:"Không thể chấp nhận trận. Xem console."},uo={group:"Balaclava: Auto Champion Select",autoSwitchName:"Tự động {name} [{state}]",turnOn:"Bật",turnOff:"Tắt",autoSwitchOn:"Tự động {name} đã bật!",autoSwitchOff:"Tự động {name} đã tắt!",autoSwitchError:"Không đổi được tự động {name}. Xem console.",forcePickName:"Bỏ qua ý định chọn tướng",forceBanName:"Bỏ qua ý định chọn khi cấm",forceSwitchName:"{name} [{state}]",forcePickLegend:"Vẫn chọn dù đồng đội cũng định chọn",forceBanLegend:"Vẫn cấm dù đồng đội định chọn",forceSwitchOn:"{name} đã bật!",forceSwitchOff:"{name} đã tắt!",forceSwitchError:"Không đổi được {name}. Xem console.",refreshChampionsName:"Làm mới tướng",refreshChampionsLegend:"Danh sách tướng thường tự làm mới...",refreshChampionsSuccess:"Đã làm mới tướng!",refreshChampionsError:"Không thể làm mới tướng. Xem console."},kt={plugin:no,toggles:oo,states:io,actions:so,positions:ao,list:ro,selectors:lo,settings:co,toasts:ho,commandBar:uo},po={socialRosterTitle:"AUTO CHAMPION SELECT",champSelectMenuTitle:"Auto Champion Select"},mo={autoAccept:"接受",pick:"选择",ban:"禁用"},go={on:"ON",off:"OFF"},fo={pick:"选择",ban:"禁用"},yo={TOP:"上路",JUNGLE:"打野",MIDDLE:"中路",BOTTOM:"下路",UTILITY:"辅助"},Po={two:"{first}或{second}",many:"{items}或{last}"},So={pickPlaceholder:"添加选用英雄",banPlaceholder:"添加禁用英雄",search:"搜索",emptyTitle:"无英雄",pickEmptyHint:"用菜单添加",banEmptyHint:"用菜单添加",remove:"移除{name}",positionFilterLabel:"按分路筛选英雄",random:{label:"随机",assignedTitlePart:"仅在分配位置为{positions}时执行",poolTitlePart:"将随机英雄池限制为{positions}"},bravery:{label:"勇敢举动",description:"用于斗魂竞技场"},positionBadge:{randomAssignedAny:"随机可用于任意位置。点击限制为选定征召位置。",randomAssignedSome:"随机仅在分配位置为{positions}时使用。仅征召;点击编辑。",randomPoolAny:"随机可从所有可用英雄中选择。点击筛选英雄池。",randomPoolSome:"随机从{positions}英雄中选择。点击编辑。",championSome:"仅当分配位置为{positions}时选择此英雄。仅征召;点击编辑。",championAny:"此英雄可用于任意位置。点击限制位置。"}},Ao={triggerLabel:"Auto Champion Select 设置",empty:"无设置",actionDelay:"操作延迟",pickIntent:"设置选用意向",forcePick:"无视队友意向并选用",forceBan:"无视队友意向并禁用",hideAutoAcceptPrompt:"隐藏对局接受提示",handleLabel:"{label} {handle}",handles:{min:"最小",max:"最大"},actionDelayValue:{instant:"立即",exact:"延迟{delay}",upTo:"最多{delay}",range:"延迟{min}-{max}"}},Co={readyCheckAccepted:"对局已接受!",readyCheckAcceptFailed:"接受对局失败。查看控制台。"},bo={group:"Balaclava: Auto Champion Select",autoSwitchName:"自动{name} [{state}]",turnOn:"开启",turnOff:"关闭",autoSwitchOn:"自动{name}已开启!",autoSwitchOff:"自动{name}已关闭!",autoSwitchError:"切换自动{name}失败。查看控制台。",forcePickName:"无视队友意向选用",forceBanName:"无视队友意向禁用",forceSwitchName:"{name} [{state}]",forcePickLegend:"即使队友也想用该英雄也会选用",forceBanLegend:"即使队友想用该英雄也会禁用",forceSwitchOn:"{name}已开启!",forceSwitchOff:"{name}已关闭!",forceSwitchError:"切换{name}失败。查看控制台。",refreshChampionsName:"刷新英雄列表",refreshChampionsLegend:"英雄列表通常会自动刷新...",refreshChampionsSuccess:"英雄列表已刷新!",refreshChampionsError:"刷新英雄列表失败。查看控制台。"},Eo={plugin:po,toggles:mo,states:go,actions:fo,positions:yo,list:Po,selectors:So,settings:Ao,toasts:Co,commandBar:bo},Pt="en-US",W=Object.freeze({"en-US":hn,"es-MX":bn,"ko-KR":Mn,"pt-BR":Un,"tr-TR":eo,"vi-VN":kt,"vn-VN":kt,"zh-CN":Eo});let ct=Pt,de=!1;function Oo(){var o,t,e;return typeof document<"u"?((t=(o=document.body)==null?void 0:o.dataset)==null?void 0:t.locale)||((e=document.documentElement)==null?void 0:e.lang)||"":typeof navigator<"u"&&navigator.language||""}async function wo(){try{const o=await E("GET",g.regionLocale);if(!o.ok)return"";const t=await o.json();return typeof(t==null?void 0:t.locale)=="string"?t.locale:""}catch{return""}}function To(o){var s;const t=String(o||"").replace("_","-"),e=Object.keys(W).find(a=>a.toLowerCase()===t.toLowerCase());if(e)return e;const n=(s=t.split("-")[0])==null?void 0:s.toLowerCase();return Object.keys(W).find(a=>a.toLowerCase().startsWith(`${n}-`))||Pt}function he(o){return ct=To(o),ct}function Lt(o,t){return t.split(".").reduce((e,n)=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e[n]},o)}function Io(o,t){return o.replace(/\{(\w+)\}/g,(e,n)=>Object.prototype.hasOwnProperty.call(t,n)?String(t[n]):e)}function ue(){return de||he(Oo()),ct}async function ko(){const o=await wo();return o?(de=!0,he(o)):ue()}function l(o,t={}){const e=ue(),n=Lt(W[e],o),i=Lt(W[Pt],o);return Io(typeof n=="string"?n:typeof i=="string"?i:o,t)}function Lo(o){const t=o.map(e=>String(e));return t.length===0?"":t.length===1?t[0]:t.length===2?l("list.two",{first:t[0],second:t[1]}):l("list.many",{items:t.slice(0,-1).join(", "),last:t[t.length-1]})}function X(o){const t=`positions.${o.value}`,e=l(t);return e===t?o.label:e}function _o(o){const t=te(o);return t?X(t):""}const O=Object.freeze({dropdown:"lol-uikit-framed-dropdown",dropdownOption:"lol-uikit-dropdown-option",radioInputOption:"lol-uikit-radio-input-option",scrollable:"lol-uikit-scrollable",socialRosterGroup:"lol-social-roster-group"}),d=Object.freeze({socialRoster:".lol-social-roster",champSelectButtons:".bottom-right-buttons",firstChampSelectSquareButton:"lol-social-chat-toggle-button, .missions-tracker-button-component, .champ-select-voice-button-wrapper",dropdownRoot:".ui-dropdown",dropdownCurrent:".ui-dropdown-current",dropdownCurrentContent:".ui-dropdown-current-content",dropdownOption:O.dropdownOption,dropdownOptionSelected:`${O.dropdownOption}[selected]`,dropdownOptionsContainer:".ui-dropdown-options-container",dropdownOptions:".ui-dropdown-options",dropdownScrollable:O.scrollable,socialRosterGroupArrow:".arrow",socialRosterGroupHeader:".group-header",socialRosterGroupLabel:"span"});function _t(){return document.querySelector(d.socialRoster)}function dt(){return document.querySelector(d.champSelectButtons)}const vo=50,Ro=100,Q=210,Z=40,q="controlado-position-filter",ht="controlado-position-filter-visible",_="controlado-position-filter__badge",ut="controlado-position-filter__badge--active",vt="controlado-placeholder",Rt="controlado-search",pe="controlado-filter-input",me="controlado-tag--search",ge="controlado-tag",fe="controlado-filter-icon",B="controlado-filter-icon--trash",Mt="controlado-champion-option__content",Nt="controlado-champion-option__icon",Mo="controlado-champion-option__text",Bt="controlado-champion-option__name",No="controlado-champion-option__description",Bo="controlado-champion-option__static-icon",Dt=`
|
|
11
|
+
${d.dropdownRoot} {
|
|
12
12
|
position: relative;
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -16,7 +16,7 @@ import{request as I,sleep as v,linkEndpoint as yt}from"https://cdn.jsdelivr.net/
|
|
|
16
16
|
--framed-dropdown-scrollable-max-height: ${Q}px;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
:host ${
|
|
19
|
+
:host ${d.dropdownRoot} dt${d.dropdownCurrent} {
|
|
20
20
|
display: grid;
|
|
21
21
|
grid-template-columns: minmax(0, 1fr) max-content;
|
|
22
22
|
align-items: center;
|
|
@@ -24,17 +24,17 @@ import{request as I,sleep as v,linkEndpoint as yt}from"https://cdn.jsdelivr.net/
|
|
|
24
24
|
padding: 7px 8px 7px 10px;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
:host ${
|
|
27
|
+
:host ${d.dropdownRoot} dt${d.dropdownCurrent}::after {
|
|
28
28
|
display: none;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
:host ${
|
|
31
|
+
:host ${d.dropdownRoot} dt${d.dropdownCurrent} ${d.dropdownCurrentContent} {
|
|
32
32
|
min-width: 0;
|
|
33
33
|
padding: 0;
|
|
34
34
|
text-align: left;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
${
|
|
37
|
+
${d.dropdownOptionsContainer} {
|
|
38
38
|
position: absolute;
|
|
39
39
|
top: auto;
|
|
40
40
|
bottom: 100%;
|
|
@@ -44,25 +44,25 @@ import{request as I,sleep as v,linkEndpoint as yt}from"https://cdn.jsdelivr.net/
|
|
|
44
44
|
transform: translateY(0);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
${
|
|
48
|
-
${
|
|
47
|
+
${d.dropdownOptions},
|
|
48
|
+
${d.dropdownScrollable} {
|
|
49
49
|
height: ${Q}px;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
${
|
|
52
|
+
${d.dropdownOptions} {
|
|
53
53
|
width: 100%;
|
|
54
54
|
box-sizing: border-box;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
${
|
|
57
|
+
${d.dropdownOptions} ${d.dropdownScrollable} {
|
|
58
58
|
box-sizing: border-box;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
${
|
|
62
|
-
padding-top: ${
|
|
61
|
+
${d.dropdownOptionsContainer}.${ht} ${d.dropdownOptions} ${d.dropdownScrollable} {
|
|
62
|
+
padding-top: ${Z}px;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
.${
|
|
65
|
+
.${q} {
|
|
66
66
|
position: absolute;
|
|
67
67
|
left: 0;
|
|
68
68
|
right: 0;
|
|
@@ -71,8 +71,8 @@ import{request as I,sleep as v,linkEndpoint as yt}from"https://cdn.jsdelivr.net/
|
|
|
71
71
|
display: flex;
|
|
72
72
|
align-items: center;
|
|
73
73
|
justify-content: space-between;
|
|
74
|
-
height: ${
|
|
75
|
-
min-height: ${
|
|
74
|
+
height: ${Z}px;
|
|
75
|
+
min-height: ${Z}px;
|
|
76
76
|
padding: 0 17px;
|
|
77
77
|
border-bottom: 1px solid #1e282d;
|
|
78
78
|
background: #010a13;
|
|
@@ -80,7 +80,7 @@ import{request as I,sleep as v,linkEndpoint as yt}from"https://cdn.jsdelivr.net/
|
|
|
80
80
|
box-sizing: border-box;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
.${
|
|
83
|
+
.${_} {
|
|
84
84
|
appearance: none;
|
|
85
85
|
display: grid;
|
|
86
86
|
place-items: center;
|
|
@@ -97,19 +97,19 @@ import{request as I,sleep as v,linkEndpoint as yt}from"https://cdn.jsdelivr.net/
|
|
|
97
97
|
outline: none;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
.${
|
|
101
|
-
.${
|
|
100
|
+
.${_}:hover,
|
|
101
|
+
.${_}:focus {
|
|
102
102
|
border-color: #c8aa6e;
|
|
103
103
|
background: #0f1b2d;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
.${
|
|
106
|
+
.${ut} {
|
|
107
107
|
border-color: #f0e6d2;
|
|
108
108
|
background: #09202c;
|
|
109
109
|
box-shadow: 0 0 0 1px #c89b3c, 0 0 10px rgba(200, 155, 60, 0.45);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
.${
|
|
112
|
+
.${_} img {
|
|
113
113
|
display: block;
|
|
114
114
|
width: 18px;
|
|
115
115
|
height: 18px;
|
|
@@ -118,13 +118,13 @@ import{request as I,sleep as v,linkEndpoint as yt}from"https://cdn.jsdelivr.net/
|
|
|
118
118
|
pointer-events: none;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
.${
|
|
122
|
-
.${
|
|
123
|
-
.${
|
|
121
|
+
.${_}:hover img,
|
|
122
|
+
.${_}:focus img,
|
|
123
|
+
.${ut} img {
|
|
124
124
|
opacity: 1;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
.${
|
|
127
|
+
.${fe} {
|
|
128
128
|
cursor: default;
|
|
129
129
|
display: inline-block;
|
|
130
130
|
flex: 0 0 auto;
|
|
@@ -137,14 +137,14 @@ import{request as I,sleep as v,linkEndpoint as yt}from"https://cdn.jsdelivr.net/
|
|
|
137
137
|
-webkit-mask-size: 18px 18px;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
.${
|
|
140
|
+
.${B} {
|
|
141
141
|
cursor: pointer;
|
|
142
142
|
background-color: #c86e6e;
|
|
143
143
|
-webkit-mask-image: url('/fe/lol-uikit/images/icon_delete.png');
|
|
144
144
|
-webkit-mask-size: 12px 12px;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
.${
|
|
147
|
+
.${pe} {
|
|
148
148
|
flex: 0 0 auto;
|
|
149
149
|
min-width: 0;
|
|
150
150
|
width: auto;
|
|
@@ -158,7 +158,7 @@ import{request as I,sleep as v,linkEndpoint as yt}from"https://cdn.jsdelivr.net/
|
|
|
158
158
|
font-weight: inherit;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
.${
|
|
161
|
+
.${ge} {
|
|
162
162
|
cursor: default;
|
|
163
163
|
display: inline-flex;
|
|
164
164
|
align-items: center;
|
|
@@ -176,7 +176,7 @@ import{request as I,sleep as v,linkEndpoint as yt}from"https://cdn.jsdelivr.net/
|
|
|
176
176
|
box-shadow: inset 0 0 8px rgba(15, 30, 45, 0.6);
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
.${
|
|
179
|
+
.${me} {
|
|
180
180
|
border-color: #d7b46a;
|
|
181
181
|
color: #f6e1b2;
|
|
182
182
|
background: #1a232f;
|
|
@@ -189,4 +189,4 @@ import{request as I,sleep as v,linkEndpoint as yt}from"https://cdn.jsdelivr.net/
|
|
|
189
189
|
text-transform: none;
|
|
190
190
|
font-weight: 500;
|
|
191
191
|
}
|
|
192
|
-
`;function Z(o){const t=document.createElement(A.dropdownOption);return t.setAttribute("slot",A.dropdownOption),t.innerText=o,t}class We{constructor(t,e,n,i={}){this.dropdownElement=t,this.placeholderText=e,this.searchPlaceholderText=i.searchPlaceholderText||"Search",this.staticOptions=Array.isArray(i.staticOptions)?i.staticOptions:[],this.onPriorityOptionSelected=n,this.placeholderOption=null,this.searchQuery="",this.activePositionFilter=null,this.hasRecommendedPositionData=!1,this.recommendedPositionsByOption=new WeakMap,this.staticOptionElements=new WeakSet}renderOptions(t){this.dropdownElement.replaceChildren(),this.hasRecommendedPositionData=!1,this.staticOptionElements=new WeakSet,this.placeholderOption=Z(this.placeholderText),this.placeholderOption.setAttribute("selected","true"),this.hidePlaceholderOption(),this.dropdownElement.appendChild(this.placeholderOption);for(const e of this.staticOptions)this.dropdownElement.appendChild(this.createStaticOption(e));for(const e of t){const n=this.getChampionRecommendedPositions(e),i=this.createChampionOption(e,n);n.length>0&&(this.hasRecommendedPositionData=!0),this.dropdownElement.appendChild(i)}this.hasRecommendedPositionData||(this.activePositionFilter=null),this.applyOptionFilters()}createChampionOption(t,e){const n=Z("");return this.recommendedPositionsByOption.set(n,new Set(e)),n.title=t.name,n.appendChild(this.createChampionOptionContent(t)),n.addEventListener("click",()=>{this.onPriorityOptionSelected(t.id),requestAnimationFrame(()=>this.reset())}),n}createStaticOption(t){const e=Z(""),n=typeof t.description=="string"?t.description:"";return this.staticOptionElements.add(e),e.title=n?`${t.label}. ${n}`:t.label,e.appendChild(this.createStaticOptionContent(t,n)),e.addEventListener("click",()=>{this.onPriorityOptionSelected(t.value),requestAnimationFrame(()=>this.reset())}),e}createChampionOptionContent(t){const e=document.createElement("span");e.classList.add(_t);const n=document.createElement("img");n.classList.add(Rt),n.src=t.squarePortraitPath,n.alt="",n.draggable=!1,n.loading="lazy";const i=document.createElement("span");return i.classList.add(vt),i.innerText=t.name,e.append(n,i),e}createStaticOptionContent(t,e=""){const n=document.createElement("span");n.classList.add(_t);const i=t.iconPath?document.createElement("img"):document.createElement("span");i.classList.add(Rt),t.iconClass&&i.classList.add(t.iconClass),t.iconPath?(i.src=t.iconPath,i.alt="",i.draggable=!1,i.loading="lazy"):(i.classList.add(je),i.innerText=t.iconText||"?");const s=document.createElement("span");s.classList.add(vt),s.innerText=t.label;const r=document.createElement("span");if(r.classList.add(Ue),r.appendChild(s),e){const a=document.createElement("span");a.classList.add(qe),a.innerText=e,r.appendChild(a)}return n.append(i,r),n}getChampionRecommendedPositions(t){return Array.isArray(t.recommendedPositions)?t.recommendedPositions:[]}async waitForRender(){for(let t=0;t<Ve;t++){const e=this.dropdownElement.shadowRoot;if(this.dropdownElement.isConnected&&(e!=null&&e.querySelector(c.dropdownCurrent)))return e;await v(Ye)}return null}ensureSearchPlaceholder(t){if(t.querySelector(`#${It}`))return;const e=t.querySelector(c.dropdownCurrent);e&&e.appendChild(this.createSearchPlaceholder())}ensurePositionFilter(t){var n;const e=t.querySelector(c.dropdownOptionsContainer);if(e){if(!this.hasRecommendedPositionData){(n=t.querySelector(`.${j}`))==null||n.remove(),e.classList.remove(dt),this.activePositionFilter=null;return}e.classList.add(dt),t.querySelector(`.${j}`)||e.insertBefore(this.createPositionFilter(),e.firstChild),this.syncPositionFilter(t)}}createPositionFilter(){const t=document.createElement("div");t.classList.add(j),t.setAttribute("role","toolbar"),t.setAttribute("aria-label","Filter champions by position");for(const e of x)t.appendChild(this.createPositionFilterBadge(e));return t}createPositionFilterBadge(t){const e=document.createElement("button");e.classList.add(R),e.type="button",e.dataset.position=t.value,e.title=t.label,e.setAttribute("aria-label",t.label),e.setAttribute("aria-pressed","false");const n=document.createElement("img");return n.src=t.iconPath,n.alt="",n.draggable=!1,e.appendChild(n),e.addEventListener("pointerdown",i=>{i.preventDefault(),i.stopPropagation()}),e.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),this.togglePositionFilter(t.value)}),e}createSearchPlaceholder(){const t=document.createElement("div");t.classList.add(se,ie),t.id=It;const e=document.createElement("input");e.classList.add(oe),e.id=Tt,e.type="text",e.placeholder=this.searchPlaceholderText,e.setAttribute("aria-label",this.searchPlaceholderText),e.size=Math.max(this.searchPlaceholderText.length,1);const n=document.createElement("span");return n.classList.add(re),n.addEventListener("click",()=>{n.classList.contains(N)&&this.clearSearch(e,n)}),e.addEventListener("input",i=>{this.ensureOpen(),this.setSearchQuery(i.target.value),n.classList.toggle(N,!!i.target.value)}),["pointerdown","click"].forEach(i=>{t.addEventListener(i,s=>s.stopPropagation()),n.addEventListener(i,s=>s.stopPropagation())}),["pointerdown","focusin"].forEach(i=>{e.addEventListener(i,s=>s.stopPropagation(),!0)}),t.appendChild(n),t.appendChild(e),t}togglePositionFilter(t){const e=F(t);e&&(this.activePositionFilter=this.activePositionFilter===e?null:e,this.withShadowRoot(n=>this.syncPositionFilter(n)),this.applyOptionFilters())}syncPositionFilter(t){t.querySelectorAll(`.${R}`).forEach(e=>{const n=e.dataset.position===this.activePositionFilter;e.classList.toggle(ht,n),e.setAttribute("aria-pressed",String(n))})}clearSearch(t,e){t.value="",this.setSearchQuery(""),e.classList.toggle(N,!1)}setSearchQuery(t){this.searchQuery=t,this.applyOptionFilters()}applyOptionFilters(){const t=this.searchQuery.toLowerCase();this.dropdownElement.querySelectorAll(c.dropdownOption).forEach(n=>{if(n===this.placeholderOption){this.hidePlaceholderOption();return}this.matchesSearchQuery(n,t)&&this.matchesPositionFilter(n)?n.style.display="":n.style.display="none"})}matchesSearchQuery(t,e){return(t.textContent??"").toLowerCase().includes(e)}matchesPositionFilter(t){var e;return this.staticOptionElements.has(t)||!this.activePositionFilter?!0:((e=this.recommendedPositionsByOption.get(t))==null?void 0:e.has(this.activePositionFilter))===!0}hidePlaceholderOption(){this.placeholderOption&&(this.placeholderOption.style.display="none")}reset(){var t;this.dropdownElement.querySelectorAll(c.dropdownOptionSelected).forEach(e=>{e.removeAttribute("selected")}),(t=this.placeholderOption)==null||t.setAttribute("selected","true"),this.withShadowRoot(e=>{var s;const n=e.querySelector(`#${Tt}`),i=e.querySelector(`.${N}`);n&&i?this.clearSearch(n,i):(n&&(n.value="",this.setSearchQuery("")),i&&i.classList.remove(N)),this.isOpen()&&((s=e.querySelector(c.dropdownCurrent))==null||s.click())})}isOpen(){return this.dropdownElement.classList.contains("active")}ensureOpen(){this.isOpen()||this.withShadowRoot(t=>{const e=t.querySelector(c.dropdownCurrent);e&&e.click()})}patchDropdownShadowDom(){this.withShadowRoot(t=>{this.ensureDropdownOpensUpward(t),this.injectDropdownSearchStyles(t),this.ensurePositionFilter(t)})}ensureDropdownOpensUpward(t){var e;(e=t.querySelector(c.dropdownRoot))==null||e.classList.add("opens-upward")}injectDropdownSearchStyles(t){const e=t.querySelector("style[data-controlado='dropdown-tags']");if(e){e.textContent=Lt;return}const n=document.createElement("style");n.dataset.controlado="dropdown-tags",n.textContent=Lt,t.appendChild(n)}withShadowRoot(t){const e=this.dropdownElement.shadowRoot;e&&t(e)}}const Xe=".champion-priority-selector__position-badge",Ke=".champion-priority-selector__position-option",tt=".champion-priority-selector__remove",et="✕",Mt="?",$="Random",k="Bravery",Qe="For Arena mode",kt="/fe/lol-champ-select/images/champion-grid/bravery-champion.png",Je="controlado-champion-option__icon--bravery",Ze="champion-priority-selector__icon--bravery",tn=0,Nt=1,U=8,h=Object.freeze({CHAMPION_ASSIGNED:"champion-assigned",RANDOM_ASSIGNED:"random-assigned",RANDOM_POOL:"random-pool"}),en=5,nn=150,on="cubic-bezier(0.2, 0, 0, 1)";class xt{constructor(t,e,n,i={}){this.element=this.createRootElement(),this.dropdownElement=this.createDropdownElement();const s=[];i.enableBraveryOption===!0&&s.push({value:_,label:k,description:Qe,iconPath:kt,iconClass:Je}),s.push({value:S,label:$,iconText:Mt}),this.championDropdown=new We(this.dropdownElement,t,l=>this.addPriorityOption(l),{searchPlaceholderText:i.searchPlaceholderText,staticOptions:s});const{scrollElement:r,trackElement:a}=this.createSelectedChampionsScroll();this.scrollElement=r,this.trackElement=a,this.enablePositionRestrictions=i.enablePositionRestrictions===!0,this.enableRandomPoolPositionFilters=i.enableRandomPoolPositionFilters===!0,this.enableRandomAssignedPositionRestrictions=i.enableRandomAssignedPositionRestrictions===!0,this.enableBraveryOption=i.enableBraveryOption===!0,this.enablePositionMenu=this.enablePositionRestrictions||this.enableRandomAssignedPositionRestrictions||this.enableRandomPoolPositionFilters,this.positionMenuElement=this.enablePositionMenu?this.createPositionMenu():null,this.positionMenuTarget=null,this.positionsByChampionId={},this.randomAssignedPositions=[],this.randomPoolPositions=[],this.emptyElement=this.createEmptyState(t),this.element.append(this.dropdownElement,this.scrollElement),this.positionMenuElement&&this.element.appendChild(this.positionMenuElement),this.config=null,this.configKey=e,this.loadChampions=n,this.champions=[],this.championById=new Map,this.selectedPriorityOptions=[],this.optionButtons=new Map,this.dragState=null,this.handleWindowPointerMove=l=>this.moveDrag(l),this.handleWindowPointerUp=l=>this.finishDrag(l),this.handleWindowPointerCancel=l=>this.cancelDrag(l),this.handlePositionMenuOutsidePointerDown=l=>this.closePositionMenuOnOutsidePointerDown(l),this.handlePositionMenuKeyDown=l=>this.closePositionMenuOnKeyDown(l),this.setupInFlight=null,this.setupPending=!1}createRootElement(){const t=document.createElement("div");return t.classList.add("champion-priority-selector"),t}createDropdownElement(){const t=document.createElement(A.dropdown);return t.classList.add("dropdown-champions-default","dropdown-drop-up"),t}createSelectedChampionsScroll(){const t=document.createElement(A.scrollable);t.classList.add("champion-priority-selector__scroll"),t.setAttribute("direction","horizontal"),t.setAttribute("overflow-masks","disabled"),t.setAttribute("side-scroll-wheel","true");const e=document.createElement("div");return e.classList.add("champion-priority-selector__track"),t.appendChild(e),{scrollElement:t,trackElement:e}}createEmptyState(t){const e=document.createElement("div");e.classList.add("champion-priority-selector__empty");const n=document.createElement("span");n.innerText="No champions";const i=document.createElement("span"),s=t.replace(/^Add\s+/i,"").toLowerCase();return i.innerText=`Use dropdown to add ${s} option`,e.append(n,i),e}createPositionMenu(){const t=document.createElement("div");t.classList.add("champion-priority-selector__position-menu"),t.hidden=!0;for(const e of x)t.appendChild(this.createPositionOption(e));return t}createPositionOption(t){const e=document.createElement("button");e.classList.add("champion-priority-selector__position-option"),e.type="button",e.dataset.position=t.value,e.title=t.label,e.setAttribute("aria-label",t.label),e.setAttribute("aria-pressed","false"),e.addEventListener("pointerdown",i=>i.stopPropagation()),e.addEventListener("click",i=>{i.stopPropagation(),this.togglePositionMenuPosition(t.value)});const n=document.createElement("img");return n.src=t.iconPath,n.alt=t.label,n.draggable=!1,e.appendChild(n),e}async setup(){return this.setupPending=!0,this.setupInFlight||(this.setupInFlight=this.runSetupLoop()),this.setupInFlight}refresh(){return this.setup()}async runSetupLoop(){try{for(;this.setupPending;)this.setupPending=!1,await this.performSetup()}finally{this.setupInFlight=null}}async performSetup(){this.champions=await this.loadChampions(),this.championById=new Map(this.champions.map(n=>[n.id,n]));const t=this.getAllowedChampionIds();this.config=Zt(this.configKey,{allowedChampionIds:t}),this.selectedPriorityOptions=pt(this.config.priorityOptions||this.config.champions,t).filter(n=>this.isPriorityOptionEnabled(n)),this.enablePositionRestrictions&&(this.positionsByChampionId=W(this.config.positionsByChampionId,H(this.selectedPriorityOptions))),this.enableRandomAssignedPositionRestrictions&&(this.randomAssignedPositions=O(this.config.randomAssignedPositions)),this.enableRandomPoolPositionFilters&&(this.randomPoolPositions=O(this.config.randomPoolPositions)),this.championDropdown.renderOptions(this.champions),this.renderSelectedPriorityOptions();const e=await this.championDropdown.waitForRender();e&&(this.championDropdown.ensureSearchPlaceholder(e),this.championDropdown.patchDropdownShadowDom())}getAllowedChampionIds(){return new Set(this.championById.keys())}isPriorityOptionEnabled(t){return!w(t)||this.enableBraveryOption}addPriorityOption(t){const e=L(t);e===null||this.selectedPriorityOptions.includes(e)||!this.isPriorityOptionEnabled(e)||!p(e)&&!w(e)&&!this.championById.has(e)||(this.selectedPriorityOptions.push(e),this.renderSelectedPriorityOptions(),this.saveConfig())}removePriorityOption(t){var s;const e=L(t),n=this.selectedPriorityOptions.indexOf(e);if(e===null||n===-1)return;this.selectedPriorityOptions.splice(n,1);const i=typeof e=="number"?e:null;((s=this.positionMenuTarget)==null?void 0:s.option)===e&&this.closePositionMenu(),this.enablePositionRestrictions&&i!==null&&delete this.positionsByChampionId[String(i)],this.enableRandomAssignedPositionRestrictions&&p(e)&&(this.randomAssignedPositions=[]),this.enableRandomPoolPositionFilters&&p(e)&&(this.randomPoolPositions=[]),this.renderSelectedPriorityOptions(),this.saveConfig()}movePriorityOptionToIndex(t,e){const n=L(t),i=this.selectedPriorityOptions.indexOf(n);if(n===null||i===-1)return!1;const[s]=this.selectedPriorityOptions.splice(i,1),r=Math.max(0,Math.min(e,this.selectedPriorityOptions.length));return this.selectedPriorityOptions.splice(r,0,s),i!==r}syncPositionsByChampionId(){this.enablePositionRestrictions&&(this.positionsByChampionId=W(this.positionsByChampionId,H(this.selectedPriorityOptions)))}syncRandomPoolPositions(){this.enableRandomPoolPositionFilters&&(this.randomPoolPositions=O(this.randomPoolPositions))}syncRandomAssignedPositions(){this.enableRandomAssignedPositionRestrictions&&(this.randomAssignedPositions=O(this.randomAssignedPositions))}saveConfig(){this.syncPositionsByChampionId(),this.syncRandomAssignedPositions(),this.syncRandomPoolPositions();const t=this.getAllowedChampionIds();this.config=B(this.configKey,e=>(e.priorityOptions=[...this.selectedPriorityOptions],e.champions=H(this.selectedPriorityOptions),this.enableRandomAssignedPositionRestrictions&&(e.randomAssignedPositions=[...this.randomAssignedPositions]),this.enableRandomPoolPositionFilters&&(e.randomPoolPositions=[...this.randomPoolPositions]),this.enablePositionRestrictions&&(e.positionsByChampionId={...this.positionsByChampionId}),e),{allowedChampionIds:t,selectedChampionIds:H(this.selectedPriorityOptions)}),this.enablePositionRestrictions&&(this.positionsByChampionId=this.config.positionsByChampionId||{}),this.enableRandomAssignedPositionRestrictions&&(this.randomAssignedPositions=this.config.randomAssignedPositions||[]),this.enableRandomPoolPositionFilters&&(this.randomPoolPositions=this.config.randomPoolPositions||[]),console.debug(this.configKey,this.config)}renderSelectedPriorityOptions(t=null,e=null){this.positionMenuTarget!==null&&this.closePositionMenu();const n=new Set(this.selectedPriorityOptions.map(s=>T(s)));for(const[s,r]of this.optionButtons)n.has(s)||(r.remove(),this.optionButtons.delete(s));if(this.selectedPriorityOptions.length===0){this.trackElement.replaceChildren(this.emptyElement);return}this.emptyElement.remove();const i=this.selectedPriorityOptions.map((s,r)=>this.getPriorityOptionButton(s,r)).filter(Boolean);this.trackElement.append(...i),t&&this.animateReorder(t,e)}getPriorityOptionButton(t,e){return p(t)?this.getRandomOptionButton(e):w(t)?this.enableBraveryOption?this.getBraveryOptionButton(e):null:this.getChampionOptionButton(t,e)}getChampionOptionButton(t,e){const n=this.championById.get(t);if(!n)return null;const i=String(t);let s=this.optionButtons.get(i);s||(s=this.createIconButton(n),this.optionButtons.set(i,s)),s.dataset.rank=String(e+1),s.classList.toggle("champion-priority-selector__icon--random",!1);const r=this.getChampionPositionTitleSuffix(t);s.title=`${e+1}. ${n.name}${r}`,s.setAttribute("aria-label",`${e+1}. ${n.name}${r}`);const a=s.querySelector("img");a.src=n.squarePortraitPath,a.alt=n.name;const l=s.querySelector(tt);return l.setAttribute("aria-label",`Remove ${n.name}`),l.title=`Remove ${n.name}`,this.renderPositionBadge(s,t),s}getRandomOptionButton(t){let e=this.optionButtons.get(S);e||(e=this.createRandomOptionButton(),this.optionButtons.set(S,e)),e.dataset.rank=String(t+1);const n=this.getRandomPositionTitleSuffix();e.title=`${t+1}. ${$}${n}`,e.setAttribute("aria-label",`${t+1}. ${$}${n}`);const i=e.querySelector(tt);return i.setAttribute("aria-label",`Remove ${$}`),i.title=`Remove ${$}`,this.renderPositionBadge(e,S),e}getBraveryOptionButton(t){let e=this.optionButtons.get(_);e||(e=this.createBraveryOptionButton(),this.optionButtons.set(_,e)),e.dataset.rank=String(t+1),e.title=`${t+1}. ${k}`,e.setAttribute("aria-label",`${t+1}. ${k}`);const n=e.querySelector("img");n.src=kt,n.alt=k;const i=e.querySelector(tt);return i.setAttribute("aria-label",`Remove ${k}`),i.title=`Remove ${k}`,e}createIconButton(t){const e=document.createElement("div");e.classList.add("champion-priority-selector__icon"),e.setAttribute("role","button"),e.tabIndex=0;const n=document.createElement("img");n.draggable=!1;const i=document.createElement("button");if(i.classList.add("champion-priority-selector__remove"),i.type="button",i.dataset.icon=et,i.addEventListener("pointerdown",s=>s.stopPropagation()),i.addEventListener("click",s=>{s.stopPropagation(),this.removePriorityOption(t.id)}),e.addEventListener("pointerdown",s=>this.startDrag(s,t.id)),e.addEventListener("auxclick",s=>this.removePriorityOptionOnMiddleClick(s,t.id)),this.enablePositionRestrictions){const s={option:t.id,kind:h.CHAMPION_ASSIGNED};e.addEventListener("contextmenu",r=>this.openPositionMenu(r,s))}return e.append(n,i),e}createRandomOptionButton(){const t=document.createElement("div");t.classList.add("champion-priority-selector__icon","champion-priority-selector__icon--random"),t.setAttribute("role","button"),t.tabIndex=0;const e=document.createElement("span");e.classList.add("champion-priority-selector__random-icon"),e.innerText=Mt;const n=document.createElement("button");if(n.classList.add("champion-priority-selector__remove"),n.type="button",n.dataset.icon=et,n.addEventListener("pointerdown",i=>i.stopPropagation()),n.addEventListener("click",i=>{i.stopPropagation(),this.removePriorityOption(S)}),t.addEventListener("pointerdown",i=>this.startDrag(i,S)),t.addEventListener("auxclick",i=>this.removePriorityOptionOnMiddleClick(i,S)),this.enableRandomPoolPositionFilters){const i={option:S,kind:h.RANDOM_POOL};t.addEventListener("contextmenu",s=>this.openPositionMenu(s,i))}return t.append(e,n),t}createBraveryOptionButton(){const t=document.createElement("div");t.classList.add("champion-priority-selector__icon",Ze),t.setAttribute("role","button"),t.tabIndex=0;const e=document.createElement("img");e.draggable=!1;const n=document.createElement("button");return n.classList.add("champion-priority-selector__remove"),n.type="button",n.dataset.icon=et,n.addEventListener("pointerdown",i=>i.stopPropagation()),n.addEventListener("click",i=>{i.stopPropagation(),this.removePriorityOption(_)}),t.addEventListener("pointerdown",i=>this.startDrag(i,_)),t.addEventListener("auxclick",i=>this.removePriorityOptionOnMiddleClick(i,_)),t.append(e,n),t}getChampionAllowedPositions(t){const e=u(t);return e===null?[]:this.positionsByChampionId[String(e)]||[]}getRandomPoolPositions(){return this.randomPoolPositions}getRandomAssignedPositions(){return this.randomAssignedPositions}getPositionLabels(t){return t.map(e=>{var n;return(n=Ct(e))==null?void 0:n.label}).filter(Boolean)}getChampionAllowedPositionLabels(t){return this.getPositionLabels(this.getChampionAllowedPositions(t))}getRandomPoolPositionLabels(){return this.getPositionLabels(this.getRandomPoolPositions())}getRandomAssignedPositionLabels(){return this.getPositionLabels(this.getRandomAssignedPositions())}getChampionPositionTitleSuffix(t){const e=this.getChampionAllowedPositionLabels(t);return e.length>0?` (${e.join(", ")})`:""}getRandomPositionTitleSuffix(){const t=[],e=this.getRandomAssignedPositionLabels(),n=this.getRandomPoolPositionLabels();return e.length>0&&t.push(`runs only when assigned lane matches ${this.formatPositionLabelsForSentence(e)}`),n.length>0&&t.push(`filters random pool to ${this.formatPositionLabelsForSentence(n)}`),t.length>0?` (${t.join("; ")})`:""}formatPositionLabelsForSentence(t){return t.length<=1?t[0]||"":t.length===2?`${t[0]} or ${t[1]}`:`${t.slice(0,-1).join(", ")}, or ${t[t.length-1]}`}renderPositionBadge(t,e){t.querySelectorAll(Xe).forEach(i=>i.remove());const n=L(e);if(n!==null)for(const i of this.getPositionBadgeTargetsForOption(n)){const s=this.createPositionBadge(i);s&&t.appendChild(s)}}getPositionBadgeTargetsForOption(t){return this.selectedPriorityOptions.includes(t)?p(t)?[{option:t,kind:h.RANDOM_ASSIGNED},{option:t,kind:h.RANDOM_POOL}].filter(e=>this.canOpenPositionMenuForTarget(e)):w(t)?[]:[{option:t,kind:h.CHAMPION_ASSIGNED}].filter(e=>this.canOpenPositionMenuForTarget(e)):[]}createPositionBadge(t){const e=this.getAllowedPositionsForPositionMenuTarget(t),n=this.getAllowedPositionLabelsForPositionMenuTarget(t),i=t.kind===h.RANDOM_POOL,s=document.createElement("button");if(s.classList.add("champion-priority-selector__position-badge"),s.classList.toggle("champion-priority-selector__position-badge--random",i),s.type="button",s.dataset.positionTarget=t.kind,s.title=this.getPositionBadgeTitle(n,t),s.setAttribute("aria-label",s.title),s.addEventListener("pointerdown",l=>l.stopPropagation()),s.addEventListener("click",l=>this.openPositionMenu(l,t,s)),i)return e.length>0?(s.classList.add("champion-priority-selector__position-badge--active"),s.dataset.count=String(e.length)):s.classList.add("champion-priority-selector__position-badge--empty"),s;if(e.length===0)return s.classList.add("champion-priority-selector__position-badge--empty"),s.innerText="+",s;const r=Ct(e[0]);if(!r)return null;e.length>1&&(s.dataset.count=String(e.length));const a=document.createElement("img");return a.src=r.iconPath,a.alt=r.label,a.draggable=!1,s.appendChild(a),s}getPositionBadgeTitle(t,e){return e.kind===h.RANDOM_ASSIGNED?t.length===0?"The plugin can use Random in any lane. Click to run it only in selected draft lanes.":`The plugin will use Random only when your assigned lane matches ${this.formatPositionLabelsForSentence(t)}. Draft modes only. Click to edit.`:e.kind===h.RANDOM_POOL?t.length===0?"The plugin can choose any available champion at random. Click to filter the pool first.":`The plugin filters Random to champions for ${this.formatPositionLabelsForSentence(t)}, then picks one. Click to edit.`:t.length>0?`The plugin will pick this champion only when your assigned lane matches ${this.formatPositionLabelsForSentence(t)}. Draft modes only. Click to edit.`:"The plugin can pick this champion in any lane. Click to limit it to selected draft lanes."}canOpenPositionMenuForTarget(t){if(!this.selectedPriorityOptions.includes(t.option))return!1;switch(t.kind){case h.CHAMPION_ASSIGNED:return typeof t.option=="number"&&this.enablePositionRestrictions;case h.RANDOM_ASSIGNED:return p(t.option)&&this.enableRandomAssignedPositionRestrictions;case h.RANDOM_POOL:return p(t.option)&&this.enableRandomPoolPositionFilters;default:return!1}}normalizePositionMenuTarget(t){if(!t||typeof t!="object"||Array.isArray(t)||!("option"in t)||!("kind"in t))return null;const e=L(t.option),n=e===null?null:{option:e,kind:String(t.kind)};return n&&this.canOpenPositionMenuForTarget(n)?n:null}getAllowedPositionsForPositionMenuTarget(t){switch(t.kind){case h.CHAMPION_ASSIGNED:return this.getChampionAllowedPositions(t.option);case h.RANDOM_ASSIGNED:return this.getRandomAssignedPositions();case h.RANDOM_POOL:return this.getRandomPoolPositions();default:return[]}}getAllowedPositionLabelsForPositionMenuTarget(t){return this.getPositionLabels(this.getAllowedPositionsForPositionMenuTarget(t))}setAllowedPositionsForPositionMenuTarget(t,e){switch(t.kind){case h.CHAMPION_ASSIGNED:{const n=String(t.option);e.length>0?this.positionsByChampionId[n]=e:delete this.positionsByChampionId[n];break}case h.RANDOM_ASSIGNED:this.randomAssignedPositions=e;break;case h.RANDOM_POOL:this.randomPoolPositions=e;break}}openPositionMenu(t,e,n=null){if(!this.positionMenuElement)return;const i=this.normalizePositionMenuTarget(e);if(i===null)return;t.preventDefault(),t.stopPropagation(),this.positionMenuTarget=i,this.renderPositionMenu(),this.positionMenuElement.hidden=!1,this.positionMenuElement.style.left="0px",this.positionMenuElement.style.top="0px";const{left:s,top:r}=this.getPositionMenuCoordinates(t,n);this.positionMenuElement.style.left=`${s}px`,this.positionMenuElement.style.top=`${r}px`,document.addEventListener("pointerdown",this.handlePositionMenuOutsidePointerDown,!0),document.addEventListener("keydown",this.handlePositionMenuKeyDown,!0)}getPositionMenuCoordinates(t,e=null){const n=this.positionMenuElement.getBoundingClientRect();let i=t.clientX,s=t.clientY;if(e&&t.type==="click"&&t.detail===0){const l=e.getBoundingClientRect();i=l.left+l.width/2,s=l.bottom}const r=Math.min(Math.max(i,U),window.innerWidth-n.width-U),a=Math.min(Math.max(s,U),window.innerHeight-n.height-U);return{left:r,top:a}}renderPositionMenu(){if(!this.positionMenuElement||this.positionMenuTarget===null)return;const t=new Set(this.getAllowedPositionsForPositionMenuTarget(this.positionMenuTarget));this.positionMenuElement.querySelectorAll(Ke).forEach(e=>{const n=t.has(e.dataset.position);e.classList.toggle("champion-priority-selector__position-option--selected",n),e.setAttribute("aria-pressed",String(n))})}togglePositionMenuPosition(t){if(!this.positionMenuElement||this.positionMenuTarget===null)return;const e=F(t);if(!e)return;const n=this.positionMenuTarget,i=n.option,s=new Set(this.getAllowedPositionsForPositionMenuTarget(n));s.has(e)?s.delete(e):s.add(e);const r=x.map(y=>y.value).filter(y=>s.has(y));this.setAllowedPositionsForPositionMenuTarget(n,r),this.renderPositionMenu();const a=T(i),l=a?this.optionButtons.get(a):null,d=this.selectedPriorityOptions.indexOf(i);l&&d!==-1&&(p(i)?this.getRandomOptionButton(d):this.getChampionOptionButton(i,d)),this.saveConfig()}closePositionMenuOnOutsidePointerDown(t){var e;(e=this.positionMenuElement)!=null&&e.contains(t.target)||this.closePositionMenu()}closePositionMenuOnKeyDown(t){t.key==="Escape"&&this.closePositionMenu()}closePositionMenu(){this.positionMenuElement&&(this.positionMenuElement.hidden=!0,this.positionMenuTarget=null,document.removeEventListener("pointerdown",this.handlePositionMenuOutsidePointerDown,!0),document.removeEventListener("keydown",this.handlePositionMenuKeyDown,!0))}startDrag(t,e){var s;if(t.button===Nt){t.preventDefault();return}if(t.button!==tn)return;this.dragState&&this.clearDragState();const n=T(e),i=n?this.optionButtons.get(n):null;if(i){this.dragState={option:e,pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,active:!1,moved:!1};try{(s=i.setPointerCapture)==null||s.call(i,t.pointerId)}catch{}window.addEventListener("pointermove",this.handleWindowPointerMove),window.addEventListener("pointerup",this.handleWindowPointerUp),window.addEventListener("pointercancel",this.handleWindowPointerCancel)}}removePriorityOptionOnMiddleClick(t,e){t.button===Nt&&(t.preventDefault(),t.stopPropagation(),this.removePriorityOption(e))}moveDrag(t){var y;if(!this.dragState||this.dragState.pointerId!==t.pointerId)return;const e=this.dragState.option,n=T(e),i=t.clientX-this.dragState.startX,s=t.clientY-this.dragState.startY,r=Math.hypot(i,s);if(!this.dragState.active){if(r<en)return;this.dragState.active=!0,n&&((y=this.optionButtons.get(n))==null||y.classList.add("champion-priority-selector__icon--dragging"))}t.preventDefault();const a=this.getDropIndex(t.clientX,e),l=this.selectedPriorityOptions.indexOf(e);if(a===l||a===-1)return;const d=this.getIconPositions();this.movePriorityOptionToIndex(e,a)&&(this.dragState.moved=!0,this.renderSelectedPriorityOptions(d,e))}finishDrag(t){if(!this.dragState||this.dragState.pointerId!==t.pointerId)return;const e=this.dragState.active,n=this.dragState.moved;this.clearDragState(),e&&n&&this.saveConfig()}cancelDrag(t){!this.dragState||this.dragState.pointerId!==t.pointerId||this.clearDragState()}clearDragState(){var s;if(!this.dragState)return;const{option:t,pointerId:e}=this.dragState,n=T(t),i=n?this.optionButtons.get(n):null;i==null||i.classList.remove("champion-priority-selector__icon--dragging");try{(s=i==null?void 0:i.releasePointerCapture)==null||s.call(i,e)}catch{}window.removeEventListener("pointermove",this.handleWindowPointerMove),window.removeEventListener("pointerup",this.handleWindowPointerUp),window.removeEventListener("pointercancel",this.handleWindowPointerCancel),this.dragState=null}getDropIndex(t,e){const n=this.selectedPriorityOptions.filter(i=>i!==e);for(let i=0;i<n.length;i++){const s=T(n[i]),r=s?this.optionButtons.get(s):null;if(!r)continue;const a=r.getBoundingClientRect();if(t<a.left+a.width/2)return i}return n.length}getIconPositions(){const t=new Map;for(const e of this.selectedPriorityOptions){const n=T(e),i=n?this.optionButtons.get(n):null;i&&t.set(n,i.getBoundingClientRect())}return t}animateReorder(t,e){for(const n of this.selectedPriorityOptions){if(n===e)continue;const i=T(n),s=i?this.optionButtons.get(i):null,r=i?t.get(i):null;if(!s||!r||typeof s.animate!="function")continue;const a=s.getBoundingClientRect(),l=r.left-a.left,d=r.top-a.top;l===0&&d===0||s.animate([{transform:`translate(${l}px, ${d}px)`},{transform:"translate(0, 0)"}],{duration:nn,easing:on})}}}const sn=200,nt="auto-select-champ-select-menu--collapsed",rn="auto-select-champ-select-menu-button-wrapper--open";class an{constructor(t,e,n){this.element=document.createElement("div"),this.element.classList.add("auto-select-champ-select-menu",nt),this.buttonWrapper=document.createElement("div"),this.buttonWrapper.classList.add("auto-select-champ-select-menu-button-wrapper"),this.headerElement=document.createElement("button"),this.headerElement.classList.add("auto-select-champ-select-menu__header"),this.headerElement.type="button",this.headerElement.setAttribute("aria-label",t),this.headerElement.setAttribute("aria-expanded","false"),this.headerElement.addEventListener("click",()=>this.toggle()),this.contentElement=document.createElement("div"),this.contentElement.classList.add("auto-select-champ-select-menu__content"),this.titleElement=document.createElement("div"),this.titleElement.classList.add("auto-select-champ-select-menu__title"),this.titleElement.textContent=t,this.titleAccessoryElement=null,this.buttonWrapper.append(this.headerElement,this.element),this.contentElement.appendChild(this.titleElement),this.element.appendChild(this.contentElement),this.returnControlsToSocialRoster=e,this.controlElements=n,this.boundCloseOnOutsideInteraction=i=>this.closeOnOutsideInteraction(i),this.buttonObserver=null,this.buttonMountFrame=null,this.buttonMountTask=null,this.hiddenStates=new WeakMap,this.mounted=!1}async mount(){return this.mounted?this.mountButton():(this.mounted=!0,this.controlElements.forEach(t=>{this.hiddenStates.set(t,t.classList.contains("hidden")),t.classList.remove("hidden"),this.contentElement.appendChild(t)}),this.observeButtonContainer(),document.addEventListener("pointerdown",this.boundCloseOnOutsideInteraction,!0),this.mountButton())}unmount(){return this.mounted?(this.mounted=!1,this.stopButtonMounting(),document.removeEventListener("pointerdown",this.boundCloseOnOutsideInteraction,!0),this.setOpen(!1),this.buttonWrapper.remove(),this.restoreHiddenStates(),this.returnControlsToSocialRoster()):this.returnControlsToSocialRoster()}stopButtonMounting(){var t;(t=this.buttonObserver)==null||t.disconnect(),this.buttonObserver=null,this.buttonMountFrame!==null&&(cancelAnimationFrame(this.buttonMountFrame),this.buttonMountFrame=null),this.buttonMountTask=null}restoreHiddenStates(){this.controlElements.forEach(t=>{t.classList.toggle("hidden",this.hiddenStates.get(t)===!0),this.hiddenStates.delete(t)})}isOpen(){return!this.element.classList.contains(nt)}setOpen(t){this.element.classList.toggle(nt,!t),this.buttonWrapper.classList.toggle(rn,t),this.headerElement.setAttribute("aria-expanded",String(t))}toggle(){this.setOpen(!this.isOpen())}closeOnOutsideInteraction(t){if(!this.isOpen())return;(typeof t.composedPath=="function"?t.composedPath():[]).includes(this.buttonWrapper)||this.buttonWrapper.contains(t.target)||this.setOpen(!1)}observeButtonContainer(){this.buttonObserver=new MutationObserver(()=>this.scheduleMountButton()),this.buttonObserver.observe(document.body,{childList:!0,subtree:!0})}scheduleMountButton(){this.buttonMountFrame===null&&(this.buttonMountFrame=requestAnimationFrame(()=>{this.buttonMountFrame=null,this.mountButton()}))}mountButton(){return this.buttonMountTask||(this.buttonMountTask=this.appendButtonToContainer().finally(()=>{this.buttonMountTask=null})),this.buttonMountTask}async appendButtonToContainer(){let t=ct();for(;this.mounted&&!t;)await v(sn),t=ct();if(!this.mounted||!t)return;const e=t.querySelector(c.firstChampSelectSquareButton);this.buttonWrapper.parentNode===t&&this.buttonWrapper.nextSibling===e||t.insertBefore(this.buttonWrapper,e)}setTitleAccessory(t){this.titleAccessoryElement=t,(!t.isConnected||t.parentNode!==this.titleElement)&&this.titleElement.appendChild(t)}}class ot{constructor(t,e){this.element=document.createElement(A.radioInputOption),this.element.classList.add("lol-settings-voice-input-mode-option","auto-select-checkbox"),this.element.innerText=t,this.config=null,this.configKey=e,this.setupComplete=!1}setup(){this.syncFromConfig(),this.setupComplete||(this.element.addEventListener("click",()=>this.toggle()),this.setupComplete=!0)}syncFromConfig(){this.config=Zt(this.configKey),this.element.toggleAttribute("selected",this.config.enabled===!0)}toggle(){return console.debug("auto-champion-select: Toggling",this.configKey),this.config=B(this.configKey,t=>(t.enabled=!t.enabled,t)),this.element.toggleAttribute("selected",this.config.enabled===!0),this.config.enabled}}const ln=224,cn="auto-select-settings-trigger",Dt="auto-select-settings-flyout",Ft="auto-select-settings-menu",dn="auto-select-settings-menu__empty",hn="auto-select-settings-checkbox",un="auto-select-settings-range",pn="auto-select-settings-range__header",mn="auto-select-settings-range__label",fn="auto-select-settings-range__value",gn="auto-select-settings-range__track",Pn="auto-select-settings-range__fill",yn="auto-select-settings-range__handle",Cn="auto-select-settings-range__handle--min",Sn="auto-select-settings-range__handle--max",q="auto-select-settings-range__handle--dragging";class An{constructor(t=[]){this.controls=t,this.triggerElements=new Set,this.flyoutElement=this.createFlyoutElement(),this.open=!1,this.activeTriggerElement=null,this.setupComplete=!1,this.boundCloseOnOutsideInteraction=e=>this.closeOnOutsideInteraction(e),this.boundCloseOnEscape=e=>this.closeOnEscape(e),this.boundPositionFlyout=()=>this.positionFlyout(),this.renderControls()}setup(){this.ensureFlyoutConnected(),this.controls.forEach(t=>{var e;return(e=t.setup)==null?void 0:e.call(t)}),this.sync(),!this.setupComplete&&(document.addEventListener("pointerdown",this.boundCloseOnOutsideInteraction,!0),document.addEventListener("keydown",this.boundCloseOnEscape,!0),window.addEventListener("resize",this.boundPositionFlyout),this.setupComplete=!0)}setControls(t){this.controls=t,this.renderControls(),this.setupComplete&&this.controls.forEach(e=>{var n;return(n=e.setup)==null?void 0:n.call(e)}),this.sync()}createTriggerElement(t="Auto champion select settings"){const e=document.createElement("button");return e.type="button",e.classList.add(cn),e.dataset.autoSelectSettings="trigger",e.setAttribute("aria-label",t),e.setAttribute("aria-expanded","false"),e.title=t,e.addEventListener("click",n=>{n.preventDefault(),n.stopImmediatePropagation(),n.stopPropagation(),this.toggleFlyout(e)},!0),this.triggerElements.add(e),e}createFlyoutElement(){const t=document.createElement("lol-uikit-flyout-frame");t.classList.add("flyout",Dt),t.dataset.autoSelectSettings="flyout",t.setAttribute("orientation","bottom"),t.setAttribute("animated","true"),t.setAttribute("caretless","true"),t.style.position="fixed",t.style.overflow="visible",t.style.display="none";const e=document.createElement("lc-flyout-content"),n=document.createElement("div");return n.classList.add("social-options-menu","active",Ft),e.appendChild(n),t.appendChild(e),t}renderControls(){const t=this.flyoutElement.querySelector(`.${Ft}`);if(t){if(t.replaceChildren(),this.controls.length===0){const e=document.createElement("div");e.classList.add(dn),e.textContent="No settings available",t.appendChild(e);return}t.append(...this.controls.map(e=>e.element))}}sync(){this.controls.forEach(t=>{var e;return(e=t.sync)==null?void 0:e.call(t)})}ensureFlyoutConnected(){document.querySelectorAll(`.${Dt}`).forEach(t=>{t!==this.flyoutElement&&t.remove()}),this.flyoutElement.isConnected||document.body.appendChild(this.flyoutElement)}isOpen(){return this.open&&this.flyoutElement.isConnected&&getComputedStyle(this.flyoutElement).display!=="none"}setOpen(t,e=this.activeTriggerElement){this.open=t,this.activeTriggerElement=t?e:null,this.ensureFlyoutConnected(),this.flyoutElement.style.display=t?"block":"none",this.flyoutElement.toggleAttribute("show",t),this.triggerElements.forEach(n=>{n.setAttribute("aria-expanded",String(t&&n===this.activeTriggerElement))}),t&&(this.sync(),this.positionFlyout())}toggleFlyout(t){const e=!this.isOpen()||this.activeTriggerElement!==t;this.setOpen(e,t)}positionFlyout(){if(!this.isOpen()||!this.activeTriggerElement)return;const t=this.activeTriggerElement.getBoundingClientRect(),e=Math.min(ln,window.innerWidth-16);this.flyoutElement.style.width=`${e}px`;const n=this.flyoutElement.getBoundingClientRect(),i=t.right-e+4,s=Math.max(8,Math.min(window.innerWidth-e-8,i)),r=t.bottom+4,a=r+n.height<=window.innerHeight-8?r:Math.max(8,t.top-n.height-4);this.flyoutElement.style.left=`${Math.round(s)}px`,this.flyoutElement.style.top=`${Math.round(a)}px`}closeOnOutsideInteraction(t){if(!this.isOpen())return;const e=typeof t.composedPath=="function"?t.composedPath():[],n=[...this.triggerElements].some(s=>e.includes(s)),i=e.includes(this.flyoutElement);!n&&!i&&this.setOpen(!1)}closeOnEscape(t){t.key==="Escape"&&this.isOpen()&&this.setOpen(!1)}}class it{constructor(t,e){this.label=t,this.options=e,this.element=document.createElement(A.radioInputOption),this.element.classList.add("lol-settings-voice-input-mode-option",hn),this.element.textContent=t,this.element.title=t,this.setupComplete=!1}setup(){this.sync(),!this.setupComplete&&(this.element.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.options.toggle(),this.sync()}),this.setupComplete=!0)}sync(){this.element.toggleAttribute("selected",this.options.isSelected()===!0)}}class En{constructor(t,e){this.label=t,this.options=e,this.dragHandle=null,this.dragStartedCollapsed=!1,this.setupComplete=!1,this.boundPointerMove=i=>this.onPointerMove(i),this.boundPointerUp=()=>this.stopDragging(),this.element=document.createElement("div"),this.element.classList.add(un);const n=document.createElement("div");n.classList.add(pn),this.labelElement=document.createElement("span"),this.labelElement.classList.add(mn),this.labelElement.textContent=t,this.valueElement=document.createElement("span"),this.valueElement.classList.add(fn),this.trackElement=document.createElement("div"),this.trackElement.classList.add(gn),this.fillElement=document.createElement("div"),this.fillElement.classList.add(Pn),this.minHandleElement=this.createHandle("min"),this.maxHandleElement=this.createHandle("max"),n.append(this.labelElement,this.valueElement),this.trackElement.append(this.fillElement,this.minHandleElement,this.maxHandleElement),this.element.append(n,this.trackElement)}setup(){this.sync(),!this.setupComplete&&(this.trackElement.addEventListener("pointerdown",t=>this.onTrackPointerDown(t)),this.minHandleElement.addEventListener("pointerdown",t=>this.startDragging(t,"min")),this.maxHandleElement.addEventListener("pointerdown",t=>this.startDragging(t,"max")),this.minHandleElement.addEventListener("keydown",t=>this.onHandleKeyDown(t,"min")),this.maxHandleElement.addEventListener("keydown",t=>this.onHandleKeyDown(t,"max")),this.setupComplete=!0)}createHandle(t){const e=document.createElement("button");return e.type="button",e.classList.add(yn,t==="min"?Cn:Sn),e.setAttribute("aria-label",`${this.label} ${t}`),e.setAttribute("aria-valuemin",String(this.options.min)),e.setAttribute("aria-valuemax",String(this.options.max)),e.setAttribute("role","slider"),e}getNormalizedValue(){const t=this.options.getValue(),e=this.snapValue(t.min),n=this.snapValue(t.max);return{min:Math.min(e,n),max:Math.max(e,n)}}snapValue(t){const e=this.options.min,n=this.options.max,i=this.options.step,s=Number(t),r=Number.isFinite(s)?s:e,a=Math.round((r-e)/i)*i+e;return Math.max(e,Math.min(n,a))}sync(){const t=this.getNormalizedValue(),e=this.valueToPercent(t.min),n=this.valueToPercent(t.max);this.valueElement.textContent=this.options.formatValue(t),this.fillElement.style.left=`${e}%`,this.fillElement.style.width=`${n-e}%`,this.minHandleElement.style.left=`${e}%`,this.maxHandleElement.style.left=`${n}%`,this.syncHandle(this.minHandleElement,t.min),this.syncHandle(this.maxHandleElement,t.max)}syncHandle(t,e){t.setAttribute("aria-valuenow",String(e)),t.setAttribute("aria-valuetext",this.options.formatValue({min:e,max:e}))}valueToPercent(t){const e=this.options.max-this.options.min;return e<=0?0:(t-this.options.min)/e*100}clientXToValue(t){const e=this.trackElement.getBoundingClientRect(),n=e.width<=0?0:(t-e.left)/e.width;return this.snapValue(this.options.min+(this.options.max-this.options.min)*n)}onTrackPointerDown(t){if(t.target===this.minHandleElement||t.target===this.maxHandleElement)return;const e=this.clientXToValue(t.clientX),n=this.getNormalizedValue(),i=Math.abs(e-n.min)<=Math.abs(e-n.max)?"min":"max";this.startDragging(t,i),this.setHandleValue(i,e)}startDragging(t,e){t.preventDefault(),t.stopPropagation(),this.dragHandle=e;const n=this.getNormalizedValue();this.dragStartedCollapsed=n.min===n.max,this.syncDraggingHandle(),document.addEventListener("pointermove",this.boundPointerMove,!0),document.addEventListener("pointerup",this.boundPointerUp,!0)}onPointerMove(t){if(!this.dragHandle)return;t.preventDefault();const e=this.clientXToValue(t.clientX),n=this.resolveDragHandleForValue(e);this.dragHandle=n,this.syncDraggingHandle(),this.setHandleValue(n,e)}stopDragging(){this.clearDraggingHandle(),this.dragHandle=null,this.dragStartedCollapsed=!1,document.removeEventListener("pointermove",this.boundPointerMove,!0),document.removeEventListener("pointerup",this.boundPointerUp,!0)}syncDraggingHandle(){this.minHandleElement.classList.toggle(q,this.dragHandle==="min"),this.maxHandleElement.classList.toggle(q,this.dragHandle==="max")}clearDraggingHandle(){this.minHandleElement.classList.remove(q),this.maxHandleElement.classList.remove(q)}onHandleKeyDown(t,e){const n=this.getNormalizedValue();let s=e==="min"?n.min:n.max;if(t.key==="ArrowLeft"||t.key==="ArrowDown")s-=this.options.step;else if(t.key==="ArrowRight"||t.key==="ArrowUp")s+=this.options.step;else if(t.key==="Home")s=this.options.min;else if(t.key==="End")s=this.options.max;else return;t.preventDefault(),this.setHandleValue(e,s)}resolveDragHandleForValue(t){if(!this.dragHandle)return"min";if(!this.dragStartedCollapsed)return this.dragHandle;const e=this.getNormalizedValue();return t<e.min?"min":t>e.max?"max":this.dragHandle}setHandleValue(t,e){const n=this.getNormalizedValue(),i=this.snapValue(e),s=t==="min"?{min:Math.min(i,n.max),max:n.max}:{min:n.min,max:Math.max(i,n.min)};this.options.setValue(s),this.sync()}}const bn="auto-select-social-roster-section",Bt="auto-select-social-roster-section__header";class On{constructor(t,...e){this.element=document.createElement(A.socialRosterGroup),this.element.classList.add(bn),this.element.addEventListener("post-render",()=>this.onPostRender()),this.element.addEventListener("click",()=>this.onClick()),this.label=t,this.collapsibleElements=e,this.headerAccessoryElement=null,this.waitRender()}waitRender(){new MutationObserver((t,e)=>{if(this.element.querySelector(c.socialRosterGroupLabel)){const n=new Event("post-render");this.element.dispatchEvent(n),e.disconnect()}}).observe(this.element,{childList:!0})}onPostRender(){this.element.querySelector(c.socialRosterGroupLabel).innerText=this.label;const t=this.element.querySelector(c.socialRosterGroupHeader);t==null||t.removeAttribute("draggable"),t&&this.headerAccessoryElement&&(t.classList.add(Bt),t.appendChild(this.headerAccessoryElement))}setHeaderAccessory(t){this.headerAccessoryElement=t;const e=this.element.querySelector(c.socialRosterGroupHeader);e&&(e.classList.add(Bt),e.appendChild(t))}onClick(){var t;this.collapsibleElements.forEach(e=>{e.closest(".auto-select-champ-select-menu")||e.classList.toggle("hidden")}),(t=this.element.querySelector(c.socialRosterGroupArrow))==null||t.toggleAttribute("open")}}function ae(o){var t,e;o&&((e=(t=globalThis.Toast)==null?void 0:t.success)==null||e.call(t,o))}function ut(o){var t,e;o&&((e=(t=globalThis.Toast)==null?void 0:t.error)==null||e.call(t,o))}function wn(o,t){const e=globalThis.Toast;return typeof(e==null?void 0:e.promise)=="function"?e.promise(o,t):o}const D="Balaclava: Auto Champion Select";function In(o){return typeof(o==null?void 0:o.then)=="function"}class Pt{constructor({id:t,name:e,legend:n,tags:i,group:s,callback:r,toasts:a}){this.id=t,this.name=e,this.legend=n,this.tags=i,this.group=s,this.perform=this.perform.bind(this),this.callback=r,this.toasts=a}perform(){try{const t=this.callback();if(In(t))return wn(t,{loading:this.toasts.loading,success:this.toasts.success,error:this.toasts.error});const e=this.toasts.success||(t?this.toasts.on:this.toasts.off);ae(e)}catch(t){ut(this.toasts.error),console.error(t)}}}class le extends Pt{constructor(t,e,n){super({id:`${e}Switch`,name:()=>`Auto ${t} [${P(e).enabled?"ON":"OFF"}]`,legend:()=>P(e).enabled?"Turn OFF":"Turn ON",tags:[D,e,"switch"],group:D,callback:n,toasts:{on:`Auto ${t} is ON!`,off:`Auto ${t} is OFF!`,error:`Failed to toggle Auto ${t}. Check console.`}})}}function Tn(o){return B(o,e=>(e.force=!e.force,e)).force}class ce extends Pt{constructor(t,e){const n=e==="controladoPick",i=`Ignore Team Intent ${t}`;super({id:`${e}ForceSwitch`,name:()=>`${i} [${P(e).force?"ON":"OFF"}]`,legend:()=>n?"Pick champions even when a teammate shows the same intent":"Ban champions even when an ally shows the same intent",tags:[D,e,"force","intent","switch"],group:D,callback:()=>Tn(e),toasts:{on:`${i} is ON!`,off:`${i} is OFF!`,error:`Failed to toggle ${i}. Check console.`}})}}class _n extends Pt{constructor(t){super({id:"RefreshDropdowns",name:()=>"Refresh Champions",legend:()=>"Normally champion selectors refresh automatically...",tags:[D,"refresh"],group:D,callback:t,toasts:{success:"Refreshed Champions!",error:"Failed to refresh Champions. Check console."}})}}class Rn extends le{constructor(t){super("Pick","controladoPick",t)}}class vn extends le{constructor(t){super("Ban","controladoBan",t)}}class Ln extends ce{constructor(){super("Pick","controladoPick")}}class Mn extends ce{constructor(){super("Ban","controladoBan")}}function kn(o){for(const t of o)CommandBar.addAction(t)}const Nn=200,xn=6e4,$t=2e3,Dn=".ready-check-root-element",Fn="#lol-uikit-layer-manager-wrapper > .modal",Bn="Accepted ready check!",Ht="Failed to accept ready check. Check console.",$n=".auto-select-champ-select-menu__header",m=Object.freeze({autoAccept:"controladoAutoAccept",actionDelay:"controladoActionDelay",pick:"controladoPick",ban:"controladoBan"});function Hn(){return P(m.autoAccept).enabled===!0}function de(){return P(m.autoAccept).hideAutoAcceptPrompt===!0}function Gn(){const o=P(m.autoAccept);return o.enabled===!0&&o.hideAutoAcceptPrompt===!0}function zn(){const o=de();B(m.autoAccept,t=>(t.hideAutoAcceptPrompt=!o,t))}function he(o){return o==="pick"?m.pick:m.ban}function Gt(o){return P(he(o)).force===!0}function zt(o){B(he(o),t=>(t.force=t.force!==!0,t))}function Vn(){const o=P(m.actionDelay),{minMs:t,maxMs:e}=G(o.minMs,o.maxMs);return{min:t,max:e}}function Yn(o){const{minMs:t,maxMs:e}=G(o.min,o.max);B(m.actionDelay,n=>(n.minMs=t,n.maxMs=e,n))}function Un(o){const{minMs:t,maxMs:e}=G(o.min,o.max);return t===0&&e===0?"Instant":t===e?`Delays actions for ${V(e)}`:t===0?`Delays actions up to ${V(e)}`:`Delays actions ${V(t)}-${V(e)}`}class qn{constructor(t){this.isEnabled=t,this.observer=null,this.hiddenModal=null,this.hiddenModalStyles=new WeakMap,this.sync=this.sync.bind(this)}start(){this.observer||(this.observer=new MutationObserver(()=>this.sync()),this.observer.observe(document.body,{childList:!0,subtree:!0}),this.sync())}sync(){const t=jn();if(!t){this.restore();return}if(!this.isEnabled()){this.restore();return}this.hide(t)}hide(t){this.hiddenModal!==t&&(this.restore(),this.hiddenModal=t,this.hiddenModalStyles.set(t,{display:t.style.getPropertyValue("display"),displayPriority:t.style.getPropertyPriority("display"),pointerEvents:t.style.getPropertyValue("pointer-events"),pointerEventsPriority:t.style.getPropertyPriority("pointer-events")}),t.style.setProperty("display","none","important"),t.style.setProperty("pointer-events","none","important"))}restore(){if(!this.hiddenModal)return;const t=this.hiddenModal,e=this.hiddenModalStyles.get(t);Vt(t,"display",e==null?void 0:e.display,e==null?void 0:e.displayPriority),Vt(t,"pointer-events",e==null?void 0:e.pointerEvents,e==null?void 0:e.pointerEventsPriority),this.hiddenModalStyles.delete(t),this.hiddenModal=null}}function jn(){const o=document.querySelector(Dn);return(o==null?void 0:o.closest(Fn))||null}function Vt(o,t,e,n){e?o.style.setProperty(t,e,n||""):o.style.removeProperty(t)}async function Wn(o){function t(){return Hn()?!1:(o.restore(),!0)}if(t()||(console.debug(`auto-champion-select(auto-accept): Ready check detected, accepting in ${$t}ms...`),await v($t),t()))return;let e=!1;try{e=await Xn()}catch(n){throw o.restore(),ut(Ht),n}e?ae(Bn):(o.restore(),ut(Ht))}async function Xn(){const o=await I("POST",f.readyCheckAccept);return o.ok?(console.debug("auto-champion-select(auto-accept): Accepted ready check"),!0):(console.error("auto-champion-select(auto-accept): Failed to accept ready check",o),!1)}async function Kn(o){const t=await I("GET",f.gameflowPhase),e=t.ok?await t.json():null;o.handleGameflowPhase(e)}function Qn({championSelect:o,champSelectControlsMenu:t,readyCheckModalSuppressor:e,setupChampionSelectors:n}){let i=0;return async function(l){const d=++i;try{await s(l,d)}catch(y){console.error("auto-champion-select: Failed to handle gameflow phase",y)}};async function s(a,l){a==="ReadyCheck"?Wn(e).catch(d=>{console.error("auto-champion-select(auto-accept): Failed to handle ready check",d)}):e.restore(),await r(a),l===i&&await n()}async function r(a){a==="ChampSelect"?(o.mount(),await t.mount()):(o.unmount(),await t.unmount())}}function Jn(){const o=new ze,t=new ot("Accept",m.autoAccept),e=new ot("Pick",m.pick),n=new xt("Add pick",m.pick,Fe,{enablePositionRestrictions:!0,enableRandomAssignedPositionRestrictions:!0,enableBraveryOption:!0,enableRandomPoolPositionFilters:!0}),i=new ot("Ban",m.ban),s=new xt("Add ban",m.ban,ee,{enableRandomPoolPositionFilters:!0}),r=to(n,s),a=eo(t,e,i),l=new An,d=new On("Auto champion select",r,a);return d.setHeaderAccessory(l.createTriggerElement()),{championSelect:o,autoAcceptToggle:t,pickToggle:e,banToggle:i,pickChampionSelector:n,banChampionSelector:s,selectorsContainer:r,checkboxesContainer:a,pluginSection:d,settingsMenu:l,championSelectors:[n,s]}}function Zn(o){return[new En("Action delay",{min:qt,max:jt,step:st,getValue:Vn,setValue:Yn,formatValue:Un}),new it("Ignore team intent and pick",{isSelected:()=>Gt("pick"),toggle:()=>zt("pick")}),new it("Ignore team intent and ban",{isSelected:()=>Gt("ban"),toggle:()=>zt("ban")}),new it("Hide auto-accept prompt",{isSelected:()=>de(),toggle:()=>{zn(),o.sync()}})]}function to(...o){const t=document.createElement("div");return t.append(...o.map(e=>e.element)),t}function eo(...o){const t=document.createElement("div");return t.classList.add("auto-select-checkboxes-div"),t.append(...o.map(e=>e.element)),t}function no({pluginSection:o,checkboxesContainer:t,selectorsContainer:e}){let n=null,i=0,s=()=>!1;async function r(a){let l=wt();for(;!l;){if(s()||a!==i)return;await v(Nn),l=wt()}s()||a!==i||l.append(o.element,t,e)}return{setIsChampSelectControlsMounted(a){s=a},returnControlsToSocialRoster(){if(n)return n;const a=++i;return n=r(a).catch(l=>console.error("auto-champion-select: Failed to return controls to social roster",l)).finally(()=>{n=null}),n}}}function oo({autoAcceptToggle:o,pickToggle:t,banToggle:e,readyCheckModalSuppressor:n}){o.setup(),o.element.addEventListener("click",()=>n.sync()),t.setup(),e.setup()}async function io(o){await Promise.all(o.map(t=>t.setup()))}async function so(o){await Promise.all(o.map(t=>t.refresh()))}function ro(){const o=Jn(),t=new qn(Gn);o.settingsMenu.setControls(Zn(t));const e=no(o),n=new an("Auto Champion Select",e.returnControlsToSocialRoster,[o.checkboxesContainer,o.selectorsContainer]);n.setTitleAccessory(o.settingsMenu.createTriggerElement()),e.setIsChampSelectControlsMounted(()=>n.mounted);const i={...o,champSelectControlsMenu:n,readyCheckModalSuppressor:t,setupToggles:()=>oo({...o,readyCheckModalSuppressor:t}),setupSettingsMenu:()=>o.settingsMenu.setup(),setupChampionSelectors:()=>io(o.championSelectors),refreshChampionSelectors:()=>so(o.championSelectors),refreshPickChampionSelector:async()=>{await o.pickChampionSelector.refresh()}};return i.handleGameflowPhase=Qn(i),i}function ao(o){yt(f.gameflowPhase,t=>{o.handleGameflowPhase(t.data)}),yt(f.wallet,async t=>{if(t.eventType==="Update"){console.debug("auto-champion-select(wallet): Refreshing champion selectors...");try{await o.refreshPickChampionSelector()}catch(e){console.error("auto-champion-select(wallet): Failed to refresh champion selectors",e)}}})}function lo({pickToggle:o,banToggle:t,refreshChampionSelectors:e}){kn([new Rn(()=>o.toggle()),new vn(()=>t.toggle()),new Ln,new Mn,new _n(e)])}function co(o){let t=null,e=null;function n(){e==null||e.disconnect(),e=null,t!==null&&(cancelAnimationFrame(t),t=null)}const i=setTimeout(()=>{n()},xn);function s(){if(!(ct()!==null))return;clearTimeout(i),n(),document.querySelector($n)!==null||o.handleGameflowPhase("ChampSelect")}e=new MutationObserver(()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,s()}))}),e.observe(document.body,{childList:!0,subtree:!0}),s()}async function ho(){const o=ro();o.setupToggles(),o.setupSettingsMenu(),o.readyCheckModalSuppressor.start(),lo(o),ao(o),await Kn(o),co(o),console.debug(`auto-champion-select(${ue}): Report bugs to Balaclava#1912`)}let Yt=!1;function Ut(){Yt||(Yt=!0,ho().catch(o=>console.error("auto-champion-select: Failed to initialize",o)))}document.readyState==="loading"?window.addEventListener("load",Ut,{once:!0}):Ut();export{Ut as load};
|
|
192
|
+
`;function tt(o){const t=document.createElement(O.dropdownOption);return t.setAttribute("slot",O.dropdownOption),t.innerText=o,t}class Do{constructor(t,e,n,i={}){this.dropdownElement=t,this.placeholderText=e,this.searchPlaceholderText=i.searchPlaceholderText||l("selectors.search"),this.staticOptions=Array.isArray(i.staticOptions)?i.staticOptions:[],this.onPriorityOptionSelected=n,this.placeholderOption=null,this.searchQuery="",this.activePositionFilter=null,this.hasRecommendedPositionData=!1,this.recommendedPositionsByOption=new WeakMap,this.staticOptionElements=new WeakSet}renderOptions(t){this.dropdownElement.replaceChildren(),this.hasRecommendedPositionData=!1,this.staticOptionElements=new WeakSet,this.placeholderOption=tt(this.placeholderText),this.placeholderOption.setAttribute("selected","true"),this.hidePlaceholderOption(),this.dropdownElement.appendChild(this.placeholderOption);for(const e of this.staticOptions)this.dropdownElement.appendChild(this.createStaticOption(e));for(const e of t){const n=this.getChampionRecommendedPositions(e),i=this.createChampionOption(e,n);n.length>0&&(this.hasRecommendedPositionData=!0),this.dropdownElement.appendChild(i)}this.hasRecommendedPositionData||(this.activePositionFilter=null),this.applyOptionFilters()}createChampionOption(t,e){const n=tt("");return this.recommendedPositionsByOption.set(n,new Set(e)),n.title=t.name,n.appendChild(this.createChampionOptionContent(t)),n.addEventListener("click",()=>{this.onPriorityOptionSelected(t.id),requestAnimationFrame(()=>this.reset())}),n}createStaticOption(t){const e=tt(""),n=typeof t.description=="string"?t.description:"";return this.staticOptionElements.add(e),e.title=n?`${t.label}. ${n}`:t.label,e.appendChild(this.createStaticOptionContent(t,n)),e.addEventListener("click",()=>{this.onPriorityOptionSelected(t.value),requestAnimationFrame(()=>this.reset())}),e}createChampionOptionContent(t){const e=document.createElement("span");e.classList.add(Mt);const n=document.createElement("img");n.classList.add(Nt),n.src=t.squarePortraitPath,n.alt="",n.draggable=!1,n.loading="lazy";const i=document.createElement("span");return i.classList.add(Bt),i.innerText=t.name,e.append(n,i),e}createStaticOptionContent(t,e=""){const n=document.createElement("span");n.classList.add(Mt);const i=t.iconPath?document.createElement("img"):document.createElement("span");i.classList.add(Nt),t.iconClass&&i.classList.add(t.iconClass),t.iconPath?(i.src=t.iconPath,i.alt="",i.draggable=!1,i.loading="lazy"):(i.classList.add(Bo),i.innerText=t.iconText||"?");const s=document.createElement("span");s.classList.add(Bt),s.innerText=t.label;const a=document.createElement("span");if(a.classList.add(Mo),a.appendChild(s),e){const r=document.createElement("span");r.classList.add(No),r.innerText=e,a.appendChild(r)}return n.append(i,a),n}getChampionRecommendedPositions(t){return Array.isArray(t.recommendedPositions)?t.recommendedPositions:[]}async waitForRender(){for(let t=0;t<vo;t++){const e=this.dropdownElement.shadowRoot;if(this.dropdownElement.isConnected&&(e!=null&&e.querySelector(d.dropdownCurrent)))return e;await v(Ro)}return null}ensureSearchPlaceholder(t){if(t.querySelector(`#${vt}`))return;const e=t.querySelector(d.dropdownCurrent);e&&e.appendChild(this.createSearchPlaceholder())}ensurePositionFilter(t){var n;const e=t.querySelector(d.dropdownOptionsContainer);if(e){if(!this.hasRecommendedPositionData){(n=t.querySelector(`.${q}`))==null||n.remove(),e.classList.remove(ht),this.activePositionFilter=null;return}e.classList.add(ht),t.querySelector(`.${q}`)||e.insertBefore(this.createPositionFilter(),e.firstChild),this.syncPositionFilter(t)}}createPositionFilter(){const t=document.createElement("div");t.classList.add(q),t.setAttribute("role","toolbar"),t.setAttribute("aria-label",l("selectors.positionFilterLabel"));for(const e of D)t.appendChild(this.createPositionFilterBadge(e));return t}createPositionFilterBadge(t){const e=X(t),n=document.createElement("button");n.classList.add(_),n.type="button",n.dataset.position=t.value,n.title=e,n.setAttribute("aria-label",e),n.setAttribute("aria-pressed","false");const i=document.createElement("img");return i.src=t.iconPath,i.alt="",i.draggable=!1,n.appendChild(i),n.addEventListener("pointerdown",s=>{s.preventDefault(),s.stopPropagation()}),n.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),this.togglePositionFilter(t.value)}),n}createSearchPlaceholder(){const t=document.createElement("div");t.classList.add(ge,me),t.id=vt;const e=document.createElement("input");e.classList.add(pe),e.id=Rt,e.type="text",e.placeholder=this.searchPlaceholderText,e.setAttribute("aria-label",this.searchPlaceholderText),e.size=Math.max(this.searchPlaceholderText.length,1);const n=document.createElement("span");return n.classList.add(fe),n.addEventListener("click",()=>{n.classList.contains(B)&&this.clearSearch(e,n)}),e.addEventListener("input",i=>{this.ensureOpen(),this.setSearchQuery(i.target.value),n.classList.toggle(B,!!i.target.value)}),["pointerdown","click"].forEach(i=>{t.addEventListener(i,s=>s.stopPropagation()),n.addEventListener(i,s=>s.stopPropagation())}),["pointerdown","focusin"].forEach(i=>{e.addEventListener(i,s=>s.stopPropagation(),!0)}),t.appendChild(n),t.appendChild(e),t}togglePositionFilter(t){const e=x(t);e&&(this.activePositionFilter=this.activePositionFilter===e?null:e,this.withShadowRoot(n=>this.syncPositionFilter(n)),this.applyOptionFilters())}syncPositionFilter(t){t.querySelectorAll(`.${_}`).forEach(e=>{const n=e.dataset.position===this.activePositionFilter;e.classList.toggle(ut,n),e.setAttribute("aria-pressed",String(n))})}clearSearch(t,e){t.value="",this.setSearchQuery(""),e.classList.toggle(B,!1)}setSearchQuery(t){this.searchQuery=t,this.applyOptionFilters()}applyOptionFilters(){const t=this.searchQuery.toLowerCase();this.dropdownElement.querySelectorAll(d.dropdownOption).forEach(n=>{if(n===this.placeholderOption){this.hidePlaceholderOption();return}this.matchesSearchQuery(n,t)&&this.matchesPositionFilter(n)?n.style.display="":n.style.display="none"})}matchesSearchQuery(t,e){return(t.textContent??"").toLowerCase().includes(e)}matchesPositionFilter(t){var e;return this.staticOptionElements.has(t)||!this.activePositionFilter?!0:((e=this.recommendedPositionsByOption.get(t))==null?void 0:e.has(this.activePositionFilter))===!0}hidePlaceholderOption(){this.placeholderOption&&(this.placeholderOption.style.display="none")}reset(){var t;this.dropdownElement.querySelectorAll(d.dropdownOptionSelected).forEach(e=>{e.removeAttribute("selected")}),(t=this.placeholderOption)==null||t.setAttribute("selected","true"),this.withShadowRoot(e=>{var s;const n=e.querySelector(`#${Rt}`),i=e.querySelector(`.${B}`);n&&i?this.clearSearch(n,i):(n&&(n.value="",this.setSearchQuery("")),i&&i.classList.remove(B)),this.isOpen()&&((s=e.querySelector(d.dropdownCurrent))==null||s.click())})}isOpen(){return this.dropdownElement.classList.contains("active")}ensureOpen(){this.isOpen()||this.withShadowRoot(t=>{const e=t.querySelector(d.dropdownCurrent);e&&e.click()})}patchDropdownShadowDom(){this.withShadowRoot(t=>{this.ensureDropdownOpensUpward(t),this.injectDropdownSearchStyles(t),this.ensurePositionFilter(t)})}ensureDropdownOpensUpward(t){var e;(e=t.querySelector(d.dropdownRoot))==null||e.classList.add("opens-upward")}injectDropdownSearchStyles(t){const e=t.querySelector("style[data-controlado='dropdown-tags']");if(e){e.textContent=Dt;return}const n=document.createElement("style");n.dataset.controlado="dropdown-tags",n.textContent=Dt,t.appendChild(n)}withShadowRoot(t){const e=this.dropdownElement.shadowRoot;e&&t(e)}}const xo=".champion-priority-selector__position-badge",Fo=".champion-priority-selector__position-option",et=".champion-priority-selector__remove",nt="✕",xt="?",Ft="/fe/lol-champ-select/images/champion-grid/bravery-champion.png",$o="controlado-champion-option__icon--bravery",Ho="champion-priority-selector__icon--bravery",zo=0,$t=1,G=8,u=Object.freeze({CHAMPION_ASSIGNED:"champion-assigned",RANDOM_ASSIGNED:"random-assigned",RANDOM_POOL:"random-pool"}),Vo=5,Go=150,Uo="cubic-bezier(0.2, 0, 0, 1)";function Ht(){return l("selectors.random.label")}function zt(){return l("selectors.bravery.label")}class Vt{constructor(t,e,n,i={}){this.element=this.createRootElement(),this.dropdownElement=this.createDropdownElement();const s=[];i.enableBraveryOption===!0&&s.push({value:L,label:zt(),description:l("selectors.bravery.description"),iconPath:Ft,iconClass:$o}),s.push({value:b,label:Ht(),iconText:xt}),this.championDropdown=new Do(this.dropdownElement,t,c=>this.addPriorityOption(c),{searchPlaceholderText:i.searchPlaceholderText,staticOptions:s});const{scrollElement:a,trackElement:r}=this.createSelectedChampionsScroll();this.scrollElement=a,this.trackElement=r,this.enablePositionRestrictions=i.enablePositionRestrictions===!0,this.enableRandomPoolPositionFilters=i.enableRandomPoolPositionFilters===!0,this.enableRandomAssignedPositionRestrictions=i.enableRandomAssignedPositionRestrictions===!0,this.enableBraveryOption=i.enableBraveryOption===!0,this.enablePositionMenu=this.enablePositionRestrictions||this.enableRandomAssignedPositionRestrictions||this.enableRandomPoolPositionFilters,this.positionMenuElement=this.enablePositionMenu?this.createPositionMenu():null,this.positionMenuTarget=null,this.positionsByChampionId={},this.randomAssignedPositions=[],this.randomPoolPositions=[],this.emptyElement=this.createEmptyState(e),this.element.append(this.dropdownElement,this.scrollElement),this.positionMenuElement&&this.element.appendChild(this.positionMenuElement),this.config=null,this.configKey=e,this.loadChampions=n,this.champions=[],this.championById=new Map,this.selectedPriorityOptions=[],this.optionButtons=new Map,this.dragState=null,this.handleWindowPointerMove=c=>this.moveDrag(c),this.handleWindowPointerUp=c=>this.finishDrag(c),this.handleWindowPointerCancel=c=>this.cancelDrag(c),this.handlePositionMenuOutsidePointerDown=c=>this.closePositionMenuOnOutsidePointerDown(c),this.handlePositionMenuKeyDown=c=>this.closePositionMenuOnKeyDown(c),this.setupInFlight=null,this.setupPending=!1}createRootElement(){const t=document.createElement("div");return t.classList.add("champion-priority-selector"),t}createDropdownElement(){const t=document.createElement(O.dropdown);return t.classList.add("dropdown-champions-default","dropdown-drop-up"),t}createSelectedChampionsScroll(){const t=document.createElement(O.scrollable);t.classList.add("champion-priority-selector__scroll"),t.setAttribute("direction","horizontal"),t.setAttribute("overflow-masks","disabled"),t.setAttribute("side-scroll-wheel","true");const e=document.createElement("div");return e.classList.add("champion-priority-selector__track"),t.appendChild(e),{scrollElement:t,trackElement:e}}createEmptyState(t){const e=document.createElement("div");e.classList.add("champion-priority-selector__empty");const n=document.createElement("span");n.innerText=l("selectors.emptyTitle");const i=document.createElement("span");return i.innerText=l(t==="controladoPick"?"selectors.pickEmptyHint":"selectors.banEmptyHint"),e.append(n,i),e}createPositionMenu(){const t=document.createElement("div");t.classList.add("champion-priority-selector__position-menu"),t.hidden=!0;for(const e of D)t.appendChild(this.createPositionOption(e));return t}createPositionOption(t){const e=X(t),n=document.createElement("button");n.classList.add("champion-priority-selector__position-option"),n.type="button",n.dataset.position=t.value,n.title=e,n.setAttribute("aria-label",e),n.setAttribute("aria-pressed","false"),n.addEventListener("pointerdown",s=>s.stopPropagation()),n.addEventListener("click",s=>{s.stopPropagation(),this.togglePositionMenuPosition(t.value)});const i=document.createElement("img");return i.src=t.iconPath,i.alt=e,i.draggable=!1,n.appendChild(i),n}async setup(){return this.setupPending=!0,this.setupInFlight||(this.setupInFlight=this.runSetupLoop()),this.setupInFlight}refresh(){return this.setup()}async runSetupLoop(){try{for(;this.setupPending;)this.setupPending=!1,await this.performSetup()}finally{this.setupInFlight=null}}async performSetup(){this.champions=await this.loadChampions(),this.championById=new Map(this.champions.map(n=>[n.id,n]));const t=this.getAllowedChampionIds();this.config=ae(this.configKey,{allowedChampionIds:t}),this.selectedPriorityOptions=mt(this.config.priorityOptions||this.config.champions,t).filter(n=>this.isPriorityOptionEnabled(n)),this.enablePositionRestrictions&&(this.positionsByChampionId=j(this.config.positionsByChampionId,F(this.selectedPriorityOptions))),this.enableRandomAssignedPositionRestrictions&&(this.randomAssignedPositions=T(this.config.randomAssignedPositions)),this.enableRandomPoolPositionFilters&&(this.randomPoolPositions=T(this.config.randomPoolPositions)),this.championDropdown.renderOptions(this.champions),this.renderSelectedPriorityOptions();const e=await this.championDropdown.waitForRender();e&&(this.championDropdown.ensureSearchPlaceholder(e),this.championDropdown.patchDropdownShadowDom())}getAllowedChampionIds(){return new Set(this.championById.keys())}isPriorityOptionEnabled(t){return!I(t)||this.enableBraveryOption}addPriorityOption(t){const e=R(t);e===null||this.selectedPriorityOptions.includes(e)||!this.isPriorityOptionEnabled(e)||!f(e)&&!I(e)&&!this.championById.has(e)||(this.selectedPriorityOptions.push(e),this.renderSelectedPriorityOptions(),this.saveConfig())}removePriorityOption(t){var s;const e=R(t),n=this.selectedPriorityOptions.indexOf(e);if(e===null||n===-1)return;this.selectedPriorityOptions.splice(n,1);const i=typeof e=="number"?e:null;((s=this.positionMenuTarget)==null?void 0:s.option)===e&&this.closePositionMenu(),this.enablePositionRestrictions&&i!==null&&delete this.positionsByChampionId[String(i)],this.enableRandomAssignedPositionRestrictions&&f(e)&&(this.randomAssignedPositions=[]),this.enableRandomPoolPositionFilters&&f(e)&&(this.randomPoolPositions=[]),this.renderSelectedPriorityOptions(),this.saveConfig()}movePriorityOptionToIndex(t,e){const n=R(t),i=this.selectedPriorityOptions.indexOf(n);if(n===null||i===-1)return!1;const[s]=this.selectedPriorityOptions.splice(i,1),a=Math.max(0,Math.min(e,this.selectedPriorityOptions.length));return this.selectedPriorityOptions.splice(a,0,s),i!==a}syncPositionsByChampionId(){this.enablePositionRestrictions&&(this.positionsByChampionId=j(this.positionsByChampionId,F(this.selectedPriorityOptions)))}syncRandomPoolPositions(){this.enableRandomPoolPositionFilters&&(this.randomPoolPositions=T(this.randomPoolPositions))}syncRandomAssignedPositions(){this.enableRandomAssignedPositionRestrictions&&(this.randomAssignedPositions=T(this.randomAssignedPositions))}saveConfig(){this.syncPositionsByChampionId(),this.syncRandomAssignedPositions(),this.syncRandomPoolPositions();const t=this.getAllowedChampionIds();this.config=M(this.configKey,e=>(e.priorityOptions=[...this.selectedPriorityOptions],e.champions=F(this.selectedPriorityOptions),this.enableRandomAssignedPositionRestrictions&&(e.randomAssignedPositions=[...this.randomAssignedPositions]),this.enableRandomPoolPositionFilters&&(e.randomPoolPositions=[...this.randomPoolPositions]),this.enablePositionRestrictions&&(e.positionsByChampionId={...this.positionsByChampionId}),e),{allowedChampionIds:t,selectedChampionIds:F(this.selectedPriorityOptions)}),this.enablePositionRestrictions&&(this.positionsByChampionId=this.config.positionsByChampionId||{}),this.enableRandomAssignedPositionRestrictions&&(this.randomAssignedPositions=this.config.randomAssignedPositions||[]),this.enableRandomPoolPositionFilters&&(this.randomPoolPositions=this.config.randomPoolPositions||[]),console.debug(this.configKey,this.config)}renderSelectedPriorityOptions(t=null,e=null){this.positionMenuTarget!==null&&this.closePositionMenu();const n=new Set(this.selectedPriorityOptions.map(s=>k(s)));for(const[s,a]of this.optionButtons)n.has(s)||(a.remove(),this.optionButtons.delete(s));if(this.selectedPriorityOptions.length===0){this.trackElement.replaceChildren(this.emptyElement);return}this.emptyElement.remove();const i=this.selectedPriorityOptions.map((s,a)=>this.getPriorityOptionButton(s,a)).filter(Boolean);this.trackElement.append(...i),t&&this.animateReorder(t,e)}getPriorityOptionButton(t,e){return f(t)?this.getRandomOptionButton(e):I(t)?this.enableBraveryOption?this.getBraveryOptionButton(e):null:this.getChampionOptionButton(t,e)}getChampionOptionButton(t,e){const n=this.championById.get(t);if(!n)return null;const i=String(t);let s=this.optionButtons.get(i);s||(s=this.createIconButton(n),this.optionButtons.set(i,s)),s.dataset.rank=String(e+1),s.classList.toggle("champion-priority-selector__icon--random",!1);const a=this.getChampionPositionTitleSuffix(t);s.title=`${e+1}. ${n.name}${a}`,s.setAttribute("aria-label",`${e+1}. ${n.name}${a}`);const r=s.querySelector("img");r.src=n.squarePortraitPath,r.alt=n.name;const c=s.querySelector(et);return c.setAttribute("aria-label",l("selectors.remove",{name:n.name})),c.title=l("selectors.remove",{name:n.name}),this.renderPositionBadge(s,t),s}getRandomOptionButton(t){let e=this.optionButtons.get(b);e||(e=this.createRandomOptionButton(),this.optionButtons.set(b,e)),e.dataset.rank=String(t+1);const n=Ht(),i=this.getRandomPositionTitleSuffix();e.title=`${t+1}. ${n}${i}`,e.setAttribute("aria-label",`${t+1}. ${n}${i}`);const s=e.querySelector(et);return s.setAttribute("aria-label",l("selectors.remove",{name:n})),s.title=l("selectors.remove",{name:n}),this.renderPositionBadge(e,b),e}getBraveryOptionButton(t){let e=this.optionButtons.get(L);e||(e=this.createBraveryOptionButton(),this.optionButtons.set(L,e)),e.dataset.rank=String(t+1);const n=zt();e.title=`${t+1}. ${n}`,e.setAttribute("aria-label",`${t+1}. ${n}`);const i=e.querySelector("img");i.src=Ft,i.alt=n;const s=e.querySelector(et);return s.setAttribute("aria-label",l("selectors.remove",{name:n})),s.title=l("selectors.remove",{name:n}),e}createIconButton(t){const e=document.createElement("div");e.classList.add("champion-priority-selector__icon"),e.setAttribute("role","button"),e.tabIndex=0;const n=document.createElement("img");n.draggable=!1;const i=document.createElement("button");if(i.classList.add("champion-priority-selector__remove"),i.type="button",i.dataset.icon=nt,i.addEventListener("pointerdown",s=>s.stopPropagation()),i.addEventListener("click",s=>{s.stopPropagation(),this.removePriorityOption(t.id)}),e.addEventListener("pointerdown",s=>this.startDrag(s,t.id)),e.addEventListener("auxclick",s=>this.removePriorityOptionOnMiddleClick(s,t.id)),this.enablePositionRestrictions){const s={option:t.id,kind:u.CHAMPION_ASSIGNED};e.addEventListener("contextmenu",a=>this.openPositionMenu(a,s))}return e.append(n,i),e}createRandomOptionButton(){const t=document.createElement("div");t.classList.add("champion-priority-selector__icon","champion-priority-selector__icon--random"),t.setAttribute("role","button"),t.tabIndex=0;const e=document.createElement("span");e.classList.add("champion-priority-selector__random-icon"),e.innerText=xt;const n=document.createElement("button");if(n.classList.add("champion-priority-selector__remove"),n.type="button",n.dataset.icon=nt,n.addEventListener("pointerdown",i=>i.stopPropagation()),n.addEventListener("click",i=>{i.stopPropagation(),this.removePriorityOption(b)}),t.addEventListener("pointerdown",i=>this.startDrag(i,b)),t.addEventListener("auxclick",i=>this.removePriorityOptionOnMiddleClick(i,b)),this.enableRandomPoolPositionFilters){const i={option:b,kind:u.RANDOM_POOL};t.addEventListener("contextmenu",s=>this.openPositionMenu(s,i))}return t.append(e,n),t}createBraveryOptionButton(){const t=document.createElement("div");t.classList.add("champion-priority-selector__icon",Ho),t.setAttribute("role","button"),t.tabIndex=0;const e=document.createElement("img");e.draggable=!1;const n=document.createElement("button");return n.classList.add("champion-priority-selector__remove"),n.type="button",n.dataset.icon=nt,n.addEventListener("pointerdown",i=>i.stopPropagation()),n.addEventListener("click",i=>{i.stopPropagation(),this.removePriorityOption(L)}),t.addEventListener("pointerdown",i=>this.startDrag(i,L)),t.addEventListener("auxclick",i=>this.removePriorityOptionOnMiddleClick(i,L)),t.append(e,n),t}getChampionAllowedPositions(t){const e=p(t);return e===null?[]:this.positionsByChampionId[String(e)]||[]}getRandomPoolPositions(){return this.randomPoolPositions}getRandomAssignedPositions(){return this.randomAssignedPositions}getPositionLabels(t){return t.map(e=>_o(e)).filter(Boolean)}getChampionAllowedPositionLabels(t){return this.getPositionLabels(this.getChampionAllowedPositions(t))}getRandomPoolPositionLabels(){return this.getPositionLabels(this.getRandomPoolPositions())}getRandomAssignedPositionLabels(){return this.getPositionLabels(this.getRandomAssignedPositions())}getChampionPositionTitleSuffix(t){const e=this.getChampionAllowedPositionLabels(t);return e.length>0?` (${e.join(", ")})`:""}getRandomPositionTitleSuffix(){const t=[],e=this.getRandomAssignedPositionLabels(),n=this.getRandomPoolPositionLabels();return e.length>0&&t.push(l("selectors.random.assignedTitlePart",{positions:this.formatPositionLabelsForSentence(e)})),n.length>0&&t.push(l("selectors.random.poolTitlePart",{positions:this.formatPositionLabelsForSentence(n)})),t.length>0?` (${t.join("; ")})`:""}formatPositionLabelsForSentence(t){return Lo(t)}renderPositionBadge(t,e){t.querySelectorAll(xo).forEach(i=>i.remove());const n=R(e);if(n!==null)for(const i of this.getPositionBadgeTargetsForOption(n)){const s=this.createPositionBadge(i);s&&t.appendChild(s)}}getPositionBadgeTargetsForOption(t){return this.selectedPriorityOptions.includes(t)?f(t)?[{option:t,kind:u.RANDOM_ASSIGNED},{option:t,kind:u.RANDOM_POOL}].filter(e=>this.canOpenPositionMenuForTarget(e)):I(t)?[]:[{option:t,kind:u.CHAMPION_ASSIGNED}].filter(e=>this.canOpenPositionMenuForTarget(e)):[]}createPositionBadge(t){const e=this.getAllowedPositionsForPositionMenuTarget(t),n=this.getAllowedPositionLabelsForPositionMenuTarget(t),i=t.kind===u.RANDOM_POOL,s=document.createElement("button");if(s.classList.add("champion-priority-selector__position-badge"),s.classList.toggle("champion-priority-selector__position-badge--random",i),s.type="button",s.dataset.positionTarget=t.kind,s.title=this.getPositionBadgeTitle(n,t),s.setAttribute("aria-label",s.title),s.addEventListener("pointerdown",c=>c.stopPropagation()),s.addEventListener("click",c=>this.openPositionMenu(c,t,s)),i)return e.length>0?(s.classList.add("champion-priority-selector__position-badge--active"),s.dataset.count=String(e.length)):s.classList.add("champion-priority-selector__position-badge--empty"),s;if(e.length===0)return s.classList.add("champion-priority-selector__position-badge--empty"),s.innerText="+",s;const a=te(e[0]);if(!a)return null;e.length>1&&(s.dataset.count=String(e.length));const r=document.createElement("img");return r.src=a.iconPath,r.alt=X(a),r.draggable=!1,s.appendChild(r),s}getPositionBadgeTitle(t,e){return e.kind===u.RANDOM_ASSIGNED?t.length===0?l("selectors.positionBadge.randomAssignedAny"):l("selectors.positionBadge.randomAssignedSome",{positions:this.formatPositionLabelsForSentence(t)}):e.kind===u.RANDOM_POOL?t.length===0?l("selectors.positionBadge.randomPoolAny"):l("selectors.positionBadge.randomPoolSome",{positions:this.formatPositionLabelsForSentence(t)}):t.length>0?l("selectors.positionBadge.championSome",{positions:this.formatPositionLabelsForSentence(t)}):l("selectors.positionBadge.championAny")}canOpenPositionMenuForTarget(t){if(!this.selectedPriorityOptions.includes(t.option))return!1;switch(t.kind){case u.CHAMPION_ASSIGNED:return typeof t.option=="number"&&this.enablePositionRestrictions;case u.RANDOM_ASSIGNED:return f(t.option)&&this.enableRandomAssignedPositionRestrictions;case u.RANDOM_POOL:return f(t.option)&&this.enableRandomPoolPositionFilters;default:return!1}}normalizePositionMenuTarget(t){if(!t||typeof t!="object"||Array.isArray(t)||!("option"in t)||!("kind"in t))return null;const e=R(t.option),n=e===null?null:{option:e,kind:String(t.kind)};return n&&this.canOpenPositionMenuForTarget(n)?n:null}getAllowedPositionsForPositionMenuTarget(t){switch(t.kind){case u.CHAMPION_ASSIGNED:return this.getChampionAllowedPositions(t.option);case u.RANDOM_ASSIGNED:return this.getRandomAssignedPositions();case u.RANDOM_POOL:return this.getRandomPoolPositions();default:return[]}}getAllowedPositionLabelsForPositionMenuTarget(t){return this.getPositionLabels(this.getAllowedPositionsForPositionMenuTarget(t))}setAllowedPositionsForPositionMenuTarget(t,e){switch(t.kind){case u.CHAMPION_ASSIGNED:{const n=String(t.option);e.length>0?this.positionsByChampionId[n]=e:delete this.positionsByChampionId[n];break}case u.RANDOM_ASSIGNED:this.randomAssignedPositions=e;break;case u.RANDOM_POOL:this.randomPoolPositions=e;break}}openPositionMenu(t,e,n=null){if(!this.positionMenuElement)return;const i=this.normalizePositionMenuTarget(e);if(i===null)return;t.preventDefault(),t.stopPropagation(),this.positionMenuTarget=i,this.renderPositionMenu(),this.positionMenuElement.hidden=!1,this.positionMenuElement.style.left="0px",this.positionMenuElement.style.top="0px";const{left:s,top:a}=this.getPositionMenuCoordinates(t,n);this.positionMenuElement.style.left=`${s}px`,this.positionMenuElement.style.top=`${a}px`,document.addEventListener("pointerdown",this.handlePositionMenuOutsidePointerDown,!0),document.addEventListener("keydown",this.handlePositionMenuKeyDown,!0)}getPositionMenuCoordinates(t,e=null){const n=this.positionMenuElement.getBoundingClientRect();let i=t.clientX,s=t.clientY;if(e&&t.type==="click"&&t.detail===0){const c=e.getBoundingClientRect();i=c.left+c.width/2,s=c.bottom}const a=Math.min(Math.max(i,G),window.innerWidth-n.width-G),r=Math.min(Math.max(s,G),window.innerHeight-n.height-G);return{left:a,top:r}}renderPositionMenu(){if(!this.positionMenuElement||this.positionMenuTarget===null)return;const t=new Set(this.getAllowedPositionsForPositionMenuTarget(this.positionMenuTarget));this.positionMenuElement.querySelectorAll(Fo).forEach(e=>{const n=t.has(e.dataset.position);e.classList.toggle("champion-priority-selector__position-option--selected",n),e.setAttribute("aria-pressed",String(n))})}togglePositionMenuPosition(t){if(!this.positionMenuElement||this.positionMenuTarget===null)return;const e=x(t);if(!e)return;const n=this.positionMenuTarget,i=n.option,s=new Set(this.getAllowedPositionsForPositionMenuTarget(n));s.has(e)?s.delete(e):s.add(e);const a=D.map(S=>S.value).filter(S=>s.has(S));this.setAllowedPositionsForPositionMenuTarget(n,a),this.renderPositionMenu();const r=k(i),c=r?this.optionButtons.get(r):null,h=this.selectedPriorityOptions.indexOf(i);c&&h!==-1&&(f(i)?this.getRandomOptionButton(h):this.getChampionOptionButton(i,h)),this.saveConfig()}closePositionMenuOnOutsidePointerDown(t){var e;(e=this.positionMenuElement)!=null&&e.contains(t.target)||this.closePositionMenu()}closePositionMenuOnKeyDown(t){t.key==="Escape"&&this.closePositionMenu()}closePositionMenu(){this.positionMenuElement&&(this.positionMenuElement.hidden=!0,this.positionMenuTarget=null,document.removeEventListener("pointerdown",this.handlePositionMenuOutsidePointerDown,!0),document.removeEventListener("keydown",this.handlePositionMenuKeyDown,!0))}startDrag(t,e){var s;if(t.button===$t){t.preventDefault();return}if(t.button!==zo)return;this.dragState&&this.clearDragState();const n=k(e),i=n?this.optionButtons.get(n):null;if(i){this.dragState={option:e,pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,active:!1,moved:!1};try{(s=i.setPointerCapture)==null||s.call(i,t.pointerId)}catch{}window.addEventListener("pointermove",this.handleWindowPointerMove),window.addEventListener("pointerup",this.handleWindowPointerUp),window.addEventListener("pointercancel",this.handleWindowPointerCancel)}}removePriorityOptionOnMiddleClick(t,e){t.button===$t&&(t.preventDefault(),t.stopPropagation(),this.removePriorityOption(e))}moveDrag(t){var S;if(!this.dragState||this.dragState.pointerId!==t.pointerId)return;const e=this.dragState.option,n=k(e),i=t.clientX-this.dragState.startX,s=t.clientY-this.dragState.startY,a=Math.hypot(i,s);if(!this.dragState.active){if(a<Vo)return;this.dragState.active=!0,n&&((S=this.optionButtons.get(n))==null||S.classList.add("champion-priority-selector__icon--dragging"))}t.preventDefault();const r=this.getDropIndex(t.clientX,e),c=this.selectedPriorityOptions.indexOf(e);if(r===c||r===-1)return;const h=this.getIconPositions();this.movePriorityOptionToIndex(e,r)&&(this.dragState.moved=!0,this.renderSelectedPriorityOptions(h,e))}finishDrag(t){if(!this.dragState||this.dragState.pointerId!==t.pointerId)return;const e=this.dragState.active,n=this.dragState.moved;this.clearDragState(),e&&n&&this.saveConfig()}cancelDrag(t){!this.dragState||this.dragState.pointerId!==t.pointerId||this.clearDragState()}clearDragState(){var s;if(!this.dragState)return;const{option:t,pointerId:e}=this.dragState,n=k(t),i=n?this.optionButtons.get(n):null;i==null||i.classList.remove("champion-priority-selector__icon--dragging");try{(s=i==null?void 0:i.releasePointerCapture)==null||s.call(i,e)}catch{}window.removeEventListener("pointermove",this.handleWindowPointerMove),window.removeEventListener("pointerup",this.handleWindowPointerUp),window.removeEventListener("pointercancel",this.handleWindowPointerCancel),this.dragState=null}getDropIndex(t,e){const n=this.selectedPriorityOptions.filter(i=>i!==e);for(let i=0;i<n.length;i++){const s=k(n[i]),a=s?this.optionButtons.get(s):null;if(!a)continue;const r=a.getBoundingClientRect();if(t<r.left+r.width/2)return i}return n.length}getIconPositions(){const t=new Map;for(const e of this.selectedPriorityOptions){const n=k(e),i=n?this.optionButtons.get(n):null;i&&t.set(n,i.getBoundingClientRect())}return t}animateReorder(t,e){for(const n of this.selectedPriorityOptions){if(n===e)continue;const i=k(n),s=i?this.optionButtons.get(i):null,a=i?t.get(i):null;if(!s||!a||typeof s.animate!="function")continue;const r=s.getBoundingClientRect(),c=a.left-r.left,h=a.top-r.top;c===0&&h===0||s.animate([{transform:`translate(${c}px, ${h}px)`},{transform:"translate(0, 0)"}],{duration:Go,easing:Uo})}}}const Yo=200,ot="auto-select-champ-select-menu--collapsed",qo="auto-select-champ-select-menu-button-wrapper--open";class jo{constructor(t,e,n){this.element=document.createElement("div"),this.element.classList.add("auto-select-champ-select-menu",ot),this.buttonWrapper=document.createElement("div"),this.buttonWrapper.classList.add("auto-select-champ-select-menu-button-wrapper"),this.headerElement=document.createElement("button"),this.headerElement.classList.add("auto-select-champ-select-menu__header"),this.headerElement.type="button",this.headerElement.setAttribute("aria-label",t),this.headerElement.setAttribute("aria-expanded","false"),this.headerElement.addEventListener("click",()=>this.toggle()),this.contentElement=document.createElement("div"),this.contentElement.classList.add("auto-select-champ-select-menu__content"),this.titleElement=document.createElement("div"),this.titleElement.classList.add("auto-select-champ-select-menu__title"),this.titleElement.textContent=t,this.titleAccessoryElement=null,this.buttonWrapper.append(this.headerElement,this.element),this.contentElement.appendChild(this.titleElement),this.element.appendChild(this.contentElement),this.returnControlsToSocialRoster=e,this.controlElements=n,this.boundCloseOnOutsideInteraction=i=>this.closeOnOutsideInteraction(i),this.buttonObserver=null,this.buttonMountFrame=null,this.buttonMountTask=null,this.hiddenStates=new WeakMap,this.mounted=!1}async mount(){return this.mounted?this.mountButton():(this.mounted=!0,this.controlElements.forEach(t=>{this.hiddenStates.set(t,t.classList.contains("hidden")),t.classList.remove("hidden"),this.contentElement.appendChild(t)}),this.observeButtonContainer(),document.addEventListener("pointerdown",this.boundCloseOnOutsideInteraction,!0),this.mountButton())}unmount(){return this.mounted?(this.mounted=!1,this.stopButtonMounting(),document.removeEventListener("pointerdown",this.boundCloseOnOutsideInteraction,!0),this.setOpen(!1),this.buttonWrapper.remove(),this.restoreHiddenStates(),this.returnControlsToSocialRoster()):this.returnControlsToSocialRoster()}stopButtonMounting(){var t;(t=this.buttonObserver)==null||t.disconnect(),this.buttonObserver=null,this.buttonMountFrame!==null&&(cancelAnimationFrame(this.buttonMountFrame),this.buttonMountFrame=null),this.buttonMountTask=null}restoreHiddenStates(){this.controlElements.forEach(t=>{t.classList.toggle("hidden",this.hiddenStates.get(t)===!0),this.hiddenStates.delete(t)})}isOpen(){return!this.element.classList.contains(ot)}setOpen(t){this.element.classList.toggle(ot,!t),this.buttonWrapper.classList.toggle(qo,t),this.headerElement.setAttribute("aria-expanded",String(t))}toggle(){this.setOpen(!this.isOpen())}closeOnOutsideInteraction(t){if(!this.isOpen())return;(typeof t.composedPath=="function"?t.composedPath():[]).includes(this.buttonWrapper)||this.buttonWrapper.contains(t.target)||this.setOpen(!1)}observeButtonContainer(){this.buttonObserver=new MutationObserver(()=>this.scheduleMountButton()),this.buttonObserver.observe(document.body,{childList:!0,subtree:!0})}scheduleMountButton(){this.buttonMountFrame===null&&(this.buttonMountFrame=requestAnimationFrame(()=>{this.buttonMountFrame=null,this.mountButton()}))}mountButton(){return this.buttonMountTask||(this.buttonMountTask=this.appendButtonToContainer().finally(()=>{this.buttonMountTask=null})),this.buttonMountTask}async appendButtonToContainer(){let t=dt();for(;this.mounted&&!t;)await v(Yo),t=dt();if(!this.mounted||!t)return;const e=t.querySelector(d.firstChampSelectSquareButton);this.buttonWrapper.parentNode===t&&this.buttonWrapper.nextSibling===e||t.insertBefore(this.buttonWrapper,e)}setTitleAccessory(t){this.titleAccessoryElement=t,(!t.isConnected||t.parentNode!==this.titleElement)&&this.titleElement.appendChild(t)}}class it{constructor(t,e){this.element=document.createElement(O.radioInputOption),this.element.classList.add("lol-settings-voice-input-mode-option","auto-select-checkbox"),this.element.innerText=t,this.config=null,this.configKey=e,this.setupComplete=!1}setup(){this.syncFromConfig(),this.setupComplete||(this.element.addEventListener("click",()=>this.toggle()),this.setupComplete=!0)}syncFromConfig(){this.config=ae(this.configKey),this.element.toggleAttribute("selected",this.config.enabled===!0)}toggle(){return console.debug("auto-champion-select: Toggling",this.configKey),this.config=M(this.configKey,t=>(t.enabled=!t.enabled,t)),this.element.toggleAttribute("selected",this.config.enabled===!0),this.config.enabled}}const Ko=224,Wo="auto-select-settings-trigger",Gt="auto-select-settings-flyout",Ut="auto-select-settings-menu",Xo="auto-select-settings-menu__empty",Jo="auto-select-settings-checkbox",Qo="auto-select-settings-range",Zo="auto-select-settings-range__header",ti="auto-select-settings-range__label",ei="auto-select-settings-range__value",ni="auto-select-settings-range__track",oi="auto-select-settings-range__fill",ii="auto-select-settings-range__handle",si="auto-select-settings-range__handle--min",ai="auto-select-settings-range__handle--max",U="auto-select-settings-range__handle--dragging";class ri{constructor(t=[]){this.controls=t,this.triggerElements=new Set,this.flyoutElement=this.createFlyoutElement(),this.open=!1,this.activeTriggerElement=null,this.setupComplete=!1,this.boundCloseOnOutsideInteraction=e=>this.closeOnOutsideInteraction(e),this.boundCloseOnEscape=e=>this.closeOnEscape(e),this.boundPositionFlyout=()=>this.positionFlyout(),this.renderControls()}setup(){this.ensureFlyoutConnected(),this.controls.forEach(t=>{var e;return(e=t.setup)==null?void 0:e.call(t)}),this.sync(),!this.setupComplete&&(document.addEventListener("pointerdown",this.boundCloseOnOutsideInteraction,!0),document.addEventListener("keydown",this.boundCloseOnEscape,!0),window.addEventListener("resize",this.boundPositionFlyout),this.setupComplete=!0)}setControls(t){this.controls=t,this.renderControls(),this.setupComplete&&this.controls.forEach(e=>{var n;return(n=e.setup)==null?void 0:n.call(e)}),this.sync()}createTriggerElement(t=l("settings.triggerLabel")){const e=document.createElement("button");return e.type="button",e.classList.add(Wo),e.dataset.autoSelectSettings="trigger",e.setAttribute("aria-label",t),e.setAttribute("aria-expanded","false"),e.title=t,e.addEventListener("click",n=>{n.preventDefault(),n.stopImmediatePropagation(),n.stopPropagation(),this.toggleFlyout(e)},!0),this.triggerElements.add(e),e}createFlyoutElement(){const t=document.createElement("lol-uikit-flyout-frame");t.classList.add("flyout",Gt),t.dataset.autoSelectSettings="flyout",t.setAttribute("orientation","bottom"),t.setAttribute("animated","true"),t.setAttribute("caretless","true"),t.style.position="fixed",t.style.overflow="visible",t.style.display="none";const e=document.createElement("lc-flyout-content"),n=document.createElement("div");return n.classList.add("social-options-menu","active",Ut),e.appendChild(n),t.appendChild(e),t}renderControls(){const t=this.flyoutElement.querySelector(`.${Ut}`);if(t){if(t.replaceChildren(),this.controls.length===0){const e=document.createElement("div");e.classList.add(Xo),e.textContent=l("settings.empty"),t.appendChild(e);return}t.append(...this.controls.map(e=>e.element))}}sync(){this.controls.forEach(t=>{var e;return(e=t.sync)==null?void 0:e.call(t)})}ensureFlyoutConnected(){document.querySelectorAll(`.${Gt}`).forEach(t=>{t!==this.flyoutElement&&t.remove()}),this.flyoutElement.isConnected||document.body.appendChild(this.flyoutElement)}isOpen(){return this.open&&this.flyoutElement.isConnected&&getComputedStyle(this.flyoutElement).display!=="none"}setOpen(t,e=this.activeTriggerElement){this.open=t,this.activeTriggerElement=t?e:null,this.ensureFlyoutConnected(),this.flyoutElement.style.display=t?"block":"none",this.flyoutElement.toggleAttribute("show",t),this.triggerElements.forEach(n=>{n.setAttribute("aria-expanded",String(t&&n===this.activeTriggerElement))}),t&&(this.sync(),this.positionFlyout())}toggleFlyout(t){const e=!this.isOpen()||this.activeTriggerElement!==t;this.setOpen(e,t)}positionFlyout(){if(!this.isOpen()||!this.activeTriggerElement)return;const t=this.activeTriggerElement.getBoundingClientRect(),e=Math.min(Ko,window.innerWidth-16);this.flyoutElement.style.width=`${e}px`;const n=this.flyoutElement.getBoundingClientRect(),i=t.right-e+4,s=Math.max(8,Math.min(window.innerWidth-e-8,i)),a=t.bottom+4,r=a+n.height<=window.innerHeight-8?a:Math.max(8,t.top-n.height-4);this.flyoutElement.style.left=`${Math.round(s)}px`,this.flyoutElement.style.top=`${Math.round(r)}px`}closeOnOutsideInteraction(t){if(!this.isOpen())return;const e=typeof t.composedPath=="function"?t.composedPath():[],n=[...this.triggerElements].some(s=>e.includes(s)),i=e.includes(this.flyoutElement);!n&&!i&&this.setOpen(!1)}closeOnEscape(t){t.key==="Escape"&&this.isOpen()&&this.setOpen(!1)}}class Y{constructor(t,e){this.label=t,this.options=e,this.element=document.createElement(O.radioInputOption),this.element.classList.add("lol-settings-voice-input-mode-option",Jo),this.element.textContent=t,this.element.title=t,this.setupComplete=!1}setup(){this.sync(),!this.setupComplete&&(this.element.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.options.toggle(),this.sync()}),this.setupComplete=!0)}sync(){this.element.toggleAttribute("selected",this.options.isSelected()===!0)}}class li{constructor(t,e){this.label=t,this.options=e,this.dragHandle=null,this.dragStartedCollapsed=!1,this.setupComplete=!1,this.boundPointerMove=i=>this.onPointerMove(i),this.boundPointerUp=()=>this.stopDragging(),this.element=document.createElement("div"),this.element.classList.add(Qo);const n=document.createElement("div");n.classList.add(Zo),this.labelElement=document.createElement("span"),this.labelElement.classList.add(ti),this.labelElement.textContent=t,this.valueElement=document.createElement("span"),this.valueElement.classList.add(ei),this.trackElement=document.createElement("div"),this.trackElement.classList.add(ni),this.fillElement=document.createElement("div"),this.fillElement.classList.add(oi),this.minHandleElement=this.createHandle("min"),this.maxHandleElement=this.createHandle("max"),n.append(this.labelElement,this.valueElement),this.trackElement.append(this.fillElement,this.minHandleElement,this.maxHandleElement),this.element.append(n,this.trackElement)}setup(){this.sync(),!this.setupComplete&&(this.trackElement.addEventListener("pointerdown",t=>this.onTrackPointerDown(t)),this.minHandleElement.addEventListener("pointerdown",t=>this.startDragging(t,"min")),this.maxHandleElement.addEventListener("pointerdown",t=>this.startDragging(t,"max")),this.minHandleElement.addEventListener("keydown",t=>this.onHandleKeyDown(t,"min")),this.maxHandleElement.addEventListener("keydown",t=>this.onHandleKeyDown(t,"max")),this.setupComplete=!0)}createHandle(t){const e=document.createElement("button");return e.type="button",e.classList.add(ii,t==="min"?si:ai),e.setAttribute("aria-label",l("settings.handleLabel",{label:this.label,handle:l(`settings.handles.${t}`)})),e.setAttribute("aria-valuemin",String(this.options.min)),e.setAttribute("aria-valuemax",String(this.options.max)),e.setAttribute("role","slider"),e}getNormalizedValue(){const t=this.options.getValue(),e=this.snapValue(t.min),n=this.snapValue(t.max);return{min:Math.min(e,n),max:Math.max(e,n)}}snapValue(t){const e=this.options.min,n=this.options.max,i=this.options.step,s=Number(t),a=Number.isFinite(s)?s:e,r=Math.round((a-e)/i)*i+e;return Math.max(e,Math.min(n,r))}sync(){const t=this.getNormalizedValue(),e=this.valueToPercent(t.min),n=this.valueToPercent(t.max);this.valueElement.textContent=this.options.formatValue(t),this.fillElement.style.left=`${e}%`,this.fillElement.style.width=`${n-e}%`,this.minHandleElement.style.left=`${e}%`,this.maxHandleElement.style.left=`${n}%`,this.syncHandle(this.minHandleElement,t.min),this.syncHandle(this.maxHandleElement,t.max)}syncHandle(t,e){t.setAttribute("aria-valuenow",String(e)),t.setAttribute("aria-valuetext",this.options.formatValue({min:e,max:e}))}valueToPercent(t){const e=this.options.max-this.options.min;return e<=0?0:(t-this.options.min)/e*100}clientXToValue(t){const e=this.trackElement.getBoundingClientRect(),n=e.width<=0?0:(t-e.left)/e.width;return this.snapValue(this.options.min+(this.options.max-this.options.min)*n)}onTrackPointerDown(t){if(t.target===this.minHandleElement||t.target===this.maxHandleElement)return;const e=this.clientXToValue(t.clientX),n=this.getNormalizedValue(),i=Math.abs(e-n.min)<=Math.abs(e-n.max)?"min":"max";this.startDragging(t,i),this.setHandleValue(i,e)}startDragging(t,e){t.preventDefault(),t.stopPropagation(),this.dragHandle=e;const n=this.getNormalizedValue();this.dragStartedCollapsed=n.min===n.max,this.syncDraggingHandle(),document.addEventListener("pointermove",this.boundPointerMove,!0),document.addEventListener("pointerup",this.boundPointerUp,!0)}onPointerMove(t){if(!this.dragHandle)return;t.preventDefault();const e=this.clientXToValue(t.clientX),n=this.resolveDragHandleForValue(e);this.dragHandle=n,this.syncDraggingHandle(),this.setHandleValue(n,e)}stopDragging(){this.clearDraggingHandle(),this.dragHandle=null,this.dragStartedCollapsed=!1,document.removeEventListener("pointermove",this.boundPointerMove,!0),document.removeEventListener("pointerup",this.boundPointerUp,!0)}syncDraggingHandle(){this.minHandleElement.classList.toggle(U,this.dragHandle==="min"),this.maxHandleElement.classList.toggle(U,this.dragHandle==="max")}clearDraggingHandle(){this.minHandleElement.classList.remove(U),this.maxHandleElement.classList.remove(U)}onHandleKeyDown(t,e){const n=this.getNormalizedValue();let s=e==="min"?n.min:n.max;if(t.key==="ArrowLeft"||t.key==="ArrowDown")s-=this.options.step;else if(t.key==="ArrowRight"||t.key==="ArrowUp")s+=this.options.step;else if(t.key==="Home")s=this.options.min;else if(t.key==="End")s=this.options.max;else return;t.preventDefault(),this.setHandleValue(e,s)}resolveDragHandleForValue(t){if(!this.dragHandle)return"min";if(!this.dragStartedCollapsed)return this.dragHandle;const e=this.getNormalizedValue();return t<e.min?"min":t>e.max?"max":this.dragHandle}setHandleValue(t,e){const n=this.getNormalizedValue(),i=this.snapValue(e),s=t==="min"?{min:Math.min(i,n.max),max:n.max}:{min:n.min,max:Math.max(i,n.min)};this.options.setValue(s),this.sync()}}const ci="auto-select-social-roster-section",Yt="auto-select-social-roster-section__header";class di{constructor(t,...e){this.element=document.createElement(O.socialRosterGroup),this.element.classList.add(ci),this.element.addEventListener("post-render",()=>this.onPostRender()),this.element.addEventListener("click",()=>this.onClick()),this.label=t,this.collapsibleElements=e,this.headerAccessoryElement=null,this.waitRender()}waitRender(){new MutationObserver((t,e)=>{if(this.element.querySelector(d.socialRosterGroupLabel)){const n=new Event("post-render");this.element.dispatchEvent(n),e.disconnect()}}).observe(this.element,{childList:!0})}onPostRender(){this.element.querySelector(d.socialRosterGroupLabel).innerText=this.label;const t=this.element.querySelector(d.socialRosterGroupHeader);t==null||t.removeAttribute("draggable"),t&&this.headerAccessoryElement&&(t.classList.add(Yt),t.appendChild(this.headerAccessoryElement))}setHeaderAccessory(t){this.headerAccessoryElement=t;const e=this.element.querySelector(d.socialRosterGroupHeader);e&&(e.classList.add(Yt),e.appendChild(t))}onClick(){var t;this.collapsibleElements.forEach(e=>{e.closest(".auto-select-champ-select-menu")||e.classList.toggle("hidden")}),(t=this.element.querySelector(d.socialRosterGroupArrow))==null||t.toggleAttribute("open")}}function ye(o){o&&Toast.success(o)}function pt(o){o&&Toast.error(o)}function hi(o,t){return typeof Toast.promise=="function"?Toast.promise(o,t):o}const St="Balaclava: Auto Champion Select";function At(){return l("commandBar.group")}function ui(o){return typeof(o==null?void 0:o.then)=="function"}class Ct{constructor({id:t,name:e,legend:n,tags:i,group:s,callback:a,toasts:r}){this.id=t,this.name=e,this.legend=n,this.tags=i,this.group=s,this.perform=this.perform.bind(this),this.callback=a,this.toasts=r}perform(){try{const t=this.callback();if(ui(t))return hi(t,{loading:this.toasts.loading,success:this.toasts.success,error:this.toasts.error});const e=this.toasts.success||(t?this.toasts.on:this.toasts.off);ye(e)}catch(t){pt(this.toasts.error),console.error(t)}}}class Pe extends Ct{constructor(t,e,n){super({id:`${e}Switch`,name:()=>l("commandBar.autoSwitchName",{name:t,state:y(e).enabled?l("states.on"):l("states.off")}),legend:()=>y(e).enabled?l("commandBar.turnOff"):l("commandBar.turnOn"),tags:[St,e,"switch"],group:At(),callback:n,toasts:{on:l("commandBar.autoSwitchOn",{name:t}),off:l("commandBar.autoSwitchOff",{name:t}),error:l("commandBar.autoSwitchError",{name:t})}})}}function pi(o){return M(o,e=>(e.force=!e.force,e)).force}class Se extends Ct{constructor(t){const e=t==="controladoPick",n=l(e?"commandBar.forcePickName":"commandBar.forceBanName");super({id:`${t}ForceSwitch`,name:()=>l("commandBar.forceSwitchName",{name:n,state:y(t).force?l("states.on"):l("states.off")}),legend:()=>l(e?"commandBar.forcePickLegend":"commandBar.forceBanLegend"),tags:[St,t,"force","intent","switch"],group:At(),callback:()=>pi(t),toasts:{on:l("commandBar.forceSwitchOn",{name:n}),off:l("commandBar.forceSwitchOff",{name:n}),error:l("commandBar.forceSwitchError",{name:n})}})}}class mi extends Ct{constructor(t){super({id:"RefreshDropdowns",name:()=>l("commandBar.refreshChampionsName"),legend:()=>l("commandBar.refreshChampionsLegend"),tags:[St,"refresh"],group:At(),callback:t,toasts:{success:l("commandBar.refreshChampionsSuccess"),error:l("commandBar.refreshChampionsError")}})}}class gi extends Pe{constructor(t){super(l("actions.pick"),"controladoPick",t)}}class fi extends Pe{constructor(t){super(l("actions.ban"),"controladoBan",t)}}class yi extends Se{constructor(){super("controladoPick")}}class Pi extends Se{constructor(){super("controladoBan")}}function Si(o){for(const t of o)CommandBar.addAction(t)}const Ai=200,Ci=6e4,qt=2e3,bi=".ready-check-root-element",Ei="#lol-uikit-layer-manager-wrapper > .modal",Oi=".auto-select-champ-select-menu__header",m=Object.freeze({autoAccept:"controladoAutoAccept",actionDelay:"controladoActionDelay",pick:"controladoPick",ban:"controladoBan"});function wi(){return y(m.autoAccept).enabled===!0}function Ae(){return y(m.autoAccept).hideAutoAcceptPrompt===!0}function Ti(){const o=y(m.autoAccept);return o.enabled===!0&&o.hideAutoAcceptPrompt===!0}function Ii(){const o=Ae();M(m.autoAccept,t=>(t.hideAutoAcceptPrompt=!o,t))}function Ce(o){return o==="pick"?m.pick:m.ban}function be(){return y(m.pick).pickIntent!==!1}function ki(){const o=be();M(m.pick,t=>(t.pickIntent=!o,t))}function jt(o){return y(Ce(o)).force===!0}function Kt(o){M(Ce(o),t=>(t.force=t.force!==!0,t))}function Li(){const o=y(m.actionDelay),{minMs:t,maxMs:e}=$(o.minMs,o.maxMs);return{min:t,max:e}}function _i(o){const{minMs:t,maxMs:e}=$(o.min,o.max);M(m.actionDelay,n=>(n.minMs=t,n.maxMs=e,n))}function vi(o){const{minMs:t,maxMs:e}=$(o.min,o.max);return t===0&&e===0?l("settings.actionDelayValue.instant"):t===e?l("settings.actionDelayValue.exact",{delay:z(e)}):t===0?l("settings.actionDelayValue.upTo",{delay:z(e)}):l("settings.actionDelayValue.range",{min:z(t),max:z(e)})}class Ri{constructor(t){this.isEnabled=t,this.observer=null,this.hiddenModal=null,this.hiddenModalStyles=new WeakMap,this.sync=this.sync.bind(this)}start(){this.observer||(this.observer=new MutationObserver(()=>this.sync()),this.observer.observe(document.body,{childList:!0,subtree:!0}),this.sync())}sync(){const t=Mi();if(!t){this.restore();return}if(!this.isEnabled()){this.restore();return}this.hide(t)}hide(t){this.hiddenModal!==t&&(this.restore(),this.hiddenModal=t,this.hiddenModalStyles.set(t,{display:t.style.getPropertyValue("display"),displayPriority:t.style.getPropertyPriority("display"),pointerEvents:t.style.getPropertyValue("pointer-events"),pointerEventsPriority:t.style.getPropertyPriority("pointer-events")}),t.style.setProperty("display","none","important"),t.style.setProperty("pointer-events","none","important"))}restore(){if(!this.hiddenModal)return;const t=this.hiddenModal,e=this.hiddenModalStyles.get(t);Wt(t,"display",e==null?void 0:e.display,e==null?void 0:e.displayPriority),Wt(t,"pointer-events",e==null?void 0:e.pointerEvents,e==null?void 0:e.pointerEventsPriority),this.hiddenModalStyles.delete(t),this.hiddenModal=null}}function Mi(){const o=document.querySelector(bi);return(o==null?void 0:o.closest(Ei))||null}function Wt(o,t,e,n){e?o.style.setProperty(t,e,n||""):o.style.removeProperty(t)}async function Ni(o){function t(){return wi()?!1:(o.restore(),!0)}if(t()||(console.debug(`auto-champion-select(auto-accept): Ready check detected, accepting in ${qt}ms...`),await v(qt),t()))return;let e=!1;try{e=await Bi()}catch(n){throw o.restore(),pt(l("toasts.readyCheckAcceptFailed")),n}e?ye(l("toasts.readyCheckAccepted")):(o.restore(),pt(l("toasts.readyCheckAcceptFailed")))}async function Bi(){const o=await E("POST",g.readyCheckAccept);return o.ok?(console.debug("auto-champion-select(auto-accept): Accepted ready check"),!0):(console.error("auto-champion-select(auto-accept): Failed to accept ready check",o),!1)}async function Di(o){const t=await E("GET",g.gameflowPhase),e=t.ok?await t.json():null;o.handleGameflowPhase(e)}function xi({championSelect:o,champSelectControlsMenu:t,readyCheckModalSuppressor:e,setupChampionSelectors:n}){let i=0;return async function(c){const h=++i;try{await s(c,h)}catch(S){console.error("auto-champion-select: Failed to handle gameflow phase",S)}};async function s(r,c){r==="ReadyCheck"?Ni(e).catch(h=>{console.error("auto-champion-select(auto-accept): Failed to handle ready check",h)}):e.restore(),await a(r),c===i&&await n()}async function a(r){r==="ChampSelect"?(o.mount(),await t.mount()):(o.unmount(),await t.unmount())}}function Fi(){const o=new Ze,t=new it(l("toggles.autoAccept"),m.autoAccept),e=new it(l("toggles.pick"),m.pick),n=new Vt(l("selectors.pickPlaceholder"),m.pick,Ke,{enablePositionRestrictions:!0,enableRandomAssignedPositionRestrictions:!0,enableBraveryOption:!0,enableRandomPoolPositionFilters:!0}),i=new it(l("toggles.ban"),m.ban),s=new Vt(l("selectors.banPlaceholder"),m.ban,le,{enableRandomPoolPositionFilters:!0}),a=Hi(n,s),r=zi(t,e,i),c=new ri,h=new di(l("plugin.socialRosterTitle"),a,r);return h.setHeaderAccessory(c.createTriggerElement()),{championSelect:o,autoAcceptToggle:t,pickToggle:e,banToggle:i,pickChampionSelector:n,banChampionSelector:s,selectorsContainer:a,checkboxesContainer:r,pluginSection:h,settingsMenu:c,championSelectors:[n,s]}}function $i(o){return[new li(l("settings.actionDelay"),{min:Qt,max:Zt,step:st,getValue:Li,setValue:_i,formatValue:vi}),new Y(l("settings.pickIntent"),{isSelected:()=>be(),toggle:()=>ki()}),new Y(l("settings.forcePick"),{isSelected:()=>jt("pick"),toggle:()=>Kt("pick")}),new Y(l("settings.forceBan"),{isSelected:()=>jt("ban"),toggle:()=>Kt("ban")}),new Y(l("settings.hideAutoAcceptPrompt"),{isSelected:()=>Ae(),toggle:()=>{Ii(),o.sync()}})]}function Hi(...o){const t=document.createElement("div");return t.append(...o.map(e=>e.element)),t}function zi(...o){const t=document.createElement("div");return t.classList.add("auto-select-checkboxes-div"),t.append(...o.map(e=>e.element)),t}function Vi({pluginSection:o,checkboxesContainer:t,selectorsContainer:e}){let n=null,i=0,s=()=>!1;async function a(r){let c=_t();for(;!c;){if(s()||r!==i)return;await v(Ai),c=_t()}s()||r!==i||c.append(o.element,t,e)}return{setIsChampSelectControlsMounted(r){s=r},returnControlsToSocialRoster(){if(n)return n;const r=++i;return n=a(r).catch(c=>console.error("auto-champion-select: Failed to return controls to social roster",c)).finally(()=>{n=null}),n}}}function Gi({autoAcceptToggle:o,pickToggle:t,banToggle:e,readyCheckModalSuppressor:n}){o.setup(),o.element.addEventListener("click",()=>n.sync()),t.setup(),e.setup()}async function Ui(o){await Promise.all(o.map(t=>t.setup()))}async function Yi(o){await Promise.all(o.map(t=>t.refresh()))}function qi(){const o=Fi(),t=new Ri(Ti);o.settingsMenu.setControls($i(t));const e=Vi(o),n=new jo(l("plugin.champSelectMenuTitle"),e.returnControlsToSocialRoster,[o.checkboxesContainer,o.selectorsContainer]);n.setTitleAccessory(o.settingsMenu.createTriggerElement()),e.setIsChampSelectControlsMounted(()=>n.mounted);const i={...o,champSelectControlsMenu:n,readyCheckModalSuppressor:t,setupToggles:()=>Gi({...o,readyCheckModalSuppressor:t}),setupSettingsMenu:()=>o.settingsMenu.setup(),setupChampionSelectors:()=>Ui(o.championSelectors),refreshChampionSelectors:()=>Yi(o.championSelectors),refreshPickChampionSelector:async()=>{await o.pickChampionSelector.refresh()}};return i.handleGameflowPhase=xi(i),i}function ji(o){bt(g.gameflowPhase,t=>{o.handleGameflowPhase(t.data)}),bt(g.wallet,async t=>{if(t.eventType==="Update"){console.debug("auto-champion-select(wallet): Refreshing champion selectors...");try{await o.refreshPickChampionSelector()}catch(e){console.error("auto-champion-select(wallet): Failed to refresh champion selectors",e)}}})}function Ki({pickToggle:o,banToggle:t,refreshChampionSelectors:e}){Si([new gi(()=>o.toggle()),new fi(()=>t.toggle()),new yi,new Pi,new mi(e)])}function Wi(o){let t=null,e=null;function n(){e==null||e.disconnect(),e=null,t!==null&&(cancelAnimationFrame(t),t=null)}const i=setTimeout(()=>{n()},Ci);function s(){if(!(dt()!==null))return;clearTimeout(i),n(),document.querySelector(Oi)!==null||o.handleGameflowPhase("ChampSelect")}e=new MutationObserver(()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,s()}))}),e.observe(document.body,{childList:!0,subtree:!0}),s()}async function Xi(){await ko();const o=qi();o.setupToggles(),o.setupSettingsMenu(),o.readyCheckModalSuppressor.start(),Ki(o),ji(o),await Di(o),Wi(o),console.debug(`auto-champion-select(${Ee}): Report bugs to Balaclava#1912`)}let Xt=!1;function Jt(){Xt||(Xt=!0,Xi().catch(o=>console.error("auto-champion-select: Failed to initialize",o)))}document.readyState==="loading"?window.addEventListener("load",Jt,{once:!0}):Jt();export{Jt as load};
|