/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
import{liteThrottle as r}from"../../../pacer-lite/dist/lite-throttler.js";import{formEventClient as e}from"./EventClient.js";function t(r,e){return"function"==typeof r?r(e):r}function n(r,e){return d(e).reduce((r,e)=>null===r?null:void 0!==r?r[e]:void 0,r)}function o(r,e,n){const o=d(e);return function r(e){if(!o.length)return t(n,e);const i=o.shift();if("string"==typeof i||"number"==typeof i&&!Array.isArray(e))return"object"==typeof e?(null===e&&(e={}),{...e,[i]:r(e[i])}):{[i]:r()};if(Array.isArray(e)&&"number"==typeof i){const t=e.slice(0,i);return[...t.length?t:new Array(i),r(e[i]),...e.slice(i+1)]}return[...new Array(i),r()]}(r)}function i(r,e){const t=d(e);return function r(e){if(!e)return;if(1===t.length){const r=t[0];if(Array.isArray(e)&&"number"==typeof r)return e.filter((e,t)=>t!==r);const{[r]:n,...o}=e;return o}const n=t.shift();if(("string"==typeof n||"number"==typeof n&&!Array.isArray(e))&&"object"==typeof e)return{...e,[n]:r(e[n])};if("number"==typeof n&&Array.isArray(e)){if(n>=e.length)return e;const t=e.slice(0,n);return[...t.length?t:new Array(n),r(e[n]),...e.slice(n+1)]}throw new Error("It seems we have created an infinite loop in deleteBy. ")}(r)}const a=/^(\d+)$/gm,s=/\.(\d+)(?=\.)/gm,u=/^(\d+)\./gm,c=/\.(\d+$)/gm,f=/\.{2,}/gm,l="__int__",y=`${l}$1`;function d(r){if(Array.isArray(r))return[...r];if("string"!=typeof r)throw new Error("Path must be a string.");return r.replace(/(^\[)|]/gm,"").replace(/\[/g,".").replace(a,y).replace(s,`.${y}.`).replace(u,`${y}.`).replace(c,`.${y}`).replace(f,".").split(".").map(r=>{if(r.startsWith(l)){const e=r.substring(l.length),t=parseInt(e,10);return String(t)===e?t:e}return r})}function m(r){return!(Array.isArray(r)&&0===r.length)}function p(r,e){return e.validationLogic({form:e.form,validators:e.validators,event:{type:r,async:!1},runValidation:r=>r.validators.filter(Boolean).map(r=>({cause:r.cause,validate:r.fn}))})}function g(r,e){const{asyncDebounceMs:t}=e,{onBlurAsyncDebounceMs:n,onChangeAsyncDebounceMs:o,onDynamicAsyncDebounceMs:i}=e.validators||{},a=t??0;return e.validationLogic({form:e.form,validators:e.validators,event:{type:r,async:!0},runValidation:e=>e.validators.filter(Boolean).map(e=>{const t=e?.cause||r;let s=a;switch(t){case"change":s=o??a;break;case"blur":s=n??a;break;case"dynamic":s=i??a;break;case"submit":s=0}return"submit"===r&&(s=0),{cause:t,validate:e.fn,debounceMs:s}})})}const b=r=>!!r&&"object"==typeof r&&"fields"in r;function v(r,e){if(Object.is(r,e))return!0;if("object"!=typeof r||null===r||"object"!=typeof e||null===e)return!1;if(r instanceof Date&&e instanceof Date)return r.getTime()===e.getTime();if(r instanceof Map&&e instanceof Map){if(r.size!==e.size)return!1;for(const[t,n]of r)if(!e.has(t)||!Object.is(n,e.get(t)))return!1;return!0}if(r instanceof Set&&e instanceof Set){if(r.size!==e.size)return!1;for(const t of r)if(!e.has(t))return!1;return!0}const t=Object.keys(r),n=Object.keys(e);if(t.length!==n.length)return!1;for(const o of t)if(!n.includes(o)||!v(r[o],e[o]))return!1;return!0}const w=({newFormValidatorError:r,isPreviousErrorFromFormValidator:e,previousErrorValue:t})=>r?{newErrorValue:r,newSource:"form"}:e?{newErrorValue:void 0,newSource:void 0}:t?{newErrorValue:t,newSource:"field"}:{newErrorValue:void 0,newSource:void 0},h=({formLevelError:r,fieldLevelError:e})=>e?{newErrorValue:e,newSource:"field"}:r?{newErrorValue:r,newSource:"form"}:{newErrorValue:void 0,newSource:void 0};function A(r,e){return null==r?e:{...r,...e}}let E=256;const V=[];let j;for(;E--;)V[E]=(E+256).toString(16).substring(1);function S(){let r,e=0,t="";if(!j||E+16>256){for(j=new Array(256),e=256;e--;)j[e]=256*Math.random()|0;e=0,E=0}for(;e<16;e++)r=j[E+e],t+=6===e?V[15&r|64]:8===e?V[63&r|128]:V[r],1&e&&e>1&&e<11&&(t+="-");return E++,t}const M=r(r=>e.emit("form-state",{id:r.formId,state:r.store.state}),{wait:300});export{i as deleteBy,h as determineFieldLevelErrorSourceAndValue,w as determineFormLevelErrorSourceAndValue,v as evaluate,t as functionalUpdate,g as getAsyncValidatorArray,n as getBy,p as getSyncValidatorArray,b as isGlobalFormValidationError,m as isNonEmptyArray,d as makePathArray,A as mergeOpts,o as setBy,M as throttleFormState,S as uuid};