Current File : /home/pacjaorg/public_html/kmm/media/vendor/codemirror/mode/soy/soy.min.js |
(function(l){typeof exports=="object"&&typeof module=="object"?l(require("../../lib/codemirror"),require("../htmlmixed/htmlmixed")):typeof define=="function"&&define.amd?define(["../../lib/codemirror","../htmlmixed/htmlmixed"],l):l(CodeMirror)})(function(l){"use strict";var d={noEndTag:!0,soyState:"param-def"},y={alias:{noEndTag:!0},delpackage:{noEndTag:!0},namespace:{noEndTag:!0,soyState:"namespace-def"},"@attribute":d,"@attribute?":d,"@param":d,"@param?":d,"@inject":d,"@inject?":d,"@state":d,template:{soyState:"templ-def",variableScope:!0},extern:{soyState:"param-def"},export:{soyState:"export"},literal:{},msg:{},fallbackmsg:{noEndTag:!0,reduceIndent:!0},select:{},plural:{},let:{soyState:"var-def"},if:{},javaimpl:{},jsimpl:{},elseif:{noEndTag:!0,reduceIndent:!0},else:{noEndTag:!0,reduceIndent:!0},switch:{},case:{noEndTag:!0,reduceIndent:!0},default:{noEndTag:!0,reduceIndent:!0},foreach:{variableScope:!0,soyState:"for-loop"},ifempty:{noEndTag:!0,reduceIndent:!0},for:{variableScope:!0,soyState:"for-loop"},call:{soyState:"templ-ref"},param:{soyState:"param-ref"},print:{noEndTag:!0},deltemplate:{soyState:"templ-def",variableScope:!0},delcall:{soyState:"templ-ref"},log:{},element:{variableScope:!0},velog:{},const:{soyState:"const-def"}},U=Object.keys(y).filter(function(r){return!y[r].noEndTag||y[r].reduceIndent});l.defineMode("soy",function(r){var m=l.getMode(r,"text/plain"),v={html:l.getMode(r,{name:"text/html",multilineTagIndentFactor:2,multilineTagIndentPastTag:!1,allowMissingTagName:!0}),attributes:m,text:m,uri:m,trusted_resource_uri:m,css:l.getMode(r,"text/css"),js:l.getMode(r,{name:"text/javascript",statementIndent:2*r.indentUnit})};function p(n){return n[n.length-1]}function w(n,e,t){if(n.sol()){for(var o=0;o<e.indent&&n.eat(/\s/);o++);if(o)return null}var c=n.string,i=t.exec(c.substr(n.pos));i&&(n.string=c.substr(0,n.pos+i.index));var u=n.hideFirstChars(e.indent,function(){var a=p(e.localStates);return a.mode.token(n,a.state)});return n.string=c,u}function j(n,e){for(;n;){if(n.element===e)return!0;n=n.next}return!1}function S(n,e){return{element:e,next:n}}function b(n){n.context&&(n.context.scope&&(n.variables=n.context.scope),n.context=n.context.previousContext)}function k(n,e,t){return j(n,e)?"variable-2":t?"variable":"variable-2 error"}function x(n,e,t){this.previousContext=n,this.tag=e,this.kind=null,this.scope=t}function s(n,e){var t;return n.match(/[[]/)?(e.soyState.push("list-literal"),e.context=new x(e.context,"list-literal",e.variables),e.lookupVariables=!1,null):n.match(/\bmap(?=\()/)?(e.soyState.push("map-literal"),"keyword"):n.match(/\brecord(?=\()/)?(e.soyState.push("record-literal"),"keyword"):n.match(/([\w]+)(?=\()/)?"variable callee":(t=n.match(/^["']/))?(e.soyState.push("string"),e.quoteKind=t[0],"string"):n.match(/^[(]/)?(e.soyState.push("open-parentheses"),null):n.match(/(null|true|false)(?!\w)/)||n.match(/0x([0-9a-fA-F]{2,})/)||n.match(/-?([0-9]*[.])?[0-9]+(e[0-9]*)?/)?"atom":n.match(/(\||[+\-*\/%]|[=!]=|\?:|[<>]=?)/)?"operator":(t=n.match(/^\$([\w]+)/))?k(e.variables,t[1],!e.lookupVariables):(t=n.match(/^\w+/))?/^(?:as|and|or|not|in|if)$/.test(t[0])?"keyword":null:(n.next(),null)}return{startState:function(){return{soyState:[],variables:S(null,"ij"),scopes:null,indent:0,quoteKind:null,context:null,lookupVariables:!0,localStates:[{mode:v.html,state:l.startState(v.html)}]}},copyState:function(n){return{tag:n.tag,soyState:n.soyState.concat([]),variables:n.variables,context:n.context,indent:n.indent,quoteKind:n.quoteKind,lookupVariables:n.lookupVariables,localStates:n.localStates.map(function(e){return{mode:e.mode,state:l.copyState(e.mode,e.state)}})}},token:function(n,e){var t;switch(p(e.soyState)){case"comment":if(n.match(/^.*?\*\//)?e.soyState.pop():n.skipToEnd(),!e.context||!e.context.scope)for(var o=/@param\??\s+(\S+)/g,c=n.current(),t;t=o.exec(c);)e.variables=S(e.variables,t[1]);return"comment";case"string":var t=n.match(/^.*?(["']|\\[\s\S])/);return t?t[1]==e.quoteKind&&(e.quoteKind=null,e.soyState.pop()):n.skipToEnd(),"string"}if(!e.soyState.length||p(e.soyState)!="literal"){if(n.match(/^\/\*/))return e.soyState.push("comment"),"comment";if(n.match(n.sol()?/^\s*\/\/.*/:/^\s+\/\/.*/))return"comment"}switch(p(e.soyState)){case"templ-def":return(t=n.match(/^\.?([\w]+(?!\.[\w]+)*)/))?(e.soyState.pop(),"def"):(n.next(),null);case"templ-ref":return(t=n.match(/(\.?[a-zA-Z_][a-zA-Z_0-9]+)+/))?(e.soyState.pop(),t[0][0]=="."?"variable-2":"variable"):(t=n.match(/^\$([\w]+)/))?(e.soyState.pop(),k(e.variables,t[1],!e.lookupVariables)):(n.next(),null);case"namespace-def":return(t=n.match(/^\.?([\w\.]+)/))?(e.soyState.pop(),"variable"):(n.next(),null);case"param-def":return(t=n.match(/^\*/))?(e.soyState.pop(),e.soyState.push("param-type"),"type"):(t=n.match(/^\w+/))?(e.variables=S(e.variables,t[0]),e.soyState.pop(),e.soyState.push("param-type"),"def"):(n.next(),null);case"param-ref":return(t=n.match(/^\w+/))?(e.soyState.pop(),"property"):(n.next(),null);case"open-parentheses":return n.match(/[)]/)?(e.soyState.pop(),null):s(n,e);case"param-type":var i=n.peek();return"}]=>,".indexOf(i)!=-1?(e.soyState.pop(),null):i=="["?(e.soyState.push("param-type-record"),null):i=="("?(e.soyState.push("param-type-template"),null):i=="<"?(e.soyState.push("param-type-parameter"),null):(t=n.match(/^([\w]+|[?])/))?"type":(n.next(),null);case"param-type-record":var i=n.peek();return i=="]"?(e.soyState.pop(),null):n.match(/^\w+/)?(e.soyState.push("param-type"),"property"):(n.next(),null);case"param-type-parameter":return n.match(/^[>]/)?(e.soyState.pop(),null):n.match(/^[<,]/)?(e.soyState.push("param-type"),null):(n.next(),null);case"param-type-template":return n.match(/[>]/)?(e.soyState.pop(),e.soyState.push("param-type"),null):n.match(/^\w+/)?(e.soyState.push("param-type"),"def"):(n.next(),null);case"var-def":return(t=n.match(/^\$([\w]+)/))?(e.variables=S(e.variables,t[1]),e.soyState.pop(),"def"):(n.next(),null);case"for-loop":return n.match(/\bin\b/)?(e.soyState.pop(),"keyword"):n.peek()=="$"?(e.soyState.push("var-def"),null):(n.next(),null);case"record-literal":return n.match(/^[)]/)?(e.soyState.pop(),null):n.match(/[(,]/)?(e.soyState.push("map-value"),e.soyState.push("record-key"),null):(n.next(),null);case"map-literal":return n.match(/^[)]/)?(e.soyState.pop(),null):n.match(/[(,]/)?(e.soyState.push("map-value"),e.soyState.push("map-value"),null):(n.next(),null);case"list-literal":return n.match("]")?(e.soyState.pop(),e.lookupVariables=!0,b(e),null):n.match(/\bfor\b/)?(e.lookupVariables=!0,e.soyState.push("for-loop"),"keyword"):s(n,e);case"record-key":return n.match(/[\w]+/)?"property":n.match(/^[:]/)?(e.soyState.pop(),null):(n.next(),null);case"map-value":return n.peek()==")"||n.peek()==","||n.match(/^[:)]/)?(e.soyState.pop(),null):s(n,e);case"import":return n.eat(";")?(e.soyState.pop(),e.indent-=2*r.indentUnit,null):n.match(/\w+(?=\s+as\b)/)?"variable":(t=n.match(/\w+/))?/\b(from|as)\b/.test(t[0])?"keyword":"def":(t=n.match(/^["']/))?(e.soyState.push("string"),e.quoteKind=t[0],"string"):(n.next(),null);case"tag":var u,a;e.tag===void 0?(u=!0,a=""):(u=e.tag[0]=="/",a=u?e.tag.substring(1):e.tag);var f=y[a];if(n.match(/^\/?}/)){var T=n.current()=="/}";return T&&!u&&b(e),e.tag=="/template"||e.tag=="/deltemplate"?(e.variables=S(null,"ij"),e.indent=0):e.indent-=r.indentUnit*(T||U.indexOf(e.tag)==-1?2:1),e.soyState.pop(),"keyword"}else if(n.match(/^([\w?]+)(?==)/)){if(e.context&&e.context.tag==a&&n.current()=="kind"&&(t=n.match(/^="([^"]+)/,!1))){var E=t[1];e.context.kind=E;var I=v[E]||v.html,h=p(e.localStates);h.mode.indent&&(e.indent+=h.mode.indent(h.state,"","")),e.localStates.push({mode:I,state:l.startState(I)})}return"attribute"}return s(n,e);case"template-call-expression":return n.match(/^([\w-?]+)(?==)/)?"attribute":n.eat(">")||n.eat("/>")?(e.soyState.pop(),"keyword"):s(n,e);case"literal":return n.match("{/literal}",!1)?(e.soyState.pop(),this.token(n,e)):w(n,e,/\{\/literal}/);case"export":if(t=n.match(/\w+/)){if(e.soyState.pop(),t=="const")return e.soyState.push("const-def"),"keyword";if(t=="extern")return e.soyState.push("param-def"),"keyword"}else n.next();return null;case"const-def":return n.match(/^\w+/)?(e.soyState.pop(),"def"):(n.next(),null)}if(n.match("{literal}"))return e.indent+=r.indentUnit,e.soyState.push("literal"),e.context=new x(e.context,"literal",e.variables),"keyword";if(t=n.match(/^\{([/@\\]?\w+\??)(?=$|[\s}]|\/[/*])/)){var q=e.tag;e.tag=t[1];var u=e.tag[0]=="/",V=!!y[e.tag],a=u?e.tag.substring(1):e.tag,f=y[a];e.tag!="/switch"&&(e.indent+=((u||f&&f.reduceIndent)&&q!="switch"?1:2)*r.indentUnit),e.soyState.push("tag");var g=!1;if(f){if(u||f.soyState&&e.soyState.push(f.soyState),!f.noEndTag&&(V||!u))e.context=new x(e.context,e.tag,f.variableScope?e.variables:null);else if(u){var $=a=="extern"&&e.context&&e.context.tag=="export";if(!e.context||e.context.tag!=a&&!$)g=!0;else if(e.context){if(e.context.kind){e.localStates.pop();var h=p(e.localStates);h.mode.indent&&(e.indent-=h.mode.indent(h.state,"",""))}b(e)}}}else u&&(g=!0);return(g?"error ":"")+"keyword"}else{if(n.eat("{"))return e.tag="print",e.indent+=2*r.indentUnit,e.soyState.push("tag"),"keyword";if(!e.context&&n.sol()&&n.match(/import\b/))return e.soyState.push("import"),e.indent+=2*r.indentUnit,"keyword";if(t=n.match("<{"))return e.soyState.push("template-call-expression"),e.indent+=2*r.indentUnit,e.soyState.push("tag"),"keyword";if(t=n.match("</>"))return e.indent-=1*r.indentUnit,"keyword"}return w(n,e,/\{|\s+\/\/|\/\*/)},indent:function(n,e,t){var o=n.indent,c=p(n.soyState);if(c=="comment")return l.Pass;if(c=="literal")/^\{\/literal}/.test(e)&&(o-=r.indentUnit);else{if(/^\s*\{\/(template|deltemplate)\b/.test(e))return 0;/^\{(\/|(fallbackmsg|elseif|else|ifempty)\b)/.test(e)&&(o-=r.indentUnit),n.tag!="switch"&&/^\{(case|default)\b/.test(e)&&(o-=r.indentUnit),/^\{\/switch\b/.test(e)&&(o-=r.indentUnit)}var i=p(n.localStates);return o&&i.mode.indent&&(o+=i.mode.indent(i.state,e,t)),o},innerMode:function(n){return n.soyState.length&&p(n.soyState)!="literal"?null:p(n.localStates)},electricInput:/^\s*\{(\/|\/template|\/deltemplate|\/switch|fallbackmsg|elseif|else|case|default|ifempty|\/literal\})$/,lineComment:"//",blockCommentStart:"/*",blockCommentEnd:"*/",blockCommentContinue:" * ",useInnerComments:!1,fold:"indent"}},"htmlmixed"),l.registerHelper("wordChars","soy",/[\w$]/),l.registerHelper("hintWords","soy",Object.keys(y).concat(["css","debugger"])),l.defineMIME("text/x-soy","soy")});