performance.mark("js-parse-end:77313-f439c46a2769a1fe.js"); "use strict";(globalThis.webpackChunk_github_ui_github_ui=globalThis.webpackChunk_github_ui_github_ui||[]).push([["77313"],{53464(t,e,i){i.d(e,{Ay:()=>k});class s{constructor(t,e,{tabInsertsSuggestions:i,defaultFirstOption:s,scrollIntoViewOptions:n}={}){this.input=t,this.list=e,this.tabInsertsSuggestions=null==i||i,this.defaultFirstOption=null!=s&&s,this.scrollIntoViewOptions=null!=n?n:{block:"nearest",inline:"nearest"},this.isComposing=!1,e.id||(e.id=`combobox-${Math.random().toString().slice(2,6)}`),this.ctrlBindings=!!navigator.userAgent.match(/Macintosh/),this.keyboardEventHandler=t=>(function(t,e){if(!t.shiftKey&&!t.metaKey&&!t.altKey&&(e.ctrlBindings||!t.ctrlKey)&&!e.isComposing)switch(t.key){case"Enter":r(e.input,e.list)&&t.preventDefault();break;case"Tab":e.tabInsertsSuggestions&&r(e.input,e.list)&&t.preventDefault();break;case"Escape":e.clearSelection();break;case"ArrowDown":e.navigate(1),t.preventDefault();break;case"ArrowUp":e.navigate(-1),t.preventDefault();break;case"n":e.ctrlBindings&&t.ctrlKey&&(e.navigate(1),t.preventDefault());break;case"p":e.ctrlBindings&&t.ctrlKey&&(e.navigate(-1),t.preventDefault());break;default:if(t.ctrlKey)break;e.clearSelection()}})(t,this),this.compositionEventHandler=t=>{var e,i;return e=t,i=this,void(i.isComposing="compositionstart"===e.type,document.getElementById(i.input.getAttribute("aria-controls")||"")&&i.clearSelection())},this.inputHandler=this.clearSelection.bind(this),t.setAttribute("role","combobox"),t.setAttribute("aria-controls",e.id),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-haspopup","listbox")}destroy(){this.clearSelection(),this.stop(),this.input.removeAttribute("role"),this.input.removeAttribute("aria-controls"),this.input.removeAttribute("aria-expanded"),this.input.removeAttribute("aria-autocomplete"),this.input.removeAttribute("aria-haspopup")}start(){this.input.setAttribute("aria-expanded","true"),this.input.addEventListener("compositionstart",this.compositionEventHandler),this.input.addEventListener("compositionend",this.compositionEventHandler),this.input.addEventListener("input",this.inputHandler),this.input.addEventListener("keydown",this.keyboardEventHandler),this.list.addEventListener("click",n),this.indicateDefaultOption()}stop(){this.clearSelection(),this.input.setAttribute("aria-expanded","false"),this.input.removeEventListener("compositionstart",this.compositionEventHandler),this.input.removeEventListener("compositionend",this.compositionEventHandler),this.input.removeEventListener("input",this.inputHandler),this.input.removeEventListener("keydown",this.keyboardEventHandler),this.list.removeEventListener("click",n)}indicateDefaultOption(){var t;this.defaultFirstOption&&(null==(t=Array.from(this.list.querySelectorAll('[role="option"]:not([aria-disabled="true"])')).filter(o)[0])||t.setAttribute("data-combobox-option-default","true"))}navigate(t=1){let e=Array.from(this.list.querySelectorAll('[aria-selected="true"]')).filter(o)[0],i=Array.from(this.list.querySelectorAll('[role="option"]')).filter(o),s=i.indexOf(e);if(s===i.length-1&&1===t||0===s&&-1===t){this.clearSelection(),this.input.focus();return}let n=1===t?0:i.length-1;if(e&&s>=0){let e=s+t;e>=0&&e0||t.offsetHeight>0)}let a=window.testScreenReaderDelay||100;class l{constructor(t,e,i,n=!1){var r;if(this.container=t,this.input=e,this.results=i,this.combobox=new s(e,i,{defaultFirstOption:n}),this.feedback=t.getRootNode().getElementById(`${this.results.id}-feedback`),this.autoselectEnabled=n,this.clearButton=t.getRootNode().getElementById(`${this.input.id||this.input.name}-clear`),this.clientOptions=i.querySelectorAll("[role=option]"),this.feedback&&(this.feedback.setAttribute("aria-live","polite"),this.feedback.setAttribute("aria-atomic","true")),this.clearButton&&!this.clearButton.getAttribute("aria-label")){const t=document.querySelector(`label[for="${this.input.name}"]`);this.clearButton.setAttribute("aria-label","clear:"),this.clearButton.setAttribute("aria-labelledby",`${this.clearButton.id} ${(null==t?void 0:t.id)||""}`)}this.input.getAttribute("aria-expanded")||this.input.setAttribute("aria-expanded","false"),this.results.popover?this.results.matches(":popover-open")&&this.results.hidePopover():this.results.hidden=!0,this.results.getAttribute("aria-label")||this.results.setAttribute("aria-label","results"),this.input.setAttribute("autocomplete","off"),this.input.setAttribute("spellcheck","false"),this.interactingWithList=!1,this.onInputChange=function(t,e=0){let i;return function(...s){clearTimeout(i),i=window.setTimeout(()=>{clearTimeout(i),t(...s)},e)}}(this.onInputChange.bind(this),300),this.onResultsMouseDown=this.onResultsMouseDown.bind(this),this.onInputBlur=this.onInputBlur.bind(this),this.onInputFocus=this.onInputFocus.bind(this),this.onKeydown=this.onKeydown.bind(this),this.onCommit=this.onCommit.bind(this),this.handleClear=this.handleClear.bind(this),this.input.addEventListener("keydown",this.onKeydown),this.input.addEventListener("focus",this.onInputFocus),this.input.addEventListener("blur",this.onInputBlur),this.input.addEventListener("input",this.onInputChange),this.results.addEventListener("mousedown",this.onResultsMouseDown),this.results.addEventListener("combobox-commit",this.onCommit),null==(r=this.clearButton)||r.addEventListener("click",this.handleClear)}destroy(){this.input.removeEventListener("keydown",this.onKeydown),this.input.removeEventListener("focus",this.onInputFocus),this.input.removeEventListener("blur",this.onInputBlur),this.input.removeEventListener("input",this.onInputChange),this.results.removeEventListener("mousedown",this.onResultsMouseDown),this.results.removeEventListener("combobox-commit",this.onCommit)}handleClear(t){t.preventDefault(),"true"===this.input.getAttribute("aria-expanded")&&(this.input.setAttribute("aria-expanded","false"),this.updateFeedbackForScreenReaders("Results hidden.")),this.input.value="",this.container.value="",this.input.focus(),this.input.dispatchEvent(new Event("change")),this.close()}onKeydown(t){if("Escape"===t.key&&this.container.open)this.close(),t.stopPropagation(),t.preventDefault();else if(t.altKey&&"ArrowUp"===t.key&&this.container.open)this.close(),t.stopPropagation(),t.preventDefault();else if(t.altKey&&"ArrowDown"===t.key&&!this.container.open){if(!this.input.value.trim())return;this.open(),t.stopPropagation(),t.preventDefault()}}onInputFocus(){this.interactingWithList||this.fetchResults()}onInputBlur(){this.interactingWithList||this.close()}onCommit({target:t}){if(!(t instanceof HTMLElement)||(this.close(),t instanceof HTMLAnchorElement))return;let e=t.getAttribute("data-autocomplete-value")||t.textContent;this.updateFeedbackForScreenReaders(`${t.textContent||""} selected.`),this.container.value=e,e||this.updateFeedbackForScreenReaders("Results hidden.")}onResultsMouseDown(){this.interactingWithList=!0}onInputChange(){this.feedback&&this.feedback.textContent&&(this.feedback.textContent=""),this.container.removeAttribute("value"),this.fetchResults()}identifyOptions(){let t=0;for(let e of this.results.querySelectorAll('[role="option"]:not([id])'))e.id=`${this.results.id}-option-${t++}`}updateFeedbackForScreenReaders(t){setTimeout(()=>{this.feedback&&(this.feedback.textContent=t)},a)}fetchResults(){let t=this.input.value.trim();if(!t&&!this.container.fetchOnEmpty)return void this.close();let e=this.container.src;if(!e)return;let i=new URL(e,window.location.href),s=new URLSearchParams(i.search.slice(1));s.append("q",t),i.search=s.toString(),this.container.dispatchEvent(new CustomEvent("loadstart")),this.container.fetchResult(i).then(t=>{this.results.innerHTML=t,this.identifyOptions(),this.combobox.indicateDefaultOption();let e=this.results.querySelectorAll('[role="option"]'),i=!!e.length||!!this.results.querySelectorAll('[data-no-result-found="true"]').length,s=e.length,[n]=e,r=null==n?void 0:n.textContent;this.autoselectEnabled&&r?this.updateFeedbackForScreenReaders(`${s} results. ${r} is the top result: Press Enter to activate.`):this.updateFeedbackForScreenReaders(`${s||"No"} results.`),i?this.open():this.close(),this.container.dispatchEvent(new CustomEvent("load")),this.container.dispatchEvent(new CustomEvent("loadend"))}).catch(()=>{this.container.dispatchEvent(new CustomEvent("error")),this.container.dispatchEvent(new CustomEvent("loadend"))})}open(){(this.results.popover?!this.results.matches(":popover-open"):this.results.hidden)&&(this.combobox.start(),this.results.popover?this.results.showPopover():this.results.hidden=!1),this.container.open=!0,this.interactingWithList=!0}close(){(this.results.popover?this.results.matches(":popover-open"):!this.results.hidden)&&(this.combobox.stop(),this.results.popover?this.results.hidePopover():this.results.hidden=!0),this.container.open=!1,this.interactingWithList=!1}}var u,h,c,d,p,b=function(t,e,i,s){if("a"===i&&!s)throw TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(t):s?s.value:e.get(t)},f=function(t,e,i,s,n){if("m"===s)throw TypeError("Private method is not writable");if("a"===s&&!n)throw TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!n:!e.has(t))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(t,i):n?n.value=i:e.set(t,i),i},v=function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&0>e.indexOf(s)&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,s=Object.getOwnPropertySymbols(t);ne.indexOf(s[n])&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(i[s[n]]=t[s[n]]);return i};let m=globalThis.HTMLElement||null;class g extends Event{constructor(t,e){var{relatedTarget:i}=e;super(t,v(e,["relatedTarget"])),this.relatedTarget=i}}let E=new WeakMap,w=null;class y extends m{constructor(){super(...arguments),u.add(this),h.set(this,null),c.set(this,null),p.set(this,void 0)}static define(t="auto-complete",e=customElements){return e.define(t,this),this}static setCSPTrustedTypesPolicy(t){w=null===t?t:Promise.resolve(t)}get forElement(){var t;if(null==(t=b(this,h,"f"))?void 0:t.isConnected)return b(this,h,"f");let e=this.getAttribute("for"),i=this.getRootNode();return e&&(i instanceof Document||i instanceof ShadowRoot)?i.getElementById(e):null}set forElement(t){f(this,h,t,"f"),this.setAttribute("for","")}get inputElement(){var t;return(null==(t=b(this,c,"f"))?void 0:t.isConnected)?b(this,c,"f"):this.querySelector("input")}set inputElement(t){f(this,c,t,"f"),b(this,u,"m",d).call(this)}connectedCallback(){this.isConnected&&(b(this,u,"m",d).call(this),new MutationObserver(()=>{E.get(this)||b(this,u,"m",d).call(this)}).observe(this,{subtree:!0,childList:!0}))}disconnectedCallback(){let t=E.get(this);t&&(t.destroy(),E.delete(this))}get src(){return this.getAttribute("src")||""}set src(t){this.setAttribute("src",t)}get value(){return this.getAttribute("value")||""}set value(t){this.setAttribute("value",t)}get open(){return this.hasAttribute("open")}set open(t){t?this.setAttribute("open",""):this.removeAttribute("open")}get fetchOnEmpty(){return this.hasAttribute("fetch-on-empty")}set fetchOnEmpty(t){this.toggleAttribute("fetch-on-empty",t)}async fetchResult(t){var e;null==(e=b(this,p,"f"))||e.abort();let{signal:i}=f(this,p,new AbortController,"f"),s=await fetch(t.toString(),{signal:i,headers:{Accept:"text/fragment+html"}});if(!s.ok)throw Error(await s.text());return w?(await w).createHTML(await s.text(),s):await s.text()}static get observedAttributes(){return["open","value","for"]}attributeChangedCallback(t,e,i){var s,n;if(e===i)return;let r=E.get(this);if(r)switch((this.forElement!==(null==(s=E.get(this))?void 0:s.results)||this.inputElement!==(null==(n=E.get(this))?void 0:n.input))&&b(this,u,"m",d).call(this),t){case"open":null===i?r.close():r.open();break;case"value":null!==i&&(r.input.value=i),this.dispatchEvent(new g("auto-complete-change",{bubbles:!0,relatedTarget:r.input}))}}}h=new WeakMap,c=new WeakMap,p=new WeakMap,u=new WeakSet,d=function(){var t;null==(t=E.get(this))||t.destroy();let{forElement:e,inputElement:i}=this;if(!e||!i)return;let s="true"===this.getAttribute("data-autoselect");E.set(this,new l(this,i,e,s)),e.setAttribute("role","listbox")};let A="u">typeof globalThis?globalThis:window;try{A.AutocompleteElement=A.AutoCompleteElement=y.define()}catch(t){if(!(A.DOMException&&t instanceof DOMException&&"NotSupportedError"===t.name)&&!(t instanceof ReferenceError))throw t}let k=y}}]); //# sourceMappingURL=77313-f439c46a2769a1fe-e4029368b2357f3f.js.map