/* TODO(nednguyen): fix this implementation on windows
337758
function(a) {
      if (this.isAbs(a))
        return a;

      if (a.startsWith('./'))
        a = a.substring(2);
      var res = this.join(this.currentWorkingDirectory, a);
      return this.normPath(res);
    }
8955
function NvmApi () {
	var self = this;

	Object.defineProperty(this, "initialized", {
		"value": false,
		"enumerable": false,
		"writable": true
	});

	Object.defineProperty(this, "__data", {
		"value": {},
		"enumerable": false,
		"writable": true
	});

	// Get data for NVM wrapper
	Async.parallel([
		function (cb) {
			COMMANDS.current(function (err, version) {
				if (err) {
					return cb(err);
				}

				self.__data.current = version;
				cb();
			});
		},

		function (cb) {
			COMMANDS.nvmVersion(function (err, version) {
				if (err) {
					return cb(err);
				}

				self.__data.version = version;
				cb();
			});
		},

		function (cb) {
			COMMANDS.nodePath(function (err, path) {
				if (err) {
					return cb(err);
				}

				self.__data.which = path;
				cb();
			});
		},

		function (cb) {
			COMMANDS.list(function (err, versions) {
				if (err) {
					return cb(err);
				}

				if (versions.hasOwnProperty("current")) {
					delete versions.current;
				}

				self.__data.installed = versions;
				cb();
			});
		}
	], function (err) {
		if (err) {
			console.warn(
				"Error Calling NVM. Make sure it's properly installed and sourced."
			);

			console.error(err.stack || err.message || err);
			return;
		}

		self.initialized = true;

		if (self.__data.hasOwnProperty("callbacks")) {
			self.__data.callbacks.forEach(function (func) {
				func.call(self, self);
			});
		}
	});

	return this;
}
156606
@SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME")
    public static void fixPlatformPaths() {
        if (System.getProperty(LIB_PROP) == null) {
            // Set necessary parameters for seamless PC/SC access.
            // http://ludovicrousseau.blogspot.com.es/2013/03/oracle-javaxsmartcardio-failures.html
            if (System.getProperty("os.name").equalsIgnoreCase("Linux")) {
                // Only try loading 64b paths if JVM can use them.
                if (System.getProperty("os.arch").contains("64")) {
                    if (new File(debian64_path).exists()) {
                        System.setProperty(LIB_PROP, debian64_path);
                    } else if (new File(fedora64_path).exists()) {
                        System.setProperty(LIB_PROP, fedora64_path);
                    } else if (new File(ubuntu64_path).exists()) {
                        System.setProperty(LIB_PROP, ubuntu64_path);
                    }
                } else if (new File(ubuntu_path).exists()) {
                    System.setProperty(LIB_PROP, ubuntu_path);
                } else if (new File(ubuntu32_path).exists()) {
                    System.setProperty(LIB_PROP, ubuntu32_path);
                } else if (new File(raspbian_path).exists()) {
                    System.setProperty(LIB_PROP, raspbian_path);
                } else {
                    // XXX: dlopen() works properly on Debian OpenJDK 7
                    // System.err.println("Hint: pcsc-lite probably missing.");
                }
            } else if (System.getProperty("os.name").equalsIgnoreCase("FreeBSD")) {
                if (new File(freebsd_path).exists()) {
                    System.setProperty(LIB_PROP, freebsd_path);
                } else {
                    System.err.println("Hint: pcsc-lite is missing. pkg install devel/libccid");
                }
            }
        } else {
            // TODO: display some helpful information?
        }
    }
164326
private void init(final Window window) {

        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        m_warningIcon.setContentMode(ContentMode.HTML);
        m_warningIcon.setValue(FontOpenCms.WARNING.getHtml());
        if (window != null) {
            m_cancel.addClickListener(e -> window.close());
        }
        m_table.setWidth("100%");
        m_table.setHeight("100%");

        List<CmsModuleRow> rows = new ArrayList<CmsModuleRow>();
        for (CmsModule module : OpenCms.getModuleManager().getAllInstalledModules()) {
            CmsModuleRow row = new CmsModuleRow(module);
            rows.add(row);
        }
        CmsBeanTableBuilder<CmsModuleRow> builder = CmsBeanTableBuilder.newInstance(CmsModuleRow.class);
        builder.buildTable(m_table, rows);
        m_table.setCellStyleGenerator(builder.getDefaultCellStyleGenerator());
        m_table.setItemIconPropertyId("icon");
        m_table.setRowHeaderMode(RowHeaderMode.ICON_ONLY);
        m_table.setSelectable(true);
        m_table.setVisibleColumns("name", "title");
        m_table.setSortContainerPropertyId("name");
        m_table.sort();

        m_filter.setIcon(FontOpenCms.FILTER);
        m_filter.setInputPrompt(
            Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_EXPLORER_FILTER_0));
        m_filter.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
        m_filter.addTextChangeListener(new TextChangeListener() {

            public void textChange(TextChangeEvent event) {

                filterTable(event.getText());

            }
        });
    }
91313
function _changeEncodingAndReloadDoc(document) {
        var promise = document.reload();
        promise.done(function (text, readTimestamp) {
            encodingSelect.$button.text(document.file._encoding);
            // Store the preferred encoding in the state
            var projectRoot = ProjectManager.getProjectRoot(),
                context = {
                    location : {
                        scope: "user",
                        layer: "project",
                        layerID: projectRoot.fullPath
                    }
                };
            var encoding = PreferencesManager.getViewState("encoding", context);
            encoding[document.file.fullPath] = document.file._encoding;
            PreferencesManager.setViewState("encoding", encoding, context);
        });
        promise.fail(function (error) {
            console.log("Error reloading contents of " + document.file.fullPath, error);
        });
    }
132909
function fixDoubleBlack(stack) {
  var n, p, s, z
  for(var i=stack.length-1; i>=0; --i) {
    n = stack[i]
    if(i === 0) {
      n._color = BLACK
      return
    }
    //console.log("visit node:", n.key, i, stack[i].key, stack[i-1].key)
    p = stack[i-1]
    if(p.left === n) {
      //console.log("left child")
      s = p.right
      if(s.right && s.right._color === RED) {
        //console.log("case 1: right sibling child red")
        s = p.right = cloneNode(s)
        z = s.right = cloneNode(s.right)
        p.right = s.left
        s.left = p
        s.right = z
        s._color = p._color
        n._color = BLACK
        p._color = BLACK
        z._color = BLACK
        recount(p)
        recount(s)
        if(i > 1) {
          var pp = stack[i-2]
          if(pp.left === p) {
            pp.left = s
          } else {
            pp.right = s
          }
        }
        stack[i-1] = s
        return
      } else if(s.left && s.left._color === RED) {
        //console.log("case 1: left sibling child red")
        s = p.right = cloneNode(s)
        z = s.left = cloneNode(s.left)
        p.right = z.left
        s.left = z.right
        z.left = p
        z.right = s
        z._color = p._color
        p._color = BLACK
        s._color = BLACK
        n._color = BLACK
        recount(p)
        recount(s)
        recount(z)
        if(i > 1) {
          var pp = stack[i-2]
          if(pp.left === p) {
            pp.left = z
          } else {
            pp.right = z
          }
        }
        stack[i-1] = z
        return
      }
      if(s._color === BLACK) {
        if(p._color === RED) {
          //console.log("case 2: black sibling, red parent", p.right.value)
          p._color = BLACK
          p.right = repaint(RED, s)
          return
        } else {
          //console.log("case 2: black sibling, black parent", p.right.value)
          p.right = repaint(RED, s)
          continue  
        }
      } else {
        //console.log("case 3: red sibling")
        s = cloneNode(s)
        p.right = s.left
        s.left = p
        s._color = p._color
        p._color = RED
        recount(p)
        recount(s)
        if(i > 1) {
          var pp = stack[i-2]
          if(pp.left === p) {
            pp.left = s
          } else {
            pp.right = s
          }
        }
        stack[i-1] = s
        stack[i] = p
        if(i+1 < stack.length) {
          stack[i+1] = n
        } else {
          stack.push(n)
        }
        i = i+2
      }
    } else {
      //console.log("right child")
      s = p.left
      if(s.left && s.left._color === RED) {
        //console.log("case 1: left sibling child red", p.value, p._color)
        s = p.left = cloneNode(s)
        z = s.left = cloneNode(s.left)
        p.left = s.right
        s.right = p
        s.left = z
        s._color = p._color
        n._color = BLACK
        p._color = BLACK
        z._color = BLACK
        recount(p)
        recount(s)
        if(i > 1) {
          var pp = stack[i-2]
          if(pp.right === p) {
            pp.right = s
          } else {
            pp.left = s
          }
        }
        stack[i-1] = s
        return
      } else if(s.right && s.right._color === RED) {
        //console.log("case 1: right sibling child red")
        s = p.left = cloneNode(s)
        z = s.right = cloneNode(s.right)
        p.left = z.right
        s.right = z.left
        z.right = p
        z.left = s
        z._color = p._color
        p._color = BLACK
        s._color = BLACK
        n._color = BLACK
        recount(p)
        recount(s)
        recount(z)
        if(i > 1) {
          var pp = stack[i-2]
          if(pp.right === p) {
            pp.right = z
          } else {
            pp.left = z
          }
        }
        stack[i-1] = z
        return
      }
      if(s._color === BLACK) {
        if(p._color === RED) {
          //console.log("case 2: black sibling, red parent")
          p._color = BLACK
          p.left = repaint(RED, s)
          return
        } else {
          //console.log("case 2: black sibling, black parent")
          p.left = repaint(RED, s)
          continue  
        }
      } else {
        //console.log("case 3: red sibling")
        s = cloneNode(s)
        p.left = s.right
        s.right = p
        s._color = p._color
        p._color = RED
        recount(p)
        recount(s)
        if(i > 1) {
          var pp = stack[i-2]
          if(pp.right === p) {
            pp.right = s
          } else {
            pp.left = s
          }
        }
        stack[i-1] = s
        stack[i] = p
        if(i+1 < stack.length) {
          stack[i+1] = n
        } else {
          stack.push(n)
        }
        i = i+2
      }
    }
  }
}
278076
function bnpDAddOffset(n,w) {
  while(this.t <= w) this[this.t++] = 0;
  this[w] += n;
  while(this[w] >= this.DV) {
    this[w] -= this.DV;
    if(++w >= this.t) this[this.t++] = 0;
    ++this[w];
  }
}
691360
void removeWindow(FileWindow w) {
        fileWindows.remove(w.getUrl());
        JMenu windowMenu = getWindowMenu();
        int count = windowMenu.getItemCount();
        JMenuItem lastItem = windowMenu.getItem(count -1);
        String name = getShortName(w.getUrl());
        for (int i = 5; i < count; i++) {
            JMenuItem item = windowMenu.getItem(i);
            if (item == null) continue; // separator
            String text = item.getText();
            //1 D:\foo.js
            //2 D:\bar.js
            int pos = text.indexOf(' ');
            if (text.substring(pos + 1).equals(name)) {
                windowMenu.remove(item);
                // Cascade    [0]
                // Tile       [1]
                // -------    [2]
                // Console    [3]
                // -------    [4]
                if (count == 6) {
                    // remove the final separator
                    windowMenu.remove(4);
                } else {
                    int j = i - 4;
                    for (;i < count -1; i++) {
                        JMenuItem thisItem = windowMenu.getItem(i);
                        if (thisItem != null) {
                            //1 D:\foo.js
                            //2 D:\bar.js
                            text = thisItem.getText();
                            if (text.equals("More Windows...")) {
                                break;
                            }
                            pos = text.indexOf(' ');
                            thisItem.setText((char)('0' + j) + " " +
                                             text.substring(pos + 1));
                            thisItem.setMnemonic('0' + j);
                            j++;
                        }
                    }
                    if (count - 6 == 0 && lastItem != item) {
                        if (lastItem.getText().equals("More Windows...")) {
                            windowMenu.remove(lastItem);
                        }
                    }
                }
                break;
            }
        }
        windowMenu.revalidate();
    }
1204045
function (fname) {

    _sclose();

    var num = 3;
    var fd  = null;
    while (!fd && num > 0) {
      try {
        fd = fs.openSync(fname, 'a+', 420);
      } catch (e) {
        if ('ENOENT' === e.code) {
          try {
            mkdirp.sync(path.dirname(fname), 493);  /**<  0755  */
          } catch (e) {
          }
        }
      }
      num--;
    }

    _inode_ = 0;
    _stream = fs.createWriteStream(fname, {'fd' : fd || 1, 'encoding' : 'utf8'});
    _stream.on('error', function (e) {});
  }
822395
private void throwCannotInstanciateUnsupported(EJBBinding binding,
                                                   JavaColonNamespace jndiType,
                                                   String lookupName,
                                                   String messageId) throws NameNotFoundException {
        J2EEName j2eeName = getJ2EEName(binding);
        String jndiName = jndiType.toString() + "/" + lookupName;
        String msgTxt = Tr.formatMessage(tc, messageId,
                                         binding.interfaceName,
                                         j2eeName.getComponent(),
                                         j2eeName.getModule(),
                                         j2eeName.getApplication(),
                                         jndiName);
        throw (new NameNotFoundException(msgTxt));
    }
1102339
function gli_window_put_string(win, val) {
    var ix, ch;

    //### might be efficient to split the implementation up into
    //### gli_window_buffer_put_string(), etc, since many functions
    //### know the window type when they call this
    switch (win.type) {
    case Const.wintype_TextBuffer:
        if (win.style != win.accumstyle
            || win.hyperlink != win.accumhyperlink)
            gli_window_buffer_deaccumulate(win);
        win.accum.push(val);
        break;
    case Const.wintype_TextGrid:
        for (ix=0; ix<val.length; ix++) {
            ch = val.charAt(ix);

            /* Canonicalize the cursor position. This is like calling
               gli_window_grid_canonicalize(), but I've inlined it. */
            if (win.cursorx < 0)
                win.cursorx = 0;
            else if (win.cursorx >= win.gridwidth) {
                win.cursorx = 0;
                win.cursory++;
            }
            if (win.cursory < 0)
                win.cursory = 0;
            else if (win.cursory >= win.gridheight)
                break; /* outside the window */

            if (ch == "\n") {
                /* a newline just moves the cursor. */
                win.cursory++;
                win.cursorx = 0;
                continue;
            }

            lineobj = win.lines[win.cursory];
            lineobj.dirty = true;
            lineobj.chars[win.cursorx] = ch;
            lineobj.styles[win.cursorx] = win.style;
            lineobj.hyperlinks[win.cursorx] = win.hyperlink;

            win.cursorx++;
            /* We can leave the cursor outside the window, since it will be
               canonicalized next time a character is printed. */
        }
        break;
    }
}
506440
public final void mFUNCT() throws RecognitionException {
        try {
            int _type = FUNCT;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // C:\\Project\\Obdalib\\obdalib-parent\\obdalib-core\\src\\main\\java\\it\\unibz\\inf\\obda\\gui\\swing\\utils\\MappingFilter.g:122:6: ( ( 'F' | 'f' ) ( 'U' | 'u' ) ( 'N' | 'n' ) ( 'C' | 'c' ) ( 'T' | 't' ) )
            // C:\\Project\\Obdalib\\obdalib-parent\\obdalib-core\\src\\main\\java\\it\\unibz\\inf\\obda\\gui\\swing\\utils\\MappingFilter.g:122:8: ( 'F' | 'f' ) ( 'U' | 'u' ) ( 'N' | 'n' ) ( 'C' | 'c' ) ( 'T' | 't' )
            {
            if ( input.LA(1)=='F'||input.LA(1)=='f' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            if ( input.LA(1)=='U'||input.LA(1)=='u' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            if ( input.LA(1)=='N'||input.LA(1)=='n' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            if ( input.LA(1)=='C'||input.LA(1)=='c' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            if ( input.LA(1)=='T'||input.LA(1)=='t' ) {
                input.consume();
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                recover(mse);
                throw mse;
            }


            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        	// do for sure before leaving
        }
    }
1367994
public static void main(String[] args) throws Exception {

    SAXProcessor sp = new SAXProcessor();

    // data
    //
    double[] dat = TSProcessor.readFileColumn(DAT_FNAME, 1, 0);
    // TSProcessor tp = new TSProcessor();
    // double[] dat = tp.readTS("src/resources/dataset/asys40.txt", 0);
    // double[] dat = TSProcessor.readFileColumn(filename, columnIdx,
    // sizeLimit)FileColumn(DAT_FNAME, 1, 0);
    LOGGER.info("read {} points from {}", dat.length, DAT_FNAME);

    String str = "win_width: " + cPoint + "; SAX: W " + SAX_WINDOW_SIZE + ", P " + SAX_PAA_SIZE
        + ", A " + SAX_ALPHABET_SIZE + ", STR " + SAX_NR_STRATEGY.toString();

    int frameCounter = 0;
    int startOffset = cPoint;
    while (cPoint < dat.length - startOffset - 1) {

      if (0 == cPoint % 2) {

        BufferedImage tsChart = getChart(dat, cPoint);

        // bitmap 1
        //
        double[] win1 = Arrays.copyOfRange(dat, cPoint - startOffset, cPoint);
        Map<String, Integer> shingledData1 = sp.ts2Shingles(win1, SAX_WINDOW_SIZE, SAX_PAA_SIZE,
            SAX_ALPHABET_SIZE, SAX_NR_STRATEGY, SAX_NORM_THRESHOLD, SHINGLE_SIZE);
        BufferedImage pam1 = getHeatMap(shingledData1, "pre-window");

        double[] win2 = Arrays.copyOfRange(dat, cPoint, cPoint + startOffset);
        Map<String, Integer> shingledData2 = sp.ts2Shingles(win2, SAX_WINDOW_SIZE, SAX_PAA_SIZE,
            SAX_ALPHABET_SIZE, SAX_NR_STRATEGY, SAX_NORM_THRESHOLD, SHINGLE_SIZE);
        BufferedImage pam2 = getHeatMap(shingledData2, "post-window");

        // the assemble
        //
        BufferedImage target = new BufferedImage(800, 530, BufferedImage.TYPE_INT_ARGB);
        Graphics targetGraphics = target.getGraphics();
        targetGraphics.setColor(Color.WHITE);
        targetGraphics.fillRect(0, 0, 799, 529);

        targetGraphics.drawImage(tsChart, 0, 0, null);

        targetGraphics.drawImage(pam1, 10, 410, null);// draws the first image onto it

        targetGraphics.drawImage(pam2, 120, 410, null);// draws the first image onto it

        targetGraphics.setColor(Color.RED);
        targetGraphics.setFont(new Font("monospaced", Font.PLAIN, 16));
        targetGraphics.drawString(str, 300, 420);

        targetGraphics.setColor(Color.BLUE);
        targetGraphics.setFont(new Font("monospaced", Font.PLAIN, 24));
        double dist = ed.distance(toVector(shingledData1), toVector(shingledData2));
        targetGraphics.drawString("ED=" + df.format(dist), 300, 480);

        // String fileName = new SimpleDateFormat("yyyyMMddhhmmssSS'.png'").format(new Date());
        File outputfile = new File("dframe" + String.format("%04d", frameCounter) + ".png");
        ImageIO.write(target, "png", outputfile);
        frameCounter++;
      }

      cPoint++;
    }
  }
1263767
function(window) {
    // fix low-level stat names and return Map instead of object.
    var ortcObjects = ['RTCRtpSender', 'RTCRtpReceiver', 'RTCIceGatherer',
      'RTCIceTransport', 'RTCDtlsTransport'];
    ortcObjects.forEach(function(ortcObjectName) {
      var obj = window[ortcObjectName];
      if (obj && obj.prototype && obj.prototype.getStats) {
        var nativeGetstats = obj.prototype.getStats;
        obj.prototype.getStats = function() {
          return nativeGetstats.apply(this)
            .then(function(nativeStats) {
              var mapStats = new Map();
              Object.keys(nativeStats).forEach(function(id) {
                nativeStats[id].type = fixStatsType(nativeStats[id]);
                mapStats.set(id, nativeStats[id]);
              });
              return mapStats;
            });
        };
      }
    });
  }
1250926
function(str) {
            var root, error = null;

            i = j = current = 0;
            chunks = [];
            input = str.replace(/\r\n/g, '\n');
            if (env.filename) {
                that.env.inputs[env.filename] = input;
            }

            // Split the input into chunks.
            chunks = (function (chunks) {
                var j = 0,
                    skip = /(?:@\{[\w-]+\}|[^"'`\{\}\/\(\)\\])+/g,
                    comment = /\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g,
                    string = /"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'|`((?:[^`]|\\.)*)`/g,
                    level = 0,
                    match,
                    chunk = chunks[0],
                    inParam;

                for (var i = 0, c, cc; i < input.length;) {
                    skip.lastIndex = i;
                    match = skip.exec(input);
                    if (match) {
                        if (match.index === i) {
                            i += match[0].length;
                            chunk.push(match[0]);
                        }
                    }
                    c = input.charAt(i);
                    comment.lastIndex = string.lastIndex = i;

                    match = string.exec(input)
                    if (match) {
                        if (match.index === i) {
                            i += match[0].length;
                            chunk.push(match[0]);
                            continue;
                        }
                    }

                    if (!inParam && c === '/') {
                        cc = input.charAt(i + 1);
                        if (cc === '/' || cc === '*') {
                            match = comment.exec(input);
                            if (match) {
                                if (match.index === i) {
                                    i += match[0].length;
                                    chunk.push(match[0]);
                                    continue;
                                }
                            }
                        }
                    }

                    switch (c) {
                        case '{':
                            if (!inParam) {
                                level ++;
                            }
                            else {
                                inParam = false;
                            }
                            chunk.push(c);
                            break;
                        case '}':
                            if (!inParam) {
                                level --;
                                chunk.push(c);
                                chunks[++j] = chunk = [];
                            }
                            else {
                                inParam = false;
                                chunk.push(c);
                            }
                            break;
                        case '(':
                            if (!inParam) {
                                inParam = true;
                            }
                            else {
                                inParam = false;
                            }
                            chunk.push(c);
                            break;
                        case ')':
                            if (inParam) {
                                inParam = false;
                            }
                            chunk.push(c);
                            break;
                        default:
                            chunk.push(c);
                    }

                    i++;
                }
                if (level !== 0) {
                    error = {
                        index: i - 1,
                        message: (level > 0) ? "missing closing `}`" : "missing opening `{`",
                        filename: env.filename
                    };
                }

                return chunks.map(function (c) { return c.join(''); });
            })([[]]);

            if (error) {
                util.error(env, error);
                throw new Error('N/A');
            }

            // Start with the primary rule.
            // The whole syntax tree is held under a Ruleset node,
            // with the `root` property set to true, so no `{}` are
            // output.
            root = new tree.Ruleset([], $(this.parsers.primary));
            root.root = true;

            // Get an array of Ruleset objects, flattened
            // and sorted according to specificitySort
            root.toList = (function() {
                return function(env) {
                    env.frames = env.frames || [];


                    // call populates Invalid-caused errors
                    var definitions = this.flatten([], [], env);
                    definitions.sort(specificitySort);
                    return definitions;
                };
            })();

            // Sort rules by specificity: this function expects selectors to be
            // split already.
            //
            // Written to be used as a .sort(Function);
            // argument.
            //
            // [1, 0, 0, 467] > [0, 0, 1, 520]
            var specificitySort = function(a, b) {
                var as = a.specificity;
                var bs = b.specificity;

                if (as[0] != bs[0]) return bs[0] - as[0];
                if (as[1] != bs[1]) return bs[1] - as[1];
                if (as[2] != bs[2]) return bs[2] - as[2];
                return bs[3] - as[3];
            };

            return root;
        }
1093201
function setupWindow(win, conn) {
  win.on('inputChar', function (c, i) {
    if (i === nc.keys.ESC) {
      var items = {};
      for (var i=0; i<connections.length; i++) {
        items[connections[i].client.opt.server] = connections[i].wins.status;
        for (var j=0,chans=Object.keys(connections[i].wins.channels); j<chans.length; j++)
          items['  ' + chans[j]] = connections[i].wins.channels[chans[j]];
        for (var j=0,queries=Object.keys(connections[i].wins.queries); j<queries.length; j++)
          items['  Q:' + queries[j]] = connections[i].wins.queries[queries[j]];
      }
      widgets.ListBox(items,
        {
          title: 'Windows',
          height: Math.min(Object.keys(items).length+2, nc.lines-2),
          style: {
            colors: {
              bg: 'blue',
              fg: 'white'
            }
          }
        }, function(window) {
          if (window)
            window.top();
          nc.redraw();
      });
    } else if (i === nc.keys.BACKSPACE && win.curx > 0) {
      win.inbuffer = win.inbuffer.substring(0, win.curx - 1) + win.inbuffer.substring(win.curx);
      win.delch(win.height-1, win.curx - 1);
      win.refresh();
    } else if (i === nc.keys.DEL) {
      win.inbuffer = win.inbuffer.substring(0, win.curx) + win.inbuffer.substring(win.curx + 1);
      win.delch(win.height-1, win.curx);
      win.refresh();
    } else if (i === nc.keys.LEFT && win.curx > 0) {
      win.cursor(win.height-1, win.curx-1);
      win.refresh();
    } else if (i === nc.keys.RIGHT && win.curx < win.inbuffer.length) {
      win.cursor(win.height-1, win.curx+1);
      win.refresh();
    } else if (i === nc.keys.END) {
      win.cursor(win.height-1, win.inbuffer.length);
      win.refresh();
    } else if (i === nc.keys.HOME) {
      win.cursor(win.height-1, 0);
      win.refresh();
	  } else if (i === nc.keys.NEWLINE) {
	    if (win.inbuffer.length) {
	      if (win.inbuffer[0] === '/') {
  	      var cmd = win.inbuffer.substring(1).split(' ', 1).join('').trim(),
  	          args = win.inbuffer.substring(win.inbuffer.indexOf(cmd)+cmd.length+1).trim();
	        switch (cmd.toLowerCase()) {
            case 'j':
	          case 'join':
              if (args.length) {
                if (args[0] !== '#' && args[0] !== '&'
                    && args[0] !== '+' && args[0] !== '!')
                  args = "#" + args;
                if (args.length > 1 && !conn.wins.channels[args])
                  conn.client.join(args);
              }
	          break;
            case 'part':
              var name = getWinName(win, conn);
              if (name[0] === '#' || name[0] === '&'
                  || name[0] === '+' || name[0] === '!') {
                conn.client.part(name);
                delete conn.wins.channels[name];
              }
            break;
	          case 'msg':
	            var who = args.substring(0, args.indexOf(' ')),
	                message = args.substring(args.indexOf(' ')+1);
	            if (!who.length || !message.length)
	              appendLine(win, 'Invalid arguments');
	            else {
	              conn.client.say(who, message);
	              appendLine(win, '* ->' + who + ': ' + message);
	            }
	          break;
	          case 'me':
	            if (win !== conn.wins.status) {
	              if (args.length) {
                  var key = getWinName(win, conn);
	                conn.client.say(key, CTCP_DELIM + 'ACTION ' + args + CTCP_DELIM);
  	              appendLine(win, '* ' + conn.client.nick + ' ' + args, COLOR_ACTION);
  	            }
	            } else
	              appendLine(win, 'That command is only valid on channel and query windows');
	          break;
            case 'whois':
              if (args.length) {
                conn.client.send('WHOIS', args, false);
              }
            break;
            case 'nick':
              if (args.length) {
                var newnick = args.split(' ', 1).join('');
                if (newnick) {
                  conn.client.prevnick = conn.client.nick;
                  conn.client.send("NICK", newnick);
                  conn.client.nick = newnick;
                }
              }
            break;
            case 'away':
              conn.client.send('AWAY', (args.length ? args : 'I am away'));
              appendLine(conn.wins.status, '* You have been marked as being away', nc.attrs.BOLD);
            break;
            case 'back':
              conn.client.send('AWAY');
              appendLine(conn.wins.status, '* You are no longer marked as being away', nc.attrs.BOLD);
            break;
            case 'exit':
	          case 'quit':
	            if (args.length)
  	            conn.client.disconnect(args);
  	          else
  	            conn.client.disconnect();
	            cleanup();
	          break;
	          case 'close':
	            if (win === conn.wins.status)
	              conn.client.disconnect();
	            else {
                var key = getWinName(win, conn);
                if (key[0] === '#' || key[0] === '&'
                    || key[0] === '+' || key[0] === '!') {
                  conn.client.part(key);
                  delete conn.wins.channels[key];
                } else
                  delete conn.wins.queries[key];
	            }
              win.close();
              nc.redraw();
              if (nc.numwins === 1)
                cleanup();
              return;
	          break;
	          case 'query':
	            var to = args.split(' ', 1).join('');
              if (!conn.wins.queries[to.toLowerCase()]) {
                var query = new nc.Window(nc.lines, nc.cols);
                setupWindow(query, conn);
                updateHeader(query, 'Query: ' + to, {pos: 'center'});
                conn.wins.queries[to.toLowerCase()] = query;
              }
	          break;
            case 'connect':
            break;
            case 'server':
            break;
            case 'whowas':
            break;
            case 'who':
            break;
            case 'info':
            break;
            case 'banlist':
            break;
            case 'notice':
            break;
            case 'invite':
            break;
            case 'ctcp':
            break;
	          default:
  	          appendLine(win, 'Unknown command: ' + cmd);
	        }
	      } else if (win.inbuffer.length && win !== conn.wins.status) {
          var key = getWinName(win, conn);
	        conn.client.say(key, win.inbuffer);
	        appendLine(win, '<' + conn.client.nick + '> ' + win.inbuffer);
	      }
	      win.inbuffer = "";
	      win.cursor(win.height-1, 0);
	      win.clrtoeol();
	      win.refresh();
	    }
	  } else if (i >= 32 && i <= 126 && win.curx < win.width-1) {
	    win.inbuffer = win.inbuffer.slice(0, win.curx) + c + win.inbuffer.slice(win.curx);

	    if (win.curx < win.inbuffer.length) {
	      win.insch(i);
	      win.cursor(win.height - 1, win.curx + 1);
	    } else {
	      win.addch(i);
	    }
	    
	    win.refresh();
	  }
  });
  win.scrollok(true);
  win.hline(win.height-2, 0, win.width);
  win.setscrreg(1, win.height-3); // Leave one line at the top for the header
  win.cursor(win.height-1, 0);
  win.refresh();
  win.inbuffer = "";
}
126459
void initInputsByIdMap() {
    inputsById.clear();
    for (CompilerInput input : externs) {
      InputId id = input.getInputId();
      CompilerInput previous = putCompilerInput(id, input);
      if (previous != null) {
        report(JSError.make(DUPLICATE_EXTERN_INPUT, input.getName()));
      }
    }
    for (CompilerInput input : moduleGraph.getAllInputs()) {
      InputId id = input.getInputId();
      CompilerInput previous = putCompilerInput(id, input);
      if (previous != null) {
        report(JSError.make(DUPLICATE_INPUT, input.getName()));
      }
    }
  }