import { DateTime, Duration, Interval, Zone, FixedOffsetZone } from "luxon"; export declare const XML_MIME = "application/xml"; export declare const JSON_MIME = "application/json"; export declare const JSONAPI_MIME = "application/vnd.api+json"; export declare const SVG_MIME = "image/svg+xml"; export declare const TEXT_MIME = "text/plain"; export declare const BINARY_MIME = "application/octet-stream"; export declare const UTC_OPTIONS: { zone: FixedOffsetZone; }; export declare function hasArgs(value: unknown): boolean; export declare function hasNoArgs(value: unknown): boolean; export declare function isStringArg(value: unknown): value is string; export declare function isNumArg(value: unknown): value is number; export declare function isNonEmptyStringArg(value: unknown): value is string; export declare function isObject(obj: unknown): obj is object; export declare function isDef(value: Value | undefined | null): value is Value; export declare function reErrorWithMessage(err: unknown, message: string): Error; export interface StringDictionary { [index: string]: unknown; } export declare function asStringDictionary(inobj: unknown): StringDictionary; export declare function doStringGetterSetter(inobj: unknown, field: string, value?: string): unknown; export declare function doBoolGetterSetter(inobj: unknown, field: string, value?: boolean): unknown; export declare function doIntGetterSetter(inobj: unknown, field: string, value?: number): unknown; export declare function doFloatGetterSetter(inobj: unknown, field: string, value?: number): StringDictionary; export declare function doMomentGetterSetter(inobj: unknown, field: string, value?: DateTime | string): StringDictionary; /** * Converts entire DataView to a string as utf-8. * * @param dataView bytes to convert * @returns the string */ export declare function dataViewToString(dataView: DataView): string; /** * Log a message to the console. Put here to limit lint console errors * for the times we really do want to use console.log. Will also append a * p tag to a div#debug if it exists. * * @param msg the message to log */ export declare function log(msg: string): void; /** * typescript-y check if Error. * * @param error object that might be an Error * @returns true if Error object */ export declare function isError(error: unknown): error is Error; /** * typescript-y convert errors. * * @param maybeError obejct that might be an Error object * @returns an Error object */ export declare function toError(maybeError: unknown): Error; export declare const DEBUG_ELEMENT = "sp-debug"; export declare class SeisPlotDebugElement extends HTMLElement { constructor(); getCodeElement(): HTMLElement | null; debug(msg: string): void; clear(): void; } /** * Log a warning message to the console. Put here to limit lint console errors * for the times we really do want to use console.log. Will also append a * p tag to a div#debug if it exists. * * @param msg the message to log */ export declare function warn(msg: string): void; /** * String representation of input. This is kind of dumb but makes * flow happier. * * @param value any kind of thing that can be turned into a string * @returns a string */ export declare function stringify(value: unknown): string; export declare function isoToDateTime(val: string): DateTime; /** * Create a luxon Interval from a start and end. * * @param start start of the interval as iso string or DateTime * @param end end of the interval as string or DateTime * @returns the interval */ export declare function startEnd(start: string | DateTime, end: string | DateTime): Interval; /** * Create a luxon Interval from a start and a duration. If the duration is negative, the * start time will become the end time. This differs from luxon Interval.after which * will return an invalid Interval instead. * * @param start start of the interval as iso string or DateTime * @param duration duration of the interval as iso string, number of seconds, or Duration * @returns the interval */ export declare function startDuration(start: string | DateTime, duration: string | Duration | number): Interval; /** * Create a luxon Interval from a duration and a end. If the duration is negative, the * end time will become the start time. This differs from luxon Interval.before which * will return an invalid Interval instead. * * @param duration duration of the interval as iso string, number of seconds, or Duration * @param end end of the interval as string or DateTime * @returns the interval */ export declare function durationEnd(duration: string | Duration | number, end: string | DateTime): Interval; /** * Create a luxon Interval from a duration and a center time. The final duration * will be twice the input. * * @param duration half duration of the interval as iso string, number of seconds, or Duration * @param end center of the interval as string or DateTime * @returns the interval */ export declare function centerTimeDuration(center: string | DateTime, duration: string | Duration | number): Interval; /** * Calculates offset of remote server versus local time. It is assumed that the * argument was acquired as close in time to calling this as possible. * * @param serverTimeUTC now as reported by remote server * @returns offset in seconds to now on local machine */ export declare function calcClockOffset(serverTimeUTC: DateTime): number; export declare const WAY_FUTURE: DateTime; export declare const WAY_PAST: DateTime; /** * converts the input value is a DateTime, throws Error if not * a string, Date or DateTime. Zero length string or "now" return * current time. * * @param d 'now', string time, Date, number of milliseconds since epoch, or DateTime * @returns DateTime created from argument */ export declare function checkStringOrDate(d: string | Date | DateTime): DateTime; /** * Converts name and value into a html query parameter, with appending ampersand. * * @param name parameter name * @param val parameter value * @returns formated query parameter */ export declare function makeParam(name: string, val: unknown): string; /** * Converts name and value into a parameter line, with appending newline, * for including in POST body. * * @param name parameter name * @param val parameter value * @returns formated query parameter */ export declare function makePostParam(name: string, val: unknown): string; /** * converts to ISO8601 but removes the trailing Z as FDSN web services * do not allow that. * * @param date DateTime to convert to string * @returns ISO8601 without timezone Z */ export declare function toIsoWoZ(date: DateTime): string; /** * Extracts a valid starting DateTime from interval. * Throws Error if interval is not valid. * @param interval luxon Interval * @returns start DateTime */ export declare function validStartTime(interval: Interval): DateTime; /** * Extracts a valid ending DateTime from interval. * Throws Error if interval is not valid. * @param interval luxon Interval * @returns end DateTime */ export declare function validEndTime(interval: Interval): DateTime; /** * Converts a luxon DateTime to a Javascript Date, checking for null, * undefined and isValid first. Throws Error in that case. * * @param d luxon DateTime * @returns Javascript Date */ export declare function toJSDate(d: DateTime | null | undefined): Date; /** * Check a Luxon DateTime, Interval or Duration for valid. * Throws Error if not. THis is to avoid globally setting * luxon's Settings.throwOnInvalid = true; * but still throw/catch on invalid dates. * @param d luxon object * @param msg optional message to add to error * @returns passed in object if valid */ export declare function checkLuxonValid(d: null | DateTime | Interval | Duration, msg?: string): Duration | DateTime | Interval; /** * Create string name for a timezone. Uses zone name except for UTC, which * returns "UTC". * * @param zone timezone to describe * @param atTime optional time to calc name at ie EST vs EDT * @return string version of zone */ export declare function nameForTimeZone(zone: string | null | Zone, atTime?: DateTime | null): string; /** * Utility method to pull raw text result from a url. * Result returned is an Promise. * * @param url the url * @returns promise to string result */ export declare function pullText(url: string, timeoutSec?: number): Promise; /** * Utility method to pull raw json result from a url. * Result returned is an Promise. * * @param url the url * @returns promise to string result */ export declare function pullJson(url: string, timeoutSec?: number): Promise>; /** * @returns the protocol, http: or https: for the document if possible. * Note this includes the colon. */ export declare function checkProtocol(defaultProtocol?: string): string; /** * Upgrade url protocol to https if document location is https * @param url url to upgrade * @return upgraded url */ export declare function fixProtocolInUrl(url: string): string; export interface FetchInitObject { cache: string; redirect: string; mode: string; referrer: string; headers: Record; signal?: AbortSignal; } /** * Create default fetch init object with the given mimeType. Sets * no-cache, follow redirects, cors mode, referrer as seisplotjs and * mimetype as a header. Note that redirect with POST may fail due to * POST being changed to GET on a 301. Fetching with POST may wish * to use redirect: "manual" to handle the 301 correctly by POSTing to * the new URL. * * * @param mimeType requested mime type * @returns object with fetch configuration parameters */ export declare function defaultFetchInitObj(mimeType?: string): RequestInit; export declare function cloneFetchInitObj(fetchInit: RequestInit): RequestInit; export declare function errorFetch(_url: URL | RequestInfo, _init?: RequestInit): Promise; export declare let default_fetch: null | ((url: URL | RequestInfo, init?: RequestInit) => Promise); export declare function setDefaultFetch(fetcher: (url: URL | RequestInfo, init?: RequestInit) => Promise): void; export declare function getFetch(): (url: URL | RequestInfo, init?: RequestInit) => Promise; /** * Does a fetch, but times out if it takes too long. * * @param url url to retrieve * @param fetchInit fetch configuration, initialization * @param timeoutSec maximum time to wait in seconds * @param fetcher optional fetch to use instead of global fetch * @returns promise to the result * @throws Error if time out or other failure */ export declare function doFetchWithTimeout(url: string | URL, fetchInit?: RequestInit | null, timeoutSec?: number, fetcher?: (url: URL | RequestInfo, init?: RequestInit) => Promise): Promise; /** * Allows downloading of in memory data, as ArrayBufferLike, to file as if * the user clicked a download link. * * @param data ArrayBufferLike to download * @param filename default filename * @param mimeType mimeType, default application/octet-stream */ export declare function downloadBlobAsFile(data: Uint8Array, filename: string, mimeType?: string): void; /** * Recursively calculates the mean of a slice of an array. This helps with * very long seismograms to equally weight each sample point without overflowing. * * @param dataSlice slice of a seismogram * @param totalPts number of points in the original seismogram * @returns sum of slice data points divided by totalPts */ export declare function meanOfSlice(dataSlice: Int32Array | Float32Array | Float64Array, totalPts: number): number; export declare const SVG_NS = "http://www.w3.org/2000/svg"; export declare const XHTML_NS = "http://www.w3.org/1999/xhtml"; export declare function createSVGElement(name: string): SVGElement; export declare function mightBeXml(buf: ArrayBufferLike): boolean; export declare function updateVersionText(selector?: string): void; /** * Parses a string of the form 'an+b', where 'a' is a positive integer (can be omitted if 1), 'n' is a * literal character, and 'b' is an integer (or omitted for zero). Examples include: '3n+1', * 'n', '2n', '4n-2'. The resulting 'b' value will be reduced to its smallest positive form; for * example, the previous example would return [4, 2] (-2 % 4 = 2), which is an equivalent representation * when considering the bias for an infinite series. * @param value String of the form 'an+b' * @returns The 'a' and 'b' values parsed and reduced from the given 'value' string, returned as an array */ export declare function anplusb(value: string | number): Array; //# sourceMappingURL=util.d.mts.map