You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

2 lines
52 KiB

System.register(["./chunk-vendor.js","./chunk-frameworks.js"],(function(){"use strict";var e,t,n,s,o,r,c,i,l,a,u,d,m,g,f,h,b,p,j,y,S,v,q,A,L,w,E,T,x,k,_;return{setters:[function(r){e=r.o,t=r.a,n=r.r,s=r.I,o=r.f},function(e){r=e.e,c=e.aD,i=e.n,l=e.f,a=e.aE,u=e.c,d=e.C,m=e.a,g=e.aF,f=e.p,h=e.aG,b=e.aH,p=e.aI,j=e.aJ,y=e.as,S=e.aK,v=e.H,q=e.a3,A=e.i,L=e.al,w=e.aj,E=e.s,T=e.G,x=e.B,k=e.X,_=e.aL}],execute:function(){const C=()=>{const e=document.querySelector(".js-branches-list"),t=document.querySelector("#spoof-warning"),n=document.querySelector(".commit-title");e&&(e.parentElement.hidden=!0,t.hidden=!1,t.removeAttribute("aria-hidden"),n.classList.add("pb-1"))},I=document.querySelector("#async-branches-list");function H(e,t){return Array.from(document.querySelectorAll(".js-details-container.open.Details--on")).filter((n=>n.getAttribute(e)===t))}function M(e,t,n,s,o){const i=document.querySelector(".js-file-filter"),l=new URL(window.location.href,window.location.origin);if(!e&&!s){if(t)return;return l.search="",r(c(),"",l.toString())}const a=i.querySelector(".js-file-filter-form"),u=new FormData(a),d=n.filter((e=>!u.getAll("file-filters[]").includes(e))),m=o.filter((e=>!u.getAll("owned-by[]").includes(e)));for(const r of d)u.append("file-filters[]",r);for(const r of m)u.append("owned-by[]",r);const g=new URLSearchParams(u);g.has("file-filters[]")&&""!==g.toString()||g.set("file-filters[]",""),t&&g.set("w","1"),l.search=g.toString(),r(c(),"",l.toString())}function R(e){var t;t=e,document.querySelector(".js-file-filter-text").classList.toggle("text-blue",t),function(e){const t=document.querySelector(".js-reset-filters"),n=document.querySelector(".js-commits-filtered");null==t||n||(t.hidden=!e)}(e),function(){const e=P(),t=V();for(const o of e)if(t){const e="0"===o.getAttribute("data-non-deleted-files-count");o.disabled=e}else o.disabled=!1;const n=document.querySelector(".js-deleted-files-container"),s=F();if(s&&n){const t=function(e){const t=e.find((e=>e.checked&&"0"!==e.getAttribute("data-deleted-files-count")));return Boolean(t)}(Array.from(e));n.classList.toggle("text-gray",!t),s.disabled=!t}}(),function(){const e=O(),t=document.querySelector(".js-file-filter-select-all-container"),n=e?"data-select-all-markup":"data-all-selected-markup",s=t.getAttribute(n);t.textContent=s,t.classList.toggle("text-gray",!e),t.classList.toggle("text-blue",e)}(),function(){const e=document.querySelector(".js-deleted-files-container");if(e){const t=V()?"data-show-deleted-markup":"data-hide-deleted-markup",n=e.getAttribute(t);e.textContent=n}}(),function(){const e=document.querySelectorAll(".js-file-type-count");for(const t of e){const e=V()?"data-non-deleted-file-count-markup":"data-all-file-count-markup",n=t.getAttribute(e);n&&(t.textContent=n)}}(),M(e,X(),D(),U(),N())}function $(e){!function(){const e=F(),t=D(),n=document.querySelectorAll(".js-file"),s=N(),o=B();for(const r of n){let n=!0;const c=r.getAttribute("data-file-type");if(c&&(n=t.includes(c)),o&&n){r.hasAttribute("data-file-user-viewed")&&(n=!o.checked)}if(s.length>0&&n){n=(r.getAttribute("data-codeowners")||"").split(",").filter((e=>s.includes(e))).length>0}if(e&&e.checked&&n){"true"===r.getAttribute("data-file-deleted")&&(n=!1)}K(r,n)}}(),R(e)}function D(){return Array.from(P()).filter((e=>e.checked)).map((e=>e.value))}function P(){return document.querySelectorAll(".js-diff-file-type-option")}function F(){const e=document.querySelector(".js-deleted-files-toggle");if(e instanceof HTMLInputElement)return e}function B(){const e=document.querySelector(".js-viewed-files-toggle");if(e instanceof HTMLInputElement)return e}function W(){return O()||V()||U()}function U(){return N().length>0}function N(){return Array.from(document.querySelectorAll(".js-diff-owner-option")).filter((e=>e.checked)).map((e=>e.value))}function O(){return D().length!==P().length}function X(){return new URLSearchParams(window.location.search).has("w")}function V(){const e=F();return!!e&&e.checked}function K(e,t){const n=e.closest(".js-file.js-details-container");n.classList.toggle("open",t),n.classList.toggle("Details--on",t)}function G(e){const t=P();for(const n of t)n.checked=e}function J({currentTarget:e}){const t=e,n=t.hasAttribute("open");t.closest(".js-file-header").classList.toggle("has-open-dropdown",n)}I&&I.addEventListener("include-fragment-replaced",C),e("change",".js-diff-file-type-option",(function(){$(W())})),e("change",".js-diff-owner-option",(function(){$(U())})),e("click",".js-file-filter-select-all",(function(){O()&&(G(!0),$(W()))})),e("change",".js-deleted-files-toggle",(function(){$(W())})),e("change",".js-viewed-files-toggle",(function(){$(W())})),t(".js-file-filter",(function(){W()?R(!0):M(!1,X(),D(),U(),N())})),e("click",".js-file-header .js-details-target",(function({currentTarget:e}){if(!document.querySelector(".js-file-filter"))return;const t=e.closest(".js-details-container"),n=function(e){const t=e.getAttribute("data-file-type"),n=H("data-file-type",t),s=Array.from(document.querySelectorAll(".js-diff-file-type-option")).find((e=>e.value===t));if(!s)return!1;const o=s.checked!==n.length>0;return o&&(s.checked=n.length>0),o}(t),s=F();let o=!1;s&&(o=function(e,t){let n=!1;if("true"===e.getAttribute("data-file-deleted")){const e=H("data-file-deleted","true");n=t.checked!==(0===e.length),n&&(t.checked=0===e.length)}return n}(t,s));const r=B();let c=!1;r&&(c=function(e,t){let n=!1;if("true"===e.getAttribute("data-file-user-viewed")){const e=H("data-file-user-viewed","true");n=t.checked!==(0===e.length),n&&(t.checked=0===e.length)}return n}(t,r)),(n||o||c)&&R(W())})),e("details:toggled-group",".js-file.js-details-container",(function(e){e.target===e.currentTarget&&function(e){if(!document.querySelector(".js-file-filter"))return;G(e);const t=F();t&&(t.checked=!e),R(W())}(e.detail.open)})),e("details:toggled",".js-file.js-details-container",(function(e){if(e.target!==e.currentTarget)return;const t=e.currentTarget;t.getBoundingClientRect().top<0&&a(t)})),i((()=>{const e=window.location.hash.slice(1);if(!e)return;const t=document.getElementsByName(e)[0];if(!t)return;const n=t.nextElementSibling;n&&n.matches(".js-file.js-details-container")&&(n.classList.add("open"),n.classList.add("Details--on"))})),t(".js-file-header-dropdown",{subscribe:e=>l(e,"toggle",J)});const Q="```suggestion",Y="```",z=new RegExp("```suggestion(?:.*)\n","i"),Z=new RegExp("```(\n|$)");function ee(e,t){const n=e.slice(0,t).split("\n");return e.split("\n")[n.length-1]}function te(e){const t=/^(\s+)/.exec(e);return t&&t[0]||""}function ne(e,t,n=0){const s=t.substring(n,t.length),o=e.exec(s);return o?o.index+n:-1}function se(e,t){const n=[];let s=0,o=-1;for(;(o=ne(z,e,s))>-1;){s=o+Q.length;const t=ne(Z,e,s);if(-1===t)return!1;s=t+Y.length,n.push([o,t])}return n.some((e=>t>e[0]&&t<e[1]))}function oe(e,t){const n=function(e){let t="```suggestion\n";return t+=e+"\n",t+=Y,t}(e),s=t.selectionStart,o=t.value,r=ne(/\n/,o,s),c=""===o.trim(),i=ee(o,s),l=""===i.trim(),a="\n```".length;let d=o,m=0;if(c)d=n,m=d.length-a;else if(-1===r)l?(d=o+n,m=d.length-a):(d=[o,n].join("\n"),m=d.length-a);else if(l){const e=s-te(i).length,t=o.substring(0,e),c=o.substring(r,o.length);d=[t,n,c].join(""),m=d.length-c.length-a}else if(se(o,s)){const e=ne(/```/,o,s)+3,t=o.substring(0,e),r=o.substring(e,o.length);d=[t,"\n",n,r].join(""),m=d.length-r.length-a}else{const e=o.substring(0,r),t=o.substring(r,o.length);d=[e,"\n",n,t].join(""),m=d.length-t.length-a}u(t,d),t.focus(),t.setSelectionRange(m,m)}const re=".js-add-to-batch-enabled",ce=".js-unchanged-suggestion",ie=".js-closed-pull",le=".js-viewing-subset-changes",ae=".js-validation-on-left-blob",ue=".js-validation-on-right-blob",de=".js-outdated-comment",me=".js-resolved-thread",ge=".js-pending-review";function fe(e,t){const n=document.querySelectorAll(".js-apply-suggestion-button"),s=e.querySelector(".js-disabled-apply-suggestion-button");for(const o of n){const e=s.cloneNode(!0);be(e,t),o.closest("details").replaceWith(e)}}function he(e){const t=document.querySelector(".js-batched-suggested-changes-container");t&&t.classList.add("d-none");for(const n of document.querySelectorAll(".js-apply-single-suggestion"))n.classList.remove("d-none"),n.disabled=!0,n.setAttribute("aria-label",e);for(const n of document.querySelectorAll(".js-batched-suggested-changes-add"))n.classList.remove("d-none"),n.disabled=!0,n.setAttribute("aria-label",e);for(const n of document.querySelectorAll(".js-batched-suggested-changes-remove"))n.classList.add("d-none");for(const n of document.querySelectorAll(".js-focus-commit-suggestions-form-button"))n.classList.add("d-none");for(const n of document.querySelectorAll(".pending-batched-suggestion-label"))n.classList.add("d-none")}function be(e,t){e.setAttribute("aria-label",t),e.classList.remove("d-none")}function pe(e,t){const n=document.querySelector(".js-suggested-changes-inline-validation-template").cloneNode(!0);n.classList.remove("js-suggested-changes-inline-validation-template");n.querySelector(".js-suggested-changes-inline-error-message").textContent=e.trim();t.parentNode.insertBefore(n,t.nextSibling)}function je(e){if(!document.querySelector(".js-suggested-changes-subset-files"))return;const t=e.querySelectorAll(".js-suggested-change-toolbar-item"),n=le,s=document.querySelector(n).textContent.trim();for(const o of t)o.disabled=!0,o.setAttribute("aria-label",s)}function ye(){const e=document.querySelector(".js-batched-suggested-changes-container");e&&setTimeout((()=>function(e){const t=e.closest(".js-review-state-classes").querySelectorAll("[data-pending-batched-suggestion]").length;for(const s of document.querySelectorAll(".js-pending-batched-suggested-changes-count"))s.textContent=String(t);const n=document.querySelector(".js-reenable-add-to-batch").textContent;for(const s of document.querySelectorAll("[data-batched-suggestion-reenable-sibling]"))s.removeAttribute("data-batched-suggestion-reenable-sibling"),s.removeAttribute("disabled"),s.setAttribute("aria-label",n);if(t>0){e.hidden=!1;const t=e.querySelector(".js-batched-suggested-changes-toggle");t.classList.add("anim-pulse-in"),t.addEventListener("animationend",(()=>t.classList.remove("anim-pulse-in")),{once:!0});for(const e of document.querySelectorAll(".js-apply-single-suggestion"))e.classList.add("d-none");for(const e of document.querySelectorAll(".js-batched-suggested-changes-add")){const t=e.closest(".js-suggested-change-form-container");"true"===t.getAttribute("data-pending-batched-suggestion")||"true"===t.getAttribute("data-comment-pending")||"true"===t.getAttribute("data-outdated-comment")?e.classList.add("d-none"):e.classList.remove("d-none"),"true"===e.getAttribute("data-batched-suggestion-disabled-by-sibling")&&(e.removeAttribute("data-batched-suggestion-disabled-by-sibling"),e.setAttribute("disabled","disabled"),e.setAttribute("aria-label",document.querySelector(".js-one-suggestion-per-line").textContent))}for(const e of document.querySelectorAll(".js-batched-suggested-changes-remove"))"true"===e.closest(".js-suggested-change-form-container").getAttribute("data-pending-batched-suggestion")?e.classList.remove("d-none"):e.classList.add("d-none");for(const e of document.querySelectorAll(".js-focus-commit-suggestions-form-button")){const t=e.closest(".js-suggested-change-form-container"),n="true"===t.getAttribute("data-comment-pending"),s="true"===t.getAttribute("data-outdated-comment"),o="true"===t.getAttribute("data-resolved-comment"),r="left"===e.closest(".js-inline-comments-container").querySelector('input[name="side"]').value;n||s||o||r?e.classList.add("d-none"):e.classList.remove("d-none")}for(const e of document.querySelectorAll(".pending-batched-suggestion-label"))"true"===e.closest(".js-suggested-change-form-container").getAttribute("data-pending-batched-suggestion")?e.classList.remove("d-none"):e.classList.add("d-none")}else{e.hidden=!0;for(const e of document.querySelectorAll(".js-apply-single-suggestion"))e.classList.remove("d-none");for(const e of document.querySelectorAll(".js-batched-suggested-changes-add"))e.classList.remove("d-none");for(const e of document.querySelectorAll(".js-batched-suggested-changes-remove"))e.classList.add("d-none");for(const e of document.querySelectorAll(".js-focus-commit-suggestions-form-button"))e.classList.add("d-none");for(const e of document.querySelectorAll(".pending-batched-suggestion-label"))e.classList.add("d-none")}}(e)))}function Se(e,t){const n=e.querySelector("input[name=commit_title]"),s=e.querySelector("textarea[name=commit_message]");let o=n.value.trim();""===o&&(o=n.defaultValue);const r=s.value.trim();""!==r&&(o=`${o}\n\n${r}\n`),n.disabled=!0,s.disabled=!0;const c=document.createElement("input");c.setAttribute("type","hidden"),c.setAttribute("name","message"),c.value=o,e.appendChild(c);const i=document.createElement("input");i.setAttribute("type","hidden"),i.setAttribute("name","changes"),i.value=JSON.stringify(t),e.appendChild(i)}function ve(e,t){const n=e.nextElementSibling;return n&&n.matches(t)?n:null}function qe(e){const t=e.querySelector(".js-toggle-file-notes");t instanceof HTMLInputElement&&u(t,!0)}function Ae(){for(const e of document.querySelectorAll(".file .js-inline-comments-container")){const t=e.querySelectorAll(".js-comments-holder > *").length>0,n=e.querySelector(".js-inline-comment-form-container"),s=!!n&&n.classList.contains("open");t||s||e.remove()}}function Le(e){const t=document.querySelector(e).firstElementChild.cloneNode(!0),n=t.querySelector("textarea");return n instanceof HTMLTextAreaElement&&(n.value=""),t}async function we(e){const t=e.querySelector(".js-suggestion-button-placeholder");if(!t)return;const n=t.getAttribute("data-src-base");if(!n)return;const s=new URL(n,window.location.origin),o=t.closest(".js-inline-comment-form")||t.closest(".js-comment-update");if(!(o instanceof HTMLFormElement))return;const r=function(e,t){const n=new URLSearchParams(e.search.slice(1)),s=t.elements.namedItem("in_reply_to")||t.elements.namedItem("comment_id");if(s instanceof HTMLInputElement&&s.value)return n.append("comment_id",s.value),n;const o=t.elements.namedItem("path"),r=t.elements.namedItem("start_side"),c=t.elements.namedItem("start_line"),i=t.elements.namedItem("side"),l=t.elements.namedItem("line"),a=t.elements.namedItem("start_commit_oid"),u=t.elements.namedItem("end_commit_oid"),d=t.elements.namedItem("base_commit_oid");return o instanceof HTMLInputElement&&r instanceof HTMLInputElement&&c instanceof HTMLInputElement&&i instanceof HTMLInputElement&&l instanceof HTMLInputElement&&a instanceof HTMLInputElement&&u instanceof HTMLInputElement&&d instanceof HTMLInputElement?(n.append("path",o.value),n.append("start_side",r.value),n.append("start_line",c.value),n.append("end_side",i.value),n.append("end_line",l.value),n.append("start_commit_oid",a.value),n.append("end_commit_oid",u.value),n.append("base_commit_oid",d.value),n):null}(s,o);if(!r)return;s.search=r.toString();const c=await m(document,s.toString());t.innerHTML="",t.appendChild(c)}function Ee(e,t,n,s){if(e.classList.remove("bg-green-light","bg-red-light"),!s)return"right"===n?(e.classList.add("color-green-6"),void(e.textContent="+"+t)):"left"===n?(e.classList.add("text-red"),void(e.textContent="-"+t)):void(e.textContent=String(t));e.textContent=t}e("click",".js-suggested-change-toolbar-item",(function(e){const t=e.currentTarget;t instanceof HTMLButtonElement&&!t.disabled&&function(e){const t=e.getAttribute("data-lines");null!=t&&oe(t,e.closest(".js-suggested-changes-container").querySelector(".js-comment-field"))}(t)})),e("click",".js-refresh-after-suggestion",(function(){window.location.reload()})),t(".js-inline-comments-container",{add(e){je(e)}}),t(".js-preview-body .js-apply-changes",{add(e){const t=e.closest(".js-suggested-changes-container");if(!t)return e.remove();const n=document.querySelector(ue).textContent,s=document.querySelector(ae).textContent,o=e.closest(".js-suggested-changes-blob");if(""!==t.getAttribute("data-thread-side")){if("left"===t.getAttribute("data-thread-side"))return pe(s,o),e.remove()}else{const t=e.closest(".js-inline-comment-form"),n=t.querySelector('input[name="side"]');if(!t||!n)return e.remove();if(t&&"left"===n.value)return pe(s,o),e.remove()}const r=e.previousElementSibling,c=r.querySelector(".js-blob-code-deletion"),i=r.querySelectorAll(".js-blob-code-addition");if(!c||0===i.length)return;if(c.textContent===Array.from(i).map((e=>e.textContent)).join("\n"))return pe(n,o),e.remove();e.remove()}}),t(".js-comment-body .js-apply-changes",{add(e){const t=e.closest(".js-suggested-changes-container");if(!t)return e.remove();const n=t.querySelector(".js-suggested-changes-template");if(!(n instanceof HTMLTemplateElement))return e.remove();const s=n.content.cloneNode(!0),o=s.querySelector(".js-disabled-apply-suggestion-button");let r;try{r=s.querySelector(".js-batched-suggested-changes-add")}catch(h){if("QueryError"!==h.name)throw h}if(document.querySelectorAll(".js-suggested-changes-files-tab").length){const e=document.querySelector(re).textContent;r&&(r.removeAttribute("disabled"),r.setAttribute("aria-label",e))}const c=document.querySelector(".js-pull-header-details"),i=c&&"true"===c.getAttribute("data-pull-is-open"),l=e.closest(".js-resolvable-timeline-thread-container"),a="true"===n.getAttribute("data-comment-pending"),u=t.classList.contains("js-selection-contains-deletions");if(l&&"true"===l.getAttribute("data-resolved")){const t=document.querySelector(me).textContent,n=s.querySelector("details");return n&&n.remove(),be(o,t),r&&(r.setAttribute("disabled","disabled"),r.setAttribute("aria-label",t)),e.replaceWith(s)}if(!i){const t=document.querySelector(ie).textContent;return be(o,t),r&&(r.setAttribute("disabled","disabled"),r.setAttribute("aria-label",t)),e.replaceWith(s)}if(a){const t=document.querySelector(ge).textContent;return s.querySelector("details").remove(),be(o,t),r&&(r.setAttribute("disabled","disabled"),r.setAttribute("aria-label",t)),e.replaceWith(s)}if(u){const t=document.querySelector(ae).textContent;return s.querySelector("details").remove(),be(o,t),r&&(r.setAttribute("disabled","disabled"),r.setAttribute("aria-label",t)),e.replaceWith(s)}const d=document.querySelector(".js-suggested-changes-subset-files"),m="true"===n.getAttribute("data-outdated-comment");if(d||m){let t;return d?t=document.querySelector(le).textContent:m&&(t=document.querySelector(de).textContent),s.querySelector("details").remove(),be(o,t),r&&(r.setAttribute("disabled","disabled"),r.setAttribute("aria-label",t)),e.replaceWith(s)}const g=s.querySelector(".js-single-suggested-change-form"),f=e.closest(".js-suggested-changes-blob");if(f){const e=f.querySelector(".js-blob-code-deletion"),t=f.querySelectorAll(".js-blob-code-addition");if(!e)return;const n=e.textContent,c=Array.from(t).map((e=>e.textContent));if(c.length>0&&n===c.join("\n")){const e=document.querySelector(ce).textContent;s.querySelector("details").remove(),be(o,e),r&&(r.setAttribute("disabled","disabled"),r.setAttribute("aria-label",e))}else for(const s of c){const e=document.createElement("input");e.setAttribute("type","hidden"),e.setAttribute("name","value[]"),e.value=s,g.appendChild(e)}}e.replaceWith(s)}}),t(".js-pull-header-details",{add(e){const t="true"===e.getAttribute("data-pull-is-open"),n=document.querySelector(".js-suggested-changes-template");if(t||!(n instanceof HTMLTemplateElement))return;const s=n.content,o=document.querySelector(ie).textContent;fe(s,o),he(o)}}),t(".js-suggested-changes-subset-files",{add(){const e=document.querySelector(".js-suggested-changes-template");if(!(e instanceof HTMLTemplateElement))return;const t=e.content,n=document.querySelector(le).textContent;fe(t,n),he(n)}}),e("click",".js-apply-suggestion-button",(async function(e){const t=e.currentTarget.parentElement;if(t){const e=t.querySelector(".js-suggestion-commit-title");setTimeout((()=>e.focus()),1)}})),e("click",".js-dismiss-suggested-change-onboarding-notice",(async function(e){const t=e.currentTarget.getAttribute("data-url"),n=e.currentTarget.parentElement.querySelector(".js-data-url-csrf"),s=new FormData;s.append("notice","suggested_changes_onboarding_prompt");if((await fetch(t,{method:"POST",mode:"same-origin",body:s,headers:{"Scoped-CSRF-Token":n.value,"X-Requested-With":"XMLHttpRequest"}})).ok){const e=document.querySelectorAll(".js-suggested-change-onboarding-notice");for(const t of e)t.remove()}})),d("keypress",".js-comment-field",(function(e){if("Enter"===e.key){(function(e){const t=e.selectionStart;if(!se(e.value,t))return!1;const n=e.value,s=ee(n,t);if(null===s)return!1;const o="\n"+te(s),r=n.substr(0,t)+o+n.substr(t);u(e,r);const c=t+o.length;return e.setSelectionRange(c,c),!0})(e.target)&&e.preventDefault()}})),d("keypress",".js-suggestion-commit-message",(function(e){const t=e.currentTarget;"Enter"===e.key&&t.setAttribute("rows","3")})),e("click",".js-batched-suggested-changes-add",(function(e){const t=e.target,n=t.closest(".js-suggested-change-form-container");if("true"===n.getAttribute("data-comment-pending")||"true"===n.getAttribute("data-outdated-comment")||"true"===t.getAttribute("data-batched-suggestion-disabled-by-sibling"))return;n.setAttribute("data-pending-batched-suggestion","true");const s=t.closest(".js-inline-comments-container");for(const o of s.querySelectorAll(".js-batched-suggested-changes-add"))o.setAttribute("data-batched-suggestion-disabled-by-sibling","true");t.removeAttribute("data-batched-suggestion-disabled-by-sibling"),ye()})),e("click",".js-batched-suggested-changes-remove",(function(e){e.currentTarget.closest(".js-suggested-change-form-container").removeAttribute("data-pending-batched-suggestion");const t=e.currentTarget.closest(".js-inline-comments-container");for(const n of t.querySelectorAll(".js-batched-suggested-changes-add"))n.setAttribute("data-batched-suggestion-reenable-sibling","true");ye()})),e("click",".js-focus-commit-suggestions-form-button",(function(e){e.preventDefault(),window.location.href="#clear-commit-suggestions",window.location.href="#commit-suggestions"})),e("click",".js-dismiss-batched-suggested-changes-onboarding-notice",(async function(e){const t=e.currentTarget.getAttribute("data-url"),n=e.currentTarget.parentElement.querySelector(".js-data-url-csrf"),s=new FormData;s.append("notice","batched_suggested_changes_onboarding_prompt");if((await fetch(t,{method:"POST",mode:"same-origin",body:s,headers:{"Scoped-CSRF-Token":n.value,"X-Requested-With":"XMLHttpRequest"}})).ok)for(const o of document.querySelectorAll(".js-batched-suggested-change-onboarding-notice"))o.remove()})),e("click",".js-single-suggested-change-form .js-suggested-changes-submit",(function(e){const t=e.currentTarget.closest(".js-single-suggested-change-form"),n=Array.from(t.querySelectorAll('input[name="value[]"]')).map((e=>e.value)),s=[{commentId:t.querySelector("input[name=comment_id]").value,path:t.querySelector("input[name=path]").value,suggestion:n}];Se(t,s)})),n(".js-single-suggested-change-form",(async function(e,t){const n=e.closest(".js-suggested-change-form-container"),s=e.closest("details"),o=n.querySelector(".js-suggestion-applied"),r=e.closest(".js-suggested-changes-contents").querySelector(".js-error-message-placeholder");try{await t.json(),o.classList.remove("d-none");n.querySelector(".js-batched-suggested-changes-add").classList.add("d-none"),s.remove(),window.location.reload()}catch(c){if("QueryError"!==c.name){const t=c.response.json&&c.response.json.error,o=r.querySelector(".js-error-message");r.hidden=!1,o.textContent=t,n.prepend(r);e.closest(".js-suggested-change-form-container").querySelector(".js-batched-suggested-changes-add").classList.add("d-none"),s.remove()}}})),e("click",".js-suggestion-batch-submit",(function(e){const t=e.currentTarget.closest(".js-batched-suggested-changes-form"),n=[];for(const s of document.querySelectorAll("[data-pending-batched-suggestion]")){const e=s.querySelector(".js-single-suggested-change-form"),t=Array.from(e.querySelectorAll('input[name="value[]"]')).map((e=>e.value));n.push({commentId:e.querySelector("input[name=comment_id]").value,path:e.querySelector("input[name=path]").value,suggestion:t})}Se(t,n)})),n(".js-batched-suggested-changes-form",(async function(e,t){try{await t.json();e.closest(".js-batched-suggested-changes-container").hidden=!0,window.location.reload()}catch(n){const t=n.response.json&&n.response.json.error,s=e.closest(".js-batched-suggested-changes-container").querySelector(".js-error-message-container");s.querySelector(".js-error-message").textContent=t,s.hidden=!1}})),t(".js-files-tab-stale",{add(){const e=document.querySelector(".js-batched-suggested-changes-container");e&&setTimeout((()=>{e.hidden=!0}))}}),e("click",".js-add-single-line-comment",(function(e){const t=e.currentTarget;qe(t.closest(".file"));const n=function(e){const t=e.closest("tr"),n=ve(t,".js-inline-comments-container");if(n instanceof Element){const e=Array.from(n.querySelectorAll(".js-inline-comment-form")).pop();return e instanceof HTMLFormElement&&xe(e,t.querySelector("button.js-add-line-comment")),n}}(t)||function(e){const t=e.closest("tr"),n=Le("#js-inline-comments-single-container-template"),s=n.querySelector(".js-inline-comment-form");s instanceof HTMLFormElement&&xe(s,e);return t.after(n),n}(t),s=Array.from(n.querySelectorAll(".js-line-comments")).pop();g(s)})),e("click",".js-add-split-line-comment",(function(e){const t=e.currentTarget;qe(t.closest(".file"));const n=t.closest("tr"),s="addition"===t.getAttribute("data-type")?"js-addition":"js-deletion",o=function(e,t,n){const s=e.querySelector(".js-line-comments."+t);if(s){return xe(Array.from(s.querySelectorAll(".js-inline-comment-form")).pop(),n),s}const o=Le("#js-inline-comments-split-form-container-template");o.classList.add(t);const r=o.querySelector(".js-inline-comment-form");r instanceof HTMLFormElement&&xe(r,n);const c=e.querySelectorAll("."+t);c[c.length-1].after(o);for(const i of c)i.remove();return o}(function(e){let t=ve(e,".js-inline-comments-container");return t||(t=Le("#js-inline-comments-split-container-template"),e.after(t),t)}(n),s,t),r=Array.from(o.querySelectorAll(".js-line-comments")).pop();g(r)})),n(".js-inline-comment-form",(async function(e,t){let n;!function(e){const t=e.querySelector(".js-comment-form-error");t&&(t.hidden=!0,t.textContent=null)}(e);try{n=await t.json()}catch(i){if(i.response){let t;try{t=i.response.json}catch(l){}if(t)return void function(e,t){const n=e.querySelector(".js-comment-form-error");let s;s=t.errors?Array.isArray(t.errors)?t.errors.join(", "):t.errors:"There was an error posting your comment.";n.textContent=s,n.style.display="block",n.hidden=!1,n.classList.remove("d-none")}(e,t)}throw i}const s=n.json,o=s.inline_comment,r=e.closest(".js-line-comments");o&&r.querySelector(".js-comments-holder").append(f(document,o));const c=s.inline_comment_thread;c&&r.replaceWith(f(document,c)),h(e)})),document.addEventListener("session:resume",(function(e){const t=e.detail;!function(e){const[t,n]=e.match(/^new_inline_comment_(?:discussion|diff)_(?:[\w-]+)_(\d+)_(\d+)$/)||[];if(!t)return;const s=document.querySelector(`.js-inline-comment-form input[name='in_reply_to'][value='${n}']`);if(!s)return;const o=s.closest(".js-line-comments");o&&g(o)}(t.targetId),function(e){const[t,n]=e.match(/^new_inline_comment_diff_(?:[\w-]+)_(\d+)$/)||[];if(!t)return;const s=document.querySelector(`.js-add-line-comment[data-anchor='${t}'][data-position='${n}']`);s&&s.click()}(t.targetId)})),t(".js-comment",{remove:Ae}),e("inlinecomment:focus",".js-inline-comment-form-container",(function(e){const t=e.target.querySelector(".js-suggested-changes-container");t&&we(t)})),t(".js-suggested-changes-container.is-comment-editing",(e=>{we(e)})),document.addEventListener("inlinecomment:collapse",(()=>{Ae()}));const Te={R:"right",L:"left"};function xe(e,t){const n=["type","path","position","line","side","original-line"];for(const i of n){const n=e.elements.namedItem(i);if(n instanceof HTMLInputElement){const e=t.getAttribute("data-"+i)||"";n.value=e}}!function(e,t){const n=j();if(!n)return;if(n.end.is(n.start))return;if(!b(t,n))return void p();const{start:{lineNumber:s},end:{lineNumber:o}}=n;let{start:{side:r},end:{side:c}}=n;const i=Number(t.getAttribute("data-line")),l=t.getAttribute("data-side");if(i!==o||!n.end.isContext()&&l!==Te[c])return void p();const a=Te[r],u=e.elements.namedItem("start_line"),d=e.elements.namedItem("start_side"),m=e.elements.namedItem("line"),g=e.elements.namedItem("side"),f=e.elements.namedItem("preview_start_side"),h=e.elements.namedItem("preview_side");if(u instanceof HTMLInputElement&&d instanceof HTMLInputElement&&m instanceof HTMLInputElement&&g instanceof HTMLInputElement&&f instanceof HTMLInputElement&&h instanceof HTMLInputElement){u.value=String(s),d.value=a,d.value=f.value=d.value,h.value=g.value;const t=u.value;r=d.value;const o=m.value;c=g.value;const i=e.closest(".js-inline-comment-form-container");if(t&&o){const e=i.querySelector(".js-multi-line-preview"),s=e.querySelector(".js-multi-line-preview-start"),l=e.querySelector(".js-multi-line-preview-end"),a=n.start.isContext(),u=n.end.isContext();Ee(s,t,r,a),Ee(l,o,c,u),e.hidden=!1,i.classList.add("is-multiline")}else i.querySelector(".js-multi-line-preview").hidden=!0,i.classList.remove("is-multiline");je(i)}}(e,t);const s=t.getAttribute("data-position")||"",o=t.getAttribute("data-anchor")||"",r=e.querySelector(".js-comment-field"),c=r.id.replace(/^r\d+ /,"").replace("${anchor}",o).replace("${position}",s);for(const i of e.querySelectorAll(`[for="${r.id}"]`))i.setAttribute("for",c);r.id=c}function ke(e){const t=_e();if(!t)return;Ce(e,t);const n=function(e,t){const n=function(e,t){const n=/^(diff-[0-9a-f]{32})(?:[L|R]\d+)?$/.exec(t);if(!n)return;const s=n[1],o=e.querySelector(`a[name='${s}']`);if(!o)return;const r=o.nextElementSibling;if(r&&!r.querySelector(".js-diff-load-container"))return;return r}(e,t);if(n)return n;return function(e,t){const n=/^(?:r|commitcomment-)(\d+)$/.exec(t);if(!n)return;const s=n[1],o=e.querySelector("#diff-with-comment-"+s);if(!o)return;return o.closest(".js-file")}(e,t)}(e,t);n&&(a(n),Ie(n))}function _e(){return window.location.hash.slice(1)}function Ce(e,t){let n;n=t.match(/^diff-.+[LR]\d+-[LR]\d+/)?y(e.ownerDocument,t.substring(0,t.indexOf("-",5))):y(e.ownerDocument,t),n&&e.contains(n)&&(S(n),a(n))}function Ie(e){const t=e.querySelector(".js-diff-entry-loader"),n=e.querySelector(".js-diff-placeholder"),s=e.querySelector("button.js-diff-load"),o=e.querySelector(".js-button-text");n.setAttribute("fill","url('#animated-diff-gradient')"),o.textContent=s.getAttribute("data-disable-with")||"",s.disabled=!0;const r=new URL(t.getAttribute("data-fragment-url")||"",window.location.origin);return t.src=r.toString(),t.data}function He(e,t,n){const s=Array.from(e.querySelectorAll('[role="menuitem"]'));let o=s.indexOf(t),r=s.indexOf(n);if(-1===o)throw new Error("Couldn't find startIndex in container");if(-1===r)throw new Error("Couldn't find endItem in container");Me(e),s[r].classList.add("is-last-in-range"),o>r&&([o,r]=[r,o]);for(const c of s.slice(o,r+1))c.classList.add("is-range-selected")}function Me(e){for(const t of e.querySelectorAll('[role="menuitem"]'))t.classList.remove("is-range-selected","is-last-in-range")}t(".js-diff-progressive-container",(function(e){ke(e);const t=e.querySelector(".js-diff-progressive-loader");t&&t.addEventListener("load",(function(){ke(e)}))})),t(".js-diff-load-container",(function(e){const t=e.querySelector(".js-diff-entry-loader");t&&t.addEventListener("load",(function(){e.closest(".js-file").classList.remove("hide-file-notes-toggle");const t=_e();t&&Ce(e,t)}))})),e("click",".js-diff-load",(function(e){if(e.target.classList.contains("js-ignore-this"))return;Ie(e.currentTarget.closest(".js-diff-load-container"))})),e("click",".js-rendered, .js-source",(function(e){const t=e.currentTarget;t.classList.contains("selected")?e.preventDefault():(function(e){const t=e.closest(".js-file-header"),n=e.classList.contains("js-rendered"),s=e.classList.contains("js-source"),o=t.getAttribute("data-short-path"),c=t.getAttribute("data-anchor"),i=new URL(window.location.href,window.location.origin),l=new URLSearchParams(i.search.slice(1));i.hash=c,n?l.set("short_path",o):s&&l.delete("short_path");i.search=l.toString(),r(null,"",i.toString())}(t),function(e){for(const t of document.querySelectorAll(".js-rendered, .js-source"))t.classList.remove("selected"),t.removeAttribute("aria-current");e.classList.add("selected"),e.setAttribute("aria-current","true")}(t))})),n(".js-prose-diff-toggle-form",(async function(e,t){const n=e.closest(".js-details-container"),s=n.querySelector(".js-file-content"),o=await t.html();for(;s.lastChild;)s.removeChild(s.lastChild);s.append(o.html),n.classList.toggle("display-rich-diff"),n.classList.toggle("show-inline-notes")})),e("change",".js-diff-style-toggle input",(function(e){if(!(e.target instanceof Element))return;const t=e.target.closest(".js-diff-settings");for(const n of t.querySelectorAll(".js-diff-style-toggle label"))n.classList.toggle("selected")})),e("click",".js-toc-retry",(function(e){if(!(e.target instanceof Element))return;const t=e.target.closest(".select-menu").querySelector("include-fragment"),n=t.getAttribute("src");t.setAttribute("src",""),t.setAttribute("src",n)})),e("details-menu-select",".js-pull-base-branch-menu",(function(){const e=document.querySelector(".js-change-base-template").content.cloneNode(!0);e instanceof DocumentFragment&&v({content:e})}),{capture:!0}),t(".js-diffbar-range-menu .js-diffbar-range-list",{subscribe:function(e){const t=e.closest("details-menu"),n=e.classList.contains("js-diffbar-invert-range");let s=!1;function o(e){s=e.shiftKey,s&&e.preventDefault()}function r(t){if(!s)return;t.preventDefault();const o=t.detail.relatedTarget;if(o.classList.contains("is-range-selected")){t.stopPropagation();const s=e.querySelectorAll(".is-range-selected"),o=n?s.length-1:0,r=n?0:s.length-1,c=s[o],i=s[r],l=e.getAttribute("data-range-url"),a=c.getAttribute("data-parent-commit"),u=i.getAttribute("data-commit"),d=a&&u?`${a}..${u}`:u,m=l.replace("$range",d);q({url:m,container:document.querySelector("#js-repo-pjax-container")})}else t.stopImmediatePropagation(),async function(e,t){function n(n){He(e,t,n.target.closest('[role="menuitem"]'))}He(e,t,t),e.addEventListener("mouseover",n),await new Promise((e=>window.addEventListener("keyup",e,{once:!0}))),e.removeEventListener("mouseover",n),Me(e)}(e,o)}return e.addEventListener("click",o,{capture:!0}),t.addEventListener("details-menu-select",r),{unsubscribe:()=>{e.removeEventListener("click",o,{capture:!0}),t.removeEventListener("details-menu-select",r)}}}}),e("toggle",".js-diffbar-range-menu",(function(e){const t=e.currentTarget;if(!t.hasAttribute("open"))return;const n=t.querySelector(".in-range");n&&n.focus()}),{capture:!0}),e("click",".js-compare-tab",(function(e){for(const n of document.querySelectorAll(".js-compare-tab.selected"))n.classList.remove("selected");e.currentTarget.classList.add("selected");for(const n of document.querySelectorAll("#commits_bucket, #files_bucket, #commit_comments_bucket"))n.classList.add("d-none");const t=e.currentTarget.hash;document.querySelector(t).classList.remove("d-none"),e.preventDefault()})),i((function({target:e}){if(!(e instanceof HTMLElement))return;const t=e.closest("#commits_bucket, #files_bucket, #commit_comments_bucket");t&&t instanceof HTMLElement&&!A(t)&&document.querySelector(`.js-compare-tab[href="#${t.id}"]`).click()})),e("click",".js-toggle-range-editor-cross-repo",(function(){document.querySelector(".js-range-editor").classList.toggle("is-cross-repo")})),e("pjax:click",".js-range-editor",(function(e){const t=document.querySelector(".js-compare-pr");if(t&&t.classList.contains("open")){const t=e.detail.options,n=new URL(t.url,window.location.origin);n.search.match(/expand=1/)||(n.search+=(n.search?"&":"")+"expand=1",t.url=n.toString())}})),t(".js-compare-pr.open",{add(){document.body.classList.add("is-pr-composer-expanded")},remove(){document.body.classList.remove("is-pr-composer-expanded")}}),e("change",".js-collab-checkbox",(function({currentTarget:e}){const t=e.form;for(const s of t.querySelectorAll(".errored"))s.classList.remove("errored");const n=e.closest(".js-collab-option").querySelector(".js-status-indicator");n.classList.remove("status-indicator-success","status-indicator-failed"),n.classList.add("status-indicator-loading")})),n(".js-collab-form",(async function(e,t){try{await t.text()}catch(n){for(const t of e.querySelectorAll(".status-indicator-loading")){t.classList.remove("status-indicator-loading"),t.classList.add("status-indicator-failed");const e=t.closest(".js-collab-option");e.classList.add("errored");const n=e.querySelector(".js-collab-checkbox");n.checked=!n.checked}for(const t of e.querySelectorAll(".status-indicator-success"))t.classList.remove("status-indicator-success");return}for(const s of e.querySelectorAll(".errored"))s.classList.remove("errored");for(const s of e.querySelectorAll(".status-indicator-loading"))s.classList.remove("status-indicator-loading"),s.classList.add("status-indicator-success")})),t(".js-timeline-item > .js-commit-group",{constructor:HTMLElement,add(e){if(e.querySelector(".js-commit-group-header"))return;const t=e.closest(".js-timeline-item");if(!(t instanceof HTMLElement))return;let n=t.previousElementSibling;n instanceof HTMLElement&&(n.classList.contains("js-timeline-item")||(n=n.previousElementSibling,n instanceof HTMLElement))&&n.querySelector(".js-commit-group")&&function(e,t){const n=e.querySelector(".js-commit-group-commits"),s=t.querySelectorAll(".js-commit-group-commits > .js-commit");for(const r of s)r.classList.toggle("py-3"),n.appendChild(r);const o=e.querySelector(".js-commit-group-count");o instanceof HTMLElement&&(o.textContent=""+n.querySelectorAll(".js-commit").length),t.remove()}(n,t)}}),e("details:toggled",".js-pull-merging",(function({currentTarget:e}){const t=Array.from(e.querySelectorAll(".js-merge-pull-request")),n=t.some(A);for(const s of t)s.classList.toggle("is-dirty",n)})),e("click",".js-merge-box-try-again",(async function({currentTarget:e}){const t=e.getAttribute("data-form-target");if(!["js-cleanup-branch-form","js-merge-branch-form","js-queue-branch-form","js-update-branch-form"].includes(t))return;const n=e.closest(".js-pull-merging").getElementsByClassName(t)[0];o(n,"submit")})),document.addEventListener("session:resume",(function(e){const t=document.getElementById(e.detail.targetId);if(t){const e=t.closest(".js-merge-pull-request");if(e){const t=e.closest(".js-details-container");t&&t.classList.add("open")}}})),e("change",".js-merge-button-toggle",(function({currentTarget:e}){const t=e.closest(".js-merge-pr"),n=!e.checked;for(const s of t.querySelectorAll(".js-merge-commit-button"))s.disabled=n})),e("change",".js-auto-merge-admin-override",(function({currentTarget:e}){const t=e.closest(".js-merge-message-container"),n=e.checked,s=t.querySelector(".js-merge-box"),o=t.querySelector(".js-auto-merge-box"),r=t.querySelector(".js-merge-form"),c=t.querySelector(".js-auto-merge-form"),i=t.querySelectorAll(".js-merge-menu-item"),l=t.querySelectorAll(".js-auto-merge-menu-item");if(s.hidden=!n,o.hidden=n,r.hidden=!n,c.hidden=n,n)for(let a=0;a<l.length;a++){const e=l[a].getAttribute("aria-checked");null!==e&&i[a].setAttribute("aria-checked",e)}else for(let a=0;a<i.length;a++){const e=i[a].getAttribute("aria-checked");null!==e&&l[a].setAttribute("aria-checked",e)}})),e("details-menu-selected",".js-merge-method-menu",(function(e){const t=e.detail.relatedTarget,n=t.closest(".js-merge-pr"),s=n.querySelector(".js-merge-pull-request"),o=n.querySelector(".js-auto-merge-admin-override"),r=n.querySelector(".js-merge-method-menu-button"),c=r.getAttribute("data-merge-button-class");r.classList.toggle("btn-danger",t.hasAttribute("data-dangerous-action")),c&&r.classList.toggle(c,!t.hasAttribute("data-dangerous-action"));const i=n.querySelector(".js-merge-title"),l=n.querySelector(".js-merge-message");i.defaultValue===i.value&&(i.defaultValue=i.value=t.getAttribute("data-input-title-value"));l.defaultValue===l.value&&(l.defaultValue=l.value=t.getAttribute("data-input-message-value"));n.classList.toggle("is-merging","merge"===t.value),n.classList.toggle("is-squashing","squash"===t.value),n.classList.toggle("is-rebasing","rebase"===t.value),n.classList.toggle("is-merging-group","group"===t.value),n.classList.toggle("is-merging-solo","solo"===t.value),n.classList.toggle("is-merging-jump","jump"===t.value);const a=s.classList.contains("js-admin-override-merge")&&"merge"===t.value||s.classList.contains("js-admin-override-squash")&&"squash"===t.value||s.classList.contains("js-admin-override-rebase")&&"rebase"===t.value,u=n.querySelectorAll(".js-admin-override");for(const p of u)p.hidden=!a||null!==o;const d=n.querySelector(".js-merge-type");d&&(d.value=t.value);const m=a&&!n.querySelector(".js-merge-button-toggle").checked,g=n.querySelectorAll(".js-merge-pull-request .js-merge-commit-button");for(const p of g)p.type=t.value===p.value?"submit":"button",p.disabled=m;s.classList.toggle("text-red",a);const f=n.closest(".js-pull-merging"),h=new URL(f.getAttribute("data-url"),window.location.origin),b=new URLSearchParams(h.search);b.set("merge_type",t.value),h.search=b.toString(),f.setAttribute("data-url",h.toString())}),{capture:!0}),e("details:toggled",".js-merge-pr",(function(e){const t=e.currentTarget.querySelector(".js-merge-message");t&&o(t,"change")})),t(".branch-action-item.js-details-container.open",{add(e){for(const t of e.querySelectorAll(".js-merge-review-section"))t.setAttribute("open","")},remove(e){for(const t of e.querySelectorAll(".js-merge-review-section"))t.removeAttribute("open")}}),e("toggle",".js-details-container .js-merge-review-section",(function({currentTarget:e}){const t=e.closest(".js-details-container"),n=t.querySelectorAll(".js-merge-review-section").length,s=t.querySelectorAll(".js-merge-review-section[open]").length,o=s===n;0===s?L(t,{force:!1}):o&&L(t,{force:!0})}),{capture:!0}),t("poll-include-fragment[data-to-be-polled]",{constructor:s,add(e){function t(){e.src=e.getAttribute("data-to-be-polled"),e.removeAttribute("data-to-be-polled")}document.hidden?document.addEventListener("visibilitychange",t,{once:!0}):t()}});let Re=!1;function $e(){const e=document.querySelectorAll(".pull-request-ref-restore");for(let t=0;t<e.length;t++)e[t].classList.toggle("last",t===e.length-1)}function De(){const e=null!=document.querySelector("#js-pull-restorable"),t=document.querySelector(".js-pull-discussion-timeline");t&&t.classList.toggle("is-pull-restorable",e)}function Pe(){const e=document.querySelector(".js-reviews-container");e&&setTimeout((()=>function(e){const t=e.closest(".js-review-state-classes"),n=t.querySelectorAll(".js-pending-review-comment").length,s=document.querySelector(".js-review-changes");t.classList.toggle("is-review-pending",n>0);for(const o of document.querySelectorAll(".js-pending-review-comment-count"))o.textContent=String(n);for(const o of document.querySelectorAll(".js-pending-comment-count-type"))o instanceof HTMLElement&&(o.textContent=o.getAttribute(1===n?"data-singular-string":"data-plural-string"));if(n>0){s.textContent=s.getAttribute("data-pending-message")||"";const t=e.querySelector(".js-reviews-toggle");t.classList.add("anim-pulse-in"),t.addEventListener("animationend",(()=>t.classList.remove("anim-pulse-in")),{once:!0})}else s.textContent=s.getAttribute("data-message")||""}(e)))}function Fe(e){return e.getAttribute("ratio").split("/")}function Be(e){if(e){const[t,n]=Fe(e),s=parseInt(t)/parseInt(n),o=e.querySelector(".js-review-progress"),r=e.querySelector(".js-review-count");o instanceof HTMLElement&&r&&(o.style.width=100*s+"%",r.textContent=`${t} / ${n}`)}}document.addEventListener("keydown",(function(e){"Alt"===e.key&&(Re=!0)})),document.addEventListener("keyup",(function(e){"Alt"===e.key&&(Re=!1)})),e("click",".js-toggle-outdated-comments",(function(e){if(!((e instanceof MouseEvent&&e.altKey||Re)&&e.currentTarget instanceof HTMLElement))return;const t=e.currentTarget,n=t.closest("details");function s(){const e=n.hasAttribute("open");for(const n of document.querySelectorAll(".js-toggle-outdated-comments"))if(n!==t){n.closest("details").toggleAttribute("open",e)}}setTimeout((()=>{w(t,s)}))})),t(".pull-request-ref-restore",{add:$e,remove:$e}),t("#js-pull-restorable",{add:De,remove:De}),n(".js-inline-comment-form",(async function(e,t){await t.text(),Pe()})),n(".js-pending-review-comment .js-comment-delete",(async function(e,t){await t.text(),Pe()})),n(".js-resolvable-timeline-thread-form",(async function(e,t){try{const n=await t.html();e.closest(".js-resolvable-timeline-thread-container").replaceWith(n.html)}catch(n){E()}})),e("click",".js-resolvable-thread-toggler",(function(e){if(!(e.target instanceof HTMLElement))return;const t=e.target.closest(".js-resolvable-timeline-thread-container");e.target.closest(".js-resolvable-thread-toggler-container").classList.toggle("border-bottom");t.querySelector(".js-resolvable-thread-contents").classList.toggle("d-none");for(const n of t.querySelectorAll(".js-resolvable-thread-toggler"))n.classList.toggle("d-none")})),n(".js-toggle-user-reviewed-file-form",(async function(e,t){const n=e.closest(".js-details-container"),s=!!n.querySelector(".js-reviewed-file"),o=n.classList.contains("open"),r=n.querySelector(".js-file-header"),c=!!r&&60===r.getBoundingClientRect().top;(!s&&o||s&&!o)&&(L(n),c&&a(n));const i=e.querySelector(".js-reviewed-toggle");s?(i.classList.remove("bg-blue-2","border-blue-light"),i.classList.add("text-gray","border-gray-dark")):(i.classList.remove("text-gray","border-gray-dark"),i.classList.add("bg-blue-2","border-blue-light"));i.querySelector(".js-reviewed-checkbox").disabled=!0;const l=document.querySelector("progress-bar");l instanceof ProgressBarElement&&(s?l.decrement():l.increment());const u=await t.html(),d=e.closest(".js-replace-file-header-review");d&&(d.replaceWith(u.html),n.hasAttribute("data-file-user-viewed")?n.removeAttribute("data-file-user-viewed"):n.setAttribute("data-file-user-viewed","true"))}));class ProgressBarElement extends HTMLElement{static get observedAttributes(){return["ratio"]}attributeChangedCallback(e){"ratio"===e&&Be(this)}connectedCallback(){Be(this)}increment(){const[e,t]=Fe(this),n=Math.min(parseInt(e)+1,parseInt(t));this.setAttribute("ratio",`${n}/${t}`)}decrement(){const[e,t]=Fe(this),n=Math.min(parseInt(e)-1,parseInt(t));this.setAttribute("ratio",`${n}/${t}`)}}function We(e){S(e),a(e)}async function Ue(e,t){const{anchor:n,side:s,line:o,lastLine:r,hashFragment:c,partialHashFragment:i}=e,l=y(document,n);if(!l)return;const a=l.nextElementSibling;if(!a)return;const u=Oe(a,s,o,r);if(!u.length){const e=y(document,c);if(e)return void We(e);const t=a.querySelector(".js-diff-load-container");if(!t)return;try{await function(e){const t=e.querySelector(".js-diff-entry-loader"),n=e.querySelector(".js-diff-placeholder"),s=e.querySelector("button.js-diff-load"),o=e.querySelector(".js-button-text");n.setAttribute("fill","url('#animated-diff-gradient')"),o.textContent=s.getAttribute("data-disable-with")||"",s.disabled=!0;const r=new URL(t.getAttribute("data-fragment-url")||"",window.location.origin);return t.src=r.toString(),t.data}(t);const e=y(document,c);e instanceof HTMLElement&&We(e)}catch(m){We(a)}return}await function(e,t){return Promise.all(e.map((e=>Ne(e,t))))}(u,i);const d=y(document,c);Oe(a,s,o,r).length?Ue(e,t):d?We(d):t<1&&Ue(e,t+1)}async function Ne(e,t){let n;if(t){const s="R"===t.slice(-1)?"data-right-range":"data-left-range",o=e.getAttribute(s)||"";n=t+parseInt(o.split("-")[0],10)}else n=e.hash.slice(1);const s=e.getAttribute("data-url"),o=new URL(s,window.location.origin),r=new URLSearchParams(o.search.slice(1));r.append("anchor",n),o.search=r.toString(),""!==window.location.hash&&window.history.replaceState(null,"","#");const c=await m(document,o.toString()),i=e.closest(".js-expandable-line"),l=function(e,t){const n=e.nextElementSibling;return n instanceof HTMLElement&&n.matches(t)?n:null}(i,".file-diff-line");l?w(l,(()=>{i.replaceWith(c)})):i.replaceWith(c)}function Oe(e,t,n,s){const o=parseInt(n,10),r=parseInt(s||"",10);return Array.from(e.querySelectorAll(".js-expand")).filter((e=>{const n="R"===t?"data-right-range":"data-left-range",s=(e.getAttribute(n)||"").split("-"),c=parseInt(s[0],10),i=parseInt(s[1],10);return c<=o&&o<=i||(o<=c&&i<=r||c<=r&&r<=i)}))}function Xe(e){return Math.floor(e/2)}function Ve(e,t){const n=e.parentElement;if(!n)return;const s=n.children;let o;if(4===s.length)for(let r=0,c=s.length;r<c;r++){s[r]===e&&(o=Xe(r))}for(let r=0,c=s.length;r<c;r++){const e=s[r];null!=o&&Xe(r)!==o||e.classList.toggle("is-hovered",t)}}function Ke(){const e=document.querySelector("meta[name=diff-view]"),t=e&&e instanceof HTMLMetaElement?e.content:"",n=document.querySelector(".js-file-diff-split"),s=!!("split"===t&&n||document.querySelector(".wants-full-width-container"));document.body.classList.toggle("full-width",s)}function Ge(e){const t=e.parentElement,n=t.querySelectorAll("td.js-line-comments").length,s=t.querySelectorAll("td.js-line-comments.is-collapsed").length;t.classList.toggle("is-collapsed",s>0&&n===s)}window.customElements.get("progress-bar")||(window.ProgressBarElement=ProgressBarElement,window.customElements.define("progress-bar",ProgressBarElement)),document.addEventListener("pjax:end",(function(){for(const e of document.querySelectorAll(".js-pull-refresh-on-pjax"))T(e)})),t(".js-multi-line-callout",(function(e){const t=document.querySelector(".js-linkable-line-number");if(!t)return;if(t.closest(".js-diff-table").offsetHeight<343)return;const n=t.closest("tr");if(!n)return;const s=n.lastElementChild;s&&(e.remove(),s.prepend(e),e.removeAttribute("hidden"))})),e("submit",".js-multi-line-callout",(function(e){if(!(e.target instanceof Element))return;e.target.closest(".js-multi-line-callout").hidden=!0})),e("click",".js-dismiss-multi-line-suggestion-onboarding-notice",(async function(e){const t=e.currentTarget.getAttribute("data-url"),n=e.currentTarget.parentElement.querySelector(".js-data-url-csrf"),s=new FormData;s.append("notice","multi_line_suggestions");if((await fetch(t,{method:"POST",mode:"same-origin",body:s,headers:{"Scoped-CSRF-Token":n.value,"X-Requested-With":"XMLHttpRequest"}})).ok){const e=document.querySelectorAll(".js-multi-line-suggestion-onboarding-notice");for(const t of e)t.remove()}})),t(".js-updating-pull-request-commits-count",{add(e){const t=e.textContent,n=document.querySelectorAll(".js-updateable-pull-request-commits-count");for(const s of n)s.textContent=t}}),(async()=>{if(await x,window.performance&&window.performance.navigation&&window.performance.navigation.type===window.performance.navigation.TYPE_RELOAD){const e=document.getElementById("js-report-pull-request-refresh");e&&k(e)}})(),i((function(){const e=function(e){if(!e)return;const t=_(e);if(!t)return;const n=t[1],s=t[2],o=t[3],r=t[5];return{anchor:n,side:s,line:o,lastLine:r,hashFragment:n+s+o,partialHashFragment:n+s}}(window.location.hash);e&&(y(document,e.hashFragment)&&!e.lastLine||Ue(e,0))})),e("click",".js-expand",(function(e){e.preventDefault(),Ne(e.currentTarget)})),t(".diff-table",(function(e){let t=null;function n(){t&&Ve(t,!1),t=null}function s(e){t&&Ve(t,!1),e.target instanceof HTMLElement&&(t=e.target.closest("td.blob-code"),t&&Ve(t,!0))}return{add:function(){e.addEventListener("mouseenter",n),e.addEventListener("mouseleave",n),e.addEventListener("mouseover",s)},remove:function(){e.removeEventListener("mouseenter",n),e.removeEventListener("mouseleave",n),e.removeEventListener("mouseover",s)}}})),t("meta[name=diff-view]",{add:Ke,remove:Ke}),t(".js-file-diff-split",{add:Ke,remove:Ke}),t(".js-compare-tab.selected",{add:Ke,remove:Ke}),t(".wants-full-width-container",{add:Ke,remove:Ke}),e("change",".js-toggle-file-notes",(function(e){const t=e.currentTarget;t.closest(".file").classList.toggle("show-inline-notes",t.checked)})),e("click",".js-toggle-all-file-notes",(function(e){const t=Array.from(document.querySelectorAll(".js-toggle-file-notes")),n=t.some((e=>e.checked));for(const s of t)u(s,!n);e.preventDefault()})),t(".js-inline-comments-container",(function(e){let t;const n=e.closest(".file");if(n){return{add:t=function(){const e=null!=n.querySelector(".js-inline-comments-container");n.classList.toggle("has-inline-notes",e)},remove:t}}})),e("change",".js-toggle-file-check-annotations",(function(e){const t=e.currentTarget,n=t.closest(".file").querySelectorAll(".js-inline-annotations");for(const s of n)s instanceof HTMLElement&&(s.hidden=!t.checked)})),t("td.js-line-comments.is-collapsed",{add:Ge,remove:Ge})}}}));
//# sourceMappingURL=diffs-f9cf7c8d.js.map