{
  "version": 3,
  "sources": ["../../../src/font-library/utils/sort-font-faces.ts"],
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { FontFace } from '@wordpress/core-data';\n\nfunction getNumericFontWeight( value: string ): number {\n\tswitch ( value ) {\n\t\tcase 'normal':\n\t\t\treturn 400;\n\t\tcase 'bold':\n\t\t\treturn 700;\n\t\tcase 'bolder':\n\t\t\treturn 500;\n\t\tcase 'lighter':\n\t\t\treturn 300;\n\t\tdefault:\n\t\t\treturn parseInt( value, 10 );\n\t}\n}\n\nexport function sortFontFaces( faces: FontFace[] ): FontFace[] {\n\treturn faces.sort( ( a, b ) => {\n\t\t// Ensure 'normal' fontStyle is always first\n\t\tif ( a.fontStyle === 'normal' && b.fontStyle !== 'normal' ) {\n\t\t\treturn -1;\n\t\t}\n\t\tif ( b.fontStyle === 'normal' && a.fontStyle !== 'normal' ) {\n\t\t\treturn 1;\n\t\t}\n\n\t\t// If both fontStyles are the same, sort by fontWeight\n\t\tif ( a.fontStyle === b.fontStyle ) {\n\t\t\treturn (\n\t\t\t\tgetNumericFontWeight( a.fontWeight?.toString() ?? 'normal' ) -\n\t\t\t\tgetNumericFontWeight( b.fontWeight?.toString() ?? 'normal' )\n\t\t\t);\n\t\t}\n\n\t\t// Sort other fontStyles alphabetically\n\t\tif ( ! a.fontStyle || ! b.fontStyle ) {\n\t\t\treturn ! a.fontStyle ? 1 : -1;\n\t\t}\n\n\t\treturn a.fontStyle.localeCompare( b.fontStyle );\n\t} );\n}\n"],
  "mappings": ";AAKA,SAAS,qBAAsB,OAAwB;AACtD,UAAS,OAAQ;AAAA,IAChB,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AACJ,aAAO;AAAA,IACR;AACC,aAAO,SAAU,OAAO,EAAG;AAAA,EAC7B;AACD;AAEO,SAAS,cAAe,OAAgC;AAC9D,SAAO,MAAM,KAAM,CAAE,GAAG,MAAO;AAE9B,QAAK,EAAE,cAAc,YAAY,EAAE,cAAc,UAAW;AAC3D,aAAO;AAAA,IACR;AACA,QAAK,EAAE,cAAc,YAAY,EAAE,cAAc,UAAW;AAC3D,aAAO;AAAA,IACR;AAGA,QAAK,EAAE,cAAc,EAAE,WAAY;AAClC,aACC,qBAAsB,EAAE,YAAY,SAAS,KAAK,QAAS,IAC3D,qBAAsB,EAAE,YAAY,SAAS,KAAK,QAAS;AAAA,IAE7D;AAGA,QAAK,CAAE,EAAE,aAAa,CAAE,EAAE,WAAY;AACrC,aAAO,CAAE,EAAE,YAAY,IAAI;AAAA,IAC5B;AAEA,WAAO,EAAE,UAAU,cAAe,EAAE,SAAU;AAAA,EAC/C,CAAE;AACH;",
  "names": []
}
