// Generated by IcedCoffeeScript 1.7.1-c
(function() {
  var iced, kb, pgp, pgp_sig, __iced_k, __iced_k_noop;

  iced = require('iced-runtime').iced;
  __iced_k = __iced_k_noop = function() {};

  pgp = require('./openpgp/keymanager');

  pgp_sig = require('./openpgp/sigeng');

  kb = require('./keybase/hilev');

  exports.import_armored_public = function(_arg, cb) {
    var armored, asp, err, opts, ret, warnings, ___iced_passed_deferral, __iced_deferrals, __iced_k;
    __iced_k = __iced_k_noop;
    ___iced_passed_deferral = iced.findDeferral(arguments);
    armored = _arg.armored, asp = _arg.asp, opts = _arg.opts;
    warnings = null;
    (function(_this) {
      return (function(__iced_k) {
        if (armored.match(/^-{5}BEGIN PGP PUBLIC KEY BLOCK-{5}/)) {
          (function(__iced_k) {
            __iced_deferrals = new iced.Deferrals(__iced_k, {
              parent: ___iced_passed_deferral,
              filename: "/Users/max/src/keybase/kbpgp/src/ukm.iced",
              funcname: "import_armored_public"
            });
            pgp.KeyManager.import_from_armored_pgp({
              armored: armored,
              asp: asp,
              opts: opts
            }, __iced_deferrals.defer({
              assign_fn: (function() {
                return function() {
                  err = arguments[0];
                  ret = arguments[1];
                  return warnings = arguments[2];
                };
              })(),
              lineno: 12
            }));
            __iced_deferrals._fulfill();
          })(__iced_k);
        } else {
          (function(__iced_k) {
            __iced_deferrals = new iced.Deferrals(__iced_k, {
              parent: ___iced_passed_deferral,
              filename: "/Users/max/src/keybase/kbpgp/src/ukm.iced",
              funcname: "import_armored_public"
            });
            kb.KeyManager.import_public({
              hex: armored
            }, __iced_deferrals.defer({
              assign_fn: (function() {
                return function() {
                  err = arguments[0];
                  return ret = arguments[1];
                };
              })(),
              lineno: 14
            }));
            __iced_deferrals._fulfill();
          })(__iced_k);
        }
      });
    })(this)((function(_this) {
      return function() {
        return cb(err, ret, warnings);
      };
    })(this));
  };

  exports.decode_sig = function(_arg) {
    var armored;
    armored = _arg.armored;
    if (armored.match(/^-{5}BEGIN PGP MESSAGE-{5}/)) {
      return pgp_sig.decode_sig({
        armored: armored
      });
    } else {
      return kb.decode_sig({
        armored: armored
      });
    }
  };

}).call(this);
