removed dependency on built-editor.min.js
[ccsdk/distribution.git] / dgbuilder / public / ace / worker-json.js
1 "no use strict";
2 !(function(window) {
3 if (typeof window.window != "undefined" && window.document)
4     return;
5 if (window.require && window.define)
6     return;
7
8 if (!window.console) {
9     window.console = function() {
10         var msgs = Array.prototype.slice.call(arguments, 0);
11         postMessage({type: "log", data: msgs});
12     };
13     window.console.error =
14     window.console.warn = 
15     window.console.log =
16     window.console.trace = window.console;
17 }
18 window.window = window;
19 window.ace = window;
20
21 window.onerror = function(message, file, line, col, err) {
22     postMessage({type: "error", data: {
23         message: message,
24         data: err.data,
25         file: file,
26         line: line, 
27         col: col,
28         stack: err.stack
29     }});
30 };
31
32 window.normalizeModule = function(parentId, moduleName) {
33     // normalize plugin requires
34     if (moduleName.indexOf("!") !== -1) {
35         var chunks = moduleName.split("!");
36         return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]);
37     }
38     // normalize relative requires
39     if (moduleName.charAt(0) == ".") {
40         var base = parentId.split("/").slice(0, -1).join("/");
41         moduleName = (base ? base + "/" : "") + moduleName;
42         
43         while (moduleName.indexOf(".") !== -1 && previous != moduleName) {
44             var previous = moduleName;
45             moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
46         }
47     }
48     
49     return moduleName;
50 };
51
52 window.require = function require(parentId, id) {
53     if (!id) {
54         id = parentId;
55         parentId = null;
56     }
57     if (!id.charAt)
58         throw new Error("worker.js require() accepts only (parentId, id) as arguments");
59
60     id = window.normalizeModule(parentId, id);
61
62     var module = window.require.modules[id];
63     if (module) {
64         if (!module.initialized) {
65             module.initialized = true;
66             module.exports = module.factory().exports;
67         }
68         return module.exports;
69     }
70    
71     if (!window.require.tlns)
72         return console.log("unable to load " + id);
73     
74     var path = resolveModuleId(id, window.require.tlns);
75     if (path.slice(-3) != ".js") path += ".js";
76     
77     window.require.id = id;
78     window.require.modules[id] = {}; // prevent infinite loop on broken modules
79     importScripts(path);
80     return window.require(parentId, id);
81 };
82 function resolveModuleId(id, paths) {
83     var testPath = id, tail = "";
84     while (testPath) {
85         var alias = paths[testPath];
86         if (typeof alias == "string") {
87             return alias + tail;
88         } else if (alias) {
89             return  alias.location.replace(/\/*$/, "/") + (tail || alias.main || alias.name);
90         } else if (alias === false) {
91             return "";
92         }
93         var i = testPath.lastIndexOf("/");
94         if (i === -1) break;
95         tail = testPath.substr(i) + tail;
96         testPath = testPath.slice(0, i);
97     }
98     return id;
99 }
100 window.require.modules = {};
101 window.require.tlns = {};
102
103 window.define = function(id, deps, factory) {
104     if (arguments.length == 2) {
105         factory = deps;
106         if (typeof id != "string") {
107             deps = id;
108             id = window.require.id;
109         }
110     } else if (arguments.length == 1) {
111         factory = id;
112         deps = [];
113         id = window.require.id;
114     }
115     
116     if (typeof factory != "function") {
117         window.require.modules[id] = {
118             exports: factory,
119             initialized: true
120         };
121         return;
122     }
123
124     if (!deps.length)
125         // If there is no dependencies, we inject "require", "exports" and
126         // "module" as dependencies, to provide CommonJS compatibility.
127         deps = ["require", "exports", "module"];
128
129     var req = function(childId) {
130         return window.require(id, childId);
131     };
132
133     window.require.modules[id] = {
134         exports: {},
135         factory: function() {
136             var module = this;
137             var returnExports = factory.apply(this, deps.map(function(dep) {
138                 switch (dep) {
139                     // Because "require", "exports" and "module" aren't actual
140                     // dependencies, we must handle them seperately.
141                     case "require": return req;
142                     case "exports": return module.exports;
143                     case "module":  return module;
144                     // But for all other dependencies, we can just go ahead and
145                     // require them.
146                     default:        return req(dep);
147                 }
148             }));
149             if (returnExports)
150                 module.exports = returnExports;
151             return module;
152         }
153     };
154 };
155 window.define.amd = {};
156 require.tlns = {};
157 window.initBaseUrls  = function initBaseUrls(topLevelNamespaces) {
158     for (var i in topLevelNamespaces)
159         require.tlns[i] = topLevelNamespaces[i];
160 };
161
162 window.initSender = function initSender() {
163
164     var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter;
165     var oop = window.require("ace/lib/oop");
166     
167     var Sender = function() {};
168     
169     (function() {
170         
171         oop.implement(this, EventEmitter);
172                 
173         this.callback = function(data, callbackId) {
174             postMessage({
175                 type: "call",
176                 id: callbackId,
177                 data: data
178             });
179         };
180     
181         this.emit = function(name, data) {
182             postMessage({
183                 type: "event",
184                 name: name,
185                 data: data
186             });
187         };
188         
189     }).call(Sender.prototype);
190     
191     return new Sender();
192 };
193
194 var main = window.main = null;
195 var sender = window.sender = null;
196
197 window.onmessage = function(e) {
198     var msg = e.data;
199     if (msg.event && sender) {
200         sender._signal(msg.event, msg.data);
201     }
202     else if (msg.command) {
203         if (main[msg.command])
204             main[msg.command].apply(main, msg.args);
205         else if (window[msg.command])
206             window[msg.command].apply(window, msg.args);
207         else
208             throw new Error("Unknown command:" + msg.command);
209     }
210     else if (msg.init) {
211         window.initBaseUrls(msg.tlns);
212         require("ace/lib/es5-shim");
213         sender = window.sender = window.initSender();
214         var clazz = require(msg.module)[msg.classname];
215         main = window.main = new clazz(sender);
216     }
217 };
218 })(this);
219
220 define("ace/lib/oop",["require","exports","module"], function(require, exports, module) {
221 "use strict";
222
223 exports.inherits = function(ctor, superCtor) {
224     ctor.super_ = superCtor;
225     ctor.prototype = Object.create(superCtor.prototype, {
226         constructor: {
227             value: ctor,
228             enumerable: false,
229             writable: true,
230             configurable: true
231         }
232     });
233 };
234
235 exports.mixin = function(obj, mixin) {
236     for (var key in mixin) {
237         obj[key] = mixin[key];
238     }
239     return obj;
240 };
241
242 exports.implement = function(proto, mixin) {
243     exports.mixin(proto, mixin);
244 };
245
246 });
247
248 define("ace/range",["require","exports","module"], function(require, exports, module) {
249 "use strict";
250 var comparePoints = function(p1, p2) {
251     return p1.row - p2.row || p1.column - p2.column;
252 };
253 var Range = function(startRow, startColumn, endRow, endColumn) {
254     this.start = {
255         row: startRow,
256         column: startColumn
257     };
258
259     this.end = {
260         row: endRow,
261         column: endColumn
262     };
263 };
264
265 (function() {
266     this.isEqual = function(range) {
267         return this.start.row === range.start.row &&
268             this.end.row === range.end.row &&
269             this.start.column === range.start.column &&
270             this.end.column === range.end.column;
271     };
272     this.toString = function() {
273         return ("Range: [" + this.start.row + "/" + this.start.column +
274             "] -> [" + this.end.row + "/" + this.end.column + "]");
275     };
276
277     this.contains = function(row, column) {
278         return this.compare(row, column) == 0;
279     };
280     this.compareRange = function(range) {
281         var cmp,
282             end = range.end,
283             start = range.start;
284
285         cmp = this.compare(end.row, end.column);
286         if (cmp == 1) {
287             cmp = this.compare(start.row, start.column);
288             if (cmp == 1) {
289                 return 2;
290             } else if (cmp == 0) {
291                 return 1;
292             } else {
293                 return 0;
294             }
295         } else if (cmp == -1) {
296             return -2;
297         } else {
298             cmp = this.compare(start.row, start.column);
299             if (cmp == -1) {
300                 return -1;
301             } else if (cmp == 1) {
302                 return 42;
303             } else {
304                 return 0;
305             }
306         }
307     };
308     this.comparePoint = function(p) {
309         return this.compare(p.row, p.column);
310     };
311     this.containsRange = function(range) {
312         return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
313     };
314     this.intersects = function(range) {
315         var cmp = this.compareRange(range);
316         return (cmp == -1 || cmp == 0 || cmp == 1);
317     };
318     this.isEnd = function(row, column) {
319         return this.end.row == row && this.end.column == column;
320     };
321     this.isStart = function(row, column) {
322         return this.start.row == row && this.start.column == column;
323     };
324     this.setStart = function(row, column) {
325         if (typeof row == "object") {
326             this.start.column = row.column;
327             this.start.row = row.row;
328         } else {
329             this.start.row = row;
330             this.start.column = column;
331         }
332     };
333     this.setEnd = function(row, column) {
334         if (typeof row == "object") {
335             this.end.column = row.column;
336             this.end.row = row.row;
337         } else {
338             this.end.row = row;
339             this.end.column = column;
340         }
341     };
342     this.inside = function(row, column) {
343         if (this.compare(row, column) == 0) {
344             if (this.isEnd(row, column) || this.isStart(row, column)) {
345                 return false;
346             } else {
347                 return true;
348             }
349         }
350         return false;
351     };
352     this.insideStart = function(row, column) {
353         if (this.compare(row, column) == 0) {
354             if (this.isEnd(row, column)) {
355                 return false;
356             } else {
357                 return true;
358             }
359         }
360         return false;
361     };
362     this.insideEnd = function(row, column) {
363         if (this.compare(row, column) == 0) {
364             if (this.isStart(row, column)) {
365                 return false;
366             } else {
367                 return true;
368             }
369         }
370         return false;
371     };
372     this.compare = function(row, column) {
373         if (!this.isMultiLine()) {
374             if (row === this.start.row) {
375                 return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
376             }
377         }
378
379         if (row < this.start.row)
380             return -1;
381
382         if (row > this.end.row)
383             return 1;
384
385         if (this.start.row === row)
386             return column >= this.start.column ? 0 : -1;
387
388         if (this.end.row === row)
389             return column <= this.end.column ? 0 : 1;
390
391         return 0;
392     };
393     this.compareStart = function(row, column) {
394         if (this.start.row == row && this.start.column == column) {
395             return -1;
396         } else {
397             return this.compare(row, column);
398         }
399     };
400     this.compareEnd = function(row, column) {
401         if (this.end.row == row && this.end.column == column) {
402             return 1;
403         } else {
404             return this.compare(row, column);
405         }
406     };
407     this.compareInside = function(row, column) {
408         if (this.end.row == row && this.end.column == column) {
409             return 1;
410         } else if (this.start.row == row && this.start.column == column) {
411             return -1;
412         } else {
413             return this.compare(row, column);
414         }
415     };
416     this.clipRows = function(firstRow, lastRow) {
417         if (this.end.row > lastRow)
418             var end = {row: lastRow + 1, column: 0};
419         else if (this.end.row < firstRow)
420             var end = {row: firstRow, column: 0};
421
422         if (this.start.row > lastRow)
423             var start = {row: lastRow + 1, column: 0};
424         else if (this.start.row < firstRow)
425             var start = {row: firstRow, column: 0};
426
427         return Range.fromPoints(start || this.start, end || this.end);
428     };
429     this.extend = function(row, column) {
430         var cmp = this.compare(row, column);
431
432         if (cmp == 0)
433             return this;
434         else if (cmp == -1)
435             var start = {row: row, column: column};
436         else
437             var end = {row: row, column: column};
438
439         return Range.fromPoints(start || this.start, end || this.end);
440     };
441
442     this.isEmpty = function() {
443         return (this.start.row === this.end.row && this.start.column === this.end.column);
444     };
445     this.isMultiLine = function() {
446         return (this.start.row !== this.end.row);
447     };
448     this.clone = function() {
449         return Range.fromPoints(this.start, this.end);
450     };
451     this.collapseRows = function() {
452         if (this.end.column == 0)
453             return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0);
454         else
455             return new Range(this.start.row, 0, this.end.row, 0);
456     };
457     this.toScreenRange = function(session) {
458         var screenPosStart = session.documentToScreenPosition(this.start);
459         var screenPosEnd = session.documentToScreenPosition(this.end);
460
461         return new Range(
462             screenPosStart.row, screenPosStart.column,
463             screenPosEnd.row, screenPosEnd.column
464         );
465     };
466     this.moveBy = function(row, column) {
467         this.start.row += row;
468         this.start.column += column;
469         this.end.row += row;
470         this.end.column += column;
471     };
472
473 }).call(Range.prototype);
474 Range.fromPoints = function(start, end) {
475     return new Range(start.row, start.column, end.row, end.column);
476 };
477 Range.comparePoints = comparePoints;
478
479 Range.comparePoints = function(p1, p2) {
480     return p1.row - p2.row || p1.column - p2.column;
481 };
482
483
484 exports.Range = Range;
485 });
486
487 define("ace/apply_delta",["require","exports","module"], function(require, exports, module) {
488 "use strict";
489
490 function throwDeltaError(delta, errorText){
491     console.log("Invalid Delta:", delta);
492     throw "Invalid Delta: " + errorText;
493 }
494
495 function positionInDocument(docLines, position) {
496     return position.row    >= 0 && position.row    <  docLines.length &&
497            position.column >= 0 && position.column <= docLines[position.row].length;
498 }
499
500 function validateDelta(docLines, delta) {
501     if (delta.action != "insert" && delta.action != "remove")
502         throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
503     if (!(delta.lines instanceof Array))
504         throwDeltaError(delta, "delta.lines must be an Array");
505     if (!delta.start || !delta.end)
506        throwDeltaError(delta, "delta.start/end must be an present");
507     var start = delta.start;
508     if (!positionInDocument(docLines, delta.start))
509         throwDeltaError(delta, "delta.start must be contained in document");
510     var end = delta.end;
511     if (delta.action == "remove" && !positionInDocument(docLines, end))
512         throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
513     var numRangeRows = end.row - start.row;
514     var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
515     if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
516         throwDeltaError(delta, "delta.range must match delta lines");
517 }
518
519 exports.applyDelta = function(docLines, delta, doNotValidate) {
520     
521     var row = delta.start.row;
522     var startColumn = delta.start.column;
523     var line = docLines[row] || "";
524     switch (delta.action) {
525         case "insert":
526             var lines = delta.lines;
527             if (lines.length === 1) {
528                 docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
529             } else {
530                 var args = [row, 1].concat(delta.lines);
531                 docLines.splice.apply(docLines, args);
532                 docLines[row] = line.substring(0, startColumn) + docLines[row];
533                 docLines[row + delta.lines.length - 1] += line.substring(startColumn);
534             }
535             break;
536         case "remove":
537             var endColumn = delta.end.column;
538             var endRow = delta.end.row;
539             if (row === endRow) {
540                 docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
541             } else {
542                 docLines.splice(
543                     row, endRow - row + 1,
544                     line.substring(0, startColumn) + docLines[endRow].substring(endColumn)
545                 );
546             }
547             break;
548     }
549 };
550 });
551
552 define("ace/lib/event_emitter",["require","exports","module"], function(require, exports, module) {
553 "use strict";
554
555 var EventEmitter = {};
556 var stopPropagation = function() { this.propagationStopped = true; };
557 var preventDefault = function() { this.defaultPrevented = true; };
558
559 EventEmitter._emit =
560 EventEmitter._dispatchEvent = function(eventName, e) {
561     this._eventRegistry || (this._eventRegistry = {});
562     this._defaultHandlers || (this._defaultHandlers = {});
563
564     var listeners = this._eventRegistry[eventName] || [];
565     var defaultHandler = this._defaultHandlers[eventName];
566     if (!listeners.length && !defaultHandler)
567         return;
568
569     if (typeof e != "object" || !e)
570         e = {};
571
572     if (!e.type)
573         e.type = eventName;
574     if (!e.stopPropagation)
575         e.stopPropagation = stopPropagation;
576     if (!e.preventDefault)
577         e.preventDefault = preventDefault;
578
579     listeners = listeners.slice();
580     for (var i=0; i<listeners.length; i++) {
581         listeners[i](e, this);
582         if (e.propagationStopped)
583             break;
584     }
585     
586     if (defaultHandler && !e.defaultPrevented)
587         return defaultHandler(e, this);
588 };
589
590
591 EventEmitter._signal = function(eventName, e) {
592     var listeners = (this._eventRegistry || {})[eventName];
593     if (!listeners)
594         return;
595     listeners = listeners.slice();
596     for (var i=0; i<listeners.length; i++)
597         listeners[i](e, this);
598 };
599
600 EventEmitter.once = function(eventName, callback) {
601     var _self = this;
602     callback && this.addEventListener(eventName, function newCallback() {
603         _self.removeEventListener(eventName, newCallback);
604         callback.apply(null, arguments);
605     });
606 };
607
608
609 EventEmitter.setDefaultHandler = function(eventName, callback) {
610     var handlers = this._defaultHandlers;
611     if (!handlers)
612         handlers = this._defaultHandlers = {_disabled_: {}};
613     
614     if (handlers[eventName]) {
615         var old = handlers[eventName];
616         var disabled = handlers._disabled_[eventName];
617         if (!disabled)
618             handlers._disabled_[eventName] = disabled = [];
619         disabled.push(old);
620         var i = disabled.indexOf(callback);
621         if (i != -1) 
622             disabled.splice(i, 1);
623     }
624     handlers[eventName] = callback;
625 };
626 EventEmitter.removeDefaultHandler = function(eventName, callback) {
627     var handlers = this._defaultHandlers;
628     if (!handlers)
629         return;
630     var disabled = handlers._disabled_[eventName];
631     
632     if (handlers[eventName] == callback) {
633         var old = handlers[eventName];
634         if (disabled)
635             this.setDefaultHandler(eventName, disabled.pop());
636     } else if (disabled) {
637         var i = disabled.indexOf(callback);
638         if (i != -1)
639             disabled.splice(i, 1);
640     }
641 };
642
643 EventEmitter.on =
644 EventEmitter.addEventListener = function(eventName, callback, capturing) {
645     this._eventRegistry = this._eventRegistry || {};
646
647     var listeners = this._eventRegistry[eventName];
648     if (!listeners)
649         listeners = this._eventRegistry[eventName] = [];
650
651     if (listeners.indexOf(callback) == -1)
652         listeners[capturing ? "unshift" : "push"](callback);
653     return callback;
654 };
655
656 EventEmitter.off =
657 EventEmitter.removeListener =
658 EventEmitter.removeEventListener = function(eventName, callback) {
659     this._eventRegistry = this._eventRegistry || {};
660
661     var listeners = this._eventRegistry[eventName];
662     if (!listeners)
663         return;
664
665     var index = listeners.indexOf(callback);
666     if (index !== -1)
667         listeners.splice(index, 1);
668 };
669
670 EventEmitter.removeAllListeners = function(eventName) {
671     if (this._eventRegistry) this._eventRegistry[eventName] = [];
672 };
673
674 exports.EventEmitter = EventEmitter;
675
676 });
677
678 define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
679 "use strict";
680
681 var oop = require("./lib/oop");
682 var EventEmitter = require("./lib/event_emitter").EventEmitter;
683
684 var Anchor = exports.Anchor = function(doc, row, column) {
685     this.$onChange = this.onChange.bind(this);
686     this.attach(doc);
687     
688     if (typeof column == "undefined")
689         this.setPosition(row.row, row.column);
690     else
691         this.setPosition(row, column);
692 };
693
694 (function() {
695
696     oop.implement(this, EventEmitter);
697     this.getPosition = function() {
698         return this.$clipPositionToDocument(this.row, this.column);
699     };
700     this.getDocument = function() {
701         return this.document;
702     };
703     this.$insertRight = false;
704     this.onChange = function(delta) {
705         if (delta.start.row == delta.end.row && delta.start.row != this.row)
706             return;
707
708         if (delta.start.row > this.row)
709             return;
710             
711         var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight);
712         this.setPosition(point.row, point.column, true);
713     };
714     
715     function $pointsInOrder(point1, point2, equalPointsInOrder) {
716         var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
717         return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
718     }
719             
720     function $getTransformedPoint(delta, point, moveIfEqual) {
721         var deltaIsInsert = delta.action == "insert";
722         var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row    - delta.start.row);
723         var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
724         var deltaStart = delta.start;
725         var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
726         if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
727             return {
728                 row: point.row,
729                 column: point.column
730             };
731         }
732         if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
733             return {
734                 row: point.row + deltaRowShift,
735                 column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
736             };
737         }
738         
739         return {
740             row: deltaStart.row,
741             column: deltaStart.column
742         };
743     }
744     this.setPosition = function(row, column, noClip) {
745         var pos;
746         if (noClip) {
747             pos = {
748                 row: row,
749                 column: column
750             };
751         } else {
752             pos = this.$clipPositionToDocument(row, column);
753         }
754
755         if (this.row == pos.row && this.column == pos.column)
756             return;
757
758         var old = {
759             row: this.row,
760             column: this.column
761         };
762
763         this.row = pos.row;
764         this.column = pos.column;
765         this._signal("change", {
766             old: old,
767             value: pos
768         });
769     };
770     this.detach = function() {
771         this.document.removeEventListener("change", this.$onChange);
772     };
773     this.attach = function(doc) {
774         this.document = doc || this.document;
775         this.document.on("change", this.$onChange);
776     };
777     this.$clipPositionToDocument = function(row, column) {
778         var pos = {};
779
780         if (row >= this.document.getLength()) {
781             pos.row = Math.max(0, this.document.getLength() - 1);
782             pos.column = this.document.getLine(pos.row).length;
783         }
784         else if (row < 0) {
785             pos.row = 0;
786             pos.column = 0;
787         }
788         else {
789             pos.row = row;
790             pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
791         }
792
793         if (column < 0)
794             pos.column = 0;
795
796         return pos;
797     };
798
799 }).call(Anchor.prototype);
800
801 });
802
803 define("ace/document",["require","exports","module","ace/lib/oop","ace/apply_delta","ace/lib/event_emitter","ace/range","ace/anchor"], function(require, exports, module) {
804 "use strict";
805
806 var oop = require("./lib/oop");
807 var applyDelta = require("./apply_delta").applyDelta;
808 var EventEmitter = require("./lib/event_emitter").EventEmitter;
809 var Range = require("./range").Range;
810 var Anchor = require("./anchor").Anchor;
811
812 var Document = function(textOrLines) {
813     this.$lines = [""];
814     if (textOrLines.length === 0) {
815         this.$lines = [""];
816     } else if (Array.isArray(textOrLines)) {
817         this.insertMergedLines({row: 0, column: 0}, textOrLines);
818     } else {
819         this.insert({row: 0, column:0}, textOrLines);
820     }
821 };
822
823 (function() {
824
825     oop.implement(this, EventEmitter);
826     this.setValue = function(text) {
827         var len = this.getLength() - 1;
828         this.remove(new Range(0, 0, len, this.getLine(len).length));
829         this.insert({row: 0, column: 0}, text);
830     };
831     this.getValue = function() {
832         return this.getAllLines().join(this.getNewLineCharacter());
833     };
834     this.createAnchor = function(row, column) {
835         return new Anchor(this, row, column);
836     };
837     if ("aaa".split(/a/).length === 0) {
838         this.$split = function(text) {
839             return text.replace(/\r\n|\r/g, "\n").split("\n");
840         };
841     } else {
842         this.$split = function(text) {
843             return text.split(/\r\n|\r|\n/);
844         };
845     }
846
847
848     this.$detectNewLine = function(text) {
849         var match = text.match(/^.*?(\r\n|\r|\n)/m);
850         this.$autoNewLine = match ? match[1] : "\n";
851         this._signal("changeNewLineMode");
852     };
853     this.getNewLineCharacter = function() {
854         switch (this.$newLineMode) {
855           case "windows":
856             return "\r\n";
857           case "unix":
858             return "\n";
859           default:
860             return this.$autoNewLine || "\n";
861         }
862     };
863
864     this.$autoNewLine = "";
865     this.$newLineMode = "auto";
866     this.setNewLineMode = function(newLineMode) {
867         if (this.$newLineMode === newLineMode)
868             return;
869
870         this.$newLineMode = newLineMode;
871         this._signal("changeNewLineMode");
872     };
873     this.getNewLineMode = function() {
874         return this.$newLineMode;
875     };
876     this.isNewLine = function(text) {
877         return (text == "\r\n" || text == "\r" || text == "\n");
878     };
879     this.getLine = function(row) {
880         return this.$lines[row] || "";
881     };
882     this.getLines = function(firstRow, lastRow) {
883         return this.$lines.slice(firstRow, lastRow + 1);
884     };
885     this.getAllLines = function() {
886         return this.getLines(0, this.getLength());
887     };
888     this.getLength = function() {
889         return this.$lines.length;
890     };
891     this.getTextRange = function(range) {
892         return this.getLinesForRange(range).join(this.getNewLineCharacter());
893     };
894     this.getLinesForRange = function(range) {
895         var lines;
896         if (range.start.row === range.end.row) {
897             lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
898         } else {
899             lines = this.getLines(range.start.row, range.end.row);
900             lines[0] = (lines[0] || "").substring(range.start.column);
901             var l = lines.length - 1;
902             if (range.end.row - range.start.row == l)
903                 lines[l] = lines[l].substring(0, range.end.column);
904         }
905         return lines;
906     };
907     this.insertLines = function(row, lines) {
908         console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
909         return this.insertFullLines(row, lines);
910     };
911     this.removeLines = function(firstRow, lastRow) {
912         console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
913         return this.removeFullLines(firstRow, lastRow);
914     };
915     this.insertNewLine = function(position) {
916         console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.");
917         return this.insertMergedLines(position, ["", ""]);
918     };
919     this.insert = function(position, text) {
920         if (this.getLength() <= 1)
921             this.$detectNewLine(text);
922         
923         return this.insertMergedLines(position, this.$split(text));
924     };
925     this.insertInLine = function(position, text) {
926         var start = this.clippedPos(position.row, position.column);
927         var end = this.pos(position.row, position.column + text.length);
928         
929         this.applyDelta({
930             start: start,
931             end: end,
932             action: "insert",
933             lines: [text]
934         }, true);
935         
936         return this.clonePos(end);
937     };
938     
939     this.clippedPos = function(row, column) {
940         var length = this.getLength();
941         if (row === undefined) {
942             row = length;
943         } else if (row < 0) {
944             row = 0;
945         } else if (row >= length) {
946             row = length - 1;
947             column = undefined;
948         }
949         var line = this.getLine(row);
950         if (column == undefined)
951             column = line.length;
952         column = Math.min(Math.max(column, 0), line.length);
953         return {row: row, column: column};
954     };
955     
956     this.clonePos = function(pos) {
957         return {row: pos.row, column: pos.column};
958     };
959     
960     this.pos = function(row, column) {
961         return {row: row, column: column};
962     };
963     
964     this.$clipPosition = function(position) {
965         var length = this.getLength();
966         if (position.row >= length) {
967             position.row = Math.max(0, length - 1);
968             position.column = this.getLine(length - 1).length;
969         } else {
970             position.row = Math.max(0, position.row);
971             position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
972         }
973         return position;
974     };
975     this.insertFullLines = function(row, lines) {
976         row = Math.min(Math.max(row, 0), this.getLength());
977         var column = 0;
978         if (row < this.getLength()) {
979             lines = lines.concat([""]);
980             column = 0;
981         } else {
982             lines = [""].concat(lines);
983             row--;
984             column = this.$lines[row].length;
985         }
986         this.insertMergedLines({row: row, column: column}, lines);
987     };    
988     this.insertMergedLines = function(position, lines) {
989         var start = this.clippedPos(position.row, position.column);
990         var end = {
991             row: start.row + lines.length - 1,
992             column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
993         };
994         
995         this.applyDelta({
996             start: start,
997             end: end,
998             action: "insert",
999             lines: lines
1000         });
1001         
1002         return this.clonePos(end);
1003     };
1004     this.remove = function(range) {
1005         var start = this.clippedPos(range.start.row, range.start.column);
1006         var end = this.clippedPos(range.end.row, range.end.column);
1007         this.applyDelta({
1008             start: start,
1009             end: end,
1010             action: "remove",
1011             lines: this.getLinesForRange({start: start, end: end})
1012         });
1013         return this.clonePos(start);
1014     };
1015     this.removeInLine = function(row, startColumn, endColumn) {
1016         var start = this.clippedPos(row, startColumn);
1017         var end = this.clippedPos(row, endColumn);
1018         
1019         this.applyDelta({
1020             start: start,
1021             end: end,
1022             action: "remove",
1023             lines: this.getLinesForRange({start: start, end: end})
1024         }, true);
1025         
1026         return this.clonePos(start);
1027     };
1028     this.removeFullLines = function(firstRow, lastRow) {
1029         firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
1030         lastRow  = Math.min(Math.max(0, lastRow ), this.getLength() - 1);
1031         var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
1032         var deleteLastNewLine  = lastRow  < this.getLength() - 1;
1033         var startRow = ( deleteFirstNewLine ? firstRow - 1                  : firstRow                    );
1034         var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0                           );
1035         var endRow   = ( deleteLastNewLine  ? lastRow + 1                   : lastRow                     );
1036         var endCol   = ( deleteLastNewLine  ? 0                             : this.getLine(endRow).length ); 
1037         var range = new Range(startRow, startCol, endRow, endCol);
1038         var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
1039         
1040         this.applyDelta({
1041             start: range.start,
1042             end: range.end,
1043             action: "remove",
1044             lines: this.getLinesForRange(range)
1045         });
1046         return deletedLines;
1047     };
1048     this.removeNewLine = function(row) {
1049         if (row < this.getLength() - 1 && row >= 0) {
1050             this.applyDelta({
1051                 start: this.pos(row, this.getLine(row).length),
1052                 end: this.pos(row + 1, 0),
1053                 action: "remove",
1054                 lines: ["", ""]
1055             });
1056         }
1057     };
1058     this.replace = function(range, text) {
1059         if (!(range instanceof Range))
1060             range = Range.fromPoints(range.start, range.end);
1061         if (text.length === 0 && range.isEmpty())
1062             return range.start;
1063         if (text == this.getTextRange(range))
1064             return range.end;
1065
1066         this.remove(range);
1067         var end;
1068         if (text) {
1069             end = this.insert(range.start, text);
1070         }
1071         else {
1072             end = range.start;
1073         }
1074         
1075         return end;
1076     };
1077     this.applyDeltas = function(deltas) {
1078         for (var i=0; i<deltas.length; i++) {
1079             this.applyDelta(deltas[i]);
1080         }
1081     };
1082     this.revertDeltas = function(deltas) {
1083         for (var i=deltas.length-1; i>=0; i--) {
1084             this.revertDelta(deltas[i]);
1085         }
1086     };
1087     this.applyDelta = function(delta, doNotValidate) {
1088         var isInsert = delta.action == "insert";
1089         if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
1090             : !Range.comparePoints(delta.start, delta.end)) {
1091             return;
1092         }
1093         
1094         if (isInsert && delta.lines.length > 20000)
1095             this.$splitAndapplyLargeDelta(delta, 20000);
1096         applyDelta(this.$lines, delta, doNotValidate);
1097         this._signal("change", delta);
1098     };
1099     
1100     this.$splitAndapplyLargeDelta = function(delta, MAX) {
1101         var lines = delta.lines;
1102         var l = lines.length;
1103         var row = delta.start.row; 
1104         var column = delta.start.column;
1105         var from = 0, to = 0;
1106         do {
1107             from = to;
1108             to += MAX - 1;
1109             var chunk = lines.slice(from, to);
1110             if (to > l) {
1111                 delta.lines = chunk;
1112                 delta.start.row = row + from;
1113                 delta.start.column = column;
1114                 break;
1115             }
1116             chunk.push("");
1117             this.applyDelta({
1118                 start: this.pos(row + from, column),
1119                 end: this.pos(row + to, column = 0),
1120                 action: delta.action,
1121                 lines: chunk
1122             }, true);
1123         } while(true);
1124     };
1125     this.revertDelta = function(delta) {
1126         this.applyDelta({
1127             start: this.clonePos(delta.start),
1128             end: this.clonePos(delta.end),
1129             action: (delta.action == "insert" ? "remove" : "insert"),
1130             lines: delta.lines.slice()
1131         });
1132     };
1133     this.indexToPosition = function(index, startRow) {
1134         var lines = this.$lines || this.getAllLines();
1135         var newlineLength = this.getNewLineCharacter().length;
1136         for (var i = startRow || 0, l = lines.length; i < l; i++) {
1137             index -= lines[i].length + newlineLength;
1138             if (index < 0)
1139                 return {row: i, column: index + lines[i].length + newlineLength};
1140         }
1141         return {row: l-1, column: lines[l-1].length};
1142     };
1143     this.positionToIndex = function(pos, startRow) {
1144         var lines = this.$lines || this.getAllLines();
1145         var newlineLength = this.getNewLineCharacter().length;
1146         var index = 0;
1147         var row = Math.min(pos.row, lines.length);
1148         for (var i = startRow || 0; i < row; ++i)
1149             index += lines[i].length + newlineLength;
1150
1151         return index + pos.column;
1152     };
1153
1154 }).call(Document.prototype);
1155
1156 exports.Document = Document;
1157 });
1158
1159 define("ace/lib/lang",["require","exports","module"], function(require, exports, module) {
1160 "use strict";
1161
1162 exports.last = function(a) {
1163     return a[a.length - 1];
1164 };
1165
1166 exports.stringReverse = function(string) {
1167     return string.split("").reverse().join("");
1168 };
1169
1170 exports.stringRepeat = function (string, count) {
1171     var result = '';
1172     while (count > 0) {
1173         if (count & 1)
1174             result += string;
1175
1176         if (count >>= 1)
1177             string += string;
1178     }
1179     return result;
1180 };
1181
1182 var trimBeginRegexp = /^\s\s*/;
1183 var trimEndRegexp = /\s\s*$/;
1184
1185 exports.stringTrimLeft = function (string) {
1186     return string.replace(trimBeginRegexp, '');
1187 };
1188
1189 exports.stringTrimRight = function (string) {
1190     return string.replace(trimEndRegexp, '');
1191 };
1192
1193 exports.copyObject = function(obj) {
1194     var copy = {};
1195     for (var key in obj) {
1196         copy[key] = obj[key];
1197     }
1198     return copy;
1199 };
1200
1201 exports.copyArray = function(array){
1202     var copy = [];
1203     for (var i=0, l=array.length; i<l; i++) {
1204         if (array[i] && typeof array[i] == "object")
1205             copy[i] = this.copyObject(array[i]);
1206         else 
1207             copy[i] = array[i];
1208     }
1209     return copy;
1210 };
1211
1212 exports.deepCopy = function deepCopy(obj) {
1213     if (typeof obj !== "object" || !obj)
1214         return obj;
1215     var copy;
1216     if (Array.isArray(obj)) {
1217         copy = [];
1218         for (var key = 0; key < obj.length; key++) {
1219             copy[key] = deepCopy(obj[key]);
1220         }
1221         return copy;
1222     }
1223     if (Object.prototype.toString.call(obj) !== "[object Object]")
1224         return obj;
1225     
1226     copy = {};
1227     for (var key in obj)
1228         copy[key] = deepCopy(obj[key]);
1229     return copy;
1230 };
1231
1232 exports.arrayToMap = function(arr) {
1233     var map = {};
1234     for (var i=0; i<arr.length; i++) {
1235         map[arr[i]] = 1;
1236     }
1237     return map;
1238
1239 };
1240
1241 exports.createMap = function(props) {
1242     var map = Object.create(null);
1243     for (var i in props) {
1244         map[i] = props[i];
1245     }
1246     return map;
1247 };
1248 exports.arrayRemove = function(array, value) {
1249   for (var i = 0; i <= array.length; i++) {
1250     if (value === array[i]) {
1251       array.splice(i, 1);
1252     }
1253   }
1254 };
1255
1256 exports.escapeRegExp = function(str) {
1257     return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
1258 };
1259
1260 exports.escapeHTML = function(str) {
1261     return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
1262 };
1263
1264 exports.getMatchOffsets = function(string, regExp) {
1265     var matches = [];
1266
1267     string.replace(regExp, function(str) {
1268         matches.push({
1269             offset: arguments[arguments.length-2],
1270             length: str.length
1271         });
1272     });
1273
1274     return matches;
1275 };
1276 exports.deferredCall = function(fcn) {
1277     var timer = null;
1278     var callback = function() {
1279         timer = null;
1280         fcn();
1281     };
1282
1283     var deferred = function(timeout) {
1284         deferred.cancel();
1285         timer = setTimeout(callback, timeout || 0);
1286         return deferred;
1287     };
1288
1289     deferred.schedule = deferred;
1290
1291     deferred.call = function() {
1292         this.cancel();
1293         fcn();
1294         return deferred;
1295     };
1296
1297     deferred.cancel = function() {
1298         clearTimeout(timer);
1299         timer = null;
1300         return deferred;
1301     };
1302     
1303     deferred.isPending = function() {
1304         return timer;
1305     };
1306
1307     return deferred;
1308 };
1309
1310
1311 exports.delayedCall = function(fcn, defaultTimeout) {
1312     var timer = null;
1313     var callback = function() {
1314         timer = null;
1315         fcn();
1316     };
1317
1318     var _self = function(timeout) {
1319         if (timer == null)
1320             timer = setTimeout(callback, timeout || defaultTimeout);
1321     };
1322
1323     _self.delay = function(timeout) {
1324         timer && clearTimeout(timer);
1325         timer = setTimeout(callback, timeout || defaultTimeout);
1326     };
1327     _self.schedule = _self;
1328
1329     _self.call = function() {
1330         this.cancel();
1331         fcn();
1332     };
1333
1334     _self.cancel = function() {
1335         timer && clearTimeout(timer);
1336         timer = null;
1337     };
1338
1339     _self.isPending = function() {
1340         return timer;
1341     };
1342
1343     return _self;
1344 };
1345 });
1346
1347 define("ace/worker/mirror",["require","exports","module","ace/range","ace/document","ace/lib/lang"], function(require, exports, module) {
1348 "use strict";
1349
1350 var Range = require("../range").Range;
1351 var Document = require("../document").Document;
1352 var lang = require("../lib/lang");
1353     
1354 var Mirror = exports.Mirror = function(sender) {
1355     this.sender = sender;
1356     var doc = this.doc = new Document("");
1357     
1358     var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
1359     
1360     var _self = this;
1361     sender.on("change", function(e) {
1362         var data = e.data;
1363         if (data[0].start) {
1364             doc.applyDeltas(data);
1365         } else {
1366             for (var i = 0; i < data.length; i += 2) {
1367                 if (Array.isArray(data[i+1])) {
1368                     var d = {action: "insert", start: data[i], lines: data[i+1]};
1369                 } else {
1370                     var d = {action: "remove", start: data[i], end: data[i+1]};
1371                 }
1372                 doc.applyDelta(d, true);
1373             }
1374         }
1375         if (_self.$timeout)
1376             return deferredUpdate.schedule(_self.$timeout);
1377         _self.onUpdate();
1378     });
1379 };
1380
1381 (function() {
1382     
1383     this.$timeout = 500;
1384     
1385     this.setTimeout = function(timeout) {
1386         this.$timeout = timeout;
1387     };
1388     
1389     this.setValue = function(value) {
1390         this.doc.setValue(value);
1391         this.deferredUpdate.schedule(this.$timeout);
1392     };
1393     
1394     this.getValue = function(callbackId) {
1395         this.sender.callback(this.doc.getValue(), callbackId);
1396     };
1397     
1398     this.onUpdate = function() {
1399     };
1400     
1401     this.isPending = function() {
1402         return this.deferredUpdate.isPending();
1403     };
1404     
1405 }).call(Mirror.prototype);
1406
1407 });
1408
1409 define("ace/mode/json/json_parse",["require","exports","module"], function(require, exports, module) {
1410 "use strict";
1411
1412     var at,     // The index of the current character
1413         ch,     // The current character
1414         escapee = {
1415             '"':  '"',
1416             '\\': '\\',
1417             '/':  '/',
1418             b:    '\b',
1419             f:    '\f',
1420             n:    '\n',
1421             r:    '\r',
1422             t:    '\t'
1423         },
1424         text,
1425
1426         error = function (m) {
1427
1428             throw {
1429                 name:    'SyntaxError',
1430                 message: m,
1431                 at:      at,
1432                 text:    text
1433             };
1434         },
1435
1436         next = function (c) {
1437
1438             if (c && c !== ch) {
1439                 error("Expected '" + c + "' instead of '" + ch + "'");
1440             }
1441
1442             ch = text.charAt(at);
1443             at += 1;
1444             return ch;
1445         },
1446
1447         number = function () {
1448
1449             var number,
1450                 string = '';
1451
1452             if (ch === '-') {
1453                 string = '-';
1454                 next('-');
1455             }
1456             while (ch >= '0' && ch <= '9') {
1457                 string += ch;
1458                 next();
1459             }
1460             if (ch === '.') {
1461                 string += '.';
1462                 while (next() && ch >= '0' && ch <= '9') {
1463                     string += ch;
1464                 }
1465             }
1466             if (ch === 'e' || ch === 'E') {
1467                 string += ch;
1468                 next();
1469                 if (ch === '-' || ch === '+') {
1470                     string += ch;
1471                     next();
1472                 }
1473                 while (ch >= '0' && ch <= '9') {
1474                     string += ch;
1475                     next();
1476                 }
1477             }
1478             number = +string;
1479             if (isNaN(number)) {
1480                 error("Bad number");
1481             } else {
1482                 return number;
1483             }
1484         },
1485
1486         string = function () {
1487
1488             var hex,
1489                 i,
1490                 string = '',
1491                 uffff;
1492
1493             if (ch === '"') {
1494                 while (next()) {
1495                     if (ch === '"') {
1496                         next();
1497                         return string;
1498                     } else if (ch === '\\') {
1499                         next();
1500                         if (ch === 'u') {
1501                             uffff = 0;
1502                             for (i = 0; i < 4; i += 1) {
1503                                 hex = parseInt(next(), 16);
1504                                 if (!isFinite(hex)) {
1505                                     break;
1506                                 }
1507                                 uffff = uffff * 16 + hex;
1508                             }
1509                             string += String.fromCharCode(uffff);
1510                         } else if (typeof escapee[ch] === 'string') {
1511                             string += escapee[ch];
1512                         } else {
1513                             break;
1514                         }
1515                     } else {
1516                         string += ch;
1517                     }
1518                 }
1519             }
1520             error("Bad string");
1521         },
1522
1523         white = function () {
1524
1525             while (ch && ch <= ' ') {
1526                 next();
1527             }
1528         },
1529
1530         word = function () {
1531
1532             switch (ch) {
1533             case 't':
1534                 next('t');
1535                 next('r');
1536                 next('u');
1537                 next('e');
1538                 return true;
1539             case 'f':
1540                 next('f');
1541                 next('a');
1542                 next('l');
1543                 next('s');
1544                 next('e');
1545                 return false;
1546             case 'n':
1547                 next('n');
1548                 next('u');
1549                 next('l');
1550                 next('l');
1551                 return null;
1552             }
1553             error("Unexpected '" + ch + "'");
1554         },
1555
1556         value,  // Place holder for the value function.
1557
1558         array = function () {
1559
1560             var array = [];
1561
1562             if (ch === '[') {
1563                 next('[');
1564                 white();
1565                 if (ch === ']') {
1566                     next(']');
1567                     return array;   // empty array
1568                 }
1569                 while (ch) {
1570                     array.push(value());
1571                     white();
1572                     if (ch === ']') {
1573                         next(']');
1574                         return array;
1575                     }
1576                     next(',');
1577                     white();
1578                 }
1579             }
1580             error("Bad array");
1581         },
1582
1583         object = function () {
1584
1585             var key,
1586                 object = {};
1587
1588             if (ch === '{') {
1589                 next('{');
1590                 white();
1591                 if (ch === '}') {
1592                     next('}');
1593                     return object;   // empty object
1594                 }
1595                 while (ch) {
1596                     key = string();
1597                     white();
1598                     next(':');
1599                     if (Object.hasOwnProperty.call(object, key)) {
1600                         error('Duplicate key "' + key + '"');
1601                     }
1602                     object[key] = value();
1603                     white();
1604                     if (ch === '}') {
1605                         next('}');
1606                         return object;
1607                     }
1608                     next(',');
1609                     white();
1610                 }
1611             }
1612             error("Bad object");
1613         };
1614
1615     value = function () {
1616
1617         white();
1618         switch (ch) {
1619         case '{':
1620             return object();
1621         case '[':
1622             return array();
1623         case '"':
1624             return string();
1625         case '-':
1626             return number();
1627         default:
1628             return ch >= '0' && ch <= '9' ? number() : word();
1629         }
1630     };
1631
1632     return function (source, reviver) {
1633         var result;
1634
1635         text = source;
1636         at = 0;
1637         ch = ' ';
1638         result = value();
1639         white();
1640         if (ch) {
1641             error("Syntax error");
1642         }
1643
1644         return typeof reviver === 'function' ? function walk(holder, key) {
1645             var k, v, value = holder[key];
1646             if (value && typeof value === 'object') {
1647                 for (k in value) {
1648                     if (Object.hasOwnProperty.call(value, k)) {
1649                         v = walk(value, k);
1650                         if (v !== undefined) {
1651                             value[k] = v;
1652                         } else {
1653                             delete value[k];
1654                         }
1655                     }
1656                 }
1657             }
1658             return reviver.call(holder, key, value);
1659         }({'': result}, '') : result;
1660     };
1661 });
1662
1663 define("ace/mode/json_worker",["require","exports","module","ace/lib/oop","ace/worker/mirror","ace/mode/json/json_parse"], function(require, exports, module) {
1664 "use strict";
1665
1666 var oop = require("../lib/oop");
1667 var Mirror = require("../worker/mirror").Mirror;
1668 var parse = require("./json/json_parse");
1669
1670 var JsonWorker = exports.JsonWorker = function(sender) {
1671     Mirror.call(this, sender);
1672     this.setTimeout(200);
1673 };
1674
1675 oop.inherits(JsonWorker, Mirror);
1676
1677 (function() {
1678
1679     this.onUpdate = function() {
1680         var value = this.doc.getValue();
1681         var errors = [];
1682         try {
1683             if (value)
1684                 parse(value);
1685         } catch (e) {
1686             var pos = this.doc.indexToPosition(e.at-1);
1687             errors.push({
1688                 row: pos.row,
1689                 column: pos.column,
1690                 text: e.message,
1691                 type: "error"
1692             });
1693         }
1694         this.sender.emit("annotate", errors);
1695     };
1696
1697 }).call(JsonWorker.prototype);
1698
1699 });
1700
1701 define("ace/lib/es5-shim",["require","exports","module"], function(require, exports, module) {
1702
1703 function Empty() {}
1704
1705 if (!Function.prototype.bind) {
1706     Function.prototype.bind = function bind(that) { // .length is 1
1707         var target = this;
1708         if (typeof target != "function") {
1709             throw new TypeError("Function.prototype.bind called on incompatible " + target);
1710         }
1711         var args = slice.call(arguments, 1); // for normal call
1712         var bound = function () {
1713
1714             if (this instanceof bound) {
1715
1716                 var result = target.apply(
1717                     this,
1718                     args.concat(slice.call(arguments))
1719                 );
1720                 if (Object(result) === result) {
1721                     return result;
1722                 }
1723                 return this;
1724
1725             } else {
1726                 return target.apply(
1727                     that,
1728                     args.concat(slice.call(arguments))
1729                 );
1730
1731             }
1732
1733         };
1734         if(target.prototype) {
1735             Empty.prototype = target.prototype;
1736             bound.prototype = new Empty();
1737             Empty.prototype = null;
1738         }
1739         return bound;
1740     };
1741 }
1742 var call = Function.prototype.call;
1743 var prototypeOfArray = Array.prototype;
1744 var prototypeOfObject = Object.prototype;
1745 var slice = prototypeOfArray.slice;
1746 var _toString = call.bind(prototypeOfObject.toString);
1747 var owns = call.bind(prototypeOfObject.hasOwnProperty);
1748 var defineGetter;
1749 var defineSetter;
1750 var lookupGetter;
1751 var lookupSetter;
1752 var supportsAccessors;
1753 if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
1754     defineGetter = call.bind(prototypeOfObject.__defineGetter__);
1755     defineSetter = call.bind(prototypeOfObject.__defineSetter__);
1756     lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
1757     lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
1758 }
1759 if ([1,2].splice(0).length != 2) {
1760     if(function() { // test IE < 9 to splice bug - see issue #138
1761         function makeArray(l) {
1762             var a = new Array(l+2);
1763             a[0] = a[1] = 0;
1764             return a;
1765         }
1766         var array = [], lengthBefore;
1767         
1768         array.splice.apply(array, makeArray(20));
1769         array.splice.apply(array, makeArray(26));
1770
1771         lengthBefore = array.length; //46
1772         array.splice(5, 0, "XXX"); // add one element
1773
1774         lengthBefore + 1 == array.length
1775
1776         if (lengthBefore + 1 == array.length) {
1777             return true;// has right splice implementation without bugs
1778         }
1779     }()) {//IE 6/7
1780         var array_splice = Array.prototype.splice;
1781         Array.prototype.splice = function(start, deleteCount) {
1782             if (!arguments.length) {
1783                 return [];
1784             } else {
1785                 return array_splice.apply(this, [
1786                     start === void 0 ? 0 : start,
1787                     deleteCount === void 0 ? (this.length - start) : deleteCount
1788                 ].concat(slice.call(arguments, 2)))
1789             }
1790         };
1791     } else {//IE8
1792         Array.prototype.splice = function(pos, removeCount){
1793             var length = this.length;
1794             if (pos > 0) {
1795                 if (pos > length)
1796                     pos = length;
1797             } else if (pos == void 0) {
1798                 pos = 0;
1799             } else if (pos < 0) {
1800                 pos = Math.max(length + pos, 0);
1801             }
1802
1803             if (!(pos+removeCount < length))
1804                 removeCount = length - pos;
1805
1806             var removed = this.slice(pos, pos+removeCount);
1807             var insert = slice.call(arguments, 2);
1808             var add = insert.length;            
1809             if (pos === length) {
1810                 if (add) {
1811                     this.push.apply(this, insert);
1812                 }
1813             } else {
1814                 var remove = Math.min(removeCount, length - pos);
1815                 var tailOldPos = pos + remove;
1816                 var tailNewPos = tailOldPos + add - remove;
1817                 var tailCount = length - tailOldPos;
1818                 var lengthAfterRemove = length - remove;
1819
1820                 if (tailNewPos < tailOldPos) { // case A
1821                     for (var i = 0; i < tailCount; ++i) {
1822                         this[tailNewPos+i] = this[tailOldPos+i];
1823                     }
1824                 } else if (tailNewPos > tailOldPos) { // case B
1825                     for (i = tailCount; i--; ) {
1826                         this[tailNewPos+i] = this[tailOldPos+i];
1827                     }
1828                 } // else, add == remove (nothing to do)
1829
1830                 if (add && pos === lengthAfterRemove) {
1831                     this.length = lengthAfterRemove; // truncate array
1832                     this.push.apply(this, insert);
1833                 } else {
1834                     this.length = lengthAfterRemove + add; // reserves space
1835                     for (i = 0; i < add; ++i) {
1836                         this[pos+i] = insert[i];
1837                     }
1838                 }
1839             }
1840             return removed;
1841         };
1842     }
1843 }
1844 if (!Array.isArray) {
1845     Array.isArray = function isArray(obj) {
1846         return _toString(obj) == "[object Array]";
1847     };
1848 }
1849 var boxedString = Object("a"),
1850     splitString = boxedString[0] != "a" || !(0 in boxedString);
1851
1852 if (!Array.prototype.forEach) {
1853     Array.prototype.forEach = function forEach(fun /*, thisp*/) {
1854         var object = toObject(this),
1855             self = splitString && _toString(this) == "[object String]" ?
1856                 this.split("") :
1857                 object,
1858             thisp = arguments[1],
1859             i = -1,
1860             length = self.length >>> 0;
1861         if (_toString(fun) != "[object Function]") {
1862             throw new TypeError(); // TODO message
1863         }
1864
1865         while (++i < length) {
1866             if (i in self) {
1867                 fun.call(thisp, self[i], i, object);
1868             }
1869         }
1870     };
1871 }
1872 if (!Array.prototype.map) {
1873     Array.prototype.map = function map(fun /*, thisp*/) {
1874         var object = toObject(this),
1875             self = splitString && _toString(this) == "[object String]" ?
1876                 this.split("") :
1877                 object,
1878             length = self.length >>> 0,
1879             result = Array(length),
1880             thisp = arguments[1];
1881         if (_toString(fun) != "[object Function]") {
1882             throw new TypeError(fun + " is not a function");
1883         }
1884
1885         for (var i = 0; i < length; i++) {
1886             if (i in self)
1887                 result[i] = fun.call(thisp, self[i], i, object);
1888         }
1889         return result;
1890     };
1891 }
1892 if (!Array.prototype.filter) {
1893     Array.prototype.filter = function filter(fun /*, thisp */) {
1894         var object = toObject(this),
1895             self = splitString && _toString(this) == "[object String]" ?
1896                 this.split("") :
1897                     object,
1898             length = self.length >>> 0,
1899             result = [],
1900             value,
1901             thisp = arguments[1];
1902         if (_toString(fun) != "[object Function]") {
1903             throw new TypeError(fun + " is not a function");
1904         }
1905
1906         for (var i = 0; i < length; i++) {
1907             if (i in self) {
1908                 value = self[i];
1909                 if (fun.call(thisp, value, i, object)) {
1910                     result.push(value);
1911                 }
1912             }
1913         }
1914         return result;
1915     };
1916 }
1917 if (!Array.prototype.every) {
1918     Array.prototype.every = function every(fun /*, thisp */) {
1919         var object = toObject(this),
1920             self = splitString && _toString(this) == "[object String]" ?
1921                 this.split("") :
1922                 object,
1923             length = self.length >>> 0,
1924             thisp = arguments[1];
1925         if (_toString(fun) != "[object Function]") {
1926             throw new TypeError(fun + " is not a function");
1927         }
1928
1929         for (var i = 0; i < length; i++) {
1930             if (i in self && !fun.call(thisp, self[i], i, object)) {
1931                 return false;
1932             }
1933         }
1934         return true;
1935     };
1936 }
1937 if (!Array.prototype.some) {
1938     Array.prototype.some = function some(fun /*, thisp */) {
1939         var object = toObject(this),
1940             self = splitString && _toString(this) == "[object String]" ?
1941                 this.split("") :
1942                 object,
1943             length = self.length >>> 0,
1944             thisp = arguments[1];
1945         if (_toString(fun) != "[object Function]") {
1946             throw new TypeError(fun + " is not a function");
1947         }
1948
1949         for (var i = 0; i < length; i++) {
1950             if (i in self && fun.call(thisp, self[i], i, object)) {
1951                 return true;
1952             }
1953         }
1954         return false;
1955     };
1956 }
1957 if (!Array.prototype.reduce) {
1958     Array.prototype.reduce = function reduce(fun /*, initial*/) {
1959         var object = toObject(this),
1960             self = splitString && _toString(this) == "[object String]" ?
1961                 this.split("") :
1962                 object,
1963             length = self.length >>> 0;
1964         if (_toString(fun) != "[object Function]") {
1965             throw new TypeError(fun + " is not a function");
1966         }
1967         if (!length && arguments.length == 1) {
1968             throw new TypeError("reduce of empty array with no initial value");
1969         }
1970
1971         var i = 0;
1972         var result;
1973         if (arguments.length >= 2) {
1974             result = arguments[1];
1975         } else {
1976             do {
1977                 if (i in self) {
1978                     result = self[i++];
1979                     break;
1980                 }
1981                 if (++i >= length) {
1982                     throw new TypeError("reduce of empty array with no initial value");
1983                 }
1984             } while (true);
1985         }
1986
1987         for (; i < length; i++) {
1988             if (i in self) {
1989                 result = fun.call(void 0, result, self[i], i, object);
1990             }
1991         }
1992
1993         return result;
1994     };
1995 }
1996 if (!Array.prototype.reduceRight) {
1997     Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
1998         var object = toObject(this),
1999             self = splitString && _toString(this) == "[object String]" ?
2000                 this.split("") :
2001                 object,
2002             length = self.length >>> 0;
2003         if (_toString(fun) != "[object Function]") {
2004             throw new TypeError(fun + " is not a function");
2005         }
2006         if (!length && arguments.length == 1) {
2007             throw new TypeError("reduceRight of empty array with no initial value");
2008         }
2009
2010         var result, i = length - 1;
2011         if (arguments.length >= 2) {
2012             result = arguments[1];
2013         } else {
2014             do {
2015                 if (i in self) {
2016                     result = self[i--];
2017                     break;
2018                 }
2019                 if (--i < 0) {
2020                     throw new TypeError("reduceRight of empty array with no initial value");
2021                 }
2022             } while (true);
2023         }
2024
2025         do {
2026             if (i in this) {
2027                 result = fun.call(void 0, result, self[i], i, object);
2028             }
2029         } while (i--);
2030
2031         return result;
2032     };
2033 }
2034 if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
2035     Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
2036         var self = splitString && _toString(this) == "[object String]" ?
2037                 this.split("") :
2038                 toObject(this),
2039             length = self.length >>> 0;
2040
2041         if (!length) {
2042             return -1;
2043         }
2044
2045         var i = 0;
2046         if (arguments.length > 1) {
2047             i = toInteger(arguments[1]);
2048         }
2049         i = i >= 0 ? i : Math.max(0, length + i);
2050         for (; i < length; i++) {
2051             if (i in self && self[i] === sought) {
2052                 return i;
2053             }
2054         }
2055         return -1;
2056     };
2057 }
2058 if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
2059     Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
2060         var self = splitString && _toString(this) == "[object String]" ?
2061                 this.split("") :
2062                 toObject(this),
2063             length = self.length >>> 0;
2064
2065         if (!length) {
2066             return -1;
2067         }
2068         var i = length - 1;
2069         if (arguments.length > 1) {
2070             i = Math.min(i, toInteger(arguments[1]));
2071         }
2072         i = i >= 0 ? i : length - Math.abs(i);
2073         for (; i >= 0; i--) {
2074             if (i in self && sought === self[i]) {
2075                 return i;
2076             }
2077         }
2078         return -1;
2079     };
2080 }
2081 if (!Object.getPrototypeOf) {
2082     Object.getPrototypeOf = function getPrototypeOf(object) {
2083         return object.__proto__ || (
2084             object.constructor ?
2085             object.constructor.prototype :
2086             prototypeOfObject
2087         );
2088     };
2089 }
2090 if (!Object.getOwnPropertyDescriptor) {
2091     var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
2092                          "non-object: ";
2093     Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
2094         if ((typeof object != "object" && typeof object != "function") || object === null)
2095             throw new TypeError(ERR_NON_OBJECT + object);
2096         if (!owns(object, property))
2097             return;
2098
2099         var descriptor, getter, setter;
2100         descriptor =  { enumerable: true, configurable: true };
2101         if (supportsAccessors) {
2102             var prototype = object.__proto__;
2103             object.__proto__ = prototypeOfObject;
2104
2105             var getter = lookupGetter(object, property);
2106             var setter = lookupSetter(object, property);
2107             object.__proto__ = prototype;
2108
2109             if (getter || setter) {
2110                 if (getter) descriptor.get = getter;
2111                 if (setter) descriptor.set = setter;
2112                 return descriptor;
2113             }
2114         }
2115         descriptor.value = object[property];
2116         return descriptor;
2117     };
2118 }
2119 if (!Object.getOwnPropertyNames) {
2120     Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
2121         return Object.keys(object);
2122     };
2123 }
2124 if (!Object.create) {
2125     var createEmpty;
2126     if (Object.prototype.__proto__ === null) {
2127         createEmpty = function () {
2128             return { "__proto__": null };
2129         };
2130     } else {
2131         createEmpty = function () {
2132             var empty = {};
2133             for (var i in empty)
2134                 empty[i] = null;
2135             empty.constructor =
2136             empty.hasOwnProperty =
2137             empty.propertyIsEnumerable =
2138             empty.isPrototypeOf =
2139             empty.toLocaleString =
2140             empty.toString =
2141             empty.valueOf =
2142             empty.__proto__ = null;
2143             return empty;
2144         }
2145     }
2146
2147     Object.create = function create(prototype, properties) {
2148         var object;
2149         if (prototype === null) {
2150             object = createEmpty();
2151         } else {
2152             if (typeof prototype != "object")
2153                 throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
2154             var Type = function () {};
2155             Type.prototype = prototype;
2156             object = new Type();
2157             object.__proto__ = prototype;
2158         }
2159         if (properties !== void 0)
2160             Object.defineProperties(object, properties);
2161         return object;
2162     };
2163 }
2164
2165 function doesDefinePropertyWork(object) {
2166     try {
2167         Object.defineProperty(object, "sentinel", {});
2168         return "sentinel" in object;
2169     } catch (exception) {
2170     }
2171 }
2172 if (Object.defineProperty) {
2173     var definePropertyWorksOnObject = doesDefinePropertyWork({});
2174     var definePropertyWorksOnDom = typeof document == "undefined" ||
2175         doesDefinePropertyWork(document.createElement("div"));
2176     if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
2177         var definePropertyFallback = Object.defineProperty;
2178     }
2179 }
2180
2181 if (!Object.defineProperty || definePropertyFallback) {
2182     var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
2183     var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
2184     var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
2185                                       "on this javascript engine";
2186
2187     Object.defineProperty = function defineProperty(object, property, descriptor) {
2188         if ((typeof object != "object" && typeof object != "function") || object === null)
2189             throw new TypeError(ERR_NON_OBJECT_TARGET + object);
2190         if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
2191             throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
2192         if (definePropertyFallback) {
2193             try {
2194                 return definePropertyFallback.call(Object, object, property, descriptor);
2195             } catch (exception) {
2196             }
2197         }
2198         if (owns(descriptor, "value")) {
2199
2200             if (supportsAccessors && (lookupGetter(object, property) ||
2201                                       lookupSetter(object, property)))
2202             {
2203                 var prototype = object.__proto__;
2204                 object.__proto__ = prototypeOfObject;
2205                 delete object[property];
2206                 object[property] = descriptor.value;
2207                 object.__proto__ = prototype;
2208             } else {
2209                 object[property] = descriptor.value;
2210             }
2211         } else {
2212             if (!supportsAccessors)
2213                 throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
2214             if (owns(descriptor, "get"))
2215                 defineGetter(object, property, descriptor.get);
2216             if (owns(descriptor, "set"))
2217                 defineSetter(object, property, descriptor.set);
2218         }
2219
2220         return object;
2221     };
2222 }
2223 if (!Object.defineProperties) {
2224     Object.defineProperties = function defineProperties(object, properties) {
2225         for (var property in properties) {
2226             if (owns(properties, property))
2227                 Object.defineProperty(object, property, properties[property]);
2228         }
2229         return object;
2230     };
2231 }
2232 if (!Object.seal) {
2233     Object.seal = function seal(object) {
2234         return object;
2235     };
2236 }
2237 if (!Object.freeze) {
2238     Object.freeze = function freeze(object) {
2239         return object;
2240     };
2241 }
2242 try {
2243     Object.freeze(function () {});
2244 } catch (exception) {
2245     Object.freeze = (function freeze(freezeObject) {
2246         return function freeze(object) {
2247             if (typeof object == "function") {
2248                 return object;
2249             } else {
2250                 return freezeObject(object);
2251             }
2252         };
2253     })(Object.freeze);
2254 }
2255 if (!Object.preventExtensions) {
2256     Object.preventExtensions = function preventExtensions(object) {
2257         return object;
2258     };
2259 }
2260 if (!Object.isSealed) {
2261     Object.isSealed = function isSealed(object) {
2262         return false;
2263     };
2264 }
2265 if (!Object.isFrozen) {
2266     Object.isFrozen = function isFrozen(object) {
2267         return false;
2268     };
2269 }
2270 if (!Object.isExtensible) {
2271     Object.isExtensible = function isExtensible(object) {
2272         if (Object(object) === object) {
2273             throw new TypeError(); // TODO message
2274         }
2275         var name = '';
2276         while (owns(object, name)) {
2277             name += '?';
2278         }
2279         object[name] = true;
2280         var returnValue = owns(object, name);
2281         delete object[name];
2282         return returnValue;
2283     };
2284 }
2285 if (!Object.keys) {
2286     var hasDontEnumBug = true,
2287         dontEnums = [
2288             "toString",
2289             "toLocaleString",
2290             "valueOf",
2291             "hasOwnProperty",
2292             "isPrototypeOf",
2293             "propertyIsEnumerable",
2294             "constructor"
2295         ],
2296         dontEnumsLength = dontEnums.length;
2297
2298     for (var key in {"toString": null}) {
2299         hasDontEnumBug = false;
2300     }
2301
2302     Object.keys = function keys(object) {
2303
2304         if (
2305             (typeof object != "object" && typeof object != "function") ||
2306             object === null
2307         ) {
2308             throw new TypeError("Object.keys called on a non-object");
2309         }
2310
2311         var keys = [];
2312         for (var name in object) {
2313             if (owns(object, name)) {
2314                 keys.push(name);
2315             }
2316         }
2317
2318         if (hasDontEnumBug) {
2319             for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
2320                 var dontEnum = dontEnums[i];
2321                 if (owns(object, dontEnum)) {
2322                     keys.push(dontEnum);
2323                 }
2324             }
2325         }
2326         return keys;
2327     };
2328
2329 }
2330 if (!Date.now) {
2331     Date.now = function now() {
2332         return new Date().getTime();
2333     };
2334 }
2335 var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
2336     "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
2337     "\u2029\uFEFF";
2338 if (!String.prototype.trim || ws.trim()) {
2339     ws = "[" + ws + "]";
2340     var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
2341         trimEndRegexp = new RegExp(ws + ws + "*$");
2342     String.prototype.trim = function trim() {
2343         return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
2344     };
2345 }
2346
2347 function toInteger(n) {
2348     n = +n;
2349     if (n !== n) { // isNaN
2350         n = 0;
2351     } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
2352         n = (n > 0 || -1) * Math.floor(Math.abs(n));
2353     }
2354     return n;
2355 }
2356
2357 function isPrimitive(input) {
2358     var type = typeof input;
2359     return (
2360         input === null ||
2361         type === "undefined" ||
2362         type === "boolean" ||
2363         type === "number" ||
2364         type === "string"
2365     );
2366 }
2367
2368 function toPrimitive(input) {
2369     var val, valueOf, toString;
2370     if (isPrimitive(input)) {
2371         return input;
2372     }
2373     valueOf = input.valueOf;
2374     if (typeof valueOf === "function") {
2375         val = valueOf.call(input);
2376         if (isPrimitive(val)) {
2377             return val;
2378         }
2379     }
2380     toString = input.toString;
2381     if (typeof toString === "function") {
2382         val = toString.call(input);
2383         if (isPrimitive(val)) {
2384             return val;
2385         }
2386     }
2387     throw new TypeError();
2388 }
2389 var toObject = function (o) {
2390     if (o == null) { // this matches both null and undefined
2391         throw new TypeError("can't convert "+o+" to object");
2392     }
2393     return Object(o);
2394 };
2395
2396 });