// ggsql.js — ggsql language for prism-code-editor
//
// AUTO-GENERATED by tools/build_ggsql_grammar.R from the TextMate grammar at:
// https://github.com/posit-dev/ggsql/blob/main/ggsql-vscode/syntaxes/ggsql.tmLanguage.json
// Do not edit by hand.
//
// NOTE: The import path below is a content-hashed internal module of
// prism-code-editor. If bslib updates prism-code-editor, this hash may change.
// Re-run this script to regenerate.

import "./sql.js";
import { l as languages } from "../../index-C1_GGQ8y.js";

var sql = languages.sql;
var ggsql = {};

// Copy SQL tokens
Object.keys(sql).forEach(function(k) { ggsql[k] = sql[k]; });

// ggsql clause keywords
ggsql["ggsql-keyword"] = {
  pattern: /\b(?:VISUALISE|VISUALIZE|DRAW|PLACE|SCALE|FACET|PROJECT|LABEL|MAPPING|REMAPPING|SETTING|FILTER|FROM|ORDER|BY|PARTITION|RENAMING|AS|TO|VIA)\b/i,
  alias: "keyword",
};

// Geom types
ggsql["ggsql-geom"] = {
  pattern: /\b(?:point|line|path|bar|col|area|tile|polygon|ribbon|histogram|density|smooth|boxplot|violin|text|label|segment|arrow|rule|range|spatial)\b/,
  alias: "builtin",
};

// Scale type modifiers
ggsql["ggsql-scale-type"] = {
  pattern: /\b(?:CONTINUOUS|DISCRETE|BINNED|ORDINAL|IDENTITY)\b/i,
  alias: "builtin",
};

// Scale type values
ggsql["ggsql-scale-value"] = {
  pattern: /\b(?:linear|log|log10|log2|sqrt|reverse|date|datetime|time|viridis|plasma|magma|inferno|cividis|diverging|sequential|identity)\b/,
  alias: "string",
};

// Aesthetic names
ggsql["ggsql-aesthetic"] = {
  pattern: /\b(?:x|y|xmin|xmax|ymin|ymax|xend|yend|theta|radius|thetamin|thetamax|radiusmin|radiusmax|thetaend|radiusend|color|colour|fill|stroke|opacity|size|shape|linetype|linewidth|width|height|label|family|fontface|hjust|vjust|weight|coef|intercept|offset|density|count|intensity|geometry|panel|row|column)\b/,
  alias: "attr-name",
};

// Property names
ggsql["ggsql-property"] = {
  pattern: /\b(?:type|limits|breaks|labels|expand|direction|na_value|palette|domain|range|free|ncol|missing|xlim|ylim|ratio|angle|clip|start|title|subtitle|x|y|caption|tag|color|colour|fill|size|shape|linetype)\b/,
  alias: "property",
};

// Project types
ggsql["ggsql-project"] = {
  pattern: /\b(?:cartesian|polar)\b/,
  alias: "class-name",
};

// Fat arrow operator
ggsql["ggsql-arrow"] = {
  pattern: /=>/,
  alias: "operator",
};

// SQL functions (aggregate, window, datetime, string, math, conversion, conditional, JSON, list)
ggsql["function"] = /\b(?:count|sum|avg|min|max|stddev|variance|array_agg|string_agg|group_concat|row_number|rank|dense_rank|ntile|lag|lead|first_value|last_value|nth_value|cume_dist|percent_rank|date_trunc|date_part|datepart|datename|dateadd|datediff|extract|now|current_date|current_time|current_timestamp|getdate|getutcdate|strftime|strptime|make_date|make_time|make_timestamp|concat|substring|substr|left|right|length|len|char_length|lower|upper|trim|ltrim|rtrim|replace|reverse|repeat|lpad|rpad|split_part|string_split|format|printf|regexp_replace|regexp_extract|regexp_matches|abs|ceil|ceiling|floor|round|trunc|truncate|mod|power|sqrt|exp|ln|log|log10|log2|sign|sin|cos|tan|asin|acos|atan|atan2|pi|degrees|radians|random|rand|cast|convert|coalesce|nullif|ifnull|isnull|nvl|try_cast|typeof|if|iff|iif|greatest|least|decode|json|json_extract|json_extract_path|json_extract_string|json_value|json_query|json_object|json_array|json_array_length|to_json|from_json|list|list_value|list_aggregate|array_length|unnest|generate_series|range)(?=\s*\()/i;

// Reorder: ggsql tokens before generic SQL keyword/boolean
var ordered = {};
["comment", "variable", "string", "identifier"].forEach(function(k) {
  if (k in ggsql) ordered[k] = ggsql[k];
});
["ggsql-keyword", "ggsql-geom", "ggsql-scale-type", "ggsql-scale-value",
 "ggsql-aesthetic", "ggsql-property", "ggsql-project", "ggsql-arrow"].forEach(function(k) {
  if (k in ggsql) ordered[k] = ggsql[k];
});
Object.keys(ggsql).forEach(function(k) {
  if (!(k in ordered)) ordered[k] = ggsql[k];
});

languages.ggsql = ordered;

