{"version":3,"file":"use-presets.mjs","names":[],"sources":["../../src/presets/use-presets.ts"],"sourcesContent":["import type { BasePreset } from '@wordpress/global-styles-engine';\nimport { useSetting } from '../hooks';\n\nconst EMPTY_ARRAY: any[] = [];\n\n/**\n * Read + mutate the preset array stored at `${settingsPath}.${origin}`.\n *\n * `presets` reflects the merged (user-edited) value; `basePresets` is read\n * explicitly from the theme base, used to compare against or reset to the\n * theme-provided values.\n *\n * @param settingsPath Origin-keyed base path, e.g. 'shadow.presets'.\n * @param origin       'default' | 'theme' | 'custom'.\n */\nexport function usePresets< T extends BasePreset >(\n\tsettingsPath: string,\n\torigin: string\n) {\n\tconst path = `${ settingsPath }.${ origin }`;\n\tconst [ presets = EMPTY_ARRAY, setPresets ] = useSetting< T[] >( path );\n\tconst [ basePresets = EMPTY_ARRAY ] = useSetting< T[] >(\n\t\tpath,\n\t\tundefined,\n\t\t'base'\n\t);\n\n\treturn { presets, basePresets, setPresets };\n}\n"],"mappings":";;AAGA,MAAM,cAAqB,CAAC;;;;;;;;;;;AAY5B,SAAgB,WACf,cACA,QACC;CACD,MAAM,OAAO,GAAI,aAAc,GAAI;CACnC,MAAM,CAAE,UAAU,aAAa,cAAe,WAAmB,IAAK;CACtE,MAAM,CAAE,cAAc,eAAgB,WACrC,MACA,KAAA,GACA,MACD;CAEA,OAAO;EAAE;EAAS;EAAa;CAAW;AAC3C"}