@dbml/parse 7.0.0-alpha.1 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +0 -0
- package/dist/__tests__/examples/binder/binder.test.d.ts +0 -0
- package/dist/__tests__/examples/binder/records.test.d.ts +0 -0
- package/dist/__tests__/examples/compiler/applyTextEdits.test.d.ts +0 -0
- package/dist/__tests__/examples/compiler/identifierUtils.test.d.ts +0 -0
- package/dist/__tests__/examples/compiler/renameTable.test.d.ts +0 -0
- package/dist/__tests__/examples/compiler/splitQualifiedIdentifier.test.d.ts +0 -0
- package/dist/__tests__/examples/compiler/stringUtils.test.d.ts +0 -0
- package/dist/__tests__/examples/compiler/syncDiagramView.test.d.ts +0 -0
- package/dist/__tests__/examples/interpreter/interpreter.test.d.ts +0 -0
- package/dist/__tests__/examples/interpreter/record/data.test.d.ts +0 -0
- package/dist/__tests__/examples/interpreter/record/fk.test.d.ts +0 -0
- package/dist/__tests__/examples/interpreter/record/increment.test.d.ts +0 -0
- package/dist/__tests__/examples/interpreter/record/multi_records.test.d.ts +0 -0
- package/dist/__tests__/examples/interpreter/record/pk.test.d.ts +0 -0
- package/dist/__tests__/examples/interpreter/record/table_partial.test.d.ts +0 -0
- package/dist/__tests__/examples/interpreter/record/type_compatibility.test.d.ts +0 -0
- package/dist/__tests__/examples/interpreter/record/unique.test.d.ts +0 -0
- package/dist/__tests__/examples/lexer/lexer.test.d.ts +0 -0
- package/dist/__tests__/examples/lexer/scientific-notation.test.d.ts +0 -0
- package/dist/__tests__/examples/parser/parser.test.d.ts +0 -0
- package/dist/__tests__/examples/services/definition/general.test.d.ts +0 -0
- package/dist/__tests__/examples/services/definition/records.test.d.ts +0 -0
- package/dist/__tests__/examples/services/references/general.test.d.ts +0 -0
- package/dist/__tests__/examples/services/references/records.test.d.ts +0 -0
- package/dist/__tests__/examples/services/service_utils.test.d.ts +0 -0
- package/dist/__tests__/examples/services/suggestions/general.test.d.ts +0 -0
- package/dist/__tests__/examples/services/suggestions/suggestions_diagramview.test.d.ts +0 -0
- package/dist/__tests__/examples/services/suggestions/suggestions_records.test.d.ts +0 -0
- package/dist/__tests__/examples/validator/records.test.d.ts +0 -0
- package/dist/__tests__/examples/validator/validator.test.d.ts +0 -0
- package/dist/__tests__/examples/wildcard/wildcard.test.d.ts +0 -0
- package/dist/__tests__/fuzz/interpreter.test.d.ts +0 -0
- package/dist/__tests__/fuzz/parser.test.d.ts +0 -0
- package/dist/__tests__/fuzz/services.test.d.ts +0 -0
- package/dist/__tests__/properties/lexer.test.d.ts +0 -0
- package/dist/__tests__/properties/parser.test.d.ts +0 -0
- package/dist/__tests__/snapshots/binder/binder.test.d.ts +0 -0
- package/dist/__tests__/snapshots/interpreter/interpreter.test.d.ts +0 -0
- package/dist/__tests__/snapshots/lexer/lexer.test.d.ts +0 -0
- package/dist/__tests__/snapshots/nan/nan.test.d.ts +0 -0
- package/dist/__tests__/snapshots/parser/parser.test.d.ts +0 -0
- package/dist/__tests__/snapshots/validator/validator.test.d.ts +0 -0
- package/dist/__tests__/utils/arbitraries/grammars.d.ts +0 -0
- package/dist/__tests__/utils/arbitraries/index.d.ts +0 -0
- package/dist/__tests__/utils/arbitraries/tokens.d.ts +0 -0
- package/dist/__tests__/utils/arbitraries/utils.d.ts +0 -0
- package/dist/__tests__/utils/compiler.d.ts +0 -0
- package/dist/__tests__/utils/index.d.ts +0 -0
- package/dist/__tests__/utils/mocks.d.ts +0 -0
- package/dist/__tests__/utils/testHelpers.d.ts +0 -0
- package/dist/dbml-parse.js +7 -7
- package/dist/dbml-parse.mjs +26 -27
- package/dist/index.d.ts +0 -0
- package/dist/src/compiler/index.d.ts +0 -0
- package/dist/src/compiler/queries/container/element.d.ts +0 -0
- package/dist/src/compiler/queries/container/index.d.ts +0 -0
- package/dist/src/compiler/queries/container/scope.d.ts +0 -0
- package/dist/src/compiler/queries/container/scopeKind.d.ts +0 -0
- package/dist/src/compiler/queries/container/stack.d.ts +0 -0
- package/dist/src/compiler/queries/container/token.d.ts +0 -0
- package/dist/src/compiler/queries/parse.d.ts +0 -0
- package/dist/src/compiler/queries/symbol.d.ts +0 -0
- package/dist/src/compiler/queries/token.d.ts +0 -0
- package/dist/src/compiler/queries/transform/applyTextEdits.d.ts +0 -0
- package/dist/src/compiler/queries/transform/index.d.ts +0 -0
- package/dist/src/compiler/queries/transform/renameTable.d.ts +0 -0
- package/dist/src/compiler/queries/transform/syncDiagramView.d.ts +0 -0
- package/dist/src/compiler/queries/transform/utils.d.ts +0 -0
- package/dist/src/compiler/queries/utils.d.ts +0 -0
- package/dist/src/compiler/types.d.ts +0 -0
- package/dist/src/constants.d.ts +0 -0
- package/dist/src/core/analyzer/analyzer.d.ts +0 -0
- package/dist/src/core/analyzer/binder/binder.d.ts +0 -0
- package/dist/src/core/analyzer/binder/elementBinder/checks.d.ts +0 -0
- package/dist/src/core/analyzer/binder/elementBinder/custom.d.ts +0 -0
- package/dist/src/core/analyzer/binder/elementBinder/diagramView.d.ts +0 -0
- package/dist/src/core/analyzer/binder/elementBinder/enum.d.ts +0 -0
- package/dist/src/core/analyzer/binder/elementBinder/indexes.d.ts +0 -0
- package/dist/src/core/analyzer/binder/elementBinder/note.d.ts +0 -0
- package/dist/src/core/analyzer/binder/elementBinder/project.d.ts +0 -0
- package/dist/src/core/analyzer/binder/elementBinder/records.d.ts +0 -0
- package/dist/src/core/analyzer/binder/elementBinder/ref.d.ts +0 -0
- package/dist/src/core/analyzer/binder/elementBinder/table.d.ts +0 -0
- package/dist/src/core/analyzer/binder/elementBinder/tableGroup.d.ts +0 -0
- package/dist/src/core/analyzer/binder/elementBinder/tablePartial.d.ts +0 -0
- package/dist/src/core/analyzer/binder/types.d.ts +0 -0
- package/dist/src/core/analyzer/binder/utils.d.ts +0 -0
- package/dist/src/core/analyzer/symbol/factory.d.ts +0 -0
- package/dist/src/core/analyzer/symbol/symbolIndex.d.ts +0 -0
- package/dist/src/core/analyzer/symbol/symbolTable.d.ts +0 -0
- package/dist/src/core/analyzer/symbol/symbols.d.ts +0 -0
- package/dist/src/core/analyzer/symbol/utils.d.ts +0 -0
- package/dist/src/core/analyzer/types.d.ts +0 -0
- package/dist/src/core/analyzer/utils.d.ts +0 -0
- package/dist/src/core/analyzer/validator/elementValidators/checks.d.ts +0 -0
- package/dist/src/core/analyzer/validator/elementValidators/custom.d.ts +0 -0
- package/dist/src/core/analyzer/validator/elementValidators/diagramView.d.ts +0 -0
- package/dist/src/core/analyzer/validator/elementValidators/enum.d.ts +0 -0
- package/dist/src/core/analyzer/validator/elementValidators/indexes.d.ts +0 -0
- package/dist/src/core/analyzer/validator/elementValidators/note.d.ts +0 -0
- package/dist/src/core/analyzer/validator/elementValidators/project.d.ts +0 -0
- package/dist/src/core/analyzer/validator/elementValidators/records.d.ts +0 -0
- package/dist/src/core/analyzer/validator/elementValidators/ref.d.ts +0 -0
- package/dist/src/core/analyzer/validator/elementValidators/table.d.ts +0 -0
- package/dist/src/core/analyzer/validator/elementValidators/tableGroup.d.ts +0 -0
- package/dist/src/core/analyzer/validator/elementValidators/tablePartial.d.ts +0 -0
- package/dist/src/core/analyzer/validator/types.d.ts +0 -0
- package/dist/src/core/analyzer/validator/utils.d.ts +0 -0
- package/dist/src/core/analyzer/validator/validator.d.ts +0 -0
- package/dist/src/core/errors.d.ts +0 -0
- package/dist/src/core/interpreter/elementInterpreter/diagramView.d.ts +0 -0
- package/dist/src/core/interpreter/elementInterpreter/enum.d.ts +0 -0
- package/dist/src/core/interpreter/elementInterpreter/project.d.ts +0 -0
- package/dist/src/core/interpreter/elementInterpreter/ref.d.ts +0 -0
- package/dist/src/core/interpreter/elementInterpreter/sticky_note.d.ts +0 -0
- package/dist/src/core/interpreter/elementInterpreter/table.d.ts +0 -0
- package/dist/src/core/interpreter/elementInterpreter/tableGroup.d.ts +0 -0
- package/dist/src/core/interpreter/elementInterpreter/tablePartial.d.ts +0 -0
- package/dist/src/core/interpreter/interpreter.d.ts +0 -0
- package/dist/src/core/interpreter/records/index.d.ts +0 -0
- package/dist/src/core/interpreter/records/utils/constraints/fk.d.ts +0 -0
- package/dist/src/core/interpreter/records/utils/constraints/helper.d.ts +0 -0
- package/dist/src/core/interpreter/records/utils/constraints/index.d.ts +0 -0
- package/dist/src/core/interpreter/records/utils/constraints/pk.d.ts +0 -0
- package/dist/src/core/interpreter/records/utils/constraints/unique.d.ts +0 -0
- package/dist/src/core/interpreter/records/utils/data/index.d.ts +0 -0
- package/dist/src/core/interpreter/records/utils/data/sqlTypes.d.ts +0 -0
- package/dist/src/core/interpreter/records/utils/data/values.d.ts +0 -0
- package/dist/src/core/interpreter/records/utils/index.d.ts +0 -0
- package/dist/src/core/interpreter/types.d.ts +5 -1
- package/dist/src/core/interpreter/utils.d.ts +0 -0
- package/dist/src/core/lexer/lexer.d.ts +0 -0
- package/dist/src/core/lexer/tokens.d.ts +0 -0
- package/dist/src/core/lexer/utils.d.ts +0 -0
- package/dist/src/core/option.d.ts +0 -0
- package/dist/src/core/parser/contextStack.d.ts +0 -0
- package/dist/src/core/parser/factory.d.ts +0 -0
- package/dist/src/core/parser/nodes.d.ts +0 -0
- package/dist/src/core/parser/parser.d.ts +0 -0
- package/dist/src/core/parser/utils.d.ts +0 -0
- package/dist/src/core/report.d.ts +0 -0
- package/dist/src/core/types.d.ts +0 -0
- package/dist/src/core/utils.d.ts +0 -0
- package/dist/src/index.d.ts +0 -0
- package/dist/src/services/definition/provider.d.ts +0 -0
- package/dist/src/services/diagnostics/provider.d.ts +0 -0
- package/dist/src/services/index.d.ts +0 -0
- package/dist/src/services/monarch.d.ts +0 -0
- package/dist/src/services/references/provider.d.ts +0 -0
- package/dist/src/services/suggestions/provider.d.ts +0 -0
- package/dist/src/services/suggestions/recordRowSnippet.d.ts +0 -0
- package/dist/src/services/suggestions/utils.d.ts +0 -0
- package/dist/src/services/types.d.ts +0 -0
- package/dist/src/services/utils.d.ts +0 -0
- package/package.json +2 -2
package/dist/dbml-parse.js
CHANGED
|
@@ -8,15 +8,15 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
8
8
|
`:return``;case`t`:return` `;case`n`:return`
|
|
9
9
|
`;case`\\`:return`\\`;case`r`:return`\r`;case`'`:return`'`;case`"`:return`"`;case"`":return"`";case`0`:return`\0`;case`b`:return`\b`;case`v`:return`\v`;case`f`:return`\f`;case` `:return`\\ `;case`u`:{let t=``;for(let n=0;n<=3;n+=1){if(this.isAtEnd()||!Rl(this.peek()))return this.errors.push(new E(T.INVALID_ESCAPE_SEQUENCE,`Invalid unicode escape sequence '\\u${t}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`,Yc.create(_.STRING_LITERAL,e,this.current,`\\u${t}`,!0))),`\\u${t}`;t+=this.advance()}return String.fromCharCode(parseInt(t,16))}default:return this.text[this.current.offset-1]}}};let od=function(e){return e[e.ListExpression=0]=`ListExpression`,e[e.GroupExpression=1]=`GroupExpression`,e[e.BlockExpression=2]=`BlockExpression`,e}({});var sd=class{constructor(){this.stack=[],this.numberOfNestedLParens=0,this.numberOfNestedLBrackets=0,this.numberOfNestedLBraces=0}push(e){this.stack.push(e),e===od.ListExpression&&(this.numberOfNestedLBrackets+=1),e===od.GroupExpression&&(this.numberOfNestedLParens+=1),e===od.BlockExpression&&(this.numberOfNestedLBraces+=1)}pop(){let e=this.stack.pop();return e===od.ListExpression&&--this.numberOfNestedLBrackets,e===od.GroupExpression&&--this.numberOfNestedLParens,e===od.BlockExpression&&--this.numberOfNestedLBraces,e}top(){return h(this.stack)}isWithinGroupExpressionContext(){return this.numberOfNestedLParens>0}isWithinListExpressionContext(){return this.numberOfNestedLBrackets>0}isWithinBlockExpressionContext(){return this.numberOfNestedLBraces>0}withContextDo(e,t){return()=>{this.push(e);try{return t()}finally{this.pop()}}}findHandlerContext(e,t){if(!(this.numberOfNestedLBraces<=0&&this.numberOfNestedLBrackets<=0&&this.numberOfNestedLParens<=0))for(let n=t;n<e.length-1;n+=1)switch(e[n].kind){case _.COMMA:if(this.isWithinGroupExpressionContext()||this.isWithinListExpressionContext())return[...this.stack].reverse().find(e=>[od.GroupExpression,od.ListExpression].includes(e));break;case _.RPAREN:if(this.isWithinGroupExpressionContext())return od.GroupExpression;break;case _.RBRACE:if(this.isWithinBlockExpressionContext())return od.BlockExpression;break;case _.RBRACKET:if(this.isWithinListExpressionContext())return od.ListExpression;break;default:break}}},cd=class{constructor(e){this.generator=e}create(e,t){return new e(t,this.generator.nextId())}},V=class{constructor(e,t,n){this.token=e,this.partialNode=t,this.handlerContext=n}},ld=class{constructor(e,t,n){this.current=0,this.errors=[],this.contextStack=new sd,this.synchronizeProgram=()=>{let e=this.peek();e.kind===_.EOF?this.logError(e,T.UNEXPECTED_EOF,`Unexpected EOF`):R(this.advance())},this.synchronizeElementDeclarationName=()=>{for(;!this.isAtEnd();){let e=this.peek();if(Ku(e)||this.check(_.COLON,_.LBRACE,_.LBRACKET))break;R(e),this.advance()}},this.synchronizeElementDeclarationAlias=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(_.COLON,_.LBRACE,_.LBRACKET))break;R(e),this.advance()}},this.blockExpression=this.contextStack.withContextDo(od.BlockExpression,()=>{let e={body:[]},t=()=>this.nodeFactory.create(S,e);try{this.consume(`Expect an opening brace '{'`,_.LBRACE),e.blockOpenBrace=this.previous()}catch(e){if(!(e instanceof V))throw e;if(!this.canHandle(e))throw new V(e.token,t(),e.handlerContext);this.synchronizeBlock()}for(;!this.isAtEnd()&&!this.check(_.RBRACE);)try{e.body.push(this.canBeField()?this.fieldDeclaration():this.expression())}catch(n){if(!(n instanceof V))throw n;if(e.body.push(n.partialNode),!this.canHandle(n))throw new V(n.token,t(),n.handlerContext);this.synchronizeBlock()}try{this.consume(`Expect a closing brace '}'`,_.RBRACE),e.blockCloseBrace=this.previous()}catch(e){if(!(e instanceof V))throw e;if(!this.canHandle(e))throw new V(e.token,t(),e.handlerContext);this.synchronizeBlock()}return t()}),this.synchronizeBlock=()=>{if(!this.check(_.RBRACE))for(R(this.advance());!this.isAtEnd();){let e=this.peek();if(this.check(_.RBRACE)||Zc(this.previous(),e))break;R(e),this.advance()}},this.tupleExpression=this.contextStack.withContextDo(od.GroupExpression,()=>{let e={elementList:[],commaList:[]},t=()=>this.nodeFactory.create(fl,{groupOpenParen:e.tupleOpenParen,groupCloseParen:e.tupleCloseParen,expression:e.elementList[0]}),n=()=>this.nodeFactory.create(ul,e);try{this.consume(`Expect an opening parenthesis '('`,_.LPAREN),e.tupleOpenParen=this.previous()}catch(e){if(!(e instanceof V))throw e;if(!this.canHandle(e))throw new V(e.token,n(),e.handlerContext);this.synchronizeTuple()}if(!this.isAtEnd()&&!this.check(_.RPAREN))try{e.elementList.push(this.normalExpression())}catch(n){if(!(n instanceof V))throw n;if(e.elementList.push(n.partialNode),!this.canHandle(n))throw new V(n.token,t(),n.handlerContext);this.synchronizeTuple()}for(;!this.isAtEnd()&&!this.check(_.RPAREN);)try{this.consume(`Expect a comma ','`,_.COMMA),e.commaList.push(this.previous()),e.elementList.push(this.normalExpression())}catch(t){if(!(t instanceof V))throw t;if(t.partialNode instanceof v&&e.elementList.push(t.partialNode),!this.canHandle(t))throw new V(t.token,n(),t.handlerContext);this.synchronizeTuple()}try{this.consume(`Expect a closing parenthesis ')'`,_.RPAREN),e.tupleCloseParen=this.previous()}catch(e){if(!(e instanceof V))throw e;if(!this.canHandle(e))throw new V(e.token,n(),e.handlerContext);this.synchronizeTuple()}return e.elementList.length===1?t():n()}),this.synchronizeTuple=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(_.RPAREN,_.COMMA))break;R(e),this.advance()}},this.listExpression=this.contextStack.withContextDo(od.ListExpression,()=>{let e={elementList:[],commaList:[]},t=()=>this.nodeFactory.create(C,e);try{this.consume(`Expect an opening bracket '['`,_.LBRACKET),e.listOpenBracket=this.previous()}catch(e){if(!(e instanceof V))throw e;if(!this.canHandle(e))throw new V(e.token,t(),e.handlerContext);this.synchronizeList()}if(!this.isAtEnd()&&!this.check(_.RBRACKET))try{e.elementList.push(this.attribute())}catch(n){if(!(n instanceof V))throw n;if(e.elementList.push(n.partialNode),!this.canHandle(n))throw new V(n.token,t(),n.handlerContext);this.synchronizeList()}for(;!this.isAtEnd()&&!this.check(_.RBRACKET);)try{this.consume(`Expect a comma ','`,_.COMMA),e.commaList.push(this.previous()),e.elementList.push(this.attribute())}catch(n){if(!(n instanceof V))throw n;if(n.partialNode instanceof v&&e.elementList.push(n.partialNode),!this.canHandle(n))throw new V(n.token,t(),n.handlerContext);this.synchronizeList()}try{this.consume(`Expect a closing bracket ']'`,_.RBRACKET),e.listCloseBracket=this.previous()}catch(e){if(!(e instanceof V))throw e;if(!this.canHandle(e))throw new V(e.token,t(),e.handlerContext);this.synchronizeList()}return t()}),this.synchronizeList=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(_.COMMA,_.RBRACKET))break;R(e),this.advance()}},this.synchronizeAttributeName=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(_.COMMA,_.RBRACKET,_.COLON))break;R(e),this.advance()}},this.synchronizeAttributeValue=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(_.COMMA,_.RBRACKET))break;R(e),this.advance()}},this.source=e,this.tokens=t,this.nodeFactory=new cd(n)}isAtEnd(){return this.current>=this.tokens.length||this.tokens[this.current].kind===_.EOF}advance(){return this.isAtEnd()?h(this.tokens):this.tokens[this.current++]}peek(e=0){return e+this.current>=this.tokens.length?h(this.tokens):this.tokens[this.current+e]}match(...e){let t=this.check(...e);return t&&this.advance(),t}check(...e){let t=this.peek();return e.includes(t.kind)}previous(){return this.tokens[this.current-1]}canHandle(e){return e.handlerContext===void 0||e.handlerContext===this.contextStack.top()}consume(e,...t){if(!this.match(...t))throw this.logError(this.peek(),T.UNEXPECTED_TOKEN,e),new V(this.peek(),void 0,this.contextStack.findHandlerContext(this.tokens,this.current))}discardUntil(e,...t){if(this.isAtEnd()||!this.check(...t)){for(R(this.peek()),this.logError(this.advance(),T.UNEXPECTED_TOKEN,e);!this.isAtEnd()&&!this.check(...t);)R(this.advance());return!this.isAtEnd()}return!0}gatherInvalid(){let e=[],t=[],n,r=0;for(;r<this.tokens.length&&this.tokens[r].isInvalid;r+=1)t.push(this.tokens[r]);for(n=this.tokens[r],n.leadingInvalid=[...t,...n.leadingInvalid],e.push(n),r+=1;r<this.tokens.length;r+=1){let t=this.tokens[r];t.isInvalid?n.trailingInvalid.push(t):(n=t,e.push(n))}this.tokens=e}parse(){let e=this.program(),t=this.advance(),n=this.nodeFactory.create(rl,{body:e,eof:t,source:this.source});return this.gatherInvalid(),new D({ast:n,tokens:this.tokens},this.errors)}program(){let e=[];for(;!this.isAtEnd();)try{let t=this.elementDeclaration();e.push(t)}catch(t){if(!(t instanceof V))throw t;e.push(t.partialNode),this.synchronizeProgram()}return e}elementDeclaration(){let e={},t=()=>this.nodeFactory.create(b,e);try{this.consume(`Expect an identifier`,_.IDENTIFIER),e.type=this.previous()}catch(e){throw e instanceof V?new V(e.token,t(),e.handlerContext):e}if(!this.check(_.COLON,_.LBRACE,_.LBRACKET))try{e.name=this.normalExpression()}catch(n){if(!(n instanceof V))throw n;if(e.name=n.partialNode,!this.canHandle(n))throw new V(n.token,t(),n.handlerContext);this.synchronizeElementDeclarationName()}if(Ku(this.peek()))if(e.as=this.advance(),this.check(_.COLON,_.LBRACE,_.LBRACKET))this.logError(this.peek(),T.UNEXPECTED_TOKEN,`Expect an alias`);else try{e.alias=this.normalExpression()}catch(n){if(!(n instanceof V))throw n;if(e.alias=n.partialNode,!this.canHandle(n))throw new V(n.token,t(),n.handlerContext);this.synchronizeElementDeclarationAlias()}try{e.attributeList=this.check(_.LBRACKET)?this.listExpression():void 0}catch(n){throw n instanceof V?(e.attributeList=n.partialNode,new V(n.token,t(),n.handlerContext)):n}if(!this.discardUntil(`Expect an opening brace '{' or a colon ':'`,_.LBRACE,_.COLON))return t();try{if(this.match(_.COLON)){e.bodyColon=this.previous();let t=this.expression();t instanceof b?(R(t),this.logError(t,T.UNEXPECTED_ELEMENT_DECLARATION,`An element's simple body must not be an element declaration`)):e.body=t}else e.body=this.blockExpression()}catch(n){throw n instanceof V?(e.body=n.partialNode,new V(n.token,t(),n.handlerContext)):n}return this.nodeFactory.create(b,e)}fieldDeclaration(){let e={},t=()=>this.nodeFactory.create(b,e);try{this.consume(`Expect an identifier`,_.IDENTIFIER),e.type=this.previous()}catch(n){throw n instanceof V?(e.type=n.partialNode,new V(n.token,t(),n.handlerContext)):n}try{this.consume(`Expect a colon ':'`,_.COLON),e.bodyColon=this.previous()}catch(n){throw n instanceof V?(e.bodyColon=n.partialNode,new V(n.token,t(),n.handlerContext)):n}try{let t=this.expression();t instanceof b?this.errors.push(new E(T.INVALID_ELEMENT_IN_SIMPLE_BODY,`Simple body cannot be an element declaration`,t)):e.body=t}catch(n){throw n instanceof V?(e.body=n.partialNode,new V(n.token,t(),n.handlerContext)):n}return this.nodeFactory.create(b,e)}expression(){let e={args:[]},t=()=>Gu(e.callee,e.args,this.nodeFactory).unwrap_or(this.nodeFactory.create(x,e));try{e.callee=this.commaExpression()}catch(n){throw n instanceof V?(e.callee=n.partialNode,new V(n.token,t(),n.handlerContext)):n}if(this.shouldStopFunctionApplication())return t();let n=e.callee;for(;!this.shouldStopFunctionApplication();){Qc(this.previous())||this.logError(n,T.MISSING_SPACES,`Expect a following space`);try{n=this.commaExpression(),e.args.push(n)}catch(r){throw r instanceof V?(n=r.partialNode,e.args.push(n),new V(r.token,t(),r.handlerContext)):r}}return t()}shouldStopFunctionApplication(){if(this.isAtEnd()||Xc(this.previous()))return!0;let e=this.peek().kind;return[_.RBRACE,_.RBRACKET,_.RPAREN,_.COMMA,_.COLON].includes(e)}commaExpression(){let e=this.check(_.COMMA)?this.nodeFactory.create(_l,{prevToken:this.previous()}):this.normalExpression();if(!this.check(_.COMMA))return e;let t={elementList:[e],commaList:[]};do{if(t.commaList.push(this.advance()),this.shouldStopCommaExpression()){t.elementList.push(this.nodeFactory.create(_l,{prevToken:this.previous()}));break}if(this.check(_.COMMA)){t.elementList.push(this.nodeFactory.create(_l,{prevToken:this.previous()}));continue}try{let e=this.normalExpression();t.elementList.push(e)}catch(e){throw e instanceof V?(e.partialNode&&t.elementList.push(e.partialNode),new V(e.token,this.nodeFactory.create(dl,t),e.handlerContext)):e}}while(!this.shouldStopCommaExpression()&&this.check(_.COMMA));return this.nodeFactory.create(dl,t)}shouldStopCommaExpression(){if(this.isAtEnd()||Xc(this.previous()))return!0;let e=this.peek().kind;return[_.RBRACE,_.LBRACE,_.RBRACKET,_.LBRACKET,_.RPAREN,_.LPAREN,_.COLON].includes(e)}normalExpression(){return this.expression_bp(0)}expression_bp(e){let t=this.leftExpression_bp();for(;!this.isAtEnd();){let n=this.peek();if(n.kind===_.LPAREN){let{left:r}=hd(n);if(r<e||Zc(this.previous(),n)&&!this.contextStack.isWithinGroupExpressionContext()&&!this.contextStack.isWithinListExpressionContext())break;try{t=this.nodeFactory.create(w,{callee:t,argumentList:this.tupleExpression()})}catch(e){throw e instanceof V?(t=this.nodeFactory.create(w,{callee:t,argumentList:e.partialNode}),new V(e.token,t,e.handlerContext)):e}}else if(n.kind===_.LBRACKET){if(Qc(this.previous()))break;try{t=this.nodeFactory.create(vl,{expression:t,indexer:this.listExpression()})}catch(e){throw e instanceof V?(t=this.nodeFactory.create(vl,{expression:t,indexer:e.partialNode}),new V(e.token,t,e.handlerContext)):e}}else if(Jc(n)){let r=n,i=hd(r);if(i.left!==null){if(i.left<=e)break;this.advance(),t=this.nodeFactory.create(cl,{expression:t,op:r})}else{let n=dd(r);if(n.left===null||n.left<=e)break;this.advance();try{t=this.nodeFactory.create(sl,{leftExpression:t,op:r,rightExpression:r.value===`.`?this.extractOperand():this.expression_bp(n.right)})}catch(e){throw e instanceof V?(t=this.nodeFactory.create(sl,{leftExpression:t,op:r,rightExpression:e.partialNode}),new V(e.token,t,e.handlerContext)):e}}}else break}return t}leftExpression_bp(){let e;if(Jc(this.peek())){let t={};t.op=this.peek();let n=pd(t.op);if(n.right===null)throw this.logError(t.op,T.UNKNOWN_PREFIX_OP,`Unexpected '${t.op.value}' in an expression`),new V(t.op,this.nodeFactory.create(_l,{prevToken:t.op}),this.contextStack.findHandlerContext(this.tokens,this.current));this.advance();try{t.expression=this.expression_bp(n.right)}catch(e){throw e instanceof V?(t.expression=e.partialNode,new V(e.token,this.nodeFactory.create(ol,t),e.handlerContext)):e}e=this.nodeFactory.create(ol,t)}else if(e=this.extractOperand(),e instanceof _l)throw new V(this.peek(),this.nodeFactory.create(_l,{prevToken:this.peek()}),this.contextStack.findHandlerContext(this.tokens,this.current));return e}extractOperand(){return this.check(_.WILDCARD)?(this.advance(),this.nodeFactory.create(ml,{token:this.previous()})):this.check(_.NUMERIC_LITERAL,_.STRING_LITERAL,_.COLOR_LITERAL,_.QUOTED_STRING,_.IDENTIFIER)?this.primaryExpression():this.check(_.FUNCTION_EXPRESSION)?this.functionExpression():this.check(_.LBRACKET)?this.listExpression():this.check(_.LBRACE)?this.blockExpression():this.check(_.LPAREN)?this.tupleExpression():(this.peek().kind===_.EOF?this.logError(this.peek(),T.UNEXPECTED_EOF,`Unexpected EOF`):this.logError(this.peek(),T.INVALID_OPERAND,`Invalid start of operand "${this.peek().value}"`),this.nodeFactory.create(_l,{prevToken:this.previous()}))}functionExpression(){let e={};try{this.consume(`Expect a function expression`,_.FUNCTION_EXPRESSION),e.value=this.previous()}catch(t){throw t instanceof V?new V(t.token,this.nodeFactory.create(ll,e),t.handlerContext):t}return this.nodeFactory.create(ll,e)}canBeField(){return this.peek().kind===_.IDENTIFIER&&this.peek(1).kind===_.COLON}primaryExpression(){if(this.match(_.COLOR_LITERAL,_.STRING_LITERAL,_.NUMERIC_LITERAL))return this.nodeFactory.create(gl,{expression:this.nodeFactory.create(pl,{literal:this.previous()})});if(this.match(_.QUOTED_STRING,_.IDENTIFIER))return this.nodeFactory.create(gl,{expression:this.nodeFactory.create(hl,{variable:this.previous()})});throw this.logError(this.peek(),T.UNEXPECTED_TOKEN,`Expect a variable or literal`),new V(this.peek(),void 0,this.contextStack.findHandlerContext(this.tokens,this.current))}attribute(){let e={};if(this.check(_.COLON,_.RBRACKET,_.COMMA)){let t=this.peek();this.logError(t,T.EMPTY_ATTRIBUTE_NAME,`Expect a non-empty attribute name`),e.name=this.nodeFactory.create(il,{identifiers:[]})}else try{e.name=this.attributeName()}catch(t){if(!(t instanceof V))throw t;if(e.name=t.partialNode,!this.canHandle(t))throw new V(t.token,this.nodeFactory.create(al,e),t.handlerContext);this.synchronizeAttributeName()}return this.match(_.COLON)&&(e.colon=this.previous(),e.value=this.attributeValue()),this.nodeFactory.create(al,e)}attributeValue(){let e;try{e=this.peek().kind===_.IDENTIFIER&&this.peek(1).kind===_.IDENTIFIER?this.attributeName():this.normalExpression()}catch(t){if(!(t instanceof V)||!this.canHandle(t))throw t;e=t.partialNode,this.synchronizeAttributeValue()}return e}attributeName(){let e=[];if(this.peek().kind!==_.IDENTIFIER)return this.primaryExpression();for(;!this.isAtEnd()&&!this.check(_.COLON,_.COMMA,_.RBRACKET);)try{this.consume(`Expect an identifier`,_.IDENTIFIER),e.push(this.previous())}catch(t){throw t instanceof V?new V(t.token,this.nodeFactory.create(il,{identifiers:e}),t.handlerContext):t}return this.nodeFactory.create(il,{identifiers:e})}logError(e,t,n){this.errors.push(new E(t,n,e))}},ud={"+":{left:9,right:10},"-":{left:9,right:10},"/":{left:11,right:12},"%":{left:11,right:12},"<":{left:7,right:8},"<=":{left:7,right:8},">":{left:7,right:8},">=":{left:7,right:8},"<>":{left:7,right:8},"=":{left:2,right:3},"==":{left:4,right:5},"!=":{left:4,right:5},".":{left:16,right:17}};function dd(e){return ud[e.value]||{left:null,right:null}}var fd={"+":{left:null,right:15},"-":{left:null,right:15},"<":{left:null,right:15},">":{left:null,right:15},"<>":{left:null,right:15},"!":{left:null,right:15},"~":{left:null,right:15}};function pd(e){return fd[e.value]||{left:null,right:null}}var md={"(":{left:14,right:null}};function hd(e){return md[e.value]||{left:null,right:null}}var gd=class{constructor(e,t){this.ast=e,this.symbolFactory=t,this.publicSchemaSymbol=this.symbolFactory.create(xl,{symbolTable:new su}),this.ast.symbol=this.publicSchemaSymbol,this.ast.symbol.declaration=this.ast}validate(){let e=[],t=[];this.ast.body.forEach(n=>{if(n.parent=this.ast,n.type===void 0)return;let r=new(xu(n))(n,this.publicSchemaSymbol.symbolTable,this.symbolFactory).validate();e.push(...r.errors),t.push(...r.warnings)});let n=this.ast.body.filter(e=>Fu(e).unwrap_or(void 0)===A.Project);return n.length>1&&n.forEach(t=>e.push(new E(T.PROJECT_REDEFINED,`Only one project can exist`,t))),new D(this.ast,e,t)}},_d=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return[]}},vd=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.bindBody(this.declarationNode.body)}bindBody(e){if(!e||e instanceof x)return[];let t=e.body.filter(e=>e instanceof b);return this.bindSubElements(t)}bindSubElements(e){return e.flatMap(e=>e.type?new(jd(e))(e,this.ast,this.symbolFactory).bind():[])}},yd=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.declarationNode.body instanceof S?this.bindBody(this.declarationNode.body):[]}bindBody(e){let[,t]=g(e.body,e=>e instanceof x);return this.bindSubElements(t)}bindSubElements(e){return e.flatMap(e=>{if(!e.type)return[];let t=e.type.value.toLowerCase();if(!(e.body instanceof S))return[];let n=[];switch(t){case`tables`:n.push(...this.bindTableReferences(e.body));break;case`notes`:n.push(...this.bindNoteReferences(e.body));break;case`tablegroups`:n.push(...this.bindTableGroupReferences(e.body));break;case`schemas`:n.push(...this.bindSchemaReferences(e.body));break;default:break}return n})}bindTableReferences(e){let[t]=g(e.body,e=>e instanceof x);return t.flatMap(e=>!e.callee||$u(e.callee)?[]:[e.callee,...e.args].flatMap(Md).flatMap(e=>{let t=e.variables.pop();if(!t)return[];let n=e.variables;return Nd(this.ast,[...n.map(e=>({node:e,kind:M.Schema})),{node:t,kind:M.Table}])}))}bindNoteReferences(e){let[t]=g(e.body,e=>e instanceof x);return t.flatMap(e=>!e.callee||$u(e.callee)?[]:Md(e.callee).flatMap(e=>{let t=e.variables.pop();return t?Nd(this.ast,[{node:t,kind:M.Note}]):[]}))}bindTableGroupReferences(e){let[t]=g(e.body,e=>e instanceof x);return t.flatMap(e=>!e.callee||$u(e.callee)?[]:Md(e.callee).flatMap(e=>{let t=e.variables.pop();if(!t)return[];let n=e.variables;return Nd(this.ast,[...n.map(e=>({node:e,kind:M.Schema})),{node:t,kind:M.TableGroup}])}))}bindSchemaReferences(e){let[t]=g(e.body,e=>e instanceof x);return t.flatMap(e=>!e.callee||$u(e.callee)?[]:Md(e.callee).flatMap(e=>Nd(this.ast,e.variables.map(e=>({node:e,kind:M.Schema})))))}},bd=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.declarationNode.body instanceof S?this.bindBody(this.declarationNode.body):[]}bindBody(e){if(!e||e instanceof x)return[];let t=e.body.filter(e=>e instanceof x);return this.bindSubElements(t)}bindSubElements(e){return e.flatMap(e=>e.type?new(jd(e))(e,this.ast,this.symbolFactory).bind():[])}},xd=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return!(this.declarationNode.parent instanceof b)||Fu(this.declarationNode.parent).unwrap_or(void 0)!==A.Table||!(this.declarationNode.body instanceof S)?[]:this.bindBody(this.declarationNode.body)}bindBody(e){if(!e)return[];if(e instanceof x)return this.bindFields([e]);let[t,n]=g(e.body,e=>e instanceof x);return[...this.bindFields(t),...this.bindSubElements(n)]}bindFields(e){return e.flatMap(e=>{if(!e.callee)return[];let t=P(this.declarationNode.parent.name).map(e=>e.join(`.`)).unwrap_or(`<unnamed>`),n=this.declarationNode.parent.symbol.symbolTable;return[e.callee,...e.args].flatMap(Md).flatMap(e=>e.variables.length+e.tupleElements.length>1?[]:e.variables.length?e.variables[0]:e.tupleElements).flatMap(e=>{let r=I(e).unwrap_or(void 0);if(r===void 0)return[];let i=Yl(r),a=n.get(i);return a?(e.referee=a,a.references.push(e),[]):new E(T.BINDING_ERROR,`No column named '${r}' inside Table '${t}'`,e)})})}bindSubElements(e){return e.flatMap(e=>e.type?new(jd(e))(e,this.ast,this.symbolFactory).bind():[])}},Sd=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.bindBody(this.declarationNode.body)}bindBody(e){if(!e||e instanceof x)return[];let t=e.body.filter(e=>e instanceof b);return this.bindSubElements(t)}bindSubElements(e){return e.flatMap(e=>e.type?new(jd(e))(e,this.ast,this.symbolFactory).bind():[])}},Cd=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.declarationNode.body instanceof S?this.bindBody(this.declarationNode.body):[]}bindBody(e){if(!e||e instanceof x)return[];let t=e.body.filter(e=>e instanceof b);return this.bindSubElements(t)}bindSubElements(e){return e.flatMap(e=>e.type?new(jd(e))(e,this.ast,this.symbolFactory).bind():[])}},wd=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return!(this.declarationNode.parent instanceof rl)&&Fu(this.declarationNode.parent).unwrap_or(void 0)!==A.Project?[]:this.bindBody(this.declarationNode.body)}bindBody(e){if(!e)return[];if(e instanceof x)return this.bindFields([e]);let[t,n]=g(e.body,e=>e instanceof x);return[...this.bindFields(t),...this.bindSubElements(n)]}bindFields(e){return e.flatMap(e=>e.callee?[e.callee,...e.args].flatMap(Md).flatMap(e=>{let t=e.tupleElements.length?e.tupleElements:e.variables.pop(),n=e.variables.pop();if(!t||!n)return[];Array.isArray(t)||(t=[t]);let r=e.variables;return t.flatMap(e=>Nd(this.ast,[...r.map(e=>({node:e,kind:M.Schema})),{node:n,kind:M.Table},{node:e,kind:M.Column}]))}):[])}bindSubElements(e){return e.flatMap(e=>e.type?new(jd(e))(e,this.ast,this.symbolFactory).bind():[])}},Td=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.declarationNode.body instanceof S?this.bindBody(this.declarationNode.body):[]}resolvePartialInjections(){let{body:e}=this.declarationNode;return(e?e instanceof S?e.body:[e]:[]).filter(e=>e instanceof x&&Tu(e.callee)).reverse().flatMap(e=>{let t=Lu(e.callee.expression).unwrap_or(void 0);if(!t)return[];let n=t.variables.pop(),r=t.variables;if(!n)return[];let i=Nd(this.ast,[...r.map(e=>({node:e,kind:M.Schema})),{node:n,kind:M.TablePartial}]);return i.length?i:(n.referee?.symbolTable?.forEach(t=>{let r=F(t.declaration.callee).unwrap_or(void 0);if(r===void 0)return;let i=this.symbolFactory.create(Nl,{declaration:e,tablePartialSymbol:n.referee}),a=Yl(r),o=this.declarationNode.symbol?.symbolTable;o?.has(a)||o?.set(a,i)}),[])})}bindBody(e){if(!e)return[];if(e instanceof x)return this.bindFields([e]);let[t,n]=g(e.body,e=>e instanceof x);return[...this.bindFields(t),...this.bindSubElements(n)]}bindFields(e){return(e=>e.flatMap(e=>{if(!e.callee)return[];let t=[],n=[e.callee,...e.args];if(h(n)instanceof C){let e=N(h(n)).getValue();t.push(...e.ref?.flatMap(e=>e.value?this.bindInlineRef(e.value):[])||[]),t.push(...e.default?.flatMap(e=>e.value?this.tryToBindEnumFieldRef(e.value):[])||[]),n.pop()}return n[1]&&this.tryToBindColumnType(n[1]),t}))(e.filter(e=>!Tu(e.callee)))}tryToBindColumnType(e){let t=Lu(e).unwrap_or(void 0);if(!t)return;let n=t.variables.pop(),r=t.variables;n&&Nd(this.ast,[...r.map(e=>({node:e,kind:M.Schema})),{node:n,kind:M.Enum}])}tryToBindEnumFieldRef(e){if(z(e))return[];if(B(e)){let t=e.expression.variable?.value?.toLowerCase();if(t&&Ul.includes(t))return[]}let t=Lu(e).unwrap_or(void 0);if(!t)return[];let n=t.variables.pop(),r=t.variables.pop();if(!n||!r)return[];let i=t.variables;return Nd(this.ast,[...i.map(e=>({node:e,kind:M.Schema})),{node:r,kind:M.Enum},{node:n,kind:M.EnumField}])}bindInlineRef(e){return Md(e).flatMap(e=>{let t=e.variables.pop(),n=e.variables.pop();if(!t)return[];let r=e.variables;return n?Nd(this.ast,[...r.map(e=>({node:e,kind:M.Schema})),{node:n,kind:M.Table},{node:t,kind:M.Column}]):Nd(this.declarationNode,[{node:t,kind:M.Column}])})}bindSubElements(e){return e.flatMap(e=>e.type?new(jd(e))(e,this.ast,this.symbolFactory).bind():[])}},Ed=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.declarationNode.body instanceof S?this.bindBody(this.declarationNode.body):[]}bindBody(e){if(!e)return[];if(e instanceof x)return this.bindFields([e]);let[t,n]=g(e.body,e=>e instanceof x);return[...this.bindFields(t),...this.bindSubElements(n)]}bindFields(e){return e.flatMap(e=>e.callee?[e.callee,...e.args].flatMap(Md).flatMap(e=>{let t=e.variables.pop();if(!t)return[];let n=e.variables;return Nd(this.ast,[...n.map(e=>({node:e,kind:M.Schema})),{node:t,kind:M.Table}])}):[])}bindSubElements(e){return e.flatMap(e=>e.type?new(jd(e))(e,this.ast,this.symbolFactory).bind():[])}},Dd=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.declarationNode.body instanceof S?this.bindBody(this.declarationNode.body):[]}bindBody(e){if(!e)return[];if(e instanceof x)return this.bindFields([e]);let[t,n]=g(e.body,e=>e instanceof x);return[...this.bindFields(t),...this.bindSubElements(n)]}bindFields(e){return e.flatMap(e=>{if(!e.callee)return[];let t=[],n=[e.callee,...e.args];if(h(n)instanceof C){let e=N(h(n)).getValue();t.push(...e.ref?.flatMap(e=>e.value?this.bindInlineRef(e.value):[])||[]),n.pop()}return n[1]&&this.tryToBindColumnType(n[1]),t})}tryToBindColumnType(e){let t=Lu(e).unwrap_or(void 0);if(!t)return;let n=t.variables.pop(),r=t.variables;n&&Nd(this.ast,[...r.map(e=>({node:e,kind:M.Schema})),{node:n,kind:M.Enum}])}bindInlineRef(e){return Md(e).flatMap(e=>{let t=e.variables.pop(),n=e.variables.pop();if(!t)return[];let r=e.variables;return n?Nd(this.ast,[...r.map(e=>({node:e,kind:M.Schema})),{node:n,kind:M.Table},{node:t,kind:M.Column}]):Nd(this.declarationNode,[{node:t,kind:M.Column}])})}bindSubElements(e){return e.flatMap(e=>e.type?new(jd(e))(e,this.ast,this.symbolFactory).bind():[])}};function Od(e){return[ql,Jl,Xl,Ql,Yl,Zl,$l,tu,nu,ru,iu].map(t=>t(e))}function kd(e){if(e instanceof xl)return M.Schema;if(e instanceof wl)return M.Table;if(e instanceof Tl)return M.Column;if(e instanceof Sl)return M.Enum;if(e instanceof Cl)return M.EnumField;if(e instanceof El)return M.TableGroup;if(e instanceof Dl)return M.TableGroupField;if(e instanceof jl)return M.TablePartial;if(e instanceof Nl)return M.Column;if(e instanceof Ml)return M.PartialInjection;if(e instanceof Al)return M.Note;if(e instanceof Ol)return M.DiagramView;if(e instanceof kl)return M.DiagramViewField;throw Error(`No other possible symbol kind in getSymbolKind`)}var Ad=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n,this.boundColumns=new Map}bind(){let e=[];return this.declarationNode.name&&e.push(...this.bindRecordsName(this.declarationNode.name)),this.declarationNode.body instanceof S&&e.push(...this.bindBody(this.declarationNode.body)),e}bindRecordsName(e){return this.declarationNode.parent instanceof rl?this.bindTopLevelName(e):this.bindInsideTableName(e)}bindTopLevelName(e){let t=Wu(e).unwrap_or(void 0);if(!t)return[];let n=t.variables.pop(),r=t.variables;if(!n)return[];let i=Nd(this.ast,[...r.map(e=>({node:e,kind:M.Schema})),{node:n,kind:M.Table}]);if(i.length>0)return i;let a=n.referee;if(!a?.symbolTable)return[];let o=id(n.referee?.declaration).unwrap_or(`<invalid name>`),s=[];for(let e of t.args){let t=I(e).unwrap_or(`<unnamed>`),n=Yl(t),r=a.symbolTable.get(n);if(!r){s.push(new E(T.BINDING_ERROR,`Column '${t}' does not exist in Table '${o}'`,e));continue}e.referee=r,r.references.push(e);let i=this.boundColumns.get(r);i&&(s.push(new E(T.DUPLICATE_COLUMN_REFERENCES_IN_RECORDS,`Column '${t}' is referenced more than once in a Records for Table '${o}'`,i)),s.push(new E(T.DUPLICATE_COLUMN_REFERENCES_IN_RECORDS,`Column '${t}' is referenced more than once in a Records for Table '${o}'`,e))),this.boundColumns.set(r,e)}return s}bindInsideTableName(e){let t=this.declarationNode.parent;if(!(t instanceof b)||Fu(t).unwrap_or(void 0)!==A.Table)return[];let n=t.symbol?.symbolTable;if(!n||!Nu(e))return[];let r=id(t).unwrap_or(`<invalid name>`),i=[];for(let t of e.elementList){let e=I(t).unwrap_or(`<unnamed>`),a=Yl(e),o=n.get(a);if(!o){i.push(new E(T.BINDING_ERROR,`Column '${e}' does not exist in Table '${r}'`,t));continue}t.referee=o,o.references.push(t)}return i}bindBody(e){if(!e)return[];if(e instanceof x)return this.bindDataRow(e);let t=e.body.filter(e=>e instanceof x),n=e.body.filter(e=>e instanceof b);return[...this.bindDataRows(t),...this.bindSubElements(n)]}bindDataRows(e){return e.flatMap(e=>this.bindDataRow(e))}bindDataRow(e){return e.callee?(e.callee instanceof dl?e.callee.elementList:[e.callee]).flatMap(Md).flatMap(e=>{let t=e.variables.pop(),n=e.variables.pop();if(!t||!n)return[];let r=e.variables;return Nd(this.ast,[...r.map(e=>({node:e,kind:M.Schema})),{node:n,kind:M.Enum},{node:t,kind:M.EnumField}])}):[]}bindSubElements(e){return e.flatMap(e=>e.type?new(jd(e))(e,this.ast,this.symbolFactory).bind():[])}};function jd(e){switch(e.type.value.toLowerCase()){case A.Enum:return bd;case A.Table:return Td;case A.TableGroup:return Ed;case A.Project:return Cd;case A.Ref:return wd;case A.Note:return Sd;case A.Indexes:return xd;case A.TablePartial:return Dd;case A.Check:return _d;case A.Records:return Ad;case A.DiagramView:return yd;default:return vd}}function Md(e){if(!e)return[];if(B(e))return[{variables:[e],tupleElements:[]}];if(e instanceof sl){let t=Lu(e).unwrap_or(void 0);return t?[t]:[...Md(e.leftExpression),...Md(e.rightExpression)]}if(e instanceof ol||e instanceof cl)return Md(e.expression);if(e instanceof ul){let t=Lu(e).unwrap_or(void 0);return t?[t]:e.elementList.flatMap(Md)}return[]}function Nd(e,t){if(!e.symbol?.symbolTable)throw Error(`lookupAndBindInScope should only be called with initial scope having a symbol table`);let n=e.symbol.symbolTable,r=kd(e.symbol),i=e instanceof b?id(e).unwrap_or(`<invalid name>`):Gl;if(e instanceof rl&&t.length){let{node:e,kind:n}=t[0];I(e).unwrap_or(`<unnamed>`)===`public`&&n===M.Schema&&t.shift()}for(let e of t){let{node:t,kind:a}=e,o=I(t).unwrap_or(`<unnamed>`),s=au(o,a),c=n.get(s);if(!c)return[new E(T.BINDING_ERROR,`${a} '${o}' does not exist in ${i===void 0?`global scope`:`${r} '${i}'`}`,t)];if(t.referee=c,c.references.push(t),i=o,r=a,!c.symbolTable)return[];n=c.symbolTable}return[]}var Pd=class{constructor(e,t){this.ast=e,this.symbolFactory=t}resolvePartialInjections(){return this.ast.body.filter(e=>Fu(e).unwrap_or(``)===A.Table).flatMap(e=>new Td(e,this.ast,this.symbolFactory).resolvePartialInjections())}resolve(){let e=[];e.push(...this.resolvePartialInjections());for(let t of this.ast.body)if(t.type){let n=new(jd(t))(t,this.ast,this.symbolFactory);e.push(...n.bind())}return new D(this.ast,e)}},Fd=class{constructor(e){this.generator=e}create(e,t){return new e(t,this.generator.nextId())}},Id=class{constructor(e,t){this.ast=e,this.symbolFactory=new Fd(t)}analyze(){return new gd(this.ast,this.symbolFactory).validate().chain(e=>new Pd(e,this.symbolFactory).resolve())}validate(){return new gd(this.ast,this.symbolFactory).validate().chain(e=>new D(e,[]))}};function Ld(e,t){let{variables:n,tupleElements:r}=Lu(e).unwrap(),i=r.map(e=>I(e).unwrap()),a=n.map(e=>I(e).unwrap());return r.length?n.length===0?{schemaName:t.schemaName,tableName:t.name,fieldNames:i}:{tableName:a.pop(),schemaName:a.pop()||null,fieldNames:i}:n.length===1?{schemaName:t.schemaName,tableName:t.name,fieldNames:[a[0]]}:{fieldNames:[a.pop()],tableName:a.pop(),schemaName:a.pop()||null}}function Rd(e){switch(e){case`<`:return[`1`,`*`];case`<>`:return[`*`,`*`];case`>`:return[`*`,`1`];case`-`:return[`1`,`1`];default:throw Error(`Invalid relation op`)}}function H(e){return{start:{offset:e.startPos.offset,line:e.startPos.line+1,column:e.startPos.column+1},end:{offset:e.endPos.offset,line:e.endPos.line+1,column:e.endPos.column+1}}}function zd(e){let t=Iu(e).unwrap_or(void 0)?.pop();return t instanceof ul?t.elementList.map(e=>e.referee):[t.referee]}function Bd(e){let t=P(e).unwrap();return{name:t.pop(),schemaName:t}}function Vd(e){return e.expression.literal.value}function Hd(e,t){if(Array.isArray(e)){let n=e.map(({id:e})=>e).sort().join(`,`),r=t.map(({id:e})=>e).sort().join(`,`);return n<r?`${n}-${r}`:`${r}-${n}`}let n=e.id.toString(),r=t.id.toString();return n<r?`${n}-${r}`:`${r}-${n}`}function Ud(e,t){return Array.isArray(e)?Gc(e.map(({id:e})=>e).sort(),t.map(({id:e})=>e).sort()).every(([e,t])=>e===t):e.id===t.id}function Wd(e){let t=e.split(`
|
|
10
10
|
`),n=t.slice(t.findIndex(e=>e.trimStart()!==``)),r=n.filter(e=>e.trimStart()),i=Math.min(...r.map(e=>e.length-e.trimStart().length));return n.map(e=>e.slice(i)).join(`
|
|
11
|
-
`)}function Gd(e){if(e){if(z(e))return{value:L(e).unwrap(),type:`string`};if(ju(e))return{type:`number`,value:Hl(e)};if(ed(e))return{value:e.expression.variable.value.toLowerCase(),type:`boolean`};if(e instanceof ll&&e.value)return{value:e.value.value,type:`expression`};if(nd(e))return{value:Iu(e).map(h).and_then(F).unwrap(),type:`string`};throw Error(`Unreachable`)}}function Kd(e,t){let n=``,r=null,i,a;if(e instanceof w){let t=e.argumentList.elementList;if(r=t.map(e=>ju(e)?Vl(e):z(e)?L(e).unwrap():F(e).unwrap()).join(`,`),n=`(${r})`,t.length===2&&ju(t[0])&&ju(t[1])){let e=Hl(t[0]),n=Hl(t[1]);!isNaN(e)&&!isNaN(n)&&(i={precision:Math.trunc(e),scale:Math.trunc(n)})}else if(t.length===1&&ju(t[0])){let e=Hl(t[0]);isNaN(e)||(a={length:Math.trunc(e)})}e=e.callee}for(;e instanceof w||e instanceof vl;)e instanceof w?(n=`(${e.argumentList.elementList.map(e=>ju(e)?Vl(e):z(e)?L(e).unwrap():F(e).unwrap()).join(`,`)})${n}`,e=e.callee):e instanceof vl&&(n=`${`[${e.indexer.elementList.map(e=>e.name.expression.literal.value).join(`,`)}]`}${n}`,e=e.array);let{name:o,schemaName:s}=Bd(e),c=s.length===0?null:s[0],l=!![...t.enums.values()].find(e=>e.name===o&&e.schemaName===c);return s.length>1?new D({schemaName:s.length===0?null:s[0],type_name:`${o}${n}`,args:r,numericParams:i,lengthParam:a,isEnum:l},[new E(T.UNSUPPORTED,`Nested schema is not supported`,e)]):new D({schemaName:s.length===0?null:s[0],type_name:`${o}${n}`,args:r,numericParams:i,lengthParam:a,isEnum:l})}function qd(e,t){let n=[...t.tables.entries()].find(([,t])=>t===e)?.[0];if(!n)throw Error(`mergeTableAndPartials should be called after all tables are interpreted`);if(!(n.body instanceof S))throw Error(`Table element should have a block body`);let r=[...e.indexes],i=[...e.checks],a=e.headerColor,o=e.note,s=[...t.tablePartials.values()];for(let t of[...e.partials].reverse()){let{name:e}=t,n=s.find(t=>t.name===e);n&&(r.push(...n.indexes),i.push(...n.checks),n.headerColor!==void 0&&(a=n.headerColor),n.note!==void 0&&(o=n.note))}let c=new Map(e.fields.map(e=>[e.name,e])),l=new Set(c.keys()),u=new Map(s.map(e=>[e.name,e])),d=[];for(let e of n.body.body)if(e instanceof x)if(Tu(e.callee)){let t=F(e.callee.expression).unwrap_or(void 0),n=u.get(t);if(!n)continue;for(let e of n.fields)l.has(e.name)||d.push(e)}else{let t=F(e.callee).unwrap(),n=c.get(t);if(!n)continue;d.push(n)}let f=Bc([...d].reverse(),`name`).reverse();return{...e,fields:f,indexes:r,checks:i,headerColor:a,note:o}}function Jd(e,t){let n=[],r=[...t.tablePartials.values()],i=new Set(e.fields.map(e=>e.name));for(let t of[...e.partials].reverse()){let{name:a}=t,o=r.find(e=>e.name===a);if(o){for(let t of o.fields)if(!i.has(t.name))for(let r of t.inline_refs){let i=Rd(r.relation);n.push({name:null,schemaName:null,token:r.token,endpoints:[{schemaName:r.schemaName,tableName:r.tableName,fieldNames:r.fieldNames,token:r.token,relation:i[1]},{schemaName:e.schemaName,tableName:e.name,fieldNames:[t.name],token:t.token,relation:i[0]}]})}}}return n}var Yd=class{constructor(e,t){this.declarationNode=e,this.env=t,this.table={name:void 0,schemaName:void 0,alias:null,fields:[],token:void 0,indexes:[],partials:[],checks:[]},this.pkColumns=[]}interpret(){this.table.token=H(this.declarationNode),this.env.tables.set(this.declarationNode,this.table);let e=[...this.interpretName(this.declarationNode.name),...this.interpretAlias(this.declarationNode.alias),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)];return this.pkColumns.length>=2&&(this.table.indexes.push({columns:this.pkColumns.map(({name:e,token:t})=>({value:e,type:`column`,token:t})),token:{start:{offset:-1,line:-1,column:-1},end:{offset:-1,line:-1,column:-1}},pk:!0}),this.pkColumns.forEach(e=>{e.pk=!1})),e}interpretName(e){let{name:t,schemaName:n}=Bd(e);return n.length>1?(this.table.name=t,this.table.schemaName=n.join(`.`),[new E(T.UNSUPPORTED,`Nested schema is not supported`,e)]):(this.table.name=t,this.table.schemaName=n.length?n[0]:null,[])}interpretAlias(e){if(!e)return[];let t=I(e).unwrap_or(null);return t&&(this.env.aliases.push({name:t,kind:`table`,value:{tableName:this.table.name,schemaName:this.table.schemaName}}),this.table.alias=t),[]}interpretSettingList(e){let t=N(e).getValue();this.table.headerColor=t[j.HeaderColor]?.length?Vd(t[j.HeaderColor]?.at(0)?.value):void 0;let[n]=t[j.Note]||[];return this.table.note=n&&{value:L(n?.value).map(Wd).unwrap(),token:H(n)},[]}interpretBody(e){let[t,n]=g(e.body,e=>e instanceof x);return[...this.interpretFields(t),...this.interpretSubElements(n)]}interpretSubElements(e){return e.flatMap(e=>{switch(e.type?.value.toLowerCase()){case A.Note:return this.table.note={value:L(e.body instanceof S?e.body.body[0].callee:e.body.callee).map(Wd).unwrap(),token:H(e)},[];case A.Indexes:return this.interpretIndexes(e);case A.Check:return this.interpretChecks(e);case A.Records:return this.env.recordsElements.push(e),[];default:return[]}})}interpretInjection(e,t){let n={order:t,token:H(e)};return n.name=F(e.expression).unwrap_or(``),this.table.partials.push(n),[]}interpretFields(e){let t=(this.declarationNode.symbol?.symbolTable?[...this.declarationNode.symbol.symbolTable.entries()]:[]).filter(([e])=>ou(e).unwrap_or(null)?.kind===M.Column).length?[]:[new E(T.EMPTY_TABLE,`A Table must have at least one column`,this.declarationNode)],n=e.flatMap((e,t)=>Tu(e.callee)?this.interpretInjection(e.callee,t):this.interpretColumn(e));return[...t,...n]}interpretColumn(e){let t=[],n={};n.name=I(e.callee).unwrap();let r=Kd(e.args[0],this.env);n.type=r.getValue(),t.push(...r.getErrors()),n.token=H(e),n.inline_refs=[];let i=e.args.slice(1);if(h(i)instanceof C){let r=N(i.pop()).getValue();n.pk=!!r[j.PK]?.length||!!r[j.PrimaryKey]?.length,n.increment=!!r[j.Increment]?.length,n.unique=!!r[j.Unique]?.length,n.not_null=r[j.NotNull]?.length?!0:r[j.Null]?.length?!1:void 0,n.dbdefault=Gd(r[j.Default]?.at(0)?.value);let a=r[j.Note]?.at(0);n.note=a&&{value:L(a.value).map(Wd).unwrap(),token:H(a)},n.inline_refs=(r[j.Ref]||[]).flatMap(n=>{let[r]=zd(n.value.expression);if(Ud(r,e.symbol))return t.push(new E(T.SAME_ENDPOINT,`Two endpoints are the same`,n)),[];let i=n.value.op,a=P(n.value.expression).unwrap(),o;if(a.length===1){let[e]=a;o={schemaName:this.table.schemaName,tableName:this.table.name,fieldNames:[e],relation:i.value,token:H(n)}}else if(a.length===2){let[e,t]=a;o={schemaName:null,tableName:e,fieldNames:[t],relation:i.value,token:H(n)}}else if(a.length===3){let[e,t,r]=a;o={schemaName:e,tableName:t,fieldNames:[r],relation:i.value,token:H(n)}}else{t.push(new E(T.UNSUPPORTED,`Nested schema is not supported`,n));let e=a.pop(),r=a.pop();o={schemaName:a.join(`.`),tableName:r,fieldNames:[e],relation:i.value,token:H(n)}}let s=this.registerInlineRefToEnv(e,r,o,n);return t.push(...s),s.length===0?o:[]}),n.checks=(r[j.Check]||[]).map(e=>({token:H(e),expression:e.value.value.value}))}return n.pk||=i.some(e=>F(e).unwrap().toLowerCase()===`pk`),n.unique||=i.some(e=>F(e).unwrap().toLowerCase()===`unique`),this.table.fields.push(n),n.pk&&this.pkColumns.push(n),t}interpretIndexes(e){return this.table.indexes.push(...e.body.body.map(e=>{let t={columns:[]},n=e;t.token=H(n);let r=[n.callee,...n.args];if(h(r)instanceof C){let e=N(r.pop()).getValue();t.pk=!!e[j.PK]?.length,t.unique=!!e[j.Unique]?.length,t.name=L(e[j.Name]?.at(0)?.value).unwrap_or(void 0);let n=e[j.Note]?.at(0);t.note=n&&{value:L(n.value).unwrap(),token:H(n)},t.type=F(e[j.Type]?.at(0)?.value).unwrap_or(void 0)}return r.flatMap(e=>{if(!(e instanceof w))return e;let t=[];for(;e instanceof w;)t.push(e.argumentList),e=e.callee;return t.push(e),t}).forEach(e=>{let{functional:n,nonFunctional:r}=Ru(e).unwrap();t.columns.push(...n.map(e=>({value:e.value.value,type:`expression`,token:H(e)})),...r.map(e=>({value:I(e).unwrap(),type:`column`,token:H(e)})))}),t})),[]}interpretChecks(e){return this.table.checks.push(...e.body.body.map(e=>{let t={},n=e;return t.token=H(n),n.args[0]instanceof C&&(t.name=L(N(n.args[0]).getValue()[j.Name]?.at(0)?.value).unwrap_or(void 0)),t.expression=n.callee.value.value,t})),[]}registerInlineRefToEnv(e,t,n,r){let i=Hd(e.symbol,t);if(this.env.refIds[i])return[new E(T.CIRCULAR_REF,`References with same endpoints exist`,r),new E(T.CIRCULAR_REF,`References with same endpoints exist`,this.env.refIds[i])];let a=Rd(n.relation);return this.env.refIds[i]=r,this.env.ref.set(r,{name:null,schemaName:null,token:n.token,endpoints:[{...n,relation:a[1]},{schemaName:this.table.schemaName,tableName:this.table.name,fieldNames:[F(e.callee).unwrap()],token:H(e),relation:a[0]}]}),[]}},Xd=class{constructor(e,t){this.declarationNode=e,this.env=t,this.note={name:void 0,content:void 0,token:void 0}}interpret(){return this.note.token=H(this.declarationNode),this.env.notes.set(this.declarationNode,this.note),[...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)]}interpretName(e){let{name:t}=Bd(e);return this.note.name=t,[]}interpretSettingList(e){let t=N(e).getValue();return this.note.headerColor=t.headercolor?.length?Vd(t.headercolor?.at(0)?.value):void 0,[]}interpretBody(e){let[t,n]=g(e.body,e=>e instanceof x);return t.length!==1||n.length>0?[new E(T.INVALID_NOTE,`Invalid note syntax`,e)]:[...this.interpretNote(t[0])]}interpretNote(e){let t=ta(e,`callee.expression.literal.value`,``);return this.note.content=Wd(t),[]}},Zd=class{constructor(e,t){this.declarationNode=e,this.env=t,this.container=this.declarationNode.parent instanceof b?this.env.tables.get(this.declarationNode.parent):void 0,this.ref={}}interpret(){return this.ref.token=H(this.declarationNode),this.env.ref.set(this.declarationNode,this.ref),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(e){let t=[],n=P(this.declarationNode.name).unwrap_or([]);return this.ref.name=n.pop()||null,n.length>1&&t.push(new E(T.UNSUPPORTED,`Nested schema is not supported`,this.declarationNode.name)),this.ref.schemaName=n.join(`.`)||null,t}interpretBody(e){return e instanceof x?this.interpretField(e):this.interpretField(e.body[0])}interpretField(e){let t=e.callee.op.value,{leftExpression:n,rightExpression:r}=e.callee,i=zd(n),a=zd(r);if(Ud(i,a))return[new E(T.SAME_ENDPOINT,`Two endpoints are the same`,e)];let o=Hd(i,a);if(this.env.refIds[o])return[new E(T.CIRCULAR_REF,`References with same endpoints exist`,this.declarationNode),new E(T.CIRCULAR_REF,`References with same endpoints exist`,this.env.refIds[o])];if(e.args[0]){let t=N(e.args[0]).getValue(),n=t.delete?.at(0)?.value;this.ref.onDelete=n instanceof il?rd(n).unwrap_or(void 0):F(n).unwrap_or(void 0);let r=t.update?.at(0)?.value;this.ref.onUpdate=r instanceof il?rd(r).unwrap_or(void 0):F(r).unwrap_or(void 0),this.ref.color=t.color?.length?Vd(t.color?.at(0)?.value):void 0}let s=Rd(t);return this.ref.endpoints=[{...Ld(n,this.container),relation:s[0],token:H(n)},{...Ld(r,this.container),relation:s[1],token:H(r)}],this.env.refIds[o]=this.declarationNode,[]}},Qd=class{constructor(e,t){this.declarationNode=e,this.env=t,this.tableGroup={tables:[]}}interpret(){let e=[];return this.tableGroup.token=H(this.declarationNode),this.env.tableGroups.set(this.declarationNode,this.tableGroup),e.push(...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)),e}interpretName(e){let t=[],{name:n,schemaName:r}=Bd(e);return r.length>=2&&(this.tableGroup.name=n,this.tableGroup.schemaName=r.join(`.`),t.push(new E(T.UNSUPPORTED,`Nested schema is not supported`,this.declarationNode.name))),this.tableGroup.name=n,this.tableGroup.schemaName=r[0]||null,t}interpretBody(e){let[t,n]=g(e.body,e=>e instanceof x);return[...this.interpretFields(t),...this.interpretSubElements(n)]}interpretSubElements(e){return e.flatMap(e=>{switch(e.type?.value.toLowerCase()){case`note`:this.tableGroup.note={value:L(e.body instanceof S?e.body.body[0].callee:e.body.callee).map(Wd).unwrap(),token:H(e)};break;default:break}return[]})}interpretFields(e){let t=[];return this.tableGroup.tables=e.map(e=>{let n=P(e.callee).unwrap();n.length>2&&t.push(new E(T.UNSUPPORTED,`Nested schema is not supported`,e));let r=Iu(e.callee).unwrap().pop().referee.id;if(this.env.tableOwnerGroup[r]){let i=this.env.tableOwnerGroup[r],{schemaName:a,name:o}=this.env.tableGroups.get(i),s=a?`${a}.${o}`:o;t.push(new E(T.TABLE_REAPPEAR_IN_TABLEGROUP,`Table "${n.join(`.`)}" already appears in group "${s}"`,e))}else this.env.tableOwnerGroup[r]=this.declarationNode;return{name:n.pop(),schemaName:n.join(`.`)}}),t}interpretSettingList(e){let t=N(e).getValue();this.tableGroup.color=t.color?.length?Vd(t.color?.at(0)?.value):void 0;let[n]=t.note||[];return this.tableGroup.note=n&&{value:L(n?.value).map(Wd).unwrap(),token:H(n)},[]}},$d=class{constructor(e,t){this.declarationNode=e,this.env=t,this.enum={values:[]}}interpret(){return this.enum.token=H(this.declarationNode),this.env.enums.set(this.declarationNode,this.enum),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(e){let{name:t,schemaName:n}=Bd(e);return n.length>1?(this.enum.name=t,this.enum.schemaName=n.join(`.`),[new E(T.UNSUPPORTED,`Nested schema is not supported`,e)]):(this.enum.name=t,this.enum.schemaName=n.length?n[0]:null,[])}interpretBody(e){return e.body.flatMap(e=>{let t=e,n={};n.token=H(t),n.name=F(t.callee).unwrap();let r=N(t.args[0]).getValue().note?.at(0);return n.note=r&&{value:L(r.value).map(Wd).unwrap(),token:H(r)},this.enum.values.push(n),[]})}},ef=class{constructor(e,t){this.declarationNode=e,this.env=t,this.tablePartial={name:void 0,fields:[],token:void 0,indexes:[],checks:[]},this.pkColumns=[]}interpret(){this.tablePartial.token=H(this.declarationNode),this.env.tablePartials.set(this.declarationNode,this.tablePartial);let e=[...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)];return this.pkColumns.length>=2&&(this.tablePartial.indexes.push({columns:this.pkColumns.map(({name:e,token:t})=>({value:e,type:`column`,token:t})),token:{start:{offset:-1,line:-1,column:-1},end:{offset:-1,line:-1,column:-1}},pk:!0}),this.pkColumns.forEach(e=>{e.pk=!1})),e}interpretName(e){let{name:t}=Bd(e);return this.tablePartial.name=t,[]}interpretSettingList(e){let t=N(e).getValue(),n=mc(t[j.HeaderColor]);this.tablePartial.headerColor=n?Vd(n.value):void 0;let[r]=t[j.Note]||[];return this.tablePartial.note=r&&{value:L(r?.value).map(Wd).unwrap(),token:H(r)},[]}interpretBody(e){let[t,n]=g(e.body,e=>e instanceof x);return[...this.interpretFields(t),...this.interpretSubElements(n)]}interpretSubElements(e){return e.flatMap(e=>{switch(e.type?.value.toLowerCase()){case A.Note:return this.tablePartial.note={value:L(e.body instanceof S?e.body.body[0].callee:e.body.callee).map(Wd).unwrap(),token:H(e)},[];case A.Indexes:return this.interpretIndexes(e);case A.Check:return this.interpretChecks(e);default:return[]}})}interpretFields(e){return e.flatMap(e=>this.interpretColumn(e))}interpretColumn(e){let t=[],n={};n.name=I(e.callee).unwrap();let r=Kd(e.args[0],this.env);n.type=r.getValue(),t.push(...r.getErrors()),n.token=H(e),n.inline_refs=[];let i=e.args.slice(1);if(h(i)instanceof C){let r=N(i.pop()).getValue();n.pk=!!r[j.PK]?.length||!!r[j.PrimaryKey]?.length,n.increment=!!r[j.Increment]?.length,n.unique=!!r[j.Unique]?.length,n.not_null=r[j.NotNull]?.length?!0:r[j.Null]?.length?!1:void 0,n.dbdefault=Gd(r[j.Default]?.at(0)?.value);let a=r[j.Note]?.at(0);n.note=a&&{value:L(a.value).map(Wd).unwrap(),token:H(a)},n.inline_refs=(r[j.Ref]||[]).flatMap(n=>{let[r]=zd(n.value.expression);if(Ud(r,e.symbol))return t.push(new E(T.SAME_ENDPOINT,`Two endpoints are the same`,n)),[];let i=n.value.op,a=P(n.value.expression).unwrap(),o;if(a.length===2){let[e,t]=a;o={schemaName:null,tableName:e,fieldNames:[t],relation:i.value,token:H(n)}}else if(a.length===3){let[e,t,r]=a;o={schemaName:e,tableName:t,fieldNames:[r],relation:i.value,token:H(n)}}else{t.push(new E(T.UNSUPPORTED,`Unsupported`,n));let e=a.pop(),r=a.pop();o={schemaName:a.join(`.`),tableName:r,fieldNames:[e],relation:i.value,token:H(n)}}return o}),n.checks=(r[j.Check]||[]).map(e=>({token:H(e),expression:e.value.value.value}))}return n.pk||=i.some(e=>F(e).unwrap().toLowerCase()===`pk`),n.unique||=i.some(e=>F(e).unwrap().toLowerCase()===`unique`),this.tablePartial.fields.push(n),n.pk&&this.pkColumns.push(n),t}interpretIndexes(e){return this.tablePartial.indexes.push(...e.body.body.map(e=>{let t={columns:[]},n=e;t.token=H(n);let r=[n.callee,...n.args];if(h(r)instanceof C){let e=N(r.pop()).getValue();t.pk=!!e[j.PK]?.length,t.unique=!!e[j.Unique]?.length,t.name=L(e[j.Name]?.at(0)?.value).unwrap_or(void 0);let n=e[j.Note]?.at(0);t.note=n&&{value:L(n.value).unwrap(),token:H(n)},t.type=F(e[j.Type]?.at(0)?.value).unwrap_or(void 0)}return r.flatMap(e=>{if(!(e instanceof w))return e;let t=[],n=e;for(;n instanceof w;)t.push(n.argumentList),n=n.callee;return t.push(n),t}).forEach(e=>{let{functional:n,nonFunctional:r}=Ru(e).unwrap();t.columns.push(...n.map(e=>({value:e.value.value,type:`expression`,token:H(e)})),...r.map(e=>({value:I(e).unwrap(),type:`column`,token:H(e)})))}),t})),[]}interpretChecks(e){return this.tablePartial.checks.push(...e.body.body.map(e=>{let t={},n=e;return t.token=H(n),n.args[0]instanceof C&&(t.name=L(N(n.args[0]).getValue()[j.Name]?.at(0)?.value).unwrap_or(void 0)),t.expression=n.callee.value.value,t})),[]}},tf=class{constructor(e,t){this.declarationNode=e,this.env=t,this.project={enums:[],refs:[],tableGroups:[],tables:[],tablePartials:[]}}interpret(){return this.env.project.set(this.declarationNode,this.project),this.project.token=H(this.declarationNode),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(e){if(!e)return this.project.name=null,[];let{name:t}=Bd(e);return this.project.name=t,[]}interpretBody(e){return e.body.flatMap(e=>{let t=e;switch(t.type?.value.toLowerCase()){case`table`:{let e=new Yd(t,this.env).interpret();return this.project.tables.push(this.env.tables.get(t)),e}case`ref`:{let e=new Zd(t,this.env).interpret();return this.project.refs.push(this.env.ref.get(t)),e}case`tablegroup`:{let e=new Qd(t,this.env).interpret();return this.project.tableGroups.push(this.env.tableGroups.get(t)),e}case`enum`:{let e=new $d(t,this.env).interpret();return this.project.enums.push(this.env.enums.get(t)),e}case`note`:return this.project.note={value:L(t.body instanceof S?t.body.body[0].callee:t.body.callee).map(Wd).unwrap(),token:H(t)},[];case`tablepartial`:{let e=new ef(t,this.env).interpret();return this.project.tablePartials.push(this.env.tablePartials.get(t)),e}default:return this.project[t.type.value.toLowerCase()]=L(t.body.callee).unwrap(),[]}})}},nf=class{constructor(e,t){this.declarationNode=e,this.env=t,this.diagramView={visibleEntities:{tables:null,stickyNotes:null,tableGroups:null,schemas:null}}}interpret(){let e=[];return this.diagramView.token=H(this.declarationNode),this.env.diagramViews.set(this.declarationNode,this.diagramView),this.env.diagramViewWildcards.set(this.diagramView,new Set),this.env.diagramViewExplicitlySet.set(this.diagramView,new Set),this.declarationNode.name&&e.push(...this.interpretName(this.declarationNode.name)),this.declarationNode.body instanceof S&&e.push(...this.interpretBody(this.declarationNode.body)),e}interpretName(e){let t=P(e).unwrap_or([]);return t.length>0&&(this.diagramView.name=t[t.length-1],t.length>1&&(this.diagramView.schemaName=t.slice(0,-1).join(`.`))),[]}interpretBody(e){if(e.body.length===1){let t=e.body[0];if(t instanceof x&&$u(t.callee))return this.diagramView.visibleEntities={tables:[],stickyNotes:[],tableGroups:[],schemas:[]},this.env.diagramViewWildcards.set(this.diagramView,new Set([`tables`,`stickyNotes`,`tableGroups`,`schemas`])),this.env.diagramViewExplicitlySet.set(this.diagramView,new Set([`tables`,`stickyNotes`,`tableGroups`,`schemas`])),[]}let[t]=g(e.body,e=>e instanceof b),n=new Set;for(let e of t){let t=e.type?.value.toLowerCase();t&&n.add(t),e.body instanceof S&&this.interpretSubBlock(e.body,t)}let r=this.diagramView.visibleEntities;(n.has(`tables`)&&r.tables!==null||n.has(`tablegroups`)&&r.tableGroups!==null||n.has(`schemas`)&&r.schemas!==null)&&(n.has(`tables`)||(r.tables=[]),n.has(`tablegroups`)||(r.tableGroups=[]),n.has(`schemas`)||(r.schemas=[]));let i=this.env.diagramViewExplicitlySet.get(this.diagramView);return n.has(`tables`)&&i.add(`tables`),n.has(`tablegroups`)&&i.add(`tableGroups`),n.has(`schemas`)&&i.add(`schemas`),n.has(`notes`)&&i.add(`stickyNotes`),[]}interpretSubBlock(e,t){if(!t)return;if(e.body.some(e=>e instanceof x&&$u(e.callee))){let e=this.env.diagramViewWildcards.get(this.diagramView);switch(t){case`tables`:this.diagramView.visibleEntities.tables=[],e.add(`tables`);break;case`notes`:this.diagramView.visibleEntities.stickyNotes=[],e.add(`stickyNotes`);break;case`tablegroups`:this.diagramView.visibleEntities.tableGroups=[],e.add(`tableGroups`);break;case`schemas`:this.diagramView.visibleEntities.schemas=[],e.add(`schemas`);break}return}if(e.body.length===0)return;let n=[];for(let t of e.body){if(!(t instanceof x))continue;let e=Bu(t.callee);if(e?.declaration instanceof b){let t=P(e.declaration.name).unwrap_or([]);if(t.length>0){let e=t[t.length-1],r=t.length>1?t.slice(0,-1).join(`.`):Gl;n.push({name:e,schemaName:r});continue}}let r=P(t.callee).unwrap_or([]);if(r.length===0)continue;let i=r[r.length-1],a=r.length>1?r[0]:Gl;n.push({name:i,schemaName:a})}switch(t){case`tables`:this.diagramView.visibleEntities.tables=n.length>0?n:null;break;case`notes`:this.diagramView.visibleEntities.stickyNotes=n.length>0?n.map(e=>({name:e.name})):null;break;case`tablegroups`:this.diagramView.visibleEntities.tableGroups=n.length>0?n.map(e=>({name:e.name})):null;break;case`schemas`:this.diagramView.visibleEntities.schemas=n.length>0?n.map(e=>({name:e.name})):null;break}}},rf={mysql:new Set([`int`,`integer`,`smallint`,`bigint`,`tinyint`,`mediumint`]),postgres:new Set([`int`,`integer`,`smallint`,`bigint`,`serial`,`bigserial`,`smallserial`]),mssql:new Set([`int`,`integer`,`smallint`,`bigint`,`tinyint`]),oracle:new Set([`int`,`integer`,`smallint`]),snowflake:new Set([`int`,`integer`,`smallint`,`bigint`,`tinyint`])},af={mysql:new Set([`decimal`,`numeric`,`float`,`double`,`real`]),postgres:new Set([`decimal`,`numeric`,`real`,`float`,`double precision`]),mssql:new Set([`decimal`,`numeric`,`real`,`float`]),oracle:new Set([`number`,`decimal`,`numeric`,`float`,`real`]),snowflake:new Set([`number`,`decimal`,`numeric`,`float`,`double`,`real`])},of={mysql:new Set([`bool`,`boolean`,`bit`]),postgres:new Set([`bool`,`boolean`]),mssql:new Set([`bit`]),oracle:new Set([]),snowflake:new Set([`boolean`])},sf={mysql:new Set([`varchar`,`char`,`text`,`tinytext`,`mediumtext`,`longtext`,`string`]),postgres:new Set([`varchar`,`char`,`character`,`character varying`,`text`,`string`]),mssql:new Set([`varchar`,`char`,`nvarchar`,`nchar`,`text`,`ntext`,`string`]),oracle:new Set([`varchar`,`varchar2`,`char`,`nvarchar2`,`nchar`,`string`]),snowflake:new Set([`varchar`,`char`,`text`,`string`])},cf={mysql:new Set([`binary`,`varbinary`,`blob`,`tinyblob`,`mediumblob`,`longblob`]),postgres:new Set([`bytea`]),mssql:new Set([`binary`,`varbinary`]),oracle:new Set([`blob`,`raw`]),snowflake:new Set([`binary`,`varbinary`])},lf={mysql:new Set([`date`,`datetime`,`timestamp`,`time`]),postgres:new Set([`date`,`timestamp`,`timestamptz`,`timestamp with time zone`,`timestamp without time zone`,`time`,`timetz`,`time with time zone`,`time without time zone`]),mssql:new Set([`date`,`datetime`,`datetime2`,`smalldatetime`,`time`]),oracle:new Set([`date`,`timestamp`,`timestamp with time zone`,`timestamp with local time zone`]),snowflake:new Set([`date`,`datetime`,`timestamp`,`time`])},uf={mysql:new Set([]),postgres:new Set([`serial`,`smallserial`,`bigserial`]),mssql:new Set([]),oracle:new Set([]),snowflake:new Set([])};function df(e){return e.toLowerCase().trim().replace(/\s+/g,` `)}function ff(e,t){let n=df(e);return t?rf[t].has(n):Object.values(rf).some(e=>e.has(n))}function pf(e,t){let n=df(e);return t?af[t].has(n):Object.values(af).some(e=>e.has(n))}function mf(e,t){return ff(e,t)||pf(e,t)}function hf(e,t){let n=df(e);return t?of[t].has(n):Object.values(of).some(e=>e.has(n))}function gf(e,t){let n=df(e);return t?sf[t].has(n):Object.values(sf).some(e=>e.has(n))}function _f(e,t){let n=df(e);return t?cf[t].has(n):Object.values(cf).some(e=>e.has(n))}function vf(e,t){let n=df(e);return t?lf[t].has(n):Object.values(lf).some(e=>e.has(n))}function yf(e,t){let n=df(e);return t?uf[t].has(n):Object.values(uf).some(e=>e.has(n))}function bf(e){let t=e.declaration;return t instanceof x&&t.args[0]||null}function xf(e){let t=bf(e);if(!(t instanceof w)||!t.argumentList||t.argumentList.elementList.length!==2)return{};let n=zu(t.argumentList.elementList[0]),r=zu(t.argumentList.elementList[1]);return n===null||r===null?{}:{precision:Math.trunc(n),scale:Math.trunc(r)}}function Sf(e){let t=bf(e);if(!(t instanceof w)||!t.argumentList||t.argumentList.elementList.length!==1)return{};let n=zu(t.argumentList.elementList[0]);return n===null?{}:{length:Math.trunc(n)}}function Cf(e,t){if(t)return`string`;if(ff(e))return`integer`;if(pf(e))return`real`;if(hf(e))return`bool`;if(gf(e))return`string`;let n=df(e);return n===`date`?`date`:n===`time`||n===`timetz`||n===`time with time zone`||n===`time without time zone`?`time`:vf(e)?`datetime`:e}var wf=class extends Error{},Tf=class extends wf{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}},Ef=class extends wf{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}},Df=class extends wf{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}},Of=class extends wf{},kf=class extends wf{constructor(e){super(`Invalid unit ${e}`)}},Af=class extends wf{},jf=class extends wf{constructor(){super(`Zone is an abstract class`)}},U=`numeric`,Mf=`short`,Nf=`long`,Pf={year:U,month:U,day:U},Ff={year:U,month:Mf,day:U},If={year:U,month:Mf,day:U,weekday:Mf},Lf={year:U,month:Nf,day:U},Rf={year:U,month:Nf,day:U,weekday:Nf},zf={hour:U,minute:U},Bf={hour:U,minute:U,second:U},Vf={hour:U,minute:U,second:U,timeZoneName:Mf},Hf={hour:U,minute:U,second:U,timeZoneName:Nf},Uf={hour:U,minute:U,hourCycle:`h23`},Wf={hour:U,minute:U,second:U,hourCycle:`h23`},Gf={hour:U,minute:U,second:U,hourCycle:`h23`,timeZoneName:Mf},Kf={hour:U,minute:U,second:U,hourCycle:`h23`,timeZoneName:Nf},qf={year:U,month:U,day:U,hour:U,minute:U},Jf={year:U,month:U,day:U,hour:U,minute:U,second:U},Yf={year:U,month:Mf,day:U,hour:U,minute:U},Xf={year:U,month:Mf,day:U,hour:U,minute:U,second:U},Zf={year:U,month:Mf,day:U,weekday:Mf,hour:U,minute:U},Qf={year:U,month:Nf,day:U,hour:U,minute:U,timeZoneName:Mf},$f={year:U,month:Nf,day:U,hour:U,minute:U,second:U,timeZoneName:Mf},ep={year:U,month:Nf,day:U,weekday:Nf,hour:U,minute:U,timeZoneName:Nf},tp={year:U,month:Nf,day:U,weekday:Nf,hour:U,minute:U,second:U,timeZoneName:Nf},np=class{get type(){throw new jf}get name(){throw new jf}get ianaName(){return this.name}get isUniversal(){throw new jf}offsetName(e,t){throw new jf}formatOffset(e,t){throw new jf}offset(e){throw new jf}equals(e){throw new jf}get isValid(){throw new jf}},rp=null,ip=class e extends np{static get instance(){return rp===null&&(rp=new e),rp}get type(){return`system`}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return Hm(e,t,n)}formatOffset(e,t){return Km(this.offset(e),t)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type===`system`}get isValid(){return!0}},ap=new Map;function op(e){let t=ap.get(e);return t===void 0&&(t=new Intl.DateTimeFormat(`en-US`,{hour12:!1,timeZone:e,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,era:`short`}),ap.set(e,t)),t}var sp={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function cp(e,t){let n=e.format(t).replace(/\u200E/g,``),[,r,i,a,o,s,c,l]=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(n);return[a,r,i,o,s,c,l]}function lp(e,t){let n=e.formatToParts(t),r=[];for(let e=0;e<n.length;e++){let{type:t,value:i}=n[e],a=sp[t];t===`era`?r[a]=i:K(a)||(r[a]=parseInt(i,10))}return r}var up=new Map,dp=class e extends np{static create(t){let n=up.get(t);return n===void 0&&up.set(t,n=new e(t)),n}static resetCache(){up.clear(),ap.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e}).format(),!0}catch{return!1}}constructor(t){super(),this.zoneName=t,this.valid=e.isValidZone(t)}get type(){return`iana`}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return Hm(e,t,n,this.name)}formatOffset(e,t){return Km(this.offset(e),t)}offset(e){if(!this.valid)return NaN;let t=new Date(e);if(isNaN(t))return NaN;let n=op(this.name),[r,i,a,o,s,c,l]=n.formatToParts?lp(n,t):cp(n,t);o===`BC`&&(r=-Math.abs(r)+1);let u=Rm({year:r,month:i,day:a,hour:s===24?0:s,minute:c,second:l,millisecond:0}),d=+t,f=d%1e3;return d-=f>=0?f:1e3+f,(u-d)/(60*1e3)}equals(e){return e.type===`iana`&&e.name===this.name}get isValid(){return this.valid}},fp={};function pp(e,t={}){let n=JSON.stringify([e,t]),r=fp[n];return r||(r=new Intl.ListFormat(e,t),fp[n]=r),r}var mp=new Map;function hp(e,t={}){let n=JSON.stringify([e,t]),r=mp.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),mp.set(n,r)),r}var gp=new Map;function _p(e,t={}){let n=JSON.stringify([e,t]),r=gp.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),gp.set(n,r)),r}var vp=new Map;function yp(e,t={}){let{base:n,...r}=t,i=JSON.stringify([e,r]),a=vp.get(i);return a===void 0&&(a=new Intl.RelativeTimeFormat(e,t),vp.set(i,a)),a}var bp=null;function xp(){return bp||(bp=new Intl.DateTimeFormat().resolvedOptions().locale,bp)}var Sp=new Map;function Cp(e){let t=Sp.get(e);return t===void 0&&(t=new Intl.DateTimeFormat(e).resolvedOptions(),Sp.set(e,t)),t}var wp=new Map;function Tp(e){let t=wp.get(e);if(!t){let n=new Intl.Locale(e);t=`getWeekInfo`in n?n.getWeekInfo():n.weekInfo,`minimalDays`in t||(t={...Fp,...t}),wp.set(e,t)}return t}function Ep(e){let t=e.indexOf(`-x-`);t!==-1&&(e=e.substring(0,t));let n=e.indexOf(`-u-`);if(n===-1)return[e];{let t,r;try{t=hp(e).resolvedOptions(),r=e}catch{let i=e.substring(0,n);t=hp(i).resolvedOptions(),r=i}let{numberingSystem:i,calendar:a}=t;return[r,i,a]}}function Dp(e,t,n){return n||t?(e.includes(`-u-`)||(e+=`-u`),n&&(e+=`-ca-${n}`),t&&(e+=`-nu-${t}`),e):e}function Op(e){let t=[];for(let n=1;n<=12;n++){let r=Y.utc(2009,n,1);t.push(e(r))}return t}function kp(e){let t=[];for(let n=1;n<=7;n++){let r=Y.utc(2016,11,13+n);t.push(e(r))}return t}function Ap(e,t,n,r){let i=e.listingMode();return i===`error`?null:i===`en`?n(t):r(t)}function jp(e){return e.numberingSystem&&e.numberingSystem!==`latn`?!1:e.numberingSystem===`latn`||!e.locale||e.locale.startsWith(`en`)||Cp(e.locale).numberingSystem===`latn`}var Mp=class{constructor(e,t,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;let{padTo:r,floor:i,...a}=n;if(!t||Object.keys(a).length>0){let t={useGrouping:!1,...n};n.padTo>0&&(t.minimumIntegerDigits=n.padTo),this.inf=_p(e,t)}}format(e){if(this.inf){let t=this.floor?Math.floor(e):e;return this.inf.format(t)}else return q(this.floor?Math.floor(e):Pm(e,3),this.padTo)}},Np=class{constructor(e,t,n){this.opts=n,this.originalZone=void 0;let r;if(this.opts.timeZone)this.dt=e;else if(e.zone.type===`fixed`){let t=-1*(e.offset/60),n=t>=0?`Etc/GMT+${t}`:`Etc/GMT${t}`;e.offset!==0&&dp.create(n).valid?(r=n,this.dt=e):(r=`UTC`,this.dt=e.offset===0?e:e.setZone(`UTC`).plus({minutes:e.offset}),this.originalZone=e.zone)}else e.zone.type===`system`?this.dt=e:e.zone.type===`iana`?(this.dt=e,r=e.zone.name):(r=`UTC`,this.dt=e.setZone(`UTC`).plus({minutes:e.offset}),this.originalZone=e.zone);let i={...this.opts};i.timeZone=i.timeZone||r,this.dtf=hp(t,i)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(``):this.dtf.format(this.dt.toJSDate())}formatToParts(){let e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(e=>{if(e.type===`timeZoneName`){let t=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...e,value:t}}else return e}):e}resolvedOptions(){return this.dtf.resolvedOptions()}},Pp=class{constructor(e,t,n){this.opts={style:`long`,...n},!t&&Sm()&&(this.rtf=yp(e,n))}format(e,t){return this.rtf?this.rtf.format(e,t):dh(t,e,this.opts.numeric,this.opts.style!==`long`)}formatToParts(e,t){return this.rtf?this.rtf.formatToParts(e,t):[]}},Fp={firstDay:1,minimalDays:4,weekend:[6,7]},W=class e{static fromOpts(t){return e.create(t.locale,t.numberingSystem,t.outputCalendar,t.weekSettings,t.defaultToEN)}static create(t,n,r,i,a=!1){let o=t||G.defaultLocale;return new e(o||(a?`en-US`:xp()),n||G.defaultNumberingSystem,r||G.defaultOutputCalendar,Om(i)||G.defaultWeekSettings,o)}static resetCache(){bp=null,mp.clear(),gp.clear(),vp.clear(),Sp.clear(),wp.clear()}static fromObject({locale:t,numberingSystem:n,outputCalendar:r,weekSettings:i}={}){return e.create(t,n,r,i)}constructor(e,t,n,r,i){let[a,o,s]=Ep(e);this.locale=a,this.numberingSystem=t||o||null,this.outputCalendar=n||s||null,this.weekSettings=r,this.intl=Dp(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=i,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached??=jp(this),this.fastNumbersCached}listingMode(){let e=this.isEnglish(),t=(this.numberingSystem===null||this.numberingSystem===`latn`)&&(this.outputCalendar===null||this.outputCalendar===`gregory`);return e&&t?`en`:`intl`}clone(t){return!t||Object.getOwnPropertyNames(t).length===0?this:e.create(t.locale||this.specifiedLocale,t.numberingSystem||this.numberingSystem,t.outputCalendar||this.outputCalendar,Om(t.weekSettings)||this.weekSettings,t.defaultToEN||!1)}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,t=!1){return Ap(this,e,Zm,()=>{let n=this.intl===`ja`||this.intl.startsWith(`ja-`);t&=!n;let r=t?{month:e,day:`numeric`}:{month:e},i=t?`format`:`standalone`;if(!this.monthsCache[i][e]){let t=n?e=>this.dtFormatter(e,r).format():e=>this.extract(e,r,`month`);this.monthsCache[i][e]=Op(t)}return this.monthsCache[i][e]})}weekdays(e,t=!1){return Ap(this,e,th,()=>{let n=t?{weekday:e,year:`numeric`,month:`long`,day:`numeric`}:{weekday:e},r=t?`format`:`standalone`;return this.weekdaysCache[r][e]||(this.weekdaysCache[r][e]=kp(e=>this.extract(e,n,`weekday`))),this.weekdaysCache[r][e]})}meridiems(){return Ap(this,void 0,()=>nh,()=>{if(!this.meridiemCache){let e={hour:`numeric`,hourCycle:`h12`};this.meridiemCache=[Y.utc(2016,11,13,9),Y.utc(2016,11,13,19)].map(t=>this.extract(t,e,`dayperiod`))}return this.meridiemCache})}eras(e){return Ap(this,e,oh,()=>{let t={era:e};return this.eraCache[e]||(this.eraCache[e]=[Y.utc(-40,1,1),Y.utc(2017,1,1)].map(e=>this.extract(e,t,`era`))),this.eraCache[e]})}extract(e,t,n){let r=this.dtFormatter(e,t).formatToParts().find(e=>e.type.toLowerCase()===n);return r?r.value:null}numberFormatter(e={}){return new Mp(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,t={}){return new Np(e,this.intl,t)}relFormatter(e={}){return new Pp(this.intl,this.isEnglish(),e)}listFormatter(e={}){return pp(this.intl,e)}isEnglish(){return this.locale===`en`||this.locale.toLowerCase()===`en-us`||Cp(this.intl).locale.startsWith(`en-us`)}getWeekSettings(){return this.weekSettings?this.weekSettings:Cm()?Tp(this.locale):Fp}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}},Ip=null,Lp=class e extends np{static get utcInstance(){return Ip===null&&(Ip=new e(0)),Ip}static instance(t){return t===0?e.utcInstance:new e(t)}static parseSpecifier(t){if(t){let n=t.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(n)return new e(Um(n[1],n[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return`fixed`}get name(){return this.fixed===0?`UTC`:`UTC${Km(this.fixed,`narrow`)}`}get ianaName(){return this.fixed===0?`Etc/UTC`:`Etc/GMT${Km(-this.fixed,`narrow`)}`}offsetName(){return this.name}formatOffset(e,t){return Km(this.fixed,t)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return e.type===`fixed`&&e.fixed===this.fixed}get isValid(){return!0}},Rp=class extends np{constructor(e){super(),this.zoneName=e}get type(){return`invalid`}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return``}offset(){return NaN}equals(){return!1}get isValid(){return!1}};function zp(e,t){if(K(e)||e===null)return t;if(e instanceof np)return e;if(bm(e)){let n=e.toLowerCase();return n===`default`?t:n===`local`||n===`system`?ip.instance:n===`utc`||n===`gmt`?Lp.utcInstance:Lp.parseSpecifier(n)||dp.create(e)}else if(vm(e))return Lp.instance(e);else if(typeof e==`object`&&`offset`in e&&typeof e.offset==`function`)return e;else return new Rp(e)}var Bp={arab:`[٠-٩]`,arabext:`[۰-۹]`,bali:`[᭐-᭙]`,beng:`[০-৯]`,deva:`[०-९]`,fullwide:`[0-9]`,gujr:`[૦-૯]`,hanidec:`[〇|一|二|三|四|五|六|七|八|九]`,khmr:`[០-៩]`,knda:`[೦-೯]`,laoo:`[໐-໙]`,limb:`[᥆-᥏]`,mlym:`[൦-൯]`,mong:`[᠐-᠙]`,mymr:`[၀-၉]`,orya:`[୦-୯]`,tamldec:`[௦-௯]`,telu:`[౦-౯]`,thai:`[๐-๙]`,tibt:`[༠-༩]`,latn:`\\d`},Vp={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},Hp=Bp.hanidec.replace(/[\[|\]]/g,``).split(``);function Up(e){let t=parseInt(e,10);if(isNaN(t)){t=``;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(e[n].search(Bp.hanidec)!==-1)t+=Hp.indexOf(e[n]);else for(let e in Vp){let[n,i]=Vp[e];r>=n&&r<=i&&(t+=r-n)}}return parseInt(t,10)}else return t}var Wp=new Map;function Gp(){Wp.clear()}function Kp({numberingSystem:e},t=``){let n=e||`latn`,r=Wp.get(n);r===void 0&&(r=new Map,Wp.set(n,r));let i=r.get(t);return i===void 0&&(i=RegExp(`${Bp[n]}${t}`),r.set(t,i)),i}var qp=()=>Date.now(),Jp=`system`,Yp=null,Xp=null,Zp=null,Qp=60,$p,em=null,G=class{static get now(){return qp}static set now(e){qp=e}static set defaultZone(e){Jp=e}static get defaultZone(){return zp(Jp,ip.instance)}static get defaultLocale(){return Yp}static set defaultLocale(e){Yp=e}static get defaultNumberingSystem(){return Xp}static set defaultNumberingSystem(e){Xp=e}static get defaultOutputCalendar(){return Zp}static set defaultOutputCalendar(e){Zp=e}static get defaultWeekSettings(){return em}static set defaultWeekSettings(e){em=Om(e)}static get twoDigitCutoffYear(){return Qp}static set twoDigitCutoffYear(e){Qp=e%100}static get throwOnInvalid(){return $p}static set throwOnInvalid(e){$p=e}static resetCaches(){W.resetCache(),dp.resetCache(),Y.resetCache(),Gp()}},tm=class{constructor(e,t){this.reason=e,this.explanation=t}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}},nm=[0,31,59,90,120,151,181,212,243,273,304,334],rm=[0,31,60,91,121,152,182,213,244,274,305,335];function im(e,t){return new tm(`unit out of range`,`you specified ${t} (of type ${typeof t}) as a ${e}, which is invalid`)}function am(e,t,n){let r=new Date(Date.UTC(e,t-1,n));e<100&&e>=0&&r.setUTCFullYear(r.getUTCFullYear()-1900);let i=r.getUTCDay();return i===0?7:i}function om(e,t,n){return n+(Fm(e)?rm:nm)[t-1]}function sm(e,t){let n=Fm(e)?rm:nm,r=n.findIndex(e=>e<t),i=t-n[r];return{month:r+1,day:i}}function cm(e,t){return(e-t+7)%7+1}function lm(e,t=4,n=1){let{year:r,month:i,day:a}=e,o=om(r,i,a),s=cm(am(r,i,a),n),c=Math.floor((o-s+14-t)/7),l;return c<1?(l=r-1,c=Bm(l,t,n)):c>Bm(r,t,n)?(l=r+1,c=1):l=r,{weekYear:l,weekNumber:c,weekday:s,...qm(e)}}function um(e,t=4,n=1){let{weekYear:r,weekNumber:i,weekday:a}=e,o=cm(am(r,1,t),n),s=Im(r),c=i*7+a-o-7+t,l;c<1?(l=r-1,c+=Im(l)):c>s?(l=r+1,c-=Im(r)):l=r;let{month:u,day:d}=sm(l,c);return{year:l,month:u,day:d,...qm(e)}}function dm(e){let{year:t,month:n,day:r}=e;return{year:t,ordinal:om(t,n,r),...qm(e)}}function fm(e){let{year:t,ordinal:n}=e,{month:r,day:i}=sm(t,n);return{year:t,month:r,day:i,...qm(e)}}function pm(e,t){if(!K(e.localWeekday)||!K(e.localWeekNumber)||!K(e.localWeekYear)){if(!K(e.weekday)||!K(e.weekNumber)||!K(e.weekYear))throw new Of(`Cannot mix locale-based week fields with ISO-based week fields`);return K(e.localWeekday)||(e.weekday=e.localWeekday),K(e.localWeekNumber)||(e.weekNumber=e.localWeekNumber),K(e.localWeekYear)||(e.weekYear=e.localWeekYear),delete e.localWeekday,delete e.localWeekNumber,delete e.localWeekYear,{minDaysInFirstWeek:t.getMinDaysInFirstWeek(),startOfWeek:t.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function mm(e,t=4,n=1){let r=ym(e.weekYear),i=km(e.weekNumber,1,Bm(e.weekYear,t,n)),a=km(e.weekday,1,7);return r?i?a?!1:im(`weekday`,e.weekday):im(`week`,e.weekNumber):im(`weekYear`,e.weekYear)}function hm(e){let t=ym(e.year),n=km(e.ordinal,1,Im(e.year));return t?n?!1:im(`ordinal`,e.ordinal):im(`year`,e.year)}function gm(e){let t=ym(e.year),n=km(e.month,1,12),r=km(e.day,1,Lm(e.year,e.month));return t?n?r?!1:im(`day`,e.day):im(`month`,e.month):im(`year`,e.year)}function _m(e){let{hour:t,minute:n,second:r,millisecond:i}=e,a=km(t,0,23)||t===24&&n===0&&r===0&&i===0,o=km(n,0,59),s=km(r,0,59),c=km(i,0,999);return a?o?s?c?!1:im(`millisecond`,i):im(`second`,r):im(`minute`,n):im(`hour`,t)}function K(e){return e===void 0}function vm(e){return typeof e==`number`}function ym(e){return typeof e==`number`&&e%1==0}function bm(e){return typeof e==`string`}function xm(e){return Object.prototype.toString.call(e)===`[object Date]`}function Sm(){try{return typeof Intl<`u`&&!!Intl.RelativeTimeFormat}catch{return!1}}function Cm(){try{return typeof Intl<`u`&&!!Intl.Locale&&(`weekInfo`in Intl.Locale.prototype||`getWeekInfo`in Intl.Locale.prototype)}catch{return!1}}function wm(e){return Array.isArray(e)?e:[e]}function Tm(e,t,n){if(e.length!==0)return e.reduce((e,r)=>{let i=[t(r),r];return e&&n(e[0],i[0])===e[0]?e:i},null)[1]}function Em(e,t){return t.reduce((t,n)=>(t[n]=e[n],t),{})}function Dm(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Om(e){if(e==null)return null;if(typeof e!=`object`)throw new Af(`Week settings must be an object`);if(!km(e.firstDay,1,7)||!km(e.minimalDays,1,7)||!Array.isArray(e.weekend)||e.weekend.some(e=>!km(e,1,7)))throw new Af(`Invalid week settings`);return{firstDay:e.firstDay,minimalDays:e.minimalDays,weekend:Array.from(e.weekend)}}function km(e,t,n){return ym(e)&&e>=t&&e<=n}function Am(e,t){return e-t*Math.floor(e/t)}function q(e,t=2){let n=e<0,r;return r=n?`-`+(``+-e).padStart(t,`0`):(``+e).padStart(t,`0`),r}function jm(e){if(!(K(e)||e===null||e===``))return parseInt(e,10)}function Mm(e){if(!(K(e)||e===null||e===``))return parseFloat(e)}function Nm(e){if(!(K(e)||e===null||e===``)){let t=parseFloat(`0.`+e)*1e3;return Math.floor(t)}}function Pm(e,t,n=`round`){let r=10**t;switch(n){case`expand`:return e>0?Math.ceil(e*r)/r:Math.floor(e*r)/r;case`trunc`:return Math.trunc(e*r)/r;case`round`:return Math.round(e*r)/r;case`floor`:return Math.floor(e*r)/r;case`ceil`:return Math.ceil(e*r)/r;default:throw RangeError(`Value rounding ${n} is out of range`)}}function Fm(e){return e%4==0&&(e%100!=0||e%400==0)}function Im(e){return Fm(e)?366:365}function Lm(e,t){let n=Am(t-1,12)+1,r=e+(t-n)/12;return n===2?Fm(r)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function Rm(e){let t=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond);return e.year<100&&e.year>=0&&(t=new Date(t),t.setUTCFullYear(e.year,e.month-1,e.day)),+t}function zm(e,t,n){return-cm(am(e,1,t),n)+t-1}function Bm(e,t=4,n=1){let r=zm(e,t,n),i=zm(e+1,t,n);return(Im(e)-r+i)/7}function Vm(e){return e>99?e:e>G.twoDigitCutoffYear?1900+e:2e3+e}function Hm(e,t,n,r=null){let i=new Date(e),a={hourCycle:`h23`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`};r&&(a.timeZone=r);let o={timeZoneName:t,...a},s=new Intl.DateTimeFormat(n,o).formatToParts(i).find(e=>e.type.toLowerCase()===`timezonename`);return s?s.value:null}function Um(e,t){let n=parseInt(e,10);Number.isNaN(n)&&(n=0);let r=parseInt(t,10)||0,i=n<0||Object.is(n,-0)?-r:r;return n*60+i}function Wm(e){let t=Number(e);if(typeof e==`boolean`||e===``||!Number.isFinite(t))throw new Af(`Invalid unit value ${e}`);return t}function Gm(e,t){let n={};for(let r in e)if(Dm(e,r)){let i=e[r];if(i==null)continue;n[t(r)]=Wm(i)}return n}function Km(e,t){let n=Math.trunc(Math.abs(e/60)),r=Math.trunc(Math.abs(e%60)),i=e>=0?`+`:`-`;switch(t){case`short`:return`${i}${q(n,2)}:${q(r,2)}`;case`narrow`:return`${i}${n}${r>0?`:${r}`:``}`;case`techie`:return`${i}${q(n,2)}${q(r,2)}`;default:throw RangeError(`Value format ${t} is out of range for property format`)}}function qm(e){return Em(e,[`hour`,`minute`,`second`,`millisecond`])}var Jm=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],Ym=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],Xm=[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`];function Zm(e){switch(e){case`narrow`:return[...Xm];case`short`:return[...Ym];case`long`:return[...Jm];case`numeric`:return[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`11`,`12`];case`2-digit`:return[`01`,`02`,`03`,`04`,`05`,`06`,`07`,`08`,`09`,`10`,`11`,`12`];default:return null}}var Qm=[`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`],$m=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],eh=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function th(e){switch(e){case`narrow`:return[...eh];case`short`:return[...$m];case`long`:return[...Qm];case`numeric`:return[`1`,`2`,`3`,`4`,`5`,`6`,`7`];default:return null}}var nh=[`AM`,`PM`],rh=[`Before Christ`,`Anno Domini`],ih=[`BC`,`AD`],ah=[`B`,`A`];function oh(e){switch(e){case`narrow`:return[...ah];case`short`:return[...ih];case`long`:return[...rh];default:return null}}function sh(e){return nh[e.hour<12?0:1]}function ch(e,t){return th(t)[e.weekday-1]}function lh(e,t){return Zm(t)[e.month-1]}function uh(e,t){return oh(t)[e.year<0?0:1]}function dh(e,t,n=`always`,r=!1){let i={years:[`year`,`yr.`],quarters:[`quarter`,`qtr.`],months:[`month`,`mo.`],weeks:[`week`,`wk.`],days:[`day`,`day`,`days`],hours:[`hour`,`hr.`],minutes:[`minute`,`min.`],seconds:[`second`,`sec.`]},a=[`hours`,`minutes`,`seconds`].indexOf(e)===-1;if(n===`auto`&&a){let n=e===`days`;switch(t){case 1:return n?`tomorrow`:`next ${i[e][0]}`;case-1:return n?`yesterday`:`last ${i[e][0]}`;case 0:return n?`today`:`this ${i[e][0]}`}}let o=Object.is(t,-0)||t<0,s=Math.abs(t),c=s===1,l=i[e],u=r?c?l[1]:l[2]||l[1]:c?i[e][0]:e;return o?`${s} ${u} ago`:`in ${s} ${u}`}function fh(e,t){let n=``;for(let r of e)r.literal?n+=r.val:n+=t(r.val);return n}var ph={D:Pf,DD:Ff,DDD:Lf,DDDD:Rf,t:zf,tt:Bf,ttt:Vf,tttt:Hf,T:Uf,TT:Wf,TTT:Gf,TTTT:Kf,f:qf,ff:Yf,fff:Qf,ffff:ep,F:Jf,FF:Xf,FFF:$f,FFFF:tp},mh=class e{static create(t,n={}){return new e(t,n)}static parseFormat(e){let t=null,n=``,r=!1,i=[];for(let a=0;a<e.length;a++){let o=e.charAt(a);o===`'`?((n.length>0||r)&&i.push({literal:r||/^\s+$/.test(n),val:n===``?`'`:n}),t=null,n=``,r=!r):r||o===t?n+=o:(n.length>0&&i.push({literal:/^\s+$/.test(n),val:n}),n=o,t=o)}return n.length>0&&i.push({literal:r||/^\s+$/.test(n),val:n}),i}static macroTokenToFormatOpts(e){return ph[e]}constructor(e,t){this.opts=t,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,t){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...t}).format()}dtFormatter(e,t={}){return this.loc.dtFormatter(e,{...this.opts,...t})}formatDateTime(e,t){return this.dtFormatter(e,t).format()}formatDateTimeParts(e,t){return this.dtFormatter(e,t).formatToParts()}formatInterval(e,t){return this.dtFormatter(e.start,t).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,t){return this.dtFormatter(e,t).resolvedOptions()}num(e,t=0,n=void 0){if(this.opts.forceSimple)return q(e,t);let r={...this.opts};return t>0&&(r.padTo=t),n&&(r.signDisplay=n),this.loc.numberFormatter(r).format(e)}formatDateTimeFromString(t,n){let r=this.loc.listingMode()===`en`,i=this.loc.outputCalendar&&this.loc.outputCalendar!==`gregory`,a=(e,n)=>this.loc.extract(t,e,n),o=e=>t.isOffsetFixed&&t.offset===0&&e.allowZ?`Z`:t.isValid?t.zone.formatOffset(t.ts,e.format):``,s=()=>r?sh(t):a({hour:`numeric`,hourCycle:`h12`},`dayperiod`),c=(e,n)=>r?lh(t,e):a(n?{month:e}:{month:e,day:`numeric`},`month`),l=(e,n)=>r?ch(t,e):a(n?{weekday:e}:{weekday:e,month:`long`,day:`numeric`},`weekday`),u=n=>{let r=e.macroTokenToFormatOpts(n);return r?this.formatWithSystemDefault(t,r):n},d=e=>r?uh(t,e):a({era:e},`era`);return fh(e.parseFormat(n),e=>{switch(e){case`S`:return this.num(t.millisecond);case`u`:case`SSS`:return this.num(t.millisecond,3);case`s`:return this.num(t.second);case`ss`:return this.num(t.second,2);case`uu`:return this.num(Math.floor(t.millisecond/10),2);case`uuu`:return this.num(Math.floor(t.millisecond/100));case`m`:return this.num(t.minute);case`mm`:return this.num(t.minute,2);case`h`:return this.num(t.hour%12==0?12:t.hour%12);case`hh`:return this.num(t.hour%12==0?12:t.hour%12,2);case`H`:return this.num(t.hour);case`HH`:return this.num(t.hour,2);case`Z`:return o({format:`narrow`,allowZ:this.opts.allowZ});case`ZZ`:return o({format:`short`,allowZ:this.opts.allowZ});case`ZZZ`:return o({format:`techie`,allowZ:this.opts.allowZ});case`ZZZZ`:return t.zone.offsetName(t.ts,{format:`short`,locale:this.loc.locale});case`ZZZZZ`:return t.zone.offsetName(t.ts,{format:`long`,locale:this.loc.locale});case`z`:return t.zoneName;case`a`:return s();case`d`:return i?a({day:`numeric`},`day`):this.num(t.day);case`dd`:return i?a({day:`2-digit`},`day`):this.num(t.day,2);case`c`:return this.num(t.weekday);case`ccc`:return l(`short`,!0);case`cccc`:return l(`long`,!0);case`ccccc`:return l(`narrow`,!0);case`E`:return this.num(t.weekday);case`EEE`:return l(`short`,!1);case`EEEE`:return l(`long`,!1);case`EEEEE`:return l(`narrow`,!1);case`L`:return i?a({month:`numeric`,day:`numeric`},`month`):this.num(t.month);case`LL`:return i?a({month:`2-digit`,day:`numeric`},`month`):this.num(t.month,2);case`LLL`:return c(`short`,!0);case`LLLL`:return c(`long`,!0);case`LLLLL`:return c(`narrow`,!0);case`M`:return i?a({month:`numeric`},`month`):this.num(t.month);case`MM`:return i?a({month:`2-digit`},`month`):this.num(t.month,2);case`MMM`:return c(`short`,!1);case`MMMM`:return c(`long`,!1);case`MMMMM`:return c(`narrow`,!1);case`y`:return i?a({year:`numeric`},`year`):this.num(t.year);case`yy`:return i?a({year:`2-digit`},`year`):this.num(t.year.toString().slice(-2),2);case`yyyy`:return i?a({year:`numeric`},`year`):this.num(t.year,4);case`yyyyyy`:return i?a({year:`numeric`},`year`):this.num(t.year,6);case`G`:return d(`short`);case`GG`:return d(`long`);case`GGGGG`:return d(`narrow`);case`kk`:return this.num(t.weekYear.toString().slice(-2),2);case`kkkk`:return this.num(t.weekYear,4);case`W`:return this.num(t.weekNumber);case`WW`:return this.num(t.weekNumber,2);case`n`:return this.num(t.localWeekNumber);case`nn`:return this.num(t.localWeekNumber,2);case`ii`:return this.num(t.localWeekYear.toString().slice(-2),2);case`iiii`:return this.num(t.localWeekYear,4);case`o`:return this.num(t.ordinal);case`ooo`:return this.num(t.ordinal,3);case`q`:return this.num(t.quarter);case`qq`:return this.num(t.quarter,2);case`X`:return this.num(Math.floor(t.ts/1e3));case`x`:return this.num(t.ts);default:return u(e)}})}formatDurationFromString(t,n){let r=this.opts.signMode===`negativeLargestOnly`?-1:1,i=e=>{switch(e[0]){case`S`:return`milliseconds`;case`s`:return`seconds`;case`m`:return`minutes`;case`h`:return`hours`;case`d`:return`days`;case`w`:return`weeks`;case`M`:return`months`;case`y`:return`years`;default:return null}},a=(e,t)=>n=>{let a=i(n);if(a){let i=t.isNegativeDuration&&a!==t.largestUnit?r:1,o;return o=this.opts.signMode===`negativeLargestOnly`&&a!==t.largestUnit?`never`:this.opts.signMode===`all`?`always`:`auto`,this.num(e.get(a)*i,n.length,o)}else return n},o=e.parseFormat(n),s=o.reduce((e,{literal:t,val:n})=>t?e:e.concat(n),[]),c=t.shiftTo(...s.map(i).filter(e=>e));return fh(o,a(c,{isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]}))}},hh=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function gh(...e){let t=e.reduce((e,t)=>e+t.source,``);return RegExp(`^${t}$`)}function _h(...e){return t=>e.reduce(([e,n,r],i)=>{let[a,o,s]=i(t,r);return[{...e,...a},o||n,s]},[{},null,1]).slice(0,2)}function vh(e,...t){if(e==null)return[null,null];for(let[n,r]of t){let t=n.exec(e);if(t)return r(t)}return[null,null]}function yh(...e){return(t,n)=>{let r={},i;for(i=0;i<e.length;i++)r[e[i]]=jm(t[n+i]);return[r,null,n+i]}}var bh=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,xh=`(?:${bh.source}?(?:\\[(${hh.source})\\])?)?`,Sh=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Ch=RegExp(`${Sh.source}${xh}`),wh=RegExp(`(?:[Tt]${Ch.source})?`),Th=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,Eh=/(\d{4})-?W(\d\d)(?:-?(\d))?/,Dh=/(\d{4})-?(\d{3})/,Oh=yh(`weekYear`,`weekNumber`,`weekDay`),kh=yh(`year`,`ordinal`),Ah=/(\d{4})-(\d\d)-(\d\d)/,jh=RegExp(`${Sh.source} ?(?:${bh.source}|(${hh.source}))?`),Mh=RegExp(`(?: ${jh.source})?`);function Nh(e,t,n){let r=e[t];return K(r)?n:jm(r)}function Ph(e,t){return[{year:Nh(e,t),month:Nh(e,t+1,1),day:Nh(e,t+2,1)},null,t+3]}function Fh(e,t){return[{hours:Nh(e,t,0),minutes:Nh(e,t+1,0),seconds:Nh(e,t+2,0),milliseconds:Nm(e[t+3])},null,t+4]}function Ih(e,t){let n=!e[t]&&!e[t+1],r=Um(e[t+1],e[t+2]);return[{},n?null:Lp.instance(r),t+3]}function Lh(e,t){return[{},e[t]?dp.create(e[t]):null,t+1]}var Rh=RegExp(`^T?${Sh.source}$`),zh=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function Bh(e){let[t,n,r,i,a,o,s,c,l]=e,u=t[0]===`-`,d=c&&c[0]===`-`,f=(e,t=!1)=>e!==void 0&&(t||e&&u)?-e:e;return[{years:f(Mm(n)),months:f(Mm(r)),weeks:f(Mm(i)),days:f(Mm(a)),hours:f(Mm(o)),minutes:f(Mm(s)),seconds:f(Mm(c),c===`-0`),milliseconds:f(Nm(l),d)}]}var Vh={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Hh(e,t,n,r,i,a,o){let s={year:t.length===2?Vm(jm(t)):jm(t),month:Ym.indexOf(n)+1,day:jm(r),hour:jm(i),minute:jm(a)};return o&&(s.second=jm(o)),e&&(s.weekday=e.length>3?Qm.indexOf(e)+1:$m.indexOf(e)+1),s}var Uh=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function Wh(e){let[,t,n,r,i,a,o,s,c,l,u,d]=e,f=Hh(t,i,r,n,a,o,s),ee;return ee=c?Vh[c]:l?0:Um(u,d),[f,new Lp(ee)]}function Gh(e){return e.replace(/\([^()]*\)|[\n\t]/g,` `).replace(/(\s\s+)/g,` `).trim()}var Kh=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,qh=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,Jh=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function Yh(e){let[,t,n,r,i,a,o,s]=e;return[Hh(t,i,r,n,a,o,s),Lp.utcInstance]}function Xh(e){let[,t,n,r,i,a,o,s]=e;return[Hh(t,s,n,r,i,a,o),Lp.utcInstance]}var Zh=gh(Th,wh),Qh=gh(Eh,wh),$h=gh(Dh,wh),eg=gh(Ch),tg=_h(Ph,Fh,Ih,Lh),ng=_h(Oh,Fh,Ih,Lh),rg=_h(kh,Fh,Ih,Lh),ig=_h(Fh,Ih,Lh);function ag(e){return vh(e,[Zh,tg],[Qh,ng],[$h,rg],[eg,ig])}function og(e){return vh(Gh(e),[Uh,Wh])}function sg(e){return vh(e,[Kh,Yh],[qh,Yh],[Jh,Xh])}function cg(e){return vh(e,[zh,Bh])}var lg=_h(Fh);function ug(e){return vh(e,[Rh,lg])}var dg=gh(Ah,Mh),fg=gh(jh),pg=_h(Fh,Ih,Lh);function mg(e){return vh(e,[dg,tg],[fg,pg])}var hg=`Invalid Duration`,gg={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},_g={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...gg},vg=146097/400,yg=146097/4800,bg={years:{quarters:4,months:12,weeks:vg/7,days:vg,hours:vg*24,minutes:vg*24*60,seconds:vg*24*60*60,milliseconds:vg*24*60*60*1e3},quarters:{months:3,weeks:vg/28,days:vg/4,hours:vg*24/4,minutes:vg*24*60/4,seconds:vg*24*60*60/4,milliseconds:vg*24*60*60*1e3/4},months:{weeks:yg/7,days:yg,hours:yg*24,minutes:yg*24*60,seconds:yg*24*60*60,milliseconds:yg*24*60*60*1e3},...gg},xg=[`years`,`quarters`,`months`,`weeks`,`days`,`hours`,`minutes`,`seconds`,`milliseconds`],Sg=xg.slice(0).reverse();function Cg(e,t,n=!1){return new Dg({values:n?t.values:{...e.values,...t.values||{}},loc:e.loc.clone(t.loc),conversionAccuracy:t.conversionAccuracy||e.conversionAccuracy,matrix:t.matrix||e.matrix})}function wg(e,t){let n=t.milliseconds??0;for(let r of Sg.slice(1))t[r]&&(n+=t[r]*e[r].milliseconds);return n}function Tg(e,t){let n=wg(e,t)<0?-1:1;xg.reduceRight((r,i)=>{if(K(t[i]))return r;if(r){let a=t[r]*n,o=e[i][r],s=Math.floor(a/o);t[i]+=s*n,t[r]-=s*o*n}return i},null),xg.reduce((n,r)=>{if(K(t[r]))return n;if(n){let i=t[n]%1;t[n]-=i,t[r]+=i*e[n][r]}return r},null)}function Eg(e){let t={};for(let[n,r]of Object.entries(e))r!==0&&(t[n]=r);return t}var Dg=class e{constructor(e){let t=e.conversionAccuracy===`longterm`||!1,n=t?bg:_g;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||W.create(),this.conversionAccuracy=t?`longterm`:`casual`,this.invalid=e.invalid||null,this.matrix=n,this.isLuxonDuration=!0}static fromMillis(t,n){return e.fromObject({milliseconds:t},n)}static fromObject(t,n={}){if(typeof t!=`object`||!t)throw new Af(`Duration.fromObject: argument expected to be an object, got ${t===null?`null`:typeof t}`);return new e({values:Gm(t,e.normalizeUnit),loc:W.fromObject(n),conversionAccuracy:n.conversionAccuracy,matrix:n.matrix})}static fromDurationLike(t){if(vm(t))return e.fromMillis(t);if(e.isDuration(t))return t;if(typeof t==`object`)return e.fromObject(t);throw new Af(`Unknown duration argument ${t} of type ${typeof t}`)}static fromISO(t,n){let[r]=cg(t);return r?e.fromObject(r,n):e.invalid(`unparsable`,`the input "${t}" can't be parsed as ISO 8601`)}static fromISOTime(t,n){let[r]=ug(t);return r?e.fromObject(r,n):e.invalid(`unparsable`,`the input "${t}" can't be parsed as ISO 8601`)}static invalid(t,n=null){if(!t)throw new Af(`need to specify a reason the Duration is invalid`);let r=t instanceof tm?t:new tm(t,n);if(G.throwOnInvalid)throw new Df(r);return new e({invalid:r})}static normalizeUnit(e){let t={year:`years`,years:`years`,quarter:`quarters`,quarters:`quarters`,month:`months`,months:`months`,week:`weeks`,weeks:`weeks`,day:`days`,days:`days`,hour:`hours`,hours:`hours`,minute:`minutes`,minutes:`minutes`,second:`seconds`,seconds:`seconds`,millisecond:`milliseconds`,milliseconds:`milliseconds`}[e&&e.toLowerCase()];if(!t)throw new kf(e);return t}static isDuration(e){return e&&e.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,t={}){let n={...t,floor:t.round!==!1&&t.floor!==!1};return this.isValid?mh.create(this.loc,n).formatDurationFromString(this,e):hg}toHuman(e={}){if(!this.isValid)return hg;let t=e.showZeros!==!1,n=xg.map(n=>{let r=this.values[n];return K(r)||r===0&&!t?null:this.loc.numberFormatter({style:`unit`,unitDisplay:`long`,...e,unit:n.slice(0,-1)}).format(r)}).filter(e=>e);return this.loc.listFormatter({type:`conjunction`,style:e.listStyle||`narrow`,...e}).format(n)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e=`P`;return this.years!==0&&(e+=this.years+`Y`),(this.months!==0||this.quarters!==0)&&(e+=this.months+this.quarters*3+`M`),this.weeks!==0&&(e+=this.weeks+`W`),this.days!==0&&(e+=this.days+`D`),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(e+=`T`),this.hours!==0&&(e+=this.hours+`H`),this.minutes!==0&&(e+=this.minutes+`M`),(this.seconds!==0||this.milliseconds!==0)&&(e+=Pm(this.seconds+this.milliseconds/1e3,3)+`S`),e===`P`&&(e+=`T0S`),e}toISOTime(e={}){if(!this.isValid)return null;let t=this.toMillis();return t<0||t>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:`extended`,...e,includeOffset:!1},Y.fromMillis(t,{zone:`UTC`}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?wg(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(t){if(!this.isValid)return this;let n=e.fromDurationLike(t),r={};for(let e of xg)(Dm(n.values,e)||Dm(this.values,e))&&(r[e]=n.get(e)+this.get(e));return Cg(this,{values:r},!0)}minus(t){if(!this.isValid)return this;let n=e.fromDurationLike(t);return this.plus(n.negate())}mapUnits(e){if(!this.isValid)return this;let t={};for(let n of Object.keys(this.values))t[n]=Wm(e(this.values[n],n));return Cg(this,{values:t},!0)}get(t){return this[e.normalizeUnit(t)]}set(t){if(!this.isValid)return this;let n={...this.values,...Gm(t,e.normalizeUnit)};return Cg(this,{values:n})}reconfigure({locale:e,numberingSystem:t,conversionAccuracy:n,matrix:r}={}){let i={loc:this.loc.clone({locale:e,numberingSystem:t}),matrix:r,conversionAccuracy:n};return Cg(this,i)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;let e=this.toObject();return Tg(this.matrix,e),Cg(this,{values:e},!0)}rescale(){if(!this.isValid)return this;let e=Eg(this.normalize().shiftToAll().toObject());return Cg(this,{values:e},!0)}shiftTo(...t){if(!this.isValid||t.length===0)return this;t=t.map(t=>e.normalizeUnit(t));let n={},r={},i=this.toObject(),a;for(let e of xg)if(t.indexOf(e)>=0){a=e;let t=0;for(let n in r)t+=this.matrix[n][e]*r[n],r[n]=0;vm(i[e])&&(t+=i[e]);let o=Math.trunc(t);n[e]=o,r[e]=(t*1e3-o*1e3)/1e3}else vm(i[e])&&(r[e]=i[e]);for(let e in r)r[e]!==0&&(n[a]+=e===a?r[e]:r[e]/this.matrix[a][e]);return Tg(this.matrix,n),Cg(this,{values:n},!0)}shiftToAll(){return this.isValid?this.shiftTo(`years`,`months`,`weeks`,`days`,`hours`,`minutes`,`seconds`,`milliseconds`):this}negate(){if(!this.isValid)return this;let e={};for(let t of Object.keys(this.values))e[t]=this.values[t]===0?0:-this.values[t];return Cg(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;let e=Eg(this.values);return Cg(this,{values:e},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid||!this.loc.equals(e.loc))return!1;function t(e,t){return e===void 0||e===0?t===void 0||t===0:e===t}for(let n of xg)if(!t(this.values[n],e.values[n]))return!1;return!0}},Og=`Invalid Interval`;function kg(e,t){return!e||!e.isValid?Ag.invalid(`missing or invalid start`):!t||!t.isValid?Ag.invalid(`missing or invalid end`):t<e?Ag.invalid(`end before start`,`The end of an interval must be after its start, but you had start=${e.toISO()} and end=${t.toISO()}`):null}var Ag=class e{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(t,n=null){if(!t)throw new Af(`need to specify a reason the Interval is invalid`);let r=t instanceof tm?t:new tm(t,n);if(G.throwOnInvalid)throw new Ef(r);return new e({invalid:r})}static fromDateTimes(t,n){let r=M_(t),i=M_(n);return kg(r,i)??new e({start:r,end:i})}static after(t,n){let r=Dg.fromDurationLike(n),i=M_(t);return e.fromDateTimes(i,i.plus(r))}static before(t,n){let r=Dg.fromDurationLike(n),i=M_(t);return e.fromDateTimes(i.minus(r),i)}static fromISO(t,n){let[r,i]=(t||``).split(`/`,2);if(r&&i){let t,a;try{t=Y.fromISO(r,n),a=t.isValid}catch{a=!1}let o,s;try{o=Y.fromISO(i,n),s=o.isValid}catch{s=!1}if(a&&s)return e.fromDateTimes(t,o);if(a){let r=Dg.fromISO(i,n);if(r.isValid)return e.after(t,r)}else if(s){let t=Dg.fromISO(r,n);if(t.isValid)return e.before(o,t)}}return e.invalid(`unparsable`,`the input "${t}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e=`milliseconds`){return this.isValid?this.toDuration(e).get(e):NaN}count(e=`milliseconds`,t){if(!this.isValid)return NaN;let n=this.start.startOf(e,t),r;return r=t?.useLocaleWeeks?this.end.reconfigure({locale:n.locale}):this.end,r=r.startOf(e,t),Math.floor(r.diff(n,e).get(e))+(r.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return this.isValid?this.s>e:!1}isBefore(e){return this.isValid?this.e<=e:!1}contains(e){return this.isValid?this.s<=e&&this.e>e:!1}set({start:t,end:n}={}){return this.isValid?e.fromDateTimes(t||this.s,n||this.e):this}splitAt(...t){if(!this.isValid)return[];let n=t.map(M_).filter(e=>this.contains(e)).sort((e,t)=>e.toMillis()-t.toMillis()),r=[],{s:i}=this,a=0;for(;i<this.e;){let t=n[a]||this.e,o=+t>+this.e?this.e:t;r.push(e.fromDateTimes(i,o)),i=o,a+=1}return r}splitBy(t){let n=Dg.fromDurationLike(t);if(!this.isValid||!n.isValid||n.as(`milliseconds`)===0)return[];let{s:r}=this,i=1,a,o=[];for(;r<this.e;){let t=this.start.plus(n.mapUnits(e=>e*i));a=+t>+this.e?this.e:t,o.push(e.fromDateTimes(r,a)),r=a,i+=1}return o}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(t){if(!this.isValid)return this;let n=this.s>t.s?this.s:t.s,r=this.e<t.e?this.e:t.e;return n>=r?null:e.fromDateTimes(n,r)}union(t){if(!this.isValid)return this;let n=this.s<t.s?this.s:t.s,r=this.e>t.e?this.e:t.e;return e.fromDateTimes(n,r)}static merge(e){let[t,n]=e.sort((e,t)=>e.s-t.s).reduce(([e,t],n)=>t?t.overlaps(n)||t.abutsStart(n)?[e,t.union(n)]:[e.concat([t]),n]:[e,n],[[],null]);return n&&t.push(n),t}static xor(t){let n=null,r=0,i=[],a=t.map(e=>[{time:e.s,type:`s`},{time:e.e,type:`e`}]),o=Array.prototype.concat(...a).sort((e,t)=>e.time-t.time);for(let t of o)r+=t.type===`s`?1:-1,r===1?n=t.time:(n&&+n!=+t.time&&i.push(e.fromDateTimes(n,t.time)),n=null);return e.merge(i)}difference(...t){return e.xor([this].concat(t)).map(e=>this.intersection(e)).filter(e=>e&&!e.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:Og}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(e=Pf,t={}){return this.isValid?mh.create(this.s.loc.clone(t),e).formatInterval(this):Og}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:Og}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:Og}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:Og}toFormat(e,{separator:t=` – `}={}){return this.isValid?`${this.s.toFormat(e)}${t}${this.e.toFormat(e)}`:Og}toDuration(e,t){return this.isValid?this.e.diff(this.s,e,t):Dg.invalid(this.invalidReason)}mapEndpoints(t){return e.fromDateTimes(t(this.s),t(this.e))}},jg=class{static hasDST(e=G.defaultZone){let t=Y.now().setZone(e).set({month:12});return!e.isUniversal&&t.offset!==t.set({month:6}).offset}static isValidIANAZone(e){return dp.isValidZone(e)}static normalizeZone(e){return zp(e,G.defaultZone)}static getStartOfWeek({locale:e=null,locObj:t=null}={}){return(t||W.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:t=null}={}){return(t||W.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:t=null}={}){return(t||W.create(e)).getWeekendDays().slice()}static months(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i=`gregory`}={}){return(r||W.create(t,n,i)).months(e)}static monthsFormat(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i=`gregory`}={}){return(r||W.create(t,n,i)).months(e,!0)}static weekdays(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||W.create(t,n,null)).weekdays(e)}static weekdaysFormat(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||W.create(t,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return W.create(e).meridiems()}static eras(e=`short`,{locale:t=null}={}){return W.create(t,null,`gregory`).eras(e)}static features(){return{relative:Sm(),localeWeek:Cm()}}};function Mg(e,t){let n=e=>e.toUTC(0,{keepLocalTime:!0}).startOf(`day`).valueOf(),r=n(t)-n(e);return Math.floor(Dg.fromMillis(r).as(`days`))}function Ng(e,t,n){let r=[[`years`,(e,t)=>t.year-e.year],[`quarters`,(e,t)=>t.quarter-e.quarter+(t.year-e.year)*4],[`months`,(e,t)=>t.month-e.month+(t.year-e.year)*12],[`weeks`,(e,t)=>{let n=Mg(e,t);return(n-n%7)/7}],[`days`,Mg]],i={},a=e,o,s;for(let[c,l]of r)n.indexOf(c)>=0&&(o=c,i[c]=l(e,t),s=a.plus(i),s>t?(i[c]--,e=a.plus(i),e>t&&(s=e,i[c]--,e=a.plus(i))):e=s);return[e,i,s,o]}function Pg(e,t,n,r){let[i,a,o,s]=Ng(e,t,n),c=t-i,l=n.filter(e=>[`hours`,`minutes`,`seconds`,`milliseconds`].indexOf(e)>=0);l.length===0&&(o<t&&(o=i.plus({[s]:1})),o!==i&&(a[s]=(a[s]||0)+c/(o-i)));let u=Dg.fromObject(a,r);return l.length>0?Dg.fromMillis(c,r).shiftTo(...l).plus(u):u}var Fg=`missing Intl.DateTimeFormat.formatToParts support`;function J(e,t=e=>e){return{regex:e,deser:([e])=>t(Up(e))}}var Ig=`[ \xA0]`,Lg=new RegExp(Ig,`g`);function Rg(e){return e.replace(/\./g,`\\.?`).replace(Lg,Ig)}function zg(e){return e.replace(/\./g,``).replace(Lg,` `).toLowerCase()}function Bg(e,t){return e===null?null:{regex:RegExp(e.map(Rg).join(`|`)),deser:([n])=>e.findIndex(e=>zg(n)===zg(e))+t}}function Vg(e,t){return{regex:e,deser:([,e,t])=>Um(e,t),groups:t}}function Hg(e){return{regex:e,deser:([e])=>e}}function Ug(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,`\\$&`)}function Wg(e,t){let n=Kp(t),r=Kp(t,`{2}`),i=Kp(t,`{3}`),a=Kp(t,`{4}`),o=Kp(t,`{6}`),s=Kp(t,`{1,2}`),c=Kp(t,`{1,3}`),l=Kp(t,`{1,6}`),u=Kp(t,`{1,9}`),d=Kp(t,`{2,4}`),f=Kp(t,`{4,6}`),ee=e=>({regex:RegExp(Ug(e.val)),deser:([e])=>e,literal:!0}),p=(p=>{if(e.literal)return ee(p);switch(p.val){case`G`:return Bg(t.eras(`short`),0);case`GG`:return Bg(t.eras(`long`),0);case`y`:return J(l);case`yy`:return J(d,Vm);case`yyyy`:return J(a);case`yyyyy`:return J(f);case`yyyyyy`:return J(o);case`M`:return J(s);case`MM`:return J(r);case`MMM`:return Bg(t.months(`short`,!0),1);case`MMMM`:return Bg(t.months(`long`,!0),1);case`L`:return J(s);case`LL`:return J(r);case`LLL`:return Bg(t.months(`short`,!1),1);case`LLLL`:return Bg(t.months(`long`,!1),1);case`d`:return J(s);case`dd`:return J(r);case`o`:return J(c);case`ooo`:return J(i);case`HH`:return J(r);case`H`:return J(s);case`hh`:return J(r);case`h`:return J(s);case`mm`:return J(r);case`m`:return J(s);case`q`:return J(s);case`qq`:return J(r);case`s`:return J(s);case`ss`:return J(r);case`S`:return J(c);case`SSS`:return J(i);case`u`:return Hg(u);case`uu`:return Hg(s);case`uuu`:return J(n);case`a`:return Bg(t.meridiems(),0);case`kkkk`:return J(a);case`kk`:return J(d,Vm);case`W`:return J(s);case`WW`:return J(r);case`E`:case`c`:return J(n);case`EEE`:return Bg(t.weekdays(`short`,!1),1);case`EEEE`:return Bg(t.weekdays(`long`,!1),1);case`ccc`:return Bg(t.weekdays(`short`,!0),1);case`cccc`:return Bg(t.weekdays(`long`,!0),1);case`Z`:case`ZZ`:return Vg(RegExp(`([+-]${s.source})(?::(${r.source}))?`),2);case`ZZZ`:return Vg(RegExp(`([+-]${s.source})(${r.source})?`),2);case`z`:return Hg(/[a-z_+-/]{1,256}?/i);case` `:return Hg(/[^\S\n\r]/);default:return ee(p)}})(e)||{invalidReason:Fg};return p.token=e,p}var Gg={year:{"2-digit":`yy`,numeric:`yyyyy`},month:{numeric:`M`,"2-digit":`MM`,short:`MMM`,long:`MMMM`},day:{numeric:`d`,"2-digit":`dd`},weekday:{short:`EEE`,long:`EEEE`},dayperiod:`a`,dayPeriod:`a`,hour12:{numeric:`h`,"2-digit":`hh`},hour24:{numeric:`H`,"2-digit":`HH`},minute:{numeric:`m`,"2-digit":`mm`},second:{numeric:`s`,"2-digit":`ss`},timeZoneName:{long:`ZZZZZ`,short:`ZZZ`}};function Kg(e,t,n){let{type:r,value:i}=e;if(r===`literal`){let e=/^\s+$/.test(i);return{literal:!e,val:e?` `:i}}let a=t[r],o=r;r===`hour`&&(o=t.hour12==null?t.hourCycle==null?n.hour12?`hour12`:`hour24`:t.hourCycle===`h11`||t.hourCycle===`h12`?`hour12`:`hour24`:t.hour12?`hour12`:`hour24`);let s=Gg[o];if(typeof s==`object`&&(s=s[a]),s)return{literal:!1,val:s}}function qg(e){return[`^${e.map(e=>e.regex).reduce((e,t)=>`${e}(${t.source})`,``)}$`,e]}function Jg(e,t,n){let r=e.match(t);if(r){let e={},t=1;for(let i in n)if(Dm(n,i)){let a=n[i],o=a.groups?a.groups+1:1;!a.literal&&a.token&&(e[a.token.val[0]]=a.deser(r.slice(t,t+o))),t+=o}return[r,e]}else return[r,{}]}function Yg(e){let t=e=>{switch(e){case`S`:return`millisecond`;case`s`:return`second`;case`m`:return`minute`;case`h`:case`H`:return`hour`;case`d`:return`day`;case`o`:return`ordinal`;case`L`:case`M`:return`month`;case`y`:return`year`;case`E`:case`c`:return`weekday`;case`W`:return`weekNumber`;case`k`:return`weekYear`;case`q`:return`quarter`;default:return null}},n=null,r;return K(e.z)||(n=dp.create(e.z)),K(e.Z)||(n||=new Lp(e.Z),r=e.Z),K(e.q)||(e.M=(e.q-1)*3+1),K(e.h)||(e.h<12&&e.a===1?e.h+=12:e.h===12&&e.a===0&&(e.h=0)),e.G===0&&e.y&&(e.y=-e.y),K(e.u)||(e.S=Nm(e.u)),[Object.keys(e).reduce((n,r)=>{let i=t(r);return i&&(n[i]=e[r]),n},{}),n,r]}var Xg=null;function Zg(){return Xg||=Y.fromMillis(1555555555555),Xg}function Qg(e,t){if(e.literal)return e;let n=r_(mh.macroTokenToFormatOpts(e.val),t);return n==null||n.includes(void 0)?e:n}function $g(e,t){return Array.prototype.concat(...e.map(e=>Qg(e,t)))}var e_=class{constructor(e,t){if(this.locale=e,this.format=t,this.tokens=$g(mh.parseFormat(t),e),this.units=this.tokens.map(t=>Wg(t,e)),this.disqualifyingUnit=this.units.find(e=>e.invalidReason),!this.disqualifyingUnit){let[e,t]=qg(this.units);this.regex=RegExp(e,`i`),this.handlers=t}}explainFromTokens(e){if(this.isValid){let[t,n]=Jg(e,this.regex,this.handlers),[r,i,a]=n?Yg(n):[null,null,void 0];if(Dm(n,`a`)&&Dm(n,`H`))throw new Of(`Can't include meridiem when specifying 24-hour format`);return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:t,matches:n,result:r,zone:i,specificOffset:a}}else return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}};function t_(e,t,n){return new e_(e,n).explainFromTokens(t)}function n_(e,t,n){let{result:r,zone:i,specificOffset:a,invalidReason:o}=t_(e,t,n);return[r,i,a,o]}function r_(e,t){if(!e)return null;let n=mh.create(t,e).dtFormatter(Zg()),r=n.formatToParts(),i=n.resolvedOptions();return r.map(t=>Kg(t,e,i))}var i_=`Invalid DateTime`,a_=864e13;function o_(e){return new tm(`unsupported zone`,`the zone "${e.name}" is not supported`)}function s_(e){return e.weekData===null&&(e.weekData=lm(e.c)),e.weekData}function c_(e){return e.localWeekData===null&&(e.localWeekData=lm(e.c,e.loc.getMinDaysInFirstWeek(),e.loc.getStartOfWeek())),e.localWeekData}function l_(e,t){let n={ts:e.ts,zone:e.zone,c:e.c,o:e.o,loc:e.loc,invalid:e.invalid};return new Y({...n,...t,old:n})}function u_(e,t,n){let r=e-t*60*1e3,i=n.offset(r);if(t===i)return[r,t];r-=(i-t)*60*1e3;let a=n.offset(r);return i===a?[r,i]:[e-Math.min(i,a)*60*1e3,Math.max(i,a)]}function d_(e,t){e+=t*60*1e3;let n=new Date(e);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),millisecond:n.getUTCMilliseconds()}}function f_(e,t,n){return u_(Rm(e),t,n)}function p_(e,t){let n=e.o,r=e.c.year+Math.trunc(t.years),i=e.c.month+Math.trunc(t.months)+Math.trunc(t.quarters)*3,a={...e.c,year:r,month:i,day:Math.min(e.c.day,Lm(r,i))+Math.trunc(t.days)+Math.trunc(t.weeks)*7},o=Dg.fromObject({years:t.years-Math.trunc(t.years),quarters:t.quarters-Math.trunc(t.quarters),months:t.months-Math.trunc(t.months),weeks:t.weeks-Math.trunc(t.weeks),days:t.days-Math.trunc(t.days),hours:t.hours,minutes:t.minutes,seconds:t.seconds,milliseconds:t.milliseconds}).as(`milliseconds`),[s,c]=u_(Rm(a),n,e.zone);return o!==0&&(s+=o,c=e.zone.offset(s)),{ts:s,o:c}}function m_(e,t,n,r,i,a){let{setZone:o,zone:s}=n;if(e&&Object.keys(e).length!==0||t){let r=t||s,i=Y.fromObject(e,{...n,zone:r,specificOffset:a});return o?i:i.setZone(s)}else return Y.invalid(new tm(`unparsable`,`the input "${i}" can't be parsed as ${r}`))}function h_(e,t,n=!0){return e.isValid?mh.create(W.create(`en-US`),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(e,t):null}function g_(e,t,n){let r=e.c.year>9999||e.c.year<0,i=``;if(r&&e.c.year>=0&&(i+=`+`),i+=q(e.c.year,r?6:4),n===`year`)return i;if(t){if(i+=`-`,i+=q(e.c.month),n===`month`)return i;i+=`-`}else if(i+=q(e.c.month),n===`month`)return i;return i+=q(e.c.day),i}function __(e,t,n,r,i,a,o){let s=!n||e.c.millisecond!==0||e.c.second!==0,c=``;switch(o){case`day`:case`month`:case`year`:break;default:if(c+=q(e.c.hour),o===`hour`)break;if(t){if(c+=`:`,c+=q(e.c.minute),o===`minute`)break;s&&(c+=`:`,c+=q(e.c.second))}else{if(c+=q(e.c.minute),o===`minute`)break;s&&(c+=q(e.c.second))}if(o===`second`)break;s&&(!r||e.c.millisecond!==0)&&(c+=`.`,c+=q(e.c.millisecond,3))}return i&&(e.isOffsetFixed&&e.offset===0&&!a?c+=`Z`:e.o<0?(c+=`-`,c+=q(Math.trunc(-e.o/60)),c+=`:`,c+=q(Math.trunc(-e.o%60))):(c+=`+`,c+=q(Math.trunc(e.o/60)),c+=`:`,c+=q(Math.trunc(e.o%60)))),a&&(c+=`[`+e.zone.ianaName+`]`),c}var v_={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},y_={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},b_={ordinal:1,hour:0,minute:0,second:0,millisecond:0},x_=[`year`,`month`,`day`,`hour`,`minute`,`second`,`millisecond`],S_=[`weekYear`,`weekNumber`,`weekday`,`hour`,`minute`,`second`,`millisecond`],C_=[`year`,`ordinal`,`hour`,`minute`,`second`,`millisecond`];function w_(e){let t={year:`year`,years:`year`,month:`month`,months:`month`,day:`day`,days:`day`,hour:`hour`,hours:`hour`,minute:`minute`,minutes:`minute`,quarter:`quarter`,quarters:`quarter`,second:`second`,seconds:`second`,millisecond:`millisecond`,milliseconds:`millisecond`,weekday:`weekday`,weekdays:`weekday`,weeknumber:`weekNumber`,weeksnumber:`weekNumber`,weeknumbers:`weekNumber`,weekyear:`weekYear`,weekyears:`weekYear`,ordinal:`ordinal`}[e.toLowerCase()];if(!t)throw new kf(e);return t}function T_(e){switch(e.toLowerCase()){case`localweekday`:case`localweekdays`:return`localWeekday`;case`localweeknumber`:case`localweeknumbers`:return`localWeekNumber`;case`localweekyear`:case`localweekyears`:return`localWeekYear`;default:return w_(e)}}function E_(e){if(A_===void 0&&(A_=G.now()),e.type!==`iana`)return e.offset(A_);let t=e.name,n=j_.get(t);return n===void 0&&(n=e.offset(A_),j_.set(t,n)),n}function D_(e,t){let n=zp(t.zone,G.defaultZone);if(!n.isValid)return Y.invalid(o_(n));let r=W.fromObject(t),i,a;if(K(e.year))i=G.now();else{for(let t of x_)K(e[t])&&(e[t]=v_[t]);let t=gm(e)||_m(e);if(t)return Y.invalid(t);let r=E_(n);[i,a]=f_(e,r,n)}return new Y({ts:i,zone:n,loc:r,o:a})}function O_(e,t,n){let r=K(n.round)?!0:n.round,i=K(n.rounding)?`trunc`:n.rounding,a=(e,a)=>(e=Pm(e,r||n.calendary?0:2,n.calendary?`round`:i),t.loc.clone(n).relFormatter(n).format(e,a)),o=r=>n.calendary?t.hasSame(e,r)?0:t.startOf(r).diff(e.startOf(r),r).get(r):t.diff(e,r).get(r);if(n.unit)return a(o(n.unit),n.unit);for(let e of n.units){let t=o(e);if(Math.abs(t)>=1)return a(t,e)}return a(e>t?-0:0,n.units[n.units.length-1])}function k_(e){let t={},n;return e.length>0&&typeof e[e.length-1]==`object`?(t=e[e.length-1],n=Array.from(e).slice(0,e.length-1)):n=Array.from(e),[t,n]}var A_,j_=new Map,Y=class e{constructor(e){let t=e.zone||G.defaultZone,n=e.invalid||(Number.isNaN(e.ts)?new tm(`invalid input`):null)||(t.isValid?null:o_(t));this.ts=K(e.ts)?G.now():e.ts;let r=null,i=null;if(!n)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(t))[r,i]=[e.old.c,e.old.o];else{let a=vm(e.o)&&!e.old?e.o:t.offset(this.ts);r=d_(this.ts,a),n=Number.isNaN(r.year)?new tm(`invalid input`):null,r=n?null:r,i=n?null:a}this._zone=t,this.loc=e.loc||W.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=i,this.isLuxonDateTime=!0}static now(){return new e({})}static local(){let[e,t]=k_(arguments),[n,r,i,a,o,s,c]=t;return D_({year:n,month:r,day:i,hour:a,minute:o,second:s,millisecond:c},e)}static utc(){let[e,t]=k_(arguments),[n,r,i,a,o,s,c]=t;return e.zone=Lp.utcInstance,D_({year:n,month:r,day:i,hour:a,minute:o,second:s,millisecond:c},e)}static fromJSDate(t,n={}){let r=xm(t)?t.valueOf():NaN;if(Number.isNaN(r))return e.invalid(`invalid input`);let i=zp(n.zone,G.defaultZone);return i.isValid?new e({ts:r,zone:i,loc:W.fromObject(n)}):e.invalid(o_(i))}static fromMillis(t,n={}){if(vm(t))return t<-a_||t>a_?e.invalid(`Timestamp out of range`):new e({ts:t,zone:zp(n.zone,G.defaultZone),loc:W.fromObject(n)});throw new Af(`fromMillis requires a numerical input, but received a ${typeof t} with value ${t}`)}static fromSeconds(t,n={}){if(vm(t))return new e({ts:t*1e3,zone:zp(n.zone,G.defaultZone),loc:W.fromObject(n)});throw new Af(`fromSeconds requires a numerical input`)}static fromObject(t,n={}){t||={};let r=zp(n.zone,G.defaultZone);if(!r.isValid)return e.invalid(o_(r));let i=W.fromObject(n),a=Gm(t,T_),{minDaysInFirstWeek:o,startOfWeek:s}=pm(a,i),c=G.now(),l=K(n.specificOffset)?r.offset(c):n.specificOffset,u=!K(a.ordinal),d=!K(a.year),f=!K(a.month)||!K(a.day),ee=d||f,p=a.weekYear||a.weekNumber;if((ee||u)&&p)throw new Of(`Can't mix weekYear/weekNumber units with year/month/day or ordinals`);if(f&&u)throw new Of(`Can't mix ordinal dates with month/day`);let te=p||a.weekday&&!ee,ne,re,ie=d_(c,l);te?(ne=S_,re=y_,ie=lm(ie,o,s)):u?(ne=C_,re=b_,ie=dm(ie)):(ne=x_,re=v_);let ae=!1;for(let e of ne){let t=a[e];K(t)?ae?a[e]=re[e]:a[e]=ie[e]:ae=!0}let oe=(te?mm(a,o,s):u?hm(a):gm(a))||_m(a);if(oe)return e.invalid(oe);let[se,ce]=f_(te?um(a,o,s):u?fm(a):a,l,r),le=new e({ts:se,zone:r,o:ce,loc:i});return a.weekday&&ee&&t.weekday!==le.weekday?e.invalid(`mismatched weekday`,`you can't specify both a weekday of ${a.weekday} and a date of ${le.toISO()}`):le.isValid?le:e.invalid(le.invalid)}static fromISO(e,t={}){let[n,r]=ag(e);return m_(n,r,t,`ISO 8601`,e)}static fromRFC2822(e,t={}){let[n,r]=og(e);return m_(n,r,t,`RFC 2822`,e)}static fromHTTP(e,t={}){let[n,r]=sg(e);return m_(n,r,t,`HTTP`,t)}static fromFormat(t,n,r={}){if(K(t)||K(n))throw new Af(`fromFormat requires an input string and a format`);let{locale:i=null,numberingSystem:a=null}=r,[o,s,c,l]=n_(W.fromOpts({locale:i,numberingSystem:a,defaultToEN:!0}),t,n);return l?e.invalid(l):m_(o,s,r,`format ${n}`,t,c)}static fromString(t,n,r={}){return e.fromFormat(t,n,r)}static fromSQL(e,t={}){let[n,r]=mg(e);return m_(n,r,t,`SQL`,e)}static invalid(t,n=null){if(!t)throw new Af(`need to specify a reason the DateTime is invalid`);let r=t instanceof tm?t:new tm(t,n);if(G.throwOnInvalid)throw new Tf(r);return new e({invalid:r})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,t={}){let n=r_(e,W.fromObject(t));return n?n.map(e=>e?e.val:null).join(``):null}static expandFormat(e,t={}){return $g(mh.parseFormat(e),W.fromObject(t)).map(e=>e.val).join(``)}static resetCache(){A_=void 0,j_.clear()}get(e){return this[e]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?s_(this).weekYear:NaN}get weekNumber(){return this.isValid?s_(this).weekNumber:NaN}get weekday(){return this.isValid?s_(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?c_(this).weekday:NaN}get localWeekNumber(){return this.isValid?c_(this).weekNumber:NaN}get localWeekYear(){return this.isValid?c_(this).weekYear:NaN}get ordinal(){return this.isValid?dm(this.c).ordinal:NaN}get monthShort(){return this.isValid?jg.months(`short`,{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?jg.months(`long`,{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?jg.weekdays(`short`,{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?jg.weekdays(`long`,{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:`short`,locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:`long`,locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];let e=864e5,t=6e4,n=Rm(this.c),r=this.zone.offset(n-e),i=this.zone.offset(n+e),a=this.zone.offset(n-r*t),o=this.zone.offset(n-i*t);if(a===o)return[this];let s=n-a*t,c=n-o*t,l=d_(s,a),u=d_(c,o);return l.hour===u.hour&&l.minute===u.minute&&l.second===u.second&&l.millisecond===u.millisecond?[l_(this,{ts:s}),l_(this,{ts:c})]:[this]}get isInLeapYear(){return Fm(this.year)}get daysInMonth(){return Lm(this.year,this.month)}get daysInYear(){return this.isValid?Im(this.year):NaN}get weeksInWeekYear(){return this.isValid?Bm(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Bm(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){let{locale:t,numberingSystem:n,calendar:r}=mh.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:t,numberingSystem:n,outputCalendar:r}}toUTC(e=0,t={}){return this.setZone(Lp.instance(e),t)}toLocal(){return this.setZone(G.defaultZone)}setZone(t,{keepLocalTime:n=!1,keepCalendarTime:r=!1}={}){if(t=zp(t,G.defaultZone),t.equals(this.zone))return this;if(t.isValid){let e=this.ts;if(n||r){let n=t.offset(this.ts),r=this.toObject();[e]=f_(r,n,t)}return l_(this,{ts:e,zone:t})}else return e.invalid(o_(t))}reconfigure({locale:e,numberingSystem:t,outputCalendar:n}={}){let r=this.loc.clone({locale:e,numberingSystem:t,outputCalendar:n});return l_(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;let t=Gm(e,T_),{minDaysInFirstWeek:n,startOfWeek:r}=pm(t,this.loc),i=!K(t.weekYear)||!K(t.weekNumber)||!K(t.weekday),a=!K(t.ordinal),o=!K(t.year),s=!K(t.month)||!K(t.day),c=o||s,l=t.weekYear||t.weekNumber;if((c||a)&&l)throw new Of(`Can't mix weekYear/weekNumber units with year/month/day or ordinals`);if(s&&a)throw new Of(`Can't mix ordinal dates with month/day`);let u;i?u=um({...lm(this.c,n,r),...t},n,r):K(t.ordinal)?(u={...this.toObject(),...t},K(t.day)&&(u.day=Math.min(Lm(u.year,u.month),u.day))):u=fm({...dm(this.c),...t});let[d,f]=f_(u,this.o,this.zone);return l_(this,{ts:d,o:f})}plus(e){if(!this.isValid)return this;let t=Dg.fromDurationLike(e);return l_(this,p_(this,t))}minus(e){if(!this.isValid)return this;let t=Dg.fromDurationLike(e).negate();return l_(this,p_(this,t))}startOf(e,{useLocaleWeeks:t=!1}={}){if(!this.isValid)return this;let n={},r=Dg.normalizeUnit(e);switch(r){case`years`:n.month=1;case`quarters`:case`months`:n.day=1;case`weeks`:case`days`:n.hour=0;case`hours`:n.minute=0;case`minutes`:n.second=0;case`seconds`:n.millisecond=0;break}if(r===`weeks`)if(t){let e=this.loc.getStartOfWeek(),{weekday:t}=this;t<e&&(n.weekNumber=this.weekNumber-1),n.weekday=e}else n.weekday=1;return r===`quarters`&&(n.month=(Math.ceil(this.month/3)-1)*3+1),this.set(n)}endOf(e,t){return this.isValid?this.plus({[e]:1}).startOf(e,t).minus(1):this}toFormat(e,t={}){return this.isValid?mh.create(this.loc.redefaultToEN(t)).formatDateTimeFromString(this,e):i_}toLocaleString(e=Pf,t={}){return this.isValid?mh.create(this.loc.clone(t),e).formatDateTime(this):i_}toLocaleParts(e={}){return this.isValid?mh.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e=`extended`,suppressSeconds:t=!1,suppressMilliseconds:n=!1,includeOffset:r=!0,extendedZone:i=!1,precision:a=`milliseconds`}={}){if(!this.isValid)return null;a=w_(a);let o=e===`extended`,s=g_(this,o,a);return x_.indexOf(a)>=3&&(s+=`T`),s+=__(this,o,t,n,r,i,a),s}toISODate({format:e=`extended`,precision:t=`day`}={}){return this.isValid?g_(this,e===`extended`,w_(t)):null}toISOWeekDate(){return h_(this,`kkkk-'W'WW-c`)}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:t=!1,includeOffset:n=!0,includePrefix:r=!1,extendedZone:i=!1,format:a=`extended`,precision:o=`milliseconds`}={}){return this.isValid?(o=w_(o),(r&&x_.indexOf(o)>=3?`T`:``)+__(this,a===`extended`,t,e,n,i,o)):null}toRFC2822(){return h_(this,`EEE, dd LLL yyyy HH:mm:ss ZZZ`,!1)}toHTTP(){return h_(this.toUTC(),`EEE, dd LLL yyyy HH:mm:ss 'GMT'`)}toSQLDate(){return this.isValid?g_(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:t=!1,includeOffsetSpace:n=!0}={}){let r=`HH:mm:ss.SSS`;return(t||e)&&(n&&(r+=` `),t?r+=`z`:e&&(r+=`ZZ`)),h_(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():i_}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};let t={...this.c};return e.includeConfig&&(t.outputCalendar=this.outputCalendar,t.numberingSystem=this.loc.numberingSystem,t.locale=this.loc.locale),t}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,t=`milliseconds`,n={}){if(!this.isValid||!e.isValid)return Dg.invalid(`created by diffing an invalid DateTime`);let r={locale:this.locale,numberingSystem:this.numberingSystem,...n},i=wm(t).map(Dg.normalizeUnit),a=e.valueOf()>this.valueOf(),o=Pg(a?this:e,a?e:this,i,r);return a?o.negate():o}diffNow(t=`milliseconds`,n={}){return this.diff(e.now(),t,n)}until(e){return this.isValid?Ag.fromDateTimes(this,e):this}hasSame(e,t,n){if(!this.isValid)return!1;let r=e.valueOf(),i=this.setZone(e.zone,{keepLocalTime:!0});return i.startOf(t,n)<=r&&r<=i.endOf(t,n)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(t={}){if(!this.isValid)return null;let n=t.base||e.fromObject({},{zone:this.zone}),r=t.padding?this<n?-t.padding:t.padding:0,i=[`years`,`months`,`days`,`hours`,`minutes`,`seconds`],a=t.unit;return Array.isArray(t.unit)&&(i=t.unit,a=void 0),O_(n,this.plus(r),{...t,numeric:`always`,units:i,unit:a})}toRelativeCalendar(t={}){return this.isValid?O_(t.base||e.fromObject({},{zone:this.zone}),this,{...t,numeric:`auto`,units:[`years`,`months`,`days`],calendary:!0}):null}static min(...t){if(!t.every(e.isDateTime))throw new Af(`min requires all arguments be DateTimes`);return Tm(t,e=>e.valueOf(),Math.min)}static max(...t){if(!t.every(e.isDateTime))throw new Af(`max requires all arguments be DateTimes`);return Tm(t,e=>e.valueOf(),Math.max)}static fromFormatExplain(e,t,n={}){let{locale:r=null,numberingSystem:i=null}=n;return t_(W.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0}),e,t)}static fromStringExplain(t,n,r={}){return e.fromFormatExplain(t,n,r)}static buildFormatParser(e,t={}){let{locale:n=null,numberingSystem:r=null}=t;return new e_(W.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0}),e)}static fromFormatParser(t,n,r={}){if(K(t)||K(n))throw new Af(`fromFormatParser requires an input string and a format parser`);let{locale:i=null,numberingSystem:a=null}=r,o=W.fromOpts({locale:i,numberingSystem:a,defaultToEN:!0});if(!o.equals(n.locale))throw new Af(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${n.locale}`);let{result:s,zone:c,specificOffset:l,invalidReason:u}=n.explainFromTokens(t);return u?e.invalid(u):m_(s,c,r,`format ${n.format}`,t,l)}static get DATE_SHORT(){return Pf}static get DATE_MED(){return Ff}static get DATE_MED_WITH_WEEKDAY(){return If}static get DATE_FULL(){return Lf}static get DATE_HUGE(){return Rf}static get TIME_SIMPLE(){return zf}static get TIME_WITH_SECONDS(){return Bf}static get TIME_WITH_SHORT_OFFSET(){return Vf}static get TIME_WITH_LONG_OFFSET(){return Hf}static get TIME_24_SIMPLE(){return Uf}static get TIME_24_WITH_SECONDS(){return Wf}static get TIME_24_WITH_SHORT_OFFSET(){return Gf}static get TIME_24_WITH_LONG_OFFSET(){return Kf}static get DATETIME_SHORT(){return qf}static get DATETIME_SHORT_WITH_SECONDS(){return Jf}static get DATETIME_MED(){return Yf}static get DATETIME_MED_WITH_SECONDS(){return Xf}static get DATETIME_MED_WITH_WEEKDAY(){return Zf}static get DATETIME_FULL(){return Qf}static get DATETIME_FULL_WITH_SECONDS(){return $f}static get DATETIME_HUGE(){return ep}static get DATETIME_HUGE_WITH_SECONDS(){return tp}};function M_(e){if(Y.isDateTime(e))return e;if(e&&e.valueOf&&vm(e.valueOf()))return Y.fromJSDate(e);if(e&&typeof e==`object`)return Y.fromObject(e);throw new Af(`Unknown datetime argument: ${e}, of type ${typeof e}`)}function N_(e){return ed(e)?e.expression.variable?.value?.toLowerCase()===`null`:e instanceof _l}function P_(e){return L(e).unwrap_or(void 0)===``}function F_(e){return e instanceof ll}function I_(e){let t=zu(e);if(t!==null)return t;if(ju(e)&&e instanceof ol&&e.expression){let t=e.op?.value,n=zu(e.expression);if(n!==null)return t===`-`?-n:n}return null}function L_(e){if(e==null)return null;if(typeof e==`number`)return e;if(typeof e==`string`){let t=Number(e);return isNaN(t)?null:t}if(typeof e==`boolean`)return e?1:0;let t=I_(e);if(t!==null)return t;let n=L(e).unwrap_or(void 0);if(n!==void 0){let e=Number(n);if(!isNaN(e))return e}return null}function R_(e){if(e==null)return null;if(typeof e==`number`)return Number.isInteger(e)?e:null;if(typeof e==`string`){let t=Number(e);return isNaN(t)||!Number.isInteger(t)?null:t}if(typeof e==`boolean`)return e?1:0;let t=I_(e);if(t!==null)return Number.isInteger(t)?t:null;let n=L(e).unwrap_or(void 0);if(n!==void 0){let e=Number(n);if(!isNaN(e)&&Number.isInteger(e))return e}return null}const z_=[`true`,`yes`,`y`,`t`,`1`],B_=[`false`,`no`,`n`,`f`,`0`];function V_(e){if(e==null)return null;if(typeof e==`boolean`)return e;if(typeof e==`number`)return e===0?!1:e===1?!0:null;if(typeof e==`string`){let t=e.toLowerCase();return z_.includes(t)?!0:B_.includes(t)?!1:null}if(ed(e)){let t=e.expression.variable?.value?.toLowerCase();if(t===`true`)return!0;if(t===`false`)return!1}let t=zu(e);if(t===0)return!1;if(t===1)return!0;let n=L(e)?.unwrap_or(``).toLowerCase();if(n){if(z_.includes(n))return!0;if(B_.includes(n))return!1}return null}function H_(e){if(e==null)return null;if(typeof e==`string`)return e;let t=P(e).unwrap_or(void 0);return t?h(t):L(e).unwrap_or(null)}function U_(e){if(e==null)return null;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return e.toString();let t=L(e).unwrap_or(null)??L_(e)??V_(e);return t===null?null:t.toString()}var W_=[`yyyy-MM-dd`,`M/d/yyyy`,`d MMM yyyy`,`MMM d, yyyy`],G_=[`yyyy-MM-dd HH:mm:ss`,`yyyy-MM-dd HH:mm:ss.SSS`,`yyyy-MM-dd HH:mm:ss.SSSZZ`,`yyyy-MM-dd HH:mm:ssZZ`],K_=[`HH:mm:ss`,`HH:mm:ssZZ`,`HH:mm:ss.SSS`,`HH:mm:ss.SSSZZ`];function q_(e){if(e==null)return null;let t=typeof e==`string`?e:L(e).unwrap_or(null);if(t===null)return null;for(let e of K_){let n=Y.fromFormat(t,e,{setZone:!0});if(n.isValid)return n.toISOTime({suppressMilliseconds:!0,includeOffset:r(n)})}for(let e of W_){let n=Y.fromFormat(t,e,{setZone:!0});if(n.isValid)return n.toISODate()}for(let e of G_){let n=Y.fromFormat(t,e,{setZone:!0});if(n.isValid)return n.toISO({suppressMilliseconds:!0,includeOffset:r(n)})}let n=Y.fromISO(t,{setZone:!0});if(n.isValid)return n.toISO({suppressMilliseconds:!0,includeOffset:r(n)});return null;function r(e){return e.zone.type!==`system`}}function J_(e,t,n){return t.map((t,r)=>{let i=e[t]?.value;if(i==null&&n&&n[r]){let e=n[r];if(e?.dbdefault)return JSON.stringify(e.dbdefault.value)}return JSON.stringify(i)}).join(`|`)}function Y_(e,t,n){return t.some((t,r)=>{let i=e[t]?.value;return i==null&&n&&n[r]&&n[r]?.dbdefault?!1:i==null})}function X_(e){return e.increment||yf(e.type.type_name)}function Z_(e,t,n){return e?`${e}.${t}.${n}`:`${t}.${n}`}function Q_(e,t,n){return n.length===1?Z_(e,t,n[0]):`(${n.map(n=>Z_(e,t,n)).join(`, `)})`}function $_(e,t){return t.length===1?JSON.stringify(e[t[0]]?.value):`(${t.map(t=>JSON.stringify(e[t]?.value)).join(`, `)})`}function ev(e,t,n){let r=t.map(t=>e.columnNodes[t]).filter(Boolean);return r.length>0?r.map(e=>new E(T.INVALID_RECORDS_FIELD,n,e)):[new E(T.INVALID_RECORDS_FIELD,n,e.node)]}var tv=e=>e>1?`Composite PK`:`PK`;function nv(e){return bc(Array.from(e.records),([t,n])=>{if(Ac(n))return[];e.cachedMergedTables.has(t)||e.cachedMergedTables.set(t,qd(t,e));let r=e.cachedMergedTables.get(t),i=ov(r),a=sv(n),o=Mc(r.fields,`name`);return bc(i,e=>rv(e,n,a,o,r))})}function rv(e,t,n,r,i){let a=cv(e,n,r,i,t);if(!Ac(a))return a;let o=io(e.map(e=>r[e])),s=o.every(e=>e&&X_(e)),[c,l]=g(t,t=>Y_(t.values,e,o)),u=s?[]:iv(c,e,i),d=av(l,e,o,i);return[...u,...d]}function iv(e,t,n){if(Ac(e))return[];let r=`NULL in ${tv(t.length)}: ${Q_(n.schemaName,n.name,t)} cannot be NULL`;return bc(e,e=>ev(e,t,r))}function av(e,t,n,r){return bc(cc(Tc(e,e=>J_(e.values,t,n)),e=>e.length>1),e=>{let n=tv(t.length),i=Q_(r.schemaName,r.name,t);return bc(e.slice(1),e=>ev(e,t,`Duplicate ${n}: ${i} = ${$_(e.values,t)}`))})}function ov(e){return[...e.fields.filter(e=>e.pk).map(e=>[e.name]),...e.indexes.filter(e=>e.pk).map(e=>e.columns.map(e=>e.value))]}function sv(e){return new Set(e.flatMap(e=>Object.keys(e.values)))}function cv(e,t,n,r,i){let a=tc(e,Array.from(t));if(Ac(a))return[];let o=a.filter(e=>{let t=n[e];return t&&!t.increment&&!yf(t.type.type_name)&&!t.dbdefault});if(Ac(o))return[];let s=`${tv(o.length)}: Column ${Q_(r.schemaName,r.name,o)} is missing from record and has no default value`;return i.map(e=>new E(T.INVALID_RECORDS_FIELD,s,e.node))}var lv=e=>e>1?`Composite UNIQUE`:`UNIQUE`;function uv(e){return bc(Array.from(e.records),([t,n])=>{e.cachedMergedTables.has(t)||e.cachedMergedTables.set(t,qd(t,e));let r=e.cachedMergedTables.get(t);if(Ac(n))return[];let i=dv(r),a=Mc(r.fields,`name`);return bc(i,e=>fv(n,e,io(e.map(e=>a[e])),r))})}function dv(e){return[...e.fields.filter(e=>e.unique).map(e=>[e.name]),...e.indexes.filter(e=>e.unique).map(e=>e.columns.map(e=>e.value))]}function fv(e,t,n,r){return bc(cc(Tc(e.filter(e=>!Y_(e.values,t,n)),e=>J_(e.values,t,n)),e=>e.length>1),e=>{let n=lv(t.length),i=Q_(r.schemaName,r.name,t);return bc(e.slice(1),e=>ev(e,t,`Duplicate ${n}: ${i} = ${$_(e.values,t)}`))})}function pv(e){let t=[...e.ref.values(),...bc(Array.from(e.tables.values()),t=>Jd(t,e))],n=mv(e);return bc(t,e=>_v(e,n))}function mv(e){let t=new Map;for(let n of e.tables.values()){let r=hv(n.schemaName,n.name),i=e.records.get(n)||[];e.cachedMergedTables.has(n)||e.cachedMergedTables.set(n,qd(n,e));let a=e.cachedMergedTables.get(n);t.set(r,{mergedTable:a,rows:i})}return t}function hv(e,t){return e?`${e}.${t}`:`${Gl}.${t}`}function gv(e,t,n,r){if(Ac(e.rows))return[];let i=new Set(t.rows.map(e=>J_(e.values,r.fieldNames)));return bc(e.rows.filter(e=>!Y_(e.values,n.fieldNames)).filter(e=>{let t=J_(e.values,n.fieldNames);return!i.has(t)}),i=>{let a=Q_(e.mergedTable.schemaName,e.mergedTable.name,n.fieldNames),o=Q_(t.mergedTable.schemaName,t.mergedTable.name,r.fieldNames),s=`FK violation: ${a} = ${$_(i.values,n.fieldNames)} does not exist in ${o}`;return ev(i,n.fieldNames,s)})}function _v(e,t){if(!e.endpoints)return[];let[n,r]=e.endpoints,i=t.get(hv(n.schemaName,n.tableName)),a=t.get(hv(r.schemaName,r.tableName));return!i||!a?[]:vv(i,a,n,r)}function vv(e,t,n,r){let i=n.relation,a=r.relation;return i===`1`&&a===`1`||i===`*`&&a===`*`?[...gv(e,t,n,r),...gv(t,e,r,n)]:i===`*`&&a===`1`?gv(e,t,n,r):i===`1`&&a===`*`?gv(t,e,r,n):[]}var yv=class{constructor(e){this.env=e,this.tableToRecordMap=new Map}interpret(e){let t=[],n=[];for(let r of e){let{table:e,mergedColumns:i}=bv(r,this.env),a=this.tableToRecordMap.get(e);if(a){t.push(new E(T.DUPLICATE_RECORDS_FOR_TABLE,`Duplicate Records blocks for the same Table '${e.name}' - A Table can only have one Records block`,a)),t.push(new E(T.DUPLICATE_RECORDS_FOR_TABLE,`Duplicate Records blocks for the same Table '${e.name}' - A Table can only have one Records block`,r));continue}this.tableToRecordMap.set(e,r);for(let a of r.body.body){let r=a,o=xv(r,i,this.env);t.push(...o.getErrors()),n.push(...o.getWarnings());let s=o.getValue();s.row&&(this.env.records.has(e)||this.env.records.set(e,[]),this.env.records.get(e).push({values:s.row,node:r,columnNodes:s.columnNodes}))}}let r=this.validateConstraints();return n.push(...r),new D(void 0,t,n)}validateConstraints(){let e=[];return e.push(...nv(this.env).map(e=>e.toWarning())),e.push(...uv(this.env).map(e=>e.toWarning())),e.push(...pv(this.env).map(e=>e.toWarning())),e}};function bv(e,t){let n=e.name,r=e.parent;if(r instanceof b){let e=t.tables.get(r),i=qd(e,t);return n?{table:e,mergedTable:i,mergedColumns:n.elementList.map(e=>i.fields.find(t=>t.name===F(e).unwrap()))}:{table:e,mergedTable:i,mergedColumns:i.fields}}let i=Wu(n).unwrap(),a=h(i.variables).referee.declaration,o=t.tables.get(a),s=qd(o,t);return{table:o,mergedTable:s,mergedColumns:i.args.map(e=>s.fields.find(t=>t.name===F(e).unwrap()))}}function xv(e,t,n){let r=[],i=[],a={},o={},s=e.callee instanceof dl?e.callee.elementList:[e.callee];if(s.length!==t.length)return r.push(new E(T.INVALID_RECORDS_FIELD,`Expected ${t.length} values but got ${s.length}`,e)),new D({row:null,columnNodes:{}},r,i);for(let e=0;e<t.length;e++){let c=s[e],l=t[e];o[l.name]=c;let u=Cv(c,l,n);r.push(...u.getErrors()),i.push(...u.getWarnings());let d=u.getValue();d!==null&&(a[l.name]=d)}return new D({row:a,columnNodes:o},r,i)}function Sv(e,t){return e instanceof ll?e.value?.value||``:!isNaN(e.start)&&!isNaN(e.end)?t.slice(e.start,e.end):``}function Cv(e,t,n){let r=t.type.type_name.split(`(`)[0],{increment:i,not_null:a,dbdefault:o}=t,s=t.type.isEnum||!1,c=Cf(r,s),l=U_(e),u=l===null?Sv(e,n.source):l,d=l===null?`expression`:c;if(e instanceof ll)return new D({value:e.value?.value||``,type:`expression`},[],[]);if(N_(e)||P_(e)&&!gf(r)){let n=o&&o.value.toString().toLowerCase()!==`null`,s=yf(r);return a&&!n&&!i&&!s?new D({value:null,type:c},[],[new Pl(T.INVALID_RECORDS_FIELD,`NULL not allowed for non-nullable column '${t.name}' without default and increment`,e)]):new D({value:null,type:c},[],[])}if(s){let r=([...n.enums.values()].find(e=>e.schemaName===t.type.schemaName&&e.name===t.type.type_name)?.values||[]).map(e=>e.name),i=L(e).unwrap_or(void 0);return i===void 0&&(i=P(e).unwrap_or([]).pop()),r.includes(i)?new D({value:i,type:c},[],[]):new D({value:i,type:c},[],[new Pl(T.INVALID_RECORDS_FIELD,`Invalid enum value for column '${t.name}'`,e)])}if(mf(r)){let n=L_(e);if(n===null)return new D({value:u,type:d},[],[new Pl(T.INVALID_RECORDS_FIELD,`Invalid numeric value for column '${t.name}'`,e)]);if(ff(r)&&!Number.isInteger(n))return new D({value:Math.floor(n),type:c},[],[new Pl(T.INVALID_RECORDS_FIELD,`Invalid integer value ${n} for column '${t.name}': expected integer, got decimal`,e)]);if(pf(r)&&t.type.numericParams){let{precision:r,scale:i}=t.type.numericParams,a=n.toString().split(`.`),o=a[0].replace(/^-/,``),s=a[1]||``,l=o.length+s.length,u=s.length;if(l>r)return new D({value:n,type:c},[],[new Pl(T.INVALID_RECORDS_FIELD,`Numeric value ${n} for column '${t.name}' exceeds precision: expected at most ${r} total digits, got ${l}`,e)]);if(u>i)return new D({value:n,type:c},[],[new Pl(T.INVALID_RECORDS_FIELD,`Numeric value ${n} for column '${t.name}' exceeds scale: expected at most ${i} decimal digits, got ${u}`,e)])}return new D({value:n,type:c},[],[])}if(hf(r)){let n=V_(e);return n===null?new D({value:u,type:d},[],[new Pl(T.INVALID_RECORDS_FIELD,`Invalid boolean value for column '${t.name}'`,e)]):new D({value:n,type:c},[],[])}if(vf(r)){let n=q_(e);return n===null?new D({value:u,type:d},[],[new Pl(T.INVALID_RECORDS_FIELD,`Invalid datetime value for column '${t.name}', expected valid datetime format (e.g., 'YYYY-MM-DD', 'HH:MM:SS', 'YYYY-MM-DD HH:MM:SS', 'MM/DD/YYYY', 'D MMM YYYY', or 'MMM D, YYYY')`,e)]):new D({value:n,type:c},[],[])}if(gf(r)){let n=U_(e);if(n===null)return new D({value:u,type:d},[],[new Pl(T.INVALID_RECORDS_FIELD,`Invalid string value for column '${t.name}'`,e)]);if(t.type.lengthParam){let{length:r}=t.type.lengthParam,i=new TextEncoder().encode(n).length;if(i>r)return new D({value:n,type:c},[],[new Pl(T.INVALID_RECORDS_FIELD,`String value for column '${t.name}' exceeds maximum length: expected at most ${r} bytes (UTF-8), got ${i} bytes`,e)])}return new D({value:n,type:`string`},[],[])}return new D({value:u,type:d},[],[])}function wv(e){return{...e,fields:e.fields.map(e=>({...e,type:{...e.type,isEnum:void 0,lengthParam:void 0,numericParams:void 0}}))}}function Tv(e){for(let t of e.diagramViews.values()){let n=t.visibleEntities,r=e.diagramViewWildcards.get(t),i=e.diagramViewExplicitlySet.get(t);!r||!i||r.has(`tableGroups`)&&n.tableGroups&&n.tableGroups.length===0&&(i.has(`tables`)||i.has(`schemas`)||(n.tableGroups=Array.from(e.tableGroups.values()).map(e=>({name:e.name}))))}}function Ev(e){let t=[];for(let[n,r]of e.records){if(!r.length)continue;let e=Object.keys(r[0].columnNodes);t.push({schemaName:n.schemaName||void 0,tableName:n.name,columns:e,values:r.map(t=>e.map(e=>{let n=t.values[e];return n?{value:n.value,type:n.type}:{value:null,type:`expression`}}))})}return{schemas:[],tables:Array.from(e.tables.values()).map(wv),notes:Array.from(e.notes.values()),refs:Array.from(e.ref.values()),enums:Array.from(e.enums.values()),tableGroups:Array.from(e.tableGroups.values()),aliases:e.aliases,project:Array.from(e.project.values())[0]||{},tablePartials:Array.from(e.tablePartials.values()).map(wv),records:t,diagramViews:Array.from(e.diagramViews.values())}}var Dv=class{constructor(e){this.ast=e,this.env={schema:[],tables:new Map,notes:new Map,refIds:{},ref:new Map,enums:new Map,tableOwnerGroup:{},tableGroups:new Map,aliases:[],project:new Map,tablePartials:new Map,records:new Map,recordsElements:[],cachedMergedTables:new Map,source:e.source,diagramViews:new Map,diagramViewWildcards:new Map,diagramViewExplicitlySet:new Map}}interpret(){let e=this.ast.body.flatMap(e=>{switch(Fu(e).unwrap_or(void 0)){case A.Table:return new Yd(e,this.env).interpret();case A.Note:return new Xd(e,this.env).interpret();case A.Ref:return new Zd(e,this.env).interpret();case A.TableGroup:return new Qd(e,this.env).interpret();case A.TablePartial:return new ef(e,this.env).interpret();case A.Enum:return new $d(e,this.env).interpret();case A.Project:return new tf(e,this.env).interpret();case A.DiagramView:return new nf(e,this.env).interpret();case A.Records:return this.env.recordsElements.push(e),[];default:return[]}}),t=[];if(this.env.recordsElements.length){let n=new yv(this.env).interpret(this.env.recordsElements);e.push(...n.getErrors()),t.push(...n.getWarnings())}return Tv(this.env),new D(Ev(this.env),e,t)}};let X=function(e){return e[e.Function=1]=`Function`,e[e.Constructor=2]=`Constructor`,e[e.Field=3]=`Field`,e[e.Variable=4]=`Variable`,e[e.Class=5]=`Class`,e[e.Struct=6]=`Struct`,e[e.Interface=7]=`Interface`,e[e.Module=8]=`Module`,e[e.Property=9]=`Property`,e[e.Event=10]=`Event`,e[e.Operator=11]=`Operator`,e[e.Unit=12]=`Unit`,e[e.Value=13]=`Value`,e[e.Constant=14]=`Constant`,e[e.Enum=15]=`Enum`,e[e.EnumMember=16]=`EnumMember`,e[e.Keyword=17]=`Keyword`,e[e.Text=18]=`Text`,e[e.Color=19]=`Color`,e[e.File=20]=`File`,e[e.Reference=21]=`Reference`,e[e.Customcolor=22]=`Customcolor`,e[e.Folder=23]=`Folder`,e[e.TypeParameter=24]=`TypeParameter`,e[e.User=25]=`User`,e[e.Issue=26]=`Issue`,e[e.Snippet=27]=`Snippet`,e}({}),Z=function(e){return e[e.None=0]=`None`,e[e.KeepWhitespace=1]=`KeepWhitespace`,e[e.InsertAsSnippet=4]=`InsertAsSnippet`,e}({}),Ov=function(e){return e[e.Hint=1]=`Hint`,e[e.Info=2]=`Info`,e[e.Warning=4]=`Warning`,e[e.Error=8]=`Error`,e}({});function kv(e){return e?e.split(``).every(e=>Fl(e)||Il(e))&&!Il(e[0]):!1}function Av(e){return kv(e)?e:`"${Mv(e)}"`}function jv(e){let t=``,n=0,r={n:`
|
|
11
|
+
`)}function Gd(e){if(e){if(z(e))return{value:L(e).unwrap(),type:`string`};if(ju(e))return{type:`number`,value:Hl(e)};if(ed(e))return{value:e.expression.variable.value.toLowerCase(),type:`boolean`};if(e instanceof ll&&e.value)return{value:e.value.value,type:`expression`};if(nd(e))return{value:Iu(e).map(h).and_then(F).unwrap(),type:`string`};throw Error(`Unreachable`)}}function Kd(e,t){let n=``,r=null,i,a;if(e instanceof w){let t=e.argumentList.elementList;if(r=t.map(e=>ju(e)?Vl(e):z(e)?L(e).unwrap():F(e).unwrap()).join(`,`),n=`(${r})`,t.length===2&&ju(t[0])&&ju(t[1])){let e=Hl(t[0]),n=Hl(t[1]);!isNaN(e)&&!isNaN(n)&&(i={precision:Math.trunc(e),scale:Math.trunc(n)})}else if(t.length===1&&ju(t[0])){let e=Hl(t[0]);isNaN(e)||(a={length:Math.trunc(e)})}e=e.callee}for(;e instanceof w||e instanceof vl;)e instanceof w?(n=`(${e.argumentList.elementList.map(e=>ju(e)?Vl(e):z(e)?L(e).unwrap():F(e).unwrap()).join(`,`)})${n}`,e=e.callee):e instanceof vl&&(n=`${`[${e.indexer.elementList.map(e=>e.name.expression.literal.value).join(`,`)}]`}${n}`,e=e.array);let{name:o,schemaName:s}=Bd(e),c=s.length===0?null:s[0],l=!![...t.enums.values()].find(e=>e.name===o&&e.schemaName===c);return s.length>1?new D({schemaName:s.length===0?null:s[0],type_name:`${o}${n}`,args:r,numericParams:i,lengthParam:a,isEnum:l},[new E(T.UNSUPPORTED,`Nested schema is not supported`,e)]):new D({schemaName:s.length===0?null:s[0],type_name:`${o}${n}`,args:r,numericParams:i,lengthParam:a,isEnum:l})}function qd(e,t){let n=[...t.tables.entries()].find(([,t])=>t===e)?.[0];if(!n)throw Error(`mergeTableAndPartials should be called after all tables are interpreted`);if(!(n.body instanceof S))throw Error(`Table element should have a block body`);let r=[...e.indexes],i=[...e.checks],a=e.headerColor,o=e.note,s=[...t.tablePartials.values()];for(let t of[...e.partials].reverse()){let{name:e}=t,n=s.find(t=>t.name===e);n&&(r.push(...n.indexes),i.push(...n.checks),n.headerColor!==void 0&&(a=n.headerColor),n.note!==void 0&&(o=n.note))}let c=new Map(e.fields.map(e=>[e.name,e])),l=new Set(c.keys()),u=new Map(s.map(e=>[e.name,e])),d=[];for(let e of n.body.body)if(e instanceof x)if(Tu(e.callee)){let t=F(e.callee.expression).unwrap_or(void 0),n=u.get(t);if(!n)continue;for(let e of n.fields)l.has(e.name)||d.push(e)}else{let t=F(e.callee).unwrap(),n=c.get(t);if(!n)continue;d.push(n)}let f=Bc([...d].reverse(),`name`).reverse();return{...e,fields:f,indexes:r,checks:i,headerColor:a,note:o}}function Jd(e,t){let n=[],r=[...t.tablePartials.values()],i=new Set(e.fields.map(e=>e.name));for(let t of[...e.partials].reverse()){let{name:a}=t,o=r.find(e=>e.name===a);if(o){for(let t of o.fields)if(!i.has(t.name))for(let r of t.inline_refs){let i=Rd(r.relation);n.push({name:null,schemaName:null,token:r.token,endpoints:[{schemaName:r.schemaName,tableName:r.tableName,fieldNames:r.fieldNames,token:r.token,relation:i[1]},{schemaName:e.schemaName,tableName:e.name,fieldNames:[t.name],token:t.token,relation:i[0]}]})}}}return n}var Yd=class{constructor(e,t){this.declarationNode=e,this.env=t,this.table={name:void 0,schemaName:void 0,alias:null,fields:[],token:void 0,indexes:[],partials:[],checks:[]},this.pkColumns=[]}interpret(){this.table.token=H(this.declarationNode),this.env.tables.set(this.declarationNode,this.table);let e=[...this.interpretName(this.declarationNode.name),...this.interpretAlias(this.declarationNode.alias),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)];return this.pkColumns.length>=2&&(this.table.indexes.push({columns:this.pkColumns.map(({name:e,token:t})=>({value:e,type:`column`,token:t})),token:{start:{offset:-1,line:-1,column:-1},end:{offset:-1,line:-1,column:-1}},pk:!0}),this.pkColumns.forEach(e=>{e.pk=!1})),e}interpretName(e){let{name:t,schemaName:n}=Bd(e);return n.length>1?(this.table.name=t,this.table.schemaName=n.join(`.`),[new E(T.UNSUPPORTED,`Nested schema is not supported`,e)]):(this.table.name=t,this.table.schemaName=n.length?n[0]:null,[])}interpretAlias(e){if(!e)return[];let t=I(e).unwrap_or(null);return t&&(this.env.aliases.push({name:t,kind:`table`,value:{tableName:this.table.name,schemaName:this.table.schemaName}}),this.table.alias=t),[]}interpretSettingList(e){let t=N(e).getValue();this.table.headerColor=t[j.HeaderColor]?.length?Vd(t[j.HeaderColor]?.at(0)?.value):void 0;let[n]=t[j.Note]||[];return this.table.note=n&&{value:L(n?.value).map(Wd).unwrap(),token:H(n)},[]}interpretBody(e){let[t,n]=g(e.body,e=>e instanceof x);return[...this.interpretFields(t),...this.interpretSubElements(n)]}interpretSubElements(e){return e.flatMap(e=>{switch(e.type?.value.toLowerCase()){case A.Note:return this.table.note={value:L(e.body instanceof S?e.body.body[0].callee:e.body.callee).map(Wd).unwrap(),token:H(e)},[];case A.Indexes:return this.interpretIndexes(e);case A.Check:return this.interpretChecks(e);case A.Records:return this.env.recordsElements.push(e),[];default:return[]}})}interpretInjection(e,t){let n={order:t,token:H(e)};return n.name=F(e.expression).unwrap_or(``),this.table.partials.push(n),[]}interpretFields(e){let t=(this.declarationNode.symbol?.symbolTable?[...this.declarationNode.symbol.symbolTable.entries()]:[]).filter(([e])=>ou(e).unwrap_or(null)?.kind===M.Column).length?[]:[new E(T.EMPTY_TABLE,`A Table must have at least one column`,this.declarationNode)],n=e.flatMap((e,t)=>Tu(e.callee)?this.interpretInjection(e.callee,t):this.interpretColumn(e));return[...t,...n]}interpretColumn(e){let t=[],n={};n.name=I(e.callee).unwrap();let r=Kd(e.args[0],this.env);n.type=r.getValue(),t.push(...r.getErrors()),n.token=H(e),n.inline_refs=[];let i=e.args.slice(1);if(h(i)instanceof C){let r=N(i.pop()).getValue();n.pk=!!r[j.PK]?.length||!!r[j.PrimaryKey]?.length,n.increment=!!r[j.Increment]?.length,n.unique=!!r[j.Unique]?.length,n.not_null=r[j.NotNull]?.length?!0:r[j.Null]?.length?!1:void 0,n.dbdefault=Gd(r[j.Default]?.at(0)?.value);let a=r[j.Note]?.at(0);n.note=a&&{value:L(a.value).map(Wd).unwrap(),token:H(a)},n.inline_refs=(r[j.Ref]||[]).flatMap(n=>{let[r]=zd(n.value.expression);if(Ud(r,e.symbol))return t.push(new E(T.SAME_ENDPOINT,`Two endpoints are the same`,n)),[];let i=n.value.op,a=P(n.value.expression).unwrap(),o;if(a.length===1){let[e]=a;o={schemaName:this.table.schemaName,tableName:this.table.name,fieldNames:[e],relation:i.value,token:H(n)}}else if(a.length===2){let[e,t]=a;o={schemaName:null,tableName:e,fieldNames:[t],relation:i.value,token:H(n)}}else if(a.length===3){let[e,t,r]=a;o={schemaName:e,tableName:t,fieldNames:[r],relation:i.value,token:H(n)}}else{t.push(new E(T.UNSUPPORTED,`Nested schema is not supported`,n));let e=a.pop(),r=a.pop();o={schemaName:a.join(`.`),tableName:r,fieldNames:[e],relation:i.value,token:H(n)}}let s=this.registerInlineRefToEnv(e,r,o,n);return t.push(...s),s.length===0?o:[]}),n.checks=(r[j.Check]||[]).map(e=>({token:H(e),expression:e.value.value.value}))}return n.pk||=i.some(e=>F(e).unwrap().toLowerCase()===`pk`),n.unique||=i.some(e=>F(e).unwrap().toLowerCase()===`unique`),this.table.fields.push(n),n.pk&&this.pkColumns.push(n),t}interpretIndexes(e){return this.table.indexes.push(...e.body.body.map(e=>{let t={columns:[]},n=e;t.token=H(n);let r=[n.callee,...n.args];if(h(r)instanceof C){let e=N(r.pop()).getValue();t.pk=!!e[j.PK]?.length,t.unique=!!e[j.Unique]?.length,t.name=L(e[j.Name]?.at(0)?.value).unwrap_or(void 0);let n=e[j.Note]?.at(0);t.note=n&&{value:L(n.value).unwrap(),token:H(n)},t.type=F(e[j.Type]?.at(0)?.value).unwrap_or(void 0)}return r.flatMap(e=>{if(!(e instanceof w))return e;let t=[];for(;e instanceof w;)t.push(e.argumentList),e=e.callee;return t.push(e),t}).forEach(e=>{let{functional:n,nonFunctional:r}=Ru(e).unwrap();t.columns.push(...n.map(e=>({value:e.value.value,type:`expression`,token:H(e)})),...r.map(e=>({value:I(e).unwrap(),type:`column`,token:H(e)})))}),t})),[]}interpretChecks(e){return this.table.checks.push(...e.body.body.map(e=>{let t={},n=e;return t.token=H(n),n.args[0]instanceof C&&(t.name=L(N(n.args[0]).getValue()[j.Name]?.at(0)?.value).unwrap_or(void 0)),t.expression=n.callee.value.value,t})),[]}registerInlineRefToEnv(e,t,n,r){let i=Hd(e.symbol,t);if(this.env.refIds[i])return[new E(T.CIRCULAR_REF,`References with same endpoints exist`,r),new E(T.CIRCULAR_REF,`References with same endpoints exist`,this.env.refIds[i])];let a=Rd(n.relation);return this.env.refIds[i]=r,this.env.ref.set(r,{name:null,schemaName:null,token:n.token,endpoints:[{...n,relation:a[1]},{schemaName:this.table.schemaName,tableName:this.table.name,fieldNames:[F(e.callee).unwrap()],token:H(e),relation:a[0]}]}),[]}},Xd=class{constructor(e,t){this.declarationNode=e,this.env=t,this.note={name:void 0,content:void 0,token:void 0}}interpret(){return this.note.token=H(this.declarationNode),this.env.notes.set(this.declarationNode,this.note),[...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)]}interpretName(e){let{name:t}=Bd(e);return this.note.name=t,[]}interpretSettingList(e){let t=N(e).getValue();return this.note.headerColor=t.headercolor?.length?Vd(t.headercolor?.at(0)?.value):void 0,[]}interpretBody(e){let[t,n]=g(e.body,e=>e instanceof x);return t.length!==1||n.length>0?[new E(T.INVALID_NOTE,`Invalid note syntax`,e)]:[...this.interpretNote(t[0])]}interpretNote(e){let t=ta(e,`callee.expression.literal.value`,``);return this.note.content=Wd(t),[]}},Zd=class{constructor(e,t){this.declarationNode=e,this.env=t,this.container=this.declarationNode.parent instanceof b?this.env.tables.get(this.declarationNode.parent):void 0,this.ref={}}interpret(){return this.ref.token=H(this.declarationNode),this.env.ref.set(this.declarationNode,this.ref),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(e){let t=[],n=P(this.declarationNode.name).unwrap_or([]);return this.ref.name=n.pop()||null,n.length>1&&t.push(new E(T.UNSUPPORTED,`Nested schema is not supported`,this.declarationNode.name)),this.ref.schemaName=n.join(`.`)||null,t}interpretBody(e){return e instanceof x?this.interpretField(e):this.interpretField(e.body[0])}interpretField(e){let t=e.callee.op.value,{leftExpression:n,rightExpression:r}=e.callee,i=zd(n),a=zd(r);if(Ud(i,a))return[new E(T.SAME_ENDPOINT,`Two endpoints are the same`,e)];let o=Hd(i,a);if(this.env.refIds[o])return[new E(T.CIRCULAR_REF,`References with same endpoints exist`,this.declarationNode),new E(T.CIRCULAR_REF,`References with same endpoints exist`,this.env.refIds[o])];if(e.args[0]){let t=N(e.args[0]).getValue(),n=t.delete?.at(0)?.value;this.ref.onDelete=n instanceof il?rd(n).unwrap_or(void 0):F(n).unwrap_or(void 0);let r=t.update?.at(0)?.value;this.ref.onUpdate=r instanceof il?rd(r).unwrap_or(void 0):F(r).unwrap_or(void 0),this.ref.color=t.color?.length?Vd(t.color?.at(0)?.value):void 0}let s=Rd(t);return this.ref.endpoints=[{...Ld(n,this.container),relation:s[0],token:H(n)},{...Ld(r,this.container),relation:s[1],token:H(r)}],this.env.refIds[o]=this.declarationNode,[]}},Qd=class{constructor(e,t){this.declarationNode=e,this.env=t,this.tableGroup={tables:[]}}interpret(){let e=[];return this.tableGroup.token=H(this.declarationNode),this.env.tableGroups.set(this.declarationNode,this.tableGroup),e.push(...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)),e}interpretName(e){let t=[],{name:n,schemaName:r}=Bd(e);return r.length>=2&&(this.tableGroup.name=n,this.tableGroup.schemaName=r.join(`.`),t.push(new E(T.UNSUPPORTED,`Nested schema is not supported`,this.declarationNode.name))),this.tableGroup.name=n,this.tableGroup.schemaName=r[0]||null,t}interpretBody(e){let[t,n]=g(e.body,e=>e instanceof x);return[...this.interpretFields(t),...this.interpretSubElements(n)]}interpretSubElements(e){return e.flatMap(e=>{switch(e.type?.value.toLowerCase()){case`note`:this.tableGroup.note={value:L(e.body instanceof S?e.body.body[0].callee:e.body.callee).map(Wd).unwrap(),token:H(e)};break;default:break}return[]})}interpretFields(e){let t=[];return this.tableGroup.tables=e.map(e=>{let n=P(e.callee).unwrap();n.length>2&&t.push(new E(T.UNSUPPORTED,`Nested schema is not supported`,e));let r=Iu(e.callee).unwrap().pop().referee.id;if(this.env.tableOwnerGroup[r]){let i=this.env.tableOwnerGroup[r],{schemaName:a,name:o}=this.env.tableGroups.get(i),s=a?`${a}.${o}`:o;t.push(new E(T.TABLE_REAPPEAR_IN_TABLEGROUP,`Table "${n.join(`.`)}" already appears in group "${s}"`,e))}else this.env.tableOwnerGroup[r]=this.declarationNode;return{name:n.pop(),schemaName:n.join(`.`)}}),t}interpretSettingList(e){let t=N(e).getValue();this.tableGroup.color=t.color?.length?Vd(t.color?.at(0)?.value):void 0;let[n]=t.note||[];return this.tableGroup.note=n&&{value:L(n?.value).map(Wd).unwrap(),token:H(n)},[]}},$d=class{constructor(e,t){this.declarationNode=e,this.env=t,this.enum={values:[]}}interpret(){return this.enum.token=H(this.declarationNode),this.env.enums.set(this.declarationNode,this.enum),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(e){let{name:t,schemaName:n}=Bd(e);return n.length>1?(this.enum.name=t,this.enum.schemaName=n.join(`.`),[new E(T.UNSUPPORTED,`Nested schema is not supported`,e)]):(this.enum.name=t,this.enum.schemaName=n.length?n[0]:null,[])}interpretBody(e){return e.body.flatMap(e=>{let t=e,n={};n.token=H(t),n.name=F(t.callee).unwrap();let r=N(t.args[0]).getValue().note?.at(0);return n.note=r&&{value:L(r.value).map(Wd).unwrap(),token:H(r)},this.enum.values.push(n),[]})}},ef=class{constructor(e,t){this.declarationNode=e,this.env=t,this.tablePartial={name:void 0,fields:[],token:void 0,indexes:[],checks:[]},this.pkColumns=[]}interpret(){this.tablePartial.token=H(this.declarationNode),this.env.tablePartials.set(this.declarationNode,this.tablePartial);let e=[...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)];return this.pkColumns.length>=2&&(this.tablePartial.indexes.push({columns:this.pkColumns.map(({name:e,token:t})=>({value:e,type:`column`,token:t})),token:{start:{offset:-1,line:-1,column:-1},end:{offset:-1,line:-1,column:-1}},pk:!0}),this.pkColumns.forEach(e=>{e.pk=!1})),e}interpretName(e){let{name:t}=Bd(e);return this.tablePartial.name=t,[]}interpretSettingList(e){let t=N(e).getValue(),n=mc(t[j.HeaderColor]);this.tablePartial.headerColor=n?Vd(n.value):void 0;let[r]=t[j.Note]||[];return this.tablePartial.note=r&&{value:L(r?.value).map(Wd).unwrap(),token:H(r)},[]}interpretBody(e){let[t,n]=g(e.body,e=>e instanceof x);return[...this.interpretFields(t),...this.interpretSubElements(n)]}interpretSubElements(e){return e.flatMap(e=>{switch(e.type?.value.toLowerCase()){case A.Note:return this.tablePartial.note={value:L(e.body instanceof S?e.body.body[0].callee:e.body.callee).map(Wd).unwrap(),token:H(e)},[];case A.Indexes:return this.interpretIndexes(e);case A.Check:return this.interpretChecks(e);default:return[]}})}interpretFields(e){return e.flatMap(e=>this.interpretColumn(e))}interpretColumn(e){let t=[],n={};n.name=I(e.callee).unwrap();let r=Kd(e.args[0],this.env);n.type=r.getValue(),t.push(...r.getErrors()),n.token=H(e),n.inline_refs=[];let i=e.args.slice(1);if(h(i)instanceof C){let r=N(i.pop()).getValue();n.pk=!!r[j.PK]?.length||!!r[j.PrimaryKey]?.length,n.increment=!!r[j.Increment]?.length,n.unique=!!r[j.Unique]?.length,n.not_null=r[j.NotNull]?.length?!0:r[j.Null]?.length?!1:void 0,n.dbdefault=Gd(r[j.Default]?.at(0)?.value);let a=r[j.Note]?.at(0);n.note=a&&{value:L(a.value).map(Wd).unwrap(),token:H(a)},n.inline_refs=(r[j.Ref]||[]).flatMap(n=>{let[r]=zd(n.value.expression);if(Ud(r,e.symbol))return t.push(new E(T.SAME_ENDPOINT,`Two endpoints are the same`,n)),[];let i=n.value.op,a=P(n.value.expression).unwrap(),o;if(a.length===2){let[e,t]=a;o={schemaName:null,tableName:e,fieldNames:[t],relation:i.value,token:H(n)}}else if(a.length===3){let[e,t,r]=a;o={schemaName:e,tableName:t,fieldNames:[r],relation:i.value,token:H(n)}}else{t.push(new E(T.UNSUPPORTED,`Unsupported`,n));let e=a.pop(),r=a.pop();o={schemaName:a.join(`.`),tableName:r,fieldNames:[e],relation:i.value,token:H(n)}}return o}),n.checks=(r[j.Check]||[]).map(e=>({token:H(e),expression:e.value.value.value}))}return n.pk||=i.some(e=>F(e).unwrap().toLowerCase()===`pk`),n.unique||=i.some(e=>F(e).unwrap().toLowerCase()===`unique`),this.tablePartial.fields.push(n),n.pk&&this.pkColumns.push(n),t}interpretIndexes(e){return this.tablePartial.indexes.push(...e.body.body.map(e=>{let t={columns:[]},n=e;t.token=H(n);let r=[n.callee,...n.args];if(h(r)instanceof C){let e=N(r.pop()).getValue();t.pk=!!e[j.PK]?.length,t.unique=!!e[j.Unique]?.length,t.name=L(e[j.Name]?.at(0)?.value).unwrap_or(void 0);let n=e[j.Note]?.at(0);t.note=n&&{value:L(n.value).unwrap(),token:H(n)},t.type=F(e[j.Type]?.at(0)?.value).unwrap_or(void 0)}return r.flatMap(e=>{if(!(e instanceof w))return e;let t=[],n=e;for(;n instanceof w;)t.push(n.argumentList),n=n.callee;return t.push(n),t}).forEach(e=>{let{functional:n,nonFunctional:r}=Ru(e).unwrap();t.columns.push(...n.map(e=>({value:e.value.value,type:`expression`,token:H(e)})),...r.map(e=>({value:I(e).unwrap(),type:`column`,token:H(e)})))}),t})),[]}interpretChecks(e){return this.tablePartial.checks.push(...e.body.body.map(e=>{let t={},n=e;return t.token=H(n),n.args[0]instanceof C&&(t.name=L(N(n.args[0]).getValue()[j.Name]?.at(0)?.value).unwrap_or(void 0)),t.expression=n.callee.value.value,t})),[]}},tf=class{constructor(e,t){this.declarationNode=e,this.env=t,this.project={enums:[],refs:[],tableGroups:[],tables:[],tablePartials:[]}}interpret(){return this.env.project.set(this.declarationNode,this.project),this.project.token=H(this.declarationNode),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(e){if(!e)return this.project.name=null,[];let{name:t}=Bd(e);return this.project.name=t,[]}interpretBody(e){return e.body.flatMap(e=>{let t=e;switch(t.type?.value.toLowerCase()){case`table`:{let e=new Yd(t,this.env).interpret();return this.project.tables.push(this.env.tables.get(t)),e}case`ref`:{let e=new Zd(t,this.env).interpret();return this.project.refs.push(this.env.ref.get(t)),e}case`tablegroup`:{let e=new Qd(t,this.env).interpret();return this.project.tableGroups.push(this.env.tableGroups.get(t)),e}case`enum`:{let e=new $d(t,this.env).interpret();return this.project.enums.push(this.env.enums.get(t)),e}case`note`:return this.project.note={value:L(t.body instanceof S?t.body.body[0].callee:t.body.callee).map(Wd).unwrap(),token:H(t)},[];case`tablepartial`:{let e=new ef(t,this.env).interpret();return this.project.tablePartials.push(this.env.tablePartials.get(t)),e}default:return this.project[t.type.value.toLowerCase()]=L(t.body.callee).unwrap(),[]}})}},nf=class{constructor(e,t){this.declarationNode=e,this.env=t,this.diagramView={visibleEntities:{tables:null,stickyNotes:null,tableGroups:null,schemas:null}}}interpret(){let e=[];return this.diagramView.token=H(this.declarationNode),this.env.diagramViews.set(this.declarationNode,this.diagramView),this.env.diagramViewWildcards.set(this.diagramView,new Set),this.env.diagramViewExplicitlySet.set(this.diagramView,new Set),this.declarationNode.name&&e.push(...this.interpretName(this.declarationNode.name)),this.declarationNode.body instanceof S&&e.push(...this.interpretBody(this.declarationNode.body)),e}interpretName(e){let t=P(e).unwrap_or([]);return t.length>0&&(this.diagramView.name=t[t.length-1],t.length>1&&(this.diagramView.schemaName=t.slice(0,-1).join(`.`))),[]}interpretBody(e){if(e.body.length===1){let t=e.body[0];if(t instanceof x&&$u(t.callee))return this.diagramView.visibleEntities={tables:[],stickyNotes:[],tableGroups:[],schemas:[]},this.env.diagramViewWildcards.set(this.diagramView,new Set([`tables`,`stickyNotes`,`tableGroups`,`schemas`])),this.env.diagramViewExplicitlySet.set(this.diagramView,new Set([`tables`,`stickyNotes`,`tableGroups`,`schemas`])),[]}let[t]=g(e.body,e=>e instanceof b),n=new Set;for(let e of t){let t=e.type?.value.toLowerCase();t&&n.add(t),e.body instanceof S&&this.interpretSubBlock(e.body,t)}let r=this.diagramView.visibleEntities;(n.has(`tables`)&&r.tables!==null||n.has(`tablegroups`)&&r.tableGroups!==null||n.has(`schemas`)&&r.schemas!==null)&&(n.has(`tables`)||(r.tables=[]),n.has(`tablegroups`)||(r.tableGroups=[]),n.has(`schemas`)||(r.schemas=[]));let i=this.env.diagramViewExplicitlySet.get(this.diagramView);return n.has(`tables`)&&i.add(`tables`),n.has(`tablegroups`)&&i.add(`tableGroups`),n.has(`schemas`)&&i.add(`schemas`),n.has(`notes`)&&i.add(`stickyNotes`),[]}interpretSubBlock(e,t){if(!t)return;if(e.body.some(e=>e instanceof x&&$u(e.callee))){let e=this.env.diagramViewWildcards.get(this.diagramView);switch(t){case`tables`:this.diagramView.visibleEntities.tables=[],e.add(`tables`);break;case`notes`:this.diagramView.visibleEntities.stickyNotes=[],e.add(`stickyNotes`);break;case`tablegroups`:this.diagramView.visibleEntities.tableGroups=[],e.add(`tableGroups`);break;case`schemas`:this.diagramView.visibleEntities.schemas=[],e.add(`schemas`);break}return}if(e.body.length===0)return;let n=[];for(let t of e.body){if(!(t instanceof x))continue;let e=Bu(t.callee);if(e?.declaration instanceof b){let t=P(e.declaration.name).unwrap_or([]);if(t.length>0){let e=t[t.length-1],r=t.length>1?t.slice(0,-1).join(`.`):Gl;n.push({name:e,schemaName:r});continue}}let r=P(t.callee).unwrap_or([]);if(r.length===0)continue;let i=r[r.length-1],a=r.length>1?r[0]:Gl;n.push({name:i,schemaName:a})}switch(t){case`tables`:this.diagramView.visibleEntities.tables=n.length>0?n:null;break;case`notes`:this.diagramView.visibleEntities.stickyNotes=n.length>0?n.map(e=>({name:e.name})):null;break;case`tablegroups`:this.diagramView.visibleEntities.tableGroups=n.length>0?n.map(e=>({name:e.name})):null;break;case`schemas`:this.diagramView.visibleEntities.schemas=n.length>0?n.map(e=>({name:e.name})):null;break}}},rf={mysql:new Set([`int`,`integer`,`smallint`,`bigint`,`tinyint`,`mediumint`]),postgres:new Set([`int`,`integer`,`smallint`,`bigint`,`serial`,`bigserial`,`smallserial`]),mssql:new Set([`int`,`integer`,`smallint`,`bigint`,`tinyint`]),oracle:new Set([`int`,`integer`,`smallint`]),snowflake:new Set([`int`,`integer`,`smallint`,`bigint`,`tinyint`])},af={mysql:new Set([`decimal`,`numeric`,`float`,`double`,`real`]),postgres:new Set([`decimal`,`numeric`,`real`,`float`,`double precision`]),mssql:new Set([`decimal`,`numeric`,`real`,`float`]),oracle:new Set([`number`,`decimal`,`numeric`,`float`,`real`]),snowflake:new Set([`number`,`decimal`,`numeric`,`float`,`double`,`real`])},of={mysql:new Set([`bool`,`boolean`,`bit`]),postgres:new Set([`bool`,`boolean`]),mssql:new Set([`bit`]),oracle:new Set([]),snowflake:new Set([`boolean`])},sf={mysql:new Set([`varchar`,`char`,`text`,`tinytext`,`mediumtext`,`longtext`,`string`]),postgres:new Set([`varchar`,`char`,`character`,`character varying`,`text`,`string`]),mssql:new Set([`varchar`,`char`,`nvarchar`,`nchar`,`text`,`ntext`,`string`]),oracle:new Set([`varchar`,`varchar2`,`char`,`nvarchar2`,`nchar`,`string`]),snowflake:new Set([`varchar`,`char`,`text`,`string`])},cf={mysql:new Set([`binary`,`varbinary`,`blob`,`tinyblob`,`mediumblob`,`longblob`]),postgres:new Set([`bytea`]),mssql:new Set([`binary`,`varbinary`]),oracle:new Set([`blob`,`raw`]),snowflake:new Set([`binary`,`varbinary`])},lf={mysql:new Set([`date`,`datetime`,`timestamp`,`time`]),postgres:new Set([`date`,`timestamp`,`timestamptz`,`timestamp with time zone`,`timestamp without time zone`,`time`,`timetz`,`time with time zone`,`time without time zone`]),mssql:new Set([`date`,`datetime`,`datetime2`,`smalldatetime`,`time`]),oracle:new Set([`date`,`timestamp`,`timestamp with time zone`,`timestamp with local time zone`]),snowflake:new Set([`date`,`datetime`,`timestamp`,`time`])},uf={mysql:new Set([]),postgres:new Set([`serial`,`smallserial`,`bigserial`]),mssql:new Set([]),oracle:new Set([]),snowflake:new Set([])};function df(e){return e.toLowerCase().trim().replace(/\s+/g,` `)}function ff(e,t){let n=df(e);return t?rf[t].has(n):Object.values(rf).some(e=>e.has(n))}function pf(e,t){let n=df(e);return t?af[t].has(n):Object.values(af).some(e=>e.has(n))}function mf(e,t){return ff(e,t)||pf(e,t)}function hf(e,t){let n=df(e);return t?of[t].has(n):Object.values(of).some(e=>e.has(n))}function gf(e,t){let n=df(e);return t?sf[t].has(n):Object.values(sf).some(e=>e.has(n))}function _f(e,t){let n=df(e);return t?cf[t].has(n):Object.values(cf).some(e=>e.has(n))}function vf(e,t){let n=df(e);return t?lf[t].has(n):Object.values(lf).some(e=>e.has(n))}function yf(e,t){let n=df(e);return t?uf[t].has(n):Object.values(uf).some(e=>e.has(n))}function bf(e){let t=e.declaration;return t instanceof x&&t.args[0]||null}function xf(e){let t=bf(e);if(!(t instanceof w)||!t.argumentList||t.argumentList.elementList.length!==2)return{};let n=zu(t.argumentList.elementList[0]),r=zu(t.argumentList.elementList[1]);return n===null||r===null?{}:{precision:Math.trunc(n),scale:Math.trunc(r)}}function Sf(e){let t=bf(e);if(!(t instanceof w)||!t.argumentList||t.argumentList.elementList.length!==1)return{};let n=zu(t.argumentList.elementList[0]);return n===null?{}:{length:Math.trunc(n)}}function Cf(e,t){if(t)return`string`;if(ff(e))return`integer`;if(pf(e))return`real`;if(hf(e))return`bool`;if(gf(e))return`string`;let n=df(e);return n===`date`?`date`:n===`time`||n===`timetz`||n===`time with time zone`||n===`time without time zone`?`time`:vf(e)?`datetime`:e}var wf=class extends Error{},Tf=class extends wf{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}},Ef=class extends wf{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}},Df=class extends wf{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}},Of=class extends wf{},kf=class extends wf{constructor(e){super(`Invalid unit ${e}`)}},Af=class extends wf{},jf=class extends wf{constructor(){super(`Zone is an abstract class`)}},U=`numeric`,Mf=`short`,Nf=`long`,Pf={year:U,month:U,day:U},Ff={year:U,month:Mf,day:U},If={year:U,month:Mf,day:U,weekday:Mf},Lf={year:U,month:Nf,day:U},Rf={year:U,month:Nf,day:U,weekday:Nf},zf={hour:U,minute:U},Bf={hour:U,minute:U,second:U},Vf={hour:U,minute:U,second:U,timeZoneName:Mf},Hf={hour:U,minute:U,second:U,timeZoneName:Nf},Uf={hour:U,minute:U,hourCycle:`h23`},Wf={hour:U,minute:U,second:U,hourCycle:`h23`},Gf={hour:U,minute:U,second:U,hourCycle:`h23`,timeZoneName:Mf},Kf={hour:U,minute:U,second:U,hourCycle:`h23`,timeZoneName:Nf},qf={year:U,month:U,day:U,hour:U,minute:U},Jf={year:U,month:U,day:U,hour:U,minute:U,second:U},Yf={year:U,month:Mf,day:U,hour:U,minute:U},Xf={year:U,month:Mf,day:U,hour:U,minute:U,second:U},Zf={year:U,month:Mf,day:U,weekday:Mf,hour:U,minute:U},Qf={year:U,month:Nf,day:U,hour:U,minute:U,timeZoneName:Mf},$f={year:U,month:Nf,day:U,hour:U,minute:U,second:U,timeZoneName:Mf},ep={year:U,month:Nf,day:U,weekday:Nf,hour:U,minute:U,timeZoneName:Nf},tp={year:U,month:Nf,day:U,weekday:Nf,hour:U,minute:U,second:U,timeZoneName:Nf},np=class{get type(){throw new jf}get name(){throw new jf}get ianaName(){return this.name}get isUniversal(){throw new jf}offsetName(e,t){throw new jf}formatOffset(e,t){throw new jf}offset(e){throw new jf}equals(e){throw new jf}get isValid(){throw new jf}},rp=null,ip=class e extends np{static get instance(){return rp===null&&(rp=new e),rp}get type(){return`system`}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return Hm(e,t,n)}formatOffset(e,t){return Km(this.offset(e),t)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type===`system`}get isValid(){return!0}},ap=new Map;function op(e){let t=ap.get(e);return t===void 0&&(t=new Intl.DateTimeFormat(`en-US`,{hour12:!1,timeZone:e,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,era:`short`}),ap.set(e,t)),t}var sp={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function cp(e,t){let n=e.format(t).replace(/\u200E/g,``),[,r,i,a,o,s,c,l]=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(n);return[a,r,i,o,s,c,l]}function lp(e,t){let n=e.formatToParts(t),r=[];for(let e=0;e<n.length;e++){let{type:t,value:i}=n[e],a=sp[t];t===`era`?r[a]=i:K(a)||(r[a]=parseInt(i,10))}return r}var up=new Map,dp=class e extends np{static create(t){let n=up.get(t);return n===void 0&&up.set(t,n=new e(t)),n}static resetCache(){up.clear(),ap.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e}).format(),!0}catch{return!1}}constructor(t){super(),this.zoneName=t,this.valid=e.isValidZone(t)}get type(){return`iana`}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return Hm(e,t,n,this.name)}formatOffset(e,t){return Km(this.offset(e),t)}offset(e){if(!this.valid)return NaN;let t=new Date(e);if(isNaN(t))return NaN;let n=op(this.name),[r,i,a,o,s,c,l]=n.formatToParts?lp(n,t):cp(n,t);o===`BC`&&(r=-Math.abs(r)+1);let u=Rm({year:r,month:i,day:a,hour:s===24?0:s,minute:c,second:l,millisecond:0}),d=+t,f=d%1e3;return d-=f>=0?f:1e3+f,(u-d)/(60*1e3)}equals(e){return e.type===`iana`&&e.name===this.name}get isValid(){return this.valid}},fp={};function pp(e,t={}){let n=JSON.stringify([e,t]),r=fp[n];return r||(r=new Intl.ListFormat(e,t),fp[n]=r),r}var mp=new Map;function hp(e,t={}){let n=JSON.stringify([e,t]),r=mp.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),mp.set(n,r)),r}var gp=new Map;function _p(e,t={}){let n=JSON.stringify([e,t]),r=gp.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),gp.set(n,r)),r}var vp=new Map;function yp(e,t={}){let{base:n,...r}=t,i=JSON.stringify([e,r]),a=vp.get(i);return a===void 0&&(a=new Intl.RelativeTimeFormat(e,t),vp.set(i,a)),a}var bp=null;function xp(){return bp||(bp=new Intl.DateTimeFormat().resolvedOptions().locale,bp)}var Sp=new Map;function Cp(e){let t=Sp.get(e);return t===void 0&&(t=new Intl.DateTimeFormat(e).resolvedOptions(),Sp.set(e,t)),t}var wp=new Map;function Tp(e){let t=wp.get(e);if(!t){let n=new Intl.Locale(e);t=`getWeekInfo`in n?n.getWeekInfo():n.weekInfo,`minimalDays`in t||(t={...Fp,...t}),wp.set(e,t)}return t}function Ep(e){let t=e.indexOf(`-x-`);t!==-1&&(e=e.substring(0,t));let n=e.indexOf(`-u-`);if(n===-1)return[e];{let t,r;try{t=hp(e).resolvedOptions(),r=e}catch{let i=e.substring(0,n);t=hp(i).resolvedOptions(),r=i}let{numberingSystem:i,calendar:a}=t;return[r,i,a]}}function Dp(e,t,n){return n||t?(e.includes(`-u-`)||(e+=`-u`),n&&(e+=`-ca-${n}`),t&&(e+=`-nu-${t}`),e):e}function Op(e){let t=[];for(let n=1;n<=12;n++){let r=Y.utc(2009,n,1);t.push(e(r))}return t}function kp(e){let t=[];for(let n=1;n<=7;n++){let r=Y.utc(2016,11,13+n);t.push(e(r))}return t}function Ap(e,t,n,r){let i=e.listingMode();return i===`error`?null:i===`en`?n(t):r(t)}function jp(e){return e.numberingSystem&&e.numberingSystem!==`latn`?!1:e.numberingSystem===`latn`||!e.locale||e.locale.startsWith(`en`)||Cp(e.locale).numberingSystem===`latn`}var Mp=class{constructor(e,t,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;let{padTo:r,floor:i,...a}=n;if(!t||Object.keys(a).length>0){let t={useGrouping:!1,...n};n.padTo>0&&(t.minimumIntegerDigits=n.padTo),this.inf=_p(e,t)}}format(e){if(this.inf){let t=this.floor?Math.floor(e):e;return this.inf.format(t)}else return q(this.floor?Math.floor(e):Pm(e,3),this.padTo)}},Np=class{constructor(e,t,n){this.opts=n,this.originalZone=void 0;let r;if(this.opts.timeZone)this.dt=e;else if(e.zone.type===`fixed`){let t=-1*(e.offset/60),n=t>=0?`Etc/GMT+${t}`:`Etc/GMT${t}`;e.offset!==0&&dp.create(n).valid?(r=n,this.dt=e):(r=`UTC`,this.dt=e.offset===0?e:e.setZone(`UTC`).plus({minutes:e.offset}),this.originalZone=e.zone)}else e.zone.type===`system`?this.dt=e:e.zone.type===`iana`?(this.dt=e,r=e.zone.name):(r=`UTC`,this.dt=e.setZone(`UTC`).plus({minutes:e.offset}),this.originalZone=e.zone);let i={...this.opts};i.timeZone=i.timeZone||r,this.dtf=hp(t,i)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(``):this.dtf.format(this.dt.toJSDate())}formatToParts(){let e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(e=>{if(e.type===`timeZoneName`){let t=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...e,value:t}}else return e}):e}resolvedOptions(){return this.dtf.resolvedOptions()}},Pp=class{constructor(e,t,n){this.opts={style:`long`,...n},!t&&Sm()&&(this.rtf=yp(e,n))}format(e,t){return this.rtf?this.rtf.format(e,t):dh(t,e,this.opts.numeric,this.opts.style!==`long`)}formatToParts(e,t){return this.rtf?this.rtf.formatToParts(e,t):[]}},Fp={firstDay:1,minimalDays:4,weekend:[6,7]},W=class e{static fromOpts(t){return e.create(t.locale,t.numberingSystem,t.outputCalendar,t.weekSettings,t.defaultToEN)}static create(t,n,r,i,a=!1){let o=t||G.defaultLocale;return new e(o||(a?`en-US`:xp()),n||G.defaultNumberingSystem,r||G.defaultOutputCalendar,Om(i)||G.defaultWeekSettings,o)}static resetCache(){bp=null,mp.clear(),gp.clear(),vp.clear(),Sp.clear(),wp.clear()}static fromObject({locale:t,numberingSystem:n,outputCalendar:r,weekSettings:i}={}){return e.create(t,n,r,i)}constructor(e,t,n,r,i){let[a,o,s]=Ep(e);this.locale=a,this.numberingSystem=t||o||null,this.outputCalendar=n||s||null,this.weekSettings=r,this.intl=Dp(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=i,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached??=jp(this),this.fastNumbersCached}listingMode(){let e=this.isEnglish(),t=(this.numberingSystem===null||this.numberingSystem===`latn`)&&(this.outputCalendar===null||this.outputCalendar===`gregory`);return e&&t?`en`:`intl`}clone(t){return!t||Object.getOwnPropertyNames(t).length===0?this:e.create(t.locale||this.specifiedLocale,t.numberingSystem||this.numberingSystem,t.outputCalendar||this.outputCalendar,Om(t.weekSettings)||this.weekSettings,t.defaultToEN||!1)}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,t=!1){return Ap(this,e,Zm,()=>{let n=this.intl===`ja`||this.intl.startsWith(`ja-`);t&=!n;let r=t?{month:e,day:`numeric`}:{month:e},i=t?`format`:`standalone`;if(!this.monthsCache[i][e]){let t=n?e=>this.dtFormatter(e,r).format():e=>this.extract(e,r,`month`);this.monthsCache[i][e]=Op(t)}return this.monthsCache[i][e]})}weekdays(e,t=!1){return Ap(this,e,th,()=>{let n=t?{weekday:e,year:`numeric`,month:`long`,day:`numeric`}:{weekday:e},r=t?`format`:`standalone`;return this.weekdaysCache[r][e]||(this.weekdaysCache[r][e]=kp(e=>this.extract(e,n,`weekday`))),this.weekdaysCache[r][e]})}meridiems(){return Ap(this,void 0,()=>nh,()=>{if(!this.meridiemCache){let e={hour:`numeric`,hourCycle:`h12`};this.meridiemCache=[Y.utc(2016,11,13,9),Y.utc(2016,11,13,19)].map(t=>this.extract(t,e,`dayperiod`))}return this.meridiemCache})}eras(e){return Ap(this,e,oh,()=>{let t={era:e};return this.eraCache[e]||(this.eraCache[e]=[Y.utc(-40,1,1),Y.utc(2017,1,1)].map(e=>this.extract(e,t,`era`))),this.eraCache[e]})}extract(e,t,n){let r=this.dtFormatter(e,t).formatToParts().find(e=>e.type.toLowerCase()===n);return r?r.value:null}numberFormatter(e={}){return new Mp(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,t={}){return new Np(e,this.intl,t)}relFormatter(e={}){return new Pp(this.intl,this.isEnglish(),e)}listFormatter(e={}){return pp(this.intl,e)}isEnglish(){return this.locale===`en`||this.locale.toLowerCase()===`en-us`||Cp(this.intl).locale.startsWith(`en-us`)}getWeekSettings(){return this.weekSettings?this.weekSettings:Cm()?Tp(this.locale):Fp}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}},Ip=null,Lp=class e extends np{static get utcInstance(){return Ip===null&&(Ip=new e(0)),Ip}static instance(t){return t===0?e.utcInstance:new e(t)}static parseSpecifier(t){if(t){let n=t.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(n)return new e(Um(n[1],n[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return`fixed`}get name(){return this.fixed===0?`UTC`:`UTC${Km(this.fixed,`narrow`)}`}get ianaName(){return this.fixed===0?`Etc/UTC`:`Etc/GMT${Km(-this.fixed,`narrow`)}`}offsetName(){return this.name}formatOffset(e,t){return Km(this.fixed,t)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return e.type===`fixed`&&e.fixed===this.fixed}get isValid(){return!0}},Rp=class extends np{constructor(e){super(),this.zoneName=e}get type(){return`invalid`}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return``}offset(){return NaN}equals(){return!1}get isValid(){return!1}};function zp(e,t){if(K(e)||e===null)return t;if(e instanceof np)return e;if(bm(e)){let n=e.toLowerCase();return n===`default`?t:n===`local`||n===`system`?ip.instance:n===`utc`||n===`gmt`?Lp.utcInstance:Lp.parseSpecifier(n)||dp.create(e)}else if(vm(e))return Lp.instance(e);else if(typeof e==`object`&&`offset`in e&&typeof e.offset==`function`)return e;else return new Rp(e)}var Bp={arab:`[٠-٩]`,arabext:`[۰-۹]`,bali:`[᭐-᭙]`,beng:`[০-৯]`,deva:`[०-९]`,fullwide:`[0-9]`,gujr:`[૦-૯]`,hanidec:`[〇|一|二|三|四|五|六|七|八|九]`,khmr:`[០-៩]`,knda:`[೦-೯]`,laoo:`[໐-໙]`,limb:`[᥆-᥏]`,mlym:`[൦-൯]`,mong:`[᠐-᠙]`,mymr:`[၀-၉]`,orya:`[୦-୯]`,tamldec:`[௦-௯]`,telu:`[౦-౯]`,thai:`[๐-๙]`,tibt:`[༠-༩]`,latn:`\\d`},Vp={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},Hp=Bp.hanidec.replace(/[\[|\]]/g,``).split(``);function Up(e){let t=parseInt(e,10);if(isNaN(t)){t=``;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(e[n].search(Bp.hanidec)!==-1)t+=Hp.indexOf(e[n]);else for(let e in Vp){let[n,i]=Vp[e];r>=n&&r<=i&&(t+=r-n)}}return parseInt(t,10)}else return t}var Wp=new Map;function Gp(){Wp.clear()}function Kp({numberingSystem:e},t=``){let n=e||`latn`,r=Wp.get(n);r===void 0&&(r=new Map,Wp.set(n,r));let i=r.get(t);return i===void 0&&(i=RegExp(`${Bp[n]}${t}`),r.set(t,i)),i}var qp=()=>Date.now(),Jp=`system`,Yp=null,Xp=null,Zp=null,Qp=60,$p,em=null,G=class{static get now(){return qp}static set now(e){qp=e}static set defaultZone(e){Jp=e}static get defaultZone(){return zp(Jp,ip.instance)}static get defaultLocale(){return Yp}static set defaultLocale(e){Yp=e}static get defaultNumberingSystem(){return Xp}static set defaultNumberingSystem(e){Xp=e}static get defaultOutputCalendar(){return Zp}static set defaultOutputCalendar(e){Zp=e}static get defaultWeekSettings(){return em}static set defaultWeekSettings(e){em=Om(e)}static get twoDigitCutoffYear(){return Qp}static set twoDigitCutoffYear(e){Qp=e%100}static get throwOnInvalid(){return $p}static set throwOnInvalid(e){$p=e}static resetCaches(){W.resetCache(),dp.resetCache(),Y.resetCache(),Gp()}},tm=class{constructor(e,t){this.reason=e,this.explanation=t}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}},nm=[0,31,59,90,120,151,181,212,243,273,304,334],rm=[0,31,60,91,121,152,182,213,244,274,305,335];function im(e,t){return new tm(`unit out of range`,`you specified ${t} (of type ${typeof t}) as a ${e}, which is invalid`)}function am(e,t,n){let r=new Date(Date.UTC(e,t-1,n));e<100&&e>=0&&r.setUTCFullYear(r.getUTCFullYear()-1900);let i=r.getUTCDay();return i===0?7:i}function om(e,t,n){return n+(Fm(e)?rm:nm)[t-1]}function sm(e,t){let n=Fm(e)?rm:nm,r=n.findIndex(e=>e<t),i=t-n[r];return{month:r+1,day:i}}function cm(e,t){return(e-t+7)%7+1}function lm(e,t=4,n=1){let{year:r,month:i,day:a}=e,o=om(r,i,a),s=cm(am(r,i,a),n),c=Math.floor((o-s+14-t)/7),l;return c<1?(l=r-1,c=Bm(l,t,n)):c>Bm(r,t,n)?(l=r+1,c=1):l=r,{weekYear:l,weekNumber:c,weekday:s,...qm(e)}}function um(e,t=4,n=1){let{weekYear:r,weekNumber:i,weekday:a}=e,o=cm(am(r,1,t),n),s=Im(r),c=i*7+a-o-7+t,l;c<1?(l=r-1,c+=Im(l)):c>s?(l=r+1,c-=Im(r)):l=r;let{month:u,day:d}=sm(l,c);return{year:l,month:u,day:d,...qm(e)}}function dm(e){let{year:t,month:n,day:r}=e;return{year:t,ordinal:om(t,n,r),...qm(e)}}function fm(e){let{year:t,ordinal:n}=e,{month:r,day:i}=sm(t,n);return{year:t,month:r,day:i,...qm(e)}}function pm(e,t){if(!K(e.localWeekday)||!K(e.localWeekNumber)||!K(e.localWeekYear)){if(!K(e.weekday)||!K(e.weekNumber)||!K(e.weekYear))throw new Of(`Cannot mix locale-based week fields with ISO-based week fields`);return K(e.localWeekday)||(e.weekday=e.localWeekday),K(e.localWeekNumber)||(e.weekNumber=e.localWeekNumber),K(e.localWeekYear)||(e.weekYear=e.localWeekYear),delete e.localWeekday,delete e.localWeekNumber,delete e.localWeekYear,{minDaysInFirstWeek:t.getMinDaysInFirstWeek(),startOfWeek:t.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function mm(e,t=4,n=1){let r=ym(e.weekYear),i=km(e.weekNumber,1,Bm(e.weekYear,t,n)),a=km(e.weekday,1,7);return r?i?a?!1:im(`weekday`,e.weekday):im(`week`,e.weekNumber):im(`weekYear`,e.weekYear)}function hm(e){let t=ym(e.year),n=km(e.ordinal,1,Im(e.year));return t?n?!1:im(`ordinal`,e.ordinal):im(`year`,e.year)}function gm(e){let t=ym(e.year),n=km(e.month,1,12),r=km(e.day,1,Lm(e.year,e.month));return t?n?r?!1:im(`day`,e.day):im(`month`,e.month):im(`year`,e.year)}function _m(e){let{hour:t,minute:n,second:r,millisecond:i}=e,a=km(t,0,23)||t===24&&n===0&&r===0&&i===0,o=km(n,0,59),s=km(r,0,59),c=km(i,0,999);return a?o?s?c?!1:im(`millisecond`,i):im(`second`,r):im(`minute`,n):im(`hour`,t)}function K(e){return e===void 0}function vm(e){return typeof e==`number`}function ym(e){return typeof e==`number`&&e%1==0}function bm(e){return typeof e==`string`}function xm(e){return Object.prototype.toString.call(e)===`[object Date]`}function Sm(){try{return typeof Intl<`u`&&!!Intl.RelativeTimeFormat}catch{return!1}}function Cm(){try{return typeof Intl<`u`&&!!Intl.Locale&&(`weekInfo`in Intl.Locale.prototype||`getWeekInfo`in Intl.Locale.prototype)}catch{return!1}}function wm(e){return Array.isArray(e)?e:[e]}function Tm(e,t,n){if(e.length!==0)return e.reduce((e,r)=>{let i=[t(r),r];return e&&n(e[0],i[0])===e[0]?e:i},null)[1]}function Em(e,t){return t.reduce((t,n)=>(t[n]=e[n],t),{})}function Dm(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Om(e){if(e==null)return null;if(typeof e!=`object`)throw new Af(`Week settings must be an object`);if(!km(e.firstDay,1,7)||!km(e.minimalDays,1,7)||!Array.isArray(e.weekend)||e.weekend.some(e=>!km(e,1,7)))throw new Af(`Invalid week settings`);return{firstDay:e.firstDay,minimalDays:e.minimalDays,weekend:Array.from(e.weekend)}}function km(e,t,n){return ym(e)&&e>=t&&e<=n}function Am(e,t){return e-t*Math.floor(e/t)}function q(e,t=2){let n=e<0,r;return r=n?`-`+(``+-e).padStart(t,`0`):(``+e).padStart(t,`0`),r}function jm(e){if(!(K(e)||e===null||e===``))return parseInt(e,10)}function Mm(e){if(!(K(e)||e===null||e===``))return parseFloat(e)}function Nm(e){if(!(K(e)||e===null||e===``)){let t=parseFloat(`0.`+e)*1e3;return Math.floor(t)}}function Pm(e,t,n=`round`){let r=10**t;switch(n){case`expand`:return e>0?Math.ceil(e*r)/r:Math.floor(e*r)/r;case`trunc`:return Math.trunc(e*r)/r;case`round`:return Math.round(e*r)/r;case`floor`:return Math.floor(e*r)/r;case`ceil`:return Math.ceil(e*r)/r;default:throw RangeError(`Value rounding ${n} is out of range`)}}function Fm(e){return e%4==0&&(e%100!=0||e%400==0)}function Im(e){return Fm(e)?366:365}function Lm(e,t){let n=Am(t-1,12)+1,r=e+(t-n)/12;return n===2?Fm(r)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function Rm(e){let t=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond);return e.year<100&&e.year>=0&&(t=new Date(t),t.setUTCFullYear(e.year,e.month-1,e.day)),+t}function zm(e,t,n){return-cm(am(e,1,t),n)+t-1}function Bm(e,t=4,n=1){let r=zm(e,t,n),i=zm(e+1,t,n);return(Im(e)-r+i)/7}function Vm(e){return e>99?e:e>G.twoDigitCutoffYear?1900+e:2e3+e}function Hm(e,t,n,r=null){let i=new Date(e),a={hourCycle:`h23`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`};r&&(a.timeZone=r);let o={timeZoneName:t,...a},s=new Intl.DateTimeFormat(n,o).formatToParts(i).find(e=>e.type.toLowerCase()===`timezonename`);return s?s.value:null}function Um(e,t){let n=parseInt(e,10);Number.isNaN(n)&&(n=0);let r=parseInt(t,10)||0,i=n<0||Object.is(n,-0)?-r:r;return n*60+i}function Wm(e){let t=Number(e);if(typeof e==`boolean`||e===``||!Number.isFinite(t))throw new Af(`Invalid unit value ${e}`);return t}function Gm(e,t){let n={};for(let r in e)if(Dm(e,r)){let i=e[r];if(i==null)continue;n[t(r)]=Wm(i)}return n}function Km(e,t){let n=Math.trunc(Math.abs(e/60)),r=Math.trunc(Math.abs(e%60)),i=e>=0?`+`:`-`;switch(t){case`short`:return`${i}${q(n,2)}:${q(r,2)}`;case`narrow`:return`${i}${n}${r>0?`:${r}`:``}`;case`techie`:return`${i}${q(n,2)}${q(r,2)}`;default:throw RangeError(`Value format ${t} is out of range for property format`)}}function qm(e){return Em(e,[`hour`,`minute`,`second`,`millisecond`])}var Jm=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],Ym=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],Xm=[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`];function Zm(e){switch(e){case`narrow`:return[...Xm];case`short`:return[...Ym];case`long`:return[...Jm];case`numeric`:return[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`11`,`12`];case`2-digit`:return[`01`,`02`,`03`,`04`,`05`,`06`,`07`,`08`,`09`,`10`,`11`,`12`];default:return null}}var Qm=[`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`],$m=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],eh=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function th(e){switch(e){case`narrow`:return[...eh];case`short`:return[...$m];case`long`:return[...Qm];case`numeric`:return[`1`,`2`,`3`,`4`,`5`,`6`,`7`];default:return null}}var nh=[`AM`,`PM`],rh=[`Before Christ`,`Anno Domini`],ih=[`BC`,`AD`],ah=[`B`,`A`];function oh(e){switch(e){case`narrow`:return[...ah];case`short`:return[...ih];case`long`:return[...rh];default:return null}}function sh(e){return nh[e.hour<12?0:1]}function ch(e,t){return th(t)[e.weekday-1]}function lh(e,t){return Zm(t)[e.month-1]}function uh(e,t){return oh(t)[e.year<0?0:1]}function dh(e,t,n=`always`,r=!1){let i={years:[`year`,`yr.`],quarters:[`quarter`,`qtr.`],months:[`month`,`mo.`],weeks:[`week`,`wk.`],days:[`day`,`day`,`days`],hours:[`hour`,`hr.`],minutes:[`minute`,`min.`],seconds:[`second`,`sec.`]},a=[`hours`,`minutes`,`seconds`].indexOf(e)===-1;if(n===`auto`&&a){let n=e===`days`;switch(t){case 1:return n?`tomorrow`:`next ${i[e][0]}`;case-1:return n?`yesterday`:`last ${i[e][0]}`;case 0:return n?`today`:`this ${i[e][0]}`}}let o=Object.is(t,-0)||t<0,s=Math.abs(t),c=s===1,l=i[e],u=r?c?l[1]:l[2]||l[1]:c?i[e][0]:e;return o?`${s} ${u} ago`:`in ${s} ${u}`}function fh(e,t){let n=``;for(let r of e)r.literal?n+=r.val:n+=t(r.val);return n}var ph={D:Pf,DD:Ff,DDD:Lf,DDDD:Rf,t:zf,tt:Bf,ttt:Vf,tttt:Hf,T:Uf,TT:Wf,TTT:Gf,TTTT:Kf,f:qf,ff:Yf,fff:Qf,ffff:ep,F:Jf,FF:Xf,FFF:$f,FFFF:tp},mh=class e{static create(t,n={}){return new e(t,n)}static parseFormat(e){let t=null,n=``,r=!1,i=[];for(let a=0;a<e.length;a++){let o=e.charAt(a);o===`'`?((n.length>0||r)&&i.push({literal:r||/^\s+$/.test(n),val:n===``?`'`:n}),t=null,n=``,r=!r):r||o===t?n+=o:(n.length>0&&i.push({literal:/^\s+$/.test(n),val:n}),n=o,t=o)}return n.length>0&&i.push({literal:r||/^\s+$/.test(n),val:n}),i}static macroTokenToFormatOpts(e){return ph[e]}constructor(e,t){this.opts=t,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,t){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...t}).format()}dtFormatter(e,t={}){return this.loc.dtFormatter(e,{...this.opts,...t})}formatDateTime(e,t){return this.dtFormatter(e,t).format()}formatDateTimeParts(e,t){return this.dtFormatter(e,t).formatToParts()}formatInterval(e,t){return this.dtFormatter(e.start,t).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,t){return this.dtFormatter(e,t).resolvedOptions()}num(e,t=0,n=void 0){if(this.opts.forceSimple)return q(e,t);let r={...this.opts};return t>0&&(r.padTo=t),n&&(r.signDisplay=n),this.loc.numberFormatter(r).format(e)}formatDateTimeFromString(t,n){let r=this.loc.listingMode()===`en`,i=this.loc.outputCalendar&&this.loc.outputCalendar!==`gregory`,a=(e,n)=>this.loc.extract(t,e,n),o=e=>t.isOffsetFixed&&t.offset===0&&e.allowZ?`Z`:t.isValid?t.zone.formatOffset(t.ts,e.format):``,s=()=>r?sh(t):a({hour:`numeric`,hourCycle:`h12`},`dayperiod`),c=(e,n)=>r?lh(t,e):a(n?{month:e}:{month:e,day:`numeric`},`month`),l=(e,n)=>r?ch(t,e):a(n?{weekday:e}:{weekday:e,month:`long`,day:`numeric`},`weekday`),u=n=>{let r=e.macroTokenToFormatOpts(n);return r?this.formatWithSystemDefault(t,r):n},d=e=>r?uh(t,e):a({era:e},`era`);return fh(e.parseFormat(n),e=>{switch(e){case`S`:return this.num(t.millisecond);case`u`:case`SSS`:return this.num(t.millisecond,3);case`s`:return this.num(t.second);case`ss`:return this.num(t.second,2);case`uu`:return this.num(Math.floor(t.millisecond/10),2);case`uuu`:return this.num(Math.floor(t.millisecond/100));case`m`:return this.num(t.minute);case`mm`:return this.num(t.minute,2);case`h`:return this.num(t.hour%12==0?12:t.hour%12);case`hh`:return this.num(t.hour%12==0?12:t.hour%12,2);case`H`:return this.num(t.hour);case`HH`:return this.num(t.hour,2);case`Z`:return o({format:`narrow`,allowZ:this.opts.allowZ});case`ZZ`:return o({format:`short`,allowZ:this.opts.allowZ});case`ZZZ`:return o({format:`techie`,allowZ:this.opts.allowZ});case`ZZZZ`:return t.zone.offsetName(t.ts,{format:`short`,locale:this.loc.locale});case`ZZZZZ`:return t.zone.offsetName(t.ts,{format:`long`,locale:this.loc.locale});case`z`:return t.zoneName;case`a`:return s();case`d`:return i?a({day:`numeric`},`day`):this.num(t.day);case`dd`:return i?a({day:`2-digit`},`day`):this.num(t.day,2);case`c`:return this.num(t.weekday);case`ccc`:return l(`short`,!0);case`cccc`:return l(`long`,!0);case`ccccc`:return l(`narrow`,!0);case`E`:return this.num(t.weekday);case`EEE`:return l(`short`,!1);case`EEEE`:return l(`long`,!1);case`EEEEE`:return l(`narrow`,!1);case`L`:return i?a({month:`numeric`,day:`numeric`},`month`):this.num(t.month);case`LL`:return i?a({month:`2-digit`,day:`numeric`},`month`):this.num(t.month,2);case`LLL`:return c(`short`,!0);case`LLLL`:return c(`long`,!0);case`LLLLL`:return c(`narrow`,!0);case`M`:return i?a({month:`numeric`},`month`):this.num(t.month);case`MM`:return i?a({month:`2-digit`},`month`):this.num(t.month,2);case`MMM`:return c(`short`,!1);case`MMMM`:return c(`long`,!1);case`MMMMM`:return c(`narrow`,!1);case`y`:return i?a({year:`numeric`},`year`):this.num(t.year);case`yy`:return i?a({year:`2-digit`},`year`):this.num(t.year.toString().slice(-2),2);case`yyyy`:return i?a({year:`numeric`},`year`):this.num(t.year,4);case`yyyyyy`:return i?a({year:`numeric`},`year`):this.num(t.year,6);case`G`:return d(`short`);case`GG`:return d(`long`);case`GGGGG`:return d(`narrow`);case`kk`:return this.num(t.weekYear.toString().slice(-2),2);case`kkkk`:return this.num(t.weekYear,4);case`W`:return this.num(t.weekNumber);case`WW`:return this.num(t.weekNumber,2);case`n`:return this.num(t.localWeekNumber);case`nn`:return this.num(t.localWeekNumber,2);case`ii`:return this.num(t.localWeekYear.toString().slice(-2),2);case`iiii`:return this.num(t.localWeekYear,4);case`o`:return this.num(t.ordinal);case`ooo`:return this.num(t.ordinal,3);case`q`:return this.num(t.quarter);case`qq`:return this.num(t.quarter,2);case`X`:return this.num(Math.floor(t.ts/1e3));case`x`:return this.num(t.ts);default:return u(e)}})}formatDurationFromString(t,n){let r=this.opts.signMode===`negativeLargestOnly`?-1:1,i=e=>{switch(e[0]){case`S`:return`milliseconds`;case`s`:return`seconds`;case`m`:return`minutes`;case`h`:return`hours`;case`d`:return`days`;case`w`:return`weeks`;case`M`:return`months`;case`y`:return`years`;default:return null}},a=(e,t)=>n=>{let a=i(n);if(a){let i=t.isNegativeDuration&&a!==t.largestUnit?r:1,o;return o=this.opts.signMode===`negativeLargestOnly`&&a!==t.largestUnit?`never`:this.opts.signMode===`all`?`always`:`auto`,this.num(e.get(a)*i,n.length,o)}else return n},o=e.parseFormat(n),s=o.reduce((e,{literal:t,val:n})=>t?e:e.concat(n),[]),c=t.shiftTo(...s.map(i).filter(e=>e));return fh(o,a(c,{isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]}))}},hh=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function gh(...e){let t=e.reduce((e,t)=>e+t.source,``);return RegExp(`^${t}$`)}function _h(...e){return t=>e.reduce(([e,n,r],i)=>{let[a,o,s]=i(t,r);return[{...e,...a},o||n,s]},[{},null,1]).slice(0,2)}function vh(e,...t){if(e==null)return[null,null];for(let[n,r]of t){let t=n.exec(e);if(t)return r(t)}return[null,null]}function yh(...e){return(t,n)=>{let r={},i;for(i=0;i<e.length;i++)r[e[i]]=jm(t[n+i]);return[r,null,n+i]}}var bh=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,xh=`(?:${bh.source}?(?:\\[(${hh.source})\\])?)?`,Sh=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Ch=RegExp(`${Sh.source}${xh}`),wh=RegExp(`(?:[Tt]${Ch.source})?`),Th=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,Eh=/(\d{4})-?W(\d\d)(?:-?(\d))?/,Dh=/(\d{4})-?(\d{3})/,Oh=yh(`weekYear`,`weekNumber`,`weekDay`),kh=yh(`year`,`ordinal`),Ah=/(\d{4})-(\d\d)-(\d\d)/,jh=RegExp(`${Sh.source} ?(?:${bh.source}|(${hh.source}))?`),Mh=RegExp(`(?: ${jh.source})?`);function Nh(e,t,n){let r=e[t];return K(r)?n:jm(r)}function Ph(e,t){return[{year:Nh(e,t),month:Nh(e,t+1,1),day:Nh(e,t+2,1)},null,t+3]}function Fh(e,t){return[{hours:Nh(e,t,0),minutes:Nh(e,t+1,0),seconds:Nh(e,t+2,0),milliseconds:Nm(e[t+3])},null,t+4]}function Ih(e,t){let n=!e[t]&&!e[t+1],r=Um(e[t+1],e[t+2]);return[{},n?null:Lp.instance(r),t+3]}function Lh(e,t){return[{},e[t]?dp.create(e[t]):null,t+1]}var Rh=RegExp(`^T?${Sh.source}$`),zh=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function Bh(e){let[t,n,r,i,a,o,s,c,l]=e,u=t[0]===`-`,d=c&&c[0]===`-`,f=(e,t=!1)=>e!==void 0&&(t||e&&u)?-e:e;return[{years:f(Mm(n)),months:f(Mm(r)),weeks:f(Mm(i)),days:f(Mm(a)),hours:f(Mm(o)),minutes:f(Mm(s)),seconds:f(Mm(c),c===`-0`),milliseconds:f(Nm(l),d)}]}var Vh={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Hh(e,t,n,r,i,a,o){let s={year:t.length===2?Vm(jm(t)):jm(t),month:Ym.indexOf(n)+1,day:jm(r),hour:jm(i),minute:jm(a)};return o&&(s.second=jm(o)),e&&(s.weekday=e.length>3?Qm.indexOf(e)+1:$m.indexOf(e)+1),s}var Uh=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function Wh(e){let[,t,n,r,i,a,o,s,c,l,u,d]=e,f=Hh(t,i,r,n,a,o,s),ee;return ee=c?Vh[c]:l?0:Um(u,d),[f,new Lp(ee)]}function Gh(e){return e.replace(/\([^()]*\)|[\n\t]/g,` `).replace(/(\s\s+)/g,` `).trim()}var Kh=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,qh=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,Jh=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function Yh(e){let[,t,n,r,i,a,o,s]=e;return[Hh(t,i,r,n,a,o,s),Lp.utcInstance]}function Xh(e){let[,t,n,r,i,a,o,s]=e;return[Hh(t,s,n,r,i,a,o),Lp.utcInstance]}var Zh=gh(Th,wh),Qh=gh(Eh,wh),$h=gh(Dh,wh),eg=gh(Ch),tg=_h(Ph,Fh,Ih,Lh),ng=_h(Oh,Fh,Ih,Lh),rg=_h(kh,Fh,Ih,Lh),ig=_h(Fh,Ih,Lh);function ag(e){return vh(e,[Zh,tg],[Qh,ng],[$h,rg],[eg,ig])}function og(e){return vh(Gh(e),[Uh,Wh])}function sg(e){return vh(e,[Kh,Yh],[qh,Yh],[Jh,Xh])}function cg(e){return vh(e,[zh,Bh])}var lg=_h(Fh);function ug(e){return vh(e,[Rh,lg])}var dg=gh(Ah,Mh),fg=gh(jh),pg=_h(Fh,Ih,Lh);function mg(e){return vh(e,[dg,tg],[fg,pg])}var hg=`Invalid Duration`,gg={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},_g={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...gg},vg=146097/400,yg=146097/4800,bg={years:{quarters:4,months:12,weeks:vg/7,days:vg,hours:vg*24,minutes:vg*24*60,seconds:vg*24*60*60,milliseconds:vg*24*60*60*1e3},quarters:{months:3,weeks:vg/28,days:vg/4,hours:vg*24/4,minutes:vg*24*60/4,seconds:vg*24*60*60/4,milliseconds:vg*24*60*60*1e3/4},months:{weeks:yg/7,days:yg,hours:yg*24,minutes:yg*24*60,seconds:yg*24*60*60,milliseconds:yg*24*60*60*1e3},...gg},xg=[`years`,`quarters`,`months`,`weeks`,`days`,`hours`,`minutes`,`seconds`,`milliseconds`],Sg=xg.slice(0).reverse();function Cg(e,t,n=!1){return new Dg({values:n?t.values:{...e.values,...t.values||{}},loc:e.loc.clone(t.loc),conversionAccuracy:t.conversionAccuracy||e.conversionAccuracy,matrix:t.matrix||e.matrix})}function wg(e,t){let n=t.milliseconds??0;for(let r of Sg.slice(1))t[r]&&(n+=t[r]*e[r].milliseconds);return n}function Tg(e,t){let n=wg(e,t)<0?-1:1;xg.reduceRight((r,i)=>{if(K(t[i]))return r;if(r){let a=t[r]*n,o=e[i][r],s=Math.floor(a/o);t[i]+=s*n,t[r]-=s*o*n}return i},null),xg.reduce((n,r)=>{if(K(t[r]))return n;if(n){let i=t[n]%1;t[n]-=i,t[r]+=i*e[n][r]}return r},null)}function Eg(e){let t={};for(let[n,r]of Object.entries(e))r!==0&&(t[n]=r);return t}var Dg=class e{constructor(e){let t=e.conversionAccuracy===`longterm`||!1,n=t?bg:_g;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||W.create(),this.conversionAccuracy=t?`longterm`:`casual`,this.invalid=e.invalid||null,this.matrix=n,this.isLuxonDuration=!0}static fromMillis(t,n){return e.fromObject({milliseconds:t},n)}static fromObject(t,n={}){if(typeof t!=`object`||!t)throw new Af(`Duration.fromObject: argument expected to be an object, got ${t===null?`null`:typeof t}`);return new e({values:Gm(t,e.normalizeUnit),loc:W.fromObject(n),conversionAccuracy:n.conversionAccuracy,matrix:n.matrix})}static fromDurationLike(t){if(vm(t))return e.fromMillis(t);if(e.isDuration(t))return t;if(typeof t==`object`)return e.fromObject(t);throw new Af(`Unknown duration argument ${t} of type ${typeof t}`)}static fromISO(t,n){let[r]=cg(t);return r?e.fromObject(r,n):e.invalid(`unparsable`,`the input "${t}" can't be parsed as ISO 8601`)}static fromISOTime(t,n){let[r]=ug(t);return r?e.fromObject(r,n):e.invalid(`unparsable`,`the input "${t}" can't be parsed as ISO 8601`)}static invalid(t,n=null){if(!t)throw new Af(`need to specify a reason the Duration is invalid`);let r=t instanceof tm?t:new tm(t,n);if(G.throwOnInvalid)throw new Df(r);return new e({invalid:r})}static normalizeUnit(e){let t={year:`years`,years:`years`,quarter:`quarters`,quarters:`quarters`,month:`months`,months:`months`,week:`weeks`,weeks:`weeks`,day:`days`,days:`days`,hour:`hours`,hours:`hours`,minute:`minutes`,minutes:`minutes`,second:`seconds`,seconds:`seconds`,millisecond:`milliseconds`,milliseconds:`milliseconds`}[e&&e.toLowerCase()];if(!t)throw new kf(e);return t}static isDuration(e){return e&&e.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,t={}){let n={...t,floor:t.round!==!1&&t.floor!==!1};return this.isValid?mh.create(this.loc,n).formatDurationFromString(this,e):hg}toHuman(e={}){if(!this.isValid)return hg;let t=e.showZeros!==!1,n=xg.map(n=>{let r=this.values[n];return K(r)||r===0&&!t?null:this.loc.numberFormatter({style:`unit`,unitDisplay:`long`,...e,unit:n.slice(0,-1)}).format(r)}).filter(e=>e);return this.loc.listFormatter({type:`conjunction`,style:e.listStyle||`narrow`,...e}).format(n)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e=`P`;return this.years!==0&&(e+=this.years+`Y`),(this.months!==0||this.quarters!==0)&&(e+=this.months+this.quarters*3+`M`),this.weeks!==0&&(e+=this.weeks+`W`),this.days!==0&&(e+=this.days+`D`),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(e+=`T`),this.hours!==0&&(e+=this.hours+`H`),this.minutes!==0&&(e+=this.minutes+`M`),(this.seconds!==0||this.milliseconds!==0)&&(e+=Pm(this.seconds+this.milliseconds/1e3,3)+`S`),e===`P`&&(e+=`T0S`),e}toISOTime(e={}){if(!this.isValid)return null;let t=this.toMillis();return t<0||t>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:`extended`,...e,includeOffset:!1},Y.fromMillis(t,{zone:`UTC`}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?wg(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(t){if(!this.isValid)return this;let n=e.fromDurationLike(t),r={};for(let e of xg)(Dm(n.values,e)||Dm(this.values,e))&&(r[e]=n.get(e)+this.get(e));return Cg(this,{values:r},!0)}minus(t){if(!this.isValid)return this;let n=e.fromDurationLike(t);return this.plus(n.negate())}mapUnits(e){if(!this.isValid)return this;let t={};for(let n of Object.keys(this.values))t[n]=Wm(e(this.values[n],n));return Cg(this,{values:t},!0)}get(t){return this[e.normalizeUnit(t)]}set(t){if(!this.isValid)return this;let n={...this.values,...Gm(t,e.normalizeUnit)};return Cg(this,{values:n})}reconfigure({locale:e,numberingSystem:t,conversionAccuracy:n,matrix:r}={}){let i={loc:this.loc.clone({locale:e,numberingSystem:t}),matrix:r,conversionAccuracy:n};return Cg(this,i)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;let e=this.toObject();return Tg(this.matrix,e),Cg(this,{values:e},!0)}rescale(){if(!this.isValid)return this;let e=Eg(this.normalize().shiftToAll().toObject());return Cg(this,{values:e},!0)}shiftTo(...t){if(!this.isValid||t.length===0)return this;t=t.map(t=>e.normalizeUnit(t));let n={},r={},i=this.toObject(),a;for(let e of xg)if(t.indexOf(e)>=0){a=e;let t=0;for(let n in r)t+=this.matrix[n][e]*r[n],r[n]=0;vm(i[e])&&(t+=i[e]);let o=Math.trunc(t);n[e]=o,r[e]=(t*1e3-o*1e3)/1e3}else vm(i[e])&&(r[e]=i[e]);for(let e in r)r[e]!==0&&(n[a]+=e===a?r[e]:r[e]/this.matrix[a][e]);return Tg(this.matrix,n),Cg(this,{values:n},!0)}shiftToAll(){return this.isValid?this.shiftTo(`years`,`months`,`weeks`,`days`,`hours`,`minutes`,`seconds`,`milliseconds`):this}negate(){if(!this.isValid)return this;let e={};for(let t of Object.keys(this.values))e[t]=this.values[t]===0?0:-this.values[t];return Cg(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;let e=Eg(this.values);return Cg(this,{values:e},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid||!this.loc.equals(e.loc))return!1;function t(e,t){return e===void 0||e===0?t===void 0||t===0:e===t}for(let n of xg)if(!t(this.values[n],e.values[n]))return!1;return!0}},Og=`Invalid Interval`;function kg(e,t){return!e||!e.isValid?Ag.invalid(`missing or invalid start`):!t||!t.isValid?Ag.invalid(`missing or invalid end`):t<e?Ag.invalid(`end before start`,`The end of an interval must be after its start, but you had start=${e.toISO()} and end=${t.toISO()}`):null}var Ag=class e{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(t,n=null){if(!t)throw new Af(`need to specify a reason the Interval is invalid`);let r=t instanceof tm?t:new tm(t,n);if(G.throwOnInvalid)throw new Ef(r);return new e({invalid:r})}static fromDateTimes(t,n){let r=M_(t),i=M_(n);return kg(r,i)??new e({start:r,end:i})}static after(t,n){let r=Dg.fromDurationLike(n),i=M_(t);return e.fromDateTimes(i,i.plus(r))}static before(t,n){let r=Dg.fromDurationLike(n),i=M_(t);return e.fromDateTimes(i.minus(r),i)}static fromISO(t,n){let[r,i]=(t||``).split(`/`,2);if(r&&i){let t,a;try{t=Y.fromISO(r,n),a=t.isValid}catch{a=!1}let o,s;try{o=Y.fromISO(i,n),s=o.isValid}catch{s=!1}if(a&&s)return e.fromDateTimes(t,o);if(a){let r=Dg.fromISO(i,n);if(r.isValid)return e.after(t,r)}else if(s){let t=Dg.fromISO(r,n);if(t.isValid)return e.before(o,t)}}return e.invalid(`unparsable`,`the input "${t}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e=`milliseconds`){return this.isValid?this.toDuration(e).get(e):NaN}count(e=`milliseconds`,t){if(!this.isValid)return NaN;let n=this.start.startOf(e,t),r;return r=t?.useLocaleWeeks?this.end.reconfigure({locale:n.locale}):this.end,r=r.startOf(e,t),Math.floor(r.diff(n,e).get(e))+(r.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return this.isValid?this.s>e:!1}isBefore(e){return this.isValid?this.e<=e:!1}contains(e){return this.isValid?this.s<=e&&this.e>e:!1}set({start:t,end:n}={}){return this.isValid?e.fromDateTimes(t||this.s,n||this.e):this}splitAt(...t){if(!this.isValid)return[];let n=t.map(M_).filter(e=>this.contains(e)).sort((e,t)=>e.toMillis()-t.toMillis()),r=[],{s:i}=this,a=0;for(;i<this.e;){let t=n[a]||this.e,o=+t>+this.e?this.e:t;r.push(e.fromDateTimes(i,o)),i=o,a+=1}return r}splitBy(t){let n=Dg.fromDurationLike(t);if(!this.isValid||!n.isValid||n.as(`milliseconds`)===0)return[];let{s:r}=this,i=1,a,o=[];for(;r<this.e;){let t=this.start.plus(n.mapUnits(e=>e*i));a=+t>+this.e?this.e:t,o.push(e.fromDateTimes(r,a)),r=a,i+=1}return o}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(t){if(!this.isValid)return this;let n=this.s>t.s?this.s:t.s,r=this.e<t.e?this.e:t.e;return n>=r?null:e.fromDateTimes(n,r)}union(t){if(!this.isValid)return this;let n=this.s<t.s?this.s:t.s,r=this.e>t.e?this.e:t.e;return e.fromDateTimes(n,r)}static merge(e){let[t,n]=e.sort((e,t)=>e.s-t.s).reduce(([e,t],n)=>t?t.overlaps(n)||t.abutsStart(n)?[e,t.union(n)]:[e.concat([t]),n]:[e,n],[[],null]);return n&&t.push(n),t}static xor(t){let n=null,r=0,i=[],a=t.map(e=>[{time:e.s,type:`s`},{time:e.e,type:`e`}]),o=Array.prototype.concat(...a).sort((e,t)=>e.time-t.time);for(let t of o)r+=t.type===`s`?1:-1,r===1?n=t.time:(n&&+n!=+t.time&&i.push(e.fromDateTimes(n,t.time)),n=null);return e.merge(i)}difference(...t){return e.xor([this].concat(t)).map(e=>this.intersection(e)).filter(e=>e&&!e.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:Og}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(e=Pf,t={}){return this.isValid?mh.create(this.s.loc.clone(t),e).formatInterval(this):Og}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:Og}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:Og}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:Og}toFormat(e,{separator:t=` – `}={}){return this.isValid?`${this.s.toFormat(e)}${t}${this.e.toFormat(e)}`:Og}toDuration(e,t){return this.isValid?this.e.diff(this.s,e,t):Dg.invalid(this.invalidReason)}mapEndpoints(t){return e.fromDateTimes(t(this.s),t(this.e))}},jg=class{static hasDST(e=G.defaultZone){let t=Y.now().setZone(e).set({month:12});return!e.isUniversal&&t.offset!==t.set({month:6}).offset}static isValidIANAZone(e){return dp.isValidZone(e)}static normalizeZone(e){return zp(e,G.defaultZone)}static getStartOfWeek({locale:e=null,locObj:t=null}={}){return(t||W.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:t=null}={}){return(t||W.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:t=null}={}){return(t||W.create(e)).getWeekendDays().slice()}static months(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i=`gregory`}={}){return(r||W.create(t,n,i)).months(e)}static monthsFormat(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i=`gregory`}={}){return(r||W.create(t,n,i)).months(e,!0)}static weekdays(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||W.create(t,n,null)).weekdays(e)}static weekdaysFormat(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||W.create(t,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return W.create(e).meridiems()}static eras(e=`short`,{locale:t=null}={}){return W.create(t,null,`gregory`).eras(e)}static features(){return{relative:Sm(),localeWeek:Cm()}}};function Mg(e,t){let n=e=>e.toUTC(0,{keepLocalTime:!0}).startOf(`day`).valueOf(),r=n(t)-n(e);return Math.floor(Dg.fromMillis(r).as(`days`))}function Ng(e,t,n){let r=[[`years`,(e,t)=>t.year-e.year],[`quarters`,(e,t)=>t.quarter-e.quarter+(t.year-e.year)*4],[`months`,(e,t)=>t.month-e.month+(t.year-e.year)*12],[`weeks`,(e,t)=>{let n=Mg(e,t);return(n-n%7)/7}],[`days`,Mg]],i={},a=e,o,s;for(let[c,l]of r)n.indexOf(c)>=0&&(o=c,i[c]=l(e,t),s=a.plus(i),s>t?(i[c]--,e=a.plus(i),e>t&&(s=e,i[c]--,e=a.plus(i))):e=s);return[e,i,s,o]}function Pg(e,t,n,r){let[i,a,o,s]=Ng(e,t,n),c=t-i,l=n.filter(e=>[`hours`,`minutes`,`seconds`,`milliseconds`].indexOf(e)>=0);l.length===0&&(o<t&&(o=i.plus({[s]:1})),o!==i&&(a[s]=(a[s]||0)+c/(o-i)));let u=Dg.fromObject(a,r);return l.length>0?Dg.fromMillis(c,r).shiftTo(...l).plus(u):u}var Fg=`missing Intl.DateTimeFormat.formatToParts support`;function J(e,t=e=>e){return{regex:e,deser:([e])=>t(Up(e))}}var Ig=`[ \xA0]`,Lg=new RegExp(Ig,`g`);function Rg(e){return e.replace(/\./g,`\\.?`).replace(Lg,Ig)}function zg(e){return e.replace(/\./g,``).replace(Lg,` `).toLowerCase()}function Bg(e,t){return e===null?null:{regex:RegExp(e.map(Rg).join(`|`)),deser:([n])=>e.findIndex(e=>zg(n)===zg(e))+t}}function Vg(e,t){return{regex:e,deser:([,e,t])=>Um(e,t),groups:t}}function Hg(e){return{regex:e,deser:([e])=>e}}function Ug(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,`\\$&`)}function Wg(e,t){let n=Kp(t),r=Kp(t,`{2}`),i=Kp(t,`{3}`),a=Kp(t,`{4}`),o=Kp(t,`{6}`),s=Kp(t,`{1,2}`),c=Kp(t,`{1,3}`),l=Kp(t,`{1,6}`),u=Kp(t,`{1,9}`),d=Kp(t,`{2,4}`),f=Kp(t,`{4,6}`),ee=e=>({regex:RegExp(Ug(e.val)),deser:([e])=>e,literal:!0}),p=(p=>{if(e.literal)return ee(p);switch(p.val){case`G`:return Bg(t.eras(`short`),0);case`GG`:return Bg(t.eras(`long`),0);case`y`:return J(l);case`yy`:return J(d,Vm);case`yyyy`:return J(a);case`yyyyy`:return J(f);case`yyyyyy`:return J(o);case`M`:return J(s);case`MM`:return J(r);case`MMM`:return Bg(t.months(`short`,!0),1);case`MMMM`:return Bg(t.months(`long`,!0),1);case`L`:return J(s);case`LL`:return J(r);case`LLL`:return Bg(t.months(`short`,!1),1);case`LLLL`:return Bg(t.months(`long`,!1),1);case`d`:return J(s);case`dd`:return J(r);case`o`:return J(c);case`ooo`:return J(i);case`HH`:return J(r);case`H`:return J(s);case`hh`:return J(r);case`h`:return J(s);case`mm`:return J(r);case`m`:return J(s);case`q`:return J(s);case`qq`:return J(r);case`s`:return J(s);case`ss`:return J(r);case`S`:return J(c);case`SSS`:return J(i);case`u`:return Hg(u);case`uu`:return Hg(s);case`uuu`:return J(n);case`a`:return Bg(t.meridiems(),0);case`kkkk`:return J(a);case`kk`:return J(d,Vm);case`W`:return J(s);case`WW`:return J(r);case`E`:case`c`:return J(n);case`EEE`:return Bg(t.weekdays(`short`,!1),1);case`EEEE`:return Bg(t.weekdays(`long`,!1),1);case`ccc`:return Bg(t.weekdays(`short`,!0),1);case`cccc`:return Bg(t.weekdays(`long`,!0),1);case`Z`:case`ZZ`:return Vg(RegExp(`([+-]${s.source})(?::(${r.source}))?`),2);case`ZZZ`:return Vg(RegExp(`([+-]${s.source})(${r.source})?`),2);case`z`:return Hg(/[a-z_+-/]{1,256}?/i);case` `:return Hg(/[^\S\n\r]/);default:return ee(p)}})(e)||{invalidReason:Fg};return p.token=e,p}var Gg={year:{"2-digit":`yy`,numeric:`yyyyy`},month:{numeric:`M`,"2-digit":`MM`,short:`MMM`,long:`MMMM`},day:{numeric:`d`,"2-digit":`dd`},weekday:{short:`EEE`,long:`EEEE`},dayperiod:`a`,dayPeriod:`a`,hour12:{numeric:`h`,"2-digit":`hh`},hour24:{numeric:`H`,"2-digit":`HH`},minute:{numeric:`m`,"2-digit":`mm`},second:{numeric:`s`,"2-digit":`ss`},timeZoneName:{long:`ZZZZZ`,short:`ZZZ`}};function Kg(e,t,n){let{type:r,value:i}=e;if(r===`literal`){let e=/^\s+$/.test(i);return{literal:!e,val:e?` `:i}}let a=t[r],o=r;r===`hour`&&(o=t.hour12==null?t.hourCycle==null?n.hour12?`hour12`:`hour24`:t.hourCycle===`h11`||t.hourCycle===`h12`?`hour12`:`hour24`:t.hour12?`hour12`:`hour24`);let s=Gg[o];if(typeof s==`object`&&(s=s[a]),s)return{literal:!1,val:s}}function qg(e){return[`^${e.map(e=>e.regex).reduce((e,t)=>`${e}(${t.source})`,``)}$`,e]}function Jg(e,t,n){let r=e.match(t);if(r){let e={},t=1;for(let i in n)if(Dm(n,i)){let a=n[i],o=a.groups?a.groups+1:1;!a.literal&&a.token&&(e[a.token.val[0]]=a.deser(r.slice(t,t+o))),t+=o}return[r,e]}else return[r,{}]}function Yg(e){let t=e=>{switch(e){case`S`:return`millisecond`;case`s`:return`second`;case`m`:return`minute`;case`h`:case`H`:return`hour`;case`d`:return`day`;case`o`:return`ordinal`;case`L`:case`M`:return`month`;case`y`:return`year`;case`E`:case`c`:return`weekday`;case`W`:return`weekNumber`;case`k`:return`weekYear`;case`q`:return`quarter`;default:return null}},n=null,r;return K(e.z)||(n=dp.create(e.z)),K(e.Z)||(n||=new Lp(e.Z),r=e.Z),K(e.q)||(e.M=(e.q-1)*3+1),K(e.h)||(e.h<12&&e.a===1?e.h+=12:e.h===12&&e.a===0&&(e.h=0)),e.G===0&&e.y&&(e.y=-e.y),K(e.u)||(e.S=Nm(e.u)),[Object.keys(e).reduce((n,r)=>{let i=t(r);return i&&(n[i]=e[r]),n},{}),n,r]}var Xg=null;function Zg(){return Xg||=Y.fromMillis(1555555555555),Xg}function Qg(e,t){if(e.literal)return e;let n=r_(mh.macroTokenToFormatOpts(e.val),t);return n==null||n.includes(void 0)?e:n}function $g(e,t){return Array.prototype.concat(...e.map(e=>Qg(e,t)))}var e_=class{constructor(e,t){if(this.locale=e,this.format=t,this.tokens=$g(mh.parseFormat(t),e),this.units=this.tokens.map(t=>Wg(t,e)),this.disqualifyingUnit=this.units.find(e=>e.invalidReason),!this.disqualifyingUnit){let[e,t]=qg(this.units);this.regex=RegExp(e,`i`),this.handlers=t}}explainFromTokens(e){if(this.isValid){let[t,n]=Jg(e,this.regex,this.handlers),[r,i,a]=n?Yg(n):[null,null,void 0];if(Dm(n,`a`)&&Dm(n,`H`))throw new Of(`Can't include meridiem when specifying 24-hour format`);return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:t,matches:n,result:r,zone:i,specificOffset:a}}else return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}};function t_(e,t,n){return new e_(e,n).explainFromTokens(t)}function n_(e,t,n){let{result:r,zone:i,specificOffset:a,invalidReason:o}=t_(e,t,n);return[r,i,a,o]}function r_(e,t){if(!e)return null;let n=mh.create(t,e).dtFormatter(Zg()),r=n.formatToParts(),i=n.resolvedOptions();return r.map(t=>Kg(t,e,i))}var i_=`Invalid DateTime`,a_=864e13;function o_(e){return new tm(`unsupported zone`,`the zone "${e.name}" is not supported`)}function s_(e){return e.weekData===null&&(e.weekData=lm(e.c)),e.weekData}function c_(e){return e.localWeekData===null&&(e.localWeekData=lm(e.c,e.loc.getMinDaysInFirstWeek(),e.loc.getStartOfWeek())),e.localWeekData}function l_(e,t){let n={ts:e.ts,zone:e.zone,c:e.c,o:e.o,loc:e.loc,invalid:e.invalid};return new Y({...n,...t,old:n})}function u_(e,t,n){let r=e-t*60*1e3,i=n.offset(r);if(t===i)return[r,t];r-=(i-t)*60*1e3;let a=n.offset(r);return i===a?[r,i]:[e-Math.min(i,a)*60*1e3,Math.max(i,a)]}function d_(e,t){e+=t*60*1e3;let n=new Date(e);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),millisecond:n.getUTCMilliseconds()}}function f_(e,t,n){return u_(Rm(e),t,n)}function p_(e,t){let n=e.o,r=e.c.year+Math.trunc(t.years),i=e.c.month+Math.trunc(t.months)+Math.trunc(t.quarters)*3,a={...e.c,year:r,month:i,day:Math.min(e.c.day,Lm(r,i))+Math.trunc(t.days)+Math.trunc(t.weeks)*7},o=Dg.fromObject({years:t.years-Math.trunc(t.years),quarters:t.quarters-Math.trunc(t.quarters),months:t.months-Math.trunc(t.months),weeks:t.weeks-Math.trunc(t.weeks),days:t.days-Math.trunc(t.days),hours:t.hours,minutes:t.minutes,seconds:t.seconds,milliseconds:t.milliseconds}).as(`milliseconds`),[s,c]=u_(Rm(a),n,e.zone);return o!==0&&(s+=o,c=e.zone.offset(s)),{ts:s,o:c}}function m_(e,t,n,r,i,a){let{setZone:o,zone:s}=n;if(e&&Object.keys(e).length!==0||t){let r=t||s,i=Y.fromObject(e,{...n,zone:r,specificOffset:a});return o?i:i.setZone(s)}else return Y.invalid(new tm(`unparsable`,`the input "${i}" can't be parsed as ${r}`))}function h_(e,t,n=!0){return e.isValid?mh.create(W.create(`en-US`),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(e,t):null}function g_(e,t,n){let r=e.c.year>9999||e.c.year<0,i=``;if(r&&e.c.year>=0&&(i+=`+`),i+=q(e.c.year,r?6:4),n===`year`)return i;if(t){if(i+=`-`,i+=q(e.c.month),n===`month`)return i;i+=`-`}else if(i+=q(e.c.month),n===`month`)return i;return i+=q(e.c.day),i}function __(e,t,n,r,i,a,o){let s=!n||e.c.millisecond!==0||e.c.second!==0,c=``;switch(o){case`day`:case`month`:case`year`:break;default:if(c+=q(e.c.hour),o===`hour`)break;if(t){if(c+=`:`,c+=q(e.c.minute),o===`minute`)break;s&&(c+=`:`,c+=q(e.c.second))}else{if(c+=q(e.c.minute),o===`minute`)break;s&&(c+=q(e.c.second))}if(o===`second`)break;s&&(!r||e.c.millisecond!==0)&&(c+=`.`,c+=q(e.c.millisecond,3))}return i&&(e.isOffsetFixed&&e.offset===0&&!a?c+=`Z`:e.o<0?(c+=`-`,c+=q(Math.trunc(-e.o/60)),c+=`:`,c+=q(Math.trunc(-e.o%60))):(c+=`+`,c+=q(Math.trunc(e.o/60)),c+=`:`,c+=q(Math.trunc(e.o%60)))),a&&(c+=`[`+e.zone.ianaName+`]`),c}var v_={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},y_={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},b_={ordinal:1,hour:0,minute:0,second:0,millisecond:0},x_=[`year`,`month`,`day`,`hour`,`minute`,`second`,`millisecond`],S_=[`weekYear`,`weekNumber`,`weekday`,`hour`,`minute`,`second`,`millisecond`],C_=[`year`,`ordinal`,`hour`,`minute`,`second`,`millisecond`];function w_(e){let t={year:`year`,years:`year`,month:`month`,months:`month`,day:`day`,days:`day`,hour:`hour`,hours:`hour`,minute:`minute`,minutes:`minute`,quarter:`quarter`,quarters:`quarter`,second:`second`,seconds:`second`,millisecond:`millisecond`,milliseconds:`millisecond`,weekday:`weekday`,weekdays:`weekday`,weeknumber:`weekNumber`,weeksnumber:`weekNumber`,weeknumbers:`weekNumber`,weekyear:`weekYear`,weekyears:`weekYear`,ordinal:`ordinal`}[e.toLowerCase()];if(!t)throw new kf(e);return t}function T_(e){switch(e.toLowerCase()){case`localweekday`:case`localweekdays`:return`localWeekday`;case`localweeknumber`:case`localweeknumbers`:return`localWeekNumber`;case`localweekyear`:case`localweekyears`:return`localWeekYear`;default:return w_(e)}}function E_(e){if(A_===void 0&&(A_=G.now()),e.type!==`iana`)return e.offset(A_);let t=e.name,n=j_.get(t);return n===void 0&&(n=e.offset(A_),j_.set(t,n)),n}function D_(e,t){let n=zp(t.zone,G.defaultZone);if(!n.isValid)return Y.invalid(o_(n));let r=W.fromObject(t),i,a;if(K(e.year))i=G.now();else{for(let t of x_)K(e[t])&&(e[t]=v_[t]);let t=gm(e)||_m(e);if(t)return Y.invalid(t);let r=E_(n);[i,a]=f_(e,r,n)}return new Y({ts:i,zone:n,loc:r,o:a})}function O_(e,t,n){let r=K(n.round)?!0:n.round,i=K(n.rounding)?`trunc`:n.rounding,a=(e,a)=>(e=Pm(e,r||n.calendary?0:2,n.calendary?`round`:i),t.loc.clone(n).relFormatter(n).format(e,a)),o=r=>n.calendary?t.hasSame(e,r)?0:t.startOf(r).diff(e.startOf(r),r).get(r):t.diff(e,r).get(r);if(n.unit)return a(o(n.unit),n.unit);for(let e of n.units){let t=o(e);if(Math.abs(t)>=1)return a(t,e)}return a(e>t?-0:0,n.units[n.units.length-1])}function k_(e){let t={},n;return e.length>0&&typeof e[e.length-1]==`object`?(t=e[e.length-1],n=Array.from(e).slice(0,e.length-1)):n=Array.from(e),[t,n]}var A_,j_=new Map,Y=class e{constructor(e){let t=e.zone||G.defaultZone,n=e.invalid||(Number.isNaN(e.ts)?new tm(`invalid input`):null)||(t.isValid?null:o_(t));this.ts=K(e.ts)?G.now():e.ts;let r=null,i=null;if(!n)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(t))[r,i]=[e.old.c,e.old.o];else{let a=vm(e.o)&&!e.old?e.o:t.offset(this.ts);r=d_(this.ts,a),n=Number.isNaN(r.year)?new tm(`invalid input`):null,r=n?null:r,i=n?null:a}this._zone=t,this.loc=e.loc||W.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=i,this.isLuxonDateTime=!0}static now(){return new e({})}static local(){let[e,t]=k_(arguments),[n,r,i,a,o,s,c]=t;return D_({year:n,month:r,day:i,hour:a,minute:o,second:s,millisecond:c},e)}static utc(){let[e,t]=k_(arguments),[n,r,i,a,o,s,c]=t;return e.zone=Lp.utcInstance,D_({year:n,month:r,day:i,hour:a,minute:o,second:s,millisecond:c},e)}static fromJSDate(t,n={}){let r=xm(t)?t.valueOf():NaN;if(Number.isNaN(r))return e.invalid(`invalid input`);let i=zp(n.zone,G.defaultZone);return i.isValid?new e({ts:r,zone:i,loc:W.fromObject(n)}):e.invalid(o_(i))}static fromMillis(t,n={}){if(vm(t))return t<-a_||t>a_?e.invalid(`Timestamp out of range`):new e({ts:t,zone:zp(n.zone,G.defaultZone),loc:W.fromObject(n)});throw new Af(`fromMillis requires a numerical input, but received a ${typeof t} with value ${t}`)}static fromSeconds(t,n={}){if(vm(t))return new e({ts:t*1e3,zone:zp(n.zone,G.defaultZone),loc:W.fromObject(n)});throw new Af(`fromSeconds requires a numerical input`)}static fromObject(t,n={}){t||={};let r=zp(n.zone,G.defaultZone);if(!r.isValid)return e.invalid(o_(r));let i=W.fromObject(n),a=Gm(t,T_),{minDaysInFirstWeek:o,startOfWeek:s}=pm(a,i),c=G.now(),l=K(n.specificOffset)?r.offset(c):n.specificOffset,u=!K(a.ordinal),d=!K(a.year),f=!K(a.month)||!K(a.day),ee=d||f,p=a.weekYear||a.weekNumber;if((ee||u)&&p)throw new Of(`Can't mix weekYear/weekNumber units with year/month/day or ordinals`);if(f&&u)throw new Of(`Can't mix ordinal dates with month/day`);let te=p||a.weekday&&!ee,ne,re,ie=d_(c,l);te?(ne=S_,re=y_,ie=lm(ie,o,s)):u?(ne=C_,re=b_,ie=dm(ie)):(ne=x_,re=v_);let ae=!1;for(let e of ne){let t=a[e];K(t)?ae?a[e]=re[e]:a[e]=ie[e]:ae=!0}let oe=(te?mm(a,o,s):u?hm(a):gm(a))||_m(a);if(oe)return e.invalid(oe);let[se,ce]=f_(te?um(a,o,s):u?fm(a):a,l,r),le=new e({ts:se,zone:r,o:ce,loc:i});return a.weekday&&ee&&t.weekday!==le.weekday?e.invalid(`mismatched weekday`,`you can't specify both a weekday of ${a.weekday} and a date of ${le.toISO()}`):le.isValid?le:e.invalid(le.invalid)}static fromISO(e,t={}){let[n,r]=ag(e);return m_(n,r,t,`ISO 8601`,e)}static fromRFC2822(e,t={}){let[n,r]=og(e);return m_(n,r,t,`RFC 2822`,e)}static fromHTTP(e,t={}){let[n,r]=sg(e);return m_(n,r,t,`HTTP`,t)}static fromFormat(t,n,r={}){if(K(t)||K(n))throw new Af(`fromFormat requires an input string and a format`);let{locale:i=null,numberingSystem:a=null}=r,[o,s,c,l]=n_(W.fromOpts({locale:i,numberingSystem:a,defaultToEN:!0}),t,n);return l?e.invalid(l):m_(o,s,r,`format ${n}`,t,c)}static fromString(t,n,r={}){return e.fromFormat(t,n,r)}static fromSQL(e,t={}){let[n,r]=mg(e);return m_(n,r,t,`SQL`,e)}static invalid(t,n=null){if(!t)throw new Af(`need to specify a reason the DateTime is invalid`);let r=t instanceof tm?t:new tm(t,n);if(G.throwOnInvalid)throw new Tf(r);return new e({invalid:r})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,t={}){let n=r_(e,W.fromObject(t));return n?n.map(e=>e?e.val:null).join(``):null}static expandFormat(e,t={}){return $g(mh.parseFormat(e),W.fromObject(t)).map(e=>e.val).join(``)}static resetCache(){A_=void 0,j_.clear()}get(e){return this[e]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?s_(this).weekYear:NaN}get weekNumber(){return this.isValid?s_(this).weekNumber:NaN}get weekday(){return this.isValid?s_(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?c_(this).weekday:NaN}get localWeekNumber(){return this.isValid?c_(this).weekNumber:NaN}get localWeekYear(){return this.isValid?c_(this).weekYear:NaN}get ordinal(){return this.isValid?dm(this.c).ordinal:NaN}get monthShort(){return this.isValid?jg.months(`short`,{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?jg.months(`long`,{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?jg.weekdays(`short`,{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?jg.weekdays(`long`,{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:`short`,locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:`long`,locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];let e=864e5,t=6e4,n=Rm(this.c),r=this.zone.offset(n-e),i=this.zone.offset(n+e),a=this.zone.offset(n-r*t),o=this.zone.offset(n-i*t);if(a===o)return[this];let s=n-a*t,c=n-o*t,l=d_(s,a),u=d_(c,o);return l.hour===u.hour&&l.minute===u.minute&&l.second===u.second&&l.millisecond===u.millisecond?[l_(this,{ts:s}),l_(this,{ts:c})]:[this]}get isInLeapYear(){return Fm(this.year)}get daysInMonth(){return Lm(this.year,this.month)}get daysInYear(){return this.isValid?Im(this.year):NaN}get weeksInWeekYear(){return this.isValid?Bm(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Bm(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){let{locale:t,numberingSystem:n,calendar:r}=mh.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:t,numberingSystem:n,outputCalendar:r}}toUTC(e=0,t={}){return this.setZone(Lp.instance(e),t)}toLocal(){return this.setZone(G.defaultZone)}setZone(t,{keepLocalTime:n=!1,keepCalendarTime:r=!1}={}){if(t=zp(t,G.defaultZone),t.equals(this.zone))return this;if(t.isValid){let e=this.ts;if(n||r){let n=t.offset(this.ts),r=this.toObject();[e]=f_(r,n,t)}return l_(this,{ts:e,zone:t})}else return e.invalid(o_(t))}reconfigure({locale:e,numberingSystem:t,outputCalendar:n}={}){let r=this.loc.clone({locale:e,numberingSystem:t,outputCalendar:n});return l_(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;let t=Gm(e,T_),{minDaysInFirstWeek:n,startOfWeek:r}=pm(t,this.loc),i=!K(t.weekYear)||!K(t.weekNumber)||!K(t.weekday),a=!K(t.ordinal),o=!K(t.year),s=!K(t.month)||!K(t.day),c=o||s,l=t.weekYear||t.weekNumber;if((c||a)&&l)throw new Of(`Can't mix weekYear/weekNumber units with year/month/day or ordinals`);if(s&&a)throw new Of(`Can't mix ordinal dates with month/day`);let u;i?u=um({...lm(this.c,n,r),...t},n,r):K(t.ordinal)?(u={...this.toObject(),...t},K(t.day)&&(u.day=Math.min(Lm(u.year,u.month),u.day))):u=fm({...dm(this.c),...t});let[d,f]=f_(u,this.o,this.zone);return l_(this,{ts:d,o:f})}plus(e){if(!this.isValid)return this;let t=Dg.fromDurationLike(e);return l_(this,p_(this,t))}minus(e){if(!this.isValid)return this;let t=Dg.fromDurationLike(e).negate();return l_(this,p_(this,t))}startOf(e,{useLocaleWeeks:t=!1}={}){if(!this.isValid)return this;let n={},r=Dg.normalizeUnit(e);switch(r){case`years`:n.month=1;case`quarters`:case`months`:n.day=1;case`weeks`:case`days`:n.hour=0;case`hours`:n.minute=0;case`minutes`:n.second=0;case`seconds`:n.millisecond=0;break}if(r===`weeks`)if(t){let e=this.loc.getStartOfWeek(),{weekday:t}=this;t<e&&(n.weekNumber=this.weekNumber-1),n.weekday=e}else n.weekday=1;return r===`quarters`&&(n.month=(Math.ceil(this.month/3)-1)*3+1),this.set(n)}endOf(e,t){return this.isValid?this.plus({[e]:1}).startOf(e,t).minus(1):this}toFormat(e,t={}){return this.isValid?mh.create(this.loc.redefaultToEN(t)).formatDateTimeFromString(this,e):i_}toLocaleString(e=Pf,t={}){return this.isValid?mh.create(this.loc.clone(t),e).formatDateTime(this):i_}toLocaleParts(e={}){return this.isValid?mh.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e=`extended`,suppressSeconds:t=!1,suppressMilliseconds:n=!1,includeOffset:r=!0,extendedZone:i=!1,precision:a=`milliseconds`}={}){if(!this.isValid)return null;a=w_(a);let o=e===`extended`,s=g_(this,o,a);return x_.indexOf(a)>=3&&(s+=`T`),s+=__(this,o,t,n,r,i,a),s}toISODate({format:e=`extended`,precision:t=`day`}={}){return this.isValid?g_(this,e===`extended`,w_(t)):null}toISOWeekDate(){return h_(this,`kkkk-'W'WW-c`)}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:t=!1,includeOffset:n=!0,includePrefix:r=!1,extendedZone:i=!1,format:a=`extended`,precision:o=`milliseconds`}={}){return this.isValid?(o=w_(o),(r&&x_.indexOf(o)>=3?`T`:``)+__(this,a===`extended`,t,e,n,i,o)):null}toRFC2822(){return h_(this,`EEE, dd LLL yyyy HH:mm:ss ZZZ`,!1)}toHTTP(){return h_(this.toUTC(),`EEE, dd LLL yyyy HH:mm:ss 'GMT'`)}toSQLDate(){return this.isValid?g_(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:t=!1,includeOffsetSpace:n=!0}={}){let r=`HH:mm:ss.SSS`;return(t||e)&&(n&&(r+=` `),t?r+=`z`:e&&(r+=`ZZ`)),h_(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():i_}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};let t={...this.c};return e.includeConfig&&(t.outputCalendar=this.outputCalendar,t.numberingSystem=this.loc.numberingSystem,t.locale=this.loc.locale),t}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,t=`milliseconds`,n={}){if(!this.isValid||!e.isValid)return Dg.invalid(`created by diffing an invalid DateTime`);let r={locale:this.locale,numberingSystem:this.numberingSystem,...n},i=wm(t).map(Dg.normalizeUnit),a=e.valueOf()>this.valueOf(),o=Pg(a?this:e,a?e:this,i,r);return a?o.negate():o}diffNow(t=`milliseconds`,n={}){return this.diff(e.now(),t,n)}until(e){return this.isValid?Ag.fromDateTimes(this,e):this}hasSame(e,t,n){if(!this.isValid)return!1;let r=e.valueOf(),i=this.setZone(e.zone,{keepLocalTime:!0});return i.startOf(t,n)<=r&&r<=i.endOf(t,n)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(t={}){if(!this.isValid)return null;let n=t.base||e.fromObject({},{zone:this.zone}),r=t.padding?this<n?-t.padding:t.padding:0,i=[`years`,`months`,`days`,`hours`,`minutes`,`seconds`],a=t.unit;return Array.isArray(t.unit)&&(i=t.unit,a=void 0),O_(n,this.plus(r),{...t,numeric:`always`,units:i,unit:a})}toRelativeCalendar(t={}){return this.isValid?O_(t.base||e.fromObject({},{zone:this.zone}),this,{...t,numeric:`auto`,units:[`years`,`months`,`days`],calendary:!0}):null}static min(...t){if(!t.every(e.isDateTime))throw new Af(`min requires all arguments be DateTimes`);return Tm(t,e=>e.valueOf(),Math.min)}static max(...t){if(!t.every(e.isDateTime))throw new Af(`max requires all arguments be DateTimes`);return Tm(t,e=>e.valueOf(),Math.max)}static fromFormatExplain(e,t,n={}){let{locale:r=null,numberingSystem:i=null}=n;return t_(W.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0}),e,t)}static fromStringExplain(t,n,r={}){return e.fromFormatExplain(t,n,r)}static buildFormatParser(e,t={}){let{locale:n=null,numberingSystem:r=null}=t;return new e_(W.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0}),e)}static fromFormatParser(t,n,r={}){if(K(t)||K(n))throw new Af(`fromFormatParser requires an input string and a format parser`);let{locale:i=null,numberingSystem:a=null}=r,o=W.fromOpts({locale:i,numberingSystem:a,defaultToEN:!0});if(!o.equals(n.locale))throw new Af(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${n.locale}`);let{result:s,zone:c,specificOffset:l,invalidReason:u}=n.explainFromTokens(t);return u?e.invalid(u):m_(s,c,r,`format ${n.format}`,t,l)}static get DATE_SHORT(){return Pf}static get DATE_MED(){return Ff}static get DATE_MED_WITH_WEEKDAY(){return If}static get DATE_FULL(){return Lf}static get DATE_HUGE(){return Rf}static get TIME_SIMPLE(){return zf}static get TIME_WITH_SECONDS(){return Bf}static get TIME_WITH_SHORT_OFFSET(){return Vf}static get TIME_WITH_LONG_OFFSET(){return Hf}static get TIME_24_SIMPLE(){return Uf}static get TIME_24_WITH_SECONDS(){return Wf}static get TIME_24_WITH_SHORT_OFFSET(){return Gf}static get TIME_24_WITH_LONG_OFFSET(){return Kf}static get DATETIME_SHORT(){return qf}static get DATETIME_SHORT_WITH_SECONDS(){return Jf}static get DATETIME_MED(){return Yf}static get DATETIME_MED_WITH_SECONDS(){return Xf}static get DATETIME_MED_WITH_WEEKDAY(){return Zf}static get DATETIME_FULL(){return Qf}static get DATETIME_FULL_WITH_SECONDS(){return $f}static get DATETIME_HUGE(){return ep}static get DATETIME_HUGE_WITH_SECONDS(){return tp}};function M_(e){if(Y.isDateTime(e))return e;if(e&&e.valueOf&&vm(e.valueOf()))return Y.fromJSDate(e);if(e&&typeof e==`object`)return Y.fromObject(e);throw new Af(`Unknown datetime argument: ${e}, of type ${typeof e}`)}function N_(e){return ed(e)?e.expression.variable?.value?.toLowerCase()===`null`:e instanceof _l}function P_(e){return L(e).unwrap_or(void 0)===``}function F_(e){return e instanceof ll}function I_(e){let t=zu(e);if(t!==null)return t;if(ju(e)&&e instanceof ol&&e.expression){let t=e.op?.value,n=zu(e.expression);if(n!==null)return t===`-`?-n:n}return null}function L_(e){if(e==null)return null;if(typeof e==`number`)return e;if(typeof e==`string`){let t=Number(e);return isNaN(t)?null:t}if(typeof e==`boolean`)return e?1:0;let t=I_(e);if(t!==null)return t;let n=L(e).unwrap_or(void 0);if(n!==void 0){let e=Number(n);if(!isNaN(e))return e}return null}function R_(e){if(e==null)return null;if(typeof e==`number`)return Number.isInteger(e)?e:null;if(typeof e==`string`){let t=Number(e);return isNaN(t)||!Number.isInteger(t)?null:t}if(typeof e==`boolean`)return e?1:0;let t=I_(e);if(t!==null)return Number.isInteger(t)?t:null;let n=L(e).unwrap_or(void 0);if(n!==void 0){let e=Number(n);if(!isNaN(e)&&Number.isInteger(e))return e}return null}const z_=[`true`,`yes`,`y`,`t`,`1`],B_=[`false`,`no`,`n`,`f`,`0`];function V_(e){if(e==null)return null;if(typeof e==`boolean`)return e;if(typeof e==`number`)return e===0?!1:e===1?!0:null;if(typeof e==`string`){let t=e.toLowerCase();return z_.includes(t)?!0:B_.includes(t)?!1:null}if(ed(e)){let t=e.expression.variable?.value?.toLowerCase();if(t===`true`)return!0;if(t===`false`)return!1}let t=zu(e);if(t===0)return!1;if(t===1)return!0;let n=L(e)?.unwrap_or(``).toLowerCase();if(n){if(z_.includes(n))return!0;if(B_.includes(n))return!1}return null}function H_(e){if(e==null)return null;if(typeof e==`string`)return e;let t=P(e).unwrap_or(void 0);return t?h(t):L(e).unwrap_or(null)}function U_(e){if(e==null)return null;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return e.toString();let t=L(e).unwrap_or(null)??L_(e)??V_(e);return t===null?null:t.toString()}var W_=[`yyyy-MM-dd`,`M/d/yyyy`,`d MMM yyyy`,`MMM d, yyyy`],G_=[`yyyy-MM-dd HH:mm:ss`,`yyyy-MM-dd HH:mm:ss.SSS`,`yyyy-MM-dd HH:mm:ss.SSSZZ`,`yyyy-MM-dd HH:mm:ssZZ`],K_=[`HH:mm:ss`,`HH:mm:ssZZ`,`HH:mm:ss.SSS`,`HH:mm:ss.SSSZZ`];function q_(e){if(e==null)return null;let t=typeof e==`string`?e:L(e).unwrap_or(null);if(t===null)return null;for(let e of K_){let n=Y.fromFormat(t,e,{setZone:!0});if(n.isValid)return n.toISOTime({suppressMilliseconds:!0,includeOffset:r(n)})}for(let e of W_){let n=Y.fromFormat(t,e,{setZone:!0});if(n.isValid)return n.toISODate()}for(let e of G_){let n=Y.fromFormat(t,e,{setZone:!0});if(n.isValid)return n.toISO({suppressMilliseconds:!0,includeOffset:r(n)})}let n=Y.fromISO(t,{setZone:!0});if(n.isValid)return n.toISO({suppressMilliseconds:!0,includeOffset:r(n)});return null;function r(e){return e.zone.type!==`system`}}function J_(e,t,n){return t.map((t,r)=>{let i=e[t]?.value;if(i==null&&n&&n[r]){let e=n[r];if(e?.dbdefault)return JSON.stringify(e.dbdefault.value)}return JSON.stringify(i)}).join(`|`)}function Y_(e,t,n){return t.some((t,r)=>{let i=e[t]?.value;return i==null&&n&&n[r]&&n[r]?.dbdefault?!1:i==null})}function X_(e){return e.increment||yf(e.type.type_name)}function Z_(e,t,n){return e?`${e}.${t}.${n}`:`${t}.${n}`}function Q_(e,t,n){return n.length===1?Z_(e,t,n[0]):`(${n.map(n=>Z_(e,t,n)).join(`, `)})`}function $_(e,t){return t.length===1?JSON.stringify(e[t[0]]?.value):`(${t.map(t=>JSON.stringify(e[t]?.value)).join(`, `)})`}function ev(e,t,n){let r=t.map(t=>e.columnNodes[t]).filter(Boolean);return r.length>0?r.map(e=>new E(T.INVALID_RECORDS_FIELD,n,e)):[new E(T.INVALID_RECORDS_FIELD,n,e.node)]}var tv=e=>e>1?`Composite PK`:`PK`;function nv(e){return bc(Array.from(e.records),([t,{rows:n}])=>{if(Ac(n))return[];e.cachedMergedTables.has(t)||e.cachedMergedTables.set(t,qd(t,e));let r=e.cachedMergedTables.get(t),i=ov(r),a=sv(n),o=Mc(r.fields,`name`);return bc(i,e=>rv(e,n,a,o,r))})}function rv(e,t,n,r,i){let a=cv(e,n,r,i,t);if(!Ac(a))return a;let o=io(e.map(e=>r[e])),s=o.every(e=>e&&X_(e)),[c,l]=g(t,t=>Y_(t.values,e,o)),u=s?[]:iv(c,e,i),d=av(l,e,o,i);return[...u,...d]}function iv(e,t,n){if(Ac(e))return[];let r=`NULL in ${tv(t.length)}: ${Q_(n.schemaName,n.name,t)} cannot be NULL`;return bc(e,e=>ev(e,t,r))}function av(e,t,n,r){return bc(cc(Tc(e,e=>J_(e.values,t,n)),e=>e.length>1),e=>{let n=tv(t.length),i=Q_(r.schemaName,r.name,t);return bc(e.slice(1),e=>ev(e,t,`Duplicate ${n}: ${i} = ${$_(e.values,t)}`))})}function ov(e){return[...e.fields.filter(e=>e.pk).map(e=>[e.name]),...e.indexes.filter(e=>e.pk).map(e=>e.columns.map(e=>e.value))]}function sv(e){return new Set(e.flatMap(e=>Object.keys(e.values)))}function cv(e,t,n,r,i){let a=tc(e,Array.from(t));if(Ac(a))return[];let o=a.filter(e=>{let t=n[e];return t&&!t.increment&&!yf(t.type.type_name)&&!t.dbdefault});if(Ac(o))return[];let s=`${tv(o.length)}: Column ${Q_(r.schemaName,r.name,o)} is missing from record and has no default value`;return i.map(e=>new E(T.INVALID_RECORDS_FIELD,s,e.node))}var lv=e=>e>1?`Composite UNIQUE`:`UNIQUE`;function uv(e){return bc(Array.from(e.records),([t,{rows:n}])=>{e.cachedMergedTables.has(t)||e.cachedMergedTables.set(t,qd(t,e));let r=e.cachedMergedTables.get(t);if(Ac(n))return[];let i=dv(r),a=Mc(r.fields,`name`);return bc(i,e=>fv(n,e,io(e.map(e=>a[e])),r))})}function dv(e){return[...e.fields.filter(e=>e.unique).map(e=>[e.name]),...e.indexes.filter(e=>e.unique).map(e=>e.columns.map(e=>e.value))]}function fv(e,t,n,r){return bc(cc(Tc(e.filter(e=>!Y_(e.values,t,n)),e=>J_(e.values,t,n)),e=>e.length>1),e=>{let n=lv(t.length),i=Q_(r.schemaName,r.name,t);return bc(e.slice(1),e=>ev(e,t,`Duplicate ${n}: ${i} = ${$_(e.values,t)}`))})}function pv(e){let t=[...e.ref.values(),...bc(Array.from(e.tables.values()),t=>Jd(t,e))],n=mv(e);return bc(t,e=>_v(e,n))}function mv(e){let t=new Map;for(let n of e.tables.values()){let r=hv(n.schemaName,n.name),i=e.records.get(n)?.rows||[];e.cachedMergedTables.has(n)||e.cachedMergedTables.set(n,qd(n,e));let a=e.cachedMergedTables.get(n);t.set(r,{mergedTable:a,rows:i})}return t}function hv(e,t){return e?`${e}.${t}`:`${Gl}.${t}`}function gv(e,t,n,r){if(Ac(e.rows))return[];let i=new Set(t.rows.map(e=>J_(e.values,r.fieldNames)));return bc(e.rows.filter(e=>!Y_(e.values,n.fieldNames)).filter(e=>{let t=J_(e.values,n.fieldNames);return!i.has(t)}),i=>{let a=Q_(e.mergedTable.schemaName,e.mergedTable.name,n.fieldNames),o=Q_(t.mergedTable.schemaName,t.mergedTable.name,r.fieldNames),s=`FK violation: ${a} = ${$_(i.values,n.fieldNames)} does not exist in ${o}`;return ev(i,n.fieldNames,s)})}function _v(e,t){if(!e.endpoints)return[];let[n,r]=e.endpoints,i=t.get(hv(n.schemaName,n.tableName)),a=t.get(hv(r.schemaName,r.tableName));return!i||!a?[]:vv(i,a,n,r)}function vv(e,t,n,r){let i=n.relation,a=r.relation;return i===`1`&&a===`1`||i===`*`&&a===`*`?[...gv(e,t,n,r),...gv(t,e,r,n)]:i===`*`&&a===`1`?gv(e,t,n,r):i===`1`&&a===`*`?gv(t,e,r,n):[]}var yv=class{constructor(e){this.env=e,this.tableToRecordMap=new Map}interpret(e){let t=[],n=[];for(let r of e){let{table:e,mergedColumns:i}=bv(r,this.env),a=this.tableToRecordMap.get(e);if(a){t.push(new E(T.DUPLICATE_RECORDS_FOR_TABLE,`Duplicate Records blocks for the same Table '${e.name}' - A Table can only have one Records block`,a)),t.push(new E(T.DUPLICATE_RECORDS_FOR_TABLE,`Duplicate Records blocks for the same Table '${e.name}' - A Table can only have one Records block`,r));continue}this.tableToRecordMap.set(e,r),this.env.records.has(e)||this.env.records.set(e,{element:r,rows:[]});let o=this.env.records.get(e);for(let e of r.body.body){let r=e,a=xv(r,i,this.env);t.push(...a.getErrors()),n.push(...a.getWarnings());let s=a.getValue();s.row&&o.rows.push({values:s.row,node:r,columnNodes:s.columnNodes})}}let r=this.validateConstraints();return n.push(...r),new D(void 0,t,n)}validateConstraints(){let e=[];return e.push(...nv(this.env).map(e=>e.toWarning())),e.push(...uv(this.env).map(e=>e.toWarning())),e.push(...pv(this.env).map(e=>e.toWarning())),e}};function bv(e,t){let n=e.name,r=e.parent;if(r instanceof b){let e=t.tables.get(r),i=qd(e,t);return n?{table:e,mergedTable:i,mergedColumns:n.elementList.map(e=>i.fields.find(t=>t.name===F(e).unwrap()))}:{table:e,mergedTable:i,mergedColumns:i.fields}}let i=Wu(n).unwrap(),a=h(i.variables).referee.declaration,o=t.tables.get(a),s=qd(o,t);return{table:o,mergedTable:s,mergedColumns:i.args.map(e=>s.fields.find(t=>t.name===F(e).unwrap()))}}function xv(e,t,n){let r=[],i=[],a={},o={},s=e.callee instanceof dl?e.callee.elementList:[e.callee];if(s.length!==t.length)return r.push(new E(T.INVALID_RECORDS_FIELD,`Expected ${t.length} values but got ${s.length}`,e)),new D({row:null,columnNodes:{}},r,i);for(let e=0;e<t.length;e++){let c=s[e],l=t[e];o[l.name]=c;let u=Cv(c,l,n);r.push(...u.getErrors()),i.push(...u.getWarnings());let d=u.getValue();d!==null&&(a[l.name]=d)}return new D({row:a,columnNodes:o},r,i)}function Sv(e,t){return e instanceof ll?e.value?.value||``:!isNaN(e.start)&&!isNaN(e.end)?t.slice(e.start,e.end):``}function Cv(e,t,n){let r=t.type.type_name.split(`(`)[0],{increment:i,not_null:a,dbdefault:o}=t,s=t.type.isEnum||!1,c=Cf(r,s),l=U_(e),u=l===null?Sv(e,n.source):l,d=l===null?`expression`:c;if(e instanceof ll)return new D({value:e.value?.value||``,type:`expression`},[],[]);if(N_(e)||P_(e)&&!gf(r)){let n=o&&o.value.toString().toLowerCase()!==`null`,s=yf(r);return a&&!n&&!i&&!s?new D({value:null,type:c},[],[new Pl(T.INVALID_RECORDS_FIELD,`NULL not allowed for non-nullable column '${t.name}' without default and increment`,e)]):new D({value:null,type:c},[],[])}if(s){let r=([...n.enums.values()].find(e=>e.schemaName===t.type.schemaName&&e.name===t.type.type_name)?.values||[]).map(e=>e.name),i=L(e).unwrap_or(void 0);return i===void 0&&(i=P(e).unwrap_or([]).pop()),r.includes(i)?new D({value:i,type:c},[],[]):new D({value:i,type:c},[],[new Pl(T.INVALID_RECORDS_FIELD,`Invalid enum value for column '${t.name}'`,e)])}if(mf(r)){let n=L_(e);if(n===null)return new D({value:u,type:d},[],[new Pl(T.INVALID_RECORDS_FIELD,`Invalid numeric value for column '${t.name}'`,e)]);if(ff(r)&&!Number.isInteger(n))return new D({value:Math.floor(n),type:c},[],[new Pl(T.INVALID_RECORDS_FIELD,`Invalid integer value ${n} for column '${t.name}': expected integer, got decimal`,e)]);if(pf(r)&&t.type.numericParams){let{precision:r,scale:i}=t.type.numericParams,a=n.toString().split(`.`),o=a[0].replace(/^-/,``),s=a[1]||``,l=o.length+s.length,u=s.length;if(l>r)return new D({value:n,type:c},[],[new Pl(T.INVALID_RECORDS_FIELD,`Numeric value ${n} for column '${t.name}' exceeds precision: expected at most ${r} total digits, got ${l}`,e)]);if(u>i)return new D({value:n,type:c},[],[new Pl(T.INVALID_RECORDS_FIELD,`Numeric value ${n} for column '${t.name}' exceeds scale: expected at most ${i} decimal digits, got ${u}`,e)])}return new D({value:n,type:c},[],[])}if(hf(r)){let n=V_(e);return n===null?new D({value:u,type:d},[],[new Pl(T.INVALID_RECORDS_FIELD,`Invalid boolean value for column '${t.name}'`,e)]):new D({value:n,type:c},[],[])}if(vf(r)){let n=q_(e);return n===null?new D({value:u,type:d},[],[new Pl(T.INVALID_RECORDS_FIELD,`Invalid datetime value for column '${t.name}', expected valid datetime format (e.g., 'YYYY-MM-DD', 'HH:MM:SS', 'YYYY-MM-DD HH:MM:SS', 'MM/DD/YYYY', 'D MMM YYYY', or 'MMM D, YYYY')`,e)]):new D({value:n,type:c},[],[])}if(gf(r)){let n=U_(e);if(n===null)return new D({value:u,type:d},[],[new Pl(T.INVALID_RECORDS_FIELD,`Invalid string value for column '${t.name}'`,e)]);if(t.type.lengthParam){let{length:r}=t.type.lengthParam,i=new TextEncoder().encode(n).length;if(i>r)return new D({value:n,type:c},[],[new Pl(T.INVALID_RECORDS_FIELD,`String value for column '${t.name}' exceeds maximum length: expected at most ${r} bytes (UTF-8), got ${i} bytes`,e)])}return new D({value:n,type:`string`},[],[])}return new D({value:u,type:d},[],[])}function wv(e){return{...e,fields:e.fields.map(e=>({...e,type:{...e.type,isEnum:void 0,lengthParam:void 0,numericParams:void 0}}))}}function Tv(e){for(let t of e.diagramViews.values()){let n=t.visibleEntities,r=e.diagramViewWildcards.get(t),i=e.diagramViewExplicitlySet.get(t);!r||!i||r.has(`tableGroups`)&&n.tableGroups&&n.tableGroups.length===0&&(i.has(`tables`)||i.has(`schemas`)||(n.tableGroups=Array.from(e.tableGroups.values()).map(e=>({name:e.name}))))}}function Ev(e){let t=[];for(let[n,{element:r,rows:i}]of e.records){if(!i.length)continue;let e=Object.keys(i[0].columnNodes);t.push({schemaName:n.schemaName||void 0,tableName:n.name,columns:e,token:H(r),values:i.map(t=>e.map(e=>{let n=t.values[e];return n?{value:n.value,type:n.type}:{value:null,type:`expression`}}))})}return{schemas:[],tables:Array.from(e.tables.values()).map(wv),notes:Array.from(e.notes.values()),refs:Array.from(e.ref.values()),enums:Array.from(e.enums.values()),tableGroups:Array.from(e.tableGroups.values()),aliases:e.aliases,project:Array.from(e.project.values())[0]||{},tablePartials:Array.from(e.tablePartials.values()).map(wv),records:t,diagramViews:Array.from(e.diagramViews.values())}}var Dv=class{constructor(e){this.ast=e,this.env={schema:[],tables:new Map,notes:new Map,refIds:{},ref:new Map,enums:new Map,tableOwnerGroup:{},tableGroups:new Map,aliases:[],project:new Map,tablePartials:new Map,records:new Map,recordsElements:[],cachedMergedTables:new Map,source:e.source,diagramViews:new Map,diagramViewWildcards:new Map,diagramViewExplicitlySet:new Map}}interpret(){let e=this.ast.body.flatMap(e=>{switch(Fu(e).unwrap_or(void 0)){case A.Table:return new Yd(e,this.env).interpret();case A.Note:return new Xd(e,this.env).interpret();case A.Ref:return new Zd(e,this.env).interpret();case A.TableGroup:return new Qd(e,this.env).interpret();case A.TablePartial:return new ef(e,this.env).interpret();case A.Enum:return new $d(e,this.env).interpret();case A.Project:return new tf(e,this.env).interpret();case A.DiagramView:return new nf(e,this.env).interpret();case A.Records:return this.env.recordsElements.push(e),[];default:return[]}}),t=[];if(this.env.recordsElements.length){let n=new yv(this.env).interpret(this.env.recordsElements);e.push(...n.getErrors()),t.push(...n.getWarnings())}return Tv(this.env),new D(Ev(this.env),e,t)}};let X=function(e){return e[e.Function=1]=`Function`,e[e.Constructor=2]=`Constructor`,e[e.Field=3]=`Field`,e[e.Variable=4]=`Variable`,e[e.Class=5]=`Class`,e[e.Struct=6]=`Struct`,e[e.Interface=7]=`Interface`,e[e.Module=8]=`Module`,e[e.Property=9]=`Property`,e[e.Event=10]=`Event`,e[e.Operator=11]=`Operator`,e[e.Unit=12]=`Unit`,e[e.Value=13]=`Value`,e[e.Constant=14]=`Constant`,e[e.Enum=15]=`Enum`,e[e.EnumMember=16]=`EnumMember`,e[e.Keyword=17]=`Keyword`,e[e.Text=18]=`Text`,e[e.Color=19]=`Color`,e[e.File=20]=`File`,e[e.Reference=21]=`Reference`,e[e.Customcolor=22]=`Customcolor`,e[e.Folder=23]=`Folder`,e[e.TypeParameter=24]=`TypeParameter`,e[e.User=25]=`User`,e[e.Issue=26]=`Issue`,e[e.Snippet=27]=`Snippet`,e}({}),Z=function(e){return e[e.None=0]=`None`,e[e.KeepWhitespace=1]=`KeepWhitespace`,e[e.InsertAsSnippet=4]=`InsertAsSnippet`,e}({}),Ov=function(e){return e[e.Hint=1]=`Hint`,e[e.Info=2]=`Info`,e[e.Warning=4]=`Warning`,e[e.Error=8]=`Error`,e}({});function kv(e){return e?e.split(``).every(e=>Fl(e)||Il(e))&&!Il(e[0]):!1}function Av(e){return kv(e)?e:`"${Mv(e)}"`}function jv(e){let t=``,n=0,r={n:`
|
|
12
12
|
`,t:` `,r:`\r`,b:`\b`,f:`\f`,v:`\v`,0:`\0`,"\\":`\\`,'"':`"`,"'":`'`,"`":"`"};for(;n<e.length;)if(e[n]===`\\`&&n+1<e.length){let i=e[n+1];if(i===`u`&&n+5<e.length){let r=e.slice(n+2,n+6);if(/^[0-9a-fA-F]{4}$/.test(r)){t+=String.fromCharCode(parseInt(r,16)),n+=6;continue}}i in r?(t+=r[i],n+=2):(t+=i,n+=2)}else t+=e[n],n++;return t}function Mv(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];switch(r){case`\\`:t+=`\\\\`;break;case`"`:t+=`\\"`;break;case`'`:t+=`\\'`;break;case`
|
|
13
|
-
`:t+=`\\n`;break;case` `:t+=`\\t`;break;case`\r`:t+=`\\r`;break;case`\b`:t+=`\\b`;break;case`\f`:t+=`\\f`;break;case`\v`:t+=`\\v`;break;case`\0`:t+=`\\0`;break;default:t+=r}}return t}function Nv(e){if(e==null)return`null`;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return String(e);if(typeof e==`string`)return`'${Mv(e)}'`;let{value:t,type:n}=e;if(t==null||hf(n)&&typeof t==`string`&&t.toLowerCase()===`null`)return`null`;if(n===`expression`)return typeof t==`string`&&t.toLowerCase().trim()===`null`?`null`:`\`${t}\``;if(hf(n)){let e=V_(t);return e===null?`\`${t}\``:e?`true`:`false`}if(mf(n)){let e=L_(t);return e===null?`\`${t}\``:String(e)}if(vf(n)){let e=q_(t);return e===null?`\`${t}\``:`'${Mv(e)}'`}let r=U_(t);return r===null?`\`${t}\``:`'${Mv(r)}'`}function Pv(e){return(e.match(/"(?:[^"\\]|\\.)*"|[^."]+/g)||[]).map(e=>e.startsWith(`"`)&&e.endsWith(`"`)?jv(e.slice(1,-1)):e.trim()).filter(e=>e.length>0)}function Fv(e){switch(e){case M.Schema:return X.Module;case M.Table:case M.TablePartial:return X.Class;case M.Column:case M.TableGroupField:return X.Field;case M.Enum:return X.Enum;case M.EnumField:return X.EnumMember;case M.TableGroup:return X.Struct;default:return X.Text}}function Iv(e,t){if(!e||Qc(e))return!1;for(let n of e.trailingTrivia){if(n.start>t)break;if(n.kind===_.NEWLINE&&n.end<=t)return!1}return!0}function Q(){return{suggestions:[]}}function Lv(e){return{...e,suggestions:e.suggestions.map(e=>({...e,insertText:` ${e.insertText}`}))}}function Rv(e){return{...e,suggestions:e.suggestions.map(e=>({...e,insertText:e.quoted?e.insertText:Av(e.insertText??``),quoted:!0}))}}function zv(e,t=`, `){let n=e.suggestions.map(e=>typeof e.label==`string`?e.label:e.label.label).join(t);return n?{...e,suggestions:[{label:`* (all)`,insertText:n,insertTextRules:Z.KeepWhitespace,kind:X.Snippet,sortText:`00`,range:void 0},...e.suggestions]}:e}function Bv(e,t){return e<t.start||e>t.end?!1:t.body?e<t.body.start||e>t.body.end:!0}function Vv(e){return e.commaList.length+e.elementList.length===0}function Hv(e){let t=[];for(let[n,r]of e.symbolTable.entries()){let e=ou(n).unwrap_or(void 0);if(e===void 0||e.kind!==M.Column||!(r instanceof Tl||r instanceof Nl))continue;let i=Uv(r,e.name);i&&t.push(i)}return t}function Uv(e,t){let n=Yl(t),r=e instanceof Nl?e.tablePartialSymbol.symbolTable.get(n)?.declaration:e.declaration;if(!(r instanceof x))return null;let i=F(r.callee).unwrap_or(null),a=F(r.args[0]).unwrap_or(null);return i===null||a===null?null:{name:i,type:a}}function Wv(e,t,n,r){let i=e.container.element(r);return!(i instanceof b)||Fu(i).unwrap_or(void 0)!==A.Records||!(i.body instanceof S)||!i.body||!Bl(r,i.body)||t.getLineContent(n.lineNumber).trim()!==``?null:i.parent instanceof rl?Gv(e,i):Kv(e,i)}function Gv(e,t){if(!(t.name instanceof w))return Q();let n=t.name.argumentList?.elementList||[],r=n.map(e=>Bu(e));if(!r||r.length===0)return Q();let i=n.map((e,t)=>{let n=r[t];if(!n||!(n instanceof Tl||n instanceof Nl))return null;let i=F(e).unwrap_or(void 0);return i?Uv(n,i):null}).filter(e=>e!==null);return i.length===0?Q():{suggestions:[{label:`Record row snippet`,insertText:i.map((e,t)=>`\${${t+1}:${e.name} (${e.type})}`).join(`, `),insertTextRules:Z.InsertAsSnippet,kind:X.Snippet,range:void 0}]}}function Kv(e,t){let n=t.parent;if(!(n instanceof b))return Q();let r=n.symbol;if(!(r instanceof wl))return Q();let i;if(t.name instanceof ul){let e=t.name.elementList,n=e.map(e=>Bu(e)).filter(e=>e!==void 0);i=e.map((e,t)=>{let r=n[t];if(!r||!(r instanceof Tl||r instanceof Nl))return null;let i=F(e).unwrap_or(void 0);return i===void 0?null:Uv(r,i)}).filter(e=>e!==null)}else{let e=Hv(r);if(!e)return Q();i=e}return i.length===0?Q():{suggestions:[{label:`Record row snippet`,insertText:i.map((e,t)=>`\${${t+1}:${e.name} (${e.type})}`).join(`, `),insertTextRules:Z.InsertAsSnippet,kind:X.Snippet,range:void 0}]}}function qv(e,t){return e.getOffsetAt(t)}var Jv=class{constructor(e,t=[]){this.compiler=e,this.triggerCharacters=t}provideCompletionItems(e,t){let n=qv(e,t),r=Wv(this.compiler,e,t,n);if(r!==null)return r;let i=this.compiler.token.flatStream(),{token:a,index:o}=this.compiler.container.token(n),s=o===void 0?i[0]:i[o+1];if([...a?.trailingTrivia||[],...a?.leadingTrivia||[],...s?.leadingTrivia||[]].find(e=>tl(e)&&Bl(n,e)))return Q();if(o===void 0)return oy();if([_.STRING_LITERAL,_.QUOTED_STRING].includes(a.kind)&&Bl(n,a))return Q();let c=this.compiler.container.element(n);if(this.compiler.container.scopeKind(n)===$.TOPLEVEL||c instanceof b&&c.type&&c.type.start<=n&&c.type.end>=n)return oy();let l=[...this.compiler.container.stack(n)].reverse();for(let e of l)if(e instanceof ol)switch(e.op?.value){case`>`:case`<`:case`<>`:case`-`:return Xv(this.compiler,n,e);case`~`:return Yv(this.compiler,n);default:}else if(e instanceof sl)switch(e.op?.value){case`>`:case`<`:case`<>`:case`-`:return Xv(this.compiler,n,e);case`.`:return iy(this.compiler,n,e);default:}else if(e instanceof al)return ty(this.compiler,n,e);else if(e instanceof C)return ty(this.compiler,n,e);else if(e instanceof ul)return $v(this.compiler,n,e);else if(e instanceof dl)return ey(this.compiler,n);else if(e instanceof w)return fy(this.compiler,n,e);else if(e instanceof x)return ay(this.compiler,n,e);else if(e instanceof b){if(Bv(n,e))return dy(this.compiler,n,e);if(e.bodyColon&&n>=e.bodyColon.end||e.body&&Bl(n,e.body))return ay(this.compiler,n,void 0)}return Q()}};function Yv(e,t){return Qv(e,t,e.parse.ast(),[M.TablePartial])}function Xv(e,t,n){let r=e.container.scopeKind(t);if([$.REF,$.TABLE,$.TABLEPARTIAL].includes(r)){let r=Qv(e,t,e.container.element(t),[M.Table,M.Schema,M.Column]);return Iv(n.op,t)?Lv(r):r}return Q()}function Zv(e,t,n){return Rv({suggestions:e.symbol.members(t).filter(({kind:e})=>n.includes(e)).map(({name:e,kind:t})=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:Fv(t),sortText:Fv(t).toString().padStart(2,`0`),range:void 0}))})}function Qv(e,t,n,r){if(n===void 0)return Q();let i=n,a={suggestions:[]};for(;i;){if(i?.symbol?.symbolTable){let{symbol:t}=i;a.suggestions.push(...Zv(e,t,r).suggestions)}i=i instanceof b?i.parent:void 0}return Rv(a)}function $v(e,t,n){let r=e.container.scopeKind(t),i=e.container.element(t),a=[...e.container.stack(t)];for(let r of a)if(r instanceof w&&r.argumentList===n)return fy(e,t,r);if(i instanceof b&&Fu(i).unwrap_or(void 0)===A.Records&&!(i.name instanceof w)&&Bv(t,i)){let t=i.parent?.symbol||i.name?.referee;if(t){let r=Zv(e,t,[M.Column]);return Vv(n)?zv(r):r}}switch(r){case $.INDEXES:return vy(e,t);case $.REF:for(;a.length>0;){let n=a.pop();if(n instanceof sl&&n.op?.value===`.`)return iy(e,t,n)}return uy(e,t);default:break}return Q()}function ey(e,t){return e.container.scopeKind(t)===$.RECORDS?Qv(e,t,e.container.element(t),[M.Schema,M.Enum,M.EnumField]):Q()}function ty(e,t,n){let{token:r}=e.container.token(t);if([_.COMMA,_.LBRACKET].includes(r?.kind)){let n=ny(e,t);return r?.kind===_.COMMA&&Iv(r,t)?Lv(n):n}if(n.name&&n.name.start<=t&&n.name.end>=t)return ny(e,t);if(n.name instanceof il){let i=ry(e,t,rd(n.name).unwrap_or(``));return r?.kind===_.COLON&&Iv(r,t)?Lv(i):i}return Q()}function ny(e,t){let n=e.container.element(t);if(n instanceof rl)return Q();let r=e.container.scopeKind(t);if(n.body&&!Bl(t,n.body)){let e;switch(r){case $.TABLE:case $.TABLEPARTIAL:e=[j.HeaderColor,j.Note];break;case $.TABLEGROUP:e=[j.Color,j.Note];break;default:e=[]}return{suggestions:e.map(e=>({label:e,insertText:`${e}: `,kind:X.Field,insertTextRules:Z.KeepWhitespace,range:void 0}))}}switch(r){case $.TABLE:case $.TABLEPARTIAL:return{suggestions:[...[j.PK,j.PrimaryKey,j.Null,j.NotNull,j.Increment,j.Unique].map(e=>({label:e,insertText:e,kind:X.Property,insertTextRules:Z.KeepWhitespace,range:void 0})),...[j.Ref,j.Default,j.Note,j.Check].map(e=>({label:e,insertText:`${e}: `,kind:X.Property,insertTextRules:Z.KeepWhitespace,range:void 0}))]};case $.ENUM:return{suggestions:[...[j.Note].map(e=>({label:e,insertText:`${e}: `,kind:X.Property,insertTextRules:Z.KeepWhitespace,range:void 0}))]};case $.INDEXES:return{suggestions:[...[j.Unique,j.PK].map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Property,range:void 0})),...[j.Note,j.Name,j.Type].map(e=>({label:e,insertText:`${e}: `,kind:X.Property,insertTextRules:Z.KeepWhitespace,range:void 0}))]};case $.REF:return{suggestions:[j.Update,j.Delete,j.Color].map(e=>({label:e,insertText:`${e}: `,kind:X.Property,insertTextRules:Z.KeepWhitespace,range:void 0}))};case $.CHECKS:return{suggestions:[j.Name].map(e=>({label:e,insertText:`${e}: `,kind:X.Property,insertTextRules:Z.KeepWhitespace,range:void 0}))};default:break}return Q()}function ry(e,t,n){switch(n?.toLowerCase()){case`update`:case`delete`:return{suggestions:[`cascade`,`set default`,`set null`,`restrict`].map(e=>({label:e,insertText:e,kind:X.Value,insertTextRules:Z.KeepWhitespace,range:void 0}))};case`type`:return{suggestions:[`btree`,`hash`].map(e=>({label:e,insertText:`${e}`,kind:X.Value,insertTextRules:Z.KeepWhitespace,range:void 0}))};case`default`:return Qv(e,t,e.container.element(t),[M.Schema,M.Enum]);default:break}return Q()}function iy(e,t,n){let r=Iu(n).unwrap_or([]);if(r.pop(),r.some(e=>!B(e)))return Q();let i=r.map(e=>F(e).unwrap());return Rv({suggestions:e.symbol.ofName(i,e.container.element(t)).flatMap(({symbol:t})=>e.symbol.members(t)).map(({kind:e,name:t})=>({label:t,insertText:t,kind:Fv(e),range:void 0}))})}function ay(e,t,n){switch(e.container.scopeKind(t)){case $.TABLE:case $.TABLEPARTIAL:return cy(e,t,n);case $.PROJECT:return ly(e,t,n);case $.INDEXES:return gy(e,t);case $.ENUM:return sy(e,t,n);case $.REF:{let n=uy(e,t);return e.container.token(t).token?.kind===_.COLON&&Iv(e.container.token(t).token,t)?Lv(n):n}case $.TABLEGROUP:return py(e);case $.DIAGRAMVIEW:return my();case $.CUSTOM:{let n=e.container.element(t);return n instanceof b&&n.parent instanceof b&&Fu(n.parent).unwrap_or(void 0)===A.DiagramView?hy(e,t):Q()}default:return Q()}}function oy(){return{suggestions:[`Table`,`TableGroup`,`Enum`,`Project`,`Ref`,`TablePartial`,`Records`,`DiagramView`].map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0}))}}function sy(e,t,n){return n?.callee&&yy(t,n)===1?Qv(e,t,e.container.element(t),[M.Schema,M.Table,M.Column]):Q()}function cy(e,t,n){let r=[`Note`,`indexes`,`checks`,`Records`];if(!n?.callee)return{suggestions:r.map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0}))};let i=yy(t,n);return i===0?{suggestions:r.map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0}))}:i===1?_y(e,t):Q()}function ly(e,t,n){return!n?.callee||yy(t,n)===0?{suggestions:[`Table`,`TableGroup`,`Enum`,`Note`,`Ref`,`TablePartial`].map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0}))}:Q()}function uy(e,t){return Qv(e,t,e.container.element(t),[M.Schema,M.Table,M.Column])}function dy(e,t,n){return Fu(n).unwrap_or(void 0)===A.Records?Qv(e,t,n.parent,[M.Schema,M.Table]):Q()}function fy(e,t,n){let r=e.container.element(t),i=n.callee&&Bl(t,n.callee),a=n.argumentList&&Bl(t,n.argumentList);if(r instanceof b&&Fu(r).unwrap_or(void 0)===A.Records&&Bv(t,r)){if(i)return Qv(e,t,r.parent,[M.Schema,M.Table]);if(!a)return Q();let o=n.callee;if(!o)return Q();let s=Iu(o).unwrap_or([o]),c=s[s.length-1]?.referee;if(!c)return Q();let l=Zv(e,c,[M.Column]),{argumentList:u}=n;return!u||!Vv(u)?l:zv(l)}let o=[...e.container.stack(t)];for(let r of o){if(!a||!(r instanceof x)||r.callee!==n||F(n.callee).unwrap_or(``).toLowerCase()!==A.Records)continue;let i=e.container.element(t).symbol;if(!i)return Q();let o=Zv(e,i,[M.Column]),{argumentList:s}=n;return!s||!Vv(s)?o:zv(o)}return Q()}function py(e){return{suggestions:[...Rv({suggestions:[...e.parse.publicSymbolTable().entries()].flatMap(([e])=>{let t=ou(e).unwrap_or(void 0);if(t===void 0)return[];let{kind:n,name:r}=t;return n!==M.Table&&n!==M.Schema?[]:{label:r,insertText:r,insertTextRules:Z.KeepWhitespace,kind:Fv(n),range:void 0}})}).suggestions,...[`Note`].map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0}))]}}function my(){return{suggestions:[...[`Tables`,`TableGroups`,`Notes`,`Schemas`].map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0})),{label:`*`,insertText:`*`,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0}]}}function hy(e,t){let n=e.container.element(t);if(!(n instanceof b))return Q();let r=n.type?.value.toLowerCase(),i={label:`*`,insertText:`*`,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0};switch(r){case`tables`:return{suggestions:[i,...Qv(e,t,e.parse.ast(),[M.Table,M.Schema]).suggestions]};case`tablegroups`:return{suggestions:[i,...Qv(e,t,e.parse.ast(),[M.TableGroup]).suggestions]};case`schemas`:return{suggestions:[i,{label:Gl,insertText:Gl,insertTextRules:Z.KeepWhitespace,kind:X.Module,range:void 0},...Qv(e,t,e.parse.ast(),[M.Schema]).suggestions]};case`notes`:return{suggestions:[i,...Qv(e,t,e.parse.ast(),[M.Note]).suggestions]};default:return Q()}}function gy(e,t){return vy(e,t)}function _y(e,t){return{suggestions:[...`integer.int.tinyint.smallint.mediumint.bigint.bit.bool.binary.varbinary.logical.char.nchar.varchar.varchar2.nvarchar.nvarchar2.binary_float.binary_double.float.double.decimal.dec.real.money.smallmoney.enum.tinyblob.tinytext.blob.text.mediumblob.mediumtext.longblob.longtext.ntext.set.inet6.uuid.image.date.time.datetime.datetime2.timestamp.year.smalldatetime.datetimeoffset.XML.sql_variant.uniqueidentifier.CURSOR.BFILE.CLOB.NCLOB.RAW`.split(`.`).map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.TypeParameter,sortText:X.TypeParameter.toString().padStart(2,`0`),range:void 0})),...Qv(e,t,e.container.element(t),[M.Enum,M.Schema]).suggestions]}}function vy(e,t){let n=e.container.element(t)?.parent;if(!(n?.symbol instanceof wl))return Q();let{symbolTable:r}=n.symbol;return Rv({suggestions:[...r.entries()].flatMap(([e])=>{let t=ou(e).unwrap_or(void 0);if(t===void 0)return[];let{name:n}=t;return{label:n,insertText:n,insertTextRules:Z.KeepWhitespace,kind:Fv(M.Column),range:void 0}})})}function yy(e,t){if(!t.callee)return-1;let n=[t.callee,...t.args],r=n.findIndex(t=>e<=t.end);return r===-1?n.length:r}var by=class{constructor(e){this.compiler=e}provideDefinition(e,t){let{uri:n}=e,r=qv(e,t),i=[...this.compiler.container.stack(r)];for(;i.length!==0;){let e=i.pop();if(!e?.referee)continue;let t;if(e.referee?.declaration&&[y.PRIMARY_EXPRESSION,y.VARIABLE].includes(e?.kind)&&({declaration:t}=e.referee),t){let{startPos:e,endPos:r}=t;return[{range:{startColumn:e.column+1,startLineNumber:e.line+1,endColumn:r.column+1,endLineNumber:r.line+1},uri:n}]}}return[]}},xy=class{constructor(e){this.compiler=e}provideReferences(e,t){let{uri:n}=e,r=qv(e,t),i=[...this.compiler.container.stack(r)];for(;i.length!==0;){let e=i.pop();if(e&&[y.ELEMENT_DECLARATION,y.FUNCTION_APPLICATION,y.PRIMARY_EXPRESSION].includes(e?.kind)){let{symbol:t}=e;if(t?.references.length)return t.references.map(({startPos:e,endPos:t})=>({range:{startColumn:e.column+1,startLineNumber:e.line+1,endColumn:t.column+1,endLineNumber:t.line+1},uri:n}))}}return[]}},Sy=class{constructor(e){this.compiler=e}provideDiagnostics(){let e=[],t=this.compiler.parse._(),n=t.getErrors();for(let t of n)e.push(this.createDiagnostic(t,`error`));let r=t.getWarnings();for(let t of r)e.push(this.createDiagnostic(t,`warning`));return e}provideErrors(){return this.compiler.parse._().getErrors().map(e=>this.createDiagnostic(e,`error`))}provideWarnings(){return this.compiler.parse._().getWarnings().map(e=>this.createDiagnostic(e,`warning`))}provideMarkers(){return this.provideDiagnostics().map(e=>({severity:this.getSeverityValue(e.type),message:e.text,startLineNumber:e.startRow,startColumn:e.startColumn,endLineNumber:e.endRow,endColumn:e.endColumn,code:e.code?String(e.code):void 0}))}createDiagnostic(e,t){let n=e.nodeOrToken,r=n.startPos,i=n.endPos;return{type:t,text:e.diagnostic,startRow:r.line+1,startColumn:r.column+1,endRow:i.line+1,endColumn:i.column+1,code:e.code}}getSeverityValue(e){return e===`error`?Ov.Error:Ov.Warning}},Cy={tokenPostfix:`.dbml`,brackets:[{open:`[`,close:`]`,token:`delimiter.square`},{open:`(`,close:`)`,token:`delimiter.parenthesis`},{open:`{`,close:`}`,token:`delimiter.curly`}],decls:[`project`,`tablegroup`,`table`,`enum`,`ref`,`note`,`tablepartial`,`records`,`checks`,`diagramview`],dataTypes:`TINYINT.SMALLINT.MEDIUMINT.INT.INTEGER.BIGINT.FLOAT.DOUBLE.DECIMAL.DEC.BIT.BOOL.REAL.MONEY.BINARY_FLOAT.BINARY_DOUBLE.smallmoney.ENUM.CHAR.BINARY.VARCHAR.VARBINARY.TINYBLOB.TINYTEXT.BLOB.TEXT.MEDIUMBLOB.MEDIUMTEXT.LONGBLOB.LONGTEXT.SET.INET6.UUID.NVARCHAR.NCHAR.NTEXT.IMAGE.VARCHAR2.NVARCHAR2.DATE.TIME.DATETIME.DATETIME2.TIMESTAMP.YEAR.smalldatetime.datetimeoffset.XML.sql_variant.uniqueidentifier.CURSOR.BFILE.CLOB.NCLOB.RAW`.split(`.`),settings:[`indexes`,`ref`,`note`,`headercolor`,`pk`,`null`,`increment`,`unique`,`default`,`note`,`primary`,`key`,`name`,`as`,`color`,`check`,`tables`,`tablegroups`,`notes`,`schemas`],symbols:/[=><!~?:&|+\-\/\^%]+/,escapes:/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,newline:/[\r\n]/,digits:/\d+(_+\d+)*/,idtf:/[\p{L}0-9_]+/u,ignoreCase:!0,unicode:!0,tokenizer:{root:[[/[{}\[\]\(\)]/,`@bracket`],[/[,.:]/,`delimiter`],{include:`@numbers`},{include:`common`}],common:[{include:`@whitespace`},[/[<>-]/,`operators`],[/\*/,`keyword.wildcard`],[/("[^"\\]*(?:\\.[^"\\]*)*")(\s+)(@idtf(?:\.@idtf*)*)/,[`string`,``,`keyword`]],[/"([^"\\]|\\.)*$/,``],[/'([^'\\]|\\.)*$/,``],[/"/,`string`,`@string_double`],[/'/,`string`,`@string_single`],[/`/,`string`,`@string_backtick`],[/(@idtf)(\s+)(@idtf(?:\.@idtf)*)/,{cases:{"$1@decls":[`keyword`,``,`identifier`],"$1==not":{cases:{"$3==null":[`keyword`,``,`keyword`],"@default":[`identifier`,``,`identifier`]}},"@default":[`identifier`,``,`keyword`]}}],[/@idtf/,{cases:{"@dataTypes":`keyword`,"@decls":`keyword`,"@settings":`keyword`,"@default":`identifier`}}]],numbers:[[/0[xX][0-9a-fA-F]*/,`number`],[/[$][+-]*\d*(\.\d*)?/,`number`],[/((\d+(\.\d*)?)|(\.\d+))([eE][\-+]?\d+)?/,`number`],[/#([0-9A-F]{3}){1,2}/,`number.hex`]],string_double:[[/[^\\"]+/,`string`],[/@escapes/,`string.escape`],[/\\./,`string.escape.invalid`],[/"/,`string`,`@pop`]],string_single:[[/[^\\']+/,`string`],[/@escapes/,`string.escape`],[/\\./,`string.escape.invalid`],[/'/,`string`,`@pop`]],string_backtick:[[/[^\\`$]+/,`string`],[/@escapes/,`string.escape`],[/`/,`string`,`@pop`]],endTripleQuotesString:[[/\\'/,`string`],[/(.*[^\\])?(\\\\)*'''/,`string`,`@popall`],[/.*$/,`string`]],whitespace:[[/[ \t\r\n]+/,``],[/\/\*/,`comment`,`@comment`],[/\/\/.*$/,`comment`],[/'''(.*[^\\])?(\\\\)*'''/,`string`],[/'''.*$/,`string`,`@endTripleQuotesString`]],comment:[[/[^\/*]+/,`comment`],[/\*\//,`comment`,`@pop`],[/[\/*]/,`comment`]]}},wy=t({CompletionItemInsertTextRule:()=>Z,CompletionItemKind:()=>X,DBMLCompletionItemProvider:()=>Jv,DBMLDefinitionProvider:()=>by,DBMLDiagnosticsProvider:()=>Sy,DBMLReferencesProvider:()=>xy,MarkerSeverity:()=>Ov,dbmlMonarchTokensProvider:()=>Cy},1);function Ty(){return this.parse._().getValue().ast}function Ey(){return this.parse._().getErrors()}function Dy(){return this.parse._().getWarnings()}function Oy(){return this.parse._().getValue().tokens}function ky(){return this.parse._().getValue().rawDb}function Ay(){return this.parse._().getValue().ast.symbol.symbolTable}function jy(){return this.parse.tokens().flatMap(e=>[...e.leadingInvalid,e,...e.trailingInvalid])}function My(){return this.parse.tokens().filter(Yu)}function Ny(e){return e.symbolTable?[...e.symbolTable.entries()].map(([e,t])=>({...ou(e).unwrap(),symbol:t})):[]}function Py(e,t){if(e.length===0)return[];let n=[];for(let r=t;r;r=r instanceof b?r.parent:void 0){if(!r.symbol?.symbolTable)continue;let{symbolTable:t}=r.symbol,i=[t],a=[];for(let t of e)a=i.flatMap(e=>Od(t).flatMap(t=>{let n=e.get(t),r=ou(t).unwrap_or(void 0);return!n||!r?[]:{...r,symbol:n}})),i=a.flatMap(e=>e.symbol.symbolTable?e.symbol.symbolTable:[]);n.push(...a)}return n}function Fy(e,t){return`${e.join(`.`)}@${t.id}`}function Iy(e){let t=this.token.flatStream(),{index:n,token:r}=this.container.token(e),i=n===void 0?-1:fc(t,e=>!e.isInvalid,n);if(i===-1)return[this.parse.ast()];let a=t[i].start,o=this.parse.ast(),s=[o];for(;;){let e=Zu(o).find(e=>Bl(a,e));if(e===void 0||e instanceof Yc)break;s.push(e),o=e}if(r?.kind===_.COLON)return s;for(;s.length>0;){let t=!1,n=h(s);if(n instanceof x){let r=this.parse.source();for(let i=n.end;i<e;i+=1)r[i]===`
|
|
14
|
-
`&&(s.pop(),t=!0)}else n instanceof ol||n instanceof sl?this.container.token(e).token!==n.op&&(s.pop(),t=!0):n instanceof C?n.listCloseBracket&&n.end<=e&&(s.pop(),t=!0):n instanceof ul?n.tupleCloseParen&&n.end<=e&&(s.pop(),t=!0):n instanceof dl?n.end<=e&&(s.pop(),t=!0):n instanceof S?n.blockCloseBrace&&n.end<=e&&(s.pop(),t=!0):n instanceof il||n.end<e&&(s.pop(),t=!0);if(t){let t=h(s);t instanceof b&&t.end<=e&&s.pop()}if(!t)break}return s}function Ly(e){let t=this.token.flatStream().findIndex(t=>t.start>=e);return t===void 0||t<=0?{token:void 0,index:void 0}:{token:this.token.flatStream()[t-1],index:t-1}}function Ry(e){let t=this.container.stack(e);for(let e=t.length-1;e>=0;--e)if(t[e]instanceof b)return t[e];return this.parse.ast()}function zy(e){return this.container.element(e)?.symbol?.symbolTable}let $=function(e){return e[e.TABLE=0]=`TABLE`,e[e.ENUM=1]=`ENUM`,e[e.TABLEGROUP=2]=`TABLEGROUP`,e[e.INDEXES=3]=`INDEXES`,e[e.NOTE=4]=`NOTE`,e[e.REF=5]=`REF`,e[e.PROJECT=6]=`PROJECT`,e[e.CUSTOM=7]=`CUSTOM`,e[e.TOPLEVEL=8]=`TOPLEVEL`,e[e.TABLEPARTIAL=9]=`TABLEPARTIAL`,e[e.CHECKS=10]=`CHECKS`,e[e.RECORDS=11]=`RECORDS`,e[e.DIAGRAMVIEW=12]=`DIAGRAMVIEW`,e}({});function By(e){let t=this.container.element(e);if(t instanceof rl)return $.TOPLEVEL;switch(t.type?.value.toLowerCase()){case`table`:return $.TABLE;case`enum`:return $.ENUM;case`ref`:return $.REF;case`tablegroup`:return $.TABLEGROUP;case`indexes`:return $.INDEXES;case`note`:return $.NOTE;case`project`:return $.PROJECT;case`tablepartial`:return $.TABLEPARTIAL;case`checks`:return $.CHECKS;case`records`:return $.RECORDS;case`diagramview`:return $.DIAGRAMVIEW;default:return $.CUSTOM}}function Vy(e,t,n=!1){let r=n?t:[...t].sort((e,t)=>t.start-e.start),i=e;for(let{start:e,end:t,newText:n}of r)i=i.substring(0,e)+n+i.substring(t);return i}function Hy(e){if(typeof e!=`string`)return{schema:e.schema??`public`,table:e.table};let t=Pv(e);if(t.length===0)return{schema:Gl,table:``};if(t.length===1)return{schema:Gl,table:t[0]};if(t.length===2)return{schema:t[0],table:t[1]};let n=t[t.length-1];return{schema:t.slice(0,-1).join(`.`),table:n}}function Uy(e,t,n){let r=Jl(n);if(t===`public`){let t=e.get(r);return t instanceof wl?t:null}let i=ql(t),a=e.get(i);if(!a||!a.symbolTable)return null;let o=a.symbolTable.get(r);return o instanceof wl?o:null}function Wy(e){return e.startsWith(`"`)&&e.endsWith(`"`)&&e.length>=2?e.slice(1,-1):e}function Gy(e){return e?e.split(``).every(e=>Fl(e)||Il(e))&&!Il(e[0]):!1}function Ky(e,t){if(!e.declaration)return!1;let n=e.declaration;if(!n.name)return!1;let r=n.name;return t.substring(r.start,r.end).includes(`"`)}function qy(e,t,n){let r=!Gy(t),i=!Gy(e),a=n||r,o=n||i;return{schema:e,table:t,formattedSchema:o?`"${e}"`:e,formattedTable:a?`"${t}"`:t,shouldQuoteSchema:o,shouldQuoteTable:a}}function Jy(e,t,n,r,i){let a=Jl(i),o;if(r===`public`)o=e.get(a);else{let t=ql(r),n=e.get(t);if(!n||!n.symbolTable)return!1;o=n.symbolTable.get(a)}return!(!o||t===r&&n===i)}function Yy(e,t,n){let r=e.start-1;for(;r>=0&&/\s/.test(n[r]);)r--;if(r<0||n[r]!==`.`)return null;for(r--;r>=0&&/\s/.test(n[r]);)r--;if(r<0)return null;let i,a;if(n[r]===`"`){for(a=r+1,r--;r>=0&&n[r]!==`"`;)r--;if(r<0)return null;i=r}else{for(a=r+1;r>=0&&/[a-zA-Z0-9_]/.test(n[r]);)r--;i=r+1}return Wy(n.substring(i,a))===t?{start:i,end:e.end}:null}function Xy(e,t,n,r){let i=[],a=new Set;for(let o of e){let e=Yy(o,t,r)??{start:o.start,end:o.end},s=`${e.start}-${e.end}`;if(a.has(s))continue;a.add(s);let c=n.schema===`public`?n.formattedTable:`${n.formattedSchema}.${n.formattedTable}`;i.push({start:e.start,end:e.end,newText:c})}return i}function Zy(e,t){let n=this.parse.source(),r=this.parse.publicSymbolTable(),i=Hy(e),a=Hy(t),o=i.schema,s=i.table,c=a.schema,l=a.table,u=Uy(r,o,s);if(!u||Jy(r,o,s,c,l))return n;let d=qy(c,l,Ky(u,n)),f=[];if(u.declaration){let e=u.declaration;e.name&&f.push(e.name)}for(let e of u.references)n.substring(e.start,e.end).replace(/"/g,``)===s&&f.push(e);return Vy(n,Xy(f,o,d,n))}function Qy(e){let t=[],n=new ad(e).lex();if(n.getErrors().length>0)return t;let r=new ld(e,n.getValue(),new nl).parse();if(r.getErrors().length>0)return t;let i=r.getValue().ast;for(let e of i.body)if(e.type?.value
|
|
15
|
-
`)}function
|
|
13
|
+
`:t+=`\\n`;break;case` `:t+=`\\t`;break;case`\r`:t+=`\\r`;break;case`\b`:t+=`\\b`;break;case`\f`:t+=`\\f`;break;case`\v`:t+=`\\v`;break;case`\0`:t+=`\\0`;break;default:t+=r}}return t}function Nv(e){if(e==null)return`null`;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return String(e);if(typeof e==`string`)return`'${Mv(e)}'`;let{value:t,type:n}=e;if(t==null||hf(n)&&typeof t==`string`&&t.toLowerCase()===`null`)return`null`;if(n===`expression`)return typeof t==`string`&&t.toLowerCase().trim()===`null`?`null`:`\`${t}\``;if(hf(n)){let e=V_(t);return e===null?`\`${t}\``:e?`true`:`false`}if(mf(n)){let e=L_(t);return e===null?`\`${t}\``:String(e)}if(vf(n)){let e=q_(t);return e===null?`\`${t}\``:`'${Mv(e)}'`}let r=U_(t);return r===null?`\`${t}\``:`'${Mv(r)}'`}function Pv(e){return(e.match(/"(?:[^"\\]|\\.)*"|[^."]+/g)||[]).map(e=>e.startsWith(`"`)&&e.endsWith(`"`)?jv(e.slice(1,-1)):e.trim()).filter(e=>e.length>0)}function Fv(e){switch(e){case M.Schema:return X.Module;case M.Table:case M.TablePartial:return X.Class;case M.Column:case M.TableGroupField:return X.Field;case M.Enum:return X.Enum;case M.EnumField:return X.EnumMember;case M.TableGroup:return X.Struct;default:return X.Text}}function Iv(e,t){if(!e||Qc(e))return!1;for(let n of e.trailingTrivia){if(n.start>t)break;if(n.kind===_.NEWLINE&&n.end<=t)return!1}return!0}function Q(){return{suggestions:[]}}function Lv(e){return{...e,suggestions:e.suggestions.map(e=>({...e,insertText:` ${e.insertText}`}))}}function Rv(e){return{...e,suggestions:e.suggestions.map(e=>({...e,insertText:e.quoted?e.insertText:Av(e.insertText??``),quoted:!0}))}}function zv(e,t=`, `){let n=e.suggestions.map(e=>typeof e.label==`string`?e.label:e.label.label).join(t);return n?{...e,suggestions:[{label:`* (all)`,insertText:n,insertTextRules:Z.KeepWhitespace,kind:X.Snippet,sortText:`00`,range:void 0},...e.suggestions]}:e}function Bv(e,t){return e<t.start||e>t.end?!1:t.body?e<t.body.start||e>t.body.end:!0}function Vv(e){return e.commaList.length+e.elementList.length===0}function Hv(e){let t=[];for(let[n,r]of e.symbolTable.entries()){let e=ou(n).unwrap_or(void 0);if(e===void 0||e.kind!==M.Column||!(r instanceof Tl||r instanceof Nl))continue;let i=Uv(r,e.name);i&&t.push(i)}return t}function Uv(e,t){let n=Yl(t),r=e instanceof Nl?e.tablePartialSymbol.symbolTable.get(n)?.declaration:e.declaration;if(!(r instanceof x))return null;let i=F(r.callee).unwrap_or(null),a=F(r.args[0]).unwrap_or(null);return i===null||a===null?null:{name:i,type:a}}function Wv(e,t,n,r){let i=e.container.element(r);return!(i instanceof b)||Fu(i).unwrap_or(void 0)!==A.Records||!(i.body instanceof S)||!i.body||!Bl(r,i.body)||t.getLineContent(n.lineNumber).trim()!==``?null:i.parent instanceof rl?Gv(e,i):Kv(e,i)}function Gv(e,t){if(!(t.name instanceof w))return Q();let n=t.name.argumentList?.elementList||[],r=n.map(e=>Bu(e));if(!r||r.length===0)return Q();let i=n.map((e,t)=>{let n=r[t];if(!n||!(n instanceof Tl||n instanceof Nl))return null;let i=F(e).unwrap_or(void 0);return i?Uv(n,i):null}).filter(e=>e!==null);return i.length===0?Q():{suggestions:[{label:`Record row snippet`,insertText:i.map((e,t)=>`\${${t+1}:${e.name} (${e.type})}`).join(`, `),insertTextRules:Z.InsertAsSnippet,kind:X.Snippet,range:void 0}]}}function Kv(e,t){let n=t.parent;if(!(n instanceof b))return Q();let r=n.symbol;if(!(r instanceof wl))return Q();let i;if(t.name instanceof ul){let e=t.name.elementList,n=e.map(e=>Bu(e)).filter(e=>e!==void 0);i=e.map((e,t)=>{let r=n[t];if(!r||!(r instanceof Tl||r instanceof Nl))return null;let i=F(e).unwrap_or(void 0);return i===void 0?null:Uv(r,i)}).filter(e=>e!==null)}else{let e=Hv(r);if(!e)return Q();i=e}return i.length===0?Q():{suggestions:[{label:`Record row snippet`,insertText:i.map((e,t)=>`\${${t+1}:${e.name} (${e.type})}`).join(`, `),insertTextRules:Z.InsertAsSnippet,kind:X.Snippet,range:void 0}]}}function qv(e,t){return e.getOffsetAt(t)}var Jv=class{constructor(e,t=[]){this.compiler=e,this.triggerCharacters=t}provideCompletionItems(e,t){let n=qv(e,t),r=Wv(this.compiler,e,t,n);if(r!==null)return r;let i=this.compiler.token.flatStream(),{token:a,index:o}=this.compiler.container.token(n),s=o===void 0?i[0]:i[o+1];if([...a?.trailingTrivia||[],...a?.leadingTrivia||[],...s?.leadingTrivia||[]].find(e=>tl(e)&&Bl(n,e)))return Q();if(o===void 0)return oy();if([_.STRING_LITERAL,_.QUOTED_STRING].includes(a.kind)&&Bl(n,a))return Q();let c=this.compiler.container.element(n);if(this.compiler.container.scopeKind(n)===$.TOPLEVEL||c instanceof b&&c.type&&c.type.start<=n&&c.type.end>=n)return oy();let l=[...this.compiler.container.stack(n)].reverse();for(let e of l)if(e instanceof ol)switch(e.op?.value){case`>`:case`<`:case`<>`:case`-`:return Xv(this.compiler,n,e);case`~`:return Yv(this.compiler,n);default:}else if(e instanceof sl)switch(e.op?.value){case`>`:case`<`:case`<>`:case`-`:return Xv(this.compiler,n,e);case`.`:return iy(this.compiler,n,e);default:}else if(e instanceof al)return ty(this.compiler,n,e);else if(e instanceof C)return ty(this.compiler,n,e);else if(e instanceof ul)return $v(this.compiler,n,e);else if(e instanceof dl)return ey(this.compiler,n);else if(e instanceof w)return fy(this.compiler,n,e);else if(e instanceof x)return ay(this.compiler,n,e);else if(e instanceof b){if(Bv(n,e))return dy(this.compiler,n,e);if(e.bodyColon&&n>=e.bodyColon.end||e.body&&Bl(n,e.body))return ay(this.compiler,n,void 0)}return Q()}};function Yv(e,t){return Qv(e,t,e.parse.ast(),[M.TablePartial])}function Xv(e,t,n){let r=e.container.scopeKind(t);if([$.REF,$.TABLE,$.TABLEPARTIAL].includes(r)){let r=Qv(e,t,e.container.element(t),[M.Table,M.Schema,M.Column]);return Iv(n.op,t)?Lv(r):r}return Q()}function Zv(e,t,n){return Rv({suggestions:e.symbol.members(t).filter(({kind:e})=>n.includes(e)).map(({name:e,kind:t})=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:Fv(t),sortText:Fv(t).toString().padStart(2,`0`),range:void 0}))})}function Qv(e,t,n,r){if(n===void 0)return Q();let i=n,a={suggestions:[]};for(;i;){if(i?.symbol?.symbolTable){let{symbol:t}=i;a.suggestions.push(...Zv(e,t,r).suggestions)}i=i instanceof b?i.parent:void 0}return Rv(a)}function $v(e,t,n){let r=e.container.scopeKind(t),i=e.container.element(t),a=[...e.container.stack(t)];for(let r of a)if(r instanceof w&&r.argumentList===n)return fy(e,t,r);if(i instanceof b&&Fu(i).unwrap_or(void 0)===A.Records&&!(i.name instanceof w)&&Bv(t,i)){let t=i.parent?.symbol||i.name?.referee;if(t){let r=Zv(e,t,[M.Column]);return Vv(n)?zv(r):r}}switch(r){case $.INDEXES:return vy(e,t);case $.REF:for(;a.length>0;){let n=a.pop();if(n instanceof sl&&n.op?.value===`.`)return iy(e,t,n)}return uy(e,t);default:break}return Q()}function ey(e,t){return e.container.scopeKind(t)===$.RECORDS?Qv(e,t,e.container.element(t),[M.Schema,M.Enum,M.EnumField]):Q()}function ty(e,t,n){let{token:r}=e.container.token(t);if([_.COMMA,_.LBRACKET].includes(r?.kind)){let n=ny(e,t);return r?.kind===_.COMMA&&Iv(r,t)?Lv(n):n}if(n.name&&n.name.start<=t&&n.name.end>=t)return ny(e,t);if(n.name instanceof il){let i=ry(e,t,rd(n.name).unwrap_or(``));return r?.kind===_.COLON&&Iv(r,t)?Lv(i):i}return Q()}function ny(e,t){let n=e.container.element(t);if(n instanceof rl)return Q();let r=e.container.scopeKind(t);if(n.body&&!Bl(t,n.body)){let e;switch(r){case $.TABLE:case $.TABLEPARTIAL:e=[j.HeaderColor,j.Note];break;case $.TABLEGROUP:e=[j.Color,j.Note];break;default:e=[]}return{suggestions:e.map(e=>({label:e,insertText:`${e}: `,kind:X.Field,insertTextRules:Z.KeepWhitespace,range:void 0}))}}switch(r){case $.TABLE:case $.TABLEPARTIAL:return{suggestions:[...[j.PK,j.PrimaryKey,j.Null,j.NotNull,j.Increment,j.Unique].map(e=>({label:e,insertText:e,kind:X.Property,insertTextRules:Z.KeepWhitespace,range:void 0})),...[j.Ref,j.Default,j.Note,j.Check].map(e=>({label:e,insertText:`${e}: `,kind:X.Property,insertTextRules:Z.KeepWhitespace,range:void 0}))]};case $.ENUM:return{suggestions:[...[j.Note].map(e=>({label:e,insertText:`${e}: `,kind:X.Property,insertTextRules:Z.KeepWhitespace,range:void 0}))]};case $.INDEXES:return{suggestions:[...[j.Unique,j.PK].map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Property,range:void 0})),...[j.Note,j.Name,j.Type].map(e=>({label:e,insertText:`${e}: `,kind:X.Property,insertTextRules:Z.KeepWhitespace,range:void 0}))]};case $.REF:return{suggestions:[j.Update,j.Delete,j.Color].map(e=>({label:e,insertText:`${e}: `,kind:X.Property,insertTextRules:Z.KeepWhitespace,range:void 0}))};case $.CHECKS:return{suggestions:[j.Name].map(e=>({label:e,insertText:`${e}: `,kind:X.Property,insertTextRules:Z.KeepWhitespace,range:void 0}))};default:break}return Q()}function ry(e,t,n){switch(n?.toLowerCase()){case`update`:case`delete`:return{suggestions:[`cascade`,`set default`,`set null`,`restrict`].map(e=>({label:e,insertText:e,kind:X.Value,insertTextRules:Z.KeepWhitespace,range:void 0}))};case`type`:return{suggestions:[`btree`,`hash`].map(e=>({label:e,insertText:`${e}`,kind:X.Value,insertTextRules:Z.KeepWhitespace,range:void 0}))};case`default`:return Qv(e,t,e.container.element(t),[M.Schema,M.Enum]);default:break}return Q()}function iy(e,t,n){let r=Iu(n).unwrap_or([]);if(r.pop(),r.some(e=>!B(e)))return Q();let i=r.map(e=>F(e).unwrap());return Rv({suggestions:e.symbol.ofName(i,e.container.element(t)).flatMap(({symbol:t})=>e.symbol.members(t)).map(({kind:e,name:t})=>({label:t,insertText:t,kind:Fv(e),range:void 0}))})}function ay(e,t,n){switch(e.container.scopeKind(t)){case $.TABLE:case $.TABLEPARTIAL:return cy(e,t,n);case $.PROJECT:return ly(e,t,n);case $.INDEXES:return gy(e,t);case $.ENUM:return sy(e,t,n);case $.REF:{let n=uy(e,t);return e.container.token(t).token?.kind===_.COLON&&Iv(e.container.token(t).token,t)?Lv(n):n}case $.TABLEGROUP:return py(e);case $.DIAGRAMVIEW:return my();case $.CUSTOM:{let n=e.container.element(t);return n instanceof b&&n.parent instanceof b&&Fu(n.parent).unwrap_or(void 0)===A.DiagramView?hy(e,t):Q()}default:return Q()}}function oy(){return{suggestions:[`Table`,`TableGroup`,`Enum`,`Project`,`Ref`,`TablePartial`,`Records`,`DiagramView`].map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0}))}}function sy(e,t,n){return n?.callee&&yy(t,n)===1?Qv(e,t,e.container.element(t),[M.Schema,M.Table,M.Column]):Q()}function cy(e,t,n){let r=[`Note`,`indexes`,`checks`,`Records`];if(!n?.callee)return{suggestions:r.map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0}))};let i=yy(t,n);return i===0?{suggestions:r.map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0}))}:i===1?_y(e,t):Q()}function ly(e,t,n){return!n?.callee||yy(t,n)===0?{suggestions:[`Table`,`TableGroup`,`Enum`,`Note`,`Ref`,`TablePartial`].map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0}))}:Q()}function uy(e,t){return Qv(e,t,e.container.element(t),[M.Schema,M.Table,M.Column])}function dy(e,t,n){return Fu(n).unwrap_or(void 0)===A.Records?Qv(e,t,n.parent,[M.Schema,M.Table]):Q()}function fy(e,t,n){let r=e.container.element(t),i=n.callee&&Bl(t,n.callee),a=n.argumentList&&Bl(t,n.argumentList);if(r instanceof b&&Fu(r).unwrap_or(void 0)===A.Records&&Bv(t,r)){if(i)return Qv(e,t,r.parent,[M.Schema,M.Table]);if(!a)return Q();let o=n.callee;if(!o)return Q();let s=Iu(o).unwrap_or([o]),c=s[s.length-1]?.referee;if(!c)return Q();let l=Zv(e,c,[M.Column]),{argumentList:u}=n;return!u||!Vv(u)?l:zv(l)}let o=[...e.container.stack(t)];for(let r of o){if(!a||!(r instanceof x)||r.callee!==n||F(n.callee).unwrap_or(``).toLowerCase()!==A.Records)continue;let i=e.container.element(t).symbol;if(!i)return Q();let o=Zv(e,i,[M.Column]),{argumentList:s}=n;return!s||!Vv(s)?o:zv(o)}return Q()}function py(e){return{suggestions:[...Rv({suggestions:[...e.parse.publicSymbolTable().entries()].flatMap(([e])=>{let t=ou(e).unwrap_or(void 0);if(t===void 0)return[];let{kind:n,name:r}=t;return n!==M.Table&&n!==M.Schema?[]:{label:r,insertText:r,insertTextRules:Z.KeepWhitespace,kind:Fv(n),range:void 0}})}).suggestions,...[`Note`].map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0}))]}}function my(){return{suggestions:[...[`Tables`,`TableGroups`,`Notes`,`Schemas`].map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0})),{label:`*`,insertText:`*`,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0}]}}function hy(e,t){let n=e.container.element(t);if(!(n instanceof b))return Q();let r=n.type?.value.toLowerCase(),i={label:`*`,insertText:`*`,insertTextRules:Z.KeepWhitespace,kind:X.Keyword,range:void 0};switch(r){case`tables`:return{suggestions:[i,...Qv(e,t,e.parse.ast(),[M.Table,M.Schema]).suggestions]};case`tablegroups`:return{suggestions:[i,...Qv(e,t,e.parse.ast(),[M.TableGroup]).suggestions]};case`schemas`:return{suggestions:[i,{label:Gl,insertText:Gl,insertTextRules:Z.KeepWhitespace,kind:X.Module,range:void 0},...Qv(e,t,e.parse.ast(),[M.Schema]).suggestions]};case`notes`:return{suggestions:[i,...Qv(e,t,e.parse.ast(),[M.Note]).suggestions]};default:return Q()}}function gy(e,t){return vy(e,t)}function _y(e,t){return{suggestions:[...`integer.int.tinyint.smallint.mediumint.bigint.bit.bool.binary.varbinary.logical.char.nchar.varchar.varchar2.nvarchar.nvarchar2.binary_float.binary_double.float.double.decimal.dec.real.money.smallmoney.enum.tinyblob.tinytext.blob.text.mediumblob.mediumtext.longblob.longtext.ntext.set.inet6.uuid.image.date.time.datetime.datetime2.timestamp.year.smalldatetime.datetimeoffset.XML.sql_variant.uniqueidentifier.CURSOR.BFILE.CLOB.NCLOB.RAW`.split(`.`).map(e=>({label:e,insertText:e,insertTextRules:Z.KeepWhitespace,kind:X.TypeParameter,sortText:X.TypeParameter.toString().padStart(2,`0`),range:void 0})),...Qv(e,t,e.container.element(t),[M.Enum,M.Schema]).suggestions]}}function vy(e,t){let n=e.container.element(t)?.parent;if(!(n?.symbol instanceof wl))return Q();let{symbolTable:r}=n.symbol;return Rv({suggestions:[...r.entries()].flatMap(([e])=>{let t=ou(e).unwrap_or(void 0);if(t===void 0)return[];let{name:n}=t;return{label:n,insertText:n,insertTextRules:Z.KeepWhitespace,kind:Fv(M.Column),range:void 0}})})}function yy(e,t){if(!t.callee)return-1;let n=[t.callee,...t.args],r=n.findIndex(t=>e<=t.end);return r===-1?n.length:r}var by=class{constructor(e){this.compiler=e}provideDefinition(e,t){let{uri:n}=e,r=qv(e,t),i=[...this.compiler.container.stack(r)];for(;i.length!==0;){let e=i.pop();if(!e?.referee)continue;let t;if(e.referee?.declaration&&[y.PRIMARY_EXPRESSION,y.VARIABLE].includes(e?.kind)&&({declaration:t}=e.referee),t){let{startPos:e,endPos:r}=t;return[{range:{startColumn:e.column+1,startLineNumber:e.line+1,endColumn:r.column+1,endLineNumber:r.line+1},uri:n}]}}return[]}},xy=class{constructor(e){this.compiler=e}provideReferences(e,t){let{uri:n}=e,r=qv(e,t),i=[...this.compiler.container.stack(r)];for(;i.length!==0;){let e=i.pop();if(e&&[y.ELEMENT_DECLARATION,y.FUNCTION_APPLICATION,y.PRIMARY_EXPRESSION].includes(e?.kind)){let{symbol:t}=e;if(t?.references.length)return t.references.map(({startPos:e,endPos:t})=>({range:{startColumn:e.column+1,startLineNumber:e.line+1,endColumn:t.column+1,endLineNumber:t.line+1},uri:n}))}}return[]}},Sy=class{constructor(e){this.compiler=e}provideDiagnostics(){let e=[],t=this.compiler.parse._(),n=t.getErrors();for(let t of n)e.push(this.createDiagnostic(t,`error`));let r=t.getWarnings();for(let t of r)e.push(this.createDiagnostic(t,`warning`));return e}provideErrors(){return this.compiler.parse._().getErrors().map(e=>this.createDiagnostic(e,`error`))}provideWarnings(){return this.compiler.parse._().getWarnings().map(e=>this.createDiagnostic(e,`warning`))}provideMarkers(){return this.provideDiagnostics().map(e=>({severity:this.getSeverityValue(e.type),message:e.text,startLineNumber:e.startRow,startColumn:e.startColumn,endLineNumber:e.endRow,endColumn:e.endColumn,code:e.code?String(e.code):void 0}))}createDiagnostic(e,t){let n=e.nodeOrToken,r=n.startPos,i=n.endPos;return{type:t,text:e.diagnostic,startRow:r.line+1,startColumn:r.column+1,endRow:i.line+1,endColumn:i.column+1,code:e.code}}getSeverityValue(e){return e===`error`?Ov.Error:Ov.Warning}},Cy={tokenPostfix:`.dbml`,brackets:[{open:`[`,close:`]`,token:`delimiter.square`},{open:`(`,close:`)`,token:`delimiter.parenthesis`},{open:`{`,close:`}`,token:`delimiter.curly`}],decls:[`project`,`tablegroup`,`table`,`enum`,`ref`,`note`,`tablepartial`,`records`,`checks`,`diagramview`],dataTypes:`TINYINT.SMALLINT.MEDIUMINT.INT.INTEGER.BIGINT.FLOAT.DOUBLE.DECIMAL.DEC.BIT.BOOL.REAL.MONEY.BINARY_FLOAT.BINARY_DOUBLE.smallmoney.ENUM.CHAR.BINARY.VARCHAR.VARBINARY.TINYBLOB.TINYTEXT.BLOB.TEXT.MEDIUMBLOB.MEDIUMTEXT.LONGBLOB.LONGTEXT.SET.INET6.UUID.NVARCHAR.NCHAR.NTEXT.IMAGE.VARCHAR2.NVARCHAR2.DATE.TIME.DATETIME.DATETIME2.TIMESTAMP.YEAR.smalldatetime.datetimeoffset.XML.sql_variant.uniqueidentifier.CURSOR.BFILE.CLOB.NCLOB.RAW`.split(`.`),settings:[`indexes`,`ref`,`note`,`headercolor`,`pk`,`null`,`increment`,`unique`,`default`,`note`,`primary`,`key`,`name`,`as`,`color`,`check`,`tables`,`tablegroups`,`notes`,`schemas`],symbols:/[=><!~?:&|+\-/^%]+/,escapes:/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,newline:/[\r\n]/,digits:/\d+(_+\d+)*/,idtf:/[\p{L}0-9_]+/u,ignoreCase:!0,unicode:!0,tokenizer:{root:[[/[{}[\]()]/,`@bracket`],[/[,.:]/,`delimiter`],{include:`@numbers`},{include:`common`}],common:[{include:`@whitespace`},[/[<>-]/,`operators`],[/\*/,`keyword.wildcard`],[/("[^"\\]*(?:\\.[^"\\]*)*")(\s+)(@idtf(?:\.@idtf*)*)/,[`string`,``,`keyword`]],[/"([^"\\]|\\.)*$/,``],[/'([^'\\]|\\.)*$/,``],[/"/,`string`,`@string_double`],[/'/,`string`,`@string_single`],[/`/,`string`,`@string_backtick`],[/(@idtf)(\s+)(@idtf(?:\.@idtf)*)/,{cases:{"$1@decls":[`keyword`,``,`identifier`],"$1==not":{cases:{"$3==null":[`keyword`,``,`keyword`],"@default":[`identifier`,``,`identifier`]}},"@default":[`identifier`,``,`keyword`]}}],[/@idtf/,{cases:{"@dataTypes":`keyword`,"@decls":`keyword`,"@settings":`keyword`,"@default":`identifier`}}]],numbers:[[/0[xX][0-9a-fA-F]*/,`number`],[/[$][+-]*\d*(\.\d*)?/,`number`],[/((\d+(\.\d*)?)|(\.\d+))([eE][-+]?\d+)?/,`number`],[/#([0-9A-F]{3}){1,2}/,`number.hex`]],string_double:[[/[^\\"]+/,`string`],[/@escapes/,`string.escape`],[/\\./,`string.escape.invalid`],[/"/,`string`,`@pop`]],string_single:[[/[^\\']+/,`string`],[/@escapes/,`string.escape`],[/\\./,`string.escape.invalid`],[/'/,`string`,`@pop`]],string_backtick:[[/[^\\`$]+/,`string`],[/@escapes/,`string.escape`],[/`/,`string`,`@pop`]],endTripleQuotesString:[[/\\'/,`string`],[/(.*[^\\])?(\\\\)*'''/,`string`,`@popall`],[/.*$/,`string`]],whitespace:[[/[ \t\r\n]+/,``],[/\/\*/,`comment`,`@comment`],[/\/\/.*$/,`comment`],[/'''(.*[^\\])?(\\\\)*'''/,`string`],[/'''.*$/,`string`,`@endTripleQuotesString`]],comment:[[/[^/*]+/,`comment`],[/\*\//,`comment`,`@pop`],[/[/*]/,`comment`]]}},wy=t({CompletionItemInsertTextRule:()=>Z,CompletionItemKind:()=>X,DBMLCompletionItemProvider:()=>Jv,DBMLDefinitionProvider:()=>by,DBMLDiagnosticsProvider:()=>Sy,DBMLReferencesProvider:()=>xy,MarkerSeverity:()=>Ov,dbmlMonarchTokensProvider:()=>Cy},1);function Ty(){return this.parse._().getValue().ast}function Ey(){return this.parse._().getErrors()}function Dy(){return this.parse._().getWarnings()}function Oy(){return this.parse._().getValue().tokens}function ky(){return this.parse._().getValue().rawDb}function Ay(){return this.parse._().getValue().ast.symbol.symbolTable}function jy(){return this.parse.tokens().flatMap(e=>[...e.leadingInvalid,e,...e.trailingInvalid])}function My(){return this.parse.tokens().filter(Yu)}function Ny(e){return e.symbolTable?[...e.symbolTable.entries()].map(([e,t])=>({...ou(e).unwrap(),symbol:t})):[]}function Py(e,t){if(e.length===0)return[];let n=[];for(let r=t;r;r=r instanceof b?r.parent:void 0){if(!r.symbol?.symbolTable)continue;let{symbolTable:t}=r.symbol,i=[t],a=[];for(let t of e)a=i.flatMap(e=>Od(t).flatMap(t=>{let n=e.get(t),r=ou(t).unwrap_or(void 0);return!n||!r?[]:{...r,symbol:n}})),i=a.flatMap(e=>e.symbol.symbolTable?e.symbol.symbolTable:[]);n.push(...a)}return n}function Fy(e,t){return`${e.join(`.`)}@${t.id}`}function Iy(e){let t=this.token.flatStream(),{index:n,token:r}=this.container.token(e),i=n===void 0?-1:fc(t,e=>!e.isInvalid,n);if(i===-1)return[this.parse.ast()];let a=t[i].start,o=this.parse.ast(),s=[o];for(;;){let e=Zu(o).find(e=>Bl(a,e));if(e===void 0||e instanceof Yc)break;s.push(e),o=e}if(r?.kind===_.COLON)return s;for(;s.length>0;){let t=!1,n=h(s);if(n instanceof x){let r=this.parse.source();for(let i=n.end;i<e;i+=1)r[i]===`
|
|
14
|
+
`&&(s.pop(),t=!0)}else n instanceof ol||n instanceof sl?this.container.token(e).token!==n.op&&(s.pop(),t=!0):n instanceof C?n.listCloseBracket&&n.end<=e&&(s.pop(),t=!0):n instanceof ul?n.tupleCloseParen&&n.end<=e&&(s.pop(),t=!0):n instanceof dl?n.end<=e&&(s.pop(),t=!0):n instanceof S?n.blockCloseBrace&&n.end<=e&&(s.pop(),t=!0):n instanceof il||n.end<e&&(s.pop(),t=!0);if(t){let t=h(s);t instanceof b&&t.end<=e&&s.pop()}if(!t)break}return s}function Ly(e){let t=this.token.flatStream().findIndex(t=>t.start>=e);return t===void 0||t<=0?{token:void 0,index:void 0}:{token:this.token.flatStream()[t-1],index:t-1}}function Ry(e){let t=this.container.stack(e);for(let e=t.length-1;e>=0;--e)if(t[e]instanceof b)return t[e];return this.parse.ast()}function zy(e){return this.container.element(e)?.symbol?.symbolTable}let $=function(e){return e[e.TABLE=0]=`TABLE`,e[e.ENUM=1]=`ENUM`,e[e.TABLEGROUP=2]=`TABLEGROUP`,e[e.INDEXES=3]=`INDEXES`,e[e.NOTE=4]=`NOTE`,e[e.REF=5]=`REF`,e[e.PROJECT=6]=`PROJECT`,e[e.CUSTOM=7]=`CUSTOM`,e[e.TOPLEVEL=8]=`TOPLEVEL`,e[e.TABLEPARTIAL=9]=`TABLEPARTIAL`,e[e.CHECKS=10]=`CHECKS`,e[e.RECORDS=11]=`RECORDS`,e[e.DIAGRAMVIEW=12]=`DIAGRAMVIEW`,e}({});function By(e){let t=this.container.element(e);if(t instanceof rl)return $.TOPLEVEL;switch(t.type?.value.toLowerCase()){case`table`:return $.TABLE;case`enum`:return $.ENUM;case`ref`:return $.REF;case`tablegroup`:return $.TABLEGROUP;case`indexes`:return $.INDEXES;case`note`:return $.NOTE;case`project`:return $.PROJECT;case`tablepartial`:return $.TABLEPARTIAL;case`checks`:return $.CHECKS;case`records`:return $.RECORDS;case`diagramview`:return $.DIAGRAMVIEW;default:return $.CUSTOM}}function Vy(e,t,n=!1){let r=n?t:[...t].sort((e,t)=>t.start-e.start),i=e;for(let{start:e,end:t,newText:n}of r)i=i.substring(0,e)+n+i.substring(t);return i}function Hy(e){if(typeof e!=`string`)return{schema:e.schema??`public`,table:e.table};let t=Pv(e);if(t.length===0)return{schema:Gl,table:``};if(t.length===1)return{schema:Gl,table:t[0]};if(t.length===2)return{schema:t[0],table:t[1]};let n=t[t.length-1];return{schema:t.slice(0,-1).join(`.`),table:n}}function Uy(e,t,n){let r=Jl(n);if(t===`public`){let t=e.get(r);return t instanceof wl?t:null}let i=ql(t),a=e.get(i);if(!a||!a.symbolTable)return null;let o=a.symbolTable.get(r);return o instanceof wl?o:null}function Wy(e){return e.startsWith(`"`)&&e.endsWith(`"`)&&e.length>=2?e.slice(1,-1):e}function Gy(e){return e?e.split(``).every(e=>Fl(e)||Il(e))&&!Il(e[0]):!1}function Ky(e,t){if(!e.declaration)return!1;let n=e.declaration;if(!n.name)return!1;let r=n.name;return t.substring(r.start,r.end).includes(`"`)}function qy(e,t,n){let r=!Gy(t),i=!Gy(e),a=n||r,o=n||i;return{schema:e,table:t,formattedSchema:o?`"${e}"`:e,formattedTable:a?`"${t}"`:t,shouldQuoteSchema:o,shouldQuoteTable:a}}function Jy(e,t,n,r,i){let a=Jl(i),o;if(r===`public`)o=e.get(a);else{let t=ql(r),n=e.get(t);if(!n||!n.symbolTable)return!1;o=n.symbolTable.get(a)}return!(!o||t===r&&n===i)}function Yy(e,t,n){let r=e.start-1;for(;r>=0&&/\s/.test(n[r]);)r--;if(r<0||n[r]!==`.`)return null;for(r--;r>=0&&/\s/.test(n[r]);)r--;if(r<0)return null;let i,a;if(n[r]===`"`){for(a=r+1,r--;r>=0&&n[r]!==`"`;)r--;if(r<0)return null;i=r}else{for(a=r+1;r>=0&&/[a-zA-Z0-9_]/.test(n[r]);)r--;i=r+1}return Wy(n.substring(i,a))===t?{start:i,end:e.end}:null}function Xy(e,t,n,r){let i=[],a=new Set;for(let o of e){let e=Yy(o,t,r)??{start:o.start,end:o.end},s=`${e.start}-${e.end}`;if(a.has(s))continue;a.add(s);let c=n.schema===`public`?n.formattedTable:`${n.formattedSchema}.${n.formattedTable}`;i.push({start:e.start,end:e.end,newText:c})}return i}function Zy(e,t){let n=this.parse.source(),r=this.parse.publicSymbolTable(),i=Hy(e),a=Hy(t),o=i.schema,s=i.table,c=a.schema,l=a.table,u=Uy(r,o,s);if(!u||Jy(r,o,s,c,l))return n;let d=qy(c,l,Ky(u,n)),f=[];if(u.declaration){let e=u.declaration;e.name&&f.push(e.name)}for(let e of u.references)n.substring(e.start,e.end).replace(/"/g,``)===s&&f.push(e);return Vy(n,Xy(f,o,d,n))}function Qy(e){let t=[],n=new ad(e).lex();if(n.getErrors().length>0)return t;let r=new ld(e,n.getValue(),new nl).parse();if(r.getErrors().length>0)return t;let i=r.getValue().ast;for(let e of i.body)if(e.type?.value.toLowerCase()===A.DiagramView){let n=e.name?P(e.name).unwrap_or([]):[],r=n.length>0?n[n.length-1]:``;t.push({name:r,startIndex:e.start,endIndex:e.end})}return t}function $y(e,t){let n=[`DiagramView ${Av(e)} {`];if(t?.tables!==void 0&&t.tables!==null)if(t.tables.length===0)n.push(` Tables { * }`);else{let e=t.tables.map(e=>e.schemaName===`public`?e.name:`${e.schemaName}.${e.name}`);n.push(` Tables {`),e.forEach(e=>n.push(` ${e}`)),n.push(` }`)}return t?.stickyNotes!==void 0&&(t.stickyNotes===null||(t.stickyNotes.length===0?n.push(` Notes { * }`):(n.push(` Notes {`),t.stickyNotes.forEach(e=>n.push(` ${e.name}`)),n.push(` }`)))),t?.tableGroups!==void 0&&(t.tableGroups===null||(t.tableGroups.length===0?n.push(` TableGroups { * }`):(n.push(` TableGroups {`),t.tableGroups.forEach(e=>n.push(` ${e.name}`)),n.push(` }`)))),t?.schemas!==void 0&&(t.schemas===null||(t.schemas.length===0?n.push(` Schemas { * }`):(n.push(` Schemas {`),t.schemas.forEach(e=>n.push(` ${e.name}`)),n.push(` }`)))),n.push(`}`),n.join(`
|
|
15
|
+
`)}function eb(e,t,n){let r=n??Qy(e),i=[];for(let n of t){let t=tb(e,n,r);i.push(...t)}return i.sort((e,t)=>t.start-e.start),{newDbml:Vy(e,i,!0),edits:i}}function tb(e,t,n){switch(t.operation){case`create`:return nb(e,t,n);case`update`:return rb(e,t,n);case`delete`:return ib(e,t,n);default:return[]}}function nb(e,t,n){if(n.find(e=>e.name===t.name))return rb(e,t,n);let r=`
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
`;return[{start:e.length,end:e.length,newText:r}]}function
|
|
17
|
+
`+$y(t.name,t.visibleEntities)+`
|
|
18
|
+
`;return[{start:e.length,end:e.length,newText:r}]}function rb(e,t,n){let r=n.find(e=>e.name===t.name);if(!r)return[];let i=[];if(t.newName||t.visibleEntities){let e=$y(t.newName||t.name,t.visibleEntities);i.push({start:r.startIndex,end:r.endIndex,newText:e})}return i}function ib(e,t,n){let r=n.find(e=>e.name===t.name);if(!r)return[];let i=r.startIndex,a=r.endIndex;for(;i>0&&e[i-1]===`
|
|
19
19
|
`;){i--,i>0&&e[i-1]===`\r`&&i--;let t=e.lastIndexOf(`
|
|
20
20
|
`,i-1)+1;if(e.substring(t,i).trim()!==``){i=r.startIndex,i>0&&e[i-1]===`
|
|
21
21
|
`&&(i--,i>0&&e[i-1]===`\r`&&i--);break}}return a<e.length&&e[a]===`\r`&&a++,a<e.length&&e[a]===`
|
|
22
|
-
`&&a++,[{start:i,end:a,newText:``}]}var
|
|
22
|
+
`&&a++,[{start:i,end:a,newText:``}]}var ab=class{constructor(){this.source=``,this.cache=new Map,this.nodeIdGenerator=new nl,this.symbolIdGenerator=new bl,this.token={invalidStream:this.query(My),flatStream:this.query(jy)},this.parse={source:()=>this.source,_:this.query(this.interpret),ast:this.query(Ty),errors:this.query(Ey),warnings:this.query(Dy),tokens:this.query(Oy),rawDb:this.query(ky),publicSymbolTable:this.query(Ay)},this.container={stack:this.query(Iy),token:this.query(Ly),element:this.query(Ry),scope:this.query(zy),scopeKind:this.query(By)},this.symbol={ofName:this.query(Py,Fy),members:this.query(Ny)}}setSource(e){this.source=e,this.cache.clear(),this.nodeIdGenerator.reset(),this.symbolIdGenerator.reset()}query(e,t){let n=Symbol();return((...r)=>{if(r.length===0){if(this.cache.has(n))return this.cache.get(n);let t=e.apply(this,r);return this.cache.set(n,t),t}let i=t?t(...r):r[0],a=this.cache.get(n);if(a instanceof Map&&a.has(i))return a.get(i);let o=e.apply(this,r);return a instanceof Map||(a=new Map,this.cache.set(n,a)),a.set(i,o),o})}interpret(){let e=new ad(this.source).lex().chain(e=>new ld(this.source,e,this.nodeIdGenerator).parse()).chain(({ast:e,tokens:t})=>new Id(e,this.symbolIdGenerator).analyze().map(()=>({ast:e,tokens:t})));return e.getErrors().length>0?e:e.chain(({ast:e,tokens:t})=>new Dv(e).interpret().map(n=>({ast:e,tokens:t,rawDb:n})))}renameTable(e,t){return Zy.call(this,e,t)}syncDiagramView(e,t){return eb(this.parse.source(),e,t)}findDiagramViewBlocks(){return Qy(this.parse.source())}applyTextEdits(e){return Vy(this.parse.source(),e)}initMonacoServices(){return{definitionProvider:new by(this),referenceProvider:new xy(this),autocompletionProvider:new Jv(this),diagnosticsProvider:new Sy(this)}}};exports.CompileError=E,exports.CompileErrorCode=T,exports.Compiler=ab,exports.ElementDeclarationNode=b,exports.ElementKind=A,exports.FALSY_VALUES=B_,exports.ProgramNode=rl,exports.ScopeKind=$,exports.SyntaxNode=v,exports.SyntaxNodeKind=y,exports.SyntaxToken=Yc,exports.SyntaxTokenKind=_,exports.TRUTHY_VALUES=z_,exports.addDoubleQuoteIfNeeded=Av,exports.dbmlMonarchTokensProvider=Cy,exports.escapeString=Mv,exports.extractNumericLiteral=zu,exports.extractSignedNumber=I_,exports.formatRecordValue=Nv,exports.getLengthTypeParam=Sf,exports.getNumericTypeParams=xf,exports.getRecordValueType=Cf,exports.isBinaryType=_f,exports.isBooleanType=hf,exports.isDateTimeType=vf,exports.isEmptyStringLiteral=P_,exports.isFloatType=pf,exports.isFunctionExpression=F_,exports.isIntegerType=ff,exports.isNullish=N_,exports.isNumericType=mf,exports.isSerialType=yf,exports.isStringType=gf,exports.isValidIdentifier=kv,exports.normalizeTypeName=df,Object.defineProperty(exports,`services`,{enumerable:!0,get:function(){return wy}}),exports.splitQualifiedIdentifier=Pv,exports.tryExtractBoolean=V_,exports.tryExtractDateTime=q_,exports.tryExtractEnum=H_,exports.tryExtractInteger=R_,exports.tryExtractNumeric=L_,exports.tryExtractString=U_,exports.unescapeString=jv,exports.validateForeignKeys=pv,exports.validatePrimaryKey=nv,exports.validateUnique=uv;
|