import { a as RuleName, i as Questions, l as Engine, s as Situation } from "../index-PpPG9s53.cjs"; import { a as aidesWithLocalisation, i as Localisation, t as AideRuleNames } from "../index-BPMv9o7z.cjs"; //#region src/lib/AidesVeloEngine.d.ts /** * Represents an aid with its metadata. */ type Aide = { /** The rule name of the aid (see {@link AideRuleNames}). */id: AideRuleNames; /** The title of the aid (as defined in the Publicodes rules). */ title: string; /** The description of the aid (with resolved placeholders). */ description: string | undefined; /** The URL of the aid (as defined in the Publicodes rules). */ url: string; /** The collectivity that provides the aid. */ collectivity: { kind: "pays" | "région" | "département" | "epci" | "code insee"; value: string; code?: string; }; /** The amount of the aid in euros. */ amount: number; /** * The miniature URL of the collectivity providing the aid. * * @note The URL points to the * `github.com/betagouv/aides-jeunes/public/img/institution` directory. You * probably want to extract the miniature from the URL and format them * according to your needs. */ logo: string | undefined; lastUpdate?: Date; endDate?: Date; }; /** * A wrapper around the {@link Engine} class to compute the available aids for the * given inputs (which are a subset of the Publicodes situation corresponding to * the rules that are questions). * * @note This class is stateful and should be used to compute the aids for a * single situation. If you want to compute the aids for multiple situations, * you should create a new instance of this class for each situation. You * can use {@link shallowCopy} to create a new instance with the same rules and * inputs. */ declare class AidesVeloEngine { private inputs; private engine; /** * Create a new instance of the engine with a initialized set of rules. * * @param empty If `true`, the engine will be created with an empty set of * rules. Otherwise, it will be created with the default set of rules. */ constructor(empty?: boolean); /** * Set the inputs of the engine. This will update the Publicodes situation * with the given inputs. * * @param inputs The inputs to set (corresponding to the rules that are * questions). * * @note The format of the inputs are in the JS format, not the Publicodes * format. For example, boolean values are represented as `true` or `false` * instead of `oui` or `non` and the values are not wrapped in single quotes. */ setInputs(inputs: Questions): this; /** * Set the situation of the engine. This will update the Publicodes situation * with the given situation. * * @param situation The situation to set. * @returns The instance of the engine with the updated situation. * * @note This is a low-level method prefer using {@link setInputs} instead. */ setSituation(situation: Situation): this; /** * Filter the available aids by the given country. * * @param country The country to filter the aids by. The default is `france`. * @returns The list of available aids with their metadata (see {@link * Aide}). * * @note No computation is done here. This is just a filter on the available * aids. */ getAllAidesIn(country?: Localisation["country"]): Omit[]; /** * Compute all the available aids for the current inputs (see {@link setInputs}). * * @returns The list of available aids with their metadata (see {@link Aide}). */ computeAides(): Aide[]; /** * Create a shallow copy of the engine with the same rules and inputs. This * is useful to compute the aids for multiple situations. * * @returns A new instance of the engine with the same rules and inputs. */ shallowCopy(): AidesVeloEngine; /** * Return a shallow copy of the wrapped Publicodes engine. This is useful to * get the current state of the engine (rules and inputs) without modifying * it. */ getEngine(): Engine; /** * Get the options of a question by its name, if it has any. * * @param name The name of the question to get the options of. * @returns The list of options or `undefined` if the question doesn't have * any. */ getOptions(name: T): Questions[T][] | undefined; /** * Format the description of an aid by replacing the placeholders with the * evaluated values. * * @param ruleName The name of the rule to format. * @param engine The Publicodes engine used to evaluate the rule. * @param veloCat The category of the bike. * @param ville The name of the city. * * @returns The formatted description. * * NOTE: this method is legacy from mesaidesvelo.fr and should be removed at * some point to simplify the code base. Or if needed, placeholders should be * replaced with the `texte` mechanism in the publicodes rules. */ formatDescription({ ruleName, veloCat, ville }: { ruleName: RuleName; veloCat: Questions["vélo . type"]; ville: string; }): string; } //#endregion //#region src/lib/utils.d.ts /** * Slugify a string by removing accents, converting to lowercase, and replacing * spaces with hyphens. * * @note It's used to generate the slugified name of the communes. * * Source: https://byby.dev/js-slugify-string */ declare function slugify(str: string): string; //#endregion export { type Aide, type AideRuleNames, AidesVeloEngine, type Localisation, type Questions, type RuleName, type Situation, aidesWithLocalisation, slugify };