{
  "version": 3,
  "sources": ["../../src/font-library/api.ts"],
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport type {\n\tCollectionFontFace,\n\tCollectionFontFamily,\n\tFontFace,\n} from '@wordpress/core-data';\nimport type { DataRegistry } from '@wordpress/data';\n\nconst FONT_FAMILIES_URL = '/wp/v2/font-families';\n\n/**\n * Invalidates the cache for font family queries.\n * This should be called after installing fonts\n * to ensure the UI reflects the latest state.\n *\n * @param registry The data registry to use for dispatching actions.\n */\nfunction invalidateFontFamilyCache( registry: DataRegistry ) {\n\tconst { receiveEntityRecords } = registry.dispatch( coreDataStore );\n\n\t// Invalidate all font family queries\n\t// Ideally there should be a dedicated action to do this\n\t// \"invalide all cacches for this entity type\"\n\treceiveEntityRecords(\n\t\t'postType',\n\t\t'wp_font_family',\n\t\t[],\n\t\tundefined,\n\t\ttrue // invalidateCache\n\t);\n}\n\nexport async function fetchInstallFontFamily(\n\tdata: FormData,\n\tregistry: DataRegistry\n) {\n\tconst config = {\n\t\tpath: FONT_FAMILIES_URL,\n\t\tmethod: 'POST',\n\t\tbody: data,\n\t};\n\tconst response: CollectionFontFamily = await apiFetch( config );\n\tinvalidateFontFamilyCache( registry );\n\n\treturn {\n\t\tid: response.id as string,\n\t\t...response.font_family_settings,\n\t\tfontFace: [],\n\t};\n}\n\nexport async function fetchInstallFontFace(\n\tfontFamilyId: string,\n\tdata: FormData,\n\tregistry: DataRegistry\n): Promise< FontFace > {\n\tconst config = {\n\t\tpath: `${ FONT_FAMILIES_URL }/${ fontFamilyId }/font-faces`,\n\t\tmethod: 'POST',\n\t\tbody: data,\n\t};\n\tconst response = ( await apiFetch( config ) ) as CollectionFontFace;\n\tinvalidateFontFamilyCache( registry );\n\treturn {\n\t\tid: response.id,\n\t\t...response.font_face_settings,\n\t};\n}\n"],
  "mappings": ";AAGA,OAAO,cAAc;AACrB,SAAS,SAAS,qBAAqB;AAQvC,IAAM,oBAAoB;AAS1B,SAAS,0BAA2B,UAAyB;AAC5D,QAAM,EAAE,qBAAqB,IAAI,SAAS,SAAU,aAAc;AAKlE;AAAA,IACC;AAAA,IACA;AAAA,IACA,CAAC;AAAA,IACD;AAAA,IACA;AAAA;AAAA,EACD;AACD;AAEA,eAAsB,uBACrB,MACA,UACC;AACD,QAAM,SAAS;AAAA,IACd,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,MAAM;AAAA,EACP;AACA,QAAM,WAAiC,MAAM,SAAU,MAAO;AAC9D,4BAA2B,QAAS;AAEpC,SAAO;AAAA,IACN,IAAI,SAAS;AAAA,IACb,GAAG,SAAS;AAAA,IACZ,UAAU,CAAC;AAAA,EACZ;AACD;AAEA,eAAsB,qBACrB,cACA,MACA,UACsB;AACtB,QAAM,SAAS;AAAA,IACd,MAAM,GAAI,iBAAkB,IAAK,YAAa;AAAA,IAC9C,QAAQ;AAAA,IACR,MAAM;AAAA,EACP;AACA,QAAM,WAAa,MAAM,SAAU,MAAO;AAC1C,4BAA2B,QAAS;AACpC,SAAO;AAAA,IACN,IAAI,SAAS;AAAA,IACb,GAAG,SAAS;AAAA,EACb;AACD;",
  "names": []
}
