"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 src_exports = {}; __export(src_exports, { arrayTransformMap: () => arrayTransformMap, deepGet: () => deepGet, getArrayValueByIndex: () => get, segmentation: () => segmentation, transformArray: () => transformArray, transformNumber: () => transformNumber, transformString: () => transformString, useCircularArray: () => useCircularArray }); module.exports = __toCommonJS(src_exports); // src/transform/index.ts function transformNumber(arg) { if (typeof arg === "number") { return isNaN(arg) ? 0 : arg; } if (!arg) return 0; if (typeof arg === "string") { const res = parseFloat(arg); return isNaN(res) ? 0 : res; } return 0; } function transformArray(arg) { if (typeof arg !== "string") return []; if (!arg) return []; return arg.split(","); } function transformString(arg) { if (Array.isArray(arg)) { return arg.join(","); } if (typeof arg === "string") { return arg; } if (typeof arg === "number" && !isNaN(arg)) { return arg.toString(); } return ""; } // src/segmentation.ts function segmentation(arr, fn) { const rowArr = []; let colArr = []; let index = 0; let length = arr.length; let realRemaining = 24; while (index < length) { let element = arr[index]; let span; if (typeof element === "number") { span = element; } else if (fn && typeof fn === "function") { span = fn(element); } else if (typeof element !== "number" && typeof element !== "object") { span = 0; } else if (typeof element !== "number" && !fn) { span = element.span; } else { span = 8; } const remaining = realRemaining - span; if (remaining > 0) { colArr.push(element); index++; realRemaining = remaining; if (index >= length) { rowArr.push(colArr); colArr = []; } } else if (remaining === 0) { colArr.push(element); rowArr.push(colArr); realRemaining = 24; colArr = []; index++; } else if (remaining < 0) { realRemaining = 24; rowArr.push(colArr); colArr = []; } else { } } return rowArr; } // src/deepGet.ts function deepGet(obj, ...selectors) { return selectors.map((s) => { return s.replace(/\[(\w+)\]/g, ".$1").split(".").reduce((prev, cur) => { return prev?.[cur]; }, obj); }); } // src/transform/arrayTransformMap.ts function arrayTransformMap(arr, key) { const map = /* @__PURE__ */ new Map(); for (let i = 0; i < arr.length; i++) { const item = arr[i]; const mapKey = item[key]; if (map.has(mapKey)) { map.get(mapKey)?.push(item); } else { map.set(mapKey, [item]); } } function get2(key2) { let keys = typeof key2 === "string" ? key2.trim().split(",") : Array.isArray(key2) ? key2 : (() => { throw "\u53C2\u6570\u5F02\u5E38 string | string[]"; })(); let result = []; keys.forEach((k) => { result.push(...map.get(k) || []); }); return result; } return { get: get2 }; } // src/array/value.ts function get(arr, i) { if (isNaN(i)) return void 0; const len = arr.length; if (len === 0) return void 0; i = i % len; if (i < 0) { i = len + i; } return arr[i]; } // src/array/circularArray.ts function useCircularArray(arr, groupNumber) { const getGroupByIndex = (groupIndex) => { const x = groupIndex * groupNumber; const y = (groupIndex + 1) * groupNumber; let temp = x; const group = []; while (temp < y) { group.push(get(arr, temp)); temp++; } return group; }; return { getGroupByIndex }; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { arrayTransformMap, deepGet, getArrayValueByIndex, segmentation, transformArray, transformNumber, transformString, useCircularArray });