System.register(["./chunk-frameworks.js","./chunk-vendor.js"],function(U,D){"use strict";var h,w,b,k,S,p,E,L,T,c,j,_;return{setters:[function(r){h=r.o,w=r.aW,b=r.C,k=r.X,S=r.F,p=r.p,E=r.k,L=r.aY,T=r.r},function(r){c=r.a,j=r.o,_=r.r}],execute:function(){var r=Object.defineProperty,a=(e,t)=>r(e,"name",{value:t,configurable:!0});function v(e){const t=e.querySelector(".js-gist-files"),s=document.getElementById("js-gist-file-template"),n=document.createElement("div");n.innerHTML=s.textContent;for(const i of n.querySelectorAll("[id]"))i.id!=="blob-dragged-file-input"&&i.removeAttribute("id");const o=n.querySelector(".js-code-textarea");o!=null&&o.setAttribute("id",`blob_contents_${Date.now()}`);for(const i of n.children)t.append(i);return t.lastElementChild}a(v,"createEmptyFile");function x(e){for(const t of e.querySelectorAll(".js-gist-file")){const s=t.querySelector(".js-gist-filename"),n=t.querySelector(".js-blob-contents");if(!s.value&&!n.value)return t}return v(e)}a(x,"withEmptyFile");function d(e){return w(e.closest(".js-code-editor"))}a(d,"withEditor");async function g(e){const t=e.getAttribute("data-language-detection-url");if(!t)return;const s=new URL(t,window.location.origin),n=new URLSearchParams(s.search.slice(1));n.append("filename",e.value),s.search=n.toString();const o=await fetch(s.toString(),{headers:{"X-Requested-With":"XMLHttpRequest",Accept:"application/json"}});if(!o.ok){const u=new Error,f=o.statusText?` ${o.statusText}`:"";throw u.message=`HTTP ${o.status}${f}`,u}const l=await o.json();(await d(e)).setMode(l.language)}a(g,"onFilenameChange"),h(".js-gist-filename",async e=>{const t=e,s=e.closest(".js-code-editor");await d(s),b(t,g),e.addEventListener("blur",()=>k(t,g),{once:!0})}),c("click",".js-add-gist-file",function(e){e.preventDefault();const t=e.currentTarget.closest(".js-blob-form");v(t).scrollIntoView()}),c("gist:filedrop",".js-blob-form",async function(e){const{file:t,data:s}=e.detail,n=x(e.currentTarget),o=n.querySelector(".js-gist-filename");o.value=t.name,g(o),(await d(o)).setCode(s),n.scrollIntoView()}),c("click",".js-remove-gist-file",function(e){e.preventDefault();const t=e.currentTarget.closest(".js-gist-file");for(const s of t.querySelectorAll(".js-gist-deleted input"))s.disabled=!1;t.querySelector(".js-code-editor").remove()});function y(e){const t=e.querySelectorAll(".js-remove-gist-file");for(const s of t)s.classList.toggle("d-none",t.length<2)}a(y,"updateRemoveButtonVisibility"),j(".js-remove-gist-file",function(e){const t=e.closest(".js-gist-files");return{add(){y(t)},remove(){y(t)}}});var I=Object.defineProperty,m=(e,t)=>I(e,"name",{value:t,configurable:!0});h(".js-quicksearch-field",A),S(".js-quicksearch-field",C),c("navigation:keydown",".js-quicksearch-results",R),c("submit",".js-quicksearch-form",F),c("focusout:delay",".js-quicksearch-field",function(e){const s=e.currentTarget.closest("form").querySelector(".js-quicksearch-results");s&&(s.classList.remove("active"),p(s))});function A(e){E(e.form.querySelector(".js-quicksearch-results"))}m(A,"bindQuickSearchEvents");function F(e){const t=e.currentTarget.querySelector(".js-quicksearch-results");t&&(t.classList.remove("active"),p(t))}m(F,"teardown");function R(e){const t=e,s=t.target,n=s.closest("form");if(t.detail.hotkey==="Escape"){const o=n.querySelector(".js-quicksearch-results");o.classList.remove("active"),L(o)}else t.detail.hotkey==="Enter"&&!s.classList.contains("js-navigation-item")&&(T(n),t.preventDefault())}m(R,"onNavigationKeyDown");let q=null;async function C(e){const t=e.target,s=t.value.replace(/^\s+|\s+$/g,""),n=t.closest("form"),o=n.querySelector(".js-quicksearch-results"),l=o.getAttribute("data-quicksearch-url");let i="";q==null||q.abort();const{signal:u}=q=new AbortController;if(s.length){const f=new URL(l,window.location.origin),P=new URLSearchParams(f.search.slice(1));P.append("q",s),f.search=P.toString(),n.classList.add("is-sending");try{const $=await fetch(f.toString(),{signal:u});$.ok&&(i=await $.text())}catch{}}u.aborted||(i&&(o.innerHTML=i),o.classList.toggle("active",s!==""),n.classList.remove("is-sending"))}m(C,"fetchResults"),_(".js-gist-file-update-container .js-comment-update",async function(e,t){let s;try{s=await t.json()}catch{return}if(e.action=s.json.url,s.json.authenticity_token){const n=e.querySelector("input[name=authenticity_token]");n.value=s.json.authenticity_token}}),j(".js-gist-dropzone",()=>{D.import("./chunk-drag-drop.js")})}}});
//# sourceMappingURL=gist-2b478f35.js.map
