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

/*eslint-env browser, amd*/
/*eslint-disable missing-nls */
define("orion/editor/stylers/text_css/syntax", ["orion/editor/stylers/lib/syntax"], function(mLib) {
	// This list generated by modifying cssContentAssist.js getPropertyProposals() to dump a list of all property proposals to the console
	// The list should be reversed so that long names come before short ones ('flex-flow' before 'flex') so the entire word is marked as a keyword
	var keywords = [
		"zoom", "z-index", "writing-mode", "word-wrap", "word-spacing", 
		"word-break", "will-change", "width", "widows", "white-space-collapse", "white-space", "volume", "voice-volume", "voice-stress", "voice-rate", 
		"voice-pitch-range", "voice-pitch", "voice-family", "voice-duration", "voice-balance", "visibility", "vertical-align", "user-select", 
		"user-modify", "unicode-bidi", "transition-timing-function", "transition-property", "transition-duration", "transition-delay", "transition", 
		"transform-style", "transform-origin", "transform", "touch-action", "-ms-touch-action", "top", "text-wrap", "text-transform", "text-shadow", 
		"text-rendering", "text-overflow", "text-outline", "text-justify", "text-indent", "text-height", "text-emphasis", "text-decoration-style", 
		"text-decoration-line", "text-decoration-color", "text-decoration", "text-anchor", "text-align-last", "text-align", "target-position", 
		"target-new", "target-name", "target", "tab-size", "table-layout", "stroke-width", "stroke-opacity", "stroke-miterlimit", "stroke-linejoin", 
		"stroke-linecap", "stroke-dashoffset", "stroke-dasharray", "stroke", "string-set", "stress", "stop-opacity", "stop-color", "src", "speech-rate", 
		"speak-punctuation", "speak-numeral", "speak-header", "speak", "size", "shape-rendering", "ruby-span", "ruby-position", "ruby-overhang", 
		"ruby-align", "rotation-point", "rotation", "right", "richness", "rest-before", "rest-after", "rest", "resize", "rendering-intent", "quotes", 
		"punctuation-trim", "presentation-level", "position", "pointer-events", "play-during", "pitch-range", "pitch", "phonemes", "perspective-origin", 
		"perspective", "pause-before", "pause-after", "pause", "page-policy", "page-break-inside", "page-break-before", "page-break-after", "page", 
		"padding-top", "padding-right", "padding-left", "padding-bottom", "padding", "overflow-y", "overflow-x", "overflow-wrap", "overflow-style", 
		"overflow", "outline-width", "outline-style", "outline-offset", "outline-color", "outline", "orphans", "-webkit-order", "order", "opacity", 
		"object-position", "object-fit", "nav-up", "nav-right", "nav-left", "nav-index", "nav-down", "move-to", "min-width", "min-height", 
		"max-width", "max-height", "mask", "marquee-style", "marquee-speed", "marquee-play-count", "marquee-direction", "marks", "marker-start", 
		"marker-mid", "marker-end", "marker", "mark-before", "mark-after", "mark", "margin-top", "margin-right", "margin-left", "margin-bottom", 
		"margin", "list-style-type", "list-style-position", "list-style-image", "list-style", "line-stacking-strategy", "line-stacking-shift", 
		"line-stacking-ruby", "line-stacking", "line-break", "line-height", "letter-spacing", "left", "kerning", "-webkit-justify-content", "justify-content", 
		"inline-box-align", "ime-mode", "image-resolution", "image-rendering", "image-orientation", "icon", "hyphens", "hyphenate-resource", 
		"hyphenate-lines", "hyphenate-character", "hyphenate-before", "hyphenate-after", "height", "hanging-punctuation", "grid-template-rows", 
		"grid-template-columns", "grid-template-areas", "grid-template", "grid-row-sizing", "grid-row-span", "grid-row-end", "grid-row-start", "grid-row-align", 
		"grid-rows", "grid-row", "grid-layer", "grid-flow", "grid-column-span", "grid-column-end", "grid-column-start", "grid-column-sizing", 
		"grid-column-align", "grid-columns", "grid-column", "grid-cell-stacking", "grid-auto-rows", "grid-auto-position", "grid-auto-flow", 
		"grid-auto-columns", "grid-area", "grid", "glyph-orientation-vertical", "glyph-orientation-horizontal", "font-weight", "font-variant-position", 
		"font-variant-numeric", "font-variant-ligatures", "font-variant-east-asian", "font-variant-caps", "font-variant-alternates", "font-variant", 
		"font-style", "font-stretch", "font-size-adjust", "font-size", "font-kerning", "font-feature-settings", "font-family", "font", "flood-opacity", 
		"flood-color", "float-offset", "float", "-ms-flex-wrap", "-ms-flex-pack", "-ms-flex-order", "-ms-flex-direction", "-ms-flex-align", "-ms-flex", 
		"-webkit-flex-wrap", "-webkit-flex-shrink", "-webkit-flex-grow", "-webkit-flex-flow", "-webkit-flex-direction", "-webkit-flex-basis", "-webkit-flex", 
		"flex-wrap", "flex-shrink", "flex-grow", "flex-flow", "flex-direction", "flex-basis", "flex", "fit-position", "fit", "filter", "fill-rule", 
		"fill-opacity", "fill", "enable-background", "empty-cells", "elevation", "drop-initial-value", "drop-initial-size", "drop-initial-before-align", 
		"drop-initial-before-adjust", "drop-initial-after-align", "drop-initial-after-adjust", "dominant-baseline", "display", "direction", "cursor", 
		"cue-before", "cue-after", "cue", "crop", "counter-reset", "counter-increment", "content", "columns", "column-width", "column-span", 
		"column-rule-width", "column-rule-style", "column-rule-color", "column-rule", "column-gap", "column-fill", "column-count", "color-rendering", 
		"color-profile", "color-interpolation-filters", "color-interpolation", "color", "clip-rule", "clip-path", "-webkit-clip-path", "clip", "clear", 
		"caption-side", "break-inside", "break-before", "break-after", "box-sizing", "box-shadow", "box-decoration-break", "-webkit-box-pack", 
		"-webkit-box-orient", "-webkit-box-ordinal-group", "-webkit-box-lines", "-webkit-box-flex-group", "-webkit-box-flex", "-webkit-box-direction", 
		"-webkit-box-decoration-break", "-webkit-box-align", "-o-box-decoration-break", "-moz-box-pack", "-moz-box-orient", "-moz-box-ordinal-group", "-moz-box-lines", 
		"-moz-box-flex-group", "-moz-box-flex", "-moz-box-direction", "-moz-box-decoration-break", "-moz-box-align", "bottom", "border-width", 
		"border-top-width", "border-top-style", "border-top-right-radius", "border-top-left-radius", "border-top-color", "border-top", "border-style", 
		"border-spacing", "border-right-width", "border-right-style", "border-right-color", "border-right", "border-radius", "border-left-width", 
		"border-left-style", "border-left-color", "border-left", "border-image-width", "border-image-source", "border-image-slice", "border-image-repeat", 
		"border-image-outset", "border-image", "border-color", "border-collapse", "border-bottom-width", "border-bottom-style", "border-bottom-right-radius", 
		"border-bottom-left-radius", "border-bottom-color", "border-bottom", "border", "bookmark-target", "bookmark-state", "bookmark-level", "bookmark-label", 
		"bleed", "binding", "behavior", "baseline-shift", "background-size", "background-repeat", "background-position", "background-origin", 
		"background-image", "background-color", "background-clip", "background-attachment", "background", "backface-visibility", "azimuth", 
		"-o-appearance", "-webkit-appearance", "-ms-appearance", "-moz-appearance", "appearance", "-o-animation-play-state", "-o-animation-name", 
		"-o-animation-iteration-count", "-o-animation-duration", "-o-animation-direction", "-o-animation-delay", "-webkit-animation-play-state", 
		"-webkit-animation-name", "-webkit-animation-iteration-count", "-webkit-animation-fill-mode", "-webkit-animation-duration", "-webkit-animation-direction", 
		"-webkit-animation-delay", "-ms-animation-play-state", "-ms-animation-name", "-ms-animation-iteration-count", "-ms-animation-duration", 
		"-ms-animation-direction", "-ms-animation-delay", "-moz-animation-play-state", "-moz-animation-name", "-moz-animation-iteration-count", 
		"-moz-animation-duration", "-moz-animation-direction", "-moz-animation-delay", "animation-timing-function", "animation-play-state", "animation-name", 
		"animation-iteration-count", "animation-fill-mode", "animation-duration", "animation-direction", "animation-delay", "animation", "alignment-baseline", 
		"alignment-adjust", "-webkit-align-self", "-webkit-align-content", "-webkit-align-items", "all", "align-self", "align-content", "align-items"
	];
	var colors = [
		"AliceBlue", "AntiqueWhite", "Aquamarine", "Aqua", "Azure",
		"Beige", "Bisque", "Black", "BlanchedAlmond", "BlueViolet", "Blue", "Brown", "BurlyWood",
		"CadetBlue", "Chartreuse", "Chocolate", "Coral", "CornflowerBlue", "Cornsilk", "Crimson", "Cyan",
		"DarkBlue", "DarkCyan", "DarkGoldenRod", "DarkGray", "DarkGrey", "DarkGreen", "DarkKhaki", "DarkMagenta", "DarkOliveGreen",
		"DarkOrange", "DarkOrchid", "DarkRed", "DarkSalmon", "DarkSeaGreen", "DarkSlateBlue", "DarkSlateGray", "DarkSlateGrey",
		"DarkTurquoise", "DarkViolet", "DeepPink", "DeepSkyBlue", "DimGray", "DimGrey", "DodgerBlue",
		"FireBrick", "FloralWhite", "ForestGreen", "Fuchsia",
		"Gainsboro", "GhostWhite", "Gold", "GoldenRod", "Gray", "Grey", "GreenYellow", "Green",
		"HoneyDew", "HotPink",
		"IndianRed", "Indigo", "Ivory",
		"Khaki",
		"LavenderBlush", "Lavender", "LawnGreen", "LemonChiffon", "LightBlue", "LightCoral", "LightCyan", "LightGoldenRodYellow",
		"LightGray", "LightGrey", "LightGreen", "LightPink", "LightSalmon", "LightSeaGreen", "LightSkyBlue", "LightSlateGray",
		"LightSlateGrey", "LightSteelBlue", "LightYellow", "LimeGreen", "Lime", "Linen",
		"Magenta", "Maroon", "MediumAquaMarine", "MediumBlue", "MediumOrchid", "MediumPurple", "MediumSeaGreen", "MediumSlateBlue",
		"MediumSpringGreen", "MediumTurquoise", "MediumVioletRed", "MidnightBlue", "MintCream", "MistyRose", "Moccasin",
		"NavajoWhite", "Navy",
		"OldLace", "OliveDrab", "Olive", "OrangeRed", "Orange", "Orchid",
		"PaleGoldenRod", "PaleGreen", "PaleTurquoise", "PaleVioletRed", "PapayaWhip", "PeachPuff", "Peru", "Pink", "Plum", "PowderBlue", "Purple",
		"RebeccaPurple", "Red", "RosyBrown", "RoyalBlue",
		"SaddleBrown", "Salmon", "SandyBrown", "SeaGreen", "SeaShell", "Sienna", "Silver", "SkyBlue", "SlateBlue", "SlateGray", "SlateGrey", "Snow", "SpringGreen", "SteelBlue",
		"Tan", "Teal", "Thistle", "Tomato", "Turquoise",
		"Violet",
		"Wheat", "WhiteSmoke", "White",
		"YellowGreen", "Yellow"
	];
	var directives = ["charset", "document", "font-face", "import", "keyframes", "media", "namespace", "page", "supports"];

	var grammars = [];
	grammars.push.apply(grammars, mLib.grammars);
	grammars.push({
		id: "orion.css",
		contentTypes: ["text/css"],
		patterns: [
			{include: "#string_single_multiline"},
			{include: "#string_double_multiline"},
			{include: "orion.lib#string_doubleQuote"},
			{include: "orion.lib#string_singleQuote"},
			{include: "orion.c-like#comment_block"},
			{include: "orion.lib#brace_open"},
			{include: "orion.lib#brace_close"},
			{include: "orion.lib#bracket_open"},
			{include: "orion.lib#bracket_close"},
			{include: "orion.lib#parenthesis_open"},
			{include: "orion.lib#parenthesis_close"},
			{include: "orion.lib#number_decimal"},
			{include: "#number_hex"},
			{include: "#numeric_value"},
			{include: "#color"},
			{include: "#keyword"},
			{include: "#directive"}
		],
		repository: {
			color: {
				match: "(?i)\\b(?:" + colors.join("|") + ")\\b",
				name: "constant.other.color.css"
			},
			directive: {
				match: "(^|\\s)(@("  + directives.join("|") + "))\\b",
				captures: {
					2: {name: "keyword.other.directive.css"}
				}
			},
			keyword: {
				match: "(?:-webkit-|-moz-|-ms-|-o-|\\b)(?:" + keywords.join("|") + ")\\b",
				name: "support.type.propertyName.css"
			},
			number_hex: {
				match: "#[0-9A-Fa-f]+\\b",
				name: "constant.numeric.hex.css"
			},
			numeric_value: {
				match: "(?i)\\b-?(?:\\.\\d+|\\d+\\.?\\d*)(?:%|em|ex|ch|rem|vw|vh|vmin|vmax|in|cm|mm|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?\\b",
				name: "constant.numeric.value.css"
			},
			string_double_multiline: {
				begin: '"(?:\\\\.|[^\\\\"])*\\\\$',
				end: '^(?:$|(?:\\\\.|[^\\\\"])*("|[^\\\\]$))',
				name: "string.quoted.double.css"
			},
			string_single_multiline: {
				begin: "'(?:\\\\.|[^\\\\'])*\\\\$",
				end: "^(?:$|(?:\\\\.|[^\\\\'])*('|[^\\\\]$))",
				name: "string.quoted.single.css"
			}
		}
	});
	return {
		id: grammars[grammars.length - 1].id,
		grammars: grammars,
		keywords: keywords
	};
});
