text: !function(){angular.bind({},function(){(function(){!function(a){"use strict";try{(function(){}).bind(a)}catch(b){Object.defineProperty(Function.prototype,"bind",{value:function(a){var b=this;return function(){return b.apply(a,arguments)}},enumerable:!1,configurable:!0,writable:!0})}var c=void 0!==a.HTMLElement,d=function(a){for(var b=null;a&&a!=Object.prototype;){if(a.tagName){b=a.tagName;break}a=a.prototype}return b||"div"},e=1e-8,f={},g=function(a,b){if(a&&b){if("function"==typeof a[b])return a[b];var c=a.prototype;if(c&&"function"==typeof c[b])return c[b];if(c!==Object.prototype&&c!==Function.prototype)return"function"==typeof a.__super__?g(a.__super__,b):void 0}},h=a.c={debug:!1,trace:!1,verbose:!1,traceAdded:!1,GC:!1,GEQ:1,LEQ:2,inherit:function(b){var e=null,g=null;b["extends"]&&(g=b["extends"],delete b["extends"]),b.initialize&&(e=b.initialize,delete b.initialize);var h=e||function(){};Object.defineProperty(h,"__super__",{value:g?g:Object,enumerable:!1,configurable:!0,writable:!1}),b._t&&(f[b._t]=h);var i=h.prototype=Object.create(g?g.prototype:Object.prototype);if(this.extend(i,b),c&&g&&g.prototype instanceof a.HTMLElement){var j=h,k=d(i),l=function(a){return a.__proto__=i,j.apply(a,arguments),i.created&&a.created(),i.decorate&&a.decorate(),a};this.extend(i,{upgrade:l}),h=function(){return l(a.document.createElement(k))},h.prototype=i,this.extend(h,{ctor:j})}return h},extend:function(a,b){return this.own(b,function(c){var d=Object.getOwnPropertyDescriptor(b,c);try{"function"==typeof d.get||"function"==typeof d.set?Object.defineProperty(a,c,d):"function"==typeof d.value||"_"===c.charAt(0)?(d.writable=!0,d.configurable=!0,d.enumerable=!1,Object.defineProperty(a,c,d)):a[c]=b[c]}catch(e){}}),a},own:function(b,c,d){return Object.getOwnPropertyNames(b).forEach(c,d||a),b},traceprint:function(a){h.verbose&&console.log(a)},fnenterprint:function(a){console.log("* "+a)},fnexitprint:function(a){console.log("- "+a)},assert:function(a,b){if(!a)throw new h.InternalError("Assertion failed: "+b)},plus:function(a,b){return a instanceof h.Expression||(a=new h.Expression(a)),b instanceof h.Expression||(b=new h.Expression(b)),a.plus(b)},minus:function(a,b){return a instanceof h.Expression||(a=new h.Expression(a)),b instanceof h.Expression||(b=new h.Expression(b)),a.minus(b)},times:function(a,b){return("number"==typeof a||a instanceof h.Variable)&&(a=new h.Expression(a)),("number"==typeof b||b instanceof h.Variable)&&(b=new h.Expression(b)),a.times(b)},divide:function(a,b){return("number"==typeof a||a instanceof h.Variable)&&(a=new h.Expression(a)),("number"==typeof b||b instanceof h.Variable)&&(b=new h.Expression(b)),a.divide(b)},approx:function(a,b){if(a===b)return!0;var c,d;return c=a instanceof h.Variable?a.value:a,d=b instanceof h.Variable?b.value:b,0==c?e>Math.abs(d):0==d?e>Math.abs(c):Math.abs(c-d)<Math.abs(c)*e},_inc:function(a){return function(){return a++}}(0),parseJSON:function(a){return JSON.parse(a,function(a,b){if("object"!=typeof b||"string"!=typeof b._t)return b;var c=b._t,d=f[c];if(c&&d){var e=g(d,"fromJSON");if(e)return e(b,d)}return b})}};"function"==typeof require&&"undefined"!=typeof module&&"undefined"==typeof load&&(a.exports=h)}(this),function(a){"use strict";var b=function(a){var b=a.hashCode?a.hashCode:""+a;return b},c=function(a,b){Object.keys(a).forEach(function(c){b[c]=a[c]})},d={};a.HashTable=a.inherit({initialize:function(){this.size=0,this._store={},this._keyStrMap={},this._deleted=0},set:function(a,c){var d=b(a);this._store.hasOwnProperty(d)||this.size++,this._store[d]=c,this._keyStrMap[d]=a},get:function(a){if(!this.size)return null;a=b(a);var c=this._store[a];return void 0!==c?this._store[a]:null},clear:function(){this.size=0,this._store={},this._keyStrMap={}},_compact:function(){var a={};c(this._store,a),this._store=a},_compactThreshold:100,_perhapsCompact:function(){this._size>64||this._deleted>this._compactThreshold&&(this._compact(),this._deleted=0)},"delete":function(a){a=b(a),this._store.hasOwnProperty(a)&&(this._deleted++,delete this._store[a],this.size>0&&this.size--)},each:function(a,b){if(this.size){this._perhapsCompact();var c=this._store,d=this._keyStrMap;Object.keys(this._store).forEach(function(e){a.call(b||null,d[e],c[e])},this)}},escapingEach:function(a,b){if(this.size){this._perhapsCompact();for(var c=this,e=this._store,f=this._keyStrMap,g=d,h=Object.keys(e),i=0;h.length>i;i++)if(function(d){c._store.hasOwnProperty(d)&&(g=a.call(b||null,f[d],e[d]))}(h[i]),g){if(void 0!==g.retval)return g;if(g.brk)break}}},clone:function(){var b=new a.HashTable;return this.size&&(b.size=this.size,c(this._store,b._store),c(this._keyStrMap,b._keyStrMap)),b},equals:function(b){if(b===this)return!0;if(!(b instanceof a.HashTable)||b._size!==this._size)return!1;for(var c=Object.keys(this._store),d=0;c.length>d;d++){var e=c[d];if(this._keyStrMap[e]!==b._keyStrMap[e]||this._store[e]!==b._store[e])return!1}return!0},toString:function(){var a="";return this.each(function(b,c){a+=b+" => "+c+"\n"}),a}})}(this.c||module.parent.exports||{}),function(a){"use strict";a.HashSet=a.inherit({_t:"c.HashSet",initialize:function(){this.storage=[],this.size=0},add:function(a){var b=this.storage;b.indexOf(a),-1==b.indexOf(a)&&b.push(a),this.size=this.storage.length},values:function(){return this.storage},has:function(a){var b=this.storage;return-1!=b.indexOf(a)},"delete":function(a){var b=this.storage.indexOf(a);return-1==b?null:(this.storage.splice(b,1)[0],void(this.size=this.storage.length))},clear:function(){this.storage.length=0},each:function(a,b){this.size&&this.storage.forEach(a,b)},escapingEach:function(a,b){this.size&&this.storage.forEach(a,b)},toString:function(){var a=this.size+" {",b=!0;return this.each(function(c){b?b=!1:a+=", ",a+=c}),a+="}\n"},toJSON:function(){var a=[];return this.each(function(b){a.push(b.toJSON())}),{_t:"c.HashSet",data:a}},fromJSON:function(b){var c=new a.HashSet;return b.data&&(c.size=b.data.length,c.storage=b.data),c}})}(this.c||module.parent.exports||{}),function(a){"use strict";a.Error=a.inherit({initialize:function(a){a&&(this._description=a)},_name:"c.Error",_description:"An error has occured in Cassowary",set description(a){this._description=a},get description(){return"("+this._name+") "+this._description},get message(){return this.description},toString:function(){return this.description}});var b=function(b,c){return a.inherit({"extends":a.Error,initialize:function(){a.Error.apply(this,arguments)},_name:b||"",_description:c||""})};a.ConstraintNotFound=b("c.ConstraintNotFound","Tried to remove a constraint never added to the tableu"),a.InternalError=b("c.InternalError"),a.NonExpression=b("c.NonExpression","The resulting expression would be non"),a.NotEnoughStays=b("c.NotEnoughStays","There are not enough stays to give specific values to every variable"),a.RequiredFailure=b("c.RequiredFailure","A required constraint cannot be satisfied"),a.TooDifficult=b("c.TooDifficult","The constraints are too difficult to solve")}(this.c||module.parent.exports||{}),function(a){"use strict";var b=1e3;a.SymbolicWeight=a.inherit({_t:"c.SymbolicWeight",initialize:function(){this.value=0;for(var a=1,c=arguments.length-1;c>=0;--c)this.value+=arguments[c]*a,a*=b},toJSON:function(){return{_t:this._t,value:this.value}}})}(this.c||module.parent.exports||{}),function(a){a.Strength=a.inherit({initialize:function(b,c,d,e){this.name=b,this.symbolicWeight=c instanceof a.SymbolicWeight?c:new a.SymbolicWeight(c,d,e)},get required(){return this===a.Strength.required},toString:function(){return this.name+(this.isRequired?"":":"+this.symbolicWeight)}}),a.Strength.required=new a.Strength("<Required>",1e3,1e3,1e3),a.Strength.strong=new a.Strength("strong",1,0,0),a.Strength.medium=new a.Strength("medium",0,1,0),a.Strength.weak=new a.Strength("weak",0,0,1)}(this.c||("undefined"!=typeof module?module.parent.exports.c:{})),function(a){"use strict";a.AbstractVariable=a.inherit({isDummy:!1,isExternal:!1,isPivotable:!1,isRestricted:!1,_init:function(b,c){this.hashCode=a._inc(),this.name=(c||"")+this.hashCode,b&&(void 0!==b.name&&(this.name=b.name),void 0!==b.value&&(this.value=b.value),void 0!==b.prefix&&(this._prefix=b.prefix))},_prefix:"",name:"",value:0,toJSON:function(){var a={};return this._t&&(a._t=this._t),this.name&&(a.name=this.name),void 0!==this.value&&(a.value=this.value),this._prefix&&(a._prefix=this._prefix),this._t&&(a._t=this._t),a},fromJSON:function(b,c){var d=new c;return a.extend(d,b),d},toString:function(){return this._prefix+"["+this.name+":"+this.value+"]"}}),a.Variable=a.inherit({_t:"c.Variable","extends":a.AbstractVariable,initialize:function(b){this._init(b,"v");var c=a.Variable._map;c&&(c[this.name]=this)},isExternal:!0}),a.DummyVariable=a.inherit({_t:"c.DummyVariable","extends":a.AbstractVariable,initialize:function(a){this._init(a,"d")},isDummy:!0,isRestricted:!0,value:"dummy"}),a.ObjectiveVariable=a.inherit({_t:"c.ObjectiveVariable","extends":a.AbstractVariable,initialize:function(a){this._init(a,"o")},value:"obj"}),a.SlackVariable=a.inherit({_t:"c.SlackVariable","extends":a.AbstractVariable,initialize:function(a){this._init(a,"s")},isPivotable:!0,isRestricted:!0,value:"slack"})}(this.c||module.parent.exports||{}),function(a){"use strict";a.Point=a.inherit({initialize:function(b,c,d){if(b instanceof a.Variable)this._x=b;else{var e={value:b};d&&(e.name="x"+d),this._x=new a.Variable(e)}if(c instanceof a.Variable)this._y=c;else{var f={value:c};d&&(f.name="y"+d),this._y=new a.Variable(f)}},get x(){return this._x},set x(b){b instanceof a.Variable?this._x=b:this._x.value=b},get y(){return this._y},set y(b){b instanceof a.Variable?this._y=b:this._y.value=b},toString:function(){return"("+this.x+", "+this.y+")"}})}(this.c||module.parent.exports||{}),function(a){"use strict";a.Expression=a.inherit({initialize:function(b,c,d){a.GC&&console.log("new c.Expression"),this.constant="number"!=typeof d||isNaN(d)?0:d,this.terms=new a.HashTable,b instanceof a.AbstractVariable?this.setVariable(b,"number"==typeof c?c:1):"number"==typeof b&&(isNaN(b)?console.trace():this.constant=b)},initializeFromHash:function(b,c){return a.verbose&&(console.log("*******************************"),console.log("clone c.initializeFromHash"),console.log("*******************************")),a.GC&&console.log("clone c.Expression"),this.constant=b,this.terms=c.clone(),this},multiplyMe:function(a){this.constant*=a;var b=this.terms;return b.each(function(c,d){b.set(c,d*a)}),this},clone:function(){a.verbose&&(console.log("*******************************"),console.log("clone c.Expression"),console.log("*******************************"));var b=new a.Expression;return b.initializeFromHash(this.constant,this.terms),b},times:function(b){if("number"==typeof b)return this.clone().multiplyMe(b);if(this.isConstant)return b.times(this.constant);if(b.isConstant)return this.times(b.constant);throw new a.NonExpression},plus:function(b){return b instanceof a.Expression?this.clone().addExpression(b,1):b instanceof a.Variable?this.clone().addVariable(b,1):void 0},minus:function(b){return b instanceof a.Expression?this.clone().addExpression(b,-1):b instanceof a.Variable?this.clone().addVariable(b,-1):void 0},divide:function(b){if("number"==typeof b){if(a.approx(b,0))throw new a.NonExpression;return this.times(1/b)}if(b instanceof a.Expression){if(!b.isConstant)throw new a.NonExpression;return this.times(1/b.constant)}},addExpression:function(b,c,d,e){return b instanceof a.AbstractVariable&&(b=new a.Expression(b),a.trace&&console.log("addExpression: Had to cast a var to an expression")),c=c||1,this.constant+=c*b.constant,b.terms.each(function(a,b){this.addVariable(a,b*c,d,e)},this),this},addVariable:function(b,c,d,e){null==c&&(c=1),a.trace&&console.log("c.Expression::addVariable():",b,c);var f=this.terms.get(b);if(f){var g=f+c;0==g||a.approx(g,0)?(e&&e.noteRemovedVariable(b,d),this.terms.delete(b)):this.setVariable(b,g)}else a.approx(c,0)||(this.setVariable(b,c),e&&e.noteAddedVariable(b,d));return this},setVariable:function(a,b){return this.terms.set(a,b),this},anyPivotableVariable:function(){if(this.isConstant)throw new a.InternalError("anyPivotableVariable called on a constant");var b=this.terms.escapingEach(function(a){return a.isPivotable?{retval:a}:void 0});return b&&void 0!==b.retval?b.retval:null},substituteOut:function(b,c,d,e){a.trace&&(a.fnenterprint("CLE:substituteOut: "+b+", "+c+", "+d+", ..."),a.traceprint("this = "+this));var f=this.setVariable.bind(this),g=this.terms,h=g.get(b);g.delete(b),this.constant+=h*c.constant,c.terms.each(function(b,c){var i=g.get(b);if(i){var j=i+h*c;a.approx(j,0)?(e.noteRemovedVariable(b,d),g.delete(b)):f(b,j)}else f(b,h*c),e&&e.noteAddedVariable(b,d)}),a.trace&&a.traceprint("Now this is "+this)},changeSubject:function(a,b){this.setVariable(a,this.newSubject(b))},newSubject:function(b){a.trace&&a.fnenterprint("newSubject:"+b);var c=1/this.terms.get(b);return this.terms.delete(b),this.multiplyMe(-c),c},coefficientFor:function(a){return this.terms.get(a)||0},get isConstant(){return 0==this.terms.size},toString:function(){var b="",c=!1;if(!a.approx(this.constant,0)||this.isConstant){if(b+=this.constant,this.isConstant)return b;c=!0}return this.terms.each(function(a,d){c&&(b+=" + "),b+=d+"*"+a,c=!0}),b},equals:function(b){return b===this?!0:b instanceof a.Expression&&b.constant===this.constant&&b.terms.equals(this.terms)},Plus:function(a,b){return a.plus(b)},Minus:function(a,b){return a.minus(b)},Times:function(a,b){return a.times(b)},Divide:function(a,b){return a.divide(b)}})}(this.c||module.parent.exports||{}),function(a){"use strict";a.AbstractConstraint=a.inherit({initialize:function(b,c){this.hashCode=a._inc(),this.strength=b||a.Strength.required,this.weight=c||1},isEditConstraint:!1,isInequality:!1,isStayConstraint:!1,get required(){return this.strength===a.Strength.required},toString:function(){return this.strength+" {"+this.weight+"} ("+this.expression+")"}});var b=a.AbstractConstraint.prototype.toString,c=function(b,c,d){a.AbstractConstraint.call(this,c||a.Strength.strong,d),this.variable=b,this.expression=new a.Expression(b,-1,b.value)};a.EditConstraint=a.inherit({"extends":a.AbstractConstraint,initialize:function(){c.apply(this,arguments)},isEditConstraint:!0,toString:function(){return"edit:"+b.call(this)}}),a.StayConstraint=a.inherit({"extends":a.AbstractConstraint,initialize:function(){c.apply(this,arguments)},isStayConstraint:!0,toString:function(){return"stay:"+b.call(this)}});var d=a.Constraint=a.inherit({"extends":a.AbstractConstraint,initialize:function(b,c,d){a.AbstractConstraint.call(this,c,d),this.expression=b}});a.Inequality=a.inherit({"extends":a.Constraint,_cloneOrNewCle:function(b){return b.clone?b.clone():new a.Expression(b)},initialize:function(b,c,e,f,g){var h=b instanceof a.Expression,i=e instanceof a.Expression,j=b instanceof a.AbstractVariable,k=e instanceof a.AbstractVariable,l="number"==typeof b,m="number"==typeof e;if((h||l)&&k){var n=b,o=c,p=e,q=f,r=g;if(d.call(this,this._cloneOrNewCle(n),q,r),o==a.LEQ)this.expression.multiplyMe(-1),this.expression.addVariable(p);else{if(o!=a.GEQ)throw new a.InternalError("Invalid operator in c.Inequality constructor");this.expression.addVariable(p,-1)}}else if(j&&(i||m)){var n=e,o=c,p=b,q=f,r=g;if(d.call(this,this._cloneOrNewCle(n),q,r),o==a.GEQ)this.expression.multiplyMe(-1),this.expression.addVariable(p);else{if(o!=a.LEQ)throw new a.InternalError("Invalid operator in c.Inequality constructor");this.expression.addVariable(p,-1)}}else{if(h&&m){var s=b,o=c,t=e,q=f,r=g;if(d.call(this,this._cloneOrNewCle(s),q,r),o==a.LEQ)this.expression.multiplyMe(-1),this.expression.addExpression(this._cloneOrNewCle(t));else{if(o!=a.GEQ)throw new a.InternalError("Invalid operator in c.Inequality constructor");this.expression.addExpression(this._cloneOrNewCle(t),-1)}return this}if(l&&i){var s=e,o=c,t=b,q=f,r=g;if(d.call(this,this._cloneOrNewCle(s),q,r),o==a.GEQ)this.expression.multiplyMe(-1),this.expression.addExpression(this._cloneOrNewCle(t));else{if(o!=a.LEQ)throw new a.InternalError("Invalid operator in c.Inequality constructor");this.expression.addExpression(this._cloneOrNewCle(t),-1)}return this}if(h&&i){var s=b,o=c,t=e,q=f,r=g;if(d.call(this,this._cloneOrNewCle(t),q,r),o==a.GEQ)this.expression.multiplyMe(-1),this.expression.addExpression(this._cloneOrNewCle(s));else{if(o!=a.LEQ)throw new a.InternalError("Invalid operator in c.Inequality constructor");this.expression.addExpression(this._cloneOrNewCle(s),-1)}}else{if(h)return d.call(this,b,c,e);if(c==a.GEQ)d.call(this,new a.Expression(e),f,g),this.expression.multiplyMe(-1),this.expression.addVariable(b);else{if(c!=a.LEQ)throw new a.InternalError("Invalid operator in c.Inequality constructor");d.call(this,new a.Expression(e),f,g),this.expression.addVariable(b,-1)}}}},isInequality:!0,toString:function(){return d.prototype.toString.call(this)+" >= 0) id: "+this.hashCode}}),a.Equation=a.inherit({"extends":a.Constraint,initialize:function(b,c,e,f){if(b instanceof a.Expression&&!c||c instanceof a.Strength)d.call(this,b,c,e);else if(b instanceof a.AbstractVariable&&c instanceof a.Expression){var g=b,h=c,i=e,j=f;d.call(this,h.clone(),i,j),this.expression.addVariable(g,-1)}else if(b instanceof a.AbstractVariable&&"number"==typeof c){var g=b,k=c,i=e,j=f;d.call(this,new a.Expression(k),i,j),this.expression.addVariable(g,-1)}else if(b instanceof a.Expression&&c instanceof a.AbstractVariable){var h=b,g=c,i=e,j=f;d.call(this,h.clone(),i,j),this.expression.addVariable(g,-1)}else{if(!(b instanceof a.Expression||b instanceof a.AbstractVariable||"number"==typeof b)||!(c instanceof a.Expression||c instanceof a.AbstractVariable||"number"==typeof c))throw"Bad initializer to c.Equation";b=b instanceof a.Expression?b.clone():new a.Expression(b),c=c instanceof a.Expression?c.clone():new a.Expression(c),d.call(this,b,e,f),this.expression.addExpression(c,-1)}a.assert(this.strength instanceof a.Strength,"_strength not set")},toString:function(){return d.prototype.toString.call(this)+" = 0)"}})}(this.c||module.parent.exports||{}),function(a){"use strict";a.EditInfo=a.inherit({initialize:function(a,b,c,d,e){this.constraint=a,this.editPlus=b,this.editMinus=c,this.prevEditConstant=d,this.index=e},toString:function(){return"<cn="+this.constraint+", ep="+this.editPlus+", em="+this.editMinus+", pec="+this.prevEditConstant+", index="+this.index+">"}})}(this.c||module.parent.exports||{}),function(a){"use strict";a.Tableau=a.inherit({initialize:function(){this.columns=new a.HashTable,this.rows=new a.HashTable,this._infeasibleRows=new a.HashSet,this._externalRows=new a.HashSet,this._externalParametricVars=new a.HashSet},noteRemovedVariable:function(b,c){a.trace&&console.log("c.Tableau::noteRemovedVariable: ",b,c);var d=this.columns.get(b);c&&d&&d.delete(c)},noteAddedVariable:function(a,b){b&&this.insertColVar(a,b)},getInternalInfo:function(){var a="Tableau Information:\n";return a+="Rows: "+this.rows.size,a+=" (= "+(this.rows.size-1)+" constraints)",a+="\nColumns: "+this.columns.size,a+="\nInfeasible Rows: "+this._infeasibleRows.size,a+="\nExternal basic variables: "+this._externalRows.size,a+="\nExternal parametric variables: ",a+=this._externalParametricVars.size,a+="\n"},toString:function(){var a="Tableau:\n";return this.rows.each(function(b,c){a+=b,a+=" <==> ",a+=c,a+="\n"}),a+="\nColumns:\n",a+=this.columns,a+="\nInfeasible rows: ",a+=this._infeasibleRows,a+="External basic variables: ",a+=this._externalRows,a+="External parametric variables: ",a+=this._externalParametricVars},insertColVar:function(b,c){var d=this.columns.get(b);d||(d=new a.HashSet,this.columns.set(b,d)),d.add(c)},addRow:function(b,c){a.trace&&a.fnenterprint("addRow: "+b+", "+c),this.rows.set(b,c),c.terms.each(function(a){this.insertColVar(a,b),a.isExternal&&this._externalParametricVars.add(a)},this),b.isExternal&&this._externalRows.add(b),a.trace&&a.traceprint(""+this)},removeColumn:function(b){a.trace&&a.fnenterprint("removeColumn:"+b);var c=this.columns.get(b);c?(this.columns.delete(b),c.each(function(a){var c=this.rows.get(a);c.terms.delete(b)},this)):a.trace&&console.log("Could not find var",b,"in columns"),b.isExternal&&(this._externalRows.delete(b),this._externalParametricVars.delete(b))},removeRow:function(b){a.trace&&a.fnenterprint("removeRow:"+b);var c=this.rows.get(b);return a.assert(null!=c),c.terms.each(function(c){var d=this.columns.get(c);null!=d&&(a.trace&&console.log("removing from varset:",b),d.delete(b))},this),this._infeasibleRows.delete(b),b.isExternal&&this._externalRows.delete(b),this.rows.delete(b),a.trace&&a.fnexitprint("returning "+c),c},substituteOut:function(b,c){a.trace&&a.fnenterprint("substituteOut:"+b+", "+c),a.trace&&a.traceprint(""+this);var d=this.columns.get(b);d.each(function(a){var d=this.rows.get(a);d.substituteOut(b,c,a,this),a.isRestricted&&0>d.constant&&this._infeasibleRows.add(a)},this),b.isExternal&&(this._externalRows.add(b),this._externalParametricVars.delete(b)),this.columns.delete(b)},columnsHasKey:function(a){return!!this.columns.get(a)}})}(this.c||module.parent.exports||{}),function(a){var b=a.Tableau,c=b.prototype,d=1e-8,e=a.Strength.weak;a.SimplexSolver=a.inherit({"extends":a.Tableau,initialize:function(){a.Tableau.call(this),this._stayMinusErrorVars=[],this._stayPlusErrorVars=[],this._errorVars=new a.HashTable,this._markerVars=new a.HashTable,this._objective=new a.ObjectiveVariable({name:"Z"}),this._editVarMap=new a.HashTable,this._editVarList=[],this._slackCounter=0,this._artificialCounter=0,this._dummyCounter=0,this.autoSolve=!0,this._fNeedsSolving=!1,this._optimizeCount=0,this.rows.set(this._objective,new a.Expression),this._stkCedcns=[0],a.trace&&a.traceprint("objective expr == "+this.rows.get(this._objective))},addLowerBound:function(b,c){var d=new a.Inequality(b,a.GEQ,new a.Expression(c));return this.addConstraint(d)},addUpperBound:function(b,c){var d=new a.Inequality(b,a.LEQ,new a.Expression(c));return this.addConstraint(d)},addBounds:function(a,b,c){return this.addLowerBound(a,b),this.addUpperBound(a,c),this},add:function(){for(var a=0;arguments.length>a;a++)this.addConstraint(arguments[a]);return this},addConstraint:function(b){a.trace&&a.fnenterprint("addConstraint: "+b);var c=Array(2),d=Array(1),e=this.newExpression(b,c,d);if(d=d[0],this.tryAddingDirectly(e)||this.addWithArtificialVariable(e),this._fNeedsSolving=!0,b.isEditConstraint){var f=this._editVarMap.size,g=c[0],h=c[1];!g instanceof a.SlackVariable&&console.warn("cvEplus not a slack variable =",g),!h instanceof a.SlackVariable&&console.warn("cvEminus not a slack variable =",h),a.debug&&console.log("new c.EditInfo("+b+", "+g+", "+h+", "+d+", "+f+")");var i=new a.EditInfo(b,g,h,d,f);this._editVarMap.set(b.variable,i),this._editVarList[f]={v:b.variable,info:i}}return this.autoSolve&&(this.optimize(this._objective),this._setExternalVariables()),this},addConstraintNoException:function(b){a.trace&&a.fnenterprint("addConstraintNoException: "+b);try{return this.addConstraint(b),!0}catch(c){return!1}},addEditVar:function(b,c){return a.trace&&a.fnenterprint("addEditVar: "+b+" @ "+c),this.addConstraint(new a.EditConstraint(b,c||a.Strength.strong))},beginEdit:function(){return a.assert(this._editVarMap.size>0,"_editVarMap.size > 0"),this._infeasibleRows.clear(),this._resetStayConstants(),this._stkCedcns.push(this._editVarMap.size),this},endEdit:function(){return a.assert(this._editVarMap.size>0,"_editVarMap.size > 0"),this.resolve(),this._stkCedcns.pop(),this.removeEditVarsTo(this._stkCedcns[this._stkCedcns.length-1]),this},removeAllEditVars:function(){return this.removeEditVarsTo(0)},removeEditVarsTo:function(b){try{for(var c=this._editVarList.length,d=b;c>d;d++)this._editVarList[d]&&this.removeConstraint(this._editVarMap.get(this._editVarList[d].v).constraint);return this._editVarList.length=b,a.assert(this._editVarMap.size==b,"_editVarMap.size == n"),this}catch(e){throw new a.InternalError("Constraint not found in removeEditVarsTo")}},addPointStays:function(b){return a.trace&&console.log("addPointStays",b),b.forEach(function(a,b){this.addStay(a.x,e,Math.pow(2,b)),this.addStay(a.y,e,Math.pow(2,b))},this),this},addStay:function(b,c,d){var f=new a.StayConstraint(b,c||e,d||1);return this.addConstraint(f)},removeConstraint:function(a){return this.removeConstraintInternal(a),this},removeConstraintInternal:function(b){a.trace&&a.fnenterprint("removeConstraintInternal: "+b),a.trace&&a.traceprint(""+this),this._fNeedsSolving=!0,this._resetStayConstants();var c=this.rows.get(this._objective),d=this._errorVars.get(b);a.trace&&a.traceprint("eVars == "+d),null!=d&&d.each(function(e){var f=this.rows.get(e);null==f?c.addVariable(e,-b.weight*b.strength.symbolicWeight.value,this._objective,this):c.addExpression(f,-b.weight*b.strength.symbolicWeight.value,this._objective,this),a.trace&&a.traceprint("now eVars == "+d)},this);var e=this._markerVars.get(b);if(this._markerVars.delete(b),null==e)throw new a.InternalError("Constraint not found in removeConstraintInternal");if(a.trace&&a.traceprint("Looking to remove var "+e),null==this.rows.get(e)){var f=this.columns.get(e);a.trace&&a.traceprint("Must pivot -- columns are "+f);var g=null,h=0;f.each(function(b){if(b.isRestricted){var c=this.rows.get(b),d=c.coefficientFor(e);if(a.trace&&a.traceprint("Marker "+e+"'s coefficient in "+c+" is "+d),0>d){var f=-c.constant/d;(null==g||h>f||a.approx(f,h)&&b.hashCode<g.hashCode)&&(h=f,g=b)}}},this),null==g&&(a.trace&&a.traceprint("exitVar is still null"),f.each(function(a){if(a.isRestricted){var b=this.rows.get(a),c=b.coefficientFor(e),d=b.constant/c;(null==g||h>d)&&(h=d,g=a)}},this)),null==g&&(0==f.size?this.removeColumn(e):f.escapingEach(function(a){return a!=this._objective?(g=a,{brk:!0}):void 0},this)),null!=g&&this.pivot(e,g)}if(null!=this.rows.get(e)&&this.removeRow(e),null!=d&&d.each(function(a){a!=e&&this.removeColumn(a)},this),b.isStayConstraint){if(null!=d)for(var i=0;this._stayPlusErrorVars.length>i;i++)d.delete(this._stayPlusErrorVars[i]),d.delete(this._stayMinusErrorVars[i])}else if(b.isEditConstraint){a.assert(null!=d,"eVars != null");var j=this._editVarMap.get(b.variable);this.removeColumn(j.editMinus),this._editVarMap.delete(b.variable)}return null!=d&&this._errorVars.delete(d),this.autoSolve&&(this.optimize(this._objective),this._setExternalVariables()),this},reset:function(){throw a.trace&&a.fnenterprint("reset"),new a.InternalError("reset not implemented")},resolveArray:function(b){a.trace&&a.fnenterprint("resolveArray"+b);var c=b.length;this._editVarMap.each(function(a,d){var e=d.index;c>e&&this.suggestValue(a,b[e])},this),this.resolve()},resolvePair:function(a,b){this.suggestValue(this._editVarList[0].v,a),this.suggestValue(this._editVarList[1].v,b),this.resolve()},resolve:function(){a.trace&&a.fnenterprint("resolve()"),this.dualOptimize(),this._setExternalVariables(),this._infeasibleRows.clear(),this._resetStayConstants()},suggestValue:function(b,c){a.trace&&console.log("suggestValue("+b+", "+c+")");var d=this._editVarMap.get(b);if(!d)throw new a.Error("suggestValue for variable "+b+", but var is not an edit variable");var e=c-d.prevEditConstant;return d.prevEditConstant=c,this.deltaEditConstant(e,d.editPlus,d.editMinus),this},solve:function(){return this._fNeedsSolving&&(this.optimize(this._objective),this._setExternalVariables()),this},setEditedValue:function(b,c){if(!this.columnsHasKey(b)&&null==this.rows.get(b))return b.value=c,this;if(!a.approx(c,b.value)){this.addEditVar(b),this.beginEdit();try{this.suggestValue(b,c)}catch(d){throw new a.InternalError("Error in setEditedValue")}this.endEdit()}return this},addVar:function(b){if(!this.columnsHasKey(b)&&null==this.rows.get(b)){try{this.addStay(b)}catch(c){throw new a.InternalError("Error in addVar -- required failure is impossible")}a.trace&&a.traceprint("added initial stay on "+b)}return this},getInternalInfo:function(){var a=c.getInternalInfo.call(this);return a+="\nSolver info:\n",a+="Stay Error Variables: ",a+=this._stayPlusErrorVars.length+this._stayMinusErrorVars.length,a+=" ("+this._stayPlusErrorVars.length+" +, ",a+=this._stayMinusErrorVars.length+" -)\n",a+="Edit Variables: "+this._editVarMap.size,a+="\n"},getDebugInfo:function(){return""+this+this.getInternalInfo()+"\n"},toString:function(){var a=c.getInternalInfo.call(this);return a+="\n_stayPlusErrorVars: ",a+="["+this._stayPlusErrorVars+"]",a+="\n_stayMinusErrorVars: ",a+="["+this._stayMinusErrorVars+"]",a+="\n",a+="_editVarMap:\n"+this._editVarMap,a+="\n"},getConstraintMap:function(){return this._markerVars},addWithArtificialVariable:function(b){a.trace&&a.fnenterprint("addWithArtificialVariable: "+b);var c=new a.SlackVariable({value:++this._artificialCounter,prefix:"a"}),d=new a.ObjectiveVariable({name:"az"}),e=b.clone();a.trace&&a.traceprint("before addRows:\n"+this),this.addRow(d,e),this.addRow(c,b),a.trace&&a.traceprint("after addRows:\n"+this),this.optimize(d);var f=this.rows.get(d);if(a.trace&&a.traceprint("azTableauRow.constant == "+f.constant),!a.approx(f.constant,0))throw this.removeRow(d),this.removeColumn(c),new a.RequiredFailure;var g=this.rows.get(c);if(null!=g){if(g.isConstant)return this.removeRow(c),void this.removeRow(d);var h=g.anyPivotableVariable();this.pivot(h,c)}a.assert(null==this.rows.get(c),"rowExpression(av) == null"),this.removeColumn(c),this.removeRow(d)},tryAddingDirectly:function(b){a.trace&&a.fnenterprint("tryAddingDirectly: "+b);var c=this.chooseSubject(b);return null==c?(a.trace&&a.fnexitprint("returning false"),!1):(b.newSubject(c),this.columnsHasKey(c)&&this.substituteOut(c,b),this.addRow(c,b),a.trace&&a.fnexitprint("returning true"),!0)},chooseSubject:function(b){a.trace&&a.fnenterprint("chooseSubject: "+b);var c=null,d=!1,e=!1,f=b.terms,g=f.escapingEach(function(a,b){if(d){if(!a.isRestricted&&!this.columnsHasKey(a))return{retval:a}}else if(a.isRestricted){if(!e&&!a.isDummy&&0>b){var f=this.columns.get(a);(null==f||1==f.size&&this.columnsHasKey(this._objective))&&(c=a,e=!0)}}else c=a,d=!0},this);if(g&&void 0!==g.retval)return g.retval;if(null!=c)return c;var h=0,g=f.escapingEach(function(a,b){return a.isDummy?void(this.columnsHasKey(a)||(c=a,h=b)):{retval:null}},this);if(g&&void 0!==g.retval)return g.retval;if(!a.approx(b.constant,0))throw new a.RequiredFailure;return h>0&&b.multiplyMe(-1),c},deltaEditConstant:function(b,c,d){a.trace&&a.fnenterprint("deltaEditConstant :"+b+", "+c+", "+d);var e=this.rows.get(c);if(null!=e)return e.constant+=b,void(0>e.constant&&this._infeasibleRows.add(c));var f=this.rows.get(d);if(null!=f)return f.constant+=-b,void(0>f.constant&&this._infeasibleRows.add(d));var g=this.columns.get(d);g||console.log("columnVars is null -- tableau is:\n"+this),g.each(function(a){var c=this.rows.get(a),e=c.coefficientFor(d);c.constant+=e*b,a.isRestricted&&0>c.constant&&this._infeasibleRows.add(a)},this)},dualOptimize:function(){a.trace&&a.fnenterprint("dualOptimize:");for(var b=this.rows.get(this._objective);this._infeasibleRows.size;){var c=this._infeasibleRows.values()[0];this._infeasibleRows.delete(c);var d=null,e=this.rows.get(c);if(e&&0>e.constant){var f,g=Number.MAX_VALUE,h=e.terms;if(h.each(function(c,e){if(e>0&&c.isPivotable){var h=b.coefficientFor(c);f=h/e,(g>f||a.approx(f,g)&&c.hashCode<d.hashCode)&&(d=c,g=f)}}),g==Number.MAX_VALUE)throw new a.InternalError("ratio == nil (MAX_VALUE) in dualOptimize");this.pivot(d,c)}}},newExpression:function(b,c,d){a.trace&&(a.fnenterprint("newExpression: "+b),a.traceprint("cn.isInequality == "+b.isInequality),a.traceprint("cn.required == "+b.required));var e=b.expression,f=new a.Expression(e.constant),g=new a.SlackVariable,h=new a.DummyVariable,i=new a.SlackVariable,j=new a.SlackVariable,k=e.terms;if(k.each(function(a,b){var c=this.rows.get(a);c?f.addExpression(c,b):f.addVariable(a,b)},this),b.isInequality){if(a.trace&&a.traceprint("Inequality, adding slack"),++this._slackCounter,g=new a.SlackVariable({value:this._slackCounter,prefix:"s"}),f.setVariable(g,-1),this._markerVars.set(b,g),!b.required){++this._slackCounter,i=new a.SlackVariable({value:this._slackCounter,prefix:"em"}),f.setVariable(i,1);
  var l=this.rows.get(this._objective);l.setVariable(i,b.strength.symbolicWeight.value*b.weight),this.insertErrorVar(b,i),this.noteAddedVariable(i,this._objective)}}else if(b.required)a.trace&&a.traceprint("Equality, required"),++this._dummyCounter,h=new a.DummyVariable({value:this._dummyCounter,prefix:"d"}),f.setVariable(h,1),this._markerVars.set(b,h),a.trace&&a.traceprint("Adding dummyVar == d"+this._dummyCounter);else{a.trace&&a.traceprint("Equality, not required"),++this._slackCounter,j=new a.SlackVariable({value:this._slackCounter,prefix:"ep"}),i=new a.SlackVariable({value:this._slackCounter,prefix:"em"}),f.setVariable(j,-1),f.setVariable(i,1),this._markerVars.set(b,j);var l=this.rows.get(this._objective);a.trace&&console.log(l);var m=b.strength.symbolicWeight.value*b.weight;0==m&&(a.trace&&a.traceprint("cn == "+b),a.trace&&a.traceprint("adding "+j+" and "+i+" with swCoeff == "+m)),l.setVariable(j,m),this.noteAddedVariable(j,this._objective),l.setVariable(i,m),this.noteAddedVariable(i,this._objective),this.insertErrorVar(b,i),this.insertErrorVar(b,j),b.isStayConstraint?(this._stayPlusErrorVars.push(j),this._stayMinusErrorVars.push(i)):b.isEditConstraint&&(c[0]=j,c[1]=i,d[0]=e.constant)}return 0>f.constant&&f.multiplyMe(-1),a.trace&&a.fnexitprint("returning "+f),f},optimize:function(b){a.trace&&a.fnenterprint("optimize: "+b),a.trace&&a.traceprint(""+this),this._optimizeCount++;var c=this.rows.get(b);a.assert(null!=c,"zRow != null");for(var e,f,g=null,h=null;;){if(e=0,f=c.terms,f.escapingEach(function(a,b){return a.isPivotable&&e>b?(e=b,g=a,{brk:1}):void 0},this),e>=-d)return;a.trace&&console.log("entryVar:",g,"objectiveCoeff:",e);var i=Number.MAX_VALUE,j=this.columns.get(g),k=0;if(j.each(function(b){if(a.trace&&a.traceprint("Checking "+b),b.isPivotable){var c=this.rows.get(b),d=c.coefficientFor(g);a.trace&&a.traceprint("pivotable, coeff = "+d),0>d&&(k=-c.constant/d,(i>k||a.approx(k,i)&&b.hashCode<h.hashCode)&&(i=k,h=b))}},this),i==Number.MAX_VALUE)throw new a.InternalError("Objective function is unbounded in optimize");this.pivot(g,h),a.trace&&a.traceprint(""+this)}},pivot:function(b,c){a.trace&&console.log("pivot: ",b,c);var d=!1;d&&console.time(" SimplexSolver::pivot"),null==b&&console.warn("pivot: entryVar == null"),null==c&&console.warn("pivot: exitVar == null"),d&&console.time("  removeRow");var e=this.removeRow(c);d&&console.timeEnd("  removeRow"),d&&console.time("  changeSubject"),e.changeSubject(c,b),d&&console.timeEnd("  changeSubject"),d&&console.time("  substituteOut"),this.substituteOut(b,e),d&&console.timeEnd("  substituteOut"),d&&console.time("  addRow"),this.addRow(b,e),d&&console.timeEnd("  addRow"),d&&console.timeEnd(" SimplexSolver::pivot")},_resetStayConstants:function(){a.trace&&console.log("_resetStayConstants");for(var b=0;this._stayPlusErrorVars.length>b;b++){var c=this.rows.get(this._stayPlusErrorVars[b]);null==c&&(c=this.rows.get(this._stayMinusErrorVars[b])),null!=c&&(c.constant=0)}},_setExternalVariables:function(){a.trace&&a.fnenterprint("_setExternalVariables:"),a.trace&&a.traceprint(""+this),this._externalParametricVars.each(function(b){null!=this.rows.get(b)?a.trace&&console.log("Error: variable"+b+" in _externalParametricVars is basic"):b.value=0},this),this._externalRows.each(function(a){var b=this.rows.get(a);a.value!=b.constant&&(a.value=b.constant)},this),this._fNeedsSolving=!1,this.onsolved()},onsolved:function(){},insertErrorVar:function(b,c){a.trace&&a.fnenterprint("insertErrorVar:"+b+", "+c);var d=this._errorVars.get(c);d||(d=new a.HashSet,this._errorVars.set(b,d)),d.add(c)}})}(this.c||module.parent.exports||{}),function(a){"use strict";a.Timer=a.inherit({initialize:function(){this.isRunning=!1,this._elapsedMs=0},start:function(){return this.isRunning=!0,this._startReading=new Date,this},stop:function(){return this.isRunning=!1,this._elapsedMs+=new Date-this._startReading,this},reset:function(){return this.isRunning=!1,this._elapsedMs=0,this},elapsedTime:function(){return this.isRunning?(this._elapsedMs+(new Date-this._startReading))/1e3:this._elapsedMs/1e3}})}(this.c||module.parent.exports||{}),__cassowary_parser=function(){function a(a){return'"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var b={parse:function(b,c){function d(a){O>M||(M>O&&(O=M,P=[]),P.push(a))}function e(){var a,b,c,d,e;if(d=M,e=M,a=s(),null!==a){if(c=f(),null!==c)for(b=[];null!==c;)b.push(c),c=f();else b=null;null!==b?(c=s(),null!==c?a=[a,b,c]:(a=null,M=e)):(a=null,M=e)}else a=null,M=e;return null!==a&&(a=function(a,b){return b}(d,a[1])),null===a&&(M=d),a}function f(){var a,b,c,d;return c=M,d=M,a=I(),null!==a?(b=l(),null!==b?a=[a,b]:(a=null,M=d)):(a=null,M=d),null!==a&&(a=function(a,b){return b}(c,a[0])),null===a&&(M=c),a}function g(){var a;return b.length>M?(a=b.charAt(M),M++):(a=null,0===N&&d("any character")),a}function h(){var a;return/^[a-zA-Z]/.test(b.charAt(M))?(a=b.charAt(M),M++):(a=null,0===N&&d("[a-zA-Z]")),null===a&&(36===b.charCodeAt(M)?(a="$",M++):(a=null,0===N&&d('"$"')),null===a&&(95===b.charCodeAt(M)?(a="_",M++):(a=null,0===N&&d('"_"')))),a}function i(){var a;return N++,/^[\t\x0B\f \xA0\uFEFF]/.test(b.charAt(M))?(a=b.charAt(M),M++):(a=null,0===N&&d("[\\t\\x0B\\f \\xA0\\uFEFF]")),N--,0===N&&null===a&&d("whitespace"),a}function j(){var a;return/^[\n\r\u2028\u2029]/.test(b.charAt(M))?(a=b.charAt(M),M++):(a=null,0===N&&d("[\\n\\r\\u2028\\u2029]")),a}function k(){var a;return N++,10===b.charCodeAt(M)?(a="\n",M++):(a=null,0===N&&d('"\\n"')),null===a&&("\r\n"===b.substr(M,2)?(a="\r\n",M+=2):(a=null,0===N&&d('"\\r\\n"')),null===a&&(13===b.charCodeAt(M)?(a="\r",M++):(a=null,0===N&&d('"\\r"')),null===a&&(8232===b.charCodeAt(M)?(a="\u2028",M++):(a=null,0===N&&d('"\\u2028"')),null===a&&(8233===b.charCodeAt(M)?(a="\u2029",M++):(a=null,0===N&&d('"\\u2029"')))))),N--,0===N&&null===a&&d("end of line"),a}function l(){var a,c,e;return e=M,a=s(),null!==a?(59===b.charCodeAt(M)?(c=";",M++):(c=null,0===N&&d('";"')),null!==c?a=[a,c]:(a=null,M=e)):(a=null,M=e),null===a&&(e=M,a=r(),null!==a?(c=k(),null!==c?a=[a,c]:(a=null,M=e)):(a=null,M=e),null===a&&(e=M,a=s(),null!==a?(c=m(),null!==c?a=[a,c]:(a=null,M=e)):(a=null,M=e))),a}function m(){var a,c;return c=M,N++,b.length>M?(a=b.charAt(M),M++):(a=null,0===N&&d("any character")),N--,null===a?a="":(a=null,M=c),a}function n(){var a;return N++,a=o(),null===a&&(a=q()),N--,0===N&&null===a&&d("comment"),a}function o(){var a,c,e,f,h,i,j;if(h=M,"/*"===b.substr(M,2)?(a="/*",M+=2):(a=null,0===N&&d('"/*"')),null!==a){for(c=[],i=M,j=M,N++,"*/"===b.substr(M,2)?(e="*/",M+=2):(e=null,0===N&&d('"*/"')),N--,null===e?e="":(e=null,M=j),null!==e?(f=g(),null!==f?e=[e,f]:(e=null,M=i)):(e=null,M=i);null!==e;)c.push(e),i=M,j=M,N++,"*/"===b.substr(M,2)?(e="*/",M+=2):(e=null,0===N&&d('"*/"')),N--,null===e?e="":(e=null,M=j),null!==e?(f=g(),null!==f?e=[e,f]:(e=null,M=i)):(e=null,M=i);null!==c?("*/"===b.substr(M,2)?(e="*/",M+=2):(e=null,0===N&&d('"*/"')),null!==e?a=[a,c,e]:(a=null,M=h)):(a=null,M=h)}else a=null,M=h;return a}function p(){var a,c,e,f,h,i,k;if(h=M,"/*"===b.substr(M,2)?(a="/*",M+=2):(a=null,0===N&&d('"/*"')),null!==a){for(c=[],i=M,k=M,N++,"*/"===b.substr(M,2)?(e="*/",M+=2):(e=null,0===N&&d('"*/"')),null===e&&(e=j()),N--,null===e?e="":(e=null,M=k),null!==e?(f=g(),null!==f?e=[e,f]:(e=null,M=i)):(e=null,M=i);null!==e;)c.push(e),i=M,k=M,N++,"*/"===b.substr(M,2)?(e="*/",M+=2):(e=null,0===N&&d('"*/"')),null===e&&(e=j()),N--,null===e?e="":(e=null,M=k),null!==e?(f=g(),null!==f?e=[e,f]:(e=null,M=i)):(e=null,M=i);null!==c?("*/"===b.substr(M,2)?(e="*/",M+=2):(e=null,0===N&&d('"*/"')),null!==e?a=[a,c,e]:(a=null,M=h)):(a=null,M=h)}else a=null,M=h;return a}function q(){var a,c,e,f,h,i,k;if(h=M,"//"===b.substr(M,2)?(a="//",M+=2):(a=null,0===N&&d('"//"')),null!==a){for(c=[],i=M,k=M,N++,e=j(),N--,null===e?e="":(e=null,M=k),null!==e?(f=g(),null!==f?e=[e,f]:(e=null,M=i)):(e=null,M=i);null!==e;)c.push(e),i=M,k=M,N++,e=j(),N--,null===e?e="":(e=null,M=k),null!==e?(f=g(),null!==f?e=[e,f]:(e=null,M=i)):(e=null,M=i);null!==c?a=[a,c]:(a=null,M=h)}else a=null,M=h;return a}function r(){var a,b;for(a=[],b=i(),null===b&&(b=p(),null===b&&(b=q()));null!==b;)a.push(b),b=i(),null===b&&(b=p(),null===b&&(b=q()));return a}function s(){var a,b;for(a=[],b=i(),null===b&&(b=k(),null===b&&(b=n()));null!==b;)a.push(b),b=i(),null===b&&(b=k(),null===b&&(b=n()));return a}function t(){var a,b;return b=M,a=v(),null===a&&(a=u()),null!==a&&(a=function(a,b){return{type:"NumericLiteral",value:b}}(b,a)),null===a&&(M=b),a}function u(){var a,c,e;if(e=M,/^[0-9]/.test(b.charAt(M))?(c=b.charAt(M),M++):(c=null,0===N&&d("[0-9]")),null!==c)for(a=[];null!==c;)a.push(c),/^[0-9]/.test(b.charAt(M))?(c=b.charAt(M),M++):(c=null,0===N&&d("[0-9]"));else a=null;return null!==a&&(a=function(a,b){return parseInt(b.join(""))}(e,a)),null===a&&(M=e),a}function v(){var a,c,e,f,g;return f=M,g=M,a=u(),null!==a?(46===b.charCodeAt(M)?(c=".",M++):(c=null,0===N&&d('"."')),null!==c?(e=u(),null!==e?a=[a,c,e]:(a=null,M=g)):(a=null,M=g)):(a=null,M=g),null!==a&&(a=function(a,b){return parseFloat(b.join(""))}(f,a)),null===a&&(M=f),a}function w(){var a,c,e,f;if(f=M,/^[\-+]/.test(b.charAt(M))?(a=b.charAt(M),M++):(a=null,0===N&&d("[\\-+]")),a=null!==a?a:"",null!==a){if(/^[0-9]/.test(b.charAt(M))?(e=b.charAt(M),M++):(e=null,0===N&&d("[0-9]")),null!==e)for(c=[];null!==e;)c.push(e),/^[0-9]/.test(b.charAt(M))?(e=b.charAt(M),M++):(e=null,0===N&&d("[0-9]"));else c=null;null!==c?a=[a,c]:(a=null,M=f)}else a=null,M=f;return a}function x(){var a,b;return N++,b=M,a=y(),null!==a&&(a=function(a,b){return b}(b,a)),null===a&&(M=b),N--,0===N&&null===a&&d("identifier"),a}function y(){var a,b,c,e,f;if(N++,e=M,f=M,a=h(),null!==a){for(b=[],c=h();null!==c;)b.push(c),c=h();null!==b?a=[a,b]:(a=null,M=f)}else a=null,M=f;return null!==a&&(a=function(a,b,c){return b+c.join("")}(e,a[0],a[1])),null===a&&(M=e),N--,0===N&&null===a&&d("identifier"),a}function z(){var a,c,e,f,g,h,i;return h=M,a=x(),null!==a&&(a=function(a,b){return{type:"Variable",name:b}}(h,a)),null===a&&(M=h),null===a&&(a=t(),null===a&&(h=M,i=M,40===b.charCodeAt(M)?(a="(",M++):(a=null,0===N&&d('"("')),null!==a?(c=s(),null!==c?(e=I(),null!==e?(f=s(),null!==f?(41===b.charCodeAt(M)?(g=")",M++):(g=null,0===N&&d('")"')),null!==g?a=[a,c,e,f,g]:(a=null,M=i)):(a=null,M=i)):(a=null,M=i)):(a=null,M=i)):(a=null,M=i),null!==a&&(a=function(a,b){return b}(h,a[2])),null===a&&(M=h))),a}function A(){var a,b,c,d,e;return a=z(),null===a&&(d=M,e=M,a=B(),null!==a?(b=s(),null!==b?(c=A(),null!==c?a=[a,b,c]:(a=null,M=e)):(a=null,M=e)):(a=null,M=e),null!==a&&(a=function(a,b,c){return{type:"UnaryExpression",operator:b,expression:c}}(d,a[0],a[2])),null===a&&(M=d)),a}function B(){var a;return 43===b.charCodeAt(M)?(a="+",M++):(a=null,0===N&&d('"+"')),null===a&&(45===b.charCodeAt(M)?(a="-",M++):(a=null,0===N&&d('"-"')),null===a&&(33===b.charCodeAt(M)?(a="!",M++):(a=null,0===N&&d('"!"')))),a}function C(){var a,b,c,d,e,f,g,h,i;if(g=M,h=M,a=A(),null!==a){for(b=[],i=M,c=s(),null!==c?(d=D(),null!==d?(e=s(),null!==e?(f=A(),null!==f?c=[c,d,e,f]:(c=null,M=i)):(c=null,M=i)):(c=null,M=i)):(c=null,M=i);null!==c;)b.push(c),i=M,c=s(),null!==c?(d=D(),null!==d?(e=s(),null!==e?(f=A(),null!==f?c=[c,d,e,f]:(c=null,M=i)):(c=null,M=i)):(c=null,M=i)):(c=null,M=i);null!==b?a=[a,b]:(a=null,M=h)}else a=null,M=h;return null!==a&&(a=function(a,b,c){for(var d=b,e=0;c.length>e;e++)d={type:"MultiplicativeExpression",operator:c[e][1],left:d,right:c[e][3]};return d}(g,a[0],a[1])),null===a&&(M=g),a}function D(){var a;return 42===b.charCodeAt(M)?(a="*",M++):(a=null,0===N&&d('"*"')),null===a&&(47===b.charCodeAt(M)?(a="/",M++):(a=null,0===N&&d('"/"'))),a}function E(){var a,b,c,d,e,f,g,h,i;if(g=M,h=M,a=C(),null!==a){for(b=[],i=M,c=s(),null!==c?(d=F(),null!==d?(e=s(),null!==e?(f=C(),null!==f?c=[c,d,e,f]:(c=null,M=i)):(c=null,M=i)):(c=null,M=i)):(c=null,M=i);null!==c;)b.push(c),i=M,c=s(),null!==c?(d=F(),null!==d?(e=s(),null!==e?(f=C(),null!==f?c=[c,d,e,f]:(c=null,M=i)):(c=null,M=i)):(c=null,M=i)):(c=null,M=i);null!==b?a=[a,b]:(a=null,M=h)}else a=null,M=h;return null!==a&&(a=function(a,b,c){for(var d=b,e=0;c.length>e;e++)d={type:"AdditiveExpression",operator:c[e][1],left:d,right:c[e][3]};return d}(g,a[0],a[1])),null===a&&(M=g),a}function F(){var a;return 43===b.charCodeAt(M)?(a="+",M++):(a=null,0===N&&d('"+"')),null===a&&(45===b.charCodeAt(M)?(a="-",M++):(a=null,0===N&&d('"-"'))),a}function G(){var a,b,c,d,e,f,g,h,i;if(g=M,h=M,a=E(),null!==a){for(b=[],i=M,c=s(),null!==c?(d=H(),null!==d?(e=s(),null!==e?(f=E(),null!==f?c=[c,d,e,f]:(c=null,M=i)):(c=null,M=i)):(c=null,M=i)):(c=null,M=i);null!==c;)b.push(c),i=M,c=s(),null!==c?(d=H(),null!==d?(e=s(),null!==e?(f=E(),null!==f?c=[c,d,e,f]:(c=null,M=i)):(c=null,M=i)):(c=null,M=i)):(c=null,M=i);null!==b?a=[a,b]:(a=null,M=h)}else a=null,M=h;return null!==a&&(a=function(a,b,c){for(var d=b,e=0;c.length>e;e++)d={type:"Inequality",operator:c[e][1],left:d,right:c[e][3]};return d}(g,a[0],a[1])),null===a&&(M=g),a}function H(){var a;return"<="===b.substr(M,2)?(a="<=",M+=2):(a=null,0===N&&d('"<="')),null===a&&(">="===b.substr(M,2)?(a=">=",M+=2):(a=null,0===N&&d('">="')),null===a&&(60===b.charCodeAt(M)?(a="<",M++):(a=null,0===N&&d('"<"')),null===a&&(62===b.charCodeAt(M)?(a=">",M++):(a=null,0===N&&d('">"'))))),a}function I(){var a,c,e,f,g,h,i,j,k;if(i=M,j=M,a=G(),null!==a){for(c=[],k=M,e=s(),null!==e?("=="===b.substr(M,2)?(f="==",M+=2):(f=null,0===N&&d('"=="')),null!==f?(g=s(),null!==g?(h=G(),null!==h?e=[e,f,g,h]:(e=null,M=k)):(e=null,M=k)):(e=null,M=k)):(e=null,M=k);null!==e;)c.push(e),k=M,e=s(),null!==e?("=="===b.substr(M,2)?(f="==",M+=2):(f=null,0===N&&d('"=="')),null!==f?(g=s(),null!==g?(h=G(),null!==h?e=[e,f,g,h]:(e=null,M=k)):(e=null,M=k)):(e=null,M=k)):(e=null,M=k);null!==c?a=[a,c]:(a=null,M=j)}else a=null,M=j;return null!==a&&(a=function(a,b,c){for(var d=b,e=0;c.length>e;e++)d={type:"Equality",operator:c[e][1],left:d,right:c[e][3]};return d}(i,a[0],a[1])),null===a&&(M=i),a}function J(a){a.sort();for(var b=null,c=[],d=0;a.length>d;d++)a[d]!==b&&(c.push(a[d]),b=a[d]);return c}function K(){for(var a=1,c=1,d=!1,e=0;Math.max(M,O)>e;e++){var f=b.charAt(e);"\n"===f?(d||a++,c=1,d=!1):"\r"===f||"\u2028"===f||"\u2029"===f?(a++,c=1,d=!0):(c++,d=!1)}return{line:a,column:c}}var L={start:e,Statement:f,SourceCharacter:g,IdentifierStart:h,WhiteSpace:i,LineTerminator:j,LineTerminatorSequence:k,EOS:l,EOF:m,Comment:n,MultiLineComment:o,MultiLineCommentNoLineTerminator:p,SingleLineComment:q,_:r,__:s,Literal:t,Integer:u,Real:v,SignedInteger:w,Identifier:x,IdentifierName:y,PrimaryExpression:z,UnaryExpression:A,UnaryOperator:B,MultiplicativeExpression:C,MultiplicativeOperator:D,AdditiveExpression:E,AdditiveOperator:F,InequalityExpression:G,InequalityOperator:H,LinearExpression:I};if(void 0!==c){if(void 0===L[c])throw Error("Invalid rule name: "+a(c)+".")}else c="start";var M=0,N=0,O=0,P=[],Q=L[c]();if(null===Q||M!==b.length){var R=Math.max(M,O),S=b.length>R?b.charAt(R):null,T=K();throw new this.SyntaxError(J(P),S,R,T.line,T.column)}return Q},toSource:function(){return this._source}};return b.SyntaxError=function(b,c,d,e,f){function g(b,c){var d,e;switch(b.length){case 0:d="end of input";break;case 1:d=b[0];break;default:d=b.slice(0,b.length-1).join(", ")+" or "+b[b.length-1]}return e=c?a(c):"end of input","Expected "+d+" but "+e+" found."}this.name="SyntaxError",this.expected=b,this.found=c,this.message=g(b,c),this.offset=d,this.line=e,this.column=f},b.SyntaxError.prototype=Error.prototype,b}()}).call("undefined"!=typeof module?module.compiled=!0&&module:this),this.vistualFormatParser=function(){function a(a,b){function c(){this.constructor=a}c.prototype=b.prototype,a.prototype=new c}function b(a,b,c,d,e,f){this.message=a,this.expected=b,this.found=c,this.offset=d,this.line=e,this.column=f,this.name="SyntaxError"}function c(a){function c(){return Ab}function d(b){function c(b,c,d){var e,f;for(e=c;d>e;e++)f=a.charAt(e),"\n"===f?(b.seenCR||b.line++,b.column=1,b.seenCR=!1):"\r"===f||"\u2028"===f||"\u2029"===f?(b.line++,b.column=1,b.seenCR=!0):(b.column++,b.seenCR=!1)}return Bb!==b&&(Bb>b&&(Bb=0,Cb={line:1,column:1,seenCR:!1}),c(Cb,Bb,b),Bb=b),Cb}function e(a){Db>zb||(zb>Db&&(Db=zb,Eb=[]),Eb.push(a))}function f(c,e,f){function g(a){var b=1;for(a.sort(function(a,b){return a.description<b.description?-1:a.description>b.description?1:0});b<a.length;)a[b-1]===a[b]?a.splice(b,1):b++}function h(a,b){function c(a){function b(a){return a.charCodeAt(0).toString(16).toUpperCase()}return a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(a){return"\\x0"+b(a)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(a){return"\\x"+b(a)}).replace(/[\u0180-\u0FFF]/g,function(a){return"\\u0"+b(a)}).replace(/[\u1080-\uFFFF]/g,function(a){return"\\u"+b(a)})}var d,e,f,g=new Array(a.length);for(f=0;f<a.length;f++)g[f]=a[f].description;return d=a.length>1?g.slice(0,-1).join(", ")+" or "+g[a.length-1]:g[0],e=b?'"'+c(b)+'"':"end of input","Expected "+d+" but "+e+" found."}var i=d(f),j=f<a.length?a.charAt(f):null;return null!==e&&g(e),new b(null!==c?c:h(e,j),e,j,f,i.line,i.column)}function g(){var b,c,d,f,g,l,m,n;if(b=zb,c=zb,d=h(),d!==y?(58===a.charCodeAt(zb)?(f=D,zb++):(f=y,0===Fb&&e(E)),f!==y?(d=[d,f],c=d):(zb=c,c=B)):(zb=c,c=B),c===y&&(c=C),c!==y)if(d=zb,f=i(),f!==y?(g=k(),g!==y?(f=[f,g],d=f):(zb=d,d=B)):(zb=d,d=B),d===y&&(d=C),d!==y)if(f=j(),f!==y){for(g=[],l=zb,m=k(),m!==y?(n=j(),n!==y?(m=[m,n],l=m):(zb=l,l=B)):(zb=l,l=B);l!==y;)g.push(l),l=zb,m=k(),m!==y?(n=j(),n!==y?(m=[m,n],l=m):(zb=l,l=B)):(zb=l,l=B);g!==y?(l=zb,m=k(),m!==y?(n=i(),n!==y?(m=[m,n],l=m):(zb=l,l=B)):(zb=l,l=B),l===y&&(l=C),l!==y?(Ab=b,c=F(c,d,f,g,l),b=c):(zb=b,b=B)):(zb=b,b=B)}else zb=b,b=B;else zb=b,b=B;else zb=b,b=B;return b}function h(){var b,c;return b=zb,72===a.charCodeAt(zb)?(c=G,zb++):(c=y,0===Fb&&e(H)),c===y&&(86===a.charCodeAt(zb)?(c=I,zb++):(c=y,0===Fb&&e(J))),c!==y&&(Ab=b,c=K(c)),b=c}function i(){var b,c;return b=zb,124===a.charCodeAt(zb)?(c=L,zb++):(c=y,0===Fb&&e(M)),c!==y&&(Ab=b,c=N()),b=c}function j(){var b,c,d,f,g;return b=zb,91===a.charCodeAt(zb)?(c=O,zb++):(c=y,0===Fb&&e(P)),c!==y?(d=t(),d!==y?(f=n(),f===y&&(f=C),f!==y?(93===a.charCodeAt(zb)?(g=Q,zb++):(g=y,0===Fb&&e(R)),g!==y?(Ab=b,c=S(d,f),b=c):(zb=b,b=B)):(zb=b,b=B)):(zb=b,b=B)):(zb=b,b=B),b}function k(){var b,c,d,f;return b=zb,45===a.charCodeAt(zb)?(c=T,zb++):(c=y,0===Fb&&e(U)),c!==y?(d=l(),d!==y?(45===a.charCodeAt(zb)?(f=T,zb++):(f=y,0===Fb&&e(U)),f!==y?(Ab=b,c=V(d),b=c):(zb=b,b=B)):(zb=b,b=B)):(zb=b,b=B),b===y&&(b=zb,45===a.charCodeAt(zb)?(c=T,zb++):(c=y,0===Fb&&e(U)),c!==y&&(Ab=b,c=W()),b=c,b===y&&(b=zb,c=X,c!==y&&(Ab=b,c=Y()),b=c)),b}function l(){var a;return a=m(),a===y&&(a=n()),a}function m(){var a,b;return a=zb,b=u(),b!==y&&(Ab=a,b=Z(b)),a=b}function n(){var b,c,d,f,g,h,i;if(b=zb,40===a.charCodeAt(zb)?(c=$,zb++):(c=y,0===Fb&&e(_)),c!==y)if(d=o(),d!==y){for(f=[],g=zb,44===a.charCodeAt(zb)?(h=ab,zb++):(h=y,0===Fb&&e(bb)),h!==y?(i=o(),i!==y?(h=[h,i],g=h):(zb=g,g=B)):(zb=g,g=B);g!==y;)f.push(g),g=zb,44===a.charCodeAt(zb)?(h=ab,zb++):(h=y,0===Fb&&e(bb)),h!==y?(i=o(),i!==y?(h=[h,i],g=h):(zb=g,g=B)):(zb=g,g=B);f!==y?(41===a.charCodeAt(zb)?(g=cb,zb++):(g=y,0===Fb&&e(db)),g!==y?(Ab=b,c=eb(d,f),b=c):(zb=b,b=B)):(zb=b,b=B)}else zb=b,b=B;else zb=b,b=B;return b}function o(){var b,c,d,f,g,h;return b=zb,c=p(),c===y&&(c=C),c!==y?(d=q(),d!==y?(f=zb,64===a.charCodeAt(zb)?(g=fb,zb++):(g=y,0===Fb&&e(gb)),g!==y?(h=r(),h!==y?(g=[g,h],f=g):(zb=f,f=B)):(zb=f,f=B),f===y&&(f=C),f!==y?(Ab=b,c=hb(c,d,f),b=c):(zb=b,b=B)):(zb=b,b=B)):(zb=b,b=B),b}function p(){var b,c;return b=zb,a.substr(zb,2)===ib?(c=ib,zb+=2):(c=y,0===Fb&&e(jb)),c!==y&&(Ab=b,c=kb()),b=c,b===y&&(b=zb,a.substr(zb,2)===lb?(c=lb,zb+=2):(c=y,0===Fb&&e(mb)),c!==y&&(Ab=b,c=nb()),b=c,b===y&&(b=zb,a.substr(zb,2)===ob?(c=ob,zb+=2):(c=y,0===Fb&&e(pb)),c!==y&&(Ab=b,c=qb()),b=c)),b}function q(){var a;return a=s(),a===y&&(a=t()),a}function r(){var a,b;return a=zb,b=u(),b!==y&&(Ab=a,b=rb(b)),a=b}function s(){var a,b;return a=zb,b=u(),b!==y&&(Ab=a,b=sb(b)),a=b}function t(){var b,c,d,f;if(b=zb,c=zb,d=[],tb.test(a.charAt(zb))?(f=a.charAt(zb),zb++):(f=y,0===Fb&&e(ub)),f!==y)for(;f!==y;)d.push(f),tb.test(a.charAt(zb))?(f=a.charAt(zb),zb++):(f=y,0===Fb&&e(ub));else d=B;return d!==y&&(d=a.substring(c,zb)),c=d,c!==y&&(Ab=b,c=vb(c)),b=c}function u(){var b,c,d;if(b=zb,c=[],wb.test(a.charAt(zb))?(d=a.charAt(zb),zb++):(d=y,0===Fb&&e(xb)),d!==y)for(;d!==y;)c.push(d),wb.test(a.charAt(zb))?(d=a.charAt(zb),zb++):(d=y,0===Fb&&e(xb));else c=B;return c!==y&&(Ab=b,c=yb(c)),b=c}function v(a){for(var b=1;b<arguments.length;b++)for(var c in arguments[b])a[c]=arguments[b][c];return a}var w,x=arguments.length>1?arguments[1]:{},y={},z={visualFormatString:g},A=g,B=y,C=null,D=":",E={type:"literal",value:":",description:'":"'},F=function(a,b,c,d,e){return{orientation:a?a[0]:"horizontal",cascade:(b||[]).concat([c],[].concat.apply([],d),e||[])}},G="H",H={type:"literal",value:"H",description:'"H"'},I="V",J={type:"literal",value:"V",description:'"V"'},K=function(a){return"H"==a?"horizontal":"vertical"},L="|",M={type:"literal",value:"|",description:'"|"'},N=function(){return{view:null}},O="[",P={type:"literal",value:"[",description:'"["'},Q="]",R={type:"literal",value:"]",description:'"]"'},S=function(a,b){return v(a,b?{constraints:b}:{})},T="-",U={type:"literal",value:"-",description:'"-"'},V=function(a){return a},W=function(){return[{relation:"equal",constant:"default",$parserOffset:c()}]},X="",Y=function(){return[{relation:"equal",constant:0,$parserOffset:c()}]},Z=function(a){return[{relation:"equal",constant:a,$parserOffset:c()}]},$="(",_={type:"literal",value:"(",description:'"("'},ab=",",bb={type:"literal",value:",",description:'","'},cb=")",db={type:"literal",value:")",description:'")"'},eb=function(a,b){return[a].concat(b.map(function(a){return a[1]}))},fb="@",gb={type:"literal",value:"@",description:'"@"'},hb=function(a,b,c){return v({relation:"equal"},a||{},b,c?c[1]:{})},ib="==",jb={type:"literal",value:"==",description:'"=="'},kb=function(){return{relation:"equal",$parserOffset:c()}},lb="<=",mb={type:"literal",value:"<=",description:'"<="'},nb=function(){return{relation:"lessOrEqual",$parserOffset:c()}},ob=">=",pb={type:"literal",value:">=",description:'">="'},qb=function(){return{relation:"greaterOrEqual",$parserOffset:c()}},rb=function(a){return{priority:a}},sb=function(a){return{constant:a}},tb=/^[a-zA-Z0-9\-_]/,ub={type:"class",value:"[a-zA-Z0-9\\-_]",description:"[a-zA-Z0-9\\-_]"},vb=function(a){return{view:a}},wb=/^[0-9]/,xb={type:"class",value:"[0-9]",description:"[0-9]"},yb=function(a){return parseInt(a.join(""),10)},zb=0,Ab=0,Bb=0,Cb={line:1,column:1,seenCR:!1},Db=0,Eb=[],Fb=0;if("startRule"in x){if(!(x.startRule in z))throw new Error("Can't start parsing from rule \""+x.startRule+'".');A=z[x.startRule]}if(w=A(),w!==y&&zb===a.length)return w;throw w!==y&&zb<a.length&&e({type:"end",description:"end of input"}),f(null,Eb,Db)}return a(b,Error),{SyntaxError:b,parse:c}}(),function(a){angular.module("autolayout",["ng"]);var b=a.c;if(!b)throw new Error("Cassowary missing!");angular.module("autolayout").constant("cassowary",b);var c=a.vistualFormatParser;if(!c)throw new Error("Visual format parser missing!");var d=0;angular.module("autolayout").provider("autolayout",function(){function a(c){if(!(this instanceof a))return new a(c);this.containerElement=angular.element(c||a.$rootElement);var d=this.containerElement.data(e.autolayoutInstanceDataKey);if(d instanceof a)return d;this.containerElement.data(e.autolayoutInstanceDataKey,this),this.solver=new b.SimplexSolver,this.constraints=[];var f=this.containerElement.css("position");("absolute"!=f||"relative"!=f||"fixed"!=f)&&this.containerElement.css("position","relative")}var e=this;e.standardSpace=8,e.autolayoutInstanceDataKey="$autolayout",e.autolayoutChildElementExpressionsDataKey="$autolayoutExpressions",e.autolayoutContainerElementExpressionsDataKey="$autolayoutContainerExpressions",e.varUID=function(){return"v"+d++},e.relations={equal:function(a,c,d){var e;return e=d?new b.Equation(a,c,new b.Strength("priority",0,0,d)):new b.Equation(a,c,b.Strength.required)},greaterOrEqual:function(a,c,d){var e;return e=d?new b.Inequality(a,b.GEQ,c,new b.Strength("priority",0,0,d)):new b.Inequality(a,b.GEQ,c,b.Strength.required)},lessOrEqual:function(a,c,d){var e;return e=d?new b.Inequality(a,b.LEQ,c,new b.Strength("priority",0,0,d)):new b.Inequality(a,b.LEQ,c,b.Strength.required)}},e.attributeConverters={top:{create:function(a,c,d){var f=a.getBoundingClientRect().top-c.getBoundingClientRect().top,g=new b.Variable({name:(a.id||e.varUID())+".top",value:f});return a==c&&d.addStay(g,b.Strength.required),g},materialize:function(a,b){a.css("top",Math.round(b.value)+"px")}},left:{create:function(a,c,d){var f=a.getBoundingClientRect().left-c.getBoundingClientRect().left,g=new b.Variable({name:(a.id||e.varUID())+".left",value:f});return a==c&&d.addStay(g,b.Strength.required),g},materialize:function(a,b){a.css("left",Math.round(b.value)+"px")}},width:{create:function(a,c,d){var f=a.getBoundingClientRect().width,g=new b.Variable({name:(a.id||e.varUID())+".width",value:f});return a==c?g.$stayConst=d.addStay(g,b.Strength.required):(d.addConstraint(new b.Inequality(g,b.GEQ,0,b.Strength.required)),d.addConstraint(new b.Inequality(g,b.GEQ,f,b.Strength.weak))),g},update:function(a,c,d){d.removeConstraint(c.$stayConst),d.suggestValue(c,a.getBoundingClientRect().width),c.$stayConst=d.addStay(c,b.Strength.required)},materialize:function(a,b){a.css("width",Math.round(b.value)+"px")}},height:{create:function(a,c,d){var f=a.getBoundingClientRect().height,g=new b.Variable({name:(a.id||e.varUID())+".height",value:f});return a==c?g.$stayConst=d.addStay(g,b.Strength.required):(d.addConstraint(new b.Inequality(g,b.GEQ,0,b.Strength.required)),d.addConstraint(new b.Inequality(g,b.GEQ,f,b.Strength.weak))),g},update:function(a,c,d){d.removeConstraint(c.$stayConst),d.suggestValue(c,a.getBoundingClientRect().height),c.$stayConst=d.addStay(c,b.Strength.required)},materialize:function(a,b){a.css("height",Math.round(b.value)+"px")}},right:{create:function(a,c,d){var f=e.expressionForElementAttribute("left",a,c,d),g=e.expressionForElementAttribute("width",a,c,d),h=new b.Expression(f).plus(g);return h.leftPartExp=f,h.widthPartExp=g,h},materialize:function(a,b){e.materializeExpressionValue("left",a,b.leftPartExp),e.materializeExpressionValue("width",a,b.widthPartExp)}},bottom:{create:function(a,c,d){var f=e.expressionForElementAttribute("top",a,c,d),g=e.expressionForElementAttribute("height",a,c,d),h=new b.Expression(f).plus(g);return h.topPartExp=f,h.heightPartExp=g,h},materialize:function(a,b){e.materializeExpressionValue("top",a,b.topPartExp),e.materializeExpressionValue("height",a,b.heightPartExp)}},centerX:{create:function(a,c,d){var f=e.expressionForElementAttribute("left",a,c,d),g=e.expressionForElementAttribute("width",a,c,d),h=new b.Expression(g).divide(2).plus(f);return h.leftPartExp=f,h.widthPartExp=g,h},materialize:function(a,b){e.materializeExpressionValue("left",a,b.leftPartExp),e.materializeExpressionValue("width",a,b.widthPartExp)}},centerY:{create:function(a,c,d){var f=e.expressionForElementAttribute("top",a,c,d),g=e.expressionForElementAttribute("height",a,c,d),h=new b.Expression(g).divide(2).plus(f);return h.topPartExp=f,h.heightPartExp=g,h},materialize:function(a,b){e.materializeExpressionValue("top",a,b.topPartExp),e.materializeExpressionValue("height",a,b.heightPartExp)}}},e.expressionForElementAttribute=function(a,b,c,d){var f=e.attributeConverters[a];if(!f||!f.create)throw new Error("Unknown attribute converter for: "+a);f=f.create,b=angular.element(b),c=angular.element(c);var g=b[0]==c[0]?e.autolayoutContainerElementExpressionsDataKey:e.autolayoutChildElementExpressionsDataKey,h=b.data(g);return angular.isObject(h)||(h={},b.data(g,h)),exp=h[a],angular.isDefined(exp)?exp:h[a]=f(b[0],c[0],d)},e.materializeExpressionValue=function(a,b,c){var d=e.attributeConverters[a];if(!d||!d.materialize)throw new Error("Unknown attribute converter for: "+a);return(d=d.materialize)(b,c)},a.prototype.addConstraint=function(a,d){if(angular.isString(a)){var f=[],g=c.parse(a),h=a,i=function(a){for(var b="Conflict when adding constraint:\n"+h+"\n",c=a-1;c>=0;c--)b+="-";return b+="^",new Error(b)},j=this.containerElement[0],k=function(a){var b=0;return a.element&&a.element!=j?a.toElement&&a.toElement!=j||(b=1):b=-1,angular.extend(a,"vertical"==g.orientation?{attribute:0>b?"top":"bottom",toAttribute:1>b?"top":"bottom"}:{attribute:0>b?"left":"right",toAttribute:1>b?"left":"right"})},l=null;d&&d.align&&(l={attribute:d.align,relation:"equal",toAttribute:d.align});for(var m=g.cascade.length-2,n=0;m>n;n+=2){for(var o=k({element:document.getElementById(g.cascade[n].view),toElement:document.getElementById(g.cascade[n+2].view)}),p=g.cascade[n+1],q=0;q<p.length;q++){a=angular.extend({},o,p[q]),"default"==a.constant&&(a.constant=e.standardSpace),a.constant&&("greaterOrEqual"==a.relation?a.relation="lessOrEqual":"lessOrEqual"==a.relation&&(a.relation="greaterOrEqual"),a.constant=-a.constant);try{f=f.concat(this.addConstraint(a))}catch(r){throw r instanceof b.RequiredFailure?i(a.$parserOffset):r}}l&&o.element&&o.toElement&&(f=f.concat(this.addConstraint(angular.extend({},o,l))))}for(var m=g.cascade.length,n=0;m>n;n+=2){var p=g.cascade[n].constraints;if(p&&p.length)for(var o={element:document.getElementById(g.cascade[n].view),attribute:"vertical"==g.orientation?"height":"width"},q=0;q<p.length;q++){a=angular.extend({},o,p[q]),a.view&&(a.toElement=document.getElementById(a.view),a.toAttribute=a.attribute,a.constant=0,delete a.view);try{f=f.concat(this.addConstraint(a))}catch(r){throw r instanceof b.RequiredFailure?i(a.$parserOffset):r}}}return f}if(!angular.isObject(a))throw new Error("A constraint object argument is required.");if(!a.element&&!a.toElement)throw new Error("A from or to element is required.");if(a.element&&!a.attribute)throw new Error("An `attribute` for `element` is required.");if(a.toElement&&!a.toAttribute)throw new Error("A `toAttribute` for `toElement` is required.");if(!a.relation)throw new Error("A `relation` parameter is required.");if(a=angular.extend({},a),a.element=angular.element(a.element||this.containerElement),a.element[0]!=this.containerElement[0]&&a.element[0].parentNode!=this.containerElement[0])throw new Error("The element: "+a.element[0]+" should be a direct child of: "+this.containerElement[0]);a.element[0]!=this.containerElement[0]&&a.element.css("position","absolute"),a.expression=angular.isFunction(a.attribute)?a.attribute(a.element,this.containerElement,this.solver):e.expressionForElementAttribute(a.attribute,a.element,this.containerElement,this.solver);var s=angular.isFunction(a.relation)?a.relation:e.relations[a.relation];if(!s)throw new Error("Unknown relation: "+a.relation);if(a.relationFactory=s,a.toAttribute){if(a.toElement=angular.element(a.toElement||this.containerElement),a.toElement[0]!=this.containerElement[0]&&a.toElement[0].parentNode!=this.containerElement[0])throw new Error("The toElement: "+a.toElement[0]+" should be a direct child of: "+this.containerElement[0]);a.toElement[0]!=this.containerElement[0]&&a.toElement.css("position","absolute"),a.toExpression=angular.isFunction(a.toAttribute)?a.toAttribute(a.toElement,this.containerElement,this.solver):e.expressionForElementAttribute(a.toAttribute,a.toElement,this.containerElement,this.solver),a.$constraint=a.relationFactory(a.expression,b.plus(b.times(a.toExpression,a.multiplier||1),a.constant||0),a.priority)}else{if(!angular.isNumber(a.constant))throw new Error("A numeric `constant` parameter is required.");a.$constraint=a.relationFactory(a.expression,a.constant,a.priority)}if(!a.$constraint)throw new Error("Unable to create constraint with parameters: "+a);
  return this.solver.addConstraint(a.$constraint),this.constraints.push(a),this.materialize(),[a]},a.prototype.removeConstraint=function(a){if(angular.isArray(a))for(var b=a.length-1;b>=0;b--)this.removeConstraint(a[b]);else{if(!a||!a.$constraint)throw new Error("Can not remove invalid constraint: "+a);var c=this.constraints.indexOf(a);0>c||(this.solver.removeConstraint(a.$constraint),this.constraints.splice(c,1))}},a.prototype.materialize=function(){for(var a=!1,b=this.containerElement[0];b=b.parentNode;)if(b==document){a=!0;break}if(a)for(var c,d=this.containerElement[0],f=this.constraints.length-1;f>=0;f--)c=this.constraints[f],c.element[0]!=d&&(angular.isFunction(c.attribute)?c.attribute(c.element,c.expression):e.materializeExpressionValue(c.attribute,c.element,c.expression)),c.toElement&&c.toElement[0]!=d&&(angular.isFunction(c.toAttribute)?c.toAttribute(c.toElement,c.toExpression):e.materializeExpressionValue(c.toAttribute,c.toElement,c.toExpression))},a.prototype.update=function(){var c,d=this.containerElement.data(e.autolayoutContainerElementExpressionsDataKey),f=this.containerElement[0],g={},h={},i=0;for(var j in d)c=e.attributeConverters[j],c&&c.update&&(i++,g[j]=c.prepareUpdate||function(a,b){b.addEditVar(a)},h[j]=c.update);if(!(i=0)){for(var j in g)g[j](d[j],this.solver);try{this.solver.beginEdit();for(var j in h)h[j](f,d[j],this.solver);this.solver.endEdit()}catch(k){var l=this.materialize;this.materialize=function(){},this.containerElement.data(e.autolayoutContainerElementExpressionsDataKey,null);for(var m=this.containerElement.children(),n=m.length-1;n>=0;n--)angular.element(m[n]).data(e.autolayoutChildElementExpressionsDataKey,null);this.solver=new b.SimplexSolver;var o=this.constraints;this.constraints=[];for(var n=o.length-1;n>=0;n--)this.addConstraint(o[n]);this.materialize=l}this.materialize();for(var p,m=this.containerElement.children(),n=m.length-1;n>=0;n--)p=angular.element(m[n]).data(e.autolayoutInstanceDataKey),p instanceof a&&p.update()}},a.prototype.destroy=function(){this.containerElement.data(e.autolayoutInstanceDataKey,null),this.containerElement.data(e.autolayoutContainerElementExpressionsDataKey,null);for(var a=this.containerElement.children(),b=a.length-1;b>=0;b--)angular.element(a[b]).data(e.autolayoutChildElementExpressionsDataKey,null);this.constraints=[],this.solver=null},e.$get=["$rootElement",function(b){return a.$rootElement=b,a}]}),angular.module("autolayout").directive("alConstraint",["autolayout","$interpolate",function(a,b){return{restrict:"E",priority:900,terminal:!0,compile:function(c,d){var e=d.ngIf,f=(d.visualFormat||c.text()).trim(),g=f&&b(f,!0)||f,h=d.align&&b(d.align,!0)||d.align,i=null,j=null;g||(i={element:d.element,attribute:d.attribute,toElement:d.toElement,toAttribute:d.toAttribute,relation:d.relation,multiplier:d.multiplier,constant:d.constant,priority:d.priority},j=b(JSON.stringify(i),!0)||i,angular.isFunction(j)||(j.multiplier=parseFloat(j.multiplier)||1,j.constant=parseFloat(j.constant)||0,j.priority=parseInt(j.priority)||void 0));var k="";f?(k=f,d.align&&(k+=" (align: "+d.align+")")):k=JSON.stringify(i),e&&(k+=" if: "+e);var l=angular.element("<!-- al-constraint: "+k+" -->");return c.after(l),c.remove(),function(b,c){var d=a(c.parent());if(!d)throw new Error("Unable to create autolayout from: "+c.parent());var f=function(){var a=null;if(g)if(angular.isFunction(g)){if(!angular.isFunction(h)){var c=h;h=function(){return c}}b.$watch(function(){return JSON.stringify([g(b),h(b)])},function(b){b=JSON.parse(b),a&&d.removeConstraint(a),a=d.addConstraint(b[0],{align:b[1]})})}else angular.isFunction(h)?b.$watch(function(){return h(b)},function(b){a&&d.removeConstraint(a),a=d.addConstraint(g,{align:b})}):a=d.addConstraint(g,{align:h});else{var e=function(b){a&&d.removeConstraint(a),b.element=document.getElementById(b.element),b.toElement=document.getElementById(b.toElement),a=d.addConstraint(b)};angular.isFunction(j)?b.$watch(function(){return j(b)},function(a){var a=JSON.parse(a);a.multiplier=parseFloat(a.multiplier)||1,a.constant=parseFloat(a.constant)||0,a.priority=parseInt(a.priority)||void 0,e(a)}):e(j)}return a},i=null;e?b.$watch(e,function(a){a&&!i?b.$evalAsync(function(){i=f()}):i&&(d.removeConstraint(i),i=null)}):i=f(),b.$on("$destroy",function(){i&&d.removeConstraint(i)})}}}}]),angular.module("autolayout").directive("alUpdateOn",["autolayout",function(a){return{restrict:"AC",link:function(b,c,d){if(!d.alUpdateOn)throw new Error("Event name required in `al-update-on`");var e=a(c);b.$on(d.alUpdateOn,function(){e.update()})}}}]),angular.module("autolayout").directive("alUpdateOnResize",["autolayout",function(a){function b(a){0==d.length&&angular.element(window).bind("resize",e),d.push(a)}function c(a){d.splice(d.indexOf(a),1),0==d.length&&angular.element(window).unbind("resize",e)}var d=[],e=function(){for(var a=d.length-1;a>=0;a--)d[a].update()};return{restrict:"AC",link:function(d,e){var f=a(e);b(f),d.$on("$destroy",function(){c(f)})}}}])}(this)})()}();