KodExplorer/static/js/lib/ace/emmet.min.js

50 lines
208 KiB
JavaScript
Raw Normal View History

2016-12-21 08:01:06 +00:00
var _=(function(){var root=this;var previousUnderscore=root._;var breaker={};var ArrayProto=Array.prototype,ObjProto=Object.prototype,FuncProto=Function.prototype;var slice=ArrayProto.slice,unshift=ArrayProto.unshift,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty;var nativeForEach=ArrayProto.forEach,nativeMap=ArrayProto.map,nativeReduce=ArrayProto.reduce,nativeReduceRight=ArrayProto.reduceRight,nativeFilter=ArrayProto.filter,nativeEvery=ArrayProto.every,nativeSome=ArrayProto.some,nativeIndexOf=ArrayProto.indexOf,nativeLastIndexOf=ArrayProto.lastIndexOf,nativeIsArray=Array.isArray,nativeKeys=Object.keys,nativeBind=FuncProto.bind;var _=function(obj){return new wrapper(obj)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports){exports=module.exports=_}exports._=_}else{root["_"]=_}_.VERSION="1.3.3";var each=_.each=_.forEach=function(obj,iterator,context){if(obj==null){return}if(nativeForEach&&obj.forEach===nativeForEach){obj.forEach(iterator,context)}else{if(obj.length===+obj.length){for(var i=0,l=obj.length;i<l;i++){if(i in obj&&iterator.call(context,obj[i],i,obj)===breaker){return}}}else{for(var key in obj){if(_.has(obj,key)){if(iterator.call(context,obj[key],key,obj)===breaker){return}}}}}};_.map=_.collect=function(obj,iterator,context){var results=[];if(obj==null){return results}if(nativeMap&&obj.map===nativeMap){return obj.map(iterator,context)}each(obj,function(value,index,list){results[results.length]=iterator.call(context,value,index,list)});if(obj.length===+obj.length){results.length=obj.length}return results};_.reduce=_.foldl=_.inject=function(obj,iterator,memo,context){var initial=arguments.length>2;if(obj==null){obj=[]}if(nativeReduce&&obj.reduce===nativeReduce){if(context){iterator=_.bind(iterator,context)}return initial?obj.reduce(iterator,memo):obj.reduce(iterator)}each(obj,function(value,index,list){if(!initial){memo=value;initial=true}else{memo=iterator.call(context,memo,value,index,list)}});if(!initial){throw new TypeError("Reduce of empty array with no initial value")}return memo};_.reduceRight=_.foldr=function(obj,iterator,memo,context){var initial=arguments.length>2;if(obj==null){obj=[]}if(nativeReduceRight&&obj.reduceRight===nativeReduceRight){if(context){iterator=_.bind(iterator,context)}return initial?obj.reduceRight(iterator,memo):obj.reduceRight(iterator)}var reversed=_.toArray(obj).reverse();if(context&&!initial){iterator=_.bind(iterator,context)}return initial?_.reduce(reversed,iterator,memo,context):_.reduce(reversed,iterator)};_.find=_.detect=function(obj,iterator,context){var result;any(obj,function(value,index,list){if(iterator.call(context,value,index,list)){result=value;return true}});return result};_.filter=_.select=function(obj,iterator,context){var results=[];if(obj==null){return results}if(nativeFilter&&obj.filter===nativeFilter){return obj.filter(iterator,context)}each(obj,function(value,index,list){if(iterator.call(context,value,index,list)){results[results.length]=value}});return results};_.reject=function(obj,iterator,context){var results=[];if(obj==null){return results}each(obj,function(value,index,list){if(!iterator.call(context,value,index,list)){results[results.length]=value}});return results};_.every=_.all=function(obj,iterator,context){var result=true;if(obj==null){return result}if(nativeEvery&&obj.every===nativeEvery){return obj.every(iterator,context)}each(obj,function(value,index,list){if(!(result=result&&iterator.call(context,value,index,list))){return breaker}});return !!result};var any=_.some=_.any=function(obj,iterator,context){iterator||(iterator=_.identity);var result=false;if(obj==null){return result}if(nativeSome&&obj.some===nativeSome){return obj.some(iterator,context)}each(obj,function(value,index,list){if(result||(result=iterator.call(context,value,index,list))){return breaker}});return !!result};_.include=_.contains=function(obj,target){var found=false;if(obj==null){return found}if(nativeIndexOf&&obj.indexOf===nativeIndexOf){return obj.indexOf(target)!=-1}found=any(obj,function(value){return value===target});return
computed<result.computed&&(result={value:value,computed:computed})});return result.value};_.shuffle=function(obj){var shuffled=[],rand;each(obj,function(value,index,list){rand=Math.floor(Math.random()*(index+1));shuffled[index]=shuffled[rand];shuffled[rand]=value});return shuffled};_.sortBy=function(obj,val,context){var iterator=_.isFunction(val)?val:function(obj){return obj[val]};return _.pluck(_.map(obj,function(value,index,list){return{value:value,criteria:iterator.call(context,value,index,list)}}).sort(function(left,right){var a=left.criteria,b=right.criteria;if(a===void 0){return 1}if(b===void 0){return -1}return a<b?-1:a>b?1:0}),"value")};_.groupBy=function(obj,val){var result={};var iterator=_.isFunction(val)?val:function(obj){return obj[val]};each(obj,function(value,index){var key=iterator(value,index);(result[key]||(result[key]=[])).push(value)});return result};_.sortedIndex=function(array,obj,iterator){iterator||(iterator=_.identity);var low=0,high=array.length;while(low<high){var mid=(low+high)>>1;iterator(array[mid])<iterator(obj)?low=mid+1:high=mid}return low};_.toArray=function(obj){if(!obj){return[]}if(_.isArray(obj)){return slice.call(obj)}if(_.isArguments(obj)){return slice.call(obj)}if(obj.toArray&&_.isFunction(obj.toArray)){return obj.toArray()}return _.values(obj)};_.size=function(obj){return _.isArray(obj)?obj.length:_.keys(obj).length};_.first=_.head=_.take=function(array,n,guard){return(n!=null)&&!guard?slice.call(array,0,n):array[0]};_.initial=function(array,n,guard){return slice.call(array,0,array.length-((n==null)||guard?1:n))};_.last=function(array,n,guard){if((n!=null)&&!guard){return slice.call(array,Math.max(array.length-n,0))}else{return array[array.length-1]}};_.rest=_.tail=function(array,index,guard){return slice.call(array,(index==null)||guard?1:index)};_.compact=function(array){return _.filter(array,function(value){return !!value})};_.flatten=function(array,shallow){return _.reduce(array,function(memo,value){if(_.isArray(value)){return memo.concat(shallow?value:_.flatten(value))}memo[memo.length]=value;return memo},[])};_.without=function(array){return _.difference(array,slice.call(arguments,1))};_.uniq=_.unique=function(array,isSorted,iterator){var initial=iterator?_.map(array,iterator):array;var results=[];if(array.length<3){isSorted=true}_.reduce(initial,function(memo,value,index){if(isSorted?_.last(memo)!==value||!memo.length:!_.include(memo,value)){memo.push(value);results.push(array[index])}return memo},[]);return results};_.union=function(){return _.uniq(_.flatten(arguments,true))};_.intersection=_.intersect=function(array){var rest=slice.call(arguments,1);return _.filter(_.uniq(array),function(item){return _.every(rest,function(other){return _.indexOf(other,item)>=0})})};_.difference=function(array){var rest=_.flatten(slice.call(arguments,1),true);return _.filter(array,function(value){return !_.include(rest,value)})};_.zip=function(){var args=slice.call(arguments);var length=_.max(_.pluck(args,"length"));var results=new Array(length);for(var i=0;i<length;i++){results[i]=_.pluck(args,""+i)}return results};_.indexOf=function(array,item,isSorted){if(array==null){return -1}var i,l;if(isSorted){i=_.sortedIndex(array,item);return array[i]===item?i:-1}if(nativeIndexOf&&array.indexOf===nativeIndexOf){return array.indexOf(item)}for(i=0,l=array.length;i<l;i++){if(i in array&&array[i]===item){return i}}return -1};_.lastIndexOf=function(array,item){if(array==null){return -1}if(nativeLastIndexOf&&array.lastIndexOf===nativeLastIndexOf){return array.lastIndexOf(item)}var i=array.length;while(i--){if(i in array&&array[i]===item){return i}}return -1};_.range=function(start,stop,step){if(arguments.length<=1){stop=start||0;start=0}step=arguments[2]||1;var len=Math.max(Math.ceil((stop-start)/step),0);var idx=0;var range=new Array(len);while(idx<len){range[idx++]=start;start+=step}return range};var ctor=function(){};_.bind=function bind(func,context){var bound,args;if(func.bind===nativeBind&&nativeBind){return nativeBind.apply(func,slice.call(arguments,1))}if(!_.isFunction(func)){throw new TypeErro
var whenDone=_.debounce(function(){more=throttling=false},wait);return function(){context=this;args=arguments;var later=function(){timeout=null;if(more){func.apply(context,args)}whenDone()};if(!timeout){timeout=setTimeout(later,wait)}if(throttling){more=true}else{result=func.apply(context,args)}whenDone();throttling=true;return result}};_.debounce=function(func,wait,immediate){var timeout;return function(){var context=this,args=arguments;var later=function(){timeout=null;if(!immediate){func.apply(context,args)}};if(immediate&&!timeout){func.apply(context,args)}clearTimeout(timeout);timeout=setTimeout(later,wait)}};_.once=function(func){var ran=false,memo;return function(){if(ran){return memo}ran=true;return memo=func.apply(this,arguments)}};_.wrap=function(func,wrapper){return function(){var args=[func].concat(slice.call(arguments,0));return wrapper.apply(this,args)}};_.compose=function(){var funcs=arguments;return function(){var args=arguments;for(var i=funcs.length-1;i>=0;i--){args=[funcs[i].apply(this,args)]}return args[0]}};_.after=function(times,func){if(times<=0){return func()}return function(){if(--times<1){return func.apply(this,arguments)}}};_.keys=nativeKeys||function(obj){if(obj!==Object(obj)){throw new TypeError("Invalid object")}var keys=[];for(var key in obj){if(_.has(obj,key)){keys[keys.length]=key}}return keys};_.values=function(obj){return _.map(obj,_.identity)};_.functions=_.methods=function(obj){var names=[];for(var key in obj){if(_.isFunction(obj[key])){names.push(key)}}return names.sort()};_.extend=function(obj){each(slice.call(arguments,1),function(source){for(var prop in source){obj[prop]=source[prop]}});return obj};_.pick=function(obj){var result={};each(_.flatten(slice.call(arguments,1)),function(key){if(key in obj){result[key]=obj[key]}});return result};_.defaults=function(obj){each(slice.call(arguments,1),function(source){for(var prop in source){if(obj[prop]==null){obj[prop]=source[prop]}}});return obj};_.clone=function(obj){if(!_.isObject(obj)){return obj}return _.isArray(obj)?obj.slice():_.extend({},obj)};_.tap=function(obj,interceptor){interceptor(obj);return obj};function eq(a,b,stack){if(a===b){return a!==0||1/a==1/b}if(a==null||b==null){return a===b}if(a._chain){a=a._wrapped}if(b._chain){b=b._wrapped}if(a.isEqual&&_.isFunction(a.isEqual)){return a.isEqual(b)}if(b.isEqual&&_.isFunction(b.isEqual)){return b.isEqual(a)}var className=toString.call(a);if(className!=toString.call(b)){return false}switch(className){case"[object String]":return a==String(b);case"[object Number]":return a!=+a?b!=+b:(a==0?1/a==1/b:a==+b);case"[object Date]":case"[object Boolean]":return +a==+b;case"[object RegExp]":return a.source==b.source&&a.global==b.global&&a.multiline==b.multiline&&a.ignoreCase==b.ignoreCase}if(typeof a!="object"||typeof b!="object"){return false}var length=stack.length;while(length--){if(stack[length]==a){return true}}stack.push(a);var size=0,result=true;if(className=="[object Array]"){size=a.length;result=size==b.length;if(result){while(size--){if(!(result=size in a==size in b&&eq(a[size],b[size],stack))){break}}}}else{if("constructor" in a!="constructor" in b||a.constructor!=b.constructor){return false}for(var key in a){if(_.has(a,key)){size++;if(!(result=_.has(b,key)&&eq(a[key],b[key],stack))){break}}}if(result){for(key in b){if(_.has(b,key)&&!(size--)){break}}result=!size}}stack.pop();return result}_.isEqual=function(a,b){return eq(a,b,[])};_.isEmpty=function(obj){if(obj==null){return true}if(_.isArray(obj)||_.isString(obj)){return obj.length===0}for(var key in obj){if(_.has(obj,key)){return false}}return true};_.isElement=function(obj){return !!(obj&&obj.nodeType==1)};_.isArray=nativeIsArray||function(obj){return toString.call(obj)=="[object Array]"};_.isObject=function(obj){return obj===Object(obj)};_.isArguments=function(obj){return toString.call(obj)=="[object Arguments]"};if(!_.isArguments(arguments)){_.isArguments=function(obj){return !!(obj&&_.has(obj,"callee"))}}_.isFunction=function(obj){return toString.call(obj)=="[object Function]"};_.isString=function(obj){return toString.cal
};_.result=function(object,property){if(object==null){return null}var value=object[property];return _.isFunction(value)?value.call(object):value};_.mixin=function(obj){each(_.functions(obj),function(name){addToWrapper(name,_[name]=obj[name])})};var idCounter=0;_.uniqueId=function(prefix){var id=idCounter++;return prefix?prefix+id:id};_.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var noMatch=/.^/;var escapes={"\\":"\\","'":"'","r":"\r","n":"\n","t":"\t","u2028":"\u2028","u2029":"\u2029"};for(var p in escapes){escapes[escapes[p]]=p}var escaper=/\\|'|\r|\n|\t|\u2028|\u2029/g;var unescaper=/\\(\\|'|r|n|t|u2028|u2029)/g;var unescape=function(code){return code.replace(unescaper,function(match,escape){return escapes[escape]})};_.template=function(text,data,settings){settings=_.defaults(settings||{},_.templateSettings);var source="__p+='"+text.replace(escaper,function(match){return"\\"+escapes[match]}).replace(settings.escape||noMatch,function(match,code){return"'+\n_.escape("+unescape(code)+")+\n'"}).replace(settings.interpolate||noMatch,function(match,code){return"'+\n("+unescape(code)+")+\n'"}).replace(settings.evaluate||noMatch,function(match,code){return"';\n"+unescape(code)+"\n;__p+='"})+"';\n";if(!settings.variable){source="with(obj||{}){\n"+source+"}\n"}source="var __p='';"+"var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n"+source+"return __p;\n";var render=new Function(settings.variable||"obj","_",source);if(data){return render(data,_)}var template=function(data){return render.call(this,data,_)};template.source="function("+(settings.variable||"obj")+"){\n"+source+"}";return template};_.chain=function(obj){return _(obj).chain()};var wrapper=function(obj){this._wrapped=obj};_.prototype=wrapper.prototype;var result=function(obj,chain){return chain?_(obj).chain():obj};var addToWrapper=function(name,func){wrapper.prototype[name]=function(){var args=slice.call(arguments);unshift.call(args,this._wrapped);return result(func.apply(_,args),this._chain)}};_.mixin(_);each(["pop","push","reverse","shift","sort","splice","unshift"],function(name){var method=ArrayProto[name];wrapper.prototype[name]=function(){var wrapped=this._wrapped;method.apply(wrapped,arguments);var length=wrapped.length;if((name=="shift"||name=="splice")&&length===0){delete wrapped[0]}return result(wrapped,this._chain)}});each(["concat","join","slice"],function(name){var method=ArrayProto[name];wrapper.prototype[name]=function(){return result(method.apply(this._wrapped,arguments),this._chain)}});wrapper.prototype.chain=function(){this._chain=true;return this};wrapper.prototype.value=function(){return this._wrapped};return _}).call({});var emmet=(function(global){var defaultSyntax="html";var defaultProfile="plain";if(typeof _=="undefined"){try{_=global[["require"][0]]("underscore")}catch(e){}}if(typeof _=="undefined"){throw"Cannot access to Underscore.js lib"}var modules={_:_};var ctor=function(){};function inherits(parent,protoProps,staticProps){var child;if(protoProps&&protoProps.hasOwnProperty("constructor")){child=protoProps.constructor}else{child=function(){parent.apply(this,arguments)}}_.extend(child,parent);ctor.prototype=parent.prototype;child.prototype=new ctor();if(protoProps){_.extend(child.prototype,protoProps)}if(staticProps){_.extend(child,staticProps)}child.prototype.constructor=child;child.__super__=parent.prototype;return child}var moduleLoader=null;function r(name){if(!(name in modules)&&moduleLoader){moduleLoader(name)}return modules[name]}return{define:function(name,factory){if(!(name in modules)){modules[name]=_.isFunction(factory)?this.exec(factory):factory}},require:r,exec:function(fn,context){return fn.call(context||global,_.bind(r,this),_,this)},extend:function(protoProps,classProps){var child=inherits(this,protoProps,classProps);child.extend=this.extend;if(protoProps.hasOwnProperty("toString")){child.prototype.toString=protoProps.toString}return child},expandAbbreviation:function(abbr,syntax,profile,contextNode){if(!abbr){return""}syntax=syntax||defaultSynta
var reWord=/[\w\-:\$@]/;var pairs={"[":"]","(":")","{":"}"};var spliceFn=Array.prototype.splice;var preprocessors=[];var postprocessors=[];var outputProcessors=[];function AbbreviationNode(parent){this.parent=null;this.children=[];this._attributes=[];this.abbreviation="";this.counter=1;this._name=null;this._text="";this.repeatCount=1;this.hasImplicitRepeat=false;this._data={};this.start="";this.end="";this.content="";this.padding=""}AbbreviationNode.prototype={addChild:function(child,position){child=child||new AbbreviationNode;child.parent=this;if(_.isUndefined(position)){this.children.push(child)}else{this.children.splice(position,0,child)}return child},clone:function(){var node=new AbbreviationNode();var attrs=["abbreviation","counter","_name","_text","repeatCount","hasImplicitRepeat","start","end","content","padding"];_.each(attrs,function(a){node[a]=this[a]},this);node._attributes=_.map(this._attributes,function(attr){return _.clone(attr)});node._data=_.clone(this._data);node.children=_.map(this.children,function(child){child=child.clone();child.parent=node;return child});return node},remove:function(){if(this.parent){this.parent.children=_.without(this.parent.children,this)}return this},replace:function(){var parent=this.parent;var ix=_.indexOf(parent.children,this);var items=_.flatten(arguments);spliceFn.apply(parent.children,[ix,1].concat(items));_.each(items,function(item){item.parent=parent})},updateProperty:function(name,value){this[name]=value;_.each(this.children,function(child){child.updateProperty(name,value)});return this},find:function(fn){return this.findAll(fn)[0]},findAll:function(fn){if(!_.isFunction(fn)){var elemName=fn.toLowerCase();fn=function(item){return item.name().toLowerCase()==elemName}}var result=[];_.each(this.children,function(child){if(fn(child)){result.push(child)}result=result.concat(child.findAll(fn))});return _.compact(result)},data:function(name,value){if(arguments.length==2){this._data[name]=value;if(name=="resource"&&require("elements").is(value,"snippet")){this.content=value.data;if(this._text){this.content=require("abbreviationUtils").insertChildContent(value.data,this._text)}}}return this._data[name]},name:function(){var res=this.matchedResource();if(require("elements").is(res,"element")){return res.name}return this._name},attributeList:function(){var attrs=[];var res=this.matchedResource();if(require("elements").is(res,"element")&&_.isArray(res.attributes)){attrs=attrs.concat(res.attributes)}return optimizeAttributes(attrs.concat(this._attributes))},attribute:function(name,value){if(arguments.length==2){var ix=_.indexOf(_.pluck(this._attributes,"name"),name.toLowerCase());if(~ix){this._attributes[ix].value=value}else{this._attributes.push({name:name,value:value})}}return(_.find(this.attributeList(),function(attr){return attr.name==name})||{}).value},matchedResource:function(){return this.data("resource")},index:function(){return this.parent?_.indexOf(this.parent.children,this):-1},_setRepeat:function(count){if(count){this.repeatCount=parseInt(count,10)||1}else{this.hasImplicitRepeat=true}},setAbbreviation:function(abbr){abbr=abbr||"";var that=this;abbr=abbr.replace(/\*(\d+)?$/,function(str,repeatCount){that._setRepeat(repeatCount);return""});this.abbreviation=abbr;var abbrText=extractText(abbr);if(abbrText){abbr=abbrText.element;this.content=this._text=abbrText.text}var abbrAttrs=parseAttributes(abbr);if(abbrAttrs){abbr=abbrAttrs.element;this._attributes=abbrAttrs.attributes}this._name=abbr;if(this._name&&!reValidName.test(this._name)){throw"Invalid abbreviation"}},toString:function(){var utils=require("utils");var start=this.start;var end=this.end;var content=this.content;var node=this;_.each(outputProcessors,function(fn){start=fn(start,node,"start");content=fn(content,node,"content");end=fn(end,node,"end")});var innerContent=_.map(this.children,function(child){return child.toString()}).join("");content=require("abbreviationUtils").insertChildContent(content,innerContent,{keepVariable:false});return start+utils.padString(content,this.padding)+end},hasEmptyChildren:function(){
var root=new AbbreviationNode;var context=root.addChild(),ch;var stream=require("stringStream").create(abbr);var loopProtector=1000,multiplier;while(!stream.eol()&&--loopProtector>0){ch=stream.peek();switch(ch){case"(":stream.start=stream.pos;if(stream.skipToPair("(",")")){var inner=parseAbbreviation(stripped(stream.current()));if(multiplier=stream.match(/^\*(\d+)?/,true)){context._setRepeat(multiplier[1])}_.each(inner.children,function(child){context.addChild(child)})}else{throw'Invalid abbreviation: mo matching ")" found for character at '+stream.pos}break;case">":context=context.addChild();stream.next();break;case"+":context=context.parent.addChild();stream.next();break;case"^":var parent=context.parent||context;context=(parent.parent||parent).addChild();stream.next();break;default:stream.start=stream.pos;stream.eatWhile(function(c){if(c=="["||c=="{"){if(stream.skipToPair(c,pairs[c])){stream.backUp(1);return true}throw'Invalid abbreviation: mo matching "'+pairs[c]+'" found for character at '+stream.pos}if(c=="+"){stream.next();var isMarker=stream.eol()||~"+>^*".indexOf(stream.peek());stream.backUp(1);return isMarker}return c!="("&&isAllowedChar(c)});context.setAbbreviation(stream.current());stream.start=stream.pos}}if(loopProtector<1){throw"Endless loop detected"}return root}function extractAttributes(attrSet,attrs){attrSet=require("utils").trim(attrSet);var result=[];var stream=require("stringStream").create(attrSet);stream.eatSpace();while(!stream.eol()){stream.start=stream.pos;if(stream.eatWhile(reWord)){var attrName=stream.current();var attrValue="";if(stream.peek()=="="){stream.next();stream.start=stream.pos;var quote=stream.peek();if(quote=='"'||quote=="'"){stream.next();if(consumeQuotedValue(stream,quote)){attrValue=stream.current();attrValue=attrValue.substring(1,attrValue.length-1)}else{throw"Invalid attribute value"}}else{if(stream.eatWhile(/[^\s\]]/)){attrValue=stream.current()}else{throw"Invalid attribute value"}}}result.push({name:attrName,value:attrValue});stream.eatSpace()}else{break}}return result}function parseAttributes(abbr){var result=[];var attrMap={"#":"id",".":"class"};var nameEnd=null;var stream=require("stringStream").create(abbr);while(!stream.eol()){switch(stream.peek()){case"#":case".":if(nameEnd===null){nameEnd=stream.pos}var attrName=attrMap[stream.peek()];stream.next();stream.start=stream.pos;stream.eatWhile(reWord);result.push({name:attrName,value:stream.current()});break;case"[":if(nameEnd===null){nameEnd=stream.pos}stream.start=stream.pos;if(!stream.skipToPair("[","]")){throw"Invalid attribute set definition"}result=result.concat(extractAttributes(stripped(stream.current())));break;default:stream.next()}}if(!result.length){return null}return{element:abbr.substring(0,nameEnd),attributes:optimizeAttributes(result)}}function optimizeAttributes(attrs){attrs=_.map(attrs,function(attr){return _.clone(attr)});var lookup={};return _.filter(attrs,function(attr){if(!(attr.name in lookup)){return lookup[attr.name]=attr}var la=lookup[attr.name];if(attr.name.toLowerCase()=="class"){la.value+=(la.value.length?" ":"")+attr.value}else{la.value=attr.value}return false})}function extractText(abbr){if(!~abbr.indexOf("{")){return null}var stream=require("stringStream").create(abbr);while(!stream.eol()){switch(stream.peek()){case"[":case"(":stream.skipToPair(stream.peek(),pairs[stream.peek()]);break;case"{":stream.start=stream.pos;stream.skipToPair("{","}");return{element:abbr.substring(0,stream.start),text:stripped(stream.current())};default:stream.next()}}}function unroll(node){for(var i=node.children.length-1,j,child,maxCount;i>=0;i--){child=node.children[i];if(child.isRepeating()){maxCount=j=child.repeatCount;child.repeatCount=1;child.updateProperty("counter",1);child.updateProperty("maxCount",maxCount);while(--j>0){child.parent.addChild(child.clone(),i+1).updateProperty("counter",j+1).updateProperty("maxCount",maxCount)}}}_.each(node.children,unroll);return node}function squash(node){for(var i=node.children.length-1;i>=0;i--){var n=node.children[i];if(n.isGroup()){n.replace(squash(n).children)}else{
_.each(postprocessors,function(fn){fn(tree,options)});return tree},AbbreviationNode:AbbreviationNode,addPreprocessor:function(fn){if(!_.include(preprocessors,fn)){preprocessors.push(fn)}},removeFilter:function(fn){preprocessor=_.without(preprocessors,fn)},addPostprocessor:function(fn){if(!_.include(postprocessors,fn)){postprocessors.push(fn)}},removePostprocessor:function(fn){postprocessors=_.without(postprocessors,fn)},addOutputProcessor:function(fn){if(!_.include(outputProcessors,fn)){outputProcessors.push(fn)}},removeOutputProcessor:function(fn){outputProcessors=_.without(outputProcessors,fn)},isAllowedChar:function(ch){ch=String(ch);return isAllowedChar(ch)||~">+^[](){}".indexOf(ch)}}});emmet.exec(function(require,_){function matchResources(node,syntax){var resources=require("resources");var elements=require("elements");var parser=require("abbreviationParser");_.each(_.clone(node.children),function(child){var r=resources.getMatchedResource(child,syntax);if(_.isString(r)){child.data("resource",elements.create("snippet",r))}else{if(elements.is(r,"reference")){var subtree=parser.parse(r.data,{syntax:syntax});if(child.repeatCount>1){var repeatedChildren=subtree.findAll(function(node){return node.hasImplicitRepeat});_.each(repeatedChildren,function(node){node.repeatCount=child.repeatCount;node.hasImplicitRepeat=false})}var deepestChild=subtree.deepestChild();if(deepestChild){_.each(child.children,function(c){deepestChild.addChild(c)})}_.each(subtree.children,function(node){_.each(child.attributeList(),function(attr){node.attribute(attr.name,attr.value)})});child.replace(subtree.children)}else{child.data("resource",r)}}matchResources(child,syntax)})}require("abbreviationParser").addPreprocessor(function(tree,options){var syntax=options.syntax||emmet.defaultSyntax();matchResources(tree,syntax)})});emmet.exec(function(require,_){var parser=require("abbreviationParser");var outputPlaceholder="$#";function locateOutputPlaceholder(text){var range=require("range");var result=[];var stream=require("stringStream").create(text);while(!stream.eol()){if(stream.peek()=="\\"){stream.next()}else{stream.start=stream.pos;if(stream.match(outputPlaceholder,true)){result.push(range.create(stream.start,outputPlaceholder));continue}}stream.next()}return result}function replaceOutputPlaceholders(source,value){var utils=require("utils");var ranges=locateOutputPlaceholder(source);ranges.reverse();_.each(ranges,function(r){source=utils.replaceSubstring(source,value,r)});return source}function hasOutputPlaceholder(node){if(locateOutputPlaceholder(node.content).length){return true}return !!_.find(node.attributeList(),function(attr){return !!locateOutputPlaceholder(attr.value).length})}function insertPastedContent(node,content,overwrite){var nodesWithPlaceholders=node.findAll(function(item){return hasOutputPlaceholder(item)});if(hasOutputPlaceholder(node)){nodesWithPlaceholders.unshift(node)}if(nodesWithPlaceholders.length){_.each(nodesWithPlaceholders,function(item){item.content=replaceOutputPlaceholders(item.content,content);_.each(item._attributes,function(attr){attr.value=replaceOutputPlaceholders(attr.value,content)})})}else{var deepest=node.deepestChild()||node;if(overwrite){deepest.content=content}else{deepest.content=require("abbreviationUtils").insertChildContent(deepest.content,content)}}}parser.addPreprocessor(function(tree,options){if(options.pastedContent){var utils=require("utils");var lines=_.map(utils.splitByLines(options.pastedContent,true),utils.trim);tree.findAll(function(item){if(item.hasImplicitRepeat){item.data("paste",lines);return item.repeatCount=lines.length}})}});parser.addPostprocessor(function(tree,options){var targets=tree.findAll(function(item){var pastedContentObj=item.data("paste");var pastedContent="";if(_.isArray(pastedContentObj)){pastedContent=pastedContentObj[item.counter-1]}else{if(_.isFunction(pastedContentObj)){pastedContent=pastedContentObj(item.counter-1,item.content)}else{if(pastedContentObj){pastedContent=pastedContentObj}}}if(pastedContent){insertPastedContent(item,pastedContent,!!item.data("pasteOverwri
if(me.total_lines<=me.linenum){me.line=false}else{me.line=me.lines[me.linenum]}if(me.chnum!==-1){me.chnum=0}return me.line},nextChar:function(){var me=this;me.chnum+=1;while(me.line.charAt(me.chnum)===""){if(this.nextLine()===false){me.ch=false;return false}me.chnum=-1;me.ch="\n";return"\n"}me.ch=me.line.charAt(me.chnum);return me.ch},peek:function(){return this.line.charAt(this.chnum+1)}};isNameChar=function(c){return(c=="&"||c==="_"||c==="-"||(c>="a"&&c<="z")||(c>="A"&&c<="Z"))};isDigit=function(ch){return(ch!==false&&ch>="0"&&ch<="9")};isOp=(function(){var opsa="{}[]()+*=.,;:>~|\\%$#@^!".split(""),opsmatcha="*^|$~".split(""),ops={},opsmatch={},i=0;for(;i<opsa.length;i+=1){ops[opsa[i]]=true}for(i=0;i<opsmatcha.length;i+=1){opsmatch[opsmatcha[i]]=true}return function(ch,matchattr){if(matchattr){return !!opsmatch[ch]}return !!ops[ch]}}());function isset(v){return typeof v!=="undefined"}function getConf(){return{"char":walker.chnum,line:walker.linenum}}function tokener(value,type,conf){var w=walker,c=conf||{};tokens.push({charstart:isset(c["char"])?c["char"]:w.chnum,charend:isset(c.charend)?c.charend:w.chnum,linestart:isset(c.line)?c.line:w.linenum,lineend:isset(c.lineend)?c.lineend:w.linenum,value:value,type:type||value})}function error(m,config){var w=walker,conf=config||{},c=isset(conf["char"])?conf["char"]:w.chnum,l=isset(conf.line)?conf.line:w.linenum;return{name:"ParseError",message:m+" at line "+(l+1)+" char "+(c+1),walker:w,tokens:tokens}}function white(){var c=walker.ch,token="",conf=getConf();while(c===" "||c==="\t"){token+=c;c=walker.nextChar()}tokener(token,"white",conf)}function comment(){var w=walker,c=w.ch,token=c,cnext,conf=getConf();cnext=w.nextChar();if(cnext==="/"){token+=cnext;var pk=w.peek();while(pk&&pk!=="\n"){token+=cnext;cnext=w.nextChar();pk=w.peek()}}else{if(cnext==="*"){while(!(c==="*"&&cnext==="/")){token+=cnext;c=cnext;cnext=w.nextChar()}}else{conf.charend=conf["char"];conf.lineend=conf.line;return tokener(token,token,conf)}}token+=cnext;w.nextChar();tokener(token,"comment",conf)}function str(){var w=walker,c=w.ch,q=c,token=c,cnext,conf=getConf();c=w.nextChar();while(c!==q){if(c==="\n"){cnext=w.nextChar();if(cnext==="\\"){token+=c+cnext}else{throw error("Unterminated string",conf)}}else{if(c==="\\"){token+=c+w.nextChar()}else{token+=c}}c=w.nextChar()}token+=c;w.nextChar();tokener(token,"string",conf)}function brace(){var w=walker,c=w.ch,depth=0,token=c,conf=getConf();c=w.nextChar();while(c!==")"&&!depth){if(c==="("){depth++}else{if(c===")"){depth--}else{if(c===false){throw error("Unterminated brace",conf)}}}token+=c;c=w.nextChar()}token+=c;w.nextChar();tokener(token,"brace",conf)}function identifier(pre){var w=walker,c=w.ch,conf=getConf(),token=(pre)?pre+c:c;c=w.nextChar();if(pre){conf["char"]-=pre.length}while(isNameChar(c)||isDigit(c)){token+=c;c=w.nextChar()}tokener(token,"identifier",conf)}function num(){var w=walker,c=w.ch,conf=getConf(),token=c,point=token===".",nondigit;c=w.nextChar();nondigit=!isDigit(c);if(point&&nondigit){conf.charend=conf["char"];conf.lineend=conf.line;return tokener(token,".",conf)}if(token==="-"&&nondigit){return identifier("-")}while(c!==false&&(isDigit(c)||(!point&&c==="."))){if(c==="."){point=true}token+=c;c=w.nextChar()}tokener(token,"number",conf)}function op(){var w=walker,c=w.ch,conf=getConf(),token=c,next=w.nextChar();if(next==="="&&isOp(token,true)){token+=next;tokener(token,"match",conf);w.nextChar();return}conf.charend=conf["char"]+1;conf.lineend=conf.line;tokener(token,token,conf)}function tokenize(){var ch=walker.ch;if(ch===" "||ch==="\t"){return white()}if(ch==="/"){return comment()}if(ch==='"'||ch==="'"){return str()}if(ch==="("){return brace()}if(ch==="-"||ch==="."||isDigit(ch)){return num()}if(isNameChar(ch)){return identifier()}if(isOp(ch)){return op()}if(ch==="\n"){tokener("line");walker.nextChar();return}throw error("Unrecognized character")}function getNewline(content,pos){return content.charAt(pos)=="\r"&&content.charAt(pos+1)=="\n"?"\r\n":content.charAt(pos)}return{lex:function(source){walker.init(source);tokens=[];while(walker.ch!==false)
return chain(doctype(1))}else{return null}}}}else{if(stream.eat("?")){stream.eatWhile(/[\w\._\-]/);state.tokenize=inBlock("meta","?>");return"meta"}else{type=stream.eat("/")?"closeTag":"openTag";stream.eatSpace();tagName="";var c;while((c=stream.eat(/[^\s\u00a0=<>\"\'\/?]/))){tagName+=c}state.tokenize=inTag;return"tag"}}}else{if(ch=="&"){var ok;if(stream.eat("#")){if(stream.eat("x")){ok=stream.eatWhile(/[a-fA-F\d]/)&&stream.eat(";")}else{ok=stream.eatWhile(/[\d]/)&&stream.eat(";")}}else{ok=stream.eatWhile(/[\w\.\-:]/)&&stream.eat(";")}return ok?"atom":"error"}else{stream.eatWhile(/[^&<]/);return"text"}}}function inTag(stream,state){var ch=stream.next();if(ch==">"||(ch=="/"&&stream.eat(">"))){state.tokenize=inText;type=ch==">"?"endTag":"selfcloseTag";return"tag"}else{if(ch=="="){type="equals";return null}else{if(/[\'\"]/.test(ch)){state.tokenize=inAttribute(ch);return state.tokenize(stream,state)}else{stream.eatWhile(/[^\s\u00a0=<>\"\'\/?]/);return"word"}}}}function inAttribute(quote){return function(stream,state){while(!stream.eol()){if(stream.next()==quote){state.tokenize=inTag;break}}return"string"}}function inBlock(style,terminator){return function(stream,state){while(!stream.eol()){if(stream.match(terminator)){state.tokenize=inText;break}stream.next()}return style}}function doctype(depth){return function(stream,state){var ch;while((ch=stream.next())!=null){if(ch=="<"){state.tokenize=doctype(depth+1);return state.tokenize(stream,state)}else{if(ch==">"){if(depth==1){state.tokenize=inText;break}else{state.tokenize=doctype(depth-1);return state.tokenize(stream,state)}}}}return"meta"}}var curState=null,setStyle;function pass(){for(var i=arguments.length-1;i>=0;i--){curState.cc.push(arguments[i])}}function cont(){pass.apply(null,arguments);return true}function pushContext(tagName,startOfLine){var noIndent=Kludges.doNotIndent.hasOwnProperty(tagName)||(curState.context&&curState.context.noIndent);curState.context={prev:curState.context,tagName:tagName,indent:curState.indented,startOfLine:startOfLine,noIndent:noIndent}}function popContext(){if(curState.context){curState.context=curState.context.prev}}function element(type){if(type=="openTag"){curState.tagName=tagName;return cont(attributes,endtag(curState.startOfLine))}else{if(type=="closeTag"){var err=false;if(curState.context){if(curState.context.tagName!=tagName){if(Kludges.implicitlyClosed.hasOwnProperty(curState.context.tagName.toLowerCase())){popContext()}err=!curState.context||curState.context.tagName!=tagName}}else{err=true}if(err){setStyle="error"}return cont(endclosetag(err))}}return cont()}function endtag(startOfLine){return function(type){if(type=="selfcloseTag"||(type=="endTag"&&Kludges.autoSelfClosers.hasOwnProperty(curState.tagName.toLowerCase()))){maybePopContext(curState.tagName.toLowerCase());return cont()}if(type=="endTag"){maybePopContext(curState.tagName.toLowerCase());pushContext(curState.tagName,startOfLine);return cont()}return cont()}}function endclosetag(err){return function(type){if(err){setStyle="error"}if(type=="endTag"){popContext();return cont()}setStyle="error";return cont(arguments.callee)}}function maybePopContext(nextTagName){var parentTagName;while(true){if(!curState.context){return}parentTagName=curState.context.tagName.toLowerCase();if(!Kludges.contextGrabbers.hasOwnProperty(parentTagName)||!Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)){return}popContext()}}function attributes(type){if(type=="word"){setStyle="attribute";return cont(attribute,attributes)}if(type=="endTag"||type=="selfcloseTag"){return pass()}setStyle="error";return cont(attributes)}function attribute(type){if(type=="equals"){return cont(attvalue,attributes)}if(!Kludges.allowMissing){setStyle="error"}return(type=="endTag"||type=="selfcloseTag")?pass():cont()}function attvalue(type){if(type=="string"){return cont(attvaluemaybe)}if(type=="word"&&Kludges.allowUnquoted){setStyle="string";return cont()}setStyle="error";return(type=="endTag"||type=="selfCloseTag")?pass():cont()}function attvaluemaybe(type){if(type=="string"){return cont(attvaluemaybe)}else{
/*!
* string_score.js: String Scoring Algorithm 0.1.10
*
* http://joshaven.com/string_score
* https://github.com/joshaven/string_score
*
* Copyright (C) 2009-2011 Joshaven Potter <yourtech@gmail.com>
* Special thanks to all of the contributors listed here https://github.com/joshaven/string_score
* MIT license: http://www.opensource.org/licenses/mit-license.php
*
* Date: Tue Mar 1 2011
*/
emmet.define("string-score",function(require,_){return{score:function(string,abbreviation,fuzziness){if(string==abbreviation){return 1
}if(abbreviation==""){return 0}var total_character_score=0,abbreviation_length=abbreviation.length,string_length=string.length,start_of_string_bonus,abbreviation_score,fuzzies=1,final_score;for(var i=0,character_score,index_in_string,c,index_c_lowercase,index_c_uppercase,min_index;i<abbreviation_length;++i){c=abbreviation.charAt(i);index_c_lowercase=string.indexOf(c.toLowerCase());index_c_uppercase=string.indexOf(c.toUpperCase());min_index=Math.min(index_c_lowercase,index_c_uppercase);index_in_string=(min_index>-1)?min_index:Math.max(index_c_lowercase,index_c_uppercase);if(index_in_string===-1){if(fuzziness){fuzzies+=1-fuzziness;continue}else{return 0}}else{character_score=0.1}if(string[index_in_string]===c){character_score+=0.1}if(index_in_string===0){character_score+=0.6;if(i===0){start_of_string_bonus=1}}else{if(string.charAt(index_in_string-1)===" "){character_score+=0.8}}string=string.substring(index_in_string+1,string_length);total_character_score+=character_score}abbreviation_score=total_character_score/abbreviation_length;final_score=((abbreviation_score*(abbreviation_length/string_length))+abbreviation_score)/2;final_score=final_score/fuzzies;if(start_of_string_bonus&&(final_score+0.15<1)){final_score+=0.15}return final_score}}});emmet.define("utils",function(require,_){var caretPlaceholder="${0}";function StringBuilder(value){this._data=[];this.length=0;if(value){this.append(value)}}StringBuilder.prototype={append:function(text){this._data.push(text);this.length+=text.length},toString:function(){return this._data.join("")},valueOf:function(){return this.toString()}};return{reTag:/<\/?[\w:\-]+(?:\s+[\w\-:]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*\s*(\/?)>$/,endsWithTag:function(str){return this.reTag.test(str)},isNumeric:function(ch){if(typeof(ch)=="string"){ch=ch.charCodeAt(0)}return(ch&&ch>47&&ch<58)},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"")},getNewline:function(){var res=require("resources");if(!res){return"\n"}var nl=res.getVariable("newline");return _.isString(nl)?nl:"\n"},setNewline:function(str){var res=require("resources");res.setVariable("newline",str);res.setVariable("nl",str)},splitByLines:function(text,removeEmpty){var nl=this.getNewline();var lines=(text||"").replace(/\r\n/g,"\n").replace(/\n\r/g,"\n").replace(/\r/g,"\n").replace(/\n/g,nl).split(nl);if(removeEmpty){lines=_.filter(lines,function(line){return line.length&&!!this.trim(line)},this)}return lines},normalizeNewline:function(text){return this.splitByLines(text).join(this.getNewline())},repeatString:function(str,howMany){var result=[];for(var i=0;i<howMany;i++){result.push(str)}return result.join("")},getStringsPads:function(strings){var lengths=_.map(strings,function(s){return _.isString(s)?s.length:+s});var max=_.max(lengths);return _.map(lengths,function(l){var pad=max-l;return pad?this.repeatString(" ",pad):""},this)},padString:function(text,pad){var padStr=(_.isNumber(pad))?this.repeatString(require("resources").getVariable("indentation")||"\t",pad):pad;var result=[];var lines=this.splitByLines(text);var nl=this.getNewline();result.push(lines[0]);for(var j=1;j<lines.length;j++){result.push(nl+padStr+lines[j])}return result.join("")},zeroPadString:function(str,pad){var padding="";var il=str.length;while(pad>il++){padding+="0"}return padding+str},unindentString:function(text,pad){var lines=this.splitByLines(text);for(var i=0;i<lines.length;i++){if(lines[i].search(pad)==0){lines[i]=lines[i].substr(pad.length)}}return lines.join(this.getNewline())},replaceUnescapedSymbol:function(str,symbol,replace){var i=0;var il=str.length;var sl=symbol.length;var matchCount=0;while(i<il){if(str.charAt(i)=="\\"){i+=sl+1}else{if(str.substr(i,sl)==symbol){var curSl=sl;matchCount++;var newValue=replace;if(_.isFunction(replace)){var replaceData=replace(str,symbol,i,matchCount);if(replaceData){curSl=replaceData[0].length;newValue=replaceData[1]}else{newValue=false}}if(newValue===false){i++;continue}str=str.substring(0,i)+newValue+str.substring(i+curSl);il=str.length;i+=newValue.length}else{i++}}}return str},replaceVariables:funct
}if(decrement&&total&&_.isNumber(value)){value=total-value+1}value+=base;return[str.substring(pos,j),that.zeroPadString(value+"",pad)]})},matchesTag:function(str){return this.reTag.test(str||"")},escapeText:function(text){return text.replace(/([\$\\])/g,"\\$1")},unescapeText:function(text){return text.replace(/\\(.)/g,"$1")},getCaretPlaceholder:function(){return _.isFunction(caretPlaceholder)?caretPlaceholder.apply(this,arguments):caretPlaceholder},setCaretPlaceholder:function(value){caretPlaceholder=value},getLinePadding:function(line){return(line.match(/^(\s+)/)||[""])[0]},getLinePaddingFromPosition:function(content,pos){var lineRange=this.findNewlineBounds(content,pos);return this.getLinePadding(lineRange.substring(content))},escapeForRegexp:function(str){var specials=new RegExp("[.*+?|()\\[\\]{}\\\\]","g");return str.replace(specials,"\\$&")},prettifyNumber:function(num,fraction){return num.toFixed(typeof fraction=="undefined"?2:fraction).replace(/\.?0+$/,"")},stringBuilder:function(value){return new StringBuilder(value)},replaceSubstring:function(str,value,start,end){if(_.isObject(start)&&"end" in start){end=start.end;start=start.start}if(_.isString(end)){end=start+end.length}if(_.isUndefined(end)){end=start}if(start<0||start>str.length){return str}return str.substring(0,start)+value+str.substring(end)},narrowToNonSpace:function(text,start,end){var range=require("range").create(start,end);var reSpace=/[\s\n\r\u00a0]/;while(range.start<range.end){if(!reSpace.test(text.charAt(range.start))){break}range.start++}while(range.end>range.start){range.end--;if(!reSpace.test(text.charAt(range.end))){range.end++;break}}return range},findNewlineBounds:function(text,from){var len=text.length,start=0,end=len-1;for(var i=from-1;i>0;i--){var ch=text.charAt(i);if(ch=="\n"||ch=="\r"){start=i+1;break}}for(var j=from;j<len;j++){var ch=text.charAt(j);if(ch=="\n"||ch=="\r"){end=j;break}}return require("range").create(start,end-start)},deepMerge:function(){var options,name,src,copy,copyIsArray,clone,target=arguments[0]||{},i=1,length=arguments.length;if(!_.isObject(target)&&!_.isFunction(target)){target={}}for(;i<length;i++){if((options=arguments[i])!=null){for(name in options){src=target[name];copy=options[name];if(target===copy){continue}if(copy&&(_.isObject(copy)||(copyIsArray=_.isArray(copy)))){if(copyIsArray){copyIsArray=false;clone=src&&_.isArray(src)?src:[]}else{clone=src&&_.isObject(src)?src:{}}target[name]=this.deepMerge(clone,copy)}else{if(copy!==undefined){target[name]=copy}}}}}return target}}});emmet.define("range",function(require,_){function cmp(a,b,op){switch(op){case"eq":case"==":return a===b;case"lt":case"<":return a<b;case"lte":case"<=":return a<=b;case"gt":case">":return a>b;case"gte":case">=":return a>=b}}function Range(start,len){if(_.isObject(start)&&"start" in start){this.start=Math.min(start.start,start.end);this.end=Math.max(start.start,start.end)}else{if(_.isArray(start)){this.start=start[0];this.end=start[1]}else{len=_.isString(len)?len.length:+len;this.start=start;this.end=start+len}}}Range.prototype={length:function(){return Math.abs(this.end-this.start)},equal:function(range){return this.cmp(range,"eq","eq")},shift:function(delta){this.start+=delta;this.end+=delta;return this},overlap:function(range){return range.start<=this.end&&range.end>=this.start},intersection:function(range){if(this.overlap(range)){var start=Math.max(range.start,this.start);var end=Math.min(range.end,this.end);return new Range(start,end-start)}return null},union:function(range){if(this.overlap(range)){var start=Math.min(range.start,this.start);var end=Math.max(range.end,this.end);return new Range(start,end-start)}return null},inside:function(loc){return this.cmp(loc,"lte","gt")},contains:function(loc){return this.cmp(loc,"lt","gt")},include:function(r){return this.cmp(loc,"lte","gte")},cmp:function(loc,left,right){var a,b;if(loc instanceof Range){a=loc.start;b=loc.end}else{a=b=loc}return cmp(this.start,a,left||"<=")&&cmp(this.end,b,right||">")},substring:function(str){return this.length()>0?str.substring(this.start,this.end):""},clone:
},exec:function(skipValue,args){args=args||[];var result=null;_.find(this.list(),function(h){result=h.fn.apply(h,args);if(result!==skipValue){return true}});return result}};return{create:function(){return new HandlerList()}}});emmet.define("tokenIterator",function(require,_){function TokenIterator(tokens){this.tokens=tokens;this._position=0;this.reset()}TokenIterator.prototype={next:function(){if(this.hasNext()){var token=this.tokens[++this._i];this._position=token.start;return token}return null},current:function(){return this.tokens[this._i]},position:function(){return this._position},hasNext:function(){return this._i<this._il-1},reset:function(){this._i=-1;this._il=this.tokens.length},item:function(){return this.tokens[this._i]},itemNext:function(){return this.tokens[this._i+1]},itemPrev:function(){return this.tokens[this._i-1]},nextUntil:function(type,callback){var token;var test=_.isString(type)?function(t){return t.type==type}:type;while(token=this.next()){if(callback){callback.call(this,token)}if(test.call(this,token)){break}}}};return{create:function(tokens){return new TokenIterator(tokens)}}});emmet.define("stringStream",function(require,_){function StringStream(string){this.pos=this.start=0;this.string=string}StringStream.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==0},peek:function(){return this.string.charAt(this.pos)},next:function(){if(this.pos<this.string.length){return this.string.charAt(this.pos++)}},eat:function(match){var ch=this.string.charAt(this.pos),ok;if(typeof match=="string"){ok=ch==match}else{ok=ch&&(match.test?match.test(ch):match(ch))}if(ok){++this.pos;return ch}},eatWhile:function(match){var start=this.pos;while(this.eat(match)){}return this.pos>start},eatSpace:function(){var start=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos))){++this.pos}return this.pos>start},skipToEnd:function(){this.pos=this.string.length},skipTo:function(ch){var found=this.string.indexOf(ch,this.pos);if(found>-1){this.pos=found;return true}},skipToPair:function(open,close){var braceCount=0,ch;var pos=this.pos,len=this.string.length;while(pos<len){ch=this.string.charAt(pos++);if(ch==open){braceCount++}else{if(ch==close){braceCount--;if(braceCount<1){this.pos=pos;return true}}}}return false},backUp:function(n){this.pos-=n},match:function(pattern,consume,caseInsensitive){if(typeof pattern=="string"){var cased=caseInsensitive?function(str){return str.toLowerCase()}:function(str){return str};if(cased(this.string).indexOf(cased(pattern),this.pos)==this.pos){if(consume!==false){this.pos+=pattern.length}return true}}else{var match=this.string.slice(this.pos).match(pattern);if(match&&consume!==false){this.pos+=match[0].length}return match}},current:function(){return this.string.slice(this.start,this.pos)}};return{create:function(string){return new StringStream(string)}}});emmet.define("resources",function(require,_){var VOC_SYSTEM="system";var VOC_USER="user";var cache={};var reTag=/^<(\w+\:?[\w\-]*)((?:\s+[\w\:\-]+\s*=\s*(['"]).*?\3)*)\s*(\/?)>/;var systemSettings={};var userSettings={};var resolvers=require("handlerList").create();function normalizeCaretPlaceholder(text){var utils=require("utils");return utils.replaceUnescapedSymbol(text,"|",utils.getCaretPlaceholder())}function parseItem(name,value,type){value=normalizeCaretPlaceholder(value);if(type=="snippets"){return require("elements").create("snippet",value)}if(type=="abbreviations"){return parseAbbreviation(name,value)}}function parseAbbreviation(key,value){key=require("utils").trim(key);var elements=require("elements");var m;if(m=reTag.exec(value)){return elements.create("element",m[1],m[2],m[4]=="/")}else{return elements.create("reference",value)}}function normalizeName(str){return str.replace(/:$/,"").replace(/:/g,"-")}return{setVocabulary:function(data,type){cache={};if(type==VOC_SYSTEM){systemSettings=data}else{userSettings=data}},getVocabulary:function(name){return name==VOC_SYSTEM?systemSettings:userSettings},getMatchedResource:function(node,syntax){return resolvers.exec(null,_.toArray(arguments))
}data=this.getSection(data["extends"])}},findSnippet:function(syntax,name,memo){if(!syntax||!name){return null}memo=memo||[];var names=[name];if(~name.indexOf("-")){names.push(name.replace(/\-/g,":"))}var data=this.getSection(syntax),matchedItem=null;_.find(["snippets","abbreviations"],function(sectionName){var data=this.getSection(syntax,sectionName);if(data){return _.find(names,function(n){if(data[n]){return matchedItem=parseItem(n,data[n],sectionName)}})}},this);memo.push(syntax);if(!matchedItem&&data["extends"]&&!_.include(memo,data["extends"])){return this.findSnippet(data["extends"],name,memo)}return matchedItem},fuzzyFindSnippet:function(syntax,name,minScore){minScore=minScore||0.3;var payload=this.getAllSnippets(syntax);var sc=require("string-score");name=normalizeName(name);var scores=_.map(payload,function(value,key){return{key:key,score:sc.score(value.nk,name,0.1)}});var result=_.last(_.sortBy(scores,"score"));if(result&&result.score>=minScore){var k=result.key;return payload[k].parsedValue}},getAllSnippets:function(syntax){var cacheKey="all-"+syntax;if(!cache[cacheKey]){var stack=[],sectionKey=syntax;var memo=[];do{var section=this.getSection(sectionKey);if(!section){break}_.each(["snippets","abbreviations"],function(sectionName){var stackItem={};_.each(section[sectionName]||null,function(v,k){stackItem[k]={nk:normalizeName(k),value:v,parsedValue:parseItem(k,v,sectionName),type:sectionName}});stack.push(stackItem)});memo.push(sectionKey);sectionKey=section["extends"]}while(sectionKey&&!_.include(memo,sectionKey));cache[cacheKey]=_.extend.apply(_,stack.reverse())}return cache[cacheKey]}}});emmet.define("actions",function(require,_,zc){var actions={};function humanizeActionName(name){return require("utils").trim(name.charAt(0).toUpperCase()+name.substring(1).replace(/_[a-z]/g,function(str){return" "+str.charAt(1).toUpperCase()}))}return{add:function(name,fn,options){name=name.toLowerCase();options=options||{};if(!options.label){options.label=humanizeActionName(name)}actions[name]={name:name,fn:fn,options:options}},get:function(name){return actions[name.toLowerCase()]},run:function(name,args){if(!_.isArray(args)){args=_.rest(arguments)}var action=this.get(name);if(action){return action.fn.apply(emmet,args)}else{emmet.log('Action "%s" is not defined',name);return false}},getAll:function(){return actions},getList:function(){return _.values(this.getAll())},getMenu:function(skipActions){var result=[];skipActions=skipActions||[];_.each(this.getList(),function(action){if(action.options.hidden||_.include(skipActions,action.name)){return}var actionName=humanizeActionName(action.name);var ctx=result;if(action.options.label){var parts=action.options.label.split("/");actionName=parts.pop();var menuName,submenu;while(menuName=parts.shift()){submenu=_.find(ctx,function(item){return item.type=="submenu"&&item.name==menuName});if(!submenu){submenu={name:menuName,type:"submenu",items:[]};ctx.push(submenu)}ctx=submenu.items}}ctx.push({type:"action",name:action.name,label:actionName})});return result},getActionNameForMenuTitle:function(title,menu){var item=null;_.find(menu||this.getMenu(),function(val){if(val.type=="action"){if(val.label==title||val.name==title){return item=val.name}}else{return item=this.getActionNameForMenuTitle(title,val.items)}},this);return item||null}}});emmet.define("profile",function(require,_){var profiles={};var defaultProfile={tag_case:"asis",attr_case:"asis",attr_quotes:"double",tag_nl:"decide",tag_nl_leaf:false,place_cursor:true,indent:true,inline_break:3,self_closing_tag:"xhtml",filters:"",extraFilters:""};function OutputProfile(options){_.extend(this,defaultProfile,options)}OutputProfile.prototype={tagName:function(name){return stringCase(name,this.tag_case)},attributeName:function(name){return stringCase(name,this.attr_case)},attributeQuote:function(){return this.attr_quotes=="single"?"'":'"'},selfClosing:function(param){if(this.self_closing_tag=="xhtml"){return" /"}if(this.self_closing_tag===true){return"/"}return""},cursor:function(){return this.place_cursor?require("utils").getCaretPlaceholder
}if(name instanceof OutputProfile){return name}if(_.isString(name)&&name.toLowerCase() in profiles){return profiles[name.toLowerCase()]}return this.create(name)},remove:function(name){name=(name||"").toLowerCase();if(name in profiles){delete profiles[name]}},reset:function(){profiles={};createDefaultProfiles()},stringCase:stringCase}});emmet.define("editorUtils",function(require,_){return{isInsideTag:function(html,caretPos){var reTag=/^<\/?\w[\w\:\-]*.*?>/;var pos=caretPos;while(pos>-1){if(html.charAt(pos)=="<"){break}pos--}if(pos!=-1){var m=reTag.exec(html.substring(pos));if(m&&caretPos>pos&&caretPos<pos+m[0].length){return true}}return false},outputInfo:function(editor,syntax,profile){profile=profile||editor.getProfileName();return{syntax:String(syntax||editor.getSyntax()),profile:profile||null,content:String(editor.getContent())}},unindent:function(editor,text){return require("utils").unindentString(text,this.getCurrentLinePadding(editor))},getCurrentLinePadding:function(editor){return require("utils").getLinePadding(editor.getCurrentLine())}}});emmet.define("actionUtils",function(require,_){return{mimeTypes:{"gif":"image/gif","png":"image/png","jpg":"image/jpeg","jpeg":"image/jpeg","svg":"image/svg+xml","html":"text/html","htm":"text/html"},extractAbbreviation:function(str){var curOffset=str.length;var startIndex=-1;var groupCount=0;var braceCount=0;var textCount=0;var utils=require("utils");var parser=require("abbreviationParser");while(true){curOffset--;if(curOffset<0){startIndex=0;break}var ch=str.charAt(curOffset);if(ch=="]"){braceCount++}else{if(ch=="["){if(!braceCount){startIndex=curOffset+1;break}braceCount--}else{if(ch=="}"){textCount++}else{if(ch=="{"){if(!textCount){startIndex=curOffset+1;break}textCount--}else{if(ch==")"){groupCount++}else{if(ch=="("){if(!groupCount){startIndex=curOffset+1;break}groupCount--}else{if(braceCount||textCount){continue}else{if(!parser.isAllowedChar(ch)||(ch==">"&&utils.endsWithTag(str.substring(0,curOffset+1)))){startIndex=curOffset+1;break}}}}}}}}}if(startIndex!=-1&&!textCount&&!braceCount&&!groupCount){return str.substring(startIndex).replace(/^[\*\+\>\^]+/,"")}else{return""}},getImageSize:function(stream){var pngMagicNum="\211PNG\r\n\032\n",jpgMagicNum="\377\330",gifMagicNum="GIF8",nextByte=function(){return stream.charCodeAt(pos++)};if(stream.substr(0,8)===pngMagicNum){var pos=stream.indexOf("IHDR")+4;return{width:(nextByte()<<24)|(nextByte()<<16)|(nextByte()<<8)|nextByte(),height:(nextByte()<<24)|(nextByte()<<16)|(nextByte()<<8)|nextByte()}}else{if(stream.substr(0,4)===gifMagicNum){pos=6;return{width:nextByte()|(nextByte()<<8),height:nextByte()|(nextByte()<<8)}}else{if(stream.substr(0,2)===jpgMagicNum){pos=2;var l=stream.length;while(pos<l){if(nextByte()!=255){return}var marker=nextByte();if(marker==218){break}var size=(nextByte()<<8)|nextByte();if(marker>=192&&marker<=207&&!(marker&4)&&!(marker&8)){pos+=1;return{height:(nextByte()<<8)|nextByte(),width:(nextByte()<<8)|nextByte()}}else{pos+=size-2}}}}}},captureContext:function(editor){var allowedSyntaxes={"html":1,"xml":1,"xsl":1};var syntax=String(editor.getSyntax());if(syntax in allowedSyntaxes){var content=String(editor.getContent());var tag=require("htmlMatcher").find(content,editor.getCaretPos());if(tag&&tag.type=="tag"){var startTag=tag.open;var contextNode={name:startTag.name,attributes:[]};var tagTree=require("xmlEditTree").parse(startTag.range.substring(content));if(tagTree){contextNode.attributes=_.map(tagTree.getAll(),function(item){return{name:item.name(),value:item.value()}})}return contextNode}}return null},findExpressionBounds:function(editor,fn){var content=String(editor.getContent());var il=content.length;var exprStart=editor.getCaretPos()-1;var exprEnd=exprStart+1;while(exprStart>=0&&fn(content.charAt(exprStart),exprStart,content)){exprStart--}while(exprEnd<il&&fn(content.charAt(exprEnd),exprEnd,content)){exprEnd++}if(exprEnd>exprStart){return require("range").create([++exprStart,exprEnd])}},compoundUpdate:function(editor,data){if(data){var sel=editor.getSelectionRange();editor.replaceContent(data.data,da
var tag=require("htmlMatcher").tag(content,caretPos);return tag&&tag.open.name.toLowerCase()=="style"&&tag.innerRange.cmp(caretPos,"lte","gte")},isInlineCSS:function(editor){var content=String(editor.getContent());var caretPos=editor.getCaretPos();var tree=require("xmlEditTree").parseFromPosition(content,caretPos,true);if(tree){var attr=tree.itemFromPosition(caretPos,true);return attr&&attr.name().toLowerCase()=="style"&&attr.valueRange(true).cmp(caretPos,"lte","gte")}return false}}});emmet.define("abbreviationUtils",function(require,_){return{isSnippet:function(node){return require("elements").is(node.matchedResource(),"snippet")},isUnary:function(node){if(node.children.length||node._text||this.isSnippet(node)){return false}var r=node.matchedResource();return r&&r.is_empty},isInline:function(node){return node.isTextNode()||!node.name()||require("tagName").isInlineLevel(node.name())},isBlock:function(node){return this.isSnippet(node)||!this.isInline(node)},isSnippet:function(node){return require("elements").is(node.matchedResource(),"snippet")},hasTagsInContent:function(node){return require("utils").matchesTag(node.content)},hasBlockChildren:function(node){return(this.hasTagsInContent(node)&&this.isBlock(node))||_.any(node.children,function(child){return this.isBlock(child)},this)},insertChildContent:function(text,childContent,options){options=_.extend({keepVariable:true,appendIfNoChild:true},options||{});var childVariableReplaced=false;var utils=require("utils");text=utils.replaceVariables(text,function(variable,name,data){var output=variable;if(name=="child"){output=utils.padString(childContent,utils.getLinePaddingFromPosition(text,data.start));childVariableReplaced=true;if(options.keepVariable){output+=variable}}return output});if(!childVariableReplaced&&options.appendIfNoChild){text+=childContent}return text}}});emmet.define("base64",function(require,_){var chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return{encode:function(input){var output=[];var chr1,chr2,chr3,enc1,enc2,enc3,enc4,cdp1,cdp2,cdp3;var i=0,il=input.length,b64=chars;while(i<il){cdp1=input.charCodeAt(i++);cdp2=input.charCodeAt(i++);cdp3=input.charCodeAt(i++);chr1=cdp1&255;chr2=cdp2&255;chr3=cdp3&255;enc1=chr1>>2;enc2=((chr1&3)<<4)|(chr2>>4);enc3=((chr2&15)<<2)|(chr3>>6);enc4=chr3&63;if(isNaN(cdp2)){enc3=enc4=64}else{if(isNaN(cdp3)){enc4=64}}output.push(b64.charAt(enc1)+b64.charAt(enc2)+b64.charAt(enc3)+b64.charAt(enc4))}return output.join("")},decode:function(data){var o1,o2,o3,h1,h2,h3,h4,bits,i=0,ac=0,tmpArr=[];var b64=chars,il=data.length;if(!data){return data}data+="";do{h1=b64.indexOf(data.charAt(i++));h2=b64.indexOf(data.charAt(i++));h3=b64.indexOf(data.charAt(i++));h4=b64.indexOf(data.charAt(i++));bits=h1<<18|h2<<12|h3<<6|h4;o1=bits>>16&255;o2=bits>>8&255;o3=bits&255;if(h3==64){tmpArr[ac++]=String.fromCharCode(o1)}else{if(h4==64){tmpArr[ac++]=String.fromCharCode(o1,o2)}else{tmpArr[ac++]=String.fromCharCode(o1,o2,o3)}}}while(i<il);return tmpArr.join("")}}});emmet.define("htmlMatcher",function(require,_){var reOpenTag=/^<([\w\:\-]+)((?:\s+[\w\-:]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/;var reCloseTag=/^<\/([\w\:\-]+)[^>]*>/;function openTag(i,match){return{name:match[1],selfClose:!!match[3],range:require("range").create(i,match[0]),type:"open"}}function closeTag(i,match){return{name:match[1],range:require("range").create(i,match[0]),type:"close"}}function comment(i,match){return{range:require("range").create(i,_.isNumber(match)?match-i:match[0]),type:"comment"}}function createMatcher(text){var memo={},m;return{open:function(i){var m=this.matches(i);return m&&m.type=="open"?m:null},close:function(i){var m=this.matches(i);return m&&m.type=="close"?m:null},matches:function(i){var key="p"+i;if(!(key in memo)){if(text.charAt(i)=="<"){var substr=text.slice(i);if(m=substr.match(reOpenTag)){memo[key]=openTag(i,m)}else{if(m=substr.match(reCloseTag)){memo[key]=closeTag(i,m)}else{memo[key]=false}}}}return memo[key]},text:function(){return text}}}function matches(text,pos,pattern){return text.substring(pos,pos
if(close){var r=range.create2(open.range.start,close.range.end);if(r.contains(pos)){break}}else{if(open.range.contains(pos)){break}}open=null}else{if(matches(text,i,"-->")){for(var j=i-1;j>=0;j--){if(matches(text,j,"-->")){break}else{if(matches(text,j,"<!--")){i=j;break}}}}else{if(matches(text,i,"<!--")){var j=i+4,jl=text.length;for(;j<jl;j++){if(matches(text,j,"-->")){j+=3;break}}open=comment(i,j);break}}}}if(open){var outerRange=null;var innerRange=null;if(close){outerRange=range.create2(open.range.start,close.range.end);innerRange=range.create2(open.range.end,close.range.start)}else{outerRange=innerRange=range.create2(open.range.start,open.range.end)}if(open.type=="comment"){var _c=outerRange.substring(text);innerRange.start+=_c.length-_c.replace(/^<\!--\s*/,"").length;innerRange.end-=_c.length-_c.replace(/\s*-->$/,"").length}return{open:open,close:close,type:open.type=="comment"?"comment":"tag",innerRange:innerRange,innerContent:function(){return this.innerRange.substring(text)},outerRange:outerRange,outerContent:function(){return this.outerRange.substring(text)},range:!innerRange.length()||!innerRange.cmp(pos,"lte","gte")?outerRange:innerRange,content:function(){return this.range.substring(text)},source:text}}},tag:function(text,pos){var result=this.find(text,pos);if(result&&result.type=="tag"){return result}}}});emmet.define("tabStops",function(require,_){var startPlaceholderNum=100;var tabstopIndex=0;var defaultOptions={replaceCarets:false,escape:function(ch){return"\\"+ch},tabstop:function(data){return data.token},variable:function(data){return data.token}};require("abbreviationParser").addOutputProcessor(function(text,node,type){var maxNum=0;var tabstops=require("tabStops");var utils=require("utils");var tsOptions={tabstop:function(data){var group=parseInt(data.group);if(group==0){return"${0}"}if(group>maxNum){maxNum=group}if(data.placeholder){var ix=group+tabstopIndex;var placeholder=tabstops.processText(data.placeholder,tsOptions);return"${"+ix+":"+placeholder+"}"}else{return"${"+(group+tabstopIndex)+"}"}}};text=tabstops.processText(text,tsOptions);text=utils.replaceVariables(text,tabstops.variablesResolver(node));tabstopIndex+=maxNum+1;return text});return{extract:function(text,options){var utils=require("utils");var placeholders={carets:""};var marks=[];options=_.extend({},defaultOptions,options,{tabstop:function(data){var token=data.token;var ret="";if(data.placeholder=="cursor"){marks.push({start:data.start,end:data.start+token.length,group:"carets",value:""})}else{if("placeholder" in data){placeholders[data.group]=data.placeholder}if(data.group in placeholders){ret=placeholders[data.group]}marks.push({start:data.start,end:data.start+token.length,group:data.group,value:ret})}return token}});if(options.replaceCarets){text=text.replace(new RegExp(utils.escapeForRegexp(utils.getCaretPlaceholder()),"g"),"${0:cursor}")}text=this.processText(text,options);var buf=utils.stringBuilder(),lastIx=0;var tabStops=_.map(marks,function(mark){buf.append(text.substring(lastIx,mark.start));var pos=buf.length;var ph=placeholders[mark.group]||"";buf.append(ph);lastIx=mark.end;return{group:mark.group,start:pos,end:pos+ph.length}});buf.append(text.substring(lastIx));return{text:buf.toString(),tabstops:_.sortBy(tabStops,"start")}},processText:function(text,options){options=_.extend({},defaultOptions,options);var buf=require("utils").stringBuilder();var stream=require("stringStream").create(text);var ch,m,a;while(ch=stream.next()){if(ch=="\\"&&!stream.eol()){buf.append(options.escape(stream.next()));continue}a=ch;if(ch=="$"){stream.start=stream.pos-1;if(m=stream.match(/^[0-9]+/)){a=options.tabstop({start:buf.length,group:stream.current().substr(1),token:stream.current()})}else{if(m=stream.match(/^\{([a-z_\-][\w\-]*)\}/)){a=options.variable({start:buf.length,name:m[1],token:stream.current()})}else{if(m=stream.match(/^\{([0-9]+)(:.+?)?\}/,false)){stream.skipToPair("{","}");var obj={start:buf.length,group:m[1],token:stream.current()};var placeholder=obj.token.substring(obj.group.length+2,obj.token.length-1);if(placeholder){obj.plac
}},resetTabstopIndex:function(){tabstopIndex=0;startPlaceholderNum=100}}});emmet.define("preferences",function(require,_){var preferences={};var defaults={};var _dbgDefaults=null;var _dbgPreferences=null;function toBoolean(val){if(_.isString(val)){val=val.toLowerCase();return val=="yes"||val=="true"||val=="1"}return !!val}function isValueObj(obj){return _.isObject(obj)&&"value" in obj&&_.keys(obj).length<3}return{define:function(name,value,description){var prefs=name;if(_.isString(name)){prefs={};prefs[name]={value:value,description:description}}_.each(prefs,function(v,k){defaults[k]=isValueObj(v)?v:{value:v}})},set:function(name,value){var prefs=name;if(_.isString(name)){prefs={};prefs[name]=value}_.each(prefs,function(v,k){if(!(k in defaults)){throw'Property "'+k+'" is not defined. You should define it first with `define` method of current module'}if(v!==defaults[k].value){switch(typeof defaults[k].value){case"boolean":v=toBoolean(v);break;case"number":v=parseInt(v+"",10)||0;break;default:if(v!==null){v+=""}}preferences[k]=v}else{if(k in preferences){delete preferences[k]}}})},get:function(name){if(name in preferences){return preferences[name]}if(name in defaults){return defaults[name].value}return void 0},getArray:function(name){var val=this.get(name);if(_.isUndefined(val)||val===null||val===""){return null}val=_.map(val.split(","),require("utils").trim);if(!val.length){return null}return val},getDict:function(name){var result={};_.each(this.getArray(name),function(val){var parts=val.split(":");result[parts[0]]=parts[1]});return result},description:function(name){return name in defaults?defaults[name].description:void 0},remove:function(name){if(!_.isArray(name)){name=[name]}_.each(name,function(key){if(key in preferences){delete preferences[key]}if(key in defaults){delete defaults[key]}})},list:function(){return _.map(_.keys(defaults).sort(),function(key){return{name:key,value:this.get(key),type:typeof defaults[key].value,description:defaults[key].description}},this)},load:function(json){_.each(json,function(value,key){this.set(key,value)},this)},exportModified:function(){return _.clone(preferences)},reset:function(){preferences={}},_startTest:function(){_dbgDefaults=defaults;_dbgPreferences=preferences;defaults={};preferences={}},_stopTest:function(){defaults=_dbgDefaults;preferences=_dbgPreferences}}});emmet.define("filters",function(require,_){var registeredFilters={};var basicFilters="html";function list(filters){if(!filters){return[]}if(_.isString(filters)){return filters.split(/[\|,]/g)}return filters}return{add:function(name,fn){registeredFilters[name]=fn},apply:function(tree,filters,profile){var utils=require("utils");profile=require("profile").get(profile);_.each(list(filters),function(filter){var name=utils.trim(filter.toLowerCase());if(name&&name in registeredFilters){tree=registeredFilters[name](tree,profile)}});return tree},composeList:function(syntax,profile,additionalFilters){profile=require("profile").get(profile);var filters=list(profile.filters||require("resources").findItem(syntax,"filters")||basicFilters);if(profile.extraFilters){filters=filters.concat(list(profile.extraFilters))}if(additionalFilters){filters=filters.concat(list(additionalFilters))}if(!filters||!filters.length){filters=list(basicFilters)}return filters},extractFromAbbreviation:function(abbr){var filters="";abbr=abbr.replace(/\|([\w\|\-]+)$/,function(str,p1){filters=p1;return""});return[abbr,list(filters)]}}});emmet.define("elements",function(require,_){var factories={};var reAttrs=/([\w\-:]+)\s*=\s*(['"])(.*?)\2/g;var result={add:function(name,factory){var that=this;factories[name]=function(){var elem=factory.apply(that,arguments);if(elem){elem.type=name}return elem}},get:function(name){return factories[name]},create:function(name){var args=[].slice.call(arguments,1);var factory=this.get(name);return factory?factory.apply(this,args):null},is:function(elem,type){return elem&&elem.type===type}};function commonFactory(value){return{data:value}}result.add("element",function(elementName,attrs,isEmpty){var ret={name:elementName,is_empt
}})};update(this._positions);_.each(this.list(),function(item){update(item._positions)});this.source=require("utils").replaceSubstring(this.source,value,r)},add:function(name,value,pos){var item=new EditElement(name,value);this._children.push(item);return item},get:function(name){if(_.isNumber(name)){return this.list()[name]}if(_.isString(name)){return _.find(this.list(),function(prop){return prop.name()===name})}return name},getAll:function(name){if(!_.isArray(name)){name=[name]}var names=[],indexes=[];_.each(name,function(item){if(_.isString(item)){names.push(item)}else{if(_.isNumber(item)){indexes.push(item)}}});return _.filter(this.list(),function(attribute,i){return _.include(indexes,i)||_.include(names,attribute.name())})},value:function(name,value,pos){var element=this.get(name);if(element){return element.value(value)}if(!_.isUndefined(value)){return this.add(name,value,pos)}},values:function(name){return _.map(this.getAll(name),function(element){return element.value()})},remove:function(name){var element=this.get(name);if(element){this._updateSource("",element.fullRange());this._children=_.without(this._children,element)}},list:function(){return this._children},indexOf:function(item){return _.indexOf(this.list(),this.get(item))},name:function(val){if(!_.isUndefined(val)&&this._name!==(val=String(val))){this._updateSource(val,this._positions.name,this._positions.name+this._name.length);this._name=val}return this._name},nameRange:function(isAbsolute){return range(this._positions.name+(isAbsolute?this.options.offset:0),this.name())},range:function(isAbsolute){return range(isAbsolute?this.options.offset:0,this.toString())},itemFromPosition:function(pos,isAbsolute){return _.find(this.list(),function(elem){return elem.range(isAbsolute).inside(pos)})},toString:function(){return this.source}};function EditElement(parent,nameToken,valueToken){this.parent=parent;this._name=nameToken.value;this._value=valueToken?valueToken.value:"";this._positions={name:nameToken.start,value:valueToken?valueToken.start:-1};this.initialize.apply(this,arguments)}EditElement.extend=core.extend;EditElement.prototype={initialize:function(){},_pos:function(num,isAbsolute){return num+(isAbsolute?this.parent.options.offset:0)},value:function(val){if(!_.isUndefined(val)&&this._value!==(val=String(val))){this.parent._updateSource(val,this.valueRange());this._value=val}return this._value},name:function(val){if(!_.isUndefined(val)&&this._name!==(val=String(val))){this.parent._updateSource(val,this.nameRange());this._name=val}return this._name},namePosition:function(isAbsolute){return this._pos(this._positions.name,isAbsolute)},valuePosition:function(isAbsolute){return this._pos(this._positions.value,isAbsolute)},range:function(isAbsolute){return range(this.namePosition(isAbsolute),this.toString())},fullRange:function(isAbsolute){return this.range(isAbsolute)},nameRange:function(isAbsolute){return range(this.namePosition(isAbsolute),this.name())},valueRange:function(isAbsolute){return range(this.valuePosition(isAbsolute),this.value())},toString:function(){return this.name()+this.value()},valueOf:function(){return this.toString()}};return{EditContainer:EditContainer,EditElement:EditElement,createToken:function(start,value,type){var obj={start:start||0,value:value||"",type:type};obj.end=obj.start+obj.value.length;return obj}}});emmet.define("cssEditTree",function(require,_){var defaultOptions={styleBefore:"\n\t",styleSeparator:": ",offset:0};var WHITESPACE_REMOVE_FROM_START=1;var WHITESPACE_REMOVE_FROM_END=2;function range(start,len){return require("range").create(start,len)}function trimWhitespaceTokens(tokens,mask){mask=mask||(WHITESPACE_REMOVE_FROM_START|WHITESPACE_REMOVE_FROM_END);var whitespace=["white","line"];if((mask&WHITESPACE_REMOVE_FROM_END)==WHITESPACE_REMOVE_FROM_END){while(tokens.length&&_.include(whitespace,_.last(tokens).type)){tokens.pop()}}if((mask&WHITESPACE_REMOVE_FROM_START)==WHITESPACE_REMOVE_FROM_START){while(tokens.length&&_.include(whitespace,tokens[0].type)){tokens.shift()}}return tokens}function findSelectorRange(it){var tokens
var sep=/[\s\u00a0,]/;var add=function(){stream.next();result.push(range(stream.start,stream.current()));stream.start=stream.pos};stream.eatSpace();stream.start=stream.pos;while(ch=stream.next()){if(ch=='"'||ch=="'"){stream.next();if(!stream.skipTo(ch)){break}add()}else{if(ch=="("){stream.backUp(1);if(!stream.skipToPair("(",")")){break}stream.backUp(1);add()}else{if(sep.test(ch)){result.push(range(stream.start,stream.current().length-1));stream.eatWhile(sep);stream.start=stream.pos}}}}add();return _.chain(result).filter(function(item){return !!item.length()}).uniq(false,function(item){return item.toString()}).value()}function isValidIdentifier(it){var tokens=it.tokens;for(var i=it._i+1,il=tokens.length;i<il;i++){if(tokens[i].type==":"){return true}if(tokens[i].type=="identifier"||tokens[i].type=="line"){return false}}return false}var CSSEditContainer=require("editTree").EditContainer.extend({initialize:function(source,options){_.defaults(this.options,defaultOptions);var editTree=require("editTree");var it=require("tokenIterator").create(require("cssParser").parse(source));var selectorRange=findSelectorRange(it);this._positions.name=selectorRange.start;this._name=selectorRange.substring(source);if(!it.current()||it.current().type!="{"){throw"Invalid CSS rule"}this._positions.contentStart=it.position()+1;var propertyRange,valueRange,token;while(token=it.next()){if(token.type=="identifier"&&isValidIdentifier(it)){propertyRange=range(token);valueRange=findValueRange(it);var end=(it.current()&&it.current().type==";")?range(it.current()):range(valueRange.end,0);this._children.push(new CSSEditElement(this,editTree.createToken(propertyRange.start,propertyRange.substring(source)),editTree.createToken(valueRange.start,valueRange.substring(source)),editTree.createToken(end.start,end.substring(source))))}}this._saveStyle()},_saveStyle:function(){var start=this._positions.contentStart;var source=this.source;var utils=require("utils");_.each(this.list(),function(p){p.styleBefore=source.substring(start,p.namePosition());var lines=utils.splitByLines(p.styleBefore);if(lines.length>1){p.styleBefore="\n"+_.last(lines)}p.styleSeparator=source.substring(p.nameRange().end,p.valuePosition());p.styleBefore=_.last(p.styleBefore.split("*/"));p.styleSeparator=p.styleSeparator.replace(/\/\*.*?\*\//g,"");start=p.range().end})},add:function(name,value,pos){var list=this.list();var start=this._positions.contentStart;var styles=_.pick(this.options,"styleBefore","styleSeparator");var editTree=require("editTree");if(_.isUndefined(pos)){pos=list.length}var donor=list[pos];if(donor){start=donor.fullRange().start}else{if(donor=list[pos-1]){donor.end(";");start=donor.range().end}}if(donor){styles=_.pick(donor,"styleBefore","styleSeparator")}var nameToken=editTree.createToken(start+styles.styleBefore.length,name);var valueToken=editTree.createToken(nameToken.end+styles.styleSeparator.length,value);var property=new CSSEditElement(this,nameToken,valueToken,editTree.createToken(valueToken.end,";"));_.extend(property,styles);this._updateSource(property.styleBefore+property.toString(),start);this._children.splice(pos,0,property);return property}});var CSSEditElement=require("editTree").EditElement.extend({initialize:function(rule,name,value,end){this.styleBefore=rule.options.styleBefore;this.styleSeparator=rule.options.styleSeparator;this._end=end.value;this._positions.end=end.start},valueParts:function(isAbsolute){var parts=findParts(this.value());if(isAbsolute){var offset=this.valuePosition(true);_.each(parts,function(p){p.shift(offset)})}return parts},end:function(val){if(!_.isUndefined(val)&&this._end!==val){this.parent._updateSource(val,this._positions.end,this._positions.end+this._end.length);this._end=val}return this._end},fullRange:function(isAbsolute){var r=this.range(isAbsolute);r.start-=this.styleBefore.length;return r},toString:function(){return this.name()+this.styleSeparator+this.value()+this.end()}});return{parse:function(source,options){return new CSSEditContainer(source,options)},parseFromPosition:function(content,pos,isBackward){var bounds=this.
},findParts:findParts}});emmet.define("xmlEditTree",function(require,_){var defaultOptions={styleBefore:" ",styleSeparator:"=",styleQuote:'"',offset:0};var startTag=/^<([\w\:\-]+)((?:\s+[\w\-:]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/m;var XMLEditContainer=require("editTree").EditContainer.extend({initialize:function(source,options){_.defaults(this.options,defaultOptions);this._positions.name=1;var attrToken=null;var tokens=require("xmlParser").parse(source);var range=require("range");_.each(tokens,function(token){token.value=range.create(token).substring(source);switch(token.type){case"tag":if(/^<[^\/]+/.test(token.value)){this._name=token.value.substring(1)}break;case"attribute":if(attrToken){this._children.push(new XMLEditElement(this,attrToken))}attrToken=token;break;case"string":this._children.push(new XMLEditElement(this,attrToken,token));attrToken=null;break}},this);if(attrToken){this._children.push(new XMLEditElement(this,attrToken))}this._saveStyle()},_saveStyle:function(){var start=this.nameRange().end;var source=this.source;_.each(this.list(),function(p){p.styleBefore=source.substring(start,p.namePosition());if(p.valuePosition()!==-1){p.styleSeparator=source.substring(p.namePosition()+p.name().length,p.valuePosition()-p.styleQuote.length)}start=p.range().end})},add:function(name,value,pos){var list=this.list();var start=this.nameRange().end;var editTree=require("editTree");var styles=_.pick(this.options,"styleBefore","styleSeparator","styleQuote");if(_.isUndefined(pos)){pos=list.length}var donor=list[pos];if(donor){start=donor.fullRange().start}else{if(donor=list[pos-1]){start=donor.range().end}}if(donor){styles=_.pick(donor,"styleBefore","styleSeparator","styleQuote")}value=styles.styleQuote+value+styles.styleQuote;var attribute=new XMLEditElement(this,editTree.createToken(start+styles.styleBefore.length,name),editTree.createToken(start+styles.styleBefore.length+name.length+styles.styleSeparator.length,value));_.extend(attribute,styles);this._updateSource(attribute.styleBefore+attribute.toString(),start);this._children.splice(pos,0,attribute);return attribute}});var XMLEditElement=require("editTree").EditElement.extend({initialize:function(parent,nameToken,valueToken){this.styleBefore=parent.options.styleBefore;this.styleSeparator=parent.options.styleSeparator;var value="",quote=parent.options.styleQuote;if(valueToken){value=valueToken.value;quote=value.charAt(0);if(quote=='"'||quote=="'"){value=value.substring(1)}else{quote=""}if(quote&&value.charAt(value.length-1)==quote){value=value.substring(0,value.length-1)}}this.styleQuote=quote;this._value=value;this._positions.value=valueToken?valueToken.start+quote.length:-1},fullRange:function(isAbsolute){var r=this.range(isAbsolute);r.start-=this.styleBefore.length;return r},toString:function(){return this.name()+this.styleSeparator+this.styleQuote+this.value()+this.styleQuote}});return{parse:function(source,options){return new XMLEditContainer(source,options)},parseFromPosition:function(content,pos,isBackward){var bounds=this.extractTag(content,pos,isBackward);if(!bounds||!bounds.inside(pos)){return null}return this.parse(bounds.substring(content),{offset:bounds.start})},extractTag:function(content,pos,isBackward){var len=content.length,i;var range=require("range");var maxLen=Math.min(2000,len);var r=null;var match=function(pos){var m;if(content.charAt(pos)=="<"&&(m=content.substr(pos,maxLen).match(startTag))){return range.create(pos,m[0])}};for(i=pos;i>=0;i--){if(r=match(i)){break}}if(r&&(r.inside(pos)||isBackward)){return r}if(!r&&isBackward){return null}for(i=pos;i<len;i++){if(r=match(i)){return r}}}}});emmet.define("expandAbbreviation",function(require,_){var handlers=require("handlerList").create();var module=null;var actions=require("actions");actions.add("expand_abbreviation",function(editor,syntax,profile){var args=_.toArray(arguments);var info=require("editorUtils").outputInfo(editor,syntax,profile);args[1]=info.syntax;args[2]=info.profile;return handlers.exec(false,args)});actions.add("expand_abbreviation_with_tab",function(editor,s
if(content){editor.replaceContent(content,caretPos-abbr.length,caretPos);return true}}return false},{order:-1});return module={addHandler:function(fn,options){handlers.add(fn,options)},removeHandler:function(fn){handlers.remove(fn,options)},findAbbreviation:function(editor){var range=require("range").create(editor.getSelectionRange());var content=String(editor.getContent());if(range.length()){return range.substring(content)}var curLine=editor.getCurrentLineRange();return require("actionUtils").extractAbbreviation(content.substring(curLine.start,range.start))}}});emmet.define("wrapWithAbbreviation",function(require,_){var module=null;require("actions").add("wrap_with_abbreviation",function(editor,abbr,syntax,profile){var info=require("editorUtils").outputInfo(editor,syntax,profile);var utils=require("utils");var editorUtils=require("editorUtils");abbr=abbr||editor.prompt("Enter abbreviation");if(!abbr){return null}abbr=String(abbr);var range=require("range").create(editor.getSelectionRange());if(!range.length()){var match=require("htmlMatcher").tag(info.content,range.start);if(!match){return false}range=utils.narrowToNonSpace(info.content,match.range)}var newContent=utils.escapeText(range.substring(info.content));var result=module.wrap(abbr,editorUtils.unindent(editor,newContent),info.syntax,info.profile,require("actionUtils").captureContext(editor));if(result){editor.replaceContent(result,range.start,range.end);return true}return false});return module={wrap:function(abbr,text,syntax,profile,contextNode){var filters=require("filters");var utils=require("utils");syntax=syntax||emmet.defaultSyntax();profile=require("profile").get(profile,syntax);require("tabStops").resetTabstopIndex();var data=filters.extractFromAbbreviation(abbr);var parsedTree=require("abbreviationParser").parse(data[0],{syntax:syntax,pastedContent:text,contextNode:contextNode});if(parsedTree){var filtersList=filters.composeList(syntax,profile,data[1]);filters.apply(parsedTree,filtersList,profile);return utils.replaceVariables(parsedTree.toString())}return null}}});emmet.exec(function(require,_){function toggleHTMLComment(editor){var range=require("range").create(editor.getSelectionRange());var info=require("editorUtils").outputInfo(editor);if(!range.length()){var tag=require("htmlMatcher").tag(info.content,editor.getCaretPos());if(tag){range=tag.outerRange}}return genericCommentToggle(editor,"<!--","-->",range)}function toggleCSSComment(editor){var range=require("range").create(editor.getSelectionRange());var info=require("editorUtils").outputInfo(editor);if(!range.length()){var rule=require("cssEditTree").parseFromPosition(info.content,editor.getCaretPos());if(rule){var property=cssItemFromPosition(rule,editor.getCaretPos());range=property?property.range(true):require("range").create(rule.nameRange(true).start,rule.source)}}if(!range.length()){range=require("range").create(editor.getCurrentLineRange());require("utils").narrowToNonSpace(info.content,range)}return genericCommentToggle(editor,"/*","*/",range)}function cssItemFromPosition(rule,absPos){var relPos=absPos-(rule.options.offset||0);var reSafeChar=/^[\s\n\r]/;return _.find(rule.list(),function(item){if(item.range().end===relPos){return reSafeChar.test(rule.source.charAt(relPos))}return item.range().inside(relPos)})}function searchComment(text,from,startToken,endToken){var commentStart=-1;var commentEnd=-1;var hasMatch=function(str,start){return text.substr(start,str.length)==str};while(from--){if(hasMatch(startToken,from)){commentStart=from;break}}if(commentStart!=-1){from=commentStart;var contentLen=text.length;while(contentLen>=from++){if(hasMatch(endToken,from)){commentEnd=from+endToken.length;break}}}return(commentStart!=-1&&commentEnd!=-1)?require("range").create(commentStart,commentEnd-commentStart):null}function genericCommentToggle(editor,commentStart,commentEnd,range){var editorUtils=require("editorUtils");var content=editorUtils.outputInfo(editor).content;var caretPos=editor.getCaretPos();var newContent=null;var utils=require("utils");function removeComment(str){return str.replace(new
if(info.syntax=="css"){var caretPos=editor.getCaretPos();var tag=require("htmlMatcher").tag(info.content,caretPos);if(tag&&tag.open.range.inside(caretPos)){info.syntax="html"}}if(info.syntax=="css"){return toggleCSSComment(editor)}return toggleHTMLComment(editor)})});emmet.exec(function(require,_){function findNewEditPoint(editor,inc,offset){inc=inc||1;offset=offset||0;var curPoint=editor.getCaretPos()+offset;var content=String(editor.getContent());var maxLen=content.length;var nextPoint=-1;var reEmptyLine=/^\s+$/;function getLine(ix){var start=ix;while(start>=0){var c=content.charAt(start);if(c=="\n"||c=="\r"){break}start--}return content.substring(start,ix)}while(curPoint<=maxLen&&curPoint>=0){curPoint+=inc;var curChar=content.charAt(curPoint);var nextChar=content.charAt(curPoint+1);var prevChar=content.charAt(curPoint-1);switch(curChar){case'"':case"'":if(nextChar==curChar&&prevChar=="="){nextPoint=curPoint+1}break;case">":if(nextChar=="<"){nextPoint=curPoint+1}break;case"\n":case"\r":if(reEmptyLine.test(getLine(curPoint-1))){nextPoint=curPoint}break}if(nextPoint!=-1){break}}return nextPoint}var actions=require("actions");actions.add("prev_edit_point",function(editor){var curPos=editor.getCaretPos();var newPoint=findNewEditPoint(editor,-1);if(newPoint==curPos){newPoint=findNewEditPoint(editor,-1,-2)}if(newPoint!=-1){editor.setCaretPos(newPoint);return true}return false},{label:"Previous Edit Point"});actions.add("next_edit_point",function(editor){var newPoint=findNewEditPoint(editor,1);if(newPoint!=-1){editor.setCaretPos(newPoint);return true}return false})});emmet.exec(function(require,_){var startTag=/^<([\w\:\-]+)((?:\s+[\w\-:]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/;function findItem(editor,isBackward,extractFn,rangeFn){var range=require("range");var content=require("editorUtils").outputInfo(editor).content;var contentLength=content.length;var itemRange,rng;var prevRange=range.create(-1,0);var sel=range.create(editor.getSelectionRange());var searchPos=sel.start,loop=100000;while(searchPos>=0&&searchPos<contentLength&&--loop>0){if((itemRange=extractFn(content,searchPos,isBackward))){if(prevRange.equal(itemRange)){break}prevRange=itemRange.clone();rng=rangeFn(itemRange.substring(content),itemRange.start,sel.clone());if(rng){editor.createSelection(rng.start,rng.end);return true}else{searchPos=isBackward?itemRange.start:itemRange.end-1}}searchPos+=isBackward?-1:1}return false}function findNextHTMLItem(editor){var isFirst=true;return findItem(editor,false,function(content,searchPos){if(isFirst){isFirst=false;return findOpeningTagFromPosition(content,searchPos)}else{return getOpeningTagFromPosition(content,searchPos)}},function(tag,offset,selRange){return getRangeForHTMLItem(tag,offset,selRange,false)})}function findPrevHTMLItem(editor){return findItem(editor,true,getOpeningTagFromPosition,function(tag,offset,selRange){return getRangeForHTMLItem(tag,offset,selRange,true)})}function makePossibleRangesHTML(source,tokens,offset){offset=offset||0;var range=require("range");var result=[];var attrStart=-1,attrName="",attrValue="",attrValueRange,tagName;_.each(tokens,function(tok){switch(tok.type){case"tag":tagName=source.substring(tok.start,tok.end);if(/^<[\w\:\-]/.test(tagName)){result.push(range.create({start:tok.start+1,end:tok.end}))}break;case"attribute":attrStart=tok.start;attrName=source.substring(tok.start,tok.end);break;case"string":result.push(range.create(attrStart,tok.end-attrStart));attrValueRange=range.create(tok);attrValue=attrValueRange.substring(source);if(isQuote(attrValue.charAt(0))){attrValueRange.start++}if(isQuote(attrValue.charAt(attrValue.length-1))){attrValueRange.end--}result.push(attrValueRange);if(attrName=="class"){result=result.concat(classNameRanges(attrValueRange.substring(source),attrValueRange.start))}break}});_.each(result,function(r){r.shift(offset)});return _.chain(result).filter(function(item){return !!item.length()}).uniq(false,function(item){return item.toString()}).value()}function classNameRanges(className,offset){offset=offset||0;var result=[];var stream=require
}}return _.find(ranges,function(r){return r.end>selRange.end})}function findOpeningTagFromPosition(html,pos){var tag;while(pos>=0){if(tag=getOpeningTagFromPosition(html,pos)){return tag}pos--}return null}function getOpeningTagFromPosition(html,pos){var m;if(html.charAt(pos)=="<"&&(m=html.substring(pos,html.length).match(startTag))){return require("range").create(pos,m[0])}}function isQuote(ch){return ch=='"'||ch=="'"}function makePossibleRangesCSS(property){var valueRange=property.valueRange(true);var result=[property.range(true),valueRange];var stringStream=require("stringStream");var cssEditTree=require("cssEditTree");var range=require("range");var value=property.value();_.each(property.valueParts(),function(r){var clone=r.clone();result.push(clone.shift(valueRange.start));var stream=stringStream.create(r.substring(value));if(stream.match(/^[\w\-]+\(/,true)){stream.start=stream.pos;stream.skipToPair("(",")");var fnBody=stream.current();result.push(range.create(clone.start+stream.start,fnBody));_.each(cssEditTree.findParts(fnBody),function(part){result.push(range.create(clone.start+stream.start+part.start,part.substring(fnBody)))})}});return _.chain(result).filter(function(item){return !!item.length()}).uniq(false,function(item){return item.toString()}).value()}function matchedRangeForCSSProperty(rule,selRange,isBackward){var property=null;var possibleRanges,curRange=null,ix;var list=rule.list();var searchFn,nearestItemFn;if(isBackward){list.reverse();searchFn=function(p){return p.range(true).start<=selRange.start};nearestItemFn=function(r){return r.start<selRange.start}}else{searchFn=function(p){return p.range(true).end>=selRange.end};nearestItemFn=function(r){return r.end>selRange.start}}while(property=_.find(list,searchFn)){possibleRanges=makePossibleRangesCSS(property);if(isBackward){possibleRanges.reverse()}curRange=_.find(possibleRanges,function(r){return r.equal(selRange)});if(!curRange){var matchedRanges=_.filter(possibleRanges,function(r){return r.inside(selRange.end)});if(matchedRanges.length>1){curRange=matchedRanges[1];break}if(curRange=_.find(possibleRanges,nearestItemFn)){break}}else{ix=_.indexOf(possibleRanges,curRange);if(ix!=possibleRanges.length-1){curRange=possibleRanges[ix+1];break}}curRange=null;selRange.start=selRange.end=isBackward?property.range(true).start-1:property.range(true).end+1}return curRange}function findNextCSSItem(editor){return findItem(editor,false,require("cssEditTree").extractRule,getRangeForNextItemInCSS)}function findPrevCSSItem(editor){return findItem(editor,true,require("cssEditTree").extractRule,getRangeForPrevItemInCSS)}function getRangeForNextItemInCSS(rule,offset,selRange){var tree=require("cssEditTree").parse(rule,{offset:offset});var range=tree.nameRange(true);if(selRange.end<range.end){return range}return matchedRangeForCSSProperty(tree,selRange,false)}function getRangeForPrevItemInCSS(rule,offset,selRange){var tree=require("cssEditTree").parse(rule,{offset:offset});var curRange=matchedRangeForCSSProperty(tree,selRange,true);if(!curRange){var range=tree.nameRange(true);if(selRange.start>range.start){return range}}return curRange}var actions=require("actions");actions.add("select_next_item",function(editor){if(editor.getSyntax()=="css"){return findNextCSSItem(editor)}else{return findNextHTMLItem(editor)}});actions.add("select_previous_item",function(editor){if(editor.getSyntax()=="css"){return findPrevCSSItem(editor)}else{return findPrevHTMLItem(editor)}})});emmet.exec(function(require,_){var actions=require("actions");var matcher=require("htmlMatcher");var lastMatch=null;function matchPair(editor,direction){direction=String((direction||"out").toLowerCase());var info=require("editorUtils").outputInfo(editor);var range=require("range");var sel=range.create(editor.getSelectionRange());var content=info.content;if(lastMatch&&!lastMatch.range.equal(sel)){lastMatch=null}if(lastMatch&&sel.length()){if(direction=="in"){if(lastMatch.type=="tag"&&!lastMatch.close){return false}else{if(lastMatch.range.equal(lastMatch.outerRange)){lastMatch.range=lastMatch.innerRange}else{var narro
actions.add("match_pair_outward",function(editor){return matchPair(editor,"out")},{label:"HTML/Match Pair Tag (outward)"});actions.add("matching_pair",function(editor){var content=String(editor.getContent());var caretPos=editor.getCaretPos();if(content.charAt(caretPos)=="<"){caretPos++}var tag=matcher.tag(content,caretPos);if(tag&&tag.close){if(tag.open.range.inside(caretPos)){editor.setCaretPos(tag.close.range.start)}else{editor.setCaretPos(tag.open.range.start)}return true}return false},{label:"HTML/Go To Matching Tag Pair"})});emmet.exec(function(require,_){require("actions").add("remove_tag",function(editor){var utils=require("utils");var info=require("editorUtils").outputInfo(editor);var tag=require("htmlMatcher").tag(info.content,editor.getCaretPos());if(tag){if(!tag.close){editor.replaceContent(utils.getCaretPlaceholder(),tag.range.start,tag.range.end)}else{var tagContentRange=utils.narrowToNonSpace(info.content,tag.innerRange);var startLineBounds=utils.findNewlineBounds(info.content,tagContentRange.start);var startLinePad=utils.getLinePadding(startLineBounds.substring(info.content));var tagContent=tagContentRange.substring(info.content);tagContent=utils.unindentString(tagContent,startLinePad);editor.replaceContent(utils.getCaretPlaceholder()+utils.escapeText(tagContent),tag.outerRange.start,tag.outerRange.end)}return true}return false},{label:"HTML/Remove Tag"})});emmet.exec(function(require,_){function joinTag(editor,profile,tag){var utils=require("utils");var slash=profile.selfClosing()||" /";var content=tag.open.range.substring(tag.source).replace(/\s*>$/,slash+">");var caretPos=editor.getCaretPos();if(content.length+tag.outerRange.start<caretPos){caretPos=content.length+tag.outerRange.start}content=utils.escapeText(content);editor.replaceContent(content,tag.outerRange.start,tag.outerRange.end);editor.setCaretPos(caretPos);return true}function splitTag(editor,profile,tag){var utils=require("utils");var nl=utils.getNewline();var pad=require("resources").getVariable("indentation");var caretPos=editor.getCaretPos();var tagContent=(profile.tag_nl===true)?nl+pad+nl:"";var content=tag.outerContent().replace(/\s*\/>$/,">");caretPos=tag.outerRange.start+content.length;content+=tagContent+"</"+tag.open.name+">";content=utils.escapeText(content);editor.replaceContent(content,tag.outerRange.start,tag.outerRange.end);editor.setCaretPos(caretPos);return true}require("actions").add("split_join_tag",function(editor,profileName){var matcher=require("htmlMatcher");var info=require("editorUtils").outputInfo(editor,null,profileName);var profile=require("profile").get(info.profile);var tag=matcher.tag(info.content,editor.getCaretPos());if(tag){return tag.close?joinTag(editor,profile,tag):splitTag(editor,profile,tag)}return false},{label:"HTML/Split\\Join Tag Declaration"})});emmet.define("reflectCSSValue",function(require,_){var handlers=require("handlerList").create();require("actions").add("reflect_css_value",function(editor){if(editor.getSyntax()!="css"){return false}return require("actionUtils").compoundUpdate(editor,doCSSReflection(editor))},{label:"CSS/Reflect Value"});function doCSSReflection(editor){var cssEditTree=require("cssEditTree");var outputInfo=require("editorUtils").outputInfo(editor);var caretPos=editor.getCaretPos();var cssRule=cssEditTree.parseFromPosition(outputInfo.content,caretPos);if(!cssRule){return}var property=cssRule.itemFromPosition(caretPos,true);if(!property){return}var oldRule=cssRule.source;var offset=cssRule.options.offset;var caretDelta=caretPos-offset-property.range().start;handlers.exec(false,[property]);if(oldRule!==cssRule.source){return{data:cssRule.source,start:offset,end:offset+oldRule.length,caret:offset+property.range().start+caretDelta}}}function getReflectedCSSName(name){name=require("cssEditTree").baseName(name);var vendorPrefix="^(?:\\-\\w+\\-)?",m;if(name=="opacity"||name=="filter"){return new RegExp(vendorPrefix+"(?:opacity|filter)$")}else{if(m=name.match(/^border-radius-(top|bottom)(left|right)/)){return new RegExp(vendorPrefix+"(?:"+name+"|border-"+m[1]+"-"+m[2]+"-radius)$")}el
_.each(property.parent.list(),function(p){if(reName.test(p.name())){reflectValue(property,p)}})},{order:-1});return{addHandler:function(fn,options){handlers.add(fn,options)},removeHandler:function(fn){handlers.remove(fn,options)}}});emmet.exec(function(require,_){require("actions").add("evaluate_math_expression",function(editor){var actionUtils=require("actionUtils");var utils=require("utils");var content=String(editor.getContent());var chars=".+-*/\\";var sel=require("range").create(editor.getSelectionRange());if(!sel.length()){sel=actionUtils.findExpressionBounds(editor,function(ch){return utils.isNumeric(ch)||chars.indexOf(ch)!=-1})}if(sel&&sel.length()){var expr=sel.substring(content);expr=expr.replace(/([\d\.\-]+)\\([\d\.\-]+)/g,"Math.round($1/$2)");try{var result=utils.prettifyNumber(new Function("return "+expr)());editor.replaceContent(result,sel.start,sel.end);editor.setCaretPos(sel.start+result.length);return true}catch(e){}}return false},{label:"Numbers/Evaluate Math Expression"})});emmet.exec(function(require,_){function incrementNumber(editor,step){var utils=require("utils");var actionUtils=require("actionUtils");var hasSign=false;var hasDecimal=false;var r=actionUtils.findExpressionBounds(editor,function(ch,pos,content){if(utils.isNumeric(ch)){return true}if(ch=="."){if(!utils.isNumeric(content.charAt(pos+1))){return false}return hasDecimal?false:hasDecimal=true}if(ch=="-"){return hasSign?false:hasSign=true}return false});if(r&&r.length()){var strNum=r.substring(String(editor.getContent()));var num=parseFloat(strNum);if(!_.isNaN(num)){num=utils.prettifyNumber(num+step);if(/^(\-?)0+[1-9]/.test(strNum)){var minus="";if(RegExp.$1){minus="-";num=num.substring(1)}var parts=num.split(".");parts[0]=utils.zeroPadString(parts[0],intLength(strNum));num=minus+parts.join(".")}editor.replaceContent(num,r.start,r.end);editor.createSelection(r.start,r.start+num.length);return true}}return false}function intLength(num){num=num.replace(/^\-/,"");if(~num.indexOf(".")){return num.split(".")[0].length}return num.length}var actions=require("actions");_.each([1,-1,10,-10,0.1,-0.1],function(num){var prefix=num>0?"increment":"decrement";actions.add(prefix+"_number_by_"+String(Math.abs(num)).replace(".","").substring(0,2),function(editor){return incrementNumber(editor,num)},{label:"Numbers/"+prefix.charAt(0).toUpperCase()+prefix.substring(1)+" number by "+Math.abs(num)})})});emmet.exec(function(require,_){var actions=require("actions");var prefs=require("preferences");prefs.define("css.closeBraceIndentation","\n","Indentation before closing brace of CSS rule. Some users prefere "+"indented closing brace of CSS rule for better readability. "+"This preferences value will be automatically inserted before "+"closing brace when user adds newline in newly created CSS rule "+"(e.g. when “Insert formatted linebreak” action will be performed "+"in CSS file). If youre such user, you may want to write put a value "+"like <code>\\n\\t</code> in this preference.");actions.add("insert_formatted_line_break_only",function(editor){var utils=require("utils");var res=require("resources");var info=require("editorUtils").outputInfo(editor);var caretPos=editor.getCaretPos();var nl=utils.getNewline();if(_.include(["html","xml","xsl"],info.syntax)){var pad=res.getVariable("indentation");var tag=require("htmlMatcher").tag(info.content,caretPos);if(tag&&!tag.innerRange.length()){editor.replaceContent(nl+pad+utils.getCaretPlaceholder()+nl,caretPos);return true}}else{if(info.syntax=="css"){var content=info.content;if(caretPos&&content.charAt(caretPos-1)=="{"){var append=prefs.get("css.closeBraceIndentation");var pad=res.getVariable("indentation");var hasCloseBrace=content.charAt(caretPos)=="}";if(!hasCloseBrace){for(var i=caretPos,il=content.length,ch;i<il;i++){ch=content.charAt(i);if(ch=="{"){break}if(ch=="}"){append="";hasCloseBrace=true;break}}}if(!hasCloseBrace){append+="}"}var insValue=nl+pad+utils.getCaretPlaceholder()+append;editor.replaceContent(insValue,caretPos);return true}}}return false},{hidden:true});actions.add("insert_formatted_line_
if(!selection.length()){var pair=matcher.find(info.content,editor.getCaretPos());if(pair){selection=pair.outerRange}}if(selection.length()){var text=selection.substring(info.content);var lines=utils.splitByLines(text);for(var i=1;i<lines.length;i++){lines[i]=lines[i].replace(/^\s+/,"")}text=lines.join("").replace(/\s{2,}/," ");var textLen=text.length;text=utils.escapeText(text);editor.replaceContent(text,selection.start,selection.end);editor.createSelection(selection.start,selection.start+textLen);return true}return false})});emmet.exec(function(require,_){require("actions").add("encode_decode_data_url",function(editor){var data=String(editor.getSelection());var caretPos=editor.getCaretPos();if(!data){var text=String(editor.getContent()),m;while(caretPos-->=0){if(startsWith("src=",text,caretPos)){if(m=text.substr(caretPos).match(/^(src=(["'])?)([^'"<>\s]+)\1?/)){data=m[3];caretPos+=m[1].length}break}else{if(startsWith("url(",text,caretPos)){if(m=text.substr(caretPos).match(/^(url\((['"])?)([^'"\)\s]+)\1?/)){data=m[3];caretPos+=m[1].length}break}}}}if(data){if(startsWith("data:",data)){return decodeFromBase64(editor,data,caretPos)}else{return encodeToBase64(editor,data,caretPos)}}return false},{label:"Encode\\Decode data:URL image"});function startsWith(token,text,pos){pos=pos||0;return text.charAt(pos)==token.charAt(0)&&text.substr(pos,token.length)==token}function encodeToBase64(editor,imgPath,pos){var file=require("file");var actionUtils=require("actionUtils");var editorFile=editor.getFilePath();var defaultMimeType="application/octet-stream";if(editorFile===null){throw"You should save your file before using this action"}var realImgPath=file.locateFile(editorFile,imgPath);if(realImgPath===null){throw"Can't find "+imgPath+" file"}file.read(realImgPath,function(err,content){if(err){throw"Unable to read "+realImgPath+": "+err}var b64=require("base64").encode(String(content));if(!b64){throw"Can't encode file content to base64"}b64="data:"+(actionUtils.mimeTypes[String(file.getExt(realImgPath))]||defaultMimeType)+";base64,"+b64;editor.replaceContent("$0"+b64,pos,pos+imgPath.length)});return true}function decodeFromBase64(editor,data,pos){var filePath=String(editor.prompt("Enter path to file (absolute or relative)"));if(!filePath){return false}var file=require("file");var absPath=file.createPath(editor.getFilePath(),filePath);if(!absPath){throw"Can't save file"}file.save(absPath,require("base64").decode(data.replace(/^data\:.+?;.+?,/,"")));editor.replaceContent("$0"+filePath,pos,pos+data.length);return true}});emmet.exec(function(require,_){function updateImageSizeHTML(editor){var offset=editor.getCaretPos();var info=require("editorUtils").outputInfo(editor);var xmlElem=require("xmlEditTree").parseFromPosition(info.content,offset,true);if(xmlElem&&(xmlElem.name()||"").toLowerCase()=="img"){getImageSizeForSource(editor,xmlElem.value("src"),function(size){if(size){var compoundData=xmlElem.range(true);xmlElem.value("width",size.width);xmlElem.value("height",size.height,xmlElem.indexOf("width")+1);require("actionUtils").compoundUpdate(editor,_.extend(compoundData,{data:xmlElem.toString(),caret:offset}))}})}}function updateImageSizeCSS(editor){var offset=editor.getCaretPos();var info=require("editorUtils").outputInfo(editor);var cssRule=require("cssEditTree").parseFromPosition(info.content,offset,true);if(cssRule){var prop=cssRule.itemFromPosition(offset,true),m;if(prop&&(m=/url\((["']?)(.+?)\1\)/i.exec(prop.value()||""))){getImageSizeForSource(editor,m[2],function(size){if(size){var compoundData=cssRule.range(true);cssRule.value("width",size.width+"px");cssRule.value("height",size.height+"px",cssRule.indexOf("width")+1);require("actionUtils").compoundUpdate(editor,_.extend(compoundData,{data:cssRule.toString(),caret:offset}))}})}}}function getImageSizeForSource(editor,src,callback){var fileContent;var au=require("actionUtils");if(src){if(/^data:/.test(src)){fileContent=require("base64").decode(src.replace(/^data\:.+?;.+?,/,""));return callback(au.getImageSize(fileContent))}var file=require("file");var absPath=file.locateFile(edi
prefs.define("css.propertyEnd",";","Defines a symbol that should be placed at the end of CSS property "+"when expanding CSS abbreviations.");prefs.define("stylus.valueSeparator"," ","Defines a symbol that should be placed between CSS property and "+"value when expanding CSS abbreviations in Stylus dialect.");prefs.define("stylus.propertyEnd","","Defines a symbol that should be placed at the end of CSS property "+"when expanding CSS abbreviations in Stylus dialect.");prefs.define("sass.propertyEnd","","Defines a symbol that should be placed at the end of CSS property "+"when expanding CSS abbreviations in SASS dialect.");prefs.define("css.autoInsertVendorPrefixes",true,"Automatically generate vendor-prefixed copies of expanded CSS "+"property. By default, Emmet will generate vendor-prefixed "+"properties only when you put dash before abbreviation "+"(e.g. <code>-bxsh</code>). With this option enabled, you dont "+"need dashes before abbreviations: Emmet will produce "+"vendor-prefixed properties for you.");var descTemplate=_.template("A comma-separated list of CSS properties that may have "+"<code><%= vendor %></code> vendor prefix. This list is used to generate "+"a list of prefixed properties when expanding <code>-property</code> "+"abbreviations. Empty list means that all possible CSS values may "+"have <code><%= vendor %></code> prefix.");var descAddonTemplate=_.template("A comma-separated list of <em>additional</em> CSS properties "+"for <code>css.<%= vendor %>Preperties</code> preference. "+"You should use this list if you want to add or remove a few CSS "+"properties to original set. To add a new property, simply write its name, "+"to remove it, precede property with hyphen.<br>"+"For example, to add <em>foo</em> property and remove <em>border-radius</em> one, "+"the preference value will look like this: <code>foo, -border-radius</code>.");var props={"webkit":"animation, animation-delay, animation-direction, animation-duration, animation-fill-mode, animation-iteration-count, animation-name, animation-play-state, animation-timing-function, appearance, backface-visibility, background-clip, background-composite, background-origin, background-size, border-fit, border-horizontal-spacing, border-image, border-vertical-spacing, box-align, box-direction, box-flex, box-flex-group, box-lines, box-ordinal-group, box-orient, box-pack, box-reflect, box-shadow, color-correction, column-break-after, column-break-before, column-break-inside, column-count, column-gap, column-rule-color, column-rule-style, column-rule-width, column-span, column-width, dashboard-region, font-smoothing, highlight, hyphenate-character, hyphenate-limit-after, hyphenate-limit-before, hyphens, line-box-contain, line-break, line-clamp, locale, margin-before-collapse, margin-after-collapse, marquee-direction, marquee-increment, marquee-repetition, marquee-style, mask-attachment, mask-box-image, mask-box-image-outset, mask-box-image-repeat, mask-box-image-slice, mask-box-image-source, mask-box-image-width, mask-clip, mask-composite, mask-image, mask-origin, mask-position, mask-repeat, mask-size, nbsp-mode, perspective, perspective-origin, rtl-ordering, text-combine, text-decorations-in-effect, text-emphasis-color, text-emphasis-position, text-emphasis-style, text-fill-color, text-orientation, text-security, text-stroke-color, text-stroke-width, transform, transition, transform-origin, transform-style, transition-delay, transition-duration, transition-property, transition-timing-function, user-drag, user-modify, user-select, writing-mode, svg-shadow, box-sizing, border-radius","moz":"animation-delay, animation-direction, animation-duration, animation-fill-mode, animation-iteration-count, animation-name, animation-play-state, animation-timing-function, appearance, backface-visibility, background-inline-policy, binding, border-bottom-colors, border-image, border-left-colors, border-right-colors, border-top-colors, box-align, box-direction, box-flex, box-ordinal-group, box-orient, box-pack, box-shadow, box-sizing, column-count, column-gap, column-rule-colo
_.each(props,function(v,k){prefs.define("css."+k+"Properties",v,descTemplate({vendor:k}));prefs.define("css."+k+"PropertiesAddon","",descAddonTemplate({vendor:k}))});prefs.define("css.unitlessProperties","z-index, line-height, opacity, font-weight, zoom","The list of properties whose values must not contain units.");prefs.define("css.intUnit","px","Default unit for integer values");prefs.define("css.floatUnit","em","Default unit for float values");prefs.define("css.keywords","auto, inherit","A comma-separated list of valid keywords that can be used in CSS abbreviations.");prefs.define("css.keywordAliases","a:auto, i:inherit, s:solid, da:dashed, do:dotted, t:transparent","A comma-separated list of keyword aliases, used in CSS abbreviation. "+"Each alias should be defined as <code>alias:keyword_name</code>.");prefs.define("css.unitAliases","e:em, p:%, x:ex, r:rem","A comma-separated list of unit aliases, used in CSS abbreviation. "+"Each alias should be defined as <code>alias:unit_value</code>.");prefs.define("css.color.short",true,"Should color values like <code>#ffffff</code> be shortened to "+"<code>#fff</code> after abbreviation with color was expanded.");prefs.define("css.color.case","keep","Letter case of color values generated by abbreviations with color "+"(like <code>c#0</code>). Possible values are <code>upper</code>, "+"<code>lower</code> and <code>keep</code>.");prefs.define("css.fuzzySearch",true,"Enable fuzzy search among CSS snippet names. When enabled, every "+"<em>unknown</em> snippet will be scored against available snippet "+"names (not values or CSS properties!). The match with best score "+"will be used to resolve snippet value. For example, with this "+"preference enabled, the following abbreviations are equal: "+"<code>ov:h</code> == <code>ov-h</code> == <code>o-h</code> == "+"<code>oh</code>");prefs.define("css.fuzzySearchMinScore",0.3,"The minium score (from 0 to 1) that fuzzy-matched abbreviation should "+"achive. Lower values may produce many false-positive matches, "+"higher values may reduce possible matches.");prefs.define("css.alignVendor",false,"If set to <code>true</code>, all generated vendor-prefixed properties "+"will be aligned by real property name.");function isNumeric(ch){var code=ch&&ch.charCodeAt(0);return(ch&&ch=="."||(code>47&&code<58))}function isSingleProperty(snippet){var utils=require("utils");snippet=utils.trim(snippet);if(~snippet.indexOf("/*")||/[\n\r]/.test(snippet)){return false}if(!/^[a-z0-9\-]+\s*\:/i.test(snippet)){return false}snippet=require("tabStops").processText(snippet,{replaceCarets:true,tabstop:function(){return"value"}});return snippet.split(":").length==2}function normalizeValue(value){if(value.charAt(0)=="-"&&!/^\-[\.\d]/.test(value)){value=value.replace(/^\-+/,"")}if(value.charAt(0)=="#"){return normalizeHexColor(value)}return getKeyword(value)}function normalizeHexColor(value){var hex=value.replace(/^#+/,"")||"0";if(hex.toLowerCase()=="t"){return"transparent"}var repeat=require("utils").repeatString;var color=null;switch(hex.length){case 1:color=repeat(hex,6);break;case 2:color=repeat(hex,3);break;case 3:color=hex.charAt(0)+hex.charAt(0)+hex.charAt(1)+hex.charAt(1)+hex.charAt(2)+hex.charAt(2);break;case 4:color=hex+hex.substr(0,2);break;case 5:color=hex+hex.charAt(0);break;default:color=hex.substr(0,6)}if(prefs.get("css.color.short")){var p=color.split("");if(p[0]==p[1]&&p[2]==p[3]&&p[4]==p[5]){color=p[0]+p[2]+p[4]}}switch(prefs.get("css.color.case")){case"upper":color=color.toUpperCase();break;case"lower":color=color.toLowerCase();break}return"#"+color}function getKeyword(name){var aliases=prefs.getDict("css.keywordAliases");return name in aliases?aliases[name]:name}function getUnit(name){var aliases=prefs.getDict("css.unitAliases");return name in aliases?aliases[name]:name}function isValidKeyword(keyword){return _.include(prefs.getArray("css.keywords"),getKeyword(keyword))}function hasPrefix(property,prefix){var info=vendorPrefixes[prefix];if(!info){info=_.find(vendorPrefixes,function(data){return data.prefix==prefix})}return info&&info.supports(proper
}if(!isSingleProperty(snippet)){return snippet}if(isImportant){if(~snippet.indexOf(";")){snippet=snippet.split(";").join(" !important;")}else{snippet+=" !important"}}return formatProperty(snippet,syntax)}function parseList(list){var result=_.map((list||"").split(","),require("utils").trim);return result.length?result:null}function getProperties(key){var list=prefs.getArray(key);_.each(prefs.getArray(key+"Addon"),function(prop){if(prop.charAt(0)=="-"){list=_.without(list,prop.substr(1))}else{if(prop.charAt(0)=="+"){prop=prop.substr(1)}list.push(prop)}});return list}addPrefix("w",{prefix:"webkit"});addPrefix("m",{prefix:"moz"});addPrefix("s",{prefix:"ms"});addPrefix("o",{prefix:"o"});var cssSyntaxes=["css","less","sass","scss","stylus"];require("resources").addResolver(function(node,syntax){if(_.include(cssSyntaxes,syntax)&&node.isElement()){return module.expandToSnippet(node.abbreviation,syntax)}return null});var ea=require("expandAbbreviation");ea.addHandler(function(editor,syntax,profile){if(!_.include(cssSyntaxes,syntax)){return false}var caretPos=editor.getSelectionRange().end;var abbr=ea.findAbbreviation(editor);if(abbr){var content=emmet.expandAbbreviation(abbr,syntax,profile);if(content){var replaceFrom=caretPos-abbr.length;var replaceTo=caretPos;if(editor.getContent().charAt(caretPos)==";"&&content.charAt(content.length-1)==";"){replaceTo++}editor.replaceContent(content,replaceFrom,replaceTo);return true}}return false});return module={addPrefix:addPrefix,supportsPrefix:hasPrefix,prefixed:function(property,prefix){return hasPrefix(property,prefix)?"-"+prefix+"-"+property:property},listPrefixes:function(){return _.map(vendorPrefixes,function(obj){return obj.prefix})},getPrefix:function(name){return vendorPrefixes[name]},removePrefix:function(name){if(name in vendorPrefixes){delete vendorPrefixes[name]}},extractPrefixes:function(abbr){if(abbr.charAt(0)!="-"){return{property:abbr,prefixes:null}}var i=1,il=abbr.length,ch;var prefixes=[];while(i<il){ch=abbr.charAt(i);if(ch=="-"){i++;break}if(ch in vendorPrefixes){prefixes.push(ch)}else{prefixes.length=0;i=1;break}i++}if(i==il-1){i=1;prefixes.length=1}return{property:abbr.substring(i),prefixes:prefixes.length?prefixes:"all"}},findValuesInAbbreviation:function(abbr,syntax){syntax=syntax||"css";var i=0,il=abbr.length,value="",ch;while(i<il){ch=abbr.charAt(i);if(isNumeric(ch)||ch=="#"||(ch=="-"&&isNumeric(abbr.charAt(i+1)))){value=abbr.substring(i);break}i++}var property=abbr.substring(0,abbr.length-value.length);var res=require("resources");var keywords=[];while(~property.indexOf("-")&&!res.findSnippet(syntax,property)){var parts=property.split("-");var lastPart=parts.pop();if(!isValidKeyword(lastPart)){break}keywords.unshift(lastPart);property=parts.join("-")}return keywords.join("-")+value},parseValues:function(str){var stream=require("stringStream").create(str);var values=[];var ch=null;while(ch=stream.next()){if(ch=="#"){stream.match(/^t|[0-9a-f]+/i,true);values.push(stream.current())}else{if(ch=="-"){if(isValidKeyword(_.last(values))||(stream.start&&isNumeric(str.charAt(stream.start-1)))){stream.start=stream.pos}stream.match(/^\-?[0-9]*(\.[0-9]+)?[a-z%\.]*/,true);values.push(stream.current())}else{stream.match(/^[0-9]*(\.[0-9]*)?[a-z%]*/,true);values.push(stream.current())}}stream.start=stream.pos}return _.map(_.compact(values),normalizeValue)},extractValues:function(abbr){var abbrValues=this.findValuesInAbbreviation(abbr);if(!abbrValues){return{property:abbr,values:null}}return{property:abbr.substring(0,abbr.length-abbrValues.length).replace(/-$/,""),values:this.parseValues(abbrValues)}},normalizeValue:function(value,property){property=(property||"").toLowerCase();var unitlessProps=prefs.getArray("css.unitlessProperties");return value.replace(/^(\-?[0-9\.]+)([a-z]*)$/,function(str,val,unit){if(!unit&&(val=="0"||_.include(unitlessProps,property))){return val}if(!unit){return val.replace(/\.$/,"")+prefs.get(~val.indexOf(".")?"css.floatUnit":"css.intUnit")}return val+getUnit(unit)})},expand:function(abbr,value,syntax){syntax=syntax||"css";var resources=require("resourc
},this).join(" ")+";"}snippetObj.value=value||snippetObj.value;var prefixes=abbrData.prefixes=="all"||(!abbrData.prefixes&&autoInsertPrefixes)?findPrefixes(snippetObj.name,autoInsertPrefixes&&abbrData.prefixes!="all"):abbrData.prefixes;var names=[],propName;_.each(prefixes,function(p){if(p in vendorPrefixes){propName=vendorPrefixes[p].transformName(snippetObj.name);names.push(propName);result.push(transformSnippet(propName+":"+snippetObj.value,isImportant,syntax))}});result.push(transformSnippet(snippetObj.name+":"+snippetObj.value,isImportant,syntax));names.push(snippetObj.name);if(prefs.get("css.alignVendor")){var pads=require("utils").getStringsPads(names);result=_.map(result,function(prop,i){return pads[i]+prop})}return result},expandToSnippet:function(abbr,syntax){var snippet=this.expand(abbr,null,syntax);if(_.isArray(snippet)){return snippet.join("\n")}if(!_.isString(snippet)){return snippet.data}return String(snippet)},splitSnippet:function(snippet){var utils=require("utils");snippet=utils.trim(snippet);if(snippet.indexOf(":")==-1){return{name:snippet,value:defaultValue}}var pair=snippet.split(":");return{name:utils.trim(pair.shift()),value:utils.trim(pair.join(":")).replace(/^(\$\{0\}|\$0)(\s*;?)$/,"${1}$2")}},getSyntaxPreference:getSyntaxPreference,transformSnippet:transformSnippet}});emmet.define("cssGradient",function(require,_){var defaultLinearDirections=["top","to bottom","0deg"];var module=null;var cssSyntaxes=["css","less","sass","scss","stylus","styl"];var reDeg=/\d+deg/i;var reKeyword=/top|bottom|left|right/i;var prefs=require("preferences");prefs.define("css.gradient.prefixes","webkit, moz, o","A comma-separated list of vendor-prefixes for which values should "+"be generated.");prefs.define("css.gradient.oldWebkit",true,"Generate gradient definition for old Webkit implementations");prefs.define("css.gradient.omitDefaultDirection",true,"Do not output default direction definition in generated gradients.");prefs.define("css.gradient.defaultProperty","background-image","When gradient expanded outside CSS value context, it will produce "+"properties with this name.");prefs.define("css.gradient.fallback",false,"With this option enabled, CSS gradient generator will produce "+"<code>background-color</code> property with gradient first color "+"as fallback for old browsers.");function normalizeSpace(str){return require("utils").trim(str).replace(/\s+/g," ")}function parseLinearGradient(gradient){var direction=defaultLinearDirections[0];var stream=require("stringStream").create(require("utils").trim(gradient));var colorStops=[],ch;while(ch=stream.next()){if(stream.peek()==","){colorStops.push(stream.current());stream.next();stream.eatSpace();stream.start=stream.pos}else{if(ch=="("){stream.skipTo(")")}}}colorStops.push(stream.current());colorStops=_.compact(_.map(colorStops,normalizeSpace));if(!colorStops.length){return null}if(reDeg.test(colorStops[0])||reKeyword.test(colorStops[0])){direction=colorStops.shift()}return{type:"linear",direction:direction,colorStops:_.map(colorStops,parseColorStop)}}function parseColorStop(colorStop){colorStop=normalizeSpace(colorStop);var color=null;colorStop=colorStop.replace(/^(\w+\(.+?\))\s*/,function(str,c){color=c;return""});if(!color){var parts=colorStop.split(" ");color=parts[0];colorStop=parts[1]||""}var result={color:color};if(colorStop){colorStop.replace(/^(\-?[\d\.]+)([a-z%]+)?$/,function(str,pos,unit){result.position=pos;if(~pos.indexOf(".")){unit=""}else{if(!unit){unit="%"}}if(unit){result.unit=unit}})}return result}function resolvePropertyName(name,syntax){var res=require("resources");var prefs=require("preferences");var snippet=res.findSnippet(syntax,name);if(!snippet&&prefs.get("css.fuzzySearch")){snippet=res.fuzzyFindSnippet(syntax,name,parseFloat(prefs.get("css.fuzzySearchMinScore")))}if(snippet){if(!_.isString(snippet)){snippet=snippet.data}return require("cssResolver").splitSnippet(snippet).name}}function fillImpliedPositions(colorStops){var from=0;_.each(colorStops,function(cs,i){if(!i){return cs.position=cs.position||0}if(i==colorStops.length-1&&!("position"
var css=require("cssResolver");if(prefs.get("css.gradient.fallback")&&~propertyName.toLowerCase().indexOf("background")){props.push({name:"background-color",value:"${1:"+gradient.colorStops[0].color+"}"})}_.each(prefs.getArray("css.gradient.prefixes"),function(prefix){var name=css.prefixed(propertyName,prefix);if(prefix=="webkit"&&prefs.get("css.gradient.oldWebkit")){try{props.push({name:name,value:module.oldWebkitLinearGradient(gradient)})}catch(e){}}props.push({name:name,value:module.toString(gradient,prefix)})});return props.sort(function(a,b){return b.name.length-a.name.length})}function pasteGradient(property,gradient,valueRange){var rule=property.parent;var utils=require("utils");var alignVendor=require("preferences").get("css.alignVendor");var sep=property.styleSeparator;var before=property.styleBefore;_.each(rule.getAll(getPrefixedNames(property.name())),function(item){if(item!=property&&/gradient/i.test(item.value())){if(item.styleSeparator.length<sep.length){sep=item.styleSeparator}if(item.styleBefore.length<before.length){before=item.styleBefore}rule.remove(item)}});if(alignVendor){if(before!=property.styleBefore){var fullRange=property.fullRange();rule._updateSource(before,fullRange.start,fullRange.start+property.styleBefore.length);property.styleBefore=before}if(sep!=property.styleSeparator){rule._updateSource(sep,property.nameRange().end,property.valueRange().start);property.styleSeparator=sep}}var value=property.value();if(!valueRange){valueRange=require("range").create(0,property.value())}var val=function(v){return utils.replaceSubstring(value,v,valueRange)};property.value(val(module.toString(gradient))+"${2}");var propsToInsert=getPropertiesForGradient(gradient,property.name());if(alignVendor){var values=_.pluck(propsToInsert,"value");var names=_.pluck(propsToInsert,"name");values.push(property.value());names.push(property.name());var valuePads=utils.getStringsPads(_.map(values,function(v){return v.substring(0,v.indexOf("("))}));var namePads=utils.getStringsPads(names);property.name(_.last(namePads)+property.name());_.each(propsToInsert,function(prop,i){prop.name=namePads[i]+prop.name;prop.value=valuePads[i]+prop.value});property.value(_.last(valuePads)+property.value())}_.each(propsToInsert,function(prop){rule.add(prop.name,prop.value,rule.indexOf(property))})}function findGradient(cssProp){var value=cssProp.value();var gradient=null;var matchedPart=_.find(cssProp.valueParts(),function(part){return gradient=module.parse(part.substring(value))});if(matchedPart&&gradient){return{gradient:gradient,valueRange:matchedPart}}return null}function expandGradientOutsideValue(editor,syntax){var propertyName=prefs.get("css.gradient.defaultProperty");if(!propertyName){return false}var content=String(editor.getContent());var lineRange=require("range").create(editor.getCurrentLineRange());var line=lineRange.substring(content).replace(/^\s+/,function(pad){lineRange.start+=pad.length;return""}).replace(/\s+$/,function(pad){lineRange.end-=pad.length;return""});var css=require("cssResolver");var gradient=module.parse(line);if(gradient){var props=getPropertiesForGradient(gradient,propertyName);props.push({name:propertyName,value:module.toString(gradient)+"${2}"});var sep=css.getSyntaxPreference("valueSeparator",syntax);var end=css.getSyntaxPreference("propertyEnd",syntax);if(require("preferences").get("css.alignVendor")){var pads=require("utils").getStringsPads(_.map(props,function(prop){return prop.value.substring(0,prop.value.indexOf("("))}));_.each(props,function(prop,i){prop.value=pads[i]+prop.value})}props=_.map(props,function(item){return item.name+sep+item.value+end});editor.replaceContent(props.join("\n"),lineRange.start,lineRange.end);return true}return false}function findGradientFromPosition(content,pos){var cssProp=null;var cssRule=require("cssEditTree").parseFromPosition(content,pos,true);if(cssRule){cssProp=cssRule.itemFromPosition(pos,true);if(!cssProp){cssProp=_.find(cssRule.list(),function(elem){return elem.range(true).end==pos})}}return{rule:cssRule,property:cssProp}}require("expandAbbreviation").addHandl
return true}}return expandGradientOutsideValue(editor,syntax)});require("reflectCSSValue").addHandler(function(property){var utils=require("utils");var g=findGradient(property);if(!g){return false}var value=property.value();var val=function(v){return utils.replaceSubstring(value,v,g.valueRange)};_.each(property.parent.getAll(getPrefixedNames(property.name())),function(prop){if(prop===property){return}var m=prop.value().match(/^\s*(\-([a-z]+)\-)?linear\-gradient/);if(m){prop.value(val(module.toString(g.gradient,m[2]||"")))}else{if(m=prop.value().match(/\s*\-webkit\-gradient/)){prop.value(val(module.oldWebkitLinearGradient(g.gradient)))}}});return true});return module={parse:function(gradient){var result=null;require("utils").trim(gradient).replace(/^([\w\-]+)\((.+?)\)$/,function(str,type,definition){type=type.toLowerCase().replace(/^\-[a-z]+\-/,"");if(type=="linear-gradient"||type=="lg"){result=parseLinearGradient(definition);return""}return str});return result},oldWebkitLinearGradient:function(gradient){if(_.isString(gradient)){gradient=this.parse(gradient)}if(!gradient){return null}var colorStops=_.map(gradient.colorStops,_.clone);_.each(colorStops,function(cs){if(!("position" in cs)){return}if(~cs.position.indexOf(".")||cs.unit=="%"){cs.position=parseFloat(cs.position)/(cs.unit=="%"?100:1)}else{throw"Can't convert color stop '"+(cs.position+(cs.unit||""))+"'"}});fillImpliedPositions(colorStops);colorStops=_.map(colorStops,function(cs,i){if(!cs.position&&!i){return"from("+cs.color+")"}if(cs.position==1&&i==colorStops.length-1){return"to("+cs.color+")"}return"color-stop("+(cs.position.toFixed(2).replace(/\.?0+$/,""))+", "+cs.color+")"});return"-webkit-gradient(linear, "+oldWebkitDirection(gradient.direction)+", "+colorStops.join(", ")+")"},toString:function(gradient,prefix){if(gradient.type=="linear"){var fn=(prefix?"-"+prefix+"-":"")+"linear-gradient";var colorStops=_.map(gradient.colorStops,function(cs){return cs.color+("position" in cs?" "+cs.position+(cs.unit||""):"")});if(gradient.direction&&(!prefs.get("css.gradient.omitDefaultDirection")||!_.include(defaultLinearDirections,gradient.direction))){colorStops.unshift(gradient.direction)}return fn+"("+colorStops.join(", ")+")"}}}});emmet.exec(function(require,_){var generators=require("handlerList").create();var resources=require("resources");_.extend(resources,{addGenerator:function(regexp,fn,options){if(_.isString(regexp)){regexp=new RegExp(regexp)}generators.add(function(node,syntax){var m;if((m=regexp.exec(node.name()))){return fn(m,node,syntax)}return null},options)}});resources.addResolver(function(node,syntax){return generators.exec(null,_.toArray(arguments))})});emmet.define("tagName",function(require,_){var elementTypes={empty:[],blockLevel:"address,applet,blockquote,button,center,dd,del,dir,div,dl,dt,fieldset,form,frameset,hr,iframe,ins,isindex,li,link,map,menu,noframes,noscript,object,ol,p,pre,script,table,tbody,td,tfoot,th,thead,tr,ul,h1,h2,h3,h4,h5,h6".split(","),inlineLevel:"a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,select,small,span,strike,strong,sub,sup,textarea,tt,u,var".split(",")};var elementMap={"p":"span","ul":"li","ol":"li","table":"tr","tr":"td","tbody":"tr","thead":"tr","tfoot":"tr","colgroup":"col","select":"option","optgroup":"option","audio":"source","video":"source","object":"param","map":"area"};return{resolve:function(name){name=(name||"").toLowerCase();if(name in elementMap){return this.getMapping(name)}if(this.isInlineLevel(name)){return"span"}return"div"},getMapping:function(name){return elementMap[name.toLowerCase()]},isInlineLevel:function(name){return this.isTypeOf(name,"inlineLevel")},isBlockLevel:function(name){return this.isTypeOf(name,"blockLevel")},isEmptyElement:function(name){return this.isTypeOf(name,"empty")},isTypeOf:function(name,type){return _.include(elementTypes[type],name)},addMapping:function(parent,child){elementMap[parent]=child},removeMapping:function(parent){if(parent in elementMap){delete elementMap[parent]}},addElementToColl
var shouldRunHtmlFilter=false;function getSeparators(){return{element:prefs.get("bem.elementSeparator"),modifier:prefs.get("bem.modifierSeparator")}}function bemParse(item){if(require("abbreviationUtils").isSnippet(item)){return item}item.__bem={block:"",element:"",modifier:""};var classNames=normalizeClassName(item.attribute("class")).split(" ");var reBlockName=/^[a-z]\-/i;item.__bem.block=_.find(classNames,function(name){return reBlockName.test(name)});if(!item.__bem.block){reBlockName=/^[a-z]/i;item.__bem.block=_.find(classNames,function(name){return reBlockName.test(name)})||""}classNames=_.chain(classNames).map(function(name){return processClassName(name,item)}).flatten().uniq().value().join(" ");if(classNames){item.attribute("class",classNames)}return item}function normalizeClassName(className){var utils=require("utils");className=(" "+(className||"")+" ").replace(/\s+/g," ");var shortSymbol=prefs.get("bem.shortElementPrefix");if(shortSymbol){var re=new RegExp("\\s("+utils.escapeForRegexp(shortSymbol)+"+)","g");className=className.replace(re,function(str,p1){return" "+utils.repeatString(getSeparators().element,p1.length)})}return utils.trim(className)}function processClassName(name,item){name=transformClassName(name,item,"element");name=transformClassName(name,item,"modifier");var block="",element="",modifier="";var separators=getSeparators();if(~name.indexOf(separators.element)){var blockElem=name.split(separators.element);var elemModifiers=blockElem[1].split(separators.modifier);block=blockElem[0];element=elemModifiers.shift();modifier=elemModifiers.join(separators.modifier)}else{if(~name.indexOf(separators.modifier)){var blockModifiers=name.split(separators.modifier);block=blockModifiers.shift();modifier=blockModifiers.join(separators.modifier)}}if(block||element||modifier){if(!block){block=item.__bem.block}var prefix=block;var result=[];if(element){prefix+=separators.element+element;result.push(prefix)}else{result.push(prefix)}if(modifier){result.push(prefix+separators.modifier+modifier)}item.__bem.block=block;item.__bem.element=element;item.__bem.modifier=modifier;return result}return name}function transformClassName(name,item,entityType){var separators=getSeparators();var reSep=new RegExp("^("+separators[entityType]+")+","g");if(reSep.test(name)){var depth=0;var cleanName=name.replace(reSep,function(str,p1){depth=str.length/separators[entityType].length;return""});var donor=item;while(donor.parent&&depth--){donor=donor.parent}if(!donor||!donor.__bem){donor=item}if(donor&&donor.__bem){var prefix=donor.__bem.block;if(entityType=="modifier"&&donor.__bem.element){prefix+=separators.element+donor.__bem.element}return prefix+separators[entityType]+cleanName}}return name}function process(tree,profile){if(tree.name){bemParse(tree,profile)}var abbrUtils=require("abbreviationUtils");_.each(tree.children,function(item){process(item,profile);if(!abbrUtils.isSnippet(item)&&item.start){shouldRunHtmlFilter=true}});return tree}require("filters").add("bem",function(tree,profile){shouldRunHtmlFilter=false;tree=process(tree,profile);if(shouldRunHtmlFilter){tree=require("filters").apply(tree,"html",profile)}return tree})});emmet.exec(function(require,_){var prefs=require("preferences");prefs.define("filter.commentAfter",'\n<!-- /<%= attr("id", "#") %><%= attr("class", ".") %> -->',"A definition of comment that should be placed <i>after</i> matched "+"element when <code>comment</code> filter is applied. This definition "+"is an ERB-style template passed to <code>_.template()</code> "+"function (see Underscore.js docs for details). In template context, "+"the following properties and functions are availabe:\n"+"<ul>"+"<li><code>attr(name, before, after)</code> a function that outputs"+"specified attribute value concatenated with <code>before</code> "+"and <code>after</code> strings. If attribute doesn't exists, the "+"empty string will be returned.</li>"+"<li><code>node</code> current node (instance of <code>AbbreviationNode</code>)</li>"+"<li><code>name</code> name of current tag</li>"+"<li><code>padding</code> c
if(attr){return(before||"")+attr+(after||"")}return""}};var nodeBefore=utils.normalizeNewline(templateBefore?templateBefore(ctx):"");var nodeAfter=utils.normalizeNewline(templateAfter?templateAfter(ctx):"");node.start=node.start.replace(/</,nodeBefore+"<");node.end=node.end.replace(/>/,">"+nodeAfter)}function process(tree,before,after){var abbrUtils=require("abbreviationUtils");_.each(tree.children,function(item){if(abbrUtils.isBlock(item)){addComments(item,before,after)}process(item,before,after)});return tree}require("filters").add("c",function(tree){var templateBefore=_.template(prefs.get("filter.commentBefore"));var templateAfter=_.template(prefs.get("filter.commentAfter"));return process(tree,templateBefore,templateAfter)})});emmet.exec(function(require,_){var charMap={"<":"&lt;",">":"&gt;","&":"&amp;"};function escapeChars(str){return str.replace(/([<>&])/g,function(str,p1){return charMap[p1]})}require("filters").add("e",function process(tree){_.each(tree.children,function(item){item.start=escapeChars(item.start);item.end=escapeChars(item.end);item.content=escapeChars(item.content);process(item)});return tree})});emmet.exec(function(require,_){var placeholder="%s";var prefs=require("preferences");prefs.define("format.noIndentTags","html","A comma-separated list of tag names that should not get inner indentation.");prefs.define("format.forceIndentationForTags","body","A comma-separated list of tag names that should <em>always</em> get inner indentation.");function getIndentation(node){if(_.include(prefs.getArray("format.noIndentTags")||[],node.name())){return""}return require("resources").getVariable("indentation")}function hasBlockSibling(item){return item.parent&&require("abbreviationUtils").hasBlockChildren(item.parent)}function isVeryFirstChild(item){return item.parent&&!item.parent.parent&&!item.index()}function shouldAddLineBreak(node,profile){var abbrUtils=require("abbreviationUtils");if(profile.tag_nl===true||abbrUtils.isBlock(node)){return true}if(!node.parent||!profile.inline_break){return false}return shouldFormatInline(node.parent,profile)}function shouldBreakChild(node,profile){return node.children.length&&shouldAddLineBreak(node.children[0],profile)}function shouldFormatInline(node,profile){var nodeCount=0;var abbrUtils=require("abbreviationUtils");return !!_.find(node.children,function(child){if(child.isTextNode()||!abbrUtils.isInline(child)){nodeCount=0}else{if(abbrUtils.isInline(child)){nodeCount++}}if(nodeCount>=profile.inline_break){return true}})}function isRoot(item){return !item.parent}function processSnippet(item,profile,level){item.start=item.end="";if(!isVeryFirstChild(item)&&profile.tag_nl!==false&&shouldAddLineBreak(item,profile)){if(isRoot(item.parent)||!require("abbreviationUtils").isInline(item.parent)){item.start=require("utils").getNewline()+item.start}}return item}function shouldBreakInsideInline(node,profile){var abbrUtils=require("abbreviationUtils");var hasBlockElems=_.any(node.children,function(child){if(abbrUtils.isSnippet(child)){return false}return !abbrUtils.isInline(child)});if(!hasBlockElems){return shouldFormatInline(node,profile)}return true}function processTag(item,profile,level){item.start=item.end=placeholder;var utils=require("utils");var abbrUtils=require("abbreviationUtils");var isUnary=abbrUtils.isUnary(item);var nl=utils.getNewline();var indent=getIndentation(item);if(profile.tag_nl!==false){var forceNl=profile.tag_nl===true&&(profile.tag_nl_leaf||item.children.length);if(!forceNl){forceNl=_.include(prefs.getArray("format.forceIndentationForTags")||[],item.name())}if(!item.isTextNode()){if(shouldAddLineBreak(item,profile)){if(!isVeryFirstChild(item)&&(!abbrUtils.isSnippet(item.parent)||item.index())){item.start=nl+item.start}if(abbrUtils.hasBlockChildren(item)||shouldBreakChild(item,profile)||(forceNl&&!isUnary)){item.end=nl+item.end}if(abbrUtils.hasTagsInContent(item)||(forceNl&&!item.children.length&&!isUnary)){item.start+=nl+indent}}else{if(abbrUtils.isInline(item)&&hasBlockSibling(item)&&!isVeryFirstChild(item)){item.start=nl+item.start}else{if(abbrUtils.isIn
break;default:otherAttrs.push(":"+attrName+" => "+attrQuote+(a.value||cursor)+attrQuote)}});if(otherAttrs.length){attrs+="{"+otherAttrs.join(", ")+"}"}return attrs}function hasBlockSibling(item){return item.parent&&item.parent.hasBlockChildren()}function processTag(item,profile,level){if(!item.parent){return item}var abbrUtils=require("abbreviationUtils");var utils=require("utils");var attrs=makeAttributesString(item,profile);var cursor=profile.cursor();var isUnary=abbrUtils.isUnary(item);var selfClosing=profile.self_closing_tag&&isUnary?"/":"";var start="";var tagName="%"+profile.tagName(item.name());if(tagName.toLowerCase()=="%div"&&attrs&&attrs.indexOf("{")==-1){tagName=""}item.end="";start=tagName+attrs+selfClosing+" ";var placeholder="%s";item.start=utils.replaceSubstring(item.start,start,item.start.indexOf(placeholder),placeholder);if(!item.children.length&&!isUnary){item.start+=cursor}return item}require("filters").add("haml",function process(tree,profile,level){level=level||0;var abbrUtils=require("abbreviationUtils");if(!level){tree=require("filters").apply(tree,"_format",profile)}_.each(tree.children,function(item){if(!abbrUtils.isSnippet(item)){processTag(item,profile,level)}process(item,profile,level+1)});return tree})});emmet.exec(function(require,_){function makeAttributesString(node,profile){var attrQuote=profile.attributeQuote();var cursor=profile.cursor();return _.map(node.attributeList(),function(a){var attrName=profile.attributeName(a.name);return" "+attrName+"="+attrQuote+(a.value||cursor)+attrQuote}).join("")}function processTag(item,profile,level){if(!item.parent){return item}var abbrUtils=require("abbreviationUtils");var utils=require("utils");var attrs=makeAttributesString(item,profile);var cursor=profile.cursor();var isUnary=abbrUtils.isUnary(item);var start="";var end="";if(!item.isTextNode()){var tagName=profile.tagName(item.name());if(isUnary){start="<"+tagName+attrs+profile.selfClosing()+">";item.end=""}else{start="<"+tagName+attrs+">";end="</"+tagName+">"}}var placeholder="%s";item.start=utils.replaceSubstring(item.start,start,item.start.indexOf(placeholder),placeholder);item.end=utils.replaceSubstring(item.end,end,item.end.indexOf(placeholder),placeholder);if(!item.children.length&&!isUnary&&!~item.content.indexOf(cursor)&&!require("tabStops").extract(item.content).tabstops.length){item.start+=cursor}return item}require("filters").add("html",function process(tree,profile,level){level=level||0;var abbrUtils=require("abbreviationUtils");if(!level){tree=require("filters").apply(tree,"_format",profile)}_.each(tree.children,function(item){if(!abbrUtils.isSnippet(item)){processTag(item,profile,level)}process(item,profile,level+1)});return tree})});emmet.exec(function(require,_){var rePad=/^\s+/;var reNl=/[\n\r]/g;require("filters").add("s",function process(tree,profile,level){var abbrUtils=require("abbreviationUtils");_.each(tree.children,function(item){if(!abbrUtils.isSnippet(item)){item.start=item.start.replace(rePad,"");item.end=item.end.replace(rePad,"")}item.start=item.start.replace(reNl,"");item.end=item.end.replace(reNl,"");item.content=item.content.replace(reNl,"");process(item)});return tree})});emmet.exec(function(require,_){require("preferences").define("filter.trimRegexp","[\\s|\\u00a0]*[\\d|#|\\-|*|\\u2022]+\\.?\\s*","Regular expression used to remove list markers (numbers, dashes, "+"bullets, etc.) in <code>t</code> (trim) filter. The trim filter "+"is useful for wrapping with abbreviation lists, pased from other "+"documents (for example, Word documents).");function process(tree,re){_.each(tree.children,function(item){if(item.content){item.content=item.content.replace(re,"")}process(item,re)});return tree}require("filters").add("t",function(tree){var re=new RegExp(require("preferences").get("filter.trimRegexp"));return process(tree,re)})});emmet.exec(function(require,_){var tags={"xsl:variable":1,"xsl:with-param":1};function trimAttribute(node){node.start=node.start.replace(/\s+select\s*=\s*(['"]).*?\1/,"")}require("filters").add("xsl",function process(tree){var abbrUtils=require(
var prefs=require("preferences");prefs.define("lorem.defaultLang","en");require("abbreviationParser").addPreprocessor(function(tree,options){var re=/^(?:lorem|lipsum)([a-z]{2})?(\d*)$/i,match;tree.findAll(function(node){if(node._name&&(match=node._name.match(re))){var wordCound=match[2]||30;var lang=match[1]||prefs.get("lorem.defaultLang")||"en";node._name="";node.data("forceNameResolving",node.isRepeating()||node.attributeList().length);node.data("pasteOverwrites",true);node.data("paste",function(i,content){return paragraph(lang,wordCound,!i)})}})});function randint(from,to){return Math.round(Math.random()*(to-from)+from)}function sample(arr,count){var len=arr.length;var iterations=Math.min(len,count);var result=[];while(result.length<iterations){var randIx=randint(0,len-1);if(!_.include(result,randIx)){result.push(randIx)}}return _.map(result,function(ix){return arr[ix]})}function choice(val){if(_.isString(val)){return val.charAt(randint(0,val.length-1))}return val[randint(0,val.length-1)]}function sentence(words,end){if(words.length){words[0]=words[0].charAt(0).toUpperCase()+words[0].substring(1)}return words.join(" ")+(end||choice("?!..."))}function insertCommas(words){var len=words.length;var totalCommas=0;if(len>3&&len<=6){totalCommas=randint(0,1)}else{if(len>6&&len<=12){totalCommas=randint(0,2)}else{totalCommas=randint(1,4)}}_.each(_.range(totalCommas),function(ix){if(ix<words.length-1){words[ix]+=","}})}function paragraph(lang,wordCount,startWithCommon){var data=langs[lang];if(!data){return""}var result=[];var totalWords=0;var words;wordCount=parseInt(wordCount,10);if(startWithCommon&&data.common){words=data.common.slice(0,wordCount);if(words.length>5){words[4]+=","}totalWords+=words.length;result.push(sentence(words,"."))}while(totalWords<wordCount){words=sample(data.words,Math.min(randint(3,12)*randint(1,5),wordCount-totalWords));totalWords+=words.length;insertCommas(words);result.push(sentence(words))}return result.join(" ")}return{addLang:function(lang,data){if(_.isString(data)){data={words:_.compact(data.split(" "))}}else{if(_.isArray(data)){data={words:data}}}langs[lang]=data}}});emmet.define("bootstrap",function(require,_){var snippets={"variables":{"lang":"en","locale":"en-US","charset":"UTF-8","indentation":"\t","newline":"\n"},"css":{"filters":"html","snippets":{"@i":"@import url(|);","@import":"@import url(|);","@m":"@media ${1:screen} {\n\t|\n}","@media":"@media ${1:screen} {\n\t|\n}","@f":"@font-face {\n\tfont-family:|;\n\tsrc:url(|);\n}","@f+":"@font-face {\n\tfont-family: '${1:FontName}';\n\tsrc: url('${2:FileName}.eot');\n\tsrc: url('${2:FileName}.eot?#iefix') format('embedded-opentype'),\n\t\t url('${2:FileName}.woff') format('woff'),\n\t\t url('${2:FileName}.ttf') format('truetype'),\n\t\t url('${2:FileName}.svg#${1:FontName}') format('svg');\n\tfont-style: ${3:normal};\n\tfont-weight: ${4:normal};\n}","@kf":"@-webkit-keyframes ${1:identifier} {\n\t${2:from} { ${3} }${6}\n\t${4:to} { ${5} }\n}\n@-o-keyframes ${1:identifier} {\n\t${2:from} { ${3} }${6}\n\t${4:to} { ${5} }\n}\n@-moz-keyframes ${1:identifier} {\n\t${2:from} { ${3} }${6}\n\t${4:to} { ${5} }\n}\n@keyframes ${1:identifier} {\n\t${2:from} { ${3} }${6}\n\t${4:to} { ${5} }\n}","anim":"animation:|;","anim-":"animation:${1:name} ${2:duration} ${3:timing-function} ${4:delay} ${5:iteration-count} ${6:direction} ${7:fill-mode};","animdel":"animation-delay:${1:time};","animdir":"animation-direction:${1:normal};","animdir:n":"animation-direction:normal;","animdir:r":"animation-direction:reverse;","animdir:a":"animation-direction:alternate;","animdir:ar":"animation-direction:alternate-reverse;","animdur":"animation-duration:${1:0}s;","animfm":"animation-fill-mode:${1:both};","animfm:f":"animation-fill-mode:forwards;","animfm:b":"animation-fill-mode:backwards;","animfm:bt":"animation-fill-mode:both;","animfm:bh":"animation-fill-mode:both;","animic":"animation-iteration-count:${1:1};","animic:i":"animation-iteration-count:infinite;","animn":"animation-name:${1:none};","animps":"animation-play-state:${1:running};","animps:p":"animation-play-state:
var res=require("resources");var userData=res.getVocabulary("user")||{};res.setVocabulary(require("utils").deepMerge(userData,snippets),"user")});