Helper functions
343062
function requireSecondPassword (options) {
  return function (wallet) {
    if (wallet.isDoubleEncrypted && !wallet.validateSecondPassword(options.second_password)) {
      throw 'ERR_SECPASS'
    }
    return wallet
  }
}
710693
function (item, disabled) {
            return {
                title: item.title,
                aClass: item.aClass,
                value: item.aClass ? '' : item.value,
                liClass: disabled ? scope.disabledClass : '',
                pgHref: disabled ? '' : scope.pgHref.replace(regex, item.page),
                action: function () {
                    if (!disabled) {
                        internalAction(scope, item.page);
                    }
                }
            };    
        }
1079254
function mapCOW(arr, func) {
    var res = null;

    for(var i=0; i<arr.length; i++) {
        var item = func(arr[i]);

        if(item !== arr[i]) {
            if(!res) {
                res = arr.slice();
            }

            res[i] = item;
        }
    }

    return res || arr;
}
378346
function(val, ctx, partials, inverted, start, end, tags) {
      var pass;

      if (isArray(val) && val.length === 0) {
        return false;
      }

      if (typeof val == 'function') {
        val = this.ls(val, ctx, partials, inverted, start, end, tags);
      }

      pass = (val === '') || !!val;

      if (!inverted && pass && ctx) {
        ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
      }

      return pass;
    }
805421
function(x, keys_, value) {
  if (isnt(x) || isnt(keys_) || isnt(value))  { return false; }

  var keys  = _.isArray(keys_) ? keys_ : keys_.split('.').map(function(x) {return x==='' ? null: x});

  if (anyIsnt(keys))                          { return false; }

  return keys;
}
825895
function(tpl, data, label) {
    var t = String(tpl),
      s = label || /#\{([^}]*)\}/mg,
      trim = String.trim ||
      function(str) {
          return str.replace(/^\s+|\s+$/g, "")
      }
    return t.replace(s, function(value, name) {
      value = data[trim(name)]
      // only handle `undefined`
      return value === undefined ? "" : value
    })
  }
1140417
function selector(str) {
        var elems = [];

        each(str.split(/\s*,\s*/), function(s) {
            var m = s.match(/([#.])(\w+)/);
            if (m === null) {
                throw Error('Supports only simple single #ID or .CLASS selector.');
            }

            if (m[1]) {
                var elem = document.getElementById(m[2]);

                if (elem) {
                    elems.push(elem);
                }
            }

            elems = elems.concat(getElementsByClassName(str));
        });

        return elems;
    }
1156251
function() {
    if (!ICAL.debug) {
      return;
    }

    if (typeof (console) !== 'undefined' && 'log' in console) {
      ICAL.helpers.dumpn = function consoleDumpn(input) {
        console.log(input);
      };
    } else {
      ICAL.helpers.dumpn = function geckoDumpn(input) {
        dump(input + '\n');
      };
    }

    ICAL.helpers.dumpn(arguments[0]);
  }
1286731
function(x) {
  return _.isUndefined(x) || _.isNull(x) || _.isNaN(x);
}
1055618
function $$(selector, ctx) {
  return Array.prototype.slice.call((ctx || document).querySelectorAll(selector))
}
188566
function(fn) {
    var n = this.elements.length, k = n, i;
    do { i = k - n;
      fn(this.elements[i], i+1);
    } while (--n);
  }
1323677
function scopify (code, unescapeSingleQuotes) {
      // Interpolations got escaped as HTML and must be unescaped to be JS.
      if (unescapeSingleQuotes) {
        code = code.replace(/\\'/g, "'")
      }
      var tokens = code.split(/\b/)
      var isProperty = false
      var isLoopVar = false
      var isInString = false
      for (var i = 0; i < tokens.length; i++) {
        var token = tokens[i]
        var stringTokens = token.match(/['"]/g)
        if (stringTokens) {
          isInString = ((isInString ? 1 : 0) + stringTokens.length) % 2
        } else if (!isInString) {
          if (/^[a-z_]/i.test(token)) {
            if (!ltl.jsPattern.test(token)) {
              for (var j = 0; j < loopVars.length; j++) {
                for (var k = 0; k < loopVars[j].length; k++) {
                  if (token === loopVars[j][k][0]) {
                    isLoopVar = true
                    tokens[i] = loopVars[j][k][1]
                  }
                }
              }
              if (!isProperty && !isLoopVar) {
                tokens[i] = 'scope.' + token
              }
            }
          }
          isProperty = token[token.length - 1] === '.'
          isLoopVar = false
        }
      }
      code = tokens.join('')
      return code
    }
546466
function massageSelector(input) {
  var result = pouchdbUtils.clone(input);
  var wasAnded = false;
  if ('$and' in result) {
    result = mergeAndedSelectors(result['$and']);
    wasAnded = true;
  }

  ['$or', '$nor'].forEach(function (orOrNor) {
    if (orOrNor in result) {
      // message each individual selector
      // e.g. {foo: 'bar'} becomes {foo: {$eq: 'bar'}}
      result[orOrNor].forEach(function (subSelector) {
        var fields = Object.keys(subSelector);
        for (var i = 0; i < fields.length; i++) {
          var field = fields[i];
          var matcher = subSelector[field];
          if (typeof matcher !== 'object' || matcher === null) {
            subSelector[field] = {$eq: matcher};
          }
        }
      });
    }
  });

  if ('$not' in result) {
    //This feels a little like forcing, but it will work for now,
    //I would like to come back to this and make the merging of selectors a little more generic
    result['$not'] = mergeAndedSelectors([result['$not']]);
  }

  var fields = Object.keys(result);

  for (var i = 0; i < fields.length; i++) {
    var field = fields[i];
    var matcher = result[field];

    if (typeof matcher !== 'object' || matcher === null) {
      matcher = {$eq: matcher};
    } else if ('$ne' in matcher && !wasAnded) {
      // I put these in an array, since there may be more than one
      // but in the "mergeAnded" operation, I already take care of that
      matcher.$ne = [matcher.$ne];
    }
    result[field] = matcher;
  }

  return result;
}
371716
function (s) {
          s = Tools.trim(s);

          function rep(re, str) {
            s = s.replace(re, str);
          }

          // example: [b] to <strong>
          rep(/\n/gi, "<br />");
          rep(/\[b\]/gi, "<strong>");
          rep(/\[\/b\]/gi, "</strong>");
          rep(/\[i\]/gi, "<em>");
          rep(/\[\/i\]/gi, "</em>");
          rep(/\[u\]/gi, "<u>");
          rep(/\[\/u\]/gi, "</u>");
          rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi, "<a href=\"$1\">$2</a>");
          rep(/\[url\](.*?)\[\/url\]/gi, "<a href=\"$1\">$1</a>");
          rep(/\[img\](.*?)\[\/img\]/gi, "<img src=\"$1\" />");
          rep(/\[color=(.*?)\](.*?)\[\/color\]/gi, "<font color=\"$1\">$2</font>");
          rep(/\[code\](.*?)\[\/code\]/gi, "<span class=\"codeStyle\">$1</span>&nbsp;");
          rep(/\[quote.*?\](.*?)\[\/quote\]/gi, "<span class=\"quoteStyle\">$1</span>&nbsp;");

          return s;
        }
1328610
function(val, ctx, partials, inverted, start, end, tags) {
      var cx = ctx[ctx.length - 1],
          t = null;

      if (!inverted && this.c && val.length > 0) {
        return this.ho(val, cx, partials, this.text.substring(start, end), tags);
      }

      t = val.call(cx);

      if (typeof t == 'function') {
        if (inverted) {
          return true;
        } else if (this.c) {
          return this.ho(t, cx, partials, this.text.substring(start, end), tags);
        }
      }

      return t;
    }
1164652
function(key, ctx, partials, returnFound) {
      var names = key.split('.'),
          val = this.f(names[0], ctx, partials, returnFound),
          cx = null;

      if (key === '.' && isArray(ctx[ctx.length - 2])) {
        return ctx[ctx.length - 1];
      }

      for (var i = 1; i < names.length; i++) {
        if (val && typeof val == 'object' && names[i] in val) {
          cx = val;
          val = val[names[i]];
        } else {
          val = '';
        }
      }

      if (returnFound && !val) {
        return false;
      }

      if (!returnFound && typeof val == 'function') {
        ctx.push(cx);
        val = this.lv(val, ctx, partials);
        ctx.pop();
      }

      return val;
    }
659286
function showHelp(specifiedScripts) {
    if (parsedArgv.help) {
      // if --help was specified, then yargs will show the default help
      log.info(help(psConfig))
      return true
    }
    const helpStyle = String(psConfig.options['help-style'])
    const hasDefaultScript = Boolean(psConfig.scripts.default)
    const noScriptSpecifiedAndNoDefault =
      !specifiedScripts.length && !hasDefaultScript
    const hasHelpScript = Boolean(psConfig.scripts.help)
    const commandIsHelp =
      isEqual(specifiedScripts[0], 'help') && !hasHelpScript
    const shouldShowSpecificScriptHelp =
      commandIsHelp && specifiedScripts.length > 1
    if (shouldShowSpecificScriptHelp) {
      log.info(specificHelpScript(psConfig, specifiedScripts[1]))
      return true
    } else if (commandIsHelp || noScriptSpecifiedAndNoDefault) {
      // Can't achieve 100% branch coverage without refactoring this showHelp()
      // function into ./index.js and re-working existing tests and such. Branch
      // options aren't relevant here either, so telling Istanbul to ignore.
      /* istanbul ignore next */
      if (helpStyle === 'all') {
        parser.showHelp('log')
      }
      log.info(help(psConfig))
      return true
    }

    return false
  }