!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),(f.jsondiffpatch||(f.jsondiffpatch={})).formatters=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o
'),t.out(t.indentPad),t.out('
'),t.out(e),t.out('
'),t.out(n),t.out("
")}},AnnotatedFormatter.prototype.typeFormattterErrorFormatter=function(t,e){t.row("",'
'+e+"
")},AnnotatedFormatter.prototype.formatTextDiffString=function(t,e){var n=this.parseTextDiff(e);t.out('")},AnnotatedFormatter.prototype.rootBegin=function(t,e,n){t.out(''),"node"===e&&(t.row("{"),t.indent()),"array"===n&&t.row('"_t": "a",',"Array delta (member names indicate array indices)")},AnnotatedFormatter.prototype.rootEnd=function(t,e){"node"===e&&(t.indent(-1),t.row("}")),t.out("
")},AnnotatedFormatter.prototype.nodeBegin=function(t,e,n,o,r){t.row("""+e+"": {"),"node"===o&&t.indent(),"array"===r&&t.row('"_t": "a",',"Array delta (member names indicate array indices)")},AnnotatedFormatter.prototype.nodeEnd=function(t,e,n,o,r,a){"node"===o&&t.indent(-1),t.row("}"+(a?"":","))},AnnotatedFormatter.prototype.format_unchanged=function(){},AnnotatedFormatter.prototype.format_movedestination=function(){},AnnotatedFormatter.prototype.format_node=function(t,e,n){this.formatDeltaChildren(t,e,n)};var wrapPropertyName=function(t){return'
"'+t+""
"},deltaAnnotations={added:function(t,e,n,o){var r="
([newValue])
";return"undefined"==typeof o?"new value"+r:"number"==typeof o?"insert at index "+o+r:"add property "+wrapPropertyName(o)+r},modified:function(t,e,n,o){var r="
([previousValue, newValue])
";return"undefined"==typeof o?"modify value"+r:"number"==typeof o?"modify at index "+o+r:"modify property "+wrapPropertyName(o)+r},deleted:function(t,e,n,o){var r="
([previousValue, 0, 0])
";return"undefined"==typeof o?"delete value"+r:"number"==typeof o?"remove index "+o+r:"delete property "+wrapPropertyName(o)+r},moved:function(t,e,n,o){return'move from index '+o+' to index '+t[1]+""},textdiff:function(t,e,n,o){var r="undefined"==typeof o?"":"number"==typeof o?" at index "+o:" at property "+wrapPropertyName(o);return"text diff"+r+', format is a variation of Unidiff'}},formatAnyChange=function(t,e){var n=this.getDeltaType(e),o=deltaAnnotations[n],r=o&&o.apply(o,Array.prototype.slice.call(arguments,1)),a=JSON.stringify(e,null,2);"textdiff"===n&&(a=a.split("\\n").join('\\n"+\n "')),t.indent(),t.row(a,r),t.indent(-1)};AnnotatedFormatter.prototype.format_added=formatAnyChange,AnnotatedFormatter.prototype.format_modified=formatAnyChange,AnnotatedFormatter.prototype.format_deleted=formatAnyChange,AnnotatedFormatter.prototype.format_moved=formatAnyChange,AnnotatedFormatter.prototype.format_textdiff=formatAnyChange,exports.AnnotatedFormatter=AnnotatedFormatter;var defaultInstance;exports.format=function(t,e){return defaultInstance||(defaultInstance=new AnnotatedFormatter),defaultInstance.format(t,e)}; },{"./base":4}],4:[function(require,module,exports){ var isArray="function"==typeof Array.isArray?Array.isArray:function(e){return e instanceof Array},getObjectKeys="function"==typeof Object.keys?function(e){return Object.keys(e)}:function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},trimUnderscore=function(e){return"_"===e.substr(0,1)?e.slice(1):e},arrayKeyToSortNumber=function(e){return"_t"===e?-1:"_"===e.substr(0,1)?parseInt(e.slice(1),10):parseInt(e,10)+.1},arrayKeyComparer=function(e,t){return arrayKeyToSortNumber(e)-arrayKeyToSortNumber(t)},BaseFormatter=function(){};BaseFormatter.prototype.format=function(e,t){var r={};return this.prepareContext(r),this.recurse(r,e,t),this.finalize(r)},BaseFormatter.prototype.prepareContext=function(e){e.buffer=[],e.out=function(){this.buffer.push.apply(this.buffer,arguments)}},BaseFormatter.prototype.typeFormattterNotFound=function(e,t){throw new Error("cannot format delta type: "+t)},BaseFormatter.prototype.typeFormattterErrorFormatter=function(e,t){return t.toString()},BaseFormatter.prototype.finalize=function(e){return isArray(e.buffer)?e.buffer.join(""):void 0},BaseFormatter.prototype.recurse=function(e,t,r,o,n,a,i){var f=t&&a,s=f?a.value:r;if("undefined"!=typeof t||"undefined"!=typeof o){var u=this.getDeltaType(t,a),p="node"===u?"a"===t._t?"array":"object":"";"undefined"!=typeof o?this.nodeBegin(e,o,n,u,p,i):this.rootBegin(e,u,p);var y;try{y=this["format_"+u]||this.typeFormattterNotFound(e,u),y.call(this,e,t,s,o,n,a)}catch(c){this.typeFormattterErrorFormatter(e,c,t,s,o,n,a),"undefined"!=typeof console&&console.error&&console.error(c.stack)}"undefined"!=typeof o?this.nodeEnd(e,o,n,u,p,i):this.rootEnd(e,u,p)}},BaseFormatter.prototype.formatDeltaChildren=function(e,t,r){var o=this;this.forEachDeltaKey(t,r,function(n,a,i,f){o.recurse(e,t[n],r?r[a]:void 0,n,a,i,f)})},BaseFormatter.prototype.forEachDeltaKey=function(e,t,r){var o,n=getObjectKeys(e),a="a"===e._t,i={};if("undefined"!=typeof t)for(o in t)Object.prototype.hasOwnProperty.call(t,o)&&("undefined"!=typeof e[o]||a&&"undefined"!=typeof e["_"+o]||n.push(o));for(o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var f=e[o];isArray(f)&&3===f[2]&&(i[f[1].toString()]={key:o,value:t&&t[parseInt(o.substr(1))]},this.includeMoveDestinations!==!1&&"undefined"==typeof t&&"undefined"==typeof e[f[1]]&&n.push(f[1].toString()))}a?n.sort(arrayKeyComparer):n.sort();for(var s=0,u=n.length;u>s;s++){var p=n[s];if(!a||"_t"!==p){var y=a?"number"==typeof p?p:parseInt(trimUnderscore(p),10):p,c=s===u-1;r(p,y,i[y],c)}}},BaseFormatter.prototype.getDeltaType=function(e,t){if("undefined"==typeof e)return"undefined"!=typeof t?"movedestination":"unchanged";if(isArray(e)){if(1===e.length)return"added";if(2===e.length)return"modified";if(3===e.length&&0===e[2])return"deleted";if(3===e.length&&2===e[2])return"textdiff";if(3===e.length&&3===e[2])return"moved"}else if("object"==typeof e)return"node";return"unknown"},BaseFormatter.prototype.parseTextDiff=function(e){for(var t=[],r=e.split("\n@@ "),o=0,n=r.length;n>o;o++){var a=r[o],i={pieces:[]},f=/^(?:@@ )?[-+]?(\d+),(\d+)/.exec(a).slice(1);i.location={line:f[0],chr:f[1]};for(var s=a.split("\n").slice(1),u=0,p=s.length;p>u;u++){var y=s[u];if(y.length){var c={type:"context"};"+"===y.substr(0,1)?c.type="added":"-"===y.substr(0,1)&&(c.type="deleted"),c.text=y.slice(1),i.pieces.push(c)}}t.push(i)}return t},exports.BaseFormatter=BaseFormatter; },{}],5:[function(require,module,exports){ function htmlEscape(t){for(var e=t,o=[[/&/g,"&"],[//g,">"],[/'/g,"'"],[/"/g,"""]],a=0;a'+e+"")},HtmlFormatter.prototype.formatValue=function(t,e){t.out("
"+htmlEscape(JSON.stringify(e,null,2))+"
")},HtmlFormatter.prototype.formatTextDiffString=function(t,e){var o=this.parseTextDiff(e);t.out('")};var adjustArrows=function(t){t=t||document;var e=function(t){return t.textContent||t.innerText},o=function(t,e,o){for(var a=t.querySelectorAll(e),r=0,i=a.length;i>r;r++)o(a[r])},a=function(t,e){for(var o=0,a=t.children.length;a>o;o++)e(t.children[o],o)};o(t,".jsondiffpatch-arrow",function(t){var o=t.parentNode,r=t.children[0],i=r.children[1];r.style.display="none";var n,s=e(o.querySelector(".jsondiffpatch-moved-destination")),d=o.parentNode;if(a(d,function(t){t.getAttribute("data-key")===s&&(n=t)}),n)try{var f=n.offsetTop-o.offsetTop;r.setAttribute("height",Math.abs(f)+6),t.style.top=-8+(f>0?0:f)+"px";var l=f>0?"M30,0 Q-10,"+Math.round(f/2)+" 26,"+(f-4):"M30,"+-f+" Q-10,"+Math.round(-f/2)+" 26,4";i.setAttribute("d",l),r.style.display=""}catch(c){return}})};HtmlFormatter.prototype.rootBegin=function(t,e,o){var a="jsondiffpatch-"+e+(o?" jsondiffpatch-child-node-type-"+o:"");t.out('
')},HtmlFormatter.prototype.rootEnd=function(t){t.out("
"+(t.hasArrows?'":""))},HtmlFormatter.prototype.nodeBegin=function(t,e,o,a,r){var i="jsondiffpatch-"+a+(r?" jsondiffpatch-child-node-type-"+r:"");t.out('
  • '+o+"
    ")},HtmlFormatter.prototype.nodeEnd=function(t){t.out("
  • ")},HtmlFormatter.prototype.format_unchanged=function(t,e,o){"undefined"!=typeof o&&(t.out('
    '),this.formatValue(t,o),t.out("
    "))},HtmlFormatter.prototype.format_movedestination=function(t,e,o){"undefined"!=typeof o&&(t.out('
    '),this.formatValue(t,o),t.out("
    "))},HtmlFormatter.prototype.format_node=function(t,e,o){var a="a"===e._t?"array":"object";t.out('")},HtmlFormatter.prototype.format_added=function(t,e){t.out('
    '),this.formatValue(t,e[0]),t.out("
    ")},HtmlFormatter.prototype.format_modified=function(t,e){t.out('
    '),this.formatValue(t,e[0]),t.out('
    '),this.formatValue(t,e[1]),t.out("
    ")},HtmlFormatter.prototype.format_deleted=function(t,e){t.out('
    '),this.formatValue(t,e[0]),t.out("
    ")},HtmlFormatter.prototype.format_moved=function(t,e){t.out('
    '),this.formatValue(t,e[0]),t.out('
    '+e[1]+"
    "),t.out('
    '),t.hasArrows=!0},HtmlFormatter.prototype.format_textdiff=function(t,e){t.out('
    '),this.formatTextDiffString(t,e[0]),t.out("
    ")};var showUnchanged=function(t,e,o){var a=e||document.body,r="jsondiffpatch-unchanged-",i={showing:r+"showing",hiding:r+"hiding",visible:r+"visible",hidden:r+"hidden"},n=a.classList;if(n){if(!o)return n.remove(i.showing),n.remove(i.hiding),n.remove(i.visible),n.remove(i.hidden),void(t===!1&&n.add(i.hidden));t===!1?(n.remove(i.showing),n.add(i.visible),setTimeout(function(){n.add(i.hiding)},10)):(n.remove(i.hiding),n.add(i.showing),n.remove(i.hidden));var s=setInterval(function(){adjustArrows(a)},100);setTimeout(function(){n.remove(i.showing),n.remove(i.hiding),t===!1?(n.add(i.hidden),n.remove(i.visible)):(n.add(i.visible),n.remove(i.hidden)),setTimeout(function(){n.remove(i.visible),clearInterval(s)},o+400)},o)}},hideUnchanged=function(t,e){return showUnchanged(!1,t,e)};exports.HtmlFormatter=HtmlFormatter,exports.showUnchanged=showUnchanged,exports.hideUnchanged=hideUnchanged;var defaultInstance;exports.format=function(t,e){return defaultInstance||(defaultInstance=new HtmlFormatter),defaultInstance.format(t,e)}; },{"./base":4}],6:[function(require,module,exports){ var environment=require("../environment");if(exports.base=require("./base"),exports.html=require("./html"),exports.annotated=require("./annotated"),exports.jsonpatch=require("./jsonpatch"),!environment.isBrowser){var consoleModuleName="./console";exports.console=require(consoleModuleName)} },{"../environment":2,"./annotated":3,"./base":4,"./html":5,"./jsonpatch":7}],7:[function(require,module,exports){ !function(){function t(){this.includeMoveDestinations=!1}function e(t){return t[t.length-1]}function n(t,e){return t.sort(e),t}function o(t){return n(t,function(t,n){var o=t.path.split("/"),r=n.path.split("/");return o.length!==r.length?o.length-r.length:d(e(o),e(r))})}function r(t,e){var n=[],o=[];return t.forEach(function(t){var r=e(t)?n:o;r.push(t)}),[n,o]}function p(t){var e=r(t,function(t){return"remove"===t.op}),n=e[0],p=e[1],u=o(n);return u.concat(p)}var u=require("./base"),i=u.BaseFormatter,a={added:"add",deleted:"remove",modified:"replace",moved:"moved",movedestination:"movedestination",unchanged:"unchanged",error:"error",textDiffLine:"textDiffLine"};t.prototype=new i,t.prototype.prepareContext=function(t){i.prototype.prepareContext.call(this,t),t.result=[],t.path=[],t.pushCurrentOp=function(t,e){var n={op:t,path:this.currentPath()};"undefined"!=typeof e&&(n.value=e),this.result.push(n)},t.currentPath=function(){return"/"+this.path.join("/")}},t.prototype.typeFormattterErrorFormatter=function(t,e){t.out("[ERROR]"+e)},t.prototype.rootBegin=function(){},t.prototype.rootEnd=function(){},t.prototype.nodeBegin=function(t,e,n){t.path.push(n)},t.prototype.nodeEnd=function(t){t.path.pop()},t.prototype.format_unchanged=function(t,e,n){"undefined"!=typeof n&&t.pushCurrentOp(a.unchanged,n)},t.prototype.format_movedestination=function(t,e,n){"undefined"!=typeof n&&t.pushCurrentOp(a.movedestination,n)},t.prototype.format_node=function(t,e,n){this.formatDeltaChildren(t,e,n)},t.prototype.format_added=function(t,e){t.pushCurrentOp(a.added,e[0])},t.prototype.format_modified=function(t,e){t.pushCurrentOp(a.modified,e[1])},t.prototype.format_deleted=function(t){t.pushCurrentOp(a.deleted)},t.prototype.format_moved=function(t,e){t.pushCurrentOp(a.moved,e[1])},t.prototype.format_textdiff=function(){throw"not implimented"},t.prototype.format=function(t,e){var n={};return this.prepareContext(n),this.recurse(n,t,e),n.result},exports.JSONFormatter=t;var f,d=function(t,e){var n=parseInt(t,10),o=parseInt(e,10);return isNaN(n)||isNaN(o)?0:o-n},c=function(e,n){return f||(f=new t),p(f.format(e,n))};exports.log=function(t,e){console.log(c(t,e))},exports.format=c}(); },{"./base":4}]},{},[1])(1) }); //# sourceMappingURL=jsondiffpatch-formatters.min.map