From 0c8c82112d7bfe97a161c89c8372323f998d645d Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Sun, 10 Mar 2024 21:45:14 -0700 Subject: [PATCH] Move former `render_input` to MergeState.renderInDomElement. This allows making internal functions protected --- .../{index-yJGRNYQc.js => index-Dzwy4hAX.js} | 152 ++++++------ webapp/dist/index.html | 2 +- webapp/src/main.ts | 4 +- webapp/src/merge_state.ts | 234 +++++++++--------- 4 files changed, 195 insertions(+), 197 deletions(-) rename webapp/dist/assets/{index-yJGRNYQc.js => index-Dzwy4hAX.js} (75%) diff --git a/webapp/dist/assets/index-yJGRNYQc.js b/webapp/dist/assets/index-Dzwy4hAX.js similarity index 75% rename from webapp/dist/assets/index-yJGRNYQc.js rename to webapp/dist/assets/index-Dzwy4hAX.js index f45880c..e34834f 100644 --- a/webapp/dist/assets/index-yJGRNYQc.js +++ b/webapp/dist/assets/index-Dzwy4hAX.js @@ -1,92 +1,92 @@ -var df=Object.defineProperty;var gf=(O,m,S)=>m in O?df(O,m,{enumerable:!0,configurable:!0,writable:!0,value:S}):O[m]=S;var fn=(O,m,S)=>(gf(O,typeof m!="symbol"?m+"":m,S),S);(function(){const m=document.createElement("link").relList;if(m&&m.supports&&m.supports("modulepreload"))return;for(const k of document.querySelectorAll('link[rel="modulepreload"]'))N(k);new MutationObserver(k=>{for(const z of k)if(z.type==="childList")for(const h of z.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&N(h)}).observe(document,{childList:!0,subtree:!0});function S(k){const z={};return k.integrity&&(z.integrity=k.integrity),k.referrerPolicy&&(z.referrerPolicy=k.referrerPolicy),k.crossOrigin==="use-credentials"?z.credentials="include":k.crossOrigin==="anonymous"?z.credentials="omit":z.credentials="same-origin",z}function N(k){if(k.ep)return;k.ep=!0;const z=S(k);fetch(k.href,z)}})();button_collapse_uncollapse_menu.onclick=function(){this.closest(".main-menu").classList.toggle("collapsed")};var pf=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function vf(O){return O&&O.__esModule&&Object.prototype.hasOwnProperty.call(O,"default")?O.default:O}var Cl={exports:{}},Wa;function qa(){return Wa||(Wa=1,function(O,m){(function(S,N){O.exports=N()})(pf,function(){var S=navigator.userAgent,N=navigator.platform,k=/gecko\/\d/i.test(S),z=/MSIE \d/.test(S),h=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(S),c=/Edge\/(\d+)/.exec(S),d=z||h||c,v=d&&(z?document.documentMode||6:+(c||h)[1]),b=!c&&/WebKit\//.test(S),w=b&&/Qt\/\d+\.\d+/.test(S),A=!c&&/Chrome\/(\d+)/.exec(S),_=A&&+A[1],F=/Opera\//.test(S),K=/Apple Computer/.test(navigator.vendor),Y=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(S),q=/PhantomJS/.test(S),Z=K&&(/Mobile\/\w+/.test(S)||navigator.maxTouchPoints>2),le=/Android/.test(S),ie=Z||le||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(S),ne=Z||/Mac/.test(N),he=/\bCrOS\b/.test(S),re=/win/i.test(N),J=F&&S.match(/Version\/(\d*\.\d*)/);J&&(J=Number(J[1])),J&&J>=15&&(F=!1,b=!0);var ye=ne&&(w||F&&(J==null||J<12.11)),Fe=k||d&&v>=9;function Ke(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var Me=function(e,t){var i=e.className,r=Ke(t).exec(i);if(r){var n=i.slice(r.index+r[0].length);e.className=i.slice(0,r.index)+(n?r[1]+n:"")}};function qe(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function De(e,t){return qe(e).appendChild(t)}function Q(e,t,i,r){var n=document.createElement(e);if(i&&(n.className=i),r&&(n.style.cssText=r),typeof t=="string")n.appendChild(document.createTextNode(t));else if(t)for(var l=0;l=t)return o+(t-l);o+=a-l,o+=i-o%i,l=a+1}}var gt=function(){this.id=null,this.f=null,this.time=0,this.handler=pr(this.onTimeout,this)};gt.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},gt.prototype.set=function(e,t){this.f=t;var i=+new Date+e;(!this.id||i=t)return r+Math.min(o,t-n);if(n+=l-r,n+=i-n%i,r=l+1,n>=t)return r}}var vr=[""];function yr(e){for(;vr.length<=e;)vr.push(f(vr)+" ");return vr[e]}function f(e){return e[e.length-1]}function y(e,t){for(var i=[],r=0;r"€"&&(e.toUpperCase()!=e.toLowerCase()||D.test(e))}function H(e,t){return t?t.source.indexOf("\\w")>-1&&I(e)?!0:t.test(e):I(e)}function R(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var oe=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function ue(e){return e.charCodeAt(0)>=768&&oe.test(e)}function ce(e,t,i){for(;(i<0?t>0:ti?-1:1;;){if(t==i)return t;var n=(t+i)/2,l=r<0?Math.ceil(n):Math.floor(n);if(l==t)return e(l)?t:i;e(l)?i=l:t=l+r}}function Ce(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,l=0;lt||t==i&&o.to==t)&&(r(Math.max(o.from,t),Math.min(o.to,i),o.level==1?"rtl":"ltr",l),n=!0)}n||r(t,i,"ltr")}var be=null;function Ne(e,t,i){var r;be=null;for(var n=0;nt)return n;l.to==t&&(l.from!=l.to&&i=="before"?r=n:be=n),l.from==t&&(l.from!=l.to&&i!="before"?r=n:be=n)}return r??be}var ut=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(u){return u<=247?e.charAt(u):1424<=u&&u<=1524?"R":1536<=u&&u<=1785?t.charAt(u-1536):1774<=u&&u<=2220?"r":8192<=u&&u<=8203?"w":u==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,l=/[LRr]/,o=/[Lb1n]/,a=/[1n]/;function s(u,g,p){this.level=u,this.from=g,this.to=p}return function(u,g){var p=g=="ltr"?"L":"R";if(u.length==0||g=="ltr"&&!r.test(u))return!1;for(var T=u.length,C=[],E=0;E-1&&(r[t]=n.slice(0,l).concat(n.slice(l+1)))}}}function Te(e,t){var i=mr(e,t);if(i.length)for(var r=Array.prototype.slice.call(arguments,2),n=0;n0}function Mt(e){e.prototype.on=function(t,i){te(this,t,i)},e.prototype.off=function(t,i){je(this,t,i)}}function Oe(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function Nl(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function pn(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function $r(e){Oe(e),Nl(e)}function vn(e){return e.target||e.srcElement}function Ol(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),ne&&e.ctrlKey&&t==1&&(t=3),t}var ns=function(){if(d&&v<9)return!1;var e=Q("div");return"draggable"in e||"dragDrop"in e}(),yn;function ls(e){if(yn==null){var t=Q("span","​");De(e,Q("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(yn=t.offsetWidth<=1&&t.offsetHeight>2&&!(d&&v<8))}var i=yn?Q("span","​"):Q("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var mn;function os(e){if(mn!=null)return mn;var t=De(e,document.createTextNode("AخA")),i=bt(t,0,1).getBoundingClientRect(),r=bt(t,1,2).getBoundingClientRect();return qe(e),!i||i.left==i.right?!1:mn=r.right-i.right<3}var bn=` +var gf=Object.defineProperty;var pf=(E,m,C)=>m in E?gf(E,m,{enumerable:!0,configurable:!0,writable:!0,value:C}):E[m]=C;var fn=(E,m,C)=>(pf(E,typeof m!="symbol"?m+"":m,C),C);(function(){const m=document.createElement("link").relList;if(m&&m.supports&&m.supports("modulepreload"))return;for(const k of document.querySelectorAll('link[rel="modulepreload"]'))N(k);new MutationObserver(k=>{for(const z of k)if(z.type==="childList")for(const h of z.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&N(h)}).observe(document,{childList:!0,subtree:!0});function C(k){const z={};return k.integrity&&(z.integrity=k.integrity),k.referrerPolicy&&(z.referrerPolicy=k.referrerPolicy),k.crossOrigin==="use-credentials"?z.credentials="include":k.crossOrigin==="anonymous"?z.credentials="omit":z.credentials="same-origin",z}function N(k){if(k.ep)return;k.ep=!0;const z=C(k);fetch(k.href,z)}})();button_collapse_uncollapse_menu.onclick=function(){this.closest(".main-menu").classList.toggle("collapsed")};var vf=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yf(E){return E&&E.__esModule&&Object.prototype.hasOwnProperty.call(E,"default")?E.default:E}var Cl={exports:{}},Ia;function Za(){return Ia||(Ia=1,function(E,m){(function(C,N){E.exports=N()})(vf,function(){var C=navigator.userAgent,N=navigator.platform,k=/gecko\/\d/i.test(C),z=/MSIE \d/.test(C),h=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(C),c=/Edge\/(\d+)/.exec(C),d=z||h||c,v=d&&(z?document.documentMode||6:+(c||h)[1]),b=!c&&/WebKit\//.test(C),w=b&&/Qt\/\d+\.\d+/.test(C),A=!c&&/Chrome\/(\d+)/.exec(C),_=A&&+A[1],F=/Opera\//.test(C),K=/Apple Computer/.test(navigator.vendor),Y=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(C),q=/PhantomJS/.test(C),Z=K&&(/Mobile\/\w+/.test(C)||navigator.maxTouchPoints>2),le=/Android/.test(C),ie=Z||le||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(C),ne=Z||/Mac/.test(N),he=/\bCrOS\b/.test(C),re=/win/i.test(N),J=F&&C.match(/Version\/(\d*\.\d*)/);J&&(J=Number(J[1])),J&&J>=15&&(F=!1,b=!0);var ye=ne&&(w||F&&(J==null||J<12.11)),Fe=k||d&&v>=9;function Ke(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var Me=function(e,t){var i=e.className,r=Ke(t).exec(i);if(r){var n=i.slice(r.index+r[0].length);e.className=i.slice(0,r.index)+(n?r[1]+n:"")}};function qe(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function De(e,t){return qe(e).appendChild(t)}function Q(e,t,i,r){var n=document.createElement(e);if(i&&(n.className=i),r&&(n.style.cssText=r),typeof t=="string")n.appendChild(document.createTextNode(t));else if(t)for(var l=0;l=t)return o+(t-l);o+=a-l,o+=i-o%i,l=a+1}}var gt=function(){this.id=null,this.f=null,this.time=0,this.handler=pr(this.onTimeout,this)};gt.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},gt.prototype.set=function(e,t){this.f=t;var i=+new Date+e;(!this.id||i=t)return r+Math.min(o,t-n);if(n+=l-r,n+=i-n%i,r=l+1,n>=t)return r}}var vr=[""];function yr(e){for(;vr.length<=e;)vr.push(f(vr)+" ");return vr[e]}function f(e){return e[e.length-1]}function y(e,t){for(var i=[],r=0;r"€"&&(e.toUpperCase()!=e.toLowerCase()||D.test(e))}function H(e,t){return t?t.source.indexOf("\\w")>-1&&I(e)?!0:t.test(e):I(e)}function R(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var oe=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function ue(e){return e.charCodeAt(0)>=768&&oe.test(e)}function ce(e,t,i){for(;(i<0?t>0:ti?-1:1;;){if(t==i)return t;var n=(t+i)/2,l=r<0?Math.ceil(n):Math.floor(n);if(l==t)return e(l)?t:i;e(l)?i=l:t=l+r}}function Ce(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,l=0;lt||t==i&&o.to==t)&&(r(Math.max(o.from,t),Math.min(o.to,i),o.level==1?"rtl":"ltr",l),n=!0)}n||r(t,i,"ltr")}var be=null;function Ne(e,t,i){var r;be=null;for(var n=0;nt)return n;l.to==t&&(l.from!=l.to&&i=="before"?r=n:be=n),l.from==t&&(l.from!=l.to&&i!="before"?r=n:be=n)}return r??be}var ut=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(u){return u<=247?e.charAt(u):1424<=u&&u<=1524?"R":1536<=u&&u<=1785?t.charAt(u-1536):1774<=u&&u<=2220?"r":8192<=u&&u<=8203?"w":u==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,l=/[LRr]/,o=/[Lb1n]/,a=/[1n]/;function s(u,g,p){this.level=u,this.from=g,this.to=p}return function(u,g){var p=g=="ltr"?"L":"R";if(u.length==0||g=="ltr"&&!r.test(u))return!1;for(var T=u.length,S=[],O=0;O-1&&(r[t]=n.slice(0,l).concat(n.slice(l+1)))}}}function Te(e,t){var i=mr(e,t);if(i.length)for(var r=Array.prototype.slice.call(arguments,2),n=0;n0}function Mt(e){e.prototype.on=function(t,i){te(this,t,i)},e.prototype.off=function(t,i){je(this,t,i)}}function Oe(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function Ol(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function pn(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function $r(e){Oe(e),Ol(e)}function vn(e){return e.target||e.srcElement}function El(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),ne&&e.ctrlKey&&t==1&&(t=3),t}var ls=function(){if(d&&v<9)return!1;var e=Q("div");return"draggable"in e||"dragDrop"in e}(),yn;function os(e){if(yn==null){var t=Q("span","​");De(e,Q("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(yn=t.offsetWidth<=1&&t.offsetHeight>2&&!(d&&v<8))}var i=yn?Q("span","​"):Q("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var mn;function as(e){if(mn!=null)return mn;var t=De(e,document.createTextNode("AخA")),i=bt(t,0,1).getBoundingClientRect(),r=bt(t,1,2).getBoundingClientRect();return qe(e),!i||i.left==i.right?!1:mn=r.right-i.right<3}var bn=` b`.split(/\n/).length!=3?function(e){for(var t=0,i=[],r=e.length;t<=r;){var n=e.indexOf(` -`,t);n==-1&&(n=e.length);var l=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),o=l.indexOf("\r");o!=-1?(i.push(l.slice(0,o)),t+=o+1):(i.push(l),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},as=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch{return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch{}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},ss=function(){var e=Q("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),wn=null;function us(e){if(wn!=null)return wn;var t=De(e,Q("span","x")),i=t.getBoundingClientRect(),r=bt(t,0,1).getBoundingClientRect();return wn=Math.abs(i.left-r.left)>1}var Cn={},br={};function fs(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Cn[e]=t}function hs(e,t){br[e]=t}function Di(e){if(typeof e=="string"&&br.hasOwnProperty(e))e=br[e];else if(e&&typeof e.name=="string"&&br.hasOwnProperty(e.name)){var t=br[e.name];typeof t=="string"&&(t={name:t}),e=M(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Di("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Di("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function Sn(e,t){t=Di(t);var i=Cn[t.name];if(!i)return Sn(e,"text/plain");var r=i(e,t);if(wr.hasOwnProperty(t.name)){var n=wr[t.name];for(var l in n)n.hasOwnProperty(l)&&(r.hasOwnProperty(l)&&(r["_"+l]=r[l]),r[l]=n[l])}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var o in t.modeProps)r[o]=t.modeProps[o];return r}var wr={};function cs(e,t){var i=wr.hasOwnProperty(e)?wr[e]:wr[e]={};dt(t,i)}function jt(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var i={};for(var r in t){var n=t[r];n instanceof Array&&(n=n.concat([])),i[r]=n}return i}function Ln(e,t){for(var i;e.innerMode&&(i=e.innerMode(t),!(!i||i.mode==e));)t=i.state,e=i.mode;return i||{mode:e,state:t}}function El(e,t,i){return e.startState?e.startState(t,i):!0}var Ee=function(e,t,i){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=i};Ee.prototype.eol=function(){return this.pos>=this.string.length},Ee.prototype.sol=function(){return this.pos==this.lineStart},Ee.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Ee.prototype.next=function(){if(this.post},Ee.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Ee.prototype.skipToEnd=function(){this.pos=this.string.length},Ee.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Ee.prototype.backUp=function(e){this.pos-=e},Ee.prototype.column=function(){return this.lastColumnPos0?null:(l&&t!==!1&&(this.pos+=l[0].length),l)}},Ee.prototype.current=function(){return this.string.slice(this.start,this.pos)},Ee.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Ee.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Ee.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function j(e,t){if(t-=e.first,t<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var i=e;!i.lines;)for(var r=0;;++r){var n=i.children[r],l=n.chunkSize();if(t=e.first&&ti?P(i,j(e,i).text.length):ds(t,j(e,t.line).text.length)}function ds(e,t){var i=e.ch;return i==null||i>t?P(e.line,t):i<0?P(e.line,0):e}function Il(e,t){for(var i=[],r=0;rthis.maxLookAhead&&(this.maxLookAhead=e),t},Ct.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},Ct.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},Ct.fromSaved=function(e,t,i){return t instanceof Ei?new Ct(e,jt(e.mode,t.state),i,t.lookAhead):new Ct(e,jt(e.mode,t),i)},Ct.prototype.save=function(e){var t=e!==!1?jt(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Ei(t,this.maxLookAhead):t};function Fl(e,t,i,r){var n=[e.state.modeGen],l={};Ul(e,t.text,e.doc.mode,i,function(u,g){return n.push(u,g)},l,r);for(var o=i.state,a=function(u){i.baseTokens=n;var g=e.state.overlays[u],p=1,T=0;i.state=!0,Ul(e,t.text,g.mode,i,function(C,E){for(var W=p;TC&&n.splice(p,1,C,n[p+1],B),p+=2,T=Math.min(C,B)}if(E)if(g.opaque)n.splice(W,p-W,C,"overlay "+E),p=W+2;else for(;We.options.maxHighlightLength&&jt(e.doc.mode,r.state),l=Fl(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=l.styles,l.classes?t.styleClasses=l.classes:t.styleClasses&&(t.styleClasses=null),i===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function Yr(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new Ct(r,!0,t);var l=gs(e,t,i),o=l>r.first&&j(r,l-1).stateAfter,a=o?Ct.fromSaved(r,o,l):new Ct(r,El(r.mode),l);return r.iter(l,t,function(s){Mn(e,s.text,a);var u=a.line;s.stateAfter=u==t-1||u%5==0||u>=n.viewFrom&&ut.start)return l}throw new Error("Mode "+e.name+" failed to advance stream.")}var Bl=function(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i};function Rl(e,t,i,r){var n=e.doc,l=n.mode,o;t=se(n,t);var a=j(n,t.line),s=Yr(e,t.line,i),u=new Ee(a.text,e.options.tabSize,s),g;for(r&&(g=[]);(r||u.pose.options.maxHighlightLength?(a=!1,o&&Mn(e,t,r,g.pos),g.pos=t.length,p=null):p=zl(_n(i,g,r.state,T),l),T){var C=T[0].name;C&&(p="m-"+(p?C+" "+p:C))}if(!a||u!=p){for(;so;--a){if(a<=l.first)return l.first;var s=j(l,a-1),u=s.stateAfter;if(u&&(!i||a+(u instanceof Ei?u.lookAhead:0)<=l.modeFrontier))return a;var g=Ze(s.text,null,e.options.tabSize);(n==null||r>g)&&(n=a-1,r=g)}return n}function ps(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontieri;r--){var n=j(e,r).stateAfter;if(n&&(!(n instanceof Ei)||r+n.lookAhead=t:l.to>t);(r||(r=[])).push(new Wi(o,l.from,s?null:l.to))}}return r}function Cs(e,t,i){var r;if(e)for(var n=0;n=t:l.to>t);if(a||l.from==t&&o.type=="bookmark"&&(!i||l.marker.insertLeft)){var s=l.from==null||(o.inclusiveLeft?l.from<=t:l.from0&&a)for(var X=0;X0)){var g=[s,1],p=ae(u.from,a.from),T=ae(u.to,a.to);(p<0||!o.inclusiveLeft&&!p)&&g.push({from:u.from,to:a.from}),(T>0||!o.inclusiveRight&&!T)&&g.push({from:a.to,to:u.to}),n.splice.apply(n,g),s+=g.length-3}}return n}function $l(e){var t=e.markedSpans;if(t){for(var i=0;it)&&(!r||Nn(r,l.marker)<0)&&(r=l.marker)}return r}function Zl(e,t,i,r,n){var l=j(e,t),o=_t&&l.markedSpans;if(o)for(var a=0;a=0&&p<=0||g<=0&&p>=0)&&(g<=0&&(s.marker.inclusiveRight&&n.inclusiveLeft?ae(u.to,i)>=0:ae(u.to,i)>0)||g>=0&&(s.marker.inclusiveRight&&n.inclusiveLeft?ae(u.from,r)<=0:ae(u.from,r)<0)))return!0}}}function pt(e){for(var t;t=ql(e);)e=t.find(-1,!0).line;return e}function Ts(e){for(var t;t=Hi(e);)e=t.find(1,!0).line;return e}function ks(e){for(var t,i;t=Hi(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function On(e,t){var i=j(e,t),r=pt(i);return i==r?t:pe(r)}function Ql(e,t){if(t>e.lastLine())return t;var i=j(e,t),r;if(!Bt(e,i))return t;for(;r=Hi(i);)i=r.find(1,!0).line;return pe(i)+1}function Bt(e,t){var i=_t&&t.markedSpans;if(i){for(var r=void 0,n=0;nt.maxLineLength&&(t.maxLineLength=n,t.maxLine=r)})}var Cr=function(e,t,i){this.text=e,Xl(this,t),this.height=i?i(this):1};Cr.prototype.lineNo=function(){return pe(this)},Mt(Cr);function xs(e,t,i,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),$l(e),Xl(e,i);var n=r?r(e):1;n!=e.height&&wt(e,n)}function As(e){e.parent=null,$l(e)}var Ms={},_s={};function Jl(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?_s:Ms;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function jl(e,t){var i=kt("span",null,null,b?"padding-right: .1px":null),r={pre:kt("pre",[i],"CodeMirror-line"),content:i,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var n=0;n<=(t.rest?t.rest.length:0);n++){var l=n?t.rest[n-1]:t.line,o=void 0;r.pos=0,r.addToken=Ns,os(e.display.measure)&&(o=ge(l,e.doc.direction))&&(r.addToken=Es(r.addToken,o)),r.map=[];var a=t!=e.display.externalMeasured&&pe(l);Ws(l,r,Hl(e,l,a)),l.styleClasses&&(l.styleClasses.bgClass&&(r.bgClass=zr(l.styleClasses.bgClass,r.bgClass||"")),l.styleClasses.textClass&&(r.textClass=zr(l.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(ls(e.display.measure))),n==0?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(b){var s=r.content.lastChild;(/\bcm-tab\b/.test(s.className)||s.querySelector&&s.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return Te(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=zr(r.pre.className,r.textClass||"")),r}function Ds(e){var t=Q("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Ns(e,t,i,r,n,l,o){if(t){var a=e.splitSpaces?Os(t,e.trailingSpace):t,s=e.cm.state.specialChars,u=!1,g;if(!s.test(t))e.col+=t.length,g=document.createTextNode(a),e.map.push(e.pos,e.pos+t.length,g),d&&v<9&&(u=!0),e.pos+=t.length;else{g=document.createDocumentFragment();for(var p=0;;){s.lastIndex=p;var T=s.exec(t),C=T?T.index-p:t.length-p;if(C){var E=document.createTextNode(a.slice(p,p+C));d&&v<9?g.appendChild(Q("span",[E])):g.appendChild(E),e.map.push(e.pos,e.pos+C,E),e.col+=C,e.pos+=C}if(!T)break;p+=C+1;var W=void 0;if(T[0]==" "){var B=e.cm.options.tabSize,U=B-e.col%B;W=g.appendChild(Q("span",yr(U),"cm-tab")),W.setAttribute("role","presentation"),W.setAttribute("cm-text"," "),e.col+=U}else T[0]=="\r"||T[0]==` -`?(W=g.appendChild(Q("span",T[0]=="\r"?"␍":"␤","cm-invalidchar")),W.setAttribute("cm-text",T[0]),e.col+=1):(W=e.cm.options.specialCharPlaceholder(T[0]),W.setAttribute("cm-text",T[0]),d&&v<9?g.appendChild(Q("span",[W])):g.appendChild(W),e.col+=1);e.map.push(e.pos,e.pos+1,W),e.pos++}}if(e.trailingSpace=a.charCodeAt(t.length-1)==32,i||r||n||u||l||o){var $=i||"";r&&($+=r),n&&($+=n);var G=Q("span",[g],$,l);if(o)for(var X in o)o.hasOwnProperty(X)&&X!="style"&&X!="class"&&G.setAttribute(X,o[X]);return e.content.appendChild(G)}e.content.appendChild(g)}}function Os(e,t){if(e.length>1&&!/ /.test(e))return e;for(var i=t,r="",n=0;nu&&p.from<=u));T++);if(p.to>=g)return e(i,r,n,l,o,a,s);e(i,r.slice(0,p.to-u),n,l,null,a,s),l=null,r=r.slice(p.to-u),u=p.to}}}function Vl(e,t,i,r){var n=!r&&i.widgetNode;n&&e.map.push(e.pos,e.pos+t,n),!r&&e.cm.display.input.needsContentAttribute&&(n||(n=e.content.appendChild(document.createElement("span"))),n.setAttribute("cm-marker",i.id)),n&&(e.cm.display.input.setUneditable(n),e.content.appendChild(n)),e.pos+=t,e.trailingSpace=!1}function Ws(e,t,i){var r=e.markedSpans,n=e.text,l=0;if(!r){for(var o=1;os||fe.collapsed&&V.to==s&&V.from==s)){if(V.to!=null&&V.to!=s&&C>V.to&&(C=V.to,W=""),fe.className&&(E+=" "+fe.className),fe.css&&(T=(T?T+";":"")+fe.css),fe.startStyle&&V.from==s&&(B+=" "+fe.startStyle),fe.endStyle&&V.to==C&&(X||(X=[])).push(fe.endStyle,V.to),fe.title&&(($||($={})).title=fe.title),fe.attributes)for(var we in fe.attributes)($||($={}))[we]=fe.attributes[we];fe.collapsed&&(!U||Nn(U.marker,fe)<0)&&(U=V)}else V.from>s&&C>V.from&&(C=V.from)}if(X)for(var Ue=0;Ue=a)break;for(var st=Math.min(a,C);;){if(g){var nt=s+g.length;if(!U){var We=nt>st?g.slice(0,st-s):g;t.addToken(t,We,p?p+E:E,B,s+We.length==C?W:"",T,$)}if(nt>=st){g=g.slice(st-s),s=st;break}s=nt,B=""}g=n.slice(l,l=i[u++]),p=Jl(i[u++],t.cm.options)}}}function eo(e,t,i){this.line=t,this.rest=ks(t),this.size=this.rest?pe(f(this.rest))-i+1:1,this.node=this.text=null,this.hidden=Bt(e,t)}function Bi(e,t,i){for(var r=[],n,l=t;l2&&l.push((s.bottom+u.top)/2-i.top)}}l.push(i.bottom-i.top)}}function ao(e,t,i){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};if(e.rest){for(var r=0;ri)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}}function $s(e,t){t=pt(t);var i=pe(t),r=e.display.externalMeasured=new eo(e.doc,t,i);r.lineN=i;var n=r.built=jl(e,r);return r.text=n.pre,De(e.display.lineMeasure,n.pre),r}function so(e,t,i,r){return Lt(e,Lr(e,t),i,r)}function Pn(e,t){if(t>=e.display.viewFrom&&t=i.lineN&&tt)&&(l=s-a,n=l-1,t>=s&&(o="right")),n!=null){if(r=e[u+2],a==s&&i==(r.insertLeft?"left":"right")&&(o=i),i=="left"&&n==0)for(;u&&e[u-2]==e[u-3]&&e[u-1].insertLeft;)r=e[(u-=3)+2],o="left";if(i=="right"&&n==s-a)for(;u=0&&(i=e[n]).left==i.right;n--);return i}function Ys(e,t,i,r){var n=fo(t.map,i,r),l=n.node,o=n.start,a=n.end,s=n.collapse,u;if(l.nodeType==3){for(var g=0;g<4;g++){for(;o&&ue(t.line.text.charAt(n.coverStart+o));)--o;for(;n.coverStart+a0&&(s=r="right");var p;e.options.lineWrapping&&(p=l.getClientRects()).length>1?u=p[r=="right"?p.length-1:0]:u=l.getBoundingClientRect()}if(d&&v<9&&!o&&(!u||!u.left&&!u.right)){var T=l.parentNode.getClientRects()[0];T?u={left:T.left,right:T.left+kr(e.display),top:T.top,bottom:T.bottom}:u=uo}for(var C=u.top-t.rect.top,E=u.bottom-t.rect.top,W=(C+E)/2,B=t.view.measure.heights,U=0;U=r.text.length?(s=r.text.length,u="before"):s<=0&&(s=0,u="after"),!a)return o(u=="before"?s-1:s,u=="before");function g(E,W,B){var U=a[W],$=U.level==1;return o(B?E-1:E,$!=B)}var p=Ne(a,s,u),T=be,C=g(s,p,u=="before");return T!=null&&(C.other=g(s,T,u!="before")),C}function yo(e,t){var i=0;t=se(e.doc,t),e.options.lineWrapping||(i=kr(e.display)*t.ch);var r=j(e.doc,t.line),n=Dt(r)+Ri(e.display);return{left:i,right:i,top:n,bottom:n+r.height}}function Rn(e,t,i,r,n){var l=P(e,t,i);return l.xRel=n,r&&(l.outside=r),l}function zn(e,t,i){var r=e.doc;if(i+=e.display.viewOffset,i<0)return Rn(r.first,0,null,-1,-1);var n=er(r,i),l=r.first+r.size-1;if(n>l)return Rn(r.first+r.size-1,j(r,l).text.length,null,1,1);t<0&&(t=0);for(var o=j(r,n);;){var a=Zs(e,o,n,t,i),s=Ls(o,a.ch+(a.xRel>0||a.outside>0?1:0));if(!s)return a;var u=s.find(1);if(u.line==n)return u;o=j(r,n=u.line)}}function mo(e,t,i,r){r-=Bn(t);var n=t.text.length,l=me(function(o){return Lt(e,i,o-1).bottom<=r},n,0);return n=me(function(o){return Lt(e,i,o).top>r},l,n),{begin:l,end:n}}function bo(e,t,i,r){i||(i=Lr(e,t));var n=zi(e,t,Lt(e,i,r),"line").top;return mo(e,t,i,n)}function Un(e,t,i,r){return e.bottom<=i?!1:e.top>i?!0:(r?e.left:e.right)>t}function Zs(e,t,i,r,n){n-=Dt(t);var l=Lr(e,t),o=Bn(t),a=0,s=t.text.length,u=!0,g=ge(t,e.doc.direction);if(g){var p=(e.options.lineWrapping?Js:Qs)(e,t,i,l,g,r,n);u=p.level!=1,a=u?p.from:p.to-1,s=u?p.to:p.from-1}var T=null,C=null,E=me(function(ee){var V=Lt(e,l,ee);return V.top+=o,V.bottom+=o,Un(V,r,n,!1)?(V.top<=n&&V.left<=r&&(T=ee,C=V),!0):!1},a,s),W,B,U=!1;if(C){var $=r-C.left=X.bottom?1:0}return E=ce(t.text,E,1),Rn(i,E,B,U,r-W)}function Qs(e,t,i,r,n,l,o){var a=me(function(p){var T=n[p],C=T.level!=1;return Un(vt(e,P(i,C?T.to:T.from,C?"before":"after"),"line",t,r),l,o,!0)},0,n.length-1),s=n[a];if(a>0){var u=s.level!=1,g=vt(e,P(i,u?s.from:s.to,u?"after":"before"),"line",t,r);Un(g,l,o,!0)&&g.top>o&&(s=n[a-1])}return s}function Js(e,t,i,r,n,l,o){var a=mo(e,t,r,o),s=a.begin,u=a.end;/\s/.test(t.text.charAt(u-1))&&u--;for(var g=null,p=null,T=0;T=u||C.to<=s)){var E=C.level!=1,W=Lt(e,r,E?Math.min(u,C.to)-1:Math.max(s,C.from)).right,B=WB)&&(g=C,p=B)}}return g||(g=n[n.length-1]),g.fromu&&(g={from:g.from,to:u,level:g.level}),g}var rr;function Tr(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(rr==null){rr=Q("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)rr.appendChild(document.createTextNode("x")),rr.appendChild(Q("br"));rr.appendChild(document.createTextNode("x"))}De(e.measure,rr);var i=rr.offsetHeight/50;return i>3&&(e.cachedTextHeight=i),qe(e.measure),i||1}function kr(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=Q("span","xxxxxxxxxx"),i=Q("pre",[t],"CodeMirror-line-like");De(e.measure,i);var r=t.getBoundingClientRect(),n=(r.right-r.left)/10;return n>2&&(e.cachedCharWidth=n),n||10}function Gn(e){for(var t=e.display,i={},r={},n=t.gutters.clientLeft,l=t.gutters.firstChild,o=0;l;l=l.nextSibling,++o){var a=e.display.gutterSpecs[o].className;i[a]=l.offsetLeft+l.clientLeft+n,r[a]=l.clientWidth}return{fixedPos:Kn(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:i,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Kn(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function wo(e){var t=Tr(e.display),i=e.options.lineWrapping,r=i&&Math.max(5,e.display.scroller.clientWidth/kr(e.display)-3);return function(n){if(Bt(e.doc,n))return 0;var l=0;if(n.widgets)for(var o=0;o0&&(u=j(e.doc,s.line).text).length==s.ch){var g=Ze(u,u.length,e.options.tabSize)-u.length;s=P(s.line,Math.max(0,Math.round((l-oo(e.display).left)/kr(e.display))-g))}return s}function nr(e,t){if(t>=e.display.viewTo||(t-=e.display.viewFrom,t<0))return null;for(var i=e.display.view,r=0;rt)&&(n.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=n.viewTo)_t&&On(e.doc,t)n.viewFrom?zt(e):(n.viewFrom+=r,n.viewTo+=r);else if(t<=n.viewFrom&&i>=n.viewTo)zt(e);else if(t<=n.viewFrom){var l=Gi(e,i,i+r,1);l?(n.view=n.view.slice(l.index),n.viewFrom=l.lineN,n.viewTo+=r):zt(e)}else if(i>=n.viewTo){var o=Gi(e,t,t,-1);o?(n.view=n.view.slice(0,o.index),n.viewTo=o.lineN):zt(e)}else{var a=Gi(e,t,t,-1),s=Gi(e,i,i+r,1);a&&s?(n.view=n.view.slice(0,a.index).concat(Bi(e,a.lineN,s.lineN)).concat(n.view.slice(s.index)),n.viewTo+=r):zt(e)}var u=n.externalMeasured;u&&(i=n.lineN&&t=r.viewTo)){var l=r.view[nr(e,t)];if(l.node!=null){var o=l.changes||(l.changes=[]);Se(o,i)==-1&&o.push(i)}}}function zt(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Gi(e,t,i,r){var n=nr(e,t),l,o=e.display.view;if(!_t||i==e.doc.first+e.doc.size)return{index:n,lineN:i};for(var a=e.display.viewFrom,s=0;s0){if(n==o.length-1)return null;l=a+o[n].size-t,n++}else l=a-t;t+=l,i+=l}for(;On(e.doc,i)!=i;){if(n==(r<0?0:o.length-1))return null;i+=r*o[n-(r<0?1:0)].size,n+=r}return{index:n,lineN:i}}function js(e,t,i){var r=e.display,n=r.view;n.length==0||t>=r.viewTo||i<=r.viewFrom?(r.view=Bi(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=Bi(e,t,r.viewFrom).concat(r.view):r.viewFromi&&(r.view=r.view.slice(0,nr(e,i)))),r.viewTo=i}function Co(e){for(var t=e.display.view,i=0,r=0;r=e.display.viewTo||s.to().line0?o:e.defaultCharWidth())+"px"}if(r.other){var a=i.appendChild(Q("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));a.style.display="",a.style.left=r.other.left+"px",a.style.top=r.other.top+"px",a.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function Ki(e,t){return e.top-t.top||e.left-t.left}function Vs(e,t,i){var r=e.display,n=e.doc,l=document.createDocumentFragment(),o=oo(e.display),a=o.left,s=Math.max(r.sizerWidth,tr(e)-r.sizer.offsetLeft)-o.right,u=n.direction=="ltr";function g(G,X,ee,V){X<0&&(X=0),X=Math.round(X),V=Math.round(V),l.appendChild(Q("div",null,"CodeMirror-selected","position: absolute; left: "+G+`px; +`,t);n==-1&&(n=e.length);var l=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),o=l.indexOf("\r");o!=-1?(i.push(l.slice(0,o)),t+=o+1):(i.push(l),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},ss=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch{return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch{}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},us=function(){var e=Q("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),wn=null;function fs(e){if(wn!=null)return wn;var t=De(e,Q("span","x")),i=t.getBoundingClientRect(),r=bt(t,0,1).getBoundingClientRect();return wn=Math.abs(i.left-r.left)>1}var Cn={},br={};function hs(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Cn[e]=t}function cs(e,t){br[e]=t}function Di(e){if(typeof e=="string"&&br.hasOwnProperty(e))e=br[e];else if(e&&typeof e.name=="string"&&br.hasOwnProperty(e.name)){var t=br[e.name];typeof t=="string"&&(t={name:t}),e=M(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Di("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Di("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function Sn(e,t){t=Di(t);var i=Cn[t.name];if(!i)return Sn(e,"text/plain");var r=i(e,t);if(wr.hasOwnProperty(t.name)){var n=wr[t.name];for(var l in n)n.hasOwnProperty(l)&&(r.hasOwnProperty(l)&&(r["_"+l]=r[l]),r[l]=n[l])}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var o in t.modeProps)r[o]=t.modeProps[o];return r}var wr={};function ds(e,t){var i=wr.hasOwnProperty(e)?wr[e]:wr[e]={};dt(t,i)}function jt(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var i={};for(var r in t){var n=t[r];n instanceof Array&&(n=n.concat([])),i[r]=n}return i}function Ln(e,t){for(var i;e.innerMode&&(i=e.innerMode(t),!(!i||i.mode==e));)t=i.state,e=i.mode;return i||{mode:e,state:t}}function Wl(e,t,i){return e.startState?e.startState(t,i):!0}var Ee=function(e,t,i){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=i};Ee.prototype.eol=function(){return this.pos>=this.string.length},Ee.prototype.sol=function(){return this.pos==this.lineStart},Ee.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Ee.prototype.next=function(){if(this.post},Ee.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Ee.prototype.skipToEnd=function(){this.pos=this.string.length},Ee.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Ee.prototype.backUp=function(e){this.pos-=e},Ee.prototype.column=function(){return this.lastColumnPos0?null:(l&&t!==!1&&(this.pos+=l[0].length),l)}},Ee.prototype.current=function(){return this.string.slice(this.start,this.pos)},Ee.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Ee.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Ee.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function j(e,t){if(t-=e.first,t<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var i=e;!i.lines;)for(var r=0;;++r){var n=i.children[r],l=n.chunkSize();if(t=e.first&&ti?P(i,j(e,i).text.length):gs(t,j(e,t.line).text.length)}function gs(e,t){var i=e.ch;return i==null||i>t?P(e.line,t):i<0?P(e.line,0):e}function Fl(e,t){for(var i=[],r=0;rthis.maxLookAhead&&(this.maxLookAhead=e),t},Ct.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},Ct.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},Ct.fromSaved=function(e,t,i){return t instanceof Ei?new Ct(e,jt(e.mode,t.state),i,t.lookAhead):new Ct(e,jt(e.mode,t),i)},Ct.prototype.save=function(e){var t=e!==!1?jt(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Ei(t,this.maxLookAhead):t};function Hl(e,t,i,r){var n=[e.state.modeGen],l={};Gl(e,t.text,e.doc.mode,i,function(u,g){return n.push(u,g)},l,r);for(var o=i.state,a=function(u){i.baseTokens=n;var g=e.state.overlays[u],p=1,T=0;i.state=!0,Gl(e,t.text,g.mode,i,function(S,O){for(var W=p;TS&&n.splice(p,1,S,n[p+1],B),p+=2,T=Math.min(S,B)}if(O)if(g.opaque)n.splice(W,p-W,S,"overlay "+O),p=W+2;else for(;We.options.maxHighlightLength&&jt(e.doc.mode,r.state),l=Hl(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=l.styles,l.classes?t.styleClasses=l.classes:t.styleClasses&&(t.styleClasses=null),i===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function Yr(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new Ct(r,!0,t);var l=ps(e,t,i),o=l>r.first&&j(r,l-1).stateAfter,a=o?Ct.fromSaved(r,o,l):new Ct(r,Wl(r.mode),l);return r.iter(l,t,function(s){Mn(e,s.text,a);var u=a.line;s.stateAfter=u==t-1||u%5==0||u>=n.viewFrom&&ut.start)return l}throw new Error("Mode "+e.name+" failed to advance stream.")}var Rl=function(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i};function zl(e,t,i,r){var n=e.doc,l=n.mode,o;t=se(n,t);var a=j(n,t.line),s=Yr(e,t.line,i),u=new Ee(a.text,e.options.tabSize,s),g;for(r&&(g=[]);(r||u.pose.options.maxHighlightLength?(a=!1,o&&Mn(e,t,r,g.pos),g.pos=t.length,p=null):p=Ul(_n(i,g,r.state,T),l),T){var S=T[0].name;S&&(p="m-"+(p?S+" "+p:S))}if(!a||u!=p){for(;so;--a){if(a<=l.first)return l.first;var s=j(l,a-1),u=s.stateAfter;if(u&&(!i||a+(u instanceof Ei?u.lookAhead:0)<=l.modeFrontier))return a;var g=Ze(s.text,null,e.options.tabSize);(n==null||r>g)&&(n=a-1,r=g)}return n}function vs(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontieri;r--){var n=j(e,r).stateAfter;if(n&&(!(n instanceof Ei)||r+n.lookAhead=t:l.to>t);(r||(r=[])).push(new Wi(o,l.from,s?null:l.to))}}return r}function Ss(e,t,i){var r;if(e)for(var n=0;n=t:l.to>t);if(a||l.from==t&&o.type=="bookmark"&&(!i||l.marker.insertLeft)){var s=l.from==null||(o.inclusiveLeft?l.from<=t:l.from0&&a)for(var X=0;X0)){var g=[s,1],p=ae(u.from,a.from),T=ae(u.to,a.to);(p<0||!o.inclusiveLeft&&!p)&&g.push({from:u.from,to:a.from}),(T>0||!o.inclusiveRight&&!T)&&g.push({from:a.to,to:u.to}),n.splice.apply(n,g),s+=g.length-3}}return n}function Xl(e){var t=e.markedSpans;if(t){for(var i=0;it)&&(!r||Nn(r,l.marker)<0)&&(r=l.marker)}return r}function Ql(e,t,i,r,n){var l=j(e,t),o=_t&&l.markedSpans;if(o)for(var a=0;a=0&&p<=0||g<=0&&p>=0)&&(g<=0&&(s.marker.inclusiveRight&&n.inclusiveLeft?ae(u.to,i)>=0:ae(u.to,i)>0)||g>=0&&(s.marker.inclusiveRight&&n.inclusiveLeft?ae(u.from,r)<=0:ae(u.from,r)<0)))return!0}}}function pt(e){for(var t;t=Zl(e);)e=t.find(-1,!0).line;return e}function ks(e){for(var t;t=Hi(e);)e=t.find(1,!0).line;return e}function xs(e){for(var t,i;t=Hi(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function On(e,t){var i=j(e,t),r=pt(i);return i==r?t:pe(r)}function Jl(e,t){if(t>e.lastLine())return t;var i=j(e,t),r;if(!Bt(e,i))return t;for(;r=Hi(i);)i=r.find(1,!0).line;return pe(i)+1}function Bt(e,t){var i=_t&&t.markedSpans;if(i){for(var r=void 0,n=0;nt.maxLineLength&&(t.maxLineLength=n,t.maxLine=r)})}var Cr=function(e,t,i){this.text=e,Yl(this,t),this.height=i?i(this):1};Cr.prototype.lineNo=function(){return pe(this)},Mt(Cr);function As(e,t,i,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),Xl(e),Yl(e,i);var n=r?r(e):1;n!=e.height&&wt(e,n)}function Ms(e){e.parent=null,Xl(e)}var _s={},Ds={};function jl(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?Ds:_s;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function Vl(e,t){var i=kt("span",null,null,b?"padding-right: .1px":null),r={pre:kt("pre",[i],"CodeMirror-line"),content:i,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var n=0;n<=(t.rest?t.rest.length:0);n++){var l=n?t.rest[n-1]:t.line,o=void 0;r.pos=0,r.addToken=Os,as(e.display.measure)&&(o=ge(l,e.doc.direction))&&(r.addToken=Ws(r.addToken,o)),r.map=[];var a=t!=e.display.externalMeasured&&pe(l);Is(l,r,Pl(e,l,a)),l.styleClasses&&(l.styleClasses.bgClass&&(r.bgClass=zr(l.styleClasses.bgClass,r.bgClass||"")),l.styleClasses.textClass&&(r.textClass=zr(l.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(os(e.display.measure))),n==0?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(b){var s=r.content.lastChild;(/\bcm-tab\b/.test(s.className)||s.querySelector&&s.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return Te(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=zr(r.pre.className,r.textClass||"")),r}function Ns(e){var t=Q("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Os(e,t,i,r,n,l,o){if(t){var a=e.splitSpaces?Es(t,e.trailingSpace):t,s=e.cm.state.specialChars,u=!1,g;if(!s.test(t))e.col+=t.length,g=document.createTextNode(a),e.map.push(e.pos,e.pos+t.length,g),d&&v<9&&(u=!0),e.pos+=t.length;else{g=document.createDocumentFragment();for(var p=0;;){s.lastIndex=p;var T=s.exec(t),S=T?T.index-p:t.length-p;if(S){var O=document.createTextNode(a.slice(p,p+S));d&&v<9?g.appendChild(Q("span",[O])):g.appendChild(O),e.map.push(e.pos,e.pos+S,O),e.col+=S,e.pos+=S}if(!T)break;p+=S+1;var W=void 0;if(T[0]==" "){var B=e.cm.options.tabSize,U=B-e.col%B;W=g.appendChild(Q("span",yr(U),"cm-tab")),W.setAttribute("role","presentation"),W.setAttribute("cm-text"," "),e.col+=U}else T[0]=="\r"||T[0]==` +`?(W=g.appendChild(Q("span",T[0]=="\r"?"␍":"␤","cm-invalidchar")),W.setAttribute("cm-text",T[0]),e.col+=1):(W=e.cm.options.specialCharPlaceholder(T[0]),W.setAttribute("cm-text",T[0]),d&&v<9?g.appendChild(Q("span",[W])):g.appendChild(W),e.col+=1);e.map.push(e.pos,e.pos+1,W),e.pos++}}if(e.trailingSpace=a.charCodeAt(t.length-1)==32,i||r||n||u||l||o){var $=i||"";r&&($+=r),n&&($+=n);var G=Q("span",[g],$,l);if(o)for(var X in o)o.hasOwnProperty(X)&&X!="style"&&X!="class"&&G.setAttribute(X,o[X]);return e.content.appendChild(G)}e.content.appendChild(g)}}function Es(e,t){if(e.length>1&&!/ /.test(e))return e;for(var i=t,r="",n=0;nu&&p.from<=u));T++);if(p.to>=g)return e(i,r,n,l,o,a,s);e(i,r.slice(0,p.to-u),n,l,null,a,s),l=null,r=r.slice(p.to-u),u=p.to}}}function eo(e,t,i,r){var n=!r&&i.widgetNode;n&&e.map.push(e.pos,e.pos+t,n),!r&&e.cm.display.input.needsContentAttribute&&(n||(n=e.content.appendChild(document.createElement("span"))),n.setAttribute("cm-marker",i.id)),n&&(e.cm.display.input.setUneditable(n),e.content.appendChild(n)),e.pos+=t,e.trailingSpace=!1}function Is(e,t,i){var r=e.markedSpans,n=e.text,l=0;if(!r){for(var o=1;os||fe.collapsed&&V.to==s&&V.from==s)){if(V.to!=null&&V.to!=s&&S>V.to&&(S=V.to,W=""),fe.className&&(O+=" "+fe.className),fe.css&&(T=(T?T+";":"")+fe.css),fe.startStyle&&V.from==s&&(B+=" "+fe.startStyle),fe.endStyle&&V.to==S&&(X||(X=[])).push(fe.endStyle,V.to),fe.title&&(($||($={})).title=fe.title),fe.attributes)for(var we in fe.attributes)($||($={}))[we]=fe.attributes[we];fe.collapsed&&(!U||Nn(U.marker,fe)<0)&&(U=V)}else V.from>s&&S>V.from&&(S=V.from)}if(X)for(var Ue=0;Ue=a)break;for(var st=Math.min(a,S);;){if(g){var nt=s+g.length;if(!U){var We=nt>st?g.slice(0,st-s):g;t.addToken(t,We,p?p+O:O,B,s+We.length==S?W:"",T,$)}if(nt>=st){g=g.slice(st-s),s=st;break}s=nt,B=""}g=n.slice(l,l=i[u++]),p=jl(i[u++],t.cm.options)}}}function to(e,t,i){this.line=t,this.rest=xs(t),this.size=this.rest?pe(f(this.rest))-i+1:1,this.node=this.text=null,this.hidden=Bt(e,t)}function Bi(e,t,i){for(var r=[],n,l=t;l2&&l.push((s.bottom+u.top)/2-i.top)}}l.push(i.bottom-i.top)}}function so(e,t,i){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};if(e.rest){for(var r=0;ri)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}}function Xs(e,t){t=pt(t);var i=pe(t),r=e.display.externalMeasured=new to(e.doc,t,i);r.lineN=i;var n=r.built=Vl(e,r);return r.text=n.pre,De(e.display.lineMeasure,n.pre),r}function uo(e,t,i,r){return Lt(e,Lr(e,t),i,r)}function Pn(e,t){if(t>=e.display.viewFrom&&t=i.lineN&&tt)&&(l=s-a,n=l-1,t>=s&&(o="right")),n!=null){if(r=e[u+2],a==s&&i==(r.insertLeft?"left":"right")&&(o=i),i=="left"&&n==0)for(;u&&e[u-2]==e[u-3]&&e[u-1].insertLeft;)r=e[(u-=3)+2],o="left";if(i=="right"&&n==s-a)for(;u=0&&(i=e[n]).left==i.right;n--);return i}function qs(e,t,i,r){var n=ho(t.map,i,r),l=n.node,o=n.start,a=n.end,s=n.collapse,u;if(l.nodeType==3){for(var g=0;g<4;g++){for(;o&&ue(t.line.text.charAt(n.coverStart+o));)--o;for(;n.coverStart+a0&&(s=r="right");var p;e.options.lineWrapping&&(p=l.getClientRects()).length>1?u=p[r=="right"?p.length-1:0]:u=l.getBoundingClientRect()}if(d&&v<9&&!o&&(!u||!u.left&&!u.right)){var T=l.parentNode.getClientRects()[0];T?u={left:T.left,right:T.left+kr(e.display),top:T.top,bottom:T.bottom}:u=fo}for(var S=u.top-t.rect.top,O=u.bottom-t.rect.top,W=(S+O)/2,B=t.view.measure.heights,U=0;U=r.text.length?(s=r.text.length,u="before"):s<=0&&(s=0,u="after"),!a)return o(u=="before"?s-1:s,u=="before");function g(O,W,B){var U=a[W],$=U.level==1;return o(B?O-1:O,$!=B)}var p=Ne(a,s,u),T=be,S=g(s,p,u=="before");return T!=null&&(S.other=g(s,T,u!="before")),S}function mo(e,t){var i=0;t=se(e.doc,t),e.options.lineWrapping||(i=kr(e.display)*t.ch);var r=j(e.doc,t.line),n=Dt(r)+Ri(e.display);return{left:i,right:i,top:n,bottom:n+r.height}}function Rn(e,t,i,r,n){var l=P(e,t,i);return l.xRel=n,r&&(l.outside=r),l}function zn(e,t,i){var r=e.doc;if(i+=e.display.viewOffset,i<0)return Rn(r.first,0,null,-1,-1);var n=er(r,i),l=r.first+r.size-1;if(n>l)return Rn(r.first+r.size-1,j(r,l).text.length,null,1,1);t<0&&(t=0);for(var o=j(r,n);;){var a=Qs(e,o,n,t,i),s=Ts(o,a.ch+(a.xRel>0||a.outside>0?1:0));if(!s)return a;var u=s.find(1);if(u.line==n)return u;o=j(r,n=u.line)}}function bo(e,t,i,r){r-=Bn(t);var n=t.text.length,l=me(function(o){return Lt(e,i,o-1).bottom<=r},n,0);return n=me(function(o){return Lt(e,i,o).top>r},l,n),{begin:l,end:n}}function wo(e,t,i,r){i||(i=Lr(e,t));var n=zi(e,t,Lt(e,i,r),"line").top;return bo(e,t,i,n)}function Un(e,t,i,r){return e.bottom<=i?!1:e.top>i?!0:(r?e.left:e.right)>t}function Qs(e,t,i,r,n){n-=Dt(t);var l=Lr(e,t),o=Bn(t),a=0,s=t.text.length,u=!0,g=ge(t,e.doc.direction);if(g){var p=(e.options.lineWrapping?js:Js)(e,t,i,l,g,r,n);u=p.level!=1,a=u?p.from:p.to-1,s=u?p.to:p.from-1}var T=null,S=null,O=me(function(ee){var V=Lt(e,l,ee);return V.top+=o,V.bottom+=o,Un(V,r,n,!1)?(V.top<=n&&V.left<=r&&(T=ee,S=V),!0):!1},a,s),W,B,U=!1;if(S){var $=r-S.left=X.bottom?1:0}return O=ce(t.text,O,1),Rn(i,O,B,U,r-W)}function Js(e,t,i,r,n,l,o){var a=me(function(p){var T=n[p],S=T.level!=1;return Un(vt(e,P(i,S?T.to:T.from,S?"before":"after"),"line",t,r),l,o,!0)},0,n.length-1),s=n[a];if(a>0){var u=s.level!=1,g=vt(e,P(i,u?s.from:s.to,u?"after":"before"),"line",t,r);Un(g,l,o,!0)&&g.top>o&&(s=n[a-1])}return s}function js(e,t,i,r,n,l,o){var a=bo(e,t,r,o),s=a.begin,u=a.end;/\s/.test(t.text.charAt(u-1))&&u--;for(var g=null,p=null,T=0;T=u||S.to<=s)){var O=S.level!=1,W=Lt(e,r,O?Math.min(u,S.to)-1:Math.max(s,S.from)).right,B=WB)&&(g=S,p=B)}}return g||(g=n[n.length-1]),g.fromu&&(g={from:g.from,to:u,level:g.level}),g}var rr;function Tr(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(rr==null){rr=Q("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)rr.appendChild(document.createTextNode("x")),rr.appendChild(Q("br"));rr.appendChild(document.createTextNode("x"))}De(e.measure,rr);var i=rr.offsetHeight/50;return i>3&&(e.cachedTextHeight=i),qe(e.measure),i||1}function kr(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=Q("span","xxxxxxxxxx"),i=Q("pre",[t],"CodeMirror-line-like");De(e.measure,i);var r=t.getBoundingClientRect(),n=(r.right-r.left)/10;return n>2&&(e.cachedCharWidth=n),n||10}function Gn(e){for(var t=e.display,i={},r={},n=t.gutters.clientLeft,l=t.gutters.firstChild,o=0;l;l=l.nextSibling,++o){var a=e.display.gutterSpecs[o].className;i[a]=l.offsetLeft+l.clientLeft+n,r[a]=l.clientWidth}return{fixedPos:Kn(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:i,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Kn(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function Co(e){var t=Tr(e.display),i=e.options.lineWrapping,r=i&&Math.max(5,e.display.scroller.clientWidth/kr(e.display)-3);return function(n){if(Bt(e.doc,n))return 0;var l=0;if(n.widgets)for(var o=0;o0&&(u=j(e.doc,s.line).text).length==s.ch){var g=Ze(u,u.length,e.options.tabSize)-u.length;s=P(s.line,Math.max(0,Math.round((l-ao(e.display).left)/kr(e.display))-g))}return s}function nr(e,t){if(t>=e.display.viewTo||(t-=e.display.viewFrom,t<0))return null;for(var i=e.display.view,r=0;rt)&&(n.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=n.viewTo)_t&&On(e.doc,t)n.viewFrom?zt(e):(n.viewFrom+=r,n.viewTo+=r);else if(t<=n.viewFrom&&i>=n.viewTo)zt(e);else if(t<=n.viewFrom){var l=Gi(e,i,i+r,1);l?(n.view=n.view.slice(l.index),n.viewFrom=l.lineN,n.viewTo+=r):zt(e)}else if(i>=n.viewTo){var o=Gi(e,t,t,-1);o?(n.view=n.view.slice(0,o.index),n.viewTo=o.lineN):zt(e)}else{var a=Gi(e,t,t,-1),s=Gi(e,i,i+r,1);a&&s?(n.view=n.view.slice(0,a.index).concat(Bi(e,a.lineN,s.lineN)).concat(n.view.slice(s.index)),n.viewTo+=r):zt(e)}var u=n.externalMeasured;u&&(i=n.lineN&&t=r.viewTo)){var l=r.view[nr(e,t)];if(l.node!=null){var o=l.changes||(l.changes=[]);Se(o,i)==-1&&o.push(i)}}}function zt(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Gi(e,t,i,r){var n=nr(e,t),l,o=e.display.view;if(!_t||i==e.doc.first+e.doc.size)return{index:n,lineN:i};for(var a=e.display.viewFrom,s=0;s0){if(n==o.length-1)return null;l=a+o[n].size-t,n++}else l=a-t;t+=l,i+=l}for(;On(e.doc,i)!=i;){if(n==(r<0?0:o.length-1))return null;i+=r*o[n-(r<0?1:0)].size,n+=r}return{index:n,lineN:i}}function Vs(e,t,i){var r=e.display,n=r.view;n.length==0||t>=r.viewTo||i<=r.viewFrom?(r.view=Bi(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=Bi(e,t,r.viewFrom).concat(r.view):r.viewFromi&&(r.view=r.view.slice(0,nr(e,i)))),r.viewTo=i}function So(e){for(var t=e.display.view,i=0,r=0;r=e.display.viewTo||s.to().line0?o:e.defaultCharWidth())+"px"}if(r.other){var a=i.appendChild(Q("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));a.style.display="",a.style.left=r.other.left+"px",a.style.top=r.other.top+"px",a.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function Ki(e,t){return e.top-t.top||e.left-t.left}function eu(e,t,i){var r=e.display,n=e.doc,l=document.createDocumentFragment(),o=ao(e.display),a=o.left,s=Math.max(r.sizerWidth,tr(e)-r.sizer.offsetLeft)-o.right,u=n.direction=="ltr";function g(G,X,ee,V){X<0&&(X=0),X=Math.round(X),V=Math.round(V),l.appendChild(Q("div",null,"CodeMirror-selected","position: absolute; left: "+G+`px; top: `+X+"px; width: "+(ee??s-G)+`px; - height: `+(V-X)+"px"))}function p(G,X,ee){var V=j(n,G),fe=V.text.length,we,Ue;function ke(We,lt){return Ui(e,P(G,We),"div",V,lt)}function st(We,lt,Xe){var He=bo(e,V,null,We),Ie=lt=="ltr"==(Xe=="after")?"left":"right",Ae=Xe=="after"?He.begin:He.end-(/\s/.test(V.text.charAt(He.end-1))?2:1);return ke(Ae,Ie)[Ie]}var nt=ge(V,n.direction);return Ce(nt,X||0,ee??fe,function(We,lt,Xe,He){var Ie=Xe=="ltr",Ae=ke(We,Ie?"left":"right"),ot=ke(lt-1,Ie?"right":"left"),Pr=X==null&&We==0,Yt=ee==null&<==fe,Je=He==0,Tt=!nt||He==nt.length-1;if(ot.top-Ae.top<=3){var Ge=(u?Pr:Yt)&&Je,bl=(u?Yt:Pr)&&Tt,Wt=Ge?a:(Ie?Ae:ot).left,ur=bl?s:(Ie?ot:Ae).right;g(Wt,Ae.top,ur-Wt,Ae.bottom)}else{var fr,et,Br,wl;Ie?(fr=u&&Pr&&Je?a:Ae.left,et=u?s:st(We,Xe,"before"),Br=u?a:st(lt,Xe,"after"),wl=u&&Yt&&Tt?s:ot.right):(fr=u?st(We,Xe,"before"):a,et=!u&&Pr&&Je?s:Ae.right,Br=!u&&Yt&&Tt?a:ot.left,wl=u?st(lt,Xe,"after"):s),g(fr,Ae.top,et-fr,Ae.bottom),Ae.bottom0?t.blinker=setInterval(function(){e.hasFocus()||xr(e),t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function Lo(e){e.hasFocus()||(e.display.input.focus(),e.state.focused||Zn(e))}function qn(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,e.state.focused&&xr(e))},100)}function Zn(e,t){e.state.delayingBlurEvent&&!e.state.draggingText&&(e.state.delayingBlurEvent=!1),e.options.readOnly!="nocursor"&&(e.state.focused||(Te(e,"focus",e,t),e.state.focused=!0,xt(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),b&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Yn(e))}function xr(e,t){e.state.delayingBlurEvent||(e.state.focused&&(Te(e,"blur",e,t),e.state.focused=!1,Me(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function $i(e){for(var t=e.display,i=t.lineDiv.offsetTop,r=Math.max(0,t.scroller.getBoundingClientRect().top),n=t.lineDiv.getBoundingClientRect().top,l=0,o=0;o.005||C<-.005)&&(ne.display.sizerWidth){var W=Math.ceil(g/kr(e.display));W>e.display.maxLineLength&&(e.display.maxLineLength=W,e.display.maxLine=a.line,e.display.maxLineChanged=!0)}}}Math.abs(l)>2&&(t.scroller.scrollTop+=l)}function To(e){if(e.widgets)for(var t=0;t=o&&(l=er(t,Dt(j(t,s))-e.wrapper.clientHeight),o=s)}return{from:l,to:Math.max(o,l+1)}}function eu(e,t){if(!xe(e,"scrollCursorIntoView")){var i=e.display,r=i.sizer.getBoundingClientRect(),n=null,l=i.wrapper.ownerDocument;if(t.top+r.top<0?n=!0:t.bottom+r.top>(l.defaultView.innerHeight||l.documentElement.clientHeight)&&(n=!1),n!=null&&!q){var o=Q("div","​",null,`position: absolute; + height: `+(V-X)+"px"))}function p(G,X,ee){var V=j(n,G),fe=V.text.length,we,Ue;function ke(We,lt){return Ui(e,P(G,We),"div",V,lt)}function st(We,lt,Xe){var He=wo(e,V,null,We),Ie=lt=="ltr"==(Xe=="after")?"left":"right",Ae=Xe=="after"?He.begin:He.end-(/\s/.test(V.text.charAt(He.end-1))?2:1);return ke(Ae,Ie)[Ie]}var nt=ge(V,n.direction);return Ce(nt,X||0,ee??fe,function(We,lt,Xe,He){var Ie=Xe=="ltr",Ae=ke(We,Ie?"left":"right"),ot=ke(lt-1,Ie?"right":"left"),Pr=X==null&&We==0,Yt=ee==null&<==fe,Je=He==0,Tt=!nt||He==nt.length-1;if(ot.top-Ae.top<=3){var Ge=(u?Pr:Yt)&&Je,bl=(u?Yt:Pr)&&Tt,Wt=Ge?a:(Ie?Ae:ot).left,ur=bl?s:(Ie?ot:Ae).right;g(Wt,Ae.top,ur-Wt,Ae.bottom)}else{var fr,et,Br,wl;Ie?(fr=u&&Pr&&Je?a:Ae.left,et=u?s:st(We,Xe,"before"),Br=u?a:st(lt,Xe,"after"),wl=u&&Yt&&Tt?s:ot.right):(fr=u?st(We,Xe,"before"):a,et=!u&&Pr&&Je?s:Ae.right,Br=!u&&Yt&&Tt?a:ot.left,wl=u?st(lt,Xe,"after"):s),g(fr,Ae.top,et-fr,Ae.bottom),Ae.bottom0?t.blinker=setInterval(function(){e.hasFocus()||xr(e),t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function To(e){e.hasFocus()||(e.display.input.focus(),e.state.focused||Zn(e))}function qn(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,e.state.focused&&xr(e))},100)}function Zn(e,t){e.state.delayingBlurEvent&&!e.state.draggingText&&(e.state.delayingBlurEvent=!1),e.options.readOnly!="nocursor"&&(e.state.focused||(Te(e,"focus",e,t),e.state.focused=!0,xt(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),b&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Yn(e))}function xr(e,t){e.state.delayingBlurEvent||(e.state.focused&&(Te(e,"blur",e,t),e.state.focused=!1,Me(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function $i(e){for(var t=e.display,i=t.lineDiv.offsetTop,r=Math.max(0,t.scroller.getBoundingClientRect().top),n=t.lineDiv.getBoundingClientRect().top,l=0,o=0;o.005||S<-.005)&&(ne.display.sizerWidth){var W=Math.ceil(g/kr(e.display));W>e.display.maxLineLength&&(e.display.maxLineLength=W,e.display.maxLine=a.line,e.display.maxLineChanged=!0)}}}Math.abs(l)>2&&(t.scroller.scrollTop+=l)}function ko(e){if(e.widgets)for(var t=0;t=o&&(l=er(t,Dt(j(t,s))-e.wrapper.clientHeight),o=s)}return{from:l,to:Math.max(o,l+1)}}function tu(e,t){if(!xe(e,"scrollCursorIntoView")){var i=e.display,r=i.sizer.getBoundingClientRect(),n=null,l=i.wrapper.ownerDocument;if(t.top+r.top<0?n=!0:t.bottom+r.top>(l.defaultView.innerHeight||l.documentElement.clientHeight)&&(n=!1),n!=null&&!q){var o=Q("div","​",null,`position: absolute; top: `+(t.top-i.viewOffset-Ri(e.display))+`px; height: `+(t.bottom-t.top+St(e)+i.barHeight)+`px; - left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(n),e.display.lineSpace.removeChild(o)}}}function tu(e,t,i,r){r==null&&(r=0);var n;!e.options.lineWrapping&&t==i&&(i=t.sticky=="before"?P(t.line,t.ch+1,"before"):t,t=t.ch?P(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t);for(var l=0;l<5;l++){var o=!1,a=vt(e,t),s=!i||i==t?a:vt(e,i);n={left:Math.min(a.left,s.left),top:Math.min(a.top,s.top)-r,right:Math.max(a.left,s.left),bottom:Math.max(a.bottom,s.bottom)+r};var u=Qn(e,n),g=e.doc.scrollTop,p=e.doc.scrollLeft;if(u.scrollTop!=null&&(ti(e,u.scrollTop),Math.abs(e.doc.scrollTop-g)>1&&(o=!0)),u.scrollLeft!=null&&(lr(e,u.scrollLeft),Math.abs(e.doc.scrollLeft-p)>1&&(o=!0)),!o)break}return n}function ru(e,t){var i=Qn(e,t);i.scrollTop!=null&&ti(e,i.scrollTop),i.scrollLeft!=null&&lr(e,i.scrollLeft)}function Qn(e,t){var i=e.display,r=Tr(e.display);t.top<0&&(t.top=0);var n=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:i.scroller.scrollTop,l=Hn(e),o={};t.bottom-t.top>l&&(t.bottom=t.top+l);var a=e.doc.height+Fn(i),s=t.topa-r;if(t.topn+l){var g=Math.min(t.top,(u?a:t.bottom)-l);g!=n&&(o.scrollTop=g)}var p=e.options.fixedGutter?0:i.gutters.offsetWidth,T=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-p,C=tr(e)-i.gutters.offsetWidth,E=t.right-t.left>C;return E&&(t.right=t.left+C),t.left<10?o.scrollLeft=0:t.leftC+T-3&&(o.scrollLeft=t.right+(E?0:10)-C),o}function Jn(e,t){t!=null&&(Yi(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t)}function Ar(e){Yi(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function ei(e,t,i){(t!=null||i!=null)&&Yi(e),t!=null&&(e.curOp.scrollLeft=t),i!=null&&(e.curOp.scrollTop=i)}function iu(e,t){Yi(e),e.curOp.scrollToPos=t}function Yi(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var i=yo(e,t.from),r=yo(e,t.to);ko(e,i,r,t.margin)}}function ko(e,t,i,r){var n=Qn(e,{left:Math.min(t.left,i.left),top:Math.min(t.top,i.top)-r,right:Math.max(t.right,i.right),bottom:Math.max(t.bottom,i.bottom)+r});ei(e,n.scrollLeft,n.scrollTop)}function ti(e,t){Math.abs(e.doc.scrollTop-t)<2||(k||Vn(e,{top:t}),xo(e,t,!0),k&&Vn(e),ni(e,100))}function xo(e,t,i){t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),!(e.display.scroller.scrollTop==t&&!i)&&(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function lr(e,t,i,r){t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),!((i?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r)&&(e.doc.scrollLeft=t,No(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function ri(e){var t=e.display,i=t.gutters.offsetWidth,r=Math.round(e.doc.height+Fn(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?i:0,docHeight:r,scrollHeight:r+St(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var or=function(e,t,i){this.cm=i;var r=this.vert=Q("div",[Q("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=Q("div",[Q("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=n.tabIndex=-1,e(r),e(n),te(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),te(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,d&&v<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};or.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(i){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var n=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+n)+"px"}else this.vert.scrollTop=0,this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=i?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var l=e.viewWidth-e.barLeft-(i?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+l)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(r==0&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:i?r:0,bottom:t?r:0}},or.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},or.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},or.prototype.zeroWidthHack=function(){var e=ne&&!Y?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.visibility=this.vert.style.visibility="hidden",this.disableHoriz=new gt,this.disableVert=new gt},or.prototype.enableZeroWidthBar=function(e,t,i){e.style.visibility="";function r(){var n=e.getBoundingClientRect(),l=i=="vert"?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1);l!=e?e.style.visibility="hidden":t.set(1e3,r)}t.set(1e3,r)},or.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var ii=function(){};ii.prototype.update=function(){return{bottom:0,right:0}},ii.prototype.setScrollLeft=function(){},ii.prototype.setScrollTop=function(){},ii.prototype.clear=function(){};function Mr(e,t){t||(t=ri(e));var i=e.display.barWidth,r=e.display.barHeight;Ao(e,t);for(var n=0;n<4&&i!=e.display.barWidth||r!=e.display.barHeight;n++)i!=e.display.barWidth&&e.options.lineWrapping&&$i(e),Ao(e,ri(e)),i=e.display.barWidth,r=e.display.barHeight}function Ao(e,t){var i=e.display,r=i.scrollbars.update(t);i.sizer.style.paddingRight=(i.barWidth=r.right)+"px",i.sizer.style.paddingBottom=(i.barHeight=r.bottom)+"px",i.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(i.scrollbarFiller.style.display="block",i.scrollbarFiller.style.height=r.bottom+"px",i.scrollbarFiller.style.width=r.right+"px"):i.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(i.gutterFiller.style.display="block",i.gutterFiller.style.height=r.bottom+"px",i.gutterFiller.style.width=t.gutterWidth+"px"):i.gutterFiller.style.display=""}var Mo={native:or,null:ii};function _o(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&Me(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Mo[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),te(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,i){i=="horizontal"?lr(e,t):ti(e,t)},e),e.display.scrollbars.addClass&&xt(e.display.wrapper,e.display.scrollbars.addClass)}var nu=0;function ar(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++nu,markArrays:null},Is(e.curOp)}function sr(e){var t=e.curOp;t&&Hs(t,function(i){for(var r=0;r=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new qi(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function au(e){e.updatedDisplay=e.mustUpdate&&jn(e.cm,e.update)}function su(e){var t=e.cm,i=t.display;e.updatedDisplay&&$i(t),e.barMeasure=ri(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=so(t,i.maxLine,i.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+e.adjustWidthTo+St(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-tr(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=i.input.prepareSelection())}function uu(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft=e.display.viewTo)){var i=+new Date+e.options.workTime,r=Yr(e,t.highlightFrontier),n=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(l){if(r.line>=e.display.viewFrom){var o=l.styles,a=l.text.length>e.options.maxHighlightLength?jt(t.mode,r.state):null,s=Fl(e,l,r,!0);a&&(r.state=a),l.styles=s.styles;var u=l.styleClasses,g=s.classes;g?l.styleClasses=g:u&&(l.styleClasses=null);for(var p=!o||o.length!=l.styles.length||u!=g&&(!u||!g||u.bgClass!=g.bgClass||u.textClass!=g.textClass),T=0;!p&&Ti)return ni(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),n.length&&at(e,function(){for(var l=0;l=i.viewFrom&&t.visible.to<=i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&Co(e)==0)return!1;Oo(e)&&(zt(e),t.dims=Gn(e));var n=r.first+r.size,l=Math.max(t.visible.from-e.options.viewportMargin,r.first),o=Math.min(n,t.visible.to+e.options.viewportMargin);i.viewFromo&&i.viewTo-o<20&&(o=Math.min(n,i.viewTo)),_t&&(l=On(e.doc,l),o=Ql(e.doc,o));var a=l!=i.viewFrom||o!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;js(e,l,o),i.viewOffset=Dt(j(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var s=Co(e);if(!a&&s==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))return!1;var u=du(e);return s>4&&(i.lineDiv.style.display="none"),pu(e,i.updateLineNumbers,t.dims),s>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,gu(u),qe(i.cursorDiv),qe(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,a&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,ni(e,400)),i.updateLineNumbers=null,!0}function Do(e,t){for(var i=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==tr(e)){if(i&&i.top!=null&&(i={top:Math.min(e.doc.height+Fn(e.display)-Hn(e),i.top)}),t.visible=Xi(e.display,e.doc,i),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=Xi(e.display,e.doc,i));if(!jn(e,t))break;$i(e);var n=ri(e);Vr(e),Mr(e,n),tl(e,n),t.force=!1}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function Vn(e,t){var i=new qi(e,t);if(jn(e,i)){$i(e),Do(e,i);var r=ri(e);Vr(e),Mr(e,r),tl(e,r),i.finish()}}function pu(e,t,i){var r=e.display,n=e.options.lineNumbers,l=r.lineDiv,o=l.firstChild;function a(E){var W=E.nextSibling;return b&&ne&&e.display.currentWheelTarget==E?E.style.display="none":E.parentNode.removeChild(E),W}for(var s=r.view,u=r.viewFrom,g=0;g-1&&(C=!1),to(e,p,u,i)),C&&(qe(p.lineNumber),p.lineNumber.appendChild(document.createTextNode(kn(e.options,u)))),o=p.node.nextSibling}u+=p.size}for(;o;)o=a(o)}function el(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px",Be(e,"gutterChanged",e)}function tl(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+St(e)+"px"}function No(e){var t=e.display,i=t.view;if(!(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))){for(var r=Kn(t)-t.scroller.scrollLeft+e.doc.scrollLeft,n=t.gutters.offsetWidth,l=r+"px",o=0;o=105&&(n.wrapper.style.clipPath="inset(0px)"),n.wrapper.setAttribute("translate","no"),d&&v<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!b&&!(k&&ie)&&(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,n.gutterSpecs=rl(r.gutters,r.lineNumbers),Eo(n),i.init(n)}var Zi=0,Ot=null;d?Ot=-.53:k?Ot=15:A?Ot=-.7:K&&(Ot=-1/3);function Wo(e){var t=e.wheelDeltaX,i=e.wheelDeltaY;return t==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),i==null&&e.detail&&e.axis==e.VERTICAL_AXIS?i=e.detail:i==null&&(i=e.wheelDelta),{x:t,y:i}}function yu(e){var t=Wo(e);return t.x*=Ot,t.y*=Ot,t}function Io(e,t){A&&_==102&&(e.display.chromeScrollHack==null?e.display.sizer.style.pointerEvents="none":clearTimeout(e.display.chromeScrollHack),e.display.chromeScrollHack=setTimeout(function(){e.display.chromeScrollHack=null,e.display.sizer.style.pointerEvents=""},100));var i=Wo(t),r=i.x,n=i.y,l=Ot;t.deltaMode===0&&(r=t.deltaX,n=t.deltaY,l=1);var o=e.display,a=o.scroller,s=a.scrollWidth>a.clientWidth,u=a.scrollHeight>a.clientHeight;if(r&&s||n&&u){if(n&&ne&&b){e:for(var g=t.target,p=o.view;g!=a;g=g.parentNode)for(var T=0;T=0&&ae(e,r.to())<=0)return i}return-1};var de=function(e,t){this.anchor=e,this.head=t};de.prototype.from=function(){return Oi(this.anchor,this.head)},de.prototype.to=function(){return Ni(this.anchor,this.head)},de.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function yt(e,t,i){var r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(function(T,C){return ae(T.from(),C.from())}),i=Se(t,n);for(var l=1;l0:s>=0){var u=Oi(a.from(),o.from()),g=Ni(a.to(),o.to()),p=a.empty()?o.from()==o.head:a.from()==a.head;l<=i&&--i,t.splice(--l,2,new de(p?g:u,p?u:g))}}return new ft(t,i)}function Ut(e,t){return new ft([new de(e,t||e)],0)}function Gt(e){return e.text?P(e.from.line+e.text.length-1,f(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Fo(e,t){if(ae(e,t.from)<0)return e;if(ae(e,t.to)<=0)return Gt(t);var i=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Gt(t).ch-t.to.ch),P(i,r)}function il(e,t){for(var i=[],r=0;r1&&e.remove(a.line+1,E-1),e.insert(a.line+1,U)}Be(e,"change",e,t)}function Kt(e,t,i){function r(n,l,o){if(n.linked)for(var a=0;a1&&!e.done[e.done.length-2].ranges)return e.done.pop(),f(e.done)}function Uo(e,t,i,r){var n=e.history;n.undone.length=0;var l=+new Date,o,a;if((n.lastOp==r||n.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.lastModTime>l-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(o=wu(n,n.lastOp==r)))a=f(o.changes),ae(t.from,t.to)==0&&ae(t.from,a.to)==0?a.to=Gt(t):o.changes.push(ol(e,t));else{var s=f(n.done);for((!s||!s.ranges)&&Ji(e.sel,n.done),o={changes:[ol(e,t)],generation:n.generation},n.done.push(o);n.done.length>n.undoDepth;)n.done.shift(),n.done[0].ranges||n.done.shift()}n.done.push(i),n.generation=++n.maxGeneration,n.lastModTime=n.lastSelTime=l,n.lastOp=n.lastSelOp=r,n.lastOrigin=n.lastSelOrigin=t.origin,a||Te(e,"historyAdded")}function Cu(e,t,i,r){var n=t.charAt(0);return n=="*"||n=="+"&&i.ranges.length==r.ranges.length&&i.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function Su(e,t,i,r){var n=e.history,l=r&&r.origin;i==n.lastSelOp||l&&n.lastSelOrigin==l&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==l||Cu(e,l,f(n.done),t))?n.done[n.done.length-1]=t:Ji(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=l,n.lastSelOp=i,r&&r.clearRedo!==!1&&zo(n.undone)}function Ji(e,t){var i=f(t);i&&i.ranges&&i.equals(e)||t.push(e)}function Go(e,t,i,r){var n=t["spans_"+e.id],l=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,r),function(o){o.markedSpans&&((n||(n=t["spans_"+e.id]={}))[l]=o.markedSpans),++l})}function Lu(e){if(!e)return null;for(var t,i=0;i-1&&(f(a)[p]=u[p],delete u[p])}}return r}function al(e,t,i,r){if(r){var n=e.anchor;if(i){var l=ae(t,n)<0;l!=ae(i,n)<0?(n=t,t=i):l!=ae(t,i)<0&&(t=i)}return new de(n,t)}else return new de(i||t,t)}function ji(e,t,i,r,n){n==null&&(n=e.cm&&(e.cm.display.shift||e.extend)),Qe(e,new ft([al(e.sel.primary(),t,i,n)],0),r)}function $o(e,t,i){for(var r=[],n=e.cm&&(e.cm.display.shift||e.extend),l=0;l=t.ch:a.to>t.ch))){if(n&&(Te(s,"beforeCursorEnter"),s.explicitlyCleared))if(l.markedSpans){--o;continue}else break;if(!s.atomic)continue;if(i){var p=s.find(r<0?1:-1),T=void 0;if((r<0?g:u)&&(p=Jo(e,p,-r,p&&p.line==t.line?l:null)),p&&p.line==t.line&&(T=ae(p,i))&&(r<0?T<0:T>0))return Dr(e,p,t,r,n)}var C=s.find(r<0?-1:1);return(r<0?u:g)&&(C=Jo(e,C,r,C.line==t.line?l:null)),C?Dr(e,C,t,r,n):null}}return t}function en(e,t,i,r,n){var l=r||1,o=Dr(e,t,i,l,n)||!n&&Dr(e,t,i,l,!0)||Dr(e,t,i,-l,n)||!n&&Dr(e,t,i,-l,!0);return o||(e.cantEdit=!0,P(e.first,0))}function Jo(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?se(e,P(t.line-1)):null:i>0&&t.ch==(r||j(e,t.line)).text.length?t.line=0;--n)ea(e,{from:r[n].from,to:r[n].to,text:n?[""]:t.text,origin:t.origin});else ea(e,t)}}function ea(e,t){if(!(t.text.length==1&&t.text[0]==""&&ae(t.from,t.to)==0)){var i=il(e,t);Uo(e,t,i,e.cm?e.cm.curOp.id:NaN),ai(e,t,i,Dn(e,t));var r=[];Kt(e,function(n,l){!l&&Se(r,n.history)==-1&&(na(n.history,t),r.push(n.history)),ai(n,t,null,Dn(n,t))})}}function tn(e,t,i){var r=e.cm&&e.cm.state.suppressEdits;if(!(r&&!i)){for(var n=e.history,l,o=e.sel,a=t=="undo"?n.done:n.undone,s=t=="undo"?n.undone:n.done,u=0;u=0;--C){var E=T(C);if(E)return E.v}}}}function ta(e,t){if(t!=0&&(e.first+=t,e.sel=new ft(y(e.sel.ranges,function(n){return new de(P(n.anchor.line+t,n.anchor.ch),P(n.head.line+t,n.head.ch))}),e.sel.primIndex),e.cm)){rt(e.cm,e.first,e.first-t,t);for(var i=e.cm.display,r=i.viewFrom;re.lastLine())){if(t.from.linel&&(t={from:t.from,to:P(l,j(e,l).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Vt(e,t.from,t.to),i||(i=il(e,t)),e.cm?xu(e.cm,t,r):ll(e,t,r),Vi(e,i,ht),e.cantEdit&&en(e,P(e.firstLine(),0))&&(e.cantEdit=!1)}}function xu(e,t,i){var r=e.doc,n=e.display,l=t.from,o=t.to,a=!1,s=l.line;e.options.lineWrapping||(s=pe(pt(j(r,l.line))),r.iter(s,o.line+1,function(C){if(C==n.maxLine)return a=!0,!0})),r.sel.contains(t.from,t.to)>-1&&Pt(e),ll(r,t,i,wo(e)),e.options.lineWrapping||(r.iter(s,l.line+t.text.length,function(C){var E=Pi(C);E>n.maxLineLength&&(n.maxLine=C,n.maxLineLength=E,n.maxLineChanged=!0,a=!1)}),a&&(e.curOp.updateMaxLine=!0)),ps(r,l.line),ni(e,400);var u=t.text.length-(o.line-l.line)-1;t.full?rt(e):l.line==o.line&&t.text.length==1&&!Po(e.doc,t)?Rt(e,l.line,"text"):rt(e,l.line,o.line+1,u);var g=$e(e,"changes"),p=$e(e,"change");if(p||g){var T={from:l,to:o,text:t.text,removed:t.removed,origin:t.origin};p&&Be(e,"change",e,T),g&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(T)}e.display.selForContextMenu=null}function Or(e,t,i,r,n){var l;r||(r=i),ae(r,i)<0&&(l=[r,i],i=l[0],r=l[1]),typeof t=="string"&&(t=e.splitLines(t)),Nr(e,{from:i,to:r,text:t,origin:n})}function ra(e,t,i,r){i1||!(this.children[0]instanceof ui))){var a=[];this.collapse(a),this.children=[new ui(a)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t50){for(var o=n.lines.length%25+25,a=o;a10);e.parent.maybeSpill()}},iterN:function(e,t,i){for(var r=0;re.display.maxLineLength&&(e.display.maxLine=u,e.display.maxLineLength=g,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&rt(e,r,n+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Zo(e.doc)),e&&Be(e,"markerCleared",e,this,r,n),t&&sr(e),this.parent&&this.parent.clear()}},$t.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var i,r,n=0;n0||o==0&&l.clearWhenEmpty!==!1)return l;if(l.replacedWith&&(l.collapsed=!0,l.widgetNode=kt("span",[l.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||l.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(l.widgetNode.insertLeft=!0)),l.collapsed){if(Zl(e,t.line,t,i,l)||t.line!=i.line&&Zl(e,i.line,t,i,l))throw new Error("Inserting collapsed marker partially overlapping an existing one");ys()}l.addToHistory&&Uo(e,{from:t,to:i,origin:"markText"},e.sel,NaN);var a=t.line,s=e.cm,u;if(e.iter(a,i.line+1,function(p){s&&l.collapsed&&!s.options.lineWrapping&&pt(p)==s.display.maxLine&&(u=!0),l.collapsed&&a!=t.line&&wt(p,0),bs(p,new Wi(l,a==t.line?t.ch:null,a==i.line?i.ch:null),e.cm&&e.cm.curOp),++a}),l.collapsed&&e.iter(t.line,i.line+1,function(p){Bt(e,p)&&wt(p,0)}),l.clearOnEnter&&te(l,"beforeCursorEnter",function(){return l.clear()}),l.readOnly&&(vs(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),l.collapsed&&(l.id=++oa,l.atomic=!0),s){if(u&&(s.curOp.updateMaxLine=!0),l.collapsed)rt(s,t.line,i.line+1);else if(l.className||l.startStyle||l.endStyle||l.css||l.attributes||l.title)for(var g=t.line;g<=i.line;g++)Rt(s,g,"text");l.atomic&&Zo(s.doc),Be(s,"markerAdded",s,l)}return l}var ci=function(e,t){this.markers=e,this.primary=t;for(var i=0;i=0;s--)Nr(this,r[s]);a?Yo(this,a):this.cm&&Ar(this.cm)}),undo:ze(function(){tn(this,"undo")}),redo:ze(function(){tn(this,"redo")}),undoSelection:ze(function(){tn(this,"undo",!0)}),redoSelection:ze(function(){tn(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,i=0,r=0;r=e.ch)&&t.push(n.marker.parent||n.marker)}return t},findMarks:function(e,t,i){e=se(this,e),t=se(this,t);var r=[],n=e.line;return this.iter(e.line,t.line+1,function(l){var o=l.markedSpans;if(o)for(var a=0;a=s.to||s.from==null&&n!=e.line||s.from!=null&&n==t.line&&s.from>=t.ch)&&(!i||i(s.marker))&&r.push(s.marker.parent||s.marker)}++n}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var i=t.markedSpans;if(i)for(var r=0;re)return t=e,!0;e-=l,++i}),se(this,P(i,t))},indexFromPos:function(e){e=se(this,e);var t=e.ch;if(e.linet&&(t=e.from),e.to!=null&&e.to-1){t.state.draggingText(e),setTimeout(function(){return t.display.input.focus()},20);return}try{var g=e.dataTransfer.getData("Text");if(g){var p;if(t.state.draggingText&&!t.state.draggingText.copy&&(p=t.listSelections()),Vi(t.doc,Ut(i,i)),p)for(var T=0;T=0;a--)Or(e.doc,"",r[a].from,r[a].to,"+delete");Ar(e)})}function ul(e,t,i){var r=ce(e.text,t+i,i);return r<0||r>e.text.length?null:r}function fl(e,t,i){var r=ul(e,t.ch,i);return r==null?null:new P(t.line,r,i<0?"after":"before")}function hl(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var l=ge(i,t.doc.direction);if(l){var o=n<0?f(l):l[0],a=n<0==(o.level==1),s=a?"after":"before",u;if(o.level>0||t.doc.direction=="rtl"){var g=Lr(t,i);u=n<0?i.text.length-1:0;var p=Lt(t,g,u).top;u=me(function(T){return Lt(t,g,T).top==p},n<0==(o.level==1)?o.from:o.to-1,u),s=="before"&&(u=ul(i,u,1))}else u=n<0?o.to:o.from;return new P(r,u,s)}}return new P(r,n<0?i.text.length:0,n<0?"before":"after")}function Ru(e,t,i,r){var n=ge(t,e.doc.direction);if(!n)return fl(t,i,r);i.ch>=t.text.length?(i.ch=t.text.length,i.sticky="before"):i.ch<=0&&(i.ch=0,i.sticky="after");var l=Ne(n,i.ch,i.sticky),o=n[l];if(e.doc.direction=="ltr"&&o.level%2==0&&(r>0?o.to>i.ch:o.from=o.from&&T>=g.begin)){var C=p?"before":"after";return new P(i.line,T,C)}}var E=function(U,$,G){for(var X=function(we,Ue){return Ue?new P(i.line,a(we,1),"before"):new P(i.line,we,"after")};U>=0&&U0==(ee.level!=1),fe=V?G.begin:a(G.end,-1);if(ee.from<=fe&&fe0?g.end:a(g.begin,-1);return B!=null&&!(r>0&&B==t.text.length)&&(W=E(r>0?0:n.length-1,r,u(B)),W)?W:null}var pi={selectAll:jo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),ht)},killLine:function(e){return Ir(e,function(t){if(t.empty()){var i=j(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line0)n=new P(n.line,n.ch+1),e.replaceRange(l.charAt(n.ch-1)+l.charAt(n.ch-2),P(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){var o=j(e.doc,n.line-1).text;o&&(n=new P(n.line,1),e.replaceRange(l.charAt(0)+e.doc.lineSeparator()+o.charAt(o.length-1),P(n.line-1,o.length-1),n,"+transpose"))}}i.push(new de(n,n))}e.setSelections(i)})},newlineAndIndent:function(e){return at(e,function(){for(var t=e.listSelections(),i=t.length-1;i>=0;i--)e.replaceRange(e.doc.lineSeparator(),t[i].anchor,t[i].head,"+input");t=e.listSelections();for(var r=0;re&&ae(t,this.pos)==0&&i==this.button};var yi,mi;function Yu(e,t){var i=+new Date;return mi&&mi.compare(i,e,t)?(yi=mi=null,"triple"):yi&&yi.compare(i,e,t)?(mi=new dl(i,e,t),yi=null,"double"):(yi=new dl(i,e,t),mi=null,"single")}function Sa(e){var t=this,i=t.display;if(!(xe(t,e)||i.activeTouch&&i.input.supportsTouch())){if(i.input.ensurePolled(),i.shift=e.shiftKey,Nt(i,e)){b||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100));return}if(!gl(t,e)){var r=ir(t,e),n=Ol(e),l=r?Yu(r,n):"single";At(t).focus(),n==1&&t.state.selectingText&&t.state.selectingText(e),!(r&&qu(t,n,r,l,e))&&(n==1?r?Qu(t,r,l,e):vn(e)==i.scroller&&Oe(e):n==2?(r&&ji(t.doc,r),setTimeout(function(){return i.input.focus()},20)):n==3&&(Fe?t.display.input.onContextMenu(e):qn(t)))}}}function qu(e,t,i,r,n){var l="Click";return r=="double"?l="Double"+l:r=="triple"&&(l="Triple"+l),l=(t==1?"Left":t==2?"Middle":"Right")+l,vi(e,da(l,n),n,function(o){if(typeof o=="string"&&(o=pi[o]),!o)return!1;var a=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),a=o(e,i)!=Ht}finally{e.state.suppressEdits=!1}return a})}function Zu(e,t,i){var r=e.getOption("configureMouse"),n=r?r(e,t,i):{};if(n.unit==null){var l=he?i.shiftKey&&i.metaKey:i.altKey;n.unit=l?"rectangle":t=="single"?"char":t=="double"?"word":"line"}return(n.extend==null||e.doc.extend)&&(n.extend=e.doc.extend||i.shiftKey),n.addNew==null&&(n.addNew=ne?i.metaKey:i.ctrlKey),n.moveOnDrag==null&&(n.moveOnDrag=!(ne?i.altKey:i.ctrlKey)),n}function Qu(e,t,i,r){d?setTimeout(pr(Lo,e),0):e.curOp.focus=tt(Ft(e));var n=Zu(e,i,r),l=e.doc.sel,o;e.options.dragDrop&&ns&&!e.isReadOnly()&&i=="single"&&(o=l.contains(t))>-1&&(ae((o=l.ranges[o]).from(),t)<0||t.xRel>0)&&(ae(o.to(),t)>0||t.xRel<0)?Ju(e,r,t,n):ju(e,r,t,n)}function Ju(e,t,i,r){var n=e.display,l=!1,o=Re(e,function(u){b&&(n.scroller.draggable=!1),e.state.draggingText=!1,e.state.delayingBlurEvent&&(e.hasFocus()?e.state.delayingBlurEvent=!1:qn(e)),je(n.wrapper.ownerDocument,"mouseup",o),je(n.wrapper.ownerDocument,"mousemove",a),je(n.scroller,"dragstart",s),je(n.scroller,"drop",o),l||(Oe(u),r.addNew||ji(e.doc,i,null,null,r.extend),b&&!K||d&&v==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),a=function(u){l=l||Math.abs(t.clientX-u.clientX)+Math.abs(t.clientY-u.clientY)>=10},s=function(){return l=!0};b&&(n.scroller.draggable=!0),e.state.draggingText=o,o.copy=!r.moveOnDrag,te(n.wrapper.ownerDocument,"mouseup",o),te(n.wrapper.ownerDocument,"mousemove",a),te(n.scroller,"dragstart",s),te(n.scroller,"drop",o),e.state.delayingBlurEvent=!0,setTimeout(function(){return n.input.focus()},20),n.scroller.dragDrop&&n.scroller.dragDrop()}function La(e,t,i){if(i=="char")return new de(t,t);if(i=="word")return e.findWordAt(t);if(i=="line")return new de(P(t.line,0),se(e.doc,P(t.line+1,0)));var r=i(e,t);return new de(r.from,r.to)}function ju(e,t,i,r){d&&qn(e);var n=e.display,l=e.doc;Oe(t);var o,a,s=l.sel,u=s.ranges;if(r.addNew&&!r.extend?(a=l.sel.contains(i),a>-1?o=u[a]:o=new de(i,i)):(o=l.sel.primary(),a=l.sel.primIndex),r.unit=="rectangle")r.addNew||(o=new de(i,i)),i=ir(e,t,!0,!0),a=-1;else{var g=La(e,i,r.unit);r.extend?o=al(o,g.anchor,g.head,r.extend):o=g}r.addNew?a==-1?(a=u.length,Qe(l,yt(e,u.concat([o]),a),{scroll:!1,origin:"*mouse"})):u.length>1&&u[a].empty()&&r.unit=="char"&&!r.extend?(Qe(l,yt(e,u.slice(0,a).concat(u.slice(a+1)),0),{scroll:!1,origin:"*mouse"}),s=l.sel):sl(l,a,o,Ur):(a=0,Qe(l,new ft([o],0),Ur),s=l.sel);var p=i;function T(G){if(ae(p,G)!=0)if(p=G,r.unit=="rectangle"){for(var X=[],ee=e.options.tabSize,V=Ze(j(l,i.line).text,i.ch,ee),fe=Ze(j(l,G.line).text,G.ch,ee),we=Math.min(V,fe),Ue=Math.max(V,fe),ke=Math.min(i.line,G.line),st=Math.min(e.lastLine(),Math.max(i.line,G.line));ke<=st;ke++){var nt=j(l,ke).text,We=Gr(nt,we,ee);we==Ue?X.push(new de(P(ke,We),P(ke,We))):nt.length>We&&X.push(new de(P(ke,We),P(ke,Gr(nt,Ue,ee))))}X.length||X.push(new de(i,i)),Qe(l,yt(e,s.ranges.slice(0,a).concat(X),a),{origin:"*mouse",scroll:!1}),e.scrollIntoView(G)}else{var lt=o,Xe=La(e,G,r.unit),He=lt.anchor,Ie;ae(Xe.anchor,He)>0?(Ie=Xe.head,He=Oi(lt.from(),Xe.anchor)):(Ie=Xe.anchor,He=Ni(lt.to(),Xe.head));var Ae=s.ranges.slice(0);Ae[a]=Vu(e,new de(se(l,He),Ie)),Qe(l,yt(e,Ae,a),Ur)}}var C=n.wrapper.getBoundingClientRect(),E=0;function W(G){var X=++E,ee=ir(e,G,!0,r.unit=="rectangle");if(ee)if(ae(ee,p)!=0){e.curOp.focus=tt(Ft(e)),T(ee);var V=Xi(n,l);(ee.line>=V.to||ee.lineC.bottom?20:0;fe&&setTimeout(Re(e,function(){E==X&&(n.scroller.scrollTop+=fe,W(G))}),50)}}function B(G){e.state.selectingText=!1,E=1/0,G&&(Oe(G),n.input.focus()),je(n.wrapper.ownerDocument,"mousemove",U),je(n.wrapper.ownerDocument,"mouseup",$),l.history.lastSelOrigin=null}var U=Re(e,function(G){G.buttons===0||!Ol(G)?B(G):W(G)}),$=Re(e,B);e.state.selectingText=$,te(n.wrapper.ownerDocument,"mousemove",U),te(n.wrapper.ownerDocument,"mouseup",$)}function Vu(e,t){var i=t.anchor,r=t.head,n=j(e.doc,i.line);if(ae(i,r)==0&&i.sticky==r.sticky)return t;var l=ge(n);if(!l)return t;var o=Ne(l,i.ch,i.sticky),a=l[o];if(a.from!=i.ch&&a.to!=i.ch)return t;var s=o+(a.from==i.ch==(a.level!=1)?0:1);if(s==0||s==l.length)return t;var u;if(r.line!=i.line)u=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var g=Ne(l,r.ch,r.sticky),p=g-o||(r.ch-i.ch)*(a.level==1?-1:1);g==s-1||g==s?u=p<0:u=p>0}var T=l[s+(u?-1:0)],C=u==(T.level==1),E=C?T.from:T.to,W=C?"after":"before";return i.ch==E&&i.sticky==W?t:new de(new P(i.line,E,W),r)}function Ta(e,t,i,r){var n,l;if(t.touches)n=t.touches[0].clientX,l=t.touches[0].clientY;else try{n=t.clientX,l=t.clientY}catch{return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&Oe(t);var o=e.display,a=o.lineDiv.getBoundingClientRect();if(l>a.bottom||!$e(e,i))return pn(t);l-=a.top-o.viewOffset;for(var s=0;s=n){var g=er(e.doc,l),p=e.display.gutterSpecs[s];return Te(e,i,e,g,p.className,t),pn(t)}}}function gl(e,t){return Ta(e,t,"gutterClick",!0)}function ka(e,t){Nt(e.display,t)||ef(e,t)||xe(e,t,"contextmenu")||Fe||e.display.input.onContextMenu(t)}function ef(e,t){return $e(e,"gutterContextMenu")?Ta(e,t,"gutterContextMenu",!1):!1}function xa(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),jr(e)}var Fr={toString:function(){return"CodeMirror.Init"}},Aa={},on={};function tf(e){var t=e.optionHandlers;function i(r,n,l,o){e.defaults[r]=n,l&&(t[r]=o?function(a,s,u){u!=Fr&&l(a,s,u)}:l)}e.defineOption=i,e.Init=Fr,i("value","",function(r,n){return r.setValue(n)},!0),i("mode",null,function(r,n){r.doc.modeOption=n,nl(r)},!0),i("indentUnit",2,nl,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,function(r){oi(r),jr(r),rt(r)},!0),i("lineSeparator",null,function(r,n){if(r.doc.lineSep=n,!!n){var l=[],o=r.doc.first;r.doc.iter(function(s){for(var u=0;;){var g=s.text.indexOf(n,u);if(g==-1)break;u=g+n.length,l.push(P(o,g))}o++});for(var a=l.length-1;a>=0;a--)Or(r.doc,n,l[a],P(l[a].line,l[a].ch+n.length))}}),i("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\u2066\u2067\u2069\ufeff\ufff9-\ufffc]/g,function(r,n,l){r.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),l!=Fr&&r.refresh()}),i("specialCharPlaceholder",Ds,function(r){return r.refresh()},!0),i("electricChars",!0),i("inputStyle",ie?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),i("spellcheck",!1,function(r,n){return r.getInputField().spellcheck=n},!0),i("autocorrect",!1,function(r,n){return r.getInputField().autocorrect=n},!0),i("autocapitalize",!1,function(r,n){return r.getInputField().autocapitalize=n},!0),i("rtlMoveVisually",!re),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){xa(r),li(r)},!0),i("keyMap","default",function(r,n,l){var o=nn(n),a=l!=Fr&&nn(l);a&&a.detach&&a.detach(r,o),o.attach&&o.attach(r,a||null)}),i("extraKeys",null),i("configureMouse",null),i("lineWrapping",!1,nf,!0),i("gutters",[],function(r,n){r.display.gutterSpecs=rl(n,r.options.lineNumbers),li(r)},!0),i("fixedGutter",!0,function(r,n){r.display.gutters.style.left=n?Kn(r.display)+"px":"0",r.refresh()},!0),i("coverGutterNextToScrollbar",!1,function(r){return Mr(r)},!0),i("scrollbarStyle","native",function(r){_o(r),Mr(r),r.display.scrollbars.setScrollTop(r.doc.scrollTop),r.display.scrollbars.setScrollLeft(r.doc.scrollLeft)},!0),i("lineNumbers",!1,function(r,n){r.display.gutterSpecs=rl(r.options.gutters,n),li(r)},!0),i("firstLineNumber",1,li,!0),i("lineNumberFormatter",function(r){return r},li,!0),i("showCursorWhenSelecting",!1,Vr,!0),i("resetSelectionOnContextMenu",!0),i("lineWiseCopyCut",!0),i("pasteLinesPerSelection",!0),i("selectionsMayTouch",!1),i("readOnly",!1,function(r,n){n=="nocursor"&&(xr(r),r.display.input.blur()),r.display.input.readOnlyChanged(n)}),i("screenReaderLabel",null,function(r,n){n=n===""?null:n,r.display.input.screenReaderLabelChanged(n)}),i("disableInput",!1,function(r,n){n||r.display.input.reset()},!0),i("dragDrop",!0,rf),i("allowDropFileTypes",null),i("cursorBlinkRate",530),i("cursorScrollMargin",0),i("cursorHeight",1,Vr,!0),i("singleCursorHeightPerLine",!0,Vr,!0),i("workTime",100),i("workDelay",100),i("flattenSpans",!0,oi,!0),i("addModeClass",!1,oi,!0),i("pollInterval",100),i("undoDepth",200,function(r,n){return r.doc.history.undoDepth=n}),i("historyEventDelay",1250),i("viewportMargin",10,function(r){return r.refresh()},!0),i("maxHighlightLength",1e4,oi,!0),i("moveInputWithCursor",!0,function(r,n){n||r.display.input.resetPosition()}),i("tabindex",null,function(r,n){return r.display.input.getField().tabIndex=n||""}),i("autofocus",null),i("direction","ltr",function(r,n){return r.doc.setDirection(n)},!0),i("phrases",null)}function rf(e,t,i){var r=i&&i!=Fr;if(!t!=!r){var n=e.display.dragFunctions,l=t?te:je;l(e.display.scroller,"dragstart",n.start),l(e.display.scroller,"dragenter",n.enter),l(e.display.scroller,"dragover",n.over),l(e.display.scroller,"dragleave",n.leave),l(e.display.scroller,"drop",n.drop)}}function nf(e){e.options.lineWrapping?(xt(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Me(e.display.wrapper,"CodeMirror-wrap"),Wn(e)),$n(e),rt(e),jr(e),setTimeout(function(){return Mr(e)},100)}function Le(e,t){var i=this;if(!(this instanceof Le))return new Le(e,t);this.options=t=t?dt(t):{},dt(Aa,t,!1);var r=t.value;typeof r=="string"?r=new it(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var n=new Le.inputStyles[t.inputStyle](this),l=this.display=new vu(e,r,n,t);l.wrapper.CodeMirror=this,xa(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),_o(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new gt,keySeq:null,specialChars:null},t.autofocus&&!ie&&l.input.focus(),d&&v<11&&setTimeout(function(){return i.display.input.reset(!0)},20),lf(this),Iu(),ar(this),this.curOp.forceUpdate=!0,Bo(this,r),t.autofocus&&!ie||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&Zn(i)},20):xr(this);for(var o in on)on.hasOwnProperty(o)&&on[o](this,t[o],Fr);Oo(this),t.finishInit&&t.finishInit(this);for(var a=0;a20*20}te(t.scroller,"touchstart",function(s){if(!xe(e,s)&&!l(s)&&!gl(e,s)){t.input.ensurePolled(),clearTimeout(i);var u=+new Date;t.activeTouch={start:u,moved:!1,prev:u-r.end<=300?r:null},s.touches.length==1&&(t.activeTouch.left=s.touches[0].pageX,t.activeTouch.top=s.touches[0].pageY)}}),te(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),te(t.scroller,"touchend",function(s){var u=t.activeTouch;if(u&&!Nt(t,s)&&u.left!=null&&!u.moved&&new Date-u.start<300){var g=e.coordsChar(t.activeTouch,"page"),p;!u.prev||o(u,u.prev)?p=new de(g,g):!u.prev.prev||o(u,u.prev.prev)?p=e.findWordAt(g):p=new de(P(g.line,0),se(e.doc,P(g.line+1,0))),e.setSelection(p.anchor,p.head),e.focus(),Oe(s)}n()}),te(t.scroller,"touchcancel",n),te(t.scroller,"scroll",function(){t.scroller.clientHeight&&(ti(e,t.scroller.scrollTop),lr(e,t.scroller.scrollLeft,!0),Te(e,"scroll",e))}),te(t.scroller,"mousewheel",function(s){return Io(e,s)}),te(t.scroller,"DOMMouseScroll",function(s){return Io(e,s)}),te(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(s){xe(e,s)||$r(s)},over:function(s){xe(e,s)||(Wu(e,s),$r(s))},start:function(s){return Eu(e,s)},drop:Re(e,Ou),leave:function(s){xe(e,s)||ua(e)}};var a=t.input.getField();te(a,"keyup",function(s){return wa.call(e,s)}),te(a,"keydown",Re(e,ba)),te(a,"keypress",Re(e,Ca)),te(a,"focus",function(s){return Zn(e,s)}),te(a,"blur",function(s){return xr(e,s)})}var pl=[];Le.defineInitHook=function(e){return pl.push(e)};function bi(e,t,i,r){var n=e.doc,l;i==null&&(i="add"),i=="smart"&&(n.mode.indent?l=Yr(e,t).state:i="prev");var o=e.options.tabSize,a=j(n,t),s=Ze(a.text,null,o);a.stateAfter&&(a.stateAfter=null);var u=a.text.match(/^\s*/)[0],g;if(!r&&!/\S/.test(a.text))g=0,i="not";else if(i=="smart"&&(g=n.mode.indent(l,a.text.slice(u.length),a.text),g==Ht||g>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?g=Ze(j(n,t-1).text,null,o):g=0:i=="add"?g=s+e.options.indentUnit:i=="subtract"?g=s-e.options.indentUnit:typeof i=="number"&&(g=s+i),g=Math.max(0,g);var p="",T=0;if(e.options.indentWithTabs)for(var C=Math.floor(g/o);C;--C)T+=o,p+=" ";if(To,s=bn(t),u=null;if(a&&r.ranges.length>1)if(mt&&mt.text.join(` -`)==t){if(r.ranges.length%mt.text.length==0){u=[];for(var g=0;g=0;T--){var C=r.ranges[T],E=C.from(),W=C.to();C.empty()&&(i&&i>0?E=P(E.line,E.ch-i):e.state.overwrite&&!a?W=P(W.line,Math.min(j(l,W.line).text.length,W.ch+f(s).length)):a&&mt&&mt.lineWise&&mt.text.join(` + left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(n),e.display.lineSpace.removeChild(o)}}}function ru(e,t,i,r){r==null&&(r=0);var n;!e.options.lineWrapping&&t==i&&(i=t.sticky=="before"?P(t.line,t.ch+1,"before"):t,t=t.ch?P(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t);for(var l=0;l<5;l++){var o=!1,a=vt(e,t),s=!i||i==t?a:vt(e,i);n={left:Math.min(a.left,s.left),top:Math.min(a.top,s.top)-r,right:Math.max(a.left,s.left),bottom:Math.max(a.bottom,s.bottom)+r};var u=Qn(e,n),g=e.doc.scrollTop,p=e.doc.scrollLeft;if(u.scrollTop!=null&&(ti(e,u.scrollTop),Math.abs(e.doc.scrollTop-g)>1&&(o=!0)),u.scrollLeft!=null&&(lr(e,u.scrollLeft),Math.abs(e.doc.scrollLeft-p)>1&&(o=!0)),!o)break}return n}function iu(e,t){var i=Qn(e,t);i.scrollTop!=null&&ti(e,i.scrollTop),i.scrollLeft!=null&&lr(e,i.scrollLeft)}function Qn(e,t){var i=e.display,r=Tr(e.display);t.top<0&&(t.top=0);var n=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:i.scroller.scrollTop,l=Hn(e),o={};t.bottom-t.top>l&&(t.bottom=t.top+l);var a=e.doc.height+Fn(i),s=t.topa-r;if(t.topn+l){var g=Math.min(t.top,(u?a:t.bottom)-l);g!=n&&(o.scrollTop=g)}var p=e.options.fixedGutter?0:i.gutters.offsetWidth,T=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-p,S=tr(e)-i.gutters.offsetWidth,O=t.right-t.left>S;return O&&(t.right=t.left+S),t.left<10?o.scrollLeft=0:t.leftS+T-3&&(o.scrollLeft=t.right+(O?0:10)-S),o}function Jn(e,t){t!=null&&(Yi(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t)}function Ar(e){Yi(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function ei(e,t,i){(t!=null||i!=null)&&Yi(e),t!=null&&(e.curOp.scrollLeft=t),i!=null&&(e.curOp.scrollTop=i)}function nu(e,t){Yi(e),e.curOp.scrollToPos=t}function Yi(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var i=mo(e,t.from),r=mo(e,t.to);xo(e,i,r,t.margin)}}function xo(e,t,i,r){var n=Qn(e,{left:Math.min(t.left,i.left),top:Math.min(t.top,i.top)-r,right:Math.max(t.right,i.right),bottom:Math.max(t.bottom,i.bottom)+r});ei(e,n.scrollLeft,n.scrollTop)}function ti(e,t){Math.abs(e.doc.scrollTop-t)<2||(k||Vn(e,{top:t}),Ao(e,t,!0),k&&Vn(e),ni(e,100))}function Ao(e,t,i){t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),!(e.display.scroller.scrollTop==t&&!i)&&(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function lr(e,t,i,r){t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),!((i?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r)&&(e.doc.scrollLeft=t,Oo(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function ri(e){var t=e.display,i=t.gutters.offsetWidth,r=Math.round(e.doc.height+Fn(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?i:0,docHeight:r,scrollHeight:r+St(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var or=function(e,t,i){this.cm=i;var r=this.vert=Q("div",[Q("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=Q("div",[Q("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=n.tabIndex=-1,e(r),e(n),te(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),te(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,d&&v<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};or.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(i){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var n=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+n)+"px"}else this.vert.scrollTop=0,this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=i?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var l=e.viewWidth-e.barLeft-(i?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+l)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(r==0&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:i?r:0,bottom:t?r:0}},or.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},or.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},or.prototype.zeroWidthHack=function(){var e=ne&&!Y?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.visibility=this.vert.style.visibility="hidden",this.disableHoriz=new gt,this.disableVert=new gt},or.prototype.enableZeroWidthBar=function(e,t,i){e.style.visibility="";function r(){var n=e.getBoundingClientRect(),l=i=="vert"?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1);l!=e?e.style.visibility="hidden":t.set(1e3,r)}t.set(1e3,r)},or.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var ii=function(){};ii.prototype.update=function(){return{bottom:0,right:0}},ii.prototype.setScrollLeft=function(){},ii.prototype.setScrollTop=function(){},ii.prototype.clear=function(){};function Mr(e,t){t||(t=ri(e));var i=e.display.barWidth,r=e.display.barHeight;Mo(e,t);for(var n=0;n<4&&i!=e.display.barWidth||r!=e.display.barHeight;n++)i!=e.display.barWidth&&e.options.lineWrapping&&$i(e),Mo(e,ri(e)),i=e.display.barWidth,r=e.display.barHeight}function Mo(e,t){var i=e.display,r=i.scrollbars.update(t);i.sizer.style.paddingRight=(i.barWidth=r.right)+"px",i.sizer.style.paddingBottom=(i.barHeight=r.bottom)+"px",i.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(i.scrollbarFiller.style.display="block",i.scrollbarFiller.style.height=r.bottom+"px",i.scrollbarFiller.style.width=r.right+"px"):i.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(i.gutterFiller.style.display="block",i.gutterFiller.style.height=r.bottom+"px",i.gutterFiller.style.width=t.gutterWidth+"px"):i.gutterFiller.style.display=""}var _o={native:or,null:ii};function Do(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&Me(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new _o[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),te(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,i){i=="horizontal"?lr(e,t):ti(e,t)},e),e.display.scrollbars.addClass&&xt(e.display.wrapper,e.display.scrollbars.addClass)}var lu=0;function ar(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++lu,markArrays:null},Fs(e.curOp)}function sr(e){var t=e.curOp;t&&Ps(t,function(i){for(var r=0;r=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new qi(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function su(e){e.updatedDisplay=e.mustUpdate&&jn(e.cm,e.update)}function uu(e){var t=e.cm,i=t.display;e.updatedDisplay&&$i(t),e.barMeasure=ri(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=uo(t,i.maxLine,i.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+e.adjustWidthTo+St(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-tr(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=i.input.prepareSelection())}function fu(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft=e.display.viewTo)){var i=+new Date+e.options.workTime,r=Yr(e,t.highlightFrontier),n=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(l){if(r.line>=e.display.viewFrom){var o=l.styles,a=l.text.length>e.options.maxHighlightLength?jt(t.mode,r.state):null,s=Hl(e,l,r,!0);a&&(r.state=a),l.styles=s.styles;var u=l.styleClasses,g=s.classes;g?l.styleClasses=g:u&&(l.styleClasses=null);for(var p=!o||o.length!=l.styles.length||u!=g&&(!u||!g||u.bgClass!=g.bgClass||u.textClass!=g.textClass),T=0;!p&&Ti)return ni(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),n.length&&at(e,function(){for(var l=0;l=i.viewFrom&&t.visible.to<=i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&So(e)==0)return!1;Eo(e)&&(zt(e),t.dims=Gn(e));var n=r.first+r.size,l=Math.max(t.visible.from-e.options.viewportMargin,r.first),o=Math.min(n,t.visible.to+e.options.viewportMargin);i.viewFromo&&i.viewTo-o<20&&(o=Math.min(n,i.viewTo)),_t&&(l=On(e.doc,l),o=Jl(e.doc,o));var a=l!=i.viewFrom||o!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;Vs(e,l,o),i.viewOffset=Dt(j(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var s=So(e);if(!a&&s==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))return!1;var u=gu(e);return s>4&&(i.lineDiv.style.display="none"),vu(e,i.updateLineNumbers,t.dims),s>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,pu(u),qe(i.cursorDiv),qe(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,a&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,ni(e,400)),i.updateLineNumbers=null,!0}function No(e,t){for(var i=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==tr(e)){if(i&&i.top!=null&&(i={top:Math.min(e.doc.height+Fn(e.display)-Hn(e),i.top)}),t.visible=Xi(e.display,e.doc,i),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=Xi(e.display,e.doc,i));if(!jn(e,t))break;$i(e);var n=ri(e);Vr(e),Mr(e,n),tl(e,n),t.force=!1}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function Vn(e,t){var i=new qi(e,t);if(jn(e,i)){$i(e),No(e,i);var r=ri(e);Vr(e),Mr(e,r),tl(e,r),i.finish()}}function vu(e,t,i){var r=e.display,n=e.options.lineNumbers,l=r.lineDiv,o=l.firstChild;function a(O){var W=O.nextSibling;return b&&ne&&e.display.currentWheelTarget==O?O.style.display="none":O.parentNode.removeChild(O),W}for(var s=r.view,u=r.viewFrom,g=0;g-1&&(S=!1),ro(e,p,u,i)),S&&(qe(p.lineNumber),p.lineNumber.appendChild(document.createTextNode(kn(e.options,u)))),o=p.node.nextSibling}u+=p.size}for(;o;)o=a(o)}function el(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px",Be(e,"gutterChanged",e)}function tl(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+St(e)+"px"}function Oo(e){var t=e.display,i=t.view;if(!(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))){for(var r=Kn(t)-t.scroller.scrollLeft+e.doc.scrollLeft,n=t.gutters.offsetWidth,l=r+"px",o=0;o=105&&(n.wrapper.style.clipPath="inset(0px)"),n.wrapper.setAttribute("translate","no"),d&&v<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!b&&!(k&&ie)&&(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,n.gutterSpecs=rl(r.gutters,r.lineNumbers),Wo(n),i.init(n)}var Zi=0,Ot=null;d?Ot=-.53:k?Ot=15:A?Ot=-.7:K&&(Ot=-1/3);function Io(e){var t=e.wheelDeltaX,i=e.wheelDeltaY;return t==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),i==null&&e.detail&&e.axis==e.VERTICAL_AXIS?i=e.detail:i==null&&(i=e.wheelDelta),{x:t,y:i}}function mu(e){var t=Io(e);return t.x*=Ot,t.y*=Ot,t}function Fo(e,t){A&&_==102&&(e.display.chromeScrollHack==null?e.display.sizer.style.pointerEvents="none":clearTimeout(e.display.chromeScrollHack),e.display.chromeScrollHack=setTimeout(function(){e.display.chromeScrollHack=null,e.display.sizer.style.pointerEvents=""},100));var i=Io(t),r=i.x,n=i.y,l=Ot;t.deltaMode===0&&(r=t.deltaX,n=t.deltaY,l=1);var o=e.display,a=o.scroller,s=a.scrollWidth>a.clientWidth,u=a.scrollHeight>a.clientHeight;if(r&&s||n&&u){if(n&&ne&&b){e:for(var g=t.target,p=o.view;g!=a;g=g.parentNode)for(var T=0;T=0&&ae(e,r.to())<=0)return i}return-1};var de=function(e,t){this.anchor=e,this.head=t};de.prototype.from=function(){return Oi(this.anchor,this.head)},de.prototype.to=function(){return Ni(this.anchor,this.head)},de.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function yt(e,t,i){var r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(function(T,S){return ae(T.from(),S.from())}),i=Se(t,n);for(var l=1;l0:s>=0){var u=Oi(a.from(),o.from()),g=Ni(a.to(),o.to()),p=a.empty()?o.from()==o.head:a.from()==a.head;l<=i&&--i,t.splice(--l,2,new de(p?g:u,p?u:g))}}return new ft(t,i)}function Ut(e,t){return new ft([new de(e,t||e)],0)}function Gt(e){return e.text?P(e.from.line+e.text.length-1,f(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Ho(e,t){if(ae(e,t.from)<0)return e;if(ae(e,t.to)<=0)return Gt(t);var i=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Gt(t).ch-t.to.ch),P(i,r)}function il(e,t){for(var i=[],r=0;r1&&e.remove(a.line+1,O-1),e.insert(a.line+1,U)}Be(e,"change",e,t)}function Kt(e,t,i){function r(n,l,o){if(n.linked)for(var a=0;a1&&!e.done[e.done.length-2].ranges)return e.done.pop(),f(e.done)}function Go(e,t,i,r){var n=e.history;n.undone.length=0;var l=+new Date,o,a;if((n.lastOp==r||n.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.lastModTime>l-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(o=Cu(n,n.lastOp==r)))a=f(o.changes),ae(t.from,t.to)==0&&ae(t.from,a.to)==0?a.to=Gt(t):o.changes.push(ol(e,t));else{var s=f(n.done);for((!s||!s.ranges)&&Ji(e.sel,n.done),o={changes:[ol(e,t)],generation:n.generation},n.done.push(o);n.done.length>n.undoDepth;)n.done.shift(),n.done[0].ranges||n.done.shift()}n.done.push(i),n.generation=++n.maxGeneration,n.lastModTime=n.lastSelTime=l,n.lastOp=n.lastSelOp=r,n.lastOrigin=n.lastSelOrigin=t.origin,a||Te(e,"historyAdded")}function Su(e,t,i,r){var n=t.charAt(0);return n=="*"||n=="+"&&i.ranges.length==r.ranges.length&&i.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function Lu(e,t,i,r){var n=e.history,l=r&&r.origin;i==n.lastSelOp||l&&n.lastSelOrigin==l&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==l||Su(e,l,f(n.done),t))?n.done[n.done.length-1]=t:Ji(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=l,n.lastSelOp=i,r&&r.clearRedo!==!1&&Uo(n.undone)}function Ji(e,t){var i=f(t);i&&i.ranges&&i.equals(e)||t.push(e)}function Ko(e,t,i,r){var n=t["spans_"+e.id],l=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,r),function(o){o.markedSpans&&((n||(n=t["spans_"+e.id]={}))[l]=o.markedSpans),++l})}function Tu(e){if(!e)return null;for(var t,i=0;i-1&&(f(a)[p]=u[p],delete u[p])}}return r}function al(e,t,i,r){if(r){var n=e.anchor;if(i){var l=ae(t,n)<0;l!=ae(i,n)<0?(n=t,t=i):l!=ae(t,i)<0&&(t=i)}return new de(n,t)}else return new de(i||t,t)}function ji(e,t,i,r,n){n==null&&(n=e.cm&&(e.cm.display.shift||e.extend)),Qe(e,new ft([al(e.sel.primary(),t,i,n)],0),r)}function Xo(e,t,i){for(var r=[],n=e.cm&&(e.cm.display.shift||e.extend),l=0;l=t.ch:a.to>t.ch))){if(n&&(Te(s,"beforeCursorEnter"),s.explicitlyCleared))if(l.markedSpans){--o;continue}else break;if(!s.atomic)continue;if(i){var p=s.find(r<0?1:-1),T=void 0;if((r<0?g:u)&&(p=jo(e,p,-r,p&&p.line==t.line?l:null)),p&&p.line==t.line&&(T=ae(p,i))&&(r<0?T<0:T>0))return Dr(e,p,t,r,n)}var S=s.find(r<0?-1:1);return(r<0?u:g)&&(S=jo(e,S,r,S.line==t.line?l:null)),S?Dr(e,S,t,r,n):null}}return t}function en(e,t,i,r,n){var l=r||1,o=Dr(e,t,i,l,n)||!n&&Dr(e,t,i,l,!0)||Dr(e,t,i,-l,n)||!n&&Dr(e,t,i,-l,!0);return o||(e.cantEdit=!0,P(e.first,0))}function jo(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?se(e,P(t.line-1)):null:i>0&&t.ch==(r||j(e,t.line)).text.length?t.line=0;--n)ta(e,{from:r[n].from,to:r[n].to,text:n?[""]:t.text,origin:t.origin});else ta(e,t)}}function ta(e,t){if(!(t.text.length==1&&t.text[0]==""&&ae(t.from,t.to)==0)){var i=il(e,t);Go(e,t,i,e.cm?e.cm.curOp.id:NaN),ai(e,t,i,Dn(e,t));var r=[];Kt(e,function(n,l){!l&&Se(r,n.history)==-1&&(la(n.history,t),r.push(n.history)),ai(n,t,null,Dn(n,t))})}}function tn(e,t,i){var r=e.cm&&e.cm.state.suppressEdits;if(!(r&&!i)){for(var n=e.history,l,o=e.sel,a=t=="undo"?n.done:n.undone,s=t=="undo"?n.undone:n.done,u=0;u=0;--S){var O=T(S);if(O)return O.v}}}}function ra(e,t){if(t!=0&&(e.first+=t,e.sel=new ft(y(e.sel.ranges,function(n){return new de(P(n.anchor.line+t,n.anchor.ch),P(n.head.line+t,n.head.ch))}),e.sel.primIndex),e.cm)){rt(e.cm,e.first,e.first-t,t);for(var i=e.cm.display,r=i.viewFrom;re.lastLine())){if(t.from.linel&&(t={from:t.from,to:P(l,j(e,l).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Vt(e,t.from,t.to),i||(i=il(e,t)),e.cm?Au(e.cm,t,r):ll(e,t,r),Vi(e,i,ht),e.cantEdit&&en(e,P(e.firstLine(),0))&&(e.cantEdit=!1)}}function Au(e,t,i){var r=e.doc,n=e.display,l=t.from,o=t.to,a=!1,s=l.line;e.options.lineWrapping||(s=pe(pt(j(r,l.line))),r.iter(s,o.line+1,function(S){if(S==n.maxLine)return a=!0,!0})),r.sel.contains(t.from,t.to)>-1&&Pt(e),ll(r,t,i,Co(e)),e.options.lineWrapping||(r.iter(s,l.line+t.text.length,function(S){var O=Pi(S);O>n.maxLineLength&&(n.maxLine=S,n.maxLineLength=O,n.maxLineChanged=!0,a=!1)}),a&&(e.curOp.updateMaxLine=!0)),vs(r,l.line),ni(e,400);var u=t.text.length-(o.line-l.line)-1;t.full?rt(e):l.line==o.line&&t.text.length==1&&!Bo(e.doc,t)?Rt(e,l.line,"text"):rt(e,l.line,o.line+1,u);var g=$e(e,"changes"),p=$e(e,"change");if(p||g){var T={from:l,to:o,text:t.text,removed:t.removed,origin:t.origin};p&&Be(e,"change",e,T),g&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(T)}e.display.selForContextMenu=null}function Or(e,t,i,r,n){var l;r||(r=i),ae(r,i)<0&&(l=[r,i],i=l[0],r=l[1]),typeof t=="string"&&(t=e.splitLines(t)),Nr(e,{from:i,to:r,text:t,origin:n})}function ia(e,t,i,r){i1||!(this.children[0]instanceof ui))){var a=[];this.collapse(a),this.children=[new ui(a)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t50){for(var o=n.lines.length%25+25,a=o;a10);e.parent.maybeSpill()}},iterN:function(e,t,i){for(var r=0;re.display.maxLineLength&&(e.display.maxLine=u,e.display.maxLineLength=g,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&rt(e,r,n+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Qo(e.doc)),e&&Be(e,"markerCleared",e,this,r,n),t&&sr(e),this.parent&&this.parent.clear()}},$t.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var i,r,n=0;n0||o==0&&l.clearWhenEmpty!==!1)return l;if(l.replacedWith&&(l.collapsed=!0,l.widgetNode=kt("span",[l.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||l.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(l.widgetNode.insertLeft=!0)),l.collapsed){if(Ql(e,t.line,t,i,l)||t.line!=i.line&&Ql(e,i.line,t,i,l))throw new Error("Inserting collapsed marker partially overlapping an existing one");ms()}l.addToHistory&&Go(e,{from:t,to:i,origin:"markText"},e.sel,NaN);var a=t.line,s=e.cm,u;if(e.iter(a,i.line+1,function(p){s&&l.collapsed&&!s.options.lineWrapping&&pt(p)==s.display.maxLine&&(u=!0),l.collapsed&&a!=t.line&&wt(p,0),ws(p,new Wi(l,a==t.line?t.ch:null,a==i.line?i.ch:null),e.cm&&e.cm.curOp),++a}),l.collapsed&&e.iter(t.line,i.line+1,function(p){Bt(e,p)&&wt(p,0)}),l.clearOnEnter&&te(l,"beforeCursorEnter",function(){return l.clear()}),l.readOnly&&(ys(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),l.collapsed&&(l.id=++aa,l.atomic=!0),s){if(u&&(s.curOp.updateMaxLine=!0),l.collapsed)rt(s,t.line,i.line+1);else if(l.className||l.startStyle||l.endStyle||l.css||l.attributes||l.title)for(var g=t.line;g<=i.line;g++)Rt(s,g,"text");l.atomic&&Qo(s.doc),Be(s,"markerAdded",s,l)}return l}var ci=function(e,t){this.markers=e,this.primary=t;for(var i=0;i=0;s--)Nr(this,r[s]);a?qo(this,a):this.cm&&Ar(this.cm)}),undo:ze(function(){tn(this,"undo")}),redo:ze(function(){tn(this,"redo")}),undoSelection:ze(function(){tn(this,"undo",!0)}),redoSelection:ze(function(){tn(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,i=0,r=0;r=e.ch)&&t.push(n.marker.parent||n.marker)}return t},findMarks:function(e,t,i){e=se(this,e),t=se(this,t);var r=[],n=e.line;return this.iter(e.line,t.line+1,function(l){var o=l.markedSpans;if(o)for(var a=0;a=s.to||s.from==null&&n!=e.line||s.from!=null&&n==t.line&&s.from>=t.ch)&&(!i||i(s.marker))&&r.push(s.marker.parent||s.marker)}++n}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var i=t.markedSpans;if(i)for(var r=0;re)return t=e,!0;e-=l,++i}),se(this,P(i,t))},indexFromPos:function(e){e=se(this,e);var t=e.ch;if(e.linet&&(t=e.from),e.to!=null&&e.to-1){t.state.draggingText(e),setTimeout(function(){return t.display.input.focus()},20);return}try{var g=e.dataTransfer.getData("Text");if(g){var p;if(t.state.draggingText&&!t.state.draggingText.copy&&(p=t.listSelections()),Vi(t.doc,Ut(i,i)),p)for(var T=0;T=0;a--)Or(e.doc,"",r[a].from,r[a].to,"+delete");Ar(e)})}function ul(e,t,i){var r=ce(e.text,t+i,i);return r<0||r>e.text.length?null:r}function fl(e,t,i){var r=ul(e,t.ch,i);return r==null?null:new P(t.line,r,i<0?"after":"before")}function hl(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var l=ge(i,t.doc.direction);if(l){var o=n<0?f(l):l[0],a=n<0==(o.level==1),s=a?"after":"before",u;if(o.level>0||t.doc.direction=="rtl"){var g=Lr(t,i);u=n<0?i.text.length-1:0;var p=Lt(t,g,u).top;u=me(function(T){return Lt(t,g,T).top==p},n<0==(o.level==1)?o.from:o.to-1,u),s=="before"&&(u=ul(i,u,1))}else u=n<0?o.to:o.from;return new P(r,u,s)}}return new P(r,n<0?i.text.length:0,n<0?"before":"after")}function zu(e,t,i,r){var n=ge(t,e.doc.direction);if(!n)return fl(t,i,r);i.ch>=t.text.length?(i.ch=t.text.length,i.sticky="before"):i.ch<=0&&(i.ch=0,i.sticky="after");var l=Ne(n,i.ch,i.sticky),o=n[l];if(e.doc.direction=="ltr"&&o.level%2==0&&(r>0?o.to>i.ch:o.from=o.from&&T>=g.begin)){var S=p?"before":"after";return new P(i.line,T,S)}}var O=function(U,$,G){for(var X=function(we,Ue){return Ue?new P(i.line,a(we,1),"before"):new P(i.line,we,"after")};U>=0&&U0==(ee.level!=1),fe=V?G.begin:a(G.end,-1);if(ee.from<=fe&&fe0?g.end:a(g.begin,-1);return B!=null&&!(r>0&&B==t.text.length)&&(W=O(r>0?0:n.length-1,r,u(B)),W)?W:null}var pi={selectAll:Vo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),ht)},killLine:function(e){return Ir(e,function(t){if(t.empty()){var i=j(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line0)n=new P(n.line,n.ch+1),e.replaceRange(l.charAt(n.ch-1)+l.charAt(n.ch-2),P(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){var o=j(e.doc,n.line-1).text;o&&(n=new P(n.line,1),e.replaceRange(l.charAt(0)+e.doc.lineSeparator()+o.charAt(o.length-1),P(n.line-1,o.length-1),n,"+transpose"))}}i.push(new de(n,n))}e.setSelections(i)})},newlineAndIndent:function(e){return at(e,function(){for(var t=e.listSelections(),i=t.length-1;i>=0;i--)e.replaceRange(e.doc.lineSeparator(),t[i].anchor,t[i].head,"+input");t=e.listSelections();for(var r=0;re&&ae(t,this.pos)==0&&i==this.button};var yi,mi;function qu(e,t){var i=+new Date;return mi&&mi.compare(i,e,t)?(yi=mi=null,"triple"):yi&&yi.compare(i,e,t)?(mi=new dl(i,e,t),yi=null,"double"):(yi=new dl(i,e,t),mi=null,"single")}function La(e){var t=this,i=t.display;if(!(xe(t,e)||i.activeTouch&&i.input.supportsTouch())){if(i.input.ensurePolled(),i.shift=e.shiftKey,Nt(i,e)){b||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100));return}if(!gl(t,e)){var r=ir(t,e),n=El(e),l=r?qu(r,n):"single";At(t).focus(),n==1&&t.state.selectingText&&t.state.selectingText(e),!(r&&Zu(t,n,r,l,e))&&(n==1?r?Ju(t,r,l,e):vn(e)==i.scroller&&Oe(e):n==2?(r&&ji(t.doc,r),setTimeout(function(){return i.input.focus()},20)):n==3&&(Fe?t.display.input.onContextMenu(e):qn(t)))}}}function Zu(e,t,i,r,n){var l="Click";return r=="double"?l="Double"+l:r=="triple"&&(l="Triple"+l),l=(t==1?"Left":t==2?"Middle":"Right")+l,vi(e,ga(l,n),n,function(o){if(typeof o=="string"&&(o=pi[o]),!o)return!1;var a=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),a=o(e,i)!=Ht}finally{e.state.suppressEdits=!1}return a})}function Qu(e,t,i){var r=e.getOption("configureMouse"),n=r?r(e,t,i):{};if(n.unit==null){var l=he?i.shiftKey&&i.metaKey:i.altKey;n.unit=l?"rectangle":t=="single"?"char":t=="double"?"word":"line"}return(n.extend==null||e.doc.extend)&&(n.extend=e.doc.extend||i.shiftKey),n.addNew==null&&(n.addNew=ne?i.metaKey:i.ctrlKey),n.moveOnDrag==null&&(n.moveOnDrag=!(ne?i.altKey:i.ctrlKey)),n}function Ju(e,t,i,r){d?setTimeout(pr(To,e),0):e.curOp.focus=tt(Ft(e));var n=Qu(e,i,r),l=e.doc.sel,o;e.options.dragDrop&&ls&&!e.isReadOnly()&&i=="single"&&(o=l.contains(t))>-1&&(ae((o=l.ranges[o]).from(),t)<0||t.xRel>0)&&(ae(o.to(),t)>0||t.xRel<0)?ju(e,r,t,n):Vu(e,r,t,n)}function ju(e,t,i,r){var n=e.display,l=!1,o=Re(e,function(u){b&&(n.scroller.draggable=!1),e.state.draggingText=!1,e.state.delayingBlurEvent&&(e.hasFocus()?e.state.delayingBlurEvent=!1:qn(e)),je(n.wrapper.ownerDocument,"mouseup",o),je(n.wrapper.ownerDocument,"mousemove",a),je(n.scroller,"dragstart",s),je(n.scroller,"drop",o),l||(Oe(u),r.addNew||ji(e.doc,i,null,null,r.extend),b&&!K||d&&v==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),a=function(u){l=l||Math.abs(t.clientX-u.clientX)+Math.abs(t.clientY-u.clientY)>=10},s=function(){return l=!0};b&&(n.scroller.draggable=!0),e.state.draggingText=o,o.copy=!r.moveOnDrag,te(n.wrapper.ownerDocument,"mouseup",o),te(n.wrapper.ownerDocument,"mousemove",a),te(n.scroller,"dragstart",s),te(n.scroller,"drop",o),e.state.delayingBlurEvent=!0,setTimeout(function(){return n.input.focus()},20),n.scroller.dragDrop&&n.scroller.dragDrop()}function Ta(e,t,i){if(i=="char")return new de(t,t);if(i=="word")return e.findWordAt(t);if(i=="line")return new de(P(t.line,0),se(e.doc,P(t.line+1,0)));var r=i(e,t);return new de(r.from,r.to)}function Vu(e,t,i,r){d&&qn(e);var n=e.display,l=e.doc;Oe(t);var o,a,s=l.sel,u=s.ranges;if(r.addNew&&!r.extend?(a=l.sel.contains(i),a>-1?o=u[a]:o=new de(i,i)):(o=l.sel.primary(),a=l.sel.primIndex),r.unit=="rectangle")r.addNew||(o=new de(i,i)),i=ir(e,t,!0,!0),a=-1;else{var g=Ta(e,i,r.unit);r.extend?o=al(o,g.anchor,g.head,r.extend):o=g}r.addNew?a==-1?(a=u.length,Qe(l,yt(e,u.concat([o]),a),{scroll:!1,origin:"*mouse"})):u.length>1&&u[a].empty()&&r.unit=="char"&&!r.extend?(Qe(l,yt(e,u.slice(0,a).concat(u.slice(a+1)),0),{scroll:!1,origin:"*mouse"}),s=l.sel):sl(l,a,o,Ur):(a=0,Qe(l,new ft([o],0),Ur),s=l.sel);var p=i;function T(G){if(ae(p,G)!=0)if(p=G,r.unit=="rectangle"){for(var X=[],ee=e.options.tabSize,V=Ze(j(l,i.line).text,i.ch,ee),fe=Ze(j(l,G.line).text,G.ch,ee),we=Math.min(V,fe),Ue=Math.max(V,fe),ke=Math.min(i.line,G.line),st=Math.min(e.lastLine(),Math.max(i.line,G.line));ke<=st;ke++){var nt=j(l,ke).text,We=Gr(nt,we,ee);we==Ue?X.push(new de(P(ke,We),P(ke,We))):nt.length>We&&X.push(new de(P(ke,We),P(ke,Gr(nt,Ue,ee))))}X.length||X.push(new de(i,i)),Qe(l,yt(e,s.ranges.slice(0,a).concat(X),a),{origin:"*mouse",scroll:!1}),e.scrollIntoView(G)}else{var lt=o,Xe=Ta(e,G,r.unit),He=lt.anchor,Ie;ae(Xe.anchor,He)>0?(Ie=Xe.head,He=Oi(lt.from(),Xe.anchor)):(Ie=Xe.anchor,He=Ni(lt.to(),Xe.head));var Ae=s.ranges.slice(0);Ae[a]=ef(e,new de(se(l,He),Ie)),Qe(l,yt(e,Ae,a),Ur)}}var S=n.wrapper.getBoundingClientRect(),O=0;function W(G){var X=++O,ee=ir(e,G,!0,r.unit=="rectangle");if(ee)if(ae(ee,p)!=0){e.curOp.focus=tt(Ft(e)),T(ee);var V=Xi(n,l);(ee.line>=V.to||ee.lineS.bottom?20:0;fe&&setTimeout(Re(e,function(){O==X&&(n.scroller.scrollTop+=fe,W(G))}),50)}}function B(G){e.state.selectingText=!1,O=1/0,G&&(Oe(G),n.input.focus()),je(n.wrapper.ownerDocument,"mousemove",U),je(n.wrapper.ownerDocument,"mouseup",$),l.history.lastSelOrigin=null}var U=Re(e,function(G){G.buttons===0||!El(G)?B(G):W(G)}),$=Re(e,B);e.state.selectingText=$,te(n.wrapper.ownerDocument,"mousemove",U),te(n.wrapper.ownerDocument,"mouseup",$)}function ef(e,t){var i=t.anchor,r=t.head,n=j(e.doc,i.line);if(ae(i,r)==0&&i.sticky==r.sticky)return t;var l=ge(n);if(!l)return t;var o=Ne(l,i.ch,i.sticky),a=l[o];if(a.from!=i.ch&&a.to!=i.ch)return t;var s=o+(a.from==i.ch==(a.level!=1)?0:1);if(s==0||s==l.length)return t;var u;if(r.line!=i.line)u=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var g=Ne(l,r.ch,r.sticky),p=g-o||(r.ch-i.ch)*(a.level==1?-1:1);g==s-1||g==s?u=p<0:u=p>0}var T=l[s+(u?-1:0)],S=u==(T.level==1),O=S?T.from:T.to,W=S?"after":"before";return i.ch==O&&i.sticky==W?t:new de(new P(i.line,O,W),r)}function ka(e,t,i,r){var n,l;if(t.touches)n=t.touches[0].clientX,l=t.touches[0].clientY;else try{n=t.clientX,l=t.clientY}catch{return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&Oe(t);var o=e.display,a=o.lineDiv.getBoundingClientRect();if(l>a.bottom||!$e(e,i))return pn(t);l-=a.top-o.viewOffset;for(var s=0;s=n){var g=er(e.doc,l),p=e.display.gutterSpecs[s];return Te(e,i,e,g,p.className,t),pn(t)}}}function gl(e,t){return ka(e,t,"gutterClick",!0)}function xa(e,t){Nt(e.display,t)||tf(e,t)||xe(e,t,"contextmenu")||Fe||e.display.input.onContextMenu(t)}function tf(e,t){return $e(e,"gutterContextMenu")?ka(e,t,"gutterContextMenu",!1):!1}function Aa(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),jr(e)}var Fr={toString:function(){return"CodeMirror.Init"}},Ma={},on={};function rf(e){var t=e.optionHandlers;function i(r,n,l,o){e.defaults[r]=n,l&&(t[r]=o?function(a,s,u){u!=Fr&&l(a,s,u)}:l)}e.defineOption=i,e.Init=Fr,i("value","",function(r,n){return r.setValue(n)},!0),i("mode",null,function(r,n){r.doc.modeOption=n,nl(r)},!0),i("indentUnit",2,nl,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,function(r){oi(r),jr(r),rt(r)},!0),i("lineSeparator",null,function(r,n){if(r.doc.lineSep=n,!!n){var l=[],o=r.doc.first;r.doc.iter(function(s){for(var u=0;;){var g=s.text.indexOf(n,u);if(g==-1)break;u=g+n.length,l.push(P(o,g))}o++});for(var a=l.length-1;a>=0;a--)Or(r.doc,n,l[a],P(l[a].line,l[a].ch+n.length))}}),i("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\u2066\u2067\u2069\ufeff\ufff9-\ufffc]/g,function(r,n,l){r.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),l!=Fr&&r.refresh()}),i("specialCharPlaceholder",Ns,function(r){return r.refresh()},!0),i("electricChars",!0),i("inputStyle",ie?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),i("spellcheck",!1,function(r,n){return r.getInputField().spellcheck=n},!0),i("autocorrect",!1,function(r,n){return r.getInputField().autocorrect=n},!0),i("autocapitalize",!1,function(r,n){return r.getInputField().autocapitalize=n},!0),i("rtlMoveVisually",!re),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){Aa(r),li(r)},!0),i("keyMap","default",function(r,n,l){var o=nn(n),a=l!=Fr&&nn(l);a&&a.detach&&a.detach(r,o),o.attach&&o.attach(r,a||null)}),i("extraKeys",null),i("configureMouse",null),i("lineWrapping",!1,lf,!0),i("gutters",[],function(r,n){r.display.gutterSpecs=rl(n,r.options.lineNumbers),li(r)},!0),i("fixedGutter",!0,function(r,n){r.display.gutters.style.left=n?Kn(r.display)+"px":"0",r.refresh()},!0),i("coverGutterNextToScrollbar",!1,function(r){return Mr(r)},!0),i("scrollbarStyle","native",function(r){Do(r),Mr(r),r.display.scrollbars.setScrollTop(r.doc.scrollTop),r.display.scrollbars.setScrollLeft(r.doc.scrollLeft)},!0),i("lineNumbers",!1,function(r,n){r.display.gutterSpecs=rl(r.options.gutters,n),li(r)},!0),i("firstLineNumber",1,li,!0),i("lineNumberFormatter",function(r){return r},li,!0),i("showCursorWhenSelecting",!1,Vr,!0),i("resetSelectionOnContextMenu",!0),i("lineWiseCopyCut",!0),i("pasteLinesPerSelection",!0),i("selectionsMayTouch",!1),i("readOnly",!1,function(r,n){n=="nocursor"&&(xr(r),r.display.input.blur()),r.display.input.readOnlyChanged(n)}),i("screenReaderLabel",null,function(r,n){n=n===""?null:n,r.display.input.screenReaderLabelChanged(n)}),i("disableInput",!1,function(r,n){n||r.display.input.reset()},!0),i("dragDrop",!0,nf),i("allowDropFileTypes",null),i("cursorBlinkRate",530),i("cursorScrollMargin",0),i("cursorHeight",1,Vr,!0),i("singleCursorHeightPerLine",!0,Vr,!0),i("workTime",100),i("workDelay",100),i("flattenSpans",!0,oi,!0),i("addModeClass",!1,oi,!0),i("pollInterval",100),i("undoDepth",200,function(r,n){return r.doc.history.undoDepth=n}),i("historyEventDelay",1250),i("viewportMargin",10,function(r){return r.refresh()},!0),i("maxHighlightLength",1e4,oi,!0),i("moveInputWithCursor",!0,function(r,n){n||r.display.input.resetPosition()}),i("tabindex",null,function(r,n){return r.display.input.getField().tabIndex=n||""}),i("autofocus",null),i("direction","ltr",function(r,n){return r.doc.setDirection(n)},!0),i("phrases",null)}function nf(e,t,i){var r=i&&i!=Fr;if(!t!=!r){var n=e.display.dragFunctions,l=t?te:je;l(e.display.scroller,"dragstart",n.start),l(e.display.scroller,"dragenter",n.enter),l(e.display.scroller,"dragover",n.over),l(e.display.scroller,"dragleave",n.leave),l(e.display.scroller,"drop",n.drop)}}function lf(e){e.options.lineWrapping?(xt(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Me(e.display.wrapper,"CodeMirror-wrap"),Wn(e)),$n(e),rt(e),jr(e),setTimeout(function(){return Mr(e)},100)}function Le(e,t){var i=this;if(!(this instanceof Le))return new Le(e,t);this.options=t=t?dt(t):{},dt(Ma,t,!1);var r=t.value;typeof r=="string"?r=new it(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var n=new Le.inputStyles[t.inputStyle](this),l=this.display=new yu(e,r,n,t);l.wrapper.CodeMirror=this,Aa(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Do(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new gt,keySeq:null,specialChars:null},t.autofocus&&!ie&&l.input.focus(),d&&v<11&&setTimeout(function(){return i.display.input.reset(!0)},20),of(this),Fu(),ar(this),this.curOp.forceUpdate=!0,Ro(this,r),t.autofocus&&!ie||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&Zn(i)},20):xr(this);for(var o in on)on.hasOwnProperty(o)&&on[o](this,t[o],Fr);Eo(this),t.finishInit&&t.finishInit(this);for(var a=0;a20*20}te(t.scroller,"touchstart",function(s){if(!xe(e,s)&&!l(s)&&!gl(e,s)){t.input.ensurePolled(),clearTimeout(i);var u=+new Date;t.activeTouch={start:u,moved:!1,prev:u-r.end<=300?r:null},s.touches.length==1&&(t.activeTouch.left=s.touches[0].pageX,t.activeTouch.top=s.touches[0].pageY)}}),te(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),te(t.scroller,"touchend",function(s){var u=t.activeTouch;if(u&&!Nt(t,s)&&u.left!=null&&!u.moved&&new Date-u.start<300){var g=e.coordsChar(t.activeTouch,"page"),p;!u.prev||o(u,u.prev)?p=new de(g,g):!u.prev.prev||o(u,u.prev.prev)?p=e.findWordAt(g):p=new de(P(g.line,0),se(e.doc,P(g.line+1,0))),e.setSelection(p.anchor,p.head),e.focus(),Oe(s)}n()}),te(t.scroller,"touchcancel",n),te(t.scroller,"scroll",function(){t.scroller.clientHeight&&(ti(e,t.scroller.scrollTop),lr(e,t.scroller.scrollLeft,!0),Te(e,"scroll",e))}),te(t.scroller,"mousewheel",function(s){return Fo(e,s)}),te(t.scroller,"DOMMouseScroll",function(s){return Fo(e,s)}),te(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(s){xe(e,s)||$r(s)},over:function(s){xe(e,s)||(Iu(e,s),$r(s))},start:function(s){return Wu(e,s)},drop:Re(e,Eu),leave:function(s){xe(e,s)||fa(e)}};var a=t.input.getField();te(a,"keyup",function(s){return Ca.call(e,s)}),te(a,"keydown",Re(e,wa)),te(a,"keypress",Re(e,Sa)),te(a,"focus",function(s){return Zn(e,s)}),te(a,"blur",function(s){return xr(e,s)})}var pl=[];Le.defineInitHook=function(e){return pl.push(e)};function bi(e,t,i,r){var n=e.doc,l;i==null&&(i="add"),i=="smart"&&(n.mode.indent?l=Yr(e,t).state:i="prev");var o=e.options.tabSize,a=j(n,t),s=Ze(a.text,null,o);a.stateAfter&&(a.stateAfter=null);var u=a.text.match(/^\s*/)[0],g;if(!r&&!/\S/.test(a.text))g=0,i="not";else if(i=="smart"&&(g=n.mode.indent(l,a.text.slice(u.length),a.text),g==Ht||g>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?g=Ze(j(n,t-1).text,null,o):g=0:i=="add"?g=s+e.options.indentUnit:i=="subtract"?g=s-e.options.indentUnit:typeof i=="number"&&(g=s+i),g=Math.max(0,g);var p="",T=0;if(e.options.indentWithTabs)for(var S=Math.floor(g/o);S;--S)T+=o,p+=" ";if(To,s=bn(t),u=null;if(a&&r.ranges.length>1)if(mt&&mt.text.join(` +`)==t){if(r.ranges.length%mt.text.length==0){u=[];for(var g=0;g=0;T--){var S=r.ranges[T],O=S.from(),W=S.to();S.empty()&&(i&&i>0?O=P(O.line,O.ch-i):e.state.overwrite&&!a?W=P(W.line,Math.min(j(l,W.line).text.length,W.ch+f(s).length)):a&&mt&&mt.lineWise&&mt.text.join(` `)==s.join(` -`)&&(E=W=P(E.line,0)));var B={from:E,to:W,text:u?u[T%u.length]:s,origin:n||(a?"paste":e.state.cutIncoming>o?"cut":"+input")};Nr(e.doc,B),Be(e,"inputRead",e,B)}t&&!a&&_a(e,t),Ar(e),e.curOp.updateInput<2&&(e.curOp.updateInput=p),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Ma(e,t){var i=e.clipboardData&&e.clipboardData.getData("Text");if(i)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&t.hasFocus()&&at(t,function(){return vl(t,i,0,null,"paste")}),!0}function _a(e,t){if(!(!e.options.electricChars||!e.options.smartIndent))for(var i=e.doc.sel,r=i.ranges.length-1;r>=0;r--){var n=i.ranges[r];if(!(n.head.ch>100||r&&i.ranges[r-1].head.line==n.head.line)){var l=e.getModeAt(n.head),o=!1;if(l.electricChars){for(var a=0;a-1){o=bi(e,n.head.line,"smart");break}}else l.electricInput&&l.electricInput.test(j(e.doc,n.head.line).text.slice(0,n.head.ch))&&(o=bi(e,n.head.line,"smart"));o&&Be(e,"electricInput",e,n.head.line)}}}function Da(e){for(var t=[],i=[],r=0;rl&&(bi(this,a.head.line,r,!0),l=a.head.line,o==this.doc.sel.primIndex&&Ar(this));else{var s=a.from(),u=a.to(),g=Math.max(l,s.line);l=Math.min(this.lastLine(),u.line-(u.ch?0:1))+1;for(var p=g;p0&&sl(this.doc,o,new de(s,T[o].to()),ht)}}}),getTokenAt:function(r,n){return Rl(this,r,n)},getLineTokens:function(r,n){return Rl(this,P(r),n,!0)},getTokenTypeAt:function(r){r=se(this.doc,r);var n=Hl(this,j(this.doc,r.line)),l=0,o=(n.length-1)/2,a=r.ch,s;if(a==0)s=n[2];else for(;;){var u=l+o>>1;if((u?n[u*2-1]:0)>=a)o=u;else if(n[u*2+1]s&&(r=s,o=!0),a=j(this.doc,r)}else a=r;return zi(this,a,{top:0,left:0},n||"page",l||o).top+(o?this.doc.height-Dt(a):0)},defaultTextHeight:function(){return Tr(this.display)},defaultCharWidth:function(){return kr(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(r,n,l,o,a){var s=this.display;r=vt(this,se(this.doc,r));var u=r.bottom,g=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),s.sizer.appendChild(n),o=="over")u=r.top;else if(o=="above"||o=="near"){var p=Math.max(s.wrapper.clientHeight,this.doc.height),T=Math.max(s.sizer.clientWidth,s.lineSpace.clientWidth);(o=="above"||r.bottom+n.offsetHeight>p)&&r.top>n.offsetHeight?u=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=p&&(u=r.bottom),g+n.offsetWidth>T&&(g=T-n.offsetWidth)}n.style.top=u+"px",n.style.left=n.style.right="",a=="right"?(g=s.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(a=="left"?g=0:a=="middle"&&(g=(s.sizer.clientWidth-n.offsetWidth)/2),n.style.left=g+"px"),l&&ru(this,{left:g,top:u,right:g+n.offsetWidth,bottom:u+n.offsetHeight})},triggerOnKeyDown:Ve(ba),triggerOnKeyPress:Ve(Ca),triggerOnKeyUp:wa,triggerOnMouseDown:Ve(Sa),execCommand:function(r){if(pi.hasOwnProperty(r))return pi[r].call(null,this)},triggerElectric:Ve(function(r){_a(this,r)}),findPosH:function(r,n,l,o){var a=1;n<0&&(a=-1,n=-n);for(var s=se(this.doc,r),u=0;u0&&g(l.charAt(o-1));)--o;for(;a.5||this.options.lineWrapping)&&$n(this),Te(this,"refresh",this)}),swapDoc:Ve(function(r){var n=this.doc;return n.cm=null,this.state.selectingText&&this.state.selectingText(),Bo(this,r),jr(this),this.display.input.reset(),ei(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,Be(this,"swapDoc",this,n),n}),phrase:function(r){var n=this.options.phrases;return n&&Object.prototype.hasOwnProperty.call(n,r)?n[r]:r},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Mt(e),e.registerHelper=function(r,n,l){i.hasOwnProperty(r)||(i[r]=e[r]={_global:[]}),i[r][n]=l},e.registerGlobalHelper=function(r,n,l,o){e.registerHelper(r,n,o),i[r]._global.push({pred:l,val:o})}}function ml(e,t,i,r,n){var l=t,o=i,a=j(e,t.line),s=n&&e.direction=="rtl"?-i:i;function u(){var $=t.line+s;return $=e.first+e.size?!1:(t=new P($,t.ch,t.sticky),a=j(e,$))}function g($){var G;if(r=="codepoint"){var X=a.text.charCodeAt(t.ch+(i>0?0:-1));if(isNaN(X))G=null;else{var ee=i>0?X>=55296&&X<56320:X>=56320&&X<57343;G=new P(t.line,Math.max(0,Math.min(a.text.length,t.ch+i*(ee?2:1))),-i)}}else n?G=Ru(e.cm,a,t,i):G=fl(a,t,i);if(G==null)if(!$&&u())t=hl(n,e.cm,a,t.line,s);else return!1;else t=G;return!0}if(r=="char"||r=="codepoint")g();else if(r=="column")g(!0);else if(r=="word"||r=="group")for(var p=null,T=r=="group",C=e.cm&&e.cm.getHelper(t,"wordChars"),E=!0;!(i<0&&!g(!E));E=!1){var W=a.text.charAt(t.ch)||` -`,B=H(W,C)?"w":T&&W==` -`?"n":!T||/\s/.test(W)?null:"p";if(T&&!E&&!B&&(B="s"),p&&p!=B){i<0&&(i=1,g(),t.sticky="after");break}if(B&&(p=B),i>0&&!g(!E))break}var U=en(e,t,l,o,!0);return xn(l,U)&&(U.hitSide=!0),U}function Oa(e,t,i,r){var n=e.doc,l=t.left,o;if(r=="page"){var a=Math.min(e.display.wrapper.clientHeight,At(e).innerHeight||n(e).documentElement.clientHeight),s=Math.max(a-.5*Tr(e.display),3);o=(i>0?t.bottom:t.top)+i*s}else r=="line"&&(o=i>0?t.bottom+3:t.top-3);for(var u;u=zn(e,l,o),!!u.outside;){if(i<0?o<=0:o>=n.height){u.hitSide=!0;break}o+=i*5}return u}var ve=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new gt,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};ve.prototype.init=function(e){var t=this,i=this,r=i.cm,n=i.div=e.lineDiv;n.contentEditable=!0,yl(n,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function l(a){for(var s=a.target;s;s=s.parentNode){if(s==n)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(s.className))break}return!1}te(n,"paste",function(a){!l(a)||xe(r,a)||Ma(a,r)||v<=11&&setTimeout(Re(r,function(){return t.updateFromDOM()}),20)}),te(n,"compositionstart",function(a){t.composing={data:a.data,done:!1}}),te(n,"compositionupdate",function(a){t.composing||(t.composing={data:a.data,done:!1})}),te(n,"compositionend",function(a){t.composing&&(a.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),te(n,"touchstart",function(){return i.forceCompositionEnd()}),te(n,"input",function(){t.composing||t.readFromDOMSoon()});function o(a){if(!(!l(a)||xe(r,a))){if(r.somethingSelected())an({lineWise:!1,text:r.getSelections()}),a.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var s=Da(r);an({lineWise:!0,text:s.text}),a.type=="cut"&&r.operation(function(){r.setSelections(s.ranges,0,ht),r.replaceSelection("",null,"cut")})}else return;if(a.clipboardData){a.clipboardData.clearData();var u=mt.text.join(` -`);if(a.clipboardData.setData("Text",u),a.clipboardData.getData("Text")==u){a.preventDefault();return}}var g=Na(),p=g.firstChild;yl(p),r.display.lineSpace.insertBefore(g,r.display.lineSpace.firstChild),p.value=mt.text.join(` -`);var T=tt(Pe(n));Zt(p),setTimeout(function(){r.display.lineSpace.removeChild(g),T.focus(),T==n&&i.showPrimarySelection()},50)}}te(n,"copy",o),te(n,"cut",o)},ve.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},ve.prototype.prepareSelection=function(){var e=So(this.cm,!1);return e.focus=tt(Pe(this.div))==this.div,e},ve.prototype.showSelection=function(e,t){!e||!this.cm.display.view.length||((e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e))},ve.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},ve.prototype.showPrimarySelection=function(){var e=this.getSelection(),t=this.cm,i=t.doc.sel.primary(),r=i.from(),n=i.to();if(t.display.viewTo==t.display.viewFrom||r.line>=t.display.viewTo||n.line=t.display.viewFrom&&Ea(t,r)||{node:a[0].measure.map[2],offset:0},u=n.linee.firstLine()&&(r=P(r.line-1,j(e.doc,r.line-1).length)),n.ch==j(e.doc,n.line).text.length&&n.linet.viewTo-1)return!1;var l,o,a;r.line==t.viewFrom||(l=nr(e,r.line))==0?(o=pe(t.view[0].line),a=t.view[0].node):(o=pe(t.view[l].line),a=t.view[l-1].node.nextSibling);var s=nr(e,n.line),u,g;if(s==t.view.length-1?(u=t.viewTo-1,g=t.lineDiv.lastChild):(u=pe(t.view[s+1].line)-1,g=t.view[s+1].node.previousSibling),!a)return!1;for(var p=e.doc.splitLines(sf(e,a,g,o,u)),T=Vt(e.doc,P(o,0),P(u,j(e.doc,u).text.length));p.length>1&&T.length>1;)if(f(p)==f(T))p.pop(),T.pop(),u--;else if(p[0]==T[0])p.shift(),T.shift(),o++;else break;for(var C=0,E=0,W=p[0],B=T[0],U=Math.min(W.length,B.length);Cr.ch&&$.charCodeAt($.length-E-1)==G.charCodeAt(G.length-E-1);)C--,E++;p[p.length-1]=$.slice(0,$.length-E).replace(/^\u200b+/,""),p[0]=p[0].slice(C).replace(/\u200b+$/,"");var ee=P(o,C),V=P(u,T.length?f(T).length-E:0);if(p.length>1||p[0]||ae(ee,V))return Or(e.doc,p,ee,V,"+input"),!0},ve.prototype.ensurePolled=function(){this.forceCompositionEnd()},ve.prototype.reset=function(){this.forceCompositionEnd()},ve.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},ve.prototype.readFromDOMSoon=function(){var e=this;this.readDOMTimeout==null&&(this.readDOMTimeout=setTimeout(function(){if(e.readDOMTimeout=null,e.composing)if(e.composing.done)e.composing=null;else return;e.updateFromDOM()},80))},ve.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&at(this.cm,function(){return rt(e.cm)})},ve.prototype.setUneditable=function(e){e.contentEditable="false"},ve.prototype.onKeyPress=function(e){e.charCode==0||this.composing||(e.preventDefault(),this.cm.isReadOnly()||Re(this.cm,vl)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0))},ve.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},ve.prototype.onContextMenu=function(){},ve.prototype.resetPosition=function(){},ve.prototype.needsContentAttribute=!0;function Ea(e,t){var i=Pn(e,t.line);if(!i||i.hidden)return null;var r=j(e.doc,t.line),n=ao(i,r,t.line),l=ge(r,e.doc.direction),o="left";if(l){var a=Ne(l,t.ch);o=a%2?"right":"left"}var s=fo(n.map,t.ch,o);return s.offset=s.collapse=="right"?s.end:s.start,s}function af(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function Hr(e,t){return t&&(e.bad=!0),e}function sf(e,t,i,r,n){var l="",o=!1,a=e.doc.lineSeparator(),s=!1;function u(C){return function(E){return E.id==C}}function g(){o&&(l+=a,s&&(l+=a),o=s=!1)}function p(C){C&&(g(),l+=C)}function T(C){if(C.nodeType==1){var E=C.getAttribute("cm-text");if(E){p(E);return}var W=C.getAttribute("cm-marker"),B;if(W){var U=e.findMarks(P(r,0),P(n+1,0),u(+W));U.length&&(B=U[0].find(0))&&p(Vt(e.doc,B.from,B.to).join(a));return}if(C.getAttribute("contenteditable")=="false")return;var $=/^(pre|div|p|li|table|br)$/i.test(C.nodeName);if(!/^br$/i.test(C.nodeName)&&C.textContent.length==0)return;$&&g();for(var G=0;G=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),te(n,"paste",function(o){xe(r,o)||Ma(o,r)||(r.state.pasteIncoming=+new Date,i.fastPoll())});function l(o){if(!xe(r,o)){if(r.somethingSelected())an({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var a=Da(r);an({lineWise:!0,text:a.text}),o.type=="cut"?r.setSelections(a.ranges,null,ht):(i.prevInput="",n.value=a.text.join(` -`),Zt(n))}else return;o.type=="cut"&&(r.state.cutIncoming=+new Date)}}te(n,"cut",l),te(n,"copy",l),te(e.scroller,"paste",function(o){if(!(Nt(e,o)||xe(r,o))){if(!n.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}var a=new Event("paste");a.clipboardData=o.clipboardData,n.dispatchEvent(a)}}),te(e.lineSpace,"selectstart",function(o){Nt(e,o)||Oe(o)}),te(n,"compositionstart",function(){var o=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:o,range:r.markText(o,r.getCursor("to"),{className:"CodeMirror-composing"})}}),te(n,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},_e.prototype.createField=function(e){this.wrapper=Na(),this.textarea=this.wrapper.firstChild;var t=this.cm.options;yl(this.textarea,t.spellcheck,t.autocorrect,t.autocapitalize)},_e.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},_e.prototype.prepareSelection=function(){var e=this.cm,t=e.display,i=e.doc,r=So(e);if(e.options.moveInputWithCursor){var n=vt(e,i.sel.primary().head,"div"),l=t.wrapper.getBoundingClientRect(),o=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+o.top-l.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+o.left-l.left))}return r},_e.prototype.showSelection=function(e){var t=this.cm,i=t.display;De(i.cursorDiv,e.cursors),De(i.selectionDiv,e.selection),e.teTop!=null&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},_e.prototype.reset=function(e){if(!(this.contextMenuPending||this.composing&&e)){var t=this.cm;if(this.resetting=!0,t.somethingSelected()){this.prevInput="";var i=t.getSelection();this.textarea.value=i,t.state.focused&&Zt(this.textarea),d&&v>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",d&&v>=9&&(this.hasSelection=null));this.resetting=!1}},_e.prototype.getField=function(){return this.textarea},_e.prototype.supportsTouch=function(){return!1},_e.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!ie||tt(Pe(this.textarea))!=this.textarea))try{this.textarea.focus()}catch{}},_e.prototype.blur=function(){this.textarea.blur()},_e.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},_e.prototype.receivedFocus=function(){this.slowPoll()},_e.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},_e.prototype.fastPoll=function(){var e=!1,t=this;t.pollingFast=!0;function i(){var r=t.poll();!r&&!e?(e=!0,t.polling.set(60,i)):(t.pollingFast=!1,t.slowPoll())}t.polling.set(20,i)},_e.prototype.poll=function(){var e=this,t=this.cm,i=this.textarea,r=this.prevInput;if(this.contextMenuPending||this.resetting||!t.state.focused||as(i)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var n=i.value;if(n==r&&!t.somethingSelected())return!1;if(d&&v>=9&&this.hasSelection===n||ne&&/[\uf700-\uf7ff]/.test(n))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var l=n.charCodeAt(0);if(l==8203&&!r&&(r="​"),l==8666)return this.reset(),this.cm.execCommand("undo")}for(var o=0,a=Math.min(r.length,n.length);o1e3||n.indexOf(` +`)&&(O=W=P(O.line,0)));var B={from:O,to:W,text:u?u[T%u.length]:s,origin:n||(a?"paste":e.state.cutIncoming>o?"cut":"+input")};Nr(e.doc,B),Be(e,"inputRead",e,B)}t&&!a&&Da(e,t),Ar(e),e.curOp.updateInput<2&&(e.curOp.updateInput=p),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function _a(e,t){var i=e.clipboardData&&e.clipboardData.getData("Text");if(i)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&t.hasFocus()&&at(t,function(){return vl(t,i,0,null,"paste")}),!0}function Da(e,t){if(!(!e.options.electricChars||!e.options.smartIndent))for(var i=e.doc.sel,r=i.ranges.length-1;r>=0;r--){var n=i.ranges[r];if(!(n.head.ch>100||r&&i.ranges[r-1].head.line==n.head.line)){var l=e.getModeAt(n.head),o=!1;if(l.electricChars){for(var a=0;a-1){o=bi(e,n.head.line,"smart");break}}else l.electricInput&&l.electricInput.test(j(e.doc,n.head.line).text.slice(0,n.head.ch))&&(o=bi(e,n.head.line,"smart"));o&&Be(e,"electricInput",e,n.head.line)}}}function Na(e){for(var t=[],i=[],r=0;rl&&(bi(this,a.head.line,r,!0),l=a.head.line,o==this.doc.sel.primIndex&&Ar(this));else{var s=a.from(),u=a.to(),g=Math.max(l,s.line);l=Math.min(this.lastLine(),u.line-(u.ch?0:1))+1;for(var p=g;p0&&sl(this.doc,o,new de(s,T[o].to()),ht)}}}),getTokenAt:function(r,n){return zl(this,r,n)},getLineTokens:function(r,n){return zl(this,P(r),n,!0)},getTokenTypeAt:function(r){r=se(this.doc,r);var n=Pl(this,j(this.doc,r.line)),l=0,o=(n.length-1)/2,a=r.ch,s;if(a==0)s=n[2];else for(;;){var u=l+o>>1;if((u?n[u*2-1]:0)>=a)o=u;else if(n[u*2+1]s&&(r=s,o=!0),a=j(this.doc,r)}else a=r;return zi(this,a,{top:0,left:0},n||"page",l||o).top+(o?this.doc.height-Dt(a):0)},defaultTextHeight:function(){return Tr(this.display)},defaultCharWidth:function(){return kr(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(r,n,l,o,a){var s=this.display;r=vt(this,se(this.doc,r));var u=r.bottom,g=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),s.sizer.appendChild(n),o=="over")u=r.top;else if(o=="above"||o=="near"){var p=Math.max(s.wrapper.clientHeight,this.doc.height),T=Math.max(s.sizer.clientWidth,s.lineSpace.clientWidth);(o=="above"||r.bottom+n.offsetHeight>p)&&r.top>n.offsetHeight?u=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=p&&(u=r.bottom),g+n.offsetWidth>T&&(g=T-n.offsetWidth)}n.style.top=u+"px",n.style.left=n.style.right="",a=="right"?(g=s.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(a=="left"?g=0:a=="middle"&&(g=(s.sizer.clientWidth-n.offsetWidth)/2),n.style.left=g+"px"),l&&iu(this,{left:g,top:u,right:g+n.offsetWidth,bottom:u+n.offsetHeight})},triggerOnKeyDown:Ve(wa),triggerOnKeyPress:Ve(Sa),triggerOnKeyUp:Ca,triggerOnMouseDown:Ve(La),execCommand:function(r){if(pi.hasOwnProperty(r))return pi[r].call(null,this)},triggerElectric:Ve(function(r){Da(this,r)}),findPosH:function(r,n,l,o){var a=1;n<0&&(a=-1,n=-n);for(var s=se(this.doc,r),u=0;u0&&g(l.charAt(o-1));)--o;for(;a.5||this.options.lineWrapping)&&$n(this),Te(this,"refresh",this)}),swapDoc:Ve(function(r){var n=this.doc;return n.cm=null,this.state.selectingText&&this.state.selectingText(),Ro(this,r),jr(this),this.display.input.reset(),ei(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,Be(this,"swapDoc",this,n),n}),phrase:function(r){var n=this.options.phrases;return n&&Object.prototype.hasOwnProperty.call(n,r)?n[r]:r},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Mt(e),e.registerHelper=function(r,n,l){i.hasOwnProperty(r)||(i[r]=e[r]={_global:[]}),i[r][n]=l},e.registerGlobalHelper=function(r,n,l,o){e.registerHelper(r,n,o),i[r]._global.push({pred:l,val:o})}}function ml(e,t,i,r,n){var l=t,o=i,a=j(e,t.line),s=n&&e.direction=="rtl"?-i:i;function u(){var $=t.line+s;return $=e.first+e.size?!1:(t=new P($,t.ch,t.sticky),a=j(e,$))}function g($){var G;if(r=="codepoint"){var X=a.text.charCodeAt(t.ch+(i>0?0:-1));if(isNaN(X))G=null;else{var ee=i>0?X>=55296&&X<56320:X>=56320&&X<57343;G=new P(t.line,Math.max(0,Math.min(a.text.length,t.ch+i*(ee?2:1))),-i)}}else n?G=zu(e.cm,a,t,i):G=fl(a,t,i);if(G==null)if(!$&&u())t=hl(n,e.cm,a,t.line,s);else return!1;else t=G;return!0}if(r=="char"||r=="codepoint")g();else if(r=="column")g(!0);else if(r=="word"||r=="group")for(var p=null,T=r=="group",S=e.cm&&e.cm.getHelper(t,"wordChars"),O=!0;!(i<0&&!g(!O));O=!1){var W=a.text.charAt(t.ch)||` +`,B=H(W,S)?"w":T&&W==` +`?"n":!T||/\s/.test(W)?null:"p";if(T&&!O&&!B&&(B="s"),p&&p!=B){i<0&&(i=1,g(),t.sticky="after");break}if(B&&(p=B),i>0&&!g(!O))break}var U=en(e,t,l,o,!0);return xn(l,U)&&(U.hitSide=!0),U}function Ea(e,t,i,r){var n=e.doc,l=t.left,o;if(r=="page"){var a=Math.min(e.display.wrapper.clientHeight,At(e).innerHeight||n(e).documentElement.clientHeight),s=Math.max(a-.5*Tr(e.display),3);o=(i>0?t.bottom:t.top)+i*s}else r=="line"&&(o=i>0?t.bottom+3:t.top-3);for(var u;u=zn(e,l,o),!!u.outside;){if(i<0?o<=0:o>=n.height){u.hitSide=!0;break}o+=i*5}return u}var ve=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new gt,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};ve.prototype.init=function(e){var t=this,i=this,r=i.cm,n=i.div=e.lineDiv;n.contentEditable=!0,yl(n,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function l(a){for(var s=a.target;s;s=s.parentNode){if(s==n)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(s.className))break}return!1}te(n,"paste",function(a){!l(a)||xe(r,a)||_a(a,r)||v<=11&&setTimeout(Re(r,function(){return t.updateFromDOM()}),20)}),te(n,"compositionstart",function(a){t.composing={data:a.data,done:!1}}),te(n,"compositionupdate",function(a){t.composing||(t.composing={data:a.data,done:!1})}),te(n,"compositionend",function(a){t.composing&&(a.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),te(n,"touchstart",function(){return i.forceCompositionEnd()}),te(n,"input",function(){t.composing||t.readFromDOMSoon()});function o(a){if(!(!l(a)||xe(r,a))){if(r.somethingSelected())an({lineWise:!1,text:r.getSelections()}),a.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var s=Na(r);an({lineWise:!0,text:s.text}),a.type=="cut"&&r.operation(function(){r.setSelections(s.ranges,0,ht),r.replaceSelection("",null,"cut")})}else return;if(a.clipboardData){a.clipboardData.clearData();var u=mt.text.join(` +`);if(a.clipboardData.setData("Text",u),a.clipboardData.getData("Text")==u){a.preventDefault();return}}var g=Oa(),p=g.firstChild;yl(p),r.display.lineSpace.insertBefore(g,r.display.lineSpace.firstChild),p.value=mt.text.join(` +`);var T=tt(Pe(n));Zt(p),setTimeout(function(){r.display.lineSpace.removeChild(g),T.focus(),T==n&&i.showPrimarySelection()},50)}}te(n,"copy",o),te(n,"cut",o)},ve.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},ve.prototype.prepareSelection=function(){var e=Lo(this.cm,!1);return e.focus=tt(Pe(this.div))==this.div,e},ve.prototype.showSelection=function(e,t){!e||!this.cm.display.view.length||((e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e))},ve.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},ve.prototype.showPrimarySelection=function(){var e=this.getSelection(),t=this.cm,i=t.doc.sel.primary(),r=i.from(),n=i.to();if(t.display.viewTo==t.display.viewFrom||r.line>=t.display.viewTo||n.line=t.display.viewFrom&&Wa(t,r)||{node:a[0].measure.map[2],offset:0},u=n.linee.firstLine()&&(r=P(r.line-1,j(e.doc,r.line-1).length)),n.ch==j(e.doc,n.line).text.length&&n.linet.viewTo-1)return!1;var l,o,a;r.line==t.viewFrom||(l=nr(e,r.line))==0?(o=pe(t.view[0].line),a=t.view[0].node):(o=pe(t.view[l].line),a=t.view[l-1].node.nextSibling);var s=nr(e,n.line),u,g;if(s==t.view.length-1?(u=t.viewTo-1,g=t.lineDiv.lastChild):(u=pe(t.view[s+1].line)-1,g=t.view[s+1].node.previousSibling),!a)return!1;for(var p=e.doc.splitLines(uf(e,a,g,o,u)),T=Vt(e.doc,P(o,0),P(u,j(e.doc,u).text.length));p.length>1&&T.length>1;)if(f(p)==f(T))p.pop(),T.pop(),u--;else if(p[0]==T[0])p.shift(),T.shift(),o++;else break;for(var S=0,O=0,W=p[0],B=T[0],U=Math.min(W.length,B.length);Sr.ch&&$.charCodeAt($.length-O-1)==G.charCodeAt(G.length-O-1);)S--,O++;p[p.length-1]=$.slice(0,$.length-O).replace(/^\u200b+/,""),p[0]=p[0].slice(S).replace(/\u200b+$/,"");var ee=P(o,S),V=P(u,T.length?f(T).length-O:0);if(p.length>1||p[0]||ae(ee,V))return Or(e.doc,p,ee,V,"+input"),!0},ve.prototype.ensurePolled=function(){this.forceCompositionEnd()},ve.prototype.reset=function(){this.forceCompositionEnd()},ve.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},ve.prototype.readFromDOMSoon=function(){var e=this;this.readDOMTimeout==null&&(this.readDOMTimeout=setTimeout(function(){if(e.readDOMTimeout=null,e.composing)if(e.composing.done)e.composing=null;else return;e.updateFromDOM()},80))},ve.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&at(this.cm,function(){return rt(e.cm)})},ve.prototype.setUneditable=function(e){e.contentEditable="false"},ve.prototype.onKeyPress=function(e){e.charCode==0||this.composing||(e.preventDefault(),this.cm.isReadOnly()||Re(this.cm,vl)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0))},ve.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},ve.prototype.onContextMenu=function(){},ve.prototype.resetPosition=function(){},ve.prototype.needsContentAttribute=!0;function Wa(e,t){var i=Pn(e,t.line);if(!i||i.hidden)return null;var r=j(e.doc,t.line),n=so(i,r,t.line),l=ge(r,e.doc.direction),o="left";if(l){var a=Ne(l,t.ch);o=a%2?"right":"left"}var s=ho(n.map,t.ch,o);return s.offset=s.collapse=="right"?s.end:s.start,s}function sf(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function Hr(e,t){return t&&(e.bad=!0),e}function uf(e,t,i,r,n){var l="",o=!1,a=e.doc.lineSeparator(),s=!1;function u(S){return function(O){return O.id==S}}function g(){o&&(l+=a,s&&(l+=a),o=s=!1)}function p(S){S&&(g(),l+=S)}function T(S){if(S.nodeType==1){var O=S.getAttribute("cm-text");if(O){p(O);return}var W=S.getAttribute("cm-marker"),B;if(W){var U=e.findMarks(P(r,0),P(n+1,0),u(+W));U.length&&(B=U[0].find(0))&&p(Vt(e.doc,B.from,B.to).join(a));return}if(S.getAttribute("contenteditable")=="false")return;var $=/^(pre|div|p|li|table|br)$/i.test(S.nodeName);if(!/^br$/i.test(S.nodeName)&&S.textContent.length==0)return;$&&g();for(var G=0;G=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),te(n,"paste",function(o){xe(r,o)||_a(o,r)||(r.state.pasteIncoming=+new Date,i.fastPoll())});function l(o){if(!xe(r,o)){if(r.somethingSelected())an({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var a=Na(r);an({lineWise:!0,text:a.text}),o.type=="cut"?r.setSelections(a.ranges,null,ht):(i.prevInput="",n.value=a.text.join(` +`),Zt(n))}else return;o.type=="cut"&&(r.state.cutIncoming=+new Date)}}te(n,"cut",l),te(n,"copy",l),te(e.scroller,"paste",function(o){if(!(Nt(e,o)||xe(r,o))){if(!n.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}var a=new Event("paste");a.clipboardData=o.clipboardData,n.dispatchEvent(a)}}),te(e.lineSpace,"selectstart",function(o){Nt(e,o)||Oe(o)}),te(n,"compositionstart",function(){var o=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:o,range:r.markText(o,r.getCursor("to"),{className:"CodeMirror-composing"})}}),te(n,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},_e.prototype.createField=function(e){this.wrapper=Oa(),this.textarea=this.wrapper.firstChild;var t=this.cm.options;yl(this.textarea,t.spellcheck,t.autocorrect,t.autocapitalize)},_e.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},_e.prototype.prepareSelection=function(){var e=this.cm,t=e.display,i=e.doc,r=Lo(e);if(e.options.moveInputWithCursor){var n=vt(e,i.sel.primary().head,"div"),l=t.wrapper.getBoundingClientRect(),o=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+o.top-l.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+o.left-l.left))}return r},_e.prototype.showSelection=function(e){var t=this.cm,i=t.display;De(i.cursorDiv,e.cursors),De(i.selectionDiv,e.selection),e.teTop!=null&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},_e.prototype.reset=function(e){if(!(this.contextMenuPending||this.composing&&e)){var t=this.cm;if(this.resetting=!0,t.somethingSelected()){this.prevInput="";var i=t.getSelection();this.textarea.value=i,t.state.focused&&Zt(this.textarea),d&&v>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",d&&v>=9&&(this.hasSelection=null));this.resetting=!1}},_e.prototype.getField=function(){return this.textarea},_e.prototype.supportsTouch=function(){return!1},_e.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!ie||tt(Pe(this.textarea))!=this.textarea))try{this.textarea.focus()}catch{}},_e.prototype.blur=function(){this.textarea.blur()},_e.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},_e.prototype.receivedFocus=function(){this.slowPoll()},_e.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},_e.prototype.fastPoll=function(){var e=!1,t=this;t.pollingFast=!0;function i(){var r=t.poll();!r&&!e?(e=!0,t.polling.set(60,i)):(t.pollingFast=!1,t.slowPoll())}t.polling.set(20,i)},_e.prototype.poll=function(){var e=this,t=this.cm,i=this.textarea,r=this.prevInput;if(this.contextMenuPending||this.resetting||!t.state.focused||ss(i)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var n=i.value;if(n==r&&!t.somethingSelected())return!1;if(d&&v>=9&&this.hasSelection===n||ne&&/[\uf700-\uf7ff]/.test(n))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var l=n.charCodeAt(0);if(l==8203&&!r&&(r="​"),l==8666)return this.reset(),this.cm.execCommand("undo")}for(var o=0,a=Math.min(r.length,n.length);o1e3||n.indexOf(` `)>-1?i.value=e.prevInput="":e.prevInput=n,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},_e.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},_e.prototype.onKeyPress=function(){d&&v>=9&&(this.hasSelection=null),this.fastPoll()},_e.prototype.onContextMenu=function(e){var t=this,i=t.cm,r=i.display,n=t.textarea;t.contextMenuPending&&t.contextMenuPending();var l=ir(i,e),o=r.scroller.scrollTop;if(!l||F)return;var a=i.options.resetSelectionOnContextMenu;a&&i.doc.sel.contains(l)==-1&&Re(i,Qe)(i.doc,Ut(l),ht);var s=n.style.cssText,u=t.wrapper.style.cssText,g=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px; top: `+(e.clientY-g.top-5)+"px; left: "+(e.clientX-g.left-5)+`px; z-index: 1000; background: `+(d?"rgba(255, 255, 255, .05)":"transparent")+`; - outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;var p;b&&(p=n.ownerDocument.defaultView.scrollY),r.input.focus(),b&&n.ownerDocument.defaultView.scrollTo(null,p),r.input.reset(),i.somethingSelected()||(n.value=t.prevInput=" "),t.contextMenuPending=C,r.selForContextMenu=i.doc.sel,clearTimeout(r.detectingSelectAll);function T(){if(n.selectionStart!=null){var W=i.somethingSelected(),B="​"+(W?n.value:"");n.value="⇚",n.value=B,t.prevInput=W?"":"​",n.selectionStart=1,n.selectionEnd=B.length,r.selForContextMenu=i.doc.sel}}function C(){if(t.contextMenuPending==C&&(t.contextMenuPending=!1,t.wrapper.style.cssText=u,n.style.cssText=s,d&&v<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=o),n.selectionStart!=null)){(!d||d&&v<9)&&T();var W=0,B=function(){r.selForContextMenu==i.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&t.prevInput=="​"?Re(i,jo)(i):W++<10?r.detectingSelectAll=setTimeout(B,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(B,200)}}if(d&&v>=9&&T(),Fe){$r(e);var E=function(){je(window,"mouseup",E),setTimeout(C,20)};te(window,"mouseup",E)}else setTimeout(C,50)},_e.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},_e.prototype.setUneditable=function(){},_e.prototype.needsContentAttribute=!1;function ff(e,t){if(t=t?dt(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),t.autofocus==null){var i=tt(Pe(e));t.autofocus=i==e||e.getAttribute("autofocus")!=null&&i==document.body}function r(){e.value=a.getValue()}var n;if(e.form&&(te(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var l=e.form;n=l.submit;try{var o=l.submit=function(){r(),l.submit=n,l.submit(),l.submit=o}}catch{}}t.finishInit=function(s){s.save=r,s.getTextArea=function(){return e},s.toTextArea=function(){s.toTextArea=isNaN,r(),e.parentNode.removeChild(s.getWrapperElement()),e.style.display="",e.form&&(je(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=n))}},e.style.display="none";var a=Le(function(s){return e.parentNode.insertBefore(s,e.nextSibling)},t);return a}function hf(e){e.off=je,e.on=te,e.wheelEventPixels=yu,e.Doc=it,e.splitLines=bn,e.countColumn=Ze,e.findColumn=Gr,e.isWordChar=I,e.Pass=Ht,e.signal=Te,e.Line=Cr,e.changeEnd=Gt,e.scrollbarModel=Mo,e.Pos=P,e.cmpPos=ae,e.modes=Cn,e.mimeModes=br,e.resolveMode=Di,e.getMode=Sn,e.modeExtensions=wr,e.extendMode=cs,e.copyState=jt,e.startState=El,e.innerMode=Ln,e.commands=pi,e.keyMap=Et,e.keyName=ga,e.isModifierKey=ca,e.lookupKey=Wr,e.normalizeKeyMap=Bu,e.StringStream=Ee,e.SharedTextMarker=ci,e.TextMarker=$t,e.LineWidget=hi,e.e_preventDefault=Oe,e.e_stopPropagation=Nl,e.e_stop=$r,e.addClass=xt,e.contains=ct,e.rmClass=Me,e.keyNames=Xt}tf(Le),of(Le);var cf="iter insert remove copy getEditor constructor".split(" ");for(var un in it.prototype)it.prototype.hasOwnProperty(un)&&Se(cf,un)<0&&(Le.prototype[un]=function(e){return function(){return e.apply(this.doc,arguments)}}(it.prototype[un]));return Mt(it),Le.inputStyles={textarea:_e,contenteditable:ve},Le.defineMode=function(e){!Le.defaults.mode&&e!="null"&&(Le.defaults.mode=e),fs.apply(this,arguments)},Le.defineMIME=hs,Le.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Le.defineMIME("text/plain","null"),Le.defineExtension=function(e,t){Le.prototype[e]=t},Le.defineDocExtension=function(e,t){it.prototype[e]=t},Le.fromTextArea=ff,hf(Le),Le.version="5.65.16",Le})}(Cl)),Cl.exports}var yf=qa();const mf=vf(yf);var Ia={exports:{}},Fa;function bf(){return Fa||(Fa=1,function(O,m){(function(S){S(qa())})(function(S){var N=S.Pos,k="http://www.w3.org/2000/svg";function z(f,y){this.mv=f,this.type=y,this.classes=y=="left"?{chunk:"CodeMirror-merge-l-chunk",start:"CodeMirror-merge-l-chunk-start",end:"CodeMirror-merge-l-chunk-end",insert:"CodeMirror-merge-l-inserted",del:"CodeMirror-merge-l-deleted",connect:"CodeMirror-merge-l-connect"}:{chunk:"CodeMirror-merge-r-chunk",start:"CodeMirror-merge-r-chunk-start",end:"CodeMirror-merge-r-chunk-end",insert:"CodeMirror-merge-r-inserted",del:"CodeMirror-merge-r-deleted",connect:"CodeMirror-merge-r-connect"}}z.prototype={constructor:z,init:function(f,y,L){this.edit=this.mv.edit,(this.edit.state.diffViews||(this.edit.state.diffViews=[])).push(this),this.orig=S(f,dt({value:y,readOnly:!this.mv.options.allowEditingOriginals},dt(L))),this.mv.options.connect=="align"&&(this.edit.state.trackAlignable||(this.edit.state.trackAlignable=new Ht(this.edit)),this.orig.state.trackAlignable=new Ht(this.orig)),this.lockButton.title=this.edit.phrase("Toggle locked scrolling"),this.lockButton.setAttribute("aria-label",this.lockButton.title),this.orig.state.diffViews=[this];var x=L.chunkClassLocation||"background";Object.prototype.toString.call(x)!="[object Array]"&&(x=[x]),this.classes.classLocation=x,this.diff=kt(De(y),De(L.value),this.mv.options.ignoreWhitespace),this.chunks=bt(this.diff),this.diffOutOfDate=this.dealigned=!1,this.needsScrollSync=null,this.showDifferences=L.showDifferences!==!1},registerEvents:function(f){this.forceUpdate=d(this),A(this,!0,!1),v(this,f)},setShowDifferences:function(f){f=f!==!1,f!=this.showDifferences&&(this.showDifferences=f,this.forceUpdate("full"))}};function h(f){f.diffOutOfDate&&(f.diff=kt(f.orig.getValue(),f.edit.getValue(),f.mv.options.ignoreWhitespace),f.chunks=bt(f.diff),f.diffOutOfDate=!1,S.signal(f.edit,"updateDiff",f.diff))}var c=!1;function d(f){var y={from:0,to:0,marked:[]},L={from:0,to:0,marked:[]},x,M=!1;function D(ue){c=!0,M=!1,ue=="full"&&(f.svg&&At(f.svg),f.copyButtons&&At(f.copyButtons),F(f.edit,y.marked,f.classes),F(f.orig,L.marked,f.classes),y.from=y.to=L.from=L.to=0),h(f),f.showDifferences&&(K(f.edit,f.diff,y,DIFF_INSERT,f.classes),K(f.orig,f.diff,L,DIFF_DELETE,f.classes)),f.mv.options.connect=="align"&&re(f),Z(f),f.needsScrollSync!=null&&b(f,f.needsScrollSync),c=!1}function I(ue){c||(f.dealigned=!0,H(ue))}function H(ue){c||M||(clearTimeout(x),ue===!0&&(M=!0),x=setTimeout(D,ue===!0?20:250))}function R(ue,ce){f.diffOutOfDate||(f.diffOutOfDate=!0,y.from=y.to=L.from=L.to=0),I(ce.text.length-1!=ce.to.line-ce.from.line)}function oe(){f.diffOutOfDate=!0,f.dealigned=!0,D("full")}return f.edit.on("change",R),f.orig.on("change",R),f.edit.on("swapDoc",oe),f.orig.on("swapDoc",oe),f.mv.options.connect=="align"&&(S.on(f.edit.state.trackAlignable,"realign",I),S.on(f.orig.state.trackAlignable,"realign",I)),f.edit.on("viewportChange",function(){H(!1)}),f.orig.on("viewportChange",function(){H(!1)}),D(),D}function v(f,y){f.edit.on("scroll",function(){b(f,!0)&&Z(f)}),f.orig.on("scroll",function(){b(f,!1)&&Z(f),y&&b(y,!0)&&Z(y)})}function b(f,y){if(f.diffOutOfDate)return f.lockScroll&&f.needsScrollSync==null&&(f.needsScrollSync=y),!1;if(f.needsScrollSync=null,!f.lockScroll)return!0;var L,x,M=+new Date;if(y?(L=f.edit,x=f.orig):(L=f.orig,x=f.edit),L.state.scrollSetBy==f&&(L.state.scrollSetAt||0)+250>M)return!1;var D=L.getScrollInfo();if(f.mv.options.connect=="align")Ce=D.top;else{var I=.5*D.clientHeight,H=D.top+I,R=L.lineAtHeight(H,"local"),oe=xt(f.chunks,R,y),ue=w(L,y?oe.edit:oe.orig),ce=w(x,y?oe.orig:oe.edit),me=(H-ue.top)/(ue.bot-ue.top),Ce=ce.top-I+me*(ce.bot-ce.top),be,Ne;if(Ce>D.top&&(Ne=D.top/I)<1)Ce=Ce*Ne+D.top*(1-Ne);else if((be=D.height-D.clientHeight-D.top)be&&(Ne=be/I)<1&&(Ce=Ce*Ne+(ut.height-ut.clientHeight-be)*(1-Ne))}}return x.scrollTo(D.left,Ce),x.state.scrollSetAt=M,x.state.scrollSetBy=f,!0}function w(f,y){var L=y.after;return L==null&&(L=f.lastLine()+1),{top:f.heightAtLine(y.before||0,"local"),bot:f.heightAtLine(L,"local")}}function A(f,y,L){f.lockScroll=y,y&&L!=!1&&b(f,DIFF_INSERT)&&Z(f),(y?S.addClass:S.rmClass)(f.lockButton,"CodeMirror-merge-scrolllock-enabled")}function _(f,y,L){for(var x=L.classLocation,M=0;M20||L.from-D.to>20?(F(f,L.marked,M),q(f,y,x,L.marked,D.from,D.to,M),L.from=D.from,L.to=D.to):(D.fromL.to&&(q(f,y,x,L.marked,L.to,D.to,M),L.to=D.to))})}function Y(f,y,L,x,M,D){for(var I=L.classLocation,H=f.getLineHandle(y),R=0;RKr&&(Ce&&(ce(me,Kr),Ce=!1),me=te)}else if(Ce=!0,ut==L){var mr=Ze(H,ge,!0),je=Ur(R,H),Te=ht(oe,mr);Jt(je,Te)||x.push(f.markText(je,Te,{className:ue})),H=mr}}Ce&&ce(me,H.line+1)}function Z(f){if(f.showDifferences){if(f.svg){At(f.svg);var y=f.gap.offsetWidth;pr(f.svg,"width",y,"height",f.gap.offsetHeight)}f.copyButtons&&At(f.copyButtons);for(var L=f.edit.getViewport(),x=f.orig.getViewport(),M=f.mv.wrap.getBoundingClientRect().top,D=M-f.edit.getScrollerElement().getBoundingClientRect().top+f.edit.getScrollInfo().top,I=M-f.orig.getScrollerElement().getBoundingClientRect().top+f.orig.getScrollInfo().top,H=0;H=L.from&&R.origFrom<=x.to&&R.origTo>=x.from&&Fe(f,R,I,D,y)}}}function le(f,y){for(var L=0,x=0,M=0;Mf&&D.editFrom<=f)return null;if(D.editFrom>f)break;L=D.editTo,x=D.origTo}return x+(f-L)}function ie(f,y,L){for(var x=f.state.trackAlignable,M=f.firstLine(),D=0,I=[],H=0;;H++){for(var R=y[H],oe=R?L?R.origFrom:R.editFrom:1e9;Dce){D++,M--;continue e}if(me.editTo>ue){if(me.editFrom<=ue)continue e;break}H+=me.origTo-me.origFrom-(me.editTo-me.editFrom),I++}if(ue==ce-H)R[x]=ce,D++;else if(ue1&&x.push(ye(f[I],L[I],R))}}function ye(f,y,L){var x=!0;y>f.lastLine()&&(y--,x=!1);var M=document.createElement("div");return M.className="CodeMirror-merge-spacer",M.style.height=L+"px",M.style.minWidth="1px",f.addLineWidget(y,M,{height:L,above:x,mergeSpacer:!0,handleMouseEvents:!0})}function Fe(f,y,L,x,M){var D=f.type=="left",I=f.orig.heightAtLine(y.origFrom,"local",!0)-L;if(f.svg){var H=I,R=f.edit.heightAtLine(y.editFrom,"local",!0)-x;if(D){var oe=H;H=R,R=oe}var ue=f.orig.heightAtLine(y.origTo,"local",!0)-L,ce=f.edit.heightAtLine(y.editTo,"local",!0)-x;if(D){var oe=ue;ue=ce,ce=oe}var me=" C "+M/2+" "+R+" "+M/2+" "+H+" "+(M+2)+" "+H,Ce=" C "+M/2+" "+ue+" "+M/2+" "+ce+" -1 "+ce;pr(f.svg.appendChild(document.createElementNS(k,"path")),"d","M -1 "+R+me+" L "+(M+2)+" "+ue+Ce+" z","class",f.classes.connect)}if(f.copyButtons){var be=f.copyButtons.appendChild(Pe("div",f.type=="left"?"⇝":"⇜","CodeMirror-merge-copy")),Ne=f.mv.options.allowEditingOriginals;if(be.title=f.edit.phrase(Ne?"Push to left":"Revert chunk"),be.chunk=y,be.style.top=(y.origTo>y.origFrom?I:f.edit.heightAtLine(y.editFrom,"local")-x)+"px",be.setAttribute("role","button"),be.setAttribute("tabindex","0"),be.setAttribute("aria-label",be.title),Ne){var ut=f.edit.heightAtLine(y.editFrom,"local")-x,ge=f.copyButtons.appendChild(Pe("div",f.type=="right"?"⇝":"⇜","CodeMirror-merge-copy-reverse"));ge.title="Push to right",ge.chunk={editFrom:y.origFrom,editTo:y.origTo,origFrom:y.editFrom,origTo:y.editTo},ge.style.top=ut+"px",f.type=="right"?ge.style.left="2px":ge.style.right="2px",ge.setAttribute("role","button"),ge.setAttribute("tabindex","0"),ge.setAttribute("aria-label",ge.title)}}}function Ke(f,y,L,x){if(!f.diffOutOfDate){var M=x.origTo>L.lastLine()?N(x.origFrom-1):N(x.origFrom,0),D=N(x.origTo,0),I=x.editTo>y.lastLine()?N(x.editFrom-1):N(x.editFrom,0),H=N(x.editTo,0),R=f.mv.options.revertChunk;R?R(f.mv,L,M,D,y,I,H):y.replaceRange(L.getRange(M,D),I,H)}}var Me=S.MergeView=function(f,y){if(!(this instanceof Me))return new Me(f,y);this.options=y;var L=y.origLeft,x=y.origRight==null?y.orig:y.origRight,M=L!=null,D=x!=null,I=1+(M?1:0)+(D?1:0),H=[],R=this.left=null,oe=this.right=null,ue=this;if(M){R=this.left=new z(this,"left");var ce=Pe("div",null,"CodeMirror-merge-pane CodeMirror-merge-left");H.push(ce),H.push(qe(R))}var me=Pe("div",null,"CodeMirror-merge-pane CodeMirror-merge-editor");if(H.push(me),D){oe=this.right=new z(this,"right"),H.push(qe(oe));var Ce=Pe("div",null,"CodeMirror-merge-pane CodeMirror-merge-right");H.push(Ce)}(D?Ce:me).className+=" CodeMirror-merge-pane-rightmost",H.push(Pe("div",null,null,"height: 0; clear: both;"));var be=this.wrap=f.appendChild(Pe("div",H,"CodeMirror-merge CodeMirror-merge-"+I+"pane"));this.edit=S(me,dt(y)),R&&R.init(ce,L,y),oe&&oe.init(Ce,x,y),y.collapseIdentical&&this.editor().operation(function(){Ft(ue,y.collapseIdentical)}),y.connect=="align"&&(this.aligners=[],re(this.left||this.right,!0)),R&&R.registerEvents(oe),oe&&oe.registerEvents(R);var Ne=function(){R&&Z(R),oe&&Z(oe)};S.on(window,"resize",Ne);var ut=setInterval(function(){for(var ge=be.parentNode;ge&&ge!=document.body;ge=ge.parentNode);ge||(clearInterval(ut),S.off(window,"resize",Ne))},5e3)};function qe(f){var y=f.lockButton=Pe("div",null,"CodeMirror-merge-scrolllock");y.setAttribute("role","button"),y.setAttribute("tabindex","0");var L=Pe("div",[y],"CodeMirror-merge-scrolllock-wrap");S.on(y,"click",function(){A(f,!f.lockScroll)}),S.on(y,"keyup",function(I){(I.key==="Enter"||I.code==="Space")&&A(f,!f.lockScroll)});var x=[L];if(f.mv.options.revertButtons!==!1){f.copyButtons=Pe("div",null,"CodeMirror-merge-copybuttons-"+f.type);var M=function(I){var H=I.target||I.srcElement;if(H.chunk){if(H.className=="CodeMirror-merge-copy-reverse"){Ke(f,f.orig,f.edit,H.chunk);return}Ke(f,f.edit,f.orig,H.chunk)}};S.on(f.copyButtons,"click",M),S.on(f.copyButtons,"keyup",function(I){(I.key==="Enter"||I.code==="Space")&&M(I)}),x.unshift(f.copyButtons)}if(f.mv.options.connect!="align"){var D=document.createElementNS&&document.createElementNS(k,"svg");D&&!D.createSVGRect&&(D=null),f.svg=D,D&&x.push(D)}return f.gap=Pe("div",x,"CodeMirror-merge-gap")}Me.prototype={constructor:Me,editor:function(){return this.edit},rightOriginal:function(){return this.right&&this.right.orig},leftOriginal:function(){return this.left&&this.left.orig},setShowDifferences:function(f){this.right&&this.right.setShowDifferences(f),this.left&&this.left.setShowDifferences(f)},rightChunks:function(){if(this.right)return h(this.right),this.right.chunks},leftChunks:function(){if(this.left)return h(this.left),this.left.chunks}};function De(f){return typeof f=="string"?f:f.getValue()}var Q;function kt(f,y,L){Q||(Q=new diff_match_patch);for(var x=Q.diff_main(f,y),M=0;Mue&&(I&&y.push({origFrom:x,origTo:ce,editFrom:L,editTo:ue}),L=Ce,x=be)}else Ze(R==DIFF_INSERT?M:D,H[1])}return(L<=M.line||x<=D.line)&&y.push({origFrom:x,origTo:D.line+1,editFrom:L,editTo:M.line+1}),y}function ct(f,y){if(y==f.length-1)return!0;var L=f[y+1][1];return L.length==1&&y1||y==f.length-3)&&L.charCodeAt(0)==10)}function tt(f,y){if(y==0)return!0;var L=f[y-1][1];return L.charCodeAt(L.length-1)!=10?!1:y==1?!0:(L=f[y-2][1],L.charCodeAt(L.length-1)==10)}function xt(f,y,L){for(var x,M,D,I,H=0;Hy?(M=R.editFrom,I=R.origFrom):ue>y&&(M=R.editTo,I=R.origTo)),ue<=y?(x=R.editTo,D=R.origTo):oe<=y&&(x=R.editFrom,D=R.origFrom)}return{edit:{before:x,after:M},orig:{before:D,after:I}}}function zr(f,y,L){f.addLineClass(y,"wrap","CodeMirror-merge-collapsed-line");var x=document.createElement("span");x.className="CodeMirror-merge-collapsed-widget",x.title=f.phrase("Identical text collapsed. Click to expand.");var M=f.markText(N(y,0),N(L-1),{inclusiveLeft:!0,inclusiveRight:!0,replacedWith:x,clearOnEnter:!0});function D(){M.clear(),f.removeLineClass(y,"wrap","CodeMirror-merge-collapsed-line")}return M.explicitlyCleared&&D(),S.on(x,"click",D),M.on("clear",D),S.on(x,"click",D),{mark:M,clear:D}}function Zt(f,y){var L=[];function x(){for(var H=0;H=0&&Hy){var ue=[{line:R,cm:x}];f.left&&ue.push({line:le(R,f.left.chunks),cm:f.left.orig}),f.right&&ue.push({line:le(R,f.right.chunks),cm:f.right.orig});var ce=Zt(oe,ue);f.options.onCollapse&&f.options.onCollapse(f,R,oe,ce)}}}function Pe(f,y,L,x){var M=document.createElement(f);if(L&&(M.className=L),x&&(M.style.cssText=x),typeof y=="string")M.appendChild(document.createTextNode(y));else if(y)for(var D=0;D0;--y)f.removeChild(f.firstChild)}function pr(f){for(var y=1;y0)break}this.signal(),this.alignable.splice(L,0,f,y)},find:function(f){for(var y=0;y-1){var oe=this.alignable[D+1];oe==Se?this.alignable.splice(D,2):this.alignable[D+1]=oe&~Se}I>-1&&L&&this.set(f+L,Se)}};function ht(f,y){return(f.line-y.line||f.ch-y.ch)<0?f:y}function Ur(f,y){return(f.line-y.line||f.ch-y.ch)>0?f:y}function Jt(f,y){return f.line==y.line&&f.ch==y.ch}function Gr(f,y,L){for(var x=f.length-1;x>=0;x--){var M=f[x],D=(L?M.origTo:M.editTo)-1;if(Dy)return D}}function yr(f,y){var L=null,x=f.state.diffViews,M=f.getCursor().line;if(x)for(var D=0;DL:R"u"&&(d=!0);var v=d,b=this.diff_commonPrefix(h,c),w=h.substring(0,b);h=h.substring(b),c=c.substring(b),b=this.diff_commonSuffix(h,c);var A=h.substring(h.length-b);h=h.substring(0,h.length-b),c=c.substring(0,c.length-b);var _=this.diff_compute(h,c,v);return w&&_.unshift([k,w]),A&&_.push([k,A]),this.diff_cleanupMerge(_),_},m.prototype.diff_compute=function(h,c,d){var v;if(!h)return[[N,c]];if(!c)return[[S,h]];var b=h.length>c.length?h:c,w=h.length>c.length?c:h,A=b.indexOf(w);if(A!=-1)return v=[[N,b.substring(0,A)],[k,w],[N,b.substring(A+w.length)]],h.length>c.length&&(v[0][0]=v[2][0]=S),v;b=w=null;var _=this.diff_halfMatch(h,c);if(_){var F=_[0],K=_[1],Y=_[2],q=_[3],Z=_[4],le=this.diff_main(F,Y,d),ie=this.diff_main(K,q,d);return le.concat([[k,Z]],ie)}d&&(h.length<100||c.length<100)&&(d=!1);var ne;if(d){var he=this.diff_linesToChars(h,c);h=he[0],c=he[1],ne=he[2]}if(v=this.diff_map(h,c),v||(v=[[S,h],[N,c]]),d){this.diff_charsToLines(v,ne),this.diff_cleanupSemantic(v),v.push([k,""]);for(var re=0,J=0,ye=0,Fe="",Ke="";re=1&&ye>=1){var he=this.diff_main(Fe,Ke,!1);v.splice(re-J-ye,J+ye),re=re-J-ye;for(var Me=he.length-1;Me>=0;Me--)v.splice(re,0,he[Me]);re=re+he.length}ye=0,J=0,Fe="",Ke="";break}re++}v.pop()}return v},m.prototype.diff_linesToChars=function(h,c){var d=[],v={};d[0]="";function b(_){for(var F="",K=0,Y=-1,q=d.length;Y<_.length-1;){Y=_.indexOf(` -`,K),Y==-1&&(Y=_.length-1);var Z=_.substring(K,Y+1);K=Y+1,(v.hasOwnProperty?v.hasOwnProperty(Z):v[Z]!==void 0)?F+=String.fromCharCode(v[Z]):(F+=String.fromCharCode(q),v[Z]=q,d[q++]=Z)}return F}var w=b(h),A=b(c);return[w,A,d]},m.prototype.diff_charsToLines=function(h,c){for(var d=0;d0&&new Date().getTime()>d)return null;_[re]={};for(var J=-re;J<=re;J+=2){for(J==-re||J!=re&&K[J-1]=0;_--)for(;;)if(h[_][b-1+","+w]!==void 0){b--,A===S?v[0][1]=c.charAt(b)+v[0][1]:v.unshift([S,c.charAt(b)]),A=S;break}else if(h[_][b+","+(w-1)]!==void 0){w--,A===N?v[0][1]=d.charAt(w)+v[0][1]:v.unshift([N,d.charAt(w)]),A=N;break}else{if(b--,w--,c.charAt(b)!=d.charAt(w))throw new Error("No diagonal. Can't happen. (diff_path1)");A===k?v[0][1]=c.charAt(b)+v[0][1]:v.unshift([k,c.charAt(b)]),A=k}return v},m.prototype.diff_path2=function(h,c,d){for(var v=[],b=0,w=c.length,A=d.length,_=null,F=h.length-2;F>=0;F--)for(;;)if(h[F][w-1+","+A]!==void 0){w--,_===S?v[b-1][1]+=c.charAt(c.length-w-1):v[b++]=[S,c.charAt(c.length-w-1)],_=S;break}else if(h[F][w+","+(A-1)]!==void 0){A--,_===N?v[b-1][1]+=d.charAt(d.length-A-1):v[b++]=[N,d.charAt(d.length-A-1)],_=N;break}else{if(w--,A--,c.charAt(c.length-w-1)!=d.charAt(d.length-A-1))throw new Error("No diagonal. Can't happen. (diff_path2)");_===k?v[b-1][1]+=c.charAt(c.length-w-1):v[b++]=[k,c.charAt(c.length-w-1)],_=k}return v},m.prototype.diff_commonPrefix=function(h,c){if(!h||!c||h.charAt(0)!=c.charAt(0))return 0;for(var d=0,v=Math.min(h.length,c.length),b=v,w=0;dc.length?h:c,v=h.length>c.length?c:h;if(d.length<10||v.length<1)return null;var b=this;function w(ie,ne,he){for(var re=ie.substring(he,he+Math.floor(ie.length/4)),J=-1,ye="",Fe,Ke,Me,qe;(J=ne.indexOf(re,J+1))!=-1;){var De=b.diff_commonPrefix(ie.substring(he),ne.substring(J)),Q=b.diff_commonSuffix(ie.substring(0,he),ne.substring(0,J));ye.length=ie.length/2?[Fe,Ke,Me,qe,ye]:null}var A=w(d,v,Math.ceil(d.length/4)),_=w(d,v,Math.ceil(d.length/2)),F;if(!A&&!_)return null;_?A?F=A[4].length>_[4].length?A:_:F=_:F=A;var K,Y,q,Z;h.length>c.length?(K=F[0],Y=F[1],q=F[2],Z=F[3]):(q=F[0],Z=F[1],K=F[2],Y=F[3]);var le=F[4];return[K,Y,q,Z,le]},m.prototype.diff_cleanupSemantic=function(h){for(var c=!1,d=[],v=0,b=null,w=0,A=0,_=0;w0?d[v-1]:-1,A=0,_=0,b=null,c=!0)),w++;c&&this.diff_cleanupMerge(h),this.diff_cleanupSemanticLossless(h)},m.prototype.diff_cleanupSemanticLossless=function(h){var c=/[^a-zA-Z0-9]/,d=/\s/,v=/[\r\n]/,b=/\n\r?\n$/,w=/^\r?\n\r?\n/;function A(J,ye){if(!J||!ye)return 5;var Fe=0;return(J.charAt(J.length-1).match(c)||ye.charAt(0).match(c))&&(Fe++,(J.charAt(J.length-1).match(d)||ye.charAt(0).match(d))&&(Fe++,(J.charAt(J.length-1).match(v)||ye.charAt(0).match(v))&&(Fe++,(J.match(b)||ye.match(w))&&Fe++))),Fe}for(var _=1;_=he&&(he=re,le=F,ie=K,ne=Y)}h[_-1][1]!=le&&(le?h[_-1][1]=le:(h.splice(_-1,1),_--),h[_][1]=ie,ne?h[_+1][1]=ne:(h.splice(_+1,1),_--))}_++}},m.prototype.diff_cleanupEfficiency=function(h){for(var c=!1,d=[],v=0,b="",w=0,A=!1,_=!1,F=!1,K=!1;w0?d[v-1]:-1,F=K=!1),c=!0)),w++;c&&this.diff_cleanupMerge(h)},m.prototype.diff_cleanupMerge=function(h){h.push([k,""]);for(var c=0,d=0,v=0,b="",w="",A;c0&&h[c-d-v-1][0]==k?h[c-d-v-1][1]+=w.substring(0,A):(h.splice(0,0,[k,w.substring(0,A)]),c++),w=w.substring(A),b=b.substring(A)),A=this.diff_commonSuffix(w,b),A!==0&&(h[c][1]=w.substring(w.length-A)+h[c][1],w=w.substring(0,w.length-A),b=b.substring(0,b.length-A))),d===0?h.splice(c-d-v,d+v,[N,w]):v===0?h.splice(c-d-v,d+v,[S,b]):h.splice(c-d-v,d+v,[S,b],[N,w]),c=c-d-v+(d?1:0)+(v?1:0)+1):c!==0&&h[c-1][0]==k?(h[c-1][1]+=h[c][1],h.splice(c,1)):c++,v=0,d=0,b="",w="";break}h[h.length-1][1]===""&&h.pop();var _=!1;for(c=1;cc));A++)b=d,w=v;return h.length!=A&&h[A][0]===S?w:w+(c-b)},m.prototype.diff_prettyHtml=function(h){for(var c=[],d=0,v=0;v/g,">").replace(/\n/g,"¶
");switch(b){case N:c[v]=''+A+"";break;case S:c[v]=''+A+"";break;case k:c[v]=''+A+"";break}b!==S&&(d+=w.length)}return c.join("")},m.prototype.diff_text1=function(h){for(var c=[],d=0;dthis.Match_MaxBits)throw new Error("Pattern too long for this browser.");var v=this.match_alphabet(c),b=this;function w(Fe,Ke){var Me=Fe/c.length,qe=Math.abs(d-Ke);return b.Match_Distance?Me+qe/b.Match_Distance:qe?1:Me}var A=this.Match_Threshold,_=h.indexOf(c,d);_!=-1&&(A=Math.min(w(0,_),A),_=h.lastIndexOf(c,d+c.length),_!=-1&&(A=Math.min(w(0,_),A)));var F=1<=ie;re--){var J=v[h.charAt(re-1)];if(le===0?he[re]=(he[re+1]<<1|1)&J:he[re]=(he[re+1]<<1|1)&J|((Z[re+1]|Z[re])<<1|1)|Z[re+1],he[re]&F){var ye=w(le,re-1);if(ye<=A)if(A=ye,_=re-1,_>d)ie=Math.max(1,2*d-_);else break}}if(w(le+1,d)>A)break;Z=he}return _},m.prototype.match_alphabet=function(h){for(var c={},d=0;d"u")v=h,b=this.diff_main(v,c,!0),b.length>2&&(this.diff_cleanupSemantic(b),this.diff_cleanupEfficiency(b));else if(h&&typeof h=="object"&&typeof c>"u"&&typeof d>"u")b=h,v=this.diff_text1(b);else if(typeof h=="string"&&c&&typeof c=="object"&&typeof d>"u")v=h,b=c;else if(typeof h=="string"&&typeof c=="string"&&d&&typeof d=="object")v=h,b=d;else throw new Error("Unknown call format to patch_make.");if(b.length===0)return[];for(var w=[],A=new z,_=0,F=0,K=0,Y=v,q=v,Z=0;Z=2*this.Patch_Margin&&_&&(this.patch_addContext(A,Y),w.push(A),A=new z,_=0,Y=q,F=K);break}le!==N&&(F+=ie.length),le!==S&&(K+=ie.length)}return _&&(this.patch_addContext(A,Y),w.push(A)),w},m.prototype.patch_deepCopy=function(h){for(var c=[],d=0;dthis.Match_MaxBits?(F=this.match_main(c,_.substring(0,this.Match_MaxBits),A),F!=-1&&(K=this.match_main(c,_.substring(_.length-this.Match_MaxBits),A+_.length-this.Match_MaxBits),(K==-1||F>=K)&&(F=-1))):F=this.match_main(c,_,A),F==-1)b[w]=!1,v-=h[w].length2-h[w].length1;else{b[w]=!0,v=F-A;var Y;if(K==-1?Y=c.substring(F,F+_.length):Y=c.substring(F,K+this.Match_MaxBits),_==Y)c=c.substring(0,F)+this.diff_text2(h[w].diffs)+c.substring(F+_.length);else{var q=this.diff_main(_,Y,!1);if(_.length>this.Match_MaxBits&&this.diff_levenshtein(q)/_.length>this.Patch_DeleteThreshold)b[w]=!1;else{this.diff_cleanupSemanticLossless(q);for(var Z=0,le,ie=0;iew[0][1].length){var A=c-w[0][1].length;w[0][1]=d.substring(w[0][1].length)+w[0][1],b.start1-=A,b.start2-=A,b.length1+=A,b.length2+=A}if(b=h[h.length-1],w=b.diffs,w.length==0||w[w.length-1][0]!=k)w.push([k,d]),b.length1+=c,b.length2+=c;else if(c>w[w.length-1][1].length){var A=c-w[w.length-1][1].length;w[w.length-1][1]+=d.substring(0,A),b.length1+=A,b.length2+=A}return d},m.prototype.patch_splitMax=function(h){for(var c=0;cthis.Match_MaxBits){var d=h[c];h.splice(c--,1);for(var v=this.Match_MaxBits,b=d.start1,w=d.start2,A="";d.diffs.length!==0;){var _=new z,F=!0;for(_.start1=b-A.length,_.start2=w-A.length,A!==""&&(_.length1=_.length2=A.length,_.diffs.push([k,A]));d.diffs.length!==0&&_.length12*v?(_.length1+=Y.length,b+=Y.length,F=!1,_.diffs.push([K,Y]),d.diffs.shift()):(Y=Y.substring(0,v-_.length1-this.Patch_Margin),_.length1+=Y.length,b+=Y.length,K===k?(_.length2+=Y.length,w+=Y.length):F=!1,_.diffs.push([K,Y]),Y==d.diffs[0][1]?d.diffs.shift():d.diffs[0][1]=d.diffs[0][1].substring(Y.length))}A=this.diff_text2(_.diffs),A=A.substring(A.length-this.Patch_Margin);var q=this.diff_text1(d.diffs).substring(0,this.Patch_Margin);q!==""&&(_.length1+=q.length,_.length2+=q.length,_.diffs.length!==0&&_.diffs[_.diffs.length-1][0]===k?_.diffs[_.diffs.length-1][1]+=q:_.diffs.push([k,q])),F||h.splice(++c,0,_)}}},m.prototype.patch_toText=function(h){for(var c=[],d=0;d0&&t.prevInput=="​"?Re(i,Vo)(i):W++<10?r.detectingSelectAll=setTimeout(B,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(B,200)}}if(d&&v>=9&&T(),Fe){$r(e);var O=function(){je(window,"mouseup",O),setTimeout(S,20)};te(window,"mouseup",O)}else setTimeout(S,50)},_e.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},_e.prototype.setUneditable=function(){},_e.prototype.needsContentAttribute=!1;function hf(e,t){if(t=t?dt(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),t.autofocus==null){var i=tt(Pe(e));t.autofocus=i==e||e.getAttribute("autofocus")!=null&&i==document.body}function r(){e.value=a.getValue()}var n;if(e.form&&(te(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var l=e.form;n=l.submit;try{var o=l.submit=function(){r(),l.submit=n,l.submit(),l.submit=o}}catch{}}t.finishInit=function(s){s.save=r,s.getTextArea=function(){return e},s.toTextArea=function(){s.toTextArea=isNaN,r(),e.parentNode.removeChild(s.getWrapperElement()),e.style.display="",e.form&&(je(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=n))}},e.style.display="none";var a=Le(function(s){return e.parentNode.insertBefore(s,e.nextSibling)},t);return a}function cf(e){e.off=je,e.on=te,e.wheelEventPixels=mu,e.Doc=it,e.splitLines=bn,e.countColumn=Ze,e.findColumn=Gr,e.isWordChar=I,e.Pass=Ht,e.signal=Te,e.Line=Cr,e.changeEnd=Gt,e.scrollbarModel=_o,e.Pos=P,e.cmpPos=ae,e.modes=Cn,e.mimeModes=br,e.resolveMode=Di,e.getMode=Sn,e.modeExtensions=wr,e.extendMode=ds,e.copyState=jt,e.startState=Wl,e.innerMode=Ln,e.commands=pi,e.keyMap=Et,e.keyName=pa,e.isModifierKey=da,e.lookupKey=Wr,e.normalizeKeyMap=Ru,e.StringStream=Ee,e.SharedTextMarker=ci,e.TextMarker=$t,e.LineWidget=hi,e.e_preventDefault=Oe,e.e_stopPropagation=Ol,e.e_stop=$r,e.addClass=xt,e.contains=ct,e.rmClass=Me,e.keyNames=Xt}rf(Le),af(Le);var df="iter insert remove copy getEditor constructor".split(" ");for(var un in it.prototype)it.prototype.hasOwnProperty(un)&&Se(df,un)<0&&(Le.prototype[un]=function(e){return function(){return e.apply(this.doc,arguments)}}(it.prototype[un]));return Mt(it),Le.inputStyles={textarea:_e,contenteditable:ve},Le.defineMode=function(e){!Le.defaults.mode&&e!="null"&&(Le.defaults.mode=e),hs.apply(this,arguments)},Le.defineMIME=cs,Le.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Le.defineMIME("text/plain","null"),Le.defineExtension=function(e,t){Le.prototype[e]=t},Le.defineDocExtension=function(e,t){it.prototype[e]=t},Le.fromTextArea=hf,cf(Le),Le.version="5.65.16",Le})}(Cl)),Cl.exports}var mf=Za();const bf=yf(mf);var Fa={exports:{}},Ha;function wf(){return Ha||(Ha=1,function(E,m){(function(C){C(Za())})(function(C){var N=C.Pos,k="http://www.w3.org/2000/svg";function z(f,y){this.mv=f,this.type=y,this.classes=y=="left"?{chunk:"CodeMirror-merge-l-chunk",start:"CodeMirror-merge-l-chunk-start",end:"CodeMirror-merge-l-chunk-end",insert:"CodeMirror-merge-l-inserted",del:"CodeMirror-merge-l-deleted",connect:"CodeMirror-merge-l-connect"}:{chunk:"CodeMirror-merge-r-chunk",start:"CodeMirror-merge-r-chunk-start",end:"CodeMirror-merge-r-chunk-end",insert:"CodeMirror-merge-r-inserted",del:"CodeMirror-merge-r-deleted",connect:"CodeMirror-merge-r-connect"}}z.prototype={constructor:z,init:function(f,y,L){this.edit=this.mv.edit,(this.edit.state.diffViews||(this.edit.state.diffViews=[])).push(this),this.orig=C(f,dt({value:y,readOnly:!this.mv.options.allowEditingOriginals},dt(L))),this.mv.options.connect=="align"&&(this.edit.state.trackAlignable||(this.edit.state.trackAlignable=new Ht(this.edit)),this.orig.state.trackAlignable=new Ht(this.orig)),this.lockButton.title=this.edit.phrase("Toggle locked scrolling"),this.lockButton.setAttribute("aria-label",this.lockButton.title),this.orig.state.diffViews=[this];var x=L.chunkClassLocation||"background";Object.prototype.toString.call(x)!="[object Array]"&&(x=[x]),this.classes.classLocation=x,this.diff=kt(De(y),De(L.value),this.mv.options.ignoreWhitespace),this.chunks=bt(this.diff),this.diffOutOfDate=this.dealigned=!1,this.needsScrollSync=null,this.showDifferences=L.showDifferences!==!1},registerEvents:function(f){this.forceUpdate=d(this),A(this,!0,!1),v(this,f)},setShowDifferences:function(f){f=f!==!1,f!=this.showDifferences&&(this.showDifferences=f,this.forceUpdate("full"))}};function h(f){f.diffOutOfDate&&(f.diff=kt(f.orig.getValue(),f.edit.getValue(),f.mv.options.ignoreWhitespace),f.chunks=bt(f.diff),f.diffOutOfDate=!1,C.signal(f.edit,"updateDiff",f.diff))}var c=!1;function d(f){var y={from:0,to:0,marked:[]},L={from:0,to:0,marked:[]},x,M=!1;function D(ue){c=!0,M=!1,ue=="full"&&(f.svg&&At(f.svg),f.copyButtons&&At(f.copyButtons),F(f.edit,y.marked,f.classes),F(f.orig,L.marked,f.classes),y.from=y.to=L.from=L.to=0),h(f),f.showDifferences&&(K(f.edit,f.diff,y,DIFF_INSERT,f.classes),K(f.orig,f.diff,L,DIFF_DELETE,f.classes)),f.mv.options.connect=="align"&&re(f),Z(f),f.needsScrollSync!=null&&b(f,f.needsScrollSync),c=!1}function I(ue){c||(f.dealigned=!0,H(ue))}function H(ue){c||M||(clearTimeout(x),ue===!0&&(M=!0),x=setTimeout(D,ue===!0?20:250))}function R(ue,ce){f.diffOutOfDate||(f.diffOutOfDate=!0,y.from=y.to=L.from=L.to=0),I(ce.text.length-1!=ce.to.line-ce.from.line)}function oe(){f.diffOutOfDate=!0,f.dealigned=!0,D("full")}return f.edit.on("change",R),f.orig.on("change",R),f.edit.on("swapDoc",oe),f.orig.on("swapDoc",oe),f.mv.options.connect=="align"&&(C.on(f.edit.state.trackAlignable,"realign",I),C.on(f.orig.state.trackAlignable,"realign",I)),f.edit.on("viewportChange",function(){H(!1)}),f.orig.on("viewportChange",function(){H(!1)}),D(),D}function v(f,y){f.edit.on("scroll",function(){b(f,!0)&&Z(f)}),f.orig.on("scroll",function(){b(f,!1)&&Z(f),y&&b(y,!0)&&Z(y)})}function b(f,y){if(f.diffOutOfDate)return f.lockScroll&&f.needsScrollSync==null&&(f.needsScrollSync=y),!1;if(f.needsScrollSync=null,!f.lockScroll)return!0;var L,x,M=+new Date;if(y?(L=f.edit,x=f.orig):(L=f.orig,x=f.edit),L.state.scrollSetBy==f&&(L.state.scrollSetAt||0)+250>M)return!1;var D=L.getScrollInfo();if(f.mv.options.connect=="align")Ce=D.top;else{var I=.5*D.clientHeight,H=D.top+I,R=L.lineAtHeight(H,"local"),oe=xt(f.chunks,R,y),ue=w(L,y?oe.edit:oe.orig),ce=w(x,y?oe.orig:oe.edit),me=(H-ue.top)/(ue.bot-ue.top),Ce=ce.top-I+me*(ce.bot-ce.top),be,Ne;if(Ce>D.top&&(Ne=D.top/I)<1)Ce=Ce*Ne+D.top*(1-Ne);else if((be=D.height-D.clientHeight-D.top)be&&(Ne=be/I)<1&&(Ce=Ce*Ne+(ut.height-ut.clientHeight-be)*(1-Ne))}}return x.scrollTo(D.left,Ce),x.state.scrollSetAt=M,x.state.scrollSetBy=f,!0}function w(f,y){var L=y.after;return L==null&&(L=f.lastLine()+1),{top:f.heightAtLine(y.before||0,"local"),bot:f.heightAtLine(L,"local")}}function A(f,y,L){f.lockScroll=y,y&&L!=!1&&b(f,DIFF_INSERT)&&Z(f),(y?C.addClass:C.rmClass)(f.lockButton,"CodeMirror-merge-scrolllock-enabled")}function _(f,y,L){for(var x=L.classLocation,M=0;M20||L.from-D.to>20?(F(f,L.marked,M),q(f,y,x,L.marked,D.from,D.to,M),L.from=D.from,L.to=D.to):(D.fromL.to&&(q(f,y,x,L.marked,L.to,D.to,M),L.to=D.to))})}function Y(f,y,L,x,M,D){for(var I=L.classLocation,H=f.getLineHandle(y),R=0;RKr&&(Ce&&(ce(me,Kr),Ce=!1),me=te)}else if(Ce=!0,ut==L){var mr=Ze(H,ge,!0),je=Ur(R,H),Te=ht(oe,mr);Jt(je,Te)||x.push(f.markText(je,Te,{className:ue})),H=mr}}Ce&&ce(me,H.line+1)}function Z(f){if(f.showDifferences){if(f.svg){At(f.svg);var y=f.gap.offsetWidth;pr(f.svg,"width",y,"height",f.gap.offsetHeight)}f.copyButtons&&At(f.copyButtons);for(var L=f.edit.getViewport(),x=f.orig.getViewport(),M=f.mv.wrap.getBoundingClientRect().top,D=M-f.edit.getScrollerElement().getBoundingClientRect().top+f.edit.getScrollInfo().top,I=M-f.orig.getScrollerElement().getBoundingClientRect().top+f.orig.getScrollInfo().top,H=0;H=L.from&&R.origFrom<=x.to&&R.origTo>=x.from&&Fe(f,R,I,D,y)}}}function le(f,y){for(var L=0,x=0,M=0;Mf&&D.editFrom<=f)return null;if(D.editFrom>f)break;L=D.editTo,x=D.origTo}return x+(f-L)}function ie(f,y,L){for(var x=f.state.trackAlignable,M=f.firstLine(),D=0,I=[],H=0;;H++){for(var R=y[H],oe=R?L?R.origFrom:R.editFrom:1e9;Dce){D++,M--;continue e}if(me.editTo>ue){if(me.editFrom<=ue)continue e;break}H+=me.origTo-me.origFrom-(me.editTo-me.editFrom),I++}if(ue==ce-H)R[x]=ce,D++;else if(ue1&&x.push(ye(f[I],L[I],R))}}function ye(f,y,L){var x=!0;y>f.lastLine()&&(y--,x=!1);var M=document.createElement("div");return M.className="CodeMirror-merge-spacer",M.style.height=L+"px",M.style.minWidth="1px",f.addLineWidget(y,M,{height:L,above:x,mergeSpacer:!0,handleMouseEvents:!0})}function Fe(f,y,L,x,M){var D=f.type=="left",I=f.orig.heightAtLine(y.origFrom,"local",!0)-L;if(f.svg){var H=I,R=f.edit.heightAtLine(y.editFrom,"local",!0)-x;if(D){var oe=H;H=R,R=oe}var ue=f.orig.heightAtLine(y.origTo,"local",!0)-L,ce=f.edit.heightAtLine(y.editTo,"local",!0)-x;if(D){var oe=ue;ue=ce,ce=oe}var me=" C "+M/2+" "+R+" "+M/2+" "+H+" "+(M+2)+" "+H,Ce=" C "+M/2+" "+ue+" "+M/2+" "+ce+" -1 "+ce;pr(f.svg.appendChild(document.createElementNS(k,"path")),"d","M -1 "+R+me+" L "+(M+2)+" "+ue+Ce+" z","class",f.classes.connect)}if(f.copyButtons){var be=f.copyButtons.appendChild(Pe("div",f.type=="left"?"⇝":"⇜","CodeMirror-merge-copy")),Ne=f.mv.options.allowEditingOriginals;if(be.title=f.edit.phrase(Ne?"Push to left":"Revert chunk"),be.chunk=y,be.style.top=(y.origTo>y.origFrom?I:f.edit.heightAtLine(y.editFrom,"local")-x)+"px",be.setAttribute("role","button"),be.setAttribute("tabindex","0"),be.setAttribute("aria-label",be.title),Ne){var ut=f.edit.heightAtLine(y.editFrom,"local")-x,ge=f.copyButtons.appendChild(Pe("div",f.type=="right"?"⇝":"⇜","CodeMirror-merge-copy-reverse"));ge.title="Push to right",ge.chunk={editFrom:y.origFrom,editTo:y.origTo,origFrom:y.editFrom,origTo:y.editTo},ge.style.top=ut+"px",f.type=="right"?ge.style.left="2px":ge.style.right="2px",ge.setAttribute("role","button"),ge.setAttribute("tabindex","0"),ge.setAttribute("aria-label",ge.title)}}}function Ke(f,y,L,x){if(!f.diffOutOfDate){var M=x.origTo>L.lastLine()?N(x.origFrom-1):N(x.origFrom,0),D=N(x.origTo,0),I=x.editTo>y.lastLine()?N(x.editFrom-1):N(x.editFrom,0),H=N(x.editTo,0),R=f.mv.options.revertChunk;R?R(f.mv,L,M,D,y,I,H):y.replaceRange(L.getRange(M,D),I,H)}}var Me=C.MergeView=function(f,y){if(!(this instanceof Me))return new Me(f,y);this.options=y;var L=y.origLeft,x=y.origRight==null?y.orig:y.origRight,M=L!=null,D=x!=null,I=1+(M?1:0)+(D?1:0),H=[],R=this.left=null,oe=this.right=null,ue=this;if(M){R=this.left=new z(this,"left");var ce=Pe("div",null,"CodeMirror-merge-pane CodeMirror-merge-left");H.push(ce),H.push(qe(R))}var me=Pe("div",null,"CodeMirror-merge-pane CodeMirror-merge-editor");if(H.push(me),D){oe=this.right=new z(this,"right"),H.push(qe(oe));var Ce=Pe("div",null,"CodeMirror-merge-pane CodeMirror-merge-right");H.push(Ce)}(D?Ce:me).className+=" CodeMirror-merge-pane-rightmost",H.push(Pe("div",null,null,"height: 0; clear: both;"));var be=this.wrap=f.appendChild(Pe("div",H,"CodeMirror-merge CodeMirror-merge-"+I+"pane"));this.edit=C(me,dt(y)),R&&R.init(ce,L,y),oe&&oe.init(Ce,x,y),y.collapseIdentical&&this.editor().operation(function(){Ft(ue,y.collapseIdentical)}),y.connect=="align"&&(this.aligners=[],re(this.left||this.right,!0)),R&&R.registerEvents(oe),oe&&oe.registerEvents(R);var Ne=function(){R&&Z(R),oe&&Z(oe)};C.on(window,"resize",Ne);var ut=setInterval(function(){for(var ge=be.parentNode;ge&&ge!=document.body;ge=ge.parentNode);ge||(clearInterval(ut),C.off(window,"resize",Ne))},5e3)};function qe(f){var y=f.lockButton=Pe("div",null,"CodeMirror-merge-scrolllock");y.setAttribute("role","button"),y.setAttribute("tabindex","0");var L=Pe("div",[y],"CodeMirror-merge-scrolllock-wrap");C.on(y,"click",function(){A(f,!f.lockScroll)}),C.on(y,"keyup",function(I){(I.key==="Enter"||I.code==="Space")&&A(f,!f.lockScroll)});var x=[L];if(f.mv.options.revertButtons!==!1){f.copyButtons=Pe("div",null,"CodeMirror-merge-copybuttons-"+f.type);var M=function(I){var H=I.target||I.srcElement;if(H.chunk){if(H.className=="CodeMirror-merge-copy-reverse"){Ke(f,f.orig,f.edit,H.chunk);return}Ke(f,f.edit,f.orig,H.chunk)}};C.on(f.copyButtons,"click",M),C.on(f.copyButtons,"keyup",function(I){(I.key==="Enter"||I.code==="Space")&&M(I)}),x.unshift(f.copyButtons)}if(f.mv.options.connect!="align"){var D=document.createElementNS&&document.createElementNS(k,"svg");D&&!D.createSVGRect&&(D=null),f.svg=D,D&&x.push(D)}return f.gap=Pe("div",x,"CodeMirror-merge-gap")}Me.prototype={constructor:Me,editor:function(){return this.edit},rightOriginal:function(){return this.right&&this.right.orig},leftOriginal:function(){return this.left&&this.left.orig},setShowDifferences:function(f){this.right&&this.right.setShowDifferences(f),this.left&&this.left.setShowDifferences(f)},rightChunks:function(){if(this.right)return h(this.right),this.right.chunks},leftChunks:function(){if(this.left)return h(this.left),this.left.chunks}};function De(f){return typeof f=="string"?f:f.getValue()}var Q;function kt(f,y,L){Q||(Q=new diff_match_patch);for(var x=Q.diff_main(f,y),M=0;Mue&&(I&&y.push({origFrom:x,origTo:ce,editFrom:L,editTo:ue}),L=Ce,x=be)}else Ze(R==DIFF_INSERT?M:D,H[1])}return(L<=M.line||x<=D.line)&&y.push({origFrom:x,origTo:D.line+1,editFrom:L,editTo:M.line+1}),y}function ct(f,y){if(y==f.length-1)return!0;var L=f[y+1][1];return L.length==1&&y1||y==f.length-3)&&L.charCodeAt(0)==10)}function tt(f,y){if(y==0)return!0;var L=f[y-1][1];return L.charCodeAt(L.length-1)!=10?!1:y==1?!0:(L=f[y-2][1],L.charCodeAt(L.length-1)==10)}function xt(f,y,L){for(var x,M,D,I,H=0;Hy?(M=R.editFrom,I=R.origFrom):ue>y&&(M=R.editTo,I=R.origTo)),ue<=y?(x=R.editTo,D=R.origTo):oe<=y&&(x=R.editFrom,D=R.origFrom)}return{edit:{before:x,after:M},orig:{before:D,after:I}}}function zr(f,y,L){f.addLineClass(y,"wrap","CodeMirror-merge-collapsed-line");var x=document.createElement("span");x.className="CodeMirror-merge-collapsed-widget",x.title=f.phrase("Identical text collapsed. Click to expand.");var M=f.markText(N(y,0),N(L-1),{inclusiveLeft:!0,inclusiveRight:!0,replacedWith:x,clearOnEnter:!0});function D(){M.clear(),f.removeLineClass(y,"wrap","CodeMirror-merge-collapsed-line")}return M.explicitlyCleared&&D(),C.on(x,"click",D),M.on("clear",D),C.on(x,"click",D),{mark:M,clear:D}}function Zt(f,y){var L=[];function x(){for(var H=0;H=0&&Hy){var ue=[{line:R,cm:x}];f.left&&ue.push({line:le(R,f.left.chunks),cm:f.left.orig}),f.right&&ue.push({line:le(R,f.right.chunks),cm:f.right.orig});var ce=Zt(oe,ue);f.options.onCollapse&&f.options.onCollapse(f,R,oe,ce)}}}function Pe(f,y,L,x){var M=document.createElement(f);if(L&&(M.className=L),x&&(M.style.cssText=x),typeof y=="string")M.appendChild(document.createTextNode(y));else if(y)for(var D=0;D0;--y)f.removeChild(f.firstChild)}function pr(f){for(var y=1;y0)break}this.signal(),this.alignable.splice(L,0,f,y)},find:function(f){for(var y=0;y-1){var oe=this.alignable[D+1];oe==Se?this.alignable.splice(D,2):this.alignable[D+1]=oe&~Se}I>-1&&L&&this.set(f+L,Se)}};function ht(f,y){return(f.line-y.line||f.ch-y.ch)<0?f:y}function Ur(f,y){return(f.line-y.line||f.ch-y.ch)>0?f:y}function Jt(f,y){return f.line==y.line&&f.ch==y.ch}function Gr(f,y,L){for(var x=f.length-1;x>=0;x--){var M=f[x],D=(L?M.origTo:M.editTo)-1;if(Dy)return D}}function yr(f,y){var L=null,x=f.state.diffViews,M=f.getCursor().line;if(x)for(var D=0;DL:R"u"&&(d=!0);var v=d,b=this.diff_commonPrefix(h,c),w=h.substring(0,b);h=h.substring(b),c=c.substring(b),b=this.diff_commonSuffix(h,c);var A=h.substring(h.length-b);h=h.substring(0,h.length-b),c=c.substring(0,c.length-b);var _=this.diff_compute(h,c,v);return w&&_.unshift([k,w]),A&&_.push([k,A]),this.diff_cleanupMerge(_),_},m.prototype.diff_compute=function(h,c,d){var v;if(!h)return[[N,c]];if(!c)return[[C,h]];var b=h.length>c.length?h:c,w=h.length>c.length?c:h,A=b.indexOf(w);if(A!=-1)return v=[[N,b.substring(0,A)],[k,w],[N,b.substring(A+w.length)]],h.length>c.length&&(v[0][0]=v[2][0]=C),v;b=w=null;var _=this.diff_halfMatch(h,c);if(_){var F=_[0],K=_[1],Y=_[2],q=_[3],Z=_[4],le=this.diff_main(F,Y,d),ie=this.diff_main(K,q,d);return le.concat([[k,Z]],ie)}d&&(h.length<100||c.length<100)&&(d=!1);var ne;if(d){var he=this.diff_linesToChars(h,c);h=he[0],c=he[1],ne=he[2]}if(v=this.diff_map(h,c),v||(v=[[C,h],[N,c]]),d){this.diff_charsToLines(v,ne),this.diff_cleanupSemantic(v),v.push([k,""]);for(var re=0,J=0,ye=0,Fe="",Ke="";re=1&&ye>=1){var he=this.diff_main(Fe,Ke,!1);v.splice(re-J-ye,J+ye),re=re-J-ye;for(var Me=he.length-1;Me>=0;Me--)v.splice(re,0,he[Me]);re=re+he.length}ye=0,J=0,Fe="",Ke="";break}re++}v.pop()}return v},m.prototype.diff_linesToChars=function(h,c){var d=[],v={};d[0]="";function b(_){for(var F="",K=0,Y=-1,q=d.length;Y<_.length-1;){Y=_.indexOf(` +`,K),Y==-1&&(Y=_.length-1);var Z=_.substring(K,Y+1);K=Y+1,(v.hasOwnProperty?v.hasOwnProperty(Z):v[Z]!==void 0)?F+=String.fromCharCode(v[Z]):(F+=String.fromCharCode(q),v[Z]=q,d[q++]=Z)}return F}var w=b(h),A=b(c);return[w,A,d]},m.prototype.diff_charsToLines=function(h,c){for(var d=0;d0&&new Date().getTime()>d)return null;_[re]={};for(var J=-re;J<=re;J+=2){for(J==-re||J!=re&&K[J-1]=0;_--)for(;;)if(h[_][b-1+","+w]!==void 0){b--,A===C?v[0][1]=c.charAt(b)+v[0][1]:v.unshift([C,c.charAt(b)]),A=C;break}else if(h[_][b+","+(w-1)]!==void 0){w--,A===N?v[0][1]=d.charAt(w)+v[0][1]:v.unshift([N,d.charAt(w)]),A=N;break}else{if(b--,w--,c.charAt(b)!=d.charAt(w))throw new Error("No diagonal. Can't happen. (diff_path1)");A===k?v[0][1]=c.charAt(b)+v[0][1]:v.unshift([k,c.charAt(b)]),A=k}return v},m.prototype.diff_path2=function(h,c,d){for(var v=[],b=0,w=c.length,A=d.length,_=null,F=h.length-2;F>=0;F--)for(;;)if(h[F][w-1+","+A]!==void 0){w--,_===C?v[b-1][1]+=c.charAt(c.length-w-1):v[b++]=[C,c.charAt(c.length-w-1)],_=C;break}else if(h[F][w+","+(A-1)]!==void 0){A--,_===N?v[b-1][1]+=d.charAt(d.length-A-1):v[b++]=[N,d.charAt(d.length-A-1)],_=N;break}else{if(w--,A--,c.charAt(c.length-w-1)!=d.charAt(d.length-A-1))throw new Error("No diagonal. Can't happen. (diff_path2)");_===k?v[b-1][1]+=c.charAt(c.length-w-1):v[b++]=[k,c.charAt(c.length-w-1)],_=k}return v},m.prototype.diff_commonPrefix=function(h,c){if(!h||!c||h.charAt(0)!=c.charAt(0))return 0;for(var d=0,v=Math.min(h.length,c.length),b=v,w=0;dc.length?h:c,v=h.length>c.length?c:h;if(d.length<10||v.length<1)return null;var b=this;function w(ie,ne,he){for(var re=ie.substring(he,he+Math.floor(ie.length/4)),J=-1,ye="",Fe,Ke,Me,qe;(J=ne.indexOf(re,J+1))!=-1;){var De=b.diff_commonPrefix(ie.substring(he),ne.substring(J)),Q=b.diff_commonSuffix(ie.substring(0,he),ne.substring(0,J));ye.length=ie.length/2?[Fe,Ke,Me,qe,ye]:null}var A=w(d,v,Math.ceil(d.length/4)),_=w(d,v,Math.ceil(d.length/2)),F;if(!A&&!_)return null;_?A?F=A[4].length>_[4].length?A:_:F=_:F=A;var K,Y,q,Z;h.length>c.length?(K=F[0],Y=F[1],q=F[2],Z=F[3]):(q=F[0],Z=F[1],K=F[2],Y=F[3]);var le=F[4];return[K,Y,q,Z,le]},m.prototype.diff_cleanupSemantic=function(h){for(var c=!1,d=[],v=0,b=null,w=0,A=0,_=0;w0?d[v-1]:-1,A=0,_=0,b=null,c=!0)),w++;c&&this.diff_cleanupMerge(h),this.diff_cleanupSemanticLossless(h)},m.prototype.diff_cleanupSemanticLossless=function(h){var c=/[^a-zA-Z0-9]/,d=/\s/,v=/[\r\n]/,b=/\n\r?\n$/,w=/^\r?\n\r?\n/;function A(J,ye){if(!J||!ye)return 5;var Fe=0;return(J.charAt(J.length-1).match(c)||ye.charAt(0).match(c))&&(Fe++,(J.charAt(J.length-1).match(d)||ye.charAt(0).match(d))&&(Fe++,(J.charAt(J.length-1).match(v)||ye.charAt(0).match(v))&&(Fe++,(J.match(b)||ye.match(w))&&Fe++))),Fe}for(var _=1;_=he&&(he=re,le=F,ie=K,ne=Y)}h[_-1][1]!=le&&(le?h[_-1][1]=le:(h.splice(_-1,1),_--),h[_][1]=ie,ne?h[_+1][1]=ne:(h.splice(_+1,1),_--))}_++}},m.prototype.diff_cleanupEfficiency=function(h){for(var c=!1,d=[],v=0,b="",w=0,A=!1,_=!1,F=!1,K=!1;w0?d[v-1]:-1,F=K=!1),c=!0)),w++;c&&this.diff_cleanupMerge(h)},m.prototype.diff_cleanupMerge=function(h){h.push([k,""]);for(var c=0,d=0,v=0,b="",w="",A;c0&&h[c-d-v-1][0]==k?h[c-d-v-1][1]+=w.substring(0,A):(h.splice(0,0,[k,w.substring(0,A)]),c++),w=w.substring(A),b=b.substring(A)),A=this.diff_commonSuffix(w,b),A!==0&&(h[c][1]=w.substring(w.length-A)+h[c][1],w=w.substring(0,w.length-A),b=b.substring(0,b.length-A))),d===0?h.splice(c-d-v,d+v,[N,w]):v===0?h.splice(c-d-v,d+v,[C,b]):h.splice(c-d-v,d+v,[C,b],[N,w]),c=c-d-v+(d?1:0)+(v?1:0)+1):c!==0&&h[c-1][0]==k?(h[c-1][1]+=h[c][1],h.splice(c,1)):c++,v=0,d=0,b="",w="";break}h[h.length-1][1]===""&&h.pop();var _=!1;for(c=1;cc));A++)b=d,w=v;return h.length!=A&&h[A][0]===C?w:w+(c-b)},m.prototype.diff_prettyHtml=function(h){for(var c=[],d=0,v=0;v/g,">").replace(/\n/g,"¶
");switch(b){case N:c[v]=''+A+"";break;case C:c[v]=''+A+"";break;case k:c[v]=''+A+"";break}b!==C&&(d+=w.length)}return c.join("")},m.prototype.diff_text1=function(h){for(var c=[],d=0;dthis.Match_MaxBits)throw new Error("Pattern too long for this browser.");var v=this.match_alphabet(c),b=this;function w(Fe,Ke){var Me=Fe/c.length,qe=Math.abs(d-Ke);return b.Match_Distance?Me+qe/b.Match_Distance:qe?1:Me}var A=this.Match_Threshold,_=h.indexOf(c,d);_!=-1&&(A=Math.min(w(0,_),A),_=h.lastIndexOf(c,d+c.length),_!=-1&&(A=Math.min(w(0,_),A)));var F=1<=ie;re--){var J=v[h.charAt(re-1)];if(le===0?he[re]=(he[re+1]<<1|1)&J:he[re]=(he[re+1]<<1|1)&J|((Z[re+1]|Z[re])<<1|1)|Z[re+1],he[re]&F){var ye=w(le,re-1);if(ye<=A)if(A=ye,_=re-1,_>d)ie=Math.max(1,2*d-_);else break}}if(w(le+1,d)>A)break;Z=he}return _},m.prototype.match_alphabet=function(h){for(var c={},d=0;d"u")v=h,b=this.diff_main(v,c,!0),b.length>2&&(this.diff_cleanupSemantic(b),this.diff_cleanupEfficiency(b));else if(h&&typeof h=="object"&&typeof c>"u"&&typeof d>"u")b=h,v=this.diff_text1(b);else if(typeof h=="string"&&c&&typeof c=="object"&&typeof d>"u")v=h,b=c;else if(typeof h=="string"&&typeof c=="string"&&d&&typeof d=="object")v=h,b=d;else throw new Error("Unknown call format to patch_make.");if(b.length===0)return[];for(var w=[],A=new z,_=0,F=0,K=0,Y=v,q=v,Z=0;Z=2*this.Patch_Margin&&_&&(this.patch_addContext(A,Y),w.push(A),A=new z,_=0,Y=q,F=K);break}le!==N&&(F+=ie.length),le!==C&&(K+=ie.length)}return _&&(this.patch_addContext(A,Y),w.push(A)),w},m.prototype.patch_deepCopy=function(h){for(var c=[],d=0;dthis.Match_MaxBits?(F=this.match_main(c,_.substring(0,this.Match_MaxBits),A),F!=-1&&(K=this.match_main(c,_.substring(_.length-this.Match_MaxBits),A+_.length-this.Match_MaxBits),(K==-1||F>=K)&&(F=-1))):F=this.match_main(c,_,A),F==-1)b[w]=!1,v-=h[w].length2-h[w].length1;else{b[w]=!0,v=F-A;var Y;if(K==-1?Y=c.substring(F,F+_.length):Y=c.substring(F,K+this.Match_MaxBits),_==Y)c=c.substring(0,F)+this.diff_text2(h[w].diffs)+c.substring(F+_.length);else{var q=this.diff_main(_,Y,!1);if(_.length>this.Match_MaxBits&&this.diff_levenshtein(q)/_.length>this.Patch_DeleteThreshold)b[w]=!1;else{this.diff_cleanupSemanticLossless(q);for(var Z=0,le,ie=0;iew[0][1].length){var A=c-w[0][1].length;w[0][1]=d.substring(w[0][1].length)+w[0][1],b.start1-=A,b.start2-=A,b.length1+=A,b.length2+=A}if(b=h[h.length-1],w=b.diffs,w.length==0||w[w.length-1][0]!=k)w.push([k,d]),b.length1+=c,b.length2+=c;else if(c>w[w.length-1][1].length){var A=c-w[w.length-1][1].length;w[w.length-1][1]+=d.substring(0,A),b.length1+=A,b.length2+=A}return d},m.prototype.patch_splitMax=function(h){for(var c=0;cthis.Match_MaxBits){var d=h[c];h.splice(c--,1);for(var v=this.Match_MaxBits,b=d.start1,w=d.start2,A="";d.diffs.length!==0;){var _=new z,F=!0;for(_.start1=b-A.length,_.start2=w-A.length,A!==""&&(_.length1=_.length2=A.length,_.diffs.push([k,A]));d.diffs.length!==0&&_.length12*v?(_.length1+=Y.length,b+=Y.length,F=!1,_.diffs.push([K,Y]),d.diffs.shift()):(Y=Y.substring(0,v-_.length1-this.Patch_Margin),_.length1+=Y.length,b+=Y.length,K===k?(_.length2+=Y.length,w+=Y.length):F=!1,_.diffs.push([K,Y]),Y==d.diffs[0][1]?d.diffs.shift():d.diffs[0][1]=d.diffs[0][1].substring(Y.length))}A=this.diff_text2(_.diffs),A=A.substring(A.length-this.Patch_Margin);var q=this.diff_text1(d.diffs).substring(0,this.Patch_Margin);q!==""&&(_.length1+=q.length,_.length2+=q.length,_.diffs.length!==0&&_.diffs[_.diffs.length-1][0]===k?_.diffs[_.diffs.length-1][1]+=q:_.diffs.push([k,q])),F||h.splice(++c,0,_)}}},m.prototype.patch_toText=function(h){for(var c=[],d=0;dO}):void 0,Za="$lit$",qt=`lit$${(Math.random()+"").slice(9)}$`,Qa="?"+qt,Cf=`<${Qa}>`,gr=document,Ti=()=>gr.createComment(""),ki=O=>O===null||typeof O!="object"&&typeof O!="function",Ja=Array.isArray,Sf=O=>Ja(O)||typeof(O==null?void 0:O[Symbol.iterator])=="function",Ll=`[ -\f\r]`,wi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ba=/-->/g,Ra=/>/g,hr=RegExp(`>|${Ll}(?:([^\\s"'>=/]+)(${Ll}*=${Ll}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`,"g"),za=/'/g,Ua=/"/g,ja=/^(?:script|style|textarea|title)$/i,Lf=O=>(m,...S)=>({_$litType$:O,strings:m,values:S}),dr=Lf(1),xi=Symbol.for("lit-noChange"),Ye=Symbol.for("lit-nothing"),Ga=new WeakMap,cr=gr.createTreeWalker(gr,129);function Va(O,m){if(!Array.isArray(O)||!O.hasOwnProperty("raw"))throw Error("invalid template strings array");return Pa!==void 0?Pa.createHTML(m):m}const Tf=(O,m)=>{const S=O.length-1,N=[];let k,z=m===2?"":"",h=wi;for(let c=0;c"?(h=k??wi,w=-1):b[1]===void 0?w=-2:(w=h.lastIndex-b[2].length,v=b[1],h=b[3]===void 0?hr:b[3]==='"'?Ua:za):h===Ua||h===za?h=hr:h===Ba||h===Ra?h=wi:(h=hr,k=void 0);const _=h===hr&&O[c+1].startsWith("/>")?" ":"";z+=h===wi?d+Cf:w>=0?(N.push(v),d.slice(0,w)+Za+d.slice(w)+qt+_):d+qt+(w===-2?c:_)}return[Va(O,z+(O[S]||"")+(m===2?"":"")),N]};class Ai{constructor({strings:m,_$litType$:S},N){let k;this.parts=[];let z=0,h=0;const c=m.length-1,d=this.parts,[v,b]=Tf(m,S);if(this.el=Ai.createElement(v,N),cr.currentNode=this.el.content,S===2){const w=this.el.content.firstChild;w.replaceWith(...w.childNodes)}for(;(k=cr.nextNode())!==null&&d.length0){k.textContent=dn?dn.emptyScript:"";for(let _=0;_2||N[0]!==""||N[1]!==""?(this._$AH=Array(N.length-1).fill(new String),this.strings=N):this._$AH=Ye}_$AI(m,S=this,N,k){const z=this.strings;let h=!1;if(z===void 0)m=Rr(this,m,S,0),h=!ki(m)||m!==this._$AH&&m!==xi,h&&(this._$AH=m);else{const c=m;let d,v;for(m=z[0],d=0;d{const N=(S==null?void 0:S.renderBefore)??m;let k=N._$litPart$;if(k===void 0){const z=(S==null?void 0:S.renderBefore)??null;N._$litPart$=k=new _i(m.insertBefore(Ti(),z),z,void 0,S??{})}return k._$AI(O),k};function Df(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function Al(O,m=!1){const S=Df(),N=`_${S}`;return Object.defineProperty(window,N,{value:k=>(m&&Reflect.deleteProperty(window,N),O==null?void 0:O(k)),writable:!1,configurable:!0}),S}async function es(O,m={}){return new Promise((S,N)=>{const k=Al(h=>{S(h),Reflect.deleteProperty(window,`_${z}`)},!0),z=Al(h=>{N(h),Reflect.deleteProperty(window,`_${k}`)},!0);window.__TAURI_IPC__({cmd:O,callback:k,error:z,...m})})}async function Ml(O){return es("tauri",O)}async function Nf(O=0){return Ml({__tauriModule:"Process",message:{cmd:"exit",exitCode:O}})}function kl(O){return O.type=="Text"?O.value:null}const _l="__TAURI__"in globalThis;async function ts(O,m,S){if(_l){let N={};return S!=null&&(N={result:S}),await es(O,N)}else return await rs(O,m,S)}async function rs(O,m,S){let N=null,k={};S!=null&&(N=JSON.stringify(S),k["Content-Type"]="application/json");const z=await fetch(`/api/${O}`,{method:m,body:N,headers:k});if(z.ok)return await z.json();{let h="";throw z.status<500&&(h=`Likely bug in the webapp: got response "${z.status} ${z.statusText}" for "${O}" request. Additional details, if any, follow. `),h+await z.text()}}async function Dl(O){_l?await Nf(O):await rs("exit","POST",O)}async function Of(){await Dl(0)}async function Ka(){await Dl(1)}async function Ef(){await Dl(2)}async function $a(O){return await ts("save","PUT",O)}async function Wf(){const O=await ts("get_merge_data","GET");for(const m in O)O[m]={left:O[m][0],right:O[m][1],edit:O[m][2]};return O}class If{constructor(){fn(this,"merge_views");fn(this,"dom_ids");fn(this,"initial_values");this.merge_views={},this.dom_ids={},this.initial_values={}}values(){const m={};for(const S in this.merge_views)m[S]=this.merge_views[S].editor().getValue();return m}getSingleMergeState(m){const S=this.merge_views[m],N=S.editor();return{input:{left:this.initial_values[m].left,right:this.initial_values[m].right,edit:{type:"Text",value:this.merge_views[m].editor().getValue()}},wrapLines:N.getOption("lineWrapping")??!1,collapseIdentical:!!N.getOption("collapseIdentical"),showRightSide:!!S.rightOriginal(),cursorPosition:N.getCursor()}}createCodeMirrorMergeWidget(m,S,N){const k=N.input,z=document.getElementById(`collapse_${m}`),h=document.getElementById(`linewrap_${m}`),c=document.getElementById(`rightside_${m}`),d=document.getElementById(`prevChange_${m}`),v=document.getElementById(`nextChange_${m}`),b=document.getElementById(`details_${m}`),w=document.getElementById(`cm_${m}`);let A;N.showRightSide&&(A=kl(k.right)??"");const _={value:kl(k.edit)??"",origLeft:kl(k.left)??"",orig:A,lineWrapping:N.wrapLines,collapseIdentical:N.collapseIdentical,lineNumbers:!0,mode:"text/plain",connect:"align"},F=mf.MergeView(w,_);F.editor().setOption("extraKeys",{"Alt-Down":Ci,"Option-Down":Ci,"Cmd-Down":Ci,"Alt-Up":hn,"Option-Up":hn,"Cmd-Up":hn,Tab:Ci}),N.cursorPosition!=null&&(F.editor().setSelection(N.cursorPosition),F.editor().scrollIntoView(null,50)),z.onclick=()=>this.recreateCodeMirrorFlippingOption(S,"collapseIdentical"),h.onclick=()=>this.recreateCodeMirrorFlippingOption(S,"wrapLines"),c.onclick=()=>this.recreateCodeMirrorFlippingOption(S,"showRightSide"),d.onclick=()=>hn(F.editor()),v.onclick=()=>Ci(F.editor()),b.open=!1,b.ontoggle=()=>F.editor().refresh(),console.log(b),this.merge_views[S]=F,this.dom_ids[S]=m,this.initial_values[S]=k}recreateCodeMirrorFlippingOption(m,S){var v;if(this.merge_views[m]==null){console.warn("Trying to toggle line wrapping on a non-existent editor",m,this);return}let k=this.dom_ids[m];const z=`cm_${k}`,h=this.getSingleMergeState(m),c=document.createElement("div");(v=document.getElementById(z))==null||v.replaceWith(c),c.id=z,this.createCodeMirrorMergeWidget(k,m,Pf(h,S));const d=document.getElementById(`details_${k}`);d.open=!0}}function Ff(O,m){let S=[],N=h=>`${h}_${O}`;for(const h in m){const c=Xa(m[h]);c!=null?S.push(dr`
- ${h}: ${c} - -
`):S.push(dr` -
- - - ${h} - - - - - - -
-
- `)}const k=document.getElementById(O);k.innerHTML="",Li(dr`${S}`,k);const z=new If;for(let h in m)Xa(m[h])==null&&z.createCodeMirrorMergeWidget(N(h),h,Hf(m[h]));return z}function Hf(O){return{input:O,wrapLines:!0,collapseIdentical:!0,showRightSide:!0}}function Pf(O,m){let S=Object.assign({},O);return S[m]=!S[m],S}function Xa(O){let m=Array.from([{file:O.left,side:"left"},{file:O.right,side:"right"},{file:O.edit,side:"middle"}]).find(S=>S.file.type=="Unsupported");if(m==null)return null;if(m.file.type!="Unsupported")throw new Error("this statement is unreachable; this check exists to make TS happy");return dr`error: ${m.file.value} (occurred on the - ${m.side} side)`}function Ci(O){O.execCommand("goNextDiff"),O.scrollIntoView(null,50)}function hn(O){O.execCommand("goPrevDiff"),O.scrollIntoView(null,50)}async function Bf(O,m){return Ml({__tauriModule:"Event",message:{cmd:"unlisten",event:O,eventId:m}})}async function Rf(O,m,S){return Ml({__tauriModule:"Event",message:{cmd:"listen",event:O,windowLabel:m,handler:Al(S)}}).then(N=>async()=>Bf(O,N))}var Ya;(function(O){O.WINDOW_RESIZED="tauri://resize",O.WINDOW_MOVED="tauri://move",O.WINDOW_CLOSE_REQUESTED="tauri://close-requested",O.WINDOW_CREATED="tauri://window-created",O.WINDOW_DESTROYED="tauri://destroyed",O.WINDOW_FOCUS="tauri://focus",O.WINDOW_BLUR="tauri://blur",O.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",O.WINDOW_THEME_CHANGED="tauri://theme-changed",O.WINDOW_FILE_DROP="tauri://file-drop",O.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",O.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",O.MENU="tauri://menu",O.CHECK_UPDATE="tauri://update",O.UPDATE_AVAILABLE="tauri://update-available",O.INSTALL_UPDATE="tauri://update-install",O.STATUS_UPDATE="tauri://update-status",O.DOWNLOAD_PROGRESS="tauri://update-download-progress"})(Ya||(Ya={}));async function cn(O,m){return Rf(O,null,m)}function is(O){console.log("Caught error, showing to user:",O);const m=document.getElementById("modal_dialog_with_message"),S=document.getElementById("message_of_modal_dialog_with_message");Li(`${String(O)}`,S),m.showModal(),console.log("Done showing error to user.")}async function xl(O){try{return await O()}catch(m){is(m)}}window.addEventListener("DOMContentLoaded",async()=>{const O=document.getElementById("loading_message");O.innerHTML="",Li(dr` + */const Si=globalThis,dn=Si.trustedTypes,Ba=dn?dn.createPolicy("lit-html",{createHTML:E=>E}):void 0,Qa="$lit$",qt=`lit$${(Math.random()+"").slice(9)}$`,Ja="?"+qt,Sf=`<${Ja}>`,gr=document,Ti=()=>gr.createComment(""),ki=E=>E===null||typeof E!="object"&&typeof E!="function",ja=Array.isArray,Lf=E=>ja(E)||typeof(E==null?void 0:E[Symbol.iterator])=="function",Ll=`[ +\f\r]`,wi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ra=/-->/g,za=/>/g,hr=RegExp(`>|${Ll}(?:([^\\s"'>=/]+)(${Ll}*=${Ll}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`,"g"),Ua=/'/g,Ga=/"/g,Va=/^(?:script|style|textarea|title)$/i,Tf=E=>(m,...C)=>({_$litType$:E,strings:m,values:C}),dr=Tf(1),xi=Symbol.for("lit-noChange"),Ye=Symbol.for("lit-nothing"),Ka=new WeakMap,cr=gr.createTreeWalker(gr,129);function es(E,m){if(!Array.isArray(E)||!E.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ba!==void 0?Ba.createHTML(m):m}const kf=(E,m)=>{const C=E.length-1,N=[];let k,z=m===2?"":"",h=wi;for(let c=0;c"?(h=k??wi,w=-1):b[1]===void 0?w=-2:(w=h.lastIndex-b[2].length,v=b[1],h=b[3]===void 0?hr:b[3]==='"'?Ga:Ua):h===Ga||h===Ua?h=hr:h===Ra||h===za?h=wi:(h=hr,k=void 0);const _=h===hr&&E[c+1].startsWith("/>")?" ":"";z+=h===wi?d+Sf:w>=0?(N.push(v),d.slice(0,w)+Qa+d.slice(w)+qt+_):d+qt+(w===-2?c:_)}return[es(E,z+(E[C]||"")+(m===2?"":"")),N]};class Ai{constructor({strings:m,_$litType$:C},N){let k;this.parts=[];let z=0,h=0;const c=m.length-1,d=this.parts,[v,b]=kf(m,C);if(this.el=Ai.createElement(v,N),cr.currentNode=this.el.content,C===2){const w=this.el.content.firstChild;w.replaceWith(...w.childNodes)}for(;(k=cr.nextNode())!==null&&d.length0){k.textContent=dn?dn.emptyScript:"";for(let _=0;_2||N[0]!==""||N[1]!==""?(this._$AH=Array(N.length-1).fill(new String),this.strings=N):this._$AH=Ye}_$AI(m,C=this,N,k){const z=this.strings;let h=!1;if(z===void 0)m=Rr(this,m,C,0),h=!ki(m)||m!==this._$AH&&m!==xi,h&&(this._$AH=m);else{const c=m;let d,v;for(m=z[0],d=0;d{const N=(C==null?void 0:C.renderBefore)??m;let k=N._$litPart$;if(k===void 0){const z=(C==null?void 0:C.renderBefore)??null;N._$litPart$=k=new _i(m.insertBefore(Ti(),z),z,void 0,C??{})}return k._$AI(E),k};function Nf(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function Al(E,m=!1){const C=Nf(),N=`_${C}`;return Object.defineProperty(window,N,{value:k=>(m&&Reflect.deleteProperty(window,N),E==null?void 0:E(k)),writable:!1,configurable:!0}),C}async function ts(E,m={}){return new Promise((C,N)=>{const k=Al(h=>{C(h),Reflect.deleteProperty(window,`_${z}`)},!0),z=Al(h=>{N(h),Reflect.deleteProperty(window,`_${k}`)},!0);window.__TAURI_IPC__({cmd:E,callback:k,error:z,...m})})}async function Ml(E){return ts("tauri",E)}async function Of(E=0){return Ml({__tauriModule:"Process",message:{cmd:"exit",exitCode:E}})}function kl(E){return E.type=="Text"?E.value:null}const _l="__TAURI__"in globalThis;async function rs(E,m,C){if(_l){let N={};return C!=null&&(N={result:C}),await ts(E,N)}else return await is(E,m,C)}async function is(E,m,C){let N=null,k={};C!=null&&(N=JSON.stringify(C),k["Content-Type"]="application/json");const z=await fetch(`/api/${E}`,{method:m,body:N,headers:k});if(z.ok)return await z.json();{let h="";throw z.status<500&&(h=`Likely bug in the webapp: got response "${z.status} ${z.statusText}" for "${E}" request. Additional details, if any, follow. `),h+await z.text()}}async function Dl(E){_l?await Of(E):await is("exit","POST",E)}async function Ef(){await Dl(0)}async function $a(){await Dl(1)}async function Wf(){await Dl(2)}async function Xa(E){return await rs("save","PUT",E)}async function If(){const E=await rs("get_merge_data","GET");for(const m in E)E[m]={left:E[m][0],right:E[m][1],edit:E[m][2]};return E}class Nl{constructor(){fn(this,"merge_views");fn(this,"dom_ids");fn(this,"initial_values");this.merge_views={},this.dom_ids={},this.initial_values={}}values(){const m={};for(const C in this.merge_views)m[C]=this.merge_views[C].editor().getValue();return m}static renderInDomElement(m,C){let N=[],k=c=>`${c}_${m}`;for(const c in C){const d=Ya(C[c]);d!=null?N.push(dr`
+ ${c}: ${d} + +
`):N.push(dr` +
+ + + ${c} + + + + + + +
+
+ `)}const z=document.getElementById(m);z.innerHTML="",Li(dr`${N}`,z);const h=new Nl;for(let c in C)Ya(C[c])==null&&h.createCodeMirrorMergeWidget(k(c),c,Ff(C[c]));return h}createCodeMirrorMergeWidget(m,C,N){const k=N.input,z=document.getElementById(`collapse_${m}`),h=document.getElementById(`linewrap_${m}`),c=document.getElementById(`rightside_${m}`),d=document.getElementById(`prevChange_${m}`),v=document.getElementById(`nextChange_${m}`),b=document.getElementById(`details_${m}`),w=document.getElementById(`cm_${m}`);let A;N.showRightSide&&(A=kl(k.right)??"");const _={value:kl(k.edit)??"",origLeft:kl(k.left)??"",orig:A,lineWrapping:N.wrapLines,collapseIdentical:N.collapseIdentical,lineNumbers:!0,mode:"text/plain",connect:"align"},F=bf.MergeView(w,_);F.editor().setOption("extraKeys",{"Alt-Down":Ci,"Option-Down":Ci,"Cmd-Down":Ci,"Alt-Up":hn,"Option-Up":hn,"Cmd-Up":hn,Tab:Ci}),N.cursorPosition!=null&&(F.editor().setSelection(N.cursorPosition),F.editor().scrollIntoView(null,50)),z.onclick=()=>this.recreateCodeMirrorFlippingOption(C,"collapseIdentical"),h.onclick=()=>this.recreateCodeMirrorFlippingOption(C,"wrapLines"),c.onclick=()=>this.recreateCodeMirrorFlippingOption(C,"showRightSide"),d.onclick=()=>hn(F.editor()),v.onclick=()=>Ci(F.editor()),b.open=!1,b.ontoggle=()=>F.editor().refresh(),console.log(b),this.merge_views[C]=F,this.dom_ids[C]=m,this.initial_values[C]=k}getSingleMergeState(m){const C=this.merge_views[m],N=C.editor();return{input:{left:this.initial_values[m].left,right:this.initial_values[m].right,edit:{type:"Text",value:this.merge_views[m].editor().getValue()}},wrapLines:N.getOption("lineWrapping")??!1,collapseIdentical:!!N.getOption("collapseIdentical"),showRightSide:!!C.rightOriginal(),cursorPosition:N.getCursor()}}recreateCodeMirrorFlippingOption(m,C){var v;if(this.merge_views[m]==null){console.warn("Trying to toggle line wrapping on a non-existent editor",m,this);return}let k=this.dom_ids[m];const z=`cm_${k}`,h=this.getSingleMergeState(m),c=document.createElement("div");(v=document.getElementById(z))==null||v.replaceWith(c),c.id=z,this.createCodeMirrorMergeWidget(k,m,Hf(h,C));const d=document.getElementById(`details_${k}`);d.open=!0}}function Ff(E){return{input:E,wrapLines:!0,collapseIdentical:!0,showRightSide:!0}}function Hf(E,m){let C=Object.assign({},E);return C[m]=!C[m],C}function Ya(E){let m=Array.from([{file:E.left,side:"left"},{file:E.right,side:"right"},{file:E.edit,side:"middle"}]).find(C=>C.file.type=="Unsupported");if(m==null)return null;if(m.file.type!="Unsupported")throw new Error("this statement is unreachable; this check exists to make TS happy");return dr`error: ${m.file.value} (occurred on the + ${m.side} side)`}function Ci(E){E.execCommand("goNextDiff"),E.scrollIntoView(null,50)}function hn(E){E.execCommand("goPrevDiff"),E.scrollIntoView(null,50)}async function Pf(E,m){return Ml({__tauriModule:"Event",message:{cmd:"unlisten",event:E,eventId:m}})}async function Bf(E,m,C){return Ml({__tauriModule:"Event",message:{cmd:"listen",event:E,windowLabel:m,handler:Al(C)}}).then(N=>async()=>Pf(E,N))}var qa;(function(E){E.WINDOW_RESIZED="tauri://resize",E.WINDOW_MOVED="tauri://move",E.WINDOW_CLOSE_REQUESTED="tauri://close-requested",E.WINDOW_CREATED="tauri://window-created",E.WINDOW_DESTROYED="tauri://destroyed",E.WINDOW_FOCUS="tauri://focus",E.WINDOW_BLUR="tauri://blur",E.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",E.WINDOW_THEME_CHANGED="tauri://theme-changed",E.WINDOW_FILE_DROP="tauri://file-drop",E.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",E.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",E.MENU="tauri://menu",E.CHECK_UPDATE="tauri://update",E.UPDATE_AVAILABLE="tauri://update-available",E.INSTALL_UPDATE="tauri://update-install",E.STATUS_UPDATE="tauri://update-status",E.DOWNLOAD_PROGRESS="tauri://update-download-progress"})(qa||(qa={}));async function cn(E,m){return Bf(E,null,m)}function ns(E){console.log("Caught error, showing to user:",E);const m=document.getElementById("modal_dialog_with_message"),C=document.getElementById("message_of_modal_dialog_with_message");Li(`${String(E)}`,C),m.showModal(),console.log("Done showing error to user.")}async function xl(E){try{return await E()}catch(m){ns(m)}}window.addEventListener("DOMContentLoaded",async()=>{const E=document.getElementById("loading_message");E.innerHTML="",Li(dr`

Loading...

Getting the data we want to merge...

- `,O);let m;try{m=await Wf()}catch(v){throw is(v),await Ef(),new Error("Internal error: this statement should be unreachable")}Li(dr` + `,E);let m;try{m=await If()}catch(v){throw ns(v),await Wf(),new Error("Internal error: this statement should be unreachable")}Li(dr`

Loading...

Rendering diffs...

- `,O);const S=Ff("lit",m);Li(dr``,O);const N=async()=>await xl(async()=>{await $a(S.values())}),k=document.getElementById("button_save"),z=document.getElementById("button_save_and_quit"),h=async()=>await xl(async()=>{await $a(S.values()),k.disabled=!0,z.disabled=!0,Of(),await new Promise(v=>setTimeout(v,100)),window.close()}),c=async()=>await xl(async()=>{k.disabled=!0,z.disabled=!0,Ka(),await new Promise(v=>setTimeout(v,100)),window.close()}),d=()=>(window.location.reload(),!1);k.onclick=N,z.onclick=h,document.getElementById("button_abandon_changes_and_quit").onclick=c,document.getElementById("button_revert").onclick=d,_l?(await cn("save",async v=>N()),await cn("save_and_quit",async v=>h()),await cn("revert",async v=>d()),await cn("abandon_changes_and_quit",async v=>Ka())):document.addEventListener("keydown",async v=>{const b=v.metaKey||v.ctrlKey;return v.key=="s"&&b?(await N(),v.preventDefault(),!1):!0})}); + `,E);const C=Nl.renderInDomElement("lit",m);Li(dr``,E);const N=async()=>await xl(async()=>{await Xa(C.values())}),k=document.getElementById("button_save"),z=document.getElementById("button_save_and_quit"),h=async()=>await xl(async()=>{await Xa(C.values()),k.disabled=!0,z.disabled=!0,Ef(),await new Promise(v=>setTimeout(v,100)),window.close()}),c=async()=>await xl(async()=>{k.disabled=!0,z.disabled=!0,$a(),await new Promise(v=>setTimeout(v,100)),window.close()}),d=()=>(window.location.reload(),!1);k.onclick=N,z.onclick=h,document.getElementById("button_abandon_changes_and_quit").onclick=c,document.getElementById("button_revert").onclick=d,_l?(await cn("save",async v=>N()),await cn("save_and_quit",async v=>h()),await cn("revert",async v=>d()),await cn("abandon_changes_and_quit",async v=>$a())):document.addEventListener("keydown",async v=>{const b=v.metaKey||v.ctrlKey;return v.key=="s"&&b?(await N(),v.preventDefault(),!1):!0})}); diff --git a/webapp/dist/index.html b/webapp/dist/index.html index c14fc82..62f2b11 100644 --- a/webapp/dist/index.html +++ b/webapp/dist/index.html @@ -4,7 +4,7 @@ Diffedit3 - + diff --git a/webapp/src/main.ts b/webapp/src/main.ts index 624cd97..0b71771 100644 --- a/webapp/src/main.ts +++ b/webapp/src/main.ts @@ -8,7 +8,7 @@ import { TAURI_BACKEND, exit_user_abandoned_merge, } from "./backend_interactions"; -import {render_input} from "./merge_state"; +import {MergeState} from "./merge_state"; // Error handling function show_error_to_user(e: any) { @@ -65,7 +65,7 @@ window.addEventListener("DOMContentLoaded", async () => { loading_elt ); - const merge_views = render_input("lit", input); + const merge_views = MergeState.renderInDomElement("lit", input); lit_html_render(html``, loading_elt); const save_or_tell_user = async () => diff --git a/webapp/src/merge_state.ts b/webapp/src/merge_state.ts index 7a3411c..84626ca 100644 --- a/webapp/src/merge_state.ts +++ b/webapp/src/merge_state.ts @@ -9,10 +9,10 @@ import { to_text, } from "./backend_interactions"; -class MergeState { - merge_views: Record; - dom_ids: Record; - initial_values: Record; +export class MergeState { + protected merge_views: Record; + protected dom_ids: Record; + protected initial_values: Record; constructor() { this.merge_views = {}; @@ -20,7 +20,7 @@ class MergeState { this.initial_values = {}; } - values(): Record { + public values(): Record { const result: Record = {}; for (const k in this.merge_views) { // TODO: Treat deleted values properly @@ -29,39 +29,102 @@ class MergeState { return result; } - protected getSingleMergeState(filename: string): SingleMergeState { - const merge_view = this.merge_views[filename]; - const editor = merge_view.editor(); - return { - input: { - left: this.initial_values[filename].left, - right: this.initial_values[filename].right, - edit: { - type: "Text", - value: this.merge_views[filename].editor().getValue(), - }, - }, - wrapLines: - editor.getOption("lineWrapping") ?? - false /* TODO: is this ever undefined? */, - collapseIdentical: !!(editor as any).getOption( - "collapseIdentical" - ) /* TODO: Allow integer values? */, - showRightSide: !!merge_view.rightOriginal(), - cursorPosition: editor.getCursor(), - }; + // TODO: Split off drawing one editor. Only draw a single div in a loop. + // Or not? Is it reasonable to render lit-html in an element that was just rendered in lit-html? + // If not, could have two functions. + // Or just don't use `lit` for creating the divs in a loop; leave a comment instead. + // + /// Renders the input inside the HTML element with id `unique_id`. + public static renderInDomElement(unique_id: string, merge_input: MergeInput) { + let templates = []; + let k_uid = (k: string) => `${k}_${unique_id}`; + + for (const k in merge_input) { + const error = to_error(merge_input[k]); + if (error != null) { + templates.push(html`
+ ${k}: ${error} + +
`); + } else { + templates.push(html` +
+ + + ${k} + + + + + + +
+
+ `); + } + } + + const target_element = document.getElementById(unique_id)!; + target_element.innerHTML = ""; // TODO: Should use replaceWith or something + lit_html_render(html`${templates}`, target_element); + + const merge_state = new MergeState(); + for (let k in merge_input) { + if (to_error(merge_input[k]) != null) { + continue; + } + merge_state.createCodeMirrorMergeWidget( + k_uid(k), + k, + fillInDefaultSettings(merge_input[k]) + ); + } + + return merge_state; } - // TODO: This method should NOT be exported. It should become protected, - // e.g. move render_input into the constructor of this class - createCodeMirrorMergeWidget( + protected createCodeMirrorMergeWidget( unique_id: string, filename: string, merge_state: SingleMergeState ) { const input = merge_state.input; // This method is tightly coupled with the DOM constructed in - // `render_input`. + // `renderInDomElement`. const collapseButtonEl = document.getElementById(`collapse_${unique_id}`)!; const linewrapButtonEl = document.getElementById(`linewrap_${unique_id}`)!; const rightsideButtonEl = document.getElementById( @@ -128,6 +191,29 @@ class MergeState { this.initial_values[filename] = input; } + protected getSingleMergeState(filename: string): SingleMergeState { + const merge_view = this.merge_views[filename]; + const editor = merge_view.editor(); + return { + input: { + left: this.initial_values[filename].left, + right: this.initial_values[filename].right, + edit: { + type: "Text", + value: this.merge_views[filename].editor().getValue(), + }, + }, + wrapLines: + editor.getOption("lineWrapping") ?? + false /* TODO: is this ever undefined? */, + collapseIdentical: !!(editor as any).getOption( + "collapseIdentical" + ) /* TODO: Allow integer values? */, + showRightSide: !!merge_view.rightOriginal(), + cursorPosition: editor.getCursor(), + }; + } + protected recreateCodeMirrorFlippingOption( filename: string, option: BooleandMergeStateOption @@ -167,94 +253,6 @@ class MergeState { } } -// TODO: Split off drawing one editor. Only draw a single div in a loop. -// Or not? Is it reasonable to render lit-html in an element that was just rendered in lit-html? -// If not, could have two functions. -// Or just don't use `lit` for creating the divs in a loop; leave a comment instead. -// -/// Renders the input inside the HTML element with id `unique_id`. -export function render_input(unique_id: string, merge_input: MergeInput) { - let templates = []; - let k_uid = (k: string) => `${k}_${unique_id}`; - - for (const k in merge_input) { - const error = to_error(merge_input[k]); - if (error != null) { - templates.push(html`
- ${k}: ${error} - -
`); - } else { - templates.push(html` -
- - - ${k} - - - - - - -
-
- `); - } - } - - const target_element = document.getElementById(unique_id)!; - target_element.innerHTML = ""; // TODO: Should use replaceWith or something - lit_html_render(html`${templates}`, target_element); - - const merge_state = new MergeState(); - for (let k in merge_input) { - if (to_error(merge_input[k]) != null) { - continue; - } - merge_state.createCodeMirrorMergeWidget( - k_uid(k), - k, - fillInDefaultSettings(merge_input[k]) - ); - } - - return merge_state; -} - type SingleMergeState = { input: SingleFileMergeInput; wrapLines: boolean;