performance.mark("js-parse-end:93796-191269fab5c8341b.js"); "use strict";(globalThis.webpackChunk_github_ui_github_ui=globalThis.webpackChunk_github_ui_github_ui||[]).push([["93796"],{65502(t,e,i){i.d(e,{k:()=>h});var s=i(10225),a=i(17243),r=i(47903),n=i(16518),o=i(14705),l=i(61876);class u extends AbortController{#t;constructor(t){super(),this.#t=t}abortIfChanged(t){(void 0===t||t!==this.#t)&&this.abort()}}class h extends l.A{suggestionCache;validationCache;prefetchedSuggestions;completeResultSetQueries;providerContext;suggestionEndpoint;validationEndpoint;abortSuggestionsController;abortValidationController;valueValidator;constructor(t,e){super(t,e),this.suggestionEndpoint="",this.validationEndpoint="",this.suggestionCache=new Map,this.completeResultSetQueries=new Set,this.validationCache=new Map,this.abortSuggestionsController=new AbortController,this.abortValidationController=new u,this.prefetchedSuggestions=new Map}abortPreviousSuggestionsRequests(){this.abortSuggestionsController.abort(),this.abortSuggestionsController=new AbortController}abortPreviousValidationRequests(t){this.abortValidationController.abortIfChanged(t?.raw),this.abortValidationController=new u(t?.raw)}getFilterValue(t,e){return e||((0,o.I8)((0,o.sF)(t)?(0,o.I8)(t.value?.values.at(-1)?.value):t.raw)??"")}getMetaSuggestions(t){return[]}async processSuggestions(t,e,i,s){if(!this.shouldGetSuggestions(e))return null;let a=(0,o.DS)(e,s);this.abortPreviousSuggestionsRequests();let r=this.abortSuggestionsController,n=e.provider.key,l=[],u=(0,o.jL)(this.displayName,this.icon),h=(0,o.Ms)(this.displayName,this.icon),d=(0,o.m1)(n);(0,o.uT)(e)&&this.options.filterTypes.valueless&&!e.raw.startsWith("-")&&l.push(u),(0,o.uT)(e)&&this.options.filterTypes.hasValue&&!e.raw.startsWith("-")&&l.push(h),this.options.filterTypes.exclusive&&""===a&&(0,o.aK)(e)&&e.raw!==`-${n}:`&&l.unshift(d);let g=l;if(this.allowsFilterValues()){for(let s of g=[...l,...[...await this.fetchSuggestions(a,e,t)??[]].map(e=>i(e,a,t))])[u,h,d].includes(s)||this.prefetchedSuggestions.set(s.value,s);if(r.signal.aborted)return null}return g}async validateFilterBlockValues(t,e,i){let s={},l=i.map(async(l,u)=>{let h=(0,o.M5)(l.value);if(!this.allowsFilterValues())return{...l,valid:!1,validations:[{type:n.b.InvalidValue,message:r.D.filterValuesUnsupported(this.key)}]};let d=i.findIndex(t=>(0,o.M5)(t.value)===h);if(!h||d=0){s[u]={...l,valid:!1,validations:[{type:n.b.EmptyValue,message:r.D.filterValueEmpty(this.key)}]};return}let g=this.prefetchedSuggestions.get(h),p=this.getMetaSuggestions(h)?.[0];if(g){s[u]={...l,...g,valid:!0,value:l.value};return}if(p?.value===h){s[u]={...l,...p,valid:!0,value:l.value};return}if(t.activeBlockId!==e.id){let e=this.getFilterValue({id:1,type:n._B.Filter,raw:`${this.key}:`,value:{raw:h,values:[{value:h}]}},h),i=await this.validateFilterValue(e,t.contextURLParams,t);if(i instanceof Error)"Aborted"===i.message?s[u]={...l,valid:void 0,value:l.value}:s[u]={...l,valid:!1};else{let e=this.validateValue?.(t,l,i);return e?e.value===a.rt?s[u]={...l,valid:!0,value:l.value}:s[u]={...l,valid:!0,...e,value:l.value}:s[u]={...l,valid:!1,validations:[{type:n.b.InvalidValue,message:r.D.filterInvalidValue(this.key,h)}]},l}}s[u]={...l,valid:void 0}});return await Promise.all(l),Object.values(s)}async fetchSuggestions(t,e,i){try{if(this.suggestionCache.has(t))return this.suggestionCache.get(t)??[];if(!this.suggestionEndpoint||""===this.suggestionEndpoint)throw Error("No suggestion endpoint provided");let e=new URL(this.suggestionEndpoint,window.location.origin),s=i.contextURLParams,r=new URLSearchParams([s?.toString(),this.providerContext?.toString()].join("&"));r.set("q",t),r.set("filter_value",t),e.search=r.toString();let n=await this.fetchData(e.toString());if(!n||!n.ok)return null;let o=await n.json(),l=Object.keys(o)[0],u=l?o[l]:null;if(Array.isArray(u)&&u.length""===e?e===t:t.startsWith(e))}rankSuggestion(t,e,i){return{...e,priority:e.priority??3}}findPrefetchedSuggestions(t){if(!t)return[];let e=(0,s.t)({items:[...this.prefetchedSuggestions.values()],filter:t,key:t=>(0,o.I8)(t.value)??"",secondaryKey:t=>t.displayName??t.description??""}).map(e=>this.rankSuggestion(t,e,{})).sort((t,e)=>e.priority-t.priority).slice(0,a.Rx);return e.push(...this.getMetaSuggestions(t)),e}async validateFilterValue(t,e,i){try{let s;if(this.validationCache.has(t))return this.validationCache.get(t)??null;if(!this.validationEndpoint||""===this.validationEndpoint)throw Error("No validation endpoint provided");let a=new URL(this.validationEndpoint,window.location.origin),r=new URLSearchParams([e?.toString(),this.providerContext?.toString()].join("&"));r.set("q",t),r.set("filter_value",t),a.search=r.toString(),this.abortPreviousValidationRequests(i);let n=await this.fetchData(a.toString(),this.abortValidationController);if(!n)return Error("Aborted");if(!n.ok)return null;let o=await n.json(),l=Object.keys(o);if(!(s=1===l.length&&l[0]&&Array.isArray(o[l[0]])?Array.isArray(o[l[0]])?o[l[0]][0]:o[l[0]]:o))return null;return this.validationCache.set(t,s),s}catch{return null}}async fetchData(t,e){let i;try{i=await fetch(t,{method:"GET",mode:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"},signal:e?.signal})}catch(t){if("AbortError"!==t.name)throw t}return i}}},45928(t,e,i){i.d(e,{E:()=>u});var s=i(4069),a=i(23666),r=i(17243),n=i(16518),o=i(14705),l=i(65502);class u extends l.k{constructor(t){super(r._i.org,t);const e=t?.businessSlug;this.suggestionEndpoint=e?(0,a.MeY)({businessSlug:e}):"/_filter/organizations",this.validationEndpoint=e?(0,a.ohj)({businessSlug:e}):"/_filter/organizations/validate",this.type=n.CH.Select}async getSuggestions(t,e,i,s){return this.processSuggestions(t,e,this.#e.bind(this),s)}rankSuggestion(t,e){let{displayName:i,description:a}=e,n=r.E4;return t&&(i&&(n-=(0,s.dt)(t,i)),a&&(n-=(0,s.dt)(t,a))),{...e,priority:n}}#e(t,e){let{name:i,login:s,avatarUrl:a}=t;return this.rankSuggestion(e,{type:n.ak.Value,displayName:i,ariaLabel:`${i}, ${this.displayName}`,value:(0,o.$4)(s)??"",description:s,inlineDescription:!0,icon:a?void 0:this.icon,avatar:a?{url:a,type:n.uW.Org}:void 0})}validateValue(t,e,i){let s=(0,o.M5)(e.value);return!!i&&!!s&&{avatar:i.avatarUrl?{url:i.avatarUrl,type:n.uW.Org}:void 0,value:s,displayName:i.name}}getValueRowProps(t){let e=this.options.renderValueVisual?.(t);return{text:t.displayName??(0,o.I8)(t.value)??"",description:t.description,descriptionVariant:"block",leadingVisual:this.options.renderValueVisual?e??null:(0,o.J)(t,this.icon,!0)}}}},92324(t,e,i){i.d(e,{I:()=>l});var s=i(4069),a=i(17243),r=i(16518),n=i(14705),o=i(65502);class l extends o.k{constructor(t){super(a._i.repo,t),this.suggestionEndpoint="/_filter/repositories",this.validationEndpoint="/_filter/repositories/validate",this.type=r.CH.Select}async getSuggestions(t,e,i,s){return this.processSuggestions(t,e,this.#e.bind(this),s)}rankSuggestion(t,e){let{displayName:i}=e,r=a.E4;return t&&i&&(r-=(0,s.dt)(t,i)),{...e,priority:r}}#e(t,e){let{nameWithOwner:i}=t;return this.rankSuggestion(e,{type:r.ak.Value,displayName:i,ariaLabel:`${i}, ${this.displayName}`,value:i,inlineDescription:!1,icon:this.icon})}validateValue(t,e,i){let s=(0,n.M5)(e.value);return!!i&&!!s&&{displayName:i.name,value:s}}getValueRowProps(t){let e=this.options.renderValueVisual?.(t);return{text:t.displayName??(0,n.I8)(t.value)??"",description:t.description,descriptionVariant:"block",leadingVisual:this.options.renderValueVisual?e??null:(0,n.J)(t,this.icon,!0)}}}},61876(t,e,i){i.d(e,{A:()=>o,e:()=>n});var s=i(12907),a=i(16518),r=i(14705);class n{key;aliases;displayName;description;priority;type;icon;options;constructor(t,e){Object.assign(this,t),this.key=t.key,this.icon=t.icon,this.type=a.CH.Text,this.displayName=t.displayName??(0,r.ZH)(t.key),this.options={...s.dQ,priority:t.priority,...e,filterTypes:{...s.dQ.filterTypes,...e?.filterTypes}},this.priority=this.options.priority}shouldGetSuggestions(t){return t&&t.type!==a._B.Space&&(0,r.Bt)(t,this.options.filterTypes.multiValue)}allowsFilterValues(){return!1!==this.options.filterTypes.inclusive||!1!==this.options.filterTypes.exclusive}}class o extends n{validateValue(t,e,i){return!!i&&i}}}}]); //# sourceMappingURL=93796-191269fab5c8341b-45ce54757467e0de.js.map