yjs/dest/browser/Frameworks/JsonIwcYatta.min.js
2014-08-06 13:33:08 +02:00

10 lines
299 KiB
JavaScript

!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){var c;c=function(a){var b,c,d,e,f,g,h;return f={},c=new DUIClient,c.connect(function(a){var b;return null!=(b=f[a.action])?b.map(function(b){return setTimeout(function(){return b(a)},0)}):void 0}),c.initOK(),h=null,g=null,b=function(){function a(a,b,d,e){var i,j,k;this.engine=a,this.HB=b,this.execution_listener=d,this.yatta=e,this.duiClient=c,this.iwcHandler=f,k=function(a){return function(b){return a.send(b)}}(this),this.execution_listener.push(k),i=function(a){return function(b){var c;return c=b.extras,a.receive(c)}}(this),this.iwcHandler.Yatta_new_operation=[i],null!=h&&this.engine.applyOps(g),j=function(a){return function(){var b;return b={root_element:a.yatta.getRootElement(),HB:a.yatta.getHistoryBuffer()._encode()},a.sendIwcIntent("Yatta_push_root_element",b)}}(this),this.iwcHandler.Yatta_get_root_element=[j]}return a.prototype.getRootElement=function(){return h},a.prototype.send=function(a){return a.uid.creator===this.HB.getUserId()&&"string"!=typeof a.uid.op_number?this.sendIwcIntent("Yatta_new_operation",a):void 0},a.prototype.receive=function(a){return a.uid.creator!==this.HB.getUserId()?this.engine.applyOp(a):void 0},a.prototype.sendIwcIntent=function(a,b){var c;return c={action:a,component:"",data:"",dataType:"",extras:b},this.duiClient.sendIntent(c)},a.prototype.sync=function(){throw new Error("Can't use this a.t.m.")},a}(),d={action:"Yatta_get_root_element",component:"",data:"",dataType:"",extras:{}},e=function(){var e,i;return c.sendIntent(d),e=!1,i=function(d){var f;return f=c.getIwcClient()._componentName,h=null!=d?d.extras.root_element:void 0,g=null!=d?d.extras.HB:void 0,e?void 0:(e=!0,a(b,f))},f.Yatta_push_root_element=[i],setTimeout(i,800)},void setTimeout(e,4e3*Math.random())},b.exports=c,"undefined"!=typeof window&&null!==window&&(window.createConnector=c)},{}],2:[function(a,b){var c;c=function(){function a(a,b){this.HB=a,this.parser=b,this.unprocessed_ops=[]}return a.prototype.parseOperation=function(a){var b;if(b=this.parser[a.type],null!=b)return b(a);throw new Error("You forgot to specify a parser for type "+a.type+". The message is "+JSON.stringify(a)+".")},a.prototype.applyOps=function(a){var b,c,d,e,f,g,h,i;for(c=[],d=0,g=a.length;g>d;d++)b=a[d],c.push(this.parseOperation(b));for(e=0,h=c.length;h>e;e++)b=c[e],this.HB.addOperation(b);for(f=0,i=c.length;i>f;f++)b=c[f],b.execute()||this.unprocessed_ops.push(b);return this.tryUnprocessed()},a.prototype.applyOp=function(a){var b;return b=this.parseOperation(a),this.HB.addOperation(b),b.execute()||this.unprocessed_ops.push(b),this.tryUnprocessed()},a.prototype.tryUnprocessed=function(){var a,b,c,d,e,f,g;for(g=[];;){for(a=this.unprocessed_ops.length,c=[],f=this.unprocessed_ops,d=0,e=f.length;e>d;d++)b=f[d],b.execute()||c.push(b);if(this.unprocessed_ops=c,this.unprocessed_ops.length===a)break;g.push(void 0)}return g},a}(),b.exports=c},{}],3:[function(a,b){var c,d,e,f;f=a("../Types/JsonTypes.coffee"),d=a("../HistoryBuffer.coffee"),c=a("../Engine.coffee"),e=function(){function a(a,b){var e,g,h;this.HB=new d(a),g=f(this.HB),this.engine=new c(this.HB,g.parser),this.connector=new b(this.engine,this.HB,g.execution_listener,this),h=this.connector.getRootElement(),null==h?(e=new g.types.JsonType(this.HB.getNextOperationIdentifier()),this.HB.addOperation(e),e.execute(),this.root_element=e):this.root_element=this.HB.getOperation(h)}return a.prototype.getRootElement=function(){return this.root_element},a.prototype.getEngine=function(){return this.engine},a.prototype.getConnector=function(){return this.connector},a.prototype.getHistoryBuffer=function(){return this.HB},a.prototype.setMutableDefault=function(a){return this.root_element.setMutableDefault(a)},a.prototype.getUserId=function(){return this.HB.getUserId()},a.prototype.val=function(a,b,c){return this.root_element.val(a,b,c)},Object.defineProperty(a.prototype,"value",{get:function(){return this.root_element.value},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),a}(),"undefined"!=typeof window&&null!==window&&(window.JsonYatta=e),b.exports=e},{"../Engine.coffee":2,"../HistoryBuffer.coffee":4,"../Types/JsonTypes.coffee":6}],4:[function(a,b){var c;c=function(){function a(a){this.user_id=a,this.operation_counter={},this.buffer={},this.change_listeners=[]}return a.prototype.getUserId=function(){return this.user_id},a.prototype.getOperationCounter=function(){var a,b,c,d;b={},d=this.operation_counter;for(c in d)a=d[c],b[c]=a;return b},a.prototype._encode=function(){var a,b,c,d,e,f;a=[],f=this.buffer;for(d in f){e=f[d];for(c in e)b=e[c],isNaN(parseInt(c))||a.push(b._encode())}return a},a.prototype.getNextOperationIdentifier=function(a){var b;return null==a&&(a=this.user_id),null==this.operation_counter[a]&&(this.operation_counter[a]=0),b={creator:a,op_number:this.operation_counter[a]},this.operation_counter[a]++,b},a.prototype.getOperation=function(a){var b;if(a instanceof Object)return null!=(b=this.buffer[a.creator])?b[a.op_number]:void 0;if(null!=a)throw new Error("This type of uid is not defined!")},a.prototype.addOperation=function(a){if(null==this.buffer[a.creator]&&(this.buffer[a.creator]={}),null==this.operation_counter[a.creator]&&(this.operation_counter[a.creator]=0),null!=this.buffer[a.creator][a.op_number])throw new Error("You must not overwrite operations!");return this.buffer[a.creator][a.op_number]=a,"number"==typeof a.op_number&&a.creator!==this.getUserId()&&this.operation_counter[a.creator]++,a},a}(),b.exports=c},{}],5:[function(a,b){var c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};b.exports=function(a){var b,c,e,f,g,h,i;return i={},h=[],g=function(){function b(b){null==b&&(b=a.getNextOperationIdentifier()),this.creator=b.creator,this.op_number=b.op_number}return b.prototype.getUid=function(){return{creator:this.creator,op_number:this.op_number}},b.prototype.execute=function(){var a,b,c;for(this.is_executed=!0,b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this},b.prototype.saveOperation=function(a,b){return null!=(null!=b?b.execute:void 0)?this[a]=b:null!=b?(null==this.unchecked&&(this.unchecked={}),this.unchecked[a]=b):void 0},b.prototype.validateSavedOperations=function(){var b,c,d,e,f,g;f={},e=this,g=this.unchecked;for(b in g)d=g[b],c=a.getOperation(d),c?this[b]=c:(f[b]=d,e=!1);return delete this.unchecked,e||(this.unchecked=f),e},b}(),b=function(a){function b(a,c){this.saveOperation("deletes",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype._encode=function(){return{type:"Delete",uid:this.getUid(),deletes:this.deletes.getUid()}},b.prototype.execute=function(){return this.validateSavedOperations()?(this.deletes.applyDelete(this),b.__super__.execute.apply(this,arguments),this):!1},b}(g),i.Delete=function(a){var c,d;return d=a.uid,c=a.deletes,new b(d,c)},f=function(a){function b(a,c,d,e){this.saveOperation("prev_cl",c),this.saveOperation("next_cl",d),null!=e?this.saveOperation("origin",e):this.saveOperation("origin",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype.applyDelete=function(a){return null==this.deleted_by&&(this.deleted_by=[]),this.deleted_by.push(a)},b.prototype.isDeleted=function(){var a;return(null!=(a=this.deleted_by)?a.length:void 0)>0},b.prototype.getDistanceToOrigin=function(){var a,b;for(a=0,b=this.prev_cl;;){if(this.origin===b)break;if(a++,this===this.prev_cl)throw new Error("this should not happen ;) ");b=b.prev_cl}return a},b.prototype.update_sl=function(){var a;return a=this.prev_cl,update("prev_cl","prev_sl"),update("next_cl","prev_sl")},b.prototype.execute=function(){var a,c,d,e,f;if(null!=this.is_executed)return this;if(this.validateSavedOperations()){if((null!=(e=this.prev_cl)?e.validateSavedOperations():void 0)&&(null!=(f=this.next_cl)?f.validateSavedOperations():void 0)&&this.prev_cl.next_cl!==this){for(a=0,d=this.prev_cl.next_cl,c=0;;){if(null==d&&(console.log(JSON.stringify(this.prev_cl.getUid())),console.log(JSON.stringify(this.next_cl.getUid()))),d===this.next_cl)break;if(d.getDistanceToOrigin()===c)d.creator<this.creator&&(this.prev_cl=d,a=c+1);else{if(!(d.getDistanceToOrigin()<c))break;c-a<=d.getDistanceToOrigin()&&(this.prev_cl=d,a=c+1)}c++,d=d.next_cl}this.next_cl=this.prev_cl.next_cl,this.prev_cl.next_cl=this,this.next_cl.prev_cl=this}return b.__super__.execute.apply(this,arguments),this}return!1},b}(g),e=function(a){function b(a,c,d,e,f){this.content=null!=c?c:"",b.__super__.constructor.call(this,a,d,e,f)}return d(b,a),b.prototype.val=function(){return this.content},b.prototype._encode=function(){var a;return a={type:"ImmutableObject",uid:this.getUid(),content:this.content},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(f),i.ImmutableObject=function(a){var b,c,d,f,g;return g=a.uid,b=a.content,f=a.prev,c=a.next,d=a.origin,new e(g,b,f,c,d)},c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return d(b,a),b.prototype.execute=function(){var a,b,c;if(this.validateSavedOperations()){for(b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this}return!1},b.prototype._encode=function(){var a,b;return{type:"Delimiter",uid:this.getUid(),prev:null!=(a=this.prev_cl)?a.getUid():void 0,next:null!=(b=this.next_cl)?b.getUid():void 0}},b}(f),i.Delimiter=function(a){var b,d,e;return e=a.uid,d=a.prev,b=a.next,new c(e,d,b)},{types:{Delete:b,Insert:f,Delimiter:c,Operation:g,ImmutableObject:e},parser:i,execution_listener:h}}},{}],6:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./TextTypes.coffee"),b.exports=function(a){var b,d,f,g,h;return g=c(a),h=g.types,f=g.parser,d=function(a){var c;return new(c=function(){function a(c){var e,f,g,i;i=c.map,g=function(e,f){return Object.defineProperty(a.prototype,e,{get:function(){var a;return a=f.val(),a instanceof b?d(a):a instanceof h.ImmutableObject?a.val():a},set:function(a){var b,d,f,g;if(a.constructor==={}.constructor){f=c.val(e),g=[];for(b in a)d=a[b],g.push(f.val(b,d,"immutable"));return g}return c.val(e,a,"immutable")},enumerable:!0,configurable:!1})};for(e in i)f=i[e],g(e,f)}return a}())(a)},b=function(b){function c(a,b,d){var e,f;if(c.__super__.constructor.call(this,a),null!=b){if("object"!=typeof b)throw new Error("The initial value of JsonTypes must be of type Object! (current type: "+typeof b+")");for(e in b)f=b[e],this.val(e,f,d)}}return e(c,b),c.prototype.mutable_default=!0,c.prototype.setMutableDefault=function(a){if(a===!0||"mutable"===a)c.prototype.mutable_default=!0;else{if(a!==!1&&"immutable"!==a)throw new Error('Set mutable either "mutable" or "immutable"!');c.prototype.mutable_default=!1}return"OK"},c.prototype.val=function(b,d,e){var f,g,i,j,k;if("object"==typeof b){for(i in b)g=b[i],this.val(i,g,d);return this}if(null!=b&&null!=d){if(e=null!=e?e===!0||"mutable"===e?!0:!1:this.mutable_default,"function"==typeof d)return this;if(e&&"number"!=typeof d||d.constructor===Object){if("string"==typeof d)return k=a.addOperation(new h.Word(a.getNextOperationIdentifier(),d)).execute(),c.__super__.val.call(this,b,k);if(d.constructor===Object)return f=a.addOperation(new c(a.getNextOperationIdentifier(),d,e)).execute(),c.__super__.val.call(this,b,f);throw new Error("You must not set "+typeof d+"-types in collaborative Json-objects!")}return j=a.addOperation(new h.ImmutableObject(void 0,d)).execute(),c.__super__.val.call(this,b,j)}return c.__super__.val.call(this,b,d)},Object.defineProperty(c.prototype,"value",{get:function(){return d(this)},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),c.prototype._encode=function(){return{type:"JsonType",uid:this.getUid()}},c}(h.MapManager),f.JsonType=function(a){var c;return c=a.uid,new b(c)},h.JsonType=b,g}},{"./TextTypes.coffee":8}],7:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./BasicTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i,j,k;return i=c(a),k=i.types,j=i.parser,f=function(c){function d(a){this.map={},d.__super__.constructor.call(this,a)}return e(d,c),d.prototype.val=function(c,e){var f,g,h,i,j;if(null!=e)return null==this.map[c]&&a.addOperation(new b(a.getNextOperationIdentifier(),this,c)).execute(),this.map[c].replace(e),this;if(null!=c)return g=null!=(i=this.map[c])?i.val():void 0,g instanceof k.ImmutableObject?g.val():g;h={},j=this.map;for(c in j)f=j[c],g=f.val(),(g instanceof k.ImmutableObject||g instanceof d)&&(g=g.val()),h[c]=g;return h},d}(k.Operation),b=function(b){function c(a,b,d){this.name=d,this.saveOperation("map_manager",b),c.__super__.constructor.call(this,a)}return e(c,b),c.prototype.execute=function(){var b,d,e,f,h;return this.validateSavedOperations()?(h=this.map_manager.getUid(),h.op_number="_"+h.op_number+"_RM_"+this.name,null==a.getOperation(h)&&(e=this.map_manager.getUid(),e.op_number="_"+e.op_number+"_RM_"+this.name+"_beginning",f=this.map_manager.getUid(),f.op_number="_"+f.op_number+"_RM_"+this.name+"_end",b=a.addOperation(new k.Delimiter(e,void 0,f)),d=a.addOperation(new k.Delimiter(f,b,void 0)).execute(),b.execute(),this.map_manager.map[this.name]=a.addOperation(new g(void 0,h,b,d)).execute()),c.__super__.execute.apply(this,arguments)):!1},c.prototype._encode=function(){return{type:"AddName",uid:this.getUid(),map_manager:this.map_manager.getUid(),name:this.name}},c}(k.Operation),j.AddName=function(a){var c,d,e;return c=a.map_manager,e=a.uid,d=a.name,new b(e,c,d)},d=function(b){function c(b,d,e,f,g,h){null!=d&&null!=e?(this.saveOperation("beginning",d),this.saveOperation("end",e)):(this.beginning=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),void 0,void 0)),this.end=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),this.beginning,void 0)),this.beginning.next_cl=this.end,this.beginning.execute(),this.end.execute()),c.__super__.constructor.call(this,b,f,g,h)}return e(c,b),c.prototype.getLastOperation=function(){return this.end.prev_cl},c.prototype.getFirstOperation=function(){return this.beginning.next_cl},c.prototype.toArray=function(){var a,b;for(a=this.beginning.next_cl,b=[];a!==this.end;)b.push(a),a=a.next_cl;return b},c.prototype.getOperationByPosition=function(a){var b;if(b=this.beginning.next_cl,a>0)for(;;){if(b=b.next_cl,b.isDeleted()||(a-=1),0===a)break;if(b instanceof k.Delimiter)throw new Error("position parameter exceeded the length of the document!")}return b},c}(k.Insert),g=function(b){function c(a,b,d,e,f,g,h){c.__super__.constructor.call(this,b,d,e,f,g,h),null!=a&&this.replace(a)}return e(c,b),c.prototype.replace=function(b){var c,d;return c=this.getLastOperation(),d=new h(b,this,a.getNextOperationIdentifier(),c,c.next_cl),a.addOperation(d).execute()},c.prototype.val=function(){var a;if(a=this.getLastOperation(),a instanceof k.Delimiter)throw new Error("dtrn");return a.val()},c.prototype._encode=function(){var a;return a={type:"ReplaceManager",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&null!=this.next_cl&&(a.prev=this.prev_cl.getUid(),a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},c}(d),j.ReplaceManager=function(a){var b,c,d,e,f,h,i;return c=a.content,i=a.uid,h=a.prev,e=a.next,f=a.origin,b=a.beginning,d=a.end,new g(c,i,b,d,h,e,f)},h=function(a){function b(a,c,d,e,f,g){if(this.saveOperation("content",a),this.saveOperation("parent",c),null==e||null==f||null==a)throw new Error("You must define content, prev, and next for Replaceable-types!");b.__super__.constructor.call(this,d,e,f,g)}return e(b,a),b.prototype.val=function(){return this.content},b.prototype.replace=function(a){return this.parent.replace(a)},b.prototype.execute=function(){var a;return this.validateSavedOperations()?("function"==typeof(a=this.content).setReplaceManager&&a.setReplaceManager(this.parent),b.__super__.execute.apply(this,arguments),this):!1},b.prototype._encode=function(){var a;return a={type:"Replaceable",content:this.content.getUid(),ReplaceManager:this.parent.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid(),uid:this.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(k.Insert),j.Replaceable=function(a){var b,c,d,e,f,g;return b=a.content,e=a.ReplaceManager,g=a.uid,f=a.prev,c=a.next,d=a.origin,new h(b,e,g,f,c,d)},k.ListManager=d,k.MapManager=f,k.ReplaceManager=g,k.Replaceable=h,i}},{"./BasicTypes.coffee":5}],8:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./StructuredTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i;return h=c(a),i=h.types,g=h.parser,b=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return e(b,a),b}(i.Delete),g.TextDelete=g.Delete,d=function(a){function b(a,c,d,e,f){if(this.content=a,null==d||null==e)throw new Error("You must define prev, and next for TextInsert-types!");b.__super__.constructor.call(this,c,d,e,f)}return e(b,a),b.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},b.prototype.val=function(){return this.isDeleted()?"":this.content},b.prototype._encode=function(){var a;return a={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(i.Insert),g.TextInsert=function(a){var b,c,e,f,g;return b=a.content,g=a.uid,f=a.prev,c=a.next,e=a.origin,new d(b,g,f,c,e)},f=function(c){function f(a,b,c,d,e,g,h){f.__super__.constructor.call(this,a,c,d,e,g,h),null!=b&&this.insertText(0,b)}return e(f,c),f.prototype.insertText=function(b,c){var e,f,g,h,i,j;for(f=this.getOperationByPosition(b),j=[],h=0,i=c.length;i>h;h++)e=c[h],g=new d(e,a.getNextOperationIdentifier(),f.prev_cl,f),j.push(a.addOperation(g).execute());return j},f.prototype.deleteText=function(c,d){var e,f,g,h,j;for(g=this.getOperationByPosition(c),j=[],f=h=0;d>=0?d>h:h>d;f=d>=0?++h:--h){for(e=a.addOperation(new b(a.getNextOperationIdentifier(),g)).execute(),g=g.next_cl;g.isDeleted();){if(g instanceof i.Delimiter)throw new Error("You can't delete more than there is..");g=g.next_cl}j.push(e._encode())}return j},f.prototype.replaceText=function(b){var c;if(null!=this.replace_manager)return c=a.addOperation(new f(a.getNextOperationIdentifier())).execute(),c.insertText(0,b),this.replace_manager.replace(c);throw new Error("This type is currently not maintained by a ReplaceManager!")},f.prototype.val=function(){var a,b;return a=function(){var a,c,d,e;for(d=this.toArray(),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(null!=b.val?b.val():"");return e}.call(this),a.join("")},f.prototype.setReplaceManager=function(a){return this.saveOperation("replace_manager",a),this.validateSavedOperations},f.prototype._encode=function(){var a;return a={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},f}(i.ListManager),g.Word=function(a){var b,c,d,e,g,h;return h=a.uid,b=a.beginning,c=a.end,g=a.prev,d=a.next,e=a.origin,new f(h,void 0,b,c,g,d,e)},i.TextInsert=d,i.TextDelete=b,i.Word=f,h}},{"./StructuredTypes.coffee":7}]},{},[3,1]),!function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};a[g][0].call(j.exports,function(b){var c=a[g][1][b];return e(c?c:b)},j,j.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){var c;c=function(a){var b,c,d,e,f,g,h;return f={},c=new DUIClient,c.connect(function(a){var b;return null!=(b=f[a.action])?b.map(function(b){return setTimeout(function(){return b(a)},0)}):void 0}),c.initOK(),h=null,g=null,b=function(){function a(a,b,d,e){var i,j,k;this.engine=a,this.HB=b,this.execution_listener=d,this.yatta=e,this.duiClient=c,this.iwcHandler=f,k=function(a){return function(b){return a.send(b)}}(this),this.execution_listener.push(k),i=function(a){return function(b){var c;return c=b.extras,a.receive(c)}}(this),this.iwcHandler.Yatta_new_operation=[i],null!=h&&this.engine.applyOps(g),j=function(a){return function(){var b;return b={root_element:a.yatta.getRootElement(),HB:a.yatta.getHistoryBuffer()._encode()},a.sendIwcIntent("Yatta_push_root_element",b)}}(this),this.iwcHandler.Yatta_get_root_element=[j]}return a.prototype.getRootElement=function(){return h},a.prototype.send=function(a){return a.uid.creator===this.HB.getUserId()&&"string"!=typeof a.uid.op_number?this.sendIwcIntent("Yatta_new_operation",a):void 0},a.prototype.receive=function(a){return a.uid.creator!==this.HB.getUserId()?this.engine.applyOp(a):void 0},a.prototype.sendIwcIntent=function(a,b){var c;return c={action:a,component:"",data:"",dataType:"",extras:b},this.duiClient.sendIntent(c)},a.prototype.sync=function(){throw new Error("Can't use this a.t.m.")},a}(),d={action:"Yatta_get_root_element",component:"",data:"",dataType:"",extras:{}},e=function(){var e,i;return c.sendIntent(d),e=!1,i=function(d){var f;return f=c.getIwcClient()._componentName,h=null!=d?d.extras.root_element:void 0,g=null!=d?d.extras.HB:void 0,e?void 0:(e=!0,a(b,f))},f.Yatta_push_root_element=[i],setTimeout(i,800)},void setTimeout(e,4e3*Math.random())},b.exports=c,"undefined"!=typeof window&&null!==window&&(window.createConnector=c)},{}],2:[function(a,b){var c;c=function(){function a(a,b){this.HB=a,this.parser=b,this.unprocessed_ops=[]}return a.prototype.parseOperation=function(a){var b;if(b=this.parser[a.type],null!=b)return b(a);throw new Error("You forgot to specify a parser for type "+a.type+". The message is "+JSON.stringify(a)+".")},a.prototype.applyOps=function(a){var b,c,d,e,f,g,h,i;for(c=[],d=0,g=a.length;g>d;d++)b=a[d],c.push(this.parseOperation(b));for(e=0,h=c.length;h>e;e++)b=c[e],this.HB.addOperation(b);for(f=0,i=c.length;i>f;f++)b=c[f],b.execute()||this.unprocessed_ops.push(b);return this.tryUnprocessed()},a.prototype.applyOp=function(a){var b;return b=this.parseOperation(a),this.HB.addOperation(b),b.execute()||this.unprocessed_ops.push(b),this.tryUnprocessed()},a.prototype.tryUnprocessed=function(){var a,b,c,d,e,f,g;for(g=[];;){for(a=this.unprocessed_ops.length,c=[],f=this.unprocessed_ops,d=0,e=f.length;e>d;d++)b=f[d],b.execute()||c.push(b);if(this.unprocessed_ops=c,this.unprocessed_ops.length===a)break;g.push(void 0)}return g},a}(),b.exports=c},{}],3:[function(a,b){var c,d,e,f;f=a("../Types/JsonTypes.coffee"),d=a("../HistoryBuffer.coffee"),c=a("../Engine.coffee"),e=function(){function a(a,b){var e,g,h;this.HB=new d(a),g=f(this.HB),this.engine=new c(this.HB,g.parser),this.connector=new b(this.engine,this.HB,g.execution_listener,this),h=this.connector.getRootElement(),null==h?(e=new g.types.JsonType(this.HB.getNextOperationIdentifier()),this.HB.addOperation(e),e.execute(),this.root_element=e):this.root_element=this.HB.getOperation(h)}return a.prototype.getRootElement=function(){return this.root_element},a.prototype.getEngine=function(){return this.engine},a.prototype.getConnector=function(){return this.connector},a.prototype.getHistoryBuffer=function(){return this.HB},a.prototype.setMutableDefault=function(a){return this.root_element.setMutableDefault(a)},a.prototype.getUserId=function(){return this.HB.getUserId()},a.prototype.val=function(a,b,c){return this.root_element.val(a,b,c)},Object.defineProperty(a.prototype,"value",{get:function(){return this.root_element.value},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),a}(),"undefined"!=typeof window&&null!==window&&(window.JsonYatta=e),b.exports=e},{"../Engine.coffee":2,"../HistoryBuffer.coffee":4,"../Types/JsonTypes.coffee":6}],4:[function(a,b){var c;c=function(){function a(a){this.user_id=a,this.operation_counter={},this.buffer={},this.change_listeners=[]}return a.prototype.getUserId=function(){return this.user_id},a.prototype.getOperationCounter=function(){var a,b,c,d;b={},d=this.operation_counter;for(c in d)a=d[c],b[c]=a;return b},a.prototype._encode=function(){var a,b,c,d,e,f;a=[],f=this.buffer;for(d in f){e=f[d];for(c in e)b=e[c],isNaN(parseInt(c))||a.push(b._encode())}return a},a.prototype.getNextOperationIdentifier=function(a){var b;return null==a&&(a=this.user_id),null==this.operation_counter[a]&&(this.operation_counter[a]=0),b={creator:a,op_number:this.operation_counter[a]},this.operation_counter[a]++,b},a.prototype.getOperation=function(a){var b;if(a instanceof Object)return null!=(b=this.buffer[a.creator])?b[a.op_number]:void 0;if(null!=a)throw new Error("This type of uid is not defined!")},a.prototype.addOperation=function(a){if(null==this.buffer[a.creator]&&(this.buffer[a.creator]={}),null==this.operation_counter[a.creator]&&(this.operation_counter[a.creator]=0),null!=this.buffer[a.creator][a.op_number])throw new Error("You must not overwrite operations!");return this.buffer[a.creator][a.op_number]=a,"number"==typeof a.op_number&&a.creator!==this.getUserId()&&this.operation_counter[a.creator]++,a},a}(),b.exports=c},{}],5:[function(a,b){var c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};b.exports=function(a){var b,c,e,f,g,h,i;return i={},h=[],g=function(){function b(b){null==b&&(b=a.getNextOperationIdentifier()),this.creator=b.creator,this.op_number=b.op_number}return b.prototype.getUid=function(){return{creator:this.creator,op_number:this.op_number}},b.prototype.execute=function(){var a,b,c;for(this.is_executed=!0,b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this},b.prototype.saveOperation=function(a,b){return null!=(null!=b?b.execute:void 0)?this[a]=b:null!=b?(null==this.unchecked&&(this.unchecked={}),this.unchecked[a]=b):void 0},b.prototype.validateSavedOperations=function(){var b,c,d,e,f,g;f={},e=this,g=this.unchecked;for(b in g)d=g[b],c=a.getOperation(d),c?this[b]=c:(f[b]=d,e=!1);return delete this.unchecked,e||(this.unchecked=f),e},b}(),b=function(a){function b(a,c){this.saveOperation("deletes",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype._encode=function(){return{type:"Delete",uid:this.getUid(),deletes:this.deletes.getUid()}},b.prototype.execute=function(){return this.validateSavedOperations()?(this.deletes.applyDelete(this),b.__super__.execute.apply(this,arguments),this):!1},b}(g),i.Delete=function(a){var c,d;return d=a.uid,c=a.deletes,new b(d,c)},f=function(a){function b(a,c,d,e){this.saveOperation("prev_cl",c),this.saveOperation("next_cl",d),null!=e?this.saveOperation("origin",e):this.saveOperation("origin",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype.applyDelete=function(a){return null==this.deleted_by&&(this.deleted_by=[]),this.deleted_by.push(a)},b.prototype.isDeleted=function(){var a;return(null!=(a=this.deleted_by)?a.length:void 0)>0},b.prototype.getDistanceToOrigin=function(){var a,b;for(a=0,b=this.prev_cl;this.origin!==b;){if(a++,this===this.prev_cl)throw new Error("this should not happen ;) ");b=b.prev_cl}return a},b.prototype.update_sl=function(){var a;return a=this.prev_cl,update("prev_cl","prev_sl"),update("next_cl","prev_sl")},b.prototype.execute=function(){var a,c,d,e,f;if(null!=this.is_executed)return this;if(this.validateSavedOperations()){if((null!=(e=this.prev_cl)?e.validateSavedOperations():void 0)&&(null!=(f=this.next_cl)?f.validateSavedOperations():void 0)&&this.prev_cl.next_cl!==this){for(a=0,d=this.prev_cl.next_cl,c=0;null==d&&(console.log(JSON.stringify(this.prev_cl.getUid())),console.log(JSON.stringify(this.next_cl.getUid()))),d!==this.next_cl;){if(d.getDistanceToOrigin()===c)d.creator<this.creator&&(this.prev_cl=d,a=c+1);else{if(!(d.getDistanceToOrigin()<c))break;c-a<=d.getDistanceToOrigin()&&(this.prev_cl=d,a=c+1)}c++,d=d.next_cl}this.next_cl=this.prev_cl.next_cl,this.prev_cl.next_cl=this,this.next_cl.prev_cl=this}return b.__super__.execute.apply(this,arguments),this}return!1},b}(g),e=function(a){function b(a,c,d,e,f){this.content=null!=c?c:"",b.__super__.constructor.call(this,a,d,e,f)}return d(b,a),b.prototype.val=function(){return this.content},b.prototype._encode=function(){var a;return a={type:"ImmutableObject",uid:this.getUid(),content:this.content},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(f),i.ImmutableObject=function(a){var b,c,d,f,g;return g=a.uid,b=a.content,f=a.prev,c=a.next,d=a.origin,new e(g,b,f,c,d)},c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return d(b,a),b.prototype.execute=function(){var a,b,c;if(this.validateSavedOperations()){for(b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this}return!1},b.prototype._encode=function(){var a,b;return{type:"Delimiter",uid:this.getUid(),prev:null!=(a=this.prev_cl)?a.getUid():void 0,next:null!=(b=this.next_cl)?b.getUid():void 0}},b}(f),i.Delimiter=function(a){var b,d,e;return e=a.uid,d=a.prev,b=a.next,new c(e,d,b)},{types:{Delete:b,Insert:f,Delimiter:c,Operation:g,ImmutableObject:e},parser:i,execution_listener:h}}},{}],6:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./TextTypes.coffee"),b.exports=function(a){var b,d,f,g,h;return g=c(a),h=g.types,f=g.parser,d=function(a){var c;return new(c=function(){function a(c){var e,f,g,i;i=c.map,g=function(e,f){return Object.defineProperty(a.prototype,e,{get:function(){var a;return a=f.val(),a instanceof b?d(a):a instanceof h.ImmutableObject?a.val():a},set:function(a){var b,d,f,g;if(a.constructor==={}.constructor){f=c.val(e),g=[];for(b in a)d=a[b],g.push(f.val(b,d,"immutable"));return g}return c.val(e,a,"immutable")},enumerable:!0,configurable:!1})};for(e in i)f=i[e],g(e,f)}return a}())(a)},b=function(b){function c(a,b,d){var e,f;if(c.__super__.constructor.call(this,a),null!=b){if("object"!=typeof b)throw new Error("The initial value of JsonTypes must be of type Object! (current type: "+typeof b+")");for(e in b)f=b[e],this.val(e,f,d)}}return e(c,b),c.prototype.mutable_default=!0,c.prototype.setMutableDefault=function(a){if(a===!0||"mutable"===a)c.prototype.mutable_default=!0;else{if(a!==!1&&"immutable"!==a)throw new Error('Set mutable either "mutable" or "immutable"!');c.prototype.mutable_default=!1}return"OK"},c.prototype.val=function(b,d,e){var f,g,i,j,k;if("object"==typeof b){for(i in b)g=b[i],this.val(i,g,d);return this
}if(null!=b&&null!=d){if(e=null!=e?e===!0||"mutable"===e?!0:!1:this.mutable_default,"function"==typeof d)return this;if(e&&"number"!=typeof d||d.constructor===Object){if("string"==typeof d)return k=a.addOperation(new h.Word(a.getNextOperationIdentifier(),d)).execute(),c.__super__.val.call(this,b,k);if(d.constructor===Object)return f=a.addOperation(new c(a.getNextOperationIdentifier(),d,e)).execute(),c.__super__.val.call(this,b,f);throw new Error("You must not set "+typeof d+"-types in collaborative Json-objects!")}return j=a.addOperation(new h.ImmutableObject(void 0,d)).execute(),c.__super__.val.call(this,b,j)}return c.__super__.val.call(this,b,d)},Object.defineProperty(c.prototype,"value",{get:function(){return d(this)},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),c.prototype._encode=function(){return{type:"JsonType",uid:this.getUid()}},c}(h.MapManager),f.JsonType=function(a){var c;return c=a.uid,new b(c)},h.JsonType=b,g}},{"./TextTypes.coffee":8}],7:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./BasicTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i,j,k;return i=c(a),k=i.types,j=i.parser,f=function(c){function d(a){this.map={},d.__super__.constructor.call(this,a)}return e(d,c),d.prototype.val=function(c,e){var f,g,h,i,j;if(null!=e)return null==this.map[c]&&a.addOperation(new b(a.getNextOperationIdentifier(),this,c)).execute(),this.map[c].replace(e),this;if(null!=c)return g=null!=(i=this.map[c])?i.val():void 0,g instanceof k.ImmutableObject?g.val():g;h={},j=this.map;for(c in j)f=j[c],g=f.val(),(g instanceof k.ImmutableObject||g instanceof d)&&(g=g.val()),h[c]=g;return h},d}(k.Operation),b=function(b){function c(a,b,d){this.name=d,this.saveOperation("map_manager",b),c.__super__.constructor.call(this,a)}return e(c,b),c.prototype.execute=function(){var b,d,e,f,h;return this.validateSavedOperations()?(h=this.map_manager.getUid(),h.op_number="_"+h.op_number+"_RM_"+this.name,null==a.getOperation(h)&&(e=this.map_manager.getUid(),e.op_number="_"+e.op_number+"_RM_"+this.name+"_beginning",f=this.map_manager.getUid(),f.op_number="_"+f.op_number+"_RM_"+this.name+"_end",b=a.addOperation(new k.Delimiter(e,void 0,f)),d=a.addOperation(new k.Delimiter(f,b,void 0)).execute(),b.execute(),this.map_manager.map[this.name]=a.addOperation(new g(void 0,h,b,d)).execute()),c.__super__.execute.apply(this,arguments)):!1},c.prototype._encode=function(){return{type:"AddName",uid:this.getUid(),map_manager:this.map_manager.getUid(),name:this.name}},c}(k.Operation),j.AddName=function(a){var c,d,e;return c=a.map_manager,e=a.uid,d=a.name,new b(e,c,d)},d=function(b){function c(b,d,e,f,g,h){null!=d&&null!=e?(this.saveOperation("beginning",d),this.saveOperation("end",e)):(this.beginning=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),void 0,void 0)),this.end=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),this.beginning,void 0)),this.beginning.next_cl=this.end,this.beginning.execute(),this.end.execute()),c.__super__.constructor.call(this,b,f,g,h)}return e(c,b),c.prototype.getLastOperation=function(){return this.end.prev_cl},c.prototype.getFirstOperation=function(){return this.beginning.next_cl},c.prototype.toArray=function(){var a,b;for(a=this.beginning.next_cl,b=[];a!==this.end;)b.push(a),a=a.next_cl;return b},c.prototype.getOperationByPosition=function(a){var b;if(b=this.beginning.next_cl,a>0)for(;b=b.next_cl,b.isDeleted()||(a-=1),0!==a;)if(b instanceof k.Delimiter)throw new Error("position parameter exceeded the length of the document!");return b},c}(k.Insert),g=function(b){function c(a,b,d,e,f,g,h){c.__super__.constructor.call(this,b,d,e,f,g,h),null!=a&&this.replace(a)}return e(c,b),c.prototype.replace=function(b){var c,d;return c=this.getLastOperation(),d=new h(b,this,a.getNextOperationIdentifier(),c,c.next_cl),a.addOperation(d).execute()},c.prototype.val=function(){var a;if(a=this.getLastOperation(),a instanceof k.Delimiter)throw new Error("dtrn");return a.val()},c.prototype._encode=function(){var a;return a={type:"ReplaceManager",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&null!=this.next_cl&&(a.prev=this.prev_cl.getUid(),a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},c}(d),j.ReplaceManager=function(a){var b,c,d,e,f,h,i;return c=a.content,i=a.uid,h=a.prev,e=a.next,f=a.origin,b=a.beginning,d=a.end,new g(c,i,b,d,h,e,f)},h=function(a){function b(a,c,d,e,f,g){if(this.saveOperation("content",a),this.saveOperation("parent",c),null==e||null==f||null==a)throw new Error("You must define content, prev, and next for Replaceable-types!");b.__super__.constructor.call(this,d,e,f,g)}return e(b,a),b.prototype.val=function(){return this.content},b.prototype.replace=function(a){return this.parent.replace(a)},b.prototype.execute=function(){var a;return this.validateSavedOperations()?("function"==typeof(a=this.content).setReplaceManager&&a.setReplaceManager(this.parent),b.__super__.execute.apply(this,arguments),this):!1},b.prototype._encode=function(){var a;return a={type:"Replaceable",content:this.content.getUid(),ReplaceManager:this.parent.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid(),uid:this.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(k.Insert),j.Replaceable=function(a){var b,c,d,e,f,g;return b=a.content,e=a.ReplaceManager,g=a.uid,f=a.prev,c=a.next,d=a.origin,new h(b,e,g,f,c,d)},k.ListManager=d,k.MapManager=f,k.ReplaceManager=g,k.Replaceable=h,i}},{"./BasicTypes.coffee":5}],8:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./StructuredTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i;return h=c(a),i=h.types,g=h.parser,b=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return e(b,a),b}(i.Delete),g.TextDelete=g.Delete,d=function(a){function b(a,c,d,e,f){if(this.content=a,null==d||null==e)throw new Error("You must define prev, and next for TextInsert-types!");b.__super__.constructor.call(this,c,d,e,f)}return e(b,a),b.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},b.prototype.val=function(){return this.isDeleted()?"":this.content},b.prototype._encode=function(){var a;return a={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(i.Insert),g.TextInsert=function(a){var b,c,e,f,g;return b=a.content,g=a.uid,f=a.prev,c=a.next,e=a.origin,new d(b,g,f,c,e)},f=function(c){function f(a,b,c,d,e,g,h){f.__super__.constructor.call(this,a,c,d,e,g,h),null!=b&&this.insertText(0,b)}return e(f,c),f.prototype.insertText=function(b,c){var e,f,g,h,i,j;for(f=this.getOperationByPosition(b),j=[],h=0,i=c.length;i>h;h++)e=c[h],g=new d(e,a.getNextOperationIdentifier(),f.prev_cl,f),j.push(a.addOperation(g).execute());return j},f.prototype.deleteText=function(c,d){var e,f,g,h,j;for(g=this.getOperationByPosition(c),j=[],f=h=0;d>=0?d>h:h>d;f=d>=0?++h:--h){for(e=a.addOperation(new b(a.getNextOperationIdentifier(),g)).execute(),g=g.next_cl;g.isDeleted();){if(g instanceof i.Delimiter)throw new Error("You can't delete more than there is..");g=g.next_cl}j.push(e._encode())}return j},f.prototype.replaceText=function(b){var c;if(null!=this.replace_manager)return c=a.addOperation(new f(a.getNextOperationIdentifier())).execute(),c.insertText(0,b),this.replace_manager.replace(c);throw new Error("This type is currently not maintained by a ReplaceManager!")},f.prototype.val=function(){var a,b;return a=function(){var a,c,d,e;for(d=this.toArray(),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(null!=b.val?b.val():"");return e}.call(this),a.join("")},f.prototype.setReplaceManager=function(a){return this.saveOperation("replace_manager",a),this.validateSavedOperations},f.prototype._encode=function(){var a;return a={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},f}(i.ListManager),g.Word=function(a){var b,c,d,e,g,h;return h=a.uid,b=a.beginning,c=a.end,g=a.prev,d=a.next,e=a.origin,new f(h,void 0,b,c,g,d,e)},i.TextInsert=d,i.TextDelete=b,i.Word=f,h}},{"./StructuredTypes.coffee":7}]},{},[3,1]),!function c(a,b,d){function e(g,h){if(!b[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=b[g]={exports:{}};a[g][0].call(j.exports,function(b){var c=a[g][1][b];return e(c?c:b)},j,j.exports,c,a,b,d)}return b[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){var c;c=function(a){var b,c,d,e,f,g,h;return f={},c=new DUIClient,c.connect(function(a){var b;return null!=(b=f[a.action])?b.map(function(b){return setTimeout(function(){return b(a)},0)}):void 0}),c.initOK(),h=null,g=null,b=function(){function a(a,b,d,e){var i,j,k;this.engine=a,this.HB=b,this.execution_listener=d,this.yatta=e,this.duiClient=c,this.iwcHandler=f,k=function(a){return function(b){return a.send(b)}}(this),this.execution_listener.push(k),i=function(a){return function(b){var c;return c=b.extras,a.receive(c)}}(this),this.iwcHandler.Yatta_new_operation=[i],null!=h&&this.engine.applyOps(g),j=function(a){return function(){var b;return b={root_element:a.yatta.getRootElement(),HB:a.yatta.getHistoryBuffer()._encode()},a.sendIwcIntent("Yatta_push_root_element",b)}}(this),this.iwcHandler.Yatta_get_root_element=[j]}return a.prototype.getRootElement=function(){return h},a.prototype.send=function(a){return a.uid.creator===this.HB.getUserId()&&"string"!=typeof a.uid.op_number?this.sendIwcIntent("Yatta_new_operation",a):void 0},a.prototype.receive=function(a){return a.uid.creator!==this.HB.getUserId()?this.engine.applyOp(a):void 0},a.prototype.sendIwcIntent=function(a,b){var c;return c={action:a,component:"",data:"",dataType:"",extras:b},this.duiClient.sendIntent(c)},a.prototype.sync=function(){throw new Error("Can't use this a.t.m.")},a}(),d={action:"Yatta_get_root_element",component:"",data:"",dataType:"",extras:{}},e=function(){var e,i;return c.sendIntent(d),e=!1,i=function(d){var f;return f=c.getIwcClient()._componentName,h=null!=d?d.extras.root_element:void 0,g=null!=d?d.extras.HB:void 0,e?void 0:(e=!0,a(b,f))},f.Yatta_push_root_element=[i],setTimeout(i,800)},void setTimeout(e,4e3*Math.random())},b.exports=c,"undefined"!=typeof window&&null!==window&&(window.createConnector=c)},{}],2:[function(a,b){var c;c=function(){function a(a,b){this.HB=a,this.parser=b,this.unprocessed_ops=[]}return a.prototype.parseOperation=function(a){var b;if(b=this.parser[a.type],null!=b)return b(a);throw new Error("You forgot to specify a parser for type "+a.type+". The message is "+JSON.stringify(a)+".")},a.prototype.applyOps=function(a){var b,c,d,e,f,g,h,i;for(c=[],d=0,g=a.length;g>d;d++)b=a[d],c.push(this.parseOperation(b));for(e=0,h=c.length;h>e;e++)b=c[e],this.HB.addOperation(b);for(f=0,i=c.length;i>f;f++)b=c[f],b.execute()||this.unprocessed_ops.push(b);return this.tryUnprocessed()},a.prototype.applyOp=function(a){var b;return b=this.parseOperation(a),this.HB.addOperation(b),b.execute()||this.unprocessed_ops.push(b),this.tryUnprocessed()},a.prototype.tryUnprocessed=function(){var a,b,c,d,e,f,g;for(g=[];;){for(a=this.unprocessed_ops.length,c=[],f=this.unprocessed_ops,d=0,e=f.length;e>d;d++)b=f[d],b.execute()||c.push(b);if(this.unprocessed_ops=c,this.unprocessed_ops.length===a)break;g.push(void 0)}return g},a}(),b.exports=c},{}],3:[function(a,b){var c,d,e,f;f=a("../Types/JsonTypes.coffee"),d=a("../HistoryBuffer.coffee"),c=a("../Engine.coffee"),e=function(){function a(a,b){var e,g,h;this.HB=new d(a),g=f(this.HB),this.engine=new c(this.HB,g.parser),this.connector=new b(this.engine,this.HB,g.execution_listener,this),h=this.connector.getRootElement(),null==h?(e=new g.types.JsonType(this.HB.getNextOperationIdentifier()),this.HB.addOperation(e),e.execute(),this.root_element=e):this.root_element=this.HB.getOperation(h)}return a.prototype.getRootElement=function(){return this.root_element},a.prototype.getEngine=function(){return this.engine},a.prototype.getConnector=function(){return this.connector},a.prototype.getHistoryBuffer=function(){return this.HB},a.prototype.setMutableDefault=function(a){return this.root_element.setMutableDefault(a)},a.prototype.getUserId=function(){return this.HB.getUserId()},a.prototype.val=function(a,b,c){return this.root_element.val(a,b,c)},Object.defineProperty(a.prototype,"value",{get:function(){return this.root_element.value},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),a}(),"undefined"!=typeof window&&null!==window&&(window.JsonYatta=e),b.exports=e},{"../Engine.coffee":2,"../HistoryBuffer.coffee":4,"../Types/JsonTypes.coffee":6}],4:[function(a,b){var c;c=function(){function a(a){this.user_id=a,this.operation_counter={},this.buffer={},this.change_listeners=[]}return a.prototype.getUserId=function(){return this.user_id},a.prototype.getOperationCounter=function(){var a,b,c,d;b={},d=this.operation_counter;for(c in d)a=d[c],b[c]=a;return b},a.prototype._encode=function(){var a,b,c,d,e,f;a=[],f=this.buffer;for(d in f){e=f[d];for(c in e)b=e[c],isNaN(parseInt(c))||a.push(b._encode())}return a},a.prototype.getNextOperationIdentifier=function(a){var b;return null==a&&(a=this.user_id),null==this.operation_counter[a]&&(this.operation_counter[a]=0),b={creator:a,op_number:this.operation_counter[a]},this.operation_counter[a]++,b},a.prototype.getOperation=function(a){var b;if(a instanceof Object)return null!=(b=this.buffer[a.creator])?b[a.op_number]:void 0;if(null!=a)throw new Error("This type of uid is not defined!")},a.prototype.addOperation=function(a){if(null==this.buffer[a.creator]&&(this.buffer[a.creator]={}),null==this.operation_counter[a.creator]&&(this.operation_counter[a.creator]=0),null!=this.buffer[a.creator][a.op_number])throw new Error("You must not overwrite operations!");return this.buffer[a.creator][a.op_number]=a,"number"==typeof a.op_number&&a.creator!==this.getUserId()&&this.operation_counter[a.creator]++,a},a}(),b.exports=c},{}],5:[function(a,b){var c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};b.exports=function(a){var b,c,e,f,g,h,i;return i={},h=[],g=function(){function b(b){null==b&&(b=a.getNextOperationIdentifier()),this.creator=b.creator,this.op_number=b.op_number}return b.prototype.getUid=function(){return{creator:this.creator,op_number:this.op_number}},b.prototype.execute=function(){var a,b,c;for(this.is_executed=!0,b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this},b.prototype.saveOperation=function(a,b){return null!=(null!=b?b.execute:void 0)?this[a]=b:null!=b?(null==this.unchecked&&(this.unchecked={}),this.unchecked[a]=b):void 0},b.prototype.validateSavedOperations=function(){var b,c,d,e,f,g;f={},e=this,g=this.unchecked;for(b in g)d=g[b],c=a.getOperation(d),c?this[b]=c:(f[b]=d,e=!1);return delete this.unchecked,e||(this.unchecked=f),e},b}(),b=function(a){function b(a,c){this.saveOperation("deletes",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype._encode=function(){return{type:"Delete",uid:this.getUid(),deletes:this.deletes.getUid()}},b.prototype.execute=function(){return this.validateSavedOperations()?(this.deletes.applyDelete(this),b.__super__.execute.apply(this,arguments),this):!1},b}(g),i.Delete=function(a){var c,d;return d=a.uid,c=a.deletes,new b(d,c)},f=function(a){function b(a,c,d,e){this.saveOperation("prev_cl",c),this.saveOperation("next_cl",d),null!=e?this.saveOperation("origin",e):this.saveOperation("origin",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype.applyDelete=function(a){return null==this.deleted_by&&(this.deleted_by=[]),this.deleted_by.push(a)},b.prototype.isDeleted=function(){var a;return(null!=(a=this.deleted_by)?a.length:void 0)>0},b.prototype.getDistanceToOrigin=function(){var a,b;for(a=0,b=this.prev_cl;this.origin!==b;){if(a++,this===this.prev_cl)throw new Error("this should not happen ;) ");b=b.prev_cl}return a},b.prototype.update_sl=function(){var a;return a=this.prev_cl,update("prev_cl","prev_sl"),update("next_cl","prev_sl")},b.prototype.execute=function(){var a,c,d,e,f;if(null!=this.is_executed)return this;if(this.validateSavedOperations()){if((null!=(e=this.prev_cl)?e.validateSavedOperations():void 0)&&(null!=(f=this.next_cl)?f.validateSavedOperations():void 0)&&this.prev_cl.next_cl!==this){for(a=0,d=this.prev_cl.next_cl,c=0;null==d&&(console.log(JSON.stringify(this.prev_cl.getUid())),console.log(JSON.stringify(this.next_cl.getUid()))),d!==this.next_cl;){if(d.getDistanceToOrigin()===c)d.creator<this.creator&&(this.prev_cl=d,a=c+1);else{if(!(d.getDistanceToOrigin()<c))break;c-a<=d.getDistanceToOrigin()&&(this.prev_cl=d,a=c+1)}c++,d=d.next_cl}this.next_cl=this.prev_cl.next_cl,this.prev_cl.next_cl=this,this.next_cl.prev_cl=this}return b.__super__.execute.apply(this,arguments),this}return!1},b}(g),e=function(a){function b(a,c,d,e,f){this.content=null!=c?c:"",b.__super__.constructor.call(this,a,d,e,f)}return d(b,a),b.prototype.val=function(){return this.content},b.prototype._encode=function(){var a;return a={type:"ImmutableObject",uid:this.getUid(),content:this.content},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(f),i.ImmutableObject=function(a){var b,c,d,f,g;return g=a.uid,b=a.content,f=a.prev,c=a.next,d=a.origin,new e(g,b,f,c,d)},c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return d(b,a),b.prototype.execute=function(){var a,b,c;if(this.validateSavedOperations()){for(b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this}return!1},b.prototype._encode=function(){var a,b;return{type:"Delimiter",uid:this.getUid(),prev:null!=(a=this.prev_cl)?a.getUid():void 0,next:null!=(b=this.next_cl)?b.getUid():void 0}},b}(f),i.Delimiter=function(a){var b,d,e;return e=a.uid,d=a.prev,b=a.next,new c(e,d,b)},{types:{Delete:b,Insert:f,Delimiter:c,Operation:g,ImmutableObject:e},parser:i,execution_listener:h}}},{}],6:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./TextTypes.coffee"),b.exports=function(a){var b,d,f,g,h;return g=c(a),h=g.types,f=g.parser,d=function(a){var c;return new(c=function(){function a(c){var e,f,g,i;i=c.map,g=function(e,f){return Object.defineProperty(a.prototype,e,{get:function(){var a;return a=f.val(),a instanceof b?d(a):a instanceof h.ImmutableObject?a.val():a},set:function(a){var b,d,f,g;if(a.constructor==={}.constructor){f=c.val(e),g=[];for(b in a)d=a[b],g.push(f.val(b,d,"immutable"));return g}return c.val(e,a,"immutable")},enumerable:!0,configurable:!1})};for(e in i)f=i[e],g(e,f)}return a}())(a)},b=function(b){function c(a,b,d){var e,f;if(c.__super__.constructor.call(this,a),null!=b){if("object"!=typeof b)throw new Error("The initial value of JsonTypes must be of type Object! (current type: "+typeof b+")");for(e in b)f=b[e],this.val(e,f,d)}}return e(c,b),c.prototype.mutable_default=!0,c.prototype.setMutableDefault=function(a){if(a===!0||"mutable"===a)c.prototype.mutable_default=!0;else{if(a!==!1&&"immutable"!==a)throw new Error('Set mutable either "mutable" or "immutable"!');c.prototype.mutable_default=!1}return"OK"},c.prototype.val=function(b,d,e){var f,g,i,j,k;if("object"==typeof b){for(i in b)g=b[i],this.val(i,g,d);return this}if(null!=b&&null!=d){if(e=null!=e?e===!0||"mutable"===e?!0:!1:this.mutable_default,"function"==typeof d)return this;if(e&&"number"!=typeof d||d.constructor===Object){if("string"==typeof d)return k=a.addOperation(new h.Word(a.getNextOperationIdentifier(),d)).execute(),c.__super__.val.call(this,b,k);if(d.constructor===Object)return f=a.addOperation(new c(a.getNextOperationIdentifier(),d,e)).execute(),c.__super__.val.call(this,b,f);throw new Error("You must not set "+typeof d+"-types in collaborative Json-objects!")}return j=a.addOperation(new h.ImmutableObject(void 0,d)).execute(),c.__super__.val.call(this,b,j)}return c.__super__.val.call(this,b,d)},Object.defineProperty(c.prototype,"value",{get:function(){return d(this)},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),c.prototype._encode=function(){return{type:"JsonType",uid:this.getUid()}},c}(h.MapManager),f.JsonType=function(a){var c;return c=a.uid,new b(c)},h.JsonType=b,g}},{"./TextTypes.coffee":8}],7:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./BasicTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i,j,k;return i=c(a),k=i.types,j=i.parser,f=function(c){function d(a){this.map={},d.__super__.constructor.call(this,a)}return e(d,c),d.prototype.val=function(c,e){var f,g,h,i,j;if(null!=e)return null==this.map[c]&&a.addOperation(new b(a.getNextOperationIdentifier(),this,c)).execute(),this.map[c].replace(e),this;if(null!=c)return g=null!=(i=this.map[c])?i.val():void 0,g instanceof k.ImmutableObject?g.val():g;h={},j=this.map;for(c in j)f=j[c],g=f.val(),(g instanceof k.ImmutableObject||g instanceof d)&&(g=g.val()),h[c]=g;return h},d}(k.Operation),b=function(b){function c(a,b,d){this.name=d,this.saveOperation("map_manager",b),c.__super__.constructor.call(this,a)}return e(c,b),c.prototype.execute=function(){var b,d,e,f,h;return this.validateSavedOperations()?(h=this.map_manager.getUid(),h.op_number="_"+h.op_number+"_RM_"+this.name,null==a.getOperation(h)&&(e=this.map_manager.getUid(),e.op_number="_"+e.op_number+"_RM_"+this.name+"_beginning",f=this.map_manager.getUid(),f.op_number="_"+f.op_number+"_RM_"+this.name+"_end",b=a.addOperation(new k.Delimiter(e,void 0,f)),d=a.addOperation(new k.Delimiter(f,b,void 0)).execute(),b.execute(),this.map_manager.map[this.name]=a.addOperation(new g(void 0,h,b,d)).execute()),c.__super__.execute.apply(this,arguments)):!1},c.prototype._encode=function(){return{type:"AddName",uid:this.getUid(),map_manager:this.map_manager.getUid(),name:this.name}},c}(k.Operation),j.AddName=function(a){var c,d,e;return c=a.map_manager,e=a.uid,d=a.name,new b(e,c,d)},d=function(b){function c(b,d,e,f,g,h){null!=d&&null!=e?(this.saveOperation("beginning",d),this.saveOperation("end",e)):(this.beginning=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),void 0,void 0)),this.end=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),this.beginning,void 0)),this.beginning.next_cl=this.end,this.beginning.execute(),this.end.execute()),c.__super__.constructor.call(this,b,f,g,h)}return e(c,b),c.prototype.getLastOperation=function(){return this.end.prev_cl},c.prototype.getFirstOperation=function(){return this.beginning.next_cl},c.prototype.toArray=function(){var a,b;for(a=this.beginning.next_cl,b=[];a!==this.end;)b.push(a),a=a.next_cl;return b},c.prototype.getOperationByPosition=function(a){var b;if(b=this.beginning.next_cl,a>0)for(;b=b.next_cl,b.isDeleted()||(a-=1),0!==a;)if(b instanceof k.Delimiter)throw new Error("position parameter exceeded the length of the document!");return b},c}(k.Insert),g=function(b){function c(a,b,d,e,f,g,h){c.__super__.constructor.call(this,b,d,e,f,g,h),null!=a&&this.replace(a)}return e(c,b),c.prototype.replace=function(b){var c,d;return c=this.getLastOperation(),d=new h(b,this,a.getNextOperationIdentifier(),c,c.next_cl),a.addOperation(d).execute()},c.prototype.val=function(){var a;if(a=this.getLastOperation(),a instanceof k.Delimiter)throw new Error("dtrn");return a.val()},c.prototype._encode=function(){var a;return a={type:"ReplaceManager",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&null!=this.next_cl&&(a.prev=this.prev_cl.getUid(),a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},c}(d),j.ReplaceManager=function(a){var b,c,d,e,f,h,i;return c=a.content,i=a.uid,h=a.prev,e=a.next,f=a.origin,b=a.beginning,d=a.end,new g(c,i,b,d,h,e,f)},h=function(a){function b(a,c,d,e,f,g){if(this.saveOperation("content",a),this.saveOperation("parent",c),null==e||null==f||null==a)throw new Error("You must define content, prev, and next for Replaceable-types!");b.__super__.constructor.call(this,d,e,f,g)}return e(b,a),b.prototype.val=function(){return this.content},b.prototype.replace=function(a){return this.parent.replace(a)},b.prototype.execute=function(){var a;return this.validateSavedOperations()?("function"==typeof(a=this.content).setReplaceManager&&a.setReplaceManager(this.parent),b.__super__.execute.apply(this,arguments),this):!1},b.prototype._encode=function(){var a;return a={type:"Replaceable",content:this.content.getUid(),ReplaceManager:this.parent.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid(),uid:this.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(k.Insert),j.Replaceable=function(a){var b,c,d,e,f,g;return b=a.content,e=a.ReplaceManager,g=a.uid,f=a.prev,c=a.next,d=a.origin,new h(b,e,g,f,c,d)},k.ListManager=d,k.MapManager=f,k.ReplaceManager=g,k.Replaceable=h,i}},{"./BasicTypes.coffee":5}],8:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./StructuredTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i;return h=c(a),i=h.types,g=h.parser,b=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return e(b,a),b}(i.Delete),g.TextDelete=g.Delete,d=function(a){function b(a,c,d,e,f){if(this.content=a,null==d||null==e)throw new Error("You must define prev, and next for TextInsert-types!");b.__super__.constructor.call(this,c,d,e,f)}return e(b,a),b.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},b.prototype.val=function(){return this.isDeleted()?"":this.content},b.prototype._encode=function(){var a;return a={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(i.Insert),g.TextInsert=function(a){var b,c,e,f,g;return b=a.content,g=a.uid,f=a.prev,c=a.next,e=a.origin,new d(b,g,f,c,e)},f=function(c){function f(a,b,c,d,e,g,h){f.__super__.constructor.call(this,a,c,d,e,g,h),null!=b&&this.insertText(0,b)}return e(f,c),f.prototype.insertText=function(b,c){var e,f,g,h,i,j;for(f=this.getOperationByPosition(b),j=[],h=0,i=c.length;i>h;h++)e=c[h],g=new d(e,a.getNextOperationIdentifier(),f.prev_cl,f),j.push(a.addOperation(g).execute());return j},f.prototype.deleteText=function(c,d){var e,f,g,h,j;for(g=this.getOperationByPosition(c),j=[],f=h=0;d>=0?d>h:h>d;f=d>=0?++h:--h){for(e=a.addOperation(new b(a.getNextOperationIdentifier(),g)).execute(),g=g.next_cl;g.isDeleted();){if(g instanceof i.Delimiter)throw new Error("You can't delete more than there is..");g=g.next_cl}j.push(e._encode())}return j},f.prototype.replaceText=function(b){var c;if(null!=this.replace_manager)return c=a.addOperation(new f(a.getNextOperationIdentifier())).execute(),c.insertText(0,b),this.replace_manager.replace(c);throw new Error("This type is currently not maintained by a ReplaceManager!")},f.prototype.val=function(){var a,b;return a=function(){var a,c,d,e;for(d=this.toArray(),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(null!=b.val?b.val():"");return e}.call(this),a.join("")},f.prototype.setReplaceManager=function(a){return this.saveOperation("replace_manager",a),this.validateSavedOperations},f.prototype._encode=function(){var a;return a={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},f}(i.ListManager),g.Word=function(a){var b,c,d,e,g,h;return h=a.uid,b=a.beginning,c=a.end,g=a.prev,d=a.next,e=a.origin,new f(h,void 0,b,c,g,d,e)},i.TextInsert=d,i.TextDelete=b,i.Word=f,h}},{"./StructuredTypes.coffee":7}]},{},[3,1]),!function d(a,b,c){function e(g,h){if(!b[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=b[g]={exports:{}};a[g][0].call(j.exports,function(b){var c=a[g][1][b];return e(c?c:b)},j,j.exports,d,a,b,c)}return b[g].exports}for(var f="function"==typeof require&&require,g=0;g<c.length;g++)e(c[g]);return e}({1:[function(a,b){var c;c=function(a){var b,c,d,e,f,g,h;return f={},c=new DUIClient,c.connect(function(a){var b;return null!=(b=f[a.action])?b.map(function(b){return setTimeout(function(){return b(a)},0)}):void 0}),c.initOK(),h=null,g=null,b=function(){function a(a,b,d,e){var i,j,k;this.engine=a,this.HB=b,this.execution_listener=d,this.yatta=e,this.duiClient=c,this.iwcHandler=f,k=function(a){return function(b){return a.send(b)}}(this),this.execution_listener.push(k),i=function(a){return function(b){var c;return c=b.extras,a.receive(c)}}(this),this.iwcHandler.Yatta_new_operation=[i],null!=h&&this.engine.applyOps(g),j=function(a){return function(){var b;return b={root_element:a.yatta.getRootElement(),HB:a.yatta.getHistoryBuffer()._encode()},a.sendIwcIntent("Yatta_push_root_element",b)}}(this),this.iwcHandler.Yatta_get_root_element=[j]}return a.prototype.getRootElement=function(){return h},a.prototype.send=function(a){return a.uid.creator===this.HB.getUserId()&&"string"!=typeof a.uid.op_number?this.sendIwcIntent("Yatta_new_operation",a):void 0},a.prototype.receive=function(a){return a.uid.creator!==this.HB.getUserId()?this.engine.applyOp(a):void 0},a.prototype.sendIwcIntent=function(a,b){var c;return c={action:a,component:"",data:"",dataType:"",extras:b},this.duiClient.sendIntent(c)},a.prototype.sync=function(){throw new Error("Can't use this a.t.m.")},a}(),d={action:"Yatta_get_root_element",component:"",data:"",dataType:"",extras:{}},e=function(){var e,i;return c.sendIntent(d),e=!1,i=function(d){var f;return f=c.getIwcClient()._componentName,h=null!=d?d.extras.root_element:void 0,g=null!=d?d.extras.HB:void 0,e?void 0:(e=!0,a(b,f))},f.Yatta_push_root_element=[i],setTimeout(i,800)},void setTimeout(e,4e3*Math.random())},b.exports=c,"undefined"!=typeof window&&null!==window&&(window.createConnector=c)},{}],2:[function(a,b){var c;c=function(){function a(a,b){this.HB=a,this.parser=b,this.unprocessed_ops=[]}return a.prototype.parseOperation=function(a){var b;if(b=this.parser[a.type],null!=b)return b(a);throw new Error("You forgot to specify a parser for type "+a.type+". The message is "+JSON.stringify(a)+".")},a.prototype.applyOps=function(a){var b,c,d,e,f,g,h,i;for(c=[],d=0,g=a.length;g>d;d++)b=a[d],c.push(this.parseOperation(b));for(e=0,h=c.length;h>e;e++)b=c[e],this.HB.addOperation(b);for(f=0,i=c.length;i>f;f++)b=c[f],b.execute()||this.unprocessed_ops.push(b);
return this.tryUnprocessed()},a.prototype.applyOp=function(a){var b;return b=this.parseOperation(a),this.HB.addOperation(b),b.execute()||this.unprocessed_ops.push(b),this.tryUnprocessed()},a.prototype.tryUnprocessed=function(){var a,b,c,d,e,f,g;for(g=[];;){for(a=this.unprocessed_ops.length,c=[],f=this.unprocessed_ops,d=0,e=f.length;e>d;d++)b=f[d],b.execute()||c.push(b);if(this.unprocessed_ops=c,this.unprocessed_ops.length===a)break;g.push(void 0)}return g},a}(),b.exports=c},{}],3:[function(a,b){var c,d,e,f;f=a("../Types/JsonTypes.coffee"),d=a("../HistoryBuffer.coffee"),c=a("../Engine.coffee"),e=function(){function a(a,b){var e,g,h;this.HB=new d(a),g=f(this.HB),this.engine=new c(this.HB,g.parser),this.connector=new b(this.engine,this.HB,g.execution_listener,this),h=this.connector.getRootElement(),null==h?(e=new g.types.JsonType(this.HB.getNextOperationIdentifier()),this.HB.addOperation(e),e.execute(),this.root_element=e):this.root_element=this.HB.getOperation(h)}return a.prototype.getRootElement=function(){return this.root_element},a.prototype.getEngine=function(){return this.engine},a.prototype.getConnector=function(){return this.connector},a.prototype.getHistoryBuffer=function(){return this.HB},a.prototype.setMutableDefault=function(a){return this.root_element.setMutableDefault(a)},a.prototype.getUserId=function(){return this.HB.getUserId()},a.prototype.val=function(a,b,c){return this.root_element.val(a,b,c)},Object.defineProperty(a.prototype,"value",{get:function(){return this.root_element.value},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),a}(),"undefined"!=typeof window&&null!==window&&(window.JsonYatta=e),b.exports=e},{"../Engine.coffee":2,"../HistoryBuffer.coffee":4,"../Types/JsonTypes.coffee":6}],4:[function(a,b){var c;c=function(){function a(a){this.user_id=a,this.operation_counter={},this.buffer={},this.change_listeners=[]}return a.prototype.getUserId=function(){return this.user_id},a.prototype.getOperationCounter=function(){var a,b,c,d;b={},d=this.operation_counter;for(c in d)a=d[c],b[c]=a;return b},a.prototype._encode=function(){var a,b,c,d,e,f;a=[],f=this.buffer;for(d in f){e=f[d];for(c in e)b=e[c],isNaN(parseInt(c))||a.push(b._encode())}return a},a.prototype.getNextOperationIdentifier=function(a){var b;return null==a&&(a=this.user_id),null==this.operation_counter[a]&&(this.operation_counter[a]=0),b={creator:a,op_number:this.operation_counter[a]},this.operation_counter[a]++,b},a.prototype.getOperation=function(a){var b;if(a instanceof Object)return null!=(b=this.buffer[a.creator])?b[a.op_number]:void 0;if(null!=a)throw new Error("This type of uid is not defined!")},a.prototype.addOperation=function(a){if(null==this.buffer[a.creator]&&(this.buffer[a.creator]={}),null==this.operation_counter[a.creator]&&(this.operation_counter[a.creator]=0),null!=this.buffer[a.creator][a.op_number])throw new Error("You must not overwrite operations!");return this.buffer[a.creator][a.op_number]=a,"number"==typeof a.op_number&&a.creator!==this.getUserId()&&this.operation_counter[a.creator]++,a},a}(),b.exports=c},{}],5:[function(a,b){var c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};b.exports=function(a){var b,c,e,f,g,h,i;return i={},h=[],g=function(){function b(b){null==b&&(b=a.getNextOperationIdentifier()),this.creator=b.creator,this.op_number=b.op_number}return b.prototype.getUid=function(){return{creator:this.creator,op_number:this.op_number}},b.prototype.execute=function(){var a,b,c;for(this.is_executed=!0,b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this},b.prototype.saveOperation=function(a,b){return null!=(null!=b?b.execute:void 0)?this[a]=b:null!=b?(null==this.unchecked&&(this.unchecked={}),this.unchecked[a]=b):void 0},b.prototype.validateSavedOperations=function(){var b,c,d,e,f,g;f={},e=this,g=this.unchecked;for(b in g)d=g[b],c=a.getOperation(d),c?this[b]=c:(f[b]=d,e=!1);return delete this.unchecked,e||(this.unchecked=f),e},b}(),b=function(a){function b(a,c){this.saveOperation("deletes",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype._encode=function(){return{type:"Delete",uid:this.getUid(),deletes:this.deletes.getUid()}},b.prototype.execute=function(){return this.validateSavedOperations()?(this.deletes.applyDelete(this),b.__super__.execute.apply(this,arguments),this):!1},b}(g),i.Delete=function(a){var c,d;return d=a.uid,c=a.deletes,new b(d,c)},f=function(a){function b(a,c,d,e){this.saveOperation("prev_cl",c),this.saveOperation("next_cl",d),null!=e?this.saveOperation("origin",e):this.saveOperation("origin",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype.applyDelete=function(a){return null==this.deleted_by&&(this.deleted_by=[]),this.deleted_by.push(a)},b.prototype.isDeleted=function(){var a;return(null!=(a=this.deleted_by)?a.length:void 0)>0},b.prototype.getDistanceToOrigin=function(){var a,b;for(a=0,b=this.prev_cl;this.origin!==b;){if(a++,this===this.prev_cl)throw new Error("this should not happen ;) ");b=b.prev_cl}return a},b.prototype.update_sl=function(){var a;return a=this.prev_cl,update("prev_cl","prev_sl"),update("next_cl","prev_sl")},b.prototype.execute=function(){var a,c,d,e,f;if(null!=this.is_executed)return this;if(this.validateSavedOperations()){if((null!=(e=this.prev_cl)?e.validateSavedOperations():void 0)&&(null!=(f=this.next_cl)?f.validateSavedOperations():void 0)&&this.prev_cl.next_cl!==this){for(a=0,d=this.prev_cl.next_cl,c=0;null==d&&(console.log(JSON.stringify(this.prev_cl.getUid())),console.log(JSON.stringify(this.next_cl.getUid()))),d!==this.next_cl;){if(d.getDistanceToOrigin()===c)d.creator<this.creator&&(this.prev_cl=d,a=c+1);else{if(!(d.getDistanceToOrigin()<c))break;c-a<=d.getDistanceToOrigin()&&(this.prev_cl=d,a=c+1)}c++,d=d.next_cl}this.next_cl=this.prev_cl.next_cl,this.prev_cl.next_cl=this,this.next_cl.prev_cl=this}return b.__super__.execute.apply(this,arguments),this}return!1},b}(g),e=function(a){function b(a,c,d,e,f){this.content=null!=c?c:"",b.__super__.constructor.call(this,a,d,e,f)}return d(b,a),b.prototype.val=function(){return this.content},b.prototype._encode=function(){var a;return a={type:"ImmutableObject",uid:this.getUid(),content:this.content},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(f),i.ImmutableObject=function(a){var b,c,d,f,g;return g=a.uid,b=a.content,f=a.prev,c=a.next,d=a.origin,new e(g,b,f,c,d)},c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return d(b,a),b.prototype.execute=function(){var a,b,c;if(this.validateSavedOperations()){for(b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this}return!1},b.prototype._encode=function(){var a,b;return{type:"Delimiter",uid:this.getUid(),prev:null!=(a=this.prev_cl)?a.getUid():void 0,next:null!=(b=this.next_cl)?b.getUid():void 0}},b}(f),i.Delimiter=function(a){var b,d,e;return e=a.uid,d=a.prev,b=a.next,new c(e,d,b)},{types:{Delete:b,Insert:f,Delimiter:c,Operation:g,ImmutableObject:e},parser:i,execution_listener:h}}},{}],6:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./TextTypes.coffee"),b.exports=function(a){var b,d,f,g,h;return g=c(a),h=g.types,f=g.parser,d=function(a){var c;return new(c=function(){function a(c){var e,f,g,i;i=c.map,g=function(e,f){return Object.defineProperty(a.prototype,e,{get:function(){var a;return a=f.val(),a instanceof b?d(a):a instanceof h.ImmutableObject?a.val():a},set:function(a){var b,d,f,g;if(a.constructor==={}.constructor){f=c.val(e),g=[];for(b in a)d=a[b],g.push(f.val(b,d,"immutable"));return g}return c.val(e,a,"immutable")},enumerable:!0,configurable:!1})};for(e in i)f=i[e],g(e,f)}return a}())(a)},b=function(b){function c(a,b,d){var e,f;if(c.__super__.constructor.call(this,a),null!=b){if("object"!=typeof b)throw new Error("The initial value of JsonTypes must be of type Object! (current type: "+typeof b+")");for(e in b)f=b[e],this.val(e,f,d)}}return e(c,b),c.prototype.mutable_default=!0,c.prototype.setMutableDefault=function(a){if(a===!0||"mutable"===a)c.prototype.mutable_default=!0;else{if(a!==!1&&"immutable"!==a)throw new Error('Set mutable either "mutable" or "immutable"!');c.prototype.mutable_default=!1}return"OK"},c.prototype.val=function(b,d,e){var f,g,i,j,k;if("object"==typeof b){for(i in b)g=b[i],this.val(i,g,d);return this}if(null!=b&&null!=d){if(e=null!=e?e===!0||"mutable"===e?!0:!1:this.mutable_default,"function"==typeof d)return this;if(e&&"number"!=typeof d||d.constructor===Object){if("string"==typeof d)return k=a.addOperation(new h.Word(a.getNextOperationIdentifier(),d)).execute(),c.__super__.val.call(this,b,k);if(d.constructor===Object)return f=a.addOperation(new c(a.getNextOperationIdentifier(),d,e)).execute(),c.__super__.val.call(this,b,f);throw new Error("You must not set "+typeof d+"-types in collaborative Json-objects!")}return j=a.addOperation(new h.ImmutableObject(void 0,d)).execute(),c.__super__.val.call(this,b,j)}return c.__super__.val.call(this,b,d)},Object.defineProperty(c.prototype,"value",{get:function(){return d(this)},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),c.prototype._encode=function(){return{type:"JsonType",uid:this.getUid()}},c}(h.MapManager),f.JsonType=function(a){var c;return c=a.uid,new b(c)},h.JsonType=b,g}},{"./TextTypes.coffee":8}],7:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./BasicTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i,j,k;return i=c(a),k=i.types,j=i.parser,f=function(c){function d(a){this.map={},d.__super__.constructor.call(this,a)}return e(d,c),d.prototype.val=function(c,e){var f,g,h,i,j;if(null!=e)return null==this.map[c]&&a.addOperation(new b(a.getNextOperationIdentifier(),this,c)).execute(),this.map[c].replace(e),this;if(null!=c)return g=null!=(i=this.map[c])?i.val():void 0,g instanceof k.ImmutableObject?g.val():g;h={},j=this.map;for(c in j)f=j[c],g=f.val(),(g instanceof k.ImmutableObject||g instanceof d)&&(g=g.val()),h[c]=g;return h},d}(k.Operation),b=function(b){function c(a,b,d){this.name=d,this.saveOperation("map_manager",b),c.__super__.constructor.call(this,a)}return e(c,b),c.prototype.execute=function(){var b,d,e,f,h;return this.validateSavedOperations()?(h=this.map_manager.getUid(),h.op_number="_"+h.op_number+"_RM_"+this.name,null==a.getOperation(h)&&(e=this.map_manager.getUid(),e.op_number="_"+e.op_number+"_RM_"+this.name+"_beginning",f=this.map_manager.getUid(),f.op_number="_"+f.op_number+"_RM_"+this.name+"_end",b=a.addOperation(new k.Delimiter(e,void 0,f)),d=a.addOperation(new k.Delimiter(f,b,void 0)).execute(),b.execute(),this.map_manager.map[this.name]=a.addOperation(new g(void 0,h,b,d)).execute()),c.__super__.execute.apply(this,arguments)):!1},c.prototype._encode=function(){return{type:"AddName",uid:this.getUid(),map_manager:this.map_manager.getUid(),name:this.name}},c}(k.Operation),j.AddName=function(a){var c,d,e;return c=a.map_manager,e=a.uid,d=a.name,new b(e,c,d)},d=function(b){function c(b,d,e,f,g,h){null!=d&&null!=e?(this.saveOperation("beginning",d),this.saveOperation("end",e)):(this.beginning=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),void 0,void 0)),this.end=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),this.beginning,void 0)),this.beginning.next_cl=this.end,this.beginning.execute(),this.end.execute()),c.__super__.constructor.call(this,b,f,g,h)}return e(c,b),c.prototype.getLastOperation=function(){return this.end.prev_cl},c.prototype.getFirstOperation=function(){return this.beginning.next_cl},c.prototype.toArray=function(){var a,b;for(a=this.beginning.next_cl,b=[];a!==this.end;)b.push(a),a=a.next_cl;return b},c.prototype.getOperationByPosition=function(a){var b;if(b=this.beginning.next_cl,a>0)for(;b=b.next_cl,b.isDeleted()||(a-=1),0!==a;)if(b instanceof k.Delimiter)throw new Error("position parameter exceeded the length of the document!");return b},c}(k.Insert),g=function(b){function c(a,b,d,e,f,g,h){c.__super__.constructor.call(this,b,d,e,f,g,h),null!=a&&this.replace(a)}return e(c,b),c.prototype.replace=function(b){var c,d;return c=this.getLastOperation(),d=new h(b,this,a.getNextOperationIdentifier(),c,c.next_cl),a.addOperation(d).execute()},c.prototype.val=function(){var a;if(a=this.getLastOperation(),a instanceof k.Delimiter)throw new Error("dtrn");return a.val()},c.prototype._encode=function(){var a;return a={type:"ReplaceManager",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&null!=this.next_cl&&(a.prev=this.prev_cl.getUid(),a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},c}(d),j.ReplaceManager=function(a){var b,c,d,e,f,h,i;return c=a.content,i=a.uid,h=a.prev,e=a.next,f=a.origin,b=a.beginning,d=a.end,new g(c,i,b,d,h,e,f)},h=function(a){function b(a,c,d,e,f,g){if(this.saveOperation("content",a),this.saveOperation("parent",c),null==e||null==f||null==a)throw new Error("You must define content, prev, and next for Replaceable-types!");b.__super__.constructor.call(this,d,e,f,g)}return e(b,a),b.prototype.val=function(){return this.content},b.prototype.replace=function(a){return this.parent.replace(a)},b.prototype.execute=function(){var a;return this.validateSavedOperations()?("function"==typeof(a=this.content).setReplaceManager&&a.setReplaceManager(this.parent),b.__super__.execute.apply(this,arguments),this):!1},b.prototype._encode=function(){var a;return a={type:"Replaceable",content:this.content.getUid(),ReplaceManager:this.parent.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid(),uid:this.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(k.Insert),j.Replaceable=function(a){var b,c,d,e,f,g;return b=a.content,e=a.ReplaceManager,g=a.uid,f=a.prev,c=a.next,d=a.origin,new h(b,e,g,f,c,d)},k.ListManager=d,k.MapManager=f,k.ReplaceManager=g,k.Replaceable=h,i}},{"./BasicTypes.coffee":5}],8:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./StructuredTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i;return h=c(a),i=h.types,g=h.parser,b=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return e(b,a),b}(i.Delete),g.TextDelete=g.Delete,d=function(a){function b(a,c,d,e,f){if(this.content=a,null==d||null==e)throw new Error("You must define prev, and next for TextInsert-types!");b.__super__.constructor.call(this,c,d,e,f)}return e(b,a),b.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},b.prototype.val=function(){return this.isDeleted()?"":this.content},b.prototype._encode=function(){var a;return a={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(i.Insert),g.TextInsert=function(a){var b,c,e,f,g;return b=a.content,g=a.uid,f=a.prev,c=a.next,e=a.origin,new d(b,g,f,c,e)},f=function(c){function f(a,b,c,d,e,g,h){f.__super__.constructor.call(this,a,c,d,e,g,h),null!=b&&this.insertText(0,b)}return e(f,c),f.prototype.insertText=function(b,c){var e,f,g,h,i,j;for(f=this.getOperationByPosition(b),j=[],h=0,i=c.length;i>h;h++)e=c[h],g=new d(e,a.getNextOperationIdentifier(),f.prev_cl,f),j.push(a.addOperation(g).execute());return j},f.prototype.deleteText=function(c,d){var e,f,g,h,j;for(g=this.getOperationByPosition(c),j=[],f=h=0;d>=0?d>h:h>d;f=d>=0?++h:--h){for(e=a.addOperation(new b(a.getNextOperationIdentifier(),g)).execute(),g=g.next_cl;g.isDeleted();){if(g instanceof i.Delimiter)throw new Error("You can't delete more than there is..");g=g.next_cl}j.push(e._encode())}return j},f.prototype.replaceText=function(b){var c;if(null!=this.replace_manager)return c=a.addOperation(new f(a.getNextOperationIdentifier())).execute(),c.insertText(0,b),this.replace_manager.replace(c);throw new Error("This type is currently not maintained by a ReplaceManager!")},f.prototype.val=function(){var a,b;return a=function(){var a,c,d,e;for(d=this.toArray(),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(null!=b.val?b.val():"");return e}.call(this),a.join("")},f.prototype.setReplaceManager=function(a){return this.saveOperation("replace_manager",a),this.validateSavedOperations},f.prototype._encode=function(){var a;return a={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},f}(i.ListManager),g.Word=function(a){var b,c,d,e,g,h;return h=a.uid,b=a.beginning,c=a.end,g=a.prev,d=a.next,e=a.origin,new f(h,void 0,b,c,g,d,e)},i.TextInsert=d,i.TextDelete=b,i.Word=f,h}},{"./StructuredTypes.coffee":7}]},{},[3,1]),!function e(a,b,c){function d(g,h){if(!b[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=b[g]={exports:{}};a[g][0].call(j.exports,function(b){var c=a[g][1][b];return d(c?c:b)},j,j.exports,e,a,b,c)}return b[g].exports}for(var f="function"==typeof require&&require,g=0;g<c.length;g++)d(c[g]);return d}({1:[function(a,b){var c;c=function(a){var b,c,d,e,f,g,h;return f={},c=new DUIClient,c.connect(function(a){var b;return null!=(b=f[a.action])?b.map(function(b){return setTimeout(function(){return b(a)},0)}):void 0}),c.initOK(),h=null,g=null,b=function(){function a(a,b,d,e){var i,j,k;this.engine=a,this.HB=b,this.execution_listener=d,this.yatta=e,this.duiClient=c,this.iwcHandler=f,k=function(a){return function(b){return a.send(b)}}(this),this.execution_listener.push(k),i=function(a){return function(b){var c;return c=b.extras,a.receive(c)}}(this),this.iwcHandler.Yatta_new_operation=[i],null!=h&&this.engine.applyOps(g),j=function(a){return function(){var b;return b={root_element:a.yatta.getRootElement(),HB:a.yatta.getHistoryBuffer()._encode()},a.sendIwcIntent("Yatta_push_root_element",b)}}(this),this.iwcHandler.Yatta_get_root_element=[j]}return a.prototype.getRootElement=function(){return h},a.prototype.send=function(a){return a.uid.creator===this.HB.getUserId()&&"string"!=typeof a.uid.op_number?this.sendIwcIntent("Yatta_new_operation",a):void 0},a.prototype.receive=function(a){return a.uid.creator!==this.HB.getUserId()?this.engine.applyOp(a):void 0},a.prototype.sendIwcIntent=function(a,b){var c;return c={action:a,component:"",data:"",dataType:"",extras:b},this.duiClient.sendIntent(c)},a.prototype.sync=function(){throw new Error("Can't use this a.t.m.")},a}(),d={action:"Yatta_get_root_element",component:"",data:"",dataType:"",extras:{}},e=function(){var e,i;return c.sendIntent(d),e=!1,i=function(d){var f;return f=c.getIwcClient()._componentName,h=null!=d?d.extras.root_element:void 0,g=null!=d?d.extras.HB:void 0,e?void 0:(e=!0,a(b,f))},f.Yatta_push_root_element=[i],setTimeout(i,800)},void setTimeout(e,4e3*Math.random())},b.exports=c,"undefined"!=typeof window&&null!==window&&(window.createConnector=c)},{}],2:[function(a,b){var c;c=function(){function a(a,b){this.HB=a,this.parser=b,this.unprocessed_ops=[]}return a.prototype.parseOperation=function(a){var b;if(b=this.parser[a.type],null!=b)return b(a);throw new Error("You forgot to specify a parser for type "+a.type+". The message is "+JSON.stringify(a)+".")},a.prototype.applyOps=function(a){var b,c,d,e,f,g,h,i;for(c=[],d=0,g=a.length;g>d;d++)b=a[d],c.push(this.parseOperation(b));for(e=0,h=c.length;h>e;e++)b=c[e],this.HB.addOperation(b);for(f=0,i=c.length;i>f;f++)b=c[f],b.execute()||this.unprocessed_ops.push(b);return this.tryUnprocessed()},a.prototype.applyOp=function(a){var b;return b=this.parseOperation(a),this.HB.addOperation(b),b.execute()||this.unprocessed_ops.push(b),this.tryUnprocessed()},a.prototype.tryUnprocessed=function(){var a,b,c,d,e,f,g;for(g=[];;){for(a=this.unprocessed_ops.length,c=[],f=this.unprocessed_ops,d=0,e=f.length;e>d;d++)b=f[d],b.execute()||c.push(b);if(this.unprocessed_ops=c,this.unprocessed_ops.length===a)break;g.push(void 0)}return g},a}(),b.exports=c},{}],3:[function(a,b){var c,d,e,f;f=a("../Types/JsonTypes.coffee"),d=a("../HistoryBuffer.coffee"),c=a("../Engine.coffee"),e=function(){function a(a,b){var e,g,h;this.HB=new d(a),g=f(this.HB),this.engine=new c(this.HB,g.parser),this.connector=new b(this.engine,this.HB,g.execution_listener,this),h=this.connector.getRootElement(),null==h?(e=new g.types.JsonType(this.HB.getNextOperationIdentifier()),this.HB.addOperation(e),e.execute(),this.root_element=e):this.root_element=this.HB.getOperation(h)}return a.prototype.getRootElement=function(){return this.root_element},a.prototype.getEngine=function(){return this.engine},a.prototype.getConnector=function(){return this.connector},a.prototype.getHistoryBuffer=function(){return this.HB},a.prototype.setMutableDefault=function(a){return this.root_element.setMutableDefault(a)},a.prototype.getUserId=function(){return this.HB.getUserId()},a.prototype.val=function(a,b,c){return this.root_element.val(a,b,c)},Object.defineProperty(a.prototype,"value",{get:function(){return this.root_element.value},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),a}(),"undefined"!=typeof window&&null!==window&&(window.JsonYatta=e),b.exports=e},{"../Engine.coffee":2,"../HistoryBuffer.coffee":4,"../Types/JsonTypes.coffee":6}],4:[function(a,b){var c;c=function(){function a(a){this.user_id=a,this.operation_counter={},this.buffer={},this.change_listeners=[]}return a.prototype.getUserId=function(){return this.user_id},a.prototype.getOperationCounter=function(){var a,b,c,d;b={},d=this.operation_counter;for(c in d)a=d[c],b[c]=a;return b},a.prototype._encode=function(){var a,b,c,d,e,f;a=[],f=this.buffer;for(d in f){e=f[d];for(c in e)b=e[c],isNaN(parseInt(c))||a.push(b._encode())}return a},a.prototype.getNextOperationIdentifier=function(a){var b;return null==a&&(a=this.user_id),null==this.operation_counter[a]&&(this.operation_counter[a]=0),b={creator:a,op_number:this.operation_counter[a]},this.operation_counter[a]++,b},a.prototype.getOperation=function(a){var b;if(a instanceof Object)return null!=(b=this.buffer[a.creator])?b[a.op_number]:void 0;if(null!=a)throw new Error("This type of uid is not defined!")},a.prototype.addOperation=function(a){if(null==this.buffer[a.creator]&&(this.buffer[a.creator]={}),null==this.operation_counter[a.creator]&&(this.operation_counter[a.creator]=0),null!=this.buffer[a.creator][a.op_number])throw new Error("You must not overwrite operations!");return this.buffer[a.creator][a.op_number]=a,"number"==typeof a.op_number&&a.creator!==this.getUserId()&&this.operation_counter[a.creator]++,a},a}(),b.exports=c},{}],5:[function(a,b){var c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};b.exports=function(a){var b,c,e,f,g,h,i;return i={},h=[],g=function(){function b(b){null==b&&(b=a.getNextOperationIdentifier()),this.creator=b.creator,this.op_number=b.op_number}return b.prototype.getUid=function(){return{creator:this.creator,op_number:this.op_number}},b.prototype.execute=function(){var a,b,c;for(this.is_executed=!0,b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this},b.prototype.saveOperation=function(a,b){return null!=(null!=b?b.execute:void 0)?this[a]=b:null!=b?(null==this.unchecked&&(this.unchecked={}),this.unchecked[a]=b):void 0},b.prototype.validateSavedOperations=function(){var b,c,d,e,f,g;f={},e=this,g=this.unchecked;for(b in g)d=g[b],c=a.getOperation(d),c?this[b]=c:(f[b]=d,e=!1);return delete this.unchecked,e||(this.unchecked=f),e},b}(),b=function(a){function b(a,c){this.saveOperation("deletes",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype._encode=function(){return{type:"Delete",uid:this.getUid(),deletes:this.deletes.getUid()}},b.prototype.execute=function(){return this.validateSavedOperations()?(this.deletes.applyDelete(this),b.__super__.execute.apply(this,arguments),this):!1},b}(g),i.Delete=function(a){var c,d;return d=a.uid,c=a.deletes,new b(d,c)},f=function(a){function b(a,c,d,e){this.saveOperation("prev_cl",c),this.saveOperation("next_cl",d),null!=e?this.saveOperation("origin",e):this.saveOperation("origin",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype.applyDelete=function(a){return null==this.deleted_by&&(this.deleted_by=[]),this.deleted_by.push(a)},b.prototype.isDeleted=function(){var a;return(null!=(a=this.deleted_by)?a.length:void 0)>0},b.prototype.getDistanceToOrigin=function(){var a,b;for(a=0,b=this.prev_cl;this.origin!==b;){if(a++,this===this.prev_cl)throw new Error("this should not happen ;) ");b=b.prev_cl}return a},b.prototype.update_sl=function(){var a;return a=this.prev_cl,update("prev_cl","prev_sl"),update("next_cl","prev_sl")},b.prototype.execute=function(){var a,c,d,e,f;if(null!=this.is_executed)return this;if(this.validateSavedOperations()){if((null!=(e=this.prev_cl)?e.validateSavedOperations():void 0)&&(null!=(f=this.next_cl)?f.validateSavedOperations():void 0)&&this.prev_cl.next_cl!==this){for(a=0,d=this.prev_cl.next_cl,c=0;null==d&&(console.log(JSON.stringify(this.prev_cl.getUid())),console.log(JSON.stringify(this.next_cl.getUid()))),d!==this.next_cl;){if(d.getDistanceToOrigin()===c)d.creator<this.creator&&(this.prev_cl=d,a=c+1);else{if(!(d.getDistanceToOrigin()<c))break;c-a<=d.getDistanceToOrigin()&&(this.prev_cl=d,a=c+1)}c++,d=d.next_cl}this.next_cl=this.prev_cl.next_cl,this.prev_cl.next_cl=this,this.next_cl.prev_cl=this}return b.__super__.execute.apply(this,arguments),this}return!1},b}(g),e=function(a){function b(a,c,d,e,f){this.content=null!=c?c:"",b.__super__.constructor.call(this,a,d,e,f)}return d(b,a),b.prototype.val=function(){return this.content},b.prototype._encode=function(){var a;return a={type:"ImmutableObject",uid:this.getUid(),content:this.content},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(f),i.ImmutableObject=function(a){var b,c,d,f,g;return g=a.uid,b=a.content,f=a.prev,c=a.next,d=a.origin,new e(g,b,f,c,d)},c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return d(b,a),b.prototype.execute=function(){var a,b,c;if(this.validateSavedOperations()){for(b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this}return!1},b.prototype._encode=function(){var a,b;return{type:"Delimiter",uid:this.getUid(),prev:null!=(a=this.prev_cl)?a.getUid():void 0,next:null!=(b=this.next_cl)?b.getUid():void 0}},b}(f),i.Delimiter=function(a){var b,d,e;return e=a.uid,d=a.prev,b=a.next,new c(e,d,b)},{types:{Delete:b,Insert:f,Delimiter:c,Operation:g,ImmutableObject:e},parser:i,execution_listener:h}}},{}],6:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./TextTypes.coffee"),b.exports=function(a){var b,d,f,g,h;return g=c(a),h=g.types,f=g.parser,d=function(a){var c;return new(c=function(){function a(c){var e,f,g,i;i=c.map,g=function(e,f){return Object.defineProperty(a.prototype,e,{get:function(){var a;return a=f.val(),a instanceof b?d(a):a instanceof h.ImmutableObject?a.val():a},set:function(a){var b,d,f,g;if(a.constructor==={}.constructor){f=c.val(e),g=[];for(b in a)d=a[b],g.push(f.val(b,d,"immutable"));return g}return c.val(e,a,"immutable")},enumerable:!0,configurable:!1})};for(e in i)f=i[e],g(e,f)}return a}())(a)},b=function(b){function c(a,b,d){var e,f;if(c.__super__.constructor.call(this,a),null!=b){if("object"!=typeof b)throw new Error("The initial value of JsonTypes must be of type Object! (current type: "+typeof b+")");for(e in b)f=b[e],this.val(e,f,d)}}return e(c,b),c.prototype.mutable_default=!0,c.prototype.setMutableDefault=function(a){if(a===!0||"mutable"===a)c.prototype.mutable_default=!0;else{if(a!==!1&&"immutable"!==a)throw new Error('Set mutable either "mutable" or "immutable"!');c.prototype.mutable_default=!1}return"OK"},c.prototype.val=function(b,d,e){var f,g,i,j,k;if("object"==typeof b){for(i in b)g=b[i],this.val(i,g,d);return this}if(null!=b&&null!=d){if(e=null!=e?e===!0||"mutable"===e?!0:!1:this.mutable_default,"function"==typeof d)return this;if(e&&"number"!=typeof d||d.constructor===Object){if("string"==typeof d)return k=a.addOperation(new h.Word(a.getNextOperationIdentifier(),d)).execute(),c.__super__.val.call(this,b,k);if(d.constructor===Object)return f=a.addOperation(new c(a.getNextOperationIdentifier(),d,e)).execute(),c.__super__.val.call(this,b,f);throw new Error("You must not set "+typeof d+"-types in collaborative Json-objects!")}return j=a.addOperation(new h.ImmutableObject(void 0,d)).execute(),c.__super__.val.call(this,b,j)}return c.__super__.val.call(this,b,d)},Object.defineProperty(c.prototype,"value",{get:function(){return d(this)},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),c.prototype._encode=function(){return{type:"JsonType",uid:this.getUid()}},c}(h.MapManager),f.JsonType=function(a){var c;return c=a.uid,new b(c)},h.JsonType=b,g}},{"./TextTypes.coffee":8}],7:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./BasicTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i,j,k;return i=c(a),k=i.types,j=i.parser,f=function(c){function d(a){this.map={},d.__super__.constructor.call(this,a)}return e(d,c),d.prototype.val=function(c,e){var f,g,h,i,j;if(null!=e)return null==this.map[c]&&a.addOperation(new b(a.getNextOperationIdentifier(),this,c)).execute(),this.map[c].replace(e),this;if(null!=c)return g=null!=(i=this.map[c])?i.val():void 0,g instanceof k.ImmutableObject?g.val():g;h={},j=this.map;for(c in j)f=j[c],g=f.val(),(g instanceof k.ImmutableObject||g instanceof d)&&(g=g.val()),h[c]=g;return h},d}(k.Operation),b=function(b){function c(a,b,d){this.name=d,this.saveOperation("map_manager",b),c.__super__.constructor.call(this,a)}return e(c,b),c.prototype.execute=function(){var b,d,e,f,h;return this.validateSavedOperations()?(h=this.map_manager.getUid(),h.op_number="_"+h.op_number+"_RM_"+this.name,null==a.getOperation(h)&&(e=this.map_manager.getUid(),e.op_number="_"+e.op_number+"_RM_"+this.name+"_beginning",f=this.map_manager.getUid(),f.op_number="_"+f.op_number+"_RM_"+this.name+"_end",b=a.addOperation(new k.Delimiter(e,void 0,f)),d=a.addOperation(new k.Delimiter(f,b,void 0)).execute(),b.execute(),this.map_manager.map[this.name]=a.addOperation(new g(void 0,h,b,d)).execute()),c.__super__.execute.apply(this,arguments)):!1},c.prototype._encode=function(){return{type:"AddName",uid:this.getUid(),map_manager:this.map_manager.getUid(),name:this.name}},c}(k.Operation),j.AddName=function(a){var c,d,e;return c=a.map_manager,e=a.uid,d=a.name,new b(e,c,d)
},d=function(b){function c(b,d,e,f,g,h){null!=d&&null!=e?(this.saveOperation("beginning",d),this.saveOperation("end",e)):(this.beginning=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),void 0,void 0)),this.end=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),this.beginning,void 0)),this.beginning.next_cl=this.end,this.beginning.execute(),this.end.execute()),c.__super__.constructor.call(this,b,f,g,h)}return e(c,b),c.prototype.getLastOperation=function(){return this.end.prev_cl},c.prototype.getFirstOperation=function(){return this.beginning.next_cl},c.prototype.toArray=function(){var a,b;for(a=this.beginning.next_cl,b=[];a!==this.end;)b.push(a),a=a.next_cl;return b},c.prototype.getOperationByPosition=function(a){var b;if(b=this.beginning.next_cl,a>0)for(;b=b.next_cl,b.isDeleted()||(a-=1),0!==a;)if(b instanceof k.Delimiter)throw new Error("position parameter exceeded the length of the document!");return b},c}(k.Insert),g=function(b){function c(a,b,d,e,f,g,h){c.__super__.constructor.call(this,b,d,e,f,g,h),null!=a&&this.replace(a)}return e(c,b),c.prototype.replace=function(b){var c,d;return c=this.getLastOperation(),d=new h(b,this,a.getNextOperationIdentifier(),c,c.next_cl),a.addOperation(d).execute()},c.prototype.val=function(){var a;if(a=this.getLastOperation(),a instanceof k.Delimiter)throw new Error("dtrn");return a.val()},c.prototype._encode=function(){var a;return a={type:"ReplaceManager",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&null!=this.next_cl&&(a.prev=this.prev_cl.getUid(),a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},c}(d),j.ReplaceManager=function(a){var b,c,d,e,f,h,i;return c=a.content,i=a.uid,h=a.prev,e=a.next,f=a.origin,b=a.beginning,d=a.end,new g(c,i,b,d,h,e,f)},h=function(a){function b(a,c,d,e,f,g){if(this.saveOperation("content",a),this.saveOperation("parent",c),null==e||null==f||null==a)throw new Error("You must define content, prev, and next for Replaceable-types!");b.__super__.constructor.call(this,d,e,f,g)}return e(b,a),b.prototype.val=function(){return this.content},b.prototype.replace=function(a){return this.parent.replace(a)},b.prototype.execute=function(){var a;return this.validateSavedOperations()?("function"==typeof(a=this.content).setReplaceManager&&a.setReplaceManager(this.parent),b.__super__.execute.apply(this,arguments),this):!1},b.prototype._encode=function(){var a;return a={type:"Replaceable",content:this.content.getUid(),ReplaceManager:this.parent.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid(),uid:this.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(k.Insert),j.Replaceable=function(a){var b,c,d,e,f,g;return b=a.content,e=a.ReplaceManager,g=a.uid,f=a.prev,c=a.next,d=a.origin,new h(b,e,g,f,c,d)},k.ListManager=d,k.MapManager=f,k.ReplaceManager=g,k.Replaceable=h,i}},{"./BasicTypes.coffee":5}],8:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./StructuredTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i;return h=c(a),i=h.types,g=h.parser,b=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return e(b,a),b}(i.Delete),g.TextDelete=g.Delete,d=function(a){function b(a,c,d,e,f){if(this.content=a,null==d||null==e)throw new Error("You must define prev, and next for TextInsert-types!");b.__super__.constructor.call(this,c,d,e,f)}return e(b,a),b.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},b.prototype.val=function(){return this.isDeleted()?"":this.content},b.prototype._encode=function(){var a;return a={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(i.Insert),g.TextInsert=function(a){var b,c,e,f,g;return b=a.content,g=a.uid,f=a.prev,c=a.next,e=a.origin,new d(b,g,f,c,e)},f=function(c){function f(a,b,c,d,e,g,h){f.__super__.constructor.call(this,a,c,d,e,g,h),null!=b&&this.insertText(0,b)}return e(f,c),f.prototype.insertText=function(b,c){var e,f,g,h,i,j;for(f=this.getOperationByPosition(b),j=[],h=0,i=c.length;i>h;h++)e=c[h],g=new d(e,a.getNextOperationIdentifier(),f.prev_cl,f),j.push(a.addOperation(g).execute());return j},f.prototype.deleteText=function(c,d){var e,f,g,h,j;for(g=this.getOperationByPosition(c),j=[],f=h=0;d>=0?d>h:h>d;f=d>=0?++h:--h){for(e=a.addOperation(new b(a.getNextOperationIdentifier(),g)).execute(),g=g.next_cl;g.isDeleted();){if(g instanceof i.Delimiter)throw new Error("You can't delete more than there is..");g=g.next_cl}j.push(e._encode())}return j},f.prototype.replaceText=function(b){var c;if(null!=this.replace_manager)return c=a.addOperation(new f(a.getNextOperationIdentifier())).execute(),c.insertText(0,b),this.replace_manager.replace(c);throw new Error("This type is currently not maintained by a ReplaceManager!")},f.prototype.val=function(){var a,b;return a=function(){var a,c,d,e;for(d=this.toArray(),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(null!=b.val?b.val():"");return e}.call(this),a.join("")},f.prototype.setReplaceManager=function(a){return this.saveOperation("replace_manager",a),this.validateSavedOperations},f.prototype._encode=function(){var a;return a={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},f}(i.ListManager),g.Word=function(a){var b,c,d,e,g,h;return h=a.uid,b=a.beginning,c=a.end,g=a.prev,d=a.next,e=a.origin,new f(h,void 0,b,c,g,d,e)},i.TextInsert=d,i.TextDelete=b,i.Word=f,h}},{"./StructuredTypes.coffee":7}]},{},[3,1]),!function f(a,b,c){function d(g,h){if(!b[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(e)return e(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=b[g]={exports:{}};a[g][0].call(j.exports,function(b){var c=a[g][1][b];return d(c?c:b)},j,j.exports,f,a,b,c)}return b[g].exports}for(var e="function"==typeof require&&require,g=0;g<c.length;g++)d(c[g]);return d}({1:[function(a,b){var c;c=function(a){var b,c,d,e,f,g,h;return f={},c=new DUIClient,c.connect(function(a){var b;return null!=(b=f[a.action])?b.map(function(b){return setTimeout(function(){return b(a)},0)}):void 0}),c.initOK(),h=null,g=null,b=function(){function a(a,b,d,e){var i,j,k;this.engine=a,this.HB=b,this.execution_listener=d,this.yatta=e,this.duiClient=c,this.iwcHandler=f,k=function(a){return function(b){return a.send(b)}}(this),this.execution_listener.push(k),i=function(a){return function(b){var c;return c=b.extras,a.receive(c)}}(this),this.iwcHandler.Yatta_new_operation=[i],null!=h&&this.engine.applyOps(g),j=function(a){return function(){var b;return b={root_element:a.yatta.getRootElement(),HB:a.yatta.getHistoryBuffer()._encode()},a.sendIwcIntent("Yatta_push_root_element",b)}}(this),this.iwcHandler.Yatta_get_root_element=[j]}return a.prototype.getRootElement=function(){return h},a.prototype.send=function(a){return a.uid.creator===this.HB.getUserId()&&"string"!=typeof a.uid.op_number?this.sendIwcIntent("Yatta_new_operation",a):void 0},a.prototype.receive=function(a){return a.uid.creator!==this.HB.getUserId()?this.engine.applyOp(a):void 0},a.prototype.sendIwcIntent=function(a,b){var c;return c={action:a,component:"",data:"",dataType:"",extras:b},this.duiClient.sendIntent(c)},a.prototype.sync=function(){throw new Error("Can't use this a.t.m.")},a}(),d={action:"Yatta_get_root_element",component:"",data:"",dataType:"",extras:{}},e=function(){var e,i;return c.sendIntent(d),e=!1,i=function(d){var f;return f=c.getIwcClient()._componentName,h=null!=d?d.extras.root_element:void 0,g=null!=d?d.extras.HB:void 0,e?void 0:(e=!0,a(b,f))},f.Yatta_push_root_element=[i],setTimeout(i,800)},void setTimeout(e,4e3*Math.random())},b.exports=c,"undefined"!=typeof window&&null!==window&&(window.createConnector=c)},{}],2:[function(a,b){var c;c=function(){function a(a,b){this.HB=a,this.parser=b,this.unprocessed_ops=[]}return a.prototype.parseOperation=function(a){var b;if(b=this.parser[a.type],null!=b)return b(a);throw new Error("You forgot to specify a parser for type "+a.type+". The message is "+JSON.stringify(a)+".")},a.prototype.applyOps=function(a){var b,c,d,e,f,g,h,i;for(c=[],d=0,g=a.length;g>d;d++)b=a[d],c.push(this.parseOperation(b));for(e=0,h=c.length;h>e;e++)b=c[e],this.HB.addOperation(b);for(f=0,i=c.length;i>f;f++)b=c[f],b.execute()||this.unprocessed_ops.push(b);return this.tryUnprocessed()},a.prototype.applyOp=function(a){var b;return b=this.parseOperation(a),this.HB.addOperation(b),b.execute()||this.unprocessed_ops.push(b),this.tryUnprocessed()},a.prototype.tryUnprocessed=function(){var a,b,c,d,e,f,g;for(g=[];;){for(a=this.unprocessed_ops.length,c=[],f=this.unprocessed_ops,d=0,e=f.length;e>d;d++)b=f[d],b.execute()||c.push(b);if(this.unprocessed_ops=c,this.unprocessed_ops.length===a)break;g.push(void 0)}return g},a}(),b.exports=c},{}],3:[function(a,b){var c,d,e,f;f=a("../Types/JsonTypes.coffee"),d=a("../HistoryBuffer.coffee"),c=a("../Engine.coffee"),e=function(){function a(a,b){var e,g,h;this.HB=new d(a),g=f(this.HB),this.engine=new c(this.HB,g.parser),this.connector=new b(this.engine,this.HB,g.execution_listener,this),h=this.connector.getRootElement(),null==h?(e=new g.types.JsonType(this.HB.getNextOperationIdentifier()),this.HB.addOperation(e),e.execute(),this.root_element=e):this.root_element=this.HB.getOperation(h)}return a.prototype.getRootElement=function(){return this.root_element},a.prototype.getEngine=function(){return this.engine},a.prototype.getConnector=function(){return this.connector},a.prototype.getHistoryBuffer=function(){return this.HB},a.prototype.setMutableDefault=function(a){return this.root_element.setMutableDefault(a)},a.prototype.getUserId=function(){return this.HB.getUserId()},a.prototype.val=function(a,b,c){return this.root_element.val(a,b,c)},Object.defineProperty(a.prototype,"value",{get:function(){return this.root_element.value},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),a}(),"undefined"!=typeof window&&null!==window&&(window.JsonYatta=e),b.exports=e},{"../Engine.coffee":2,"../HistoryBuffer.coffee":4,"../Types/JsonTypes.coffee":6}],4:[function(a,b){var c;c=function(){function a(a){this.user_id=a,this.operation_counter={},this.buffer={},this.change_listeners=[]}return a.prototype.getUserId=function(){return this.user_id},a.prototype.getOperationCounter=function(){var a,b,c,d;b={},d=this.operation_counter;for(c in d)a=d[c],b[c]=a;return b},a.prototype._encode=function(){var a,b,c,d,e,f;a=[],f=this.buffer;for(d in f){e=f[d];for(c in e)b=e[c],isNaN(parseInt(c))||a.push(b._encode())}return a},a.prototype.getNextOperationIdentifier=function(a){var b;return null==a&&(a=this.user_id),null==this.operation_counter[a]&&(this.operation_counter[a]=0),b={creator:a,op_number:this.operation_counter[a]},this.operation_counter[a]++,b},a.prototype.getOperation=function(a){var b;if(a instanceof Object)return null!=(b=this.buffer[a.creator])?b[a.op_number]:void 0;if(null!=a)throw new Error("This type of uid is not defined!")},a.prototype.addOperation=function(a){if(null==this.buffer[a.creator]&&(this.buffer[a.creator]={}),null==this.operation_counter[a.creator]&&(this.operation_counter[a.creator]=0),null!=this.buffer[a.creator][a.op_number])throw new Error("You must not overwrite operations!");return this.buffer[a.creator][a.op_number]=a,"number"==typeof a.op_number&&a.creator!==this.getUserId()&&this.operation_counter[a.creator]++,a},a}(),b.exports=c},{}],5:[function(a,b){var c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};b.exports=function(a){var b,c,e,f,g,h,i;return i={},h=[],g=function(){function b(b){null==b&&(b=a.getNextOperationIdentifier()),this.creator=b.creator,this.op_number=b.op_number}return b.prototype.getUid=function(){return{creator:this.creator,op_number:this.op_number}},b.prototype.execute=function(){var a,b,c;for(this.is_executed=!0,b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this},b.prototype.saveOperation=function(a,b){return null!=(null!=b?b.execute:void 0)?this[a]=b:null!=b?(null==this.unchecked&&(this.unchecked={}),this.unchecked[a]=b):void 0},b.prototype.validateSavedOperations=function(){var b,c,d,e,f,g;f={},e=this,g=this.unchecked;for(b in g)d=g[b],c=a.getOperation(d),c?this[b]=c:(f[b]=d,e=!1);return delete this.unchecked,e||(this.unchecked=f),e},b}(),b=function(a){function b(a,c){this.saveOperation("deletes",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype._encode=function(){return{type:"Delete",uid:this.getUid(),deletes:this.deletes.getUid()}},b.prototype.execute=function(){return this.validateSavedOperations()?(this.deletes.applyDelete(this),b.__super__.execute.apply(this,arguments),this):!1},b}(g),i.Delete=function(a){var c,d;return d=a.uid,c=a.deletes,new b(d,c)},f=function(a){function b(a,c,d,e){this.saveOperation("prev_cl",c),this.saveOperation("next_cl",d),null!=e?this.saveOperation("origin",e):this.saveOperation("origin",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype.applyDelete=function(a){return null==this.deleted_by&&(this.deleted_by=[]),this.deleted_by.push(a)},b.prototype.isDeleted=function(){var a;return(null!=(a=this.deleted_by)?a.length:void 0)>0},b.prototype.getDistanceToOrigin=function(){var a,b;for(a=0,b=this.prev_cl;this.origin!==b;){if(a++,this===this.prev_cl)throw new Error("this should not happen ;) ");b=b.prev_cl}return a},b.prototype.update_sl=function(){var a;return a=this.prev_cl,update("prev_cl","prev_sl"),update("next_cl","prev_sl")},b.prototype.execute=function(){var a,c,d,e,f;if(null!=this.is_executed)return this;if(this.validateSavedOperations()){if((null!=(e=this.prev_cl)?e.validateSavedOperations():void 0)&&(null!=(f=this.next_cl)?f.validateSavedOperations():void 0)&&this.prev_cl.next_cl!==this){for(a=0,d=this.prev_cl.next_cl,c=0;null==d&&(console.log(JSON.stringify(this.prev_cl.getUid())),console.log(JSON.stringify(this.next_cl.getUid()))),d!==this.next_cl;){if(d.getDistanceToOrigin()===c)d.creator<this.creator&&(this.prev_cl=d,a=c+1);else{if(!(d.getDistanceToOrigin()<c))break;c-a<=d.getDistanceToOrigin()&&(this.prev_cl=d,a=c+1)}c++,d=d.next_cl}this.next_cl=this.prev_cl.next_cl,this.prev_cl.next_cl=this,this.next_cl.prev_cl=this}return b.__super__.execute.apply(this,arguments),this}return!1},b}(g),e=function(a){function b(a,c,d,e,f){this.content=null!=c?c:"",b.__super__.constructor.call(this,a,d,e,f)}return d(b,a),b.prototype.val=function(){return this.content},b.prototype._encode=function(){var a;return a={type:"ImmutableObject",uid:this.getUid(),content:this.content},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(f),i.ImmutableObject=function(a){var b,c,d,f,g;return g=a.uid,b=a.content,f=a.prev,c=a.next,d=a.origin,new e(g,b,f,c,d)},c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return d(b,a),b.prototype.execute=function(){var a,b,c;if(this.validateSavedOperations()){for(b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this}return!1},b.prototype._encode=function(){var a,b;return{type:"Delimiter",uid:this.getUid(),prev:null!=(a=this.prev_cl)?a.getUid():void 0,next:null!=(b=this.next_cl)?b.getUid():void 0}},b}(f),i.Delimiter=function(a){var b,d,e;return e=a.uid,d=a.prev,b=a.next,new c(e,d,b)},{types:{Delete:b,Insert:f,Delimiter:c,Operation:g,ImmutableObject:e},parser:i,execution_listener:h}}},{}],6:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./TextTypes.coffee"),b.exports=function(a){var b,d,f,g,h;return g=c(a),h=g.types,f=g.parser,d=function(a){var c;return new(c=function(){function a(c){var e,f,g,i;i=c.map,g=function(e,f){return Object.defineProperty(a.prototype,e,{get:function(){var a;return a=f.val(),a instanceof b?d(a):a instanceof h.ImmutableObject?a.val():a},set:function(a){var b,d,f,g;if(a.constructor==={}.constructor){f=c.val(e),g=[];for(b in a)d=a[b],g.push(f.val(b,d,"immutable"));return g}return c.val(e,a,"immutable")},enumerable:!0,configurable:!1})};for(e in i)f=i[e],g(e,f)}return a}())(a)},b=function(b){function c(a,b,d){var e,f;if(c.__super__.constructor.call(this,a),null!=b){if("object"!=typeof b)throw new Error("The initial value of JsonTypes must be of type Object! (current type: "+typeof b+")");for(e in b)f=b[e],this.val(e,f,d)}}return e(c,b),c.prototype.mutable_default=!0,c.prototype.setMutableDefault=function(a){if(a===!0||"mutable"===a)c.prototype.mutable_default=!0;else{if(a!==!1&&"immutable"!==a)throw new Error('Set mutable either "mutable" or "immutable"!');c.prototype.mutable_default=!1}return"OK"},c.prototype.val=function(b,d,e){var f,g,i,j,k;if("object"==typeof b){for(i in b)g=b[i],this.val(i,g,d);return this}if(null!=b&&null!=d){if(e=null!=e?e===!0||"mutable"===e?!0:!1:this.mutable_default,"function"==typeof d)return this;if(e&&"number"!=typeof d||d.constructor===Object){if("string"==typeof d)return k=a.addOperation(new h.Word(a.getNextOperationIdentifier(),d)).execute(),c.__super__.val.call(this,b,k);if(d.constructor===Object)return f=a.addOperation(new c(a.getNextOperationIdentifier(),d,e)).execute(),c.__super__.val.call(this,b,f);throw new Error("You must not set "+typeof d+"-types in collaborative Json-objects!")}return j=a.addOperation(new h.ImmutableObject(void 0,d)).execute(),c.__super__.val.call(this,b,j)}return c.__super__.val.call(this,b,d)},Object.defineProperty(c.prototype,"value",{get:function(){return d(this)},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),c.prototype._encode=function(){return{type:"JsonType",uid:this.getUid()}},c}(h.MapManager),f.JsonType=function(a){var c;return c=a.uid,new b(c)},h.JsonType=b,g}},{"./TextTypes.coffee":8}],7:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./BasicTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i,j,k;return i=c(a),k=i.types,j=i.parser,f=function(c){function d(a){this.map={},d.__super__.constructor.call(this,a)}return e(d,c),d.prototype.val=function(c,e){var f,g,h,i,j;if(null!=e)return null==this.map[c]&&a.addOperation(new b(a.getNextOperationIdentifier(),this,c)).execute(),this.map[c].replace(e),this;if(null!=c)return g=null!=(i=this.map[c])?i.val():void 0,g instanceof k.ImmutableObject?g.val():g;h={},j=this.map;for(c in j)f=j[c],g=f.val(),(g instanceof k.ImmutableObject||g instanceof d)&&(g=g.val()),h[c]=g;return h},d}(k.Operation),b=function(b){function c(a,b,d){this.name=d,this.saveOperation("map_manager",b),c.__super__.constructor.call(this,a)}return e(c,b),c.prototype.execute=function(){var b,d,e,f,h;return this.validateSavedOperations()?(h=this.map_manager.getUid(),h.op_number="_"+h.op_number+"_RM_"+this.name,null==a.getOperation(h)&&(e=this.map_manager.getUid(),e.op_number="_"+e.op_number+"_RM_"+this.name+"_beginning",f=this.map_manager.getUid(),f.op_number="_"+f.op_number+"_RM_"+this.name+"_end",b=a.addOperation(new k.Delimiter(e,void 0,f)),d=a.addOperation(new k.Delimiter(f,b,void 0)).execute(),b.execute(),this.map_manager.map[this.name]=a.addOperation(new g(void 0,h,b,d)).execute()),c.__super__.execute.apply(this,arguments)):!1},c.prototype._encode=function(){return{type:"AddName",uid:this.getUid(),map_manager:this.map_manager.getUid(),name:this.name}},c}(k.Operation),j.AddName=function(a){var c,d,e;return c=a.map_manager,e=a.uid,d=a.name,new b(e,c,d)},d=function(b){function c(b,d,e,f,g,h){null!=d&&null!=e?(this.saveOperation("beginning",d),this.saveOperation("end",e)):(this.beginning=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),void 0,void 0)),this.end=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),this.beginning,void 0)),this.beginning.next_cl=this.end,this.beginning.execute(),this.end.execute()),c.__super__.constructor.call(this,b,f,g,h)}return e(c,b),c.prototype.getLastOperation=function(){return this.end.prev_cl},c.prototype.getFirstOperation=function(){return this.beginning.next_cl},c.prototype.toArray=function(){var a,b;for(a=this.beginning.next_cl,b=[];a!==this.end;)b.push(a),a=a.next_cl;return b},c.prototype.getOperationByPosition=function(a){var b;if(b=this.beginning.next_cl,a>0)for(;b=b.next_cl,b.isDeleted()||(a-=1),0!==a;)if(b instanceof k.Delimiter)throw new Error("position parameter exceeded the length of the document!");return b},c}(k.Insert),g=function(b){function c(a,b,d,e,f,g,h){c.__super__.constructor.call(this,b,d,e,f,g,h),null!=a&&this.replace(a)}return e(c,b),c.prototype.replace=function(b){var c,d;return c=this.getLastOperation(),d=new h(b,this,a.getNextOperationIdentifier(),c,c.next_cl),a.addOperation(d).execute()},c.prototype.val=function(){var a;if(a=this.getLastOperation(),a instanceof k.Delimiter)throw new Error("dtrn");return a.val()},c.prototype._encode=function(){var a;return a={type:"ReplaceManager",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&null!=this.next_cl&&(a.prev=this.prev_cl.getUid(),a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},c}(d),j.ReplaceManager=function(a){var b,c,d,e,f,h,i;return c=a.content,i=a.uid,h=a.prev,e=a.next,f=a.origin,b=a.beginning,d=a.end,new g(c,i,b,d,h,e,f)},h=function(a){function b(a,c,d,e,f,g){if(this.saveOperation("content",a),this.saveOperation("parent",c),null==e||null==f||null==a)throw new Error("You must define content, prev, and next for Replaceable-types!");b.__super__.constructor.call(this,d,e,f,g)}return e(b,a),b.prototype.val=function(){return this.content},b.prototype.replace=function(a){return this.parent.replace(a)},b.prototype.execute=function(){var a;return this.validateSavedOperations()?("function"==typeof(a=this.content).setReplaceManager&&a.setReplaceManager(this.parent),b.__super__.execute.apply(this,arguments),this):!1},b.prototype._encode=function(){var a;return a={type:"Replaceable",content:this.content.getUid(),ReplaceManager:this.parent.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid(),uid:this.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(k.Insert),j.Replaceable=function(a){var b,c,d,e,f,g;return b=a.content,e=a.ReplaceManager,g=a.uid,f=a.prev,c=a.next,d=a.origin,new h(b,e,g,f,c,d)},k.ListManager=d,k.MapManager=f,k.ReplaceManager=g,k.Replaceable=h,i}},{"./BasicTypes.coffee":5}],8:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./StructuredTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i;return h=c(a),i=h.types,g=h.parser,b=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return e(b,a),b}(i.Delete),g.TextDelete=g.Delete,d=function(a){function b(a,c,d,e,f){if(this.content=a,null==d||null==e)throw new Error("You must define prev, and next for TextInsert-types!");b.__super__.constructor.call(this,c,d,e,f)}return e(b,a),b.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},b.prototype.val=function(){return this.isDeleted()?"":this.content},b.prototype._encode=function(){var a;return a={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(i.Insert),g.TextInsert=function(a){var b,c,e,f,g;return b=a.content,g=a.uid,f=a.prev,c=a.next,e=a.origin,new d(b,g,f,c,e)},f=function(c){function f(a,b,c,d,e,g,h){f.__super__.constructor.call(this,a,c,d,e,g,h),null!=b&&this.insertText(0,b)}return e(f,c),f.prototype.insertText=function(b,c){var e,f,g,h,i,j;for(f=this.getOperationByPosition(b),j=[],h=0,i=c.length;i>h;h++)e=c[h],g=new d(e,a.getNextOperationIdentifier(),f.prev_cl,f),j.push(a.addOperation(g).execute());return j},f.prototype.deleteText=function(c,d){var e,f,g,h,j;for(g=this.getOperationByPosition(c),j=[],f=h=0;d>=0?d>h:h>d;f=d>=0?++h:--h){for(e=a.addOperation(new b(a.getNextOperationIdentifier(),g)).execute(),g=g.next_cl;g.isDeleted();){if(g instanceof i.Delimiter)throw new Error("You can't delete more than there is..");g=g.next_cl}j.push(e._encode())}return j},f.prototype.replaceText=function(b){var c;if(null!=this.replace_manager)return c=a.addOperation(new f(a.getNextOperationIdentifier())).execute(),c.insertText(0,b),this.replace_manager.replace(c);throw new Error("This type is currently not maintained by a ReplaceManager!")},f.prototype.val=function(){var a,b;return a=function(){var a,c,d,e;for(d=this.toArray(),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(null!=b.val?b.val():"");return e}.call(this),a.join("")},f.prototype.setReplaceManager=function(a){return this.saveOperation("replace_manager",a),this.validateSavedOperations},f.prototype._encode=function(){var a;return a={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},f}(i.ListManager),g.Word=function(a){var b,c,d,e,g,h;return h=a.uid,b=a.beginning,c=a.end,g=a.prev,d=a.next,e=a.origin,new f(h,void 0,b,c,g,d,e)},i.TextInsert=d,i.TextDelete=b,i.Word=f,h}},{"./StructuredTypes.coffee":7}]},{},[3,1]),!function g(a,b,c){function d(f,h){if(!b[f]){if(!a[f]){var i="function"==typeof require&&require;if(!h&&i)return i(f,!0);if(e)return e(f,!0);throw new Error("Cannot find module '"+f+"'")}var j=b[f]={exports:{}};a[f][0].call(j.exports,function(b){var c=a[f][1][b];return d(c?c:b)},j,j.exports,g,a,b,c)}return b[f].exports}for(var e="function"==typeof require&&require,f=0;f<c.length;f++)d(c[f]);return d}({1:[function(a,b){var c;c=function(a){var b,c,d,e,f,g,h;return f={},c=new DUIClient,c.connect(function(a){var b;return null!=(b=f[a.action])?b.map(function(b){return setTimeout(function(){return b(a)},0)}):void 0}),c.initOK(),h=null,g=null,b=function(){function a(a,b,d,e){var i,j,k;this.engine=a,this.HB=b,this.execution_listener=d,this.yatta=e,this.duiClient=c,this.iwcHandler=f,k=function(a){return function(b){return a.send(b)}}(this),this.execution_listener.push(k),i=function(a){return function(b){var c;return c=b.extras,a.receive(c)}}(this),this.iwcHandler.Yatta_new_operation=[i],null!=h&&this.engine.applyOps(g),j=function(a){return function(){var b;return b={root_element:a.yatta.getRootElement(),HB:a.yatta.getHistoryBuffer()._encode()},a.sendIwcIntent("Yatta_push_root_element",b)}}(this),this.iwcHandler.Yatta_get_root_element=[j]}return a.prototype.getRootElement=function(){return h},a.prototype.send=function(a){return a.uid.creator===this.HB.getUserId()&&"string"!=typeof a.uid.op_number?this.sendIwcIntent("Yatta_new_operation",a):void 0},a.prototype.receive=function(a){return a.uid.creator!==this.HB.getUserId()?this.engine.applyOp(a):void 0},a.prototype.sendIwcIntent=function(a,b){var c;return c={action:a,component:"",data:"",dataType:"",extras:b},this.duiClient.sendIntent(c)},a.prototype.sync=function(){throw new Error("Can't use this a.t.m.")},a}(),d={action:"Yatta_get_root_element",component:"",data:"",dataType:"",extras:{}},e=function(){var e,i;return c.sendIntent(d),e=!1,i=function(d){var f;return f=c.getIwcClient()._componentName,h=null!=d?d.extras.root_element:void 0,g=null!=d?d.extras.HB:void 0,e?void 0:(e=!0,a(b,f))},f.Yatta_push_root_element=[i],setTimeout(i,800)},void setTimeout(e,4e3*Math.random())},b.exports=c,"undefined"!=typeof window&&null!==window&&(window.createConnector=c)},{}],2:[function(a,b){var c;c=function(){function a(a,b){this.HB=a,this.parser=b,this.unprocessed_ops=[]}return a.prototype.parseOperation=function(a){var b;if(b=this.parser[a.type],null!=b)return b(a);throw new Error("You forgot to specify a parser for type "+a.type+". The message is "+JSON.stringify(a)+".")},a.prototype.applyOps=function(a){var b,c,d,e,f,g,h,i;for(c=[],d=0,g=a.length;g>d;d++)b=a[d],c.push(this.parseOperation(b));for(e=0,h=c.length;h>e;e++)b=c[e],this.HB.addOperation(b);for(f=0,i=c.length;i>f;f++)b=c[f],b.execute()||this.unprocessed_ops.push(b);return this.tryUnprocessed()},a.prototype.applyOp=function(a){var b;return b=this.parseOperation(a),this.HB.addOperation(b),b.execute()||this.unprocessed_ops.push(b),this.tryUnprocessed()},a.prototype.tryUnprocessed=function(){var a,b,c,d,e,f,g;for(g=[];;){for(a=this.unprocessed_ops.length,c=[],f=this.unprocessed_ops,d=0,e=f.length;e>d;d++)b=f[d],b.execute()||c.push(b);if(this.unprocessed_ops=c,this.unprocessed_ops.length===a)break;g.push(void 0)}return g},a}(),b.exports=c},{}],3:[function(a,b){var c,d,e,f;f=a("../Types/JsonTypes.coffee"),d=a("../HistoryBuffer.coffee"),c=a("../Engine.coffee"),e=function(){function a(a,b){var e,g,h;this.HB=new d(a),g=f(this.HB),this.engine=new c(this.HB,g.parser),this.connector=new b(this.engine,this.HB,g.execution_listener,this),h=this.connector.getRootElement(),null==h?(e=new g.types.JsonType(this.HB.getNextOperationIdentifier()),this.HB.addOperation(e),e.execute(),this.root_element=e):this.root_element=this.HB.getOperation(h)}return a.prototype.getRootElement=function(){return this.root_element},a.prototype.getEngine=function(){return this.engine},a.prototype.getConnector=function(){return this.connector},a.prototype.getHistoryBuffer=function(){return this.HB},a.prototype.setMutableDefault=function(a){return this.root_element.setMutableDefault(a)},a.prototype.getUserId=function(){return this.HB.getUserId()},a.prototype.val=function(a,b,c){return this.root_element.val(a,b,c)},Object.defineProperty(a.prototype,"value",{get:function(){return this.root_element.value},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),a}(),"undefined"!=typeof window&&null!==window&&(window.JsonYatta=e),b.exports=e},{"../Engine.coffee":2,"../HistoryBuffer.coffee":4,"../Types/JsonTypes.coffee":6}],4:[function(a,b){var c;c=function(){function a(a){this.user_id=a,this.operation_counter={},this.buffer={},this.change_listeners=[]}return a.prototype.getUserId=function(){return this.user_id},a.prototype.getOperationCounter=function(){var a,b,c,d;b={},d=this.operation_counter;for(c in d)a=d[c],b[c]=a;return b},a.prototype._encode=function(){var a,b,c,d,e,f;a=[],f=this.buffer;for(d in f){e=f[d];for(c in e)b=e[c],isNaN(parseInt(c))||a.push(b._encode())}return a},a.prototype.getNextOperationIdentifier=function(a){var b;return null==a&&(a=this.user_id),null==this.operation_counter[a]&&(this.operation_counter[a]=0),b={creator:a,op_number:this.operation_counter[a]},this.operation_counter[a]++,b},a.prototype.getOperation=function(a){var b;if(a instanceof Object)return null!=(b=this.buffer[a.creator])?b[a.op_number]:void 0;if(null!=a)throw new Error("This type of uid is not defined!")},a.prototype.addOperation=function(a){if(null==this.buffer[a.creator]&&(this.buffer[a.creator]={}),null==this.operation_counter[a.creator]&&(this.operation_counter[a.creator]=0),null!=this.buffer[a.creator][a.op_number])throw new Error("You must not overwrite operations!");
return this.buffer[a.creator][a.op_number]=a,"number"==typeof a.op_number&&a.creator!==this.getUserId()&&this.operation_counter[a.creator]++,a},a}(),b.exports=c},{}],5:[function(a,b){var c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};b.exports=function(a){var b,c,e,f,g,h,i;return i={},h=[],g=function(){function b(b){null==b&&(b=a.getNextOperationIdentifier()),this.creator=b.creator,this.op_number=b.op_number}return b.prototype.getUid=function(){return{creator:this.creator,op_number:this.op_number}},b.prototype.execute=function(){var a,b,c;for(this.is_executed=!0,b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this},b.prototype.saveOperation=function(a,b){return null!=(null!=b?b.execute:void 0)?this[a]=b:null!=b?(null==this.unchecked&&(this.unchecked={}),this.unchecked[a]=b):void 0},b.prototype.validateSavedOperations=function(){var b,c,d,e,f,g;f={},e=this,g=this.unchecked;for(b in g)d=g[b],c=a.getOperation(d),c?this[b]=c:(f[b]=d,e=!1);return delete this.unchecked,e||(this.unchecked=f),e},b}(),b=function(a){function b(a,c){this.saveOperation("deletes",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype._encode=function(){return{type:"Delete",uid:this.getUid(),deletes:this.deletes.getUid()}},b.prototype.execute=function(){return this.validateSavedOperations()?(this.deletes.applyDelete(this),b.__super__.execute.apply(this,arguments),this):!1},b}(g),i.Delete=function(a){var c,d;return d=a.uid,c=a.deletes,new b(d,c)},f=function(a){function b(a,c,d,e){this.saveOperation("prev_cl",c),this.saveOperation("next_cl",d),null!=e?this.saveOperation("origin",e):this.saveOperation("origin",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype.applyDelete=function(a){return null==this.deleted_by&&(this.deleted_by=[]),this.deleted_by.push(a)},b.prototype.isDeleted=function(){var a;return(null!=(a=this.deleted_by)?a.length:void 0)>0},b.prototype.getDistanceToOrigin=function(){var a,b;for(a=0,b=this.prev_cl;this.origin!==b;){if(a++,this===this.prev_cl)throw new Error("this should not happen ;) ");b=b.prev_cl}return a},b.prototype.update_sl=function(){var a;return a=this.prev_cl,update("prev_cl","prev_sl"),update("next_cl","prev_sl")},b.prototype.execute=function(){var a,c,d,e,f;if(null!=this.is_executed)return this;if(this.validateSavedOperations()){if((null!=(e=this.prev_cl)?e.validateSavedOperations():void 0)&&(null!=(f=this.next_cl)?f.validateSavedOperations():void 0)&&this.prev_cl.next_cl!==this){for(a=0,d=this.prev_cl.next_cl,c=0;null==d&&(console.log(JSON.stringify(this.prev_cl.getUid())),console.log(JSON.stringify(this.next_cl.getUid()))),d!==this.next_cl;){if(d.getDistanceToOrigin()===c)d.creator<this.creator&&(this.prev_cl=d,a=c+1);else{if(!(d.getDistanceToOrigin()<c))break;c-a<=d.getDistanceToOrigin()&&(this.prev_cl=d,a=c+1)}c++,d=d.next_cl}this.next_cl=this.prev_cl.next_cl,this.prev_cl.next_cl=this,this.next_cl.prev_cl=this}return b.__super__.execute.apply(this,arguments),this}return!1},b}(g),e=function(a){function b(a,c,d,e,f){this.content=null!=c?c:"",b.__super__.constructor.call(this,a,d,e,f)}return d(b,a),b.prototype.val=function(){return this.content},b.prototype._encode=function(){var a;return a={type:"ImmutableObject",uid:this.getUid(),content:this.content},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(f),i.ImmutableObject=function(a){var b,c,d,f,g;return g=a.uid,b=a.content,f=a.prev,c=a.next,d=a.origin,new e(g,b,f,c,d)},c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return d(b,a),b.prototype.execute=function(){var a,b,c;if(this.validateSavedOperations()){for(b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this}return!1},b.prototype._encode=function(){var a,b;return{type:"Delimiter",uid:this.getUid(),prev:null!=(a=this.prev_cl)?a.getUid():void 0,next:null!=(b=this.next_cl)?b.getUid():void 0}},b}(f),i.Delimiter=function(a){var b,d,e;return e=a.uid,d=a.prev,b=a.next,new c(e,d,b)},{types:{Delete:b,Insert:f,Delimiter:c,Operation:g,ImmutableObject:e},parser:i,execution_listener:h}}},{}],6:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./TextTypes.coffee"),b.exports=function(a){var b,d,f,g,h;return g=c(a),h=g.types,f=g.parser,d=function(a){var c;return new(c=function(){function a(c){var e,f,g,i;i=c.map,g=function(e,f){return Object.defineProperty(a.prototype,e,{get:function(){var a;return a=f.val(),a instanceof b?d(a):a instanceof h.ImmutableObject?a.val():a},set:function(a){var b,d,f,g;if(a.constructor==={}.constructor){f=c.val(e),g=[];for(b in a)d=a[b],g.push(f.val(b,d,"immutable"));return g}return c.val(e,a,"immutable")},enumerable:!0,configurable:!1})};for(e in i)f=i[e],g(e,f)}return a}())(a)},b=function(b){function c(a,b,d){var e,f;if(c.__super__.constructor.call(this,a),null!=b){if("object"!=typeof b)throw new Error("The initial value of JsonTypes must be of type Object! (current type: "+typeof b+")");for(e in b)f=b[e],this.val(e,f,d)}}return e(c,b),c.prototype.mutable_default=!0,c.prototype.setMutableDefault=function(a){if(a===!0||"mutable"===a)c.prototype.mutable_default=!0;else{if(a!==!1&&"immutable"!==a)throw new Error('Set mutable either "mutable" or "immutable"!');c.prototype.mutable_default=!1}return"OK"},c.prototype.val=function(b,d,e){var f,g,i,j,k;if("object"==typeof b){for(i in b)g=b[i],this.val(i,g,d);return this}if(null!=b&&null!=d){if(e=null!=e?e===!0||"mutable"===e?!0:!1:this.mutable_default,"function"==typeof d)return this;if(e&&"number"!=typeof d||d.constructor===Object){if("string"==typeof d)return k=a.addOperation(new h.Word(a.getNextOperationIdentifier(),d)).execute(),c.__super__.val.call(this,b,k);if(d.constructor===Object)return f=a.addOperation(new c(a.getNextOperationIdentifier(),d,e)).execute(),c.__super__.val.call(this,b,f);throw new Error("You must not set "+typeof d+"-types in collaborative Json-objects!")}return j=a.addOperation(new h.ImmutableObject(void 0,d)).execute(),c.__super__.val.call(this,b,j)}return c.__super__.val.call(this,b,d)},Object.defineProperty(c.prototype,"value",{get:function(){return d(this)},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),c.prototype._encode=function(){return{type:"JsonType",uid:this.getUid()}},c}(h.MapManager),f.JsonType=function(a){var c;return c=a.uid,new b(c)},h.JsonType=b,g}},{"./TextTypes.coffee":8}],7:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./BasicTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i,j,k;return i=c(a),k=i.types,j=i.parser,f=function(c){function d(a){this.map={},d.__super__.constructor.call(this,a)}return e(d,c),d.prototype.val=function(c,e){var f,g,h,i,j;if(null!=e)return null==this.map[c]&&a.addOperation(new b(a.getNextOperationIdentifier(),this,c)).execute(),this.map[c].replace(e),this;if(null!=c)return g=null!=(i=this.map[c])?i.val():void 0,g instanceof k.ImmutableObject?g.val():g;h={},j=this.map;for(c in j)f=j[c],g=f.val(),(g instanceof k.ImmutableObject||g instanceof d)&&(g=g.val()),h[c]=g;return h},d}(k.Operation),b=function(b){function c(a,b,d){this.name=d,this.saveOperation("map_manager",b),c.__super__.constructor.call(this,a)}return e(c,b),c.prototype.execute=function(){var b,d,e,f,h;return this.validateSavedOperations()?(h=this.map_manager.getUid(),h.op_number="_"+h.op_number+"_RM_"+this.name,null==a.getOperation(h)&&(e=this.map_manager.getUid(),e.op_number="_"+e.op_number+"_RM_"+this.name+"_beginning",f=this.map_manager.getUid(),f.op_number="_"+f.op_number+"_RM_"+this.name+"_end",b=a.addOperation(new k.Delimiter(e,void 0,f)),d=a.addOperation(new k.Delimiter(f,b,void 0)).execute(),b.execute(),this.map_manager.map[this.name]=a.addOperation(new g(void 0,h,b,d)).execute()),c.__super__.execute.apply(this,arguments)):!1},c.prototype._encode=function(){return{type:"AddName",uid:this.getUid(),map_manager:this.map_manager.getUid(),name:this.name}},c}(k.Operation),j.AddName=function(a){var c,d,e;return c=a.map_manager,e=a.uid,d=a.name,new b(e,c,d)},d=function(b){function c(b,d,e,f,g,h){null!=d&&null!=e?(this.saveOperation("beginning",d),this.saveOperation("end",e)):(this.beginning=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),void 0,void 0)),this.end=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),this.beginning,void 0)),this.beginning.next_cl=this.end,this.beginning.execute(),this.end.execute()),c.__super__.constructor.call(this,b,f,g,h)}return e(c,b),c.prototype.getLastOperation=function(){return this.end.prev_cl},c.prototype.getFirstOperation=function(){return this.beginning.next_cl},c.prototype.toArray=function(){var a,b;for(a=this.beginning.next_cl,b=[];a!==this.end;)b.push(a),a=a.next_cl;return b},c.prototype.getOperationByPosition=function(a){var b;if(b=this.beginning.next_cl,a>0)for(;b=b.next_cl,b.isDeleted()||(a-=1),0!==a;)if(b instanceof k.Delimiter)throw new Error("position parameter exceeded the length of the document!");return b},c}(k.Insert),g=function(b){function c(a,b,d,e,f,g,h){c.__super__.constructor.call(this,b,d,e,f,g,h),null!=a&&this.replace(a)}return e(c,b),c.prototype.replace=function(b){var c,d;return c=this.getLastOperation(),d=new h(b,this,a.getNextOperationIdentifier(),c,c.next_cl),a.addOperation(d).execute()},c.prototype.val=function(){var a;if(a=this.getLastOperation(),a instanceof k.Delimiter)throw new Error("dtrn");return a.val()},c.prototype._encode=function(){var a;return a={type:"ReplaceManager",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&null!=this.next_cl&&(a.prev=this.prev_cl.getUid(),a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},c}(d),j.ReplaceManager=function(a){var b,c,d,e,f,h,i;return c=a.content,i=a.uid,h=a.prev,e=a.next,f=a.origin,b=a.beginning,d=a.end,new g(c,i,b,d,h,e,f)},h=function(a){function b(a,c,d,e,f,g){if(this.saveOperation("content",a),this.saveOperation("parent",c),null==e||null==f||null==a)throw new Error("You must define content, prev, and next for Replaceable-types!");b.__super__.constructor.call(this,d,e,f,g)}return e(b,a),b.prototype.val=function(){return this.content},b.prototype.replace=function(a){return this.parent.replace(a)},b.prototype.execute=function(){var a;return this.validateSavedOperations()?("function"==typeof(a=this.content).setReplaceManager&&a.setReplaceManager(this.parent),b.__super__.execute.apply(this,arguments),this):!1},b.prototype._encode=function(){var a;return a={type:"Replaceable",content:this.content.getUid(),ReplaceManager:this.parent.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid(),uid:this.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(k.Insert),j.Replaceable=function(a){var b,c,d,e,f,g;return b=a.content,e=a.ReplaceManager,g=a.uid,f=a.prev,c=a.next,d=a.origin,new h(b,e,g,f,c,d)},k.ListManager=d,k.MapManager=f,k.ReplaceManager=g,k.Replaceable=h,i}},{"./BasicTypes.coffee":5}],8:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./StructuredTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i;return h=c(a),i=h.types,g=h.parser,b=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return e(b,a),b}(i.Delete),g.TextDelete=g.Delete,d=function(a){function b(a,c,d,e,f){if(this.content=a,null==d||null==e)throw new Error("You must define prev, and next for TextInsert-types!");b.__super__.constructor.call(this,c,d,e,f)}return e(b,a),b.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},b.prototype.val=function(){return this.isDeleted()?"":this.content},b.prototype._encode=function(){var a;return a={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(i.Insert),g.TextInsert=function(a){var b,c,e,f,g;return b=a.content,g=a.uid,f=a.prev,c=a.next,e=a.origin,new d(b,g,f,c,e)},f=function(c){function f(a,b,c,d,e,g,h){f.__super__.constructor.call(this,a,c,d,e,g,h),null!=b&&this.insertText(0,b)}return e(f,c),f.prototype.insertText=function(b,c){var e,f,g,h,i,j;for(f=this.getOperationByPosition(b),j=[],h=0,i=c.length;i>h;h++)e=c[h],g=new d(e,a.getNextOperationIdentifier(),f.prev_cl,f),j.push(a.addOperation(g).execute());return j},f.prototype.deleteText=function(c,d){var e,f,g,h,j;for(g=this.getOperationByPosition(c),j=[],f=h=0;d>=0?d>h:h>d;f=d>=0?++h:--h){for(e=a.addOperation(new b(a.getNextOperationIdentifier(),g)).execute(),g=g.next_cl;g.isDeleted();){if(g instanceof i.Delimiter)throw new Error("You can't delete more than there is..");g=g.next_cl}j.push(e._encode())}return j},f.prototype.replaceText=function(b){var c;if(null!=this.replace_manager)return c=a.addOperation(new f(a.getNextOperationIdentifier())).execute(),c.insertText(0,b),this.replace_manager.replace(c);throw new Error("This type is currently not maintained by a ReplaceManager!")},f.prototype.val=function(){var a,b;return a=function(){var a,c,d,e;for(d=this.toArray(),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(null!=b.val?b.val():"");return e}.call(this),a.join("")},f.prototype.setReplaceManager=function(a){return this.saveOperation("replace_manager",a),this.validateSavedOperations},f.prototype._encode=function(){var a;return a={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},f}(i.ListManager),g.Word=function(a){var b,c,d,e,g,h;return h=a.uid,b=a.beginning,c=a.end,g=a.prev,d=a.next,e=a.origin,new f(h,void 0,b,c,g,d,e)},i.TextInsert=d,i.TextDelete=b,i.Word=f,h}},{"./StructuredTypes.coffee":7}]},{},[3,1]),!function h(a,b,c){function d(f,g){if(!b[f]){if(!a[f]){var i="function"==typeof require&&require;if(!g&&i)return i(f,!0);if(e)return e(f,!0);throw new Error("Cannot find module '"+f+"'")}var j=b[f]={exports:{}};a[f][0].call(j.exports,function(b){var c=a[f][1][b];return d(c?c:b)},j,j.exports,h,a,b,c)}return b[f].exports}for(var e="function"==typeof require&&require,f=0;f<c.length;f++)d(c[f]);return d}({1:[function(a,b){var c;c=function(a){var b,c,d,e,f,g,h;return f={},c=new DUIClient,c.connect(function(a){var b;return null!=(b=f[a.action])?b.map(function(b){return setTimeout(function(){return b(a)},0)}):void 0}),c.initOK(),h=null,g=null,b=function(){function a(a,b,d,e){var i,j,k;this.engine=a,this.HB=b,this.execution_listener=d,this.yatta=e,this.duiClient=c,this.iwcHandler=f,k=function(a){return function(b){return a.send(b)}}(this),this.execution_listener.push(k),i=function(a){return function(b){var c;return c=b.extras,a.receive(c)}}(this),this.iwcHandler.Yatta_new_operation=[i],null!=h&&this.engine.applyOps(g),j=function(a){return function(){var b;return b={root_element:a.yatta.getRootElement(),HB:a.yatta.getHistoryBuffer()._encode()},a.sendIwcIntent("Yatta_push_root_element",b)}}(this),this.iwcHandler.Yatta_get_root_element=[j]}return a.prototype.getRootElement=function(){return h},a.prototype.send=function(a){return a.uid.creator===this.HB.getUserId()&&"string"!=typeof a.uid.op_number?this.sendIwcIntent("Yatta_new_operation",a):void 0},a.prototype.receive=function(a){return a.uid.creator!==this.HB.getUserId()?this.engine.applyOp(a):void 0},a.prototype.sendIwcIntent=function(a,b){var c;return c={action:a,component:"",data:"",dataType:"",extras:b},this.duiClient.sendIntent(c)},a.prototype.sync=function(){throw new Error("Can't use this a.t.m.")},a}(),d={action:"Yatta_get_root_element",component:"",data:"",dataType:"",extras:{}},e=function(){var e,i;return c.sendIntent(d),e=!1,i=function(d){var f;return f=c.getIwcClient()._componentName,h=null!=d?d.extras.root_element:void 0,g=null!=d?d.extras.HB:void 0,e?void 0:(e=!0,a(b,f))},f.Yatta_push_root_element=[i],setTimeout(i,800)},void setTimeout(e,4e3*Math.random())},b.exports=c,"undefined"!=typeof window&&null!==window&&(window.createConnector=c)},{}],2:[function(a,b){var c;c=function(){function a(a,b){this.HB=a,this.parser=b,this.unprocessed_ops=[]}return a.prototype.parseOperation=function(a){var b;if(b=this.parser[a.type],null!=b)return b(a);throw new Error("You forgot to specify a parser for type "+a.type+". The message is "+JSON.stringify(a)+".")},a.prototype.applyOps=function(a){var b,c,d,e,f,g,h,i;for(c=[],d=0,g=a.length;g>d;d++)b=a[d],c.push(this.parseOperation(b));for(e=0,h=c.length;h>e;e++)b=c[e],this.HB.addOperation(b);for(f=0,i=c.length;i>f;f++)b=c[f],b.execute()||this.unprocessed_ops.push(b);return this.tryUnprocessed()},a.prototype.applyOp=function(a){var b;return b=this.parseOperation(a),this.HB.addOperation(b),b.execute()||this.unprocessed_ops.push(b),this.tryUnprocessed()},a.prototype.tryUnprocessed=function(){var a,b,c,d,e,f,g;for(g=[];;){for(a=this.unprocessed_ops.length,c=[],f=this.unprocessed_ops,d=0,e=f.length;e>d;d++)b=f[d],b.execute()||c.push(b);if(this.unprocessed_ops=c,this.unprocessed_ops.length===a)break;g.push(void 0)}return g},a}(),b.exports=c},{}],3:[function(a,b){var c,d,e,f;f=a("../Types/JsonTypes.coffee"),d=a("../HistoryBuffer.coffee"),c=a("../Engine.coffee"),e=function(){function a(a,b){var e,g,h;this.HB=new d(a),g=f(this.HB),this.engine=new c(this.HB,g.parser),this.connector=new b(this.engine,this.HB,g.execution_listener,this),h=this.connector.getRootElement(),null==h?(e=new g.types.JsonType(this.HB.getNextOperationIdentifier()),this.HB.addOperation(e),e.execute(),this.root_element=e):this.root_element=this.HB.getOperation(h)}return a.prototype.getRootElement=function(){return this.root_element},a.prototype.getEngine=function(){return this.engine},a.prototype.getConnector=function(){return this.connector},a.prototype.getHistoryBuffer=function(){return this.HB},a.prototype.setMutableDefault=function(a){return this.root_element.setMutableDefault(a)},a.prototype.getUserId=function(){return this.HB.getUserId()},a.prototype.val=function(a,b,c){return this.root_element.val(a,b,c)},Object.defineProperty(a.prototype,"value",{get:function(){return this.root_element.value},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),a}(),"undefined"!=typeof window&&null!==window&&(window.JsonYatta=e),b.exports=e},{"../Engine.coffee":2,"../HistoryBuffer.coffee":4,"../Types/JsonTypes.coffee":6}],4:[function(a,b){var c;c=function(){function a(a){this.user_id=a,this.operation_counter={},this.buffer={},this.change_listeners=[]}return a.prototype.getUserId=function(){return this.user_id},a.prototype.getOperationCounter=function(){var a,b,c,d;b={},d=this.operation_counter;for(c in d)a=d[c],b[c]=a;return b},a.prototype._encode=function(){var a,b,c,d,e,f;a=[],f=this.buffer;for(d in f){e=f[d];for(c in e)b=e[c],isNaN(parseInt(c))||a.push(b._encode())}return a},a.prototype.getNextOperationIdentifier=function(a){var b;return null==a&&(a=this.user_id),null==this.operation_counter[a]&&(this.operation_counter[a]=0),b={creator:a,op_number:this.operation_counter[a]},this.operation_counter[a]++,b},a.prototype.getOperation=function(a){var b;if(a instanceof Object)return null!=(b=this.buffer[a.creator])?b[a.op_number]:void 0;if(null!=a)throw new Error("This type of uid is not defined!")},a.prototype.addOperation=function(a){if(null==this.buffer[a.creator]&&(this.buffer[a.creator]={}),null==this.operation_counter[a.creator]&&(this.operation_counter[a.creator]=0),null!=this.buffer[a.creator][a.op_number])throw new Error("You must not overwrite operations!");return this.buffer[a.creator][a.op_number]=a,"number"==typeof a.op_number&&a.creator!==this.getUserId()&&this.operation_counter[a.creator]++,a},a}(),b.exports=c},{}],5:[function(a,b){var c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};b.exports=function(a){var b,c,e,f,g,h,i;return i={},h=[],g=function(){function b(b){null==b&&(b=a.getNextOperationIdentifier()),this.creator=b.creator,this.op_number=b.op_number}return b.prototype.getUid=function(){return{creator:this.creator,op_number:this.op_number}},b.prototype.execute=function(){var a,b,c;for(this.is_executed=!0,b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this},b.prototype.saveOperation=function(a,b){return null!=(null!=b?b.execute:void 0)?this[a]=b:null!=b?(null==this.unchecked&&(this.unchecked={}),this.unchecked[a]=b):void 0},b.prototype.validateSavedOperations=function(){var b,c,d,e,f,g;f={},e=this,g=this.unchecked;for(b in g)d=g[b],c=a.getOperation(d),c?this[b]=c:(f[b]=d,e=!1);return delete this.unchecked,e||(this.unchecked=f),e},b}(),b=function(a){function b(a,c){this.saveOperation("deletes",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype._encode=function(){return{type:"Delete",uid:this.getUid(),deletes:this.deletes.getUid()}},b.prototype.execute=function(){return this.validateSavedOperations()?(this.deletes.applyDelete(this),b.__super__.execute.apply(this,arguments),this):!1},b}(g),i.Delete=function(a){var c,d;return d=a.uid,c=a.deletes,new b(d,c)},f=function(a){function b(a,c,d,e){this.saveOperation("prev_cl",c),this.saveOperation("next_cl",d),null!=e?this.saveOperation("origin",e):this.saveOperation("origin",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype.applyDelete=function(a){return null==this.deleted_by&&(this.deleted_by=[]),this.deleted_by.push(a)},b.prototype.isDeleted=function(){var a;return(null!=(a=this.deleted_by)?a.length:void 0)>0},b.prototype.getDistanceToOrigin=function(){var a,b;for(a=0,b=this.prev_cl;this.origin!==b;){if(a++,this===this.prev_cl)throw new Error("this should not happen ;) ");b=b.prev_cl}return a},b.prototype.update_sl=function(){var a;return a=this.prev_cl,update("prev_cl","prev_sl"),update("next_cl","prev_sl")},b.prototype.execute=function(){var a,c,d,e,f;if(null!=this.is_executed)return this;if(this.validateSavedOperations()){if((null!=(e=this.prev_cl)?e.validateSavedOperations():void 0)&&(null!=(f=this.next_cl)?f.validateSavedOperations():void 0)&&this.prev_cl.next_cl!==this){for(a=0,d=this.prev_cl.next_cl,c=0;null==d&&(console.log(JSON.stringify(this.prev_cl.getUid())),console.log(JSON.stringify(this.next_cl.getUid()))),d!==this.next_cl;){if(d.getDistanceToOrigin()===c)d.creator<this.creator&&(this.prev_cl=d,a=c+1);else{if(!(d.getDistanceToOrigin()<c))break;c-a<=d.getDistanceToOrigin()&&(this.prev_cl=d,a=c+1)}c++,d=d.next_cl}this.next_cl=this.prev_cl.next_cl,this.prev_cl.next_cl=this,this.next_cl.prev_cl=this}return b.__super__.execute.apply(this,arguments),this}return!1},b}(g),e=function(a){function b(a,c,d,e,f){this.content=null!=c?c:"",b.__super__.constructor.call(this,a,d,e,f)}return d(b,a),b.prototype.val=function(){return this.content},b.prototype._encode=function(){var a;return a={type:"ImmutableObject",uid:this.getUid(),content:this.content},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(f),i.ImmutableObject=function(a){var b,c,d,f,g;return g=a.uid,b=a.content,f=a.prev,c=a.next,d=a.origin,new e(g,b,f,c,d)},c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return d(b,a),b.prototype.execute=function(){var a,b,c;if(this.validateSavedOperations()){for(b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this}return!1},b.prototype._encode=function(){var a,b;return{type:"Delimiter",uid:this.getUid(),prev:null!=(a=this.prev_cl)?a.getUid():void 0,next:null!=(b=this.next_cl)?b.getUid():void 0}},b}(f),i.Delimiter=function(a){var b,d,e;return e=a.uid,d=a.prev,b=a.next,new c(e,d,b)},{types:{Delete:b,Insert:f,Delimiter:c,Operation:g,ImmutableObject:e},parser:i,execution_listener:h}}},{}],6:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./TextTypes.coffee"),b.exports=function(a){var b,d,f,g,h;return g=c(a),h=g.types,f=g.parser,d=function(a){var c;return new(c=function(){function a(c){var e,f,g,i;i=c.map,g=function(e,f){return Object.defineProperty(a.prototype,e,{get:function(){var a;return a=f.val(),a instanceof b?d(a):a instanceof h.ImmutableObject?a.val():a},set:function(a){var b,d,f,g;if(a.constructor==={}.constructor){f=c.val(e),g=[];for(b in a)d=a[b],g.push(f.val(b,d,"immutable"));return g}return c.val(e,a,"immutable")},enumerable:!0,configurable:!1})};for(e in i)f=i[e],g(e,f)}return a}())(a)},b=function(b){function c(a,b,d){var e,f;if(c.__super__.constructor.call(this,a),null!=b){if("object"!=typeof b)throw new Error("The initial value of JsonTypes must be of type Object! (current type: "+typeof b+")");for(e in b)f=b[e],this.val(e,f,d)}}return e(c,b),c.prototype.mutable_default=!0,c.prototype.setMutableDefault=function(a){if(a===!0||"mutable"===a)c.prototype.mutable_default=!0;else{if(a!==!1&&"immutable"!==a)throw new Error('Set mutable either "mutable" or "immutable"!');c.prototype.mutable_default=!1}return"OK"},c.prototype.val=function(b,d,e){var f,g,i,j,k;if("object"==typeof b){for(i in b)g=b[i],this.val(i,g,d);return this}if(null!=b&&null!=d){if(e=null!=e?e===!0||"mutable"===e?!0:!1:this.mutable_default,"function"==typeof d)return this;if(e&&"number"!=typeof d||d.constructor===Object){if("string"==typeof d)return k=a.addOperation(new h.Word(a.getNextOperationIdentifier(),d)).execute(),c.__super__.val.call(this,b,k);if(d.constructor===Object)return f=a.addOperation(new c(a.getNextOperationIdentifier(),d,e)).execute(),c.__super__.val.call(this,b,f);throw new Error("You must not set "+typeof d+"-types in collaborative Json-objects!")}return j=a.addOperation(new h.ImmutableObject(void 0,d)).execute(),c.__super__.val.call(this,b,j)}return c.__super__.val.call(this,b,d)},Object.defineProperty(c.prototype,"value",{get:function(){return d(this)},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),c.prototype._encode=function(){return{type:"JsonType",uid:this.getUid()}},c}(h.MapManager),f.JsonType=function(a){var c;return c=a.uid,new b(c)},h.JsonType=b,g}},{"./TextTypes.coffee":8}],7:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./BasicTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i,j,k;return i=c(a),k=i.types,j=i.parser,f=function(c){function d(a){this.map={},d.__super__.constructor.call(this,a)}return e(d,c),d.prototype.val=function(c,e){var f,g,h,i,j;if(null!=e)return null==this.map[c]&&a.addOperation(new b(a.getNextOperationIdentifier(),this,c)).execute(),this.map[c].replace(e),this;if(null!=c)return g=null!=(i=this.map[c])?i.val():void 0,g instanceof k.ImmutableObject?g.val():g;h={},j=this.map;for(c in j)f=j[c],g=f.val(),(g instanceof k.ImmutableObject||g instanceof d)&&(g=g.val()),h[c]=g;return h},d}(k.Operation),b=function(b){function c(a,b,d){this.name=d,this.saveOperation("map_manager",b),c.__super__.constructor.call(this,a)}return e(c,b),c.prototype.execute=function(){var b,d,e,f,h;return this.validateSavedOperations()?(h=this.map_manager.getUid(),h.op_number="_"+h.op_number+"_RM_"+this.name,null==a.getOperation(h)&&(e=this.map_manager.getUid(),e.op_number="_"+e.op_number+"_RM_"+this.name+"_beginning",f=this.map_manager.getUid(),f.op_number="_"+f.op_number+"_RM_"+this.name+"_end",b=a.addOperation(new k.Delimiter(e,void 0,f)),d=a.addOperation(new k.Delimiter(f,b,void 0)).execute(),b.execute(),this.map_manager.map[this.name]=a.addOperation(new g(void 0,h,b,d)).execute()),c.__super__.execute.apply(this,arguments)):!1},c.prototype._encode=function(){return{type:"AddName",uid:this.getUid(),map_manager:this.map_manager.getUid(),name:this.name}},c}(k.Operation),j.AddName=function(a){var c,d,e;return c=a.map_manager,e=a.uid,d=a.name,new b(e,c,d)},d=function(b){function c(b,d,e,f,g,h){null!=d&&null!=e?(this.saveOperation("beginning",d),this.saveOperation("end",e)):(this.beginning=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),void 0,void 0)),this.end=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),this.beginning,void 0)),this.beginning.next_cl=this.end,this.beginning.execute(),this.end.execute()),c.__super__.constructor.call(this,b,f,g,h)}return e(c,b),c.prototype.getLastOperation=function(){return this.end.prev_cl},c.prototype.getFirstOperation=function(){return this.beginning.next_cl},c.prototype.toArray=function(){var a,b;for(a=this.beginning.next_cl,b=[];a!==this.end;)b.push(a),a=a.next_cl;return b},c.prototype.getOperationByPosition=function(a){var b;if(b=this.beginning.next_cl,a>0)for(;b=b.next_cl,b.isDeleted()||(a-=1),0!==a;)if(b instanceof k.Delimiter)throw new Error("position parameter exceeded the length of the document!");return b},c}(k.Insert),g=function(b){function c(a,b,d,e,f,g,h){c.__super__.constructor.call(this,b,d,e,f,g,h),null!=a&&this.replace(a)}return e(c,b),c.prototype.replace=function(b){var c,d;return c=this.getLastOperation(),d=new h(b,this,a.getNextOperationIdentifier(),c,c.next_cl),a.addOperation(d).execute()},c.prototype.val=function(){var a;if(a=this.getLastOperation(),a instanceof k.Delimiter)throw new Error("dtrn");return a.val()},c.prototype._encode=function(){var a;return a={type:"ReplaceManager",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&null!=this.next_cl&&(a.prev=this.prev_cl.getUid(),a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},c}(d),j.ReplaceManager=function(a){var b,c,d,e,f,h,i;return c=a.content,i=a.uid,h=a.prev,e=a.next,f=a.origin,b=a.beginning,d=a.end,new g(c,i,b,d,h,e,f)},h=function(a){function b(a,c,d,e,f,g){if(this.saveOperation("content",a),this.saveOperation("parent",c),null==e||null==f||null==a)throw new Error("You must define content, prev, and next for Replaceable-types!");b.__super__.constructor.call(this,d,e,f,g)}return e(b,a),b.prototype.val=function(){return this.content},b.prototype.replace=function(a){return this.parent.replace(a)},b.prototype.execute=function(){var a;return this.validateSavedOperations()?("function"==typeof(a=this.content).setReplaceManager&&a.setReplaceManager(this.parent),b.__super__.execute.apply(this,arguments),this):!1},b.prototype._encode=function(){var a;return a={type:"Replaceable",content:this.content.getUid(),ReplaceManager:this.parent.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid(),uid:this.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(k.Insert),j.Replaceable=function(a){var b,c,d,e,f,g;return b=a.content,e=a.ReplaceManager,g=a.uid,f=a.prev,c=a.next,d=a.origin,new h(b,e,g,f,c,d)},k.ListManager=d,k.MapManager=f,k.ReplaceManager=g,k.Replaceable=h,i}},{"./BasicTypes.coffee":5}],8:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a
}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./StructuredTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i;return h=c(a),i=h.types,g=h.parser,b=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return e(b,a),b}(i.Delete),g.TextDelete=g.Delete,d=function(a){function b(a,c,d,e,f){if(this.content=a,null==d||null==e)throw new Error("You must define prev, and next for TextInsert-types!");b.__super__.constructor.call(this,c,d,e,f)}return e(b,a),b.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},b.prototype.val=function(){return this.isDeleted()?"":this.content},b.prototype._encode=function(){var a;return a={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(i.Insert),g.TextInsert=function(a){var b,c,e,f,g;return b=a.content,g=a.uid,f=a.prev,c=a.next,e=a.origin,new d(b,g,f,c,e)},f=function(c){function f(a,b,c,d,e,g,h){f.__super__.constructor.call(this,a,c,d,e,g,h),null!=b&&this.insertText(0,b)}return e(f,c),f.prototype.insertText=function(b,c){var e,f,g,h,i,j;for(f=this.getOperationByPosition(b),j=[],h=0,i=c.length;i>h;h++)e=c[h],g=new d(e,a.getNextOperationIdentifier(),f.prev_cl,f),j.push(a.addOperation(g).execute());return j},f.prototype.deleteText=function(c,d){var e,f,g,h,j;for(g=this.getOperationByPosition(c),j=[],f=h=0;d>=0?d>h:h>d;f=d>=0?++h:--h){for(e=a.addOperation(new b(a.getNextOperationIdentifier(),g)).execute(),g=g.next_cl;g.isDeleted();){if(g instanceof i.Delimiter)throw new Error("You can't delete more than there is..");g=g.next_cl}j.push(e._encode())}return j},f.prototype.replaceText=function(b){var c;if(null!=this.replace_manager)return c=a.addOperation(new f(a.getNextOperationIdentifier())).execute(),c.insertText(0,b),this.replace_manager.replace(c);throw new Error("This type is currently not maintained by a ReplaceManager!")},f.prototype.val=function(){var a,b;return a=function(){var a,c,d,e;for(d=this.toArray(),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(null!=b.val?b.val():"");return e}.call(this),a.join("")},f.prototype.setReplaceManager=function(a){return this.saveOperation("replace_manager",a),this.validateSavedOperations},f.prototype._encode=function(){var a;return a={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},f}(i.ListManager),g.Word=function(a){var b,c,d,e,g,h;return h=a.uid,b=a.beginning,c=a.end,g=a.prev,d=a.next,e=a.origin,new f(h,void 0,b,c,g,d,e)},i.TextInsert=d,i.TextDelete=b,i.Word=f,h}},{"./StructuredTypes.coffee":7}]},{},[3,1]),!function i(a,b,c){function d(f,g){if(!b[f]){if(!a[f]){var h="function"==typeof require&&require;if(!g&&h)return h(f,!0);if(e)return e(f,!0);throw new Error("Cannot find module '"+f+"'")}var j=b[f]={exports:{}};a[f][0].call(j.exports,function(b){var c=a[f][1][b];return d(c?c:b)},j,j.exports,i,a,b,c)}return b[f].exports}for(var e="function"==typeof require&&require,f=0;f<c.length;f++)d(c[f]);return d}({1:[function(a,b){var c;c=function(a){var b,c,d,e,f,g,h;return f={},c=new DUIClient,c.connect(function(a){var b;return null!=(b=f[a.action])?b.map(function(b){return setTimeout(function(){return b(a)},0)}):void 0}),c.initOK(),h=null,g=null,b=function(){function a(a,b,d,e){var i,j,k;this.engine=a,this.HB=b,this.execution_listener=d,this.yatta=e,this.duiClient=c,this.iwcHandler=f,k=function(a){return function(b){return a.send(b)}}(this),this.execution_listener.push(k),i=function(a){return function(b){var c;return c=b.extras,a.receive(c)}}(this),this.iwcHandler.Yatta_new_operation=[i],null!=h&&this.engine.applyOps(g),j=function(a){return function(){var b;return b={root_element:a.yatta.getRootElement(),HB:a.yatta.getHistoryBuffer()._encode()},a.sendIwcIntent("Yatta_push_root_element",b)}}(this),this.iwcHandler.Yatta_get_root_element=[j]}return a.prototype.getRootElement=function(){return h},a.prototype.send=function(a){return a.uid.creator===this.HB.getUserId()&&"string"!=typeof a.uid.op_number?this.sendIwcIntent("Yatta_new_operation",a):void 0},a.prototype.receive=function(a){return a.uid.creator!==this.HB.getUserId()?this.engine.applyOp(a):void 0},a.prototype.sendIwcIntent=function(a,b){var c;return c={action:a,component:"",data:"",dataType:"",extras:b},this.duiClient.sendIntent(c)},a.prototype.sync=function(){throw new Error("Can't use this a.t.m.")},a}(),d={action:"Yatta_get_root_element",component:"",data:"",dataType:"",extras:{}},e=function(){var e,i;return c.sendIntent(d),e=!1,i=function(d){var f;return f=c.getIwcClient()._componentName,h=null!=d?d.extras.root_element:void 0,g=null!=d?d.extras.HB:void 0,e?void 0:(e=!0,a(b,f))},f.Yatta_push_root_element=[i],setTimeout(i,800)},void setTimeout(e,4e3*Math.random())},b.exports=c,"undefined"!=typeof window&&null!==window&&(window.createConnector=c)},{}],2:[function(a,b){var c;c=function(){function a(a,b){this.HB=a,this.parser=b,this.unprocessed_ops=[]}return a.prototype.parseOperation=function(a){var b;if(b=this.parser[a.type],null!=b)return b(a);throw new Error("You forgot to specify a parser for type "+a.type+". The message is "+JSON.stringify(a)+".")},a.prototype.applyOps=function(a){var b,c,d,e,f,g,h,i;for(c=[],d=0,g=a.length;g>d;d++)b=a[d],c.push(this.parseOperation(b));for(e=0,h=c.length;h>e;e++)b=c[e],this.HB.addOperation(b);for(f=0,i=c.length;i>f;f++)b=c[f],b.execute()||this.unprocessed_ops.push(b);return this.tryUnprocessed()},a.prototype.applyOp=function(a){var b;return b=this.parseOperation(a),this.HB.addOperation(b),b.execute()||this.unprocessed_ops.push(b),this.tryUnprocessed()},a.prototype.tryUnprocessed=function(){var a,b,c,d,e,f,g;for(g=[];;){for(a=this.unprocessed_ops.length,c=[],f=this.unprocessed_ops,d=0,e=f.length;e>d;d++)b=f[d],b.execute()||c.push(b);if(this.unprocessed_ops=c,this.unprocessed_ops.length===a)break;g.push(void 0)}return g},a}(),b.exports=c},{}],3:[function(a,b){var c,d,e,f;f=a("../Types/JsonTypes.coffee"),d=a("../HistoryBuffer.coffee"),c=a("../Engine.coffee"),e=function(){function a(a,b){var e,g,h;this.HB=new d(a),g=f(this.HB),this.engine=new c(this.HB,g.parser),this.connector=new b(this.engine,this.HB,g.execution_listener,this),h=this.connector.getRootElement(),null==h?(e=new g.types.JsonType(this.HB.getNextOperationIdentifier()),this.HB.addOperation(e),e.execute(),this.root_element=e):this.root_element=this.HB.getOperation(h)}return a.prototype.getRootElement=function(){return this.root_element},a.prototype.getEngine=function(){return this.engine},a.prototype.getConnector=function(){return this.connector},a.prototype.getHistoryBuffer=function(){return this.HB},a.prototype.setMutableDefault=function(a){return this.root_element.setMutableDefault(a)},a.prototype.getUserId=function(){return this.HB.getUserId()},a.prototype.val=function(a,b,c){return this.root_element.val(a,b,c)},Object.defineProperty(a.prototype,"value",{get:function(){return this.root_element.value},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),a}(),"undefined"!=typeof window&&null!==window&&(window.JsonYatta=e),b.exports=e},{"../Engine.coffee":2,"../HistoryBuffer.coffee":4,"../Types/JsonTypes.coffee":6}],4:[function(a,b){var c;c=function(){function a(a){this.user_id=a,this.operation_counter={},this.buffer={},this.change_listeners=[]}return a.prototype.getUserId=function(){return this.user_id},a.prototype.getOperationCounter=function(){var a,b,c,d;b={},d=this.operation_counter;for(c in d)a=d[c],b[c]=a;return b},a.prototype._encode=function(){var a,b,c,d,e,f;a=[],f=this.buffer;for(d in f){e=f[d];for(c in e)b=e[c],isNaN(parseInt(c))||a.push(b._encode())}return a},a.prototype.getNextOperationIdentifier=function(a){var b;return null==a&&(a=this.user_id),null==this.operation_counter[a]&&(this.operation_counter[a]=0),b={creator:a,op_number:this.operation_counter[a]},this.operation_counter[a]++,b},a.prototype.getOperation=function(a){var b;if(a instanceof Object)return null!=(b=this.buffer[a.creator])?b[a.op_number]:void 0;if(null!=a)throw new Error("This type of uid is not defined!")},a.prototype.addOperation=function(a){if(null==this.buffer[a.creator]&&(this.buffer[a.creator]={}),null==this.operation_counter[a.creator]&&(this.operation_counter[a.creator]=0),null!=this.buffer[a.creator][a.op_number])throw new Error("You must not overwrite operations!");return this.buffer[a.creator][a.op_number]=a,"number"==typeof a.op_number&&a.creator!==this.getUserId()&&this.operation_counter[a.creator]++,a},a}(),b.exports=c},{}],5:[function(a,b){var c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};b.exports=function(a){var b,c,e,f,g,h,i;return i={},h=[],g=function(){function b(b){null==b&&(b=a.getNextOperationIdentifier()),this.creator=b.creator,this.op_number=b.op_number}return b.prototype.getUid=function(){return{creator:this.creator,op_number:this.op_number}},b.prototype.execute=function(){var a,b,c;for(this.is_executed=!0,b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this},b.prototype.saveOperation=function(a,b){return null!=(null!=b?b.execute:void 0)?this[a]=b:null!=b?(null==this.unchecked&&(this.unchecked={}),this.unchecked[a]=b):void 0},b.prototype.validateSavedOperations=function(){var b,c,d,e,f,g;f={},e=this,g=this.unchecked;for(b in g)d=g[b],c=a.getOperation(d),c?this[b]=c:(f[b]=d,e=!1);return delete this.unchecked,e||(this.unchecked=f),e},b}(),b=function(a){function b(a,c){this.saveOperation("deletes",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype._encode=function(){return{type:"Delete",uid:this.getUid(),deletes:this.deletes.getUid()}},b.prototype.execute=function(){return this.validateSavedOperations()?(this.deletes.applyDelete(this),b.__super__.execute.apply(this,arguments),this):!1},b}(g),i.Delete=function(a){var c,d;return d=a.uid,c=a.deletes,new b(d,c)},f=function(a){function b(a,c,d,e){this.saveOperation("prev_cl",c),this.saveOperation("next_cl",d),null!=e?this.saveOperation("origin",e):this.saveOperation("origin",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype.applyDelete=function(a){return null==this.deleted_by&&(this.deleted_by=[]),this.deleted_by.push(a)},b.prototype.isDeleted=function(){var a;return(null!=(a=this.deleted_by)?a.length:void 0)>0},b.prototype.getDistanceToOrigin=function(){var a,b;for(a=0,b=this.prev_cl;this.origin!==b;){if(a++,this===this.prev_cl)throw new Error("this should not happen ;) ");b=b.prev_cl}return a},b.prototype.update_sl=function(){var a;return a=this.prev_cl,update("prev_cl","prev_sl"),update("next_cl","prev_sl")},b.prototype.execute=function(){var a,c,d,e,f;if(null!=this.is_executed)return this;if(this.validateSavedOperations()){if((null!=(e=this.prev_cl)?e.validateSavedOperations():void 0)&&(null!=(f=this.next_cl)?f.validateSavedOperations():void 0)&&this.prev_cl.next_cl!==this){for(a=0,d=this.prev_cl.next_cl,c=0;null==d&&(console.log(JSON.stringify(this.prev_cl.getUid())),console.log(JSON.stringify(this.next_cl.getUid()))),d!==this.next_cl;){if(d.getDistanceToOrigin()===c)d.creator<this.creator&&(this.prev_cl=d,a=c+1);else{if(!(d.getDistanceToOrigin()<c))break;c-a<=d.getDistanceToOrigin()&&(this.prev_cl=d,a=c+1)}c++,d=d.next_cl}this.next_cl=this.prev_cl.next_cl,this.prev_cl.next_cl=this,this.next_cl.prev_cl=this}return b.__super__.execute.apply(this,arguments),this}return!1},b}(g),e=function(a){function b(a,c,d,e,f){this.content=null!=c?c:"",b.__super__.constructor.call(this,a,d,e,f)}return d(b,a),b.prototype.val=function(){return this.content},b.prototype._encode=function(){var a;return a={type:"ImmutableObject",uid:this.getUid(),content:this.content},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(f),i.ImmutableObject=function(a){var b,c,d,f,g;return g=a.uid,b=a.content,f=a.prev,c=a.next,d=a.origin,new e(g,b,f,c,d)},c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return d(b,a),b.prototype.execute=function(){var a,b,c;if(this.validateSavedOperations()){for(b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this}return!1},b.prototype._encode=function(){var a,b;return{type:"Delimiter",uid:this.getUid(),prev:null!=(a=this.prev_cl)?a.getUid():void 0,next:null!=(b=this.next_cl)?b.getUid():void 0}},b}(f),i.Delimiter=function(a){var b,d,e;return e=a.uid,d=a.prev,b=a.next,new c(e,d,b)},{types:{Delete:b,Insert:f,Delimiter:c,Operation:g,ImmutableObject:e},parser:i,execution_listener:h}}},{}],6:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./TextTypes.coffee"),b.exports=function(a){var b,d,f,g,h;return g=c(a),h=g.types,f=g.parser,d=function(a){var c;return new(c=function(){function a(c){var e,f,g,i;i=c.map,g=function(e,f){return Object.defineProperty(a.prototype,e,{get:function(){var a;return a=f.val(),a instanceof b?d(a):a instanceof h.ImmutableObject?a.val():a},set:function(a){var b,d,f,g;if(a.constructor==={}.constructor){f=c.val(e),g=[];for(b in a)d=a[b],g.push(f.val(b,d,"immutable"));return g}return c.val(e,a,"immutable")},enumerable:!0,configurable:!1})};for(e in i)f=i[e],g(e,f)}return a}())(a)},b=function(b){function c(a,b,d){var e,f;if(c.__super__.constructor.call(this,a),null!=b){if("object"!=typeof b)throw new Error("The initial value of JsonTypes must be of type Object! (current type: "+typeof b+")");for(e in b)f=b[e],this.val(e,f,d)}}return e(c,b),c.prototype.mutable_default=!0,c.prototype.setMutableDefault=function(a){if(a===!0||"mutable"===a)c.prototype.mutable_default=!0;else{if(a!==!1&&"immutable"!==a)throw new Error('Set mutable either "mutable" or "immutable"!');c.prototype.mutable_default=!1}return"OK"},c.prototype.val=function(b,d,e){var f,g,i,j,k;if("object"==typeof b){for(i in b)g=b[i],this.val(i,g,d);return this}if(null!=b&&null!=d){if(e=null!=e?e===!0||"mutable"===e?!0:!1:this.mutable_default,"function"==typeof d)return this;if(e&&"number"!=typeof d||d.constructor===Object){if("string"==typeof d)return k=a.addOperation(new h.Word(a.getNextOperationIdentifier(),d)).execute(),c.__super__.val.call(this,b,k);if(d.constructor===Object)return f=a.addOperation(new c(a.getNextOperationIdentifier(),d,e)).execute(),c.__super__.val.call(this,b,f);throw new Error("You must not set "+typeof d+"-types in collaborative Json-objects!")}return j=a.addOperation(new h.ImmutableObject(void 0,d)).execute(),c.__super__.val.call(this,b,j)}return c.__super__.val.call(this,b,d)},Object.defineProperty(c.prototype,"value",{get:function(){return d(this)},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),c.prototype._encode=function(){return{type:"JsonType",uid:this.getUid()}},c}(h.MapManager),f.JsonType=function(a){var c;return c=a.uid,new b(c)},h.JsonType=b,g}},{"./TextTypes.coffee":8}],7:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./BasicTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i,j,k;return i=c(a),k=i.types,j=i.parser,f=function(c){function d(a){this.map={},d.__super__.constructor.call(this,a)}return e(d,c),d.prototype.val=function(c,e){var f,g,h,i,j;if(null!=e)return null==this.map[c]&&a.addOperation(new b(a.getNextOperationIdentifier(),this,c)).execute(),this.map[c].replace(e),this;if(null!=c)return g=null!=(i=this.map[c])?i.val():void 0,g instanceof k.ImmutableObject?g.val():g;h={},j=this.map;for(c in j)f=j[c],g=f.val(),(g instanceof k.ImmutableObject||g instanceof d)&&(g=g.val()),h[c]=g;return h},d}(k.Operation),b=function(b){function c(a,b,d){this.name=d,this.saveOperation("map_manager",b),c.__super__.constructor.call(this,a)}return e(c,b),c.prototype.execute=function(){var b,d,e,f,h;return this.validateSavedOperations()?(h=this.map_manager.getUid(),h.op_number="_"+h.op_number+"_RM_"+this.name,null==a.getOperation(h)&&(e=this.map_manager.getUid(),e.op_number="_"+e.op_number+"_RM_"+this.name+"_beginning",f=this.map_manager.getUid(),f.op_number="_"+f.op_number+"_RM_"+this.name+"_end",b=a.addOperation(new k.Delimiter(e,void 0,f)),d=a.addOperation(new k.Delimiter(f,b,void 0)).execute(),b.execute(),this.map_manager.map[this.name]=a.addOperation(new g(void 0,h,b,d)).execute()),c.__super__.execute.apply(this,arguments)):!1},c.prototype._encode=function(){return{type:"AddName",uid:this.getUid(),map_manager:this.map_manager.getUid(),name:this.name}},c}(k.Operation),j.AddName=function(a){var c,d,e;return c=a.map_manager,e=a.uid,d=a.name,new b(e,c,d)},d=function(b){function c(b,d,e,f,g,h){null!=d&&null!=e?(this.saveOperation("beginning",d),this.saveOperation("end",e)):(this.beginning=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),void 0,void 0)),this.end=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),this.beginning,void 0)),this.beginning.next_cl=this.end,this.beginning.execute(),this.end.execute()),c.__super__.constructor.call(this,b,f,g,h)}return e(c,b),c.prototype.getLastOperation=function(){return this.end.prev_cl},c.prototype.getFirstOperation=function(){return this.beginning.next_cl},c.prototype.toArray=function(){var a,b;for(a=this.beginning.next_cl,b=[];a!==this.end;)b.push(a),a=a.next_cl;return b},c.prototype.getOperationByPosition=function(a){var b;if(b=this.beginning.next_cl,a>0)for(;b=b.next_cl,b.isDeleted()||(a-=1),0!==a;)if(b instanceof k.Delimiter)throw new Error("position parameter exceeded the length of the document!");return b},c}(k.Insert),g=function(b){function c(a,b,d,e,f,g,h){c.__super__.constructor.call(this,b,d,e,f,g,h),null!=a&&this.replace(a)}return e(c,b),c.prototype.replace=function(b){var c,d;return c=this.getLastOperation(),d=new h(b,this,a.getNextOperationIdentifier(),c,c.next_cl),a.addOperation(d).execute()},c.prototype.val=function(){var a;if(a=this.getLastOperation(),a instanceof k.Delimiter)throw new Error("dtrn");return a.val()},c.prototype._encode=function(){var a;return a={type:"ReplaceManager",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&null!=this.next_cl&&(a.prev=this.prev_cl.getUid(),a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},c}(d),j.ReplaceManager=function(a){var b,c,d,e,f,h,i;return c=a.content,i=a.uid,h=a.prev,e=a.next,f=a.origin,b=a.beginning,d=a.end,new g(c,i,b,d,h,e,f)},h=function(a){function b(a,c,d,e,f,g){if(this.saveOperation("content",a),this.saveOperation("parent",c),null==e||null==f||null==a)throw new Error("You must define content, prev, and next for Replaceable-types!");b.__super__.constructor.call(this,d,e,f,g)}return e(b,a),b.prototype.val=function(){return this.content},b.prototype.replace=function(a){return this.parent.replace(a)},b.prototype.execute=function(){var a;return this.validateSavedOperations()?("function"==typeof(a=this.content).setReplaceManager&&a.setReplaceManager(this.parent),b.__super__.execute.apply(this,arguments),this):!1},b.prototype._encode=function(){var a;return a={type:"Replaceable",content:this.content.getUid(),ReplaceManager:this.parent.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid(),uid:this.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(k.Insert),j.Replaceable=function(a){var b,c,d,e,f,g;return b=a.content,e=a.ReplaceManager,g=a.uid,f=a.prev,c=a.next,d=a.origin,new h(b,e,g,f,c,d)},k.ListManager=d,k.MapManager=f,k.ReplaceManager=g,k.Replaceable=h,i}},{"./BasicTypes.coffee":5}],8:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./StructuredTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i;return h=c(a),i=h.types,g=h.parser,b=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return e(b,a),b}(i.Delete),g.TextDelete=g.Delete,d=function(a){function b(a,c,d,e,f){if(this.content=a,null==d||null==e)throw new Error("You must define prev, and next for TextInsert-types!");b.__super__.constructor.call(this,c,d,e,f)}return e(b,a),b.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},b.prototype.val=function(){return this.isDeleted()?"":this.content},b.prototype._encode=function(){var a;return a={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(i.Insert),g.TextInsert=function(a){var b,c,e,f,g;return b=a.content,g=a.uid,f=a.prev,c=a.next,e=a.origin,new d(b,g,f,c,e)},f=function(c){function f(a,b,c,d,e,g,h){f.__super__.constructor.call(this,a,c,d,e,g,h),null!=b&&this.insertText(0,b)}return e(f,c),f.prototype.insertText=function(b,c){var e,f,g,h,i,j;for(f=this.getOperationByPosition(b),j=[],h=0,i=c.length;i>h;h++)e=c[h],g=new d(e,a.getNextOperationIdentifier(),f.prev_cl,f),j.push(a.addOperation(g).execute());return j},f.prototype.deleteText=function(c,d){var e,f,g,h,j;for(g=this.getOperationByPosition(c),j=[],f=h=0;d>=0?d>h:h>d;f=d>=0?++h:--h){for(e=a.addOperation(new b(a.getNextOperationIdentifier(),g)).execute(),g=g.next_cl;g.isDeleted();){if(g instanceof i.Delimiter)throw new Error("You can't delete more than there is..");g=g.next_cl}j.push(e._encode())}return j},f.prototype.replaceText=function(b){var c;if(null!=this.replace_manager)return c=a.addOperation(new f(a.getNextOperationIdentifier())).execute(),c.insertText(0,b),this.replace_manager.replace(c);throw new Error("This type is currently not maintained by a ReplaceManager!")},f.prototype.val=function(){var a,b;return a=function(){var a,c,d,e;for(d=this.toArray(),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(null!=b.val?b.val():"");return e}.call(this),a.join("")},f.prototype.setReplaceManager=function(a){return this.saveOperation("replace_manager",a),this.validateSavedOperations},f.prototype._encode=function(){var a;return a={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},f}(i.ListManager),g.Word=function(a){var b,c,d,e,g,h;return h=a.uid,b=a.beginning,c=a.end,g=a.prev,d=a.next,e=a.origin,new f(h,void 0,b,c,g,d,e)},i.TextInsert=d,i.TextDelete=b,i.Word=f,h}},{"./StructuredTypes.coffee":7}]},{},[3,1]),!function j(a,b,c){function d(f,g){if(!b[f]){if(!a[f]){var h="function"==typeof require&&require;if(!g&&h)return h(f,!0);if(e)return e(f,!0);throw new Error("Cannot find module '"+f+"'")}var i=b[f]={exports:{}};a[f][0].call(i.exports,function(b){var c=a[f][1][b];return d(c?c:b)},i,i.exports,j,a,b,c)}return b[f].exports}for(var e="function"==typeof require&&require,f=0;f<c.length;f++)d(c[f]);return d}({1:[function(a,b){var c;c=function(a){var b,c,d,e,f,g,h;return f={},c=new DUIClient,c.connect(function(a){var b;return null!=(b=f[a.action])?b.map(function(b){return setTimeout(function(){return b(a)},0)}):void 0}),c.initOK(),h=null,g=null,b=function(){function a(a,b,d,e){var i,j,k;this.engine=a,this.HB=b,this.execution_listener=d,this.yatta=e,this.duiClient=c,this.iwcHandler=f,k=function(a){return function(b){return a.send(b)}}(this),this.execution_listener.push(k),i=function(a){return function(b){var c;return c=b.extras,a.receive(c)}}(this),this.iwcHandler.Yatta_new_operation=[i],null!=h&&this.engine.applyOps(g),j=function(a){return function(){var b;return b={root_element:a.yatta.getRootElement(),HB:a.yatta.getHistoryBuffer()._encode()},a.sendIwcIntent("Yatta_push_root_element",b)}}(this),this.iwcHandler.Yatta_get_root_element=[j]}return a.prototype.getRootElement=function(){return h},a.prototype.send=function(a){return a.uid.creator===this.HB.getUserId()&&"string"!=typeof a.uid.op_number?this.sendIwcIntent("Yatta_new_operation",a):void 0},a.prototype.receive=function(a){return a.uid.creator!==this.HB.getUserId()?this.engine.applyOp(a):void 0},a.prototype.sendIwcIntent=function(a,b){var c;return c={action:a,component:"",data:"",dataType:"",extras:b},this.duiClient.sendIntent(c)},a.prototype.sync=function(){throw new Error("Can't use this a.t.m.")},a}(),d={action:"Yatta_get_root_element",component:"",data:"",dataType:"",extras:{}},e=function(){var e,i;return c.sendIntent(d),e=!1,i=function(d){var f;return f=c.getIwcClient()._componentName,h=null!=d?d.extras.root_element:void 0,g=null!=d?d.extras.HB:void 0,e?void 0:(e=!0,a(b,f))},f.Yatta_push_root_element=[i],setTimeout(i,800)},void setTimeout(e,4e3*Math.random())},b.exports=c,"undefined"!=typeof window&&null!==window&&(window.createConnector=c)},{}],2:[function(a,b){var c;c=function(){function a(a,b){this.HB=a,this.parser=b,this.unprocessed_ops=[]}return a.prototype.parseOperation=function(a){var b;if(b=this.parser[a.type],null!=b)return b(a);throw new Error("You forgot to specify a parser for type "+a.type+". The message is "+JSON.stringify(a)+".")},a.prototype.applyOps=function(a){var b,c,d,e,f,g,h,i;for(c=[],d=0,g=a.length;g>d;d++)b=a[d],c.push(this.parseOperation(b));for(e=0,h=c.length;h>e;e++)b=c[e],this.HB.addOperation(b);for(f=0,i=c.length;i>f;f++)b=c[f],b.execute()||this.unprocessed_ops.push(b);return this.tryUnprocessed()},a.prototype.applyOp=function(a){var b;return b=this.parseOperation(a),this.HB.addOperation(b),b.execute()||this.unprocessed_ops.push(b),this.tryUnprocessed()},a.prototype.tryUnprocessed=function(){var a,b,c,d,e,f,g;for(g=[];;){for(a=this.unprocessed_ops.length,c=[],f=this.unprocessed_ops,d=0,e=f.length;e>d;d++)b=f[d],b.execute()||c.push(b);if(this.unprocessed_ops=c,this.unprocessed_ops.length===a)break;g.push(void 0)}return g},a}(),b.exports=c},{}],3:[function(a,b){var c,d,e,f;f=a("../Types/JsonTypes.coffee"),d=a("../HistoryBuffer.coffee"),c=a("../Engine.coffee"),e=function(){function a(a,b){var e,g,h;this.HB=new d(a),g=f(this.HB),this.engine=new c(this.HB,g.parser),this.connector=new b(this.engine,this.HB,g.execution_listener,this),h=this.connector.getRootElement(),null==h?(e=new g.types.JsonType(this.HB.getNextOperationIdentifier()),this.HB.addOperation(e),e.execute(),this.root_element=e):this.root_element=this.HB.getOperation(h)}return a.prototype.getRootElement=function(){return this.root_element},a.prototype.getEngine=function(){return this.engine},a.prototype.getConnector=function(){return this.connector},a.prototype.getHistoryBuffer=function(){return this.HB},a.prototype.setMutableDefault=function(a){return this.root_element.setMutableDefault(a)},a.prototype.getUserId=function(){return this.HB.getUserId()},a.prototype.val=function(a,b,c){return this.root_element.val(a,b,c)},Object.defineProperty(a.prototype,"value",{get:function(){return this.root_element.value},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),a}(),"undefined"!=typeof window&&null!==window&&(window.JsonYatta=e),b.exports=e},{"../Engine.coffee":2,"../HistoryBuffer.coffee":4,"../Types/JsonTypes.coffee":6}],4:[function(a,b){var c;c=function(){function a(a){this.user_id=a,this.operation_counter={},this.buffer={},this.change_listeners=[]}return a.prototype.getUserId=function(){return this.user_id},a.prototype.getOperationCounter=function(){var a,b,c,d;b={},d=this.operation_counter;for(c in d)a=d[c],b[c]=a;return b},a.prototype._encode=function(){var a,b,c,d,e,f;a=[],f=this.buffer;for(d in f){e=f[d];for(c in e)b=e[c],isNaN(parseInt(c))||a.push(b._encode())}return a},a.prototype.getNextOperationIdentifier=function(a){var b;return null==a&&(a=this.user_id),null==this.operation_counter[a]&&(this.operation_counter[a]=0),b={creator:a,op_number:this.operation_counter[a]},this.operation_counter[a]++,b},a.prototype.getOperation=function(a){var b;if(a instanceof Object)return null!=(b=this.buffer[a.creator])?b[a.op_number]:void 0;if(null!=a)throw new Error("This type of uid is not defined!")},a.prototype.addOperation=function(a){if(null==this.buffer[a.creator]&&(this.buffer[a.creator]={}),null==this.operation_counter[a.creator]&&(this.operation_counter[a.creator]=0),null!=this.buffer[a.creator][a.op_number])throw new Error("You must not overwrite operations!");return this.buffer[a.creator][a.op_number]=a,"number"==typeof a.op_number&&a.creator!==this.getUserId()&&this.operation_counter[a.creator]++,a},a}(),b.exports=c},{}],5:[function(a,b){var c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};b.exports=function(a){var b,c,e,f,g,h,i;return i={},h=[],g=function(){function b(b){null==b&&(b=a.getNextOperationIdentifier()),this.creator=b.creator,this.op_number=b.op_number}return b.prototype.getUid=function(){return{creator:this.creator,op_number:this.op_number}},b.prototype.execute=function(){var a,b,c;for(this.is_executed=!0,b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this},b.prototype.saveOperation=function(a,b){return null!=(null!=b?b.execute:void 0)?this[a]=b:null!=b?(null==this.unchecked&&(this.unchecked={}),this.unchecked[a]=b):void 0},b.prototype.validateSavedOperations=function(){var b,c,d,e,f,g;f={},e=this,g=this.unchecked;for(b in g)d=g[b],c=a.getOperation(d),c?this[b]=c:(f[b]=d,e=!1);return delete this.unchecked,e||(this.unchecked=f),e},b}(),b=function(a){function b(a,c){this.saveOperation("deletes",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype._encode=function(){return{type:"Delete",uid:this.getUid(),deletes:this.deletes.getUid()}},b.prototype.execute=function(){return this.validateSavedOperations()?(this.deletes.applyDelete(this),b.__super__.execute.apply(this,arguments),this):!1},b}(g),i.Delete=function(a){var c,d;return d=a.uid,c=a.deletes,new b(d,c)},f=function(a){function b(a,c,d,e){this.saveOperation("prev_cl",c),this.saveOperation("next_cl",d),null!=e?this.saveOperation("origin",e):this.saveOperation("origin",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype.applyDelete=function(a){return null==this.deleted_by&&(this.deleted_by=[]),this.deleted_by.push(a)},b.prototype.isDeleted=function(){var a;return(null!=(a=this.deleted_by)?a.length:void 0)>0},b.prototype.getDistanceToOrigin=function(){var a,b;for(a=0,b=this.prev_cl;this.origin!==b;){if(a++,this===this.prev_cl)throw new Error("this should not happen ;) ");b=b.prev_cl}return a},b.prototype.update_sl=function(){var a;return a=this.prev_cl,update("prev_cl","prev_sl"),update("next_cl","prev_sl")},b.prototype.execute=function(){var a,c,d,e,f;if(null!=this.is_executed)return this;if(this.validateSavedOperations()){if((null!=(e=this.prev_cl)?e.validateSavedOperations():void 0)&&(null!=(f=this.next_cl)?f.validateSavedOperations():void 0)&&this.prev_cl.next_cl!==this){for(a=0,d=this.prev_cl.next_cl,c=0;null==d&&(console.log(JSON.stringify(this.prev_cl.getUid())),console.log(JSON.stringify(this.next_cl.getUid()))),d!==this.next_cl;){if(d.getDistanceToOrigin()===c)d.creator<this.creator&&(this.prev_cl=d,a=c+1);else{if(!(d.getDistanceToOrigin()<c))break;
c-a<=d.getDistanceToOrigin()&&(this.prev_cl=d,a=c+1)}c++,d=d.next_cl}this.next_cl=this.prev_cl.next_cl,this.prev_cl.next_cl=this,this.next_cl.prev_cl=this}return b.__super__.execute.apply(this,arguments),this}return!1},b}(g),e=function(a){function b(a,c,d,e,f){this.content=null!=c?c:"",b.__super__.constructor.call(this,a,d,e,f)}return d(b,a),b.prototype.val=function(){return this.content},b.prototype._encode=function(){var a;return a={type:"ImmutableObject",uid:this.getUid(),content:this.content},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(f),i.ImmutableObject=function(a){var b,c,d,f,g;return g=a.uid,b=a.content,f=a.prev,c=a.next,d=a.origin,new e(g,b,f,c,d)},c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return d(b,a),b.prototype.execute=function(){var a,b,c;if(this.validateSavedOperations()){for(b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this}return!1},b.prototype._encode=function(){var a,b;return{type:"Delimiter",uid:this.getUid(),prev:null!=(a=this.prev_cl)?a.getUid():void 0,next:null!=(b=this.next_cl)?b.getUid():void 0}},b}(f),i.Delimiter=function(a){var b,d,e;return e=a.uid,d=a.prev,b=a.next,new c(e,d,b)},{types:{Delete:b,Insert:f,Delimiter:c,Operation:g,ImmutableObject:e},parser:i,execution_listener:h}}},{}],6:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./TextTypes.coffee"),b.exports=function(a){var b,d,f,g,h;return g=c(a),h=g.types,f=g.parser,d=function(a){var c;return new(c=function(){function a(c){var e,f,g,i;i=c.map,g=function(e,f){return Object.defineProperty(a.prototype,e,{get:function(){var a;return a=f.val(),a instanceof b?d(a):a instanceof h.ImmutableObject?a.val():a},set:function(a){var b,d,f,g;if(a.constructor==={}.constructor){f=c.val(e),g=[];for(b in a)d=a[b],g.push(f.val(b,d,"immutable"));return g}return c.val(e,a,"immutable")},enumerable:!0,configurable:!1})};for(e in i)f=i[e],g(e,f)}return a}())(a)},b=function(b){function c(a,b,d){var e,f;if(c.__super__.constructor.call(this,a),null!=b){if("object"!=typeof b)throw new Error("The initial value of JsonTypes must be of type Object! (current type: "+typeof b+")");for(e in b)f=b[e],this.val(e,f,d)}}return e(c,b),c.prototype.mutable_default=!0,c.prototype.setMutableDefault=function(a){if(a===!0||"mutable"===a)c.prototype.mutable_default=!0;else{if(a!==!1&&"immutable"!==a)throw new Error('Set mutable either "mutable" or "immutable"!');c.prototype.mutable_default=!1}return"OK"},c.prototype.val=function(b,d,e){var f,g,i,j,k;if("object"==typeof b){for(i in b)g=b[i],this.val(i,g,d);return this}if(null!=b&&null!=d){if(e=null!=e?e===!0||"mutable"===e?!0:!1:this.mutable_default,"function"==typeof d)return this;if(e&&"number"!=typeof d||d.constructor===Object){if("string"==typeof d)return k=a.addOperation(new h.Word(a.getNextOperationIdentifier(),d)).execute(),c.__super__.val.call(this,b,k);if(d.constructor===Object)return f=a.addOperation(new c(a.getNextOperationIdentifier(),d,e)).execute(),c.__super__.val.call(this,b,f);throw new Error("You must not set "+typeof d+"-types in collaborative Json-objects!")}return j=a.addOperation(new h.ImmutableObject(void 0,d)).execute(),c.__super__.val.call(this,b,j)}return c.__super__.val.call(this,b,d)},Object.defineProperty(c.prototype,"value",{get:function(){return d(this)},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),c.prototype._encode=function(){return{type:"JsonType",uid:this.getUid()}},c}(h.MapManager),f.JsonType=function(a){var c;return c=a.uid,new b(c)},h.JsonType=b,g}},{"./TextTypes.coffee":8}],7:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./BasicTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i,j,k;return i=c(a),k=i.types,j=i.parser,f=function(c){function d(a){this.map={},d.__super__.constructor.call(this,a)}return e(d,c),d.prototype.val=function(c,e){var f,g,h,i,j;if(null!=e)return null==this.map[c]&&a.addOperation(new b(a.getNextOperationIdentifier(),this,c)).execute(),this.map[c].replace(e),this;if(null!=c)return g=null!=(i=this.map[c])?i.val():void 0,g instanceof k.ImmutableObject?g.val():g;h={},j=this.map;for(c in j)f=j[c],g=f.val(),(g instanceof k.ImmutableObject||g instanceof d)&&(g=g.val()),h[c]=g;return h},d}(k.Operation),b=function(b){function c(a,b,d){this.name=d,this.saveOperation("map_manager",b),c.__super__.constructor.call(this,a)}return e(c,b),c.prototype.execute=function(){var b,d,e,f,h;return this.validateSavedOperations()?(h=this.map_manager.getUid(),h.op_number="_"+h.op_number+"_RM_"+this.name,null==a.getOperation(h)&&(e=this.map_manager.getUid(),e.op_number="_"+e.op_number+"_RM_"+this.name+"_beginning",f=this.map_manager.getUid(),f.op_number="_"+f.op_number+"_RM_"+this.name+"_end",b=a.addOperation(new k.Delimiter(e,void 0,f)),d=a.addOperation(new k.Delimiter(f,b,void 0)).execute(),b.execute(),this.map_manager.map[this.name]=a.addOperation(new g(void 0,h,b,d)).execute()),c.__super__.execute.apply(this,arguments)):!1},c.prototype._encode=function(){return{type:"AddName",uid:this.getUid(),map_manager:this.map_manager.getUid(),name:this.name}},c}(k.Operation),j.AddName=function(a){var c,d,e;return c=a.map_manager,e=a.uid,d=a.name,new b(e,c,d)},d=function(b){function c(b,d,e,f,g,h){null!=d&&null!=e?(this.saveOperation("beginning",d),this.saveOperation("end",e)):(this.beginning=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),void 0,void 0)),this.end=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),this.beginning,void 0)),this.beginning.next_cl=this.end,this.beginning.execute(),this.end.execute()),c.__super__.constructor.call(this,b,f,g,h)}return e(c,b),c.prototype.getLastOperation=function(){return this.end.prev_cl},c.prototype.getFirstOperation=function(){return this.beginning.next_cl},c.prototype.toArray=function(){var a,b;for(a=this.beginning.next_cl,b=[];a!==this.end;)b.push(a),a=a.next_cl;return b},c.prototype.getOperationByPosition=function(a){var b;if(b=this.beginning.next_cl,a>0)for(;b=b.next_cl,b.isDeleted()||(a-=1),0!==a;)if(b instanceof k.Delimiter)throw new Error("position parameter exceeded the length of the document!");return b},c}(k.Insert),g=function(b){function c(a,b,d,e,f,g,h){c.__super__.constructor.call(this,b,d,e,f,g,h),null!=a&&this.replace(a)}return e(c,b),c.prototype.replace=function(b){var c,d;return c=this.getLastOperation(),d=new h(b,this,a.getNextOperationIdentifier(),c,c.next_cl),a.addOperation(d).execute()},c.prototype.val=function(){var a;if(a=this.getLastOperation(),a instanceof k.Delimiter)throw new Error("dtrn");return a.val()},c.prototype._encode=function(){var a;return a={type:"ReplaceManager",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&null!=this.next_cl&&(a.prev=this.prev_cl.getUid(),a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},c}(d),j.ReplaceManager=function(a){var b,c,d,e,f,h,i;return c=a.content,i=a.uid,h=a.prev,e=a.next,f=a.origin,b=a.beginning,d=a.end,new g(c,i,b,d,h,e,f)},h=function(a){function b(a,c,d,e,f,g){if(this.saveOperation("content",a),this.saveOperation("parent",c),null==e||null==f||null==a)throw new Error("You must define content, prev, and next for Replaceable-types!");b.__super__.constructor.call(this,d,e,f,g)}return e(b,a),b.prototype.val=function(){return this.content},b.prototype.replace=function(a){return this.parent.replace(a)},b.prototype.execute=function(){var a;return this.validateSavedOperations()?("function"==typeof(a=this.content).setReplaceManager&&a.setReplaceManager(this.parent),b.__super__.execute.apply(this,arguments),this):!1},b.prototype._encode=function(){var a;return a={type:"Replaceable",content:this.content.getUid(),ReplaceManager:this.parent.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid(),uid:this.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(k.Insert),j.Replaceable=function(a){var b,c,d,e,f,g;return b=a.content,e=a.ReplaceManager,g=a.uid,f=a.prev,c=a.next,d=a.origin,new h(b,e,g,f,c,d)},k.ListManager=d,k.MapManager=f,k.ReplaceManager=g,k.Replaceable=h,i}},{"./BasicTypes.coffee":5}],8:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./StructuredTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i;return h=c(a),i=h.types,g=h.parser,b=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return e(b,a),b}(i.Delete),g.TextDelete=g.Delete,d=function(a){function b(a,c,d,e,f){if(this.content=a,null==d||null==e)throw new Error("You must define prev, and next for TextInsert-types!");b.__super__.constructor.call(this,c,d,e,f)}return e(b,a),b.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},b.prototype.val=function(){return this.isDeleted()?"":this.content},b.prototype._encode=function(){var a;return a={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(i.Insert),g.TextInsert=function(a){var b,c,e,f,g;return b=a.content,g=a.uid,f=a.prev,c=a.next,e=a.origin,new d(b,g,f,c,e)},f=function(c){function f(a,b,c,d,e,g,h){f.__super__.constructor.call(this,a,c,d,e,g,h),null!=b&&this.insertText(0,b)}return e(f,c),f.prototype.insertText=function(b,c){var e,f,g,h,i,j;for(f=this.getOperationByPosition(b),j=[],h=0,i=c.length;i>h;h++)e=c[h],g=new d(e,a.getNextOperationIdentifier(),f.prev_cl,f),j.push(a.addOperation(g).execute());return j},f.prototype.deleteText=function(c,d){var e,f,g,h,j;for(g=this.getOperationByPosition(c),j=[],f=h=0;d>=0?d>h:h>d;f=d>=0?++h:--h){for(e=a.addOperation(new b(a.getNextOperationIdentifier(),g)).execute(),g=g.next_cl;g.isDeleted();){if(g instanceof i.Delimiter)throw new Error("You can't delete more than there is..");g=g.next_cl}j.push(e._encode())}return j},f.prototype.replaceText=function(b){var c;if(null!=this.replace_manager)return c=a.addOperation(new f(a.getNextOperationIdentifier())).execute(),c.insertText(0,b),this.replace_manager.replace(c);throw new Error("This type is currently not maintained by a ReplaceManager!")},f.prototype.val=function(){var a,b;return a=function(){var a,c,d,e;for(d=this.toArray(),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(null!=b.val?b.val():"");return e}.call(this),a.join("")},f.prototype.setReplaceManager=function(a){return this.saveOperation("replace_manager",a),this.validateSavedOperations},f.prototype._encode=function(){var a;return a={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},f}(i.ListManager),g.Word=function(a){var b,c,d,e,g,h;return h=a.uid,b=a.beginning,c=a.end,g=a.prev,d=a.next,e=a.origin,new f(h,void 0,b,c,g,d,e)},i.TextInsert=d,i.TextDelete=b,i.Word=f,h}},{"./StructuredTypes.coffee":7}]},{},[3,1]),!function k(a,b,c){function d(f,g){if(!b[f]){if(!a[f]){var h="function"==typeof require&&require;if(!g&&h)return h(f,!0);if(e)return e(f,!0);throw new Error("Cannot find module '"+f+"'")}var i=b[f]={exports:{}};a[f][0].call(i.exports,function(b){var c=a[f][1][b];return d(c?c:b)},i,i.exports,k,a,b,c)}return b[f].exports}for(var e="function"==typeof require&&require,f=0;f<c.length;f++)d(c[f]);return d}({1:[function(a,b){var c;c=function(a){var b,c,d,e,f,g,h;return f={},c=new DUIClient,c.connect(function(a){var b;return null!=(b=f[a.action])?b.map(function(b){return setTimeout(function(){return b(a)},0)}):void 0}),c.initOK(),h=null,g=null,b=function(){function a(a,b,d,e){var i,j,k;this.engine=a,this.HB=b,this.execution_listener=d,this.yatta=e,this.duiClient=c,this.iwcHandler=f,k=function(a){return function(b){return a.send(b)}}(this),this.execution_listener.push(k),i=function(a){return function(b){var c;return c=b.extras,a.receive(c)}}(this),this.iwcHandler.Yatta_new_operation=[i],null!=h&&this.engine.applyOps(g),j=function(a){return function(){var b;return b={root_element:a.yatta.getRootElement(),HB:a.yatta.getHistoryBuffer()._encode()},a.sendIwcIntent("Yatta_push_root_element",b)}}(this),this.iwcHandler.Yatta_get_root_element=[j]}return a.prototype.getRootElement=function(){return h},a.prototype.send=function(a){return a.uid.creator===this.HB.getUserId()&&"string"!=typeof a.uid.op_number?this.sendIwcIntent("Yatta_new_operation",a):void 0},a.prototype.receive=function(a){return a.uid.creator!==this.HB.getUserId()?this.engine.applyOp(a):void 0},a.prototype.sendIwcIntent=function(a,b){var c;return c={action:a,component:"",data:"",dataType:"",extras:b},this.duiClient.sendIntent(c)},a.prototype.sync=function(){throw new Error("Can't use this a.t.m.")},a}(),d={action:"Yatta_get_root_element",component:"",data:"",dataType:"",extras:{}},e=function(){var e,i;return c.sendIntent(d),e=!1,i=function(d){var f;return f=c.getIwcClient()._componentName,h=null!=d?d.extras.root_element:void 0,g=null!=d?d.extras.HB:void 0,e?void 0:(e=!0,a(b,f))},f.Yatta_push_root_element=[i],setTimeout(i,800)},void setTimeout(e,4e3*Math.random())},b.exports=c,"undefined"!=typeof window&&null!==window&&(window.createConnector=c)},{}],2:[function(a,b){var c;c=function(){function a(a,b){this.HB=a,this.parser=b,this.unprocessed_ops=[]}return a.prototype.parseOperation=function(a){var b;if(b=this.parser[a.type],null!=b)return b(a);throw new Error("You forgot to specify a parser for type "+a.type+". The message is "+JSON.stringify(a)+".")},a.prototype.applyOps=function(a){var b,c,d,e,f,g,h,i;for(c=[],d=0,g=a.length;g>d;d++)b=a[d],c.push(this.parseOperation(b));for(e=0,h=c.length;h>e;e++)b=c[e],this.HB.addOperation(b);for(f=0,i=c.length;i>f;f++)b=c[f],b.execute()||this.unprocessed_ops.push(b);return this.tryUnprocessed()},a.prototype.applyOp=function(a){var b;return b=this.parseOperation(a),this.HB.addOperation(b),b.execute()||this.unprocessed_ops.push(b),this.tryUnprocessed()},a.prototype.tryUnprocessed=function(){var a,b,c,d,e,f,g;for(g=[];;){for(a=this.unprocessed_ops.length,c=[],f=this.unprocessed_ops,d=0,e=f.length;e>d;d++)b=f[d],b.execute()||c.push(b);if(this.unprocessed_ops=c,this.unprocessed_ops.length===a)break;g.push(void 0)}return g},a}(),b.exports=c},{}],3:[function(a,b){var c,d,e,f;f=a("../Types/JsonTypes.coffee"),d=a("../HistoryBuffer.coffee"),c=a("../Engine.coffee"),e=function(){function a(a,b){var e,g,h;this.HB=new d(a),g=f(this.HB),this.engine=new c(this.HB,g.parser),this.connector=new b(this.engine,this.HB,g.execution_listener,this),h=this.connector.getRootElement(),null==h?(e=new g.types.JsonType(this.HB.getNextOperationIdentifier()),this.HB.addOperation(e),e.execute(),this.root_element=e):this.root_element=this.HB.getOperation(h)}return a.prototype.getRootElement=function(){return this.root_element},a.prototype.getEngine=function(){return this.engine},a.prototype.getConnector=function(){return this.connector},a.prototype.getHistoryBuffer=function(){return this.HB},a.prototype.setMutableDefault=function(a){return this.root_element.setMutableDefault(a)},a.prototype.getUserId=function(){return this.HB.getUserId()},a.prototype.val=function(a,b,c){return this.root_element.val(a,b,c)},Object.defineProperty(a.prototype,"value",{get:function(){return this.root_element.value},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),a}(),"undefined"!=typeof window&&null!==window&&(window.JsonYatta=e),b.exports=e},{"../Engine.coffee":2,"../HistoryBuffer.coffee":4,"../Types/JsonTypes.coffee":6}],4:[function(a,b){var c;c=function(){function a(a){this.user_id=a,this.operation_counter={},this.buffer={},this.change_listeners=[]}return a.prototype.getUserId=function(){return this.user_id},a.prototype.getOperationCounter=function(){var a,b,c,d;b={},d=this.operation_counter;for(c in d)a=d[c],b[c]=a;return b},a.prototype._encode=function(){var a,b,c,d,e,f;a=[],f=this.buffer;for(d in f){e=f[d];for(c in e)b=e[c],isNaN(parseInt(c))||a.push(b._encode())}return a},a.prototype.getNextOperationIdentifier=function(a){var b;return null==a&&(a=this.user_id),null==this.operation_counter[a]&&(this.operation_counter[a]=0),b={creator:a,op_number:this.operation_counter[a]},this.operation_counter[a]++,b},a.prototype.getOperation=function(a){var b;if(a instanceof Object)return null!=(b=this.buffer[a.creator])?b[a.op_number]:void 0;if(null!=a)throw new Error("This type of uid is not defined!")},a.prototype.addOperation=function(a){if(null==this.buffer[a.creator]&&(this.buffer[a.creator]={}),null==this.operation_counter[a.creator]&&(this.operation_counter[a.creator]=0),null!=this.buffer[a.creator][a.op_number])throw new Error("You must not overwrite operations!");return this.buffer[a.creator][a.op_number]=a,"number"==typeof a.op_number&&a.creator!==this.getUserId()&&this.operation_counter[a.creator]++,a},a}(),b.exports=c},{}],5:[function(a,b){var c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};b.exports=function(a){var b,c,e,f,g,h,i;return i={},h=[],g=function(){function b(b){null==b&&(b=a.getNextOperationIdentifier()),this.creator=b.creator,this.op_number=b.op_number}return b.prototype.getUid=function(){return{creator:this.creator,op_number:this.op_number}},b.prototype.execute=function(){var a,b,c;for(this.is_executed=!0,b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this},b.prototype.saveOperation=function(a,b){return null!=(null!=b?b.execute:void 0)?this[a]=b:null!=b?(null==this.unchecked&&(this.unchecked={}),this.unchecked[a]=b):void 0},b.prototype.validateSavedOperations=function(){var b,c,d,e,f,g;f={},e=this,g=this.unchecked;for(b in g)d=g[b],c=a.getOperation(d),c?this[b]=c:(f[b]=d,e=!1);return delete this.unchecked,e||(this.unchecked=f),e},b}(),b=function(a){function b(a,c){this.saveOperation("deletes",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype._encode=function(){return{type:"Delete",uid:this.getUid(),deletes:this.deletes.getUid()}},b.prototype.execute=function(){return this.validateSavedOperations()?(this.deletes.applyDelete(this),b.__super__.execute.apply(this,arguments),this):!1},b}(g),i.Delete=function(a){var c,d;return d=a.uid,c=a.deletes,new b(d,c)},f=function(a){function b(a,c,d,e){this.saveOperation("prev_cl",c),this.saveOperation("next_cl",d),null!=e?this.saveOperation("origin",e):this.saveOperation("origin",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype.applyDelete=function(a){return null==this.deleted_by&&(this.deleted_by=[]),this.deleted_by.push(a)},b.prototype.isDeleted=function(){var a;return(null!=(a=this.deleted_by)?a.length:void 0)>0},b.prototype.getDistanceToOrigin=function(){var a,b;for(a=0,b=this.prev_cl;this.origin!==b;){if(a++,this===this.prev_cl)throw new Error("this should not happen ;) ");b=b.prev_cl}return a},b.prototype.update_sl=function(){var a;return a=this.prev_cl,update("prev_cl","prev_sl"),update("next_cl","prev_sl")},b.prototype.execute=function(){var a,c,d,e,f;if(null!=this.is_executed)return this;if(this.validateSavedOperations()){if((null!=(e=this.prev_cl)?e.validateSavedOperations():void 0)&&(null!=(f=this.next_cl)?f.validateSavedOperations():void 0)&&this.prev_cl.next_cl!==this){for(a=0,d=this.prev_cl.next_cl,c=0;null==d&&(console.log(JSON.stringify(this.prev_cl.getUid())),console.log(JSON.stringify(this.next_cl.getUid()))),d!==this.next_cl;){if(d.getDistanceToOrigin()===c)d.creator<this.creator&&(this.prev_cl=d,a=c+1);else{if(!(d.getDistanceToOrigin()<c))break;c-a<=d.getDistanceToOrigin()&&(this.prev_cl=d,a=c+1)}c++,d=d.next_cl}this.next_cl=this.prev_cl.next_cl,this.prev_cl.next_cl=this,this.next_cl.prev_cl=this}return b.__super__.execute.apply(this,arguments),this}return!1},b}(g),e=function(a){function b(a,c,d,e,f){this.content=null!=c?c:"",b.__super__.constructor.call(this,a,d,e,f)}return d(b,a),b.prototype.val=function(){return this.content},b.prototype._encode=function(){var a;return a={type:"ImmutableObject",uid:this.getUid(),content:this.content},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(f),i.ImmutableObject=function(a){var b,c,d,f,g;return g=a.uid,b=a.content,f=a.prev,c=a.next,d=a.origin,new e(g,b,f,c,d)},c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return d(b,a),b.prototype.execute=function(){var a,b,c;if(this.validateSavedOperations()){for(b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this}return!1},b.prototype._encode=function(){var a,b;return{type:"Delimiter",uid:this.getUid(),prev:null!=(a=this.prev_cl)?a.getUid():void 0,next:null!=(b=this.next_cl)?b.getUid():void 0}},b}(f),i.Delimiter=function(a){var b,d,e;return e=a.uid,d=a.prev,b=a.next,new c(e,d,b)},{types:{Delete:b,Insert:f,Delimiter:c,Operation:g,ImmutableObject:e},parser:i,execution_listener:h}}},{}],6:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./TextTypes.coffee"),b.exports=function(a){var b,d,f,g,h;return g=c(a),h=g.types,f=g.parser,d=function(a){var c;return new(c=function(){function a(c){var e,f,g,i;i=c.map,g=function(e,f){return Object.defineProperty(a.prototype,e,{get:function(){var a;return a=f.val(),a instanceof b?d(a):a instanceof h.ImmutableObject?a.val():a},set:function(a){var b,d,f,g;if(a.constructor==={}.constructor){f=c.val(e),g=[];for(b in a)d=a[b],g.push(f.val(b,d,"immutable"));return g}return c.val(e,a,"immutable")},enumerable:!0,configurable:!1})};for(e in i)f=i[e],g(e,f)}return a}())(a)},b=function(b){function c(a,b,d){var e,f;if(c.__super__.constructor.call(this,a),null!=b){if("object"!=typeof b)throw new Error("The initial value of JsonTypes must be of type Object! (current type: "+typeof b+")");for(e in b)f=b[e],this.val(e,f,d)}}return e(c,b),c.prototype.mutable_default=!0,c.prototype.setMutableDefault=function(a){if(a===!0||"mutable"===a)c.prototype.mutable_default=!0;else{if(a!==!1&&"immutable"!==a)throw new Error('Set mutable either "mutable" or "immutable"!');c.prototype.mutable_default=!1}return"OK"},c.prototype.val=function(b,d,e){var f,g,i,j,k;if("object"==typeof b){for(i in b)g=b[i],this.val(i,g,d);return this}if(null!=b&&null!=d){if(e=null!=e?e===!0||"mutable"===e?!0:!1:this.mutable_default,"function"==typeof d)return this;if(e&&"number"!=typeof d||d.constructor===Object){if("string"==typeof d)return k=a.addOperation(new h.Word(a.getNextOperationIdentifier(),d)).execute(),c.__super__.val.call(this,b,k);if(d.constructor===Object)return f=a.addOperation(new c(a.getNextOperationIdentifier(),d,e)).execute(),c.__super__.val.call(this,b,f);throw new Error("You must not set "+typeof d+"-types in collaborative Json-objects!")}return j=a.addOperation(new h.ImmutableObject(void 0,d)).execute(),c.__super__.val.call(this,b,j)}return c.__super__.val.call(this,b,d)},Object.defineProperty(c.prototype,"value",{get:function(){return d(this)},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),c.prototype._encode=function(){return{type:"JsonType",uid:this.getUid()}},c}(h.MapManager),f.JsonType=function(a){var c;return c=a.uid,new b(c)},h.JsonType=b,g}},{"./TextTypes.coffee":8}],7:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./BasicTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i,j,k;return i=c(a),k=i.types,j=i.parser,f=function(c){function d(a){this.map={},d.__super__.constructor.call(this,a)}return e(d,c),d.prototype.val=function(c,e){var f,g,h,i,j;if(null!=e)return null==this.map[c]&&a.addOperation(new b(a.getNextOperationIdentifier(),this,c)).execute(),this.map[c].replace(e),this;if(null!=c)return g=null!=(i=this.map[c])?i.val():void 0,g instanceof k.ImmutableObject?g.val():g;h={},j=this.map;for(c in j)f=j[c],g=f.val(),(g instanceof k.ImmutableObject||g instanceof d)&&(g=g.val()),h[c]=g;return h},d}(k.Operation),b=function(b){function c(a,b,d){this.name=d,this.saveOperation("map_manager",b),c.__super__.constructor.call(this,a)}return e(c,b),c.prototype.execute=function(){var b,d,e,f,h;return this.validateSavedOperations()?(h=this.map_manager.getUid(),h.op_number="_"+h.op_number+"_RM_"+this.name,null==a.getOperation(h)&&(e=this.map_manager.getUid(),e.op_number="_"+e.op_number+"_RM_"+this.name+"_beginning",f=this.map_manager.getUid(),f.op_number="_"+f.op_number+"_RM_"+this.name+"_end",b=a.addOperation(new k.Delimiter(e,void 0,f)),d=a.addOperation(new k.Delimiter(f,b,void 0)).execute(),b.execute(),this.map_manager.map[this.name]=a.addOperation(new g(void 0,h,b,d)).execute()),c.__super__.execute.apply(this,arguments)):!1},c.prototype._encode=function(){return{type:"AddName",uid:this.getUid(),map_manager:this.map_manager.getUid(),name:this.name}},c}(k.Operation),j.AddName=function(a){var c,d,e;return c=a.map_manager,e=a.uid,d=a.name,new b(e,c,d)},d=function(b){function c(b,d,e,f,g,h){null!=d&&null!=e?(this.saveOperation("beginning",d),this.saveOperation("end",e)):(this.beginning=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),void 0,void 0)),this.end=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),this.beginning,void 0)),this.beginning.next_cl=this.end,this.beginning.execute(),this.end.execute()),c.__super__.constructor.call(this,b,f,g,h)}return e(c,b),c.prototype.getLastOperation=function(){return this.end.prev_cl},c.prototype.getFirstOperation=function(){return this.beginning.next_cl},c.prototype.toArray=function(){var a,b;for(a=this.beginning.next_cl,b=[];a!==this.end;)b.push(a),a=a.next_cl;return b},c.prototype.getOperationByPosition=function(a){var b;if(b=this.beginning.next_cl,a>0)for(;b=b.next_cl,b.isDeleted()||(a-=1),0!==a;)if(b instanceof k.Delimiter)throw new Error("position parameter exceeded the length of the document!");return b},c}(k.Insert),g=function(b){function c(a,b,d,e,f,g,h){c.__super__.constructor.call(this,b,d,e,f,g,h),null!=a&&this.replace(a)}return e(c,b),c.prototype.replace=function(b){var c,d;return c=this.getLastOperation(),d=new h(b,this,a.getNextOperationIdentifier(),c,c.next_cl),a.addOperation(d).execute()},c.prototype.val=function(){var a;if(a=this.getLastOperation(),a instanceof k.Delimiter)throw new Error("dtrn");return a.val()},c.prototype._encode=function(){var a;return a={type:"ReplaceManager",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&null!=this.next_cl&&(a.prev=this.prev_cl.getUid(),a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},c}(d),j.ReplaceManager=function(a){var b,c,d,e,f,h,i;return c=a.content,i=a.uid,h=a.prev,e=a.next,f=a.origin,b=a.beginning,d=a.end,new g(c,i,b,d,h,e,f)},h=function(a){function b(a,c,d,e,f,g){if(this.saveOperation("content",a),this.saveOperation("parent",c),null==e||null==f||null==a)throw new Error("You must define content, prev, and next for Replaceable-types!");b.__super__.constructor.call(this,d,e,f,g)}return e(b,a),b.prototype.val=function(){return this.content},b.prototype.replace=function(a){return this.parent.replace(a)},b.prototype.execute=function(){var a;return this.validateSavedOperations()?("function"==typeof(a=this.content).setReplaceManager&&a.setReplaceManager(this.parent),b.__super__.execute.apply(this,arguments),this):!1},b.prototype._encode=function(){var a;return a={type:"Replaceable",content:this.content.getUid(),ReplaceManager:this.parent.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid(),uid:this.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(k.Insert),j.Replaceable=function(a){var b,c,d,e,f,g;return b=a.content,e=a.ReplaceManager,g=a.uid,f=a.prev,c=a.next,d=a.origin,new h(b,e,g,f,c,d)},k.ListManager=d,k.MapManager=f,k.ReplaceManager=g,k.Replaceable=h,i}},{"./BasicTypes.coffee":5}],8:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./StructuredTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i;return h=c(a),i=h.types,g=h.parser,b=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return e(b,a),b}(i.Delete),g.TextDelete=g.Delete,d=function(a){function b(a,c,d,e,f){if(this.content=a,null==d||null==e)throw new Error("You must define prev, and next for TextInsert-types!");b.__super__.constructor.call(this,c,d,e,f)}return e(b,a),b.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},b.prototype.val=function(){return this.isDeleted()?"":this.content},b.prototype._encode=function(){var a;return a={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(i.Insert),g.TextInsert=function(a){var b,c,e,f,g;return b=a.content,g=a.uid,f=a.prev,c=a.next,e=a.origin,new d(b,g,f,c,e)},f=function(c){function f(a,b,c,d,e,g,h){f.__super__.constructor.call(this,a,c,d,e,g,h),null!=b&&this.insertText(0,b)}return e(f,c),f.prototype.insertText=function(b,c){var e,f,g,h,i,j;for(f=this.getOperationByPosition(b),j=[],h=0,i=c.length;i>h;h++)e=c[h],g=new d(e,a.getNextOperationIdentifier(),f.prev_cl,f),j.push(a.addOperation(g).execute());return j},f.prototype.deleteText=function(c,d){var e,f,g,h,j;for(g=this.getOperationByPosition(c),j=[],f=h=0;d>=0?d>h:h>d;f=d>=0?++h:--h){for(e=a.addOperation(new b(a.getNextOperationIdentifier(),g)).execute(),g=g.next_cl;g.isDeleted();){if(g instanceof i.Delimiter)throw new Error("You can't delete more than there is..");g=g.next_cl}j.push(e._encode())}return j},f.prototype.replaceText=function(b){var c;if(null!=this.replace_manager)return c=a.addOperation(new f(a.getNextOperationIdentifier())).execute(),c.insertText(0,b),this.replace_manager.replace(c);throw new Error("This type is currently not maintained by a ReplaceManager!")},f.prototype.val=function(){var a,b;return a=function(){var a,c,d,e;for(d=this.toArray(),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(null!=b.val?b.val():"");return e}.call(this),a.join("")},f.prototype.setReplaceManager=function(a){return this.saveOperation("replace_manager",a),this.validateSavedOperations},f.prototype._encode=function(){var a;return a={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},f}(i.ListManager),g.Word=function(a){var b,c,d,e,g,h;return h=a.uid,b=a.beginning,c=a.end,g=a.prev,d=a.next,e=a.origin,new f(h,void 0,b,c,g,d,e)
},i.TextInsert=d,i.TextDelete=b,i.Word=f,h}},{"./StructuredTypes.coffee":7}]},{},[3,1]),!function l(a,b,c){function d(f,g){if(!b[f]){if(!a[f]){var h="function"==typeof require&&require;if(!g&&h)return h(f,!0);if(e)return e(f,!0);throw new Error("Cannot find module '"+f+"'")}var i=b[f]={exports:{}};a[f][0].call(i.exports,function(b){var c=a[f][1][b];return d(c?c:b)},i,i.exports,l,a,b,c)}return b[f].exports}for(var e="function"==typeof require&&require,f=0;f<c.length;f++)d(c[f]);return d}({1:[function(a,b){var c;c=function(a){var b,c,d,e,f,g,h;return f={},c=new DUIClient,c.connect(function(a){var b;return null!=(b=f[a.action])?b.map(function(b){return setTimeout(function(){return b(a)},0)}):void 0}),c.initOK(),h=null,g=null,b=function(){function a(a,b,d,e){var i,j,k;this.engine=a,this.HB=b,this.execution_listener=d,this.yatta=e,this.duiClient=c,this.iwcHandler=f,k=function(a){return function(b){return a.send(b)}}(this),this.execution_listener.push(k),i=function(a){return function(b){var c;return c=b.extras,a.receive(c)}}(this),this.iwcHandler.Yatta_new_operation=[i],null!=h&&this.engine.applyOps(g),j=function(a){return function(){var b;return b={root_element:a.yatta.getRootElement(),HB:a.yatta.getHistoryBuffer()._encode()},a.sendIwcIntent("Yatta_push_root_element",b)}}(this),this.iwcHandler.Yatta_get_root_element=[j]}return a.prototype.getRootElement=function(){return h},a.prototype.send=function(a){return a.uid.creator===this.HB.getUserId()&&"string"!=typeof a.uid.op_number?this.sendIwcIntent("Yatta_new_operation",a):void 0},a.prototype.receive=function(a){return a.uid.creator!==this.HB.getUserId()?this.engine.applyOp(a):void 0},a.prototype.sendIwcIntent=function(a,b){var c;return c={action:a,component:"",data:"",dataType:"",extras:b},this.duiClient.sendIntent(c)},a.prototype.sync=function(){throw new Error("Can't use this a.t.m.")},a}(),d={action:"Yatta_get_root_element",component:"",data:"",dataType:"",extras:{}},e=function(){var e,i;return c.sendIntent(d),e=!1,i=function(d){var f;return f=c.getIwcClient()._componentName,h=null!=d?d.extras.root_element:void 0,g=null!=d?d.extras.HB:void 0,e?void 0:(e=!0,a(b,f))},f.Yatta_push_root_element=[i],setTimeout(i,800)},void setTimeout(e,4e3*Math.random())},b.exports=c,"undefined"!=typeof window&&null!==window&&(window.createConnector=c)},{}],2:[function(a,b){var c;c=function(){function a(a,b){this.HB=a,this.parser=b,this.unprocessed_ops=[]}return a.prototype.parseOperation=function(a){var b;if(b=this.parser[a.type],null!=b)return b(a);throw new Error("You forgot to specify a parser for type "+a.type+". The message is "+JSON.stringify(a)+".")},a.prototype.applyOps=function(a){var b,c,d,e,f,g,h,i;for(c=[],d=0,g=a.length;g>d;d++)b=a[d],c.push(this.parseOperation(b));for(e=0,h=c.length;h>e;e++)b=c[e],this.HB.addOperation(b);for(f=0,i=c.length;i>f;f++)b=c[f],b.execute()||this.unprocessed_ops.push(b);return this.tryUnprocessed()},a.prototype.applyOp=function(a){var b;return b=this.parseOperation(a),this.HB.addOperation(b),b.execute()||this.unprocessed_ops.push(b),this.tryUnprocessed()},a.prototype.tryUnprocessed=function(){var a,b,c,d,e,f,g;for(g=[];;){for(a=this.unprocessed_ops.length,c=[],f=this.unprocessed_ops,d=0,e=f.length;e>d;d++)b=f[d],b.execute()||c.push(b);if(this.unprocessed_ops=c,this.unprocessed_ops.length===a)break;g.push(void 0)}return g},a}(),b.exports=c},{}],3:[function(a,b){var c,d,e,f;f=a("../Types/JsonTypes.coffee"),d=a("../HistoryBuffer.coffee"),c=a("../Engine.coffee"),e=function(){function a(a,b){var e,g,h;this.HB=new d(a),g=f(this.HB),this.engine=new c(this.HB,g.parser),this.connector=new b(this.engine,this.HB,g.execution_listener,this),h=this.connector.getRootElement(),null==h?(e=new g.types.JsonType(this.HB.getNextOperationIdentifier()),this.HB.addOperation(e),e.execute(),this.root_element=e):this.root_element=this.HB.getOperation(h)}return a.prototype.getRootElement=function(){return this.root_element},a.prototype.getEngine=function(){return this.engine},a.prototype.getConnector=function(){return this.connector},a.prototype.getHistoryBuffer=function(){return this.HB},a.prototype.setMutableDefault=function(a){return this.root_element.setMutableDefault(a)},a.prototype.getUserId=function(){return this.HB.getUserId()},a.prototype.val=function(a,b,c){return this.root_element.val(a,b,c)},Object.defineProperty(a.prototype,"value",{get:function(){return this.root_element.value},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),a}(),"undefined"!=typeof window&&null!==window&&(window.JsonYatta=e),b.exports=e},{"../Engine.coffee":2,"../HistoryBuffer.coffee":4,"../Types/JsonTypes.coffee":6}],4:[function(a,b){var c;c=function(){function a(a){this.user_id=a,this.operation_counter={},this.buffer={},this.change_listeners=[]}return a.prototype.getUserId=function(){return this.user_id},a.prototype.getOperationCounter=function(){var a,b,c,d;b={},d=this.operation_counter;for(c in d)a=d[c],b[c]=a;return b},a.prototype._encode=function(){var a,b,c,d,e,f;a=[],f=this.buffer;for(d in f){e=f[d];for(c in e)b=e[c],isNaN(parseInt(c))||a.push(b._encode())}return a},a.prototype.getNextOperationIdentifier=function(a){var b;return null==a&&(a=this.user_id),null==this.operation_counter[a]&&(this.operation_counter[a]=0),b={creator:a,op_number:this.operation_counter[a]},this.operation_counter[a]++,b},a.prototype.getOperation=function(a){var b;if(a instanceof Object)return null!=(b=this.buffer[a.creator])?b[a.op_number]:void 0;if(null!=a)throw new Error("This type of uid is not defined!")},a.prototype.addOperation=function(a){if(null==this.buffer[a.creator]&&(this.buffer[a.creator]={}),null==this.operation_counter[a.creator]&&(this.operation_counter[a.creator]=0),null!=this.buffer[a.creator][a.op_number])throw new Error("You must not overwrite operations!");return this.buffer[a.creator][a.op_number]=a,"number"==typeof a.op_number&&a.creator!==this.getUserId()&&this.operation_counter[a.creator]++,a},a}(),b.exports=c},{}],5:[function(a,b){var c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};b.exports=function(a){var b,c,e,f,g,h,i;return i={},h=[],g=function(){function b(b){null==b&&(b=a.getNextOperationIdentifier()),this.creator=b.creator,this.op_number=b.op_number}return b.prototype.getUid=function(){return{creator:this.creator,op_number:this.op_number}},b.prototype.execute=function(){var a,b,c;for(this.is_executed=!0,b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this},b.prototype.saveOperation=function(a,b){return null!=(null!=b?b.execute:void 0)?this[a]=b:null!=b?(null==this.unchecked&&(this.unchecked={}),this.unchecked[a]=b):void 0},b.prototype.validateSavedOperations=function(){var b,c,d,e,f,g;f={},e=this,g=this.unchecked;for(b in g)d=g[b],c=a.getOperation(d),c?this[b]=c:(f[b]=d,e=!1);return delete this.unchecked,e||(this.unchecked=f),e},b}(),b=function(a){function b(a,c){this.saveOperation("deletes",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype._encode=function(){return{type:"Delete",uid:this.getUid(),deletes:this.deletes.getUid()}},b.prototype.execute=function(){return this.validateSavedOperations()?(this.deletes.applyDelete(this),b.__super__.execute.apply(this,arguments),this):!1},b}(g),i.Delete=function(a){var c,d;return d=a.uid,c=a.deletes,new b(d,c)},f=function(a){function b(a,c,d,e){this.saveOperation("prev_cl",c),this.saveOperation("next_cl",d),null!=e?this.saveOperation("origin",e):this.saveOperation("origin",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype.applyDelete=function(a){return null==this.deleted_by&&(this.deleted_by=[]),this.deleted_by.push(a)},b.prototype.isDeleted=function(){var a;return(null!=(a=this.deleted_by)?a.length:void 0)>0},b.prototype.getDistanceToOrigin=function(){var a,b;for(a=0,b=this.prev_cl;this.origin!==b;){if(a++,this===this.prev_cl)throw new Error("this should not happen ;) ");b=b.prev_cl}return a},b.prototype.update_sl=function(){var a;return a=this.prev_cl,update("prev_cl","prev_sl"),update("next_cl","prev_sl")},b.prototype.execute=function(){var a,c,d,e,f;if(null!=this.is_executed)return this;if(this.validateSavedOperations()){if((null!=(e=this.prev_cl)?e.validateSavedOperations():void 0)&&(null!=(f=this.next_cl)?f.validateSavedOperations():void 0)&&this.prev_cl.next_cl!==this){for(a=0,d=this.prev_cl.next_cl,c=0;null==d&&(console.log(JSON.stringify(this.prev_cl.getUid())),console.log(JSON.stringify(this.next_cl.getUid()))),d!==this.next_cl;){if(d.getDistanceToOrigin()===c)d.creator<this.creator&&(this.prev_cl=d,a=c+1);else{if(!(d.getDistanceToOrigin()<c))break;c-a<=d.getDistanceToOrigin()&&(this.prev_cl=d,a=c+1)}c++,d=d.next_cl}this.next_cl=this.prev_cl.next_cl,this.prev_cl.next_cl=this,this.next_cl.prev_cl=this}return b.__super__.execute.apply(this,arguments),this}return!1},b}(g),e=function(a){function b(a,c,d,e,f){this.content=null!=c?c:"",b.__super__.constructor.call(this,a,d,e,f)}return d(b,a),b.prototype.val=function(){return this.content},b.prototype._encode=function(){var a;return a={type:"ImmutableObject",uid:this.getUid(),content:this.content},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(f),i.ImmutableObject=function(a){var b,c,d,f,g;return g=a.uid,b=a.content,f=a.prev,c=a.next,d=a.origin,new e(g,b,f,c,d)},c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return d(b,a),b.prototype.execute=function(){var a,b,c;if(this.validateSavedOperations()){for(b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this}return!1},b.prototype._encode=function(){var a,b;return{type:"Delimiter",uid:this.getUid(),prev:null!=(a=this.prev_cl)?a.getUid():void 0,next:null!=(b=this.next_cl)?b.getUid():void 0}},b}(f),i.Delimiter=function(a){var b,d,e;return e=a.uid,d=a.prev,b=a.next,new c(e,d,b)},{types:{Delete:b,Insert:f,Delimiter:c,Operation:g,ImmutableObject:e},parser:i,execution_listener:h}}},{}],6:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./TextTypes.coffee"),b.exports=function(a){var b,d,f,g,h;return g=c(a),h=g.types,f=g.parser,d=function(a){var c;return new(c=function(){function a(c){var e,f,g,i;i=c.map,g=function(e,f){return Object.defineProperty(a.prototype,e,{get:function(){var a;return a=f.val(),a instanceof b?d(a):a instanceof h.ImmutableObject?a.val():a},set:function(a){var b,d,f,g;if(a.constructor==={}.constructor){f=c.val(e),g=[];for(b in a)d=a[b],g.push(f.val(b,d,"immutable"));return g}return c.val(e,a,"immutable")},enumerable:!0,configurable:!1})};for(e in i)f=i[e],g(e,f)}return a}())(a)},b=function(b){function c(a,b,d){var e,f;if(c.__super__.constructor.call(this,a),null!=b){if("object"!=typeof b)throw new Error("The initial value of JsonTypes must be of type Object! (current type: "+typeof b+")");for(e in b)f=b[e],this.val(e,f,d)}}return e(c,b),c.prototype.mutable_default=!0,c.prototype.setMutableDefault=function(a){if(a===!0||"mutable"===a)c.prototype.mutable_default=!0;else{if(a!==!1&&"immutable"!==a)throw new Error('Set mutable either "mutable" or "immutable"!');c.prototype.mutable_default=!1}return"OK"},c.prototype.val=function(b,d,e){var f,g,i,j,k;if("object"==typeof b){for(i in b)g=b[i],this.val(i,g,d);return this}if(null!=b&&null!=d){if(e=null!=e?e===!0||"mutable"===e?!0:!1:this.mutable_default,"function"==typeof d)return this;if(e&&"number"!=typeof d||d.constructor===Object){if("string"==typeof d)return k=a.addOperation(new h.Word(a.getNextOperationIdentifier(),d)).execute(),c.__super__.val.call(this,b,k);if(d.constructor===Object)return f=a.addOperation(new c(a.getNextOperationIdentifier(),d,e)).execute(),c.__super__.val.call(this,b,f);throw new Error("You must not set "+typeof d+"-types in collaborative Json-objects!")}return j=a.addOperation(new h.ImmutableObject(void 0,d)).execute(),c.__super__.val.call(this,b,j)}return c.__super__.val.call(this,b,d)},Object.defineProperty(c.prototype,"value",{get:function(){return d(this)},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),c.prototype._encode=function(){return{type:"JsonType",uid:this.getUid()}},c}(h.MapManager),f.JsonType=function(a){var c;return c=a.uid,new b(c)},h.JsonType=b,g}},{"./TextTypes.coffee":8}],7:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./BasicTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i,j,k;return i=c(a),k=i.types,j=i.parser,f=function(c){function d(a){this.map={},d.__super__.constructor.call(this,a)}return e(d,c),d.prototype.val=function(c,e){var f,g,h,i,j;if(null!=e)return null==this.map[c]&&a.addOperation(new b(a.getNextOperationIdentifier(),this,c)).execute(),this.map[c].replace(e),this;if(null!=c)return g=null!=(i=this.map[c])?i.val():void 0,g instanceof k.ImmutableObject?g.val():g;h={},j=this.map;for(c in j)f=j[c],g=f.val(),(g instanceof k.ImmutableObject||g instanceof d)&&(g=g.val()),h[c]=g;return h},d}(k.Operation),b=function(b){function c(a,b,d){this.name=d,this.saveOperation("map_manager",b),c.__super__.constructor.call(this,a)}return e(c,b),c.prototype.execute=function(){var b,d,e,f,h;return this.validateSavedOperations()?(h=this.map_manager.getUid(),h.op_number="_"+h.op_number+"_RM_"+this.name,null==a.getOperation(h)&&(e=this.map_manager.getUid(),e.op_number="_"+e.op_number+"_RM_"+this.name+"_beginning",f=this.map_manager.getUid(),f.op_number="_"+f.op_number+"_RM_"+this.name+"_end",b=a.addOperation(new k.Delimiter(e,void 0,f)),d=a.addOperation(new k.Delimiter(f,b,void 0)).execute(),b.execute(),this.map_manager.map[this.name]=a.addOperation(new g(void 0,h,b,d)).execute()),c.__super__.execute.apply(this,arguments)):!1},c.prototype._encode=function(){return{type:"AddName",uid:this.getUid(),map_manager:this.map_manager.getUid(),name:this.name}},c}(k.Operation),j.AddName=function(a){var c,d,e;return c=a.map_manager,e=a.uid,d=a.name,new b(e,c,d)},d=function(b){function c(b,d,e,f,g,h){null!=d&&null!=e?(this.saveOperation("beginning",d),this.saveOperation("end",e)):(this.beginning=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),void 0,void 0)),this.end=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),this.beginning,void 0)),this.beginning.next_cl=this.end,this.beginning.execute(),this.end.execute()),c.__super__.constructor.call(this,b,f,g,h)}return e(c,b),c.prototype.getLastOperation=function(){return this.end.prev_cl},c.prototype.getFirstOperation=function(){return this.beginning.next_cl},c.prototype.toArray=function(){var a,b;for(a=this.beginning.next_cl,b=[];a!==this.end;)b.push(a),a=a.next_cl;return b},c.prototype.getOperationByPosition=function(a){var b;if(b=this.beginning.next_cl,a>0)for(;b=b.next_cl,b.isDeleted()||(a-=1),0!==a;)if(b instanceof k.Delimiter)throw new Error("position parameter exceeded the length of the document!");return b},c}(k.Insert),g=function(b){function c(a,b,d,e,f,g,h){c.__super__.constructor.call(this,b,d,e,f,g,h),null!=a&&this.replace(a)}return e(c,b),c.prototype.replace=function(b){var c,d;return c=this.getLastOperation(),d=new h(b,this,a.getNextOperationIdentifier(),c,c.next_cl),a.addOperation(d).execute()},c.prototype.val=function(){var a;if(a=this.getLastOperation(),a instanceof k.Delimiter)throw new Error("dtrn");return a.val()},c.prototype._encode=function(){var a;return a={type:"ReplaceManager",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&null!=this.next_cl&&(a.prev=this.prev_cl.getUid(),a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},c}(d),j.ReplaceManager=function(a){var b,c,d,e,f,h,i;return c=a.content,i=a.uid,h=a.prev,e=a.next,f=a.origin,b=a.beginning,d=a.end,new g(c,i,b,d,h,e,f)},h=function(a){function b(a,c,d,e,f,g){if(this.saveOperation("content",a),this.saveOperation("parent",c),null==e||null==f||null==a)throw new Error("You must define content, prev, and next for Replaceable-types!");b.__super__.constructor.call(this,d,e,f,g)}return e(b,a),b.prototype.val=function(){return this.content},b.prototype.replace=function(a){return this.parent.replace(a)},b.prototype.execute=function(){var a;return this.validateSavedOperations()?("function"==typeof(a=this.content).setReplaceManager&&a.setReplaceManager(this.parent),b.__super__.execute.apply(this,arguments),this):!1},b.prototype._encode=function(){var a;return a={type:"Replaceable",content:this.content.getUid(),ReplaceManager:this.parent.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid(),uid:this.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(k.Insert),j.Replaceable=function(a){var b,c,d,e,f,g;return b=a.content,e=a.ReplaceManager,g=a.uid,f=a.prev,c=a.next,d=a.origin,new h(b,e,g,f,c,d)},k.ListManager=d,k.MapManager=f,k.ReplaceManager=g,k.Replaceable=h,i}},{"./BasicTypes.coffee":5}],8:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./StructuredTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i;return h=c(a),i=h.types,g=h.parser,b=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return e(b,a),b}(i.Delete),g.TextDelete=g.Delete,d=function(a){function b(a,c,d,e,f){if(this.content=a,null==d||null==e)throw new Error("You must define prev, and next for TextInsert-types!");b.__super__.constructor.call(this,c,d,e,f)}return e(b,a),b.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},b.prototype.val=function(){return this.isDeleted()?"":this.content},b.prototype._encode=function(){var a;return a={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(i.Insert),g.TextInsert=function(a){var b,c,e,f,g;return b=a.content,g=a.uid,f=a.prev,c=a.next,e=a.origin,new d(b,g,f,c,e)},f=function(c){function f(a,b,c,d,e,g,h){f.__super__.constructor.call(this,a,c,d,e,g,h),null!=b&&this.insertText(0,b)}return e(f,c),f.prototype.insertText=function(b,c){var e,f,g,h,i,j;for(f=this.getOperationByPosition(b),j=[],h=0,i=c.length;i>h;h++)e=c[h],g=new d(e,a.getNextOperationIdentifier(),f.prev_cl,f),j.push(a.addOperation(g).execute());return j},f.prototype.deleteText=function(c,d){var e,f,g,h,j;for(g=this.getOperationByPosition(c),j=[],f=h=0;d>=0?d>h:h>d;f=d>=0?++h:--h){for(e=a.addOperation(new b(a.getNextOperationIdentifier(),g)).execute(),g=g.next_cl;g.isDeleted();){if(g instanceof i.Delimiter)throw new Error("You can't delete more than there is..");g=g.next_cl}j.push(e._encode())}return j},f.prototype.replaceText=function(b){var c;if(null!=this.replace_manager)return c=a.addOperation(new f(a.getNextOperationIdentifier())).execute(),c.insertText(0,b),this.replace_manager.replace(c);throw new Error("This type is currently not maintained by a ReplaceManager!")},f.prototype.val=function(){var a,b;return a=function(){var a,c,d,e;for(d=this.toArray(),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(null!=b.val?b.val():"");return e}.call(this),a.join("")},f.prototype.setReplaceManager=function(a){return this.saveOperation("replace_manager",a),this.validateSavedOperations},f.prototype._encode=function(){var a;return a={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},f}(i.ListManager),g.Word=function(a){var b,c,d,e,g,h;return h=a.uid,b=a.beginning,c=a.end,g=a.prev,d=a.next,e=a.origin,new f(h,void 0,b,c,g,d,e)},i.TextInsert=d,i.TextDelete=b,i.Word=f,h}},{"./StructuredTypes.coffee":7}]},{},[3,1]),!function m(a,b,c){function d(f,g){if(!b[f]){if(!a[f]){var h="function"==typeof require&&require;if(!g&&h)return h(f,!0);if(e)return e(f,!0);throw new Error("Cannot find module '"+f+"'")}var i=b[f]={exports:{}};a[f][0].call(i.exports,function(b){var c=a[f][1][b];return d(c?c:b)},i,i.exports,m,a,b,c)}return b[f].exports}for(var e="function"==typeof require&&require,f=0;f<c.length;f++)d(c[f]);return d}({1:[function(a,b){var c;c=function(a){var b,c,d,e,f,g,h;return f={},c=new DUIClient,c.connect(function(a){var b;return null!=(b=f[a.action])?b.map(function(b){return setTimeout(function(){return b(a)},0)}):void 0}),c.initOK(),h=null,g=null,b=function(){function a(a,b,d,e){var i,j,k;this.engine=a,this.HB=b,this.execution_listener=d,this.yatta=e,this.duiClient=c,this.iwcHandler=f,k=function(a){return function(b){return a.send(b)}}(this),this.execution_listener.push(k),i=function(a){return function(b){var c;return c=b.extras,a.receive(c)}}(this),this.iwcHandler.Yatta_new_operation=[i],null!=h&&this.engine.applyOps(g),j=function(a){return function(){var b;return b={root_element:a.yatta.getRootElement(),HB:a.yatta.getHistoryBuffer()._encode()},a.sendIwcIntent("Yatta_push_root_element",b)}}(this),this.iwcHandler.Yatta_get_root_element=[j]}return a.prototype.getRootElement=function(){return h},a.prototype.send=function(a){return a.uid.creator===this.HB.getUserId()&&"string"!=typeof a.uid.op_number?this.sendIwcIntent("Yatta_new_operation",a):void 0},a.prototype.receive=function(a){return a.uid.creator!==this.HB.getUserId()?this.engine.applyOp(a):void 0},a.prototype.sendIwcIntent=function(a,b){var c;return c={action:a,component:"",data:"",dataType:"",extras:b},this.duiClient.sendIntent(c)},a.prototype.sync=function(){throw new Error("Can't use this a.t.m.")},a}(),d={action:"Yatta_get_root_element",component:"",data:"",dataType:"",extras:{}},e=function(){var e,i;return c.sendIntent(d),e=!1,i=function(d){var f;return f=c.getIwcClient()._componentName,h=null!=d?d.extras.root_element:void 0,g=null!=d?d.extras.HB:void 0,e?void 0:(e=!0,a(b,f))},f.Yatta_push_root_element=[i],setTimeout(i,800)},void setTimeout(e,4e3*Math.random())},b.exports=c,"undefined"!=typeof window&&null!==window&&(window.createConnector=c)},{}],2:[function(a,b){var c;c=function(){function a(a,b){this.HB=a,this.parser=b,this.unprocessed_ops=[]}return a.prototype.parseOperation=function(a){var b;if(b=this.parser[a.type],null!=b)return b(a);throw new Error("You forgot to specify a parser for type "+a.type+". The message is "+JSON.stringify(a)+".")},a.prototype.applyOps=function(a){var b,c,d,e,f,g,h,i;for(c=[],d=0,g=a.length;g>d;d++)b=a[d],c.push(this.parseOperation(b));for(e=0,h=c.length;h>e;e++)b=c[e],this.HB.addOperation(b);for(f=0,i=c.length;i>f;f++)b=c[f],b.execute()||this.unprocessed_ops.push(b);return this.tryUnprocessed()},a.prototype.applyOp=function(a){var b;return b=this.parseOperation(a),this.HB.addOperation(b),b.execute()||this.unprocessed_ops.push(b),this.tryUnprocessed()},a.prototype.tryUnprocessed=function(){var a,b,c,d,e,f,g;for(g=[];;){for(a=this.unprocessed_ops.length,c=[],f=this.unprocessed_ops,d=0,e=f.length;e>d;d++)b=f[d],b.execute()||c.push(b);if(this.unprocessed_ops=c,this.unprocessed_ops.length===a)break;g.push(void 0)}return g},a}(),b.exports=c},{}],3:[function(a,b){var c,d,e,f;f=a("../Types/JsonTypes.coffee"),d=a("../HistoryBuffer.coffee"),c=a("../Engine.coffee"),e=function(){function a(a,b){var e,g,h;this.HB=new d(a),g=f(this.HB),this.engine=new c(this.HB,g.parser),this.connector=new b(this.engine,this.HB,g.execution_listener,this),h=this.connector.getRootElement(),null==h?(e=new g.types.JsonType(this.HB.getNextOperationIdentifier()),this.HB.addOperation(e),e.execute(),this.root_element=e):this.root_element=this.HB.getOperation(h)}return a.prototype.getRootElement=function(){return this.root_element},a.prototype.getEngine=function(){return this.engine},a.prototype.getConnector=function(){return this.connector},a.prototype.getHistoryBuffer=function(){return this.HB},a.prototype.setMutableDefault=function(a){return this.root_element.setMutableDefault(a)},a.prototype.getUserId=function(){return this.HB.getUserId()},a.prototype.val=function(a,b,c){return this.root_element.val(a,b,c)},Object.defineProperty(a.prototype,"value",{get:function(){return this.root_element.value},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),a}(),"undefined"!=typeof window&&null!==window&&(window.JsonYatta=e),b.exports=e},{"../Engine.coffee":2,"../HistoryBuffer.coffee":4,"../Types/JsonTypes.coffee":6}],4:[function(a,b){var c;c=function(){function a(a){this.user_id=a,this.operation_counter={},this.buffer={},this.change_listeners=[]}return a.prototype.getUserId=function(){return this.user_id},a.prototype.getOperationCounter=function(){var a,b,c,d;b={},d=this.operation_counter;for(c in d)a=d[c],b[c]=a;return b},a.prototype._encode=function(){var a,b,c,d,e,f;a=[],f=this.buffer;for(d in f){e=f[d];for(c in e)b=e[c],isNaN(parseInt(c))||a.push(b._encode())}return a},a.prototype.getNextOperationIdentifier=function(a){var b;return null==a&&(a=this.user_id),null==this.operation_counter[a]&&(this.operation_counter[a]=0),b={creator:a,op_number:this.operation_counter[a]},this.operation_counter[a]++,b},a.prototype.getOperation=function(a){var b;if(a instanceof Object)return null!=(b=this.buffer[a.creator])?b[a.op_number]:void 0;if(null!=a)throw new Error("This type of uid is not defined!")},a.prototype.addOperation=function(a){if(null==this.buffer[a.creator]&&(this.buffer[a.creator]={}),null==this.operation_counter[a.creator]&&(this.operation_counter[a.creator]=0),null!=this.buffer[a.creator][a.op_number])throw new Error("You must not overwrite operations!");return this.buffer[a.creator][a.op_number]=a,"number"==typeof a.op_number&&a.creator!==this.getUserId()&&this.operation_counter[a.creator]++,a},a}(),b.exports=c},{}],5:[function(a,b){var c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};b.exports=function(a){var b,c,e,f,g,h,i;return i={},h=[],g=function(){function b(b){null==b&&(b=a.getNextOperationIdentifier()),this.creator=b.creator,this.op_number=b.op_number}return b.prototype.getUid=function(){return{creator:this.creator,op_number:this.op_number}},b.prototype.execute=function(){var a,b,c;for(this.is_executed=!0,b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this},b.prototype.saveOperation=function(a,b){return null!=(null!=b?b.execute:void 0)?this[a]=b:null!=b?(null==this.unchecked&&(this.unchecked={}),this.unchecked[a]=b):void 0},b.prototype.validateSavedOperations=function(){var b,c,d,e,f,g;f={},e=this,g=this.unchecked;for(b in g)d=g[b],c=a.getOperation(d),c?this[b]=c:(f[b]=d,e=!1);return delete this.unchecked,e||(this.unchecked=f),e},b}(),b=function(a){function b(a,c){this.saveOperation("deletes",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype._encode=function(){return{type:"Delete",uid:this.getUid(),deletes:this.deletes.getUid()}},b.prototype.execute=function(){return this.validateSavedOperations()?(this.deletes.applyDelete(this),b.__super__.execute.apply(this,arguments),this):!1},b}(g),i.Delete=function(a){var c,d;return d=a.uid,c=a.deletes,new b(d,c)},f=function(a){function b(a,c,d,e){this.saveOperation("prev_cl",c),this.saveOperation("next_cl",d),null!=e?this.saveOperation("origin",e):this.saveOperation("origin",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype.applyDelete=function(a){return null==this.deleted_by&&(this.deleted_by=[]),this.deleted_by.push(a)},b.prototype.isDeleted=function(){var a;return(null!=(a=this.deleted_by)?a.length:void 0)>0},b.prototype.getDistanceToOrigin=function(){var a,b;for(a=0,b=this.prev_cl;this.origin!==b;){if(a++,this===this.prev_cl)throw new Error("this should not happen ;) ");b=b.prev_cl}return a},b.prototype.update_sl=function(){var a;return a=this.prev_cl,update("prev_cl","prev_sl"),update("next_cl","prev_sl")},b.prototype.execute=function(){var a,c,d,e,f;if(null!=this.is_executed)return this;if(this.validateSavedOperations()){if((null!=(e=this.prev_cl)?e.validateSavedOperations():void 0)&&(null!=(f=this.next_cl)?f.validateSavedOperations():void 0)&&this.prev_cl.next_cl!==this){for(a=0,d=this.prev_cl.next_cl,c=0;null==d&&(console.log(JSON.stringify(this.prev_cl.getUid())),console.log(JSON.stringify(this.next_cl.getUid()))),d!==this.next_cl;){if(d.getDistanceToOrigin()===c)d.creator<this.creator&&(this.prev_cl=d,a=c+1);else{if(!(d.getDistanceToOrigin()<c))break;c-a<=d.getDistanceToOrigin()&&(this.prev_cl=d,a=c+1)}c++,d=d.next_cl}this.next_cl=this.prev_cl.next_cl,this.prev_cl.next_cl=this,this.next_cl.prev_cl=this}return b.__super__.execute.apply(this,arguments),this}return!1},b}(g),e=function(a){function b(a,c,d,e,f){this.content=null!=c?c:"",b.__super__.constructor.call(this,a,d,e,f)}return d(b,a),b.prototype.val=function(){return this.content},b.prototype._encode=function(){var a;return a={type:"ImmutableObject",uid:this.getUid(),content:this.content},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(f),i.ImmutableObject=function(a){var b,c,d,f,g;return g=a.uid,b=a.content,f=a.prev,c=a.next,d=a.origin,new e(g,b,f,c,d)},c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return d(b,a),b.prototype.execute=function(){var a,b,c;if(this.validateSavedOperations()){for(b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this}return!1},b.prototype._encode=function(){var a,b;return{type:"Delimiter",uid:this.getUid(),prev:null!=(a=this.prev_cl)?a.getUid():void 0,next:null!=(b=this.next_cl)?b.getUid():void 0}},b}(f),i.Delimiter=function(a){var b,d,e;return e=a.uid,d=a.prev,b=a.next,new c(e,d,b)},{types:{Delete:b,Insert:f,Delimiter:c,Operation:g,ImmutableObject:e},parser:i,execution_listener:h}}},{}],6:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./TextTypes.coffee"),b.exports=function(a){var b,d,f,g,h;return g=c(a),h=g.types,f=g.parser,d=function(a){var c;return new(c=function(){function a(c){var e,f,g,i;i=c.map,g=function(e,f){return Object.defineProperty(a.prototype,e,{get:function(){var a;return a=f.val(),a instanceof b?d(a):a instanceof h.ImmutableObject?a.val():a},set:function(a){var b,d,f,g;if(a.constructor==={}.constructor){f=c.val(e),g=[];for(b in a)d=a[b],g.push(f.val(b,d,"immutable"));return g}return c.val(e,a,"immutable")},enumerable:!0,configurable:!1})};for(e in i)f=i[e],g(e,f)}return a}())(a)},b=function(b){function c(a,b,d){var e,f;if(c.__super__.constructor.call(this,a),null!=b){if("object"!=typeof b)throw new Error("The initial value of JsonTypes must be of type Object! (current type: "+typeof b+")");for(e in b)f=b[e],this.val(e,f,d)}}return e(c,b),c.prototype.mutable_default=!0,c.prototype.setMutableDefault=function(a){if(a===!0||"mutable"===a)c.prototype.mutable_default=!0;else{if(a!==!1&&"immutable"!==a)throw new Error('Set mutable either "mutable" or "immutable"!');c.prototype.mutable_default=!1}return"OK"},c.prototype.val=function(b,d,e){var f,g,i,j,k;if("object"==typeof b){for(i in b)g=b[i],this.val(i,g,d);
return this}if(null!=b&&null!=d){if(e=null!=e?e===!0||"mutable"===e?!0:!1:this.mutable_default,"function"==typeof d)return this;if(e&&"number"!=typeof d||d.constructor===Object){if("string"==typeof d)return k=a.addOperation(new h.Word(a.getNextOperationIdentifier(),d)).execute(),c.__super__.val.call(this,b,k);if(d.constructor===Object)return f=a.addOperation(new c(a.getNextOperationIdentifier(),d,e)).execute(),c.__super__.val.call(this,b,f);throw new Error("You must not set "+typeof d+"-types in collaborative Json-objects!")}return j=a.addOperation(new h.ImmutableObject(void 0,d)).execute(),c.__super__.val.call(this,b,j)}return c.__super__.val.call(this,b,d)},Object.defineProperty(c.prototype,"value",{get:function(){return d(this)},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),c.prototype._encode=function(){return{type:"JsonType",uid:this.getUid()}},c}(h.MapManager),f.JsonType=function(a){var c;return c=a.uid,new b(c)},h.JsonType=b,g}},{"./TextTypes.coffee":8}],7:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./BasicTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i,j,k;return i=c(a),k=i.types,j=i.parser,f=function(c){function d(a){this.map={},d.__super__.constructor.call(this,a)}return e(d,c),d.prototype.val=function(c,e){var f,g,h,i,j;if(null!=e)return null==this.map[c]&&a.addOperation(new b(a.getNextOperationIdentifier(),this,c)).execute(),this.map[c].replace(e),this;if(null!=c)return g=null!=(i=this.map[c])?i.val():void 0,g instanceof k.ImmutableObject?g.val():g;h={},j=this.map;for(c in j)f=j[c],g=f.val(),(g instanceof k.ImmutableObject||g instanceof d)&&(g=g.val()),h[c]=g;return h},d}(k.Operation),b=function(b){function c(a,b,d){this.name=d,this.saveOperation("map_manager",b),c.__super__.constructor.call(this,a)}return e(c,b),c.prototype.execute=function(){var b,d,e,f,h;return this.validateSavedOperations()?(h=this.map_manager.getUid(),h.op_number="_"+h.op_number+"_RM_"+this.name,null==a.getOperation(h)&&(e=this.map_manager.getUid(),e.op_number="_"+e.op_number+"_RM_"+this.name+"_beginning",f=this.map_manager.getUid(),f.op_number="_"+f.op_number+"_RM_"+this.name+"_end",b=a.addOperation(new k.Delimiter(e,void 0,f)),d=a.addOperation(new k.Delimiter(f,b,void 0)).execute(),b.execute(),this.map_manager.map[this.name]=a.addOperation(new g(void 0,h,b,d)).execute()),c.__super__.execute.apply(this,arguments)):!1},c.prototype._encode=function(){return{type:"AddName",uid:this.getUid(),map_manager:this.map_manager.getUid(),name:this.name}},c}(k.Operation),j.AddName=function(a){var c,d,e;return c=a.map_manager,e=a.uid,d=a.name,new b(e,c,d)},d=function(b){function c(b,d,e,f,g,h){null!=d&&null!=e?(this.saveOperation("beginning",d),this.saveOperation("end",e)):(this.beginning=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),void 0,void 0)),this.end=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),this.beginning,void 0)),this.beginning.next_cl=this.end,this.beginning.execute(),this.end.execute()),c.__super__.constructor.call(this,b,f,g,h)}return e(c,b),c.prototype.getLastOperation=function(){return this.end.prev_cl},c.prototype.getFirstOperation=function(){return this.beginning.next_cl},c.prototype.toArray=function(){var a,b;for(a=this.beginning.next_cl,b=[];a!==this.end;)b.push(a),a=a.next_cl;return b},c.prototype.getOperationByPosition=function(a){var b;if(b=this.beginning.next_cl,a>0)for(;b=b.next_cl,b.isDeleted()||(a-=1),0!==a;)if(b instanceof k.Delimiter)throw new Error("position parameter exceeded the length of the document!");return b},c}(k.Insert),g=function(b){function c(a,b,d,e,f,g,h){c.__super__.constructor.call(this,b,d,e,f,g,h),null!=a&&this.replace(a)}return e(c,b),c.prototype.replace=function(b){var c,d;return c=this.getLastOperation(),d=new h(b,this,a.getNextOperationIdentifier(),c,c.next_cl),a.addOperation(d).execute()},c.prototype.val=function(){var a;if(a=this.getLastOperation(),a instanceof k.Delimiter)throw new Error("dtrn");return a.val()},c.prototype._encode=function(){var a;return a={type:"ReplaceManager",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&null!=this.next_cl&&(a.prev=this.prev_cl.getUid(),a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},c}(d),j.ReplaceManager=function(a){var b,c,d,e,f,h,i;return c=a.content,i=a.uid,h=a.prev,e=a.next,f=a.origin,b=a.beginning,d=a.end,new g(c,i,b,d,h,e,f)},h=function(a){function b(a,c,d,e,f,g){if(this.saveOperation("content",a),this.saveOperation("parent",c),null==e||null==f||null==a)throw new Error("You must define content, prev, and next for Replaceable-types!");b.__super__.constructor.call(this,d,e,f,g)}return e(b,a),b.prototype.val=function(){return this.content},b.prototype.replace=function(a){return this.parent.replace(a)},b.prototype.execute=function(){var a;return this.validateSavedOperations()?("function"==typeof(a=this.content).setReplaceManager&&a.setReplaceManager(this.parent),b.__super__.execute.apply(this,arguments),this):!1},b.prototype._encode=function(){var a;return a={type:"Replaceable",content:this.content.getUid(),ReplaceManager:this.parent.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid(),uid:this.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(k.Insert),j.Replaceable=function(a){var b,c,d,e,f,g;return b=a.content,e=a.ReplaceManager,g=a.uid,f=a.prev,c=a.next,d=a.origin,new h(b,e,g,f,c,d)},k.ListManager=d,k.MapManager=f,k.ReplaceManager=g,k.Replaceable=h,i}},{"./BasicTypes.coffee":5}],8:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./StructuredTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i;return h=c(a),i=h.types,g=h.parser,b=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return e(b,a),b}(i.Delete),g.TextDelete=g.Delete,d=function(a){function b(a,c,d,e,f){if(this.content=a,null==d||null==e)throw new Error("You must define prev, and next for TextInsert-types!");b.__super__.constructor.call(this,c,d,e,f)}return e(b,a),b.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},b.prototype.val=function(){return this.isDeleted()?"":this.content},b.prototype._encode=function(){var a;return a={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(i.Insert),g.TextInsert=function(a){var b,c,e,f,g;return b=a.content,g=a.uid,f=a.prev,c=a.next,e=a.origin,new d(b,g,f,c,e)},f=function(c){function f(a,b,c,d,e,g,h){f.__super__.constructor.call(this,a,c,d,e,g,h),null!=b&&this.insertText(0,b)}return e(f,c),f.prototype.insertText=function(b,c){var e,f,g,h,i,j;for(f=this.getOperationByPosition(b),j=[],h=0,i=c.length;i>h;h++)e=c[h],g=new d(e,a.getNextOperationIdentifier(),f.prev_cl,f),j.push(a.addOperation(g).execute());return j},f.prototype.deleteText=function(c,d){var e,f,g,h,j;for(g=this.getOperationByPosition(c),j=[],f=h=0;d>=0?d>h:h>d;f=d>=0?++h:--h){for(e=a.addOperation(new b(a.getNextOperationIdentifier(),g)).execute(),g=g.next_cl;g.isDeleted();){if(g instanceof i.Delimiter)throw new Error("You can't delete more than there is..");g=g.next_cl}j.push(e._encode())}return j},f.prototype.replaceText=function(b){var c;if(null!=this.replace_manager)return c=a.addOperation(new f(a.getNextOperationIdentifier())).execute(),c.insertText(0,b),this.replace_manager.replace(c);throw new Error("This type is currently not maintained by a ReplaceManager!")},f.prototype.val=function(){var a,b;return a=function(){var a,c,d,e;for(d=this.toArray(),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(null!=b.val?b.val():"");return e}.call(this),a.join("")},f.prototype.setReplaceManager=function(a){return this.saveOperation("replace_manager",a),this.validateSavedOperations},f.prototype._encode=function(){var a;return a={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},f}(i.ListManager),g.Word=function(a){var b,c,d,e,g,h;return h=a.uid,b=a.beginning,c=a.end,g=a.prev,d=a.next,e=a.origin,new f(h,void 0,b,c,g,d,e)},i.TextInsert=d,i.TextDelete=b,i.Word=f,h}},{"./StructuredTypes.coffee":7}]},{},[3,1]),!function n(a,b,c){function d(f,g){if(!b[f]){if(!a[f]){var h="function"==typeof require&&require;if(!g&&h)return h(f,!0);if(e)return e(f,!0);throw new Error("Cannot find module '"+f+"'")}var i=b[f]={exports:{}};a[f][0].call(i.exports,function(b){var c=a[f][1][b];return d(c?c:b)},i,i.exports,n,a,b,c)}return b[f].exports}for(var e="function"==typeof require&&require,f=0;f<c.length;f++)d(c[f]);return d}({1:[function(a,b){var c;c=function(a){var b,c,d,e,f,g,h;return f={},c=new DUIClient,c.connect(function(a){var b;return null!=(b=f[a.action])?b.map(function(b){return setTimeout(function(){return b(a)},0)}):void 0}),c.initOK(),h=null,g=null,b=function(){function a(a,b,d,e){var i,j,k;this.engine=a,this.HB=b,this.execution_listener=d,this.yatta=e,this.duiClient=c,this.iwcHandler=f,k=function(a){return function(b){return a.send(b)}}(this),this.execution_listener.push(k),i=function(a){return function(b){var c;return c=b.extras,a.receive(c)}}(this),this.iwcHandler.Yatta_new_operation=[i],null!=h&&this.engine.applyOps(g),j=function(a){return function(){var b;return b={root_element:a.yatta.getRootElement(),HB:a.yatta.getHistoryBuffer()._encode()},a.sendIwcIntent("Yatta_push_root_element",b)}}(this),this.iwcHandler.Yatta_get_root_element=[j]}return a.prototype.getRootElement=function(){return h},a.prototype.send=function(a){return a.uid.creator===this.HB.getUserId()&&"string"!=typeof a.uid.op_number?this.sendIwcIntent("Yatta_new_operation",a):void 0},a.prototype.receive=function(a){return a.uid.creator!==this.HB.getUserId()?this.engine.applyOp(a):void 0},a.prototype.sendIwcIntent=function(a,b){var c;return c={action:a,component:"",data:"",dataType:"",extras:b},this.duiClient.sendIntent(c)},a.prototype.sync=function(){throw new Error("Can't use this a.t.m.")},a}(),d={action:"Yatta_get_root_element",component:"",data:"",dataType:"",extras:{}},e=function(){var e,i;return c.sendIntent(d),e=!1,i=function(d){var f;return f=c.getIwcClient()._componentName,h=null!=d?d.extras.root_element:void 0,g=null!=d?d.extras.HB:void 0,e?void 0:(e=!0,a(b,f))},f.Yatta_push_root_element=[i],setTimeout(i,800)},void setTimeout(e,4e3*Math.random())},b.exports=c,"undefined"!=typeof window&&null!==window&&(window.createConnector=c)},{}],2:[function(a,b){var c;c=function(){function a(a,b){this.HB=a,this.parser=b,this.unprocessed_ops=[]}return a.prototype.parseOperation=function(a){var b;if(b=this.parser[a.type],null!=b)return b(a);throw new Error("You forgot to specify a parser for type "+a.type+". The message is "+JSON.stringify(a)+".")},a.prototype.applyOps=function(a){var b,c,d,e,f,g,h,i;for(c=[],d=0,g=a.length;g>d;d++)b=a[d],c.push(this.parseOperation(b));for(e=0,h=c.length;h>e;e++)b=c[e],this.HB.addOperation(b);for(f=0,i=c.length;i>f;f++)b=c[f],b.execute()||this.unprocessed_ops.push(b);return this.tryUnprocessed()},a.prototype.applyOp=function(a){var b;return b=this.parseOperation(a),this.HB.addOperation(b),b.execute()||this.unprocessed_ops.push(b),this.tryUnprocessed()},a.prototype.tryUnprocessed=function(){var a,b,c,d,e,f,g;for(g=[];;){for(a=this.unprocessed_ops.length,c=[],f=this.unprocessed_ops,d=0,e=f.length;e>d;d++)b=f[d],b.execute()||c.push(b);if(this.unprocessed_ops=c,this.unprocessed_ops.length===a)break;g.push(void 0)}return g},a}(),b.exports=c},{}],3:[function(a,b){var c,d,e,f;f=a("../Types/JsonTypes.coffee"),d=a("../HistoryBuffer.coffee"),c=a("../Engine.coffee"),e=function(){function a(a,b){var e,g,h;this.HB=new d(a),g=f(this.HB),this.engine=new c(this.HB,g.parser),this.connector=new b(this.engine,this.HB,g.execution_listener,this),h=this.connector.getRootElement(),null==h?(e=new g.types.JsonType(this.HB.getNextOperationIdentifier()),this.HB.addOperation(e),e.execute(),this.root_element=e):this.root_element=this.HB.getOperation(h)}return a.prototype.getRootElement=function(){return this.root_element},a.prototype.getEngine=function(){return this.engine},a.prototype.getConnector=function(){return this.connector},a.prototype.getHistoryBuffer=function(){return this.HB},a.prototype.setMutableDefault=function(a){return this.root_element.setMutableDefault(a)},a.prototype.getUserId=function(){return this.HB.getUserId()},a.prototype.val=function(a,b,c){return this.root_element.val(a,b,c)},Object.defineProperty(a.prototype,"value",{get:function(){return this.root_element.value},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),a}(),"undefined"!=typeof window&&null!==window&&(window.JsonYatta=e),b.exports=e},{"../Engine.coffee":2,"../HistoryBuffer.coffee":4,"../Types/JsonTypes.coffee":6}],4:[function(a,b){var c;c=function(){function a(a){this.user_id=a,this.operation_counter={},this.buffer={},this.change_listeners=[]}return a.prototype.getUserId=function(){return this.user_id},a.prototype.getOperationCounter=function(){var a,b,c,d;b={},d=this.operation_counter;for(c in d)a=d[c],b[c]=a;return b},a.prototype._encode=function(){var a,b,c,d,e,f;a=[],f=this.buffer;for(d in f){e=f[d];for(c in e)b=e[c],isNaN(parseInt(c))||a.push(b._encode())}return a},a.prototype.getNextOperationIdentifier=function(a){var b;return null==a&&(a=this.user_id),null==this.operation_counter[a]&&(this.operation_counter[a]=0),b={creator:a,op_number:this.operation_counter[a]},this.operation_counter[a]++,b},a.prototype.getOperation=function(a){var b;if(a instanceof Object)return null!=(b=this.buffer[a.creator])?b[a.op_number]:void 0;if(null!=a)throw new Error("This type of uid is not defined!")},a.prototype.addOperation=function(a){if(null==this.buffer[a.creator]&&(this.buffer[a.creator]={}),null==this.operation_counter[a.creator]&&(this.operation_counter[a.creator]=0),null!=this.buffer[a.creator][a.op_number])throw new Error("You must not overwrite operations!");return this.buffer[a.creator][a.op_number]=a,"number"==typeof a.op_number&&a.creator!==this.getUserId()&&this.operation_counter[a.creator]++,a},a}(),b.exports=c},{}],5:[function(a,b){var c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};b.exports=function(a){var b,c,e,f,g,h,i;return i={},h=[],g=function(){function b(b){null==b&&(b=a.getNextOperationIdentifier()),this.creator=b.creator,this.op_number=b.op_number}return b.prototype.getUid=function(){return{creator:this.creator,op_number:this.op_number}},b.prototype.execute=function(){var a,b,c;for(this.is_executed=!0,b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this},b.prototype.saveOperation=function(a,b){return null!=(null!=b?b.execute:void 0)?this[a]=b:null!=b?(null==this.unchecked&&(this.unchecked={}),this.unchecked[a]=b):void 0},b.prototype.validateSavedOperations=function(){var b,c,d,e,f,g;f={},e=this,g=this.unchecked;for(b in g)d=g[b],c=a.getOperation(d),c?this[b]=c:(f[b]=d,e=!1);return delete this.unchecked,e||(this.unchecked=f),e},b}(),b=function(a){function b(a,c){this.saveOperation("deletes",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype._encode=function(){return{type:"Delete",uid:this.getUid(),deletes:this.deletes.getUid()}},b.prototype.execute=function(){return this.validateSavedOperations()?(this.deletes.applyDelete(this),b.__super__.execute.apply(this,arguments),this):!1},b}(g),i.Delete=function(a){var c,d;return d=a.uid,c=a.deletes,new b(d,c)},f=function(a){function b(a,c,d,e){this.saveOperation("prev_cl",c),this.saveOperation("next_cl",d),null!=e?this.saveOperation("origin",e):this.saveOperation("origin",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype.applyDelete=function(a){return null==this.deleted_by&&(this.deleted_by=[]),this.deleted_by.push(a)},b.prototype.isDeleted=function(){var a;return(null!=(a=this.deleted_by)?a.length:void 0)>0},b.prototype.getDistanceToOrigin=function(){var a,b;for(a=0,b=this.prev_cl;this.origin!==b;){if(a++,this===this.prev_cl)throw new Error("this should not happen ;) ");b=b.prev_cl}return a},b.prototype.update_sl=function(){var a;return a=this.prev_cl,update("prev_cl","prev_sl"),update("next_cl","prev_sl")},b.prototype.execute=function(){var a,c,d,e,f;if(null!=this.is_executed)return this;if(this.validateSavedOperations()){if((null!=(e=this.prev_cl)?e.validateSavedOperations():void 0)&&(null!=(f=this.next_cl)?f.validateSavedOperations():void 0)&&this.prev_cl.next_cl!==this){for(a=0,d=this.prev_cl.next_cl,c=0;null==d&&(console.log(JSON.stringify(this.prev_cl.getUid())),console.log(JSON.stringify(this.next_cl.getUid()))),d!==this.next_cl;){if(d.getDistanceToOrigin()===c)d.creator<this.creator&&(this.prev_cl=d,a=c+1);else{if(!(d.getDistanceToOrigin()<c))break;c-a<=d.getDistanceToOrigin()&&(this.prev_cl=d,a=c+1)}c++,d=d.next_cl}this.next_cl=this.prev_cl.next_cl,this.prev_cl.next_cl=this,this.next_cl.prev_cl=this}return b.__super__.execute.apply(this,arguments),this}return!1},b}(g),e=function(a){function b(a,c,d,e,f){this.content=null!=c?c:"",b.__super__.constructor.call(this,a,d,e,f)}return d(b,a),b.prototype.val=function(){return this.content},b.prototype._encode=function(){var a;return a={type:"ImmutableObject",uid:this.getUid(),content:this.content},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(f),i.ImmutableObject=function(a){var b,c,d,f,g;return g=a.uid,b=a.content,f=a.prev,c=a.next,d=a.origin,new e(g,b,f,c,d)},c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return d(b,a),b.prototype.execute=function(){var a,b,c;if(this.validateSavedOperations()){for(b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this}return!1},b.prototype._encode=function(){var a,b;return{type:"Delimiter",uid:this.getUid(),prev:null!=(a=this.prev_cl)?a.getUid():void 0,next:null!=(b=this.next_cl)?b.getUid():void 0}},b}(f),i.Delimiter=function(a){var b,d,e;return e=a.uid,d=a.prev,b=a.next,new c(e,d,b)},{types:{Delete:b,Insert:f,Delimiter:c,Operation:g,ImmutableObject:e},parser:i,execution_listener:h}}},{}],6:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./TextTypes.coffee"),b.exports=function(a){var b,d,f,g,h;return g=c(a),h=g.types,f=g.parser,d=function(a){var c;return new(c=function(){function a(c){var e,f,g,i;i=c.map,g=function(e,f){return Object.defineProperty(a.prototype,e,{get:function(){var a;return a=f.val(),a instanceof b?d(a):a instanceof h.ImmutableObject?a.val():a},set:function(a){var b,d,f,g;if(a.constructor==={}.constructor){f=c.val(e),g=[];for(b in a)d=a[b],g.push(f.val(b,d,"immutable"));return g}return c.val(e,a,"immutable")},enumerable:!0,configurable:!1})};for(e in i)f=i[e],g(e,f)}return a}())(a)},b=function(b){function c(a,b,d){var e,f;if(c.__super__.constructor.call(this,a),null!=b){if("object"!=typeof b)throw new Error("The initial value of JsonTypes must be of type Object! (current type: "+typeof b+")");for(e in b)f=b[e],this.val(e,f,d)}}return e(c,b),c.prototype.mutable_default=!0,c.prototype.setMutableDefault=function(a){if(a===!0||"mutable"===a)c.prototype.mutable_default=!0;else{if(a!==!1&&"immutable"!==a)throw new Error('Set mutable either "mutable" or "immutable"!');c.prototype.mutable_default=!1}return"OK"},c.prototype.val=function(b,d,e){var f,g,i,j,k;if("object"==typeof b){for(i in b)g=b[i],this.val(i,g,d);return this}if(null!=b&&null!=d){if(e=null!=e?e===!0||"mutable"===e?!0:!1:this.mutable_default,"function"==typeof d)return this;if(e&&"number"!=typeof d||d.constructor===Object){if("string"==typeof d)return k=a.addOperation(new h.Word(a.getNextOperationIdentifier(),d)).execute(),c.__super__.val.call(this,b,k);if(d.constructor===Object)return f=a.addOperation(new c(a.getNextOperationIdentifier(),d,e)).execute(),c.__super__.val.call(this,b,f);throw new Error("You must not set "+typeof d+"-types in collaborative Json-objects!")}return j=a.addOperation(new h.ImmutableObject(void 0,d)).execute(),c.__super__.val.call(this,b,j)}return c.__super__.val.call(this,b,d)},Object.defineProperty(c.prototype,"value",{get:function(){return d(this)},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),c.prototype._encode=function(){return{type:"JsonType",uid:this.getUid()}},c}(h.MapManager),f.JsonType=function(a){var c;return c=a.uid,new b(c)},h.JsonType=b,g}},{"./TextTypes.coffee":8}],7:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./BasicTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i,j,k;return i=c(a),k=i.types,j=i.parser,f=function(c){function d(a){this.map={},d.__super__.constructor.call(this,a)}return e(d,c),d.prototype.val=function(c,e){var f,g,h,i,j;if(null!=e)return null==this.map[c]&&a.addOperation(new b(a.getNextOperationIdentifier(),this,c)).execute(),this.map[c].replace(e),this;if(null!=c)return g=null!=(i=this.map[c])?i.val():void 0,g instanceof k.ImmutableObject?g.val():g;h={},j=this.map;for(c in j)f=j[c],g=f.val(),(g instanceof k.ImmutableObject||g instanceof d)&&(g=g.val()),h[c]=g;return h},d}(k.Operation),b=function(b){function c(a,b,d){this.name=d,this.saveOperation("map_manager",b),c.__super__.constructor.call(this,a)}return e(c,b),c.prototype.execute=function(){var b,d,e,f,h;return this.validateSavedOperations()?(h=this.map_manager.getUid(),h.op_number="_"+h.op_number+"_RM_"+this.name,null==a.getOperation(h)&&(e=this.map_manager.getUid(),e.op_number="_"+e.op_number+"_RM_"+this.name+"_beginning",f=this.map_manager.getUid(),f.op_number="_"+f.op_number+"_RM_"+this.name+"_end",b=a.addOperation(new k.Delimiter(e,void 0,f)),d=a.addOperation(new k.Delimiter(f,b,void 0)).execute(),b.execute(),this.map_manager.map[this.name]=a.addOperation(new g(void 0,h,b,d)).execute()),c.__super__.execute.apply(this,arguments)):!1},c.prototype._encode=function(){return{type:"AddName",uid:this.getUid(),map_manager:this.map_manager.getUid(),name:this.name}},c}(k.Operation),j.AddName=function(a){var c,d,e;return c=a.map_manager,e=a.uid,d=a.name,new b(e,c,d)},d=function(b){function c(b,d,e,f,g,h){null!=d&&null!=e?(this.saveOperation("beginning",d),this.saveOperation("end",e)):(this.beginning=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),void 0,void 0)),this.end=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),this.beginning,void 0)),this.beginning.next_cl=this.end,this.beginning.execute(),this.end.execute()),c.__super__.constructor.call(this,b,f,g,h)}return e(c,b),c.prototype.getLastOperation=function(){return this.end.prev_cl},c.prototype.getFirstOperation=function(){return this.beginning.next_cl},c.prototype.toArray=function(){var a,b;for(a=this.beginning.next_cl,b=[];a!==this.end;)b.push(a),a=a.next_cl;return b},c.prototype.getOperationByPosition=function(a){var b;if(b=this.beginning.next_cl,a>0)for(;b=b.next_cl,b.isDeleted()||(a-=1),0!==a;)if(b instanceof k.Delimiter)throw new Error("position parameter exceeded the length of the document!");return b},c}(k.Insert),g=function(b){function c(a,b,d,e,f,g,h){c.__super__.constructor.call(this,b,d,e,f,g,h),null!=a&&this.replace(a)}return e(c,b),c.prototype.replace=function(b){var c,d;return c=this.getLastOperation(),d=new h(b,this,a.getNextOperationIdentifier(),c,c.next_cl),a.addOperation(d).execute()},c.prototype.val=function(){var a;if(a=this.getLastOperation(),a instanceof k.Delimiter)throw new Error("dtrn");return a.val()},c.prototype._encode=function(){var a;return a={type:"ReplaceManager",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&null!=this.next_cl&&(a.prev=this.prev_cl.getUid(),a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},c}(d),j.ReplaceManager=function(a){var b,c,d,e,f,h,i;return c=a.content,i=a.uid,h=a.prev,e=a.next,f=a.origin,b=a.beginning,d=a.end,new g(c,i,b,d,h,e,f)},h=function(a){function b(a,c,d,e,f,g){if(this.saveOperation("content",a),this.saveOperation("parent",c),null==e||null==f||null==a)throw new Error("You must define content, prev, and next for Replaceable-types!");b.__super__.constructor.call(this,d,e,f,g)}return e(b,a),b.prototype.val=function(){return this.content},b.prototype.replace=function(a){return this.parent.replace(a)},b.prototype.execute=function(){var a;return this.validateSavedOperations()?("function"==typeof(a=this.content).setReplaceManager&&a.setReplaceManager(this.parent),b.__super__.execute.apply(this,arguments),this):!1},b.prototype._encode=function(){var a;return a={type:"Replaceable",content:this.content.getUid(),ReplaceManager:this.parent.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid(),uid:this.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(k.Insert),j.Replaceable=function(a){var b,c,d,e,f,g;return b=a.content,e=a.ReplaceManager,g=a.uid,f=a.prev,c=a.next,d=a.origin,new h(b,e,g,f,c,d)},k.ListManager=d,k.MapManager=f,k.ReplaceManager=g,k.Replaceable=h,i}},{"./BasicTypes.coffee":5}],8:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./StructuredTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i;return h=c(a),i=h.types,g=h.parser,b=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return e(b,a),b}(i.Delete),g.TextDelete=g.Delete,d=function(a){function b(a,c,d,e,f){if(this.content=a,null==d||null==e)throw new Error("You must define prev, and next for TextInsert-types!");b.__super__.constructor.call(this,c,d,e,f)}return e(b,a),b.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},b.prototype.val=function(){return this.isDeleted()?"":this.content},b.prototype._encode=function(){var a;return a={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(i.Insert),g.TextInsert=function(a){var b,c,e,f,g;return b=a.content,g=a.uid,f=a.prev,c=a.next,e=a.origin,new d(b,g,f,c,e)},f=function(c){function f(a,b,c,d,e,g,h){f.__super__.constructor.call(this,a,c,d,e,g,h),null!=b&&this.insertText(0,b)}return e(f,c),f.prototype.insertText=function(b,c){var e,f,g,h,i,j;for(f=this.getOperationByPosition(b),j=[],h=0,i=c.length;i>h;h++)e=c[h],g=new d(e,a.getNextOperationIdentifier(),f.prev_cl,f),j.push(a.addOperation(g).execute());return j},f.prototype.deleteText=function(c,d){var e,f,g,h,j;for(g=this.getOperationByPosition(c),j=[],f=h=0;d>=0?d>h:h>d;f=d>=0?++h:--h){for(e=a.addOperation(new b(a.getNextOperationIdentifier(),g)).execute(),g=g.next_cl;g.isDeleted();){if(g instanceof i.Delimiter)throw new Error("You can't delete more than there is..");g=g.next_cl}j.push(e._encode())}return j},f.prototype.replaceText=function(b){var c;if(null!=this.replace_manager)return c=a.addOperation(new f(a.getNextOperationIdentifier())).execute(),c.insertText(0,b),this.replace_manager.replace(c);throw new Error("This type is currently not maintained by a ReplaceManager!")},f.prototype.val=function(){var a,b;return a=function(){var a,c,d,e;for(d=this.toArray(),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(null!=b.val?b.val():"");return e}.call(this),a.join("")},f.prototype.setReplaceManager=function(a){return this.saveOperation("replace_manager",a),this.validateSavedOperations},f.prototype._encode=function(){var a;return a={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},f}(i.ListManager),g.Word=function(a){var b,c,d,e,g,h;return h=a.uid,b=a.beginning,c=a.end,g=a.prev,d=a.next,e=a.origin,new f(h,void 0,b,c,g,d,e)},i.TextInsert=d,i.TextDelete=b,i.Word=f,h}},{"./StructuredTypes.coffee":7}]},{},[3,1]),!function o(a,b,c){function d(f,g){if(!b[f]){if(!a[f]){var h="function"==typeof require&&require;if(!g&&h)return h(f,!0);if(e)return e(f,!0);throw new Error("Cannot find module '"+f+"'")}var i=b[f]={exports:{}};a[f][0].call(i.exports,function(b){var c=a[f][1][b];return d(c?c:b)},i,i.exports,o,a,b,c)}return b[f].exports}for(var e="function"==typeof require&&require,f=0;f<c.length;f++)d(c[f]);return d}({1:[function(a,b){var c;c=function(a){var b,c,d,e,f,g,h;return f={},c=new DUIClient,c.connect(function(a){var b;return null!=(b=f[a.action])?b.map(function(b){return setTimeout(function(){return b(a)},0)}):void 0}),c.initOK(),h=null,g=null,b=function(){function a(a,b,d,e){var i,j,k;this.engine=a,this.HB=b,this.execution_listener=d,this.yatta=e,this.duiClient=c,this.iwcHandler=f,k=function(a){return function(b){return a.send(b)}}(this),this.execution_listener.push(k),i=function(a){return function(b){var c;return c=b.extras,a.receive(c)}}(this),this.iwcHandler.Yatta_new_operation=[i],null!=h&&this.engine.applyOps(g),j=function(a){return function(){var b;return b={root_element:a.yatta.getRootElement(),HB:a.yatta.getHistoryBuffer()._encode()},a.sendIwcIntent("Yatta_push_root_element",b)}}(this),this.iwcHandler.Yatta_get_root_element=[j]}return a.prototype.getRootElement=function(){return h},a.prototype.send=function(a){return a.uid.creator===this.HB.getUserId()&&"string"!=typeof a.uid.op_number?this.sendIwcIntent("Yatta_new_operation",a):void 0},a.prototype.receive=function(a){return a.uid.creator!==this.HB.getUserId()?this.engine.applyOp(a):void 0},a.prototype.sendIwcIntent=function(a,b){var c;return c={action:a,component:"",data:"",dataType:"",extras:b},this.duiClient.sendIntent(c)},a.prototype.sync=function(){throw new Error("Can't use this a.t.m.")},a}(),d={action:"Yatta_get_root_element",component:"",data:"",dataType:"",extras:{}},e=function(){var e,i;return c.sendIntent(d),e=!1,i=function(d){var f;return f=c.getIwcClient()._componentName,h=null!=d?d.extras.root_element:void 0,g=null!=d?d.extras.HB:void 0,e?void 0:(e=!0,a(b,f))},f.Yatta_push_root_element=[i],setTimeout(i,800)},void setTimeout(e,4e3*Math.random())},b.exports=c,"undefined"!=typeof window&&null!==window&&(window.createConnector=c)},{}],2:[function(a,b){var c;c=function(){function a(a,b){this.HB=a,this.parser=b,this.unprocessed_ops=[]}return a.prototype.parseOperation=function(a){var b;if(b=this.parser[a.type],null!=b)return b(a);throw new Error("You forgot to specify a parser for type "+a.type+". The message is "+JSON.stringify(a)+".")},a.prototype.applyOps=function(a){var b,c,d,e,f,g,h,i;for(c=[],d=0,g=a.length;g>d;d++)b=a[d],c.push(this.parseOperation(b));for(e=0,h=c.length;h>e;e++)b=c[e],this.HB.addOperation(b);for(f=0,i=c.length;i>f;f++)b=c[f],b.execute()||this.unprocessed_ops.push(b);
return this.tryUnprocessed()},a.prototype.applyOp=function(a){var b;return b=this.parseOperation(a),this.HB.addOperation(b),b.execute()||this.unprocessed_ops.push(b),this.tryUnprocessed()},a.prototype.tryUnprocessed=function(){var a,b,c,d,e,f,g;for(g=[];;){for(a=this.unprocessed_ops.length,c=[],f=this.unprocessed_ops,d=0,e=f.length;e>d;d++)b=f[d],b.execute()||c.push(b);if(this.unprocessed_ops=c,this.unprocessed_ops.length===a)break;g.push(void 0)}return g},a}(),b.exports=c},{}],3:[function(a,b){var c,d,e,f;f=a("../Types/JsonTypes.coffee"),d=a("../HistoryBuffer.coffee"),c=a("../Engine.coffee"),e=function(){function a(a,b){var e,g,h;this.HB=new d(a),g=f(this.HB),this.engine=new c(this.HB,g.parser),this.connector=new b(this.engine,this.HB,g.execution_listener,this),h=this.connector.getRootElement(),null==h?(e=new g.types.JsonType(this.HB.getNextOperationIdentifier()),this.HB.addOperation(e),e.execute(),this.root_element=e):this.root_element=this.HB.getOperation(h)}return a.prototype.getRootElement=function(){return this.root_element},a.prototype.getEngine=function(){return this.engine},a.prototype.getConnector=function(){return this.connector},a.prototype.getHistoryBuffer=function(){return this.HB},a.prototype.setMutableDefault=function(a){return this.root_element.setMutableDefault(a)},a.prototype.getUserId=function(){return this.HB.getUserId()},a.prototype.val=function(a,b,c){return this.root_element.val(a,b,c)},Object.defineProperty(a.prototype,"value",{get:function(){return this.root_element.value},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),a}(),"undefined"!=typeof window&&null!==window&&(window.JsonYatta=e),b.exports=e},{"../Engine.coffee":2,"../HistoryBuffer.coffee":4,"../Types/JsonTypes.coffee":6}],4:[function(a,b){var c;c=function(){function a(a){this.user_id=a,this.operation_counter={},this.buffer={},this.change_listeners=[]}return a.prototype.getUserId=function(){return this.user_id},a.prototype.getOperationCounter=function(){var a,b,c,d;b={},d=this.operation_counter;for(c in d)a=d[c],b[c]=a;return b},a.prototype._encode=function(){var a,b,c,d,e,f;a=[],f=this.buffer;for(d in f){e=f[d];for(c in e)b=e[c],isNaN(parseInt(c))||a.push(b._encode())}return a},a.prototype.getNextOperationIdentifier=function(a){var b;return null==a&&(a=this.user_id),null==this.operation_counter[a]&&(this.operation_counter[a]=0),b={creator:a,op_number:this.operation_counter[a]},this.operation_counter[a]++,b},a.prototype.getOperation=function(a){var b;if(a instanceof Object)return null!=(b=this.buffer[a.creator])?b[a.op_number]:void 0;if(null!=a)throw new Error("This type of uid is not defined!")},a.prototype.addOperation=function(a){if(null==this.buffer[a.creator]&&(this.buffer[a.creator]={}),null==this.operation_counter[a.creator]&&(this.operation_counter[a.creator]=0),null!=this.buffer[a.creator][a.op_number])throw new Error("You must not overwrite operations!");return this.buffer[a.creator][a.op_number]=a,"number"==typeof a.op_number&&a.creator!==this.getUserId()&&this.operation_counter[a.creator]++,a},a}(),b.exports=c},{}],5:[function(a,b){var c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};b.exports=function(a){var b,c,e,f,g,h,i;return i={},h=[],g=function(){function b(b){null==b&&(b=a.getNextOperationIdentifier()),this.creator=b.creator,this.op_number=b.op_number}return b.prototype.getUid=function(){return{creator:this.creator,op_number:this.op_number}},b.prototype.execute=function(){var a,b,c;for(this.is_executed=!0,b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this},b.prototype.saveOperation=function(a,b){return null!=(null!=b?b.execute:void 0)?this[a]=b:null!=b?(null==this.unchecked&&(this.unchecked={}),this.unchecked[a]=b):void 0},b.prototype.validateSavedOperations=function(){var b,c,d,e,f,g;f={},e=this,g=this.unchecked;for(b in g)d=g[b],c=a.getOperation(d),c?this[b]=c:(f[b]=d,e=!1);return delete this.unchecked,e||(this.unchecked=f),e},b}(),b=function(a){function b(a,c){this.saveOperation("deletes",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype._encode=function(){return{type:"Delete",uid:this.getUid(),deletes:this.deletes.getUid()}},b.prototype.execute=function(){return this.validateSavedOperations()?(this.deletes.applyDelete(this),b.__super__.execute.apply(this,arguments),this):!1},b}(g),i.Delete=function(a){var c,d;return d=a.uid,c=a.deletes,new b(d,c)},f=function(a){function b(a,c,d,e){this.saveOperation("prev_cl",c),this.saveOperation("next_cl",d),null!=e?this.saveOperation("origin",e):this.saveOperation("origin",c),b.__super__.constructor.call(this,a)}return d(b,a),b.prototype.applyDelete=function(a){return null==this.deleted_by&&(this.deleted_by=[]),this.deleted_by.push(a)},b.prototype.isDeleted=function(){var a;return(null!=(a=this.deleted_by)?a.length:void 0)>0},b.prototype.getDistanceToOrigin=function(){var a,b;for(a=0,b=this.prev_cl;this.origin!==b;){if(a++,this===this.prev_cl)throw new Error("this should not happen ;) ");b=b.prev_cl}return a},b.prototype.update_sl=function(){var a;return a=this.prev_cl,update("prev_cl","prev_sl"),update("next_cl","prev_sl")},b.prototype.execute=function(){var a,c,d,e,f;if(null!=this.is_executed)return this;if(this.validateSavedOperations()){if((null!=(e=this.prev_cl)?e.validateSavedOperations():void 0)&&(null!=(f=this.next_cl)?f.validateSavedOperations():void 0)&&this.prev_cl.next_cl!==this){for(a=0,d=this.prev_cl.next_cl,c=0;null==d&&(console.log(JSON.stringify(this.prev_cl.getUid())),console.log(JSON.stringify(this.next_cl.getUid()))),d!==this.next_cl;){if(d.getDistanceToOrigin()===c)d.creator<this.creator&&(this.prev_cl=d,a=c+1);else{if(!(d.getDistanceToOrigin()<c))break;c-a<=d.getDistanceToOrigin()&&(this.prev_cl=d,a=c+1)}c++,d=d.next_cl}this.next_cl=this.prev_cl.next_cl,this.prev_cl.next_cl=this,this.next_cl.prev_cl=this}return b.__super__.execute.apply(this,arguments),this}return!1},b}(g),e=function(a){function b(a,c,d,e,f){this.content=null!=c?c:"",b.__super__.constructor.call(this,a,d,e,f)}return d(b,a),b.prototype.val=function(){return this.content},b.prototype._encode=function(){var a;return a={type:"ImmutableObject",uid:this.getUid(),content:this.content},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(f),i.ImmutableObject=function(a){var b,c,d,f,g;return g=a.uid,b=a.content,f=a.prev,c=a.next,d=a.origin,new e(g,b,f,c,d)},c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return d(b,a),b.prototype.execute=function(){var a,b,c;if(this.validateSavedOperations()){for(b=0,c=h.length;c>b;b++)(a=h[b])(this._encode());return this}return!1},b.prototype._encode=function(){var a,b;return{type:"Delimiter",uid:this.getUid(),prev:null!=(a=this.prev_cl)?a.getUid():void 0,next:null!=(b=this.next_cl)?b.getUid():void 0}},b}(f),i.Delimiter=function(a){var b,d,e;return e=a.uid,d=a.prev,b=a.next,new c(e,d,b)},{types:{Delete:b,Insert:f,Delimiter:c,Operation:g,ImmutableObject:e},parser:i,execution_listener:h}}},{}],6:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./TextTypes.coffee"),b.exports=function(a){var b,d,f,g,h;return g=c(a),h=g.types,f=g.parser,d=function(a){var c;return new(c=function(){function a(c){var e,f,g,i;i=c.map,g=function(e,f){return Object.defineProperty(a.prototype,e,{get:function(){var a;return a=f.val(),a instanceof b?d(a):a instanceof h.ImmutableObject?a.val():a},set:function(a){var b,d,f,g;if(a.constructor==={}.constructor){f=c.val(e),g=[];for(b in a)d=a[b],g.push(f.val(b,d,"immutable"));return g}return c.val(e,a,"immutable")},enumerable:!0,configurable:!1})};for(e in i)f=i[e],g(e,f)}return a}())(a)},b=function(b){function c(a,b,d){var e,f;if(c.__super__.constructor.call(this,a),null!=b){if("object"!=typeof b)throw new Error("The initial value of JsonTypes must be of type Object! (current type: "+typeof b+")");for(e in b)f=b[e],this.val(e,f,d)}}return e(c,b),c.prototype.mutable_default=!0,c.prototype.setMutableDefault=function(a){if(a===!0||"mutable"===a)c.prototype.mutable_default=!0;else{if(a!==!1&&"immutable"!==a)throw new Error('Set mutable either "mutable" or "immutable"!');c.prototype.mutable_default=!1}return"OK"},c.prototype.val=function(b,d,e){var f,g,i,j,k;if("object"==typeof b){for(i in b)g=b[i],this.val(i,g,d);return this}if(null!=b&&null!=d){if(e=null!=e?e===!0||"mutable"===e?!0:!1:this.mutable_default,"function"==typeof d)return this;if(e&&"number"!=typeof d||d.constructor===Object){if("string"==typeof d)return k=a.addOperation(new h.Word(a.getNextOperationIdentifier(),d)).execute(),c.__super__.val.call(this,b,k);if(d.constructor===Object)return f=a.addOperation(new c(a.getNextOperationIdentifier(),d,e)).execute(),c.__super__.val.call(this,b,f);throw new Error("You must not set "+typeof d+"-types in collaborative Json-objects!")}return j=a.addOperation(new h.ImmutableObject(void 0,d)).execute(),c.__super__.val.call(this,b,j)}return c.__super__.val.call(this,b,d)},Object.defineProperty(c.prototype,"value",{get:function(){return d(this)},set:function(a){var b,c,d;if(a.constructor==={}.constructor){d=[];for(b in a)c=a[b],d.push(this.val(b,c,"immutable"));return d}throw new Error("You must only set Object values!")}}),c.prototype._encode=function(){return{type:"JsonType",uid:this.getUid()}},c}(h.MapManager),f.JsonType=function(a){var c;return c=a.uid,new b(c)},h.JsonType=b,g}},{"./TextTypes.coffee":8}],7:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./BasicTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i,j,k;return i=c(a),k=i.types,j=i.parser,f=function(c){function d(a){this.map={},d.__super__.constructor.call(this,a)}return e(d,c),d.prototype.val=function(c,e){var f,g,h,i,j;if(null!=e)return null==this.map[c]&&a.addOperation(new b(a.getNextOperationIdentifier(),this,c)).execute(),this.map[c].replace(e),this;if(null!=c)return g=null!=(i=this.map[c])?i.val():void 0,g instanceof k.ImmutableObject?g.val():g;h={},j=this.map;for(c in j)f=j[c],g=f.val(),(g instanceof k.ImmutableObject||g instanceof d)&&(g=g.val()),h[c]=g;return h},d}(k.Operation),b=function(b){function c(a,b,d){this.name=d,this.saveOperation("map_manager",b),c.__super__.constructor.call(this,a)}return e(c,b),c.prototype.execute=function(){var b,d,e,f,h;return this.validateSavedOperations()?(h=this.map_manager.getUid(),h.op_number="_"+h.op_number+"_RM_"+this.name,null==a.getOperation(h)&&(e=this.map_manager.getUid(),e.op_number="_"+e.op_number+"_RM_"+this.name+"_beginning",f=this.map_manager.getUid(),f.op_number="_"+f.op_number+"_RM_"+this.name+"_end",b=a.addOperation(new k.Delimiter(e,void 0,f)),d=a.addOperation(new k.Delimiter(f,b,void 0)).execute(),b.execute(),this.map_manager.map[this.name]=a.addOperation(new g(void 0,h,b,d)).execute()),c.__super__.execute.apply(this,arguments)):!1},c.prototype._encode=function(){return{type:"AddName",uid:this.getUid(),map_manager:this.map_manager.getUid(),name:this.name}},c}(k.Operation),j.AddName=function(a){var c,d,e;return c=a.map_manager,e=a.uid,d=a.name,new b(e,c,d)},d=function(b){function c(b,d,e,f,g,h){null!=d&&null!=e?(this.saveOperation("beginning",d),this.saveOperation("end",e)):(this.beginning=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),void 0,void 0)),this.end=a.addOperation(new k.Delimiter(a.getNextOperationIdentifier(),this.beginning,void 0)),this.beginning.next_cl=this.end,this.beginning.execute(),this.end.execute()),c.__super__.constructor.call(this,b,f,g,h)}return e(c,b),c.prototype.getLastOperation=function(){return this.end.prev_cl},c.prototype.getFirstOperation=function(){return this.beginning.next_cl},c.prototype.toArray=function(){var a,b;for(a=this.beginning.next_cl,b=[];a!==this.end;)b.push(a),a=a.next_cl;return b},c.prototype.getOperationByPosition=function(a){var b;if(b=this.beginning.next_cl,a>0)for(;b=b.next_cl,b.isDeleted()||(a-=1),0!==a;)if(b instanceof k.Delimiter)throw new Error("position parameter exceeded the length of the document!");return b},c}(k.Insert),g=function(b){function c(a,b,d,e,f,g,h){c.__super__.constructor.call(this,b,d,e,f,g,h),null!=a&&this.replace(a)}return e(c,b),c.prototype.replace=function(b){var c,d;return c=this.getLastOperation(),d=new h(b,this,a.getNextOperationIdentifier(),c,c.next_cl),a.addOperation(d).execute()},c.prototype.val=function(){var a;if(a=this.getLastOperation(),a instanceof k.Delimiter)throw new Error("dtrn");return a.val()},c.prototype._encode=function(){var a;return a={type:"ReplaceManager",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&null!=this.next_cl&&(a.prev=this.prev_cl.getUid(),a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},c}(d),j.ReplaceManager=function(a){var b,c,d,e,f,h,i;return c=a.content,i=a.uid,h=a.prev,e=a.next,f=a.origin,b=a.beginning,d=a.end,new g(c,i,b,d,h,e,f)},h=function(a){function b(a,c,d,e,f,g){if(this.saveOperation("content",a),this.saveOperation("parent",c),null==e||null==f||null==a)throw new Error("You must define content, prev, and next for Replaceable-types!");b.__super__.constructor.call(this,d,e,f,g)}return e(b,a),b.prototype.val=function(){return this.content},b.prototype.replace=function(a){return this.parent.replace(a)},b.prototype.execute=function(){var a;return this.validateSavedOperations()?("function"==typeof(a=this.content).setReplaceManager&&a.setReplaceManager(this.parent),b.__super__.execute.apply(this,arguments),this):!1},b.prototype._encode=function(){var a;return a={type:"Replaceable",content:this.content.getUid(),ReplaceManager:this.parent.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid(),uid:this.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(k.Insert),j.Replaceable=function(a){var b,c,d,e,f,g;return b=a.content,e=a.ReplaceManager,g=a.uid,f=a.prev,c=a.next,d=a.origin,new h(b,e,g,f,c,d)},k.ListManager=d,k.MapManager=f,k.ReplaceManager=g,k.Replaceable=h,i}},{"./BasicTypes.coffee":5}],8:[function(a,b){var c,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};c=a("./StructuredTypes.coffee"),b.exports=function(a){var b,d,f,g,h,i;return h=c(a),i=h.types,g=h.parser,b=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return e(b,a),b}(i.Delete),g.TextDelete=g.Delete,d=function(a){function b(a,c,d,e,f){if(this.content=a,null==d||null==e)throw new Error("You must define prev, and next for TextInsert-types!");b.__super__.constructor.call(this,c,d,e,f)}return e(b,a),b.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},b.prototype.val=function(){return this.isDeleted()?"":this.content},b.prototype._encode=function(){var a;return a={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},b}(i.Insert),g.TextInsert=function(a){var b,c,e,f,g;return b=a.content,g=a.uid,f=a.prev,c=a.next,e=a.origin,new d(b,g,f,c,e)},f=function(c){function f(a,b,c,d,e,g,h){f.__super__.constructor.call(this,a,c,d,e,g,h),null!=b&&this.insertText(0,b)}return e(f,c),f.prototype.insertText=function(b,c){var e,f,g,h,i,j;for(f=this.getOperationByPosition(b),j=[],h=0,i=c.length;i>h;h++)e=c[h],g=new d(e,a.getNextOperationIdentifier(),f.prev_cl,f),j.push(a.addOperation(g).execute());return j},f.prototype.deleteText=function(c,d){var e,f,g,h,j;for(g=this.getOperationByPosition(c),j=[],f=h=0;d>=0?d>h:h>d;f=d>=0?++h:--h){for(e=a.addOperation(new b(a.getNextOperationIdentifier(),g)).execute(),g=g.next_cl;g.isDeleted();){if(g instanceof i.Delimiter)throw new Error("You can't delete more than there is..");g=g.next_cl}j.push(e._encode())}return j},f.prototype.replaceText=function(b){var c;if(null!=this.replace_manager)return c=a.addOperation(new f(a.getNextOperationIdentifier())).execute(),c.insertText(0,b),this.replace_manager.replace(c);throw new Error("This type is currently not maintained by a ReplaceManager!")},f.prototype.val=function(){var a,b;return a=function(){var a,c,d,e;for(d=this.toArray(),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(null!=b.val?b.val():"");return e}.call(this),a.join("")},f.prototype.setReplaceManager=function(a){return this.saveOperation("replace_manager",a),this.validateSavedOperations},f.prototype._encode=function(){var a;return a={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(a.prev=this.prev_cl.getUid()),null!=this.next_cl&&(a.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(a.origin=this.origin.getUid()),a},f}(i.ListManager),g.Word=function(a){var b,c,d,e,g,h;return h=a.uid,b=a.beginning,c=a.end,g=a.prev,d=a.next,e=a.origin,new f(h,void 0,b,c,g,d,e)},i.TextInsert=d,i.TextDelete=b,i.Word=f,h}},{"./StructuredTypes.coffee":7}]},{},[3,1]);