performance.mark("js-parse-end:48527-864c32c33c6ed02a.js"); "use strict";(globalThis.webpackChunk_github_ui_github_ui=globalThis.webpackChunk_github_ui_github_ui||[]).push([["48527"],{32658(t,e,n){n.r(e),n.d(e,{addSoftNewline:()=>x,autocompletedList:()=>E,disableTaskList:()=>u,enableTaskList:()=>c,indent:()=>w,listIndex:()=>T});var s=n(68349),l=n(21744),i=n(72705),r=n(21403),o=n(40893),a=n(46131);function c(t){if(t.querySelector(".js-task-list-field")){for(let e of t.querySelectorAll("task-lists"))if(e instanceof i.A)for(let t of(e.disabled=!1,e.querySelectorAll("button")))t.disabled=!1}}function u(t){for(let e of t.querySelectorAll("task-lists"))if(e instanceof i.A)for(let t of(e.disabled=!0,e.querySelectorAll("button")))t.disabled=!0}function d(t,e,n){let s=t.querySelector(".js-comment-update");u(t),q(t);let l=s.elements.namedItem("task_list_track");l instanceof Element&&l.remove();let i=s.elements.namedItem("task_list_operation");i instanceof Element&&i.remove();let r=document.createElement("input");r.setAttribute("type","hidden"),r.setAttribute("name","task_list_track"),r.setAttribute("value",e),s.appendChild(r);let o=document.createElement("input");if(o.setAttribute("type","hidden"),o.setAttribute("name","task_list_operation"),o.setAttribute("value",JSON.stringify(n)),s.appendChild(o),!s.elements.namedItem("task_list_key")){let t=s.querySelector(".js-task-list-field").getAttribute("name").split("[")[0],e=document.createElement("input");e.setAttribute("type","hidden"),e.setAttribute("name","task_list_key"),e.setAttribute("value",t),s.appendChild(e)}t.classList.remove("is-comment-stale"),(0,a.k_)(s)}(0,r.lB)(".js-task-list-container .js-task-list-field",function(t){let e=t.closest(".js-task-list-container");c(e),q(e)}),(0,r.lB)(".js-convert-tasklist-to-block-enabled .contains-task-list",function(t){let e=I(t);if(!e||Array.from(e.children).some(t=>t.classList.contains("task-list-item-convert-container")))return;let n=t.ownerDocument.querySelector(".js-convert-to-block-template"),s=n?.content.cloneNode(!0);s&&e.appendChild(s)}),(0,l.on)("task-lists-move","task-lists",function(t){let{src:e,dst:n}=t.detail;d(t.currentTarget.closest(".js-task-list-container"),"reordered",{operation:"move",src:e,dst:n})}),(0,l.on)("task-lists-check","task-lists",function(t){let{position:e,checked:n}=t.detail;d(t.currentTarget.closest(".js-task-list-container"),`checked:${+!!n}`,{operation:"check",position:e,checked:n})}),(0,l.on)("click",".js-convert-to-block-button",function(t){let e=I(t.target);if(!e)return;if(!e.closest("task-lists"))throw Error("parent not found");let n=T(e);d(t.currentTarget.closest(".js-task-list-container"),"converted",{operation:"convert_to_block",position:n})}),(0,o.JW)(".js-task-list-container .js-comment-update",async function(t,e){let n,s=t.closest(".js-task-list-container"),l=t.elements.namedItem("task_list_track");l instanceof Element&&l.remove();let i=t.elements.namedItem("task_list_operation");i instanceof Element&&i.remove();try{n=await e.json()}catch(e){let t;try{t=JSON.parse(e.response.text)}catch{}if(t&&t.stale){let t=s.querySelector(".js-task-list-field");t.classList.add("session-resumable-canceled"),t.classList.remove("js-session-resumable")}else 422===e.response.status||window.location.reload()}n&&(i&&n.json.source&&(s.querySelector(".js-task-list-field").value=n.json.source),c(s),requestAnimationFrame(()=>q(s)))});let m=!1,f=!1,k=null;function b(t){m="insertLineBreak"===t.inputType}function p(t){if(m||"insertLineBreak"===t.inputType){var e;let n;void 0!==(n=E((e=t.target).value,[e.selectionStart,e.selectionEnd]))&&h(e,n),m=!1}}function h(t,e){if(null===k||!0===k){t.contentEditable="true";try{let n;m=!1,e.commandId===_.insertText?(n=e.autocompletePrefix,null!==e.writeSelection[0]&&null!==e.writeSelection[1]&&(t.selectionStart=e.writeSelection[0],t.selectionEnd=e.writeSelection[1])):t.selectionStart=e.selection[0],k=document.execCommand(e.commandId,!1,n)}catch{k=!1}t.contentEditable="false"}if(!k){try{document.execCommand("ms-beginUndoUnit")}catch{}t.value=e.text;try{document.execCommand("ms-endUndoUnit")}catch{}t.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0}))}null!=e.selection[0]&&null!=e.selection[1]&&(t.selectionStart=e.selection[0],t.selectionEnd=e.selection[1])}function g(t){if(!f&&"Enter"===t.key&&t.shiftKey&&!t.metaKey){let e=t.target,n=x(e.value,[e.selectionStart,e.selectionEnd]);if(void 0!==n)h(e,n),t.preventDefault(),(0,l.h)(e,"change")}}function y(){f=!0}function S(){f=!1}function v(t){if(f)return;if("Escape"===t.key){let e;return void("backward"===(e=t.target).selectionDirection?e.selectionEnd=e.selectionStart:e.selectionStart=e.selectionEnd)}if("Tab"!==t.key)return;let e=t.target,n=w(e.value,[e.selectionStart,e.selectionEnd],t.shiftKey);void 0!==n&&(t.preventDefault(),h(e,n))}(0,r.lB)(".js-task-list-field",{subscribe:t=>(0,s.Zz)((0,s.Rt)(t,"keydown",v),(0,s.Rt)(t,"keydown",g),(0,s.Rt)(t,"beforeinput",b),(0,s.Rt)(t,"input",p),(0,s.Rt)(t,"compositionstart",y),(0,s.Rt)(t,"compositionend",S))});let _={insertText:"insertText",delete:"delete"},j=/^(\s*)?/;function x(t,e){let n=e[0];if(!n||!t)return;let s=t.substring(0,n).split("\n"),l=s[s.length-1],i=l?.match(j);if(!i)return;let r=i[1]||"",o=` ${r}`;return{text:t.substring(0,n)+o+t.substring(n),autocompletePrefix:o,selection:[n+o.length,n+o.length],commandId:_.insertText,writeSelection:[null,null]}}let A=/^(\s*)([*-]|(\d+)\.)\s(\[[\sx]\]\s)?/;function E(t,e){let n=e[0];if(!n||!t)return;let s=t.substring(0,n).split("\n"),l=s[s.length-2],i=l?.match(A);if(!i)return;let r=i[0],o=i[1],a=i[2],c=parseInt(i[3],10),u=!!i[4],d=!isNaN(c),m=d?`${c+1}.`:a,f=`${m} ${u?"[ ] ":""}`,k=t.indexOf("\n",n);k<0&&(k=t.length);let b=t.substring(n,k);if(b.startsWith(f)&&(f=""),l.replace(r,"").trim().length>0||b.trim().length>0){let e=`${o}${f}`,s=t.substring(n),l=e.length,i=[null,null],r=t.substring(0,n)+e+s;if(d&&!t.substring(n).match(/^\s*$/g)){var p,h;p=t.substring(n),h=c+1,e+=s=p.split("\n").map(t=>{if(t.replace(/^\s+/,"").startsWith(`${h}.`)){let e=t.replace(`${h}`,`${h+1}`);return h+=1,e}return t}).join("\n"),i=[n,n+e.length],r=t.substring(0,n)+e}return{text:r,autocompletePrefix:e,selection:[n+l,n+l],commandId:_.insertText,writeSelection:i}}{let e=n-` ${r}`.length;return{autocompletePrefix:"",text:t.substring(0,e)+t.substring(n),selection:[e,e],commandId:_.delete,writeSelection:[null,null]}}}function w(t,e,n){let s=e[0]||0,l=e[1]||s;if(null===e[0]||s===l)return;let i=t.substring(0,s).lastIndexOf("\n")+1,r=t.indexOf("\n",l-1),o=r>0?r:t.length-1,a=t.substring(i,o).split("\n"),c=!1,u=0,d=0,m=[];for(let t of a){let e=t.match(/^\s*/);if(e){let s=e[0],l=t.substring(s.length);if(n){let t=s.length;s=s.slice(0,-2),u=c?u:s.length-t,c=!0,d+=s.length-t}else s+=" ",u=2,d+=2;m.push(s+l)}}let f=m.join("\n");return{text:t.substring(0,i)+f+t.substring(o),selection:[Math.max(i,s+u),l+d],autocompletePrefix:f,commandId:_.insertText,writeSelection:[i,o]}}function T(t){let e=t.closest("task-lists");if(!e)throw Error("parent not found");return Array.from(e.querySelectorAll("ol, ul")).filter(t=>!t.closest("tracking-block")).indexOf(t)}function q(t){if(0===document.querySelectorAll("tracked-issues-progress").length||t.closest(".js-timeline-item"))return;let e=t.querySelectorAll(".js-comment-body [type=checkbox]"),n=e.length,s=Array.from(e).filter(t=>t.checked).length;for(let t of document.querySelectorAll("tracked-issues-progress[data-type=checklist]"))t.setAttribute("data-completed",String(s)),t.setAttribute("data-total",String(n))}function I(t){let e=t.closest(".contains-task-list"),n=e;for(;(n=n.parentElement.closest(".contains-task-list"))!==e&&null!==n;)e=n;return e}}}]); //# sourceMappingURL=48527-864c32c33c6ed02a-f63fcd469e77c75b.js.map