'use strict';
import { propertyTypes } from '../../../properties/property-type.js';
import { dbTypes } from '../../../../../base-repo/constants/tools-constants.js';
import { createError } from '../../../../../fd-toolbox/errors/errors.js';
import { jsBasicTypes } from '../../../../../base-repo/constants/basic-types.js';
import { dbSchemaBasicTypes, contentFormatNames } from '../../../../../base-repo/constants/internal-common-strings.js';

var __defProp=Object['defineProperty'],__name=(_0x27cc3a,_0xe9453e)=>__defProp(_0x27cc3a,'name',{'value':_0xe9453e,'configurable':!![]});const integerColumnBuilder=dbSchemaBasicTypes['integer'];class SchemaAdapter{static{__name(this,'SchemaAdapter');}#dbType;constructor(_0x2ffe4c){this.#dbType=_0x2ffe4c;}['getSchemaPackageName'](){switch(this.#dbType){case dbTypes['sqlite']:return 'drizzle-orm/sqlite-core';case dbTypes['postgres']:return 'drizzle-orm/pg-core';default:throw this.#createUnsupportedError();}}['getSchemaTableConstructor'](){switch(this.#dbType){case dbTypes['sqlite']:return 'sqliteTable';case dbTypes['postgres']:return 'pgTable';default:throw this.#createUnsupportedError();}}['getSchemaAnyColumnType'](){switch(this.#dbType){case dbTypes['sqlite']:return 'AnySQLiteColumn';case dbTypes['postgres']:return 'AnyPgColumn';default:throw this.#createUnsupportedError();}}['getSchemaColumnDefinition'](_0x236ab7){let _0x230ab3;if(this.#dbType===dbTypes['sqlite'])_0x230ab3=this.#getSqliteColumnDefinition(_0x236ab7);else {if(this.#dbType===dbTypes['postgres'])_0x230ab3=this.#getPostgresColumnDefinition(_0x236ab7);else throw this.#createUnsupportedError();}return _0x230ab3;}#getPostgresColumnDefinition(_0x438008){const _0x2c692e=[];let _0xdfb423;switch(_0x438008['type']){case propertyTypes['integer']:_0xdfb423=integerColumnBuilder;break;case propertyTypes['number']:_0xdfb423='doublePrecision';break;case propertyTypes['boolean']:_0xdfb423=jsBasicTypes['boolean'];break;case propertyTypes['dateTime']:case propertyTypes['date']:_0xdfb423='timestamp';break;case propertyTypes['uuid']:case propertyTypes['string']:default:_0xdfb423=contentFormatNames['text'];break;}_0x2c692e['push'](_0xdfb423);let _0x3b4edf=_0xdfb423+'(\x22'+_0x438008['name']+'\x22)';return _0x438008['type']===-0xc46+-0x1937+0x2582&&(_0x3b4edf+='.array()'),{'method':_0xdfb423,'definition':_0x3b4edf,'imports':_0x2c692e};}#getSqliteColumnDefinition(_0x406226){const _0x509b26=[];let _0x80c0fc,_0x4b592e;switch(_0x406226['type']){case propertyTypes['integer']:_0x80c0fc=integerColumnBuilder,_0x4b592e=integerColumnBuilder+'(\x22'+_0x406226['name']+'\x22)';break;case propertyTypes['number']:_0x80c0fc='real',_0x4b592e='real(\x22'+_0x406226['name']+'\x22)';break;case propertyTypes['boolean']:_0x80c0fc=integerColumnBuilder,_0x4b592e=integerColumnBuilder+'(\x22'+_0x406226['name']+'\x22,\x20{\x20mode:\x20\x22boolean\x22\x20})';break;case propertyTypes['dateTime']:case propertyTypes['date']:_0x80c0fc=integerColumnBuilder,_0x4b592e=integerColumnBuilder+'(\x22'+_0x406226['name']+'\x22,\x20{\x20mode:\x20\x22timestamp\x22\x20})';break;case propertyTypes['uuid']:case propertyTypes['string']:default:_0x80c0fc=contentFormatNames['text'],_0x4b592e=contentFormatNames['text']+'(\x22'+_0x406226['name']+'\x22)';break;}return _0x406226['type']===0x1cfd+-0x14ce+-0x82a&&(_0x80c0fc=contentFormatNames['text'],_0x4b592e=contentFormatNames['text']+'(\x22'+_0x406226['name']+'\x22,\x20{\x20mode:\x20\x22json\x22\x20})'),_0x509b26['push'](_0x80c0fc),{'method':_0x80c0fc,'definition':_0x4b592e,'imports':_0x509b26};}#createUnsupportedError(){return createError('Schema\x20generation\x20not\x20supported\x20for\x20DB\x20type:\x20'+this.#dbType);}}

export { SchemaAdapter };
