text: // Generated by CoffeeScript 1.4.0
  (function() {
    var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
      __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(function(require, exports, module) {
      var Annotation, Spine, remove;
      Spine = require('Spine');
      remove = require('zooniverse/util').remove;
      Annotation = (function(_super) {
  
        __extends(Annotation, _super);
  
        Annotation.configure('Annotation', 'value', 'classification');
  
        function Annotation() {
          this.destroy = __bind(this.destroy, this);
  
          this.toJSON = __bind(this.toJSON, this);
  
          var alreadyThere, annotation, _i, _len, _ref, _ref1,
            _this = this;
          Annotation.__super__.constructor.apply(this, arguments);
          if ((_ref = this.value) == null) {
            this.value = {};
          }
          if (this.classification == null) {
            throw new Error('Annotation created without a classification');
          }
          this.bind('change', function() {
            return _this.classification.trigger('change');
          });
          alreadyThere = false;
          _ref1 = this.classification.annotations;
          for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
            annotation = _ref1[_i];
            alreadyThere || (alreadyThere = annotation.eql(this));
          }
          if (!alreadyThere) {
            this.classification.annotations.push(this);
          }
          this.classification.trigger('change');
        }
  
        Annotation.prototype.toJSON = function() {
          return this.value;
        };
  
        Annotation.prototype.destroy = function() {
          remove(this, {
            from: this.classification.annotations
          });
          this.classification.trigger('change');
          return Annotation.__super__.destroy.apply(this, arguments);
        };
  
        return Annotation;
  
      })(Spine.Model);
      return module.exports = Annotation;
    });
  
  }).call(this);
  