{"version":3,"file":"path-pattern.class-Dg95YGLM.js","sources":["../../../src/packages/core/router/path-pattern.class.ts"],"sourcesContent":["import { umbUrlPatternToString } from '../utils/path/url-pattern-to-string.function.js';\n\nexport type UmbPathPatternParamsType = { [key: string]: any };\n\n// Replaces property union type null with 'null' [NL]\ntype ReplaceNull = T extends null ? 'null' : T;\nexport type UmbPathPatternTypeAsEncodedParamsType = {\n\t[P in keyof T]: T[P] extends (infer R)[] ? ReplaceNull[] : ReplaceNull;\n};\n\nexport class UmbPathPattern<\n\tLocalParamsType extends UmbPathPatternParamsType = UmbPathPatternParamsType,\n\tBaseParamsType extends UmbPathPatternParamsType = LocalParamsType,\n> {\n\t#local: string;\n\t#base: string;\n\n\t/**\n\t * Get the params type of the path pattern\n\t * @public\n\t * @type {T}\n\t * @memberOf UmbPathPattern\n\t * @example `typeof MyPathPattern.PARAMS`\n\t */\n\treadonly PARAMS!: LocalParamsType;\n\n\t/**\n\t * Get absolute params type of the path pattern\n\t * @public\n\t * @type {T}\n\t * @memberOf UmbPathPattern\n\t * @example `typeof MyPathPattern.ABSOLUTE_PARAMS`\n\t */\n\treadonly ABSOLUTE_PARAMS!: LocalParamsType & BaseParamsType;\n\n\tconstructor(localPattern: string, basePath?: UmbPathPattern | string) {\n\t\tthis.#local = localPattern;\n\t\tbasePath = basePath?.toString() ?? '';\n\t\tthis.#base = basePath.lastIndexOf('/') !== basePath.length - 1 ? basePath + '/' : basePath;\n\t}\n\n\tgenerateLocal(params: LocalParamsType) {\n\t\treturn umbUrlPatternToString(this.#local, params);\n\t}\n\t/**\n\t * generate an absolute path from the path pattern\n\t * @param params\n\t * @param baseParams\n\t * @returns\n\t */\n\tgenerateAbsolute(params: LocalParamsType & BaseParamsType) {\n\t\treturn (\n\t\t\t(this.#base.indexOf(':') !== -1 ? umbUrlPatternToString(this.#base, params) : this.#base) +\n\t\t\tumbUrlPatternToString(this.#local, params)\n\t\t);\n\t}\n\n\ttoString() {\n\t\treturn this.#local;\n\t}\n}\n"],"names":["UmbPathPattern","#local","#base","localPattern","basePath","params","umbUrlPatternToString"],"mappings":";AAUO,MAAMA,EAGX;AAAA,EACDC;AAAA,EACAC;AAAA,EAoBA,YAAYC,GAAsBC,GAAoC;AACrE,SAAKH,KAASE,GACHC,IAAAA,GAAU,SAAc,KAAA,IAC9B,KAAAF,KAAQE,EAAS,YAAY,GAAG,MAAMA,EAAS,SAAS,IAAIA,IAAW,MAAMA;AAAA,EACnF;AAAA,EAEA,cAAcC,GAAyB;AAC/B,WAAAC,EAAsB,KAAKL,IAAQI,CAAM;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,iBAAiBA,GAA0C;AAC1D,YACE,KAAKH,GAAM,QAAQ,GAAG,MAAM,KAAKI,EAAsB,KAAKJ,IAAOG,CAAM,IAAI,KAAKH,MACnFI,EAAsB,KAAKL,IAAQI,CAAM;AAAA,EAE3C;AAAA,EAEA,WAAW;AACV,WAAO,KAAKJ;AAAA,EACb;AACD;"}