{"version":3,"file":"time.cjs","names":["MsSqlColumnBuilder","entityKind","MsSqlColumn"],"sources":["../../../src/mssql-core/columns/time.ts"],"sourcesContent":["import type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyMsSqlTable } from '~/mssql-core/table.ts';\nimport { type Equal, getColumnNameAndConfig } from '~/utils.ts';\nimport { MsSqlColumn, MsSqlColumnBuilder } from './common.ts';\n\nexport class MsSqlTimeStringBuilder extends MsSqlColumnBuilder<\n\t{\n\t\tdataType: 'string time';\n\t\tdata: string;\n\t\tdriverParam: string | Date;\n\t},\n\tTimeConfig\n> {\n\tstatic override readonly [entityKind]: string = 'MsSqlTimeBuilder';\n\n\tconstructor(\n\t\tname: string,\n\t\tconfig: TimeConfig | undefined,\n\t) {\n\t\tsuper(name, 'string time', 'MsSqlTime');\n\t\tthis.config.precision = config?.precision;\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMsSqlTable<{ name: TTableName }>,\n\t) {\n\t\treturn new MsSqlTimeString(\n\t\t\ttable,\n\t\t\tthis.config,\n\t\t);\n\t}\n}\n\nexport class MsSqlTimeString<T extends ColumnBaseConfig<'string time'>> extends MsSqlColumn<T, TimeConfig> {\n\tstatic override readonly [entityKind]: string = 'MsSqlTime';\n\n\treadonly fsp: number | undefined = this.config.precision;\n\n\tgetSQLType(): string {\n\t\tconst precision = this.fsp === undefined ? '' : `(${this.fsp})`;\n\t\treturn `time${precision}`;\n\t}\n\n\toverride mapFromDriverValue = (value: Date | string | null): string | null => {\n\t\treturn typeof value === 'string' ? value : value?.toISOString().split('T')[1]?.split('Z')[0] ?? null;\n\t};\n}\n\nexport class MsSqlTimeBuilder extends MsSqlColumnBuilder<\n\t{\n\t\tdataType: 'object date';\n\t\tdata: Date;\n\t\tdriverParam: string | Date;\n\t},\n\tTimeConfig\n> {\n\tstatic override readonly [entityKind]: string = 'MsSqlTimeBuilder';\n\n\tconstructor(\n\t\tname: string,\n\t\tconfig: TimeConfig | undefined,\n\t) {\n\t\tsuper(name, 'object date', 'MsSqlTime');\n\t\tthis.config.precision = config?.precision;\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMsSqlTable<{ name: TTableName }>,\n\t) {\n\t\treturn new MsSqlTime(table, this.config);\n\t}\n}\n\nexport class MsSqlTime<\n\tT extends ColumnBaseConfig<'object date'>,\n> extends MsSqlColumn<T, TimeConfig> {\n\tstatic override readonly [entityKind]: string = 'MsSqlTime';\n\n\treadonly fsp: number | undefined = this.config.precision;\n\n\tgetSQLType(): string {\n\t\tconst precision = this.fsp === undefined ? '' : `(${this.fsp})`;\n\t\treturn `time${precision}`;\n\t}\n}\nexport type TimeConfig<TMode extends 'date' | 'string' = 'date' | 'string'> = {\n\tprecision?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;\n\tmode?: TMode;\n};\n\nexport function time<TMode extends TimeConfig['mode'] & {}>(\n\tconfig?: TimeConfig<TMode>,\n): Equal<TMode, 'string'> extends true ? MsSqlTimeStringBuilder : MsSqlTimeBuilder;\nexport function time<TMode extends TimeConfig['mode'] & {}>(\n\tname: string,\n\tconfig?: TimeConfig<TMode>,\n): Equal<TMode, 'string'> extends true ? MsSqlTimeStringBuilder\n\t: MsSqlTimeBuilder;\nexport function time(a?: string | TimeConfig, b?: TimeConfig) {\n\tconst { name, config } = getColumnNameAndConfig<TimeConfig | undefined>(a, b);\n\tif (config?.mode === 'string') {\n\t\treturn new MsSqlTimeStringBuilder(name, config);\n\t}\n\treturn new MsSqlTimeBuilder(name, config);\n}\n"],"mappings":";;;;;;;AAMA,IAAa,yBAAb,cAA4CA,qDAO1C;CACD,QAA0BC,0BAAsB;CAEhD,YACC,MACA,QACC;AACD,QAAM,MAAM,eAAe,YAAY;AACvC,OAAK,OAAO,YAAY,QAAQ;;;CAIjC,AAAS,MACR,OACC;AACD,SAAO,IAAI,gBACV,OACA,KAAK,OACL;;;AAIH,IAAa,kBAAb,cAAgFC,8CAA2B;CAC1G,QAA0BD,0BAAsB;CAEhD,AAAS,MAA0B,KAAK,OAAO;CAE/C,aAAqB;AAEpB,SAAO,OADW,KAAK,QAAQ,SAAY,KAAK,IAAI,KAAK,IAAI;;CAI9D,AAAS,sBAAsB,UAA+C;AAC7E,SAAO,OAAO,UAAU,WAAW,QAAQ,OAAO,aAAa,CAAC,MAAM,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,MAAM;;;AAIlG,IAAa,mBAAb,cAAsCD,qDAOpC;CACD,QAA0BC,0BAAsB;CAEhD,YACC,MACA,QACC;AACD,QAAM,MAAM,eAAe,YAAY;AACvC,OAAK,OAAO,YAAY,QAAQ;;;CAIjC,AAAS,MACR,OACC;AACD,SAAO,IAAI,UAAU,OAAO,KAAK,OAAO;;;AAI1C,IAAa,YAAb,cAEUC,8CAA2B;CACpC,QAA0BD,0BAAsB;CAEhD,AAAS,MAA0B,KAAK,OAAO;CAE/C,aAAqB;AAEpB,SAAO,OADW,KAAK,QAAQ,SAAY,KAAK,IAAI,KAAK,IAAI;;;AAiB/D,SAAgB,KAAK,GAAyB,GAAgB;CAC7D,MAAM,EAAE,MAAM,kDAA0D,GAAG,EAAE;AAC7E,KAAI,QAAQ,SAAS,SACpB,QAAO,IAAI,uBAAuB,MAAM,OAAO;AAEhD,QAAO,IAAI,iBAAiB,MAAM,OAAO"}