|
var DIFF_DELETE=-1,DIFF_INSERT=1,DIFF_EQUAL=0;function diff_main(n,r,t){if(n==r)return n?[[DIFF_EQUAL,n]]:[];(t<0||n.length<t)&&(t=null);var i=diff_commonPrefix(n,r),e=n.substring(0,i);i=diff_commonSuffix(n=n.substring(i),r=r.substring(i));var f=n.substring(n.length-i),s=diff_compute_(n=n.substring(0,n.length-i),r=r.substring(0,r.length-i));return e&&s.unshift([DIFF_EQUAL,e]),f&&s.push([DIFF_EQUAL,f]),diff_cleanupMerge(s),null!=t&&(s=fix_cursor(s,t)),s=fix_emoji(s)}function diff_compute_(n,r){var t;if(!n)return[[DIFF_INSERT,r]];if(!r)return[[DIFF_DELETE,n]];var i=n.length>r.length?n:r,e=n.length>r.length?r:n,f=i.indexOf(e);if(-1!=f)return t=[[DIFF_INSERT,i.substring(0,f)],[DIFF_EQUAL,e],[DIFF_INSERT,i.substring(f+e.length)]],n.length>r.length&&(t[0][0]=t[2][0]=DIFF_DELETE),t;if(1==e.length)return[[DIFF_DELETE,n],[DIFF_INSERT,r]];var s=diff_halfMatch_(n,r);if(s){var l=s[0],u=s[1],g=s[2],h=s[3],_=s[4],c=diff_main(l,g),F=diff_main(u,h);return c.concat([[D |