티스토리 수익 글 보기
“use strict”;(globalThis.webpackChunk=globalThis.webpackChunk||[]).push([[“app_assets_modules_github_ref-selector_ts”],{77757:(e,t,i)=>{var n=i(29212),r=i(78134),s=i(39595),o=i(80590);function a(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function h(e,t,i,n){var r,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a–)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,i,o):r(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o}let l=class RefSelectorElement extends HTMLElement{connectedCallback(){window.addEventListener(“resize”,this.windowResized),this.refType=”branch”===this.getRequiredAttr(“type”)?n._.Branch:n._.Tag;let e=this.getAttribute(“current-committish”);this.currentCommittish=e?atob(e):null,this.input=this.hasAttribute(“initial-filter”)&&this.currentCommittish||””,this.defaultBranch=atob(this.getRequiredAttr(“default-branch”)),this.nameWithOwner=atob(this.getRequiredAttr(“name-with-owner”)),this.canCreate=this.hasAttribute(“can-create”),this.prefetchOnMouseover=this.hasAttribute(“prefetch-on-mouseover”);let t=this.getRequiredAttr(“query-endpoint”),i=this.getRequiredAttr(“cache-key”);this.index=new n.d(this.refType,this,t,i,this.nameWithOwner),this.updateViewportSize(),this.setupFetchListeners()}disconnectedCallback(){this.resizeAnimationRequest&&cancelAnimationFrame(this.resizeAnimationRequest),window.removeEventListener(“resize”,this.windowResized)}updateViewportSize(){this.isMobileViewport=window.innerWidth<544,this.windowHeight=window.innerHeight}inputEntered(e){this.input=e.detail,this.render()}tabSelected(){this.index.fetchData()}renderTemplate(e,t){return new r.i4(e,t,r.xr)}renderRow(e){let t=this.index.currentSearchResult[e];if(!t&&e>=this.listLength)return document.createElement(“span”);if(this.index.fetchFailed)return this.renderTemplate(this.fetchFailedTemplate,{index:e,refName:this.input});if(!t){let t=this.input===this.currentCommittish;return this.isCurrentVisible||(this.isCurrentVisible=t),this.renderTemplate(this.noMatchTemplate,{index:e,isCurrent:t,refName:this.input})}let i=this.input.length>0,n=t===this.currentCommittish;this.isCurrentVisible||(this.isCurrentVisible=n);let r=this.renderTemplate(this.itemTemplate,{refName:t,index:e,isFilteringClass:i?”is-filtering”:””,urlEncodedRefName:this.urlEncodeRef(t),isCurrent:n,isNotDefault:t!==this.defaultBranch});if(i){let e=r.querySelector(“span”);e.textContent=””;let i=t.split(this.input),n=i.length-1;for(let t=0;t{t||(this.index.fetchData(),t=!0)};if(!e||e.open){i();return}e.addEventListener(“toggle”,i,{once:!0}),this.prefetchOnMouseover&&e.addEventListener(“mouseover”,i,{once:!0}),this.addEventListener(“keydown”,this.keydown),this.addEventListener(“change”,this.updateCurrent);let n=e.querySelector(“input[data-ref-filter]”);n&&(n.addEventListener(“input”,()=>{this.input=n.value,this.render()}),n.addEventListener(“keydown”,t=>{if(“ArrowDown”!==t.key&&(“Tab”!==t.key||t.shiftKey)){if(“Enter”===t.key){let i=this.index.currentSearchResult.indexOf(this.input);if(-1===i){if(!this.showCreateRow)return;i=this.listLength-1}e.querySelector(`[data-index=”${i}”]`).click(),t.preventDefault()}}else t.preventDefault(),t.stopPropagation(),this.focusFirstListMember()}))}focusFirstListMember(){this.virtualizedList&&(this.currentSelectionIndex=0,this.focusItemAtIndex(this.currentSelectionIndex))}updateCurrent(e){e.target instanceof HTMLInputElement&&e.target.checked&&e.target.value&&(this.currentCommittish=e.target.value)}keydown(e){if(null!==this.currentSelectionIndex){if(“Enter”===e.key){let t=document.activeElement;if(!t)return;t.click(),e.preventDefault();return}if(“Tab”!==e.key&&”Escape”!==e.key)switch(e.preventDefault(),e.stopPropagation(),e.key){case”ArrowUp”:this.currentSelectionIndex–,this.currentSelectionIndex<0&&(this.currentSelectionIndex=this.listLength-1),this.focusItemAtIndex(this.currentSelectionIndex);break;case"Home":this.currentSelectionIndex=0,this.focusItemAtIndex(this.currentSelectionIndex);break;case"End":this.currentSelectionIndex=this.listLength-1,this.focusItemAtIndex(this.currentSelectionIndex);break;case"ArrowDown":this.currentSelectionIndex++,this.currentSelectionIndex>this.listLength-1&&(this.currentSelectionIndex=0),this.focusItemAtIndex(this.currentSelectionIndex)}}}focusItemAtIndex(e){this.virtualizedList.scrollToIndex(e,”center”),setTimeout(()=>{let t=this.listContainer.querySelector(`[data-index=”${e}”]`);t&&t.focus()},20)}setupVirtualizedList(){this.listContainer.textContent=””,this.listContainer.style.maxHeight=`${this.listHeight}px`,this.virtualizedList=new o.A(this.listContainer,{height:this.listHeight,rowCount:this.listLength,renderRow:this.renderRow.bind(this),rowHeight:e=>{let t=this.isMobileViewport?54:33;return this.showCreateRow&&e===this.listLength-1?51:t},onRowsRendered:()=>{this.hiddenCurrentElement&&(this.listContainer.removeChild(this.hiddenCurrentElement),delete this.hiddenCurrentElement),this.isCurrentVisible?this.isCurrentVisible=!1:this.hiddenCurrentItemTemplate&&(this.hiddenCurrentElement=document.createElement(“div”),this.hiddenCurrentElement?.appendChild(this.renderTemplate(this.hiddenCurrentItemTemplate,{refName:this.currentCommittish})),this.listContainer.appendChild(this.hiddenCurrentElement))},initialIndex:0,overscanCount:6}),this.virtualizedList.resize.bind(this.virtualizedList)}constructor(…e){super(…e),a(this,”isCurrentVisible”,!1),a(this,”hiddenCurrentElement”,void 0),a(this,”currentSelectionIndex”,null),a(this,”resizeAnimationRequest”,void 0),a(this,”handleWindowResize”,()=>{if(!this.virtualizedList)return;let e=this.isMobileViewport,t=this.windowHeight;this.updateViewportSize();let i=e!==this.isMobileViewport,n=t!==this.windowHeight;if(i){this.virtualizedList.destroy(),this.setupVirtualizedList();return}this.isMobileViewport&&n&&(this.listContainer.style.maxHeight=`${this.listHeight}px`,this.virtualizedList.resize(this.listHeight))}),a(this,”windowResized”,()=>{this.resizeAnimationRequest&&cancelAnimationFrame(this.resizeAnimationRequest),this.resizeAnimationRequest=requestAnimationFrame(this.handleWindowResize)})}};h([s.aC],l.prototype,”listContainer”,void 0),h([s.aC],l.prototype,”itemTemplate”,void 0),h([s.aC],l.prototype,”noMatchTemplate”,void 0),h([s.aC],l.prototype,”fetchFailedTemplate”,void 0),h([s.aC],l.prototype,”hiddenCurrentItemTemplate”,void 0),l=h([s.p_],l)},56176:(e,t,i)=>{let n;function r(){if(!n)throw Error(“Client env was requested before it was loaded. This likely means you are attempting to use client env at the module level in SSR, which is not supported. Please move your client env usage into a function.”);return n}function s(){return n?.locale??”en-US”}function o(){return!!r().login}i.d(t,{JK:()=>s,M3:()=>o,_$:()=>r}),!function(){if(“undefined”!=typeof document){let e=document.getElementById(“client-env”);if(e)try{n=JSON.parse(e.textContent||””)}catch(e){console.error(“Error parsing client-env”,e)}}}()},75028:(e,t,i)=>{i.d(t,{G:()=>r,K:()=>s});var n=i(47584);let r=n.XC?.readyState===”interactive”||n.XC?.readyState===”complete”?Promise.resolve():new Promise(e=>{n.XC?.addEventListener(“DOMContentLoaded”,()=>{e()})}),s=n.XC?.readyState===”complete”?Promise.resolve():new Promise(e=>{n.cg?.addEventListener(“load”,e)})},75632:(e,t,i)=>{i.d(t,{G7:()=>h,XY:()=>l,fQ:()=>a});var n=i(5225),r=i(56176);function s(){return new Set((0,r._$)().featureFlags)}let o=i(47584).X3||function(){try{return process?.env?.STORYBOOK===”true”}catch{return!1}}()?s:(0,n.A)(s);function a(){return Array.from(o())}function h(e){return o().has(e)}let l={isFeatureEnabled:h}},29212:(e,t,i)=>{i.d(t,{_:()=>l,d:()=>SearchIndex});var n=i(80688),r=i(57516);function s(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}let{getItem:o,setItem:a,removeItem:h}=(0,n.A)(“localStorage”,{throwQuotaErrorsOnSet:!0}),l={Branch:”branch”,Tag:”tag”};let SearchIndex=class SearchIndex{render(){this.selector.render()}async fetchData(){try{if(!this.isLoading||this.fetchInProgress)return;if(!this.bootstrapFromLocalStorage()){this.fetchInProgress=!0,this.fetchFailed=!1;let e=await fetch(`${this.refEndpoint}?type=${this.refType}`,{headers:{Accept:”application/json”}});await this.processResponse(e)}this.isLoading=!1,this.fetchInProgress=!1,this.render()}catch{this.fetchInProgress=!1,this.fetchFailed=!0}}async processResponse(e){if(this.emitStats(e),!e.ok){this.fetchFailed=!0;return}let t=e.clone(),i=await e.json();this.knownItems=i.refs,this.cacheKey=i.cacheKey,this.flushToLocalStorage(await t.text())}emitStats(e){if(!e.ok){(0,r.i)({incrementKey:”REF_SELECTOR_BOOT_FAILED”},!0);return}switch(e.status){case 200:(0,r.i)({incrementKey:”REF_SELECTOR_BOOTED_FROM_UNCACHED_HTTP”});break;case 304:(0,r.i)({incrementKey:”REF_SELECTOR_BOOTED_FROM_HTTP_CACHE”});break;default:(0,r.i)({incrementKey:”REF_SELECTOR_UNEXPECTED_RESPONSE”})}}search(e){let t;if(this.searchTerm=e,””===e){this.currentSearchResult=this.knownItems;return}let i=[],n=[];for(let r of(this.exactMatchFound=!1,this.knownItems))if(!((t=r.indexOf(e))<0)){if(0===t){e===r?(n.unshift(r),this.exactMatchFound=!0):n.push(r);continue}i.push(r)}this.currentSearchResult=[...n,...i]}bootstrapFromLocalStorage(){let e=o(this.localStorageKey);if(!e)return!1;let t=JSON.parse(e);return t.cacheKey===this.cacheKey&&"refs"in t?(this.knownItems=t.refs,this.isLoading=!1,(0,r.i)({incrementKey:"REF_SELECTOR_BOOTED_FROM_LOCALSTORAGE"}),!0):(h(this.localStorageKey),!1)}async flushToLocalStorage(e){try{a(this.localStorageKey,e)}catch(t){if(t.message.toLowerCase().includes("quota")){this.clearSiblingLocalStorage(),(0,r.i)({incrementKey:"REF_SELECTOR_LOCALSTORAGE_OVERFLOWED"});try{a(this.localStorageKey,e)}catch(e){e.message.toLowerCase().includes("quota")&&(0,r.i)({incrementKey:"REF_SELECTOR_LOCALSTORAGE_GAVE_UP"})}}else throw t}}clearSiblingLocalStorage(){for(let e of Object.keys(localStorage))e.startsWith(SearchIndex.LocalStoragePrefix)&&h(e)}clearLocalStorage(){h(this.localStorageKey)}get localStorageKey(){return`${SearchIndex.LocalStoragePrefix}:${this.nameWithOwner}:${this.refType}`}constructor(e,t,i,n,r){s(this,"refType",void 0),s(this,"selector",void 0),s(this,"knownItems",[]),s(this,"currentSearchResult",[]),s(this,"exactMatchFound",!1),s(this,"searchTerm",""),s(this,"refEndpoint",void 0),s(this,"cacheKey",void 0),s(this,"nameWithOwner",void 0),s(this,"isLoading",!0),s(this,"fetchInProgress",!1),s(this,"fetchFailed",!1),this.refType=e,this.selector=t,this.refEndpoint=i,this.cacheKey=n,this.nameWithOwner=r}};s(SearchIndex,"LocalStoragePrefix","ref-selector")},9080:(e,t,i)=>{i.d(t,{k:()=>o,v:()=>a});var n=i(5225),r=i(47584);let s=(0,n.A)(function(){return r.XC?.head?.querySelector(‘meta[name=”runtime-environment”]’)?.content||””}),o=(0,n.A)(function(){return”enterprise”===s()}),a=”webpack”},80688:(e,t,i)=>{i.d(t,{A:()=>o,D:()=>a});var n=i(47584),r=i(57516);let s=class NoOpStorage{getItem(){return null}setItem(){}removeItem(){}clear(){}key(){return null}get length(){return 0}};function o(e,t={throwQuotaErrorsOnSet:!1},i=n.cg,a=e=>e,h=e=>e){let l;try{if(!i)throw Error();l=i[e]||new s}catch{l=new s}let{throwQuotaErrorsOnSet:c}=t;function u(e){t.sendCacheStats&&(0,r.i)({incrementKey:e})}function d(e){try{if(l.removeItem(e),t.ttl){let t=`${e}:expiry`;l.removeItem(t)}}catch{}}return{getItem:function(e,t=Date.now()){try{let i=l.getItem(e);if(!i)return null;let n=`${e}:expiry`,r=Number(l.getItem(n));if(r&&t>r)return d(e),d(n),u(“SAFE_STORAGE_VALUE_EXPIRED”),null;return u(“SAFE_STORAGE_VALUE_WITHIN_TTL”),a(i)}catch{return null}},setItem:function(e,i,n=Date.now()){try{if(l.setItem(e,h(i)),t.ttl){let i=`${e}:expiry`,r=n+t.ttl;l.setItem(i,r.toString())}}catch(e){if(c&&e instanceof Error&&e.message.toLowerCase().includes(“quota”))throw e}},removeItem:d,clear:l.clear,getKeys:function(){return Object.keys(l)},get length(){return l.length}}}function a(e){return o(e,{throwQuotaErrorsOnSet:!1},n.cg,JSON.parse,JSON.stringify)}},47584:(e,t,i)=>{i.d(t,{KJ:()=>n.KJ,Kn:()=>r.Kn,X3:()=>n.X3,XC:()=>r.XC,cg:()=>r.cg,fV:()=>r.fV,g5:()=>n.g5});var n=i(25992),r=i(39833)},39833:(e,t,i)=>{i.d(t,{Kn:()=>o,XC:()=>r,cg:()=>s,fV:()=>a});let n=”undefined”!=typeof FORCE_SERVER_ENV&&FORCE_SERVER_ENV,r=”undefined”==typeof document||n?void 0:document,s=”undefined”==typeof window||n?void 0:window,o=”undefined”==typeof history||n?void 0:history,a=”undefined”==typeof location||n?{pathname:””,origin:””,search:””,hash:””,href:””}:location},25992:(e,t,i)=>{i.d(t,{KJ:()=>s,X3:()=>r,g5:()=>o});var n=i(39833);let r=void 0===n.XC,s=!r;function o(){return!!r||!n.XC||!!(n.XC.querySelector(‘react-app[data-ssr=”true”]’)||n.XC.querySelector(‘react-partial[data-ssr=”true”][partial-name=”repos-overview”]’))}},57516:(e,t,i)=>{i.d(t,{X:()=>p,i:()=>c});var n=i(47584),r=i(75028),s=i(9080),o=i(75632),a=i(56176),h=i(70170);let l=[];function c(e,t=!1,i=.5){if(!n.X3&&!0!==(0,o.G7)(“browser_stats_disabled”)){if(i<0||i>1)throw RangeError(“Sampling probability must be between 0 and 1”);void 0===e.timestamp&&(e.timestamp=Date.now()),e.loggedIn=(0,a.M3)(),e.staff=p(),e.bundler=s.v,Math.random()JSON.stringify(e));for(;i.length>0;)t.push(function(e){let t=e.shift(),i=[t],n=t.length;for(;e.length>0&&n<=65536;){let t=e[0].length;if(n+t<=65536){let r=e.shift();i.push(r),n+=t}else break}return i}(i));return t}(l))!function(e,t){try{navigator.sendBeacon&&navigator.sendBeacon(e,t)}catch{}}(e,`{"stats": [${t.join(",")}] }`);l=[]}}function p(){return!!n.XC?.head?.querySelector('meta[name="user-staff"]')?.content}n.XC?.addEventListener("pagehide",f),n.XC?.addEventListener("visibilitychange",f)}}]);
//# sourceMappingURL=app_assets_modules_github_ref-selector_ts-251c10fc23ee.js.map