/*

 Copyright (c) 2012 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors: IBM Corporation - initial API and implementation

 Copyright (c) 2011, 2014 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors:
     IBM Corporation - initial API and implementation

 Copyright (c) 2014 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors: IBM Corporation - initial API and implementation

 Copyright (c) 2014 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors: IBM Corporation - initial API and implementation

 Copyright (c) 2014 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors: IBM Corporation - initial API and implementation

 Copyright (c) 2014 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors:
     IBM Corporation - initial API and implementation
*/
(function(a,c){"function"===typeof define&&define.amd?define("orion/Deferred",c):"object"===typeof exports?module.exports=c():(a.orion=a.orion||{},a.orion.Deferred=c())})(this,function(){function a(){for(var a;a=w.shift();)a();t=!1}function c(a){w.push(a);t||(t=!0,x())}function f(a){return function(c){a(c)}}function p(){function a(){for(var b;b=k.shift();){var g=b.deferred,c="fulfilled"===d?"resolve":"reject";b=b[c];if("function"===typeof b)try{var e=b(m),l=e&&("object"===typeof e||"function"===typeof e)&&
e.then;if("function"===typeof l)if(e===g.promise)g.reject(new TypeError);else{var v=e.cancel;"function"===typeof v?g._parentCancel=v.bind(e):delete g._parentCancel;l.call(e,f(g.resolve),f(g.reject),f(g.progress))}else g.resolve(e)}catch(p){g.reject(p)}else g[c](m)}}function l(b){delete e._parentCancel;d="rejected";m=b;k.length&&c(a)}function u(b){function g(h){return function(b){(!d||"assumed"===d)&&h(b)}}delete e._parentCancel;try{var q=b&&("object"===typeof b||"function"===typeof b)&&b.then;if("function"===
typeof q)if(b===e)l(new TypeError);else{d="assumed";var f=b&&b.cancel;if("function"!==typeof f){var n=new p;b=n.promise;try{q(n.resolve,n.reject,n.progress)}catch(s){n.reject(s)}f=b.cancel;q=b.then}m=b;q.call(b,g(u),g(l));e._parentCancel=f.bind(b)}else d="fulfilled",m=b,k.length&&c(a)}catch(r){g(l)(r)}}function n(){var b=e._parentCancel;b?(delete e._parentCancel,b()):d||(b=Error("Cancel"),b.name="Cancel",l(b))}var m,d,k=[],e=this;this.resolve=function(b){d||u(b);return e};this.reject=function(b){d||
l(b);return e};this.progress=function(b){d||k.forEach(function(a){if(a.progress)try{a.progress(b)}catch(e){}});return e.promise};this.cancel=function(){e._parentCancel?setTimeout(n,0):n();return e};this.then=function(b,g,l){var f=new p;f._parentCancel=e.promise.cancel;k.push({resolve:b,reject:g,progress:l,deferred:f});("fulfilled"===d||"rejected"===d)&&c(a);return f.promise};this.promise={then:e.then,cancel:e.cancel}}var w=[],t=!1,x=function(){if("undefined"!==typeof process&&"function"===typeof process.nextTick){var c=
process.nextTick;return function(){c(a)}}if("function"===typeof MutationObserver){var l=document.createElement("div");(new MutationObserver(a)).observe(l,{attributes:!0});return function(){l.setAttribute("class","_tick")}}return function(){setTimeout(a,0)}}();p.all=function(a,c){function f(b,a){k||(d[b]=a,0===--m&&e.resolve(d))}function n(a,g){if(!k){if(c)try{f(a,c(g));return}catch(d){g=d}e.reject(g)}}var m=a.length,d=[],k=!1,e=new p;e.then(void 0,function(){k=!0;a.forEach(function(a){a.cancel&&a.cancel()})});
0===m?e.resolve(d):a.forEach(function(a,c){a.then(f.bind(void 0,c),n.bind(void 0,c))});return e.promise};p.when=function(a,c,f,n){var m;a&&"function"===typeof a.then||(m=new p,m.resolve(a),a=m.promise);return a.then(c,f,n)};return p});
(function(a,c){"function"===typeof define&&define.amd?define("orion/plugin",["orion/Deferred"],c):"object"===typeof exports?module.exports=c(require("orion/Deferred")):(a.orion=a.orion||{},a.orion.PluginProvider=c(a.orion.Deferred))})(this,function(a){function c(a,c){this.__objectId=a;this.__methods=c}return function(f){function p(h){k&&("undefined"===typeof ArrayBuffer&&(h=JSON.stringify(h)),k===self?k.postMessage(h):k.postMessage(h,"*"))}function w(){var h=[];Object.keys(s).forEach(function(a){var b=
s[a];h.push({serviceId:a,names:b.names,methods:b.methods,properties:b.properties})});return{headers:m||{},services:h}}function t(h,a){if(a&&a instanceof XMLHttpRequest){var b,c;try{b=a.status,c=a.statusText}catch(e){b=0,c=""}return{status:b||0,statusText:c}}return a}function x(h){var a=h?JSON.parse(JSON.stringify(h,t)):h;h instanceof Error&&(a.__isError=!0,a.message=a.message||h.message,a.name=a.name||h.name);return a}function v(h){if(!k)return(new a).reject(Error("plugin not connected"));h.id=String(e++);
var f=new a;y[h.id]=f;f.then(null,function(a){d&&(a instanceof Error&&"Cancel"===a.name)&&r({requestId:h.id,method:"cancel",params:a.message?[a.message]:[]})});var g=Object.prototype.toString;h.params.forEach(function(a,e){if("[object Object]"===g.call(a)&&!(a instanceof c)){var d,k;for(d in a)"[object Function]"===g.call(a[d])&&(k=k||[],k.push(d));if(k){var l=b++;z[l]=a;d=function(){delete z[l]};f.then(d,d);h.params[e]=new c(l,k)}}});r(h);return f.promise}function l(a,b){a||0===a?r({id:a,result:null,
error:b}):console.log(b)}function u(a,b,c,e){e.forEach(function(a,h){if(a&&"undefined"!==typeof a.__objectId){var b={};a.__methods.forEach(function(h){b[h]=function(){return v({objectId:a.__objectId,method:h,params:Array.prototype.slice.call(arguments)})}});e[h]=b}});var d=void 0===typeof a?null:{id:a,result:null,error:null};try{var f=c.apply(b,e);d&&(f&&"function"===typeof f.then?(q[a]=f,f.then(function(b){delete q[a];d.result=b;r(d)},function(b){q[a]&&(delete q[a],d.error=x(b),r(d))},function(){r({responseId:a,
method:"progress",params:Array.prototype.slice.call(arguments)})})):(d.result=f,r(d)))}catch(k){d&&(d.error=x(k),r(d))}}function n(a){if(!(a.source!==k&&"undefined"!==typeof window)){a="string"!==typeof a.data?a.data:JSON.parse(a.data);try{if(a.method){var b=a.method,c=a.params||[];if("serviceId"in a){var d=s[a.serviceId];d||l(a.id,"service not found");d=d.implementation;b in d?u(a.id,d,d[b],c):l(a.id,"method not found")}else if("objectId"in a){var e=z[a.objectId];e||l(a.id,"object not found");!b in
e?u(a.id,e,e[b],c):l(a.id,"method not found")}else if("requestId"in a){var f=q[a.requestId];f&&("cancel"===b&&f.cancel)&&f.cancel.apply(f,c)}else if("responseId"in a){var g=y[a.responseId];g&&("progress"===b&&g.progress)&&g.progress.apply(g,c)}else throw Error("Bad method: "+a.method);}else{var m=y[String(a.id)];delete y[String(a.id)];a.error?m.reject(a.error):m.resolve(a.result)}}catch(n){console.log("Plugin._messageHandler "+n)}}}var m=f,d=!1,k=null,e=0,b=0,g=0,q={},y={},z={},s={},r=p;this.updateHeaders=
function(a){if(d)throw Error("Cannot update headers. Plugin Provider is connected");m=a};this.registerServiceProvider=this.registerService=function(a,b,c){if(d)throw Error("Cannot register service. Plugin Provider is connected");"string"===typeof a?a=[a]:Array.isArray(a)||(a=[]);var e=null,f=[];for(e in b)"function"===typeof b[e]&&f.push(e);s[g++]={names:a,methods:f,implementation:b,properties:c||{},listeners:{}}};this.connect=function(a,b){if(!d){if("undefined"===typeof window)k=self;else if(window!==
window.parent)k=window.parent;else if(null!==window.opener)k=window.opener;else{b&&b("No valid plugin target");return}addEventListener("message",n,!1);var c={method:"plugin",params:[w()]};p(c);d=!0}a&&a()};this.disconnect=function(){d&&(removeEventListener("message",n),k=null,d=!1)}}});
define("orion/editor/stylers/lib/syntax",[],function(){return{id:"orion.lib",grammars:[{id:"orion.lib",repository:{brace_open:{match:"{",name:"punctuation.section.block.begin"},brace_close:{match:"}",name:"punctuation.section.block.end"},bracket_open:{match:"\\[",name:"punctuation.section.bracket.begin"},bracket_close:{match:"\\]",name:"punctuation.section.bracket.end"},parenthesis_open:{match:"\\(",name:"punctuation.section.parens.begin"},parenthesis_close:{match:"\\)",name:"punctuation.section.parens.end"},
doc_block:{begin:{match:"/\\*\\*",literal:"/**"},end:{match:"\\*/",literal:"*/"},name:"comment.block.documentation",patterns:[{match:"@(?:(?!\\*/)\\S)*",name:"keyword.other.documentation.tag"},{match:"\\\x3c\\S*\\\x3e",name:"keyword.other.documentation.markup"},{match:"(\\b)(TODO)(\\b)(((?!\\*/).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]},number_decimal:{match:"\\b-?(?:\\.\\d+|\\d+\\.?\\d*)(?:[eE][+-]?\\d+)?\\b",name:"constant.numeric.number"},
number_hex:{match:"\\b0[xX][0-9A-Fa-f]+\\b",name:"constant.numeric.hex"},string_doubleQuote:{match:'"(?:\\\\.|[^"])*"?',name:"string.quoted.double"},string_singleQuote:{match:"'(?:\\\\.|[^'])*'?",name:"string.quoted.single"},todo_comment_singleLine:{match:"(\\b)(TODO)(\\b)(.*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.line"}}}}},{id:"orion.c-like",repository:{comment_singleLine:{match:{match:"//.*",literal:"//"},name:"comment.line.double-slash",
patterns:[{include:"orion.lib#todo_comment_singleLine"}]},comment_block:{begin:{match:"/\\*",literal:"/*"},end:{match:"\\*/",literal:"*/"},name:"comment.block",patterns:[{match:"(\\b)(TODO)(\\b)(((?!\\*/).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]}}}],keywords:[]}});
define("orion/editor/stylers/text_x-csrc/syntax",["orion/editor/stylers/lib/syntax"],function(a){var c="auto break case char const continue default double do else enum extern float for goto if int long register return short signed sizeof static struct switch typedef union unsigned void volatile while".split(" "),f="define elif else endif error ifdef ifndef if include line pragma undef".split(" ");a=a.grammars;a.push({id:"orion.c",contentTypes:["text/x-csrc","text/x-c"],patterns:[{include:"orion.lib#string_doubleQuote"},
{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"orion.lib#doc_block"},{include:"orion.c-like#comment_block"},{include:"#directive"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+c.join("|")+")\\b",
name:"keyword.control.c"}],repository:{directive:{match:"(#\\s*(?:"+f.join("|")+"))\\b",name:"keyword.control.directive.c"}}});return{id:a[a.length-1].id,grammars:a,keywords:c.concat(f)}});define("orion/editor/stylers/text_x-arduino/syntax",["orion/editor/stylers/text_x-csrc/syntax"],function(a){a=a.grammars;var c=a[a.length-1];c.id="orion.arduino";c.contentTypes=["text/x-arduino"];return{id:c.id,grammars:a,keywords:c.keywords}});
define("plugins/languages/arduino/arduinoPlugin",["orion/plugin","orion/editor/stylers/text_x-arduino/syntax"],function(a,c){var f=new a({name:"Orion Arduino Tool Support",version:"1.0",description:"This plugin provides Arduino tools support for Orion."});f.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-arduino","extends":"text/plain",name:"Arduino",extension:["ino","pde"]}]});f.registerServiceProvider("orion.edit.highlighter",{},c.grammars[c.grammars.length-1]);f.connect()});
//@ sourceMappingURL=arduinoPlugin.js.map