// Generated by CoffeeScript 1.7.1
(function() {
  var EventEmitter, Ipc, ipc, process,
    __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; },
    __slice = [].slice;

  EventEmitter = require('events').EventEmitter;

  process = global.process;

  ipc = process.atomBinding('ipc');

  Ipc = (function(_super) {
    __extends(Ipc, _super);

    function Ipc() {
      process.on('ATOM_INTERNAL_MESSAGE', (function(_this) {
        return function() {
          var args;
          args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
          return _this.emit.apply(_this, args);
        };
      })(this));
      window.addEventListener('unload', function(event) {
        return process.removeAllListeners('ATOM_INTERNAL_MESSAGE');
      });
    }

    Ipc.prototype.send = function() {
      var args;
      args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
      return ipc.send('ipc-message', __slice.call(args));
    };

    Ipc.prototype.sendSync = function() {
      var args;
      args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
      return JSON.parse(ipc.sendSync('ipc-message-sync', __slice.call(args)));
    };

    Ipc.prototype.sendToHost = function() {
      var args;
      args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
      return ipc.send('ipc-message-host', __slice.call(args));
    };

    Ipc.prototype.sendChannel = function() {
      return this.send.apply(this, arguments);
    };

    Ipc.prototype.sendChannelSync = function() {
      return this.sendSync.apply(this, arguments);
    };

    return Ipc;

  })(EventEmitter);

  module.exports = new Ipc;

}).call(this);
