!function(e,n){functiont(e,n,t){if(Array.prototype.map)returnArray.prototype.map.call(e,n,t);for(varr=newArray(e.length),o=0,i=e.length;i>o;o++)r[o]=n.call(t,e[o],o,e);returnr}functionr(e){return{newPos:e.newPos,components:e.components.slice(0)}}functiono(e){for(varn=[],t=0;t<e.length;t++)e[t]&&n.push(e[t]);returnn}functioni(e){varn=e;returnn=n.replace(/&/g,"&"),n=n.replace(/</g,"<"),n=n.replace(/>/g,">"),n=n.replace(/"/g,""")}functionu(e,n,t){n=n||[],t=t||[];varr;for(r=0;r<n.length;r+=1)if(n[r]===e)returnt[r];varo;if("[object Array]"===a.call(e)){for(n.push(e),o=newArray(e.length),t.push(o),r=0;r<e.length;r+=1)o[r]=u(e[r],n,t);n.pop(),t.pop()}elseif("object"==typeofe&&null!==e){n.push(e),o={},t.push(o);vari,s=[];for(iine)s.push(i);for(s.sort(),r=0;r<s.length;r+=1)i=s[r],o[i]=u(e[i],n,t);n.pop(),t.pop()}elseo=e;returno}functions(e,n,r,o){for(vari=0,u=e.length,s=0,f=0;u>i;i++){vara=e[i];if(a.removed){if(a.value=r.slice(f,f+a.count).join(""),f+=a.count,i&&e[i-1].added){varl=e[i-1];e[i-1]=e[i],e[i]=l}}else{if(!a.added&&o){vard=n.slice(s,s+a.count);d=t(d,function(e,n){vart=r[f+n];returnt.length>e.length?t:e}),a.value=d.join("")}elsea.value=n.slice(s,s+a.count).join("");s+=a.count,a.added||(f+=a.count)}}returne}functionf(e){this.ignoreWhitespace=e}vara=Object.prototype.toString;f.prototype={diff:function(e,t,o){functioni(e){returno?(setTimeout(function(){o(n,e)},0),!0):e}functionu(){for(varo=-1*d;d>=o;o+=2){varu,p=h[o-1],c=h[o+1],v=(c?c.newPos:0)-o;p&&(h[o-1]=n);varg=p&&p.newPos+1<a,m=c&&v>=0&&l>v;if(g||m){if(!g||m&&p.newPos<c.newPos?(u=r(c),f.pushComponent(u.components,n,!0)):(u=p,u.newPos++,f.pushComponent(u.components,!0,n)),v=f.extractCommon(u,t,e,o),u.newPos+1>=a&&v+1>=l)returni(s(u.components,t,e,f.useLongestToken));h[o]=u}elseh[o]=n}d++}varf=this;if(t===e)returni([{value:t}]);if(!t)returni([{value:e,removed:!0}]);if(!e)returni([{value:t,added:!0}]);t=this.tokenize(t),e=this.tokenize(e);vara=t.length,l=e.length,d=1,p=a+l,h=[{newPos:-1,components:[]}],c=this.extractCommon(h[0],t,e,0);if(h[0].newPos+1>=a&&c+1>=l)returni([{value:t.join("")}]);if(o)!functiong(){setTimeout(function(){returnd>p?o():void(u()||g())},0)}();elsefor(;p>=d;){varv=u();if(v)returnv}},pushComponent:function(e,n,t){varr=e[e.length-1];r&&r.added===n&&r.removed===t?e[e.length-1]={count:r.count+1,added:n,removed:t}:e.push({count:1,added:n,removed:t})},extractCommon:function(e,n,t,r){for(varo=n.length,i=t.length,u=e.newPos,s=u-r,f=0;o>u+1&&i>s+1&&this.equals(n[u+1],t[s+1]);)u++,s++,f++;returnf&&e.components.push({count:f}),e.newPos=u,s},equals:function(e,n){vart=/\S/;returne===n||this.ignoreWhitespace&&!t.test(e)&&!t.test(n)},tokenize:function(e){returne.split("")}};varl=newf,d=newf(!0),p=newf;d.tokenize=p.tokenize=function(e){returno(e.split(/(\s+|\b)/))};varh=newf(!0);h.tokenize=function(e){returno(e.split(/([{}:;,]|\s+)/))};varc=newf,v=newf;v.ignoreTrim=!0,c.tokenize=v.tokenize=function(e){for(varn=[],t=e.split(/^/m),r=0;r<t.length;r++){varo=t[r],i=t[r-1],u=i&&i[i.length-1];"\n"===o&&"\r"===u?n[n.length-1]=n[n.length-1].slice(0,-1)+"\r\n":(this.ignoreTrim&&(o=o.trim(),r<t.length-1&&(o+="\n")),n.push(o))}returnn};varg=newf;g.tokenize=function(e){varn=[],t=e.split(/(\n|\r\n)/);t[t.length-1]||t.pop();for(varr=0;r<t.length;r++){varo=t[r];r%2?n[n.length-1]+=o:n.push(o)}returnn};varm=newf;m.tokenize=function(e){returno(e.split(/(\S.+?[.!?])(?=\s+|$)/))};varw=newf;w.useLongestToken=!0,w.tokenize=c.tokenize,w.equals=function(e,n){returnc.equals(e.replace(/,([\r\n])/g,"$1"),n.replace(/,([\r\n])/g,"$1"))};vary={Diff:f,diffChars:function(e,n,t){returnl.diff(e,n,t)},diffWords:function(e,n,t){returnd.diff(e,n,t)},diffWordsWithSpace:function(e,n,t){returnp.diff(e,n,t)},diffLines:function(e,n,t){returnc.diff(e,n,t)},diffTrimmedLines:function(e,n,t){returnv.diff(e,n,t)},diffSentences:function(e,n,t){returnm.diff(e,n,t)},diffCss:function(e,n,t){returnh.diff(e,n,t)},diffJson:function(e,t,r){returnw.diff("string"==typeofe?e:JSON.stringify(u(e),n,""),"string"==typeoft?t:JSON.stringify(u(t),n,""),r)},createTwoFilesPatch:function(e,n,r,o,i,u){functions(e){returnt(e,function(e){return""+e})}functionf(e,n,t){varr=l[l.length-2],o=n===l.length-2,i=n===l.length-3&&t.added!==r.added;/\n$/.test(t.value)||!o&&!i||e.push("\\ No newline at end of file")}vara=[];e==n&&a.push("Index: "+e),a.push("==================================================================="),a.push("--- "+e+("undefined"==typeofi?"":""+i)),a.push("+++ "+n+("undefined"==typeofu?"":""+u));varl=g.diff(r,o);l.push({value:"",lines:[]});for(vard=0,p=0,h=[],c=1,v=1,m=0;m<l.length;m++){varw=l[m],y=w.lines||w.value.replace(/\n$/,"").split("\n");if(w.lines=y,w.added||w.removed){if(!d){varP=l[m-1];d=c,p=v,P&&(h=s(P.lines.slice(-4)),d-=h.length,p-=h.length)}h.push.apply(h,t(y,function(e){return(w.added?"+":"-")+e})),f(h,m,w),w.added?v+=y.length:c+=y.length}else{if(d)if(y.length<=8&&m<l.length-2)h.push.apply(h,s(y));else{vark=Math.min(y.length,4);a.push("@@ -"+d+","+(c-d+k)+" +"+p+","+(v-p+k)+" @@"),a.push.apply(a,h),a.push.apply(a,s(y.slice(0,k))),y.length<=4&&f(a,m,w),d=0,p=0,h=[]}c+=y.length,v+=y.length}}returna.join("\n")+"\n"},createPatch:function(e,n,t,r,o){returny.createTwoFilesPatch(e,e,n,t,r,o)},applyPatch:function(e,n){for(vart=n.split("\n"),r=[],o=0,i=!1,u=!1;o<t.length&&!/^@@/.test(t[o]);)o++;for(;o<t.length;o++)if("@"===t[o][0]){vars=t[o].split(/@@ -(\d+),(\d+)\+(\d+),(\d+) @@/);r.unshift({start:s[3],oldlength:+s[2],removed:[],newlength:s[4],added:[]})}else"+"===t[o][0]?r[0].added.push(t[o].substr(1)):"-"===t[o][0]?r[0].removed.push(t[o].substr(1)):""===t[o][0]?(r[0].added.push(t[o].substr(1)),r[0].removed.push(t[o].substr(1))):"\\"===t[o][0]&&("+"===t[o-1][0]?i=!0:"-"===t[o-1][0]&&(u=!0));varf=e.split("\n");for(o=r.length-1;o>=0;o--){for(vara=r[o],l=0;l<a.oldlength;l++)if(f[a.start-1+l]!==a.removed[l])return!1;Array.prototype.splice.apply(f,[a.start-1,a.oldlength].concat(a.added))}if(i)for(;!f[f.length-1];)f.pop();elseu&&f.push("");returnf.join("\n")},convertChangesToXML:function(e){for(varn=[],t=0;t<e.length;t++){varr=e[t];r.added?n.push("<ins>"):r.removed&&n.push("<del>"),n.push(i(r.value)),r.added?n.push("</ins>"):r.removed&&n.push("</del>")}returnn.join("")},convertChangesToDMP:function(e){for(varn,t,r=[],o=0;o<e.length;o++)n=e[o],t=n.added?1:n.removed?-1:0,r.push([t,n.value]);returnr},canonicalize:u};"undefined"!=typeofmodule&&module.exports?module.exports=y:"function"==typeofdefine&&define.amd?define([],function(){returny}):"undefined"==typeofe.JsDiff&&(e.JsDiff=y)}(this);