import type { Response } from "../services/fetcher.ts"; /** Utility to extract an file extension form an string/url */ export declare function extractExtension(url: string): string | null; /** Utility function to extract a 4-digit year from a given text string. * This function searches for the first occurrence of a valid year (between 1900 and 2099) in the input text and returns it as a number. If no valid year is found, it returns null. * @param text - The input string from which to extract the year. * @returns The extracted year as a number, or null if no valid year is found. */ export declare function extractYearFromText(text: string): number | null; /** Extracts "Set-Cookie" header values from a headers object, normalizing to an array of strings. * This function checks for both "set-cookie" and "Set-Cookie" keys (case-insensitive) in the provided headers object. If found, it returns an array of cookie strings, ensuring that even a single string value is wrapped in an array. If no "Set-Cookie" header is present, it returns an empty array. * @param headers - An object representing HTTP headers, where keys are header names and values are either strings or arrays of strings. * @returns An array of cookie strings extracted from the "Set-Cookie" header, or an empty array if the header is not present. */ export declare function extractSetCookies(headers: Response["headers"] | Record): string[]; /** Extracts the first JavaScript code snippet that is passed to an `eval()` call within the provided source string. * This function uses a regular expression to search for the pattern `eval(...)` in the input source string. If a match is found, it returns the entire code snippet that is passed to `eval()`, including the `eval()` call itself. If no such pattern is found, it returns `null`. * @param source - The input string to search for `eval()` calls. * @returns The extracted code snippet passed to `eval()`, or `null` if no match is found. */ export declare function extractEvalCode(source: string): string | null; /** * Scans a source string for **any** `var/let/const` declaration whose assigned * object literal contains **all** of the specified `requiredKeys`. * * This is useful when the variable name changes across page renders (e.g. `p3`, * `cfg`, `_x2`) but the object shape is stable — you can identify it by the * keys it must contain. * * ```js * // varName unknown — find by required keys ["file", "key"] * let _x2 = { "file": "https://...", "key": "bKTI...", "hls": 0, ... }; * ``` * * @param source - Raw source string (e.g. full HTML page or script block). * @param requiredKeys - Every key listed here must exist in the parsed object. * @returns The first matching parsed object, or `null` if none is found. */ export declare function extractVariableByJSONKey(source: string, requiredKeys: string[]): Record | null; /** Extracts arguments from the first function or constructor call * inside a JavaScript source string. * * Supports: * - new Something(...) * - Something(...) * - function(...) * * If a single object literal is passed → returns parsed JSON. * Otherwise → returns indexed argument map. * * @param codeString - Full JavaScript source as string */ export declare function extractContructorJSONArguments(codeString: string): Record | null; /** Extracts the arguments of a specific named function call from an HTML body * or any source string, then parses them using {@link extractContructorJSONArguments}. * * The function locates the first occurrence of `functionName(...)` inside the * source (which can be a full HTML page), extracts the raw argument content * from inside the parentheses (handling nesting correctly), reconstructs a * minimal call string, and delegates parsing to `extractContructorJSONArguments`. * * @param source - Raw source string to search within (e.g. an HTML body). * @param functionName - Exact name of the function call to locate. * @returns Parsed argument map identical to {@link extractContructorJSONArguments}, or * `null` if the function call is not found or its args cannot be extracted. */ export declare function extractContructorJSONArgumentsByName(source: string, functionName: string): Record | null; /** * Extracts and parses a JSON object assigned to a JavaScript variable declaration. * * Handles `var`, `let`, and `const` declarations of the form: * `var/let/const varName = { ... };` * * Useful when a script first assigns a config object to a variable and then * passes that variable to a constructor, e.g.: * ```js * let p3 = { file: "...", hls: 0 }; * var ppl = new HDVBPlayer(p3); * ``` * * @param source - Raw source string (e.g. full HTML page or script block). * @param varName - The variable name whose value should be extracted. * @returns Parsed object, or `null` if not found / not parseable. */ export declare function extractVariableJSON(source: string, varName: string): Record | null; /** * Extracts the scalar value (string, number, boolean, null, or undefined) assigned * to a variable or property path anywhere in a JavaScript source string. * * Handles both: * - Declared variables: `const MDCore = "gjdw89lncgzrde";` * - Property assignments: `MDCore.ref = "gjdw89lncgzrde";` (no `var`/`let`/`const`) * * The `varName` argument may be a simple identifier (`"MDCore"`) **or** a dotted * property path (`"MDCore.ref"`). The search is case-sensitive and ignores * compound operators (`==`, `===`, `+=`, `=>`, …). * * @param source - Raw source string (e.g. full HTML page or a script block). * @param varName - Exact identifier or property path whose value is needed. * @returns The extracted value as a raw string, or `null` if not found / not parseable. * * @example * extractVariableValue(`const MDCore = "gjdw89lncgzrde";`, "MDCore"); * // → "gjdw89lncgzrde" * * extractVariableValue(`MDCore.ref = "gjdw89lncgzrde";`, "MDCore.ref"); * // → "gjdw89lncgzrde" */ export declare function extractVariableValue(source: string, varName: string): string | null;