// Generated by CoffeeScript 1.3.3
var __hasProp = {}.hasOwnProperty,
  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

define(['environ', 'mediator', 'backbone'], function(environ, mediator, Backbone) {
  var Distribution, Distributions;
  Distribution = (function(_super) {

    __extends(Distribution, _super);

    function Distribution() {
      return Distribution.__super__.constructor.apply(this, arguments);
    }

    Distribution.prototype.defaults = {
      xAxis: null,
      yAxis: null,
      series: null,
      expanded: false
    };

    Distribution.prototype.sync = function(method, model, options) {};

    return Distribution;

  })(Backbone.Model);
  Distributions = (function(_super) {

    __extends(Distributions, _super);

    function Distributions() {
      return Distributions.__super__.constructor.apply(this, arguments);
    }

    Distributions.prototype.model = Distribution;

    Distributions.prototype.comparator = function(model) {
      return model.get('order');
    };

    Distributions.prototype.initialize = function() {
      var _this = this;
      mediator.subscribe('session/load/distributions', function(distributions) {
        return _this.add(distributions, {
          silent: true
        });
      });
      return this.on('all', _.debounce(function() {
        return mediator.publish('session/save', 'distributions', _this.toJSON());
      }));
    };

    Distributions.prototype.sync = function(method, model, options) {};

    return Distributions;

  })(Backbone.Collection);
  return App.Distribution = new Distributions;
});
