"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var index_exports = {}; __export(index_exports, { arr: () => arr, cn: () => cn, date: () => date, debounce: () => debounce, documentoSchema: () => documentoSchema, emailSchema: () => emailSchema, num: () => num, obj: () => obj, passwordConfirmSchema: () => passwordConfirmSchema, passwordSchema: () => passwordSchema, phoneSchema: () => phoneSchema, required: () => required, safeParse: () => safeParse, sanitizedStr: () => sanitizedStr, storage: () => storage, str: () => str, throttle: () => throttle, urlSchema: () => urlSchema, uuidSchema: () => uuidSchema }); module.exports = __toCommonJS(index_exports); // src/utils/index.ts var date = { now: () => (/* @__PURE__ */ new Date()).toISOString(), format: (d, fmt = "YYYY-MM-DD HH:mm") => { const date2 = typeof d === "number" ? new Date(d) : new Date(d); const map = { YYYY: String(date2.getFullYear()), MM: String(date2.getMonth() + 1).padStart(2, "0"), DD: String(date2.getDate()).padStart(2, "0"), HH: String(date2.getHours()).padStart(2, "0"), mm: String(date2.getMinutes()).padStart(2, "0"), ss: String(date2.getSeconds()).padStart(2, "0") }; return fmt.replace(/YYYY|MM|DD|HH|mm|ss/g, (m) => map[m]); }, isToday: (d) => { const date2 = new Date(d); const today = /* @__PURE__ */ new Date(); return date2.toDateString() === today.toDateString(); }, daysBetween: (a, b) => Math.ceil((b.getTime() - a.getTime()) / 864e5) }; var str = { capitalize: (s) => s.charAt(0).toUpperCase() + s.slice(1).toLowerCase(), truncate: (s, max, suffix = "\u2026") => s.length <= max ? s : s.slice(0, max).trimEnd() + suffix, camelCase: (s) => s.replace(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : ""), kebabCase: (s) => s.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), slugify: (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, ""), removeAccents: (s) => s.normalize("NFD").replace(/[\u0300-\u036f]/g, ""), maskEmail: (email) => { const [user, domain] = email.split("@"); return user.length <= 2 ? `${user[0]}*@${domain}` : `${user[0]}${"*".repeat(user.length - 2)}${user.at(-1)}@${domain}`; } }; var num = { clamp: (value, min, max) => Math.min(Math.max(value, min), max), rand: (min, max) => Math.floor(Math.random() * (max - min + 1)) + min, format: (n) => n.toLocaleString("pt-BR"), percent: (part, total, decimals = 1) => { if (total === 0) return 0; return parseFloat((part / total * 100).toFixed(decimals)); } }; var CLEAN_CLASSES_REGEX = /\s+/g; function cn(...inputs) { return inputs.flat(2).filter(Boolean).join(" ").replace(CLEAN_CLASSES_REGEX, " ").trim(); } function debounce(fn, ms) { let timer; return (...args) => { clearTimeout(timer); timer = setTimeout(() => fn(...args), ms); }; } function throttle(fn, ms) { let last = 0; return (...args) => { const now = Date.now(); if (now - last >= ms) { last = now; fn(...args); } }; } var storage = { get: (key, fallback) => { try { const v = typeof localStorage !== "undefined" ? localStorage.getItem(key) : null; return v ? JSON.parse(v) : fallback; } catch { return fallback; } }, set: (key, value) => { localStorage.setItem(key, JSON.stringify(value)); }, remove: (key) => { try { localStorage.removeItem(key); } catch { } }, clear: (prefix) => { if (prefix) Object.keys(localStorage).filter((k) => k.startsWith(prefix)).forEach((k) => localStorage.removeItem(k)); else localStorage.clear(); } }; var arr = { unique: (items, key) => { if (!key) return [...new Set(items)]; return items.filter((v, i, a) => a.findIndex((item) => item[key] === v[key]) === i); }, chunk: (items, size) => { return Array.from({ length: Math.ceil(items.length / size) }, (_, i) => items.slice(i * size, i * size + size)); }, shuffle: (items) => [...items].sort(() => Math.random() - 0.5) }; var obj = { pick: (o, keys) => keys.reduce((r, k) => { if (k in o) r[k] = o[k]; return r; }, {}), omit: (o, keys) => Object.fromEntries(Object.entries(o).filter(([k]) => !keys.includes(k))), isEmpty: (o) => o == null || Object.keys(o).length === 0 }; // src/validators/index.ts var import_zod = require("zod"); var emailSchema = import_zod.z.string().trim().toLowerCase().email("Email inv\xE1lido").transform((v) => v); var passwordSchema = import_zod.z.string().min(8, "M\xEDnimo 8 caracteres").regex(/[A-Z]/, "Pelo menos 1 letra mai\xFAscula").regex(/[a-z]/, "Pelo menos 1 letra min\xFAscula").regex(/[0-9]/, "Pelo menos 1 n\xFAmero"); var passwordConfirmSchema = import_zod.z.object({ password: passwordSchema, confirm: import_zod.z.string() }).refine(({ password, confirm }) => password === confirm, { message: "Senhas n\xE3o coincidem", path: ["confirm"] }); var uuidSchema = import_zod.z.string().uuid("UUID inv\xE1lido"); var urlSchema = import_zod.z.string().url("URL inv\xE1lida").or(import_zod.z.literal("")).transform((v) => v === "" ? void 0 : v); var phoneSchema = import_zod.z.string().regex(/^(\+?55)?\s?\(?\d{2}\)?\s?\d{4,5}-?\d{4}$/, "Telefone inv\xE1lido \u2014 use (xx) xxxxx-xxxx"); var documentoSchema = import_zod.z.string().transform((v) => v.replace(/\D/g, "")).refine((v) => v.length === 11 || v.length === 14, { message: "CPF (11 d\xEDgitos) ou CNPJ (14 d\xEDgitos)" }); function required(schema, msg = "Campo obrigat\xF3rio") { return schema.refine((v) => !!v && String(v).trim().length > 0, { message: msg }); } var sanitizedStr = import_zod.z.string().transform((v) => v.replace(/<[^>]*>/g, "").trim()).pipe(import_zod.z.string().min(1)); function safeParse(schema, data) { const result = schema.safeParse(data); return result.success ? { success: true, data: result.data } : { success: false, errors: result.error }; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { arr, cn, date, debounce, documentoSchema, emailSchema, num, obj, passwordConfirmSchema, passwordSchema, phoneSchema, required, safeParse, sanitizedStr, storage, str, throttle, urlSchema, uuidSchema }); //# sourceMappingURL=index.js.map