import { type AnyType } from './any';
import { FilterOperator, type MetricFilterRule, type ModelRequiredFilterRule } from './filter';
export type RequiredFilter = {
    [key: string]: AnyType;
} & {
    required?: boolean;
};
export type ParsedFilter = {
    type: string;
    values: AnyType[];
    is?: boolean;
    date_interval?: string;
};
declare const filterGrammar = "ROOT\n= EXPRESSION / EMPTY_STRING\nEMPTY_STRING = '' {\n    return {\n      type: 'equals',\n      values: [],\n      is: true,\n    }\n  }\n\nEXPRESSION\n= BETWEEN_DATE / BETWEEN_NUMERICAL / NUMERICAL / DATE_RESTRICTION / LIST / TERM\n\nBETWEEN_DATE = SPACE_SYMBOL* (\"between\"i / \"BETWEEN\") SPACE_SYMBOL+ min:DATE_STRING SPACE_SYMBOL+ (\"and\"i / \"AND\") SPACE_SYMBOL+ max:DATE_STRING {\n    return {\n        type: 'inBetween',\n        values: [min, max],\n        is: true\n    }\n   }\n\nBETWEEN_NUMERICAL = SPACE_SYMBOL* (\"between\"i / \"BETWEEN\") SPACE_SYMBOL+ min:NUMBER SPACE_SYMBOL+ (\"and\"i / \"AND\") SPACE_SYMBOL+ max:NUMBER {\n    return {\n        type: 'inBetween',\n        values: [min, max],\n        is: true\n    }\n   }\n\nNUMERICAL = SPACE_SYMBOL* operator:OPERATOR SPACE_SYMBOL* value:NUMBER {\n    return {\n        type: operator,\n        values: [value]\n    }\n   }\n\nOPERATOR = '>=' / '<=' / '>' / '<'\n\nDATE_STRING\n  = quotation_mark date:ISO_DATE quotation_mark { return date }\n  / ISO_DATE\n\nISO_DATE\n  = year:YEAR \"-\" month:MONTH \"-\" day:DAY time:(\"T\" TIME \"Z\"?)? {\n      return text();\n    }\n\nYEAR = [0-9][0-9][0-9][0-9]\nMONTH = (\"0\" [1-9]) / (\"1\" [0-2])\nDAY = (\"0\" [1-9]) / ([1-2] [0-9]) / (\"3\" [0-1])\nTIME = [0-9][0-9] \":\" [0-9][0-9] \":\" [0-9][0-9] (\".\" [0-9]+)?\n\nDATE_RESTRICTION = SPACE_SYMBOL* operator:DATE_OPERATOR SPACE_SYMBOL* value:NUMBER SPACE_SYMBOL* interval:DATE_INTERVAL {\n    return {\n        type: operator,\n        values: [value],\n        date_interval: interval\n    }\n   }\n\nDATE_OPERATOR = 'inThePast' / 'inTheNext'\nDATE_INTERVAL = 'milliseconds' / 'seconds' / 'minutes' / 'hours' / 'days' / 'weeks' / 'months' / 'years'\n\nNUMBER\n  = '-'? FLOAT ([Ee] [+-]? INTEGER)?\n    { return Number(text()) }\n\nFLOAT\n  = INTEGER '.'? INTEGER?\n\nINTEGER\n  = [0-9]+\n\nLIST\n= left:TERM COMMA right:EXPRESSION {\n return {\n     type: ',',\n       left: left,\n       right: right\n   }\n}\n\nTERM\n=  not:(NOT)? term:(PCT / KEYWORDS / MATCH) {\n    term.is = not ? false : true\n    return term\n   }\n\n\n\nKEYWORDS = (\"EMPTY\" / \"empty\") {\n    return {\n        type: 'blank',\n    }\n}\n/ (\"NULL\" / \"null\") {\n    return {\n        type: 'null',\n    }\n}\nMATCH\n= quotation_mark sequence:(char  / COMMA / UNDERSCORE / CARET)+ quotation_mark {\n       return {\n           type:'equals',\n           values: [sequence.join('')]\n       }\n   }\n   / sequence:(char  / COMMA / UNDERSCORE / CARET)+ {\n    return {\n        type:'equals',\n        values: [sequence.join('')]\n    }\n}\nPCT\n=  CONTAINS / STARTS_WITH / ENDS_WITH\nCONTAINS\n= PCT_SYMBOL value:(char / UNDERSCORE)+ PCT_SYMBOL !(string / PCT_SYMBOL / UNDERSCORE)  {\n  return {\n      type: 'include',\n      values: [value.join('')]\n    }\n}\nSTARTS_WITH\n= value:(char / UNDERSCORE)+ PCT_SYMBOL !(string / PCT_SYMBOL / UNDERSCORE) {\n      return {\n      type: 'startsWith',\n      values: [value.join('')]\n  }\n}\nENDS_WITH\n=  PCT_SYMBOL value:(char / UNDERSCORE)+ !(PCT_SYMBOL ) {\nreturn {\n     type: 'endsWith',\n     values: [value.join('')]\n }\n}\nNOT = '!'\nCOMMA = COMMA_SYMBOL\nraw_string \"string\"\n= str:char_sequence { return str }\nstring \"string\"\n= str:char_sequence { return str ? str.trim():str}\n/* ----- 7. Strings ----- */\nchar_sequence \"string\"\n= quotation_mark chars:(valid_char / escaped_quotation_mark)* quotation_mark {\n  return '\"' + chars.join(\"\") + '\"'\n}\n/\nchars:char+ {return chars.join('') }\nchar \"character\"\n=  ESCAPE_CARET\n/ escape symbol:SYMBOLS { return symbol}\n/ escape\nsequence:(\n      '\"'\n  / \"\\\\\"\n  / \"/\"\n  / \"b\" { return \"\\b\"; }\n  / \"f\" { return \"\\f\"; }\n  / \"n\" { return \"\\n\"; }\n  / \"r\" { return \"\\r\"; }\n  / \"t\" { return \"\\t\"; }\n  / \"u\" digits:$(HEXDIG HEXDIG HEXDIG HEXDIG) {\n      return String.fromCharCode(parseInt(digits, 16));\n    }\n)\n{ return sequence }\n/ unescaped\n/ NOT_SYMBOL\n/* Returns a single space for double escaped space at the end, or before a comma\nto reverse escapeWithDoubleLastEscape */\nESCAPE_CARET\n= CARET (SPACE_SYMBOL ! FOLLOWING_SPACE_END / ESCAPED_DOUBLE_SPACE) {\n  return \" \"\n}\n/\nCARET symbol:(PCT_SYMBOL / UNDERSCORE / COMMA_SYMBOL / CARET / NOT_SYMBOL) {\n  return symbol\n}\nSYMBOLS = PCT_SYMBOL / COMMA_SYMBOL / NOT_SYMBOL / UNDERSCORE / CARET\nPCT_SYMBOL \t\t        = '%'\nUNDERSCORE \t\t        = '_'\nCOMMA_SYMBOL   \t        = \",\"\nNOT_SYMBOL\t  \t        = \"-\"\nSPACE_SYMBOL            = \" \"\nFOLLOWING_SPACE_END     = \"^ \" (&COMMA_SYMBOL / !.)\nESCAPED_DOUBLE_SPACE    = \" ^ \"\nCARET \t   \t\t        = \"^\"\nescape         \t        = \"\\\\\"\nescaped_quotation_mark  = '\\\\\"'\nquotation_mark \t        = '\"'\nunescaped      \t        = !SYMBOLS char:char_range { return char;}\nvalid_char              = char:char_range { return char;}\nchar_range              = [^\\0-\\x1F\\x22\\x5C]\nHEXDIG                  = [0-9a-f]i\n\n\n";
export declare const parseOperator: (operator: string, isTrue: boolean, fieldName: string) => FilterOperator;
export declare const parseFilters: (rawFilters: Record<string, AnyType>[] | undefined) => MetricFilterRule[];
export declare const parseModelRequiredFilters: ({ requiredFilters, defaultFilters, }: {
    requiredFilters: RequiredFilter[] | undefined;
    defaultFilters: RequiredFilter[] | undefined;
}) => ModelRequiredFilterRule[];
export default filterGrammar;
//# sourceMappingURL=filterGrammar.d.ts.map