{"version":3,"file":"values.mjs","names":[],"sources":["../../../../../../src/libs/collection/custom-fields/fields/range/values.ts"],"sourcesContent":["/** Preserves invalid input shapes for validation while normalizing valid slider values. */\nexport const normalizeRangeInputValue = (\n\tvalue: unknown,\n\tthumbs?: 1 | 2,\n): unknown => {\n\tif (!Array.isArray(value)) return value;\n\n\tconst limit = thumbs === 2 ? 2 : 1;\n\tconst limited = value.slice(0, limit);\n\tif (\n\t\tlimited.every(\n\t\t\t(item): item is number =>\n\t\t\t\ttypeof item === \"number\" && Number.isFinite(item),\n\t\t)\n\t) {\n\t\treturn limited.toSorted((a, b) => a - b);\n\t}\n\n\treturn limited;\n};\n\n/** Produces the stable array shape used by relation-table inserts and responses. */\nexport const normalizeStoredRangeValues = (\n\tvalue: unknown,\n\tthumbs?: 1 | 2,\n): number[] => {\n\tif (!Array.isArray(value)) return [];\n\n\tconst limit = thumbs === 2 ? 2 : 1;\n\treturn value\n\t\t.filter(\n\t\t\t(item): item is number =>\n\t\t\t\ttypeof item === \"number\" && Number.isFinite(item),\n\t\t)\n\t\t.slice(0, limit)\n\t\t.toSorted((a, b) => a - b);\n};\n"],"mappings":"AACA,MAAa,GACZ,EACA,IACa,CACb,GAAI,CAAC,MAAM,QAAQ,CAAK,EAAG,OAAO,EAElC,IAAM,EAAQ,IAAW,EAAI,EAAI,EAC3B,EAAU,EAAM,MAAM,EAAG,CAAK,EAUpC,OARC,EAAQ,MACN,GACA,OAAO,GAAS,UAAY,OAAO,SAAS,CAAI,CAClD,EAEO,EAAQ,UAAU,EAAG,IAAM,EAAI,CAAC,EAGjC,CACR,EAGa,GACZ,EACA,IACc,CACd,GAAI,CAAC,MAAM,QAAQ,CAAK,EAAG,MAAO,CAAC,EAEnC,IAAM,EAAQ,IAAW,EAAI,EAAI,EACjC,OAAO,EACL,OACC,GACA,OAAO,GAAS,UAAY,OAAO,SAAS,CAAI,CAClD,CAAC,CACA,MAAM,EAAG,CAAK,CAAC,CACf,UAAU,EAAG,IAAM,EAAI,CAAC,CAC3B"}